semiotic 3.0.0-beta.7 → 3.0.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 (181) hide show
  1. package/CLAUDE.md +24 -11
  2. package/README.md +67 -64
  3. package/ai/cli.js +34 -21
  4. package/ai/dist/componentRegistry.js +2 -0
  5. package/ai/dist/mcp-server.js +54 -0
  6. package/ai/examples.md +75 -0
  7. package/ai/schema.json +71 -0
  8. package/ai/system-prompt.md +3 -0
  9. package/dist/{ChartGrid.d.ts → components/ChartGrid.d.ts} +9 -7
  10. package/dist/{LinkedCharts.d.ts → components/LinkedCharts.d.ts} +34 -1
  11. package/dist/{Tooltip → components/Tooltip}/Tooltip.d.ts +9 -2
  12. package/dist/{charts → components/charts}/index.d.ts +2 -0
  13. package/dist/{charts → components/charts}/network/ChordDiagram.d.ts +2 -0
  14. package/dist/{charts → components/charts}/network/CirclePack.d.ts +2 -0
  15. package/dist/{charts → components/charts}/network/ForceDirectedGraph.d.ts +2 -0
  16. package/dist/components/charts/network/OrbitDiagram.d.ts +78 -0
  17. package/dist/{charts → components/charts}/network/SankeyDiagram.d.ts +2 -0
  18. package/dist/{charts → components/charts}/network/TreeDiagram.d.ts +2 -0
  19. package/dist/{charts → components/charts}/network/Treemap.d.ts +2 -0
  20. package/dist/{charts → components/charts}/ordinal/BarChart.d.ts +2 -0
  21. package/dist/{charts → components/charts}/ordinal/BoxPlot.d.ts +2 -0
  22. package/dist/{charts → components/charts}/ordinal/DonutChart.d.ts +2 -0
  23. package/dist/{charts → components/charts}/ordinal/DotPlot.d.ts +2 -0
  24. package/dist/{charts → components/charts}/ordinal/GroupedBarChart.d.ts +2 -0
  25. package/dist/{charts → components/charts}/ordinal/PieChart.d.ts +2 -0
  26. package/dist/{charts → components/charts}/ordinal/StackedBarChart.d.ts +2 -0
  27. package/dist/{charts → components/charts}/ordinal/SwarmPlot.d.ts +2 -0
  28. package/dist/components/charts/shared/diagnoseConfig.d.ts +23 -0
  29. package/dist/{charts → components/charts}/shared/hooks.d.ts +23 -1
  30. package/dist/components/charts/shared/stringDistance.d.ts +11 -0
  31. package/dist/{charts → components/charts}/shared/tooltipUtils.d.ts +1 -1
  32. package/dist/{charts → components/charts}/shared/types.d.ts +6 -0
  33. package/dist/{charts → components/charts}/shared/withChartWrapper.d.ts +10 -0
  34. package/dist/{charts → components/charts}/xy/AreaChart.d.ts +8 -0
  35. package/dist/{charts → components/charts}/xy/BubbleChart.d.ts +8 -0
  36. package/dist/{charts → components/charts}/xy/ConnectedScatterplot.d.ts +3 -0
  37. package/dist/{charts → components/charts}/xy/Heatmap.d.ts +8 -0
  38. package/dist/{charts → components/charts}/xy/LineChart.d.ts +26 -0
  39. package/dist/{charts → components/charts}/xy/Scatterplot.d.ts +3 -0
  40. package/dist/{charts → components/charts}/xy/StackedAreaChart.d.ts +8 -0
  41. package/dist/{export → components/export}/exportChart.d.ts +6 -1
  42. package/dist/components/semiotic-ai.d.ts +61 -0
  43. package/dist/components/semiotic-data.d.ts +7 -0
  44. package/dist/components/semiotic-network.d.ts +14 -0
  45. package/dist/components/semiotic-ordinal.d.ts +18 -0
  46. package/dist/components/semiotic-realtime.d.ts +22 -0
  47. package/dist/components/semiotic-server.d.ts +1 -0
  48. package/dist/components/semiotic-xy.d.ts +16 -0
  49. package/dist/components/semiotic.d.ts +57 -0
  50. package/dist/{server → components/server}/renderToStaticSVG.d.ts +7 -0
  51. package/dist/{stream → components/stream}/NetworkSVGOverlay.d.ts +20 -0
  52. package/dist/{stream → components/stream}/OrdinalSVGOverlay.d.ts +8 -0
  53. package/dist/{stream → components/stream}/PipelineStore.d.ts +7 -0
  54. package/dist/{stream → components/stream}/SVGOverlay.d.ts +15 -0
  55. package/dist/components/stream/SceneToSVG.d.ts +20 -0
  56. package/dist/components/stream/hitTestUtils.d.ts +23 -0
  57. package/dist/{stream → components/stream}/networkTypes.d.ts +10 -2
  58. package/dist/{stream → components/stream}/ordinalTypes.d.ts +16 -10
  59. package/dist/components/stream/renderers/areaCanvasRenderer.d.ts +2 -0
  60. package/dist/{stream → components/stream}/types.d.ts +12 -0
  61. package/dist/components/stream/useStalenessCheck.d.ts +16 -0
  62. package/dist/{types → components/types}/legendTypes.d.ts +5 -0
  63. package/dist/network.min.js +1 -1
  64. package/dist/network.module.min.js +1 -1
  65. package/dist/ordinal.min.js +1 -1
  66. package/dist/ordinal.module.min.js +1 -1
  67. package/dist/realtime.min.js +1 -1
  68. package/dist/realtime.module.min.js +1 -1
  69. package/dist/semiotic-ai.d.ts +3 -0
  70. package/dist/semiotic-ai.min.js +1 -1
  71. package/dist/semiotic-ai.module.min.js +1 -1
  72. package/dist/semiotic-network.d.ts +1 -0
  73. package/dist/semiotic-ordinal.d.ts +1 -0
  74. package/dist/semiotic.d.ts +3 -3
  75. package/dist/semiotic.min.js +1 -1
  76. package/dist/semiotic.module.min.js +1 -1
  77. package/dist/server.min.js +1 -1
  78. package/dist/server.module.min.js +1 -1
  79. package/dist/test/canvasMock.d.ts +2 -0
  80. package/dist/test-utils/canvasMock.d.ts +20 -0
  81. package/dist/test-utils/frameMock.d.ts +78 -0
  82. package/dist/xy.min.js +1 -1
  83. package/dist/xy.module.min.js +1 -1
  84. package/package.json +9 -17
  85. package/dist/stream/renderers/areaCanvasRenderer.d.ts +0 -7
  86. /package/dist/{Annotation.d.ts → components/Annotation.d.ts} +0 -0
  87. /package/dist/{CategoryColors.d.ts → components/CategoryColors.d.ts} +0 -0
  88. /package/dist/{ChartContainer.d.ts → components/ChartContainer.d.ts} +0 -0
  89. /package/dist/{ChartErrorBoundary.d.ts → components/ChartErrorBoundary.d.ts} +0 -0
  90. /package/dist/{ContextLayout.d.ts → components/ContextLayout.d.ts} +0 -0
  91. /package/dist/{DetailsPanel.d.ts → components/DetailsPanel.d.ts} +0 -0
  92. /package/dist/{Legend.d.ts → components/Legend.d.ts} +0 -0
  93. /package/dist/{ThemeProvider.d.ts → components/ThemeProvider.d.ts} +0 -0
  94. /package/dist/{charts → components/charts}/ordinal/Histogram.d.ts +0 -0
  95. /package/dist/{charts → components/charts}/ordinal/RidgelinePlot.d.ts +0 -0
  96. /package/dist/{charts → components/charts}/ordinal/ViolinPlot.d.ts +0 -0
  97. /package/dist/{charts → components/charts}/realtime/RealtimeHeatmap.d.ts +0 -0
  98. /package/dist/{charts → components/charts}/realtime/RealtimeHistogram.d.ts +0 -0
  99. /package/dist/{charts → components/charts}/realtime/RealtimeLineChart.d.ts +0 -0
  100. /package/dist/{charts → components/charts}/realtime/RealtimeSwarmChart.d.ts +0 -0
  101. /package/dist/{charts → components/charts}/realtime/RealtimeWaterfallChart.d.ts +0 -0
  102. /package/dist/{charts → components/charts}/shared/ChartError.d.ts +0 -0
  103. /package/dist/{charts → components/charts}/shared/annotationRules.d.ts +0 -0
  104. /package/dist/{charts → components/charts}/shared/colorUtils.d.ts +0 -0
  105. /package/dist/{charts → components/charts}/shared/formatUtils.d.ts +0 -0
  106. /package/dist/{charts → components/charts}/shared/legendUtils.d.ts +0 -0
  107. /package/dist/{charts → components/charts}/shared/loess.d.ts +0 -0
  108. /package/dist/{charts → components/charts}/shared/networkUtils.d.ts +0 -0
  109. /package/dist/{charts → components/charts}/shared/selectionUtils.d.ts +0 -0
  110. /package/dist/{charts → components/charts}/shared/statisticalOverlays.d.ts +0 -0
  111. /package/dist/{charts → components/charts}/shared/validateChartData.d.ts +0 -0
  112. /package/dist/{charts → components/charts}/shared/validateProps.d.ts +0 -0
  113. /package/dist/{charts → components/charts}/xy/MinimapChart.d.ts +0 -0
  114. /package/dist/{charts → components/charts}/xy/ScatterplotMatrix.d.ts +0 -0
  115. /package/dist/{data → components/data}/fromVegaLite.d.ts +0 -0
  116. /package/dist/{data → components/data}/transforms.d.ts +0 -0
  117. /package/dist/{export → components/export}/chartConfig.d.ts +0 -0
  118. /package/dist/{export → components/export}/selectionSerializer.d.ts +0 -0
  119. /package/dist/{geometry → components/geometry}/sankeyLinks.d.ts +0 -0
  120. /package/dist/{realtime → components/realtime}/BinAccumulator.d.ts +0 -0
  121. /package/dist/{realtime → components/realtime}/IncrementalExtent.d.ts +0 -0
  122. /package/dist/{realtime → components/realtime}/RingBuffer.d.ts +0 -0
  123. /package/dist/{realtime → components/realtime}/renderers/types.d.ts +0 -0
  124. /package/dist/{realtime → components/realtime}/renderers/waterfallRenderer.d.ts +0 -0
  125. /package/dist/{realtime → components/realtime}/types.d.ts +0 -0
  126. /package/dist/{store → components/store}/ObservationStore.d.ts +0 -0
  127. /package/dist/{store → components/store}/SelectionStore.d.ts +0 -0
  128. /package/dist/{store → components/store}/ThemeStore.d.ts +0 -0
  129. /package/dist/{store → components/store}/TooltipStore.d.ts +0 -0
  130. /package/dist/{store → components/store}/createStore.d.ts +0 -0
  131. /package/dist/{store → components/store}/useObservation.d.ts +0 -0
  132. /package/dist/{store → components/store}/useSelection.d.ts +0 -0
  133. /package/dist/{stream → components/stream}/CanvasHitTester.d.ts +0 -0
  134. /package/dist/{stream → components/stream}/DataSourceAdapter.d.ts +0 -0
  135. /package/dist/{stream → components/stream}/MarginalGraphics.d.ts +0 -0
  136. /package/dist/{stream → components/stream}/NetworkCanvasHitTester.d.ts +0 -0
  137. /package/dist/{stream → components/stream}/NetworkPipelineStore.d.ts +0 -0
  138. /package/dist/{stream → components/stream}/OrdinalCanvasHitTester.d.ts +0 -0
  139. /package/dist/{stream → components/stream}/OrdinalPipelineStore.d.ts +0 -0
  140. /package/dist/{stream → components/stream}/ParticlePool.d.ts +0 -0
  141. /package/dist/{stream → components/stream}/SceneGraph.d.ts +0 -0
  142. /package/dist/{stream → components/stream}/StreamNetworkFrame.d.ts +0 -0
  143. /package/dist/{stream → components/stream}/StreamOrdinalFrame.d.ts +0 -0
  144. /package/dist/{stream → components/stream}/StreamXYFrame.d.ts +0 -0
  145. /package/dist/{stream → components/stream}/accessorUtils.d.ts +0 -0
  146. /package/dist/{stream → components/stream}/keyboardNav.d.ts +0 -0
  147. /package/dist/{stream → components/stream}/layouts/chordLayoutPlugin.d.ts +0 -0
  148. /package/dist/{stream → components/stream}/layouts/forceLayoutPlugin.d.ts +0 -0
  149. /package/dist/{stream → components/stream}/layouts/hierarchyLayoutPlugin.d.ts +0 -0
  150. /package/dist/{stream → components/stream}/layouts/index.d.ts +0 -0
  151. /package/dist/{stream → components/stream}/layouts/sankeyLayoutPlugin.d.ts +0 -0
  152. /package/dist/{stream → components/stream}/ordinalSceneBuilders/barScene.d.ts +0 -0
  153. /package/dist/{stream → components/stream}/ordinalSceneBuilders/connectorScene.d.ts +0 -0
  154. /package/dist/{stream → components/stream}/ordinalSceneBuilders/pieScene.d.ts +0 -0
  155. /package/dist/{stream → components/stream}/ordinalSceneBuilders/pointScene.d.ts +0 -0
  156. /package/dist/{stream → components/stream}/ordinalSceneBuilders/statisticalScene.d.ts +0 -0
  157. /package/dist/{stream → components/stream}/ordinalSceneBuilders/timelineScene.d.ts +0 -0
  158. /package/dist/{stream → components/stream}/ordinalSceneBuilders/types.d.ts +0 -0
  159. /package/dist/{stream → components/stream}/renderers/barCanvasRenderer.d.ts +0 -0
  160. /package/dist/{stream → components/stream}/renderers/boxplotCanvasRenderer.d.ts +0 -0
  161. /package/dist/{stream → components/stream}/renderers/candlestickCanvasRenderer.d.ts +0 -0
  162. /package/dist/{stream → components/stream}/renderers/connectorCanvasRenderer.d.ts +0 -0
  163. /package/dist/{stream → components/stream}/renderers/heatmapCanvasRenderer.d.ts +0 -0
  164. /package/dist/{stream → components/stream}/renderers/lineCanvasRenderer.d.ts +0 -0
  165. /package/dist/{stream → components/stream}/renderers/networkArcRenderer.d.ts +0 -0
  166. /package/dist/{stream → components/stream}/renderers/networkCircleRenderer.d.ts +0 -0
  167. /package/dist/{stream → components/stream}/renderers/networkEdgeRenderer.d.ts +0 -0
  168. /package/dist/{stream → components/stream}/renderers/networkParticleRenderer.d.ts +0 -0
  169. /package/dist/{stream → components/stream}/renderers/networkRectRenderer.d.ts +0 -0
  170. /package/dist/{stream → components/stream}/renderers/pointCanvasRenderer.d.ts +0 -0
  171. /package/dist/{stream → components/stream}/renderers/swarmCanvasRenderer.d.ts +0 -0
  172. /package/dist/{stream → components/stream}/renderers/types.d.ts +0 -0
  173. /package/dist/{stream → components/stream}/renderers/violinCanvasRenderer.d.ts +0 -0
  174. /package/dist/{stream → components/stream}/renderers/waterfallCanvasRenderer.d.ts +0 -0
  175. /package/dist/{stream → components/stream}/renderers/wedgeCanvasRenderer.d.ts +0 -0
  176. /package/dist/{stream → components/stream}/useResponsiveSize.d.ts +0 -0
  177. /package/dist/{types → components/types}/annotationTypes.d.ts +0 -0
  178. /package/dist/{types → components/types}/generalTypes.d.ts +0 -0
  179. /package/dist/{types → components/types}/interactionTypes.d.ts +0 -0
  180. /package/dist/{types → components/types}/networkTypes.d.ts +0 -0
  181. /package/dist/{types → components/types}/ordinalTypes.d.ts +0 -0
@@ -1 +1 @@
1
- import*as t from"react";import{arc as e}from"d3-shape";import{scaleLinear as i,scaleBand as r}from"d3-scale";import{min as n,groups as o,max as a,sum as s,mean as c,group as l,quantile as u}from"d3-array";import{schemeCategory10 as h}from"d3-scale-chromatic";import{interpolateNumber as f}from"d3-interpolate";import{forceLink as d,forceSimulation as y,forceManyBody as g,forceX as p,forceY as m}from"d3-force";import{ribbon as x,chord as v}from"d3-chord";import{hierarchy as k,partition as b,pack as w,treemap as E,treemapBinary as S,cluster as A,tree as P}from"d3-hierarchy";class L{constructor(t){if(this._capacity=t,this.head=0,this._size=0,1>t)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(t)}push(t){let e;return this._size===this._capacity?e=this.buffer[this.head]:this._size++,this.buffer[this.head]=t,this.head=(this.head+1)%this._capacity,e}pushMany(t){const e=[];for(const i of t){const t=this.push(i);void 0!==t&&e.push(t)}return e}get(t){if(t>=0&&this._size>t)return this.buffer[(this.head-this._size+t+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let t=0;const e=this;return{next:()=>e._size>t?{done:!1,value:e.get(t++)}:{done:!0,value:void 0}}}toArray(){const t=[];for(const e of this)t.push(e);return t}resize(t){if(1>t)throw Error("RingBuffer capacity must be at least 1");const e=this.toArray(),i=[];for(;e.length>t;)i.push(e.shift());this._capacity=t,this.buffer=Array(t),this.head=0,this._size=0;for(const t of e)this.push(t);return i}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}}class M{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(t){Number.isNaN(t)||(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}evict(t){t!==this._min&&t!==this._max||(this._dirty=!0)}recalculate(t,e){this._min=1/0,this._max=-1/0;for(const i of t){const t=e?e(i):i;Number.isNaN(t)||(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}this._dirty=!1}clear(){this._min=1/0,this._max=-1/0,this._dirty=!1}get extent(){return[this._min,this._max]}get min(){return this._min}get max(){return this._max}get dirty(){return this._dirty}}function D(t,e,i,r,n){const o=new Map;for(const a of t){const t=e(a),s=i(a);if(null==t||null==s||Number.isNaN(t)||Number.isNaN(s))continue;const c=Math.floor(t/r)*r;let l=o.get(c);if(l||(l={start:c,end:c+r,total:0,categories:new Map},o.set(c,l)),l.total+=s,n){const t=n(a);l.categories.set(t,(l.categories.get(t)||0)+s)}}return o}function _(t,e,i,r,n,o){const a=[],s=[];for(const n of t){const t=i(n),o=r(n);null==t||null==o||Number.isNaN(t)||Number.isNaN(o)||(a.push([e.x(t),e.y(o)]),s.push(o))}return{type:"line",path:a,rawValues:s,style:n,datum:t,group:o}}function $(t,e,i,r,n,o,a,s){const c=[],l=[];for(const o of t){const t=i(o),a=r(o);if(null==t||null==a||Number.isNaN(t)||Number.isNaN(a))continue;const u=e.x(t);c.push([u,e.y(a)]);const h=s?s(o):n;l.push([u,e.y(h)])}return{type:"area",topPath:c,bottomPath:l,style:o,datum:t,group:a}}function W(t,e,i,r,n,o,a){const s=i(t),c=r(t);if(null==s||null==c||Number.isNaN(s)||Number.isNaN(c))return null;const l={type:"point",x:e.x(s),y:e.y(c),r:n,style:o,datum:t};return void 0!==a&&(l.pointId=a),l}function N(t,e,i,r,n,o,a){return{type:"rect",x:t,y:e,w:i,h:r,style:n,datum:o,group:a}}function T(t,e,i,r,n,o){return{type:"heatcell",x:t,y:e,w:i,h:r,fill:n,datum:o}}function R(t,e){if("function"==typeof t)return e=>+t(e);const i=t||e;return t=>+t[i]}function z(t,e){return"function"==typeof t?t:t?e=>e[t]+"":e?t=>t[e]+"":void 0}class O{constructor(t){this.xExtent=new M,this.yExtent=new M,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.lastIngestTime=0,this.scales=null,this.scene=[],this.version=0,this.config=t,this.buffer=new L(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=R(t.timeAccessor||t.xAccessor,"time"),this.getY=R(t.valueAccessor||t.yAccessor,"value")):(this.getX=R(t.xAccessor,"x"),this.getY=R(t.yAccessor,"y")),this.getGroup=z(t.groupAccessor),this.getCategory=z(t.categoryAccessor),this.getSize=t.sizeAccessor?R(t.sizeAccessor,"size"):void 0,this.getColor=z(t.colorAccessor),this.getBounds=t.boundsAccessor?R(t.boundsAccessor,"bounds"):void 0,this.getY0=t.y0Accessor?R(t.y0Accessor,"y0"):void 0,this.getPointId=z(t.pointIdAccessor),"candlestick"===t.chartType&&(this.getOpen=R(t.openAccessor,"open"),this.getHigh=R(t.highAccessor,"high"),this.getLow=R(t.lowAccessor,"low"),this.getClose=R(t.closeAccessor,"close")),t.pulse&&(this.timestampBuffer=new L(t.windowSize))}ingest(t){const e="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=e,t.bounded){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const i=t.totalSize||t.inserts.length;i>this.buffer.capacity&&(this.buffer.resize(i),this.timestampBuffer&&i>this.timestampBuffer.capacity&&this.timestampBuffer.resize(i));for(const i of t.inserts)this.buffer.push(i),this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(i)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(i)),this.yExtent.push(this.getLow(i))):(this.yExtent.push(this.getY(i)),this.getY0&&this.yExtent.push(this.getY0(i)))}else for(const i of t.inserts){"growing"===this.config.windowMode&&this.buffer.full&&(this.growingCap*=2,this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap));const t=this.buffer.push(i);this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(i)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(i)),this.yExtent.push(this.getLow(i))):(this.yExtent.push(this.getY(i)),this.getY0&&this.yExtent.push(this.getY0(i))),null!=t&&(this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):this.yExtent.evict(this.getY(t)))}return!0}computeScene(t){var e,r,n,o,a,s;const{config:c,buffer:l}=this;if(this.xExtent.dirty&&this.xExtent.recalculate(l,this.getX),this.yExtent.dirty)if("candlestick"===c.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const t of l)this.yExtent.push(this.getHigh(t)),this.yExtent.push(this.getLow(t))}else this.yExtent.recalculate(l,this.getY);const u=this.xExtent.extent,h=this.yExtent.extent;let f=c.xExtent?[null!==(e=c.xExtent[0])&&void 0!==e?e:u[0],null!==(r=c.xExtent[1])&&void 0!==r?r:u[1]]:u,d=c.yExtent?[null!==(n=c.yExtent[0])&&void 0!==n?n:h[0],null!==(o=c.yExtent[1])&&void 0!==o?o:h[1]]:h;const y=c.yExtent&&null!=c.yExtent[0]&&null!=c.yExtent[1];if("stackedarea"===c.chartType&&!y&&l.size>0)if(c.normalize)d=[0,1+c.extentPadding];else{const t=l.toArray(),e=this.groupData(t),i=new Map;for(const t of e)for(const e of t.data){const t=this.getX(e),r=this.getY(e);null==t||null==r||Number.isNaN(t)||Number.isNaN(r)||i.set(t,(i.get(t)||0)+r)}let r=0;for(const t of i.values())t>r&&(r=t);d=[0,r+(r>0?r*c.extentPadding:1)]}else if("bar"===c.chartType&&c.binSize&&!y&&l.size>0){const[,t]=function(t,e,i,r,n){const o=D(t,e,i,r,n);if(0===o.size)return[0,0];let a=0;for(const t of o.values())t.total>a&&(a=t.total);return[0,a]}(l,this.getX,this.getY,c.binSize,this.getCategory);d=[0,t+t*c.extentPadding]}else if("waterfall"===c.chartType&&!y&&l.size>0){const[t,e]=function(t,e){let i=0,r=0,n=0;for(const o of t){const t=e(o);null==t||Number.isNaN(t)||(n+=t,i>n&&(i=n),n>r&&(r=n))}return[i,r]}(l,this.getY),i=e-t,r=i>0?i*c.extentPadding:1;d=[Math.min(0,t-Math.abs(r)),Math.max(0,e+Math.abs(r))]}else if(!y&&d[0]!==1/0){if(this.getBounds){const t=l.toArray();for(const e of t){const t=this.getY(e),i=this.getBounds(e);null!=t&&!Number.isNaN(t)&&i&&(t+i>d[1]&&(d[1]=t+i),d[0]>t-i&&(d[0]=t-i))}}const t=d[1]-d[0],e=t>0?t*c.extentPadding:1,i=null===(a=c.yExtent)||void 0===a?void 0:a[0],r=null===(s=c.yExtent)||void 0===s?void 0:s[1];d=[null!=i?d[0]:d[0]-e,null!=r?d[1]:d[1]+e]}if(f[0]!==1/0&&f[1]!==-1/0||(f=[0,1]),d[0]!==1/0&&d[1]!==-1/0||(d=[0,1]),void 0!==c.arrowOfTime)if("x"==("up"===(g=c.arrowOfTime)||"down"===g?"y":"x")){const e="right"===c.arrowOfTime?[0,t.width]:[t.width,0];this.scales={x:i().domain(f).range(e),y:i().domain(d).range([t.height,0])}}else{const e="down"===c.arrowOfTime?[0,t.height]:[t.height,0];this.scales={x:i().domain(d).range([0,t.width]),y:i().domain(f).range(e)}}else this.scales={x:i().domain(f).range([0,t.width]),y:i().domain(d).range([t.height,0])};var g;this.config.transition&&this.scene.length>0&&this.snapshotPositions();const p=l.toArray();this.scene=this.buildSceneNodes(t),this.config.decay&&this.applyDecay(this.scene,p),this.config.pulse&&this.applyPulse(this.scene,p),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++}buildSceneNodes(t){const{config:e,buffer:i,scales:r}=this;if(!r||0===i.size)return[];const n=i.toArray();switch(e.chartType){case"line":return this.buildLineScene(n);case"area":return this.buildAreaScene(n);case"stackedarea":return this.buildStackedAreaScene(n);case"scatter":case"bubble":return this.buildPointScene(n);case"heatmap":return this.buildHeatmapScene(n,t);case"bar":return this.buildBarScene(n);case"swarm":return this.buildSwarmScene(n);case"waterfall":return this.buildWaterfallScene(n,t);case"candlestick":return this.buildCandlestickScene(n,t);default:return[]}}buildLineScene(t){var e;const i=this.groupData(t),r=[],n=null===(e=this.config.annotations)||void 0===e?void 0:e.filter(t=>"threshold"===t.type&&t.color).map(t=>({value:t.value,color:t.color,thresholdType:t.thresholdType||"greater"}));if(this.getBounds)for(const t of i){const e=this.buildBoundsForGroup(t.data,t.key);e&&r.push(e)}for(const t of i){const e=this.resolveLineStyle(t.key,t.data[0]),i=_(t.data,this.scales,this.getX,this.getY,e,t.key);n&&n.length>0&&(i.colorThresholds=n),r.push(i)}return r}buildAreaScene(t){const e=this.groupData(t),i=[],r=this.scales.y.domain()[0];for(const t of e){const e=this.resolveAreaStyle(t.key,t.data[0]),n=$(t.data,this.scales,this.getX,this.getY,r,e,t.key,this.getY0);this.config.gradientFill&&(n.fillGradient=this.config.gradientFill),i.push(n)}return i}buildStackedAreaScene(t){const e=this.groupData(t);return e.sort((t,e)=>e.key>t.key?-1:t.key>e.key?1:0),function(t,e,i,r,n,o){var a;const s=new Set;for(const e of t)for(const t of e.data){const e=i(t);null==e||Number.isNaN(e)||s.add(e)}const c=Array.from(s).sort((t,e)=>t-e),l=new Map;for(const e of t){const t=new Map;for(const n of e.data){const e=i(n),o=r(n);null==e||null==o||Number.isNaN(e)||Number.isNaN(o)||t.set(e,(t.get(e)||0)+o)}l.set(e.key,t)}let u;if(o){u=new Map;for(const e of c){let i=0;for(const r of t)i+=(null===(a=l.get(r.key))||void 0===a?void 0:a.get(e))||0;u.set(e,i||1)}}const h=[],f=new Map;for(const t of c)f.set(t,0);for(const i of t){const t=l.get(i.key),r=[],a=[];for(const i of c){let n=t.get(i)||0;const s=f.get(i);o&&(n/=u.get(i));const c=e.x(i);a.push([c,e.y(s)]),r.push([c,e.y(s+n)]),f.set(i,s+n)}h.push({type:"area",topPath:r,bottomPath:a,style:n(i.key,i.data[0]),datum:i.data,group:i.key})}return h}(e,this.scales,this.getX,this.getY,(t,e)=>this.resolveAreaStyle(t,e),this.config.normalize)}buildPointScene(t){const e=[],i="bubble"===this.config.chartType?10:5,r=this.config.sizeRange||[3,15];let n=null;if(this.getSize&&!this.config.pointStyle){const e=t.map(t=>this.getSize(t)).filter(t=>null!=t&&!Number.isNaN(t));if(e.length>0){const t=Math.min(...e),i=Math.max(...e);n=e=>t===i?(r[0]+r[1])/2:r[0]+(e-t)/(i-t)*(r[1]-r[0])}}let o=null;if(this.getColor&&!this.config.pointStyle){const e=new Set;for(const i of t){const t=this.getColor(i);t&&e.add(t)}const i=Array.isArray(this.config.colorScheme)?this.config.colorScheme:["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];o=new Map;let r=0;for(const t of e)o.set(t,i[r%i.length]),r++}for(const r of t){let t=this.config.pointStyle?this.config.pointStyle(r):{fill:"#4e79a7",opacity:.8},a=t.r||i;if(n&&this.getSize){const t=this.getSize(r);null==t||Number.isNaN(t)||(a=n(t))}if(o&&this.getColor){const e=this.getColor(r);e&&o.has(e)&&(t=Object.assign(Object.assign({},t),{fill:o.get(e)}))}const s=this.getPointId?this.getPointId(r)+"":void 0,c=W(r,this.scales,this.getX,this.getY,a,t,s);c&&e.push(c)}return e}buildHeatmapScene(t,e){const i=[];if(this.config.heatmapAggregation)return this.buildStreamingHeatmapScene(t,e);const r=R(this.config.valueAccessor,"value"),n=new Set,o=new Set;for(const e of t)n.add(this.getX(e)),o.add(this.getY(e));const a=Array.from(n).sort((t,e)=>t-e),s=Array.from(o).sort((t,e)=>t-e);if(0===a.length||0===s.length)return i;const c=e.width/a.length,l=e.height/s.length,u=new Map;for(const e of t){const t=`${this.getX(e)}_${this.getY(e)}`;u.set(t,{val:r(e),datum:e})}let h=1/0,f=-1/0;for(const{val:t}of u.values())h>t&&(h=t),t>f&&(f=t);const d=f-h||1;for(let t=0;a.length>t;t++)for(let e=0;s.length>e;e++){const r=u.get(`${a[t]}_${s[e]}`);if(!r)continue;const n=(r.val-h)/d;i.push(T(t*c,(s.length-1-e)*l,c,l,`rgb(${Math.round(220-180*n)},${Math.round(220-100*n)},${Math.round(255-50*n)})`,r.datum))}return i}buildStreamingHeatmapScene(t,e){var i,r,n;const o=[],a=null!==(i=this.config.heatmapXBins)&&void 0!==i?i:20,s=null!==(r=this.config.heatmapYBins)&&void 0!==r?r:20,c=null!==(n=this.config.heatmapAggregation)&&void 0!==n?n:"count",l=R(this.config.valueAccessor,"value");if(!this.scales||0===t.length)return o;const[u,h]=this.scales.x.domain(),[f,d]=this.scales.y.domain(),y=(h-u||1)/a,g=(d-f||1)/s,p=new Map;for(const e of t){const t=this.getX(e),i=this.getY(e),r=Math.min(Math.floor((t-u)/y),a-1),n=Math.min(Math.floor((i-f)/g),s-1);if(0>r||0>n)continue;const o=`${r}_${n}`;let c=p.get(o);c||(c={sum:0,count:0,data:[]},p.set(o,c)),c.count++,c.sum+=l(e),c.data.push(e)}let m=1/0,x=-1/0;const v=new Map;for(const[t,e]of p){let i;switch(c){case"sum":i=e.sum;break;case"mean":i=e.count>0?e.sum/e.count:0;break;default:i=e.count}v.set(t,i),m>i&&(m=i),i>x&&(x=i)}const k=x-m||1,b=e.width/a,w=e.height/s;for(const[t,e]of v){const[i,r]=t.split("_"),n=+i,a=+r,c=(e-m)/k,l=`rgb(${Math.round(220-180*c)},${Math.round(220-100*c)},${Math.round(255-50*c)})`,u=p.get(t);o.push(T(n*b,(s-1-a)*w,b,w,l,{xi:n,yi:a,value:e,count:u.count,sum:u.sum,data:u.data}))}return o}buildBarScene(t){var e;if(!this.config.binSize)return[];const i=D(t,this.getX,this.getY,this.config.binSize,this.getCategory);if(0===i.size)return[];let r=null;if(this.getCategory){const t=new Set;for(const e of i.values())for(const i of e.categories.keys())t.add(i);const e=this.config.barColors?Object.keys(this.config.barColors):[],n=new Set(e),o=Array.from(t).filter(t=>!n.has(t)).sort();r=[...e.filter(e=>t.has(e)),...o]}const n=[],o=this.scales,[a,s]=o.x.domain();for(const t of i.values()){const i=Math.max(t.start,a),c=Math.min(t.end,s);if(i>=c)continue;const l=o.x(i),u=o.x(c),h=Math.min(l,u)+.5,f=Math.max(l,u)-.5-h;if(f>0)if(r&&t.categories.size>0){let i=0;for(const a of r){const r=t.categories.get(a)||0;if(0===r)continue;const s=o.y(i),c=o.y(i+r);n.push(N(h,Math.min(s,c),f,Math.abs(s-c),{fill:(null===(e=this.config.barColors)||void 0===e?void 0:e[a])||"#4e79a7"},{binStart:t.start,binEnd:t.end,total:t.total,category:a,categoryValue:r},a)),i+=r}}else{const e=o.y(0),i=o.y(t.total);n.push(N(h,Math.min(e,i),f,Math.abs(e-i),{fill:"#007bff"},{binStart:t.start,binEnd:t.end,total:t.total}))}}return n}buildSwarmScene(t){var e,i,r,n;const o=[],a=this.config.swarmStyle||{},s=null!==(e=a.radius)&&void 0!==e?e:3,c=null!==(i=a.fill)&&void 0!==i?i:"#007bff",l=null!==(r=a.opacity)&&void 0!==r?r:.7,u=a.stroke,h=a.strokeWidth;for(const e of t){const t=this.getX(e),i=this.getY(e);if(null==i||Number.isNaN(i))continue;const r=this.scales.x(t),a=this.scales.y(i);let f=c;if(this.getCategory){const t=this.getCategory(e);f=(null===(n=this.config.barColors)||void 0===n?void 0:n[t])||f}const d={type:"point",x:r,y:a,r:s,style:{fill:f,opacity:l,stroke:u,strokeWidth:h},datum:e};this.getPointId&&(d.pointId=this.getPointId(e)+""),o.push(d)}return o}buildWaterfallScene(t,e){var i,r,n;const o=[],a=this.scales,s=this.config.waterfallStyle,c=t.filter(t=>{const e=this.getY(t);return null!=e&&!Number.isNaN(e)});if(0===c.length)return o;const l=null!==(i=null==s?void 0:s.positiveColor)&&void 0!==i?i:"#28a745",u=null!==(r=null==s?void 0:s.negativeColor)&&void 0!==r?r:"#dc3545",h=null!==(n=null==s?void 0:s.gap)&&void 0!==n?n:1,f=null==s?void 0:s.stroke,d=null==s?void 0:s.strokeWidth;let y=0;for(let t=0;c.length>t;t++){const i=c[t],r=this.getX(i),n=this.getY(i),g=y+n;let p;p=c.length-1>t?this.getX(c[t+1])-r:t>0?r-this.getX(c[t-1]):0;const m=a.x(r),x=0!==p?a.x(r+p):m+e.width/10,v=Math.min(m,x)+h/2,k=Math.max(m,x)-h/2-v;if(0>=k){y=g;continue}const b=a.y(y),w=a.y(g);o.push(N(v,Math.min(b,w),k,Math.abs(b-w),{fill:0>n?u:l,stroke:f,strokeWidth:d},Object.assign(Object.assign({},i),{baseline:y,cumEnd:g,delta:n,_connectorStroke:null==s?void 0:s.connectorStroke,_connectorWidth:null==s?void 0:s.connectorWidth}))),y=g}return o}buildCandlestickScene(t,e){if(!(this.getOpen&&this.getHigh&&this.getLow&&this.getClose&&this.scales))return[];const i=[],r=this.config.candlestickStyle||{},n=r.upColor||"#28a745",o=r.downColor||"#dc3545",a=r.wickColor||"#333",s=r.wickWidth||1,c=t.map(t=>this.getX(t)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let l=r.bodyWidth||6;if(!r.bodyWidth&&c.length>1){let t=1/0;for(let e=1;c.length>e;e++){const i=Math.abs(this.scales.x(c[e])-this.scales.x(c[e-1]));i>0&&t>i&&(t=i)}t!==1/0&&(l=Math.max(2,Math.min(.6*t,20)))}for(const e of t){const t=this.getX(e);if(null==t||Number.isNaN(t))continue;const r=this.getOpen(e),c=this.getHigh(e),u=this.getLow(e),h=this.getClose(e);if([r,c,u,h].some(t=>null==t||Number.isNaN(t)))continue;const f=h>=r;i.push({type:"candlestick",x:this.scales.x(t),openY:this.scales.y(r),closeY:this.scales.y(h),highY:this.scales.y(c),lowY:this.scales.y(u),bodyWidth:l,upColor:n,downColor:o,wickColor:a,wickWidth:s,isUp:f,datum:e})}return i}buildBoundsForGroup(t,e){if(!this.getBounds||!this.scales)return null;const i=[],r=[];for(const e of t){const t=this.getX(e),n=this.getY(e);if(null==t||null==n||Number.isNaN(t)||Number.isNaN(n))continue;const o=this.getBounds(e),a=this.scales.x(t);if(o&&0!==o)i.push([a,this.scales.y(n+o)]),r.push([a,this.scales.y(n-o)]);else{const t=this.scales.y(n);i.push([a,t]),r.push([a,t])}}return 2>i.length?null:{type:"area",topPath:i,bottomPath:r,style:this.resolveBoundsStyle(e,t[0]),datum:t,group:e,interactive:!1}}resolveBoundsStyle(t,e){const i=this.config.boundsStyle;return"function"==typeof i?i(e||{},t):i&&"object"==typeof i?i:{fill:this.resolveLineStyle(t,e).stroke||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(t,e){var i,r,n;const o=this.config.decay;if(!o||1>=e)return 1;const a=null!==(i=o.minOpacity)&&void 0!==i?i:.1,s=e-1-t;switch(o.type){case"linear":return a+(1-s/(e-1))*(1-a);case"exponential":{const t=null!==(r=o.halfLife)&&void 0!==r?r:e/2;return a+Math.pow(.5,s/t)*(1-a)}case"step":return(null!==(n=o.stepThreshold)&&void 0!==n?n:.5*e)>s?1:a;default:return 1}}applyDecay(t,e){var i,r;if(!this.config.decay)return;const n=e.length;if(1>=n)return;const o=new Map;for(let t=0;e.length>t;t++)o.set(e[t],t);for(const e of t){if("line"===e.type||"area"===e.type)continue;const t=o.get(e.datum);if(null==t)continue;const a=this.computeDecayOpacity(t,n);if("heatcell"===e.type)e.style={opacity:a};else if("candlestick"===e.type)e._decayOpacity=a;else{const t=null!==(r=null===(i=e.style)||void 0===i?void 0:i.opacity)&&void 0!==r?r:1;e.style=Object.assign(Object.assign({},e.style),{opacity:t*a})}}}computePulseIntensity(t,e){var i;const r=this.config.pulse;if(!r)return 0;const n=null!==(i=r.duration)&&void 0!==i?i:500,o=e-t;return n>o?1-o/n:0}applyPulse(t,e){var i,r;if(!this.config.pulse||!this.timestampBuffer)return;const n="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(i=this.config.pulse.color)&&void 0!==i?i:"rgba(255,255,255,0.6)",a=null!==(r=this.config.pulse.glowRadius)&&void 0!==r?r:4,s=new Map;for(let t=0;e.length>t;t++)s.set(e[t],t);for(const e of t){if("line"===e.type||"area"===e.type)continue;const t=s.get(e.datum);if(null==t)continue;const i=this.timestampBuffer.get(t);if(null==i)continue;const r=this.computePulseIntensity(i,n);r>0&&(e._pulseIntensity=r,e._pulseColor=o,e._pulseGlowRadius=a)}}get hasActivePulses(){var t;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const e="undefined"!=typeof performance?performance.now():Date.now(),i=null!==(t=this.config.pulse.duration)&&void 0!==t?t:500,r=this.timestampBuffer.peek();return null!=r&&i>e-r}snapshotPositions(){this.prevPositionMap.clear();for(let t=0;this.scene.length>t;t++){const e=this.scene[t],i=this.getNodeIdentity(e,t);i&&("point"===e.type?this.prevPositionMap.set(i,{x:e.x,y:e.y,r:e.r}):"rect"===e.type||"heatcell"===e.type?this.prevPositionMap.set(i,{x:e.x,y:e.y,w:e.w,h:e.h}):"candlestick"===e.type&&this.prevPositionMap.set(i,{x:e.x,y:e.openY}))}}getNodeIdentity(t,e){var i,r,n,o;switch(t.type){case"point":return`p:${void 0===t.datum?e:this.getX(t.datum)}_${this.getY(t.datum)}`;case"rect":return`r:${t.group||""}:${null!==(o=null!==(r=null===(i=t.datum)||void 0===i?void 0:i.binStart)&&void 0!==r?r:null===(n=t.datum)||void 0===n?void 0:n.category)&&void 0!==o?o:e}`;case"heatcell":return`h:${t.x}_${t.y}`;case"candlestick":return"c:"+this.getX(t.datum);default:return null}}startTransition(){var t,e,i,r,n,o;if(!this.config.transition||0===this.prevPositionMap.size)return;const a=null!==(t=this.config.transition.duration)&&void 0!==t?t:300;let s=!1;for(let t=0;this.scene.length>t;t++){const a=this.scene[t],c=this.getNodeIdentity(a,t);if(!c)continue;const l=this.prevPositionMap.get(c);if(l)if("point"===a.type){const t={x:a.x,y:a.y,r:a.r};l.x===t.x&&l.y===t.y||(a._targetX=t.x,a._targetY=t.y,a._targetR=t.r,a.x=l.x,a.y=l.y,a.r=null!==(e=l.r)&&void 0!==e?e:a.r,s=!0)}else if("rect"===a.type){const t={x:a.x,y:a.y,w:a.w,h:a.h};l.x===t.x&&l.y===t.y&&l.w===t.w&&l.h===t.h||(a._targetX=t.x,a._targetY=t.y,a._targetW=t.w,a._targetH=t.h,a.x=l.x,a.y=l.y,a.w=null!==(i=l.w)&&void 0!==i?i:a.w,a.h=null!==(r=l.h)&&void 0!==r?r:a.h,s=!0)}else if("heatcell"===a.type){const t={x:a.x,y:a.y,w:a.w,h:a.h};l.x===t.x&&l.y===t.y||(a._targetX=t.x,a._targetY=t.y,a._targetW=t.w,a._targetH=t.h,a.x=l.x,a.y=l.y,a.w=null!==(n=l.w)&&void 0!==n?n:a.w,a.h=null!==(o=l.h)&&void 0!==o?o:a.h,s=!0)}}s&&(this.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:a})}advanceTransition(t){var e;if(!this.activeTransition)return!1;const i=Math.min((t-this.activeTransition.startTime)/this.activeTransition.duration,1),r="linear"===(null===(e=this.config.transition)||void 0===e?void 0:e.easing)?i:1-Math.pow(1-i,3);for(const t of this.scene)if("point"===t.type){if(void 0===t._targetX)continue;const e=this.getNodeIdentity(t,0);if(!e)continue;const i=this.prevPositionMap.get(e);if(!i)continue;t.x=i.x+(t._targetX-i.x)*r,t.y=i.y+(t._targetY-i.y)*r,void 0!==t._targetR&&void 0!==i.r&&(t.r=i.r+(t._targetR-i.r)*r)}else if("rect"===t.type){if(void 0===t._targetX)continue;const e=this.getNodeIdentity(t,0);if(!e)continue;const i=this.prevPositionMap.get(e);if(!i)continue;t.x=i.x+(t._targetX-i.x)*r,t.y=i.y+(t._targetY-i.y)*r,void 0!==i.w&&(t.w=i.w+(t._targetW-i.w)*r),void 0!==i.h&&(t.h=i.h+(t._targetH-i.h)*r)}else if("heatcell"===t.type){if(void 0===t._targetX)continue;const e=this.getNodeIdentity(t,0);if(!e)continue;const i=this.prevPositionMap.get(e);if(!i)continue;t.x=i.x+(t._targetX-i.x)*r,t.y=i.y+(t._targetY-i.y)*r,void 0!==i.w&&(t.w=i.w+(t._targetW-i.w)*r),void 0!==i.h&&(t.h=i.h+(t._targetH-i.h)*r)}if(i>=1){for(const t of this.scene)if("point"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("rect"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("heatcell"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}return this.activeTransition=null,!1}return!0}groupData(t){if(!this.getGroup)return[{key:"_default",data:t}];const e=new Map;for(const i of t){const t=this.getGroup(i);e.has(t)||e.set(t,[]),e.get(t).push(i)}return Array.from(e.entries()).map(([t,e])=>({key:t,data:e}))}resolveLineStyle(t,e){const i=this.config.lineStyle;return"function"==typeof i?i(e||{},t):i&&"object"==typeof i?{stroke:i.stroke||"#007bff",strokeWidth:i.strokeWidth||2,strokeDasharray:i.strokeDasharray,fill:i.fill,fillOpacity:i.fillOpacity,opacity:i.opacity}:{stroke:"#007bff",strokeWidth:2}}resolveAreaStyle(t,e){var i;if(this.config.areaStyle)return this.config.areaStyle(e||{});const r=this.config.lineStyle;return"function"==typeof r?r(e||{},t):r&&"object"==typeof r?{fill:r.fill||r.stroke||"#4e79a7",fillOpacity:null!==(i=r.fillOpacity)&&void 0!==i?i:.7,stroke:r.stroke||"#4e79a7",strokeWidth:r.strokeWidth||2}:{fill:"#4e79a7",fillOpacity:.7,stroke:"#4e79a7",strokeWidth:2}}getData(){return this.buffer.toArray()}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],this.version++}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}updateConfig(t){Object.assign(this.config,t)}}function B(t,e){var i=t.get(e);if(!i)throw Error("missing: "+e);return i}function Y(t,e){var i,r=[],n=[],o=[],a={},s=[];function c(t){o[t]=!1,a.hasOwnProperty(t)&&Object.keys(a[t]).forEach(function(e){delete a[t][e],o[e]&&c(e)})}function l(t){var e,r,h=!1;for(n.push(t),o[t]=!0,e=0;s[t].length>e;e++)(r=s[t][e])===i?(u(i,n),h=!0):o[r]||(h=l(r));if(h)c(t);else for(e=0;s[t].length>e;e++){var f=a[r=s[t][e]];f||(a[r]=f={}),f[r]=!0}return n.pop(),h}function u(t,e){var i=[].concat(e).concat(t);r.push(i)}function h(e){!function(e){for(var i=0;t.length>i;i++)i>=e&&t[i]||(t[i]=[]),t[i]=t[i].filter(function(t){return t>=e})}(e);for(var i,r=function(t){for(var e=t.length,i=Array(e),r=Array(e),n=Array(e),o=Array(e),a=Array(e),s=Array(e),c=0;e>c;++c)i[c]=-1,r[c]=0,n[c]=!1,o[c]=0,a[c]=-1,s[c]=[];var l,u=0,h=[],f=[];function d(e){var c=[e],l=[e];for(i[e]=r[e]=u,n[e]=!0,u+=1;l.length>0;){var d=t[e=l[l.length-1]];if(d.length>o[e]){for(var y=o[e];d.length>y;++y){var g=d[y];if(0>i[g]){i[g]=r[g]=u,n[g]=!0,u+=1,c.push(g),l.push(g);break}n[g]&&(r[e]=0|Math.min(r[e],r[g])),0>a[g]||s[e].push(a[g])}o[e]=y}else{if(r[e]===i[e]){var p=[],m=[],x=0;for(y=c.length-1;y>=0;--y){var v=c[y];if(n[v]=!1,p.push(v),m.push(s[v]),x+=s[v].length,a[v]=h.length,v===e){c.length=y;break}}h.push(p);var k=Array(x);for(y=0;m.length>y;y++)for(var b=0;m[y].length>b;b++)k[--x]=m[y][b];f.push(k)}l.pop()}}}for(c=0;e>c;++c)0>i[c]&&d(c);for(c=0;f.length>c;c++){var y=f[c];if(0!==y.length){y.sort(function(t,e){return t-e}),l=[y[0]];for(var g=1;y.length>g;g++)y[g]!==y[g-1]&&l.push(y[g]);f[c]=l}}return{components:h,adjacencyList:f}}(t),n=r.components.filter(function(t){return t.length>1}),o=1/0,a=0;n.length>a;a++)for(var s=0;n[a].length>s;s++)o>n[a][s]&&(o=n[a][s],i=a);var c=n[i];if(!c)return!1;var l=t.map(function(t,e){return-1===c.indexOf(e)?[]:t.filter(function(t){return-1!==c.indexOf(t)})});return{leastVertex:o,adjList:l}}i=0;for(var f=t.length;f>i;){var d=h(i);if(i=d.leastVertex,s=d.adjList){for(var y=0;s.length>y;y++)for(var g=0;s[y].length>g;g++){var p=s[y][g];o[+p]=!1,a[p]={}}l(i),i+=1}else i=f}return r}function X(t){return t.y0-t.y1>0?"up":"down"}function C(t,e){return e(t.source)==e(t.target)}function I(t){var e=0;t.source.sourceLinks.forEach(function(t){e=t.circular?e+1:e});var i=0;return t.target.targetLinks.forEach(function(t){i=t.circular?i+1:i}),1>=e&&1>=i}function j(t){return t.target.x0-t.source.x1}function F(t,e){var i=H(t),r=j(e)/Math.tan(i);return"up"==X(t)?t.y1-r:t.y1+r}function q(t,e){var i=H(t),r=j(e)/Math.tan(i);return"up"==X(t)?t.y1+r:t.y1-r}function H(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function G(t,e){return e(t)}function V(t){return Q(t.source)}function Z(t){return Q(t.target)}function Q(t){return(t.y0+t.y1)/2}function U(t){return t.virtual?0:t.value}function J(t,e){var i=0;t.sourceLinks.forEach(function(t){i=t.circular&&!C(t,e)?i+1:i});var r=0;return t.targetLinks.forEach(function(t){r=t.circular&&!C(t,e)?r+1:r}),i+r}function K(t){return t.target.depth}function tt(t,e){return t.sourceLinks.length?t.depth:e-1}function et(t,e){return t.y0-e.y0}function it(t,e){return e.y0-t.y0}function rt(t,e){return t.y1-e.y1}function nt(t,e){return e.y1-t.y1}function ot(t,e){return st(t.source,e.source)||t.index-e.index}function at(t,e){return st(t.target,e.target)||t.index-e.index}function st(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function ct(t,e){return lt(t)==lt(e)?"bottom"==t.circularLinkType?it(t,e):et(t,e):lt(e)-lt(t)}function lt(t){return t.target.column-t.source.column}function ut(t,e){return ht(t)==ht(e)}function ht(t){return t.y0-t.y1>0?"up":"down"}function ft(t,e,i,r,o){let a=t;var s=Math.max(8,.15*(a.y1-a.y0));a.links.forEach(function(t){t.circular&&(t._circularWidth=Math.min(t.width,s))});var c=n(a.links,function(t){return t.source.y0});a.links.forEach(function(t){t.circular&&(t.circularPathData={})});var l=a.links.filter(function(t){return t.circular});return l.sort(function(t,e){return e.value-t.value}),l.forEach(function(t,e){t._circularStub=e>=4}),dt(a.links.filter(function(t){return"top"==t.circularLinkType}),e,i),dt(a.links.filter(function(t){return"bottom"==t.circularLinkType}),e,i),a.links.forEach(function(t){if(t.circular){if(t.circularPathData.arcRadius=t._circularWidth+r,t.circularPathData.rightNodeBuffer=5,t.circularPathData.leftNodeBuffer=5,t.circularPathData.sourceWidth=t.source.x1-t.source.x0,t.circularPathData.sourceX=t.source.x0+t.circularPathData.sourceWidth,t.circularPathData.targetX=t.target.x0,t.circularPathData.sourceY=t.y0,t.circularPathData.targetY=t.y1,C(t,e)&&I(t))t.circularPathData.rightSmallArcRadius=r+t._circularWidth/2,t.circularPathData.rightLargeArcRadius=r+t._circularWidth/2,t.circularPathData.leftSmallArcRadius=r+t._circularWidth/2,t.circularPathData.leftLargeArcRadius=r+t._circularWidth/2,"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=t.source.y1+o+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=t.source.y0-o-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius);else{var n=t.source.column,s=t.circularLinkType,l=a.links.filter(function(t){return t.source.column==n&&t.circularLinkType==s});l.sort("bottom"==t.circularLinkType?it:et);var u=0;l.forEach(function(e,n){e.circularLinkID==t.circularLinkID&&(t.circularPathData.rightSmallArcRadius=r+t._circularWidth/2+u,t.circularPathData.rightLargeArcRadius=r+t._circularWidth/2+n*i+u),u+=e._circularWidth||e.width}),n=t.target.column,(l=a.links.filter(function(t){return t.target.column==n&&t.circularLinkType==s})).sort("bottom"==t.circularLinkType?nt:rt),u=0,l.forEach(function(e,n){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=r+t._circularWidth/2+u,t.circularPathData.leftLargeArcRadius=r+t._circularWidth/2+n*i+u),u+=e._circularWidth||e.width}),"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=Math.max(a.y1,t.source.y1,t.target.y1)+o+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=c-o-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius)}t.circularPathData.rightInnerExtent=t.circularPathData.sourceX+t.circularPathData.rightNodeBuffer,t.circularPathData.leftInnerExtent=t.circularPathData.targetX-t.circularPathData.leftNodeBuffer,t.circularPathData.rightFullExtent=t.circularPathData.sourceX+t.circularPathData.rightLargeArcRadius+t.circularPathData.rightNodeBuffer,t.circularPathData.leftFullExtent=t.circularPathData.targetX-t.circularPathData.leftLargeArcRadius-t.circularPathData.leftNodeBuffer}t.path=t.circular?function(t){return"top"==t.circularLinkType?"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 0 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY-t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 0 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 0 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY-t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 0 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY:"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 1 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY+t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 1 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 1 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY+t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 1 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY}(t):function(t){var e=t.source.x1,i=t.y0,r=t.target.x0,n=t.y1,o=(e+r)/2;return"M"+e+","+i+"C"+o+","+i+" "+o+","+n+" "+r+","+n}(t)}),a}function dt(t,e,i){t.sort(ct);var r=t.filter(function(t){return!t._circularStub});return t.forEach(function(t,n){var o=0;if(t._circularStub)t.circularPathData.verticalBuffer=0;else if(C(t,e)&&I(t))t.circularPathData.verticalBuffer=o+t._circularWidth/2;else{for(var a=0;r.length>a;a++){var s=r[a];if(s!==t&&s.circularPathData&&void 0!==s.circularPathData.verticalBuffer&&yt(t,s)){var c=s.circularPathData.verticalBuffer+(s._circularWidth||s.width)/2+i;o=c>o?c:o}}t.circularPathData.verticalBuffer=o+t._circularWidth/2}}),t}function yt(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}function gt(t){return function(){return t}}function pt(t){return t.index}function mt(t){return t.nodes}function xt(t){return t.links}function vt(t,e,i){var r=o(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});r.forEach(function(n){var o=n.length;n.sort(e||function(t,e){return t.circularLinkType==e.circularLinkType?J(e,i)-J(t,i):"top"==t.circularLinkType&&"bottom"==e.circularLinkType||"top"==t.circularLinkType&&0==e.partOfCycle||0==t.partOfCycle&&"bottom"==e.circularLinkType?-1:0}),n.forEach(function(e,n){e.depth==r.length-1&&1==o||0==e.depth&&1==o?(e.y0=t.y1/2-e.value*t.ky,e.y1=e.y0+e.value*t.ky):e.partOfCycle?0==J(e,i)?(e.y0=t.y1/2+n,e.y1=e.y0+e.value*t.ky):"top"==e.circularLinkType?(e.y0=t.y0+n,e.y1=e.y0+e.value*t.ky):(e.y0=t.y1-e.value*t.ky-n,e.y1=e.y0+e.value*t.ky):0==t.y0||0==t.y1?(e.y0=(t.y1-t.y0)/o*n,e.y1=e.y0+e.value*t.ky):(e.y0=(t.y1-t.y0)/2-o/2+n,e.y1=e.y0+e.value*t.ky)})})}function kt(t,e,i,r,n,a){var s=o(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});f();for(var l=1,u=a;u>0;--u)h(l*=.99,i),f();function h(e,i){var r=s.length;s.forEach(function(n){var o=n.length,a=n[0].depth;n.forEach(function(n){var s;if(n.sourceLinks.length||n.targetLinks.length)if(n.partOfCycle&&J(n,i)>0){var l=c(n.sourceLinks,Z),u=c(n.targetLinks,V),h=l&&u?(l+u)/2:l||u;if(h){var f=(h-Q(n))*e*.3;n.y0+=f,n.y1+=f}}else if(0==a&&1==o)n.y0=t.y1/2-(s=n.y1-n.y0)/2,n.y1=t.y1/2+s/2;else if(a==r-1&&1==o)n.y0=t.y1/2-(s=n.y1-n.y0)/2,n.y1=t.y1/2+s/2;else if(1==n.targetLinks.length&&1==n.targetLinks[0].source.sourceLinks.length)s=n.y1-n.y0,n.y0=n.targetLinks[0].source.y0,n.y1=n.y0+s;else{var d=c(n.sourceLinks,Z),y=c(n.targetLinks,V),g=((d&&y?(d+y)/2:d||y)-Q(n))*e;n.y0+=g,n.y1+=g}})})}function f(){s.forEach(function(i){var o,a,s,c=t.y0,l=i.length;for(i.sort(e||st),s=0;l>s;++s)(a=c-(o=i[s]).y0)>0&&(o.y0+=a,o.y1+=a),c=o.y1+r;if((a=c-r-t.y1)>0)for(c=o.y0-=a,o.y1-=a,s=l-2;s>=0;--s)(a=(o=i[s]).y1+n-c)>0&&(o.y0-=a,o.y1-=a),c=o.y0})}}function bt(t){t.nodes.forEach(function(t){t.sourceLinks.sort(at),t.targetLinks.sort(ot)}),t.nodes.forEach(function(t){var e=t.y0,i=e,r=t.y1,n=r;t.sourceLinks.forEach(function(t){t.circular?(t.y0=r-t.width/2,r-=t.width):(t.y0=e+t.width/2,e+=t.width)}),t.targetLinks.forEach(function(t){t.circular?(t.y1=n-t.width/2,n-=t.width):(t.y1=i+t.width/2,i+=t.width)})})}function wt(){var t=0,e=0,i=1,r=1,c=24,u=8,h=null,f=pt,d=tt,y=void 0,g=32,p=2,m=mt,x=xt;function v(){var v={nodes:m.apply(null,arguments),links:x.apply(null,arguments)};return function(m){m.x0=t,m.y0=e,m.x1=i,m.y1=r,m.py=0,function(t,e){t.nodes.forEach(function(t,e){t.index=e,t.sourceLinks=[],t.targetLinks=[]});var i=function(t,e){var i=new Map;return l(t,e).forEach(function(t,e){i.set(e,t[0])}),i}(t.nodes,e);t.links.forEach(function(t,e){t.index=e;var r=t.source,n=t.target;"object"!=typeof r&&(r=t.source=B(i,r)),"object"!=typeof n&&(n=t.target=B(i,n)),r.sourceLinks.push(t),n.targetLinks.push(t)})}(m,f),function(t,e){var i=0;if(null==e){for(var r=[],n=0;t.links.length>n;n++){var o=t.links[n],a=o.source.index,s=o.target.index;r[a]||(r[a]=[]),r[s]||(r[s]=[]),-1===r[a].indexOf(s)&&r[a].push(s)}var c=Y(r);c.sort(function(t,e){return t.length-e.length});var l={};for(n=0;c.length>n;n++){var u=c[n].slice(-2);l[u[0]]||(l[u[0]]={}),l[u[0]][u[1]]=!0}t.links.forEach(function(t){var e=t.target.index,r=t.source.index;e===r||l[r]&&l[r][e]?(t.circular=!0,t.circularLinkID=i++):t.circular=!1})}else t.links.forEach(function(t){e(t.source)<e(t.target)?t.circular=!1:(t.circular=!0,t.circularLinkID=i++)})}(m,y),function(t,e){var i=0,r=0;t.links.forEach(function(n){n.circular&&(n.circularLinkType=n.source.circularLinkType||n.target.circularLinkType?n.source.circularLinkType?n.source.circularLinkType:n.target.circularLinkType:r>i?"top":"bottom","top"==n.circularLinkType?i++:r++,t.nodes.forEach(function(t){G(t,e)!=G(n.source,e)&&G(t,e)!=G(n.target,e)||(t.circularLinkType=n.circularLinkType)}))}),t.links.forEach(function(t){t.circular&&(t.source.circularLinkType==t.target.circularLinkType&&(t.circularLinkType=t.source.circularLinkType),C(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(m,f),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max(s(t.sourceLinks,U),s(t.targetLinks,U)),t.sourceLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)}),t.targetLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)})})}(m),function(t,e,i){var r,n,o;if(null!=e){t.nodes.sort(function(t,i){return e(t)<e(i)?-1:1});var a=0,s=e(t.nodes[0]);t.nodes.forEach(function(t){a=e(t)==s?a:a+1,s=e(t)==s?s:e(t),t.column=a})}for(r=t.nodes,n=[],o=0;r.length;++o,r=n,n=[])r.forEach(function(t){t.depth=o,t.sourceLinks.forEach(function(t){0>n.indexOf(t.target)&&!t.circular&&n.push(t.target)})});for(r=t.nodes,n=[],o=0;r.length;++o,r=n,n=[])r.forEach(function(t){t.height=o,t.targetLinks.forEach(function(t){0>n.indexOf(t.source)&&!t.circular&&n.push(t.source)})});t.nodes.forEach(function(t){t.column=null==e?i(t,o):t.column})}(m,y,d);var x=u;if(null!==h){var v=o(m.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),k=a(v,function(t){return t.length});k>1&&(x=Math.max(1,(r-e)*h/(k-1)))}(function(t,e,i){var r=o(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});t.py=e;var c=n(r,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/s(e,function(t){return t.value})});t.ky=c,t.links.forEach(function(e){e.width=e.value*t.ky});var l=a(t.nodes,function(t){return t.column});t.nodes.forEach(l>0?function(e){e.x0=t.x0+e.column*((t.x1-t.x0-i)/l),e.x1=e.x0+i}:function(e){e.x0=t.x0,e.x1=e.x0+i})})(m,x,c),vt(m,y,f),kt(m,y,f,x,x,g),bt(m),ft(m,f,p,10,8),vt(m,y,f),kt(m,y,f,x,x,g),bt(m),ft(m,f,p,10,8),function(t,e){let i=t;i.nodes.forEach(function(t){t.y+(t.y1-t.y0)>i.y1&&(t.y=t.y-(t.y+(t.y1-t.y0)-i.y1));var r=i.links.filter(function(i){return G(i.source,e)==G(t,e)}),n=r.length;n>1&&r.sort(function(t,e){if(!t.circular&&!e.circular){if(t.target.column==e.target.column)return t.y1-e.y1;if(!ut(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var i=F(e,t);return t.y1-i}if(e.target.column>t.target.column)return F(t,e)-e.y1}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.target.column===e.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.target.column===e.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:"top"==t.circularLinkType?-1:1:void 0});var o=t.y0;r.forEach(function(t){t.y0=o+t.width/2,o+=t.width}),r.forEach(function(e,i){if("bottom"==e.circularLinkType){for(var o=i+1,a=0;n>o;o++)a+=r[o].width;e.y0=t.y1-a-e.width/2}})})}(m,f),function(t,e){let i=t;i.nodes.forEach(function(t){var r=i.links.filter(function(i){return G(i.target,e)==G(t,e)}),n=r.length;n>1&&r.sort(function(t,e){if(!t.circular&&!e.circular){if(t.source.column==e.source.column)return t.y0-e.y0;if(!ut(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var i=q(e,t);return t.y0-i}if(e.source.column>t.source.column)return q(t,e)-e.y0}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:t.source.column-e.source.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:e.source.column-t.source.column:"top"==t.circularLinkType?-1:1:void 0});var o=t.y0;r.forEach(function(t){t.y1=o+t.width/2,o+=t.width}),r.forEach(function(e,i){if("bottom"==e.circularLinkType){for(var o=i+1,a=0;n>o;o++)a+=r[o].width;e.y1=t.y1-a-e.width/2}})})}(m,f),function(t){var e=t.nodes,i=t.links,r=!1,o=!1;if(i.forEach(function(t){"top"==t.circularLinkType?r=!0:"bottom"==t.circularLinkType&&(o=!0)}),0==r||0==o){var s=n(e,function(t){return t.y0}),c=a(e,function(t){return t.y1}),l=(t.y1-t.y0)/(c-s);function u(e){return(e-s)/(c-s)*(t.y1-t.y0)+t.y0}1>l?(e.forEach(function(t){t.y0=u(t.y0),t.y1=u(t.y1)}),i.forEach(function(t){t.y0=u(t.y0),t.y1=u(t.y1),t.width=t.width*l})):e.forEach(function(t){var e=t.y1-t.y0,i=u(t.y0)-t.y0;t.y0=u(t.y0),t.y1=t.y0+e,t.sourceLinks.forEach(function(t){t.y0=t.y0+i}),t.targetLinks.forEach(function(t){t.y1=t.y1+i})})}}(m),ft(m,f,p,10,8)}(v),v}return v.update=function(t){return bt(t),ft(t,f,p,10,8),t},v.nodeWidth=function(t){return arguments.length?(c=+t,v):c},v.nodePadding=function(t){return arguments.length?(u=+t,v):u},v.nodePaddingRatio=function(t){return arguments.length?(h=+t,v):h},v.nodes=function(t){return arguments.length?(m="function"==typeof t?t:gt(t),v):m},v.links=function(t){return arguments.length?(x="function"==typeof t?t:gt(t),v):x},v.nodeId=function(t){return arguments.length?(f="function"==typeof t?t:gt(t),v):f},v.nodeAlign=function(t){return arguments.length?(d="function"==typeof t?t:gt(t),v):d},v.nodeSort=function(t){return arguments.length?(y=t,v):y},v.iterations=function(t){return arguments.length?(g=+t,v):g},v.circularLinkGap=function(t){return arguments.length?(p=+t,v):p},v.extent=function(n){return arguments.length?(t=+n[0][0],e=+n[0][1],i=+n[1][0],r=+n[1][1],v):[[t,e],[i,r]]},v.size=function(n){return arguments.length?(t=e=0,i=+n[0],r=+n[1],v):[i-t,r-e]},v}const Et=t=>{let e,i,r,n,o,a,s,c,l;return"down"===t.direction?(e=t.y0-t.sankeyWidth/2,i=t.y1-t.sankeyWidth/2,r=t.y1+t.sankeyWidth/2,n=t.y0+t.sankeyWidth/2,o=t.source.y1,a=t.target.y0,s=f(o,a),c=s(.5),l=s(.5),`M${e},${o}C${e},${c} ${i},${l} ${i},${a}L${r},${a}C${r},${l} ${n},${c} ${n},${o}Z`):(e=t.source.x1,i=t.target.x0,s=f(e,i),r=s(.5),n=s(.5),o=t.y0-t.sankeyWidth/2,a=t.y1-t.sankeyWidth/2,c=t.y1+t.sankeyWidth/2,l=t.y0+t.sankeyWidth/2,`M${e},${o}C${r},${o} ${n},${a} ${i},${a}L${i},${c}C${n},${c} ${r},${l} ${e},${l}Z`)};function St(t){var e;const i=t.sankeyWidth/2,r=(null!==(e=t._circularWidth)&&void 0!==e?e:t.sankeyWidth)/2,n=t.circularPathData;if(!n)return null;if("down"===t.direction)return null;if(t._circularStub){const e=n.sourceX,r=n.sourceY,o=n.targetX,a=n.targetY;if("object"!=typeof t.source||!t.source||"object"!=typeof t.target||!t.target)return null;const s=Math.max(15,Math.min(40,.33*(n.rightFullExtent-e))),c=Math.max(15,Math.min(40,.33*(o-n.leftFullExtent)));return`M${e},${r-i}L${e+s},${r-i}L${e+s},${r+i}L${e},${r+i}ZM${o},${a-i}L${o-c},${a-i}L${o-c},${a+i}L${o},${a+i}Z`}const o=n.sourceX,a=n.sourceY,s=n.targetX,c=n.targetY,l=n.rightFullExtent,u=n.leftFullExtent,h=n.verticalFullExtent,f="bottom"===t.circularLinkType?1:-1,d=Math.max(4,Math.min(r,15));return`M${o},${a-f*i}L${l},${a-f*i}L${l+r},${a-f*i+f*d}L${l+r},${h+f*r-f*d}L${l+r-d},${h+f*r}L${u-r+d},${h+f*r}L${u-r},${h+f*r-f*d}L${u-r},${c-f*i+f*d}L${u-r+d},${c-f*i}L${s},${c-f*i}L${s},${c+f*i}L${u+r},${c+f*i}L${u+r},${h-f*r}L${l-r},${h-f*r}L${l-r},${a+f*i}L${o},${a+f*i}Z`}const At={left:function(t){return t.depth},right:function(t,e){return e-1-t.height},center:function(t){return t.targetLinks.length?t.depth:t.sourceLinks.length?Math.min.apply(Math,t.sourceLinks.map(K))-1:0},justify:tt},Pt={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,i,r){var n,o,a,s,c,l,u;if(0===t.length)return;const h="vertical"===i.orientation?"down":"right",f=i.nodeAlign||"justify",d=null!==(n=i.nodeWidth)&&void 0!==n?n:15,y=null!==(o=i.nodePaddingRatio)&&void 0!==o?o:.05,g=null!==(a=i.iterations)&&void 0!==a?a:100,p=t.map(t=>Object.assign({},t)),m=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id,value:Math.sqrt(Math.max(1,t.value||1))}));let x;x="down"===h?[[0,0],[r[1],r[0]]]:[[0,0],[r[0],r[1]]];const v=wt().extent(x).links(m).nodes(p).nodeAlign(At[f]||tt).nodeId(t=>t.id).nodeWidth(d).iterations(g);v.nodePaddingRatio&&v.nodePaddingRatio(y),v();{let t=1/0,e=-1/0,i=1/0,n=-1/0;for(const r of p)t>r.x0&&(t=r.x0),r.x1>e&&(e=r.x1),i>r.y0&&(i=r.y0),r.y1>n&&(n=r.y1);for(const r of m){if(!r.circular||!r.circularPathData)continue;const o=r.circularPathData,a=(null!==(c=null!==(s=r._circularWidth)&&void 0!==s?s:r.width)&&void 0!==c?c:0)/2;t>o.leftFullExtent-a&&(t=o.leftFullExtent-a),o.rightFullExtent+a>e&&(e=o.rightFullExtent+a),i>o.verticalFullExtent-a&&(i=o.verticalFullExtent-a),o.verticalFullExtent+a>n&&(n=o.verticalFullExtent+a)}const o=e-t,a=n-i,u=r[0],h=r[1];if(o>0&&a>0&&(0>t||0>i||e>u||n>h)){const e=Math.min(u/o,h/a),r=-t*e+(u-o*e)/2,n=-i*e+(h-a*e)/2;for(const t of p)t.x0=t.x0*e+r,t.x1=t.x1*e+r,t.y0=t.y0*e+n,t.y1=t.y1*e+n;for(const t of m)if(t.y0=t.y0*e+n,t.y1=t.y1*e+n,t.width=(null!==(l=t.width)&&void 0!==l?l:0)*e,t._circularWidth&&(t._circularWidth*=e),t.circular&&t.circularPathData){const i=t.circularPathData;i.sourceX=i.sourceX*e+r,i.targetX=i.targetX*e+r,i.sourceY=i.sourceY*e+n,i.targetY=i.targetY*e+n,i.rightFullExtent=i.rightFullExtent*e+r,i.leftFullExtent=i.leftFullExtent*e+r,i.verticalFullExtent=i.verticalFullExtent*e+n,i.rightInnerExtent=i.rightInnerExtent*e+r,i.leftInnerExtent=i.leftInnerExtent*e+r,i.verticalRightInnerExtent=i.verticalRightInnerExtent*e+n,i.verticalLeftInnerExtent=i.verticalLeftInnerExtent*e+n,i.rightSmallArcRadius*=e,i.rightLargeArcRadius*=e,i.leftSmallArcRadius*=e,i.leftLargeArcRadius*=e,i.sourceWidth*=e,i.rightNodeBuffer*=e,i.leftNodeBuffer*=e,i.arcRadius*=e}}}const k=new Map;for(const e of t)k.set(e.id,e);for(const t of p){const e=k.get(t.id);e&&(e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.value=t.value,e.depth=t.depth,e.sourceLinks=t.sourceLinks,e.targetLinks=t.targetLinks,e.width=t.x1-t.x0,e.height=t.y1-t.y0,e.x=t.x0+(t.x1-t.x0)/2,e.y=t.y0+(t.y1-t.y0)/2)}const b=new Map;for(const t of e)b.set(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const t of m){const e=t.source,i=t.target,r="object"==typeof e&&null!==e?e.id:e+"",n="object"==typeof i&&null!==i?i.id:i+"",o=b.get(`${r}\0${n}`);if(o){o.y0=t.y0,o.y1=t.y1,o.sankeyWidth=null!==(u=t.width)&&void 0!==u?u:0,o.circular=!!t.circular,o.circularPathData=t.circularPathData,o._circularWidth=t._circularWidth,o._circularStub=t._circularStub,o.path=t.path,o.circularLinkType=t.circularLinkType,o.direction=h;const e=k.get(r),i=k.get(n);e&&(o.source=e),i&&(o.target=i)}}},buildScene(t,e,i,r){var n,o,a,s;const c="vertical"===i.orientation?"down":"right",l=i.nodeStyle,u=i.edgeStyle,f=null!==(n=i.edgeOpacity)&&void 0!==n?n:.5,d=i.edgeColorBy||"source",y=Array.isArray(i.colorScheme)?i.colorScheme:h,g=new Map;t.forEach((t,e)=>{g.set(t.id,y[e%y.length])});const p=[],m=[],x=[];for(const e of t){const t=e.x1-e.x0,i=e.y1-e.y0;if(0>=t||0>=i)continue;const r=l?l(e):{},n={fill:r.fill||g.get(e.id)||"#4d430c",stroke:r.stroke,strokeWidth:r.strokeWidth,opacity:r.opacity};p.push({type:"rect",x:e.x0,y:e.y0,w:t,h:i,style:n,datum:e,id:e.id,label:e.id})}const v=[...e].sort((t,e)=>(e.sankeyWidth||0)-(t.sankeyWidth||0));for(const t of v){if(!t.sankeyWidth||0>=t.sankeyWidth)continue;const e="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;if(!e||!i)continue;let r="#999";u?r=u(t).fill||r:"target"===d&&i?r=g.get(i.id)||r:e&&(r=g.get(e.id)||r);const n=u?u(t):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,i=t.sankeyWidth/2,s=Math.max(15,Math.min(40,.33*(e.rightFullExtent-e.sourceX))),c=Math.max(15,Math.min(40,.33*(e.targetX-e.leftFullExtent))),l=n.fill||r;m.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-i}L${e.sourceX+s},${e.sourceY-i}L${e.sourceX+s},${e.sourceY+i}L${e.sourceX},${e.sourceY+i}Z`,style:{fill:l,fillOpacity:null!==(o=n.fillOpacity)&&void 0!==o?o:f,stroke:"none",opacity:n.opacity},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+s}}),m.push({type:"bezier",pathD:`M${e.targetX},${e.targetY-i}L${e.targetX-c},${e.targetY-i}L${e.targetX-c},${e.targetY+i}L${e.targetX},${e.targetY+i}Z`,style:{fill:l,fillOpacity:null!==(a=n.fillOpacity)&&void 0!==a?a:f,stroke:"none",opacity:n.opacity},datum:t,_gradient:{direction:"left",from:0,to:1,x0:e.targetX-c,x1:e.targetX}});continue}let c;if(c=t.circular&&t.circularPathData?St(t):Et(t),!c)continue;const l={fill:n.fill||r,fillOpacity:null!==(s=n.fillOpacity)&&void 0!==s?s:f,stroke:n.stroke||"none",strokeWidth:n.strokeWidth,opacity:n.opacity};m.push({type:"bezier",pathD:c,bezierCache:t.bezier,style:l,datum:t})}if(!1!==i.showLabels){const e=(k=i.nodeLabel)?"function"==typeof k?k:t=>t[k]||t.id:null;for(const i of t){const t=i.x1-i.x0,n=i.y1-i.y0;if(0>=t||0>=n)continue;const o=e?e(i):i.id;if(!o)continue;let a,s,l;"down"===c?(a=i.x0+t/2,s=i.y1+14,l="middle"):(r[0]/2>i.x0+t/2?(a=i.x0-6,l="end"):(a=i.x1+6,l="start"),s=i.y0+n/2),x.push({x:a,y:s,text:o+"",anchor:l,baseline:"middle",fontSize:11})}}var k;return{sceneNodes:p,sceneEdges:m,labels:x}}},Lt={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,i,r){var n,o;if(0===t.length)return;const a=null!==(n=i.iterations)&&void 0!==n?n:Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),s=null!==(o=i.forceStrength)&&void 0!==o?o:.1,c=r[0]/2,l=r[1]/2;for(let e=0;t.length>e;e++){const i=t[e];if(null==i.x||null==i.y||0===i.x&&0===i.y){const t=10*Math.sqrt(e+.5),r=2.399963229728653*e;i.x=c+t*Math.cos(r),i.y=l+t*Math.sin(r)}}const u=Mt(i.nodeSize,i.nodeSizeRange,t),h=d().strength(t=>Math.min(2.5,t.weight?t.weight*s:s)).id(t=>t.id),f=r[1]/r[0],x=y().force("charge",g().strength(t=>-25*(t=>u(t))(t))).force("x",p(r[0]/2).strength(.1*f)).force("y",m(r[1]/2).strength(.1));if(x.nodes(t),e.length>0){const t=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id}));x.force("link",h),x.force("link").links(t)}.1>x.alpha()&&x.alpha(1),x.stop();for(let t=0;a>t;++t)x.tick();const v=new Map;for(const e of t)v.set(e.id,e);for(const t of e){if("string"==typeof t.source){const e=v.get(t.source);e&&(t.source=e)}if("string"==typeof t.target){const e=v.get(t.target);e&&(t.target=e)}}},buildScene(t,e,i,r){var n,o,a;const s=i.nodeStyle,c=i.edgeStyle,l=Mt(i.nodeSize,i.nodeSizeRange,t),u=Array.isArray(i.colorScheme)?i.colorScheme:h,f=new Map;t.forEach((t,e)=>{f.set(t.id,u[e%u.length])});const d=[],y=[],g=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=l(e),i=s?s(e):{},r={fill:i.fill||f.get(e.id)||"#007bff",stroke:i.stroke||"#fff",strokeWidth:null!==(n=i.strokeWidth)&&void 0!==n?n:2,opacity:i.opacity};d.push({type:"circle",cx:e.x,cy:e.y,r:t,style:r,datum:e,id:e.id,label:e.id})}const p=new Map;for(const e of t)p.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:p.get(t.source),i="object"==typeof t.target?t.target:p.get(t.target);if(!e||!i)continue;if(null==e.x||null==e.y)continue;if(null==i.x||null==i.y)continue;const r=c?c(t):{},n={stroke:r.stroke||"#999",strokeWidth:null!==(o=r.strokeWidth)&&void 0!==o?o:1,opacity:null!==(a=r.opacity)&&void 0!==a?a:.6};y.push({type:"line",x1:e.x,y1:e.y,x2:i.x,y2:i.y,style:n,datum:t})}if(!1!==i.showLabels){const e=(m=i.nodeLabel)?"function"==typeof m?m:t=>t[m]||t.id:null;for(const i of t){if(null==i.x||null==i.y)continue;const t=e?e(i):i.id;if(!t)continue;const r=l(i);g.push({x:i.x,y:i.y-r-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var m;return{sceneNodes:d,sceneEdges:y,labels:g}}};function Mt(t,e,r){var o,s;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const c=e||[5,20],l=r.map(e=>{var i;return null===(i=e.data)||void 0===i?void 0:i[t]}).filter(t=>null!=t&&"number"==typeof t);if(0===l.length)return()=>c[0];const u=null!==(o=n(l))&&void 0!==o?o:0,h=null!==(s=a(l))&&void 0!==s?s:1;if(u===h)return()=>(c[0]+c[1])/2;const f=i().domain([u,h]).range(c).clamp(!0);return e=>{var i;const r=null===(i=e.data)||void 0===i?void 0:i[t];return null==r||"number"!=typeof r?c[0]:f(r)}}const Dt=h,_t={supportsStreaming:!1,hierarchical:!1,computeLayout(t,i,r,n){if(0===t.length)return;const{padAngle:o=.01,groupWidth:a=20,sortGroups:s}=r,c=Math.min(n[0],n[1])/2,l=c-a,u=n[0]/2,h=n[1]/2,f=(d=r.valueAccessor)?"function"==typeof d?d:t=>{var e;return null!==(e=t[d])&&void 0!==e?e:1}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:1};var d;const y=new Map;for(let e=0;t.length>e;e++)y.set(t[e].id,e);const g=t.length,p=Array.from({length:g},()=>Array.from({length:g},()=>0));for(const t of i){const e="string"==typeof t.target?t.target:t.target.id,i=y.get("string"==typeof t.source?t.source:t.source.id),r=y.get(e);if(void 0===i||void 0===r)continue;const n=f(t);p[i][r]=n}const m=v().padAngle(o);s&&m.sortGroups(s);const x=m(p),k=x.groups,b=e().innerRadius(l).outerRadius(c);for(const e of k){const i=t[e.index],r=b.centroid(e);i.x=r[0]+u,i.y=r[1]+h,i.arcData={startAngle:e.startAngle,endAngle:e.endAngle}}const w=new Map;for(const e of t)w.set(e.id,e);for(const t of i){const e="string"==typeof t.target?t.target:t.target.id,i=w.get("string"==typeof t.source?t.source:t.source.id),r=w.get(e);i&&(t.source=i),r&&(t.target=r)}const E=new Map;for(const t of i)E.set(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const e of x){const i=t[e.source.index].id,r=t[e.target.index].id,n=E.get(`${i}\0${r}`)||E.get(`${r}\0${i}`);n&&(n.chordData=e)}},buildScene(t,e,i,r){var n,o;const{groupWidth:a=20,edgeOpacity:s=.5}=i,c=Math.min(r[0],r[1])/2,l=c-a,u=r[0]/2,h=r[1]/2,f=i.nodeStyle,d=i.edgeStyle,y=i.edgeColorBy||"source",g=Array.isArray(i.colorScheme)?i.colorScheme:Dt,p=new Map;t.forEach((t,e)=>{p.set(t.id,g[e%g.length])});const m=x().radius(l),v=[],k=[],b=[];for(let e=0;t.length>e;e++){const i=t[e],r=i.arcData;if(!r)continue;let o;o=f?f(i).fill||p.get(i.id)||g[e%g.length]:p.get(i.id)||g[e%g.length];const a=f?f(i):{},s={fill:o,stroke:a.stroke||"black",strokeWidth:null!==(n=a.strokeWidth)&&void 0!==n?n:1,opacity:a.opacity};v.push({type:"arc",cx:u,cy:h,innerR:l,outerR:c,startAngle:r.startAngle-Math.PI/2,endAngle:r.endAngle-Math.PI/2,style:s,datum:i,id:i.id,label:i.id})}for(const t of e){const e=t.chordData;if(!e)continue;const i=m(e);if(!i)continue;const r=$t(i,u,h);let n="#999";if(d)n=d(t).fill||n;else{const e="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;"target"===y&&i?n=p.get(i.id)||n:e&&(n=p.get(e.id)||n)}const a=d?d(t):{},c={fill:n,fillOpacity:null!==(o=a.fillOpacity)&&void 0!==o?o:s,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity};k.push({type:"ribbon",pathD:r,style:c,datum:t})}if(!1!==i.showLabels){const e=(w=i.nodeLabel)?"function"==typeof w?w:t=>t[w]||t.id:null,r=c+12;for(const i of t){const t=i.arcData;if(!t)continue;const n=e?e(i):i.id;if(!n)continue;const o=(t.startAngle+t.endAngle)/2,a=o-Math.PI/2;b.push({x:u+Math.cos(a)*r,y:h+Math.sin(a)*r,text:n+"",anchor:o>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var w;return{sceneNodes:v,sceneEdges:k,labels:b}}};function $t(t,e,i){const r=t.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!r)return t;const n=[];let o=0;for(;r.length>o;){const t=r[o];if("M"===t||"L"===t)for(n.push(t),o++;r.length>o&&!isNaN(Number(r[o]));)n.push(Number(r[o])+e+""),o++,r.length>o&&!isNaN(Number(r[o]))&&(n.push(Number(r[o])+i+""),o++);else if("C"===t)for(n.push(t),o++;r.length>o&&!isNaN(Number(r[o]));)for(let t=0;3>t&&r.length>o&&!isNaN(Number(r[o]));t++)n.push(Number(r[o])+e+""),o++,r.length>o&&!isNaN(Number(r[o]))&&(n.push(Number(r[o])+i+""),o++);else if("Q"===t)for(n.push(t),o++;r.length>o&&!isNaN(Number(r[o]));)for(let t=0;2>t&&r.length>o&&!isNaN(Number(r[o]));t++)n.push(Number(r[o])+e+""),o++,r.length>o&&!isNaN(Number(r[o]))&&(n.push(Number(r[o])+i+""),o++);else if("A"===t)for(n.push(t),o++;r.length>o&&!isNaN(Number(r[o]));)n.push(r[o++]),r.length>o&&n.push(r[o++]),r.length>o&&n.push(r[o++]),r.length>o&&n.push(r[o++]),r.length>o&&n.push(r[o++]),r.length>o&&(n.push(Number(r[o])+e+""),o++),r.length>o&&(n.push(Number(r[o])+i+""),o++);else"Z"===t||"z"===t?(n.push(t),o++):(n.push(r[o]),o++)}return n.join(" ")}const Wt={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,i,r){var n;const o=i.__hierarchyRoot;if(!o)return;const a=i.chartType,s=(c=i.childrenAccessor)?"function"==typeof c?c:t=>t[c]:void 0;var c;const l=i.hierarchySum||(t=>{var e;return null!==(e=t.value)&&void 0!==e?e:0}),u=k(o,s);u.sum(l),u.sort((t,e)=>{var i,r;return(null!==(i=e.value)&&void 0!==i?i:0)-(null!==(r=t.value)&&void 0!==r?r:0)});const[h,f]=r;switch(a){case"tree":!function(t,e,i,r){const n=e.treeOrientation||"vertical",o=P();o.size("horizontal"===n?[r,i]:"radial"===n?[2*Math.PI,Math.min(i,r)/2*.8]:[i,r]),o(t)}(u,i,h,f);break;case"cluster":!function(t,e,i,r){const n=e.treeOrientation||"vertical",o=A();o.size("horizontal"===n?[r,i]:"radial"===n?[2*Math.PI,Math.min(i,r)/2*.8]:[i,r]),o(t)}(u,i,h,f);break;case"treemap":!function(t,e,i,r){var n,o;const a=null!==(n=e.padding)&&void 0!==n?n:4,s=null!==(o=e.paddingTop)&&void 0!==o?o:0,c=E().size([i,r]).tile(S).padding(a);s>0&&c.paddingTop(s),c(t)}(u,i,h,f);break;case"circlepack":!function(t,e,i,r){var n;const o=null!==(n=e.padding)&&void 0!==n?n:4;w().size([i,r]).padding(o)(t)}(u,i,h,f);break;case"partition":!function(t,e,i,r){var n;b().size([i,r]).padding(null!==(n=e.padding)&&void 0!==n?n:1)(t)}(u,i,h,f)}const d=u.descendants();t.length=0,e.length=0;const y=new Map;for(let e=0;d.length>e;e++){const r=d[e],o={id:Ot(r,i,e),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(n=r.value)&&void 0!==n?n:0,depth:r.depth,data:r.data,createdByFrame:!0};"tree"===a||"cluster"===a?Nt(o,r,i):"treemap"===a||"partition"===a?Tt(o,r):"circlepack"===a&&Rt(o,r),o.__hierarchyNode=r,t.push(o),y.set(r,o)}if("tree"===a||"cluster"===a)for(const t of d)if(t.parent){const i=y.get(t.parent),r=y.get(t);i&&r&&e.push({source:i,target:r,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,i,r){const n=i.nodeStyle||(()=>({})),o=i.edgeStyle||(()=>({}));switch(i.chartType){case"tree":case"cluster":return function(t,e,i,r,n,o){var a,s,c,l,u;const h=[],f=[],d=[],y=i.treeOrientation||"vertical",g="radial"===y,p=r[0]/2,m=r[1]/2,x="number"==typeof(k=i.nodeSize)?k:5,v=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];var k;for(const e of t){let t=e.x,r=e.y;g&&(t+=p,r+=m);const o=n(e);let s=o.fill||"#4d430c";i.colorByDepth&&void 0!==e.depth&&(s=v[e.depth%v.length]);const c={fill:s,stroke:o.stroke||"#fff",strokeWidth:null!==(a=o.strokeWidth)&&void 0!==a?a:1,opacity:o.opacity};h.push({type:"circle",cx:t,cy:r,r:x,style:c,datum:e,id:e.id,label:e.id,depth:e.depth})}const b=null!==(s=i.edgeOpacity)&&void 0!==s?s:.5;for(const t of e){const e="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;if(!e||!i)continue;let r=e.x,n=e.y,a=i.x,s=i.y;g&&(r+=p,n+=m,a+=p,s+=m);const u=zt(r,n,a,s,y),h=o(t),d={fill:"none",stroke:h.stroke||"#999",strokeWidth:null!==(c=h.strokeWidth)&&void 0!==c?c:1.5,opacity:null!==(l=h.opacity)&&void 0!==l?l:b};f.push({type:"curved",pathD:u,style:d,datum:t})}if(!1!==i.showLabels){const e=Bt(i.nodeLabel);for(const i of t){const t=e?e(i):i.id;if(!t)continue;let r,n,o,a=i.x,s=i.y;if(g&&(a+=p,s+=m),g){const t=a-p,e=s-m,i=Math.sqrt(t*t+e*e);i>0?(r=a+t/i*10,n=s+e/i*10,o=0>t?"end":"start"):(r=a,n=s-12,o="middle")}else"horizontal"===y?((null===(u=i.data)||void 0===u?void 0:u.children)&&0!==i.data.children.length?(r=a-x-6,o="end"):(r=a+x+6,o="start"),n=s):(r=a,n=s+x+14,o="middle");d.push({x:r,y:n,text:t+"",anchor:o,baseline:"middle",fontSize:11})}}return{sceneNodes:h,sceneEdges:f,labels:d}}(t,e,i,r,n,o);case"treemap":case"partition":return function(t,e,i,r){var n,o;const a=[],s=[],c=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const i of t){const t=i.x1-i.x0,o=i.y1-i.y0;if(0>=t||0>=o)continue;const s=r(i);let l=s.fill||"#4d430c";e.colorByDepth&&void 0!==i.depth&&(l=c[i.depth%c.length]);const u={fill:l,stroke:s.stroke||"#fff",strokeWidth:null!==(n=s.strokeWidth)&&void 0!==n?n:1,opacity:s.opacity};a.push({type:"rect",x:i.x0,y:i.y0,w:t,h:o,style:u,datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==e.showLabels){const i=Bt(e.nodeLabel);for(const r of t){const t=r.x1-r.x0,n=r.y1-r.y0;if(0>=t||0>=n)continue;if((null===(o=r.data)||void 0===o?void 0:o.children)&&r.data.children.length>0&&"partition"!==e.chartType)continue;const a=i?i(r):r.id;a&&(30>t||16>n||s.push({x:r.x0+t/2,y:r.y0+n/2,text:a+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,n)/6))}))}}return{sceneNodes:a,sceneEdges:[],labels:s}}(t,i,0,n);case"circlepack":return function(t,e,i,r){var n,o,a,s,c;const l=[],u=[],h=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const i of t){const t=null!==(n=i.__radius)&&void 0!==n?n:5;if(0>=t)continue;const s=r(i);let c=s.fill||"#4d430c";e.colorByDepth&&void 0!==i.depth&&(c=h[i.depth%h.length]);const u={fill:c,stroke:s.stroke||"#fff",strokeWidth:null!==(o=s.strokeWidth)&&void 0!==o?o:1,opacity:null!==(a=s.opacity)&&void 0!==a?a:.7};l.push({type:"circle",cx:i.x,cy:i.y,r:t,style:u,datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==e.showLabels){const i=Bt(e.nodeLabel);for(const e of t){const t=null!==(s=e.__radius)&&void 0!==s?s:5,r=i?i(e):e.id;if(!r)continue;if(15>t)continue;const n=!((null===(c=e.data)||void 0===c?void 0:c.children)&&e.data.children.length>0);u.push({x:e.x,y:n?e.y:e.y-t+14,text:r+"",anchor:"middle",baseline:n?"middle":"hanging",fontSize:Math.min(11,Math.max(8,t/3)),fill:n?void 0:"#000",stroke:n?void 0:"#fff",strokeWidth:n?void 0:3,paintOrder:n?void 0:"stroke"})}}return{sceneNodes:l,sceneEdges:[],labels:u}}(t,i,0,n);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Nt(t,e,i){const r=i.treeOrientation||"vertical";if("radial"===r){const i=e.x,r=e.y;t.x=r*Math.cos(i-Math.PI/2),t.y=r*Math.sin(i-Math.PI/2)}else"horizontal"===r?(t.x=e.y,t.y=e.x):(t.x=e.x,t.y=e.y);t.x0=t.x-5,t.x1=t.x+5,t.y0=t.y-5,t.y1=t.y+5,t.width=10,t.height=10}function Tt(t,e){t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.x=(e.x0+e.x1)/2,t.y=(e.y0+e.y1)/2,t.width=e.x1-e.x0,t.height=e.y1-e.y0}function Rt(t,e){var i;const r=null!==(i=e.r)&&void 0!==i?i:0;t.x=e.x,t.y=e.y,t.x0=e.x-r,t.x1=e.x+r,t.y0=e.y-r,t.y1=e.y+r,t.width=2*r,t.height=2*r,t.__radius=r}function zt(t,e,i,r,n){if("horizontal"===n){const n=(t+i)/2;return`M ${t},${e} C ${n},${e} ${n},${r} ${i},${r}`}if("radial"===n){const n=(t+i)/2;return`M ${t},${e} Q ${n},${e} ${n},${(e+r)/2} T ${i},${r}`}{const n=(e+r)/2;return`M ${t},${e} C ${t},${n} ${i},${n} ${i},${r}`}}function Ot(t,e,i){const r=e.nodeIDAccessor;return"function"==typeof r?r(t.data)+"":"string"==typeof r&&void 0!==t.data[r]?t.data[r]+"":void 0!==t.data.name?t.data.name+"":void 0!==t.data.id?t.data.id+"":"node-"+i}function Bt(t){return t?"function"==typeof t?t:e=>{var i;return(null===(i=e.data)||void 0===i?void 0:i[t])||e[t]||e.id}:null}const Yt={sankey:Pt,force:Lt,chord:_t,tree:Wt,cluster:Wt,treemap:Wt,circlepack:Wt,partition:Wt};function Xt(t,e){const{columns:i,config:r,resolvePieceStyle:n}=t,o=[],a=Math.min(e.width,e.height)/2-4,s="donut"===r.chartType?r.innerRadius||60:0,c=-Math.PI/2+(r.startAngle||0)*Math.PI/180,l=2*Math.PI;for(const t of Object.values(i)){const e=c+t.pctStart*l,i=c+(t.pctStart+t.pct)*l,r=n(t.pieceData[0],t.name);o.push({type:"wedge",cx:0,cy:0,innerRadius:s,outerRadius:a,startAngle:e,endAngle:i,style:r,datum:t.pieceData,category:t.name})}return o}function Ct(t){var e,i,r;const n=t.length,o=t[0],a=t[n-1];return{n:n,min:o,q1:null!==(e=u(t,.25))&&void 0!==e?e:o,median:null!==(i=u(t,.5))&&void 0!==i?i:(o+a)/2,q3:null!==(r=u(t,.75))&&void 0!==r?r:a,max:a,mean:t.reduce((t,e)=>t+e,0)/n}}const It={bar:function(t,e){const{scales:i,columns:r,config:n,getR:o,getStack:a,resolvePieceStyle:s}=t,{r:c,projection:l}=i,u=[],h="vertical"===l,f="horizontal"===l,d=n.normalize;for(const t of Object.values(r)){const e=new Map;for(const i of t.pieceData){const t=a?a(i):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const r=e.get(t);r.total+=o(i),r.pieces.push(i)}let i=0;if(d)for(const t of e.values())i+=Math.abs(t.total);let r=0,n=0;for(const[o,l]of e){let e=l.total;d&&i>0&&(e/=i);const y=s(l.pieces[0],a?o:t.name),g=Object.assign(Object.assign({},l.pieces[0]),{__aggregateValue:l.total,__pieceCount:l.pieces.length,category:t.name});if(h){const i=c(0>e?n:r+e),a=0>e?c(n+e)-c(n):c(r)-c(r+e);u.push(N(t.x,i,t.width,Math.abs(a),y,g,o)),0>e?n+=e:r+=e}else if(f){const i=c(0>e?n+e:r),a=0>e?c(n)-c(n+e):c(r+e)-c(r);u.push(N(i,t.x,Math.abs(a),t.width,y,g,o)),0>e?n+=e:r+=e}}}return u},clusterbar:function(t,e){const{scales:i,columns:r,getR:n,getGroup:o,resolvePieceStyle:a}=t,{r:s,projection:c}=i,l=[],u="vertical"===c,h=[],f=new Set;for(const t of Object.values(r))for(const e of t.pieceData){const t=o?o(e):"_default";f.has(t)||(f.add(t),h.push(t))}const d=h.length||1;for(const t of Object.values(r)){const e=t.width/d,i=new Map;for(const e of t.pieceData){const t=o?o(e):"_default";i.has(t)||i.set(t,[]),i.get(t).push(e)}for(let r=0;h.length>r;r++){const o=i.get(h[r])||[];for(const i of o){const o=n(i),c=a(i,t.name);if(u){const n=t.x+r*e,a=s(0),u=s(o);l.push(N(n,Math.min(a,u),e,Math.abs(a-u),c,i,h[r]))}else{const n=t.x+r*e,a=s(0),u=s(o);l.push(N(Math.min(a,u),n,Math.abs(u-a),e,c,i,h[r]))}}}}return l},point:function(t,e){var i,r;const{scales:n,columns:o,getR:a,multiScales:s,resolvePieceStyle:c}=t,{r:l,projection:u}=n,h=[],f="vertical"===u,d="radial"===u,y=s.length>0,g=2*Math.PI,p=-Math.PI/2;for(const t of Object.values(o))for(const e of t.pieceData){const n=null!==(i=e.__rIndex)&&void 0!==i?i:0,o=null!==(r=e.__rValue)&&void 0!==r?r:a(e),u=y&&s[n]||l,m=c(e,t.name),x=m.r||5;let v,k;if(d){const e=p+(t.pctStart+t.pct/2)*g,i=u(o);v=Math.cos(e)*i,k=Math.sin(e)*i}else f?(v=t.middle,k=u(o)):(v=u(o),k=t.middle);h.push({type:"point",x:v,y:k,r:x,style:m,datum:e})}return h},swarm:function(t,e){const{scales:i,columns:r,getR:n,resolvePieceStyle:o}=t,{r:a,projection:s}=i,c=[],l="vertical"===s;for(const t of Object.values(r)){const e=t.width/2;for(let i=0;t.pieceData.length>i;i++){const r=t.pieceData[i],s=n(r),u=o(r,t.name),h=u.r||4,f=(7919*i%100/100-.5)*e*.8,d=l?t.middle+f:a(s),y=l?a(s):t.middle+f;c.push({type:"point",x:d,y:y,r:h,style:u,datum:r})}}return c},pie:Xt,donut:Xt,boxplot:function(t,e){var i,r,n,o,a;const{scales:s,columns:c,config:l,getR:h,resolveSummaryStyle:f}=t,{r:d,projection:y}=s,g=[],p="vertical"===y,m=!1!==l.showOutliers;for(const t of Object.values(c)){const e=t.pieceData.map(t=>h(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(0===e.length)continue;const s=e[0],c=e[e.length-1],l=null!==(i=u(e,.25))&&void 0!==i?i:s,y=null!==(r=u(e,.5))&&void 0!==r?r:(s+c)/2,x=null!==(n=u(e,.75))&&void 0!==n?n:c,v=x-l,k=l-1.5*v,b=x+1.5*v,w=null!==(o=e.find(t=>t>=k))&&void 0!==o?o:s,E=null!==(a=[...e].reverse().find(t=>b>=t))&&void 0!==a?a:c,S=f(t.pieceData[0],t.name),A=[];if(m)for(const e of t.pieceData){const i=h(e);if(k>i||i>b){const r=p?t.middle:d(i),n=p?d(i):t.middle;A.push({px:r,py:n,value:i,datum:e})}}if(g.push({type:"boxplot",x:p?t.middle:0,y:p?0:t.middle,projection:p?"vertical":"horizontal",columnWidth:.6*t.width,minPos:d(w),q1Pos:d(l),medianPos:d(y),q3Pos:d(x),maxPos:d(E),stats:{min:w,q1:l,median:y,q3:x,max:E},style:S,datum:t.pieceData,category:t.name,outliers:A}),m)for(const t of A)g.push({type:"point",x:t.px,y:t.py,r:3,style:{fill:S.fill||"#999",opacity:.6},datum:t.datum})}return g},violin:function(t,e){var i,r,n;const{scales:o,columns:a,config:s,getR:c,resolveSummaryStyle:l}=t,{r:h,projection:f}=o,d=[],y="vertical"===f,g=s.bins||20,p=!1!==s.showIQR;for(const t of Object.values(a)){const e=t.pieceData.map(t=>c(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const o=e[0],a=e[e.length-1],s=(a-o)/g||1,f=Array(g).fill(0);for(const t of e)f[Math.min(Math.floor((t-o)/s),g-1)]++;const m=Math.max(...f,1),x=t.width/2*.9;let v="";if(y){for(let e=0;g>e;e++){const i=h(o+(e+.5)*s),r=f[e]/m*x;v+=0===e?`M ${t.middle+r} ${i}`:` L ${t.middle+r} ${i}`}for(let e=g-1;e>=0;e--){const i=h(o+(e+.5)*s);v+=` L ${t.middle-f[e]/m*x} ${i}`}v+=" Z"}else{for(let e=0;g>e;e++){const i=h(o+(e+.5)*s),r=f[e]/m*x;v+=0===e?`M ${i} ${t.middle-r}`:` L ${i} ${t.middle-r}`}for(let e=g-1;e>=0;e--)v+=` L ${h(o+(e+.5)*s)} ${t.middle+f[e]/m*x}`;v+=" Z"}const k=l(t.pieceData[0],t.name);let b;if(p&&e.length>=4){const s=null!==(i=u(e,.25))&&void 0!==i?i:o,c=null!==(r=u(e,.5))&&void 0!==r?r:(o+a)/2,l=null!==(n=u(e,.75))&&void 0!==n?n:a;b={q1Pos:h(s),medianPos:h(c),q3Pos:h(l),centerPos:t.middle,isVertical:y}}const w=y?{x:t.x,y:Math.min(h(a),h(o)),width:t.width,height:Math.abs(h(a)-h(o))}:{x:Math.min(h(o),h(a)),y:t.x,width:Math.abs(h(a)-h(o)),height:t.width};d.push({type:"violin",pathString:v,translateX:0,translateY:0,bounds:w,iqrLine:b,stats:Ct(e),style:k,datum:t.pieceData,category:t.name})}return d},histogram:function(t,e){const{scales:i,columns:r,config:n,getR:o,resolveSummaryStyle:a}=t,{r:s}=i,c=[],l=n.bins||25,u=n.normalize;for(const t of Object.values(r)){const e=t.pieceData.map(t=>o(t)).filter(t=>null!=t&&!isNaN(t));if(0===e.length)continue;const i=Math.min(...e),r=(Math.max(...e)-i)/l||1,n=Array(l).fill(0);for(const t of e)n[Math.min(Math.floor((t-i)/r),l-1)]++;const h=e.length,f=Math.max(...n,1),d=a(t.pieceData[0],t.name);for(let e=0;l>e;e++){if(0===n[e])continue;const o=(u?n[e]/h:n[e]/f)*t.width*.9,a=s(i+e*r),l=s(i+(e+1)*r);c.push(N(Math.min(a,l),t.x+t.width-o,Math.abs(l-a),o,d,{bin:e,count:n[e],range:[i+e*r,i+(e+1)*r],category:t.name},t.name))}}return c},ridgeline:function(t,e){var i;const{scales:r,columns:n,config:o,getR:a,resolveSummaryStyle:s}=t,{r:c,projection:l}=r,u=[],h=o.bins||20,f="horizontal"===l,d=o.amplitude||1.5;for(const t of Object.values(n)){const e=t.pieceData.map(t=>a(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const r=e[0],n=e[e.length-1],o=(n-r)/h||1,l=Array(h).fill(0);for(const t of e)l[Math.min(Math.floor((t-r)/o),h-1)]++;const y=Math.max(...l,1),g=s(t.pieceData[0],t.name),p=t.width*d;let m="";if(f){const e=t.x+t.width;m=`M ${c(r)} ${e}`;for(let t=0;h>t;t++)m+=` L ${c(r+(t+.5)*o)} ${e-l[t]/y*p}`;m+=` L ${c(n)} ${e} Z`}else{const e=t.x;m=`M ${e} ${c(r)}`;for(let t=0;h>t;t++){const i=c(r+(t+.5)*o);m+=` L ${e+l[t]/y*p} ${i}`}m+=` L ${e} ${c(n)} Z`}const x=f?{x:Math.min(c(r),c(n)),y:t.x,width:Math.abs(c(n)-c(r)),height:t.width}:{x:t.x,y:Math.min(c(n),c(r)),width:t.width,height:Math.abs(c(n)-c(r))};u.push({type:"violin",pathString:m,translateX:0,translateY:0,bounds:x,stats:Ct(e),style:Object.assign(Object.assign({},g),{fillOpacity:null!==(i=g.fillOpacity)&&void 0!==i?i:.5}),datum:t.pieceData,category:t.name})}return u},timeline:function(t,e){const{scales:i,columns:r,getRawRange:n,resolvePieceStyle:o}=t,{r:a,projection:s}=i,c=[],l="horizontal"===s;for(const t of Object.values(r))for(const e of t.pieceData){const i=n(e);if(!i)continue;const[r,s]=i,u=o(e,t.name);if(l){const i=a(Math.min(r,s)),n=a(Math.max(r,s));c.push(N(i,t.x,n-i,t.width,u,e,t.name))}else{const i=a(Math.max(r,s)),n=a(Math.min(r,s));c.push(N(t.x,i,t.width,n-i,u,e,t.name))}}return c}};class jt{constructor(t){this.rExtent=new M,this.rExtents=[],this.rAccessors=[],this.categories=new Set,this._colorSchemeMap=null,this._colorSchemeIndex=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.lastIngestTime=0,this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.version=0,this.config=t,this.buffer=new L(t.windowSize),this.getO=z(t.oAccessor||t.categoryAccessor,"category");const e="streaming"===t.runtimeMode,i=t.rAccessor;Array.isArray(i)?(this.rAccessors=i.map(t=>R(t,"value")),this.getR=this.rAccessors[0],this.rExtents=i.map(()=>new M)):(this.getR=R(e&&(t.timeAccessor||t.valueAccessor)&&t.valueAccessor||i,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=z(t.stackBy),this.getGroup=z(t.groupBy),this.getColor=z(t.colorAccessor),this.getConnector=z(t.connectorAccessor),t.pulse&&(this.timestampBuffer=new L(t.windowSize))}ingest(t){const e="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=e,t.bounded){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const i=t.totalSize||t.inserts.length;i>this.buffer.capacity&&(this.buffer.resize(i),this.timestampBuffer&&i>this.timestampBuffer.capacity&&this.timestampBuffer.resize(i));for(const i of t.inserts)this.buffer.push(i),this.timestampBuffer&&this.timestampBuffer.push(e),this.categories.add(this.getO(i)),this.pushValueExtent(i)}else for(const i of t.inserts){const t=this.buffer.push(i);this.timestampBuffer&&this.timestampBuffer.push(e),this.categories.add(this.getO(i)),this.pushValueExtent(i),null!=t&&this.evictValueExtent(t)}return!0}pushValueExtent(t){if("timeline"===this.config.chartType){const e=this.getRawRange(t);e&&(this.rExtent.push(e[0]),this.rExtent.push(e[1]))}else if(this.rAccessors.length>1){for(let e=0;this.rAccessors.length>e;e++)this.rExtents[e].push(this.rAccessors[e](t));this.rExtent.push(this.getR(t))}else this.rExtent.push(this.getR(t))}evictValueExtent(t){if("timeline"===this.config.chartType){const e=this.getRawRange(t);e&&(this.rExtent.evict(e[0]),this.rExtent.evict(e[1]))}else if(this.rAccessors.length>1){for(let e=0;this.rAccessors.length>e;e++)this.rExtents[e].evict(this.rAccessors[e](t));this.rExtent.evict(this.getR(t))}else this.rExtent.evict(this.getR(t))}getRawRange(t){const e=this.config.rAccessor;if(!e)return null;const i="function"==typeof e?e(t):t[e];return Array.isArray(i)&&i.length>=2?[+i[0],+i[1]]:null}computeScene(t){const{config:e,buffer:n}=this;if(0===n.size)return this.scales=null,this.scene=[],this.columns={},void this.version++;this.rExtent.dirty&&this.rExtent.recalculate(n,this.getR);const o=n.toArray(),a=e.projection||"vertical",s=e.oExtent||this.resolveCategories(o),c=this.computeValueDomain(o,s),l="horizontal"===a,u=null!=e.barPadding?e.barPadding/("vertical"===a?t.width:t.height):.1;let h,f;if("radial"===a){h=r().domain(s).range([0,1]).padding(0);const n=Math.min(t.width,t.height)/2,o=e.innerRadius||0;f=i().domain(c).range([o,n])}else l?(h=r().domain(s).range([0,t.height]).padding(u),f=i().domain(c).range([0,t.width])):(h=r().domain(s).range([0,t.width]).padding(u),f=i().domain(c).range([t.height,0]));this.scales={o:h,r:f,projection:a},this.multiScales=this.rAccessors.length>1&&e.multiAxis?this.rAccessors.map((r,o)=>{const a=this.rExtents[o];a.dirty&&a.recalculate(n,r);let[s,c]=a.extent;s===1/0&&(s=0,c=1);const u=c-s,h=u>0?u*(e.extentPadding||.05):1;return s-=h,c+=h,s>0&&(s=0),l?i().domain([s,c]).range([0,t.width]):i().domain([s,c]).range([t.height,0])}):[];let d=o;this.rAccessors.length>1&&(d=o.flatMap(t=>this.rAccessors.map((e,i)=>Object.assign(Object.assign({},t),{__rIndex:i,__rValue:e(t),__rName:this.resolveRAccessorName(i)})))),this.columns=this.buildColumns(d,s,h,a,t),this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(d,t),this.config.decay&&this.applyDecay(this.scene,o),this.config.pulse&&this.applyPulse(this.scene,o),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++}resolveRAccessorName(t){const e=Array.isArray(this.config.rAccessor)?this.config.rAccessor[t]:this.config.rAccessor;return"string"==typeof e?e:"value"+t}resolveCategories(t){const e=Array.from(this.categories),i=this.config.oSort;if("streaming"===this.config.runtimeMode&&void 0===i)return e;if(!1===i)return e;if("function"==typeof i)return e.sort(i);const r=new Map;for(const e of t){const t=this.getO(e);r.set(t,(r.get(t)||0)+Math.abs(this.getR(e)))}return e.sort("asc"===i?(t,e)=>(r.get(t)||0)-(r.get(e)||0):(t,e)=>(r.get(e)||0)-(r.get(t)||0))}computeValueDomain(t,e){var i,r;const n=this.config.chartType,o=this.config.extentPadding||.05;if("radial"===this.config.projection&&("pie"===n||"donut"===n))return[0,1];let a=0,s=0;if("bar"===n&&this.getStack){const e=new Map,i=new Map;for(const r of t){const t=this.getO(r),n=this.getR(r);0>n?i.set(t,(i.get(t)||0)+n):e.set(t,(e.get(t)||0)+n)}for(const t of e.values())t>s&&(s=t);for(const t of i.values())a>t&&(a=t)}else if("bar"===n){const e=new Map;for(const i of t){const t=this.getO(i),r=this.getR(i);e.set(t,(e.get(t)||0)+r)}for(const t of e.values())t>s&&(s=t),a>t&&(a=t)}else if("clusterbar"===n)for(const e of t){const t=this.getR(e);t>s&&(s=t),a>t&&(a=t)}else{const t=this.rExtent.extent[0],e=this.rExtent.extent[1];t!==1/0&&(a=t),e!==-1/0&&(s=e)}this.config.rExtent&&(null!=this.config.rExtent[0]&&(a=this.config.rExtent[0]),null!=this.config.rExtent[1]&&(s=this.config.rExtent[1]));const c=s-a,l=c>0?c*o:1;return(null===(i=this.config.rExtent)||void 0===i?void 0:i[0])||(a-=l),(null===(r=this.config.rExtent)||void 0===r?void 0:r[1])||(s+=l),"bar"!==n&&"clusterbar"!==n||(a>0&&(a=0),0>s&&(s=0)),[a,s]}buildColumns(t,e,i,r,n){var o;const a={},s=new Map;for(const e of t){const t=this.getO(e);s.has(t)||s.set(t,[]),s.get(t).push(e)}let c=0;if("radial"===r)for(const e of t)c+=Math.abs(this.getR(e));const l=this.config.dynamicColumnWidth;let u=null;if(l&&"radial"!==r){u=new Map;let t=0;for(const i of e){const e=s.get(i)||[];let r;r="string"==typeof l?e.reduce((t,e)=>t+(Number(e[l])||0),0):l(e),u.set(i,r),t+=r}const o=("horizontal"===r?n.height:n.width)-i.padding()*i.step()*e.length;if(t>0)for(const[e,i]of u)u.set(e,i/t*o)}let h=0,f=0;for(const t of e){const e=s.get(t)||[],r=e.reduce((t,e)=>t+Math.abs(this.getR(e)),0),n=c>0?r/c:0;let l,d;u?(l=f,d=u.get(t)||i.bandwidth(),f+=d+i.padding()*i.step()):(l=null!==(o=i(t))&&void 0!==o?o:0,d=i.bandwidth()),a[t]={name:t,x:l,y:0,width:d,middle:l+d/2,padding:i.padding()*i.step(),pieceData:e,pct:n,pctStart:h},h+=n}return a}getSceneContext(){return{scales:this.scales,columns:this.columns,config:this.config,getR:this.getR,getStack:this.getStack,getGroup:this.getGroup,getColor:this.getColor,getConnector:this.getConnector,getO:this.getO,multiScales:this.multiScales,rAccessors:this.rAccessors,resolvePieceStyle:(t,e)=>this.resolvePieceStyle(t,e),resolveSummaryStyle:(t,e)=>this.resolveSummaryStyle(t,e),getRawRange:t=>this.getRawRange(t)}}buildSceneNodes(t,e){if(!this.scales)return[];const i=this.getSceneContext(),r=It[this.config.chartType];let n=r?r(i,e):[];if(this.getConnector&&this.scales){const t=function(t,e){const{scales:i,config:r,getConnector:n,getO:o}=t;if(!n||!i)return[];const a=[],{projection:s}=i,c=new Map;for(const t of e){if("point"!==t.type&&"rect"!==t.type)continue;const e=t.datum;if(!e)continue;const i=n(e);if(!i)continue;let r,a;"point"===t.type?(r=t.x,a=t.y):(r=t.x+t.w/2,a=t.y+("vertical"===s?0:t.h/2)),c.has(i)||c.set(i,[]),c.get(i).push({x:r,y:a,datum:e,category:o(e)})}const l=i.o.domain(),u=r.connectorStyle;for(const[t,e]of c)if(e.length>=2){e.sort((t,e)=>l.indexOf(t.category)-l.indexOf(e.category));for(let i=0;e.length-1>i;i++){const r=e[i],n=e[i+1],o="function"==typeof u?u(r.datum):u||{stroke:"#999",strokeWidth:1,opacity:.5};a.push({type:"connector",x1:r.x,y1:r.y,x2:n.x,y2:n.y,style:o,datum:r.datum,group:t})}}return a}(i,n);n=[...t,...n]}return n}resolvePieceStyle(t,e){return"function"==typeof this.config.pieceStyle?this.config.pieceStyle(t,e):this.config.pieceStyle&&"object"==typeof this.config.pieceStyle?this.config.pieceStyle:this.config.barColors&&e?{fill:this.config.barColors[e]||"#007bff"}:e?{fill:this.getColorFromScheme(e)}:{fill:"#007bff"}}getColorFromScheme(t){this._colorSchemeMap||(this._colorSchemeMap=new Map);const e=this._colorSchemeMap.get(t);if(e)return e;const i=Array.isArray(this.config.colorScheme)?this.config.colorScheme:["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],r=i[this._colorSchemeIndex%i.length];return this._colorSchemeIndex++,this._colorSchemeMap.set(t,r),r}resolveSummaryStyle(t,e){return"function"==typeof this.config.summaryStyle?this.config.summaryStyle(t,e):this.config.summaryStyle&&"object"==typeof this.config.summaryStyle?this.config.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}computeDecayOpacity(t,e){var i,r,n;const o=this.config.decay;if(!o||1>=e)return 1;const a=null!==(i=o.minOpacity)&&void 0!==i?i:.1,s=e-1-t;switch(o.type){case"linear":return a+(1-s/(e-1))*(1-a);case"exponential":{const t=null!==(r=o.halfLife)&&void 0!==r?r:e/2;return a+Math.pow(.5,s/t)*(1-a)}case"step":return(null!==(n=o.stepThreshold)&&void 0!==n?n:.5*e)>s?1:a;default:return 1}}applyDecay(t,e){var i,r;if(!this.config.decay)return;const n=e.length;if(1>=n)return;const o=new Map;for(let t=0;e.length>t;t++)o.set(e[t],t);for(const e of t){if("connector"===e.type||"violin"===e.type||"boxplot"===e.type||"wedge"===e.type)continue;const t=o.get(e.datum);if(null==t)continue;const a=this.computeDecayOpacity(t,n),s=null!==(r=null===(i=e.style)||void 0===i?void 0:i.opacity)&&void 0!==r?r:1;e.style=Object.assign(Object.assign({},e.style),{opacity:s*a})}}applyPulse(t,e){var i,r,n;if(!this.config.pulse||!this.timestampBuffer)return;const o="undefined"!=typeof performance?performance.now():Date.now(),a=null!==(i=this.config.pulse.duration)&&void 0!==i?i:500,s=null!==(r=this.config.pulse.color)&&void 0!==r?r:"rgba(255,255,255,0.6)",c=null!==(n=this.config.pulse.glowRadius)&&void 0!==n?n:4,l=new Map;for(let t=0;e.length>t;t++)l.set(e[t],t);for(const e of t){if("connector"===e.type||"violin"===e.type||"boxplot"===e.type||"wedge"===e.type)continue;const t=l.get(e.datum);if(null==t)continue;const i=this.timestampBuffer.get(t);if(null==i)continue;const r=o-i;a>r&&(e._pulseIntensity=1-r/a,e._pulseColor=s,e._pulseGlowRadius=c)}}get hasActivePulses(){var t;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const e="undefined"!=typeof performance?performance.now():Date.now(),i=null!==(t=this.config.pulse.duration)&&void 0!==t?t:500,r=this.timestampBuffer.peek();return null!=r&&i>e-r}snapshotPositions(){var t,e;this.prevPositionMap.clear();for(let i=0;this.scene.length>i;i++){const r=this.scene[i];if("point"===r.type)this.prevPositionMap.set("p:"+i,{x:r.x,y:r.y,r:r.r});else if("rect"===r.type){const n=`r:${r.group||""}:${null!==(e=null===(t=r.datum)||void 0===t?void 0:t.category)&&void 0!==e?e:i}`;this.prevPositionMap.set(n,{x:r.x,y:r.y,w:r.w,h:r.h})}}}startTransition(){var t,e,i,r,n;if(!this.config.transition||0===this.prevPositionMap.size)return;const o=null!==(t=this.config.transition.duration)&&void 0!==t?t:300;let a=!1;for(let t=0;this.scene.length>t;t++){const o=this.scene[t];let s=null;if("point"===o.type?s="p:"+t:"rect"===o.type&&(s=`r:${o.group||""}:${null!==(i=null===(e=o.datum)||void 0===e?void 0:e.category)&&void 0!==i?i:t}`),!s)continue;const c=this.prevPositionMap.get(s);c&&("point"===o.type?c.x===o.x&&c.y===o.y||(o._targetX=o.x,o._targetY=o.y,o.x=c.x,o.y=c.y,a=!0):"rect"===o.type&&(c.x===o.x&&c.y===o.y&&c.w===o.w&&c.h===o.h||(o._targetX=o.x,o._targetY=o.y,o._targetW=o.w,o._targetH=o.h,o.x=c.x,o.y=c.y,o.w=null!==(r=c.w)&&void 0!==r?r:o.w,o.h=null!==(n=c.h)&&void 0!==n?n:o.h,a=!0)))}a&&(this.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:o})}advanceTransition(t){var e,i,r;if(!this.activeTransition)return!1;const n=Math.min((t-this.activeTransition.startTime)/this.activeTransition.duration,1),o="linear"===(null===(e=this.config.transition)||void 0===e?void 0:e.easing)?n:1-Math.pow(1-n,3);for(const t of this.scene)if("point"===t.type){if(void 0===t._targetX)continue;const e=this.prevPositionMap.get("p:0");if(!e)continue;t.x=e.x+(t._targetX-e.x)*o,t.y=e.y+(t._targetY-e.y)*o}else if("rect"===t.type){if(void 0===t._targetX)continue;const e=`r:${t.group||""}:${null!==(r=null===(i=t.datum)||void 0===i?void 0:i.category)&&void 0!==r?r:0}`,n=this.prevPositionMap.get(e);if(!n)continue;t.x=n.x+(t._targetX-n.x)*o,t.y=n.y+(t._targetY-n.y)*o,void 0!==n.w&&(t.w=n.w+(t._targetW-n.w)*o,t.h=n.h+(t._targetH-n.h)*o)}if(n>=1){for(const t of this.scene)if("point"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t._targetX=void 0,t._targetY=void 0}else if("rect"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}return this.activeTransition=null,!1}return!0}getData(){return this.buffer.toArray()}clear(){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],this.columns={},this.version++}get size(){return this.buffer.size}getOAccessor(){return this.getO}getRAccessor(){return this.getR}updateConfig(t){t.colorScheme!==this.config.colorScheme&&(this._colorSchemeMap=null,this._colorSchemeIndex=0),Object.assign(this.config,t)}}const Ft=require("react-dom/server");function qt(t){return Math.round(100*t)/100+""}function Ht(e){var i,r,n,o;const a=e.size||[500,300],s=Object.assign(Object.assign({},{top:20,right:20,bottom:30,left:40}),e.margin),c=a[0]-s.left-s.right,l=a[1]-s.top-s.bottom,u="streaming"===e.runtimeMode||["bar","swarm","waterfall"].includes(e.chartType),h={chartType:e.chartType,windowSize:null!==(i=e.windowSize)&&void 0!==i?i:200,windowMode:null!==(r=e.windowMode)&&void 0!==r?r:"sliding",arrowOfTime:u&&null!==(n=e.arrowOfTime)&&void 0!==n?n:"right",extentPadding:null!==(o=e.extentPadding)&&void 0!==o?o:.1,xAccessor:u?void 0:e.xAccessor,yAccessor:u?void 0:e.yAccessor,timeAccessor:u?e.timeAccessor:void 0,valueAccessor:e.valueAccessor,colorAccessor:e.colorAccessor,sizeAccessor:e.sizeAccessor,groupAccessor:e.groupAccessor,categoryAccessor:e.categoryAccessor,lineDataAccessor:e.lineDataAccessor,xExtent:e.xExtent,yExtent:e.yExtent,sizeRange:e.sizeRange,binSize:e.binSize,normalize:e.normalize,boundsAccessor:e.boundsAccessor,boundsStyle:e.boundsStyle,openAccessor:e.openAccessor,highAccessor:e.highAccessor,lowAccessor:e.lowAccessor,closeAccessor:e.closeAccessor,candlestickStyle:e.candlestickStyle,lineStyle:e.lineStyle,pointStyle:e.pointStyle,areaStyle:e.areaStyle,colorScheme:e.colorScheme,barColors:e.barColors},f=new O(h);if(e.data&&f.ingest({inserts:e.data,bounded:!0}),f.computeScene({width:c,height:l}),!f.scales||0===f.scene.length)return Ft.renderToStaticMarkup(t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"stream-xy-frame",width:a[0],height:a[1]}));const d=f.scene.map((e,i)=>function(e,i){var r,n,o;switch(e.type){case"line":{const r=e;if(0===r.path.length)return null;const n="M"+r.path.map(([t,e])=>`${t},${e}`).join("L");return t.createElement("path",{key:"line-"+i,d:n,fill:"none",stroke:r.style.stroke||"#4e79a7",strokeWidth:r.style.strokeWidth||2,strokeDasharray:r.style.strokeDasharray,opacity:r.style.opacity})}case"area":{const o=e;if(0===o.topPath.length)return null;const a=o.topPath.map(([t,e])=>`${t},${e}`).join("L"),s=[...o.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L");return t.createElement("path",{key:"area-"+i,d:`M${a}L${s}Z`,fill:o.style.fill||"#4e79a7",fillOpacity:null!==(n=null!==(r=o.style.fillOpacity)&&void 0!==r?r:o.style.opacity)&&void 0!==n?n:.7,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})}case"point":return t.createElement("circle",{key:"point-"+i,cx:e.x,cy:e.y,r:e.r,fill:e.style.fill||"#4e79a7",opacity:null!==(o=e.style.opacity)&&void 0!==o?o:.8,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth});case"rect":return t.createElement("rect",{key:"rect-"+i,x:e.x,y:e.y,width:e.w,height:e.h,fill:e.style.fill||"#4e79a7",opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth});case"heatcell":return t.createElement("rect",{key:"heatcell-"+i,x:e.x,y:e.y,width:e.w,height:e.h,fill:e.fill});case"candlestick":{const r=e,n=Math.min(r.openY,r.closeY),o=Math.max(Math.abs(r.openY-r.closeY),1),a=r.isUp?r.upColor:r.downColor;return t.createElement("g",{key:"candle-"+i},t.createElement("line",{x1:r.x,y1:r.highY,x2:r.x,y2:r.lowY,stroke:r.wickColor,strokeWidth:r.wickWidth}),t.createElement("rect",{x:r.x-r.bodyWidth/2,y:n,width:r.bodyWidth,height:o,fill:a,stroke:a,strokeWidth:1}))}default:return null}}(e,i)).filter(Boolean),y=!1!==e.showAxes?function(e,i,r){var n,o,a,s;const c=e.x.ticks(5).map(t=>({pixel:e.x(t),label:(r.xFormat||r.tickFormatTime||qt)(t)})),l=e.y.ticks(5).map(t=>({pixel:e.y(t),label:(r.yFormat||r.tickFormatValue||qt)(t)}));return t.createElement("g",{className:"stream-axes"},t.createElement("line",{x1:0,y1:i.height,x2:i.width,y2:i.height,stroke:"#ccc",strokeWidth:1}),c.map((e,r)=>t.createElement("g",{key:"xtick-"+r,transform:`translate(${e.pixel},${i.height})`},t.createElement("line",{y2:5,stroke:"#ccc",strokeWidth:1}),t.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:"#666"},e.label))),r.xLabel&&t.createElement("text",{x:i.width/2,y:i.height+40,textAnchor:"middle",fontSize:12,fill:"#333"},r.xLabel),t.createElement("line",{x1:0,y1:0,x2:0,y2:i.height,stroke:"#ccc",strokeWidth:1}),l.map((e,i)=>t.createElement("g",{key:"ytick-"+i,transform:`translate(0,${e.pixel})`},t.createElement("line",{x2:-5,stroke:"#ccc",strokeWidth:1}),t.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"#666"},e.label))),r.yLabel&&t.createElement("text",{x:15-(null!==(o=null===(n=r.margin)||void 0===n?void 0:n.left)&&void 0!==o?o:40),y:i.height/2,textAnchor:"middle",fontSize:12,fill:"#333",transform:`rotate(-90, ${15-(null!==(s=null===(a=r.margin)||void 0===a?void 0:a.left)&&void 0!==s?s:40)}, ${i.height/2})`},r.yLabel))}(f.scales,{width:c,height:l},e):null,g=e.title&&"string"==typeof e.title?t.createElement("text",{x:a[0]/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"#333"},e.title):null,p=e.background?t.createElement("rect",{x:0,y:0,width:c,height:l,fill:e.background}):null,m=t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"stream-xy-frame"+(e.className?" "+e.className:""),width:a[0],height:a[1]},t.createElement("g",{transform:`translate(${s.left},${s.top})`},p,d,y),g);return Ft.renderToStaticMarkup(m)}function Gt(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}const Vt=new Set(["tree","cluster","treemap","circlepack","partition"]);function Zt(i){const r=i.chartType||"force",n=i.size||[500,500],o=Object.assign(Object.assign({},{top:20,right:20,bottom:20,left:20}),i.margin),a=n[0]-o.left-o.right,s=n[1]-o.top-o.bottom,c=function(t){return Yt[t]}(r);if(!c)throw Error(`No layout plugin found for chart type: "${r}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition.`);const l={chartType:r,nodeIDAccessor:i.nodeIDAccessor,sourceAccessor:i.sourceAccessor,targetAccessor:i.targetAccessor,valueAccessor:i.valueAccessor,childrenAccessor:i.childrenAccessor,hierarchySum:i.hierarchySum,orientation:i.orientation,nodeAlign:i.nodeAlign,nodePaddingRatio:i.nodePaddingRatio,nodeWidth:i.nodeWidth,iterations:i.iterations,forceStrength:i.forceStrength,padAngle:i.padAngle,groupWidth:i.groupWidth,sortGroups:i.sortGroups,edgeSort:i.edgeSort,treeOrientation:i.treeOrientation,edgeType:i.edgeType,padding:i.padding,paddingTop:i.paddingTop,nodeStyle:i.nodeStyle,edgeStyle:i.edgeStyle,nodeLabel:i.nodeLabel,showLabels:i.showLabels,colorBy:i.colorBy,colorScheme:i.colorScheme,edgeColorBy:i.edgeColorBy,edgeOpacity:i.edgeOpacity,colorByDepth:i.colorByDepth,nodeSize:i.nodeSize,nodeSizeRange:i.nodeSizeRange};let u,h;if(Vt.has(r)){const e=i.data||i.edges;if(!e||Array.isArray(e))return Ft.renderToStaticMarkup(t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"stream-network-frame",width:n[0],height:n[1]}));l.__hierarchyRoot=e,u=[],h=[]}else{const e=i.nodes||[],r=Array.isArray(i.edges)?i.edges:[];if(0===e.length&&0===r.length)return Ft.renderToStaticMarkup(t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"stream-network-frame",width:n[0],height:n[1]}));u=function(t,e){const i=Gt(e.nodeIDAccessor,"id");return t.map(t=>({id:i(t)+"",x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:t}))}(e,l),h=function(t,e){const i=Gt(e.sourceAccessor,"source"),r=Gt(e.targetAccessor,"target"),n=Gt(e.valueAccessor,"value");return t.map(t=>({source:i(t)+"",target:r(t)+"",value:Number(n(t))||1,y0:0,y1:0,sankeyWidth:0,data:t}))}(r,l)}c.computeLayout(u,h,l,[a,s]);const{sceneNodes:f,sceneEdges:d,labels:y}=c.buildScene(u,h,l,[a,s]),g=d.map((e,i)=>function(e,i){switch(e.type){case"line":return t.createElement("line",{key:"net-edge-line-"+i,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":return t.createElement("path",{key:"net-edge-bezier-"+i,d:e.pathD,fill:e.style.fill||"#999",fillOpacity:e.style.fillOpacity,stroke:e.style.stroke||"none",strokeWidth:e.style.strokeWidth,opacity:e.style.opacity});case"ribbon":return t.createElement("path",{key:"net-edge-ribbon-"+i,d:e.pathD,fill:e.style.fill||"#999",fillOpacity:e.style.fillOpacity,stroke:e.style.stroke||"none",strokeWidth:e.style.strokeWidth,opacity:e.style.opacity});case"curved":return t.createElement("path",{key:"net-edge-curved-"+i,d:e.pathD,fill:e.style.fill||"none",stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity});default:return null}}(e,i)).filter(Boolean),p=f.map((i,r)=>function(i,r){switch(i.type){case"circle":return t.createElement("circle",{key:"net-circle-"+r,cx:i.cx,cy:i.cy,r:i.r,fill:i.style.fill||"#4e79a7",stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity});case"rect":return t.createElement("rect",{key:"net-rect-"+r,x:i.x,y:i.y,width:i.w,height:i.h,fill:i.style.fill||"#4e79a7",stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity});case"arc":{const n=i,o=e().innerRadius(n.innerR).outerRadius(n.outerR).startAngle(n.startAngle).endAngle(n.endAngle)({})||"";return t.createElement("path",{key:"net-arc-"+r,d:o,transform:`translate(${n.cx},${n.cy})`,fill:n.style.fill||"#4e79a7",stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})}default:return null}}(i,r)).filter(Boolean),m=y.map((e,i)=>function(e,i){return t.createElement("text",{key:"net-label-"+i,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,i)).filter(Boolean),x=i.title&&"string"==typeof i.title?t.createElement("text",{x:n[0]/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"#333"},i.title):null,v=i.background?t.createElement("rect",{x:0,y:0,width:a,height:s,fill:i.background}):null,k=t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"stream-network-frame"+(i.className?" "+i.className:""),width:n[0],height:n[1]},t.createElement("g",{transform:`translate(${o.left},${o.top})`},v,g,p,m),x);return Ft.renderToStaticMarkup(k)}function Qt(i){var r,n,o;const a=i.size||[500,400],s=Object.assign(Object.assign({},{top:20,right:20,bottom:30,left:40}),i.margin),c=a[0]-s.left-s.right,l=a[1]-s.top-s.bottom,u=i.projection||"vertical",h="radial"===u,f={chartType:i.chartType,windowSize:null!==(r=i.windowSize)&&void 0!==r?r:1e4,windowMode:null!==(n=i.windowMode)&&void 0!==n?n:"sliding",extentPadding:null!==(o=i.extentPadding)&&void 0!==o?o:.05,projection:u,oAccessor:i.oAccessor,rAccessor:i.rAccessor,colorAccessor:i.colorAccessor,stackBy:i.stackBy,groupBy:i.groupBy,categoryAccessor:i.categoryAccessor,valueAccessor:i.valueAccessor,timeAccessor:i.timeAccessor,rExtent:i.rExtent,oExtent:i.oExtent,barPadding:i.barPadding,innerRadius:i.innerRadius,normalize:i.normalize,startAngle:i.startAngle,bins:i.bins,showOutliers:i.showOutliers,showIQR:i.showIQR,amplitude:i.amplitude,oSort:i.oSort,connectorAccessor:i.connectorAccessor,connectorStyle:i.connectorStyle,dynamicColumnWidth:i.dynamicColumnWidth,pieceStyle:i.pieceStyle,summaryStyle:i.summaryStyle,colorScheme:i.colorScheme,barColors:i.barColors},d=new jt(f);if(i.data&&d.ingest({inserts:i.data,bounded:!0}),d.computeScene({width:c,height:l}),!d.scales||0===d.scene.length)return Ft.renderToStaticMarkup(t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"stream-ordinal-frame",width:a[0],height:a[1]}));const y=d.scene.map((i,r)=>function(i,r){var n,o,a,s,c;switch(i.type){case"rect":return t.createElement("rect",{key:"ord-rect-"+r,x:i.x,y:i.y,width:i.w,height:i.h,fill:i.style.fill||"#4e79a7",opacity:i.style.opacity,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth});case"point":return t.createElement("circle",{key:"ord-point-"+r,cx:i.x,cy:i.y,r:i.r,fill:i.style.fill||"#4e79a7",opacity:null!==(n=i.style.opacity)&&void 0!==n?n:.8,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth});case"wedge":{const n=i,o=e().innerRadius(n.innerRadius).outerRadius(n.outerRadius).startAngle(n.startAngle).endAngle(n.endAngle)({})||"";return t.createElement("path",{key:"ord-wedge-"+r,d:o,transform:`translate(${n.cx},${n.cy})`,fill:n.style.fill||"#4e79a7",stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})}case"boxplot":{const e=i,n=e.columnWidth/2;return"vertical"===e.projection?t.createElement("g",{key:"ord-boxplot-"+r},t.createElement("line",{x1:e.x,y1:e.minPos,x2:e.x,y2:e.maxPos,stroke:e.style.stroke||"#333",strokeWidth:1}),t.createElement("rect",{x:e.x-n,y:Math.min(e.q1Pos,e.q3Pos),width:e.columnWidth,height:Math.abs(e.q3Pos-e.q1Pos),fill:e.style.fill||"#4e79a7",fillOpacity:null!==(o=e.style.fillOpacity)&&void 0!==o?o:.6,stroke:e.style.stroke||"#333",strokeWidth:1}),t.createElement("line",{x1:e.x-n,y1:e.medianPos,x2:e.x+n,y2:e.medianPos,stroke:e.style.stroke||"#333",strokeWidth:2}),t.createElement("line",{x1:e.x-.5*n,y1:e.minPos,x2:e.x+.5*n,y2:e.minPos,stroke:e.style.stroke||"#333",strokeWidth:1}),t.createElement("line",{x1:e.x-.5*n,y1:e.maxPos,x2:e.x+.5*n,y2:e.maxPos,stroke:e.style.stroke||"#333",strokeWidth:1})):t.createElement("g",{key:"ord-boxplot-"+r},t.createElement("line",{x1:e.minPos,y1:e.y,x2:e.maxPos,y2:e.y,stroke:e.style.stroke||"#333",strokeWidth:1}),t.createElement("rect",{x:Math.min(e.q1Pos,e.q3Pos),y:e.y-n,width:Math.abs(e.q3Pos-e.q1Pos),height:e.columnWidth,fill:e.style.fill||"#4e79a7",fillOpacity:null!==(a=e.style.fillOpacity)&&void 0!==a?a:.6,stroke:e.style.stroke||"#333",strokeWidth:1}),t.createElement("line",{x1:e.medianPos,y1:e.y-n,x2:e.medianPos,y2:e.y+n,stroke:e.style.stroke||"#333",strokeWidth:2}),t.createElement("line",{x1:e.minPos,y1:e.y-.5*n,x2:e.minPos,y2:e.y+.5*n,stroke:e.style.stroke||"#333",strokeWidth:1}),t.createElement("line",{x1:e.maxPos,y1:e.y-.5*n,x2:e.maxPos,y2:e.y+.5*n,stroke:e.style.stroke||"#333",strokeWidth:1}))}case"violin":{const e=i,n=[t.createElement("path",{key:"ord-violin-path-"+r,d:e.pathString,transform:e.translateX||e.translateY?`translate(${e.translateX},${e.translateY})`:void 0,fill:e.style.fill||"#4e79a7",fillOpacity:null!==(s=e.style.fillOpacity)&&void 0!==s?s:.6,stroke:e.style.stroke||"#333",strokeWidth:e.style.strokeWidth||1})];if(e.iqrLine&&e.bounds){const i=e.bounds,o=i.x+i.width/2,a=i.y+i.height/2;i.height>i.width?n.push(t.createElement("line",{key:"ord-violin-iqr-"+r,x1:o,y1:e.iqrLine.q1Pos,x2:o,y2:e.iqrLine.q3Pos,stroke:e.style.stroke||"#333",strokeWidth:2}),t.createElement("circle",{key:"ord-violin-med-"+r,cx:o,cy:e.iqrLine.medianPos,r:3,fill:"white",stroke:e.style.stroke||"#333",strokeWidth:1})):n.push(t.createElement("line",{key:"ord-violin-iqr-"+r,x1:e.iqrLine.q1Pos,y1:a,x2:e.iqrLine.q3Pos,y2:a,stroke:e.style.stroke||"#333",strokeWidth:2}),t.createElement("circle",{key:"ord-violin-med-"+r,cx:e.iqrLine.medianPos,cy:a,r:3,fill:"white",stroke:e.style.stroke||"#333",strokeWidth:1}))}return t.createElement("g",{key:"ord-violin-"+r},n)}case"connector":return t.createElement("line",{key:"ord-conn-"+r,x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,stroke:i.style.stroke||"#999",strokeWidth:i.style.strokeWidth||1,opacity:null!==(c=i.style.opacity)&&void 0!==c?c:.5});default:return null}}(i,r)).filter(Boolean),g=!1!==i.showAxes?function(e,i,r){var n,o,a,s,c,l,u,h;const f=e.scales;if(!f)return null;if("radial"===f.projection)return null;const d="vertical"===f.projection,y=Object.values(e.columns).map(t=>({pixel:t.middle,label:(r.oFormat||String)(t.name)})),g=f.r.ticks(5).map(t=>({pixel:f.r(t),label:(r.rFormat||qt)(t)}));return d?t.createElement("g",{className:"ordinal-axes"},t.createElement("line",{x1:0,y1:i.height,x2:i.width,y2:i.height,stroke:"#ccc",strokeWidth:1}),y.map((e,r)=>t.createElement("g",{key:"oxtick-"+r,transform:`translate(${e.pixel},${i.height})`},t.createElement("line",{y2:5,stroke:"#ccc",strokeWidth:1}),t.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:"#666"},e.label))),r.oLabel&&t.createElement("text",{x:i.width/2,y:i.height+40,textAnchor:"middle",fontSize:12,fill:"#333"},r.oLabel),t.createElement("line",{x1:0,y1:0,x2:0,y2:i.height,stroke:"#ccc",strokeWidth:1}),g.map((e,i)=>t.createElement("g",{key:"oytick-"+i,transform:`translate(0,${e.pixel})`},t.createElement("line",{x2:-5,stroke:"#ccc",strokeWidth:1}),t.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"#666"},e.label))),r.rLabel&&t.createElement("text",{x:15-(null!==(o=null===(n=r.margin)||void 0===n?void 0:n.left)&&void 0!==o?o:40),y:i.height/2,textAnchor:"middle",fontSize:12,fill:"#333",transform:`rotate(-90, ${15-(null!==(s=null===(a=r.margin)||void 0===a?void 0:a.left)&&void 0!==s?s:40)}, ${i.height/2})`},r.rLabel)):t.createElement("g",{className:"ordinal-axes"},t.createElement("line",{x1:0,y1:i.height,x2:i.width,y2:i.height,stroke:"#ccc",strokeWidth:1}),g.map((e,r)=>t.createElement("g",{key:"oxtick-"+r,transform:`translate(${e.pixel},${i.height})`},t.createElement("line",{y2:5,stroke:"#ccc",strokeWidth:1}),t.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:"#666"},e.label))),r.rLabel&&t.createElement("text",{x:i.width/2,y:i.height+40,textAnchor:"middle",fontSize:12,fill:"#333"},r.rLabel),t.createElement("line",{x1:0,y1:0,x2:0,y2:i.height,stroke:"#ccc",strokeWidth:1}),y.map((e,i)=>t.createElement("g",{key:"oytick-"+i,transform:`translate(0,${e.pixel})`},t.createElement("line",{x2:-5,stroke:"#ccc",strokeWidth:1}),t.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"#666"},e.label))),r.oLabel&&t.createElement("text",{x:15-(null!==(l=null===(c=r.margin)||void 0===c?void 0:c.left)&&void 0!==l?l:40),y:i.height/2,textAnchor:"middle",fontSize:12,fill:"#333",transform:`rotate(-90, ${15-(null!==(h=null===(u=r.margin)||void 0===u?void 0:u.left)&&void 0!==h?h:40)}, ${i.height/2})`},r.oLabel))}(d,{width:c,height:l},i):null,p=i.title&&"string"==typeof i.title?t.createElement("text",{x:a[0]/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"#333"},i.title):null,m=i.background?t.createElement("rect",{x:0,y:0,width:c,height:l,fill:i.background}):null,x=t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"stream-ordinal-frame"+(i.className?" "+i.className:""),width:a[0],height:a[1]},t.createElement("g",{transform:`translate(${h?s.left+c/2:s.left},${h?s.top+l/2:s.top})`},m,y,g),p);return Ft.renderToStaticMarkup(x)}function Ut(t,e){switch(t){case"xy":return Ht(e);case"ordinal":return Qt(e);case"network":return Zt(e);default:throw Error(`Unknown frame type: ${t}. Must be "xy", "ordinal", or "network".`)}}function Jt(t){return Ht(t)}function Kt(t){return Qt(t)}function te(t){return Zt(t)}export{te as renderNetworkToStaticSVG,Kt as renderOrdinalToStaticSVG,Ut as renderToStaticSVG,Jt as renderXYToStaticSVG};
1
+ import*as t from"react";import{scaleLinear as e,scaleBand as i}from"d3-scale";import{min as r,groups as n,max as o,sum as a,mean as s,group as c,quantile as l}from"d3-array";import{schemeCategory10 as u}from"d3-scale-chromatic";import{interpolateNumber as h}from"d3-interpolate";import{forceLink as f,forceSimulation as d,forceManyBody as y,forceX as g,forceY as p}from"d3-force";import{ribbon as m,chord as x}from"d3-chord";import{arc as v}from"d3-shape";import{hierarchy as k,partition as b,pack as w,treemap as E,treemapBinary as A,cluster as S,tree as P}from"d3-hierarchy";class L{constructor(t){if(this._capacity=t,this.head=0,this._size=0,1>t)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(t)}push(t){let e;return this._size===this._capacity?e=this.buffer[this.head]:this._size++,this.buffer[this.head]=t,this.head=(this.head+1)%this._capacity,e}pushMany(t){const e=[];for(const i of t){const t=this.push(i);void 0!==t&&e.push(t)}return e}get(t){if(t>=0&&this._size>t)return this.buffer[(this.head-this._size+t+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let t=0;const e=this;return{next:()=>e._size>t?{done:!1,value:e.get(t++)}:{done:!0,value:void 0}}}toArray(){const t=[];for(const e of this)t.push(e);return t}resize(t){if(1>t)throw Error("RingBuffer capacity must be at least 1");const e=this.toArray(),i=[];for(;e.length>t;)i.push(e.shift());this._capacity=t,this.buffer=Array(t),this.head=0,this._size=0;for(const t of e)this.push(t);return i}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}}class M{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(t){Number.isNaN(t)||(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}evict(t){t!==this._min&&t!==this._max||(this._dirty=!0)}recalculate(t,e){this._min=1/0,this._max=-1/0;for(const i of t){const t=e?e(i):i;Number.isNaN(t)||(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}this._dirty=!1}clear(){this._min=1/0,this._max=-1/0,this._dirty=!1}get extent(){return[this._min,this._max]}get min(){return this._min}get max(){return this._max}get dirty(){return this._dirty}}function D(t,e,i,r,n){const o=new Map;for(const a of t){const t=e(a),s=i(a);if(null==t||null==s||Number.isNaN(t)||Number.isNaN(s))continue;const c=Math.floor(t/r)*r;let l=o.get(c);if(l||(l={start:c,end:c+r,total:0,categories:new Map},o.set(c,l)),l.total+=s,n){const t=n(a);l.categories.set(t,(l.categories.get(t)||0)+s)}}return o}function _(t,e,i,r,n,o){const a=[];for(const n of t){const t=i(n),o=r(n);null==t||null==o||Number.isNaN(t)||Number.isNaN(o)||a.push({px:e.x(t),py:e.y(o),rawY:o,d:n})}a.sort((t,e)=>t.px-e.px);const s=Array(a.length),c=Array(a.length),l=Array(a.length);for(let t=0;a.length>t;t++){const e=a[t];s[t]=[e.px,e.py],c[t]=e.rawY,l[t]=e.d}return{type:"line",path:s,rawValues:c,style:n,datum:l,group:o}}function $(t,e,i,r,n,o,a,s){const c=[];for(const o of t){const t=i(o),a=r(o);if(null==t||null==a||Number.isNaN(t)||Number.isNaN(a))continue;const l=e.x(t),u=s?s(o):n;c.push({px:l,topY:e.y(a),botY:e.y(u)})}c.sort((t,e)=>t.px-e.px);const l=Array(c.length),u=Array(c.length);for(let t=0;c.length>t;t++){const e=c[t];l[t]=[e.px,e.topY],u[t]=[e.px,e.botY]}return{type:"area",topPath:l,bottomPath:u,style:o,datum:t,group:a}}function W(t,e,i,r,n,o,a){const s=i(t),c=r(t);if(null==s||null==c||Number.isNaN(s)||Number.isNaN(c))return null;const l={type:"point",x:e.x(s),y:e.y(c),r:n,style:o,datum:t};return void 0!==a&&(l.pointId=a),l}function N(t,e,i,r,n,o,a){return{type:"rect",x:t,y:e,w:i,h:r,style:n,datum:o,group:a}}function R(t,e,i,r,n,o){return{type:"heatcell",x:t,y:e,w:i,h:r,fill:n,datum:o}}function T(t,e){if("function"==typeof t)return e=>+t(e);const i=t||e;return t=>+t[i]}function z(t,e){return"function"==typeof t?t:t?e=>e[t]+"":e?t=>t[e]+"":void 0}class O{constructor(t){this.xExtent=new M,this.yExtent=new M,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.lastIngestTime=0,this.needsFullRebuild=!0,this.lastLayout=null,this.scales=null,this.scene=[],this.version=0,this.config=t,this.buffer=new L(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=T(t.timeAccessor||t.xAccessor,"time"),this.getY=T(t.valueAccessor||t.yAccessor,"value")):(this.getX=T(t.xAccessor,"x"),this.getY=T(t.yAccessor,"y")),this.getGroup=z(t.groupAccessor),this.getCategory=z(t.categoryAccessor),this.getSize=t.sizeAccessor?T(t.sizeAccessor,"size"):void 0,this.getColor=z(t.colorAccessor),this.getBounds=t.boundsAccessor?T(t.boundsAccessor,"bounds"):void 0,this.getY0=t.y0Accessor?T(t.y0Accessor,"y0"):void 0,this.getPointId=z(t.pointIdAccessor),"candlestick"===t.chartType&&(this.getOpen=T(t.openAccessor,"open"),this.getHigh=T(t.highAccessor,"high"),this.getLow=T(t.lowAccessor,"low"),this.getClose=T(t.closeAccessor,"close")),t.pulse&&(this.timestampBuffer=new L(t.windowSize))}ingest(t){const e="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=e,this.needsFullRebuild=!0,t.bounded){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const i=t.totalSize||t.inserts.length;i>this.buffer.capacity&&(this.buffer.resize(i),this.timestampBuffer&&i>this.timestampBuffer.capacity&&this.timestampBuffer.resize(i));for(const i of t.inserts)this.buffer.push(i),this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(i)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(i)),this.yExtent.push(this.getLow(i))):(this.yExtent.push(this.getY(i)),this.getY0&&this.yExtent.push(this.getY0(i)))}else for(const i of t.inserts){"growing"===this.config.windowMode&&this.buffer.full&&(this.growingCap*=2,this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap));const t=this.buffer.push(i);this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(i)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(i)),this.yExtent.push(this.getLow(i))):(this.yExtent.push(this.getY(i)),this.getY0&&this.yExtent.push(this.getY0(i))),null!=t&&(this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):this.yExtent.evict(this.getY(t)))}return!0}computeScene(t){var i,r,n,o,a,s;const{config:c,buffer:l}=this;if(!this.needsFullRebuild&&this.lastLayout&&this.scene.length>0&&this.scales&&(this.lastLayout.width!==t.width||this.lastLayout.height!==t.height))return void this.remapScene(t);if(this.xExtent.dirty&&this.xExtent.recalculate(l,this.getX),this.yExtent.dirty)if("candlestick"===c.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const t of l)this.yExtent.push(this.getHigh(t)),this.yExtent.push(this.getLow(t))}else this.yExtent.recalculate(l,this.getY);const u=this.xExtent.extent,h=this.yExtent.extent;let f=c.xExtent?[null!==(i=c.xExtent[0])&&void 0!==i?i:u[0],null!==(r=c.xExtent[1])&&void 0!==r?r:u[1]]:u,d=c.yExtent?[null!==(n=c.yExtent[0])&&void 0!==n?n:h[0],null!==(o=c.yExtent[1])&&void 0!==o?o:h[1]]:h;const y=c.yExtent&&null!=c.yExtent[0]&&null!=c.yExtent[1];if("stackedarea"===c.chartType&&!y&&l.size>0)if(c.normalize)d=[0,1+c.extentPadding];else{const t=l.toArray(),e=this.groupData(t),i=new Map;for(const t of e)for(const e of t.data){const t=this.getX(e),r=this.getY(e);null==t||null==r||Number.isNaN(t)||Number.isNaN(r)||i.set(t,(i.get(t)||0)+r)}let r=0;for(const t of i.values())t>r&&(r=t);d=[0,r+(r>0?r*c.extentPadding:1)]}else if("bar"===c.chartType&&c.binSize&&!y&&l.size>0){const[,t]=function(t,e,i,r,n){const o=D(t,e,i,r,n);if(0===o.size)return[0,0];let a=0;for(const t of o.values())t.total>a&&(a=t.total);return[0,a]}(l,this.getX,this.getY,c.binSize,this.getCategory);d=[0,t+t*c.extentPadding]}else if("waterfall"===c.chartType&&!y&&l.size>0){const[t,e]=function(t,e){let i=0,r=0,n=0;for(const o of t){const t=e(o);null==t||Number.isNaN(t)||(n+=t,i>n&&(i=n),n>r&&(r=n))}return[i,r]}(l,this.getY),i=e-t,r=i>0?i*c.extentPadding:1;d=[Math.min(0,t-Math.abs(r)),Math.max(0,e+Math.abs(r))]}else if(!y&&d[0]!==1/0){if(this.getBounds){const t=l.toArray();for(const e of t){const t=this.getY(e),i=this.getBounds(e);null!=t&&!Number.isNaN(t)&&i&&(t+i>d[1]&&(d[1]=t+i),d[0]>t-i&&(d[0]=t-i))}}const t=d[1]-d[0],e=t>0?t*c.extentPadding:1,i=null===(a=c.yExtent)||void 0===a?void 0:a[0],r=null===(s=c.yExtent)||void 0===s?void 0:s[1];d=[null!=i?d[0]:d[0]-e,null!=r?d[1]:d[1]+e]}if(f[0]!==1/0&&f[1]!==-1/0||(f=[0,1]),d[0]!==1/0&&d[1]!==-1/0||(d=[0,1]),void 0!==c.arrowOfTime)if("x"==("up"===(g=c.arrowOfTime)||"down"===g?"y":"x")){const i="right"===c.arrowOfTime?[0,t.width]:[t.width,0];this.scales={x:e().domain(f).range(i),y:e().domain(d).range([t.height,0])}}else{const i="down"===c.arrowOfTime?[0,t.height]:[t.height,0];this.scales={x:e().domain(d).range([0,t.width]),y:e().domain(f).range(i)}}else this.scales={x:e().domain(f).range([0,t.width]),y:e().domain(d).range([t.height,0])};var g;this.config.transition&&this.scene.length>0&&this.snapshotPositions();const p=l.toArray();this.scene=this.buildSceneNodes(t),this.config.decay&&this.applyDecay(this.scene,p),this.config.pulse&&this.applyPulse(this.scene,p),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.needsFullRebuild=!1,this.lastLayout={width:t.width,height:t.height},this.version++}remapScene(t){const i=t.width/this.lastLayout.width,r=t.height/this.lastLayout.height;for(const t of this.scene)switch(t.type){case"line":for(const e of t.path)e[0]*=i,e[1]*=r;break;case"area":for(const e of t.topPath)e[0]*=i,e[1]*=r;for(const e of t.bottomPath)e[0]*=i,e[1]*=r;break;case"point":t.x*=i,t.y*=r;break;case"rect":case"heatcell":t.x*=i,t.y*=r,t.w*=i,t.h*=r;break;case"candlestick":t.x*=i,t.openY*=r,t.closeY*=r,t.highY*=r,t.lowY*=r}const n=this.scales.x.domain(),o=this.scales.y.domain(),a=this.scales.x.range(),s=this.scales.y.range();this.scales={x:e().domain(n).range([a[0]*i,a[1]*i]),y:e().domain(o).range([s[0]*r,s[1]*r])},this.lastLayout={width:t.width,height:t.height},this.version++}buildSceneNodes(t){const{config:e,buffer:i,scales:r}=this;if(!r||0===i.size)return[];const n=i.toArray();switch(e.chartType){case"line":return this.buildLineScene(n);case"area":return this.buildAreaScene(n);case"stackedarea":return this.buildStackedAreaScene(n);case"scatter":case"bubble":return this.buildPointScene(n);case"heatmap":return this.buildHeatmapScene(n,t);case"bar":return this.buildBarScene(n);case"swarm":return this.buildSwarmScene(n);case"waterfall":return this.buildWaterfallScene(n,t);case"candlestick":return this.buildCandlestickScene(n,t);default:return[]}}buildLineScene(t){var e;const i=this.groupData(t),r=[],n=null===(e=this.config.annotations)||void 0===e?void 0:e.filter(t=>"threshold"===t.type&&t.color).map(t=>({value:t.value,color:t.color,thresholdType:t.thresholdType||"greater"}));if(this.getBounds)for(const t of i){const e=this.buildBoundsForGroup(t.data,t.key);e&&r.push(e)}for(const t of i){const e=this.resolveLineStyle(t.key,t.data[0]),i=_(t.data,this.scales,this.getX,this.getY,e,t.key);n&&n.length>0&&(i.colorThresholds=n),r.push(i)}return r}buildAreaScene(t){const e=this.groupData(t),i=[],r=this.scales.y.domain()[0];for(const t of e){const e=this.resolveAreaStyle(t.key,t.data[0]),n=$(t.data,this.scales,this.getX,this.getY,r,e,t.key,this.getY0);this.config.gradientFill&&(n.fillGradient=this.config.gradientFill),i.push(n)}return i}buildStackedAreaScene(t){const e=this.groupData(t);return e.sort((t,e)=>e.key>t.key?-1:t.key>e.key?1:0),function(t,e,i,r,n,o){var a;const s=new Set;for(const e of t)for(const t of e.data){const e=i(t);null==e||Number.isNaN(e)||s.add(e)}const c=Array.from(s).sort((t,e)=>t-e),l=new Map;for(const e of t){const t=new Map;for(const n of e.data){const e=i(n),o=r(n);null==e||null==o||Number.isNaN(e)||Number.isNaN(o)||t.set(e,(t.get(e)||0)+o)}l.set(e.key,t)}let u;if(o){u=new Map;for(const e of c){let i=0;for(const r of t)i+=(null===(a=l.get(r.key))||void 0===a?void 0:a.get(e))||0;u.set(e,i||1)}}const h=[],f=new Map;for(const t of c)f.set(t,0);for(const i of t){const t=l.get(i.key),r=[],a=[];for(const i of c){let n=t.get(i)||0;const s=f.get(i);o&&(n/=u.get(i));const c=e.x(i);a.push([c,e.y(s)]),r.push([c,e.y(s+n)]),f.set(i,s+n)}h.push({type:"area",topPath:r,bottomPath:a,style:n(i.key,i.data[0]),datum:i.data,group:i.key})}return h}(e,this.scales,this.getX,this.getY,(t,e)=>this.resolveAreaStyle(t,e),this.config.normalize)}buildPointScene(t){const e=[],i="bubble"===this.config.chartType?10:5,r=this.config.sizeRange||[3,15];let n=null;if(this.getSize&&!this.config.pointStyle){const e=t.map(t=>this.getSize(t)).filter(t=>null!=t&&!Number.isNaN(t));if(e.length>0){const t=Math.min(...e),i=Math.max(...e);n=e=>t===i?(r[0]+r[1])/2:r[0]+(e-t)/(i-t)*(r[1]-r[0])}}let o=null;if(this.getColor&&!this.config.pointStyle){const e=new Set;for(const i of t){const t=this.getColor(i);t&&e.add(t)}const i=Array.isArray(this.config.colorScheme)?this.config.colorScheme:["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];o=new Map;let r=0;for(const t of e)o.set(t,i[r%i.length]),r++}for(const r of t){let t=this.config.pointStyle?this.config.pointStyle(r):{fill:"#4e79a7",opacity:.8},a=t.r||i;if(n&&this.getSize){const t=this.getSize(r);null==t||Number.isNaN(t)||(a=n(t))}if(o&&this.getColor){const e=this.getColor(r);e&&o.has(e)&&(t=Object.assign(Object.assign({},t),{fill:o.get(e)}))}const s=this.getPointId?this.getPointId(r)+"":void 0,c=W(r,this.scales,this.getX,this.getY,a,t,s);c&&e.push(c)}return e}buildHeatmapScene(t,e){const i=[];if(this.config.heatmapAggregation)return this.buildStreamingHeatmapScene(t,e);const r=T(this.config.valueAccessor,"value"),n=new Set,o=new Set;for(const e of t)n.add(this.getX(e)),o.add(this.getY(e));const a=Array.from(n).sort((t,e)=>t-e),s=Array.from(o).sort((t,e)=>t-e);if(0===a.length||0===s.length)return i;const c=e.width/a.length,l=e.height/s.length,u=new Map;for(const e of t){const t=`${this.getX(e)}_${this.getY(e)}`;u.set(t,{val:r(e),datum:e})}let h=1/0,f=-1/0;for(const{val:t}of u.values())h>t&&(h=t),t>f&&(f=t);const d=f-h||1;for(let t=0;a.length>t;t++)for(let e=0;s.length>e;e++){const r=u.get(`${a[t]}_${s[e]}`);if(!r)continue;const n=(r.val-h)/d;i.push(R(t*c,(s.length-1-e)*l,c,l,`rgb(${Math.round(220-180*n)},${Math.round(220-100*n)},${Math.round(255-50*n)})`,r.datum))}return i}buildStreamingHeatmapScene(t,e){var i,r,n;const o=[],a=null!==(i=this.config.heatmapXBins)&&void 0!==i?i:20,s=null!==(r=this.config.heatmapYBins)&&void 0!==r?r:20,c=null!==(n=this.config.heatmapAggregation)&&void 0!==n?n:"count",l=T(this.config.valueAccessor,"value");if(!this.scales||0===t.length)return o;const[u,h]=this.scales.x.domain(),[f,d]=this.scales.y.domain(),y=(h-u||1)/a,g=(d-f||1)/s,p=new Map;for(const e of t){const t=this.getX(e),i=this.getY(e),r=Math.min(Math.floor((t-u)/y),a-1),n=Math.min(Math.floor((i-f)/g),s-1);if(0>r||0>n)continue;const o=`${r}_${n}`;let c=p.get(o);c||(c={sum:0,count:0,data:[]},p.set(o,c)),c.count++,c.sum+=l(e),c.data.push(e)}let m=1/0,x=-1/0;const v=new Map;for(const[t,e]of p){let i;switch(c){case"sum":i=e.sum;break;case"mean":i=e.count>0?e.sum/e.count:0;break;default:i=e.count}v.set(t,i),m>i&&(m=i),i>x&&(x=i)}const k=x-m||1,b=e.width/a,w=e.height/s;for(const[t,e]of v){const[i,r]=t.split("_"),n=+i,a=+r,c=(e-m)/k,l=`rgb(${Math.round(220-180*c)},${Math.round(220-100*c)},${Math.round(255-50*c)})`,u=p.get(t);o.push(R(n*b,(s-1-a)*w,b,w,l,{xi:n,yi:a,value:e,count:u.count,sum:u.sum,data:u.data}))}return o}buildBarScene(t){var e;if(!this.config.binSize)return[];const i=D(t,this.getX,this.getY,this.config.binSize,this.getCategory);if(0===i.size)return[];let r=null;if(this.getCategory){const t=new Set;for(const e of i.values())for(const i of e.categories.keys())t.add(i);const e=this.config.barColors?Object.keys(this.config.barColors):[],n=new Set(e),o=Array.from(t).filter(t=>!n.has(t)).sort();r=[...e.filter(e=>t.has(e)),...o]}const n=[],o=this.scales,[a,s]=o.x.domain();for(const t of i.values()){const i=Math.max(t.start,a),c=Math.min(t.end,s);if(i>=c)continue;const l=o.x(i),u=o.x(c),h=Math.min(l,u)+.5,f=Math.max(l,u)-.5-h;if(f>0)if(r&&t.categories.size>0){let i=0;for(const a of r){const r=t.categories.get(a)||0;if(0===r)continue;const s=o.y(i),c=o.y(i+r);n.push(N(h,Math.min(s,c),f,Math.abs(s-c),{fill:(null===(e=this.config.barColors)||void 0===e?void 0:e[a])||"#4e79a7"},{binStart:t.start,binEnd:t.end,total:t.total,category:a,categoryValue:r},a)),i+=r}}else{const e=o.y(0),i=o.y(t.total);n.push(N(h,Math.min(e,i),f,Math.abs(e-i),{fill:"#007bff"},{binStart:t.start,binEnd:t.end,total:t.total}))}}return n}buildSwarmScene(t){var e,i,r,n;const o=[],a=this.config.swarmStyle||{},s=null!==(e=a.radius)&&void 0!==e?e:3,c=null!==(i=a.fill)&&void 0!==i?i:"#007bff",l=null!==(r=a.opacity)&&void 0!==r?r:.7,u=a.stroke,h=a.strokeWidth;for(const e of t){const t=this.getX(e),i=this.getY(e);if(null==i||Number.isNaN(i))continue;const r=this.scales.x(t),a=this.scales.y(i);let f=c;if(this.getCategory){const t=this.getCategory(e);f=(null===(n=this.config.barColors)||void 0===n?void 0:n[t])||f}const d={type:"point",x:r,y:a,r:s,style:{fill:f,opacity:l,stroke:u,strokeWidth:h},datum:e};this.getPointId&&(d.pointId=this.getPointId(e)+""),o.push(d)}return o}buildWaterfallScene(t,e){var i,r,n;const o=[],a=this.scales,s=this.config.waterfallStyle,c=t.filter(t=>{const e=this.getY(t);return null!=e&&!Number.isNaN(e)});if(0===c.length)return o;const l=null!==(i=null==s?void 0:s.positiveColor)&&void 0!==i?i:"#28a745",u=null!==(r=null==s?void 0:s.negativeColor)&&void 0!==r?r:"#dc3545",h=null!==(n=null==s?void 0:s.gap)&&void 0!==n?n:1,f=null==s?void 0:s.stroke,d=null==s?void 0:s.strokeWidth;let y=0;for(let t=0;c.length>t;t++){const i=c[t],r=this.getX(i),n=this.getY(i),g=y+n;let p;p=c.length-1>t?this.getX(c[t+1])-r:t>0?r-this.getX(c[t-1]):0;const m=a.x(r),x=0!==p?a.x(r+p):m+e.width/10,v=Math.min(m,x)+h/2,k=Math.max(m,x)-h/2-v;if(0>=k){y=g;continue}const b=a.y(y),w=a.y(g);o.push(N(v,Math.min(b,w),k,Math.abs(b-w),{fill:0>n?u:l,stroke:f,strokeWidth:d},Object.assign(Object.assign({},i),{baseline:y,cumEnd:g,delta:n,_connectorStroke:null==s?void 0:s.connectorStroke,_connectorWidth:null==s?void 0:s.connectorWidth}))),y=g}return o}buildCandlestickScene(t,e){if(!(this.getOpen&&this.getHigh&&this.getLow&&this.getClose&&this.scales))return[];const i=[],r=this.config.candlestickStyle||{},n=r.upColor||"#28a745",o=r.downColor||"#dc3545",a=r.wickColor||"#333",s=r.wickWidth||1,c=t.map(t=>this.getX(t)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let l=r.bodyWidth||6;if(!r.bodyWidth&&c.length>1){let t=1/0;for(let e=1;c.length>e;e++){const i=Math.abs(this.scales.x(c[e])-this.scales.x(c[e-1]));i>0&&t>i&&(t=i)}t!==1/0&&(l=Math.max(2,Math.min(.6*t,20)))}for(const e of t){const t=this.getX(e);if(null==t||Number.isNaN(t))continue;const r=this.getOpen(e),c=this.getHigh(e),u=this.getLow(e),h=this.getClose(e);if([r,c,u,h].some(t=>null==t||Number.isNaN(t)))continue;const f=h>=r;i.push({type:"candlestick",x:this.scales.x(t),openY:this.scales.y(r),closeY:this.scales.y(h),highY:this.scales.y(c),lowY:this.scales.y(u),bodyWidth:l,upColor:n,downColor:o,wickColor:a,wickWidth:s,isUp:f,datum:e})}return i}buildBoundsForGroup(t,e){if(!this.getBounds||!this.scales)return null;const i=[],r=[];for(const e of t){const t=this.getX(e),n=this.getY(e);if(null==t||null==n||Number.isNaN(t)||Number.isNaN(n))continue;const o=this.getBounds(e),a=this.scales.x(t);if(o&&0!==o)i.push([a,this.scales.y(n+o)]),r.push([a,this.scales.y(n-o)]);else{const t=this.scales.y(n);i.push([a,t]),r.push([a,t])}}return 2>i.length?null:{type:"area",topPath:i,bottomPath:r,style:this.resolveBoundsStyle(e,t[0]),datum:t,group:e,interactive:!1}}resolveBoundsStyle(t,e){const i=this.config.boundsStyle;return"function"==typeof i?i(e||{},t):i&&"object"==typeof i?i:{fill:this.resolveLineStyle(t,e).stroke||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(t,e){var i,r,n;const o=this.config.decay;if(!o||1>=e)return 1;const a=null!==(i=o.minOpacity)&&void 0!==i?i:.1,s=e-1-t;switch(o.type){case"linear":return a+(1-s/(e-1))*(1-a);case"exponential":{const t=null!==(r=o.halfLife)&&void 0!==r?r:e/2;return a+Math.pow(.5,s/t)*(1-a)}case"step":return(null!==(n=o.stepThreshold)&&void 0!==n?n:.5*e)>s?1:a;default:return 1}}applyDecay(t,e){var i,r;if(!this.config.decay)return;const n=e.length;if(1>=n)return;const o=new Map;for(let t=0;e.length>t;t++)o.set(e[t],t);for(const e of t){if("line"===e.type||"area"===e.type)continue;const t=o.get(e.datum);if(null==t)continue;const a=this.computeDecayOpacity(t,n);if("heatcell"===e.type)e.style={opacity:a};else if("candlestick"===e.type)e._decayOpacity=a;else{const t=null!==(r=null===(i=e.style)||void 0===i?void 0:i.opacity)&&void 0!==r?r:1;e.style=Object.assign(Object.assign({},e.style),{opacity:t*a})}}}computePulseIntensity(t,e){var i;const r=this.config.pulse;if(!r)return 0;const n=null!==(i=r.duration)&&void 0!==i?i:500,o=e-t;return n>o?1-o/n:0}applyPulse(t,e){var i,r;if(!this.config.pulse||!this.timestampBuffer)return;const n="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(i=this.config.pulse.color)&&void 0!==i?i:"rgba(255,255,255,0.6)",a=null!==(r=this.config.pulse.glowRadius)&&void 0!==r?r:4,s=new Map;for(let t=0;e.length>t;t++)s.set(e[t],t);for(const e of t){if("line"===e.type)continue;if("area"===e.type){const t=Array.isArray(e.datum)?e.datum:[e.datum];let i=0;for(const e of t){const t=s.get(e);if(null==t)continue;const r=this.timestampBuffer.get(t);if(null==r)continue;const o=this.computePulseIntensity(r,n);o>i&&(i=o)}i>0&&(e._pulseIntensity=i,e._pulseColor=o);continue}const t=s.get(e.datum);if(null==t)continue;const i=this.timestampBuffer.get(t);if(null==i)continue;const r=this.computePulseIntensity(i,n);r>0&&(e._pulseIntensity=r,e._pulseColor=o,e._pulseGlowRadius=a)}}get hasActivePulses(){var t;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const e="undefined"!=typeof performance?performance.now():Date.now(),i=null!==(t=this.config.pulse.duration)&&void 0!==t?t:500,r=this.timestampBuffer.peek();return null!=r&&i>e-r}snapshotPositions(){this.prevPositionMap.clear();for(let t=0;this.scene.length>t;t++){const e=this.scene[t],i=this.getNodeIdentity(e,t);i&&("point"===e.type?this.prevPositionMap.set(i,{x:e.x,y:e.y,r:e.r}):"rect"===e.type||"heatcell"===e.type?this.prevPositionMap.set(i,{x:e.x,y:e.y,w:e.w,h:e.h}):"candlestick"===e.type&&this.prevPositionMap.set(i,{x:e.x,y:e.openY}))}}getNodeIdentity(t,e){var i,r,n,o;switch(t.type){case"point":return`p:${void 0===t.datum?e:this.getX(t.datum)}_${this.getY(t.datum)}`;case"rect":return`r:${t.group||""}:${null!==(o=null!==(r=null===(i=t.datum)||void 0===i?void 0:i.binStart)&&void 0!==r?r:null===(n=t.datum)||void 0===n?void 0:n.category)&&void 0!==o?o:e}`;case"heatcell":return`h:${t.x}_${t.y}`;case"candlestick":return"c:"+this.getX(t.datum);default:return null}}startTransition(){var t,e,i,r,n,o;if(!this.config.transition||0===this.prevPositionMap.size)return;const a=null!==(t=this.config.transition.duration)&&void 0!==t?t:300;let s=!1;for(let t=0;this.scene.length>t;t++){const a=this.scene[t],c=this.getNodeIdentity(a,t);if(!c)continue;const l=this.prevPositionMap.get(c);if(l)if("point"===a.type){const t={x:a.x,y:a.y,r:a.r};l.x===t.x&&l.y===t.y||(a._targetX=t.x,a._targetY=t.y,a._targetR=t.r,a.x=l.x,a.y=l.y,a.r=null!==(e=l.r)&&void 0!==e?e:a.r,s=!0)}else if("rect"===a.type){const t={x:a.x,y:a.y,w:a.w,h:a.h};l.x===t.x&&l.y===t.y&&l.w===t.w&&l.h===t.h||(a._targetX=t.x,a._targetY=t.y,a._targetW=t.w,a._targetH=t.h,a.x=l.x,a.y=l.y,a.w=null!==(i=l.w)&&void 0!==i?i:a.w,a.h=null!==(r=l.h)&&void 0!==r?r:a.h,s=!0)}else if("heatcell"===a.type){const t={x:a.x,y:a.y,w:a.w,h:a.h};l.x===t.x&&l.y===t.y||(a._targetX=t.x,a._targetY=t.y,a._targetW=t.w,a._targetH=t.h,a.x=l.x,a.y=l.y,a.w=null!==(n=l.w)&&void 0!==n?n:a.w,a.h=null!==(o=l.h)&&void 0!==o?o:a.h,s=!0)}}s&&(this.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:a})}advanceTransition(t){var e;if(!this.activeTransition)return!1;const i=Math.min((t-this.activeTransition.startTime)/this.activeTransition.duration,1),r="linear"===(null===(e=this.config.transition)||void 0===e?void 0:e.easing)?i:1-Math.pow(1-i,3);for(const t of this.scene)if("point"===t.type){if(void 0===t._targetX)continue;const e=this.getNodeIdentity(t,0);if(!e)continue;const i=this.prevPositionMap.get(e);if(!i)continue;t.x=i.x+(t._targetX-i.x)*r,t.y=i.y+(t._targetY-i.y)*r,void 0!==t._targetR&&void 0!==i.r&&(t.r=i.r+(t._targetR-i.r)*r)}else if("rect"===t.type){if(void 0===t._targetX)continue;const e=this.getNodeIdentity(t,0);if(!e)continue;const i=this.prevPositionMap.get(e);if(!i)continue;t.x=i.x+(t._targetX-i.x)*r,t.y=i.y+(t._targetY-i.y)*r,void 0!==i.w&&(t.w=i.w+(t._targetW-i.w)*r),void 0!==i.h&&(t.h=i.h+(t._targetH-i.h)*r)}else if("heatcell"===t.type){if(void 0===t._targetX)continue;const e=this.getNodeIdentity(t,0);if(!e)continue;const i=this.prevPositionMap.get(e);if(!i)continue;t.x=i.x+(t._targetX-i.x)*r,t.y=i.y+(t._targetY-i.y)*r,void 0!==i.w&&(t.w=i.w+(t._targetW-i.w)*r),void 0!==i.h&&(t.h=i.h+(t._targetH-i.h)*r)}if(i>=1){for(const t of this.scene)if("point"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("rect"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("heatcell"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}return this.activeTransition=null,!1}return!0}groupData(t){if(!this.getGroup)return[{key:"_default",data:t}];const e=new Map;for(const i of t){const t=this.getGroup(i);e.has(t)||e.set(t,[]),e.get(t).push(i)}return Array.from(e.entries()).map(([t,e])=>({key:t,data:e}))}resolveLineStyle(t,e){const i=this.config.lineStyle;return"function"==typeof i?i(e||{},t):i&&"object"==typeof i?{stroke:i.stroke||"#007bff",strokeWidth:i.strokeWidth||2,strokeDasharray:i.strokeDasharray,fill:i.fill,fillOpacity:i.fillOpacity,opacity:i.opacity}:{stroke:"#007bff",strokeWidth:2}}resolveAreaStyle(t,e){var i;if(this.config.areaStyle)return this.config.areaStyle(e||{});const r=this.config.lineStyle;return"function"==typeof r?r(e||{},t):r&&"object"==typeof r?{fill:r.fill||r.stroke||"#4e79a7",fillOpacity:null!==(i=r.fillOpacity)&&void 0!==i?i:.7,stroke:r.stroke||"#4e79a7",strokeWidth:r.strokeWidth||2}:{fill:"#4e79a7",fillOpacity:.7,stroke:"#4e79a7",strokeWidth:2}}getData(){return this.buffer.toArray()}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.activeTransition=null,this.lastIngestTime=0,this.needsFullRebuild=!0,this.lastLayout=null,this.scales=null,this.scene=[],this.version++}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}updateConfig(t){Object.assign(this.config,t),this.needsFullRebuild=!0}}function Y(t,e){var i=t.get(e);if(!i)throw Error("missing: "+e);return i}function B(t,e){var i,r=[],n=[],o=[],a={},s=[];function c(t){o[t]=!1,a.hasOwnProperty(t)&&Object.keys(a[t]).forEach(function(e){delete a[t][e],o[e]&&c(e)})}function l(t){var e,r,h=!1;for(n.push(t),o[t]=!0,e=0;s[t].length>e;e++)(r=s[t][e])===i?(u(i,n),h=!0):o[r]||(h=l(r));if(h)c(t);else for(e=0;s[t].length>e;e++){var f=a[r=s[t][e]];f||(a[r]=f={}),f[r]=!0}return n.pop(),h}function u(t,e){var i=[].concat(e).concat(t);r.push(i)}function h(e){!function(e){for(var i=0;t.length>i;i++)i>=e&&t[i]||(t[i]=[]),t[i]=t[i].filter(function(t){return t>=e})}(e);for(var i,r=function(t){for(var e=t.length,i=Array(e),r=Array(e),n=Array(e),o=Array(e),a=Array(e),s=Array(e),c=0;e>c;++c)i[c]=-1,r[c]=0,n[c]=!1,o[c]=0,a[c]=-1,s[c]=[];var l,u=0,h=[],f=[];function d(e){var c=[e],l=[e];for(i[e]=r[e]=u,n[e]=!0,u+=1;l.length>0;){var d=t[e=l[l.length-1]];if(d.length>o[e]){for(var y=o[e];d.length>y;++y){var g=d[y];if(0>i[g]){i[g]=r[g]=u,n[g]=!0,u+=1,c.push(g),l.push(g);break}n[g]&&(r[e]=0|Math.min(r[e],r[g])),0>a[g]||s[e].push(a[g])}o[e]=y}else{if(r[e]===i[e]){var p=[],m=[],x=0;for(y=c.length-1;y>=0;--y){var v=c[y];if(n[v]=!1,p.push(v),m.push(s[v]),x+=s[v].length,a[v]=h.length,v===e){c.length=y;break}}h.push(p);var k=Array(x);for(y=0;m.length>y;y++)for(var b=0;m[y].length>b;b++)k[--x]=m[y][b];f.push(k)}l.pop()}}}for(c=0;e>c;++c)0>i[c]&&d(c);for(c=0;f.length>c;c++){var y=f[c];if(0!==y.length){y.sort(function(t,e){return t-e}),l=[y[0]];for(var g=1;y.length>g;g++)y[g]!==y[g-1]&&l.push(y[g]);f[c]=l}}return{components:h,adjacencyList:f}}(t),n=r.components.filter(function(t){return t.length>1}),o=1/0,a=0;n.length>a;a++)for(var s=0;n[a].length>s;s++)o>n[a][s]&&(o=n[a][s],i=a);var c=n[i];if(!c)return!1;var l=t.map(function(t,e){return-1===c.indexOf(e)?[]:t.filter(function(t){return-1!==c.indexOf(t)})});return{leastVertex:o,adjList:l}}i=0;for(var f=t.length;f>i;){var d=h(i);if(i=d.leastVertex,s=d.adjList){for(var y=0;s.length>y;y++)for(var g=0;s[y].length>g;g++){var p=s[y][g];o[+p]=!1,a[p]={}}l(i),i+=1}else i=f}return r}function X(t){return t.y0-t.y1>0?"up":"down"}function C(t,e){return e(t.source)==e(t.target)}function I(t){var e=0;t.source.sourceLinks.forEach(function(t){e=t.circular?e+1:e});var i=0;return t.target.targetLinks.forEach(function(t){i=t.circular?i+1:i}),1>=e&&1>=i}function j(t){return t.target.x0-t.source.x1}function F(t,e){var i=H(t),r=j(e)/Math.tan(i);return"up"==X(t)?t.y1-r:t.y1+r}function q(t,e){var i=H(t),r=j(e)/Math.tan(i);return"up"==X(t)?t.y1+r:t.y1-r}function H(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function G(t,e){return e(t)}function V(t){return Q(t.source)}function Z(t){return Q(t.target)}function Q(t){return(t.y0+t.y1)/2}function U(t){return t.virtual?0:t.value}function J(t,e){var i=0;t.sourceLinks.forEach(function(t){i=t.circular&&!C(t,e)?i+1:i});var r=0;return t.targetLinks.forEach(function(t){r=t.circular&&!C(t,e)?r+1:r}),i+r}function K(t){return t.target.depth}function tt(t,e){return t.sourceLinks.length?t.depth:e-1}function et(t,e){return t.y0-e.y0}function it(t,e){return e.y0-t.y0}function rt(t,e){return t.y1-e.y1}function nt(t,e){return e.y1-t.y1}function ot(t,e){return st(t.source,e.source)||t.index-e.index}function at(t,e){return st(t.target,e.target)||t.index-e.index}function st(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function ct(t,e){return lt(t)==lt(e)?"bottom"==t.circularLinkType?it(t,e):et(t,e):lt(e)-lt(t)}function lt(t){return t.target.column-t.source.column}function ut(t,e){return ht(t)==ht(e)}function ht(t){return t.y0-t.y1>0?"up":"down"}function ft(t,e,i,n,o){let a=t;var s=Math.max(8,.15*(a.y1-a.y0));a.links.forEach(function(t){t.circular&&(t._circularWidth=Math.min(t.width,s))});var c=r(a.links,function(t){return t.source.y0});a.links.forEach(function(t){t.circular&&(t.circularPathData={})});var l=a.links.filter(function(t){return t.circular});return l.sort(function(t,e){return e.value-t.value}),l.forEach(function(t,e){t._circularStub=e>=4}),dt(a.links.filter(function(t){return"top"==t.circularLinkType}),e,i),dt(a.links.filter(function(t){return"bottom"==t.circularLinkType}),e,i),a.links.forEach(function(t){if(t.circular){if(t.circularPathData.arcRadius=t._circularWidth+n,t.circularPathData.rightNodeBuffer=5,t.circularPathData.leftNodeBuffer=5,t.circularPathData.sourceWidth=t.source.x1-t.source.x0,t.circularPathData.sourceX=t.source.x0+t.circularPathData.sourceWidth,t.circularPathData.targetX=t.target.x0,t.circularPathData.sourceY=t.y0,t.circularPathData.targetY=t.y1,C(t,e)&&I(t))t.circularPathData.rightSmallArcRadius=n+t._circularWidth/2,t.circularPathData.rightLargeArcRadius=n+t._circularWidth/2,t.circularPathData.leftSmallArcRadius=n+t._circularWidth/2,t.circularPathData.leftLargeArcRadius=n+t._circularWidth/2,"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=t.source.y1+o+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=t.source.y0-o-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius);else{var r=t.source.column,s=t.circularLinkType,l=a.links.filter(function(t){return t.source.column==r&&t.circularLinkType==s});l.sort("bottom"==t.circularLinkType?it:et);var u=0;l.forEach(function(e,r){e.circularLinkID==t.circularLinkID&&(t.circularPathData.rightSmallArcRadius=n+t._circularWidth/2+u,t.circularPathData.rightLargeArcRadius=n+t._circularWidth/2+r*i+u),u+=e._circularWidth||e.width}),r=t.target.column,(l=a.links.filter(function(t){return t.target.column==r&&t.circularLinkType==s})).sort("bottom"==t.circularLinkType?nt:rt),u=0,l.forEach(function(e,r){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=n+t._circularWidth/2+u,t.circularPathData.leftLargeArcRadius=n+t._circularWidth/2+r*i+u),u+=e._circularWidth||e.width}),"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=Math.max(a.y1,t.source.y1,t.target.y1)+o+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=c-o-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius)}t.circularPathData.rightInnerExtent=t.circularPathData.sourceX+t.circularPathData.rightNodeBuffer,t.circularPathData.leftInnerExtent=t.circularPathData.targetX-t.circularPathData.leftNodeBuffer,t.circularPathData.rightFullExtent=t.circularPathData.sourceX+t.circularPathData.rightLargeArcRadius+t.circularPathData.rightNodeBuffer,t.circularPathData.leftFullExtent=t.circularPathData.targetX-t.circularPathData.leftLargeArcRadius-t.circularPathData.leftNodeBuffer}t.path=t.circular?function(t){return"top"==t.circularLinkType?"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 0 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY-t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 0 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 0 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY-t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 0 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY:"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 1 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY+t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 1 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 1 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY+t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 1 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY}(t):function(t){var e=t.source.x1,i=t.y0,r=t.target.x0,n=t.y1,o=(e+r)/2;return"M"+e+","+i+"C"+o+","+i+" "+o+","+n+" "+r+","+n}(t)}),a}function dt(t,e,i){t.sort(ct);var r=t.filter(function(t){return!t._circularStub});return t.forEach(function(t,n){var o=0;if(t._circularStub)t.circularPathData.verticalBuffer=0;else if(C(t,e)&&I(t))t.circularPathData.verticalBuffer=o+t._circularWidth/2;else{for(var a=0;r.length>a;a++){var s=r[a];if(s!==t&&s.circularPathData&&void 0!==s.circularPathData.verticalBuffer&&yt(t,s)){var c=s.circularPathData.verticalBuffer+(s._circularWidth||s.width)/2+i;o=c>o?c:o}}t.circularPathData.verticalBuffer=o+t._circularWidth/2}}),t}function yt(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}function gt(t){return function(){return t}}function pt(t){return t.index}function mt(t){return t.nodes}function xt(t){return t.links}function vt(t,e,i){var r=n(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});r.forEach(function(n){var o=n.length;n.sort(e||function(t,e){return t.circularLinkType==e.circularLinkType?J(e,i)-J(t,i):"top"==t.circularLinkType&&"bottom"==e.circularLinkType||"top"==t.circularLinkType&&0==e.partOfCycle||0==t.partOfCycle&&"bottom"==e.circularLinkType?-1:0}),n.forEach(function(e,n){e.depth==r.length-1&&1==o||0==e.depth&&1==o?(e.y0=t.y1/2-e.value*t.ky,e.y1=e.y0+e.value*t.ky):e.partOfCycle?0==J(e,i)?(e.y0=t.y1/2+n,e.y1=e.y0+e.value*t.ky):"top"==e.circularLinkType?(e.y0=t.y0+n,e.y1=e.y0+e.value*t.ky):(e.y0=t.y1-e.value*t.ky-n,e.y1=e.y0+e.value*t.ky):0==t.y0||0==t.y1?(e.y0=(t.y1-t.y0)/o*n,e.y1=e.y0+e.value*t.ky):(e.y0=(t.y1-t.y0)/2-o/2+n,e.y1=e.y0+e.value*t.ky)})})}function kt(t,e,i,r,o,a){var c=n(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});f();for(var l=1,u=a;u>0;--u)h(l*=.99,i),f();function h(e,i){var r=c.length;c.forEach(function(n){var o=n.length,a=n[0].depth;n.forEach(function(n){var c;if(n.sourceLinks.length||n.targetLinks.length)if(n.partOfCycle&&J(n,i)>0){var l=s(n.sourceLinks,Z),u=s(n.targetLinks,V),h=l&&u?(l+u)/2:l||u;if(h){var f=(h-Q(n))*e*.3;n.y0+=f,n.y1+=f}}else if(0==a&&1==o)n.y0=t.y1/2-(c=n.y1-n.y0)/2,n.y1=t.y1/2+c/2;else if(a==r-1&&1==o)n.y0=t.y1/2-(c=n.y1-n.y0)/2,n.y1=t.y1/2+c/2;else if(1==n.targetLinks.length&&1==n.targetLinks[0].source.sourceLinks.length)c=n.y1-n.y0,n.y0=n.targetLinks[0].source.y0,n.y1=n.y0+c;else{var d=s(n.sourceLinks,Z),y=s(n.targetLinks,V),g=((d&&y?(d+y)/2:d||y)-Q(n))*e;n.y0+=g,n.y1+=g}})})}function f(){c.forEach(function(i){var n,a,s,c=t.y0,l=i.length;for(i.sort(e||st),s=0;l>s;++s)(a=c-(n=i[s]).y0)>0&&(n.y0+=a,n.y1+=a),c=n.y1+r;if((a=c-r-t.y1)>0)for(c=n.y0-=a,n.y1-=a,s=l-2;s>=0;--s)(a=(n=i[s]).y1+o-c)>0&&(n.y0-=a,n.y1-=a),c=n.y0})}}function bt(t){t.nodes.forEach(function(t){t.sourceLinks.sort(at),t.targetLinks.sort(ot)}),t.nodes.forEach(function(t){var e=t.y0,i=e,r=t.y1,n=r;t.sourceLinks.forEach(function(t){t.circular?(t.y0=r-t.width/2,r-=t.width):(t.y0=e+t.width/2,e+=t.width)}),t.targetLinks.forEach(function(t){t.circular?(t.y1=n-t.width/2,n-=t.width):(t.y1=i+t.width/2,i+=t.width)})})}function wt(){var t=0,e=0,i=1,s=1,l=24,u=8,h=null,f=pt,d=tt,y=void 0,g=32,p=2,m=mt,x=xt;function v(){var v={nodes:m.apply(null,arguments),links:x.apply(null,arguments)};return function(m){m.x0=t,m.y0=e,m.x1=i,m.y1=s,m.py=0,function(t,e){t.nodes.forEach(function(t,e){t.index=e,t.sourceLinks=[],t.targetLinks=[]});var i=function(t,e){var i=new Map;return c(t,e).forEach(function(t,e){i.set(e,t[0])}),i}(t.nodes,e);t.links.forEach(function(t,e){t.index=e;var r=t.source,n=t.target;"object"!=typeof r&&(r=t.source=Y(i,r)),"object"!=typeof n&&(n=t.target=Y(i,n)),r.sourceLinks.push(t),n.targetLinks.push(t)})}(m,f),function(t,e){var i=0;if(null==e){for(var r=[],n=0;t.links.length>n;n++){var o=t.links[n],a=o.source.index,s=o.target.index;r[a]||(r[a]=[]),r[s]||(r[s]=[]),-1===r[a].indexOf(s)&&r[a].push(s)}var c=B(r);c.sort(function(t,e){return t.length-e.length});var l={};for(n=0;c.length>n;n++){var u=c[n].slice(-2);l[u[0]]||(l[u[0]]={}),l[u[0]][u[1]]=!0}t.links.forEach(function(t){var e=t.target.index,r=t.source.index;e===r||l[r]&&l[r][e]?(t.circular=!0,t.circularLinkID=i++):t.circular=!1})}else t.links.forEach(function(t){e(t.source)<e(t.target)?t.circular=!1:(t.circular=!0,t.circularLinkID=i++)})}(m,y),function(t,e){var i=0,r=0;t.links.forEach(function(n){n.circular&&(n.circularLinkType=n.source.circularLinkType||n.target.circularLinkType?n.source.circularLinkType?n.source.circularLinkType:n.target.circularLinkType:r>i?"top":"bottom","top"==n.circularLinkType?i++:r++,t.nodes.forEach(function(t){G(t,e)!=G(n.source,e)&&G(t,e)!=G(n.target,e)||(t.circularLinkType=n.circularLinkType)}))}),t.links.forEach(function(t){t.circular&&(t.source.circularLinkType==t.target.circularLinkType&&(t.circularLinkType=t.source.circularLinkType),C(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(m,f),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max(a(t.sourceLinks,U),a(t.targetLinks,U)),t.sourceLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)}),t.targetLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)})})}(m),function(t,e,i){var r,n,o;if(null!=e){t.nodes.sort(function(t,i){return e(t)<e(i)?-1:1});var a=0,s=e(t.nodes[0]);t.nodes.forEach(function(t){a=e(t)==s?a:a+1,s=e(t)==s?s:e(t),t.column=a})}for(r=t.nodes,n=[],o=0;r.length;++o,r=n,n=[])r.forEach(function(t){t.depth=o,t.sourceLinks.forEach(function(t){0>n.indexOf(t.target)&&!t.circular&&n.push(t.target)})});for(r=t.nodes,n=[],o=0;r.length;++o,r=n,n=[])r.forEach(function(t){t.height=o,t.targetLinks.forEach(function(t){0>n.indexOf(t.source)&&!t.circular&&n.push(t.source)})});t.nodes.forEach(function(t){t.column=null==e?i(t,o):t.column})}(m,y,d);var x=u;if(null!==h){var v=n(m.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),k=o(v,function(t){return t.length});k>1&&(x=Math.max(1,(s-e)*h/(k-1)))}(function(t,e,i){var s=n(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});t.py=e;var c=r(s,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/a(e,function(t){return t.value})});t.ky=c,t.links.forEach(function(e){e.width=e.value*t.ky});var l=o(t.nodes,function(t){return t.column});t.nodes.forEach(l>0?function(e){e.x0=t.x0+e.column*((t.x1-t.x0-i)/l),e.x1=e.x0+i}:function(e){e.x0=t.x0,e.x1=e.x0+i})})(m,x,l),vt(m,y,f),kt(m,y,f,x,x,g),bt(m),ft(m,f,p,10,8),vt(m,y,f),kt(m,y,f,x,x,g),bt(m),ft(m,f,p,10,8),function(t,e){let i=t;i.nodes.forEach(function(t){t.y+(t.y1-t.y0)>i.y1&&(t.y=t.y-(t.y+(t.y1-t.y0)-i.y1));var r=i.links.filter(function(i){return G(i.source,e)==G(t,e)}),n=r.length;n>1&&r.sort(function(t,e){if(!t.circular&&!e.circular){if(t.target.column==e.target.column)return t.y1-e.y1;if(!ut(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var i=F(e,t);return t.y1-i}if(e.target.column>t.target.column)return F(t,e)-e.y1}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.target.column===e.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.target.column===e.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:"top"==t.circularLinkType?-1:1:void 0});var o=t.y0;r.forEach(function(t){t.y0=o+t.width/2,o+=t.width}),r.forEach(function(e,i){if("bottom"==e.circularLinkType){for(var o=i+1,a=0;n>o;o++)a+=r[o].width;e.y0=t.y1-a-e.width/2}})})}(m,f),function(t,e){let i=t;i.nodes.forEach(function(t){var r=i.links.filter(function(i){return G(i.target,e)==G(t,e)}),n=r.length;n>1&&r.sort(function(t,e){if(!t.circular&&!e.circular){if(t.source.column==e.source.column)return t.y0-e.y0;if(!ut(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var i=q(e,t);return t.y0-i}if(e.source.column>t.source.column)return q(t,e)-e.y0}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:t.source.column-e.source.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:e.source.column-t.source.column:"top"==t.circularLinkType?-1:1:void 0});var o=t.y0;r.forEach(function(t){t.y1=o+t.width/2,o+=t.width}),r.forEach(function(e,i){if("bottom"==e.circularLinkType){for(var o=i+1,a=0;n>o;o++)a+=r[o].width;e.y1=t.y1-a-e.width/2}})})}(m,f),function(t){var e=t.nodes,i=t.links,n=!1,a=!1;if(i.forEach(function(t){"top"==t.circularLinkType?n=!0:"bottom"==t.circularLinkType&&(a=!0)}),0==n||0==a){var s=r(e,function(t){return t.y0}),c=o(e,function(t){return t.y1}),l=(t.y1-t.y0)/(c-s);function u(e){return(e-s)/(c-s)*(t.y1-t.y0)+t.y0}1>l?(e.forEach(function(t){t.y0=u(t.y0),t.y1=u(t.y1)}),i.forEach(function(t){t.y0=u(t.y0),t.y1=u(t.y1),t.width=t.width*l})):e.forEach(function(t){var e=t.y1-t.y0,i=u(t.y0)-t.y0;t.y0=u(t.y0),t.y1=t.y0+e,t.sourceLinks.forEach(function(t){t.y0=t.y0+i}),t.targetLinks.forEach(function(t){t.y1=t.y1+i})})}}(m),ft(m,f,p,10,8)}(v),v}return v.update=function(t){return bt(t),ft(t,f,p,10,8),t},v.nodeWidth=function(t){return arguments.length?(l=+t,v):l},v.nodePadding=function(t){return arguments.length?(u=+t,v):u},v.nodePaddingRatio=function(t){return arguments.length?(h=+t,v):h},v.nodes=function(t){return arguments.length?(m="function"==typeof t?t:gt(t),v):m},v.links=function(t){return arguments.length?(x="function"==typeof t?t:gt(t),v):x},v.nodeId=function(t){return arguments.length?(f="function"==typeof t?t:gt(t),v):f},v.nodeAlign=function(t){return arguments.length?(d="function"==typeof t?t:gt(t),v):d},v.nodeSort=function(t){return arguments.length?(y=t,v):y},v.iterations=function(t){return arguments.length?(g=+t,v):g},v.circularLinkGap=function(t){return arguments.length?(p=+t,v):p},v.extent=function(r){return arguments.length?(t=+r[0][0],e=+r[0][1],i=+r[1][0],s=+r[1][1],v):[[t,e],[i,s]]},v.size=function(r){return arguments.length?(t=e=0,i=+r[0],s=+r[1],v):[i-t,s-e]},v}const Et=t=>{let e,i,r,n,o,a,s,c,l;return"down"===t.direction?(e=t.y0-t.sankeyWidth/2,i=t.y1-t.sankeyWidth/2,r=t.y1+t.sankeyWidth/2,n=t.y0+t.sankeyWidth/2,o=t.source.y1,a=t.target.y0,s=h(o,a),c=s(.5),l=s(.5),`M${e},${o}C${e},${c} ${i},${l} ${i},${a}L${r},${a}C${r},${l} ${n},${c} ${n},${o}Z`):(e=t.source.x1,i=t.target.x0,s=h(e,i),r=s(.5),n=s(.5),o=t.y0-t.sankeyWidth/2,a=t.y1-t.sankeyWidth/2,c=t.y1+t.sankeyWidth/2,l=t.y0+t.sankeyWidth/2,`M${e},${o}C${r},${o} ${n},${a} ${i},${a}L${i},${c}C${n},${c} ${r},${l} ${e},${l}Z`)};function At(t){var e;const i=t.sankeyWidth/2,r=(null!==(e=t._circularWidth)&&void 0!==e?e:t.sankeyWidth)/2,n=t.circularPathData;if(!n)return null;if("down"===t.direction)return null;if(t._circularStub){const e=n.sourceX,r=n.sourceY,o=n.targetX,a=n.targetY;if("object"!=typeof t.source||!t.source||"object"!=typeof t.target||!t.target)return null;const s=Math.max(15,Math.min(40,.33*(n.rightFullExtent-e))),c=Math.max(15,Math.min(40,.33*(o-n.leftFullExtent)));return`M${e},${r-i}L${e+s},${r-i}L${e+s},${r+i}L${e},${r+i}ZM${o},${a-i}L${o-c},${a-i}L${o-c},${a+i}L${o},${a+i}Z`}const o=n.sourceX,a=n.sourceY,s=n.targetX,c=n.targetY,l=n.rightFullExtent,u=n.leftFullExtent,h=n.verticalFullExtent,f="bottom"===t.circularLinkType?1:-1,d=Math.max(4,Math.min(r,15));return`M${o},${a-f*i}L${l},${a-f*i}L${l+r},${a-f*i+f*d}L${l+r},${h+f*r-f*d}L${l+r-d},${h+f*r}L${u-r+d},${h+f*r}L${u-r},${h+f*r-f*d}L${u-r},${c-f*i+f*d}L${u-r+d},${c-f*i}L${s},${c-f*i}L${s},${c+f*i}L${u+r},${c+f*i}L${u+r},${h-f*r}L${l-r},${h-f*r}L${l-r},${a+f*i}L${o},${a+f*i}Z`}const St={left:function(t){return t.depth},right:function(t,e){return e-1-t.height},center:function(t){return t.targetLinks.length?t.depth:t.sourceLinks.length?Math.min.apply(Math,t.sourceLinks.map(K))-1:0},justify:tt},Pt={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,i,r){var n,o,a,s,c,l,u;if(0===t.length)return;const h="vertical"===i.orientation?"down":"right",f=i.nodeAlign||"justify",d=null!==(n=i.nodeWidth)&&void 0!==n?n:15,y=null!==(o=i.nodePaddingRatio)&&void 0!==o?o:.05,g=null!==(a=i.iterations)&&void 0!==a?a:100,p=t.map(t=>Object.assign({},t)),m=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id,value:Math.sqrt(Math.max(1,t.value||1))}));let x;x="down"===h?[[0,0],[r[1],r[0]]]:[[0,0],[r[0],r[1]]];const v=wt().extent(x).links(m).nodes(p).nodeAlign(St[f]||tt).nodeId(t=>t.id).nodeWidth(d).iterations(g);v.nodePaddingRatio&&v.nodePaddingRatio(y),v();{let t=1/0,e=-1/0,i=1/0,n=-1/0;for(const r of p)t>r.x0&&(t=r.x0),r.x1>e&&(e=r.x1),i>r.y0&&(i=r.y0),r.y1>n&&(n=r.y1);for(const r of m){if(!r.circular||!r.circularPathData)continue;const o=r.circularPathData,a=(null!==(c=null!==(s=r._circularWidth)&&void 0!==s?s:r.width)&&void 0!==c?c:0)/2;t>o.leftFullExtent-a&&(t=o.leftFullExtent-a),o.rightFullExtent+a>e&&(e=o.rightFullExtent+a),i>o.verticalFullExtent-a&&(i=o.verticalFullExtent-a),o.verticalFullExtent+a>n&&(n=o.verticalFullExtent+a)}const o=e-t,a=n-i,u=r[0],h=r[1];if(o>0&&a>0&&(0>t||0>i||e>u||n>h)){const e=Math.min(u/o,h/a),r=-t*e+(u-o*e)/2,n=-i*e+(h-a*e)/2;for(const t of p)t.x0=t.x0*e+r,t.x1=t.x1*e+r,t.y0=t.y0*e+n,t.y1=t.y1*e+n;for(const t of m)if(t.y0=t.y0*e+n,t.y1=t.y1*e+n,t.width=(null!==(l=t.width)&&void 0!==l?l:0)*e,t._circularWidth&&(t._circularWidth*=e),t.circular&&t.circularPathData){const i=t.circularPathData;i.sourceX=i.sourceX*e+r,i.targetX=i.targetX*e+r,i.sourceY=i.sourceY*e+n,i.targetY=i.targetY*e+n,i.rightFullExtent=i.rightFullExtent*e+r,i.leftFullExtent=i.leftFullExtent*e+r,i.verticalFullExtent=i.verticalFullExtent*e+n,i.rightInnerExtent=i.rightInnerExtent*e+r,i.leftInnerExtent=i.leftInnerExtent*e+r,i.verticalRightInnerExtent=i.verticalRightInnerExtent*e+n,i.verticalLeftInnerExtent=i.verticalLeftInnerExtent*e+n,i.rightSmallArcRadius*=e,i.rightLargeArcRadius*=e,i.leftSmallArcRadius*=e,i.leftLargeArcRadius*=e,i.sourceWidth*=e,i.rightNodeBuffer*=e,i.leftNodeBuffer*=e,i.arcRadius*=e}}}const k=new Map;for(const e of t)k.set(e.id,e);for(const t of p){const e=k.get(t.id);e&&(e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.value=t.value,e.depth=t.depth,e.sourceLinks=t.sourceLinks,e.targetLinks=t.targetLinks,e.width=t.x1-t.x0,e.height=t.y1-t.y0,e.x=t.x0+(t.x1-t.x0)/2,e.y=t.y0+(t.y1-t.y0)/2)}const b=new Map;for(const t of e)b.set(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const t of m){const e=t.source,i=t.target,r="object"==typeof e&&null!==e?e.id:e+"",n="object"==typeof i&&null!==i?i.id:i+"",o=b.get(`${r}\0${n}`);if(o){o.y0=t.y0,o.y1=t.y1,o.sankeyWidth=null!==(u=t.width)&&void 0!==u?u:0,o.circular=!!t.circular,o.circularPathData=t.circularPathData,o._circularWidth=t._circularWidth,o._circularStub=t._circularStub,o.path=t.path,o.circularLinkType=t.circularLinkType,o.direction=h;const e=k.get(r),i=k.get(n);e&&(o.source=e),i&&(o.target=i)}}},buildScene(t,e,i,r){var n,o,a,s;const c="vertical"===i.orientation?"down":"right",l=i.nodeStyle,h=i.edgeStyle,f=null!==(n=i.edgeOpacity)&&void 0!==n?n:.5,d=i.edgeColorBy||"source",y=Array.isArray(i.colorScheme)?i.colorScheme:u,g=new Map;t.forEach((t,e)=>{g.set(t.id,y[e%y.length])});const p=[],m=[],x=[];for(const e of t){const t=e.x1-e.x0,i=e.y1-e.y0;if(0>=t||0>=i)continue;const r=l?l(e):{},n={fill:r.fill||g.get(e.id)||"#4d430c",stroke:r.stroke,strokeWidth:r.strokeWidth,opacity:r.opacity};p.push({type:"rect",x:e.x0,y:e.y0,w:t,h:i,style:n,datum:e,id:e.id,label:e.id})}const v=[...e].sort((t,e)=>(e.sankeyWidth||0)-(t.sankeyWidth||0));for(const t of v){if(!t.sankeyWidth||0>=t.sankeyWidth)continue;const e="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;if(!e||!i)continue;let r="#999";h?r=h(t).fill||r:"target"===d&&i?r=g.get(i.id)||r:e&&(r=g.get(e.id)||r);const n=h?h(t):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,i=t.sankeyWidth/2,s=Math.max(15,Math.min(40,.33*(e.rightFullExtent-e.sourceX))),c=Math.max(15,Math.min(40,.33*(e.targetX-e.leftFullExtent))),l=n.fill||r;m.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-i}L${e.sourceX+s},${e.sourceY-i}L${e.sourceX+s},${e.sourceY+i}L${e.sourceX},${e.sourceY+i}Z`,style:{fill:l,fillOpacity:null!==(o=n.fillOpacity)&&void 0!==o?o:f,stroke:"none",opacity:n.opacity},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+s}}),m.push({type:"bezier",pathD:`M${e.targetX},${e.targetY-i}L${e.targetX-c},${e.targetY-i}L${e.targetX-c},${e.targetY+i}L${e.targetX},${e.targetY+i}Z`,style:{fill:l,fillOpacity:null!==(a=n.fillOpacity)&&void 0!==a?a:f,stroke:"none",opacity:n.opacity},datum:t,_gradient:{direction:"left",from:0,to:1,x0:e.targetX-c,x1:e.targetX}});continue}let c;if(c=t.circular&&t.circularPathData?At(t):Et(t),!c)continue;const l={fill:n.fill||r,fillOpacity:null!==(s=n.fillOpacity)&&void 0!==s?s:f,stroke:n.stroke||"none",strokeWidth:n.strokeWidth,opacity:n.opacity};m.push({type:"bezier",pathD:c,bezierCache:t.bezier,style:l,datum:t})}if(!1!==i.showLabels){const e=(k=i.nodeLabel)?"function"==typeof k?k:t=>t[k]||t.id:null;for(const i of t){const t=i.x1-i.x0,n=i.y1-i.y0;if(0>=t||0>=n)continue;const o=e?e(i):i.id;if(!o)continue;let a,s,l;"down"===c?(a=i.x0+t/2,s=i.y1+14,l="middle"):(r[0]/2>i.x0+t/2?(a=i.x0-6,l="end"):(a=i.x1+6,l="start"),s=i.y0+n/2),x.push({x:a,y:s,text:o+"",anchor:l,baseline:"middle",fontSize:11})}}var k;return{sceneNodes:p,sceneEdges:m,labels:x}}},Lt={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,i,r){var n,o;if(0===t.length)return;const a=null!==(n=i.iterations)&&void 0!==n?n:Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),s=null!==(o=i.forceStrength)&&void 0!==o?o:.1,c=r[0]/2,l=r[1]/2;for(let e=0;t.length>e;e++){const i=t[e];if(null==i.x||null==i.y||0===i.x&&0===i.y){const t=10*Math.sqrt(e+.5),r=2.399963229728653*e;i.x=c+t*Math.cos(r),i.y=l+t*Math.sin(r)}}const u=Mt(i.nodeSize,i.nodeSizeRange,t),h=f().strength(t=>Math.min(2.5,t.weight?t.weight*s:s)).id(t=>t.id),m=r[1]/r[0],x=d().force("charge",y().strength(t=>-25*(t=>u(t))(t))).force("x",g(r[0]/2).strength(.1*m)).force("y",p(r[1]/2).strength(.1));if(x.nodes(t),e.length>0){const t=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id}));x.force("link",h),x.force("link").links(t)}.1>x.alpha()&&x.alpha(1),x.stop();for(let t=0;a>t;++t)x.tick();const v=new Map;for(const e of t)v.set(e.id,e);for(const t of e){if("string"==typeof t.source){const e=v.get(t.source);e&&(t.source=e)}if("string"==typeof t.target){const e=v.get(t.target);e&&(t.target=e)}}},buildScene(t,e,i,r){var n,o,a;const s=i.nodeStyle,c=i.edgeStyle,l=Mt(i.nodeSize,i.nodeSizeRange,t),h=Array.isArray(i.colorScheme)?i.colorScheme:u,f=new Map;t.forEach((t,e)=>{f.set(t.id,h[e%h.length])});const d=[],y=[],g=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=l(e),i=s?s(e):{},r={fill:i.fill||f.get(e.id)||"#007bff",stroke:i.stroke||"#fff",strokeWidth:null!==(n=i.strokeWidth)&&void 0!==n?n:2,opacity:i.opacity};d.push({type:"circle",cx:e.x,cy:e.y,r:t,style:r,datum:e,id:e.id,label:e.id})}const p=new Map;for(const e of t)p.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:p.get(t.source),i="object"==typeof t.target?t.target:p.get(t.target);if(!e||!i)continue;if(null==e.x||null==e.y)continue;if(null==i.x||null==i.y)continue;const r=c?c(t):{},n={stroke:r.stroke||"#999",strokeWidth:null!==(o=r.strokeWidth)&&void 0!==o?o:1,opacity:null!==(a=r.opacity)&&void 0!==a?a:.6};y.push({type:"line",x1:e.x,y1:e.y,x2:i.x,y2:i.y,style:n,datum:t})}if(!1!==i.showLabels){const e=(m=i.nodeLabel)?"function"==typeof m?m:t=>t[m]||t.id:null;for(const i of t){if(null==i.x||null==i.y)continue;const t=e?e(i):i.id;if(!t)continue;const r=l(i);g.push({x:i.x,y:i.y-r-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var m;return{sceneNodes:d,sceneEdges:y,labels:g}}};function Mt(t,i,n){var a,s;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const c=i||[5,20],l=n.map(e=>{var i;return null===(i=e.data)||void 0===i?void 0:i[t]}).filter(t=>null!=t&&"number"==typeof t);if(0===l.length)return()=>c[0];const u=null!==(a=r(l))&&void 0!==a?a:0,h=null!==(s=o(l))&&void 0!==s?s:1;if(u===h)return()=>(c[0]+c[1])/2;const f=e().domain([u,h]).range(c).clamp(!0);return e=>{var i;const r=null===(i=e.data)||void 0===i?void 0:i[t];return null==r||"number"!=typeof r?c[0]:f(r)}}const Dt=u,_t={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,i,r){if(0===t.length)return;const{padAngle:n=.01,groupWidth:o=20,sortGroups:a}=i,s=Math.min(r[0],r[1])/2,c=s-o,l=r[0]/2,u=r[1]/2,h=(f=i.valueAccessor)?"function"==typeof f?f:t=>{var e;return null!==(e=t[f])&&void 0!==e?e:1}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:1};var f;const d=new Map;for(let e=0;t.length>e;e++)d.set(t[e].id,e);const y=t.length,g=Array.from({length:y},()=>Array.from({length:y},()=>0));for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,i=d.get("string"==typeof t.source?t.source:t.source.id),r=d.get(e);if(void 0===i||void 0===r)continue;const n=h(t);g[i][r]=n}const p=x().padAngle(n);a&&p.sortGroups(a);const m=p(g),k=m.groups,b=v().innerRadius(c).outerRadius(s);for(const e of k){const i=t[e.index],r=b.centroid(e);i.x=r[0]+l,i.y=r[1]+u,i.arcData={startAngle:e.startAngle,endAngle:e.endAngle}}const w=new Map;for(const e of t)w.set(e.id,e);for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,i=w.get("string"==typeof t.source?t.source:t.source.id),r=w.get(e);i&&(t.source=i),r&&(t.target=r)}const E=new Map;for(const t of e)E.set(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const e of m){const i=t[e.source.index].id,r=t[e.target.index].id,n=E.get(`${i}\0${r}`)||E.get(`${r}\0${i}`);n&&(n.chordData=e)}},buildScene(t,e,i,r){var n,o;const{groupWidth:a=20,edgeOpacity:s=.5}=i,c=Math.min(r[0],r[1])/2,l=c-a,u=r[0]/2,h=r[1]/2,f=i.nodeStyle,d=i.edgeStyle,y=i.edgeColorBy||"source",g=Array.isArray(i.colorScheme)?i.colorScheme:Dt,p=new Map;t.forEach((t,e)=>{p.set(t.id,g[e%g.length])});const x=m().radius(l),v=[],k=[],b=[];for(let e=0;t.length>e;e++){const i=t[e],r=i.arcData;if(!r)continue;let o;o=f?f(i).fill||p.get(i.id)||g[e%g.length]:p.get(i.id)||g[e%g.length];const a=f?f(i):{},s={fill:o,stroke:a.stroke||"black",strokeWidth:null!==(n=a.strokeWidth)&&void 0!==n?n:1,opacity:a.opacity};v.push({type:"arc",cx:u,cy:h,innerR:l,outerR:c,startAngle:r.startAngle-Math.PI/2,endAngle:r.endAngle-Math.PI/2,style:s,datum:i,id:i.id,label:i.id})}for(const t of e){const e=t.chordData;if(!e)continue;const i=x(e);if(!i)continue;const r=$t(i,u,h);let n="#999";if(d)n=d(t).fill||n;else{const e="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;"target"===y&&i?n=p.get(i.id)||n:e&&(n=p.get(e.id)||n)}const a=d?d(t):{},c={fill:n,fillOpacity:null!==(o=a.fillOpacity)&&void 0!==o?o:s,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity};k.push({type:"ribbon",pathD:r,style:c,datum:t})}if(!1!==i.showLabels){const e=(w=i.nodeLabel)?"function"==typeof w?w:t=>t[w]||t.id:null,r=c+12;for(const i of t){const t=i.arcData;if(!t)continue;const n=e?e(i):i.id;if(!n)continue;const o=(t.startAngle+t.endAngle)/2,a=o-Math.PI/2;b.push({x:u+Math.cos(a)*r,y:h+Math.sin(a)*r,text:n+"",anchor:o>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var w;return{sceneNodes:v,sceneEdges:k,labels:b}}};function $t(t,e,i){const r=t.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!r)return t;const n=[];let o=0;for(;r.length>o;){const t=r[o];if("M"===t||"L"===t)for(n.push(t),o++;r.length>o&&!isNaN(Number(r[o]));)n.push(Number(r[o])+e+""),o++,r.length>o&&!isNaN(Number(r[o]))&&(n.push(Number(r[o])+i+""),o++);else if("C"===t)for(n.push(t),o++;r.length>o&&!isNaN(Number(r[o]));)for(let t=0;3>t&&r.length>o&&!isNaN(Number(r[o]));t++)n.push(Number(r[o])+e+""),o++,r.length>o&&!isNaN(Number(r[o]))&&(n.push(Number(r[o])+i+""),o++);else if("Q"===t)for(n.push(t),o++;r.length>o&&!isNaN(Number(r[o]));)for(let t=0;2>t&&r.length>o&&!isNaN(Number(r[o]));t++)n.push(Number(r[o])+e+""),o++,r.length>o&&!isNaN(Number(r[o]))&&(n.push(Number(r[o])+i+""),o++);else if("A"===t)for(n.push(t),o++;r.length>o&&!isNaN(Number(r[o]));)n.push(r[o++]),r.length>o&&n.push(r[o++]),r.length>o&&n.push(r[o++]),r.length>o&&n.push(r[o++]),r.length>o&&n.push(r[o++]),r.length>o&&(n.push(Number(r[o])+e+""),o++),r.length>o&&(n.push(Number(r[o])+i+""),o++);else"Z"===t||"z"===t?(n.push(t),o++):(n.push(r[o]),o++)}return n.join(" ")}const Wt={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,i,r){var n;const o=i.__hierarchyRoot;if(!o)return;const a=i.chartType,s=(c=i.childrenAccessor)?"function"==typeof c?c:t=>t[c]:void 0;var c;const l=i.hierarchySum||(t=>{var e;return null!==(e=t.value)&&void 0!==e?e:0}),u=k(o,s);u.sum(l),u.sort((t,e)=>{var i,r;return(null!==(i=e.value)&&void 0!==i?i:0)-(null!==(r=t.value)&&void 0!==r?r:0)});const[h,f]=r;switch(a){case"tree":!function(t,e,i,r){const n=e.treeOrientation||"vertical",o=P();o.size("horizontal"===n?[r,i]:"radial"===n?[2*Math.PI,Math.min(i,r)/2*.8]:[i,r]),o(t)}(u,i,h,f);break;case"cluster":!function(t,e,i,r){const n=e.treeOrientation||"vertical",o=S();o.size("horizontal"===n?[r,i]:"radial"===n?[2*Math.PI,Math.min(i,r)/2*.8]:[i,r]),o(t)}(u,i,h,f);break;case"treemap":!function(t,e,i,r){var n,o;const a=null!==(n=e.padding)&&void 0!==n?n:4,s=null!==(o=e.paddingTop)&&void 0!==o?o:0,c=E().size([i,r]).tile(A).padding(a);s>0&&c.paddingTop(s),c(t)}(u,i,h,f);break;case"circlepack":!function(t,e,i,r){var n;const o=null!==(n=e.padding)&&void 0!==n?n:4;w().size([i,r]).padding(o)(t)}(u,i,h,f);break;case"partition":!function(t,e,i,r){var n;b().size([i,r]).padding(null!==(n=e.padding)&&void 0!==n?n:1)(t)}(u,i,h,f)}const d=u.descendants();t.length=0,e.length=0;const y=new Map;for(let e=0;d.length>e;e++){const r=d[e],o={id:Ot(r,i,e),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(n=r.value)&&void 0!==n?n:0,depth:r.depth,data:r.data,createdByFrame:!0};"tree"===a||"cluster"===a?Nt(o,r,i):"treemap"===a||"partition"===a?Rt(o,r):"circlepack"===a&&Tt(o,r),o.__hierarchyNode=r,t.push(o),y.set(r,o)}if("tree"===a||"cluster"===a)for(const t of d)if(t.parent){const i=y.get(t.parent),r=y.get(t);i&&r&&e.push({source:i,target:r,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,i,r){const n=i.nodeStyle||(()=>({})),o=i.edgeStyle||(()=>({}));switch(i.chartType){case"tree":case"cluster":return function(t,e,i,r,n,o){var a,s,c,l,u;const h=[],f=[],d=[],y=i.treeOrientation||"vertical",g="radial"===y,p=r[0]/2,m=r[1]/2,x="number"==typeof(k=i.nodeSize)?k:5,v=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];var k;for(const e of t){let t=e.x,r=e.y;g&&(t+=p,r+=m);const o=n(e);let s=o.fill||"#4d430c";i.colorByDepth&&void 0!==e.depth&&(s=v[e.depth%v.length]);const c={fill:s,stroke:o.stroke||"#fff",strokeWidth:null!==(a=o.strokeWidth)&&void 0!==a?a:1,opacity:o.opacity};h.push({type:"circle",cx:t,cy:r,r:x,style:c,datum:e,id:e.id,label:e.id,depth:e.depth})}const b=null!==(s=i.edgeOpacity)&&void 0!==s?s:.5;for(const t of e){const e="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;if(!e||!i)continue;let r=e.x,n=e.y,a=i.x,s=i.y;g&&(r+=p,n+=m,a+=p,s+=m);const u=zt(r,n,a,s,y),h=o(t),d={fill:"none",stroke:h.stroke||"#999",strokeWidth:null!==(c=h.strokeWidth)&&void 0!==c?c:1.5,opacity:null!==(l=h.opacity)&&void 0!==l?l:b};f.push({type:"curved",pathD:u,style:d,datum:t})}if(!1!==i.showLabels){const e=Yt(i.nodeLabel);for(const i of t){const t=e?e(i):i.id;if(!t)continue;let r,n,o,a=i.x,s=i.y;if(g&&(a+=p,s+=m),g){const t=a-p,e=s-m,i=Math.sqrt(t*t+e*e);i>0?(r=a+t/i*10,n=s+e/i*10,o=0>t?"end":"start"):(r=a,n=s-12,o="middle")}else"horizontal"===y?((null===(u=i.data)||void 0===u?void 0:u.children)&&0!==i.data.children.length?(r=a-x-6,o="end"):(r=a+x+6,o="start"),n=s):(r=a,n=s+x+14,o="middle");d.push({x:r,y:n,text:t+"",anchor:o,baseline:"middle",fontSize:11})}}return{sceneNodes:h,sceneEdges:f,labels:d}}(t,e,i,r,n,o);case"treemap":case"partition":return function(t,e,i,r){var n,o;const a=[],s=[],c=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const i of t){const t=i.x1-i.x0,o=i.y1-i.y0;if(0>=t||0>=o)continue;const s=r(i);let l=s.fill||"#4d430c";e.colorByDepth&&void 0!==i.depth&&(l=c[i.depth%c.length]);const u={fill:l,stroke:s.stroke||"#fff",strokeWidth:null!==(n=s.strokeWidth)&&void 0!==n?n:1,opacity:s.opacity};a.push({type:"rect",x:i.x0,y:i.y0,w:t,h:o,style:u,datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==e.showLabels){const i=Yt(e.nodeLabel);for(const r of t){const t=r.x1-r.x0,n=r.y1-r.y0;if(0>=t||0>=n)continue;if((null===(o=r.data)||void 0===o?void 0:o.children)&&r.data.children.length>0&&"partition"!==e.chartType)continue;const a=i?i(r):r.id;a&&(30>t||16>n||s.push({x:r.x0+t/2,y:r.y0+n/2,text:a+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,n)/6))}))}}return{sceneNodes:a,sceneEdges:[],labels:s}}(t,i,0,n);case"circlepack":return function(t,e,i,r){var n,o,a,s,c;const l=[],u=[],h=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const i of t){const t=null!==(n=i.__radius)&&void 0!==n?n:5;if(0>=t)continue;const s=r(i);let c=s.fill||"#4d430c";e.colorByDepth&&void 0!==i.depth&&(c=h[i.depth%h.length]);const u={fill:c,stroke:s.stroke||"#fff",strokeWidth:null!==(o=s.strokeWidth)&&void 0!==o?o:1,opacity:null!==(a=s.opacity)&&void 0!==a?a:.7};l.push({type:"circle",cx:i.x,cy:i.y,r:t,style:u,datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==e.showLabels){const i=Yt(e.nodeLabel);for(const e of t){const t=null!==(s=e.__radius)&&void 0!==s?s:5,r=i?i(e):e.id;if(!r)continue;if(15>t)continue;const n=!((null===(c=e.data)||void 0===c?void 0:c.children)&&e.data.children.length>0);u.push({x:e.x,y:n?e.y:e.y-t+14,text:r+"",anchor:"middle",baseline:n?"middle":"hanging",fontSize:Math.min(11,Math.max(8,t/3)),fill:n?void 0:"#000",stroke:n?void 0:"#fff",strokeWidth:n?void 0:3,paintOrder:n?void 0:"stroke"})}}return{sceneNodes:l,sceneEdges:[],labels:u}}(t,i,0,n);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Nt(t,e,i){const r=i.treeOrientation||"vertical";if("radial"===r){const i=e.x,r=e.y;t.x=r*Math.cos(i-Math.PI/2),t.y=r*Math.sin(i-Math.PI/2)}else"horizontal"===r?(t.x=e.y,t.y=e.x):(t.x=e.x,t.y=e.y);t.x0=t.x-5,t.x1=t.x+5,t.y0=t.y-5,t.y1=t.y+5,t.width=10,t.height=10}function Rt(t,e){t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.x=(e.x0+e.x1)/2,t.y=(e.y0+e.y1)/2,t.width=e.x1-e.x0,t.height=e.y1-e.y0}function Tt(t,e){var i;const r=null!==(i=e.r)&&void 0!==i?i:0;t.x=e.x,t.y=e.y,t.x0=e.x-r,t.x1=e.x+r,t.y0=e.y-r,t.y1=e.y+r,t.width=2*r,t.height=2*r,t.__radius=r}function zt(t,e,i,r,n){if("horizontal"===n){const n=(t+i)/2;return`M ${t},${e} C ${n},${e} ${n},${r} ${i},${r}`}if("radial"===n){const n=(t+i)/2;return`M ${t},${e} Q ${n},${e} ${n},${(e+r)/2} T ${i},${r}`}{const n=(e+r)/2;return`M ${t},${e} C ${t},${n} ${i},${n} ${i},${r}`}}function Ot(t,e,i){const r=e.nodeIDAccessor;return"function"==typeof r?r(t.data)+"":"string"==typeof r&&void 0!==t.data[r]?t.data[r]+"":void 0!==t.data.name?t.data.name+"":void 0!==t.data.id?t.data.id+"":"node-"+i}function Yt(t){return t?"function"==typeof t?t:e=>{var i;return(null===(i=e.data)||void 0===i?void 0:i[t])||e[t]||e.id}:null}const Bt={sankey:Pt,force:Lt,chord:_t,tree:Wt,cluster:Wt,treemap:Wt,circlepack:Wt,partition:Wt};function Xt(t,e){const{columns:i,config:r,resolvePieceStyle:n}=t,o=[],a=Math.min(e.width,e.height)/2-4,s="donut"===r.chartType?r.innerRadius||60:0,c=-Math.PI/2+(r.startAngle||0)*Math.PI/180,l=2*Math.PI;for(const t of Object.values(i)){const e=c+t.pctStart*l,i=c+(t.pctStart+t.pct)*l,r=n(t.pieceData[0],t.name);o.push({type:"wedge",cx:0,cy:0,innerRadius:s,outerRadius:a,startAngle:e,endAngle:i,style:r,datum:t.pieceData,category:t.name})}return o}function Ct(t){var e,i,r;const n=t.length,o=t[0],a=t[n-1];return{n:n,min:o,q1:null!==(e=l(t,.25))&&void 0!==e?e:o,median:null!==(i=l(t,.5))&&void 0!==i?i:(o+a)/2,q3:null!==(r=l(t,.75))&&void 0!==r?r:a,max:a,mean:t.reduce((t,e)=>t+e,0)/n}}const It={bar:function(t,e){const{scales:i,columns:r,config:n,getR:o,getStack:a,resolvePieceStyle:s}=t,{r:c,projection:l}=i,u=[],h="vertical"===l,f="horizontal"===l,d=n.normalize;for(const t of Object.values(r)){const e=new Map;for(const i of t.pieceData){const t=a?a(i):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const r=e.get(t);r.total+=o(i),r.pieces.push(i)}let i=0;if(d)for(const t of e.values())i+=Math.abs(t.total);let r=0,n=0;for(const[o,l]of e){let e=l.total;d&&i>0&&(e/=i);const y=s(l.pieces[0],a?o:t.name),g=Object.assign(Object.assign({},l.pieces[0]),{__aggregateValue:l.total,__pieceCount:l.pieces.length,category:t.name});if(h){const i=c(0>e?n:r+e),a=0>e?c(n+e)-c(n):c(r)-c(r+e);u.push(N(t.x,i,t.width,Math.abs(a),y,g,o)),0>e?n+=e:r+=e}else if(f){const i=c(0>e?n+e:r),a=0>e?c(n)-c(n+e):c(r+e)-c(r);u.push(N(i,t.x,Math.abs(a),t.width,y,g,o)),0>e?n+=e:r+=e}}}return u},clusterbar:function(t,e){const{scales:i,columns:r,getR:n,getGroup:o,resolvePieceStyle:a}=t,{r:s,projection:c}=i,l=[],u="vertical"===c,h=[],f=new Set;for(const t of Object.values(r))for(const e of t.pieceData){const t=o?o(e):"_default";f.has(t)||(f.add(t),h.push(t))}const d=h.length||1;for(const t of Object.values(r)){const e=t.width/d,i=new Map;for(const e of t.pieceData){const t=o?o(e):"_default";i.has(t)||i.set(t,[]),i.get(t).push(e)}for(let r=0;h.length>r;r++){const o=i.get(h[r])||[];for(const i of o){const o=n(i),c=a(i,t.name);if(u){const n=t.x+r*e,a=s(0),u=s(o);l.push(N(n,Math.min(a,u),e,Math.abs(a-u),c,i,h[r]))}else{const n=t.x+r*e,a=s(0),u=s(o);l.push(N(Math.min(a,u),n,Math.abs(u-a),e,c,i,h[r]))}}}}return l},point:function(t,e){var i,r;const{scales:n,columns:o,getR:a,multiScales:s,resolvePieceStyle:c}=t,{r:l,projection:u}=n,h=[],f="vertical"===u,d="radial"===u,y=s.length>0,g=2*Math.PI,p=-Math.PI/2;for(const t of Object.values(o))for(const e of t.pieceData){const n=null!==(i=e.__rIndex)&&void 0!==i?i:0,o=null!==(r=e.__rValue)&&void 0!==r?r:a(e),u=y&&s[n]||l,m=c(e,t.name),x=m.r||5;let v,k;if(d){const e=p+(t.pctStart+t.pct/2)*g,i=u(o);v=Math.cos(e)*i,k=Math.sin(e)*i}else f?(v=t.middle,k=u(o)):(v=u(o),k=t.middle);h.push({type:"point",x:v,y:k,r:x,style:m,datum:e})}return h},swarm:function(t,e){const{scales:i,columns:r,getR:n,resolvePieceStyle:o}=t,{r:a,projection:s}=i,c=[],l="vertical"===s;for(const t of Object.values(r)){const e=t.width/2;for(let i=0;t.pieceData.length>i;i++){const r=t.pieceData[i],s=n(r),u=o(r,t.name),h=u.r||4,f=(7919*i%100/100-.5)*e*.8,d=l?t.middle+f:a(s),y=l?a(s):t.middle+f;c.push({type:"point",x:d,y:y,r:h,style:u,datum:r})}}return c},pie:Xt,donut:Xt,boxplot:function(t,e){var i,r,n,o,a;const{scales:s,columns:c,config:u,getR:h,resolveSummaryStyle:f}=t,{r:d,projection:y}=s,g=[],p="vertical"===y,m=!1!==u.showOutliers;for(const t of Object.values(c)){const e=t.pieceData.map(t=>h(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(0===e.length)continue;const s=e[0],c=e[e.length-1],u=null!==(i=l(e,.25))&&void 0!==i?i:s,y=null!==(r=l(e,.5))&&void 0!==r?r:(s+c)/2,x=null!==(n=l(e,.75))&&void 0!==n?n:c,v=x-u,k=u-1.5*v,b=x+1.5*v,w=null!==(o=e.find(t=>t>=k))&&void 0!==o?o:s,E=null!==(a=[...e].reverse().find(t=>b>=t))&&void 0!==a?a:c,A=f(t.pieceData[0],t.name),S=[];if(m)for(const e of t.pieceData){const i=h(e);if(k>i||i>b){const r=p?t.middle:d(i),n=p?d(i):t.middle;S.push({px:r,py:n,value:i,datum:e})}}if(g.push({type:"boxplot",x:p?t.middle:0,y:p?0:t.middle,projection:p?"vertical":"horizontal",columnWidth:.6*t.width,minPos:d(w),q1Pos:d(u),medianPos:d(y),q3Pos:d(x),maxPos:d(E),stats:{n:e.length,min:w,q1:u,median:y,q3:x,max:E,mean:e.reduce((t,e)=>t+e,0)/e.length},style:A,datum:t.pieceData,category:t.name,outliers:S}),m)for(const t of S)g.push({type:"point",x:t.px,y:t.py,r:3,style:{fill:A.fill||"#999",opacity:.6},datum:t.datum})}return g},violin:function(t,e){var i,r,n;const{scales:o,columns:a,config:s,getR:c,resolveSummaryStyle:u}=t,{r:h,projection:f}=o,d=[],y="vertical"===f,g=s.bins||20,p=!1!==s.showIQR;for(const t of Object.values(a)){const e=t.pieceData.map(t=>c(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const o=e[0],a=e[e.length-1],s=(a-o)/g||1,f=Array(g).fill(0);for(const t of e)f[Math.min(Math.floor((t-o)/s),g-1)]++;const m=Math.max(...f,1),x=t.width/2*.9;let v="";if(y){for(let e=0;g>e;e++){const i=h(o+(e+.5)*s),r=f[e]/m*x;v+=0===e?`M ${t.middle+r} ${i}`:` L ${t.middle+r} ${i}`}for(let e=g-1;e>=0;e--){const i=h(o+(e+.5)*s);v+=` L ${t.middle-f[e]/m*x} ${i}`}v+=" Z"}else{for(let e=0;g>e;e++){const i=h(o+(e+.5)*s),r=f[e]/m*x;v+=0===e?`M ${i} ${t.middle-r}`:` L ${i} ${t.middle-r}`}for(let e=g-1;e>=0;e--)v+=` L ${h(o+(e+.5)*s)} ${t.middle+f[e]/m*x}`;v+=" Z"}const k=u(t.pieceData[0],t.name);let b;if(p&&e.length>=4){const s=null!==(i=l(e,.25))&&void 0!==i?i:o,c=null!==(r=l(e,.5))&&void 0!==r?r:(o+a)/2,u=null!==(n=l(e,.75))&&void 0!==n?n:a;b={q1Pos:h(s),medianPos:h(c),q3Pos:h(u),centerPos:t.middle,isVertical:y}}const w=y?{x:t.x,y:Math.min(h(a),h(o)),width:t.width,height:Math.abs(h(a)-h(o))}:{x:Math.min(h(o),h(a)),y:t.x,width:Math.abs(h(a)-h(o)),height:t.width};d.push({type:"violin",pathString:v,translateX:0,translateY:0,bounds:w,iqrLine:b,stats:Ct(e),style:k,datum:t.pieceData,category:t.name})}return d},histogram:function(t,e){const{scales:i,columns:r,config:n,getR:o,resolveSummaryStyle:a}=t,{r:s}=i,c=[],l=n.bins||25,u=n.normalize;for(const t of Object.values(r)){const e=t.pieceData.map(t=>o(t)).filter(t=>null!=t&&!isNaN(t));if(0===e.length)continue;const i=Math.min(...e),r=(Math.max(...e)-i)/l||1,n=Array(l).fill(0);for(const t of e)n[Math.min(Math.floor((t-i)/r),l-1)]++;const h=e.length,f=Math.max(...n,1),d=a(t.pieceData[0],t.name);for(let e=0;l>e;e++){if(0===n[e])continue;const o=(u?n[e]/h:n[e]/f)*t.width*.9,a=s(i+e*r),l=s(i+(e+1)*r);c.push(N(Math.min(a,l),t.x+t.width-o,Math.abs(l-a),o,d,{bin:e,count:n[e],range:[i+e*r,i+(e+1)*r],category:t.name},t.name))}}return c},ridgeline:function(t,e){var i;const{scales:r,columns:n,config:o,getR:a,resolveSummaryStyle:s}=t,{r:c,projection:l}=r,u=[],h=o.bins||20,f="horizontal"===l,d=o.amplitude||1.5;for(const t of Object.values(n)){const e=t.pieceData.map(t=>a(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const r=e[0],n=e[e.length-1],o=(n-r)/h||1,l=Array(h).fill(0);for(const t of e)l[Math.min(Math.floor((t-r)/o),h-1)]++;const y=Math.max(...l,1),g=s(t.pieceData[0],t.name),p=t.width*d;let m="";if(f){const e=t.x+t.width;m=`M ${c(r)} ${e}`;for(let t=0;h>t;t++)m+=` L ${c(r+(t+.5)*o)} ${e-l[t]/y*p}`;m+=` L ${c(n)} ${e} Z`}else{const e=t.x;m=`M ${e} ${c(r)}`;for(let t=0;h>t;t++){const i=c(r+(t+.5)*o);m+=` L ${e+l[t]/y*p} ${i}`}m+=` L ${e} ${c(n)} Z`}const x=f?{x:Math.min(c(r),c(n)),y:t.x,width:Math.abs(c(n)-c(r)),height:t.width}:{x:t.x,y:Math.min(c(n),c(r)),width:t.width,height:Math.abs(c(n)-c(r))};u.push({type:"violin",pathString:m,translateX:0,translateY:0,bounds:x,stats:Ct(e),style:Object.assign(Object.assign({},g),{fillOpacity:null!==(i=g.fillOpacity)&&void 0!==i?i:.5}),datum:t.pieceData,category:t.name})}return u},timeline:function(t,e){const{scales:i,columns:r,getRawRange:n,resolvePieceStyle:o}=t,{r:a,projection:s}=i,c=[],l="horizontal"===s;for(const t of Object.values(r))for(const e of t.pieceData){const i=n(e);if(!i)continue;const[r,s]=i,u=o(e,t.name);if(l){const i=a(Math.min(r,s)),n=a(Math.max(r,s));c.push(N(i,t.x,n-i,t.width,u,e,t.name))}else{const i=a(Math.max(r,s)),n=a(Math.min(r,s));c.push(N(t.x,i,t.width,n-i,u,e,t.name))}}return c}};class jt{constructor(t){this.rExtent=new M,this.rExtents=[],this.rAccessors=[],this.categories=new Set,this._colorSchemeMap=null,this._colorSchemeIndex=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.lastIngestTime=0,this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.version=0,this.config=t,this.buffer=new L(t.windowSize),this.getO=z(t.oAccessor||t.categoryAccessor,"category");const e="streaming"===t.runtimeMode,i=t.rAccessor;Array.isArray(i)?(this.rAccessors=i.map(t=>T(t,"value")),this.getR=this.rAccessors[0],this.rExtents=i.map(()=>new M)):(this.getR=T(e&&(t.timeAccessor||t.valueAccessor)&&t.valueAccessor||i,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=z(t.stackBy),this.getGroup=z(t.groupBy),this.getColor=z(t.colorAccessor),this.getConnector=z(t.connectorAccessor),t.pulse&&(this.timestampBuffer=new L(t.windowSize))}ingest(t){const e="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=e,t.bounded){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const i=t.totalSize||t.inserts.length;i>this.buffer.capacity&&(this.buffer.resize(i),this.timestampBuffer&&i>this.timestampBuffer.capacity&&this.timestampBuffer.resize(i));for(const i of t.inserts)this.buffer.push(i),this.timestampBuffer&&this.timestampBuffer.push(e),this.categories.add(this.getO(i)),this.pushValueExtent(i)}else for(const i of t.inserts){const t=this.buffer.push(i);this.timestampBuffer&&this.timestampBuffer.push(e),this.categories.add(this.getO(i)),this.pushValueExtent(i),null!=t&&this.evictValueExtent(t)}return!0}pushValueExtent(t){if("timeline"===this.config.chartType){const e=this.getRawRange(t);e&&(this.rExtent.push(e[0]),this.rExtent.push(e[1]))}else if(this.rAccessors.length>1){for(let e=0;this.rAccessors.length>e;e++)this.rExtents[e].push(this.rAccessors[e](t));this.rExtent.push(this.getR(t))}else this.rExtent.push(this.getR(t))}evictValueExtent(t){if("timeline"===this.config.chartType){const e=this.getRawRange(t);e&&(this.rExtent.evict(e[0]),this.rExtent.evict(e[1]))}else if(this.rAccessors.length>1){for(let e=0;this.rAccessors.length>e;e++)this.rExtents[e].evict(this.rAccessors[e](t));this.rExtent.evict(this.getR(t))}else this.rExtent.evict(this.getR(t))}getRawRange(t){const e=this.config.rAccessor;if(!e)return null;const i="function"==typeof e?e(t):t[e];return Array.isArray(i)&&i.length>=2?[+i[0],+i[1]]:null}computeScene(t){const{config:r,buffer:n}=this;if(0===n.size)return this.scales=null,this.scene=[],this.columns={},void this.version++;this.rExtent.dirty&&this.rExtent.recalculate(n,this.getR);const o=n.toArray(),a=r.projection||"vertical",s=r.oExtent||this.resolveCategories(o),c=this.computeValueDomain(o,s),l="horizontal"===a,u=null!=r.barPadding?r.barPadding/("vertical"===a?t.width:t.height):.1;let h,f;if("radial"===a){h=i().domain(s).range([0,1]).padding(0);const n=Math.min(t.width,t.height)/2,o=r.innerRadius||0;f=e().domain(c).range([o,n])}else l?(h=i().domain(s).range([0,t.height]).padding(u),f=e().domain(c).range([0,t.width])):(h=i().domain(s).range([0,t.width]).padding(u),f=e().domain(c).range([t.height,0]));this.scales={o:h,r:f,projection:a},this.multiScales=this.rAccessors.length>1&&r.multiAxis?this.rAccessors.map((i,o)=>{const a=this.rExtents[o];a.dirty&&a.recalculate(n,i);let[s,c]=a.extent;s===1/0&&(s=0,c=1);const u=c-s,h=u>0?u*(r.extentPadding||.05):1;return s-=h,c+=h,s>0&&(s=0),l?e().domain([s,c]).range([0,t.width]):e().domain([s,c]).range([t.height,0])}):[];let d=o;this.rAccessors.length>1&&(d=o.flatMap(t=>this.rAccessors.map((e,i)=>Object.assign(Object.assign({},t),{__rIndex:i,__rValue:e(t),__rName:this.resolveRAccessorName(i)})))),this.columns=this.buildColumns(d,s,h,a,t),this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(d,t),this.config.decay&&this.applyDecay(this.scene,o),this.config.pulse&&this.applyPulse(this.scene,o),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++}resolveRAccessorName(t){const e=Array.isArray(this.config.rAccessor)?this.config.rAccessor[t]:this.config.rAccessor;return"string"==typeof e?e:"value"+t}resolveCategories(t){const e=Array.from(this.categories),i=this.config.oSort;if("streaming"===this.config.runtimeMode&&void 0===i)return e;if(!1===i)return e;if("function"==typeof i)return e.sort(i);const r=new Map;for(const e of t){const t=this.getO(e);r.set(t,(r.get(t)||0)+Math.abs(this.getR(e)))}return e.sort("asc"===i?(t,e)=>(r.get(t)||0)-(r.get(e)||0):(t,e)=>(r.get(e)||0)-(r.get(t)||0))}computeValueDomain(t,e){var i,r;const n=this.config.chartType,o=this.config.extentPadding||.05;if("radial"===this.config.projection&&("pie"===n||"donut"===n))return[0,1];let a=0,s=0;if("bar"===n&&this.getStack){const e=new Map,i=new Map;for(const r of t){const t=this.getO(r),n=this.getR(r);0>n?i.set(t,(i.get(t)||0)+n):e.set(t,(e.get(t)||0)+n)}for(const t of e.values())t>s&&(s=t);for(const t of i.values())a>t&&(a=t)}else if("bar"===n){const e=new Map;for(const i of t){const t=this.getO(i),r=this.getR(i);e.set(t,(e.get(t)||0)+r)}for(const t of e.values())t>s&&(s=t),a>t&&(a=t)}else if("clusterbar"===n)for(const e of t){const t=this.getR(e);t>s&&(s=t),a>t&&(a=t)}else{const t=this.rExtent.extent[0],e=this.rExtent.extent[1];t!==1/0&&(a=t),e!==-1/0&&(s=e)}this.config.rExtent&&(null!=this.config.rExtent[0]&&(a=this.config.rExtent[0]),null!=this.config.rExtent[1]&&(s=this.config.rExtent[1]));const c=s-a,l=c>0?c*o:1;return(null===(i=this.config.rExtent)||void 0===i?void 0:i[0])||(a-=l),(null===(r=this.config.rExtent)||void 0===r?void 0:r[1])||(s+=l),"bar"!==n&&"clusterbar"!==n||(a>0&&(a=0),0>s&&(s=0)),[a,s]}buildColumns(t,e,i,r,n){var o;const a={},s=new Map;for(const e of t){const t=this.getO(e);s.has(t)||s.set(t,[]),s.get(t).push(e)}let c=0;if("radial"===r)for(const e of t)c+=Math.abs(this.getR(e));const l=this.config.dynamicColumnWidth;let u=null;if(l&&"radial"!==r){u=new Map;let t=0;for(const i of e){const e=s.get(i)||[];let r;r="string"==typeof l?e.reduce((t,e)=>t+(Number(e[l])||0),0):l(e),u.set(i,r),t+=r}const o=("horizontal"===r?n.height:n.width)-i.padding()*i.step()*e.length;if(t>0)for(const[e,i]of u)u.set(e,i/t*o)}let h=0,f=0;for(const t of e){const e=s.get(t)||[],r=e.reduce((t,e)=>t+Math.abs(this.getR(e)),0),n=c>0?r/c:0;let l,d;u?(l=f,d=u.get(t)||i.bandwidth(),f+=d+i.padding()*i.step()):(l=null!==(o=i(t))&&void 0!==o?o:0,d=i.bandwidth()),a[t]={name:t,x:l,y:0,width:d,middle:l+d/2,padding:i.padding()*i.step(),pieceData:e,pct:n,pctStart:h},h+=n}return a}getSceneContext(){return{scales:this.scales,columns:this.columns,config:this.config,getR:this.getR,getStack:this.getStack,getGroup:this.getGroup,getColor:this.getColor,getConnector:this.getConnector,getO:this.getO,multiScales:this.multiScales,rAccessors:this.rAccessors,resolvePieceStyle:(t,e)=>this.resolvePieceStyle(t,e),resolveSummaryStyle:(t,e)=>this.resolveSummaryStyle(t,e),getRawRange:t=>this.getRawRange(t)}}buildSceneNodes(t,e){if(!this.scales)return[];const i=this.getSceneContext(),r=It[this.config.chartType];let n=r?r(i,e):[];if(this.getConnector&&this.scales){const t=function(t,e){const{scales:i,config:r,getConnector:n,getO:o}=t;if(!n||!i)return[];const a=[],{projection:s}=i,c=new Map;for(const t of e){if("point"!==t.type&&"rect"!==t.type)continue;const e=t.datum;if(!e)continue;const i=n(e);if(!i)continue;let r,a;"point"===t.type?(r=t.x,a=t.y):(r=t.x+t.w/2,a=t.y+("vertical"===s?0:t.h/2)),c.has(i)||c.set(i,[]),c.get(i).push({x:r,y:a,datum:e,category:o(e)})}const l=i.o.domain(),u=r.connectorStyle;for(const[t,e]of c)if(e.length>=2){e.sort((t,e)=>l.indexOf(t.category)-l.indexOf(e.category));for(let i=0;e.length-1>i;i++){const r=e[i],n=e[i+1],o="function"==typeof u?u(r.datum):u||{stroke:"#999",strokeWidth:1,opacity:.5};a.push({type:"connector",x1:r.x,y1:r.y,x2:n.x,y2:n.y,style:o,datum:r.datum,group:t})}}return a}(i,n);n=[...t,...n]}return n}resolvePieceStyle(t,e){return"function"==typeof this.config.pieceStyle?this.config.pieceStyle(t,e):this.config.pieceStyle&&"object"==typeof this.config.pieceStyle?this.config.pieceStyle:this.config.barColors&&e?{fill:this.config.barColors[e]||"#007bff"}:e?{fill:this.getColorFromScheme(e)}:{fill:"#007bff"}}getColorFromScheme(t){this._colorSchemeMap||(this._colorSchemeMap=new Map);const e=this._colorSchemeMap.get(t);if(e)return e;const i=Array.isArray(this.config.colorScheme)?this.config.colorScheme:["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],r=i[this._colorSchemeIndex%i.length];return this._colorSchemeIndex++,this._colorSchemeMap.set(t,r),r}resolveSummaryStyle(t,e){return"function"==typeof this.config.summaryStyle?this.config.summaryStyle(t,e):this.config.summaryStyle&&"object"==typeof this.config.summaryStyle?this.config.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}computeDecayOpacity(t,e){var i,r,n;const o=this.config.decay;if(!o||1>=e)return 1;const a=null!==(i=o.minOpacity)&&void 0!==i?i:.1,s=e-1-t;switch(o.type){case"linear":return a+(1-s/(e-1))*(1-a);case"exponential":{const t=null!==(r=o.halfLife)&&void 0!==r?r:e/2;return a+Math.pow(.5,s/t)*(1-a)}case"step":return(null!==(n=o.stepThreshold)&&void 0!==n?n:.5*e)>s?1:a;default:return 1}}applyDecay(t,e){var i,r;if(!this.config.decay)return;const n=e.length;if(1>=n)return;const o=new Map;for(let t=0;e.length>t;t++)o.set(e[t],t);for(const e of t){if("connector"===e.type||"violin"===e.type||"boxplot"===e.type||"wedge"===e.type)continue;const t=o.get(e.datum);if(null==t)continue;const a=this.computeDecayOpacity(t,n),s=null!==(r=null===(i=e.style)||void 0===i?void 0:i.opacity)&&void 0!==r?r:1;e.style=Object.assign(Object.assign({},e.style),{opacity:s*a})}}applyPulse(t,e){var i,r,n;if(!this.config.pulse||!this.timestampBuffer)return;const o="undefined"!=typeof performance?performance.now():Date.now(),a=null!==(i=this.config.pulse.duration)&&void 0!==i?i:500,s=null!==(r=this.config.pulse.color)&&void 0!==r?r:"rgba(255,255,255,0.6)",c=null!==(n=this.config.pulse.glowRadius)&&void 0!==n?n:4,l=new Map;for(let t=0;e.length>t;t++)l.set(e[t],t);for(const i of t){if("connector"===i.type||"violin"===i.type||"boxplot"===i.type)continue;if("wedge"===i.type){const t=i.category;if(!t)continue;let r=0;for(let i=0;e.length>i;i++){const n=e[i],s=this.config.oAccessor;if(("function"==typeof s?s(n):n[s||"category"])!==t)continue;const c=this.timestampBuffer.get(i);if(null==c)continue;const l=o-c;if(a>l){const t=1-l/a;t>r&&(r=t)}}r>0&&(i._pulseIntensity=r,i._pulseColor=s);continue}const t=l.get(i.datum);if(null==t)continue;const r=this.timestampBuffer.get(t);if(null==r)continue;const n=o-r;a>n&&(i._pulseIntensity=1-n/a,i._pulseColor=s,i._pulseGlowRadius=c)}}get hasActivePulses(){var t;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const e="undefined"!=typeof performance?performance.now():Date.now(),i=null!==(t=this.config.pulse.duration)&&void 0!==t?t:500,r=this.timestampBuffer.peek();return null!=r&&i>e-r}snapshotPositions(){var t,e;this.prevPositionMap.clear();for(let i=0;this.scene.length>i;i++){const r=this.scene[i];if("point"===r.type)this.prevPositionMap.set("p:"+i,{x:r.x,y:r.y,r:r.r});else if("rect"===r.type){const n=`r:${r.group||""}:${null!==(e=null===(t=r.datum)||void 0===t?void 0:t.category)&&void 0!==e?e:i}`;this.prevPositionMap.set(n,{x:r.x,y:r.y,w:r.w,h:r.h})}}}startTransition(){var t,e,i,r,n;if(!this.config.transition||0===this.prevPositionMap.size)return;const o=null!==(t=this.config.transition.duration)&&void 0!==t?t:300;let a=!1;for(let t=0;this.scene.length>t;t++){const o=this.scene[t];let s=null;if("point"===o.type?s="p:"+t:"rect"===o.type&&(s=`r:${o.group||""}:${null!==(i=null===(e=o.datum)||void 0===e?void 0:e.category)&&void 0!==i?i:t}`),!s)continue;const c=this.prevPositionMap.get(s);c&&("point"===o.type?c.x===o.x&&c.y===o.y||(o._targetX=o.x,o._targetY=o.y,o.x=c.x,o.y=c.y,a=!0):"rect"===o.type&&(c.x===o.x&&c.y===o.y&&c.w===o.w&&c.h===o.h||(o._targetX=o.x,o._targetY=o.y,o._targetW=o.w,o._targetH=o.h,o.x=c.x,o.y=c.y,o.w=null!==(r=c.w)&&void 0!==r?r:o.w,o.h=null!==(n=c.h)&&void 0!==n?n:o.h,a=!0)))}a&&(this.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:o})}advanceTransition(t){var e,i,r;if(!this.activeTransition)return!1;const n=Math.min((t-this.activeTransition.startTime)/this.activeTransition.duration,1),o="linear"===(null===(e=this.config.transition)||void 0===e?void 0:e.easing)?n:1-Math.pow(1-n,3);for(let t=0;this.scene.length>t;t++){const e=this.scene[t];if("point"===e.type){if(void 0===e._targetX)continue;const i=this.prevPositionMap.get("p:"+t);if(!i)continue;e.x=i.x+(e._targetX-i.x)*o,e.y=i.y+(e._targetY-i.y)*o}else if("rect"===e.type){if(void 0===e._targetX)continue;const n=`r:${e.group||""}:${null!==(r=null===(i=e.datum)||void 0===i?void 0:i.category)&&void 0!==r?r:t}`,a=this.prevPositionMap.get(n);if(!a)continue;e.x=a.x+(e._targetX-a.x)*o,e.y=a.y+(e._targetY-a.y)*o,void 0!==a.w&&(e.w=a.w+(e._targetW-a.w)*o,e.h=a.h+(e._targetH-a.h)*o)}}if(n>=1){for(const t of this.scene)if("point"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t._targetX=void 0,t._targetY=void 0}else if("rect"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}return this.activeTransition=null,!1}return!0}getData(){return this.buffer.toArray()}clear(){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],this.columns={},this.version++}get size(){return this.buffer.size}getOAccessor(){return this.getO}getRAccessor(){return this.getR}updateConfig(t){t.colorScheme!==this.config.colorScheme&&(this._colorSchemeMap=null,this._colorSchemeIndex=0),Object.assign(this.config,t)}}const Ft=require("react-dom/server");function qt(t){return Math.round(100*t)/100+""}function Ht(e){var i,r,n,o;const a=e.size||[500,300],s=Object.assign(Object.assign({},{top:20,right:20,bottom:30,left:40}),e.margin),c=a[0]-s.left-s.right,l=a[1]-s.top-s.bottom,u="streaming"===e.runtimeMode||["bar","swarm","waterfall"].includes(e.chartType),h={chartType:e.chartType,windowSize:null!==(i=e.windowSize)&&void 0!==i?i:200,windowMode:null!==(r=e.windowMode)&&void 0!==r?r:"sliding",arrowOfTime:u&&null!==(n=e.arrowOfTime)&&void 0!==n?n:"right",extentPadding:null!==(o=e.extentPadding)&&void 0!==o?o:.1,xAccessor:u?void 0:e.xAccessor,yAccessor:u?void 0:e.yAccessor,timeAccessor:u?e.timeAccessor:void 0,valueAccessor:e.valueAccessor,colorAccessor:e.colorAccessor,sizeAccessor:e.sizeAccessor,groupAccessor:e.groupAccessor,categoryAccessor:e.categoryAccessor,lineDataAccessor:e.lineDataAccessor,xExtent:e.xExtent,yExtent:e.yExtent,sizeRange:e.sizeRange,binSize:e.binSize,normalize:e.normalize,boundsAccessor:e.boundsAccessor,boundsStyle:e.boundsStyle,openAccessor:e.openAccessor,highAccessor:e.highAccessor,lowAccessor:e.lowAccessor,closeAccessor:e.closeAccessor,candlestickStyle:e.candlestickStyle,lineStyle:e.lineStyle,pointStyle:e.pointStyle,areaStyle:e.areaStyle,colorScheme:e.colorScheme,barColors:e.barColors},f=new O(h);if(e.data&&f.ingest({inserts:e.data,bounded:!0}),f.computeScene({width:c,height:l}),!f.scales||0===f.scene.length)return Ft.renderToStaticMarkup(t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"stream-xy-frame",width:a[0],height:a[1]}));const d=f.scene.map((e,i)=>function(e,i){var r,n,o;switch(e.type){case"line":{const r=e;if(0===r.path.length)return null;const n="M"+r.path.map(([t,e])=>`${t},${e}`).join("L");return t.createElement("path",{key:"line-"+i,d:n,fill:"none",stroke:r.style.stroke||"#4e79a7",strokeWidth:r.style.strokeWidth||2,strokeDasharray:r.style.strokeDasharray,opacity:r.style.opacity})}case"area":{const o=e;if(0===o.topPath.length)return null;const a=o.topPath.map(([t,e])=>`${t},${e}`).join("L"),s=[...o.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L");return t.createElement("path",{key:"area-"+i,d:`M${a}L${s}Z`,fill:o.style.fill||"#4e79a7",fillOpacity:null!==(n=null!==(r=o.style.fillOpacity)&&void 0!==r?r:o.style.opacity)&&void 0!==n?n:.7,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})}case"point":return t.createElement("circle",{key:"point-"+i,cx:e.x,cy:e.y,r:e.r,fill:e.style.fill||"#4e79a7",opacity:null!==(o=e.style.opacity)&&void 0!==o?o:.8,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth});case"rect":return t.createElement("rect",{key:"rect-"+i,x:e.x,y:e.y,width:e.w,height:e.h,fill:e.style.fill||"#4e79a7",opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth});case"heatcell":return t.createElement("rect",{key:"heatcell-"+i,x:e.x,y:e.y,width:e.w,height:e.h,fill:e.fill});case"candlestick":{const r=e,n=Math.min(r.openY,r.closeY),o=Math.max(Math.abs(r.openY-r.closeY),1),a=r.isUp?r.upColor:r.downColor;return t.createElement("g",{key:"candle-"+i},t.createElement("line",{x1:r.x,y1:r.highY,x2:r.x,y2:r.lowY,stroke:r.wickColor,strokeWidth:r.wickWidth}),t.createElement("rect",{x:r.x-r.bodyWidth/2,y:n,width:r.bodyWidth,height:o,fill:a,stroke:a,strokeWidth:1}))}default:return null}}(e,i)).filter(Boolean),y=!1!==e.showAxes?function(e,i,r){var n,o,a,s;const c=e.x.ticks(5).map(t=>({pixel:e.x(t),label:(r.xFormat||r.tickFormatTime||qt)(t)})),l=e.y.ticks(5).map(t=>({pixel:e.y(t),label:(r.yFormat||r.tickFormatValue||qt)(t)}));return t.createElement("g",{className:"stream-axes"},t.createElement("line",{x1:0,y1:i.height,x2:i.width,y2:i.height,stroke:"#ccc",strokeWidth:1}),c.map((e,r)=>t.createElement("g",{key:"xtick-"+r,transform:`translate(${e.pixel},${i.height})`},t.createElement("line",{y2:5,stroke:"#ccc",strokeWidth:1}),t.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:"#666"},e.label))),r.xLabel&&t.createElement("text",{x:i.width/2,y:i.height+40,textAnchor:"middle",fontSize:12,fill:"#333"},r.xLabel),t.createElement("line",{x1:0,y1:0,x2:0,y2:i.height,stroke:"#ccc",strokeWidth:1}),l.map((e,i)=>t.createElement("g",{key:"ytick-"+i,transform:`translate(0,${e.pixel})`},t.createElement("line",{x2:-5,stroke:"#ccc",strokeWidth:1}),t.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"#666"},e.label))),r.yLabel&&t.createElement("text",{x:15-(null!==(o=null===(n=r.margin)||void 0===n?void 0:n.left)&&void 0!==o?o:40),y:i.height/2,textAnchor:"middle",fontSize:12,fill:"#333",transform:`rotate(-90, ${15-(null!==(s=null===(a=r.margin)||void 0===a?void 0:a.left)&&void 0!==s?s:40)}, ${i.height/2})`},r.yLabel))}(f.scales,{width:c,height:l},e):null,g=e.title&&"string"==typeof e.title?t.createElement("text",{x:a[0]/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"#333"},e.title):null,p=e.background?t.createElement("rect",{x:0,y:0,width:c,height:l,fill:e.background}):null,m=t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"stream-xy-frame"+(e.className?" "+e.className:""),width:a[0],height:a[1]},t.createElement("g",{transform:`translate(${s.left},${s.top})`},p,d,y),g);return Ft.renderToStaticMarkup(m)}function Gt(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}const Vt=new Set(["tree","cluster","treemap","circlepack","partition"]);function Zt(e){const i=e.chartType||"force",r=e.size||[500,500],n=Object.assign(Object.assign({},{top:20,right:20,bottom:20,left:20}),e.margin),o=r[0]-n.left-n.right,a=r[1]-n.top-n.bottom,s=function(t){return Bt[t]}(i);if(!s)throw Error(`No layout plugin found for chart type: "${i}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition.`);const c={chartType:i,nodeIDAccessor:e.nodeIDAccessor,sourceAccessor:e.sourceAccessor,targetAccessor:e.targetAccessor,valueAccessor:e.valueAccessor,childrenAccessor:e.childrenAccessor,hierarchySum:e.hierarchySum,orientation:e.orientation,nodeAlign:e.nodeAlign,nodePaddingRatio:e.nodePaddingRatio,nodeWidth:e.nodeWidth,iterations:e.iterations,forceStrength:e.forceStrength,padAngle:e.padAngle,groupWidth:e.groupWidth,sortGroups:e.sortGroups,edgeSort:e.edgeSort,treeOrientation:e.treeOrientation,edgeType:e.edgeType,padding:e.padding,paddingTop:e.paddingTop,nodeStyle:e.nodeStyle,edgeStyle:e.edgeStyle,nodeLabel:e.nodeLabel,showLabels:e.showLabels,colorBy:e.colorBy,colorScheme:e.colorScheme,edgeColorBy:e.edgeColorBy,edgeOpacity:e.edgeOpacity,colorByDepth:e.colorByDepth,nodeSize:e.nodeSize,nodeSizeRange:e.nodeSizeRange};let l,u;if(Vt.has(i)){const i=e.data||e.edges;if(!i||Array.isArray(i))return Ft.renderToStaticMarkup(t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"stream-network-frame",width:r[0],height:r[1]}));c.__hierarchyRoot=i,l=[],u=[]}else{const i=e.nodes||[],n=Array.isArray(e.edges)?e.edges:[];if(0===i.length&&0===n.length)return Ft.renderToStaticMarkup(t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"stream-network-frame",width:r[0],height:r[1]}));if(u=function(t,e){const i=Gt(e.sourceAccessor,"source"),r=Gt(e.targetAccessor,"target"),n=Gt(e.valueAccessor,"value");return t.map(t=>({source:i(t)+"",target:r(t)+"",value:Number(n(t))||1,y0:0,y1:0,sankeyWidth:0,data:t}))}(n,c),0===i.length&&u.length>0){const t=new Set;for(const e of u){const i="string"==typeof e.target?e.target:e.target.id;t.add("string"==typeof e.source?e.source:e.source.id),t.add(i)}l=Array.from(t).map(t=>({id:t,x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:{id:t}}))}else l=function(t,e){const i=Gt(e.nodeIDAccessor,"id");return t.map(t=>({id:i(t)+"",x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:t}))}(i,c)}s.computeLayout(l,u,c,[o,a]);const{sceneNodes:h,sceneEdges:f,labels:d}=s.buildScene(l,u,c,[o,a]),y=f.map((e,i)=>function(e,i){switch(e.type){case"line":return t.createElement("line",{key:"net-edge-"+i,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":case"ribbon":return t.createElement("path",{key:"net-edge-"+i,d:e.pathD,fill:e.style.fill||"#999",fillOpacity:e.style.fillOpacity,stroke:e.style.stroke||"none",strokeWidth:e.style.strokeWidth,opacity:e.style.opacity});case"curved":return t.createElement("path",{key:"net-edge-"+i,d:e.pathD,fill:e.style.fill||"none",stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity});default:return null}}(e,i)).filter(Boolean),g=h.map((e,i)=>function(e,i){switch(e.type){case"circle":return t.createElement("circle",{key:"net-circle-"+i,cx:e.cx,cy:e.cy,r:e.r,fill:e.style.fill||"#4e79a7",stroke:e.style.stroke,strokeWidth:e.style.strokeWidth,opacity:e.style.opacity});case"rect":return t.createElement("rect",{key:"net-rect-"+i,x:e.x,y:e.y,width:e.w,height:e.h,fill:e.style.fill||"#4e79a7",stroke:e.style.stroke,strokeWidth:e.style.strokeWidth,opacity:e.style.opacity});case"arc":{const r=e,n=v().innerRadius(r.innerR).outerRadius(r.outerR).startAngle(r.startAngle).endAngle(r.endAngle)({})||"";return t.createElement("path",{key:"net-arc-"+i,d:n,transform:`translate(${r.cx},${r.cy})`,fill:r.style.fill||"#4e79a7",stroke:r.style.stroke,strokeWidth:r.style.strokeWidth,opacity:r.style.opacity})}default:return null}}(e,i)).filter(Boolean),p=d.map((e,i)=>function(e,i){return t.createElement("text",{key:"net-label-"+i,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,i)).filter(Boolean),m=e.title&&"string"==typeof e.title?t.createElement("text",{x:r[0]/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"#333"},e.title):null,x=e.background?t.createElement("rect",{x:0,y:0,width:o,height:a,fill:e.background}):null,k=t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"stream-network-frame"+(e.className?" "+e.className:""),width:r[0],height:r[1]},t.createElement("g",{transform:`translate(${n.left},${n.top})`},x,y,g,p),m);return Ft.renderToStaticMarkup(k)}function Qt(e){var i,r,n;const o=e.size||[500,400],a=Object.assign(Object.assign({},{top:20,right:20,bottom:30,left:40}),e.margin),s=o[0]-a.left-a.right,c=o[1]-a.top-a.bottom,l=e.projection||"vertical",u="radial"===l,h={chartType:e.chartType,windowSize:null!==(i=e.windowSize)&&void 0!==i?i:1e4,windowMode:null!==(r=e.windowMode)&&void 0!==r?r:"sliding",extentPadding:null!==(n=e.extentPadding)&&void 0!==n?n:.05,projection:l,oAccessor:e.oAccessor,rAccessor:e.rAccessor,colorAccessor:e.colorAccessor,stackBy:e.stackBy,groupBy:e.groupBy,categoryAccessor:e.categoryAccessor,valueAccessor:e.valueAccessor,timeAccessor:e.timeAccessor,rExtent:e.rExtent,oExtent:e.oExtent,barPadding:e.barPadding,innerRadius:e.innerRadius,normalize:e.normalize,startAngle:e.startAngle,bins:e.bins,showOutliers:e.showOutliers,showIQR:e.showIQR,amplitude:e.amplitude,oSort:e.oSort,connectorAccessor:e.connectorAccessor,connectorStyle:e.connectorStyle,dynamicColumnWidth:e.dynamicColumnWidth,pieceStyle:e.pieceStyle,summaryStyle:e.summaryStyle,colorScheme:e.colorScheme,barColors:e.barColors},f=new jt(h);if(e.data&&f.ingest({inserts:e.data,bounded:!0}),f.computeScene({width:s,height:c}),!f.scales||0===f.scene.length)return Ft.renderToStaticMarkup(t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"stream-ordinal-frame",width:o[0],height:o[1]}));const d=f.scene.map((e,i)=>function(e,i){var r,n,o,a,s;switch(e.type){case"rect":return t.createElement("rect",{key:"ord-rect-"+i,x:e.x,y:e.y,width:e.w,height:e.h,fill:e.style.fill||"#4e79a7",opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth});case"point":return t.createElement("circle",{key:"ord-point-"+i,cx:e.x,cy:e.y,r:e.r,fill:e.style.fill||"#4e79a7",opacity:null!==(r=e.style.opacity)&&void 0!==r?r:.8,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth});case"wedge":{const r=e,n=v().innerRadius(r.innerRadius).outerRadius(r.outerRadius).startAngle(r.startAngle).endAngle(r.endAngle)({})||"";return t.createElement("path",{key:"ord-wedge-"+i,d:n,transform:`translate(${r.cx},${r.cy})`,fill:r.style.fill||"#4e79a7",stroke:r.style.stroke,strokeWidth:r.style.strokeWidth,opacity:r.style.opacity})}case"boxplot":{const r=e,a=r.columnWidth/2;return"vertical"===r.projection?t.createElement("g",{key:"ord-boxplot-"+i},t.createElement("line",{x1:r.x,y1:r.minPos,x2:r.x,y2:r.maxPos,stroke:r.style.stroke||"#333",strokeWidth:1}),t.createElement("rect",{x:r.x-a,y:Math.min(r.q1Pos,r.q3Pos),width:r.columnWidth,height:Math.abs(r.q3Pos-r.q1Pos),fill:r.style.fill||"#4e79a7",fillOpacity:null!==(n=r.style.fillOpacity)&&void 0!==n?n:.6,stroke:r.style.stroke||"#333",strokeWidth:1}),t.createElement("line",{x1:r.x-a,y1:r.medianPos,x2:r.x+a,y2:r.medianPos,stroke:r.style.stroke||"#333",strokeWidth:2}),t.createElement("line",{x1:r.x-.5*a,y1:r.minPos,x2:r.x+.5*a,y2:r.minPos,stroke:r.style.stroke||"#333",strokeWidth:1}),t.createElement("line",{x1:r.x-.5*a,y1:r.maxPos,x2:r.x+.5*a,y2:r.maxPos,stroke:r.style.stroke||"#333",strokeWidth:1})):t.createElement("g",{key:"ord-boxplot-"+i},t.createElement("line",{x1:r.minPos,y1:r.y,x2:r.maxPos,y2:r.y,stroke:r.style.stroke||"#333",strokeWidth:1}),t.createElement("rect",{x:Math.min(r.q1Pos,r.q3Pos),y:r.y-a,width:Math.abs(r.q3Pos-r.q1Pos),height:r.columnWidth,fill:r.style.fill||"#4e79a7",fillOpacity:null!==(o=r.style.fillOpacity)&&void 0!==o?o:.6,stroke:r.style.stroke||"#333",strokeWidth:1}),t.createElement("line",{x1:r.medianPos,y1:r.y-a,x2:r.medianPos,y2:r.y+a,stroke:r.style.stroke||"#333",strokeWidth:2}),t.createElement("line",{x1:r.minPos,y1:r.y-.5*a,x2:r.minPos,y2:r.y+.5*a,stroke:r.style.stroke||"#333",strokeWidth:1}),t.createElement("line",{x1:r.maxPos,y1:r.y-.5*a,x2:r.maxPos,y2:r.y+.5*a,stroke:r.style.stroke||"#333",strokeWidth:1}))}case"violin":{const r=e,n=[t.createElement("path",{key:"ord-violin-path-"+i,d:r.pathString,transform:r.translateX||r.translateY?`translate(${r.translateX},${r.translateY})`:void 0,fill:r.style.fill||"#4e79a7",fillOpacity:null!==(a=r.style.fillOpacity)&&void 0!==a?a:.6,stroke:r.style.stroke||"#333",strokeWidth:r.style.strokeWidth||1})];if(r.iqrLine&&r.bounds){const e=r.bounds,o=e.x+e.width/2,a=e.y+e.height/2;e.height>e.width?n.push(t.createElement("line",{key:"ord-violin-iqr-"+i,x1:o,y1:r.iqrLine.q1Pos,x2:o,y2:r.iqrLine.q3Pos,stroke:r.style.stroke||"#333",strokeWidth:2}),t.createElement("circle",{key:"ord-violin-med-"+i,cx:o,cy:r.iqrLine.medianPos,r:3,fill:"white",stroke:r.style.stroke||"#333",strokeWidth:1})):n.push(t.createElement("line",{key:"ord-violin-iqr-"+i,x1:r.iqrLine.q1Pos,y1:a,x2:r.iqrLine.q3Pos,y2:a,stroke:r.style.stroke||"#333",strokeWidth:2}),t.createElement("circle",{key:"ord-violin-med-"+i,cx:r.iqrLine.medianPos,cy:a,r:3,fill:"white",stroke:r.style.stroke||"#333",strokeWidth:1}))}return t.createElement("g",{key:"ord-violin-"+i},n)}case"connector":return t.createElement("line",{key:"ord-conn-"+i,x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:null!==(s=e.style.opacity)&&void 0!==s?s:.5});default:return null}}(e,i)).filter(Boolean),y=!1!==e.showAxes?function(e,i,r){var n,o,a,s,c,l,u,h;const f=e.scales;if(!f)return null;if("radial"===f.projection)return null;const d="vertical"===f.projection,y=Object.values(e.columns).map(t=>({pixel:t.middle,label:(r.oFormat||String)(t.name)})),g=f.r.ticks(5).map(t=>({pixel:f.r(t),label:(r.rFormat||qt)(t)}));return d?t.createElement("g",{className:"ordinal-axes"},t.createElement("line",{x1:0,y1:i.height,x2:i.width,y2:i.height,stroke:"#ccc",strokeWidth:1}),y.map((e,r)=>t.createElement("g",{key:"oxtick-"+r,transform:`translate(${e.pixel},${i.height})`},t.createElement("line",{y2:5,stroke:"#ccc",strokeWidth:1}),t.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:"#666"},e.label))),r.oLabel&&t.createElement("text",{x:i.width/2,y:i.height+40,textAnchor:"middle",fontSize:12,fill:"#333"},r.oLabel),t.createElement("line",{x1:0,y1:0,x2:0,y2:i.height,stroke:"#ccc",strokeWidth:1}),g.map((e,i)=>t.createElement("g",{key:"oytick-"+i,transform:`translate(0,${e.pixel})`},t.createElement("line",{x2:-5,stroke:"#ccc",strokeWidth:1}),t.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"#666"},e.label))),r.rLabel&&t.createElement("text",{x:15-(null!==(o=null===(n=r.margin)||void 0===n?void 0:n.left)&&void 0!==o?o:40),y:i.height/2,textAnchor:"middle",fontSize:12,fill:"#333",transform:`rotate(-90, ${15-(null!==(s=null===(a=r.margin)||void 0===a?void 0:a.left)&&void 0!==s?s:40)}, ${i.height/2})`},r.rLabel)):t.createElement("g",{className:"ordinal-axes"},t.createElement("line",{x1:0,y1:i.height,x2:i.width,y2:i.height,stroke:"#ccc",strokeWidth:1}),g.map((e,r)=>t.createElement("g",{key:"oxtick-"+r,transform:`translate(${e.pixel},${i.height})`},t.createElement("line",{y2:5,stroke:"#ccc",strokeWidth:1}),t.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:"#666"},e.label))),r.rLabel&&t.createElement("text",{x:i.width/2,y:i.height+40,textAnchor:"middle",fontSize:12,fill:"#333"},r.rLabel),t.createElement("line",{x1:0,y1:0,x2:0,y2:i.height,stroke:"#ccc",strokeWidth:1}),y.map((e,i)=>t.createElement("g",{key:"oytick-"+i,transform:`translate(0,${e.pixel})`},t.createElement("line",{x2:-5,stroke:"#ccc",strokeWidth:1}),t.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"#666"},e.label))),r.oLabel&&t.createElement("text",{x:15-(null!==(l=null===(c=r.margin)||void 0===c?void 0:c.left)&&void 0!==l?l:40),y:i.height/2,textAnchor:"middle",fontSize:12,fill:"#333",transform:`rotate(-90, ${15-(null!==(h=null===(u=r.margin)||void 0===u?void 0:u.left)&&void 0!==h?h:40)}, ${i.height/2})`},r.oLabel))}(f,{width:s,height:c},e):null,g=e.title&&"string"==typeof e.title?t.createElement("text",{x:o[0]/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"#333"},e.title):null,p=e.background?t.createElement("rect",{x:0,y:0,width:s,height:c,fill:e.background}):null,m=t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"stream-ordinal-frame"+(e.className?" "+e.className:""),width:o[0],height:o[1]},t.createElement("g",{transform:`translate(${u?a.left+s/2:a.left},${u?a.top+c/2:a.top})`},p,d,y),g);return Ft.renderToStaticMarkup(m)}function Ut(t,e){switch(t){case"xy":return Ht(e);case"ordinal":return Qt(e);case"network":return Zt(e);default:throw Error(`Unknown frame type: ${t}. Must be "xy", "ordinal", or "network".`)}}function Jt(t){return Ht(t)}function Kt(t){return Qt(t)}function te(t){return Zt(t)}export{te as renderNetworkToStaticSVG,Kt as renderOrdinalToStaticSVG,Ut as renderToStaticSVG,Jt as renderXYToStaticSVG};
@@ -0,0 +1,2 @@
1
+ export declare function setupCanvasMock(): void;
2
+ export declare function teardownCanvasMock(): void;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Creates a mock 2D canvas rendering context with all commonly used
3
+ * methods stubbed as vi.fn() and properties set to sensible defaults.
4
+ */
5
+ export declare function createMockCanvasContext(): Record<string, any>;
6
+ /**
7
+ * Sets up the canvas getContext mock on HTMLCanvasElement.prototype,
8
+ * mocks requestAnimationFrame to execute callbacks synchronously,
9
+ * and mocks cancelAnimationFrame.
10
+ *
11
+ * @returns A cleanup function that restores the mocked globals.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * let cleanup: () => void
16
+ * beforeEach(() => { cleanup = setupCanvasMock() })
17
+ * afterEach(() => { cleanup() })
18
+ * ```
19
+ */
20
+ export declare function setupCanvasMock(): () => void;