semiotic 3.2.2 → 3.3.0

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 (73) hide show
  1. package/CLAUDE.md +118 -222
  2. package/README.md +37 -17
  3. package/ai/schema.json +64 -1
  4. package/ai/system-prompt.md +3 -3
  5. package/dist/components/Tooltip/Tooltip.d.ts +6 -1
  6. package/dist/components/charts/index.d.ts +2 -0
  7. package/dist/components/charts/ordinal/BarChart.d.ts +2 -0
  8. package/dist/components/charts/ordinal/GaugeChart.d.ts +55 -0
  9. package/dist/components/charts/ordinal/GroupedBarChart.d.ts +1 -0
  10. package/dist/components/charts/ordinal/StackedBarChart.d.ts +1 -0
  11. package/dist/components/charts/ordinal/SwimlaneChart.d.ts +4 -0
  12. package/dist/components/charts/realtime/RealtimeHeatmap.d.ts +2 -0
  13. package/dist/components/charts/realtime/RealtimeHistogram.d.ts +2 -0
  14. package/dist/components/charts/realtime/RealtimeLineChart.d.ts +2 -0
  15. package/dist/components/charts/realtime/RealtimeSwarmChart.d.ts +2 -0
  16. package/dist/components/charts/realtime/RealtimeWaterfallChart.d.ts +2 -0
  17. package/dist/components/charts/shared/hooks.d.ts +5 -1
  18. package/dist/components/charts/shared/types.d.ts +14 -5
  19. package/dist/components/charts/shared/useChartSetup.d.ts +2 -0
  20. package/dist/components/charts/xy/AreaChart.d.ts +17 -2
  21. package/dist/components/charts/xy/LineChart.d.ts +14 -3
  22. package/dist/components/realtime/RingBuffer.d.ts +11 -0
  23. package/dist/components/realtime/types.d.ts +4 -0
  24. package/dist/components/semiotic-ordinal.d.ts +2 -0
  25. package/dist/components/semiotic-server.d.ts +6 -1
  26. package/dist/components/semiotic-utils.d.ts +2 -1
  27. package/dist/components/semiotic.d.ts +3 -3
  28. package/dist/components/server/animatedGif.d.ts +78 -0
  29. package/dist/components/server/renderToStaticSVG.d.ts +85 -5
  30. package/dist/components/server/staticAnnotations.d.ts +40 -0
  31. package/dist/components/server/staticLegend.d.ts +39 -0
  32. package/dist/components/server/svgHatchPattern.d.ts +26 -0
  33. package/dist/components/server/themeResolver.d.ts +35 -0
  34. package/dist/components/store/LinkedCrosshairStore.d.ts +6 -2
  35. package/dist/components/stream/CanvasHitTester.d.ts +13 -0
  36. package/dist/components/stream/GeoPipelineStore.d.ts +6 -1
  37. package/dist/components/stream/NetworkPipelineStore.d.ts +20 -0
  38. package/dist/components/stream/OrdinalPipelineStore.d.ts +11 -0
  39. package/dist/components/stream/OrdinalSVGOverlay.d.ts +6 -1
  40. package/dist/components/stream/PipelineStore.d.ts +28 -1
  41. package/dist/components/stream/SVGOverlay.d.ts +11 -5
  42. package/dist/components/stream/accessorUtils.d.ts +3 -3
  43. package/dist/components/stream/geoTypes.d.ts +2 -0
  44. package/dist/components/stream/hitTestUtils.d.ts +15 -0
  45. package/dist/components/stream/networkTypes.d.ts +33 -0
  46. package/dist/components/stream/ordinalTypes.d.ts +37 -4
  47. package/dist/components/stream/renderers/resolveCSSColor.d.ts +17 -0
  48. package/dist/components/stream/types.d.ts +58 -5
  49. package/dist/components/stream/xySceneBuilders/mixedScene.d.ts +12 -0
  50. package/dist/components/stream/xySceneBuilders/types.d.ts +15 -0
  51. package/dist/geo.min.js +1 -1
  52. package/dist/geo.module.min.js +1 -1
  53. package/dist/network.min.js +1 -1
  54. package/dist/network.module.min.js +1 -1
  55. package/dist/ordinal.min.js +1 -1
  56. package/dist/ordinal.module.min.js +1 -1
  57. package/dist/realtime.min.js +1 -1
  58. package/dist/realtime.module.min.js +1 -1
  59. package/dist/semiotic-ai.min.js +1 -1
  60. package/dist/semiotic-ai.module.min.js +1 -1
  61. package/dist/semiotic-ordinal.d.ts +2 -0
  62. package/dist/semiotic-server.d.ts +6 -1
  63. package/dist/semiotic-utils.d.ts +2 -1
  64. package/dist/semiotic-utils.min.js +1 -1
  65. package/dist/semiotic-utils.module.min.js +1 -1
  66. package/dist/semiotic.d.ts +3 -3
  67. package/dist/semiotic.min.js +1 -1
  68. package/dist/semiotic.module.min.js +1 -1
  69. package/dist/server.min.js +1 -1
  70. package/dist/server.module.min.js +1 -1
  71. package/dist/xy.min.js +1 -1
  72. package/dist/xy.module.min.js +1 -1
  73. package/package.json +21 -7
@@ -1 +1 @@
1
- import*as t from"react";import{useRef as e,useMemo as n,useEffect as r,useState as o,useSyncExternalStore as i,createContext as l,useContext as a,useCallback as s,forwardRef as c,useImperativeHandle as u,useId as h}from"react";import{select as d}from"d3-selection";import{brushX as f,brushY as y,brush as g}from"d3-brush";import{scaleSequential as p,scaleLinear as m,scaleLog as v}from"d3-scale";import{quadtree as x}from"d3-quadtree";import{schemeCategory10 as b,interpolateViridis as k,interpolateGreens as w,interpolateReds as E,interpolateBlues as A}from"d3-scale-chromatic";import{bin as M,min as S,groups as _,max as P,sum as D,mean as T,group as L}from"d3-array";import{packEnclose as C,hierarchy as $,partition as N,pack as O,treemap as W,treemapBinary as I,cluster as z,tree as B}from"d3-hierarchy";import{area as j,curveCatmullRom as F,curveCardinal as R,curveBasis as Y,curveStepBefore as H,curveStepAfter as X,curveStep as G,curveMonotoneY as V,curveMonotoneX as q,curveLinear as U,arc as K,line as Z,curveNatural as Q,pie as J}from"d3-shape";import tt from"regression";import{interpolateNumber as et}from"d3-interpolate";import{forceLink as nt,forceSimulation as rt,forceManyBody as ot,forceCenter as it,forceX as lt,forceY as at}from"d3-force";import{ribbon as st,chord as ct}from"d3-chord";function ut(t,e){let n=0,r=e.length-1;for(;r>n;){const o=n+r+1>>1;e[o]>t?r=o-1:n=o}return e[n]}function ht(t,e){let n=0,r=e.length-1;for(;r>n;){const o=n+r>>1;t>e[o]?n=o+1:r=o}return e[n]}function dt({width:o,height:i,totalWidth:l,totalHeight:a,margin:s,dimension:c,scales:u,onBrush:h,binSize:p,snap:m,binBoundaries:v,snapDuring:x,streaming:b}){const k=e(null),w=e(null),E=e(h);E.current=h;const A=e(u);A.current=u;const M=n(()=>v?[...v].sort((t,e)=>t-e):void 0,[v]),S=e(M);S.current=M;const _=e(!1),P=e(null);return r(()=>{if(!k.current)return;const t=d(k.current).select(".brush-g"),e="x"===c?f():"y"===c?y():g();return e.extent([[0,0],[o,i]]),e.on("brush end",n=>{if(_.current)return;const r=A.current;if(!r)return;if(!n.selection)return P.current=null,void E.current(null);let l,a;if("x"===c){const[t,e]=n.selection;l=[r.x.invert(t),r.x.invert(e)],a=[r.y.invert(i),r.y.invert(0)]}else if("y"===c){const[t,e]=n.selection;l=[r.x.invert(0),r.x.invert(o)],a=[r.y.invert(e),r.y.invert(t)]}else{const[[t,e],[o,i]]=n.selection;l=[r.x.invert(t),r.x.invert(o)],a=[r.y.invert(i),r.y.invert(e)]}if("bin"===m&&"y"!==c&&("end"===n.type||"brush"===n.type&&x)){const o=S.current;o&&o.length>0?l=function(t,e){return 0===e.length?t:[ut(t[0],e),ht(t[1],e)]}(l,o):p&&p>0&&(l=[Math.floor(l[0]/p)*p,Math.ceil(l[1]/p)*p]);const i=r.x(l[0]),a=r.x(l[1]);if(_.current=!0,"x"===c)t.call(e.move,[i,a]);else if("xy"===c){const r=n.selection;t.call(e.move,[[i,r[0][1]],[a,r[1][1]]])}_.current=!1}const s={x:l,y:a};P.current=s,E.current(s)}),t.call(e),w.current=e,t.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{e.on("brush end",null),w.current=null}},[o,i,c,m,p,x]),r(()=>{if(!(b&&u&&w.current&&P.current))return;if(!k.current)return;if("y"===c)return;const t=P.current,e=u.x.domain()[0],n=d(k.current).select(".brush-g");if(e>=t.x[1])return _.current=!0,n.call(w.current.move,null),_.current=!1,P.current=null,void E.current(null);let r=t.x[0],o=!1;if(e>t.x[0]){if(r=e,"bin"===m){const t=S.current;t&&t.length>0?r=ht(e,t):p&&p>0&&(r=Math.ceil(e/p)*p)}if(r>=t.x[1])return _.current=!0,n.call(w.current.move,null),_.current=!1,P.current=null,void E.current(null);o=!0}const i=u.x(r),l=u.x(t.x[1]);if(_.current=!0,"x"===c)n.call(w.current.move,[i,l]);else{const e=u.y(t.y[1]),r=u.y(t.y[0]);n.call(w.current.move,[[i,e],[l,r]])}if(_.current=!1,o){const e={x:[r,t.x[1]],y:t.y};P.current=e,E.current(e)}},[u,b,c,m,p]),t.createElement("svg",{ref:k,width:l,height:a,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},t.createElement("g",{className:"brush-g",transform:`translate(${s.left},${s.top})`}))}class ft{constructor(t,e){var n,r;this.lastBoundedData=null,this.chunkTimer=0,this.pushBuffer=[],this.flushScheduled=!1,this.callback=t,this.chunkThreshold=null!==(n=null==e?void 0:e.chunkThreshold)&&void 0!==n?n:5e3,this.chunkSize=null!==(r=null==e?void 0:e.chunkSize)&&void 0!==r?r:5e3}updateChunkOptions(t){null!=t.chunkThreshold&&(this.chunkThreshold=t.chunkThreshold),null!=t.chunkSize&&(this.chunkSize=t.chunkSize)}clearLastData(){this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(t){if(this.lastBoundedData=t,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.chunkThreshold>=t.length)return void this.callback({inserts:t,bounded:!0});this.callback({inserts:t.slice(0,this.chunkSize),bounded:!0,totalSize:t.length});let e=this.chunkSize;const n=()=>{if(e>=t.length)return;if(t!==this.lastBoundedData)return;const r=Math.min(e+this.chunkSize,t.length);this.callback({inserts:t.slice(e,r),bounded:!1}),e=r,this.chunkTimer=t.length>e?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}flushPushBuffer(){if(this.flushScheduled=!1,0===this.pushBuffer.length)return;const t=this.pushBuffer;this.pushBuffer=[],this.callback({inserts:t,bounded:!1})}scheduleFlush(){this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flushPushBuffer()))}push(t){this.pushBuffer.push(t),this.scheduleFlush()}pushMany(t){if(0!==t.length){for(let e=0;t.length>e;e++)this.pushBuffer.push(t[e]);this.scheduleFlush()}}flush(){this.flushPushBuffer()}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1}}class yt{constructor(t){if(this._capacity=t,this.head=0,this._size=0,1>t)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(t)}push(t){let e;return this._size===this._capacity?e=this.buffer[this.head]:this._size++,this.buffer[this.head]=t,this.head=(this.head+1)%this._capacity,e}pushMany(t){const e=[];for(const n of t){const t=this.push(n);void 0!==t&&e.push(t)}return e}get(t){if(t>=0&&this._size>t)return this.buffer[(this.head-this._size+t+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let t=0;const e=this;return{next:()=>e._size>t?{done:!1,value:e.get(t++)}:{done:!0,value:void 0}}}forEach(t){const e=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)t(this.buffer[(e+n)%this._capacity],n)}toArray(){const t=Array(this._size),e=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)t[n]=this.buffer[(e+n)%this._capacity];return t}resize(t){if(1>t)throw Error("RingBuffer capacity must be at least 1");const e=this.toArray(),n=[];for(;e.length>t;)n.push(e.shift());this._capacity=t,this.buffer=Array(t),this.head=0,this._size=0;for(const t of e)this.push(t);return 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 gt{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(t){Number.isNaN(t)||(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}evict(t){t!==this._min&&t!==this._max||(this._dirty=!0)}recalculate(t,e){this._min=1/0,this._max=-1/0;for(const n of t){const t=e?e(n):n;Number.isNaN(t)||(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}this._dirty=!1}clear(){this._min=1/0,this._max=-1/0,this._dirty=!1}get extent(){return[this._min,this._max]}get min(){return this._min}get max(){return this._max}get dirty(){return this._dirty}}function pt(t,e,n,r,o){const i=new Map;for(const l of t){const t=e(l),a=n(l);if(null==t||null==a||Number.isNaN(t)||Number.isNaN(a))continue;const s=Math.floor(t/r)*r;let c=i.get(s);if(c||(c={start:s,end:s+r,total:0,categories:new Map},i.set(s,c)),c.total+=a,o){const t=o(l);c.categories.set(t,(c.categories.get(t)||0)+a)}}return i}function mt(t,e){return t===e||typeof t==typeof e&&"function"==typeof t&&"function"==typeof e&&""+t==""+e}function vt(t,e){if("function"==typeof t)return e=>+t(e);const n=t||e;return t=>+t[n]}function xt(t,e){if("function"==typeof t)return t;const n=t||e;return t=>t[n]}function bt(t,e){return"function"==typeof t?t:t?e=>e[t]+"":void 0}const kt=b,wt=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];function Et(t,e,n){var r,o,i;if(1>=n)return 1;const l=null!==(r=t.minOpacity)&&void 0!==r?r:.1,a=n-1-e;switch(t.type){case"linear":return l+(1-a/(n-1))*(1-l);case"exponential":{const e=null!==(o=t.halfLife)&&void 0!==o?o:n/2;return l+Math.pow(.5,a/e)*(1-l)}case"step":return(null!==(i=t.stepThreshold)&&void 0!==i?i:.5*n)>a?1:l;default:return 1}}function At(t,e,n){var r;const o=null!==(r=t.duration)&&void 0!==r?r:500,i=n-e;return o>i?1-i/o:0}function Mt(t,e="ease-out-cubic"){return"linear"===e?t:1-Math.pow(1-t,3)}function St(t,e){return Math.min((t-e.startTime)/e.duration,1)}function _t(t,e,n){return t+(e-t)*n}function Pt(t,e,n){var r,o,i,l;switch(e.type){case"point":if(e.pointId)return"p:"+e.pointId;if("streaming"===t.runtimeMode&&e.datum){const n=t.getX(e.datum),r=t.getY(e.datum);if(t.getCategory)return`p:${t.getCategory(e.datum)}:${n}:${r}`;if(null!=n&&null!=r)return`p:${n}:${r}`}return"p:"+n;case"rect":return`r:${e.group||""}:${null!==(l=null!==(o=null===(r=e.datum)||void 0===r?void 0:r.binStart)&&void 0!==o?o:null===(i=e.datum)||void 0===i?void 0:i.category)&&void 0!==l?l:n}`;case"heatcell":return`h:${e.x}_${e.y}`;case"candlestick":return null==e.datum?"c:"+n:"c:"+t.getX(e.datum);case"line":return"l:"+(e.group||"_default");case"area":return"a:"+(e.group||"_default");default:return null}}function Dt(t,e,n,r,o,i){const l=[];for(const o of t){const t=n(o),i=r(o);null==t||null==i||Number.isNaN(t)||Number.isNaN(i)||l.push({px:e.x(t),py:e.y(i),rawY:i,d:o})}l.sort((t,e)=>t.px-e.px);const a=Array(l.length),s=Array(l.length),c=Array(l.length);for(let t=0;l.length>t;t++){const e=l[t];a[t]=[e.px,e.py],s[t]=e.rawY,c[t]=e.d}return{type:"line",path:a,rawValues:s,style:o,datum:c,group:i}}function Tt(t,e,n,r,o,i,l,a){const s=[];for(const i of t){const t=n(i),l=r(i);if(null==t||null==l||Number.isNaN(t)||Number.isNaN(l))continue;const c=e.x(t),u=a?a(i):o;s.push({px:c,topY:e.y(l),botY:e.y(u)})}s.sort((t,e)=>t.px-e.px);const c=Array(s.length),u=Array(s.length);for(let t=0;s.length>t;t++){const e=s[t];c[t]=[e.px,e.topY],u[t]=[e.px,e.botY]}return{type:"area",topPath:c,bottomPath:u,style:i,datum:t,group:l}}function Lt(t,e,n,r,o,i,l){const a=n(t),s=r(t);if(null==a||null==s||Number.isNaN(a)||Number.isNaN(s))return null;const c={type:"point",x:e.x(a),y:e.y(s),r:o,style:i,datum:t};return void 0!==l&&(c.pointId=l),c}function Ct(t,e,n,r,o,i,l){return{type:"rect",x:t,y:e,w:n,h:r,style:o,datum:i,group:l}}function $t(t,e,n,r,o,i,l){const a={type:"heatcell",x:t,y:e,w:n,h:r,fill:o,datum:i};return(null==l?void 0:l.showValues)&&(a.showValues=!0,a.value=l.value,l.valueFormat&&(a.valueFormat=l.valueFormat)),a}function Nt(t,e,n){if(!t.getBounds||!t.scales)return null;const r=[],o=[];for(const n of e){const e=t.getX(n),i=t.getY(n);if(null==e||null==i||Number.isNaN(e)||Number.isNaN(i))continue;const l=t.getBounds(n),a=t.scales.x(e);if(l&&0!==l)r.push([a,t.scales.y(i+l)]),o.push([a,t.scales.y(i-l)]);else{const e=t.scales.y(i);r.push([a,e]),o.push([a,e])}}return 2>r.length?null:{type:"area",topPath:r,bottomPath:o,style:t.resolveBoundsStyle(n,e[0]),datum:e,group:n,interactive:!1}}function Ot(t,e,n,r){var o;if(!t.config.pointStyle)return;const i=null!=r?r:t.getY;for(const r of e){const e=t.resolveGroupColor(r.key);for(const l of r.data){let r=t.config.pointStyle(l);!r.fill&&e&&(r=Object.assign(Object.assign({},r),{fill:e}));const a=null!==(o=r.r)&&void 0!==o?o:3,s=t.getPointId?t.getPointId(l)+"":void 0,c=Lt(l,t.scales,t.getX,i,a,r,s);c&&n.push(c)}}}const Wt={blues:A,reds:E,greens:w,viridis:k};class It{constructor(t){this.xExtent=new gt,this.yExtent=new gt,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.prevPathMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupColorMap=new Map,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this._ingestVersion=0,this._bufferArrayCache=null,this._bufferDirty=!0,this.needsFullRebuild=!0,this.lastLayout=null,this.scales=null,this.scene=[],this.version=0,this.xIsDate=!1,this._quadtree=null,this.config=t,this.buffer=new yt(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=vt(t.timeAccessor||t.xAccessor,"time"),this.getY=vt(t.valueAccessor||t.yAccessor,"value")):(this.getX=vt(t.xAccessor,"x"),this.getY=vt(t.yAccessor,"y")),this.getGroup=bt(t.groupAccessor),this.getCategory=bt(t.categoryAccessor),this.getSize=t.sizeAccessor?vt(t.sizeAccessor,"size"):void 0,this.getColor=bt(t.colorAccessor),this.getBounds=t.boundsAccessor?vt(t.boundsAccessor,"bounds"):void 0,this.getY0=t.y0Accessor?vt(t.y0Accessor,"y0"):void 0,this.getPointId=bt(t.pointIdAccessor),"candlestick"===t.chartType&&(this.getOpen=vt(t.openAccessor,"open"),this.getHigh=vt(t.highAccessor,"high"),this.getLow=vt(t.lowAccessor,"low"),this.getClose=vt(t.closeAccessor,"close")),t.pulse&&(this.timestampBuffer=new yt(t.windowSize))}ingest(t){const e="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=e,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,t.bounded){if(this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.getX=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?vt(this.config.timeAccessor||this.config.xAccessor,"time"):vt(this.config.xAccessor,"x"),this.xIsDate=!1,t.inserts.length>0){const e=t.inserts[0],n=this.config.xAccessor,r="function"==typeof n?n(e):e[n||"x"],o=r instanceof Date,i="string"==typeof r&&r.length>=10&&!isNaN(new Date(r).getTime())&&isNaN(Number(r));if(this.xIsDate=o||i,i){const t="string"==typeof n?n:void 0;this.getX=t?e=>+new Date(e[t]):t=>+(n(t)instanceof Date?n(t):new Date(n(t)))}}const n=t.totalSize||t.inserts.length;n>this.buffer.capacity&&(this.buffer.resize(n),this.timestampBuffer&&n>this.timestampBuffer.capacity&&this.timestampBuffer.resize(n));for(const n of t.inserts)this.buffer.push(n),this.timestampBuffer&&this.timestampBuffer.push(e),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 t.inserts){if("growing"===this.config.windowMode&&this.buffer.full){const t=this.config.maxCapacity||1e6;t>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,t),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap))}const t=this.buffer.push(n);this.timestampBuffer&&this.timestampBuffer.push(e),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!=t&&(this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):this.yExtent.evict(this.getY(t)))}return!0}computeScene(t){var e,n,r,o,i,l;const{config:a,buffer:s}=this;if(!this.needsFullRebuild&&this.lastLayout&&this.scene.length>0&&this.scales&&(this.lastLayout.width!==t.width||this.lastLayout.height!==t.height))return void this.remapScene(t);if(this.xExtent.dirty&&this.xExtent.recalculate(s,this.getX),this.yExtent.dirty)if("candlestick"===a.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const t of s)this.yExtent.push(this.getHigh(t)),this.yExtent.push(this.getLow(t))}else this.yExtent.recalculate(s,this.getY);const c=this.getBufferArray(),u=this.xExtent.extent,h=this.yExtent.extent;let d=a.xExtent?[null!==(e=a.xExtent[0])&&void 0!==e?e:u[0],null!==(n=a.xExtent[1])&&void 0!==n?n:u[1]]:u,f=a.yExtent?[null!==(r=a.yExtent[0])&&void 0!==r?r:h[0],null!==(o=a.yExtent[1])&&void 0!==o?o:h[1]]:h;const y=a.yExtent&&null!=a.yExtent[0]&&null!=a.yExtent[1];if("stackedarea"===a.chartType&&!y&&s.size>0)if(a.normalize)f=[0,1+a.extentPadding];else{const t=`${s.size}:${this._ingestVersion}`;if(this._stackExtentCache&&this._stackExtentCache.key===t)f=this._stackExtentCache.yDomain;else{const e=this.groupData(c),n=new Map;for(const t of e)for(const e of t.data){const t=this.getX(e),r=this.getY(e);null==t||null==r||Number.isNaN(t)||Number.isNaN(r)||n.set(t,(n.get(t)||0)+r)}let r=0;for(const t of n.values())t>r&&(r=t);f=[0,r+(r>0?r*a.extentPadding:1)],this._stackExtentCache={key:t,yDomain:f}}}else if("bar"===a.chartType&&a.binSize&&!y&&s.size>0){const[,t]=function(t,e,n,r,o){const i=pt(t,e,n,r,o);if(0===i.size)return[0,0];let l=0;for(const t of i.values())t.total>l&&(l=t.total);return[0,l]}(s,this.getX,this.getY,a.binSize,this.getCategory);f=[0,t+t*a.extentPadding]}else if("waterfall"===a.chartType&&!y&&s.size>0){const[t,e]=function(t,e){let n=0,r=0,o=0;for(const i of t){const t=e(i);null==t||Number.isNaN(t)||(o+=t,n>o&&(n=o),o>r&&(r=o))}return[n,r]}(s,this.getY),n=e-t,r=n>0?n*a.extentPadding:1;f=[Math.min(0,t-Math.abs(r)),Math.max(0,e+Math.abs(r))]}else if(!y&&f[0]!==1/0){if(this.getBounds)for(const t of c){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 t=f[1]-f[0],e=t>0?t*a.extentPadding:1,n=null===(i=a.yExtent)||void 0===i?void 0:i[0],r=null===(l=a.yExtent)||void 0===l?void 0:l[1];f=[null!=n?f[0]:f[0]-e,null!=r?f[1]:f[1]+e],"log"===a.yScaleType&&0>=f[0]&&h[0]>0&&(f[0]=null!=n?f[0]:h[0]/(1+a.extentPadding))}if(d[0]!==1/0&&d[1]!==-1/0||(d=[0,1]),f[0]!==1/0&&f[1]!==-1/0||(f=[0,1]),"streaming"===a.runtimeMode)if("x"==("up"===(g=a.arrowOfTime)||"down"===g?"y":"x")){const e="right"===a.arrowOfTime?[0,t.width]:[t.width,0];this.scales={x:m().domain(d).range(e),y:m().domain(f).range([t.height,0])}}else{const e="down"===a.arrowOfTime?[0,t.height]:[t.height,0];this.scales={x:m().domain(f).range([0,t.width]),y:m().domain(d).range(e)}}else{const e=(t,e,n)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return v().domain(t).range(n).clamp(!0)}return m().domain(e).range(n)};this.scales={x:e(a.xScaleType,d,[0,t.width]),y:e(a.yScaleType,f,[t.height,0])}}var g;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(t,c),this.config.decay&&this.applyDecay(this.scene,c),this.config.pulse&&this.applyPulse(this.scene,c),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.rebuildQuadtree(),this.needsFullRebuild=!1,this.lastLayout={width:t.width,height:t.height},this.version++}rebuildQuadtree(){const t=this.config.chartType;if("scatter"!==t&&"bubble"!==t)return void(this._quadtree=null);const e=this.scene.filter(t=>"point"===t.type);this._quadtree=e.length>It.QUADTREE_THRESHOLD?x().x(t=>t.x).y(t=>t.y).addAll(e):null}get quadtree(){return this._quadtree}remapScene(t){const e=t.width/this.lastLayout.width,n=t.height/this.lastLayout.height;for(const t of this.scene)switch(t.type){case"line":for(const r of t.path)r[0]*=e,r[1]*=n;break;case"area":for(const r of t.topPath)r[0]*=e,r[1]*=n;for(const r of t.bottomPath)r[0]*=e,r[1]*=n;break;case"point":t.x*=e,t.y*=n;break;case"rect":case"heatcell":t.x*=e,t.y*=n,t.w*=e,t.h*=n;break;case"candlestick":t.x*=e,t.openY*=n,t.closeY*=n,t.highY*=n,t.lowY*=n}const r=this.scales.x.domain(),o=this.scales.y.domain(),i=this.scales.x.range(),l=this.scales.y.range(),a=(t,e,n)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return v().domain(t).range(n).clamp(!0)}return m().domain(e).range(n)};this.scales={x:a(this.config.xScaleType,r,[i[0]*e,i[1]*e]),y:a(this.config.yScaleType,o,[l[0]*n,l[1]*n])},this.lastLayout={width:t.width,height:t.height},this.rebuildQuadtree(),this.version++}buildSceneNodes(t,e){var n;const{config:r,scales:o}=this;if(!o||0===e.length)return[];const i={scales:o,config:r,getX:this.getX,getY:this.getY,getY0:this.getY0,getSize:this.getSize,getColor:this.getColor,getGroup:this.getGroup,getCategory:this.getCategory,getPointId:this.getPointId,getBounds:this.getBounds,getOpen:this.getOpen,getHigh:this.getHigh,getLow:this.getLow,getClose:this.getClose,resolveLineStyle:(t,e)=>this.resolveLineStyle(t,e),resolveAreaStyle:(t,e)=>this.resolveAreaStyle(t,e),resolveBoundsStyle:(t,e)=>this.resolveBoundsStyle(t,e),resolveColorMap:t=>this.resolveColorMap(t),resolveGroupColor:t=>this.resolveGroupColor(t),groupData:t=>this.groupData(t),barCategoryCache:this._barCategoryCache};switch(r.chartType){case"line":return function(t,e){var n;const r=t.groupData(e),o=[],i=null===(n=t.config.annotations)||void 0===n?void 0:n.filter(t=>"threshold"===t.type&&t.color).map(t=>({value:t.value,color:t.color,thresholdType:t.thresholdType||"greater"}));if(t.getBounds)for(const e of r){const n=Nt(t,e.data,e.key);n&&o.push(n)}for(const e of r){const n=t.resolveLineStyle(e.key,e.data[0]),r=Dt(e.data,t.scales,t.getX,t.getY,n,e.key);i&&i.length>0&&(r.colorThresholds=i),t.config.curve&&"linear"!==t.config.curve&&(r.curve=t.config.curve),o.push(r)}return Ot(t,r,o),o}(i,e);case"area":return function(t,e){const n=t.groupData(e),r=[],o=t.scales.y.domain()[0],i=t.getY0?e=>{const n=t.getY0(e);return null==n?o:n}:void 0;for(const e of n){const n=t.resolveAreaStyle(e.key,e.data[0]),l=Tt(e.data,t.scales,t.getX,t.getY,o,n,e.key,i);t.config.gradientFill&&(l.fillGradient=t.config.gradientFill),t.config.curve&&"linear"!==t.config.curve&&(l.curve=t.config.curve),r.push(l)}return Ot(t,n,r),r}(i,e);case"stackedarea":return function(t,e){const n=t.groupData(e);n.sort((t,e)=>e.key>t.key?-1:t.key>e.key?1:0);const r=t.config.curve&&"linear"!==t.config.curve?t.config.curve:void 0,{nodes:o,stackedTops:i}=function(t,e,n,r,o,i,l){var a;const s=new Set;for(const e of t)for(const t of e.data){const e=n(t);null==e||Number.isNaN(e)||s.add(e)}const c=Array.from(s).sort((t,e)=>t-e),u=new Map;for(const e of t){const t=new Map;for(const o of e.data){const e=n(o),i=r(o);null==e||null==i||Number.isNaN(e)||Number.isNaN(i)||t.set(e,(t.get(e)||0)+i)}u.set(e.key,t)}let h;if(i){h=new Map;for(const e of c){let n=0;for(const r of t)n+=(null===(a=u.get(r.key))||void 0===a?void 0:a.get(e))||0;h.set(e,n||1)}}const d=[],f=new Map,y=new Map;for(const t of c)y.set(t,0);for(const n of t){const t=u.get(n.key),r=[],a=[],s=new Map;for(const n of c){let o=t.get(n)||0;const l=y.get(n);i&&(o/=h.get(n));const c=l+o,u=e.x(n);a.push([u,e.y(l)]),r.push([u,e.y(c)]),y.set(n,c),s.set(n,c)}f.set(n.key,s);const g={type:"area",topPath:r,bottomPath:a,style:o(n.key,n.data[0]),datum:n.data,group:n.key};l&&(g.curve=l),d.push(g)}return{nodes:d,stackedTops:f}}(n,t.scales,t.getX,t.getY,(e,n)=>t.resolveAreaStyle(e,n),t.config.normalize,r),l=o;if(t.config.pointStyle){const e=new WeakMap;for(const r of n){const n=i.get(r.key);if(n)for(const o of r.data){const r=t.getX(o),i=t.getY(o);null==r||Number.isNaN(r)||null==i||Number.isNaN(i)||!n.has(r)||e.set(o,n.get(r))}}const r=n=>{var r;return null!==(r=e.get(n))&&void 0!==r?r:t.getY(n)};Ot(t,n,l,r)}return l}(i,e);case"scatter":case"bubble":return function(t,e){const n=[],r="bubble"===t.config.chartType?10:5,o=t.config.sizeRange||[3,15];let i=null;if(t.getSize&&!t.config.pointStyle){const n=e.map(e=>t.getSize(e)).filter(t=>null!=t&&!Number.isNaN(t));if(n.length>0){let t=1/0,e=-1/0;for(const r of n)t>r&&(t=r),r>e&&(e=r);i=n=>t===e?(o[0]+o[1])/2:o[0]+(n-t)/(e-t)*(o[1]-o[0])}}const l=t.getColor?t.resolveColorMap(e):null;for(const o of e){let e=t.config.pointStyle?t.config.pointStyle(o):{fill:"#4e79a7",opacity:.8},a=e.r||r;if(i&&t.getSize){const e=t.getSize(o);null==e||Number.isNaN(e)||(a=i(e))}if(l&&t.getColor&&!e.fill){const n=t.getColor(o);n&&l.has(n)&&(e=Object.assign(Object.assign({},e),{fill:l.get(n)}))}const s=t.getPointId?t.getPointId(o)+"":void 0,c=Lt(o,t.scales,t.getX,t.getY,a,e,s);c&&n.push(c)}return n}(i,e);case"heatmap":return function(t,e,n){if(t.config.heatmapAggregation)return function(t,e,n){var r,o,i;const l=[],a=Math.max(1,Math.floor(null!==(r=t.config.heatmapXBins)&&void 0!==r?r:20)),s=Math.max(1,Math.floor(null!==(o=t.config.heatmapYBins)&&void 0!==o?o:20)),c=null!==(i=t.config.heatmapAggregation)&&void 0!==i?i:"count",u=vt(t.config.valueAccessor,"value");if(!t.scales||0===e.length)return l;const[h,d]=t.scales.x.domain(),[f,y]=t.scales.y.domain(),g=(d-h||1)/a,p=(y-f||1)/s,m=new Map;for(const n of e){const e=t.getX(n),r=t.getY(n);if(!isFinite(e)||!isFinite(r))continue;const o=Math.min(Math.floor((e-h)/g),a-1),i=Math.min(Math.floor((r-f)/p),s-1);if(0>o||0>i)continue;const l=u(n),c=`${o}_${i}`;let d=m.get(c);d||(d={sum:0,count:0,data:[]},m.set(c,d)),d.count++,d.sum+=isFinite(l)?l:0,d.data.push(n)}let v=1/0,x=-1/0;const b=new Map;for(const[t,e]of m){let n;switch(c){case"sum":n=e.sum;break;case"mean":n=e.count>0?e.sum/e.count:0;break;default:n=e.count}b.set(t,n),v>n&&(v=n),n>x&&(x=n)}const k=x-v||1,w=n.width/a,E=n.height/s;for(const[e,n]of b){const[r,o]=e.split("_"),i=+r,a=+o,c=(n-v)/k,u=`rgb(${Math.round(220-180*c)},${Math.round(220-100*c)},${Math.round(255-50*c)})`,h=m.get(e);l.push($t(i*w,(s-1-a)*E,w,E,u,{xi:i,yi:a,value:n,count:h.count,sum:h.sum,data:h.data},t.config.showValues?{value:n,showValues:!0,valueFormat:t.config.heatmapValueFormat}:void 0))}return l}(t,e,n);const r=[],o=vt(t.config.valueAccessor,"value"),i=xt(t.config.xAccessor,"x"),l=xt(t.config.yAccessor,"y"),a=new Set,s=new Set;for(const t of e)a.add(i(t)),s.add(l(t));const c=Array.from(a),u=Array.from(s),h=c.every(t=>"number"==typeof t&&!isNaN(t)),d=u.every(t=>"number"==typeof t&&!isNaN(t)),f=h?c.sort((t,e)=>t-e):c,y=d?u.sort((t,e)=>t-e):u;if(0===f.length||0===y.length)return r;const g=n.width/f.length,m=n.height/y.length,v=new Map;for(const t of e){const e=`${i(t)}\0${l(t)}`;v.set(e,{val:o(t),datum:t})}let x=1/0,b=-1/0;for(const{val:t}of v.values())isFinite(t)&&(x>t&&(x=t),t>b&&(b=t));if(!isFinite(x)||!isFinite(b))return r;const k=p(Wt["string"==typeof t.config.colorScheme?t.config.colorScheme:"blues"]||A).domain([x,b]);for(let e=0;f.length>e;e++)for(let n=0;y.length>n;n++){const o=v.get(`${f[e]}\0${y[n]}`);if(!o||!isFinite(o.val))continue;const i=k(o.val);r.push($t(e*g,(y.length-1-n)*m,g,m,i,o.datum,t.config.showValues?{value:o.val,showValues:!0,valueFormat:t.config.heatmapValueFormat}:void 0))}return r}(i,e,t);case"bar":{const t=function(t,e){var n;if(!t.config.binSize)return{nodes:[],binBoundaries:[]};const r=pt(e,t.getX,t.getY,t.config.binSize,t.getCategory);if(0===r.size)return{nodes:[],binBoundaries:[]};let o=null;if(t.getCategory){const e=new Set;for(const t of r.values())for(const n of t.categories.keys())e.add(n);const n=t.config.barColors?Object.keys(t.config.barColors):[],i=new Set(n),l=Array.from(e).filter(t=>!i.has(t)).sort(),a=n.filter(t=>e.has(t)),s=a.join("\0")+""+l.join("\0");t.barCategoryCache&&t.barCategoryCache.key===s?o=t.barCategoryCache.order:(o=[...a,...l],t.barCategoryCache={key:s,order:o})}const i=[],l=t.scales,[a,s]=l.x.domain();for(const e of r.values()){const r=Math.max(e.start,a),c=Math.min(e.end,s);if(r>=c)continue;const u=l.x(r),h=l.x(c),d=Math.abs(h-u),f=d>2?1:0,y=Math.min(u,h)+f/2,g=Math.max(d-f,1);if(g>0)if(o&&e.categories.size>0){let r=0;for(const a of o){const o=e.categories.get(a)||0;if(0===o)continue;const s=l.y(r),c=l.y(r+o);i.push(Ct(y,Math.min(s,c),g,Math.abs(s-c),{fill:(null===(n=t.config.barColors)||void 0===n?void 0:n[a])||"#4e79a7"},{binStart:e.start,binEnd:e.end,total:e.total,category:a,categoryValue:o},a)),r+=o}}else{const t=l.y(0),n=l.y(e.total);i.push(Ct(y,Math.min(t,n),g,Math.abs(t-n),{fill:"#007bff"},{binStart:e.start,binEnd:e.end,total:e.total}))}}const c=new Set;for(const t of r.values())c.add(t.start),c.add(t.end);return{nodes:i,binBoundaries:Array.from(c).sort((t,e)=>t-e)}}(i,e);return this._barCategoryCache=null!==(n=i.barCategoryCache)&&void 0!==n?n:null,this._binBoundaries=t.binBoundaries,t.nodes}case"swarm":return function(t,e){var n,r,o,i;const l=[],a=t.config.swarmStyle||{},s=null!==(n=a.radius)&&void 0!==n?n:3,c=null!==(r=a.fill)&&void 0!==r?r:"#007bff",u=null!==(o=a.opacity)&&void 0!==o?o:.7,h=a.stroke,d=a.strokeWidth;for(const n of e){const e=t.getX(n),r=t.getY(n);if(null==r||Number.isNaN(r))continue;const o=t.scales.x(e),a=t.scales.y(r);let f=c;if(t.getCategory){const e=t.getCategory(n);f=(null===(i=t.config.barColors)||void 0===i?void 0:i[e])||f}const y={type:"point",x:o,y:a,r:s,style:{fill:f,opacity:u,stroke:h,strokeWidth:d},datum:n};t.getPointId&&(y.pointId=t.getPointId(n)+""),l.push(y)}return l}(i,e);case"waterfall":return function(t,e,n){var r,o,i;const l=[],a=t.scales,s=t.config.waterfallStyle,c=e.filter(e=>{const n=t.getY(e),r=t.getX(e);return null!=n&&!Number.isNaN(n)&&null!=r&&isFinite(r)});if(0===c.length)return l;const u=null!==(r=null==s?void 0:s.positiveColor)&&void 0!==r?r:"#28a745",h=null!==(o=null==s?void 0:s.negativeColor)&&void 0!==o?o:"#dc3545",d=null!==(i=null==s?void 0:s.gap)&&void 0!==i?i:1,f=null==s?void 0:s.stroke,y=null==s?void 0:s.strokeWidth;let g=0;for(let e=0;c.length>e;e++){const r=c[e],o=t.getX(r),i=t.getY(r),p=g+i;let m;m=c.length-1>e?t.getX(c[e+1])-o:e>0?o-t.getX(c[e-1]):0;const v=a.x(o),x=0!==m?a.x(o+m):v+n.width/10,b=Math.min(v,x)+d/2,k=Math.max(v,x)-d/2-b;if(0>=k){g=p;continue}const w=a.y(g),E=a.y(p);l.push(Ct(b,Math.min(w,E),k,Math.abs(w-E),{fill:0>i?h:u,stroke:f,strokeWidth:y},Object.assign(Object.assign({},r),{baseline:g,cumEnd:p,delta:i,_connectorStroke:null==s?void 0:s.connectorStroke,_connectorWidth:null==s?void 0:s.connectorWidth}))),g=p}return l}(i,e,t);case"candlestick":return function(t,e){if(!(t.getOpen&&t.getHigh&&t.getLow&&t.getClose&&t.scales))return[];const n=[],r=t.config.candlestickStyle||{},o=r.upColor||"#28a745",i=r.downColor||"#dc3545",l=r.wickColor||"#333",a=r.wickWidth||1,s=e.map(e=>t.getX(e)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let c=r.bodyWidth||6;if(!r.bodyWidth&&s.length>1){let e=1/0;for(let n=1;s.length>n;n++){const r=Math.abs(t.scales.x(s[n])-t.scales.x(s[n-1]));r>0&&e>r&&(e=r)}e!==1/0&&(c=Math.max(2,Math.min(.6*e,20)))}for(const r of e){const e=t.getX(r);if(null==e||Number.isNaN(e))continue;const s=t.getOpen(r),u=t.getHigh(r),h=t.getLow(r),d=t.getClose(r);if([s,u,h,d].some(t=>null==t||Number.isNaN(t)))continue;const f=d>=s;n.push({type:"candlestick",x:t.scales.x(e),openY:t.scales.y(s),closeY:t.scales.y(d),highY:t.scales.y(u),lowY:t.scales.y(h),bodyWidth:c,upColor:o,downColor:i,wickColor:l,wickWidth:a,isUp:f,datum:r})}return n}(i,e);default:return[]}}resolveBoundsStyle(t,e){const n=this.config.boundsStyle;return"function"==typeof n?n(e||{},t):n&&"object"==typeof n?n:{fill:this.resolveLineStyle(t,e).stroke||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(t,e){const n=this.config.decay;return n&&e>1?Et(n,t,e):1}applyDecay(t,e){this.config.decay&&function(t,e,n){var r,o;const i=n.length;if(1>=i)return;const l=new Map;for(let t=0;n.length>t;t++)l.set(n[t],t);for(const n of e){if("line"===n.type){const e=Array.isArray(n.datum)?n.datum:[];if(2>e.length)continue;const r=Array(e.length);let o=!1;for(let n=0;e.length>n;n++){const a=l.get(e[n]);null!=a?(r[n]=Et(t,a,i),1>r[n]&&(o=!0)):r[n]=1}o&&(n._decayOpacities=r);continue}if("area"===n.type){const e=Array.isArray(n.datum)?n.datum:[],r=n.topPath?n.topPath.length:e.length;if(2>r)continue;if(e.length===r){const o=Array(r);let a=!1;for(let n=0;e.length>n;n++){const r=l.get(e[n]);null!=r?(o[n]=Et(t,r,i),1>o[n]&&(a=!0)):o[n]=1}a&&(n._decayOpacities=o)}else{let o=1;for(const n of e){const e=l.get(n);if(null!=e){const n=Et(t,e,i);o>n&&(o=n)}}if(1>o){const t=Array(r);t.fill(o),n._decayOpacities=t}}continue}const e=l.get(n.datum);if(null==e)continue;const a=Et(t,e,i);if("heatcell"===n.type)n.style={opacity:a};else if("candlestick"===n.type)n._decayOpacity=a;else{const t=null!==(o=null===(r=n.style)||void 0===r?void 0:r.opacity)&&void 0!==o?o:1;n.style=Object.assign(Object.assign({},n.style),{opacity:t*a})}}}(this.config.decay,t,e)}applyPulse(t,e){this.config.pulse&&this.timestampBuffer&&function(t,e,n,r){var o,i;const l="undefined"!=typeof performance?performance.now():Date.now(),a=null!==(o=t.color)&&void 0!==o?o:"rgba(255,255,255,0.6)",s=null!==(i=t.glowRadius)&&void 0!==i?i:4,c=new Map;for(let t=0;n.length>t;t++)c.set(n[t],t);for(const n of e){if("line"===n.type)continue;if("area"===n.type){const e=Array.isArray(n.datum)?n.datum:[n.datum];let o=0;for(const n of e){const e=c.get(n);if(null==e)continue;const i=r.get(e);if(null==i)continue;const a=At(t,i,l);a>o&&(o=a)}o>0&&(n._pulseIntensity=o,n._pulseColor=a);continue}const e=c.get(n.datum);if(null==e)continue;const o=r.get(e);if(null==o)continue;const i=At(t,o,l);i>0&&(n._pulseIntensity=i,n._pulseColor=a,n._pulseGlowRadius=s)}}(this.config.pulse,t,e,this.timestampBuffer)}get hasActivePulses(){return!!this.config.pulse&&function(t,e){var n;if(!e||0===e.size)return!1;const r="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(n=t.duration)&&void 0!==n?n:500,i=e.peek();return null!=i&&o>r-i}(this.config.pulse,this.timestampBuffer)}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(t,e,n,r){var o,i,l;n.clear(),r.clear();for(let a=0;e.length>a;a++){const s=e[a],c=Pt(t,s,a);c&&("point"===s.type?n.set(c,{x:s.x,y:s.y,r:s.r,opacity:s.style.opacity}):"rect"===s.type?n.set(c,{x:s.x,y:s.y,w:s.w,h:s.h,opacity:s.style.opacity}):"heatcell"===s.type?n.set(c,{x:s.x,y:s.y,w:s.w,h:s.h,opacity:null===(o=s.style)||void 0===o?void 0:o.opacity}):"candlestick"===s.type?n.set(c,{x:s.x,y:s.openY}):"line"===s.type?r.set(c,{path:s.path.map(t=>[t[0],t[1]]),opacity:null===(i=s.style)||void 0===i?void 0:i.opacity}):"area"===s.type&&r.set(c,{topPath:s.topPath.map(t=>[t[0],t[1]]),bottomPath:s.bottomPath.map(t=>[t[0],t[1]]),opacity:null===(l=s.style)||void 0===l?void 0:l.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}startTransition(){if(!this.config.transition)return;const t=function(t,e,n,r,o){var i,l,a,s,c,u,h,d,f,y,g,p,m,v,x,b,k,w,E,A,M,S,_,P,D,T,L,C;if(0===r.size&&0===o.size)return n;const $=null!==(i=e.duration)&&void 0!==i?i:300;if(n.exitNodes.length>0){const t=new Set(n.exitNodes);n.scene=n.scene.filter(e=>!t.has(e)),n.exitNodes=[]}let N=!1;const O=new Set,W=new Set;for(let e=0;n.scene.length>e;e++){const i=n.scene[e],E=Pt(t,i,e);if(!E)continue;if(i._transitionKey=E,"line"===i.type||"area"===i.type){const t=o.get(E);if(t){if(W.add(E),"line"===i.type&&t.path&&t.path.length===i.path.length){i._targetPath=i.path.map(t=>[t[0],t[1]]),i._prevPath=t.path;for(let e=0;i.path.length>e;e++)i.path[e]=[t.path[e][0],t.path[e][1]];N=!0}else if("area"===i.type&&t.topPath&&t.bottomPath&&t.topPath.length===i.topPath.length&&t.bottomPath.length===i.bottomPath.length){i._targetTopPath=i.topPath.map(t=>[t[0],t[1]]),i._targetBottomPath=i.bottomPath.map(t=>[t[0],t[1]]),i._prevTopPath=t.topPath,i._prevBottomPath=t.bottomPath;for(let e=0;i.topPath.length>e;e++)i.topPath[e]=[t.topPath[e][0],t.topPath[e][1]];for(let e=0;i.bottomPath.length>e;e++)i.bottomPath[e]=[t.bottomPath[e][0],t.bottomPath[e][1]];N=!0}i._targetOpacity=null!==(l=i.style.opacity)&&void 0!==l?l:1,i._startOpacity=null!==(s=null!==(a=t.opacity)&&void 0!==a?a:i.style.opacity)&&void 0!==s?s:1}else i._targetOpacity=null!==(c=i.style.opacity)&&void 0!==c?c:1,i._startOpacity=0,i.style=Object.assign(Object.assign({},i.style),{opacity:0}),N=!0;continue}const A=r.get(E);if("point"===i.type)if(A){O.add(E);const t={x:i.x,y:i.y,r:i.r};i._targetOpacity=null!==(u=i.style.opacity)&&void 0!==u?u:1,A.x===t.x&&A.y===t.y&&A.r===t.r||(i._targetX=t.x,i._targetY=t.y,i._targetR=t.r,i.x=A.x,i.y=A.y,i.r=null!==(h=A.r)&&void 0!==h?h:i.r,N=!0)}else i._targetOpacity=null!==(d=i.style.opacity)&&void 0!==d?d:1,i.style=Object.assign(Object.assign({},i.style),{opacity:0}),N=!0;else if("rect"===i.type)if(A){O.add(E);const t={x:i.x,y:i.y,w:i.w,h:i.h};i._targetOpacity=null!==(f=i.style.opacity)&&void 0!==f?f:1,A.x===t.x&&A.y===t.y&&A.w===t.w&&A.h===t.h||(i._targetX=t.x,i._targetY=t.y,i._targetW=t.w,i._targetH=t.h,i.x=A.x,i.y=A.y,i.w=null!==(y=A.w)&&void 0!==y?y:i.w,i.h=null!==(g=A.h)&&void 0!==g?g:i.h,N=!0)}else i._targetOpacity=null!==(p=i.style.opacity)&&void 0!==p?p:1,i.style=Object.assign(Object.assign({},i.style),{opacity:0}),N=!0;else if("heatcell"===i.type)if(A){O.add(E);const t={x:i.x,y:i.y,w:i.w,h:i.h};i._targetOpacity=null!==(v=null===(m=i.style)||void 0===m?void 0:m.opacity)&&void 0!==v?v:1,A.x===t.x&&A.y===t.y&&A.w===t.w&&A.h===t.h||(i._targetX=t.x,i._targetY=t.y,i._targetW=t.w,i._targetH=t.h,i.x=A.x,i.y=A.y,i.w=null!==(x=A.w)&&void 0!==x?x:i.w,i.h=null!==(b=A.h)&&void 0!==b?b:i.h,N=!0)}else i._targetOpacity=null!==(w=null===(k=i.style)||void 0===k?void 0:k.opacity)&&void 0!==w?w:1,i.style=Object.assign(Object.assign({},i.style||{}),{opacity:0}),N=!0}for(const[t,e]of o)if(!W.has(t))if(t.startsWith("l:")&&e.path){const r={type:"line",path:e.path.map(t=>[t[0],t[1]]),group:t.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:null!==(E=e.opacity)&&void 0!==E?E:1},_targetOpacity:0,_transitionKey:t,datum:null};n.exitNodes.push(r),N=!0}else if(t.startsWith("a:")&&e.topPath&&e.bottomPath){const r={type:"area",topPath:e.topPath.map(t=>[t[0],t[1]]),bottomPath:e.bottomPath.map(t=>[t[0],t[1]]),group:t.slice(2),style:{fill:"#999",opacity:null!==(A=e.opacity)&&void 0!==A?A:1},_targetOpacity:0,_transitionKey:t,datum:null};n.exitNodes.push(r),N=!0}for(const[t,e]of r)if(!O.has(t)){if(t.startsWith("p:")){const r={type:"point",x:e.x,y:e.y,r:null!==(M=e.r)&&void 0!==M?M:3,style:{opacity:null!==(S=e.opacity)&&void 0!==S?S:1},datum:null,_targetOpacity:0,_transitionKey:t};n.exitNodes.push(r)}else if(t.startsWith("r:")){const r={type:"rect",x:e.x,y:e.y,w:null!==(_=e.w)&&void 0!==_?_:0,h:null!==(P=e.h)&&void 0!==P?P:0,style:{opacity:null!==(D=e.opacity)&&void 0!==D?D:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t};n.exitNodes.push(r)}else if(t.startsWith("h:")){const r={type:"heatcell",x:e.x,y:e.y,w:null!==(T=e.w)&&void 0!==T?T:0,h:null!==(L=e.h)&&void 0!==L?L:0,fill:"#999",datum:null,style:{opacity:null!==(C=e.opacity)&&void 0!==C?C:1},_targetOpacity:0,_transitionKey:t};n.exitNodes.push(r)}N=!0}return n.exitNodes.length>0&&(n.scene=[...n.scene,...n.exitNodes]),N&&(n.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:$}),n}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap);this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition}advanceTransition(t){if(!this.activeTransition||!this.config.transition)return!1;const e={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},n=function(t,e,n,r){var o,i,l,a,s;if(!n.activeTransition)return!1;const c=St(t,n.activeTransition),u=Mt(c,"linear"===e.easing?"linear":"ease-out-cubic");for(const t of n.scene){const e=t._transitionKey;if("point"===t.type){if(void 0!==t._targetOpacity){const n=e?r.get(e):void 0,i=n?null!==(o=n.opacity)&&void 0!==o?o:1:0;t.style.opacity=_t(i,t._targetOpacity,u)}if(void 0===t._targetX)continue;if(!e)continue;const n=r.get(e);if(!n)continue;t.x=_t(n.x,t._targetX,u),t.y=_t(n.y,t._targetY,u),void 0!==t._targetR&&void 0!==n.r&&(t.r=_t(n.r,t._targetR,u))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const n=e?r.get(e):void 0,o=n?null!==(i=n.opacity)&&void 0!==i?i:1:0;t.style.opacity=_t(o,t._targetOpacity,u)}if(void 0===t._targetX)continue;if(!e)continue;const n=r.get(e);if(!n)continue;t.x=_t(n.x,t._targetX,u),t.y=_t(n.y,t._targetY,u),void 0!==n.w&&(t.w=_t(n.w,t._targetW,u)),void 0!==n.h&&(t.h=_t(n.h,t._targetH,u))}else if("heatcell"===t.type){if(void 0!==t._targetOpacity){const n=e?r.get(e):void 0,o=n?null!==(l=n.opacity)&&void 0!==l?l:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:_t(o,t._targetOpacity,u)})}if(void 0===t._targetX)continue;if(!e)continue;const n=r.get(e);if(!n)continue;t.x=_t(n.x,t._targetX,u),t.y=_t(n.y,t._targetY,u),void 0!==n.w&&(t.w=_t(n.w,t._targetW,u)),void 0!==n.h&&(t.h=_t(n.h,t._targetH,u))}else if("line"===t.type){if(void 0!==t._targetOpacity){const e=null!==(a=t._startOpacity)&&void 0!==a?a:0;t.style=Object.assign(Object.assign({},t.style),{opacity:_t(e,t._targetOpacity,u)})}const e=t._prevPath,n=t._targetPath;if(e&&n&&e.length===t.path.length)for(let r=0;t.path.length>r;r++)t.path[r][0]=_t(e[r][0],n[r][0],u),t.path[r][1]=_t(e[r][1],n[r][1],u)}else if("area"===t.type){if(void 0!==t._targetOpacity){const e=null!==(s=t._startOpacity)&&void 0!==s?s:0;t.style=Object.assign(Object.assign({},t.style),{opacity:_t(e,t._targetOpacity,u)})}const e=t._prevTopPath,n=t._prevBottomPath,r=t._targetTopPath,o=t._targetBottomPath;if(e&&r&&e.length===t.topPath.length)for(let n=0;t.topPath.length>n;n++)t.topPath[n][0]=_t(e[n][0],r[n][0],u),t.topPath[n][1]=_t(e[n][1],r[n][1],u);if(n&&o&&n.length===t.bottomPath.length)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e][0]=_t(n[e][0],o[e][0],u),t.bottomPath[e][1]=_t(n[e][1],o[e][1],u)}}if(c>=1){for(const t of n.scene){if(void 0!==t._targetOpacity){const e=t._targetOpacity;t.style=Object.assign(Object.assign({},"line"===t.type||"area"===t.type?t.style:t.style||{}),{opacity:0===e?0:e}),t._targetOpacity=void 0}if("point"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("rect"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("heatcell"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("line"===t.type){const e=t._targetPath;if(e)for(let n=0;t.path.length>n;n++)t.path[n]=e[n];t._prevPath=void 0,t._targetPath=void 0}else if("area"===t.type){const e=t._targetTopPath,n=t._targetBottomPath;if(e)for(let n=0;t.topPath.length>n;n++)t.topPath[n]=e[n];if(n)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e]=n[e];t._prevTopPath=void 0,t._prevBottomPath=void 0,t._targetTopPath=void 0,t._targetBottomPath=void 0}}if(n.exitNodes.length>0){const t=new Set(n.exitNodes);n.scene=n.scene.filter(e=>!t.has(e)),n.exitNodes=[]}return n.activeTransition=null,!1}return!0}(t,this.config.transition,e,this.prevPositionMap);return this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition,n}groupData(t){if(!this.getGroup)return[{key:"_default",data:t}];const e=new Map;for(const n of t){const t=this.getGroup(n);e.has(t)||e.set(t,[]),e.get(t).push(n)}return Array.from(e.entries()).map(([t,e])=>({key:t,data:e}))}resolveColorMap(t){const e=new Set;for(const n of t){const t=this.getColor(n);t&&e.add(t)}const n=Array.from(e).sort(),r=n.join("\0");if(this._colorMapCache&&this._colorMapCache.key===r)return this._colorMapCache.map;const o=Array.isArray(this.config.colorScheme)?this.config.colorScheme:wt,i=new Map;for(let t=0;n.length>t;t++)i.set(n[t],o[t%o.length]);return this._colorMapCache={key:r,map:i},i}resolveLineStyle(t,e){const n=this.config.lineStyle;if("function"==typeof n){const r=n(e||{},t);if(r&&!r.stroke&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},r),{stroke:e})}return r}return 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(t,e){var n;if(this.config.areaStyle){const n=this.config.areaStyle(e||{});if(n&&!n.fill&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},n),{fill:e,stroke:n.stroke||e})}return n}const r=this.config.lineStyle;if("function"==typeof r){const n=r(e||{},t);if(n&&!n.fill&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},n),{fill:e,stroke:n.stroke||e})}return n}return r&&"object"==typeof r?{fill:r.fill||r.stroke||"#4e79a7",fillOpacity:null!==(n=r.fillOpacity)&&void 0!==n?n:.7,stroke:r.stroke||"#4e79a7",strokeWidth:r.strokeWidth||2}:{fill:"#4e79a7",fillOpacity:.7,stroke:"#4e79a7",strokeWidth:2}}resolveGroupColor(t){if(this._colorMapCache){const e=this._colorMapCache.map.get(t);if(e)return e}const e=this._groupColorMap.get(t);if(e)return e;const n=Array.isArray(this.config.colorScheme)?this.config.colorScheme:wt,r=n[this._groupColorMap.size%n.length];return this._groupColorMap.set(t,r),r}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}getBinBoundaries(){return this._binBoundaries}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.prevPathMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this.needsFullRebuild=!0,this._bufferDirty=!0,this._bufferArrayCache=null,this.lastLayout=null,this.scales=null,this.scene=[],this._quadtree=null,this._colorMapCache=null,this._groupColorMap=new Map,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this.version++}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}updateConfig(t){var e,n,r,o;const i=Object.assign({},this.config);void 0!==t.colorScheme&&(this._colorMapCache=null,this._groupColorMap=new Map),void 0===t.barColors&&void 0===t.colorScheme||(this._barCategoryCache=null),void 0===t.normalize&&void 0===t.extentPadding&&void 0===t.xAccessor&&void 0===t.yAccessor&&void 0===t.groupAccessor&&void 0===t.categoryAccessor&&void 0===t.chartType||(this._stackExtentCache=null);let l=!1;Object.assign(this.config,t);const a="chartType"in t&&t.chartType!==i.chartType||"runtimeMode"in t&&t.runtimeMode!==i.runtimeMode;if(a||void 0!==t.xAccessor||void 0!==t.yAccessor||void 0!==t.timeAccessor||void 0!==t.valueAccessor){const s=a||!mt(null!==(e=t.xAccessor)&&void 0!==e?e:t.timeAccessor,null!==(n=i.xAccessor)&&void 0!==n?n:i.timeAccessor),c=a||!mt(null!==(r=t.yAccessor)&&void 0!==r?r:t.valueAccessor,null!==(o=i.yAccessor)&&void 0!==o?o:i.valueAccessor);(s||c)&&(["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?(this.getX=vt(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=vt(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=vt(this.config.xAccessor,"x"),this.getY=vt(this.config.yAccessor,"y")),l=!0)}if("groupAccessor"in t&&!mt(t.groupAccessor,i.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?bt(this.config.groupAccessor):void 0,l=!0),"categoryAccessor"in t&&!mt(t.categoryAccessor,i.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?bt(this.config.categoryAccessor):void 0,l=!0),"sizeAccessor"in t&&!mt(t.sizeAccessor,i.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?vt(this.config.sizeAccessor,"size"):void 0,l=!0),"colorAccessor"in t&&!mt(t.colorAccessor,i.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?bt(this.config.colorAccessor):void 0,l=!0),"y0Accessor"in t&&!mt(t.y0Accessor,i.y0Accessor)&&(this.getY0=this.config.y0Accessor?vt(this.config.y0Accessor,"y0"):void 0,l=!0),"pointIdAccessor"in t&&!mt(t.pointIdAccessor,i.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?bt(this.config.pointIdAccessor):void 0,l=!0),!l){const e=Object.keys(t).filter(t=>!t.endsWith("Accessor")&&"timeAccessor"!==t&&"valueAccessor"!==t);for(const n of e)if(t[n]!==i[n]){l=!0;break}}l&&(this.needsFullRebuild=!0)}}function zt(t,e,n){return n.x>t||t>n.x+n.w||n.y>e||e>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 Bt(t){let e=t%(2*Math.PI);return 0>e&&(e+=2*Math.PI),e}function jt(t,e,n){const r=e-t.x,o=n-t.y,i=Math.sqrt(r*r+o*o);return i>Math.max(t.r+5,12)?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:i}}function Ft(t,e,n){var r,o,i,l;if(0===t.path.length)return null;const a=Vt(t.path,e);if(0>a)return null;const[s,c]=t.path[a];let u;if(t.path.length>1){let r=1/0;const o=Math.max(0,a-1),i=Math.min(t.path.length-2,a);for(let l=o;i>=l;l++){const[o,i]=t.path[l],[a,s]=t.path[l+1],c=Rt(e,n,o,i,a,s);r>c&&(r=c)}u=r}else{const t=e-s,r=n-c;u=Math.sqrt(t*t+r*r)}const h=null!==(l=null!==(o=null===(r=t.style)||void 0===r?void 0:r.strokeWidth)&&void 0!==o?o:null===(i=t.style)||void 0===i?void 0:i.lineWidth)&&void 0!==l?l:1;return u>Math.max(5,h/2+2)?null:{node:t,datum:Array.isArray(t.datum)&&t.datum[a]?t.datum[a]:t.datum,x:s,y:c,distance:u}}function Rt(t,e,n,r,o,i){const l=o-n,a=i-r,s=l*l+a*a;if(0===s)return Math.sqrt(Math.pow(t-n,2)+Math.pow(e-r,2));let c=((t-n)*l+(e-r)*a)/s;c=Math.max(0,Math.min(1,c));const u=r+c*a;return Math.sqrt(Math.pow(t-(n+c*l),2)+Math.pow(e-u,2))}function Yt(t,e,n){const r=zt(e,n,t);return r.hit?{node:t,datum:t.datum,x:r.cx,y:r.cy,distance:0}:null}function Ht(t,e,n){const r=zt(e,n,t);return r.hit?{node:t,datum:t.datum,x:r.cx,y:r.cy,distance:0}:null}function Xt(t,e,n){const r=t.bodyWidth/2,o=Math.min(t.openY,t.closeY);if(!(t.x-r-3>e||e>t.x+r+3||t.highY-3>n||n>t.lowY+3)){const r=o+Math.max(Math.max(t.openY,t.closeY)-o,1)/2,i=e-t.x,l=n-r;return{node:t,datum:t.datum,x:t.x,y:r,distance:Math.sqrt(i*i+l*l)}}return null}function Gt(t,e,n){if(0===t.topPath.length)return null;const r=Vt(t.topPath,e);if(0>r)return null;const[o,i]=t.topPath[r],l=e-o,a=n-i,s=Math.sqrt(l*l+a*a);return{node:t,datum:Array.isArray(t.datum)&&t.datum[r]?t.datum[r]:t.datum,x:o,y:i,distance:s}}function Vt(t,e){if(0===t.length)return-1;let n=0,r=t.length-1;for(;r>n;){const o=n+r>>1;e>t[o][0]?n=o+1:r=o}return n>0&&Math.abs(t[n][0]-e)>=Math.abs(t[n-1][0]-e)?n-1:n}function qt(t){var e,n;const r=new Map;for(const n of t){const t=null!==(e=n.group)&&void 0!==e?e:"_default";let o=r.get(t);o||(o=[],r.set(t,o)),o.push(n)}for(const t of r.values()){t.sort((t,e)=>t.x-e.x||t.y-e.y);for(let e=0;t.length>e;e++)t[e]._groupIndex=e}const o=Array.from(r.keys()).sort((t,e)=>{const n=r.get(t),o=r.get(e);return(n.length>0?n[0].y:0)-(o.length>0?o[0].y:0)}),i=Array.from(r.values()).flat();i.sort((t,e)=>t.x-e.x||t.y-e.y);const l=new Map;for(let t=0;i.length>t;t++){i[t]._flatIndex=t;const e=null===(n=i[t].datum)||void 0===n?void 0:n.id;null!=e&&l.set(e+"",t)}return{flat:i,groups:o,byGroup:r,idToIdx:l}}function Ut(t,e){var n,r;if(0===t.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const o=Math.max(0,Math.min(e,t.flat.length-1)),i=t.flat[o];return{flatIndex:o,group:null!==(n=i.group)&&void 0!==n?n:"_default",indexInGroup:null!==(r=i._groupIndex)&&void 0!==r?r:0}}function Kt(t,e,n){const{group:r,indexInGroup:o}=e,i=n.byGroup.get(r);switch(t){case"ArrowRight":return i.length-1>o?i[o+1]._flatIndex:e.flatIndex;case"ArrowLeft":return o>0?i[o-1]._flatIndex:e.flatIndex;case"ArrowDown":{const t=n.groups.indexOf(r);return n.groups.length-1>t?Zt(n,n.groups[t+1],i[o]):e.flatIndex}case"ArrowUp":{const t=n.groups.indexOf(r);return t>0?Zt(n,n.groups[t-1],i[o]):e.flatIndex}case"PageDown":return Math.min(e.flatIndex+Math.max(1,Math.floor(.1*n.flat.length)),n.flat.length-1);case"PageUp":return Math.max(e.flatIndex-Math.max(1,Math.floor(.1*n.flat.length)),0);case"Home":return 0;case"End":return n.flat.length-1;case"Escape":return-1;default:return null}}function Zt(t,e,n){const r=t.byGroup.get(e);let o=0,i=Math.abs(r[0].x-n.x);for(let t=1;r.length>t;t++){const e=Math.abs(r[t].x-n.x);i>e&&(i=e,o=t)}return r[o]._flatIndex}function Qt(t){const e=t.datum||{};return Object.assign(Object.assign({},"object"!=typeof e||null===e||Array.isArray(e)?{}:e),{data:e,x:t.x,y:t.y,time:t.x,value:t.y})}function Jt(t,n,i){const l=e(null),[a,s]=o(null);return r(()=>{if(!n&&!i)return;const t=l.current;if(!t)return;const e=new ResizeObserver(t=>{for(const e of t){const{width:t,height:n}=e.contentRect;s(e=>e&&e.w===t&&e.h===n?e:{w:t,h:n})}});return e.observe(t),()=>e.disconnect()},[n,i]),[l,[n&&a?a.w:t[0],i&&a?a.h:t[1]]]}function te(t,e,n,o,i,l){r(()=>{if(!t)return;const r=setInterval(()=>{var r;const a=e.current;if(!a||0===a.lastIngestTime)return;const s="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(r=t.threshold)&&void 0!==r?r:5e3,u=s-a.lastIngestTime>c;u!==i&&(l(u),n.current=!0,o())},1e3);return()=>clearInterval(r)},[t,i,o])}It.QUADTREE_THRESHOLD=500;const ee={fill:e=>t.createElement("rect",{style:e,width:16,height:16}),line:e=>t.createElement("line",{style:e,x1:0,y1:0,x2:16,y2:16})};function ne(t,e,n,r){let o;return o="function"==typeof n?n(t):(0,ee[n])(r(t,e)),o}function re(){return t.createElement("path",{d:"M4,8.8 L7.2,12 L12.8,4.8",fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function oe(t,e,n){return n&&n.size>0?n.has(t.label)?1:.3:null!=e?t.label===e?1:.3:1}function ie({config:e,orientation:n="vertical",width:r=100}){const{colorFn:o,domain:i,label:l,format:a}=e,s=a||(t=>Math.round(100*t)/100+""),c="grad-legend-"+t.useId();if("horizontal"===n){const e=12,n=Math.min(r,200),a=Math.max(0,(r-n)/2),u=[];for(let e=0;64>=e;e++){const n=e/64;u.push(t.createElement("stop",{key:e,offset:100*n+"%",stopColor:o(i[0]+n*(i[1]-i[0]))}))}return t.createElement("g",{"aria-label":l||"Gradient legend"},t.createElement("defs",null,t.createElement("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"100%",y2:"0%"},u)),l&&t.createElement("text",{x:a+n/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},l),t.createElement("rect",{x:a,y:0,width:n,height:e,fill:`url(#${c})`,rx:2}),t.createElement("text",{x:a,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(i[0])),t.createElement("text",{x:a+n,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(i[1])))}const u=[];for(let e=0;64>=e;e++){const n=e/64;u.push(t.createElement("stop",{key:e,offset:100*n+"%",stopColor:o(i[1]-n*(i[1]-i[0]))}))}return t.createElement("g",{"aria-label":l||"Gradient legend"},l&&t.createElement("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},l),t.createElement("defs",null,t.createElement("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"0%",y2:"100%"},u)),t.createElement("rect",{x:0,y:0,width:14,height:100,fill:`url(#${c})`,rx:2}),t.createElement("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(i[1])),t.createElement("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(i[0])))}function le(e){const{legendGroups:n,customClickBehavior:r,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:l,legendInteraction:a,title:s="Legend",width:c=100,height:u=20,orientation:h="vertical"}=e,[d,f]=t.useState(0),[y,g]=t.useState(0),p=t.useCallback((t,e)=>{f(t),g(e)},[]),m="vertical"===h?(({legendGroups:e,width:n,customClickBehavior:r,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:l,focusedGroupIndex:a,focusedItemIndex:s,onFocusedIndexChange:c,legendInteraction:u})=>{let h=24;const d=[];return e.forEach((e,f)=>{h+=5,d.push(t.createElement("line",{key:"legend-top-line legend-symbol-"+f,stroke:"gray",x1:0,y1:h,x2:n,y2:h})),h+=8,e.label&&(h+=16,d.push(t.createElement("text",{key:"legend-text-"+f,y:h,className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label)),h+=8),d.push(t.createElement("g",{key:"legend-group-"+f,className:"legend-item",transform:`translate(0,${h})`},((e,n,r,o,i,l,a,s,c,u)=>{const{type:h="fill",styleFn:d,items:f}=e,y=[];let g=0;const p=!(!n&&!r),m="isolate"===u||void 0===u&&null!=i;return f.forEach((e,u)=>{const v=ne(e,u,h,d),x=oe(e,o,i),b=i&&i.size>0&&i.has(e.label);y.push(t.createElement("g",{key:"legend-item-"+u,transform:`translate(0,${g})`,onClick:n?()=>n(e):void 0,onMouseEnter:r?()=>r(e):void 0,onMouseLeave:r?()=>r(null):void 0,tabIndex:p?s===l&&u===a?0:-1:void 0,role:p?"option":void 0,"aria-selected":p&&m?b||!1:void 0,"aria-current":p&&!m&&null!=o&&e.label===o||void 0,"aria-label":e.label,onKeyDown:p?t=>{var r;if("Enter"!==t.key&&" "!==t.key||(t.preventDefault(),n&&n(e)),"ArrowDown"===t.key||"ArrowUp"===t.key){t.preventDefault();const e=(u+("ArrowDown"===t.key?1:-1)+f.length)%f.length;c(s,e);const n=null===(r=t.currentTarget.parentElement)||void 0===r?void 0:r.children[e];n instanceof SVGElement&&n.focus()}}:void 0,onFocus:p?t=>{c(s,u),r&&r(e);const n=t.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:p?t=>{r&&r(null);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","hidden")}:void 0,style:{cursor:p?"pointer":"default",opacity:x,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},p&&t.createElement("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*e.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),v,b&&t.createElement(re,null),t.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label))),g+=22}),y})(e,r,o,i,l,a,s,f,c,u))),h+=22*e.items.length+8}),d})({legendGroups:n||[],width:c,customClickBehavior:r,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:l,focusedGroupIndex:d,focusedItemIndex:y,onFocusedIndexChange:p,legendInteraction:a}):(({legendGroups:e,height:n,width:r,customClickBehavior:o,customHoverBehavior:i,highlightedCategory:l,isolatedCategories:a,focusedGroupIndex:s,focusedItemIndex:c,onFocusedIndexChange:u,legendInteraction:h})=>{let d=0;const f=[];e.forEach((e,n)=>{let y=0;e.label&&(y+=16);const g=((e,n,r,o,i,l,a,s,c,u,h)=>{const{type:d="fill",styleFn:f,items:y}=e,g=[];let p=0,m=0;const v=!(!n&&!r),x="isolate"===u||void 0===u&&null!=i;y.forEach((e,u)=>{const b=ne(e,u,d,f),k=oe(e,o,i),w=i&&i.size>0&&i.has(e.label),E=26+7*e.label.length;h&&h>0&&p>0&&p+E>h&&(m++,p=0),g.push(t.createElement("g",{key:"legend-item-"+u,transform:`translate(${p},${22*m})`,onClick:n?()=>n(e):void 0,onMouseEnter:r?()=>r(e):void 0,onMouseLeave:r?()=>r(null):void 0,tabIndex:v?s===l&&u===a?0:-1:void 0,role:v?"option":void 0,"aria-selected":v&&x?w||!1:void 0,"aria-current":v&&!x&&null!=o&&e.label===o||void 0,"aria-label":e.label,onKeyDown:v?t=>{var r;if("Enter"!==t.key&&" "!==t.key||(t.preventDefault(),n&&n(e)),"ArrowRight"===t.key||"ArrowLeft"===t.key){t.preventDefault();const e=(u+("ArrowRight"===t.key?1:-1)+y.length)%y.length;c(s,e);const n=null===(r=t.currentTarget.parentElement)||void 0===r?void 0:r.children[e];n instanceof SVGElement&&n.focus()}}:void 0,onFocus:v?t=>{c(s,u),r&&r(e);const n=t.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:v?t=>{r&&r(null);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","hidden")}:void 0,style:{cursor:v?"pointer":"default",opacity:k,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},v&&t.createElement("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*e.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),b,w&&t.createElement(re,null),t.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label))),p+=E});let b=0,k=0;for(const t of y){const e=26+7*t.label.length;h&&h>0&&k>0&&k+e>h?(b=Math.max(b,k),k=e):k+=e}b=Math.max(b,k);const w=m+1;return{items:g,offset:b,totalRows:w,totalHeight:22*w}})(e,o,i,l,a,s,c,n,u,h,r);y+=g.offset+5,f.push(Object.assign(Object.assign({label:e.label},g),{offset:y,totalRows:g.totalRows,totalHeight:g.totalHeight})),d+=y+12});let y=d>r?0:Math.max(0,(r-d)/2);const g=[];return f.forEach((r,o)=>{const i=e[o];i.label&&(g.push(t.createElement("text",{key:"legend-text-"+o,transform:`translate(${y},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},i.label)),y+=16),g.push(t.createElement("g",{key:"legend-group-"+o,className:"legend-item",transform:`translate(${y},0)`},r.items)),y+=r.offset+5,e[o+1]&&g.push(t.createElement("line",{key:"legend-top-line legend-symbol-"+o,stroke:"gray",x1:y,y1:-8,x2:y,y2:(r.totalHeight||n)+0+8})),y+=12}),t.createElement("g",null,g)})({legendGroups:n||[],title:s,height:u,width:c,customClickBehavior:r,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:l,focusedGroupIndex:d,focusedItemIndex:y,onFocusedIndexChange:p,legendInteraction:a}),v=!(!r&&!o);return t.createElement("g",{role:v?"listbox":void 0,"aria-multiselectable":!(!v||"isolate"!==a&&(void 0!==a||null==l))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"}},void 0!==s&&""!==s&&"vertical"===h&&t.createElement("text",{className:"legend-title",y:16,x:c/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)"},s),m)}function ae(e){const{legend:n,totalWidth:r,totalHeight:o,margin:i,legendPosition:l="right",title:a,legendHoverBehavior:s,legendClickBehavior:c,legendHighlightedCategory:u,legendIsolatedCategories:h,legendInteraction:d}=e;if(!n)return null;const f="top"===l||"bottom"===l;let y,g;return"left"===l?(y=4,g=i.top):"top"===l?(y=0,g=a?32:8):"bottom"===l?(y=0,g=o-i.bottom+50):(y=r-i.right+10,g=i.top),t.createElement("g",{transform:`translate(${y}, ${g})`},function(t){return"object"==typeof t&&null!==t&&"gradient"in t}(n)?t.createElement(ie,{config:n.gradient,orientation:f?"horizontal":"vertical",width:f?r:100}):function(t){return"object"==typeof t&&null!==t&&"legendGroups"in t}(n)?t.createElement(le,{legendGroups:n.legendGroups,title:"",width:f?r:100,orientation:f?"horizontal":"vertical",customHoverBehavior:s,customClickBehavior:c,highlightedCategory:u,isolatedCategories:h,legendInteraction:d}):n)}function se(t){return"string"==typeof t?{type:t}:t}function ce({orient:e,config:r,values:o,scale:i,size:l,length:a}){const s=function(t){var e,n,r,o,i;return{type:t.type,bins:null!==(e=t.bins)&&void 0!==e?e:20,fill:null!==(n=t.fill)&&void 0!==n?n:"#4e79a7",fillOpacity:null!==(r=t.fillOpacity)&&void 0!==r?r:.5,stroke:null!==(o=t.stroke)&&void 0!==o?o:"none",strokeWidth:null!==(i=t.strokeWidth)&&void 0!==i?i:1}}(r),c="top"===e||"bottom"===e,u=n(()=>{if(0===o.length)return null;const n=i.domain(),r=l-8;if("boxplot"===s.type){const n=function(t){const e=[...t].sort((t,e)=>t-e),n=e.length;if(0===n)return null;const r=e[Math.floor(.25*n)],o=e[Math.floor(.5*n)],i=e[Math.floor(.75*n)],l=i-r;return{q1:r,median:o,q3:i,whiskerLow:Math.max(e[0],r-1.5*l),whiskerHigh:Math.min(e[n-1],i+1.5*l)}}(o);if(!n)return null;const{q1:l,median:a,q3:u,whiskerLow:h,whiskerHigh:d}=n,f=Math.min(.5*r,20),y=(r-f)/2+4;if(c){const n=i(l),r=i(u),o=i(a),c=i(h),g=i(d),p="top"===e?-1:1,m=0;return t.createElement("g",{"data-testid":"marginal-boxplot-"+e},t.createElement("line",{x1:c,y1:m+p*(y+f/2),x2:g,y2:m+p*(y+f/2),stroke:s.fill,strokeWidth:s.strokeWidth}),t.createElement("line",{x1:c,y1:m+p*y,x2:c,y2:m+p*(y+f),stroke:s.fill,strokeWidth:s.strokeWidth}),t.createElement("line",{x1:g,y1:m+p*y,x2:g,y2:m+p*(y+f),stroke:s.fill,strokeWidth:s.strokeWidth}),t.createElement("rect",{x:Math.min(n,r),y:"top"===e?m-y-f:m+y,width:Math.abs(r-n),height:f,fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),t.createElement("line",{x1:o,y1:"top"===e?m-y-f:m+y,x2:o,y2:"top"===e?m-y:m+y+f,stroke:s.fill,strokeWidth:2}))}{const n=i(l),r=i(u),o=i(a),c=i(h),g=i(d),p="left"===e?-1:1,m=0;return t.createElement("g",{"data-testid":"marginal-boxplot-"+e},t.createElement("line",{x1:m+p*(y+f/2),y1:c,x2:m+p*(y+f/2),y2:g,stroke:s.fill,strokeWidth:s.strokeWidth}),t.createElement("line",{x1:m+p*y,y1:c,x2:m+p*(y+f),y2:c,stroke:s.fill,strokeWidth:s.strokeWidth}),t.createElement("line",{x1:m+p*y,y1:g,x2:m+p*(y+f),y2:g,stroke:s.fill,strokeWidth:s.strokeWidth}),t.createElement("rect",{x:"left"===e?m-y-f:m+y,y:Math.min(n,r),width:f,height:Math.abs(r-n),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),t.createElement("line",{x1:"left"===e?m-y-f:m+y,y1:o,x2:"left"===e?m-y:m+y+f,y2:o,stroke:s.fill,strokeWidth:2}))}}const u=M().domain(n).thresholds(s.bins)(o);if(0===u.length)return null;const h=Math.max(...u.map(t=>t.length));if(0===h)return null;if("histogram"===s.type)return t.createElement("g",{"data-testid":"marginal-histogram-"+e},u.map((n,o)=>{if(null==n.x0||null==n.x1)return null;const l=n.length/h*r;if(c){const r=i(n.x0),a=i(n.x1)-i(n.x0);return t.createElement("rect",{key:o,x:r,y:"top"===e?-4-l:4,width:Math.max(a,.5),height:l,fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth})}{const r=i(n.x0),a=i(n.x1)-i(n.x0);return t.createElement("rect",{key:o,x:"left"===e?-4-l:4,y:Math.min(r,r+a),width:l,height:Math.abs(a),fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth})}}));if("violin"===s.type){const n=r/2+4,o=[];for(const t of u){if(null==t.x0||null==t.x1)continue;const l=t.length/h*(r/2),a=i((t.x0+t.x1)/2);o.push(c?`${a},${"top"===e?-(n-l):n-l}`:`${"left"===e?-(n-l):n-l},${a}`)}for(let t=u.length-1;t>=0;t--){const l=u[t];if(null==l.x0||null==l.x1)continue;const a=l.length/h*(r/2),s=i((l.x0+l.x1)/2);o.push(c?`${s},${"top"===e?-(n+a):n+a}`:`${"left"===e?-(n+a):n+a},${s}`)}return t.createElement("g",{"data-testid":"marginal-violin-"+e},t.createElement("polygon",{points:o.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}))}if("ridgeline"===s.type){const n=[];if(c){const t=0,o=null!=u[0].x0?i(u[0].x0):0;n.push(`M${o},${t}`);for(const t of u){if(null==t.x0||null==t.x1)continue;const o=t.length/h*r,l=i((t.x0+t.x1)/2);n.push(`L${l},${"top"===e?-o-4:o+4}`)}const l=null!=u[u.length-1].x1?i(u[u.length-1].x1):a;n.push(`L${l},${t}`),n.push("Z")}else{const t=0,o=null!=u[0].x0?i(u[0].x0):0;n.push(`M${t},${o}`);for(const t of u){if(null==t.x0||null==t.x1)continue;const o=t.length/h*r,l=i((t.x0+t.x1)/2);n.push(`L${"left"===e?-o-4:o+4},${l}`)}const l=null!=u[u.length-1].x1?i(u[u.length-1].x1):a;n.push(`L${t},${l}`),n.push("Z")}return t.createElement("g",{"data-testid":"marginal-ridgeline-"+e},t.createElement("path",{d:n.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}))}return null},[o,i,s,l,a,e,c,4]);return u?t.createElement("g",{className:"marginal-"+e,"data-testid":"marginal-"+e},u):null}function ue(t,e=120,n=8){if(!t)return[];const r=Math.max(1,Math.floor(e/n)),o=t.split(/\s+/),i=[];let l="";for(const t of o)l&&l.length+1+t.length>r?(i.push(l),l=t):l=l?`${l} ${t}`:t;return l&&i.push(l),i}function he(t,e,n,r){return"curly"===t?r?`M0,0 C${.6*n},0 ${.4*n},${e/2} ${n},${e/2} C${.4*n},${e/2} ${.6*n},${e} 0,${e}`:`M0,0 C0,${.6*n} ${e/2},${.4*n} ${e/2},${n} C${e/2},${.4*n} ${e},${.6*n} ${e},0`:r?`M0,0 L${n},0 L${n},${e} L0,${e}`:`M0,0 L0,${n} L${e},${n} L${e},0`}function de(e){const{x:n=0,y:r=0,dx:o,dy:i,nx:l,ny:a,note:s,connector:c,subject:u,type:h,color:d,className:f,disable:y,events:g={},"data-testid":p}=e,m=new Set(Array.isArray(y)?y:[]);let v=o||0,x=i||0;null!=l&&(v=l-n),null!=a&&(x=a-r);const b="string"==typeof h?h:"label";if("bracket"===b&&u&&0===v&&0===x)if(void 0!==u.width){v=u.width/2;const t=u.depth||30;x=t+(0>t?-5:5)}else if(void 0!==u.height){const t=u.depth||30;v=t+(0>t?-5:5),x=u.height/2}return t.createElement("g",Object.assign({className:("annotation "+(f||"")).trim(),transform:`translate(${n},${r})`,"data-testid":p},g),!m.has("connector")&&function(e,n,r,o,i,l){const a=[];let s=0,c=0;if("callout-circle"!==i&&"label"!==i||!(null==l?void 0:l.radius)){if("callout-rect"===i&&l){const t=l.width||0,r=l.height||0;if(t>0||r>0){const o=t/2,i=r/2,l=e-o,a=n-i;if(0!==l||0!==a){const e=Math.abs(l),n=Math.abs(a),u=t/2,h=r/2,d=e*h>n*u?u/e:h/n;s=o+l*d,c=i+a*d}}}else if("bracket"===i&&l){const t=l.width,e=l.height,n=l.depth||30;void 0!==t?(s=t/2,c=n):void 0!==e&&(s=n,c=e/2)}}else{const t=(l.radius||0)+(l.radiusPadding||0);if(t>0&&(0!==e||0!==n)){const r=Math.atan2(n,e);s=Math.cos(r)*t,c=Math.sin(r)*t}}if(Math.sqrt(Math.pow(e-s,2)+Math.pow(n-c,2))>.5&&(a.push(t.createElement("line",{key:"connector-line",x1:s,y1:c,x2:e,y2:n,stroke:o||"currentColor"})),"arrow"===(null==r?void 0:r.end))){const r=10,i=16/180*Math.PI,l=Math.atan2(n-c,e-s);a.push(t.createElement("path",{key:"connector-arrow",d:`M${s},${c}L${s+r*Math.cos(l+i)},${c+r*Math.sin(l+i)}L${s+r*Math.cos(l-i)},${c+r*Math.sin(l-i)}Z`,fill:o||"currentColor",stroke:"none"}))}return t.createElement("g",{className:"annotation-connector"},a)}(v,x,c,d,b,u),!m.has("subject")&&function(e,n,r,o,i){var l;const a=[];switch(e){case"callout-circle":{const e=((null==n?void 0:n.radius)||0)+((null==n?void 0:n.radiusPadding)||0);e>0&&a.push(t.createElement("circle",{key:"subject-circle",r:e,fill:"none",stroke:r||"currentColor"}));break}case"callout-rect":{const e=(null==n?void 0:n.width)||0,o=(null==n?void 0:n.height)||0;(e>0||o>0)&&a.push(t.createElement("rect",{key:"subject-rect",width:e,height:o,fill:"none",stroke:r||"currentColor"}));break}case"callout-custom":(null==n?void 0:n.custom)&&a.push(...Array.isArray(n.custom)?n.custom:[n.custom]);break;case"xy-threshold":{const e=o||0,l=i||0;if(void 0!==(null==n?void 0:n.x)){const o=(n.x||0)-e;a.push(t.createElement("line",{key:"threshold-line",x1:o,y1:(n.y1||0)-l,x2:o,y2:(n.y2||0)-l,stroke:r||"currentColor",strokeDasharray:"5,5"}))}else if(void 0!==(null==n?void 0:n.y)){const o=(n.y||0)-l;a.push(t.createElement("line",{key:"threshold-line",x1:(n.x1||0)-e,y1:o,x2:(n.x2||0)-e,y2:o,stroke:r||"currentColor",strokeDasharray:"5,5"}))}else void 0!==(null==n?void 0:n.x1)||void 0!==(null==n?void 0:n.x2)?a.push(t.createElement("line",{key:"threshold-line",x1:(n.x1||0)-e,y1:0,x2:(n.x2||0)-e,y2:0,stroke:r||"currentColor",strokeDasharray:"5,5"})):void 0===(null==n?void 0:n.y1)&&void 0===(null==n?void 0:n.y2)||a.push(t.createElement("line",{key:"threshold-line",x1:0,y1:(n.y1||0)-l,x2:0,y2:(n.y2||0)-l,stroke:r||"currentColor",strokeDasharray:"5,5"}));break}case"bracket":{const e=null!==(l=null==n?void 0:n.width)&&void 0!==l?l:null==n?void 0:n.height;void 0!==e&&a.push(t.createElement("path",{key:"bracket-path",d:he((null==n?void 0:n.type)||"curly",e,(null==n?void 0:n.depth)||30,void 0===(null==n?void 0:n.width)),fill:"none",stroke:r||"currentColor"}));break}}return t.createElement("g",{className:"annotation-subject"},a)}(b,u,d,n,r),!m.has("note")&&function(e,n,r,o){if(!e)return t.createElement("g",{className:"annotation-note"});const{label:i,title:l,orientation:a,align:s,wrap:c=120,noWrap:u}=e;if(!i&&!l)return t.createElement("g",{className:"annotation-note"});let h=a;h||(h=Math.abs(n)>Math.abs(r)?"leftRight":"topBottom");let d=s;d&&"dynamic"!==d||(d="topBottom"===h?0>n?"right":"left":0>r?"bottom":"top");let f="start";"topBottom"===h?"right"===d?f="end":"middle"===d&&(f="middle"):f=0>n?"end":"start";const y=16,g=l?u?[l]:ue(l,c):[],p=i?u?[i]:ue(i,c):[],m="leftRight"===h?"end"===f?-4:4:0;let v=0;const x=[];g.length>0&&(x.push(t.createElement("text",{key:"annotation-note-title",className:"annotation-note-title",fill:o||void 0,textAnchor:f,fontWeight:"bold"},g.map((e,n)=>t.createElement("tspan",{key:n,x:m,dy:0===n?0:y},e)))),v=g.length*y),p.length>0&&x.push(t.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:o||void 0,textAnchor:f,y:v},p.map((e,n)=>t.createElement("tspan",{key:n,x:m,dy:0===n?0:y},e))));let b=null;if((l||i)&&(0!==n||0!==r))if("topBottom"===h){const e=Math.min(c,120);let n=0,r=e;"end"===f?(n=-e,r=0):"middle"===f&&(n=-e/2,r=e/2),b=t.createElement("line",{className:"note-line",x1:n,x2:r,y1:0,y2:0,stroke:o||"currentColor"})}else{const e=(g.length+p.length)*y+(p.length>0?y:0);let n=0,r=e;"bottom"===d?(n=-e,r=0):"middle"===d&&(n=-e/2,r=e/2),b=t.createElement("line",{className:"note-line",x1:0,x2:0,y1:n,y2:r,stroke:o||"currentColor"})}const k=Math.max(0,g.length+p.length-1)*y;let w=0;return"topBottom"===h?w=0>r?-(k+2):18:"leftRight"===h&&(w="middle"===d?-(k+y+(p.length>0&&g.length>0?2:0))/2+8:"bottom"===d||0>r?-(k+2):18),t.createElement("g",{className:"annotation-note",transform:`translate(${n},${r})`},t.createElement("g",{className:"annotation-note-content",transform:0!==w?`translate(0,${w})`:void 0},x),b)}(s,v,x,d))}function fe(e){var n,r;const{noteData:o}=e,{screenCoordinates:i}=o,l="string"==typeof o.type?o.type:"label",a=o.eventListeners||o.events||{};if(o.coordinates&&i){const e=o.nx||i[0][0]+(null!==(n=o.dx)&&void 0!==n?n:0),a=o.ny||i[0][1]+(null!==(r=o.dy)&&void 0!==r?r:0),s=i.map((n,r)=>{const i=Object.assign({},o,{note:0===r?o.note:{label:""},x:n[0],y:n[1],nx:e,ny:a});return t.createElement(de,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+r},i,{type:l}))});return t.createElement("g",null,s)}const s=o.note||{title:"none",label:o.label};return t.createElement(de,Object.assign({"data-testid":"semiotic-annotation",key:`${s.label}-${s.title}-${o.i}`,events:a},o,{type:l}))}function ye(t,e){var n,r,o;const i=null!==(r=null===(n=e.scales)||void 0===n?void 0:n.x)&&void 0!==r?r:null===(o=e.scales)||void 0===o?void 0:o.time;return i?null!=t.x?i(t.x):e.xAccessor&&null!=t[e.xAccessor]?i(t[e.xAccessor]):null:null}function ge(t,e){var n,r,o;const i=null!==(r=null===(n=e.scales)||void 0===n?void 0:n.y)&&void 0!==r?r:null===(o=e.scales)||void 0===o?void 0:o.value;return i?null!=t.y?i(t.y):e.yAccessor&&null!=t[e.yAccessor]?i(t[e.yAccessor]):null:null}function pe(t,e,n){var r,o,i,l;const a=t.anchor||"fixed";if("latest"===a){if(null!=t.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let o=n.pointNodes.length-1;o>=0;o--){const i=n.pointNodes[o];if(i.pointId===t.pointId){const t={x:i.x,y:i.y};return null===(r=n.stickyPositionCache)||void 0===r||r.set(e,t),t}}const i=function(t){var e,n,r,o,i,l;const a=t.data;if(!a||0===a.length)return null;const s=a[a.length-1],c=null!==(n=null===(e=t.scales)||void 0===e?void 0:e.x)&&void 0!==n?n:null===(r=t.scales)||void 0===r?void 0:r.time,u=null!==(i=null===(o=t.scales)||void 0===o?void 0:o.y)&&void 0!==i?i:null===(l=t.scales)||void 0===l?void 0:l.value;if(!c||!u)return null;const h=s[t.xAccessor||"x"],d=s[t.yAccessor||"y"];return null==h||null==d?null:{x:c(h),y:u(d)}}(n);return i&&(null===(o=n.stickyPositionCache)||void 0===o||o.set(e,i)),i}let s=null,c=null;if(null!=t.pointId&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===t.pointId);e&&(s=e.x,c=e.y)}if(null!=s&&null!=c||(s=ye(t,n),c=ge(t,n)),null!=s&&null!=c)return null===(i=n.stickyPositionCache)||void 0===i||i.set(e,{x:s,y:c}),{x:s,y:c};if("sticky"===a){const t=null===(l=n.stickyPositionCache)||void 0===l?void 0:l.get(e);if(t)return t}return null}function me(t,e,n,r=50){return!(-r>t||t>(n.width||0)+r||-r>e||e>(n.height||0)+r)}const ve={linear:U,monotoneX:q,monotoneY:V,step:G,stepAfter:X,stepBefore:H,basis:Y,cardinal:R,catmullRom:F};let xe={positions:new Map};const be=new Set;function ke(){for(const t of be)t()}function we(t,e){const n=xe.positions.get(t);if(!n||n.sourceId!==e)return;const r=new Map(xe.positions);r.delete(t),xe={positions:r},ke()}function Ee(){return xe}function Ae(t){return be.add(t),()=>be.delete(t)}const Me={positions:new Map};function Se(){return()=>{}}function _e(){return Me}function Pe(t,e,n){if("left"===t||"right"===t){const r="left"===t?n:0,o="left"===t?-1:1,i=Math.ceil(e/8);let l="M0,"+r;for(let t=0;i>t;t++){const n=8*(t+1);l+=`L${Math.min(8*t+4,e)},${r+4*o}`,l+=`L${Math.min(n,e)},${r}`}return l}{const r="bottom"===t?0:e,o="bottom"===t?1:-1,i=Math.ceil(n/8);let l=`M${r},0`;for(let t=0;i>t;t++){const e=8*(t+1);l+=`L${r+4*o},${Math.min(8*t+4,n)}`,l+=`L${r},${Math.min(e,n)}`}return l}}function De(e){const{width:r,height:o,totalWidth:i,totalHeight:l,margin:a,scales:s,showAxes:c,axes:u,showGrid:h,xFormat:d,yFormat:f}=e,y=n(()=>{var t;if(!s)return[];const e=null==u?void 0:u.find(t=>"bottom"===t.orient),n=(null==e?void 0:e.tickFormat)||d||Te,o=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5,i=s.x.ticks(Math.min(o,Math.max(2,Math.floor(r/70)))),l=i.map(t=>t.valueOf()),a=i.map((t,e)=>({value:t,pixel:s.x(t),label:n(t,e,l)})),c=a.reduce((t,e)=>Math.max(t,6.5*e.label.length),0);return Le(a,Math.max(55,c+8))},[s,u,d,r]),g=n(()=>{var t;if(!s)return[];const e=null==u?void 0:u.find(t=>"left"===t.orient),n=(null==e?void 0:e.tickFormat)||f||Te,r=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5;return Le(s.y.ticks(Math.min(r,Math.max(2,Math.floor(o/30)))).map(t=>({value:t,pixel:s.y(t),label:n(t)})),22)},[s,u,f,o]),p=h&&s,m=c&&s;if(!p&&!m)return null;const v=null==u?void 0:u.find(t=>"bottom"===t.orient),x=null==u?void 0:u.find(t=>"left"===t.orient),b=m&&(!v||!1!==v.baseline),k=m&&(!x||!1!==x.baseline),w=(null==v?void 0:v.jaggedBase)||!1,E=(null==x?void 0:x.jaggedBase)||!1,A="var(--semiotic-border, #ccc)";return t.createElement("svg",{width:i,height:l,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},t.createElement("g",{transform:`translate(${a.left},${a.top})`},p&&t.createElement("g",{className:"stream-grid"},y.map((e,n)=>t.createElement("line",{key:"xgrid-"+n,x1:e.pixel,y1:0,x2:e.pixel,y2:o,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1})),g.map((e,n)=>t.createElement("line",{key:"ygrid-"+n,x1:0,y1:e.pixel,x2:r,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),b&&!w&&t.createElement("line",{x1:0,y1:o,x2:r,y2:o,stroke:A,strokeWidth:1}),w&&t.createElement("path",{d:Pe("bottom",r,o),fill:"none",stroke:A,strokeWidth:1}),k&&!E&&t.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:A,strokeWidth:1}),E&&t.createElement("path",{d:Pe("left",r,o),fill:"none",stroke:A,strokeWidth:1})))}function Te(t,e,n){return Math.round(100*t)/100+""}function Le(t,e){if(2>=t.length)return t;const n=[t[0]];for(let r=1;t.length-1>r;r++)e>Math.abs(t[r].pixel-n[n.length-1].pixel)||n.push(t[r]);const r=t[t.length-1];return e>Math.abs(r.pixel-n[n.length-1].pixel)?n[n.length-1]=r:n.push(r),n}function Ce(t,e){return t instanceof Date&&(!(e&&e instanceof Date)||t.getFullYear()!==e.getFullYear()||t.getMonth()!==e.getMonth()||t.getDate()!==e.getDate())}function $e(r){var o,l;const{width:a,height:s,totalWidth:c,totalHeight:u,margin:h,scales:d,showAxes:f,axes:y,xLabel:g,yLabel:p,yLabelRight:m,xFormat:v,yFormat:x,showGrid:b,title:k,legend:w,legendHoverBehavior:E,legendClickBehavior:A,legendHighlightedCategory:M,legendIsolatedCategories:S,legendPosition:_="right",foregroundGraphics:P,marginalGraphics:D,xValues:T,yValues:L,annotations:$,svgAnnotationRules:N,xAccessor:O,yAccessor:W,annotationData:I,pointNodes:z,curve:B,underlayRendered:F,linkedCrosshairName:R,linkedCrosshairSourceId:Y,children:H}=r,X=n(()=>{var t;if(!f||!d)return[];const e=null==y?void 0:y.find(t=>"bottom"===t.orient),n=(null==e?void 0:e.tickFormat)||v||Te,r=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5,o=d.x.ticks(Math.min(r,Math.max(2,Math.floor(a/70)))),i=o.map(t=>t.valueOf()),l=o.map((t,e)=>({value:t,pixel:d.x(t),label:n(t,e,i)})),s=l.reduce((t,e)=>Math.max(t,6.5*e.label.length),0);return Le(l,Math.max(55,s+8))},[f,d,y,v,a]),G=n(()=>{var t;if(!f||!d)return[];const e=null==y?void 0:y.find(t=>"left"===t.orient),n=(null==e?void 0:e.tickFormat)||x||Te,r=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5;return Le(d.y.ticks(Math.min(r,Math.max(2,Math.floor(s/30)))).map(t=>({value:t,pixel:d.y(t),label:n(t)})),22)},[f,d,y,x,s]),V=n(()=>{var t;if(!f||!d)return[];const e=null==y?void 0:y.find(t=>"right"===t.orient);if(!e)return[];const n=e.tickFormat||x||Te,r=null!==(t=e.ticks)&&void 0!==t?t:5;return Le(d.y.ticks(Math.min(r,Math.max(2,Math.floor(s/30)))).map(t=>({value:t,pixel:d.y(t),label:n(t)})),22)},[f,d,y,x,s]),q=e(new Map),K=e(null!==(o=null==$?void 0:$.length)&&void 0!==o?o:0),Z=null!==(l=null==$?void 0:$.length)&&void 0!==l?l:0;K.current!==Z&&(K.current=Z,q.current=new Map);const Q=n(()=>{if(!$||0===$.length)return null;const e=function(e,n,r){var o,i,l,a,s,c,u,h,d,f,y,g,p,m,v,x,b,k,w,E,A,M,S,_,P,D,T,L,$,N,O,W,I,z,B,F,R,Y,H,X,G,V,q,K,Z,Q,J,et;switch(e.type){case"label":{const o=pe(e,n,r);if(!o)return null;const{x:i,y:l}=o;return me(i,l,r)?t.createElement(fe,{key:"ann-"+n,noteData:{x:i,y:l,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":{const o=pe(e,n,r);if(!o)return null;const{x:i,y:l}=o;return me(i,l,r)?t.createElement(fe,{key:"ann-"+n,noteData:{x:i,y:l,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=ye(e,r);if(null==o)return null;const i=e.color||"#f97316",l=e.labelPosition||"top";let a;return a="bottom"===l?(r.height||0)-4:"center"===l?(r.height||0)/2:12,t.createElement("g",{key:"ann-"+n},t.createElement("line",{x1:o,y1:0,x2:o,y2:r.height||0,stroke:i,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&t.createElement("text",{x:o+4,y:a,fill:i,fontSize:12,fontWeight:"bold"},e.label))}case"y-threshold":{const o=ge(e,r);if(null==o)return null;const i=e.color||"#f97316",l=e.labelPosition||"right";let a,s;return"left"===l?(a=4,s="start"):"center"===l?(a=(r.width||0)/2,s="middle"):(a=(r.width||0)-4,s="end"),t.createElement("g",{key:"ann-"+n},t.createElement("line",{x1:0,y1:o,x2:r.width||0,y2:o,stroke:i,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&t.createElement("text",{x:a,y:o-4,textAnchor:s,fill:i,fontSize:12,fontWeight:"bold"},e.label))}case"enclose":{const o=(e.coordinates||[]).map(t=>({x:ye(Object.assign(Object.assign({},t),{type:"point"}),r),y:ge(Object.assign(Object.assign({},t),{type:"point"}),r),r:1})).filter(t=>null!=t.x&&null!=t.y);if(2>o.length)return null;const i=C(o),l=e.padding||10;return t.createElement("g",{key:"ann-"+n},t.createElement("circle",{cx:i.x,cy:i.y,r:i.r+l,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&t.createElement("text",{x:i.x,y:i.y-i.r-l-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12},e.label))}case"rect-enclose":{const o=(e.coordinates||[]).map(t=>({x:ye(Object.assign(Object.assign({},t),{type:"point"}),r),y:ge(Object.assign(Object.assign({},t),{type:"point"}),r)})).filter(t=>null!=t.x&&null!=t.y);if(2>o.length)return null;const i=e.padding||10,l=o.map(t=>t.x),a=o.map(t=>t.y),s=Math.min(...l)-i,c=Math.max(...l)+i,u=Math.min(...a)-i,h=Math.max(...a)+i;return t.createElement("g",{key:"ann-"+n},t.createElement("rect",{x:s,y:u,width:c-s,height:h-u,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&t.createElement("text",{x:(s+c)/2,y:u-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12},e.label))}case"highlight":{const o=r.data||[],i="function"==typeof e.filter?o.filter(e.filter):e.field&&null!=e.value?o.filter(t=>t[e.field]===e.value):[],l={stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return t.createElement("g",{key:"ann-"+n},i.map((n,o)=>{const i=ye(n,r),a=ge(n,r);if(null==i||null==a)return null;const s="function"==typeof e.r?e.r(n):e.r||6,c="function"==typeof e.style?e.style(n):e.style||l;return t.createElement("circle",Object.assign({key:"hl-"+o,cx:i,cy:a,r:s},c))}))}case"bracket":{const o=ye(e,r),i=ge(e,r);return t.createElement(fe,{key:"ann-"+n,noteData:{x:null!=o?o:0,y:null!=i?i: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 h=r.data||[];if(2>h.length)return null;const d=r.xAccessor||"x",f=r.yAccessor||"y",y=h.map(t=>[t[d],t[f]]).filter(t=>null!=t[0]&&null!=t[1]);if(2>y.length)return null;const g=null!==(i=null===(o=r.scales)||void 0===o?void 0:o.x)&&void 0!==i?i:null===(l=r.scales)||void 0===l?void 0:l.time,p=null!==(s=null===(a=r.scales)||void 0===a?void 0:a.y)&&void 0!==s?s:null===(c=r.scales)||void 0===c?void 0:c.value;if(!g||!p)return null;const m=e.method||"linear";let v;v="loess"===m?function(t,e=.3){const n=t.length;if(2>n)return t.slice();const r=t.slice().sort((t,e)=>t[0]-e[0]),o=r.map(t=>t[0]),i=r.map(t=>t[1]),l=Math.max(2,Math.ceil(e*n)),a=[];for(let t=0;n>t;t++){const e=o[t],r=o.map(t=>Math.abs(t-e)),s=r.slice().sort((t,e)=>t-e)[Math.min(l-1,n-1)]||1,c=[];for(let t=0;n>t;t++){const e=0===s?0:r[t]/s;c[t]=1>e?Math.pow(1-Math.pow(e,3),3):0}let u=0,h=0,d=0,f=0,y=0;for(let t=0;n>t;t++){const e=c[t];0!==e&&(u+=e,h+=e*o[t],d+=e*i[t],f+=e*o[t]*o[t],y+=e*o[t]*i[t])}if(0===u){a.push([e,i[t]]);continue}const g=u*f-h*h;if(1e-12>Math.abs(g))a.push([e,d/u]);else{const t=(u*y-h*d)/g;a.push([e,(d-t*h)/u+t*e])}}return a}(y,null!==(u=e.bandwidth)&&void 0!==u?u:.3):("polynomial"===m?tt.polynomial(y,{order:e.order||2}):tt.linear(y)).points;const x=v.map(([t,e])=>`${g(t)},${p(e)}`).join(" "),b=e.color||"#6366f1";return t.createElement("g",{key:"ann-"+n},t.createElement("polyline",{points:x,fill:"none",stroke:b,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&t.createElement("text",{x:g(v[v.length-1][0])+4,y:p(v[v.length-1][1])-4,fill:b,fontSize:11},e.label))}case"band":{const o=null!==(d=null===(h=r.scales)||void 0===h?void 0:h.y)&&void 0!==d?d:null===(f=r.scales)||void 0===f?void 0:f.value,i=null!==(y=null==o?void 0:o(e.y0))&&void 0!==y?y:0,l=null!==(g=null==o?void 0:o(e.y1))&&void 0!==g?g:r.height||0;return t.createElement("g",{key:"ann-"+n},t.createElement("rect",{x:0,y:Math.min(i,l),width:r.width||0,height:Math.abs(l-i),fill:e.fill||"var(--semiotic-primary, #6366f1)",fillOpacity:e.fillOpacity||.1}),e.label&&t.createElement("text",{x:(r.width||0)-4,y:Math.min(i,l)-4,textAnchor:"end",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11},e.label))}case"envelope":{const o=r.data||[];if(2>o.length)return null;const i=r.xAccessor||"x",l=null!==(m=null===(p=r.scales)||void 0===p?void 0:p.x)&&void 0!==m?m:null===(v=r.scales)||void 0===v?void 0:v.time,a=null!==(b=null===(x=r.scales)||void 0===x?void 0:x.y)&&void 0!==b?b:null===(k=r.scales)||void 0===k?void 0:k.value;if(!l||!a)return null;const s=e.upperAccessor||"upperBounds",c=e.lowerAccessor||"lowerBounds",u=e.filter,h=o.filter(t=>null!=t[s]&&null!=t[c]&&!(u&&!u(t))).sort((t,e)=>t[i]-e[i]);if(2>h.length)return null;const d=ve[r.curve||"linear"]||U,f=j().x(t=>l(t[i])).y0(t=>a(t[c])).y1(t=>a(t[s])).curve(d)(h);if(!f)return null;const y=e.fill||"#6366f1";return t.createElement("g",{key:"ann-"+n},t.createElement("path",{d:f,fill:y,fillOpacity:null!==(w=e.fillOpacity)&&void 0!==w?w:.15,stroke:"none"}),e.label&&h.length>0&&t.createElement("text",{x:l(h[h.length-1][i])+4,y:a(h[h.length-1][s])-4,fill:y,fontSize:11},e.label))}case"anomaly-band":{const o=r.data||[];if(2>o.length)return null;const i=r.yAccessor||"y",l=null!==(A=null===(E=r.scales)||void 0===E?void 0:E.x)&&void 0!==A?A:null===(M=r.scales)||void 0===M?void 0:M.time,a=null!==(_=null===(S=r.scales)||void 0===S?void 0:S.y)&&void 0!==_?_:null===(P=r.scales)||void 0===P?void 0:P.value;if(!l||!a)return null;const s=o.map(t=>t[i]).filter(t=>null!=t&&isFinite(t));if(2>s.length)return null;const c=s.reduce((t,e)=>t+e,0)/s.length,u=s.reduce((t,e)=>t+Math.pow(e-c,2),0)/s.length,h=Math.sqrt(u),d=null!==(D=e.threshold)&&void 0!==D?D:2,f=c-d*h,y=!1!==e.showBand,g=e.fill||"#6366f1",p=null!==(T=e.fillOpacity)&&void 0!==T?T:.1,m=e.anomalyColor||"#ef4444",v=null!==(L=e.anomalyRadius)&&void 0!==L?L:6,x=a(c+d*h),b=a(f),k=o.filter(t=>{const e=t[i];return null!=e&&Math.abs(e-c)>d*h});return t.createElement("g",{key:"ann-"+n},y&&t.createElement("rect",{x:0,y:Math.min(x,b),width:r.width||0,height:Math.abs(b-x),fill:g,fillOpacity:p}),k.map((e,n)=>{const o=ye(e,r),i=ge(e,r);return null==o||null==i?null:t.createElement("circle",{key:"anomaly-"+n,cx:o,cy:i,r:v,fill:m,fillOpacity:.7,stroke:m,strokeWidth:1.5})}),e.label&&t.createElement("text",{x:(r.width||0)-4,y:Math.min(x,b)-4,textAnchor:"end",fill:g,fontSize:11},e.label))}case"forecast":{const o=r.data||[];if(3>o.length)return null;const i=r.xAccessor||"x",l=r.yAccessor||"y",a=null!==(N=null===($=r.scales)||void 0===$?void 0:$.x)&&void 0!==N?N:null===(O=r.scales)||void 0===O?void 0:O.time,s=null!==(I=null===(W=r.scales)||void 0===W?void 0:W.y)&&void 0!==I?I:null===(z=r.scales)||void 0===z?void 0:z.value;if(!a||!s)return null;const c=o.map(t=>[t[i],t[l]]).filter(t=>null!=t[0]&&null!=t[1]&&isFinite(t[0])&&isFinite(t[1])).sort((t,e)=>t[0]-e[0]);if(3>c.length)return null;let u;if("polynomial"===(e.method||"linear")){const t=tt.polynomial(c,{order:e.order||2}).equation;u=e=>t.reduce((t,n,r)=>t+n*Math.pow(e,r),0)}else{const t=c.length;let e=0,n=0,r=0,o=0;for(const[t,i]of c)e+=t,n+=i,r+=t*t,o+=t*i;const i=t*r-e*e;if(1e-12>Math.abs(i))return null;const l=(t*o-e*n)/i,a=(n-l*e)/t;u=t=>a+l*t}const h=c.length,d=c.map(([t,e])=>e-u(t)).reduce((t,e)=>t+e*e,0),f=Math.sqrt(d/Math.max(h-2,1)),y=c.reduce((t,e)=>t+e[0],0)/h,g=c.reduce((t,e)=>t+Math.pow(e[0]-y,2),0),p=null!==(B=e.confidence)&&void 0!==B?B:.95,m=.99>p?.95>p?.9>p?1:1.645:1.96:2.576,v=null!==(F=e.steps)&&void 0!==F?F:5,x=c[h-1][0],b=(x-c[0][0])/Math.max(h-1,1),k=[];for(let t=1;v>=t;t++)k.push(x+t*b);const w=[];for(const t of k){const e=u(t),n=f*Math.sqrt(1+1/h+(g>0?Math.pow(t-y,2)/g:0))*m;w.push({x:t,yCenter:e,yUpper:e+n,yLower:e-n})}const E=`M${w.map(t=>`${a(t.x)},${s(t.yUpper)}`).join(" L")} L${w.slice().reverse().map(t=>`${a(t.x)},${s(t.yLower)}`).join(" L")} Z`,A=w.map(t=>`${a(t.x)},${s(t.yCenter)}`).join(" "),M=`${a(x)},${s(u(x))}`,S=e.strokeColor||"#6366f1";return t.createElement("g",{key:"ann-"+n},t.createElement("path",{d:E,fill:e.fill||"#6366f1",fillOpacity:null!==(R=e.fillOpacity)&&void 0!==R?R:.15,stroke:"none"}),t.createElement("polyline",{points:`${M} ${A}`,fill:"none",stroke:S,strokeWidth:null!==(Y=e.strokeWidth)&&void 0!==Y?Y:2,strokeDasharray:null!==(H=e.strokeDasharray)&&void 0!==H?H:"6,3"}),e.label&&w.length>0&&t.createElement("text",{x:a(w[w.length-1].x)+4,y:s(w[w.length-1].yCenter)-4,fill:S,fontSize:11},e.label))}case"widget":{let o=null,i=null;if(null!=e.px&&null!=e.py)o=e.px,i=e.py;else{const t=pe(e,n,r);if(!t)return null;o=t.x,i=t.y}if(null==o||null==i)return null;if(!me(o,i,r))return null;const l=null!==(X=e.dx)&&void 0!==X?X:0,a=null!==(G=e.dy)&&void 0!==G?G:0,s=null!==(V=e.width)&&void 0!==V?V:32,c=null!==(q=e.height)&&void 0!==q?q:32,u=null!==(K=e.content)&&void 0!==K?K:t.createElement("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info"},"ℹ️");return t.createElement("foreignObject",{key:"ann-"+n,x:o+l-s/2,y:i+a-c/2,width:s,height:c,style:{overflow:"visible",pointerEvents:"auto"}},t.createElement("div",{style:{width:s,height:c,display:"flex",alignItems:"center",justifyContent:"center"}},u))}case"text":{const o=pe(e,n,r);if(!o)return null;const{x:i,y:l}=o;return t.createElement("text",{key:"ann-text-"+n,x:i+(e.dx||0),y:l+(e.dy||0),fill:e.color||"var(--semiotic-text, #333)",fontSize:e.fontSize||11,dominantBaseline:"middle",style:{fontFamily:"inherit"}},e.label)}case"category-highlight":{const o=e.category;if(null==o)return null;const i=null===(Z=r.scales)||void 0===Z?void 0:Z.o,l=null===(Q=r.scales)||void 0===Q?void 0:Q.x,a=null===(J=r.scales)||void 0===J?void 0:J.y,s=(null==i?void 0:i.bandwidth)?i:(null==l?void 0:l.bandwidth)?l:(null==a?void 0:a.bandwidth)?a:null;if(!s)return null;const c=s(o);if(null==c)return null;const u=s.bandwidth(),h=e.color||"var(--semiotic-primary, #4589ff)",d=null!==(et=e.opacity)&&void 0!==et?et:.15,f=e.label;return(r.projection?"vertical"===r.projection:s===l)?t.createElement("g",{key:"ann-"+n},t.createElement("rect",{x:c,y:0,width:u,height:r.height||0,fill:h,fillOpacity:d}),f&&t.createElement("text",{x:c+u/2,y:12,textAnchor:"middle",fill:h,fontSize:12,fontWeight:"bold"},f)):t.createElement("g",{key:"ann-"+n},t.createElement("rect",{x:0,y:c,width:r.width||0,height:u,fill:h,fillOpacity:d}),f&&t.createElement("text",{x:12,y:c+u/2,dominantBaseline:"middle",fill:h,fontSize:12,fontWeight:"bold"},f))}default:return null}},n={scales:d?{x:d.x,y:d.y,time:d.x,value:d.y}:null,timeAxis:"x",xAccessor:O,yAccessor:W,width:a,height:s,data:I,frameType:"xy",pointNodes:z,curve:B,stickyPositionCache:q.current};return $.map((t,r)=>{if(N){const o=N(t,r,n);return null!=o?o:e(t,r,n)}return e(t,r,n)}).filter(Boolean)},[$,N,a,s,O,W,I,d,z,B]),J=function(t){var e;const n=i(t?Ae:Se,t?Ee:_e,t?Ee:_e);return t&&null!==(e=n.positions.get(t))&&void 0!==e?e:null}(R);return f||k||w||P||D||Q&&Q.length>0||b||H||J?t.createElement("svg",{role:"img",width:c,height:u,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"}},t.createElement("title",null,"string"==typeof k?k:"XY Chart"),t.createElement("desc",null,"string"==typeof k?k+" — XY data visualization":"XY data visualization"),t.createElement("g",{transform:`translate(${h.left},${h.top})`},b&&d&&!F&&t.createElement("g",{className:"stream-grid"},X.map((e,n)=>t.createElement("line",{key:"xgrid-"+n,x1:e.pixel,y1:0,x2:e.pixel,y2:s,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1})),G.map((e,n)=>t.createElement("line",{key:"ygrid-"+n,x1:0,y1:e.pixel,x2:a,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),f&&d&&(()=>{const e=null==y?void 0:y.find(t=>"left"===t.orient),n=null==y?void 0:y.find(t=>"bottom"===t.orient),r=!e||!1!==e.baseline,o=(null==e?void 0:e.jaggedBase)||!1,i=(null==n?void 0:n.jaggedBase)||!1,l=null==n?void 0:n.landmarkTicks,c=null==e?void 0:e.landmarkTicks,u="var(--semiotic-border, #ccc)",d="var(--semiotic-text-secondary, var(--semiotic-text, #666))",f="var(--semiotic-text, #333)";return t.createElement("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"}},!F&&(!n||!1!==n.baseline)&&!i&&t.createElement("line",{x1:0,y1:s,x2:a,y2:s,stroke:u,strokeWidth:1}),!F&&i&&t.createElement("path",{d:Pe("bottom",a,s),fill:"none",stroke:u,strokeWidth:1}),X.map((e,n)=>{const r=!!l&&("function"==typeof l?l(e.value,n):Ce(e.value,n>0?X[n-1].value:void 0));return t.createElement("g",{key:"xtick-"+n,transform:`translate(${e.pixel},${s})`},t.createElement("line",{y2:5,stroke:u,strokeWidth:1}),t.createElement("text",{y:18,textAnchor:"middle",fontSize:r?11:10,fontWeight:r?600:400,fill:d,style:{userSelect:"none"}},e.label))}),g&&t.createElement("text",{x:a/2,y:s+40,textAnchor:"middle",fontSize:12,fill:f,style:{userSelect:"none"}},g),!F&&r&&!o&&t.createElement("line",{x1:0,y1:0,x2:0,y2:s,stroke:u,strokeWidth:1}),!F&&o&&t.createElement("path",{d:Pe("left",a,s),fill:"none",stroke:u,strokeWidth:1}),G.map((e,n)=>{const r=!!c&&("function"==typeof c?c(e.value,n):Ce(e.value,n>0?G[n-1].value:void 0));return t.createElement("g",{key:"ytick-"+n,transform:`translate(0,${e.pixel})`},t.createElement("line",{x2:-5,stroke:u,strokeWidth:1}),t.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:r?11:10,fontWeight:r?600:400,fill:d,style:{userSelect:"none"}},e.label))}),(()=>{const n=(null==e?void 0:e.label)||p;return n?t.createElement("text",{x:15-h.left,y:s/2,textAnchor:"middle",fontSize:12,fill:f,transform:`rotate(-90, ${15-h.left}, ${s/2})`,style:{userSelect:"none"}},n):null})(),(()=>{const e=null==y?void 0:y.find(t=>"right"===t.orient);if(!e||0===V.length)return null;const n=e.landmarkTicks,r=e.label||m;return t.createElement(t.Fragment,null,!1!==e.baseline&&t.createElement("line",{x1:a,y1:0,x2:a,y2:s,stroke:u,strokeWidth:1}),V.map((e,r)=>{const o=!!n&&("function"==typeof n?n(e.value,r):Ce(e.value,r>0?V[r-1].value:void 0));return t.createElement("g",{key:"ytick-r-"+r,transform:`translate(${a},${e.pixel})`},t.createElement("line",{x2:5,stroke:u,strokeWidth:1}),t.createElement("text",{x:8,textAnchor:"start",dominantBaseline:"middle",fontSize:o?11:10,fontWeight:o?600:400,fill:d,style:{userSelect:"none"}},e.label))}),r&&t.createElement("text",{x:a+h.right-15,y:s/2,textAnchor:"middle",fontSize:12,fill:f,transform:`rotate(90, ${a+h.right-15}, ${s/2})`,style:{userSelect:"none"}},r))})())})(),Q,D&&d&&T&&L&&t.createElement(t.Fragment,null,D.top&&t.createElement("g",{transform:"translate(0, 0)"},t.createElement(ce,{orient:"top",config:se(D.top),values:T,scale:d.x,size:h.top,length:a})),D.bottom&&t.createElement("g",{transform:`translate(0, ${s})`},t.createElement(ce,{orient:"bottom",config:se(D.bottom),values:T,scale:d.x,size:h.bottom,length:a})),D.left&&t.createElement("g",{transform:"translate(0, 0)"},t.createElement(ce,{orient:"left",config:se(D.left),values:L,scale:d.y,size:h.left,length:s})),D.right&&t.createElement("g",{transform:`translate(${a}, 0)`},t.createElement(ce,{orient:"right",config:se(D.right),values:L,scale:d.y,size:h.right,length:s}))),P,J&&J.sourceId!==Y&&(null==d?void 0:d.x)&&(()=>{const e=d.x(J.xValue);return null==e||0>e||e>a?null:t.createElement("line",{x1:e,y1:0,x2:e,y2:s,stroke:"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:1,strokeDasharray:"4,4",pointerEvents:"none"})})(),H),k&&t.createElement("text",{x:c/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof k?k:null),ae({legend:w,totalWidth:c,totalHeight:u,margin:h,legendPosition:_,title:k,legendHoverBehavior:E,legendClickBehavior:A,legendHighlightedCategory:M,legendIsolatedCategories:S})):null}function Ne(t,e="#4e79a7"){return t&&"string"==typeof t?t:e}const Oe="undefined"==typeof window||"undefined"==typeof document,We=t.createContext(null);function Ie(){return t.useContext(We)}const ze={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function Be(t,e){if(!t||0===t.length)return e+", empty";const n={};for(const e of t)n[e.type]=(n[e.type]||0)+1;const r=[],o={point:"points",line:"lines",area:"areas",rect:"bars",heatcell:"cells",circle:"nodes",candlestick:"candlesticks",wedge:"wedges",arc:"arcs",geoarea:"regions"},i=["point","line","area","rect","heatcell","circle","candlestick","wedge","arc","geoarea"],l=Object.keys(n).sort((t,e)=>{const n=i.indexOf(t),r=i.indexOf(e);return(-1===n?999:n)-(-1===r?999:r)});for(const t of l)r.push(`${n[t]} ${o[t]||t}`);return`${e}, ${r.join(", ")}`}function je(t,e,n){const r=[];return t>0&&r.push(t+" nodes"),e>0&&r.push(e+" edges"),0===r.length?n+", empty":`${n}, ${r.join(", ")}`}const Fe=t=>{if(null==t)return"";const e=Math.round(100*t)/100;return Number.isNaN(e)?"":e+""},Re={position:"absolute",top:0,left:0,right:0,zIndex:5,padding:"14px 16px 12px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)",fontFamily:"var(--semiotic-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif)",fontSize:13,lineHeight:1.5,color:"var(--semiotic-text, #333)",background:"var(--semiotic-bg, #fff)",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},Ye={marginBottom:8,paddingRight:28,color:"var(--semiotic-text-secondary, #666)",fontSize:12,letterSpacing:"0.01em"},He={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-border, #e0e0e0)",background:"var(--semiotic-bg, #fff)",cursor:"pointer",color:"var(--semiotic-text-secondary, #666)",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},Xe={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},Ge={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-border, #e0e0e0)",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-text-secondary, #666)"},Ve={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"},qe={textAlign:"left",fontSize:11,color:"var(--semiotic-text-secondary, #999)",marginBottom:4,fontStyle:"italic"};function Ue({scene:e,chartType:n,tableId:r,chartTitle:o}){var i;const[l,a]=t.useState(!1),s=Ie(),c=null!==(i=null==s?void 0:s.visible)&&void 0!==i&&i,u=l||c,h=t.useRef(null),d=o?"Data summary for "+o:r?`Data summary for ${n} ${r}`:"Data summary for "+n,f=t.useCallback(()=>{l||c||a(!0)},[l,c]),y=t.useCallback(t=>{var e;c||(null===(e=h.current)||void 0===e?void 0:e.contains(t.relatedTarget))||a(!1)},[c]);if(!e||0===e.length)return r?t.createElement("span",{id:r,tabIndex:-1,style:ze}):null;if(!u)return t.createElement("div",{id:r,tabIndex:-1,onFocus:f,style:ze,role:"region","aria-label":d},t.createElement("button",{type:"button",onClick:()=>a(!0)},"View data summary (",e.length," elements)"));const g=function(t){var e,n,r,o,i,l,a,s,c,u,h,d,f,y,g,p,m,v,x,b,k,w,E,A,M;const S=[];if(!Array.isArray(t))return S;for(const _ of t)if(_&&"object"==typeof _)try{switch(_.type){case"point":S.push({label:"Point",values:{x:_.x,y:_.y}});break;case"line":{const t=_.path,e=Array.isArray(_.datum)?_.datum:[];if(!Array.isArray(t))break;for(let n=0;t.length>n&&e.length>n;n++){const e=t[n];Array.isArray(e)&&S.push({label:"Line point",values:{x:e[0],y:e[1]}})}break}case"area":{const t=_.topPath,e=Array.isArray(_.datum)?_.datum:[];if(!Array.isArray(t))break;for(let n=0;t.length>n&&e.length>n;n++){const e=t[n];Array.isArray(e)&&S.push({label:"Area point",values:{x:e[0],y:e[1]}})}break}case"rect":{const t=null!=_.datum&&"object"==typeof _.datum?_.datum:{},i=null!==(n=null!==(e=t.category)&&void 0!==e?e:_.group)&&void 0!==n?n:"",l=null!==(o=null!==(r=t.value)&&void 0!==r?r:t.__aggregateValue)&&void 0!==o?o:t.total;S.push({label:"Bar",values:{category:i,value:null!=l?l:""}});break}case"heatcell":S.push({label:"Cell",values:{x:_.x,y:_.y,value:_.value}});break;case"wedge":S.push({label:"Wedge",values:{category:null!==(s=null!==(l=null===(i=_.datum)||void 0===i?void 0:i.category)&&void 0!==l?l:null===(a=_.datum)||void 0===a?void 0:a.label)&&void 0!==s?s:"",value:null!==(u=null===(c=_.datum)||void 0===c?void 0:c.value)&&void 0!==u?u:""}});break;case"circle":S.push({label:"Node",values:{id:null!==(d=null===(h=_.datum)||void 0===h?void 0:h.id)&&void 0!==d?d:"",x:null!==(f=_.cx)&&void 0!==f?f:_.x,y:null!==(y=_.cy)&&void 0!==y?y:_.y}});break;case"arc":S.push({label:"Arc",values:{id:null!==(p=null===(g=_.datum)||void 0===g?void 0:g.id)&&void 0!==p?p:"",x:null!==(m=_.cx)&&void 0!==m?m:_.x,y:null!==(v=_.cy)&&void 0!==v?v:_.y}});break;case"candlestick":S.push({label:"Candlestick",values:{x:_.x,open:_.open,high:_.high,low:_.low,close:_.close}});break;case"geoarea":S.push({label:"Region",values:{name:null!==(E=null!==(k=null===(b=null===(x=_.datum)||void 0===x?void 0:x.properties)||void 0===b?void 0:b.name)&&void 0!==k?k:null===(w=_.datum)||void 0===w?void 0:w.name)&&void 0!==E?E:"",value:null!==(M=null===(A=_.datum)||void 0===A?void 0:A.value)&&void 0!==M?M:""}})}}catch(t){}return S}(e),p=function(t){if(!t||0===t.length)return[];const e=new Set;for(const n of t)if(n&&n.values)for(const t of Object.keys(n.values))e.add(t);const n=[];for(const r of e){const e=[],o=new Set;for(const n of t){if(!n||!n.values)continue;const t=n.values[r];null!=t&&""!==t&&("number"==typeof t&&!Number.isNaN(t)&&Number.isFinite(t)?e.push(t):"number"==typeof t||"object"!=typeof t&&"function"!=typeof t&&o.add(t+""))}if(e.length>0){let t=e[0],o=e[0],i=0;for(const n of e)t>n&&(t=n),n>o&&(o=n),i+=n;n.push({name:r,count:e.length,numeric:!0,min:t,max:o,mean:i/e.length})}else if(o.size>0){const t=Array.from(o);n.push({name:r,count:t.length,numeric:!1,uniqueValues:t.slice(0,5)})}}return n}(g),m=function(t,e){const n=[t+" data points."];for(const t of e)if(t.numeric)n.push(`${t.name}: ${Fe(t.min)} to ${Fe(t.max)}, mean ${Fe(t.mean)}.`);else{const e=t.uniqueValues,r=e.length>3?`${e.slice(0,3).join(", ")}… (${t.count} unique)`:e.join(", ");n.push(`${t.name}: ${r}.`)}return n.join(" ")}(g.length,p),v=g.slice(0,5),x=new Set;for(const t of v)for(const e of Object.keys(t.values))x.add(e);const b=Array.from(x);return t.createElement("div",{ref:h,id:r,tabIndex:-1,onBlur:y,style:Re,role:"region","aria-label":d},t.createElement("button",{type:"button",onClick:()=>{c&&s&&s.setVisible(!1),a(!1)},"aria-label":"Close data summary",style:He},"×"),t.createElement("div",{role:"note",style:Ye},m),t.createElement("table",{role:"table","aria-label":"Sample data for "+n,style:Xe},t.createElement("caption",{style:qe},"First ",v.length," of ",g.length," data points"),t.createElement("thead",null,t.createElement("tr",null,t.createElement("th",{style:Ge},"type"),b.map(e=>t.createElement("th",{key:e,style:Ge},e)))),t.createElement("tbody",null,v.map((e,n)=>t.createElement("tr",{key:n},t.createElement("td",{style:Ve},e.label),b.map(n=>{return t.createElement("td",{key:n,style:Ve},null==(r=e.values[n])||""===r?"—":"number"==typeof r?Number.isNaN(r)?"—":Fe(r):"boolean"==typeof r?r?"true":"false":"object"==typeof r?"—":r+"");var r}))))))}function Ke({nodes:e,edges:n,chartType:r,tableId:o,chartTitle:i}){var l,a,s,c,u,h,d,f,y,g,p,m,v,x;const[b,k]=t.useState(!1),w=Ie(),E=null!==(l=null==w?void 0:w.visible)&&void 0!==l&&l,A=b||E,M=i?"Data summary for "+i:o?`Data summary for ${r} ${o}`:"Data summary for "+r,S=t.useRef(null),_=t.useCallback(()=>{b||E||k(!0)},[b,E]),P=t.useCallback(t=>{var e;E||(null===(e=S.current)||void 0===e?void 0:e.contains(t.relatedTarget))||k(!1)},[E]);if(!e||0===e.length)return o?t.createElement("span",{id:o,tabIndex:-1,style:ze}):null;if(!A)return t.createElement("div",{id:o,tabIndex:-1,onFocus:_,style:ze,role:"region","aria-label":M},t.createElement("button",{type:"button",onClick:()=>k(!0)},"View data summary (",e.length," nodes, ",n.length," edges)"));const D=Array.isArray(e)?e:[],T=Array.isArray(n)?n:[],L=new Map,C=new Map,$=new Map,N=new Map;for(const t of T){if(!t||"object"!=typeof t)continue;const e=null!==(a=t.datum)&&void 0!==a?a:t,n="object"==typeof e.source?null===(s=e.source)||void 0===s?void 0:s.id:e.source,r="object"==typeof e.target?null===(c=e.target)||void 0===c?void 0:c.id:e.target,o="number"==typeof e.value&&Number.isFinite(e.value)?e.value:0;if(null!=n&&""!==n){const t=n+"";C.set(t,(null!==(u=C.get(t))&&void 0!==u?u:0)+1),N.set(t,(null!==(h=N.get(t))&&void 0!==h?h:0)+o)}if(null!=r&&""!==r){const t=r+"";L.set(t,(null!==(d=L.get(t))&&void 0!==d?d:0)+1),$.set(t,(null!==(f=$.get(t))&&void 0!==f?f:0)+o)}}const O=[];for(let t=0;D.length>t;t++){const e=D[t];if(!e||"object"!=typeof e)continue;const n=null!==(g=null===(y=e.datum)||void 0===y?void 0:y.id)&&void 0!==g?g:e.id,r=null!=n?n+"":"node-"+t,o=null!==(p=L.get(r))&&void 0!==p?p:0,i=null!==(m=C.get(r))&&void 0!==m?m:0,l=null!==(v=$.get(r))&&void 0!==v?v:0,a=null!==(x=N.get(r))&&void 0!==x?x:0;O.push({id:r,degree:o+i,inDeg:o,outDeg:i,wDegree:l+a,wInDeg:l,wOutDeg:a})}O.sort((t,e)=>e.degree-t.degree);let W=0,I=0;if(O.length>0){let t=0;for(const e of O)t+=e.degree,e.degree>I&&(I=e.degree);W=t/O.length}const z=T.some(t=>{var e;const n=null!==(e=null==t?void 0:t.datum)&&void 0!==e?e:t;return"number"==typeof(null==n?void 0:n.value)&&Number.isFinite(n.value)}),B=[`${O.length} nodes, ${T.length} edges.`];O.length>0&&B.push(`Mean degree: ${Fe(W)}, max degree: ${I}.`);const j=O.slice(0,5);return t.createElement("div",{ref:S,id:o,tabIndex:-1,onBlur:P,style:Re,role:"region","aria-label":M},t.createElement("button",{type:"button",onClick:()=>{E&&w&&w.setVisible(!1),k(!1)},"aria-label":"Close data summary",style:He},"×"),t.createElement("div",{role:"note",style:Ye},B.join(" ")),t.createElement("table",{role:"table","aria-label":"Node degree summary for "+r,style:Xe},t.createElement("caption",{style:qe},"Top ",j.length," of ",O.length," nodes by degree"),t.createElement("thead",null,t.createElement("tr",null,t.createElement("th",{style:Ge},"id"),t.createElement("th",{style:Ge},"degree"),t.createElement("th",{style:Ge},"in"),t.createElement("th",{style:Ge},"out"),z&&t.createElement("th",{style:Ge},"w. degree"),z&&t.createElement("th",{style:Ge},"w. in"),z&&t.createElement("th",{style:Ge},"w. out"))),t.createElement("tbody",null,j.map((e,n)=>t.createElement("tr",{key:n},t.createElement("td",{style:Ve},e.id),t.createElement("td",{style:Ve},e.degree),t.createElement("td",{style:Ve},e.inDeg),t.createElement("td",{style:Ve},e.outDeg),z&&t.createElement("td",{style:Ve},Fe(e.wDegree)),z&&t.createElement("td",{style:Ve},Fe(e.wInDeg)),z&&t.createElement("td",{style:Ve},Fe(e.wOutDeg)))))))}function Ze({summary:e}){return e?t.createElement("div",{role:"note",style:ze},e):null}function Qe({tableId:e}){return t.createElement("a",{href:"#"+e,style:ze,onClick:t=>{t.preventDefault();const n=document.getElementById(e);n&&requestAnimationFrame(()=>n.focus())},onFocus:t=>{Object.assign(t.currentTarget.style,{position:"absolute",width:"auto",height:"auto",overflow:"visible",clip:"auto",whiteSpace:"normal",padding:"4px 8px",background:"var(--semiotic-bg, #fff)",color:"var(--semiotic-text, #000)",border:"2px solid var(--semiotic-focus, #005fcc)",borderRadius:"4px",zIndex:"10",fontSize:"12px",top:"4px",left:"4px"})},onBlur:t=>{const e=t.currentTarget;e.removeAttribute("style"),Object.assign(e.style,ze)}},"Skip to data table")}function Je({hoverPoint:e}){let n="";if(e){const t=e.data||e;n="object"==typeof t?"Focused on data point: "+Object.entries(t).filter(([,t])=>"object"!=typeof t&&"function"!=typeof t).map(([t,e])=>`${t}: ${e}`).join(", "):"Focused on data point: "+t}return t.createElement("div",{"aria-live":"polite","aria-atomic":"true",style:ze},n)}const tn="var(--semiotic-focus, #005fcc)";function en({active:e,hoverPoint:n,margin:r,size:o,shape:i="circle",width:l,height:a}){if(!e||!n)return null;const s=n.x+r.left,c=n.y+r.top;let u;if("rect"===i&&null!=l&&null!=a){const e=Math.max(l,4),n=Math.max(a,4);u=t.createElement("rect",{x:s-e/2-3,y:c-n/2-3,width:e+6,height:n+6,rx:3,fill:"none",stroke:tn,strokeWidth:2,strokeDasharray:"4,2"})}else u=t.createElement("circle","wedge"===i?{cx:s,cy:c,r:12,fill:"none",stroke:tn,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:s,cy:c,r:8,fill:"none",stroke:tn,strokeWidth:2,strokeDasharray:"4,2"});return t.createElement("svg",{style:{position:"absolute",left:0,top:0,width:o[0],height:o[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true"},u)}function nn({x:e,y:n,containerWidth:r,containerHeight:o,margin:i,children:l,className:a="stream-frame-tooltip",zIndex:s=1}){const c=t.useRef(null),[u,h]=t.useState(null);t.useLayoutEffect(()=>{const t=c.current;if(!t)return;const e=t.getBoundingClientRect();h(t=>t&&t.width===e.width&&t.height===e.height?t:{width:e.width,height:e.height})},[l,a,r,o]);let d;return d=u?`translate(${u.width+12>r-e?"calc(-100% - 12px)":"12px"}, ${u.height+12>o-n?"calc(-100% - 4px)":"4px"})`:`translate(${e>.7*r?"calc(-100% - 12px)":"12px"}, ${.3*o>n?"4px":"calc(-100% - 4px)"})`,t.createElement("div",{ref:c,className:a,style:{position:"absolute",left:i.left+e,top:i.top+n,transform:d,pointerEvents:"none",zIndex:s,width:"max-content"}},l)}function rn(){const[t,e]=o(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return r(()=>{if("undefined"==typeof window||!window.matchMedia)return;const t=window.matchMedia("(prefers-reduced-motion: reduce)");return e(t.matches),function(t,e){return"function"==typeof t.addEventListener?(t.addEventListener("change",e),()=>t.removeEventListener("change",e)):(t.addListener(e),()=>t.removeListener(e))}(t,t=>e(t.matches))},[]),t}function on(r){const o=l(null),c=ln(r);return[function({children:e}){const i=n(()=>ln(r),[]);return t.createElement(o.Provider,{value:i,children:e})},t=>{var n;const r=null!==(n=a(o))&&void 0!==n?n:c,l=e(t);l.current=t;const u=s(()=>l.current(r.getState()),[r]),h=s(()=>l.current(r.getState()),[r]);return i(r.subscribe,u,h)}]}function ln(t){const e=new EventTarget;let n=t(function(t){n=Object.assign(Object.assign({},n),t(n)),e.dispatchEvent(new CustomEvent("update"))});return{getState:()=>n,subscribe:function(t){return e.addEventListener("update",t),()=>e.removeEventListener("update",t)}}}const an={mode:"light",colors:{primary:"#00a2ce",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",background:"transparent",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},sn={mode:"dark",colors:{primary:"#4fc3f7",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",background:"#1a1a2e",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},cn={mode:"light",colors:{primary:"#0000cc",categorical:["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],sequential:"blues",diverging:"RdBu",background:"#ffffff",text:"#000000",textSecondary:"#333333",grid:"#999999",border:"#000000",focus:"#0000cc",selection:"#0000cc",selectionOpacity:.1},typography:{fontFamily:"system-ui, sans-serif",titleSize:18,labelSize:14,tickSize:12},tooltip:{background:"#000000",text:"#ffffff",borderRadius:"4px",fontSize:"14px",shadow:"0 2px 8px rgba(0, 0, 0, 0.3)"},borderRadius:"4px"},[un,hn]=on(t=>({theme:an,setTheme(e){t(t=>{if("light"===e)return{theme:an};if("dark"===e)return{theme:sn};if("high-contrast"===e)return{theme:cn};if(e.mode&&"auto"!==e.mode){const t="dark"===e.mode?sn:an;return{theme:Object.assign(Object.assign(Object.assign({},t),e),{colors:Object.assign(Object.assign({},t.colors),e.colors||{}),typography:Object.assign(Object.assign({},t.typography),e.typography||{})})}}return{theme:Object.assign(Object.assign(Object.assign({},t.theme),e),{colors:Object.assign(Object.assign({},t.theme.colors),e.colors||{}),typography:Object.assign(Object.assign({},t.theme.typography),e.typography||{})})}})}}));function dn(t,e,n,r){const o=t.getContext("2d");if(!o)return null;const i=e[0]*r,l=e[1]*r,a=e[0]+"px",s=e[1]+"px";return t.style.width!==a&&(t.style.width=a),t.style.height!==s&&(t.style.height=s),t.width===i&&t.height===l||(t.width=i,t.height=l),o.setTransform(r,0,0,r,0,0),o.translate(n.left,n.top),o}function fn(){return"undefined"!=typeof window&&window.devicePixelRatio||1}function yn(t){switch(t){case"monotoneX":return q;case"monotoneY":return V;case"cardinal":return R;case"catmullRom":return F;case"step":return G;case"stepBefore":return H;case"stepAfter":return X;case"basis":return Y;case"natural":return Q;default:return null}}function gn(t,e,n){let r=n;for(const n of e)"lesser"===n.thresholdType?n.value>t&&(r=n.color):t>n.value&&(r=n.color);return r}function pn(t,e,n,r,o,i){if(2>e.length)return;const l=[0];for(let t=1;e.length>t;t++){const n=e[t][0]-e[t-1][0],r=e[t][1]-e[t-1][1];l.push(l[t-1]+Math.sqrt(n*n+r*r))}const a=l[l.length-1];if(0===a)return;const s=Math.min(.2*a,40);t.strokeStyle=n,t.lineWidth=r,t.lineCap=i;for(let n=0;e.length-1>n;n++){const r=(l[n]+l[n+1])/2;let i=o;s>r&&(i*=r/s),s>a-r&&(i*=(a-r)/s),t.globalAlpha=Math.max(0,i),t.beginPath(),t.moveTo(e[n][0],e[n][1]),t.lineTo(e[n+1][0],e[n+1][1]),t.stroke()}}function mn(t){return!(!t._pulseIntensity||0>=t._pulseIntensity)}function vn(t,e,n=.3){mn(e)&&(t.globalAlpha=e._pulseIntensity*n,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fillRect(e.x,e.y,e.w,e.h))}function xn(t,e,n=.6){var r,o,i,l,a;if(!mn(e))return;const s=null!==(r=e._pulseGlowRadius)&&void 0!==r?r:4,c=e.r+s*e._pulseIntensity,u=null!==(i=null!==(o=e.cx)&&void 0!==o?o:e.x)&&void 0!==i?i:0,h=null!==(a=null!==(l=e.cy)&&void 0!==l?l:e.y)&&void 0!==a?a:0;t.beginPath(),t.arc(u,h,c,0,2*Math.PI),t.strokeStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.lineWidth=2*e._pulseIntensity,t.globalAlpha=e._pulseIntensity*n,t.stroke()}function bn(t,e,n,r=.35){mn(e)&&(t.globalAlpha=e._pulseIntensity*r,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fill())}function kn(t){switch(t){case"monotoneX":return q;case"monotoneY":return V;case"cardinal":return R;case"catmullRom":return F;case"step":return G;case"stepBefore":return H;case"stepAfter":return X;case"basis":return Y;case"natural":return Q;default:return null}}function wn(t){if(t.startsWith("#")){const e=4===t.length?t[1]+t[1]+t[2]+t[2]+t[3]+t[3]:t.slice(1,7);return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[78,121,167]}function En(t,e){const n=kn(e.curve);if(!n||2>e.topPath.length||2>e.bottomPath.length){t.beginPath(),t.moveTo(e.topPath[0][0],e.topPath[0][1]);for(let n=1;e.topPath.length>n;n++)t.lineTo(e.topPath[n][0],e.topPath[n][1]);for(let n=e.bottomPath.length-1;n>=0;n--)t.lineTo(e.bottomPath[n][0],e.bottomPath[n][1]);t.closePath()}else{const r=j().x(t=>t[0]).y0((t,n)=>e.bottomPath[n][1]).y1(t=>t[1]).curve(n).context(t);t.beginPath(),r(e.topPath)}}const An=(t,e,n,r)=>{var o,i,l;const a=e.filter(t=>"area"===t.type);for(const e of a){if(2>e.topPath.length)continue;const n=e.style.fill||"#4e79a7",r=e._decayOpacities;if(r&&r.length===e.topPath.length){const i=null!==(o=e.style.fillOpacity)&&void 0!==o?o:.7;t.fillStyle=n;for(let n=0;e.topPath.length-1>n;n++)t.globalAlpha=.5*(r[n]+r[n+1])*i,t.beginPath(),t.moveTo(e.topPath[n][0],e.topPath[n][1]),t.lineTo(e.topPath[n+1][0],e.topPath[n+1][1]),t.lineTo(e.bottomPath[n+1][0],e.bottomPath[n+1][1]),t.lineTo(e.bottomPath[n][0],e.bottomPath[n][1]),t.closePath(),t.fill();if(e.style.stroke&&"none"!==e.style.stroke){t.strokeStyle=e.style.stroke,t.lineWidth=e.style.strokeWidth||2,t.setLineDash([]);for(let n=0;e.topPath.length-1>n;n++)t.globalAlpha=.5*(r[n]+r[n+1]),t.beginPath(),t.moveTo(e.topPath[n][0],e.topPath[n][1]),t.lineTo(e.topPath[n+1][0],e.topPath[n+1][1]),t.stroke()}t.globalAlpha=1;continue}const a=null!==(i=e.style.opacity)&&void 0!==i?i:1;if(En(t,e),e.fillGradient){let r=1/0;for(const t of e.topPath)r>t[1]&&(r=t[1]);let o=-1/0;for(const t of e.bottomPath)t[1]>o&&(o=t[1]);const i=wn("string"==typeof n?n:"#4e79a7"),l=e.fillGradient.topOpacity,s=e.fillGradient.bottomOpacity,c=t.createLinearGradient(0,r,0,o);c.addColorStop(0,`rgba(${i[0]},${i[1]},${i[2]},${l})`),c.addColorStop(1,`rgba(${i[0]},${i[1]},${i[2]},${s})`),t.fillStyle=c,t.globalAlpha=a}else{const r=null!==(l=e.style.fillOpacity)&&void 0!==l?l:.7;t.globalAlpha=r*a,t.fillStyle=n}if(t.fill(),e._pulseIntensity&&e._pulseIntensity>0&&(En(t,e),bn(t,e)),e.style.stroke&&"none"!==e.style.stroke){t.globalAlpha=a,t.strokeStyle=e.style.stroke,t.lineWidth=e.style.strokeWidth||2,t.setLineDash([]);const n=kn(e.curve);if(t.beginPath(),n)Z().x(t=>t[0]).y(t=>t[1]).curve(n).context(t)(e.topPath);else{t.moveTo(e.topPath[0][0],e.topPath[0][1]);for(let n=1;e.topPath.length>n;n++)t.lineTo(e.topPath[n][0],e.topPath[n][1])}t.stroke()}t.globalAlpha=1}},Mn=(t,e,n,r)=>{var o;const i=e.filter(t=>"point"===t.type);if(0!==i.length){t.save();try{for(const e of i){t.beginPath(),t.arc(e.x,e.y,e.r,0,2*Math.PI);const n=null!==(o=e.style.opacity)&&void 0!==o?o:e.style.fillOpacity;null!=n&&(t.globalAlpha=n),t.fillStyle=e.style.fill||"#4e79a7",t.fill(),e.style.stroke&&(t.strokeStyle=e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.stroke()),xn(t,e),t.globalAlpha=1}}finally{t.restore()}}},Sn=(t,e,n,r)=>{const o=e.filter(t=>"rect"===t.type);for(const e of o)null!=e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.icon?_n(t,e):(t.fillStyle=e.style.fill||"#007bff",t.fillRect(e.x,e.y,e.w,e.h),e.style.stroke&&(t.strokeStyle=e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.strokeRect(e.x,e.y,e.w,e.h))),vn(t,e),t.globalAlpha=1};function _n(t,e){const n=e.style.icon,r=e.style.iconPadding||2,o=Math.min(e.w,e.h)-r;if(0>=o)return;const i=e.h>e.w;if(t.save(),t.beginPath(),t.rect(e.x,e.y,e.w,e.h),t.clip(),i){const i=o+r,l=e.x+(e.w-o)/2;for(let r=e.y+e.h-o;r>=e.y-o;r-=i)t.drawImage(n,l,r,o,o)}else{const i=o+r,l=e.y+(e.h-o)/2;for(let r=e.x;e.x+e.w>r;r+=i)t.drawImage(n,r,l,o,o)}t.restore()}function Pn(t){const[e,n,r]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(t);return.299*e+.587*n+.114*r>128?"#000":"#fff"}function Dn(t){return Number.isInteger(t)?t+"":100>Math.abs(t)?1>Math.abs(t)?t.toPrecision(3):t.toFixed(1):t.toFixed(0)}const Tn=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Ln(t){const e=t[1]-t[0],n=3156e7;return 864e5>e?t=>{const e=new Date(t);return`${(e.getUTCHours()+"").padStart(2,"0")}:${(e.getUTCMinutes()+"").padStart(2,"0")}`}:n>e?t=>{const e=new Date(t);return`${Tn[e.getUTCMonth()]} ${e.getUTCDate()}`}:5*n>e?t=>{const e=new Date(t);return`${Tn[e.getUTCMonth()]} ${e.getUTCFullYear()}`}:t=>new Date(t).getUTCFullYear()+""}const Cn={line:[An,(t,e,n,r)=>{var o,i;const l=e.filter(t=>"line"===t.type);for(const a of l){if(2>a.path.length)continue;const s=a.style.stroke||"#007bff",c=a.style.strokeWidth||2,u=a.colorThresholds,h=a.rawValues;if(t.setLineDash(a.style.strokeDasharray?a.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=a.style.opacity&&(t.globalAlpha=a.style.opacity),t.lineWidth=c,t.lineCap=a.style.strokeLinecap||"butt",a.style._edgeFade){const g=null!==(o=a.style.opacity)&&void 0!==o?o:1;pn(t,a.path,s,c,g,a.style.strokeLinecap||"butt"),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt";continue}const d=yn(a.curve),f=u&&u.length>0&&h&&h.length===a.path.length,y=a._decayOpacities;if(y&&y.length===a.path.length&&!f){t.strokeStyle=s;const p=null!==(i=a.style.opacity)&&void 0!==i?i:1;for(let m=0;a.path.length-1>m;m++)t.globalAlpha=.5*(y[m]+y[m+1])*p,t.beginPath(),t.moveTo(a.path[m][0],a.path[m][1]),t.lineTo(a.path[m+1][0],a.path[m+1][1]),t.stroke()}else if(f){let v=null,x=null,b=null,k=null,w=!1;function E(e,n,r){t.beginPath(),t.strokeStyle=e,t.moveTo(n,r),w=!0}function A(){w&&(t.stroke(),w=!1)}for(let M=0;a.path.length>M;M++){const[S,_]=a.path[M],P=h[M],D=gn(P,u,s);if(null!==v&&null!==k&&null!==b){if(D===k)t.lineTo(S,_);else{const T=[];for(const L of u){const C=L.value;(b>C||C>P)&&(C>b||P>C)||b===C||P===C||T.push({t:(C-b)/(P-b)})}T.sort((t,e)=>t.t-e.t);for(const $ of T){const N=v+(S-v)*$.t,O=x+(_-x)*$.t,W=gn(b+(P-b)*Math.min($.t+1e-4,1),u,s);t.lineTo(N,O),A(),E(W,N,O)}t.lineTo(S,_)}v=S,x=_,b=P,k=D}else E(D,S,_),v=S,x=_,b=P,k=D}A()}else{if(t.beginPath(),t.strokeStyle=s,d)Z().x(t=>t[0]).y(t=>t[1]).curve(d).context(t)(a.path);else{const[I,z]=a.path[0];t.moveTo(I,z);for(let B=1;a.path.length>B;B++)t.lineTo(a.path[B][0],a.path[B][1])}t.stroke()}if(a.style.fill&&a.style.fillOpacity&&a.style.fillOpacity>0){if(t.beginPath(),t.globalAlpha=a.style.fillOpacity,t.fillStyle=a.style.fill,d&&!f)Z().x(t=>t[0]).y(t=>t[1]).curve(d).context(t)(a.path);else{const[F,R]=a.path[0];t.moveTo(F,R);for(let Y=1;a.path.length>Y;Y++)t.lineTo(a.path[Y][0],a.path[Y][1])}const j=a.path[0][0];t.lineTo(a.path[a.path.length-1][0],r.height),t.lineTo(j,r.height),t.closePath(),t.fill()}t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt"}},Mn],area:[An,Mn],stackedarea:[An,Mn],scatter:[Mn],bubble:[Mn],heatmap:[(t,e,n,r)=>{const o=e.filter(t=>"heatcell"===t.type);t.save();try{for(const e of o){const n=e.style;if(null!=(null==n?void 0:n.opacity)&&(t.globalAlpha=n.opacity),t.fillStyle=e.fill,t.fillRect(e.x,e.y,e.w,e.h),t.strokeStyle="#fff",t.lineWidth=1,t.strokeRect(e.x,e.y,e.w,e.h),vn(t,e),t.globalAlpha=1,e.showValues&&null!=e.value){if(20>e.w||20>e.h)continue;const n=e.valueFormat?e.valueFormat(e.value):Dn(e.value),r=Math.max(10,Math.min(16,.3*Math.min(e.w,e.h))),o=e.x+e.w/2,i=e.y+e.h/2;t.fillStyle=Pn(e.fill),t.font=r+"px sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText(n,o,i)}}}finally{t.restore()}}],bar:[Sn],swarm:[Mn],waterfall:[(t,e,n,r)=>{var o,i,l;Sn(t,e);const a=e.filter(t=>"rect"===t.type);if(2>a.length)return;const s=a[0].datum,c=null==s?void 0:s._connectorStroke;if(c){t.save(),t.strokeStyle=c,t.lineWidth=null!==(o=null==s?void 0:s._connectorWidth)&&void 0!==o?o:1,t.setLineDash([]);for(let e=0;a.length-1>e;e++){const r=a[e],o=a[e+1];if(!(null===(i=r.datum)||void 0===i?void 0:i.cumEnd)||!(null===(l=o.datum)||void 0===l?void 0:l.baseline))continue;const s=n.y(r.datum.cumEnd),c=r.x+r.w,u=o.x;t.beginPath(),t.moveTo(c,s),t.lineTo(u,s),t.stroke()}t.restore()}}],candlestick:[(t,e,n,r)=>{for(const n of e){if("candlestick"!==n.type)continue;const e=n;t.save();const r=e._decayOpacity;null!=r&&1!==r&&(t.globalAlpha=r),t.beginPath(),t.moveTo(e.x,e.highY),t.lineTo(e.x,e.lowY),t.strokeStyle=e.wickColor,t.lineWidth=e.wickWidth,t.stroke();const o=Math.min(e.openY,e.closeY),i=Math.abs(e.openY-e.closeY),l=e.isUp?e.upColor:e.downColor;t.fillStyle=l,t.fillRect(e.x-e.bodyWidth/2,o,e.bodyWidth,Math.max(i,1)),t.strokeStyle=l,t.lineWidth=1,t.strokeRect(e.x-e.bodyWidth/2,o,e.bodyWidth,Math.max(i,1)),t.restore()}}]},$n={top:20,right:20,bottom:30,left:40},Nn={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"},On={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 Wn({hover:e}){const n=t=>Number.isInteger(t)?t+"":t.toFixed(2);return t.createElement("div",{className:"semiotic-tooltip",style:On},t.createElement("div",{style:{fontWeight:600,marginBottom:2}},n(e.value)),t.createElement("div",{style:{opacity:.7,fontSize:11}},n(e.time)))}const In=c(function(i,l){var a,c,h,d,f,y,g,p,m,v,x;const{chartType:b,runtimeMode:k,data:w,chunkThreshold:E,chunkSize:A,xAccessor:M,yAccessor:S,colorAccessor:_,sizeAccessor:P,groupAccessor:D,lineDataAccessor:T,curve:L,normalize:C,binSize:$,valueAccessor:N,arrowOfTime:O="right",windowMode:W="sliding",windowSize:I=200,timeAccessor:z,xExtent:B,yExtent:j,extentPadding:F=.1,sizeRange:R,size:Y=[500,300],responsiveWidth:H,responsiveHeight:X,margin:G,className:V,background:q,lineStyle:U,pointStyle:K,areaStyle:Z,waterfallStyle:Q,swarmStyle:J,barColors:tt,colorScheme:et,boundsAccessor:nt,boundsStyle:rt,y0Accessor:ot,gradientFill:it,openAccessor:lt,highAccessor:at,lowAccessor:st,closeAccessor:ct,candlestickStyle:ut,showAxes:ht=!0,axes:yt,xLabel:gt,yLabel:pt,yLabelRight:mt,xFormat:vt,yFormat:xt,tickFormatTime:bt,tickFormatValue:kt,hoverAnnotation:wt,tooltipContent:Et,customHoverBehavior:At,enableHover:Mt,annotations:St,svgAnnotationRules:_t,showGrid:Pt,legend:Dt,legendHoverBehavior:Tt,legendClickBehavior:Lt,legendHighlightedCategory:Ct,legendIsolatedCategories:$t,legendPosition:Nt,backgroundGraphics:Ot,foregroundGraphics:Wt,canvasPreRenderers:zt,svgPreRenderers:Bt,title:Rt,categoryAccessor:Vt,brush:Zt,onBrush:ee,decay:ne,pulse:re,transition:oe,staleness:ie,heatmapAggregation:le,heatmapXBins:ae,heatmapYBins:se,showValues:ce,heatmapValueFormat:ue,marginalGraphics:he,pointIdAccessor:de,xScaleType:fe,yScaleType:ye,accessibleTable:ge=!0,description:pe,summary:me,linkedCrosshairName:ve,linkedCrosshairSourceId:xe}=i,be=rn(),ke=e(be);ke.current=be;const[we,Ee]=Jt(Y,H,X),Ae=Object.assign(Object.assign({},$n),G);if(he){const t=60;he.top&&t>Ae.top&&(Ae.top=t),he.bottom&&t>Ae.bottom&&(Ae.bottom=t),he.left&&t>Ae.left&&(Ae.left=t),he.right&&t>Ae.right&&(Ae.right=t)}const Me=Ee[0]-Ae.left-Ae.right,Se=Ee[1]-Ae.top-Ae.bottom,_e="function"==typeof Wt?Wt({size:Ee,margin:Ae}):Wt,Pe="function"==typeof Ot?Ot({size:Ee,margin:Ae}):Ot,Te=null!=wt?wt:Mt,Le=e(null),Ce=e(null),We=e(0),Ie=e(!1),ze=hn(t=>t.theme),[je,Fe]=o(0),[Re,Ye]=o(null),He=e(null),Xe=e(null),[Ge,Ve]=o(null),[qe,Ke]=o(!1),[tn,on]=o([]),[ln,an]=o([]),sn=e(()=>{}),cn="streaming"===k||["bar","swarm","waterfall"].includes(b),un=n(()=>({chartType:b,runtimeMode:cn?"streaming":"bounded",windowSize:I,windowMode:W,arrowOfTime:cn?O:"right",extentPadding:F,xAccessor:cn?void 0:M,yAccessor:cn?void 0:S,timeAccessor:cn?z:void 0,valueAccessor:N,colorAccessor:_,sizeAccessor:P,groupAccessor:D,categoryAccessor:Vt,lineDataAccessor:T,xScaleType:fe,yScaleType:ye,xExtent:B,yExtent:j,sizeRange:R,binSize:$,normalize:C,boundsAccessor:nt,boundsStyle:rt,y0Accessor:ot,gradientFill:"boolean"==typeof it?it?{topOpacity:.8,bottomOpacity:.05}:void 0:it,openAccessor:lt,highAccessor:at,lowAccessor:st,closeAccessor:ct,candlestickStyle:ut,lineStyle:U,pointStyle:K,areaStyle:Z,swarmStyle:J,waterfallStyle:Q,colorScheme:et,barColors:tt,annotations:St,decay:ne,pulse:re,transition:oe,staleness:ie,heatmapAggregation:le,heatmapXBins:ae,heatmapYBins:se,showValues:ce,heatmapValueFormat:ue,pointIdAccessor:de,curve:L}),[b,I,W,O,F,M,S,z,N,fe,ye,_,P,D,Vt,T,B,j,R,$,C,nt,rt,ot,it,lt,at,st,ct,ut,U,K,Z,J,Q,et,tt,St,ne,re,oe,ie,le,ae,se,ce,ue,cn,de,L]),yn=e(null);yn.current||(yn.current=new It(un));const gn=s(()=>{We.current||(We.current=requestAnimationFrame(()=>sn.current()))},[]);r(()=>{var t;null===(t=yn.current)||void 0===t||t.updateConfig(un),Ie.current=!0,gn()},[un,gn]),r(()=>{Ie.current=!0,gn()},[ze,gn]);const pn=e(null);pn.current||(pn.current=new ft(t=>{const e=yn.current;e&&e.ingest(t)&&(Ie.current=!0,gn())},{chunkThreshold:E,chunkSize:A})),r(()=>{var t;null===(t=pn.current)||void 0===t||t.updateChunkOptions({chunkThreshold:E,chunkSize:A})},[E,A]);const mn=s(t=>{var e;null===(e=pn.current)||void 0===e||e.push(t)},[]),vn=s(t=>{var e;null===(e=pn.current)||void 0===e||e.pushMany(t)},[]),xn=s(()=>{var t,e;null===(t=pn.current)||void 0===t||t.clear(),null===(e=yn.current)||void 0===e||e.clear(),Ie.current=!0,gn()},[gn]);u(l,()=>({push:mn,pushMany:vn,clear:xn,getData:()=>{var t,e,n;return null===(t=pn.current)||void 0===t||t.flush(),null!==(n=null===(e=yn.current)||void 0===e?void 0:e.getData())&&void 0!==n?n:[]},getScales:()=>{var t,e;return null!==(e=null===(t=yn.current)||void 0===t?void 0:t.scales)&&void 0!==e?e:null},getExtents:()=>{var t,e;return null!==(e=null===(t=yn.current)||void 0===t?void 0:t.getExtents())&&void 0!==e?e:null}}),[mn,vn,xn]),r(()=>{var t;w&&(null===(t=pn.current)||void 0===t||t.setBoundedData(w))},[w]);const bn=e(()=>{}),kn=e(()=>{});bn.current=t=>{if(!Te)return;const e=Le.current;if(!e)return;const n=e.getBoundingClientRect(),r=t.clientX-n.left-Ae.left,o=t.clientY-n.top-Ae.top;if(0>r||r>Me||0>o||o>Se)return void(He.current&&(He.current=null,Xe.current=null,Ve(null),At&&(At(null),Ie.current=!0),gn()));const i=yn.current;if(!i||0===i.scene.length)return;const l=function(t,e,n,r=30,o){let i=null,l=!1;if(o){const t=o.find(e,n,r);if(t){const o=jt(t,e,n);o&&r>o.distance&&(i=o,l=!0)}}for(const a of t){let t=null;switch(a.type){case"point":if(o&&l)break;t=jt(a,e,n);break;case"line":t=Ft(a,e,n);break;case"rect":t=Yt(a,e,n);break;case"heatcell":t=Ht(a,e,n);break;case"area":if(!1===a.interactive)break;t=Gt(a,e,n);break;case"candlestick":t=Xt(a,e,n)}t&&r>t.distance&&(i&&t.distance>=i.distance||(i=t))}return i}(i.scene,r,o,30,i.quadtree);if(!l)return void(He.current&&(He.current=null,Xe.current=null,Ve(null),At&&At(null),gn()));const a=l.datum||{},s=Object.assign(Object.assign({},"object"!=typeof a||null===a||Array.isArray(a)?{}:a),{data:a,time:l.x,value:l.y,x:l.x,y:l.y});He.current=s,Xe.current=l.node,Ve(s),At&&(At(s),Ie.current=!0),gn()},kn.current=()=>{He.current&&(He.current=null,Xe.current=null,Ve(null),At&&(At(null),Ie.current=!0),gn())},s(t=>bn.current(t),[]);const wn=s(()=>kn.current(),[]),En=e(-1),An=e(null),Mn=e(null),Sn=s(t=>{const e=yn.current;if(!e||0===e.scene.length)return;const n=e.version;let r;if(Mn.current&&Mn.current.version===n)r=Mn.current.graph;else{const t=function(t){var e,n,r,o;const i=[];for(const l of t)switch(l.type){case"point":i.push({x:l.x,y:l.y,datum:l.datum,shape:"circle",group:null!==(e=l.group)&&void 0!==e?e:"_default"});break;case"line":{const t=l,e=Array.isArray(t.datum)?t.datum:[],r=null!==(n=t.group)&&void 0!==n?n:"_default";for(let n=0;t.path.length>n&&e.length>n;n++)i.push({x:t.path[n][0],y:t.path[n][1],datum:e[n],shape:"circle",group:r});break}case"area":{const t=l,e=Array.isArray(t.datum)?t.datum:[],n=null!==(r=t.group)&&void 0!==r?r:"_default";for(let r=0;t.topPath.length>r&&e.length>r;r++)i.push({x:t.topPath[r][0],y:t.topPath[r][1],datum:e[r],shape:"circle",group:n});break}case"rect":i.push({x:l.x+l.w/2,y:l.y+l.h/2,datum:l.datum,shape:"rect",w:l.w,h:l.h,group:null!==(o=l.group)&&void 0!==o?o:"_default"});break;case"heatcell":i.push({x:l.x+l.w/2,y:l.y+l.h/2,datum:l.datum,shape:"rect",w:l.w,h:l.h,group:"_default"})}return i.sort((t,e)=>t.x-e.x||t.y-e.y),i}(e.scene);if(0===t.length)return;r=qt(t),Mn.current={version:n,graph:r}}const o=En.current;if(0>o){if("Escape"===t.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(t.key))return;t.preventDefault(),En.current=0;const e=r.flat[0];An.current={shape:e.shape,w:e.w,h:e.h};const n=Qt(e);return He.current=n,Ve(n),At&&At(n),void gn()}const i=Ut(r,o),l=Kt(t.key,i,r);if(null===l)return;if(t.preventDefault(),0>l)return En.current=-1,An.current=null,He.current=null,Xe.current=null,Ve(null),At&&At(null),void gn();En.current=l;const a=r.flat[l];An.current={shape:a.shape,w:a.w,h:a.h};const s=Qt(a);He.current=s,Ve(s),At&&At(s),gn()},[At,gn]),_n=s(t=>{En.current=-1,An.current=null,bn.current(t)},[]);sn.current=()=>{var t,e;We.current=0;const n=Le.current,r=Ce.current;if(!n||!r)return;const o=yn.current;if(!o)return;const i="undefined"!=typeof performance?performance.now():Date.now(),l=o.advanceTransition(ke.current?i+1e6:i),a=!ke.current&&l,s=Ie.current||l;s&&!a&&o.computeScene({width:Me,height:Se});const c=fn(),u=function(t){if(!t)return Nn;const e=getComputedStyle(t),n=e.getPropertyValue("--semiotic-border").trim(),r=e.getPropertyValue("--semiotic-text-secondary").trim(),o=e.getPropertyValue("--semiotic-bg").trim(),i=r||e.getPropertyValue("--text-secondary").trim(),l=e.getPropertyValue("--text-primary").trim(),a=n||e.getPropertyValue("--surface-3").trim(),s=o||e.getPropertyValue("--surface-0").trim();return i||l||n?{axisStroke:a||Nn.axisStroke,tickText:i||Nn.tickText,crosshair:i?i+"66":Nn.crosshair,hoverFill:s?s+"4D":Nn.hoverFill,hoverStroke:i?i+"99":Nn.hoverStroke,pointRing:s||Nn.pointRing}:Nn}(n),h=null!==(t=null==ie?void 0:ie.threshold)&&void 0!==t?t:5e3,d=ie&&o.lastIngestTime>0&&i-o.lastIngestTime>h;if(s){const t=dn(n,Ee,Ae,c);if(t){t.clearRect(-Ae.left,-Ae.top,Ee[0],Ee[1]),d&&(t.globalAlpha=null!==(e=null==ie?void 0:ie.dimOpacity)&&void 0!==e?e:.5);const r=getComputedStyle(n).getPropertyValue("--semiotic-bg").trim(),i=q||(r&&"transparent"!==r?r:null);if(i&&(t.fillStyle=i,t.fillRect(-Ae.left,-Ae.top,Ee[0],Ee[1])),t.save(),"function"==typeof t.rect&&(t.beginPath(),t.rect(0,0,Me,Se),t.clip()),zt&&o.scales)for(const e of zt)t.save(),e(t,o.scene,o.scales,{width:Me,height:Se}),t.restore();const l=Cn[b];if(l&&o.scales)for(const e of l)e(t,o.scene,o.scales,{width:Me,height:Se});t.restore(),d&&(t.globalAlpha=1)}}{const t=dn(r,Ee,Ae,c);if(t&&(t.clearRect(-Ae.left,-Ae.top,Ee[0],Ee[1]),Te&&He.current&&o.scales&&function(t,e,n,r,o,i,l){var a;if(!1===o.crosshair)return;t.save();const s="object"==typeof o.crosshair?o.crosshair:{};t.strokeStyle=s.stroke||l.crosshair,t.lineWidth=s.strokeWidth||1,t.setLineDash(s.strokeDasharray?s.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),t.beginPath(),t.moveTo(e.x,0),t.lineTo(e.x,r),t.stroke(),t.beginPath(),t.moveTo(0,e.y),t.lineTo(n,e.y),t.stroke(),t.restore();let c="";try{(null===(a=t.canvas)||void 0===a?void 0:a.parentElement)&&(c=getComputedStyle(t.canvas).getPropertyValue("--semiotic-primary").trim())}catch(t){}const u=o.pointColor||function(t){if(!t)return null;if("heatcell"===t.type)return t.fill||null;if("candlestick"===t.type)return t.isUp?t.upColor:t.downColor;const{style:e}=t;if(!e)return null;const n="string"==typeof e.fill?e.fill:null;return"line"===t.type||"area"===t.type?e.stroke||n||null:n||e.stroke||null}(i)||c||"#007bff";t.beginPath(),t.arc(e.x,e.y,4,0,2*Math.PI),t.fillStyle=u,t.fill(),t.strokeStyle=l.pointRing,t.lineWidth=2,t.stroke()}(t,He.current,Me,Se,"object"==typeof Te?Te:{},Xe.current,u),Xe.current&&Array.isArray(wt))){const e=wt.find(t=>t&&"object"==typeof t&&"highlight"===t.type);e&&function(t,e,n,r){var o;if(!n)return;const i=n.group;if(void 0!==i)for(const n of e){if("line"!==n.type)continue;if(n.group!==i)continue;if(2>n.path.length)continue;const e="function"==typeof r.style?r.style(n.datum):r.style||{};t.save(),t.beginPath(),t.moveTo(n.path[0][0],n.path[0][1]);for(let e=1;n.path.length>e;e++)t.lineTo(n.path[e][0],n.path[e][1]);t.strokeStyle=e.stroke||n.style.stroke||"#007bff",t.lineWidth=e.strokeWidth||(n.style.strokeWidth||2)+2,t.globalAlpha=null!==(o=e.opacity)&&void 0!==o?o:1,t.stroke(),t.restore()}}(t,o.scene,Xe.current,e)}}s&&n&&n.setAttribute("aria-label",Be(o.scene,b+" chart"));const f=Ie.current;if(Ie.current=!1,f&&o.scales&&((!Re||Re.x.domain()[0]!==o.scales.x.domain()[0]||Re.x.domain()[1]!==o.scales.x.domain()[1]||Re.y.domain()[0]!==o.scales.y.domain()[0]||Re.y.domain()[1]!==o.scales.y.domain()[1]||Re.x.range()[0]!==o.scales.x.range()[0]||Re.x.range()[1]!==o.scales.x.range()[1]||Re.y.range()[0]!==o.scales.y.range()[0]||Re.y.range()[1]!==o.scales.y.range()[1])&&Ye(o.scales),he)){const t=o.getData(),e="function"==typeof M?M:t=>t[M||"x"],n="function"==typeof S?S:t=>t[S||"y"];on(t.map(t=>e(t)).filter(t=>"number"==typeof t&&isFinite(t))),an(t.map(t=>n(t)).filter(t=>"number"==typeof t&&isFinite(t)))}f&&St&&St.length>0&&Fe(t=>t+1),(null==ie?void 0:ie.showBadge)&&Ke(!!d),(a||o.hasActivePulses)&&(We.current=requestAnimationFrame(()=>sn.current()))},r(()=>(gn(),()=>{We.current&&(cancelAnimationFrame(We.current),We.current=0)}),[gn]),r(()=>{Ie.current=!0,gn()},[b,Me,Se,ht,q,U,zt,gn]),te(ie,yn,Ie,gn,qe,Ke);const Pn=n(()=>{if(vt||bt)return;const t=yn.current;return(null==t?void 0:t.xIsDate)&&Re?Ln(Re.x.domain()):void 0},[vt,bt,Re]),Dn=vt||bt||Pn,Tn=Te&&Ge?Et?Et(Ge):t.createElement(Wn,{hover:Ge}):null,On=Tn?t.createElement(nn,{x:Ge.x,y:Ge.y,containerWidth:Me,containerHeight:Se,margin:Ae,className:"stream-frame-tooltip"},Tn):null,In=An.current,zn=t.createElement(en,{active:En.current>=0,hoverPoint:Ge,margin:Ae,size:Ee,shape:null==In?void 0:In.shape,width:null==In?void 0:In.w,height:null==In?void 0:In.h}),Bn=(t,e,n,r)=>"string"==typeof t?{key:t,fn:null}:"function"==typeof t?{key:n,fn:t}:"string"==typeof e?{key:e,fn:null}:"function"==typeof e?{key:r,fn:e}:{key:void 0,fn:null},jn=Bn(M,z,"__semiotic_resolvedX","__semiotic_resolvedTime"),Fn=Bn(S,N,"__semiotic_resolvedY","__semiotic_resolvedValue"),Rn=jn.key,Yn=Fn.key,Hn=St&&St.length>0,Xn=t=>{if(!t||!Hn||!jn.fn&&!Fn.fn)return t;let e=!1;const n=t.map(t=>{const n=jn.fn&&jn.key&&!(jn.key in t),r=Fn.fn&&Fn.key&&!(Fn.key in t);if(!n&&!r)return t;e=!0;const o=Object.assign({},t);return n&&(o[jn.key]=jn.fn(t)),r&&(o[Fn.key]=Fn.fn(t)),o});return e?n:t};if(Oe){const e=yn.current;e&&w&&(e.ingest({inserts:w,bounded:!0}),e.computeScene({width:Me,height:Se}));const n=null!==(a=null==e?void 0:e.scene)&&void 0!==a?a:[],r=null!==(c=null==e?void 0:e.scales)&&void 0!==c?c:null,o=Dn||(()=>{if((null==e?void 0:e.xIsDate)&&r)return Ln(r.x.domain())})();return t.createElement("div",{className:"stream-xy-frame"+(V?" "+V:""),role:"img","aria-label":pe||("string"==typeof Rt?Rt:"XY chart"),style:{position:"relative",width:Ee[0],height:Ee[1]}},t.createElement(Ze,{summary:me}),t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:Ee[0],height:Ee[1],style:{position:"absolute",left:0,top:0}},t.createElement("g",{transform:`translate(${Ae.left},${Ae.top})`},Pe),t.createElement("g",{transform:`translate(${Ae.left},${Ae.top})`},q&&t.createElement("rect",{x:0,y:0,width:Me,height:Se,fill:q}),Bt&&r&&Bt.map((e,o)=>t.createElement(t.Fragment,{key:"svgpre-"+o},e(n,r,{width:Me,height:Se}))),n.map((e,n)=>function(e,n){var r,o,i;switch(e.type){case"line":{const r=e;if(0===r.path.length)return null;const o="M"+r.path.map(([t,e])=>`${t},${e}`).join("L");return t.createElement("path",{key:"line-"+n,d:o,fill:"none",stroke:r.style.stroke||"#4e79a7",strokeWidth:r.style.strokeWidth||2,strokeDasharray:r.style.strokeDasharray,opacity:r.style.opacity})}case"area":{const i=e;if(0===i.topPath.length)return null;const l=i.topPath.map(([t,e])=>`${t},${e}`).join("L"),a=[...i.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L");return t.createElement("path",{key:"area-"+n,d:`M${l}L${a}Z`,fill:Ne(i.style.fill),fillOpacity:null!==(o=null!==(r=i.style.fillOpacity)&&void 0!==r?r:i.style.opacity)&&void 0!==o?o:.7,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})}case"point":{const r=e;return t.createElement("circle",{key:"point-"+n,cx:r.x,cy:r.y,r:r.r,fill:Ne(r.style.fill),opacity:null!==(i=r.style.opacity)&&void 0!==i?i:.8,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})}case"rect":{const r=e;return t.createElement("rect",{key:"rect-"+n,x:r.x,y:r.y,width:r.w,height:r.h,fill:Ne(r.style.fill),opacity:r.style.opacity,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})}case"heatcell":{const r=e;if(r.showValues&&null!=r.value&&r.w>=20&&r.h>=20){const e=r.valueFormat?r.valueFormat(r.value):Number.isInteger(r.value)?r.value+"":100>Math.abs(r.value)?1>Math.abs(r.value)?r.value.toPrecision(3):r.value.toFixed(1):r.value.toFixed(0),[o,i,l]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(r.fill),a=.299*o+.587*i+.114*l>128?"#000":"#fff",s=Math.max(10,Math.min(16,.3*Math.min(r.w,r.h)));return t.createElement("g",{key:"heatcell-"+n},t.createElement("rect",{x:r.x,y:r.y,width:r.w,height:r.h,fill:r.fill}),t.createElement("text",{x:r.x+r.w/2,y:r.y+r.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:a,fontSize:s+"px"},e))}return t.createElement("rect",{key:"heatcell-"+n,x:r.x,y:r.y,width:r.w,height:r.h,fill:r.fill})}case"candlestick":{const r=e,o=Math.min(r.openY,r.closeY),i=Math.max(Math.abs(r.openY-r.closeY),1),l=r.isUp?r.upColor:r.downColor;return t.createElement("g",{key:"candle-"+n},t.createElement("line",{x1:r.x,y1:r.highY,x2:r.x,y2:r.lowY,stroke:r.wickColor,strokeWidth:r.wickWidth}),t.createElement("rect",{x:r.x-r.bodyWidth/2,y:o,width:r.bodyWidth,height:i,fill:l,stroke:l,strokeWidth:1}))}default:return null}}(e,n)).filter(Boolean))),t.createElement($e,{width:Me,height:Se,totalWidth:Ee[0],totalHeight:Ee[1],margin:Ae,scales:r,showAxes:ht,axes:yt,xLabel:gt,yLabel:pt,yLabelRight:mt,xFormat:o,yFormat:xt||kt,showGrid:Pt,title:Rt,legend:Dt,legendHoverBehavior:Tt,legendClickBehavior:Lt,legendHighlightedCategory:Ct,legendIsolatedCategories:$t,legendPosition:Nt,foregroundGraphics:_e,marginalGraphics:he,xValues:[],yValues:[],annotations:St,svgAnnotationRules:_t,annotationFrame:0,xAccessor:Rn,yAccessor:Yn,annotationData:Xn(null==e?void 0:e.getData()),pointNodes:null==e?void 0:e.scene.filter(t=>"point"===t.type),curve:"string"==typeof L?L:void 0,linkedCrosshairName:ve,linkedCrosshairSourceId:xe}))}const Gn="semiotic-table-"+t.useId();return t.createElement("div",{ref:we,className:"stream-xy-frame"+(V?" "+V:""),role:"group","aria-label":pe||("string"==typeof Rt?Rt:"XY chart"),tabIndex:0,style:{position:"relative",width:H?"100%":Ee[0],height:X?"100%":Ee[1],overflow:"visible"},onKeyDown:Sn},ge&&t.createElement(Qe,{tableId:Gn}),ge&&t.createElement(Ue,{scene:null!==(d=null===(h=yn.current)||void 0===h?void 0:h.scene)&&void 0!==d?d:[],chartType:b+" chart",tableId:Gn,chartTitle:"string"==typeof Rt?Rt:void 0}),t.createElement(Ze,{summary:me}),t.createElement("div",{role:"img","aria-label":pe||("string"==typeof Rt?Rt:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:Te?_n:void 0,onMouseLeave:Te?wn:void 0},Pe&&t.createElement("svg",{style:{position:"absolute",left:0,top:0,width:Ee[0],height:Ee[1],pointerEvents:"none"}},t.createElement("g",{transform:`translate(${Ae.left},${Ae.top})`},Pe)),t.createElement(De,{width:Me,height:Se,totalWidth:Ee[0],totalHeight:Ee[1],margin:Ae,scales:Re,showAxes:ht,axes:yt,showGrid:Pt,xFormat:Dn,yFormat:xt||kt}),t.createElement("canvas",{ref:Le,"aria-label":Be(null!==(y=null===(f=yn.current)||void 0===f?void 0:f.scene)&&void 0!==y?y:[],b+" chart"),style:{position:"absolute",left:0,top:0}}),t.createElement("canvas",{ref:Ce,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),t.createElement(Je,{hoverPoint:Ge}),t.createElement($e,{width:Me,height:Se,totalWidth:Ee[0],totalHeight:Ee[1],margin:Ae,scales:Re,showAxes:ht,axes:yt,xLabel:gt,yLabel:pt,yLabelRight:mt,xFormat:Dn,yFormat:xt||kt,showGrid:Pt,title:Rt,legend:Dt,legendHoverBehavior:Tt,legendClickBehavior:Lt,legendHighlightedCategory:Ct,legendIsolatedCategories:$t,legendPosition:Nt,foregroundGraphics:_e,marginalGraphics:he,xValues:tn,yValues:ln,annotations:St,svgAnnotationRules:_t,annotationFrame:je,xAccessor:Rn,yAccessor:Yn,annotationData:Xn(null===(g=yn.current)||void 0===g?void 0:g.getData()),pointNodes:null===(p=yn.current)||void 0===p?void 0:p.scene.filter(t=>"point"===t.type),curve:"string"==typeof L?L:void 0,underlayRendered:!0,linkedCrosshairName:ve,linkedCrosshairSourceId:xe}),(Zt||ee)&&t.createElement(dt,{width:Me,height:Se,totalWidth:Ee[0],totalHeight:Ee[1],margin:Ae,dimension:null!==(m=null==Zt?void 0:Zt.dimension)&&void 0!==m?m:"xy",scales:Re,onBrush:null!=ee?ee:()=>{},binSize:$,snap:null==Zt?void 0:Zt.snap,binBoundaries:null!==(v=null==Zt?void 0:Zt.binBoundaries)&&void 0!==v?v:"bar"===b?null===(x=yn.current)||void 0===x?void 0:x.getBinBoundaries():void 0,snapDuring:null==Zt?void 0:Zt.snapDuring,streaming:"streaming"===k}),(null==ie?void 0:ie.showBadge)&&t.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===ie.badgePosition?{top:4,left:4}:"bottom-left"===ie.badgePosition?{bottom:4,left:4}:"bottom-right"===ie.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:qe?"#dc3545":"#28a745",color:"white"})},qe?"STALE":"LIVE"),zn,On))});In.displayName="StreamXYFrame";const zn={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},Bn={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class jn{constructor(t){this.capacity=t,this.particles=Array(t);for(let e=0;t>e;e++)this.particles[e]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0}}spawn(t){for(let e=0;this.capacity>e;e++){const n=this.particles[e];if(!n.active)return n.active=!0,n.t=0,n.offset=Math.random()-.5,n.edgeIndex=t,n.x=0,n.y=0,n}return null}step(t,e,n,r){var o;for(let i=0;this.capacity>i;i++){const l=this.particles[i];if(!l.active)continue;const a=n[l.edgeIndex];if(!a||!a.bezier){l.active=!1;continue}const s=r&&null!==(o=r[l.edgeIndex])&&void 0!==o?o:1;if(l.t+=t*e*s*(a.bezier.circular?.3:1),l.t>=1){l.active=!1;continue}const c=Fn(a.bezier,l.t,l.offset);l.x=c.x,l.y=c.y}}countForEdge(t){let e=0;for(let n=0;this.capacity>n;n++)this.particles[n].active&&this.particles[n].edgeIndex===t&&e++;return e}clear(){for(let t=0;this.capacity>t;t++)this.particles[t].active=!1}resize(t){if(this.capacity>=t)return;const e=this.particles;this.particles=Array(t);for(let n=0;t>n;n++)this.particles[n]=e.length>n?e[n]:{t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0};this.capacity=t}}function Fn(t,e,n){if(t.circular&&t.segments)return function(t,e,n,r){const o=t.length,i=e*o,l=Math.min(Math.floor(i),o-1),a=i-l,[s,c,u,h]=t[l],d=Rn(s,c,u,h,a),f=h.x-s.x,y=h.y-s.y,g=Math.sqrt(f*f+y*y);if(g>.001){const t=f/g;d.x+=-y/g*n*r*2,d.y+=t*n*r*2}return d}(t.segments,e,n,t.halfWidth);if(!t.points)return{x:0,y:0};const[r,o,i,l]=t.points,a=Rn(r,o,i,l,e),s=l.x-r.x,c=l.y-r.y,u=Math.sqrt(s*s+c*c);if(u>.001){const e=s/u;a.x+=-c/u*n*t.halfWidth*2,a.y+=e*n*t.halfWidth*2}return a}function Rn(t,e,n,r,o){const i=1-o,l=i*i,a=l*i,s=o*o,c=s*o;return{x:a*t.x+3*l*o*e.x+3*i*s*n.x+c*r.x,y:a*t.y+3*l*o*e.y+3*i*s*n.y+c*r.y}}function Yn(t,e){var n=t.get(e);if(!n)throw Error("missing: "+e);return n}function Hn(t,e){var n,r=[],o=[],i=[],l={},a=[];function s(t){i[t]=!1,l.hasOwnProperty(t)&&Object.keys(l[t]).forEach(function(e){delete l[t][e],i[e]&&s(e)})}function c(t){var e,r,h=!1;for(o.push(t),i[t]=!0,e=0;a[t].length>e;e++)(r=a[t][e])===n?(u(n,o),h=!0):i[r]||(h=c(r));if(h)s(t);else for(e=0;a[t].length>e;e++){var d=l[r=a[t][e]];d||(l[r]=d={}),d[r]=!0}return o.pop(),h}function u(t,e){var n=[].concat(e).concat(t);r.push(n)}function h(e){!function(e){for(var n=0;t.length>n;n++)n>=e&&t[n]||(t[n]=[]),t[n]=t[n].filter(function(t){return t>=e})}(e);for(var n,r=function(t){for(var e=t.length,n=Array(e),r=Array(e),o=Array(e),i=Array(e),l=Array(e),a=Array(e),s=0;e>s;++s)n[s]=-1,r[s]=0,o[s]=!1,i[s]=0,l[s]=-1,a[s]=[];var c,u=0,h=[],d=[];function f(e){var s=[e],c=[e];for(n[e]=r[e]=u,o[e]=!0,u+=1;c.length>0;){var f=t[e=c[c.length-1]];if(f.length>i[e]){for(var y=i[e];f.length>y;++y){var g=f[y];if(0>n[g]){n[g]=r[g]=u,o[g]=!0,u+=1,s.push(g),c.push(g);break}o[g]&&(r[e]=0|Math.min(r[e],r[g])),0>l[g]||a[e].push(l[g])}i[e]=y}else{if(r[e]===n[e]){var p=[],m=[],v=0;for(y=s.length-1;y>=0;--y){var x=s[y];if(o[x]=!1,p.push(x),m.push(a[x]),v+=a[x].length,l[x]=h.length,x===e){s.length=y;break}}h.push(p);var b=Array(v);for(y=0;m.length>y;y++)for(var k=0;m[y].length>k;k++)b[--v]=m[y][k];d.push(b)}c.pop()}}}for(s=0;e>s;++s)0>n[s]&&f(s);for(s=0;d.length>s;s++){var y=d[s];if(0!==y.length){y.sort(function(t,e){return t-e}),c=[y[0]];for(var g=1;y.length>g;g++)y[g]!==y[g-1]&&c.push(y[g]);d[s]=c}}return{components:h,adjacencyList:d}}(t),o=r.components.filter(function(t){return t.length>1}),i=1/0,l=0;o.length>l;l++)for(var a=0;o[l].length>a;a++)i>o[l][a]&&(i=o[l][a],n=l);var s=o[n];if(!s)return!1;var c=t.map(function(t,e){return-1===s.indexOf(e)?[]:t.filter(function(t){return-1!==s.indexOf(t)})});return{leastVertex:i,adjList:c}}n=0;for(var d=t.length;d>n;){var f=h(n);if(n=f.leastVertex,a=f.adjList){for(var y=0;a.length>y;y++)for(var g=0;a[y].length>g;g++){var p=a[y][g];i[+p]=!1,l[p]={}}c(n),n+=1}else n=d}return r}function Xn(t){return t.y0-t.y1>0?"up":"down"}function Gn(t,e){return e(t.source)==e(t.target)}function Vn(t){var e=0;t.source.sourceLinks.forEach(function(t){e=t.circular?e+1:e});var n=0;return t.target.targetLinks.forEach(function(t){n=t.circular?n+1:n}),1>=e&&1>=n}function qn(t){return t.target.x0-t.source.x1}function Un(t,e){var n=Zn(t),r=qn(e)/Math.tan(n);return"up"==Xn(t)?t.y1-r:t.y1+r}function Kn(t,e){var n=Zn(t),r=qn(e)/Math.tan(n);return"up"==Xn(t)?t.y1+r:t.y1-r}function Zn(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function Qn(t,e){return e(t)}function Jn(t){return er(t.source)}function tr(t){return er(t.target)}function er(t){return(t.y0+t.y1)/2}function nr(t){return t.virtual?0:t.value}function rr(t,e){var n=0;t.sourceLinks.forEach(function(t){n=t.circular&&!Gn(t,e)?n+1:n});var r=0;return t.targetLinks.forEach(function(t){r=t.circular&&!Gn(t,e)?r+1:r}),n+r}function or(t){return t.target.depth}function ir(t,e){return t.sourceLinks.length?t.depth:e-1}function lr(t,e){return t.y0-e.y0}function ar(t,e){return e.y0-t.y0}function sr(t,e){return t.y1-e.y1}function cr(t,e){return e.y1-t.y1}function ur(t,e){return dr(t.source,e.source)||t.index-e.index}function hr(t,e){return dr(t.target,e.target)||t.index-e.index}function dr(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function fr(t,e){return yr(t)==yr(e)?"bottom"==t.circularLinkType?ar(t,e):lr(t,e):yr(e)-yr(t)}function yr(t){return t.target.column-t.source.column}function gr(t,e){return pr(t)==pr(e)}function pr(t){return t.y0-t.y1>0?"up":"down"}function mr(t,e,n,r,o){let i=t;var l=Math.max(8,.15*(i.y1-i.y0));i.links.forEach(function(t){t.circular&&(t._circularWidth=Math.min(t.width,l))});var a=S(i.links,function(t){return t.source.y0});i.links.forEach(function(t){t.circular&&(t.circularPathData={})});var s=i.links.filter(function(t){return t.circular});return s.sort(function(t,e){return e.value-t.value}),s.forEach(function(t,e){t._circularStub=e>=4}),vr(i.links.filter(function(t){return"top"==t.circularLinkType}),e,n),vr(i.links.filter(function(t){return"bottom"==t.circularLinkType}),e,n),i.links.forEach(function(t){if(t.circular){if(t.circularPathData.arcRadius=t._circularWidth+r,t.circularPathData.rightNodeBuffer=5,t.circularPathData.leftNodeBuffer=5,t.circularPathData.sourceWidth=t.source.x1-t.source.x0,t.circularPathData.sourceX=t.source.x0+t.circularPathData.sourceWidth,t.circularPathData.targetX=t.target.x0,t.circularPathData.sourceY=t.y0,t.circularPathData.targetY=t.y1,Gn(t,e)&&Vn(t))t.circularPathData.rightSmallArcRadius=r+t._circularWidth/2,t.circularPathData.rightLargeArcRadius=r+t._circularWidth/2,t.circularPathData.leftSmallArcRadius=r+t._circularWidth/2,t.circularPathData.leftLargeArcRadius=r+t._circularWidth/2,"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=t.source.y1+o+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=t.source.y0-o-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius);else{var l=t.source.column,s=t.circularLinkType,c=i.links.filter(function(t){return t.source.column==l&&t.circularLinkType==s});c.sort("bottom"==t.circularLinkType?ar:lr);var u=0;c.forEach(function(e,o){e.circularLinkID==t.circularLinkID&&(t.circularPathData.rightSmallArcRadius=r+t._circularWidth/2+u,t.circularPathData.rightLargeArcRadius=r+t._circularWidth/2+o*n+u),u+=e._circularWidth||e.width}),l=t.target.column,(c=i.links.filter(function(t){return t.target.column==l&&t.circularLinkType==s})).sort("bottom"==t.circularLinkType?cr:sr),u=0,c.forEach(function(e,o){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=r+t._circularWidth/2+u,t.circularPathData.leftLargeArcRadius=r+t._circularWidth/2+o*n+u),u+=e._circularWidth||e.width}),"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=Math.max(i.y1,t.source.y1,t.target.y1)+o+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=a-o-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius)}t.circularPathData.rightInnerExtent=t.circularPathData.sourceX+t.circularPathData.rightNodeBuffer,t.circularPathData.leftInnerExtent=t.circularPathData.targetX-t.circularPathData.leftNodeBuffer,t.circularPathData.rightFullExtent=t.circularPathData.sourceX+t.circularPathData.rightLargeArcRadius+t.circularPathData.rightNodeBuffer,t.circularPathData.leftFullExtent=t.circularPathData.targetX-t.circularPathData.leftLargeArcRadius-t.circularPathData.leftNodeBuffer}t.path=t.circular?function(t){return"top"==t.circularLinkType?"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 0 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY-t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 0 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 0 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY-t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 0 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY:"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 1 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY+t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 1 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 1 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY+t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 1 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY}(t):function(t){var e=t.source.x1,n=t.y0,r=t.target.x0,o=t.y1,i=(e+r)/2;return"M"+e+","+n+"C"+i+","+n+" "+i+","+o+" "+r+","+o}(t)}),i}function vr(t,e,n){t.sort(fr);var r=t.filter(function(t){return!t._circularStub});return t.forEach(function(t,o){var i=0;if(t._circularStub)t.circularPathData.verticalBuffer=0;else if(Gn(t,e)&&Vn(t))t.circularPathData.verticalBuffer=i+t._circularWidth/2;else{for(var l=0;r.length>l;l++){var a=r[l];if(a!==t&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&xr(t,a)){var s=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+n;i=s>i?s:i}}t.circularPathData.verticalBuffer=i+t._circularWidth/2}}),t}function xr(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}function br(t){return function(){return t}}function kr(t){return t.index}function wr(t){return t.nodes}function Er(t){return t.links}function Ar(t,e,n){var r=_(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});r.forEach(function(o,i){var l=o.length;if(e)o.sort(e);else if(i>0){var a=new Map;o.forEach(function(t,e){var n,r,o,i=(r=0,o=0,(n=t).targetLinks.forEach(function(t){if(!t.circular){var e=t.value||1;o+=er(t.source)*e,r+=e}}),n.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;o+=er(t.target)*e,r+=e}}),r>0?o/r:NaN);a.set(t,{bc:i,idx:e})}),o.sort(function(t,e){var n=a.get(t),r=a.get(e),o=n.bc,i=r.bc;if(t.circularLinkType!==e.circularLinkType){if("top"==t.circularLinkType&&"bottom"==e.circularLinkType)return-1;if("bottom"==t.circularLinkType&&"top"==e.circularLinkType)return 1;if("top"==t.circularLinkType)return-1;if("top"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return-1}return isNaN(o)||isNaN(i)?isNaN(o)?isNaN(i)?n.idx-r.idx:1:-1:o-i})}else o.sort(function(t,e){return t.circularLinkType==e.circularLinkType?rr(e,n)-rr(t,n):"top"==t.circularLinkType&&"bottom"==e.circularLinkType||"top"==t.circularLinkType&&0==e.partOfCycle||0==t.partOfCycle&&"bottom"==e.circularLinkType?-1:0});o.forEach(function(e,o){e.depth==r.length-1&&1==l||0==e.depth&&1==l?(e.y0=t.y1/2-e.value*t.ky,e.y1=e.y0+e.value*t.ky):e.partOfCycle?0==rr(e,n)?(e.y0=t.y1/2+o,e.y1=e.y0+e.value*t.ky):"top"==e.circularLinkType?(e.y0=t.y0+o,e.y1=e.y0+e.value*t.ky):(e.y0=t.y1-e.value*t.ky-o,e.y1=e.y0+e.value*t.ky):0==t.y0||0==t.y1?(e.y0=(t.y1-t.y0)/l*o,e.y1=e.y0+e.value*t.ky):(e.y0=(t.y1-t.y0)/2-l/2+o,e.y1=e.y0+e.value*t.ky)})})}function Mr(t,e,n,r,o,i){var l=_(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});u();for(var a=1,s=i;s>0;--s)c(a*=.99,n),u();function c(e,n){var r=l.length;l.forEach(function(o){var i=o.length,l=o[0].depth;o.forEach(function(o){var a;if(o.sourceLinks.length||o.targetLinks.length)if(o.partOfCycle&&rr(o,n)>0){var s=T(o.sourceLinks,tr),c=T(o.targetLinks,Jn),u=s&&c?(s+c)/2:s||c;if(u){var h=(u-er(o))*e*.3;o.y0+=h,o.y1+=h}}else if(0==l&&1==i)o.y0=t.y1/2-(a=o.y1-o.y0)/2,o.y1=t.y1/2+a/2;else if(l==r-1&&1==i)o.y0=t.y1/2-(a=o.y1-o.y0)/2,o.y1=t.y1/2+a/2;else if(1==o.targetLinks.length&&1==o.targetLinks[0].source.sourceLinks.length)a=o.y1-o.y0,o.y0=o.targetLinks[0].source.y0,o.y1=o.y0+a;else{var d=T(o.sourceLinks,tr),f=T(o.targetLinks,Jn),y=((d&&f?(d+f)/2:d||f)-er(o))*e;o.y0+=y,o.y1+=y}})})}function u(){l.forEach(function(n){var i,l,a,s=t.y0,c=n.length;for(n.sort(e||dr),a=0;c>a;++a)(l=s-(i=n[a]).y0)>0&&(i.y0+=l,i.y1+=l),s=i.y1+r;if((l=s-r-t.y1)>0)for(s=i.y0-=l,i.y1-=l,a=c-2;a>=0;--a)(l=(i=n[a]).y1+o-s)>0&&(i.y0-=l,i.y1-=l),s=i.y0})}}function Sr(t){t.nodes.forEach(function(t){t.sourceLinks.sort(hr),t.targetLinks.sort(ur)}),t.nodes.forEach(function(t){var e=t.y0,n=e,r=t.y1,o=r;t.sourceLinks.forEach(function(t){t.circular?(t.y0=r-t.width/2,r-=t.width):(t.y0=e+t.width/2,e+=t.width)}),t.targetLinks.forEach(function(t){t.circular?(t.y1=o-t.width/2,o-=t.width):(t.y1=n+t.width/2,n+=t.width)})})}function _r(){var t=0,e=0,n=1,r=1,o=24,i=8,l=null,a=kr,s=ir,c=void 0,u=32,h=2,d=wr,f=Er;function y(){var y={nodes:d.apply(null,arguments),links:f.apply(null,arguments)};return function(d){d.x0=t,d.y0=e,d.x1=n,d.y1=r,d.py=0,function(t,e){t.nodes.forEach(function(t,e){t.index=e,t.sourceLinks=[],t.targetLinks=[]});var n=function(t,e){var n=new Map;return L(t,e).forEach(function(t,e){n.set(e,t[0])}),n}(t.nodes,e);t.links.forEach(function(t,e){t.index=e;var r=t.source,o=t.target;"object"!=typeof r&&(r=t.source=Yn(n,r)),"object"!=typeof o&&(o=t.target=Yn(n,o)),r.sourceLinks.push(t),o.targetLinks.push(t)})}(d,a),function(t,e){var n=0;if(null==e){for(var r=[],o=0;t.links.length>o;o++){var i=t.links[o],l=i.source.index,a=i.target.index;r[l]||(r[l]=[]),r[a]||(r[a]=[]),-1===r[l].indexOf(a)&&r[l].push(a)}var s=Hn(r);s.sort(function(t,e){return t.length-e.length});var c={};for(o=0;s.length>o;o++){var u=s[o].slice(-2);c[u[0]]||(c[u[0]]={}),c[u[0]][u[1]]=!0}t.links.forEach(function(t){var e=t.target.index,r=t.source.index;e===r||c[r]&&c[r][e]?(t.circular=!0,t.circularLinkID=n++):t.circular=!1})}else t.links.forEach(function(t){e(t.source)<e(t.target)?t.circular=!1:(t.circular=!0,t.circularLinkID=n++)})}(d,c),function(t,e){var n=0,r=0;t.links.forEach(function(o){o.circular&&(o.circularLinkType=o.source.circularLinkType||o.target.circularLinkType?o.source.circularLinkType?o.source.circularLinkType:o.target.circularLinkType:r>n?"top":"bottom","top"==o.circularLinkType?n++:r++,t.nodes.forEach(function(t){Qn(t,e)!=Qn(o.source,e)&&Qn(t,e)!=Qn(o.target,e)||(t.circularLinkType=o.circularLinkType)}))}),t.links.forEach(function(t){t.circular&&(t.source.circularLinkType==t.target.circularLinkType&&(t.circularLinkType=t.source.circularLinkType),Gn(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(d,a),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max(D(t.sourceLinks,nr),D(t.targetLinks,nr)),t.sourceLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)}),t.targetLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)})})}(d),function(t,e,n){var r,o,i;if(null!=e){t.nodes.sort(function(t,n){return e(t)<e(n)?-1:1});var l=0,a=e(t.nodes[0]);t.nodes.forEach(function(t){l=e(t)==a?l:l+1,a=e(t)==a?a:e(t),t.column=l})}for(r=t.nodes,o=[],i=0;r.length;++i,r=o,o=[])r.forEach(function(t){t.depth=i,t.sourceLinks.forEach(function(t){0>o.indexOf(t.target)&&!t.circular&&o.push(t.target)})});for(r=t.nodes,o=[],i=0;r.length;++i,r=o,o=[])r.forEach(function(t){t.height=i,t.targetLinks.forEach(function(t){0>o.indexOf(t.source)&&!t.circular&&o.push(t.source)})});t.nodes.forEach(function(t){t.column=null==e?n(t,i):t.column})}(d,c,s);var f=i;if(null!==l){var y=_(d.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),g=P(y,function(t){return t.length});g>1&&(f=Math.max(1,(r-e)*l/(g-1)))}(function(t,e,n){var r=_(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});t.py=e;var o=S(r,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/D(e,function(t){return t.value})});t.ky=o,t.links.forEach(function(e){e.width=e.value*t.ky});var i=P(t.nodes,function(t){return t.column});t.nodes.forEach(i>0?function(e){e.x0=t.x0+e.column*((t.x1-t.x0-n)/i),e.x1=e.x0+n}:function(e){e.x0=t.x0,e.x1=e.x0+n})})(d,f,o),Ar(d,c,a),Mr(d,c,a,f,f,u),Sr(d),mr(d,a,h,10,8),Ar(d,c,a),Mr(d,c,a,f,f,u),Sr(d),mr(d,a,h,10,8),function(t,e){let n=t;n.nodes.forEach(function(t){t.y+(t.y1-t.y0)>n.y1&&(t.y=t.y-(t.y+(t.y1-t.y0)-n.y1));var r=n.links.filter(function(n){return Qn(n.source,e)==Qn(t,e)}),o=r.length;o>1&&r.sort(function(t,e){if(!t.circular&&!e.circular){if(t.target.column==e.target.column)return t.y1-e.y1;if(!gr(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var n=Un(e,t);return t.y1-n}if(e.target.column>t.target.column)return Un(t,e)-e.y1}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.target.column===e.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.target.column===e.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:"top"==t.circularLinkType?-1:1:void 0});var i=t.y0;r.forEach(function(t){t.y0=i+t.width/2,i+=t.width}),r.forEach(function(e,n){if("bottom"==e.circularLinkType){for(var i=n+1,l=0;o>i;i++)l+=r[i].width;e.y0=t.y1-l-e.width/2}})})}(d,a),function(t,e){let n=t;n.nodes.forEach(function(t){var r=n.links.filter(function(n){return Qn(n.target,e)==Qn(t,e)}),o=r.length;o>1&&r.sort(function(t,e){if(!t.circular&&!e.circular){if(t.source.column==e.source.column)return t.y0-e.y0;if(!gr(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var n=Kn(e,t);return t.y0-n}if(e.source.column>t.source.column)return Kn(t,e)-e.y0}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:t.source.column-e.source.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:e.source.column-t.source.column:"top"==t.circularLinkType?-1:1:void 0});var i=t.y0;r.forEach(function(t){t.y1=i+t.width/2,i+=t.width}),r.forEach(function(e,n){if("bottom"==e.circularLinkType){for(var i=n+1,l=0;o>i;i++)l+=r[i].width;e.y1=t.y1-l-e.width/2}})})}(d,a),function(t){var e=t.nodes,n=t.links,r=!1,o=!1;if(n.forEach(function(t){"top"==t.circularLinkType?r=!0:"bottom"==t.circularLinkType&&(o=!0)}),0==r||0==o){var i=S(e,function(t){return t.y0}),l=P(e,function(t){return t.y1}),a=(t.y1-t.y0)/(l-i);function s(e){return(e-i)/(l-i)*(t.y1-t.y0)+t.y0}1>a?(e.forEach(function(t){t.y0=s(t.y0),t.y1=s(t.y1)}),n.forEach(function(t){t.y0=s(t.y0),t.y1=s(t.y1),t.width=t.width*a})):e.forEach(function(t){var e=t.y1-t.y0,n=s(t.y0)-t.y0;t.y0=s(t.y0),t.y1=t.y0+e,t.sourceLinks.forEach(function(t){t.y0=t.y0+n}),t.targetLinks.forEach(function(t){t.y1=t.y1+n})})}}(d),mr(d,a,h,10,8)}(y),y}return y.update=function(t){return Sr(t),mr(t,a,h,10,8),t},y.nodeWidth=function(t){return arguments.length?(o=+t,y):o},y.nodePadding=function(t){return arguments.length?(i=+t,y):i},y.nodePaddingRatio=function(t){return arguments.length?(l=+t,y):l},y.nodes=function(t){return arguments.length?(d="function"==typeof t?t:br(t),y):d},y.links=function(t){return arguments.length?(f="function"==typeof t?t:br(t),y):f},y.nodeId=function(t){return arguments.length?(a="function"==typeof t?t:br(t),y):a},y.nodeAlign=function(t){return arguments.length?(s="function"==typeof t?t:br(t),y):s},y.nodeSort=function(t){return arguments.length?(c=t,y):c},y.iterations=function(t){return arguments.length?(u=+t,y):u},y.circularLinkGap=function(t){return arguments.length?(h=+t,y):h},y.extent=function(o){return arguments.length?(t=+o[0][0],e=+o[0][1],n=+o[1][0],r=+o[1][1],y):[[t,e],[n,r]]},y.size=function(o){return arguments.length?(t=e=0,n=+o[0],r=+o[1],y):[n-t,r-e]},y}const Pr=t=>{let e,n,r,o,i,l,a,s,c;return"down"===t.direction?(e=t.y0-t.sankeyWidth/2,n=t.y1-t.sankeyWidth/2,r=t.y1+t.sankeyWidth/2,o=t.y0+t.sankeyWidth/2,i=t.source.x1,l=t.target.x0,a=et(i,l),s=a(.5),c=a(.5),`M${e},${i}C${e},${s} ${n},${c} ${n},${l}L${r},${l}C${r},${c} ${o},${s} ${o},${i}Z`):(e=t.source.x1,n=t.target.x0,a=et(e,n),r=a(.5),o=a(.5),i=t.y0-t.sankeyWidth/2,l=t.y1-t.sankeyWidth/2,s=t.y1+t.sankeyWidth/2,c=t.y0+t.sankeyWidth/2,`M${e},${i}C${r},${i} ${o},${l} ${n},${l}L${n},${s}C${o},${s} ${r},${c} ${e},${c}Z`)};function Dr(t){var e;const n=t.sankeyWidth/2,r=(null!==(e=t._circularWidth)&&void 0!==e?e:t.sankeyWidth)/2,o=t.circularPathData;if(!o)return null;if("down"===t.direction)return null;if(t._circularStub){const e=o.sourceX,r=o.sourceY,i=o.targetX,l=o.targetY;if("object"!=typeof t.source||!t.source||"object"!=typeof t.target||!t.target)return null;const a=Math.max(15,Math.min(40,.33*(o.rightFullExtent-e))),s=Math.max(15,Math.min(40,.33*(i-o.leftFullExtent)));return`M${e},${r-n}L${e+a},${r-n}L${e+a},${r+n}L${e},${r+n}ZM${i},${l-n}L${i-s},${l-n}L${i-s},${l+n}L${i},${l+n}Z`}const i=o.sourceX,l=o.sourceY,a=o.targetX,s=o.targetY,c=o.rightFullExtent,u=o.leftFullExtent,h=o.verticalFullExtent,d="bottom"===t.circularLinkType?1:-1,f=Math.max(4,Math.min(r,15));return`M${i},${l-d*n}L${c},${l-d*n}L${c+r},${l-d*n+d*f}L${c+r},${h+d*r-d*f}L${c+r-f},${h+d*r}L${u-r+f},${h+d*r}L${u-r},${h+d*r-d*f}L${u-r},${s-d*n+d*f}L${u-r+f},${s-d*n}L${a},${s-d*n}L${a},${s+d*n}L${u+r},${s+d*n}L${u+r},${h-d*r}L${c-r},${h-d*r}L${c-r},${l+d*n}L${i},${l+d*n}Z`}const Tr=new Set,Lr=new WeakMap;function Cr(t,e){if("production"===process.env.NODE_ENV)return t;if(!t||!t.data||"object"!=typeof t.data)return t;let n=Lr.get(t);if(n){const t=n.get(e);if(t)return t}else n=new Map,Lr.set(t,n);const r=new Proxy(t,{get(t,n,r){if("string"==typeof n&&!(n in t)&&t.data&&n in t.data){const t=`${e}:${n}`;Tr.has(t)||(Tr.add(t),console.warn(`[Semiotic] "${e}" callback accessed "${n}" on the wrapper object, but it only exists on ".data". Use d.data.${n} (or d.data?.${n}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(t,n,r)}});return n.set(e,r),r}const $r={left:function(t){return t.depth},right:function(t,e){return e-1-t.height},center:function(t){return t.targetLinks.length?t.depth:t.sourceLinks.length?Math.min.apply(Math,t.sourceLinks.map(or))-1:0},justify:ir},Nr={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,r){var o,i,l,a,s,c,u;if(0===t.length)return;const h="vertical"===n.orientation?"down":"right",d=n.nodeAlign||"justify",f=null!==(o=n.nodeWidth)&&void 0!==o?o:15,y=null!==(i=n.nodePaddingRatio)&&void 0!==i?i:.05,g=null!==(l=n.iterations)&&void 0!==l?l:100,p=t.map(t=>Object.assign({},t)),m=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id,value:Math.sqrt(Math.max(1,t.value||1))}));let v;v="down"===h?[[0,0],[r[1],r[0]]]:[[0,0],[r[0],r[1]]];const x=_r().extent(v).links(m).nodes(p).nodeAlign($r[d]||ir).nodeId(t=>t.id).nodeWidth(f).iterations(g);x.nodePaddingRatio&&x.nodePaddingRatio(y),x();{let t=1/0,e=-1/0,n=1/0,o=-1/0;for(const r of p)t>r.x0&&(t=r.x0),r.x1>e&&(e=r.x1),n>r.y0&&(n=r.y0),r.y1>o&&(o=r.y1);for(const r of m){if(!r.circular||!r.circularPathData)continue;const i=r.circularPathData,l=(null!==(s=null!==(a=r._circularWidth)&&void 0!==a?a:r.width)&&void 0!==s?s:0)/2;t>i.leftFullExtent-l&&(t=i.leftFullExtent-l),i.rightFullExtent+l>e&&(e=i.rightFullExtent+l),n>i.verticalFullExtent-l&&(n=i.verticalFullExtent-l),i.verticalFullExtent+l>o&&(o=i.verticalFullExtent+l)}const i=e-t,l=o-n,u=r[0],h=r[1];if(i>0&&l>0&&(0>t||0>n||e>u||o>h)){const e=Math.min(u/i,h/l),r=-t*e+(u-i*e)/2,o=-n*e+(h-l*e)/2;for(const t of p)t.x0=t.x0*e+r,t.x1=t.x1*e+r,t.y0=t.y0*e+o,t.y1=t.y1*e+o;for(const t of m)if(t.y0=t.y0*e+o,t.y1=t.y1*e+o,t.width=(null!==(c=t.width)&&void 0!==c?c:0)*e,t._circularWidth&&(t._circularWidth*=e),t.circular&&t.circularPathData){const n=t.circularPathData;n.sourceX=n.sourceX*e+r,n.targetX=n.targetX*e+r,n.sourceY=n.sourceY*e+o,n.targetY=n.targetY*e+o,n.rightFullExtent=n.rightFullExtent*e+r,n.leftFullExtent=n.leftFullExtent*e+r,n.verticalFullExtent=n.verticalFullExtent*e+o,n.rightInnerExtent=n.rightInnerExtent*e+r,n.leftInnerExtent=n.leftInnerExtent*e+r,n.verticalRightInnerExtent=n.verticalRightInnerExtent*e+o,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*e+o,n.rightSmallArcRadius*=e,n.rightLargeArcRadius*=e,n.leftSmallArcRadius*=e,n.leftLargeArcRadius*=e,n.sourceWidth*=e,n.rightNodeBuffer*=e,n.leftNodeBuffer*=e,n.arcRadius*=e}}}const b=new Map;for(const e of t)b.set(e.id,e);for(const t of p){const e=b.get(t.id);e&&(e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.value=t.value,e.depth=t.depth,e.sourceLinks=t.sourceLinks,e.targetLinks=t.targetLinks,e.width=t.x1-t.x0,e.height=t.y1-t.y0,e.x=t.x0+(t.x1-t.x0)/2,e.y=t.y0+(t.y1-t.y0)/2)}const k=new Map;for(const t of e)k.set(t._edgeKey?t._edgeKey:`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const t of m){const e=t.source,n=t.target,r="object"==typeof e&&null!==e?e.id:e+"",o="object"==typeof n&&null!==n?n.id:n+"",i=k.get(t._edgeKey?t._edgeKey:`${r}\0${o}`);if(i){i.y0=t.y0,i.y1=t.y1,i.sankeyWidth=null!==(u=t.width)&&void 0!==u?u:0,i.circular=!!t.circular,i.circularPathData=t.circularPathData,i._circularWidth=t._circularWidth,i._circularStub=t._circularStub,i.path=t.path,i.circularLinkType=t.circularLinkType,i.direction=h;const e=b.get(r),n=b.get(o);e&&(i.source=e),n&&(i.target=n)}}},buildScene(t,e,n,r){var o,i,l,a;const s="vertical"===n.orientation?"down":"right",c=n.nodeStyle,u=n.edgeStyle,h=null!==(o=n.edgeOpacity)&&void 0!==o?o:.5,d=n.edgeColorBy||"source",f=Array.isArray(n.colorScheme)?n.colorScheme:b,y=new Map;t.forEach((t,e)=>{y.set(t.id,f[e%f.length])});const g=[],p=[],m=[],v=new Map;for(const e of t){const t=e.x1-e.x0,n=e.y1-e.y0;if(0>=t||0>=n)continue;const r=c?c(Cr(e,"nodeStyle")):{},o={fill:r.fill||y.get(e.id)||"#4d430c",stroke:r.stroke,strokeWidth:r.strokeWidth,opacity:r.opacity};v.set(e.id,("string"==typeof o.fill?o.fill:null)||y.get(e.id)||"#4d430c"),g.push("down"===s?{type:"rect",x:e.y0,y:e.x0,w:n,h:t,style:o,datum:e,id:e.id,label:e.id}:{type:"rect",x:e.x0,y:e.y0,w:t,h:n,style:o,datum:e,id:e.id,label:e.id})}const x=[...e].sort((t,e)=>(e.sankeyWidth||0)-(t.sankeyWidth||0));for(const t of x){if(!t.sankeyWidth||0>=t.sankeyWidth)continue;const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;if(!e||!n)continue;let r="#999";r="function"==typeof d?d(t)||r:"target"===d?v.get(n.id)||y.get(n.id)||r:v.get(e.id)||y.get(e.id)||r;const o=u?u(Cr(t,"edgeStyle")):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,n=t.sankeyWidth/2,a=Math.max(15,Math.min(40,.33*(e.rightFullExtent-e.sourceX))),s=Math.max(15,Math.min(40,.33*(e.targetX-e.leftFullExtent))),c=o.fill||r;p.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-n}L${e.sourceX+a},${e.sourceY-n}L${e.sourceX+a},${e.sourceY+n}L${e.sourceX},${e.sourceY+n}Z`,style:{fill:c,fillOpacity:null!==(i=o.fillOpacity)&&void 0!==i?i:h,stroke:"none",opacity:o.opacity},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+a}}),p.push({type:"bezier",pathD:`M${e.targetX},${e.targetY-n}L${e.targetX-s},${e.targetY-n}L${e.targetX-s},${e.targetY+n}L${e.targetX},${e.targetY+n}Z`,style:{fill:c,fillOpacity:null!==(l=o.fillOpacity)&&void 0!==l?l:h,stroke:"none",opacity:o.opacity},datum:t,_gradient:{direction:"left",from:0,to:1,x0:e.targetX-s,x1:e.targetX}});continue}let s;if(s=t.circular&&t.circularPathData?Dr(t):Pr(t),!s)continue;const c={fill:o.fill||r,fillOpacity:null!==(a=o.fillOpacity)&&void 0!==a?a:h,stroke:o.stroke||"none",strokeWidth:o.strokeWidth,opacity:o.opacity};p.push({type:"bezier",pathD:s,bezierCache:t.bezier,style:c,datum:t})}if(!1!==n.showLabels){const e=(k=n.nodeLabel)?"function"==typeof k?k:t=>t[k]||t.id:null;for(const n of t){const t=n.x1-n.x0,o=n.y1-n.y0;if(0>=t||0>=o)continue;const i=e?e(n):n.id;if(!i)continue;let l,a,c;"down"===s?(l=n.y0+(n.y1-n.y0)/2,a=n.x1+14,c="middle"):(r[0]/2>n.x0+t/2?(l=n.x0-6,c="end"):(l=n.x1+6,c="start"),a=n.y0+o/2),m.push({x:l,y:a,text:i+"",anchor:c,baseline:"middle",fontSize:11})}}var k;return{sceneNodes:g,sceneEdges:p,labels:m}}},Or={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,r){var o,i;if(0===t.length)return;const l=null!==(o=n.forceStrength)&&void 0!==o?o:.1,a=r[0]/2,s=r[1]/2,c=n.__previousPositions;let u=0;const h=[];for(const e of t){const t=null!=e.x&&null!=e.y&&(0!==e.x||0!==e.y),n=null==c?void 0:c.get(e.id);t?u++:n?(e.x=n.x,e.y=n.y,u++):h.push(e)}const d=u>0&&.3>=(t.length>0?h.length/t.length:1);if(d){const n=new Map;for(const e of t)n.set(e.id,e);for(const t of h){const r=Wr(t.id,e,n);if(r.length>0){let e=0,n=0;for(const t of r)e+=t.x,n+=t.y;const o=Ir(t.id),i=o%360*(Math.PI/180),l=10+o%20;t.x=e/r.length+l*Math.cos(i),t.y=n/r.length+l*Math.sin(i)}else{const e=Ir(t.id),n=e%360*(Math.PI/180),r=15+e%30;t.x=a+r*Math.cos(n),t.y=s+r*Math.sin(n)}}}else{const e=2.399963229728653;for(let n=0;t.length>n;n++){const r=t[n];if(null==r.x||null==r.y||0===r.x&&0===r.y){const t=10*Math.sqrt(n+.5),o=n*e;r.x=a+t*Math.cos(o),r.y=s+t*Math.sin(o)}}}const f=null!==(i=n.iterations)&&void 0!==i?i:Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),y=d?40:f,g=zr(n.nodeSize,n.nodeSizeRange,t),p=t=>g(t),m=nt().strength(t=>Math.min(2.5,t.weight?t.weight*l:l)).id(t=>t.id),v=rt().force("charge",ot().strength(t=>-25*p(t))).force("center",it(a,s).strength(.8)).force("x",lt(a).strength(.15)).force("y",at(s).strength(.15));if(v.nodes(t),e.length>0){const t=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id}));v.force("link",m),v.force("link").links(t)}d?v.alpha(.3):.1>v.alpha()&&v.alpha(1),v.stop();for(let t=0;y>t;++t)v.tick();for(const e of t){if(null==e.x||null==e.y)continue;const t=p(e);e.x=Math.max(t,Math.min(r[0]-t,e.x)),e.y=Math.max(t,Math.min(r[1]-t,e.y)),e.x0=0,e.x1=0,e.y0=0,e.y1=0}const x=new Map;for(const e of t)x.set(e.id,e);for(const t of e){if("string"==typeof t.source){const e=x.get(t.source);e&&(t.source=e)}if("string"==typeof t.target){const e=x.get(t.target);e&&(t.target=e)}}},buildScene(t,e,n,r){var o,i,l;const a=n.nodeStyle,s=n.edgeStyle,c=zr(n.nodeSize,n.nodeSizeRange,t),u=Array.isArray(n.colorScheme)?n.colorScheme:b,h=new Map;t.forEach((t,e)=>{h.set(t.id,u[e%u.length])});const d=[],f=[],y=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=c(Cr(e,"nodeSize")),n=a?a(Cr(e,"nodeStyle")):{},r={fill:n.fill||h.get(e.id)||"#007bff",stroke:n.stroke||"#fff",strokeWidth:null!==(o=n.strokeWidth)&&void 0!==o?o:2,opacity:n.opacity};d.push({type:"circle",cx:e.x,cy:e.y,r:t,style:r,datum:e,id:e.id,label:e.id})}const g=new Map;for(const e of t)g.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:g.get(t.source),n="object"==typeof t.target?t.target:g.get(t.target);if(!e||!n)continue;if(null==e.x||null==e.y)continue;if(null==n.x||null==n.y)continue;const r=s?s(Cr(t,"edgeStyle")):{},o={stroke:r.stroke||"#999",strokeWidth:null!==(i=r.strokeWidth)&&void 0!==i?i:1,opacity:null!==(l=r.opacity)&&void 0!==l?l:.6};f.push({type:"line",x1:e.x,y1:e.y,x2:n.x,y2:n.y,style:o,datum:t})}if(!1!==n.showLabels){const e=(p=n.nodeLabel)?"function"==typeof p?p:t=>t[p]||t.id:null;for(const n of t){if(null==n.x||null==n.y)continue;const t=e?e(n):n.id;if(!t)continue;const r=c(Cr(n,"nodeSize"));y.push({x:n.x,y:n.y-r-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var p;return{sceneNodes:d,sceneEdges:f,labels:y}}};function Wr(t,e,n){const r=[];for(const o of e){const e="string"==typeof o.source?o.source:o.source.id,i="string"==typeof o.target?o.target:o.target.id;let l=null;if(e===t?l=i:i===t&&(l=e),l){const t=n.get(l);!t||0===t.x&&0===t.y||r.push({x:t.x,y:t.y})}}return r}function Ir(t){let e=0;for(let n=0;t.length>n;n++)e=(e<<5)-e+t.charCodeAt(n)|0;return Math.abs(e)}function zr(t,e,n){var r,o;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const i=e||[5,20],l=n.map(e=>{var n;return null===(n=e.data)||void 0===n?void 0:n[t]}).filter(t=>null!=t&&"number"==typeof t);if(0===l.length)return()=>i[0];const a=null!==(r=S(l))&&void 0!==r?r:0,s=null!==(o=P(l))&&void 0!==o?o:1;if(a===s)return()=>(i[0]+i[1])/2;const c=m().domain([a,s]).range(i).clamp(!0);return e=>{var n;const r=null===(n=e.data)||void 0===n?void 0:n[t];return null==r||"number"!=typeof r?i[0]:c(r)}}const Br=b,jr={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,n,r){if(0===t.length)return;const{padAngle:o=.01,groupWidth:i=20,sortGroups:l}=n,a=Math.min(r[0],r[1])/2,s=a-i,c=r[0]/2,u=r[1]/2,h=(d=n.valueAccessor)?"function"==typeof d?d:t=>{var e;return null!==(e=t[d])&&void 0!==e?e:1}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:1};var d;const f=new Map;for(let e=0;t.length>e;e++)f.set(t[e].id,e);const y=t.length,g=Array.from({length:y},()=>Array.from({length:y},()=>0));for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=f.get("string"==typeof t.source?t.source:t.source.id),r=f.get(e);if(void 0===n||void 0===r)continue;const o=h(t);g[n][r]=o}const p=ct().padAngle(o);l&&p.sortGroups(l);const m=p(g),v=m.groups,x=K().innerRadius(s).outerRadius(a);for(const e of v){const n=t[e.index],r=x.centroid(e);n.x=r[0]+c,n.y=r[1]+u,n.arcData={startAngle:e.startAngle,endAngle:e.endAngle}}const b=new Map;for(const e of t)b.set(e.id,e);for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=b.get("string"==typeof t.source?t.source:t.source.id),r=b.get(e);n&&(t.source=n),r&&(t.target=r)}const k=new Map;for(const t of e)k.set(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const e of m){const n=t[e.source.index].id,r=t[e.target.index].id,o=k.get(`${n}\0${r}`)||k.get(`${r}\0${n}`);o&&(o.chordData=e)}},buildScene(t,e,n,r){var o,i;const{groupWidth:l=20,edgeOpacity:a=.5}=n,s=Math.min(r[0],r[1])/2,c=s-l,u=r[0]/2,h=r[1]/2,d=n.nodeStyle,f=n.edgeStyle,y=n.edgeColorBy||"source",g=Array.isArray(n.colorScheme)?n.colorScheme:Br,p=new Map;t.forEach((t,e)=>{p.set(t.id,g[e%g.length])});const m=st().radius(c),v=[],x=[],b=[];for(let e=0;t.length>e;e++){const n=t[e],r=n.arcData;if(!r)continue;let i;i=d?d(Cr(n,"nodeStyle")).fill||p.get(n.id)||g[e%g.length]:p.get(n.id)||g[e%g.length];const l=d?d(Cr(n,"nodeStyle")):{},a={fill:i,stroke:l.stroke||"black",strokeWidth:null!==(o=l.strokeWidth)&&void 0!==o?o:1,opacity:l.opacity};v.push({type:"arc",cx:u,cy:h,innerR:c,outerR:s,startAngle:r.startAngle-Math.PI/2,endAngle:r.endAngle-Math.PI/2,style:a,datum:n,id:n.id,label:n.id})}for(const t of e){const e=t.chordData;if(!e)continue;const n=m(e);if(!n)continue;const r=Fr(n,u,h);let o="#999";if(f)o=f(Cr(t,"edgeStyle")).fill||o;else{const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;"target"===y&&n?o=p.get(n.id)||o:e&&(o=p.get(e.id)||o)}const l=f?f(Cr(t,"edgeStyle")):{},s={fill:o,fillOpacity:null!==(i=l.fillOpacity)&&void 0!==i?i:a,stroke:l.stroke||"none",strokeWidth:l.strokeWidth,opacity:l.opacity};x.push({type:"ribbon",pathD:r,style:s,datum:t})}if(!1!==n.showLabels){const e=(k=n.nodeLabel)?"function"==typeof k?k:t=>t[k]||t.id:null,r=s+12;for(const n of t){const t=n.arcData;if(!t)continue;const o=e?e(n):n.id;if(!o)continue;const i=(t.startAngle+t.endAngle)/2,l=i-Math.PI/2;b.push({x:u+Math.cos(l)*r,y:h+Math.sin(l)*r,text:o+"",anchor:i>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var k;return{sceneNodes:v,sceneEdges:x,labels:b}}};function Fr(t,e,n){const r=t.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!r)return t;const o=[];let i=0;for(;r.length>i;){const t=r[i];if("M"===t||"L"===t)for(o.push(t),i++;r.length>i&&!isNaN(Number(r[i]));)o.push(Number(r[i])+e+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("C"===t)for(o.push(t),i++;r.length>i&&!isNaN(Number(r[i]));)for(let t=0;3>t&&r.length>i&&!isNaN(Number(r[i]));t++)o.push(Number(r[i])+e+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("Q"===t)for(o.push(t),i++;r.length>i&&!isNaN(Number(r[i]));)for(let t=0;2>t&&r.length>i&&!isNaN(Number(r[i]));t++)o.push(Number(r[i])+e+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("A"===t)for(o.push(t),i++;r.length>i&&!isNaN(Number(r[i]));)o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&(o.push(Number(r[i])+e+""),i++),r.length>i&&(o.push(Number(r[i])+n+""),i++);else"Z"===t||"z"===t?(o.push(t),i++):(o.push(r[i]),i++)}return o.join(" ")}const Rr=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Yr(t){const[e,n,r]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(t);return.299*e+.587*n+.114*r>150?"#222":"#fff"}function Hr(t,e,n){const r=e.nodeIDAccessor;return"function"==typeof r?r(t.data)+"":"string"==typeof r&&void 0!==t.data[r]?t.data[r]+"":void 0!==t.data.name?t.data.name+"":void 0!==t.data.id?t.data.id+"":"node-"+n}function Xr(t){return t?"function"==typeof t?t:e=>{var n;return(null===(n=e.data)||void 0===n?void 0:n[t])||e[t]||e.id}:null}function Gr(t,e,n,r,o){if("horizontal"===o){const o=(t+n)/2;return`M ${t},${e} C ${o},${e} ${o},${r} ${n},${r}`}if("radial"===o){const o=(t+n)/2;return`M ${t},${e} Q ${o},${e} ${o},${(e+r)/2} T ${n},${r}`}{const o=(e+r)/2;return`M ${t},${e} C ${t},${o} ${n},${o} ${n},${r}`}}const Vr={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,n,r){var o;const i=n.__hierarchyRoot;if(!i)return;const l=n.chartType,a=function(t){if(t)return"function"==typeof t?t:e=>e[t]}(n.childrenAccessor),s=n.hierarchySum||(t=>{var e;return null!==(e=t.value)&&void 0!==e?e:0}),c=$(i,a);c.sum(s),c.sort((t,e)=>{var n,r;return(null!==(n=e.value)&&void 0!==n?n:0)-(null!==(r=t.value)&&void 0!==r?r:0)});const[u,h]=r;switch(l){case"tree":!function(t,e,n,r){const o=e.treeOrientation||"vertical",i=B();i.size("horizontal"===o?[r,n]:"radial"===o?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),i(t)}(c,n,u,h);break;case"cluster":!function(t,e,n,r){const o=e.treeOrientation||"vertical",i=z();i.size("horizontal"===o?[r,n]:"radial"===o?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),i(t)}(c,n,u,h);break;case"treemap":!function(t,e,n,r){var o,i;const l=null!==(o=e.padding)&&void 0!==o?o:4,a=null!==(i=e.paddingTop)&&void 0!==i?i:0,s=W().size([n,r]).tile(I).padding(l);a>0&&s.paddingTop(a),s(t)}(c,n,u,h);break;case"circlepack":!function(t,e,n,r){var o;const i=null!==(o=e.padding)&&void 0!==o?o:4;O().size([n,r]).padding(i)(t)}(c,n,u,h);break;case"partition":!function(t,e,n,r){var o;N().size([n,r]).padding(null!==(o=e.padding)&&void 0!==o?o:1)(t)}(c,n,u,h)}const d=c.descendants();t.length=0,e.length=0;const f=new Map;for(let e=0;d.length>e;e++){const r=d[e],i={id:Hr(r,n,e),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(o=r.value)&&void 0!==o?o:0,depth:r.depth,data:r.data,createdByFrame:!0};"tree"===l||"cluster"===l?qr(i,r,n):"treemap"===l||"partition"===l?Ur(i,r):"circlepack"===l&&Kr(i,r),i.__hierarchyNode=r,t.push(i),f.set(r,i)}if("tree"===l||"cluster"===l)for(const t of d)if(t.parent){const n=f.get(t.parent),r=f.get(t);n&&r&&e.push({source:n,target:r,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,n,r){const o=n.nodeStyle||(()=>({})),i=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(t,e,n,r,o,i){var l,a,s,c,u;const h=[],d=[],f=[],y=n.treeOrientation||"vertical",g="radial"===y,p=r[0]/2,m=r[1]/2,v="number"==typeof(x=n.nodeSize)?x:5;var x;for(const e of t){let t=e.x,r=e.y;g&&(t+=p,r+=m);const i=o(Cr(e,"nodeStyle"));let a=i.fill||"#4d430c";n.colorByDepth&&void 0!==e.depth&&(a=Rr[e.depth%Rr.length]);const s={fill:a,stroke:i.stroke||"#fff",strokeWidth:null!==(l=i.strokeWidth)&&void 0!==l?l:1,opacity:i.opacity};h.push({type:"circle",cx:t,cy:r,r:v,style:s,datum:e,id:e.id,label:e.id,depth:e.depth})}const b=null!==(a=n.edgeOpacity)&&void 0!==a?a:.5;for(const t of e){const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;if(!e||!n)continue;let r=e.x,o=e.y,l=n.x,a=n.y;g&&(r+=p,o+=m,l+=p,a+=m);const u=Gr(r,o,l,a,y),h=i(Cr(t,"edgeStyle")),f={fill:"none",stroke:h.stroke||"#999",strokeWidth:null!==(s=h.strokeWidth)&&void 0!==s?s:1.5,opacity:null!==(c=h.opacity)&&void 0!==c?c:b};d.push({type:"curved",pathD:u,style:f,datum:t})}if(!1!==n.showLabels){const e=Xr(n.nodeLabel);for(const n of t){const t=e?e(n):n.id;if(!t)continue;let r,o,i,l=n.x,a=n.y;if(g&&(l+=p,a+=m),g){const t=l-p,e=a-m,n=Math.sqrt(t*t+e*e);n>0?(r=l+t/n*10,o=a+e/n*10,i=0>t?"end":"start"):(r=l,o=a-12,i="middle")}else"horizontal"===y?((null===(u=n.data)||void 0===u?void 0:u.children)&&0!==n.data.children.length?(r=l-v-6,i="end"):(r=l+v+6,i="start"),o=a):(r=l,o=a+v+14,i="middle");f.push({x:r,y:o,text:t+"",anchor:i,baseline:"middle",fontSize:11})}}return{sceneNodes:h,sceneEdges:d,labels:f}}(t,e,n,r,o,i);case"treemap":case"partition":return function(t,e,n,r){var o,i;const l=[],a=[];for(const n of t){const t=n.x1-n.x0,i=n.y1-n.y0;if(0>=t||0>=i)continue;const a=r(Cr(n,"nodeStyle"));let s=a.fill||"#4d430c";e.colorByDepth&&void 0!==n.depth&&(s=Rr[n.depth%Rr.length]);const c={fill:s,stroke:a.stroke||"#fff",strokeWidth:null!==(o=a.strokeWidth)&&void 0!==o?o:1,opacity:a.opacity};l.push({type:"rect",x:n.x0,y:n.y0,w:t,h:i,style:c,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==e.showLabels){const n=Xr(e.nodeLabel),o=e.labelMode||"leaf",l="partition"===e.chartType;for(const s of t){const t=s.x1-s.x0,c=s.y1-s.y0;if(0>=t||0>=c)continue;const u=!((null===(i=s.data)||void 0===i?void 0:i.children)&&s.data.children.length>0);if(!l){if("leaf"===o&&!u)continue;if("parent"===o&&u)continue}const h=n?n(s):s.id;if(!h)continue;if((u?30:40)>t||(u?16:14)>c)continue;let d=r(Cr(s,"nodeStyle")).fill||"#4d430c";e.colorByDepth&&void 0!==s.depth&&(d=Rr[s.depth%Rr.length]);const f=Yr(d);a.push(u?{x:s.x0+t/2,y:s.y0+c/2,text:h+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,c)/6)),fill:f}:{x:s.x0+4,y:s.y0+12,text:h+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:f})}}return{sceneNodes:l,sceneEdges:[],labels:a}}(t,n,0,o);case"circlepack":return function(t,e,n,r){var o,i,l,a,s;const c=[],u=[];for(const n of t){const t=null!==(o=n.__radius)&&void 0!==o?o:5;if(0>=t)continue;const a=r(Cr(n,"nodeStyle"));let s=a.fill||"#4d430c";e.colorByDepth&&void 0!==n.depth&&(s=Rr[n.depth%Rr.length]);const u={fill:s,stroke:a.stroke||"#fff",strokeWidth:null!==(i=a.strokeWidth)&&void 0!==i?i:1,opacity:null!==(l=a.opacity)&&void 0!==l?l:.7};c.push({type:"circle",cx:n.x,cy:n.y,r:t,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==e.showLabels){const n=Xr(e.nodeLabel);for(const o of t){const t=null!==(a=o.__radius)&&void 0!==a?a:5,i=n?n(o):o.id;if(!i)continue;if(15>t)continue;const l=!((null===(s=o.data)||void 0===s?void 0:s.children)&&o.data.children.length>0);let c=r(Cr(o,"nodeStyle")).fill||"#4d430c";if(e.colorByDepth&&void 0!==o.depth&&(c=Rr[o.depth%Rr.length]),l){const e=Yr(c);u.push({x:o.x,y:o.y,text:i+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,t/3)),fill:e})}else u.push({x:o.x,y:o.y-t+14,text:i+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,t/3)),fill:"#000",stroke:"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:c,sceneEdges:[],labels:u}}(t,n,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function qr(t,e,n){const r=n.treeOrientation||"vertical";if("radial"===r){const n=e.x,r=e.y;t.x=r*Math.cos(n-Math.PI/2),t.y=r*Math.sin(n-Math.PI/2)}else"horizontal"===r?(t.x=e.y,t.y=e.x):(t.x=e.x,t.y=e.y);t.x0=t.x-5,t.x1=t.x+5,t.y0=t.y-5,t.y1=t.y+5,t.width=10,t.height=10}function Ur(t,e){t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.x=(e.x0+e.x1)/2,t.y=(e.y0+e.y1)/2,t.width=e.x1-e.x0,t.height=e.y1-e.y0}function Kr(t,e){var n;const r=null!==(n=e.r)&&void 0!==n?n:0;t.x=e.x,t.y=e.y,t.x0=e.x-r,t.x1=e.x+r,t.y0=e.y-r,t.y1=e.y+r,t.width=2*r,t.height=2*r,t.__radius=r}function Zr(t){const e=t;return e.__orbitState||(e.__orbitState={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()}),e.__orbitState}const Qr={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(t,e,n,r){const o=n.__hierarchyRoot;o&&function(t,e,n,r,o){var i,l;const a=function(t){if("function"==typeof t)return t;const e=t||"children";return t=>t[e]||null}(n.childrenAccessor),s=function(t){if("function"==typeof t)return t;const e=t||"name";return t=>{var n;return(null!==(n=t[e])&&void 0!==n?n:"")+""}}(n.nodeIDAccessor),c=function(t){if(Array.isArray(t))return t;switch(t){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(n.orbitMode),u=null!==(i=n.orbitSize)&&void 0!==i?i:2.95,h=null!==(l=n.orbitEccentricity)&&void 0!==l?l:1,d="number"==typeof u?()=>u:u,f="number"==typeof h?()=>h:h,y=Zr(n);y.metaMap.clear(),r.length=0,o.length=0;const g=new Map;function p(t){var e;const n=null!==(e=g.get(t))&&void 0!==e?e:0;return g.set(t,n+1),0===n?t:`${t}__${n}`}const m=e[0]/2,v=e[1]/2,x=Math.min(e[0],e[1])/2*.85,b=p(s(t));r.push({id:b,x:m,y:v,x0:m,x1:m,y0:v,y1:v,width:0,height:0,value:0,depth:0,data:t}),y.metaMap.set(b,{ring:x,angle:0,depth:0,parentId:null,eccentricity:1}),function t(e,n,i,l,u,h,g){const m=a(e);if(!(null==m?void 0:m.length))return;const v=m.length;let x=0,b=0,k=0;for(;v>b;)b+=c[Math.min(k,c.length-1)],k++,x++;let w=0;for(let v=0;x>v;v++){const b=c[Math.min(v,c.length-1)],k=m.slice(w,w+b);if(!k.length)break;const E=(v+1)/x,A={id:n,depth:h,data:e,parentId:n},M=g?u/d(A)*E:u*E,S=J().value(t=>{var e;return(null===(e=a(t))||void 0===e?void 0:e.length)?4:1}).sort(null),_=S(k),P=f(A);for(let e=0;k.length>e;e++){const a=(_[e].startAngle+_[e].endAngle)/2,c=k[e],u=p(s(c)),d=i+M*Math.sin(a),f=l+M*Math.cos(a)*P;r.push({id:u,x:d,y:f,x0:d,x1:d,y0:f,y1:f,width:0,height:0,value:0,depth:h,data:c}),y.metaMap.set(u,{ring:M,angle:a,depth:h,parentId:n,eccentricity:P}),o.push({source:n,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:u}}),t(c,u,d,f,M,h+1,!0)}w+=b}}(t,b,m,v,x,1,!1)}(o,r,n,t,e)},buildScene(t,e,n,r){var o,i,l,a,s;const c=n.nodeStyle,u=n.nodeSize,h="number"==typeof u?()=>u:"function"==typeof u?u:()=>6,d=[],f=[],y=[];if(!1!==n.orbitShowRings){const e=Zr(n),r=new Map;for(const e of t)r.set(e.id,e);const o=new Map;for(const[,t]of e.metaMap){if(!t.parentId)continue;const e=r.get(t.parentId);if(!e)continue;const n=`${t.parentId}:${t.ring}`;o.has(n)||o.set(n,{parentX:e.x,parentY:e.y,ring:t.ring,ecc:t.eccentricity})}const i=48,l={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:t,parentY:e,ring:n,ecc:r}]of o)for(let o=0;i>o;o++){const a=o/i*Math.PI*2,s=(o+1)/i*Math.PI*2;f.push({type:"line",x1:t+n*Math.sin(a),y1:e+n*Math.cos(a)*r,x2:t+n*Math.sin(s),y2:e+n*Math.cos(s)*r,style:l,datum:null})}}for(const e of t){if(null==e.x||null==e.y)continue;const t=h(Cr(e,"nodeSize")),n=c?c(Cr(e,"nodeStyle")):{},r={fill:n.fill||"#6366f1",stroke:n.stroke||"#fff",strokeWidth:null!==(o=n.strokeWidth)&&void 0!==o?o:1,opacity:null!==(i=n.opacity)&&void 0!==i?i:0===(null!==(l=e.depth)&&void 0!==l?l:0)?1:.85};d.push({type:"circle",cx:e.x,cy:e.y,r:t,style:r,datum:e,id:e.id,label:e.id,depth:e.depth})}const g=new Map;for(const e of t)g.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:g.get(t.source),n="object"==typeof t.target?t.target:g.get(t.target);e&&n&&(null!=e.x&&null!=n.x&&f.push({type:"line",x1:e.x,y1:e.y,x2:n.x,y2:n.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:t}))}if(n.showLabels){const e=n.nodeLabel;for(const n of t){const t=h(Cr(n,"nodeSize"));if(4>=t)continue;const r="function"==typeof e?e(n):e&&null!==(s=null===(a=n.data)||void 0===a?void 0:a[e])&&void 0!==s?s:n.id;y.push({x:n.x,y:n.y+t+12,text:r+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:d,sceneEdges:f,labels:y}},tick:(t,e,n,r,o)=>!1!==n.orbitAnimated&&(function(t,e){var n,r;const o=Zr(e),i=null!==(n=e.orbitSpeed)&&void 0!==n?n:.25,l=null!==(r=e.orbitRevolution)&&void 0!==r?r:function(t){switch(t){case"decay":return t=>{var e;return Math.pow(.6,null!==(e=t.depth)&&void 0!==e?e:0)};case"alternate":return t=>{var e;const n=null!==(e=t.depth)&&void 0!==e?e:0;return(n%2==0?1:-1)/(n+1)};default:return t=>{var e;return 1/((null!==(e=t.depth)&&void 0!==e?e:0)+1)}}}(e.orbitRevolutionStyle),a=(("undefined"!=typeof performance?performance.now():Date.now())-o.startTime)/1e3,s=i*(Math.PI/6),c=new Map;for(const e of t)c.set(e.id,e);for(const e of t){const t=o.metaMap.get(e.id);if(!t||!t.parentId)continue;const n=c.get(t.parentId);if(!n)continue;const r=t.angle+a*s*l({id:e.id,depth:t.depth,data:e.data,parentId:t.parentId});e.x=n.x+t.ring*Math.sin(r),e.y=n.y+t.ring*Math.cos(r)*t.eccentricity,e.x0=e.x,e.x1=e.x,e.y0=e.y,e.y1=e.y}}(t,n),!0)},Jr={sankey:Nr,force:Or,chord:jr,tree:Vr,cluster:Vr,treemap:Vr,circlepack:Vr,partition:Vr,orbit:Qr};function to(t){return Jr[t]}class eo{constructor(t){this.nodes=new Map,this.edges=new Map,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.particlePool=null,this.transition=null,this.lastIngestTime=0,this.nodeTimestamps=new Map,this.edgeTimestamps=new Map,this._decaySortedNodes=null,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this._lastPositionSnapshot=null,this.config=t,this.tensionConfig=Object.assign(Object.assign({},zn),t.tensionConfig),"sankey"===t.chartType&&t.showParticles&&(this.particlePool=new jn(2e3))}updateConfig(t){const e=this.config,n=t;e.__orbitState&&(n.__orbitState=e.__orbitState),e.__hierarchyRoot&&(n.__hierarchyRoot=e.__hierarchyRoot),this.config=t,this.tensionConfig=Object.assign(Object.assign({},zn),t.tensionConfig),"sankey"===t.chartType&&t.showParticles&&!this.particlePool&&(this.particlePool=new jn(2e3))}ingestHierarchy(t,e){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this.config.__hierarchyRoot=t,this.runLayout(e)}ingestBounded(t,e,n){const{nodeIDAccessor:r="id",sourceAccessor:o="source",targetAccessor:i="target",valueAccessor:l="value"}=this.config,a="function"==typeof r?r:t=>t[r],s="function"==typeof o?o:t=>t[o],c="function"==typeof i?i:t=>t[i],u="function"==typeof l?l:t=>{var e;return null!==(e=t[l])&&void 0!==e?e:1};this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const e of t){const t=a(e)+"";this.nodes.set(t,Object.assign(Object.assign({},no(t)),{data:e}))}for(let t=0;e.length>t;t++){const n=e[t],r=s(n)+"",o=c(n)+"",i=Number(u(n))||1;this.nodes.has(r)||this.nodes.set(r,Object.assign(Object.assign({},no(r)),{data:n})),this.nodes.has(o)||this.nodes.set(o,Object.assign(Object.assign({},no(o)),{data:n}));const l=`${r}\0${o}\0${t}`;this.edges.set(l,{source:r,target:o,value:i,y0:0,y1:0,sankeyWidth:0,data:n,_edgeKey:l})}this.runLayout(n)}edgeKey(t,e){return`${t}\0${e}`}ingestEdge(t){const{source:e,target:n,value:r}=t,o=0===this.nodes.size;let i=!1;const l="undefined"!=typeof performance?performance.now():Date.now();this.lastIngestTime=l,this._decaySortedNodes=null,this.nodes.has(e)||(this.nodes.set(e,no(e)),this.nodeTimestamps.set(e,l),this.tension+=this.tensionConfig.newNode,i=!0),this.nodes.has(n)||(this.nodes.set(n,no(n)),this.nodeTimestamps.set(n,l),this.tension+=this.tensionConfig.newNode,i=!0);const a=this.edgeKey(e,n),s=this.edges.get(a);let c=!1;return s?(s.value+=r,this.edgeTimestamps.set(a,l),this.tension+=this.tensionConfig.weightChange,c=!0):(this.edges.set(a,{source:e,target:n,value:r,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(a,l),this.tension+=this.tensionConfig.newEdge,i=!0),o||i||c||this.tension>=this.tensionConfig.threshold}runLayout(t){var e,n,r,o,i,l;const a=to(this.config.chartType);if(!a)return;let s=Array.from(this.nodes.values()),c=Array.from(this.edges.values());if(0===s.length&&!a.hierarchical)return;if(this.prepareForRelayout(),a.supportsStreaming&&!a.hierarchical){const t=new Map;for(const a of s)if(void 0!==a._prevX0){const s=(null!==(e=a._prevX1)&&void 0!==e?e:0)-(null!==(n=a._prevX0)&&void 0!==n?n:0),c=(null!==(r=a._prevY1)&&void 0!==r?r:0)-(null!==(o=a._prevY0)&&void 0!==o?o:0);t.set(a.id,{x:(null!==(i=a._prevX0)&&void 0!==i?i:0)+s/2,y:(null!==(l=a._prevY0)&&void 0!==l?l:0)+c/2})}else 0===a.x&&0===a.y||t.set(a.id,{x:a.x,y:a.y});if(this._lastPositionSnapshot)for(const[e,n]of this._lastPositionSnapshot)t.has(e)||t.set(e,n);this.config.__previousPositions=t.size>0?t:void 0}if(a.computeLayout(s,c,this.config,t),delete this.config.__previousPositions,a.hierarchical&&s.length>0){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const t of s)this.nodes.set(t.id,t);for(let t=0;c.length>t;t++){const e=c[t],n=e._edgeKey||`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}\0${t}`;e._edgeKey=n,this.edges.set(n,e)}}this.finalizeLayout();const u=new Map;for(const t of this.nodes.values())0===t.x&&0===t.y||u.set(t.id,{x:t.x,y:t.y});this._lastPositionSnapshot=u,this.saveTargetPositions(),s.some(t=>void 0!==t._prevX0&&(0!==t._prevX0||0!==t._prevX1||0!==t._prevY0||0!==t._prevY1))&&this.tensionConfig.transitionDuration>0&&(this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:this.tensionConfig.transitionDuration});const h=new Set(this.nodes.keys()),d=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const t of h)this.previousNodeIds.has(t)||this.addedNodes.add(t);for(const t of this.previousNodeIds)h.has(t)||this.removedNodes.add(t);for(const t of d)this.previousEdgeKeys.has(t)||this.addedEdges.add(t);for(const t of this.previousEdgeKeys)d.has(t)||this.removedEdges.add(t);(this.addedNodes.size>0||this.removedNodes.size>0||this.addedEdges.size>0||this.removedEdges.size>0)&&(this.lastTopologyChangeTime="undefined"!=typeof performance?performance.now():Date.now()),this.previousNodeIds=h,this.previousEdgeKeys=d,this.layoutVersion++}buildScene(t){const e=to(this.config.chartType);if(!e)return;const n=Array.from(this.nodes.values()),r=Array.from(this.edges.values()),{sceneNodes:o,sceneEdges:i,labels:l}=e.buildScene(n,r,this.config,t);this.sceneNodes=o,this.sceneEdges=i,this.labels=l}get isAnimating(){const t=to(this.config.chartType);return!!(null==t?void 0:t.supportsAnimation)&&!1!==this.config.orbitAnimated}tickAnimation(t,e){const n=to(this.config.chartType);if(!(null==n?void 0:n.tick))return!1;const r=Array.from(this.nodes.values()),o=Array.from(this.edges.values());return n.tick(r,o,this.config,t,e)}advanceTransition(t){if(!this.transition)return!1;const e=St(t,this.transition),n=Mt(e);for(const t of this.nodes.values())void 0===t._targetX0||void 0===t._prevX0||0===t._prevX0&&0===t._prevX1||(t.x0=_t(t._prevX0,t._targetX0,n),t.x1=_t(t._prevX1,t._targetX1,n),t.y0=_t(t._prevY0,t._targetY0,n),t.y1=_t(t._prevY1,t._targetY1,n));for(const t of this.edges.values())void 0!==t._targetY0&&void 0!==t._prevY0&&void 0!==t._prevSankeyWidth&&t._prevSankeyWidth>0&&(t.y0=_t(t._prevY0,t._targetY0,n),t.y1=_t(t._prevY1,t._targetY1,n),t.sankeyWidth=_t(t._prevSankeyWidth,t._targetSankeyWidth,n));return this.rebuildAllBeziers(),1>e||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){for(const t of this.nodes.values())t._prevX0=t.x0,t._prevX1=t.x1,t._prevY0=t.y0,t._prevY1=t.y1;for(const t of this.edges.values())t._prevY0=t.y0,t._prevY1=t.y1,t._prevSankeyWidth=t.sankeyWidth}finalizeLayout(){const t="vertical"===this.config.orientation?"down":"right";for(const t of this.nodes.values())if(0!==t.x0||0!==t.x1||0!==t.y0||0!==t.y1)t.width=t.x1-t.x0,t.height=t.y1-t.y0,t.x=t.x0+t.width/2,t.y=t.y0+t.height/2;else{const e=5;t.x0=t.x-e,t.x1=t.x+e,t.y0=t.y-e,t.y1=t.y+e,t.width=2*e,t.height=2*e}for(const e of this.edges.values())e.direction=t,this.updateEdgeBezier(e);this.tension=0}saveTargetPositions(){for(const t of this.nodes.values())t._targetX0=t.x0,t._targetX1=t.x1,t._targetY0=t.y0,t._targetY1=t.y1;for(const t of this.edges.values())t._targetY0=t.y0,t._targetY1=t.y1,t._targetSankeyWidth=t.sankeyWidth}restorePreviousPositions(){for(const t of this.nodes.values())void 0===t._prevX0||0===t._prevX0&&0===t._prevX1||(t.x0=t._prevX0,t.x1=t._prevX1,t.y0=t._prevY0,t.y1=t._prevY1);for(const t of this.edges.values())void 0!==t._prevY0&&void 0!==t._prevSankeyWidth&&t._prevSankeyWidth>0&&(t.y0=t._prevY0,t.y1=t._prevY1,t.sankeyWidth=t._prevSankeyWidth);this.rebuildAllBeziers()}snapToTargets(){for(const t of this.nodes.values())void 0!==t._targetX0&&(t.x0=t._targetX0,t.x1=t._targetX1,t.y0=t._targetY0,t.y1=t._targetY1);for(const t of this.edges.values())void 0!==t._targetY0&&(t.y0=t._targetY0,t.y1=t._targetY1,t.sankeyWidth=t._targetSankeyWidth);this.rebuildAllBeziers()}updateEdgeBezier(t){const e="string"==typeof t.source?this.nodes.get(t.source):t.source,n="string"==typeof t.target?this.nodes.get(t.target):t.target;e&&n&&(t.bezier=t.circular&&t.circularPathData?this.buildCircularBezier(t):this.buildStandardBezier(t,e,n))}buildStandardBezier(t,e,n){const r=(t.sankeyWidth||1)/2;if("down"===t.direction){const o=e.x1,i=n.x0,l=et(o,i);return{circular:!1,points:[{x:t.y0,y:o},{x:t.y0,y:l(.5)},{x:t.y1,y:l(.5)},{x:t.y1,y:i}],halfWidth:r}}const o=e.x1,i=n.x0,l=et(o,i);return{circular:!1,points:[{x:o,y:t.y0},{x:l(.5),y:t.y0},{x:l(.5),y:t.y1},{x:i,y:t.y1}],halfWidth:r}}buildCircularBezier(t){const e=(t._circularWidth||t.sankeyWidth||1)/2,n=t.circularPathData;if(t._circularStub){const t=Math.max(15,Math.min(40,.33*(n.rightFullExtent-n.sourceX))),r=Math.max(15,Math.min(40,.33*(n.targetX-n.leftFullExtent)));return{circular:!0,segments:[[{x:n.sourceX,y:n.sourceY},{x:n.sourceX+.33*t,y:n.sourceY},{x:n.sourceX+.66*t,y:n.sourceY},{x:n.sourceX+t,y:n.sourceY}],[{x:n.targetX-r,y:n.targetY},{x:n.targetX-.66*r,y:n.targetY},{x:n.targetX-.33*r,y:n.targetY},{x:n.targetX,y:n.targetY}]],halfWidth:e}}let r;r="down"===t.direction?[{x:n.sourceY,y:n.sourceX},{x:n.sourceY,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.leftFullExtent},{x:n.targetY,y:n.leftFullExtent},{x:n.targetY,y:n.targetX}]:[{x:n.sourceX,y:n.sourceY},{x:n.rightFullExtent,y:n.sourceY},{x:n.rightFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.targetY},{x:n.targetX,y:n.targetY}];const o=[];for(let t=0;r.length-1>t;t++){const e=r[t],n=r[t+1],i=n.x-e.x,l=n.y-e.y;o.push([e,{x:e.x+i/3,y:e.y+l/3},{x:e.x+2*i/3,y:e.y+2*l/3},n])}return{circular:!0,segments:o,halfWidth:e}}rebuildAllBeziers(){for(const t of this.nodes.values())t.width=t.x1-t.x0,t.height=t.y1-t.y0,t.x=t.x0+t.width/2,t.y=t.y0+t.height/2;for(const t of this.edges.values())this.updateEdgeBezier(t)}applyPulse(t){var e,n,r,o,i;const l=this.config.pulse;if(!l)return;const a=null!==(e=l.duration)&&void 0!==e?e:500,s=null!==(n=l.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",c=null!==(r=l.glowRadius)&&void 0!==r?r:4;for(const e of this.sceneNodes){const n=e.id;if(!n)continue;const r=this.nodeTimestamps.get(n);if(!r)continue;const o=t-r;a>o&&(e._pulseIntensity=1-o/a,e._pulseColor=s,e._pulseGlowRadius=c)}for(const e of this.sceneEdges){const n=e.datum;if(!n)continue;const r="object"==typeof n.source?null===(o=n.source)||void 0===o?void 0:o.id:n.source,l="object"==typeof n.target?null===(i=n.target)||void 0===i?void 0:i.id:n.target;if(!r||!l)continue;const c=this.edgeTimestamps.get(`${r}\0${l}`);if(!c)continue;const u=t-c;a>u&&(e._pulseIntensity=1-u/a,e._pulseColor=s)}}applyDecay(){var t,e,n,r,o;const i=this.config.decay;if(!i)return;const l=null!==(t=i.minOpacity)&&void 0!==t?t:.1,a=this.nodeTimestamps.size;if(1>=a)return;this._decaySortedNodes||(this._decaySortedNodes=Array.from(this.nodeTimestamps.entries()).sort((t,e)=>t[1]-e[1]));const s=this._decaySortedNodes,c=new Map;for(let t=0;s.length>t;t++)c.set(s[t][0],t);for(const t of this.sceneNodes){const s=t.id;if(!s)continue;const u=c.get(s);if(void 0===u)continue;const h=a-1-u;let d;switch(i.type){case"linear":d=l+(1-h/(a-1))*(1-l);break;case"exponential":{const t=null!==(e=i.halfLife)&&void 0!==e?e:a/2;d=l+Math.pow(.5,h/t)*(1-l);break}case"step":d=(null!==(n=i.stepThreshold)&&void 0!==n?n:.5*a)>h?1:l;break;default:d=1}const f=null!==(o=null===(r=t.style)||void 0===r?void 0:r.opacity)&&void 0!==o?o:1;t.style=Object.assign(Object.assign({},t.style),{opacity:f*d})}}applyTopologyDiff(t){var e;if(0===this.addedNodes.size)return;const n=t-this.lastTopologyChangeTime;if(n>=2e3)return;const r=1-n/2e3;for(const t of this.sceneNodes){const n=t.id;n&&this.addedNodes.has(n)&&(t._pulseIntensity=Math.max(null!==(e=t._pulseIntensity)&&void 0!==e?e:0,r),t._pulseColor="rgba(34, 197, 94, 0.7)",t._pulseGlowRadius=8)}}get hasActiveTopologyDiff(){return 0!==this.addedNodes.size&&2e3>("undefined"!=typeof performance?performance.now():Date.now())-this.lastTopologyChangeTime}applyThresholds(t){var e,n;const r=this.config.thresholds;if(!r)return;const o=null!==(e=r.warningColor)&&void 0!==e?e:"#f59e0b",i=null!==(n=r.criticalColor)&&void 0!==n?n:"#ef4444",l=!1!==r.pulse;for(const e of this.sceneNodes){const n=e.id;if(!n)continue;const a=this.nodes.get(n);if(!a)continue;const s=r.metric(a);let c=null;void 0===r.critical||r.critical>s?void 0===r.warning||r.warning>s||(c=o):c=i,c&&(e.style=Object.assign(Object.assign({},e.style),{fill:c}),l&&(e._pulseIntensity=.6+.4*Math.sin(t/300),e._pulseColor=c,e._pulseGlowRadius=6))}}get hasActiveThresholds(){const t=this.config.thresholds;if(!t)return!1;for(const e of this.nodes.values()){const n=t.metric(e);if(void 0!==t.warning&&n>=t.warning||void 0!==t.critical&&n>=t.critical)return!0}return!1}get hasActivePulses(){var t;const e=this.config.pulse;if(!e||0===this.lastIngestTime)return!1;const n="undefined"!=typeof performance?performance.now():Date.now();return(null!==(t=e.duration)&&void 0!==t?t:500)>n-this.lastIngestTime}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}clear(){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.transition=null,this.lastIngestTime=0,this._lastPositionSnapshot=null,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.particlePool&&this.particlePool.clear()}}function no(t){return{id:t,x0:0,x1:0,y0:0,y1:0,x:0,y:0,width:0,height:0,value:0,createdByFrame:!0}}function ro(t,e,n,r,o=30){let i=null,l=o,a=1/0;for(const e of t){const t=oo(e,n,r);if(t)if("rect"===e.type){const n=e.w*e.h;a>n&&(i=t,a=n)}else l>t.distance&&(i=t,l=t.distance)}if(i)return i;for(const t of e){const e=so(t,n,r);e&&l>e.distance&&(i=e,l=e.distance)}return i}function oo(t,e,n){switch(t.type){case"circle":return function(t,e,n){const r=e-t.cx,o=n-t.cy,i=Math.sqrt(r*r+o*o);return i>Math.max(t.r+5,12)?null:{type:"node",datum:t.datum,x:t.cx,y:t.cy,distance:i}}(t,e,n);case"rect":return function(t,e,n){const r=zt(e,n,t);return r.hit?{type:"node",datum:t.datum,x:r.cx,y:r.cy,distance:0}:null}(t,e,n);case"arc":return function(t,e,n){const r=e-t.cx,o=n-t.cy,i=Math.sqrt(r*r+o*o);if(t.innerR-2>i||i>t.outerR+2)return null;const l=Bt(Math.atan2(o,r)),a=Bt(t.startAngle),s=Bt(t.endAngle);if(a>s?l>=a||s>=l:l>=a&&s>=l){const e=(t.startAngle+t.endAngle)/2,n=(t.innerR+t.outerR)/2;return{type:"node",datum:t.datum,x:t.cx+n*Math.cos(e),y:t.cy+n*Math.sin(e),distance:0}}return null}(t,e,n);default:return null}}let io=null,lo=null;function ao(){return lo||(io=document.createElement("canvas"),io.width=1,io.height=1,lo=io.getContext("2d")),lo}function so(t,e,n){switch(t.type){case"bezier":return function(t,e,n){var r,o;if(!t.pathD)return null;try{const i=new Path2D(t.pathD),l=ao();if(!l)return null;if(l.isPointInPath(i,e,n)){const i="object"==typeof(null===(r=t.datum)||void 0===r?void 0:r.source)?t.datum.source:null,l="object"==typeof(null===(o=t.datum)||void 0===o?void 0:o.target)?t.datum.target:null;return{type:"edge",datum:t.datum,x:i&&l?(i.x1+l.x0)/2:e,y:t.datum?(t.datum.y0+t.datum.y1)/2:n,distance:0}}const a=l.lineWidth;l.lineWidth=10;const s=l.isPointInStroke(i,e,n);if(l.lineWidth=a,s)return{type:"edge",datum:t.datum,x:e,y:n,distance:4}}catch(t){}return null}(t,e,n);case"line":return function(t,e,n){const r=t.x2-t.x1,o=t.y2-t.y1,i=r*r+o*o;if(0===i)return null;let l=((e-t.x1)*r+(n-t.y1)*o)/i;l=Math.max(0,Math.min(1,l));const a=t.x1+l*r,s=t.y1+l*o,c=Math.sqrt(Math.pow(e-a,2)+Math.pow(n-s,2));return c>5?null:{type:"edge",datum:t.datum,x:a,y:s,distance:c}}(t,e,n);case"ribbon":case"curved":return function(t,e,n){if(!t.pathD)return null;try{const r=new Path2D(t.pathD),o=ao();if(!o)return null;if(o.isPointInPath(r,e,n))return{type:"edge",datum:t.datum,x:e,y:n,distance:0};const i=o.lineWidth;o.lineWidth=10;const l=o.isPointInStroke(r,e,n);if(o.lineWidth=i,l)return{type:"edge",datum:t.datum,x:e,y:n,distance:4}}catch(t){}return null}(t,e,n);default:return null}}function co(e){const{width:n,height:r,totalWidth:o,totalHeight:i,margin:l,labels:a,title:s,legend:c,legendHoverBehavior:u,legendClickBehavior:h,legendHighlightedCategory:d,legendIsolatedCategories:f,legendPosition:y="right",foregroundGraphics:g,sceneNodes:p,annotations:m,svgAnnotationRules:v}=e;return t.createElement(t.Fragment,null,t.createElement("svg",{role:"img",width:o,height:i,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},t.createElement("title",null,"string"==typeof s?s:"Network Chart"),t.createElement("desc",null,"string"==typeof s?s+" — network data visualization":"Network data visualization"),t.createElement("g",{transform:`translate(${l.left},${l.top})`},a.map((e,n)=>t.createElement("text",{key:"label-"+n,x:e.x,y:e.y,textAnchor:e.anchor||"start",dominantBaseline:e.baseline||"middle",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"currentColor",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,style:{pointerEvents:"none"}},e.text)),m&&m.filter(t=>"widget"!==t.type).map((e,o)=>{if(v){const i=v(e,o,{width:n,height:r,sceneNodes:p});if(i)return t.createElement(t.Fragment,{key:"annotation-"+o},i)}return null}),g),s&&"string"==typeof s?t.createElement("text",{x:o/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor"},s):s?t.createElement("foreignObject",{x:0,y:0,width:o,height:l.top},s):null,ae({legend:c,totalWidth:o,totalHeight:i,margin:l,legendPosition:y,title:s,legendHoverBehavior:u,legendClickBehavior:h,legendHighlightedCategory:d,legendIsolatedCategories:f})),null==m?void 0:m.filter(t=>"widget"===t.type&&t.nodeId&&p).map((e,n)=>{var r,o,i,a,s,c,u,h,d;const f=p.find(t=>{var n,r,o,i,l;return t.id===e.nodeId||(null===(n=t.datum)||void 0===n?void 0:n.id)===e.nodeId||(null===(o=null===(r=t.datum)||void 0===r?void 0:r.data)||void 0===o?void 0:o.id)===e.nodeId||(null===(l=null===(i=t.datum)||void 0===i?void 0:i.data)||void 0===l?void 0:l.name)===e.nodeId});if(!f)return null;const y=l.left+(null!==(r=f.cx)&&void 0!==r?r:null!=f.x&&null!=f.w?f.x+f.w/2:null!==(o=f.x)&&void 0!==o?o:0),g=l.top+(null!==(i=f.cy)&&void 0!==i?i:null!=f.y&&null!=f.h?f.y+f.h/2:null!==(a=f.y)&&void 0!==a?a:0),m=null!==(s=e.dx)&&void 0!==s?s:0,v=null!==(c=e.dy)&&void 0!==c?c:-16,x=null!==(u=e.width)&&void 0!==u?u:32,b=null!==(h=e.height)&&void 0!==h?h:32,k=null!==(d=e.content)&&void 0!==d?d:t.createElement("span",{style:{fontSize:18,cursor:"default"}},"ℹ️");return t.createElement("div",{key:"widget-"+n,style:{position:"absolute",left:y+m-x/2,top:g+v-b/2,width:x,height:b,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:5}},k)}))}function uo(t,e){var n,r,o,i,l,a;if(!e.pathD)return;t.save();const s=new Path2D(e.pathD);if(e.style.fill&&"none"!==e.style.fill){const l=e._gradient;if(l){const o=t.createLinearGradient(l.x0,0,l.x1,0),i=null!==(r=null!==(n=e.style.fillOpacity)&&void 0!==n?n:e.style.opacity)&&void 0!==r?r:.5,a="string"==typeof e.style.fill?e.style.fill:"#999";o.addColorStop(0,1===l.from?a:"transparent"),o.addColorStop(1,1===l.to?a:"transparent"),t.fillStyle=o,t.globalAlpha=i}else t.fillStyle=e.style.fill,t.globalAlpha=null!==(i=null!==(o=e.style.fillOpacity)&&void 0!==o?o:e.style.opacity)&&void 0!==i?i:.5;t.fill(s)}e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=e.style.stroke,t.lineWidth=null!==(l=e.style.strokeWidth)&&void 0!==l?l:.5,t.globalAlpha=.5*(null!==(a=e.style.opacity)&&void 0!==a?a:1),t.stroke(s)),e._pulseIntensity&&e._pulseIntensity>0&&(t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.globalAlpha=.2*e._pulseIntensity,t.fill(s)),t.restore()}function ho(t,e){var n,r;t.save(),t.strokeStyle=e.style.stroke||"#999",t.lineWidth=null!==(n=e.style.strokeWidth)&&void 0!==n?n:1,void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.strokeDasharray&&t.setLineDash(e.style.strokeDasharray.split(/[\s,]+/).map(Number)),t.beginPath(),t.moveTo(e.x1,e.y1),t.lineTo(e.x2,e.y2),t.stroke(),e._pulseIntensity&&e._pulseIntensity>0&&(t.setLineDash([]),t.strokeStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.lineWidth=(null!==(r=e.style.strokeWidth)&&void 0!==r?r:1)+3*e._pulseIntensity,t.globalAlpha=.4*e._pulseIntensity,t.beginPath(),t.moveTo(e.x1,e.y1),t.lineTo(e.x2,e.y2),t.stroke()),t.restore()}function fo(t,e){var n,r,o,i;if(!e.pathD)return;t.save();const l=new Path2D(e.pathD);e.style.fill&&"none"!==e.style.fill&&(t.fillStyle=e.style.fill,t.globalAlpha=null!==(r=null!==(n=e.style.fillOpacity)&&void 0!==n?n:e.style.opacity)&&void 0!==r?r:.5,t.fill(l)),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=e.style.stroke,t.lineWidth=null!==(o=e.style.strokeWidth)&&void 0!==o?o:.5,t.globalAlpha=.3*(null!==(i=e.style.opacity)&&void 0!==i?i:1),t.stroke(l)),e._pulseIntensity&&e._pulseIntensity>0&&(t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.globalAlpha=.25*e._pulseIntensity,t.fill(l)),t.restore()}function yo(t,e){var n,r;if(!e.pathD)return;t.save();const o=new Path2D(e.pathD);t.strokeStyle=e.style.stroke||"#999",t.lineWidth=null!==(n=e.style.strokeWidth)&&void 0!==n?n:1,void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),t.stroke(o),e.style.fill&&"none"!==e.style.fill&&(t.fillStyle=e.style.fill,t.globalAlpha=null!==(r=e.style.fillOpacity)&&void 0!==r?r:.1,t.fill(o)),t.restore()}co.displayName="NetworkSVGOverlay";const go={top:20,right:80,bottom:20,left:80},po={top:40,right:40,bottom:40,left:40},mo=new Set(["chord","force","circlepack","orbit"]),vo=[800,600],xo={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 bo({data:e}){var n,r,o,i,l,a;if("edge"===e.type){const n=e.data;return t.createElement("div",{className:"semiotic-tooltip",style:xo},t.createElement("div",{style:{fontWeight:600}},"object"==typeof n.source?n.source.id:n.source," → ","object"==typeof n.target?n.target.id:n.target),null!=n.value&&t.createElement("div",{style:{marginTop:4,opacity:.8}},"Value:"," ","number"==typeof n.value?n.value.toLocaleString():n.value+""))}const s=e.data,c=null==s?void 0:s.__hierarchyNode;if(c){const e=[];let l=c;for(;l;){const t=null!==(i=null!==(r=null===(n=l.data)||void 0===n?void 0:n.name)&&void 0!==r?r:null===(o=l.data)||void 0===o?void 0:o.id)&&void 0!==i?i:s.id;null!=t&&e.unshift(t+""),l=l.parent}e.length>1&&e.shift();const a=e.length-1;return t.createElement("div",{className:"semiotic-tooltip",style:xo},t.createElement("div",null,e.map((e,n)=>t.createElement("span",{key:n},n>0&&t.createElement("span",{style:{margin:"0 3px",opacity:.5}}," → "),n===a?t.createElement("strong",null,e):t.createElement("span",{style:{opacity:.7}},e)))),null!=s.value&&s.value>0&&t.createElement("div",{style:{marginTop:4,opacity:.8}},"number"==typeof s.value?s.value.toLocaleString():s.value+""))}const u=((null===(l=s.sourceLinks)||void 0===l?void 0:l.length)||0)+((null===(a=s.targetLinks)||void 0===a?void 0:a.length)||0),h=(s.sourceLinks||[]).reduce((t,e)=>t+(e.value||0),0)+(s.targetLinks||[]).reduce((t,e)=>t+(e.value||0),0);return t.createElement("div",{className:"semiotic-tooltip",style:xo},t.createElement("div",{style:{fontWeight:600}},s.id),null!=s.value&&s.value>0&&t.createElement("div",{style:{marginTop:4,opacity:.8}},"Total:"," ","number"==typeof s.value?s.value.toLocaleString():s.value+""),u>0&&t.createElement("div",{style:{marginTop:4,opacity:.8}},"Connections: ",u,h!==u&&` (weighted: ${h.toLocaleString()})`))}const ko=c(function(i,l){var a,c,h,d,f,y,g,p,m,v,x,b,k,w;const{chartType:E,nodes:A,edges:M,data:S,initialEdges:_,nodeIDAccessor:P="id",sourceAccessor:D="source",targetAccessor:T="target",valueAccessor:L="value",childrenAccessor:C,hierarchySum:$,orientation:N="horizontal",nodeAlign:O="justify",nodePaddingRatio:W=.05,nodeWidth:I=15,iterations:z=300,forceStrength:B=.1,padAngle:j=.01,groupWidth:F=20,sortGroups:R,edgeSort:Y,treeOrientation:H="vertical",edgeType:X="curve",padding:G,paddingTop:V,tensionConfig:q,showParticles:U=!1,particleStyle:Z,nodeStyle:Q,edgeStyle:J,colorBy:tt,colorScheme:et="category10",edgeColorBy:nt="source",edgeOpacity:rt=.5,colorByDepth:ot=!1,nodeSize:it=8,nodeSizeRange:lt=[5,20],nodeLabel:at,showLabels:st=!0,labelMode:ct,size:ut=vo,responsiveWidth:ht,responsiveHeight:dt,margin:ft,className:yt,background:gt,enableHover:pt=!0,tooltipContent:mt,customHoverBehavior:vt,customClickBehavior:xt,onObservation:bt,chartId:wt,onTopologyChange:Et,annotations:At,svgAnnotationRules:Mt,legend:St,legendPosition:_t,legendHoverBehavior:Pt,legendClickBehavior:Dt,legendHighlightedCategory:Tt,legendIsolatedCategories:Lt,title:Ct,foregroundGraphics:$t,backgroundGraphics:Nt,decay:Ot,pulse:Wt,staleness:It,thresholds:zt,accessibleTable:Bt=!0,description:jt,summary:Ft,orbitMode:Rt,orbitSize:Yt,orbitSpeed:Ht,orbitRevolution:Xt,orbitRevolutionStyle:Gt,orbitEccentricity:Vt,orbitShowRings:Zt,orbitAnimated:Qt}=i,ee=rn(),ne=e(ee);ne.current=ee;const re="semiotic-table-"+t.useId(),oe=mo.has(E)?po:go,[ie,le]=Jt(ut,ht,dt),ae=Object.assign(Object.assign({},oe),ft),se=le[0]-ae.left-ae.right,ce=le[1]-ae.top-ae.bottom,ue="function"==typeof $t?$t({size:le,margin:ae}):$t,he=n(()=>Object.assign(Object.assign({},zn),q),[q]),de=n(()=>Object.assign(Object.assign({},Bn),Z),[Z]),fe=n(()=>({chartType:E,nodeIDAccessor:P,sourceAccessor:D,targetAccessor:T,valueAccessor:L,childrenAccessor:C,hierarchySum:$,orientation:N,nodeAlign:O,nodePaddingRatio:W,nodeWidth:I,iterations:z,forceStrength:B,padAngle:j,groupWidth:F,sortGroups:R,edgeSort:Y,treeOrientation:H,edgeType:X,padding:G,paddingTop:V,tensionConfig:he,showParticles:U,particleStyle:de,nodeStyle:Q,edgeStyle:J,nodeLabel:at,showLabels:st,labelMode:ct,colorBy:tt,colorScheme:et,edgeColorBy:nt,edgeOpacity:rt,colorByDepth:ot,nodeSize:it,nodeSizeRange:lt,decay:Ot,pulse:Wt,staleness:It,thresholds:zt,orbitMode:Rt,orbitSize:Yt,orbitSpeed:Ht,orbitRevolution:Xt,orbitRevolutionStyle:Gt,orbitEccentricity:Vt,orbitShowRings:Zt,orbitAnimated:Qt}),[E,P,D,T,L,C,$,N,O,W,I,z,B,j,F,R,Y,H,X,G,V,he,U,de,Q,J,at,st,ct,tt,et,nt,rt,ot,it,lt,Ot,Wt,It,zt,Rt,Yt,Ht,Xt,Gt,Vt,Zt,Qt]),ye=e(null),ge=e(0),pe=e(0),me=e(!0),ve=hn(t=>t.theme),xe=e(()=>{}),be=e(null);be.current||(be.current=new eo(fe));const[ke,we]=o(null),[Ee,Ae]=o(0),[Me,Se]=o(0),[_e,Pe]=o(!1),De=e(null),Te=e(new Map),Le=e(0),Ce=s(t=>{if("function"==typeof tt)return tt(t)+"";if("string"==typeof tt&&t.data){const e=t.data[tt];if(void 0!==e){if(!Te.current.has(e+"")){const t=Array.isArray(et)?et:kt;Te.current.set(e+"",t[Le.current++%t.length])}return Te.current.get(e+"")}}if(Te.current.has(t.id))return Te.current.get(t.id);const e=Array.isArray(et)?et:kt,n=tt?e[Le.current++%e.length]:e[0];return Te.current.set(t.id,n),n},[tt,et]),$e=s(t=>{if("function"==typeof nt)return nt(t);const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;return"target"===nt&&n?Ce(n):e?Ce(e):"#999"},[nt,Ce]),We=s(t=>{if(!(null==Z?void 0:Z.colorBy))return $e(t);const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;return"target"===de.colorBy&&n?Ce(n):e?Ce(e):"#999"},[null==Z?void 0:Z.colorBy,de.colorBy,Ce,$e]),Ie="sankey"===E&&U||!!Wt||null!==(c=null===(a=be.current)||void 0===a?void 0:a.isAnimating)&&void 0!==c&&c,ze=s(()=>{ge.current&&!Ie||ge.current||(ge.current=requestAnimationFrame(()=>xe.current()))},[Ie]);r(()=>{var t;null===(t=be.current)||void 0===t||t.updateConfig(fe),me.current=!0,ze()},[fe,ze]),r(()=>{me.current=!0,ze()},[ve,ze]);const Be=s(()=>{var t;const e=be.current;if(!e)return;e.runLayout([se,ce]),e.buildScene([se,ce]),me.current=!0;for(const n of e.sceneNodes)n.id&&"string"==typeof(null===(t=n.style)||void 0===t?void 0:t.fill)&&Te.current.set(n.id,n.style.fill);const n=Array.isArray(et)?et:kt,r=Array.from(e.nodes.values());for(let t=0;r.length>t;t++){const e=r[t];Te.current.has(e.id)||Te.current.set(e.id,n[t%n.length])}if(Le.current=r.length,Ae(e.layoutVersion),Et){const{nodes:t,edges:n}=e.getLayoutData();Et(t,n)}},[se,ce,Et,et]),Fe=s(t=>{const e=be.current;e&&(e.ingestEdge(t)&&Be(),ze())},[Be,ze]),Re=s(t=>{const e=be.current;if(!e)return;let n=!1;for(const r of t)e.ingestEdge(r)&&(n=!0);n&&Be(),ze()},[Be,ze]),Ye=s(()=>{var t;null===(t=be.current)||void 0===t||t.clear(),Te.current.clear(),Le.current=0,Ae(0),we(null),De.current=null,me.current=!0,ze()},[ze]),He=s(()=>{const t=be.current;t&&(t.tension+=999,Be(),ze())},[Be,ze]);u(l,()=>({push:Fe,pushMany:Re,clear:Ye,getTopology:()=>{var t,e;return null!==(e=null===(t=be.current)||void 0===t?void 0:t.getLayoutData())&&void 0!==e?e:{nodes:[],edges:[]}},getTopologyDiff:()=>{const t=be.current;return t?{addedNodes:Array.from(t.addedNodes),removedNodes:Array.from(t.removedNodes),addedEdges:Array.from(t.addedEdges),removedEdges:Array.from(t.removedEdges)}:{addedNodes:[],removedNodes:[],addedEdges:[],removedEdges:[]}},relayout:He,getTension:()=>{var t,e;return null!==(e=null===(t=be.current)||void 0===t?void 0:t.tension)&&void 0!==e?e:0}}),[Fe,Re,Ye,He]);const Xe=["tree","cluster","treemap","circlepack","partition","orbit"].includes(E),Ge=Xe?S||(Array.isArray(M)?void 0:M):void 0;r(()=>{var t;const e=be.current;if(e)if(Xe&&Ge)e.ingestHierarchy(Ge,[se,ce]),e.buildScene([se,ce]),me.current=!0,ze();else{const n=A||[],r=Array.isArray(M)?M:[];if(0===n.length&&0===r.length)return;e.ingestBounded(n,r,[se,ce]),e.buildScene([se,ce]);for(const n of e.sceneNodes)n.id&&(null===(t=n.style)||void 0===t?void 0:t.fill)&&Te.current.set(n.id,n.style.fill+"");const o=Array.isArray(et)?et:kt,i=Array.from(e.nodes.values());for(let t=0;i.length>t;t++){const e=i[t];Te.current.has(e.id)||Te.current.set(e.id,o[t%o.length])}Le.current=i.length,me.current=!0,ze()}},[A,M,S,Ge,Xe,se,ce,fe,ze,et]),r(()=>{_&&_.length>0&&Re(_)},[]);const Ve=s(t=>{if(vt&&vt(t),bt){const e=Date.now();bt(t?{type:"hover",datum:t.data||{},x:t.x,y:t.y,timestamp:e,chartType:"StreamNetworkFrame",chartId:wt}:{type:"hover-end",timestamp:e,chartType:"StreamNetworkFrame",chartId:wt})}},[vt,bt,wt]),qe=s(t=>{if(xt&&xt(t),bt){const e=Date.now();bt(t?{type:"click",datum:t.data||{},x:t.x,y:t.y,timestamp:e,chartType:"StreamNetworkFrame",chartId:wt}:{type:"click-end",timestamp:e,chartType:"StreamNetworkFrame",chartId:wt})}},[xt,bt,wt]),Ue=e(()=>{}),tn=e(()=>{});Ue.current=t=>{if(!pt)return;const e=ye.current;if(!e)return;const n=e.getBoundingClientRect(),r=t.clientX-n.left-ae.left,o=t.clientY-n.top-ae.top;if(0>r||r>se||0>o||o>ce)return void(De.current&&(De.current=null,we(null),Ve&&(Ve(null),me.current=!0),ze()));const i=be.current;if(!i)return;const l=ro(i.sceneNodes,i.sceneEdges,r,o);if(!l)return void(De.current&&(De.current=null,we(null),Ve&&(Ve(null),me.current=!0),ze()));const a=l.datum||{},s=Object.assign(Object.assign({},"object"!=typeof a||null===a||Array.isArray(a)?{}:a),{type:l.type,data:a,x:l.x,y:l.y});De.current=s,we(s),Ve&&(Ve(s),me.current=!0),ze()},tn.current=()=>{De.current&&(De.current=null,we(null),Ve&&(Ve(null),me.current=!0),ze())};const on=e(()=>{});on.current=t=>{if(!xt&&!bt)return;const e=ye.current;if(!e)return;const n=e.getBoundingClientRect(),r=t.clientX-n.left-ae.left,o=t.clientY-n.top-ae.top;if(0>r||r>se||0>o||o>ce)return;const i=be.current;if(!i)return;const l=ro(i.sceneNodes,i.sceneEdges,r,o);if(l){const t=l.datum||{};qe(Object.assign(Object.assign({},"object"!=typeof t||null===t||Array.isArray(t)?{}:t),{type:l.type,data:t,x:l.x,y:l.y}))}else qe(null)},s(t=>Ue.current(t),[]);const ln=s(()=>tn.current(),[]),an=s(t=>on.current(t),[]),sn=e(-1),cn=e(null),un=e(-1),yn=s(t=>{var e;const n=be.current;if(!n)return;const r=function(t){var e,n,r,o,i,l;const a=[];for(const s of t)"circle"===s.type&&null!=s.cx?a.push({x:s.cx,y:s.cy,datum:s.datum,shape:"circle",group:null!==(n=null===(e=s.datum)||void 0===e?void 0:e.id)&&void 0!==n?n:"_default"}):"rect"===s.type&&null!=s.x?a.push({x:s.x+s.w/2,y:s.y+s.h/2,datum:s.datum,shape:"rect",w:s.w,h:s.h,group:null!==(o=null===(r=s.datum)||void 0===r?void 0:r.id)&&void 0!==o?o:"_default"}):"arc"===s.type&&null!=s.cx&&a.push({x:s.cx,y:s.cy,datum:s.datum,shape:"circle",group:null!==(l=null===(i=s.datum)||void 0===i?void 0:i.id)&&void 0!==l?l:"_default"});return a.sort((t,e)=>t.x-e.x||t.y-e.y),a}(n.sceneNodes);if(0===r.length)return;const o=qt(r),i=sn.current;if(0>i){if("Escape"===t.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Enter"].includes(t.key))return;t.preventDefault(),sn.current=0,un.current=-1;const e=o.flat[0];cn.current={shape:e.shape,w:e.w,h:e.h};const n=e.datum||{},r=Object.assign(Object.assign({},"object"!=typeof n||null===n||Array.isArray(n)?{}:n),{type:"node",data:n,x:e.x,y:e.y});return De.current=r,we(r),Ve&&(Ve(r),me.current=!0),void ze()}const l=Ut(o,i),a=function(t,e,n,r,o){var i,l,a;const s=n.flat[e.flatIndex];if(!s)return Kt(t,e,n);const c=null===(i=s.datum)||void 0===i?void 0:i.id;switch(t){case"ArrowRight":case"ArrowLeft":case"ArrowDown":case"ArrowUp":{const r=null!==(l=function(t,e,n){let r=null,o=1/0;for(let i=0;t.flat.length>i;i++){const l=t.flat[i];if(l===e)continue;const a=l.x-e.x,s=l.y-e.y;let c=!1;switch(n){case"right":c=a>0&&Math.abs(a)>=Math.abs(s);break;case"left":c=0>a&&Math.abs(a)>=Math.abs(s);break;case"down":c=s>0&&Math.abs(s)>=Math.abs(a);break;case"up":c=0>s&&Math.abs(s)>=Math.abs(a)}if(!c)continue;const u=a*a+s*s;o>u&&(o=u,r=i)}return r}(n,s,"ArrowRight"===t?"right":"ArrowLeft"===t?"left":"ArrowDown"===t?"down":"up"))&&void 0!==l?l:e.flatIndex;return r!==e.flatIndex&&(o.current=-1),r}case"Enter":{if(null==c)return e.flatIndex;const t=function(t,e){var n,r,o;const i=t+"",l=[];for(const t of e){const e=null!==(n=t.datum)&&void 0!==n?n:t,a="object"==typeof e.source?null===(r=e.source)||void 0===r?void 0:r.id:e.source,s="object"==typeof e.target?null===(o=e.target)||void 0===o?void 0:o.id:e.target,c=null!=a,u=null!=s;c&&a+""===i&&u?l.push(s+""):u&&s+""===i&&c&&l.push(a+"")}return l}(c,r);if(0===t.length)return e.flatIndex;const i=null!==(a=n.idToIdx.get(t[(o.current+1)%t.length]))&&void 0!==a?a:-1;return 0>i?e.flatIndex:(o.current=-1,i)}default:{const r=Kt(t,e,n);return null!==r&&r!==e.flatIndex&&(o.current=-1),r}}}(t.key,l,o,null!==(e=n.sceneEdges)&&void 0!==e?e:[],un);if(null===a)return;if(t.preventDefault(),0>a)return sn.current=-1,cn.current=null,un.current=-1,De.current=null,we(null),Ve&&(Ve(null),me.current=!0),void ze();sn.current=a;const s=o.flat[a];cn.current={shape:s.shape,w:s.w,h:s.h};const c=s.datum||{},u=Object.assign(Object.assign({},"object"!=typeof c||null===c||Array.isArray(c)?{}:c),{type:"node",data:c,x:s.x,y:s.y});De.current=u,we(u),Ve&&(Ve(u),me.current=!0),ze()},[Ve,ze]),gn=s(t=>{sn.current=-1,cn.current=null,Ue.current(t)},[]);xe.current=()=>{var t,e,n,r,o,i,l;ge.current=0;const a=ye.current;if(!a)return;const s=a.getContext("2d");if(!s)return;const c=be.current;if(!c)return;const u=performance.now(),h=pe.current?Math.min((u-pe.current)/1e3,.1):.016;pe.current=u;const d=c.advanceTransition(ne.current?u+1e6:u),f=!ne.current&&d,y=!ne.current&&c.tickAnimation([se,ce],h);(d||me.current||y)&&c.buildScene([se,ce]);const g=fn();if(!dn(a,le,ae,g))return;s.clearRect(-ae.left,-ae.top,le[0],le[1]),gt&&(s.fillStyle=gt,s.fillRect(0,0,se,ce)),Ot&&c.applyDecay(),Wt&&c.applyPulse(u),zt&&c.applyThresholds(u),c.applyTopologyDiff(u);const p=null!==(t=null==It?void 0:It.threshold)&&void 0!==t?t:5e3,m=It&&c.lastIngestTime>0&&u-c.lastIngestTime>p;if(m&&(s.globalAlpha=null!==(e=null==It?void 0:It.dimOpacity)&&void 0!==e?e:.5),function(t,e){for(const n of e)switch(n.type){case"bezier":uo(t,n);break;case"line":ho(t,n);break;case"ribbon":fo(t,n);break;case"curved":yo(t,n)}}(s,c.sceneEdges),function(t,e){var n,r,o;for(const i of e){if("rect"!==i.type)continue;const e=i;e.w>0&&e.h>0&&(t.save(),void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.fill&&(t.fillStyle=e.style.fill,void 0!==e.style.fillOpacity&&(t.globalAlpha=(null!==(n=e.style.opacity)&&void 0!==n?n:1)*e.style.fillOpacity),t.fillRect(e.x,e.y,e.w,e.h)),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=e.style.stroke,t.lineWidth=null!==(r=e.style.strokeWidth)&&void 0!==r?r:1,t.globalAlpha=null!==(o=e.style.opacity)&&void 0!==o?o:1,t.strokeRect(e.x,e.y,e.w,e.h)),vn(t,e),t.restore())}}(s,c.sceneNodes),function(t,e){var n,r,o;for(const i of e){if("circle"!==i.type)continue;const e=i;e.r>0&&(t.save(),void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),t.beginPath(),t.arc(e.cx,e.cy,e.r,0,2*Math.PI),e.style.fill&&(t.fillStyle=e.style.fill,void 0!==e.style.fillOpacity&&(t.globalAlpha=(null!==(n=e.style.opacity)&&void 0!==n?n:1)*e.style.fillOpacity),t.fill()),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=e.style.stroke,t.lineWidth=null!==(r=e.style.strokeWidth)&&void 0!==r?r:1,t.globalAlpha=null!==(o=e.style.opacity)&&void 0!==o?o:1,t.stroke()),xn(t,e),t.restore())}}(s,c.sceneNodes),function(t,e){var n,r,o;for(const i of e){if("arc"!==i.type)continue;const e=i;t.save(),void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),t.beginPath(),t.arc(e.cx,e.cy,e.outerR,e.startAngle,e.endAngle),t.arc(e.cx,e.cy,e.innerR,e.endAngle,e.startAngle,!0),t.closePath(),e.style.fill&&(t.fillStyle=e.style.fill,void 0!==e.style.fillOpacity&&(t.globalAlpha=(null!==(n=e.style.opacity)&&void 0!==n?n:1)*e.style.fillOpacity),t.fill()),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=e.style.stroke,t.lineWidth=null!==(r=e.style.strokeWidth)&&void 0!==r?r:1,t.globalAlpha=null!==(o=e.style.opacity)&&void 0!==o?o:1,t.stroke()),t.restore()}}(s,c.sceneNodes),U&&c.particlePool&&!m){const t=Array.from(c.edges.values());if(t.length>0){!function(t,e,n,r){var o,i;const l=null!==(o=r.spawnRate)&&void 0!==o?o:Bn.spawnRate,a=null!==(i=r.maxPerEdge)&&void 0!==i?i:Bn.maxPerEdge;for(let r=0;e.length>r;r++){const o=e[r];if(!o.bezier)continue;if(t.countForEdge(r)>=a)continue;const i=o.value*l*n*(o.bezier.circular?.3:1),s=Math.floor(i),c=i-s;let u=s;Math.random()<c&&u++;for(let e=0;u>e&&t.countForEdge(r)<a;e++)t.spawn(r)}}(c.particlePool,t,h,de);const e=.5*(null!==(n=de.speedMultiplier)&&void 0!==n?n:1);let r;if(de.proportionalSpeed){const e=t.reduce((t,e)=>Math.max(t,e.value||1),1);r=t.map(t=>.3+(t.value||1)/e*1.7)}c.particlePool.step(h,e,t,r),function(t,e,n,r,o){var i,l;const a=null!==(i=r.radius)&&void 0!==i?i:Bn.radius,s=null!==(l=r.opacity)&&void 0!==l?l:Bn.opacity;t.globalAlpha=s;for(let i=0;e.particles.length>i;i++){const l=e.particles[i];if(!l.active)continue;const s=n[l.edgeIndex];if(s){if("function"==typeof r.color){const e="object"==typeof s.source?s.source:null;t.fillStyle=e?r.color(s,e):"#666"}else t.fillStyle=r.color&&"inherit"!==r.color?r.color:o(s);t.beginPath(),t.arc(l.x,l.y,a,0,2*Math.PI),t.fill()}}t.globalAlpha=1}(s,c.particlePool,t,de,We)}}m&&(s.globalAlpha=1);const v=me.current;if(me.current=!1,v||f||y){const t=ye.current;t&&t.setAttribute("aria-label",je(null!==(o=null===(r=c.sceneNodes)||void 0===r?void 0:r.length)&&void 0!==o?o:0,null!==(l=null===(i=c.sceneEdges)||void 0===i?void 0:i.length)&&void 0!==l?l:0,"Network chart"))}(v||f||y)&&Se(t=>t+1),(Ie||f||y||c.hasActivePulses||c.hasActiveThresholds||c.hasActiveTopologyDiff)&&(ge.current=requestAnimationFrame(()=>xe.current()))},r(()=>(ze(),()=>{ge.current&&(cancelAnimationFrame(ge.current),ge.current=0)}),[ze]),r(()=>{me.current=!0,ze()},[E,se,ce,gt,ze]),te(It,be,me,ze,_e,Pe);const pn=pt&&ke?t.createElement(nn,{x:ke.x,y:ke.y,containerWidth:se,containerHeight:ce,margin:ae,className:"stream-network-tooltip",zIndex:2},mt?mt(ke):t.createElement(bo,{data:ke})):null;if(Oe){const e=be.current;if(e){const t=["tree","cluster","treemap","circlepack","partition","orbit"].includes(E),n=t?S||(Array.isArray(M)?void 0:M):void 0;if(t&&n)e.ingestHierarchy(n,[se,ce]),e.buildScene([se,ce]);else{const t=A||[],n=Array.isArray(M)?M:[];(t.length>0||n.length>0)&&(e.ingestBounded(t,n,[se,ce]),e.buildScene([se,ce]))}}const n=null!==(h=null==e?void 0:e.sceneNodes)&&void 0!==h?h:[],r=null!==(d=null==e?void 0:e.sceneEdges)&&void 0!==d?d:[],o=null!==(f=null==e?void 0:e.labels)&&void 0!==f?f:[];return t.createElement("div",{className:"stream-network-frame"+(yt?" "+yt:""),role:"img","aria-label":jt||("string"==typeof Ct?Ct:"Network chart"),style:{position:"relative",width:le[0],height:le[1]}},t.createElement(Ze,{summary:Ft}),t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:le[0],height:le[1],style:{position:"absolute",left:0,top:0}},Nt&&t.createElement("g",{transform:`translate(${ae.left},${ae.top})`},Nt),t.createElement("g",{transform:`translate(${ae.left},${ae.top})`},gt&&t.createElement("rect",{x:0,y:0,width:se,height:ce,fill:gt}),r.map((e,n)=>function(e,n){switch(e.type){case"line":return t.createElement("line",{key:"net-edge-"+n,x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity});case"bezier":{const r=e;return t.createElement("path",{key:"net-edge-"+n,d:r.pathD,fill:Ne(r.style.fill,"#999"),fillOpacity:r.style.fillOpacity,stroke:r.style.stroke||"none",strokeWidth:r.style.strokeWidth,opacity:r.style.opacity})}case"ribbon":{const r=e;return t.createElement("path",{key:"net-edge-"+n,d:r.pathD,fill:Ne(r.style.fill,"#999"),fillOpacity:r.style.fillOpacity,stroke:r.style.stroke||"none",strokeWidth:r.style.strokeWidth,opacity:r.style.opacity})}case"curved":{const r=e;return t.createElement("path",{key:"net-edge-"+n,d:r.pathD,fill:Ne(r.style.fill,"none"),stroke:r.style.stroke||"#999",strokeWidth:r.style.strokeWidth||1,opacity:r.style.opacity})}default:return null}}(e,n)).filter(Boolean),n.map((e,n)=>function(e,n){switch(e.type){case"circle":{const r=e;return t.createElement("circle",{key:"net-circle-"+n,cx:r.cx,cy:r.cy,r:r.r,fill:Ne(r.style.fill),stroke:r.style.stroke,strokeWidth:r.style.strokeWidth,opacity:r.style.opacity})}case"rect":{const r=e;return t.createElement("rect",{key:"net-rect-"+n,x:r.x,y:r.y,width:r.w,height:r.h,fill:Ne(r.style.fill),stroke:r.style.stroke,strokeWidth:r.style.strokeWidth,opacity:r.style.opacity})}case"arc":{const r=e,o=K().innerRadius(r.innerR).outerRadius(r.outerR).startAngle(r.startAngle).endAngle(r.endAngle)({})||"";return t.createElement("path",{key:"net-arc-"+n,d:o,transform:`translate(${r.cx},${r.cy})`,fill:Ne(r.style.fill),stroke:r.style.stroke,strokeWidth:r.style.strokeWidth,opacity:r.style.opacity})}default:return null}}(e,n)).filter(Boolean),o.map((e,n)=>function(e,n){return t.createElement("text",{key:"net-label-"+n,x:e.x,y:e.y,textAnchor:e.anchor||"middle",dominantBaseline:e.baseline||"auto",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"#333",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder},e.text)}(e,n)).filter(Boolean))),t.createElement(co,{width:se,height:ce,totalWidth:le[0],totalHeight:le[1],margin:ae,labels:o,sceneNodes:n,title:Ct,legend:St,legendPosition:_t,legendHoverBehavior:Pt,legendClickBehavior:Dt,legendHighlightedCategory:Tt,legendIsolatedCategories:Lt,foregroundGraphics:ue,annotations:At,svgAnnotationRules:Mt,annotationFrame:0}))}const mn=be.current;return t.createElement("div",{ref:ie,className:"stream-network-frame"+(yt?" "+yt:""),role:"group","aria-label":jt||("string"==typeof Ct?Ct:"Network chart"),tabIndex:0,style:{position:"relative",width:ht?"100%":le[0],height:dt?"100%":le[1],overflow:"visible"},onKeyDown:yn},Bt&&t.createElement(Qe,{tableId:re}),Bt&&t.createElement(Ke,{nodes:null!==(y=null==mn?void 0:mn.sceneNodes)&&void 0!==y?y:[],edges:null!==(g=null==mn?void 0:mn.sceneEdges)&&void 0!==g?g:[],chartType:"Network chart",tableId:re,chartTitle:"string"==typeof Ct?Ct:void 0}),t.createElement(Ze,{summary:Ft}),t.createElement("div",{role:"img","aria-label":jt||("string"==typeof Ct?Ct:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:pt?gn:void 0,onMouseLeave:pt?ln:void 0,onClick:xt||bt?an:void 0},Nt&&t.createElement("svg",{overflow:"visible",style:{position:"absolute",top:0,left:0,width:le[0],height:le[1],pointerEvents:"none",overflow:"visible"}},t.createElement("g",{transform:`translate(${ae.left},${ae.top})`},Nt)),t.createElement("canvas",{ref:ye,"aria-label":je(null!==(m=null===(p=null==mn?void 0:mn.sceneNodes)||void 0===p?void 0:p.length)&&void 0!==m?m:0,null!==(x=null===(v=null==mn?void 0:mn.sceneEdges)||void 0===v?void 0:v.length)&&void 0!==x?x:0,"Network chart"),style:{position:"absolute",top:0,left:0}}),t.createElement(Je,{hoverPoint:ke}),t.createElement(co,{width:se,height:ce,totalWidth:le[0],totalHeight:le[1],margin:ae,labels:(null==mn?void 0:mn.labels)||[],sceneNodes:null==mn?void 0:mn.sceneNodes,title:Ct,legend:St,legendPosition:_t,legendHoverBehavior:Pt,legendClickBehavior:Dt,legendHighlightedCategory:Tt,legendIsolatedCategories:Lt,foregroundGraphics:ue,annotations:At,svgAnnotationRules:Mt,annotationFrame:Me}),t.createElement(en,{active:sn.current>=0,hoverPoint:ke,margin:ae,size:le,shape:null===(b=cn.current)||void 0===b?void 0:b.shape,width:null===(k=cn.current)||void 0===k?void 0:k.w,height:null===(w=cn.current)||void 0===w?void 0:w.h}),pn,(null==It?void 0:It.showBadge)&&t.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===It.badgePosition?{top:4,left:4}:"bottom-left"===It.badgePosition?{bottom:4,left:4}:"bottom-right"===It.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{background:_e?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"})},_e?"STALE":"LIVE")))});function wo(t){const e=[];for(const[n,r]of Object.entries(t.fields))if("point"===r.type)e.push(t=>r.values.has(t[n]));else{const[t,o]=r.range;e.push(e=>{const r=e[n];return r>=t&&o>=r})}return t=>e.every(e=>e(t))}function Eo(t,e){let n=t.get(e);return n||(n={name:e,resolution:"union",clauses:new Map},t.set(e,n)),n}ko.displayName="StreamNetworkFrame";const[Ao,Mo]=on(t=>({selections:new Map,setClause(e,n){t(t=>{const r=new Map(t.selections),o=Eo(r,e),i=new Map(o.clauses);return i.set(n.clientId,n),r.set(e,Object.assign(Object.assign({},o),{clauses:i})),{selections:r}})},clearClause(e,n){t(t=>{const r=t.selections.get(e);if(!r)return{};const o=new Map(t.selections),i=new Map(r.clauses);return i.delete(n),o.set(e,Object.assign(Object.assign({},r),{clauses:i})),{selections:o}})},setResolution(e,n){t(t=>{const r=new Map(t.selections),o=Eo(r,e);return r.set(e,Object.assign(Object.assign({},o),{resolution:n})),{selections:r}})},clearSelection(e){t(t=>{const n=new Map(t.selections),r=n.get(e);return r&&n.set(e,Object.assign(Object.assign({},r),{clauses:new Map})),{selections:n}})}})),[So,_o]=on(t=>({observations:[],maxObservations:100,version:0,pushObservation(e){t(t=>{const n=t.observations;return n.push(e),n.length>t.maxObservations&&n.shift(),{version:t.version+1}})},clearObservations(){t(()=>({observations:[],version:0}))}}));function Po(t){const e=h(),r=t.clientId||e,{name:o}=t,i=Mo(t=>t.selections.get(o)),l=Mo(t=>t.setClause),a=Mo(t=>t.clearClause),c=n(()=>!!i&&i.clauses.size>0,[i]);return{predicate:n(()=>i&&0!==i.clauses.size?function(t,e){const n=[];for(const[r,o]of t.clauses)"crossfilter"===t.resolution&&r===e||n.push(wo(o));return 0===n.length?()=>!0:"intersect"===t.resolution?t=>n.every(e=>e(t)):t=>n.some(e=>e(t))}(i,r):()=>!0,[i,r]),isActive:c,selectPoints:s(t=>{const e={};for(const[n,r]of Object.entries(t))e[n]={type:"point",values:new Set(r)};l(o,{clientId:r,type:"point",fields:e})},[r,o,l]),selectInterval:s(t=>{const e={};for(const[n,r]of Object.entries(t))e[n]={type:"interval",range:r};l(o,{clientId:r,type:"interval",fields:e})},[r,o,l]),clear:s(()=>{a(o,r)},[a,o,r]),clientId:r}}function Do({selection:t,linkedHover:e,fallbackFields:n=[],unwrapData:o=!1,onObservation:i,chartType:l,chartId:a,onClick:c}){const u=h(),d=function(t,e){return t?!0===t?{name:"hover",fields:e||[]}:"string"==typeof t?{name:t,fields:e||[]}:{name:t.name||"hover",fields:t.fields||e||[],mode:t.mode,xField:t.xField}:null}(e,n),f=Po({name:(null==t?void 0:t.name)||"__unused__"}),y=function(t){const e=t.name||"hover",{fields:n}=t,{predicate:r,isActive:o,selectPoints:i,clear:l}=Po({name:e});return{onHover:s(t=>{if(!t)return void l();const e={};for(const r of n){const n=t[r];void 0!==n&&(e[r]=[n])}Object.keys(e).length>0&&i(e)},[n,i,l,e]),predicate:r,isActive:o}}({name:(null==d?void 0:d.name)||"hover",fields:(null==d?void 0:d.fields)||n||[]}),g=_o(t=>t.pushObservation),p=t?{isActive:f.isActive,predicate:f.predicate}:null,m=s(t=>{var n,r;if(e)if(t){let e=t.data||t.datum||t;if(Array.isArray(e)&&(e=e[0]),"x-position"===(null==d?void 0:d.mode)&&d.xField){const t=null==e?void 0:e[d.xField];null!=t&&Number.isFinite(Number(t))&&function(t,e,n){const r=xe.positions.get(t);r&&r.xValue===e&&r.sourceId===n||(xe={positions:new Map(xe.positions).set(t,{xValue:e,sourceId:n})},ke())}(d.name||"hover",Number(t),u)}"x-position"!==(null==d?void 0:d.mode)&&y.onHover(e)}else"x-position"===(null==d?void 0:d.mode)&&we(d.name||"hover",u),"x-position"!==(null==d?void 0:d.mode)&&y.onHover(null);if(i||g){const e={timestamp:Date.now(),chartType:l||"unknown",chartId:a};if(t){let o=t.data||t.datum||t;Array.isArray(o)&&(o=o[0]);const l=Object.assign(Object.assign({},e),{type:"hover",datum:o||{},x:null!==(n=t.x)&&void 0!==n?n:0,y:null!==(r=t.y)&&void 0!==r?r:0});i&&i(l),g&&g(l)}else{const t=Object.assign(Object.assign({},e),{type:"hover-end"});i&&i(t),g&&g(t)}}},[e,y,d,u,i,l,a,g]),v=s(t=>{var e,n,r,o;if(t&&c){let r=t.data||t.datum||t;Array.isArray(r)&&(r=r[0]),c(r,{x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(n=t.y)&&void 0!==n?n:0})}if(i||g){const e={timestamp:Date.now(),chartType:l||"unknown",chartId:a};if(t){let n=t.data||t.datum||t;Array.isArray(n)&&(n=n[0]);const l=Object.assign(Object.assign({},e),{type:"click",datum:n||{},x:null!==(r=t.x)&&void 0!==r?r:0,y:null!==(o=t.y)&&void 0!==o?o:0});i&&i(l),g&&g(l)}else{const t=Object.assign(Object.assign({},e),{type:"click-end"});i&&i(t),g&&g(t)}}},[c,i,g,l,a]);return r(()=>{if("x-position"!==(null==d?void 0:d.mode))return;const t=d.name||"hover";return()=>{we(t,u)}},[null==d?void 0:d.mode,null==d?void 0:d.name,u]),{activeSelectionHook:p,customHoverBehavior:m,customClickBehavior:v,crosshairSourceId:u}}const To={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 Lo(t,e,n){var r,o,i,l,a,s;const c=To[t||"primary"],u="context"===t||"sparkline"===t;return{width:null!==(r=e.width)&&void 0!==r?r:c.width,height:null!==(o=e.height)&&void 0!==o?o:c.height,showAxes:c.showAxes,showGrid:null!==(i=e.showGrid)&&void 0!==i?i:c.showGrid,enableHover:null!==(l=e.enableHover)&&void 0!==l?l:!!e.linkedHover||c.enableHover,showLegend:null!==(a=e.showLegend)&&void 0!==a?a:c.showLegend,showLabels:null!==(s=e.showLabels)&&void 0!==s?s:c.showLabels,title:u?void 0:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,xLabel:u?void 0:e.xLabel,yLabel:u?void 0:e.yLabel,categoryLabel:u?void 0:e.categoryLabel,valueLabel:u?void 0:e.valueLabel,marginDefaults:Co(c.marginDefaults,e.showCategoryTicks,e.orientation)}}function Co(t,e,n){if(!1!==e)return t;const r=Object.assign({},t);return"horizontal"===n?r.left=Math.min(r.left,15):r.bottom=Math.min(r.bottom,15),r}"undefined"!=typeof process&&process;const $o={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"},No={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function Oo(e,n,r,o){return!1===o||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?t.createElement("div",{style:Object.assign(Object.assign({},$o),{width:n,height:r})},o||"No data available"):null}function Wo(e,n,r){if(!e)return null;const o=Math.min(5,Math.floor(r/40)),i=Math.max(8,Math.floor(r/(3*o))),l=Math.max(6,Math.floor(r/(2.5*o))),a=Math.floor((r-(o*(i+l)-l))/2);return t.createElement("div",{style:{width:n,height:r,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"}},Array.from({length:o},(e,r)=>t.createElement("div",{key:r,className:"semiotic-loading-bar",style:Object.assign(Object.assign({},No),{position:"absolute",top:a+r*(i+l),left:Math.floor(.1*n),width:30+(37*r+13)%50+"%",height:i,opacity:.5+r%2*.2})})))}const Io=c(function(n,r){var o,i,l,a;const c=Lo(n.mode,{width:null!==(i=null===(o=n.size)||void 0===o?void 0:o[0])&&void 0!==i?i:n.width,height:null!==(a=null===(l=n.size)||void 0===l?void 0:l[1])&&void 0!==a?a:n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0}),{size:h,margin:d,className:f,arrowOfTime:y="right",windowMode:g="sliding",windowSize:p=200,data:m,timeAccessor:v,valueAccessor:x,timeExtent:b,valueExtent:k,extentPadding:w,stroke:E="#007bff",strokeWidth:A=2,strokeDasharray:M,background:S,tooltipContent:_,tooltip:P,onHover:D,annotations:T,svgAnnotationRules:L,tickFormatTime:C,tickFormatValue:$,decay:N,pulse:O,staleness:W,transition:I,linkedHover:z,selection:B,onObservation:j,chartId:F,loading:R,emptyContent:Y,emphasis:H,legendPosition:X}=n,G=c.showAxes,V=c.enableHover,q=null!=d?d:c.marginDefaults,U=null!=h?h:[c.width,c.height],K=null!=_?_:P,Z=e(null),{customHoverBehavior:Q}=Do({selection:B,linkedHover:z,unwrapData:!0,onObservation:j,chartType:"RealtimeLineChart",chartId:F}),J=s(t=>{D&&D(t),Q(t)},[D,Q]);u(r,()=>({push:t=>{var e;return null===(e=Z.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=Z.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=Z.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=Z.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const tt=Wo(R,U[0],U[1]),et=tt?null:Oo(m,U[0],U[1],Y),nt={stroke:E,strokeWidth:A,strokeDasharray:M};return tt||et||t.createElement(In,{ref:Z,chartType:"line",runtimeMode:"streaming",size:U,margin:q,className:H?`${f||""} semiotic-emphasis-${H}`.trim():f,arrowOfTime:y,windowMode:g,windowSize:p,data:m,timeAccessor:v,valueAccessor:x,xExtent:b,yExtent:k,extentPadding:w,lineStyle:nt,showAxes:G,background:S,hoverAnnotation:V,tooltipContent:K,customHoverBehavior:J,annotations:T,svgAnnotationRules:L,tickFormatTime:C,tickFormatValue:$,decay:N,pulse:O,staleness:W,transition:I,legendPosition:X})});Io.displayName="RealtimeLineChart";const zo=c(function(r,o){var i,l,a,c;const h=Lo(r.mode,{width:null!==(l=null===(i=r.size)||void 0===i?void 0:i[0])&&void 0!==l?l:r.width,height:null!==(c=null===(a=r.size)||void 0===a?void 0:a[1])&&void 0!==c?c:r.height,enableHover:null!=r.enableHover?!!r.enableHover:void 0}),{binSize:d,size:f,margin:y,className:g,arrowOfTime:p="right",windowMode:m="sliding",windowSize:v=200,data:x,timeAccessor:b,valueAccessor:k,timeExtent:w,valueExtent:E,extentPadding:A,categoryAccessor:M,colors:S,fill:_,stroke:P,strokeWidth:D,gap:T,background:L,tooltipContent:C,tooltip:$,onHover:N,annotations:O,svgAnnotationRules:W,tickFormatTime:I,tickFormatValue:z,linkedHover:B,selection:j,decay:F,pulse:R,staleness:Y,transition:H,onObservation:X,chartId:G,loading:V,emptyContent:q,emphasis:U,legendPosition:K,brush:Z,onBrush:Q,linkedBrush:J}=r,tt=h.showAxes,et=h.enableHover,nt=null!=y?y:h.marginDefaults,rt=null!=f?f:[h.width,h.height],ot=null!=C?C:$,it=e(null),{customHoverBehavior:lt}=Do({selection:j,linkedHover:B,unwrapData:!0,onObservation:X,chartType:"RealtimeTemporalHistogram",chartId:G}),at=s(t=>{N&&N(t),lt(t)},[N,lt]),st=!0===Z?{dimension:"x",snap:"bin"}:"x"===Z?{dimension:"x"}:"object"==typeof Z?Z:void 0,ct=(ut=J)?"string"==typeof ut?{name:ut}:ut:null;var ut;const ht=function(t){const{name:e,xField:r,yField:o}=t,{predicate:i,isActive:l,selectInterval:a,clear:c}=Po({name:e}),u=r&&o?"xyBrush":r?"xBrush":"yBrush",h=s(t=>{if(!t)return void c();const e={};"xyBrush"===u&&Array.isArray(t)&&2===t.length?(r&&(e[r]=[Math.min(t[0][0],t[1][0]),Math.max(t[0][0],t[1][0])]),o&&(e[o]=[Math.min(t[0][1],t[1][1]),Math.max(t[0][1],t[1][1])])):"xBrush"===u&&Array.isArray(t)?r&&(e[r]=[Math.min(...t),Math.max(...t)]):"yBrush"===u&&Array.isArray(t)&&o&&(e[o]=[Math.min(...t),Math.max(...t)]),Object.keys(e).length>0&&a(e)},[u,r,o,a,c]);return{brushInteraction:n(()=>({brush:u,during:h,end:h}),[u,h]),predicate:i,isActive:l,clear:c}}(Object.assign({name:(null==ct?void 0:ct.name)||"__unused_hist_brush__",xField:(null==ct?void 0:ct.xField)||("string"==typeof b?b:"time")},(null==ct?void 0:ct.yField)?{yField:ct.yField}:{})),dt=e(ht.brushInteraction);dt.current=ht.brushInteraction;const ft=s(t=>{if(Q&&Q(t),X&&X(t?{type:"brush",extent:t,timestamp:Date.now(),chartType:"RealtimeTemporalHistogram",chartId:G}:{type:"brush-end",timestamp:Date.now(),chartType:"RealtimeTemporalHistogram",chartId:G}),ct){const e=dt.current;e.end(t?"xBrush"===e.brush?t.x:"yBrush"===e.brush?t.y:[[t.x[0],t.y[0]],[t.x[1],t.y[1]]]:null)}},[Q,X,G,ct]);u(o,()=>({push:t=>{var e;return null===(e=it.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=it.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=it.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=it.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const yt=Wo(V,rt[0],rt[1]),gt=yt?null:Oo(x,rt[0],rt[1],q),pt={};return null!=_&&(pt.fill=_),null!=P&&(pt.stroke=P),null!=D&&(pt.strokeWidth=D),null!=T&&(pt.gap=T),yt||gt||t.createElement(In,{ref:it,chartType:"bar",runtimeMode:"streaming",size:rt,margin:nt,className:U?`${g||""} semiotic-emphasis-${U}`.trim():g,arrowOfTime:p,windowMode:m,windowSize:v,data:x,timeAccessor:b,valueAccessor:k,xExtent:w,yExtent:E,extentPadding:A,binSize:d,categoryAccessor:M,barColors:S,barStyle:pt,showAxes:tt,background:L,hoverAnnotation:et,tooltipContent:ot,customHoverBehavior:at,annotations:O,svgAnnotationRules:W,tickFormatTime:I,tickFormatValue:z,decay:F,pulse:R,staleness:Y,transition:H,legendPosition:K,brush:st||(J?{dimension:"x"}:void 0),onBrush:st||J?ft:void 0})});zo.displayName="RealtimeTemporalHistogram";const Bo=zo,jo=c(function(n,r){var o,i,l,a;const c=Lo(n.mode,{width:null!==(i=null===(o=n.size)||void 0===o?void 0:o[0])&&void 0!==i?i:n.width,height:null!==(a=null===(l=n.size)||void 0===l?void 0:l[1])&&void 0!==a?a:n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0}),{size:h,margin:d,className:f,arrowOfTime:y="right",windowMode:g="sliding",windowSize:p=200,data:m,timeAccessor:v,valueAccessor:x,timeExtent:b,valueExtent:k,extentPadding:w,categoryAccessor:E,colors:A,radius:M,fill:S,opacity:_,stroke:P,strokeWidth:D,background:T,tooltipContent:L,tooltip:C,onHover:$,annotations:N,svgAnnotationRules:O,tickFormatTime:W,tickFormatValue:I,linkedHover:z,selection:B,onObservation:j,chartId:F,loading:R,emptyContent:Y,emphasis:H,legendPosition:X}=n,G=c.showAxes,V=c.enableHover,q=null!=d?d:c.marginDefaults,U=null!=h?h:[c.width,c.height],K=null!=L?L:C,Z=e(null),{customHoverBehavior:Q}=Do({selection:B,linkedHover:z,unwrapData:!0,onObservation:j,chartType:"RealtimeSwarmChart",chartId:F}),J=s(t=>{$&&$(t),Q(t)},[$,Q]);u(r,()=>({push:t=>{var e;return null===(e=Z.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=Z.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=Z.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=Z.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const tt=Wo(R,U[0],U[1]),et=tt?null:Oo(m,U[0],U[1],Y),nt={};return null!=M&&(nt.radius=M),null!=S&&(nt.fill=S),null!=_&&(nt.opacity=_),null!=P&&(nt.stroke=P),null!=D&&(nt.strokeWidth=D),tt||et||t.createElement(In,{ref:Z,chartType:"swarm",runtimeMode:"streaming",size:U,margin:q,className:H?`${f||""} semiotic-emphasis-${H}`.trim():f,arrowOfTime:y,windowMode:g,windowSize:p,data:m,timeAccessor:v,valueAccessor:x,xExtent:b,yExtent:k,extentPadding:w,categoryAccessor:E,barColors:A,swarmStyle:nt,showAxes:G,background:T,hoverAnnotation:V,tooltipContent:K,customHoverBehavior:J,annotations:N,svgAnnotationRules:O,tickFormatTime:W,tickFormatValue:I,legendPosition:X})});jo.displayName="RealtimeSwarmChart";const Fo=c(function(n,r){var o,i,l,a;const c=Lo(n.mode,{width:null!==(i=null===(o=n.size)||void 0===o?void 0:o[0])&&void 0!==i?i:n.width,height:null!==(a=null===(l=n.size)||void 0===l?void 0:l[1])&&void 0!==a?a:n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0}),{size:h,margin:d,className:f,arrowOfTime:y="right",windowMode:g="sliding",windowSize:p=200,data:m,timeAccessor:v,valueAccessor:x,timeExtent:b,valueExtent:k,extentPadding:w,positiveColor:E,negativeColor:A,connectorStroke:M,connectorWidth:S,gap:_,stroke:P,strokeWidth:D,background:T,tooltipContent:L,tooltip:C,onHover:$,annotations:N,svgAnnotationRules:O,tickFormatTime:W,tickFormatValue:I,linkedHover:z,selection:B,onObservation:j,chartId:F,loading:R,emptyContent:Y,emphasis:H,legendPosition:X}=n,G=c.showAxes,V=c.enableHover,q=null!=d?d:c.marginDefaults,U=null!=h?h:[c.width,c.height],K=null!=L?L:C,Z=e(null),{customHoverBehavior:Q}=Do({selection:B,linkedHover:z,unwrapData:!0,onObservation:j,chartType:"RealtimeWaterfallChart",chartId:F}),J=s(t=>{$&&$(t),Q(t)},[$,Q]);u(r,()=>({push:t=>{var e;return null===(e=Z.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=Z.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=Z.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=Z.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const tt=Wo(R,U[0],U[1]),et=tt?null:Oo(m,U[0],U[1],Y),nt={};return null!=E&&(nt.positiveColor=E),null!=A&&(nt.negativeColor=A),null!=M&&(nt.connectorStroke=M),null!=S&&(nt.connectorWidth=S),null!=_&&(nt.gap=_),null!=P&&(nt.stroke=P),null!=D&&(nt.strokeWidth=D),tt||et||t.createElement(In,{ref:Z,chartType:"waterfall",runtimeMode:"streaming",size:U,margin:q,className:H?`${f||""} semiotic-emphasis-${H}`.trim():f,arrowOfTime:y,windowMode:g,windowSize:p,data:m,timeAccessor:v,valueAccessor:x,xExtent:b,yExtent:k,extentPadding:w,waterfallStyle:nt,showAxes:G,background:T,hoverAnnotation:V,tooltipContent:K,customHoverBehavior:J,annotations:N,svgAnnotationRules:O,tickFormatTime:W,tickFormatValue:I,legendPosition:X})});Fo.displayName="RealtimeWaterfallChart";const Ro=c(function(n,r){var o,i,l,a;const c=Lo(n.mode,{width:null!==(i=null===(o=n.size)||void 0===o?void 0:o[0])&&void 0!==i?i:n.width,height:null!==(a=null===(l=n.size)||void 0===l?void 0:l[1])&&void 0!==a?a:n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0}),{size:h,margin:d,className:f,arrowOfTime:y="right",windowMode:g="sliding",windowSize:p=200,data:m,timeAccessor:v,valueAccessor:x,categoryAccessor:b,timeExtent:k,valueExtent:w,extentPadding:E,heatmapXBins:A=20,heatmapYBins:M=20,aggregation:S="count",background:_,tooltipContent:P,tooltip:D,onHover:T,annotations:L,svgAnnotationRules:C,tickFormatTime:$,tickFormatValue:N,decay:O,pulse:W,staleness:I,linkedHover:z,selection:B,onObservation:j,chartId:F,loading:R,emptyContent:Y,emphasis:H,legendPosition:X}=n,G=c.showAxes,V=c.enableHover,q=null!=d?d:c.marginDefaults,U=null!=h?h:[c.width,c.height],K=null!=P?P:D,Z=e(null),{customHoverBehavior:Q}=Do({selection:B,linkedHover:z,unwrapData:!0,onObservation:j,chartType:"RealtimeHeatmap",chartId:F}),J=s(t=>{T&&T(t),Q(t)},[T,Q]);u(r,()=>({push:t=>{var e;return null===(e=Z.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=Z.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=Z.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=Z.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const tt=Wo(R,U[0],U[1]),et=tt?null:Oo(m,U[0],U[1],Y);return tt||et||t.createElement(In,{ref:Z,chartType:"heatmap",runtimeMode:"streaming",size:U,margin:q,className:H?`${f||""} semiotic-emphasis-${H}`.trim():f,arrowOfTime:y,windowMode:g,windowSize:p,data:m,timeAccessor:v,valueAccessor:x,categoryAccessor:b,xExtent:k,yExtent:w,extentPadding:E,heatmapXBins:A,heatmapYBins:M,heatmapAggregation:S,showAxes:G,background:_,hoverAnnotation:V,tooltipContent:K,customHoverBehavior:J,annotations:L,svgAnnotationRules:C,tickFormatTime:$,tickFormatValue:N,decay:O,pulse:W,staleness:I,legendPosition:X})});Ro.displayName="RealtimeHeatmap";export{gt as IncrementalExtent,Ro as RealtimeHeatmap,Bo as RealtimeHistogram,Io as RealtimeLineChart,jo as RealtimeSwarmChart,Fo as RealtimeWaterfallChart,yt as RingBuffer,ko as StreamNetworkFrame,In as StreamXYFrame};
1
+ import*as t from"react";import{useRef as e,useMemo as n,useEffect as r,useState as o,useSyncExternalStore as i,createContext as l,useContext as a,useCallback as s,forwardRef as c,useImperativeHandle as u,useId as d}from"react";import{select as h}from"d3-selection";import{brushX as f,brushY as y,brush as g}from"d3-brush";import{scaleLinear as p,scaleLog as v,scaleTime as m}from"d3-scale";import{quadtree as x}from"d3-quadtree";import{schemeCategory10 as b,interpolateViridis as k,interpolateGreens as w,interpolateReds as E,interpolateBlues as A}from"d3-scale-chromatic";import{bin as M,min as S,groups as P,max as _,sum as D,mean as T,group as L}from"d3-array";import{packEnclose as C,hierarchy as N,partition as $,pack as O,treemap as I,treemapBinary as W,cluster as z,tree as B}from"d3-hierarchy";import{area as j,curveCatmullRom as F,curveCardinal as R,curveBasis as Y,curveStepBefore as H,curveStepAfter as X,curveStep as G,curveMonotoneY as V,curveMonotoneX as q,curveLinear as U,arc as K,line as Z,curveNatural as Q,pie as J}from"d3-shape";import tt from"regression";import{interpolateNumber as et}from"d3-interpolate";import{forceLink as nt,forceSimulation as rt,forceManyBody as ot,forceCenter as it,forceX as lt,forceY as at}from"d3-force";import{ribbon as st,chord as ct}from"d3-chord";function ut(t,e){let n=0,r=e.length-1;for(;r>n;){const o=n+r+1>>1;e[o]>t?r=o-1:n=o}return e[n]}function dt(t,e){let n=0,r=e.length-1;for(;r>n;){const o=n+r>>1;t>e[o]?n=o+1:r=o}return e[n]}function ht({width:o,height:i,totalWidth:l,totalHeight:a,margin:s,dimension:c,scales:u,onBrush:d,binSize:p,snap:v,binBoundaries:m,snapDuring:x,streaming:b}){const k=e(null),w=e(null),E=e(d);E.current=d;const A=e(u);A.current=u;const M=n(()=>m?[...m].sort((t,e)=>t-e):void 0,[m]),S=e(M);S.current=M;const P=e(!1),_=e(null);return r(()=>{if(!k.current)return;const t=h(k.current).select(".brush-g"),e="x"===c?f():"y"===c?y():g();return e.extent([[0,0],[o,i]]),e.on("brush end",n=>{if(P.current)return;const r=A.current;if(!r)return;if(!n.selection)return _.current=null,void E.current(null);let l,a;if("x"===c){const[t,e]=n.selection;l=[r.x.invert(t),r.x.invert(e)],a=[r.y.invert(i),r.y.invert(0)]}else if("y"===c){const[t,e]=n.selection;l=[r.x.invert(0),r.x.invert(o)],a=[r.y.invert(e),r.y.invert(t)]}else{const[[t,e],[o,i]]=n.selection;l=[r.x.invert(t),r.x.invert(o)],a=[r.y.invert(i),r.y.invert(e)]}if("bin"===v&&"y"!==c&&("end"===n.type||"brush"===n.type&&x)){const o=S.current;o&&o.length>0?l=function(t,e){return 0===e.length?t:[ut(t[0],e),dt(t[1],e)]}(l,o):p&&p>0&&(l=[Math.floor(l[0]/p)*p,Math.ceil(l[1]/p)*p]);const i=r.x(l[0]),a=r.x(l[1]);if(P.current=!0,"x"===c)t.call(e.move,[i,a]);else if("xy"===c){const r=n.selection;t.call(e.move,[[i,r[0][1]],[a,r[1][1]]])}P.current=!1}const s={x:l,y:a};_.current=s,E.current(s)}),t.call(e),w.current=e,t.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{e.on("brush end",null),w.current=null}},[o,i,c,v,p,x]),r(()=>{if(!(b&&u&&w.current&&_.current))return;if(!k.current)return;if("y"===c)return;const t=_.current,e=u.x.domain()[0],n=h(k.current).select(".brush-g");if(e>=t.x[1])return P.current=!0,n.call(w.current.move,null),P.current=!1,_.current=null,void E.current(null);let r=t.x[0],o=!1;if(e>t.x[0]){if(r=e,"bin"===v){const t=S.current;t&&t.length>0?r=dt(e,t):p&&p>0&&(r=Math.ceil(e/p)*p)}if(r>=t.x[1])return P.current=!0,n.call(w.current.move,null),P.current=!1,_.current=null,void E.current(null);o=!0}const i=u.x(r),l=u.x(t.x[1]);if(P.current=!0,"x"===c)n.call(w.current.move,[i,l]);else{const e=u.y(t.y[1]),r=u.y(t.y[0]);n.call(w.current.move,[[i,e],[l,r]])}if(P.current=!1,o){const e={x:[r,t.x[1]],y:t.y};_.current=e,E.current(e)}},[u,b,c,v,p]),t.createElement("svg",{ref:k,width:l,height:a,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},t.createElement("g",{className:"brush-g",transform:`translate(${s.left},${s.top})`}))}class ft{constructor(t,e){var n,r;this.lastBoundedData=null,this.chunkTimer=0,this.pushBuffer=[],this.flushScheduled=!1,this.callback=t,this.chunkThreshold=null!==(n=null==e?void 0:e.chunkThreshold)&&void 0!==n?n:5e3,this.chunkSize=null!==(r=null==e?void 0:e.chunkSize)&&void 0!==r?r:5e3}updateChunkOptions(t){null!=t.chunkThreshold&&(this.chunkThreshold=t.chunkThreshold),null!=t.chunkSize&&(this.chunkSize=t.chunkSize)}clearLastData(){this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(t){if(this.lastBoundedData=t,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.chunkThreshold>=t.length)return void this.callback({inserts:t,bounded:!0});this.callback({inserts:t.slice(0,this.chunkSize),bounded:!0,totalSize:t.length});let e=this.chunkSize;const n=()=>{if(e>=t.length)return;if(t!==this.lastBoundedData)return;const r=Math.min(e+this.chunkSize,t.length);this.callback({inserts:t.slice(e,r),bounded:!1}),e=r,this.chunkTimer=t.length>e?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}flushPushBuffer(){if(this.flushScheduled=!1,0===this.pushBuffer.length)return;const t=this.pushBuffer;this.pushBuffer=[],this.callback({inserts:t,bounded:!1})}scheduleFlush(){this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flushPushBuffer()))}push(t){this.pushBuffer.push(t),this.scheduleFlush()}pushMany(t){if(0!==t.length){for(let e=0;t.length>e;e++)this.pushBuffer.push(t[e]);this.scheduleFlush()}}flush(){this.flushPushBuffer()}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1}}class yt{constructor(t){if(this._capacity=t,this.head=0,this._size=0,1>t)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(t)}push(t){let e;return this._size===this._capacity?e=this.buffer[this.head]:this._size++,this.buffer[this.head]=t,this.head=(this.head+1)%this._capacity,e}pushMany(t){const e=[];for(const n of t){const t=this.push(n);void 0!==t&&e.push(t)}return e}get(t){if(t>=0&&this._size>t)return this.buffer[(this.head-this._size+t+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let t=0;const e=this;return{next:()=>e._size>t?{done:!1,value:e.get(t++)}:{done:!0,value:void 0}}}forEach(t){const e=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)t(this.buffer[(e+n)%this._capacity],n)}toArray(){const t=Array(this._size),e=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)t[n]=this.buffer[(e+n)%this._capacity];return t}resize(t){if(1>t)throw Error("RingBuffer capacity must be at least 1");const e=this.toArray(),n=[];for(;e.length>t;)n.push(e.shift());this._capacity=t,this.buffer=Array(t),this.head=0,this._size=0;for(const t of e)this.push(t);return n}update(t,e){const n=[],r=(this.head-this._size+this._capacity)%this._capacity;for(let o=0;this._size>o;o++){const i=(r+o)%this._capacity,l=this.buffer[i];if(t(l)){let t;t="object"!=typeof l||null===l?l:Array.isArray(l)?[...l]:Object.assign({},l),n.push(t),this.buffer[i]=e(l)}}return n}remove(t){const e=[],n=[];if(this.forEach(r=>{t(r)?n.push(r):e.push(r)}),0===n.length)return n;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const t of e)this.push(t);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 gt{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(t){Number.isNaN(t)||(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}evict(t){t!==this._min&&t!==this._max||(this._dirty=!0)}recalculate(t,e){this._min=1/0,this._max=-1/0;for(const n of t){const t=e?e(n):n;Number.isNaN(t)||(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}this._dirty=!1}clear(){this._min=1/0,this._max=-1/0,this._dirty=!1}get extent(){return[this._min,this._max]}get min(){return this._min}get max(){return this._max}get dirty(){return this._dirty}}function pt(t,e,n,r,o){const i=new Map;for(const l of t){const t=e(l),a=n(l);if(null==t||null==a||Number.isNaN(t)||Number.isNaN(a))continue;const s=Math.floor(t/r)*r;let c=i.get(s);if(c||(c={start:s,end:s+r,total:0,categories:new Map},i.set(s,c)),c.total+=a,o){const t=o(l);c.categories.set(t,(c.categories.get(t)||0)+a)}}return i}function vt(t,e){return t===e||typeof t==typeof e&&"function"==typeof t&&"function"==typeof e&&""+t==""+e}function mt(t,e){if("function"==typeof t)return e=>+t(e);const n=t||e;return t=>+t[n]}function xt(t,e){if("function"==typeof t)return t;const n=t||e;return t=>t[n]}function bt(t,e){return"function"==typeof t?t:t?e=>e[t]+"":void 0}const kt=b,wt=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];function Et(t,e,n){var r,o,i;if(1>=n)return 1;const l=null!==(r=t.minOpacity)&&void 0!==r?r:.1,a=n-1-e;switch(t.type){case"linear":return l+(1-a/(n-1))*(1-l);case"exponential":{const e=null!==(o=t.halfLife)&&void 0!==o?o:n/2;return l+Math.pow(.5,a/e)*(1-l)}case"step":return(null!==(i=t.stepThreshold)&&void 0!==i?i:.5*n)>a?1:l;default:return 1}}function At(t,e,n){var r;const o=null!==(r=t.duration)&&void 0!==r?r:500,i=n-e;return o>i?1-i/o:0}function Mt(t,e="ease-out-cubic"){return"linear"===e?t:1-Math.pow(1-t,3)}function St(t,e){return Math.min((t-e.startTime)/e.duration,1)}function Pt(t,e,n){return t+(e-t)*n}function _t(t,e,n){var r,o,i,l;switch(e.type){case"point":if(e.pointId)return"p:"+e.pointId;if("streaming"===t.runtimeMode&&e.datum){const n=t.getX(e.datum),r=t.getY(e.datum);if(t.getCategory)return`p:${t.getCategory(e.datum)}:${n}:${r}`;if(null!=n&&null!=r)return`p:${n}:${r}`}return"p:"+n;case"rect":return`r:${e.group||""}:${null!==(l=null!==(o=null===(r=e.datum)||void 0===r?void 0:r.binStart)&&void 0!==o?o:null===(i=e.datum)||void 0===i?void 0:i.category)&&void 0!==l?l:n}`;case"heatcell":return`h:${e.x}_${e.y}`;case"candlestick":return null==e.datum?"c:"+n:"c:"+t.getX(e.datum);case"line":return"l:"+(e.group||"_default");case"area":return"a:"+(e.group||"_default");default:return null}}function Dt(t,e,n,r,o,i){const l=[];for(const o of t){const t=n(o),i=r(o);null==t||null==i||Number.isNaN(t)||Number.isNaN(i)||l.push({px:e.x(t),py:e.y(i),rawY:i,d:o})}l.sort((t,e)=>t.px-e.px);const a=Array(l.length),s=Array(l.length),c=Array(l.length);for(let t=0;l.length>t;t++){const e=l[t];a[t]=[e.px,e.py],s[t]=e.rawY,c[t]=e.d}return{type:"line",path:a,rawValues:s,style:o,datum:c,group:i}}function Tt(t,e,n,r,o,i,l,a){const s=[];for(const i of t){const t=n(i),l=r(i);if(null==t||null==l||Number.isNaN(t)||Number.isNaN(l))continue;const c=e.x(t),u=a?a(i):o;s.push({px:c,topY:e.y(l),botY:e.y(u)})}s.sort((t,e)=>t.px-e.px);const c=Array(s.length),u=Array(s.length);for(let t=0;s.length>t;t++){const e=s[t];c[t]=[e.px,e.topY],u[t]=[e.px,e.botY]}return{type:"area",topPath:c,bottomPath:u,style:i,datum:t,group:l}}function Lt(t,e,n,r,o,i,l){const a=n(t),s=r(t);if(null==a||null==s||Number.isNaN(a)||Number.isNaN(s))return null;const c={type:"point",x:e.x(a),y:e.y(s),r:o,style:i,datum:t};return void 0!==l&&(c.pointId=l),c}function Ct(t,e,n,r,o,i,l){return{type:"rect",x:t,y:e,w:n,h:r,style:o,datum:i,group:l}}function Nt(t,e,n,r,o,i,l){const a={type:"heatcell",x:t,y:e,w:n,h:r,fill:o,datum:i};return(null==l?void 0:l.showValues)&&(a.showValues=!0,a.value=l.value,l.valueFormat&&(a.valueFormat=l.valueFormat)),a}function $t(t,e,n){if(!t.getBounds||!t.scales)return null;const r=[],o=[];for(const n of e){const e=t.getX(n),i=t.getY(n);if(null==e||null==i||Number.isNaN(e)||Number.isNaN(i))continue;const l=t.getBounds(n),a=t.scales.x(e);if(l&&0!==l)r.push([a,t.scales.y(i+l)]),o.push([a,t.scales.y(i-l)]);else{const e=t.scales.y(i);r.push([a,e]),o.push([a,e])}}return 2>r.length?null:{type:"area",topPath:r,bottomPath:o,style:t.resolveBoundsStyle(n,e[0]),datum:e,group:n,interactive:!1}}function Ot(t,e,n,r){var o;if(!t.config.pointStyle)return;const i=null!=r?r:t.getY;for(const r of e){const e=t.resolveGroupColor(r.key);for(const l of r.data){let r=t.config.pointStyle(l);!r.fill&&e&&(r=Object.assign(Object.assign({},r),{fill:e}));const a=null!==(o=r.r)&&void 0!==o?o:3,s=t.getPointId?t.getPointId(l)+"":void 0,c=Lt(l,t.scales,t.getX,i,a,r,s);c&&n.push(c)}}}const It={blues:A,reds:E,greens:w,viridis:k},Wt=new Map;class zt{constructor(t){if(this.xExtent=new gt,this.yExtent=new gt,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.prevPathMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupColorMap=new Map,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this._ingestVersion=0,this._bufferArrayCache=null,this._bufferDirty=!0,this.needsFullRebuild=!0,this.lastLayout=null,this.scales=null,this.scene=[],this.version=0,this.xIsDate=!1,this._quadtree=null,this.config=t,this.buffer=new yt(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=mt(t.timeAccessor||t.xAccessor,"time"),this.getY=mt(t.valueAccessor||t.yAccessor,"value")):(this.getX=mt(t.xAccessor,"x"),this.getY=mt(t.yAccessor,"y")),this.getGroup=bt(t.groupAccessor),this.getCategory=bt(t.categoryAccessor),this.getSize=t.sizeAccessor?mt(t.sizeAccessor,"size"):void 0,this.getColor=bt(t.colorAccessor),this.getBounds=t.boundsAccessor?mt(t.boundsAccessor,"bounds"):void 0,this.getY0=t.y0Accessor?mt(t.y0Accessor,"y0"):void 0,this.getPointId=bt(t.pointIdAccessor),"candlestick"===t.chartType){const e=null!=t.openAccessor,n=null!=t.closeAccessor;this.getOpen=e?mt(t.openAccessor,"open"):void 0,this.getHigh=mt(t.highAccessor,"high"),this.getLow=mt(t.lowAccessor,"low"),this.getClose=n?mt(t.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!n}t.pulse&&(this.timestampBuffer=new yt(t.windowSize))}ingest(t){const e="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=e,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,t.bounded){if(this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.getX=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?mt(this.config.timeAccessor||this.config.xAccessor,"time"):mt(this.config.xAccessor,"x"),this.xIsDate=!1,t.inserts.length>0){const e=t.inserts[0],n=this.config.xAccessor,r="function"==typeof n?n(e):e[n||"x"],o=r instanceof Date,i="string"==typeof r&&r.length>=10&&!isNaN(new Date(r).getTime())&&isNaN(Number(r));if(this.xIsDate=o||i,i){const t="string"==typeof n?n:void 0;this.getX=t?e=>+new Date(e[t]):t=>+(n(t)instanceof Date?n(t):new Date(n(t)))}}const n=t.totalSize||t.inserts.length;n>this.buffer.capacity&&(this.buffer.resize(n),this.timestampBuffer&&n>this.timestampBuffer.capacity&&this.timestampBuffer.resize(n));for(const n of t.inserts)this.buffer.push(n),this.timestampBuffer&&this.timestampBuffer.push(e),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 t.inserts){if("growing"===this.config.windowMode&&this.buffer.full){const t=this.config.maxCapacity||1e6;t>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,t),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap))}const t=this.buffer.push(n);this.timestampBuffer&&this.timestampBuffer.push(e),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!=t&&(this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):this.yExtent.evict(this.getY(t)))}return!0}computeScene(t){var e,n,r,o,i,l,a;const{config:s,buffer:c}=this;if(!this.needsFullRebuild&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(null!==(e=this.config.scalePadding)&&void 0!==e?e:0)&&(this.lastLayout.width!==t.width||this.lastLayout.height!==t.height))return void this.remapScene(t);if(this.xExtent.dirty&&this.xExtent.recalculate(c,this.getX),this.yExtent.dirty)if("candlestick"===s.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const t of c)this.yExtent.push(this.getHigh(t)),this.yExtent.push(this.getLow(t))}else this.yExtent.recalculate(c,this.getY);const u=this.getBufferArray(),d=this.xExtent.extent,h=this.yExtent.extent;let f=s.xExtent?[null!==(n=s.xExtent[0])&&void 0!==n?n:d[0],null!==(r=s.xExtent[1])&&void 0!==r?r:d[1]]:d,y=s.yExtent?[null!==(o=s.yExtent[0])&&void 0!==o?o:h[0],null!==(i=s.yExtent[1])&&void 0!==i?i:h[1]]:h;const g=s.yExtent&&null!=s.yExtent[0]&&null!=s.yExtent[1];if("stackedarea"===s.chartType&&!g&&c.size>0)if(s.normalize)y=[0,1+s.extentPadding];else{const t=`${c.size}:${this._ingestVersion}`;if(this._stackExtentCache&&this._stackExtentCache.key===t)y=this._stackExtentCache.yDomain;else{const e=this.groupData(u),n=new Map;for(const t of e)for(const e of t.data){const t=this.getX(e),r=this.getY(e);null==t||null==r||Number.isNaN(t)||Number.isNaN(r)||n.set(t,(n.get(t)||0)+r)}let r=0;for(const t of n.values())t>r&&(r=t);y=[0,r+(r>0?r*s.extentPadding:1)],this._stackExtentCache={key:t,yDomain:y}}}else if("bar"===s.chartType&&s.binSize&&!g&&c.size>0){const[,t]=function(t,e,n,r,o){const i=pt(t,e,n,r,o);if(0===i.size)return[0,0];let l=0;for(const t of i.values())t.total>l&&(l=t.total);return[0,l]}(c,this.getX,this.getY,s.binSize,this.getCategory);y=[0,t+t*s.extentPadding]}else if("waterfall"===s.chartType&&!g&&c.size>0){const[t,e]=function(t,e){let n=0,r=0,o=0;for(const i of t){const t=e(i);null==t||Number.isNaN(t)||(o+=t,n>o&&(n=o),o>r&&(r=o))}return[n,r]}(c,this.getY),n=e-t,r=n>0?n*s.extentPadding:1;y=[Math.min(0,t-Math.abs(r)),Math.max(0,e+Math.abs(r))]}else if(!g&&y[0]!==1/0){if(this.getBounds)for(const t of u){const e=this.getY(t),n=this.getBounds(t);null!=e&&!Number.isNaN(e)&&n&&(e+n>y[1]&&(y[1]=e+n),y[0]>e-n&&(y[0]=e-n))}const t=y[1]-y[0],e=t>0?t*s.extentPadding:1,n=null===(l=s.yExtent)||void 0===l?void 0:l[0],r=null===(a=s.yExtent)||void 0===a?void 0:a[1];y=[null!=n?y[0]:y[0]-e,null!=r?y[1]:y[1]+e],"log"===s.yScaleType&&0>=y[0]&&h[0]>0&&(y[0]=null!=n?y[0]:h[0]/(1+s.extentPadding))}if(f[0]===1/0||f[1]===-1/0)if("time"===s.xScaleType){const t=Date.now();f=[t-864e5,t]}else f=[0,1];y[0]!==1/0&&y[1]!==-1/0||(y=[0,1]);const x="streaming"===s.runtimeMode,b=Math.max(0,Math.min(s.scalePadding||0,Math.min(t.width,t.height)/2-1));if(x)if("x"==("up"===(k=s.arrowOfTime)||"down"===k?"y":"x")){const e="right"===s.arrowOfTime?[b,t.width-b]:[t.width-b,b];this.scales={x:p().domain(f).range(e),y:p().domain(y).range([t.height-b,b])}}else{const e="down"===s.arrowOfTime?[b,t.height-b]:[t.height-b,b];this.scales={x:p().domain(y).range([b,t.width-b]),y:p().domain(f).range(e)}}else{const e=(t,e,n)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return v().domain(t).range(n).clamp(!0)}return"time"===t?m().domain([new Date(e[0]),new Date(e[1])]).range(n):p().domain(e).range(n)};this.scales={x:e(s.xScaleType,f,[b,t.width-b]),y:e(s.yScaleType,y,[t.height-b,b])}}var k;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(t,u),this.config.decay&&this.applyDecay(this.scene,u),this.config.pulse&&this.applyPulse(this.scene,u),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.rebuildQuadtree(),this.needsFullRebuild=!1,this.lastLayout={width:t.width,height:t.height},this.version++}rebuildQuadtree(){const t=this.config.chartType;if("scatter"!==t&&"bubble"!==t)return void(this._quadtree=null);const e=this.scene.filter(t=>"point"===t.type);this._quadtree=e.length>zt.QUADTREE_THRESHOLD?x().x(t=>t.x).y(t=>t.y).addAll(e):null}get quadtree(){return this._quadtree}remapScene(t){const e=t.width/this.lastLayout.width,n=t.height/this.lastLayout.height;for(const t of this.scene)switch(t.type){case"line":for(const r of t.path)r[0]*=e,r[1]*=n;break;case"area":for(const r of t.topPath)r[0]*=e,r[1]*=n;for(const r of t.bottomPath)r[0]*=e,r[1]*=n;break;case"point":t.x*=e,t.y*=n;break;case"rect":case"heatcell":t.x*=e,t.y*=n,t.w*=e,t.h*=n;break;case"candlestick":t.x*=e,t.openY*=n,t.closeY*=n,t.highY*=n,t.lowY*=n}const r=this.scales.x.domain(),o=this.scales.y.domain(),i=this.scales.x.range(),l=this.scales.y.range(),a=(t,e,n)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return v().domain(t).range(n).clamp(!0)}return"time"===t?m().domain([new Date(e[0]),new Date(e[1])]).range(n):p().domain(e).range(n)},s=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(t.width,t.height)/2-1)),c=l[1]>l[0];this.scales={x:a(this.config.xScaleType,r,i[0]>i[1]?[t.width-s,s]:[s,t.width-s]),y:a(this.config.yScaleType,o,c?[s,t.height-s]:[t.height-s,s])},this.lastLayout={width:t.width,height:t.height},this.rebuildQuadtree(),this.version++}buildSceneNodes(t,e){var n;const{config:r,scales:o}=this;if(!o||0===e.length)return[];const i={scales:o,config:r,getX:this.getX,getY:this.getY,getY0:this.getY0,getSize:this.getSize,getColor:this.getColor,getGroup:this.getGroup,getCategory:this.getCategory,getPointId:this.getPointId,getBounds:this.getBounds,getOpen:this.getOpen,getHigh:this.getHigh,getLow:this.getLow,getClose:this.getClose,resolveLineStyle:(t,e)=>this.resolveLineStyle(t,e),resolveAreaStyle:(t,e)=>this.resolveAreaStyle(t,e),resolveBoundsStyle:(t,e)=>this.resolveBoundsStyle(t,e),resolveColorMap:t=>this.resolveColorMap(t),resolveGroupColor:t=>this.resolveGroupColor(t),groupData:t=>this.groupData(t),barCategoryCache:this._barCategoryCache};switch(r.chartType){case"line":return function(t,e){var n;const r=t.groupData(e),o=[],i=null===(n=t.config.annotations)||void 0===n?void 0:n.filter(t=>"threshold"===t.type&&t.color).map(t=>({value:t.value,color:t.color,thresholdType:t.thresholdType||"greater"}));if(t.getBounds)for(const e of r){const n=$t(t,e.data,e.key);n&&o.push(n)}for(const e of r){const n=t.resolveLineStyle(e.key,e.data[0]),r=Dt(e.data,t.scales,t.getX,t.getY,n,e.key);i&&i.length>0&&(r.colorThresholds=i),t.config.curve&&"linear"!==t.config.curve&&(r.curve=t.config.curve),t.config.lineGradient&&(r.strokeGradient=t.config.lineGradient),o.push(r)}return Ot(t,r,o),o}(i,e);case"area":return function(t,e){const n=t.groupData(e),r=[],o=t.scales.y.domain()[0],i=t.getY0?e=>{const n=t.getY0(e);return null==n?o:n}:void 0;for(const e of n){const n=t.resolveAreaStyle(e.key,e.data[0]),l=Tt(e.data,t.scales,t.getX,t.getY,o,n,e.key,i);t.config.gradientFill&&(l.fillGradient=t.config.gradientFill),t.config.curve&&"linear"!==t.config.curve&&(l.curve=t.config.curve),t.config.lineGradient&&(l.strokeGradient=t.config.lineGradient),r.push(l)}return Ot(t,n,r),r}(i,e);case"mixed":return function(t,e){const n=t.groupData(e),r=[],o=t.config.areaGroups||new Set,i=t.scales.y.domain()[0],l=t.getY0?e=>{const n=t.getY0(e);return null==n?i:n}:void 0;for(const e of n)if(o.has(e.key)){const n=t.resolveAreaStyle(e.key,e.data[0]),o=Tt(e.data,t.scales,t.getX,t.getY,i,n,e.key,l);t.config.gradientFill&&(o.fillGradient=t.config.gradientFill),t.config.curve&&"linear"!==t.config.curve&&(o.curve=t.config.curve),t.config.lineGradient&&(o.strokeGradient=t.config.lineGradient),r.push(o)}else{const n=t.resolveLineStyle(e.key,e.data[0]),o=Dt(e.data,t.scales,t.getX,t.getY,n,e.key);t.config.curve&&"linear"!==t.config.curve&&(o.curve=t.config.curve),t.config.lineGradient&&(o.strokeGradient=t.config.lineGradient),r.push(o)}return Ot(t,n,r),r}(i,e);case"stackedarea":return function(t,e){const n=t.groupData(e);n.sort((t,e)=>e.key>t.key?-1:t.key>e.key?1:0);const r=t.config.curve&&"linear"!==t.config.curve?t.config.curve:void 0,{nodes:o,stackedTops:i}=function(t,e,n,r,o,i,l){var a;const s=new Set;for(const e of t)for(const t of e.data){const e=n(t);null==e||Number.isNaN(e)||s.add(e)}const c=Array.from(s).sort((t,e)=>t-e),u=new Map;for(const e of t){const t=new Map;for(const o of e.data){const e=n(o),i=r(o);null==e||null==i||Number.isNaN(e)||Number.isNaN(i)||t.set(e,(t.get(e)||0)+i)}u.set(e.key,t)}let d;if(i){d=new Map;for(const e of c){let n=0;for(const r of t)n+=(null===(a=u.get(r.key))||void 0===a?void 0:a.get(e))||0;d.set(e,n||1)}}const h=[],f=new Map,y=new Map;for(const t of c)y.set(t,0);for(const n of t){const t=u.get(n.key),r=[],a=[],s=new Map;for(const n of c){let o=t.get(n)||0;const l=y.get(n);i&&(o/=d.get(n));const c=l+o,u=e.x(n);a.push([u,e.y(l)]),r.push([u,e.y(c)]),y.set(n,c),s.set(n,c)}f.set(n.key,s);const g={type:"area",topPath:r,bottomPath:a,style:o(n.key,n.data[0]),datum:n.data,group:n.key};l&&(g.curve=l),h.push(g)}return{nodes:h,stackedTops:f}}(n,t.scales,t.getX,t.getY,(e,n)=>t.resolveAreaStyle(e,n),t.config.normalize,r),l=o;if(t.config.pointStyle){const e=new WeakMap;for(const r of n){const n=i.get(r.key);if(n)for(const o of r.data){const r=t.getX(o),i=t.getY(o);null==r||Number.isNaN(r)||null==i||Number.isNaN(i)||!n.has(r)||e.set(o,n.get(r))}}const r=n=>{var r;return null!==(r=e.get(n))&&void 0!==r?r:t.getY(n)};Ot(t,n,l,r)}return l}(i,e);case"scatter":case"bubble":return function(t,e){const n=[],r="bubble"===t.config.chartType?10:5,o=t.config.sizeRange||[3,15];let i=null;if(t.getSize&&!t.config.pointStyle){const n=e.map(e=>t.getSize(e)).filter(t=>null!=t&&!Number.isNaN(t));if(n.length>0){let t=1/0,e=-1/0;for(const r of n)t>r&&(t=r),r>e&&(e=r);i=n=>t===e?(o[0]+o[1])/2:o[0]+(n-t)/(e-t)*(o[1]-o[0])}}const l=t.getColor?t.resolveColorMap(e):null;for(const o of e){let e=t.config.pointStyle?t.config.pointStyle(o):{fill:"#4e79a7",opacity:.8},a=e.r||r;if(i&&t.getSize){const e=t.getSize(o);null==e||Number.isNaN(e)||(a=i(e))}if(l&&t.getColor&&!e.fill){const n=t.getColor(o);n&&l.has(n)&&(e=Object.assign(Object.assign({},e),{fill:l.get(n)}))}const s=t.getPointId?t.getPointId(o)+"":void 0,c=Lt(o,t.scales,t.getX,t.getY,a,e,s);c&&n.push(c)}return n}(i,e);case"heatmap":return function(t,e,n){if(t.config.heatmapAggregation)return function(t,e,n){var r,o,i;const l=Math.max(1,Math.floor(null!==(r=t.config.heatmapXBins)&&void 0!==r?r:20)),a=Math.max(1,Math.floor(null!==(o=t.config.heatmapYBins)&&void 0!==o?o:20)),s=null!==(i=t.config.heatmapAggregation)&&void 0!==i?i:"count",c=mt(t.config.valueAccessor,"value");if(!t.scales||0===e.length)return[];const[u,d]=t.scales.x.domain(),[h,f]=t.scales.y.domain(),y=(d-u||1)/l,g=(f-h||1)/a,p=l*a;if(p>1e6)return[];const v=new Int32Array(p),m=new Float64Array(p);for(let n=0;e.length>n;n++){const r=e[n],o=t.getX(r),i=t.getY(r);if(!isFinite(o)||!isFinite(i))continue;const s=Math.min(Math.floor((o-u)/y),l-1),d=Math.min(Math.floor((i-h)/g),a-1);if(0>s||0>d)continue;const f=d*l+s;v[f]++;const p=c(r);m[f]+=isFinite(p)?p:0}let x=1/0,b=-1/0;for(let t=0;p>t;t++){if(0===v[t])continue;let e;switch(s){case"sum":e=m[t];break;case"mean":e=m[t]/v[t];break;default:e=v[t]}x>e&&(x=e),e>b&&(b=e)}if(!isFinite(x))return[];const k=b-x||1,w=n.width/l,E=n.height/a,A=t.config.showValues,M=t.config.heatmapValueFormat,S=[];for(let t=0;a>t;t++){const e=t*l;for(let n=0;l>n;n++){const r=e+n;if(0===v[r])continue;let o;switch(s){case"sum":o=m[r];break;case"mean":o=m[r]/v[r];break;default:o=v[r]}const i=(o-x)/k;S.push(Nt(n*w,(a-1-t)*E,w,E,`rgb(${220-(180*i+.5)|0},${220-(100*i+.5)|0},${255-(50*i+.5)|0})`,{xi:n,yi:t,value:o,count:v[r],sum:m[r]},A?{value:o,showValues:!0,valueFormat:M}:void 0))}}return S}(t,e,n);if(0===e.length)return[];const r=mt(t.config.valueAccessor,"value"),o=xt(t.config.xAccessor,"x"),i=xt(t.config.yAccessor,"y"),l=new Map,a=new Map,s=Array(e.length),c=Array(e.length);for(let t=0;e.length>t;t++){const n=e[t],r=o(n),u=i(n);s[t]=r,c[t]=u,l.has(r)||l.set(r,l.size),a.has(u)||a.set(u,a.size)}const u=l.size,d=a.size;if(0===u||0===d)return[];const h=Array.from(l.keys()),f=Array.from(a.keys()),y=h.every(t=>"number"==typeof t&&!isNaN(t)),g=f.every(t=>"number"==typeof t&&!isNaN(t));if(y){h.sort((t,e)=>t-e),l.clear();for(let t=0;h.length>t;t++)l.set(h[t],t)}if(g){f.sort((t,e)=>t-e),a.clear();for(let t=0;f.length>t;t++)a.set(f[t],t)}const p=new Float64Array(e.length),v=new Float64Array(e.length),m=Array(e.length),x=new Map;let b=0;for(let t=0;e.length>t;t++){const n=e[t],o=l.get(s[t]),i=a.get(c[t]);if(void 0===o||void 0===i)continue;const d=r(n),h=i*u+o,f=x.get(h);let y;void 0!==f?y=f:(y=b++,x.set(h,y)),p[y]=h,v[y]=d,m[y]=n}let k=1/0,w=-1/0;for(let t=0;b>t;t++){const e=v[t];isFinite(e)&&(k>e&&(k=e),e>w&&(w=e))}if(!isFinite(k)||!isFinite(w))return[];const E=function(t){const e=t in It?t:"blues";let n=Wt.get(e);if(n)return n;n=Array(256);const r=It[e]||A;for(let t=0;256>t;t++)n[t]=r(t/255);return Wt.set(e,n),n}("string"==typeof t.config.colorScheme?t.config.colorScheme:"blues"),M=255/(w-k||1),S=n.width/u,P=n.height/d,_=t.config.showValues,D=t.config.heatmapValueFormat,T=[];for(let t=0;b>t;t++){const e=v[t];if(!isFinite(e))continue;const n=p[t],r=n%u;T.push(Nt(r*S,(d-1-(n-r)/u)*P,S,P,E[Math.min((e-k)*M+.5|0,255)],m[t],_?{value:e,showValues:!0,valueFormat:D}:void 0))}return T}(i,e,t);case"bar":{const t=function(t,e){var n;if(!t.config.binSize)return{nodes:[],binBoundaries:[]};const r=pt(e,t.getX,t.getY,t.config.binSize,t.getCategory);if(0===r.size)return{nodes:[],binBoundaries:[]};let o=null;if(t.getCategory){const e=new Set;for(const t of r.values())for(const n of t.categories.keys())e.add(n);const n=t.config.barColors?Object.keys(t.config.barColors):[],i=new Set(n),l=Array.from(e).filter(t=>!i.has(t)).sort(),a=n.filter(t=>e.has(t)),s=a.join("\0")+""+l.join("\0");t.barCategoryCache&&t.barCategoryCache.key===s?o=t.barCategoryCache.order:(o=[...a,...l],t.barCategoryCache={key:s,order:o})}const i=[],l=t.scales,[a,s]=l.x.domain();for(const e of r.values()){const r=Math.max(e.start,a),c=Math.min(e.end,s);if(r>=c)continue;const u=l.x(r),d=l.x(c),h=Math.abs(d-u),f=h>2?1:0,y=Math.min(u,d)+f/2,g=Math.max(h-f,1);if(g>0)if(o&&e.categories.size>0){let r=0;for(const a of o){const o=e.categories.get(a)||0;if(0===o)continue;const s=l.y(r),c=l.y(r+o);i.push(Ct(y,Math.min(s,c),g,Math.abs(s-c),{fill:(null===(n=t.config.barColors)||void 0===n?void 0:n[a])||"#4e79a7"},{binStart:e.start,binEnd:e.end,total:e.total,category:a,categoryValue:o},a)),r+=o}}else{const t=l.y(0),n=l.y(e.total);i.push(Ct(y,Math.min(t,n),g,Math.abs(t-n),{fill:"#007bff"},{binStart:e.start,binEnd:e.end,total:e.total}))}}const c=new Set;for(const t of r.values())c.add(t.start),c.add(t.end);return{nodes:i,binBoundaries:Array.from(c).sort((t,e)=>t-e)}}(i,e);return this._barCategoryCache=null!==(n=i.barCategoryCache)&&void 0!==n?n:null,this._binBoundaries=t.binBoundaries,t.nodes}case"swarm":return function(t,e){var n,r,o,i;const l=[],a=t.config.swarmStyle||{},s=null!==(n=a.radius)&&void 0!==n?n:3,c=null!==(r=a.fill)&&void 0!==r?r:"#007bff",u=null!==(o=a.opacity)&&void 0!==o?o:.7,d=a.stroke,h=a.strokeWidth;for(const n of e){const e=t.getX(n),r=t.getY(n);if(null==r||Number.isNaN(r))continue;const o=t.scales.x(e),a=t.scales.y(r);let f=c;if(t.getCategory){const e=t.getCategory(n);f=(null===(i=t.config.barColors)||void 0===i?void 0:i[e])||f}const y={type:"point",x:o,y:a,r:s,style:{fill:f,opacity:u,stroke:d,strokeWidth:h},datum:n};t.getPointId&&(y.pointId=t.getPointId(n)+""),l.push(y)}return l}(i,e);case"waterfall":return function(t,e,n){var r,o,i;const l=[],a=t.scales,s=t.config.waterfallStyle,c=e.filter(e=>{const n=t.getY(e),r=t.getX(e);return null!=n&&!Number.isNaN(n)&&null!=r&&isFinite(r)});if(0===c.length)return l;const u=null!==(r=null==s?void 0:s.positiveColor)&&void 0!==r?r:"#28a745",d=null!==(o=null==s?void 0:s.negativeColor)&&void 0!==o?o:"#dc3545",h=null!==(i=null==s?void 0:s.gap)&&void 0!==i?i:1,f=null==s?void 0:s.stroke,y=null==s?void 0:s.strokeWidth;let g=0;for(let e=0;c.length>e;e++){const r=c[e],o=t.getX(r),i=t.getY(r),p=g+i;let v;v=c.length-1>e?t.getX(c[e+1])-o:e>0?o-t.getX(c[e-1]):0;const m=a.x(o),x=0!==v?a.x(o+v):m+n.width/10,b=Math.min(m,x)+h/2,k=Math.max(m,x)-h/2-b;if(0>=k){g=p;continue}const w=a.y(g),E=a.y(p);l.push(Ct(b,Math.min(w,E),k,Math.abs(w-E),{fill:0>i?d:u,stroke:f,strokeWidth:y},Object.assign(Object.assign({},r),{baseline:g,cumEnd:p,delta:i,_connectorStroke:null==s?void 0:s.connectorStroke,_connectorWidth:null==s?void 0:s.connectorWidth}))),g=p}return l}(i,e,t);case"candlestick":return function(t,e){var n,r;if(!t.getHigh||!t.getLow||!t.scales)return[];const o=null!==(n=t.config.candlestickRangeMode)&&void 0!==n&&n;if(!(o||t.getOpen&&t.getClose))return[];const i=[],l=t.config.candlestickStyle||{},a=l.rangeColor||"#6366f1",s=o?a:l.upColor||"#28a745",c=o?a:l.downColor||"#dc3545",u=o?a:l.wickColor||"#333",d=l.wickWidth||(o?2:1),h=e.map(e=>t.getX(e)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let f=o?0:null!==(r=l.bodyWidth)&&void 0!==r?r:0;if(!o&&null==l.bodyWidth&&h.length>1){let e=1/0;for(let n=1;h.length>n;n++){const r=Math.abs(t.scales.x(h[n])-t.scales.x(h[n-1]));r>0&&e>r&&(e=r)}f=e!==1/0?Math.max(2,Math.min(.6*e,20)):6}else o||null!=l.bodyWidth||(f=6);for(const n of e){const e=t.getX(n);if(null==e||Number.isNaN(e))continue;const r=t.getHigh(n),l=t.getLow(n);if(null==r||Number.isNaN(r)||null==l||Number.isNaN(l))continue;const a=o?r:t.getOpen(n),h=o?l:t.getClose(n);if(!o&&[a,h].some(t=>null==t||Number.isNaN(t)))continue;const y=h>=a,g={type:"candlestick",x:t.scales.x(e),openY:t.scales.y(a),closeY:t.scales.y(h),highY:t.scales.y(r),lowY:t.scales.y(l),bodyWidth:f,upColor:s,downColor:c,wickColor:u,wickWidth:d,isUp:y,datum:n};o&&(g.isRange=!0),i.push(g)}return i}(i,e);default:return[]}}resolveBoundsStyle(t,e){const n=this.config.boundsStyle;return"function"==typeof n?n(e||{},t):n&&"object"==typeof n?n:{fill:this.resolveLineStyle(t,e).stroke||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(t,e){const n=this.config.decay;return n&&e>1?Et(n,t,e):1}applyDecay(t,e){this.config.decay&&function(t,e,n){var r,o;const i=n.length;if(1>=i)return;const l=new Map;for(let t=0;n.length>t;t++)l.set(n[t],t);for(const n of e){if("line"===n.type){const e=Array.isArray(n.datum)?n.datum:[];if(2>e.length)continue;const r=Array(e.length);let o=!1;for(let n=0;e.length>n;n++){const a=l.get(e[n]);null!=a?(r[n]=Et(t,a,i),1>r[n]&&(o=!0)):r[n]=1}o&&(n._decayOpacities=r);continue}if("area"===n.type){const e=Array.isArray(n.datum)?n.datum:[],r=n.topPath?n.topPath.length:e.length;if(2>r)continue;if(e.length===r){const o=Array(r);let a=!1;for(let n=0;e.length>n;n++){const r=l.get(e[n]);null!=r?(o[n]=Et(t,r,i),1>o[n]&&(a=!0)):o[n]=1}a&&(n._decayOpacities=o)}else{let o=1;for(const n of e){const e=l.get(n);if(null!=e){const n=Et(t,e,i);o>n&&(o=n)}}if(1>o){const t=Array(r);t.fill(o),n._decayOpacities=t}}continue}const e=l.get(n.datum);if(null==e)continue;const a=Et(t,e,i);if("heatcell"===n.type)n.style={opacity:a};else if("candlestick"===n.type)n._decayOpacity=a;else{const t=null!==(o=null===(r=n.style)||void 0===r?void 0:r.opacity)&&void 0!==o?o:1;n.style=Object.assign(Object.assign({},n.style),{opacity:t*a})}}}(this.config.decay,t,e)}applyPulse(t,e){this.config.pulse&&this.timestampBuffer&&function(t,e,n,r){var o,i;const l="undefined"!=typeof performance?performance.now():Date.now(),a=null!==(o=t.color)&&void 0!==o?o:"rgba(255,255,255,0.6)",s=null!==(i=t.glowRadius)&&void 0!==i?i:4,c=new Map;for(let t=0;n.length>t;t++)c.set(n[t],t);for(const n of e){if("line"===n.type)continue;if("area"===n.type){const e=Array.isArray(n.datum)?n.datum:[n.datum];let o=0;for(const n of e){const e=c.get(n);if(null==e)continue;const i=r.get(e);if(null==i)continue;const a=At(t,i,l);a>o&&(o=a)}o>0&&(n._pulseIntensity=o,n._pulseColor=a);continue}const e=c.get(n.datum);if(null==e)continue;const o=r.get(e);if(null==o)continue;const i=At(t,o,l);i>0&&(n._pulseIntensity=i,n._pulseColor=a,n._pulseGlowRadius=s)}}(this.config.pulse,t,e,this.timestampBuffer)}get hasActivePulses(){return!!this.config.pulse&&function(t,e){var n;if(!e||0===e.size)return!1;const r="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(n=t.duration)&&void 0!==n?n:500,i=e.peek();return null!=i&&o>r-i}(this.config.pulse,this.timestampBuffer)}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(t,e,n,r){var o,i,l;n.clear(),r.clear();for(let a=0;e.length>a;a++){const s=e[a],c=_t(t,s,a);c&&("point"===s.type?n.set(c,{x:s.x,y:s.y,r:s.r,opacity:s.style.opacity}):"rect"===s.type?n.set(c,{x:s.x,y:s.y,w:s.w,h:s.h,opacity:s.style.opacity}):"heatcell"===s.type?n.set(c,{x:s.x,y:s.y,w:s.w,h:s.h,opacity:null===(o=s.style)||void 0===o?void 0:o.opacity}):"candlestick"===s.type?n.set(c,{x:s.x,y:s.openY}):"line"===s.type?r.set(c,{path:s.path.map(t=>[t[0],t[1]]),opacity:null===(i=s.style)||void 0===i?void 0:i.opacity}):"area"===s.type&&r.set(c,{topPath:s.topPath.map(t=>[t[0],t[1]]),bottomPath:s.bottomPath.map(t=>[t[0],t[1]]),opacity:null===(l=s.style)||void 0===l?void 0:l.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}startTransition(){if(!this.config.transition)return;const t=function(t,e,n,r,o){var i,l,a,s,c,u,d,h,f,y,g,p,v,m,x,b,k,w,E,A,M,S,P,_,D,T,L,C;if(0===r.size&&0===o.size)return n;const N=null!==(i=e.duration)&&void 0!==i?i:300;if(n.exitNodes.length>0){const t=new Set(n.exitNodes);n.scene=n.scene.filter(e=>!t.has(e)),n.exitNodes=[]}let $=!1;const O=new Set,I=new Set;for(let e=0;n.scene.length>e;e++){const i=n.scene[e],E=_t(t,i,e);if(!E)continue;if(i._transitionKey=E,"line"===i.type||"area"===i.type){const t=o.get(E);if(t){if(I.add(E),"line"===i.type&&t.path&&t.path.length===i.path.length){i._targetPath=i.path.map(t=>[t[0],t[1]]),i._prevPath=t.path;for(let e=0;i.path.length>e;e++)i.path[e]=[t.path[e][0],t.path[e][1]];$=!0}else if("area"===i.type&&t.topPath&&t.bottomPath&&t.topPath.length===i.topPath.length&&t.bottomPath.length===i.bottomPath.length){i._targetTopPath=i.topPath.map(t=>[t[0],t[1]]),i._targetBottomPath=i.bottomPath.map(t=>[t[0],t[1]]),i._prevTopPath=t.topPath,i._prevBottomPath=t.bottomPath;for(let e=0;i.topPath.length>e;e++)i.topPath[e]=[t.topPath[e][0],t.topPath[e][1]];for(let e=0;i.bottomPath.length>e;e++)i.bottomPath[e]=[t.bottomPath[e][0],t.bottomPath[e][1]];$=!0}i._targetOpacity=null!==(l=i.style.opacity)&&void 0!==l?l:1,i._startOpacity=null!==(s=null!==(a=t.opacity)&&void 0!==a?a:i.style.opacity)&&void 0!==s?s:1}else i._targetOpacity=null!==(c=i.style.opacity)&&void 0!==c?c:1,i._startOpacity=0,i.style=Object.assign(Object.assign({},i.style),{opacity:0}),$=!0;continue}const A=r.get(E);if("point"===i.type)if(A){O.add(E);const t={x:i.x,y:i.y,r:i.r};i._targetOpacity=null!==(u=i.style.opacity)&&void 0!==u?u:1,A.x===t.x&&A.y===t.y&&A.r===t.r||(i._targetX=t.x,i._targetY=t.y,i._targetR=t.r,i.x=A.x,i.y=A.y,i.r=null!==(d=A.r)&&void 0!==d?d:i.r,$=!0)}else i._targetOpacity=null!==(h=i.style.opacity)&&void 0!==h?h:1,i.style=Object.assign(Object.assign({},i.style),{opacity:0}),$=!0;else if("rect"===i.type)if(A){O.add(E);const t={x:i.x,y:i.y,w:i.w,h:i.h};i._targetOpacity=null!==(f=i.style.opacity)&&void 0!==f?f:1,A.x===t.x&&A.y===t.y&&A.w===t.w&&A.h===t.h||(i._targetX=t.x,i._targetY=t.y,i._targetW=t.w,i._targetH=t.h,i.x=A.x,i.y=A.y,i.w=null!==(y=A.w)&&void 0!==y?y:i.w,i.h=null!==(g=A.h)&&void 0!==g?g:i.h,$=!0)}else i._targetOpacity=null!==(p=i.style.opacity)&&void 0!==p?p:1,i.style=Object.assign(Object.assign({},i.style),{opacity:0}),$=!0;else if("heatcell"===i.type)if(A){O.add(E);const t={x:i.x,y:i.y,w:i.w,h:i.h};i._targetOpacity=null!==(m=null===(v=i.style)||void 0===v?void 0:v.opacity)&&void 0!==m?m:1,A.x===t.x&&A.y===t.y&&A.w===t.w&&A.h===t.h||(i._targetX=t.x,i._targetY=t.y,i._targetW=t.w,i._targetH=t.h,i.x=A.x,i.y=A.y,i.w=null!==(x=A.w)&&void 0!==x?x:i.w,i.h=null!==(b=A.h)&&void 0!==b?b:i.h,$=!0)}else i._targetOpacity=null!==(w=null===(k=i.style)||void 0===k?void 0:k.opacity)&&void 0!==w?w:1,i.style=Object.assign(Object.assign({},i.style||{}),{opacity:0}),$=!0}for(const[t,e]of o)if(!I.has(t))if(t.startsWith("l:")&&e.path){const r={type:"line",path:e.path.map(t=>[t[0],t[1]]),group:t.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:null!==(E=e.opacity)&&void 0!==E?E:1},_targetOpacity:0,_transitionKey:t,datum:null};n.exitNodes.push(r),$=!0}else if(t.startsWith("a:")&&e.topPath&&e.bottomPath){const r={type:"area",topPath:e.topPath.map(t=>[t[0],t[1]]),bottomPath:e.bottomPath.map(t=>[t[0],t[1]]),group:t.slice(2),style:{fill:"#999",opacity:null!==(A=e.opacity)&&void 0!==A?A:1},_targetOpacity:0,_transitionKey:t,datum:null};n.exitNodes.push(r),$=!0}for(const[t,e]of r)if(!O.has(t)){if(t.startsWith("p:")){const r={type:"point",x:e.x,y:e.y,r:null!==(M=e.r)&&void 0!==M?M:3,style:{opacity:null!==(S=e.opacity)&&void 0!==S?S:1},datum:null,_targetOpacity:0,_transitionKey:t};n.exitNodes.push(r)}else if(t.startsWith("r:")){const r={type:"rect",x:e.x,y:e.y,w:null!==(P=e.w)&&void 0!==P?P:0,h:null!==(_=e.h)&&void 0!==_?_:0,style:{opacity:null!==(D=e.opacity)&&void 0!==D?D:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t};n.exitNodes.push(r)}else if(t.startsWith("h:")){const r={type:"heatcell",x:e.x,y:e.y,w:null!==(T=e.w)&&void 0!==T?T:0,h:null!==(L=e.h)&&void 0!==L?L:0,fill:"#999",datum:null,style:{opacity:null!==(C=e.opacity)&&void 0!==C?C:1},_targetOpacity:0,_transitionKey:t};n.exitNodes.push(r)}$=!0}return n.exitNodes.length>0&&(n.scene=[...n.scene,...n.exitNodes]),$&&(n.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:N}),n}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap);this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition}advanceTransition(t){if(!this.activeTransition||!this.config.transition)return!1;const e={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},n=function(t,e,n,r){var o,i,l,a,s;if(!n.activeTransition)return!1;const c=St(t,n.activeTransition),u=Mt(c,"linear"===e.easing?"linear":"ease-out-cubic");for(const t of n.scene){const e=t._transitionKey;if("point"===t.type){if(void 0!==t._targetOpacity){const n=e?r.get(e):void 0,i=n?null!==(o=n.opacity)&&void 0!==o?o:1:0;t.style.opacity=Pt(i,t._targetOpacity,u)}if(void 0===t._targetX)continue;if(!e)continue;const n=r.get(e);if(!n)continue;t.x=Pt(n.x,t._targetX,u),t.y=Pt(n.y,t._targetY,u),void 0!==t._targetR&&void 0!==n.r&&(t.r=Pt(n.r,t._targetR,u))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const n=e?r.get(e):void 0,o=n?null!==(i=n.opacity)&&void 0!==i?i:1:0;t.style.opacity=Pt(o,t._targetOpacity,u)}if(void 0===t._targetX)continue;if(!e)continue;const n=r.get(e);if(!n)continue;t.x=Pt(n.x,t._targetX,u),t.y=Pt(n.y,t._targetY,u),void 0!==n.w&&(t.w=Pt(n.w,t._targetW,u)),void 0!==n.h&&(t.h=Pt(n.h,t._targetH,u))}else if("heatcell"===t.type){if(void 0!==t._targetOpacity){const n=e?r.get(e):void 0,o=n?null!==(l=n.opacity)&&void 0!==l?l:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:Pt(o,t._targetOpacity,u)})}if(void 0===t._targetX)continue;if(!e)continue;const n=r.get(e);if(!n)continue;t.x=Pt(n.x,t._targetX,u),t.y=Pt(n.y,t._targetY,u),void 0!==n.w&&(t.w=Pt(n.w,t._targetW,u)),void 0!==n.h&&(t.h=Pt(n.h,t._targetH,u))}else if("line"===t.type){if(void 0!==t._targetOpacity){const e=null!==(a=t._startOpacity)&&void 0!==a?a:0;t.style=Object.assign(Object.assign({},t.style),{opacity:Pt(e,t._targetOpacity,u)})}const e=t._prevPath,n=t._targetPath;if(e&&n&&e.length===t.path.length)for(let r=0;t.path.length>r;r++)t.path[r][0]=Pt(e[r][0],n[r][0],u),t.path[r][1]=Pt(e[r][1],n[r][1],u)}else if("area"===t.type){if(void 0!==t._targetOpacity){const e=null!==(s=t._startOpacity)&&void 0!==s?s:0;t.style=Object.assign(Object.assign({},t.style),{opacity:Pt(e,t._targetOpacity,u)})}const e=t._prevTopPath,n=t._prevBottomPath,r=t._targetTopPath,o=t._targetBottomPath;if(e&&r&&e.length===t.topPath.length)for(let n=0;t.topPath.length>n;n++)t.topPath[n][0]=Pt(e[n][0],r[n][0],u),t.topPath[n][1]=Pt(e[n][1],r[n][1],u);if(n&&o&&n.length===t.bottomPath.length)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e][0]=Pt(n[e][0],o[e][0],u),t.bottomPath[e][1]=Pt(n[e][1],o[e][1],u)}}if(c>=1){for(const t of n.scene){if(void 0!==t._targetOpacity){const e=t._targetOpacity;t.style=Object.assign(Object.assign({},"line"===t.type||"area"===t.type?t.style:t.style||{}),{opacity:0===e?0:e}),t._targetOpacity=void 0}if("point"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("rect"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("heatcell"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("line"===t.type){const e=t._targetPath;if(e)for(let n=0;t.path.length>n;n++)t.path[n]=e[n];t._prevPath=void 0,t._targetPath=void 0}else if("area"===t.type){const e=t._targetTopPath,n=t._targetBottomPath;if(e)for(let n=0;t.topPath.length>n;n++)t.topPath[n]=e[n];if(n)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e]=n[e];t._prevTopPath=void 0,t._prevBottomPath=void 0,t._targetTopPath=void 0,t._targetBottomPath=void 0}}if(n.exitNodes.length>0){const t=new Set(n.exitNodes);n.scene=n.scene.filter(e=>!t.has(e)),n.exitNodes=[]}return n.activeTransition=null,!1}return!0}(t,this.config.transition,e,this.prevPositionMap);return this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition,n}groupData(t){if(!this.getGroup)return[{key:"_default",data:t}];const e=new Map;for(const n of t){const t=this.getGroup(n);e.has(t)||e.set(t,[]),e.get(t).push(n)}return Array.from(e.entries()).map(([t,e])=>({key:t,data:e}))}resolveColorMap(t){const e=new Set;for(const n of t){const t=this.getColor(n);t&&e.add(t)}const n=Array.from(e).sort(),r=n.join("\0");if(this._colorMapCache&&this._colorMapCache.key===r)return this._colorMapCache.map;const o=Array.isArray(this.config.colorScheme)?this.config.colorScheme:wt,i=new Map;for(let t=0;n.length>t;t++)i.set(n[t],o[t%o.length]);return this._colorMapCache={key:r,map:i},i}resolveLineStyle(t,e){const n=this.config.lineStyle;if("function"==typeof n){const r=n(e||{},t);if(r&&!r.stroke&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},r),{stroke:e})}return r}return 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:this.resolveGroupColor(t)||"#007bff",strokeWidth:2}}resolveAreaStyle(t,e){var n;if(this.config.areaStyle){const n=this.config.areaStyle(e||{});if(n&&!n.fill&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},n),{fill:e,stroke:n.stroke||e})}return n}const r=this.config.lineStyle;if("function"==typeof r){const n=r(e||{},t);if(n&&!n.fill&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},n),{fill:e,stroke:n.stroke||e})}return n}if(r&&"object"==typeof r)return{fill:r.fill||r.stroke||"#4e79a7",fillOpacity:null!==(n=r.fillOpacity)&&void 0!==n?n:.7,stroke:r.stroke||"#4e79a7",strokeWidth:r.strokeWidth||2};const o=this.resolveGroupColor(t)||"#4e79a7";return{fill:o,fillOpacity:.7,stroke:o,strokeWidth:2}}resolveGroupColor(t){if(this._colorMapCache){const e=this._colorMapCache.map.get(t);if(e)return e}const e=this._groupColorMap.get(t);if(e)return e;const n=Array.isArray(this.config.colorScheme)?this.config.colorScheme:wt,r=n[this._groupColorMap.size%n.length];return this._groupColorMap.set(t,r),r}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}remove(t){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");const e=new Set(Array.isArray(t)?t:[t]),n=this.getPointId,r=t=>e.has(n(t));if(this.timestampBuffer&&this.timestampBuffer.size>0){const t=this.timestampBuffer.toArray(),e=new Set;this.buffer.forEach((t,n)=>{r(t)&&e.add(n)}),this.timestampBuffer.clear();for(let n=0;t.length>n;n++)e.has(n)||this.timestampBuffer.push(t[n])}const o=this.buffer.remove(r);if(0===o.length)return o;for(const t of o)this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):(this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t)));return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,o}update(t,e){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const n=new Set(Array.isArray(t)?t:[t]),r=this.getPointId,o=new Set;this.buffer.forEach((t,e)=>{n.has(r(t))&&o.add(e)});const i=this.buffer.update(t=>n.has(r(t)),e);if(0===i.length)return i;for(const t of i)this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):(this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t)));return this.buffer.forEach((t,e)=>{o.has(e)&&(this.xExtent.push(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(t)),this.yExtent.push(this.getLow(t))):(this.yExtent.push(this.getY(t)),this.getY0&&this.yExtent.push(this.getY0(t))))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,i}getBinBoundaries(){return this._binBoundaries}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.prevPathMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this.needsFullRebuild=!0,this._bufferDirty=!0,this._bufferArrayCache=null,this.lastLayout=null,this.scales=null,this.scene=[],this._quadtree=null,this._colorMapCache=null,this._groupColorMap=new Map,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this.version++}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}updateConfig(t){var e,n,r,o;const i=Object.assign({},this.config);void 0!==t.colorScheme&&(this._colorMapCache=null,this._groupColorMap=new Map),void 0===t.barColors&&void 0===t.colorScheme||(this._barCategoryCache=null),void 0===t.normalize&&void 0===t.extentPadding&&void 0===t.xAccessor&&void 0===t.yAccessor&&void 0===t.groupAccessor&&void 0===t.categoryAccessor&&void 0===t.chartType||(this._stackExtentCache=null);let l=!1;Object.assign(this.config,t);const a="chartType"in t&&t.chartType!==i.chartType||"runtimeMode"in t&&t.runtimeMode!==i.runtimeMode;if(a||void 0!==t.xAccessor||void 0!==t.yAccessor||void 0!==t.timeAccessor||void 0!==t.valueAccessor){const s=a||!vt(null!==(e=t.xAccessor)&&void 0!==e?e:t.timeAccessor,null!==(n=i.xAccessor)&&void 0!==n?n:i.timeAccessor),c=a||!vt(null!==(r=t.yAccessor)&&void 0!==r?r:t.valueAccessor,null!==(o=i.yAccessor)&&void 0!==o?o:i.valueAccessor);(s||c)&&(["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?(this.getX=mt(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=mt(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=mt(this.config.xAccessor,"x"),this.getY=mt(this.config.yAccessor,"y")),l=!0)}if("groupAccessor"in t&&!vt(t.groupAccessor,i.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?bt(this.config.groupAccessor):void 0,l=!0),"categoryAccessor"in t&&!vt(t.categoryAccessor,i.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?bt(this.config.categoryAccessor):void 0,l=!0),"sizeAccessor"in t&&!vt(t.sizeAccessor,i.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?mt(this.config.sizeAccessor,"size"):void 0,l=!0),"colorAccessor"in t&&!vt(t.colorAccessor,i.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?bt(this.config.colorAccessor):void 0,l=!0),"y0Accessor"in t&&!vt(t.y0Accessor,i.y0Accessor)&&(this.getY0=this.config.y0Accessor?mt(this.config.y0Accessor,"y0"):void 0,l=!0),"pointIdAccessor"in t&&!vt(t.pointIdAccessor,i.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?bt(this.config.pointIdAccessor):void 0,l=!0),"candlestick"===this.config.chartType&&("openAccessor"in t&&!vt(t.openAccessor,i.openAccessor)||"closeAccessor"in t&&!vt(t.closeAccessor,i.closeAccessor)||"highAccessor"in t&&!vt(t.highAccessor,i.highAccessor)||"lowAccessor"in t&&!vt(t.lowAccessor,i.lowAccessor))){const t=null!=this.config.openAccessor,e=null!=this.config.closeAccessor;this.getOpen=t?mt(this.config.openAccessor,"open"):void 0,this.getHigh=mt(this.config.highAccessor,"high"),this.getLow=mt(this.config.lowAccessor,"low"),this.getClose=e?mt(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!e,l=!0}if(!l){const e=Object.keys(t).filter(t=>!t.endsWith("Accessor")&&"timeAccessor"!==t&&"valueAccessor"!==t);for(const n of e)if(t[n]!==i[n]){l=!0;break}}l&&(this.needsFullRebuild=!0)}}function Bt(t,e,n){return n.x>t||t>n.x+n.w||n.y>e||e>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 jt(t,e=30){return Math.max((null!=t?t:4)+5,12,e)}function Ft(t){return t instanceof Date?t:"number"==typeof t&&t>1e9?new Date(t):null}function Rt(t,e){const n=Ft(t);if(!n)return!1;const r=Ft(e);return!r||n.getFullYear()!==r.getFullYear()||n.getMonth()!==r.getMonth()}function Yt(t){let e=t%(2*Math.PI);return 0>e&&(e+=2*Math.PI),e}function Ht(t,e,n,r=30,o){let i=null,l=!1;if(o){const t=o.find(e,n,r);if(t){const o=Gt(t,e,n,r);o&&r>o.distance&&(i=o,l=!0)}}for(const a of t){let t=null;switch(a.type){case"point":if(o&&l)break;t=Gt(a,e,n,r);break;case"line":t=Vt(a,e,n,r);break;case"rect":t=Ut(a,e,n);break;case"heatcell":t=Kt(a,e,n);break;case"area":if(!1===a.interactive)break;t=Qt(a,e,n);break;case"candlestick":t=Zt(a,e,n)}t&&r>t.distance&&(i&&t.distance>=i.distance||(i=t))}return i}function Xt(t,e,n){if(0===t.length)return null;const r=Jt(t,e);if(0>r)return null;if(Math.abs(t[r][0]-e)>n)return null;let o=r,i=r;r>0&&t[r][0]>=e?(o=r-1,i=r):t.length-1>r&&(o=r,i=r+1);const[l,a]=t[o],[s,c]=t[i];return s===l?a:a+Math.max(0,Math.min(1,(e-l)/(s-l)))*(c-a)}function Gt(t,e,n,r=30){const o=e-t.x,i=n-t.y,l=Math.sqrt(o*o+i*i);return l>jt(t.r,r)?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:l}}function Vt(t,e,n,r=30){var o,i,l,a;if(0===t.path.length)return null;const s=Jt(t.path,e);if(0>s)return null;const[c,u]=t.path[s];let d;if(t.path.length>1){let r=1/0;const o=Math.max(0,s-1),i=Math.min(t.path.length-2,s);for(let l=o;i>=l;l++){const[o,i]=t.path[l],[a,s]=t.path[l+1],c=qt(e,n,o,i,a,s);r>c&&(r=c)}d=r}else{const t=e-c,r=n-u;d=Math.sqrt(t*t+r*r)}const h=null!==(a=null!==(i=null===(o=t.style)||void 0===o?void 0:o.strokeWidth)&&void 0!==i?i:null===(l=t.style)||void 0===l?void 0:l.lineWidth)&&void 0!==a?a:1;return d>Math.max(5,h/2+2,r)?null:{node:t,datum:Array.isArray(t.datum)&&t.datum[s]?t.datum[s]:t.datum,x:c,y:u,distance:d}}function qt(t,e,n,r,o,i){const l=o-n,a=i-r,s=l*l+a*a;if(0===s)return Math.sqrt(Math.pow(t-n,2)+Math.pow(e-r,2));let c=((t-n)*l+(e-r)*a)/s;c=Math.max(0,Math.min(1,c));const u=r+c*a;return Math.sqrt(Math.pow(t-(n+c*l),2)+Math.pow(e-u,2))}function Ut(t,e,n){const r=Bt(e,n,t);return r.hit?{node:t,datum:t.datum,x:r.cx,y:r.cy,distance:0}:null}function Kt(t,e,n){const r=Bt(e,n,t);return r.hit?{node:t,datum:t.datum,x:r.cx,y:r.cy,distance:0}:null}function Zt(t,e,n){const r=t.bodyWidth/2,o=Math.min(t.openY,t.closeY);if(!(t.x-r-3>e||e>t.x+r+3||t.highY-3>n||n>t.lowY+3)){const r=o+Math.max(Math.max(t.openY,t.closeY)-o,1)/2,i=e-t.x,l=n-r;return{node:t,datum:t.datum,x:t.x,y:r,distance:Math.sqrt(i*i+l*l)}}return null}function Qt(t,e,n){if(0===t.topPath.length)return null;const r=Jt(t.topPath,e);if(0>r)return null;const[o,i]=t.topPath[r],l=e-o,a=n-i,s=Math.sqrt(l*l+a*a);return{node:t,datum:Array.isArray(t.datum)&&t.datum[r]?t.datum[r]:t.datum,x:o,y:i,distance:s}}function Jt(t,e){if(0===t.length)return-1;let n=0,r=t.length-1;for(;r>n;){const o=n+r>>1;e>t[o][0]?n=o+1:r=o}return n>0&&Math.abs(t[n][0]-e)>=Math.abs(t[n-1][0]-e)?n-1:n}function te(t){var e,n;const r=new Map;for(const n of t){const t=null!==(e=n.group)&&void 0!==e?e:"_default";let o=r.get(t);o||(o=[],r.set(t,o)),o.push(n)}for(const t of r.values()){t.sort((t,e)=>t.x-e.x||t.y-e.y);for(let e=0;t.length>e;e++)t[e]._groupIndex=e}const o=Array.from(r.keys()).sort((t,e)=>{const n=r.get(t),o=r.get(e);return(n.length>0?n[0].y:0)-(o.length>0?o[0].y:0)}),i=Array.from(r.values()).flat();i.sort((t,e)=>t.x-e.x||t.y-e.y);const l=new Map;for(let t=0;i.length>t;t++){i[t]._flatIndex=t;const e=null===(n=i[t].datum)||void 0===n?void 0:n.id;null!=e&&l.set(e+"",t)}return{flat:i,groups:o,byGroup:r,idToIdx:l}}function ee(t,e){var n,r;if(0===t.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const o=Math.max(0,Math.min(e,t.flat.length-1)),i=t.flat[o];return{flatIndex:o,group:null!==(n=i.group)&&void 0!==n?n:"_default",indexInGroup:null!==(r=i._groupIndex)&&void 0!==r?r:0}}function ne(t,e,n){const{group:r,indexInGroup:o}=e,i=n.byGroup.get(r);switch(t){case"ArrowRight":return i.length-1>o?i[o+1]._flatIndex:e.flatIndex;case"ArrowLeft":return o>0?i[o-1]._flatIndex:e.flatIndex;case"ArrowDown":{const t=n.groups.indexOf(r);return n.groups.length-1>t?re(n,n.groups[t+1],i[o]):e.flatIndex}case"ArrowUp":{const t=n.groups.indexOf(r);return t>0?re(n,n.groups[t-1],i[o]):e.flatIndex}case"PageDown":return Math.min(e.flatIndex+Math.max(1,Math.floor(.1*n.flat.length)),n.flat.length-1);case"PageUp":return Math.max(e.flatIndex-Math.max(1,Math.floor(.1*n.flat.length)),0);case"Home":return 0;case"End":return n.flat.length-1;case"Escape":return-1;default:return null}}function re(t,e,n){const r=t.byGroup.get(e);let o=0,i=Math.abs(r[0].x-n.x);for(let t=1;r.length>t;t++){const e=Math.abs(r[t].x-n.x);i>e&&(i=e,o=t)}return r[o]._flatIndex}function oe(t){const e=t.datum||{};return Object.assign(Object.assign({},"object"!=typeof e||null===e||Array.isArray(e)?{}:e),{data:e,x:t.x,y:t.y,time:t.x,value:t.y})}function ie(t,n,i){const l=e(null),[a,s]=o(null);return r(()=>{if(!n&&!i)return;const t=l.current;if(!t)return;const e=new ResizeObserver(t=>{for(const e of t){const{width:t,height:n}=e.contentRect;s(e=>e&&e.w===t&&e.h===n?e:{w:t,h:n})}});return e.observe(t),()=>e.disconnect()},[n,i]),[l,[n&&a?a.w:t[0],i&&a?a.h:t[1]]]}function le(t,e,n,o,i,l){r(()=>{if(!t)return;const r=setInterval(()=>{var r;const a=e.current;if(!a||0===a.lastIngestTime)return;const s="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(r=t.threshold)&&void 0!==r?r:5e3,u=s-a.lastIngestTime>c;u!==i&&(l(u),n.current=!0,o())},1e3);return()=>clearInterval(r)},[t,i,o])}zt.QUADTREE_THRESHOLD=500;const ae={fill:e=>t.createElement("rect",{style:e,width:16,height:16}),line:e=>t.createElement("line",{style:e,x1:0,y1:0,x2:16,y2:16})};function se(t,e,n,r){let o;return o="function"==typeof n?n(t):(0,ae[n])(r(t,e)),o}function ce(){return t.createElement("path",{d:"M4,8.8 L7.2,12 L12.8,4.8",fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function ue(t,e,n){return n&&n.size>0?n.has(t.label)?1:.3:null!=e?t.label===e?1:.3:1}function de({config:e,orientation:n="vertical",width:r=100}){const{colorFn:o,domain:i,label:l,format:a}=e,s=a||(t=>Math.round(100*t)/100+""),c="grad-legend-"+t.useId();if("horizontal"===n){const e=12,n=Math.min(r,200),a=Math.max(0,(r-n)/2),u=[];for(let e=0;64>=e;e++){const n=e/64;u.push(t.createElement("stop",{key:e,offset:100*n+"%",stopColor:o(i[0]+n*(i[1]-i[0]))}))}return t.createElement("g",{"aria-label":l||"Gradient legend"},t.createElement("defs",null,t.createElement("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"100%",y2:"0%"},u)),l&&t.createElement("text",{x:a+n/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},l),t.createElement("rect",{x:a,y:0,width:n,height:e,fill:`url(#${c})`,rx:2}),t.createElement("text",{x:a,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(i[0])),t.createElement("text",{x:a+n,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(i[1])))}const u=[];for(let e=0;64>=e;e++){const n=e/64;u.push(t.createElement("stop",{key:e,offset:100*n+"%",stopColor:o(i[1]-n*(i[1]-i[0]))}))}return t.createElement("g",{"aria-label":l||"Gradient legend"},l&&t.createElement("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},l),t.createElement("defs",null,t.createElement("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"0%",y2:"100%"},u)),t.createElement("rect",{x:0,y:0,width:14,height:100,fill:`url(#${c})`,rx:2}),t.createElement("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(i[1])),t.createElement("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(i[0])))}function he(e){const{legendGroups:n,customClickBehavior:r,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:l,legendInteraction:a,title:s="Legend",width:c=100,height:u=20,orientation:d="vertical"}=e,[h,f]=t.useState(0),[y,g]=t.useState(0),p=t.useCallback((t,e)=>{f(t),g(e)},[]),v="vertical"===d?(({legendGroups:e,width:n,customClickBehavior:r,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:l,focusedGroupIndex:a,focusedItemIndex:s,onFocusedIndexChange:c,legendInteraction:u})=>{let d=24;const h=[];return e.forEach((e,f)=>{d+=5,h.push(t.createElement("line",{key:"legend-top-line legend-symbol-"+f,stroke:"gray",x1:0,y1:d,x2:n,y2:d})),d+=8,e.label&&(d+=16,h.push(t.createElement("text",{key:"legend-text-"+f,y:d,className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label)),d+=8),h.push(t.createElement("g",{key:"legend-group-"+f,className:"legend-item",transform:`translate(0,${d})`},((e,n,r,o,i,l,a,s,c,u)=>{const{type:d="fill",styleFn:h,items:f}=e,y=[];let g=0;const p=!(!n&&!r),v="isolate"===u||void 0===u&&null!=i;return f.forEach((e,u)=>{const m=se(e,u,d,h),x=ue(e,o,i),b=i&&i.size>0&&i.has(e.label);y.push(t.createElement("g",{key:"legend-item-"+u,transform:`translate(0,${g})`,onClick:n?()=>n(e):void 0,onMouseEnter:r?()=>r(e):void 0,onMouseLeave:r?()=>r(null):void 0,tabIndex:p?s===l&&u===a?0:-1:void 0,role:p?"option":void 0,"aria-selected":p&&v?b||!1:void 0,"aria-current":p&&!v&&null!=o&&e.label===o||void 0,"aria-label":e.label,onKeyDown:p?t=>{var r;if("Enter"!==t.key&&" "!==t.key||(t.preventDefault(),n&&n(e)),"ArrowDown"===t.key||"ArrowUp"===t.key){t.preventDefault();const e=(u+("ArrowDown"===t.key?1:-1)+f.length)%f.length;c(s,e);const n=null===(r=t.currentTarget.parentElement)||void 0===r?void 0:r.children[e];n instanceof SVGElement&&n.focus()}}:void 0,onFocus:p?t=>{c(s,u),r&&r(e);const n=t.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:p?t=>{r&&r(null);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","hidden")}:void 0,style:{cursor:p?"pointer":"default",opacity:x,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},p&&t.createElement("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*e.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),m,b&&t.createElement(ce,null),t.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label))),g+=22}),y})(e,r,o,i,l,a,s,f,c,u))),d+=22*e.items.length+8}),h})({legendGroups:n||[],width:c,customClickBehavior:r,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:l,focusedGroupIndex:h,focusedItemIndex:y,onFocusedIndexChange:p,legendInteraction:a}):(({legendGroups:e,height:n,width:r,customClickBehavior:o,customHoverBehavior:i,highlightedCategory:l,isolatedCategories:a,focusedGroupIndex:s,focusedItemIndex:c,onFocusedIndexChange:u,legendInteraction:d})=>{let h=0;const f=[];e.forEach((e,n)=>{let y=0;e.label&&(y+=16);const g=((e,n,r,o,i,l,a,s,c,u,d)=>{const{type:h="fill",styleFn:f,items:y}=e,g=[];let p=0,v=0;const m=!(!n&&!r),x="isolate"===u||void 0===u&&null!=i;y.forEach((e,u)=>{const b=se(e,u,h,f),k=ue(e,o,i),w=i&&i.size>0&&i.has(e.label),E=26+7*e.label.length;d&&d>0&&p>0&&p+E>d&&(v++,p=0),g.push(t.createElement("g",{key:"legend-item-"+u,transform:`translate(${p},${22*v})`,onClick:n?()=>n(e):void 0,onMouseEnter:r?()=>r(e):void 0,onMouseLeave:r?()=>r(null):void 0,tabIndex:m?s===l&&u===a?0:-1:void 0,role:m?"option":void 0,"aria-selected":m&&x?w||!1:void 0,"aria-current":m&&!x&&null!=o&&e.label===o||void 0,"aria-label":e.label,onKeyDown:m?t=>{var r;if("Enter"!==t.key&&" "!==t.key||(t.preventDefault(),n&&n(e)),"ArrowRight"===t.key||"ArrowLeft"===t.key){t.preventDefault();const e=(u+("ArrowRight"===t.key?1:-1)+y.length)%y.length;c(s,e);const n=null===(r=t.currentTarget.parentElement)||void 0===r?void 0:r.children[e];n instanceof SVGElement&&n.focus()}}:void 0,onFocus:m?t=>{c(s,u),r&&r(e);const n=t.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:m?t=>{r&&r(null);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","hidden")}:void 0,style:{cursor:m?"pointer":"default",opacity:k,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},m&&t.createElement("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*e.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),b,w&&t.createElement(ce,null),t.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label))),p+=E});let b=0,k=0;for(const t of y){const e=26+7*t.label.length;d&&d>0&&k>0&&k+e>d?(b=Math.max(b,k),k=e):k+=e}b=Math.max(b,k);const w=v+1;return{items:g,offset:b,totalRows:w,totalHeight:22*w}})(e,o,i,l,a,s,c,n,u,d,r);y+=g.offset+5,f.push(Object.assign(Object.assign({label:e.label},g),{offset:y,totalRows:g.totalRows,totalHeight:g.totalHeight})),h+=y+12});let y=h>r?0:Math.max(0,(r-h)/2);const g=[];return f.forEach((r,o)=>{const i=e[o];i.label&&(g.push(t.createElement("text",{key:"legend-text-"+o,transform:`translate(${y},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},i.label)),y+=16),g.push(t.createElement("g",{key:"legend-group-"+o,className:"legend-item",transform:`translate(${y},0)`},r.items)),y+=r.offset+5,e[o+1]&&g.push(t.createElement("line",{key:"legend-top-line legend-symbol-"+o,stroke:"gray",x1:y,y1:-8,x2:y,y2:(r.totalHeight||n)+0+8})),y+=12}),t.createElement("g",null,g)})({legendGroups:n||[],title:s,height:u,width:c,customClickBehavior:r,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:l,focusedGroupIndex:h,focusedItemIndex:y,onFocusedIndexChange:p,legendInteraction:a}),m=!(!r&&!o);return t.createElement("g",{role:m?"listbox":void 0,"aria-multiselectable":!(!m||"isolate"!==a&&(void 0!==a||null==l))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"}},void 0!==s&&""!==s&&"vertical"===d&&t.createElement("text",{className:"legend-title",y:16,x:c/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)"},s),v)}function fe(e){const{legend:n,totalWidth:r,totalHeight:o,margin:i,legendPosition:l="right",title:a,legendHoverBehavior:s,legendClickBehavior:c,legendHighlightedCategory:u,legendIsolatedCategories:d,legendInteraction:h}=e;if(!n)return null;const f="top"===l||"bottom"===l;let y,g;return"left"===l?(y=4,g=i.top):"top"===l?(y=0,g=a?32:8):"bottom"===l?(y=0,g=o-i.bottom+50):(y=r-i.right+10,g=i.top),t.createElement("g",{transform:`translate(${y}, ${g})`},function(t){return"object"==typeof t&&null!==t&&"gradient"in t}(n)?t.createElement(de,{config:n.gradient,orientation:f?"horizontal":"vertical",width:f?r:100}):function(t){return"object"==typeof t&&null!==t&&"legendGroups"in t}(n)?t.createElement(he,{legendGroups:n.legendGroups,title:"",width:f?r:100,orientation:f?"horizontal":"vertical",customHoverBehavior:s,customClickBehavior:c,highlightedCategory:u,isolatedCategories:d,legendInteraction:h}):n)}function ye(t){return"string"==typeof t?{type:t}:t}function ge({orient:e,config:r,values:o,scale:i,size:l,length:a}){const s=function(t){var e,n,r,o,i;return{type:t.type,bins:null!==(e=t.bins)&&void 0!==e?e:20,fill:null!==(n=t.fill)&&void 0!==n?n:"#4e79a7",fillOpacity:null!==(r=t.fillOpacity)&&void 0!==r?r:.5,stroke:null!==(o=t.stroke)&&void 0!==o?o:"none",strokeWidth:null!==(i=t.strokeWidth)&&void 0!==i?i:1}}(r),c="top"===e||"bottom"===e,u=n(()=>{if(0===o.length)return null;const n=i.domain(),r=l-8;if("boxplot"===s.type){const n=function(t){const e=[...t].sort((t,e)=>t-e),n=e.length;if(0===n)return null;const r=e[Math.floor(.25*n)],o=e[Math.floor(.5*n)],i=e[Math.floor(.75*n)],l=i-r;return{q1:r,median:o,q3:i,whiskerLow:Math.max(e[0],r-1.5*l),whiskerHigh:Math.min(e[n-1],i+1.5*l)}}(o);if(!n)return null;const{q1:l,median:a,q3:u,whiskerLow:d,whiskerHigh:h}=n,f=Math.min(.5*r,20),y=(r-f)/2+4;if(c){const n=i(l),r=i(u),o=i(a),c=i(d),g=i(h),p="top"===e?-1:1,v=0;return t.createElement("g",{"data-testid":"marginal-boxplot-"+e},t.createElement("line",{x1:c,y1:v+p*(y+f/2),x2:g,y2:v+p*(y+f/2),stroke:s.fill,strokeWidth:s.strokeWidth}),t.createElement("line",{x1:c,y1:v+p*y,x2:c,y2:v+p*(y+f),stroke:s.fill,strokeWidth:s.strokeWidth}),t.createElement("line",{x1:g,y1:v+p*y,x2:g,y2:v+p*(y+f),stroke:s.fill,strokeWidth:s.strokeWidth}),t.createElement("rect",{x:Math.min(n,r),y:"top"===e?v-y-f:v+y,width:Math.abs(r-n),height:f,fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),t.createElement("line",{x1:o,y1:"top"===e?v-y-f:v+y,x2:o,y2:"top"===e?v-y:v+y+f,stroke:s.fill,strokeWidth:2}))}{const n=i(l),r=i(u),o=i(a),c=i(d),g=i(h),p="left"===e?-1:1,v=0;return t.createElement("g",{"data-testid":"marginal-boxplot-"+e},t.createElement("line",{x1:v+p*(y+f/2),y1:c,x2:v+p*(y+f/2),y2:g,stroke:s.fill,strokeWidth:s.strokeWidth}),t.createElement("line",{x1:v+p*y,y1:c,x2:v+p*(y+f),y2:c,stroke:s.fill,strokeWidth:s.strokeWidth}),t.createElement("line",{x1:v+p*y,y1:g,x2:v+p*(y+f),y2:g,stroke:s.fill,strokeWidth:s.strokeWidth}),t.createElement("rect",{x:"left"===e?v-y-f:v+y,y:Math.min(n,r),width:f,height:Math.abs(r-n),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),t.createElement("line",{x1:"left"===e?v-y-f:v+y,y1:o,x2:"left"===e?v-y:v+y+f,y2:o,stroke:s.fill,strokeWidth:2}))}}const u=M().domain(n).thresholds(s.bins)(o);if(0===u.length)return null;const d=Math.max(...u.map(t=>t.length));if(0===d)return null;if("histogram"===s.type)return t.createElement("g",{"data-testid":"marginal-histogram-"+e},u.map((n,o)=>{if(null==n.x0||null==n.x1)return null;const l=n.length/d*r;if(c){const r=i(n.x0),a=i(n.x1)-i(n.x0);return t.createElement("rect",{key:o,x:r,y:"top"===e?-4-l:4,width:Math.max(a,.5),height:l,fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth})}{const r=i(n.x0),a=i(n.x1)-i(n.x0);return t.createElement("rect",{key:o,x:"left"===e?-4-l:4,y:Math.min(r,r+a),width:l,height:Math.abs(a),fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth})}}));if("violin"===s.type){const n=r/2+4,o=[];for(const t of u){if(null==t.x0||null==t.x1)continue;const l=t.length/d*(r/2),a=i((t.x0+t.x1)/2);o.push(c?`${a},${"top"===e?-(n-l):n-l}`:`${"left"===e?-(n-l):n-l},${a}`)}for(let t=u.length-1;t>=0;t--){const l=u[t];if(null==l.x0||null==l.x1)continue;const a=l.length/d*(r/2),s=i((l.x0+l.x1)/2);o.push(c?`${s},${"top"===e?-(n+a):n+a}`:`${"left"===e?-(n+a):n+a},${s}`)}return t.createElement("g",{"data-testid":"marginal-violin-"+e},t.createElement("polygon",{points:o.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}))}if("ridgeline"===s.type){const n=[];if(c){const t=0,o=null!=u[0].x0?i(u[0].x0):0;n.push(`M${o},${t}`);for(const t of u){if(null==t.x0||null==t.x1)continue;const o=t.length/d*r,l=i((t.x0+t.x1)/2);n.push(`L${l},${"top"===e?-o-4:o+4}`)}const l=null!=u[u.length-1].x1?i(u[u.length-1].x1):a;n.push(`L${l},${t}`),n.push("Z")}else{const t=0,o=null!=u[0].x0?i(u[0].x0):0;n.push(`M${t},${o}`);for(const t of u){if(null==t.x0||null==t.x1)continue;const o=t.length/d*r,l=i((t.x0+t.x1)/2);n.push(`L${"left"===e?-o-4:o+4},${l}`)}const l=null!=u[u.length-1].x1?i(u[u.length-1].x1):a;n.push(`L${t},${l}`),n.push("Z")}return t.createElement("g",{"data-testid":"marginal-ridgeline-"+e},t.createElement("path",{d:n.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}))}return null},[o,i,s,l,a,e,c,4]);return u?t.createElement("g",{className:"marginal-"+e,"data-testid":"marginal-"+e},u):null}function pe(t,e=120,n=8){if(!t)return[];const r=Math.max(1,Math.floor(e/n)),o=t.split(/\s+/),i=[];let l="";for(const t of o)l&&l.length+1+t.length>r?(i.push(l),l=t):l=l?`${l} ${t}`:t;return l&&i.push(l),i}function ve(t,e,n,r){return"curly"===t?r?`M0,0 C${.6*n},0 ${.4*n},${e/2} ${n},${e/2} C${.4*n},${e/2} ${.6*n},${e} 0,${e}`:`M0,0 C0,${.6*n} ${e/2},${.4*n} ${e/2},${n} C${e/2},${.4*n} ${e},${.6*n} ${e},0`:r?`M0,0 L${n},0 L${n},${e} L0,${e}`:`M0,0 L0,${n} L${e},${n} L${e},0`}function me(e){const{x:n=0,y:r=0,dx:o,dy:i,nx:l,ny:a,note:s,connector:c,subject:u,type:d,color:h,className:f,disable:y,events:g={},"data-testid":p}=e,v=new Set(Array.isArray(y)?y:[]);let m=o||0,x=i||0;null!=l&&(m=l-n),null!=a&&(x=a-r);const b="string"==typeof d?d:"label";if("bracket"===b&&u&&0===m&&0===x)if(void 0!==u.width){m=u.width/2;const t=u.depth||30;x=t+(0>t?-5:5)}else if(void 0!==u.height){const t=u.depth||30;m=t+(0>t?-5:5),x=u.height/2}return t.createElement("g",Object.assign({className:("annotation "+(f||"")).trim(),transform:`translate(${n},${r})`,"data-testid":p},g),!v.has("connector")&&function(e,n,r,o,i,l){const a=[];let s=0,c=0;if("callout-circle"!==i&&"label"!==i||!(null==l?void 0:l.radius)){if("callout-rect"===i&&l){const t=l.width||0,r=l.height||0;if(t>0||r>0){const o=t/2,i=r/2,l=e-o,a=n-i;if(0!==l||0!==a){const e=Math.abs(l),n=Math.abs(a),u=t/2,d=r/2,h=e*d>n*u?u/e:d/n;s=o+l*h,c=i+a*h}}}else if("bracket"===i&&l){const t=l.width,e=l.height,n=l.depth||30;void 0!==t?(s=t/2,c=n):void 0!==e&&(s=n,c=e/2)}}else{const t=(l.radius||0)+(l.radiusPadding||0);if(t>0&&(0!==e||0!==n)){const r=Math.atan2(n,e);s=Math.cos(r)*t,c=Math.sin(r)*t}}if(Math.sqrt(Math.pow(e-s,2)+Math.pow(n-c,2))>.5&&(a.push(t.createElement("line",{key:"connector-line",x1:s,y1:c,x2:e,y2:n,stroke:o||"var(--semiotic-text-secondary, currentColor)"})),"arrow"===(null==r?void 0:r.end))){const r=10,i=16/180*Math.PI,l=Math.atan2(n-c,e-s);a.push(t.createElement("path",{key:"connector-arrow",d:`M${s},${c}L${s+r*Math.cos(l+i)},${c+r*Math.sin(l+i)}L${s+r*Math.cos(l-i)},${c+r*Math.sin(l-i)}Z`,fill:o||"var(--semiotic-text-secondary, currentColor)",stroke:"none"}))}return t.createElement("g",{className:"annotation-connector"},a)}(m,x,c,h,b,u),!v.has("subject")&&function(e,n,r,o,i){var l;const a=[];switch(e){case"callout-circle":{const e=((null==n?void 0:n.radius)||0)+((null==n?void 0:n.radiusPadding)||0);e>0&&a.push(t.createElement("circle",{key:"subject-circle",r:e,fill:"none",stroke:r||"var(--semiotic-text-secondary, currentColor)"}));break}case"callout-rect":{const e=(null==n?void 0:n.width)||0,o=(null==n?void 0:n.height)||0;(e>0||o>0)&&a.push(t.createElement("rect",{key:"subject-rect",width:e,height:o,fill:"none",stroke:r||"var(--semiotic-text-secondary, currentColor)"}));break}case"callout-custom":(null==n?void 0:n.custom)&&a.push(...Array.isArray(n.custom)?n.custom:[n.custom]);break;case"xy-threshold":{const e=o||0,l=i||0;if(void 0!==(null==n?void 0:n.x)){const o=(n.x||0)-e;a.push(t.createElement("line",{key:"threshold-line",x1:o,y1:(n.y1||0)-l,x2:o,y2:(n.y2||0)-l,stroke:r||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"}))}else if(void 0!==(null==n?void 0:n.y)){const o=(n.y||0)-l;a.push(t.createElement("line",{key:"threshold-line",x1:(n.x1||0)-e,y1:o,x2:(n.x2||0)-e,y2:o,stroke:r||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"}))}else void 0!==(null==n?void 0:n.x1)||void 0!==(null==n?void 0:n.x2)?a.push(t.createElement("line",{key:"threshold-line",x1:(n.x1||0)-e,y1:0,x2:(n.x2||0)-e,y2:0,stroke:r||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"})):void 0===(null==n?void 0:n.y1)&&void 0===(null==n?void 0:n.y2)||a.push(t.createElement("line",{key:"threshold-line",x1:0,y1:(n.y1||0)-l,x2:0,y2:(n.y2||0)-l,stroke:r||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"}));break}case"bracket":{const e=null!==(l=null==n?void 0:n.width)&&void 0!==l?l:null==n?void 0:n.height;void 0!==e&&a.push(t.createElement("path",{key:"bracket-path",d:ve((null==n?void 0:n.type)||"curly",e,(null==n?void 0:n.depth)||30,void 0===(null==n?void 0:n.width)),fill:"none",stroke:r||"var(--semiotic-text-secondary, currentColor)"}));break}}return t.createElement("g",{className:"annotation-subject"},a)}(b,u,h,n,r),!v.has("note")&&function(e,n,r,o){if(!e)return t.createElement("g",{className:"annotation-note"});const{label:i,title:l,orientation:a,align:s,wrap:c=120,noWrap:u}=e;if(!i&&!l)return t.createElement("g",{className:"annotation-note"});let d=a;d||(d=Math.abs(n)>Math.abs(r)?"leftRight":"topBottom");let h=s;h&&"dynamic"!==h||(h="topBottom"===d?0>n?"right":"left":0>r?"bottom":"top");let f="start";"topBottom"===d?"right"===h?f="end":"middle"===h&&(f="middle"):f=0>n?"end":"start";const y=16,g=l?u?[l]:pe(l,c):[],p=i?u?[i]:pe(i,c):[],v="leftRight"===d?"end"===f?-4:4:0;let m=0;const x=[],b=o||"var(--semiotic-text, #333)";g.length>0&&(x.push(t.createElement("text",{key:"annotation-note-title",className:"annotation-note-title",fill:b,textAnchor:f,fontWeight:"bold"},g.map((e,n)=>t.createElement("tspan",{key:n,x:v,dy:0===n?0:y},e)))),m=g.length*y),p.length>0&&x.push(t.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:b,textAnchor:f,y:m},p.map((e,n)=>t.createElement("tspan",{key:n,x:v,dy:0===n?0:y},e))));let k=null;if((l||i)&&(0!==n||0!==r))if("topBottom"===d){const e=Math.min(c,120);let n=0,r=e;"end"===f?(n=-e,r=0):"middle"===f&&(n=-e/2,r=e/2),k=t.createElement("line",{className:"note-line",x1:n,x2:r,y1:0,y2:0,stroke:o||"var(--semiotic-text-secondary, currentColor)"})}else{const e=(g.length+p.length)*y+(p.length>0?y:0);let n=0,r=e;"bottom"===h?(n=-e,r=0):"middle"===h&&(n=-e/2,r=e/2),k=t.createElement("line",{className:"note-line",x1:0,x2:0,y1:n,y2:r,stroke:o||"var(--semiotic-text-secondary, currentColor)"})}const w=Math.max(0,g.length+p.length-1)*y;let E=0;return"topBottom"===d?E=0>r?-(w+2):18:"leftRight"===d&&(E="middle"===h?-(w+y+(p.length>0&&g.length>0?2:0))/2+8:"bottom"===h||0>r?-(w+2):18),t.createElement("g",{className:"annotation-note",transform:`translate(${n},${r})`},t.createElement("g",{className:"annotation-note-content",transform:0!==E?`translate(0,${E})`:void 0},x),k)}(s,m,x,h))}function xe(e){var n,r;const{noteData:o}=e,{screenCoordinates:i}=o,l="string"==typeof o.type?o.type:"label",a=o.eventListeners||o.events||{};if(o.coordinates&&i){const e=o.nx||i[0][0]+(null!==(n=o.dx)&&void 0!==n?n:0),a=o.ny||i[0][1]+(null!==(r=o.dy)&&void 0!==r?r:0),s=i.map((n,r)=>{const i=Object.assign({},o,{note:0===r?o.note:{label:""},x:n[0],y:n[1],nx:e,ny:a});return t.createElement(me,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+r},i,{type:l}))});return t.createElement("g",null,s)}const s=o.note||{title:"none",label:o.label};return t.createElement(me,Object.assign({"data-testid":"semiotic-annotation",key:`${s.label}-${s.title}-${o.i}`,events:a},o,{type:l}))}function be(t,e){var n,r,o;const i=null!==(r=null===(n=e.scales)||void 0===n?void 0:n.x)&&void 0!==r?r:null===(o=e.scales)||void 0===o?void 0:o.time;return i?null!=t.x?i(t.x):e.xAccessor&&null!=t[e.xAccessor]?i(t[e.xAccessor]):null:null}function ke(t,e){var n,r,o;const i=null!==(r=null===(n=e.scales)||void 0===n?void 0:n.y)&&void 0!==r?r:null===(o=e.scales)||void 0===o?void 0:o.value;return i?null!=t.y?i(t.y):e.yAccessor&&null!=t[e.yAccessor]?i(t[e.yAccessor]):null:null}function we(t,e,n){var r,o,i,l;const a=t.anchor||"fixed";if("latest"===a){if(null!=t.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let o=n.pointNodes.length-1;o>=0;o--){const i=n.pointNodes[o];if(i.pointId===t.pointId){const t={x:i.x,y:i.y};return null===(r=n.stickyPositionCache)||void 0===r||r.set(e,t),t}}const i=function(t){var e,n,r,o,i,l;const a=t.data;if(!a||0===a.length)return null;const s=a[a.length-1],c=null!==(n=null===(e=t.scales)||void 0===e?void 0:e.x)&&void 0!==n?n:null===(r=t.scales)||void 0===r?void 0:r.time,u=null!==(i=null===(o=t.scales)||void 0===o?void 0:o.y)&&void 0!==i?i:null===(l=t.scales)||void 0===l?void 0:l.value;if(!c||!u)return null;const d=s[t.xAccessor||"x"],h=s[t.yAccessor||"y"];return null==d||null==h?null:{x:c(d),y:u(h)}}(n);return i&&(null===(o=n.stickyPositionCache)||void 0===o||o.set(e,i)),i}let s=null,c=null;if(null!=t.pointId&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===t.pointId);e&&(s=e.x,c=e.y)}if(null!=s&&null!=c||(s=be(t,n),c=ke(t,n)),null!=s&&null!=c)return null===(i=n.stickyPositionCache)||void 0===i||i.set(e,{x:s,y:c}),{x:s,y:c};if("sticky"===a){const t=null===(l=n.stickyPositionCache)||void 0===l?void 0:l.get(e);if(t)return t}return null}function Ee(t,e,n,r=50){return!(-r>t||t>(n.width||0)+r||-r>e||e>(n.height||0)+r)}const Ae={linear:U,monotoneX:q,monotoneY:V,step:G,stepAfter:X,stepBefore:H,basis:Y,cardinal:R,catmullRom:F};let Me={positions:new Map};const Se=new Set;function Pe(){for(const t of Se)t()}function _e(t,e){const n=Me.positions.get(t);if(null==n?void 0:n.locked)return;if(!n||n.sourceId!==e)return;const r=new Map(Me.positions);r.delete(t),Me={positions:r},Pe()}function De(t,e){const n=Me.positions.get(t);if(!(null==n?void 0:n.locked))return;if(e&&n.sourceId!==e)return;const r=new Map(Me.positions);r.delete(t),Me={positions:r},Pe()}function Te(){return Me}function Le(t){return Se.add(t),()=>Se.delete(t)}const Ce={positions:new Map};function Ne(){return()=>{}}function $e(){return Ce}function Oe(t){if(t)return"dashed"===t?"6,4":"dotted"===t?"2,4":t}function Ie(t,e,n){if("left"===t||"right"===t){const r="left"===t?n:0,o="left"===t?-1:1,i=Math.ceil(e/8);let l="M0,"+r;for(let t=0;i>t;t++){const n=8*(t+1);l+=`L${Math.min(8*t+4,e)},${r+4*o}`,l+=`L${Math.min(n,e)},${r}`}return l}{const r="bottom"===t?0:e,o="bottom"===t?1:-1,i=Math.ceil(n/8);let l=`M${r},0`;for(let t=0;i>t;t++){const e=8*(t+1);l+=`L${r+4*o},${Math.min(8*t+4,n)}`,l+=`L${r},${Math.min(e,n)}`}return l}}function We(e){const{width:r,height:o,totalWidth:i,totalHeight:l,margin:a,scales:s,showAxes:c,axes:u,showGrid:d,xFormat:h,yFormat:f}=e,y=n(()=>{var t;if(!s)return[];const e=null==u?void 0:u.find(t=>"bottom"===t.orient),n=(null==e?void 0:e.tickFormat)||h||ze,o=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5,i=s.x.ticks(Math.min(o,Math.max(2,Math.floor(r/70)))),l=i.map(t=>t.valueOf()),a=i.map((t,e)=>({value:t,pixel:s.x(t),label:n(t,e,l)})),c=a.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:"number"==typeof e.label?6.5*(e.label+"").length:60),0);return Be(a,Math.max(55,c+8))},[s,u,h,r]),g=n(()=>{var t;if(!s)return[];const e=null==u?void 0:u.find(t=>"left"===t.orient),n=(null==e?void 0:e.tickFormat)||f||ze,r=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5;return Be(s.y.ticks(Math.min(r,Math.max(2,Math.floor(o/30)))).map(t=>({value:t,pixel:s.y(t),label:n(t)})),22)},[s,u,f,o]),p=d&&s,v=c&&s;if(!p&&!v)return null;const m=null==u?void 0:u.find(t=>"bottom"===t.orient),x=null==u?void 0:u.find(t=>"left"===t.orient),b=v&&(!m||!1!==m.baseline),k=v&&(!x||!1!==x.baseline),w=(null==m?void 0:m.jaggedBase)||!1,E=(null==x?void 0:x.jaggedBase)||!1,A="var(--semiotic-border, #ccc)";return t.createElement("svg",{width:i,height:l,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},t.createElement("g",{transform:`translate(${a.left},${a.top})`},p&&(()=>{var e,n;const i=Oe(null===(e=null==u?void 0:u.find(t=>"bottom"===t.orient))||void 0===e?void 0:e.gridStyle),l=Oe(null===(n=null==u?void 0:u.find(t=>"left"===t.orient))||void 0===n?void 0:n.gridStyle);return t.createElement("g",{className:"stream-grid"},y.map((e,n)=>t.createElement("line",{key:"xgrid-"+n,x1:e.pixel,y1:0,x2:e.pixel,y2:o,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:i})),g.map((e,n)=>t.createElement("line",{key:"ygrid-"+n,x1:0,y1:e.pixel,x2:r,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:l})))})(),b&&!w&&t.createElement("line",{x1:0,y1:o,x2:r,y2:o,stroke:A,strokeWidth:1}),w&&t.createElement("path",{d:Ie("bottom",r,o),fill:"none",stroke:A,strokeWidth:1}),k&&!E&&t.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:A,strokeWidth:1}),E&&t.createElement("path",{d:Ie("left",r,o),fill:"none",stroke:A,strokeWidth:1})))}function ze(t,e,n){return t instanceof Date?`${t.toLocaleString("en",{month:"short"})} ${t.getDate()}`:"number"==typeof t?Math.round(100*t)/100+"":t+""}function Be(t,e){if(2>=t.length)return t;const n=[t[0]];for(let r=1;t.length-1>r;r++)e>Math.abs(t[r].pixel-n[n.length-1].pixel)||n.push(t[r]);const r=t[t.length-1];return e>Math.abs(r.pixel-n[n.length-1].pixel)?n[n.length-1]=r:n.push(r),n}function je(o){var l,a;const{width:s,height:c,totalWidth:u,totalHeight:d,margin:h,scales:f,showAxes:y,axes:g,xLabel:p,yLabel:v,yLabelRight:m,xFormat:x,yFormat:b,showGrid:k,title:w,legend:E,legendHoverBehavior:A,legendClickBehavior:M,legendHighlightedCategory:S,legendIsolatedCategories:P,legendPosition:_="right",foregroundGraphics:D,marginalGraphics:T,xValues:L,yValues:N,annotations:$,svgAnnotationRules:O,xAccessor:I,yAccessor:W,annotationData:z,pointNodes:B,curve:F,underlayRendered:R,linkedCrosshairName:Y,linkedCrosshairSourceId:H,children:X}=o,G=n(()=>{var t;if(!y||!f)return[];const e=null==g?void 0:g.find(t=>"bottom"===t.orient),n=(null==e?void 0:e.tickFormat)||x||ze,r=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5,o=f.x.ticks(Math.min(r,Math.max(2,Math.floor(s/70)))),i=o.map(t=>t.valueOf()),l=o.map((t,e)=>({value:t,pixel:f.x(t),label:n(t,e,i)})),a=l.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:"number"==typeof e.label?6.5*(e.label+"").length:60),0),c=(null==e?void 0:e.autoRotate)?Math.max(20,Math.min(a+8,55)):Math.max(55,a+8);let u=Be(l,c);if(u.length>1&&(u=u.filter((t,e)=>0===e||t.label+""!=u[e-1].label+"")),(null==e?void 0:e.includeMax)&&u.length>0){const t=f.x.domain()[1],e=f.x(t),r=u[u.length-1].pixel;if(Math.abs(e-r)>1){const o=n(t,u.length,i);c>e-r&&u.length>1&&(u=u.slice(0,-1)),u.push({value:t,pixel:e,label:o})}}return u},[y,f,g,x,s]),V=n(()=>{var t;if(!y||!f)return[];const e=null==g?void 0:g.find(t=>"left"===t.orient),n=(null==e?void 0:e.tickFormat)||b||ze,r=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5;let o=Be(f.y.ticks(Math.min(r,Math.max(2,Math.floor(c/30)))).map(t=>({value:t,pixel:f.y(t),label:n(t)})),22);if(o.length>1&&(o=o.filter((t,e)=>0===e||t.label+""!=o[e-1].label+"")),(null==e?void 0:e.includeMax)&&o.length>0){const t=f.y.domain()[1],e=f.y(t),r=o[o.length-1].pixel;if(Math.abs(e-r)>1){const i=n(t);22>Math.abs(e-r)&&o.length>1&&(o=o.slice(0,-1)),o.push({value:t,pixel:e,label:i})}}return o},[y,f,g,b,c]),q=n(()=>{var t;if(!y||!f)return[];const e=null==g?void 0:g.find(t=>"right"===t.orient);if(!e)return[];const n=e.tickFormat||b||ze,r=null!==(t=e.ticks)&&void 0!==t?t:5;return Be(f.y.ticks(Math.min(r,Math.max(2,Math.floor(c/30)))).map(t=>({value:t,pixel:f.y(t),label:n(t)})),22)},[y,f,g,b,c]),K=e(new Map),Z=e(null!==(l=null==$?void 0:$.length)&&void 0!==l?l:0),Q=null!==(a=null==$?void 0:$.length)&&void 0!==a?a:0;Z.current!==Q&&(Z.current=Q,K.current=new Map);const J=n(()=>{if(!$||0===$.length)return null;const e=function(e,n,r){var o,i,l,a,s,c,u,d,h,f,y,g,p,v,m,x,b,k,w,E,A,M,S,P,_,D,T,L,N,$,O,I,W,z,B,F,R,Y,H,X,G,V,q,K,Z,Q,J,et;switch(e.type){case"label":{const o=we(e,n,r);if(!o)return null;const{x:i,y:l}=o;return Ee(i,l,r)?t.createElement(xe,{key:"ann-"+n,noteData:{x:i,y:l,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":{const o=we(e,n,r);if(!o)return null;const{x:i,y:l}=o;return Ee(i,l,r)?t.createElement(xe,{key:"ann-"+n,noteData:{x:i,y:l,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=be(e,r);if(null==o)return null;const i=e.color||"#f97316",l=e.labelPosition||"top";let a;return a="bottom"===l?(r.height||0)-4:"center"===l?(r.height||0)/2:12,t.createElement("g",{key:"ann-"+n},t.createElement("line",{x1:o,y1:0,x2:o,y2:r.height||0,stroke:i,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&t.createElement("text",{x:o+4,y:a,fill:i,fontSize:12,fontWeight:"bold"},e.label))}case"y-threshold":{const o=ke(e,r);if(null==o)return null;const i=e.color||"#f97316",l=e.labelPosition||"right";let a,s;return"left"===l?(a=4,s="start"):"center"===l?(a=(r.width||0)/2,s="middle"):(a=(r.width||0)-4,s="end"),t.createElement("g",{key:"ann-"+n},t.createElement("line",{x1:0,y1:o,x2:r.width||0,y2:o,stroke:i,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&t.createElement("text",{x:a,y:o-4,textAnchor:s,fill:i,fontSize:12,fontWeight:"bold"},e.label))}case"enclose":{const o=(e.coordinates||[]).map(t=>({x:be(Object.assign(Object.assign({},t),{type:"point"}),r),y:ke(Object.assign(Object.assign({},t),{type:"point"}),r),r:1})).filter(t=>null!=t.x&&null!=t.y);if(2>o.length)return null;const i=C(o),l=e.padding||10;return t.createElement("g",{key:"ann-"+n},t.createElement("circle",{cx:i.x,cy:i.y,r:i.r+l,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&t.createElement("text",{x:i.x,y:i.y-i.r-l-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12},e.label))}case"rect-enclose":{const o=(e.coordinates||[]).map(t=>({x:be(Object.assign(Object.assign({},t),{type:"point"}),r),y:ke(Object.assign(Object.assign({},t),{type:"point"}),r)})).filter(t=>null!=t.x&&null!=t.y);if(2>o.length)return null;const i=e.padding||10,l=o.map(t=>t.x),a=o.map(t=>t.y),s=Math.min(...l)-i,c=Math.max(...l)+i,u=Math.min(...a)-i,d=Math.max(...a)+i;return t.createElement("g",{key:"ann-"+n},t.createElement("rect",{x:s,y:u,width:c-s,height:d-u,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&t.createElement("text",{x:(s+c)/2,y:u-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12},e.label))}case"highlight":{const o=r.data||[],i="function"==typeof e.filter?o.filter(e.filter):e.field&&null!=e.value?o.filter(t=>t[e.field]===e.value):[],l={stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return t.createElement("g",{key:"ann-"+n},i.map((n,o)=>{const i=be(n,r),a=ke(n,r);if(null==i||null==a)return null;const s="function"==typeof e.r?e.r(n):e.r||6,c="function"==typeof e.style?e.style(n):e.style||l;return t.createElement("circle",Object.assign({key:"hl-"+o,cx:i,cy:a,r:s},c))}))}case"bracket":{const o=be(e,r),i=ke(e,r);return t.createElement(xe,{key:"ann-"+n,noteData:{x:null!=o?o:0,y:null!=i?i: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 d=r.data||[];if(2>d.length)return null;const h=r.xAccessor||"x",f=r.yAccessor||"y",y=d.map(t=>[t[h],t[f]]).filter(t=>null!=t[0]&&null!=t[1]);if(2>y.length)return null;const g=null!==(i=null===(o=r.scales)||void 0===o?void 0:o.x)&&void 0!==i?i:null===(l=r.scales)||void 0===l?void 0:l.time,p=null!==(s=null===(a=r.scales)||void 0===a?void 0:a.y)&&void 0!==s?s:null===(c=r.scales)||void 0===c?void 0:c.value;if(!g||!p)return null;const v=e.method||"linear";let m;m="loess"===v?function(t,e=.3){const n=t.length;if(2>n)return t.slice();const r=t.slice().sort((t,e)=>t[0]-e[0]),o=r.map(t=>t[0]),i=r.map(t=>t[1]),l=Math.max(2,Math.ceil(e*n)),a=[];for(let t=0;n>t;t++){const e=o[t],r=o.map(t=>Math.abs(t-e)),s=r.slice().sort((t,e)=>t-e)[Math.min(l-1,n-1)]||1,c=[];for(let t=0;n>t;t++){const e=0===s?0:r[t]/s;c[t]=1>e?Math.pow(1-Math.pow(e,3),3):0}let u=0,d=0,h=0,f=0,y=0;for(let t=0;n>t;t++){const e=c[t];0!==e&&(u+=e,d+=e*o[t],h+=e*i[t],f+=e*o[t]*o[t],y+=e*o[t]*i[t])}if(0===u){a.push([e,i[t]]);continue}const g=u*f-d*d;if(1e-12>Math.abs(g))a.push([e,h/u]);else{const t=(u*y-d*h)/g;a.push([e,(h-t*d)/u+t*e])}}return a}(y,null!==(u=e.bandwidth)&&void 0!==u?u:.3):("polynomial"===v?tt.polynomial(y,{order:e.order||2}):tt.linear(y)).points;const x=m.map(([t,e])=>`${g(t)},${p(e)}`).join(" "),b=e.color||"#6366f1";return t.createElement("g",{key:"ann-"+n},t.createElement("polyline",{points:x,fill:"none",stroke:b,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&t.createElement("text",{x:g(m[m.length-1][0])+4,y:p(m[m.length-1][1])-4,fill:b,fontSize:11},e.label))}case"band":{const o=null!==(h=null===(d=r.scales)||void 0===d?void 0:d.y)&&void 0!==h?h:null===(f=r.scales)||void 0===f?void 0:f.value,i=null!==(y=null==o?void 0:o(e.y0))&&void 0!==y?y:0,l=null!==(g=null==o?void 0:o(e.y1))&&void 0!==g?g:r.height||0;return t.createElement("g",{key:"ann-"+n},t.createElement("rect",{x:0,y:Math.min(i,l),width:r.width||0,height:Math.abs(l-i),fill:e.fill||"var(--semiotic-primary, #6366f1)",fillOpacity:e.fillOpacity||.1}),e.label&&t.createElement("text",{x:(r.width||0)-4,y:Math.min(i,l)-4,textAnchor:"end",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11},e.label))}case"envelope":{const o=r.data||[];if(2>o.length)return null;const i=r.xAccessor||"x",l=null!==(v=null===(p=r.scales)||void 0===p?void 0:p.x)&&void 0!==v?v:null===(m=r.scales)||void 0===m?void 0:m.time,a=null!==(b=null===(x=r.scales)||void 0===x?void 0:x.y)&&void 0!==b?b:null===(k=r.scales)||void 0===k?void 0:k.value;if(!l||!a)return null;const s=e.upperAccessor||"upperBounds",c=e.lowerAccessor||"lowerBounds",u=e.filter,d=o.filter(t=>null!=t[s]&&null!=t[c]&&!(u&&!u(t))).sort((t,e)=>t[i]-e[i]);if(2>d.length)return null;const h=Ae[r.curve||"linear"]||U,f=j().x(t=>l(t[i])).y0(t=>a(t[c])).y1(t=>a(t[s])).curve(h)(d);if(!f)return null;const y=e.fill||"#6366f1";return t.createElement("g",{key:"ann-"+n},t.createElement("path",{d:f,fill:y,fillOpacity:null!==(w=e.fillOpacity)&&void 0!==w?w:.15,stroke:"none"}),e.label&&d.length>0&&t.createElement("text",{x:l(d[d.length-1][i])+4,y:a(d[d.length-1][s])-4,fill:y,fontSize:11},e.label))}case"anomaly-band":{const o=r.data||[];if(2>o.length)return null;const i=r.yAccessor||"y",l=null!==(A=null===(E=r.scales)||void 0===E?void 0:E.x)&&void 0!==A?A:null===(M=r.scales)||void 0===M?void 0:M.time,a=null!==(P=null===(S=r.scales)||void 0===S?void 0:S.y)&&void 0!==P?P:null===(_=r.scales)||void 0===_?void 0:_.value;if(!l||!a)return null;const s=o.map(t=>t[i]).filter(t=>null!=t&&isFinite(t));if(2>s.length)return null;const c=s.reduce((t,e)=>t+e,0)/s.length,u=s.reduce((t,e)=>t+Math.pow(e-c,2),0)/s.length,d=Math.sqrt(u),h=null!==(D=e.threshold)&&void 0!==D?D:2,f=c-h*d,y=!1!==e.showBand,g=e.fill||"#6366f1",p=null!==(T=e.fillOpacity)&&void 0!==T?T:.1,v=e.anomalyColor||"#ef4444",m=null!==(L=e.anomalyRadius)&&void 0!==L?L:6,x=a(c+h*d),b=a(f),k=o.filter(t=>{const e=t[i];return null!=e&&Math.abs(e-c)>h*d});return t.createElement("g",{key:"ann-"+n},y&&t.createElement("rect",{x:0,y:Math.min(x,b),width:r.width||0,height:Math.abs(b-x),fill:g,fillOpacity:p}),k.map((e,n)=>{const o=be(e,r),i=ke(e,r);return null==o||null==i?null:t.createElement("circle",{key:"anomaly-"+n,cx:o,cy:i,r:m,fill:v,fillOpacity:.7,stroke:v,strokeWidth:1.5})}),e.label&&t.createElement("text",{x:(r.width||0)-4,y:Math.min(x,b)-4,textAnchor:"end",fill:g,fontSize:11},e.label))}case"forecast":{const o=r.data||[];if(3>o.length)return null;const i=r.xAccessor||"x",l=r.yAccessor||"y",a=null!==($=null===(N=r.scales)||void 0===N?void 0:N.x)&&void 0!==$?$:null===(O=r.scales)||void 0===O?void 0:O.time,s=null!==(W=null===(I=r.scales)||void 0===I?void 0:I.y)&&void 0!==W?W:null===(z=r.scales)||void 0===z?void 0:z.value;if(!a||!s)return null;const c=o.map(t=>[t[i],t[l]]).filter(t=>null!=t[0]&&null!=t[1]&&isFinite(t[0])&&isFinite(t[1])).sort((t,e)=>t[0]-e[0]);if(3>c.length)return null;let u;if("polynomial"===(e.method||"linear")){const t=tt.polynomial(c,{order:e.order||2}).equation;u=e=>t.reduce((t,n,r)=>t+n*Math.pow(e,r),0)}else{const t=c.length;let e=0,n=0,r=0,o=0;for(const[t,i]of c)e+=t,n+=i,r+=t*t,o+=t*i;const i=t*r-e*e;if(1e-12>Math.abs(i))return null;const l=(t*o-e*n)/i,a=(n-l*e)/t;u=t=>a+l*t}const d=c.length,h=c.map(([t,e])=>e-u(t)).reduce((t,e)=>t+e*e,0),f=Math.sqrt(h/Math.max(d-2,1)),y=c.reduce((t,e)=>t+e[0],0)/d,g=c.reduce((t,e)=>t+Math.pow(e[0]-y,2),0),p=null!==(B=e.confidence)&&void 0!==B?B:.95,v=.99>p?.95>p?.9>p?1:1.645:1.96:2.576,m=null!==(F=e.steps)&&void 0!==F?F:5,x=c[d-1][0],b=(x-c[0][0])/Math.max(d-1,1),k=[];for(let t=1;m>=t;t++)k.push(x+t*b);const w=[];for(const t of k){const e=u(t),n=f*Math.sqrt(1+1/d+(g>0?Math.pow(t-y,2)/g:0))*v;w.push({x:t,yCenter:e,yUpper:e+n,yLower:e-n})}const E=`M${w.map(t=>`${a(t.x)},${s(t.yUpper)}`).join(" L")} L${w.slice().reverse().map(t=>`${a(t.x)},${s(t.yLower)}`).join(" L")} Z`,A=w.map(t=>`${a(t.x)},${s(t.yCenter)}`).join(" "),M=`${a(x)},${s(u(x))}`,S=e.strokeColor||"#6366f1";return t.createElement("g",{key:"ann-"+n},t.createElement("path",{d:E,fill:e.fill||"#6366f1",fillOpacity:null!==(R=e.fillOpacity)&&void 0!==R?R:.15,stroke:"none"}),t.createElement("polyline",{points:`${M} ${A}`,fill:"none",stroke:S,strokeWidth:null!==(Y=e.strokeWidth)&&void 0!==Y?Y:2,strokeDasharray:null!==(H=e.strokeDasharray)&&void 0!==H?H:"6,3"}),e.label&&w.length>0&&t.createElement("text",{x:a(w[w.length-1].x)+4,y:s(w[w.length-1].yCenter)-4,fill:S,fontSize:11},e.label))}case"widget":{let o=null,i=null;if(null!=e.px&&null!=e.py)o=e.px,i=e.py;else{const t=we(e,n,r);if(!t)return null;o=t.x,i=t.y}if(null==o||null==i)return null;if(!Ee(o,i,r))return null;const l=null!==(X=e.dx)&&void 0!==X?X:0,a=null!==(G=e.dy)&&void 0!==G?G:0,s=null!==(V=e.width)&&void 0!==V?V:32,c=null!==(q=e.height)&&void 0!==q?q:32,u=null!==(K=e.content)&&void 0!==K?K:t.createElement("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info"},"ℹ️");return t.createElement("foreignObject",{key:"ann-"+n,x:o+l-s/2,y:i+a-c/2,width:s,height:c,style:{overflow:"visible",pointerEvents:"auto"}},t.createElement("div",{style:{width:s,height:c,display:"flex",alignItems:"center",justifyContent:"center"}},u))}case"text":{const o=we(e,n,r);if(!o)return null;const{x:i,y:l}=o;return t.createElement("text",{key:"ann-text-"+n,x:i+(e.dx||0),y:l+(e.dy||0),fill:e.color||"var(--semiotic-text, #333)",fontSize:e.fontSize||11,dominantBaseline:"middle",style:{fontFamily:"inherit"}},e.label)}case"category-highlight":{const o=e.category;if(null==o)return null;const i=null===(Z=r.scales)||void 0===Z?void 0:Z.o,l=null===(Q=r.scales)||void 0===Q?void 0:Q.x,a=null===(J=r.scales)||void 0===J?void 0:J.y,s=(null==i?void 0:i.bandwidth)?i:(null==l?void 0:l.bandwidth)?l:(null==a?void 0:a.bandwidth)?a:null;if(!s)return null;const c=s(o);if(null==c)return null;const u=s.bandwidth(),d=e.color||"var(--semiotic-primary, #4589ff)",h=null!==(et=e.opacity)&&void 0!==et?et:.15,f=e.label;return(r.projection?"vertical"===r.projection:s===l)?t.createElement("g",{key:"ann-"+n},t.createElement("rect",{x:c,y:0,width:u,height:r.height||0,fill:d,fillOpacity:h}),f&&t.createElement("text",{x:c+u/2,y:12,textAnchor:"middle",fill:d,fontSize:12,fontWeight:"bold"},f)):t.createElement("g",{key:"ann-"+n},t.createElement("rect",{x:0,y:c,width:r.width||0,height:u,fill:d,fillOpacity:h}),f&&t.createElement("text",{x:12,y:c+u/2,dominantBaseline:"middle",fill:d,fontSize:12,fontWeight:"bold"},f))}default:return null}},n={scales:f?{x:f.x,y:f.y,time:f.x,value:f.y}:null,timeAxis:"x",xAccessor:I,yAccessor:W,width:s,height:c,data:z,frameType:"xy",pointNodes:B,curve:F,stickyPositionCache:K.current};return $.map((t,r)=>{if(O){const o=O(t,r,n);return null!=o?o:e(t,r,n)}return e(t,r,n)}).filter(Boolean)},[$,O,s,c,I,W,z,f,B,F]),et=function(t){var e;const n=i(t?Le:Ne,t?Te:$e,t?Te:$e);return t&&null!==(e=n.positions.get(t))&&void 0!==e?e:null}(Y);return r(()=>{if(!(null==et?void 0:et.locked)||!Y)return;const t=t=>{"Escape"===t.key&&De(Y)};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[null==et?void 0:et.locked,Y]),y||w||E||D||T||J&&J.length>0||k||X||et?t.createElement("svg",{role:"img",width:u,height:d,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"}},t.createElement("title",null,"string"==typeof w?w:"XY Chart"),t.createElement("desc",null,"string"==typeof w?w+" — XY data visualization":"XY data visualization"),t.createElement("g",{transform:`translate(${h.left},${h.top})`},k&&f&&!R&&(()=>{var e,n;const r=Oe(null===(e=null==g?void 0:g.find(t=>"bottom"===t.orient))||void 0===e?void 0:e.gridStyle),o=Oe(null===(n=null==g?void 0:g.find(t=>"left"===t.orient))||void 0===n?void 0:n.gridStyle);return t.createElement("g",{className:"stream-grid"},G.map((e,n)=>t.createElement("line",{key:"xgrid-"+n,x1:e.pixel,y1:0,x2:e.pixel,y2:c,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r})),V.map((e,n)=>t.createElement("line",{key:"ygrid-"+n,x1:0,y1:e.pixel,x2:s,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:o})))})(),y&&f&&(()=>{const e=null==g?void 0:g.find(t=>"left"===t.orient),n=null==g?void 0:g.find(t=>"bottom"===t.orient),r=!e||!1!==e.baseline,o=!n||!1!==n.baseline,i=(null==e?void 0:e.jaggedBase)||!1,l=(null==n?void 0:n.jaggedBase)||!1,a=null==n?void 0:n.landmarkTicks,u=null==e?void 0:e.landmarkTicks,d="var(--semiotic-border, #ccc)",f="var(--semiotic-text-secondary, var(--semiotic-text, #666))",y="var(--semiotic-text, #333)",x=!!(null==n?void 0:n.autoRotate)&&G.length>1&&(()=>{const t=s/Math.max(G.length-1,1),e=G.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:60),0);return e+8>t})();return t.createElement("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"}},!R&&o&&!l&&t.createElement("line",{x1:0,y1:c,x2:s,y2:c,stroke:d,strokeWidth:1}),!R&&l&&t.createElement("path",{d:Ie("bottom",s,c),fill:"none",stroke:d,strokeWidth:1}),G.map((e,n)=>{const r=!!a&&("function"==typeof a?a(e.value,n):Rt(e.value,n>0?G[n-1].value:void 0));return t.createElement("g",{key:"xtick-"+n,transform:`translate(${e.pixel},${c})`},t.createElement("line",{y2:5,stroke:d,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?t.createElement("text",{y:x?10:18,textAnchor:x?"end":"middle",fontSize:r?11:10,fontWeight:r?600:400,fill:f,style:{userSelect:"none"},transform:x?"rotate(-45)":void 0},e.label):t.createElement("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"}},t.createElement("div",{style:{textAlign:"center",fontSize:10,userSelect:"none"}},e.label)))}),p&&t.createElement("text",{x:s/2,y:c+40,textAnchor:"middle",fontSize:12,fill:y,style:{userSelect:"none"}},p),!R&&r&&!i&&t.createElement("line",{x1:0,y1:0,x2:0,y2:c,stroke:d,strokeWidth:1}),!R&&i&&t.createElement("path",{d:Ie("left",s,c),fill:"none",stroke:d,strokeWidth:1}),V.map((e,n)=>{const r=!!u&&("function"==typeof u?u(e.value,n):Rt(e.value,n>0?V[n-1].value:void 0));return t.createElement("g",{key:"ytick-"+n,transform:`translate(0,${e.pixel})`},t.createElement("line",{x2:-5,stroke:d,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?t.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:r?11:10,fontWeight:r?600:400,fill:f,style:{userSelect:"none"}},e.label):t.createElement("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"}},t.createElement("div",{style:{textAlign:"right",fontSize:10,userSelect:"none"}},e.label)))}),(()=>{const n=(null==e?void 0:e.label)||v;return n?t.createElement("text",{x:15-h.left,y:c/2,textAnchor:"middle",fontSize:12,fill:y,transform:`rotate(-90, ${15-h.left}, ${c/2})`,style:{userSelect:"none"}},n):null})(),(()=>{const e=null==g?void 0:g.find(t=>"right"===t.orient);if(!e||0===q.length)return null;const n=e.landmarkTicks,r=e.label||m;return t.createElement(t.Fragment,null,!1!==e.baseline&&t.createElement("line",{x1:s,y1:0,x2:s,y2:c,stroke:d,strokeWidth:1}),q.map((e,r)=>{const o=!!n&&("function"==typeof n?n(e.value,r):Rt(e.value,r>0?q[r-1].value:void 0));return t.createElement("g",{key:"ytick-r-"+r,transform:`translate(${s},${e.pixel})`},t.createElement("line",{x2:5,stroke:d,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?t.createElement("text",{x:8,textAnchor:"start",dominantBaseline:"middle",fontSize:o?11:10,fontWeight:o?600:400,fill:f,style:{userSelect:"none"}},e.label):t.createElement("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"}},t.createElement("div",{style:{textAlign:"left",fontSize:10,userSelect:"none"}},e.label)))}),r&&t.createElement("text",{x:s+h.right-15,y:c/2,textAnchor:"middle",fontSize:12,fill:y,transform:`rotate(90, ${s+h.right-15}, ${c/2})`,style:{userSelect:"none"}},r))})())})(),J,T&&f&&L&&N&&t.createElement(t.Fragment,null,T.top&&t.createElement("g",{transform:"translate(0, 0)"},t.createElement(ge,{orient:"top",config:ye(T.top),values:L,scale:f.x,size:h.top,length:s})),T.bottom&&t.createElement("g",{transform:`translate(0, ${c})`},t.createElement(ge,{orient:"bottom",config:ye(T.bottom),values:L,scale:f.x,size:h.bottom,length:s})),T.left&&t.createElement("g",{transform:"translate(0, 0)"},t.createElement(ge,{orient:"left",config:ye(T.left),values:N,scale:f.y,size:h.left,length:c})),T.right&&t.createElement("g",{transform:`translate(${s}, 0)`},t.createElement(ge,{orient:"right",config:ye(T.right),values:N,scale:f.y,size:h.right,length:c}))),D,et&&et.sourceId!==H&&(null==f?void 0:f.x)&&(()=>{const e=f.x(et.xValue);if(null==e||0>e||e>s)return null;const n=et.locked;return t.createElement("line",{x1:e,y1:0,x2:e,y2:c,stroke:n?"white":"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:n?1.5:1,strokeDasharray:n?"6,3":"4,4",pointerEvents:"none"})})(),X),w&&t.createElement("text",{x:u/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof w?w:null),fe({legend:E,totalWidth:u,totalHeight:d,margin:h,legendPosition:_,title:w,legendHoverBehavior:A,legendClickBehavior:M,legendHighlightedCategory:S,legendIsolatedCategories:P})):null}function Fe(t,e="#4e79a7"){return t&&"string"==typeof t?t:e}const Re="undefined"==typeof window||"undefined"==typeof document,Ye=t.createContext(null);function He(){return t.useContext(Ye)}const Xe={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function Ge(t,e){if(!t||0===t.length)return e+", empty";const n={};for(const e of t)n[e.type]=(n[e.type]||0)+1;const r=[],o={point:"points",line:"lines",area:"areas",rect:"bars",heatcell:"cells",circle:"nodes",candlestick:"candlesticks",wedge:"wedges",arc:"arcs",geoarea:"regions"},i=["point","line","area","rect","heatcell","circle","candlestick","wedge","arc","geoarea"],l=Object.keys(n).sort((t,e)=>{const n=i.indexOf(t),r=i.indexOf(e);return(-1===n?999:n)-(-1===r?999:r)});for(const t of l)r.push(`${n[t]} ${o[t]||t}`);return`${e}, ${r.join(", ")}`}function Ve(t,e,n){const r=[];return t>0&&r.push(t+" nodes"),e>0&&r.push(e+" edges"),0===r.length?n+", empty":`${n}, ${r.join(", ")}`}const qe=t=>{if(null==t)return"";const e=Math.round(100*t)/100;return Number.isNaN(e)?"":e+""},Ue={position:"absolute",top:0,left:0,right:0,zIndex:5,padding:"14px 16px 12px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)",fontFamily:"var(--semiotic-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif)",fontSize:13,lineHeight:1.5,color:"var(--semiotic-text, #333)",background:"var(--semiotic-bg, #fff)",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},Ke={marginBottom:8,paddingRight:28,color:"var(--semiotic-text-secondary, #666)",fontSize:12,letterSpacing:"0.01em"},Ze={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-border, #e0e0e0)",background:"var(--semiotic-bg, #fff)",cursor:"pointer",color:"var(--semiotic-text-secondary, #666)",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},Qe={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},Je={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-border, #e0e0e0)",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-text-secondary, #666)"},tn={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"},en={textAlign:"left",fontSize:11,color:"var(--semiotic-text-secondary, #999)",marginBottom:4,fontStyle:"italic"};function nn({scene:e,chartType:n,tableId:r,chartTitle:o}){var i;const[l,a]=t.useState(!1),s=He(),c=null!==(i=null==s?void 0:s.visible)&&void 0!==i&&i,u=l||c,d=t.useRef(null),h=o?"Data summary for "+o:r?`Data summary for ${n} ${r}`:"Data summary for "+n,f=t.useCallback(()=>{l||c||a(!0)},[l,c]),y=t.useCallback(t=>{var e;c||(null===(e=d.current)||void 0===e?void 0:e.contains(t.relatedTarget))||a(!1)},[c]);if(!e||0===e.length)return r?t.createElement("span",{id:r,tabIndex:-1,style:Xe}):null;if(!u)return t.createElement("div",{id:r,tabIndex:-1,onFocus:f,style:Xe,role:"region","aria-label":h},t.createElement("button",{type:"button",onClick:()=>a(!0)},"View data summary (",e.length," elements)"));const g=function(t){var e,n,r,o,i,l,a,s,c,u,d,h,f,y,g,p,v,m,x,b,k,w,E,A,M;const S=[];if(!Array.isArray(t))return S;for(const P of t)if(P&&"object"==typeof P)try{switch(P.type){case"point":S.push({label:"Point",values:{x:P.x,y:P.y}});break;case"line":{const t=P.path,e=Array.isArray(P.datum)?P.datum:[];if(!Array.isArray(t))break;for(let n=0;t.length>n&&e.length>n;n++){const e=t[n];Array.isArray(e)&&S.push({label:"Line point",values:{x:e[0],y:e[1]}})}break}case"area":{const t=P.topPath,e=Array.isArray(P.datum)?P.datum:[];if(!Array.isArray(t))break;for(let n=0;t.length>n&&e.length>n;n++){const e=t[n];Array.isArray(e)&&S.push({label:"Area point",values:{x:e[0],y:e[1]}})}break}case"rect":{const t=null!=P.datum&&"object"==typeof P.datum?P.datum:{},i=null!==(n=null!==(e=t.category)&&void 0!==e?e:P.group)&&void 0!==n?n:"",l=null!==(o=null!==(r=t.value)&&void 0!==r?r:t.__aggregateValue)&&void 0!==o?o:t.total;S.push({label:"Bar",values:{category:i,value:null!=l?l:""}});break}case"heatcell":S.push({label:"Cell",values:{x:P.x,y:P.y,value:P.value}});break;case"wedge":S.push({label:"Wedge",values:{category:null!==(s=null!==(l=null===(i=P.datum)||void 0===i?void 0:i.category)&&void 0!==l?l:null===(a=P.datum)||void 0===a?void 0:a.label)&&void 0!==s?s:"",value:null!==(u=null===(c=P.datum)||void 0===c?void 0:c.value)&&void 0!==u?u:""}});break;case"circle":S.push({label:"Node",values:{id:null!==(h=null===(d=P.datum)||void 0===d?void 0:d.id)&&void 0!==h?h:"",x:null!==(f=P.cx)&&void 0!==f?f:P.x,y:null!==(y=P.cy)&&void 0!==y?y:P.y}});break;case"arc":S.push({label:"Arc",values:{id:null!==(p=null===(g=P.datum)||void 0===g?void 0:g.id)&&void 0!==p?p:"",x:null!==(v=P.cx)&&void 0!==v?v:P.x,y:null!==(m=P.cy)&&void 0!==m?m:P.y}});break;case"candlestick":S.push({label:"Candlestick",values:{x:P.x,open:P.open,high:P.high,low:P.low,close:P.close}});break;case"geoarea":S.push({label:"Region",values:{name:null!==(E=null!==(k=null===(b=null===(x=P.datum)||void 0===x?void 0:x.properties)||void 0===b?void 0:b.name)&&void 0!==k?k:null===(w=P.datum)||void 0===w?void 0:w.name)&&void 0!==E?E:"",value:null!==(M=null===(A=P.datum)||void 0===A?void 0:A.value)&&void 0!==M?M:""}})}}catch(t){}return S}(e),p=function(t){if(!t||0===t.length)return[];const e=new Set;for(const n of t)if(n&&n.values)for(const t of Object.keys(n.values))e.add(t);const n=[];for(const r of e){const e=[],o=new Set;for(const n of t){if(!n||!n.values)continue;const t=n.values[r];null!=t&&""!==t&&("number"==typeof t&&!Number.isNaN(t)&&Number.isFinite(t)?e.push(t):"number"==typeof t||"object"!=typeof t&&"function"!=typeof t&&o.add(t+""))}if(e.length>0){let t=e[0],o=e[0],i=0;for(const n of e)t>n&&(t=n),n>o&&(o=n),i+=n;n.push({name:r,count:e.length,numeric:!0,min:t,max:o,mean:i/e.length})}else if(o.size>0){const t=Array.from(o);n.push({name:r,count:t.length,numeric:!1,uniqueValues:t.slice(0,5)})}}return n}(g),v=function(t,e){const n=[t+" data points."];for(const t of e)if(t.numeric)n.push(`${t.name}: ${qe(t.min)} to ${qe(t.max)}, mean ${qe(t.mean)}.`);else{const e=t.uniqueValues,r=e.length>3?`${e.slice(0,3).join(", ")}… (${t.count} unique)`:e.join(", ");n.push(`${t.name}: ${r}.`)}return n.join(" ")}(g.length,p),m=g.slice(0,5),x=new Set;for(const t of m)for(const e of Object.keys(t.values))x.add(e);const b=Array.from(x);return t.createElement("div",{ref:d,id:r,tabIndex:-1,onBlur:y,style:Ue,role:"region","aria-label":h},t.createElement("button",{type:"button",onClick:()=>{c&&s&&s.setVisible(!1),a(!1)},"aria-label":"Close data summary",style:Ze},"×"),t.createElement("div",{role:"note",style:Ke},v),t.createElement("table",{role:"table","aria-label":"Sample data for "+n,style:Qe},t.createElement("caption",{style:en},"First ",m.length," of ",g.length," data points"),t.createElement("thead",null,t.createElement("tr",null,t.createElement("th",{style:Je},"type"),b.map(e=>t.createElement("th",{key:e,style:Je},e)))),t.createElement("tbody",null,m.map((e,n)=>t.createElement("tr",{key:n},t.createElement("td",{style:tn},e.label),b.map(n=>{return t.createElement("td",{key:n,style:tn},null==(r=e.values[n])||""===r?"—":"number"==typeof r?Number.isNaN(r)?"—":qe(r):"boolean"==typeof r?r?"true":"false":"object"==typeof r?"—":r+"");var r}))))))}function rn({nodes:e,edges:n,chartType:r,tableId:o,chartTitle:i}){var l,a,s,c,u,d,h,f,y,g,p,v,m,x;const[b,k]=t.useState(!1),w=He(),E=null!==(l=null==w?void 0:w.visible)&&void 0!==l&&l,A=b||E,M=i?"Data summary for "+i:o?`Data summary for ${r} ${o}`:"Data summary for "+r,S=t.useRef(null),P=t.useCallback(()=>{b||E||k(!0)},[b,E]),_=t.useCallback(t=>{var e;E||(null===(e=S.current)||void 0===e?void 0:e.contains(t.relatedTarget))||k(!1)},[E]);if(!e||0===e.length)return o?t.createElement("span",{id:o,tabIndex:-1,style:Xe}):null;if(!A)return t.createElement("div",{id:o,tabIndex:-1,onFocus:P,style:Xe,role:"region","aria-label":M},t.createElement("button",{type:"button",onClick:()=>k(!0)},"View data summary (",e.length," nodes, ",n.length," edges)"));const D=Array.isArray(e)?e:[],T=Array.isArray(n)?n:[],L=new Map,C=new Map,N=new Map,$=new Map;for(const t of T){if(!t||"object"!=typeof t)continue;const e=null!==(a=t.datum)&&void 0!==a?a:t,n="object"==typeof e.source?null===(s=e.source)||void 0===s?void 0:s.id:e.source,r="object"==typeof e.target?null===(c=e.target)||void 0===c?void 0:c.id:e.target,o="number"==typeof e.value&&Number.isFinite(e.value)?e.value:0;if(null!=n&&""!==n){const t=n+"";C.set(t,(null!==(u=C.get(t))&&void 0!==u?u:0)+1),$.set(t,(null!==(d=$.get(t))&&void 0!==d?d:0)+o)}if(null!=r&&""!==r){const t=r+"";L.set(t,(null!==(h=L.get(t))&&void 0!==h?h:0)+1),N.set(t,(null!==(f=N.get(t))&&void 0!==f?f:0)+o)}}const O=[];for(let t=0;D.length>t;t++){const e=D[t];if(!e||"object"!=typeof e)continue;const n=null!==(g=null===(y=e.datum)||void 0===y?void 0:y.id)&&void 0!==g?g:e.id,r=null!=n?n+"":"node-"+t,o=null!==(p=L.get(r))&&void 0!==p?p:0,i=null!==(v=C.get(r))&&void 0!==v?v:0,l=null!==(m=N.get(r))&&void 0!==m?m:0,a=null!==(x=$.get(r))&&void 0!==x?x:0;O.push({id:r,degree:o+i,inDeg:o,outDeg:i,wDegree:l+a,wInDeg:l,wOutDeg:a})}O.sort((t,e)=>e.degree-t.degree);let I=0,W=0;if(O.length>0){let t=0;for(const e of O)t+=e.degree,e.degree>W&&(W=e.degree);I=t/O.length}const z=T.some(t=>{var e;const n=null!==(e=null==t?void 0:t.datum)&&void 0!==e?e:t;return"number"==typeof(null==n?void 0:n.value)&&Number.isFinite(n.value)}),B=[`${O.length} nodes, ${T.length} edges.`];O.length>0&&B.push(`Mean degree: ${qe(I)}, max degree: ${W}.`);const j=O.slice(0,5);return t.createElement("div",{ref:S,id:o,tabIndex:-1,onBlur:_,style:Ue,role:"region","aria-label":M},t.createElement("button",{type:"button",onClick:()=>{E&&w&&w.setVisible(!1),k(!1)},"aria-label":"Close data summary",style:Ze},"×"),t.createElement("div",{role:"note",style:Ke},B.join(" ")),t.createElement("table",{role:"table","aria-label":"Node degree summary for "+r,style:Qe},t.createElement("caption",{style:en},"Top ",j.length," of ",O.length," nodes by degree"),t.createElement("thead",null,t.createElement("tr",null,t.createElement("th",{style:Je},"id"),t.createElement("th",{style:Je},"degree"),t.createElement("th",{style:Je},"in"),t.createElement("th",{style:Je},"out"),z&&t.createElement("th",{style:Je},"w. degree"),z&&t.createElement("th",{style:Je},"w. in"),z&&t.createElement("th",{style:Je},"w. out"))),t.createElement("tbody",null,j.map((e,n)=>t.createElement("tr",{key:n},t.createElement("td",{style:tn},e.id),t.createElement("td",{style:tn},e.degree),t.createElement("td",{style:tn},e.inDeg),t.createElement("td",{style:tn},e.outDeg),z&&t.createElement("td",{style:tn},qe(e.wDegree)),z&&t.createElement("td",{style:tn},qe(e.wInDeg)),z&&t.createElement("td",{style:tn},qe(e.wOutDeg)))))))}function on({summary:e}){return e?t.createElement("div",{role:"note",style:Xe},e):null}function ln({tableId:e}){return t.createElement("a",{href:"#"+e,style:Xe,onClick:t=>{t.preventDefault();const n=document.getElementById(e);n&&requestAnimationFrame(()=>n.focus())},onFocus:t=>{Object.assign(t.currentTarget.style,{position:"absolute",width:"auto",height:"auto",overflow:"visible",clip:"auto",whiteSpace:"normal",padding:"4px 8px",background:"var(--semiotic-bg, #fff)",color:"var(--semiotic-text, #000)",border:"2px solid var(--semiotic-focus, #005fcc)",borderRadius:"4px",zIndex:"10",fontSize:"12px",top:"4px",left:"4px"})},onBlur:t=>{const e=t.currentTarget;e.removeAttribute("style"),Object.assign(e.style,Xe)}},"Skip to data table")}function an({hoverPoint:e}){let n="";if(e){const t=e.data||e;n="object"==typeof t?"Focused on data point: "+Object.entries(t).filter(([,t])=>"object"!=typeof t&&"function"!=typeof t).map(([t,e])=>`${t}: ${e}`).join(", "):"Focused on data point: "+t}return t.createElement("div",{"aria-live":"polite","aria-atomic":"true",style:Xe},n)}const sn="var(--semiotic-focus, #005fcc)";function cn({active:e,hoverPoint:n,margin:r,size:o,shape:i="circle",width:l,height:a}){if(!e||!n)return null;const s=n.x+r.left,c=n.y+r.top;let u;if("rect"===i&&null!=l&&null!=a){const e=Math.max(l,4),n=Math.max(a,4);u=t.createElement("rect",{x:s-e/2-3,y:c-n/2-3,width:e+6,height:n+6,rx:3,fill:"none",stroke:sn,strokeWidth:2,strokeDasharray:"4,2"})}else u=t.createElement("circle","wedge"===i?{cx:s,cy:c,r:12,fill:"none",stroke:sn,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:s,cy:c,r:8,fill:"none",stroke:sn,strokeWidth:2,strokeDasharray:"4,2"});return t.createElement("svg",{style:{position:"absolute",left:0,top:0,width:o[0],height:o[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true"},u)}function un({x:e,y:n,containerWidth:r,containerHeight:o,margin:i,children:l,className:a="stream-frame-tooltip",zIndex:s=1}){const c=t.useRef(null),[u,d]=t.useState(null);t.useLayoutEffect(()=>{const t=c.current;if(!t)return;const e=t.getBoundingClientRect();d(t=>t&&t.width===e.width&&t.height===e.height?t:{width:e.width,height:e.height})},[l,a,r,o]);let h;return h=u?`translate(${u.width+12>r-e?"calc(-100% - 12px)":"12px"}, ${u.height+12>o-n?"calc(-100% - 4px)":"4px"})`:`translate(${e>.7*r?"calc(-100% - 12px)":"12px"}, ${.3*o>n?"4px":"calc(-100% - 4px)"})`,t.createElement("div",{ref:c,className:a,style:{position:"absolute",left:i.left+e,top:i.top+n,transform:h,pointerEvents:"none",zIndex:s,width:"max-content"}},l)}function dn(){const[t,e]=o(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return r(()=>{if("undefined"==typeof window||!window.matchMedia)return;const t=window.matchMedia("(prefers-reduced-motion: reduce)");return e(t.matches),function(t,e){return"function"==typeof t.addEventListener?(t.addEventListener("change",e),()=>t.removeEventListener("change",e)):(t.addListener(e),()=>t.removeListener(e))}(t,t=>e(t.matches))},[]),t}function hn(r){const o=l(null),c=fn(r);return[function({children:e}){const i=n(()=>fn(r),[]);return t.createElement(o.Provider,{value:i,children:e})},t=>{var n;const r=null!==(n=a(o))&&void 0!==n?n:c,l=e(t);l.current=t;const u=s(()=>l.current(r.getState()),[r]),d=s(()=>l.current(r.getState()),[r]);return i(r.subscribe,u,d)}]}function fn(t){const e=new EventTarget;let n=t(function(t){n=Object.assign(Object.assign({},n),t(n)),e.dispatchEvent(new CustomEvent("update"))});return{getState:()=>n,subscribe:function(t){return e.addEventListener("update",t),()=>e.removeEventListener("update",t)}}}const yn={mode:"light",colors:{primary:"#00a2ce",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",background:"transparent",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},gn={mode:"dark",colors:{primary:"#4fc3f7",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",background:"#1a1a2e",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},pn={mode:"light",colors:{primary:"#0000cc",categorical:["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],sequential:"blues",diverging:"RdBu",background:"#ffffff",text:"#000000",textSecondary:"#333333",grid:"#999999",border:"#000000",focus:"#0000cc",selection:"#0000cc",selectionOpacity:.1},typography:{fontFamily:"system-ui, sans-serif",titleSize:18,labelSize:14,tickSize:12},tooltip:{background:"#000000",text:"#ffffff",borderRadius:"4px",fontSize:"14px",shadow:"0 2px 8px rgba(0, 0, 0, 0.3)"},borderRadius:"4px"},[vn,mn]=hn(t=>({theme:yn,setTheme(e){t(t=>{if("light"===e)return{theme:yn};if("dark"===e)return{theme:gn};if("high-contrast"===e)return{theme:pn};if(e.mode&&"auto"!==e.mode){const t="dark"===e.mode?gn:yn;return{theme:Object.assign(Object.assign(Object.assign({},t),e),{colors:Object.assign(Object.assign({},t.colors),e.colors||{}),typography:Object.assign(Object.assign({},t.typography),e.typography||{})})}}return{theme:Object.assign(Object.assign(Object.assign({},t.theme),e),{colors:Object.assign(Object.assign({},t.theme.colors),e.colors||{}),typography:Object.assign(Object.assign({},t.theme.typography),e.typography||{})})}})}}));function xn(t,e,n,r){const o=t.getContext("2d");if(!o)return null;const i=e[0]*r,l=e[1]*r,a=e[0]+"px",s=e[1]+"px";return t.style.width!==a&&(t.style.width=a),t.style.height!==s&&(t.style.height=s),t.width===i&&t.height===l||(t.width=i,t.height=l),o.setTransform(r,0,0,r,0,0),o.translate(n.left,n.top),o}function bn(){return"undefined"!=typeof window&&window.devicePixelRatio||1}const kn=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,wn=new WeakMap;function En(t,e){var n,r;if(!e)return e;const o=kn.exec(e);if(!o)return e;const i=t.canvas;if(!i)return(null===(n=o[2])||void 0===n?void 0:n.trim())||e;let l=wn.get(i);if(l||(l=new Map,wn.set(i,l)),l.has(e))return l.get(e);const a=getComputedStyle(i).getPropertyValue(o[1]).trim()||(null===(r=o[2])||void 0===r?void 0:r.trim())||e;return l.set(e,a),a}function An(t){switch(t){case"monotoneX":return q;case"monotoneY":return V;case"cardinal":return R;case"catmullRom":return F;case"step":return G;case"stepBefore":return H;case"stepAfter":return X;case"basis":return Y;case"natural":return Q;default:return null}}function Mn(t,e,n){let r=n;for(const n of e)"lesser"===n.thresholdType?n.value>t&&(r=n.color):t>n.value&&(r=n.color);return r}function Sn(t,e,n,r,o,i){if(2>e.length)return;const l=[0];for(let t=1;e.length>t;t++){const n=e[t][0]-e[t-1][0],r=e[t][1]-e[t-1][1];l.push(l[t-1]+Math.sqrt(n*n+r*r))}const a=l[l.length-1];if(0===a)return;const s=Math.min(.2*a,40);t.strokeStyle=n,t.lineWidth=r,t.lineCap=i;for(let n=0;e.length-1>n;n++){const r=(l[n]+l[n+1])/2;let i=o;s>r&&(i*=r/s),s>a-r&&(i*=(a-r)/s),t.globalAlpha=Math.max(0,i),t.beginPath(),t.moveTo(e[n][0],e[n][1]),t.lineTo(e[n+1][0],e[n+1][1]),t.stroke()}}const Pn=(t,e,n,r)=>{var o,i;const l=e.filter(t=>"line"===t.type);for(const a of l){if(2>a.path.length)continue;const s=a.style.stroke||"#007bff",c=a.style.strokeWidth||2,u=a.colorThresholds,d=a.rawValues;if(t.setLineDash(a.style.strokeDasharray?a.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=a.style.opacity&&(t.globalAlpha=a.style.opacity),t.lineWidth=c,t.lineCap=a.style.strokeLinecap||"butt",a.style._edgeFade){const g=null!==(o=a.style.opacity)&&void 0!==o?o:1;Sn(t,a.path,s,c,g,a.style.strokeLinecap||"butt"),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt";continue}const h=An(a.curve),f=u&&u.length>0&&d&&d.length===a.path.length,y=a._decayOpacities;if(y&&y.length===a.path.length&&!f){t.strokeStyle=s;const p=null!==(i=a.style.opacity)&&void 0!==i?i:1;for(let v=0;a.path.length-1>v;v++)t.globalAlpha=.5*(y[v]+y[v+1])*p,t.beginPath(),t.moveTo(a.path[v][0],a.path[v][1]),t.lineTo(a.path[v+1][0],a.path[v+1][1]),t.stroke()}else if(f){let m=null,x=null,b=null,k=null,w=!1;function E(e,n,r){t.beginPath(),t.strokeStyle=e,t.moveTo(n,r),w=!0}function A(){w&&(t.stroke(),w=!1)}for(let M=0;a.path.length>M;M++){const[S,P]=a.path[M],_=d[M],D=Mn(_,u,s);if(null!==m&&null!==k&&null!==b){if(D===k)t.lineTo(S,P);else{const T=[];for(const L of u){const C=L.value;(b>C||C>_)&&(C>b||_>C)||b===C||_===C||T.push({t:(C-b)/(_-b)})}T.sort((t,e)=>t.t-e.t);for(const N of T){const $=m+(S-m)*N.t,O=x+(P-x)*N.t,I=Mn(b+(_-b)*Math.min(N.t+1e-4,1),u,s);t.lineTo($,O),A(),E(I,$,O)}t.lineTo(S,P)}m=S,x=P,b=_,k=D}else E(D,S,P),m=S,x=P,b=_,k=D}A()}else{if(t.beginPath(),!a.strokeGradient||2>a.strokeGradient.colorStops.length||2>a.path.length)t.strokeStyle=s;else{const W=t.createLinearGradient(a.path[0][0],0,a.path[a.path.length-1][0],0);for(const z of a.strokeGradient.colorStops)W.addColorStop(Math.max(0,Math.min(1,z.offset)),z.color);t.strokeStyle=W}if(h)Z().x(t=>t[0]).y(t=>t[1]).curve(h).context(t)(a.path);else{const[B,j]=a.path[0];t.moveTo(B,j);for(let F=1;a.path.length>F;F++)t.lineTo(a.path[F][0],a.path[F][1])}t.stroke()}if(a.style.fill&&a.style.fillOpacity&&a.style.fillOpacity>0){if(t.beginPath(),t.globalAlpha=a.style.fillOpacity,t.fillStyle=("string"==typeof a.style.fill?En(t,a.style.fill):a.style.fill)||a.style.fill,h&&!f)Z().x(t=>t[0]).y(t=>t[1]).curve(h).context(t)(a.path);else{const[Y,H]=a.path[0];t.moveTo(Y,H);for(let X=1;a.path.length>X;X++)t.lineTo(a.path[X][0],a.path[X][1])}const R=a.path[0][0];t.lineTo(a.path[a.path.length-1][0],r.height),t.lineTo(R,r.height),t.closePath(),t.fill()}t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt"}};function _n(t){return!(!t._pulseIntensity||0>=t._pulseIntensity)}function Dn(t,e,n=.3){_n(e)&&(t.globalAlpha=e._pulseIntensity*n,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fillRect(e.x,e.y,e.w,e.h))}function Tn(t,e,n=.6){var r,o,i,l,a;if(!_n(e))return;const s=null!==(r=e._pulseGlowRadius)&&void 0!==r?r:4,c=e.r+s*e._pulseIntensity,u=null!==(i=null!==(o=e.cx)&&void 0!==o?o:e.x)&&void 0!==i?i:0,d=null!==(a=null!==(l=e.cy)&&void 0!==l?l:e.y)&&void 0!==a?a:0;t.beginPath(),t.arc(u,d,c,0,2*Math.PI),t.strokeStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.lineWidth=2*e._pulseIntensity,t.globalAlpha=e._pulseIntensity*n,t.stroke()}function Ln(t,e,n,r=.35){_n(e)&&(t.globalAlpha=e._pulseIntensity*r,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fill())}function Cn(t){switch(t){case"monotoneX":return q;case"monotoneY":return V;case"cardinal":return R;case"catmullRom":return F;case"step":return G;case"stepBefore":return H;case"stepAfter":return X;case"basis":return Y;case"natural":return Q;default:return null}}function Nn(t){if(t.startsWith("#")){const e=4===t.length?t[1]+t[1]+t[2]+t[2]+t[3]+t[3]:t.slice(1,7);return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[78,121,167]}function $n(t,e){const n=Cn(e.curve);if(!n||2>e.topPath.length||2>e.bottomPath.length){t.beginPath(),t.moveTo(e.topPath[0][0],e.topPath[0][1]);for(let n=1;e.topPath.length>n;n++)t.lineTo(e.topPath[n][0],e.topPath[n][1]);for(let n=e.bottomPath.length-1;n>=0;n--)t.lineTo(e.bottomPath[n][0],e.bottomPath[n][1]);t.closePath()}else{const r=j().x(t=>t[0]).y0((t,n)=>e.bottomPath[n][1]).y1(t=>t[1]).curve(n).context(t);t.beginPath(),r(e.topPath)}}const On=(t,e,n,r)=>{var o,i,l;const a=e.filter(t=>"area"===t.type);for(const e of a){if(2>e.topPath.length)continue;const n=e.style.fill||"#4e79a7",r=e._decayOpacities;if(r&&r.length===e.topPath.length){const i=null!==(o=e.style.fillOpacity)&&void 0!==o?o:.7;t.fillStyle=n;for(let n=0;e.topPath.length-1>n;n++)t.globalAlpha=.5*(r[n]+r[n+1])*i,t.beginPath(),t.moveTo(e.topPath[n][0],e.topPath[n][1]),t.lineTo(e.topPath[n+1][0],e.topPath[n+1][1]),t.lineTo(e.bottomPath[n+1][0],e.bottomPath[n+1][1]),t.lineTo(e.bottomPath[n][0],e.bottomPath[n][1]),t.closePath(),t.fill();if(e.style.stroke&&"none"!==e.style.stroke){t.strokeStyle=En(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||2,t.setLineDash([]);for(let n=0;e.topPath.length-1>n;n++)t.globalAlpha=.5*(r[n]+r[n+1]),t.beginPath(),t.moveTo(e.topPath[n][0],e.topPath[n][1]),t.lineTo(e.topPath[n+1][0],e.topPath[n+1][1]),t.stroke()}t.globalAlpha=1;continue}const a=null!==(i=e.style.opacity)&&void 0!==i?i:1;if($n(t,e),e.fillGradient&&("colorStops"in e.fillGradient&&e.fillGradient.colorStops.length>=2||"topOpacity"in e.fillGradient)&&e.fillGradient){let r=1/0;for(const t of e.topPath)r>t[1]&&(r=t[1]);let o=-1/0;for(const t of e.bottomPath)t[1]>o&&(o=t[1]);const i=t.createLinearGradient(0,r,0,o);if("colorStops"in e.fillGradient)for(const t of e.fillGradient.colorStops){const e=Math.max(0,Math.min(1,t.offset));isNaN(e)||i.addColorStop(e,t.color)}else if("topOpacity"in e.fillGradient){const t=Nn("string"==typeof n?n:"#4e79a7");i.addColorStop(0,`rgba(${t[0]},${t[1]},${t[2]},${e.fillGradient.topOpacity})`),i.addColorStop(1,`rgba(${t[0]},${t[1]},${t[2]},${e.fillGradient.bottomOpacity})`)}t.fillStyle=i,t.globalAlpha=a}else{const r=null!==(l=e.style.fillOpacity)&&void 0!==l?l:.7;t.globalAlpha=r*a,t.fillStyle=n}if(t.fill(),e._pulseIntensity&&e._pulseIntensity>0&&($n(t,e),Ln(t,e)),e.style.stroke&&"none"!==e.style.stroke){if(t.globalAlpha=a,!e.strokeGradient||2>e.strokeGradient.colorStops.length||2>e.topPath.length)t.strokeStyle=En(t,e.style.stroke)||e.style.stroke;else{const n=t.createLinearGradient(e.topPath[0][0],0,e.topPath[e.topPath.length-1][0],0);for(const t of e.strokeGradient.colorStops)n.addColorStop(Math.max(0,Math.min(1,t.offset)),t.color);t.strokeStyle=n}t.lineWidth=e.style.strokeWidth||2,t.setLineDash([]);const n=Cn(e.curve);if(t.beginPath(),n)Z().x(t=>t[0]).y(t=>t[1]).curve(n).context(t)(e.topPath);else{t.moveTo(e.topPath[0][0],e.topPath[0][1]);for(let n=1;e.topPath.length>n;n++)t.lineTo(e.topPath[n][0],e.topPath[n][1])}t.stroke()}t.globalAlpha=1}},In=(t,e,n,r)=>{var o;const i=e.filter(t=>"point"===t.type);if(0!==i.length){t.save();try{for(const e of i){t.beginPath(),t.arc(e.x,e.y,e.r,0,2*Math.PI);const n=null!==(o=e.style.opacity)&&void 0!==o?o:e.style.fillOpacity;null!=n&&(t.globalAlpha=n),t.fillStyle=("string"==typeof e.style.fill?En(t,e.style.fill):e.style.fill)||"#4e79a7",t.fill(),e.style.stroke&&(t.strokeStyle=("string"==typeof e.style.stroke?En(t,e.style.stroke):e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.stroke()),Tn(t,e),t.globalAlpha=1}}finally{t.restore()}}},Wn=(t,e,n,r)=>{const o=e.filter(t=>"rect"===t.type);for(const e of o)null!=e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.icon?zn(t,e):(t.fillStyle=("string"==typeof e.style.fill?En(t,e.style.fill):e.style.fill)||"#007bff",t.fillRect(e.x,e.y,e.w,e.h),e.style.stroke&&(t.strokeStyle=En(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.strokeRect(e.x,e.y,e.w,e.h))),Dn(t,e),t.globalAlpha=1};function zn(t,e){const n=e.style.icon,r=e.style.iconPadding||2,o=Math.min(e.w,e.h)-r;if(0>=o)return;const i=e.h>e.w;if(t.save(),t.beginPath(),t.rect(e.x,e.y,e.w,e.h),t.clip(),i){const i=o+r,l=e.x+(e.w-o)/2;for(let r=e.y+e.h-o;r>=e.y-o;r-=i)t.drawImage(n,l,r,o,o)}else{const i=o+r,l=e.y+(e.h-o)/2;for(let r=e.x;e.x+e.w>r;r+=i)t.drawImage(n,r,l,o,o)}t.restore()}function Bn(t){const[e,n,r]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(t);return.299*e+.587*n+.114*r>128?"#000":"#fff"}function jn(t){return Number.isInteger(t)?t+"":100>Math.abs(t)?1>Math.abs(t)?t.toPrecision(3):t.toFixed(1):t.toFixed(0)}const Fn=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Rn(t){const e=t[1]-t[0],n=3156e7;return 864e5>e?t=>{const e=new Date(t);return`${(e.getUTCHours()+"").padStart(2,"0")}:${(e.getUTCMinutes()+"").padStart(2,"0")}`}:n>e?t=>{const e=new Date(t);return`${Fn[e.getUTCMonth()]} ${e.getUTCDate()}`}:5*n>e?t=>{const e=new Date(t);return`${Fn[e.getUTCMonth()]} ${e.getUTCFullYear()}`}:t=>new Date(t).getUTCFullYear()+""}const Yn={line:[On,Pn,In],area:[On,In],stackedarea:[On,In],scatter:[In],bubble:[In],heatmap:[(t,e,n,r)=>{const o=e.filter(t=>"heatcell"===t.type);t.save();try{for(const e of o){const n=e.style;if(null!=(null==n?void 0:n.opacity)&&(t.globalAlpha=n.opacity),t.fillStyle=e.fill,t.fillRect(e.x,e.y,e.w,e.h),t.strokeStyle="#fff",t.lineWidth=1,t.strokeRect(e.x,e.y,e.w,e.h),Dn(t,e),t.globalAlpha=1,e.showValues&&null!=e.value){if(20>e.w||20>e.h)continue;const n=e.valueFormat?e.valueFormat(e.value):jn(e.value),r=Math.max(10,Math.min(16,.3*Math.min(e.w,e.h))),o=e.x+e.w/2,i=e.y+e.h/2;t.fillStyle=Bn(e.fill),t.font=r+"px sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText(n,o,i)}}}finally{t.restore()}}],bar:[Wn],swarm:[In],waterfall:[(t,e,n,r)=>{var o,i,l;Wn(t,e);const a=e.filter(t=>"rect"===t.type);if(2>a.length)return;const s=a[0].datum,c=null==s?void 0:s._connectorStroke;if(c){t.save(),t.strokeStyle=c,t.lineWidth=null!==(o=null==s?void 0:s._connectorWidth)&&void 0!==o?o:1,t.setLineDash([]);for(let e=0;a.length-1>e;e++){const r=a[e],o=a[e+1];if(!(null===(i=r.datum)||void 0===i?void 0:i.cumEnd)||!(null===(l=o.datum)||void 0===l?void 0:l.baseline))continue;const s=n.y(r.datum.cumEnd),c=r.x+r.w,u=o.x;t.beginPath(),t.moveTo(c,s),t.lineTo(u,s),t.stroke()}t.restore()}}],candlestick:[(t,e,n,r)=>{for(const n of e){if("candlestick"!==n.type)continue;const e=n;t.save();const r=e._decayOpacity;if(null!=r&&1!==r&&(t.globalAlpha=r),t.beginPath(),t.moveTo(e.x,e.highY),t.lineTo(e.x,e.lowY),t.strokeStyle=e.wickColor,t.lineWidth=e.wickWidth,t.stroke(),e.isRange){const n=Math.max(2*e.wickWidth,4);t.fillStyle=e.wickColor,t.beginPath(),t.arc(e.x,e.highY,n,0,2*Math.PI),t.fill(),t.beginPath(),t.arc(e.x,e.lowY,n,0,2*Math.PI),t.fill()}else if(e.bodyWidth>0){const n=Math.min(e.openY,e.closeY),r=Math.abs(e.openY-e.closeY),o=e.isUp?e.upColor:e.downColor;t.fillStyle=o,t.fillRect(e.x-e.bodyWidth/2,n,e.bodyWidth,Math.max(r,1)),t.strokeStyle=o,t.lineWidth=1,t.strokeRect(e.x-e.bodyWidth/2,n,e.bodyWidth,Math.max(r,1))}t.restore()}}],mixed:[On,Pn,In]},Hn={top:20,right:20,bottom:30,left:40},Xn={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"},Gn={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 Vn({hover:e}){const n=t=>Number.isInteger(t)?t+"":t.toFixed(2);return t.createElement("div",{className:"semiotic-tooltip",style:Gn},t.createElement("div",{style:{fontWeight:600,marginBottom:2}},n(e.value)),t.createElement("div",{style:{opacity:.7,fontSize:11}},n(e.time)))}const qn=c(function(i,l){var a,c,d,h,f,y,g,p,v,m,x;const{chartType:b,runtimeMode:k,data:w,chunkThreshold:E,chunkSize:A,xAccessor:M,yAccessor:S,colorAccessor:P,sizeAccessor:_,groupAccessor:D,lineDataAccessor:T,curve:L,normalize:C,binSize:N,valueAccessor:$,arrowOfTime:O="right",windowMode:I="sliding",windowSize:W=200,timeAccessor:z,xExtent:B,yExtent:j,extentPadding:F=.1,scalePadding:R,sizeRange:Y,size:H=[500,300],responsiveWidth:X,responsiveHeight:G,margin:V,className:q,background:U,lineStyle:K,pointStyle:Z,areaStyle:Q,waterfallStyle:J,swarmStyle:tt,barColors:et,colorScheme:nt,boundsAccessor:rt,boundsStyle:ot,y0Accessor:it,gradientFill:lt,lineGradient:at,areaGroups:st,openAccessor:ct,highAccessor:ut,lowAccessor:dt,closeAccessor:yt,candlestickStyle:gt,showAxes:pt=!0,axes:vt,xLabel:mt,yLabel:xt,yLabelRight:bt,xFormat:kt,yFormat:wt,tickFormatTime:Et,tickFormatValue:At,hoverAnnotation:Mt,tooltipContent:St,customHoverBehavior:Pt,customClickBehavior:_t,enableHover:Dt,hoverRadius:Tt=30,tooltipMode:Lt,annotations:Ct,svgAnnotationRules:Nt,showGrid:$t,legend:Ot,legendHoverBehavior:It,legendClickBehavior:Wt,legendHighlightedCategory:Bt,legendIsolatedCategories:jt,legendPosition:Ft,backgroundGraphics:Rt,foregroundGraphics:Yt,canvasPreRenderers:Gt,svgPreRenderers:Vt,title:qt,categoryAccessor:Ut,brush:Kt,onBrush:Zt,decay:Qt,pulse:re,transition:ae,staleness:se,heatmapAggregation:ce,heatmapXBins:ue,heatmapYBins:de,showValues:he,heatmapValueFormat:fe,marginalGraphics:ye,pointIdAccessor:ge,xScaleType:pe,yScaleType:ve,accessibleTable:me=!0,description:xe,summary:be,linkedCrosshairName:ke,linkedCrosshairSourceId:we}=i,Ee=dn(),Ae=e(Ee);Ae.current=Ee;const[Me,Se]=ie(H,X,G),Pe=Object.assign(Object.assign({},Hn),V);if(ye){const t=60;ye.top&&t>Pe.top&&(Pe.top=t),ye.bottom&&t>Pe.bottom&&(Pe.bottom=t),ye.left&&t>Pe.left&&(Pe.left=t),ye.right&&t>Pe.right&&(Pe.right=t)}const _e=Se[0]-Pe.left-Pe.right,De=Se[1]-Pe.top-Pe.bottom,Te="function"==typeof Yt?Yt({size:Se,margin:Pe}):Yt,Le="function"==typeof Rt?Rt({size:Se,margin:Pe}):Rt,Ce=null!=Mt?Mt:Dt,Ne=e(null),$e=e(null),Oe=e(0),Ie=e(!1),ze=mn(t=>t.theme),[Be,Ye]=o(0),[He,Xe]=o(null),Ve=e(null),qe=e(null),[Ue,Ke]=o(null),[Ze,Qe]=o(!1),[Je,tn]=o([]),[en,rn]=o([]),sn=e(()=>{}),hn="streaming"===k||["bar","swarm","waterfall"].includes(b),fn=n(()=>({chartType:b,runtimeMode:hn?"streaming":"bounded",windowSize:W,windowMode:I,arrowOfTime:hn?O:"right",extentPadding:F,scalePadding:R,xAccessor:hn?void 0:M,yAccessor:hn?void 0:S,timeAccessor:hn?z:void 0,valueAccessor:$,colorAccessor:P,sizeAccessor:_,groupAccessor:D||(T?"_lineGroup":void 0),categoryAccessor:Ut,lineDataAccessor:T,xScaleType:pe,yScaleType:ve,xExtent:B,yExtent:j,sizeRange:Y,binSize:N,normalize:C,boundsAccessor:rt,boundsStyle:ot,y0Accessor:it,gradientFill:!0===lt?{topOpacity:.8,bottomOpacity:.05}:!1===lt?void 0:lt,areaGroups:st?new Set(st):void 0,lineGradient:at,openAccessor:ct,highAccessor:ut,lowAccessor:dt,closeAccessor:yt,candlestickStyle:gt,lineStyle:K,pointStyle:Z,areaStyle:Q,swarmStyle:tt,waterfallStyle:J,colorScheme:nt,barColors:et,annotations:Ct,decay:Qt,pulse:re,transition:ae,staleness:se,heatmapAggregation:ce,heatmapXBins:ue,heatmapYBins:de,showValues:he,heatmapValueFormat:fe,pointIdAccessor:ge,curve:L}),[b,W,I,O,F,R,M,S,z,$,pe,ve,P,_,D,Ut,T,B,j,Y,N,C,rt,ot,it,lt,at,st,ct,ut,dt,yt,gt,K,Z,Q,tt,J,nt,et,Ct,Qt,re,ae,se,ce,ue,de,he,fe,hn,ge,L]),yn=e(null);yn.current||(yn.current=new zt(fn));const gn=s(()=>{Oe.current||(Oe.current=requestAnimationFrame(()=>sn.current()))},[]);r(()=>{var t;null===(t=yn.current)||void 0===t||t.updateConfig(fn),Ie.current=!0,gn()},[fn,gn]),r(()=>{Ne.current&&wn.delete(Ne.current),Ie.current=!0,gn()},[ze,gn]);const pn=e(null);pn.current||(pn.current=new ft(t=>{const e=yn.current;e&&e.ingest(t)&&(Ie.current=!0,gn())},{chunkThreshold:E,chunkSize:A})),r(()=>{var t;null===(t=pn.current)||void 0===t||t.updateChunkOptions({chunkThreshold:E,chunkSize:A})},[E,A]);const vn=s(t=>{var e;null===(e=pn.current)||void 0===e||e.push(t)},[]),kn=s(t=>{var e;null===(e=pn.current)||void 0===e||e.pushMany(t)},[]),En=s(()=>{var t,e;null===(t=pn.current)||void 0===t||t.clear(),null===(e=yn.current)||void 0===e||e.clear(),Ie.current=!0,gn()},[gn]);u(l,()=>({push:vn,pushMany:kn,remove:t=>{var e,n,r;null===(e=pn.current)||void 0===e||e.flush();const o=null!==(r=null===(n=yn.current)||void 0===n?void 0:n.remove(t))&&void 0!==r?r:[];return o.length>0&&(Ie.current=!0,gn()),o},update:(t,e)=>{var n,r,o;null===(n=pn.current)||void 0===n||n.flush();const i=null!==(o=null===(r=yn.current)||void 0===r?void 0:r.update(t,e))&&void 0!==o?o:[];return i.length>0&&(Ie.current=!0,gn()),i},clear:En,getData:()=>{var t,e,n;return null===(t=pn.current)||void 0===t||t.flush(),null!==(n=null===(e=yn.current)||void 0===e?void 0:e.getData())&&void 0!==n?n:[]},getScales:()=>{var t,e;return null!==(e=null===(t=yn.current)||void 0===t?void 0:t.scales)&&void 0!==e?e:null},getExtents:()=>{var t,e;return null!==(e=null===(t=yn.current)||void 0===t?void 0:t.getExtents())&&void 0!==e?e:null}}),[vn,kn,En,gn]),r(()=>{var t,e;if(w){if(T&&w.length>0&&"object"==typeof w[0]&&null!==w[0]){const e="string"==typeof T?T:"coordinates";if(Array.isArray(w[0][e])){const n=[];for(const t of w){const r=t[e];if(Array.isArray(r)){const e=t.label||t.id||t.key;if(null!=e)for(const t of r)n.push(Object.assign(Object.assign({},t),{_lineGroup:e}));else for(const t of r)n.push(t)}}return void(null===(t=pn.current)||void 0===t||t.setBoundedData(n))}}null===(e=pn.current)||void 0===e||e.setBoundedData(w)}},[w,T]);const An=e(()=>{}),Mn=e(()=>{});An.current=t=>{if(!Ce)return;const e=Ne.current;if(!e)return;const n=e.getBoundingClientRect(),r=t.clientX-n.left-Pe.left,o=t.clientY-n.top-Pe.top;if(0>r||r>_e||0>o||o>De)return void(Ve.current&&(Ve.current=null,qe.current=null,Ke(null),Pt&&(Pt(null),Ie.current=!0),gn()));const i=yn.current;if(!i||0===i.scene.length)return;const l=Ht(i.scene,r,o,Tt,i.quadtree);if(!l)return void(Ve.current&&(Ve.current=null,qe.current=null,Ke(null),Pt&&Pt(null),gn()));const a=l.datum||{},s=Object.assign(Object.assign({},"object"!=typeof a||null===a||Array.isArray(a)?{}:a),{data:a,time:l.x,value:l.y,x:l.x,y:l.y});if("multi"===Lt&&i.scene.length>0&&i.scales){const t=function(t,e,n=30){const r=[];for(const o of t)if("line"===o.type){const t=o;if(2>t.path.length)continue;const i=Xt(t.path,e,n);if(null===i)continue;const l=Jt(t.path,e);r.push({node:o,datum:Array.isArray(t.datum)&&t.datum[l]?t.datum[l]:t.datum,x:t.path[l][0],y:i,group:t.group,color:t.style.stroke})}else if("area"===o.type){const t=o;if(!1===t.interactive)continue;if(2>t.topPath.length)continue;const i=Xt(t.topPath,e,n);if(null===i)continue;const l=Jt(t.topPath,e);r.push({node:o,datum:Array.isArray(t.datum)&&t.datum[l]?t.datum[l]:t.datum,x:t.topPath[l][0],y:i,group:t.group,color:"string"==typeof t.style.stroke?t.style.stroke:"string"==typeof t.style.fill?t.style.fill:void 0})}return r}(i.scene,l.x,Tt),e=i.scales.y.invert,n=i.scales.x.invert;if(t.length>0){const r=n?n(l.x):l.x;s.xValue=r,s.xPx=l.x,s.allSeries=t.map(t=>({group:t.group||"",value:e?e(t.y):t.y,valuePx:t.y,color:t.color||"#007bff",datum:t.datum}))}}Ve.current=s,qe.current=l.node,Ke(s),Pt&&(Pt(s),Ie.current=!0),gn()},Mn.current=()=>{Ve.current&&(Ve.current=null,qe.current=null,Ke(null),Pt&&(Pt(null),Ie.current=!0),gn())},s(t=>An.current(t),[]);const Sn=s(()=>Mn.current(),[]),Pn=e(()=>{});Pn.current=t=>{if(!_t)return;const e=Ne.current;if(!e)return;const n=e.getBoundingClientRect(),r=t.clientX-n.left-Pe.left,o=t.clientY-n.top-Pe.top;if(0>r||r>_e||0>o||o>De)return void _t(null);const i=yn.current;if(!i||0===i.scene.length)return void _t(null);const l=Ht(i.scene,r,o,Tt,i.quadtree);if(!l)return void _t(null);const a=l.datum||{},s=Object.assign(Object.assign({},"object"!=typeof a||null===a||Array.isArray(a)?{}:a),{data:a,time:l.x,value:l.y,x:l.x,y:l.y});_t(s)};const _n=s(t=>Pn.current(t),[]),Dn=e(-1),Tn=e(null),Ln=e(null),Cn=s(t=>{const e=yn.current;if(!e||0===e.scene.length)return;const n=e.version;let r;if(Ln.current&&Ln.current.version===n)r=Ln.current.graph;else{const t=function(t){var e,n,r,o;const i=[];for(const l of t)switch(l.type){case"point":i.push({x:l.x,y:l.y,datum:l.datum,shape:"circle",group:null!==(e=l.group)&&void 0!==e?e:"_default"});break;case"line":{const t=l,e=Array.isArray(t.datum)?t.datum:[],r=null!==(n=t.group)&&void 0!==n?n:"_default";for(let n=0;t.path.length>n&&e.length>n;n++)i.push({x:t.path[n][0],y:t.path[n][1],datum:e[n],shape:"circle",group:r});break}case"area":{const t=l,e=Array.isArray(t.datum)?t.datum:[],n=null!==(r=t.group)&&void 0!==r?r:"_default";for(let r=0;t.topPath.length>r&&e.length>r;r++)i.push({x:t.topPath[r][0],y:t.topPath[r][1],datum:e[r],shape:"circle",group:n});break}case"rect":i.push({x:l.x+l.w/2,y:l.y+l.h/2,datum:l.datum,shape:"rect",w:l.w,h:l.h,group:null!==(o=l.group)&&void 0!==o?o:"_default"});break;case"heatcell":i.push({x:l.x+l.w/2,y:l.y+l.h/2,datum:l.datum,shape:"rect",w:l.w,h:l.h,group:"_default"})}return i.sort((t,e)=>t.x-e.x||t.y-e.y),i}(e.scene);if(0===t.length)return;r=te(t),Ln.current={version:n,graph:r}}const o=Dn.current;if(0>o){if("Escape"===t.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(t.key))return;t.preventDefault(),Dn.current=0;const e=r.flat[0];Tn.current={shape:e.shape,w:e.w,h:e.h};const n=oe(e);return Ve.current=n,Ke(n),Pt&&Pt(n),void gn()}const i=ee(r,o),l=ne(t.key,i,r);if(null===l)return;if(t.preventDefault(),0>l)return Dn.current=-1,Tn.current=null,Ve.current=null,qe.current=null,Ke(null),Pt&&Pt(null),void gn();Dn.current=l;const a=r.flat[l];Tn.current={shape:a.shape,w:a.w,h:a.h};const s=oe(a);Ve.current=s,Ke(s),Pt&&Pt(s),gn()},[Pt,gn]),Nn=s(t=>{Dn.current=-1,Tn.current=null,An.current(t)},[]);sn.current=()=>{var t,e;Oe.current=0;const n=Ne.current,r=$e.current;if(!n||!r)return;const o=yn.current;if(!o)return;const i="undefined"!=typeof performance?performance.now():Date.now(),l=o.advanceTransition(Ae.current?i+1e6:i),a=!Ae.current&&l,s=Ie.current||l;s&&!a&&o.computeScene({width:_e,height:De});const c=bn(),u=function(t){if(!t)return Xn;const e=getComputedStyle(t),n=e.getPropertyValue("--semiotic-border").trim(),r=e.getPropertyValue("--semiotic-text-secondary").trim(),o=e.getPropertyValue("--semiotic-bg").trim(),i=r||e.getPropertyValue("--text-secondary").trim(),l=e.getPropertyValue("--text-primary").trim(),a=n||e.getPropertyValue("--surface-3").trim(),s=o||e.getPropertyValue("--surface-0").trim();return i||l||n?{axisStroke:a||Xn.axisStroke,tickText:i||Xn.tickText,crosshair:i?i+"66":Xn.crosshair,hoverFill:s?s+"4D":Xn.hoverFill,hoverStroke:i?i+"99":Xn.hoverStroke,pointRing:s||Xn.pointRing}:Xn}(n),d=null!==(t=null==se?void 0:se.threshold)&&void 0!==t?t:5e3,h=se&&o.lastIngestTime>0&&i-o.lastIngestTime>d;if(s){const t=xn(n,Se,Pe,c);if(t){t.clearRect(-Pe.left,-Pe.top,Se[0],Se[1]),h&&(t.globalAlpha=null!==(e=null==se?void 0:se.dimOpacity)&&void 0!==e?e:.5);const r=getComputedStyle(n).getPropertyValue("--semiotic-bg").trim(),i=U||(r&&"transparent"!==r?r:null);if(i&&(t.fillStyle=i,t.fillRect(-Pe.left,-Pe.top,Se[0],Se[1])),t.save(),"function"==typeof t.rect&&(t.beginPath(),t.rect(0,0,_e,De),t.clip()),Gt&&o.scales)for(const e of Gt)t.save(),e(t,o.scene,o.scales,{width:_e,height:De}),t.restore();const l=Yn[b];if(l&&o.scales)for(const e of l)e(t,o.scene,o.scales,{width:_e,height:De});t.restore(),h&&(t.globalAlpha=1)}}{const t=xn(r,Se,Pe,c);if(t&&(t.clearRect(-Pe.left,-Pe.top,Se[0],Se[1]),Ce&&Ve.current&&o.scales&&function(t,e,n,r,o,i,l){var a,s;if(!1===o.crosshair)return;const c=e.allSeries,u=c&&c.length>0,d=null!==(a=e.xPx)&&void 0!==a?a:e.x;t.save();const h="object"==typeof o.crosshair?o.crosshair:{};if(t.strokeStyle=h.stroke||l.crosshair,t.lineWidth=h.strokeWidth||1,t.setLineDash(h.strokeDasharray?h.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),t.beginPath(),t.moveTo(u?d:e.x,0),t.lineTo(u?d:e.x,r),t.stroke(),u||(t.beginPath(),t.moveTo(0,e.y),t.lineTo(n,e.y),t.stroke()),t.restore(),u){t.lineWidth=2,t.strokeStyle=l.pointRing;for(const e of c)null!=e.valuePx&&(t.beginPath(),t.arc(d,e.valuePx,4,0,2*Math.PI),t.fillStyle=e.color||"#007bff",t.fill(),t.stroke())}else{let n="";try{(null===(s=t.canvas)||void 0===s?void 0:s.parentElement)&&(n=getComputedStyle(t.canvas).getPropertyValue("--semiotic-primary").trim())}catch(t){}const r=o.pointColor||function(t){if(!t)return null;if("heatcell"===t.type)return t.fill||null;if("candlestick"===t.type)return t.isUp?t.upColor:t.downColor;const{style:e}=t;if(!e)return null;const n="string"==typeof e.fill?e.fill:null;return"line"===t.type||"area"===t.type?e.stroke||n||null:n||e.stroke||null}(i)||n||"#007bff";t.beginPath(),t.arc(e.x,e.y,4,0,2*Math.PI),t.fillStyle=r,t.fill(),t.strokeStyle=l.pointRing,t.lineWidth=2,t.stroke()}}(t,Ve.current,_e,De,"object"==typeof Ce?Ce:{},qe.current,u),qe.current&&Array.isArray(Mt))){const e=Mt.find(t=>t&&"object"==typeof t&&"highlight"===t.type);e&&function(t,e,n,r){var o;if(!n)return;const i=n.group;if(void 0!==i)for(const n of e){if("line"!==n.type)continue;if(n.group!==i)continue;if(2>n.path.length)continue;const e="function"==typeof r.style?r.style(n.datum):r.style||{};t.save(),t.beginPath(),t.moveTo(n.path[0][0],n.path[0][1]);for(let e=1;n.path.length>e;e++)t.lineTo(n.path[e][0],n.path[e][1]);t.strokeStyle=e.stroke||n.style.stroke||"#007bff",t.lineWidth=e.strokeWidth||(n.style.strokeWidth||2)+2,t.globalAlpha=null!==(o=e.opacity)&&void 0!==o?o:1,t.stroke(),t.restore()}}(t,o.scene,qe.current,e)}}s&&n&&n.setAttribute("aria-label",Ge(o.scene,b+" chart"));const f=Ie.current;if(Ie.current=!1,f&&o.scales){const t=t=>"object"==typeof t&&null!==t&&"function"==typeof t.valueOf?t.valueOf():t;if((!He||t(He.x.domain()[0])!==t(o.scales.x.domain()[0])||t(He.x.domain()[1])!==t(o.scales.x.domain()[1])||t(He.y.domain()[0])!==t(o.scales.y.domain()[0])||t(He.y.domain()[1])!==t(o.scales.y.domain()[1])||He.x.range()[0]!==o.scales.x.range()[0]||He.x.range()[1]!==o.scales.x.range()[1]||He.y.range()[0]!==o.scales.y.range()[0]||He.y.range()[1]!==o.scales.y.range()[1])&&Xe(o.scales),ye){const t=o.getData(),e="function"==typeof M?M:t=>t[M||"x"],n="function"==typeof S?S:t=>t[S||"y"];tn(t.map(t=>e(t)).filter(t=>"number"==typeof t&&isFinite(t))),rn(t.map(t=>n(t)).filter(t=>"number"==typeof t&&isFinite(t)))}}f&&Ct&&Ct.length>0&&Ye(t=>t+1),(null==se?void 0:se.showBadge)&&Qe(!!h),(a||o.hasActivePulses)&&(Oe.current=requestAnimationFrame(()=>sn.current()))},r(()=>(gn(),()=>{Oe.current&&(cancelAnimationFrame(Oe.current),Oe.current=0)}),[gn]),r(()=>{Ie.current=!0,gn()},[b,_e,De,pt,U,K,Gt,gn]),le(se,yn,Ie,gn,Ze,Qe);const $n=n(()=>{if(kt||Et)return;const t=yn.current;return(null==t?void 0:t.xIsDate)&&He?Rn(He.x.domain()):void 0},[kt,Et,He]),On=kt||Et||$n,In=Ce&&Ue?St?St(Ue):t.createElement(Vn,{hover:Ue}):null,Wn=In?t.createElement(un,{x:Ue.x,y:Ue.y,containerWidth:_e,containerHeight:De,margin:Pe,className:"stream-frame-tooltip"},In):null,zn=Tn.current,Bn=t.createElement(cn,{active:Dn.current>=0,hoverPoint:Ue,margin:Pe,size:Se,shape:null==zn?void 0:zn.shape,width:null==zn?void 0:zn.w,height:null==zn?void 0:zn.h}),jn=(t,e,n,r)=>"string"==typeof t?{key:t,fn:null}:"function"==typeof t?{key:n,fn:t}:"string"==typeof e?{key:e,fn:null}:"function"==typeof e?{key:r,fn:e}:{key:void 0,fn:null},Fn=jn(M,z,"__semiotic_resolvedX","__semiotic_resolvedTime"),Gn=jn(S,$,"__semiotic_resolvedY","__semiotic_resolvedValue"),qn=Fn.key,Un=Gn.key,Kn=Ct&&Ct.length>0,Zn=t=>{if(!t||!Kn||!Fn.fn&&!Gn.fn)return t;let e=!1;const n=t.map(t=>{const n=Fn.fn&&Fn.key&&!(Fn.key in t),r=Gn.fn&&Gn.key&&!(Gn.key in t);if(!n&&!r)return t;e=!0;const o=Object.assign({},t);return n&&(o[Fn.key]=Fn.fn(t)),r&&(o[Gn.key]=Gn.fn(t)),o});return e?n:t};if(Re){const e=yn.current;e&&w&&(e.ingest({inserts:w,bounded:!0}),e.computeScene({width:_e,height:De}));const n=null!==(a=null==e?void 0:e.scene)&&void 0!==a?a:[],r=null!==(c=null==e?void 0:e.scales)&&void 0!==c?c:null,o=On||(()=>{if((null==e?void 0:e.xIsDate)&&r)return Rn(r.x.domain())})();return t.createElement("div",{className:"stream-xy-frame"+(q?" "+q:""),role:"img","aria-label":xe||("string"==typeof qt?qt:"XY chart"),style:{position:"relative",width:Se[0],height:Se[1]}},t.createElement(on,{summary:be}),t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:Se[0],height:Se[1],style:{position:"absolute",left:0,top:0}},t.createElement("g",{transform:`translate(${Pe.left},${Pe.top})`},Le),t.createElement("g",{transform:`translate(${Pe.left},${Pe.top})`},U&&t.createElement("rect",{x:0,y:0,width:_e,height:De,fill:U}),Vt&&r&&Vt.map((e,o)=>t.createElement(t.Fragment,{key:"svgpre-"+o},e(n,r,{width:_e,height:De}))),n.map((e,n)=>function(e,n){var r,o,i;switch(e.type){case"line":{const r=e;if(0===r.path.length)return null;const o="M"+r.path.map(([t,e])=>`${t},${e}`).join("L");return t.createElement("path",{key:"line-"+n,d:o,fill:"none",stroke:r.style.stroke||"#4e79a7",strokeWidth:r.style.strokeWidth||2,strokeDasharray:r.style.strokeDasharray,opacity:r.style.opacity})}case"area":{const i=e;if(0===i.topPath.length)return null;const l=i.topPath.map(([t,e])=>`${t},${e}`).join("L"),a=[...i.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L");return t.createElement("path",{key:"area-"+n,d:`M${l}L${a}Z`,fill:Fe(i.style.fill),fillOpacity:null!==(o=null!==(r=i.style.fillOpacity)&&void 0!==r?r:i.style.opacity)&&void 0!==o?o:.7,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})}case"point":{const r=e;return t.createElement("circle",{key:"point-"+n,cx:r.x,cy:r.y,r:r.r,fill:Fe(r.style.fill),opacity:null!==(i=r.style.opacity)&&void 0!==i?i:.8,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})}case"rect":{const r=e;return t.createElement("rect",{key:"rect-"+n,x:r.x,y:r.y,width:r.w,height:r.h,fill:Fe(r.style.fill),opacity:r.style.opacity,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})}case"heatcell":{const r=e;if(r.showValues&&null!=r.value&&r.w>=20&&r.h>=20){const e=r.valueFormat?r.valueFormat(r.value):Number.isInteger(r.value)?r.value+"":100>Math.abs(r.value)?1>Math.abs(r.value)?r.value.toPrecision(3):r.value.toFixed(1):r.value.toFixed(0),[o,i,l]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(r.fill),a=.299*o+.587*i+.114*l>128?"#000":"#fff",s=Math.max(10,Math.min(16,.3*Math.min(r.w,r.h)));return t.createElement("g",{key:"heatcell-"+n},t.createElement("rect",{x:r.x,y:r.y,width:r.w,height:r.h,fill:r.fill}),t.createElement("text",{x:r.x+r.w/2,y:r.y+r.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:a,fontSize:s+"px"},e))}return t.createElement("rect",{key:"heatcell-"+n,x:r.x,y:r.y,width:r.w,height:r.h,fill:r.fill})}case"candlestick":{const r=e,o=Math.min(r.openY,r.closeY),i=Math.max(Math.abs(r.openY-r.closeY),1),l=r.isUp?r.upColor:r.downColor;return t.createElement("g",{key:"candle-"+n},t.createElement("line",{x1:r.x,y1:r.highY,x2:r.x,y2:r.lowY,stroke:r.wickColor,strokeWidth:r.wickWidth}),t.createElement("rect",{x:r.x-r.bodyWidth/2,y:o,width:r.bodyWidth,height:i,fill:l,stroke:l,strokeWidth:1}))}default:return null}}(e,n)).filter(Boolean))),t.createElement(je,{width:_e,height:De,totalWidth:Se[0],totalHeight:Se[1],margin:Pe,scales:r,showAxes:pt,axes:vt,xLabel:mt,yLabel:xt,yLabelRight:bt,xFormat:o,yFormat:wt||At,showGrid:$t,title:qt,legend:Ot,legendHoverBehavior:It,legendClickBehavior:Wt,legendHighlightedCategory:Bt,legendIsolatedCategories:jt,legendPosition:Ft,foregroundGraphics:Te,marginalGraphics:ye,xValues:[],yValues:[],annotations:Ct,svgAnnotationRules:Nt,annotationFrame:0,xAccessor:qn,yAccessor:Un,annotationData:Zn(null==e?void 0:e.getData()),pointNodes:null==e?void 0:e.scene.filter(t=>"point"===t.type),curve:"string"==typeof L?L:void 0,linkedCrosshairName:ke,linkedCrosshairSourceId:we}))}const Qn="semiotic-table-"+t.useId();return t.createElement("div",{ref:Me,className:"stream-xy-frame"+(q?" "+q:""),role:"group","aria-label":xe||("string"==typeof qt?qt:"XY chart"),tabIndex:0,style:{position:"relative",width:X?"100%":Se[0],height:G?"100%":Se[1],overflow:"visible"},onKeyDown:Cn},me&&t.createElement(ln,{tableId:Qn}),me&&t.createElement(nn,{scene:null!==(h=null===(d=yn.current)||void 0===d?void 0:d.scene)&&void 0!==h?h:[],chartType:b+" chart",tableId:Qn,chartTitle:"string"==typeof qt?qt:void 0}),t.createElement(on,{summary:be}),t.createElement("div",{role:"img","aria-label":xe||("string"==typeof qt?qt:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:Ce?Nn:void 0,onMouseLeave:Ce?Sn:void 0,onClick:_t?_n:void 0},Le&&t.createElement("svg",{style:{position:"absolute",left:0,top:0,width:Se[0],height:Se[1],pointerEvents:"none"}},t.createElement("g",{transform:`translate(${Pe.left},${Pe.top})`},Le)),t.createElement(We,{width:_e,height:De,totalWidth:Se[0],totalHeight:Se[1],margin:Pe,scales:He,showAxes:pt,axes:vt,showGrid:$t,xFormat:On,yFormat:wt||At}),t.createElement("canvas",{ref:Ne,"aria-label":Ge(null!==(y=null===(f=yn.current)||void 0===f?void 0:f.scene)&&void 0!==y?y:[],b+" chart"),style:{position:"absolute",left:0,top:0}}),t.createElement("canvas",{ref:$e,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),t.createElement(an,{hoverPoint:Ue}),t.createElement(je,{width:_e,height:De,totalWidth:Se[0],totalHeight:Se[1],margin:Pe,scales:He,showAxes:pt,axes:vt,xLabel:mt,yLabel:xt,yLabelRight:bt,xFormat:On,yFormat:wt||At,showGrid:$t,title:qt,legend:Ot,legendHoverBehavior:It,legendClickBehavior:Wt,legendHighlightedCategory:Bt,legendIsolatedCategories:jt,legendPosition:Ft,foregroundGraphics:Te,marginalGraphics:ye,xValues:Je,yValues:en,annotations:Ct,svgAnnotationRules:Nt,annotationFrame:Be,xAccessor:qn,yAccessor:Un,annotationData:Zn(null===(g=yn.current)||void 0===g?void 0:g.getData()),pointNodes:null===(p=yn.current)||void 0===p?void 0:p.scene.filter(t=>"point"===t.type),curve:"string"==typeof L?L:void 0,underlayRendered:!0,linkedCrosshairName:ke,linkedCrosshairSourceId:we}),(Kt||Zt)&&t.createElement(ht,{width:_e,height:De,totalWidth:Se[0],totalHeight:Se[1],margin:Pe,dimension:null!==(v=null==Kt?void 0:Kt.dimension)&&void 0!==v?v:"xy",scales:He,onBrush:null!=Zt?Zt:()=>{},binSize:N,snap:null==Kt?void 0:Kt.snap,binBoundaries:null!==(m=null==Kt?void 0:Kt.binBoundaries)&&void 0!==m?m:"bar"===b?null===(x=yn.current)||void 0===x?void 0:x.getBinBoundaries():void 0,snapDuring:null==Kt?void 0:Kt.snapDuring,streaming:"streaming"===k}),(null==se?void 0:se.showBadge)&&t.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===se.badgePosition?{top:4,left:4}:"bottom-left"===se.badgePosition?{bottom:4,left:4}:"bottom-right"===se.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:Ze?"#dc3545":"#28a745",color:"white"})},Ze?"STALE":"LIVE"),Bn,Wn))});qn.displayName="StreamXYFrame";const Un={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},Kn={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class Zn{constructor(t){this.capacity=t,this.particles=Array(t);for(let e=0;t>e;e++)this.particles[e]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0}}spawn(t){for(let e=0;this.capacity>e;e++){const n=this.particles[e];if(!n.active)return n.active=!0,n.t=0,n.offset=Math.random()-.5,n.edgeIndex=t,n.x=0,n.y=0,n}return null}step(t,e,n,r){var o;for(let i=0;this.capacity>i;i++){const l=this.particles[i];if(!l.active)continue;const a=n[l.edgeIndex];if(!a||!a.bezier){l.active=!1;continue}const s=r&&null!==(o=r[l.edgeIndex])&&void 0!==o?o:1;if(l.t+=t*e*s*(a.bezier.circular?.3:1),l.t>=1){l.active=!1;continue}const c=Qn(a.bezier,l.t,l.offset);l.x=c.x,l.y=c.y}}countForEdge(t){let e=0;for(let n=0;this.capacity>n;n++)this.particles[n].active&&this.particles[n].edgeIndex===t&&e++;return e}clear(){for(let t=0;this.capacity>t;t++)this.particles[t].active=!1}resize(t){if(this.capacity>=t)return;const e=this.particles;this.particles=Array(t);for(let n=0;t>n;n++)this.particles[n]=e.length>n?e[n]:{t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0};this.capacity=t}}function Qn(t,e,n){if(t.circular&&t.segments)return function(t,e,n,r){const o=t.length,i=e*o,l=Math.min(Math.floor(i),o-1),a=i-l,[s,c,u,d]=t[l],h=Jn(s,c,u,d,a),f=d.x-s.x,y=d.y-s.y,g=Math.sqrt(f*f+y*y);if(g>.001){const t=f/g;h.x+=-y/g*n*r*2,h.y+=t*n*r*2}return h}(t.segments,e,n,t.halfWidth);if(!t.points)return{x:0,y:0};const[r,o,i,l]=t.points,a=Jn(r,o,i,l,e),s=l.x-r.x,c=l.y-r.y,u=Math.sqrt(s*s+c*c);if(u>.001){const e=s/u;a.x+=-c/u*n*t.halfWidth*2,a.y+=e*n*t.halfWidth*2}return a}function Jn(t,e,n,r,o){const i=1-o,l=i*i,a=l*i,s=o*o,c=s*o;return{x:a*t.x+3*l*o*e.x+3*i*s*n.x+c*r.x,y:a*t.y+3*l*o*e.y+3*i*s*n.y+c*r.y}}function tr(t,e){var n=t.get(e);if(!n)throw Error("missing: "+e);return n}function er(t,e){var n,r=[],o=[],i=[],l={},a=[];function s(t){i[t]=!1,l.hasOwnProperty(t)&&Object.keys(l[t]).forEach(function(e){delete l[t][e],i[e]&&s(e)})}function c(t){var e,r,d=!1;for(o.push(t),i[t]=!0,e=0;a[t].length>e;e++)(r=a[t][e])===n?(u(n,o),d=!0):i[r]||(d=c(r));if(d)s(t);else for(e=0;a[t].length>e;e++){var h=l[r=a[t][e]];h||(l[r]=h={}),h[r]=!0}return o.pop(),d}function u(t,e){var n=[].concat(e).concat(t);r.push(n)}function d(e){!function(e){for(var n=0;t.length>n;n++)n>=e&&t[n]||(t[n]=[]),t[n]=t[n].filter(function(t){return t>=e})}(e);for(var n,r=function(t){for(var e=t.length,n=Array(e),r=Array(e),o=Array(e),i=Array(e),l=Array(e),a=Array(e),s=0;e>s;++s)n[s]=-1,r[s]=0,o[s]=!1,i[s]=0,l[s]=-1,a[s]=[];var c,u=0,d=[],h=[];function f(e){var s=[e],c=[e];for(n[e]=r[e]=u,o[e]=!0,u+=1;c.length>0;){var f=t[e=c[c.length-1]];if(f.length>i[e]){for(var y=i[e];f.length>y;++y){var g=f[y];if(0>n[g]){n[g]=r[g]=u,o[g]=!0,u+=1,s.push(g),c.push(g);break}o[g]&&(r[e]=0|Math.min(r[e],r[g])),0>l[g]||a[e].push(l[g])}i[e]=y}else{if(r[e]===n[e]){var p=[],v=[],m=0;for(y=s.length-1;y>=0;--y){var x=s[y];if(o[x]=!1,p.push(x),v.push(a[x]),m+=a[x].length,l[x]=d.length,x===e){s.length=y;break}}d.push(p);var b=Array(m);for(y=0;v.length>y;y++)for(var k=0;v[y].length>k;k++)b[--m]=v[y][k];h.push(b)}c.pop()}}}for(s=0;e>s;++s)0>n[s]&&f(s);for(s=0;h.length>s;s++){var y=h[s];if(0!==y.length){y.sort(function(t,e){return t-e}),c=[y[0]];for(var g=1;y.length>g;g++)y[g]!==y[g-1]&&c.push(y[g]);h[s]=c}}return{components:d,adjacencyList:h}}(t),o=r.components.filter(function(t){return t.length>1}),i=1/0,l=0;o.length>l;l++)for(var a=0;o[l].length>a;a++)i>o[l][a]&&(i=o[l][a],n=l);var s=o[n];if(!s)return!1;var c=t.map(function(t,e){return-1===s.indexOf(e)?[]:t.filter(function(t){return-1!==s.indexOf(t)})});return{leastVertex:i,adjList:c}}n=0;for(var h=t.length;h>n;){var f=d(n);if(n=f.leastVertex,a=f.adjList){for(var y=0;a.length>y;y++)for(var g=0;a[y].length>g;g++){var p=a[y][g];i[+p]=!1,l[p]={}}c(n),n+=1}else n=h}return r}function nr(t){return t.y0-t.y1>0?"up":"down"}function rr(t,e){return e(t.source)==e(t.target)}function or(t){var e=0;t.source.sourceLinks.forEach(function(t){e=t.circular?e+1:e});var n=0;return t.target.targetLinks.forEach(function(t){n=t.circular?n+1:n}),1>=e&&1>=n}function ir(t){return t.target.x0-t.source.x1}function lr(t,e){var n=sr(t),r=ir(e)/Math.tan(n);return"up"==nr(t)?t.y1-r:t.y1+r}function ar(t,e){var n=sr(t),r=ir(e)/Math.tan(n);return"up"==nr(t)?t.y1+r:t.y1-r}function sr(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function cr(t,e){return e(t)}function ur(t){return hr(t.source)}function dr(t){return hr(t.target)}function hr(t){return(t.y0+t.y1)/2}function fr(t){return t.virtual?0:t.value}function yr(t,e){var n=0;t.sourceLinks.forEach(function(t){n=t.circular&&!rr(t,e)?n+1:n});var r=0;return t.targetLinks.forEach(function(t){r=t.circular&&!rr(t,e)?r+1:r}),n+r}function gr(t){return t.target.depth}function pr(t,e){return t.sourceLinks.length?t.depth:e-1}function vr(t,e){return t.y0-e.y0}function mr(t,e){return e.y0-t.y0}function xr(t,e){return t.y1-e.y1}function br(t,e){return e.y1-t.y1}function kr(t,e){return Er(t.source,e.source)||t.index-e.index}function wr(t,e){return Er(t.target,e.target)||t.index-e.index}function Er(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function Ar(t,e){return Mr(t)==Mr(e)?"bottom"==t.circularLinkType?mr(t,e):vr(t,e):Mr(e)-Mr(t)}function Mr(t){return t.target.column-t.source.column}function Sr(t,e){return Pr(t)==Pr(e)}function Pr(t){return t.y0-t.y1>0?"up":"down"}function _r(t,e,n,r,o){let i=t;var l=Math.max(8,.15*(i.y1-i.y0));i.links.forEach(function(t){t.circular&&(t._circularWidth=Math.min(t.width,l))});var a=S(i.links,function(t){return t.source.y0});i.links.forEach(function(t){t.circular&&(t.circularPathData={})});var s=i.links.filter(function(t){return t.circular});return s.sort(function(t,e){return e.value-t.value}),s.forEach(function(t,e){t._circularStub=e>=4}),Dr(i.links.filter(function(t){return"top"==t.circularLinkType}),e,n),Dr(i.links.filter(function(t){return"bottom"==t.circularLinkType}),e,n),i.links.forEach(function(t){if(t.circular){if(t.circularPathData.arcRadius=t._circularWidth+r,t.circularPathData.rightNodeBuffer=5,t.circularPathData.leftNodeBuffer=5,t.circularPathData.sourceWidth=t.source.x1-t.source.x0,t.circularPathData.sourceX=t.source.x0+t.circularPathData.sourceWidth,t.circularPathData.targetX=t.target.x0,t.circularPathData.sourceY=t.y0,t.circularPathData.targetY=t.y1,rr(t,e)&&or(t))t.circularPathData.rightSmallArcRadius=r+t._circularWidth/2,t.circularPathData.rightLargeArcRadius=r+t._circularWidth/2,t.circularPathData.leftSmallArcRadius=r+t._circularWidth/2,t.circularPathData.leftLargeArcRadius=r+t._circularWidth/2,"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=t.source.y1+o+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=t.source.y0-o-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius);else{var l=t.source.column,s=t.circularLinkType,c=i.links.filter(function(t){return t.source.column==l&&t.circularLinkType==s});c.sort("bottom"==t.circularLinkType?mr:vr);var u=0;c.forEach(function(e,o){e.circularLinkID==t.circularLinkID&&(t.circularPathData.rightSmallArcRadius=r+t._circularWidth/2+u,t.circularPathData.rightLargeArcRadius=r+t._circularWidth/2+o*n+u),u+=e._circularWidth||e.width}),l=t.target.column,(c=i.links.filter(function(t){return t.target.column==l&&t.circularLinkType==s})).sort("bottom"==t.circularLinkType?br:xr),u=0,c.forEach(function(e,o){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=r+t._circularWidth/2+u,t.circularPathData.leftLargeArcRadius=r+t._circularWidth/2+o*n+u),u+=e._circularWidth||e.width}),"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=Math.max(i.y1,t.source.y1,t.target.y1)+o+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=a-o-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius)}t.circularPathData.rightInnerExtent=t.circularPathData.sourceX+t.circularPathData.rightNodeBuffer,t.circularPathData.leftInnerExtent=t.circularPathData.targetX-t.circularPathData.leftNodeBuffer,t.circularPathData.rightFullExtent=t.circularPathData.sourceX+t.circularPathData.rightLargeArcRadius+t.circularPathData.rightNodeBuffer,t.circularPathData.leftFullExtent=t.circularPathData.targetX-t.circularPathData.leftLargeArcRadius-t.circularPathData.leftNodeBuffer}t.path=t.circular?function(t){return"top"==t.circularLinkType?"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 0 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY-t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 0 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 0 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY-t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 0 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY:"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 1 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY+t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 1 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 1 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY+t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 1 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY}(t):function(t){var e=t.source.x1,n=t.y0,r=t.target.x0,o=t.y1,i=(e+r)/2;return"M"+e+","+n+"C"+i+","+n+" "+i+","+o+" "+r+","+o}(t)}),i}function Dr(t,e,n){t.sort(Ar);var r=t.filter(function(t){return!t._circularStub});return t.forEach(function(t,o){var i=0;if(t._circularStub)t.circularPathData.verticalBuffer=0;else if(rr(t,e)&&or(t))t.circularPathData.verticalBuffer=i+t._circularWidth/2;else{for(var l=0;r.length>l;l++){var a=r[l];if(a!==t&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&Tr(t,a)){var s=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+n;i=s>i?s:i}}t.circularPathData.verticalBuffer=i+t._circularWidth/2}}),t}function Tr(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}function Lr(t){return function(){return t}}function Cr(t){return t.index}function Nr(t){return t.nodes}function $r(t){return t.links}function Or(t,e,n){var r=P(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});r.forEach(function(o,i){var l=o.length;if(e)o.sort(e);else if(i>0){var a=new Map;o.forEach(function(t,e){var n,r,o,i=(r=0,o=0,(n=t).targetLinks.forEach(function(t){if(!t.circular){var e=t.value||1;o+=hr(t.source)*e,r+=e}}),n.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;o+=hr(t.target)*e,r+=e}}),r>0?o/r:NaN);a.set(t,{bc:i,idx:e})}),o.sort(function(t,e){var n=a.get(t),r=a.get(e),o=n.bc,i=r.bc;if(t.circularLinkType!==e.circularLinkType){if("top"==t.circularLinkType&&"bottom"==e.circularLinkType)return-1;if("bottom"==t.circularLinkType&&"top"==e.circularLinkType)return 1;if("top"==t.circularLinkType)return-1;if("top"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return-1}return isNaN(o)||isNaN(i)?isNaN(o)?isNaN(i)?n.idx-r.idx:1:-1:o-i})}else o.sort(function(t,e){return t.circularLinkType==e.circularLinkType?yr(e,n)-yr(t,n):"top"==t.circularLinkType&&"bottom"==e.circularLinkType||"top"==t.circularLinkType&&0==e.partOfCycle||0==t.partOfCycle&&"bottom"==e.circularLinkType?-1:0});o.forEach(function(e,o){e.depth==r.length-1&&1==l||0==e.depth&&1==l?(e.y0=t.y1/2-e.value*t.ky,e.y1=e.y0+e.value*t.ky):e.partOfCycle?0==yr(e,n)?(e.y0=t.y1/2+o,e.y1=e.y0+e.value*t.ky):"top"==e.circularLinkType?(e.y0=t.y0+o,e.y1=e.y0+e.value*t.ky):(e.y0=t.y1-e.value*t.ky-o,e.y1=e.y0+e.value*t.ky):0==t.y0||0==t.y1?(e.y0=(t.y1-t.y0)/l*o,e.y1=e.y0+e.value*t.ky):(e.y0=(t.y1-t.y0)/2-l/2+o,e.y1=e.y0+e.value*t.ky)})})}function Ir(t,e,n,r,o,i){var l=P(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});u();for(var a=1,s=i;s>0;--s)c(a*=.99,n),u();function c(e,n){var r=l.length;l.forEach(function(o){var i=o.length,l=o[0].depth;o.forEach(function(o){var a;if(o.sourceLinks.length||o.targetLinks.length)if(o.partOfCycle&&yr(o,n)>0){var s=T(o.sourceLinks,dr),c=T(o.targetLinks,ur),u=s&&c?(s+c)/2:s||c;if(u){var d=(u-hr(o))*e*.3;o.y0+=d,o.y1+=d}}else if(0==l&&1==i)o.y0=t.y1/2-(a=o.y1-o.y0)/2,o.y1=t.y1/2+a/2;else if(l==r-1&&1==i)o.y0=t.y1/2-(a=o.y1-o.y0)/2,o.y1=t.y1/2+a/2;else if(1==o.targetLinks.length&&1==o.targetLinks[0].source.sourceLinks.length)a=o.y1-o.y0,o.y0=o.targetLinks[0].source.y0,o.y1=o.y0+a;else{var h=T(o.sourceLinks,dr),f=T(o.targetLinks,ur),y=((h&&f?(h+f)/2:h||f)-hr(o))*e;o.y0+=y,o.y1+=y}})})}function u(){l.forEach(function(n){var i,l,a,s=t.y0,c=n.length;for(n.sort(e||Er),a=0;c>a;++a)(l=s-(i=n[a]).y0)>0&&(i.y0+=l,i.y1+=l),s=i.y1+r;if((l=s-r-t.y1)>0)for(s=i.y0-=l,i.y1-=l,a=c-2;a>=0;--a)(l=(i=n[a]).y1+o-s)>0&&(i.y0-=l,i.y1-=l),s=i.y0})}}function Wr(t){t.nodes.forEach(function(t){t.sourceLinks.sort(wr),t.targetLinks.sort(kr)}),t.nodes.forEach(function(t){var e=t.y0,n=e,r=t.y1,o=r;t.sourceLinks.forEach(function(t){t.circular?(t.y0=r-t.width/2,r-=t.width):(t.y0=e+t.width/2,e+=t.width)}),t.targetLinks.forEach(function(t){t.circular?(t.y1=o-t.width/2,o-=t.width):(t.y1=n+t.width/2,n+=t.width)})})}function zr(){var t=0,e=0,n=1,r=1,o=24,i=8,l=null,a=Cr,s=pr,c=void 0,u=32,d=2,h=Nr,f=$r;function y(){var y={nodes:h.apply(null,arguments),links:f.apply(null,arguments)};return function(h){h.x0=t,h.y0=e,h.x1=n,h.y1=r,h.py=0,function(t,e){t.nodes.forEach(function(t,e){t.index=e,t.sourceLinks=[],t.targetLinks=[]});var n=function(t,e){var n=new Map;return L(t,e).forEach(function(t,e){n.set(e,t[0])}),n}(t.nodes,e);t.links.forEach(function(t,e){t.index=e;var r=t.source,o=t.target;"object"!=typeof r&&(r=t.source=tr(n,r)),"object"!=typeof o&&(o=t.target=tr(n,o)),r.sourceLinks.push(t),o.targetLinks.push(t)})}(h,a),function(t,e){var n=0;if(null==e){for(var r=[],o=0;t.links.length>o;o++){var i=t.links[o],l=i.source.index,a=i.target.index;r[l]||(r[l]=[]),r[a]||(r[a]=[]),-1===r[l].indexOf(a)&&r[l].push(a)}var s=er(r);s.sort(function(t,e){return t.length-e.length});var c={};for(o=0;s.length>o;o++){var u=s[o].slice(-2);c[u[0]]||(c[u[0]]={}),c[u[0]][u[1]]=!0}t.links.forEach(function(t){var e=t.target.index,r=t.source.index;e===r||c[r]&&c[r][e]?(t.circular=!0,t.circularLinkID=n++):t.circular=!1})}else t.links.forEach(function(t){e(t.source)<e(t.target)?t.circular=!1:(t.circular=!0,t.circularLinkID=n++)})}(h,c),function(t,e){var n=0,r=0;t.links.forEach(function(o){o.circular&&(o.circularLinkType=o.source.circularLinkType||o.target.circularLinkType?o.source.circularLinkType?o.source.circularLinkType:o.target.circularLinkType:r>n?"top":"bottom","top"==o.circularLinkType?n++:r++,t.nodes.forEach(function(t){cr(t,e)!=cr(o.source,e)&&cr(t,e)!=cr(o.target,e)||(t.circularLinkType=o.circularLinkType)}))}),t.links.forEach(function(t){t.circular&&(t.source.circularLinkType==t.target.circularLinkType&&(t.circularLinkType=t.source.circularLinkType),rr(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(h,a),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max(D(t.sourceLinks,fr),D(t.targetLinks,fr)),t.sourceLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)}),t.targetLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)})})}(h),function(t,e,n){var r,o,i;if(null!=e){t.nodes.sort(function(t,n){return e(t)<e(n)?-1:1});var l=0,a=e(t.nodes[0]);t.nodes.forEach(function(t){l=e(t)==a?l:l+1,a=e(t)==a?a:e(t),t.column=l})}for(r=t.nodes,o=[],i=0;r.length;++i,r=o,o=[])r.forEach(function(t){t.depth=i,t.sourceLinks.forEach(function(t){0>o.indexOf(t.target)&&!t.circular&&o.push(t.target)})});for(r=t.nodes,o=[],i=0;r.length;++i,r=o,o=[])r.forEach(function(t){t.height=i,t.targetLinks.forEach(function(t){0>o.indexOf(t.source)&&!t.circular&&o.push(t.source)})});t.nodes.forEach(function(t){t.column=null==e?n(t,i):t.column})}(h,c,s);var f=i;if(null!==l){var y=P(h.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),g=_(y,function(t){return t.length});g>1&&(f=Math.max(1,(r-e)*l/(g-1)))}(function(t,e,n){var r=P(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});t.py=e;var o=S(r,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/D(e,function(t){return t.value})});t.ky=o,t.links.forEach(function(e){e.width=e.value*t.ky});var i=_(t.nodes,function(t){return t.column});t.nodes.forEach(i>0?function(e){e.x0=t.x0+e.column*((t.x1-t.x0-n)/i),e.x1=e.x0+n}:function(e){e.x0=t.x0,e.x1=e.x0+n})})(h,f,o),Or(h,c,a),Ir(h,c,a,f,f,u),Wr(h),_r(h,a,d,10,8),Or(h,c,a),Ir(h,c,a,f,f,u),Wr(h),_r(h,a,d,10,8),function(t,e){let n=t;n.nodes.forEach(function(t){t.y+(t.y1-t.y0)>n.y1&&(t.y=t.y-(t.y+(t.y1-t.y0)-n.y1));var r=n.links.filter(function(n){return cr(n.source,e)==cr(t,e)}),o=r.length;o>1&&r.sort(function(t,e){if(!t.circular&&!e.circular){if(t.target.column==e.target.column)return t.y1-e.y1;if(!Sr(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var n=lr(e,t);return t.y1-n}if(e.target.column>t.target.column)return lr(t,e)-e.y1}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.target.column===e.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.target.column===e.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:"top"==t.circularLinkType?-1:1:void 0});var i=t.y0;r.forEach(function(t){t.y0=i+t.width/2,i+=t.width}),r.forEach(function(e,n){if("bottom"==e.circularLinkType){for(var i=n+1,l=0;o>i;i++)l+=r[i].width;e.y0=t.y1-l-e.width/2}})})}(h,a),function(t,e){let n=t;n.nodes.forEach(function(t){var r=n.links.filter(function(n){return cr(n.target,e)==cr(t,e)}),o=r.length;o>1&&r.sort(function(t,e){if(!t.circular&&!e.circular){if(t.source.column==e.source.column)return t.y0-e.y0;if(!Sr(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var n=ar(e,t);return t.y0-n}if(e.source.column>t.source.column)return ar(t,e)-e.y0}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:t.source.column-e.source.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:e.source.column-t.source.column:"top"==t.circularLinkType?-1:1:void 0});var i=t.y0;r.forEach(function(t){t.y1=i+t.width/2,i+=t.width}),r.forEach(function(e,n){if("bottom"==e.circularLinkType){for(var i=n+1,l=0;o>i;i++)l+=r[i].width;e.y1=t.y1-l-e.width/2}})})}(h,a),function(t){var e=t.nodes,n=t.links,r=!1,o=!1;if(n.forEach(function(t){"top"==t.circularLinkType?r=!0:"bottom"==t.circularLinkType&&(o=!0)}),0==r||0==o){var i=S(e,function(t){return t.y0}),l=_(e,function(t){return t.y1}),a=(t.y1-t.y0)/(l-i);function s(e){return(e-i)/(l-i)*(t.y1-t.y0)+t.y0}1>a?(e.forEach(function(t){t.y0=s(t.y0),t.y1=s(t.y1)}),n.forEach(function(t){t.y0=s(t.y0),t.y1=s(t.y1),t.width=t.width*a})):e.forEach(function(t){var e=t.y1-t.y0,n=s(t.y0)-t.y0;t.y0=s(t.y0),t.y1=t.y0+e,t.sourceLinks.forEach(function(t){t.y0=t.y0+n}),t.targetLinks.forEach(function(t){t.y1=t.y1+n})})}}(h),_r(h,a,d,10,8)}(y),y}return y.update=function(t){return Wr(t),_r(t,a,d,10,8),t},y.nodeWidth=function(t){return arguments.length?(o=+t,y):o},y.nodePadding=function(t){return arguments.length?(i=+t,y):i},y.nodePaddingRatio=function(t){return arguments.length?(l=+t,y):l},y.nodes=function(t){return arguments.length?(h="function"==typeof t?t:Lr(t),y):h},y.links=function(t){return arguments.length?(f="function"==typeof t?t:Lr(t),y):f},y.nodeId=function(t){return arguments.length?(a="function"==typeof t?t:Lr(t),y):a},y.nodeAlign=function(t){return arguments.length?(s="function"==typeof t?t:Lr(t),y):s},y.nodeSort=function(t){return arguments.length?(c=t,y):c},y.iterations=function(t){return arguments.length?(u=+t,y):u},y.circularLinkGap=function(t){return arguments.length?(d=+t,y):d},y.extent=function(o){return arguments.length?(t=+o[0][0],e=+o[0][1],n=+o[1][0],r=+o[1][1],y):[[t,e],[n,r]]},y.size=function(o){return arguments.length?(t=e=0,n=+o[0],r=+o[1],y):[n-t,r-e]},y}const Br=t=>{let e,n,r,o,i,l,a,s,c;return"down"===t.direction?(e=t.y0-t.sankeyWidth/2,n=t.y1-t.sankeyWidth/2,r=t.y1+t.sankeyWidth/2,o=t.y0+t.sankeyWidth/2,i=t.source.x1,l=t.target.x0,a=et(i,l),s=a(.5),c=a(.5),`M${e},${i}C${e},${s} ${n},${c} ${n},${l}L${r},${l}C${r},${c} ${o},${s} ${o},${i}Z`):(e=t.source.x1,n=t.target.x0,a=et(e,n),r=a(.5),o=a(.5),i=t.y0-t.sankeyWidth/2,l=t.y1-t.sankeyWidth/2,s=t.y1+t.sankeyWidth/2,c=t.y0+t.sankeyWidth/2,`M${e},${i}C${r},${i} ${o},${l} ${n},${l}L${n},${s}C${o},${s} ${r},${c} ${e},${c}Z`)};function jr(t){var e;const n=t.sankeyWidth/2,r=(null!==(e=t._circularWidth)&&void 0!==e?e:t.sankeyWidth)/2,o=t.circularPathData;if(!o)return null;if("down"===t.direction)return null;if(t._circularStub){const e=o.sourceX,r=o.sourceY,i=o.targetX,l=o.targetY;if("object"!=typeof t.source||!t.source||"object"!=typeof t.target||!t.target)return null;const a=Math.max(15,Math.min(40,.33*(o.rightFullExtent-e))),s=Math.max(15,Math.min(40,.33*(i-o.leftFullExtent)));return`M${e},${r-n}L${e+a},${r-n}L${e+a},${r+n}L${e},${r+n}ZM${i},${l-n}L${i-s},${l-n}L${i-s},${l+n}L${i},${l+n}Z`}const i=o.sourceX,l=o.sourceY,a=o.targetX,s=o.targetY,c=o.rightFullExtent,u=o.leftFullExtent,d=o.verticalFullExtent,h="bottom"===t.circularLinkType?1:-1,f=Math.max(4,Math.min(r,15));return`M${i},${l-h*n}L${c},${l-h*n}L${c+r},${l-h*n+h*f}L${c+r},${d+h*r-h*f}L${c+r-f},${d+h*r}L${u-r+f},${d+h*r}L${u-r},${d+h*r-h*f}L${u-r},${s-h*n+h*f}L${u-r+f},${s-h*n}L${a},${s-h*n}L${a},${s+h*n}L${u+r},${s+h*n}L${u+r},${d-h*r}L${c-r},${d-h*r}L${c-r},${l+h*n}L${i},${l+h*n}Z`}const Fr=new Set,Rr=new WeakMap;function Yr(t,e){if("production"===process.env.NODE_ENV)return t;if(!t||!t.data||"object"!=typeof t.data)return t;let n=Rr.get(t);if(n){const t=n.get(e);if(t)return t}else n=new Map,Rr.set(t,n);const r=new Proxy(t,{get(t,n,r){if("string"==typeof n&&!(n in t)&&t.data&&n in t.data){const t=`${e}:${n}`;Fr.has(t)||(Fr.add(t),console.warn(`[Semiotic] "${e}" callback accessed "${n}" on the wrapper object, but it only exists on ".data". Use d.data.${n} (or d.data?.${n}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(t,n,r)}});return n.set(e,r),r}const Hr={left:function(t){return t.depth},right:function(t,e){return e-1-t.height},center:function(t){return t.targetLinks.length?t.depth:t.sourceLinks.length?Math.min.apply(Math,t.sourceLinks.map(gr))-1:0},justify:pr},Xr={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,r){var o,i,l,a,s,c,u;if(0===t.length)return;const d="vertical"===n.orientation?"down":"right",h=n.nodeAlign||"justify",f=null!==(o=n.nodeWidth)&&void 0!==o?o:15,y=null!==(i=n.nodePaddingRatio)&&void 0!==i?i:.05,g=null!==(l=n.iterations)&&void 0!==l?l:100,p=t.map(t=>Object.assign({},t)),v=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id,value:Math.sqrt(Math.max(1,t.value||1))}));let m;m="down"===d?[[0,0],[r[1],r[0]]]:[[0,0],[r[0],r[1]]];const x=zr().extent(m).links(v).nodes(p).nodeAlign(Hr[h]||pr).nodeId(t=>t.id).nodeWidth(f).iterations(g);x.nodePaddingRatio&&x.nodePaddingRatio(y),x();{let t=1/0,e=-1/0,n=1/0,o=-1/0;for(const r of p)t>r.x0&&(t=r.x0),r.x1>e&&(e=r.x1),n>r.y0&&(n=r.y0),r.y1>o&&(o=r.y1);for(const r of v){if(!r.circular||!r.circularPathData)continue;const i=r.circularPathData,l=(null!==(s=null!==(a=r._circularWidth)&&void 0!==a?a:r.width)&&void 0!==s?s:0)/2;t>i.leftFullExtent-l&&(t=i.leftFullExtent-l),i.rightFullExtent+l>e&&(e=i.rightFullExtent+l),n>i.verticalFullExtent-l&&(n=i.verticalFullExtent-l),i.verticalFullExtent+l>o&&(o=i.verticalFullExtent+l)}const i=e-t,l=o-n,u=r[0],d=r[1];if(i>0&&l>0&&(0>t||0>n||e>u||o>d)){const e=Math.min(u/i,d/l),r=-t*e+(u-i*e)/2,o=-n*e+(d-l*e)/2;for(const t of p)t.x0=t.x0*e+r,t.x1=t.x1*e+r,t.y0=t.y0*e+o,t.y1=t.y1*e+o;for(const t of v)if(t.y0=t.y0*e+o,t.y1=t.y1*e+o,t.width=(null!==(c=t.width)&&void 0!==c?c:0)*e,t._circularWidth&&(t._circularWidth*=e),t.circular&&t.circularPathData){const n=t.circularPathData;n.sourceX=n.sourceX*e+r,n.targetX=n.targetX*e+r,n.sourceY=n.sourceY*e+o,n.targetY=n.targetY*e+o,n.rightFullExtent=n.rightFullExtent*e+r,n.leftFullExtent=n.leftFullExtent*e+r,n.verticalFullExtent=n.verticalFullExtent*e+o,n.rightInnerExtent=n.rightInnerExtent*e+r,n.leftInnerExtent=n.leftInnerExtent*e+r,n.verticalRightInnerExtent=n.verticalRightInnerExtent*e+o,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*e+o,n.rightSmallArcRadius*=e,n.rightLargeArcRadius*=e,n.leftSmallArcRadius*=e,n.leftLargeArcRadius*=e,n.sourceWidth*=e,n.rightNodeBuffer*=e,n.leftNodeBuffer*=e,n.arcRadius*=e}}}const b=new Map;for(const e of t)b.set(e.id,e);for(const t of p){const e=b.get(t.id);e&&(e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.value=t.value,e.depth=t.depth,e.sourceLinks=t.sourceLinks,e.targetLinks=t.targetLinks,e.width=t.x1-t.x0,e.height=t.y1-t.y0,e.x=t.x0+(t.x1-t.x0)/2,e.y=t.y0+(t.y1-t.y0)/2)}const k=new Map;for(const t of e)k.set(t._edgeKey?t._edgeKey:`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const t of v){const e=t.source,n=t.target,r="object"==typeof e&&null!==e?e.id:e+"",o="object"==typeof n&&null!==n?n.id:n+"",i=k.get(t._edgeKey?t._edgeKey:`${r}\0${o}`);if(i){i.y0=t.y0,i.y1=t.y1,i.sankeyWidth=null!==(u=t.width)&&void 0!==u?u:0,i.circular=!!t.circular,i.circularPathData=t.circularPathData,i._circularWidth=t._circularWidth,i._circularStub=t._circularStub,i.path=t.path,i.circularLinkType=t.circularLinkType,i.direction=d;const e=b.get(r),n=b.get(o);e&&(i.source=e),n&&(i.target=n)}}},buildScene(t,e,n,r){var o,i,l,a;const s="vertical"===n.orientation?"down":"right",c=n.nodeStyle,u=n.edgeStyle,d=null!==(o=n.edgeOpacity)&&void 0!==o?o:.5,h=n.edgeColorBy||"source",f=Array.isArray(n.colorScheme)?n.colorScheme:b,y=new Map;t.forEach((t,e)=>{y.set(t.id,f[e%f.length])});const g=[],p=[],v=[],m=new Map;for(const e of t){const t=e.x1-e.x0,n=e.y1-e.y0;if(0>=t||0>=n)continue;const r=c?c(Yr(e,"nodeStyle")):{},o={fill:r.fill||y.get(e.id)||"#4d430c",stroke:r.stroke,strokeWidth:r.strokeWidth,opacity:r.opacity};m.set(e.id,("string"==typeof o.fill?o.fill:null)||y.get(e.id)||"#4d430c"),g.push("down"===s?{type:"rect",x:e.y0,y:e.x0,w:n,h:t,style:o,datum:e,id:e.id,label:e.id}:{type:"rect",x:e.x0,y:e.y0,w:t,h:n,style:o,datum:e,id:e.id,label:e.id})}const x=[...e].sort((t,e)=>(e.sankeyWidth||0)-(t.sankeyWidth||0));for(const t of x){if(!t.sankeyWidth||0>=t.sankeyWidth)continue;const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;if(!e||!n)continue;let r="#999";r="function"==typeof h?h(t)||r:"target"===h?m.get(n.id)||y.get(n.id)||r:m.get(e.id)||y.get(e.id)||r;const o=u?u(Yr(t,"edgeStyle")):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,n=t.sankeyWidth/2,a=Math.max(15,Math.min(40,.33*(e.rightFullExtent-e.sourceX))),s=Math.max(15,Math.min(40,.33*(e.targetX-e.leftFullExtent))),c=o.fill||r;p.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-n}L${e.sourceX+a},${e.sourceY-n}L${e.sourceX+a},${e.sourceY+n}L${e.sourceX},${e.sourceY+n}Z`,style:{fill:c,fillOpacity:null!==(i=o.fillOpacity)&&void 0!==i?i:d,stroke:"none",opacity:o.opacity},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+a}}),p.push({type:"bezier",pathD:`M${e.targetX},${e.targetY-n}L${e.targetX-s},${e.targetY-n}L${e.targetX-s},${e.targetY+n}L${e.targetX},${e.targetY+n}Z`,style:{fill:c,fillOpacity:null!==(l=o.fillOpacity)&&void 0!==l?l:d,stroke:"none",opacity:o.opacity},datum:t,_gradient:{direction:"left",from:0,to:1,x0:e.targetX-s,x1:e.targetX}});continue}let s;if(s=t.circular&&t.circularPathData?jr(t):Br(t),!s)continue;const c={fill:o.fill||r,fillOpacity:null!==(a=o.fillOpacity)&&void 0!==a?a:d,stroke:o.stroke||"none",strokeWidth:o.strokeWidth,opacity:o.opacity};p.push({type:"bezier",pathD:s,bezierCache:t.bezier,style:c,datum:t})}if(!1!==n.showLabels){const e=(k=n.nodeLabel)?"function"==typeof k?k:t=>t[k]||t.id:null;for(const n of t){const t=n.x1-n.x0,o=n.y1-n.y0;if(0>=t||0>=o)continue;const i=e?e(n):n.id;if(!i)continue;let l,a,c;"down"===s?(l=n.y0+(n.y1-n.y0)/2,a=n.x1+14,c="middle"):(r[0]/2>n.x0+t/2?(l=n.x0-6,c="end"):(l=n.x1+6,c="start"),a=n.y0+o/2),v.push({x:l,y:a,text:i+"",anchor:c,baseline:"middle",fontSize:11})}}var k;return{sceneNodes:g,sceneEdges:p,labels:v}}},Gr={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,r){var o,i;if(0===t.length)return;const l=null!==(o=n.forceStrength)&&void 0!==o?o:.1,a=r[0]/2,s=r[1]/2,c=n.__previousPositions;let u=0;const d=[];for(const e of t){const t=null!=e.x&&null!=e.y&&(0!==e.x||0!==e.y),n=null==c?void 0:c.get(e.id);t?u++:n?(e.x=n.x,e.y=n.y,u++):d.push(e)}const h=u>0&&.3>=(t.length>0?d.length/t.length:1);if(h){const n=new Map;for(const e of t)n.set(e.id,e);for(const t of d){const r=Vr(t.id,e,n);if(r.length>0){let e=0,n=0;for(const t of r)e+=t.x,n+=t.y;const o=qr(t.id),i=o%360*(Math.PI/180),l=10+o%20;t.x=e/r.length+l*Math.cos(i),t.y=n/r.length+l*Math.sin(i)}else{const e=qr(t.id),n=e%360*(Math.PI/180),r=15+e%30;t.x=a+r*Math.cos(n),t.y=s+r*Math.sin(n)}}}else{const e=2.399963229728653;for(let n=0;t.length>n;n++){const r=t[n];if(null==r.x||null==r.y||0===r.x&&0===r.y){const t=10*Math.sqrt(n+.5),o=n*e;r.x=a+t*Math.cos(o),r.y=s+t*Math.sin(o)}}}const f=null!==(i=n.iterations)&&void 0!==i?i:Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),y=0===n.iterations?0:h?40:f,g=Ur(n.nodeSize,n.nodeSizeRange,t),p=t=>g(t);if(y>0){const n=nt().strength(t=>Math.min(2.5,t.weight?t.weight*l:l)).id(t=>t.id),r=rt().force("charge",ot().strength(t=>-25*p(t))).force("center",it(a,s).strength(.8)).force("x",lt(a).strength(.15)).force("y",at(s).strength(.15));if(r.nodes(t),e.length>0){const t=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id}));r.force("link",n),r.force("link").links(t)}h?r.alpha(.3):.1>r.alpha()&&r.alpha(1),r.stop();for(let t=0;y>t;++t)r.tick()}for(const e of t){if(null==e.x||null==e.y)continue;const t=p(e);e.x=Math.max(t,Math.min(r[0]-t,e.x)),e.y=Math.max(t,Math.min(r[1]-t,e.y)),e.x0=0,e.x1=0,e.y0=0,e.y1=0}const v=new Map;for(const e of t)v.set(e.id,e);for(const t of e){if("string"==typeof t.source){const e=v.get(t.source);e&&(t.source=e)}if("string"==typeof t.target){const e=v.get(t.target);e&&(t.target=e)}}},buildScene(t,e,n,r){var o,i,l;const a=n.nodeStyle,s=n.edgeStyle,c=Ur(n.nodeSize,n.nodeSizeRange,t),u=Array.isArray(n.colorScheme)?n.colorScheme:b,d=new Map;t.forEach((t,e)=>{d.set(t.id,u[e%u.length])});const h=[],f=[],y=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=c(Yr(e,"nodeSize")),n=a?a(Yr(e,"nodeStyle")):{},r={fill:n.fill||d.get(e.id)||"#007bff",stroke:n.stroke||"#fff",strokeWidth:null!==(o=n.strokeWidth)&&void 0!==o?o:2,opacity:n.opacity};h.push({type:"circle",cx:e.x,cy:e.y,r:t,style:r,datum:e,id:e.id,label:e.id})}const g=new Map;for(const e of t)g.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:g.get(t.source),n="object"==typeof t.target?t.target:g.get(t.target);if(!e||!n)continue;if(null==e.x||null==e.y)continue;if(null==n.x||null==n.y)continue;const r=s?s(Yr(t,"edgeStyle")):{},o={stroke:r.stroke||"#999",strokeWidth:null!==(i=r.strokeWidth)&&void 0!==i?i:1,opacity:null!==(l=r.opacity)&&void 0!==l?l:.6};f.push({type:"line",x1:e.x,y1:e.y,x2:n.x,y2:n.y,style:o,datum:t})}if(!1!==n.showLabels){const e=(p=n.nodeLabel)?"function"==typeof p?p:t=>t[p]||t.id:null;for(const n of t){if(null==n.x||null==n.y)continue;const t=e?e(n):n.id;if(!t)continue;const r=c(Yr(n,"nodeSize"));y.push({x:n.x,y:n.y-r-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var p;return{sceneNodes:h,sceneEdges:f,labels:y}}};function Vr(t,e,n){const r=[];for(const o of e){const e="string"==typeof o.source?o.source:o.source.id,i="string"==typeof o.target?o.target:o.target.id;let l=null;if(e===t?l=i:i===t&&(l=e),l){const t=n.get(l);!t||0===t.x&&0===t.y||r.push({x:t.x,y:t.y})}}return r}function qr(t){let e=0;for(let n=0;t.length>n;n++)e=(e<<5)-e+t.charCodeAt(n)|0;return Math.abs(e)}function Ur(t,e,n){var r,o;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const i=e||[5,20],l=n.map(e=>{var n;return null===(n=e.data)||void 0===n?void 0:n[t]}).filter(t=>null!=t&&"number"==typeof t);if(0===l.length)return()=>i[0];const a=null!==(r=S(l))&&void 0!==r?r:0,s=null!==(o=_(l))&&void 0!==o?o:1;if(a===s)return()=>(i[0]+i[1])/2;const c=p().domain([a,s]).range(i).clamp(!0);return e=>{var n;const r=null===(n=e.data)||void 0===n?void 0:n[t];return null==r||"number"!=typeof r?i[0]:c(r)}}const Kr=b,Zr={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,n,r){if(0===t.length)return;const{padAngle:o=.01,groupWidth:i=20,sortGroups:l}=n,a=Math.min(r[0],r[1])/2,s=a-i,c=r[0]/2,u=r[1]/2,d=(h=n.valueAccessor)?"function"==typeof h?h:t=>{var e;return null!==(e=t[h])&&void 0!==e?e:1}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:1};var h;const f=new Map;for(let e=0;t.length>e;e++)f.set(t[e].id,e);const y=t.length,g=Array.from({length:y},()=>Array.from({length:y},()=>0));for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=f.get("string"==typeof t.source?t.source:t.source.id),r=f.get(e);if(void 0===n||void 0===r)continue;const o=d(t);g[n][r]=o}const p=ct().padAngle(o);l&&p.sortGroups(l);const v=p(g),m=v.groups,x=K().innerRadius(s).outerRadius(a);for(const e of m){const n=t[e.index],r=x.centroid(e);n.x=r[0]+c,n.y=r[1]+u,n.arcData={startAngle:e.startAngle,endAngle:e.endAngle}}const b=new Map;for(const e of t)b.set(e.id,e);for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=b.get("string"==typeof t.source?t.source:t.source.id),r=b.get(e);n&&(t.source=n),r&&(t.target=r)}const k=new Map;for(const t of e)k.set(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const e of v){const n=t[e.source.index].id,r=t[e.target.index].id,o=k.get(`${n}\0${r}`)||k.get(`${r}\0${n}`);o&&(o.chordData=e)}},buildScene(t,e,n,r){var o,i;const{groupWidth:l=20,edgeOpacity:a=.5}=n,s=Math.min(r[0],r[1])/2,c=s-l,u=r[0]/2,d=r[1]/2,h=n.nodeStyle,f=n.edgeStyle,y=n.edgeColorBy||"source",g=Array.isArray(n.colorScheme)?n.colorScheme:Kr,p=new Map;t.forEach((t,e)=>{p.set(t.id,g[e%g.length])});const v=st().radius(c),m=[],x=[],b=[];for(let e=0;t.length>e;e++){const n=t[e],r=n.arcData;if(!r)continue;let i;i=h?h(Yr(n,"nodeStyle")).fill||p.get(n.id)||g[e%g.length]:p.get(n.id)||g[e%g.length];const l=h?h(Yr(n,"nodeStyle")):{},a={fill:i,stroke:l.stroke||"black",strokeWidth:null!==(o=l.strokeWidth)&&void 0!==o?o:1,opacity:l.opacity};m.push({type:"arc",cx:u,cy:d,innerR:c,outerR:s,startAngle:r.startAngle-Math.PI/2,endAngle:r.endAngle-Math.PI/2,style:a,datum:n,id:n.id,label:n.id})}for(const t of e){const e=t.chordData;if(!e)continue;const n=v(e);if(!n)continue;const r=Qr(n,u,d);let o="#999";if(f)o=f(Yr(t,"edgeStyle")).fill||o;else{const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;"target"===y&&n?o=p.get(n.id)||o:e&&(o=p.get(e.id)||o)}const l=f?f(Yr(t,"edgeStyle")):{},s={fill:o,fillOpacity:null!==(i=l.fillOpacity)&&void 0!==i?i:a,stroke:l.stroke||"none",strokeWidth:l.strokeWidth,opacity:l.opacity};x.push({type:"ribbon",pathD:r,style:s,datum:t})}if(!1!==n.showLabels){const e=(k=n.nodeLabel)?"function"==typeof k?k:t=>t[k]||t.id:null,r=s+12;for(const n of t){const t=n.arcData;if(!t)continue;const o=e?e(n):n.id;if(!o)continue;const i=(t.startAngle+t.endAngle)/2,l=i-Math.PI/2;b.push({x:u+Math.cos(l)*r,y:d+Math.sin(l)*r,text:o+"",anchor:i>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var k;return{sceneNodes:m,sceneEdges:x,labels:b}}};function Qr(t,e,n){const r=t.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!r)return t;const o=[];let i=0;for(;r.length>i;){const t=r[i];if("M"===t||"L"===t)for(o.push(t),i++;r.length>i&&!isNaN(Number(r[i]));)o.push(Number(r[i])+e+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("C"===t)for(o.push(t),i++;r.length>i&&!isNaN(Number(r[i]));)for(let t=0;3>t&&r.length>i&&!isNaN(Number(r[i]));t++)o.push(Number(r[i])+e+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("Q"===t)for(o.push(t),i++;r.length>i&&!isNaN(Number(r[i]));)for(let t=0;2>t&&r.length>i&&!isNaN(Number(r[i]));t++)o.push(Number(r[i])+e+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("A"===t)for(o.push(t),i++;r.length>i&&!isNaN(Number(r[i]));)o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&(o.push(Number(r[i])+e+""),i++),r.length>i&&(o.push(Number(r[i])+n+""),i++);else"Z"===t||"z"===t?(o.push(t),i++):(o.push(r[i]),i++)}return o.join(" ")}const Jr=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function to(t){const[e,n,r]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(t);return.299*e+.587*n+.114*r>150?"#222":"#fff"}function eo(t,e,n){const r=e.nodeIDAccessor;return"function"==typeof r?r(t.data)+"":"string"==typeof r&&void 0!==t.data[r]?t.data[r]+"":void 0!==t.data.name?t.data.name+"":void 0!==t.data.id?t.data.id+"":"node-"+n}function no(t){return t?"function"==typeof t?t:e=>{var n;return(null===(n=e.data)||void 0===n?void 0:n[t])||e[t]||e.id}:null}function ro(t,e,n,r,o){if("horizontal"===o){const o=(t+n)/2;return`M ${t},${e} C ${o},${e} ${o},${r} ${n},${r}`}if("radial"===o){const o=(t+n)/2;return`M ${t},${e} Q ${o},${e} ${o},${(e+r)/2} T ${n},${r}`}{const o=(e+r)/2;return`M ${t},${e} C ${t},${o} ${n},${o} ${n},${r}`}}const oo={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,n,r){var o;const i=n.__hierarchyRoot;if(!i)return;const l=n.chartType,a=function(t){if(t)return"function"==typeof t?t:e=>e[t]}(n.childrenAccessor),s=n.hierarchySum||(t=>{var e;return null!==(e=t.value)&&void 0!==e?e:0}),c=N(i,a);c.sum(s),c.sort((t,e)=>{var n,r;return(null!==(n=e.value)&&void 0!==n?n:0)-(null!==(r=t.value)&&void 0!==r?r:0)});const[u,d]=r;switch(l){case"tree":!function(t,e,n,r){const o=e.treeOrientation||"vertical",i=B();i.size("horizontal"===o?[r,n]:"radial"===o?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),i(t)}(c,n,u,d);break;case"cluster":!function(t,e,n,r){const o=e.treeOrientation||"vertical",i=z();i.size("horizontal"===o?[r,n]:"radial"===o?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),i(t)}(c,n,u,d);break;case"treemap":!function(t,e,n,r){var o,i;const l=null!==(o=e.padding)&&void 0!==o?o:4,a=null!==(i=e.paddingTop)&&void 0!==i?i:0,s=I().size([n,r]).tile(W).padding(l);a>0&&s.paddingTop(a),s(t)}(c,n,u,d);break;case"circlepack":!function(t,e,n,r){var o;const i=null!==(o=e.padding)&&void 0!==o?o:4;O().size([n,r]).padding(i)(t)}(c,n,u,d);break;case"partition":!function(t,e,n,r){var o;$().size([n,r]).padding(null!==(o=e.padding)&&void 0!==o?o:1)(t)}(c,n,u,d)}const h=c.descendants();t.length=0,e.length=0;const f=new Map;for(let e=0;h.length>e;e++){const r=h[e],i={id:eo(r,n,e),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(o=r.value)&&void 0!==o?o:0,depth:r.depth,data:r.data,createdByFrame:!0};"tree"===l||"cluster"===l?io(i,r,n):"treemap"===l||"partition"===l?lo(i,r):"circlepack"===l&&ao(i,r),i.__hierarchyNode=r,t.push(i),f.set(r,i)}if("tree"===l||"cluster"===l)for(const t of h)if(t.parent){const n=f.get(t.parent),r=f.get(t);n&&r&&e.push({source:n,target:r,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,n,r){const o=n.nodeStyle||(()=>({})),i=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(t,e,n,r,o,i){var l,a,s,c,u;const d=[],h=[],f=[],y=n.treeOrientation||"vertical",g="radial"===y,p=r[0]/2,v=r[1]/2,m="number"==typeof(x=n.nodeSize)?x:5;var x;for(const e of t){let t=e.x,r=e.y;g&&(t+=p,r+=v);const i=o(Yr(e,"nodeStyle"));let a=i.fill||"#4d430c";n.colorByDepth&&void 0!==e.depth&&(a=Jr[e.depth%Jr.length]);const s={fill:a,stroke:i.stroke||"#fff",strokeWidth:null!==(l=i.strokeWidth)&&void 0!==l?l:1,opacity:i.opacity};d.push({type:"circle",cx:t,cy:r,r:m,style:s,datum:e,id:e.id,label:e.id,depth:e.depth})}const b=null!==(a=n.edgeOpacity)&&void 0!==a?a:.5;for(const t of e){const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;if(!e||!n)continue;let r=e.x,o=e.y,l=n.x,a=n.y;g&&(r+=p,o+=v,l+=p,a+=v);const u=ro(r,o,l,a,y),d=i(Yr(t,"edgeStyle")),f={fill:"none",stroke:d.stroke||"#999",strokeWidth:null!==(s=d.strokeWidth)&&void 0!==s?s:1.5,opacity:null!==(c=d.opacity)&&void 0!==c?c:b};h.push({type:"curved",pathD:u,style:f,datum:t})}if(!1!==n.showLabels){const e=no(n.nodeLabel);for(const n of t){const t=e?e(n):n.id;if(!t)continue;let r,o,i,l=n.x,a=n.y;if(g&&(l+=p,a+=v),g){const t=l-p,e=a-v,n=Math.sqrt(t*t+e*e);n>0?(r=l+t/n*10,o=a+e/n*10,i=0>t?"end":"start"):(r=l,o=a-12,i="middle")}else"horizontal"===y?((null===(u=n.data)||void 0===u?void 0:u.children)&&0!==n.data.children.length?(r=l-m-6,i="end"):(r=l+m+6,i="start"),o=a):(r=l,o=a+m+14,i="middle");f.push({x:r,y:o,text:t+"",anchor:i,baseline:"middle",fontSize:11})}}return{sceneNodes:d,sceneEdges:h,labels:f}}(t,e,n,r,o,i);case"treemap":case"partition":return function(t,e,n,r){var o,i;const l=[],a=[];for(const n of t){const t=n.x1-n.x0,i=n.y1-n.y0;if(0>=t||0>=i)continue;const a=r(Yr(n,"nodeStyle"));let s=a.fill||"#4d430c";e.colorByDepth&&void 0!==n.depth&&(s=Jr[n.depth%Jr.length]);const c={fill:s,stroke:a.stroke||"#fff",strokeWidth:null!==(o=a.strokeWidth)&&void 0!==o?o:1,opacity:a.opacity};l.push({type:"rect",x:n.x0,y:n.y0,w:t,h:i,style:c,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==e.showLabels){const n=no(e.nodeLabel),o=e.labelMode||"leaf",l="partition"===e.chartType;for(const s of t){const t=s.x1-s.x0,c=s.y1-s.y0;if(0>=t||0>=c)continue;const u=!((null===(i=s.data)||void 0===i?void 0:i.children)&&s.data.children.length>0);if(!l){if("leaf"===o&&!u)continue;if("parent"===o&&u)continue}const d=n?n(s):s.id;if(!d)continue;if((u?30:40)>t||(u?16:14)>c)continue;let h=r(Yr(s,"nodeStyle")).fill||"#4d430c";e.colorByDepth&&void 0!==s.depth&&(h=Jr[s.depth%Jr.length]);const f=to(h);a.push(u?{x:s.x0+t/2,y:s.y0+c/2,text:d+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,c)/6)),fill:f}:{x:s.x0+4,y:s.y0+12,text:d+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:f})}}return{sceneNodes:l,sceneEdges:[],labels:a}}(t,n,0,o);case"circlepack":return function(t,e,n,r){var o,i,l,a,s;const c=[],u=[];for(const n of t){const t=null!==(o=n.__radius)&&void 0!==o?o:5;if(0>=t)continue;const a=r(Yr(n,"nodeStyle"));let s=a.fill||"#4d430c";e.colorByDepth&&void 0!==n.depth&&(s=Jr[n.depth%Jr.length]);const u={fill:s,stroke:a.stroke||"#fff",strokeWidth:null!==(i=a.strokeWidth)&&void 0!==i?i:1,opacity:null!==(l=a.opacity)&&void 0!==l?l:.7};c.push({type:"circle",cx:n.x,cy:n.y,r:t,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==e.showLabels){const n=no(e.nodeLabel);for(const o of t){const t=null!==(a=o.__radius)&&void 0!==a?a:5,i=n?n(o):o.id;if(!i)continue;if(15>t)continue;const l=!((null===(s=o.data)||void 0===s?void 0:s.children)&&o.data.children.length>0);let c=r(Yr(o,"nodeStyle")).fill||"#4d430c";if(e.colorByDepth&&void 0!==o.depth&&(c=Jr[o.depth%Jr.length]),l){const e=to(c);u.push({x:o.x,y:o.y,text:i+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,t/3)),fill:e})}else u.push({x:o.x,y:o.y-t+14,text:i+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,t/3)),fill:"#000",stroke:"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:c,sceneEdges:[],labels:u}}(t,n,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function io(t,e,n){const r=n.treeOrientation||"vertical";if("radial"===r){const n=e.x,r=e.y;t.x=r*Math.cos(n-Math.PI/2),t.y=r*Math.sin(n-Math.PI/2)}else"horizontal"===r?(t.x=e.y,t.y=e.x):(t.x=e.x,t.y=e.y);t.x0=t.x-5,t.x1=t.x+5,t.y0=t.y-5,t.y1=t.y+5,t.width=10,t.height=10}function lo(t,e){t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.x=(e.x0+e.x1)/2,t.y=(e.y0+e.y1)/2,t.width=e.x1-e.x0,t.height=e.y1-e.y0}function ao(t,e){var n;const r=null!==(n=e.r)&&void 0!==n?n:0;t.x=e.x,t.y=e.y,t.x0=e.x-r,t.x1=e.x+r,t.y0=e.y-r,t.y1=e.y+r,t.width=2*r,t.height=2*r,t.__radius=r}function so(t){const e=t;return e.__orbitState||(e.__orbitState={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()}),e.__orbitState}const co={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(t,e,n,r){const o=n.__hierarchyRoot;o&&function(t,e,n,r,o){var i,l;const a=function(t){if("function"==typeof t)return t;const e=t||"children";return t=>t[e]||null}(n.childrenAccessor),s=function(t){if("function"==typeof t)return t;const e=t||"name";return t=>{var n;return(null!==(n=t[e])&&void 0!==n?n:"")+""}}(n.nodeIDAccessor),c=function(t){if(Array.isArray(t))return t;switch(t){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(n.orbitMode),u=null!==(i=n.orbitSize)&&void 0!==i?i:2.95,d=null!==(l=n.orbitEccentricity)&&void 0!==l?l:1,h="number"==typeof u?()=>u:u,f="number"==typeof d?()=>d:d,y=so(n);y.metaMap.clear(),r.length=0,o.length=0;const g=new Map;function p(t){var e;const n=null!==(e=g.get(t))&&void 0!==e?e:0;return g.set(t,n+1),0===n?t:`${t}__${n}`}const v=e[0]/2,m=e[1]/2,x=Math.min(e[0],e[1])/2*.85,b=p(s(t));r.push({id:b,x:v,y:m,x0:v,x1:v,y0:m,y1:m,width:0,height:0,value:0,depth:0,data:t}),y.metaMap.set(b,{ring:x,angle:0,depth:0,parentId:null,eccentricity:1}),function t(e,n,i,l,u,d,g){const v=a(e);if(!(null==v?void 0:v.length))return;const m=v.length;let x=0,b=0,k=0;for(;m>b;)b+=c[Math.min(k,c.length-1)],k++,x++;let w=0;for(let m=0;x>m;m++){const b=c[Math.min(m,c.length-1)],k=v.slice(w,w+b);if(!k.length)break;const E=(m+1)/x,A={id:n,depth:d,data:e,parentId:n},M=g?u/h(A)*E:u*E,S=J().value(t=>{var e;return(null===(e=a(t))||void 0===e?void 0:e.length)?4:1}).sort(null),P=S(k),_=f(A);for(let e=0;k.length>e;e++){const a=(P[e].startAngle+P[e].endAngle)/2,c=k[e],u=p(s(c)),h=i+M*Math.sin(a),f=l+M*Math.cos(a)*_;r.push({id:u,x:h,y:f,x0:h,x1:h,y0:f,y1:f,width:0,height:0,value:0,depth:d,data:c}),y.metaMap.set(u,{ring:M,angle:a,depth:d,parentId:n,eccentricity:_}),o.push({source:n,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:u}}),t(c,u,h,f,M,d+1,!0)}w+=b}}(t,b,v,m,x,1,!1)}(o,r,n,t,e)},buildScene(t,e,n,r){var o,i,l,a,s;const c=n.nodeStyle,u=n.nodeSize,d="number"==typeof u?()=>u:"function"==typeof u?u:()=>6,h=[],f=[],y=[];if(!1!==n.orbitShowRings){const e=so(n),r=new Map;for(const e of t)r.set(e.id,e);const o=new Map;for(const[,t]of e.metaMap){if(!t.parentId)continue;const e=r.get(t.parentId);if(!e)continue;const n=`${t.parentId}:${t.ring}`;o.has(n)||o.set(n,{parentX:e.x,parentY:e.y,ring:t.ring,ecc:t.eccentricity})}const i=48,l={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:t,parentY:e,ring:n,ecc:r}]of o)for(let o=0;i>o;o++){const a=o/i*Math.PI*2,s=(o+1)/i*Math.PI*2;f.push({type:"line",x1:t+n*Math.sin(a),y1:e+n*Math.cos(a)*r,x2:t+n*Math.sin(s),y2:e+n*Math.cos(s)*r,style:l,datum:null})}}for(const e of t){if(null==e.x||null==e.y)continue;const t=d(Yr(e,"nodeSize")),n=c?c(Yr(e,"nodeStyle")):{},r={fill:n.fill||"#6366f1",stroke:n.stroke||"#fff",strokeWidth:null!==(o=n.strokeWidth)&&void 0!==o?o:1,opacity:null!==(i=n.opacity)&&void 0!==i?i:0===(null!==(l=e.depth)&&void 0!==l?l:0)?1:.85};h.push({type:"circle",cx:e.x,cy:e.y,r:t,style:r,datum:e,id:e.id,label:e.id,depth:e.depth})}const g=new Map;for(const e of t)g.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:g.get(t.source),n="object"==typeof t.target?t.target:g.get(t.target);e&&n&&(null!=e.x&&null!=n.x&&f.push({type:"line",x1:e.x,y1:e.y,x2:n.x,y2:n.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:t}))}if(n.showLabels){const e=n.nodeLabel;for(const n of t){const t=d(Yr(n,"nodeSize"));if(4>=t)continue;const r="function"==typeof e?e(n):e&&null!==(s=null===(a=n.data)||void 0===a?void 0:a[e])&&void 0!==s?s:n.id;y.push({x:n.x,y:n.y+t+12,text:r+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:h,sceneEdges:f,labels:y}},tick:(t,e,n,r,o)=>!1!==n.orbitAnimated&&(function(t,e){var n,r;const o=so(e),i=null!==(n=e.orbitSpeed)&&void 0!==n?n:.25,l=null!==(r=e.orbitRevolution)&&void 0!==r?r:function(t){switch(t){case"decay":return t=>{var e;return Math.pow(.6,null!==(e=t.depth)&&void 0!==e?e:0)};case"alternate":return t=>{var e;const n=null!==(e=t.depth)&&void 0!==e?e:0;return(n%2==0?1:-1)/(n+1)};default:return t=>{var e;return 1/((null!==(e=t.depth)&&void 0!==e?e:0)+1)}}}(e.orbitRevolutionStyle),a=(("undefined"!=typeof performance?performance.now():Date.now())-o.startTime)/1e3,s=i*(Math.PI/6),c=new Map;for(const e of t)c.set(e.id,e);for(const e of t){const t=o.metaMap.get(e.id);if(!t||!t.parentId)continue;const n=c.get(t.parentId);if(!n)continue;const r=t.angle+a*s*l({id:e.id,depth:t.depth,data:e.data,parentId:t.parentId});e.x=n.x+t.ring*Math.sin(r),e.y=n.y+t.ring*Math.cos(r)*t.eccentricity,e.x0=e.x,e.x1=e.x,e.y0=e.y,e.y1=e.y}}(t,n),!0)},uo={sankey:Xr,force:Gr,chord:Zr,tree:oo,cluster:oo,treemap:oo,circlepack:oo,partition:oo,orbit:co};function ho(t){return uo[t]}class fo{constructor(t){this.nodes=new Map,this.edges=new Map,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.particlePool=null,this.transition=null,this.lastIngestTime=0,this.nodeTimestamps=new Map,this.edgeTimestamps=new Map,this._decaySortedNodes=null,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this._lastPositionSnapshot=null,this.config=t,this.tensionConfig=Object.assign(Object.assign({},Un),t.tensionConfig),"sankey"===t.chartType&&t.showParticles&&(this.particlePool=new Zn(2e3))}updateConfig(t){const e=this.config;e.__orbitState&&(t.__orbitState=e.__orbitState),e.__hierarchyRoot&&(t.__hierarchyRoot=e.__hierarchyRoot),this.config=t,this.tensionConfig=Object.assign(Object.assign({},Un),t.tensionConfig),"sankey"===t.chartType&&t.showParticles&&!this.particlePool&&(this.particlePool=new Zn(2e3))}ingestHierarchy(t,e){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this.config.__hierarchyRoot=t,this.runLayout(e)}ingestBounded(t,e,n){const{nodeIDAccessor:r="id",sourceAccessor:o="source",targetAccessor:i="target",valueAccessor:l="value"}=this.config,a="function"==typeof r?r:t=>t[r],s="function"==typeof o?o:t=>t[o],c="function"==typeof i?i:t=>t[i],u="function"==typeof l?l:t=>{var e;return null!==(e=t[l])&&void 0!==e?e:1};this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const e of t){const t=a(e)+"";this.nodes.set(t,Object.assign(Object.assign({},yo(t)),{data:e}))}for(let t=0;e.length>t;t++){const n=e[t],r=s(n)+"",o=c(n)+"",i=Number(u(n))||1;this.nodes.has(r)||this.nodes.set(r,Object.assign(Object.assign({},yo(r)),{data:n})),this.nodes.has(o)||this.nodes.set(o,Object.assign(Object.assign({},yo(o)),{data:n}));const l=`${r}\0${o}\0${t}`;this.edges.set(l,{source:r,target:o,value:i,y0:0,y1:0,sankeyWidth:0,data:n,_edgeKey:l})}this.runLayout(n)}edgeKey(t,e){return`${t}\0${e}`}ingestEdge(t){const{source:e,target:n,value:r}=t,o=0===this.nodes.size;let i=!1;const l="undefined"!=typeof performance?performance.now():Date.now();this.lastIngestTime=l,this._decaySortedNodes=null,this.nodes.has(e)||(this.nodes.set(e,yo(e)),this.nodeTimestamps.set(e,l),this.tension+=this.tensionConfig.newNode,i=!0),this.nodes.has(n)||(this.nodes.set(n,yo(n)),this.nodeTimestamps.set(n,l),this.tension+=this.tensionConfig.newNode,i=!0);const a=this.edgeKey(e,n),s=this.edges.get(a);let c=!1;return s?(s.value+=r,this.edgeTimestamps.set(a,l),this.tension+=this.tensionConfig.weightChange,c=!0):(this.edges.set(a,{source:e,target:n,value:r,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(a,l),this.tension+=this.tensionConfig.newEdge,i=!0),o||i||c||this.tension>=this.tensionConfig.threshold}runLayout(t){var e,n,r,o,i,l;const a=ho(this.config.chartType);if(!a)return;let s=Array.from(this.nodes.values()),c=Array.from(this.edges.values());if(0===s.length&&!a.hierarchical)return;if(this.prepareForRelayout(),a.supportsStreaming&&!a.hierarchical){const t=new Map;for(const a of s)if(void 0!==a._prevX0){const s=(null!==(e=a._prevX1)&&void 0!==e?e:0)-(null!==(n=a._prevX0)&&void 0!==n?n:0),c=(null!==(r=a._prevY1)&&void 0!==r?r:0)-(null!==(o=a._prevY0)&&void 0!==o?o:0);t.set(a.id,{x:(null!==(i=a._prevX0)&&void 0!==i?i:0)+s/2,y:(null!==(l=a._prevY0)&&void 0!==l?l:0)+c/2})}else 0===a.x&&0===a.y||t.set(a.id,{x:a.x,y:a.y});if(this._lastPositionSnapshot)for(const[e,n]of this._lastPositionSnapshot)t.has(e)||t.set(e,n);this.config.__previousPositions=t.size>0?t:void 0}if(a.computeLayout(s,c,this.config,t),this.config.__previousPositions=void 0,a.hierarchical&&s.length>0){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const t of s)this.nodes.set(t.id,t);for(let t=0;c.length>t;t++){const e=c[t],n=e._edgeKey||`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}\0${t}`;e._edgeKey=n,this.edges.set(n,e)}}this.finalizeLayout();const u=new Map;for(const t of this.nodes.values())0===t.x&&0===t.y||u.set(t.id,{x:t.x,y:t.y});this._lastPositionSnapshot=u,this.saveTargetPositions(),s.some(t=>void 0!==t._prevX0&&(0!==t._prevX0||0!==t._prevX1||0!==t._prevY0||0!==t._prevY1))&&this.tensionConfig.transitionDuration>0&&(this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:this.tensionConfig.transitionDuration});const d=new Set(this.nodes.keys()),h=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const t of d)this.previousNodeIds.has(t)||this.addedNodes.add(t);for(const t of this.previousNodeIds)d.has(t)||this.removedNodes.add(t);for(const t of h)this.previousEdgeKeys.has(t)||this.addedEdges.add(t);for(const t of this.previousEdgeKeys)h.has(t)||this.removedEdges.add(t);(this.addedNodes.size>0||this.removedNodes.size>0||this.addedEdges.size>0||this.removedEdges.size>0)&&(this.lastTopologyChangeTime="undefined"!=typeof performance?performance.now():Date.now()),this.previousNodeIds=d,this.previousEdgeKeys=h,this.layoutVersion++}buildScene(t){const e=ho(this.config.chartType);if(!e)return;const n=Array.from(this.nodes.values()),r=Array.from(this.edges.values()),{sceneNodes:o,sceneEdges:i,labels:l}=e.buildScene(n,r,this.config,t);this.sceneNodes=o,this.sceneEdges=i,this.labels=l}get isAnimating(){const t=ho(this.config.chartType);return!!(null==t?void 0:t.supportsAnimation)&&!1!==this.config.orbitAnimated}tickAnimation(t,e){const n=ho(this.config.chartType);if(!(null==n?void 0:n.tick))return!1;const r=Array.from(this.nodes.values()),o=Array.from(this.edges.values());return n.tick(r,o,this.config,t,e)}advanceTransition(t){if(!this.transition)return!1;const e=St(t,this.transition),n=Mt(e);for(const t of this.nodes.values())void 0===t._targetX0||void 0===t._prevX0||0===t._prevX0&&0===t._prevX1||(t.x0=Pt(t._prevX0,t._targetX0,n),t.x1=Pt(t._prevX1,t._targetX1,n),t.y0=Pt(t._prevY0,t._targetY0,n),t.y1=Pt(t._prevY1,t._targetY1,n));for(const t of this.edges.values())void 0!==t._targetY0&&void 0!==t._prevY0&&void 0!==t._prevSankeyWidth&&t._prevSankeyWidth>0&&(t.y0=Pt(t._prevY0,t._targetY0,n),t.y1=Pt(t._prevY1,t._targetY1,n),t.sankeyWidth=Pt(t._prevSankeyWidth,t._targetSankeyWidth,n));return this.rebuildAllBeziers(),1>e||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){for(const t of this.nodes.values())t._prevX0=t.x0,t._prevX1=t.x1,t._prevY0=t.y0,t._prevY1=t.y1;for(const t of this.edges.values())t._prevY0=t.y0,t._prevY1=t.y1,t._prevSankeyWidth=t.sankeyWidth}finalizeLayout(){const t="vertical"===this.config.orientation?"down":"right";for(const t of this.nodes.values())if(0!==t.x0||0!==t.x1||0!==t.y0||0!==t.y1)t.width=t.x1-t.x0,t.height=t.y1-t.y0,t.x=t.x0+t.width/2,t.y=t.y0+t.height/2;else{const e=5;t.x0=t.x-e,t.x1=t.x+e,t.y0=t.y-e,t.y1=t.y+e,t.width=2*e,t.height=2*e}for(const e of this.edges.values())e.direction=t,this.updateEdgeBezier(e);this.tension=0}saveTargetPositions(){for(const t of this.nodes.values())t._targetX0=t.x0,t._targetX1=t.x1,t._targetY0=t.y0,t._targetY1=t.y1;for(const t of this.edges.values())t._targetY0=t.y0,t._targetY1=t.y1,t._targetSankeyWidth=t.sankeyWidth}restorePreviousPositions(){for(const t of this.nodes.values())void 0===t._prevX0||0===t._prevX0&&0===t._prevX1||(t.x0=t._prevX0,t.x1=t._prevX1,t.y0=t._prevY0,t.y1=t._prevY1);for(const t of this.edges.values())void 0!==t._prevY0&&void 0!==t._prevSankeyWidth&&t._prevSankeyWidth>0&&(t.y0=t._prevY0,t.y1=t._prevY1,t.sankeyWidth=t._prevSankeyWidth);this.rebuildAllBeziers()}snapToTargets(){for(const t of this.nodes.values())void 0!==t._targetX0&&(t.x0=t._targetX0,t.x1=t._targetX1,t.y0=t._targetY0,t.y1=t._targetY1);for(const t of this.edges.values())void 0!==t._targetY0&&(t.y0=t._targetY0,t.y1=t._targetY1,t.sankeyWidth=t._targetSankeyWidth);this.rebuildAllBeziers()}updateEdgeBezier(t){const e="string"==typeof t.source?this.nodes.get(t.source):t.source,n="string"==typeof t.target?this.nodes.get(t.target):t.target;e&&n&&(t.bezier=t.circular&&t.circularPathData?this.buildCircularBezier(t):this.buildStandardBezier(t,e,n))}buildStandardBezier(t,e,n){const r=(t.sankeyWidth||1)/2;if("down"===t.direction){const o=e.x1,i=n.x0,l=et(o,i);return{circular:!1,points:[{x:t.y0,y:o},{x:t.y0,y:l(.5)},{x:t.y1,y:l(.5)},{x:t.y1,y:i}],halfWidth:r}}const o=e.x1,i=n.x0,l=et(o,i);return{circular:!1,points:[{x:o,y:t.y0},{x:l(.5),y:t.y0},{x:l(.5),y:t.y1},{x:i,y:t.y1}],halfWidth:r}}buildCircularBezier(t){const e=(t._circularWidth||t.sankeyWidth||1)/2,n=t.circularPathData;if(t._circularStub){const t=Math.max(15,Math.min(40,.33*(n.rightFullExtent-n.sourceX))),r=Math.max(15,Math.min(40,.33*(n.targetX-n.leftFullExtent)));return{circular:!0,segments:[[{x:n.sourceX,y:n.sourceY},{x:n.sourceX+.33*t,y:n.sourceY},{x:n.sourceX+.66*t,y:n.sourceY},{x:n.sourceX+t,y:n.sourceY}],[{x:n.targetX-r,y:n.targetY},{x:n.targetX-.66*r,y:n.targetY},{x:n.targetX-.33*r,y:n.targetY},{x:n.targetX,y:n.targetY}]],halfWidth:e}}let r;r="down"===t.direction?[{x:n.sourceY,y:n.sourceX},{x:n.sourceY,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.leftFullExtent},{x:n.targetY,y:n.leftFullExtent},{x:n.targetY,y:n.targetX}]:[{x:n.sourceX,y:n.sourceY},{x:n.rightFullExtent,y:n.sourceY},{x:n.rightFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.targetY},{x:n.targetX,y:n.targetY}];const o=[];for(let t=0;r.length-1>t;t++){const e=r[t],n=r[t+1],i=n.x-e.x,l=n.y-e.y;o.push([e,{x:e.x+i/3,y:e.y+l/3},{x:e.x+2*i/3,y:e.y+2*l/3},n])}return{circular:!0,segments:o,halfWidth:e}}rebuildAllBeziers(){for(const t of this.nodes.values())t.width=t.x1-t.x0,t.height=t.y1-t.y0,t.x=t.x0+t.width/2,t.y=t.y0+t.height/2;for(const t of this.edges.values())this.updateEdgeBezier(t)}applyPulse(t){var e,n,r,o,i;const l=this.config.pulse;if(!l)return;const a=null!==(e=l.duration)&&void 0!==e?e:500,s=null!==(n=l.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",c=null!==(r=l.glowRadius)&&void 0!==r?r:4;for(const e of this.sceneNodes){const n=e.id;if(!n)continue;const r=this.nodeTimestamps.get(n);if(!r)continue;const o=t-r;a>o&&(e._pulseIntensity=1-o/a,e._pulseColor=s,e._pulseGlowRadius=c)}for(const e of this.sceneEdges){const n=e.datum;if(!n)continue;const r="object"==typeof n.source?null===(o=n.source)||void 0===o?void 0:o.id:n.source,l="object"==typeof n.target?null===(i=n.target)||void 0===i?void 0:i.id:n.target;if(!r||!l)continue;const c=this.edgeTimestamps.get(`${r}\0${l}`);if(!c)continue;const u=t-c;a>u&&(e._pulseIntensity=1-u/a,e._pulseColor=s)}}applyDecay(){var t,e,n,r,o;const i=this.config.decay;if(!i)return;const l=null!==(t=i.minOpacity)&&void 0!==t?t:.1,a=this.nodeTimestamps.size;if(1>=a)return;this._decaySortedNodes||(this._decaySortedNodes=Array.from(this.nodeTimestamps.entries()).sort((t,e)=>t[1]-e[1]));const s=this._decaySortedNodes,c=new Map;for(let t=0;s.length>t;t++)c.set(s[t][0],t);for(const t of this.sceneNodes){const s=t.id;if(!s)continue;const u=c.get(s);if(void 0===u)continue;const d=a-1-u;let h;switch(i.type){case"linear":h=l+(1-d/(a-1))*(1-l);break;case"exponential":{const t=null!==(e=i.halfLife)&&void 0!==e?e:a/2;h=l+Math.pow(.5,d/t)*(1-l);break}case"step":h=(null!==(n=i.stepThreshold)&&void 0!==n?n:.5*a)>d?1:l;break;default:h=1}const f=null!==(o=null===(r=t.style)||void 0===r?void 0:r.opacity)&&void 0!==o?o:1;t.style=Object.assign(Object.assign({},t.style),{opacity:f*h})}}applyTopologyDiff(t){var e;if(0===this.addedNodes.size)return;const n=t-this.lastTopologyChangeTime;if(n>=2e3)return;const r=1-n/2e3;for(const t of this.sceneNodes){const n=t.id;n&&this.addedNodes.has(n)&&(t._pulseIntensity=Math.max(null!==(e=t._pulseIntensity)&&void 0!==e?e:0,r),t._pulseColor="rgba(34, 197, 94, 0.7)",t._pulseGlowRadius=8)}}get hasActiveTopologyDiff(){return 0!==this.addedNodes.size&&2e3>("undefined"!=typeof performance?performance.now():Date.now())-this.lastTopologyChangeTime}applyThresholds(t){var e,n;const r=this.config.thresholds;if(!r)return;const o=null!==(e=r.warningColor)&&void 0!==e?e:"#f59e0b",i=null!==(n=r.criticalColor)&&void 0!==n?n:"#ef4444",l=!1!==r.pulse;for(const e of this.sceneNodes){const n=e.id;if(!n)continue;const a=this.nodes.get(n);if(!a)continue;const s=r.metric(a);let c=null;void 0===r.critical||r.critical>s?void 0===r.warning||r.warning>s||(c=o):c=i,c&&(e.style=Object.assign(Object.assign({},e.style),{fill:c}),l&&(e._pulseIntensity=.6+.4*Math.sin(t/300),e._pulseColor=c,e._pulseGlowRadius=6))}}get hasActiveThresholds(){const t=this.config.thresholds;if(!t)return!1;for(const e of this.nodes.values()){const n=t.metric(e);if(void 0!==t.warning&&n>=t.warning||void 0!==t.critical&&n>=t.critical)return!0}return!1}get hasActivePulses(){var t;const e=this.config.pulse;if(!e||0===this.lastIngestTime)return!1;const n="undefined"!=typeof performance?performance.now():Date.now();return(null!==(t=e.duration)&&void 0!==t?t:500)>n-this.lastIngestTime}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}updateNode(t,e){var n;const r=this.nodes.get(t);if(!r)return null;const o=r.data?Object.assign({},r.data):{};return r.data=e(null!==(n=r.data)&&void 0!==n?n:{}),this.layoutVersion++,o}updateEdge(t,e,n){var r;const o=this.config.valueAccessor,i="function"==typeof o?o:o?t=>t[o]:t=>t.value,l=[];for(const[,o]of this.edges)if(("string"==typeof o.source?o.source:o.source.id)===t&&("string"==typeof o.target?o.target:o.target.id)===e){l.push(o.data?Object.assign({},o.data):{}),o.data=n(null!==(r=o.data)&&void 0!==r?r:{});const t=i(o.data);null!=t&&(o.value=Number(t))}return l.length>0&&this.layoutVersion++,l}removeNode(t){if(!this.nodes.has(t))return!1;this.nodes.delete(t),this.nodeTimestamps.delete(t);for(const[e,n]of this.edges)("string"==typeof n.source?n.source:n.source.id)!==t&&("string"==typeof n.target?n.target:n.target.id)!==t||(this.edges.delete(e),this.edgeTimestamps.delete(e));return this.layoutVersion++,!0}removeEdge(t,e){const n=[];for(const[r,o]of this.edges)("string"==typeof o.source?o.source:o.source.id)===t&&("string"==typeof o.target?o.target:o.target.id)===e&&n.push(r);for(const t of n)this.edges.delete(t),this.edgeTimestamps.delete(t);return n.length>0&&this.layoutVersion++,n.length>0}clear(){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.transition=null,this.lastIngestTime=0,this._lastPositionSnapshot=null,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.particlePool&&this.particlePool.clear()}}function yo(t){return{id:t,x0:0,x1:0,y0:0,y1:0,x:0,y:0,width:0,height:0,value:0,createdByFrame:!0}}function go(t,e,n,r,o=30){let i=null,l=o,a=1/0;for(const e of t){const t=po(e,n,r,o);if(t)if("rect"===e.type){const n=e.w*e.h;a>n&&(i=t,a=n)}else l>t.distance&&(i=t,l=t.distance)}if(i)return i;for(const t of e){const e=bo(t,n,r);e&&l>e.distance&&(i=e,l=e.distance)}return i}function po(t,e,n,r=30){switch(t.type){case"circle":return function(t,e,n,r=30){const o=e-t.cx,i=n-t.cy,l=Math.sqrt(o*o+i*i);return l>jt(t.r,r)?null:{type:"node",datum:t.datum,x:t.cx,y:t.cy,distance:l}}(t,e,n,r);case"rect":return function(t,e,n){const r=Bt(e,n,t);return r.hit?{type:"node",datum:t.datum,x:r.cx,y:r.cy,distance:0}:null}(t,e,n);case"arc":return function(t,e,n){const r=e-t.cx,o=n-t.cy,i=Math.sqrt(r*r+o*o);if(t.innerR-2>i||i>t.outerR+2)return null;const l=Yt(Math.atan2(o,r)),a=Yt(t.startAngle),s=Yt(t.endAngle);if(a>s?l>=a||s>=l:l>=a&&s>=l){const e=(t.startAngle+t.endAngle)/2,n=(t.innerR+t.outerR)/2;return{type:"node",datum:t.datum,x:t.cx+n*Math.cos(e),y:t.cy+n*Math.sin(e),distance:0}}return null}(t,e,n);default:return null}}let vo=null,mo=null;function xo(){return mo||(vo=document.createElement("canvas"),vo.width=1,vo.height=1,mo=vo.getContext("2d")),mo}function bo(t,e,n){switch(t.type){case"bezier":return function(t,e,n){var r,o;if(!t.pathD)return null;try{const i=new Path2D(t.pathD),l=xo();if(!l)return null;if(l.isPointInPath(i,e,n)){const i="object"==typeof(null===(r=t.datum)||void 0===r?void 0:r.source)?t.datum.source:null,l="object"==typeof(null===(o=t.datum)||void 0===o?void 0:o.target)?t.datum.target:null;return{type:"edge",datum:t.datum,x:i&&l?(i.x1+l.x0)/2:e,y:t.datum?(t.datum.y0+t.datum.y1)/2:n,distance:0}}const a=l.lineWidth;l.lineWidth=10;const s=l.isPointInStroke(i,e,n);if(l.lineWidth=a,s)return{type:"edge",datum:t.datum,x:e,y:n,distance:4}}catch(t){}return null}(t,e,n);case"line":return function(t,e,n){const r=t.x2-t.x1,o=t.y2-t.y1,i=r*r+o*o;if(0===i)return null;let l=((e-t.x1)*r+(n-t.y1)*o)/i;l=Math.max(0,Math.min(1,l));const a=t.x1+l*r,s=t.y1+l*o,c=Math.sqrt(Math.pow(e-a,2)+Math.pow(n-s,2));return c>5?null:{type:"edge",datum:t.datum,x:a,y:s,distance:c}}(t,e,n);case"ribbon":case"curved":return function(t,e,n){if(!t.pathD)return null;try{const r=new Path2D(t.pathD),o=xo();if(!o)return null;if(o.isPointInPath(r,e,n))return{type:"edge",datum:t.datum,x:e,y:n,distance:0};const i=o.lineWidth;o.lineWidth=10;const l=o.isPointInStroke(r,e,n);if(o.lineWidth=i,l)return{type:"edge",datum:t.datum,x:e,y:n,distance:4}}catch(t){}return null}(t,e,n);default:return null}}function ko(e){const{width:n,height:r,totalWidth:o,totalHeight:i,margin:l,labels:a,title:s,legend:c,legendHoverBehavior:u,legendClickBehavior:d,legendHighlightedCategory:h,legendIsolatedCategories:f,legendPosition:y="right",foregroundGraphics:g,sceneNodes:p,annotations:v,svgAnnotationRules:m}=e;return t.createElement(t.Fragment,null,t.createElement("svg",{role:"img",width:o,height:i,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},t.createElement("title",null,"string"==typeof s?s:"Network Chart"),t.createElement("desc",null,"string"==typeof s?s+" — network data visualization":"Network data visualization"),t.createElement("g",{transform:`translate(${l.left},${l.top})`},a.map((e,n)=>t.createElement("text",{key:"label-"+n,x:e.x,y:e.y,textAnchor:e.anchor||"start",dominantBaseline:e.baseline||"middle",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"currentColor",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,style:{pointerEvents:"none"}},e.text)),v&&v.filter(t=>"widget"!==t.type).map((e,o)=>{if(m){const i=m(e,o,{width:n,height:r,sceneNodes:p});if(i)return t.createElement(t.Fragment,{key:"annotation-"+o},i)}return null}),g),s&&"string"==typeof s?t.createElement("text",{x:o/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor"},s):s?t.createElement("foreignObject",{x:0,y:0,width:o,height:l.top},s):null,fe({legend:c,totalWidth:o,totalHeight:i,margin:l,legendPosition:y,title:s,legendHoverBehavior:u,legendClickBehavior:d,legendHighlightedCategory:h,legendIsolatedCategories:f})),null==v?void 0:v.filter(t=>"widget"===t.type&&t.nodeId&&p).map((e,n)=>{var r,o,i,a,s,c,u,d,h;const f=p.find(t=>{var n,r,o,i,l;return t.id===e.nodeId||(null===(n=t.datum)||void 0===n?void 0:n.id)===e.nodeId||(null===(o=null===(r=t.datum)||void 0===r?void 0:r.data)||void 0===o?void 0:o.id)===e.nodeId||(null===(l=null===(i=t.datum)||void 0===i?void 0:i.data)||void 0===l?void 0:l.name)===e.nodeId});if(!f)return null;const y=l.left+(null!==(r=f.cx)&&void 0!==r?r:null!=f.x&&null!=f.w?f.x+f.w/2:null!==(o=f.x)&&void 0!==o?o:0),g=l.top+(null!==(i=f.cy)&&void 0!==i?i:null!=f.y&&null!=f.h?f.y+f.h/2:null!==(a=f.y)&&void 0!==a?a:0),v=null!==(s=e.dx)&&void 0!==s?s:0,m=null!==(c=e.dy)&&void 0!==c?c:-16,x=null!==(u=e.width)&&void 0!==u?u:32,b=null!==(d=e.height)&&void 0!==d?d:32,k=null!==(h=e.content)&&void 0!==h?h:t.createElement("span",{style:{fontSize:18,cursor:"default"}},"ℹ️");return t.createElement("div",{key:"widget-"+n,style:{position:"absolute",left:y+v-x/2,top:g+m-b/2,width:x,height:b,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:5}},k)}))}function wo(t,e){var n,r,o,i,l,a;if(!e.pathD)return;t.save();const s=new Path2D(e.pathD);if(e.style.fill&&"none"!==e.style.fill){const l=e._gradient;if(l){const o=t.createLinearGradient(l.x0,0,l.x1,0),i=null!==(r=null!==(n=e.style.fillOpacity)&&void 0!==n?n:e.style.opacity)&&void 0!==r?r:.5,a="string"==typeof e.style.fill?e.style.fill:"#999";o.addColorStop(0,1===l.from?a:"transparent"),o.addColorStop(1,1===l.to?a:"transparent"),t.fillStyle=o,t.globalAlpha=i}else t.fillStyle=e.style.fill,t.globalAlpha=null!==(i=null!==(o=e.style.fillOpacity)&&void 0!==o?o:e.style.opacity)&&void 0!==i?i:.5;t.fill(s)}e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=e.style.stroke,t.lineWidth=null!==(l=e.style.strokeWidth)&&void 0!==l?l:.5,t.globalAlpha=.5*(null!==(a=e.style.opacity)&&void 0!==a?a:1),t.stroke(s)),e._pulseIntensity&&e._pulseIntensity>0&&(t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.globalAlpha=.2*e._pulseIntensity,t.fill(s)),t.restore()}function Eo(t,e){var n,r;t.save(),t.strokeStyle=e.style.stroke||"#999",t.lineWidth=null!==(n=e.style.strokeWidth)&&void 0!==n?n:1,void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.strokeDasharray&&t.setLineDash(e.style.strokeDasharray.split(/[\s,]+/).map(Number)),t.beginPath(),t.moveTo(e.x1,e.y1),t.lineTo(e.x2,e.y2),t.stroke(),e._pulseIntensity&&e._pulseIntensity>0&&(t.setLineDash([]),t.strokeStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.lineWidth=(null!==(r=e.style.strokeWidth)&&void 0!==r?r:1)+3*e._pulseIntensity,t.globalAlpha=.4*e._pulseIntensity,t.beginPath(),t.moveTo(e.x1,e.y1),t.lineTo(e.x2,e.y2),t.stroke()),t.restore()}function Ao(t,e){var n,r,o,i;if(!e.pathD)return;t.save();const l=new Path2D(e.pathD);e.style.fill&&"none"!==e.style.fill&&(t.fillStyle=e.style.fill,t.globalAlpha=null!==(r=null!==(n=e.style.fillOpacity)&&void 0!==n?n:e.style.opacity)&&void 0!==r?r:.5,t.fill(l)),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=e.style.stroke,t.lineWidth=null!==(o=e.style.strokeWidth)&&void 0!==o?o:.5,t.globalAlpha=.3*(null!==(i=e.style.opacity)&&void 0!==i?i:1),t.stroke(l)),e._pulseIntensity&&e._pulseIntensity>0&&(t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.globalAlpha=.25*e._pulseIntensity,t.fill(l)),t.restore()}function Mo(t,e){var n,r;if(!e.pathD)return;t.save();const o=new Path2D(e.pathD);t.strokeStyle=e.style.stroke||"#999",t.lineWidth=null!==(n=e.style.strokeWidth)&&void 0!==n?n:1,void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),t.stroke(o),e.style.fill&&"none"!==e.style.fill&&(t.fillStyle=e.style.fill,t.globalAlpha=null!==(r=e.style.fillOpacity)&&void 0!==r?r:.1,t.fill(o)),t.restore()}ko.displayName="NetworkSVGOverlay";const So={top:20,right:80,bottom:20,left:80},Po={top:40,right:40,bottom:40,left:40},_o=new Set(["chord","force","circlepack","orbit"]),Do=[800,600],To={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 Lo({data:e}){var n,r,o,i,l,a;if("edge"===e.type){const n=e.data;return t.createElement("div",{className:"semiotic-tooltip",style:To},t.createElement("div",{style:{fontWeight:600}},"object"==typeof n.source?n.source.id:n.source," → ","object"==typeof n.target?n.target.id:n.target),null!=n.value&&t.createElement("div",{style:{marginTop:4,opacity:.8}},"Value:"," ","number"==typeof n.value?n.value.toLocaleString():n.value+""))}const s=e.data,c=null==s?void 0:s.__hierarchyNode;if(c){const e=[];let l=c;for(;l;){const t=null!==(i=null!==(r=null===(n=l.data)||void 0===n?void 0:n.name)&&void 0!==r?r:null===(o=l.data)||void 0===o?void 0:o.id)&&void 0!==i?i:s.id;null!=t&&e.unshift(t+""),l=l.parent}e.length>1&&e.shift();const a=e.length-1;return t.createElement("div",{className:"semiotic-tooltip",style:To},t.createElement("div",null,e.map((e,n)=>t.createElement("span",{key:n},n>0&&t.createElement("span",{style:{margin:"0 3px",opacity:.5}}," → "),n===a?t.createElement("strong",null,e):t.createElement("span",{style:{opacity:.7}},e)))),null!=s.value&&s.value>0&&t.createElement("div",{style:{marginTop:4,opacity:.8}},"number"==typeof s.value?s.value.toLocaleString():s.value+""))}const u=((null===(l=s.sourceLinks)||void 0===l?void 0:l.length)||0)+((null===(a=s.targetLinks)||void 0===a?void 0:a.length)||0),d=(s.sourceLinks||[]).reduce((t,e)=>t+(e.value||0),0)+(s.targetLinks||[]).reduce((t,e)=>t+(e.value||0),0);return t.createElement("div",{className:"semiotic-tooltip",style:To},t.createElement("div",{style:{fontWeight:600}},s.id),null!=s.value&&s.value>0&&t.createElement("div",{style:{marginTop:4,opacity:.8}},"Total:"," ","number"==typeof s.value?s.value.toLocaleString():s.value+""),u>0&&t.createElement("div",{style:{marginTop:4,opacity:.8}},"Connections: ",u,d!==u&&` (weighted: ${d.toLocaleString()})`))}const Co=c(function(i,l){var a,c,d,h,f,y,g,p,v,m,x,b,k,w;const{chartType:E,nodes:A,edges:M,data:S,initialEdges:P,nodeIDAccessor:_="id",sourceAccessor:D="source",targetAccessor:T="target",valueAccessor:L="value",childrenAccessor:C,hierarchySum:N,orientation:$="horizontal",nodeAlign:O="justify",nodePaddingRatio:I=.05,nodeWidth:W=15,iterations:z=300,forceStrength:B=.1,padAngle:j=.01,groupWidth:F=20,sortGroups:R,edgeSort:Y,treeOrientation:H="vertical",edgeType:X="curve",padding:G,paddingTop:V,tensionConfig:q,showParticles:U=!1,particleStyle:Z,nodeStyle:Q,edgeStyle:J,colorBy:tt,colorScheme:et="category10",edgeColorBy:nt="source",edgeOpacity:rt=.5,colorByDepth:ot=!1,nodeSize:it=8,nodeSizeRange:lt=[5,20],nodeLabel:at,showLabels:st=!0,labelMode:ct,size:ut=Do,responsiveWidth:dt,responsiveHeight:ht,margin:ft,className:yt,background:gt,enableHover:pt=!0,tooltipContent:vt,customHoverBehavior:mt,customClickBehavior:xt,onObservation:bt,chartId:wt,onTopologyChange:Et,annotations:At,svgAnnotationRules:Mt,legend:St,legendPosition:Pt,legendHoverBehavior:_t,legendClickBehavior:Dt,legendHighlightedCategory:Tt,legendIsolatedCategories:Lt,title:Ct,foregroundGraphics:Nt,backgroundGraphics:$t,decay:Ot,pulse:It,staleness:Wt,thresholds:zt,accessibleTable:Bt=!0,description:jt,summary:Ft,orbitMode:Rt,orbitSize:Yt,orbitSpeed:Ht,orbitRevolution:Xt,orbitRevolutionStyle:Gt,orbitEccentricity:Vt,orbitShowRings:qt,orbitAnimated:Ut}=i,Kt=dn(),Zt=e(Kt);Zt.current=Kt;const Qt="semiotic-table-"+t.useId(),Jt=_o.has(E)?Po:So,[re,oe]=ie(ut,dt,ht),ae=Object.assign(Object.assign({},Jt),ft),se=oe[0]-ae.left-ae.right,ce=oe[1]-ae.top-ae.bottom,ue="function"==typeof Nt?Nt({size:oe,margin:ae}):Nt,de=n(()=>Object.assign(Object.assign({},Un),q),[q]),he=n(()=>Object.assign(Object.assign({},Kn),Z),[Z]),fe=n(()=>({chartType:E,nodeIDAccessor:_,sourceAccessor:D,targetAccessor:T,valueAccessor:L,childrenAccessor:C,hierarchySum:N,orientation:$,nodeAlign:O,nodePaddingRatio:I,nodeWidth:W,iterations:z,forceStrength:B,padAngle:j,groupWidth:F,sortGroups:R,edgeSort:Y,treeOrientation:H,edgeType:X,padding:G,paddingTop:V,tensionConfig:de,showParticles:U,particleStyle:he,nodeStyle:Q,edgeStyle:J,nodeLabel:at,showLabels:st,labelMode:ct,colorBy:tt,colorScheme:et,edgeColorBy:nt,edgeOpacity:rt,colorByDepth:ot,nodeSize:it,nodeSizeRange:lt,decay:Ot,pulse:It,staleness:Wt,thresholds:zt,orbitMode:Rt,orbitSize:Yt,orbitSpeed:Ht,orbitRevolution:Xt,orbitRevolutionStyle:Gt,orbitEccentricity:Vt,orbitShowRings:qt,orbitAnimated:Ut}),[E,_,D,T,L,C,N,$,O,I,W,z,B,j,F,R,Y,H,X,G,V,de,U,he,Q,J,at,st,ct,tt,et,nt,rt,ot,it,lt,Ot,It,Wt,zt,Rt,Yt,Ht,Xt,Gt,Vt,qt,Ut]),ye=e(null),ge=e(0),pe=e(0),ve=e(!0),me=mn(t=>t.theme),xe=e(()=>{}),be=e(null);be.current||(be.current=new fo(fe));const[ke,we]=o(null),[Ee,Ae]=o(0),[Me,Se]=o(0),[Pe,_e]=o(!1),De=e(null),Te=e(new Map),Le=e(0),Ce=s(t=>{if("function"==typeof tt)return tt(t)+"";if("string"==typeof tt&&t.data){const e=t.data[tt];if(void 0!==e){if(!Te.current.has(e+"")){const t=Array.isArray(et)?et:kt;Te.current.set(e+"",t[Le.current++%t.length])}return Te.current.get(e+"")}}if(Te.current.has(t.id))return Te.current.get(t.id);const e=Array.isArray(et)?et:kt,n=tt?e[Le.current++%e.length]:e[0];return Te.current.set(t.id,n),n},[tt,et]),Ne=s(t=>{if("function"==typeof nt)return nt(t);const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;return"target"===nt&&n?Ce(n):e?Ce(e):"#999"},[nt,Ce]),$e=s(t=>{if(!(null==Z?void 0:Z.colorBy))return Ne(t);const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;return"target"===he.colorBy&&n?Ce(n):e?Ce(e):"#999"},[null==Z?void 0:Z.colorBy,he.colorBy,Ce,Ne]),Oe="sankey"===E&&U||!!It||null!==(c=null===(a=be.current)||void 0===a?void 0:a.isAnimating)&&void 0!==c&&c,Ie=s(()=>{ge.current&&!Oe||ge.current||(ge.current=requestAnimationFrame(()=>xe.current()))},[Oe]);r(()=>{var t;null===(t=be.current)||void 0===t||t.updateConfig(fe),ve.current=!0,Ie()},[fe,Ie]),r(()=>{ve.current=!0,Ie()},[me,Ie]);const We=s(()=>{var t;const e=be.current;if(!e)return;e.runLayout([se,ce]),e.buildScene([se,ce]),ve.current=!0;for(const n of e.sceneNodes)n.id&&"string"==typeof(null===(t=n.style)||void 0===t?void 0:t.fill)&&Te.current.set(n.id,n.style.fill);const n=Array.isArray(et)?et:kt,r=Array.from(e.nodes.values());for(let t=0;r.length>t;t++){const e=r[t];Te.current.has(e.id)||Te.current.set(e.id,n[t%n.length])}if(Le.current=r.length,Ae(e.layoutVersion),Et){const{nodes:t,edges:n}=e.getLayoutData();Et(t,n)}},[se,ce,Et,et]),ze=s(t=>{const e=be.current;e&&(e.ingestEdge(t)&&We(),Ie())},[We,Ie]),Be=s(t=>{const e=be.current;if(!e)return;let n=!1;for(const r of t)e.ingestEdge(r)&&(n=!0);n&&We(),Ie()},[We,Ie]),je=s(()=>{var t;null===(t=be.current)||void 0===t||t.clear(),Te.current.clear(),Le.current=0,Ae(0),we(null),De.current=null,ve.current=!0,Ie()},[Ie]),Ye=s(()=>{const t=be.current;t&&(t.tension+=999,We(),Ie())},[We,Ie]);u(l,()=>({push:ze,pushMany:Be,removeNode:t=>{var e,n;const r=null!==(n=null===(e=be.current)||void 0===e?void 0:e.removeNode(t))&&void 0!==n&&n;return r&&(Te.current.delete(t),We(),ve.current=!0,Ie()),r},removeEdge:(t,e)=>{var n,r;const o=null!==(r=null===(n=be.current)||void 0===n?void 0:n.removeEdge(t,e))&&void 0!==r&&r;return o&&(We(),ve.current=!0,Ie()),o},updateNode:(t,e)=>{var n,r;const o=null!==(r=null===(n=be.current)||void 0===n?void 0:n.updateNode(t,e))&&void 0!==r?r:null;return o&&(ve.current=!0,Ie()),o},updateEdge:(t,e,n)=>{var r,o;const i=null!==(o=null===(r=be.current)||void 0===r?void 0:r.updateEdge(t,e,n))&&void 0!==o?o:[];return i.length>0&&(We(),ve.current=!0,Ie()),i},clear:je,getTopology:()=>{var t,e;return null!==(e=null===(t=be.current)||void 0===t?void 0:t.getLayoutData())&&void 0!==e?e:{nodes:[],edges:[]}},getTopologyDiff:()=>{const t=be.current;return t?{addedNodes:Array.from(t.addedNodes),removedNodes:Array.from(t.removedNodes),addedEdges:Array.from(t.addedEdges),removedEdges:Array.from(t.removedEdges)}:{addedNodes:[],removedNodes:[],addedEdges:[],removedEdges:[]}},relayout:Ye,getTension:()=>{var t,e;return null!==(e=null===(t=be.current)||void 0===t?void 0:t.tension)&&void 0!==e?e:0}}),[ze,Be,je,Ye,We,Ie]);const He=["tree","cluster","treemap","circlepack","partition","orbit"].includes(E),Xe=He?S||(Array.isArray(M)?void 0:M):void 0;r(()=>{var t;const e=be.current;if(e)if(He&&Xe)e.ingestHierarchy(Xe,[se,ce]),e.buildScene([se,ce]),ve.current=!0,Ie();else{const n=A||[],r=Array.isArray(M)?M:[];if(0===n.length&&0===r.length)return;e.ingestBounded(n,r,[se,ce]),e.buildScene([se,ce]);for(const n of e.sceneNodes)n.id&&(null===(t=n.style)||void 0===t?void 0:t.fill)&&Te.current.set(n.id,n.style.fill+"");const o=Array.isArray(et)?et:kt,i=Array.from(e.nodes.values());for(let t=0;i.length>t;t++){const e=i[t];Te.current.has(e.id)||Te.current.set(e.id,o[t%o.length])}Le.current=i.length,ve.current=!0,Ie()}},[A,M,S,Xe,He,se,ce,fe,Ie,et]),r(()=>{P&&P.length>0&&Be(P)},[]);const Ge=s(t=>{if(mt&&mt(t),bt){const e=Date.now();bt(t?{type:"hover",datum:t.data||{},x:t.x,y:t.y,timestamp:e,chartType:"StreamNetworkFrame",chartId:wt}:{type:"hover-end",timestamp:e,chartType:"StreamNetworkFrame",chartId:wt})}},[mt,bt,wt]),qe=s(t=>{if(xt&&xt(t),bt){const e=Date.now();bt(t?{type:"click",datum:t.data||{},x:t.x,y:t.y,timestamp:e,chartType:"StreamNetworkFrame",chartId:wt}:{type:"click-end",timestamp:e,chartType:"StreamNetworkFrame",chartId:wt})}},[xt,bt,wt]),Ue=e(()=>{}),Ke=e(()=>{});Ue.current=t=>{if(!pt)return;const e=ye.current;if(!e)return;const n=e.getBoundingClientRect(),r=t.clientX-n.left-ae.left,o=t.clientY-n.top-ae.top;if(0>r||r>se||0>o||o>ce)return void(De.current&&(De.current=null,we(null),Ge&&(Ge(null),ve.current=!0),Ie()));const i=be.current;if(!i)return;const l=go(i.sceneNodes,i.sceneEdges,r,o);if(!l)return void(De.current&&(De.current=null,we(null),Ge&&(Ge(null),ve.current=!0),Ie()));const a=l.datum||{},s=Object.assign(Object.assign({},"object"!=typeof a||null===a||Array.isArray(a)?{}:a),{type:l.type,data:a,x:l.x,y:l.y});De.current=s,we(s),Ge&&(Ge(s),ve.current=!0),Ie()},Ke.current=()=>{De.current&&(De.current=null,we(null),Ge&&(Ge(null),ve.current=!0),Ie())};const Ze=e(()=>{});Ze.current=t=>{if(!xt&&!bt)return;const e=ye.current;if(!e)return;const n=e.getBoundingClientRect(),r=t.clientX-n.left-ae.left,o=t.clientY-n.top-ae.top;if(0>r||r>se||0>o||o>ce)return;const i=be.current;if(!i)return;const l=go(i.sceneNodes,i.sceneEdges,r,o);if(l){const t=l.datum||{};qe(Object.assign(Object.assign({},"object"!=typeof t||null===t||Array.isArray(t)?{}:t),{type:l.type,data:t,x:l.x,y:l.y}))}else qe(null)},s(t=>Ue.current(t),[]);const Qe=s(()=>Ke.current(),[]),Je=s(t=>Ze.current(t),[]),tn=e(-1),en=e(null),nn=e(-1),sn=s(t=>{var e;const n=be.current;if(!n)return;const r=function(t){var e,n,r,o,i,l;const a=[];for(const s of t)"circle"===s.type&&null!=s.cx?a.push({x:s.cx,y:s.cy,datum:s.datum,shape:"circle",group:null!==(n=null===(e=s.datum)||void 0===e?void 0:e.id)&&void 0!==n?n:"_default"}):"rect"===s.type&&null!=s.x?a.push({x:s.x+s.w/2,y:s.y+s.h/2,datum:s.datum,shape:"rect",w:s.w,h:s.h,group:null!==(o=null===(r=s.datum)||void 0===r?void 0:r.id)&&void 0!==o?o:"_default"}):"arc"===s.type&&null!=s.cx&&a.push({x:s.cx,y:s.cy,datum:s.datum,shape:"circle",group:null!==(l=null===(i=s.datum)||void 0===i?void 0:i.id)&&void 0!==l?l:"_default"});return a.sort((t,e)=>t.x-e.x||t.y-e.y),a}(n.sceneNodes);if(0===r.length)return;const o=te(r),i=tn.current;if(0>i){if("Escape"===t.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Enter"].includes(t.key))return;t.preventDefault(),tn.current=0,nn.current=-1;const e=o.flat[0];en.current={shape:e.shape,w:e.w,h:e.h};const n=e.datum||{},r=Object.assign(Object.assign({},"object"!=typeof n||null===n||Array.isArray(n)?{}:n),{type:"node",data:n,x:e.x,y:e.y});return De.current=r,we(r),Ge&&(Ge(r),ve.current=!0),void Ie()}const l=ee(o,i),a=function(t,e,n,r,o){var i,l,a;const s=n.flat[e.flatIndex];if(!s)return ne(t,e,n);const c=null===(i=s.datum)||void 0===i?void 0:i.id;switch(t){case"ArrowRight":case"ArrowLeft":case"ArrowDown":case"ArrowUp":{const r=null!==(l=function(t,e,n){let r=null,o=1/0;for(let i=0;t.flat.length>i;i++){const l=t.flat[i];if(l===e)continue;const a=l.x-e.x,s=l.y-e.y;let c=!1;switch(n){case"right":c=a>0&&Math.abs(a)>=Math.abs(s);break;case"left":c=0>a&&Math.abs(a)>=Math.abs(s);break;case"down":c=s>0&&Math.abs(s)>=Math.abs(a);break;case"up":c=0>s&&Math.abs(s)>=Math.abs(a)}if(!c)continue;const u=a*a+s*s;o>u&&(o=u,r=i)}return r}(n,s,"ArrowRight"===t?"right":"ArrowLeft"===t?"left":"ArrowDown"===t?"down":"up"))&&void 0!==l?l:e.flatIndex;return r!==e.flatIndex&&(o.current=-1),r}case"Enter":{if(null==c)return e.flatIndex;const t=function(t,e){var n,r,o;const i=t+"",l=[];for(const t of e){const e=null!==(n=t.datum)&&void 0!==n?n:t,a="object"==typeof e.source?null===(r=e.source)||void 0===r?void 0:r.id:e.source,s="object"==typeof e.target?null===(o=e.target)||void 0===o?void 0:o.id:e.target,c=null!=a,u=null!=s;c&&a+""===i&&u?l.push(s+""):u&&s+""===i&&c&&l.push(a+"")}return l}(c,r);if(0===t.length)return e.flatIndex;const i=null!==(a=n.idToIdx.get(t[(o.current+1)%t.length]))&&void 0!==a?a:-1;return 0>i?e.flatIndex:(o.current=-1,i)}default:{const r=ne(t,e,n);return null!==r&&r!==e.flatIndex&&(o.current=-1),r}}}(t.key,l,o,null!==(e=n.sceneEdges)&&void 0!==e?e:[],nn);if(null===a)return;if(t.preventDefault(),0>a)return tn.current=-1,en.current=null,nn.current=-1,De.current=null,we(null),Ge&&(Ge(null),ve.current=!0),void Ie();tn.current=a;const s=o.flat[a];en.current={shape:s.shape,w:s.w,h:s.h};const c=s.datum||{},u=Object.assign(Object.assign({},"object"!=typeof c||null===c||Array.isArray(c)?{}:c),{type:"node",data:c,x:s.x,y:s.y});De.current=u,we(u),Ge&&(Ge(u),ve.current=!0),Ie()},[Ge,Ie]),hn=s(t=>{tn.current=-1,en.current=null,Ue.current(t)},[]);xe.current=()=>{var t,e,n,r,o,i,l;ge.current=0;const a=ye.current;if(!a)return;const s=a.getContext("2d");if(!s)return;const c=be.current;if(!c)return;const u=performance.now(),d=pe.current?Math.min((u-pe.current)/1e3,.1):.016;pe.current=u;const h=c.advanceTransition(Zt.current?u+1e6:u),f=!Zt.current&&h,y=!Zt.current&&c.tickAnimation([se,ce],d);(h||ve.current||y)&&c.buildScene([se,ce]);const g=bn();if(!xn(a,oe,ae,g))return;s.clearRect(-ae.left,-ae.top,oe[0],oe[1]),gt&&(s.fillStyle=gt,s.fillRect(0,0,se,ce)),Ot&&c.applyDecay(),It&&c.applyPulse(u),zt&&c.applyThresholds(u),c.applyTopologyDiff(u);const p=null!==(t=null==Wt?void 0:Wt.threshold)&&void 0!==t?t:5e3,v=Wt&&c.lastIngestTime>0&&u-c.lastIngestTime>p;if(v&&(s.globalAlpha=null!==(e=null==Wt?void 0:Wt.dimOpacity)&&void 0!==e?e:.5),function(t,e){for(const n of e)switch(n.type){case"bezier":wo(t,n);break;case"line":Eo(t,n);break;case"ribbon":Ao(t,n);break;case"curved":Mo(t,n)}}(s,c.sceneEdges),function(t,e){var n,r,o;for(const i of e){if("rect"!==i.type)continue;const e=i;e.w>0&&e.h>0&&(t.save(),void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.fill&&(t.fillStyle=e.style.fill,void 0!==e.style.fillOpacity&&(t.globalAlpha=(null!==(n=e.style.opacity)&&void 0!==n?n:1)*e.style.fillOpacity),t.fillRect(e.x,e.y,e.w,e.h)),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=e.style.stroke,t.lineWidth=null!==(r=e.style.strokeWidth)&&void 0!==r?r:1,t.globalAlpha=null!==(o=e.style.opacity)&&void 0!==o?o:1,t.strokeRect(e.x,e.y,e.w,e.h)),Dn(t,e),t.restore())}}(s,c.sceneNodes),function(t,e){var n,r,o;for(const i of e){if("circle"!==i.type)continue;const e=i;e.r>0&&(t.save(),void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),t.beginPath(),t.arc(e.cx,e.cy,e.r,0,2*Math.PI),e.style.fill&&(t.fillStyle=e.style.fill,void 0!==e.style.fillOpacity&&(t.globalAlpha=(null!==(n=e.style.opacity)&&void 0!==n?n:1)*e.style.fillOpacity),t.fill()),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=e.style.stroke,t.lineWidth=null!==(r=e.style.strokeWidth)&&void 0!==r?r:1,t.globalAlpha=null!==(o=e.style.opacity)&&void 0!==o?o:1,t.stroke()),Tn(t,e),t.restore())}}(s,c.sceneNodes),function(t,e){var n,r,o;for(const i of e){if("arc"!==i.type)continue;const e=i;t.save(),void 0!==e.style.opacity&&(t.globalAlpha=e.style.opacity),t.beginPath(),t.arc(e.cx,e.cy,e.outerR,e.startAngle,e.endAngle),t.arc(e.cx,e.cy,e.innerR,e.endAngle,e.startAngle,!0),t.closePath(),e.style.fill&&(t.fillStyle=e.style.fill,void 0!==e.style.fillOpacity&&(t.globalAlpha=(null!==(n=e.style.opacity)&&void 0!==n?n:1)*e.style.fillOpacity),t.fill()),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=e.style.stroke,t.lineWidth=null!==(r=e.style.strokeWidth)&&void 0!==r?r:1,t.globalAlpha=null!==(o=e.style.opacity)&&void 0!==o?o:1,t.stroke()),t.restore()}}(s,c.sceneNodes),U&&c.particlePool&&!v){const t=Array.from(c.edges.values());if(t.length>0){!function(t,e,n,r){var o,i;const l=null!==(o=r.spawnRate)&&void 0!==o?o:Kn.spawnRate,a=null!==(i=r.maxPerEdge)&&void 0!==i?i:Kn.maxPerEdge;for(let r=0;e.length>r;r++){const o=e[r];if(!o.bezier)continue;if(t.countForEdge(r)>=a)continue;const i=o.value*l*n*(o.bezier.circular?.3:1),s=Math.floor(i),c=i-s;let u=s;Math.random()<c&&u++;for(let e=0;u>e&&t.countForEdge(r)<a;e++)t.spawn(r)}}(c.particlePool,t,d,he);const e=.5*(null!==(n=he.speedMultiplier)&&void 0!==n?n:1);let r;if(he.proportionalSpeed){const e=t.reduce((t,e)=>Math.max(t,e.value||1),1);r=t.map(t=>.3+(t.value||1)/e*1.7)}c.particlePool.step(d,e,t,r),function(t,e,n,r,o){var i,l;const a=null!==(i=r.radius)&&void 0!==i?i:Kn.radius,s=null!==(l=r.opacity)&&void 0!==l?l:Kn.opacity;t.globalAlpha=s;for(let i=0;e.particles.length>i;i++){const l=e.particles[i];if(!l.active)continue;const s=n[l.edgeIndex];if(s){if("function"==typeof r.color){const e="object"==typeof s.source?s.source:null;t.fillStyle=e?r.color(s,e):"#666"}else t.fillStyle=r.color&&"inherit"!==r.color?r.color:o(s);t.beginPath(),t.arc(l.x,l.y,a,0,2*Math.PI),t.fill()}}t.globalAlpha=1}(s,c.particlePool,t,he,$e)}}v&&(s.globalAlpha=1);const m=ve.current;if(ve.current=!1,m||f||y){const t=ye.current;t&&t.setAttribute("aria-label",Ve(null!==(o=null===(r=c.sceneNodes)||void 0===r?void 0:r.length)&&void 0!==o?o:0,null!==(l=null===(i=c.sceneEdges)||void 0===i?void 0:i.length)&&void 0!==l?l:0,"Network chart"))}(m||f||y)&&Se(t=>t+1),(Oe||f||y||c.hasActivePulses||c.hasActiveThresholds||c.hasActiveTopologyDiff)&&(ge.current=requestAnimationFrame(()=>xe.current()))},r(()=>(Ie(),()=>{ge.current&&(cancelAnimationFrame(ge.current),ge.current=0)}),[Ie]),r(()=>{ve.current=!0,Ie()},[E,se,ce,gt,Ie]),le(Wt,be,ve,Ie,Pe,_e);const fn=pt&&ke?t.createElement(un,{x:ke.x,y:ke.y,containerWidth:se,containerHeight:ce,margin:ae,className:"stream-network-tooltip",zIndex:2},vt?vt(ke):t.createElement(Lo,{data:ke})):null;if(Re){const e=be.current;if(e){const t=["tree","cluster","treemap","circlepack","partition","orbit"].includes(E),n=t?S||(Array.isArray(M)?void 0:M):void 0;if(t&&n)e.ingestHierarchy(n,[se,ce]),e.buildScene([se,ce]);else{const t=A||[],n=Array.isArray(M)?M:[];(t.length>0||n.length>0)&&(e.ingestBounded(t,n,[se,ce]),e.buildScene([se,ce]))}}const n=null!==(d=null==e?void 0:e.sceneNodes)&&void 0!==d?d:[],r=null!==(h=null==e?void 0:e.sceneEdges)&&void 0!==h?h:[],o=null!==(f=null==e?void 0:e.labels)&&void 0!==f?f:[];return t.createElement("div",{className:"stream-network-frame"+(yt?" "+yt:""),role:"img","aria-label":jt||("string"==typeof Ct?Ct:"Network chart"),style:{position:"relative",width:oe[0],height:oe[1]}},t.createElement(on,{summary:Ft}),t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:oe[0],height:oe[1],style:{position:"absolute",left:0,top:0}},$t&&t.createElement("g",{transform:`translate(${ae.left},${ae.top})`},$t),t.createElement("g",{transform:`translate(${ae.left},${ae.top})`},gt&&t.createElement("rect",{x:0,y:0,width:se,height:ce,fill:gt}),r.map((e,n)=>function(e,n){switch(e.type){case"line":return t.createElement("line",{key:"net-edge-"+n,x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity});case"bezier":{const r=e;return t.createElement("path",{key:"net-edge-"+n,d:r.pathD,fill:Fe(r.style.fill,"#999"),fillOpacity:r.style.fillOpacity,stroke:r.style.stroke||"none",strokeWidth:r.style.strokeWidth,opacity:r.style.opacity})}case"ribbon":{const r=e;return t.createElement("path",{key:"net-edge-"+n,d:r.pathD,fill:Fe(r.style.fill,"#999"),fillOpacity:r.style.fillOpacity,stroke:r.style.stroke||"none",strokeWidth:r.style.strokeWidth,opacity:r.style.opacity})}case"curved":{const r=e;return t.createElement("path",{key:"net-edge-"+n,d:r.pathD,fill:Fe(r.style.fill,"none"),stroke:r.style.stroke||"#999",strokeWidth:r.style.strokeWidth||1,opacity:r.style.opacity})}default:return null}}(e,n)).filter(Boolean),n.map((e,n)=>function(e,n){switch(e.type){case"circle":{const r=e;return t.createElement("circle",{key:"net-circle-"+n,cx:r.cx,cy:r.cy,r:r.r,fill:Fe(r.style.fill),stroke:r.style.stroke,strokeWidth:r.style.strokeWidth,opacity:r.style.opacity})}case"rect":{const r=e;return t.createElement("rect",{key:"net-rect-"+n,x:r.x,y:r.y,width:r.w,height:r.h,fill:Fe(r.style.fill),stroke:r.style.stroke,strokeWidth:r.style.strokeWidth,opacity:r.style.opacity})}case"arc":{const r=e,o=K().innerRadius(r.innerR).outerRadius(r.outerR).startAngle(r.startAngle).endAngle(r.endAngle)({})||"";return t.createElement("path",{key:"net-arc-"+n,d:o,transform:`translate(${r.cx},${r.cy})`,fill:Fe(r.style.fill),stroke:r.style.stroke,strokeWidth:r.style.strokeWidth,opacity:r.style.opacity})}default:return null}}(e,n)).filter(Boolean),o.map((e,n)=>function(e,n){return t.createElement("text",{key:"net-label-"+n,x:e.x,y:e.y,textAnchor:e.anchor||"middle",dominantBaseline:e.baseline||"auto",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"#333",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder},e.text)}(e,n)).filter(Boolean))),t.createElement(ko,{width:se,height:ce,totalWidth:oe[0],totalHeight:oe[1],margin:ae,labels:o,sceneNodes:n,title:Ct,legend:St,legendPosition:Pt,legendHoverBehavior:_t,legendClickBehavior:Dt,legendHighlightedCategory:Tt,legendIsolatedCategories:Lt,foregroundGraphics:ue,annotations:At,svgAnnotationRules:Mt,annotationFrame:0}))}const yn=be.current;return t.createElement("div",{ref:re,className:"stream-network-frame"+(yt?" "+yt:""),role:"group","aria-label":jt||("string"==typeof Ct?Ct:"Network chart"),tabIndex:0,style:{position:"relative",width:dt?"100%":oe[0],height:ht?"100%":oe[1],overflow:"visible"},onKeyDown:sn},Bt&&t.createElement(ln,{tableId:Qt}),Bt&&t.createElement(rn,{nodes:null!==(y=null==yn?void 0:yn.sceneNodes)&&void 0!==y?y:[],edges:null!==(g=null==yn?void 0:yn.sceneEdges)&&void 0!==g?g:[],chartType:"Network chart",tableId:Qt,chartTitle:"string"==typeof Ct?Ct:void 0}),t.createElement(on,{summary:Ft}),t.createElement("div",{role:"img","aria-label":jt||("string"==typeof Ct?Ct:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:pt?hn:void 0,onMouseLeave:pt?Qe:void 0,onClick:xt||bt?Je:void 0},$t&&t.createElement("svg",{overflow:"visible",style:{position:"absolute",top:0,left:0,width:oe[0],height:oe[1],pointerEvents:"none",overflow:"visible"}},t.createElement("g",{transform:`translate(${ae.left},${ae.top})`},$t)),t.createElement("canvas",{ref:ye,"aria-label":Ve(null!==(v=null===(p=null==yn?void 0:yn.sceneNodes)||void 0===p?void 0:p.length)&&void 0!==v?v:0,null!==(x=null===(m=null==yn?void 0:yn.sceneEdges)||void 0===m?void 0:m.length)&&void 0!==x?x:0,"Network chart"),style:{position:"absolute",top:0,left:0}}),t.createElement(an,{hoverPoint:ke}),t.createElement(ko,{width:se,height:ce,totalWidth:oe[0],totalHeight:oe[1],margin:ae,labels:(null==yn?void 0:yn.labels)||[],sceneNodes:null==yn?void 0:yn.sceneNodes,title:Ct,legend:St,legendPosition:Pt,legendHoverBehavior:_t,legendClickBehavior:Dt,legendHighlightedCategory:Tt,legendIsolatedCategories:Lt,foregroundGraphics:ue,annotations:At,svgAnnotationRules:Mt,annotationFrame:Me}),t.createElement(cn,{active:tn.current>=0,hoverPoint:ke,margin:ae,size:oe,shape:null===(b=en.current)||void 0===b?void 0:b.shape,width:null===(k=en.current)||void 0===k?void 0:k.w,height:null===(w=en.current)||void 0===w?void 0:w.h}),fn,(null==Wt?void 0:Wt.showBadge)&&t.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===Wt.badgePosition?{top:4,left:4}:"bottom-left"===Wt.badgePosition?{bottom:4,left:4}:"bottom-right"===Wt.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{background:Pe?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"})},Pe?"STALE":"LIVE")))});function No(t){const e=[];for(const[n,r]of Object.entries(t.fields))if("point"===r.type)e.push(t=>r.values.has(t[n]));else{const[t,o]=r.range;e.push(e=>{const r=e[n];return r>=t&&o>=r})}return t=>e.every(e=>e(t))}function $o(t,e){let n=t.get(e);return n||(n={name:e,resolution:"union",clauses:new Map},t.set(e,n)),n}Co.displayName="StreamNetworkFrame";const[Oo,Io]=hn(t=>({selections:new Map,setClause(e,n){t(t=>{const r=new Map(t.selections),o=$o(r,e),i=new Map(o.clauses);return i.set(n.clientId,n),r.set(e,Object.assign(Object.assign({},o),{clauses:i})),{selections:r}})},clearClause(e,n){t(t=>{const r=t.selections.get(e);if(!r)return{};const o=new Map(t.selections),i=new Map(r.clauses);return i.delete(n),o.set(e,Object.assign(Object.assign({},r),{clauses:i})),{selections:o}})},setResolution(e,n){t(t=>{const r=new Map(t.selections),o=$o(r,e);return r.set(e,Object.assign(Object.assign({},o),{resolution:n})),{selections:r}})},clearSelection(e){t(t=>{const n=new Map(t.selections),r=n.get(e);return r&&n.set(e,Object.assign(Object.assign({},r),{clauses:new Map})),{selections:n}})}})),[Wo,zo]=hn(t=>({observations:[],maxObservations:100,version:0,pushObservation(e){t(t=>{const n=t.observations;return n.push(e),n.length>t.maxObservations&&n.shift(),{version:t.version+1}})},clearObservations(){t(()=>({observations:[],version:0}))}}));function Bo(t){const e=d(),r=t.clientId||e,{name:o}=t,i=Io(t=>t.selections.get(o)),l=Io(t=>t.setClause),a=Io(t=>t.clearClause),c=n(()=>!!i&&i.clauses.size>0,[i]);return{predicate:n(()=>i&&0!==i.clauses.size?function(t,e){const n=[];for(const[r,o]of t.clauses)"crossfilter"===t.resolution&&r===e||n.push(No(o));return 0===n.length?()=>!0:"intersect"===t.resolution?t=>n.every(e=>e(t)):t=>n.some(e=>e(t))}(i,r):()=>!0,[i,r]),isActive:c,selectPoints:s(t=>{const e={};for(const[n,r]of Object.entries(t))e[n]={type:"point",values:new Set(r)};l(o,{clientId:r,type:"point",fields:e})},[r,o,l]),selectInterval:s(t=>{const e={};for(const[n,r]of Object.entries(t))e[n]={type:"interval",range:r};l(o,{clientId:r,type:"interval",fields:e})},[r,o,l]),clear:s(()=>{a(o,r)},[a,o,r]),clientId:r}}function jo({selection:t,linkedHover:e,fallbackFields:i=[],unwrapData:l=!1,onObservation:a,chartType:c,chartId:u,onClick:h,hoverHighlight:f,colorByField:y}){const g=d(),p=function(t,e){return t?!0===t?{name:"hover",fields:e||[]}:"string"==typeof t?{name:t,fields:e||[]}:{name:t.name||"hover",fields:t.fields||e||[],mode:t.mode,xField:t.xField}:null}(e,i),v=Bo({name:(null==t?void 0:t.name)||"__unused__"}),m=function(t){const e=t.name||"hover",{fields:n}=t,{predicate:r,isActive:o,selectPoints:i,clear:l}=Bo({name:e});return{onHover:s(t=>{if(!t)return void l();const e={};for(const r of n){const n=t[r];void 0!==n&&(e[r]=[n])}Object.keys(e).length>0&&i(e)},[n,i,l,e]),predicate:r,isActive:o}}({name:(null==p?void 0:p.name)||"hover",fields:(null==p?void 0:p.fields)||i||[]}),x=zo(t=>t.pushObservation),b=t?{isActive:v.isActive,predicate:v.predicate}:null,[k,w]=o(null),E=y||i[0],A=n(()=>{if(!f||null==k||!E)return null;const t=k,e=E;return{isActive:!0,predicate:n=>{var r;return("string"==typeof n[e]?n[e]:(null!==(r=n[e])&&void 0!==r?r:"")+"")===t}}},[f,k,E]),M=s(t=>{var n,r;if(e)if(t){let e=t.data||t.datum||t;if(Array.isArray(e)&&(e=e[0]),"x-position"===(null==p?void 0:p.mode)&&p.xField){const t=null==e?void 0:e[p.xField];null!=t&&Number.isFinite(Number(t))&&function(t,e,n){const r=Me.positions.get(t);(null==r?void 0:r.locked)||r&&r.xValue===e&&r.sourceId===n||(Me={positions:new Map(Me.positions).set(t,{xValue:e,sourceId:n})},Pe())}(p.name||"hover",Number(t),g)}"x-position"!==(null==p?void 0:p.mode)&&m.onHover(e)}else"x-position"===(null==p?void 0:p.mode)&&_e(p.name||"hover",g),"x-position"!==(null==p?void 0:p.mode)&&m.onHover(null);if(f&&E)if(t){let e=t.data||t.datum||t;Array.isArray(e)&&(e=e[0]);const n=null==e?void 0:e[E];w(null!=n?n+"":null)}else w(null);if(a||x){const e={timestamp:Date.now(),chartType:c||"unknown",chartId:u};if(t){let o=t.data||t.datum||t;Array.isArray(o)&&(o=o[0]);const i=Object.assign(Object.assign({},e),{type:"hover",datum:o||{},x:null!==(n=t.x)&&void 0!==n?n:0,y:null!==(r=t.y)&&void 0!==r?r:0});a&&a(i),x&&x(i)}else{const t=Object.assign(Object.assign({},e),{type:"hover-end"});a&&a(t),x&&x(t)}}},[e,m,p,g,a,c,u,x,f,E]),S=s(t=>{var e,n,r,o;if("x-position"===(null==p?void 0:p.mode)&&p.xField&&t){let e=t.data||t.datum||t;Array.isArray(e)&&(e=e[0]);const n=null==e?void 0:e[p.xField];null!=n&&Number.isFinite(Number(n))&&function(t,e,n){const r=Me.positions.get(t);if(null==r?void 0:r.locked){const e=new Map(Me.positions);return e.delete(t),Me={positions:e},Pe(),!1}Me={positions:new Map(Me.positions).set(t,{xValue:e,sourceId:n,locked:!0})},Pe()}(p.name||"hover",Number(n),g)}if(t&&h){let r=t.data||t.datum||t;Array.isArray(r)&&(r=r[0]),h(r,{x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(n=t.y)&&void 0!==n?n:0})}if(a||x){const e={timestamp:Date.now(),chartType:c||"unknown",chartId:u};if(t){let n=t.data||t.datum||t;Array.isArray(n)&&(n=n[0]);const i=Object.assign(Object.assign({},e),{type:"click",datum:n||{},x:null!==(r=t.x)&&void 0!==r?r:0,y:null!==(o=t.y)&&void 0!==o?o:0});a&&a(i),x&&x(i)}else{const t=Object.assign(Object.assign({},e),{type:"click-end"});a&&a(t),x&&x(t)}}},[h,a,x,c,u,p,g]);return r(()=>{if("x-position"!==(null==p?void 0:p.mode))return;const t=p.name||"hover";return()=>{De(t,g),_e(t,g)}},[null==p?void 0:p.mode,null==p?void 0:p.name,g]),{activeSelectionHook:b,hoverSelectionHook:A,customHoverBehavior:M,customClickBehavior:S,crosshairSourceId:g}}const Fo={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 Ro(t,e,n){var r,o,i,l,a,s,c;const u=Fo[t||"primary"],d="context"===t||"sparkline"===t;return{width:null!==(r=e.width)&&void 0!==r?r:u.width,height:null!==(o=e.height)&&void 0!==o?o:u.height,showAxes:null!==(i=e.showAxes)&&void 0!==i?i:u.showAxes,showGrid:null!==(l=e.showGrid)&&void 0!==l?l:u.showGrid,enableHover:null!==(a=e.enableHover)&&void 0!==a?a:!!e.linkedHover||u.enableHover,showLegend:null!==(s=e.showLegend)&&void 0!==s?s:u.showLegend,showLabels:null!==(c=e.showLabels)&&void 0!==c?c:u.showLabels,title:d?void 0:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,xLabel:d?void 0:e.xLabel,yLabel:d?void 0:e.yLabel,categoryLabel:d?void 0:e.categoryLabel,valueLabel:d?void 0:e.valueLabel,marginDefaults:Yo(u.marginDefaults,e.showCategoryTicks,e.orientation)}}function Yo(t,e,n){if(!1!==e)return t;const r=Object.assign({},t);return"horizontal"===n?r.left=Math.min(r.left,15):r.bottom=Math.min(r.bottom,15),r}"undefined"!=typeof process&&process;const Ho={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"},Xo={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function Go(e,n,r,o){return!1===o||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?t.createElement("div",{style:Object.assign(Object.assign({},Ho),{width:n,height:r})},o||"No data available"):null}function Vo(e,n,r){if(!e)return null;const o=Math.min(5,Math.floor(r/40)),i=Math.max(8,Math.floor(r/(3*o))),l=Math.max(6,Math.floor(r/(2.5*o))),a=Math.floor((r-(o*(i+l)-l))/2);return t.createElement("div",{style:{width:n,height:r,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"}},Array.from({length:o},(e,r)=>t.createElement("div",{key:r,className:"semiotic-loading-bar",style:Object.assign(Object.assign({},Xo),{position:"absolute",top:a+r*(i+l),left:Math.floor(.1*n),width:30+(37*r+13)%50+"%",height:i,opacity:.5+r%2*.2})})))}const qo=c(function(n,r){var o,i,l,a;const c=Ro(n.mode,{width:null!==(i=null===(o=n.size)||void 0===o?void 0:o[0])&&void 0!==i?i:n.width,height:null!==(a=null===(l=n.size)||void 0===l?void 0:l[1])&&void 0!==a?a:n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0}),{size:d,margin:h,className:f,arrowOfTime:y="right",windowMode:g="sliding",windowSize:p=200,data:v,timeAccessor:m,valueAccessor:x,timeExtent:b,valueExtent:k,extentPadding:w,stroke:E="#007bff",strokeWidth:A=2,strokeDasharray:M,background:S,tooltipContent:P,tooltip:_,onHover:D,annotations:T,svgAnnotationRules:L,tickFormatTime:C,tickFormatValue:N,decay:$,pulse:O,staleness:I,transition:W,linkedHover:z,selection:B,onObservation:j,chartId:F,loading:R,emptyContent:Y,emphasis:H,legendPosition:X}=n,G=c.showAxes,V=c.enableHover,q=null!=h?h:c.marginDefaults,U=null!=d?d:[c.width,c.height],K=null!=P?P:_,Z=e(null),{customHoverBehavior:Q}=jo({selection:B,linkedHover:z,unwrapData:!0,onObservation:j,chartType:"RealtimeLineChart",chartId:F}),J=s(t=>{D&&D(t),Q(t)},[D,Q]);u(r,()=>({push:t=>{var e;return null===(e=Z.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=Z.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=Z.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,r;return null!==(r=null===(n=Z.current)||void 0===n?void 0:n.update(t,e))&&void 0!==r?r:[]},clear:()=>{var t;return null===(t=Z.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=Z.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const tt=Vo(R,U[0],U[1]),et=tt?null:Go(v,U[0],U[1],Y),nt={stroke:E,strokeWidth:A,strokeDasharray:M};return tt||et||t.createElement(qn,{ref:Z,chartType:"line",runtimeMode:"streaming",size:U,margin:q,className:H?`${f||""} semiotic-emphasis-${H}`.trim():f,arrowOfTime:y,windowMode:g,windowSize:p,data:v,timeAccessor:m,valueAccessor:x,xExtent:b,yExtent:k,extentPadding:w,lineStyle:nt,showAxes:G,background:S,hoverAnnotation:V,tooltipContent:K,customHoverBehavior:J,annotations:T,svgAnnotationRules:L,tickFormatTime:C,tickFormatValue:N,decay:$,pulse:O,staleness:I,transition:W,pointIdAccessor:n.pointIdAccessor,legendPosition:X})});qo.displayName="RealtimeLineChart";const Uo=c(function(r,o){var i,l,a,c;const d=Ro(r.mode,{width:null!==(l=null===(i=r.size)||void 0===i?void 0:i[0])&&void 0!==l?l:r.width,height:null!==(c=null===(a=r.size)||void 0===a?void 0:a[1])&&void 0!==c?c:r.height,enableHover:null!=r.enableHover?!!r.enableHover:void 0}),{binSize:h,size:f,margin:y,className:g,arrowOfTime:p="right",windowMode:v="sliding",windowSize:m=200,data:x,timeAccessor:b,valueAccessor:k,timeExtent:w,valueExtent:E,extentPadding:A,categoryAccessor:M,colors:S,fill:P,stroke:_,strokeWidth:D,gap:T,background:L,tooltipContent:C,tooltip:N,onHover:$,annotations:O,svgAnnotationRules:I,tickFormatTime:W,tickFormatValue:z,linkedHover:B,selection:j,decay:F,pulse:R,staleness:Y,transition:H,onObservation:X,chartId:G,loading:V,emptyContent:q,emphasis:U,legendPosition:K,brush:Z,onBrush:Q,linkedBrush:J}=r,tt=d.showAxes,et=d.enableHover,nt=null!=y?y:d.marginDefaults,rt=null!=f?f:[d.width,d.height],ot=null!=C?C:N,it=e(null),{customHoverBehavior:lt}=jo({selection:j,linkedHover:B,unwrapData:!0,onObservation:X,chartType:"RealtimeTemporalHistogram",chartId:G}),at=s(t=>{$&&$(t),lt(t)},[$,lt]),st=!0===Z?{dimension:"x",snap:"bin"}:"x"===Z?{dimension:"x"}:"object"==typeof Z?Z:void 0,ct=(ut=J)?"string"==typeof ut?{name:ut}:ut:null;var ut;const dt=function(t){const{name:e,xField:r,yField:o}=t,{predicate:i,isActive:l,selectInterval:a,clear:c}=Bo({name:e}),u=r&&o?"xyBrush":r?"xBrush":"yBrush",d=s(t=>{if(!t)return void c();const e={};"xyBrush"===u&&Array.isArray(t)&&2===t.length?(r&&(e[r]=[Math.min(t[0][0],t[1][0]),Math.max(t[0][0],t[1][0])]),o&&(e[o]=[Math.min(t[0][1],t[1][1]),Math.max(t[0][1],t[1][1])])):"xBrush"===u&&Array.isArray(t)?r&&(e[r]=[Math.min(...t),Math.max(...t)]):"yBrush"===u&&Array.isArray(t)&&o&&(e[o]=[Math.min(...t),Math.max(...t)]),Object.keys(e).length>0&&a(e)},[u,r,o,a,c]);return{brushInteraction:n(()=>({brush:u,during:d,end:d}),[u,d]),predicate:i,isActive:l,clear:c}}(Object.assign({name:(null==ct?void 0:ct.name)||"__unused_hist_brush__",xField:(null==ct?void 0:ct.xField)||("string"==typeof b?b:"time")},(null==ct?void 0:ct.yField)?{yField:ct.yField}:{})),ht=e(dt.brushInteraction);ht.current=dt.brushInteraction;const ft=s(t=>{if(Q&&Q(t),X&&X(t?{type:"brush",extent:t,timestamp:Date.now(),chartType:"RealtimeTemporalHistogram",chartId:G}:{type:"brush-end",timestamp:Date.now(),chartType:"RealtimeTemporalHistogram",chartId:G}),ct){const e=ht.current;e.end(t?"xBrush"===e.brush?t.x:"yBrush"===e.brush?t.y:[[t.x[0],t.y[0]],[t.x[1],t.y[1]]]:null)}},[Q,X,G,ct]);u(o,()=>({push:t=>{var e;return null===(e=it.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=it.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=it.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,r;return null!==(r=null===(n=it.current)||void 0===n?void 0:n.update(t,e))&&void 0!==r?r:[]},clear:()=>{var t;return null===(t=it.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=it.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const yt=Vo(V,rt[0],rt[1]),gt=yt?null:Go(x,rt[0],rt[1],q),pt={};return null!=P&&(pt.fill=P),null!=_&&(pt.stroke=_),null!=D&&(pt.strokeWidth=D),null!=T&&(pt.gap=T),yt||gt||t.createElement(qn,{ref:it,chartType:"bar",runtimeMode:"streaming",size:rt,margin:nt,className:U?`${g||""} semiotic-emphasis-${U}`.trim():g,arrowOfTime:p,windowMode:v,windowSize:m,data:x,timeAccessor:b,valueAccessor:k,xExtent:w,yExtent:E,extentPadding:A,binSize:h,categoryAccessor:M,barColors:S,barStyle:pt,showAxes:tt,background:L,hoverAnnotation:et,tooltipContent:ot,customHoverBehavior:at,annotations:O,svgAnnotationRules:I,tickFormatTime:W,tickFormatValue:z,decay:F,pulse:R,staleness:Y,transition:H,pointIdAccessor:r.pointIdAccessor,legendPosition:K,brush:st||(J?{dimension:"x"}:void 0),onBrush:st||J?ft:void 0})});Uo.displayName="RealtimeTemporalHistogram";const Ko=Uo,Zo=c(function(n,r){var o,i,l,a;const c=Ro(n.mode,{width:null!==(i=null===(o=n.size)||void 0===o?void 0:o[0])&&void 0!==i?i:n.width,height:null!==(a=null===(l=n.size)||void 0===l?void 0:l[1])&&void 0!==a?a:n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0}),{size:d,margin:h,className:f,arrowOfTime:y="right",windowMode:g="sliding",windowSize:p=200,data:v,timeAccessor:m,valueAccessor:x,timeExtent:b,valueExtent:k,extentPadding:w,categoryAccessor:E,colors:A,radius:M,fill:S,opacity:P,stroke:_,strokeWidth:D,background:T,tooltipContent:L,tooltip:C,onHover:N,annotations:$,svgAnnotationRules:O,tickFormatTime:I,tickFormatValue:W,linkedHover:z,selection:B,onObservation:j,chartId:F,loading:R,emptyContent:Y,emphasis:H,legendPosition:X}=n,G=c.showAxes,V=c.enableHover,q=null!=h?h:c.marginDefaults,U=null!=d?d:[c.width,c.height],K=null!=L?L:C,Z=e(null),{customHoverBehavior:Q}=jo({selection:B,linkedHover:z,unwrapData:!0,onObservation:j,chartType:"RealtimeSwarmChart",chartId:F}),J=s(t=>{N&&N(t),Q(t)},[N,Q]);u(r,()=>({push:t=>{var e;return null===(e=Z.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=Z.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=Z.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,r;return null!==(r=null===(n=Z.current)||void 0===n?void 0:n.update(t,e))&&void 0!==r?r:[]},clear:()=>{var t;return null===(t=Z.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=Z.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const tt=Vo(R,U[0],U[1]),et=tt?null:Go(v,U[0],U[1],Y),nt={};return null!=M&&(nt.radius=M),null!=S&&(nt.fill=S),null!=P&&(nt.opacity=P),null!=_&&(nt.stroke=_),null!=D&&(nt.strokeWidth=D),tt||et||t.createElement(qn,{ref:Z,chartType:"swarm",runtimeMode:"streaming",size:U,margin:q,className:H?`${f||""} semiotic-emphasis-${H}`.trim():f,arrowOfTime:y,windowMode:g,windowSize:p,data:v,timeAccessor:m,valueAccessor:x,xExtent:b,yExtent:k,extentPadding:w,categoryAccessor:E,barColors:A,swarmStyle:nt,showAxes:G,background:T,hoverAnnotation:V,tooltipContent:K,customHoverBehavior:J,annotations:$,svgAnnotationRules:O,tickFormatTime:I,tickFormatValue:W,legendPosition:X,pointIdAccessor:n.pointIdAccessor})});Zo.displayName="RealtimeSwarmChart";const Qo=c(function(n,r){var o,i,l,a;const c=Ro(n.mode,{width:null!==(i=null===(o=n.size)||void 0===o?void 0:o[0])&&void 0!==i?i:n.width,height:null!==(a=null===(l=n.size)||void 0===l?void 0:l[1])&&void 0!==a?a:n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0}),{size:d,margin:h,className:f,arrowOfTime:y="right",windowMode:g="sliding",windowSize:p=200,data:v,timeAccessor:m,valueAccessor:x,timeExtent:b,valueExtent:k,extentPadding:w,positiveColor:E,negativeColor:A,connectorStroke:M,connectorWidth:S,gap:P,stroke:_,strokeWidth:D,background:T,tooltipContent:L,tooltip:C,onHover:N,annotations:$,svgAnnotationRules:O,tickFormatTime:I,tickFormatValue:W,linkedHover:z,selection:B,onObservation:j,chartId:F,loading:R,emptyContent:Y,emphasis:H,legendPosition:X}=n,G=c.showAxes,V=c.enableHover,q=null!=h?h:c.marginDefaults,U=null!=d?d:[c.width,c.height],K=null!=L?L:C,Z=e(null),{customHoverBehavior:Q}=jo({selection:B,linkedHover:z,unwrapData:!0,onObservation:j,chartType:"RealtimeWaterfallChart",chartId:F}),J=s(t=>{N&&N(t),Q(t)},[N,Q]);u(r,()=>({push:t=>{var e;return null===(e=Z.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=Z.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=Z.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,r;return null!==(r=null===(n=Z.current)||void 0===n?void 0:n.update(t,e))&&void 0!==r?r:[]},clear:()=>{var t;return null===(t=Z.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=Z.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const tt=Vo(R,U[0],U[1]),et=tt?null:Go(v,U[0],U[1],Y),nt={};return null!=E&&(nt.positiveColor=E),null!=A&&(nt.negativeColor=A),null!=M&&(nt.connectorStroke=M),null!=S&&(nt.connectorWidth=S),null!=P&&(nt.gap=P),null!=_&&(nt.stroke=_),null!=D&&(nt.strokeWidth=D),tt||et||t.createElement(qn,{ref:Z,chartType:"waterfall",runtimeMode:"streaming",size:U,margin:q,className:H?`${f||""} semiotic-emphasis-${H}`.trim():f,arrowOfTime:y,windowMode:g,windowSize:p,data:v,timeAccessor:m,valueAccessor:x,xExtent:b,yExtent:k,extentPadding:w,waterfallStyle:nt,showAxes:G,background:T,hoverAnnotation:V,tooltipContent:K,customHoverBehavior:J,annotations:$,svgAnnotationRules:O,tickFormatTime:I,tickFormatValue:W,legendPosition:X,pointIdAccessor:n.pointIdAccessor})});Qo.displayName="RealtimeWaterfallChart";const Jo=c(function(n,r){var o,i,l,a;const c=Ro(n.mode,{width:null!==(i=null===(o=n.size)||void 0===o?void 0:o[0])&&void 0!==i?i:n.width,height:null!==(a=null===(l=n.size)||void 0===l?void 0:l[1])&&void 0!==a?a:n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0}),{size:d,margin:h,className:f,arrowOfTime:y="right",windowMode:g="sliding",windowSize:p=200,data:v,timeAccessor:m,valueAccessor:x,categoryAccessor:b,timeExtent:k,valueExtent:w,extentPadding:E,heatmapXBins:A=20,heatmapYBins:M=20,aggregation:S="count",background:P,tooltipContent:_,tooltip:D,onHover:T,annotations:L,svgAnnotationRules:C,tickFormatTime:N,tickFormatValue:$,decay:O,pulse:I,staleness:W,linkedHover:z,selection:B,onObservation:j,chartId:F,loading:R,emptyContent:Y,emphasis:H,legendPosition:X}=n,G=c.showAxes,V=c.enableHover,q=null!=h?h:c.marginDefaults,U=null!=d?d:[c.width,c.height],K=null!=_?_:D,Z=e(null),{customHoverBehavior:Q}=jo({selection:B,linkedHover:z,unwrapData:!0,onObservation:j,chartType:"RealtimeHeatmap",chartId:F}),J=s(t=>{T&&T(t),Q(t)},[T,Q]);u(r,()=>({push:t=>{var e;return null===(e=Z.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=Z.current)||void 0===e?void 0:e.pushMany(t)},remove:t=>{var e,n;return null!==(n=null===(e=Z.current)||void 0===e?void 0:e.remove(t))&&void 0!==n?n:[]},update:(t,e)=>{var n,r;return null!==(r=null===(n=Z.current)||void 0===n?void 0:n.update(t,e))&&void 0!==r?r:[]},clear:()=>{var t;return null===(t=Z.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=Z.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const tt=Vo(R,U[0],U[1]),et=tt?null:Go(v,U[0],U[1],Y);return tt||et||t.createElement(qn,{ref:Z,chartType:"heatmap",runtimeMode:"streaming",size:U,margin:q,className:H?`${f||""} semiotic-emphasis-${H}`.trim():f,arrowOfTime:y,windowMode:g,windowSize:p,data:v,timeAccessor:m,valueAccessor:x,categoryAccessor:b,xExtent:k,yExtent:w,extentPadding:E,heatmapXBins:A,heatmapYBins:M,heatmapAggregation:S,showAxes:G,background:P,hoverAnnotation:V,tooltipContent:K,customHoverBehavior:J,annotations:L,svgAnnotationRules:C,tickFormatTime:N,tickFormatValue:$,decay:O,pulse:I,staleness:W,legendPosition:X,pointIdAccessor:n.pointIdAccessor})});Jo.displayName="RealtimeHeatmap";export{gt as IncrementalExtent,Jo as RealtimeHeatmap,Ko as RealtimeHistogram,qo as RealtimeLineChart,Zo as RealtimeSwarmChart,Qo as RealtimeWaterfallChart,yt as RingBuffer,Co as StreamNetworkFrame,qn as StreamXYFrame};