semiotic 3.0.0 → 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 +23 -10
  2. package/README.md +66 -63
  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 +7 -15
  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
package/dist/xy.min.js CHANGED
@@ -1 +1 @@
1
- "use strict";const e=require("react"),t=require("d3-brush"),n=require("d3-selection"),o=require("d3-scale"),s=require("d3-array"),i=require("d3-hierarchy"),r=require("d3-scale-chromatic");function l(e){if(e&&e.__esModule)return e;const t=Object.create(null);if(e)for(const n in e)if("default"!==n){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:function(){return e[n]}})}return t.default=e,Object.freeze(t)}const a=l(e),c=5e3;class u{constructor(e){this.lastBoundedData=null,this.chunkTimer=0,this.callback=e}clearLastData(){this.lastBoundedData=null,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(e){if(this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),5e3>=e.length)return void this.callback({inserts:e,bounded:!0});this.callback({inserts:e.slice(0,c),bounded:!0,totalSize:e.length});let t=c;const n=()=>{if(t>=e.length)return;if(e!==this.lastBoundedData)return;const o=Math.min(t+c,e.length);this.callback({inserts:e.slice(t,o),bounded:!1}),t=o,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}push(e){this.callback({inserts:[e],bounded:!1})}pushMany(e){0!==e.length&&this.callback({inserts:e,bounded:!1})}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null}}class h{constructor(e){if(this._capacity=e,this.head=0,this._size=0,1>e)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(e)}push(e){let t;return this._size===this._capacity?t=this.buffer[this.head]:this._size++,this.buffer[this.head]=e,this.head=(this.head+1)%this._capacity,t}pushMany(e){const t=[];for(const n of e){const e=this.push(n);void 0!==e&&t.push(e)}return t}get(e){if(e>=0&&this._size>e)return this.buffer[(this.head-this._size+e+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 e=0;const t=this;return{next:()=>t._size>e?{done:!1,value:t.get(e++)}:{done:!0,value:void 0}}}toArray(){const e=[];for(const t of this)e.push(t);return e}resize(e){if(1>e)throw Error("RingBuffer capacity must be at least 1");const t=this.toArray(),n=[];for(;t.length>e;)n.push(t.shift());this._capacity=e,this.buffer=Array(e),this.head=0,this._size=0;for(const e of t)this.push(e);return n}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 d{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(e){Number.isNaN(e)||(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}evict(e){e!==this._min&&e!==this._max||(this._dirty=!0)}recalculate(e,t){this._min=1/0,this._max=-1/0;for(const n of e){const e=t?t(n):n;Number.isNaN(e)||(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}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 f(e,t,n,o,s){const i=new Map;for(const r of e){const e=t(r),l=n(r);if(null==e||null==l||Number.isNaN(e)||Number.isNaN(l))continue;const a=Math.floor(e/o)*o;let c=i.get(a);if(c||(c={start:a,end:a+o,total:0,categories:new Map},i.set(a,c)),c.total+=l,s){const e=s(r);c.categories.set(e,(c.categories.get(e)||0)+l)}}return i}function p(e,t,n,o,s,i){const r=[],l=[];for(const s of e){const e=n(s),i=o(s);null==e||null==i||Number.isNaN(e)||Number.isNaN(i)||(r.push([t.x(e),t.y(i)]),l.push(i))}return{type:"line",path:r,rawValues:l,style:s,datum:e,group:i}}function m(e,t,n,o,s,i,r,l){const a=[],c=[];for(const i of e){const e=n(i),r=o(i);if(null==e||null==r||Number.isNaN(e)||Number.isNaN(r))continue;const u=t.x(e);a.push([u,t.y(r)]);const h=l?l(i):s;c.push([u,t.y(h)])}return{type:"area",topPath:a,bottomPath:c,style:i,datum:e,group:r}}function y(e,t,n,o,s,i,r){const l=n(e),a=o(e);if(null==l||null==a||Number.isNaN(l)||Number.isNaN(a))return null;const c={type:"point",x:t.x(l),y:t.y(a),r:s,style:i,datum:e};return void 0!==r&&(c.pointId=r),c}function g(e,t,n,o,s,i,r){return{type:"rect",x:e,y:t,w:n,h:o,style:s,datum:i,group:r}}function b(e,t,n,o,s,i){return{type:"heatcell",x:e,y:t,w:n,h:o,fill:s,datum:i}}function v(e,t){if("function"==typeof e)return t=>+e(t);const n=e||t;return e=>+e[n]}function x(e,t){return"function"==typeof e?e:e?t=>t[e]+"":void 0}class w{constructor(e){this.xExtent=new d,this.yExtent=new d,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.lastIngestTime=0,this.scales=null,this.scene=[],this.version=0,this.config=e,this.buffer=new h(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=v(e.timeAccessor||e.xAccessor,"time"),this.getY=v(e.valueAccessor||e.yAccessor,"value")):(this.getX=v(e.xAccessor,"x"),this.getY=v(e.yAccessor,"y")),this.getGroup=x(e.groupAccessor),this.getCategory=x(e.categoryAccessor),this.getSize=e.sizeAccessor?v(e.sizeAccessor,"size"):void 0,this.getColor=x(e.colorAccessor),this.getBounds=e.boundsAccessor?v(e.boundsAccessor,"bounds"):void 0,this.getY0=e.y0Accessor?v(e.y0Accessor,"y0"):void 0,this.getPointId=x(e.pointIdAccessor),"candlestick"===e.chartType&&(this.getOpen=v(e.openAccessor,"open"),this.getHigh=v(e.highAccessor,"high"),this.getLow=v(e.lowAccessor,"low"),this.getClose=v(e.closeAccessor,"close")),e.pulse&&(this.timestampBuffer=new h(e.windowSize))}ingest(e){const t="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=t,e.bounded){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const n=e.totalSize||e.inserts.length;n>this.buffer.capacity&&(this.buffer.resize(n),this.timestampBuffer&&n>this.timestampBuffer.capacity&&this.timestampBuffer.resize(n));for(const n of e.inserts)this.buffer.push(n),this.timestampBuffer&&this.timestampBuffer.push(t),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):(this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n)))}else for(const n of e.inserts){"growing"===this.config.windowMode&&this.buffer.full&&(this.growingCap*=2,this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap));const e=this.buffer.push(n);this.timestampBuffer&&this.timestampBuffer.push(t),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):(this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n))),null!=e&&(this.xExtent.evict(this.getX(e)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(e)),this.yExtent.evict(this.getLow(e))):this.yExtent.evict(this.getY(e)))}return!0}computeScene(e){var t,n,s,i,r,l;const{config:a,buffer:c}=this;if(this.xExtent.dirty&&this.xExtent.recalculate(c,this.getX),this.yExtent.dirty)if("candlestick"===a.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const e of c)this.yExtent.push(this.getHigh(e)),this.yExtent.push(this.getLow(e))}else this.yExtent.recalculate(c,this.getY);const u=this.xExtent.extent,h=this.yExtent.extent;let d=a.xExtent?[null!==(t=a.xExtent[0])&&void 0!==t?t:u[0],null!==(n=a.xExtent[1])&&void 0!==n?n:u[1]]:u,p=a.yExtent?[null!==(s=a.yExtent[0])&&void 0!==s?s:h[0],null!==(i=a.yExtent[1])&&void 0!==i?i:h[1]]:h;const m=a.yExtent&&null!=a.yExtent[0]&&null!=a.yExtent[1];if("stackedarea"===a.chartType&&!m&&c.size>0)if(a.normalize)p=[0,1+a.extentPadding];else{const e=c.toArray(),t=this.groupData(e),n=new Map;for(const e of t)for(const t of e.data){const e=this.getX(t),o=this.getY(t);null==e||null==o||Number.isNaN(e)||Number.isNaN(o)||n.set(e,(n.get(e)||0)+o)}let o=0;for(const e of n.values())e>o&&(o=e);p=[0,o+(o>0?o*a.extentPadding:1)]}else if("bar"===a.chartType&&a.binSize&&!m&&c.size>0){const[,e]=function(e,t,n,o,s){const i=f(e,t,n,o,s);if(0===i.size)return[0,0];let r=0;for(const e of i.values())e.total>r&&(r=e.total);return[0,r]}(c,this.getX,this.getY,a.binSize,this.getCategory);p=[0,e+e*a.extentPadding]}else if("waterfall"===a.chartType&&!m&&c.size>0){const[e,t]=function(e,t){let n=0,o=0,s=0;for(const i of e){const e=t(i);null==e||Number.isNaN(e)||(s+=e,n>s&&(n=s),s>o&&(o=s))}return[n,o]}(c,this.getY),n=t-e,o=n>0?n*a.extentPadding:1;p=[Math.min(0,e-Math.abs(o)),Math.max(0,t+Math.abs(o))]}else if(!m&&p[0]!==1/0){if(this.getBounds){const e=c.toArray();for(const t of e){const e=this.getY(t),n=this.getBounds(t);null!=e&&!Number.isNaN(e)&&n&&(e+n>p[1]&&(p[1]=e+n),p[0]>e-n&&(p[0]=e-n))}}const e=p[1]-p[0],t=e>0?e*a.extentPadding:1,n=null===(r=a.yExtent)||void 0===r?void 0:r[0],o=null===(l=a.yExtent)||void 0===l?void 0:l[1];p=[null!=n?p[0]:p[0]-t,null!=o?p[1]:p[1]+t]}if(d[0]!==1/0&&d[1]!==-1/0||(d=[0,1]),p[0]!==1/0&&p[1]!==-1/0||(p=[0,1]),void 0!==a.arrowOfTime)if("x"==("up"===(y=a.arrowOfTime)||"down"===y?"y":"x")){const t="right"===a.arrowOfTime?[0,e.width]:[e.width,0];this.scales={x:o.scaleLinear().domain(d).range(t),y:o.scaleLinear().domain(p).range([e.height,0])}}else{const t="down"===a.arrowOfTime?[0,e.height]:[e.height,0];this.scales={x:o.scaleLinear().domain(p).range([0,e.width]),y:o.scaleLinear().domain(d).range(t)}}else this.scales={x:o.scaleLinear().domain(d).range([0,e.width]),y:o.scaleLinear().domain(p).range([e.height,0])};var y;this.config.transition&&this.scene.length>0&&this.snapshotPositions();const g=c.toArray();this.scene=this.buildSceneNodes(e),this.config.decay&&this.applyDecay(this.scene,g),this.config.pulse&&this.applyPulse(this.scene,g),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++}buildSceneNodes(e){const{config:t,buffer:n,scales:o}=this;if(!o||0===n.size)return[];const s=n.toArray();switch(t.chartType){case"line":return this.buildLineScene(s);case"area":return this.buildAreaScene(s);case"stackedarea":return this.buildStackedAreaScene(s);case"scatter":case"bubble":return this.buildPointScene(s);case"heatmap":return this.buildHeatmapScene(s,e);case"bar":return this.buildBarScene(s);case"swarm":return this.buildSwarmScene(s);case"waterfall":return this.buildWaterfallScene(s,e);case"candlestick":return this.buildCandlestickScene(s,e);default:return[]}}buildLineScene(e){var t;const n=this.groupData(e),o=[],s=null===(t=this.config.annotations)||void 0===t?void 0:t.filter(e=>"threshold"===e.type&&e.color).map(e=>({value:e.value,color:e.color,thresholdType:e.thresholdType||"greater"}));if(this.getBounds)for(const e of n){const t=this.buildBoundsForGroup(e.data,e.key);t&&o.push(t)}for(const e of n){const t=this.resolveLineStyle(e.key,e.data[0]),n=p(e.data,this.scales,this.getX,this.getY,t,e.key);s&&s.length>0&&(n.colorThresholds=s),o.push(n)}return o}buildAreaScene(e){const t=this.groupData(e),n=[],o=this.scales.y.domain()[0];for(const e of t){const t=this.resolveAreaStyle(e.key,e.data[0]),s=m(e.data,this.scales,this.getX,this.getY,o,t,e.key,this.getY0);this.config.gradientFill&&(s.fillGradient=this.config.gradientFill),n.push(s)}return n}buildStackedAreaScene(e){const t=this.groupData(e);return t.sort((e,t)=>t.key>e.key?-1:e.key>t.key?1:0),function(e,t,n,o,s,i){var r;const l=new Set;for(const t of e)for(const e of t.data){const t=n(e);null==t||Number.isNaN(t)||l.add(t)}const a=Array.from(l).sort((e,t)=>e-t),c=new Map;for(const t of e){const e=new Map;for(const s of t.data){const t=n(s),i=o(s);null==t||null==i||Number.isNaN(t)||Number.isNaN(i)||e.set(t,(e.get(t)||0)+i)}c.set(t.key,e)}let u;if(i){u=new Map;for(const t of a){let n=0;for(const o of e)n+=(null===(r=c.get(o.key))||void 0===r?void 0:r.get(t))||0;u.set(t,n||1)}}const h=[],d=new Map;for(const e of a)d.set(e,0);for(const n of e){const e=c.get(n.key),o=[],r=[];for(const n of a){let s=e.get(n)||0;const l=d.get(n);i&&(s/=u.get(n));const a=t.x(n);r.push([a,t.y(l)]),o.push([a,t.y(l+s)]),d.set(n,l+s)}h.push({type:"area",topPath:o,bottomPath:r,style:s(n.key,n.data[0]),datum:n.data,group:n.key})}return h}(t,this.scales,this.getX,this.getY,(e,t)=>this.resolveAreaStyle(e,t),this.config.normalize)}buildPointScene(e){const t=[],n="bubble"===this.config.chartType?10:5,o=this.config.sizeRange||[3,15];let s=null;if(this.getSize&&!this.config.pointStyle){const t=e.map(e=>this.getSize(e)).filter(e=>null!=e&&!Number.isNaN(e));if(t.length>0){const e=Math.min(...t),n=Math.max(...t);s=t=>e===n?(o[0]+o[1])/2:o[0]+(t-e)/(n-e)*(o[1]-o[0])}}let i=null;if(this.getColor&&!this.config.pointStyle){const t=new Set;for(const n of e){const e=this.getColor(n);e&&t.add(e)}const n=Array.isArray(this.config.colorScheme)?this.config.colorScheme:["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];i=new Map;let o=0;for(const e of t)i.set(e,n[o%n.length]),o++}for(const o of e){let e=this.config.pointStyle?this.config.pointStyle(o):{fill:"#4e79a7",opacity:.8},r=e.r||n;if(s&&this.getSize){const e=this.getSize(o);null==e||Number.isNaN(e)||(r=s(e))}if(i&&this.getColor){const t=this.getColor(o);t&&i.has(t)&&(e=Object.assign(Object.assign({},e),{fill:i.get(t)}))}const l=this.getPointId?this.getPointId(o)+"":void 0,a=y(o,this.scales,this.getX,this.getY,r,e,l);a&&t.push(a)}return t}buildHeatmapScene(e,t){const n=[];if(this.config.heatmapAggregation)return this.buildStreamingHeatmapScene(e,t);const o=v(this.config.valueAccessor,"value"),s=new Set,i=new Set;for(const t of e)s.add(this.getX(t)),i.add(this.getY(t));const r=Array.from(s).sort((e,t)=>e-t),l=Array.from(i).sort((e,t)=>e-t);if(0===r.length||0===l.length)return n;const a=t.width/r.length,c=t.height/l.length,u=new Map;for(const t of e){const e=`${this.getX(t)}_${this.getY(t)}`;u.set(e,{val:o(t),datum:t})}let h=1/0,d=-1/0;for(const{val:e}of u.values())h>e&&(h=e),e>d&&(d=e);const f=d-h||1;for(let e=0;r.length>e;e++)for(let t=0;l.length>t;t++){const o=u.get(`${r[e]}_${l[t]}`);if(!o)continue;const s=(o.val-h)/f;n.push(b(e*a,(l.length-1-t)*c,a,c,`rgb(${Math.round(220-180*s)},${Math.round(220-100*s)},${Math.round(255-50*s)})`,o.datum))}return n}buildStreamingHeatmapScene(e,t){var n,o,s;const i=[],r=null!==(n=this.config.heatmapXBins)&&void 0!==n?n:20,l=null!==(o=this.config.heatmapYBins)&&void 0!==o?o:20,a=null!==(s=this.config.heatmapAggregation)&&void 0!==s?s:"count",c=v(this.config.valueAccessor,"value");if(!this.scales||0===e.length)return i;const[u,h]=this.scales.x.domain(),[d,f]=this.scales.y.domain(),p=(h-u||1)/r,m=(f-d||1)/l,y=new Map;for(const t of e){const e=this.getX(t),n=this.getY(t),o=Math.min(Math.floor((e-u)/p),r-1),s=Math.min(Math.floor((n-d)/m),l-1);if(0>o||0>s)continue;const i=`${o}_${s}`;let a=y.get(i);a||(a={sum:0,count:0,data:[]},y.set(i,a)),a.count++,a.sum+=c(t),a.data.push(t)}let g=1/0,x=-1/0;const w=new Map;for(const[e,t]of y){let n;switch(a){case"sum":n=t.sum;break;case"mean":n=t.count>0?t.sum/t.count:0;break;default:n=t.count}w.set(e,n),g>n&&(g=n),n>x&&(x=n)}const k=x-g||1,A=t.width/r,E=t.height/l;for(const[e,t]of w){const[n,o]=e.split("_"),s=+n,r=+o,a=(t-g)/k,c=`rgb(${Math.round(220-180*a)},${Math.round(220-100*a)},${Math.round(255-50*a)})`,u=y.get(e);i.push(b(s*A,(l-1-r)*E,A,E,c,{xi:s,yi:r,value:t,count:u.count,sum:u.sum,data:u.data}))}return i}buildBarScene(e){var t;if(!this.config.binSize)return[];const n=f(e,this.getX,this.getY,this.config.binSize,this.getCategory);if(0===n.size)return[];let o=null;if(this.getCategory){const e=new Set;for(const t of n.values())for(const n of t.categories.keys())e.add(n);const t=this.config.barColors?Object.keys(this.config.barColors):[],s=new Set(t),i=Array.from(e).filter(e=>!s.has(e)).sort();o=[...t.filter(t=>e.has(t)),...i]}const s=[],i=this.scales,[r,l]=i.x.domain();for(const e of n.values()){const n=Math.max(e.start,r),a=Math.min(e.end,l);if(n>=a)continue;const c=i.x(n),u=i.x(a),h=Math.min(c,u)+.5,d=Math.max(c,u)-.5-h;if(d>0)if(o&&e.categories.size>0){let n=0;for(const r of o){const o=e.categories.get(r)||0;if(0===o)continue;const l=i.y(n),a=i.y(n+o);s.push(g(h,Math.min(l,a),d,Math.abs(l-a),{fill:(null===(t=this.config.barColors)||void 0===t?void 0:t[r])||"#4e79a7"},{binStart:e.start,binEnd:e.end,total:e.total,category:r,categoryValue:o},r)),n+=o}}else{const t=i.y(0),n=i.y(e.total);s.push(g(h,Math.min(t,n),d,Math.abs(t-n),{fill:"#007bff"},{binStart:e.start,binEnd:e.end,total:e.total}))}}return s}buildSwarmScene(e){var t,n,o,s;const i=[],r=this.config.swarmStyle||{},l=null!==(t=r.radius)&&void 0!==t?t:3,a=null!==(n=r.fill)&&void 0!==n?n:"#007bff",c=null!==(o=r.opacity)&&void 0!==o?o:.7,u=r.stroke,h=r.strokeWidth;for(const t of e){const e=this.getX(t),n=this.getY(t);if(null==n||Number.isNaN(n))continue;const o=this.scales.x(e),r=this.scales.y(n);let d=a;if(this.getCategory){const e=this.getCategory(t);d=(null===(s=this.config.barColors)||void 0===s?void 0:s[e])||d}const f={type:"point",x:o,y:r,r:l,style:{fill:d,opacity:c,stroke:u,strokeWidth:h},datum:t};this.getPointId&&(f.pointId=this.getPointId(t)+""),i.push(f)}return i}buildWaterfallScene(e,t){var n,o,s;const i=[],r=this.scales,l=this.config.waterfallStyle,a=e.filter(e=>{const t=this.getY(e);return null!=t&&!Number.isNaN(t)});if(0===a.length)return i;const c=null!==(n=null==l?void 0:l.positiveColor)&&void 0!==n?n:"#28a745",u=null!==(o=null==l?void 0:l.negativeColor)&&void 0!==o?o:"#dc3545",h=null!==(s=null==l?void 0:l.gap)&&void 0!==s?s:1,d=null==l?void 0:l.stroke,f=null==l?void 0:l.strokeWidth;let p=0;for(let e=0;a.length>e;e++){const n=a[e],o=this.getX(n),s=this.getY(n),m=p+s;let y;y=a.length-1>e?this.getX(a[e+1])-o:e>0?o-this.getX(a[e-1]):0;const b=r.x(o),v=0!==y?r.x(o+y):b+t.width/10,x=Math.min(b,v)+h/2,w=Math.max(b,v)-h/2-x;if(0>=w){p=m;continue}const k=r.y(p),A=r.y(m);i.push(g(x,Math.min(k,A),w,Math.abs(k-A),{fill:0>s?u:c,stroke:d,strokeWidth:f},Object.assign(Object.assign({},n),{baseline:p,cumEnd:m,delta:s,_connectorStroke:null==l?void 0:l.connectorStroke,_connectorWidth:null==l?void 0:l.connectorWidth}))),p=m}return i}buildCandlestickScene(e,t){if(!(this.getOpen&&this.getHigh&&this.getLow&&this.getClose&&this.scales))return[];const n=[],o=this.config.candlestickStyle||{},s=o.upColor||"#28a745",i=o.downColor||"#dc3545",r=o.wickColor||"#333",l=o.wickWidth||1,a=e.map(e=>this.getX(e)).filter(e=>null!=e&&!Number.isNaN(e)).sort((e,t)=>e-t);let c=o.bodyWidth||6;if(!o.bodyWidth&&a.length>1){let e=1/0;for(let t=1;a.length>t;t++){const n=Math.abs(this.scales.x(a[t])-this.scales.x(a[t-1]));n>0&&e>n&&(e=n)}e!==1/0&&(c=Math.max(2,Math.min(.6*e,20)))}for(const t of e){const e=this.getX(t);if(null==e||Number.isNaN(e))continue;const o=this.getOpen(t),a=this.getHigh(t),u=this.getLow(t),h=this.getClose(t);if([o,a,u,h].some(e=>null==e||Number.isNaN(e)))continue;const d=h>=o;n.push({type:"candlestick",x:this.scales.x(e),openY:this.scales.y(o),closeY:this.scales.y(h),highY:this.scales.y(a),lowY:this.scales.y(u),bodyWidth:c,upColor:s,downColor:i,wickColor:r,wickWidth:l,isUp:d,datum:t})}return n}buildBoundsForGroup(e,t){if(!this.getBounds||!this.scales)return null;const n=[],o=[];for(const t of e){const e=this.getX(t),s=this.getY(t);if(null==e||null==s||Number.isNaN(e)||Number.isNaN(s))continue;const i=this.getBounds(t),r=this.scales.x(e);if(i&&0!==i)n.push([r,this.scales.y(s+i)]),o.push([r,this.scales.y(s-i)]);else{const e=this.scales.y(s);n.push([r,e]),o.push([r,e])}}return 2>n.length?null:{type:"area",topPath:n,bottomPath:o,style:this.resolveBoundsStyle(t,e[0]),datum:e,group:t,interactive:!1}}resolveBoundsStyle(e,t){const n=this.config.boundsStyle;return"function"==typeof n?n(t||{},e):n&&"object"==typeof n?n:{fill:this.resolveLineStyle(e,t).stroke||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(e,t){var n,o,s;const i=this.config.decay;if(!i||1>=t)return 1;const r=null!==(n=i.minOpacity)&&void 0!==n?n:.1,l=t-1-e;switch(i.type){case"linear":return r+(1-l/(t-1))*(1-r);case"exponential":{const e=null!==(o=i.halfLife)&&void 0!==o?o:t/2;return r+Math.pow(.5,l/e)*(1-r)}case"step":return(null!==(s=i.stepThreshold)&&void 0!==s?s:.5*t)>l?1:r;default:return 1}}applyDecay(e,t){var n,o;if(!this.config.decay)return;const s=t.length;if(1>=s)return;const i=new Map;for(let e=0;t.length>e;e++)i.set(t[e],e);for(const t of e){if("line"===t.type||"area"===t.type)continue;const e=i.get(t.datum);if(null==e)continue;const r=this.computeDecayOpacity(e,s);if("heatcell"===t.type)t.style={opacity:r};else if("candlestick"===t.type)t._decayOpacity=r;else{const e=null!==(o=null===(n=t.style)||void 0===n?void 0:n.opacity)&&void 0!==o?o:1;t.style=Object.assign(Object.assign({},t.style),{opacity:e*r})}}}computePulseIntensity(e,t){var n;const o=this.config.pulse;if(!o)return 0;const s=null!==(n=o.duration)&&void 0!==n?n:500,i=t-e;return s>i?1-i/s:0}applyPulse(e,t){var n,o;if(!this.config.pulse||!this.timestampBuffer)return;const s="undefined"!=typeof performance?performance.now():Date.now(),i=null!==(n=this.config.pulse.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",r=null!==(o=this.config.pulse.glowRadius)&&void 0!==o?o:4,l=new Map;for(let e=0;t.length>e;e++)l.set(t[e],e);for(const t of e){if("line"===t.type||"area"===t.type)continue;const e=l.get(t.datum);if(null==e)continue;const n=this.timestampBuffer.get(e);if(null==n)continue;const o=this.computePulseIntensity(n,s);o>0&&(t._pulseIntensity=o,t._pulseColor=i,t._pulseGlowRadius=r)}}get hasActivePulses(){var e;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const t="undefined"!=typeof performance?performance.now():Date.now(),n=null!==(e=this.config.pulse.duration)&&void 0!==e?e:500,o=this.timestampBuffer.peek();return null!=o&&n>t-o}snapshotPositions(){this.prevPositionMap.clear();for(let e=0;this.scene.length>e;e++){const t=this.scene[e],n=this.getNodeIdentity(t,e);n&&("point"===t.type?this.prevPositionMap.set(n,{x:t.x,y:t.y,r:t.r}):"rect"===t.type||"heatcell"===t.type?this.prevPositionMap.set(n,{x:t.x,y:t.y,w:t.w,h:t.h}):"candlestick"===t.type&&this.prevPositionMap.set(n,{x:t.x,y:t.openY}))}}getNodeIdentity(e,t){var n,o,s,i;switch(e.type){case"point":return`p:${void 0===e.datum?t:this.getX(e.datum)}_${this.getY(e.datum)}`;case"rect":return`r:${e.group||""}:${null!==(i=null!==(o=null===(n=e.datum)||void 0===n?void 0:n.binStart)&&void 0!==o?o:null===(s=e.datum)||void 0===s?void 0:s.category)&&void 0!==i?i:t}`;case"heatcell":return`h:${e.x}_${e.y}`;case"candlestick":return"c:"+this.getX(e.datum);default:return null}}startTransition(){var e,t,n,o,s,i;if(!this.config.transition||0===this.prevPositionMap.size)return;const r=null!==(e=this.config.transition.duration)&&void 0!==e?e:300;let l=!1;for(let e=0;this.scene.length>e;e++){const r=this.scene[e],a=this.getNodeIdentity(r,e);if(!a)continue;const c=this.prevPositionMap.get(a);if(c)if("point"===r.type){const e={x:r.x,y:r.y,r:r.r};c.x===e.x&&c.y===e.y||(r._targetX=e.x,r._targetY=e.y,r._targetR=e.r,r.x=c.x,r.y=c.y,r.r=null!==(t=c.r)&&void 0!==t?t:r.r,l=!0)}else if("rect"===r.type){const e={x:r.x,y:r.y,w:r.w,h:r.h};c.x===e.x&&c.y===e.y&&c.w===e.w&&c.h===e.h||(r._targetX=e.x,r._targetY=e.y,r._targetW=e.w,r._targetH=e.h,r.x=c.x,r.y=c.y,r.w=null!==(n=c.w)&&void 0!==n?n:r.w,r.h=null!==(o=c.h)&&void 0!==o?o:r.h,l=!0)}else if("heatcell"===r.type){const e={x:r.x,y:r.y,w:r.w,h:r.h};c.x===e.x&&c.y===e.y||(r._targetX=e.x,r._targetY=e.y,r._targetW=e.w,r._targetH=e.h,r.x=c.x,r.y=c.y,r.w=null!==(s=c.w)&&void 0!==s?s:r.w,r.h=null!==(i=c.h)&&void 0!==i?i:r.h,l=!0)}}l&&(this.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:r})}advanceTransition(e){var t;if(!this.activeTransition)return!1;const n=Math.min((e-this.activeTransition.startTime)/this.activeTransition.duration,1),o="linear"===(null===(t=this.config.transition)||void 0===t?void 0:t.easing)?n:1-Math.pow(1-n,3);for(const e of this.scene)if("point"===e.type){if(void 0===e._targetX)continue;const t=this.getNodeIdentity(e,0);if(!t)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=n.x+(e._targetX-n.x)*o,e.y=n.y+(e._targetY-n.y)*o,void 0!==e._targetR&&void 0!==n.r&&(e.r=n.r+(e._targetR-n.r)*o)}else if("rect"===e.type){if(void 0===e._targetX)continue;const t=this.getNodeIdentity(e,0);if(!t)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=n.x+(e._targetX-n.x)*o,e.y=n.y+(e._targetY-n.y)*o,void 0!==n.w&&(e.w=n.w+(e._targetW-n.w)*o),void 0!==n.h&&(e.h=n.h+(e._targetH-n.h)*o)}else if("heatcell"===e.type){if(void 0===e._targetX)continue;const t=this.getNodeIdentity(e,0);if(!t)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=n.x+(e._targetX-n.x)*o,e.y=n.y+(e._targetY-n.y)*o,void 0!==n.w&&(e.w=n.w+(e._targetW-n.w)*o),void 0!==n.h&&(e.h=n.h+(e._targetH-n.h)*o)}if(n>=1){for(const e of this.scene)if("point"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,void 0!==e._targetR&&(e.r=e._targetR),e._targetX=void 0,e._targetY=void 0,e._targetR=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("heatcell"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}return this.activeTransition=null,!1}return!0}groupData(e){if(!this.getGroup)return[{key:"_default",data:e}];const t=new Map;for(const n of e){const e=this.getGroup(n);t.has(e)||t.set(e,[]),t.get(e).push(n)}return Array.from(t.entries()).map(([e,t])=>({key:e,data:t}))}resolveLineStyle(e,t){const n=this.config.lineStyle;return"function"==typeof n?n(t||{},e):n&&"object"==typeof n?{stroke:n.stroke||"#007bff",strokeWidth:n.strokeWidth||2,strokeDasharray:n.strokeDasharray,fill:n.fill,fillOpacity:n.fillOpacity,opacity:n.opacity}:{stroke:"#007bff",strokeWidth:2}}resolveAreaStyle(e,t){var n;if(this.config.areaStyle)return this.config.areaStyle(t||{});const o=this.config.lineStyle;return"function"==typeof o?o(t||{},e):o&&"object"==typeof o?{fill:o.fill||o.stroke||"#4e79a7",fillOpacity:null!==(n=o.fillOpacity)&&void 0!==n?n:.7,stroke:o.stroke||"#4e79a7",strokeWidth:o.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(e){Object.assign(this.config,e)}}function k(e,t,n){const o=t-e.x,s=n-e.y,i=Math.sqrt(o*o+s*s);return i>e.r+5?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:i}}function A(e,t,n){if(0===e.path.length)return null;const o=N(e.path,t);if(0>o)return null;const[s,i]=e.path[o],r=t-s,l=n-i,a=Math.sqrt(r*r+l*l);return{node:e,datum:Array.isArray(e.datum)&&e.datum[o]?e.datum[o]:e.datum,x:s,y:i,distance:a}}function E(e,t,n){return e.x>t||t>e.x+e.w||e.y>n||n>e.y+e.h?null:{node:e,datum:e.datum,x:e.x+e.w/2,y:e.y+e.h/2,distance:0}}function M(e,t,n){return e.x>t||t>e.x+e.w||e.y>n||n>e.y+e.h?null:{node:e,datum:e.datum,x:e.x+e.w/2,y:e.y+e.h/2,distance:0}}function S(e,t,n){const o=e.bodyWidth/2,s=Math.min(e.openY,e.closeY);if(!(e.x-o-3>t||t>e.x+o+3||e.highY-3>n||n>e.lowY+3)){const o=s+Math.max(Math.max(e.openY,e.closeY)-s,1)/2,i=t-e.x,r=n-o;return{node:e,datum:e.datum,x:e.x,y:o,distance:Math.sqrt(i*i+r*r)}}return null}function O(e,t,n){if(0===e.topPath.length)return null;const o=N(e.topPath,t);if(0>o)return null;const[s,i]=e.topPath[o],r=t-s,l=n-i;return{node:e,datum:e.datum,x:s,y:i,distance:Math.sqrt(r*r+l*l)}}function N(e,t){if(0===e.length)return-1;let n=0,o=e.length-1;for(;o>n;){const s=n+o>>1;t>e[s][0]?n=s+1:o=s}return n>0&&Math.abs(e[n][0]-t)>=Math.abs(e[n-1][0]-t)?n-1:n}const L={fill:e=>a.createElement("rect",{style:e,width:20,height:20}),line:e=>a.createElement("line",{style:e,x1:0,y1:0,x2:20,y2:20})};function j(e,t,n,o){let s;return s="function"==typeof n?n(e):(0,L[n])(o(e,t)),s}function C(e){const{legendGroups:t,customClickBehavior:n,title:o="Legend",width:s=100,height:i=20,orientation:r="vertical"}=e,l="vertical"===r?(({legendGroups:e,width:t,customClickBehavior:n})=>{let o=30;const s=[];return e.forEach((e,i)=>{o+=5,s.push(a.createElement("line",{key:"legend-top-line legend-symbol-"+i,stroke:"gray",x1:0,y1:o,x2:t,y2:o})),o+=10,e.label&&(o+=20,s.push(a.createElement("text",{key:"legend-text-"+i,y:o,className:"legend-group-label"},e.label)),o+=10),s.push(a.createElement("g",{key:"legend-group-"+i,className:"legend-item",transform:`translate(0,${o})`},((e,t)=>{const{type:n="fill",styleFn:o,items:s}=e,i=[];let r=0;return s.forEach((e,s)=>{const l=j(e,s,n,o);i.push(a.createElement("g",{key:"legend-item-"+s,transform:`translate(0,${r})`,onClick:t?()=>t(e):void 0,style:{cursor:t?"pointer":"default"}},l,a.createElement("text",{y:15,x:30},e.label))),r+=25}),i})(e,n))),o+=25*e.items.length+10}),s})({legendGroups:t,width:s,customClickBehavior:n}):(({legendGroups:e,title:t,height:n,customClickBehavior:o})=>{let s=0;const i=[],r=!1===t?10:40;return e.forEach((t,l)=>{t.label&&(i.push(a.createElement("text",{key:"legend-text-"+l,transform:`translate(${s},${r}) rotate(90)`,textAnchor:"start",className:"legend-group-label"},t.label)),s+=20);const c=((e,t)=>{const{type:n="fill",styleFn:o,items:s}=e,i=[];let r=0;return s.forEach((e,s)=>{const l=j(e,s,n,o);i.push(a.createElement("g",{key:"legend-item-"+s,transform:`translate(${r},0)`,onClick:t?()=>t(e):void 0,style:{cursor:t?"pointer":"default"}},l,a.createElement("text",{y:15,x:25},e.label))),r+=35,r+=8*e.label.length}),{items:i,offset:r}})(t,o);i.push(a.createElement("g",{key:"legend-group-"+l,className:"legend-item",transform:`translate(${s},${r})`},c.items)),s+=c.offset+5,e[l+1]&&i.push(a.createElement("line",{key:"legend-top-line legend-symbol-"+l,stroke:"gray",x1:s,y1:r-10,x2:s,y2:n+r+10})),s+=15}),a.createElement("g",null,!1!==t&&a.createElement("line",{x1:0,x2:s+10,y1:r-10,y2:r-10,stroke:"gray",className:"title-neatline"}),i)})({legendGroups:t,title:o,height:i,customClickBehavior:n});return a.createElement("g",null,void 0!==o&&a.createElement("text",{className:"legend-title",y:20,x:"horizontal"===r?0:s/2,textAnchor:"horizontal"===r?"start":"middle"},o),l)}function _(e){return"string"==typeof e?{type:e}:e}function W({orient:t,config:n,values:o,scale:i,size:r,length:l}){const c=function(e){var t,n,o,s,i;return{type:e.type,bins:null!==(t=e.bins)&&void 0!==t?t:20,fill:null!==(n=e.fill)&&void 0!==n?n:"#4e79a7",fillOpacity:null!==(o=e.fillOpacity)&&void 0!==o?o:.5,stroke:null!==(s=e.stroke)&&void 0!==s?s:"none",strokeWidth:null!==(i=e.strokeWidth)&&void 0!==i?i:1}}(n),u="top"===t||"bottom"===t,h=e.useMemo(()=>{if(0===o.length)return null;const e=i.domain(),n=r-8;if("boxplot"===c.type){const e=function(e){const t=[...e].sort((e,t)=>e-t),n=t.length;if(0===n)return null;const o=t[Math.floor(.25*n)],s=t[Math.floor(.5*n)],i=t[Math.floor(.75*n)],r=i-o;return{q1:o,median:s,q3:i,whiskerLow:Math.max(t[0],o-1.5*r),whiskerHigh:Math.min(t[n-1],i+1.5*r)}}(o);if(!e)return null;const{q1:s,median:r,q3:l,whiskerLow:h,whiskerHigh:d}=e,f=Math.min(.5*n,20),p=(n-f)/2+4;if(u){const e=i(s),n=i(l),o=i(r),u=i(h),m=i(d),y="top"===t?-1:1,g=0;return a.createElement("g",{"data-testid":"marginal-boxplot-"+t},a.createElement("line",{x1:u,y1:g+y*(p+f/2),x2:m,y2:g+y*(p+f/2),stroke:c.fill,strokeWidth:c.strokeWidth}),a.createElement("line",{x1:u,y1:g+y*p,x2:u,y2:g+y*(p+f),stroke:c.fill,strokeWidth:c.strokeWidth}),a.createElement("line",{x1:m,y1:g+y*p,x2:m,y2:g+y*(p+f),stroke:c.fill,strokeWidth:c.strokeWidth}),a.createElement("rect",{x:Math.min(e,n),y:"top"===t?g-p-f:g+p,width:Math.abs(n-e),height:f,fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}),a.createElement("line",{x1:o,y1:"top"===t?g-p-f:g+p,x2:o,y2:"top"===t?g-p:g+p+f,stroke:c.fill,strokeWidth:2}))}{const e=i(s),n=i(l),o=i(r),u=i(h),m=i(d),y="left"===t?-1:1,g=0;return a.createElement("g",{"data-testid":"marginal-boxplot-"+t},a.createElement("line",{x1:g+y*(p+f/2),y1:u,x2:g+y*(p+f/2),y2:m,stroke:c.fill,strokeWidth:c.strokeWidth}),a.createElement("line",{x1:g+y*p,y1:u,x2:g+y*(p+f),y2:u,stroke:c.fill,strokeWidth:c.strokeWidth}),a.createElement("line",{x1:g+y*p,y1:m,x2:g+y*(p+f),y2:m,stroke:c.fill,strokeWidth:c.strokeWidth}),a.createElement("rect",{x:"left"===t?g-p-f:g+p,y:Math.min(e,n),width:f,height:Math.abs(n-e),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}),a.createElement("line",{x1:"left"===t?g-p-f:g+p,y1:o,x2:"left"===t?g-p:g+p+f,y2:o,stroke:c.fill,strokeWidth:2}))}}const h=s.bin().domain(e).thresholds(c.bins)(o);if(0===h.length)return null;const d=Math.max(...h.map(e=>e.length));if(0===d)return null;if("histogram"===c.type)return a.createElement("g",{"data-testid":"marginal-histogram-"+t},h.map((e,o)=>{if(null==e.x0||null==e.x1)return null;const s=e.length/d*n;if(u){const n=i(e.x0),r=i(e.x1)-i(e.x0);return a.createElement("rect",{key:o,x:n,y:"top"===t?-4-s:4,width:Math.max(r,.5),height:s,fill:c.fill,fillOpacity:c.fillOpacity,stroke:c.stroke,strokeWidth:c.strokeWidth})}{const n=i(e.x0),r=i(e.x1)-i(e.x0);return a.createElement("rect",{key:o,x:"left"===t?-4-s:4,y:Math.min(n,n+r),width:s,height:Math.abs(r),fill:c.fill,fillOpacity:c.fillOpacity,stroke:c.stroke,strokeWidth:c.strokeWidth})}}));if("violin"===c.type){const e=n/2+4,o=[];for(const s of h){if(null==s.x0||null==s.x1)continue;const r=s.length/d*(n/2),l=i((s.x0+s.x1)/2);o.push(u?`${l},${"top"===t?-(e-r):e-r}`:`${"left"===t?-(e-r):e-r},${l}`)}for(let s=h.length-1;s>=0;s--){const r=h[s];if(null==r.x0||null==r.x1)continue;const l=r.length/d*(n/2),a=i((r.x0+r.x1)/2);o.push(u?`${a},${"top"===t?-(e+l):e+l}`:`${"left"===t?-(e+l):e+l},${a}`)}return a.createElement("g",{"data-testid":"marginal-violin-"+t},a.createElement("polygon",{points:o.join(" "),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}))}if("ridgeline"===c.type){const e=[];if(u){const o=0,s=null!=h[0].x0?i(h[0].x0):0;e.push(`M${s},${o}`);for(const o of h){if(null==o.x0||null==o.x1)continue;const s=o.length/d*n,r=i((o.x0+o.x1)/2);e.push(`L${r},${"top"===t?-s-4:s+4}`)}const r=null!=h[h.length-1].x1?i(h[h.length-1].x1):l;e.push(`L${r},${o}`),e.push("Z")}else{const o=0,s=null!=h[0].x0?i(h[0].x0):0;e.push(`M${o},${s}`);for(const o of h){if(null==o.x0||null==o.x1)continue;const s=o.length/d*n,r=i((o.x0+o.x1)/2);e.push(`L${"left"===t?-s-4:s+4},${r}`)}const r=null!=h[h.length-1].x1?i(h[h.length-1].x1):l;e.push(`L${o},${r}`),e.push("Z")}return a.createElement("g",{"data-testid":"marginal-ridgeline-"+t},a.createElement("path",{d:e.join(" "),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}))}return null},[o,i,c,r,l,t,u,4]);return h?a.createElement("g",{className:"marginal-"+t,"data-testid":"marginal-"+t},h):null}function B(e,t=120,n=8){if(!e)return[];const o=Math.max(1,Math.floor(t/n)),s=e.split(/\s+/),i=[];let r="";for(const e of s)r&&r.length+1+e.length>o?(i.push(r),r=e):r=r?`${r} ${e}`:e;return r&&i.push(r),i}function $(e,t,n,o){return"curly"===e?o?`M0,0 C${.6*n},0 ${.4*n},${t/2} ${n},${t/2} C${.4*n},${t/2} ${.6*n},${t} 0,${t}`:`M0,0 C0,${.6*n} ${t/2},${.4*n} ${t/2},${n} C${t/2},${.4*n} ${t},${.6*n} ${t},0`:o?`M0,0 L${n},0 L${n},${t} L0,${t}`:`M0,0 L0,${n} L${t},${n} L${t},0`}function H(e){const{x:t=0,y:n=0,dx:o,dy:s,nx:i,ny:r,note:l,connector:c,subject:u,type:h,color:d,className:f,disable:p,events:m={},"data-testid":y}=e,g=new Set(Array.isArray(p)?p:[]);let b=o||0,v=s||0;null!=i&&(b=i-t),null!=r&&(v=r-n);const x="string"==typeof h?h:"label";if("bracket"===x&&u&&0===b&&0===v)if(void 0!==u.width){b=u.width/2;const e=u.depth||30;v=e+(0>e?-5:5)}else if(void 0!==u.height){const e=u.depth||30;b=e+(0>e?-5:5),v=u.height/2}return a.createElement("g",Object.assign({className:("annotation "+(f||"")).trim(),transform:`translate(${t},${n})`,"data-testid":y},m),!g.has("connector")&&function(e,t,n,o,s,i){const r=[];let l=0,c=0;if("callout-circle"!==s&&"label"!==s||!(null==i?void 0:i.radius)){if("callout-rect"===s&&i){const n=i.width||0,o=i.height||0;if(n>0||o>0){const s=n/2,i=o/2,r=e-s,a=t-i;if(0!==r||0!==a){const e=Math.abs(r),t=Math.abs(a),u=n/2,h=o/2,d=e*h>t*u?u/e:h/t;l=s+r*d,c=i+a*d}}}else if("bracket"===s&&i){const e=i.width,t=i.height,n=i.depth||30;void 0!==e?(l=e/2,c=n):void 0!==t&&(l=n,c=t/2)}}else{const n=(i.radius||0)+(i.radiusPadding||0);if(n>0&&(0!==e||0!==t)){const o=Math.atan2(t,e);l=Math.cos(o)*n,c=Math.sin(o)*n}}if(Math.sqrt(Math.pow(e-l,2)+Math.pow(t-c,2))>.5&&(r.push(a.createElement("line",{key:"connector-line",x1:l,y1:c,x2:e,y2:t,stroke:o||"currentColor"})),"arrow"===(null==n?void 0:n.end))){const n=10,s=16/180*Math.PI,i=Math.atan2(t-c,e-l);r.push(a.createElement("path",{key:"connector-arrow",d:`M${l},${c}L${l+n*Math.cos(i+s)},${c+n*Math.sin(i+s)}L${l+n*Math.cos(i-s)},${c+n*Math.sin(i-s)}Z`,fill:o||"currentColor",stroke:"none"}))}return a.createElement("g",{className:"annotation-connector"},r)}(b,v,c,d,x,u),!g.has("subject")&&function(e,t,n,o,s){var i;const r=[];switch(e){case"callout-circle":{const e=((null==t?void 0:t.radius)||0)+((null==t?void 0:t.radiusPadding)||0);e>0&&r.push(a.createElement("circle",{key:"subject-circle",r:e,fill:"none",stroke:n||"currentColor"}));break}case"callout-rect":{const e=(null==t?void 0:t.width)||0,o=(null==t?void 0:t.height)||0;(e>0||o>0)&&r.push(a.createElement("rect",{key:"subject-rect",width:e,height:o,fill:"none",stroke:n||"currentColor"}));break}case"callout-custom":(null==t?void 0:t.custom)&&r.push(...Array.isArray(t.custom)?t.custom:[t.custom]);break;case"xy-threshold":{const e=o||0,i=s||0;if(void 0!==(null==t?void 0:t.x)){const o=(t.x||0)-e;r.push(a.createElement("line",{key:"threshold-line",x1:o,y1:(t.y1||0)-i,x2:o,y2:(t.y2||0)-i,stroke:n||"currentColor",strokeDasharray:"5,5"}))}else if(void 0!==(null==t?void 0:t.y)){const o=(t.y||0)-i;r.push(a.createElement("line",{key:"threshold-line",x1:(t.x1||0)-e,y1:o,x2:(t.x2||0)-e,y2:o,stroke:n||"currentColor",strokeDasharray:"5,5"}))}else void 0!==(null==t?void 0:t.x1)||void 0!==(null==t?void 0:t.x2)?r.push(a.createElement("line",{key:"threshold-line",x1:(t.x1||0)-e,y1:0,x2:(t.x2||0)-e,y2:0,stroke:n||"currentColor",strokeDasharray:"5,5"})):void 0===(null==t?void 0:t.y1)&&void 0===(null==t?void 0:t.y2)||r.push(a.createElement("line",{key:"threshold-line",x1:0,y1:(t.y1||0)-i,x2:0,y2:(t.y2||0)-i,stroke:n||"currentColor",strokeDasharray:"5,5"}));break}case"bracket":{const e=null!==(i=null==t?void 0:t.width)&&void 0!==i?i:null==t?void 0:t.height;void 0!==e&&r.push(a.createElement("path",{key:"bracket-path",d:$((null==t?void 0:t.type)||"curly",e,(null==t?void 0:t.depth)||30,void 0===(null==t?void 0:t.width)),fill:"none",stroke:n||"currentColor"}));break}}return a.createElement("g",{className:"annotation-subject"},r)}(x,u,d,t,n),!g.has("note")&&function(e,t,n,o){if(!e)return a.createElement("g",{className:"annotation-note"});const{label:s,title:i,orientation:r,align:l,wrap:c=120,noWrap:u}=e;if(!s&&!i)return a.createElement("g",{className:"annotation-note"});let h=r;h||(h=Math.abs(t)>Math.abs(n)?"leftRight":"topBottom");let d=l;d&&"dynamic"!==d||(d="topBottom"===h?0>t?"right":"left":0>n?"bottom":"top");let f="start";"topBottom"===h?"right"===d?f="end":"middle"===d&&(f="middle"):f=0>t?"end":"start";const p=16,m=i?u?[i]:B(i,c):[],y=s?u?[s]:B(s,c):[],g="leftRight"===h?"end"===f?-4:4:0;let b=0;const v=[];m.length>0&&(v.push(a.createElement("text",{key:"annotation-note-title",className:"annotation-note-title",fill:o||void 0,textAnchor:f,fontWeight:"bold"},m.map((e,t)=>a.createElement("tspan",{key:t,x:g,dy:0===t?0:p},e)))),b=m.length*p),y.length>0&&v.push(a.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:o||void 0,textAnchor:f,y:b},y.map((e,t)=>a.createElement("tspan",{key:t,x:g,dy:0===t?0:p},e))));let x=null;if((i||s)&&(0!==t||0!==n))if("topBottom"===h){const e=Math.min(c,120);let t=0,n=e;"end"===f?(t=-e,n=0):"middle"===f&&(t=-e/2,n=e/2),x=a.createElement("line",{className:"note-line",x1:t,x2:n,y1:0,y2:0,stroke:o||"currentColor"})}else{const e=(m.length+y.length)*p+(y.length>0?p:0);let t=0,n=e;"bottom"===d?(t=-e,n=0):"middle"===d&&(t=-e/2,n=e/2),x=a.createElement("line",{className:"note-line",x1:0,x2:0,y1:t,y2:n,stroke:o||"currentColor"})}const w=Math.max(0,m.length+y.length-1)*p;let k=0;return"topBottom"===h?k=0>n?-(w+2):18:"leftRight"===h&&(k="middle"===d?-(w+p+(y.length>0&&m.length>0?2:0))/2+8:"bottom"===d||0>n?-(w+2):18),a.createElement("g",{className:"annotation-note",transform:`translate(${t},${n})`},a.createElement("g",{className:"annotation-note-content",transform:0!==k?`translate(0,${k})`:void 0},v),x)}(l,b,v,d))}function z(e){var t,n;const{noteData:o}=e,{screenCoordinates:s}=o,i="string"==typeof o.type?o.type:"label",r=o.eventListeners||o.events||{};if(o.coordinates&&s){const e=o.nx||s[0][0]+(null!==(t=o.dx)&&void 0!==t?t:0),r=o.ny||s[0][1]+(null!==(n=o.dy)&&void 0!==n?n:0),l=s.map((t,n)=>{const s=Object.assign({},o,{note:0===n?o.note:{label:""},x:t[0],y:t[1],nx:e,ny:r});return a.createElement(H,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+n},s,{type:i}))});return a.createElement("g",null,l)}const l=o.note||{title:"none",label:o.label};return a.createElement(H,Object.assign({"data-testid":"semiotic-annotation",key:`${l.label}-${l.title}-${o.i}`,events:r},o,{type:i}))}function T(e,t){var n,o,s;const i=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.x)&&void 0!==o?o:null===(s=t.scales)||void 0===s?void 0:s.time;return i?null!=e.x?i(e.x):t.xAccessor&&null!=e[t.xAccessor]?i(e[t.xAccessor]):null:null}function F(e,t){var n,o,s;const i=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.y)&&void 0!==o?o:null===(s=t.scales)||void 0===s?void 0:s.value;return i?null!=e.y?i(e.y):t.yAccessor&&null!=e[t.yAccessor]?i(e[t.yAccessor]):null:null}function P(e,t,n,o=50){return!(-o>e||e>(n.width||0)+o||-o>t||t>(n.height||0)+o)}function I(e,t,n){if("left"===e||"right"===e){const o="left"===e?n:0,s="left"===e?-1:1,i=Math.ceil(t/8);let r="M0,"+o;for(let e=0;i>e;e++){const n=8*(e+1);r+=`L${Math.min(8*e+4,t)},${o+4*s}`,r+=`L${Math.min(n,t)},${o}`}return r}{const o="bottom"===e?0:t,s="bottom"===e?1:-1,i=Math.ceil(n/8);let r=`M${o},0`;for(let e=0;i>e;e++){const t=8*(e+1);r+=`L${o+4*s},${Math.min(8*e+4,n)}`,r+=`L${o},${Math.min(t,n)}`}return r}}function D(e){return Math.round(100*e)/100+""}function R(t){const{width:n,height:o,totalWidth:s,totalHeight:r,margin:l,scales:c,showAxes:u,axes:h,xLabel:d,yLabel:f,xFormat:p,yFormat:m,showGrid:y,title:g,legend:b,foregroundGraphics:v,marginalGraphics:x,xValues:w,yValues:k,annotations:A,svgAnnotationRules:E,annotationFrame:M,xAccessor:S,yAccessor:O,annotationData:N,pointNodes:L,children:j}=t,B=e.useMemo(()=>u&&c?c.x.ticks(5).map(e=>({value:e,pixel:c.x(e),label:(p||D)(e)})):[],[u,c,p]),$=e.useMemo(()=>u&&c?c.y.ticks(5).map(e=>({value:e,pixel:c.y(e),label:(m||D)(e)})):[],[u,c,m]),H=e.useMemo(()=>{if(!A||0===A.length)return null;const e=function(e,t,n){var o,s,r,l,c,u,h,d,f,p,m,y,g,b,v,x,w,k,A,E,M,S,O,N,L,j,C,_,W,B,$,H,I,D,R,G,Y,X,q;switch(e.type){case"label":{let o=null,s=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);if(!t)return null;o=t.x,s=t.y}else o=T(e,n),s=F(e,n);return null==o||null==s?null:P(o,s,n)?a.createElement(z,{key:"ann-"+t,noteData:{x:o,y:s,dx:e.dx||30,dy:e.dy||-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"label",connector:e.connector||{end:"arrow"},color:e.color}}):null}case"callout":{let o=null,s=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);if(!t)return null;o=t.x,s=t.y}else o=T(e,n),s=F(e,n);return null==o||null==s?null:P(o,s,n)?a.createElement(z,{key:"ann-"+t,noteData:{x:o,y:s,dx:e.dx||30,dy:e.dy||-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"callout-circle",subject:{radius:e.radius||12},connector:e.connector||{end:"arrow"},color:e.color}}):null}case"x-threshold":{const o=T(e,n);if(null==o)return null;const s=e.color||"#f97316";return a.createElement("g",{key:"ann-"+t},a.createElement("line",{x1:o,y1:0,x2:o,y2:n.height||0,stroke:s,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&a.createElement("text",{x:o+4,y:12,fill:s,fontSize:12,fontWeight:"bold"},e.label))}case"y-threshold":{const o=F(e,n);if(null==o)return null;const s=e.color||"#f97316";return a.createElement("g",{key:"ann-"+t},a.createElement("line",{x1:0,y1:o,x2:n.width||0,y2:o,stroke:s,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&a.createElement("text",{x:(n.width||0)-4,y:o-4,textAnchor:"end",fill:s,fontSize:12,fontWeight:"bold"},e.label))}case"enclose":{const o=(e.coordinates||[]).map(e=>({x:T(Object.assign(Object.assign({},e),{type:"point"}),n),y:F(Object.assign(Object.assign({},e),{type:"point"}),n),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>o.length)return null;const s=i.packEnclose(o),r=e.padding||10;return a.createElement("g",{key:"ann-"+t},a.createElement("circle",{cx:s.x,cy:s.y,r:s.r+r,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&a.createElement("text",{x:s.x,y:s.y-s.r-r-4,textAnchor:"middle",fill:e.color||"#666",fontSize:12},e.label))}case"rect-enclose":{const o=(e.coordinates||[]).map(e=>({x:T(Object.assign(Object.assign({},e),{type:"point"}),n),y:F(Object.assign(Object.assign({},e),{type:"point"}),n)})).filter(e=>null!=e.x&&null!=e.y);if(2>o.length)return null;const s=e.padding||10,i=o.map(e=>e.x),r=o.map(e=>e.y),l=Math.min(...i)-s,c=Math.max(...i)+s,u=Math.min(...r)-s,h=Math.max(...r)+s;return a.createElement("g",{key:"ann-"+t},a.createElement("rect",{x:l,y:u,width:c-l,height:h-u,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&a.createElement("text",{x:(l+c)/2,y:u-4,textAnchor:"middle",fill:e.color||"#666",fontSize:12},e.label))}case"highlight":{const o=n.data||[],s="function"==typeof e.filter?o.filter(e.filter):e.field&&null!=e.value?o.filter(t=>t[e.field]===e.value):[],i=e.style||{stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return a.createElement("g",{key:"ann-"+t},s.map((t,o)=>{const s=T(t,n),r=F(t,n);return null==s||null==r?null:a.createElement("circle",Object.assign({key:o,cx:s,cy:r,r:e.r||6},i))}))}case"bracket":{const o=T(e,n),s=F(e,n);return a.createElement(z,{key:"ann-"+t,noteData:{x:null!=o?o:0,y:null!=s?s:0,dx:e.dx||0,dy:e.dy||0,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"bracket",subject:{type:e.bracketType||"curly",width:e.width,height:e.height,depth:e.depth||30},color:e.color}})}case"trend":{const i=n.data||[];if(2>i.length)return null;const d=n.xAccessor||"x",f=n.yAccessor||"y",p=i.map(e=>[e[d],e[f]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>p.length)return null;const m=null!==(s=null===(o=n.scales)||void 0===o?void 0:o.x)&&void 0!==s?s:null===(r=n.scales)||void 0===r?void 0:r.time,y=null!==(c=null===(l=n.scales)||void 0===l?void 0:l.y)&&void 0!==c?c:null===(u=n.scales)||void 0===u?void 0:u.value;if(!m||!y)return null;const g=e.method||"linear";let b;if("loess"===g)b=function(e,t=.3){const n=e.length;if(2>n)return e.slice();const o=e.slice().sort((e,t)=>e[0]-t[0]),s=o.map(e=>e[0]),i=o.map(e=>e[1]),r=Math.max(2,Math.ceil(t*n)),l=[];for(let e=0;n>e;e++){const t=s[e],o=s.map(e=>Math.abs(e-t)),a=o.slice().sort((e,t)=>e-t)[Math.min(r-1,n-1)]||1,c=[];for(let e=0;n>e;e++){const t=0===a?0:o[e]/a;c[e]=1>t?Math.pow(1-Math.pow(t,3),3):0}let u=0,h=0,d=0,f=0,p=0;for(let e=0;n>e;e++){const t=c[e];0!==t&&(u+=t,h+=t*s[e],d+=t*i[e],f+=t*s[e]*s[e],p+=t*s[e]*i[e])}if(0===u){l.push([t,i[e]]);continue}const m=u*f-h*h;if(1e-12>Math.abs(m))l.push([t,d/u]);else{const e=(u*p-h*d)/m;l.push([t,(d-e*h)/u+e*t])}}return l}(p,null!==(h=e.bandwidth)&&void 0!==h?h:.3);else{let t;try{const n=require("regression");t="polynomial"===g?n.polynomial(p,{order:e.order||2}):n.linear(p)}catch(e){return null}b=t.points}const v=b.map(([e,t])=>`${m(e)},${y(t)}`).join(" "),x=e.color||"#6366f1";return a.createElement("g",{key:"ann-"+t},a.createElement("polyline",{points:v,fill:"none",stroke:x,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&a.createElement("text",{x:m(b[b.length-1][0])+4,y:y(b[b.length-1][1])-4,fill:x,fontSize:11},e.label))}case"band":{const o=null!==(f=null===(d=n.scales)||void 0===d?void 0:d.y)&&void 0!==f?f:null===(p=n.scales)||void 0===p?void 0:p.value,s=null!==(m=null==o?void 0:o(e.y0))&&void 0!==m?m:0,i=null!==(y=null==o?void 0:o(e.y1))&&void 0!==y?y:n.height||0;return a.createElement("g",{key:"ann-"+t},a.createElement("rect",{x:0,y:Math.min(s,i),width:n.width||0,height:Math.abs(i-s),fill:e.fill||"#6366f1",fillOpacity:e.fillOpacity||.1}),e.label&&a.createElement("text",{x:(n.width||0)-4,y:Math.min(s,i)-4,textAnchor:"end",fill:e.color||"#6366f1",fontSize:11},e.label))}case"envelope":{const o=n.data||[];if(2>o.length)return null;const s=n.xAccessor||"x",i=null!==(b=null===(g=n.scales)||void 0===g?void 0:g.x)&&void 0!==b?b:null===(v=n.scales)||void 0===v?void 0:v.time,r=null!==(w=null===(x=n.scales)||void 0===x?void 0:x.y)&&void 0!==w?w:null===(k=n.scales)||void 0===k?void 0:k.value;if(!i||!r)return null;const l=e.upperAccessor||"upperBounds",c=e.lowerAccessor||"lowerBounds",u=e.filter,h=o.filter(e=>null!=e[l]&&null!=e[c]&&!(u&&!u(e))).sort((e,t)=>e[s]-t[s]);if(2>h.length)return null;const d=h.map(e=>`${i(e[s])},${r(e[l])}`).join(" L"),f=h.slice().reverse().map(e=>`${i(e[s])},${r(e[c])}`).join(" L"),p=e.fill||"#6366f1";return a.createElement("g",{key:"ann-"+t},a.createElement("path",{d:`M${d} L${f} Z`,fill:p,fillOpacity:null!==(A=e.fillOpacity)&&void 0!==A?A:.15,stroke:"none"}),e.label&&h.length>0&&a.createElement("text",{x:i(h[h.length-1][s])+4,y:r(h[h.length-1][l])-4,fill:p,fontSize:11},e.label))}case"anomaly-band":{const o=n.data||[];if(2>o.length)return null;const s=n.yAccessor||"y",i=null!==(M=null===(E=n.scales)||void 0===E?void 0:E.x)&&void 0!==M?M:null===(S=n.scales)||void 0===S?void 0:S.time,r=null!==(N=null===(O=n.scales)||void 0===O?void 0:O.y)&&void 0!==N?N:null===(L=n.scales)||void 0===L?void 0:L.value;if(!i||!r)return null;const l=o.map(e=>e[s]).filter(e=>null!=e&&isFinite(e));if(2>l.length)return null;const c=l.reduce((e,t)=>e+t,0)/l.length,u=l.reduce((e,t)=>e+Math.pow(t-c,2),0)/l.length,h=Math.sqrt(u),d=null!==(j=e.threshold)&&void 0!==j?j:2,f=c-d*h,p=!1!==e.showBand,m=e.fill||"#6366f1",y=null!==(C=e.fillOpacity)&&void 0!==C?C:.1,g=e.anomalyColor||"#ef4444",b=null!==(_=e.anomalyRadius)&&void 0!==_?_:6,v=r(c+d*h),x=r(f),w=o.filter(e=>{const t=e[s];return null!=t&&Math.abs(t-c)>d*h});return a.createElement("g",{key:"ann-"+t},p&&a.createElement("rect",{x:0,y:Math.min(v,x),width:n.width||0,height:Math.abs(x-v),fill:m,fillOpacity:y}),w.map((e,t)=>{const o=T(e,n),s=F(e,n);return null==o||null==s?null:a.createElement("circle",{key:t,cx:o,cy:s,r:b,fill:g,fillOpacity:.7,stroke:g,strokeWidth:1.5})}),e.label&&a.createElement("text",{x:(n.width||0)-4,y:Math.min(v,x)-4,textAnchor:"end",fill:m,fontSize:11},e.label))}case"forecast":{const o=n.data||[];if(3>o.length)return null;const s=n.xAccessor||"x",i=n.yAccessor||"y",r=null!==(B=null===(W=n.scales)||void 0===W?void 0:W.x)&&void 0!==B?B:null===($=n.scales)||void 0===$?void 0:$.time,l=null!==(I=null===(H=n.scales)||void 0===H?void 0:H.y)&&void 0!==I?I:null===(D=n.scales)||void 0===D?void 0:D.value;if(!r||!l)return null;const c=o.map(e=>[e[s],e[i]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]);if(3>c.length)return null;let u;if("polynomial"===(e.method||"linear"))try{const t=require("regression").polynomial(c,{order:e.order||2}).equation;u=e=>t.reduce((t,n,o)=>t+n*Math.pow(e,o),0)}catch(e){return null}else{const e=c.length;let t=0,n=0,o=0,s=0;for(const[e,i]of c)t+=e,n+=i,o+=e*e,s+=e*i;const i=e*o-t*t;if(1e-12>Math.abs(i))return null;const r=(e*s-t*n)/i,l=(n-r*t)/e;u=e=>l+r*e}const h=c.length,d=c.map(([e,t])=>t-u(e)).reduce((e,t)=>e+t*t,0),f=Math.sqrt(d/Math.max(h-2,1)),p=c.reduce((e,t)=>e+t[0],0)/h,m=c.reduce((e,t)=>e+Math.pow(t[0]-p,2),0),y=null!==(R=e.confidence)&&void 0!==R?R:.95,g=.99>y?.95>y?.9>y?1:1.645:1.96:2.576,b=null!==(G=e.steps)&&void 0!==G?G:5,v=c[h-1][0],x=(v-c[0][0])/Math.max(h-1,1),w=[];for(let e=1;b>=e;e++)w.push(v+e*x);const k=[];for(const e of w){const t=u(e),n=f*Math.sqrt(1+1/h+(m>0?Math.pow(e-p,2)/m:0))*g;k.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const A=`M${k.map(e=>`${r(e.x)},${l(e.yUpper)}`).join(" L")} L${k.slice().reverse().map(e=>`${r(e.x)},${l(e.yLower)}`).join(" L")} Z`,E=k.map(e=>`${r(e.x)},${l(e.yCenter)}`).join(" "),M=`${r(v)},${l(u(v))}`,S=e.strokeColor||"#6366f1";return a.createElement("g",{key:"ann-"+t},a.createElement("path",{d:A,fill:e.fill||"#6366f1",fillOpacity:null!==(Y=e.fillOpacity)&&void 0!==Y?Y:.15,stroke:"none"}),a.createElement("polyline",{points:`${M} ${E}`,fill:"none",stroke:S,strokeWidth:null!==(X=e.strokeWidth)&&void 0!==X?X:2,strokeDasharray:null!==(q=e.strokeDasharray)&&void 0!==q?q:"6,3"}),e.label&&k.length>0&&a.createElement("text",{x:r(k[k.length-1].x)+4,y:l(k[k.length-1].yCenter)-4,fill:S,fontSize:11},e.label))}default:return null}},t={scales:c?{x:c.x,y:c.y,time:c.x,value:c.y}:null,timeAxis:"x",xAccessor:S,yAccessor:O,width:n,height:o,data:N,frameType:"xy",pointNodes:L};return A.map((n,o)=>{if(E){const s=E(n,o,t);return null!=s?s:e(n,o,t)}return e(n,o,t)}).filter(Boolean)},[A,E,n,o,M,S,O,N]);return u||g||b||v||x||H&&H.length>0||y||j?a.createElement("svg",{width:s,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},a.createElement("g",{transform:`translate(${l.left},${l.top})`},y&&c&&a.createElement("g",{className:"stream-grid"},B.map((e,t)=>a.createElement("line",{key:"xgrid-"+t,x1:e.pixel,y1:0,x2:e.pixel,y2:o,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1})),$.map((e,t)=>a.createElement("line",{key:"ygrid-"+t,x1:0,y1:e.pixel,x2:n,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),u&&c&&(()=>{const e=null==h?void 0:h.find(e=>"left"===e.orient),t=null==h?void 0:h.find(e=>"bottom"===e.orient),s=!e||!1!==e.baseline,i=(null==e?void 0:e.jaggedBase)||!1,r=(null==t?void 0:t.jaggedBase)||!1,c="var(--semiotic-border, #ccc)",u="var(--semiotic-text-secondary, #666)",p="var(--semiotic-text, #333)";return a.createElement("g",{className:"stream-axes"},(!t||!1!==t.baseline)&&!r&&a.createElement("line",{x1:0,y1:o,x2:n,y2:o,stroke:c,strokeWidth:1}),r&&a.createElement("path",{d:I("bottom",n,o),fill:"none",stroke:c,strokeWidth:1}),B.map((e,t)=>a.createElement("g",{key:"xtick-"+t,transform:`translate(${e.pixel},${o})`},a.createElement("line",{y2:5,stroke:c,strokeWidth:1}),a.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:u,style:{userSelect:"none"}},e.label))),d&&a.createElement("text",{x:n/2,y:o+40,textAnchor:"middle",fontSize:12,fill:p,style:{userSelect:"none"}},d),s&&!i&&a.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:c,strokeWidth:1}),i&&a.createElement("path",{d:I("left",n,o),fill:"none",stroke:c,strokeWidth:1}),$.map((e,t)=>a.createElement("g",{key:"ytick-"+t,transform:`translate(0,${e.pixel})`},a.createElement("line",{x2:-5,stroke:c,strokeWidth:1}),a.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:u,style:{userSelect:"none"}},e.label))),f&&a.createElement("text",{x:15-l.left,y:o/2,textAnchor:"middle",fontSize:12,fill:p,transform:`rotate(-90, ${15-l.left}, ${o/2})`,style:{userSelect:"none"}},f))})(),H,x&&c&&w&&k&&a.createElement(a.Fragment,null,x.top&&a.createElement("g",{transform:"translate(0, 0)"},a.createElement(W,{orient:"top",config:_(x.top),values:w,scale:c.x,size:l.top,length:n})),x.bottom&&a.createElement("g",{transform:`translate(0, ${o})`},a.createElement(W,{orient:"bottom",config:_(x.bottom),values:w,scale:c.x,size:l.bottom,length:n})),x.left&&a.createElement("g",{transform:"translate(0, 0)"},a.createElement(W,{orient:"left",config:_(x.left),values:k,scale:c.y,size:l.left,length:o})),x.right&&a.createElement("g",{transform:`translate(${n}, 0)`},a.createElement(W,{orient:"right",config:_(x.right),values:k,scale:c.y,size:l.right,length:o}))),v,j),g&&a.createElement("text",{x:s/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof g?g:null),b&&a.createElement("g",{transform:`translate(${s-l.right+10}, ${l.top})`},"object"==typeof(R=b)&&null!==R&&!a.isValidElement(R)&&"legendGroups"in R?a.createElement(C,{legendGroups:b.legendGroups,title:"",width:100}):b)):null;var R}function G(e,t,n){let o=n;for(const n of t)"lesser"===n.thresholdType?n.value>e&&(o=n.color):e>n.value&&(o=n.color);return o}function Y(e){if(e.startsWith("#")){const t=4===e.length?e[1]+e[1]+e[2]+e[2]+e[3]+e[3]:e.slice(1,7);return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[78,121,167]}const X=(e,t,n,o)=>{var s;const i=t.filter(e=>"area"===e.type);for(const t of i){if(2>t.topPath.length)continue;e.beginPath();const[n,o]=t.topPath[0];e.moveTo(n,o);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1]);for(let n=t.bottomPath.length-1;n>=0;n--)e.lineTo(t.bottomPath[n][0],t.bottomPath[n][1]);e.closePath();const i=t.style.fill||"#4e79a7";if(t.fillGradient){const n=Math.min(...t.topPath.map(e=>e[1])),o=Math.max(...t.bottomPath.map(e=>e[1])),s=e.createLinearGradient(0,n,0,o);s.addColorStop(0,i),s.addColorStop(1,i),e.fillStyle=s;const r=Y(i),l=t.fillGradient.topOpacity,a=t.fillGradient.bottomOpacity,c=e.createLinearGradient(0,n,0,o);c.addColorStop(0,`rgba(${r[0]},${r[1]},${r[2]},${l})`),c.addColorStop(1,`rgba(${r[0]},${r[1]},${r[2]},${a})`),e.fillStyle=c,e.globalAlpha=1}else{const n=null!==(s=t.style.fillOpacity)&&void 0!==s?s:.7;e.globalAlpha=n,e.fillStyle=i}if(e.fill(),t.style.stroke&&"none"!==t.style.stroke){e.globalAlpha=1,e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]),e.beginPath(),e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1]);e.stroke()}e.globalAlpha=1}},q=(e,t,n,o)=>{var s,i;const r=t.filter(e=>"point"===e.type);for(const t of r){e.beginPath(),e.arc(t.x,t.y,t.r,0,2*Math.PI);const n=null!==(s=t.style.opacity)&&void 0!==s?s:t.style.fillOpacity;if(null!=n&&(e.globalAlpha=n),e.fillStyle=t.style.fill||"#4e79a7",e.fill(),t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()),t._pulseIntensity&&t._pulseIntensity>0){const n=null!==(i=t._pulseGlowRadius)&&void 0!==i?i:4,o=t.r+n*t._pulseIntensity;e.beginPath(),e.arc(t.x,t.y,o,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=.6*t._pulseIntensity,e.stroke()}e.globalAlpha=1}},V=(e,t,n,o)=>{const s=t.filter(e=>"rect"===e.type);for(const t of s)null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.icon?U(e,t):(e.fillStyle=t.style.fill||"#007bff",e.fillRect(t.x,t.y,t.w,t.h),t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.strokeRect(t.x,t.y,t.w,t.h))),t._pulseIntensity&&t._pulseIntensity>0&&(e.globalAlpha=.3*t._pulseIntensity,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h)),e.globalAlpha=1};function U(e,t){const n=t.style.icon,o=t.style.iconPadding||2,s=Math.min(t.w,t.w)-o;if(0>=s)return;const i=t.h>t.w;if(e.save(),e.beginPath(),e.rect(t.x,t.y,t.w,t.h),e.clip(),i){const i=s+o,r=t.x+(t.w-s)/2;for(let o=t.y+t.h-s;o>=t.y-s;o-=i)e.drawImage(n,r,o,s,s)}else{const i=s+o,r=t.y+(t.h-s)/2;for(let o=t.x;t.x+t.w>o;o+=i)e.drawImage(n,o,r,s,s)}e.restore()}const Z={line:[X,(e,t,n,o)=>{const s=t.filter(e=>"line"===e.type);for(const i of s){if(2>i.path.length)continue;const r=i.style.stroke||"#007bff",l=i.style.strokeWidth||2,a=i.colorThresholds,c=i.rawValues;if(e.setLineDash(i.style.strokeDasharray?i.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=i.style.opacity&&(e.globalAlpha=i.style.opacity),e.lineWidth=l,a&&0!==a.length&&c&&c.length===i.path.length){let u=null,h=null,d=null,f=null,p=!1;function m(t,n,o){e.beginPath(),e.strokeStyle=t,e.moveTo(n,o),p=!0}function y(){p&&(e.stroke(),p=!1)}for(let g=0;i.path.length>g;g++){const[b,v]=i.path[g],x=c[g],w=G(x,a,r);if(null!==u&&null!==f&&null!==d){if(w===f)e.lineTo(b,v);else{const k=[];for(const A of a){const E=A.value;(d>E||E>x)&&(E>d||x>E)||d===E||x===E||k.push({t:(E-d)/(x-d)})}k.sort((e,t)=>e.t-t.t);for(const M of k){const S=u+(b-u)*M.t,O=h+(v-h)*M.t,N=G(d+(x-d)*Math.min(M.t+1e-4,1),a,r);e.lineTo(S,O),y(),m(N,S,O)}e.lineTo(b,v)}u=b,h=v,d=x,f=w}else m(w,b,v),u=b,h=v,d=x,f=w}y()}else{e.beginPath(),e.strokeStyle=r;const[L,j]=i.path[0];e.moveTo(L,j);for(let C=1;i.path.length>C;C++)e.lineTo(i.path[C][0],i.path[C][1]);e.stroke()}if(i.style.fill&&i.style.fillOpacity&&i.style.fillOpacity>0){e.beginPath(),e.globalAlpha=i.style.fillOpacity,e.fillStyle=i.style.fill;const[_,W]=i.path[0];e.moveTo(_,W);for(let $=1;i.path.length>$;$++)e.lineTo(i.path[$][0],i.path[$][1]);const B=i.path[0][0];e.lineTo(i.path[i.path.length-1][0],o.height),e.lineTo(B,o.height),e.closePath(),e.fill()}e.globalAlpha=1,e.setLineDash([])}}],area:[X],stackedarea:[X],scatter:[q],bubble:[q],heatmap:[(e,t,n,o)=>{const s=t.filter(e=>"heatcell"===e.type);for(const t of s){const n=t.style;null!=(null==n?void 0:n.opacity)&&(e.globalAlpha=n.opacity),e.fillStyle=t.fill,e.fillRect(t.x,t.y,t.w,t.h),e.strokeStyle="#fff",e.lineWidth=1,e.strokeRect(t.x,t.y,t.w,t.h),t._pulseIntensity&&t._pulseIntensity>0&&(e.globalAlpha=.3*t._pulseIntensity,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h)),e.globalAlpha=1}}],bar:[V],swarm:[q],waterfall:[(e,t,n,o)=>{var s,i,r;V(e,t);const l=t.filter(e=>"rect"===e.type);if(2>l.length)return;const a=l[0].datum,c=null==a?void 0:a._connectorStroke;if(c){e.save(),e.strokeStyle=c,e.lineWidth=null!==(s=null==a?void 0:a._connectorWidth)&&void 0!==s?s:1,e.setLineDash([]);for(let t=0;l.length-1>t;t++){const o=l[t],s=l[t+1];if(!(null===(i=o.datum)||void 0===i?void 0:i.cumEnd)||!(null===(r=s.datum)||void 0===r?void 0:r.baseline))continue;const a=n.y(o.datum.cumEnd),c=o.x+o.w,u=s.x;e.beginPath(),e.moveTo(c,a),e.lineTo(u,a),e.stroke()}e.restore()}}],candlestick:[(e,t,n,o)=>{for(const n of t){if("candlestick"!==n.type)continue;const t=n;e.beginPath(),e.moveTo(t.x,t.highY),e.lineTo(t.x,t.lowY),e.strokeStyle=t.wickColor,e.lineWidth=t.wickWidth,e.stroke();const o=Math.min(t.openY,t.closeY),s=Math.abs(t.openY-t.closeY),i=t.isUp?t.upColor:t.downColor;e.fillStyle=i,e.fillRect(t.x-t.bodyWidth/2,o,t.bodyWidth,Math.max(s,1)),e.strokeStyle=i,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,o,t.bodyWidth,Math.max(s,1))}}]},J={top:20,right:20,bottom:30,left:40},K={axisStroke:"#ccc",tickText:"#666",crosshair:"rgba(0, 0, 0, 0.25)",hoverFill:"rgba(255, 255, 255, 0.3)",hoverStroke:"rgba(0, 0, 0, 0.4)",pointRing:"white"},Q={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,lineHeight:1.5,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function ee({hover:e}){const t=e=>Number.isInteger(e)?e+"":e.toFixed(2);return a.createElement("div",{className:"semiotic-tooltip",style:Q},a.createElement("div",{style:{fontWeight:600,marginBottom:2}},t(e.value)),a.createElement("div",{style:{opacity:.7,fontSize:11}},t(e.time)))}function te({width:o,height:s,totalWidth:i,totalHeight:r,margin:l,dimension:c,scales:u,onBrush:h}){const d=e.useRef(null),f=e.useRef(null);return e.useEffect(()=>{if(!d.current)return;const e=n.select(d.current).select(".brush-g"),i="x"===c?t.brushX():"y"===c?t.brushY():t.brush();return i.extent([[0,0],[o,s]]),i.on("brush end",e=>{if(!u)return;if(!e.selection)return void h(null);let t,n;if("x"===c){const[o,i]=e.selection;t=[u.x.invert(o),u.x.invert(i)],n=[u.y.invert(s),u.y.invert(0)]}else if("y"===c){const[s,i]=e.selection;t=[u.x.invert(0),u.x.invert(o)],n=[u.y.invert(i),u.y.invert(s)]}else{const[[o,s],[i,r]]=e.selection;t=[u.x.invert(o),u.x.invert(i)],n=[u.y.invert(r),u.y.invert(s)]}h({x:t,y:n})}),e.call(i),f.current=i,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{i.on("brush end",null),f.current=null}},[o,s,c,u,h]),a.createElement("svg",{ref:d,width:i,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},a.createElement("g",{className:"brush-g",transform:`translate(${l.left},${l.top})`}))}const ne=e.forwardRef(function(t,n){var o,s,i;const{chartType:r,runtimeMode:l,data:c,xAccessor:h,yAccessor:d,colorAccessor:f,sizeAccessor:p,groupAccessor:m,lineDataAccessor:y,normalize:g,binSize:b,valueAccessor:v,arrowOfTime:x="right",windowMode:N="sliding",windowSize:L=200,timeAccessor:j,xExtent:C,yExtent:_,extentPadding:W=.1,sizeRange:B,size:$=[500,300],responsiveWidth:H,responsiveHeight:z,margin:T,className:F,background:P,lineStyle:I,pointStyle:D,areaStyle:G,waterfallStyle:Y,swarmStyle:X,barColors:q,colorScheme:V,boundsAccessor:U,boundsStyle:Q,y0Accessor:ne,gradientFill:oe,openAccessor:se,highAccessor:ie,lowAccessor:re,closeAccessor:le,candlestickStyle:ae,showAxes:ce=!0,axes:ue,xLabel:he,yLabel:de,xFormat:fe,yFormat:pe,tickFormatTime:me,tickFormatValue:ye,hoverAnnotation:ge,tooltipContent:be,customHoverBehavior:ve,enableHover:xe,annotations:we,svgAnnotationRules:ke,showGrid:Ae,legend:Ee,backgroundGraphics:Me,foregroundGraphics:Se,title:Oe,categoryAccessor:Ne,brush:Le,onBrush:je,decay:Ce,pulse:_e,transition:We,staleness:Be,heatmapAggregation:$e,heatmapXBins:He,heatmapYBins:ze,marginalGraphics:Te,pointIdAccessor:Fe}=t,[Pe,Ie]=function(t,n,o){const s=e.useRef(null),[i,r]=e.useState(null);return e.useEffect(()=>{if(!n&&!o)return;const e=s.current;if(!e)return;const t=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;r(t=>t&&t.w===e&&t.h===n?t:{w:e,h:n})}});return t.observe(e),()=>t.disconnect()},[n,o]),[s,[n&&i?i.w:t[0],o&&i?i.h:t[1]]]}($,H,z),De=Object.assign(Object.assign({},J),T);if(Te){const e=60;Te.top&&e>De.top&&(De.top=e),Te.bottom&&e>De.bottom&&(De.bottom=e),Te.left&&e>De.left&&(De.left=e),Te.right&&e>De.right&&(De.right=e)}const Re=Ie[0]-De.left-De.right,Ge=Ie[1]-De.top-De.bottom,Ye=null!=ge?ge:xe,Xe=e.useRef(null),qe=e.useRef(0),Ve=e.useRef(!1),[Ue,Ze]=e.useState(0),[Je,Ke]=e.useState(null),Qe=e.useRef(null),et=e.useRef(null),[tt,nt]=e.useState(null),[ot,st]=e.useState(!1),[it,rt]=e.useState([]),[lt,at]=e.useState([]),ct=e.useRef(()=>{}),ut="streaming"===l||["bar","swarm","waterfall"].includes(r),ht=e.useMemo(()=>({chartType:r,runtimeMode:ut?"streaming":"bounded",windowSize:L,windowMode:N,arrowOfTime:ut?x:"right",extentPadding:W,xAccessor:ut?void 0:h,yAccessor:ut?void 0:d,timeAccessor:ut?j:void 0,valueAccessor:v,colorAccessor:f,sizeAccessor:p,groupAccessor:m,categoryAccessor:Ne,lineDataAccessor:y,xExtent:C,yExtent:_,sizeRange:B,binSize:b,normalize:g,boundsAccessor:U,boundsStyle:Q,y0Accessor:ne,gradientFill:"boolean"==typeof oe?oe?{topOpacity:.8,bottomOpacity:.05}:void 0:oe,openAccessor:se,highAccessor:ie,lowAccessor:re,closeAccessor:le,candlestickStyle:ae,lineStyle:I,pointStyle:D,areaStyle:G,swarmStyle:X,waterfallStyle:Y,colorScheme:V,barColors:q,annotations:we,decay:Ce,pulse:_e,transition:We,staleness:Be,heatmapAggregation:$e,heatmapXBins:He,heatmapYBins:ze,pointIdAccessor:Fe}),[r,L,N,x,W,h,d,j,v,f,p,m,Ne,y,C,_,B,b,g,U,Q,ne,oe,se,ie,re,le,ae,I,D,G,X,Y,V,q,we,Ce,_e,We,Be,$e,He,ze,ut,Fe]),dt=e.useRef(null);dt.current||(dt.current=new w(ht));const ft=e.useCallback(()=>{qe.current||(qe.current=requestAnimationFrame(()=>ct.current()))},[]);e.useEffect(()=>{var e;null===(e=dt.current)||void 0===e||e.updateConfig(ht),Ve.current=!0,ft()},[ht,ft]);const pt=e.useRef(null);pt.current||(pt.current=new u(e=>{const t=dt.current;t&&t.ingest(e)&&(Ve.current=!0,ft())}));const mt=e.useCallback(e=>{var t;null===(t=pt.current)||void 0===t||t.push(e)},[]),yt=e.useCallback(e=>{var t;null===(t=pt.current)||void 0===t||t.pushMany(e)},[]),gt=e.useCallback(()=>{var e,t;null===(e=pt.current)||void 0===e||e.clear(),null===(t=dt.current)||void 0===t||t.clear(),Ve.current=!0,ft()},[ft]);e.useImperativeHandle(n,()=>({push:mt,pushMany:yt,clear:gt,getData:()=>{var e,t;return null!==(t=null===(e=dt.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=dt.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null},getExtents:()=>{var e,t;return null!==(t=null===(e=dt.current)||void 0===e?void 0:e.getExtents())&&void 0!==t?t:null}}),[mt,yt,gt]),e.useEffect(()=>{var e;c&&(null===(e=pt.current)||void 0===e||e.setBoundedData(c))},[c]);const bt=e.useRef(()=>{}),vt=e.useRef(()=>{});bt.current=e=>{if(!Ye)return;const t=Xe.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-De.left,s=e.clientY-n.top-De.top;if(0>o||o>Re||0>s||s>Ge)return void(Qe.current&&(Qe.current=null,et.current=null,nt(null),ve&&(ve(null),Ve.current=!0),ft()));const i=dt.current;if(!i||0===i.scene.length)return;const r=function(e,t,n,o=30){let s=null;for(const i of e){let e=null;switch(i.type){case"point":e=k(i,t,n);break;case"line":e=A(i,t,n);break;case"rect":e=E(i,t,n);break;case"heatcell":e=M(i,t,n);break;case"area":if(!1===i.interactive)break;e=O(i,t,n);break;case"candlestick":e=S(i,t,n)}e&&o>e.distance&&(s&&e.distance>=s.distance||(s=e))}return s}(i.scene,o,s);if(!r)return void(Qe.current&&(Qe.current=null,et.current=null,nt(null),ve&&ve(null),ft()));const l={data:r.datum,time:r.x,value:r.y,x:r.x,y:r.y};Qe.current=l,et.current=r.node,nt(l),ve&&(ve(l),Ve.current=!0),ft()},vt.current=()=>{Qe.current&&(Qe.current=null,et.current=null,nt(null),ve&&(ve(null),Ve.current=!0),ft())},e.useCallback(e=>bt.current(e),[]);const xt=e.useCallback(()=>vt.current(),[]),wt=e.useRef(-1),kt=e.useCallback(e=>{const t=dt.current;if(!t||0===t.scene.length)return;const n=function(e){const t=[];for(const n of e)switch(n.type){case"point":t.push({x:n.x,y:n.y,datum:n.datum});break;case"line":{const e=n,o=Array.isArray(e.datum)?e.datum:[];for(let n=0;e.path.length>n&&o.length>n;n++)t.push({x:e.path[n][0],y:e.path[n][1],datum:o[n]});break}case"area":{const e=n,o=Array.isArray(e.datum)?e.datum:[];for(let n=0;e.topPath.length>n&&o.length>n;n++)t.push({x:e.topPath[n][0],y:e.topPath[n][1],datum:o[n]});break}case"rect":case"heatcell":t.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum})}return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}(t.scene);if(0===n.length)return;const o=0>wt.current?-1:wt.current,s=function(e,t,n){switch(e){case"ArrowRight":case"ArrowDown":return n-1>t?t+1:t;case"ArrowLeft":case"ArrowUp":return t>0?t-1:t;case"Home":return 0;case"End":return n-1;case"Escape":return-1;default:return null}}(e.key,0>o?-1:o,n.length);if(null===s)return;if(e.preventDefault(),0>s)return wt.current=-1,Qe.current=null,et.current=null,nt(null),ve&&ve(null),void ft();const i=0>o?0:s;wt.current=i;const r={data:(l=n[i]).datum,x:l.x,y:l.y,time:l.x,value:l.y};var l;Qe.current=r,nt(r),ve&&ve(r),ft()},[ve,ft]),At=e.useCallback(e=>{wt.current=-1,bt.current(e)},[]);ct.current=()=>{var e,t;qe.current=0;const n=Xe.current;if(!n)return;const o=n.getContext("2d");if(!o)return;const s=dt.current;if(!s)return;const i="undefined"!=typeof performance?performance.now():Date.now(),l=s.advanceTransition(i);l||s.computeScene({width:Re,height:Ge});const a="undefined"!=typeof window&&window.devicePixelRatio||1;n.width=Ie[0]*a,n.height=Ie[1]*a,n.style.width=Ie[0]+"px",n.style.height=Ie[1]+"px",o.scale(a,a),o.translate(De.left,De.top),o.clearRect(-De.left,-De.top,Ie[0],Ie[1]);const c=function(e){if(!e)return K;const t=getComputedStyle(e),n=t.getPropertyValue("--semiotic-border").trim(),o=t.getPropertyValue("--semiotic-text-secondary").trim(),s=t.getPropertyValue("--semiotic-bg").trim(),i=o||t.getPropertyValue("--text-secondary").trim(),r=t.getPropertyValue("--text-primary").trim(),l=n||t.getPropertyValue("--surface-3").trim(),a=s||t.getPropertyValue("--surface-0").trim();return i||r||n?{axisStroke:l||K.axisStroke,tickText:i||K.tickText,crosshair:i?i+"66":K.crosshair,hoverFill:a?a+"4D":K.hoverFill,hoverStroke:i?i+"99":K.hoverStroke,pointRing:a||K.pointRing}:K}(n),u=null!==(e=null==Be?void 0:Be.threshold)&&void 0!==e?e:5e3,f=Be&&s.lastIngestTime>0&&i-s.lastIngestTime>u;f&&(o.globalAlpha=null!==(t=null==Be?void 0:Be.dimOpacity)&&void 0!==t?t:.5);const p=n?getComputedStyle(n).getPropertyValue("--semiotic-bg").trim():"",m=P||(p&&"transparent"!==p?p:null);m&&(o.fillStyle=m,o.fillRect(-De.left,-De.top,Ie[0],Ie[1])),o.save(),"function"==typeof o.rect&&(o.beginPath(),o.rect(0,0,Re,Ge),o.clip());const y=Z[r];if(y&&s.scales)for(const e of y)e(o,s.scene,s.scales,{width:Re,height:Ge});if(o.restore(),f&&(o.globalAlpha=1),Ye&&Qe.current&&s.scales&&function(e,t,n,o,s,i,r){if(!1===s.crosshair)return;e.save();const l="object"==typeof s.crosshair?s.crosshair:{};e.strokeStyle=l.stroke||r.crosshair,e.lineWidth=l.strokeWidth||1,e.setLineDash(l.strokeDasharray?l.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),e.beginPath(),e.moveTo(t.x,0),e.lineTo(t.x,o),e.stroke(),e.beginPath(),e.moveTo(0,t.y),e.lineTo(n,t.y),e.stroke(),e.restore(),e.beginPath(),e.arc(t.x,t.y,4,0,2*Math.PI),e.fillStyle="#007bff",e.fill(),e.strokeStyle=r.pointRing,e.lineWidth=2,e.stroke()}(o,Qe.current,Re,Ge,"object"==typeof Ye?Ye:{},0,c),et.current&&Array.isArray(ge)){const e=ge.find(e=>e&&"object"==typeof e&&"highlight"===e.type);e&&function(e,t,n,o){var s;if(!n)return;const i=n.group;if(void 0!==i)for(const n of t){if("line"!==n.type)continue;if(n.group!==i)continue;if(2>n.path.length)continue;const t="function"==typeof o.style?o.style(n.datum):o.style||{};e.save(),e.beginPath(),e.moveTo(n.path[0][0],n.path[0][1]);for(let t=1;n.path.length>t;t++)e.lineTo(n.path[t][0],n.path[t][1]);e.strokeStyle=t.stroke||n.style.stroke||"#007bff",e.lineWidth=t.strokeWidth||(n.style.strokeWidth||2)+2,e.globalAlpha=null!==(s=t.opacity)&&void 0!==s?s:1,e.stroke(),e.restore()}}(o,s.scene,et.current,e)}const g=Ve.current;if(Ve.current=!1,g&&s.scales&&(Ke(s.scales),Te)){const e=s.getData(),t="function"==typeof h?h:e=>e[h||"x"],n="function"==typeof d?d:e=>e[d||"y"];rt(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),at(e.map(e=>n(e)).filter(e=>"number"==typeof e&&isFinite(e)))}g&&we&&we.length>0&&Ze(e=>e+1),(null==Be?void 0:Be.showBadge)&&st(!!f),(l||s.hasActivePulses)&&(qe.current=requestAnimationFrame(()=>ct.current()))},e.useEffect(()=>(ft(),()=>{qe.current&&(cancelAnimationFrame(qe.current),qe.current=0)}),[ft]),e.useEffect(()=>{Ve.current=!0,ft()},[r,Re,Ge,ce,P,I,ft]),e.useEffect(()=>{if(!Be)return;const e=setInterval(()=>{var e;const t=dt.current;if(!t||0===t.lastIngestTime)return;const n="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(e=Be.threshold)&&void 0!==e?e:5e3,s=n-t.lastIngestTime>o;s!==ot&&(st(s),Ve.current=!0,ft())},1e3);return()=>clearInterval(e)},[Be,ot,ft]);const Et=Ye&&tt?be?be(tt):a.createElement(ee,{hover:tt}):null,Mt=Et?a.createElement("div",{className:"stream-frame-tooltip",style:{position:"absolute",left:De.left+tt.x,top:De.top+tt.y,transform:`translate(${tt.x>.7*Re?"calc(-100% - 12px)":"12px"}, ${.3*Ge>tt.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:1}},Et):null,St=wt.current>=0&&tt?a.createElement("svg",{style:{position:"absolute",left:0,top:0,width:Ie[0],height:Ie[1],pointerEvents:"none",zIndex:2}},a.createElement("circle",{cx:tt.x+De.left,cy:tt.y+De.top,r:8,fill:"none",stroke:"var(--accent, #6366f1)",strokeWidth:2,strokeDasharray:"4,2"})):null;return a.createElement("div",{ref:Pe,className:"stream-xy-frame"+(F?" "+F:""),role:"img","aria-label":"string"==typeof Oe?Oe:"XY chart",tabIndex:0,style:{position:"relative",width:H?"100%":Ie[0],height:z?"100%":Ie[1]},onMouseMove:Ye?At:void 0,onMouseLeave:Ye?xt:void 0,onKeyDown:kt},Me&&a.createElement("svg",{style:{position:"absolute",left:0,top:0,width:Ie[0],height:Ie[1],pointerEvents:"none"}},Me),a.createElement("canvas",{ref:Xe,style:{position:"absolute",left:0,top:0}}),a.createElement(R,{width:Re,height:Ge,totalWidth:Ie[0],totalHeight:Ie[1],margin:De,scales:Je,showAxes:ce,axes:ue,xLabel:he,yLabel:de,xFormat:fe||me,yFormat:pe||ye,showGrid:Ae,title:Oe,legend:Ee,foregroundGraphics:Se,marginalGraphics:Te,xValues:it,yValues:lt,annotations:we,svgAnnotationRules:ke,annotationFrame:Ue,xAccessor:"string"==typeof h?h:"string"==typeof j?j:void 0,yAccessor:"string"==typeof d?d:"string"==typeof v?v:void 0,annotationData:null===(o=dt.current)||void 0===o?void 0:o.getData(),pointNodes:null===(s=dt.current)||void 0===s?void 0:s.scene.filter(e=>"point"===e.type)}),(Le||je)&&a.createElement(te,{width:Re,height:Ge,totalWidth:Ie[0],totalHeight:Ie[1],margin:De,dimension:null!==(i=null==Le?void 0:Le.dimension)&&void 0!==i?i:"xy",scales:Je,onBrush:null!=je?je:()=>{}}),(null==Be?void 0:Be.showBadge)&&a.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===Be.badgePosition?{top:4,left:4}:"bottom-left"===Be.badgePosition?{bottom:4,left:4}:"bottom-right"===Be.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:ot?"#dc3545":"#28a745",color:"white"})},ot?"STALE":"LIVE"),St,Mt)});ne.displayName="StreamXYFrame";const oe={category10:r.schemeCategory10,tableau10:r.schemeTableau10,set3:r.schemeSet3,blues:r.interpolateBlues,reds:r.interpolateReds,greens:r.interpolateGreens,oranges:r.interpolateOranges,purples:r.interpolatePurples,viridis:r.interpolateViridis,plasma:r.interpolatePlasma},se=r.schemeCategory10;function ie(e,t,n){if("function"==typeof t)return t(e);const o=e[t];return n?n(o):se[Math.abs(function(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n),t&=t;return Math.abs(t)}(o+""))%se.length]}function re(e,t,n="category10"){const s=Array.from(new Set(e.map(e=>e[t]))),i=s.every(e=>"number"==typeof e||!isNaN(Number(e)));if(Array.isArray(n))return o.scaleOrdinal().domain(s).range(n).unknown("#999");const r=oe[n]||oe.category10;if(i&&"function"==typeof r)return e=>r(Number(e)/Math.max(...s.map(Number)));{const e=Array.isArray(r)?r:se;return o.scaleOrdinal().domain(s).range(e).unknown("#999")}}function le(e,t,n=[3,20],o){let s;if(s="function"==typeof t?t(e):e[t],!o)return s;const[i,r]=o,[l,a]=n;return r===i?(l+a)/2:l+(s-i)/(r-i)*(a-l)}const ae=e.createContext(null);function ce(e){return e?"string"==typeof e?{name:e}:e:null}function ue(e,t,n){return t?o=>{var s;const i=Object.assign({},e(o));if(t.isActive)if(t.predicate(o))(null==n?void 0:n.selectedStyle)&&Object.assign(i,n.selectedStyle);else{const e=null!==(s=null==n?void 0:n.unselectedOpacity)&&void 0!==s?s:.2;i.opacity=e,i.fillOpacity=e,i.strokeOpacity=e,(null==n?void 0:n.unselectedStyle)&&Object.assign(i,n.unselectedStyle)}return i}:e}function he(t){const n=e.createContext(null),o=de(t);return[function({children:o}){const s=e.useMemo(()=>de(t),[]);return a.createElement(n.Provider,{value:s,children:o})},t=>{var s;const i=null!==(s=e.useContext(n))&&void 0!==s?s:o;return function(t,n){const[o,s]=e.useState(n);return e.useLayoutEffect(()=>t(()=>s(n)),[t]),o}(i.subscribe,()=>t(i.getState()))}]}function de(e){const t=new EventTarget;let n=e(function(e){n=Object.assign(Object.assign({},n),e(n)),t.dispatchEvent(new CustomEvent("update"))});return{getState:()=>n,subscribe:function(e){return t.addEventListener("update",e),()=>t.removeEventListener("update",e)}}}function fe(e){const t=[];for(const[n,o]of Object.entries(e.fields))if("point"===o.type)t.push(e=>o.values.has(e[n]));else{const[e,s]=o.range;t.push(t=>{const o=t[n];return o>=e&&s>=o})}return e=>t.every(t=>t(e))}function pe(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}const[me,ye]=he(e=>({selections:new Map,setClause(t,n){e(e=>{const o=new Map(e.selections),s=pe(o,t),i=new Map(s.clauses);return i.set(n.clientId,n),o.set(t,Object.assign(Object.assign({},s),{clauses:i})),{selections:o}})},clearClause(t,n){e(e=>{const o=e.selections.get(t);if(!o)return{};const s=new Map(e.selections),i=new Map(o.clauses);return i.delete(n),s.set(t,Object.assign(Object.assign({},o),{clauses:i})),{selections:s}})},setResolution(t,n){e(e=>{const o=new Map(e.selections),s=pe(o,t);return o.set(t,Object.assign(Object.assign({},s),{resolution:n})),{selections:o}})},clearSelection(t){e(e=>{const n=new Map(e.selections),o=n.get(t);return o&&n.set(t,Object.assign(Object.assign({},o),{clauses:new Map})),{selections:n}})}}));function ge(t){const n=e.useId(),o=t.clientId||n,{name:s}=t,i=ye(e=>e.selections.get(s)),r=ye(e=>e.setClause),l=ye(e=>e.clearClause),a=e.useMemo(()=>!!i&&i.clauses.size>0,[i]);return{predicate:e.useMemo(()=>i&&0!==i.clauses.size?function(e,t){const n=[];for(const[o,s]of e.clauses)"crossfilter"===e.resolution&&o===t||n.push(fe(s));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(i,o):()=>!0,[i,o]),isActive:a,selectPoints:e.useCallback(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"point",values:new Set(o)};r(s,{clientId:o,type:"point",fields:t})},[o,s,r]),selectInterval:e.useCallback(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"interval",range:o};r(s,{clientId:o,type:"interval",fields:t})},[o,s,r]),clear:e.useCallback(()=>{l(s,o)},[l,s,o]),clientId:o}}function be(t){const{name:n,xField:o,yField:s}=t,{predicate:i,isActive:r,selectInterval:l,clear:a}=ge({name:n}),c=o&&s?"xyBrush":o?"xBrush":"yBrush",u=e.useCallback(e=>{if(!e)return void a();const t={};"xyBrush"===c&&Array.isArray(e)&&2===e.length?(o&&(t[o]=[Math.min(e[0][0],e[1][0]),Math.max(e[0][0],e[1][0])]),s&&(t[s]=[Math.min(e[0][1],e[1][1]),Math.max(e[0][1],e[1][1])])):"xBrush"===c&&Array.isArray(e)?o&&(t[o]=[Math.min(...e),Math.max(...e)]):"yBrush"===c&&Array.isArray(e)&&s&&(t[s]=[Math.min(...e),Math.max(...e)]),Object.keys(t).length>0&&l(t)},[c,o,s,l,a]);return{brushInteraction:e.useMemo(()=>({brush:c,during:u,end:u}),[c,u]),predicate:i,isActive:r,clear:a}}const[ve,xe]=he(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const n=e.observations;return n.push(t),n.length>e.maxObservations&&n.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}})),we="#007bff";function ke(e){return"function"==typeof e?e:t=>t[e]}function Ae(t,n,o="category10"){const s=e.useContext(ae);return e.useMemo(()=>{if(n&&"function"!=typeof n)return s&&Object.keys(s).length>0?e=>s[e]||re(t,n,o)(e):re(t,n,o)},[t,n,o,s])}function Ee({selection:t,linkedHover:n,fallbackFields:o=[],unwrapData:s=!1,onObservation:i,chartType:r,chartId:l}){const a=function(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields}:null}(n,o),c=ge({name:(null==t?void 0:t.name)||"__unused__"}),u=function(t){const n=t.name||"hover",{fields:o}=t,{predicate:s,isActive:i,selectPoints:r,clear:l}=ge({name:n});return{onHover:e.useCallback(e=>{if(!e)return void l();const t={};for(const n of o){const o=e[n];void 0!==o&&(t[n]=[o])}Object.keys(t).length>0&&r(t)},[o,r,l,n]),predicate:s,isActive:i}}({name:(null==a?void 0:a.name)||"hover",fields:(null==a?void 0:a.fields)||o||[]}),h=xe(e=>e.pushObservation),d=t?{isActive:c.isActive,predicate:c.predicate}:null,f=e.useCallback(e=>{var t,o;if(n)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]),u.onHover(t)}else u.onHover(null);if(i||h){const n={timestamp:Date.now(),chartType:r||"unknown",chartId:l};if(e){let s=e.data||e.datum||e;Array.isArray(s)&&(s=s[0]);const r=Object.assign(Object.assign({},n),{type:"hover",datum:s||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(o=e.y)&&void 0!==o?o:0});i&&i(r),h&&h(r)}else{const e=Object.assign(Object.assign({},n),{type:"hover-end"});i&&i(e),h&&h(e)}}},[n,u,i,r,l,h]),p=e.useCallback(e=>{var t,n;if(i||h){const o={timestamp:Date.now(),chartType:r||"unknown",chartId:l};if(e){let s=e.data||e.datum||e;Array.isArray(s)&&(s=s[0]);const r=Object.assign(Object.assign({},o),{type:"click",datum:s||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0});i&&i(r),h&&h(r)}else{const e=Object.assign(Object.assign({},o),{type:"click-end"});i&&i(e),h&&h(e)}}},[i,h,r,l]);return{activeSelectionHook:d,customHoverBehavior:f,customClickBehavior:p}}function Me({data:t,colorBy:n,colorScale:o,showLegend:s,userMargin:i,defaults:r={top:50,bottom:60,left:70,right:40}}){const l=void 0!==s?s:!!n,a=e.useMemo(()=>{if(l&&n)return function({data:e,colorBy:t,colorScale:n,getColor:o,strokeColor:s,strokeWidth:i}){return{legendGroups:[{styleFn:e=>{const t={fill:e.color,stroke:e.color};return void 0!==s&&(t.stroke=s),void 0!==i&&(t.strokeWidth=i),t},type:"fill",items:Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t]))).map(s=>{const i=e.find("function"==typeof t?e=>t(e)===s:e=>e[t]===s),r=i?o(i,t,n):n?n(s):"#000000";return{label:s+"",color:r}}),label:""}]}}({data:t,colorBy:n,colorScale:o,getColor:ie})},[l,n,t,o]),c=e.useMemo(()=>{const e=Object.assign(Object.assign({},r),i);return a&&120>e.right&&(e.right=120),e},[r,i,a]);return{legend:a,margin:c}}const Se={primary:{width:600,height:400,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:void 0,showLabels:void 0,marginDefaults:{top:50,bottom:60,left:70,right:40}},context:{width:400,height:250,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:10,bottom:10,left:10,right:10}},sparkline:{width:120,height:24,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:2,bottom:2,left:0,right:0}}};function Oe(e,t,n){var o,s,i,r,l,a;const c=Se[e||"primary"],u="context"===e||"sparkline"===e;return{width:null!==(o=t.width)&&void 0!==o?o:c.width,height:null!==(s=t.height)&&void 0!==s?s:c.height,showAxes:c.showAxes,showGrid:null!==(i=t.showGrid)&&void 0!==i?i:c.showGrid,enableHover:null!==(r=t.enableHover)&&void 0!==r?r:!!t.linkedHover||c.enableHover,showLegend:null!==(l=t.showLegend)&&void 0!==l?l:c.showLegend,showLabels:null!==(a=t.showLabels)&&void 0!==a?a:c.showLabels,title:u?void 0:t.title,xLabel:u?void 0:t.xLabel,yLabel:u?void 0:t.yLabel,categoryLabel:u?void 0:t.categoryLabel,valueLabel:u?void 0:t.valueLabel,marginDefaults:c.marginDefaults}}const Ne={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"8px 12px",borderRadius:"4px",fontSize:"14px",lineHeight:"1.5",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"};function Le(e,t){return"function"==typeof t?t(e):e[t]}function je(e,t){return t?t(e):null==e?"":"number"==typeof e?e.toLocaleString():e instanceof Date?e.toLocaleDateString():"object"==typeof e&&null!==e?void 0!==e.id?e.id+"":void 0!==e.name?e.name+"":JSON.stringify(e):e+""}function Ce(e){return!0===e||("function"==typeof e?e:!1!==e&&void 0!==e&&("object"!=typeof e||null===e||!("fields"in e)&&!("title"in e)||function(e={}){const{fields:t,title:n,format:o,style:s={},className:i=""}=e;return e=>{if(!e||"object"!=typeof e)return null;let r;const l=[];if(n){const t=Le(e,n);r=je(t,o)}if(t&&t.length>0)t.forEach(t=>{let n,s,i;"string"==typeof t?(n=t,s=t,i=o):(n=t.label,s=t.accessor||t.key||"",i=t.format||o);const r=Le(e,s);l.push({label:n,value:je(r,i)})});else if(!n){const t=["value","y","name","id","label"];for(const n of t)if(void 0!==e[n]){r=je(e[n],o);break}if(!r){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(r=je(e[t[0]],o))}}const c=Object.assign(Object.assign({},Ne),s);return a.createElement("div",{className:("semiotic-tooltip "+i).trim(),style:c},r&&a.createElement("div",{style:{fontWeight:l.length>0?"bold":"normal"}},r),l.map((e,t)=>a.createElement("div",{key:t,style:{marginTop:0===t&&r?"4px":0}},e.label&&a.createElement("span",null,e.label,": "),e.value)))}}(e)))}function _e(e){return"string"==typeof e?e:"value"}function We(e){return t=>{const n=t.data;return n?a.createElement("div",{className:"semiotic-tooltip",style:Ne},e.map((e,t)=>{const o=function(e,t){return"function"==typeof t?t(e):e[t]}(n,e.accessor),s=null==(i=o)?"–":"number"==typeof i?Math.abs(i)>9999?i.toLocaleString():i+"":i instanceof Date?i.toLocaleDateString():i+"";var i;return a.createElement("div",{key:t,style:t>0?{marginTop:2}:void 0},a.createElement("span",{style:{opacity:.8}},e.label,": "),a.createElement("span",{style:{fontWeight:"color"===e.role||"group"===e.role?"bold":"normal"}},s))})):null}}function Be({componentName:e,message:t,width:n,height:o}){return a.createElement("div",{role:"alert",style:{width:n,height:Math.max(o,120),display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed rgba(128, 128, 128, 0.4)",borderRadius:8,background:"rgba(128, 128, 128, 0.04)",padding:24,boxSizing:"border-box"}},a.createElement("div",{style:{textAlign:"center",maxWidth:400}},a.createElement("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"}},e),a.createElement("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5}},t)))}class $e extends a.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){var n,o;null===(o=(n=this.props).onError)||void 0===o||o.call(n,e,t)}render(){if(this.state.error){const{fallback:e}=this.props,t=this.state.error;return"function"==typeof e?e(t):void 0!==e?e:a.createElement(Be,{componentName:"ChartErrorBoundary",message:t.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}var He;const ze="undefined"!=typeof process&&"production"!==(null===(He=process.env)||void 0===He?void 0:He.NODE_ENV);function Te({componentName:e,width:t,height:n,children:o}){return a.createElement($e,{fallback:o=>a.createElement(Be,{componentName:e,message:o.message,width:t,height:n})},o)}function Fe(e,t,n,o){if(!ze)return;if(!t||0===t.length)return;if("string"!=typeof o)return;const s=t[0];if(!s||"object"!=typeof s)return;if(o in s)return;const i=Object.keys(s).join(", ");console.warn(`[semiotic] ${e}: ${n} "${o}" not found in data. Available keys: ${i}`)}function Pe(e,t){if(0===t.length)return null;const n=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(n)||n.includes(e.toLowerCase()))||t[0]}function Ie({componentName:e,data:t,accessors:n,requiredProps:o}){if(o)for(const[t,n]of Object.entries(o))if(null==n)return`${e}: ${t} is required. Provide a field name or function.`;if(!t||!Array.isArray(t)||0===t.length)return e+": No data provided. Pass a non-empty array to the data prop.";if(!Array.isArray(t)&&"object"==typeof t)return e+": data should be an array, but received an object. If this is hierarchical data, use TreeDiagram, Treemap, or CirclePack instead.";if(n){const o=function(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:e}(t).find(e=>e&&"object"==typeof e);if(o){const t=Object.keys(o);for(const[s,i]of Object.entries(n))if(i&&"string"==typeof i&&!(i in o)){const n=Pe(i,t),o=n?` Try ${s}="${n}".`:"";return`${e}: ${s} "${i}" not found in data. Available fields: ${t.join(", ")}.${o}`}}}return null}const De="__forecastSegment";function Re(e,t){return"function"==typeof t?t(e):!!e[t]}function Ge(t){var n,o;const s=Oe(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:i,margin:r,className:l,xFormat:c,yFormat:u,xAccessor:h="x",yAccessor:d="y",lineBy:f,lineDataAccessor:p="coordinates",colorBy:m,colorScheme:y="category10",curve:g="linear",showPoints:b=!1,pointRadius:v=3,fillArea:x=!1,areaOpacity:w=.3,lineWidth:k=2,tooltip:A,pointIdAccessor:E,annotations:M,anomaly:S,forecast:O,frameProps:N={},selection:L,linkedHover:j,onObservation:C,chartId:_}=t,W=s.width,B=s.height,$=s.enableHover,H=s.showGrid,z=s.showLegend,T=s.title,F=s.xLabel,P=s.yLabel,I=i||[];Fe("LineChart",I,"xAccessor",h),Fe("LineChart",I,"yAccessor",d);const D="string"==typeof h?h:"x",R="string"==typeof d?d:"y",G=e.useMemo(()=>O?function(e,t,n,o,s){return(i=o).isTraining||i.isForecast||i.isAnomaly||i.upperBounds||i.lowerBounds?function(e,t,n,o,s){var i,r,l;const{isTraining:a,isForecast:c,isAnomaly:u,upperBounds:h,lowerBounds:d,color:f="#6366f1",bandOpacity:p=.15,anomalyColor:m="#ef4444",anomalyRadius:y=6,label:g}=o,b=e.map(e=>{let t="observed";return c&&Re(e,c)?t="forecast":a&&Re(e,a)&&(t="training"),Object.assign(Object.assign({},e),{[De]:t})}),v=[];if(h&&d){const e="string"==typeof h?h:"__envUpper",t="string"==typeof d?d:"__envLower";if("function"==typeof h||"function"==typeof d)for(const n of b)"function"==typeof h&&(n[e]=h(n)),"function"==typeof d&&(n[t]=d(n));v.push({type:"envelope",upperAccessor:e,lowerAccessor:t,fill:f,fillOpacity:p,label:g})}return u&&v.push({type:"highlight",filter:e=>Re(e,u),color:m,r:y,style:{stroke:m,strokeWidth:1.5,fill:m,fillOpacity:.7}}),s&&v.push({type:"anomaly-band",threshold:null!==(i=s.threshold)&&void 0!==i?i:2,showBand:!1!==s.showBand,fill:s.bandColor||"#6366f1",fillOpacity:null!==(r=s.bandOpacity)&&void 0!==r?r:.1,anomalyColor:s.anomalyColor||"#ef4444",anomalyRadius:null!==(l=s.anomalyRadius)&&void 0!==l?l:6,label:s.label}),{processedData:b,annotations:v}}(e,0,0,o,s):function(e,t,n,o,s){var i,r,l;const{trainEnd:a,steps:c=10,confidence:u=.95,color:h="#6366f1",bandOpacity:d=.15,label:f}=o;if(null==a)return{processedData:e,annotations:[]};const p=[],m=[];for(const n of e)n[t]>a?m.push(Object.assign(Object.assign({},n),{[De]:"observed"})):p.push(Object.assign(Object.assign({},n),{[De]:"training"}));const y=p.map(e=>[e[t],e[n]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]),g=[],b=[];if(y.length>=3){const o=y.length;let s=0,i=0,r=0,l=0;for(const[e,t]of y)s+=e,i+=t,r+=e*e,l+=e*t;const a=o*r-s*s;if(Math.abs(a)>1e-12){const r=(o*l-s*i)/a,p=(i-r*s)/o,m=e=>p+r*e,v=y.map(([e,t])=>t-m(e)).reduce((e,t)=>e+t*t,0),x=Math.sqrt(v/Math.max(o-2,1)),w=y.reduce((e,t)=>e+t[0],0)/o,k=y.reduce((e,t)=>e+Math.pow(t[0]-w,2),0),A=.99>u?.95>u?.9>u?1:1.645:1.96:2.576,E=e.map(e=>e[t]).filter(e=>null!=e&&isFinite(e)),M=Math.max(...E),S=y.length>1?(y[o-1][0]-y[0][0])/(o-1):1;for(let e=1;c>=e;e++){const s=M+e*S,i=m(s),r=x*Math.sqrt(1+1/o+(k>0?Math.pow(s-w,2)/k:0))*A;b.push({[t]:s,[n]:i,[De]:"forecast",__forecastUpper:i+r,__forecastLower:i-r})}g.push({type:"envelope",upperAccessor:"__forecastUpper",lowerAccessor:"__forecastLower",fill:h,fillOpacity:d,label:f})}}return g.push({type:"x-threshold",x:a,color:"#94a3b8",strokeWidth:1,strokeDasharray:"4,2",label:"Train / Forecast"}),s&&g.push({type:"anomaly-band",threshold:null!==(i=s.threshold)&&void 0!==i?i:2,showBand:!1!==s.showBand,fill:s.bandColor||"#6366f1",fillOpacity:null!==(r=s.bandOpacity)&&void 0!==r?r:.1,anomalyColor:s.anomalyColor||"#ef4444",anomalyRadius:null!==(l=s.anomalyRadius)&&void 0!==l?l:6,label:s.label}),{processedData:[...p,...m,...b],annotations:g}}(e,t,n,o,s);var i}(I,D,R,O,S):null,[I,O,S,D,R]),Y=e.useMemo(()=>G?G.annotations:S?function(e){var t,n,o;return[{type:"anomaly-band",threshold:null!==(t=e.threshold)&&void 0!==t?t:2,showBand:!1!==e.showBand,fill:e.bandColor||"#6366f1",fillOpacity:null!==(n=e.bandOpacity)&&void 0!==n?n:.1,anomalyColor:e.anomalyColor||"#ef4444",anomalyRadius:null!==(o=e.anomalyRadius)&&void 0!==o?o:6,label:e.label}]}(S):[],[G,S]),X=G?G.processedData:I,q=O&&!f?De:f,{activeSelectionHook:V,customHoverBehavior:U}=Ee({selection:L,linkedHover:j,fallbackFields:m?["string"==typeof m?m:""]:[],onObservation:C,chartType:"LineChart",chartId:_}),Z=void 0!==(null===(n=X[0])||void 0===n?void 0:n[p]),J=e.useMemo(()=>{if(Z)return X;if(q){const e=X.reduce((e,t)=>{const n="function"==typeof q?q(t):t[q];if(!e[n]){const t={[p]:[]};"string"==typeof q&&(t[q]=n),e[n]=t}return e[n][p].push(t),e},{});return Object.values(e)}return[{[p]:X}]},[X,q,p,Z]),K=Ae(X,m,y),Q=e.useMemo(()=>e=>{const t={strokeWidth:k};return t.stroke=m?ie(e,m,K):we,x&&(t.fill=t.stroke,t.fillOpacity=w),t},[m,K,k,x,w]),ee=e.useMemo(()=>O?function(e,t){var n,o;const s=null!==(n=t.trainDasharray)&&void 0!==n?n:"8,4",i=null!==(o=t.forecastDasharray)&&void 0!==o?o:"4,4",r=t.color||"#6366f1";return t=>{const n=e(t),o=t[De];return"training"===o?Object.assign(Object.assign({},n),{strokeDasharray:s}):"forecast"===o?Object.assign(Object.assign({},n),{stroke:r,strokeDasharray:i}):n}}(Q,O):Q,[Q,O]),te=e.useMemo(()=>ue(ee,V,L),[ee,V,L]),oe=e.useMemo(()=>{if(b)return e=>{const t={r:v,fillOpacity:1};return t.fill=m?ie(e.parentLine||e,m,K):we,t}},[b,v,m,K]),se=x?"area":"line",{legend:re,margin:le}=Me({data:J,colorBy:m,colorScale:K,showLegend:z,userMargin:r,defaults:s.marginDefaults}),ae=f||m,ce=e.useMemo(()=>We([{label:F||_e(h),accessor:h,role:"x"},{label:P||_e(d),accessor:d,role:"y"},...ae?[{label:_e(ae),accessor:ae,role:"group"}]:[]]),[h,d,F,P,ae]),he=Ie({componentName:"LineChart",data:Z?(null===(o=X[0])||void 0===o?void 0:o[p])||[]:I,accessors:{xAccessor:h,yAccessor:d}});if(he)return a.createElement(Be,{componentName:"LineChart",message:he,width:W,height:B});const de=e.useMemo(()=>Z||q?J.flatMap(e=>{const t=e[p]||[];return q&&"string"==typeof q?t.map(t=>Object.assign(Object.assign({},t),{[q]:e[q]})):t}):X,[J,p,Z,q,X]),fe=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:se,data:de,xAccessor:h,yAccessor:d,groupAccessor:q||void 0,curve:g,lineStyle:te},b&&{pointStyle:oe}),{size:[W,B],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:le,showAxes:s.showAxes,xLabel:F,yLabel:P,xFormat:c,yFormat:u,enableHover:$,showGrid:H}),re&&{legend:re}),T&&{title:T}),l&&{className:l}),{tooltipContent:A?Ce(A):ce}),(j||C)&&{customHoverBehavior:U}),E&&{pointIdAccessor:E}),((null==M?void 0:M.length)||Y.length)&&{annotations:[...M||[],...Y]}),N);return a.createElement(Te,{componentName:"LineChart",width:W,height:B},a.createElement(ne,Object.assign({},fe)))}function Ye(t){var n;const o=Oe(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:s,margin:i,className:r,xFormat:l,yFormat:c,xAccessor:u="x",yAccessor:h="y",areaBy:d,y0Accessor:f,gradientFill:p=!1,lineDataAccessor:m="coordinates",colorBy:y,colorScheme:g="category10",curve:b="monotoneX",areaOpacity:v=.7,showLine:x=!0,lineWidth:w=2,tooltip:k,annotations:A,frameProps:E={},selection:M,linkedHover:S,onObservation:O,chartId:N}=t,L=o.width,j=o.height,C=o.enableHover,_=o.showGrid,W=o.showLegend,B=o.title,$=o.xLabel,H=o.yLabel,z=s||[];Fe("AreaChart",z,"xAccessor",u),Fe("AreaChart",z,"yAccessor",h);const{activeSelectionHook:T,customHoverBehavior:F}=Ee({selection:M,linkedHover:S,fallbackFields:y?["string"==typeof y?y:""]:[],onObservation:O,chartType:"AreaChart",chartId:N}),P=void 0!==(null===(n=z[0])||void 0===n?void 0:n[m]),I=e.useMemo(()=>{if(P)return z;if(d){const e=z.reduce((e,t)=>{const n="function"==typeof d?d(t):t[d];if(!e[n]){const t={[m]:[]};"string"==typeof d&&(t[d]=n),e[n]=t}return e[n][m].push(t),e},{});return Object.values(e)}return[{[m]:z}]},[z,d,m,P]),D=Ae(z,y,g),R=e.useMemo(()=>e=>{const t={},n=y?ie(e,y,D):we;return t.fill=n,t.fillOpacity=v,x?(t.stroke=n,t.strokeWidth=w):t.stroke="none",t},[y,D,v,x,w]),G=e.useMemo(()=>ue(R,T,M),[R,T,M]),{legend:Y,margin:X}=Me({data:I,colorBy:y,colorScale:D,showLegend:W,userMargin:i,defaults:o.marginDefaults}),q=d||y,V=e.useMemo(()=>We([{label:$||_e(u),accessor:u,role:"x"},{label:H||_e(h),accessor:h,role:"y"},...q?[{label:_e(q),accessor:q,role:"group"}]:[]]),[u,h,$,H,q]),U=Ie({componentName:"AreaChart",data:z,accessors:{xAccessor:u,yAccessor:h}});if(U)return a.createElement(Be,{componentName:"AreaChart",message:U,width:L,height:j});const Z=e.useMemo(()=>P||d?I.flatMap(e=>{const t=e[m]||[];return d&&"string"==typeof d?t.map(t=>Object.assign(Object.assign({},t),{[d]:e[d]})):t}):z,[I,m,P,d,z]),J=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"area",data:Z,xAccessor:u,yAccessor:h,groupAccessor:d||void 0},f&&{y0Accessor:f}),p&&{gradientFill:p}),{curve:b,lineStyle:G,size:[L,j],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:X,showAxes:o.showAxes,xLabel:$,yLabel:H,xFormat:l,yFormat:c,enableHover:C,showGrid:_}),Y&&{legend:Y}),B&&{title:B}),r&&{className:r}),{tooltipContent:k?Ce(k):V}),(S||O)&&{customHoverBehavior:F}),A&&A.length>0&&{annotations:A}),E);return a.createElement(Te,{componentName:"AreaChart",width:L,height:j},a.createElement(ne,Object.assign({},J)))}function Xe(t){var n;const o=Oe(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:s,margin:i,className:r,xFormat:l,yFormat:c,xAccessor:u="x",yAccessor:h="y",areaBy:d,lineDataAccessor:f="coordinates",colorBy:p,colorScheme:m="category10",curve:y="monotoneX",areaOpacity:g=.7,showLine:b=!0,lineWidth:v=2,normalize:x=!1,tooltip:w,annotations:k,frameProps:A={},selection:E,linkedHover:M,onObservation:S,chartId:O}=t,N=o.width,L=o.height,j=o.enableHover,C=o.showGrid,_=o.showLegend,W=o.title,B=o.xLabel,$=o.yLabel,H=s||[],{activeSelectionHook:z,customHoverBehavior:T}=Ee({selection:E,linkedHover:M,fallbackFields:p?["string"==typeof p?p:""]:[],onObservation:S,chartType:"StackedAreaChart",chartId:O}),F=void 0!==(null===(n=H[0])||void 0===n?void 0:n[f]),P=e.useMemo(()=>{if(F)return H;if(d){const e=H.reduce((e,t)=>{const n="function"==typeof d?d(t):t[d];if(!e[n]){const t={[f]:[]};"string"==typeof d&&(t[d]=n),e[n]=t}return e[n][f].push(t),e},{});return Object.values(e)}return[{[f]:H}]},[H,d,f,F]),I=Ae(H,p,m),D=e.useMemo(()=>e=>{const t={},n=p?ie(e,p,I):we;return t.fill=n,t.fillOpacity=g,b?(t.stroke=n,t.strokeWidth=v):t.stroke="none",t},[p,I,g,b,v]),R=e.useMemo(()=>ue(D,z,E),[D,z,E]),{legend:G,margin:Y}=Me({data:P,colorBy:p,colorScale:I,showLegend:_,userMargin:i,defaults:o.marginDefaults}),X=d||p,q=e.useMemo(()=>We([{label:B||_e(u),accessor:u,role:"x"},{label:$||_e(h),accessor:h,role:"y"},...X?[{label:_e(X),accessor:X,role:"group"}]:[]]),[u,h,B,$,X]),V=Ie({componentName:"StackedAreaChart",data:H,accessors:{xAccessor:u,yAccessor:h}});if(V)return a.createElement(Be,{componentName:"StackedAreaChart",message:V,width:N,height:L});const U=e.useMemo(()=>F||d?P.flatMap(e=>{const t=e[f]||[];return d&&"string"==typeof d?t.map(t=>Object.assign(Object.assign({},t),{[d]:e[d]})):t}):H,[P,f,F,d,H]),Z=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"stackedarea",data:U,xAccessor:u,yAccessor:h,groupAccessor:d||void 0,curve:y,normalize:x,lineStyle:R,size:[N,L],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Y,showAxes:o.showAxes,xLabel:B,yLabel:$,xFormat:l,yFormat:c,enableHover:j,showGrid:C},G&&{legend:G}),W&&{title:W}),r&&{className:r}),{tooltipContent:w?Ce(w):q}),(M||S)&&{customHoverBehavior:T}),k&&k.length>0&&{annotations:k}),A);return a.createElement(Te,{componentName:"StackedAreaChart",width:N,height:L},a.createElement(ne,Object.assign({},Z)))}function qe(t){const n=Oe(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:o,margin:s,className:i,xFormat:r,yFormat:l,xAccessor:c="x",yAccessor:u="y",colorBy:h,colorScheme:d="category10",sizeBy:f,sizeRange:p=[3,15],pointRadius:m=5,pointOpacity:y=.8,tooltip:g,marginalGraphics:b,pointIdAccessor:v,annotations:x,frameProps:w={},selection:k,linkedHover:A,linkedBrush:E,onObservation:M,chartId:S}=t,O=n.width,N=n.height,L=n.enableHover,j=n.showGrid,C=n.showLegend,_=n.title,W=n.xLabel,B=n.yLabel,$=o||[];Fe("Scatterplot",$,"xAccessor",c),Fe("Scatterplot",$,"yAccessor",u);const{activeSelectionHook:H,customHoverBehavior:z}=Ee({selection:k,linkedHover:A,fallbackFields:h?["string"==typeof h?h:""]:[],onObservation:M,chartType:"Scatterplot",chartId:S}),T=ce(E);be({name:(null==T?void 0:T.name)||"__unused_brush__",xField:(null==T?void 0:T.xField)||("string"==typeof c?c:void 0),yField:(null==T?void 0:T.yField)||("string"==typeof u?u:void 0)});const F=Ae($,h,d),P=e.useMemo(()=>{if(!f||0===$.length)return;const e=$.map(e=>"function"==typeof f?f(e):e[f]);return[Math.min(...e),Math.max(...e)]},[$,f]),I=e.useMemo(()=>e=>{const t={fillOpacity:y};return t.fill=h?ie(e,h,F):we,t.r=f?le(e,f,p,P):m,t},[h,F,f,p,P,m,y]),D=e.useMemo(()=>ue(I,H,k),[I,H,k]),{legend:R,margin:G}=Me({data:$,colorBy:h,colorScale:F,showLegend:C,userMargin:s,defaults:n.marginDefaults}),Y=e.useMemo(()=>We([{label:W||_e(c),accessor:c,role:"x"},{label:B||_e(u),accessor:u,role:"y"},...h?[{label:_e(h),accessor:h,role:"color"}]:[],...f?[{label:_e(f),accessor:f,role:"size"}]:[]]),[c,u,W,B,h,f]),X=Ie({componentName:"Scatterplot",data:$,accessors:{xAccessor:c,yAccessor:u}});if(X)return a.createElement(Be,{componentName:"Scatterplot",message:X,width:O,height:N});const q=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter",data:$,xAccessor:c,yAccessor:u,colorAccessor:h||void 0,sizeAccessor:f||void 0,sizeRange:p,pointStyle:D,colorScheme:d,size:[O,N],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:G,showAxes:n.showAxes,xLabel:W,yLabel:B,xFormat:r,yFormat:l,enableHover:L,showGrid:j},R&&{legend:R}),_&&{title:_}),i&&{className:i}),{tooltipContent:g?Ce(g):Y}),(A||M)&&{customHoverBehavior:z}),b&&{marginalGraphics:b}),v&&{pointIdAccessor:v}),x&&x.length>0&&{annotations:x}),w);return a.createElement(Te,{componentName:"Scatterplot",width:O,height:N},a.createElement(ne,Object.assign({},q)))}function Ve(t){const n=Oe(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:o,className:s,xFormat:i,yFormat:l,xAccessor:c="x",yAccessor:u="y",orderAccessor:h,orderLabel:d,pointRadius:f=4,tooltip:p,pointIdAccessor:m,annotations:y,frameProps:g={},selection:b,linkedHover:v,onObservation:x,chartId:w}=t,k=n.width,A=n.height,E=n.enableHover,M=n.showGrid,S=n.title,O=n.xLabel,N=n.yLabel,L=o||[],j=e.useMemo(()=>{if(!h||0===L.length)return L;const e="function"==typeof h?h:e=>e[h];return[...L].sort((t,n)=>{const o=e(t),s=e(n);return(o instanceof Date?o.getTime():+o)-(s instanceof Date?s.getTime():+s)})},[L,h]);Fe("ConnectedScatterplot",j,"xAccessor",c),Fe("ConnectedScatterplot",j,"yAccessor",u);const{activeSelectionHook:C,customHoverBehavior:_}=Ee({selection:b,linkedHover:v,fallbackFields:[],onObservation:x,chartType:"ConnectedScatterplot",chartId:w}),W=j.length,B=W>0&&100>W,$=e.useMemo(()=>0===W?[]:j.map((e,t)=>r.interpolateViridis(1===W?.5:t/(W-1))),[j,W]);e.useMemo(()=>null,[W]);const H=e.useMemo(()=>{if(W>=2)return(e,t,n)=>{var o,s;if("connected-lines"!==e.type)return null;const i=n.scales;if(!i)return null;const r=null!==(o=i.x)&&void 0!==o?o:i.time,l=null!==(s=i.y)&&void 0!==s?s:i.value;if(!r||!l)return null;const h="string"==typeof c?e=>e[c]:c,d="string"==typeof u?e=>e[u]:u,p=[];for(let e=0;j.length-1>e;e++){const t=j[e],n=j[e+1],o=r(h(t)),s=l(d(t)),i=r(h(n)),c=l(d(n)),u=$[e];B&&p.push(a.createElement("line",{key:"halo-"+e,x1:o,y1:s,x2:i,y2:c,stroke:"white",strokeWidth:f+2,strokeOpacity:.5,strokeLinecap:"round"})),p.push(a.createElement("line",{key:"conn-"+e,x1:o,y1:s,x2:i,y2:c,stroke:u,strokeWidth:f,strokeLinecap:"round"}))}return a.createElement("g",{key:"ann-"+t},p)}},[j,$,f,B,c,u,W]),z=e.useMemo(()=>e=>{const t=j.indexOf(e);return{fill:t>=0&&$.length>t?$[t]:"#6366f1",stroke:"white",strokeWidth:1,r:f,fillOpacity:1}},[j,$,f]),T=e.useMemo(()=>ue(z,C,b),[z,C,b]),F=Object.assign({top:50,right:40,bottom:60,left:70},t.margin),P=d||("string"==typeof h?h:"Order"),I=e.useMemo(()=>We([{label:O||_e(c),accessor:c,role:"x"},{label:N||_e(u),accessor:u,role:"y"},...h?[{label:P,accessor:h,role:"group"}]:[]]),[c,u,O,N,h,P]),D=Ie({componentName:"ConnectedScatterplot",data:j,accessors:{xAccessor:c,yAccessor:u}});if(D)return a.createElement(Be,{componentName:"ConnectedScatterplot",message:D,width:k,height:A});const R=e.useMemo(()=>[{type:"connected-lines"},...y||[]],[y]),G=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter",data:j,xAccessor:c,yAccessor:u,pointStyle:T,size:[k,A],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:F,showAxes:n.showAxes,xLabel:O,yLabel:N,xFormat:i,yFormat:l,enableHover:E,showGrid:M},S&&{title:S}),s&&{className:s}),{tooltipContent:p?Ce(p):I}),(v||x)&&{customHoverBehavior:_}),m&&{pointIdAccessor:m}),{annotations:R,svgAnnotationRules:H}),g);return a.createElement(Te,{componentName:"ConnectedScatterplot",width:k,height:A},a.createElement(ne,Object.assign({},G)))}function Ue(t){const n=Oe(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:o,margin:s,className:i,xFormat:r,yFormat:l,xAccessor:c="x",yAccessor:u="y",sizeBy:h,sizeRange:d=[5,40],colorBy:f,colorScheme:p="category10",bubbleOpacity:m=.6,bubbleStrokeWidth:y=1,bubbleStrokeColor:g="white",tooltip:b,marginalGraphics:v,pointIdAccessor:x,annotations:w,frameProps:k={},selection:A,linkedHover:E,linkedBrush:M,onObservation:S,chartId:O}=t,N=n.width,L=n.height,j=n.enableHover,C=n.showGrid,_=n.showLegend,W=n.title,B=n.xLabel,$=n.yLabel,H=o||[],{activeSelectionHook:z,customHoverBehavior:T}=Ee({selection:A,linkedHover:E,fallbackFields:f?["string"==typeof f?f:""]:[],onObservation:S,chartType:"BubbleChart",chartId:O}),F=ce(M);be({name:(null==F?void 0:F.name)||"__unused_brush__",xField:(null==F?void 0:F.xField)||("string"==typeof c?c:void 0),yField:(null==F?void 0:F.yField)||("string"==typeof u?u:void 0)});const P=Ae(H,f,p),I=e.useMemo(()=>{const e=H.map(e=>"function"==typeof h?h(e):e[h]);return[Math.min(...e),Math.max(...e)]},[H,h]),D=e.useMemo(()=>e=>{const t={fillOpacity:m,strokeWidth:y,stroke:g};return t.fill=f?ie(e,f,P):we,t.r=le(e,h,d,I),t},[f,P,h,d,I,m,y,g]),R=e.useMemo(()=>ue(D,z,A),[D,z,A]),{legend:G,margin:Y}=Me({data:H,colorBy:f,colorScale:P,showLegend:_,userMargin:s,defaults:n.marginDefaults}),X=e.useMemo(()=>We([{label:B||_e(c),accessor:c,role:"x"},{label:$||_e(u),accessor:u,role:"y"},{label:_e(h),accessor:h,role:"size"},...f?[{label:_e(f),accessor:f,role:"color"}]:[]]),[c,u,B,$,h,f]),q=Ie({componentName:"BubbleChart",data:H,accessors:{xAccessor:c,yAccessor:u},requiredProps:{sizeBy:h}});if(q)return a.createElement(Be,{componentName:"BubbleChart",message:q,width:N,height:L});const V=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bubble",data:H,xAccessor:c,yAccessor:u,colorAccessor:f||void 0,sizeAccessor:h,sizeRange:d,pointStyle:R,colorScheme:p,size:[N,L],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Y,showAxes:n.showAxes,xLabel:B,yLabel:$,xFormat:r,yFormat:l,enableHover:j,showGrid:C},G&&{legend:G}),W&&{title:W}),i&&{className:i}),{tooltipContent:b?Ce(b):X}),(E||S)&&{customHoverBehavior:T}),v&&{marginalGraphics:v}),x&&{pointIdAccessor:x}),w&&w.length>0&&{annotations:w}),k);return a.createElement(Te,{componentName:"BubbleChart",width:N,height:L},a.createElement(ne,Object.assign({},V)))}function Ze(t){const n=Oe(t.mode,{width:t.width,height:t.height,showGrid:void 0,enableHover:t.enableHover,showLegend:void 0,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:s,margin:i,className:l,xAccessor:c="x",yAccessor:u="y",valueAccessor:h="value",xFormat:d,yFormat:f,colorScheme:p="blues",customColorScale:m,showValues:y=!1,valueFormat:g,cellBorderColor:b="#fff",cellBorderWidth:v=1,tooltip:x,annotations:w,frameProps:k={},selection:A,linkedHover:E,onObservation:M,chartId:S}=t,O=n.width,N=n.height,L=n.enableHover,j=n.title,C=n.xLabel,_=n.yLabel,W=s||[],{margin:B}=Me({data:W,colorBy:void 0,colorScale:void 0,showLegend:!1,userMargin:i,defaults:n.marginDefaults}),{activeSelectionHook:$,customHoverBehavior:H}=Ee({selection:A,linkedHover:E,fallbackFields:[],onObservation:M,chartType:"Heatmap",chartId:S}),z=e.useMemo(()=>"function"==typeof h?e=>h(e):e=>e[h],[h]),T=e.useMemo(()=>{const e=W.map(z);return[Math.min(...e),Math.max(...e)]},[W,z]),F=e.useMemo(()=>"custom"===p&&m?m:o.scaleSequential({blues:r.interpolateBlues,reds:r.interpolateReds,greens:r.interpolateGreens,viridis:r.interpolateViridis}[p]||r.interpolateBlues).domain(T),[p,m,T]);e.useMemo(()=>{const e=ke(c),t=ke(u);return{xBinCount:new Set(W.map(e)).size,yBinCount:new Set(W.map(t)).size}},[W,c,u]),e.useMemo(()=>({coordinates:W}),[W]);const P=e.useMemo(()=>e=>{const t=z(e);return{fill:F(t),stroke:b,strokeWidth:v}},[z,F,b,v]);e.useMemo(()=>ue(P,$,A),[P,$,A]),e.useMemo(()=>{if(!y)return;const e=(T[0]+T[1])/2;return(t,n)=>{const o=z(t),s=g?g(o):o+"";return a.createElement("text",{textAnchor:"middle",dominantBaseline:"middle",fill:z(t)>e?"#fff":"#000",fontSize:"12px"},s)}},[y,z,g,T]);const I=e.useMemo(()=>We([{label:C||_e(c),accessor:c,role:"x"},{label:_||_e(u),accessor:u,role:"y"},{label:_e(h),accessor:h,role:"value"}]),[c,u,C,_,h]),D=Ie({componentName:"Heatmap",data:W,accessors:{xAccessor:c,yAccessor:u,valueAccessor:h}});if(D)return a.createElement(Be,{componentName:"Heatmap",message:D,width:O,height:N});const R=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"heatmap",data:W,xAccessor:c,yAccessor:u,valueAccessor:h,size:[O,N],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:B,showAxes:n.showAxes,xLabel:C,yLabel:_,xFormat:d,yFormat:f,enableHover:L},j&&{title:j}),l&&{className:l}),{tooltipContent:x?Ce(x):I}),(E||M)&&{customHoverBehavior:H}),w&&w.length>0&&{annotations:w}),k);return a.createElement(Te,{componentName:"Heatmap",width:O,height:N},a.createElement(ne,Object.assign({},R)))}function Je({selections:t}){const n=ye(e=>e.setResolution);return e.useEffect(()=>{for(const[e,o]of Object.entries(t))o.resolution&&n(e,o.resolution)},[t,n]),null}function Ke({children:e,selections:t}){return a.createElement(me,null,a.createElement(ve,null,t&&a.createElement(Je,{selections:t}),e))}Ge.displayName="LineChart",Ye.displayName="AreaChart",Xe.displayName="StackedAreaChart",qe.displayName="Scatterplot",Ve.displayName="ConnectedScatterplot",Ue.displayName="BubbleChart",Ze.displayName="Heatmap";const Qe="__splomIdx",et={top:4,bottom:4,left:4,right:4};function tt({frameRef:o,cellSize:s,onBrush:i}){const r=e.useRef(null),l=s-et.left-et.right,c=s-et.top-et.bottom;return e.useEffect(()=>{if(!r.current)return;const e=n.select(r.current).select(".brush-g"),s=t.brush().extent([[0,0],[l,c]]).on("brush end",e=>{var t;const n=null===(t=o.current)||void 0===t?void 0:t.getScales();if(!n)return;if(!e.selection)return void i(null);const[[s,r],[l,a]]=e.selection,c=[[n.x.invert(s),n.y.invert(r)],[n.x.invert(l),n.y.invert(a)]];i(c)});return e.call(s),e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{s.on("brush end",null)}},[l,c,o,i]),a.createElement("svg",{ref:r,width:s,height:s,style:{position:"absolute",top:0,left:0}},a.createElement("g",{className:"brush-g",transform:`translate(${et.left},${et.top})`}))}function nt({data:t,xField:n,yField:o,cellSize:s,pointRadius:i,pointOpacity:r,colorBy:l,colorScale:c,brushSelectionName:u,hoverSelectionName:h,unselectedOpacity:d,mode:f,onPointHover:p}){const m=e.useRef(null),y=ge({name:u,clientId:`splom-${n}-${o}`}),g=be({name:u,xField:n,yField:o}),b=ge({name:h,clientId:"splom-hover-source"}),v=b.selectPoints,x=e.useCallback(e=>{e?g.brushInteraction.during(e):g.brushInteraction.end(null)},[g.brushInteraction]),w=e.useCallback(e=>{if(!e)return void(null==p||p(null));const t=e.data,n=null==t?void 0:t[Qe];void 0!==n&&(v({[Qe]:[n]}),null==p||p(t,e.x+et.left,e.y+et.top))},[v,p]),k=e.useCallback(e=>{const t={opacity:r,r:i};return t.fill=l?ie(e,l,c):we,"hover"===f?b.isActive&&b.predicate(e)?(t.opacity=1,t.r=2.5*i,t.stroke="#333",t.strokeWidth=1.5):b.isActive&&(t.opacity=.6*r):y.isActive&&!y.predicate(e)&&(t.opacity=d),t},[l,c,r,i,f,y.isActive,y.predicate,b.isActive,b.predicate,d]);return a.createElement("div",{style:{position:"relative",width:s,height:s}},a.createElement(ne,{ref:m,chartType:"scatter",data:t,size:[s,s],xAccessor:n,yAccessor:o,pointStyle:k,margin:et,showAxes:!1,enableHover:"hover"===f,customHoverBehavior:"hover"===f?w:void 0,tooltipContent:"hover"===f?()=>null:void 0}),"brush"===f&&a.createElement(tt,{frameRef:m,cellSize:s,xField:n,yField:o,onBrush:x}))}function ot({data:t,field:n,label:o,cellSize:s,bins:i,brushSelectionName:r,hoverSelectionName:l,mode:c}){const u=ge({name:r,clientId:"splom-diag-"+n}),h=ge({name:l,clientId:`splom-diag-${n}-hover`}),d="hover"===c?h:u,f=d.isActive,p=d.predicate,m=e.useMemo(()=>{const e=t.map(e=>e[n]).filter(e=>null!=e&&!isNaN(e));if(0===e.length)return{bars:[],selectedBars:[],max:0};const o=Math.min(...e),r=(Math.max(...e)-o)/i||1,l=Array(i).fill(0),a=Array(i).fill(0);for(const e of t){const t=e[n];if(null==t||isNaN(t))continue;const s=Math.min(Math.floor((t-o)/r),i-1);l[s]++,f&&!p(e)||a[s]++}const c=Math.max(...l,1);return{bars:l.map((e,t)=>({x:t/i*s,w:s/i-1,h:e/c*(s-24),count:e})),selectedBars:a.map((e,t)=>({x:t/i*s,w:s/i-1,h:e/c*(s-24),count:e})),max:c}},[t,n,i,s,f,p]);return a.createElement("svg",{width:s,height:s,style:{overflow:"hidden"}},a.createElement("text",{x:s/2,y:14,textAnchor:"middle",fontSize:11,fontWeight:"bold",fill:"#333"},o),m.bars.map((e,t)=>a.createElement("rect",{key:"bg-"+t,x:e.x,y:s-e.h,width:Math.max(e.w,1),height:e.h,fill:"#ccc",opacity:f?.3:.6})),f&&m.selectedBars.map((e,t)=>a.createElement("rect",{key:"sel-"+t,x:e.x,y:s-e.h,width:Math.max(e.w,1),height:e.h,fill:we,opacity:.7})))}function st({label:e,cellSize:t}){return a.createElement("svg",{width:t,height:t},a.createElement("text",{x:t/2,y:t/2,textAnchor:"middle",dominantBaseline:"middle",fontSize:12,fontWeight:"bold",fill:"#333"},e))}function it(t){const{data:n,fields:o,fieldLabels:s={},colorBy:i,colorScheme:r="category10",cellSize:l=150,cellGap:c=4,pointRadius:u=2,pointOpacity:h=.5,diagonal:d="histogram",histogramBins:f=20,brushMode:p="crossfilter",hoverMode:m=!0,unselectedOpacity:y=.1,showGrid:g=!1,tooltip:b,showLegend:v,idAccessor:x,className:w,onObservation:k,chartId:A}=t,E="splom",M="splom-hover",S=m?"hover":p?"brush":"hover",O=ye(e=>e.clearSelection),[N,L]=e.useState(null),j=e.useCallback(()=>{O(M),L(null)},[O,M]),C=e.useMemo(()=>(n||[]).map((e,t)=>void 0!==e[Qe]?e:Object.assign(Object.assign({},e),{[Qe]:t})),[n]),_=Ae(C,i,r),W=void 0!==v?v:!!i,B=e.useMemo(()=>{if(!W||!i)return null;const e="string"==typeof i?i:null;return e?[...new Set(C.map(t=>t[e]))].map(e=>({label:e+"",color:_?_(e+""):we})):null},[W,i,C,_]),$=e.useMemo(()=>({display:"grid",gridTemplateColumns:"40px "+o.map(()=>l+"px").join(" "),gridTemplateRows:o.map(()=>l+"px").join(" ")+" 40px",gap:c+"px",width:"fit-content"}),[o,l,c,40]);return a.createElement("div",{className:w,style:{position:"relative"}},B&&a.createElement("div",{style:{display:"flex",gap:12,marginBottom:8,flexWrap:"wrap"}},B.map(e=>a.createElement("div",{key:e.label,style:{display:"flex",alignItems:"center",gap:4}},a.createElement("span",{style:{display:"inline-block",width:10,height:10,borderRadius:"50%",backgroundColor:e.color}}),a.createElement("span",{style:{fontSize:11}},e.label)))),a.createElement("div",{style:$,onMouseLeave:"hover"===S?j:void 0},o.map((e,t)=>a.createElement(a.Fragment,{key:"row-"+e},a.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",writingMode:"vertical-rl",transform:"rotate(180deg)",fontSize:11,fontWeight:"bold",color:"#333"}},s[e]||e),o.map((n,o)=>t===o?"label"===d?a.createElement(st,{key:"diag-"+e,label:s[e]||e,cellSize:l}):a.createElement(ot,{key:"diag-"+e,data:C,field:e,label:s[e]||e,cellSize:l,bins:f,colorBy:i,colorScale:_,brushSelectionName:E,hoverSelectionName:M,unselectedOpacity:y,mode:S}):a.createElement(nt,{key:`cell-${e}-${n}`,data:C,xField:n,yField:e,fieldLabels:s,cellSize:l,pointRadius:u,pointOpacity:h,colorBy:i,colorScale:_,brushSelectionName:E,hoverSelectionName:M,unselectedOpacity:y,showGrid:g,tooltip:b,mode:S,onPointHover:"hover"===S?(s,i,r)=>{s?(L({datum:s,xField:n,yField:e,colIndex:o,rowIndex:t,px:null!=i?i:0,py:null!=r?r:0}),k&&k({type:"hover",datum:s,x:null!=i?i:0,y:null!=r?r:0,timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:A})):(L(null),k&&k({type:"hover-end",timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:A}))}:void 0})))),a.createElement("div",null)," ",o.map(e=>a.createElement("div",{key:"col-label-"+e,style:{display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:"bold",color:"#333"}},s[e]||e))),N&&"hover"===S&&(()=>{const e=N.datum,t=s[N.xField]||N.xField,n=s[N.yField]||N.yField,o=i?"function"==typeof i?i(e):e[i]:null,r=x?"function"==typeof x?x(e):e[x]:"Row "+e[Qe];return a.createElement("div",{style:{position:"absolute",left:40+N.colIndex*(l+c)+N.px,top:N.rowIndex*(l+c)+N.py-8,transform:"translate(-50%, -100%)",color:"#333",background:"rgba(255,255,255,0.95)",border:"1px solid #ddd",borderRadius:3,padding:"4px 8px",fontSize:11,lineHeight:1.4,whiteSpace:"nowrap",pointerEvents:"none",zIndex:10}},a.createElement("div",{style:{fontWeight:"bold",marginBottom:2}},r+""),a.createElement("div",null,t,": ",null!=e[N.xField]?Number(e[N.xField]).toFixed(1):"–"),a.createElement("div",null,n,": ",null!=e[N.yField]?Number(e[N.yField]).toFixed(1):"–"),null!=o&&a.createElement("div",{style:{opacity:.8}},"string"==typeof i?i:"group",": ",o+""))})())}function rt(e){const{brushMode:t="crossfilter",hoverMode:n=!0}=e,o={};return!n&&t&&(o.splom={resolution:t}),n&&(o["splom-hover"]={resolution:"union"}),a.createElement(Ke,{selections:o},a.createElement(it,Object.assign({},e)))}function lt({width:o,height:s,margin:i,scales:r,brushDirection:l,extent:c,onBrush:u}){const h=e.useRef(null),d=e.useRef(null),f=e.useRef(!1),p=o+i.left+i.right,m=s+i.top+i.bottom;return e.useEffect(()=>{if(!h.current||!r)return;const e=n.select(h.current).select(".brush-group"),i="x"===l?t.brushX().extent([[0,0],[o,s]]):t.brushY().extent([[0,0],[o,s]]);return i.on("brush end",e=>{if(f.current)return;if(!e.sourceEvent)return;const t=e.selection;if(!t)return void u(null);const n=("x"===l?r.x:r.y).invert;if(!n)return;const o=[n(t[0]),n(t[1])];u(o)}),e.call(i),d.current=i,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.2).attr("stroke","steelblue").attr("stroke-width",1),()=>{i.on("brush end",null)}},[r,o,s,l,u]),e.useEffect(()=>{if(!d.current||!r||!h.current)return;const e=n.select(h.current).select(".brush-group"),t="x"===l?r.x:r.y;if(f.current=!0,c){const n=[t(c[0]),t(c[1])];e.call(d.current.move,n)}else e.call(d.current.move,null);f.current=!1},[c,r,l]),a.createElement("svg",{ref:h,width:p,height:m,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},a.createElement("g",{className:"brush-group",transform:`translate(${i.left},${i.top})`}))}function at(t){var n,o;const{data:s,width:i=600,height:r=400,margin:l,className:c,title:u,xLabel:h,yLabel:d,xFormat:f,yFormat:p,xAccessor:m="x",yAccessor:y="y",lineBy:g,lineDataAccessor:b="coordinates",colorBy:v,colorScheme:x="category10",curve:w="linear",lineWidth:k=2,fillArea:A=!1,areaOpacity:E=.3,showPoints:M=!1,pointRadius:S=3,enableHover:O=!0,showGrid:N=!1,showLegend:L,tooltip:j,minimap:C={},renderBefore:_=!1,onBrush:W,brushExtent:B,frameProps:$={}}=t,H=s||[],[z,T]=e.useState(null),F=null!=B?B:z,P=e.useCallback(e=>{B||T(e),null==W||W(e)},[B,W]),I=e.useRef(null),[D,R]=e.useState(null);e.useEffect(()=>{const e=()=>{var t,n;const o=null===(n=null===(t=I.current)||void 0===t?void 0:t.getScales)||void 0===n?void 0:n.call(t);o?R(o):requestAnimationFrame(e)};requestAnimationFrame(e)},[s]);const G=void 0!==(null===(n=H[0])||void 0===n?void 0:n[b]),Y=e.useMemo(()=>{if(G)return H;if(g){const e=H.reduce((e,t)=>{const n="function"==typeof g?g(t):t[g];if(!e[n]){const t={[b]:[]};"string"==typeof g&&(t[g]=n),e[n]=t}return e[n][b].push(t),e},{});return Object.values(e)}return[{[b]:H}]},[H,g,b,G]),X=e.useMemo(()=>G||g?Y.flatMap(e=>{const t=e[b]||[];return g&&"string"==typeof g?t.map(t=>Object.assign(Object.assign({},t),{[g]:e[g]})):t}):H,[Y,b,G,g,H]),q=Ae(H,v,x),V=e.useMemo(()=>e=>{const t={strokeWidth:k};return t.stroke=v?ie(e,v,q):we,A&&(t.fill=t.stroke,t.fillOpacity=E),t},[v,q,k,A,E]),U=e.useMemo(()=>C.lineStyle?C.lineStyle:e=>{const t={strokeWidth:1};return t.stroke=v?ie(e,v,q):we,t},[v,q,C.lineStyle]),Z=e.useMemo(()=>{if(M)return e=>{const t={r:S,fillOpacity:1};return t.fill=v?ie(e.parentLine||e,v,q):we,t}},[M,S,v,q]),{legend:J,margin:K}=Me({data:Y,colorBy:v,colorScale:q,showLegend:L,userMargin:l}),Q=C.height||60,ee=e.useMemo(()=>{var e,t,n,o,s,i,r,l;return{top:null!==(t=null===(e=C.margin)||void 0===e?void 0:e.top)&&void 0!==t?t:0,bottom:null!==(o=null===(n=C.margin)||void 0===n?void 0:n.bottom)&&void 0!==o?o:20,left:null!==(i=null===(s=C.margin)||void 0===s?void 0:s.left)&&void 0!==i?i:K.left,right:null!==(l=null===(r=C.margin)||void 0===r?void 0:r.right)&&void 0!==l?l:K.right}},[C.margin,K]),te=C.brushDirection||"x",oe=Ie({componentName:"MinimapChart",data:H,accessors:{xAccessor:m,yAccessor:y}});if(oe)return a.createElement(Be,{componentName:"MinimapChart",message:oe,width:i,height:r});const se=A?"area":"line",re=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:se,data:X,xAccessor:m,yAccessor:y,groupAccessor:g||void 0,curve:w,lineStyle:V},M&&{pointStyle:Z}),{size:[i,r],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:K,showAxes:!0,xLabel:h,yLabel:d,xFormat:f,yFormat:p,enableHover:O,showGrid:N}),J&&{legend:J}),u&&{title:u}),j&&{tooltipContent:Ce(j)}),F&&{xExtent:F}),$),le={chartType:se,data:X,xAccessor:m,yAccessor:y,groupAccessor:g||void 0,curve:w,lineStyle:U,size:[i,Q+ee.top+ee.bottom],margin:ee,showAxes:null!==(o=C.showAxes)&&void 0!==o&&o,background:C.background,enableHover:!1},ae=a.createElement("div",{key:"minimap",style:{position:"relative",width:i,overflow:"hidden"}},a.createElement(ne,Object.assign({ref:I},le)),a.createElement(lt,{width:i-ee.left-ee.right,height:Q,margin:ee,scales:D,brushDirection:te,extent:F,onBrush:P})),ce=a.createElement("div",{key:"main",style:{overflow:"hidden"}},a.createElement(ne,Object.assign({},re)));return a.createElement("div",{className:"minimap-chart"+(c?" "+c:"")},_?ae:ce,_?ce:ae)}rt.displayName="ScatterplotMatrix",at.displayName="MinimapChart",exports.AreaChart=Ye,exports.BubbleChart=Ue,exports.ConnectedScatterplot=Ve,exports.Heatmap=Ze,exports.LineChart=Ge,exports.MinimapChart=at,exports.Scatterplot=qe,exports.ScatterplotMatrix=rt,exports.StackedAreaChart=Xe,exports.StreamXYFrame=ne;
1
+ "use strict";const e=require("react"),t=require("d3-brush"),n=require("d3-selection"),o=require("d3-scale"),s=require("d3-array"),i=require("d3-hierarchy"),r=require("regression"),l=require("d3-scale-chromatic");function a(e){return e&&e.__esModule?e:{default:e}}function c(e){if(e&&e.__esModule)return e;const t=Object.create(null);if(e)for(const n in e)if("default"!==n){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:function(){return e[n]}})}return t.default=e,Object.freeze(t)}const u=c(e),h=a(r),d=5e3;class f{constructor(e){this.lastBoundedData=null,this.chunkTimer=0,this.callback=e}clearLastData(){this.lastBoundedData=null,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(e){if(this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),5e3>=e.length)return void this.callback({inserts:e,bounded:!0});this.callback({inserts:e.slice(0,d),bounded:!0,totalSize:e.length});let t=d;const n=()=>{if(t>=e.length)return;if(e!==this.lastBoundedData)return;const o=Math.min(t+d,e.length);this.callback({inserts:e.slice(t,o),bounded:!1}),t=o,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}push(e){this.callback({inserts:[e],bounded:!1})}pushMany(e){0!==e.length&&this.callback({inserts:e,bounded:!1})}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null}}class g{constructor(e){if(this._capacity=e,this.head=0,this._size=0,1>e)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(e)}push(e){let t;return this._size===this._capacity?t=this.buffer[this.head]:this._size++,this.buffer[this.head]=e,this.head=(this.head+1)%this._capacity,t}pushMany(e){const t=[];for(const n of e){const e=this.push(n);void 0!==e&&t.push(e)}return t}get(e){if(e>=0&&this._size>e)return this.buffer[(this.head-this._size+e+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 e=0;const t=this;return{next:()=>t._size>e?{done:!1,value:t.get(e++)}:{done:!0,value:void 0}}}toArray(){const e=[];for(const t of this)e.push(t);return e}resize(e){if(1>e)throw Error("RingBuffer capacity must be at least 1");const t=this.toArray(),n=[];for(;t.length>e;)n.push(t.shift());this._capacity=e,this.buffer=Array(e),this.head=0,this._size=0;for(const e of t)this.push(e);return n}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 p{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(e){Number.isNaN(e)||(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}evict(e){e!==this._min&&e!==this._max||(this._dirty=!0)}recalculate(e,t){this._min=1/0,this._max=-1/0;for(const n of e){const e=t?t(n):n;Number.isNaN(e)||(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}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 y(e,t,n,o,s){const i=new Map;for(const r of e){const e=t(r),l=n(r);if(null==e||null==l||Number.isNaN(e)||Number.isNaN(l))continue;const a=Math.floor(e/o)*o;let c=i.get(a);if(c||(c={start:a,end:a+o,total:0,categories:new Map},i.set(a,c)),c.total+=l,s){const e=s(r);c.categories.set(e,(c.categories.get(e)||0)+l)}}return i}function m(e,t,n,o,s,i){const r=[];for(const s of e){const e=n(s),i=o(s);null==e||null==i||Number.isNaN(e)||Number.isNaN(i)||r.push({px:t.x(e),py:t.y(i),rawY:i,d:s})}r.sort((e,t)=>e.px-t.px);const l=Array(r.length),a=Array(r.length),c=Array(r.length);for(let e=0;r.length>e;e++){const t=r[e];l[e]=[t.px,t.py],a[e]=t.rawY,c[e]=t.d}return{type:"line",path:l,rawValues:a,style:s,datum:c,group:i}}function b(e,t,n,o,s,i,r,l){const a=[];for(const i of e){const e=n(i),r=o(i);if(null==e||null==r||Number.isNaN(e)||Number.isNaN(r))continue;const c=t.x(e),u=l?l(i):s;a.push({px:c,topY:t.y(r),botY:t.y(u)})}a.sort((e,t)=>e.px-t.px);const c=Array(a.length),u=Array(a.length);for(let e=0;a.length>e;e++){const t=a[e];c[e]=[t.px,t.topY],u[e]=[t.px,t.botY]}return{type:"area",topPath:c,bottomPath:u,style:i,datum:e,group:r}}function v(e,t,n,o,s,i,r){const l=n(e),a=o(e);if(null==l||null==a||Number.isNaN(l)||Number.isNaN(a))return null;const c={type:"point",x:t.x(l),y:t.y(a),r:s,style:i,datum:e};return void 0!==r&&(c.pointId=r),c}function x(e,t,n,o,s,i,r){return{type:"rect",x:e,y:t,w:n,h:o,style:s,datum:i,group:r}}function k(e,t,n,o,s,i){return{type:"heatcell",x:e,y:t,w:n,h:o,fill:s,datum:i}}function w(e,t){if("function"==typeof e)return t=>+e(t);const n=e||t;return e=>+e[n]}function A(e,t){return"function"==typeof e?e:e?t=>t[e]+"":void 0}class E{constructor(e){this.xExtent=new p,this.yExtent=new p,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=e,this.buffer=new g(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=w(e.timeAccessor||e.xAccessor,"time"),this.getY=w(e.valueAccessor||e.yAccessor,"value")):(this.getX=w(e.xAccessor,"x"),this.getY=w(e.yAccessor,"y")),this.getGroup=A(e.groupAccessor),this.getCategory=A(e.categoryAccessor),this.getSize=e.sizeAccessor?w(e.sizeAccessor,"size"):void 0,this.getColor=A(e.colorAccessor),this.getBounds=e.boundsAccessor?w(e.boundsAccessor,"bounds"):void 0,this.getY0=e.y0Accessor?w(e.y0Accessor,"y0"):void 0,this.getPointId=A(e.pointIdAccessor),"candlestick"===e.chartType&&(this.getOpen=w(e.openAccessor,"open"),this.getHigh=w(e.highAccessor,"high"),this.getLow=w(e.lowAccessor,"low"),this.getClose=w(e.closeAccessor,"close")),e.pulse&&(this.timestampBuffer=new g(e.windowSize))}ingest(e){const t="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=t,this.needsFullRebuild=!0,e.bounded){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const n=e.totalSize||e.inserts.length;n>this.buffer.capacity&&(this.buffer.resize(n),this.timestampBuffer&&n>this.timestampBuffer.capacity&&this.timestampBuffer.resize(n));for(const n of e.inserts)this.buffer.push(n),this.timestampBuffer&&this.timestampBuffer.push(t),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):(this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n)))}else for(const n of e.inserts){"growing"===this.config.windowMode&&this.buffer.full&&(this.growingCap*=2,this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap));const e=this.buffer.push(n);this.timestampBuffer&&this.timestampBuffer.push(t),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):(this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n))),null!=e&&(this.xExtent.evict(this.getX(e)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(e)),this.yExtent.evict(this.getLow(e))):this.yExtent.evict(this.getY(e)))}return!0}computeScene(e){var t,n,s,i,r,l;const{config:a,buffer:c}=this;if(!this.needsFullRebuild&&this.lastLayout&&this.scene.length>0&&this.scales&&(this.lastLayout.width!==e.width||this.lastLayout.height!==e.height))return void this.remapScene(e);if(this.xExtent.dirty&&this.xExtent.recalculate(c,this.getX),this.yExtent.dirty)if("candlestick"===a.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const e of c)this.yExtent.push(this.getHigh(e)),this.yExtent.push(this.getLow(e))}else this.yExtent.recalculate(c,this.getY);const u=this.xExtent.extent,h=this.yExtent.extent;let d=a.xExtent?[null!==(t=a.xExtent[0])&&void 0!==t?t:u[0],null!==(n=a.xExtent[1])&&void 0!==n?n:u[1]]:u,f=a.yExtent?[null!==(s=a.yExtent[0])&&void 0!==s?s:h[0],null!==(i=a.yExtent[1])&&void 0!==i?i:h[1]]:h;const g=a.yExtent&&null!=a.yExtent[0]&&null!=a.yExtent[1];if("stackedarea"===a.chartType&&!g&&c.size>0)if(a.normalize)f=[0,1+a.extentPadding];else{const e=c.toArray(),t=this.groupData(e),n=new Map;for(const e of t)for(const t of e.data){const e=this.getX(t),o=this.getY(t);null==e||null==o||Number.isNaN(e)||Number.isNaN(o)||n.set(e,(n.get(e)||0)+o)}let o=0;for(const e of n.values())e>o&&(o=e);f=[0,o+(o>0?o*a.extentPadding:1)]}else if("bar"===a.chartType&&a.binSize&&!g&&c.size>0){const[,e]=function(e,t,n,o,s){const i=y(e,t,n,o,s);if(0===i.size)return[0,0];let r=0;for(const e of i.values())e.total>r&&(r=e.total);return[0,r]}(c,this.getX,this.getY,a.binSize,this.getCategory);f=[0,e+e*a.extentPadding]}else if("waterfall"===a.chartType&&!g&&c.size>0){const[e,t]=function(e,t){let n=0,o=0,s=0;for(const i of e){const e=t(i);null==e||Number.isNaN(e)||(s+=e,n>s&&(n=s),s>o&&(o=s))}return[n,o]}(c,this.getY),n=t-e,o=n>0?n*a.extentPadding:1;f=[Math.min(0,e-Math.abs(o)),Math.max(0,t+Math.abs(o))]}else if(!g&&f[0]!==1/0){if(this.getBounds){const e=c.toArray();for(const t of e){const e=this.getY(t),n=this.getBounds(t);null!=e&&!Number.isNaN(e)&&n&&(e+n>f[1]&&(f[1]=e+n),f[0]>e-n&&(f[0]=e-n))}}const e=f[1]-f[0],t=e>0?e*a.extentPadding:1,n=null===(r=a.yExtent)||void 0===r?void 0:r[0],o=null===(l=a.yExtent)||void 0===l?void 0:l[1];f=[null!=n?f[0]:f[0]-t,null!=o?f[1]:f[1]+t]}if(d[0]!==1/0&&d[1]!==-1/0||(d=[0,1]),f[0]!==1/0&&f[1]!==-1/0||(f=[0,1]),void 0!==a.arrowOfTime)if("x"==("up"===(p=a.arrowOfTime)||"down"===p?"y":"x")){const t="right"===a.arrowOfTime?[0,e.width]:[e.width,0];this.scales={x:o.scaleLinear().domain(d).range(t),y:o.scaleLinear().domain(f).range([e.height,0])}}else{const t="down"===a.arrowOfTime?[0,e.height]:[e.height,0];this.scales={x:o.scaleLinear().domain(f).range([0,e.width]),y:o.scaleLinear().domain(d).range(t)}}else this.scales={x:o.scaleLinear().domain(d).range([0,e.width]),y:o.scaleLinear().domain(f).range([e.height,0])};var p;this.config.transition&&this.scene.length>0&&this.snapshotPositions();const m=c.toArray();this.scene=this.buildSceneNodes(e),this.config.decay&&this.applyDecay(this.scene,m),this.config.pulse&&this.applyPulse(this.scene,m),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.needsFullRebuild=!1,this.lastLayout={width:e.width,height:e.height},this.version++}remapScene(e){const t=e.width/this.lastLayout.width,n=e.height/this.lastLayout.height;for(const e of this.scene)switch(e.type){case"line":for(const o of e.path)o[0]*=t,o[1]*=n;break;case"area":for(const o of e.topPath)o[0]*=t,o[1]*=n;for(const o of e.bottomPath)o[0]*=t,o[1]*=n;break;case"point":e.x*=t,e.y*=n;break;case"rect":case"heatcell":e.x*=t,e.y*=n,e.w*=t,e.h*=n;break;case"candlestick":e.x*=t,e.openY*=n,e.closeY*=n,e.highY*=n,e.lowY*=n}const s=this.scales.x.domain(),i=this.scales.y.domain(),r=this.scales.x.range(),l=this.scales.y.range();this.scales={x:o.scaleLinear().domain(s).range([r[0]*t,r[1]*t]),y:o.scaleLinear().domain(i).range([l[0]*n,l[1]*n])},this.lastLayout={width:e.width,height:e.height},this.version++}buildSceneNodes(e){const{config:t,buffer:n,scales:o}=this;if(!o||0===n.size)return[];const s=n.toArray();switch(t.chartType){case"line":return this.buildLineScene(s);case"area":return this.buildAreaScene(s);case"stackedarea":return this.buildStackedAreaScene(s);case"scatter":case"bubble":return this.buildPointScene(s);case"heatmap":return this.buildHeatmapScene(s,e);case"bar":return this.buildBarScene(s);case"swarm":return this.buildSwarmScene(s);case"waterfall":return this.buildWaterfallScene(s,e);case"candlestick":return this.buildCandlestickScene(s,e);default:return[]}}buildLineScene(e){var t;const n=this.groupData(e),o=[],s=null===(t=this.config.annotations)||void 0===t?void 0:t.filter(e=>"threshold"===e.type&&e.color).map(e=>({value:e.value,color:e.color,thresholdType:e.thresholdType||"greater"}));if(this.getBounds)for(const e of n){const t=this.buildBoundsForGroup(e.data,e.key);t&&o.push(t)}for(const e of n){const t=this.resolveLineStyle(e.key,e.data[0]),n=m(e.data,this.scales,this.getX,this.getY,t,e.key);s&&s.length>0&&(n.colorThresholds=s),o.push(n)}return o}buildAreaScene(e){const t=this.groupData(e),n=[],o=this.scales.y.domain()[0];for(const e of t){const t=this.resolveAreaStyle(e.key,e.data[0]),s=b(e.data,this.scales,this.getX,this.getY,o,t,e.key,this.getY0);this.config.gradientFill&&(s.fillGradient=this.config.gradientFill),n.push(s)}return n}buildStackedAreaScene(e){const t=this.groupData(e);return t.sort((e,t)=>t.key>e.key?-1:e.key>t.key?1:0),function(e,t,n,o,s,i){var r;const l=new Set;for(const t of e)for(const e of t.data){const t=n(e);null==t||Number.isNaN(t)||l.add(t)}const a=Array.from(l).sort((e,t)=>e-t),c=new Map;for(const t of e){const e=new Map;for(const s of t.data){const t=n(s),i=o(s);null==t||null==i||Number.isNaN(t)||Number.isNaN(i)||e.set(t,(e.get(t)||0)+i)}c.set(t.key,e)}let u;if(i){u=new Map;for(const t of a){let n=0;for(const o of e)n+=(null===(r=c.get(o.key))||void 0===r?void 0:r.get(t))||0;u.set(t,n||1)}}const h=[],d=new Map;for(const e of a)d.set(e,0);for(const n of e){const e=c.get(n.key),o=[],r=[];for(const n of a){let s=e.get(n)||0;const l=d.get(n);i&&(s/=u.get(n));const a=t.x(n);r.push([a,t.y(l)]),o.push([a,t.y(l+s)]),d.set(n,l+s)}h.push({type:"area",topPath:o,bottomPath:r,style:s(n.key,n.data[0]),datum:n.data,group:n.key})}return h}(t,this.scales,this.getX,this.getY,(e,t)=>this.resolveAreaStyle(e,t),this.config.normalize)}buildPointScene(e){const t=[],n="bubble"===this.config.chartType?10:5,o=this.config.sizeRange||[3,15];let s=null;if(this.getSize&&!this.config.pointStyle){const t=e.map(e=>this.getSize(e)).filter(e=>null!=e&&!Number.isNaN(e));if(t.length>0){const e=Math.min(...t),n=Math.max(...t);s=t=>e===n?(o[0]+o[1])/2:o[0]+(t-e)/(n-e)*(o[1]-o[0])}}let i=null;if(this.getColor&&!this.config.pointStyle){const t=new Set;for(const n of e){const e=this.getColor(n);e&&t.add(e)}const n=Array.isArray(this.config.colorScheme)?this.config.colorScheme:["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];i=new Map;let o=0;for(const e of t)i.set(e,n[o%n.length]),o++}for(const o of e){let e=this.config.pointStyle?this.config.pointStyle(o):{fill:"#4e79a7",opacity:.8},r=e.r||n;if(s&&this.getSize){const e=this.getSize(o);null==e||Number.isNaN(e)||(r=s(e))}if(i&&this.getColor){const t=this.getColor(o);t&&i.has(t)&&(e=Object.assign(Object.assign({},e),{fill:i.get(t)}))}const l=this.getPointId?this.getPointId(o)+"":void 0,a=v(o,this.scales,this.getX,this.getY,r,e,l);a&&t.push(a)}return t}buildHeatmapScene(e,t){const n=[];if(this.config.heatmapAggregation)return this.buildStreamingHeatmapScene(e,t);const o=w(this.config.valueAccessor,"value"),s=new Set,i=new Set;for(const t of e)s.add(this.getX(t)),i.add(this.getY(t));const r=Array.from(s).sort((e,t)=>e-t),l=Array.from(i).sort((e,t)=>e-t);if(0===r.length||0===l.length)return n;const a=t.width/r.length,c=t.height/l.length,u=new Map;for(const t of e){const e=`${this.getX(t)}_${this.getY(t)}`;u.set(e,{val:o(t),datum:t})}let h=1/0,d=-1/0;for(const{val:e}of u.values())h>e&&(h=e),e>d&&(d=e);const f=d-h||1;for(let e=0;r.length>e;e++)for(let t=0;l.length>t;t++){const o=u.get(`${r[e]}_${l[t]}`);if(!o)continue;const s=(o.val-h)/f;n.push(k(e*a,(l.length-1-t)*c,a,c,`rgb(${Math.round(220-180*s)},${Math.round(220-100*s)},${Math.round(255-50*s)})`,o.datum))}return n}buildStreamingHeatmapScene(e,t){var n,o,s;const i=[],r=null!==(n=this.config.heatmapXBins)&&void 0!==n?n:20,l=null!==(o=this.config.heatmapYBins)&&void 0!==o?o:20,a=null!==(s=this.config.heatmapAggregation)&&void 0!==s?s:"count",c=w(this.config.valueAccessor,"value");if(!this.scales||0===e.length)return i;const[u,h]=this.scales.x.domain(),[d,f]=this.scales.y.domain(),g=(h-u||1)/r,p=(f-d||1)/l,y=new Map;for(const t of e){const e=this.getX(t),n=this.getY(t),o=Math.min(Math.floor((e-u)/g),r-1),s=Math.min(Math.floor((n-d)/p),l-1);if(0>o||0>s)continue;const i=`${o}_${s}`;let a=y.get(i);a||(a={sum:0,count:0,data:[]},y.set(i,a)),a.count++,a.sum+=c(t),a.data.push(t)}let m=1/0,b=-1/0;const v=new Map;for(const[e,t]of y){let n;switch(a){case"sum":n=t.sum;break;case"mean":n=t.count>0?t.sum/t.count:0;break;default:n=t.count}v.set(e,n),m>n&&(m=n),n>b&&(b=n)}const x=b-m||1,A=t.width/r,E=t.height/l;for(const[e,t]of v){const[n,o]=e.split("_"),s=+n,r=+o,a=(t-m)/x,c=`rgb(${Math.round(220-180*a)},${Math.round(220-100*a)},${Math.round(255-50*a)})`,u=y.get(e);i.push(k(s*A,(l-1-r)*E,A,E,c,{xi:s,yi:r,value:t,count:u.count,sum:u.sum,data:u.data}))}return i}buildBarScene(e){var t;if(!this.config.binSize)return[];const n=y(e,this.getX,this.getY,this.config.binSize,this.getCategory);if(0===n.size)return[];let o=null;if(this.getCategory){const e=new Set;for(const t of n.values())for(const n of t.categories.keys())e.add(n);const t=this.config.barColors?Object.keys(this.config.barColors):[],s=new Set(t),i=Array.from(e).filter(e=>!s.has(e)).sort();o=[...t.filter(t=>e.has(t)),...i]}const s=[],i=this.scales,[r,l]=i.x.domain();for(const e of n.values()){const n=Math.max(e.start,r),a=Math.min(e.end,l);if(n>=a)continue;const c=i.x(n),u=i.x(a),h=Math.min(c,u)+.5,d=Math.max(c,u)-.5-h;if(d>0)if(o&&e.categories.size>0){let n=0;for(const r of o){const o=e.categories.get(r)||0;if(0===o)continue;const l=i.y(n),a=i.y(n+o);s.push(x(h,Math.min(l,a),d,Math.abs(l-a),{fill:(null===(t=this.config.barColors)||void 0===t?void 0:t[r])||"#4e79a7"},{binStart:e.start,binEnd:e.end,total:e.total,category:r,categoryValue:o},r)),n+=o}}else{const t=i.y(0),n=i.y(e.total);s.push(x(h,Math.min(t,n),d,Math.abs(t-n),{fill:"#007bff"},{binStart:e.start,binEnd:e.end,total:e.total}))}}return s}buildSwarmScene(e){var t,n,o,s;const i=[],r=this.config.swarmStyle||{},l=null!==(t=r.radius)&&void 0!==t?t:3,a=null!==(n=r.fill)&&void 0!==n?n:"#007bff",c=null!==(o=r.opacity)&&void 0!==o?o:.7,u=r.stroke,h=r.strokeWidth;for(const t of e){const e=this.getX(t),n=this.getY(t);if(null==n||Number.isNaN(n))continue;const o=this.scales.x(e),r=this.scales.y(n);let d=a;if(this.getCategory){const e=this.getCategory(t);d=(null===(s=this.config.barColors)||void 0===s?void 0:s[e])||d}const f={type:"point",x:o,y:r,r:l,style:{fill:d,opacity:c,stroke:u,strokeWidth:h},datum:t};this.getPointId&&(f.pointId=this.getPointId(t)+""),i.push(f)}return i}buildWaterfallScene(e,t){var n,o,s;const i=[],r=this.scales,l=this.config.waterfallStyle,a=e.filter(e=>{const t=this.getY(e);return null!=t&&!Number.isNaN(t)});if(0===a.length)return i;const c=null!==(n=null==l?void 0:l.positiveColor)&&void 0!==n?n:"#28a745",u=null!==(o=null==l?void 0:l.negativeColor)&&void 0!==o?o:"#dc3545",h=null!==(s=null==l?void 0:l.gap)&&void 0!==s?s:1,d=null==l?void 0:l.stroke,f=null==l?void 0:l.strokeWidth;let g=0;for(let e=0;a.length>e;e++){const n=a[e],o=this.getX(n),s=this.getY(n),p=g+s;let y;y=a.length-1>e?this.getX(a[e+1])-o:e>0?o-this.getX(a[e-1]):0;const m=r.x(o),b=0!==y?r.x(o+y):m+t.width/10,v=Math.min(m,b)+h/2,k=Math.max(m,b)-h/2-v;if(0>=k){g=p;continue}const w=r.y(g),A=r.y(p);i.push(x(v,Math.min(w,A),k,Math.abs(w-A),{fill:0>s?u:c,stroke:d,strokeWidth:f},Object.assign(Object.assign({},n),{baseline:g,cumEnd:p,delta:s,_connectorStroke:null==l?void 0:l.connectorStroke,_connectorWidth:null==l?void 0:l.connectorWidth}))),g=p}return i}buildCandlestickScene(e,t){if(!(this.getOpen&&this.getHigh&&this.getLow&&this.getClose&&this.scales))return[];const n=[],o=this.config.candlestickStyle||{},s=o.upColor||"#28a745",i=o.downColor||"#dc3545",r=o.wickColor||"#333",l=o.wickWidth||1,a=e.map(e=>this.getX(e)).filter(e=>null!=e&&!Number.isNaN(e)).sort((e,t)=>e-t);let c=o.bodyWidth||6;if(!o.bodyWidth&&a.length>1){let e=1/0;for(let t=1;a.length>t;t++){const n=Math.abs(this.scales.x(a[t])-this.scales.x(a[t-1]));n>0&&e>n&&(e=n)}e!==1/0&&(c=Math.max(2,Math.min(.6*e,20)))}for(const t of e){const e=this.getX(t);if(null==e||Number.isNaN(e))continue;const o=this.getOpen(t),a=this.getHigh(t),u=this.getLow(t),h=this.getClose(t);if([o,a,u,h].some(e=>null==e||Number.isNaN(e)))continue;const d=h>=o;n.push({type:"candlestick",x:this.scales.x(e),openY:this.scales.y(o),closeY:this.scales.y(h),highY:this.scales.y(a),lowY:this.scales.y(u),bodyWidth:c,upColor:s,downColor:i,wickColor:r,wickWidth:l,isUp:d,datum:t})}return n}buildBoundsForGroup(e,t){if(!this.getBounds||!this.scales)return null;const n=[],o=[];for(const t of e){const e=this.getX(t),s=this.getY(t);if(null==e||null==s||Number.isNaN(e)||Number.isNaN(s))continue;const i=this.getBounds(t),r=this.scales.x(e);if(i&&0!==i)n.push([r,this.scales.y(s+i)]),o.push([r,this.scales.y(s-i)]);else{const e=this.scales.y(s);n.push([r,e]),o.push([r,e])}}return 2>n.length?null:{type:"area",topPath:n,bottomPath:o,style:this.resolveBoundsStyle(t,e[0]),datum:e,group:t,interactive:!1}}resolveBoundsStyle(e,t){const n=this.config.boundsStyle;return"function"==typeof n?n(t||{},e):n&&"object"==typeof n?n:{fill:this.resolveLineStyle(e,t).stroke||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(e,t){var n,o,s;const i=this.config.decay;if(!i||1>=t)return 1;const r=null!==(n=i.minOpacity)&&void 0!==n?n:.1,l=t-1-e;switch(i.type){case"linear":return r+(1-l/(t-1))*(1-r);case"exponential":{const e=null!==(o=i.halfLife)&&void 0!==o?o:t/2;return r+Math.pow(.5,l/e)*(1-r)}case"step":return(null!==(s=i.stepThreshold)&&void 0!==s?s:.5*t)>l?1:r;default:return 1}}applyDecay(e,t){var n,o;if(!this.config.decay)return;const s=t.length;if(1>=s)return;const i=new Map;for(let e=0;t.length>e;e++)i.set(t[e],e);for(const t of e){if("line"===t.type||"area"===t.type)continue;const e=i.get(t.datum);if(null==e)continue;const r=this.computeDecayOpacity(e,s);if("heatcell"===t.type)t.style={opacity:r};else if("candlestick"===t.type)t._decayOpacity=r;else{const e=null!==(o=null===(n=t.style)||void 0===n?void 0:n.opacity)&&void 0!==o?o:1;t.style=Object.assign(Object.assign({},t.style),{opacity:e*r})}}}computePulseIntensity(e,t){var n;const o=this.config.pulse;if(!o)return 0;const s=null!==(n=o.duration)&&void 0!==n?n:500,i=t-e;return s>i?1-i/s:0}applyPulse(e,t){var n,o;if(!this.config.pulse||!this.timestampBuffer)return;const s="undefined"!=typeof performance?performance.now():Date.now(),i=null!==(n=this.config.pulse.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",r=null!==(o=this.config.pulse.glowRadius)&&void 0!==o?o:4,l=new Map;for(let e=0;t.length>e;e++)l.set(t[e],e);for(const t of e){if("line"===t.type)continue;if("area"===t.type){const e=Array.isArray(t.datum)?t.datum:[t.datum];let n=0;for(const t of e){const e=l.get(t);if(null==e)continue;const o=this.timestampBuffer.get(e);if(null==o)continue;const i=this.computePulseIntensity(o,s);i>n&&(n=i)}n>0&&(t._pulseIntensity=n,t._pulseColor=i);continue}const e=l.get(t.datum);if(null==e)continue;const n=this.timestampBuffer.get(e);if(null==n)continue;const o=this.computePulseIntensity(n,s);o>0&&(t._pulseIntensity=o,t._pulseColor=i,t._pulseGlowRadius=r)}}get hasActivePulses(){var e;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const t="undefined"!=typeof performance?performance.now():Date.now(),n=null!==(e=this.config.pulse.duration)&&void 0!==e?e:500,o=this.timestampBuffer.peek();return null!=o&&n>t-o}snapshotPositions(){this.prevPositionMap.clear();for(let e=0;this.scene.length>e;e++){const t=this.scene[e],n=this.getNodeIdentity(t,e);n&&("point"===t.type?this.prevPositionMap.set(n,{x:t.x,y:t.y,r:t.r}):"rect"===t.type||"heatcell"===t.type?this.prevPositionMap.set(n,{x:t.x,y:t.y,w:t.w,h:t.h}):"candlestick"===t.type&&this.prevPositionMap.set(n,{x:t.x,y:t.openY}))}}getNodeIdentity(e,t){var n,o,s,i;switch(e.type){case"point":return`p:${void 0===e.datum?t:this.getX(e.datum)}_${this.getY(e.datum)}`;case"rect":return`r:${e.group||""}:${null!==(i=null!==(o=null===(n=e.datum)||void 0===n?void 0:n.binStart)&&void 0!==o?o:null===(s=e.datum)||void 0===s?void 0:s.category)&&void 0!==i?i:t}`;case"heatcell":return`h:${e.x}_${e.y}`;case"candlestick":return"c:"+this.getX(e.datum);default:return null}}startTransition(){var e,t,n,o,s,i;if(!this.config.transition||0===this.prevPositionMap.size)return;const r=null!==(e=this.config.transition.duration)&&void 0!==e?e:300;let l=!1;for(let e=0;this.scene.length>e;e++){const r=this.scene[e],a=this.getNodeIdentity(r,e);if(!a)continue;const c=this.prevPositionMap.get(a);if(c)if("point"===r.type){const e={x:r.x,y:r.y,r:r.r};c.x===e.x&&c.y===e.y||(r._targetX=e.x,r._targetY=e.y,r._targetR=e.r,r.x=c.x,r.y=c.y,r.r=null!==(t=c.r)&&void 0!==t?t:r.r,l=!0)}else if("rect"===r.type){const e={x:r.x,y:r.y,w:r.w,h:r.h};c.x===e.x&&c.y===e.y&&c.w===e.w&&c.h===e.h||(r._targetX=e.x,r._targetY=e.y,r._targetW=e.w,r._targetH=e.h,r.x=c.x,r.y=c.y,r.w=null!==(n=c.w)&&void 0!==n?n:r.w,r.h=null!==(o=c.h)&&void 0!==o?o:r.h,l=!0)}else if("heatcell"===r.type){const e={x:r.x,y:r.y,w:r.w,h:r.h};c.x===e.x&&c.y===e.y||(r._targetX=e.x,r._targetY=e.y,r._targetW=e.w,r._targetH=e.h,r.x=c.x,r.y=c.y,r.w=null!==(s=c.w)&&void 0!==s?s:r.w,r.h=null!==(i=c.h)&&void 0!==i?i:r.h,l=!0)}}l&&(this.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:r})}advanceTransition(e){var t;if(!this.activeTransition)return!1;const n=Math.min((e-this.activeTransition.startTime)/this.activeTransition.duration,1),o="linear"===(null===(t=this.config.transition)||void 0===t?void 0:t.easing)?n:1-Math.pow(1-n,3);for(const e of this.scene)if("point"===e.type){if(void 0===e._targetX)continue;const t=this.getNodeIdentity(e,0);if(!t)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=n.x+(e._targetX-n.x)*o,e.y=n.y+(e._targetY-n.y)*o,void 0!==e._targetR&&void 0!==n.r&&(e.r=n.r+(e._targetR-n.r)*o)}else if("rect"===e.type){if(void 0===e._targetX)continue;const t=this.getNodeIdentity(e,0);if(!t)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=n.x+(e._targetX-n.x)*o,e.y=n.y+(e._targetY-n.y)*o,void 0!==n.w&&(e.w=n.w+(e._targetW-n.w)*o),void 0!==n.h&&(e.h=n.h+(e._targetH-n.h)*o)}else if("heatcell"===e.type){if(void 0===e._targetX)continue;const t=this.getNodeIdentity(e,0);if(!t)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=n.x+(e._targetX-n.x)*o,e.y=n.y+(e._targetY-n.y)*o,void 0!==n.w&&(e.w=n.w+(e._targetW-n.w)*o),void 0!==n.h&&(e.h=n.h+(e._targetH-n.h)*o)}if(n>=1){for(const e of this.scene)if("point"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,void 0!==e._targetR&&(e.r=e._targetR),e._targetX=void 0,e._targetY=void 0,e._targetR=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("heatcell"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}return this.activeTransition=null,!1}return!0}groupData(e){if(!this.getGroup)return[{key:"_default",data:e}];const t=new Map;for(const n of e){const e=this.getGroup(n);t.has(e)||t.set(e,[]),t.get(e).push(n)}return Array.from(t.entries()).map(([e,t])=>({key:e,data:t}))}resolveLineStyle(e,t){const n=this.config.lineStyle;return"function"==typeof n?n(t||{},e):n&&"object"==typeof n?{stroke:n.stroke||"#007bff",strokeWidth:n.strokeWidth||2,strokeDasharray:n.strokeDasharray,fill:n.fill,fillOpacity:n.fillOpacity,opacity:n.opacity}:{stroke:"#007bff",strokeWidth:2}}resolveAreaStyle(e,t){var n;if(this.config.areaStyle)return this.config.areaStyle(t||{});const o=this.config.lineStyle;return"function"==typeof o?o(t||{},e):o&&"object"==typeof o?{fill:o.fill||o.stroke||"#4e79a7",fillOpacity:null!==(n=o.fillOpacity)&&void 0!==n?n:.7,stroke:o.stroke||"#4e79a7",strokeWidth:o.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(e){Object.assign(this.config,e),this.needsFullRebuild=!0}}function S(e,t,n){return n.x>e||e>n.x+n.w||n.y>t||t>n.y+n.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:n.x+n.w/2,cy:n.y+n.h/2}}function M(e,t,n){const o=t-e.x,s=n-e.y,i=Math.sqrt(o*o+s*s);return i>e.r+5?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:i}}function O(e,t,n){if(0===e.path.length)return null;const o=B(e.path,t);if(0>o)return null;const[s,i]=e.path[o],r=t-s,l=n-i,a=Math.sqrt(r*r+l*l);return{node:e,datum:Array.isArray(e.datum)&&e.datum[o]?e.datum[o]:e.datum,x:s,y:i,distance:a}}function C(e,t,n){const o=S(t,n,e);return o.hit?{node:e,datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}function L(e,t,n){const o=S(t,n,e);return o.hit?{node:e,datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}function j(e,t,n){const o=e.bodyWidth/2,s=Math.min(e.openY,e.closeY);if(!(e.x-o-3>t||t>e.x+o+3||e.highY-3>n||n>e.lowY+3)){const o=s+Math.max(Math.max(e.openY,e.closeY)-s,1)/2,i=t-e.x,r=n-o;return{node:e,datum:e.datum,x:e.x,y:o,distance:Math.sqrt(i*i+r*r)}}return null}function N(e,t,n){if(0===e.topPath.length)return null;const o=B(e.topPath,t);if(0>o)return null;const[s,i]=e.topPath[o],r=t-s,l=n-i;return{node:e,datum:e.datum,x:s,y:i,distance:Math.sqrt(r*r+l*l)}}function B(e,t){if(0===e.length)return-1;let n=0,o=e.length-1;for(;o>n;){const s=n+o>>1;t>e[s][0]?n=s+1:o=s}return n>0&&Math.abs(e[n][0]-t)>=Math.abs(e[n-1][0]-t)?n-1:n}const H={fill:e=>u.createElement("rect",{style:e,width:20,height:20}),line:e=>u.createElement("line",{style:e,x1:0,y1:0,x2:20,y2:20})};function _(e,t,n,o){let s;return s="function"==typeof n?n(e):(0,H[n])(o(e,t)),s}function W(){return u.createElement("path",{d:"M2,6 L5,9 L10,3",fill:"none",stroke:"currentColor",strokeWidth:1.5,transform:"translate(-14, 5)"})}function $(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}function z(e){const{legendGroups:t,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:s,isolatedCategories:i,title:r="Legend",width:l=100,height:a=20,orientation:c="vertical"}=e,h="vertical"===c?(({legendGroups:e,width:t,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:s,isolatedCategories:i})=>{let r=30;const l=[];return e.forEach((e,a)=>{r+=5,l.push(u.createElement("line",{key:"legend-top-line legend-symbol-"+a,stroke:"gray",x1:0,y1:r,x2:t,y2:r})),r+=10,e.label&&(r+=20,l.push(u.createElement("text",{key:"legend-text-"+a,y:r,className:"legend-group-label"},e.label)),r+=10),l.push(u.createElement("g",{key:"legend-group-"+a,className:"legend-item",transform:`translate(0,${r})`},((e,t,n,o,s)=>{const{type:i="fill",styleFn:r,items:l}=e,a=[];let c=0;const h=!(!t&&!n);return l.forEach((e,l)=>{const d=_(e,l,i,r),f=$(e,o,s),g=s&&s.size>0&&s.has(e.label);a.push(u.createElement("g",{key:"legend-item-"+l,transform:`translate(0,${c})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,style:{cursor:h?"pointer":"default",opacity:f,transition:"opacity 150ms ease",pointerEvents:"all"}},g&&u.createElement(W,null),d,u.createElement("text",{y:15,x:30},e.label))),c+=25}),a})(e,n,o,s,i))),r+=25*e.items.length+10}),l})({legendGroups:t,width:l,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:s,isolatedCategories:i}):(({legendGroups:e,title:t,height:n,customClickBehavior:o,customHoverBehavior:s,highlightedCategory:i,isolatedCategories:r})=>{let l=0;const a=[],c=!1===t?10:40;return e.forEach((t,h)=>{t.label&&(a.push(u.createElement("text",{key:"legend-text-"+h,transform:`translate(${l},${c}) rotate(90)`,textAnchor:"start",className:"legend-group-label"},t.label)),l+=20);const d=((e,t,n,o,s)=>{const{type:i="fill",styleFn:r,items:l}=e,a=[];let c=0;const h=!(!t&&!n);return l.forEach((e,l)=>{const d=_(e,l,i,r),f=$(e,o,s),g=s&&s.size>0&&s.has(e.label);a.push(u.createElement("g",{key:"legend-item-"+l,transform:`translate(${c},0)`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,style:{cursor:h?"pointer":"default",opacity:f,transition:"opacity 150ms ease",pointerEvents:"all"}},g&&u.createElement(W,null),d,u.createElement("text",{y:15,x:25},e.label))),c+=35,c+=8*e.label.length}),{items:a,offset:c}})(t,o,s,i,r);a.push(u.createElement("g",{key:"legend-group-"+h,className:"legend-item",transform:`translate(${l},${c})`},d.items)),l+=d.offset+5,e[h+1]&&a.push(u.createElement("line",{key:"legend-top-line legend-symbol-"+h,stroke:"gray",x1:l,y1:c-10,x2:l,y2:n+c+10})),l+=15}),u.createElement("g",null,!1!==t&&u.createElement("line",{x1:0,x2:l+10,y1:c-10,y2:c-10,stroke:"gray",className:"title-neatline"}),a)})({legendGroups:t,title:r,height:a,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:s,isolatedCategories:i});return u.createElement("g",null,void 0!==r&&u.createElement("text",{className:"legend-title",y:20,x:"horizontal"===c?0:l/2,textAnchor:"horizontal"===c?"start":"middle"},r),h)}function I(e){return"string"==typeof e?{type:e}:e}function F({orient:t,config:n,values:o,scale:i,size:r,length:l}){const a=function(e){var t,n,o,s,i;return{type:e.type,bins:null!==(t=e.bins)&&void 0!==t?t:20,fill:null!==(n=e.fill)&&void 0!==n?n:"#4e79a7",fillOpacity:null!==(o=e.fillOpacity)&&void 0!==o?o:.5,stroke:null!==(s=e.stroke)&&void 0!==s?s:"none",strokeWidth:null!==(i=e.strokeWidth)&&void 0!==i?i:1}}(n),c="top"===t||"bottom"===t,h=e.useMemo(()=>{if(0===o.length)return null;const e=i.domain(),n=r-8;if("boxplot"===a.type){const e=function(e){const t=[...e].sort((e,t)=>e-t),n=t.length;if(0===n)return null;const o=t[Math.floor(.25*n)],s=t[Math.floor(.5*n)],i=t[Math.floor(.75*n)],r=i-o;return{q1:o,median:s,q3:i,whiskerLow:Math.max(t[0],o-1.5*r),whiskerHigh:Math.min(t[n-1],i+1.5*r)}}(o);if(!e)return null;const{q1:s,median:r,q3:l,whiskerLow:h,whiskerHigh:d}=e,f=Math.min(.5*n,20),g=(n-f)/2+4;if(c){const e=i(s),n=i(l),o=i(r),c=i(h),p=i(d),y="top"===t?-1:1,m=0;return u.createElement("g",{"data-testid":"marginal-boxplot-"+t},u.createElement("line",{x1:c,y1:m+y*(g+f/2),x2:p,y2:m+y*(g+f/2),stroke:a.fill,strokeWidth:a.strokeWidth}),u.createElement("line",{x1:c,y1:m+y*g,x2:c,y2:m+y*(g+f),stroke:a.fill,strokeWidth:a.strokeWidth}),u.createElement("line",{x1:p,y1:m+y*g,x2:p,y2:m+y*(g+f),stroke:a.fill,strokeWidth:a.strokeWidth}),u.createElement("rect",{x:Math.min(e,n),y:"top"===t?m-g-f:m+g,width:Math.abs(n-e),height:f,fill:a.fill,fillOpacity:a.fillOpacity,stroke:"none"===a.stroke?a.fill:a.stroke,strokeWidth:a.strokeWidth}),u.createElement("line",{x1:o,y1:"top"===t?m-g-f:m+g,x2:o,y2:"top"===t?m-g:m+g+f,stroke:a.fill,strokeWidth:2}))}{const e=i(s),n=i(l),o=i(r),c=i(h),p=i(d),y="left"===t?-1:1,m=0;return u.createElement("g",{"data-testid":"marginal-boxplot-"+t},u.createElement("line",{x1:m+y*(g+f/2),y1:c,x2:m+y*(g+f/2),y2:p,stroke:a.fill,strokeWidth:a.strokeWidth}),u.createElement("line",{x1:m+y*g,y1:c,x2:m+y*(g+f),y2:c,stroke:a.fill,strokeWidth:a.strokeWidth}),u.createElement("line",{x1:m+y*g,y1:p,x2:m+y*(g+f),y2:p,stroke:a.fill,strokeWidth:a.strokeWidth}),u.createElement("rect",{x:"left"===t?m-g-f:m+g,y:Math.min(e,n),width:f,height:Math.abs(n-e),fill:a.fill,fillOpacity:a.fillOpacity,stroke:"none"===a.stroke?a.fill:a.stroke,strokeWidth:a.strokeWidth}),u.createElement("line",{x1:"left"===t?m-g-f:m+g,y1:o,x2:"left"===t?m-g:m+g+f,y2:o,stroke:a.fill,strokeWidth:2}))}}const h=s.bin().domain(e).thresholds(a.bins)(o);if(0===h.length)return null;const d=Math.max(...h.map(e=>e.length));if(0===d)return null;if("histogram"===a.type)return u.createElement("g",{"data-testid":"marginal-histogram-"+t},h.map((e,o)=>{if(null==e.x0||null==e.x1)return null;const s=e.length/d*n;if(c){const n=i(e.x0),r=i(e.x1)-i(e.x0);return u.createElement("rect",{key:o,x:n,y:"top"===t?-4-s:4,width:Math.max(r,.5),height:s,fill:a.fill,fillOpacity:a.fillOpacity,stroke:a.stroke,strokeWidth:a.strokeWidth})}{const n=i(e.x0),r=i(e.x1)-i(e.x0);return u.createElement("rect",{key:o,x:"left"===t?-4-s:4,y:Math.min(n,n+r),width:s,height:Math.abs(r),fill:a.fill,fillOpacity:a.fillOpacity,stroke:a.stroke,strokeWidth:a.strokeWidth})}}));if("violin"===a.type){const e=n/2+4,o=[];for(const s of h){if(null==s.x0||null==s.x1)continue;const r=s.length/d*(n/2),l=i((s.x0+s.x1)/2);o.push(c?`${l},${"top"===t?-(e-r):e-r}`:`${"left"===t?-(e-r):e-r},${l}`)}for(let s=h.length-1;s>=0;s--){const r=h[s];if(null==r.x0||null==r.x1)continue;const l=r.length/d*(n/2),a=i((r.x0+r.x1)/2);o.push(c?`${a},${"top"===t?-(e+l):e+l}`:`${"left"===t?-(e+l):e+l},${a}`)}return u.createElement("g",{"data-testid":"marginal-violin-"+t},u.createElement("polygon",{points:o.join(" "),fill:a.fill,fillOpacity:a.fillOpacity,stroke:"none"===a.stroke?a.fill:a.stroke,strokeWidth:a.strokeWidth}))}if("ridgeline"===a.type){const e=[];if(c){const o=0,s=null!=h[0].x0?i(h[0].x0):0;e.push(`M${s},${o}`);for(const o of h){if(null==o.x0||null==o.x1)continue;const s=o.length/d*n,r=i((o.x0+o.x1)/2);e.push(`L${r},${"top"===t?-s-4:s+4}`)}const r=null!=h[h.length-1].x1?i(h[h.length-1].x1):l;e.push(`L${r},${o}`),e.push("Z")}else{const o=0,s=null!=h[0].x0?i(h[0].x0):0;e.push(`M${o},${s}`);for(const o of h){if(null==o.x0||null==o.x1)continue;const s=o.length/d*n,r=i((o.x0+o.x1)/2);e.push(`L${"left"===t?-s-4:s+4},${r}`)}const r=null!=h[h.length-1].x1?i(h[h.length-1].x1):l;e.push(`L${o},${r}`),e.push("Z")}return u.createElement("g",{"data-testid":"marginal-ridgeline-"+t},u.createElement("path",{d:e.join(" "),fill:a.fill,fillOpacity:a.fillOpacity,stroke:"none"===a.stroke?a.fill:a.stroke,strokeWidth:a.strokeWidth}))}return null},[o,i,a,r,l,t,c,4]);return h?u.createElement("g",{className:"marginal-"+t,"data-testid":"marginal-"+t},h):null}function P(e,t=120,n=8){if(!e)return[];const o=Math.max(1,Math.floor(t/n)),s=e.split(/\s+/),i=[];let r="";for(const e of s)r&&r.length+1+e.length>o?(i.push(r),r=e):r=r?`${r} ${e}`:e;return r&&i.push(r),i}function T(e,t,n,o){return"curly"===e?o?`M0,0 C${.6*n},0 ${.4*n},${t/2} ${n},${t/2} C${.4*n},${t/2} ${.6*n},${t} 0,${t}`:`M0,0 C0,${.6*n} ${t/2},${.4*n} ${t/2},${n} C${t/2},${.4*n} ${t},${.6*n} ${t},0`:o?`M0,0 L${n},0 L${n},${t} L0,${t}`:`M0,0 L0,${n} L${t},${n} L${t},0`}function D(e){const{x:t=0,y:n=0,dx:o,dy:s,nx:i,ny:r,note:l,connector:a,subject:c,type:h,color:d,className:f,disable:g,events:p={},"data-testid":y}=e,m=new Set(Array.isArray(g)?g:[]);let b=o||0,v=s||0;null!=i&&(b=i-t),null!=r&&(v=r-n);const x="string"==typeof h?h:"label";if("bracket"===x&&c&&0===b&&0===v)if(void 0!==c.width){b=c.width/2;const e=c.depth||30;v=e+(0>e?-5:5)}else if(void 0!==c.height){const e=c.depth||30;b=e+(0>e?-5:5),v=c.height/2}return u.createElement("g",Object.assign({className:("annotation "+(f||"")).trim(),transform:`translate(${t},${n})`,"data-testid":y},p),!m.has("connector")&&function(e,t,n,o,s,i){const r=[];let l=0,a=0;if("callout-circle"!==s&&"label"!==s||!(null==i?void 0:i.radius)){if("callout-rect"===s&&i){const n=i.width||0,o=i.height||0;if(n>0||o>0){const s=n/2,i=o/2,r=e-s,c=t-i;if(0!==r||0!==c){const e=Math.abs(r),t=Math.abs(c),u=n/2,h=o/2,d=e*h>t*u?u/e:h/t;l=s+r*d,a=i+c*d}}}else if("bracket"===s&&i){const e=i.width,t=i.height,n=i.depth||30;void 0!==e?(l=e/2,a=n):void 0!==t&&(l=n,a=t/2)}}else{const n=(i.radius||0)+(i.radiusPadding||0);if(n>0&&(0!==e||0!==t)){const o=Math.atan2(t,e);l=Math.cos(o)*n,a=Math.sin(o)*n}}if(Math.sqrt(Math.pow(e-l,2)+Math.pow(t-a,2))>.5&&(r.push(u.createElement("line",{key:"connector-line",x1:l,y1:a,x2:e,y2:t,stroke:o||"currentColor"})),"arrow"===(null==n?void 0:n.end))){const n=10,s=16/180*Math.PI,i=Math.atan2(t-a,e-l);r.push(u.createElement("path",{key:"connector-arrow",d:`M${l},${a}L${l+n*Math.cos(i+s)},${a+n*Math.sin(i+s)}L${l+n*Math.cos(i-s)},${a+n*Math.sin(i-s)}Z`,fill:o||"currentColor",stroke:"none"}))}return u.createElement("g",{className:"annotation-connector"},r)}(b,v,a,d,x,c),!m.has("subject")&&function(e,t,n,o,s){var i;const r=[];switch(e){case"callout-circle":{const e=((null==t?void 0:t.radius)||0)+((null==t?void 0:t.radiusPadding)||0);e>0&&r.push(u.createElement("circle",{key:"subject-circle",r:e,fill:"none",stroke:n||"currentColor"}));break}case"callout-rect":{const e=(null==t?void 0:t.width)||0,o=(null==t?void 0:t.height)||0;(e>0||o>0)&&r.push(u.createElement("rect",{key:"subject-rect",width:e,height:o,fill:"none",stroke:n||"currentColor"}));break}case"callout-custom":(null==t?void 0:t.custom)&&r.push(...Array.isArray(t.custom)?t.custom:[t.custom]);break;case"xy-threshold":{const e=o||0,i=s||0;if(void 0!==(null==t?void 0:t.x)){const o=(t.x||0)-e;r.push(u.createElement("line",{key:"threshold-line",x1:o,y1:(t.y1||0)-i,x2:o,y2:(t.y2||0)-i,stroke:n||"currentColor",strokeDasharray:"5,5"}))}else if(void 0!==(null==t?void 0:t.y)){const o=(t.y||0)-i;r.push(u.createElement("line",{key:"threshold-line",x1:(t.x1||0)-e,y1:o,x2:(t.x2||0)-e,y2:o,stroke:n||"currentColor",strokeDasharray:"5,5"}))}else void 0!==(null==t?void 0:t.x1)||void 0!==(null==t?void 0:t.x2)?r.push(u.createElement("line",{key:"threshold-line",x1:(t.x1||0)-e,y1:0,x2:(t.x2||0)-e,y2:0,stroke:n||"currentColor",strokeDasharray:"5,5"})):void 0===(null==t?void 0:t.y1)&&void 0===(null==t?void 0:t.y2)||r.push(u.createElement("line",{key:"threshold-line",x1:0,y1:(t.y1||0)-i,x2:0,y2:(t.y2||0)-i,stroke:n||"currentColor",strokeDasharray:"5,5"}));break}case"bracket":{const e=null!==(i=null==t?void 0:t.width)&&void 0!==i?i:null==t?void 0:t.height;void 0!==e&&r.push(u.createElement("path",{key:"bracket-path",d:T((null==t?void 0:t.type)||"curly",e,(null==t?void 0:t.depth)||30,void 0===(null==t?void 0:t.width)),fill:"none",stroke:n||"currentColor"}));break}}return u.createElement("g",{className:"annotation-subject"},r)}(x,c,d,t,n),!m.has("note")&&function(e,t,n,o){if(!e)return u.createElement("g",{className:"annotation-note"});const{label:s,title:i,orientation:r,align:l,wrap:a=120,noWrap:c}=e;if(!s&&!i)return u.createElement("g",{className:"annotation-note"});let h=r;h||(h=Math.abs(t)>Math.abs(n)?"leftRight":"topBottom");let d=l;d&&"dynamic"!==d||(d="topBottom"===h?0>t?"right":"left":0>n?"bottom":"top");let f="start";"topBottom"===h?"right"===d?f="end":"middle"===d&&(f="middle"):f=0>t?"end":"start";const g=16,p=i?c?[i]:P(i,a):[],y=s?c?[s]:P(s,a):[],m="leftRight"===h?"end"===f?-4:4:0;let b=0;const v=[];p.length>0&&(v.push(u.createElement("text",{key:"annotation-note-title",className:"annotation-note-title",fill:o||void 0,textAnchor:f,fontWeight:"bold"},p.map((e,t)=>u.createElement("tspan",{key:t,x:m,dy:0===t?0:g},e)))),b=p.length*g),y.length>0&&v.push(u.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:o||void 0,textAnchor:f,y:b},y.map((e,t)=>u.createElement("tspan",{key:t,x:m,dy:0===t?0:g},e))));let x=null;if((i||s)&&(0!==t||0!==n))if("topBottom"===h){const e=Math.min(a,120);let t=0,n=e;"end"===f?(t=-e,n=0):"middle"===f&&(t=-e/2,n=e/2),x=u.createElement("line",{className:"note-line",x1:t,x2:n,y1:0,y2:0,stroke:o||"currentColor"})}else{const e=(p.length+y.length)*g+(y.length>0?g:0);let t=0,n=e;"bottom"===d?(t=-e,n=0):"middle"===d&&(t=-e/2,n=e/2),x=u.createElement("line",{className:"note-line",x1:0,x2:0,y1:t,y2:n,stroke:o||"currentColor"})}const k=Math.max(0,p.length+y.length-1)*g;let w=0;return"topBottom"===h?w=0>n?-(k+2):18:"leftRight"===h&&(w="middle"===d?-(k+g+(y.length>0&&p.length>0?2:0))/2+8:"bottom"===d||0>n?-(k+2):18),u.createElement("g",{className:"annotation-note",transform:`translate(${t},${n})`},u.createElement("g",{className:"annotation-note-content",transform:0!==w?`translate(0,${w})`:void 0},v),x)}(l,b,v,d))}function R(e){var t,n;const{noteData:o}=e,{screenCoordinates:s}=o,i="string"==typeof o.type?o.type:"label",r=o.eventListeners||o.events||{};if(o.coordinates&&s){const e=o.nx||s[0][0]+(null!==(t=o.dx)&&void 0!==t?t:0),r=o.ny||s[0][1]+(null!==(n=o.dy)&&void 0!==n?n:0),l=s.map((t,n)=>{const s=Object.assign({},o,{note:0===n?o.note:{label:""},x:t[0],y:t[1],nx:e,ny:r});return u.createElement(D,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+n},s,{type:i}))});return u.createElement("g",null,l)}const l=o.note||{title:"none",label:o.label};return u.createElement(D,Object.assign({"data-testid":"semiotic-annotation",key:`${l.label}-${l.title}-${o.i}`,events:r},o,{type:i}))}function Y(e,t){var n,o,s;const i=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.x)&&void 0!==o?o:null===(s=t.scales)||void 0===s?void 0:s.time;return i?null!=e.x?i(e.x):t.xAccessor&&null!=e[t.xAccessor]?i(e[t.xAccessor]):null:null}function G(e,t){var n,o,s;const i=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.y)&&void 0!==o?o:null===(s=t.scales)||void 0===s?void 0:s.value;return i?null!=e.y?i(e.y):t.yAccessor&&null!=e[t.yAccessor]?i(e[t.yAccessor]):null:null}function X(e,t,n,o=50){return!(-o>e||e>(n.width||0)+o||-o>t||t>(n.height||0)+o)}function q(e,t,n){if("left"===e||"right"===e){const o="left"===e?n:0,s="left"===e?-1:1,i=Math.ceil(t/8);let r="M0,"+o;for(let e=0;i>e;e++){const n=8*(e+1);r+=`L${Math.min(8*e+4,t)},${o+4*s}`,r+=`L${Math.min(n,t)},${o}`}return r}{const o="bottom"===e?0:t,s="bottom"===e?1:-1,i=Math.ceil(n/8);let r=`M${o},0`;for(let e=0;i>e;e++){const t=8*(e+1);r+=`L${o+4*s},${Math.min(8*e+4,n)}`,r+=`L${o},${Math.min(t,n)}`}return r}}function V(e){return Math.round(100*e)/100+""}function U(e,t){return e instanceof Date&&(!(t&&t instanceof Date)||e.getFullYear()!==t.getFullYear()||e.getMonth()!==t.getMonth()||e.getDate()!==t.getDate())}function Z(t){const{width:n,height:o,totalWidth:s,totalHeight:r,margin:l,scales:a,showAxes:c,axes:d,xLabel:f,yLabel:g,xFormat:p,yFormat:y,showGrid:m,title:b,legend:v,legendHoverBehavior:x,legendClickBehavior:k,legendHighlightedCategory:w,legendIsolatedCategories:A,foregroundGraphics:E,marginalGraphics:S,xValues:M,yValues:O,annotations:C,svgAnnotationRules:L,annotationFrame:j,xAccessor:N,yAccessor:B,annotationData:H,pointNodes:_,children:W}=t,$=e.useMemo(()=>c&&a?a.x.ticks(5).map(e=>({value:e,pixel:a.x(e),label:(p||V)(e)})):[],[c,a,p]),P=e.useMemo(()=>c&&a?a.y.ticks(5).map(e=>({value:e,pixel:a.y(e),label:(y||V)(e)})):[],[c,a,y]),T=e.useMemo(()=>{if(!C||0===C.length)return null;const e=function(e,t,n){var o,s,r,l,a,c,d,f,g,p,y,m,b,v,x,k,w,A,E,S,M,O,C,L,j,N,B,H,_,W,$,z,I,F,P,T,D,q,V,U,Z,J,K,Q;switch(e.type){case"label":{let o=null,s=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);if(!t)return null;o=t.x,s=t.y}else o=Y(e,n),s=G(e,n);return null==o||null==s?null:X(o,s,n)?u.createElement(R,{key:"ann-"+t,noteData:{x:o,y:s,dx:e.dx||30,dy:e.dy||-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"label",connector:e.connector||{end:"arrow"},color:e.color}}):null}case"callout":{let o=null,s=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);if(!t)return null;o=t.x,s=t.y}else o=Y(e,n),s=G(e,n);return null==o||null==s?null:X(o,s,n)?u.createElement(R,{key:"ann-"+t,noteData:{x:o,y:s,dx:e.dx||30,dy:e.dy||-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"callout-circle",subject:{radius:e.radius||12},connector:e.connector||{end:"arrow"},color:e.color}}):null}case"x-threshold":{const o=Y(e,n);if(null==o)return null;const s=e.color||"#f97316";return u.createElement("g",{key:"ann-"+t},u.createElement("line",{x1:o,y1:0,x2:o,y2:n.height||0,stroke:s,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&u.createElement("text",{x:o+4,y:12,fill:s,fontSize:12,fontWeight:"bold"},e.label))}case"y-threshold":{const o=G(e,n);if(null==o)return null;const s=e.color||"#f97316";return u.createElement("g",{key:"ann-"+t},u.createElement("line",{x1:0,y1:o,x2:n.width||0,y2:o,stroke:s,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&u.createElement("text",{x:(n.width||0)-4,y:o-4,textAnchor:"end",fill:s,fontSize:12,fontWeight:"bold"},e.label))}case"enclose":{const o=(e.coordinates||[]).map(e=>({x:Y(Object.assign(Object.assign({},e),{type:"point"}),n),y:G(Object.assign(Object.assign({},e),{type:"point"}),n),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>o.length)return null;const s=i.packEnclose(o),r=e.padding||10;return u.createElement("g",{key:"ann-"+t},u.createElement("circle",{cx:s.x,cy:s.y,r:s.r+r,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&u.createElement("text",{x:s.x,y:s.y-s.r-r-4,textAnchor:"middle",fill:e.color||"#666",fontSize:12},e.label))}case"rect-enclose":{const o=(e.coordinates||[]).map(e=>({x:Y(Object.assign(Object.assign({},e),{type:"point"}),n),y:G(Object.assign(Object.assign({},e),{type:"point"}),n)})).filter(e=>null!=e.x&&null!=e.y);if(2>o.length)return null;const s=e.padding||10,i=o.map(e=>e.x),r=o.map(e=>e.y),l=Math.min(...i)-s,a=Math.max(...i)+s,c=Math.min(...r)-s,h=Math.max(...r)+s;return u.createElement("g",{key:"ann-"+t},u.createElement("rect",{x:l,y:c,width:a-l,height:h-c,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&u.createElement("text",{x:(l+a)/2,y:c-4,textAnchor:"middle",fill:e.color||"#666",fontSize:12},e.label))}case"highlight":{const o=n.data||[],s="function"==typeof e.filter?o.filter(e.filter):e.field&&null!=e.value?o.filter(t=>t[e.field]===e.value):[],i=e.style||{stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return u.createElement("g",{key:"ann-"+t},s.map((t,o)=>{const s=Y(t,n),r=G(t,n);return null==s||null==r?null:u.createElement("circle",Object.assign({key:o,cx:s,cy:r,r:e.r||6},i))}))}case"bracket":{const o=Y(e,n),s=G(e,n);return u.createElement(R,{key:"ann-"+t,noteData:{x:null!=o?o:0,y:null!=s?s:0,dx:e.dx||0,dy:e.dy||0,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"bracket",subject:{type:e.bracketType||"curly",width:e.width,height:e.height,depth:e.depth||30},color:e.color}})}case"trend":{const i=n.data||[];if(2>i.length)return null;const f=n.xAccessor||"x",g=n.yAccessor||"y",p=i.map(e=>[e[f],e[g]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>p.length)return null;const y=null!==(s=null===(o=n.scales)||void 0===o?void 0:o.x)&&void 0!==s?s:null===(r=n.scales)||void 0===r?void 0:r.time,m=null!==(a=null===(l=n.scales)||void 0===l?void 0:l.y)&&void 0!==a?a:null===(c=n.scales)||void 0===c?void 0:c.value;if(!y||!m)return null;const b=e.method||"linear";let v;v="loess"===b?function(e,t=.3){const n=e.length;if(2>n)return e.slice();const o=e.slice().sort((e,t)=>e[0]-t[0]),s=o.map(e=>e[0]),i=o.map(e=>e[1]),r=Math.max(2,Math.ceil(t*n)),l=[];for(let e=0;n>e;e++){const t=s[e],o=s.map(e=>Math.abs(e-t)),a=o.slice().sort((e,t)=>e-t)[Math.min(r-1,n-1)]||1,c=[];for(let e=0;n>e;e++){const t=0===a?0:o[e]/a;c[e]=1>t?Math.pow(1-Math.pow(t,3),3):0}let u=0,h=0,d=0,f=0,g=0;for(let e=0;n>e;e++){const t=c[e];0!==t&&(u+=t,h+=t*s[e],d+=t*i[e],f+=t*s[e]*s[e],g+=t*s[e]*i[e])}if(0===u){l.push([t,i[e]]);continue}const p=u*f-h*h;if(1e-12>Math.abs(p))l.push([t,d/u]);else{const e=(u*g-h*d)/p;l.push([t,(d-e*h)/u+e*t])}}return l}(p,null!==(d=e.bandwidth)&&void 0!==d?d:.3):("polynomial"===b?h.default.polynomial(p,{order:e.order||2}):h.default.linear(p)).points;const x=v.map(([e,t])=>`${y(e)},${m(t)}`).join(" "),k=e.color||"#6366f1";return u.createElement("g",{key:"ann-"+t},u.createElement("polyline",{points:x,fill:"none",stroke:k,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&u.createElement("text",{x:y(v[v.length-1][0])+4,y:m(v[v.length-1][1])-4,fill:k,fontSize:11},e.label))}case"band":{const o=null!==(g=null===(f=n.scales)||void 0===f?void 0:f.y)&&void 0!==g?g:null===(p=n.scales)||void 0===p?void 0:p.value,s=null!==(y=null==o?void 0:o(e.y0))&&void 0!==y?y:0,i=null!==(m=null==o?void 0:o(e.y1))&&void 0!==m?m:n.height||0;return u.createElement("g",{key:"ann-"+t},u.createElement("rect",{x:0,y:Math.min(s,i),width:n.width||0,height:Math.abs(i-s),fill:e.fill||"#6366f1",fillOpacity:e.fillOpacity||.1}),e.label&&u.createElement("text",{x:(n.width||0)-4,y:Math.min(s,i)-4,textAnchor:"end",fill:e.color||"#6366f1",fontSize:11},e.label))}case"envelope":{const o=n.data||[];if(2>o.length)return null;const s=n.xAccessor||"x",i=null!==(v=null===(b=n.scales)||void 0===b?void 0:b.x)&&void 0!==v?v:null===(x=n.scales)||void 0===x?void 0:x.time,r=null!==(w=null===(k=n.scales)||void 0===k?void 0:k.y)&&void 0!==w?w:null===(A=n.scales)||void 0===A?void 0:A.value;if(!i||!r)return null;const l=e.upperAccessor||"upperBounds",a=e.lowerAccessor||"lowerBounds",c=e.filter,h=o.filter(e=>null!=e[l]&&null!=e[a]&&!(c&&!c(e))).sort((e,t)=>e[s]-t[s]);if(2>h.length)return null;const d=h.map(e=>`${i(e[s])},${r(e[l])}`).join(" L"),f=h.slice().reverse().map(e=>`${i(e[s])},${r(e[a])}`).join(" L"),g=e.fill||"#6366f1";return u.createElement("g",{key:"ann-"+t},u.createElement("path",{d:`M${d} L${f} Z`,fill:g,fillOpacity:null!==(E=e.fillOpacity)&&void 0!==E?E:.15,stroke:"none"}),e.label&&h.length>0&&u.createElement("text",{x:i(h[h.length-1][s])+4,y:r(h[h.length-1][l])-4,fill:g,fontSize:11},e.label))}case"anomaly-band":{const o=n.data||[];if(2>o.length)return null;const s=n.yAccessor||"y",i=null!==(M=null===(S=n.scales)||void 0===S?void 0:S.x)&&void 0!==M?M:null===(O=n.scales)||void 0===O?void 0:O.time,r=null!==(L=null===(C=n.scales)||void 0===C?void 0:C.y)&&void 0!==L?L:null===(j=n.scales)||void 0===j?void 0:j.value;if(!i||!r)return null;const l=o.map(e=>e[s]).filter(e=>null!=e&&isFinite(e));if(2>l.length)return null;const a=l.reduce((e,t)=>e+t,0)/l.length,c=l.reduce((e,t)=>e+Math.pow(t-a,2),0)/l.length,h=Math.sqrt(c),d=null!==(N=e.threshold)&&void 0!==N?N:2,f=a-d*h,g=!1!==e.showBand,p=e.fill||"#6366f1",y=null!==(B=e.fillOpacity)&&void 0!==B?B:.1,m=e.anomalyColor||"#ef4444",b=null!==(H=e.anomalyRadius)&&void 0!==H?H:6,v=r(a+d*h),x=r(f),k=o.filter(e=>{const t=e[s];return null!=t&&Math.abs(t-a)>d*h});return u.createElement("g",{key:"ann-"+t},g&&u.createElement("rect",{x:0,y:Math.min(v,x),width:n.width||0,height:Math.abs(x-v),fill:p,fillOpacity:y}),k.map((e,t)=>{const o=Y(e,n),s=G(e,n);return null==o||null==s?null:u.createElement("circle",{key:t,cx:o,cy:s,r:b,fill:m,fillOpacity:.7,stroke:m,strokeWidth:1.5})}),e.label&&u.createElement("text",{x:(n.width||0)-4,y:Math.min(v,x)-4,textAnchor:"end",fill:p,fontSize:11},e.label))}case"forecast":{const o=n.data||[];if(3>o.length)return null;const s=n.xAccessor||"x",i=n.yAccessor||"y",r=null!==(W=null===(_=n.scales)||void 0===_?void 0:_.x)&&void 0!==W?W:null===($=n.scales)||void 0===$?void 0:$.time,l=null!==(I=null===(z=n.scales)||void 0===z?void 0:z.y)&&void 0!==I?I:null===(F=n.scales)||void 0===F?void 0:F.value;if(!r||!l)return null;const a=o.map(e=>[e[s],e[i]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]);if(3>a.length)return null;let c;if("polynomial"===(e.method||"linear")){const t=h.default.polynomial(a,{order:e.order||2}).equation;c=e=>t.reduce((t,n,o)=>t+n*Math.pow(e,o),0)}else{const e=a.length;let t=0,n=0,o=0,s=0;for(const[e,i]of a)t+=e,n+=i,o+=e*e,s+=e*i;const i=e*o-t*t;if(1e-12>Math.abs(i))return null;const r=(e*s-t*n)/i,l=(n-r*t)/e;c=e=>l+r*e}const d=a.length,f=a.map(([e,t])=>t-c(e)).reduce((e,t)=>e+t*t,0),g=Math.sqrt(f/Math.max(d-2,1)),p=a.reduce((e,t)=>e+t[0],0)/d,y=a.reduce((e,t)=>e+Math.pow(t[0]-p,2),0),m=null!==(P=e.confidence)&&void 0!==P?P:.95,b=.99>m?.95>m?.9>m?1:1.645:1.96:2.576,v=null!==(T=e.steps)&&void 0!==T?T:5,x=a[d-1][0],k=(x-a[0][0])/Math.max(d-1,1),w=[];for(let e=1;v>=e;e++)w.push(x+e*k);const A=[];for(const e of w){const t=c(e),n=g*Math.sqrt(1+1/d+(y>0?Math.pow(e-p,2)/y:0))*b;A.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const E=`M${A.map(e=>`${r(e.x)},${l(e.yUpper)}`).join(" L")} L${A.slice().reverse().map(e=>`${r(e.x)},${l(e.yLower)}`).join(" L")} Z`,S=A.map(e=>`${r(e.x)},${l(e.yCenter)}`).join(" "),M=`${r(x)},${l(c(x))}`,O=e.strokeColor||"#6366f1";return u.createElement("g",{key:"ann-"+t},u.createElement("path",{d:E,fill:e.fill||"#6366f1",fillOpacity:null!==(D=e.fillOpacity)&&void 0!==D?D:.15,stroke:"none"}),u.createElement("polyline",{points:`${M} ${S}`,fill:"none",stroke:O,strokeWidth:null!==(q=e.strokeWidth)&&void 0!==q?q:2,strokeDasharray:null!==(V=e.strokeDasharray)&&void 0!==V?V:"6,3"}),e.label&&A.length>0&&u.createElement("text",{x:r(A[A.length-1].x)+4,y:l(A[A.length-1].yCenter)-4,fill:O,fontSize:11},e.label))}case"widget":{let o=null,s=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);if(!t)return null;o=t.x,s=t.y}else null!=e.px&&null!=e.py?(o=e.px,s=e.py):(o=Y(e,n),s=G(e,n));if(null==o||null==s)return null;if(!X(o,s,n))return null;const i=null!==(U=e.dx)&&void 0!==U?U:0,r=null!==(Z=e.dy)&&void 0!==Z?Z:0,l=null!==(J=e.width)&&void 0!==J?J:32,a=null!==(K=e.height)&&void 0!==K?K:32,c=null!==(Q=e.content)&&void 0!==Q?Q:u.createElement("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info"},"ℹ️");return u.createElement("foreignObject",{key:"ann-"+t,x:o+i-l/2,y:s+r-a/2,width:l,height:a,style:{overflow:"visible",pointerEvents:"auto"}},u.createElement("div",{style:{width:l,height:a,display:"flex",alignItems:"center",justifyContent:"center"}},c))}case"text":{const o=Y(e,n),s=G(e,n);return null==o||null==s?null:u.createElement("text",{key:"ann-text-"+t,x:o+(e.dx||0),y:s+(e.dy||0),fill:e.color||"var(--semiotic-text, #333)",fontSize:e.fontSize||11,dominantBaseline:"middle",style:{fontFamily:"inherit"}},e.label)}default:return null}},t={scales:a?{x:a.x,y:a.y,time:a.x,value:a.y}:null,timeAxis:"x",xAccessor:N,yAccessor:B,width:n,height:o,data:H,frameType:"xy",pointNodes:_};return C.map((n,o)=>{if(L){const s=L(n,o,t);return null!=s?s:e(n,o,t)}return e(n,o,t)}).filter(Boolean)},[C,L,n,o,j,N,B,H]);return c||b||v||E||S||T&&T.length>0||m||W?u.createElement("svg",{width:s,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},u.createElement("g",{transform:`translate(${l.left},${l.top})`},m&&a&&u.createElement("g",{className:"stream-grid"},$.map((e,t)=>u.createElement("line",{key:"xgrid-"+t,x1:e.pixel,y1:0,x2:e.pixel,y2:o,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1})),P.map((e,t)=>u.createElement("line",{key:"ygrid-"+t,x1:0,y1:e.pixel,x2:n,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),c&&a&&(()=>{const e=null==d?void 0:d.find(e=>"left"===e.orient),t=null==d?void 0:d.find(e=>"bottom"===e.orient),s=!e||!1!==e.baseline,i=(null==e?void 0:e.jaggedBase)||!1,r=(null==t?void 0:t.jaggedBase)||!1,a=null==t?void 0:t.landmarkTicks,c=null==e?void 0:e.landmarkTicks,h="var(--semiotic-border, #ccc)",p="var(--semiotic-text-secondary, #666)",y="var(--semiotic-text, #333)";return u.createElement("g",{className:"stream-axes"},(!t||!1!==t.baseline)&&!r&&u.createElement("line",{x1:0,y1:o,x2:n,y2:o,stroke:h,strokeWidth:1}),r&&u.createElement("path",{d:q("bottom",n,o),fill:"none",stroke:h,strokeWidth:1}),$.map((e,t)=>{const n=!!a&&("function"==typeof a?a(e.value,t):U(e.value,t>0?$[t-1].value:void 0));return u.createElement("g",{key:"xtick-"+t,transform:`translate(${e.pixel},${o})`},u.createElement("line",{y2:5,stroke:h,strokeWidth:1}),u.createElement("text",{y:18,textAnchor:"middle",fontSize:n?11:10,fontWeight:n?600:400,fill:p,style:{userSelect:"none"}},e.label))}),f&&u.createElement("text",{x:n/2,y:o+40,textAnchor:"middle",fontSize:12,fill:y,style:{userSelect:"none"}},f),s&&!i&&u.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:h,strokeWidth:1}),i&&u.createElement("path",{d:q("left",n,o),fill:"none",stroke:h,strokeWidth:1}),P.map((e,t)=>{const n=!!c&&("function"==typeof c?c(e.value,t):U(e.value,t>0?P[t-1].value:void 0));return u.createElement("g",{key:"ytick-"+t,transform:`translate(0,${e.pixel})`},u.createElement("line",{x2:-5,stroke:h,strokeWidth:1}),u.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:n?11:10,fontWeight:n?600:400,fill:p,style:{userSelect:"none"}},e.label))}),g&&u.createElement("text",{x:15-l.left,y:o/2,textAnchor:"middle",fontSize:12,fill:y,transform:`rotate(-90, ${15-l.left}, ${o/2})`,style:{userSelect:"none"}},g))})(),T,S&&a&&M&&O&&u.createElement(u.Fragment,null,S.top&&u.createElement("g",{transform:"translate(0, 0)"},u.createElement(F,{orient:"top",config:I(S.top),values:M,scale:a.x,size:l.top,length:n})),S.bottom&&u.createElement("g",{transform:`translate(0, ${o})`},u.createElement(F,{orient:"bottom",config:I(S.bottom),values:M,scale:a.x,size:l.bottom,length:n})),S.left&&u.createElement("g",{transform:"translate(0, 0)"},u.createElement(F,{orient:"left",config:I(S.left),values:O,scale:a.y,size:l.left,length:o})),S.right&&u.createElement("g",{transform:`translate(${n}, 0)`},u.createElement(F,{orient:"right",config:I(S.right),values:O,scale:a.y,size:l.right,length:o}))),E,W),b&&u.createElement("text",{x:s/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof b?b:null),v&&u.createElement("g",{transform:`translate(${s-l.right+10}, ${l.top})`},"object"==typeof(D=v)&&null!==D&&!u.isValidElement(D)&&"legendGroups"in D?u.createElement(z,{legendGroups:v.legendGroups,title:"",width:100,customHoverBehavior:x,customClickBehavior:k,highlightedCategory:w,isolatedCategories:A}):v)):null;var D}const J="undefined"==typeof window||"undefined"==typeof document;function K(e,t,n){let o=n;for(const n of t)"lesser"===n.thresholdType?n.value>e&&(o=n.color):e>n.value&&(o=n.color);return o}function Q(e){if(e.startsWith("#")){const t=4===e.length?e[1]+e[1]+e[2]+e[2]+e[3]+e[3]:e.slice(1,7);return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[78,121,167]}function ee(e,t){e.beginPath(),e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1]);for(let n=t.bottomPath.length-1;n>=0;n--)e.lineTo(t.bottomPath[n][0],t.bottomPath[n][1]);e.closePath()}const te=(e,t,n,o)=>{var s;const i=t.filter(e=>"area"===e.type);for(const t of i){if(2>t.topPath.length)continue;ee(e,t);const n=t.style.fill||"#4e79a7";if(t.fillGradient){const o=Math.min(...t.topPath.map(e=>e[1])),s=Math.max(...t.bottomPath.map(e=>e[1])),i=e.createLinearGradient(0,o,0,s);i.addColorStop(0,n),i.addColorStop(1,n),e.fillStyle=i;const r=Q(n),l=t.fillGradient.topOpacity,a=t.fillGradient.bottomOpacity,c=e.createLinearGradient(0,o,0,s);c.addColorStop(0,`rgba(${r[0]},${r[1]},${r[2]},${l})`),c.addColorStop(1,`rgba(${r[0]},${r[1]},${r[2]},${a})`),e.fillStyle=c,e.globalAlpha=1}else{const o=null!==(s=t.style.fillOpacity)&&void 0!==s?s:.7;e.globalAlpha=o,e.fillStyle=n}if(e.fill(),t._pulseIntensity&&t._pulseIntensity>0&&(ee(e,t),e.globalAlpha=.35*t._pulseIntensity,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fill()),t.style.stroke&&"none"!==t.style.stroke){e.globalAlpha=1,e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]),e.beginPath(),e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1]);e.stroke()}e.globalAlpha=1}},ne=(e,t,n,o)=>{var s,i;const r=t.filter(e=>"point"===e.type);for(const t of r){e.beginPath(),e.arc(t.x,t.y,t.r,0,2*Math.PI);const n=null!==(s=t.style.opacity)&&void 0!==s?s:t.style.fillOpacity;if(null!=n&&(e.globalAlpha=n),e.fillStyle=t.style.fill||"#4e79a7",e.fill(),t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()),t._pulseIntensity&&t._pulseIntensity>0){const n=null!==(i=t._pulseGlowRadius)&&void 0!==i?i:4,o=t.r+n*t._pulseIntensity;e.beginPath(),e.arc(t.x,t.y,o,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=.6*t._pulseIntensity,e.stroke()}e.globalAlpha=1}},oe=(e,t,n,o)=>{const s=t.filter(e=>"rect"===e.type);for(const t of s)null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.icon?se(e,t):(e.fillStyle=t.style.fill||"#007bff",e.fillRect(t.x,t.y,t.w,t.h),t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.strokeRect(t.x,t.y,t.w,t.h))),t._pulseIntensity&&t._pulseIntensity>0&&(e.globalAlpha=.3*t._pulseIntensity,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h)),e.globalAlpha=1};function se(e,t){const n=t.style.icon,o=t.style.iconPadding||2,s=Math.min(t.w,t.w)-o;if(0>=s)return;const i=t.h>t.w;if(e.save(),e.beginPath(),e.rect(t.x,t.y,t.w,t.h),e.clip(),i){const i=s+o,r=t.x+(t.w-s)/2;for(let o=t.y+t.h-s;o>=t.y-s;o-=i)e.drawImage(n,r,o,s,s)}else{const i=s+o,r=t.y+(t.h-s)/2;for(let o=t.x;t.x+t.w>o;o+=i)e.drawImage(n,o,r,s,s)}e.restore()}const ie={line:[te,(e,t,n,o)=>{const s=t.filter(e=>"line"===e.type);for(const i of s){if(2>i.path.length)continue;const r=i.style.stroke||"#007bff",l=i.style.strokeWidth||2,a=i.colorThresholds,c=i.rawValues;if(e.setLineDash(i.style.strokeDasharray?i.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=i.style.opacity&&(e.globalAlpha=i.style.opacity),e.lineWidth=l,a&&0!==a.length&&c&&c.length===i.path.length){let u=null,h=null,d=null,f=null,g=!1;function p(t,n,o){e.beginPath(),e.strokeStyle=t,e.moveTo(n,o),g=!0}function y(){g&&(e.stroke(),g=!1)}for(let m=0;i.path.length>m;m++){const[b,v]=i.path[m],x=c[m],k=K(x,a,r);if(null!==u&&null!==f&&null!==d){if(k===f)e.lineTo(b,v);else{const w=[];for(const A of a){const E=A.value;(d>E||E>x)&&(E>d||x>E)||d===E||x===E||w.push({t:(E-d)/(x-d)})}w.sort((e,t)=>e.t-t.t);for(const S of w){const M=u+(b-u)*S.t,O=h+(v-h)*S.t,C=K(d+(x-d)*Math.min(S.t+1e-4,1),a,r);e.lineTo(M,O),y(),p(C,M,O)}e.lineTo(b,v)}u=b,h=v,d=x,f=k}else p(k,b,v),u=b,h=v,d=x,f=k}y()}else{e.beginPath(),e.strokeStyle=r;const[L,j]=i.path[0];e.moveTo(L,j);for(let N=1;i.path.length>N;N++)e.lineTo(i.path[N][0],i.path[N][1]);e.stroke()}if(i.style.fill&&i.style.fillOpacity&&i.style.fillOpacity>0){e.beginPath(),e.globalAlpha=i.style.fillOpacity,e.fillStyle=i.style.fill;const[B,H]=i.path[0];e.moveTo(B,H);for(let W=1;i.path.length>W;W++)e.lineTo(i.path[W][0],i.path[W][1]);const _=i.path[0][0];e.lineTo(i.path[i.path.length-1][0],o.height),e.lineTo(_,o.height),e.closePath(),e.fill()}e.globalAlpha=1,e.setLineDash([])}}],area:[te],stackedarea:[te],scatter:[ne],bubble:[ne],heatmap:[(e,t,n,o)=>{const s=t.filter(e=>"heatcell"===e.type);for(const t of s){const n=t.style;null!=(null==n?void 0:n.opacity)&&(e.globalAlpha=n.opacity),e.fillStyle=t.fill,e.fillRect(t.x,t.y,t.w,t.h),e.strokeStyle="#fff",e.lineWidth=1,e.strokeRect(t.x,t.y,t.w,t.h),t._pulseIntensity&&t._pulseIntensity>0&&(e.globalAlpha=.3*t._pulseIntensity,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h)),e.globalAlpha=1}}],bar:[oe],swarm:[ne],waterfall:[(e,t,n,o)=>{var s,i,r;oe(e,t);const l=t.filter(e=>"rect"===e.type);if(2>l.length)return;const a=l[0].datum,c=null==a?void 0:a._connectorStroke;if(c){e.save(),e.strokeStyle=c,e.lineWidth=null!==(s=null==a?void 0:a._connectorWidth)&&void 0!==s?s:1,e.setLineDash([]);for(let t=0;l.length-1>t;t++){const o=l[t],s=l[t+1];if(!(null===(i=o.datum)||void 0===i?void 0:i.cumEnd)||!(null===(r=s.datum)||void 0===r?void 0:r.baseline))continue;const a=n.y(o.datum.cumEnd),c=o.x+o.w,u=s.x;e.beginPath(),e.moveTo(c,a),e.lineTo(u,a),e.stroke()}e.restore()}}],candlestick:[(e,t,n,o)=>{for(const n of t){if("candlestick"!==n.type)continue;const t=n;e.beginPath(),e.moveTo(t.x,t.highY),e.lineTo(t.x,t.lowY),e.strokeStyle=t.wickColor,e.lineWidth=t.wickWidth,e.stroke();const o=Math.min(t.openY,t.closeY),s=Math.abs(t.openY-t.closeY),i=t.isUp?t.upColor:t.downColor;e.fillStyle=i,e.fillRect(t.x-t.bodyWidth/2,o,t.bodyWidth,Math.max(s,1)),e.strokeStyle=i,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,o,t.bodyWidth,Math.max(s,1))}}]},re={top:20,right:20,bottom:30,left:40},le={axisStroke:"#ccc",tickText:"#666",crosshair:"rgba(0, 0, 0, 0.25)",hoverFill:"rgba(255, 255, 255, 0.3)",hoverStroke:"rgba(0, 0, 0, 0.4)",pointRing:"white"},ae={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,lineHeight:1.5,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function ce({hover:e}){const t=e=>Number.isInteger(e)?e+"":e.toFixed(2);return u.createElement("div",{className:"semiotic-tooltip",style:ae},u.createElement("div",{style:{fontWeight:600,marginBottom:2}},t(e.value)),u.createElement("div",{style:{opacity:.7,fontSize:11}},t(e.time)))}function ue({width:o,height:s,totalWidth:i,totalHeight:r,margin:l,dimension:a,scales:c,onBrush:h}){const d=e.useRef(null),f=e.useRef(null),g=e.useRef(h);g.current=h;const p=e.useRef(c);return p.current=c,e.useEffect(()=>{if(!d.current)return;const e=n.select(d.current).select(".brush-g"),i="x"===a?t.brushX():"y"===a?t.brushY():t.brush();return i.extent([[0,0],[o,s]]),i.on("brush end",e=>{const t=p.current;if(!t)return;if(!e.selection)return void g.current(null);let n,i;if("x"===a){const[o,r]=e.selection;n=[t.x.invert(o),t.x.invert(r)],i=[t.y.invert(s),t.y.invert(0)]}else if("y"===a){const[s,r]=e.selection;n=[t.x.invert(0),t.x.invert(o)],i=[t.y.invert(r),t.y.invert(s)]}else{const[[o,s],[r,l]]=e.selection;n=[t.x.invert(o),t.x.invert(r)],i=[t.y.invert(l),t.y.invert(s)]}g.current({x:n,y:i})}),e.call(i),f.current=i,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{i.on("brush end",null),f.current=null}},[o,s,a]),u.createElement("svg",{ref:d,width:i,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},u.createElement("g",{className:"brush-g",transform:`translate(${l.left},${l.top})`}))}const he=e.forwardRef(function(t,n){var o,s,i,r,l;const{chartType:a,runtimeMode:c,data:h,xAccessor:d,yAccessor:g,colorAccessor:p,sizeAccessor:y,groupAccessor:m,lineDataAccessor:b,normalize:v,binSize:x,valueAccessor:k,arrowOfTime:w="right",windowMode:A="sliding",windowSize:S=200,timeAccessor:B,xExtent:H,yExtent:_,extentPadding:W=.1,sizeRange:$,size:z=[500,300],responsiveWidth:I,responsiveHeight:F,margin:P,className:T,background:D,lineStyle:R,pointStyle:Y,areaStyle:G,waterfallStyle:X,swarmStyle:q,barColors:V,colorScheme:U,boundsAccessor:K,boundsStyle:Q,y0Accessor:ee,gradientFill:te,openAccessor:ne,highAccessor:oe,lowAccessor:se,closeAccessor:ae,candlestickStyle:he,showAxes:de=!0,axes:fe,xLabel:ge,yLabel:pe,xFormat:ye,yFormat:me,tickFormatTime:be,tickFormatValue:ve,hoverAnnotation:xe,tooltipContent:ke,customHoverBehavior:we,enableHover:Ae,annotations:Ee,svgAnnotationRules:Se,showGrid:Me,legend:Oe,legendHoverBehavior:Ce,legendClickBehavior:Le,legendHighlightedCategory:je,legendIsolatedCategories:Ne,backgroundGraphics:Be,foregroundGraphics:He,title:_e,categoryAccessor:We,brush:$e,onBrush:ze,decay:Ie,pulse:Fe,transition:Pe,staleness:Te,heatmapAggregation:De,heatmapXBins:Re,heatmapYBins:Ye,marginalGraphics:Ge,pointIdAccessor:Xe}=t,[qe,Ve]=function(t,n,o){const s=e.useRef(null),[i,r]=e.useState(null);return e.useEffect(()=>{if(!n&&!o)return;const e=s.current;if(!e)return;const t=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;r(t=>t&&t.w===e&&t.h===n?t:{w:e,h:n})}});return t.observe(e),()=>t.disconnect()},[n,o]),[s,[n&&i?i.w:t[0],o&&i?i.h:t[1]]]}(z,I,F),Ue=Object.assign(Object.assign({},re),P);if(Ge){const e=60;Ge.top&&e>Ue.top&&(Ue.top=e),Ge.bottom&&e>Ue.bottom&&(Ue.bottom=e),Ge.left&&e>Ue.left&&(Ue.left=e),Ge.right&&e>Ue.right&&(Ue.right=e)}const Ze=Ve[0]-Ue.left-Ue.right,Je=Ve[1]-Ue.top-Ue.bottom,Ke=null!=xe?xe:Ae,Qe=e.useRef(null),et=e.useRef(null),tt=e.useRef(0),nt=e.useRef(!1),[ot,st]=e.useState(0),[it,rt]=e.useState(null),lt=e.useRef(null),at=e.useRef(null),[ct,ut]=e.useState(null),[ht,dt]=e.useState(!1),[ft,gt]=e.useState([]),[pt,yt]=e.useState([]),mt=e.useRef(()=>{}),bt="streaming"===c||["bar","swarm","waterfall"].includes(a),vt=e.useMemo(()=>({chartType:a,runtimeMode:bt?"streaming":"bounded",windowSize:S,windowMode:A,arrowOfTime:bt?w:"right",extentPadding:W,xAccessor:bt?void 0:d,yAccessor:bt?void 0:g,timeAccessor:bt?B:void 0,valueAccessor:k,colorAccessor:p,sizeAccessor:y,groupAccessor:m,categoryAccessor:We,lineDataAccessor:b,xExtent:H,yExtent:_,sizeRange:$,binSize:x,normalize:v,boundsAccessor:K,boundsStyle:Q,y0Accessor:ee,gradientFill:"boolean"==typeof te?te?{topOpacity:.8,bottomOpacity:.05}:void 0:te,openAccessor:ne,highAccessor:oe,lowAccessor:se,closeAccessor:ae,candlestickStyle:he,lineStyle:R,pointStyle:Y,areaStyle:G,swarmStyle:q,waterfallStyle:X,colorScheme:U,barColors:V,annotations:Ee,decay:Ie,pulse:Fe,transition:Pe,staleness:Te,heatmapAggregation:De,heatmapXBins:Re,heatmapYBins:Ye,pointIdAccessor:Xe}),[a,S,A,w,W,d,g,B,k,p,y,m,We,b,H,_,$,x,v,K,Q,ee,te,ne,oe,se,ae,he,R,Y,G,q,X,U,V,Ee,Ie,Fe,Pe,Te,De,Re,Ye,bt,Xe]),xt=e.useRef(null);xt.current||(xt.current=new E(vt));const kt=e.useCallback(()=>{tt.current||(tt.current=requestAnimationFrame(()=>mt.current()))},[]);e.useEffect(()=>{var e;null===(e=xt.current)||void 0===e||e.updateConfig(vt),nt.current=!0,kt()},[vt,kt]);const wt=e.useRef(null);wt.current||(wt.current=new f(e=>{const t=xt.current;t&&t.ingest(e)&&(nt.current=!0,kt())}));const At=e.useCallback(e=>{var t;null===(t=wt.current)||void 0===t||t.push(e)},[]),Et=e.useCallback(e=>{var t;null===(t=wt.current)||void 0===t||t.pushMany(e)},[]),St=e.useCallback(()=>{var e,t;null===(e=wt.current)||void 0===e||e.clear(),null===(t=xt.current)||void 0===t||t.clear(),nt.current=!0,kt()},[kt]);e.useImperativeHandle(n,()=>({push:At,pushMany:Et,clear:St,getData:()=>{var e,t;return null!==(t=null===(e=xt.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=xt.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null},getExtents:()=>{var e,t;return null!==(t=null===(e=xt.current)||void 0===e?void 0:e.getExtents())&&void 0!==t?t:null}}),[At,Et,St]),e.useEffect(()=>{var e;h&&(null===(e=wt.current)||void 0===e||e.setBoundedData(h))},[h]);const Mt=e.useRef(()=>{}),Ot=e.useRef(()=>{});Mt.current=e=>{if(!Ke)return;const t=Qe.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-Ue.left,s=e.clientY-n.top-Ue.top;if(0>o||o>Ze||0>s||s>Je)return void(lt.current&&(lt.current=null,at.current=null,ut(null),we&&(we(null),nt.current=!0),kt()));const i=xt.current;if(!i||0===i.scene.length)return;const r=function(e,t,n,o=30){let s=null;for(const i of e){let e=null;switch(i.type){case"point":e=M(i,t,n);break;case"line":e=O(i,t,n);break;case"rect":e=C(i,t,n);break;case"heatcell":e=L(i,t,n);break;case"area":if(!1===i.interactive)break;e=N(i,t,n);break;case"candlestick":e=j(i,t,n)}e&&o>e.distance&&(s&&e.distance>=s.distance||(s=e))}return s}(i.scene,o,s);if(!r)return void(lt.current&&(lt.current=null,at.current=null,ut(null),we&&we(null),kt()));const l={data:r.datum,time:r.x,value:r.y,x:r.x,y:r.y};lt.current=l,at.current=r.node,ut(l),we&&(we(l),nt.current=!0),kt()},Ot.current=()=>{lt.current&&(lt.current=null,at.current=null,ut(null),we&&(we(null),nt.current=!0),kt())},e.useCallback(e=>Mt.current(e),[]);const Ct=e.useCallback(()=>Ot.current(),[]),Lt=e.useRef(-1),jt=e.useCallback(e=>{const t=xt.current;if(!t||0===t.scene.length)return;const n=function(e){const t=[];for(const n of e)switch(n.type){case"point":t.push({x:n.x,y:n.y,datum:n.datum});break;case"line":{const e=n,o=Array.isArray(e.datum)?e.datum:[];for(let n=0;e.path.length>n&&o.length>n;n++)t.push({x:e.path[n][0],y:e.path[n][1],datum:o[n]});break}case"area":{const e=n,o=Array.isArray(e.datum)?e.datum:[];for(let n=0;e.topPath.length>n&&o.length>n;n++)t.push({x:e.topPath[n][0],y:e.topPath[n][1],datum:o[n]});break}case"rect":case"heatcell":t.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum})}return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}(t.scene);if(0===n.length)return;const o=0>Lt.current?-1:Lt.current,s=function(e,t,n){switch(e){case"ArrowRight":case"ArrowDown":return n-1>t?t+1:t;case"ArrowLeft":case"ArrowUp":return t>0?t-1:t;case"Home":return 0;case"End":return n-1;case"Escape":return-1;default:return null}}(e.key,0>o?-1:o,n.length);if(null===s)return;if(e.preventDefault(),0>s)return Lt.current=-1,lt.current=null,at.current=null,ut(null),we&&we(null),void kt();const i=0>o?0:s;Lt.current=i;const r={data:(l=n[i]).datum,x:l.x,y:l.y,time:l.x,value:l.y};var l;lt.current=r,ut(r),we&&we(r),kt()},[we,kt]),Nt=e.useCallback(e=>{Lt.current=-1,Mt.current(e)},[]);mt.current=()=>{var e,t;tt.current=0;const n=Qe.current,o=et.current;if(!n||!o)return;const s=xt.current;if(!s)return;const i="undefined"!=typeof performance?performance.now():Date.now(),r=s.advanceTransition(i),l=nt.current||r;l&&!r&&s.computeScene({width:Ze,height:Je});const c="undefined"!=typeof window&&window.devicePixelRatio||1,u=function(e){if(!e)return le;const t=getComputedStyle(e),n=t.getPropertyValue("--semiotic-border").trim(),o=t.getPropertyValue("--semiotic-text-secondary").trim(),s=t.getPropertyValue("--semiotic-bg").trim(),i=o||t.getPropertyValue("--text-secondary").trim(),r=t.getPropertyValue("--text-primary").trim(),l=n||t.getPropertyValue("--surface-3").trim(),a=s||t.getPropertyValue("--surface-0").trim();return i||r||n?{axisStroke:l||le.axisStroke,tickText:i||le.tickText,crosshair:i?i+"66":le.crosshair,hoverFill:a?a+"4D":le.hoverFill,hoverStroke:i?i+"99":le.hoverStroke,pointRing:a||le.pointRing}:le}(n),h=null!==(e=null==Te?void 0:Te.threshold)&&void 0!==e?e:5e3,f=Te&&s.lastIngestTime>0&&i-s.lastIngestTime>h;if(l){const e=n.getContext("2d");if(e){n.width=Ve[0]*c,n.height=Ve[1]*c,n.style.width=Ve[0]+"px",n.style.height=Ve[1]+"px",e.scale(c,c),e.translate(Ue.left,Ue.top),e.clearRect(-Ue.left,-Ue.top,Ve[0],Ve[1]),f&&(e.globalAlpha=null!==(t=null==Te?void 0:Te.dimOpacity)&&void 0!==t?t:.5);const o=getComputedStyle(n).getPropertyValue("--semiotic-bg").trim(),i=D||(o&&"transparent"!==o?o:null);i&&(e.fillStyle=i,e.fillRect(-Ue.left,-Ue.top,Ve[0],Ve[1])),e.save(),"function"==typeof e.rect&&(e.beginPath(),e.rect(0,0,Ze,Je),e.clip());const r=ie[a];if(r&&s.scales)for(const t of r)t(e,s.scene,s.scales,{width:Ze,height:Je});e.restore(),f&&(e.globalAlpha=1)}}{const e=o.getContext("2d");if(e&&(o.width=Ve[0]*c,o.height=Ve[1]*c,o.style.width=Ve[0]+"px",o.style.height=Ve[1]+"px",e.scale(c,c),e.translate(Ue.left,Ue.top),Ke&&lt.current&&s.scales&&function(e,t,n,o,s,i,r){if(!1===s.crosshair)return;e.save();const l="object"==typeof s.crosshair?s.crosshair:{};e.strokeStyle=l.stroke||r.crosshair,e.lineWidth=l.strokeWidth||1,e.setLineDash(l.strokeDasharray?l.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),e.beginPath(),e.moveTo(t.x,0),e.lineTo(t.x,o),e.stroke(),e.beginPath(),e.moveTo(0,t.y),e.lineTo(n,t.y),e.stroke(),e.restore(),e.beginPath(),e.arc(t.x,t.y,4,0,2*Math.PI),e.fillStyle="#007bff",e.fill(),e.strokeStyle=r.pointRing,e.lineWidth=2,e.stroke()}(e,lt.current,Ze,Je,"object"==typeof Ke?Ke:{},0,u),at.current&&Array.isArray(xe))){const t=xe.find(e=>e&&"object"==typeof e&&"highlight"===e.type);t&&function(e,t,n,o){var s;if(!n)return;const i=n.group;if(void 0!==i)for(const n of t){if("line"!==n.type)continue;if(n.group!==i)continue;if(2>n.path.length)continue;const t="function"==typeof o.style?o.style(n.datum):o.style||{};e.save(),e.beginPath(),e.moveTo(n.path[0][0],n.path[0][1]);for(let t=1;n.path.length>t;t++)e.lineTo(n.path[t][0],n.path[t][1]);e.strokeStyle=t.stroke||n.style.stroke||"#007bff",e.lineWidth=t.strokeWidth||(n.style.strokeWidth||2)+2,e.globalAlpha=null!==(s=t.opacity)&&void 0!==s?s:1,e.stroke(),e.restore()}}(e,s.scene,at.current,t)}}const p=nt.current;if(nt.current=!1,p&&s.scales&&(rt(s.scales),Ge)){const e=s.getData(),t="function"==typeof d?d:e=>e[d||"x"],n="function"==typeof g?g:e=>e[g||"y"];gt(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),yt(e.map(e=>n(e)).filter(e=>"number"==typeof e&&isFinite(e)))}p&&Ee&&Ee.length>0&&st(e=>e+1),(null==Te?void 0:Te.showBadge)&&dt(!!f),(r||s.hasActivePulses)&&(tt.current=requestAnimationFrame(()=>mt.current()))},e.useEffect(()=>(kt(),()=>{tt.current&&(cancelAnimationFrame(tt.current),tt.current=0)}),[kt]),e.useEffect(()=>{nt.current=!0,kt()},[a,Ze,Je,de,D,R,kt]),function(t,n,o,s,i,r){e.useEffect(()=>{if(!t)return;const e=setInterval(()=>{var e;const l=n.current;if(!l||0===l.lastIngestTime)return;const a="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(e=t.threshold)&&void 0!==e?e:5e3,u=a-l.lastIngestTime>c;u!==i&&(r(u),o.current=!0,s())},1e3);return()=>clearInterval(e)},[t,i,s])}(Te,xt,nt,kt,ht,dt);const Bt=Ke&&ct?ke?ke(ct):u.createElement(ce,{hover:ct}):null,Ht=Bt?u.createElement("div",{className:"stream-frame-tooltip",style:{position:"absolute",left:Ue.left+ct.x,top:Ue.top+ct.y,transform:`translate(${ct.x>.7*Ze?"calc(-100% - 12px)":"12px"}, ${.3*Je>ct.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:1}},Bt):null,_t=Lt.current>=0&&ct?u.createElement("svg",{style:{position:"absolute",left:0,top:0,width:Ve[0],height:Ve[1],pointerEvents:"none",zIndex:2}},u.createElement("circle",{cx:ct.x+Ue.left,cy:ct.y+Ue.top,r:8,fill:"none",stroke:"var(--accent, #6366f1)",strokeWidth:2,strokeDasharray:"4,2"})):null;if(J){const e=xt.current;e&&h&&(e.ingest({inserts:h,bounded:!0}),e.computeScene({width:Ze,height:Je}));const t=null!==(o=null==e?void 0:e.scene)&&void 0!==o?o:[],n=null!==(s=null==e?void 0:e.scales)&&void 0!==s?s:null;return u.createElement("div",{className:"stream-xy-frame"+(T?" "+T:""),role:"img","aria-label":"string"==typeof _e?_e:"XY chart",style:{position:"relative",width:Ve[0],height:Ve[1]}},u.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:Ve[0],height:Ve[1],style:{position:"absolute",left:0,top:0}},Be,u.createElement("g",{transform:`translate(${Ue.left},${Ue.top})`},D&&u.createElement("rect",{x:0,y:0,width:Ze,height:Je,fill:D}),t.map((e,t)=>function(e,t){var n,o,s;switch(e.type){case"line":{const n=e;if(0===n.path.length)return null;const o="M"+n.path.map(([e,t])=>`${e},${t}`).join("L");return u.createElement("path",{key:"line-"+t,d:o,fill:"none",stroke:n.style.stroke||"#4e79a7",strokeWidth:n.style.strokeWidth||2,strokeDasharray:n.style.strokeDasharray,opacity:n.style.opacity})}case"area":{const s=e;if(0===s.topPath.length)return null;const i=s.topPath.map(([e,t])=>`${e},${t}`).join("L"),r=[...s.bottomPath].reverse().map(([e,t])=>`${e},${t}`).join("L");return u.createElement("path",{key:"area-"+t,d:`M${i}L${r}Z`,fill:s.style.fill||"#4e79a7",fillOpacity:null!==(o=null!==(n=s.style.fillOpacity)&&void 0!==n?n:s.style.opacity)&&void 0!==o?o:.7,stroke:s.style.stroke,strokeWidth:s.style.strokeWidth})}case"point":return u.createElement("circle",{key:"point-"+t,cx:e.x,cy:e.y,r:e.r,fill:e.style.fill||"#4e79a7",opacity:null!==(s=e.style.opacity)&&void 0!==s?s:.8,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth});case"rect":return u.createElement("rect",{key:"rect-"+t,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 u.createElement("rect",{key:"heatcell-"+t,x:e.x,y:e.y,width:e.w,height:e.h,fill:e.fill});case"candlestick":{const n=e,o=Math.min(n.openY,n.closeY),s=Math.max(Math.abs(n.openY-n.closeY),1),i=n.isUp?n.upColor:n.downColor;return u.createElement("g",{key:"candle-"+t},u.createElement("line",{x1:n.x,y1:n.highY,x2:n.x,y2:n.lowY,stroke:n.wickColor,strokeWidth:n.wickWidth}),u.createElement("rect",{x:n.x-n.bodyWidth/2,y:o,width:n.bodyWidth,height:s,fill:i,stroke:i,strokeWidth:1}))}default:return null}}(e,t)).filter(Boolean))),u.createElement(Z,{width:Ze,height:Je,totalWidth:Ve[0],totalHeight:Ve[1],margin:Ue,scales:n,showAxes:de,axes:fe,xLabel:ge,yLabel:pe,xFormat:ye||be,yFormat:me||ve,showGrid:Me,title:_e,legend:Oe,legendHoverBehavior:Ce,legendClickBehavior:Le,legendHighlightedCategory:je,legendIsolatedCategories:Ne,foregroundGraphics:He,marginalGraphics:Ge,xValues:[],yValues:[],annotations:Ee,svgAnnotationRules:Se,annotationFrame:0,xAccessor:"string"==typeof d?d:"string"==typeof B?B:void 0,yAccessor:"string"==typeof g?g:"string"==typeof k?k:void 0,annotationData:null==e?void 0:e.getData(),pointNodes:null==e?void 0:e.scene.filter(e=>"point"===e.type)}))}return u.createElement("div",{ref:qe,className:"stream-xy-frame"+(T?" "+T:""),role:"img","aria-label":"string"==typeof _e?_e:"XY chart",tabIndex:0,style:{position:"relative",width:I?"100%":Ve[0],height:F?"100%":Ve[1]},onMouseMove:Ke?Nt:void 0,onMouseLeave:Ke?Ct:void 0,onKeyDown:jt},Be&&u.createElement("svg",{style:{position:"absolute",left:0,top:0,width:Ve[0],height:Ve[1],pointerEvents:"none"}},Be),u.createElement("canvas",{ref:Qe,style:{position:"absolute",left:0,top:0}}),u.createElement("canvas",{ref:et,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),u.createElement(Z,{width:Ze,height:Je,totalWidth:Ve[0],totalHeight:Ve[1],margin:Ue,scales:it,showAxes:de,axes:fe,xLabel:ge,yLabel:pe,xFormat:ye||be,yFormat:me||ve,showGrid:Me,title:_e,legend:Oe,legendHoverBehavior:Ce,legendClickBehavior:Le,legendHighlightedCategory:je,legendIsolatedCategories:Ne,foregroundGraphics:He,marginalGraphics:Ge,xValues:ft,yValues:pt,annotations:Ee,svgAnnotationRules:Se,annotationFrame:ot,xAccessor:"string"==typeof d?d:"string"==typeof B?B:void 0,yAccessor:"string"==typeof g?g:"string"==typeof k?k:void 0,annotationData:null===(i=xt.current)||void 0===i?void 0:i.getData(),pointNodes:null===(r=xt.current)||void 0===r?void 0:r.scene.filter(e=>"point"===e.type)}),($e||ze)&&u.createElement(ue,{width:Ze,height:Je,totalWidth:Ve[0],totalHeight:Ve[1],margin:Ue,dimension:null!==(l=null==$e?void 0:$e.dimension)&&void 0!==l?l:"xy",scales:it,onBrush:null!=ze?ze:()=>{}}),(null==Te?void 0:Te.showBadge)&&u.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===Te.badgePosition?{top:4,left:4}:"bottom-left"===Te.badgePosition?{bottom:4,left:4}:"bottom-right"===Te.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:ht?"#dc3545":"#28a745",color:"white"})},ht?"STALE":"LIVE"),_t,Ht)});he.displayName="StreamXYFrame";const de={category10:l.schemeCategory10,tableau10:l.schemeTableau10,set3:l.schemeSet3,blues:l.interpolateBlues,reds:l.interpolateReds,greens:l.interpolateGreens,oranges:l.interpolateOranges,purples:l.interpolatePurples,viridis:l.interpolateViridis,plasma:l.interpolatePlasma},fe=l.schemeCategory10;function ge(e,t,n){if("function"==typeof t)return t(e);const o=e[t];return n?n(o):fe[Math.abs(function(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n),t&=t;return Math.abs(t)}(o+""))%fe.length]}function pe(e,t,n="category10"){const s=Array.from(new Set(e.map(e=>e[t]))),i=s.every(e=>"number"==typeof e||!isNaN(Number(e)));if(Array.isArray(n))return o.scaleOrdinal().domain(s).range(n).unknown("#999");const r=de[n]||de.category10;if(i&&"function"==typeof r)return e=>r(Number(e)/Math.max(...s.map(Number)));{const e=Array.isArray(r)?r:fe;return o.scaleOrdinal().domain(s).range(e).unknown("#999")}}function ye(e,t,n=[3,20],o){let s;if(s="function"==typeof t?t(e):e[t],!o)return s;const[i,r]=o,[l,a]=n;return r===i?(l+a)/2:l+(s-i)/(r-i)*(a-l)}const me=e.createContext(null);function be(){return e.useContext(me)}const ve="undefined"!=typeof window?e.useLayoutEffect:e.useEffect;function xe(t){const n=e.createContext(null),o=ke(t);return[function({children:o}){const s=e.useMemo(()=>ke(t),[]);return u.createElement(n.Provider,{value:s,children:o})},t=>{var s;const i=null!==(s=e.useContext(n))&&void 0!==s?s:o;return function(t,n){const[o,s]=e.useState(n);return ve(()=>t(()=>s(n)),[t]),o}(i.subscribe,()=>t(i.getState()))}]}function ke(e){const t=new EventTarget;let n=e(function(e){n=Object.assign(Object.assign({},n),e(n)),t.dispatchEvent(new CustomEvent("update"))});return{getState:()=>n,subscribe:function(e){return t.addEventListener("update",e),()=>t.removeEventListener("update",e)}}}function we(e){const t=[];for(const[n,o]of Object.entries(e.fields))if("point"===o.type)t.push(e=>o.values.has(e[n]));else{const[e,s]=o.range;t.push(t=>{const o=t[n];return o>=e&&s>=o})}return e=>t.every(t=>t(e))}function Ae(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}const[Ee,Se]=xe(e=>({selections:new Map,setClause(t,n){e(e=>{const o=new Map(e.selections),s=Ae(o,t),i=new Map(s.clauses);return i.set(n.clientId,n),o.set(t,Object.assign(Object.assign({},s),{clauses:i})),{selections:o}})},clearClause(t,n){e(e=>{const o=e.selections.get(t);if(!o)return{};const s=new Map(e.selections),i=new Map(o.clauses);return i.delete(n),s.set(t,Object.assign(Object.assign({},o),{clauses:i})),{selections:s}})},setResolution(t,n){e(e=>{const o=new Map(e.selections),s=Ae(o,t);return o.set(t,Object.assign(Object.assign({},s),{resolution:n})),{selections:o}})},clearSelection(t){e(e=>{const n=new Map(e.selections),o=n.get(t);return o&&n.set(t,Object.assign(Object.assign({},o),{clauses:new Map})),{selections:n}})}})),[Me,Oe]=xe(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const n=e.observations;return n.push(t),n.length>e.maxObservations&&n.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}}));function Ce(t){const n=e.useId(),o=t.clientId||n,{name:s}=t,i=Se(e=>e.selections.get(s)),r=Se(e=>e.setClause),l=Se(e=>e.clearClause),a=e.useMemo(()=>!!i&&i.clauses.size>0,[i]);return{predicate:e.useMemo(()=>i&&0!==i.clauses.size?function(e,t){const n=[];for(const[o,s]of e.clauses)"crossfilter"===e.resolution&&o===t||n.push(we(s));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(i,o):()=>!0,[i,o]),isActive:a,selectPoints:e.useCallback(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"point",values:new Set(o)};r(s,{clientId:o,type:"point",fields:t})},[o,s,r]),selectInterval:e.useCallback(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"interval",range:o};r(s,{clientId:o,type:"interval",fields:t})},[o,s,r]),clear:e.useCallback(()=>{l(s,o)},[l,s,o]),clientId:o}}function Le(t){const n=t.name||"hover",{fields:o}=t,{predicate:s,isActive:i,selectPoints:r,clear:l}=Ce({name:n});return{onHover:e.useCallback(e=>{if(!e)return void l();const t={};for(const n of o){const o=e[n];void 0!==o&&(t[n]=[o])}Object.keys(t).length>0&&r(t)},[o,r,l,n]),predicate:s,isActive:i}}function je(t){const{name:n,xField:o,yField:s}=t,{predicate:i,isActive:r,selectInterval:l,clear:a}=Ce({name:n}),c=o&&s?"xyBrush":o?"xBrush":"yBrush",u=e.useCallback(e=>{if(!e)return void a();const t={};"xyBrush"===c&&Array.isArray(e)&&2===e.length?(o&&(t[o]=[Math.min(e[0][0],e[1][0]),Math.max(e[0][0],e[1][0])]),s&&(t[s]=[Math.min(e[0][1],e[1][1]),Math.max(e[0][1],e[1][1])])):"xBrush"===c&&Array.isArray(e)?o&&(t[o]=[Math.min(...e),Math.max(...e)]):"yBrush"===c&&Array.isArray(e)&&s&&(t[s]=[Math.min(...e),Math.max(...e)]),Object.keys(t).length>0&&l(t)},[c,o,s,l,a]);return{brushInteraction:e.useMemo(()=>({brush:c,during:u,end:u}),[c,u]),predicate:i,isActive:r,clear:a}}const Ne=e.createContext(!1);function Be({selections:t}){const n=Se(e=>e.setResolution);return e.useEffect(()=>{for(const[e,o]of Object.entries(t))o.resolution&&n(e,o.resolution)},[t,n]),null}function He({categoryColors:t,interaction:n,selectionName:o,field:s}){const i=Object.entries(t);if(0===i.length)return null;const r=i.map(([e])=>e),l=[{styleFn:e=>({fill:e.color,stroke:e.color}),type:"fill",items:i.map(([e,t])=>({label:e,color:t})),label:""}],a=Le({name:o,fields:[s]}),c=Ce({name:o,clientId:"__linked-legend-isolate__"}),[h,d]=e.useState(new Set),[f,g]=e.useState(null),p=e.useRef(c.selectPoints);p.current=c.selectPoints;const y=e.useRef(c.clear);y.current=c.clear,e.useEffect(()=>{"isolate"===n&&(h.size>0?p.current({[s]:Array.from(h)}):y.current())},[n,h,s]);const m=e.useCallback(e=>{"highlight"===n&&(e?(g(e.label),a.onHover({[s]:e.label})):(g(null),a.onHover(null)))},[n,s,a]),b=e.useCallback(e=>{"isolate"===n&&d(t=>{const n=new Set(t);return n.has(e.label)?n.delete(e.label):n.add(e.label),n.size===r.length?new Set:n})},[n,r.length]);return u.createElement("svg",{width:"100%",height:30,style:{display:"block",overflow:"visible"}},u.createElement(z,{legendGroups:l,title:!1,orientation:"horizontal",height:20,customHoverBehavior:"highlight"===n?m:void 0,customClickBehavior:"isolate"===n?b:void 0,highlightedCategory:f,isolatedCategories:h}))}function _e({children:e,selections:t,showLegend:n,legendPosition:o="top",legendInteraction:s="none",legendSelectionName:i="legend",legendField:r="category"}){const l=be(),a=void 0!==n?n:!(!l||0>=Object.keys(l).length);return u.createElement(Ee,null,u.createElement(Me,null,t&&u.createElement(Be,{selections:t}),u.createElement(Ne.Provider,{value:a},a&&"top"===o&&l&&u.createElement(He,{categoryColors:l,interaction:s,selectionName:i,field:r}),e,a&&"bottom"===o&&l&&u.createElement(He,{categoryColors:l,interaction:s,selectionName:i,field:r}))))}function We(e){return e?"string"==typeof e?{name:e}:e:null}function $e(e,t,n){return t?o=>{var s;const i=Object.assign({},e(o));if(t.isActive)if(t.predicate(o))(null==n?void 0:n.selectedStyle)&&Object.assign(i,n.selectedStyle);else{const e=null!==(s=null==n?void 0:n.unselectedOpacity)&&void 0!==s?s:.2;i.opacity=e,i.fillOpacity=e,i.strokeOpacity=e,(null==n?void 0:n.unselectedStyle)&&Object.assign(i,n.unselectedStyle)}return i}:e}const ze="#007bff";function Ie(e){return"function"==typeof e?e:t=>t[e]}function Fe(t,n,o="category10"){const s=be();return e.useMemo(()=>{if(n&&"function"!=typeof n)return s&&Object.keys(s).length>0?e=>s[e]||pe(t,n,o)(e):pe(t,n,o)},[t,n,o,s])}function Pe({selection:t,linkedHover:n,fallbackFields:o=[],unwrapData:s=!1,onObservation:i,chartType:r,chartId:l}){const a=function(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields}:null}(n,o),c=Ce({name:(null==t?void 0:t.name)||"__unused__"}),u=Le({name:(null==a?void 0:a.name)||"hover",fields:(null==a?void 0:a.fields)||o||[]}),h=Oe(e=>e.pushObservation),d=t?{isActive:c.isActive,predicate:c.predicate}:null,f=e.useCallback(e=>{var t,o;if(n)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]),u.onHover(t)}else u.onHover(null);if(i||h){const n={timestamp:Date.now(),chartType:r||"unknown",chartId:l};if(e){let s=e.data||e.datum||e;Array.isArray(s)&&(s=s[0]);const r=Object.assign(Object.assign({},n),{type:"hover",datum:s||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(o=e.y)&&void 0!==o?o:0});i&&i(r),h&&h(r)}else{const e=Object.assign(Object.assign({},n),{type:"hover-end"});i&&i(e),h&&h(e)}}},[n,u,i,r,l,h]),g=e.useCallback(e=>{var t,n;if(i||h){const o={timestamp:Date.now(),chartType:r||"unknown",chartId:l};if(e){let s=e.data||e.datum||e;Array.isArray(s)&&(s=s[0]);const r=Object.assign(Object.assign({},o),{type:"click",datum:s||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0});i&&i(r),h&&h(r)}else{const e=Object.assign(Object.assign({},o),{type:"click-end"});i&&i(e),h&&h(e)}}},[i,h,r,l]);return{activeSelectionHook:d,customHoverBehavior:f,customClickBehavior:g}}function Te({data:t,colorBy:n,colorScale:o,showLegend:s,userMargin:i,defaults:r={top:50,bottom:60,left:70,right:40}}){const l=e.useContext(Ne),a=void 0!==s?s:!l&&!!n,c=e.useMemo(()=>{if(a&&n)return function({data:e,colorBy:t,colorScale:n,getColor:o,strokeColor:s,strokeWidth:i}){return{legendGroups:[{styleFn:e=>{const t={fill:e.color,stroke:e.color};return void 0!==s&&(t.stroke=s),void 0!==i&&(t.strokeWidth=i),t},type:"fill",items:Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t]))).map(s=>{const i=e.find("function"==typeof t?e=>t(e)===s:e=>e[t]===s),r=i?o(i,t,n):n?n(s):"#000000";return{label:s+"",color:r}}),label:""}]}}({data:t,colorBy:n,colorScale:o,getColor:ge})},[a,n,t,o]),u=e.useMemo(()=>{const e=Object.assign(Object.assign({},r),i);return c&&120>e.right&&(e.right=120),e},[r,i,c]);return{legend:c,margin:u}}function De(t,n,o){const[s,i]=e.useState(null),[r,l]=e.useState(new Set),a=e.useCallback(e=>{"highlight"===t&&i(e?e.label:null)},[t]),c=e.useCallback(e=>{"isolate"===t&&l(t=>{const n=new Set(t);return n.has(e.label)?n.delete(e.label):n.add(e.label),n.size===o.length?new Set:n})},[t,o.length]),u=e.useMemo(()=>{if(!t||"none"===t||!n)return null;const e="string"==typeof n?n:null;return"highlight"===t&&null!=s?{isActive:!0,predicate:t=>(e?t[e]:"function"==typeof n?n(t):null)===s}:"isolate"===t&&r.size>0?{isActive:!0,predicate:t=>{const o=e?t[e]:"function"==typeof n?n(t):null;return r.has(o)}}:null},[t,n,s,r]);return{highlightedCategory:"highlight"===t?s:null,isolatedCategories:"isolate"===t?r:new Set,onLegendHover:a,onLegendClick:c,legendSelectionHook:u}}const Re={primary:{width:600,height:400,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:void 0,showLabels:void 0,marginDefaults:{top:50,bottom:60,left:70,right:40}},context:{width:400,height:250,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:10,bottom:10,left:10,right:10}},sparkline:{width:120,height:24,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:2,bottom:2,left:0,right:0}}};function Ye(e,t,n){var o,s,i,r,l,a;const c=Re[e||"primary"],u="context"===e||"sparkline"===e;return{width:null!==(o=t.width)&&void 0!==o?o:c.width,height:null!==(s=t.height)&&void 0!==s?s:c.height,showAxes:c.showAxes,showGrid:null!==(i=t.showGrid)&&void 0!==i?i:c.showGrid,enableHover:null!==(r=t.enableHover)&&void 0!==r?r:!!t.linkedHover||c.enableHover,showLegend:null!==(l=t.showLegend)&&void 0!==l?l:c.showLegend,showLabels:null!==(a=t.showLabels)&&void 0!==a?a:c.showLabels,title:u?void 0:t.title,xLabel:u?void 0:t.xLabel,yLabel:u?void 0:t.yLabel,categoryLabel:u?void 0:t.categoryLabel,valueLabel:u?void 0:t.valueLabel,marginDefaults:c.marginDefaults}}const Ge={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"8px 12px",borderRadius:"4px",fontSize:"14px",lineHeight:"1.5",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"};function Xe(e,t){return"function"==typeof t?t(e):e[t]}function qe(e,t){return t?t(e):null==e?"":"number"==typeof e?e.toLocaleString():e instanceof Date?e.toLocaleDateString():"object"==typeof e&&null!==e?void 0!==e.id?e.id+"":void 0!==e.name?e.name+"":JSON.stringify(e):e+""}function Ve(e={}){const{fields:t,title:n,format:o,style:s={},className:i=""}=e;return e=>{if(!e||"object"!=typeof e)return null;let r;const l=[];if(n){const t=Xe(e,n);r=qe(t,o)}if(t&&t.length>0)t.forEach(t=>{let n,s,i;"string"==typeof t?(n=t,s=t,i=o):(n=t.label,s=t.accessor||t.key||"",i=t.format||o);const r=Xe(e,s);l.push({label:n,value:qe(r,i)})});else if(!n){const t=["value","y","name","id","label"];for(const n of t)if(void 0!==e[n]){r=qe(e[n],o);break}if(!r){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(r=qe(e[t[0]],o))}}const a=Object.assign(Object.assign({},Ge),s);return u.createElement("div",{className:("semiotic-tooltip "+i).trim(),style:a},r&&u.createElement("div",{style:{fontWeight:l.length>0?"bold":"normal"}},r),l.map((e,t)=>u.createElement("div",{key:t,style:{marginTop:0===t&&r?"4px":0}},e.label&&u.createElement("span",null,e.label,": "),e.value)))}}function Ue(e){return!0===e?Ve():"function"==typeof e?e:!1!==e&&void 0!==e&&("object"==typeof e&&null!==e&&("fields"in e||"title"in e)?Ve(e):Ve())}function Ze(e){return"string"==typeof e?e:"value"}function Je(e){return t=>{const n=t.data;return n?u.createElement("div",{className:"semiotic-tooltip",style:Ge},e.map((e,t)=>{const o=function(e,t){return"function"==typeof t?t(e):e[t]}(n,e.accessor),s=null==(i=o)?"–":"number"==typeof i?Math.abs(i)>9999?i.toLocaleString():i+"":i instanceof Date?i.toLocaleDateString():i+"";var i;return u.createElement("div",{key:t,style:t>0?{marginTop:2}:void 0},u.createElement("span",{style:{opacity:.8}},e.label,": "),u.createElement("span",{style:{fontWeight:"color"===e.role||"group"===e.role?"bold":"normal"}},s))})):null}}function Ke({componentName:e,message:t,width:n,height:o}){return u.createElement("div",{role:"alert",style:{width:n,height:Math.max(o,120),display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed rgba(128, 128, 128, 0.4)",borderRadius:8,background:"rgba(128, 128, 128, 0.04)",padding:24,boxSizing:"border-box"}},u.createElement("div",{style:{textAlign:"center",maxWidth:400}},u.createElement("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"}},e),u.createElement("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5}},t)))}class Qe extends u.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){var n,o;null===(o=(n=this.props).onError)||void 0===o||o.call(n,e,t)}render(){if(this.state.error){const{fallback:e}=this.props,t=this.state.error;return"function"==typeof e?e(t):void 0!==e?e:u.createElement(Ke,{componentName:"ChartErrorBoundary",message:t.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}var et;const tt="undefined"!=typeof process&&"production"!==(null===(et=process.env)||void 0===et?void 0:et.NODE_ENV);function nt({componentName:e,width:t,height:n,children:o}){return u.createElement(Qe,{fallback:o=>u.createElement(Ke,{componentName:e,message:o.message,width:t,height:n})},o)}const ot={display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #999)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"},st={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function it(e,t,n,o){return!1===o||e&&Array.isArray(e)&&e.length>0||e&&!Array.isArray(e)?null:u.createElement("div",{style:Object.assign(Object.assign({},ot),{width:t,height:n})},o||"No data available")}function rt(e,t,n){if(!e)return null;const o=Math.min(5,Math.floor(n/40)),s=Math.max(8,Math.floor(n/(3*o))),i=Math.max(6,Math.floor(n/(2.5*o))),r=Math.floor((n-(o*(s+i)-i))/2);return u.createElement("div",{style:{width:t,height:n,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"}},Array.from({length:o},(e,n)=>u.createElement("div",{key:n,className:"semiotic-loading-bar",style:Object.assign(Object.assign({},st),{position:"absolute",top:r+n*(s+i),left:Math.floor(.1*t),width:30+Math.round(50*Math.random())+"%",height:s,opacity:.5+n%2*.2})})))}function lt(e,t,n,o){if(!tt)return;if(!t||0===t.length)return;if("string"!=typeof o)return;const s=t[0];if(!s||"object"!=typeof s)return;if(o in s)return;const i=Object.keys(s).join(", ");console.warn(`[semiotic] ${e}: ${n} "${o}" not found in data. Available keys: ${i}`)}function at(e,t){const n=e.length,o=t.length,s=Array(o+1);for(let e=0;o>=e;e++)s[e]=e;for(let i=1;n>=i;i++){let n=s[0];s[0]=i;for(let r=1;o>=r;r++){const o=s[r];s[r]=e[i-1]===t[r-1]?n:1+Math.min(n,s[r],s[r-1]),n=o}}return s[o]}function ct(e,t){var n;if(0===t.length)return null;const o=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(o)||o.includes(e.toLowerCase()))||(null!==(n=function(e,t,n=3){let o,s=n+1;for(const n of t){const t=at(e.toLowerCase(),n.toLowerCase());s>t&&(s=t,o=n)}return s>n?void 0:o}(e,t,3))&&void 0!==n?n:null)}function ut({componentName:e,data:t,accessors:n,requiredProps:o}){if(o)for(const[t,n]of Object.entries(o))if(null==n)return`${e}: ${t} is required. Provide a field name or function.`;if(!t||!Array.isArray(t)||0===t.length)return e+": No data provided. Pass a non-empty array to the data prop.";if(!Array.isArray(t)&&"object"==typeof t)return e+": data should be an array, but received an object. If this is hierarchical data, use TreeDiagram, Treemap, or CirclePack instead.";if(n){const o=function(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:e}(t).find(e=>e&&"object"==typeof e);if(o){const t=Object.keys(o);for(const[s,i]of Object.entries(n))if(i&&"string"==typeof i&&!(i in o)){const n=ct(i,t),o=n?` Try ${s}="${n}".`:"";return`${e}: ${s} "${i}" not found in data. Available fields: ${t.join(", ")}.${o}`}}}return null}const ht="__forecastSegment";function dt(e,t){return"function"==typeof t?t(e):!!e[t]}function ft(t){var n,o;const s=Ye(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:i,margin:r,className:l,xFormat:a,yFormat:c,xAccessor:h="x",yAccessor:d="y",lineBy:f,lineDataAccessor:g="coordinates",colorBy:p,colorScheme:y="category10",curve:m="linear",showPoints:b=!1,pointRadius:v=3,fillArea:x=!1,areaOpacity:k=.3,lineWidth:w=2,tooltip:A,pointIdAccessor:E,annotations:S,directLabel:M,gapStrategy:O="break",anomaly:C,forecast:L,frameProps:j={},selection:N,linkedHover:B,onObservation:H,chartId:_,loading:W,emptyContent:$,legendInteraction:z}=t,I=s.width,F=s.height,P=s.enableHover,T=s.showGrid,D=s.showLegend,R=s.title,Y=s.xLabel,G=s.yLabel,X=rt(W,I,F);if(X)return X;const q=it(i,I,F,$);if(q)return q;const V=i||[];lt("LineChart",V,"xAccessor",h),lt("LineChart",V,"yAccessor",d);const U="string"==typeof h?h:"x",Z="string"==typeof d?d:"y",J=e.useMemo(()=>L?function(e,t,n,o,s){return(i=o).isTraining||i.isForecast||i.isAnomaly||i.upperBounds||i.lowerBounds?function(e,t,n,o,s){var i,r,l;const{isTraining:a,isForecast:c,isAnomaly:u,upperBounds:h,lowerBounds:d,color:f="#6366f1",bandOpacity:g=.15,anomalyColor:p="#ef4444",anomalyRadius:y=6,label:m}=o,b=e.map(e=>{let t="observed";return c&&dt(e,c)?t="forecast":a&&dt(e,a)&&(t="training"),Object.assign(Object.assign({},e),{[ht]:t})}),v=[];for(let e=0;b.length>e;e++)v.push(b[e]),b.length-1>e&&b[e][ht]!==b[e+1][ht]&&v.push(Object.assign(Object.assign({},b[e]),{[ht]:b[e+1][ht]}));const x=[];if(h&&d){const e="string"==typeof h?h:"__envUpper",t="string"==typeof d?d:"__envLower";if("function"==typeof h||"function"==typeof d)for(const n of v)"function"==typeof h&&(n[e]=h(n)),"function"==typeof d&&(n[t]=d(n));x.push({type:"envelope",upperAccessor:e,lowerAccessor:t,fill:f,fillOpacity:g,label:m})}return u&&x.push({type:"highlight",filter:e=>dt(e,u),color:p,r:y,style:{stroke:p,strokeWidth:1.5,fill:p,fillOpacity:.7}}),s&&x.push({type:"anomaly-band",threshold:null!==(i=s.threshold)&&void 0!==i?i:2,showBand:!1!==s.showBand,fill:s.bandColor||"#6366f1",fillOpacity:null!==(r=s.bandOpacity)&&void 0!==r?r:.1,anomalyColor:s.anomalyColor||"#ef4444",anomalyRadius:null!==(l=s.anomalyRadius)&&void 0!==l?l:6,label:s.label}),{processedData:v,annotations:x}}(e,0,0,o,s):function(e,t,n,o,s){var i,r,l;const{trainEnd:a,steps:c=10,confidence:u=.95,color:h="#6366f1",bandOpacity:d=.15,label:f}=o;if(null==a)return{processedData:e,annotations:[]};const g=[],p=[];for(const n of e)n[t]>a?p.push(Object.assign(Object.assign({},n),{[ht]:"observed"})):g.push(Object.assign(Object.assign({},n),{[ht]:"training"}));const y=g.map(e=>[e[t],e[n]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]),m=[],b=[];if(y.length>=3){const o=y.length;let s=0,i=0,r=0,l=0;for(const[e,t]of y)s+=e,i+=t,r+=e*e,l+=e*t;const a=o*r-s*s;if(Math.abs(a)>1e-12){const r=(o*l-s*i)/a,g=(i-r*s)/o,p=e=>g+r*e,v=y.map(([e,t])=>t-p(e)).reduce((e,t)=>e+t*t,0),x=Math.sqrt(v/Math.max(o-2,1)),k=y.reduce((e,t)=>e+t[0],0)/o,w=y.reduce((e,t)=>e+Math.pow(t[0]-k,2),0),A=.99>u?.95>u?.9>u?1:1.645:1.96:2.576,E=e.map(e=>e[t]).filter(e=>null!=e&&isFinite(e)),S=Math.max(...E),M=y.length>1?(y[o-1][0]-y[0][0])/(o-1):1;for(let e=1;c>=e;e++){const s=S+e*M,i=p(s),r=x*Math.sqrt(1+1/o+(w>0?Math.pow(s-k,2)/w:0))*A;b.push({[t]:s,[n]:i,[ht]:"forecast",__forecastUpper:i+r,__forecastLower:i-r})}m.push({type:"envelope",upperAccessor:"__forecastUpper",lowerAccessor:"__forecastLower",fill:h,fillOpacity:d,label:f})}}m.push({type:"x-threshold",x:a,color:"#94a3b8",strokeWidth:1,strokeDasharray:"4,2",label:"Train / Forecast"}),s&&m.push({type:"anomaly-band",threshold:null!==(i=s.threshold)&&void 0!==i?i:2,showBand:!1!==s.showBand,fill:s.bandColor||"#6366f1",fillOpacity:null!==(r=s.bandOpacity)&&void 0!==r?r:.1,anomalyColor:s.anomalyColor||"#ef4444",anomalyRadius:null!==(l=s.anomalyRadius)&&void 0!==l?l:6,label:s.label});const v=[];if(v.push(...g),g.length>0&&p.length>0&&v.push(Object.assign(Object.assign({},g[g.length-1]),{[ht]:"observed"})),v.push(...p),b.length>0){const e=p.length>0?p[p.length-1]:g[g.length-1];e&&v.push(Object.assign(Object.assign({},e),{[ht]:"forecast"})),v.push(...b)}return{processedData:v,annotations:m}}(e,t,n,o,s);var i}(V,U,Z,L,C):null,[V,L,C,U,Z]),K=e.useMemo(()=>J?J.annotations:C?function(e){var t,n,o;return[{type:"anomaly-band",threshold:null!==(t=e.threshold)&&void 0!==t?t:2,showBand:!1!==e.showBand,fill:e.bandColor||"#6366f1",fillOpacity:null!==(n=e.bandOpacity)&&void 0!==n?n:.1,anomalyColor:e.anomalyColor||"#ef4444",anomalyRadius:null!==(o=e.anomalyRadius)&&void 0!==o?o:6,label:e.label}]}(C):[],[J,C]),Q=J?J.processedData:V,ee=L&&!f?ht:f,{activeSelectionHook:te,customHoverBehavior:ne}=Pe({selection:N,linkedHover:B,fallbackFields:p?["string"==typeof p?p:""]:[],onObservation:H,chartType:"LineChart",chartId:_}),oe=e.useCallback(e=>{const t="function"==typeof h?h(e):e[h],n="function"==typeof d?d(e):e[d];return null==t||null==n||Number.isNaN(t)||Number.isNaN(n)},[h,d]),se=void 0!==(null===(n=Q[0])||void 0===n?void 0:n[g]),ie=e.useMemo(()=>{if(se)return Q;if(ee){const e=Q.reduce((e,t)=>{const n="function"==typeof ee?ee(t):t[ee];if(!e[n]){const t={[g]:[]};"string"==typeof ee&&(t[ee]=n),e[n]=t}return e[n][g].push(t),e},{});return Object.values(e)}return[{[g]:Q}]},[Q,ee,g,se]),{gapProcessedLineData:re,hasGaps:le}=e.useMemo(()=>{if("interpolate"===O){let e=!1;const t=[];for(const n of ie){const o=(n[g]||[]).filter(t=>!oe(t)||(e=!0,!1));o.length>0&&t.push(Object.assign(Object.assign({},n),{[g]:o}))}return{gapProcessedLineData:t,hasGaps:e}}if("break"===O){let e=!1;const t=[];for(const n of ie){const o=n[g]||[];let s=[],i=0;const r=ee&&"string"==typeof ee?n[ee]:void 0;for(const l of o)if(oe(l))e=!0,s.length>0&&(t.push(Object.assign(Object.assign({},n),{[g]:s})),s=[],i++);else{const e=null!=r?`${r}__seg${i}`:"__seg"+i;s.push(Object.assign(Object.assign({},l),{_gapSegment:e}))}s.length>0&&t.push(Object.assign(Object.assign({},n),{[g]:s}))}return{gapProcessedLineData:t,hasGaps:e}}if("zero"===O){let e=!1;const t="string"==typeof d?d:"y",n=[];for(const o of ie){const s=o[g]||[],i=[];for(const n of s)oe(n)?(e=!0,i.push(Object.assign(Object.assign({},n),{[t]:0}))):i.push(n);n.push(Object.assign(Object.assign({},o),{[g]:i}))}return{gapProcessedLineData:n,hasGaps:e}}return{gapProcessedLineData:ie,hasGaps:!1}},[ie,O,g,oe,ee,d]),ae=Fe(Q,p,y),ce=e.useMemo(()=>{if(!p)return[];const e=new Set;for(const t of Q){const n="function"==typeof p?p(t):t[p];null!=n&&e.add(n+"")}return Array.from(e)},[Q,p]),ue=De(z,p,ce),de=e.useMemo(()=>ue.legendSelectionHook?ue.legendSelectionHook:te,[ue.legendSelectionHook,te]),fe=e.useMemo(()=>e=>{const t={strokeWidth:w};return t.stroke=p?ge(e,p,ae):ze,x&&(t.fill=t.stroke,t.fillOpacity=k),t},[p,ae,w,x,k]),pe=e.useMemo(()=>L?function(e,t){var n,o;const s=null!==(n=t.trainDasharray)&&void 0!==n?n:"8,4",i=null!==(o=t.forecastDasharray)&&void 0!==o?o:"4,4",r=t.color||"#6366f1";return t=>{const n=e(t),o=t[ht];return"training"===o?Object.assign(Object.assign({},n),{strokeDasharray:s}):"forecast"===o?Object.assign(Object.assign({},n),{stroke:r,strokeDasharray:i}):n}}(fe,L):fe,[fe,L]),ye=e.useMemo(()=>$e(pe,de,N),[pe,de,N]),me=e.useMemo(()=>{if(b)return e=>{const t={r:v,fillOpacity:1};return t.fill=p?ge(e.parentLine||e,p,ae):ze,t}},[b,v,p,ae]),be=x?"area":"line",ve="object"==typeof M?M:{},xe=ve.position||"end",ke=ve.fontSize||11,we=e.useMemo(()=>{var e,t;if(!M||!p)return[];const n="function"==typeof h?h:e=>e[h],o="function"==typeof d?d:e=>e[d],s="function"==typeof p?p:e=>e[p],i=new Map;for(const n of re){const o=n[g]||[];if(0===o.length)continue;const r="end"===xe?o[o.length-1]:o[0],l=null!==(t=null!==(e=s(r))&&void 0!==e?e:s(n))&&void 0!==t?t:"";l&&!i.has(l+"")&&i.set(l+"",r)}const r=Array.from(i.entries()).map(([e,t])=>({type:"text",label:e,["string"==typeof h?h:"x"]:n(t),["string"==typeof d?d:"y"]:o(t),dx:"end"===xe?6:-6,dy:0,color:ae?ae(e):ze,fontSize:ke}));r.sort((e,t)=>{const n="string"==typeof d?d:"y";return e[n]-t[n]});for(let e=1;r.length>e;e++){const t="string"==typeof d?d:"y",n=r[e-1],o=r[e];ke+2>Math.abs(o[t]+o.dy-(n[t]+n.dy))&&(o.dy+=ke+2)}return r},[M,p,ae,re,g,h,d,xe,ke]),Ae=(!M||void 0!==D)&&D,Ee=e.useMemo(()=>{if(!M)return s.marginDefaults;const e=we.reduce((e,t)=>{var n;const o=((null===(n=t.label)||void 0===n?void 0:n.length)||0)*(.6*ke);return Math.max(e,o)},0),t=e+10,n="end"===xe?"right":"left";return Object.assign(Object.assign({},s.marginDefaults),{[n]:Math.max(s.marginDefaults[n]||0,t)})},[M,we,ke,xe,s.marginDefaults]),{legend:Se,margin:Me}=Te({data:re,colorBy:p,colorScale:ae,showLegend:Ae,userMargin:r,defaults:Ee}),Oe=f||p,Ce=e.useMemo(()=>Je([{label:Y||Ze(h),accessor:h,role:"x"},{label:G||Ze(d),accessor:d,role:"y"},...Oe?[{label:Ze(Oe),accessor:Oe,role:"group"}]:[]]),[h,d,Y,G,Oe]),Le=ut({componentName:"LineChart",data:se?(null===(o=Q[0])||void 0===o?void 0:o[g])||[]:V,accessors:{xAccessor:h,yAccessor:d}});if(Le)return u.createElement(Ke,{componentName:"LineChart",message:Le,width:I,height:F});const je=e.useMemo(()=>se||ee||le?re.flatMap(e=>{const t=e[g]||[];return ee&&"string"==typeof ee?t.map(t=>Object.assign(Object.assign({},t),{[ee]:e[ee]})):t}):Q,[re,g,se,ee,Q,le]),Ne=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:be,data:je,xAccessor:h,yAccessor:d,groupAccessor:"break"===O&&le?"_gapSegment":ee||void 0,curve:m,lineStyle:ye},b&&{pointStyle:me}),{size:[I,F],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Me,showAxes:s.showAxes,xLabel:Y,yLabel:G,xFormat:a,yFormat:c,enableHover:P,showGrid:T}),Se&&{legend:Se}),z&&"none"!==z&&{legendHoverBehavior:ue.onLegendHover,legendClickBehavior:ue.onLegendClick,legendHighlightedCategory:ue.highlightedCategory,legendIsolatedCategories:ue.isolatedCategories}),R&&{title:R}),l&&{className:l}),{tooltipContent:Ue(A)||Ce}),(B||H)&&{customHoverBehavior:ne}),E&&{pointIdAccessor:E}),((null==S?void 0:S.length)||K.length||we.length)&&{annotations:[...S||[],...K,...we]}),j);return u.createElement(nt,{componentName:"LineChart",width:I,height:F},u.createElement(he,Object.assign({},Ne)))}function gt(t){var n;const o=Ye(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:s,margin:i,className:r,xFormat:l,yFormat:a,xAccessor:c="x",yAccessor:h="y",areaBy:d,y0Accessor:f,gradientFill:g=!1,lineDataAccessor:p="coordinates",colorBy:y,colorScheme:m="category10",curve:b="monotoneX",areaOpacity:v=.7,showLine:x=!0,lineWidth:k=2,tooltip:w,annotations:A,frameProps:E={},selection:S,linkedHover:M,onObservation:O,chartId:C,loading:L,emptyContent:j,legendInteraction:N}=t,B=o.width,H=o.height,_=o.enableHover,W=o.showGrid,$=o.showLegend,z=o.title,I=o.xLabel,F=o.yLabel,P=rt(L,B,H);if(P)return P;const T=it(s,B,H,j);if(T)return T;const D=s||[];lt("AreaChart",D,"xAccessor",c),lt("AreaChart",D,"yAccessor",h);const{activeSelectionHook:R,customHoverBehavior:Y}=Pe({selection:S,linkedHover:M,fallbackFields:y?["string"==typeof y?y:""]:[],onObservation:O,chartType:"AreaChart",chartId:C}),G=void 0!==(null===(n=D[0])||void 0===n?void 0:n[p]),X=e.useMemo(()=>{if(G)return D;if(d){const e=D.reduce((e,t)=>{const n="function"==typeof d?d(t):t[d];if(!e[n]){const t={[p]:[]};"string"==typeof d&&(t[d]=n),e[n]=t}return e[n][p].push(t),e},{});return Object.values(e)}return[{[p]:D}]},[D,d,p,G]),q=Fe(D,y,m),V=e.useMemo(()=>{if(!y)return[];const e=new Set;for(const t of D){const n="function"==typeof y?y(t):t[y];null!=n&&e.add(n+"")}return Array.from(e)},[D,y]),U=De(N,y,V),Z=e.useMemo(()=>U.legendSelectionHook?U.legendSelectionHook:R,[U.legendSelectionHook,R]),J=e.useMemo(()=>e=>{const t={},n=y?ge(e,y,q):ze;return t.fill=n,t.fillOpacity=v,x?(t.stroke=n,t.strokeWidth=k):t.stroke="none",t},[y,q,v,x,k]),K=e.useMemo(()=>$e(J,Z,S),[J,Z,S]),{legend:Q,margin:ee}=Te({data:X,colorBy:y,colorScale:q,showLegend:$,userMargin:i,defaults:o.marginDefaults}),te=d||y,ne=e.useMemo(()=>Je([{label:I||Ze(c),accessor:c,role:"x"},{label:F||Ze(h),accessor:h,role:"y"},...te?[{label:Ze(te),accessor:te,role:"group"}]:[]]),[c,h,I,F,te]),oe=ut({componentName:"AreaChart",data:D,accessors:{xAccessor:c,yAccessor:h}});if(oe)return u.createElement(Ke,{componentName:"AreaChart",message:oe,width:B,height:H});const se=e.useMemo(()=>G||d?X.flatMap(e=>{const t=e[p]||[];return d&&"string"==typeof d?t.map(t=>Object.assign(Object.assign({},t),{[d]:e[d]})):t}):D,[X,p,G,d,D]),ie=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"area",data:se,xAccessor:c,yAccessor:h,groupAccessor:d||void 0},f&&{y0Accessor:f}),g&&{gradientFill:g}),{curve:b,lineStyle:K,size:[B,H],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:ee,showAxes:o.showAxes,xLabel:I,yLabel:F,xFormat:l,yFormat:a,enableHover:_,showGrid:W}),Q&&{legend:Q}),N&&"none"!==N&&{legendHoverBehavior:U.onLegendHover,legendClickBehavior:U.onLegendClick,legendHighlightedCategory:U.highlightedCategory,legendIsolatedCategories:U.isolatedCategories}),z&&{title:z}),r&&{className:r}),{tooltipContent:Ue(w)||ne}),(M||O)&&{customHoverBehavior:Y}),A&&A.length>0&&{annotations:A}),E);return u.createElement(nt,{componentName:"AreaChart",width:B,height:H},u.createElement(he,Object.assign({},ie)))}function pt(t){var n;const o=Ye(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:s,margin:i,className:r,xFormat:l,yFormat:a,xAccessor:c="x",yAccessor:h="y",areaBy:d,lineDataAccessor:f="coordinates",colorBy:g,colorScheme:p="category10",curve:y="monotoneX",areaOpacity:m=.7,showLine:b=!0,lineWidth:v=2,normalize:x=!1,tooltip:k,annotations:w,frameProps:A={},selection:E,linkedHover:S,onObservation:M,chartId:O,loading:C,emptyContent:L,legendInteraction:j}=t,N=o.width,B=o.height,H=o.enableHover,_=o.showGrid,W=o.showLegend,$=o.title,z=o.xLabel,I=o.yLabel,F=rt(C,N,B);if(F)return F;const P=it(s,N,B,L);if(P)return P;const T=s||[],{activeSelectionHook:D,customHoverBehavior:R}=Pe({selection:E,linkedHover:S,fallbackFields:g?["string"==typeof g?g:""]:[],onObservation:M,chartType:"StackedAreaChart",chartId:O}),Y=void 0!==(null===(n=T[0])||void 0===n?void 0:n[f]),G=e.useMemo(()=>{if(Y)return T;if(d){const e=T.reduce((e,t)=>{const n="function"==typeof d?d(t):t[d];if(!e[n]){const t={[f]:[]};"string"==typeof d&&(t[d]=n),e[n]=t}return e[n][f].push(t),e},{});return Object.values(e)}return[{[f]:T}]},[T,d,f,Y]),X=Fe(T,g,p),q=e.useMemo(()=>{if(!g)return[];const e=new Set;for(const t of T){const n="function"==typeof g?g(t):t[g];null!=n&&e.add(n+"")}return Array.from(e)},[T,g]),V=De(j,g,q),U=e.useMemo(()=>V.legendSelectionHook?V.legendSelectionHook:D,[V.legendSelectionHook,D]),Z=e.useMemo(()=>e=>{const t={},n=g?ge(e,g,X):ze;return t.fill=n,t.fillOpacity=m,b?(t.stroke=n,t.strokeWidth=v):t.stroke="none",t},[g,X,m,b,v]),J=e.useMemo(()=>$e(Z,U,E),[Z,U,E]),{legend:K,margin:Q}=Te({data:G,colorBy:g,colorScale:X,showLegend:W,userMargin:i,defaults:o.marginDefaults}),ee=d||g,te=e.useMemo(()=>Je([{label:z||Ze(c),accessor:c,role:"x"},{label:I||Ze(h),accessor:h,role:"y"},...ee?[{label:Ze(ee),accessor:ee,role:"group"}]:[]]),[c,h,z,I,ee]),ne=ut({componentName:"StackedAreaChart",data:T,accessors:{xAccessor:c,yAccessor:h}});if(ne)return u.createElement(Ke,{componentName:"StackedAreaChart",message:ne,width:N,height:B});const oe=e.useMemo(()=>Y||d?G.flatMap(e=>{const t=e[f]||[];return d&&"string"==typeof d?t.map(t=>Object.assign(Object.assign({},t),{[d]:e[d]})):t}):T,[G,f,Y,d,T]),se=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"stackedarea",data:oe,xAccessor:c,yAccessor:h,groupAccessor:d||void 0,curve:y,normalize:x,lineStyle:J,size:[N,B],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Q,showAxes:o.showAxes,xLabel:z,yLabel:I,xFormat:l,yFormat:a,enableHover:H,showGrid:_},K&&{legend:K}),j&&"none"!==j&&{legendHoverBehavior:V.onLegendHover,legendClickBehavior:V.onLegendClick,legendHighlightedCategory:V.highlightedCategory,legendIsolatedCategories:V.isolatedCategories}),$&&{title:$}),r&&{className:r}),{tooltipContent:Ue(k)||te}),(S||M)&&{customHoverBehavior:R}),w&&w.length>0&&{annotations:w}),A);return u.createElement(nt,{componentName:"StackedAreaChart",width:N,height:B},u.createElement(he,Object.assign({},se)))}function yt(t){const n=Ye(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:o,margin:s,className:i,xFormat:r,yFormat:l,xAccessor:a="x",yAccessor:c="y",colorBy:h,colorScheme:d="category10",sizeBy:f,sizeRange:g=[3,15],pointRadius:p=5,pointOpacity:y=.8,tooltip:m,marginalGraphics:b,pointIdAccessor:v,annotations:x,frameProps:k={},selection:w,linkedHover:A,linkedBrush:E,onObservation:S,chartId:M,loading:O,emptyContent:C,legendInteraction:L}=t,j=n.width,N=n.height,B=n.enableHover,H=n.showGrid,_=n.showLegend,W=n.title,$=n.xLabel,z=n.yLabel,I=rt(O,j,N);if(I)return I;const F=it(o,j,N,C);if(F)return F;const P=o||[];lt("Scatterplot",P,"xAccessor",a),lt("Scatterplot",P,"yAccessor",c);const{activeSelectionHook:T,customHoverBehavior:D}=Pe({selection:w,linkedHover:A,fallbackFields:h?["string"==typeof h?h:""]:[],onObservation:S,chartType:"Scatterplot",chartId:M}),R=We(E),Y=je({name:(null==R?void 0:R.name)||"__unused_brush__",xField:(null==R?void 0:R.xField)||("string"==typeof a?a:void 0),yField:(null==R?void 0:R.yField)||("string"==typeof c?c:void 0)}),G=R?"xyBrush"===Y.brushInteraction.brush?"xy":"xBrush"===Y.brushInteraction.brush?"x":"y":void 0,X=u.useRef(Y.brushInteraction);X.current=Y.brushInteraction;const q=e.useCallback(e=>{const t=X.current;t.end(e?"xyBrush"===t.brush?[[e.x[0],e.y[0]],[e.x[1],e.y[1]]]:"xBrush"===t.brush?e.x:e.y:null)},[]),V=Fe(P,h,d),U=e.useMemo(()=>{if(!h)return[];const e=new Set;for(const t of P){const n="function"==typeof h?h(t):t[h];null!=n&&e.add(n+"")}return Array.from(e)},[P,h]),Z=De(L,h,U),J=e.useMemo(()=>Z.legendSelectionHook?Z.legendSelectionHook:T,[Z.legendSelectionHook,T]),K=e.useMemo(()=>{if(!f||0===P.length)return;const e=P.map(e=>"function"==typeof f?f(e):e[f]);return[Math.min(...e),Math.max(...e)]},[P,f]),Q=e.useMemo(()=>e=>{const t={fillOpacity:y};return t.fill=h?ge(e,h,V):ze,t.r=f?ye(e,f,g,K):p,t},[h,V,f,g,K,p,y]),ee=e.useMemo(()=>$e(Q,J,w),[Q,J,w]),{legend:te,margin:ne}=Te({data:P,colorBy:h,colorScale:V,showLegend:_,userMargin:s,defaults:n.marginDefaults}),oe=e.useMemo(()=>Je([{label:$||Ze(a),accessor:a,role:"x"},{label:z||Ze(c),accessor:c,role:"y"},...h?[{label:Ze(h),accessor:h,role:"color"}]:[],...f?[{label:Ze(f),accessor:f,role:"size"}]:[]]),[a,c,$,z,h,f]),se=ut({componentName:"Scatterplot",data:P,accessors:{xAccessor:a,yAccessor:c}});if(se)return u.createElement(Ke,{componentName:"Scatterplot",message:se,width:j,height:N});const ie=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter",data:P,xAccessor:a,yAccessor:c,colorAccessor:h||void 0,sizeAccessor:f||void 0,sizeRange:g,pointStyle:ee,colorScheme:d,size:[j,N],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:ne,showAxes:n.showAxes,xLabel:$,yLabel:z,xFormat:r,yFormat:l,enableHover:B,showGrid:H},te&&{legend:te}),L&&"none"!==L&&{legendHoverBehavior:Z.onLegendHover,legendClickBehavior:Z.onLegendClick,legendHighlightedCategory:Z.highlightedCategory,legendIsolatedCategories:Z.isolatedCategories}),W&&{title:W}),i&&{className:i}),{tooltipContent:Ue(m)||oe}),(A||S)&&{customHoverBehavior:D}),b&&{marginalGraphics:b}),v&&{pointIdAccessor:v}),x&&x.length>0&&{annotations:x}),R&&{brush:{dimension:G},onBrush:q}),k);return u.createElement(nt,{componentName:"Scatterplot",width:j,height:N},u.createElement(he,Object.assign({},ie)))}function mt(t){const n=Ye(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:o,className:s,xFormat:i,yFormat:r,xAccessor:a="x",yAccessor:c="y",orderAccessor:h,orderLabel:d,pointRadius:f=4,tooltip:g,pointIdAccessor:p,annotations:y,frameProps:m={},selection:b,linkedHover:v,onObservation:x,chartId:k,loading:w,emptyContent:A,legendInteraction:E}=t,S=n.width,M=n.height,O=n.enableHover,C=n.showGrid,L=n.title,j=n.xLabel,N=n.yLabel,B=rt(w,S,M);if(B)return B;const H=it(o,S,M,A);if(H)return H;const _=o||[],W=e.useMemo(()=>{if(!h||0===_.length)return _;const e="function"==typeof h?h:e=>e[h];return[..._].sort((t,n)=>{const o=e(t),s=e(n);return(o instanceof Date?o.getTime():+o)-(s instanceof Date?s.getTime():+s)})},[_,h]);lt("ConnectedScatterplot",W,"xAccessor",a),lt("ConnectedScatterplot",W,"yAccessor",c);const{activeSelectionHook:$,customHoverBehavior:z}=Pe({selection:b,linkedHover:v,fallbackFields:[],onObservation:x,chartType:"ConnectedScatterplot",chartId:k}),I=De(E,void 0,[]),F=e.useMemo(()=>I.legendSelectionHook?I.legendSelectionHook:$,[I.legendSelectionHook,$]),P=W.length,T=P>0&&100>P,D=e.useMemo(()=>0===P?[]:W.map((e,t)=>l.interpolateViridis(1===P?.5:t/(P-1))),[W,P]);e.useMemo(()=>null,[P]);const R=e.useMemo(()=>{if(P>=2)return(e,t,n)=>{var o,s;if("connected-lines"!==e.type)return null;const i=n.scales;if(!i)return null;const r=null!==(o=i.x)&&void 0!==o?o:i.time,l=null!==(s=i.y)&&void 0!==s?s:i.value;if(!r||!l)return null;const h="string"==typeof a?e=>e[a]:a,d="string"==typeof c?e=>e[c]:c,g=[];for(let e=0;W.length-1>e;e++){const t=W[e],n=W[e+1],o=r(h(t)),s=l(d(t)),i=r(h(n)),a=l(d(n)),c=D[e];T&&g.push(u.createElement("line",{key:"halo-"+e,x1:o,y1:s,x2:i,y2:a,stroke:"white",strokeWidth:f+2,strokeOpacity:.5,strokeLinecap:"round"})),g.push(u.createElement("line",{key:"conn-"+e,x1:o,y1:s,x2:i,y2:a,stroke:c,strokeWidth:f,strokeLinecap:"round"}))}return u.createElement("g",{key:"ann-"+t},g)}},[W,D,f,T,a,c,P]),Y=e.useMemo(()=>e=>{const t=W.indexOf(e);return{fill:t>=0&&D.length>t?D[t]:"#6366f1",stroke:"white",strokeWidth:1,r:f,fillOpacity:1}},[W,D,f]),G=e.useMemo(()=>$e(Y,F,b),[Y,F,b]),X=Object.assign({top:50,right:40,bottom:60,left:70},t.margin),q=d||("string"==typeof h?h:"Order"),V=e.useMemo(()=>Je([{label:j||Ze(a),accessor:a,role:"x"},{label:N||Ze(c),accessor:c,role:"y"},...h?[{label:q,accessor:h,role:"group"}]:[]]),[a,c,j,N,h,q]),U=ut({componentName:"ConnectedScatterplot",data:W,accessors:{xAccessor:a,yAccessor:c}});if(U)return u.createElement(Ke,{componentName:"ConnectedScatterplot",message:U,width:S,height:M});const Z=e.useMemo(()=>[{type:"connected-lines"},...y||[]],[y]),J=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter",data:W,xAccessor:a,yAccessor:c,pointStyle:G,size:[S,M],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:X,showAxes:n.showAxes,xLabel:j,yLabel:N,xFormat:i,yFormat:r,enableHover:O,showGrid:C},L&&{title:L}),s&&{className:s}),{tooltipContent:Ue(g)||V}),(v||x)&&{customHoverBehavior:z}),p&&{pointIdAccessor:p}),{annotations:Z,svgAnnotationRules:R}),m);return u.createElement(nt,{componentName:"ConnectedScatterplot",width:S,height:M},u.createElement(he,Object.assign({},J)))}function bt(t){const n=Ye(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:o,margin:s,className:i,xFormat:r,yFormat:l,xAccessor:a="x",yAccessor:c="y",sizeBy:h,sizeRange:d=[5,40],colorBy:f,colorScheme:g="category10",bubbleOpacity:p=.6,bubbleStrokeWidth:y=1,bubbleStrokeColor:m="white",tooltip:b,marginalGraphics:v,pointIdAccessor:x,annotations:k,frameProps:w={},selection:A,linkedHover:E,linkedBrush:S,onObservation:M,chartId:O,loading:C,emptyContent:L,legendInteraction:j}=t,N=n.width,B=n.height,H=n.enableHover,_=n.showGrid,W=n.showLegend,$=n.title,z=n.xLabel,I=n.yLabel,F=rt(C,N,B);if(F)return F;const P=it(o,N,B,L);if(P)return P;const T=o||[],{activeSelectionHook:D,customHoverBehavior:R}=Pe({selection:A,linkedHover:E,fallbackFields:f?["string"==typeof f?f:""]:[],onObservation:M,chartType:"BubbleChart",chartId:O}),Y=We(S);je({name:(null==Y?void 0:Y.name)||"__unused_brush__",xField:(null==Y?void 0:Y.xField)||("string"==typeof a?a:void 0),yField:(null==Y?void 0:Y.yField)||("string"==typeof c?c:void 0)});const G=Fe(T,f,g),X=e.useMemo(()=>{if(!f)return[];const e=new Set;for(const t of T){const n="function"==typeof f?f(t):t[f];null!=n&&e.add(n+"")}return Array.from(e)},[T,f]),q=De(j,f,X),V=e.useMemo(()=>q.legendSelectionHook?q.legendSelectionHook:D,[q.legendSelectionHook,D]),U=e.useMemo(()=>{const e=T.map(e=>"function"==typeof h?h(e):e[h]);return[Math.min(...e),Math.max(...e)]},[T,h]),Z=e.useMemo(()=>e=>{const t={fillOpacity:p,strokeWidth:y,stroke:m};return t.fill=f?ge(e,f,G):ze,t.r=ye(e,h,d,U),t},[f,G,h,d,U,p,y,m]),J=e.useMemo(()=>$e(Z,V,A),[Z,V,A]),{legend:K,margin:Q}=Te({data:T,colorBy:f,colorScale:G,showLegend:W,userMargin:s,defaults:n.marginDefaults}),ee=e.useMemo(()=>Je([{label:z||Ze(a),accessor:a,role:"x"},{label:I||Ze(c),accessor:c,role:"y"},{label:Ze(h),accessor:h,role:"size"},...f?[{label:Ze(f),accessor:f,role:"color"}]:[]]),[a,c,z,I,h,f]),te=ut({componentName:"BubbleChart",data:T,accessors:{xAccessor:a,yAccessor:c},requiredProps:{sizeBy:h}});if(te)return u.createElement(Ke,{componentName:"BubbleChart",message:te,width:N,height:B});const ne=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bubble",data:T,xAccessor:a,yAccessor:c,colorAccessor:f||void 0,sizeAccessor:h,sizeRange:d,pointStyle:J,colorScheme:g,size:[N,B],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Q,showAxes:n.showAxes,xLabel:z,yLabel:I,xFormat:r,yFormat:l,enableHover:H,showGrid:_},K&&{legend:K}),j&&"none"!==j&&{legendHoverBehavior:q.onLegendHover,legendClickBehavior:q.onLegendClick,legendHighlightedCategory:q.highlightedCategory,legendIsolatedCategories:q.isolatedCategories}),$&&{title:$}),i&&{className:i}),{tooltipContent:Ue(b)||ee}),(E||M)&&{customHoverBehavior:R}),v&&{marginalGraphics:v}),x&&{pointIdAccessor:x}),k&&k.length>0&&{annotations:k}),w);return u.createElement(nt,{componentName:"BubbleChart",width:N,height:B},u.createElement(he,Object.assign({},ne)))}function vt(t){const n=Ye(t.mode,{width:t.width,height:t.height,showGrid:void 0,enableHover:t.enableHover,showLegend:void 0,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:s,margin:i,className:r,xAccessor:a="x",yAccessor:c="y",valueAccessor:h="value",xFormat:d,yFormat:f,colorScheme:g="blues",customColorScale:p,showValues:y=!1,valueFormat:m,cellBorderColor:b="#fff",cellBorderWidth:v=1,tooltip:x,annotations:k,frameProps:w={},selection:A,linkedHover:E,onObservation:S,chartId:M,loading:O,emptyContent:C,legendInteraction:L}=t,j=n.width,N=n.height,B=n.enableHover,H=n.title,_=n.xLabel,W=n.yLabel,$=rt(O,j,N);if($)return $;const z=it(s,j,N,C);if(z)return z;const I=s||[],{margin:F}=Te({data:I,colorBy:void 0,colorScale:void 0,showLegend:!1,userMargin:i,defaults:n.marginDefaults}),{activeSelectionHook:P,customHoverBehavior:T}=Pe({selection:A,linkedHover:E,fallbackFields:[],onObservation:S,chartType:"Heatmap",chartId:M}),D=De(L,void 0,[]),R=e.useMemo(()=>D.legendSelectionHook?D.legendSelectionHook:P,[D.legendSelectionHook,P]),Y=e.useMemo(()=>"function"==typeof h?e=>h(e):e=>e[h],[h]),G=e.useMemo(()=>{const e=I.map(Y);return[Math.min(...e),Math.max(...e)]},[I,Y]),X=e.useMemo(()=>"custom"===g&&p?p:o.scaleSequential({blues:l.interpolateBlues,reds:l.interpolateReds,greens:l.interpolateGreens,viridis:l.interpolateViridis}[g]||l.interpolateBlues).domain(G),[g,p,G]);e.useMemo(()=>{const e=Ie(a),t=Ie(c);return{xBinCount:new Set(I.map(e)).size,yBinCount:new Set(I.map(t)).size}},[I,a,c]),e.useMemo(()=>({coordinates:I}),[I]);const q=e.useMemo(()=>e=>{const t=Y(e);return{fill:X(t),stroke:b,strokeWidth:v}},[Y,X,b,v]);e.useMemo(()=>$e(q,R,A),[q,R,A]),e.useMemo(()=>{if(!y)return;const e=(G[0]+G[1])/2;return(t,n)=>{const o=Y(t),s=m?m(o):o+"";return u.createElement("text",{textAnchor:"middle",dominantBaseline:"middle",fill:Y(t)>e?"#fff":"#000",fontSize:"12px"},s)}},[y,Y,m,G]);const V=e.useMemo(()=>Je([{label:_||Ze(a),accessor:a,role:"x"},{label:W||Ze(c),accessor:c,role:"y"},{label:Ze(h),accessor:h,role:"value"}]),[a,c,_,W,h]),U=ut({componentName:"Heatmap",data:I,accessors:{xAccessor:a,yAccessor:c,valueAccessor:h}});if(U)return u.createElement(Ke,{componentName:"Heatmap",message:U,width:j,height:N});const Z=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"heatmap",data:I,xAccessor:a,yAccessor:c,valueAccessor:h,size:[j,N],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:F,showAxes:n.showAxes,xLabel:_,yLabel:W,xFormat:d,yFormat:f,enableHover:B},H&&{title:H}),r&&{className:r}),{tooltipContent:Ue(x)||V}),(E||S)&&{customHoverBehavior:T}),k&&k.length>0&&{annotations:k}),w);return u.createElement(nt,{componentName:"Heatmap",width:j,height:N},u.createElement(he,Object.assign({},Z)))}ft.displayName="LineChart",gt.displayName="AreaChart",pt.displayName="StackedAreaChart",yt.displayName="Scatterplot",mt.displayName="ConnectedScatterplot",bt.displayName="BubbleChart",vt.displayName="Heatmap";const xt="__splomIdx",kt={top:4,bottom:4,left:4,right:4};function wt({frameRef:o,cellSize:s,onBrush:i}){const r=e.useRef(null),l=s-kt.left-kt.right,a=s-kt.top-kt.bottom;return e.useEffect(()=>{if(!r.current)return;const e=n.select(r.current).select(".brush-g"),s=t.brush().extent([[0,0],[l,a]]).on("brush end",e=>{var t;const n=null===(t=o.current)||void 0===t?void 0:t.getScales();if(!n)return;if(!e.selection)return void i(null);const[[s,r],[l,a]]=e.selection,c=[[n.x.invert(s),n.y.invert(r)],[n.x.invert(l),n.y.invert(a)]];i(c)});return e.call(s),e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{s.on("brush end",null)}},[l,a,o,i]),u.createElement("svg",{ref:r,width:s,height:s,style:{position:"absolute",top:0,left:0}},u.createElement("g",{className:"brush-g",transform:`translate(${kt.left},${kt.top})`}))}function At({data:t,xField:n,yField:o,cellSize:s,pointRadius:i,pointOpacity:r,colorBy:l,colorScale:a,brushSelectionName:c,hoverSelectionName:h,unselectedOpacity:d,mode:f,onPointHover:g}){const p=e.useRef(null),y=Ce({name:c,clientId:`splom-${n}-${o}`}),m=je({name:c,xField:n,yField:o}),b=Ce({name:h,clientId:"splom-hover-source"}),v=b.selectPoints,x=e.useCallback(e=>{e?m.brushInteraction.during(e):m.brushInteraction.end(null)},[m.brushInteraction]),k=e.useCallback(e=>{if(!e)return void(null==g||g(null));const t=e.data,n=null==t?void 0:t[xt];void 0!==n&&(v({[xt]:[n]}),null==g||g(t,e.x+kt.left,e.y+kt.top))},[v,g]),w=e.useCallback(e=>{const t={opacity:r,r:i};return t.fill=l?ge(e,l,a):ze,"hover"===f?b.isActive&&b.predicate(e)?(t.opacity=1,t.r=2.5*i,t.stroke="#333",t.strokeWidth=1.5):b.isActive&&(t.opacity=.6*r):y.isActive&&!y.predicate(e)&&(t.opacity=d),t},[l,a,r,i,f,y.isActive,y.predicate,b.isActive,b.predicate,d]);return u.createElement("div",{style:{position:"relative",width:s,height:s}},u.createElement(he,{ref:p,chartType:"scatter",data:t,size:[s,s],xAccessor:n,yAccessor:o,pointStyle:w,margin:kt,showAxes:!1,enableHover:"hover"===f,customHoverBehavior:"hover"===f?k:void 0,tooltipContent:"hover"===f?()=>null:void 0}),"brush"===f&&u.createElement(wt,{frameRef:p,cellSize:s,xField:n,yField:o,onBrush:x}))}function Et({data:t,field:n,label:o,cellSize:s,bins:i,brushSelectionName:r,hoverSelectionName:l,mode:a}){const c=Ce({name:r,clientId:"splom-diag-"+n}),h=Ce({name:l,clientId:`splom-diag-${n}-hover`}),d="hover"===a?h:c,f=d.isActive,g=d.predicate,p=e.useMemo(()=>{const e=t.map(e=>e[n]).filter(e=>null!=e&&!isNaN(e));if(0===e.length)return{bars:[],selectedBars:[],max:0};const o=Math.min(...e),r=(Math.max(...e)-o)/i||1,l=Array(i).fill(0),a=Array(i).fill(0);for(const e of t){const t=e[n];if(null==t||isNaN(t))continue;const s=Math.min(Math.floor((t-o)/r),i-1);l[s]++,f&&!g(e)||a[s]++}const c=Math.max(...l,1);return{bars:l.map((e,t)=>({x:t/i*s,w:s/i-1,h:e/c*(s-24),count:e})),selectedBars:a.map((e,t)=>({x:t/i*s,w:s/i-1,h:e/c*(s-24),count:e})),max:c}},[t,n,i,s,f,g]);return u.createElement("svg",{width:s,height:s,style:{overflow:"hidden"}},u.createElement("text",{x:s/2,y:14,textAnchor:"middle",fontSize:11,fontWeight:"bold",fill:"#333"},o),p.bars.map((e,t)=>u.createElement("rect",{key:"bg-"+t,x:e.x,y:s-e.h,width:Math.max(e.w,1),height:e.h,fill:"#ccc",opacity:f?.3:.6})),f&&p.selectedBars.map((e,t)=>u.createElement("rect",{key:"sel-"+t,x:e.x,y:s-e.h,width:Math.max(e.w,1),height:e.h,fill:ze,opacity:.7})))}function St({label:e,cellSize:t}){return u.createElement("svg",{width:t,height:t},u.createElement("text",{x:t/2,y:t/2,textAnchor:"middle",dominantBaseline:"middle",fontSize:12,fontWeight:"bold",fill:"#333"},e))}function Mt(t){const{data:n,fields:o,fieldLabels:s={},colorBy:i,colorScheme:r="category10",cellSize:l=150,cellGap:a=4,pointRadius:c=2,pointOpacity:h=.5,diagonal:d="histogram",histogramBins:f=20,brushMode:g="crossfilter",hoverMode:p=!0,unselectedOpacity:y=.1,showGrid:m=!1,tooltip:b,showLegend:v,idAccessor:x,className:k,onObservation:w,chartId:A}=t,E="splom",S="splom-hover",M=p?"hover":g?"brush":"hover",O=Se(e=>e.clearSelection),[C,L]=e.useState(null),j=e.useCallback(()=>{O(S),L(null)},[O,S]),N=e.useMemo(()=>(n||[]).map((e,t)=>void 0!==e[xt]?e:Object.assign(Object.assign({},e),{[xt]:t})),[n]),B=Fe(N,i,r),H=void 0!==v?v:!!i,_=e.useMemo(()=>{if(!H||!i)return null;const e="string"==typeof i?i:null;return e?[...new Set(N.map(t=>t[e]))].map(e=>({label:e+"",color:B?B(e+""):ze})):null},[H,i,N,B]),W=e.useMemo(()=>({display:"grid",gridTemplateColumns:"40px "+o.map(()=>l+"px").join(" "),gridTemplateRows:o.map(()=>l+"px").join(" ")+" 40px",gap:a+"px",width:"fit-content"}),[o,l,a,40]);return u.createElement("div",{className:k,style:{position:"relative"}},_&&u.createElement("div",{style:{display:"flex",gap:12,marginBottom:8,flexWrap:"wrap"}},_.map(e=>u.createElement("div",{key:e.label,style:{display:"flex",alignItems:"center",gap:4}},u.createElement("span",{style:{display:"inline-block",width:10,height:10,borderRadius:"50%",backgroundColor:e.color}}),u.createElement("span",{style:{fontSize:11}},e.label)))),u.createElement("div",{style:W,onMouseLeave:"hover"===M?j:void 0},o.map((e,t)=>u.createElement(u.Fragment,{key:"row-"+e},u.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",writingMode:"vertical-rl",transform:"rotate(180deg)",fontSize:11,fontWeight:"bold",color:"#333"}},s[e]||e),o.map((n,o)=>t===o?"label"===d?u.createElement(St,{key:"diag-"+e,label:s[e]||e,cellSize:l}):u.createElement(Et,{key:"diag-"+e,data:N,field:e,label:s[e]||e,cellSize:l,bins:f,colorBy:i,colorScale:B,brushSelectionName:E,hoverSelectionName:S,unselectedOpacity:y,mode:M}):u.createElement(At,{key:`cell-${e}-${n}`,data:N,xField:n,yField:e,fieldLabels:s,cellSize:l,pointRadius:c,pointOpacity:h,colorBy:i,colorScale:B,brushSelectionName:E,hoverSelectionName:S,unselectedOpacity:y,showGrid:m,tooltip:b,mode:M,onPointHover:"hover"===M?(s,i,r)=>{s?(L({datum:s,xField:n,yField:e,colIndex:o,rowIndex:t,px:null!=i?i:0,py:null!=r?r:0}),w&&w({type:"hover",datum:s,x:null!=i?i:0,y:null!=r?r:0,timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:A})):(L(null),w&&w({type:"hover-end",timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:A}))}:void 0})))),u.createElement("div",null)," ",o.map(e=>u.createElement("div",{key:"col-label-"+e,style:{display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:"bold",color:"#333"}},s[e]||e))),C&&"hover"===M&&(()=>{const e=C.datum,t=s[C.xField]||C.xField,n=s[C.yField]||C.yField,o=i?"function"==typeof i?i(e):e[i]:null,r=x?"function"==typeof x?x(e):e[x]:"Row "+e[xt];return u.createElement("div",{style:{position:"absolute",left:40+C.colIndex*(l+a)+C.px,top:C.rowIndex*(l+a)+C.py-8,transform:"translate(-50%, -100%)",color:"#333",background:"rgba(255,255,255,0.95)",border:"1px solid #ddd",borderRadius:3,padding:"4px 8px",fontSize:11,lineHeight:1.4,whiteSpace:"nowrap",pointerEvents:"none",zIndex:10}},u.createElement("div",{style:{fontWeight:"bold",marginBottom:2}},r+""),u.createElement("div",null,t,": ",null!=e[C.xField]?Number(e[C.xField]).toFixed(1):"–"),u.createElement("div",null,n,": ",null!=e[C.yField]?Number(e[C.yField]).toFixed(1):"–"),null!=o&&u.createElement("div",{style:{opacity:.8}},"string"==typeof i?i:"group",": ",o+""))})())}function Ot(e){const{brushMode:t="crossfilter",hoverMode:n=!0}=e,o={};return!n&&t&&(o.splom={resolution:t}),n&&(o["splom-hover"]={resolution:"union"}),u.createElement(_e,{selections:o},u.createElement(Mt,Object.assign({},e)))}function Ct({width:o,height:s,margin:i,scales:r,brushDirection:l,extent:a,onBrush:c}){const h=e.useRef(null),d=e.useRef(null),f=e.useRef(!1),g=o+i.left+i.right,p=s+i.top+i.bottom;return e.useEffect(()=>{if(!h.current||!r)return;const e=n.select(h.current).select(".brush-group"),i="x"===l?t.brushX().extent([[0,0],[o,s]]):t.brushY().extent([[0,0],[o,s]]);return i.on("brush end",e=>{if(f.current)return;if(!e.sourceEvent)return;const t=e.selection;if(!t)return void c(null);const n=("x"===l?r.x:r.y).invert;if(!n)return;const o=[n(t[0]),n(t[1])];c(o)}),e.call(i),d.current=i,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.2).attr("stroke","steelblue").attr("stroke-width",1),()=>{i.on("brush end",null)}},[r,o,s,l,c]),e.useEffect(()=>{if(!d.current||!r||!h.current)return;const e=n.select(h.current).select(".brush-group"),t="x"===l?r.x:r.y;if(f.current=!0,a){const n=[t(a[0]),t(a[1])];e.call(d.current.move,n)}else e.call(d.current.move,null);f.current=!1},[a,r,l]),u.createElement("svg",{ref:h,width:g,height:p,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},u.createElement("g",{className:"brush-group",transform:`translate(${i.left},${i.top})`}))}function Lt(t){var n,o;const{data:s,width:i=600,height:r=400,margin:l,className:a,title:c,xLabel:h,yLabel:d,xFormat:f,yFormat:g,xAccessor:p="x",yAccessor:y="y",lineBy:m,lineDataAccessor:b="coordinates",colorBy:v,colorScheme:x="category10",curve:k="linear",lineWidth:w=2,fillArea:A=!1,areaOpacity:E=.3,showPoints:S=!1,pointRadius:M=3,enableHover:O=!0,showGrid:C=!1,showLegend:L,tooltip:j,minimap:N={},renderBefore:B=!1,onBrush:H,brushExtent:_,frameProps:W={},loading:$,emptyContent:z}=t,I=rt($,i,r);if(I)return I;const F=it(s,i,r,z);if(F)return F;const P=s||[],[T,D]=e.useState(null),R=null!=_?_:T,Y=e.useCallback(e=>{_||D(e),null==H||H(e)},[_,H]),G=e.useRef(null),[X,q]=e.useState(null);e.useEffect(()=>{const e=()=>{var t,n;const o=null===(n=null===(t=G.current)||void 0===t?void 0:t.getScales)||void 0===n?void 0:n.call(t);o?q(o):requestAnimationFrame(e)};requestAnimationFrame(e)},[s]);const V=void 0!==(null===(n=P[0])||void 0===n?void 0:n[b]),U=e.useMemo(()=>{if(V)return P;if(m){const e=P.reduce((e,t)=>{const n="function"==typeof m?m(t):t[m];if(!e[n]){const t={[b]:[]};"string"==typeof m&&(t[m]=n),e[n]=t}return e[n][b].push(t),e},{});return Object.values(e)}return[{[b]:P}]},[P,m,b,V]),Z=e.useMemo(()=>V||m?U.flatMap(e=>{const t=e[b]||[];return m&&"string"==typeof m?t.map(t=>Object.assign(Object.assign({},t),{[m]:e[m]})):t}):P,[U,b,V,m,P]),J=Fe(P,v,x),K=e.useMemo(()=>e=>{const t={strokeWidth:w};return t.stroke=v?ge(e,v,J):ze,A&&(t.fill=t.stroke,t.fillOpacity=E),t},[v,J,w,A,E]),Q=e.useMemo(()=>N.lineStyle?N.lineStyle:e=>{const t={strokeWidth:1};return t.stroke=v?ge(e,v,J):ze,t},[v,J,N.lineStyle]),ee=e.useMemo(()=>{if(S)return e=>{const t={r:M,fillOpacity:1};return t.fill=v?ge(e.parentLine||e,v,J):ze,t}},[S,M,v,J]),{legend:te,margin:ne}=Te({data:U,colorBy:v,colorScale:J,showLegend:L,userMargin:l}),oe=N.height||60,se=e.useMemo(()=>{var e,t,n,o,s,i,r,l;return{top:null!==(t=null===(e=N.margin)||void 0===e?void 0:e.top)&&void 0!==t?t:0,bottom:null!==(o=null===(n=N.margin)||void 0===n?void 0:n.bottom)&&void 0!==o?o:20,left:null!==(i=null===(s=N.margin)||void 0===s?void 0:s.left)&&void 0!==i?i:ne.left,right:null!==(l=null===(r=N.margin)||void 0===r?void 0:r.right)&&void 0!==l?l:ne.right}},[N.margin,ne]),ie=N.brushDirection||"x",re=ut({componentName:"MinimapChart",data:P,accessors:{xAccessor:p,yAccessor:y}});if(re)return u.createElement(Ke,{componentName:"MinimapChart",message:re,width:i,height:r});const le=A?"area":"line",ae=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:le,data:Z,xAccessor:p,yAccessor:y,groupAccessor:m||void 0,curve:k,lineStyle:K},S&&{pointStyle:ee}),{size:[i,r],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:ne,showAxes:!0,xLabel:h,yLabel:d,xFormat:f,yFormat:g,enableHover:O,showGrid:C}),te&&{legend:te}),c&&{title:c}),j&&{tooltipContent:Ue(j)||void 0}),R&&{xExtent:R}),W),ce={chartType:le,data:Z,xAccessor:p,yAccessor:y,groupAccessor:m||void 0,curve:k,lineStyle:Q,size:[i,oe+se.top+se.bottom],margin:se,showAxes:null!==(o=N.showAxes)&&void 0!==o&&o,background:N.background,enableHover:!1},ue=u.createElement("div",{key:"minimap",style:{position:"relative",width:i,overflow:"hidden"}},u.createElement(he,Object.assign({ref:G},ce)),u.createElement(Ct,{width:i-se.left-se.right,height:oe,margin:se,scales:X,brushDirection:ie,extent:R,onBrush:Y})),de=u.createElement("div",{key:"main",style:{overflow:"hidden"}},u.createElement(he,Object.assign({},ae)));return u.createElement("div",{className:"minimap-chart"+(a?" "+a:"")},B?ue:de,B?de:ue)}Ot.displayName="ScatterplotMatrix",Lt.displayName="MinimapChart",exports.AreaChart=gt,exports.BubbleChart=bt,exports.ConnectedScatterplot=mt,exports.Heatmap=vt,exports.LineChart=ft,exports.MinimapChart=Lt,exports.Scatterplot=yt,exports.ScatterplotMatrix=Ot,exports.StackedAreaChart=pt,exports.StreamXYFrame=he;