semiotic 3.3.1 → 3.4.1

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.
Files changed (204) hide show
  1. package/CLAUDE.md +25 -6
  2. package/README.md +1 -1
  3. package/ai/dist/mcp-server.js +104 -9
  4. package/ai/schema.json +42 -1
  5. package/ai/system-prompt.md +4 -0
  6. package/dist/components/Annotation.d.ts +42 -2
  7. package/dist/components/CategoryColors.d.ts +1 -1
  8. package/dist/components/ChartGrid.d.ts +1 -1
  9. package/dist/components/ContextLayout.d.ts +1 -1
  10. package/dist/components/DataSummaryContext.d.ts +1 -1
  11. package/dist/components/DetailsPanel.d.ts +3 -2
  12. package/dist/components/Legend.d.ts +2 -3
  13. package/dist/components/LinkedCharts.d.ts +9 -1
  14. package/dist/components/ThemeProvider.d.ts +1 -1
  15. package/dist/components/Tooltip/FlippingTooltip.d.ts +1 -1
  16. package/dist/components/Tooltip/Tooltip.d.ts +4 -3
  17. package/dist/components/charts/geo/ChoroplethMap.d.ts +4 -4
  18. package/dist/components/charts/geo/DistanceCartogram.d.ts +5 -4
  19. package/dist/components/charts/geo/FlowMap.d.ts +4 -4
  20. package/dist/components/charts/geo/ProportionalSymbolMap.d.ts +4 -3
  21. package/dist/components/charts/index.d.ts +3 -1
  22. package/dist/components/charts/network/ChordDiagram.d.ts +4 -3
  23. package/dist/components/charts/network/CirclePack.d.ts +3 -3
  24. package/dist/components/charts/network/ForceDirectedGraph.d.ts +3 -2
  25. package/dist/components/charts/network/OrbitDiagram.d.ts +6 -5
  26. package/dist/components/charts/network/SankeyDiagram.d.ts +4 -3
  27. package/dist/components/charts/network/TreeDiagram.d.ts +3 -3
  28. package/dist/components/charts/network/Treemap.d.ts +3 -3
  29. package/dist/components/charts/ordinal/BarChart.d.ts +30 -4
  30. package/dist/components/charts/ordinal/BoxPlot.d.ts +4 -3
  31. package/dist/components/charts/ordinal/DonutChart.d.ts +4 -3
  32. package/dist/components/charts/ordinal/DotPlot.d.ts +13 -4
  33. package/dist/components/charts/ordinal/FunnelChart.d.ts +4 -3
  34. package/dist/components/charts/ordinal/GaugeChart.d.ts +2 -1
  35. package/dist/components/charts/ordinal/GroupedBarChart.d.ts +6 -5
  36. package/dist/components/charts/ordinal/Histogram.d.ts +4 -3
  37. package/dist/components/charts/ordinal/LikertChart.d.ts +8 -4
  38. package/dist/components/charts/ordinal/PieChart.d.ts +4 -3
  39. package/dist/components/charts/ordinal/RidgelinePlot.d.ts +4 -3
  40. package/dist/components/charts/ordinal/StackedBarChart.d.ts +6 -5
  41. package/dist/components/charts/ordinal/SwarmPlot.d.ts +4 -3
  42. package/dist/components/charts/ordinal/SwimlaneChart.d.ts +4 -3
  43. package/dist/components/charts/ordinal/ViolinPlot.d.ts +4 -3
  44. package/dist/components/charts/realtime/RealtimeHeatmap.d.ts +7 -6
  45. package/dist/components/charts/realtime/RealtimeHistogram.d.ts +10 -7
  46. package/dist/components/charts/realtime/RealtimeLineChart.d.ts +9 -6
  47. package/dist/components/charts/realtime/RealtimeSwarmChart.d.ts +7 -6
  48. package/dist/components/charts/realtime/RealtimeWaterfallChart.d.ts +9 -6
  49. package/dist/components/charts/shared/ChartError.d.ts +1 -2
  50. package/dist/components/charts/shared/annotationResolvers.d.ts +4 -3
  51. package/dist/components/charts/shared/annotationRules.d.ts +2 -1
  52. package/dist/components/charts/shared/colorUtils.d.ts +4 -3
  53. package/dist/components/charts/shared/datumTypes.d.ts +20 -0
  54. package/dist/components/charts/shared/diagnoseConfig.d.ts +2 -7
  55. package/dist/components/charts/shared/formatUtils.d.ts +4 -2
  56. package/dist/components/charts/shared/hooks.d.ts +41 -24
  57. package/dist/components/charts/shared/legendUtils.d.ts +3 -2
  58. package/dist/components/charts/shared/mergeShapeStyle.d.ts +43 -0
  59. package/dist/components/charts/shared/networkUtils.d.ts +7 -6
  60. package/dist/components/charts/shared/selectionUtils.d.ts +14 -11
  61. package/dist/components/charts/shared/statisticalOverlays.d.ts +14 -26
  62. package/dist/components/charts/shared/statisticalOverlaysLazy.d.ts +2 -2
  63. package/dist/components/charts/shared/statsTooltip.d.ts +3 -2
  64. package/dist/components/charts/shared/tooltipUtils.d.ts +20 -7
  65. package/dist/components/charts/shared/types.d.ts +27 -19
  66. package/dist/components/charts/shared/useChartSetup.d.ts +15 -6
  67. package/dist/components/charts/shared/useLikertAggregation.d.ts +18 -7
  68. package/dist/components/charts/shared/useOrdinalStreaming.d.ts +3 -2
  69. package/dist/components/charts/shared/useResolvedSelection.d.ts +2 -0
  70. package/dist/components/charts/shared/useStreamingLegend.d.ts +2 -1
  71. package/dist/components/charts/shared/validateChartData.d.ts +2 -1
  72. package/dist/components/charts/shared/validateProps.d.ts +2 -8
  73. package/dist/components/charts/shared/withChartWrapper.d.ts +1 -1
  74. package/dist/components/charts/xy/AreaChart.d.ts +4 -3
  75. package/dist/components/charts/xy/BubbleChart.d.ts +4 -3
  76. package/dist/components/charts/xy/CandlestickChart.d.ts +47 -0
  77. package/dist/components/charts/xy/ConnectedScatterplot.d.ts +4 -3
  78. package/dist/components/charts/xy/Heatmap.d.ts +12 -7
  79. package/dist/components/charts/xy/LineChart.d.ts +4 -3
  80. package/dist/components/charts/xy/MinimapChart.d.ts +4 -4
  81. package/dist/components/charts/xy/MultiAxisLineChart.d.ts +5 -4
  82. package/dist/components/charts/xy/QuadrantChart.d.ts +4 -3
  83. package/dist/components/charts/xy/Scatterplot.d.ts +4 -3
  84. package/dist/components/charts/xy/ScatterplotMatrix.d.ts +3 -3
  85. package/dist/components/charts/xy/StackedAreaChart.d.ts +4 -3
  86. package/dist/components/data/transforms.d.ts +8 -7
  87. package/dist/components/export/chartConfig.d.ts +4 -3
  88. package/dist/components/geo/mergeData.d.ts +2 -1
  89. package/dist/components/realtime/BinAccumulator.d.ts +3 -2
  90. package/dist/components/realtime/renderers/types.d.ts +2 -1
  91. package/dist/components/realtime/renderers/waterfallRenderer.d.ts +2 -1
  92. package/dist/components/realtime/types.d.ts +32 -16
  93. package/dist/components/semiotic-geo.d.ts +4 -0
  94. package/dist/components/semiotic-network.d.ts +7 -0
  95. package/dist/components/semiotic-ordinal.d.ts +8 -0
  96. package/dist/components/semiotic-themes.d.ts +2 -1
  97. package/dist/components/semiotic-xy.d.ts +11 -0
  98. package/dist/components/semiotic.d.ts +3 -3
  99. package/dist/components/server/animatedGif.d.ts +4 -18
  100. package/dist/components/server/renderToStaticSVG.d.ts +6 -5
  101. package/dist/components/server/serverChartConfigs.d.ts +2 -10
  102. package/dist/components/server/staticAnnotations.d.ts +2 -1
  103. package/dist/components/server/staticLegend.d.ts +2 -1
  104. package/dist/components/store/ObservationStore.d.ts +4 -3
  105. package/dist/components/store/SelectionStore.d.ts +3 -8
  106. package/dist/components/store/ThemeStore.d.ts +34 -4
  107. package/dist/components/store/TooltipStore.d.ts +1 -1
  108. package/dist/components/store/useSelection.d.ts +6 -5
  109. package/dist/components/stream/AccessibleDataTable.d.ts +5 -5
  110. package/dist/components/stream/CanvasHitTester.d.ts +10 -4
  111. package/dist/components/stream/DataSourceAdapter.d.ts +19 -1
  112. package/dist/components/stream/FocusRing.d.ts +1 -2
  113. package/dist/components/stream/GeoCanvasHitTester.d.ts +1 -1
  114. package/dist/components/stream/GeoParticlePool.d.ts +2 -1
  115. package/dist/components/stream/GeoPipelineStore.d.ts +26 -7
  116. package/dist/components/stream/MarginalGraphics.d.ts +1 -2
  117. package/dist/components/stream/NetworkPipelineStore.d.ts +8 -2
  118. package/dist/components/stream/NetworkSVGOverlay.d.ts +4 -4
  119. package/dist/components/stream/OrdinalBrushOverlay.d.ts +1 -19
  120. package/dist/components/stream/OrdinalCanvasHitTester.d.ts +3 -1
  121. package/dist/components/stream/OrdinalPipelineStore.d.ts +44 -6
  122. package/dist/components/stream/OrdinalSVGOverlay.d.ts +6 -5
  123. package/dist/components/stream/ParticlePool.d.ts +4 -0
  124. package/dist/components/stream/PipelineStore.d.ts +80 -30
  125. package/dist/components/stream/SVGOverlay.d.ts +10 -10
  126. package/dist/components/stream/SceneGraph.d.ts +6 -5
  127. package/dist/components/stream/StreamGeoFrame.d.ts +2 -1
  128. package/dist/components/stream/StreamNetworkFrame.d.ts +2 -1
  129. package/dist/components/stream/StreamOrdinalFrame.d.ts +2 -1
  130. package/dist/components/stream/StreamXYFrame.d.ts +19 -1
  131. package/dist/components/stream/XYBrushOverlay.d.ts +1 -21
  132. package/dist/components/stream/devDataAccessWarning.d.ts +2 -11
  133. package/dist/components/stream/geoTypes.d.ts +32 -18
  134. package/dist/components/stream/hoverUtils.d.ts +14 -1
  135. package/dist/components/stream/layouts/hierarchySceneBuilders.d.ts +4 -3
  136. package/dist/components/stream/layouts/hierarchyUtils.d.ts +4 -3
  137. package/dist/components/stream/networkTypes.d.ts +51 -28
  138. package/dist/components/stream/ordinalSceneBuilders/barFunnelScene.d.ts +1 -1
  139. package/dist/components/stream/ordinalSceneBuilders/barScene.d.ts +2 -2
  140. package/dist/components/stream/ordinalSceneBuilders/connectorScene.d.ts +1 -1
  141. package/dist/components/stream/ordinalSceneBuilders/pointScene.d.ts +2 -2
  142. package/dist/components/stream/ordinalSceneBuilders/statisticalScene.d.ts +4 -4
  143. package/dist/components/stream/ordinalSceneBuilders/swimlaneScene.d.ts +1 -1
  144. package/dist/components/stream/ordinalSceneBuilders/timelineScene.d.ts +1 -1
  145. package/dist/components/stream/ordinalSceneBuilders/types.d.ts +9 -8
  146. package/dist/components/stream/ordinalTypes.d.ts +102 -29
  147. package/dist/components/stream/pipelineDecay.d.ts +2 -1
  148. package/dist/components/stream/pipelinePulse.d.ts +2 -1
  149. package/dist/components/stream/pipelineTransitionUtils.d.ts +21 -0
  150. package/dist/components/stream/pipelineTransitions.d.ts +16 -4
  151. package/dist/components/stream/quadtreeHitTest.d.ts +22 -0
  152. package/dist/components/stream/renderers/colorUtils.d.ts +20 -0
  153. package/dist/components/stream/renderers/resolveCSSColor.d.ts +23 -6
  154. package/dist/components/stream/types.d.ts +63 -8
  155. package/dist/components/stream/useFrame.d.ts +122 -0
  156. package/dist/components/stream/xySceneBuilders/areaScene.d.ts +3 -2
  157. package/dist/components/stream/xySceneBuilders/barScene.d.ts +2 -1
  158. package/dist/components/stream/xySceneBuilders/boundsScene.d.ts +2 -1
  159. package/dist/components/stream/xySceneBuilders/candlestickScene.d.ts +2 -1
  160. package/dist/components/stream/xySceneBuilders/emitPointNodes.d.ts +3 -2
  161. package/dist/components/stream/xySceneBuilders/heatmapScene.d.ts +2 -1
  162. package/dist/components/stream/xySceneBuilders/lineScene.d.ts +2 -1
  163. package/dist/components/stream/xySceneBuilders/mixedScene.d.ts +2 -1
  164. package/dist/components/stream/xySceneBuilders/pointScene.d.ts +2 -1
  165. package/dist/components/stream/xySceneBuilders/swarmScene.d.ts +2 -1
  166. package/dist/components/stream/xySceneBuilders/types.d.ts +35 -26
  167. package/dist/components/stream/xySceneBuilders/waterfallScene.d.ts +2 -1
  168. package/dist/components/types/marginType.d.ts +15 -0
  169. package/dist/geo.min.js +1 -1
  170. package/dist/geo.module.min.js +1 -1
  171. package/dist/network.min.js +1 -1
  172. package/dist/network.module.min.js +1 -1
  173. package/dist/ordinal.min.js +1 -1
  174. package/dist/ordinal.module.min.js +1 -1
  175. package/dist/realtime.min.js +1 -1
  176. package/dist/realtime.module.min.js +1 -1
  177. package/dist/semiotic-ai.min.js +1 -1
  178. package/dist/semiotic-ai.module.min.js +1 -1
  179. package/dist/semiotic-geo.d.ts +4 -0
  180. package/dist/semiotic-network.d.ts +7 -0
  181. package/dist/semiotic-ordinal.d.ts +8 -0
  182. package/dist/semiotic-statisticalOverlays-Ckd_jM8z.js +1 -0
  183. package/dist/semiotic-themes.d.ts +2 -1
  184. package/dist/semiotic-themes.min.js +1 -1
  185. package/dist/semiotic-themes.module.min.js +1 -1
  186. package/dist/semiotic-utils.min.js +1 -1
  187. package/dist/semiotic-utils.module.min.js +1 -1
  188. package/dist/semiotic-xy.d.ts +11 -0
  189. package/dist/semiotic.d.ts +3 -3
  190. package/dist/semiotic.min.js +1 -1
  191. package/dist/semiotic.module.min.js +1 -1
  192. package/dist/server.min.js +1 -1
  193. package/dist/server.module.min.js +1 -1
  194. package/dist/test-utils/canvasMock.d.ts +35 -1
  195. package/dist/test-utils/ordinalFixtures.d.ts +48 -0
  196. package/dist/xy.min.js +1 -1
  197. package/dist/xy.module.min.js +1 -1
  198. package/package.json +50 -42
  199. package/dist/components/types/annotationTypes.d.ts +0 -145
  200. package/dist/components/types/generalTypes.d.ts +0 -241
  201. package/dist/components/types/interactionTypes.d.ts +0 -72
  202. package/dist/components/types/networkTypes.d.ts +0 -174
  203. package/dist/components/types/ordinalTypes.d.ts +0 -112
  204. package/dist/semiotic-statisticalOverlays-DGX_WWc5.js +0 -1
@@ -1 +1 @@
1
- "use strict";const e=require("react"),t=require("d3-interpolate"),r=require("d3-array"),n=require("d3-scale-chromatic"),o=require("d3-force"),i=require("d3-scale"),a=require("d3-chord"),s=require("d3-shape"),c=require("d3-hierarchy");function l(e){if(e&&e.__esModule)return e;const t=Object.create(null);if(e)for(const r in e)if("default"!==r){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}return t.default=e,Object.freeze(t)}const u=l(e);function d(e,t,r,n){return Object.assign(Object.assign(Object.assign({},function(e){return"object"!=typeof e||null===e||Array.isArray(e)?{}:e}(e)),{data:e,x:t,y:r,time:t,value:r}),n)}const h={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},y={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class g{constructor(e){this.capacity=e,this.particles=Array(e);for(let t=0;e>t;t++)this.particles[t]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0}}spawn(e){for(let t=0;this.capacity>t;t++){const r=this.particles[t];if(!r.active)return r.active=!0,r.t=0,r.offset=Math.random()-.5,r.edgeIndex=e,r.x=0,r.y=0,r}return null}step(e,t,r,n){var o;for(let i=0;this.capacity>i;i++){const a=this.particles[i];if(!a.active)continue;const s=r[a.edgeIndex];if(!s||!s.bezier){a.active=!1;continue}const c=n&&null!==(o=n[a.edgeIndex])&&void 0!==o?o:1;if(a.t+=e*t*c*(s.bezier.circular?.3:1),a.t>=1){a.active=!1;continue}const l=p(s.bezier,a.t,a.offset);a.x=l.x,a.y=l.y}}countForEdge(e){let t=0;for(let r=0;this.capacity>r;r++)this.particles[r].active&&this.particles[r].edgeIndex===e&&t++;return t}clear(){for(let e=0;this.capacity>e;e++)this.particles[e].active=!1}resize(e){if(this.capacity>=e)return;const t=this.particles;this.particles=Array(e);for(let r=0;e>r;r++)this.particles[r]=t.length>r?t[r]:{t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0};this.capacity=e}}function p(e,t,r){if(e.circular&&e.segments)return function(e,t,r,n){const o=e.length,i=t*o,a=Math.min(Math.floor(i),o-1),s=i-a,[c,l,u,d]=e[a],h=f(c,l,u,d,s),y=d.x-c.x,g=d.y-c.y,p=Math.sqrt(y*y+g*g);if(p>.001){const e=y/p;h.x+=-g/p*r*n*2,h.y+=e*r*n*2}return h}(e.segments,t,r,e.halfWidth);if(!e.points)return{x:0,y:0};const[n,o,i,a]=e.points,s=f(n,o,i,a,t),c=a.x-n.x,l=a.y-n.y,u=Math.sqrt(c*c+l*l);if(u>.001){const t=c/u;s.x+=-l/u*r*e.halfWidth*2,s.y+=t*r*e.halfWidth*2}return s}function f(e,t,r,n,o){const i=1-o,a=i*i,s=a*i,c=o*o,l=c*o;return{x:s*e.x+3*a*o*t.x+3*i*c*r.x+l*n.x,y:s*e.y+3*a*o*t.y+3*i*c*r.y+l*n.y}}function m(e,t){var r=e.get(t);if(!r)throw Error("missing: "+t);return r}function v(e,t){var r,n=[],o=[],i=[],a={},s=[];function c(e){i[e]=!1,a.hasOwnProperty(e)&&Object.keys(a[e]).forEach(function(t){delete a[e][t],i[t]&&c(t)})}function l(e){var t,n,d=!1;for(o.push(e),i[e]=!0,t=0;s[e].length>t;t++)(n=s[e][t])===r?(u(r,o),d=!0):i[n]||(d=l(n));if(d)c(e);else for(t=0;s[e].length>t;t++){var h=a[n=s[e][t]];h||(a[n]=h={}),h[n]=!0}return o.pop(),d}function u(e,t){var r=[].concat(t).concat(e);n.push(r)}function d(t){!function(t){for(var r=0;e.length>r;r++)r>=t&&e[r]||(e[r]=[]),e[r]=e[r].filter(function(e){return e>=t})}(t);for(var r,n=function(e){for(var t=e.length,r=Array(t),n=Array(t),o=Array(t),i=Array(t),a=Array(t),s=Array(t),c=0;t>c;++c)r[c]=-1,n[c]=0,o[c]=!1,i[c]=0,a[c]=-1,s[c]=[];var l,u=0,d=[],h=[];function y(t){var c=[t],l=[t];for(r[t]=n[t]=u,o[t]=!0,u+=1;l.length>0;){var y=e[t=l[l.length-1]];if(y.length>i[t]){for(var g=i[t];y.length>g;++g){var p=y[g];if(0>r[p]){r[p]=n[p]=u,o[p]=!0,u+=1,c.push(p),l.push(p);break}o[p]&&(n[t]=0|Math.min(n[t],n[p])),0>a[p]||s[t].push(a[p])}i[t]=g}else{if(n[t]===r[t]){var f=[],m=[],v=0;for(g=c.length-1;g>=0;--g){var b=c[g];if(o[b]=!1,f.push(b),m.push(s[b]),v+=s[b].length,a[b]=d.length,b===t){c.length=g;break}}d.push(f);var x=Array(v);for(g=0;m.length>g;g++)for(var k=0;m[g].length>k;k++)x[--v]=m[g][k];h.push(x)}l.pop()}}}for(c=0;t>c;++c)0>r[c]&&y(c);for(c=0;h.length>c;c++){var g=h[c];if(0!==g.length){g.sort(function(e,t){return e-t}),l=[g[0]];for(var p=1;g.length>p;p++)g[p]!==g[p-1]&&l.push(g[p]);h[c]=l}}return{components:d,adjacencyList:h}}(e),o=n.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],r=a);var c=o[r];if(!c)return!1;var l=e.map(function(e,t){return-1===c.indexOf(t)?[]:e.filter(function(e){return-1!==c.indexOf(e)})});return{leastVertex:i,adjList:l}}r=0;for(var h=e.length;h>r;){var y=d(r);if(r=y.leastVertex,s=y.adjList){for(var g=0;s.length>g;g++)for(var p=0;s[g].length>p;p++){var f=s[g][p];i[+f]=!1,a[f]={}}l(r),r+=1}else r=h}return n}function b(e){return e.y0-e.y1>0?"up":"down"}function x(e,t){return t(e.source)==t(e.target)}function k(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var r=0;return e.target.targetLinks.forEach(function(e){r=e.circular?r+1:r}),1>=t&&1>=r}function A(e){return e.target.x0-e.source.x1}function w(e,t){var r=E(e),n=A(t)/Math.tan(r);return"up"==b(e)?e.y1-n:e.y1+n}function S(e,t){var r=E(e),n=A(t)/Math.tan(r);return"up"==b(e)?e.y1+n:e.y1-n}function E(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function O(e,t){return t(e)}function L(e){return C(e.source)}function j(e){return C(e.target)}function C(e){return(e.y0+e.y1)/2}function D(e){return e.virtual?0:e.value}function M(e,t){var r=0;e.sourceLinks.forEach(function(e){r=e.circular&&!x(e,t)?r+1:r});var n=0;return e.targetLinks.forEach(function(e){n=e.circular&&!x(e,t)?n+1:n}),r+n}function I(e){return e.target.depth}function P(e,t){return e.sourceLinks.length?e.depth:t-1}function T(e,t){return e.y0-t.y0}function N(e,t){return t.y0-e.y0}function _(e,t){return e.y1-t.y1}function $(e,t){return t.y1-e.y1}function B(e,t){return W(e.source,t.source)||e.index-t.index}function R(e,t){return W(e.target,t.target)||e.index-t.index}function W(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function z(e,t){return H(e)==H(t)?"bottom"==e.circularLinkType?N(e,t):T(e,t):H(t)-H(e)}function H(e){return e.target.column-e.source.column}function F(e,t){return q(e)==q(t)}function q(e){return e.y0-e.y1>0?"up":"down"}function Y(e,t,n,o,i){let a=e;var s=Math.max(8,.15*(a.y1-a.y0));a.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,s))});var c=r.min(a.links,function(e){return e.source.y0});a.links.forEach(function(e){e.circular&&(e.circularPathData={})});var l=a.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}),G(a.links.filter(function(e){return"top"==e.circularLinkType}),t,n),G(a.links.filter(function(e){return"bottom"==e.circularLinkType}),t,n),a.links.forEach(function(e){if(e.circular){if(e.circularPathData.arcRadius=e._circularWidth+o,e.circularPathData.rightNodeBuffer=5,e.circularPathData.leftNodeBuffer=5,e.circularPathData.sourceWidth=e.source.x1-e.source.x0,e.circularPathData.sourceX=e.source.x0+e.circularPathData.sourceWidth,e.circularPathData.targetX=e.target.x0,e.circularPathData.sourceY=e.y0,e.circularPathData.targetY=e.y1,x(e,t)&&k(e))e.circularPathData.rightSmallArcRadius=o+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=o+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=o+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=o+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+i+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-i-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius);else{var r=e.source.column,s=e.circularLinkType,l=a.links.filter(function(e){return e.source.column==r&&e.circularLinkType==s});l.sort("bottom"==e.circularLinkType?N:T);var u=0;l.forEach(function(t,r){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=o+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=o+e._circularWidth/2+r*n+u),u+=t._circularWidth||t.width}),r=e.target.column,(l=a.links.filter(function(e){return e.target.column==r&&e.circularLinkType==s})).sort("bottom"==e.circularLinkType?$:_),u=0,l.forEach(function(t,r){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=o+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=o+e._circularWidth/2+r*n+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(a.y1,e.source.y1,e.target.y1)+i+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=c-i-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius)}e.circularPathData.rightInnerExtent=e.circularPathData.sourceX+e.circularPathData.rightNodeBuffer,e.circularPathData.leftInnerExtent=e.circularPathData.targetX-e.circularPathData.leftNodeBuffer,e.circularPathData.rightFullExtent=e.circularPathData.sourceX+e.circularPathData.rightLargeArcRadius+e.circularPathData.rightNodeBuffer,e.circularPathData.leftFullExtent=e.circularPathData.targetX-e.circularPathData.leftLargeArcRadius-e.circularPathData.leftNodeBuffer}e.path=e.circular?function(e){return"top"==e.circularLinkType?"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 0 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY-e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 0 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 0 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY-e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 0 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY:"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 1 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY+e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 1 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 1 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY+e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 1 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY}(e):function(e){var t=e.source.x1,r=e.y0,n=e.target.x0,o=e.y1,i=(t+n)/2;return"M"+t+","+r+"C"+i+","+r+" "+i+","+o+" "+n+","+o}(e)}),a}function G(e,t,r){e.sort(z);var n=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(x(e,t)&&k(e))e.circularPathData.verticalBuffer=i+e._circularWidth/2;else{for(var a=0;n.length>a;a++){var s=n[a];if(s!==e&&s.circularPathData&&void 0!==s.circularPathData.verticalBuffer&&X(e,s)){var c=s.circularPathData.verticalBuffer+(s._circularWidth||s.width)/2+r;i=c>i?c:i}}e.circularPathData.verticalBuffer=i+e._circularWidth/2}}),e}function X(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}function V(e){return function(){return e}}function K(e){return e.index}function U(e){return e.nodes}function Z(e){return e.links}function Q(e,t,n){var o=r.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});o.forEach(function(r,i){var a=r.length;if(t)r.sort(t);else if(i>0){var s=new Map;r.forEach(function(e,t){var r,n,o,i=(n=0,o=0,(r=e).targetLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=C(e.source)*t,n+=t}}),r.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=C(e.target)*t,n+=t}}),n>0?o/n:NaN);s.set(e,{bc:i,idx:t})}),r.sort(function(e,t){var r=s.get(e),n=s.get(t),o=r.bc,i=n.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)?r.idx-n.idx:1:-1:o-i})}else r.sort(function(e,t){return e.circularLinkType==t.circularLinkType?M(t,n)-M(e,n):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0});r.forEach(function(t,r){t.depth==o.length-1&&1==a||0==t.depth&&1==a?(t.y0=e.y1/2-t.value*e.ky,t.y1=t.y0+t.value*e.ky):t.partOfCycle?0==M(t,n)?(t.y0=e.y1/2+r,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+r,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-r,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/a*r,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-a/2+r,t.y1=t.y0+t.value*e.ky)})})}function J(e,t,n,o,i,a){var s=r.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});d();for(var c=1,l=a;l>0;--l)u(c*=.99,n),d();function u(t,n){var o=s.length;s.forEach(function(i){var a=i.length,s=i[0].depth;i.forEach(function(i){var c;if(i.sourceLinks.length||i.targetLinks.length)if(i.partOfCycle&&M(i,n)>0){var l=r.mean(i.sourceLinks,j),u=r.mean(i.targetLinks,L),d=l&&u?(l+u)/2:l||u;if(d){var h=(d-C(i))*t*.3;i.y0+=h,i.y1+=h}}else if(0==s&&1==a)i.y0=e.y1/2-(c=i.y1-i.y0)/2,i.y1=e.y1/2+c/2;else if(s==o-1&&1==a)i.y0=e.y1/2-(c=i.y1-i.y0)/2,i.y1=e.y1/2+c/2;else if(1==i.targetLinks.length&&1==i.targetLinks[0].source.sourceLinks.length)c=i.y1-i.y0,i.y0=i.targetLinks[0].source.y0,i.y1=i.y0+c;else{var y=r.mean(i.sourceLinks,j),g=r.mean(i.targetLinks,L),p=((y&&g?(y+g)/2:y||g)-C(i))*t;i.y0+=p,i.y1+=p}})})}function d(){s.forEach(function(r){var n,a,s,c=e.y0,l=r.length;for(r.sort(t||W),s=0;l>s;++s)(a=c-(n=r[s]).y0)>0&&(n.y0+=a,n.y1+=a),c=n.y1+o;if((a=c-o-e.y1)>0)for(c=n.y0-=a,n.y1-=a,s=l-2;s>=0;--s)(a=(n=r[s]).y1+i-c)>0&&(n.y0-=a,n.y1-=a),c=n.y0})}}function ee(e){e.nodes.forEach(function(e){e.sourceLinks.sort(R),e.targetLinks.sort(B)}),e.nodes.forEach(function(e){var t=e.y0,r=t,n=e.y1,o=n;e.sourceLinks.forEach(function(e){e.circular?(e.y0=n-e.width/2,n-=e.width):(e.y0=t+e.width/2,t+=e.width)}),e.targetLinks.forEach(function(e){e.circular?(e.y1=o-e.width/2,o-=e.width):(e.y1=r+e.width/2,r+=e.width)})})}function te(){var e=0,t=0,n=1,o=1,i=24,a=8,s=null,c=K,l=P,u=void 0,d=32,h=2,y=U,g=Z;function p(){var p={nodes:y.apply(null,arguments),links:g.apply(null,arguments)};return function(y){y.x0=e,y.y0=t,y.x1=n,y.y1=o,y.py=0,function(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var n=function(e,t){var n=new Map;return r.group(e,t).forEach(function(e,t){n.set(t,e[0])}),n}(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var r=e.source,o=e.target;"object"!=typeof r&&(r=e.source=m(n,r)),"object"!=typeof o&&(o=e.target=m(n,o)),r.sourceLinks.push(e),o.targetLinks.push(e)})}(y,c),function(e,t){var r=0;if(null==t){for(var n=[],o=0;e.links.length>o;o++){var i=e.links[o],a=i.source.index,s=i.target.index;n[a]||(n[a]=[]),n[s]||(n[s]=[]),-1===n[a].indexOf(s)&&n[a].push(s)}var c=v(n);c.sort(function(e,t){return e.length-t.length});var l={};for(o=0;c.length>o;o++){var u=c[o].slice(-2);l[u[0]]||(l[u[0]]={}),l[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,n=e.source.index;t===n||l[n]&&l[n][t]?(e.circular=!0,e.circularLinkID=r++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=r++)})}(y,u),function(e,t){var r=0,n=0;e.links.forEach(function(o){o.circular&&(o.circularLinkType=o.source.circularLinkType||o.target.circularLinkType?o.source.circularLinkType?o.source.circularLinkType:o.target.circularLinkType:n>r?"top":"bottom","top"==o.circularLinkType?r++:n++,e.nodes.forEach(function(e){O(e,t)!=O(o.source,t)&&O(e,t)!=O(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),x(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(y,c),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(r.sum(e.sourceLinks,D),r.sum(e.targetLinks,D)),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)})})}(y),function(e,t,r){var n,o,i;if(null!=t){e.nodes.sort(function(e,r){return t(e)<t(r)?-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(n=e.nodes,o=[],i=0;n.length;++i,n=o,o=[])n.forEach(function(e){e.depth=i,e.sourceLinks.forEach(function(e){0>o.indexOf(e.target)&&!e.circular&&o.push(e.target)})});for(n=e.nodes,o=[],i=0;n.length;++i,n=o,o=[])n.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?r(e,i):e.column})}(y,u,l);var g=a;if(null!==s){var p=r.groups(y.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),f=r.max(p,function(e){return e.length});f>1&&(g=Math.max(1,(o-t)*s/(f-1)))}(function(e,t,n){var o=r.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});e.py=t;var i=r.min(o,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/r.sum(t,function(e){return e.value})});e.ky=i,e.links.forEach(function(t){t.width=t.value*e.ky});var a=r.max(e.nodes,function(e){return e.column});e.nodes.forEach(a>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-n)/a),t.x1=t.x0+n}:function(t){t.x0=e.x0,t.x1=t.x0+n})})(y,g,i),Q(y,u,c),J(y,u,c,g,g,d),ee(y),Y(y,c,h,10,8),Q(y,u,c),J(y,u,c,g,g,d),ee(y),Y(y,c,h,10,8),function(e,t){let r=e;r.nodes.forEach(function(e){e.y+(e.y1-e.y0)>r.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-r.y1));var n=r.links.filter(function(r){return O(r.source,t)==O(e,t)}),o=n.length;o>1&&n.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!F(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var r=w(t,e);return e.y1-r}if(t.target.column>e.target.column)return w(e,t)-t.y1}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.target.column===t.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.target.column===t.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;n.forEach(function(e){e.y0=i+e.width/2,i+=e.width}),n.forEach(function(t,r){if("bottom"==t.circularLinkType){for(var i=r+1,a=0;o>i;i++)a+=n[i].width;t.y0=e.y1-a-t.width/2}})})}(y,c),function(e,t){let r=e;r.nodes.forEach(function(e){var n=r.links.filter(function(r){return O(r.target,t)==O(e,t)}),o=n.length;o>1&&n.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!F(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var r=S(t,e);return e.y0-r}if(t.source.column>e.source.column)return S(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;n.forEach(function(e){e.y1=i+e.width/2,i+=e.width}),n.forEach(function(t,r){if("bottom"==t.circularLinkType){for(var i=r+1,a=0;o>i;i++)a+=n[i].width;t.y1=e.y1-a-t.width/2}})})}(y,c),function(e){var t=e.nodes,n=e.links,o=!1,i=!1;if(n.forEach(function(e){"top"==e.circularLinkType?o=!0:"bottom"==e.circularLinkType&&(i=!0)}),0==o||0==i){var a=r.min(t,function(e){return e.y0}),s=r.max(t,function(e){return e.y1}),c=(e.y1-e.y0)/(s-a);function l(t){return(t-a)/(s-a)*(e.y1-e.y0)+e.y0}1>c?(t.forEach(function(e){e.y0=l(e.y0),e.y1=l(e.y1)}),n.forEach(function(e){e.y0=l(e.y0),e.y1=l(e.y1),e.width=e.width*c})):t.forEach(function(e){var t=e.y1-e.y0,r=l(e.y0)-e.y0;e.y0=l(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+r}),e.targetLinks.forEach(function(e){e.y1=e.y1+r})})}}(y),Y(y,c,h,10,8)}(p),p}return p.update=function(e){return ee(e),Y(e,c,h,10,8),e},p.nodeWidth=function(e){return arguments.length?(i=+e,p):i},p.nodePadding=function(e){return arguments.length?(a=+e,p):a},p.nodePaddingRatio=function(e){return arguments.length?(s=+e,p):s},p.nodes=function(e){return arguments.length?(y="function"==typeof e?e:V(e),p):y},p.links=function(e){return arguments.length?(g="function"==typeof e?e:V(e),p):g},p.nodeId=function(e){return arguments.length?(c="function"==typeof e?e:V(e),p):c},p.nodeAlign=function(e){return arguments.length?(l="function"==typeof e?e:V(e),p):l},p.nodeSort=function(e){return arguments.length?(u=e,p):u},p.iterations=function(e){return arguments.length?(d=+e,p):d},p.circularLinkGap=function(e){return arguments.length?(h=+e,p):h},p.extent=function(r){return arguments.length?(e=+r[0][0],t=+r[0][1],n=+r[1][0],o=+r[1][1],p):[[e,t],[n,o]]},p.size=function(r){return arguments.length?(e=t=0,n=+r[0],o=+r[1],p):[n-e,o-t]},p}const re=e=>{let r,n,o,i,a,s,c,l,u;return"down"===e.direction?(r=e.y0-e.sankeyWidth/2,n=e.y1-e.sankeyWidth/2,o=e.y1+e.sankeyWidth/2,i=e.y0+e.sankeyWidth/2,a=e.source.x1,s=e.target.x0,c=t.interpolateNumber(a,s),l=c(.5),u=c(.5),`M${r},${a}C${r},${l} ${n},${u} ${n},${s}L${o},${s}C${o},${u} ${i},${l} ${i},${a}Z`):(r=e.source.x1,n=e.target.x0,c=t.interpolateNumber(r,n),o=c(.5),i=c(.5),a=e.y0-e.sankeyWidth/2,s=e.y1-e.sankeyWidth/2,l=e.y1+e.sankeyWidth/2,u=e.y0+e.sankeyWidth/2,`M${r},${a}C${o},${a} ${i},${s} ${n},${s}L${n},${l}C${i},${l} ${o},${u} ${r},${u}Z`)};function ne(e){var t;const r=e.sankeyWidth/2,n=(null!==(t=e._circularWidth)&&void 0!==t?t:e.sankeyWidth)/2,o=e.circularPathData;if(!o)return null;if("down"===e.direction)return null;if(e._circularStub){const t=o.sourceX,n=o.sourceY,i=o.targetX,a=o.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*(o.rightFullExtent-t))),c=Math.max(15,Math.min(40,.33*(i-o.leftFullExtent)));return`M${t},${n-r}L${t+s},${n-r}L${t+s},${n+r}L${t},${n+r}ZM${i},${a-r}L${i-c},${a-r}L${i-c},${a+r}L${i},${a+r}Z`}const i=o.sourceX,a=o.sourceY,s=o.targetX,c=o.targetY,l=o.rightFullExtent,u=o.leftFullExtent,d=o.verticalFullExtent,h="bottom"===e.circularLinkType?1:-1,y=Math.max(4,Math.min(n,15));return`M${i},${a-h*r}L${l},${a-h*r}L${l+n},${a-h*r+h*y}L${l+n},${d+h*n-h*y}L${l+n-y},${d+h*n}L${u-n+y},${d+h*n}L${u-n},${d+h*n-h*y}L${u-n},${c-h*r+h*y}L${u-n+y},${c-h*r}L${s},${c-h*r}L${s},${c+h*r}L${u+n},${c+h*r}L${u+n},${d-h*n}L${l-n},${d-h*n}L${l-n},${a+h*r}L${i},${a+h*r}Z`}const oe=new Set,ie=new WeakMap;function ae(e,t){if("production"===process.env.NODE_ENV)return e;if(!e||!e.data||"object"!=typeof e.data)return e;let r=ie.get(e);if(r){const e=r.get(t);if(e)return e}else r=new Map,ie.set(e,r);const n=new Proxy(e,{get(e,r,n){if("string"==typeof r&&!(r in e)&&e.data&&r in e.data){const e=`${t}:${r}`;oe.has(e)||(oe.add(e),console.warn(`[Semiotic] "${t}" callback accessed "${r}" on the wrapper object, but it only exists on ".data". Use d.data.${r} (or d.data?.${r}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(e,r,n)}});return r.set(t,n),n}const se={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(I))-1:0},justify:P},ce={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,r,n){var o,i,a,s,c,l,u;if(0===e.length)return;const d="vertical"===r.orientation?"down":"right",h=r.nodeAlign||"justify",y=null!==(o=r.nodeWidth)&&void 0!==o?o:15,g=null!==(i=r.nodePaddingRatio)&&void 0!==i?i:.05,p=null!==(a=r.iterations)&&void 0!==a?a:100,f=e.map(e=>Object.assign({},e)),m=t.map(e=>Object.assign(Object.assign({},e),{source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id,value:Math.sqrt(Math.max(1,e.value||1))}));let v;v="down"===d?[[0,0],[n[1],n[0]]]:[[0,0],[n[0],n[1]]];const b=te().extent(v).links(m).nodes(f).nodeAlign(se[h]||P).nodeId(e=>e.id).nodeWidth(y).iterations(p);b.nodePaddingRatio&&b.nodePaddingRatio(g),b();{let e=1/0,t=-1/0,r=1/0,o=-1/0;for(const n of f)e>n.x0&&(e=n.x0),n.x1>t&&(t=n.x1),r>n.y0&&(r=n.y0),n.y1>o&&(o=n.y1);for(const n of m){if(!n.circular||!n.circularPathData)continue;const i=n.circularPathData,a=(null!==(c=null!==(s=n._circularWidth)&&void 0!==s?s:n.width)&&void 0!==c?c:0)/2;e>i.leftFullExtent-a&&(e=i.leftFullExtent-a),i.rightFullExtent+a>t&&(t=i.rightFullExtent+a),r>i.verticalFullExtent-a&&(r=i.verticalFullExtent-a),i.verticalFullExtent+a>o&&(o=i.verticalFullExtent+a)}const i=t-e,a=o-r,u=n[0],d=n[1];if(i>0&&a>0&&(0>e||0>r||t>u||o>d)){const t=Math.min(u/i,d/a),n=-e*t+(u-i*t)/2,o=-r*t+(d-a*t)/2;for(const e of f)e.x0=e.x0*t+n,e.x1=e.x1*t+n,e.y0=e.y0*t+o,e.y1=e.y1*t+o;for(const e of m)if(e.y0=e.y0*t+o,e.y1=e.y1*t+o,e.width=(null!==(l=e.width)&&void 0!==l?l:0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){const r=e.circularPathData;r.sourceX=r.sourceX*t+n,r.targetX=r.targetX*t+n,r.sourceY=r.sourceY*t+o,r.targetY=r.targetY*t+o,r.rightFullExtent=r.rightFullExtent*t+n,r.leftFullExtent=r.leftFullExtent*t+n,r.verticalFullExtent=r.verticalFullExtent*t+o,r.rightInnerExtent=r.rightInnerExtent*t+n,r.leftInnerExtent=r.leftInnerExtent*t+n,r.verticalRightInnerExtent=r.verticalRightInnerExtent*t+o,r.verticalLeftInnerExtent=r.verticalLeftInnerExtent*t+o,r.rightSmallArcRadius*=t,r.rightLargeArcRadius*=t,r.leftSmallArcRadius*=t,r.leftLargeArcRadius*=t,r.sourceWidth*=t,r.rightNodeBuffer*=t,r.leftNodeBuffer*=t,r.arcRadius*=t}}}const x=new Map;for(const t of e)x.set(t.id,t);for(const e of f){const t=x.get(e.id);t&&(t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.value=e.value,t.depth=e.depth,t.sourceLinks=e.sourceLinks,t.targetLinks=e.targetLinks,t.width=e.x1-e.x0,t.height=e.y1-e.y0,t.x=e.x0+(e.x1-e.x0)/2,t.y=e.y0+(e.y1-e.y0)/2)}const k=new Map;for(const e of t)k.set(e._edgeKey?e._edgeKey:`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const e of m){const t=e.source,r=e.target,n="object"==typeof t&&null!==t?t.id:t+"",o="object"==typeof r&&null!==r?r.id:r+"",i=k.get(e._edgeKey?e._edgeKey:`${n}\0${o}`);if(i){i.y0=e.y0,i.y1=e.y1,i.sankeyWidth=null!==(u=e.width)&&void 0!==u?u:0,i.circular=!!e.circular,i.circularPathData=e.circularPathData,i._circularWidth=e._circularWidth,i._circularStub=e._circularStub,i.path=e.path,i.circularLinkType=e.circularLinkType,i.direction=d;const t=x.get(n),r=x.get(o);t&&(i.source=t),r&&(i.target=r)}}},buildScene(e,t,r,o){var i,a,s,c;const l="vertical"===r.orientation?"down":"right",u=r.nodeStyle,d=r.edgeStyle,h=null!==(i=r.edgeOpacity)&&void 0!==i?i:.5,y=r.edgeColorBy||"source",g=Array.isArray(r.colorScheme)?r.colorScheme:n.schemeCategory10,p=new Map;e.forEach((e,t)=>{p.set(e.id,g[t%g.length])});const f=[],m=[],v=[],b=new Map;for(const t of e){const e=t.x1-t.x0,r=t.y1-t.y0;if(0>=e||0>=r)continue;const n=u?u(ae(t,"nodeStyle")):{},o={fill:n.fill||p.get(t.id)||"#4d430c",stroke:n.stroke,strokeWidth:n.strokeWidth,opacity:n.opacity};b.set(t.id,("string"==typeof o.fill?o.fill:null)||p.get(t.id)||"#4d430c"),f.push("down"===l?{type:"rect",x:t.y0,y:t.x0,w:r,h:e,style:o,datum:t,id:t.id,label:t.id}:{type:"rect",x:t.x0,y:t.y0,w:e,h:r,style:o,datum:t,id:t.id,label:t.id})}const x=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of x){if(!e.sankeyWidth||0>=e.sankeyWidth)continue;const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;if(!t||!r)continue;let n="#999";n="function"==typeof y?y(e)||n:"target"===y?b.get(r.id)||p.get(r.id)||n:b.get(t.id)||p.get(t.id)||n;const o=d?d(ae(e,"edgeStyle")):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,r=e.sankeyWidth/2,i=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),c=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),l=o.fill||n;m.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-r}L${t.sourceX+i},${t.sourceY-r}L${t.sourceX+i},${t.sourceY+r}L${t.sourceX},${t.sourceY+r}Z`,style:{fill:l,fillOpacity:null!==(a=o.fillOpacity)&&void 0!==a?a:h,stroke:"none",opacity:o.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+i}}),m.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-r}L${t.targetX-c},${t.targetY-r}L${t.targetX-c},${t.targetY+r}L${t.targetX},${t.targetY+r}Z`,style:{fill:l,fillOpacity:null!==(s=o.fillOpacity)&&void 0!==s?s:h,stroke:"none",opacity:o.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-c,x1:t.targetX}});continue}let i;if(i=e.circular&&e.circularPathData?ne(e):re(e),!i)continue;const l={fill:o.fill||n,fillOpacity:null!==(c=o.fillOpacity)&&void 0!==c?c:h,stroke:o.stroke||"none",strokeWidth:o.strokeWidth,opacity:o.opacity};m.push({type:"bezier",pathD:i,bezierCache:e.bezier,style:l,datum:e})}if(!1!==r.showLabels){const t=(k=r.nodeLabel)?"function"==typeof k?k:e=>e[k]||e.id:null;for(const r of e){const e=r.x1-r.x0,n=r.y1-r.y0;if(0>=e||0>=n)continue;const i=t?t(r):r.id;if(!i)continue;let a,s,c;"down"===l?(a=r.y0+(r.y1-r.y0)/2,s=r.x1+14,c="middle"):(o[0]/2>r.x0+e/2?(a=r.x0-6,c="end"):(a=r.x1+6,c="start"),s=r.y0+n/2),v.push({x:a,y:s,text:i+"",anchor:c,baseline:"middle",fontSize:11})}}var k;return{sceneNodes:f,sceneEdges:m,labels:v}}},le={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,r,n){var i,a;if(0===e.length)return;const s=null!==(i=r.forceStrength)&&void 0!==i?i:.1,c=n[0]/2,l=n[1]/2,u=r.__previousPositions;let d=0;const h=[];for(const t of e){const e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),r=null==u?void 0:u.get(t.id);e?d++:r?(t.x=r.x,t.y=r.y,d++):h.push(t)}const y=d>0&&.3>=(e.length>0?h.length/e.length:1);if(y){const r=new Map;for(const t of e)r.set(t.id,t);for(const e of h){const n=ue(e.id,t,r);if(n.length>0){let t=0,r=0;for(const e of n)t+=e.x,r+=e.y;const o=de(e.id),i=o%360*(Math.PI/180),a=10+o%20;e.x=t/n.length+a*Math.cos(i),e.y=r/n.length+a*Math.sin(i)}else{const t=de(e.id),r=t%360*(Math.PI/180),n=15+t%30;e.x=c+n*Math.cos(r),e.y=l+n*Math.sin(r)}}}else{const t=2.399963229728653;for(let r=0;e.length>r;r++){const n=e[r];if(null==n.x||null==n.y||0===n.x&&0===n.y){const e=10*Math.sqrt(r+.5),o=r*t;n.x=c+e*Math.cos(o),n.y=l+e*Math.sin(o)}}}const g=null!==(a=r.iterations)&&void 0!==a?a:Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),p=0===r.iterations?0:y?40:g,f=he(r.nodeSize,r.nodeSizeRange,e),m=e=>f(e);if(p>0){const r=o.forceLink().strength(e=>Math.min(2.5,e.weight?e.weight*s:s)).id(e=>e.id),n=o.forceSimulation().force("charge",o.forceManyBody().strength(e=>-25*m(e))).force("center",o.forceCenter(c,l).strength(.8)).force("x",o.forceX(c).strength(.15)).force("y",o.forceY(l).strength(.15));if(n.nodes(e),t.length>0){const e=t.map(e=>Object.assign(Object.assign({},e),{source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id}));n.force("link",r),n.force("link").links(e)}y?n.alpha(.3):.1>n.alpha()&&n.alpha(1),n.stop();for(let e=0;p>e;++e)n.tick()}for(const t of e){if(null==t.x||null==t.y)continue;const e=m(t);t.x=Math.max(e,Math.min(n[0]-e,t.x)),t.y=Math.max(e,Math.min(n[1]-e,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}const v=new Map;for(const t of e)v.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=v.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=v.get(e.target);t&&(e.target=t)}}},buildScene(e,t,r,o){var i,a,s;const c=r.nodeStyle,l=r.edgeStyle,u=he(r.nodeSize,r.nodeSizeRange,e),d=Array.isArray(r.colorScheme)?r.colorScheme:n.schemeCategory10,h=new Map;e.forEach((e,t)=>{h.set(e.id,d[t%d.length])});const y=[],g=[],p=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=u(ae(t,"nodeSize")),r=c?c(ae(t,"nodeStyle")):{},n={fill:r.fill||h.get(t.id)||"#007bff",stroke:r.stroke||"#fff",strokeWidth:null!==(i=r.strokeWidth)&&void 0!==i?i:2,opacity:r.opacity};y.push({type:"circle",cx:t.x,cy:t.y,r:e,style:n,datum:t,id:t.id,label:t.id})}const f=new Map;for(const t of e)f.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:f.get(e.source),r="object"==typeof e.target?e.target:f.get(e.target);if(!t||!r)continue;if(null==t.x||null==t.y)continue;if(null==r.x||null==r.y)continue;const n=l?l(ae(e,"edgeStyle")):{},o={stroke:n.stroke||"#999",strokeWidth:null!==(a=n.strokeWidth)&&void 0!==a?a:1,opacity:null!==(s=n.opacity)&&void 0!==s?s:.6};g.push({type:"line",x1:t.x,y1:t.y,x2:r.x,y2:r.y,style:o,datum:e})}if(!1!==r.showLabels){const t=(m=r.nodeLabel)?"function"==typeof m?m:e=>e[m]||e.id:null;for(const r of e){if(null==r.x||null==r.y)continue;const e=t?t(r):r.id;if(!e)continue;const n=u(ae(r,"nodeSize"));p.push({x:r.x,y:r.y-n-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var m;return{sceneNodes:y,sceneEdges:g,labels:p}}};function ue(e,t,r){const n=[];for(const o of t){const t="string"==typeof o.source?o.source:o.source.id,i="string"==typeof o.target?o.target:o.target.id;let a=null;if(t===e?a=i:i===e&&(a=t),a){const e=r.get(a);!e||0===e.x&&0===e.y||n.push({x:e.x,y:e.y})}}return n}function de(e){let t=0;for(let r=0;e.length>r;r++)t=(t<<5)-t+e.charCodeAt(r)|0;return Math.abs(t)}function he(e,t,n){var o,a;if(null==e)return()=>8;if("number"==typeof e)return()=>e;if("function"==typeof e)return t=>e(t)||8;const s=t||[5,20],c=n.map(t=>{var r;return null===(r=t.data)||void 0===r?void 0:r[e]}).filter(e=>null!=e&&"number"==typeof e);if(0===c.length)return()=>s[0];const l=null!==(o=r.min(c))&&void 0!==o?o:0,u=null!==(a=r.max(c))&&void 0!==a?a:1;if(l===u)return()=>(s[0]+s[1])/2;const d=i.scaleLinear().domain([l,u]).range(s).clamp(!0);return t=>{var r;const n=null===(r=t.data)||void 0===r?void 0:r[e];return null==n||"number"!=typeof n?s[0]:d(n)}}const ye=n.schemeCategory10,ge={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,r,n){if(0===e.length)return;const{padAngle:o=.01,groupWidth:i=20,sortGroups:c}=r,l=Math.min(n[0],n[1])/2,u=l-i,d=n[0]/2,h=n[1]/2,y=(g=r.valueAccessor)?"function"==typeof g?g:e=>{var t;return null!==(t=e[g])&&void 0!==t?t:1}:e=>{var t;return null!==(t=e.value)&&void 0!==t?t:1};var g;const p=new Map;for(let t=0;e.length>t;t++)p.set(e[t].id,t);const f=e.length,m=Array.from({length:f},()=>Array.from({length:f},()=>0));for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,r=p.get("string"==typeof e.source?e.source:e.source.id),n=p.get(t);if(void 0===r||void 0===n)continue;const o=y(e);m[r][n]=o}const v=a.chord().padAngle(o);c&&v.sortGroups(c);const b=v(m),x=b.groups,k=s.arc().innerRadius(u).outerRadius(l);for(const t of x){const r=e[t.index],n=k.centroid(t);r.x=n[0]+d,r.y=n[1]+h,r.arcData={startAngle:t.startAngle,endAngle:t.endAngle}}const A=new Map;for(const t of e)A.set(t.id,t);for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,r=A.get("string"==typeof e.source?e.source:e.source.id),n=A.get(t);r&&(e.source=r),n&&(e.target=n)}const w=new Map;for(const e of t)w.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const t of b){const r=e[t.source.index].id,n=e[t.target.index].id,o=w.get(`${r}\0${n}`)||w.get(`${n}\0${r}`);o&&(o.chordData=t)}},buildScene(e,t,r,n){var o,i;const{groupWidth:s=20,edgeOpacity:c=.5}=r,l=Math.min(n[0],n[1])/2,u=l-s,d=n[0]/2,h=n[1]/2,y=r.nodeStyle,g=r.edgeStyle,p=r.edgeColorBy||"source",f=Array.isArray(r.colorScheme)?r.colorScheme:ye,m=new Map;e.forEach((e,t)=>{m.set(e.id,f[t%f.length])});const v=a.ribbon().radius(u),b=[],x=[],k=[];for(let t=0;e.length>t;t++){const r=e[t],n=r.arcData;if(!n)continue;let i;i=y?y(ae(r,"nodeStyle")).fill||m.get(r.id)||f[t%f.length]:m.get(r.id)||f[t%f.length];const a=y?y(ae(r,"nodeStyle")):{},s={fill:i,stroke:a.stroke||"black",strokeWidth:null!==(o=a.strokeWidth)&&void 0!==o?o:1,opacity:a.opacity};b.push({type:"arc",cx:d,cy:h,innerR:u,outerR:l,startAngle:n.startAngle-Math.PI/2,endAngle:n.endAngle-Math.PI/2,style:s,datum:r,id:r.id,label:r.id})}for(const e of t){const t=e.chordData;if(!t)continue;const r=v(t);if(!r)continue;const n=pe(r,d,h);let o="#999";if(g)o=g(ae(e,"edgeStyle")).fill||o;else{const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;"target"===p&&r?o=m.get(r.id)||o:t&&(o=m.get(t.id)||o)}const a=g?g(ae(e,"edgeStyle")):{},s={fill:o,fillOpacity:null!==(i=a.fillOpacity)&&void 0!==i?i:c,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity};x.push({type:"ribbon",pathD:n,style:s,datum:e})}if(!1!==r.showLabels){const t=(A=r.nodeLabel)?"function"==typeof A?A:e=>e[A]||e.id:null,n=l+12;for(const r of e){const e=r.arcData;if(!e)continue;const o=t?t(r):r.id;if(!o)continue;const i=(e.startAngle+e.endAngle)/2,a=i-Math.PI/2;k.push({x:d+Math.cos(a)*n,y:h+Math.sin(a)*n,text:o+"",anchor:i>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var A;return{sceneNodes:b,sceneEdges:x,labels:k}}};function pe(e,t,r){const n=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!n)return e;const o=[];let i=0;for(;n.length>i;){const e=n[i];if("M"===e||"L"===e)for(o.push(e),i++;n.length>i&&!isNaN(Number(n[i]));)o.push(Number(n[i])+t+""),i++,n.length>i&&!isNaN(Number(n[i]))&&(o.push(Number(n[i])+r+""),i++);else if("C"===e)for(o.push(e),i++;n.length>i&&!isNaN(Number(n[i]));)for(let e=0;3>e&&n.length>i&&!isNaN(Number(n[i]));e++)o.push(Number(n[i])+t+""),i++,n.length>i&&!isNaN(Number(n[i]))&&(o.push(Number(n[i])+r+""),i++);else if("Q"===e)for(o.push(e),i++;n.length>i&&!isNaN(Number(n[i]));)for(let e=0;2>e&&n.length>i&&!isNaN(Number(n[i]));e++)o.push(Number(n[i])+t+""),i++,n.length>i&&!isNaN(Number(n[i]))&&(o.push(Number(n[i])+r+""),i++);else if("A"===e)for(o.push(e),i++;n.length>i&&!isNaN(Number(n[i]));)o.push(n[i++]),n.length>i&&o.push(n[i++]),n.length>i&&o.push(n[i++]),n.length>i&&o.push(n[i++]),n.length>i&&o.push(n[i++]),n.length>i&&(o.push(Number(n[i])+t+""),i++),n.length>i&&(o.push(Number(n[i])+r+""),i++);else"Z"===e||"z"===e?(o.push(e),i++):(o.push(n[i]),i++)}return o.join(" ")}const fe=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function me(e){const[t,r,n]=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*r+.114*n>150?"#222":"#fff"}function ve(e,t,r){const n=t.nodeIDAccessor;return"function"==typeof n?n(e.data)+"":"string"==typeof n&&void 0!==e.data[n]?e.data[n]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+r}function be(e){return e?"function"==typeof e?e:t=>{var r;return(null===(r=t.data)||void 0===r?void 0:r[e])||t[e]||t.id}:null}function xe(e){return Array.isArray(e.colorScheme)?e.colorScheme:fe}function ke(e){return Array.isArray(e.colorScheme)&&e.colorScheme.length>0?e.colorScheme[0]:"#4d430c"}function Ae(e,t,r,n,o){if("horizontal"===o){const o=(e+r)/2;return`M ${e},${t} C ${o},${t} ${o},${n} ${r},${n}`}if("radial"===o){const o=(e+r)/2;return`M ${e},${t} Q ${o},${t} ${o},${(t+n)/2} T ${r},${n}`}{const o=(t+n)/2;return`M ${e},${t} C ${e},${o} ${r},${o} ${r},${n}`}}const we={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,r,n){var o;const i=r.__hierarchyRoot;if(!i)return;const a=r.chartType,s=function(e){if(e)return"function"==typeof e?e:t=>t[e]}(r.childrenAccessor),l=r.hierarchySum,u="function"==typeof l?l:"string"==typeof l?e=>{var t;return null!==(t=e[l])&&void 0!==t?t:0}:e=>{var t;return null!==(t=e.value)&&void 0!==t?t:0},d=c.hierarchy(i,s);d.sum(u),d.sort((e,t)=>{var r,n;return(null!==(r=t.value)&&void 0!==r?r:0)-(null!==(n=e.value)&&void 0!==n?n:0)});const[h,y]=n;switch(a){case"tree":!function(e,t,r,n){const o=t.treeOrientation||"vertical",i=c.tree();i.size("horizontal"===o?[n,r]:"radial"===o?[2*Math.PI,Math.min(r,n)/2*.8]:[r,n]),i(e)}(d,r,h,y);break;case"cluster":!function(e,t,r,n){const o=t.treeOrientation||"vertical",i=c.cluster();i.size("horizontal"===o?[n,r]:"radial"===o?[2*Math.PI,Math.min(r,n)/2*.8]:[r,n]),i(e)}(d,r,h,y);break;case"treemap":!function(e,t,r,n){var o,i;const a=null!==(o=t.padding)&&void 0!==o?o:4,s=null!==(i=t.paddingTop)&&void 0!==i?i:0,l=c.treemap().size([r,n]).tile(c.treemapBinary).padding(a);s>0&&l.paddingTop(s),l(e)}(d,r,h,y);break;case"circlepack":!function(e,t,r,n){var o;const i=null!==(o=t.padding)&&void 0!==o?o:4;c.pack().size([r,n]).padding(i)(e)}(d,r,h,y);break;case"partition":!function(e,t,r,n){var o;c.partition().size([r,n]).padding(null!==(o=t.padding)&&void 0!==o?o:1)(e)}(d,r,h,y)}const g=d.descendants();e.length=0,t.length=0;const p=new Map;for(let t=0;g.length>t;t++){const n=g[t],i={id:ve(n,r,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(o=n.value)&&void 0!==o?o:0,depth:n.depth,data:n.data,createdByFrame:!0};"tree"===a||"cluster"===a?Se(i,n,r):"treemap"===a||"partition"===a?Ee(i,n):"circlepack"===a&&Oe(i,n),i.__hierarchyNode=n,e.push(i),p.set(n,i)}if("tree"===a||"cluster"===a)for(const e of g)if(e.parent){const r=p.get(e.parent),n=p.get(e);r&&n&&t.push({source:r,target:n,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,r,n){const o=r.nodeStyle||(()=>({})),i=r.edgeStyle||(()=>({}));switch(r.chartType){case"tree":case"cluster":return function(e,t,r,n,o,i){var a,s,c,l,u;const d=[],h=[],y=[],g=r.treeOrientation||"vertical",p="radial"===g,f=n[0]/2,m=n[1]/2,v="number"==typeof(b=r.nodeSize)?b:5;var b;for(const t of e){let e=t.x,n=t.y;p&&(e+=f,n+=m);const i=o(ae(t,"nodeStyle"));let s=i.fill||ke(r);if(r.colorByDepth&&void 0!==t.depth){const e=xe(r);s=e[t.depth%e.length]}const c={fill:s,stroke:i.stroke||"#fff",strokeWidth:null!==(a=i.strokeWidth)&&void 0!==a?a:1,opacity:i.opacity};d.push({type:"circle",cx:e,cy:n,r:v,style:c,datum:t,id:t.id,label:t.id,depth:t.depth})}const x=null!==(s=r.edgeOpacity)&&void 0!==s?s:.5;for(const e of t){const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;if(!t||!r)continue;let n=t.x,o=t.y,a=r.x,s=r.y;p&&(n+=f,o+=m,a+=f,s+=m);const u=Ae(n,o,a,s,g),d=i(ae(e,"edgeStyle")),y={fill:"none",stroke:d.stroke||"#999",strokeWidth:null!==(c=d.strokeWidth)&&void 0!==c?c:1.5,opacity:null!==(l=d.opacity)&&void 0!==l?l:x};h.push({type:"curved",pathD:u,style:y,datum:e})}if(!1!==r.showLabels){const t=be(r.nodeLabel);for(const r of e){const e=t?t(r):r.id;if(!e)continue;let n,o,i,a=r.x,s=r.y;if(p&&(a+=f,s+=m),p){const e=a-f,t=s-m,r=Math.sqrt(e*e+t*t);r>0?(n=a+e/r*10,o=s+t/r*10,i=0>e?"end":"start"):(n=a,o=s-12,i="middle")}else"horizontal"===g?((null===(u=r.data)||void 0===u?void 0:u.children)&&0!==r.data.children.length?(n=a-v-6,i="end"):(n=a+v+6,i="start"),o=s):(n=a,o=s+v+14,i="middle");y.push({x:n,y:o,text:e+"",anchor:i,baseline:"middle",fontSize:11})}}return{sceneNodes:d,sceneEdges:h,labels:y}}(e,t,r,n,o,i);case"treemap":case"partition":return function(e,t,r,n){var o,i;const a=[],s=[];for(const r of e){const e=r.x1-r.x0,i=r.y1-r.y0;if(0>=e||0>=i)continue;const s=n(ae(r,"nodeStyle"));let c=s.fill||ke(t);if(t.colorByDepth&&void 0!==r.depth){const e=xe(t);c=e[r.depth%e.length]}const l={fill:c,stroke:s.stroke||"#fff",strokeWidth:null!==(o=s.strokeWidth)&&void 0!==o?o:1,opacity:s.opacity};a.push({type:"rect",x:r.x0,y:r.y0,w:e,h:i,style:l,datum:r,id:r.id,label:r.id,depth:r.depth})}if(!1!==t.showLabels){const r=be(t.nodeLabel),o=t.labelMode||"leaf",a="partition"===t.chartType;for(const c of e){const e=c.x1-c.x0,l=c.y1-c.y0;if(0>=e||0>=l)continue;const u=!((null===(i=c.data)||void 0===i?void 0:i.children)&&c.data.children.length>0);if(!a){if("leaf"===o&&!u)continue;if("parent"===o&&u)continue}const d=r?r(c):c.id;if(!d)continue;if((u?30:40)>e||(u?16:14)>l)continue;let h=n(ae(c,"nodeStyle")).fill||ke(t);if(t.colorByDepth&&void 0!==c.depth){const e=xe(t);h=e[c.depth%e.length]}const y=me(h);s.push(u?{x:c.x0+e/2,y:c.y0+l/2,text:d+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,l)/6)),fill:y}:{x:c.x0+4,y:c.y0+12,text:d+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:y})}}return{sceneNodes:a,sceneEdges:[],labels:s}}(e,r,0,o);case"circlepack":return function(e,t,r,n){var o,i,a,s,c;const l=[],u=[];for(const r of e){const e=null!==(o=r.__radius)&&void 0!==o?o:5;if(0>=e)continue;const s=n(ae(r,"nodeStyle"));let c=s.fill||ke(t);if(t.colorByDepth&&void 0!==r.depth){const e=xe(t);c=e[r.depth%e.length]}const u={fill:c,stroke:s.stroke||"#fff",strokeWidth:null!==(i=s.strokeWidth)&&void 0!==i?i:1,opacity:null!==(a=s.opacity)&&void 0!==a?a:.7};l.push({type:"circle",cx:r.x,cy:r.y,r:e,style:u,datum:r,id:r.id,label:r.id,depth:r.depth})}if(!1!==t.showLabels){const r=be(t.nodeLabel);for(const o of e){const e=null!==(s=o.__radius)&&void 0!==s?s:5,i=r?r(o):o.id;if(!i)continue;if(15>e)continue;const a=!((null===(c=o.data)||void 0===c?void 0:c.children)&&o.data.children.length>0);let l=n(ae(o,"nodeStyle")).fill||ke(t);if(t.colorByDepth&&void 0!==o.depth){const e=xe(t);l=e[o.depth%e.length]}if(a){const t=me(l);u.push({x:o.x,y:o.y,text:i+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,e/3)),fill:t})}else u.push({x:o.x,y:o.y-e+14,text:i+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:"#000",stroke:"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:l,sceneEdges:[],labels:u}}(e,r,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Se(e,t,r){const n=r.treeOrientation||"vertical";if("radial"===n){const r=t.x,n=t.y;e.x=n*Math.cos(r-Math.PI/2),e.y=n*Math.sin(r-Math.PI/2)}else"horizontal"===n?(e.x=t.y,e.y=t.x):(e.x=t.x,e.y=t.y);e.x0=e.x-5,e.x1=e.x+5,e.y0=e.y-5,e.y1=e.y+5,e.width=10,e.height=10}function Ee(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 Oe(e,t){var r;const n=null!==(r=t.r)&&void 0!==r?r:0;e.x=t.x,e.y=t.y,e.x0=t.x-n,e.x1=t.x+n,e.y0=t.y-n,e.y1=t.y+n,e.width=2*n,e.height=2*n,e.__radius=n}function Le(e){const t=e;return t.__orbitState||(t.__orbitState={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()}),t.__orbitState}const je={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,r,n){const o=r.__hierarchyRoot;o&&function(e,t,r,n,o){var i,a;const c=function(e){if("function"==typeof e)return e;const t=e||"children";return e=>e[t]||null}(r.childrenAccessor),l=function(e){if("function"==typeof e)return e;const t=e||"name";return e=>{var r;return(null!==(r=e[t])&&void 0!==r?r:"")+""}}(r.nodeIDAccessor),u=function(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(r.orbitMode),d=null!==(i=r.orbitSize)&&void 0!==i?i:2.95,h=null!==(a=r.orbitEccentricity)&&void 0!==a?a:1,y="number"==typeof d?()=>d:d,g="number"==typeof h?()=>h:h,p=Le(r);p.metaMap.clear(),n.length=0,o.length=0;const f=new Map;function m(e){var t;const r=null!==(t=f.get(e))&&void 0!==t?t:0;return f.set(e,r+1),0===r?e:`${e}__${r}`}const v=t[0]/2,b=t[1]/2,x=Math.min(t[0],t[1])/2*.85,k=m(l(e));n.push({id:k,x:v,y:b,x0:v,x1:v,y0:b,y1:b,width:0,height:0,value:0,depth:0,data:e}),p.metaMap.set(k,{ring:x,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,r,i,a,d,h,f){const v=c(t);if(!(null==v?void 0:v.length))return;const b=v.length;let x=0,k=0,A=0;for(;b>k;)k+=u[Math.min(A,u.length-1)],A++,x++;let w=0;for(let b=0;x>b;b++){const k=u[Math.min(b,u.length-1)],A=v.slice(w,w+k);if(!A.length)break;const S=(b+1)/x,E={id:r,depth:h,data:t,parentId:r},O=f?d/y(E)*S:d*S,L=s.pie().value(e=>{var t;return(null===(t=c(e))||void 0===t?void 0:t.length)?4:1}).sort(null),j=L(A),C=g(E);for(let t=0;A.length>t;t++){const s=(j[t].startAngle+j[t].endAngle)/2,c=A[t],u=m(l(c)),d=i+O*Math.sin(s),y=a+O*Math.cos(s)*C;n.push({id:u,x:d,y:y,x0:d,x1:d,y0:y,y1:y,width:0,height:0,value:0,depth:h,data:c}),p.metaMap.set(u,{ring:O,angle:s,depth:h,parentId:r,eccentricity:C}),o.push({source:r,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:r,target:u}}),e(c,u,d,y,O,h+1,!0)}w+=k}}(e,k,v,b,x,1,!1)}(o,n,r,e,t)},buildScene(e,t,r,n){var o,i,a,s,c;const l=r.nodeStyle,u=r.nodeSize,d="number"==typeof u?()=>u:"function"==typeof u?u:()=>6,h=[],y=[],g=[];if(!1!==r.orbitShowRings){const t=Le(r),n=new Map;for(const t of e)n.set(t.id,t);const o=new Map;for(const[,e]of t.metaMap){if(!e.parentId)continue;const t=n.get(e.parentId);if(!t)continue;const r=`${e.parentId}:${e.ring}`;o.has(r)||o.set(r,{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:r,ecc:n}]of o)for(let o=0;i>o;o++){const s=o/i*Math.PI*2,c=(o+1)/i*Math.PI*2;y.push({type:"line",x1:e+r*Math.sin(s),y1:t+r*Math.cos(s)*n,x2:e+r*Math.sin(c),y2:t+r*Math.cos(c)*n,style:a,datum:null})}}for(const t of e){if(null==t.x||null==t.y)continue;const e=d(ae(t,"nodeSize")),r=l?l(ae(t,"nodeStyle")):{},n={fill:r.fill||"#6366f1",stroke:r.stroke||"#fff",strokeWidth:null!==(o=r.strokeWidth)&&void 0!==o?o:1,opacity:null!==(i=r.opacity)&&void 0!==i?i:0===(null!==(a=t.depth)&&void 0!==a?a:0)?1:.85};h.push({type:"circle",cx:t.x,cy:t.y,r:e,style:n,datum:t,id:t.id,label:t.id,depth:t.depth})}const p=new Map;for(const t of e)p.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:p.get(e.source),r="object"==typeof e.target?e.target:p.get(e.target);t&&r&&(null!=t.x&&null!=r.x&&y.push({type:"line",x1:t.x,y1:t.y,x2:r.x,y2:r.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:e}))}if(r.showLabels){const t=r.nodeLabel;for(const r of e){const e=d(ae(r,"nodeSize"));if(4>=e)continue;const n="function"==typeof t?t(r):t&&null!==(c=null===(s=r.data)||void 0===s?void 0:s[t])&&void 0!==c?c:r.id;g.push({x:r.x,y:r.y+e+12,text:n+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:h,sceneEdges:y,labels:g}},tick:(e,t,r,n,o)=>!1!==r.orbitAnimated&&(function(e,t){var r,n;const o=Le(t),i=null!==(r=t.orbitSpeed)&&void 0!==r?r:.25,a=null!==(n=t.orbitRevolution)&&void 0!==n?n:function(e){switch(e){case"decay":return e=>{var t;return Math.pow(.6,null!==(t=e.depth)&&void 0!==t?t:0)};case"alternate":return e=>{var t;const r=null!==(t=e.depth)&&void 0!==t?t:0;return(r%2==0?1:-1)/(r+1)};default:return e=>{var t;return 1/((null!==(t=e.depth)&&void 0!==t?t:0)+1)}}}(t.orbitRevolutionStyle),s=(("undefined"!=typeof performance?performance.now():Date.now())-o.startTime)/1e3,c=i*(Math.PI/6),l=new Map;for(const t of e)l.set(t.id,t);for(const t of e){const e=o.metaMap.get(t.id);if(!e||!e.parentId)continue;const r=l.get(e.parentId);if(!r)continue;const n=e.angle+s*c*a({id:t.id,depth:e.depth,data:t.data,parentId:e.parentId});t.x=r.x+e.ring*Math.sin(n),t.y=r.y+e.ring*Math.cos(n)*e.eccentricity,t.x0=t.x,t.x1=t.x,t.y0=t.y,t.y1=t.y}}(e,r),!0)},Ce={sankey:ce,force:le,chord:ge,tree:we,cluster:we,treemap:we,circlepack:we,partition:we,orbit:je};function De(e){return Ce[e]}function Me(e,t,r){return e+(t-e)*r}function Ie(e,t,r){var n,o,i;if(1>=r)return 1;const a=null!==(n=e.minOpacity)&&void 0!==n?n:.1,s=r-1-t;switch(e.type){case"linear":return a+(1-s/(r-1))*(1-a);case"exponential":{const t=null!==(o=e.halfLife)&&void 0!==o?o:r/2;return a+Math.pow(.5,s/t)*(1-a)}case"step":return(null!==(i=e.stepThreshold)&&void 0!==i?i:.5*r)>s?1:a;default:return 1}}class Pe{constructor(e){this.nodes=new Map,this.edges=new Map,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.particlePool=null,this.transition=null,this.lastIngestTime=0,this.nodeTimestamps=new Map,this.edgeTimestamps=new Map,this._decaySortedNodes=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._lastPositionSnapshot=null,this.config=e,this.tensionConfig=Object.assign(Object.assign({},h),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&(this.particlePool=new g(2e3))}updateConfig(e){const t=this.config;t.__orbitState&&(e.__orbitState=t.__orbitState),t.__hierarchyRoot&&(e.__hierarchyRoot=t.__hierarchyRoot),this.config=e,this.tensionConfig=Object.assign(Object.assign({},h),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&!this.particlePool&&(this.particlePool=new g(2e3))}ingestHierarchy(e,t){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this.config.__hierarchyRoot=e,this.runLayout(t)}ingestBounded(e,t,r){const{nodeIDAccessor:n="id",sourceAccessor:o="source",targetAccessor:i="target",valueAccessor:a="value"}=this.config,s="function"==typeof n?n:e=>e[n],c="function"==typeof o?o:e=>e[o],l="function"==typeof i?i:e=>e[i],u="function"==typeof a?a:e=>{var t;return null!==(t=e[a])&&void 0!==t?t:1};this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const t of e){const e=s(t)+"";this.nodes.set(e,Object.assign(Object.assign({},Te(e)),{data:t}))}for(let e=0;t.length>e;e++){const r=t[e],n=c(r)+"",o=l(r)+"",i=Number(u(r))||1;this.nodes.has(n)||this.nodes.set(n,Object.assign(Object.assign({},Te(n)),{data:r})),this.nodes.has(o)||this.nodes.set(o,Object.assign(Object.assign({},Te(o)),{data:r}));const a=`${n}\0${o}\0${e}`;this.edges.set(a,{source:n,target:o,value:i,y0:0,y1:0,sankeyWidth:0,data:r,_edgeKey:a})}this.runLayout(r)}edgeKey(e,t){return`${e}\0${t}`}ingestEdge(e){const{source:t,target:r,value:n}=e,o=0===this.nodes.size;let i=!1;const a="undefined"!=typeof performance?performance.now():Date.now();this.lastIngestTime=a,this._decaySortedNodes=null,this.nodes.has(t)||(this.nodes.set(t,Te(t)),this.nodeTimestamps.set(t,a),this.tension+=this.tensionConfig.newNode,i=!0),this.nodes.has(r)||(this.nodes.set(r,Te(r)),this.nodeTimestamps.set(r,a),this.tension+=this.tensionConfig.newNode,i=!0);const s=this.edgeKey(t,r),c=this.edges.get(s);let l=!1;return c?(c.value+=n,this.edgeTimestamps.set(s,a),this.tension+=this.tensionConfig.weightChange,l=!0):(this.edges.set(s,{source:t,target:r,value:n,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(s,a),this.tension+=this.tensionConfig.newEdge,i=!0),o||i||l||this.tension>=this.tensionConfig.threshold}runLayout(e){var t,r,n,o,i,a;const s=De(this.config.chartType);if(!s)return;let c=Array.from(this.nodes.values()),l=Array.from(this.edges.values());if(0===c.length&&!s.hierarchical)return;if(this.prepareForRelayout(),s.supportsStreaming&&!s.hierarchical){const e=new Map;for(const s of c)if(void 0!==s._prevX0){const c=(null!==(t=s._prevX1)&&void 0!==t?t:0)-(null!==(r=s._prevX0)&&void 0!==r?r:0),l=(null!==(n=s._prevY1)&&void 0!==n?n:0)-(null!==(o=s._prevY0)&&void 0!==o?o:0);e.set(s.id,{x:(null!==(i=s._prevX0)&&void 0!==i?i:0)+c/2,y:(null!==(a=s._prevY0)&&void 0!==a?a:0)+l/2})}else 0===s.x&&0===s.y||e.set(s.id,{x:s.x,y:s.y});if(this._lastPositionSnapshot)for(const[t,r]of this._lastPositionSnapshot)e.has(t)||e.set(t,r);this.config.__previousPositions=e.size>0?e:void 0}if(s.computeLayout(c,l,this.config,e),this.config.__previousPositions=void 0,s.hierarchical&&c.length>0){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const e of c)this.nodes.set(e.id,e);for(let e=0;l.length>e;e++){const t=l[e],r=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=r,this.edges.set(r,t)}}this.finalizeLayout();const u=new Map;for(const e of this.nodes.values())0===e.x&&0===e.y||u.set(e.id,{x:e.x,y:e.y});this._lastPositionSnapshot=u,this.saveTargetPositions(),c.some(e=>void 0!==e._prevX0&&(0!==e._prevX0||0!==e._prevX1||0!==e._prevY0||0!==e._prevY1))&&this.tensionConfig.transitionDuration>0&&(this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:this.tensionConfig.transitionDuration});const d=new Set(this.nodes.keys()),h=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const e of d)this.previousNodeIds.has(e)||this.addedNodes.add(e);for(const e of this.previousNodeIds)d.has(e)||this.removedNodes.add(e);for(const e of h)this.previousEdgeKeys.has(e)||this.addedEdges.add(e);for(const e of this.previousEdgeKeys)h.has(e)||this.removedEdges.add(e);(this.addedNodes.size>0||this.removedNodes.size>0||this.addedEdges.size>0||this.removedEdges.size>0)&&(this.lastTopologyChangeTime="undefined"!=typeof performance?performance.now():Date.now()),this.previousNodeIds=d,this.previousEdgeKeys=h,this.layoutVersion++}buildScene(e){const t=De(this.config.chartType);if(!t)return;const r=Array.from(this.nodes.values()),n=Array.from(this.edges.values()),{sceneNodes:o,sceneEdges:i,labels:a}=t.buildScene(r,n,this.config,e);this.sceneNodes=o,this.sceneEdges=i,this.labels=a}get isAnimating(){const e=De(this.config.chartType);return!!(null==e?void 0:e.supportsAnimation)&&!1!==this.config.orbitAnimated}tickAnimation(e,t){const r=De(this.config.chartType);if(!(null==r?void 0:r.tick))return!1;const n=Array.from(this.nodes.values()),o=Array.from(this.edges.values());return r.tick(n,o,this.config,e,t)}advanceTransition(e){if(!this.transition)return!1;const t=function(e,t){return Math.min((e-t.startTime)/t.duration,1)}(e,this.transition),r=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=Me(e._prevX0,e._targetX0,r),e.x1=Me(e._prevX1,e._targetX1,r),e.y0=Me(e._prevY0,e._targetY0,r),e.y1=Me(e._prevY1,e._targetY1,r));for(const e of this.edges.values())void 0!==e._targetY0&&void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=Me(e._prevY0,e._targetY0,r),e.y1=Me(e._prevY1,e._targetY1,r),e.sankeyWidth=Me(e._prevSankeyWidth,e._targetSankeyWidth,r));return this.rebuildAllBeziers(),1>t||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){for(const e of this.nodes.values())e._prevX0=e.x0,e._prevX1=e.x1,e._prevY0=e.y0,e._prevY1=e.y1;for(const e of this.edges.values())e._prevY0=e.y0,e._prevY1=e.y1,e._prevSankeyWidth=e.sankeyWidth}finalizeLayout(){const e="vertical"===this.config.orientation?"down":"right";for(const e of this.nodes.values())if(0!==e.x0||0!==e.x1||0!==e.y0||0!==e.y1)e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;else{const t=5;e.x0=e.x-t,e.x1=e.x+t,e.y0=e.y-t,e.y1=e.y+t,e.width=2*t,e.height=2*t}for(const t of this.edges.values())t.direction=e,this.updateEdgeBezier(t);this.tension=0}saveTargetPositions(){for(const e of this.nodes.values())e._targetX0=e.x0,e._targetX1=e.x1,e._targetY0=e.y0,e._targetY1=e.y1;for(const e of this.edges.values())e._targetY0=e.y0,e._targetY1=e.y1,e._targetSankeyWidth=e.sankeyWidth}restorePreviousPositions(){for(const e of this.nodes.values())void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=e._prevX0,e.x1=e._prevX1,e.y0=e._prevY0,e.y1=e._prevY1);for(const e of this.edges.values())void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=e._prevY0,e.y1=e._prevY1,e.sankeyWidth=e._prevSankeyWidth);this.rebuildAllBeziers()}snapToTargets(){for(const e of this.nodes.values())void 0!==e._targetX0&&(e.x0=e._targetX0,e.x1=e._targetX1,e.y0=e._targetY0,e.y1=e._targetY1);for(const e of this.edges.values())void 0!==e._targetY0&&(e.y0=e._targetY0,e.y1=e._targetY1,e.sankeyWidth=e._targetSankeyWidth);this.rebuildAllBeziers()}updateEdgeBezier(e){const t="string"==typeof e.source?this.nodes.get(e.source):e.source,r="string"==typeof e.target?this.nodes.get(e.target):e.target;t&&r&&(e.bezier=e.circular&&e.circularPathData?this.buildCircularBezier(e):this.buildStandardBezier(e,t,r))}buildStandardBezier(e,r,n){const o=(e.sankeyWidth||1)/2;if("down"===e.direction){const i=r.x1,a=n.x0,s=t.interpolateNumber(i,a);return{circular:!1,points:[{x:e.y0,y:i},{x:e.y0,y:s(.5)},{x:e.y1,y:s(.5)},{x:e.y1,y:a}],halfWidth:o}}const i=r.x1,a=n.x0,s=t.interpolateNumber(i,a);return{circular:!1,points:[{x:i,y:e.y0},{x:s(.5),y:e.y0},{x:s(.5),y:e.y1},{x:a,y:e.y1}],halfWidth:o}}buildCircularBezier(e){const t=(e._circularWidth||e.sankeyWidth||1)/2,r=e.circularPathData;if(e._circularStub){const e=Math.max(15,Math.min(40,.33*(r.rightFullExtent-r.sourceX))),n=Math.max(15,Math.min(40,.33*(r.targetX-r.leftFullExtent)));return{circular:!0,segments:[[{x:r.sourceX,y:r.sourceY},{x:r.sourceX+.33*e,y:r.sourceY},{x:r.sourceX+.66*e,y:r.sourceY},{x:r.sourceX+e,y:r.sourceY}],[{x:r.targetX-n,y:r.targetY},{x:r.targetX-.66*n,y:r.targetY},{x:r.targetX-.33*n,y:r.targetY},{x:r.targetX,y:r.targetY}]],halfWidth:t}}let n;n="down"===e.direction?[{x:r.sourceY,y:r.sourceX},{x:r.sourceY,y:r.rightFullExtent},{x:r.verticalFullExtent,y:r.rightFullExtent},{x:r.verticalFullExtent,y:r.leftFullExtent},{x:r.targetY,y:r.leftFullExtent},{x:r.targetY,y:r.targetX}]:[{x:r.sourceX,y:r.sourceY},{x:r.rightFullExtent,y:r.sourceY},{x:r.rightFullExtent,y:r.verticalFullExtent},{x:r.leftFullExtent,y:r.verticalFullExtent},{x:r.leftFullExtent,y:r.targetY},{x:r.targetX,y:r.targetY}];const o=[];for(let e=0;n.length-1>e;e++){const t=n[e],r=n[e+1],i=r.x-t.x,a=r.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},r])}return{circular:!0,segments:o,halfWidth:t}}rebuildAllBeziers(){for(const e of this.nodes.values())e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;for(const e of this.edges.values())this.updateEdgeBezier(e)}applyPulse(e){var t,r,n,o,i;const a=this.config.pulse;if(!a)return;const s=null!==(t=a.duration)&&void 0!==t?t:500,c=null!==(r=a.color)&&void 0!==r?r:"rgba(255,255,255,0.6)",l=null!==(n=a.glowRadius)&&void 0!==n?n:4;for(const t of this.sceneNodes){const r=t.id;if(!r)continue;const n=this.nodeTimestamps.get(r);if(!n)continue;const o=e-n;s>o&&(t._pulseIntensity=1-o/s,t._pulseColor=c,t._pulseGlowRadius=l)}for(const t of this.sceneEdges){const r=t.datum;if(!r)continue;const n="object"==typeof r.source?null===(o=r.source)||void 0===o?void 0:o.id:r.source,a="object"==typeof r.target?null===(i=r.target)||void 0===i?void 0:i.id:r.target;if(!n||!a)continue;const l=this.edgeTimestamps.get(`${n}\0${a}`);if(!l)continue;const u=e-l;s>u&&(t._pulseIntensity=1-u/s,t._pulseColor=c)}}applyDecay(){var e,t;const r=this.config.decay;if(!r)return;const n=this.nodeTimestamps.size;if(1>=n)return;this._decaySortedNodes||(this._decaySortedNodes=Array.from(this.nodeTimestamps.entries()).sort((e,t)=>e[1]-t[1]));const o=this._decaySortedNodes,i=new Map;for(let e=0;o.length>e;e++)i.set(o[e][0],e);for(const o of this.sceneNodes){const a=o.id;if(!a)continue;const s=i.get(a);if(void 0===s)continue;const c=Ie(r,s,n),l=null!==(t=null===(e=o.style)||void 0===e?void 0:e.opacity)&&void 0!==t?t:1;o.style=Object.assign(Object.assign({},o.style),{opacity:l*c})}}applyTopologyDiff(e){var t;if(0===this.addedNodes.size)return;const r=e-this.lastTopologyChangeTime;if(r>=2e3)return;const n=1-r/2e3;for(const e of this.sceneNodes){const r=e.id;r&&this.addedNodes.has(r)&&(e._pulseIntensity=Math.max(null!==(t=e._pulseIntensity)&&void 0!==t?t:0,n),e._pulseColor="rgba(34, 197, 94, 0.7)",e._pulseGlowRadius=8)}}get hasActiveTopologyDiff(){return 0!==this.addedNodes.size&&2e3>("undefined"!=typeof performance?performance.now():Date.now())-this.lastTopologyChangeTime}applyThresholds(e){var t,r;const n=this.config.thresholds;if(!n)return;const o=null!==(t=n.warningColor)&&void 0!==t?t:"#f59e0b",i=null!==(r=n.criticalColor)&&void 0!==r?r:"#ef4444",a=!1!==n.pulse;for(const t of this.sceneNodes){const r=t.id;if(!r)continue;const s=this.nodes.get(r);if(!s)continue;const c=n.metric(s);let l=null;void 0===n.critical||n.critical>c?void 0===n.warning||n.warning>c||(l=o):l=i,l&&(t.style=Object.assign(Object.assign({},t.style),{fill:l}),a&&(t._pulseIntensity=.6+.4*Math.sin(e/300),t._pulseColor=l,t._pulseGlowRadius=6))}}get hasActiveThresholds(){const e=this.config.thresholds;if(!e)return!1;for(const t of this.nodes.values()){const r=e.metric(t);if(void 0!==e.warning&&r>=e.warning||void 0!==e.critical&&r>=e.critical)return!0}return!1}get hasActivePulses(){var e;const t=this.config.pulse;if(!t||0===this.lastIngestTime)return!1;const r="undefined"!=typeof performance?performance.now():Date.now();return(null!==(e=t.duration)&&void 0!==e?e:500)>r-this.lastIngestTime}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}updateNode(e,t){var r;const n=this.nodes.get(e);if(!n)return null;const o=n.data?Object.assign({},n.data):{};return n.data=t(null!==(r=n.data)&&void 0!==r?r:{}),this.layoutVersion++,o}updateEdge(e,t,r){var n;const o=this.config.valueAccessor,i="function"==typeof o?o:o?e=>e[o]:e=>e.value,a=[];for(const[,o]of this.edges)if(("string"==typeof o.source?o.source:o.source.id)===e&&("string"==typeof o.target?o.target:o.target.id)===t){a.push(o.data?Object.assign({},o.data):{}),o.data=r(null!==(n=o.data)&&void 0!==n?n:{});const e=i(o.data);null!=e&&(o.value=Number(e))}return a.length>0&&this.layoutVersion++,a}removeNode(e){if(!this.nodes.has(e))return!1;this.nodes.delete(e),this.nodeTimestamps.delete(e);for(const[t,r]of this.edges)("string"==typeof r.source?r.source:r.source.id)!==e&&("string"==typeof r.target?r.target:r.target.id)!==e||(this.edges.delete(t),this.edgeTimestamps.delete(t));return this.layoutVersion++,!0}removeEdge(e,t){const r=[];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 n="function"==typeof t?t:e=>null==e?void 0:e[t];for(const[t,o]of this.edges)n(o.data)===e&&r.push(t)}else for(const[n,o]of this.edges)("string"==typeof o.source?o.source:o.source.id)===e&&("string"==typeof o.target?o.target:o.target.id)===t&&r.push(n);for(const e of r)this.edges.delete(e),this.edgeTimestamps.delete(e);return r.length>0&&this.layoutVersion++,r.length>0}clear(){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.transition=null,this.lastIngestTime=0,this._lastPositionSnapshot=null,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.particlePool&&this.particlePool.clear()}}function Te(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 Ne(e){let t=e%(2*Math.PI);return 0>t&&(t+=2*Math.PI),t}function _e(e,t,r,n,o=30){let i=null,a=o,s=1/0;for(const t of e){const e=$e(t,r,n,o);if(e)if("rect"===t.type){const r=t.w*t.h;s>r&&(i=e,s=r)}else a>e.distance&&(i=e,a=e.distance)}if(i)return i;for(const e of t){const t=ze(e,r,n);t&&a>t.distance&&(i=t,a=t.distance)}return i}function $e(e,t,r,n=30){switch(e.type){case"circle":return function(e,t,r,n=30){const o=t-e.cx,i=r-e.cy,a=Math.sqrt(o*o+i*i),s=function(e,t=30){return Math.max((null!=e?e:4)+5,12,t)}(e.r,n);return a>s?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:a}}(e,t,r,n);case"rect":return function(e,t,r){const n=function(e,t,r){return r.x>e||e>r.x+r.w||r.y>t||t>r.y+r.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:r.x+r.w/2,cy:r.y+r.h/2}}(t,r,e);return n.hit?{type:"node",datum:e.datum,x:n.cx,y:n.cy,distance:0}:null}(e,t,r);case"arc":return function(e,t,r){const n=t-e.cx,o=r-e.cy,i=Math.sqrt(n*n+o*o);if(e.innerR-2>i||i>e.outerR+2)return null;const a=Ne(Math.atan2(o,n)),s=Ne(e.startAngle),c=Ne(e.endAngle);if(s>c?a>=s||c>=a:a>=s&&c>=a){const t=(e.startAngle+e.endAngle)/2,r=(e.innerR+e.outerR)/2;return{type:"node",datum:e.datum,x:e.cx+r*Math.cos(t),y:e.cy+r*Math.sin(t),distance:0}}return null}(e,t,r);default:return null}}let Be=null,Re=null;function We(){return Re||(Be=document.createElement("canvas"),Be.width=1,Be.height=1,Re=Be.getContext("2d")),Re}function ze(e,t,r){switch(e.type){case"bezier":return function(e,t,r){var n,o;if(!e.pathD)return null;try{const i=new Path2D(e.pathD),a=We();if(!a)return null;if(a.isPointInPath(i,t,r)){const i="object"==typeof(null===(n=e.datum)||void 0===n?void 0:n.source)?e.datum.source:null,a="object"==typeof(null===(o=e.datum)||void 0===o?void 0:o.target)?e.datum.target:null;return{type:"edge",datum:e.datum,x:i&&a?(i.x1+a.x0)/2:t,y:e.datum?(e.datum.y0+e.datum.y1)/2:r,distance:0}}const s=a.lineWidth;a.lineWidth=10;const c=a.isPointInStroke(i,t,r);if(a.lineWidth=s,c)return{type:"edge",datum:e.datum,x:t,y:r,distance:4}}catch(e){}return null}(e,t,r);case"line":return function(e,t,r){const n=e.x2-e.x1,o=e.y2-e.y1,i=n*n+o*o;if(0===i)return null;let a=((t-e.x1)*n+(r-e.y1)*o)/i;a=Math.max(0,Math.min(1,a));const s=e.x1+a*n,c=e.y1+a*o,l=Math.sqrt(Math.pow(t-s,2)+Math.pow(r-c,2));return l>5?null:{type:"edge",datum:e.datum,x:s,y:c,distance:l}}(e,t,r);case"ribbon":case"curved":return function(e,t,r){if(!e.pathD)return null;try{const n=new Path2D(e.pathD),o=We();if(!o)return null;if(o.isPointInPath(n,t,r))return{type:"edge",datum:e.datum,x:t,y:r,distance:0};const i=o.lineWidth;o.lineWidth=10;const a=o.isPointInStroke(n,t,r);if(o.lineWidth=i,a)return{type:"edge",datum:e.datum,x:t,y:r,distance:4}}catch(e){}return null}(e,t,r);default:return null}}function He(e,t,r){const{group:n,indexInGroup:o}=t,i=r.byGroup.get(n);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=r.groups.indexOf(n);return r.groups.length-1>e?Fe(r,r.groups[e+1],i[o]):t.flatIndex}case"ArrowUp":{const e=r.groups.indexOf(n);return e>0?Fe(r,r.groups[e-1],i[o]):t.flatIndex}case"PageDown":return Math.min(t.flatIndex+Math.max(1,Math.floor(.1*r.flat.length)),r.flat.length-1);case"PageUp":return Math.max(t.flatIndex-Math.max(1,Math.floor(.1*r.flat.length)),0);case"Home":return 0;case"End":return r.flat.length-1;case"Escape":return-1;default:return null}}function Fe(e,t,r){const n=e.byGroup.get(t);let o=0,i=Math.abs(n[0].x-r.x);for(let e=1;n.length>e;e++){const t=Math.abs(n[e].x-r.x);i>t&&(i=t,o=e)}return n[o]._flatIndex}const qe="var(--semiotic-focus, #005fcc)";function Ye({active:e,hoverPoint:t,margin:r,size:n,shape:o="circle",width:i,height:a}){if(!e||!t)return null;const s=t.x+r.left,c=t.y+r.top;let l;if("rect"===o&&null!=i&&null!=a){const e=Math.max(i,4),t=Math.max(a,4);l=u.createElement("rect",{x:s-e/2-3,y:c-t/2-3,width:e+6,height:t+6,rx:3,fill:"none",stroke:qe,strokeWidth:2,strokeDasharray:"4,2"})}else l=u.createElement("circle","wedge"===o?{cx:s,cy:c,r:12,fill:"none",stroke:qe,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:s,cy:c,r:8,fill:"none",stroke:qe,strokeWidth:2,strokeDasharray:"4,2"});return u.createElement("svg",{style:{position:"absolute",left:0,top:0,width:n[0],height:n[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true"},l)}function Ge({x:e,y:t,containerWidth:r,containerHeight:n,margin:o,children:i,className:a="stream-frame-tooltip",zIndex:s=1}){const c=u.useRef(null),[l,d]=u.useState(null);u.useLayoutEffect(()=>{const e=c.current;if(!e)return;const t=e.getBoundingClientRect();d(e=>e&&e.width===t.width&&e.height===t.height?e:{width:t.width,height:t.height})},[i,a,r,n]);let h;return h=l?`translate(${l.width+12>r-e?"calc(-100% - 12px)":"12px"}, ${l.height+12>n-t?"calc(-100% - 4px)":"4px"})`:`translate(${e>.7*r?"calc(-100% - 12px)":"12px"}, ${.3*n>t?"4px":"calc(-100% - 4px)"})`,u.createElement("div",{ref:c,className:a,style:{position:"absolute",left:o.left+e,top:o.top+t,transform:h,pointerEvents:"none",zIndex:s,width:"max-content"}},i)}const Xe={fill:e=>u.createElement("rect",{style:e,width:16,height:16}),line:e=>u.createElement("line",{style:e,x1:0,y1:0,x2:16,y2:16})};function Ve(e,t,r,n){let o;return o="function"==typeof r?r(e):(0,Xe[r])(n(e,t)),o}function Ke(){return u.createElement("path",{d:"M4,8.8 L7.2,12 L12.8,4.8",fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function Ue(e,t,r){return r&&r.size>0?r.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}function Ze({config:e,orientation:t="vertical",width:r=100}){const{colorFn:n,domain:o,label:i,format:a}=e,s=a||(e=>Math.round(100*e)/100+""),c="grad-legend-"+u.useId();if("horizontal"===t){const e=12,t=Math.min(r,200),a=Math.max(0,(r-t)/2),l=[];for(let e=0;64>=e;e++){const t=e/64;l.push(u.createElement("stop",{key:e,offset:100*t+"%",stopColor:n(o[0]+t*(o[1]-o[0]))}))}return u.createElement("g",{"aria-label":i||"Gradient legend"},u.createElement("defs",null,u.createElement("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"100%",y2:"0%"},l)),i&&u.createElement("text",{x:a+t/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},i),u.createElement("rect",{x:a,y:0,width:t,height:e,fill:`url(#${c})`,rx:2}),u.createElement("text",{x:a,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(o[0])),u.createElement("text",{x:a+t,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(o[1])))}const l=[];for(let e=0;64>=e;e++){const t=e/64;l.push(u.createElement("stop",{key:e,offset:100*t+"%",stopColor:n(o[1]-t*(o[1]-o[0]))}))}return u.createElement("g",{"aria-label":i||"Gradient legend"},i&&u.createElement("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},i),u.createElement("defs",null,u.createElement("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"0%",y2:"100%"},l)),u.createElement("rect",{x:0,y:0,width:14,height:100,fill:`url(#${c})`,rx:2}),u.createElement("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(o[1])),u.createElement("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(o[0])))}function Qe(e){const{legendGroups:t,customClickBehavior:r,customHoverBehavior:n,highlightedCategory:o,isolatedCategories:i,legendInteraction:a,title:s="Legend",width:c=100,height:l=20,orientation:d="vertical"}=e,[h,y]=u.useState(0),[g,p]=u.useState(0),f=u.useCallback((e,t)=>{y(e),p(t)},[]),m="vertical"===d?(({legendGroups:e,width:t,customClickBehavior:r,customHoverBehavior:n,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:a,focusedItemIndex:s,onFocusedIndexChange:c,legendInteraction:l})=>{let d=24;const h=[];return e.forEach((e,y)=>{d+=5,h.push(u.createElement("line",{key:"legend-top-line legend-symbol-"+y,stroke:"gray",x1:0,y1:d,x2:t,y2:d})),d+=8,e.label&&(d+=16,h.push(u.createElement("text",{key:"legend-text-"+y,y:d,className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label)),d+=8),h.push(u.createElement("g",{key:"legend-group-"+y,className:"legend-item",transform:`translate(0,${d})`},((e,t,r,n,o,i,a,s,c,l)=>{const{type:d="fill",styleFn:h,items:y}=e,g=[];let p=0;const f=!(!t&&!r),m="isolate"===l||void 0===l&&null!=o;return y.forEach((e,l)=>{const v=Ve(e,l,d,h),b=Ue(e,n,o),x=o&&o.size>0&&o.has(e.label);g.push(u.createElement("g",{key:"legend-item-"+l,transform:`translate(0,${p})`,onClick:t?()=>t(e):void 0,onMouseEnter:r?()=>r(e):void 0,onMouseLeave:r?()=>r(null):void 0,tabIndex:f?s===i&&l===a?0:-1:void 0,role:f?"option":void 0,"aria-selected":f&&m?x||!1:void 0,"aria-current":f&&!m&&null!=n&&e.label===n||void 0,"aria-label":e.label,onKeyDown:f?r=>{var n;if("Enter"!==r.key&&" "!==r.key||(r.preventDefault(),t&&t(e)),"ArrowDown"===r.key||"ArrowUp"===r.key){r.preventDefault();const e=(l+("ArrowDown"===r.key?1:-1)+y.length)%y.length;c(s,e);const t=null===(n=r.currentTarget.parentElement)||void 0===n?void 0:n.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:f?t=>{c(s,l),r&&r(e);const n=t.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:f?e=>{r&&r(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:f?"pointer":"default",opacity:b,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},f&&u.createElement("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*e.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),v,x&&u.createElement(Ke,null),u.createElement("text",{y:8,x:22,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)"},e.label))),p+=22}),g})(e,r,n,o,i,a,s,y,c,l))),d+=22*e.items.length+8}),h})({legendGroups:t||[],width:c,customClickBehavior:r,customHoverBehavior:n,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:h,focusedItemIndex:g,onFocusedIndexChange:f,legendInteraction:a}):(({legendGroups:e,height:t,width:r,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:a,focusedGroupIndex:s,focusedItemIndex:c,onFocusedIndexChange:l,legendInteraction:d})=>{let h=0;const y=[];e.forEach((e,t)=>{let g=0;e.label&&(g+=16);const p=((e,t,r,n,o,i,a,s,c,l,d)=>{const{type:h="fill",styleFn:y,items:g}=e,p=[];let f=0,m=0;const v=!(!t&&!r),b="isolate"===l||void 0===l&&null!=o;g.forEach((e,l)=>{const x=Ve(e,l,h,y),k=Ue(e,n,o),A=o&&o.size>0&&o.has(e.label),w=26+7*e.label.length;d&&d>0&&f>0&&f+w>d&&(m++,f=0),p.push(u.createElement("g",{key:"legend-item-"+l,transform:`translate(${f},${22*m})`,onClick:t?()=>t(e):void 0,onMouseEnter:r?()=>r(e):void 0,onMouseLeave:r?()=>r(null):void 0,tabIndex:v?s===i&&l===a?0:-1:void 0,role:v?"option":void 0,"aria-selected":v&&b?A||!1:void 0,"aria-current":v&&!b&&null!=n&&e.label===n||void 0,"aria-label":e.label,onKeyDown:v?r=>{var n;if("Enter"!==r.key&&" "!==r.key||(r.preventDefault(),t&&t(e)),"ArrowRight"===r.key||"ArrowLeft"===r.key){r.preventDefault();const e=(l+("ArrowRight"===r.key?1:-1)+g.length)%g.length;c(s,e);const t=null===(n=r.currentTarget.parentElement)||void 0===n?void 0:n.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:v?t=>{c(s,l),r&&r(e);const n=t.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:v?e=>{r&&r(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:v?"pointer":"default",opacity:k,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},v&&u.createElement("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*e.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),x,A&&u.createElement(Ke,null),u.createElement("text",{y:8,x:22,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)"},e.label))),f+=w});let x=0,k=0;for(const e of g){const t=26+7*e.label.length;d&&d>0&&k>0&&k+t>d?(x=Math.max(x,k),k=t):k+=t}x=Math.max(x,k);const A=m+1;return{items:p,offset:x,totalRows:A,totalHeight:22*A}})(e,n,o,i,a,s,c,t,l,d,r);g+=p.offset+5,y.push(Object.assign(Object.assign({label:e.label},p),{offset:g,totalRows:p.totalRows,totalHeight:p.totalHeight})),h+=g+12});let g=h>r?0:Math.max(0,(r-h)/2);const p=[];return y.forEach((r,n)=>{const o=e[n];o.label&&(p.push(u.createElement("text",{key:"legend-text-"+n,transform:`translate(${g},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},o.label)),g+=16),p.push(u.createElement("g",{key:"legend-group-"+n,className:"legend-item",transform:`translate(${g},0)`},r.items)),g+=r.offset+5,e[n+1]&&p.push(u.createElement("line",{key:"legend-top-line legend-symbol-"+n,stroke:"gray",x1:g,y1:-8,x2:g,y2:(r.totalHeight||t)+0+8})),g+=12}),u.createElement("g",null,p)})({legendGroups:t||[],title:s,height:l,width:c,customClickBehavior:r,customHoverBehavior:n,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:h,focusedItemIndex:g,onFocusedIndexChange:f,legendInteraction:a}),v=!(!r&&!n);return u.createElement("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)"}},void 0!==s&&""!==s&&"vertical"===d&&u.createElement("text",{className:"legend-title",y:16,x:c/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)"},s),m)}function Je(e){const{width:t,height:r,totalWidth:n,totalHeight:o,margin:i,labels:a,title:s,legend:c,legendHoverBehavior:l,legendClickBehavior:d,legendHighlightedCategory:h,legendIsolatedCategories:y,legendPosition:g="right",foregroundGraphics:p,sceneNodes:f,annotations:m,svgAnnotationRules:v}=e;return u.createElement(u.Fragment,null,u.createElement("svg",{role:"img",width:n,height:o,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},u.createElement("title",null,"string"==typeof s?s:"Network Chart"),u.createElement("desc",null,"string"==typeof s?s+" — network data visualization":"Network data visualization"),u.createElement("g",{transform:`translate(${i.left},${i.top})`},a.map((e,t)=>u.createElement("text",{key:"label-"+t,x:e.x,y:e.y,textAnchor:e.anchor||"start",dominantBaseline:e.baseline||"middle",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"currentColor",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,style:{pointerEvents:"none"}},e.text)),m&&m.filter(e=>"widget"!==e.type).map((e,n)=>{if(v){const o=v(e,n,{width:t,height:r,sceneNodes:f});if(o)return u.createElement(u.Fragment,{key:"annotation-"+n},o)}return null}),p),s&&"string"==typeof s?u.createElement("text",{x:n/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor"},s):s?u.createElement("foreignObject",{x:0,y:0,width:n,height:i.top},s):null,function(e){const{legend:t,totalWidth:r,totalHeight:n,margin:o,legendPosition:i="right",title:a,legendHoverBehavior:s,legendClickBehavior:c,legendHighlightedCategory:l,legendIsolatedCategories:d,legendInteraction:h}=e;if(!t)return null;const y="top"===i||"bottom"===i;let g,p;return"left"===i?(g=4,p=o.top):"top"===i?(g=0,p=a?32:8):"bottom"===i?(g=0,p=n-o.bottom+50):(g=r-o.right+10,p=o.top),u.createElement("g",{transform:`translate(${g}, ${p})`},function(e){return"object"==typeof e&&null!==e&&"gradient"in e}(t)?u.createElement(Ze,{config:t.gradient,orientation:y?"horizontal":"vertical",width:y?r:100}):function(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}(t)?u.createElement(Qe,{legendGroups:t.legendGroups,title:"",width:y?r:100,orientation:y?"horizontal":"vertical",customHoverBehavior:s,customClickBehavior:c,highlightedCategory:l,isolatedCategories:d,legendInteraction:h}):t)}({legend:c,totalWidth:n,totalHeight:o,margin:i,legendPosition:g,title:s,legendHoverBehavior:l,legendClickBehavior:d,legendHighlightedCategory:h,legendIsolatedCategories:y})),null==m?void 0:m.filter(e=>"widget"===e.type&&e.nodeId&&f).map((e,t)=>{var r,n,o,a,s,c,l,d,h;const y=f.find(t=>{var r,n,o,i,a;return t.id===e.nodeId||(null===(r=t.datum)||void 0===r?void 0:r.id)===e.nodeId||(null===(o=null===(n=t.datum)||void 0===n?void 0:n.data)||void 0===o?void 0:o.id)===e.nodeId||(null===(a=null===(i=t.datum)||void 0===i?void 0:i.data)||void 0===a?void 0:a.name)===e.nodeId});if(!y)return null;const g=i.left+(null!==(r=y.cx)&&void 0!==r?r:null!=y.x&&null!=y.w?y.x+y.w/2:null!==(n=y.x)&&void 0!==n?n:0),p=i.top+(null!==(o=y.cy)&&void 0!==o?o:null!=y.y&&null!=y.h?y.y+y.h/2:null!==(a=y.y)&&void 0!==a?a:0),m=null!==(s=e.dx)&&void 0!==s?s:0,v=null!==(c=e.dy)&&void 0!==c?c:-16,b=null!==(l=e.width)&&void 0!==l?l:32,x=null!==(d=e.height)&&void 0!==d?d:32,k=null!==(h=e.content)&&void 0!==h?h:u.createElement("span",{style:{fontSize:18,cursor:"default"}},"ℹ️");return u.createElement("div",{key:"widget-"+t,style:{position:"absolute",left:g+m-b/2,top:p+v-x/2,width:b,height:x,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:5}},k)}))}function et(e,t="#4e79a7"){return e&&"string"==typeof e?e:t}Je.displayName="NetworkSVGOverlay";const tt="undefined"==typeof window||"undefined"==typeof document,rt=u.createContext(null),nt={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function ot(e,t,r){const n=[];return e>0&&n.push(e+" nodes"),t>0&&n.push(t+" edges"),0===n.length?r+", empty":`${r}, ${n.join(", ")}`}const it=e=>{if(null==e)return"";const t=Math.round(100*e)/100;return Number.isNaN(t)?"":t+""},at={position:"absolute",top:0,left:0,right:0,zIndex:5,padding:"14px 16px 12px",borderBottom:"1px solid 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-text, #333)",background:"var(--semiotic-bg, #fff)",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},st={marginBottom:8,paddingRight:28,color:"var(--semiotic-text-secondary, #666)",fontSize:12,letterSpacing:"0.01em"},ct={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-border, #e0e0e0)",background:"var(--semiotic-bg, #fff)",cursor:"pointer",color:"var(--semiotic-text-secondary, #666)",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},lt={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},ut={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-border, #e0e0e0)",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-text-secondary, #666)"},dt={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"},ht={textAlign:"left",fontSize:11,color:"var(--semiotic-text-secondary, #999)",marginBottom:4,fontStyle:"italic"};function yt({nodes:e,edges:t,chartType:r,tableId:n,chartTitle:o}){var i,a,s,c,l,d,h,y,g,p,f,m,v,b;const[x,k]=u.useState(!1),A=u.useContext(rt),w=null!==(i=null==A?void 0:A.visible)&&void 0!==i&&i,S=x||w,E=o?"Data summary for "+o:n?`Data summary for ${r} ${n}`:"Data summary for "+r,O=u.useRef(null),L=u.useCallback(()=>{x||w||k(!0)},[x,w]),j=u.useCallback(e=>{var t;w||(null===(t=O.current)||void 0===t?void 0:t.contains(e.relatedTarget))||k(!1)},[w]);if(!e||0===e.length)return n?u.createElement("span",{id:n,tabIndex:-1,style:nt}):null;if(!S)return u.createElement("div",{id:n,tabIndex:-1,onFocus:L,style:nt,role:"region","aria-label":E},u.createElement("button",{type:"button",onClick:()=>k(!0)},"View data summary (",e.length," nodes, ",t.length," edges)"));const C=Array.isArray(e)?e:[],D=Array.isArray(t)?t:[],M=new Map,I=new Map,P=new Map,T=new Map;for(const e of D){if(!e||"object"!=typeof e)continue;const t=null!==(a=e.datum)&&void 0!==a?a:e,r="object"==typeof t.source?null===(s=t.source)||void 0===s?void 0:s.id:t.source,n="object"==typeof t.target?null===(c=t.target)||void 0===c?void 0:c.id:t.target,o="number"==typeof t.value&&Number.isFinite(t.value)?t.value:0;if(null!=r&&""!==r){const e=r+"";I.set(e,(null!==(l=I.get(e))&&void 0!==l?l:0)+1),T.set(e,(null!==(d=T.get(e))&&void 0!==d?d:0)+o)}if(null!=n&&""!==n){const e=n+"";M.set(e,(null!==(h=M.get(e))&&void 0!==h?h:0)+1),P.set(e,(null!==(y=P.get(e))&&void 0!==y?y:0)+o)}}const N=[];for(let e=0;C.length>e;e++){const t=C[e];if(!t||"object"!=typeof t)continue;const r=null!==(p=null===(g=t.datum)||void 0===g?void 0:g.id)&&void 0!==p?p:t.id,n=null!=r?r+"":"node-"+e,o=null!==(f=M.get(n))&&void 0!==f?f:0,i=null!==(m=I.get(n))&&void 0!==m?m:0,a=null!==(v=P.get(n))&&void 0!==v?v:0,s=null!==(b=T.get(n))&&void 0!==b?b:0;N.push({id:n,degree:o+i,inDeg:o,outDeg:i,wDegree:a+s,wInDeg:a,wOutDeg:s})}N.sort((e,t)=>t.degree-e.degree);let _=0,$=0;if(N.length>0){let e=0;for(const t of N)e+=t.degree,t.degree>$&&($=t.degree);_=e/N.length}const B=D.some(e=>{var t;const r=null!==(t=null==e?void 0:e.datum)&&void 0!==t?t:e;return"number"==typeof(null==r?void 0:r.value)&&Number.isFinite(r.value)}),R=[`${N.length} nodes, ${D.length} edges.`];N.length>0&&R.push(`Mean degree: ${it(_)}, max degree: ${$}.`);const W=N.slice(0,5);return u.createElement("div",{ref:O,id:n,tabIndex:-1,onBlur:j,style:at,role:"region","aria-label":E},u.createElement("button",{type:"button",onClick:()=>{w&&A&&A.setVisible(!1),k(!1)},"aria-label":"Close data summary",style:ct},"×"),u.createElement("div",{role:"note",style:st},R.join(" ")),u.createElement("table",{role:"table","aria-label":"Node degree summary for "+r,style:lt},u.createElement("caption",{style:ht},"Top ",W.length," of ",N.length," nodes by degree"),u.createElement("thead",null,u.createElement("tr",null,u.createElement("th",{style:ut},"id"),u.createElement("th",{style:ut},"degree"),u.createElement("th",{style:ut},"in"),u.createElement("th",{style:ut},"out"),B&&u.createElement("th",{style:ut},"w. degree"),B&&u.createElement("th",{style:ut},"w. in"),B&&u.createElement("th",{style:ut},"w. out"))),u.createElement("tbody",null,W.map((e,t)=>u.createElement("tr",{key:t},u.createElement("td",{style:dt},e.id),u.createElement("td",{style:dt},e.degree),u.createElement("td",{style:dt},e.inDeg),u.createElement("td",{style:dt},e.outDeg),B&&u.createElement("td",{style:dt},it(e.wDegree)),B&&u.createElement("td",{style:dt},it(e.wInDeg)),B&&u.createElement("td",{style:dt},it(e.wOutDeg)))))))}function gt({summary:e}){return e?u.createElement("div",{role:"note",style:nt},e):null}function pt({tableId:e}){return u.createElement("a",{href:"#"+e,style:nt,onClick:t=>{t.preventDefault();const r=document.getElementById(e);r&&requestAnimationFrame(()=>r.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,nt)}},"Skip to data table")}function ft({hoverPoint:e}){let t="";if(e){const r=e.data||e;t="object"==typeof r?"Focused on data point: "+Object.entries(r).filter(([,e])=>"object"!=typeof e&&"function"!=typeof e).map(([e,t])=>`${e}: ${t}`).join(", "):"Focused on data point: "+r}return u.createElement("div",{"aria-live":"polite","aria-atomic":"true",style:nt},t)}function mt(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function vt(e,t,r=.3){mt(t)&&(e.globalAlpha=t._pulseIntensity*r,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h))}function bt(e,t,r=.6){var n,o,i,a,s;if(!mt(t))return;const c=null!==(n=t._pulseGlowRadius)&&void 0!==n?n:4,l=t.r+c*t._pulseIntensity,u=null!==(i=null!==(o=t.cx)&&void 0!==o?o:t.x)&&void 0!==i?i:0,d=null!==(s=null!==(a=t.cy)&&void 0!==a?a:t.y)&&void 0!==s?s:0;e.beginPath(),e.arc(u,d,l,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=t._pulseIntensity*r,e.stroke()}function xt(e,t){var r,n,o,i,a,s;if(!t.pathD)return;e.save();const c=new Path2D(t.pathD);if(t.style.fill&&"none"!==t.style.fill){const a=t._gradient;if(a){const o=e.createLinearGradient(a.x0,0,a.x1,0),i=null!==(n=null!==(r=t.style.fillOpacity)&&void 0!==r?r:t.style.opacity)&&void 0!==n?n:.5,s="string"==typeof t.style.fill?t.style.fill:"#999";o.addColorStop(0,1===a.from?s:"transparent"),o.addColorStop(1,1===a.to?s:"transparent"),e.fillStyle=o,e.globalAlpha=i}else e.fillStyle=t.style.fill,e.globalAlpha=null!==(i=null!==(o=t.style.fillOpacity)&&void 0!==o?o:t.style.opacity)&&void 0!==i?i:.5;e.fill(c)}t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(a=t.style.strokeWidth)&&void 0!==a?a:.5,e.globalAlpha=.5*(null!==(s=t.style.opacity)&&void 0!==s?s:1),e.stroke(c)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.2*t._pulseIntensity,e.fill(c)),e.restore()}function kt(e,t){var r,n;e.save(),e.strokeStyle=t.style.stroke||"#999",e.lineWidth=null!==(r=t.style.strokeWidth)&&void 0!==r?r:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.strokeDasharray&&e.setLineDash(t.style.strokeDasharray.split(/[\s,]+/).map(Number)),e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke(),t._pulseIntensity&&t._pulseIntensity>0&&(e.setLineDash([]),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=(null!==(n=t.style.strokeWidth)&&void 0!==n?n:1)+3*t._pulseIntensity,e.globalAlpha=.4*t._pulseIntensity,e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke()),e.restore()}function At(e,t){var r,n,o,i;if(!t.pathD)return;e.save();const a=new Path2D(t.pathD);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=t.style.fill,e.globalAlpha=null!==(n=null!==(r=t.style.fillOpacity)&&void 0!==r?r:t.style.opacity)&&void 0!==n?n:.5,e.fill(a)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(o=t.style.strokeWidth)&&void 0!==o?o:.5,e.globalAlpha=.3*(null!==(i=t.style.opacity)&&void 0!==i?i:1),e.stroke(a)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.25*t._pulseIntensity,e.fill(a)),e.restore()}function wt(e,t){var r,n;if(!t.pathD)return;e.save();const o=new Path2D(t.pathD);e.strokeStyle=t.style.stroke||"#999",e.lineWidth=null!==(r=t.style.strokeWidth)&&void 0!==r?r:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.stroke(o),t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=t.style.fill,e.globalAlpha=null!==(n=t.style.fillOpacity)&&void 0!==n?n:.1,e.fill(o)),e.restore()}const St={category10:n.schemeCategory10,tableau10:n.schemeTableau10,set3:n.schemeSet3,blues:n.interpolateBlues,reds:n.interpolateReds,greens:n.interpolateGreens,oranges:n.interpolateOranges,purples:n.interpolatePurples,viridis:n.interpolateViridis,plasma:n.interpolatePlasma},Et=n.schemeCategory10,Ot=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],Lt=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"],jt=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 Ct(e,t,r){if("function"==typeof t){const n=t(e);return r&&n&&"string"==typeof n&&!function(e){const t=e.toLowerCase();return t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||jt.has(t)}(n)?r(n):n}const n=null==e?void 0:e[t];return r?r(n):Et[Math.abs(function(e){let t=0;for(let r=0;e.length>r;r++)t=(t<<5)-t+e.charCodeAt(r),t&=t;return Math.abs(t)}(n+""))%Et.length]}function Dt(e,t,r="category10"){const n=Array.from(new Set(e.map(e=>null==e?void 0:e[t]).filter(e=>null!=e))),o=n.every(e=>"number"==typeof e||!isNaN(Number(e)));if(Array.isArray(r))return i.scaleOrdinal().domain(n).range(r).unknown("#999");const a=St[r]||St.category10;if(o&&"function"==typeof a){let e=-1/0;for(const t of n){const r=Number(t);r>e&&(e=r)}return t=>a(Number(t)/e)}{const e=Array.isArray(a)?a:Et;return i.scaleOrdinal().domain(n).range(e).unknown("#999")}}function Mt(t){const r=e.createContext(null),n=It(t);return[function({children:n}){const o=e.useMemo(()=>It(t),[]);return u.createElement(r.Provider,{value:o,children:n})},t=>{var o;const i=null!==(o=e.useContext(r))&&void 0!==o?o:n,a=e.useRef(t);a.current=t;const s=e.useCallback(()=>a.current(i.getState()),[i]),c=e.useCallback(()=>a.current(i.getState()),[i]);return e.useSyncExternalStore(i.subscribe,s,c)}]}function It(e){const t=new EventTarget;let r=e(function(e){r=Object.assign(Object.assign({},r),e(r)),t.dispatchEvent(new CustomEvent("update"))});return{getState:()=>r,subscribe:function(e){return t.addEventListener("update",e),()=>t.removeEventListener("update",e)}}}const Pt={mode:"light",colors:{primary:"#00a2ce",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",diverging:"RdBu",background:"transparent",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc",selection:"#00a2ce",selectionOpacity:.15},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},Tt={mode:"dark",colors:{primary:"#4fc3f7",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",diverging:"RdBu",background:"#1a1a2e",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555",selection:"#4fc3f7",selectionOpacity:.15},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},Nt={mode:"light",colors:{primary:"#0000cc",categorical:["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],sequential:"blues",diverging:"RdBu",background:"#ffffff",text:"#000000",textSecondary:"#333333",grid:"#999999",border:"#000000",focus:"#0000cc",selection:"#0000cc",selectionOpacity:.1},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"},[_t,$t]=Mt(e=>({theme:Pt,setTheme(t){e(e=>{if("light"===t)return{theme:Pt};if("dark"===t)return{theme:Tt};if("high-contrast"===t)return{theme:Nt};if(t.mode&&"auto"!==t.mode){const e="dark"===t.mode?Tt:Pt;return{theme:Object.assign(Object.assign(Object.assign({},e),t),{colors:Object.assign(Object.assign({},e.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.typography),t.typography||{})})}}return{theme:Object.assign(Object.assign(Object.assign({},e.theme),t),{colors:Object.assign(Object.assign({},e.theme.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.theme.typography),t.typography||{})})}})}})),Bt={top:20,right:80,bottom:20,left:80},Rt={top:40,right:40,bottom:40,left:40},Wt=new Set(["chord","force","circlepack","orbit"]),zt=[800,600],Ht={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,lineHeight:1.5,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function Ft({data:e}){var t,r,n,o,i,a;if("edge"===e.nodeOrEdge){const t=e.data;return u.createElement("div",{className:"semiotic-tooltip",style:Ht},u.createElement("div",{style:{fontWeight:600}},"object"==typeof t.source?t.source.id:t.source," → ","object"==typeof t.target?t.target.id:t.target),null!=t.value&&u.createElement("div",{style:{marginTop:4,opacity:.8}},"Value:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""))}const s=e.data,c=null==s?void 0:s.__hierarchyNode;if(c){const e=[];let i=c;for(;i;){const a=null!==(o=null!==(r=null===(t=i.data)||void 0===t?void 0:t.name)&&void 0!==r?r:null===(n=i.data)||void 0===n?void 0:n.id)&&void 0!==o?o:s.id;null!=a&&e.unshift(a+""),i=i.parent}e.length>1&&e.shift();const a=e.length-1;return u.createElement("div",{className:"semiotic-tooltip",style:Ht},u.createElement("div",null,e.map((e,t)=>u.createElement("span",{key:t},t>0&&u.createElement("span",{style:{margin:"0 3px",opacity:.5}}," → "),t===a?u.createElement("strong",null,e):u.createElement("span",{style:{opacity:.7}},e)))),null!=s.value&&s.value>0&&u.createElement("div",{style:{marginTop:4,opacity:.8}},"number"==typeof s.value?s.value.toLocaleString():s.value+""))}const l=((null===(i=s.sourceLinks)||void 0===i?void 0:i.length)||0)+((null===(a=s.targetLinks)||void 0===a?void 0:a.length)||0),d=(s.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(s.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0);return u.createElement("div",{className:"semiotic-tooltip",style:Ht},u.createElement("div",{style:{fontWeight:600}},s.id),null!=s.value&&s.value>0&&u.createElement("div",{style:{marginTop:4,opacity:.8}},"Total:"," ","number"==typeof s.value?s.value.toLocaleString():s.value+""),l>0&&u.createElement("div",{style:{marginTop:4,opacity:.8}},"Connections: ",l,d!==l&&` (weighted: ${d.toLocaleString()})`))}const qt=e.forwardRef(function(t,r){var n,o,i,a,c,l,g,p,f,m,v,b,x,k;const{chartType:A,nodes:w,edges:S,data:E,initialEdges:O,nodeIDAccessor:L="id",sourceAccessor:j="source",targetAccessor:C="target",valueAccessor:D="value",edgeIdAccessor:M,childrenAccessor:I,hierarchySum:P,orientation:T="horizontal",nodeAlign:N="justify",nodePaddingRatio:_=.05,nodeWidth:$=15,iterations:B=300,forceStrength:R=.1,padAngle:W=.01,groupWidth:z=20,sortGroups:H,edgeSort:F,treeOrientation:q="vertical",edgeType:Y="curve",padding:G,paddingTop:X,tensionConfig:V,showParticles:K=!1,particleStyle:U,nodeStyle:Z,edgeStyle:Q,colorBy:J,colorScheme:ee="category10",edgeColorBy:te="source",edgeOpacity:re=.5,colorByDepth:ne=!1,nodeSize:oe=8,nodeSizeRange:ie=[5,20],nodeLabel:ae,showLabels:se=!0,labelMode:ce,size:le=zt,responsiveWidth:ue,responsiveHeight:de,margin:he,className:ye,background:ge,enableHover:pe=!0,tooltipContent:fe,customHoverBehavior:me,customClickBehavior:ve,onObservation:be,chartId:xe,onTopologyChange:ke,annotations:Ae,svgAnnotationRules:we,legend:Se,legendPosition:Ee,legendHoverBehavior:Oe,legendClickBehavior:Le,legendHighlightedCategory:je,legendIsolatedCategories:Ce,title:De,foregroundGraphics:Me,backgroundGraphics:Ie,decay:Te,pulse:Ne,staleness:$e,thresholds:Be,accessibleTable:Re=!0,description:We,summary:ze,orbitMode:Fe,orbitSize:qe,orbitSpeed:Xe,orbitRevolution:Ve,orbitRevolutionStyle:Ke,orbitEccentricity:Ue,orbitShowRings:Ze,orbitAnimated:Qe}=t,rt=function(){const[t,r]=e.useState(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return e.useEffect(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)");return r(e.matches),function(e,t){return"function"==typeof e.addEventListener?(e.addEventListener("change",t),()=>e.removeEventListener("change",t)):(e.addListener(t),()=>e.removeListener(t))}(e,e=>r(e.matches))},[]),t}(),nt=e.useRef(rt);nt.current=rt;const it="semiotic-table-"+u.useId(),at=Wt.has(A)?Rt:Bt,[st,ct]=function(t,r,n){const o=e.useRef(null),[i,a]=e.useState(null);return e.useEffect(()=>{if(!r&&!n)return;const e=o.current;if(!e)return;const t=new ResizeObserver(e=>{for(const t of e){const{width:e,height:r}=t.contentRect;a(t=>t&&t.w===e&&t.h===r?t:{w:e,h:r})}});return t.observe(e),()=>t.disconnect()},[r,n]),[o,[r&&i?i.w:t[0],n&&i?i.h:t[1]]]}(le,ue,de),lt=Object.assign(Object.assign({},at),he),ut=ct[0]-lt.left-lt.right,dt=ct[1]-lt.top-lt.bottom,ht="function"==typeof Me?Me({size:ct,margin:lt}):Me,mt=e.useMemo(()=>Object.assign(Object.assign({},h),V),[V]),St=e.useMemo(()=>Object.assign(Object.assign({},y),U),[U]),Ot=e.useMemo(()=>({chartType:A,nodeIDAccessor:L,sourceAccessor:j,targetAccessor:C,valueAccessor:D,edgeIdAccessor:M,childrenAccessor:I,hierarchySum:P,orientation:T,nodeAlign:N,nodePaddingRatio:_,nodeWidth:$,iterations:B,forceStrength:R,padAngle:W,groupWidth:z,sortGroups:H,edgeSort:F,treeOrientation:q,edgeType:Y,padding:G,paddingTop:X,tensionConfig:mt,showParticles:K,particleStyle:St,nodeStyle:Z,edgeStyle:Q,nodeLabel:ae,showLabels:se,labelMode:ce,colorBy:J,colorScheme:ee,edgeColorBy:te,edgeOpacity:re,colorByDepth:ne,nodeSize:oe,nodeSizeRange:ie,decay:Te,pulse:Ne,staleness:$e,thresholds:Be,orbitMode:Fe,orbitSize:qe,orbitSpeed:Xe,orbitRevolution:Ve,orbitRevolutionStyle:Ke,orbitEccentricity:Ue,orbitShowRings:Ze,orbitAnimated:Qe}),[A,L,j,C,D,I,P,T,N,_,$,B,R,W,z,H,F,q,Y,G,X,mt,K,St,Z,Q,ae,se,ce,J,ee,te,re,ne,oe,ie,Te,Ne,$e,Be,Fe,qe,Xe,Ve,Ke,Ue,Ze,Qe]),Lt=e.useRef(null),jt=e.useRef(0),Ct=e.useRef(0),Dt=e.useRef(!0),Mt=$t(e=>e.theme),It=e.useRef(()=>{}),Pt=e.useRef(null);Pt.current||(Pt.current=new Pe(Ot));const[Tt,Nt]=e.useState(null),[_t,Ht]=e.useState(0),[qt,Yt]=e.useState(0),[Gt,Xt]=e.useState(!1),Vt=e.useRef(null),Kt=e.useRef(new Map),Ut=e.useRef(0),Zt=e.useCallback(e=>{if("function"==typeof J)return J(e)+"";if("string"==typeof J&&e.data){const t=e.data[J];if(void 0!==t){if(!Kt.current.has(t+"")){const e=Array.isArray(ee)?ee:Et;Kt.current.set(t+"",e[Ut.current++%e.length])}return Kt.current.get(t+"")}}if(Kt.current.has(e.id))return Kt.current.get(e.id);const t=Array.isArray(ee)?ee:Et,r=J?t[Ut.current++%t.length]:t[0];return Kt.current.set(e.id,r),r},[J,ee]),Qt=e.useCallback(e=>{if("function"==typeof te)return te(e);const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;return"target"===te&&r?Zt(r):t?Zt(t):"#999"},[te,Zt]),Jt=e.useCallback(e=>{if(!(null==U?void 0:U.colorBy))return Qt(e);const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;return"target"===St.colorBy&&r?Zt(r):t?Zt(t):"#999"},[null==U?void 0:U.colorBy,St.colorBy,Zt,Qt]),er="sankey"===A&&K||!!Ne||null!==(o=null===(n=Pt.current)||void 0===n?void 0:n.isAnimating)&&void 0!==o&&o,tr=e.useCallback(()=>{jt.current&&!er||jt.current||(jt.current=requestAnimationFrame(()=>It.current()))},[er]);e.useEffect(()=>{var e;null===(e=Pt.current)||void 0===e||e.updateConfig(Ot),Dt.current=!0,tr()},[Ot,tr]),e.useEffect(()=>{Dt.current=!0,tr()},[Mt,tr]);const rr=e.useCallback(()=>{var e;const t=Pt.current;if(!t)return;t.runLayout([ut,dt]),t.buildScene([ut,dt]),Dt.current=!0;for(const r of t.sceneNodes)r.id&&"string"==typeof(null===(e=r.style)||void 0===e?void 0:e.fill)&&Kt.current.set(r.id,r.style.fill);const r=Array.isArray(ee)?ee:Et,n=Array.from(t.nodes.values());for(let e=0;n.length>e;e++){const t=n[e];Kt.current.has(t.id)||Kt.current.set(t.id,r[e%r.length])}if(Ut.current=n.length,Ht(t.layoutVersion),ke){const{nodes:e,edges:r}=t.getLayoutData();ke(e,r)}},[ut,dt,ke,ee]),nr=e.useCallback(e=>{const t=Pt.current;t&&(t.ingestEdge(e)&&rr(),tr())},[rr,tr]),or=e.useCallback(e=>{const t=Pt.current;if(!t)return;let r=!1;for(const n of e)t.ingestEdge(n)&&(r=!0);r&&rr(),tr()},[rr,tr]),ir=e.useCallback(()=>{var e;null===(e=Pt.current)||void 0===e||e.clear(),Kt.current.clear(),Ut.current=0,Ht(0),Nt(null),Vt.current=null,Dt.current=!0,tr()},[tr]),ar=e.useCallback(()=>{const e=Pt.current;e&&(e.tension+=999,rr(),tr())},[rr,tr]);e.useImperativeHandle(r,()=>({push:nr,pushMany:or,removeNode:e=>{var t,r,n;const o=null!==(r=null===(t=Pt.current)||void 0===t?void 0:t.removeNode(e))&&void 0!==r&&r;if(o){const t=(null===(n=Vt.current)||void 0===n?void 0:n.data)?"function"==typeof L?L(Vt.current.data):Vt.current.data[L]:void 0;Vt.current&&"node"===Vt.current.nodeOrEdge&&t===e&&(Vt.current=null,Nt(null)),Kt.current.delete(e),rr(),Dt.current=!0,tr()}return o},removeEdge:(e,t)=>{var r,n;const o=null!==(n=null===(r=Pt.current)||void 0===r?void 0:r.removeEdge(e,t))&&void 0!==n&&n;if(o){if(Vt.current&&"edge"===Vt.current.nodeOrEdge){const r=Vt.current.data;let n;n=void 0!==t?("object"==typeof(null==r?void 0:r.source)?r.source.id:null==r?void 0:r.source)===e&&("object"==typeof(null==r?void 0:r.target)?r.target.id:null==r?void 0:r.target)===t:!M||!r||("function"==typeof M?M:e=>null==e?void 0:e[M])(r)===e,n&&(Vt.current=null,Nt(null))}rr(),Dt.current=!0,tr()}return o},updateNode:(e,t)=>{var r,n;const o=null!==(n=null===(r=Pt.current)||void 0===r?void 0:r.updateNode(e,t))&&void 0!==n?n:null;return o&&(Dt.current=!0,tr()),o},updateEdge:(e,t,r)=>{var n,o;const i=null!==(o=null===(n=Pt.current)||void 0===n?void 0:n.updateEdge(e,t,r))&&void 0!==o?o:[];return i.length>0&&(rr(),Dt.current=!0,tr()),i},clear:ir,getTopology:()=>{var e,t;return null!==(t=null===(e=Pt.current)||void 0===e?void 0:e.getLayoutData())&&void 0!==t?t:{nodes:[],edges:[]}},getTopologyDiff:()=>{const e=Pt.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:ar,getTension:()=>{var e,t;return null!==(t=null===(e=Pt.current)||void 0===e?void 0:e.tension)&&void 0!==t?t:0}}),[nr,or,ir,ar,rr,tr]);const sr=["tree","cluster","treemap","circlepack","partition","orbit"].includes(A),cr=sr?E||(Array.isArray(S)?void 0:S):void 0;e.useEffect(()=>{var e;const t=Pt.current;if(t)if(sr&&cr)t.ingestHierarchy(cr,[ut,dt]),t.buildScene([ut,dt]),Dt.current=!0,tr();else{const r=w||[],n=Array.isArray(S)?S:[];if(0===r.length&&0===n.length)return;t.ingestBounded(r,n,[ut,dt]),t.buildScene([ut,dt]);for(const r of t.sceneNodes)r.id&&(null===(e=r.style)||void 0===e?void 0:e.fill)&&Kt.current.set(r.id,r.style.fill+"");const o=Array.isArray(ee)?ee:Et,i=Array.from(t.nodes.values());for(let e=0;i.length>e;e++){const t=i[e];Kt.current.has(t.id)||Kt.current.set(t.id,o[e%o.length])}Ut.current=i.length,Dt.current=!0,tr()}},[w,S,E,cr,sr,ut,dt,Ot,tr,ee]),e.useEffect(()=>{O&&O.length>0&&or(O)},[]);const lr=e.useCallback(e=>{if(me&&me(e),be){const t=Date.now();be(e?{type:"hover",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:xe}:{type:"hover-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:xe})}},[me,be,xe]),ur=e.useCallback(e=>{if(ve&&ve(e),be){const t=Date.now();be(e?{type:"click",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:xe}:{type:"click-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:xe})}},[ve,be,xe]),dr=e.useRef(()=>{}),hr=e.useRef(()=>{});dr.current=e=>{if(!pe)return;const t=Lt.current;if(!t)return;const r=t.getBoundingClientRect(),n=e.clientX-r.left-lt.left,o=e.clientY-r.top-lt.top;if(0>n||n>ut||0>o||o>dt)return void(Vt.current&&(Vt.current=null,Nt(null),lr&&(lr(null),Dt.current=!0),tr()));const i=Pt.current;if(!i)return;const a=_e(i.sceneNodes,i.sceneEdges,n,o);if(!a)return void(Vt.current&&(Vt.current=null,Nt(null),lr&&(lr(null),Dt.current=!0),tr()));const s=d(a.datum||{},a.x,a.y,{nodeOrEdge:a.type});Vt.current=s,Nt(s),lr&&(lr(s),Dt.current=!0),tr()},hr.current=()=>{Vt.current&&(Vt.current=null,Nt(null),lr&&(lr(null),Dt.current=!0),tr())};const yr=e.useRef(()=>{});yr.current=e=>{if(!ve&&!be)return;const t=Lt.current;if(!t)return;const r=t.getBoundingClientRect(),n=e.clientX-r.left-lt.left,o=e.clientY-r.top-lt.top;if(0>n||n>ut||0>o||o>dt)return;const i=Pt.current;if(!i)return;const a=_e(i.sceneNodes,i.sceneEdges,n,o);ur(a?d(a.datum||{},a.x,a.y,{nodeOrEdge:a.type}):null)},e.useCallback(e=>dr.current(e),[]);const gr=e.useCallback(()=>hr.current(),[]),pr=e.useCallback(e=>yr.current(e),[]),fr=e.useRef(-1),mr=e.useRef(null),vr=e.useRef(-1),br=e.useCallback(e=>{var t;const r=Pt.current;if(!r)return;const n=function(e){var t,r,n,o,i,a;const s=[];for(const c of e)"circle"===c.type&&null!=c.cx?s.push({x:c.cx,y:c.cy,datum:c.datum,shape:"circle",group:null!==(r=null===(t=c.datum)||void 0===t?void 0:t.id)&&void 0!==r?r:"_default"}):"rect"===c.type&&null!=c.x?s.push({x:c.x+c.w/2,y:c.y+c.h/2,datum:c.datum,shape:"rect",w:c.w,h:c.h,group:null!==(o=null===(n=c.datum)||void 0===n?void 0:n.id)&&void 0!==o?o:"_default"}):"arc"===c.type&&null!=c.cx&&s.push({x:c.cx,y:c.cy,datum:c.datum,shape:"circle",group:null!==(a=null===(i=c.datum)||void 0===i?void 0:i.id)&&void 0!==a?a:"_default"});return s.sort((e,t)=>e.x-t.x||e.y-t.y),s}(r.sceneNodes);if(0===n.length)return;const o=function(e){var t,r;const n=new Map;for(const r of e){const e=null!==(t=r.group)&&void 0!==t?t:"_default";let o=n.get(e);o||(o=[],n.set(e,o)),o.push(r)}for(const e of n.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 o=Array.from(n.keys()).sort((e,t)=>{const r=n.get(e),o=n.get(t);return(r.length>0?r[0].y:0)-(o.length>0?o[0].y:0)}),i=Array.from(n.values()).flat();i.sort((e,t)=>e.x-t.x||e.y-t.y);const a=new Map;for(let e=0;i.length>e;e++){i[e]._flatIndex=e;const t=null===(r=i[e].datum)||void 0===r?void 0:r.id;null!=t&&a.set(t+"",e)}return{flat:i,groups:o,byGroup:n,idToIdx:a}}(n),i=fr.current;if(0>i){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Enter"].includes(e.key))return;e.preventDefault(),fr.current=0,vr.current=-1;const t=o.flat[0];mr.current={shape:t.shape,w:t.w,h:t.h};const r=d(t.datum||{},t.x,t.y,{nodeOrEdge:"node"});return Vt.current=r,Nt(r),lr&&(lr(r),Dt.current=!0),void tr()}const a=function(e,t){var r,n;if(0===e.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const o=Math.max(0,Math.min(t,e.flat.length-1)),i=e.flat[o];return{flatIndex:o,group:null!==(r=i.group)&&void 0!==r?r:"_default",indexInGroup:null!==(n=i._groupIndex)&&void 0!==n?n:0}}(o,i),s=function(e,t,r,n,o){var i,a,s;const c=r.flat[t.flatIndex];if(!c)return He(e,t,r);const l=null===(i=c.datum)||void 0===i?void 0:i.id;switch(e){case"ArrowRight":case"ArrowLeft":case"ArrowDown":case"ArrowUp":{const n=null!==(a=function(e,t,r){let n=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,c=a.y-t.y;let l=!1;switch(r){case"right":l=s>0&&Math.abs(s)>=Math.abs(c);break;case"left":l=0>s&&Math.abs(s)>=Math.abs(c);break;case"down":l=c>0&&Math.abs(c)>=Math.abs(s);break;case"up":l=0>c&&Math.abs(c)>=Math.abs(s)}if(!l)continue;const u=s*s+c*c;o>u&&(o=u,n=i)}return n}(r,c,"ArrowRight"===e?"right":"ArrowLeft"===e?"left":"ArrowDown"===e?"down":"up"))&&void 0!==a?a:t.flatIndex;return n!==t.flatIndex&&(o.current=-1),n}case"Enter":{if(null==l)return t.flatIndex;const e=function(e,t){var r,n,o;const i=e+"",a=[];for(const e of t){const t=null!==(r=e.datum)&&void 0!==r?r:e,s="object"==typeof t.source?null===(n=t.source)||void 0===n?void 0:n.id:t.source,c="object"==typeof t.target?null===(o=t.target)||void 0===o?void 0:o.id:t.target,l=null!=s,u=null!=c;l&&s+""===i&&u?a.push(c+""):u&&c+""===i&&l&&a.push(s+"")}return a}(l,n);if(0===e.length)return t.flatIndex;const i=null!==(s=r.idToIdx.get(e[(o.current+1)%e.length]))&&void 0!==s?s:-1;return 0>i?t.flatIndex:(o.current=-1,i)}default:{const n=He(e,t,r);return null!==n&&n!==t.flatIndex&&(o.current=-1),n}}}(e.key,a,o,null!==(t=r.sceneEdges)&&void 0!==t?t:[],vr);if(null===s)return;if(e.preventDefault(),0>s)return fr.current=-1,mr.current=null,vr.current=-1,Vt.current=null,Nt(null),lr&&(lr(null),Dt.current=!0),void tr();fr.current=s;const c=o.flat[s];mr.current={shape:c.shape,w:c.w,h:c.h};const l=c.datum||{},u=Object.assign(Object.assign({},"object"!=typeof l||null===l||Array.isArray(l)?{}:l),{data:l,x:c.x,y:c.y,time:c.x,value:c.y,nodeOrEdge:"node"});Vt.current=u,Nt(u),lr&&(lr(u),Dt.current=!0),tr()},[lr,tr]),xr=e.useCallback(e=>{fr.current=-1,mr.current=null,dr.current(e)},[]);It.current=()=>{var e,t,r,n,o,i,a;jt.current=0;const s=Lt.current;if(!s)return;const c=s.getContext("2d");if(!c)return;const l=Pt.current;if(!l)return;const u=performance.now(),d=Ct.current?Math.min((u-Ct.current)/1e3,.1):.016;Ct.current=u;const h=l.advanceTransition(nt.current?u+1e6:u),g=!nt.current&&h,p=!nt.current&&l.tickAnimation([ut,dt],d);(h||Dt.current||p)&&l.buildScene([ut,dt]);const f="undefined"!=typeof window&&window.devicePixelRatio||1;if(!function(e,t,r,n){const o=e.getContext("2d");if(!o)return null;const i=t[0]*n,a=t[1]*n,s=t[0]+"px",c=t[1]+"px";return e.style.width!==s&&(e.style.width=s),e.style.height!==c&&(e.style.height=c),e.width===i&&e.height===a||(e.width=i,e.height=a),o.setTransform(n,0,0,n,0,0),o.translate(r.left,r.top),o}(s,ct,lt,f))return;c.clearRect(-lt.left,-lt.top,ct[0],ct[1]),ge&&(c.fillStyle=ge,c.fillRect(0,0,ut,dt)),Te&&l.applyDecay(),Ne&&l.applyPulse(u),Be&&l.applyThresholds(u),l.applyTopologyDiff(u);const m=null!==(e=null==$e?void 0:$e.threshold)&&void 0!==e?e:5e3,v=$e&&l.lastIngestTime>0&&u-l.lastIngestTime>m;if(v&&(c.globalAlpha=null!==(t=null==$e?void 0:$e.dimOpacity)&&void 0!==t?t:.5),function(e,t){for(const r of t)switch(r.type){case"bezier":xt(e,r);break;case"line":kt(e,r);break;case"ribbon":At(e,r);break;case"curved":wt(e,r)}}(c,l.sceneEdges),function(e,t){var r,n,o;for(const i of t){if("rect"!==i.type)continue;const t=i;t.w>0&&t.h>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(r=t.style.opacity)&&void 0!==r?r:1)*t.style.fillOpacity),e.fillRect(t.x,t.y,t.w,t.h)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,e.globalAlpha=null!==(o=t.style.opacity)&&void 0!==o?o:1,e.strokeRect(t.x,t.y,t.w,t.h)),vt(e,t),e.restore())}}(c,l.sceneNodes),function(e,t){var r,n,o;for(const i of t){if("circle"!==i.type)continue;const t=i;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),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(r=t.style.opacity)&&void 0!==r?r:1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,e.globalAlpha=null!==(o=t.style.opacity)&&void 0!==o?o:1,e.stroke()),bt(e,t),e.restore())}}(c,l.sceneNodes),function(e,t){var r,n,o;for(const i of t){if("arc"!==i.type)continue;const t=i;e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.outerR,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerR,t.endAngle,t.startAngle,!0),e.closePath(),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(r=t.style.opacity)&&void 0!==r?r:1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,e.globalAlpha=null!==(o=t.style.opacity)&&void 0!==o?o:1,e.stroke()),e.restore()}}(c,l.sceneNodes),K&&l.particlePool&&!v){const e=Array.from(l.edges.values());if(e.length>0){!function(e,t,r,n){var o,i;const a=null!==(o=n.spawnRate)&&void 0!==o?o:y.spawnRate,s=null!==(i=n.maxPerEdge)&&void 0!==i?i:y.maxPerEdge;for(let n=0;t.length>n;n++){const o=t[n];if(!o.bezier)continue;if(e.countForEdge(n)>=s)continue;const i=o.value*a*r*(o.bezier.circular?.3:1),c=Math.floor(i),l=i-c;let u=c;Math.random()<l&&u++;for(let t=0;u>t&&e.countForEdge(n)<s;t++)e.spawn(n)}}(l.particlePool,e,d,St);const t=.5*(null!==(r=St.speedMultiplier)&&void 0!==r?r:1);let n;if(St.proportionalSpeed){const t=e.reduce((e,t)=>Math.max(e,t.value||1),1);n=e.map(e=>.3+(e.value||1)/t*1.7)}l.particlePool.step(d,t,e,n),function(e,t,r,n,o){var i,a;const s=null!==(i=n.radius)&&void 0!==i?i:y.radius,c=null!==(a=n.opacity)&&void 0!==a?a:y.opacity;e.globalAlpha=c;for(let i=0;t.particles.length>i;i++){const a=t.particles[i];if(!a.active)continue;const c=r[a.edgeIndex];if(c){if("function"==typeof n.color){const t="object"==typeof c.source?c.source:null;e.fillStyle=t?n.color(c,t):"#666"}else e.fillStyle=n.color&&"inherit"!==n.color?n.color:o(c);e.beginPath(),e.arc(a.x,a.y,s,0,2*Math.PI),e.fill()}}e.globalAlpha=1}(c,l.particlePool,e,St,Jt)}}v&&(c.globalAlpha=1);const b=Dt.current;if(Dt.current=!1,b||g||p){const e=Lt.current;e&&e.setAttribute("aria-label",ot(null!==(o=null===(n=l.sceneNodes)||void 0===n?void 0:n.length)&&void 0!==o?o:0,null!==(a=null===(i=l.sceneEdges)||void 0===i?void 0:i.length)&&void 0!==a?a:0,"Network chart"))}(b||g||p)&&Yt(e=>e+1),(er||g||p||l.hasActivePulses||l.hasActiveThresholds||l.hasActiveTopologyDiff)&&(jt.current=requestAnimationFrame(()=>It.current()))},e.useEffect(()=>(tr(),()=>{jt.current&&(cancelAnimationFrame(jt.current),jt.current=0)}),[tr]),e.useEffect(()=>{Dt.current=!0,tr()},[A,ut,dt,ge,tr]),function(t,r,n,o,i,a){e.useEffect(()=>{if(!t)return;const e=setInterval(()=>{var e;const s=r.current;if(!s||0===s.lastIngestTime)return;const c="undefined"!=typeof performance?performance.now():Date.now(),l=null!==(e=t.threshold)&&void 0!==e?e:5e3,u=c-s.lastIngestTime>l;u!==i&&(a(u),n.current=!0,o())},1e3);return()=>clearInterval(e)},[t,i,o])}($e,Pt,Dt,tr,Gt,Xt);const kr=pe&&Tt?u.createElement(Ge,{x:Tt.x,y:Tt.y,containerWidth:ut,containerHeight:dt,margin:lt,className:"stream-network-tooltip",zIndex:2},fe?fe(Tt):u.createElement(Ft,{data:Tt})):null;if(tt){const e=Pt.current;if(e){const t=["tree","cluster","treemap","circlepack","partition","orbit"].includes(A),r=t?E||(Array.isArray(S)?void 0:S):void 0;if(t&&r)e.ingestHierarchy(r,[ut,dt]),e.buildScene([ut,dt]);else{const t=w||[],r=Array.isArray(S)?S:[];(t.length>0||r.length>0)&&(e.ingestBounded(t,r,[ut,dt]),e.buildScene([ut,dt]))}}const t=null!==(i=null==e?void 0:e.sceneNodes)&&void 0!==i?i:[],r=null!==(a=null==e?void 0:e.sceneEdges)&&void 0!==a?a:[],n=null!==(c=null==e?void 0:e.labels)&&void 0!==c?c:[];return u.createElement("div",{className:"stream-network-frame"+(ye?" "+ye:""),role:"img","aria-label":We||("string"==typeof De?De:"Network chart"),style:{position:"relative",width:ct[0],height:ct[1]}},u.createElement(gt,{summary:ze}),u.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:ct[0],height:ct[1],style:{position:"absolute",left:0,top:0}},Ie&&u.createElement("g",{transform:`translate(${lt.left},${lt.top})`},Ie),u.createElement("g",{transform:`translate(${lt.left},${lt.top})`},ge&&u.createElement("rect",{x:0,y:0,width:ut,height:dt,fill:ge}),r.map((e,t)=>function(e,t){switch(e.type){case"line":return u.createElement("line",{key:"net-edge-"+t,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});case"bezier":{const r=e;return u.createElement("path",{key:"net-edge-"+t,d:r.pathD,fill:et(r.style.fill,"#999"),fillOpacity:r.style.fillOpacity,stroke:r.style.stroke||"none",strokeWidth:r.style.strokeWidth,opacity:r.style.opacity})}case"ribbon":{const r=e;return u.createElement("path",{key:"net-edge-"+t,d:r.pathD,fill:et(r.style.fill,"#999"),fillOpacity:r.style.fillOpacity,stroke:r.style.stroke||"none",strokeWidth:r.style.strokeWidth,opacity:r.style.opacity})}case"curved":{const r=e;return u.createElement("path",{key:"net-edge-"+t,d:r.pathD,fill:et(r.style.fill,"none"),stroke:r.style.stroke||"#999",strokeWidth:r.style.strokeWidth||1,opacity:r.style.opacity})}default:return null}}(e,t)).filter(Boolean),t.map((e,t)=>function(e,t){switch(e.type){case"circle":{const r=e;return u.createElement("circle",{key:"net-circle-"+t,cx:r.cx,cy:r.cy,r:r.r,fill:et(r.style.fill),stroke:r.style.stroke,strokeWidth:r.style.strokeWidth,opacity:r.style.opacity})}case"rect":{const r=e;return u.createElement("rect",{key:"net-rect-"+t,x:r.x,y:r.y,width:r.w,height:r.h,fill:et(r.style.fill),stroke:r.style.stroke,strokeWidth:r.style.strokeWidth,opacity:r.style.opacity})}case"arc":{const r=e,n=s.arc().innerRadius(r.innerR).outerRadius(r.outerR).startAngle(r.startAngle+Math.PI/2).endAngle(r.endAngle+Math.PI/2)({})||"";return u.createElement("path",{key:"net-arc-"+t,d:n,transform:`translate(${r.cx},${r.cy})`,fill:et(r.style.fill),stroke:r.style.stroke,strokeWidth:r.style.strokeWidth,opacity:r.style.opacity})}default:return null}}(e,t)).filter(Boolean),n.map((e,t)=>function(e,t){return u.createElement("text",{key:"net-label-"+t,x:e.x,y:e.y,textAnchor:e.anchor||"middle",dominantBaseline:e.baseline||"auto",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"#333",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder},e.text)}(e,t)).filter(Boolean))),u.createElement(Je,{width:ut,height:dt,totalWidth:ct[0],totalHeight:ct[1],margin:lt,labels:n,sceneNodes:t,title:De,legend:Se,legendPosition:Ee,legendHoverBehavior:Oe,legendClickBehavior:Le,legendHighlightedCategory:je,legendIsolatedCategories:Ce,foregroundGraphics:ht,annotations:Ae,svgAnnotationRules:we,annotationFrame:0}))}const Ar=Pt.current;return u.createElement("div",{ref:st,className:"stream-network-frame"+(ye?" "+ye:""),role:"group","aria-label":We||("string"==typeof De?De:"Network chart"),tabIndex:0,style:{position:"relative",width:ue?"100%":ct[0],height:de?"100%":ct[1],overflow:"visible"},onKeyDown:br},Re&&u.createElement(pt,{tableId:it}),Re&&u.createElement(yt,{nodes:null!==(l=null==Ar?void 0:Ar.sceneNodes)&&void 0!==l?l:[],edges:null!==(g=null==Ar?void 0:Ar.sceneEdges)&&void 0!==g?g:[],chartType:"Network chart",tableId:it,chartTitle:"string"==typeof De?De:void 0}),u.createElement(gt,{summary:ze}),u.createElement("div",{role:"img","aria-label":We||("string"==typeof De?De:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:pe?xr:void 0,onMouseLeave:pe?gr:void 0,onClick:ve||be?pr:void 0},Ie&&u.createElement("svg",{overflow:"visible",style:{position:"absolute",top:0,left:0,width:ct[0],height:ct[1],pointerEvents:"none",overflow:"visible"}},u.createElement("g",{transform:`translate(${lt.left},${lt.top})`},Ie)),u.createElement("canvas",{ref:Lt,"aria-label":ot(null!==(f=null===(p=null==Ar?void 0:Ar.sceneNodes)||void 0===p?void 0:p.length)&&void 0!==f?f:0,null!==(v=null===(m=null==Ar?void 0:Ar.sceneEdges)||void 0===m?void 0:m.length)&&void 0!==v?v:0,"Network chart"),style:{position:"absolute",top:0,left:0}}),u.createElement(ft,{hoverPoint:Tt}),u.createElement(Je,{width:ut,height:dt,totalWidth:ct[0],totalHeight:ct[1],margin:lt,labels:(null==Ar?void 0:Ar.labels)||[],sceneNodes:null==Ar?void 0:Ar.sceneNodes,title:De,legend:Se,legendPosition:Ee,legendHoverBehavior:Oe,legendClickBehavior:Le,legendHighlightedCategory:je,legendIsolatedCategories:Ce,foregroundGraphics:ht,annotations:Ae,svgAnnotationRules:we,annotationFrame:qt}),u.createElement(Ye,{active:fr.current>=0,hoverPoint:Tt,margin:lt,size:ct,shape:null===(b=mr.current)||void 0===b?void 0:b.shape,width:null===(x=mr.current)||void 0===x?void 0:x.w,height:null===(k=mr.current)||void 0===k?void 0:k.h}),kr,(null==$e?void 0:$e.showBadge)&&u.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===$e.badgePosition?{top:4,left:4}:"bottom-left"===$e.badgePosition?{bottom:4,left:4}:"bottom-right"===$e.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{background:Gt?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"})},Gt?"STALE":"LIVE")))});qt.displayName="StreamNetworkFrame";const Yt={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 Gt(e,t){return"function"==typeof t?t(e):e[t]}function Xt(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 Vt(e={}){const{fields:t,title:r,format:n,style:o={},className:i=""}=e;return e=>{if(!e||"object"!=typeof e)return null;let a;const s=[];if(r){const t=Gt(e,r);a=Xt(t,n)}if(t&&t.length>0)t.forEach(t=>{let r,o,i;"string"==typeof t?(r=t,o=t,i=n):(r=t.label,o=t.accessor||t.key||"",i=t.format||n);const a=Gt(e,o);s.push({label:r,value:Xt(a,i)})});else if(!r){const t=["value","y","name","id","label"];for(const r of t)if(void 0!==e[r]){a=Xt(e[r],n);break}if(!a){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(a=Xt(e[t[0]],n))}}const c=Object.assign(Object.assign({},Yt),o);return u.createElement("div",{className:("semiotic-tooltip "+i).trim(),style:c},a&&u.createElement("div",{style:{fontWeight:s.length>0?"bold":"normal"}},a),s.map((e,t)=>u.createElement("div",{key:t,style:{marginTop:0===t&&a?"4px":0}},e.label&&u.createElement("span",null,e.label,": "),e.value)))}}function Kt(e){if(!0===e)return Vt();if("function"==typeof e){const t=e;return e=>{const r=t(!e||"object"!=typeof e.data||null===e.data||"node"!==e.type&&"edge"!==e.type?e:e.data);return null==r?null:u.createElement("div",{className:"semiotic-tooltip",style:Yt},r)}}return!1!==e&&void 0!==e&&("object"==typeof e&&null!==e&&("fields"in e||"title"in e)?Vt(e):Vt())}const Ut=e.createContext(null);function Zt(e){const t=[];for(const[r,n]of Object.entries(e.fields))if("point"===n.type)t.push(e=>n.values.has(e[r]));else{const[e,o]=n.range;t.push(t=>{const n=t[r];return n>=e&&o>=n})}return e=>t.every(t=>t(e))}function Qt(e,t){let r=e.get(t);return r||(r={name:t,resolution:"union",clauses:new Map},e.set(t,r)),r}const[Jt,er]=Mt(e=>({selections:new Map,setClause(t,r){e(e=>{const n=new Map(e.selections),o=Qt(n,t),i=new Map(o.clauses);return i.set(r.clientId,r),n.set(t,Object.assign(Object.assign({},o),{clauses:i})),{selections:n}})},clearClause(t,r){e(e=>{const n=e.selections.get(t);if(!n)return{};const o=new Map(e.selections),i=new Map(n.clauses);return i.delete(r),o.set(t,Object.assign(Object.assign({},n),{clauses:i})),{selections:o}})},setResolution(t,r){e(e=>{const n=new Map(e.selections),o=Qt(n,t);return n.set(t,Object.assign(Object.assign({},o),{resolution:r})),{selections:n}})},clearSelection(t){e(e=>{const r=new Map(e.selections),n=r.get(t);return n&&r.set(t,Object.assign(Object.assign({},n),{clauses:new Map})),{selections:r}})}})),[tr,rr]=Mt(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const r=e.observations;return r.push(t),r.length>e.maxObservations&&r.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}}));let nr={positions:new Map};const or=new Set;function ir(){for(const e of or)e()}function ar(e,t){const r=nr.positions.get(e);if(null==r?void 0:r.locked)return;if(!r||r.sourceId!==t)return;const n=new Map(nr.positions);n.delete(e),nr={positions:n},ir()}function sr(t){const r=e.useId(),n=t.clientId||r,{name:o}=t,i=er(e=>e.selections.get(o)),a=er(e=>e.setClause),s=er(e=>e.clearClause),c=e.useMemo(()=>!!i&&i.clauses.size>0,[i]);return{predicate:e.useMemo(()=>i&&0!==i.clauses.size?function(e,t){const r=[];for(const[n,o]of e.clauses)"crossfilter"===e.resolution&&n===t||r.push(Zt(o));return 0===r.length?()=>!0:"intersect"===e.resolution?e=>r.every(t=>t(e)):e=>r.some(t=>t(e))}(i,n):()=>!0,[i,n]),isActive:c,selectPoints:e.useCallback(e=>{const t={};for(const[r,n]of Object.entries(e))t[r]={type:"point",values:new Set(n)};a(o,{clientId:n,type:"point",fields:t})},[n,o,a]),selectInterval:e.useCallback(e=>{const t={};for(const[r,n]of Object.entries(e))t[r]={type:"interval",range:n};a(o,{clientId:n,type:"interval",fields:t})},[n,o,a]),clear:e.useCallback(()=>{s(o,n)},[s,o,n]),clientId:n}}const cr=e.createContext(!1);function lr(){var e;const t=$t(e=>e.theme),r=null===(e=null==t?void 0:t.colors)||void 0===e?void 0:e.categorical;return r&&r.length>0?r:void 0}function ur(e,t,r,n,o){let i;if(Array.isArray(r))i=r;else if(t&&t.length>0)i=t;else if("string"==typeof r){const e=St[r];Array.isArray(e)&&(i=e)}return i&&0!==i.length?i[0]:"#007bff"}function dr(t,r,n){const o=e.useContext(Ut),i=lr();return e.useMemo(()=>{var e;if(!r)return;const a=null!==(e=null!=n?n:i&&i.length>0?i:void 0)&&void 0!==e?e:"category10";if(0!==t.length){if("function"==typeof r){const e=Array.from(new Set(t.map(e=>r(e)+"")));if(o&&Object.keys(o).length>0){const t=Dt(e.map(e=>({_cat:e})),"_cat",a);return e=>o[e]||t(e)}return Dt(e.map(e=>({_cat:e})),"_cat",a)}if(o&&Object.keys(o).length>0){const e=Dt(t,r,a);return t=>o[t]||e(t)}return Dt(t,r,a)}if(o&&Object.keys(o).length>0){const e=Dt([{_:"a"}],"_",a);return t=>o[t]||e(t)}},[t,r,n,o,i])}function hr({selection:t,linkedHover:r,fallbackFields:n=[],unwrapData:o=!1,onObservation:i,chartType:a,chartId:s,onClick:c,hoverHighlight:l,colorByField:u}){const d=e.useId(),h=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}:null}(r,n),y=sr({name:(null==t?void 0:t.name)||"__unused__"}),g=function(t){const r=t.name||"hover",{fields:n}=t,{predicate:o,isActive:i,selectPoints:a,clear:s}=sr({name:r});return{onHover:e.useCallback(e=>{if(!e)return void s();const t={};for(const r of n){const n=e[r];void 0!==n&&(t[r]=[n])}Object.keys(t).length>0&&a(t)},[n,a,s,r]),predicate:o,isActive:i}}({name:(null==h?void 0:h.name)||"hover",fields:(null==h?void 0:h.fields)||n||[]}),p=rr(e=>e.pushObservation),f=t?{isActive:y.isActive,predicate:y.predicate}:null,[m,v]=e.useState(null),b=u||n[0],x=e.useMemo(()=>{if(!l||null==m||!b)return null;const e=m,t=b;return{isActive:!0,predicate:r=>{var n;return("string"==typeof r[t]?r[t]:(null!==(n=r[t])&&void 0!==n?n:"")+"")===e}}},[l,m,b]),k=e.useCallback(e=>{var t,n;if(r)if(e){let t=e.data||e.datum||e;if(Array.isArray(t)&&(t=t[0]),"x-position"===(null==h?void 0:h.mode)&&h.xField){const e=null==t?void 0:t[h.xField];null!=e&&Number.isFinite(Number(e))&&function(e,t,r){const n=nr.positions.get(e);(null==n?void 0:n.locked)||n&&n.xValue===t&&n.sourceId===r||(nr={positions:new Map(nr.positions).set(e,{xValue:t,sourceId:r})},ir())}(h.name||"hover",Number(e),d)}"x-position"!==(null==h?void 0:h.mode)&&g.onHover(t)}else"x-position"===(null==h?void 0:h.mode)&&ar(h.name||"hover",d),"x-position"!==(null==h?void 0:h.mode)&&g.onHover(null);if(l&&b)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const r=null==t?void 0:t[b];v(null!=r?r+"":null)}else v(null);if(i||p){const r={timestamp:Date.now(),chartType:a||"unknown",chartId:s};if(e){let o=e.data||e.datum||e;Array.isArray(o)&&(o=o[0]);const a=Object.assign(Object.assign({},r),{type:"hover",datum:o||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0});i&&i(a),p&&p(a)}else{const e=Object.assign(Object.assign({},r),{type:"hover-end"});i&&i(e),p&&p(e)}}},[r,g,h,d,i,a,s,p,l,b]),A=e.useCallback(e=>{var t,r,n,o;if("x-position"===(null==h?void 0:h.mode)&&h.xField&&e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const r=null==t?void 0:t[h.xField];null!=r&&Number.isFinite(Number(r))&&function(e,t,r){const n=nr.positions.get(e);if(null==n?void 0:n.locked){const t=new Map(nr.positions);return t.delete(e),nr={positions:t},ir(),!1}nr={positions:new Map(nr.positions).set(e,{xValue:t,sourceId:r,locked:!0})},ir()}(h.name||"hover",Number(r),d)}if(e&&c){let n=e.data||e.datum||e;Array.isArray(n)&&(n=n[0]),c(n,{x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(r=e.y)&&void 0!==r?r:0})}if(i||p){const t={timestamp:Date.now(),chartType:a||"unknown",chartId:s};if(e){let r=e.data||e.datum||e;Array.isArray(r)&&(r=r[0]);const a=Object.assign(Object.assign({},t),{type:"click",datum:r||{},x:null!==(n=e.x)&&void 0!==n?n:0,y:null!==(o=e.y)&&void 0!==o?o:0});i&&i(a),p&&p(a)}else{const e=Object.assign(Object.assign({},t),{type:"click-end"});i&&i(e),p&&p(e)}}},[c,i,p,a,s,h,d]);return e.useEffect(()=>{if("x-position"!==(null==h?void 0:h.mode))return;const e=h.name||"hover";return()=>{!function(e,t){const r=nr.positions.get(e);if(!(null==r?void 0:r.locked))return;if(t&&r.sourceId!==t)return;const n=new Map(nr.positions);n.delete(e),nr={positions:n},ir()}(e,d),ar(e,d)}},[null==h?void 0:h.mode,null==h?void 0:h.name,d]),{activeSelectionHook:f,hoverSelectionHook:x,customHoverBehavior:k,customClickBehavior:A,crosshairSourceId:d}}function yr(t,r,n){const[o,i]=e.useState(null),[a,s]=e.useState(new Set),c=e.useCallback(e=>{"highlight"===t&&i(e?e.label:null)},[t]),l=e.useCallback(e=>{"isolate"===t&&s(t=>{const r=new Set(t);return r.has(e.label)?r.delete(e.label):r.add(e.label),r.size===n.length?new Set:r})},[t,n.length]),u=e.useMemo(()=>{if(!t||"none"===t||!r)return null;const e="string"==typeof r?r:null;return"highlight"===t&&null!=o?{isActive:!0,predicate:t=>(e?t[e]:"function"==typeof r?r(t):null)===o}:"isolate"===t&&a.size>0?{isActive:!0,predicate:t=>{const n=e?t[e]:"function"==typeof r?r(t):null;return a.has(n)}}:null},[t,r,o,a]);return{highlightedCategory:"highlight"===t?o:null,isolatedCategories:"isolate"===t?a:new Set,onLegendHover:c,onLegendClick:l,legendSelectionHook:u}}u.createContext(void 0);const gr={primary:{width:600,height:400,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:void 0,showLabels:void 0,marginDefaults:{top:50,bottom:60,left:70,right:40}},context:{width:400,height:250,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:10,bottom:10,left:10,right:10}},sparkline:{width:120,height:24,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:2,bottom:2,left:0,right:0}}};function pr(e,t,r){var n,o,i,a,s,c,l;const u=gr[e||"primary"],d="context"===e||"sparkline"===e;return{width:null!==(n=t.width)&&void 0!==n?n:e&&"primary"!==e||!(null==r?void 0:r.width)?u.width:r.width,height:null!==(o=t.height)&&void 0!==o?o:e&&"primary"!==e||!(null==r?void 0:r.height)?u.height:r.height,showAxes:null!==(i=t.showAxes)&&void 0!==i?i:u.showAxes,showGrid:null!==(a=t.showGrid)&&void 0!==a?a:u.showGrid,enableHover:null!==(s=t.enableHover)&&void 0!==s?s:!!t.linkedHover||u.enableHover,showLegend:null!==(c=t.showLegend)&&void 0!==c?c:u.showLegend,showLabels:null!==(l=t.showLabels)&&void 0!==l?l:u.showLabels,title:d?void 0:t.title,description:t.description,summary:t.summary,accessibleTable:t.accessibleTable,xLabel:d?void 0:t.xLabel,yLabel:d?void 0:t.yLabel,categoryLabel:d?void 0:t.categoryLabel,valueLabel:d?void 0:t.valueLabel,marginDefaults:fr(u.marginDefaults,t.showCategoryTicks,t.orientation)}}function fr(e,t,r){if(!1!==t)return e;const n=Object.assign({},e);return"horizontal"===r?n.left=Math.min(n.left,15):n.bottom=Math.min(n.bottom,15),n}function mr({componentName:e,message:t,diagnosticHint:r,width:n,height:o}){return u.createElement("div",{role:"alert",style:{width:n,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"}},u.createElement("div",{style:{textAlign:"center",maxWidth:400}},u.createElement("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"}},e),u.createElement("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5}},t),r&&u.createElement("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}},r)))}class vr extends u.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){var r,n;null===(n=(r=this.props).onError)||void 0===n||n.call(r,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:u.createElement(mr,{componentName:"ChartErrorBoundary",message:t.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}function br(e,t){const r=e.length,n=t.length,o=Array(n+1);for(let e=0;n>=e;e++)o[e]=e;for(let i=1;r>=i;i++){let r=o[0];o[0]=i;for(let a=1;n>=a;a++){const n=o[a];o[a]=e[i-1]===t[a-1]?r:1+Math.min(r,o[a],o[a-1]),r=n}}return o[n]}function xr(e,t,r=3){let n,o=r+1;for(const r of t){const t=br(e.toLowerCase(),r.toLowerCase());o>t&&(o=t,n=r)}return o>r?void 0:n}function kr(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:e}function Ar(e,t){var r;if(0===t.length)return null;const n=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(n)||n.includes(e.toLowerCase()))||(null!==(r=xr(e,t,3))&&void 0!==r?r:null)}function wr({componentName:e,data:t,dataLabel:r="data"}){return null==t?`${e}: No ${r} provided. Pass a hierarchical object with children: { name: "root", children: [...] }.`:Array.isArray(t)?`${e}: ${r} 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 Sr({componentName:e,nodes:t,edges:r,nodesRequired:n=!1,edgesRequired:o=!0,accessors:i}){if(null==t&&null==r)return null;if(o&&(!r||!Array.isArray(r)||0===r.length))return e+': No edges provided. Pass a non-empty array: edges={[{ source: "A", target: "B", value: 10 }, ...]}.';if(n&&(!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 r=kr(t).find(e=>e&&"object"==typeof e);if(r){const t=Object.keys(r);for(const[n,o]of Object.entries(i))if(o&&"string"==typeof o&&!(o in r)){const r=Ar(o,t),i=r?` Try ${n}="${r}".`:"";return`${e}: ${n} "${o}" not found in node data. Available fields: ${t.join(", ")}.${i}`}}}return null}const Er={width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},frameProps:{type:"object"},onClick:{type:"function"}},Or={xLabel:{type:"string"},yLabel:{type:"string"},xFormat:{type:"function"},yFormat:{type:"function"}},Lr={categoryLabel:{type:"string"},valueLabel:{type:"string"},valueFormat:{type:"function"},categoryFormat:{type:"function"}},jr=["linear","monotoneX","monotoneY","step","stepAfter","stepBefore","basis","cardinal","catmullRom"],Cr=["vertical","horizontal"],Dr={LineChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Er),Or),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},lineBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:jr},lineWidth:{type:"number"},showPoints:{type:"boolean"},pointRadius:{type:"number"},fillArea:{type:"boolean"},areaOpacity:{type:"number"}})},AreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Er),Or),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:jr},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"}})},StackedAreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Er),Or),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:jr},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"},normalize:{type:"boolean"}})},Scatterplot:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Er),Or),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"}})},BubbleChart:{required:["data","sizeBy"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Er),Or),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},bubbleOpacity:{type:"number"},bubbleStrokeWidth:{type:"number"},bubbleStrokeColor:{type:"string"}})},Heatmap:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Er),Or),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},colorScheme:{type:"string",enum:["blues","reds","greens","viridis","custom"]},customColorScale:{type:["object","function"]},showValues:{type:"boolean"},valueFormat:{type:"function"},cellBorderColor:{type:"string"},cellBorderWidth:{type:"number"},showLegend:{type:"boolean"},legendPosition:{type:"string",enum:["right","left","top","bottom"]}})},QuadrantChart:{required:["quadrants"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Er),Or),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},quadrants:{type:"object"},xCenter:{type:"number"},yCenter:{type:"number"},centerlineStyle:{type:"object"},showQuadrantLabels:{type:"boolean"},quadrantLabelSize:{type:"number"},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"}})},MultiAxisLineChart:{required:["series"],dataShape:"array",dataAccessors:["xAccessor"],props:Object.assign(Object.assign(Object.assign({},Er),Or),{data:{type:"array"},xAccessor:{type:["string","function"]},series:{type:"array"},colorScheme:{type:["string","array"]},curve:{type:"string"},lineWidth:{type:"number"},annotations:{type:"array"}})},ConnectedScatterplot:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Er),Or),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},orderAccessor:{type:["string","function"]},orderLabel:{type:"string"},pointRadius:{type:"number"},pointIdAccessor:{type:["string","function"]},annotations:{type:"array"}})},BarChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Er),Lr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Cr},sort:{type:["boolean","string","function"]},barPadding:{type:"number"},roundedTop:{type:"number"}})},StackedBarChart:{required:["data","stackBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Er),Lr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},stackBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Cr},normalize:{type:"boolean"},sort:{type:["boolean","string","function"]},barPadding:{type:"number"},roundedTop:{type:"number"}})},LikertChart:{required:["levels"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor","levelAccessor","countAccessor"],props:Object.assign(Object.assign(Object.assign({},Er),Lr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},levelAccessor:{type:["string","function"]},countAccessor:{type:["string","function"]},levels:{type:"array"},orientation:{type:"string",enum:Cr},barPadding:{type:"number"}})},GroupedBarChart:{required:["data","groupBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Er),Lr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},groupBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Cr},sort:{type:["boolean","string","function"]},barPadding:{type:"number"},roundedTop:{type:"number"}})},SwarmPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Er),Lr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Cr},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"},categoryPadding:{type:"number"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}})},BoxPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Er),Lr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Cr},showOutliers:{type:"boolean"},outlierRadius:{type:"number"},categoryPadding:{type:"number"}})},Histogram:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Er),Lr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},bins:{type:"number"},relative:{type:"boolean"},categoryPadding:{type:"number"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}})},ViolinPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Er),Lr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Cr},bins:{type:"number"},curve:{type:"string"},showIQR:{type:"boolean"},categoryPadding:{type:"number"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}})},RidgelinePlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Er),Lr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},bins:{type:"number"},amplitude:{type:"number"},categoryPadding:{type:"number"}})},DotPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Er),Lr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Cr},sort:{type:["boolean","string","function"]},dotRadius:{type:"number"},categoryPadding:{type:"number"}})},PieChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},Er),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},startAngle:{type:"number"},cornerRadius:{type:"number"}})},DonutChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},Er),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},innerRadius:{type:"number"},centerContent:{type:["object","string","number"]},startAngle:{type:"number"},cornerRadius:{type:"number"}})},GaugeChart:{required:["value"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},Er),{value:{type:"number"},min:{type:"number"},max:{type:"number"},thresholds:{type:"array"},arcWidth:{type:"number"},sweep:{type:"number"},showNeedle:{type:"boolean"},needleColor:{type:"string"},centerContent:{type:["object","string","number","function"]},valueFormat:{type:"function"},showScaleLabels:{type:"boolean"},backgroundColor:{type:"string"}})},FunnelChart:{required:["data"],dataShape:"array",dataAccessors:["stepAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Er),Lr),{data:{type:"array"},stepAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},orientation:{type:"string",enum:["horizontal","vertical"]},connectorOpacity:{type:"number"},showCategoryTicks:{type:"boolean"},responsiveWidth:{type:"boolean"},legendPosition:{type:"string",enum:["right","left","top","bottom"]}})},SwimlaneChart:{required:["subcategoryAccessor"],dataShape:"array",dataAccessors:["categoryAccessor","subcategoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Er),Lr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},subcategoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:["horizontal","vertical"]},barPadding:{type:"number"},showCategoryTicks:{type:"boolean"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]},responsiveWidth:{type:"boolean"},legendPosition:{type:"string",enum:["right","left","top","bottom"]}})},ForceDirectedGraph:{required:["nodes","edges"],dataShape:"network",dataAccessors:["nodeIDAccessor","sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},Er),{nodes:{type:"array"},edges:{type:"array"},nodeIDAccessor:{type:["string","function"]},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},nodeLabel:{type:["string","function"]},nodeSize:{type:["number","string","function"]},nodeSizeRange:{type:"array"},edgeWidth:{type:["number","string","function"]},edgeColor:{type:"string"},edgeOpacity:{type:"number"},iterations:{type:"number"},forceStrength:{type:"number"},showLabels:{type:"boolean"}})},SankeyDiagram:{required:["edges"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},Er),{nodes:{type:"array"},edges:{type:"array"},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},edgeColorBy:{type:["string","function"],enum:["source","target","gradient"]},orientation:{type:"string",enum:Cr},nodeAlign:{type:"string",enum:["justify","left","right","center"]},nodePaddingRatio:{type:"number"},nodeWidth:{type:"number"},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},edgeOpacity:{type:"number"},edgeSort:{type:"function"}})},ChordDiagram:{required:["edges"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},Er),{nodes:{type:"array"},edges:{type:"array"},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},edgeColorBy:{type:["string","function"],enum:["source","target"]},padAngle:{type:"number"},groupWidth:{type:"number"},sortGroups:{type:"function"},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},edgeOpacity:{type:"number"}})},TreeDiagram:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},Er),{data:{type:"object"},layout:{type:"string",enum:["tree","cluster","partition","treemap","circlepack"]},orientation:{type:"string",enum:["vertical","horizontal","radial"]},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},edgeStyle:{type:"string",enum:["line","curve"]},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},nodeSize:{type:"number"}})},Treemap:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},Er),{data:{type:"object"},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},showLabels:{type:"boolean"},nodeLabel:{type:["string","function"]}})},CirclePack:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},Er),{data:{type:"object"},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},showLabels:{type:"boolean"},nodeLabel:{type:["string","function"]},circleOpacity:{type:"number"}})},OrbitDiagram:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},Er),{data:{type:"object"},childrenAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},orbitMode:{type:["string","array"]},speed:{type:"number"},revolution:{type:"function"},eccentricity:{type:["number","function"]},orbitSize:{type:["number","function"]},nodeRadius:{type:["number","function"]},showRings:{type:"boolean"},showLabels:{type:"boolean"},animated:{type:"boolean"},colorByDepth:{type:"boolean"},annotations:{type:"array"},foregroundGraphics:{type:"object"}})},RealtimeLineChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},stroke:{type:"string"},strokeWidth:{type:"number"},strokeDasharray:{type:"string"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeHistogram:{required:["binSize"],dataShape:"realtime",dataAccessors:[],props:{binSize:{type:"number"},size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},colors:{type:"object"},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},fill:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},gap:{type:"number"},brush:{type:["boolean","string","object"]},onBrush:{type:"function"},linkedBrush:{type:["string","object"]},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeSwarmChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},colors:{type:"object"},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},radius:{type:"number"},fill:{type:"string"},opacity:{type:"number"},stroke:{type:"string"},strokeWidth:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeWaterfallChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},positiveColor:{type:"string"},negativeColor:{type:"string"},connectorStroke:{type:"string"},connectorWidth:{type:"number"},gap:{type:"number"},stroke:{type:"string"},strokeWidth:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeHeatmap:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},heatmapXBins:{type:"number"},heatmapYBins:{type:"number"},aggregation:{type:"string",enum:["count","sum","mean"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"}}},ScatterplotMatrix:{required:["data","fields"],dataShape:"array",dataAccessors:[],props:Object.assign(Object.assign({},Er),{data:{type:"array"},fields:{type:"array"}})},MinimapChart:{required:["data"],dataShape:"array",dataAccessors:[],props:Object.assign(Object.assign({},Er),{data:{type:"array"}})},ChoroplethMap:{required:["areas"],dataShape:"array",dataAccessors:["valueAccessor"],props:Object.assign(Object.assign({},Er),{areas:{type:["array","string"]},valueAccessor:{type:["string","function"]},colorScheme:{type:["string","array"]},projection:{type:"string"}})},ProportionalSymbolMap:{required:["points"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign({},Er),{points:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},areas:{type:["array","string"]}})},FlowMap:{required:["flows"],dataShape:"array",dataAccessors:[],props:Object.assign(Object.assign({},Er),{flows:{type:"array"},nodes:{type:"array"},valueAccessor:{type:["string","function"]}})},DistanceCartogram:{required:["points"],dataShape:"array",dataAccessors:[],props:Object.assign(Object.assign({},Er),{points:{type:"array"},center:{type:"array"},costAccessor:{type:["string","function"]}})}};function Mr(e,t){return(Array.isArray(t)?t:[t]).includes(Array.isArray(e)?"array":typeof e)}const Ir=new Set(["TreeDiagram","Treemap","CirclePack","OrbitDiagram"]),Pr=new Set(["ForceDirectedGraph","SankeyDiagram","ChordDiagram"]),Tr=new Set(["BarChart","StackedBarChart","GroupedBarChart","AreaChart","StackedAreaChart"]),Nr=new Set(["LineChart","AreaChart","StackedAreaChart"]),_r=new Set(["BarChart","StackedBarChart","GroupedBarChart","FunnelChart"]);function $r(e){const t=e.match(/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i);if(!t)return null;const[r,n,o]=[parseInt(t[1],16)/255,parseInt(t[2],16)/255,parseInt(t[3],16)/255],i=e=>e>.03928?Math.pow((e+.055)/1.055,2.4):e/12.92;return.2126*i(r)+.7152*i(n)+.0722*i(o)}function Br(e,t){const r=$r(e),n=$r(t);return null===r||null===n?null:(Math.max(r,n)+.05)/(Math.min(r,n)+.05)}const Rr=["xAccessor","yAccessor","timeAccessor","valueAccessor","categoryAccessor","colorBy","sizeBy","lineBy","areaBy","stackBy","groupBy","orderAccessor","y0Accessor","sourceAccessor","targetAccessor","nodeIDAccessor","childrenAccessor","costAccessor"];function Wr(e,t){const r=[],n=function(e,t){const r=[],n=Dr[e];if(!n)return{valid:!1,errors:[`Unknown component "${e}". Valid components: ${Object.keys(Dr).join(", ")}`]};for(const o of n.required)null==t[o]&&r.push(`"${o}" is required for ${e}.`);for(const[e,o]of Object.entries(t)){if(null==o)continue;const t=n.props[e];if(t){if(!Mr(o,t.type)){const n=Array.isArray(t.type)?t.type.join(" | "):t.type;r.push(`"${e}" should be ${n}, got ${Array.isArray(o)?"array":typeof o}.`);continue}t.enum&&"string"==typeof o&&!t.enum.includes(o)&&r.push(`"${e}" value "${o}" is not valid. Expected one of: ${t.enum.join(", ")}.`)}}const o=Object.keys(n.props),i=new Set(o);for(const n of Object.keys(t))if(void 0!==t[n]&&!i.has(n)){const t=xr(n,o),i=t?`Unknown prop "${n}" for ${e}. Did you mean "${t}"?`:`Unknown prop "${n}" for ${e}. Valid props: ${o.join(", ")}.`;r.push(i)}if("array"===n.dataShape){const o=t.data,i={};for(const e of n.dataAccessors){const r=t[e];"string"==typeof r&&(i[e]=r)}const a=function({componentName:e,data:t,accessors:r,requiredProps:n}){if(n)for(const[t,r]of Object.entries(n))if(null==r)return`${e}: ${t} is required. Provide a field name or function.`;if(null==t)return null;if(!Array.isArray(t)||0===t.length)return e+": No data provided. Pass a non-empty array to the data prop.";if(!Array.isArray(t)&&"object"==typeof t)return e+": data should be an array, but received an object. If this is hierarchical data, use TreeDiagram, Treemap, or CirclePack instead.";if(r){const n=kr(t).find(e=>e&&"object"==typeof e);if(n){const t=Object.keys(n);for(const[o,i]of Object.entries(r))if(i&&"string"==typeof i&&!(i in n)){const r=Ar(i,t),n=r?` Try ${o}="${r}".`:"";return`${e}: ${o} "${i}" not found in data. Available fields: ${t.join(", ")}.${n}`}}}return null}({componentName:e,data:o,accessors:Object.keys(i).length>0?i:void 0});a&&r.push(a)}else if("object"===n.dataShape){const n=wr({componentName:e,data:t.data});n&&r.push(n)}else if("network"===n.dataShape){const o=Sr({componentName:e,nodes:t.nodes,edges:t.edges,nodesRequired:n.required.includes("nodes"),edgesRequired:n.required.includes("edges")});o&&r.push(o)}return{valid:0===r.length,errors:r}}(e,t);for(const e of n.errors)r.push({severity:"error",code:"VALIDATION",message:e,fix:""});return Dr[e]?(function(e,t,r){const n=Dr[e];if(n){if("array"===n.dataShape){const e=t.data;e&&Array.isArray(e)&&0===e.length&&r.push({severity:"error",code:"EMPTY_DATA",message:"data is an empty array — chart will render blank.",fix:"Provide at least one data point: data={[{ x: 1, y: 2 }]}."})}"network"===n.dataShape&&t.edges&&Array.isArray(t.edges)&&0===t.edges.length&&r.push({severity:"error",code:"EMPTY_EDGES",message:"edges is an empty array — network chart will render blank.",fix:'Provide at least one edge: edges={[{ source: "A", target: "B" }]}.'})}}(e,t,r),function(e,t,r){const n=t.width,o=t.height;if(void 0===n||"number"==typeof n&&n>0||r.push({severity:"error",code:"BAD_WIDTH",message:`width=${JSON.stringify(n)} — chart needs a positive number.`,fix:"Set width={600} or use responsiveWidth={true}."}),void 0===o||"number"==typeof o&&o>0||r.push({severity:"error",code:"BAD_HEIGHT",message:`height=${JSON.stringify(o)} — chart needs a positive number.`,fix:"Set height={400} or use responsiveHeight={true}."}),t.size&&Array.isArray(t.size)){const[e,n]=t.size;(null!=e&&0>=e||null!=n&&0>=n)&&r.push({severity:"error",code:"BAD_SIZE",message:`size=[${e}, ${n}] — both dimensions must be positive.`,fix:"Set size={[600, 400]}."})}}(0,t,r),function(e,t,r){const n=Dr[e];if(!n||"array"!==n.dataShape)return;const o=t.data;if(!o||!Array.isArray(o)||0===o.length)return;const i=o[0];if(!i||"object"!=typeof i)return;const a=Object.keys(i);for(const e of n.dataAccessors){const n=t[e];"string"==typeof n&&(n in i||r.push({severity:"error",code:"ACCESSOR_MISSING",message:`${e}="${n}" not found in data. Available fields: ${a.join(", ")}.`,fix:`Change ${e} to one of: ${a.map(e=>`"${e}"`).join(", ")}.`}))}}(e,t,r),function(e,t,r){Ir.has(e)&&Array.isArray(t.data)&&r.push({severity:"error",code:"HIERARCHY_FLAT_ARRAY",message:e+" expects hierarchical data but received a flat array.",fix:'Pass a root object: data={{ name: "root", children: [...] }}. For flat data, use BarChart or LineChart.'})}(e,t,r),function(e,t,r){Pr.has(e)&&(t.edges||t.data||r.push({severity:"error",code:"NETWORK_NO_EDGES",message:e+" requires an edges prop.",fix:'Provide edges={[{ source: "A", target: "B", value: 10 }]}.'}))}(e,t,r),function(e,t,r){const n=Dr[e];if(!n||"array"!==n.dataShape)return;const o=t.data;if(!o||!Array.isArray(o)||0===o.length)return;const i=o[0];if(!i||"object"!=typeof i)return;const a=t.xAccessor;"string"==typeof a&&i[a]instanceof Date&&!t.xFormat&&r.push({severity:"warning",code:"DATE_NO_FORMAT",message:`xAccessor "${a}" contains Date objects but no xFormat is provided. Axis ticks may display "[object Object]".`,fix:"Add xFormat={d => d.toLocaleDateString()} or use timestamps (d.getTime()) instead of Date objects."})}(e,t,r),function(e,t,r){t.linkedHover&&!t.selection&&r.push({severity:"warning",code:"LINKED_HOVER_NO_SELECTION",message:"linkedHover is set but selection is not — this chart emits hover events but won't highlight from others.",fix:`Add selection={{ name: "${"object"==typeof t.linkedHover&&t.linkedHover.name||"hl"}" }} to receive cross-highlights.`})}(0,t,r),function(e,t,r){var n;if(!Tr.has(e))return;const o=t.rExtent||t.yExtent;o&&Array.isArray(o)&&o.length>=1&&null!=o[0]&&0!==o[0]&&r.push({severity:"warning",code:"NON_ZERO_BASELINE",message:`${e} has a non-zero baseline (${o[0]}). Bar and area charts should start at zero to avoid exaggerating differences.`,fix:`Remove the custom extent minimum or set it to 0: rExtent={[0, ${null!==(n=o[1])&&void 0!==n?n:"auto"}]}. For trend-focused charts, use LineChart instead.`})}(e,t,r),function(e,t,r){if(!Nr.has(e))return;if(t.gapStrategy)return;const n=t.data;if(!n||!Array.isArray(n)||0===n.length)return;const o=t.yAccessor||"y";"string"==typeof o&&n.some(e=>{const t=e[o];return null==t||Number.isNaN(t)})&&r.push({severity:"warning",code:"DATA_GAPS",message:`Data contains null/undefined/NaN values in "${o}". Default behavior breaks the line at gaps.`,fix:'Set gapStrategy="break" (default), "interpolate", or "zero" to control gap handling.'})}(e,t,r),function(e,t,r){var n,o;const i=null!==(n=t.width)&&void 0!==n?n:600,a=null!==(o=t.height)&&void 0!==o?o:400,s=t.margin;if(!s||"object"!=typeof s)return;const c=(s.left||0)+(s.right||0),l=(s.top||0)+(s.bottom||0);i>c||r.push({severity:"error",code:"MARGIN_OVERFLOW_H",message:`Horizontal margins (${c}px) >= width (${i}px) — no drawing area left.`,fix:"Reduce margin.left/right or increase width."}),a>l||r.push({severity:"error",code:"MARGIN_OVERFLOW_V",message:`Vertical margins (${l}px) >= height (${a}px) — no drawing area left.`,fix:"Reduce margin.top/bottom or increase height."})}(0,t,r),function(e,t,r){var n;const o=Dr[e];if(!o||"array"!==o.dataShape)return;const i=t.data;if(!i||!Array.isArray(i)||0===i.length)return;const a=[];t.xAccessor&&"string"==typeof t.xAccessor&&a.push({prop:"xAccessor",name:t.xAccessor}),t.yAccessor&&"string"==typeof t.yAccessor&&a.push({prop:"yAccessor",name:t.yAccessor}),t.valueAccessor&&"string"==typeof t.valueAccessor&&a.push({prop:"valueAccessor",name:t.valueAccessor});const s=Math.min(i.length,5);for(const e of a){let t=!0;for(let r=0;s>r;r++){const o=null===(n=i[r])||void 0===n?void 0:n[e.name];if("number"==typeof o&&Number.isFinite(o)){t=!1;break}}t&&r.push({severity:"error",code:"DEGENERATE_EXTENT",message:`${e.prop}="${e.name}" produces NaN or non-finite values for all sampled data points — chart extents will be invalid.`,fix:`Ensure data[].${e.name} contains finite numbers, or use a function accessor to transform values.`})}}(e,t,r),function(e,t,r){if(!_r.has(e))return;const n=t.barPadding;"number"==typeof n&&10>n&&r.push({severity:"warning",code:"BAR_PADDING_INVISIBLE",message:`barPadding=${n} is very small — bars may appear to have no spacing between them.`,fix:"Increase barPadding to at least 10 for visible gaps, e.g. barPadding={12}."})}(e,t,r),function(e,t,r){if("bottom"!==t.legendPosition)return;const n=t.margin;if(!n||"object"!=typeof n)return;const o=n.bottom;"number"==typeof o&&70>o&&r.push({severity:"warning",code:"BOTTOM_MARGIN_WITH_LEGEND",message:`legendPosition="bottom" with margin.bottom=${o}px — legend may overlap axis labels.`,fix:"Increase margin.bottom to at least 70, e.g. margin={{ ...margin, bottom: 80 }}."})}(0,t,r),function(e,t,r){var n;if(!t.showLegend)return;if("right"!==(null!==(n=t.legendPosition)&&void 0!==n?n:"right"))return;const o=t.margin;if(!o||"object"!=typeof o)return;const i=o.right;"number"==typeof i&&100>i&&r.push({severity:"warning",code:"LEGEND_MARGIN_TIGHT",message:`showLegend is true with legendPosition="right" but margin.right=${i}px — legend may be clipped or overlap the chart.`,fix:"Increase margin.right to at least 100, e.g. margin={{ ...margin, right: 120 }}."})}(0,t,r),function(e,t,r){if("Heatmap"!==e)return;const n=t.data;if(!n||!Array.isArray(n)||0===n.length)return;const o=n[0];if(o&&"object"==typeof o)for(const e of["xAccessor","yAccessor"]){const n=t[e];if("string"!=typeof n)continue;const i=o[n];"string"==typeof i&&r.push({severity:"warning",code:"HEATMAP_STRING_ACCESSOR",message:`${e}="${n}" resolves to string values (e.g. "${i}"). Heatmap will use categorical axis handling which may produce unexpected cell layout.`,fix:"If you intend categorical axes this is fine. Otherwise, convert values to numbers before passing data."})}}(e,t,r),function(e,t,r){const n=t.colorScheme;if(!n||!Array.isArray(n))return;const o="string"==typeof t.background?t.background:"#ffffff";if(!o.startsWith("#"))return;const i=[];for(const e of n){if("string"!=typeof e||!e.startsWith("#"))continue;const t=Br(e,o);null!==t&&3>t&&i.push(`${e} (${t.toFixed(1)}:1)`)}i.length>0&&r.push({severity:"warning",code:"LOW_COLOR_CONTRAST",message:`${i.length} color(s) in colorScheme have < 3:1 contrast against background "${o}": ${i.join(", ")}. Data marks may be hard to see.`,fix:'Use darker colors on light backgrounds or lighter colors on dark backgrounds. Import COLOR_BLIND_SAFE_CATEGORICAL from "semiotic" for an accessible preset.'})}(0,t,r),function(e,t,r){const n=t.colorScheme;if(!n||!Array.isArray(n)||2>n.length)return;const o=n.filter(e=>"string"==typeof e&&e.startsWith("#"));if(2>o.length)return;const i=[];for(let e=0;o.length-1>e;e++){const t=Br(o[e],o[e+1]);null!==t&&1.5>t&&i.push(`${o[e]} / ${o[e+1]} (${t.toFixed(1)}:1)`)}i.length>0&&r.push({severity:"warning",code:"LOW_ADJACENT_CONTRAST",message:`${i.length} adjacent color pair(s) in colorScheme have very similar luminance: ${i.join("; ")}. Categories may be hard to distinguish.`,fix:'Alternate light and dark colors in the scheme, or use COLOR_BLIND_SAFE_CATEGORICAL from "semiotic" for a pre-tested palette.'})}(0,t,r),function(e,t,r){const n="string"==typeof t.title&&t.title.trim().length>0,o="string"==typeof t.description&&t.description.trim().length>0,i="string"==typeof t.summary&&t.summary.trim().length>0;n||o||i||r.push({severity:"warning",code:"MISSING_DESCRIPTION",message:'No title, description, or summary provided. Screen readers will use a generic label like "XY chart".',fix:'Add a title="..." prop for a brief label, or description="..." for a detailed aria-label, or summary="..." for a screen-reader-only note describing the chart\'s purpose.'})}(0,t,r),function(e,t,r){const n=[];for(const e of Rr)"function"==typeof t[e]&&n.push(e);n.length>0&&r.push({severity:"warning",code:"FUNCTION_ACCESSOR",message:`Function accessor${n.length>1?"s":""} detected: ${n.join(", ")}. If defined inline (e.g. \`xAccessor={d => d.value}\`), every parent re-render creates a new reference which may trigger unnecessary scene rebuilds.`,fix:'Use string accessors when possible (e.g. xAccessor="value"), or memoize with useCallback / define outside the component.'})}(0,t,r),{ok:r.every(e=>"warning"===e.severity),diagnoses:r}):{ok:0===r.length,diagnoses:r}}var zr;const Hr="undefined"!=typeof process&&"production"!==(null===(zr=process.env)||void 0===zr?void 0:zr.NODE_ENV);function Fr({componentName:e,width:t,height:r,chartProps:n,children:o}){return u.createElement(vr,{fallback:o=>{let i="";if(Hr&&n)try{const t=Wr(e,n);t.ok||(i=t.diagnoses.map(e=>`${"error"===e.severity?"✗":"⚠"} ${e.message}${e.fix?" — Fix: "+e.fix:""}`).join("\n"))}catch(e){}return u.createElement(mr,{componentName:e,message:o.message,diagnosticHint:i,width:t,height:r})}},o)}const qr={display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #999)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"},Yr={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function Gr(e,t,r,n){return!1===n||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?u.createElement("div",{style:Object.assign(Object.assign({},qr),{width:t,height:r})},n||"No data available"):null}function Xr(e,t,r){if(!e)return null;const n=Math.min(5,Math.floor(r/40)),o=Math.max(8,Math.floor(r/(3*n))),i=Math.max(6,Math.floor(r/(2.5*n))),a=Math.floor((r-(n*(o+i)-i))/2);return u.createElement("div",{style:{width:t,height:r,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"}},Array.from({length:n},(e,r)=>u.createElement("div",{key:r,className:"semiotic-loading-bar",style:Object.assign(Object.assign({},Yr),{position:"absolute",top:a+r*(o+i),left:Math.floor(.1*t),width:30+(37*r+13)%50+"%",height:o,opacity:.5+r%2*.2})})))}const Vr=e.forwardRef(function(t,r){var n;const o=e.useRef(null);e.useImperativeHandle(r,()=>({push:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,r,n,i,a;const s=Array.isArray(e)?e:[e],c=null!==(n=null===(r=null===(t=o.current)||void 0===t?void 0:t.getTopology())||void 0===r?void 0:r.nodes)&&void 0!==n?n:[],l=[];for(const e of s){const t=c.find(t=>t.id===e);t&&l.push(Object.assign(Object.assign({},null!==(i=t.data)&&void 0!==i?i:{}),{id:e})),null===(a=o.current)||void 0===a||a.removeNode(e)}return l},update:(e,t)=>(Array.isArray(e)?e:[e]).flatMap(e=>{var r;const n=null===(r=o.current)||void 0===r?void 0:r.updateNode(e,t);return n?[Object.assign(Object.assign({},n),{id:e})]:[]}),clear:()=>{var e;return null===(e=o.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t,r,n;return null!==(n=null===(r=null===(t=null===(e=o.current)||void 0===e?void 0:e.getTopology())||void 0===t?void 0:t.nodes)||void 0===r?void 0:r.map(e=>e.data))&&void 0!==n?n:[]}}));const i=pr(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLegend:t.showLegend,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary},{width:600,height:600}),{nodes:a,edges:s,margin:c,className:l,nodeIDAccessor:d="id",sourceAccessor:h="source",targetAccessor:y="target",nodeLabel:g,colorBy:p,colorScheme:f,nodeSize:m=8,nodeSizeRange:v=[5,20],edgeWidth:b=1,edgeColor:x="#999",edgeOpacity:k=.6,iterations:A=300,forceStrength:w=.1,tooltip:S,frameProps:E={},onObservation:O,onClick:L,chartId:j,selection:C,linkedHover:D,loading:M,emptyContent:I,legendInteraction:P,legendPosition:T}=t,N=i.width,_=i.height,$=i.enableHover,B=i.showLegend,R=null!==(n=i.showLabels)&&void 0!==n&&n,W=i.title,z=i.description,H=i.summary,F=i.accessibleTable,q=Xr(M,N,_),Y=q?null:Gr(a,N,_,I),G=a||[],X=s||[],V=dr(G,p,f),K=e.useMemo(()=>{if(!p)return[];const e=new Set;for(const t of G){const r="function"==typeof p?p(t):t[p];null!=r&&e.add(r+"")}return Array.from(e)},[G,p]),U=yr(P,p,K),Z=lr(),Q=e.useMemo(()=>new Map,[]),J=e.useMemo(()=>{if(Array.isArray(f))return f;if(Z&&Z.length>0)return Z;const e=St[f];return Array.isArray(e)?e:Et},[f,Z]),ee=e.useMemo(()=>e=>{const t={};return t.fill=p?Ct(e.data||e,p,V):ur(0,Z,f),"number"==typeof m&&(t.r=m),t},[p,V,m,Z,f,Q]),te=e.useMemo(()=>e=>({stroke:x,strokeWidth:"number"==typeof b?b:"function"==typeof b?b(e):e[b]||1,opacity:k}),[b,x,k]),re=e.useMemo(()=>{if(R&&g)return"function"==typeof g?g:e=>{var t,r,n;return null!==(n=null!==(r=null===(t=e.data)||void 0===t?void 0:t[g])&&void 0!==r?r:e[g])&&void 0!==n?n:e.id}},[R,g]),{legend:ne,margin:oe,legendPosition:ie}=function({data:t,colorBy:r,colorScale:n,showLegend:o,legendPosition:i="right",userMargin:a,defaults:s={top:50,bottom:60,left:70,right:40},categories:c}){const l=e.useContext(cr),u=void 0!==o?o:!l&&!!r,d=e.useMemo(()=>{if(u&&r)return function({data:e,colorBy:t,colorScale:r,getColor:n,strokeColor:o,strokeWidth:i,categories:a}){const s=(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?n(a,t,r):r?r(o):Ot[i%Ot.length];return{label:o+"",color:s}});return{legendGroups:[{styleFn:e=>{const t=e.color||"#333",r={fill:t,stroke:t};return void 0!==o&&(r.stroke=o),void 0!==i&&(r.strokeWidth=i),r},type:"fill",items:s,label:""}]}}({data:t,colorBy:r,colorScale:n,getColor:Ct,categories:c})},[u,r,t,n,c]),h=e.useMemo(()=>{const e=Object.assign(Object.assign({},s),a);return d&&("right"===i&&110>e.right?e.right=110:"left"===i&&110>e.left?e.left=110:"top"===i&&50>e.top?e.top=50:"bottom"===i&&80>e.bottom&&(e.bottom=80)),e},[s,a,d,i]);return{legend:d,margin:h,legendPosition:i}}({data:G,colorBy:p,colorScale:V,showLegend:B,legendPosition:T,userMargin:c,defaults:i.marginDefaults}),{customHoverBehavior:ae,customClickBehavior:se}=hr({selection:C,linkedHover:D,fallbackFields:p?["string"==typeof p?p:""]:[],unwrapData:!0,onObservation:O,onClick:L,chartType:"ForceDirectedGraph",chartId:j}),ce=Sr({componentName:"ForceDirectedGraph",nodes:a,edges:s,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:d}});return ce?u.createElement(mr,{componentName:"ForceDirectedGraph",message:ce,width:N,height:_}):q||Y||u.createElement(Fr,{componentName:"ForceDirectedGraph",width:N,height:_},u.createElement(qt,Object.assign({ref:o,chartType:"force"},null!=a&&{nodes:G},null!=s&&{edges:X},{size:[N,_],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:oe,nodeIDAccessor:d,sourceAccessor:h,targetAccessor:y,iterations:A,forceStrength:w,nodeStyle:ee,edgeStyle:te,colorBy:p,colorScheme:J,nodeSize:m,nodeSizeRange:v,nodeLabel:re,showLabels:R,enableHover:$,tooltipContent:!1===S?()=>null:Kt(S)||void 0,customHoverBehavior:D||O||L?ae:void 0,customClickBehavior:O||L?se:void 0,legend:ne,legendPosition:ie},P&&"none"!==P&&{legendHoverBehavior:U.onLegendHover,legendClickBehavior:U.onLegendClick,legendHighlightedCategory:U.highlightedCategory,legendIsolatedCategories:U.isolatedCategories},{className:l,title:W,description:z,summary:H,accessibleTable:F},E)))});function Kr(e,t){if(!e)return[];const r=[],n=e=>{r.push(e);const o="function"==typeof t?t(e):e[t];o&&Array.isArray(o)&&o.forEach(n)};return n(e),r}function Ur(e,t,r,n){if(e&&e.length>0)return e;const o=new Set;return t.forEach(e=>{const t="function"==typeof r?r(e):e[r],i="function"==typeof n?n(e):e[n];o.add(t),o.add(i)}),Array.from(o).map(e=>({id:e}))}function Zr(e){return"function"==typeof e?e:t=>t[e]||1}function Qr({edgeColorBy:e,colorBy:t,colorScale:r,nodeStyleFn:n,edgeOpacity:o,baseStyle:i={}}){return a=>{const s=Object.assign({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=Ct(e.data||e,t,r):e&&(s.fill=n(e,e.index).fill)}else if("target"===e){const e="object"==typeof a.target?a.target:null;t&&e?s.fill=Ct(e.data||e,t,r):e&&(s.fill=n(e,e.index).fill)}else"gradient"===e&&(s.fill="#999",s.fillOpacity=.7*o);return s}}Vr.displayName="ForceDirectedGraph";const Jr=e.forwardRef(function(t,r){var n;const o=e.useRef(null);e.useImperativeHandle(r,()=>({push:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,r,n,i,a;const s=Array.isArray(e)?e:[e],c=null!==(n=null===(r=null===(t=o.current)||void 0===t?void 0:t.getTopology())||void 0===r?void 0:r.nodes)&&void 0!==n?n:[],l=[];for(const e of s){const t=c.find(t=>t.id===e);t&&l.push(Object.assign(Object.assign({},null!==(i=t.data)&&void 0!==i?i:{}),{id:e})),null===(a=o.current)||void 0===a||a.removeNode(e)}return l},update:(e,t)=>(Array.isArray(e)?e:[e]).flatMap(e=>{var r;const n=null===(r=o.current)||void 0===r?void 0:r.updateNode(e,t);return n?[Object.assign(Object.assign({},n),{id:e})]:[]}),clear:()=>{var e;return null===(e=o.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t,r,n;return null!==(n=null===(r=null===(t=null===(e=o.current)||void 0===e?void 0:e.getTopology())||void 0===t?void 0:t.edges)||void 0===r?void 0:r.map(e=>e.data))&&void 0!==n?n:[]}}));const i=pr(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary},{width:800,height:600}),{nodes:a,edges:s,margin:c,className:l,sourceAccessor:d="source",targetAccessor:h="target",valueAccessor:y="value",nodeIdAccessor:g="id",colorBy:p,colorScheme:f,edgeColorBy:m="source",orientation:v="horizontal",nodeAlign:b="justify",nodePaddingRatio:x=.05,nodeWidth:k=15,nodeLabel:A,edgeOpacity:w=.5,edgeSort:S,tooltip:E,frameProps:O={},onObservation:L,onClick:j,chartId:C,selection:D,linkedHover:M,loading:I,emptyContent:P,legendInteraction:T}=t,N=i.width,_=i.height,$=i.enableHover,B=null===(n=i.showLabels)||void 0===n||n,R=i.title,W=i.description,z=i.summary,H=i.accessibleTable,F=Xr(I,N,_),q=F?null:Gr(s,N,_,P),Y=s||[],G=e.useMemo(()=>Ur(a,Y,d,h),[a,Y,d,h]),X=dr(G,p,f),V=e.useMemo(()=>{if(!p)return[];const e=new Set;for(const t of G){const r="function"==typeof p?p(t):t[p];null!=r&&e.add(r+"")}return Array.from(e)},[G,p]),K=yr(T,p,V),U=lr(),Z=e.useMemo(()=>new Map,[]),Q=e.useMemo(()=>{if(Array.isArray(f))return f;if(U&&U.length>0)return U;const e=St[f];return Array.isArray(e)?e:Et},[f,U]),J=e.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=p?Ct(e.data||e,p,X):ur(0,U,f),t},[p,X,U,f,Z]),ee=e.useMemo(()=>Qr({edgeColorBy:m,colorBy:p,colorScale:X,nodeStyleFn:J,edgeOpacity:w,baseStyle:{stroke:"none",strokeWidth:0}}),[m,p,X,J,w]),te=e.useMemo(()=>{if(!B)return;const e=A||g;return"function"==typeof e?e:t=>{var r,n,o;return null!==(o=null!==(n=null===(r=t.data)||void 0===r?void 0:r[e])&&void 0!==n?n:t[e])&&void 0!==o?o:t.id}},[B,A,g]),re=Object.assign(Object.assign({},i.marginDefaults),c),{customHoverBehavior:ne,customClickBehavior:oe}=hr({selection:D,linkedHover:M,fallbackFields:p?["string"==typeof p?p:""]:[],unwrapData:!0,onObservation:L,onClick:j,chartType:"SankeyDiagram",chartId:C}),ie=Sr({componentName:"SankeyDiagram",edges:s,edgesRequired:!0});return ie?u.createElement(mr,{componentName:"SankeyDiagram",message:ie,width:N,height:_}):F||q||u.createElement(Fr,{componentName:"SankeyDiagram",width:N,height:_},u.createElement(qt,Object.assign({ref:o,chartType:"sankey"},G.length>0&&{nodes:G},null!=s&&{edges:Y},{size:[N,_],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:re,nodeIDAccessor:g,sourceAccessor:d,targetAccessor:h,valueAccessor:y,orientation:v,nodeAlign:b,nodePaddingRatio:x,nodeWidth:k,nodeStyle:J,edgeStyle:ee,colorBy:p,colorScheme:Q,edgeColorBy:m,edgeOpacity:w,edgeSort:S,nodeLabel:te,showLabels:B,enableHover:$,tooltipContent:!1===E?()=>null:Kt(E)||void 0,customHoverBehavior:M||L||j?ne:void 0,customClickBehavior:L||j?oe:void 0},T&&"none"!==T&&{legendHoverBehavior:K.onLegendHover,legendClickBehavior:K.onLegendClick,legendHighlightedCategory:K.highlightedCategory,legendIsolatedCategories:K.isolatedCategories},{className:l,title:R,description:W,summary:z,accessibleTable:H},O)))});Jr.displayName="SankeyDiagram";const en=e.forwardRef(function(t,r){var n;const o=e.useRef(null);e.useImperativeHandle(r,()=>({push:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,r,n,i,a;const s=Array.isArray(e)?e:[e],c=null!==(n=null===(r=null===(t=o.current)||void 0===t?void 0:t.getTopology())||void 0===r?void 0:r.nodes)&&void 0!==n?n:[],l=[];for(const e of s){const t=c.find(t=>t.id===e);t&&l.push(Object.assign(Object.assign({},null!==(i=t.data)&&void 0!==i?i:{}),{id:e})),null===(a=o.current)||void 0===a||a.removeNode(e)}return l},update:(e,t)=>(Array.isArray(e)?e:[e]).flatMap(e=>{var r;const n=null===(r=o.current)||void 0===r?void 0:r.updateNode(e,t);return n?[Object.assign(Object.assign({},n),{id:e})]:[]}),clear:()=>{var e;return null===(e=o.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t,r,n;return null!==(n=null===(r=null===(t=null===(e=o.current)||void 0===e?void 0:e.getTopology())||void 0===t?void 0:t.edges)||void 0===r?void 0:r.map(e=>e.data))&&void 0!==n?n:[]}}));const i=pr(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary},{width:600,height:600}),{nodes:a,edges:s,margin:c,className:l,sourceAccessor:d="source",targetAccessor:h="target",valueAccessor:y="value",nodeIdAccessor:g="id",colorBy:p,colorScheme:f,edgeColorBy:m="source",padAngle:v=.01,groupWidth:b=20,sortGroups:x,nodeLabel:k,edgeOpacity:A=.5,tooltip:w,frameProps:S={},onObservation:E,onClick:O,chartId:L,selection:j,linkedHover:C,loading:D,emptyContent:M,legendInteraction:I}=t,P=i.width,T=i.height,N=i.enableHover,_=null===(n=i.showLabels)||void 0===n||n,$=i.title,B=i.description,R=i.summary,W=i.accessibleTable,z=Xr(D,P,T),H=z?null:Gr(s,P,T,M),F=s||[],q=e.useMemo(()=>Ur(a,F,d,h),[a,F,d,h]),Y=dr(q,p,f),G=e.useMemo(()=>{if(!p)return[];const e=new Set;for(const t of q){const r="function"==typeof p?p(t):t[p];null!=r&&e.add(r+"")}return Array.from(e)},[q,p]),X=yr(I,p,G),V=lr(),K=e.useMemo(()=>new Map,[]),U=e.useMemo(()=>{if(Array.isArray(f))return f;if(V&&V.length>0)return V;const e=St[f];return Array.isArray(e)?e:Et},[f,V]),Z=q.length>0,Q=e.useMemo(()=>{if(Z)return(e,t)=>{var r,n;const o={stroke:"black",strokeWidth:1};if(p)o.fill=Ct(e.data||e,p,Y);else{const i=Array.isArray(f)?f:St[f]||Et,a=Array.isArray(i)?i:Et,s=null!==(n=null!==(r=e.index)&&void 0!==r?r:t)&&void 0!==n?n:0;o.fill=a[s%a.length]}return o}},[Z,p,Y,f]),J=e.useMemo(()=>{if(Z)return Qr({edgeColorBy:m,colorBy:p,colorScale:Y,nodeStyleFn:Q||(e=>({fill:ur(0,V,f)})),edgeOpacity:A,baseStyle:{stroke:"black",strokeWidth:.5,strokeOpacity:A}})},[Z,m,p,Y,Q,A,V,f,K]),ee=e.useMemo(()=>{if(!_)return;const e=k||g;return"function"==typeof e?e:t=>{var r,n,o;return null!==(o=null!==(n=null===(r=t.data)||void 0===r?void 0:r[e])&&void 0!==n?n:t[e])&&void 0!==o?o:t.id}},[_,k,g]),te=Object.assign(Object.assign({},i.marginDefaults),c),{customHoverBehavior:re,customClickBehavior:ne}=hr({selection:j,linkedHover:C,fallbackFields:p?["string"==typeof p?p:""]:[],unwrapData:!0,onObservation:E,onClick:O,chartType:"ChordDiagram",chartId:L}),oe=Sr({componentName:"ChordDiagram",edges:s,edgesRequired:!0});return oe?u.createElement(mr,{componentName:"ChordDiagram",message:oe,width:P,height:T}):z||H||u.createElement(Fr,{componentName:"ChordDiagram",width:P,height:T},u.createElement(qt,Object.assign({ref:o,chartType:"chord"},q.length>0&&{nodes:q},null!=s&&{edges:F},{size:[P,T],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:te,nodeIDAccessor:g,sourceAccessor:d,targetAccessor:h,valueAccessor:y,padAngle:v,groupWidth:b,sortGroups:x,nodeStyle:Q,edgeStyle:J,colorBy:p,colorScheme:U,edgeColorBy:m,edgeOpacity:A,nodeLabel:ee,showLabels:_,enableHover:N,tooltipContent:!1===w?()=>null:Kt(w)||void 0,customHoverBehavior:C||E||O?re:void 0,customClickBehavior:E||O?ne:void 0},I&&"none"!==I&&{legendHoverBehavior:X.onLegendHover,legendClickBehavior:X.onLegendClick,legendHighlightedCategory:X.highlightedCategory,legendIsolatedCategories:X.isolatedCategories},{className:l,title:$,description:B,summary:R,accessibleTable:W},S)))});function tn(t){var r;const n=pr(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary},{width:600,height:600}),{data:o,margin:i,className:a,layout:s="tree",orientation:c="vertical",childrenAccessor:l="children",valueAccessor:d="value",nodeIdAccessor:h="name",colorBy:y,colorScheme:g,colorByDepth:p=!1,edgeStyle:f="curve",nodeLabel:m,nodeSize:v=5,tooltip:b,frameProps:x={},onObservation:k,onClick:A,chartId:w,selection:S,linkedHover:E,loading:O,legendInteraction:L}=t,j=n.width,C=n.height,D=n.enableHover,M=null===(r=n.showLabels)||void 0===r||r,I=n.title,P=n.description,T=n.summary,N=n.accessibleTable,_=Xr(O,j,C),$=e.useMemo(()=>Kr(null!=o?o:null,l),[o,l]),B=dr($,p?void 0:y,g),R=e.useMemo(()=>{if(!y||p)return[];const e=new Set;for(const t of $){const r="function"==typeof y?y(t):t[y];null!=r&&e.add(r+"")}return Array.from(e)},[$,y,p]),W=yr(L,p?void 0:y,R),z=lr(),H=e.useMemo(()=>new Map,[]),F=e.useMemo(()=>{if(Array.isArray(g))return g;if(z&&z.length>0)return z;const e=St[g];return Array.isArray(e)?e:Et},[g,z]),q=e.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=p?Lt[(e.depth||0)%Lt.length]:y?Ct(e.data||e,y,B):ur(0,z,g),t},[y,p,B,z,g,H]),Y=e.useMemo(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),G=e.useMemo(()=>{if("treemap"===s||"circlepack"===s||"partition"===s)return Zr(d)},[s,d]),X=Object.assign(Object.assign({},n.marginDefaults),i),{customHoverBehavior:V,customClickBehavior:K}=hr({selection:S,linkedHover:E,fallbackFields:y?["string"==typeof y?y:""]:[],unwrapData:!0,onObservation:k,onClick:A,chartType:"TreeDiagram",chartId:w}),U=wr({componentName:"TreeDiagram",data:o});return U?u.createElement(mr,{componentName:"TreeDiagram",message:U,width:j,height:C}):_||u.createElement(Fr,{componentName:"TreeDiagram",width:j,height:C},u.createElement(qt,Object.assign({chartType:s},null!=o&&{data:o},{size:[j,C],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:X,nodeIDAccessor:h,childrenAccessor:l,hierarchySum:G,treeOrientation:c,edgeType:f,nodeStyle:q,edgeStyle:Y,colorBy:y,colorScheme:F,colorByDepth:p,nodeSize:v,nodeLabel:M?m||h:void 0,showLabels:M,enableHover:D,tooltipContent:!1===b?()=>null:Kt(b)||void 0,customHoverBehavior:E||k||A?V:void 0,customClickBehavior:k||A?K:void 0},L&&"none"!==L&&{legendHoverBehavior:W.onLegendHover,legendClickBehavior:W.onLegendClick,legendHighlightedCategory:W.highlightedCategory,legendIsolatedCategories:W.isolatedCategories},{className:a,title:I,description:P,summary:T,accessibleTable:N},x)))}function rn(t){var r;const n=pr(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary,linkedHover:t.linkedHover},{width:600,height:600}),{data:o,margin:i,className:a,childrenAccessor:s="children",valueAccessor:c="value",nodeIdAccessor:l="name",colorBy:d,colorScheme:h,colorByDepth:y=!1,labelMode:g="leaf",nodeLabel:p,padding:f=4,paddingTop:m,tooltip:v,frameProps:b={},selection:x,linkedHover:k,onObservation:A,onClick:w,chartId:S,loading:E,legendInteraction:O}=t,L=n.width,j=n.height,C=n.enableHover,D=null===(r=n.showLabels)||void 0===r||r,M=n.title,I=n.description,P=n.summary,T=n.accessibleTable,N=Xr(E,L,j),{activeSelectionHook:_,customHoverBehavior:$,customClickBehavior:B}=hr({selection:x,linkedHover:k,fallbackFields:d?["string"==typeof d?d:""]:[],onObservation:A,onClick:w,chartType:"Treemap",chartId:S}),R=e.useCallback(e=>{if(!e)return $(null);const t=e.data||e;$({data:(null==t?void 0:t.data)||t})},[$]),W=e.useMemo(()=>Kr(null!=o?o:null,s),[o,s]),z=dr(W,y?void 0:d,h),H=e.useMemo(()=>{if(!d||y)return[];const e=new Set;for(const t of W){const r="function"==typeof d?d(t):t[d];null!=r&&e.add(r+"")}return Array.from(e)},[W,d,y]),F=yr(O,y?void 0:d,H),q=lr(),Y=e.useMemo(()=>new Map,[]),G=e.useMemo(()=>{if(Array.isArray(h))return h;if(q&&q.length>0)return q;const e=St[h];return Array.isArray(e)?e:Et},[h,q]),X=e.useMemo(()=>e=>{const t={stroke:"#fff",strokeWidth:1,strokeOpacity:.8};return t.fill=y?Lt[(e.depth||0)%Lt.length]:d?Ct(e.data||e,d,z):ur(0,q,h),t},[d,y,z,q,h,Y]),V=e.useMemo(()=>_?e=>{var t;const r=Object.assign({},X(e));if(_.isActive)if(_.predicate(e.data||e))(null==x?void 0:x.selectedStyle)&&Object.assign(r,x.selectedStyle);else{const e=null!==(t=null==x?void 0:x.unselectedOpacity)&&void 0!==t?t:.2;r.opacity=e,r.fillOpacity=e,r.strokeOpacity=e,(null==x?void 0:x.unselectedStyle)&&Object.assign(r,x.unselectedStyle)}return r}:X,[X,_,x]),K=e.useMemo(()=>Zr(c),[c]),U=void 0!==m?m:!D||"parent"!==g&&"all"!==g?void 0:18,Z=Object.assign(Object.assign({},n.marginDefaults),i),Q=wr({componentName:"Treemap",data:o});return Q?u.createElement(mr,{componentName:"Treemap",message:Q,width:L,height:j}):N||u.createElement(Fr,{componentName:"Treemap",width:L,height:j},u.createElement(qt,Object.assign({chartType:"treemap"},null!=o&&{data:o},{size:[L,j],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Z,nodeIDAccessor:l,childrenAccessor:s,hierarchySum:K,padding:f,paddingTop:U,nodeStyle:V,colorBy:d,colorScheme:G,colorByDepth:y,nodeLabel:D?p||l:void 0,showLabels:D,labelMode:g,enableHover:C,tooltipContent:!1===v?()=>null:Kt(v)||void 0},(k||A||w)&&{customHoverBehavior:R},(A||w)&&{customClickBehavior:B},O&&"none"!==O&&{legendHoverBehavior:F.onLegendHover,legendClickBehavior:F.onLegendClick,legendHighlightedCategory:F.highlightedCategory,legendIsolatedCategories:F.isolatedCategories},{className:a,title:M,description:I,summary:P,accessibleTable:T},b)))}function nn(t){var r;const n=pr(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary},{width:600,height:600}),{data:o,margin:i,className:a,childrenAccessor:s="children",valueAccessor:c="value",nodeIdAccessor:l="name",colorBy:d,colorScheme:h,colorByDepth:y=!1,nodeLabel:g,circleOpacity:p=.7,padding:f=4,tooltip:m,frameProps:v={},onObservation:b,onClick:x,chartId:k,selection:A,linkedHover:w,loading:S,legendInteraction:E}=t,O=n.width,L=n.height,j=n.enableHover,C=null===(r=n.showLabels)||void 0===r||r,D=n.title,M=n.description,I=n.summary,P=n.accessibleTable,T=Xr(S,O,L),N=e.useMemo(()=>Kr(null!=o?o:null,s),[o,s]),_=dr(N,y?void 0:d,h),$=e.useMemo(()=>{if(!d||y)return[];const e=new Set;for(const t of N){const r="function"==typeof d?d(t):t[d];null!=r&&e.add(r+"")}return Array.from(e)},[N,d,y]),B=yr(E,y?void 0:d,$),R=lr(),W=e.useMemo(()=>new Map,[]),z=e.useMemo(()=>{if(Array.isArray(h))return h;if(R&&R.length>0)return R;const e=St[h];return Array.isArray(e)?e:Et},[h,R]),H=e.useMemo(()=>e=>{const t={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:p};return t.fill=y?Lt[(e.depth||0)%Lt.length]:d?Ct(e.data||e,d,_):ur(0,R,h),t},[d,y,_,p,R,h,W]),F=e.useMemo(()=>Zr(c),[c]),q=Object.assign(Object.assign({},n.marginDefaults),i),{customHoverBehavior:Y,customClickBehavior:G}=hr({selection:A,linkedHover:w,fallbackFields:d?["string"==typeof d?d:""]:[],unwrapData:!0,onObservation:b,onClick:x,chartType:"CirclePack",chartId:k}),X=wr({componentName:"CirclePack",data:o});return X?u.createElement(mr,{componentName:"CirclePack",message:X,width:O,height:L}):T||u.createElement(Fr,{componentName:"CirclePack",width:O,height:L},u.createElement(qt,Object.assign({chartType:"circlepack"},null!=o&&{data:o},{size:[O,L],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:q,nodeIDAccessor:l,childrenAccessor:s,hierarchySum:F,padding:f,nodeStyle:H,colorBy:d,colorScheme:z,colorByDepth:y,nodeLabel:C?g||l:void 0,showLabels:C,enableHover:j,tooltipContent:!1===m?()=>null:Kt(m)||void 0,customHoverBehavior:w||b||x?Y:void 0,customClickBehavior:b||x?G:void 0},E&&"none"!==E&&{legendHoverBehavior:B.onLegendHover,legendClickBehavior:B.onLegendClick,legendHighlightedCategory:B.highlightedCategory,legendIsolatedCategories:B.isolatedCategories},{className:a,title:D,description:M,summary:I,accessibleTable:P},v)))}en.displayName="ChordDiagram",tn.displayName="TreeDiagram",rn.displayName="Treemap",nn.displayName="CirclePack";const on=Lt;function an(t){const r=pr(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary},{width:600,height:600}),{data:n,margin:o,className:i,childrenAccessor:a="children",nodeIdAccessor:s="name",colorBy:c,colorScheme:l,colorByDepth:d=!1,orbitMode:h="flat",orbitSize:y=2.95,speed:g=.25,revolution:p,revolutionStyle:f,eccentricity:m=1,showRings:v=!0,nodeRadius:b=6,showLabels:x=!1,animated:k=!0,tooltip:A,foregroundGraphics:w,annotations:S,frameProps:E={},onObservation:O,onClick:L,chartId:j,selection:C,linkedHover:D,loading:M}=t,I=r.width,P=r.height,T=r.enableHover,N=r.title,_=r.description,$=r.summary,B=r.accessibleTable,R=Xr(M,I,P),W=dr(e.useMemo(()=>Kr(n,a),[n,a]),d?void 0:c,l),z=lr(),H=e.useMemo(()=>new Map,[]),F=e.useMemo(()=>{if(Array.isArray(l))return l;if(z&&z.length>0)return z;const e=St[l];return Array.isArray(e)?e:Et},[l,z]),q=e.useMemo(()=>{if(Array.isArray(l))return l;const e=St[l];return Array.isArray(e)?e:Et},[l]),Y=e.useMemo(()=>e=>{var t;const r={stroke:"#fff",strokeWidth:1},n=0===(null!==(t=e.depth)&&void 0!==t?t:0);return r.fill=d?n?q[0]:on[(e.depth||0)%on.length]:c?Ct(e.data||e,c,W):ur(0,z,l),r.opacity=n?1:.85,r},[c,d,W,q,z,l,H]),G=e.useMemo(()=>()=>({stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1}),[]),X=Object.assign({top:10,right:10,bottom:10,left:10},o),{customHoverBehavior:V,customClickBehavior:K}=hr({selection:C,linkedHover:D,fallbackFields:c?["string"==typeof c?c:""]:[],unwrapData:!0,onObservation:O,onClick:L,chartType:"OrbitDiagram",chartId:j}),U=e.useMemo(()=>{if(V)return e=>{V(e&&e.data&&void 0!==e.data.data?Object.assign(Object.assign({},e),{data:e.data.data}):e)}},[V]),Z=e.useMemo(()=>{if(K)return e=>{K(e&&e.data&&void 0!==e.data.data?Object.assign(Object.assign({},e),{data:e.data.data}):e)}},[K]),Q=wr({componentName:"OrbitDiagram",data:n});return Q?u.createElement(mr,{componentName:"OrbitDiagram",message:Q,width:I,height:P}):R||u.createElement(Fr,{componentName:"OrbitDiagram",width:I,height:P},u.createElement(qt,Object.assign({chartType:"orbit"},null!=n&&{data:n},{size:[I,P],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:X,nodeIDAccessor:s,childrenAccessor:a,nodeStyle:Y,edgeStyle:G,colorBy:c,colorScheme:F,colorByDepth:d,nodeSize:b,nodeLabel:x?s:void 0,showLabels:x,enableHover:!k&&T,tooltipContent:k?void 0:!1===A?()=>null:Kt(A)||void 0,customHoverBehavior:D||O||L?U:void 0,customClickBehavior:O||L?Z:void 0,foregroundGraphics:w,annotations:S,className:i,title:N,description:_,summary:$,orbitMode:h,orbitSize:y,orbitSpeed:g,orbitRevolution:p,orbitRevolutionStyle:f,orbitEccentricity:m,orbitShowRings:v,orbitAnimated:k,accessibleTable:B},E)))}an.displayName="OrbitDiagram",exports.ChordDiagram=en,exports.CirclePack=nn,exports.ForceDirectedGraph=Vr,exports.OrbitDiagram=an,exports.SankeyDiagram=Jr,exports.StreamNetworkFrame=qt,exports.TreeDiagram=tn,exports.Treemap=rn;
1
+ "use strict";const e=require("react/jsx-runtime"),t=require("react"),r=require("d3-interpolate"),n=require("d3-array"),o=require("d3-scale-chromatic"),i=require("d3-force"),a=require("d3-scale"),s=require("d3-chord"),c=require("d3-shape"),l=require("d3-hierarchy");function u(e){if(e&&e.__esModule)return e;const t=Object.create(null);if(e)for(const r in e)if("default"!==r){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}return t.default=e,Object.freeze(t)}const d=u(t);function h(e,t,r,n){return Object.assign(Object.assign(Object.assign({},function(e){return"object"!=typeof e||null===e||Array.isArray(e)?{}:e}(e)),{data:e,x:t,y:r,time:t,value:r}),n)}const y={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},g={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class f{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){const t=this._freeIndices.pop();if(void 0===t)return null;const r=this.particles[t];return r.active=!0,r.t=0,r.offset=Math.random()-.5,r.edgeIndex=e,r.x=0,r.y=0,r}step(e,t,r,n){var o;for(let i=0;this.capacity>i;i++){const a=this.particles[i];if(!a.active)continue;const s=r[a.edgeIndex];if(!s||!s.bezier){a.active=!1,this._freeIndices.push(i);continue}const c=n&&null!==(o=n[a.edgeIndex])&&void 0!==o?o:1;a.t+=e*t*c*(s.bezier.circular?.3:1),1>a.t?p(s.bezier,a.t,a.offset,a):(a.active=!1,this._freeIndices.push(i))}}countForEdge(e){let t=0;for(let r=0;this.capacity>r;r++)this.particles[r].active&&this.particles[r].edgeIndex===e&&t++;return t}clear(){for(let e=0;this.capacity>e;e++)this.particles[e].active=!1;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 r=0;e>r;r++)t.length>r?this.particles[r]=t[r]:(this.particles[r]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices.push(r));this.capacity=e}}function p(e,t,r,n){if(e.circular&&e.segments)return void function(e,t,r,n,o){const i=e.length,a=t*i,s=Math.min(Math.floor(a),i-1),c=a-s,[l,u,d,h]=e[s];m(l,u,d,h,c,o);const y=h.x-l.x,g=h.y-l.y,f=Math.sqrt(y*y+g*g);if(f>.001){const e=y/f;o.x+=-g/f*r*n*2,o.y+=e*r*n*2}}(e.segments,t,r,e.halfWidth,n);if(!e.points)return n.x=0,void(n.y=0);const[o,i,a,s]=e.points;m(o,i,a,s,t,n);const c=s.x-o.x,l=s.y-o.y,u=Math.sqrt(c*c+l*l);if(u>.001){const t=c/u;n.x+=-l/u*r*e.halfWidth*2,n.y+=t*r*e.halfWidth*2}}function m(e,t,r,n,o,i){const a=1-o,s=a*a,c=s*a,l=o*o,u=l*o;i.x=c*e.x+3*s*o*t.x+3*a*l*r.x+u*n.x,i.y=c*e.y+3*s*o*t.y+3*a*l*r.y+u*n.y}function v(e,t){var r=e.get(t);if(!r)throw Error("missing: "+t);return r}function b(e,t){var r,n=[],o=[],i=[],a={},s=[];function c(e){i[e]=!1,a.hasOwnProperty(e)&&Object.keys(a[e]).forEach(function(t){delete a[e][t],i[t]&&c(t)})}function l(e){var t,n,d=!1;for(o.push(e),i[e]=!0,t=0;s[e].length>t;t++)(n=s[e][t])===r?(u(r,o),d=!0):i[n]||(d=l(n));if(d)c(e);else for(t=0;s[e].length>t;t++){var h=a[n=s[e][t]];h||(a[n]=h={}),h[n]=!0}return o.pop(),d}function u(e,t){var r=[].concat(t).concat(e);n.push(r)}function d(t){!function(t){for(var r=0;e.length>r;r++)r>=t&&e[r]||(e[r]=[]),e[r]=e[r].filter(function(e){return e>=t})}(t);for(var r,n=function(e){for(var t=e.length,r=Array(t),n=Array(t),o=Array(t),i=Array(t),a=Array(t),s=Array(t),c=0;t>c;++c)r[c]=-1,n[c]=0,o[c]=!1,i[c]=0,a[c]=-1,s[c]=[];var l,u=0,d=[],h=[];function y(t){var c=[t],l=[t];for(r[t]=n[t]=u,o[t]=!0,u+=1;l.length>0;){var y=e[t=l[l.length-1]];if(y.length>i[t]){for(var g=i[t];y.length>g;++g){var f=y[g];if(0>r[f]){r[f]=n[f]=u,o[f]=!0,u+=1,c.push(f),l.push(f);break}o[f]&&(n[t]=0|Math.min(n[t],n[f])),0>a[f]||s[t].push(a[f])}i[t]=g}else{if(n[t]===r[t]){var p=[],m=[],v=0;for(g=c.length-1;g>=0;--g){var b=c[g];if(o[b]=!1,p.push(b),m.push(s[b]),v+=s[b].length,a[b]=d.length,b===t){c.length=g;break}}d.push(p);var x=Array(v);for(g=0;m.length>g;g++)for(var k=0;m[g].length>k;k++)x[--v]=m[g][k];h.push(x)}l.pop()}}}for(c=0;t>c;++c)0>r[c]&&y(c);for(c=0;h.length>c;c++){var g=h[c];if(0!==g.length){g.sort(function(e,t){return e-t}),l=[g[0]];for(var f=1;g.length>f;f++)g[f]!==g[f-1]&&l.push(g[f]);h[c]=l}}return{components:d,adjacencyList:h}}(e),o=n.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],r=a);var c=o[r];if(!c)return!1;var l=e.map(function(e,t){return-1===c.indexOf(t)?[]:e.filter(function(e){return-1!==c.indexOf(e)})});return{leastVertex:i,adjList:l}}r=0;for(var h=e.length;h>r;){var y=d(r);if(r=y.leastVertex,s=y.adjList){for(var g=0;s.length>g;g++)for(var f=0;s[g].length>f;f++){var p=s[g][f];i[+p]=!1,a[p]={}}l(r),r+=1}else r=h}return n}function x(e){return e.y0-e.y1>0?"up":"down"}function k(e,t){return t(e.source)==t(e.target)}function A(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var r=0;return e.target.targetLinks.forEach(function(e){r=e.circular?r+1:r}),1>=t&&1>=r}function w(e){return e.target.x0-e.source.x1}function j(e,t){var r=O(e),n=w(t)/Math.tan(r);return"up"==x(e)?e.y1-n:e.y1+n}function S(e,t){var r=O(e),n=w(t)/Math.tan(r);return"up"==x(e)?e.y1+n:e.y1-n}function O(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function L(e,t){return t(e)}function C(e){return D(e.source)}function M(e){return D(e.target)}function D(e){return(e.y0+e.y1)/2}function E(e){return e.virtual?0:e.value}function P(e,t){var r=0;e.sourceLinks.forEach(function(e){r=e.circular&&!k(e,t)?r+1:r});var n=0;return e.targetLinks.forEach(function(e){n=e.circular&&!k(e,t)?n+1:n}),r+n}function I(e){return e.target.depth}function _(e,t){return e.sourceLinks.length?e.depth:t-1}function T(e,t){return e.y0-t.y0}function N(e,t){return t.y0-e.y0}function R(e,t){return e.y1-t.y1}function W(e,t){return t.y1-e.y1}function $(e,t){return z(e.source,t.source)||e.index-t.index}function B(e,t){return z(e.target,t.target)||e.index-t.index}function z(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function H(e,t){return F(e)==F(t)?"bottom"==e.circularLinkType?N(e,t):T(e,t):F(t)-F(e)}function F(e){return e.target.column-e.source.column}function Y(e,t){return q(e)==q(t)}function q(e){return e.y0-e.y1>0?"up":"down"}function G(e,t,r,o,i){let a=e;var s=Math.max(8,.15*(a.y1-a.y0));a.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,s))});var c=n.min(a.links,function(e){return e.source.y0});a.links.forEach(function(e){e.circular&&(e.circularPathData={})});var l=a.links.filter(function(e){return e.circular});return l.sort(function(e,t){return t.value-e.value}),l.forEach(function(e,t){e._circularStub=t>=4}),X(a.links.filter(function(e){return"top"==e.circularLinkType}),t,r),X(a.links.filter(function(e){return"bottom"==e.circularLinkType}),t,r),a.links.forEach(function(e){if(e.circular){if(e.circularPathData.arcRadius=e._circularWidth+o,e.circularPathData.rightNodeBuffer=5,e.circularPathData.leftNodeBuffer=5,e.circularPathData.sourceWidth=e.source.x1-e.source.x0,e.circularPathData.sourceX=e.source.x0+e.circularPathData.sourceWidth,e.circularPathData.targetX=e.target.x0,e.circularPathData.sourceY=e.y0,e.circularPathData.targetY=e.y1,k(e,t)&&A(e))e.circularPathData.rightSmallArcRadius=o+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=o+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=o+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=o+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+i+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-i-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius);else{var n=e.source.column,s=e.circularLinkType,l=a.links.filter(function(e){return e.source.column==n&&e.circularLinkType==s});l.sort("bottom"==e.circularLinkType?N:T);var u=0;l.forEach(function(t,n){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=o+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=o+e._circularWidth/2+n*r+u),u+=t._circularWidth||t.width}),n=e.target.column,(l=a.links.filter(function(e){return e.target.column==n&&e.circularLinkType==s})).sort("bottom"==e.circularLinkType?W:R),u=0,l.forEach(function(t,n){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=o+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=o+e._circularWidth/2+n*r+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(a.y1,e.source.y1,e.target.y1)+i+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=c-i-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius)}e.circularPathData.rightInnerExtent=e.circularPathData.sourceX+e.circularPathData.rightNodeBuffer,e.circularPathData.leftInnerExtent=e.circularPathData.targetX-e.circularPathData.leftNodeBuffer,e.circularPathData.rightFullExtent=e.circularPathData.sourceX+e.circularPathData.rightLargeArcRadius+e.circularPathData.rightNodeBuffer,e.circularPathData.leftFullExtent=e.circularPathData.targetX-e.circularPathData.leftLargeArcRadius-e.circularPathData.leftNodeBuffer}e.path=e.circular?function(e){return"top"==e.circularLinkType?"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 0 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY-e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 0 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 0 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY-e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 0 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY:"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 1 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY+e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 1 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 1 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY+e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 1 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY}(e):function(e){var t=e.source.x1,r=e.y0,n=e.target.x0,o=e.y1,i=(t+n)/2;return"M"+t+","+r+"C"+i+","+r+" "+i+","+o+" "+n+","+o}(e)}),a}function X(e,t,r){e.sort(H);var n=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(k(e,t)&&A(e))e.circularPathData.verticalBuffer=i+e._circularWidth/2;else{for(var a=0;n.length>a;a++){var s=n[a];if(s!==e&&s.circularPathData&&void 0!==s.circularPathData.verticalBuffer&&V(e,s)){var c=s.circularPathData.verticalBuffer+(s._circularWidth||s.width)/2+r;i=c>i?c:i}}e.circularPathData.verticalBuffer=i+e._circularWidth/2}}),e}function V(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}function K(e){return function(){return e}}function U(e){return e.index}function Z(e){return e.nodes}function Q(e){return e.links}function J(e,t,r){var o=n.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});o.forEach(function(n,i){var a=n.length;if(t)n.sort(t);else if(i>0){var s=new Map;n.forEach(function(e,t){var r,n,o,i=(n=0,o=0,(r=e).targetLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=D(e.source)*t,n+=t}}),r.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=D(e.target)*t,n+=t}}),n>0?o/n:NaN);s.set(e,{bc:i,idx:t})}),n.sort(function(e,t){var r=s.get(e),n=s.get(t),o=r.bc,i=n.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)?r.idx-n.idx:1:-1:o-i})}else n.sort(function(e,t){return e.circularLinkType==t.circularLinkType?P(t,r)-P(e,r):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0});n.forEach(function(t,n){t.depth==o.length-1&&1==a||0==t.depth&&1==a?(t.y0=e.y1/2-t.value*e.ky,t.y1=t.y0+t.value*e.ky):t.partOfCycle?0==P(t,r)?(t.y0=e.y1/2+n,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+n,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-n,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/a*n,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-a/2+n,t.y1=t.y0+t.value*e.ky)})})}function ee(e,t,r,o,i,a){var s=n.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});d();for(var c=1,l=a;l>0;--l)u(c*=.99,r),d();function u(t,r){var o=s.length;s.forEach(function(i){var a=i.length,s=i[0].depth;i.forEach(function(i){var c;if(i.sourceLinks.length||i.targetLinks.length)if(i.partOfCycle&&P(i,r)>0){var l=n.mean(i.sourceLinks,M),u=n.mean(i.targetLinks,C),d=l&&u?(l+u)/2:l||u;if(d){var h=(d-D(i))*t*.3;i.y0+=h,i.y1+=h}}else if(0==s&&1==a)i.y0=e.y1/2-(c=i.y1-i.y0)/2,i.y1=e.y1/2+c/2;else if(s==o-1&&1==a)i.y0=e.y1/2-(c=i.y1-i.y0)/2,i.y1=e.y1/2+c/2;else if(1==i.targetLinks.length&&1==i.targetLinks[0].source.sourceLinks.length)c=i.y1-i.y0,i.y0=i.targetLinks[0].source.y0,i.y1=i.y0+c;else{var y=n.mean(i.sourceLinks,M),g=n.mean(i.targetLinks,C),f=((y&&g?(y+g)/2:y||g)-D(i))*t;i.y0+=f,i.y1+=f}})})}function d(){s.forEach(function(r){var n,a,s,c=e.y0,l=r.length;for(r.sort(t||z),s=0;l>s;++s)(a=c-(n=r[s]).y0)>0&&(n.y0+=a,n.y1+=a),c=n.y1+o;if((a=c-o-e.y1)>0)for(c=n.y0-=a,n.y1-=a,s=l-2;s>=0;--s)(a=(n=r[s]).y1+i-c)>0&&(n.y0-=a,n.y1-=a),c=n.y0})}}function te(e){e.nodes.forEach(function(e){e.sourceLinks.sort(B),e.targetLinks.sort($)}),e.nodes.forEach(function(e){var t=e.y0,r=t,n=e.y1,o=n;e.sourceLinks.forEach(function(e){e.circular?(e.y0=n-e.width/2,n-=e.width):(e.y0=t+e.width/2,t+=e.width)}),e.targetLinks.forEach(function(e){e.circular?(e.y1=o-e.width/2,o-=e.width):(e.y1=r+e.width/2,r+=e.width)})})}function re(){var e=0,t=0,r=1,o=1,i=24,a=8,s=null,c=U,l=_,u=void 0,d=32,h=2,y=Z,g=Q;function f(){var f={nodes:y.apply(null,arguments),links:g.apply(null,arguments)};return function(y){y.x0=e,y.y0=t,y.x1=r,y.y1=o,y.py=0,function(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var r=function(e,t){var r=new Map;return n.group(e,t).forEach(function(e,t){r.set(t,e[0])}),r}(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var n=e.source,o=e.target;"object"!=typeof n&&(n=e.source=v(r,n)),"object"!=typeof o&&(o=e.target=v(r,o)),n.sourceLinks.push(e),o.targetLinks.push(e)})}(y,c),function(e,t){var r=0;if(null==t){for(var n=[],o=0;e.links.length>o;o++){var i=e.links[o],a=i.source.index,s=i.target.index;n[a]||(n[a]=[]),n[s]||(n[s]=[]),-1===n[a].indexOf(s)&&n[a].push(s)}var c=b(n);c.sort(function(e,t){return e.length-t.length});var l={};for(o=0;c.length>o;o++){var u=c[o].slice(-2);l[u[0]]||(l[u[0]]={}),l[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,n=e.source.index;t===n||l[n]&&l[n][t]?(e.circular=!0,e.circularLinkID=r++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=r++)})}(y,u),function(e,t){var r=0,n=0;e.links.forEach(function(o){o.circular&&(o.circularLinkType=o.source.circularLinkType||o.target.circularLinkType?o.source.circularLinkType?o.source.circularLinkType:o.target.circularLinkType:n>r?"top":"bottom","top"==o.circularLinkType?r++:n++,e.nodes.forEach(function(e){L(e,t)!=L(o.source,t)&&L(e,t)!=L(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),k(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(y,c),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(n.sum(e.sourceLinks,E),n.sum(e.targetLinks,E)),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)})})}(y),function(e,t,r){var n,o,i;if(null!=t){e.nodes.sort(function(e,r){return t(e)<t(r)?-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(n=e.nodes,o=[],i=0;n.length;++i,n=o,o=[])n.forEach(function(e){e.depth=i,e.sourceLinks.forEach(function(e){0>o.indexOf(e.target)&&!e.circular&&o.push(e.target)})});for(n=e.nodes,o=[],i=0;n.length;++i,n=o,o=[])n.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?r(e,i):e.column})}(y,u,l);var g=a;if(null!==s){var f=n.groups(y.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),p=n.max(f,function(e){return e.length});p>1&&(g=Math.max(1,(o-t)*s/(p-1)))}(function(e,t,r){var o=n.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 i=n.min(o,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/n.sum(t,function(e){return e.value})});e.ky=i,e.links.forEach(function(t){t.width=t.value*e.ky});var a=n.max(e.nodes,function(e){return e.column});e.nodes.forEach(a>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-r)/a),t.x1=t.x0+r}:function(t){t.x0=e.x0,t.x1=t.x0+r})})(y,g,i),J(y,u,c),ee(y,u,c,g,g,d),te(y),G(y,c,h,10,8),J(y,u,c),ee(y,u,c,g,g,d),te(y),G(y,c,h,10,8),function(e,t){let r=e;r.nodes.forEach(function(e){e.y+(e.y1-e.y0)>r.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-r.y1));var n=r.links.filter(function(r){return L(r.source,t)==L(e,t)}),o=n.length;o>1&&n.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!Y(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var r=j(t,e);return e.y1-r}if(t.target.column>e.target.column)return j(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;n.forEach(function(e){e.y0=i+e.width/2,i+=e.width}),n.forEach(function(t,r){if("bottom"==t.circularLinkType){for(var i=r+1,a=0;o>i;i++)a+=n[i].width;t.y0=e.y1-a-t.width/2}})})}(y,c),function(e,t){let r=e;r.nodes.forEach(function(e){var n=r.links.filter(function(r){return L(r.target,t)==L(e,t)}),o=n.length;o>1&&n.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!Y(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var r=S(t,e);return e.y0-r}if(t.source.column>e.source.column)return S(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;n.forEach(function(e){e.y1=i+e.width/2,i+=e.width}),n.forEach(function(t,r){if("bottom"==t.circularLinkType){for(var i=r+1,a=0;o>i;i++)a+=n[i].width;t.y1=e.y1-a-t.width/2}})})}(y,c),function(e){var t=e.nodes,r=e.links,o=!1,i=!1;if(r.forEach(function(e){"top"==e.circularLinkType?o=!0:"bottom"==e.circularLinkType&&(i=!0)}),0==o||0==i){var a=n.min(t,function(e){return e.y0}),s=n.max(t,function(e){return e.y1}),c=(e.y1-e.y0)/(s-a);function l(t){return(t-a)/(s-a)*(e.y1-e.y0)+e.y0}1>c?(t.forEach(function(e){e.y0=l(e.y0),e.y1=l(e.y1)}),r.forEach(function(e){e.y0=l(e.y0),e.y1=l(e.y1),e.width=e.width*c})):t.forEach(function(e){var t=e.y1-e.y0,r=l(e.y0)-e.y0;e.y0=l(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+r}),e.targetLinks.forEach(function(e){e.y1=e.y1+r})})}}(y),G(y,c,h,10,8)}(f),f}return f.update=function(e){return te(e),G(e,c,h,10,8),e},f.nodeWidth=function(e){return arguments.length?(i=+e,f):i},f.nodePadding=function(e){return arguments.length?(a=+e,f):a},f.nodePaddingRatio=function(e){return arguments.length?(s=+e,f):s},f.nodes=function(e){return arguments.length?(y="function"==typeof e?e:K(e),f):y},f.links=function(e){return arguments.length?(g="function"==typeof e?e:K(e),f):g},f.nodeId=function(e){return arguments.length?(c="function"==typeof e?e:K(e),f):c},f.nodeAlign=function(e){return arguments.length?(l="function"==typeof e?e:K(e),f):l},f.nodeSort=function(e){return arguments.length?(u=e,f):u},f.iterations=function(e){return arguments.length?(d=+e,f):d},f.circularLinkGap=function(e){return arguments.length?(h=+e,f):h},f.extent=function(n){return arguments.length?(e=+n[0][0],t=+n[0][1],r=+n[1][0],o=+n[1][1],f):[[e,t],[r,o]]},f.size=function(n){return arguments.length?(e=t=0,r=+n[0],o=+n[1],f):[r-e,o-t]},f}const ne=e=>{let t,n,o,i,a,s,c,l,u;return"down"===e.direction?(t=e.y0-e.sankeyWidth/2,n=e.y1-e.sankeyWidth/2,o=e.y1+e.sankeyWidth/2,i=e.y0+e.sankeyWidth/2,a=e.source.x1,s=e.target.x0,c=r.interpolateNumber(a,s),l=c(.5),u=c(.5),`M${t},${a}C${t},${l} ${n},${u} ${n},${s}L${o},${s}C${o},${u} ${i},${l} ${i},${a}Z`):(t=e.source.x1,n=e.target.x0,c=r.interpolateNumber(t,n),o=c(.5),i=c(.5),a=e.y0-e.sankeyWidth/2,s=e.y1-e.sankeyWidth/2,l=e.y1+e.sankeyWidth/2,u=e.y0+e.sankeyWidth/2,`M${t},${a}C${o},${a} ${i},${s} ${n},${s}L${n},${l}C${i},${l} ${o},${u} ${t},${u}Z`)};function oe(e){var t;const r=e.sankeyWidth/2,n=(null!==(t=e._circularWidth)&&void 0!==t?t:e.sankeyWidth)/2,o=e.circularPathData;if(!o)return null;if("down"===e.direction)return null;if(e._circularStub){const t=o.sourceX,n=o.sourceY,i=o.targetX,a=o.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*(o.rightFullExtent-t))),c=Math.max(15,Math.min(40,.33*(i-o.leftFullExtent)));return`M${t},${n-r}L${t+s},${n-r}L${t+s},${n+r}L${t},${n+r}ZM${i},${a-r}L${i-c},${a-r}L${i-c},${a+r}L${i},${a+r}Z`}const i=o.sourceX,a=o.sourceY,s=o.targetX,c=o.targetY,l=o.rightFullExtent,u=o.leftFullExtent,d=o.verticalFullExtent,h="bottom"===e.circularLinkType?1:-1,y=Math.max(4,Math.min(n,15));return`M${i},${a-h*r}L${l},${a-h*r}L${l+n},${a-h*r+h*y}L${l+n},${d+h*n-h*y}L${l+n-y},${d+h*n}L${u-n+y},${d+h*n}L${u-n},${d+h*n-h*y}L${u-n},${c-h*r+h*y}L${u-n+y},${c-h*r}L${s},${c-h*r}L${s},${c+h*r}L${u+n},${c+h*r}L${u+n},${d-h*n}L${l-n},${d-h*n}L${l-n},${a+h*r}L${i},${a+h*r}Z`}const ie=new Set,ae=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 r=ae.get(e);if(r){const e=r.get(t);if(e)return e}else r=new Map,ae.set(e,r);const n=new Proxy(e,{get(e,r,n){if("string"==typeof r&&!(r in e)&&e.data&&r in e.data){const e=`${t}:${r}`;ie.has(e)||(ie.add(e),console.warn(`[Semiotic] "${t}" callback accessed "${r}" on the wrapper object, but it only exists on ".data". Use d.data.${r} (or d.data?.${r}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(e,r,n)}});return r.set(t,n),n}const 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(I))-1:0},justify:_},le={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,r,n){var o,i,a,s,c,l,u;if(0===e.length)return;const d="vertical"===r.orientation?"down":"right",h=r.nodeAlign||"justify",y=null!==(o=r.nodeWidth)&&void 0!==o?o:15,g=null!==(i=r.nodePaddingRatio)&&void 0!==i?i:.05,f=null!==(a=r.iterations)&&void 0!==a?a:100,p=e.map(e=>Object.assign({},e)),m=t.map(e=>Object.assign(Object.assign({},e),{source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id,value:Math.sqrt(Math.max(1,e.value||1))}));let v;v="down"===d?[[0,0],[n[1],n[0]]]:[[0,0],[n[0],n[1]]];const b=re().extent(v).links(m).nodes(p).nodeAlign(ce[h]||_).nodeId(e=>e.id).nodeWidth(y).iterations(f);b.nodePaddingRatio&&b.nodePaddingRatio(g),b();{let e=1/0,t=-1/0,r=1/0,o=-1/0;for(const n of p)e>n.x0&&(e=n.x0),n.x1>t&&(t=n.x1),r>n.y0&&(r=n.y0),n.y1>o&&(o=n.y1);for(const n of m){if(!n.circular||!n.circularPathData)continue;const i=n.circularPathData,a=(null!==(c=null!==(s=n._circularWidth)&&void 0!==s?s:n.width)&&void 0!==c?c:0)/2;e>i.leftFullExtent-a&&(e=i.leftFullExtent-a),i.rightFullExtent+a>t&&(t=i.rightFullExtent+a),r>i.verticalFullExtent-a&&(r=i.verticalFullExtent-a),i.verticalFullExtent+a>o&&(o=i.verticalFullExtent+a)}const i=t-e,a=o-r,u=n[0],d=n[1];if(i>0&&a>0&&(0>e||0>r||t>u||o>d)){const t=Math.min(u/i,d/a),n=-e*t+(u-i*t)/2,o=-r*t+(d-a*t)/2;for(const e of p)e.x0=e.x0*t+n,e.x1=e.x1*t+n,e.y0=e.y0*t+o,e.y1=e.y1*t+o;for(const e of m)if(e.y0=e.y0*t+o,e.y1=e.y1*t+o,e.width=(null!==(l=e.width)&&void 0!==l?l:0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){const r=e.circularPathData;r.sourceX=r.sourceX*t+n,r.targetX=r.targetX*t+n,r.sourceY=r.sourceY*t+o,r.targetY=r.targetY*t+o,r.rightFullExtent=r.rightFullExtent*t+n,r.leftFullExtent=r.leftFullExtent*t+n,r.verticalFullExtent=r.verticalFullExtent*t+o,r.rightInnerExtent=r.rightInnerExtent*t+n,r.leftInnerExtent=r.leftInnerExtent*t+n,r.verticalRightInnerExtent=r.verticalRightInnerExtent*t+o,r.verticalLeftInnerExtent=r.verticalLeftInnerExtent*t+o,r.rightSmallArcRadius*=t,r.rightLargeArcRadius*=t,r.leftSmallArcRadius*=t,r.leftLargeArcRadius*=t,r.sourceWidth*=t,r.rightNodeBuffer*=t,r.leftNodeBuffer*=t,r.arcRadius*=t}}}const x=new Map;for(const t of e)x.set(t.id,t);for(const e of p){const t=x.get(e.id);t&&(t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.value=e.value,t.depth=e.depth,t.sourceLinks=e.sourceLinks,t.targetLinks=e.targetLinks,t.width=e.x1-e.x0,t.height=e.y1-e.y0,t.x=e.x0+(e.x1-e.x0)/2,t.y=e.y0+(e.y1-e.y0)/2)}const k=new Map;for(const e of t)k.set(e._edgeKey?e._edgeKey:`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const e of m){const t=e.source,r=e.target,n="object"==typeof t&&null!==t?t.id:t+"",o="object"==typeof r&&null!==r?r.id:r+"",i=k.get(e._edgeKey?e._edgeKey:`${n}\0${o}`);if(i){i.y0=e.y0,i.y1=e.y1,i.sankeyWidth=null!==(u=e.width)&&void 0!==u?u:0,i.circular=!!e.circular,i.circularPathData=e.circularPathData,i._circularWidth=e._circularWidth,i._circularStub=e._circularStub,i.path=e.path,i.circularLinkType=e.circularLinkType,i.direction=d;const t=x.get(n),r=x.get(o);t&&(i.source=t),r&&(i.target=r)}}},buildScene(e,t,r,n){var i,a,s,c,l,u;const d="vertical"===r.orientation?"down":"right",h=r.nodeStyle,y=r.edgeStyle,g=null!==(i=r.edgeOpacity)&&void 0!==i?i:.5,f=r.edgeColorBy||"source",p=Array.isArray(r.colorScheme)?r.colorScheme:r.themeCategorical&&r.themeCategorical.length>0?r.themeCategorical:o.schemeCategory10,m=new Map;e.forEach((e,t)=>{m.set(e.id,p[t%p.length])});const v=[],b=[],x=[],k=new Map;for(const t of e){const e=t.x1-t.x0,r=t.y1-t.y0;if(0>=e||0>=r)continue;const n=h?h(se(t,"nodeStyle")):{},o={fill:n.fill||m.get(t.id)||"#4d430c",stroke:n.stroke,strokeWidth:n.strokeWidth,opacity:n.opacity};k.set(t.id,("string"==typeof o.fill?o.fill:null)||m.get(t.id)||"#4d430c"),v.push("down"===d?{type:"rect",x:t.y0,y:t.x0,w:r,h:e,style:o,datum:t,id:t.id,label:t.id}:{type:"rect",x:t.x0,y:t.y0,w:e,h:r,style:o,datum:t,id:t.id,label:t.id})}const A=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of A){if(!e.sankeyWidth||0>=e.sankeyWidth)continue;const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;if(!t||!n)continue;let o=(null===(a=r.themeSemantic)||void 0===a?void 0:a.border)||(null===(s=r.themeSemantic)||void 0===s?void 0:s.secondary)||"#999";o="function"==typeof f?f(e)||o:"target"===f?k.get(n.id)||m.get(n.id)||o:k.get(t.id)||m.get(t.id)||o;const i=y?y(se(e,"edgeStyle")):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,r=e.sankeyWidth/2,n=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),a=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),s=i.fill||o;b.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-r}L${t.sourceX+n},${t.sourceY-r}L${t.sourceX+n},${t.sourceY+r}L${t.sourceX},${t.sourceY+r}Z`,style:{fill:s,fillOpacity:null!==(c=i.fillOpacity)&&void 0!==c?c:g,stroke:"none",opacity:i.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+n}}),b.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-r}L${t.targetX-a},${t.targetY-r}L${t.targetX-a},${t.targetY+r}L${t.targetX},${t.targetY+r}Z`,style:{fill:s,fillOpacity:null!==(l=i.fillOpacity)&&void 0!==l?l:g,stroke:"none",opacity:i.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-a,x1:t.targetX}});continue}let d;if(d=e.circular&&e.circularPathData?oe(e):ne(e),!d)continue;const h={fill:i.fill||o,fillOpacity:null!==(u=i.fillOpacity)&&void 0!==u?u:g,stroke:i.stroke||"none",strokeWidth:i.strokeWidth,opacity:i.opacity};b.push({type:"bezier",pathD:d,bezierCache:e.bezier,style:h,datum:e})}if(!1!==r.showLabels){const t=(w=r.nodeLabel)?"function"==typeof w?w:e=>e[w]||e.id:null;for(const r of e){const e=r.x1-r.x0,o=r.y1-r.y0;if(0>=e||0>=o)continue;const i=t?t(r):r.id;if(!i)continue;let a,s,c;"down"===d?(a=r.y0+(r.y1-r.y0)/2,s=r.x1+14,c="middle"):(n[0]/2>r.x0+e/2?(a=r.x0-6,c="end"):(a=r.x1+6,c="start"),s=r.y0+o/2),x.push({x:a,y:s,text:i+"",anchor:c,baseline:"middle",fontSize:11})}}var w;return{sceneNodes:v,sceneEdges:b,labels:x}}},ue={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,r,n){var o,a;if(0===e.length)return;const s=null!==(o=r.forceStrength)&&void 0!==o?o:.1,c=n[0]/2,l=n[1]/2,u=r.__previousPositions;let d=0;const h=[];for(const t of e){const e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),r=null==u?void 0:u.get(t.id);e?d++:r?(t.x=r.x,t.y=r.y,d++):h.push(t)}const y=d>0&&.3>=(e.length>0?h.length/e.length:1);if(y){const r=new Map;for(const t of e)r.set(t.id,t);for(const e of h){const n=de(e.id,t,r);if(n.length>0){let t=0,r=0;for(const e of n)t+=e.x,r+=e.y;const o=he(e.id),i=o%360*(Math.PI/180),a=10+o%20;e.x=t/n.length+a*Math.cos(i),e.y=r/n.length+a*Math.sin(i)}else{const t=he(e.id),r=t%360*(Math.PI/180),n=15+t%30;e.x=c+n*Math.cos(r),e.y=l+n*Math.sin(r)}}}else{const t=2.399963229728653;for(let r=0;e.length>r;r++){const n=e[r];if(null==n.x||null==n.y||0===n.x&&0===n.y){const e=10*Math.sqrt(r+.5),o=r*t;n.x=c+e*Math.cos(o),n.y=l+e*Math.sin(o)}}}const g=null!==(a=r.iterations)&&void 0!==a?a:Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),f=0===r.iterations?0:y?40:g,p=ye(r.nodeSize,r.nodeSizeRange,e),m=e=>p(e);if(f>0){const r=i.forceLink().strength(e=>{const t=e.weight;return Math.min(2.5,t?t*s:s)}).id(e=>e.id),n=i.forceSimulation().force("charge",i.forceManyBody().strength(e=>-25*m(e))).force("center",i.forceCenter(c,l).strength(.8)).force("x",i.forceX(c).strength(.15)).force("y",i.forceY(l).strength(.15));if(n.nodes(e),t.length>0){const e=t.map(e=>Object.assign(Object.assign({},e),{source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id}));n.force("link",r),n.force("link").links(e)}y?n.alpha(.3):.1>n.alpha()&&n.alpha(1),n.stop();for(let e=0;f>e;++e)n.tick()}for(const t of e){if(null==t.x||null==t.y)continue;const e=m(t);t.x=Math.max(e,Math.min(n[0]-e,t.x)),t.y=Math.max(e,Math.min(n[1]-e,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}const v=new Map;for(const t of e)v.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=v.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=v.get(e.target);t&&(e.target=t)}}},buildScene(e,t,r,n){var i,a,s,c,l,u,d;const h=r.nodeStyle,y=r.edgeStyle,g=ye(r.nodeSize,r.nodeSizeRange,e),f=Array.isArray(r.colorScheme)?r.colorScheme:r.themeCategorical&&r.themeCategorical.length>0?r.themeCategorical:o.schemeCategory10,p=new Map;e.forEach((e,t)=>{p.set(e.id,f[t%f.length])});const m=[],v=[],b=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=g(se(t,"nodeSize")),n=h?h(se(t,"nodeStyle")):{},o={fill:n.fill||p.get(t.id)||(null===(i=r.themeSemantic)||void 0===i?void 0:i.primary)||"#007bff",stroke:n.stroke||(null===(a=r.themeSemantic)||void 0===a?void 0:a.surface)||"#fff",strokeWidth:null!==(s=n.strokeWidth)&&void 0!==s?s:2,opacity:n.opacity};m.push({type:"circle",cx:t.x,cy:t.y,r:e,style:o,datum:t,id:t.id,label:t.id})}const x=new Map;for(const t of e)x.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:x.get(e.source),n="object"==typeof e.target?e.target:x.get(e.target);if(!t||!n)continue;if(null==t.x||null==t.y)continue;if(null==n.x||null==n.y)continue;const o=y?y(se(e,"edgeStyle")):{},i={stroke:o.stroke||(null===(c=r.themeSemantic)||void 0===c?void 0:c.border)||(null===(l=r.themeSemantic)||void 0===l?void 0:l.secondary)||"#999",strokeWidth:null!==(u=o.strokeWidth)&&void 0!==u?u:1,opacity:null!==(d=o.opacity)&&void 0!==d?d:.6};v.push({type:"line",x1:t.x,y1:t.y,x2:n.x,y2:n.y,style:i,datum:e})}if(!1!==r.showLabels){const t=(k=r.nodeLabel)?"function"==typeof k?k:e=>e[k]||e.id:null;for(const r of e){if(null==r.x||null==r.y)continue;const e=t?t(r):r.id;if(!e)continue;const n=g(se(r,"nodeSize"));b.push({x:r.x,y:r.y-n-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var k;return{sceneNodes:m,sceneEdges:v,labels:b}}};function de(e,t,r){const n=[];for(const o of t){const t="string"==typeof o.source?o.source:o.source.id,i="string"==typeof o.target?o.target:o.target.id;let a=null;if(t===e?a=i:i===e&&(a=t),a){const e=r.get(a);!e||0===e.x&&0===e.y||n.push({x:e.x,y:e.y})}}return n}function he(e){let t=0;for(let r=0;e.length>r;r++)t=(t<<5)-t+e.charCodeAt(r)|0;return Math.abs(t)}function ye(e,t,r){var o,i;if(null==e)return()=>8;if("number"==typeof e)return()=>e;if("function"==typeof e)return t=>e(t)||8;const s=t||[5,20],c=r.map(t=>{var r;return null===(r=t.data)||void 0===r?void 0:r[e]}).filter(e=>null!=e&&"number"==typeof e);if(0===c.length)return()=>s[0];const l=null!==(o=n.min(c))&&void 0!==o?o:0,u=null!==(i=n.max(c))&&void 0!==i?i:1;if(l===u)return()=>(s[0]+s[1])/2;const d=a.scaleLinear().domain([l,u]).range(s).clamp(!0);return t=>{var r;const n=null===(r=t.data)||void 0===r?void 0:r[e];return null==n||"number"!=typeof n?s[0]:d(n)}}const ge=o.schemeCategory10,fe={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,r,n){if(0===e.length)return;const{padAngle:o=.01,groupWidth:i=20,sortGroups:a}=r,l=Math.min(n[0],n[1])/2,u=l-i,d=n[0]/2,h=n[1]/2,y=(g=r.valueAccessor)?"function"==typeof g?g:e=>{var t;return null!==(t=e[g])&&void 0!==t?t:1}:e=>{var t;return null!==(t=e.value)&&void 0!==t?t:1};var g;const f=new Map;for(let t=0;e.length>t;t++)f.set(e[t].id,t);const p=e.length,m=Array.from({length:p},()=>Array.from({length:p},()=>0));for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,r=f.get("string"==typeof e.source?e.source:e.source.id),n=f.get(t);if(void 0===r||void 0===n)continue;const o=y(e);m[r][n]=o}const v=s.chord().padAngle(o);a&&v.sortGroups(a);const b=v(m),x=b.groups,k=c.arc().innerRadius(u).outerRadius(l);for(const t of x){const r=e[t.index],n=k.centroid(t);r.x=n[0]+d,r.y=n[1]+h,r.arcData={startAngle:t.startAngle,endAngle:t.endAngle}}const A=new Map;for(const t of e)A.set(t.id,t);for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,r=A.get("string"==typeof e.source?e.source:e.source.id),n=A.get(t);r&&(e.source=r),n&&(e.target=n)}const w=new Map;for(const e of t)w.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const t of b){const r=e[t.source.index].id,n=e[t.target.index].id,o=w.get(`${r}\0${n}`)||w.get(`${n}\0${r}`);o&&(o.chordData=t)}},buildScene(e,t,r,n){var o,i,a,c;const{groupWidth:l=20,edgeOpacity:u=.5}=r,d=Math.min(n[0],n[1])/2,h=d-l,y=n[0]/2,g=n[1]/2,f=r.nodeStyle,p=r.edgeStyle,m=r.edgeColorBy||"source",v=Array.isArray(r.colorScheme)?r.colorScheme:r.themeCategorical&&r.themeCategorical.length>0?r.themeCategorical:ge,b=new Map;e.forEach((e,t)=>{b.set(e.id,v[t%v.length])});const x=s.ribbon().radius(h),k=[],A=[],w=[];for(let t=0;e.length>t;t++){const r=e[t],n=r.arcData;if(!n)continue;let i;i=f?f(se(r,"nodeStyle")).fill||b.get(r.id)||v[t%v.length]:b.get(r.id)||v[t%v.length];const a=f?f(se(r,"nodeStyle")):{},s={fill:i,stroke:a.stroke||"black",strokeWidth:null!==(o=a.strokeWidth)&&void 0!==o?o:1,opacity:a.opacity};k.push({type:"arc",cx:y,cy:g,innerR:h,outerR:d,startAngle:n.startAngle-Math.PI/2,endAngle:n.endAngle-Math.PI/2,style:s,datum:r,id:r.id,label:r.id})}for(const e of t){const t=e.chordData;if(!t)continue;const n=x(t);if(!n)continue;const o=pe(n,y,g);let s=(null===(i=r.themeSemantic)||void 0===i?void 0:i.border)||(null===(a=r.themeSemantic)||void 0===a?void 0:a.secondary)||"#999";if(p)s=p(se(e,"edgeStyle")).fill||s;else{const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;"target"===m&&r?s=b.get(r.id)||s:t&&(s=b.get(t.id)||s)}const l=p?p(se(e,"edgeStyle")):{},d={fill:s,fillOpacity:null!==(c=l.fillOpacity)&&void 0!==c?c:u,stroke:l.stroke||"none",strokeWidth:l.strokeWidth,opacity:l.opacity};A.push({type:"ribbon",pathD:o,style:d,datum:e})}if(!1!==r.showLabels){const t=(j=r.nodeLabel)?"function"==typeof j?j:e=>e[j]||e.id:null,n=d+12;for(const r of e){const e=r.arcData;if(!e)continue;const o=t?t(r):r.id;if(!o)continue;const i=(e.startAngle+e.endAngle)/2,a=i-Math.PI/2;w.push({x:y+Math.cos(a)*n,y:g+Math.sin(a)*n,text:o+"",anchor:i>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var j;return{sceneNodes:k,sceneEdges:A,labels:w}}};function pe(e,t,r){const n=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!n)return e;const o=[];let i=0;for(;n.length>i;){const e=n[i];if("M"===e||"L"===e)for(o.push(e),i++;n.length>i&&!isNaN(Number(n[i]));)o.push(Number(n[i])+t+""),i++,n.length>i&&!isNaN(Number(n[i]))&&(o.push(Number(n[i])+r+""),i++);else if("C"===e)for(o.push(e),i++;n.length>i&&!isNaN(Number(n[i]));)for(let e=0;3>e&&n.length>i&&!isNaN(Number(n[i]));e++)o.push(Number(n[i])+t+""),i++,n.length>i&&!isNaN(Number(n[i]))&&(o.push(Number(n[i])+r+""),i++);else if("Q"===e)for(o.push(e),i++;n.length>i&&!isNaN(Number(n[i]));)for(let e=0;2>e&&n.length>i&&!isNaN(Number(n[i]));e++)o.push(Number(n[i])+t+""),i++,n.length>i&&!isNaN(Number(n[i]))&&(o.push(Number(n[i])+r+""),i++);else if("A"===e)for(o.push(e),i++;n.length>i&&!isNaN(Number(n[i]));)o.push(n[i++]),n.length>i&&o.push(n[i++]),n.length>i&&o.push(n[i++]),n.length>i&&o.push(n[i++]),n.length>i&&o.push(n[i++]),n.length>i&&(o.push(Number(n[i])+t+""),i++),n.length>i&&(o.push(Number(n[i])+r+""),i++);else"Z"===e||"z"===e?(o.push(e),i++):(o.push(n[i]),i++)}return o.join(" ")}const me=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function ve(e){const[t,r,n]=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*r+.114*n>150?"#222":"#fff"}function be(e,t,r){const n=t.nodeIDAccessor;return"function"==typeof n?n(e.data)+"":"string"==typeof n&&void 0!==e.data[n]?e.data[n]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+r}function xe(e){return e?"function"==typeof e?e:t=>{var r;return(null===(r=t.data)||void 0===r?void 0:r[e])||t[e]||t.id}:null}function ke(e){return Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical:me}function Ae(e){var t;return Array.isArray(e.colorScheme)&&e.colorScheme.length>0?e.colorScheme[0]:(null===(t=e.themeSemantic)||void 0===t?void 0:t.primary)?e.themeSemantic.primary:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical[0]:"#4d430c"}function we(e,t,r,n,o){if("horizontal"===o){const o=(e+r)/2;return`M ${e},${t} C ${o},${t} ${o},${n} ${r},${n}`}if("radial"===o){const o=(e+r)/2;return`M ${e},${t} Q ${o},${t} ${o},${(t+n)/2} T ${r},${n}`}{const o=(t+n)/2;return`M ${e},${t} C ${e},${o} ${r},${o} ${r},${n}`}}const je={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,r,n){var o;const i=r.__hierarchyRoot;if(!i)return;const a=r.chartType,s=function(e){if(e)return"function"==typeof e?e:t=>t[e]}(r.childrenAccessor),c=r.hierarchySum,u="function"==typeof c?c:"string"==typeof c?e=>{var t;return null!==(t=e[c])&&void 0!==t?t:0}:e=>{var t;return null!==(t=e.value)&&void 0!==t?t:0},d=l.hierarchy(i,s);d.sum(u),d.sort((e,t)=>{var r,n;return(null!==(r=t.value)&&void 0!==r?r:0)-(null!==(n=e.value)&&void 0!==n?n:0)});const[h,y]=n;switch(a){case"tree":!function(e,t,r,n){const o=t.treeOrientation||"vertical",i=l.tree();i.size("horizontal"===o?[n,r]:"radial"===o?[2*Math.PI,Math.min(r,n)/2*.8]:[r,n]),i(e)}(d,r,h,y);break;case"cluster":!function(e,t,r,n){const o=t.treeOrientation||"vertical",i=l.cluster();i.size("horizontal"===o?[n,r]:"radial"===o?[2*Math.PI,Math.min(r,n)/2*.8]:[r,n]),i(e)}(d,r,h,y);break;case"treemap":!function(e,t,r,n){var o,i;const a=null!==(o=t.padding)&&void 0!==o?o:4,s=null!==(i=t.paddingTop)&&void 0!==i?i:0,c=l.treemap().size([r,n]).tile(l.treemapBinary).padding(a);s>0&&c.paddingTop(s),c(e)}(d,r,h,y);break;case"circlepack":!function(e,t,r,n){var o;const i=null!==(o=t.padding)&&void 0!==o?o:4;l.pack().size([r,n]).padding(i)(e)}(d,r,h,y);break;case"partition":!function(e,t,r,n){var o;l.partition().size([r,n]).padding(null!==(o=t.padding)&&void 0!==o?o:1)(e)}(d,r,h,y)}const g=d.descendants();e.length=0,t.length=0;const f=new Map;for(let t=0;g.length>t;t++){const n=g[t],i={id:be(n,r,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(o=n.value)&&void 0!==o?o:0,depth:n.depth,data:n.data,createdByFrame:!0};"tree"===a||"cluster"===a?Se(i,n,r):"treemap"===a||"partition"===a?Oe(i,n):"circlepack"===a&&Le(i,n),i.__hierarchyNode=n,e.push(i),f.set(n,i)}if("tree"===a||"cluster"===a)for(const e of g)if(e.parent){const r=f.get(e.parent),n=f.get(e);r&&n&&t.push({source:r,target:n,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,r,n){const o=r.nodeStyle||(()=>({})),i=r.edgeStyle||(()=>({}));switch(r.chartType){case"tree":case"cluster":return function(e,t,r,n,o,i){var a,s,c,l,u,d,h,y;const g=[],f=[],p=[],m=r.treeOrientation||"vertical",v="radial"===m,b=n[0]/2,x=n[1]/2,k="number"==typeof(A=r.nodeSize)?A:5;var A;for(const t of e){let e=t.x,n=t.y;v&&(e+=b,n+=x);const i=o(se(t,"nodeStyle"));let c=i.fill||Ae(r);if(r.colorByDepth&&void 0!==t.depth){const e=ke(r);c=e[t.depth%e.length]}const l={fill:c,stroke:i.stroke||(null===(a=r.themeSemantic)||void 0===a?void 0:a.surface)||"#fff",strokeWidth:null!==(s=i.strokeWidth)&&void 0!==s?s:1,opacity:i.opacity};g.push({type:"circle",cx:e,cy:n,r:k,style:l,datum:t,id:t.id,label:t.id,depth:t.depth})}const w=null!==(c=r.edgeOpacity)&&void 0!==c?c:.5;for(const e of t){const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;if(!t||!n)continue;let o=t.x,a=t.y,s=n.x,c=n.y;v&&(o+=b,a+=x,s+=b,c+=x);const y=we(o,a,s,c,m),g=i(se(e,"edgeStyle")),p={fill:"none",stroke:g.stroke||(null===(l=r.themeSemantic)||void 0===l?void 0:l.border)||(null===(u=r.themeSemantic)||void 0===u?void 0:u.secondary)||"#999",strokeWidth:null!==(d=g.strokeWidth)&&void 0!==d?d:1.5,opacity:null!==(h=g.opacity)&&void 0!==h?h:w};f.push({type:"curved",pathD:y,style:p,datum:e})}if(!1!==r.showLabels){const t=xe(r.nodeLabel);for(const r of e){const e=t?t(r):r.id;if(!e)continue;let n,o,i,a=r.x,s=r.y;if(v&&(a+=b,s+=x),v){const e=a-b,t=s-x,r=Math.sqrt(e*e+t*t);r>0?(n=a+e/r*10,o=s+t/r*10,i=0>e?"end":"start"):(n=a,o=s-12,i="middle")}else"horizontal"===m?((null===(y=r.data)||void 0===y?void 0:y.children)&&0!==r.data.children.length?(n=a-k-6,i="end"):(n=a+k+6,i="start"),o=s):(n=a,o=s+k+14,i="middle");p.push({x:n,y:o,text:e+"",anchor:i,baseline:"middle",fontSize:11})}}return{sceneNodes:g,sceneEdges:f,labels:p}}(e,t,r,n,o,i);case"treemap":case"partition":return function(e,t,r,n){var o,i,a,s,c;const l=[],u=[];for(const r of e){const e=r.x1-r.x0,a=r.y1-r.y0;if(0>=e||0>=a)continue;const s=n(se(r,"nodeStyle"));let c=s.fill||Ae(t);if(t.colorByDepth&&void 0!==r.depth){const e=ke(t);c=e[r.depth%e.length]}const u={fill:c,stroke:s.stroke||(null===(o=t.themeSemantic)||void 0===o?void 0:o.surface)||"#fff",strokeWidth:null!==(i=s.strokeWidth)&&void 0!==i?i:1,opacity:s.opacity};l.push({type:"rect",x:r.x0,y:r.y0,w:e,h:a,style:u,datum:r,id:r.id,label:r.id,depth:r.depth})}if(!1!==t.showLabels){const r=xe(t.nodeLabel),o=t.labelMode||"leaf",i="partition"===t.chartType;for(const l of e){const e=l.x1-l.x0,d=l.y1-l.y0;if(0>=e||0>=d)continue;const h=!((null===(a=l.data)||void 0===a?void 0:a.children)&&l.data.children.length>0);if(!i){if("leaf"===o&&!h)continue;if("parent"===o&&h)continue}const y=r?r(l):l.id;if(!y)continue;if((h?30:40)>e||(h?16:14)>d)continue;let g=n(se(l,"nodeStyle")).fill||Ae(t);if(t.colorByDepth&&void 0!==l.depth){const e=ke(t);g=e[l.depth%e.length]}const f="string"==typeof g?ve(g):null!==(c=null===(s=t.themeSemantic)||void 0===s?void 0:s.text)&&void 0!==c?c:"#000";u.push(h?{x:l.x0+e/2,y:l.y0+d/2,text:y+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,d)/6)),fill:f}:{x:l.x0+4,y:l.y0+12,text:y+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:f})}}return{sceneNodes:l,sceneEdges:[],labels:u}}(e,r,0,o);case"circlepack":return function(e,t,r,n){var o,i,a,s,c,l,u,d,h,y;const g=[],f=[];for(const r of e){const e=null!==(o=r.__radius)&&void 0!==o?o:5;if(0>=e)continue;const c=n(se(r,"nodeStyle"));let l=c.fill||Ae(t);if(t.colorByDepth&&void 0!==r.depth){const e=ke(t);l=e[r.depth%e.length]}const u={fill:l,stroke:c.stroke||(null===(i=t.themeSemantic)||void 0===i?void 0:i.surface)||"#fff",strokeWidth:null!==(a=c.strokeWidth)&&void 0!==a?a:1,opacity:null!==(s=c.opacity)&&void 0!==s?s:.7};g.push({type:"circle",cx:r.x,cy:r.y,r:e,style:u,datum:r,id:r.id,label:r.id,depth:r.depth})}if(!1!==t.showLabels){const r=xe(t.nodeLabel);for(const o of e){const e=null!==(c=o.__radius)&&void 0!==c?c:5,i=r?r(o):o.id;if(!i)continue;if(15>e)continue;const a=!((null===(l=o.data)||void 0===l?void 0:l.children)&&o.data.children.length>0);let s=n(se(o,"nodeStyle")).fill||Ae(t);if(t.colorByDepth&&void 0!==o.depth){const e=ke(t);s=e[o.depth%e.length]}if(a){const r="string"==typeof s?ve(s):null!==(d=null===(u=t.themeSemantic)||void 0===u?void 0:u.text)&&void 0!==d?d:"#000";f.push({x:o.x,y:o.y,text:i+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,e/3)),fill:r})}else f.push({x:o.x,y:o.y-e+14,text:i+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:(null===(h=t.themeSemantic)||void 0===h?void 0:h.text)||"#000",stroke:(null===(y=t.themeSemantic)||void 0===y?void 0:y.surface)||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:g,sceneEdges:[],labels:f}}(e,r,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Se(e,t,r){const n=r.treeOrientation||"vertical";if("radial"===n){const r=t.x,n=t.y;e.x=n*Math.cos(r-Math.PI/2),e.y=n*Math.sin(r-Math.PI/2)}else"horizontal"===n?(e.x=t.y,e.y=t.x):(e.x=t.x,e.y=t.y);e.x0=e.x-5,e.x1=e.x+5,e.y0=e.y-5,e.y1=e.y+5,e.width=10,e.height=10}function Oe(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 Le(e,t){var r;const n=null!==(r=t.r)&&void 0!==r?r:0;e.x=t.x,e.y=t.y,e.x0=t.x-n,e.x1=t.x+n,e.y0=t.y-n,e.y1=t.y+n,e.width=2*n,e.height=2*n,e.__radius=n}function Ce(e){const t=e;return t.__orbitState||(t.__orbitState={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()}),t.__orbitState}const Me={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,r,n){const o=r.__hierarchyRoot;o&&function(e,t,r,n,o){var i,a;const s=function(e){if("function"==typeof e)return e;const t=e||"children";return e=>e[t]||null}(r.childrenAccessor),l=function(e){if("function"==typeof e)return e;const t=e||"name";return e=>{var r;return(null!==(r=e[t])&&void 0!==r?r:"")+""}}(r.nodeIDAccessor),u=function(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(r.orbitMode),d=null!==(i=r.orbitSize)&&void 0!==i?i:2.95,h=null!==(a=r.orbitEccentricity)&&void 0!==a?a:1,y="number"==typeof d?()=>d:d,g="number"==typeof h?()=>h:h,f=Ce(r);f.metaMap.clear(),n.length=0,o.length=0;const p=new Map;function m(e){var t;const r=null!==(t=p.get(e))&&void 0!==t?t:0;return p.set(e,r+1),0===r?e:`${e}__${r}`}const v=t[0]/2,b=t[1]/2,x=Math.min(t[0],t[1])/2*.85,k=m(l(e));n.push({id:k,x:v,y:b,x0:v,x1:v,y0:b,y1:b,width:0,height:0,value:0,depth:0,data:e}),f.metaMap.set(k,{ring:x,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,r,i,a,d,h,p){const v=s(t);if(!(null==v?void 0:v.length))return;const b=v.length;let x=0,k=0,A=0;for(;b>k;)k+=u[Math.min(A,u.length-1)],A++,x++;let w=0;for(let b=0;x>b;b++){const k=u[Math.min(b,u.length-1)],A=v.slice(w,w+k);if(!A.length)break;const j=(b+1)/x,S={id:r,depth:h,data:t,parentId:r},O=p?d/y(S)*j:d*j,L=c.pie().value(e=>{var t;return(null===(t=s(e))||void 0===t?void 0:t.length)?4:1}).sort(null),C=L(A),M=g(S);for(let t=0;A.length>t;t++){const s=(C[t].startAngle+C[t].endAngle)/2,c=A[t],u=m(l(c)),d=i+O*Math.sin(s),y=a+O*Math.cos(s)*M;n.push({id:u,x:d,y:y,x0:d,x1:d,y0:y,y1:y,width:0,height:0,value:0,depth:h,data:c}),f.metaMap.set(u,{ring:O,angle:s,depth:h,parentId:r,eccentricity:M}),o.push({source:r,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:r,target:u}}),e(c,u,d,y,O,h+1,!0)}w+=k}}(e,k,v,b,x,1,!1)}(o,n,r,e,t)},buildScene(e,t,r,n){var o,i,a,s,c,l,u;const d=r.nodeStyle,h=r.nodeSize,y="number"==typeof h?()=>h:"function"==typeof h?h:()=>6,g=[],f=[],p=[];if(!1!==r.orbitShowRings){const t=Ce(r),n=new Map;for(const t of e)n.set(t.id,t);const o=new Map;for(const[,e]of t.metaMap){if(!e.parentId)continue;const t=n.get(e.parentId);if(!t)continue;const r=`${e.parentId}:${e.ring}`;o.has(r)||o.set(r,{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:r,ecc:n}]of o)for(let o=0;i>o;o++){const s=o/i*Math.PI*2,c=(o+1)/i*Math.PI*2;f.push({type:"line",x1:e+r*Math.sin(s),y1:t+r*Math.cos(s)*n,x2:e+r*Math.sin(c),y2:t+r*Math.cos(c)*n,style:a,datum:null})}}for(const t of e){if(null==t.x||null==t.y)continue;const e=y(se(t,"nodeSize")),n=d?d(se(t,"nodeStyle")):{},l={fill:n.fill||(null===(o=r.themeSemantic)||void 0===o?void 0:o.primary)||"#6366f1",stroke:n.stroke||(null===(i=r.themeSemantic)||void 0===i?void 0:i.surface)||"#fff",strokeWidth:null!==(a=n.strokeWidth)&&void 0!==a?a:1,opacity:null!==(s=n.opacity)&&void 0!==s?s:0===(null!==(c=t.depth)&&void 0!==c?c:0)?1:.85};g.push({type:"circle",cx:t.x,cy:t.y,r:e,style:l,datum:t,id:t.id,label:t.id,depth:t.depth})}const m=new Map;for(const t of e)m.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:m.get(e.source),r="object"==typeof e.target?e.target:m.get(e.target);t&&r&&(null!=t.x&&null!=r.x&&f.push({type:"line",x1:t.x,y1:t.y,x2:r.x,y2:r.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:e}))}if(r.showLabels){const t=r.nodeLabel;for(const r of e){const e=y(se(r,"nodeSize"));if(4>=e)continue;const n="function"==typeof t?t(r):t&&null!==(u=null===(l=r.data)||void 0===l?void 0:l[t])&&void 0!==u?u:r.id;p.push({x:r.x,y:r.y+e+12,text:n+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:g,sceneEdges:f,labels:p}},tick:(e,t,r,n,o)=>!1!==r.orbitAnimated&&(function(e,t){var r,n;const o=Ce(t),i=null!==(r=t.orbitSpeed)&&void 0!==r?r:.25,a=null!==(n=t.orbitRevolution)&&void 0!==n?n:function(e){switch(e){case"decay":return e=>{var t;return Math.pow(.6,null!==(t=e.depth)&&void 0!==t?t:0)};case"alternate":return e=>{var t;const r=null!==(t=e.depth)&&void 0!==t?t:0;return(r%2==0?1:-1)/(r+1)};default:return e=>{var t;return 1/((null!==(t=e.depth)&&void 0!==t?t:0)+1)}}}(t.orbitRevolutionStyle),s=(("undefined"!=typeof performance?performance.now():Date.now())-o.startTime)/1e3,c=i*(Math.PI/6),l=new Map;for(const t of e)l.set(t.id,t);for(const t of e){const e=o.metaMap.get(t.id);if(!e||!e.parentId)continue;const r=l.get(e.parentId);if(!r)continue;const n=e.angle+s*c*a({id:t.id,depth:e.depth,data:t.data,parentId:e.parentId});t.x=r.x+e.ring*Math.sin(n),t.y=r.y+e.ring*Math.cos(n)*e.eccentricity,t.x0=t.x,t.x1=t.x,t.y0=t.y,t.y1=t.y}}(e,r),!0)},De={sankey:le,force:ue,chord:fe,tree:je,cluster:je,treemap:je,circlepack:je,partition:je,orbit:Me};function Ee(e){return De[e]}function Pe(e,t,r){return e+(t-e)*r}function Ie(e,t,r){var n,o,i;if(1>=r)return 1;const a=null!==(n=e.minOpacity)&&void 0!==n?n:.1,s=r-1-t;switch(e.type){case"linear":return a+(1-s/(r-1))*(1-a);case"exponential":{const t=null!==(o=e.halfLife)&&void 0!==o?o:r/2;return a+Math.pow(.5,s/t)*(1-a)}case"step":return(null!==(i=e.stepThreshold)&&void 0!==i?i:.5*r)>s?1:a;default:return 1}}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.particlePool=null,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.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._lastPositionSnapshot=null,this.config=e,this.tensionConfig=Object.assign(Object.assign({},y),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&(this.particlePool=new f(2e3))}updateConfig(e){const t=this.config;t.__orbitState&&(e.__orbitState=t.__orbitState),t.__hierarchyRoot&&(e.__hierarchyRoot=t.__hierarchyRoot),this.config=e,this.tensionConfig=Object.assign(Object.assign({},y),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&!this.particlePool&&(this.particlePool=new f(2e3))}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.config.__hierarchyRoot=e,this.runLayout(t),this._boundedPrevSnapshot=null}ingestBounded(e,t,r){const{nodeIDAccessor:n="id",sourceAccessor:o="source",targetAccessor:i="target",valueAccessor:a="value"}=this.config,s="function"==typeof n?n:e=>e[n],c="function"==typeof o?o:e=>e[o],l="function"==typeof i?i:e=>e[i],u="function"==typeof a?a:e=>{var t;return null!==(t=e[a])&&void 0!==t?t: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;for(const t of e){const e=s(t)+"";this.nodes.set(e,Object.assign(Object.assign({},Te(e)),{data:t}))}for(let e=0;t.length>e;e++){const r=t[e],n=c(r)+"",o=l(r)+"",i=Number(u(r))||1;this.nodes.has(n)||this.nodes.set(n,Object.assign(Object.assign({},Te(n)),{data:r})),this.nodes.has(o)||this.nodes.set(o,Object.assign(Object.assign({},Te(o)),{data:r}));const a=`${n}\0${o}\0${e}`;this.edges.set(a,{source:n,target:o,value:i,y0:0,y1:0,sankeyWidth:0,data:r,_edgeKey:a})}this.runLayout(r)}edgeKey(e,t){return`${e}\0${t}`}ingestEdge(e){const{source:t,target:r,value:n}=e,o=0===this.nodes.size;let i=!1;const a="undefined"!=typeof performance?performance.now():Date.now();this.lastIngestTime=a,this._decaySortedNodes=null,this.nodes.has(t)||(this.nodes.set(t,Te(t)),this.nodeTimestamps.set(t,a),this.tension+=this.tensionConfig.newNode,i=!0),this.nodes.has(r)||(this.nodes.set(r,Te(r)),this.nodeTimestamps.set(r,a),this.tension+=this.tensionConfig.newNode,i=!0);const s=this.edgeKey(t,r),c=this.edges.get(s);let l=!1;return c?(c.value+=n,this.edgeTimestamps.set(s,a),this.tension+=this.tensionConfig.weightChange,l=!0):(this.edges.set(s,{source:t,target:r,value:n,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(s,a),this.tension+=this.tensionConfig.newEdge,i=!0),o||i||l||this.tension>=this.tensionConfig.threshold}runLayout(e){var t,r,n,o,i,a,s,c;const l=Ee(this.config.chartType);if(!l)return;let u=Array.from(this.nodes.values());const d=Array.from(this.edges.values());if(0===u.length&&!l.hierarchical)return;if(this.prepareForRelayout(),l.supportsStreaming&&!l.hierarchical){const e=new Map;for(const s of u)if(void 0!==s._prevX0){const c=(null!==(t=s._prevX1)&&void 0!==t?t:0)-(null!==(r=s._prevX0)&&void 0!==r?r:0),l=(null!==(n=s._prevY1)&&void 0!==n?n:0)-(null!==(o=s._prevY0)&&void 0!==o?o:0);e.set(s.id,{x:(null!==(i=s._prevX0)&&void 0!==i?i:0)+c/2,y:(null!==(a=s._prevY0)&&void 0!==a?a:0)+l/2})}else 0===s.x&&0===s.y||e.set(s.id,{x:s.x,y:s.y});if(this._lastPositionSnapshot)for(const[t,r]of this._lastPositionSnapshot)e.has(t)||e.set(t,r);this.config.__previousPositions=e.size>0?e:void 0}if(l.computeLayout(u,d,this.config,e),this.config.__previousPositions=void 0,l.hierarchical&&u.length>0){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const e of u)this.nodes.set(e.id,e);for(let e=0;d.length>e;e++){const t=d[e],r=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=r,this.edges.set(r,t)}const e=this._boundedPrevSnapshot;if(e&&e.size>0)for(const t of this.nodes.values()){const r=e.get(t.id);r&&(t._prevX0=r.x0,t._prevX1=r.x1,t._prevY0=r.y0,t._prevY1=r.y1)}this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,u=Array.from(this.nodes.values())}this.finalizeLayout();const h=new Map;for(const e of this.nodes.values())0===e.x&&0===e.y||h.set(e.id,{x:e.x,y:e.y});this._lastPositionSnapshot=h,this.saveTargetPositions();const y=u.some(e=>void 0!==e._prevX0&&(0!==e._prevX0||0!==e._prevX1||0!==e._prevY0||0!==e._prevY1)),g=null!==(c=null===(s=this.config.transition)||void 0===s?void 0:s.duration)&&void 0!==c?c:this.tensionConfig.transitionDuration;if(!this._hasRenderedOnce&&this.config.introAnimation&&["sankey","tree","treemap","circlepack","partition"].includes(this.config.chartType)&&u.length>0&&g>0){const t=e[0]/2,r=e[1]/2;for(const e of this.nodes.values())e._prevX0=t,e._prevX1=t,e._prevY0=r,e._prevY1=r;for(const e of this.edges.values())e._prevY0=r,e._prevY1=r,e._prevSankeyWidth=0,e._introFromZero=!0;this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:g}}else y&&g>0&&(this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:g});this._hasRenderedOnce=!0;const f=new Set(this.nodes.keys()),p=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const e of f)this.previousNodeIds.has(e)||this.addedNodes.add(e);for(const e of this.previousNodeIds)f.has(e)||this.removedNodes.add(e);for(const e of p)this.previousEdgeKeys.has(e)||this.addedEdges.add(e);for(const e of this.previousEdgeKeys)p.has(e)||this.removedEdges.add(e);(this.addedNodes.size>0||this.removedNodes.size>0||this.addedEdges.size>0||this.removedEdges.size>0)&&(this.lastTopologyChangeTime="undefined"!=typeof performance?performance.now():Date.now()),this.previousNodeIds=f,this.previousEdgeKeys=p,this.layoutVersion++}buildScene(e){const t=Ee(this.config.chartType);if(!t)return;const r=Array.from(this.nodes.values()),n=Array.from(this.edges.values()),{sceneNodes:o,sceneEdges:i,labels:a}=t.buildScene(r,n,this.config,e);this.sceneNodes=o,this.sceneEdges=i,this.labels=a}get isAnimating(){const e=Ee(this.config.chartType);return!!(null==e?void 0:e.supportsAnimation)&&!1!==this.config.orbitAnimated}tickAnimation(e,t){const r=Ee(this.config.chartType);if(!(null==r?void 0:r.tick))return!1;const n=Array.from(this.nodes.values()),o=Array.from(this.edges.values());return r.tick(n,o,this.config,e,t)}advanceTransition(e){if(!this.transition)return!1;const t=function(e,t){return Math.min((e-t.startTime)/t.duration,1)}(e,this.transition),r=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=Pe(e._prevX0,e._targetX0,r),e.x1=Pe(e._prevX1,e._targetX1,r),e.y0=Pe(e._prevY0,e._targetY0,r),e.y1=Pe(e._prevY1,e._targetY1,r));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=Pe(e._prevY0,e._targetY0,r),e.y1=Pe(e._prevY1,e._targetY1,r),e.sankeyWidth=Pe(e._prevSankeyWidth,e._targetSankeyWidth,r));return this.rebuildAllBeziers(),1>t||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){const e=this._boundedPrevSnapshot;for(const t of this.nodes.values()){const r=null==e?void 0:e.get(t.id);r&&0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1?(t._prevX0=r.x0,t._prevX1=r.x1,t._prevY0=r.y0,t._prevY1=r.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 r=t.get(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`);if(r){e._prevY0=r.y0,e._prevY1=r.y1,e._prevSankeyWidth=r.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){const t="string"==typeof e.source?this.nodes.get(e.source):e.source,r="string"==typeof e.target?this.nodes.get(e.target):e.target;t&&r&&(e.bezier=e.circular&&e.circularPathData?this.buildCircularBezier(e):this.buildStandardBezier(e,t,r))}buildStandardBezier(e,t,n){const o=(e.sankeyWidth||1)/2;if("down"===e.direction){const i=t.x1,a=n.x0,s=r.interpolateNumber(i,a);return{circular:!1,points:[{x:e.y0,y:i},{x:e.y0,y:s(.5)},{x:e.y1,y:s(.5)},{x:e.y1,y:a}],halfWidth:o}}const i=t.x1,a=n.x0,s=r.interpolateNumber(i,a);return{circular:!1,points:[{x:i,y:e.y0},{x:s(.5),y:e.y0},{x:s(.5),y:e.y1},{x:a,y:e.y1}],halfWidth:o}}buildCircularBezier(e){const t=(e._circularWidth||e.sankeyWidth||1)/2,r=e.circularPathData;if(e._circularStub){const e=Math.max(15,Math.min(40,.33*(r.rightFullExtent-r.sourceX))),n=Math.max(15,Math.min(40,.33*(r.targetX-r.leftFullExtent)));return{circular:!0,segments:[[{x:r.sourceX,y:r.sourceY},{x:r.sourceX+.33*e,y:r.sourceY},{x:r.sourceX+.66*e,y:r.sourceY},{x:r.sourceX+e,y:r.sourceY}],[{x:r.targetX-n,y:r.targetY},{x:r.targetX-.66*n,y:r.targetY},{x:r.targetX-.33*n,y:r.targetY},{x:r.targetX,y:r.targetY}]],halfWidth:t}}let n;n="down"===e.direction?[{x:r.sourceY,y:r.sourceX},{x:r.sourceY,y:r.rightFullExtent},{x:r.verticalFullExtent,y:r.rightFullExtent},{x:r.verticalFullExtent,y:r.leftFullExtent},{x:r.targetY,y:r.leftFullExtent},{x:r.targetY,y:r.targetX}]:[{x:r.sourceX,y:r.sourceY},{x:r.rightFullExtent,y:r.sourceY},{x:r.rightFullExtent,y:r.verticalFullExtent},{x:r.leftFullExtent,y:r.verticalFullExtent},{x:r.leftFullExtent,y:r.targetY},{x:r.targetX,y:r.targetY}];const o=[];for(let e=0;n.length-1>e;e++){const t=n[e],r=n[e+1],i=r.x-t.x,a=r.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},r])}return{circular:!0,segments:o,halfWidth:t}}rebuildAllBeziers(){for(const e of this.nodes.values())e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;for(const e of this.edges.values())this.updateEdgeBezier(e)}applyPulse(e){var t,r,n,o,i;const a=this.config.pulse;if(!a)return;const s=null!==(t=a.duration)&&void 0!==t?t:500,c=null!==(r=a.color)&&void 0!==r?r:"rgba(255,255,255,0.6)",l=null!==(n=a.glowRadius)&&void 0!==n?n:4;for(const t of this.sceneNodes){const r=t.id;if(!r)continue;const n=this.nodeTimestamps.get(r);if(!n)continue;const o=e-n;s>o&&(t._pulseIntensity=1-o/s,t._pulseColor=c,t._pulseGlowRadius=l)}for(const t of this.sceneEdges){const r=t.datum;if(!r)continue;const n="object"==typeof r.source?null===(o=r.source)||void 0===o?void 0:o.id:r.source,a="object"==typeof r.target?null===(i=r.target)||void 0===i?void 0:i.id:r.target;if(!n||!a)continue;const l=this.edgeTimestamps.get(`${n}\0${a}`);if(!l)continue;const u=e-l;s>u&&(t._pulseIntensity=1-u/s,t._pulseColor=c)}}applyDecay(){var e,t;const r=this.config.decay;if(!r)return;const n=this.nodeTimestamps.size;if(1>=n)return;this._decaySortedNodes||(this._decaySortedNodes=Array.from(this.nodeTimestamps.entries()).sort((e,t)=>e[1]-t[1]));const o=this._decaySortedNodes,i=new Map;for(let e=0;o.length>e;e++)i.set(o[e][0],e);for(const o of this.sceneNodes){const a=o.id;if(!a)continue;const s=i.get(a);if(void 0===s)continue;const c=Ie(r,s,n),l=null!==(t=null===(e=o.style)||void 0===e?void 0:e.opacity)&&void 0!==t?t:1;o.style=Object.assign(Object.assign({},o.style),{opacity:l*c})}}applyTopologyDiff(e){var t;if(0===this.addedNodes.size)return;const r=e-this.lastTopologyChangeTime;if(r>=2e3)return;const n=1-r/2e3;for(const e of this.sceneNodes){const r=e.id;r&&this.addedNodes.has(r)&&(e._pulseIntensity=Math.max(null!==(t=e._pulseIntensity)&&void 0!==t?t:0,n),e._pulseColor="rgba(34, 197, 94, 0.7)",e._pulseGlowRadius=8)}}get hasActiveTopologyDiff(){return 0!==this.addedNodes.size&&2e3>("undefined"!=typeof performance?performance.now():Date.now())-this.lastTopologyChangeTime}applyThresholds(e){var t,r;const n=this.config.thresholds;if(!n)return;const o=null!==(t=n.warningColor)&&void 0!==t?t:"#f59e0b",i=null!==(r=n.criticalColor)&&void 0!==r?r:"#ef4444",a=!1!==n.pulse;for(const t of this.sceneNodes){const r=t.id;if(!r)continue;const s=this.nodes.get(r);if(!s)continue;const c=n.metric(s);let l=null;void 0===n.critical||n.critical>c?void 0===n.warning||n.warning>c||(l=o):l=i,l&&(t.style=Object.assign(Object.assign({},t.style),{fill:l}),a&&(t._pulseIntensity=.6+.4*Math.sin(e/300),t._pulseColor=l,t._pulseGlowRadius=6))}}get hasActiveThresholds(){const e=this.config.thresholds;if(!e)return!1;for(const t of this.nodes.values()){const r=e.metric(t);if(void 0!==e.warning&&r>=e.warning||void 0!==e.critical&&r>=e.critical)return!0}return!1}get hasActivePulses(){var e;const t=this.config.pulse;if(!t||0===this.lastIngestTime)return!1;const r="undefined"!=typeof performance?performance.now():Date.now();return(null!==(e=t.duration)&&void 0!==e?e:500)>r-this.lastIngestTime}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}updateNode(e,t){var r;const n=this.nodes.get(e);if(!n)return null;const o=n.data?Object.assign({},n.data):{};return n.data=t(null!==(r=n.data)&&void 0!==r?r:{}),this.layoutVersion++,o}updateEdge(e,t,r){var n;const o=this.config.valueAccessor,i="function"==typeof o?o:o?e=>e[o]:e=>e.value,a=[];for(const[,o]of this.edges)if(("string"==typeof o.source?o.source:o.source.id)===e&&("string"==typeof o.target?o.target:o.target.id)===t){a.push(o.data?Object.assign({},o.data):{}),o.data=r(null!==(n=o.data)&&void 0!==n?n:{});const e=i(o.data);null!=e&&(o.value=Number(e))}return a.length>0&&this.layoutVersion++,a}removeNode(e){if(!this.nodes.has(e))return!1;this.nodes.delete(e),this.nodeTimestamps.delete(e);for(const[t,r]of this.edges)("string"==typeof r.source?r.source:r.source.id)!==e&&("string"==typeof r.target?r.target:r.target.id)!==e||(this.edges.delete(t),this.edgeTimestamps.delete(t));return this.layoutVersion++,!0}removeEdge(e,t){const r=[];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 n="function"==typeof t?t:e=>null==e?void 0:e[t];for(const[t,o]of this.edges)o.data&&n(o.data)===e&&r.push(t)}else for(const[n,o]of this.edges)("string"==typeof o.source?o.source:o.source.id)===e&&("string"==typeof o.target?o.target:o.target.id)===t&&r.push(n);for(const e of r)this.edges.delete(e),this.edgeTimestamps.delete(e);return r.length>0&&this.layoutVersion++,r.length>0}clear(){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.transition=null,this._hasRenderedOnce=!1,this.lastIngestTime=0,this._lastPositionSnapshot=null,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.particlePool&&this.particlePool.clear()}}function Te(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 Ne(e){let t=e%(2*Math.PI);return 0>t&&(t+=2*Math.PI),t}function Re(e,t,r,n,o=30){let i=null,a=o,s=1/0;for(const t of e){const e=We(t,r,n,o);if(e)if("rect"===t.type){const r=t.w*t.h;s>r&&(i=e,s=r)}else a>e.distance&&(i=e,a=e.distance)}if(i)return i;for(const e of t){const t=Fe(e,r,n);t&&a>t.distance&&(i=t,a=t.distance)}return i}function We(e,t,r,n=30){switch(e.type){case"circle":return function(e,t,r,n=30){const o=t-e.cx,i=r-e.cy,a=Math.sqrt(o*o+i*i),s=function(e,t=30){return Math.max((null!=e?e:4)+5,12,t)}(e.r,n);return a>s?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:a}}(e,t,r,n);case"rect":return function(e,t,r){const n=function(e,t,r){return r.x>e||e>r.x+r.w||r.y>t||t>r.y+r.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:r.x+r.w/2,cy:r.y+r.h/2}}(t,r,e);return n.hit?{type:"node",datum:e.datum,x:n.cx,y:n.cy,distance:0}:null}(e,t,r);case"arc":return function(e,t,r){const n=t-e.cx,o=r-e.cy,i=Math.sqrt(n*n+o*o);if(e.innerR-2>i||i>e.outerR+2)return null;const a=Ne(Math.atan2(o,n)),s=Ne(e.startAngle),c=Ne(e.endAngle);if(s>c?a>=s||c>=a:a>=s&&c>=a){const t=(e.startAngle+e.endAngle)/2,r=(e.innerR+e.outerR)/2;return{type:"node",datum:e.datum,x:e.cx+r*Math.cos(t),y:e.cy+r*Math.sin(t),distance:0}}return null}(e,t,r);default:return null}}let $e=null,Be=null;function ze(){return Be||($e=document.createElement("canvas"),$e.width=1,$e.height=1,Be=$e.getContext("2d")),Be}function He(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(e){return null}}function Fe(e,t,r){switch(e.type){case"bezier":return function(e,t,r){var n,o;if(!e.pathD)return null;const i=He(e),a=ze();if(!i||!a)return null;try{if(a.isPointInPath(i,t,r)){const i="object"==typeof(null===(n=e.datum)||void 0===n?void 0:n.source)?e.datum.source:null,a="object"==typeof(null===(o=e.datum)||void 0===o?void 0:o.target)?e.datum.target:null;return{type:"edge",datum:e.datum,x:i&&a?(i.x1+a.x0)/2:t,y:e.datum?(e.datum.y0+e.datum.y1)/2:r,distance:0}}const s=a.lineWidth;a.lineWidth=10;const c=a.isPointInStroke(i,t,r);if(a.lineWidth=s,c)return{type:"edge",datum:e.datum,x:t,y:r,distance:4}}catch(e){}return null}(e,t,r);case"line":return function(e,t,r){const n=e.x2-e.x1,o=e.y2-e.y1,i=n*n+o*o;if(0===i)return null;let a=((t-e.x1)*n+(r-e.y1)*o)/i;a=Math.max(0,Math.min(1,a));const s=e.x1+a*n,c=e.y1+a*o,l=Math.sqrt(Math.pow(t-s,2)+Math.pow(r-c,2));return l>5?null:{type:"edge",datum:e.datum,x:s,y:c,distance:l}}(e,t,r);case"ribbon":case"curved":return function(e,t,r){if(!e.pathD)return null;const n=He(e),o=ze();if(!n||!o)return null;try{if(o.isPointInPath(n,t,r))return{type:"edge",datum:e.datum,x:t,y:r,distance:0};const i=o.lineWidth;o.lineWidth=10;const a=o.isPointInStroke(n,t,r);if(o.lineWidth=i,a)return{type:"edge",datum:e.datum,x:t,y:r,distance:4}}catch(e){}return null}(e,t,r);default:return null}}function Ye(e,t,r){const{group:n,indexInGroup:o}=t,i=r.byGroup.get(n);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=r.groups.indexOf(n);return r.groups.length-1>e?qe(r,r.groups[e+1],i[o]):t.flatIndex}case"ArrowUp":{const e=r.groups.indexOf(n);return e>0?qe(r,r.groups[e-1],i[o]):t.flatIndex}case"PageDown":return Math.min(t.flatIndex+Math.max(1,Math.floor(.1*r.flat.length)),r.flat.length-1);case"PageUp":return Math.max(t.flatIndex-Math.max(1,Math.floor(.1*r.flat.length)),0);case"Home":return 0;case"End":return r.flat.length-1;case"Escape":return-1;default:return null}}function qe(e,t,r){const n=e.byGroup.get(t);let o=0,i=Math.abs(n[0].x-r.x);for(let e=1;n.length>e;e++){const t=Math.abs(n[e].x-r.x);i>t&&(i=t,o=e)}return n[o]._flatIndex}const Ge="var(--semiotic-focus, #005fcc)";function Xe({active:t,hoverPoint:r,margin:n,size:o,shape:i="circle",width:a,height:s}){if(!t||!r)return null;const c=r.x+n.left,l=r.y+n.top;let u;if("rect"===i&&null!=a&&null!=s){const t=Math.max(a,4),r=Math.max(s,4);u=e.jsx("rect",{x:c-t/2-3,y:l-r/2-3,width:t+6,height:r+6,rx:3,fill:"none",stroke:Ge,strokeWidth:2,strokeDasharray:"4,2"})}else u=e.jsx("circle","wedge"===i?{cx:c,cy:l,r:12,fill:"none",stroke:Ge,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:c,cy:l,r:8,fill:"none",stroke:Ge,strokeWidth:2,strokeDasharray:"4,2"});return e.jsx("svg",{style:{position:"absolute",left:0,top:0,width:o[0],height:o[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true",children:u})}function Ve({x:t,y:r,containerWidth:n,containerHeight:o,margin:i,children:a,className:s="stream-frame-tooltip",zIndex:c=1}){const l=d.useRef(null),[u,h]=d.useState(null);d.useLayoutEffect(()=>{const e=l.current;if(!e)return;const t=e.getBoundingClientRect();h(e=>e&&e.width===t.width&&e.height===t.height?e:{width:t.width,height:t.height})},[a,s,n,o]);let y;return y=u?`translate(${u.width+12>n-t?"calc(-100% - 12px)":"12px"}, ${u.height+12>o-r?"calc(-100% - 4px)":"4px"})`:`translate(${t>.7*n?"calc(-100% - 12px)":"12px"}, ${.3*o>r?"4px":"calc(-100% - 4px)"})`,e.jsx("div",{ref:l,className:s,style:{position:"absolute",left:i.left+t,top:i.top+r,transform:y,pointerEvents:"none",zIndex:c,width:"max-content"},children:a})}function Ke(r){const n=t.createContext(null),o=Ue(r);return[function({children:o}){const i=t.useMemo(()=>Ue(r),[]);return e.jsx(n.Provider,{value:i,children:o})},e=>{var r;const i=null!==(r=t.useContext(n))&&void 0!==r?r:o,a=t.useRef(e);a.current=e;const s=t.useCallback(()=>a.current(i.getState()),[i]),c=t.useCallback(()=>a.current(i.getState()),[i]);return t.useSyncExternalStore(i.subscribe,s,c)}]}function Ue(e){const t=new EventTarget;let r=e(function(e){r=Object.assign(Object.assign({},r),e(r)),t.dispatchEvent(new CustomEvent("update"))});return{getState:()=>r,subscribe:function(e){return t.addEventListener("update",e),()=>t.removeEventListener("update",e)}}}function Ze(e){if(!(null==e?void 0: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 Qe(e){if(!e.accessibility)return e;let t=e;if(e.accessibility.colorBlindSafe&&(t=Object.assign(Object.assign({},t),{colors:Object.assign(Object.assign({},t.colors),{categorical:Je})})),e.accessibility.highContrast){const e="dark"===t.mode;t=Object.assign(Object.assign({},t),{colors:Object.assign(Object.assign({},t.colors),{text:e?"#ffffff":"#000000",textSecondary:e?"#cccccc":"#333333",grid:e?"#666666":"#999999",border:e?"#888888":"#000000"})})}return t}const Je=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],et={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:10}},tt={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:10}},rt={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:Je,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"},[nt,ot]=Ke(e=>({theme:et,setTheme(t){e(e=>{if("light"===t)return{theme:et};if("dark"===t)return{theme:tt};if("high-contrast"===t)return{theme:rt};if(t.mode&&"auto"!==t.mode){const e="dark"===t.mode?tt:et;return{theme:Qe(Object.assign(Object.assign(Object.assign({},e),t),{colors:Object.assign(Object.assign({},e.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.typography),t.typography||{})}))}}return{theme:Qe(Object.assign(Object.assign(Object.assign({},e.theme),t),{colors:Object.assign(Object.assign({},e.theme.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.theme.typography),t.typography||{})}))}})}}));const it=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,at=new WeakMap;let st=0,ct=!1,lt=null,ut=null,dt=null;function ht(e,t){var r,n;if(!t)return t;const o=it.exec(t);if(!o)return t;const i=e.canvas;if(!i)return(null===(r=o[2])||void 0===r?void 0:r.trim())||t;!function(){if(ct)return;if("undefined"==typeof window||"undefined"==typeof document)return;ct=!0;const e=()=>{st++};if("undefined"!=typeof MutationObserver&&document.documentElement&&(lt=new MutationObserver(e),lt.observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"]})),"function"==typeof window.matchMedia)try{ut=window.matchMedia("(prefers-color-scheme: dark)"),dt=e,"function"==typeof ut.addEventListener?ut.addEventListener("change",dt):"function"==typeof ut.addListener&&ut.addListener(dt)}catch(e){}}();let a=at.get(i);a&&a.version===st||(a={version:st,map:new Map},at.set(i,a));const s=a.map.get(t);if(void 0!==s)return s;const c=getComputedStyle(i).getPropertyValue(o[1]).trim()||(null===(n=o[2])||void 0===n?void 0:n.trim())||t;return a.map.set(t,c),c}function yt(e,t,r){return"function"==typeof e?e({size:t,margin:r}):e}function gt(e){const r=function(){const[e,r]=t.useState(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return t.useEffect(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)");return r(e.matches),function(e,t){return"function"==typeof e.addEventListener?(e.addEventListener("change",t),()=>e.removeEventListener("change",t)):(e.addListener(t),()=>e.removeListener(t))}(e,e=>r(e.matches))},[]),e}(),n=t.useRef(r);n.current=r;const[o,i]=function(e,r,n){const o=t.useRef(null),[i,a]=t.useState(null);return t.useEffect(()=>{if(!r&&!n)return;const e=o.current;if(!e)return;const t=new ResizeObserver(e=>{for(const t of e){const{width:e,height:r}=t.contentRect;a(t=>t&&t.w===e&&t.h===r?t:{w:e,h:r})}});return t.observe(e),()=>t.disconnect()},[r,n]),[o,[r&&i?i.w:e[0],n&&i?i.h:e[1]]]}(e.sizeProp,e.responsiveWidth,e.responsiveHeight),a=t.useMemo(()=>Object.assign(Object.assign({},e.marginDefault),e.userMargin),[e.marginDefault,e.userMargin]),s=i[0]-a.left-a.right,c=i[1]-a.top-a.bottom,l=yt(e.foregroundGraphics,i,a),u=yt(e.backgroundGraphics,i,a),h=ot(e=>e.theme),{transition:y,introEnabled:g}=function(e,t){var r,n;if(!1===e)return{transition:void 0,introEnabled:!1};const o="undefined"!=typeof window&&(null===(r=window.matchMedia)||void 0===r?void 0:r.call(window,"(prefers-reduced-motion: reduce)").matches);return{transition:e?!0===e?{duration:300}:{duration:null!==(n=e.duration)&&void 0!==n?n:300,easing:"linear"===e.easing?"linear":"ease-out"}:t,introEnabled:!(o||!e||!0!==e&&!1===e.intro)}}(e.animate,e.transitionProp),f="semiotic-table-"+d.useId(),p=t.useRef(0),m=t.useRef(()=>{}),v=t.useCallback(()=>{p.current||(p.current=requestAnimationFrame(()=>m.current()))},[]);t.useEffect(()=>()=>{p.current&&(cancelAnimationFrame(p.current),p.current=0)},[]);const b=t.useRef(()=>{}),x=t.useRef(()=>{}),k=t.useRef(null),A=t.useRef(0),w=t.useCallback(()=>{A.current=0;const e=k.current;k.current=null,e&&b.current(e)},[]),j=t.useCallback(e=>{k.current={clientX:e.clientX,clientY:e.clientY},0===A.current&&(A.current=requestAnimationFrame(w))},[w]),S=t.useCallback(()=>{k.current=null,0!==A.current&&(cancelAnimationFrame(A.current),A.current=0),x.current()},[]);t.useEffect(()=>()=>{k.current=null,0!==A.current&&(cancelAnimationFrame(A.current),A.current=0)},[]);const O=e.themeDirtyRef;return t.useEffect(()=>{O&&(st++,O.current=!0,v())},[h,v,O]),{reducedMotion:r,reducedMotionRef:n,responsiveRef:o,size:i,margin:a,adjustedWidth:s,adjustedHeight:c,resolvedForeground:l,resolvedBackground:u,currentTheme:h,transition:y,introEnabled:g,tableId:f,rafRef:p,renderFnRef:m,scheduleRender:v,hoverHandlerRef:b,hoverLeaveRef:x,onPointerMove:j,onPointerLeave:S}}const ft={fill:t=>e.jsx("rect",{style:t,width:16,height:16}),line:t=>e.jsx("line",{style:t,x1:0,y1:0,x2:16,y2:16})};function pt(e,t,r,n){let o;return o="function"==typeof r?r(e):(0,ft[r])(n(e,t)),o}function mt(){return e.jsx("path",{d:"M4,8.8 L7.2,12 L12.8,4.8",fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function vt(e,t,r){return r&&r.size>0?r.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}const bt=(t,r,n,o,i,a,s,c,l,u)=>{const{type:d="fill",styleFn:h,items:y}=t,g=[];let f=0;const p=!(!r&&!n),m="isolate"===u||void 0===u&&null!=i;return y.forEach((t,u)=>{const v=pt(t,u,d,h),b=vt(t,o,i),x=i&&i.size>0&&i.has(t.label);g.push(e.jsxs("g",{transform:`translate(0,${f})`,onClick:r?()=>r(t):void 0,onMouseEnter:n?()=>n(t):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:p?c===a&&u===s?0:-1:void 0,role:p?"option":void 0,"aria-selected":p&&m?x||!1:void 0,"aria-current":p&&!m&&null!=o&&t.label===o||void 0,"aria-label":t.label,onKeyDown:p?e=>{var n;if("Enter"!==e.key&&" "!==e.key||(e.preventDefault(),r&&r(t)),"ArrowDown"===e.key||"ArrowUp"===e.key){e.preventDefault();const t=(u+("ArrowDown"===e.key?1:-1)+y.length)%y.length;l(c,t);const r=null===(n=e.currentTarget.parentElement)||void 0===n?void 0:n.children[t];r instanceof SVGElement&&r.focus()}}:void 0,onFocus:p?e=>{l(c,u),n&&n(t);const r=e.currentTarget.querySelector(".semiotic-legend-focus-ring");r&&r.setAttribute("visibility","visible")}:void 0,onBlur:p?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:p?"pointer":"default",opacity:b,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[p&&e.jsx("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*t.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),v,x&&e.jsx(mt,{}),e.jsx("text",{y:8,x:22,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:t.label})]},"legend-item-"+u)),f+=22}),g};function xt({config:t,orientation:r="vertical",width:n=100}){const{colorFn:o,domain:i,label:a,format:s}=t,c=s||(e=>Math.round(100*e)/100+""),l="grad-legend-"+d.useId();if("horizontal"===r){const t=12,r=Math.min(n,200),s=Math.max(0,(n-r)/2),u=[];for(let t=0;64>=t;t++){const r=t/64;u.push(e.jsx("stop",{offset:100*r+"%",stopColor:o(i[0]+r*(i[1]-i[0]))},t))}return e.jsxs("g",{"aria-label":a||"Gradient legend",children:[e.jsx("defs",{children:e.jsx("linearGradient",{id:l,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:u})}),a&&e.jsx("text",{x:s+r/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:a}),e.jsx("rect",{x:s,y:0,width:r,height:t,fill:`url(#${l})`,rx:2}),e.jsx("text",{x:s,y:t+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:c(i[0])}),e.jsx("text",{x:s+r,y:t+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:c(i[1])})]})}const u=[];for(let t=0;64>=t;t++){const r=t/64;u.push(e.jsx("stop",{offset:100*r+"%",stopColor:o(i[1]-r*(i[1]-i[0]))},t))}return e.jsxs("g",{"aria-label":a||"Gradient legend",children:[a&&e.jsx("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:a}),e.jsx("defs",{children:e.jsx("linearGradient",{id:l,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:u})}),e.jsx("rect",{x:0,y:0,width:14,height:100,fill:`url(#${l})`,rx:2}),e.jsx("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:c(i[1])}),e.jsx("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:c(i[0])})]})}function kt(t){const{legendGroups:r,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:a,legendInteraction:s,title:c="Legend",width:l=100,height:u=20,orientation:h="vertical"}=t,[y,g]=d.useState(0),[f,p]=d.useState(0),m=d.useCallback((e,t)=>{g(e),p(t)},[]),v="vertical"===h?(({legendGroups:t,width:r,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:a,focusedGroupIndex:s,focusedItemIndex:c,onFocusedIndexChange:l,legendInteraction:u})=>{let d=24;const h=[];return t.forEach((t,y)=>{d+=5,h.push(e.jsx("line",{stroke:"gray",x1:0,y1:d,x2:r,y2:d},"legend-top-line legend-symbol-"+y)),d+=8,t.label&&(d+=16,h.push(e.jsx("text",{y:d,className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:t.label},"legend-text-"+y)),d+=8),h.push(e.jsx("g",{className:"legend-item",transform:`translate(0,${d})`,children:bt(t,n,o,i,a,s,c,y,l,u)},"legend-group-"+y)),d+=22*t.items.length+8}),h})({legendGroups:r||[],width:l,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:a,focusedGroupIndex:y,focusedItemIndex:f,onFocusedIndexChange:m,legendInteraction:s}):(({legendGroups:t,height:r,width:n,customClickBehavior:o,customHoverBehavior:i,highlightedCategory:a,isolatedCategories:s,focusedGroupIndex:c,focusedItemIndex:l,onFocusedIndexChange:u,legendInteraction:d})=>{let h=0;const y=[];t.forEach((t,r)=>{let g=0;t.label&&(g+=16);const f=((t,r,n,o,i,a,s,c,l,u,d)=>{const{type:h="fill",styleFn:y,items:g}=t,f=[];let p=0,m=0;const v=!(!r&&!n),b="isolate"===u||void 0===u&&null!=i;g.forEach((t,u)=>{const x=pt(t,u,h,y),k=vt(t,o,i),A=i&&i.size>0&&i.has(t.label),w=26+7*t.label.length;d&&d>0&&p>0&&p+w>d&&(m++,p=0),f.push(e.jsxs("g",{transform:`translate(${p},${22*m})`,onClick:r?()=>r(t):void 0,onMouseEnter:n?()=>n(t):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:v?c===a&&u===s?0:-1:void 0,role:v?"option":void 0,"aria-selected":v&&b?A||!1:void 0,"aria-current":v&&!b&&null!=o&&t.label===o||void 0,"aria-label":t.label,onKeyDown:v?e=>{var n;if("Enter"!==e.key&&" "!==e.key||(e.preventDefault(),r&&r(t)),"ArrowRight"===e.key||"ArrowLeft"===e.key){e.preventDefault();const t=(u+("ArrowRight"===e.key?1:-1)+g.length)%g.length;l(c,t);const r=null===(n=e.currentTarget.parentElement)||void 0===n?void 0:n.children[t];r instanceof SVGElement&&r.focus()}}:void 0,onFocus:v?e=>{l(c,u),n&&n(t);const r=e.currentTarget.querySelector(".semiotic-legend-focus-ring");r&&r.setAttribute("visibility","visible")}:void 0,onBlur:v?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:v?"pointer":"default",opacity:k,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[v&&e.jsx("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*t.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),x,A&&e.jsx(mt,{}),e.jsx("text",{y:8,x:22,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:t.label})]},"legend-item-"+u)),p+=w});let x=0,k=0;for(const e of g){const t=26+7*e.label.length;d&&d>0&&k>0&&k+t>d?(x=Math.max(x,k),k=t):k+=t}x=Math.max(x,k);const A=m+1;return{items:f,offset:x,totalRows:A,totalHeight:22*A}})(t,o,i,a,s,c,l,r,u,d,n);g+=f.offset+5,y.push(Object.assign(Object.assign({label:t.label},f),{offset:g,totalRows:f.totalRows,totalHeight:f.totalHeight})),h+=g+12});let g=h>n?0:Math.max(0,(n-h)/2);const f=[];return y.forEach((n,o)=>{const i=t[o];i.label&&(f.push(e.jsx("text",{transform:`translate(${g},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:i.label},"legend-text-"+o)),g+=16),f.push(e.jsx("g",{className:"legend-item",transform:`translate(${g},0)`,children:n.items},"legend-group-"+o)),g+=n.offset+5,t[o+1]&&f.push(e.jsx("line",{stroke:"gray",x1:g,y1:-8,x2:g,y2:(n.totalHeight||r)+0+8},"legend-top-line legend-symbol-"+o)),g+=12}),e.jsx("g",{children:f})})({legendGroups:r||[],title:c,height:u,width:l,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:a,focusedGroupIndex:y,focusedItemIndex:f,onFocusedIndexChange:m,legendInteraction:s}),b=!(!n&&!o);return e.jsxs("g",{role:b?"listbox":void 0,"aria-multiselectable":!(!b||"isolate"!==s&&(void 0!==s||null==a))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[void 0!==c&&""!==c&&"vertical"===h&&e.jsx("text",{className:"legend-title",y:16,x:l/2,textAnchor:"middle",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:c}),v]})}function At(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}function wt(e){return"object"==typeof e&&null!==e&&"gradient"in e}function jt(t){const{legend:r,totalWidth:n,totalHeight:o,margin:i,legendPosition:a="right",title:s,legendHoverBehavior:c,legendClickBehavior:l,legendHighlightedCategory:u,legendIsolatedCategories:d,legendInteraction:h}=t;if(!r)return null;const y="top"===a||"bottom"===a;let g,f;return"left"===a?(g=4,f=i.top):"top"===a?(g=0,f=s?32:8):"bottom"===a?(g=0,f=o-i.bottom+50):(g=n-i.right+10,f=i.top),e.jsx("g",{transform:`translate(${g}, ${f})`,children:wt(r)?e.jsx(xt,{config:r.gradient,orientation:y?"horizontal":"vertical",width:y?n:100}):At(r)?e.jsx(kt,{legendGroups:r.legendGroups,title:"",width:y?n:100,orientation:y?"horizontal":"vertical",customHoverBehavior:c,customClickBehavior:l,highlightedCategory:u,isolatedCategories:d,legendInteraction:h}):r})}function St(t){const{width:r,height:n,totalWidth:o,totalHeight:i,margin:a,labels:s,title:c,legend:l,legendHoverBehavior:u,legendClickBehavior:h,legendHighlightedCategory:y,legendIsolatedCategories:g,legendPosition:f="right",foregroundGraphics:p,sceneNodes:m,annotations:v,svgAnnotationRules:b}=t;return e.jsxs(e.Fragment,{children:[e.jsxs("svg",{role:"img",width:o,height:i,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[e.jsx("title",{children:"string"==typeof c?c:"Network Chart"}),e.jsx("desc",{children:"string"==typeof c?c+" — network data visualization":"Network data visualization"}),e.jsxs("g",{transform:`translate(${a.left},${a.top})`,children:[s.map((t,r)=>e.jsx("text",{x:t.x,y:t.y,textAnchor:t.anchor||"start",dominantBaseline:t.baseline||"middle",fontSize:t.fontSize||11,fontWeight:t.fontWeight,fill:t.fill||"currentColor",stroke:t.stroke,strokeWidth:t.strokeWidth,paintOrder:t.paintOrder,style:{pointerEvents:"none"},children:t.text},"label-"+r)),v&&v.filter(e=>"widget"!==e.type).map((t,o)=>{if(b){const i=b(t,o,{width:r,height:n,sceneNodes:m});if(i)return e.jsx(d.Fragment,{children:i},"annotation-"+o)}return null}),p]}),c&&"string"==typeof c?e.jsx("text",{x:o/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor",children:c}):c?e.jsx("foreignObject",{x:0,y:0,width:o,height:a.top,children:c}):null,jt({legend:l,totalWidth:o,totalHeight:i,margin:a,legendPosition:f,title:c,legendHoverBehavior:u,legendClickBehavior:h,legendHighlightedCategory:y,legendIsolatedCategories:g})]}),null==v?void 0:v.filter(e=>"widget"===e.type&&e.nodeId&&m).map((t,r)=>{var n,o,i,s,c,l,u,d,h;const y=m.find(e=>{var r,n,o,i,a;return e.id===t.nodeId||(null===(r=e.datum)||void 0===r?void 0:r.id)===t.nodeId||(null===(o=null===(n=e.datum)||void 0===n?void 0:n.data)||void 0===o?void 0:o.id)===t.nodeId||(null===(a=null===(i=e.datum)||void 0===i?void 0:i.data)||void 0===a?void 0:a.name)===t.nodeId});if(!y)return null;const g=a.left+(null!==(n=y.cx)&&void 0!==n?n:null!=y.x&&null!=y.w?y.x+y.w/2:null!==(o=y.x)&&void 0!==o?o:0),f=a.top+(null!==(i=y.cy)&&void 0!==i?i:null!=y.y&&null!=y.h?y.y+y.h/2:null!==(s=y.y)&&void 0!==s?s:0),p=null!==(c=t.dx)&&void 0!==c?c:0,v=null!==(l=t.dy)&&void 0!==l?l:-16,b=null!==(u=t.width)&&void 0!==u?u:32,x=null!==(d=t.height)&&void 0!==d?d:32,k=null!==(h=t.content)&&void 0!==h?h:e.jsx("span",{style:{fontSize:18,cursor:"default"},children:"ℹ️"});return e.jsx("div",{style:{position:"absolute",left:g+p-b/2,top:f+v-x/2,width:b,height:x,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:5},children:k},"widget-"+r)})]})}function Ot(e,t="#4e79a7"){return e&&"string"==typeof e?e:t}St.displayName="NetworkSVGOverlay";const Lt="undefined"==typeof window||"undefined"==typeof document,Ct=d.createContext(null),Mt={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function Dt(e,t,r){const n=[];return e>0&&n.push(e+" nodes"),t>0&&n.push(t+" edges"),0===n.length?r+", empty":`${r}, ${n.join(", ")}`}const Et=e=>{if(null==e)return"";const t=Math.round(100*e)/100;return Number.isNaN(t)?"":t+""},Pt={position:"absolute",top:0,left:0,right:0,zIndex:5,padding:"14px 16px 12px",borderBottom:"1px solid 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-text, #333)",background:"var(--semiotic-bg, #fff)",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},It={marginBottom:8,paddingRight:28,color:"var(--semiotic-text-secondary, #666)",fontSize:12,letterSpacing:"0.01em"},_t={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-border, #e0e0e0)",background:"var(--semiotic-bg, #fff)",cursor:"pointer",color:"var(--semiotic-text-secondary, #666)",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},Tt={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},Nt={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-border, #e0e0e0)",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-text-secondary, #666)"},Rt={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"},Wt={textAlign:"left",fontSize:11,color:"var(--semiotic-text-secondary, #999)",marginBottom:4,fontStyle:"italic"};function $t({nodes:t,edges:r,chartType:n,tableId:o,chartTitle:i}){var a,s,c,l,u,h,y,g,f,p,m,v,b,x;const[k,A]=d.useState(!1),w=d.useContext(Ct),j=null!==(a=null==w?void 0:w.visible)&&void 0!==a&&a,S=k||j,O=i?"Data summary for "+i:o?`Data summary for ${n} ${o}`:"Data summary for "+n,L=d.useRef(null),C=d.useCallback(()=>{k||j||A(!0)},[k,j]),M=d.useCallback(e=>{var t;j||(null===(t=L.current)||void 0===t?void 0:t.contains(e.relatedTarget))||A(!1)},[j]);if(!t||0===t.length)return o?e.jsx("span",{id:o,tabIndex:-1,style:Mt}):null;if(!S)return e.jsx("div",{id:o,tabIndex:-1,onFocus:C,style:Mt,role:"region","aria-label":O,children:e.jsxs("button",{type:"button",onClick:()=>A(!0),children:["View data summary (",t.length," nodes, ",r.length," edges)"]})});const D=Array.isArray(t)?t:[],E=Array.isArray(r)?r:[],P=new Map,I=new Map,_=new Map,T=new Map;for(const e of E){if(!e||"object"!=typeof e)continue;const t=null!==(s=e.datum)&&void 0!==s?s:e,r="object"==typeof t.source?null===(c=t.source)||void 0===c?void 0:c.id:t.source,n="object"==typeof t.target?null===(l=t.target)||void 0===l?void 0:l.id:t.target,o="number"==typeof t.value&&Number.isFinite(t.value)?t.value:0;if(null!=r&&""!==r){const e=r+"";I.set(e,(null!==(u=I.get(e))&&void 0!==u?u:0)+1),T.set(e,(null!==(h=T.get(e))&&void 0!==h?h:0)+o)}if(null!=n&&""!==n){const e=n+"";P.set(e,(null!==(y=P.get(e))&&void 0!==y?y:0)+1),_.set(e,(null!==(g=_.get(e))&&void 0!==g?g:0)+o)}}const N=[];for(let e=0;D.length>e;e++){const t=D[e];if(!t||"object"!=typeof t)continue;const r=null!==(p=null===(f=t.datum)||void 0===f?void 0:f.id)&&void 0!==p?p:t.id,n=null!=r?r+"":"node-"+e,o=null!==(m=P.get(n))&&void 0!==m?m:0,i=null!==(v=I.get(n))&&void 0!==v?v:0,a=null!==(b=_.get(n))&&void 0!==b?b:0,s=null!==(x=T.get(n))&&void 0!==x?x:0;N.push({id:n,degree:o+i,inDeg:o,outDeg:i,wDegree:a+s,wInDeg:a,wOutDeg:s})}N.sort((e,t)=>t.degree-e.degree);let R=0,W=0;if(N.length>0){let e=0;for(const t of N)e+=t.degree,t.degree>W&&(W=t.degree);R=e/N.length}const $=E.some(e=>{var t;const r=null!==(t=null==e?void 0:e.datum)&&void 0!==t?t:e;return"number"==typeof(null==r?void 0:r.value)&&Number.isFinite(r.value)}),B=[`${N.length} nodes, ${E.length} edges.`];N.length>0&&B.push(`Mean degree: ${Et(R)}, max degree: ${W}.`);const z=N.slice(0,5);return e.jsxs("div",{ref:L,id:o,tabIndex:-1,onBlur:M,style:Pt,role:"region","aria-label":O,children:[e.jsx("button",{type:"button",onClick:()=>{j&&w&&w.setVisible(!1),A(!1)},"aria-label":"Close data summary",style:_t,children:"×"}),e.jsx("div",{role:"note",style:It,children:B.join(" ")}),e.jsxs("table",{role:"table","aria-label":"Node degree summary for "+n,style:Tt,children:[e.jsxs("caption",{style:Wt,children:["Top ",z.length," of ",N.length," nodes by degree"]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:Nt,children:"id"}),e.jsx("th",{style:Nt,children:"degree"}),e.jsx("th",{style:Nt,children:"in"}),e.jsx("th",{style:Nt,children:"out"}),$&&e.jsx("th",{style:Nt,children:"w. degree"}),$&&e.jsx("th",{style:Nt,children:"w. in"}),$&&e.jsx("th",{style:Nt,children:"w. out"})]})}),e.jsx("tbody",{children:z.map((t,r)=>e.jsxs("tr",{children:[e.jsx("td",{style:Rt,children:t.id}),e.jsx("td",{style:Rt,children:t.degree}),e.jsx("td",{style:Rt,children:t.inDeg}),e.jsx("td",{style:Rt,children:t.outDeg}),$&&e.jsx("td",{style:Rt,children:Et(t.wDegree)}),$&&e.jsx("td",{style:Rt,children:Et(t.wInDeg)}),$&&e.jsx("td",{style:Rt,children:Et(t.wOutDeg)})]},r))})]})]})}function Bt({summary:t}){return t?e.jsx("div",{role:"note",style:Mt,children:t}):null}function zt({tableId:t}){return e.jsx("a",{href:"#"+t,style:Mt,onClick:e=>{e.preventDefault();const r=document.getElementById(t);r&&requestAnimationFrame(()=>r.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,Mt)},children:"Skip to data table"})}function Ht({hoverPoint:t}){let r="";if(t){const e=t.data||t;r="object"==typeof e?"Focused on data point: "+Object.entries(e).filter(([,e])=>"object"!=typeof e&&"function"!=typeof e).map(([e,t])=>`${e}: ${t}`).join(", "):"Focused on data point: "+e}return e.jsx("div",{"aria-live":"polite","aria-atomic":"true",style:Mt,children:r})}function Ft(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function Yt(e,t,r=.3){Ft(t)&&(e.globalAlpha=t._pulseIntensity*r,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h))}function qt(e,t,r=.6){var n,o,i,a,s;if(!Ft(t))return;const c=null!==(n=t._pulseGlowRadius)&&void 0!==n?n:4,l=t.r+c*t._pulseIntensity,u=null!==(i=null!==(o=t.cx)&&void 0!==o?o:t.x)&&void 0!==i?i:0,d=null!==(s=null!==(a=t.cy)&&void 0!==a?a:t.y)&&void 0!==s?s:0;e.beginPath(),e.arc(u,d,l,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=t._pulseIntensity*r,e.stroke()}function Gt(e){return e._cachedPath2D&&e._cachedPath2DSource===e.pathD||(e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD),e._cachedPath2D}function Xt(e,t){var r,n,o,i,a,s;if(!t.pathD)return;e.save();const c=Gt(t);if(t.style.fill&&"none"!==t.style.fill){const a=t._gradient;if(a){const o=e.createLinearGradient(a.x0,0,a.x1,0),i=null!==(n=null!==(r=t.style.fillOpacity)&&void 0!==r?r:t.style.opacity)&&void 0!==n?n:.5,s="string"==typeof t.style.fill?t.style.fill:"#999",c=ht(e,s)||s;o.addColorStop(0,1===a.from?c:"transparent"),o.addColorStop(1,1===a.to?c:"transparent"),e.fillStyle=o,e.globalAlpha=i}else e.fillStyle="string"==typeof t.style.fill&&ht(e,t.style.fill)||t.style.fill,e.globalAlpha=null!==(i=null!==(o=t.style.fillOpacity)&&void 0!==o?o:t.style.opacity)&&void 0!==i?i:.5;e.fill(c)}t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=ht(e,t.style.stroke)||t.style.stroke,e.lineWidth=null!==(a=t.style.strokeWidth)&&void 0!==a?a:.5,e.globalAlpha=.5*(null!==(s=t.style.opacity)&&void 0!==s?s:1),e.stroke(c)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.2*t._pulseIntensity,e.fill(c)),e.restore()}function Vt(e,t){var r,n;e.save();const o=t.style.stroke||"#999";e.strokeStyle=ht(e,o)||o,e.lineWidth=null!==(r=t.style.strokeWidth)&&void 0!==r?r:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.strokeDasharray&&e.setLineDash(t.style.strokeDasharray.split(/[\s,]+/).map(Number)),e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke(),t._pulseIntensity&&t._pulseIntensity>0&&(e.setLineDash([]),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=(null!==(n=t.style.strokeWidth)&&void 0!==n?n:1)+3*t._pulseIntensity,e.globalAlpha=.4*t._pulseIntensity,e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke()),e.restore()}function Kt(e,t){var r,n,o,i;if(!t.pathD)return;e.save();const a=Gt(t);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&ht(e,t.style.fill)||t.style.fill,e.globalAlpha=null!==(n=null!==(r=t.style.fillOpacity)&&void 0!==r?r:t.style.opacity)&&void 0!==n?n:.5,e.fill(a)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=ht(e,t.style.stroke)||t.style.stroke,e.lineWidth=null!==(o=t.style.strokeWidth)&&void 0!==o?o:.5,e.globalAlpha=.3*(null!==(i=t.style.opacity)&&void 0!==i?i:1),e.stroke(a)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.25*t._pulseIntensity,e.fill(a)),e.restore()}function Ut(e,t){var r,n;if(!t.pathD)return;e.save();const o=Gt(t),i=t.style.stroke||"#999";e.strokeStyle=ht(e,i)||i,e.lineWidth=null!==(r=t.style.strokeWidth)&&void 0!==r?r:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.stroke(o),t.style.fill&&"none"!==t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&ht(e,t.style.fill)||t.style.fill,e.globalAlpha=null!==(n=t.style.fillOpacity)&&void 0!==n?n:.1,e.fill(o)),e.restore()}const Zt={category10:o.schemeCategory10,tableau10:o.schemeTableau10,set3:o.schemeSet3,blues:o.interpolateBlues,reds:o.interpolateReds,greens:o.interpolateGreens,oranges:o.interpolateOranges,purples:o.interpolatePurples,viridis:o.interpolateViridis,plasma:o.interpolatePlasma},Qt=o.schemeCategory10,Jt=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],er=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"],tr=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 rr(e,t,r){if("function"==typeof t){const n=t(e);return r&&n&&"string"==typeof n&&!function(e){const t=e.toLowerCase();return t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||tr.has(t)}(n)?r(n):n}const n=null==e?void 0:e[t];return r?r(n):Qt[Math.abs(function(e){let t=0;for(let r=0;e.length>r;r++)t=(t<<5)-t+e.charCodeAt(r),t&=t;return Math.abs(t)}(n+""))%Qt.length]}function nr(e,t,r="category10"){const n=Array.from(new Set(e.map(e=>null==e?void 0:e[t]).filter(e=>null!=e))),o=n.every(e=>"number"==typeof e||!isNaN(Number(e)));if(Array.isArray(r))return a.scaleOrdinal().domain(n).range(r).unknown("#999");const i=Zt[r]||Zt.category10;if(o&&"function"==typeof i){let e=-1/0;for(const t of n){const r=Number(t);r>e&&(e=r)}return t=>i(Number(t)/e)}{const e=Array.isArray(i)?i:Qt;return a.scaleOrdinal().domain(n).range(e).unknown("#999")}}const or={top:20,right:80,bottom:20,left:80},ir={top:40,right:40,bottom:40,left:40},ar=new Set(["chord","force","circlepack","orbit"]),sr=[800,600],cr={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,lineHeight:1.5,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function lr({data:t}){var r,n,o,i,a,s;if("edge"===t.nodeOrEdge){const r=t.data;return e.jsxs("div",{className:"semiotic-tooltip",style:cr,children:[e.jsxs("div",{style:{fontWeight:600},children:["object"==typeof r.source?r.source.id:r.source," → ","object"==typeof r.target?r.target.id:r.target]}),null!=r.value&&e.jsxs("div",{style:{marginTop:4,opacity:.8},children:["Value:"," ","number"==typeof r.value?r.value.toLocaleString():r.value+""]})]})}const c=t.data,l=null==c?void 0:c.__hierarchyNode;if(l){const t=[];let a=l;for(;a;){const e=null!==(i=null!==(n=null===(r=a.data)||void 0===r?void 0:r.name)&&void 0!==n?n:null===(o=a.data)||void 0===o?void 0:o.id)&&void 0!==i?i:c.id;null!=e&&t.unshift(e+""),a=a.parent}t.length>1&&t.shift();const s=t.length-1;return e.jsxs("div",{className:"semiotic-tooltip",style:cr,children:[e.jsx("div",{children:t.map((t,r)=>e.jsxs("span",{children:[r>0&&e.jsx("span",{style:{margin:"0 3px",opacity:.5},children:" → "}),r===s?e.jsx("strong",{children:t}):e.jsx("span",{style:{opacity:.7},children:t})]},r))}),null!=c.value&&c.value>0&&e.jsx("div",{style:{marginTop:4,opacity:.8},children:"number"==typeof c.value?c.value.toLocaleString():c.value+""})]})}const u=((null===(a=c.sourceLinks)||void 0===a?void 0:a.length)||0)+((null===(s=c.targetLinks)||void 0===s?void 0:s.length)||0),d=(c.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(c.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0);return e.jsxs("div",{className:"semiotic-tooltip",style:cr,children:[e.jsx("div",{style:{fontWeight:600},children:c.id}),null!=c.value&&c.value>0&&e.jsxs("div",{style:{marginTop:4,opacity:.8},children:["Total:"," ","number"==typeof c.value?c.value.toLocaleString():c.value+""]}),u>0&&e.jsxs("div",{style:{marginTop:4,opacity:.8},children:["Connections: ",u,d!==u&&` (weighted: ${d.toLocaleString()})`]})]})}const ur=t.forwardRef(function(r,n){var o,i,a,s,l,u,d,f,p,m,v,b,x,k,A,w,j;const{chartType:S,nodes:O,edges:L,data:C,initialEdges:M,nodeIDAccessor:D="id",sourceAccessor:E="source",targetAccessor:P="target",valueAccessor:I="value",edgeIdAccessor:_,childrenAccessor:T,hierarchySum:N,orientation:R="horizontal",nodeAlign:W="justify",nodePaddingRatio:$=.05,nodeWidth:B=15,iterations:z=300,forceStrength:H=.1,padAngle:F=.01,groupWidth:Y=20,sortGroups:q,edgeSort:G,treeOrientation:X="vertical",edgeType:V="curve",padding:K,paddingTop:U,tensionConfig:Z,showParticles:Q=!1,particleStyle:J,nodeStyle:ee,edgeStyle:te,colorBy:re,colorScheme:ne="category10",edgeColorBy:oe="source",edgeOpacity:ie=.5,colorByDepth:ae=!1,nodeSize:se=8,nodeSizeRange:ce=[5,20],nodeLabel:le,showLabels:ue=!0,labelMode:de,size:he=sr,responsiveWidth:ye,responsiveHeight:ge,margin:fe,className:pe,background:me,enableHover:ve=!0,tooltipContent:be,customHoverBehavior:xe,customClickBehavior:ke,onObservation:Ae,chartId:we,onTopologyChange:je,annotations:Se,svgAnnotationRules:Oe,legend:Le,legendPosition:Ce,legendHoverBehavior:Me,legendClickBehavior:De,legendHighlightedCategory:Ee,legendIsolatedCategories:Pe,title:Ie,foregroundGraphics:Te,backgroundGraphics:Ne,decay:We,pulse:$e,transition:Be,animate:ze,staleness:He,thresholds:Fe,accessibleTable:qe=!0,description:Ge,summary:Ke,orbitMode:Ue,orbitSize:Qe,orbitSpeed:Je,orbitRevolution:et,orbitRevolutionStyle:tt,orbitEccentricity:rt,orbitShowRings:nt,orbitAnimated:ot}=r,it=ar.has(S)?ir:or,at=t.useRef(!0),st=gt({sizeProp:he,responsiveWidth:ye,responsiveHeight:ge,userMargin:fe,marginDefault:it,foregroundGraphics:Te,backgroundGraphics:Ne,animate:ze,transitionProp:Be,themeDirtyRef:at}),{reducedMotionRef:ct,responsiveRef:lt,size:ut,margin:dt,adjustedWidth:yt,adjustedHeight:ft,resolvedForeground:pt,resolvedBackground:mt,transition:vt,introEnabled:bt,tableId:xt,rafRef:kt,renderFnRef:At,scheduleRender:wt,currentTheme:jt}=st,Ct=t.useMemo(()=>Object.assign(Object.assign({},y),Z),[Z]),Mt=t.useMemo(()=>Object.assign(Object.assign({},g),J),[J]),Et=t.useMemo(()=>{var e;return{chartType:S,nodeIDAccessor:D,sourceAccessor:E,targetAccessor:P,valueAccessor:I,edgeIdAccessor:_,childrenAccessor:T,hierarchySum:N,orientation:R,nodeAlign:W,nodePaddingRatio:$,nodeWidth:B,iterations:z,forceStrength:H,padAngle:F,groupWidth:Y,sortGroups:q,edgeSort:G,treeOrientation:X,edgeType:V,padding:K,paddingTop:U,tensionConfig:Ct,showParticles:Q,particleStyle:Mt,nodeStyle:ee,edgeStyle:te,nodeLabel:le,showLabels:ue,labelMode:de,colorBy:re,colorScheme:ne,themeCategorical:null===(e=null==jt?void 0:jt.colors)||void 0===e?void 0:e.categorical,themeSemantic:Ze(jt),edgeColorBy:oe,edgeOpacity:ie,colorByDepth:ae,nodeSize:se,nodeSizeRange:ce,decay:We,pulse:$e,transition:vt,introAnimation:bt,staleness:He,thresholds:Fe,orbitMode:Ue,orbitSize:Qe,orbitSpeed:Je,orbitRevolution:et,orbitRevolutionStyle:tt,orbitEccentricity:rt,orbitShowRings:nt,orbitAnimated:ot}},[S,D,E,P,I,T,N,R,W,$,B,z,H,F,Y,q,G,X,V,K,U,Ct,Q,Mt,ee,te,le,ue,de,re,ne,oe,ie,ae,se,ce,We,$e,null==vt?void 0:vt.duration,null==vt?void 0:vt.easing,bt,He,Fe,Ue,Qe,Je,et,tt,rt,nt,ot,jt]),Pt=t.useRef(null),It=t.useRef(0),_t=t.useRef(null);_t.current||(_t.current=new _e(Et));const[Tt,Nt]=t.useState(null),[Rt,Wt]=t.useState(0),[Ft,Gt]=t.useState(0),[Zt,Jt]=t.useState(!1),er=t.useRef(null),tr=t.useRef(new Map),rr=t.useRef(0),nr=t.useCallback(e=>{if("function"==typeof re)return re(e)+"";if("string"==typeof re&&e.data){const t=e.data[re];if(void 0!==t){if(!tr.current.has(t+"")){const e=Array.isArray(ne)?ne:Qt;tr.current.set(t+"",e[rr.current++%e.length])}return tr.current.get(t+"")}}if(tr.current.has(e.id))return tr.current.get(e.id);const t=Array.isArray(ne)?ne:Qt,r=re?t[rr.current++%t.length]:t[0];return tr.current.set(e.id,r),r},[re,ne]),cr=(null===(o=null==jt?void 0:jt.colors)||void 0===o?void 0:o.border)||(null===(i=null==jt?void 0:jt.colors)||void 0===i?void 0:i.secondary)||(null===(a=null==jt?void 0:jt.colors)||void 0===a?void 0:a.primary)||"#999",ur=t.useCallback(e=>{if("function"==typeof oe)return oe(e);const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;return"target"===oe&&r?nr(r):t?nr(t):cr},[oe,nr,cr]),dr=t.useCallback(e=>{if(!(null==J?void 0:J.colorBy))return ur(e);const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;return"target"===Mt.colorBy&&r?nr(r):t?nr(t):cr},[null==J?void 0:J.colorBy,Mt.colorBy,nr,ur,cr]),hr="sankey"===S&&Q||!!$e||null!==(l=null===(s=_t.current)||void 0===s?void 0:s.isAnimating)&&void 0!==l&&l;t.useEffect(()=>{var e;null===(e=_t.current)||void 0===e||e.updateConfig(Et),at.current=!0,wt()},[Et,wt]),t.useEffect(()=>{var e;const t=_t.current;if(t){t.buildScene([yt,ft]);for(const r of t.sceneNodes)r.id&&"string"==typeof(null===(e=r.style)||void 0===e?void 0:e.fill)&&tr.current.set(r.id,r.style.fill);at.current=!0,wt()}},[jt,yt,ft,wt]);const yr=t.useCallback(()=>{var e;const t=_t.current;if(!t)return;t.runLayout([yt,ft]),t.buildScene([yt,ft]),at.current=!0;for(const r of t.sceneNodes)r.id&&"string"==typeof(null===(e=r.style)||void 0===e?void 0:e.fill)&&tr.current.set(r.id,r.style.fill);const r=Array.isArray(ne)?ne:Qt,n=Array.from(t.nodes.values());for(let e=0;n.length>e;e++){const t=n[e];tr.current.has(t.id)||tr.current.set(t.id,r[e%r.length])}if(rr.current=n.length,Wt(t.layoutVersion),je){const{nodes:e,edges:r}=t.getLayoutData();je(e,r)}},[yt,ft,je,ne]),gr=t.useCallback(e=>{const t=_t.current;t&&(t.ingestEdge(e)&&yr(),wt())},[yr,wt]),fr=t.useCallback(e=>{const t=_t.current;if(!t)return;let r=!1;for(const n of e)t.ingestEdge(n)&&(r=!0);r&&yr(),wt()},[yr,wt]),pr=t.useCallback(()=>{var e;null===(e=_t.current)||void 0===e||e.clear(),tr.current.clear(),rr.current=0,Wt(0),Nt(null),er.current=null,at.current=!0,wt()},[wt]),mr=t.useCallback(()=>{const e=_t.current;e&&(e.tension+=999,yr(),wt())},[yr,wt]);t.useImperativeHandle(n,()=>({push:gr,pushMany:fr,removeNode:e=>{var t,r,n;const o=null!==(r=null===(t=_t.current)||void 0===t?void 0:t.removeNode(e))&&void 0!==r&&r;if(o){const t=(null===(n=er.current)||void 0===n?void 0:n.data)?"function"==typeof D?D(er.current.data):er.current.data[D]:void 0;er.current&&"node"===er.current.nodeOrEdge&&t===e&&(er.current=null,Nt(null)),tr.current.delete(e),yr(),at.current=!0,wt()}return o},removeEdge:(e,t)=>{var r,n;const o=null!==(n=null===(r=_t.current)||void 0===r?void 0:r.removeEdge(e,t))&&void 0!==n&&n;if(o){if(er.current&&"edge"===er.current.nodeOrEdge){const r=er.current.data;let n;n=void 0!==t?("object"==typeof(null==r?void 0:r.source)?r.source.id:null==r?void 0:r.source)===e&&("object"==typeof(null==r?void 0:r.target)?r.target.id:null==r?void 0:r.target)===t:!_||!r||("function"==typeof _?_:e=>null==e?void 0:e[_])(r)===e,n&&(er.current=null,Nt(null))}yr(),at.current=!0,wt()}return o},updateNode:(e,t)=>{var r,n;const o=null!==(n=null===(r=_t.current)||void 0===r?void 0:r.updateNode(e,t))&&void 0!==n?n:null;return o&&(at.current=!0,wt()),o},updateEdge:(e,t,r)=>{var n,o;const i=null!==(o=null===(n=_t.current)||void 0===n?void 0:n.updateEdge(e,t,r))&&void 0!==o?o:[];return i.length>0&&(yr(),at.current=!0,wt()),i},clear:pr,getTopology:()=>{var e,t;return null!==(t=null===(e=_t.current)||void 0===e?void 0:e.getLayoutData())&&void 0!==t?t:{nodes:[],edges:[]}},getTopologyDiff:()=>{const e=_t.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:mr,getTension:()=>{var e,t;return null!==(t=null===(e=_t.current)||void 0===e?void 0:e.tension)&&void 0!==t?t:0}}),[gr,fr,pr,mr,yr,wt]);const vr=["tree","cluster","treemap","circlepack","partition","orbit"].includes(S),br=vr?C||(Array.isArray(L)?void 0:L):void 0;t.useEffect(()=>{var e;const t=_t.current;if(t)if(vr&&br)t.ingestHierarchy(br,[yt,ft]),t.buildScene([yt,ft]),at.current=!0,wt();else{const r=O||[],n=Array.isArray(L)?L:[];if(0===r.length&&0===n.length)return;t.ingestBounded(r,n,[yt,ft]),t.buildScene([yt,ft]);for(const r of t.sceneNodes)r.id&&(null===(e=r.style)||void 0===e?void 0:e.fill)&&tr.current.set(r.id,r.style.fill+"");const o=Array.isArray(ne)?ne:Qt,i=Array.from(t.nodes.values());for(let e=0;i.length>e;e++){const t=i[e];tr.current.has(t.id)||tr.current.set(t.id,o[e%o.length])}rr.current=i.length,at.current=!0,wt()}},[O,L,C,br,vr,yt,ft,Et,wt,ne]),t.useEffect(()=>{M&&M.length>0&&fr(M)},[]);const xr=t.useCallback(e=>{if(xe&&xe(e),Ae){const t=Date.now();Ae(e?{type:"hover",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:we}:{type:"hover-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:we})}},[xe,Ae,we]),kr=t.useCallback(e=>{if(ke&&ke(e),Ae){const t=Date.now();Ae(e?{type:"click",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:we}:{type:"click-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:we})}},[ke,Ae,we]),{hoverHandlerRef:Ar,hoverLeaveRef:wr,onPointerMove:jr,onPointerLeave:Sr}=st;Ar.current=e=>{if(!ve)return;const t=Pt.current;if(!t)return;const r=t.getBoundingClientRect(),n=e.clientX-r.left-dt.left,o=e.clientY-r.top-dt.top;if(0>n||n>yt||0>o||o>ft)return void(er.current&&(er.current=null,Nt(null),xr&&(xr(null),at.current=!0),wt()));const i=_t.current;if(!i)return;const a=Re(i.sceneNodes,i.sceneEdges,n,o);if(!a)return void(er.current&&(er.current=null,Nt(null),xr&&(xr(null),at.current=!0),wt()));const s=h(a.datum||{},a.x,a.y,{nodeOrEdge:a.type});er.current=s,Nt(s),xr&&(xr(s),at.current=!0),wt()},wr.current=()=>{er.current&&(er.current=null,Nt(null),xr&&(xr(null),at.current=!0),wt())};const Or=t.useRef(()=>{});Or.current=e=>{if(!ke&&!Ae)return;const t=Pt.current;if(!t)return;const r=t.getBoundingClientRect(),n=e.clientX-r.left-dt.left,o=e.clientY-r.top-dt.top;if(0>n||n>yt||0>o||o>ft)return;const i=_t.current;if(!i)return;const a=Re(i.sceneNodes,i.sceneEdges,n,o);kr(a?h(a.datum||{},a.x,a.y,{nodeOrEdge:a.type}):null)};const Lr=t.useCallback(e=>Or.current(e),[]),Cr=t.useRef(-1),Mr=t.useRef(null),Dr=t.useRef(-1),Er=t.useCallback(e=>{var t;const r=_t.current;if(!r)return;const n=function(e){var t,r,n,o,i,a;const s=[];for(const c of e)"circle"===c.type&&null!=c.cx?s.push({x:c.cx,y:c.cy,datum:c.datum,shape:"circle",group:null!==(r=null===(t=c.datum)||void 0===t?void 0:t.id)&&void 0!==r?r:"_default"}):"rect"===c.type&&null!=c.x?s.push({x:c.x+c.w/2,y:c.y+c.h/2,datum:c.datum,shape:"rect",w:c.w,h:c.h,group:null!==(o=null===(n=c.datum)||void 0===n?void 0:n.id)&&void 0!==o?o:"_default"}):"arc"===c.type&&null!=c.cx&&s.push({x:c.cx,y:c.cy,datum:c.datum,shape:"circle",group:null!==(a=null===(i=c.datum)||void 0===i?void 0:i.id)&&void 0!==a?a:"_default"});return s.sort((e,t)=>e.x-t.x||e.y-t.y),s}(r.sceneNodes);if(0===n.length)return;const o=function(e){var t,r;const n=new Map;for(const r of e){const e=null!==(t=r.group)&&void 0!==t?t:"_default";let o=n.get(e);o||(o=[],n.set(e,o)),o.push(r)}for(const e of n.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 o=Array.from(n.keys()).sort((e,t)=>{const r=n.get(e),o=n.get(t);return(r.length>0?r[0].y:0)-(o.length>0?o[0].y:0)}),i=Array.from(n.values()).flat();i.sort((e,t)=>e.x-t.x||e.y-t.y);const a=new Map;for(let e=0;i.length>e;e++){i[e]._flatIndex=e;const t=null===(r=i[e].datum)||void 0===r?void 0:r.id;null!=t&&a.set(t+"",e)}return{flat:i,groups:o,byGroup:n,idToIdx:a}}(n),i=Cr.current;if(0>i){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Enter"].includes(e.key))return;e.preventDefault(),Cr.current=0,Dr.current=-1;const t=o.flat[0];Mr.current={shape:t.shape,w:t.w,h:t.h};const r=h(t.datum||{},t.x,t.y,{nodeOrEdge:"node"});return er.current=r,Nt(r),xr&&(xr(r),at.current=!0),void wt()}const a=function(e,t){var r,n;if(0===e.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const o=Math.max(0,Math.min(t,e.flat.length-1)),i=e.flat[o];return{flatIndex:o,group:null!==(r=i.group)&&void 0!==r?r:"_default",indexInGroup:null!==(n=i._groupIndex)&&void 0!==n?n:0}}(o,i),s=function(e,t,r,n,o){var i,a,s;const c=r.flat[t.flatIndex];if(!c)return Ye(e,t,r);const l=null===(i=c.datum)||void 0===i?void 0:i.id;switch(e){case"ArrowRight":case"ArrowLeft":case"ArrowDown":case"ArrowUp":{const n=null!==(a=function(e,t,r){let n=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,c=a.y-t.y;let l=!1;switch(r){case"right":l=s>0&&Math.abs(s)>=Math.abs(c);break;case"left":l=0>s&&Math.abs(s)>=Math.abs(c);break;case"down":l=c>0&&Math.abs(c)>=Math.abs(s);break;case"up":l=0>c&&Math.abs(c)>=Math.abs(s)}if(!l)continue;const u=s*s+c*c;o>u&&(o=u,n=i)}return n}(r,c,"ArrowRight"===e?"right":"ArrowLeft"===e?"left":"ArrowDown"===e?"down":"up"))&&void 0!==a?a:t.flatIndex;return n!==t.flatIndex&&(o.current=-1),n}case"Enter":{if(null==l)return t.flatIndex;const e=function(e,t){var r,n,o;const i=e+"",a=[];for(const e of t){const t=null!==(r=e.datum)&&void 0!==r?r:e,s="object"==typeof t.source?null===(n=t.source)||void 0===n?void 0:n.id:t.source,c="object"==typeof t.target?null===(o=t.target)||void 0===o?void 0:o.id:t.target,l=null!=s,u=null!=c;l&&s+""===i&&u?a.push(c+""):u&&c+""===i&&l&&a.push(s+"")}return a}(l,n);if(0===e.length)return t.flatIndex;const i=null!==(s=r.idToIdx.get(e[(o.current+1)%e.length]))&&void 0!==s?s:-1;return 0>i?t.flatIndex:(o.current=-1,i)}default:{const n=Ye(e,t,r);return null!==n&&n!==t.flatIndex&&(o.current=-1),n}}}(e.key,a,o,null!==(t=r.sceneEdges)&&void 0!==t?t:[],Dr);if(null===s)return;if(e.preventDefault(),0>s)return Cr.current=-1,Mr.current=null,Dr.current=-1,er.current=null,Nt(null),xr&&(xr(null),at.current=!0),void wt();Cr.current=s;const c=o.flat[s];Mr.current={shape:c.shape,w:c.w,h:c.h};const l=c.datum||{},u=Object.assign(Object.assign({},"object"!=typeof l||null===l||Array.isArray(l)?{}:l),{data:l,x:c.x,y:c.y,time:c.x,value:c.y,nodeOrEdge:"node"});er.current=u,Nt(u),xr&&(xr(u),at.current=!0),wt()},[xr,wt]),Pr=t.useCallback(e=>{Cr.current=-1,Mr.current=null,jr(e)},[jr]);At.current=()=>{var e,t,r,n,o,i,a;kt.current=0;const s=Pt.current;if(!s)return;const c=s.getContext("2d");if(!c)return;const l=_t.current;if(!l)return;const u=performance.now(),d=It.current?Math.min((u-It.current)/1e3,.1):.016;It.current=u;const h=l.advanceTransition(ct.current?u+1e6:u),y=!ct.current&&h,f=!ct.current&&l.tickAnimation([yt,ft],d);(h||at.current||f)&&l.buildScene([yt,ft]);const p="undefined"!=typeof window&&window.devicePixelRatio||1;if(!function(e,t,r,n){const o=e.getContext("2d");if(!o)return null;const i=t[0]*n,a=t[1]*n,s=t[0]+"px",c=t[1]+"px";return e.style.width!==s&&(e.style.width=s),e.style.height!==c&&(e.style.height=c),e.width===i&&e.height===a||(e.width=i,e.height=a),o.setTransform(n,0,0,n,0,0),o.translate(r.left,r.top),o}(s,ut,dt,p))return;c.clearRect(-dt.left,-dt.top,ut[0],ut[1]),me&&(c.fillStyle=me,c.fillRect(0,0,yt,ft)),We&&l.applyDecay(),$e&&l.applyPulse(u),Fe&&l.applyThresholds(u),l.applyTopologyDiff(u);const m=null!==(e=null==He?void 0:He.threshold)&&void 0!==e?e:5e3,v=He&&l.lastIngestTime>0&&u-l.lastIngestTime>m;if(v&&(c.globalAlpha=null!==(t=null==He?void 0:He.dimOpacity)&&void 0!==t?t:.5),function(e,t){for(const r of t)switch(r.type){case"bezier":Xt(e,r);break;case"line":Vt(e,r);break;case"ribbon":Kt(e,r);break;case"curved":Ut(e,r)}}(c,l.sceneEdges),function(e,t){var r,n,o;for(const i of t){if("rect"!==i.type)continue;const t=i;t.w>0&&t.h>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&ht(e,t.style.fill)||t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(r=t.style.opacity)&&void 0!==r?r:1)*t.style.fillOpacity),e.fillRect(t.x,t.y,t.w,t.h)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=ht(e,t.style.stroke)||t.style.stroke,e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,e.globalAlpha=null!==(o=t.style.opacity)&&void 0!==o?o:1,e.strokeRect(t.x,t.y,t.w,t.h)),Yt(e,t),e.restore())}}(c,l.sceneNodes),function(e,t){var r,n,o;for(const i of t){if("circle"!==i.type)continue;const t=i;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),t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&ht(e,t.style.fill)||t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(r=t.style.opacity)&&void 0!==r?r:1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=ht(e,t.style.stroke)||t.style.stroke,e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,e.globalAlpha=null!==(o=t.style.opacity)&&void 0!==o?o:1,e.stroke()),qt(e,t),e.restore())}}(c,l.sceneNodes),function(e,t){var r,n,o;for(const i of t){if("arc"!==i.type)continue;const t=i;e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.outerR,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerR,t.endAngle,t.startAngle,!0),e.closePath(),t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&ht(e,t.style.fill)||t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(r=t.style.opacity)&&void 0!==r?r:1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=ht(e,t.style.stroke)||t.style.stroke,e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,e.globalAlpha=null!==(o=t.style.opacity)&&void 0!==o?o:1,e.stroke()),e.restore()}}(c,l.sceneNodes),Q&&l.particlePool&&!v){const e=Array.from(l.edges.values());if(e.length>0){!function(e,t,r,n){var o,i;const a=null!==(o=n.spawnRate)&&void 0!==o?o:g.spawnRate,s=null!==(i=n.maxPerEdge)&&void 0!==i?i:g.maxPerEdge;for(let n=0;t.length>n;n++){const o=t[n];if(!o.bezier)continue;if(e.countForEdge(n)>=s)continue;const i=o.value*a*r*(o.bezier.circular?.3:1),c=Math.floor(i),l=i-c;let u=c;Math.random()<l&&u++;for(let t=0;u>t&&e.countForEdge(n)<s;t++)e.spawn(n)}}(l.particlePool,e,d,Mt);const t=.5*(null!==(r=Mt.speedMultiplier)&&void 0!==r?r:1);let n;if(Mt.proportionalSpeed){const t=e.reduce((e,t)=>Math.max(e,t.value||1),1);n=e.map(e=>.3+(e.value||1)/t*1.7)}l.particlePool.step(d,t,e,n),function(e,t,r,n,o){var i,a;const s=null!==(i=n.radius)&&void 0!==i?i:g.radius,c=null!==(a=n.opacity)&&void 0!==a?a:g.opacity;e.globalAlpha=c;for(let i=0;t.particles.length>i;i++){const a=t.particles[i];if(!a.active)continue;const c=r[a.edgeIndex];if(c){if("function"==typeof n.color){const t="object"==typeof c.source?c.source:null;e.fillStyle=t?n.color(c,t):ht(e,"var(--semiotic-secondary, #666)")}else e.fillStyle=n.color&&"inherit"!==n.color?n.color:o(c);e.beginPath(),e.arc(a.x,a.y,s,0,2*Math.PI),e.fill()}}e.globalAlpha=1}(c,l.particlePool,e,Mt,dr)}}v&&(c.globalAlpha=1);const b=at.current;if(at.current=!1,b||y||f){const e=Pt.current;e&&e.setAttribute("aria-label",Dt(null!==(o=null===(n=l.sceneNodes)||void 0===n?void 0:n.length)&&void 0!==o?o:0,null!==(a=null===(i=l.sceneEdges)||void 0===i?void 0:i.length)&&void 0!==a?a:0,"Network chart"))}(b||y||f)&&Gt(e=>e+1),(hr||y||null!=l.transition||f||l.hasActivePulses||l.hasActiveThresholds||l.hasActiveTopologyDiff)&&(kt.current=requestAnimationFrame(()=>At.current()))},t.useEffect(()=>(wt(),()=>{}),[wt]),t.useEffect(()=>{at.current=!0,wt()},[S,yt,ft,me,wt]),function(e,r,n,o,i,a){t.useEffect(()=>{if(!e)return;const t=setInterval(()=>{var t;const s=r.current;if(!s||0===s.lastIngestTime)return;const c="undefined"!=typeof performance?performance.now():Date.now(),l=null!==(t=e.threshold)&&void 0!==t?t:5e3,u=c-s.lastIngestTime>l;u!==i&&(a(u),n.current=!0,o())},1e3);return()=>clearInterval(t)},[e,i,o])}(He,_t,at,wt,Zt,Jt);const Ir=ve&&Tt?e.jsx(Ve,{x:Tt.x,y:Tt.y,containerWidth:yt,containerHeight:ft,margin:dt,className:"stream-network-tooltip",zIndex:2,children:be?be(Tt):e.jsx(lr,{data:Tt})}):null;if(Lt){const t=_t.current;if(t){const e=["tree","cluster","treemap","circlepack","partition","orbit"].includes(S),r=e?C||(Array.isArray(L)?void 0:L):void 0;if(e&&r)t.ingestHierarchy(r,[yt,ft]),t.buildScene([yt,ft]);else{const e=O||[],r=Array.isArray(L)?L:[];(e.length>0||r.length>0)&&(t.ingestBounded(e,r,[yt,ft]),t.buildScene([yt,ft]))}}const r=null!==(u=null==t?void 0:t.sceneNodes)&&void 0!==u?u:[],n=null!==(d=null==t?void 0:t.sceneEdges)&&void 0!==d?d:[],o=null!==(f=null==t?void 0:t.labels)&&void 0!==f?f:[];return e.jsxs("div",{className:"stream-network-frame"+(pe?" "+pe:""),role:"img","aria-label":Ge||("string"==typeof Ie?Ie:"Network chart"),style:{position:"relative",width:ut[0],height:ut[1]},children:[e.jsx(Bt,{summary:Ke}),e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:ut[0],height:ut[1],style:{position:"absolute",left:0,top:0},children:[mt&&e.jsx("g",{transform:`translate(${dt.left},${dt.top})`,children:mt}),e.jsxs("g",{transform:`translate(${dt.left},${dt.top})`,children:[me&&e.jsx("rect",{x:0,y:0,width:yt,height:ft,fill:me}),n.map((t,r)=>function(t,r){switch(t.type){case"line":return e.jsx("line",{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.stroke||"#999",strokeWidth:t.style.strokeWidth||1,opacity:t.style.opacity},"net-edge-"+r);case"bezier":{const n=t;return e.jsx("path",{d:n.pathD,fill:Ot(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-edge-"+r)}case"ribbon":{const n=t;return e.jsx("path",{d:n.pathD,fill:Ot(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-edge-"+r)}case"curved":{const n=t;return e.jsx("path",{d:n.pathD,fill:Ot(n.style.fill,"none"),stroke:n.style.stroke||"#999",strokeWidth:n.style.strokeWidth||1,opacity:n.style.opacity},"net-edge-"+r)}default:return null}}(t,r)).filter(Boolean),r.map((t,r)=>function(t,r){switch(t.type){case"circle":{const n=t;return e.jsx("circle",{cx:n.cx,cy:n.cy,r:n.r,fill:Ot(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-circle-"+r)}case"rect":{const n=t;return e.jsx("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:Ot(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-rect-"+r)}case"arc":{const n=t,o=c.arc().innerRadius(n.innerR).outerRadius(n.outerR).startAngle(n.startAngle+Math.PI/2).endAngle(n.endAngle+Math.PI/2)({})||"";return e.jsx("path",{d:o,transform:`translate(${n.cx},${n.cy})`,fill:Ot(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-arc-"+r)}default:return null}}(t,r)).filter(Boolean),o.map((t,r)=>function(t,r){return e.jsx("text",{x:t.x,y:t.y,textAnchor:t.anchor||"middle",dominantBaseline:t.baseline||"auto",fontSize:t.fontSize||11,fontWeight:t.fontWeight,fill:t.fill||"#333",stroke:t.stroke,strokeWidth:t.strokeWidth,paintOrder:t.paintOrder,children:t.text},"net-label-"+r)}(t,r)).filter(Boolean)]})]}),e.jsx(St,{width:yt,height:ft,totalWidth:ut[0],totalHeight:ut[1],margin:dt,labels:o,sceneNodes:r,title:Ie,legend:Le,legendPosition:Ce,legendHoverBehavior:Me,legendClickBehavior:De,legendHighlightedCategory:Ee,legendIsolatedCategories:Pe,foregroundGraphics:pt,annotations:Se,svgAnnotationRules:Oe,annotationFrame:0})]})}const _r=_t.current;return e.jsxs("div",{ref:lt,className:"stream-network-frame"+(pe?" "+pe:""),role:"group","aria-label":Ge||("string"==typeof Ie?Ie:"Network chart"),tabIndex:0,style:{position:"relative",width:ye?"100%":ut[0],height:ge?"100%":ut[1],overflow:"visible"},onKeyDown:Er,children:[qe&&e.jsx(zt,{tableId:xt}),qe&&e.jsx($t,{nodes:null!==(p=null==_r?void 0:_r.sceneNodes)&&void 0!==p?p:[],edges:null!==(m=null==_r?void 0:_r.sceneEdges)&&void 0!==m?m:[],chartType:"Network chart",tableId:xt,chartTitle:"string"==typeof Ie?Ie:void 0}),e.jsx(Bt,{summary:Ke}),e.jsxs("div",{role:"img","aria-label":Ge||("string"==typeof Ie?Ie:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:ve?Pr:void 0,onMouseLeave:ve?Sr:void 0,onClick:ke||Ae?Lr:void 0,children:[mt&&e.jsx("svg",{overflow:"visible",style:{position:"absolute",top:0,left:0,width:ut[0],height:ut[1],pointerEvents:"none",overflow:"visible"},children:e.jsx("g",{transform:`translate(${dt.left},${dt.top})`,children:mt})}),e.jsx("canvas",{ref:Pt,"aria-label":Dt(null!==(b=null===(v=null==_r?void 0:_r.sceneNodes)||void 0===v?void 0:v.length)&&void 0!==b?b:0,null!==(k=null===(x=null==_r?void 0:_r.sceneEdges)||void 0===x?void 0:x.length)&&void 0!==k?k:0,"Network chart"),style:{position:"absolute",top:0,left:0}}),e.jsx(Ht,{hoverPoint:Tt}),e.jsx(St,{width:yt,height:ft,totalWidth:ut[0],totalHeight:ut[1],margin:dt,labels:(null==_r?void 0:_r.labels)||[],sceneNodes:null==_r?void 0:_r.sceneNodes,title:Ie,legend:Le,legendPosition:Ce,legendHoverBehavior:Me,legendClickBehavior:De,legendHighlightedCategory:Ee,legendIsolatedCategories:Pe,foregroundGraphics:pt,annotations:Se,svgAnnotationRules:Oe,annotationFrame:Ft}),e.jsx(Xe,{active:Cr.current>=0,hoverPoint:Tt,margin:dt,size:ut,shape:null===(A=Mr.current)||void 0===A?void 0:A.shape,width:null===(w=Mr.current)||void 0===w?void 0:w.w,height:null===(j=Mr.current)||void 0===j?void 0:j.h}),Ir,(null==He?void 0:He.showBadge)&&e.jsx("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===He.badgePosition?{top:4,left:4}:"bottom-left"===He.badgePosition?{bottom:4,left:4}:"bottom-right"===He.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{background:Zt?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"}),children:Zt?"STALE":"LIVE"})]})]})});ur.displayName="StreamNetworkFrame";const dr={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 hr(e,t){return"function"==typeof t?t(e):e[t]}function yr(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 gr(t={}){const{fields:r,title:n,format:o,style:i={},className:a=""}=t;return t=>{if(!t||"object"!=typeof t)return null;let s;const c=[];if(n){const e=hr(t,n);s=yr(e,o)}if(r&&r.length>0)r.forEach(e=>{let r,n,i;"string"==typeof e?(r=e,n=e,i=o):(r=e.label,n=e.accessor||e.key||"",i=e.format||o);const a=hr(t,n);c.push({label:r,value:yr(a,i)})});else if(!n){const e=["value","y","name","id","label"];for(const r of e)if(void 0!==t[r]){s=yr(t[r],o);break}if(!s){const e=Object.keys(t).filter(e=>!e.startsWith("_"));e.length>0&&(s=yr(t[e[0]],o))}}const l=Object.assign(Object.assign({},dr),i);return e.jsxs("div",{className:("semiotic-tooltip "+a).trim(),style:l,children:[s&&e.jsx("div",{style:{fontWeight:c.length>0?"bold":"normal"},children:s}),c.map((t,r)=>e.jsxs("div",{style:{marginTop:0===r&&s?"4px":0},children:[t.label&&e.jsxs("span",{children:[t.label,": "]}),t.value]},r))]})}}function fr(t){if(!0===t)return gr();if("function"==typeof t){const r=t;return t=>{const n=r(!t||"object"!=typeof t.data||null===t.data||"node"!==t.type&&"edge"!==t.type?t:t.data);return null==n?null:e.jsx("div",{className:"semiotic-tooltip",style:dr,children:n})}}return!1!==t&&void 0!==t&&("object"==typeof t&&null!==t&&("fields"in t||"title"in t)?gr(t):gr())}const pr=t.createContext(null);function mr(e){const t=[];for(const[r,n]of Object.entries(e.fields))if("point"===n.type)t.push(e=>n.values.has(e[r]));else{const[e,o]=n.range;t.push(t=>{const n=t[r];return n>=e&&o>=n})}return e=>t.every(t=>t(e))}function vr(e,t){let r=e.get(t);return r||(r={name:t,resolution:"union",clauses:new Map},e.set(t,r)),r}const[br,xr]=Ke(e=>({selections:new Map,setClause(t,r){e(e=>{const n=new Map(e.selections),o=vr(n,t),i=new Map(o.clauses);return i.set(r.clientId,r),n.set(t,Object.assign(Object.assign({},o),{clauses:i})),{selections:n}})},clearClause(t,r){e(e=>{const n=e.selections.get(t);if(!n)return{};const o=new Map(e.selections),i=new Map(n.clauses);return i.delete(r),o.set(t,Object.assign(Object.assign({},n),{clauses:i})),{selections:o}})},setResolution(t,r){e(e=>{const n=new Map(e.selections),o=vr(n,t);return n.set(t,Object.assign(Object.assign({},o),{resolution:r})),{selections:n}})},clearSelection(t){e(e=>{const r=new Map(e.selections),n=r.get(t);return n&&r.set(t,Object.assign(Object.assign({},n),{clauses:new Map})),{selections:r}})}})),[kr,Ar]=Ke(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const r=e.observations;return r.push(t),r.length>e.maxObservations&&r.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}}));let wr={positions:new Map};const jr=new Set;function Sr(){for(const e of jr)e()}function Or(e,t){const r=wr.positions.get(e);if(null==r?void 0:r.locked)return;if(!r||r.sourceId!==t)return;const n=new Map(wr.positions);n.delete(e),wr={positions:n},Sr()}function Lr(e){const r=t.useId(),n=e.clientId||r,{name:o}=e,i=xr(e=>e.selections.get(o)),a=xr(e=>e.setClause),s=xr(e=>e.clearClause),c=t.useMemo(()=>!!i&&i.clauses.size>0,[i]);return{predicate:t.useMemo(()=>i&&0!==i.clauses.size?function(e,t){const r=[];for(const[n,o]of e.clauses)"crossfilter"===e.resolution&&n===t||r.push(mr(o));return 0===r.length?()=>!0:"intersect"===e.resolution?e=>r.every(t=>t(e)):e=>r.some(t=>t(e))}(i,n):()=>!0,[i,n]),isActive:c,selectPoints:t.useCallback(e=>{const t={};for(const[r,n]of Object.entries(e))t[r]={type:"point",values:new Set(n)};a(o,{clientId:n,type:"point",fields:t})},[n,o,a]),selectInterval:t.useCallback(e=>{const t={};for(const[r,n]of Object.entries(e))t[r]={type:"interval",range:n};a(o,{clientId:n,type:"interval",fields:t})},[n,o,a]),clear:t.useCallback(()=>{s(o,n)},[s,o,n]),clientId:n}}const Cr=t.createContext(!1);function Mr(){var e;const t=ot(e=>e.theme),r=null===(e=null==t?void 0:t.colors)||void 0===e?void 0:e.categorical;return r&&r.length>0?r:void 0}function Dr(e,t,r,n,o){let i;if(Array.isArray(r))i=r;else if(t&&t.length>0)i=t;else if("string"==typeof r){const e=Zt[r];Array.isArray(e)&&(i=e)}return i&&0!==i.length?i[0]:"#007bff"}function Er(e,r,n){const o=t.useContext(pr),i=Mr();return t.useMemo(()=>{var t;if(!r)return;const a=null!==(t=null!=n?n:i&&i.length>0?i:void 0)&&void 0!==t?t:"category10";if(0!==e.length){if("function"==typeof r){const t=Array.from(new Set(e.map(e=>r(e)+"")));if(o&&Object.keys(o).length>0){const e=nr(t.map(e=>({_cat:e})),"_cat",a);return t=>o[t]||e(t)}return nr(t.map(e=>({_cat:e})),"_cat",a)}if(o&&Object.keys(o).length>0){const t=nr(e,r,a);return e=>o[e]||t(e)}return nr(e,r,a)}if(o&&Object.keys(o).length>0){const e=nr([{_:"a"}],"_",a);return t=>o[t]||e(t)}},[e,r,n,o,i])}function Pr({selection:e,linkedHover:r,fallbackFields:n=[],unwrapData:o=!1,onObservation:i,chartType:a,chartId:s,onClick:c,hoverHighlight:l,colorByField:u}){const d=t.useId(),h=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}:null}(r,n),y=Lr({name:(null==e?void 0:e.name)||"__unused__"}),g=function(e){const r=e.name||"hover",{fields:n}=e,{predicate:o,isActive:i,selectPoints:a,clear:s}=Lr({name:r});return{onHover:t.useCallback(e=>{if(!e)return void s();const t={};for(const r of n){const n=e[r];void 0!==n&&(t[r]=[n])}Object.keys(t).length>0&&a(t)},[n,a,s,r]),predicate:o,isActive:i}}({name:(null==h?void 0:h.name)||"hover",fields:(null==h?void 0:h.fields)||n||[]}),f=Ar(e=>e.pushObservation),p=e?{isActive:y.isActive,predicate:y.predicate}:null,[m,v]=t.useState(null),b=u||n[0],x=t.useMemo(()=>{if(!l||null==m||!b)return null;const e=m,t=b;return{isActive:!0,predicate:r=>{var n;return("string"==typeof r[t]?r[t]:(null!==(n=r[t])&&void 0!==n?n:"")+"")===e}}},[l,m,b]),k=t.useCallback(e=>{var t,n;if(r)if(e){let t=e.data||e.datum||e;if(Array.isArray(t)&&(t=t[0]),"x-position"===(null==h?void 0:h.mode)&&h.xField){const e=null==t?void 0:t[h.xField];null!=e&&Number.isFinite(Number(e))&&function(e,t,r){const n=wr.positions.get(e);(null==n?void 0:n.locked)||n&&n.xValue===t&&n.sourceId===r||(wr={positions:new Map(wr.positions).set(e,{xValue:t,sourceId:r})},Sr())}(h.name||"hover",Number(e),d)}"x-position"!==(null==h?void 0:h.mode)&&g.onHover(t)}else"x-position"===(null==h?void 0:h.mode)&&Or(h.name||"hover",d),"x-position"!==(null==h?void 0:h.mode)&&g.onHover(null);if(l&&b)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const r=null==t?void 0:t[b];v(null!=r?r+"":null)}else v(null);if(i||f){const r={timestamp:Date.now(),chartType:a||"unknown",chartId:s};if(e){let o=e.data||e.datum||e;Array.isArray(o)&&(o=o[0]);const a=Object.assign(Object.assign({},r),{type:"hover",datum:o||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0});i&&i(a),f&&f(a)}else{const e=Object.assign(Object.assign({},r),{type:"hover-end"});i&&i(e),f&&f(e)}}},[r,g,h,d,i,a,s,f,l,b]),A=t.useCallback(e=>{var t,r,n,o;if("x-position"===(null==h?void 0:h.mode)&&h.xField&&e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const r=null==t?void 0:t[h.xField];null!=r&&Number.isFinite(Number(r))&&function(e,t,r){const n=wr.positions.get(e);if(null==n?void 0:n.locked){const t=new Map(wr.positions);return t.delete(e),wr={positions:t},Sr(),!1}wr={positions:new Map(wr.positions).set(e,{xValue:t,sourceId:r,locked:!0})},Sr()}(h.name||"hover",Number(r),d)}if(e&&c){let n=e.data||e.datum||e;Array.isArray(n)&&(n=n[0]),c(n,{x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(r=e.y)&&void 0!==r?r:0})}if(i||f){const t={timestamp:Date.now(),chartType:a||"unknown",chartId:s};if(e){let r=e.data||e.datum||e;Array.isArray(r)&&(r=r[0]);const a=Object.assign(Object.assign({},t),{type:"click",datum:r||{},x:null!==(n=e.x)&&void 0!==n?n:0,y:null!==(o=e.y)&&void 0!==o?o:0});i&&i(a),f&&f(a)}else{const e=Object.assign(Object.assign({},t),{type:"click-end"});i&&i(e),f&&f(e)}}},[c,i,f,a,s,h,d]);return t.useEffect(()=>{if("x-position"!==(null==h?void 0:h.mode))return;const e=h.name||"hover";return()=>{!function(e,t){const r=wr.positions.get(e);if(!(null==r?void 0:r.locked))return;if(t&&r.sourceId!==t)return;const n=new Map(wr.positions);n.delete(e),wr={positions:n},Sr()}(e,d),Or(e,d)}},[null==h?void 0:h.mode,null==h?void 0:h.name,d]),{activeSelectionHook:p,hoverSelectionHook:x,customHoverBehavior:k,customClickBehavior:A,crosshairSourceId:d}}function Ir(e,r,n){const[o,i]=t.useState(null),[a,s]=t.useState(new Set),c=t.useCallback(t=>{"highlight"===e&&i(t?t.label:null)},[e]),l=t.useCallback(t=>{"isolate"===e&&s(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=t.useMemo(()=>{if(!e||"none"===e||!r)return null;const t="string"==typeof r?r:null;return"highlight"===e&&null!=o?{isActive:!0,predicate:e=>(t?e[t]:"function"==typeof r?r(e):null)===o}:"isolate"===e&&a.size>0?{isActive:!0,predicate:e=>{const n=t?e[t]:"function"==typeof r?r(e):null;return a.has(n)}}:null},[e,r,o,a]);return{highlightedCategory:"highlight"===e?o:null,isolatedCategories:"isolate"===e?a:new Set,onLegendHover:c,onLegendClick:l,legendSelectionHook:u}}d.createContext(void 0);const _r={primary:{width:600,height:400,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:void 0,showLabels:void 0,marginDefaults:{top:50,bottom:60,left:70,right:40}},context:{width:400,height:250,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:10,bottom:10,left:10,right:10}},sparkline:{width:120,height:24,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:2,bottom:2,left:0,right:0}}};function Tr(e,t,r){var n,o,i,a,s,c,l;const u=_r[e||"primary"],d="context"===e||"sparkline"===e;return{width:null!==(n=t.width)&&void 0!==n?n:e&&"primary"!==e||!(null==r?void 0:r.width)?u.width:r.width,height:null!==(o=t.height)&&void 0!==o?o:e&&"primary"!==e||!(null==r?void 0:r.height)?u.height:r.height,showAxes:null!==(i=t.showAxes)&&void 0!==i?i:u.showAxes,showGrid:null!==(a=t.showGrid)&&void 0!==a?a:u.showGrid,enableHover:null!==(s=t.enableHover)&&void 0!==s?s:!!t.linkedHover||u.enableHover,showLegend:null!==(c=t.showLegend)&&void 0!==c?c:u.showLegend,showLabels:null!==(l=t.showLabels)&&void 0!==l?l:u.showLabels,title:d?void 0:t.title,description:t.description,summary:t.summary,accessibleTable:t.accessibleTable,xLabel:d?void 0:t.xLabel,yLabel:d?void 0:t.yLabel,categoryLabel:d?void 0:t.categoryLabel,valueLabel:d?void 0:t.valueLabel,marginDefaults:Nr(u.marginDefaults,t.showCategoryTicks,t.orientation),compactMode:d}}function Nr(e,t,r){if(!1!==t)return e;const n=Object.assign({},e);return"horizontal"===r?n.left=Math.min(n.left,15):n.bottom=Math.min(n.bottom,15),n}function Rr(e,t){if(!function(e){return void 0!==e.stroke||void 0!==e.strokeWidth||void 0!==e.opacity}(t))return null!=e?e:()=>({});const r={};return void 0!==t.stroke&&(r.stroke=t.stroke),void 0!==t.strokeWidth&&(r.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(r.opacity=t.opacity),e?(...t)=>{const n=e(...t)||{};return Object.assign(Object.assign({},n),r)}:(...e)=>Object.assign({},r)}function Wr({componentName:t,message:r,diagnosticHint:n,width:o,height:i}){return e.jsx("div",{role:"alert",style:{width:o,height:Math.max(i,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:e.jsxs("div",{style:{textAlign:"center",maxWidth:400},children:[e.jsx("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"},children:t}),e.jsx("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5},children:r}),n&&e.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})]})})}class $r extends d.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){var r,n;null===(n=(r=this.props).onError)||void 0===n||n.call(r,e,t)}render(){if(this.state.error){const{fallback:t}=this.props,r=this.state.error;return"function"==typeof t?t(r):void 0!==t?t:e.jsx(Wr,{componentName:"ChartErrorBoundary",message:r.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}function Br(e,t){const r=e.length,n=t.length,o=Array(n+1);for(let e=0;n>=e;e++)o[e]=e;for(let i=1;r>=i;i++){let r=o[0];o[0]=i;for(let a=1;n>=a;a++){const n=o[a];o[a]=e[i-1]===t[a-1]?r:1+Math.min(r,o[a],o[a-1]),r=n}}return o[n]}function zr(e,t,r=3){let n,o=r+1;for(const r of t){const t=Br(e.toLowerCase(),r.toLowerCase());o>t&&(o=t,n=r)}return o>r?void 0:n}function Hr(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:e}function Fr(e,t){var r;if(0===t.length)return null;const n=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(n)||n.includes(e.toLowerCase()))||(null!==(r=zr(e,t,3))&&void 0!==r?r:null)}function Yr({componentName:e,data:t,dataLabel:r="data"}){return null==t?`${e}: No ${r} provided. Pass a hierarchical object with children: { name: "root", children: [...] }.`:Array.isArray(t)?`${e}: ${r} 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 qr({componentName:e,nodes:t,edges:r,nodesRequired:n=!1,edgesRequired:o=!0,accessors:i}){if(null==t&&null==r)return null;if(o&&(!r||!Array.isArray(r)||0===r.length))return e+': No edges provided. Pass a non-empty array: edges={[{ source: "A", target: "B", value: 10 }, ...]}.';if(n&&(!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 r=Hr(t).find(e=>e&&"object"==typeof e);if(r){const t=Object.keys(r);for(const[n,o]of Object.entries(i))if(o&&"string"==typeof o&&!(o in r)){const r=Fr(o,t),i=r?` Try ${n}="${r}".`:"";return`${e}: ${n} "${o}" not found in node data. Available fields: ${t.join(", ")}.${i}`}}}return null}const Gr={width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},frameProps:{type:"object"},onClick:{type:"function"}},Xr={xLabel:{type:"string"},yLabel:{type:"string"},xFormat:{type:"function"},yFormat:{type:"function"}},Vr={categoryLabel:{type:"string"},valueLabel:{type:"string"},valueFormat:{type:"function"},categoryFormat:{type:"function"}},Kr=["linear","monotoneX","monotoneY","step","stepAfter","stepBefore","basis","cardinal","catmullRom"],Ur=["vertical","horizontal"],Zr={LineChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Gr),Xr),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},lineBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:Kr},lineWidth:{type:"number"},showPoints:{type:"boolean"},pointRadius:{type:"number"},fillArea:{type:"boolean"},areaOpacity:{type:"number"}})},AreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Gr),Xr),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:Kr},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"}})},StackedAreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Gr),Xr),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:Kr},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"},normalize:{type:"boolean"}})},Scatterplot:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Gr),Xr),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"}})},BubbleChart:{required:["data","sizeBy"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Gr),Xr),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},bubbleOpacity:{type:"number"},bubbleStrokeWidth:{type:"number"},bubbleStrokeColor:{type:"string"}})},Heatmap:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Gr),Xr),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},colorScheme:{type:"string",enum:["blues","reds","greens","viridis","custom"]},customColorScale:{type:["object","function"]},showValues:{type:"boolean"},valueFormat:{type:"function"},cellBorderColor:{type:"string"},cellBorderWidth:{type:"number"},showLegend:{type:"boolean"},legendPosition:{type:"string",enum:["right","left","top","bottom"]}})},QuadrantChart:{required:["quadrants"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Gr),Xr),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},quadrants:{type:"object"},xCenter:{type:"number"},yCenter:{type:"number"},centerlineStyle:{type:"object"},showQuadrantLabels:{type:"boolean"},quadrantLabelSize:{type:"number"},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"}})},MultiAxisLineChart:{required:["series"],dataShape:"array",dataAccessors:["xAccessor"],props:Object.assign(Object.assign(Object.assign({},Gr),Xr),{data:{type:"array"},xAccessor:{type:["string","function"]},series:{type:"array"},colorScheme:{type:["string","array"]},curve:{type:"string"},lineWidth:{type:"number"},annotations:{type:"array"}})},CandlestickChart:{required:["highAccessor","lowAccessor"],dataShape:"array",dataAccessors:["xAccessor","highAccessor","lowAccessor"],props:Object.assign(Object.assign(Object.assign({},Gr),Xr),{data:{type:"array"},xAccessor:{type:["string","function"]},highAccessor:{type:["string","function"]},lowAccessor:{type:["string","function"]},openAccessor:{type:["string","function"]},closeAccessor:{type:["string","function"]},candlestickStyle:{type:"object"},mode:{type:"string",enum:["primary","context","sparkline"]},annotations:{type:"array"}})},ConnectedScatterplot:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Gr),Xr),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},orderAccessor:{type:["string","function"]},orderLabel:{type:"string"},pointRadius:{type:"number"},pointIdAccessor:{type:["string","function"]},annotations:{type:"array"}})},BarChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Gr),Vr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Ur},sort:{type:["boolean","string","function"]},barPadding:{type:"number"},roundedTop:{type:"number"}})},StackedBarChart:{required:["data","stackBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Gr),Vr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},stackBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Ur},normalize:{type:"boolean"},sort:{type:["boolean","string","function"]},barPadding:{type:"number"},roundedTop:{type:"number"}})},LikertChart:{required:["levels"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor","levelAccessor","countAccessor"],props:Object.assign(Object.assign(Object.assign({},Gr),Vr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},levelAccessor:{type:["string","function"]},countAccessor:{type:["string","function"]},levels:{type:"array"},orientation:{type:"string",enum:Ur},barPadding:{type:"number"}})},GroupedBarChart:{required:["data","groupBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Gr),Vr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},groupBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Ur},sort:{type:["boolean","string","function"]},barPadding:{type:"number"},roundedTop:{type:"number"}})},SwarmPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Gr),Vr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Ur},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"},categoryPadding:{type:"number"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}})},BoxPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Gr),Vr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Ur},showOutliers:{type:"boolean"},outlierRadius:{type:"number"},categoryPadding:{type:"number"}})},Histogram:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Gr),Vr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},bins:{type:"number"},relative:{type:"boolean"},categoryPadding:{type:"number"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}})},ViolinPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Gr),Vr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Ur},bins:{type:"number"},curve:{type:"string"},showIQR:{type:"boolean"},categoryPadding:{type:"number"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}})},RidgelinePlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Gr),Vr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},bins:{type:"number"},amplitude:{type:"number"},categoryPadding:{type:"number"}})},DotPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Gr),Vr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Ur},sort:{type:["boolean","string","function"]},dotRadius:{type:"number"},categoryPadding:{type:"number"}})},PieChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},Gr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},startAngle:{type:"number"},cornerRadius:{type:"number"}})},DonutChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},Gr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},innerRadius:{type:"number"},centerContent:{type:["object","string","number"]},startAngle:{type:"number"},cornerRadius:{type:"number"}})},GaugeChart:{required:["value"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},Gr),{value:{type:"number"},min:{type:"number"},max:{type:"number"},thresholds:{type:"array"},arcWidth:{type:"number"},sweep:{type:"number"},showNeedle:{type:"boolean"},needleColor:{type:"string"},centerContent:{type:["object","string","number","function"]},valueFormat:{type:"function"},showScaleLabels:{type:"boolean"},backgroundColor:{type:"string"}})},FunnelChart:{required:["data"],dataShape:"array",dataAccessors:["stepAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Gr),Vr),{data:{type:"array"},stepAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},orientation:{type:"string",enum:["horizontal","vertical"]},connectorOpacity:{type:"number"},showCategoryTicks:{type:"boolean"},responsiveWidth:{type:"boolean"},legendPosition:{type:"string",enum:["right","left","top","bottom"]}})},SwimlaneChart:{required:["subcategoryAccessor"],dataShape:"array",dataAccessors:["categoryAccessor","subcategoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Gr),Vr),{data:{type:"array"},categoryAccessor:{type:["string","function"]},subcategoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:["horizontal","vertical"]},barPadding:{type:"number"},showCategoryTicks:{type:"boolean"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]},responsiveWidth:{type:"boolean"},legendPosition:{type:"string",enum:["right","left","top","bottom"]}})},ForceDirectedGraph:{required:["nodes","edges"],dataShape:"network",dataAccessors:["nodeIDAccessor","sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},Gr),{nodes:{type:"array"},edges:{type:"array"},nodeIDAccessor:{type:["string","function"]},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},nodeLabel:{type:["string","function"]},nodeSize:{type:["number","string","function"]},nodeSizeRange:{type:"array"},edgeWidth:{type:["number","string","function"]},edgeColor:{type:"string"},edgeOpacity:{type:"number"},iterations:{type:"number"},forceStrength:{type:"number"},showLabels:{type:"boolean"}})},SankeyDiagram:{required:["edges"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},Gr),{nodes:{type:"array"},edges:{type:"array"},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},edgeColorBy:{type:["string","function"],enum:["source","target","gradient"]},orientation:{type:"string",enum:Ur},nodeAlign:{type:"string",enum:["justify","left","right","center"]},nodePaddingRatio:{type:"number"},nodeWidth:{type:"number"},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},edgeOpacity:{type:"number"},edgeSort:{type:"function"}})},ChordDiagram:{required:["edges"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},Gr),{nodes:{type:"array"},edges:{type:"array"},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},edgeColorBy:{type:["string","function"],enum:["source","target"]},padAngle:{type:"number"},groupWidth:{type:"number"},sortGroups:{type:"function"},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},edgeOpacity:{type:"number"}})},TreeDiagram:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},Gr),{data:{type:"object"},layout:{type:"string",enum:["tree","cluster","partition","treemap","circlepack"]},orientation:{type:"string",enum:["vertical","horizontal","radial"]},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},edgeStyle:{type:"string",enum:["line","curve"]},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},nodeSize:{type:"number"}})},Treemap:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},Gr),{data:{type:"object"},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},showLabels:{type:"boolean"},nodeLabel:{type:["string","function"]}})},CirclePack:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},Gr),{data:{type:"object"},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},showLabels:{type:"boolean"},nodeLabel:{type:["string","function"]},circleOpacity:{type:"number"}})},OrbitDiagram:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},Gr),{data:{type:"object"},childrenAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},orbitMode:{type:["string","array"]},speed:{type:"number"},revolution:{type:"function"},eccentricity:{type:["number","function"]},orbitSize:{type:["number","function"]},nodeRadius:{type:["number","function"]},showRings:{type:"boolean"},showLabels:{type:"boolean"},animated:{type:"boolean"},colorByDepth:{type:"boolean"},annotations:{type:"array"},foregroundGraphics:{type:"object"}})},RealtimeLineChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},stroke:{type:"string"},strokeWidth:{type:"number"},strokeDasharray:{type:"string"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeHistogram:{required:["binSize"],dataShape:"realtime",dataAccessors:[],props:{binSize:{type:"number"},size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},colors:{type:"object"},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},fill:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},gap:{type:"number"},brush:{type:["boolean","string","object"]},onBrush:{type:"function"},linkedBrush:{type:["string","object"]},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeSwarmChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},colors:{type:"object"},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},radius:{type:"number"},fill:{type:"string"},opacity:{type:"number"},stroke:{type:"string"},strokeWidth:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeWaterfallChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},positiveColor:{type:"string"},negativeColor:{type:"string"},connectorStroke:{type:"string"},connectorWidth:{type:"number"},gap:{type:"number"},stroke:{type:"string"},strokeWidth:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeHeatmap:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},heatmapXBins:{type:"number"},heatmapYBins:{type:"number"},aggregation:{type:"string",enum:["count","sum","mean"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"}}},ScatterplotMatrix:{required:["data","fields"],dataShape:"array",dataAccessors:[],props:Object.assign(Object.assign({},Gr),{data:{type:"array"},fields:{type:"array"}})},MinimapChart:{required:["data"],dataShape:"array",dataAccessors:[],props:Object.assign(Object.assign({},Gr),{data:{type:"array"}})},ChoroplethMap:{required:["areas"],dataShape:"array",dataAccessors:["valueAccessor"],props:Object.assign(Object.assign({},Gr),{areas:{type:["array","string"]},valueAccessor:{type:["string","function"]},colorScheme:{type:["string","array"]},projection:{type:"string"}})},ProportionalSymbolMap:{required:["points"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign({},Gr),{points:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},areas:{type:["array","string"]}})},FlowMap:{required:["flows"],dataShape:"array",dataAccessors:[],props:Object.assign(Object.assign({},Gr),{flows:{type:"array"},nodes:{type:"array"},valueAccessor:{type:["string","function"]}})},DistanceCartogram:{required:["points"],dataShape:"array",dataAccessors:[],props:Object.assign(Object.assign({},Gr),{points:{type:"array"},center:{type:"array"},costAccessor:{type:["string","function"]}})}};function Qr(e,t){return(Array.isArray(t)?t:[t]).includes(Array.isArray(e)?"array":typeof e)}const Jr=new Set(["TreeDiagram","Treemap","CirclePack","OrbitDiagram"]),en=new Set(["ForceDirectedGraph","SankeyDiagram","ChordDiagram"]),tn=new Set(["BarChart","StackedBarChart","GroupedBarChart","AreaChart","StackedAreaChart"]),rn=new Set(["LineChart","AreaChart","StackedAreaChart"]),nn=new Set(["BarChart","StackedBarChart","GroupedBarChart","FunnelChart"]);function on(e){const t=e.match(/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i);if(!t)return null;const[r,n,o]=[parseInt(t[1],16)/255,parseInt(t[2],16)/255,parseInt(t[3],16)/255],i=e=>e>.03928?Math.pow((e+.055)/1.055,2.4):e/12.92;return.2126*i(r)+.7152*i(n)+.0722*i(o)}function an(e,t){const r=on(e),n=on(t);return null===r||null===n?null:(Math.max(r,n)+.05)/(Math.min(r,n)+.05)}const sn=["xAccessor","yAccessor","timeAccessor","valueAccessor","categoryAccessor","colorBy","sizeBy","lineBy","areaBy","stackBy","groupBy","orderAccessor","y0Accessor","sourceAccessor","targetAccessor","nodeIDAccessor","childrenAccessor","costAccessor"];function cn(e,t){const r=[],n=function(e,t){const r=[],n=Zr[e];if(!n)return{valid:!1,errors:[`Unknown component "${e}". Valid components: ${Object.keys(Zr).join(", ")}`]};for(const o of n.required)null==t[o]&&r.push(`"${o}" is required for ${e}.`);for(const[e,o]of Object.entries(t)){if(null==o)continue;const t=n.props[e];if(t){if(!Qr(o,t.type)){const n=Array.isArray(t.type)?t.type.join(" | "):t.type;r.push(`"${e}" should be ${n}, got ${Array.isArray(o)?"array":typeof o}.`);continue}t.enum&&"string"==typeof o&&!t.enum.includes(o)&&r.push(`"${e}" value "${o}" is not valid. Expected one of: ${t.enum.join(", ")}.`)}}const o=Object.keys(n.props),i=new Set(o);for(const n of Object.keys(t))if(void 0!==t[n]&&!i.has(n)){const t=zr(n,o),i=t?`Unknown prop "${n}" for ${e}. Did you mean "${t}"?`:`Unknown prop "${n}" for ${e}. Valid props: ${o.join(", ")}.`;r.push(i)}if("array"===n.dataShape){const o=t.data,i={};for(const e of n.dataAccessors){const r=t[e];"string"==typeof r&&(i[e]=r)}const a=function({componentName:e,data:t,accessors:r,requiredProps:n}){if(n)for(const[t,r]of Object.entries(n))if(null==r)return`${e}: ${t} is required. Provide a field name or function.`;if(null==t)return null;if(!Array.isArray(t)||0===t.length)return e+": No data provided. Pass a non-empty array to the data prop.";if(!Array.isArray(t)&&"object"==typeof t)return e+": data should be an array, but received an object. If this is hierarchical data, use TreeDiagram, Treemap, or CirclePack instead.";if(r){const n=Hr(t).find(e=>e&&"object"==typeof e);if(n){const t=Object.keys(n);for(const[o,i]of Object.entries(r))if(i&&"string"==typeof i&&!(i in n)){const r=Fr(i,t),n=r?` Try ${o}="${r}".`:"";return`${e}: ${o} "${i}" not found in data. Available fields: ${t.join(", ")}.${n}`}}}return null}({componentName:e,data:o,accessors:Object.keys(i).length>0?i:void 0});a&&r.push(a)}else if("object"===n.dataShape){const n=Yr({componentName:e,data:t.data});n&&r.push(n)}else if("network"===n.dataShape){const o=qr({componentName:e,nodes:t.nodes,edges:t.edges,nodesRequired:n.required.includes("nodes"),edgesRequired:n.required.includes("edges")});o&&r.push(o)}return{valid:0===r.length,errors:r}}(e,t);for(const e of n.errors)r.push({severity:"error",code:"VALIDATION",message:e,fix:""});return Zr[e]?(function(e,t,r){const n=Zr[e];if(n){if("array"===n.dataShape){const e=t.data;e&&Array.isArray(e)&&0===e.length&&r.push({severity:"error",code:"EMPTY_DATA",message:"data is an empty array — chart will render blank.",fix:"Provide at least one data point: data={[{ x: 1, y: 2 }]}."})}"network"===n.dataShape&&t.edges&&Array.isArray(t.edges)&&0===t.edges.length&&r.push({severity:"error",code:"EMPTY_EDGES",message:"edges is an empty array — network chart will render blank.",fix:'Provide at least one edge: edges={[{ source: "A", target: "B" }]}.'})}}(e,t,r),function(e,t,r){const n=t.width,o=t.height;if(void 0===n||"number"==typeof n&&n>0||r.push({severity:"error",code:"BAD_WIDTH",message:`width=${JSON.stringify(n)} — chart needs a positive number.`,fix:"Set width={600} or use responsiveWidth={true}."}),void 0===o||"number"==typeof o&&o>0||r.push({severity:"error",code:"BAD_HEIGHT",message:`height=${JSON.stringify(o)} — chart needs a positive number.`,fix:"Set height={400} or use responsiveHeight={true}."}),t.size&&Array.isArray(t.size)){const[e,n]=t.size;(null!=e&&0>=e||null!=n&&0>=n)&&r.push({severity:"error",code:"BAD_SIZE",message:`size=[${e}, ${n}] — both dimensions must be positive.`,fix:"Set size={[600, 400]}."})}}(0,t,r),function(e,t,r){const n=Zr[e];if(!n||"array"!==n.dataShape)return;const o=t.data;if(!o||!Array.isArray(o)||0===o.length)return;const i=o[0];if(!i||"object"!=typeof i)return;const a=Object.keys(i);for(const e of n.dataAccessors){const n=t[e];"string"==typeof n&&(n in i||r.push({severity:"error",code:"ACCESSOR_MISSING",message:`${e}="${n}" not found in data. Available fields: ${a.join(", ")}.`,fix:`Change ${e} to one of: ${a.map(e=>`"${e}"`).join(", ")}.`}))}}(e,t,r),function(e,t,r){Jr.has(e)&&Array.isArray(t.data)&&r.push({severity:"error",code:"HIERARCHY_FLAT_ARRAY",message:e+" expects hierarchical data but received a flat array.",fix:'Pass a root object: data={{ name: "root", children: [...] }}. For flat data, use BarChart or LineChart.'})}(e,t,r),function(e,t,r){en.has(e)&&(t.edges||t.data||r.push({severity:"error",code:"NETWORK_NO_EDGES",message:e+" requires an edges prop.",fix:'Provide edges={[{ source: "A", target: "B", value: 10 }]}.'}))}(e,t,r),function(e,t,r){const n=Zr[e];if(!n||"array"!==n.dataShape)return;const o=t.data;if(!o||!Array.isArray(o)||0===o.length)return;const i=o[0];if(!i||"object"!=typeof i)return;const a=t.xAccessor;"string"==typeof a&&i[a]instanceof Date&&!t.xFormat&&r.push({severity:"warning",code:"DATE_NO_FORMAT",message:`xAccessor "${a}" contains Date objects but no xFormat is provided. Axis ticks may display "[object Object]".`,fix:"Add xFormat={d => d.toLocaleDateString()} or use timestamps (d.getTime()) instead of Date objects."})}(e,t,r),function(e,t,r){t.linkedHover&&!t.selection&&r.push({severity:"warning",code:"LINKED_HOVER_NO_SELECTION",message:"linkedHover is set but selection is not — this chart emits hover events but won't highlight from others.",fix:`Add selection={{ name: "${"object"==typeof t.linkedHover&&t.linkedHover.name||"hl"}" }} to receive cross-highlights.`})}(0,t,r),function(e,t,r){var n;if(!tn.has(e))return;const o=t.rExtent||t.yExtent;o&&Array.isArray(o)&&o.length>=1&&null!=o[0]&&0!==o[0]&&r.push({severity:"warning",code:"NON_ZERO_BASELINE",message:`${e} has a non-zero baseline (${o[0]}). Bar and area charts should start at zero to avoid exaggerating differences.`,fix:`Remove the custom extent minimum or set it to 0: rExtent={[0, ${null!==(n=o[1])&&void 0!==n?n:"auto"}]}. For trend-focused charts, use LineChart instead.`})}(e,t,r),function(e,t,r){if(!rn.has(e))return;if(t.gapStrategy)return;const n=t.data;if(!n||!Array.isArray(n)||0===n.length)return;const o=t.yAccessor||"y";"string"==typeof o&&n.some(e=>{const t=e[o];return null==t||Number.isNaN(t)})&&r.push({severity:"warning",code:"DATA_GAPS",message:`Data contains null/undefined/NaN values in "${o}". Default behavior breaks the line at gaps.`,fix:'Set gapStrategy="break" (default), "interpolate", or "zero" to control gap handling.'})}(e,t,r),function(e,t,r){var n,o;const i=null!==(n=t.width)&&void 0!==n?n:600,a=null!==(o=t.height)&&void 0!==o?o:400,s=t.margin;if(!s||"object"!=typeof s)return;const c=(s.left||0)+(s.right||0),l=(s.top||0)+(s.bottom||0);i>c||r.push({severity:"error",code:"MARGIN_OVERFLOW_H",message:`Horizontal margins (${c}px) >= width (${i}px) — no drawing area left.`,fix:"Reduce margin.left/right or increase width."}),a>l||r.push({severity:"error",code:"MARGIN_OVERFLOW_V",message:`Vertical margins (${l}px) >= height (${a}px) — no drawing area left.`,fix:"Reduce margin.top/bottom or increase height."})}(0,t,r),function(e,t,r){var n;const o=Zr[e];if(!o||"array"!==o.dataShape)return;const i=t.data;if(!i||!Array.isArray(i)||0===i.length)return;const a=[];t.xAccessor&&"string"==typeof t.xAccessor&&a.push({prop:"xAccessor",name:t.xAccessor}),t.yAccessor&&"string"==typeof t.yAccessor&&a.push({prop:"yAccessor",name:t.yAccessor}),t.valueAccessor&&"string"==typeof t.valueAccessor&&a.push({prop:"valueAccessor",name:t.valueAccessor});const s=Math.min(i.length,5);for(const e of a){let t=!0;for(let r=0;s>r;r++){const o=null===(n=i[r])||void 0===n?void 0:n[e.name];if("number"==typeof o&&Number.isFinite(o)){t=!1;break}}t&&r.push({severity:"error",code:"DEGENERATE_EXTENT",message:`${e.prop}="${e.name}" produces NaN or non-finite values for all sampled data points — chart extents will be invalid.`,fix:`Ensure data[].${e.name} contains finite numbers, or use a function accessor to transform values.`})}}(e,t,r),function(e,t,r){if(!nn.has(e))return;const n=t.barPadding;"number"==typeof n&&10>n&&r.push({severity:"warning",code:"BAR_PADDING_INVISIBLE",message:`barPadding=${n} is very small — bars may appear to have no spacing between them.`,fix:"Increase barPadding to at least 10 for visible gaps, e.g. barPadding={12}."})}(e,t,r),function(e,t,r){if("bottom"!==t.legendPosition)return;const n=t.margin;if(!n||"object"!=typeof n)return;const o=n.bottom;"number"==typeof o&&70>o&&r.push({severity:"warning",code:"BOTTOM_MARGIN_WITH_LEGEND",message:`legendPosition="bottom" with margin.bottom=${o}px — legend may overlap axis labels.`,fix:"Increase margin.bottom to at least 70, e.g. margin={{ ...margin, bottom: 80 }}."})}(0,t,r),function(e,t,r){var n;if(!t.showLegend)return;if("right"!==(null!==(n=t.legendPosition)&&void 0!==n?n:"right"))return;const o=t.margin;if(!o||"object"!=typeof o)return;const i=o.right;"number"==typeof i&&100>i&&r.push({severity:"warning",code:"LEGEND_MARGIN_TIGHT",message:`showLegend is true with legendPosition="right" but margin.right=${i}px — legend may be clipped or overlap the chart.`,fix:"Increase margin.right to at least 100, e.g. margin={{ ...margin, right: 120 }}."})}(0,t,r),function(e,t,r){if("Heatmap"!==e)return;const n=t.data;if(!n||!Array.isArray(n)||0===n.length)return;const o=n[0];if(o&&"object"==typeof o)for(const e of["xAccessor","yAccessor"]){const n=t[e];if("string"!=typeof n)continue;const i=o[n];"string"==typeof i&&r.push({severity:"warning",code:"HEATMAP_STRING_ACCESSOR",message:`${e}="${n}" resolves to string values (e.g. "${i}"). Heatmap will use categorical axis handling which may produce unexpected cell layout.`,fix:"If you intend categorical axes this is fine. Otherwise, convert values to numbers before passing data."})}}(e,t,r),function(e,t,r){const n=t.colorScheme;if(!n||!Array.isArray(n))return;const o="string"==typeof t.background?t.background:"#ffffff";if(!o.startsWith("#"))return;const i=[];for(const e of n){if("string"!=typeof e||!e.startsWith("#"))continue;const t=an(e,o);null!==t&&3>t&&i.push(`${e} (${t.toFixed(1)}:1)`)}i.length>0&&r.push({severity:"warning",code:"LOW_COLOR_CONTRAST",message:`${i.length} color(s) in colorScheme have < 3:1 contrast against background "${o}": ${i.join(", ")}. Data marks may be hard to see.`,fix:'Use darker colors on light backgrounds or lighter colors on dark backgrounds. Import COLOR_BLIND_SAFE_CATEGORICAL from "semiotic" for an accessible preset.'})}(0,t,r),function(e,t,r){const n=t.colorScheme;if(!n||!Array.isArray(n)||2>n.length)return;const o=n.filter(e=>"string"==typeof e&&e.startsWith("#"));if(2>o.length)return;const i=[];for(let e=0;o.length-1>e;e++){const t=an(o[e],o[e+1]);null!==t&&1.5>t&&i.push(`${o[e]} / ${o[e+1]} (${t.toFixed(1)}:1)`)}i.length>0&&r.push({severity:"warning",code:"LOW_ADJACENT_CONTRAST",message:`${i.length} adjacent color pair(s) in colorScheme have very similar luminance: ${i.join("; ")}. Categories may be hard to distinguish.`,fix:'Alternate light and dark colors in the scheme, or use COLOR_BLIND_SAFE_CATEGORICAL from "semiotic" for a pre-tested palette.'})}(0,t,r),function(e,t,r){const n="string"==typeof t.title&&t.title.trim().length>0,o="string"==typeof t.description&&t.description.trim().length>0,i="string"==typeof t.summary&&t.summary.trim().length>0;n||o||i||r.push({severity:"warning",code:"MISSING_DESCRIPTION",message:'No title, description, or summary provided. Screen readers will use a generic label like "XY chart".',fix:'Add a title="..." prop for a brief label, or description="..." for a detailed aria-label, or summary="..." for a screen-reader-only note describing the chart\'s purpose.'})}(0,t,r),function(e,t,r){const n=[];for(const e of sn)"function"==typeof t[e]&&n.push(e);n.length>0&&r.push({severity:"warning",code:"FUNCTION_ACCESSOR",message:`Function accessor${n.length>1?"s":""} detected: ${n.join(", ")}. If defined inline (e.g. \`xAccessor={d => d.value}\`), every parent re-render creates a new reference which may trigger unnecessary scene rebuilds.`,fix:'Use string accessors when possible (e.g. xAccessor="value"), or memoize with useCallback / define outside the component.'})}(0,t,r),{ok:r.every(e=>"warning"===e.severity),diagnoses:r}):{ok:0===r.length,diagnoses:r}}var ln;const un="undefined"!=typeof process&&"production"!==(null===(ln=process.env)||void 0===ln?void 0:ln.NODE_ENV);function dn({componentName:t,width:r,height:n,chartProps:o,children:i}){return e.jsx($r,{fallback:i=>{let a="";if(un&&o)try{const e=cn(t,o);e.ok||(a=e.diagnoses.map(e=>`${"error"===e.severity?"✗":"⚠"} ${e.message}${e.fix?" — Fix: "+e.fix:""}`).join("\n"))}catch(e){}return e.jsx(Wr,{componentName:t,message:i.message,diagnosticHint:a,width:r,height:n})},children:i})}const hn={display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #999)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"},yn={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function gn(t,r,n,o){return!1===o||null==t||Array.isArray(t)&&t.length>0?null:Array.isArray(t)?e.jsx("div",{style:Object.assign(Object.assign({},hn),{width:r,height:n}),children:o||"No data available"}):null}function fn(t,r,n){if(!t)return null;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 e.jsx("div",{style:{width:r,height:n,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"},children:Array.from({length:o},(t,n)=>e.jsx("div",{className:"semiotic-loading-bar",style:Object.assign(Object.assign({},yn),{position:"absolute",top:s+n*(i+a),left:Math.floor(.1*r),width:30+(37*n+13)%50+"%",height:i,opacity:.5+n%2*.2})},n))})}const pn=t.forwardRef(function(r,n){var o;const i=t.useRef(null);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,r,n,o,a;const s=Array.isArray(e)?e:[e],c=null!==(n=null===(r=null===(t=i.current)||void 0===t?void 0:t.getTopology())||void 0===r?void 0:r.nodes)&&void 0!==n?n:[],l=[];for(const e of s){const t=c.find(t=>t.id===e);t&&l.push(Object.assign(Object.assign({},null!==(o=t.data)&&void 0!==o?o:{}),{id:e})),null===(a=i.current)||void 0===a||a.removeNode(e)}return l},update:(e,t)=>(Array.isArray(e)?e:[e]).flatMap(e=>{var r;const n=null===(r=i.current)||void 0===r?void 0:r.updateNode(e,t);return n?[Object.assign(Object.assign({},n),{id:e})]:[]}),clear:()=>{var e;return null===(e=i.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t,r,n;return null!==(n=null===(r=null===(t=null===(e=i.current)||void 0===e?void 0:e.getTopology())||void 0===t?void 0:t.nodes)||void 0===r?void 0:r.map(e=>e.data))&&void 0!==n?n:[]}}));const a=Tr(r.mode,{width:r.width,height:r.height,enableHover:r.enableHover,showLegend:r.showLegend,showLabels:r.showLabels,title:r.title,description:r.description,accessibleTable:r.accessibleTable,summary:r.summary},{width:600,height:600}),{nodes:s,edges:c,margin:l,className:u,nodeIDAccessor:d="id",sourceAccessor:h="source",targetAccessor:y="target",nodeLabel:g,colorBy:f,colorScheme:p,nodeSize:m=8,nodeSizeRange:v=[5,20],edgeWidth:b=1,edgeColor:x="#999",edgeOpacity:k=.6,iterations:A=300,forceStrength:w=.1,tooltip:j,frameProps:S={},onObservation:O,onClick:L,chartId:C,selection:M,linkedHover:D,loading:E,emptyContent:P,legendInteraction:I,legendPosition:_,stroke:T,strokeWidth:N,opacity:R}=r,W=a.width,$=a.height,B=a.enableHover,z=a.showLegend,H=null!==(o=a.showLabels)&&void 0!==o&&o,F=a.title,Y=a.description,q=a.summary,G=a.accessibleTable,X=fn(E,W,$),V=X?null:gn(s,W,$,P),K=s||[],U=c||[],Z=Er(K,f,p),Q=t.useMemo(()=>{if(!f)return[];const e=new Set;for(const t of K){const r="function"==typeof f?f(t):t[f];null!=r&&e.add(r+"")}return Array.from(e)},[K,f]),J=Ir(I,f,Q),ee=Mr(),te=t.useMemo(()=>new Map,[]),re=t.useMemo(()=>{if(Array.isArray(p))return p;if(ee&&ee.length>0)return ee;const e=Zt[p];return Array.isArray(e)?e:Qt},[p,ee]),ne=t.useMemo(()=>e=>{const t={};return t.fill=f?rr(e.data||e,f,Z):Dr(0,ee,p),"number"==typeof m&&(t.r=m),t},[f,Z,m,ee,p,te]),oe=t.useMemo(()=>Rr(ne,{stroke:T,strokeWidth:N,opacity:R}),[ne,T,N,R]),ie=t.useMemo(()=>e=>({stroke:x,strokeWidth:"number"==typeof b?b:"function"==typeof b?b(e):e[b]||1,opacity:k}),[b,x,k]),ae=t.useMemo(()=>Rr(ie,{stroke:T,strokeWidth:N,opacity:R}),[ie,T,N,R]),se=t.useMemo(()=>{if(H&&g)return"function"==typeof g?g:e=>{var t,r,n;return null!==(n=null!==(r=null===(t=e.data)||void 0===t?void 0:t[g])&&void 0!==r?r:e[g])&&void 0!==n?n:e.id}},[H,g]),{legend:ce,margin:le,legendPosition:ue}=function({data:e,colorBy:r,colorScale:n,showLegend:o,legendPosition:i="right",userMargin:a,defaults:s={top:50,bottom:60,left:70,right:40},categories:c}){const l=t.useContext(Cr),u=void 0!==o?o:!l&&!!r,d=t.useMemo(()=>{if(!u||!r)return;const t=function({data:e,colorBy:t,colorScale:r,getColor:n,strokeColor:o,strokeWidth:i,categories:a}){const s=(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?n(a,t,r):r?r(o):Jt[i%Jt.length];return{label:o+"",color:s}});return{legendGroups:[{styleFn:e=>{const t=e.color||"#333",r={fill:t,stroke:t};return void 0!==o&&(r.stroke=o),void 0!==i&&(r.strokeWidth=i),r},type:"fill",items:s,label:""}]}}({data:e,colorBy:r,colorScale:n,getColor:rr,categories:c});return 0!==t.legendGroups.reduce((e,t)=>e+t.items.length,0)?t:void 0},[u,r,e,n,c]),h=t.useMemo(()=>{const e="number"==typeof a?{top:a,bottom:a,left:a,right:a}:null!=a?a:{},t=Object.assign(Object.assign({},s),e);return d&&("right"===i&&110>t.right?t.right=110:"left"===i&&110>t.left?t.left=110:"top"===i&&50>t.top?t.top=50:"bottom"===i&&80>t.bottom&&(t.bottom=80)),t},[s,a,d,i]);return{legend:d,margin:h,legendPosition:i}}({data:K,colorBy:f,colorScale:Z,showLegend:z,legendPosition:_,userMargin:l,defaults:a.marginDefaults}),{customHoverBehavior:de,customClickBehavior:he}=Pr({selection:M,linkedHover:D,fallbackFields:f?["string"==typeof f?f:""]:[],unwrapData:!0,onObservation:O,onClick:L,chartType:"ForceDirectedGraph",chartId:C}),ye=qr({componentName:"ForceDirectedGraph",nodes:s,edges:c,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:d}});return ye?e.jsx(Wr,{componentName:"ForceDirectedGraph",message:ye,width:W,height:$}):X||V||e.jsx(dn,{componentName:"ForceDirectedGraph",width:W,height:$,children:e.jsx(ur,Object.assign({ref:i,chartType:"force"},null!=s&&{nodes:K},null!=c&&{edges:U},{size:[W,$],responsiveWidth:r.responsiveWidth,responsiveHeight:r.responsiveHeight,margin:le,nodeIDAccessor:d,sourceAccessor:h,targetAccessor:y,iterations:A,forceStrength:w,nodeStyle:oe,edgeStyle:ae,colorBy:f,colorScheme:re,nodeSize:m,nodeSizeRange:v,nodeLabel:se,showLabels:H,enableHover:B,tooltipContent:!1===j?()=>null:fr(j)||void 0,customHoverBehavior:D||O||L?de:void 0,customClickBehavior:O||L?he:void 0,legend:ce,legendPosition:ue},I&&"none"!==I&&{legendHoverBehavior:J.onLegendHover,legendClickBehavior:J.onLegendClick,legendHighlightedCategory:J.highlightedCategory,legendIsolatedCategories:J.isolatedCategories},{className:u,title:F,description:Y,summary:q,accessibleTable:G},null!=r.animate&&{animate:r.animate},S))})});function mn(e,t){if(!e)return[];const r=[],n=e=>{r.push(e);const o="function"==typeof t?t(e):e[t];o&&Array.isArray(o)&&o.forEach(n)};return n(e),r}function vn(e,t,r,n){if(e&&e.length>0)return e;const o=new Set;return t.forEach(e=>{const t="function"==typeof r?r(e):e[r],i="function"==typeof n?n(e):e[n];o.add(t),o.add(i)}),Array.from(o).map(e=>({id:e}))}function bn(e){return"function"==typeof e?e:t=>t[e]||1}function xn({edgeColorBy:e,colorBy:t,colorScale:r,nodeStyleFn:n,edgeOpacity:o,baseStyle:i={}}){return a=>{const s=Object.assign({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=rr(e.data||e,t,r):e&&(s.fill=n(e,e.index).fill)}else if("target"===e){const e="object"==typeof a.target?a.target:null;t&&e?s.fill=rr(e.data||e,t,r):e&&(s.fill=n(e,e.index).fill)}else"gradient"===e&&(s.fill="#999",s.fillOpacity=.7*o);return s}}pn.displayName="ForceDirectedGraph";const kn=t.forwardRef(function(r,n){var o;const i=t.useRef(null);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,r,n,o,a;const s=Array.isArray(e)?e:[e],c=null!==(n=null===(r=null===(t=i.current)||void 0===t?void 0:t.getTopology())||void 0===r?void 0:r.nodes)&&void 0!==n?n:[],l=[];for(const e of s){const t=c.find(t=>t.id===e);t&&l.push(Object.assign(Object.assign({},null!==(o=t.data)&&void 0!==o?o:{}),{id:e})),null===(a=i.current)||void 0===a||a.removeNode(e)}return l},update:(e,t)=>(Array.isArray(e)?e:[e]).flatMap(e=>{var r;const n=null===(r=i.current)||void 0===r?void 0:r.updateNode(e,t);return n?[Object.assign(Object.assign({},n),{id:e})]:[]}),clear:()=>{var e;return null===(e=i.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t,r,n;return null!==(n=null===(r=null===(t=null===(e=i.current)||void 0===e?void 0:e.getTopology())||void 0===t?void 0:t.edges)||void 0===r?void 0:r.map(e=>e.data))&&void 0!==n?n:[]}}));const a=Tr(r.mode,{width:r.width,height:r.height,enableHover:r.enableHover,showLabels:r.showLabels,title:r.title,description:r.description,accessibleTable:r.accessibleTable,summary:r.summary},{width:800,height:600}),{nodes:s,edges:c,margin:l,className:u,sourceAccessor:d="source",targetAccessor:h="target",valueAccessor:y="value",nodeIdAccessor:g="id",colorBy:f,colorScheme:p,edgeColorBy:m="source",orientation:v="horizontal",nodeAlign:b="justify",nodePaddingRatio:x=.05,nodeWidth:k=15,nodeLabel:A,edgeOpacity:w=.5,edgeSort:j,tooltip:S,frameProps:O={},onObservation:L,onClick:C,chartId:M,selection:D,linkedHover:E,loading:P,emptyContent:I,legendInteraction:_,stroke:T,strokeWidth:N,opacity:R}=r,W=a.width,$=a.height,B=a.enableHover,z=null===(o=a.showLabels)||void 0===o||o,H=a.title,F=a.description,Y=a.summary,q=a.accessibleTable,G=fn(P,W,$),X=G?null:gn(c,W,$,I),V=c||[],K=t.useMemo(()=>vn(s,V,d,h),[s,V,d,h]),U=Er(K,f,p),Z=t.useMemo(()=>{if(!f)return[];const e=new Set;for(const t of K){const r="function"==typeof f?f(t):t[f];null!=r&&e.add(r+"")}return Array.from(e)},[K,f]),Q=Ir(_,f,Z),J=Mr(),ee=t.useMemo(()=>new Map,[]),te=t.useMemo(()=>{if(Array.isArray(p))return p;if(J&&J.length>0)return J;const e=Zt[p];return Array.isArray(e)?e:Qt},[p,J]),re=t.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=f?rr(e.data||e,f,U):Dr(0,J,p),t},[f,U,J,p,ee]),ne=t.useMemo(()=>Rr(re,{stroke:T,strokeWidth:N,opacity:R}),[re,T,N,R]),oe=t.useMemo(()=>xn({edgeColorBy:m,colorBy:f,colorScale:U,nodeStyleFn:ne,edgeOpacity:w,baseStyle:{stroke:"none",strokeWidth:0}}),[m,f,U,ne,w]),ie=t.useMemo(()=>Rr(oe,{stroke:T,strokeWidth:N,opacity:R}),[oe,T,N,R]),ae=t.useMemo(()=>{if(!z)return;const e=A||g;return"function"==typeof e?e:t=>{var r,n,o;return null!==(o=null!==(n=null===(r=t.data)||void 0===r?void 0:r[e])&&void 0!==n?n:t[e])&&void 0!==o?o:t.id}},[z,A,g]),se=Object.assign(Object.assign({},a.marginDefaults),"number"==typeof l?{top:l,bottom:l,left:l,right:l}:l),{customHoverBehavior:ce,customClickBehavior:le}=Pr({selection:D,linkedHover:E,fallbackFields:f?["string"==typeof f?f:""]:[],unwrapData:!0,onObservation:L,onClick:C,chartType:"SankeyDiagram",chartId:M}),ue=qr({componentName:"SankeyDiagram",edges:c,edgesRequired:!0});return ue?e.jsx(Wr,{componentName:"SankeyDiagram",message:ue,width:W,height:$}):G||X||e.jsx(dn,{componentName:"SankeyDiagram",width:W,height:$,children:e.jsx(ur,Object.assign({ref:i,chartType:"sankey"},K.length>0&&{nodes:K},null!=c&&{edges:V},{size:[W,$],responsiveWidth:r.responsiveWidth,responsiveHeight:r.responsiveHeight,margin:se,nodeIDAccessor:g,sourceAccessor:d,targetAccessor:h,valueAccessor:y,orientation:v,nodeAlign:b,nodePaddingRatio:x,nodeWidth:k,nodeStyle:ne,edgeStyle:ie,colorBy:f,colorScheme:te,edgeColorBy:m,edgeOpacity:w,edgeSort:j,nodeLabel:ae,showLabels:z,enableHover:B,tooltipContent:!1===S?()=>null:fr(S)||void 0,customHoverBehavior:E||L||C?ce:void 0,customClickBehavior:L||C?le:void 0},_&&"none"!==_&&{legendHoverBehavior:Q.onLegendHover,legendClickBehavior:Q.onLegendClick,legendHighlightedCategory:Q.highlightedCategory,legendIsolatedCategories:Q.isolatedCategories},{className:u,title:H,description:F,summary:Y,accessibleTable:q},null!=r.animate&&{animate:r.animate},O))})});kn.displayName="SankeyDiagram";const An=t.forwardRef(function(r,n){var o;const i=t.useRef(null);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,r,n,o,a;const s=Array.isArray(e)?e:[e],c=null!==(n=null===(r=null===(t=i.current)||void 0===t?void 0:t.getTopology())||void 0===r?void 0:r.nodes)&&void 0!==n?n:[],l=[];for(const e of s){const t=c.find(t=>t.id===e);t&&l.push(Object.assign(Object.assign({},null!==(o=t.data)&&void 0!==o?o:{}),{id:e})),null===(a=i.current)||void 0===a||a.removeNode(e)}return l},update:(e,t)=>(Array.isArray(e)?e:[e]).flatMap(e=>{var r;const n=null===(r=i.current)||void 0===r?void 0:r.updateNode(e,t);return n?[Object.assign(Object.assign({},n),{id:e})]:[]}),clear:()=>{var e;return null===(e=i.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t,r,n;return null!==(n=null===(r=null===(t=null===(e=i.current)||void 0===e?void 0:e.getTopology())||void 0===t?void 0:t.edges)||void 0===r?void 0:r.map(e=>e.data))&&void 0!==n?n:[]}}));const a=Tr(r.mode,{width:r.width,height:r.height,enableHover:r.enableHover,showLabels:r.showLabels,title:r.title,description:r.description,accessibleTable:r.accessibleTable,summary:r.summary},{width:600,height:600}),{nodes:s,edges:c,margin:l,className:u,sourceAccessor:d="source",targetAccessor:h="target",valueAccessor:y="value",nodeIdAccessor:g="id",colorBy:f,colorScheme:p,edgeColorBy:m="source",padAngle:v=.01,groupWidth:b=20,sortGroups:x,nodeLabel:k,edgeOpacity:A=.5,tooltip:w,frameProps:j={},onObservation:S,onClick:O,chartId:L,selection:C,linkedHover:M,loading:D,emptyContent:E,legendInteraction:P,stroke:I,strokeWidth:_,opacity:T}=r,N=a.width,R=a.height,W=a.enableHover,$=null===(o=a.showLabels)||void 0===o||o,B=a.title,z=a.description,H=a.summary,F=a.accessibleTable,Y=fn(D,N,R),q=Y?null:gn(c,N,R,E),G=c||[],X=t.useMemo(()=>vn(s,G,d,h),[s,G,d,h]),V=Er(X,f,p),K=t.useMemo(()=>{if(!f)return[];const e=new Set;for(const t of X){const r="function"==typeof f?f(t):t[f];null!=r&&e.add(r+"")}return Array.from(e)},[X,f]),U=Ir(P,f,K),Z=Mr(),Q=t.useMemo(()=>new Map,[]),J=t.useMemo(()=>{if(Array.isArray(p))return p;if(Z&&Z.length>0)return Z;const e=Zt[p];return Array.isArray(e)?e:Qt},[p,Z]),ee=X.length>0,te=t.useMemo(()=>{if(ee)return(e,t)=>{var r,n;const o={stroke:"black",strokeWidth:1};if(f)o.fill=rr(e.data||e,f,V);else{const i=Array.isArray(p)?p:Zt[p]||Qt,a=Array.isArray(i)?i:Qt,s=null!==(n=null!==(r=e.index)&&void 0!==r?r:t)&&void 0!==n?n:0;o.fill=a[s%a.length]}return o}},[ee,f,V,p]),re=t.useMemo(()=>te?Rr(te,{stroke:I,strokeWidth:_,opacity:T}):void 0,[te,I,_,T]),ne=t.useMemo(()=>{if(ee)return xn({edgeColorBy:m,colorBy:f,colorScale:V,nodeStyleFn:re||(e=>({fill:Dr(0,Z,p)})),edgeOpacity:A,baseStyle:{stroke:"black",strokeWidth:.5,strokeOpacity:A}})},[ee,m,f,V,re,A,Z,p,Q]),oe=t.useMemo(()=>ne?Rr(ne,{stroke:I,strokeWidth:_,opacity:T}):void 0,[ne,I,_,T]),ie=t.useMemo(()=>{if(!$)return;const e=k||g;return"function"==typeof e?e:t=>{var r,n,o;return null!==(o=null!==(n=null===(r=t.data)||void 0===r?void 0:r[e])&&void 0!==n?n:t[e])&&void 0!==o?o:t.id}},[$,k,g]),ae=Object.assign(Object.assign({},a.marginDefaults),"number"==typeof l?{top:l,bottom:l,left:l,right:l}:l),{customHoverBehavior:se,customClickBehavior:ce}=Pr({selection:C,linkedHover:M,fallbackFields:f?["string"==typeof f?f:""]:[],unwrapData:!0,onObservation:S,onClick:O,chartType:"ChordDiagram",chartId:L}),le=qr({componentName:"ChordDiagram",edges:c,edgesRequired:!0});return le?e.jsx(Wr,{componentName:"ChordDiagram",message:le,width:N,height:R}):Y||q||e.jsx(dn,{componentName:"ChordDiagram",width:N,height:R,children:e.jsx(ur,Object.assign({ref:i,chartType:"chord"},X.length>0&&{nodes:X},null!=c&&{edges:G},{size:[N,R],responsiveWidth:r.responsiveWidth,responsiveHeight:r.responsiveHeight,margin:ae,nodeIDAccessor:g,sourceAccessor:d,targetAccessor:h,valueAccessor:y,padAngle:v,groupWidth:b,sortGroups:x,nodeStyle:re,edgeStyle:oe,colorBy:f,colorScheme:J,edgeColorBy:m,edgeOpacity:A,nodeLabel:ie,showLabels:$,enableHover:W,tooltipContent:!1===w?()=>null:fr(w)||void 0,customHoverBehavior:M||S||O?se:void 0,customClickBehavior:S||O?ce:void 0},P&&"none"!==P&&{legendHoverBehavior:U.onLegendHover,legendClickBehavior:U.onLegendClick,legendHighlightedCategory:U.highlightedCategory,legendIsolatedCategories:U.isolatedCategories},{className:u,title:B,description:z,summary:H,accessibleTable:F},null!=r.animate&&{animate:r.animate},j))})});function wn(r){var n;const o=Tr(r.mode,{width:r.width,height:r.height,enableHover:r.enableHover,showLabels:r.showLabels,title:r.title,description:r.description,accessibleTable:r.accessibleTable,summary:r.summary},{width:600,height:600}),{data:i,margin:a,className:s,layout:c="tree",orientation:l="vertical",childrenAccessor:u="children",valueAccessor:d="value",nodeIdAccessor:h="name",colorBy:y,colorScheme:g,colorByDepth:f=!1,edgeStyle:p="curve",nodeLabel:m,nodeSize:v=5,tooltip:b,frameProps:x={},onObservation:k,onClick:A,chartId:w,selection:j,linkedHover:S,loading:O,legendInteraction:L,stroke:C,strokeWidth:M,opacity:D}=r,E=o.width,P=o.height,I=o.enableHover,_=null===(n=o.showLabels)||void 0===n||n,T=o.title,N=o.description,R=o.summary,W=o.accessibleTable,$=fn(O,E,P),B=t.useMemo(()=>mn(null!=i?i:null,u),[i,u]),z=Er(B,f?void 0:y,g),H=t.useMemo(()=>{if(!y||f)return[];const e=new Set;for(const t of B){const r="function"==typeof y?y(t):t[y];null!=r&&e.add(r+"")}return Array.from(e)},[B,y,f]),F=Ir(L,f?void 0:y,H),Y=Mr(),q=t.useMemo(()=>new Map,[]),G=t.useMemo(()=>{if(Array.isArray(g))return g;if(Y&&Y.length>0)return Y;const e=Zt[g];return Array.isArray(e)?e:Qt},[g,Y]),X=t.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=f?er[(e.depth||0)%er.length]:y?rr(e.data||e,y,z):Dr(0,Y,g),t},[y,f,z,Y,g,q]),V=t.useMemo(()=>Rr(X,{stroke:C,strokeWidth:M,opacity:D}),[X,C,M,D]),K=t.useMemo(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),U=t.useMemo(()=>Rr(K,{stroke:C,strokeWidth:M,opacity:D}),[K,C,M,D]),Z=t.useMemo(()=>{if("treemap"===c||"circlepack"===c||"partition"===c)return bn(d)},[c,d]),Q=Object.assign(Object.assign({},o.marginDefaults),"number"==typeof a?{top:a,bottom:a,left:a,right:a}:a),{customHoverBehavior:J,customClickBehavior:ee}=Pr({selection:j,linkedHover:S,fallbackFields:y?["string"==typeof y?y:""]:[],unwrapData:!0,onObservation:k,onClick:A,chartType:"TreeDiagram",chartId:w}),te=Yr({componentName:"TreeDiagram",data:i});return te?e.jsx(Wr,{componentName:"TreeDiagram",message:te,width:E,height:P}):$||e.jsx(dn,{componentName:"TreeDiagram",width:E,height:P,children:e.jsx(ur,Object.assign({chartType:c},null!=i&&{data:i},{size:[E,P],responsiveWidth:r.responsiveWidth,responsiveHeight:r.responsiveHeight,margin:Q,nodeIDAccessor:h,childrenAccessor:u,hierarchySum:Z,treeOrientation:l,edgeType:p,nodeStyle:V,edgeStyle:U,colorBy:y,colorScheme:G,colorByDepth:f,nodeSize:v,nodeLabel:_?m||h:void 0,showLabels:_,enableHover:I,tooltipContent:!1===b?()=>null:fr(b)||void 0,customHoverBehavior:S||k||A?J:void 0,customClickBehavior:k||A?ee:void 0},L&&"none"!==L&&{legendHoverBehavior:F.onLegendHover,legendClickBehavior:F.onLegendClick,legendHighlightedCategory:F.highlightedCategory,legendIsolatedCategories:F.isolatedCategories},{className:s,title:T,description:N,summary:R,accessibleTable:W},null!=r.animate&&{animate:r.animate},x))})}function jn(r){var n;const o=Tr(r.mode,{width:r.width,height:r.height,enableHover:r.enableHover,showLabels:r.showLabels,title:r.title,description:r.description,accessibleTable:r.accessibleTable,summary:r.summary,linkedHover:r.linkedHover},{width:600,height:600}),{data:i,margin:a,className:s,childrenAccessor:c="children",valueAccessor:l="value",nodeIdAccessor:u="name",colorBy:d,colorScheme:h,colorByDepth:y=!1,labelMode:g="leaf",nodeLabel:f,padding:p=4,paddingTop:m,tooltip:v,frameProps:b={},selection:x,linkedHover:k,onObservation:A,onClick:w,chartId:j,loading:S,legendInteraction:O,stroke:L,strokeWidth:C,opacity:M}=r,D=o.width,E=o.height,P=o.enableHover,I=null===(n=o.showLabels)||void 0===n||n,_=o.title,T=o.description,N=o.summary,R=o.accessibleTable,W=fn(S,D,E),{activeSelectionHook:$,customHoverBehavior:B,customClickBehavior:z}=Pr({selection:x,linkedHover:k,fallbackFields:d?["string"==typeof d?d:""]:[],onObservation:A,onClick:w,chartType:"Treemap",chartId:j}),H=function(e){const r=ot(e=>e.theme.colors.selectionOpacity);return t.useMemo(()=>{var t,n;if(void 0!==e||void 0!==r)return Object.assign(Object.assign({name:null!==(t=null==e?void 0:e.name)&&void 0!==t?t:""},e),{unselectedOpacity:null!==(n=null==e?void 0:e.unselectedOpacity)&&void 0!==n?n:r})},[e,r])}(x),F=t.useCallback(e=>{if(!e)return B(null);const t=e.data||e;B({data:(null==t?void 0:t.data)||t})},[B]),Y=t.useMemo(()=>mn(null!=i?i:null,c),[i,c]),q=Er(Y,y?void 0:d,h),G=t.useMemo(()=>{if(!d||y)return[];const e=new Set;for(const t of Y){const r="function"==typeof d?d(t):t[d];null!=r&&e.add(r+"")}return Array.from(e)},[Y,d,y]),X=Ir(O,y?void 0:d,G),V=Mr(),K=t.useMemo(()=>new Map,[]),U=t.useMemo(()=>{if(Array.isArray(h))return h;if(V&&V.length>0)return V;const e=Zt[h];return Array.isArray(e)?e:Qt},[h,V]),Z=t.useMemo(()=>e=>{const t={stroke:"#fff",strokeWidth:1,strokeOpacity:.8};return t.fill=y?er[(e.depth||0)%er.length]:d?rr(e.data||e,d,q):Dr(0,V,h),t},[d,y,q,V,h,K]),Q=t.useMemo(()=>Rr(Z,{stroke:L,strokeWidth:C,opacity:M}),[Z,L,C,M]),J=t.useMemo(()=>$?e=>{var t;const r=Object.assign({},Q(e));if($.isActive)if($.predicate(e.data||e))(null==H?void 0:H.selectedStyle)&&Object.assign(r,H.selectedStyle);else{const e=null!==(t=null==H?void 0:H.unselectedOpacity)&&void 0!==t?t:.5;r.opacity=e,r.fillOpacity=e,r.strokeOpacity=e,(null==H?void 0:H.unselectedStyle)&&Object.assign(r,H.unselectedStyle)}return r}:Q,[Q,$,H]),ee=t.useMemo(()=>bn(l),[l]),te=void 0!==m?m:!I||"parent"!==g&&"all"!==g?void 0:18,re=Object.assign(Object.assign({},o.marginDefaults),"number"==typeof a?{top:a,bottom:a,left:a,right:a}:a),ne=Yr({componentName:"Treemap",data:i});return ne?e.jsx(Wr,{componentName:"Treemap",message:ne,width:D,height:E}):W||e.jsx(dn,{componentName:"Treemap",width:D,height:E,children:e.jsx(ur,Object.assign({chartType:"treemap"},null!=i&&{data:i},{size:[D,E],responsiveWidth:r.responsiveWidth,responsiveHeight:r.responsiveHeight,margin:re,nodeIDAccessor:u,childrenAccessor:c,hierarchySum:ee,padding:p,paddingTop:te,nodeStyle:J,colorBy:d,colorScheme:U,colorByDepth:y,nodeLabel:I?f||u:void 0,showLabels:I,labelMode:g,enableHover:P,tooltipContent:!1===v?()=>null:fr(v)||void 0},(k||A||w)&&{customHoverBehavior:F},(A||w)&&{customClickBehavior:z},O&&"none"!==O&&{legendHoverBehavior:X.onLegendHover,legendClickBehavior:X.onLegendClick,legendHighlightedCategory:X.highlightedCategory,legendIsolatedCategories:X.isolatedCategories},{className:s,title:_,description:T,summary:N,accessibleTable:R},null!=r.animate&&{animate:r.animate},b))})}function Sn(r){var n;const o=Tr(r.mode,{width:r.width,height:r.height,enableHover:r.enableHover,showLabels:r.showLabels,title:r.title,description:r.description,accessibleTable:r.accessibleTable,summary:r.summary},{width:600,height:600}),{data:i,margin:a,className:s,childrenAccessor:c="children",valueAccessor:l="value",nodeIdAccessor:u="name",colorBy:d,colorScheme:h,colorByDepth:y=!1,nodeLabel:g,circleOpacity:f=.7,padding:p=4,tooltip:m,frameProps:v={},onObservation:b,onClick:x,chartId:k,selection:A,linkedHover:w,loading:j,legendInteraction:S,stroke:O,strokeWidth:L,opacity:C}=r,M=o.width,D=o.height,E=o.enableHover,P=null===(n=o.showLabels)||void 0===n||n,I=o.title,_=o.description,T=o.summary,N=o.accessibleTable,R=fn(j,M,D),W=t.useMemo(()=>mn(null!=i?i:null,c),[i,c]),$=Er(W,y?void 0:d,h),B=t.useMemo(()=>{if(!d||y)return[];const e=new Set;for(const t of W){const r="function"==typeof d?d(t):t[d];null!=r&&e.add(r+"")}return Array.from(e)},[W,d,y]),z=Ir(S,y?void 0:d,B),H=Mr(),F=t.useMemo(()=>new Map,[]),Y=t.useMemo(()=>{if(Array.isArray(h))return h;if(H&&H.length>0)return H;const e=Zt[h];return Array.isArray(e)?e:Qt},[h,H]),q=t.useMemo(()=>e=>{const t={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:f};return t.fill=y?er[(e.depth||0)%er.length]:d?rr(e.data||e,d,$):Dr(0,H,h),t},[d,y,$,f,H,h,F]),G=t.useMemo(()=>Rr(q,{stroke:O,strokeWidth:L,opacity:C}),[q,O,L,C]),X=t.useMemo(()=>bn(l),[l]),V=Object.assign(Object.assign({},o.marginDefaults),"number"==typeof a?{top:a,bottom:a,left:a,right:a}:a),{customHoverBehavior:K,customClickBehavior:U}=Pr({selection:A,linkedHover:w,fallbackFields:d?["string"==typeof d?d:""]:[],unwrapData:!0,onObservation:b,onClick:x,chartType:"CirclePack",chartId:k}),Z=Yr({componentName:"CirclePack",data:i});return Z?e.jsx(Wr,{componentName:"CirclePack",message:Z,width:M,height:D}):R||e.jsx(dn,{componentName:"CirclePack",width:M,height:D,children:e.jsx(ur,Object.assign({chartType:"circlepack"},null!=i&&{data:i},{size:[M,D],responsiveWidth:r.responsiveWidth,responsiveHeight:r.responsiveHeight,margin:V,nodeIDAccessor:u,childrenAccessor:c,hierarchySum:X,padding:p,nodeStyle:G,colorBy:d,colorScheme:Y,colorByDepth:y,nodeLabel:P?g||u:void 0,showLabels:P,enableHover:E,tooltipContent:!1===m?()=>null:fr(m)||void 0,customHoverBehavior:w||b||x?K:void 0,customClickBehavior:b||x?U:void 0},S&&"none"!==S&&{legendHoverBehavior:z.onLegendHover,legendClickBehavior:z.onLegendClick,legendHighlightedCategory:z.highlightedCategory,legendIsolatedCategories:z.isolatedCategories},{className:s,title:I,description:_,summary:T,accessibleTable:N},null!=r.animate&&{animate:r.animate},v))})}An.displayName="ChordDiagram",wn.displayName="TreeDiagram",jn.displayName="Treemap",Sn.displayName="CirclePack";const On=er;function Ln(r){const n=Tr(r.mode,{width:r.width,height:r.height,enableHover:r.enableHover,showLabels:r.showLabels,title:r.title,description:r.description,accessibleTable:r.accessibleTable,summary:r.summary},{width:600,height:600}),{data:o,margin:i,className:a,childrenAccessor:s="children",nodeIdAccessor:c="name",colorBy:l,colorScheme:u,colorByDepth:d=!1,orbitMode:h="flat",orbitSize:y=2.95,speed:g=.25,revolution:f,revolutionStyle:p,eccentricity:m=1,showRings:v=!0,nodeRadius:b=6,showLabels:x=!1,animated:k=!0,tooltip:A,foregroundGraphics:w,annotations:j,frameProps:S={},onObservation:O,onClick:L,chartId:C,selection:M,linkedHover:D,loading:E,stroke:P,strokeWidth:I,opacity:_}=r,T=n.width,N=n.height,R=n.enableHover,W=n.title,$=n.description,B=n.summary,z=n.accessibleTable,H=fn(E,T,N),F=Er(t.useMemo(()=>mn(o,s),[o,s]),d?void 0:l,u),Y=Mr(),q=t.useMemo(()=>new Map,[]),G=t.useMemo(()=>{if(Array.isArray(u))return u;if(Y&&Y.length>0)return Y;const e=Zt[u];return Array.isArray(e)?e:Qt},[u,Y]),X=t.useMemo(()=>{if(Array.isArray(u))return u;const e=Zt[u];return Array.isArray(e)?e:Qt},[u]),V=t.useMemo(()=>e=>{var t;const r={stroke:"#fff",strokeWidth:1},n=0===(null!==(t=e.depth)&&void 0!==t?t:0);return r.fill=d?n?X[0]:On[(e.depth||0)%On.length]:l?rr(e.data||e,l,F):Dr(0,Y,u),r.opacity=n?1:.85,r},[l,d,F,X,Y,u,q]),K=t.useMemo(()=>Rr(V,{stroke:P,strokeWidth:I,opacity:_}),[V,P,I,_]),U=t.useMemo(()=>()=>({stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1}),[]),Z=Object.assign({top:10,right:10,bottom:10,left:10},"number"==typeof i?{top:i,bottom:i,left:i,right:i}:i),{customHoverBehavior:Q,customClickBehavior:J}=Pr({selection:M,linkedHover:D,fallbackFields:l?["string"==typeof l?l:""]:[],unwrapData:!0,onObservation:O,onClick:L,chartType:"OrbitDiagram",chartId:C}),ee=t.useMemo(()=>{if(Q)return e=>{Q(e&&e.data&&void 0!==e.data.data?Object.assign(Object.assign({},e),{data:e.data.data}):e)}},[Q]),te=t.useMemo(()=>{if(J)return e=>{J(e&&e.data&&void 0!==e.data.data?Object.assign(Object.assign({},e),{data:e.data.data}):e)}},[J]),re=Yr({componentName:"OrbitDiagram",data:o});return re?e.jsx(Wr,{componentName:"OrbitDiagram",message:re,width:T,height:N}):H||e.jsx(dn,{componentName:"OrbitDiagram",width:T,height:N,children:e.jsx(ur,Object.assign({chartType:"orbit"},null!=o&&{data:o},{size:[T,N],responsiveWidth:r.responsiveWidth,responsiveHeight:r.responsiveHeight,margin:Z,nodeIDAccessor:c,childrenAccessor:s,nodeStyle:K,edgeStyle:U,colorBy:l,colorScheme:G,colorByDepth:d,nodeSize:b,nodeLabel:x?c:void 0,showLabels:x,enableHover:!k&&R,tooltipContent:k?void 0:!1===A?()=>null:fr(A)||void 0,customHoverBehavior:D||O||L?ee:void 0,customClickBehavior:O||L?te:void 0,foregroundGraphics:w,annotations:j,className:a,title:W,description:$,summary:B,orbitMode:h,orbitSize:y,orbitSpeed:g,orbitRevolution:f,orbitRevolutionStyle:p,orbitEccentricity:m,orbitShowRings:v,orbitAnimated:k,accessibleTable:z},null!=r.animate&&{animate:r.animate},S))})}Ln.displayName="OrbitDiagram",exports.ChordDiagram=An,exports.CirclePack=Sn,exports.ForceDirectedGraph=pn,exports.OrbitDiagram=Ln,exports.SankeyDiagram=kn,exports.StreamNetworkFrame=ur,exports.TreeDiagram=wn,exports.Treemap=jn;