semiotic 3.1.2 → 3.2.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.
- package/CLAUDE.md +134 -216
- package/LICENSE +197 -10
- package/README.md +1 -0
- package/ai/dist/componentRegistry.js +6 -0
- package/ai/dist/mcp-server.js +115 -5
- package/ai/examples.md +93 -0
- package/ai/schema.json +3916 -878
- package/ai/system-prompt.md +27 -0
- package/dist/components/ThemeProvider.d.ts +5 -3
- package/dist/components/charts/geo/ChoroplethMap.d.ts +1 -1
- package/dist/components/charts/index.d.ts +8 -1
- package/dist/components/charts/ordinal/BarChart.d.ts +1 -0
- package/dist/components/charts/ordinal/BoxPlot.d.ts +1 -0
- package/dist/components/charts/ordinal/DonutChart.d.ts +1 -0
- package/dist/components/charts/ordinal/DotPlot.d.ts +1 -0
- package/dist/components/charts/ordinal/FunnelChart.d.ts +55 -0
- package/dist/components/charts/ordinal/GroupedBarChart.d.ts +1 -0
- package/dist/components/charts/ordinal/Histogram.d.ts +1 -0
- package/dist/components/charts/ordinal/PieChart.d.ts +1 -0
- package/dist/components/charts/ordinal/RidgelinePlot.d.ts +1 -0
- package/dist/components/charts/ordinal/StackedBarChart.d.ts +1 -0
- package/dist/components/charts/ordinal/SwarmPlot.d.ts +1 -0
- package/dist/components/charts/ordinal/ViolinPlot.d.ts +1 -0
- package/dist/components/charts/shared/colorManipulation.d.ts +15 -0
- package/dist/components/charts/shared/formatUtils.d.ts +28 -0
- package/dist/components/charts/shared/hatchPattern.d.ts +35 -0
- package/dist/components/charts/shared/hooks.d.ts +16 -1
- package/dist/components/charts/shared/legendUtils.d.ts +2 -1
- package/dist/components/charts/shared/selectionUtils.d.ts +11 -0
- package/dist/components/charts/shared/statisticalOverlays.d.ts +49 -5
- package/dist/components/charts/shared/types.d.ts +4 -1
- package/dist/components/charts/xy/Heatmap.d.ts +1 -1
- package/dist/components/charts/xy/MultiAxisLineChart.d.ts +71 -0
- package/dist/components/realtime/types.d.ts +2 -0
- package/dist/components/semiotic-ai.d.ts +3 -0
- package/dist/components/semiotic-ordinal.d.ts +3 -0
- package/dist/components/semiotic-themes.d.ts +64 -0
- package/dist/components/semiotic-xy.d.ts +1 -0
- package/dist/components/semiotic.d.ts +11 -5
- package/dist/components/store/ThemeStore.d.ts +22 -2
- package/dist/components/stream/OrdinalSVGOverlay.d.ts +1 -0
- package/dist/components/stream/PipelineStore.d.ts +2 -0
- package/dist/components/stream/SVGOverlay.d.ts +5 -3
- package/dist/components/stream/accessorUtils.d.ts +14 -0
- package/dist/components/stream/networkTypes.d.ts +2 -0
- package/dist/components/stream/ordinalSceneBuilders/barFunnelScene.d.ts +27 -0
- package/dist/components/stream/ordinalSceneBuilders/funnelScene.d.ts +26 -0
- package/dist/components/stream/ordinalTypes.d.ts +16 -2
- package/dist/components/stream/renderers/barFunnelCanvasRenderer.d.ts +12 -0
- package/dist/components/stream/renderers/trapezoidCanvasRenderer.d.ts +15 -0
- package/dist/components/stream/sceneUtils.d.ts +10 -0
- package/dist/components/stream/types.d.ts +10 -3
- package/dist/geo.min.js +1 -1
- package/dist/geo.module.min.js +1 -1
- package/dist/network.min.js +1 -1
- package/dist/network.module.min.js +1 -1
- package/dist/ordinal.min.js +1 -1
- package/dist/ordinal.module.min.js +1 -1
- package/dist/realtime.min.js +1 -1
- package/dist/realtime.module.min.js +1 -1
- package/dist/semiotic-ai-statisticalOverlays-C2PPlmXv.js +1 -0
- package/dist/semiotic-ai.d.ts +3 -0
- package/dist/semiotic-ai.min.js +1 -1
- package/dist/semiotic-ai.module.min.js +1 -1
- package/dist/semiotic-ordinal.d.ts +3 -0
- package/dist/semiotic-statisticalOverlays-D8LhSbQt.js +1 -0
- package/dist/semiotic-themes.d.ts +64 -0
- package/dist/semiotic-themes.min.js +1 -0
- package/dist/semiotic-themes.module.min.js +1 -0
- package/dist/semiotic-xy.d.ts +1 -0
- package/dist/semiotic.d.ts +11 -5
- package/dist/semiotic.min.js +1 -1
- package/dist/semiotic.module.min.js +1 -1
- package/dist/server.min.js +1 -1
- package/dist/server.module.min.js +1 -1
- package/dist/xy-statisticalOverlays-C2PPlmXv.js +1 -0
- package/dist/xy.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +24 -5
- package/dist/semiotic-ai-statisticalOverlays-C1f7TYyD.js +0 -1
- package/dist/semiotic-statisticalOverlays-C1f7TYyD.js +0 -1
- package/dist/xy-statisticalOverlays-C1f7TYyD.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as t from"react";import{useRef as e,useState as n,useEffect as i,useMemo as r,createContext as o,useContext as a,useCallback as l,useSyncExternalStore as s,forwardRef as c,useImperativeHandle as u,useId as h}from"react";import{brushX as d,brushY as f,brush as y}from"d3-brush";import{select as g}from"d3-selection";import{scaleLinear as p,scaleSequential as v,scaleLog as m}from"d3-scale";import{schemeCategory10 as x,interpolateViridis as b,interpolateGreens as k,interpolateReds as w,interpolateBlues as E}from"d3-scale-chromatic";import{quadtree as A}from"d3-quadtree";import{bin as M,min as P,groups as S,max as _,sum as L,mean as D,group as T}from"d3-array";import{packEnclose as W,hierarchy as $,partition as C,pack as O,treemap as N,treemapBinary as z,cluster as I,tree as B}from"d3-hierarchy";import{area as j,curveCatmullRom as R,curveCardinal as F,curveBasis as Y,curveStepBefore as H,curveStepAfter as X,curveStep as G,curveMonotoneY as V,curveMonotoneX as q,curveLinear as K,arc as Z,line as U,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 it,forceManyBody as rt,forceCenter as ot,forceX as at,forceY as lt}from"d3-force";import{ribbon as st,chord as ct}from"d3-chord";class ut{constructor(t,e){var n,i;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!==(i=null==e?void 0:e.chunkSize)&&void 0!==i?i: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 i=Math.min(e+this.chunkSize,t.length);this.callback({inserts:t.slice(e,i),bounded:!1}),e=i,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 ht{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 dt{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 ft(t,e,n,i,r){const o=new Map;for(const a of t){const t=e(a),l=n(a);if(null==t||null==l||Number.isNaN(t)||Number.isNaN(l))continue;const s=Math.floor(t/i)*i;let c=o.get(s);if(c||(c={start:s,end:s+i,total:0,categories:new Map},o.set(s,c)),c.total+=l,r){const t=r(a);c.categories.set(t,(c.categories.get(t)||0)+l)}}return o}function yt(t,e,n,i,r,o){const a=[];for(const r of t){const t=n(r),o=i(r);null==t||null==o||Number.isNaN(t)||Number.isNaN(o)||a.push({px:e.x(t),py:e.y(o),rawY:o,d:r})}a.sort((t,e)=>t.px-e.px);const l=Array(a.length),s=Array(a.length),c=Array(a.length);for(let t=0;a.length>t;t++){const e=a[t];l[t]=[e.px,e.py],s[t]=e.rawY,c[t]=e.d}return{type:"line",path:l,rawValues:s,style:r,datum:c,group:o}}function gt(t,e,n,i,r,o,a,l){const s=[];for(const o of t){const t=n(o),a=i(o);if(null==t||null==a||Number.isNaN(t)||Number.isNaN(a))continue;const c=e.x(t),u=l?l(o):r;s.push({px:c,topY:e.y(a),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:o,datum:t,group:a}}function pt(t,e,n,i,r,o,a){const l=n(t),s=i(t);if(null==l||null==s||Number.isNaN(l)||Number.isNaN(s))return null;const c={type:"point",x:e.x(l),y:e.y(s),r:r,style:o,datum:t};return void 0!==a&&(c.pointId=a),c}function vt(t,e,n,i,r,o,a){return{type:"rect",x:t,y:e,w:n,h:i,style:r,datum:o,group:a}}function mt(t,e,n,i,r,o,a){const l={type:"heatcell",x:t,y:e,w:n,h:i,fill:r,datum:o};return(null==a?void 0:a.showValues)&&(l.showValues=!0,l.value=a.value,a.valueFormat&&(l.valueFormat=a.valueFormat)),l}function xt(t,e){if("function"==typeof t)return e=>+t(e);const n=t||e;return t=>+t[n]}function bt(t,e){if("function"==typeof t)return t;const n=t||e;return t=>t[n]}function kt(t,e){return"function"==typeof t?t:t?e=>e[t]+"":void 0}const wt=x,Et=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];function At(t,e="ease-out-cubic"){return"linear"===e?t:1-Math.pow(1-t,3)}function Mt(t,e){return Math.min((t-e.startTime)/e.duration,1)}function Pt(t,e,n){return t+(e-t)*n}class St{constructor(t){this.xExtent=new dt,this.yExtent=new dt,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._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._quadtree=null,this.config=t,this.buffer=new ht(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=xt(t.timeAccessor||t.xAccessor,"time"),this.getY=xt(t.valueAccessor||t.yAccessor,"value")):(this.getX=xt(t.xAccessor,"x"),this.getY=xt(t.yAccessor,"y")),this.getGroup=kt(t.groupAccessor),this.getCategory=kt(t.categoryAccessor),this.getSize=t.sizeAccessor?xt(t.sizeAccessor,"size"):void 0,this.getColor=kt(t.colorAccessor),this.getBounds=t.boundsAccessor?xt(t.boundsAccessor,"bounds"):void 0,this.getY0=t.y0Accessor?xt(t.y0Accessor,"y0"):void 0,this.getPointId=kt(t.pointIdAccessor),"candlestick"===t.chartType&&(this.getOpen=xt(t.openAccessor,"open"),this.getHigh=xt(t.highAccessor,"high"),this.getLow=xt(t.lowAccessor,"low"),this.getClose=xt(t.closeAccessor,"close")),t.pulse&&(this.timestampBuffer=new ht(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){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear();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,i,r,o,a;const{config:l,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"===l.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=l.xExtent?[null!==(e=l.xExtent[0])&&void 0!==e?e:u[0],null!==(n=l.xExtent[1])&&void 0!==n?n:u[1]]:u,f=l.yExtent?[null!==(i=l.yExtent[0])&&void 0!==i?i:h[0],null!==(r=l.yExtent[1])&&void 0!==r?r:h[1]]:h;const y=l.yExtent&&null!=l.yExtent[0]&&null!=l.yExtent[1];if("stackedarea"===l.chartType&&!y&&s.size>0)if(l.normalize)f=[0,1+l.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),i=this.getY(e);null==t||null==i||Number.isNaN(t)||Number.isNaN(i)||n.set(t,(n.get(t)||0)+i)}let i=0;for(const t of n.values())t>i&&(i=t);f=[0,i+(i>0?i*l.extentPadding:1)],this._stackExtentCache={key:t,yDomain:f}}}else if("bar"===l.chartType&&l.binSize&&!y&&s.size>0){const[,t]=function(t,e,n,i,r){const o=ft(t,e,n,i,r);if(0===o.size)return[0,0];let a=0;for(const t of o.values())t.total>a&&(a=t.total);return[0,a]}(s,this.getX,this.getY,l.binSize,this.getCategory);f=[0,t+t*l.extentPadding]}else if("waterfall"===l.chartType&&!y&&s.size>0){const[t,e]=function(t,e){let n=0,i=0,r=0;for(const o of t){const t=e(o);null==t||Number.isNaN(t)||(r+=t,n>r&&(n=r),r>i&&(i=r))}return[n,i]}(s,this.getY),n=e-t,i=n>0?n*l.extentPadding:1;f=[Math.min(0,t-Math.abs(i)),Math.max(0,e+Math.abs(i))]}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*l.extentPadding:1,n=null===(o=l.yExtent)||void 0===o?void 0:o[0],i=null===(a=l.yExtent)||void 0===a?void 0:a[1];f=[null!=n?f[0]:f[0]-e,null!=i?f[1]:f[1]+e],"log"===l.yScaleType&&0>=f[0]&&h[0]>0&&(f[0]=null!=n?f[0]:h[0]/(1+l.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"===l.runtimeMode)if("x"==("up"===(g=l.arrowOfTime)||"down"===g?"y":"x")){const e="right"===l.arrowOfTime?[0,t.width]:[t.width,0];this.scales={x:p().domain(d).range(e),y:p().domain(f).range([t.height,0])}}else{const e="down"===l.arrowOfTime?[0,t.height]:[t.height,0];this.scales={x:p().domain(f).range([0,t.width]),y:p().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 m().domain(t).range(n).clamp(!0)}return p().domain(e).range(n)};this.scales={x:e(l.xScaleType,d,[0,t.width]),y:e(l.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>St.QUADTREE_THRESHOLD?A().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 i of t.path)i[0]*=e,i[1]*=n;break;case"area":for(const i of t.topPath)i[0]*=e,i[1]*=n;for(const i of t.bottomPath)i[0]*=e,i[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 i=this.scales.x.domain(),r=this.scales.y.domain(),o=this.scales.x.range(),a=this.scales.y.range(),l=(t,e,n)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return m().domain(t).range(n).clamp(!0)}return p().domain(e).range(n)};this.scales={x:l(this.config.xScaleType,i,[o[0]*e,o[1]*e]),y:l(this.config.yScaleType,r,[a[0]*n,a[1]*n])},this.lastLayout={width:t.width,height:t.height},this.rebuildQuadtree(),this.version++}buildSceneNodes(t,e){const{config:n,scales:i}=this;if(!i||0===e.length)return[];switch(n.chartType){case"line":return this.buildLineScene(e);case"area":return this.buildAreaScene(e);case"stackedarea":return this.buildStackedAreaScene(e);case"scatter":case"bubble":return this.buildPointScene(e);case"heatmap":return this.buildHeatmapScene(e,t);case"bar":return this.buildBarScene(e);case"swarm":return this.buildSwarmScene(e);case"waterfall":return this.buildWaterfallScene(e,t);case"candlestick":return this.buildCandlestickScene(e,t);default:return[]}}buildLineScene(t){var e;const n=this.groupData(t),i=[],r=null===(e=this.config.annotations)||void 0===e?void 0:e.filter(t=>"threshold"===t.type&&t.color).map(t=>({value:t.value,color:t.color,thresholdType:t.thresholdType||"greater"}));if(this.getBounds)for(const t of n){const e=this.buildBoundsForGroup(t.data,t.key);e&&i.push(e)}for(const t of n){const e=this.resolveLineStyle(t.key,t.data[0]),n=yt(t.data,this.scales,this.getX,this.getY,e,t.key);r&&r.length>0&&(n.colorThresholds=r),this.config.curve&&"linear"!==this.config.curve&&(n.curve=this.config.curve),i.push(n)}return i}buildAreaScene(t){const e=this.groupData(t),n=[],i=this.scales.y.domain()[0];for(const t of e){const e=this.resolveAreaStyle(t.key,t.data[0]),r=gt(t.data,this.scales,this.getX,this.getY,i,e,t.key,this.getY0);this.config.gradientFill&&(r.fillGradient=this.config.gradientFill),this.config.curve&&"linear"!==this.config.curve&&(r.curve=this.config.curve),n.push(r)}return n}buildStackedAreaScene(t){const e=this.groupData(t);return e.sort((t,e)=>e.key>t.key?-1:t.key>e.key?1:0),function(t,e,n,i,r,o,a){var l;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 r of e.data){const e=n(r),o=i(r);null==e||null==o||Number.isNaN(e)||Number.isNaN(o)||t.set(e,(t.get(e)||0)+o)}u.set(e.key,t)}let h;if(o){h=new Map;for(const e of c){let n=0;for(const i of t)n+=(null===(l=u.get(i.key))||void 0===l?void 0:l.get(e))||0;h.set(e,n||1)}}const d=[],f=new Map;for(const t of c)f.set(t,0);for(const n of t){const t=u.get(n.key),i=[],l=[];for(const n of c){let r=t.get(n)||0;const a=f.get(n);o&&(r/=h.get(n));const s=e.x(n);l.push([s,e.y(a)]),i.push([s,e.y(a+r)]),f.set(n,a+r)}const s={type:"area",topPath:i,bottomPath:l,style:r(n.key,n.data[0]),datum:n.data,group:n.key};a&&(s.curve=a),d.push(s)}return d}(e,this.scales,this.getX,this.getY,(t,e)=>this.resolveAreaStyle(t,e),this.config.normalize,this.config.curve&&"linear"!==this.config.curve?this.config.curve:void 0)}buildPointScene(t){const e=[],n="bubble"===this.config.chartType?10:5,i=this.config.sizeRange||[3,15];let r=null;if(this.getSize&&!this.config.pointStyle){const e=t.map(t=>this.getSize(t)).filter(t=>null!=t&&!Number.isNaN(t));if(e.length>0){let t=1/0,n=-1/0;for(const i of e)t>i&&(t=i),i>n&&(n=i);r=e=>t===n?(i[0]+i[1])/2:i[0]+(e-t)/(n-t)*(i[1]-i[0])}}const o=this.getColor?this.resolveColorMap(t):null;for(const i of t){let t=this.config.pointStyle?this.config.pointStyle(i):{fill:"#4e79a7",opacity:.8},a=t.r||n;if(r&&this.getSize){const t=this.getSize(i);null==t||Number.isNaN(t)||(a=r(t))}if(o&&this.getColor&&!t.fill){const e=this.getColor(i);e&&o.has(e)&&(t=Object.assign(Object.assign({},t),{fill:o.get(e)}))}const l=this.getPointId?this.getPointId(i)+"":void 0,s=pt(i,this.scales,this.getX,this.getY,a,t,l);s&&e.push(s)}return e}buildHeatmapScene(t,e){const n=[];if(this.config.heatmapAggregation)return this.buildStreamingHeatmapScene(t,e);const i=xt(this.config.valueAccessor,"value"),r=bt(this.config.xAccessor,"x"),o=bt(this.config.yAccessor,"y"),a=new Set,l=new Set;for(const e of t)a.add(r(e)),l.add(o(e));const s=Array.from(a),c=Array.from(l),u=s.every(t=>"number"==typeof t&&!isNaN(t)),h=c.every(t=>"number"==typeof t&&!isNaN(t)),d=u?s.sort((t,e)=>t-e):s,f=h?c.sort((t,e)=>t-e):c;if(0===d.length||0===f.length)return n;const y=e.width/d.length,g=e.height/f.length,p=new Map;for(const e of t){const t=`${r(e)}\0${o(e)}`;p.set(t,{val:i(e),datum:e})}let m=1/0,x=-1/0;for(const{val:t}of p.values())m>t&&(m=t),t>x&&(x=t);const A=v({blues:E,reds:w,greens:k,viridis:b}["string"==typeof this.config.colorScheme?this.config.colorScheme:"blues"]||E).domain([m,x]);for(let t=0;d.length>t;t++)for(let e=0;f.length>e;e++){const i=p.get(`${d[t]}\0${f[e]}`);if(!i)continue;const r=A(i.val);n.push(mt(t*y,(f.length-1-e)*g,y,g,r,i.datum,this.config.showValues?{value:i.val,showValues:!0,valueFormat:this.config.heatmapValueFormat}:void 0))}return n}buildStreamingHeatmapScene(t,e){var n,i,r;const o=[],a=null!==(n=this.config.heatmapXBins)&&void 0!==n?n:20,l=null!==(i=this.config.heatmapYBins)&&void 0!==i?i:20,s=null!==(r=this.config.heatmapAggregation)&&void 0!==r?r:"count",c=xt(this.config.valueAccessor,"value");if(!this.scales||0===t.length)return o;const[u,h]=this.scales.x.domain(),[d,f]=this.scales.y.domain(),y=(h-u||1)/a,g=(f-d||1)/l,p=new Map;for(const e of t){const t=this.getX(e),n=this.getY(e),i=Math.min(Math.floor((t-u)/y),a-1),r=Math.min(Math.floor((n-d)/g),l-1);if(0>i||0>r)continue;const o=`${i}_${r}`;let s=p.get(o);s||(s={sum:0,count:0,data:[]},p.set(o,s)),s.count++,s.sum+=c(e),s.data.push(e)}let v=1/0,m=-1/0;const x=new Map;for(const[t,e]of p){let n;switch(s){case"sum":n=e.sum;break;case"mean":n=e.count>0?e.sum/e.count:0;break;default:n=e.count}x.set(t,n),v>n&&(v=n),n>m&&(m=n)}const b=m-v||1,k=e.width/a,w=e.height/l;for(const[t,e]of x){const[n,i]=t.split("_"),r=+n,a=+i,s=(e-v)/b,c=`rgb(${Math.round(220-180*s)},${Math.round(220-100*s)},${Math.round(255-50*s)})`,u=p.get(t);o.push(mt(r*k,(l-1-a)*w,k,w,c,{xi:r,yi:a,value:e,count:u.count,sum:u.sum,data:u.data},this.config.showValues?{value:e,showValues:!0,valueFormat:this.config.heatmapValueFormat}:void 0))}return o}buildBarScene(t){var e;if(!this.config.binSize)return[];const n=ft(t,this.getX,this.getY,this.config.binSize,this.getCategory);if(0===n.size)return[];let i=null;if(this.getCategory){const t=new Set;for(const e of n.values())for(const n of e.categories.keys())t.add(n);const e=this.config.barColors?Object.keys(this.config.barColors):[],r=new Set(e),o=Array.from(t).filter(t=>!r.has(t)).sort(),a=e.filter(e=>t.has(e)),l=a.join("\0")+""+o.join("\0");this._barCategoryCache&&this._barCategoryCache.key===l?i=this._barCategoryCache.order:(i=[...a,...o],this._barCategoryCache={key:l,order:i})}const r=[],o=this.scales,[a,l]=o.x.domain();for(const t of n.values()){const n=Math.max(t.start,a),s=Math.min(t.end,l);if(n>=s)continue;const c=o.x(n),u=o.x(s),h=Math.abs(u-c),d=h>2?1:0,f=Math.min(c,u)+d/2,y=Math.max(h-d,1);if(y>0)if(i&&t.categories.size>0){let n=0;for(const a of i){const i=t.categories.get(a)||0;if(0===i)continue;const l=o.y(n),s=o.y(n+i);r.push(vt(f,Math.min(l,s),y,Math.abs(l-s),{fill:(null===(e=this.config.barColors)||void 0===e?void 0:e[a])||"#4e79a7"},{binStart:t.start,binEnd:t.end,total:t.total,category:a,categoryValue:i},a)),n+=i}}else{const e=o.y(0),n=o.y(t.total);r.push(vt(f,Math.min(e,n),y,Math.abs(e-n),{fill:"#007bff"},{binStart:t.start,binEnd:t.end,total:t.total}))}}return r}buildSwarmScene(t){var e,n,i,r;const o=[],a=this.config.swarmStyle||{},l=null!==(e=a.radius)&&void 0!==e?e:3,s=null!==(n=a.fill)&&void 0!==n?n:"#007bff",c=null!==(i=a.opacity)&&void 0!==i?i:.7,u=a.stroke,h=a.strokeWidth;for(const e of t){const t=this.getX(e),n=this.getY(e);if(null==n||Number.isNaN(n))continue;const i=this.scales.x(t),a=this.scales.y(n);let d=s;if(this.getCategory){const t=this.getCategory(e);d=(null===(r=this.config.barColors)||void 0===r?void 0:r[t])||d}const f={type:"point",x:i,y:a,r:l,style:{fill:d,opacity:c,stroke:u,strokeWidth:h},datum:e};this.getPointId&&(f.pointId=this.getPointId(e)+""),o.push(f)}return o}buildWaterfallScene(t,e){var n,i,r;const o=[],a=this.scales,l=this.config.waterfallStyle,s=t.filter(t=>{const e=this.getY(t);return null!=e&&!Number.isNaN(e)});if(0===s.length)return o;const c=null!==(n=null==l?void 0:l.positiveColor)&&void 0!==n?n:"#28a745",u=null!==(i=null==l?void 0:l.negativeColor)&&void 0!==i?i:"#dc3545",h=null!==(r=null==l?void 0:l.gap)&&void 0!==r?r:1,d=null==l?void 0:l.stroke,f=null==l?void 0:l.strokeWidth;let y=0;for(let t=0;s.length>t;t++){const n=s[t],i=this.getX(n),r=this.getY(n),g=y+r;let p;p=s.length-1>t?this.getX(s[t+1])-i:t>0?i-this.getX(s[t-1]):0;const v=a.x(i),m=0!==p?a.x(i+p):v+e.width/10,x=Math.min(v,m)+h/2,b=Math.max(v,m)-h/2-x;if(0>=b){y=g;continue}const k=a.y(y),w=a.y(g);o.push(vt(x,Math.min(k,w),b,Math.abs(k-w),{fill:0>r?u:c,stroke:d,strokeWidth:f},Object.assign(Object.assign({},n),{baseline:y,cumEnd:g,delta:r,_connectorStroke:null==l?void 0:l.connectorStroke,_connectorWidth:null==l?void 0:l.connectorWidth}))),y=g}return o}buildCandlestickScene(t,e){if(!(this.getOpen&&this.getHigh&&this.getLow&&this.getClose&&this.scales))return[];const n=[],i=this.config.candlestickStyle||{},r=i.upColor||"#28a745",o=i.downColor||"#dc3545",a=i.wickColor||"#333",l=i.wickWidth||1,s=t.map(t=>this.getX(t)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let c=i.bodyWidth||6;if(!i.bodyWidth&&s.length>1){let t=1/0;for(let e=1;s.length>e;e++){const n=Math.abs(this.scales.x(s[e])-this.scales.x(s[e-1]));n>0&&t>n&&(t=n)}t!==1/0&&(c=Math.max(2,Math.min(.6*t,20)))}for(const e of t){const t=this.getX(e);if(null==t||Number.isNaN(t))continue;const i=this.getOpen(e),s=this.getHigh(e),u=this.getLow(e),h=this.getClose(e);if([i,s,u,h].some(t=>null==t||Number.isNaN(t)))continue;const d=h>=i;n.push({type:"candlestick",x:this.scales.x(t),openY:this.scales.y(i),closeY:this.scales.y(h),highY:this.scales.y(s),lowY:this.scales.y(u),bodyWidth:c,upColor:r,downColor:o,wickColor:a,wickWidth:l,isUp:d,datum:e})}return n}buildBoundsForGroup(t,e){if(!this.getBounds||!this.scales)return null;const n=[],i=[];for(const e of t){const t=this.getX(e),r=this.getY(e);if(null==t||null==r||Number.isNaN(t)||Number.isNaN(r))continue;const o=this.getBounds(e),a=this.scales.x(t);if(o&&0!==o)n.push([a,this.scales.y(r+o)]),i.push([a,this.scales.y(r-o)]);else{const t=this.scales.y(r);n.push([a,t]),i.push([a,t])}}return 2>n.length?null:{type:"area",topPath:n,bottomPath:i,style:this.resolveBoundsStyle(e,t[0]),datum:t,group:e,interactive:!1}}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){var n,i,r;const o=this.config.decay;if(!o||1>=e)return 1;const a=null!==(n=o.minOpacity)&&void 0!==n?n:.1,l=e-1-t;switch(o.type){case"linear":return a+(1-l/(e-1))*(1-a);case"exponential":{const t=null!==(i=o.halfLife)&&void 0!==i?i:e/2;return a+Math.pow(.5,l/t)*(1-a)}case"step":return(null!==(r=o.stepThreshold)&&void 0!==r?r:.5*e)>l?1:a;default:return 1}}applyDecay(t,e){var n,i;if(!this.config.decay)return;const r=e.length;if(1>=r)return;const o=new Map;for(let t=0;e.length>t;t++)o.set(e[t],t);for(const e of t){if("line"===e.type){const t=Array.isArray(e.datum)?e.datum:[];if(2>t.length)continue;const n=Array(t.length);let i=!1;for(let e=0;t.length>e;e++){const a=o.get(t[e]);null!=a?(n[e]=this.computeDecayOpacity(a,r),1>n[e]&&(i=!0)):n[e]=1}i&&(e._decayOpacities=n);continue}if("area"===e.type){const t=Array.isArray(e.datum)?e.datum:[],n=e.topPath?e.topPath.length:t.length;if(2>n)continue;if(t.length===n){const i=Array(n);let a=!1;for(let e=0;t.length>e;e++){const n=o.get(t[e]);null!=n?(i[e]=this.computeDecayOpacity(n,r),1>i[e]&&(a=!0)):i[e]=1}a&&(e._decayOpacities=i)}else{let i=1;for(const e of t){const t=o.get(e);if(null!=t){const e=this.computeDecayOpacity(t,r);i>e&&(i=e)}}if(1>i){const t=Array(n);t.fill(i),e._decayOpacities=t}}continue}const t=o.get(e.datum);if(null==t)continue;const a=this.computeDecayOpacity(t,r);if("heatcell"===e.type)e.style={opacity:a};else if("candlestick"===e.type)e._decayOpacity=a;else{const t=null!==(i=null===(n=e.style)||void 0===n?void 0:n.opacity)&&void 0!==i?i:1;e.style=Object.assign(Object.assign({},e.style),{opacity:t*a})}}}computePulseIntensity(t,e){var n;const i=this.config.pulse;if(!i)return 0;const r=null!==(n=i.duration)&&void 0!==n?n:500,o=e-t;return r>o?1-o/r:0}applyPulse(t,e){var n,i;if(!this.config.pulse||!this.timestampBuffer)return;const r="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(n=this.config.pulse.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",a=null!==(i=this.config.pulse.glowRadius)&&void 0!==i?i:4,l=new Map;for(let t=0;e.length>t;t++)l.set(e[t],t);for(const e of t){if("line"===e.type)continue;if("area"===e.type){const t=Array.isArray(e.datum)?e.datum:[e.datum];let n=0;for(const e of t){const t=l.get(e);if(null==t)continue;const i=this.timestampBuffer.get(t);if(null==i)continue;const o=this.computePulseIntensity(i,r);o>n&&(n=o)}n>0&&(e._pulseIntensity=n,e._pulseColor=o);continue}const t=l.get(e.datum);if(null==t)continue;const n=this.timestampBuffer.get(t);if(null==n)continue;const i=this.computePulseIntensity(n,r);i>0&&(e._pulseIntensity=i,e._pulseColor=o,e._pulseGlowRadius=a)}}get hasActivePulses(){var t;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const e="undefined"!=typeof performance?performance.now():Date.now(),n=null!==(t=this.config.pulse.duration)&&void 0!==t?t:500,i=this.timestampBuffer.peek();return null!=i&&n>e-i}snapshotPositions(){var t,e,n;this.prevPositionMap.clear(),this.prevPathMap.clear();for(let i=0;this.scene.length>i;i++){const r=this.scene[i],o=this.getNodeIdentity(r,i);o&&("point"===r.type?this.prevPositionMap.set(o,{x:r.x,y:r.y,r:r.r,opacity:r.style.opacity}):"rect"===r.type?this.prevPositionMap.set(o,{x:r.x,y:r.y,w:r.w,h:r.h,opacity:r.style.opacity}):"heatcell"===r.type?this.prevPositionMap.set(o,{x:r.x,y:r.y,w:r.w,h:r.h,opacity:null===(t=r.style)||void 0===t?void 0:t.opacity}):"candlestick"===r.type?this.prevPositionMap.set(o,{x:r.x,y:r.openY}):"line"===r.type?this.prevPathMap.set(o,{path:r.path.map(t=>[t[0],t[1]]),opacity:null===(e=r.style)||void 0===e?void 0:e.opacity}):"area"===r.type&&this.prevPathMap.set(o,{topPath:r.topPath.map(t=>[t[0],t[1]]),bottomPath:r.bottomPath.map(t=>[t[0],t[1]]),opacity:null===(n=r.style)||void 0===n?void 0:n.opacity}))}}getNodeIdentity(t,e){var n,i,r,o;switch(t.type){case"point":if(t.pointId)return"p:"+t.pointId;if("streaming"===this.config.runtimeMode&&t.datum){if(this.getCategory)return`p:${this.getCategory(t.datum)}:${this.getY(t.datum)}`;const e=this.getX(t.datum),n=this.getY(t.datum);if(null!=e&&null!=n)return`p:${e}:${n}`}return"p:"+e;case"rect":return`r:${t.group||""}:${null!==(o=null!==(i=null===(n=t.datum)||void 0===n?void 0:n.binStart)&&void 0!==i?i:null===(r=t.datum)||void 0===r?void 0:r.category)&&void 0!==o?o:e}`;case"heatcell":return`h:${t.x}_${t.y}`;case"candlestick":return null==t.datum?"c:"+e:"c:"+this.getX(t.datum);case"line":return"l:"+(t.group||"_default");case"area":return"a:"+(t.group||"_default");default:return null}}startTransition(){var t,e,n,i,r,o,a,l,s,c,u,h,d,f,y,g,p,v,m,x,b,k,w,E,A,M;if(!this.config.transition||0===this.prevPositionMap.size&&0===this.prevPathMap.size)return;const P=null!==(t=this.config.transition.duration)&&void 0!==t?t:300;if(this.exitNodes.length>0){const t=new Set(this.exitNodes);this.scene=this.scene.filter(e=>!t.has(e)),this.exitNodes=[]}let S=!1;const _=new Set,L=new Set;for(let t=0;this.scene.length>t;t++){const p=this.scene[t],v=this.getNodeIdentity(p,t);if(!v)continue;if(p._transitionKey=v,"line"===p.type||"area"===p.type){const t=this.prevPathMap.get(v);if(t){if(L.add(v),"line"===p.type&&t.path&&t.path.length===p.path.length){p._targetPath=p.path.map(t=>[t[0],t[1]]),p._prevPath=t.path;for(let e=0;p.path.length>e;e++)p.path[e]=[t.path[e][0],t.path[e][1]];S=!0}else if("area"===p.type&&t.topPath&&t.bottomPath&&t.topPath.length===p.topPath.length&&t.bottomPath.length===p.bottomPath.length){p._targetTopPath=p.topPath.map(t=>[t[0],t[1]]),p._targetBottomPath=p.bottomPath.map(t=>[t[0],t[1]]),p._prevTopPath=t.topPath,p._prevBottomPath=t.bottomPath;for(let e=0;p.topPath.length>e;e++)p.topPath[e]=[t.topPath[e][0],t.topPath[e][1]];for(let e=0;p.bottomPath.length>e;e++)p.bottomPath[e]=[t.bottomPath[e][0],t.bottomPath[e][1]];S=!0}p._targetOpacity=null!==(e=p.style.opacity)&&void 0!==e?e:1}else p._targetOpacity=null!==(n=p.style.opacity)&&void 0!==n?n:1,p.style=Object.assign(Object.assign({},p.style),{opacity:0}),S=!0;continue}const m=this.prevPositionMap.get(v);if("point"===p.type)if(m){_.add(v);const t={x:p.x,y:p.y,r:p.r};p._targetOpacity=null!==(i=p.style.opacity)&&void 0!==i?i:1,m.x===t.x&&m.y===t.y||(p._targetX=t.x,p._targetY=t.y,p._targetR=t.r,p.x=m.x,p.y=m.y,p.r=null!==(r=m.r)&&void 0!==r?r:p.r,S=!0)}else p._targetOpacity=null!==(o=p.style.opacity)&&void 0!==o?o:1,p.style=Object.assign(Object.assign({},p.style),{opacity:0}),S=!0;else if("rect"===p.type)if(m){_.add(v);const t={x:p.x,y:p.y,w:p.w,h:p.h};p._targetOpacity=null!==(a=p.style.opacity)&&void 0!==a?a:1,m.x===t.x&&m.y===t.y&&m.w===t.w&&m.h===t.h||(p._targetX=t.x,p._targetY=t.y,p._targetW=t.w,p._targetH=t.h,p.x=m.x,p.y=m.y,p.w=null!==(l=m.w)&&void 0!==l?l:p.w,p.h=null!==(s=m.h)&&void 0!==s?s:p.h,S=!0)}else p._targetOpacity=null!==(c=p.style.opacity)&&void 0!==c?c:1,p.style=Object.assign(Object.assign({},p.style),{opacity:0}),S=!0;else if("heatcell"===p.type)if(m){_.add(v);const t={x:p.x,y:p.y,w:p.w,h:p.h};p._targetOpacity=null!==(h=null===(u=p.style)||void 0===u?void 0:u.opacity)&&void 0!==h?h:1,m.x===t.x&&m.y===t.y||(p._targetX=t.x,p._targetY=t.y,p._targetW=t.w,p._targetH=t.h,p.x=m.x,p.y=m.y,p.w=null!==(d=m.w)&&void 0!==d?d:p.w,p.h=null!==(f=m.h)&&void 0!==f?f:p.h,S=!0)}else p._targetOpacity=null!==(g=null===(y=p.style)||void 0===y?void 0:y.opacity)&&void 0!==g?g:1,p.style=Object.assign(Object.assign({},p.style||{}),{opacity:0}),S=!0}for(const[t,e]of this.prevPathMap)if(!L.has(t))if(t.startsWith("l:")&&e.path){const n={type:"line",path:e.path.map(t=>[t[0],t[1]]),group:t.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:null!==(p=e.opacity)&&void 0!==p?p:1},_targetOpacity:0,_transitionKey:t,datum:null};this.exitNodes.push(n),S=!0}else if(t.startsWith("a:")&&e.topPath&&e.bottomPath){const n={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!==(v=e.opacity)&&void 0!==v?v:1},_targetOpacity:0,_transitionKey:t,datum:null};this.exitNodes.push(n),S=!0}for(const[t,e]of this.prevPositionMap)if(!_.has(t)){if(t.startsWith("p:")){const n={type:"point",x:e.x,y:e.y,r:null!==(m=e.r)&&void 0!==m?m:3,style:{opacity:null!==(x=e.opacity)&&void 0!==x?x:1},datum:null,_targetOpacity:0,_transitionKey:t};this.exitNodes.push(n)}else if(t.startsWith("r:")){const n={type:"rect",x:e.x,y:e.y,w:null!==(b=e.w)&&void 0!==b?b:0,h:null!==(k=e.h)&&void 0!==k?k:0,style:{opacity:null!==(w=e.opacity)&&void 0!==w?w:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t};this.exitNodes.push(n)}else if(t.startsWith("h:")){const n={type:"heatcell",x:e.x,y:e.y,w:null!==(E=e.w)&&void 0!==E?E:0,h:null!==(A=e.h)&&void 0!==A?A:0,fill:"#999",datum:null,style:{opacity:null!==(M=e.opacity)&&void 0!==M?M:1},_targetOpacity:0,_transitionKey:t};this.exitNodes.push(n)}S=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),S&&(this.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:P})}advanceTransition(t){var e,n,i,r,o,a;if(!this.activeTransition)return!1;const l=Mt(t,this.activeTransition),s=At(l,"linear"===(null===(e=this.config.transition)||void 0===e?void 0:e.easing)?"linear":"ease-out-cubic");for(const t of this.scene){const e=t._transitionKey;if("point"===t.type){if(void 0!==t._targetOpacity){const i=e?this.prevPositionMap.get(e):void 0,r=i?null!==(n=i.opacity)&&void 0!==n?n:1:0;t.style.opacity=Pt(r,t._targetOpacity,s)}if(void 0===t._targetX)continue;if(!e)continue;const i=this.prevPositionMap.get(e);if(!i)continue;t.x=Pt(i.x,t._targetX,s),t.y=Pt(i.y,t._targetY,s),void 0!==t._targetR&&void 0!==i.r&&(t.r=Pt(i.r,t._targetR,s))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const n=e?this.prevPositionMap.get(e):void 0,r=n?null!==(i=n.opacity)&&void 0!==i?i:1:0;t.style.opacity=Pt(r,t._targetOpacity,s)}if(void 0===t._targetX)continue;if(!e)continue;const n=this.prevPositionMap.get(e);if(!n)continue;t.x=Pt(n.x,t._targetX,s),t.y=Pt(n.y,t._targetY,s),void 0!==n.w&&(t.w=Pt(n.w,t._targetW,s)),void 0!==n.h&&(t.h=Pt(n.h,t._targetH,s))}else if("heatcell"===t.type){if(void 0!==t._targetOpacity){const n=e?this.prevPositionMap.get(e):void 0,i=n?null!==(r=n.opacity)&&void 0!==r?r:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:Pt(i,t._targetOpacity,s)})}if(void 0===t._targetX)continue;if(!e)continue;const n=this.prevPositionMap.get(e);if(!n)continue;t.x=Pt(n.x,t._targetX,s),t.y=Pt(n.y,t._targetY,s),void 0!==n.w&&(t.w=Pt(n.w,t._targetW,s)),void 0!==n.h&&(t.h=Pt(n.h,t._targetH,s))}else if("line"===t.type){if(void 0!==t._targetOpacity){const e=void 0===t._prevPath&&t._targetOpacity>0?0:null!==(o=t.style.opacity)&&void 0!==o?o:1;t.style=Object.assign(Object.assign({},t.style),{opacity:Pt(e,t._targetOpacity,s)})}const e=t._prevPath,n=t._targetPath;if(e&&n&&e.length===t.path.length)for(let i=0;t.path.length>i;i++)t.path[i][0]=Pt(e[i][0],n[i][0],s),t.path[i][1]=Pt(e[i][1],n[i][1],s)}else if("area"===t.type){if(void 0!==t._targetOpacity){const e=void 0===t._prevTopPath&&t._targetOpacity>0?0:null!==(a=t.style.opacity)&&void 0!==a?a:1;t.style=Object.assign(Object.assign({},t.style),{opacity:Pt(e,t._targetOpacity,s)})}const e=t._prevTopPath,n=t._prevBottomPath,i=t._targetTopPath,r=t._targetBottomPath;if(e&&i&&e.length===t.topPath.length)for(let n=0;t.topPath.length>n;n++)t.topPath[n][0]=Pt(e[n][0],i[n][0],s),t.topPath[n][1]=Pt(e[n][1],i[n][1],s);if(n&&r&&n.length===t.bottomPath.length)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e][0]=Pt(n[e][0],r[e][0],s),t.bottomPath[e][1]=Pt(n[e][1],r[e][1],s)}}if(l>=1){for(const t of this.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(this.exitNodes.length>0){const t=new Set(this.exitNodes);this.scene=this.scene.filter(e=>!t.has(e)),this.exitNodes=[]}return this.activeTransition=null,!1}return!0}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(),i=n.join("\0");if(this._colorMapCache&&this._colorMapCache.key===i)return this._colorMapCache.map;const r=Array.isArray(this.config.colorScheme)?this.config.colorScheme:Et,o=new Map;for(let t=0;n.length>t;t++)o.set(n[t],r[t%r.length]);return this._colorMapCache={key:i,map:o},o}resolveLineStyle(t,e){const n=this.config.lineStyle;if("function"==typeof n){const i=n(e||{},t);if(i&&!i.stroke&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},i),{stroke:e})}return i}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 i=this.config.lineStyle;if("function"==typeof i){const n=i(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 i&&"object"==typeof i?{fill:i.fill||i.stroke||"#4e79a7",fillOpacity:null!==(n=i.fillOpacity)&&void 0!==n?n:.7,stroke:i.stroke||"#4e79a7",strokeWidth:i.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:Et,i=n[this._groupColorMap.size%n.length];return this._groupColorMap.set(t,i),i}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}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._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){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),Object.assign(this.config,t),(void 0!==t.xAccessor||void 0!==t.yAccessor||void 0!==t.timeAccessor||void 0!==t.valueAccessor)&&(["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?(this.getX=xt(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=xt(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=xt(this.config.xAccessor,"x"),this.getY=xt(this.config.yAccessor,"y"))),void 0!==t.groupAccessor&&(this.getGroup=kt(this.config.groupAccessor)),void 0!==t.categoryAccessor&&(this.getCategory=kt(this.config.categoryAccessor)),void 0!==t.sizeAccessor&&(this.getSize=this.config.sizeAccessor?xt(this.config.sizeAccessor,"size"):void 0),void 0!==t.colorAccessor&&(this.getColor=kt(this.config.colorAccessor)),void 0!==t.y0Accessor&&(this.getY0=this.config.y0Accessor?xt(this.config.y0Accessor,"y0"):void 0),void 0!==t.pointIdAccessor&&(this.getPointId=kt(this.config.pointIdAccessor)),this.needsFullRebuild=!0}}function _t(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 Lt(t){let e=t%(2*Math.PI);return 0>e&&(e+=2*Math.PI),e}function Dt(t,e,n){const i=e-t.x,r=n-t.y,o=Math.sqrt(i*i+r*r);return o>t.r+5?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:o}}function Tt(t,e,n){var i,r,o,a;if(0===t.path.length)return null;const l=zt(t.path,e);if(0>l)return null;const[s,c]=t.path[l];let u;if(t.path.length>1){let i=1/0;const r=Math.max(0,l-1),o=Math.min(t.path.length-2,l);for(let a=r;o>=a;a++){const[r,o]=t.path[a],[l,s]=t.path[a+1],c=Wt(e,n,r,o,l,s);i>c&&(i=c)}u=i}else{const t=e-s,i=n-c;u=Math.sqrt(t*t+i*i)}const h=null!==(a=null!==(r=null===(i=t.style)||void 0===i?void 0:i.strokeWidth)&&void 0!==r?r:null===(o=t.style)||void 0===o?void 0:o.lineWidth)&&void 0!==a?a:1;return u>Math.max(5,h/2+2)?null:{node:t,datum:Array.isArray(t.datum)&&t.datum[l]?t.datum[l]:t.datum,x:s,y:c,distance:u}}function Wt(t,e,n,i,r,o){const a=r-n,l=o-i,s=a*a+l*l;if(0===s)return Math.sqrt(Math.pow(t-n,2)+Math.pow(e-i,2));let c=((t-n)*a+(e-i)*l)/s;c=Math.max(0,Math.min(1,c));const u=i+c*l;return Math.sqrt(Math.pow(t-(n+c*a),2)+Math.pow(e-u,2))}function $t(t,e,n){const i=_t(e,n,t);return i.hit?{node:t,datum:t.datum,x:i.cx,y:i.cy,distance:0}:null}function Ct(t,e,n){const i=_t(e,n,t);return i.hit?{node:t,datum:t.datum,x:i.cx,y:i.cy,distance:0}:null}function Ot(t,e,n){const i=t.bodyWidth/2,r=Math.min(t.openY,t.closeY);if(!(t.x-i-3>e||e>t.x+i+3||t.highY-3>n||n>t.lowY+3)){const i=r+Math.max(Math.max(t.openY,t.closeY)-r,1)/2,o=e-t.x,a=n-i;return{node:t,datum:t.datum,x:t.x,y:i,distance:Math.sqrt(o*o+a*a)}}return null}function Nt(t,e,n){if(0===t.topPath.length)return null;const i=zt(t.topPath,e);if(0>i)return null;const[r,o]=t.topPath[i],a=e-r,l=n-o,s=Math.sqrt(a*a+l*l);return{node:t,datum:Array.isArray(t.datum)&&t.datum[i]?t.datum[i]:t.datum,x:r,y:o,distance:s}}function zt(t,e){if(0===t.length)return-1;let n=0,i=t.length-1;for(;i>n;){const r=n+i>>1;e>t[r][0]?n=r+1:i=r}return n>0&&Math.abs(t[n][0]-e)>=Math.abs(t[n-1][0]-e)?n-1:n}function It(t,e,n){switch(t){case"ArrowRight":case"ArrowDown":return n-1>e?e+1:e;case"ArrowLeft":case"ArrowUp":return e>0?e-1:e;case"Home":return 0;case"End":return n-1;case"Escape":return-1;default:return null}}function Bt(t,r,o){const a=e(null),[l,s]=n(null);return i(()=>{if(!r&&!o)return;const t=a.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()},[r,o]),[a,[r&&l?l.w:t[0],o&&l?l.h:t[1]]]}function jt(t,e,n,r,o,a){i(()=>{if(!t)return;const i=setInterval(()=>{var i;const l=e.current;if(!l||0===l.lastIngestTime)return;const s="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(i=t.threshold)&&void 0!==i?i:5e3,u=s-l.lastIngestTime>c;u!==o&&(a(u),n.current=!0,r())},1e3);return()=>clearInterval(i)},[t,o,r])}St.QUADTREE_THRESHOLD=500;const Rt={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 Ft(t,e,n,i){let r;return r="function"==typeof n?n(t):(0,Rt[n])(i(t,e)),r}function Yt(){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 Ht(t,e,n){return n&&n.size>0?n.has(t.label)?1:.3:null!=e?t.label===e?1:.3:1}function Xt({config:e,orientation:n="vertical",width:i=100}){const{colorFn:r,domain:o,label:a,format:l}=e,s=l||(t=>Math.round(100*t)/100+""),c="grad-legend-"+t.useId();if("horizontal"===n){const e=12,n=Math.min(i,200),l=Math.max(0,(i-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:r(o[0]+n*(o[1]-o[0]))}))}return t.createElement("g",{"aria-label":a||"Gradient legend"},t.createElement("defs",null,t.createElement("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"100%",y2:"0%"},u)),a&&t.createElement("text",{x:l+n/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},a),t.createElement("rect",{x:l,y:0,width:n,height:e,fill:`url(#${c})`,rx:2}),t.createElement("text",{x:l,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(o[0])),t.createElement("text",{x:l+n,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(o[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:r(o[1]-n*(o[1]-o[0]))}))}return t.createElement("g",{"aria-label":a||"Gradient legend"},a&&t.createElement("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},a),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(o[1])),t.createElement("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(o[0])))}function Gt(e){const{legendGroups:n,customClickBehavior:i,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:a,legendInteraction:l,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)},[]),v="vertical"===h?(({legendGroups:e,width:n,customClickBehavior:i,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:a,focusedGroupIndex:l,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,i,r,o,a,l,s,c,u)=>{const{type:h="fill",styleFn:d,items:f}=e,y=[];let g=0;const p=!(!n&&!i),v="isolate"===u||void 0===u&&null!=o;return f.forEach((e,u)=>{const m=Ft(e,u,h,d),x=Ht(e,r,o),b=o&&o.size>0&&o.has(e.label);y.push(t.createElement("g",{key:"legend-item-"+u,transform:`translate(0,${g})`,onClick:n?()=>n(e):void 0,onMouseEnter:i?()=>i(e):void 0,onMouseLeave:i?()=>i(null):void 0,tabIndex:p?s===a&&u===l?0:-1:void 0,role:p?"option":void 0,"aria-selected":p&&v?b||!1:void 0,"aria-current":p&&!v&&null!=r&&e.label===r||void 0,"aria-label":e.label,onKeyDown:p?t=>{var i;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===(i=t.currentTarget.parentElement)||void 0===i?void 0:i.children[e];n instanceof SVGElement&&n.focus()}}:void 0,onFocus:p?t=>{c(s,u),i&&i(e);const n=t.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:p?t=>{i&&i(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(Yt,null),t.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label))),g+=22}),y})(e,i,r,o,a,l,s,f,c,u))),h+=22*e.items.length+8}),d})({legendGroups:n||[],width:c,customClickBehavior:i,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:a,focusedGroupIndex:d,focusedItemIndex:y,onFocusedIndexChange:p,legendInteraction:l}):(({legendGroups:e,height:n,width:i,customClickBehavior:r,customHoverBehavior:o,highlightedCategory:a,isolatedCategories:l,focusedGroupIndex:s,focusedItemIndex:c,onFocusedIndexChange:u,legendInteraction:h})=>{let d=0;const f=[];e.forEach((e,n)=>{let i=0;e.label&&(i+=16);const y=((e,n,i,r,o,a,l,s,c,u)=>{const{type:h="fill",styleFn:d,items:f}=e,y=[];let g=0;const p=!(!n&&!i),v="isolate"===u||void 0===u&&null!=o;return f.forEach((e,u)=>{const m=Ft(e,u,h,d),x=Ht(e,r,o),b=o&&o.size>0&&o.has(e.label);y.push(t.createElement("g",{key:"legend-item-"+u,transform:`translate(${g},0)`,onClick:n?()=>n(e):void 0,onMouseEnter:i?()=>i(e):void 0,onMouseLeave:i?()=>i(null):void 0,tabIndex:p?s===a&&u===l?0:-1:void 0,role:p?"option":void 0,"aria-selected":p&&v?b||!1:void 0,"aria-current":p&&!v&&null!=r&&e.label===r||void 0,"aria-label":e.label,onKeyDown:p?t=>{var i;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)+f.length)%f.length;c(s,e);const n=null===(i=t.currentTarget.parentElement)||void 0===i?void 0:i.children[e];n instanceof SVGElement&&n.focus()}}:void 0,onFocus:p?t=>{c(s,u),i&&i(e);const n=t.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:p?t=>{i&&i(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(Yt,null),t.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label))),g+=26+7*e.label.length}),{items:y,offset:g}})(e,r,o,a,l,s,c,n,u,h);i+=y.offset+5,f.push(Object.assign(Object.assign({label:e.label},y),{offset:i})),d+=i+12});let y=Math.max(0,(i-d)/2);const g=[];return f.forEach((i,r)=>{const o=e[r];o.label&&(g.push(t.createElement("text",{key:"legend-text-"+r,transform:`translate(${y},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},o.label)),y+=16),g.push(t.createElement("g",{key:"legend-group-"+r,className:"legend-item",transform:`translate(${y},0)`},i.items)),y+=i.offset+5,e[r+1]&&g.push(t.createElement("line",{key:"legend-top-line legend-symbol-"+r,stroke:"gray",x1:y,y1:-8,x2:y,y2:n+0+8})),y+=12}),t.createElement("g",null,g)})({legendGroups:n||[],title:s,height:u,width:c,customClickBehavior:i,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:a,focusedGroupIndex:d,focusedItemIndex:y,onFocusedIndexChange:p,legendInteraction:l}),m=!(!i&&!r);return t.createElement("g",{role:m?"listbox":void 0,"aria-multiselectable":!(!m||"isolate"!==l&&(void 0!==l||null==a))||void 0,"aria-label":"Chart legend"},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),v)}function Vt(e){const{legend:n,totalWidth:i,totalHeight:r,margin:o,legendPosition:a="right",title:l,legendHoverBehavior:s,legendClickBehavior:c,legendHighlightedCategory:u,legendIsolatedCategories:h,legendInteraction:d}=e;if(!n)return null;const f="top"===a||"bottom"===a;let y,g;return"left"===a?(y=4,g=o.top):"top"===a?(y=0,g=l?32:8):"bottom"===a?(y=0,g=r-o.bottom+50):(y=i-o.right+10,g=o.top),t.createElement("g",{transform:`translate(${y}, ${g})`},function(t){return"object"==typeof t&&null!==t&&"gradient"in t}(n)?t.createElement(Xt,{config:n.gradient,orientation:f?"horizontal":"vertical",width:f?i:100}):function(t){return"object"==typeof t&&null!==t&&"legendGroups"in t}(n)?t.createElement(Gt,{legendGroups:n.legendGroups,title:"",width:f?i:100,orientation:f?"horizontal":"vertical",customHoverBehavior:s,customClickBehavior:c,highlightedCategory:u,isolatedCategories:h,legendInteraction:d}):n)}function qt(t){return"string"==typeof t?{type:t}:t}function Kt({orient:e,config:n,values:i,scale:o,size:a,length:l}){const s=function(t){var e,n,i,r,o;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!==(i=t.fillOpacity)&&void 0!==i?i:.5,stroke:null!==(r=t.stroke)&&void 0!==r?r:"none",strokeWidth:null!==(o=t.strokeWidth)&&void 0!==o?o:1}}(n),c="top"===e||"bottom"===e,u=r(()=>{if(0===i.length)return null;const n=o.domain(),r=a-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 i=e[Math.floor(.25*n)],r=e[Math.floor(.5*n)],o=e[Math.floor(.75*n)],a=o-i;return{q1:i,median:r,q3:o,whiskerLow:Math.max(e[0],i-1.5*a),whiskerHigh:Math.min(e[n-1],o+1.5*a)}}(i);if(!n)return null;const{q1:a,median:l,q3:u,whiskerLow:h,whiskerHigh:d}=n,f=Math.min(.5*r,20),y=(r-f)/2+4;if(c){const n=o(a),i=o(u),r=o(l),c=o(h),g=o(d),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,i),y:"top"===e?v-y-f:v+y,width:Math.abs(i-n),height:f,fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),t.createElement("line",{x1:r,y1:"top"===e?v-y-f:v+y,x2:r,y2:"top"===e?v-y:v+y+f,stroke:s.fill,strokeWidth:2}))}{const n=o(a),i=o(u),r=o(l),c=o(h),g=o(d),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,i),width:f,height:Math.abs(i-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:r,x2:"left"===e?v-y:v+y+f,y2:r,stroke:s.fill,strokeWidth:2}))}}const u=M().domain(n).thresholds(s.bins)(i);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,i)=>{if(null==n.x0||null==n.x1)return null;const a=n.length/h*r;if(c){const r=o(n.x0),l=o(n.x1)-o(n.x0);return t.createElement("rect",{key:i,x:r,y:"top"===e?-4-a:4,width:Math.max(l,.5),height:a,fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth})}{const r=o(n.x0),l=o(n.x1)-o(n.x0);return t.createElement("rect",{key:i,x:"left"===e?-4-a:4,y:Math.min(r,r+l),width:a,height:Math.abs(l),fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth})}}));if("violin"===s.type){const n=r/2+4,i=[];for(const t of u){if(null==t.x0||null==t.x1)continue;const a=t.length/h*(r/2),l=o((t.x0+t.x1)/2);i.push(c?`${l},${"top"===e?-(n-a):n-a}`:`${"left"===e?-(n-a):n-a},${l}`)}for(let t=u.length-1;t>=0;t--){const a=u[t];if(null==a.x0||null==a.x1)continue;const l=a.length/h*(r/2),s=o((a.x0+a.x1)/2);i.push(c?`${s},${"top"===e?-(n+l):n+l}`:`${"left"===e?-(n+l):n+l},${s}`)}return t.createElement("g",{"data-testid":"marginal-violin-"+e},t.createElement("polygon",{points:i.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,i=null!=u[0].x0?o(u[0].x0):0;n.push(`M${i},${t}`);for(const t of u){if(null==t.x0||null==t.x1)continue;const i=t.length/h*r,a=o((t.x0+t.x1)/2);n.push(`L${a},${"top"===e?-i-4:i+4}`)}const a=null!=u[u.length-1].x1?o(u[u.length-1].x1):l;n.push(`L${a},${t}`),n.push("Z")}else{const t=0,i=null!=u[0].x0?o(u[0].x0):0;n.push(`M${t},${i}`);for(const t of u){if(null==t.x0||null==t.x1)continue;const i=t.length/h*r,a=o((t.x0+t.x1)/2);n.push(`L${"left"===e?-i-4:i+4},${a}`)}const a=null!=u[u.length-1].x1?o(u[u.length-1].x1):l;n.push(`L${t},${a}`),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},[i,o,s,a,l,e,c,4]);return u?t.createElement("g",{className:"marginal-"+e,"data-testid":"marginal-"+e},u):null}function Zt(t,e=120,n=8){if(!t)return[];const i=Math.max(1,Math.floor(e/n)),r=t.split(/\s+/),o=[];let a="";for(const t of r)a&&a.length+1+t.length>i?(o.push(a),a=t):a=a?`${a} ${t}`:t;return a&&o.push(a),o}function Ut(t,e,n,i){return"curly"===t?i?`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`:i?`M0,0 L${n},0 L${n},${e} L0,${e}`:`M0,0 L0,${n} L${e},${n} L${e},0`}function Qt(e){const{x:n=0,y:i=0,dx:r,dy:o,nx:a,ny:l,note:s,connector:c,subject:u,type:h,color:d,className:f,disable:y,events:g={},"data-testid":p}=e,v=new Set(Array.isArray(y)?y:[]);let m=r||0,x=o||0;null!=a&&(m=a-n),null!=l&&(x=l-i);const b="string"==typeof h?h:"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},${i})`,"data-testid":p},g),!v.has("connector")&&function(e,n,i,r,o,a){const l=[];let s=0,c=0;if("callout-circle"!==o&&"label"!==o||!(null==a?void 0:a.radius)){if("callout-rect"===o&&a){const t=a.width||0,i=a.height||0;if(t>0||i>0){const r=t/2,o=i/2,a=e-r,l=n-o;if(0!==a||0!==l){const e=Math.abs(a),n=Math.abs(l),u=t/2,h=i/2,d=e*h>n*u?u/e:h/n;s=r+a*d,c=o+l*d}}}else if("bracket"===o&&a){const t=a.width,e=a.height,n=a.depth||30;void 0!==t?(s=t/2,c=n):void 0!==e&&(s=n,c=e/2)}}else{const t=(a.radius||0)+(a.radiusPadding||0);if(t>0&&(0!==e||0!==n)){const i=Math.atan2(n,e);s=Math.cos(i)*t,c=Math.sin(i)*t}}if(Math.sqrt(Math.pow(e-s,2)+Math.pow(n-c,2))>.5&&(l.push(t.createElement("line",{key:"connector-line",x1:s,y1:c,x2:e,y2:n,stroke:r||"currentColor"})),"arrow"===(null==i?void 0:i.end))){const i=10,o=16/180*Math.PI,a=Math.atan2(n-c,e-s);l.push(t.createElement("path",{key:"connector-arrow",d:`M${s},${c}L${s+i*Math.cos(a+o)},${c+i*Math.sin(a+o)}L${s+i*Math.cos(a-o)},${c+i*Math.sin(a-o)}Z`,fill:r||"currentColor",stroke:"none"}))}return t.createElement("g",{className:"annotation-connector"},l)}(m,x,c,d,b,u),!v.has("subject")&&function(e,n,i,r,o){var a;const l=[];switch(e){case"callout-circle":{const e=((null==n?void 0:n.radius)||0)+((null==n?void 0:n.radiusPadding)||0);e>0&&l.push(t.createElement("circle",{key:"subject-circle",r:e,fill:"none",stroke:i||"currentColor"}));break}case"callout-rect":{const e=(null==n?void 0:n.width)||0,r=(null==n?void 0:n.height)||0;(e>0||r>0)&&l.push(t.createElement("rect",{key:"subject-rect",width:e,height:r,fill:"none",stroke:i||"currentColor"}));break}case"callout-custom":(null==n?void 0:n.custom)&&l.push(...Array.isArray(n.custom)?n.custom:[n.custom]);break;case"xy-threshold":{const e=r||0,a=o||0;if(void 0!==(null==n?void 0:n.x)){const r=(n.x||0)-e;l.push(t.createElement("line",{key:"threshold-line",x1:r,y1:(n.y1||0)-a,x2:r,y2:(n.y2||0)-a,stroke:i||"currentColor",strokeDasharray:"5,5"}))}else if(void 0!==(null==n?void 0:n.y)){const r=(n.y||0)-a;l.push(t.createElement("line",{key:"threshold-line",x1:(n.x1||0)-e,y1:r,x2:(n.x2||0)-e,y2:r,stroke:i||"currentColor",strokeDasharray:"5,5"}))}else void 0!==(null==n?void 0:n.x1)||void 0!==(null==n?void 0:n.x2)?l.push(t.createElement("line",{key:"threshold-line",x1:(n.x1||0)-e,y1:0,x2:(n.x2||0)-e,y2:0,stroke:i||"currentColor",strokeDasharray:"5,5"})):void 0===(null==n?void 0:n.y1)&&void 0===(null==n?void 0:n.y2)||l.push(t.createElement("line",{key:"threshold-line",x1:0,y1:(n.y1||0)-a,x2:0,y2:(n.y2||0)-a,stroke:i||"currentColor",strokeDasharray:"5,5"}));break}case"bracket":{const e=null!==(a=null==n?void 0:n.width)&&void 0!==a?a:null==n?void 0:n.height;void 0!==e&&l.push(t.createElement("path",{key:"bracket-path",d:Ut((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:i||"currentColor"}));break}}return t.createElement("g",{className:"annotation-subject"},l)}(b,u,d,n,i),!v.has("note")&&function(e,n,i,r){if(!e)return t.createElement("g",{className:"annotation-note"});const{label:o,title:a,orientation:l,align:s,wrap:c=120,noWrap:u}=e;if(!o&&!a)return t.createElement("g",{className:"annotation-note"});let h=l;h||(h=Math.abs(n)>Math.abs(i)?"leftRight":"topBottom");let d=s;d&&"dynamic"!==d||(d="topBottom"===h?0>n?"right":"left":0>i?"bottom":"top");let f="start";"topBottom"===h?"right"===d?f="end":"middle"===d&&(f="middle"):f=0>n?"end":"start";const y=16,g=a?u?[a]:Zt(a,c):[],p=o?u?[o]:Zt(o,c):[],v="leftRight"===h?"end"===f?-4:4:0;let m=0;const x=[];g.length>0&&(x.push(t.createElement("text",{key:"annotation-note-title",className:"annotation-note-title",fill:r||void 0,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:r||void 0,textAnchor:f,y:m},p.map((e,n)=>t.createElement("tspan",{key:n,x:v,dy:0===n?0:y},e))));let b=null;if((a||o)&&(0!==n||0!==i))if("topBottom"===h){const e=Math.min(c,120);let n=0,i=e;"end"===f?(n=-e,i=0):"middle"===f&&(n=-e/2,i=e/2),b=t.createElement("line",{className:"note-line",x1:n,x2:i,y1:0,y2:0,stroke:r||"currentColor"})}else{const e=(g.length+p.length)*y+(p.length>0?y:0);let n=0,i=e;"bottom"===d?(n=-e,i=0):"middle"===d&&(n=-e/2,i=e/2),b=t.createElement("line",{className:"note-line",x1:0,x2:0,y1:n,y2:i,stroke:r||"currentColor"})}const k=Math.max(0,g.length+p.length-1)*y;let w=0;return"topBottom"===h?w=0>i?-(k+2):18:"leftRight"===h&&(w="middle"===d?-(k+y+(p.length>0&&g.length>0?2:0))/2+8:"bottom"===d||0>i?-(k+2):18),t.createElement("g",{className:"annotation-note",transform:`translate(${n},${i})`},t.createElement("g",{className:"annotation-note-content",transform:0!==w?`translate(0,${w})`:void 0},x),b)}(s,m,x,d))}function Jt(e){var n,i;const{noteData:r}=e,{screenCoordinates:o}=r,a="string"==typeof r.type?r.type:"label",l=r.eventListeners||r.events||{};if(r.coordinates&&o){const e=r.nx||o[0][0]+(null!==(n=r.dx)&&void 0!==n?n:0),l=r.ny||o[0][1]+(null!==(i=r.dy)&&void 0!==i?i:0),s=o.map((n,i)=>{const o=Object.assign({},r,{note:0===i?r.note:{label:""},x:n[0],y:n[1],nx:e,ny:l});return t.createElement(Qt,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+i},o,{type:a}))});return t.createElement("g",null,s)}const s=r.note||{title:"none",label:r.label};return t.createElement(Qt,Object.assign({"data-testid":"semiotic-annotation",key:`${s.label}-${s.title}-${r.i}`,events:l},r,{type:a}))}const te={linear:K,monotoneX:q,monotoneY:V,step:G,stepAfter:X,stepBefore:H,basis:Y,cardinal:F,catmullRom:R};function ee(t,e){var n,i,r;const o=null!==(i=null===(n=e.scales)||void 0===n?void 0:n.x)&&void 0!==i?i:null===(r=e.scales)||void 0===r?void 0:r.time;return o?null!=t.x?o(t.x):e.xAccessor&&null!=t[e.xAccessor]?o(t[e.xAccessor]):null:null}function ne(t,e){var n,i,r;const o=null!==(i=null===(n=e.scales)||void 0===n?void 0:n.y)&&void 0!==i?i:null===(r=e.scales)||void 0===r?void 0:r.value;return o?null!=t.y?o(t.y):e.yAccessor&&null!=t[e.yAccessor]?o(t[e.yAccessor]):null:null}function ie(t,e,n){var i,r,o,a;const l=t.anchor||"fixed";if("latest"===l){if(null!=t.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let r=n.pointNodes.length-1;r>=0;r--){const o=n.pointNodes[r];if(o.pointId===t.pointId){const t={x:o.x,y:o.y};return null===(i=n.stickyPositionCache)||void 0===i||i.set(e,t),t}}const o=function(t){var e,n,i,r,o,a;const l=t.data;if(!l||0===l.length)return null;const s=l[l.length-1],c=null!==(n=null===(e=t.scales)||void 0===e?void 0:e.x)&&void 0!==n?n:null===(i=t.scales)||void 0===i?void 0:i.time,u=null!==(o=null===(r=t.scales)||void 0===r?void 0:r.y)&&void 0!==o?o:null===(a=t.scales)||void 0===a?void 0:a.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 o&&(null===(r=n.stickyPositionCache)||void 0===r||r.set(e,o)),o}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=ee(t,n),c=ne(t,n)),null!=s&&null!=c)return null===(o=n.stickyPositionCache)||void 0===o||o.set(e,{x:s,y:c}),{x:s,y:c};if("sticky"===l){const t=null===(a=n.stickyPositionCache)||void 0===a?void 0:a.get(e);if(t)return t}return null}function re(t,e,n,i=50){return!(-i>t||t>(n.width||0)+i||-i>e||e>(n.height||0)+i)}function oe(t,e,n){if("left"===t||"right"===t){const i="left"===t?n:0,r="left"===t?-1:1,o=Math.ceil(e/8);let a="M0,"+i;for(let t=0;o>t;t++){const n=8*(t+1);a+=`L${Math.min(8*t+4,e)},${i+4*r}`,a+=`L${Math.min(n,e)},${i}`}return a}{const i="bottom"===t?0:e,r="bottom"===t?1:-1,o=Math.ceil(n/8);let a=`M${i},0`;for(let t=0;o>t;t++){const e=8*(t+1);a+=`L${i+4*r},${Math.min(8*t+4,n)}`,a+=`L${i},${Math.min(e,n)}`}return a}}function ae(e){const{width:n,height:i,totalWidth:o,totalHeight:a,margin:l,scales:s,showAxes:c,axes:u,showGrid:h,xFormat:d,yFormat:f}=e,y=r(()=>{var t;if(!s)return[];const e=null==u?void 0:u.find(t=>"bottom"===t.orient),i=(null==e?void 0:e.tickFormat)||d||le,r=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5;return s.x.ticks(Math.min(r,Math.max(2,Math.floor(n/70)))).map(t=>({value:t,pixel:s.x(t),label:i(t)}))},[s,u,d,n]),g=r(()=>{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||le,r=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5;return s.y.ticks(Math.min(r,Math.max(2,Math.floor(i/30)))).map(t=>({value:t,pixel:s.y(t),label:n(t)}))},[s,u,f,i]),p=h&&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:o,height:a,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},t.createElement("g",{transform:`translate(${l.left},${l.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:i,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1})),g.map((e,i)=>t.createElement("line",{key:"ygrid-"+i,x1:0,y1:e.pixel,x2:n,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),b&&!w&&t.createElement("line",{x1:0,y1:i,x2:n,y2:i,stroke:A,strokeWidth:1}),w&&t.createElement("path",{d:oe("bottom",n,i),fill:"none",stroke:A,strokeWidth:1}),k&&!E&&t.createElement("line",{x1:0,y1:0,x2:0,y2:i,stroke:A,strokeWidth:1}),E&&t.createElement("path",{d:oe("left",n,i),fill:"none",stroke:A,strokeWidth:1})))}function le(t){return Math.round(100*t)/100+""}function se(t,e){return t instanceof Date&&(!(e&&e instanceof Date)||t.getFullYear()!==e.getFullYear()||t.getMonth()!==e.getMonth()||t.getDate()!==e.getDate())}function ce(n){var i,o;const{width:a,height:l,totalWidth:s,totalHeight:c,margin:u,scales:h,showAxes:d,axes:f,xLabel:y,yLabel:g,xFormat:p,yFormat:v,showGrid:m,title:x,legend:b,legendHoverBehavior:k,legendClickBehavior:w,legendHighlightedCategory:E,legendIsolatedCategories:A,legendPosition:M="right",foregroundGraphics:P,marginalGraphics:S,xValues:_,yValues:L,annotations:D,svgAnnotationRules:T,xAccessor:$,yAccessor:C,annotationData:O,pointNodes:N,curve:z,underlayRendered:I,children:B}=n,R=r(()=>{var t;if(!d||!h)return[];const e=null==f?void 0:f.find(t=>"bottom"===t.orient),n=(null==e?void 0:e.tickFormat)||p||le,i=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5;return h.x.ticks(Math.min(i,Math.max(2,Math.floor(a/70)))).map(t=>({value:t,pixel:h.x(t),label:n(t)}))},[d,h,f,p,a]),F=r(()=>{var t;if(!d||!h)return[];const e=null==f?void 0:f.find(t=>"left"===t.orient),n=(null==e?void 0:e.tickFormat)||v||le,i=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5;return h.y.ticks(Math.min(i,Math.max(2,Math.floor(l/30)))).map(t=>({value:t,pixel:h.y(t),label:n(t)}))},[d,h,f,v,l]),Y=e(new Map),H=e(null!==(i=null==D?void 0:D.length)&&void 0!==i?i:0),X=null!==(o=null==D?void 0:D.length)&&void 0!==o?o:0;H.current!==X&&(H.current=X,Y.current=new Map);const G=r(()=>{if(!D||0===D.length)return null;const e=function(e,n,i){var r,o,a,l,s,c,u,h,d,f,y,g,p,v,m,x,b,k,w,E,A,M,P,S,_,L,D,T,$,C,O,N,z,I,B,R,F,Y,H,X,G,V,q,Z;switch(e.type){case"label":{const r=ie(e,n,i);if(!r)return null;const{x:o,y:a}=r;return re(o,a,i)?t.createElement(Jt,{key:"ann-"+n,noteData:{x:o,y:a,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 r=ie(e,n,i);if(!r)return null;const{x:o,y:a}=r;return re(o,a,i)?t.createElement(Jt,{key:"ann-"+n,noteData:{x:o,y:a,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 r=ee(e,i);if(null==r)return null;const o=e.color||"#f97316";return t.createElement("g",{key:"ann-"+n},t.createElement("line",{x1:r,y1:0,x2:r,y2:i.height||0,stroke:o,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&t.createElement("text",{x:r+4,y:12,fill:o,fontSize:12,fontWeight:"bold"},e.label))}case"y-threshold":{const r=ne(e,i);if(null==r)return null;const o=e.color||"#f97316";return t.createElement("g",{key:"ann-"+n},t.createElement("line",{x1:0,y1:r,x2:i.width||0,y2:r,stroke:o,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&t.createElement("text",{x:(i.width||0)-4,y:r-4,textAnchor:"end",fill:o,fontSize:12,fontWeight:"bold"},e.label))}case"enclose":{const r=(e.coordinates||[]).map(t=>({x:ee(Object.assign(Object.assign({},t),{type:"point"}),i),y:ne(Object.assign(Object.assign({},t),{type:"point"}),i),r:1})).filter(t=>null!=t.x&&null!=t.y);if(2>r.length)return null;const o=W(r),a=e.padding||10;return t.createElement("g",{key:"ann-"+n},t.createElement("circle",{cx:o.x,cy:o.y,r:o.r+a,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&t.createElement("text",{x:o.x,y:o.y-o.r-a-4,textAnchor:"middle",fill:e.color||"#666",fontSize:12},e.label))}case"rect-enclose":{const r=(e.coordinates||[]).map(t=>({x:ee(Object.assign(Object.assign({},t),{type:"point"}),i),y:ne(Object.assign(Object.assign({},t),{type:"point"}),i)})).filter(t=>null!=t.x&&null!=t.y);if(2>r.length)return null;const o=e.padding||10,a=r.map(t=>t.x),l=r.map(t=>t.y),s=Math.min(...a)-o,c=Math.max(...a)+o,u=Math.min(...l)-o,h=Math.max(...l)+o;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||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&t.createElement("text",{x:(s+c)/2,y:u-4,textAnchor:"middle",fill:e.color||"#666",fontSize:12},e.label))}case"highlight":{const r=i.data||[],o="function"==typeof e.filter?r.filter(e.filter):e.field&&null!=e.value?r.filter(t=>t[e.field]===e.value):[],a=e.style||{stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return t.createElement("g",{key:"ann-"+n},o.map((n,r)=>{const o=ee(n,i),l=ne(n,i);return null==o||null==l?null:t.createElement("circle",Object.assign({key:"hl-"+r,cx:o,cy:l,r:e.r||6},a))}))}case"bracket":{const r=ee(e,i),o=ne(e,i);return t.createElement(Jt,{key:"ann-"+n,noteData:{x:null!=r?r:0,y:null!=o?o:0,dx:e.dx||0,dy:e.dy||0,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"bracket",subject:{type:e.bracketType||"curly",width:e.width,height:e.height,depth:e.depth||30},color:e.color}})}case"trend":{const h=i.data||[];if(2>h.length)return null;const d=i.xAccessor||"x",f=i.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!==(o=null===(r=i.scales)||void 0===r?void 0:r.x)&&void 0!==o?o:null===(a=i.scales)||void 0===a?void 0:a.time,p=null!==(s=null===(l=i.scales)||void 0===l?void 0:l.y)&&void 0!==s?s:null===(c=i.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 i=t.slice().sort((t,e)=>t[0]-e[0]),r=i.map(t=>t[0]),o=i.map(t=>t[1]),a=Math.max(2,Math.ceil(e*n)),l=[];for(let t=0;n>t;t++){const e=r[t],i=r.map(t=>Math.abs(t-e)),s=i.slice().sort((t,e)=>t-e)[Math.min(a-1,n-1)]||1,c=[];for(let t=0;n>t;t++){const e=0===s?0:i[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*r[t],d+=e*o[t],f+=e*r[t]*r[t],y+=e*r[t]*o[t])}if(0===u){l.push([e,o[t]]);continue}const g=u*f-h*h;if(1e-12>Math.abs(g))l.push([e,d/u]);else{const t=(u*y-h*d)/g;l.push([e,(d-t*h)/u+t*e])}}return l}(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 r=null!==(d=null===(h=i.scales)||void 0===h?void 0:h.y)&&void 0!==d?d:null===(f=i.scales)||void 0===f?void 0:f.value,o=null!==(y=null==r?void 0:r(e.y0))&&void 0!==y?y:0,a=null!==(g=null==r?void 0:r(e.y1))&&void 0!==g?g:i.height||0;return t.createElement("g",{key:"ann-"+n},t.createElement("rect",{x:0,y:Math.min(o,a),width:i.width||0,height:Math.abs(a-o),fill:e.fill||"#6366f1",fillOpacity:e.fillOpacity||.1}),e.label&&t.createElement("text",{x:(i.width||0)-4,y:Math.min(o,a)-4,textAnchor:"end",fill:e.color||"#6366f1",fontSize:11},e.label))}case"envelope":{const r=i.data||[];if(2>r.length)return null;const o=i.xAccessor||"x",a=null!==(v=null===(p=i.scales)||void 0===p?void 0:p.x)&&void 0!==v?v:null===(m=i.scales)||void 0===m?void 0:m.time,l=null!==(b=null===(x=i.scales)||void 0===x?void 0:x.y)&&void 0!==b?b:null===(k=i.scales)||void 0===k?void 0:k.value;if(!a||!l)return null;const s=e.upperAccessor||"upperBounds",c=e.lowerAccessor||"lowerBounds",u=e.filter,h=r.filter(t=>null!=t[s]&&null!=t[c]&&!(u&&!u(t))).sort((t,e)=>t[o]-e[o]);if(2>h.length)return null;const d=te[i.curve||"linear"]||K,f=j().x(t=>a(t[o])).y0(t=>l(t[c])).y1(t=>l(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:a(h[h.length-1][o])+4,y:l(h[h.length-1][s])-4,fill:y,fontSize:11},e.label))}case"anomaly-band":{const r=i.data||[];if(2>r.length)return null;const o=i.yAccessor||"y",a=null!==(A=null===(E=i.scales)||void 0===E?void 0:E.x)&&void 0!==A?A:null===(M=i.scales)||void 0===M?void 0:M.time,l=null!==(S=null===(P=i.scales)||void 0===P?void 0:P.y)&&void 0!==S?S:null===(_=i.scales)||void 0===_?void 0:_.value;if(!a||!l)return null;const s=r.map(t=>t[o]).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!==(L=e.threshold)&&void 0!==L?L:2,f=c-d*h,y=!1!==e.showBand,g=e.fill||"#6366f1",p=null!==(D=e.fillOpacity)&&void 0!==D?D:.1,v=e.anomalyColor||"#ef4444",m=null!==(T=e.anomalyRadius)&&void 0!==T?T:6,x=l(c+d*h),b=l(f),k=r.filter(t=>{const e=t[o];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:i.width||0,height:Math.abs(b-x),fill:g,fillOpacity:p}),k.map((e,n)=>{const r=ee(e,i),o=ne(e,i);return null==r||null==o?null:t.createElement("circle",{key:"anomaly-"+n,cx:r,cy:o,r:m,fill:v,fillOpacity:.7,stroke:v,strokeWidth:1.5})}),e.label&&t.createElement("text",{x:(i.width||0)-4,y:Math.min(x,b)-4,textAnchor:"end",fill:g,fontSize:11},e.label))}case"forecast":{const r=i.data||[];if(3>r.length)return null;const o=i.xAccessor||"x",a=i.yAccessor||"y",l=null!==(C=null===($=i.scales)||void 0===$?void 0:$.x)&&void 0!==C?C:null===(O=i.scales)||void 0===O?void 0:O.time,s=null!==(z=null===(N=i.scales)||void 0===N?void 0:N.y)&&void 0!==z?z:null===(I=i.scales)||void 0===I?void 0:I.value;if(!l||!s)return null;const c=r.map(t=>[t[o],t[a]]).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,i)=>t+n*Math.pow(e,i),0)}else{const t=c.length;let e=0,n=0,i=0,r=0;for(const[t,o]of c)e+=t,n+=o,i+=t*t,r+=t*o;const o=t*i-e*e;if(1e-12>Math.abs(o))return null;const a=(t*r-e*n)/o,l=(n-a*e)/t;u=t=>l+a*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,v=.99>p?.95>p?.9>p?1:1.645:1.96:2.576,m=null!==(R=e.steps)&&void 0!==R?R:5,x=c[h-1][0],b=(x-c[0][0])/Math.max(h-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/h+(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=>`${l(t.x)},${s(t.yUpper)}`).join(" L")} L${w.slice().reverse().map(t=>`${l(t.x)},${s(t.yLower)}`).join(" L")} Z`,A=w.map(t=>`${l(t.x)},${s(t.yCenter)}`).join(" "),M=`${l(x)},${s(u(x))}`,P=e.strokeColor||"#6366f1";return t.createElement("g",{key:"ann-"+n},t.createElement("path",{d:E,fill:e.fill||"#6366f1",fillOpacity:null!==(F=e.fillOpacity)&&void 0!==F?F:.15,stroke:"none"}),t.createElement("polyline",{points:`${M} ${A}`,fill:"none",stroke:P,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:l(w[w.length-1].x)+4,y:s(w[w.length-1].yCenter)-4,fill:P,fontSize:11},e.label))}case"widget":{let r=null,o=null;if(null!=e.px&&null!=e.py)r=e.px,o=e.py;else{const t=ie(e,n,i);if(!t)return null;r=t.x,o=t.y}if(null==r||null==o)return null;if(!re(r,o,i))return null;const a=null!==(X=e.dx)&&void 0!==X?X:0,l=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!==(Z=e.content)&&void 0!==Z?Z:t.createElement("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info"},"ℹ️");return t.createElement("foreignObject",{key:"ann-"+n,x:r+a-s/2,y:o+l-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 r=ie(e,n,i);if(!r)return null;const{x:o,y:a}=r;return t.createElement("text",{key:"ann-text-"+n,x:o+(e.dx||0),y:a+(e.dy||0),fill:e.color||"var(--semiotic-text, #333)",fontSize:e.fontSize||11,dominantBaseline:"middle",style:{fontFamily:"inherit"}},e.label)}default:return null}},n={scales:h?{x:h.x,y:h.y,time:h.x,value:h.y}:null,timeAxis:"x",xAccessor:$,yAccessor:C,width:a,height:l,data:O,frameType:"xy",pointNodes:N,curve:z,stickyPositionCache:Y.current};return D.map((t,i)=>{if(T){const r=T(t,i,n);return null!=r?r:e(t,i,n)}return e(t,i,n)}).filter(Boolean)},[D,T,a,l,$,C,O,h,N,z]);return d||x||b||P||S||G&&G.length>0||m||B?t.createElement("svg",{role:"img",width:s,height:c,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},t.createElement("title",null,"string"==typeof x?x:"XY Chart"),t.createElement("desc",null,"string"==typeof x?x+" — XY data visualization":"XY data visualization"),t.createElement("g",{transform:`translate(${u.left},${u.top})`},m&&h&&!I&&t.createElement("g",{className:"stream-grid"},R.map((e,n)=>t.createElement("line",{key:"xgrid-"+n,x1:e.pixel,y1:0,x2:e.pixel,y2:l,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1})),F.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}))),d&&h&&(()=>{const e=null==f?void 0:f.find(t=>"left"===t.orient),n=null==f?void 0:f.find(t=>"bottom"===t.orient),i=!e||!1!==e.baseline,r=(null==e?void 0:e.jaggedBase)||!1,o=(null==n?void 0:n.jaggedBase)||!1,s=null==n?void 0:n.landmarkTicks,c=null==e?void 0:e.landmarkTicks,h="var(--semiotic-border, #ccc)",d="var(--semiotic-text-secondary, #666)",p="var(--semiotic-text, #333)";return t.createElement("g",{className:"stream-axes"},!I&&(!n||!1!==n.baseline)&&!o&&t.createElement("line",{x1:0,y1:l,x2:a,y2:l,stroke:h,strokeWidth:1}),!I&&o&&t.createElement("path",{d:oe("bottom",a,l),fill:"none",stroke:h,strokeWidth:1}),R.map((e,n)=>{const i=!!s&&("function"==typeof s?s(e.value,n):se(e.value,n>0?R[n-1].value:void 0));return t.createElement("g",{key:"xtick-"+n,transform:`translate(${e.pixel},${l})`},t.createElement("line",{y2:5,stroke:h,strokeWidth:1}),t.createElement("text",{y:18,textAnchor:"middle",fontSize:i?11:10,fontWeight:i?600:400,fill:d,style:{userSelect:"none"}},e.label))}),y&&t.createElement("text",{x:a/2,y:l+40,textAnchor:"middle",fontSize:12,fill:p,style:{userSelect:"none"}},y),!I&&i&&!r&&t.createElement("line",{x1:0,y1:0,x2:0,y2:l,stroke:h,strokeWidth:1}),!I&&r&&t.createElement("path",{d:oe("left",a,l),fill:"none",stroke:h,strokeWidth:1}),F.map((e,n)=>{const i=!!c&&("function"==typeof c?c(e.value,n):se(e.value,n>0?F[n-1].value:void 0));return t.createElement("g",{key:"ytick-"+n,transform:`translate(0,${e.pixel})`},t.createElement("line",{x2:-5,stroke:h,strokeWidth:1}),t.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:i?11:10,fontWeight:i?600:400,fill:d,style:{userSelect:"none"}},e.label))}),g&&t.createElement("text",{x:15-u.left,y:l/2,textAnchor:"middle",fontSize:12,fill:p,transform:`rotate(-90, ${15-u.left}, ${l/2})`,style:{userSelect:"none"}},g))})(),G,S&&h&&_&&L&&t.createElement(t.Fragment,null,S.top&&t.createElement("g",{transform:"translate(0, 0)"},t.createElement(Kt,{orient:"top",config:qt(S.top),values:_,scale:h.x,size:u.top,length:a})),S.bottom&&t.createElement("g",{transform:`translate(0, ${l})`},t.createElement(Kt,{orient:"bottom",config:qt(S.bottom),values:_,scale:h.x,size:u.bottom,length:a})),S.left&&t.createElement("g",{transform:"translate(0, 0)"},t.createElement(Kt,{orient:"left",config:qt(S.left),values:L,scale:h.y,size:u.left,length:l})),S.right&&t.createElement("g",{transform:`translate(${a}, 0)`},t.createElement(Kt,{orient:"right",config:qt(S.right),values:L,scale:h.y,size:u.right,length:l}))),P,B),x&&t.createElement("text",{x:s/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof x?x:null),Vt({legend:b,totalWidth:s,totalHeight:c,margin:u,legendPosition:M,title:x,legendHoverBehavior:k,legendClickBehavior:w,legendHighlightedCategory:E,legendIsolatedCategories:A})):null}const ue="undefined"==typeof window||"undefined"==typeof document,he={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function de(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 i=[],r={point:"points",line:"lines",area:"areas",rect:"bars",heatcell:"cells",circle:"nodes",candlestick:"candlesticks"},o=["point","line","area","rect","heatcell","circle","candlestick"],a=Object.keys(n).sort((t,e)=>{const n=o.indexOf(t),i=o.indexOf(e);return(-1===n?999:n)-(-1===i?999:i)});for(const t of a)i.push(`${n[t]} ${r[t]||t}`);return`${e}, ${i.join(", ")}`}function fe(t,e,n){const i=[];return t>0&&i.push(t+" nodes"),e>0&&i.push(e+" edges"),0===i.length?n+", empty":`${n}, ${i.join(", ")}`}function ye({scene:e,chartType:n}){var i,r,o,a;const l=[];for(const t of e){if(l.length>=50)break;"point"===t.type?l.push({label:"Point",values:{x:Math.round(100*t.x)/100+"",y:Math.round(100*t.y)/100+""}}):"rect"===t.type?l.push({label:"Bar",values:{category:(null===(i=t.datum)||void 0===i?void 0:i.category)||"",value:Math.round(100*(null!==(o=null===(r=t.datum)||void 0===r?void 0:r.value)&&void 0!==o?o:0))/100+""}}):"heatcell"===t.type&&l.push({label:"Cell",values:{x:Math.round(100*t.x)/100+"",y:Math.round(100*t.y)/100+"",value:Math.round(100*(null!==(a=t.value)&&void 0!==a?a:0))/100+""}})}if(0===l.length)return null;const s=new Set;for(const t of l)for(const e of Object.keys(t.values))s.add(e);const c=Array.from(s);return t.createElement("table",{style:he,role:"table","aria-label":"Data table for "+n},t.createElement("thead",null,t.createElement("tr",null,c.map(e=>t.createElement("th",{key:e},e)))),t.createElement("tbody",null,l.map((e,n)=>t.createElement("tr",{key:n},c.map(n=>{var i;return t.createElement("td",{key:n},null!==(i=e.values[n])&&void 0!==i?i:"")}))),e.length>50&&t.createElement("tr",null,t.createElement("td",{colSpan:c.length},"...and ",e.length-50," more items"))))}function ge({nodes:e,chartType:n}){var i,r,o,a,l;const s=[];for(const t of e){if(s.length>=50)break;s.push({values:{id:(null===(i=t.datum)||void 0===i?void 0:i.id)||t.id||"",x:Math.round(100*(null!==(o=null!==(r=t.cx)&&void 0!==r?r:t.x)&&void 0!==o?o:0))/100+"",y:Math.round(100*(null!==(l=null!==(a=t.cy)&&void 0!==a?a:t.y)&&void 0!==l?l:0))/100+""}})}if(0===s.length)return null;const c=new Set;for(const t of s)for(const e of Object.keys(t.values))c.add(e);const u=Array.from(c);return t.createElement("table",{style:he,role:"table","aria-label":"Data table for "+n},t.createElement("thead",null,t.createElement("tr",null,u.map(e=>t.createElement("th",{key:e},e)))),t.createElement("tbody",null,s.map((e,n)=>t.createElement("tr",{key:n},u.map(n=>{var i;return t.createElement("td",{key:n},null!==(i=e.values[n])&&void 0!==i?i:"")}))),e.length>50&&t.createElement("tr",null,t.createElement("td",{colSpan:u.length},"...and ",e.length-50," more items"))))}function pe({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:he},n)}function ve(n){const i=o(null),c=me(n);return[function({children:e}){const o=r(()=>me(n),[]);return t.createElement(i.Provider,{value:o,children:e})},t=>{var n;const r=null!==(n=a(i))&&void 0!==n?n:c,o=e(t);o.current=t;const u=l(()=>o.current(r.getState()),[r]),h=l(()=>o.current(r.getState()),[r]);return s(r.subscribe,u,h)}]}function me(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 xe={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}},be={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}},[ke,we]=ve(t=>({theme:xe,setTheme(e){t(t=>"light"===e?{theme:xe}:"dark"===e?{theme:be}:{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 Ee(t,e,n,i){const r=t.getContext("2d");if(!r)return null;const o=e[0]*i,a=e[1]*i,l=e[0]+"px",s=e[1]+"px";return t.style.width!==l&&(t.style.width=l),t.style.height!==s&&(t.style.height=s),t.width===o&&t.height===a||(t.width=o,t.height=a),r.setTransform(i,0,0,i,0,0),r.translate(n.left,n.top),r}function Ae(){return"undefined"!=typeof window&&window.devicePixelRatio||1}function Me(t){switch(t){case"monotoneX":return q;case"monotoneY":return V;case"cardinal":return F;case"catmullRom":return R;case"step":return G;case"stepBefore":return H;case"stepAfter":return X;case"basis":return Y;case"natural":return Q;default:return null}}function Pe(t,e,n){let i=n;for(const n of e)"lesser"===n.thresholdType?n.value>t&&(i=n.color):t>n.value&&(i=n.color);return i}function Se(t,e,n,i,r,o){if(2>e.length)return;const a=[0];for(let t=1;e.length>t;t++){const n=e[t][0]-e[t-1][0],i=e[t][1]-e[t-1][1];a.push(a[t-1]+Math.sqrt(n*n+i*i))}const l=a[a.length-1];if(0===l)return;const s=Math.min(.2*l,40);t.strokeStyle=n,t.lineWidth=i,t.lineCap=o;for(let n=0;e.length-1>n;n++){const i=(a[n]+a[n+1])/2;let o=r;s>i&&(o*=i/s),s>l-i&&(o*=(l-i)/s),t.globalAlpha=Math.max(0,o),t.beginPath(),t.moveTo(e[n][0],e[n][1]),t.lineTo(e[n+1][0],e[n+1][1]),t.stroke()}}function _e(t){return!(!t._pulseIntensity||0>=t._pulseIntensity)}function Le(t,e,n=.3){_e(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 De(t,e,n=.6){var i,r,o,a,l;if(!_e(e))return;const s=null!==(i=e._pulseGlowRadius)&&void 0!==i?i:4,c=e.r+s*e._pulseIntensity,u=null!==(o=null!==(r=e.cx)&&void 0!==r?r:e.x)&&void 0!==o?o:0,h=null!==(l=null!==(a=e.cy)&&void 0!==a?a:e.y)&&void 0!==l?l: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 Te(t,e,n,i=.35){_e(e)&&(t.globalAlpha=e._pulseIntensity*i,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fill())}function We(t){switch(t){case"monotoneX":return q;case"monotoneY":return V;case"cardinal":return F;case"catmullRom":return R;case"step":return G;case"stepBefore":return H;case"stepAfter":return X;case"basis":return Y;case"natural":return Q;default:return null}}function $e(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 Ce(t,e){const n=We(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 i=j().x(t=>t[0]).y0((t,n)=>e.bottomPath[n][1]).y1(t=>t[1]).curve(n).context(t);t.beginPath(),i(e.topPath)}}const Oe=(t,e,n,i)=>{var r,o,a;const l=e.filter(t=>"area"===t.type);for(const e of l){if(2>e.topPath.length)continue;const n=e.style.fill||"#4e79a7",i=e._decayOpacities;if(i&&i.length===e.topPath.length){const o=null!==(r=e.style.fillOpacity)&&void 0!==r?r:.7;t.fillStyle=n;for(let n=0;e.topPath.length-1>n;n++)t.globalAlpha=.5*(i[n]+i[n+1])*o,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*(i[n]+i[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 l=null!==(o=e.style.opacity)&&void 0!==o?o:1;if(Ce(t,e),e.fillGradient){let i=1/0;for(const t of e.topPath)i>t[1]&&(i=t[1]);let r=-1/0;for(const t of e.bottomPath)t[1]>r&&(r=t[1]);const o=$e(n),a=e.fillGradient.topOpacity,s=e.fillGradient.bottomOpacity,c=t.createLinearGradient(0,i,0,r);c.addColorStop(0,`rgba(${o[0]},${o[1]},${o[2]},${a})`),c.addColorStop(1,`rgba(${o[0]},${o[1]},${o[2]},${s})`),t.fillStyle=c,t.globalAlpha=l}else{const i=null!==(a=e.style.fillOpacity)&&void 0!==a?a:.7;t.globalAlpha=i*l,t.fillStyle=n}if(t.fill(),e._pulseIntensity&&e._pulseIntensity>0&&(Ce(t,e),Te(t,e)),e.style.stroke&&"none"!==e.style.stroke){t.globalAlpha=l,t.strokeStyle=e.style.stroke,t.lineWidth=e.style.strokeWidth||2,t.setLineDash([]);const n=We(e.curve);if(t.beginPath(),n)U().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}},Ne=(t,e,n,i)=>{var r;const o=e.filter(t=>"point"===t.type);t.save();try{for(const e of o){t.beginPath(),t.arc(e.x,e.y,e.r,0,2*Math.PI);const n=null!==(r=e.style.opacity)&&void 0!==r?r: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()),De(t,e),t.globalAlpha=1}}finally{t.restore()}},ze=(t,e,n,i)=>{const r=e.filter(t=>"rect"===t.type);for(const e of r)null!=e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.icon?Ie(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))),Le(t,e),t.globalAlpha=1};function Ie(t,e){const n=e.style.icon,i=e.style.iconPadding||2,r=Math.min(e.w,e.h)-i;if(0>=r)return;const o=e.h>e.w;if(t.save(),t.beginPath(),t.rect(e.x,e.y,e.w,e.h),t.clip(),o){const o=r+i,a=e.x+(e.w-r)/2;for(let i=e.y+e.h-r;i>=e.y-r;i-=o)t.drawImage(n,a,i,r,r)}else{const o=r+i,a=e.y+(e.h-r)/2;for(let i=e.x;e.x+e.w>i;i+=o)t.drawImage(n,i,a,r,r)}t.restore()}function Be(t){const[e,n,i]=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*i>128?"#000":"#fff"}function je(t){return Number.isInteger(t)?t+"":100>Math.abs(t)?1>Math.abs(t)?t.toPrecision(3):t.toFixed(1):t.toFixed(0)}const Re={line:[Oe,(t,e,n,i)=>{var r,o;const a=e.filter(t=>"line"===t.type);for(const l of a){if(2>l.path.length)continue;const s=l.style.stroke||"#007bff",c=l.style.strokeWidth||2,u=l.colorThresholds,h=l.rawValues;if(t.setLineDash(l.style.strokeDasharray?l.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=l.style.opacity&&(t.globalAlpha=l.style.opacity),t.lineWidth=c,t.lineCap=l.style.strokeLinecap||"butt",l.style._edgeFade){const g=null!==(r=l.style.opacity)&&void 0!==r?r:1;Se(t,l.path,s,c,g,l.style.strokeLinecap||"butt"),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt";continue}const d=Me(l.curve),f=u&&u.length>0&&h&&h.length===l.path.length,y=l._decayOpacities;if(y&&y.length===l.path.length&&!f){t.strokeStyle=s;const p=null!==(o=l.style.opacity)&&void 0!==o?o:1;for(let v=0;l.path.length-1>v;v++)t.globalAlpha=.5*(y[v]+y[v+1])*p,t.beginPath(),t.moveTo(l.path[v][0],l.path[v][1]),t.lineTo(l.path[v+1][0],l.path[v+1][1]),t.stroke()}else if(f){let m=null,x=null,b=null,k=null,w=!1;function E(e,n,i){t.beginPath(),t.strokeStyle=e,t.moveTo(n,i),w=!0}function A(){w&&(t.stroke(),w=!1)}for(let M=0;l.path.length>M;M++){const[P,S]=l.path[M],_=h[M],L=Pe(_,u,s);if(null!==m&&null!==k&&null!==b){if(L===k)t.lineTo(P,S);else{const D=[];for(const T of u){const W=T.value;(b>W||W>_)&&(W>b||_>W)||b===W||_===W||D.push({t:(W-b)/(_-b)})}D.sort((t,e)=>t.t-e.t);for(const $ of D){const C=m+(P-m)*$.t,O=x+(S-x)*$.t,N=Pe(b+(_-b)*Math.min($.t+1e-4,1),u,s);t.lineTo(C,O),A(),E(N,C,O)}t.lineTo(P,S)}m=P,x=S,b=_,k=L}else E(L,P,S),m=P,x=S,b=_,k=L}A()}else{if(t.beginPath(),t.strokeStyle=s,d)U().x(t=>t[0]).y(t=>t[1]).curve(d).context(t)(l.path);else{const[z,I]=l.path[0];t.moveTo(z,I);for(let B=1;l.path.length>B;B++)t.lineTo(l.path[B][0],l.path[B][1])}t.stroke()}if(l.style.fill&&l.style.fillOpacity&&l.style.fillOpacity>0){if(t.beginPath(),t.globalAlpha=l.style.fillOpacity,t.fillStyle=l.style.fill,d&&!f)U().x(t=>t[0]).y(t=>t[1]).curve(d).context(t)(l.path);else{const[R,F]=l.path[0];t.moveTo(R,F);for(let Y=1;l.path.length>Y;Y++)t.lineTo(l.path[Y][0],l.path[Y][1])}const j=l.path[0][0];t.lineTo(l.path[l.path.length-1][0],i.height),t.lineTo(j,i.height),t.closePath(),t.fill()}t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt"}}],area:[Oe],stackedarea:[Oe],scatter:[Ne],bubble:[Ne],heatmap:[(t,e,n,i)=>{const r=e.filter(t=>"heatcell"===t.type);t.save();try{for(const e of r){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),Le(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):je(e.value),i=Math.max(10,Math.min(16,.3*Math.min(e.w,e.h))),r=e.x+e.w/2,o=e.y+e.h/2;t.fillStyle=Be(e.fill),t.font=i+"px sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText(n,r,o)}}}finally{t.restore()}}],bar:[ze],swarm:[Ne],waterfall:[(t,e,n,i)=>{var r,o,a;ze(t,e);const l=e.filter(t=>"rect"===t.type);if(2>l.length)return;const s=l[0].datum,c=null==s?void 0:s._connectorStroke;if(c){t.save(),t.strokeStyle=c,t.lineWidth=null!==(r=null==s?void 0:s._connectorWidth)&&void 0!==r?r:1,t.setLineDash([]);for(let e=0;l.length-1>e;e++){const i=l[e],r=l[e+1];if(!(null===(o=i.datum)||void 0===o?void 0:o.cumEnd)||!(null===(a=r.datum)||void 0===a?void 0:a.baseline))continue;const s=n.y(i.datum.cumEnd),c=i.x+i.w,u=r.x;t.beginPath(),t.moveTo(c,s),t.lineTo(u,s),t.stroke()}t.restore()}}],candlestick:[(t,e,n,i)=>{for(const n of e){if("candlestick"!==n.type)continue;const e=n;t.save();const i=e._decayOpacity;null!=i&&1!==i&&(t.globalAlpha=i),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 r=Math.min(e.openY,e.closeY),o=Math.abs(e.openY-e.closeY),a=e.isUp?e.upColor:e.downColor;t.fillStyle=a,t.fillRect(e.x-e.bodyWidth/2,r,e.bodyWidth,Math.max(o,1)),t.strokeStyle=a,t.lineWidth=1,t.strokeRect(e.x-e.bodyWidth/2,r,e.bodyWidth,Math.max(o,1)),t.restore()}}]},Fe={top:20,right:20,bottom:30,left:40},Ye={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"},He={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 Xe({hover:e}){const n=t=>Number.isInteger(t)?t+"":t.toFixed(2);return t.createElement("div",{className:"semiotic-tooltip",style:He},t.createElement("div",{style:{fontWeight:600,marginBottom:2}},n(e.value)),t.createElement("div",{style:{opacity:.7,fontSize:11}},n(e.time)))}function Ge({width:n,height:r,totalWidth:o,totalHeight:a,margin:l,dimension:s,scales:c,onBrush:u}){const h=e(null),p=e(null),v=e(u);v.current=u;const m=e(c);return m.current=c,i(()=>{if(!h.current)return;const t=g(h.current).select(".brush-g"),e="x"===s?d():"y"===s?f():y();return e.extent([[0,0],[n,r]]),e.on("brush end",t=>{const e=m.current;if(!e)return;if(!t.selection)return void v.current(null);let i,o;if("x"===s){const[n,a]=t.selection;i=[e.x.invert(n),e.x.invert(a)],o=[e.y.invert(r),e.y.invert(0)]}else if("y"===s){const[r,a]=t.selection;i=[e.x.invert(0),e.x.invert(n)],o=[e.y.invert(a),e.y.invert(r)]}else{const[[n,r],[a,l]]=t.selection;i=[e.x.invert(n),e.x.invert(a)],o=[e.y.invert(l),e.y.invert(r)]}v.current({x:i,y:o})}),t.call(e),p.current=e,t.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{e.on("brush end",null),p.current=null}},[n,r,s]),t.createElement("svg",{ref:h,width:o,height:a,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},t.createElement("g",{className:"brush-g",transform:`translate(${l.left},${l.top})`}))}const Ve=c(function(o,a){var s,c,h,d,f,y,g,p,v;const{chartType:m,runtimeMode:x,data:b,chunkThreshold:k,chunkSize:w,xAccessor:E,yAccessor:A,colorAccessor:M,sizeAccessor:P,groupAccessor:S,lineDataAccessor:_,curve:L,normalize:D,binSize:T,valueAccessor:W,arrowOfTime:$="right",windowMode:C="sliding",windowSize:O=200,timeAccessor:N,xExtent:z,yExtent:I,extentPadding:B=.1,sizeRange:j,size:R=[500,300],responsiveWidth:F,responsiveHeight:Y,margin:H,className:X,background:G,lineStyle:V,pointStyle:q,areaStyle:K,waterfallStyle:Z,swarmStyle:U,barColors:Q,colorScheme:J,boundsAccessor:tt,boundsStyle:et,y0Accessor:nt,gradientFill:it,openAccessor:rt,highAccessor:ot,lowAccessor:at,closeAccessor:lt,candlestickStyle:st,showAxes:ct=!0,axes:ht,xLabel:dt,yLabel:ft,xFormat:yt,yFormat:gt,tickFormatTime:pt,tickFormatValue:vt,hoverAnnotation:mt,tooltipContent:xt,customHoverBehavior:bt,enableHover:kt,annotations:wt,svgAnnotationRules:Et,showGrid:At,legend:Mt,legendHoverBehavior:Pt,legendClickBehavior:_t,legendHighlightedCategory:Lt,legendIsolatedCategories:Wt,legendPosition:zt,backgroundGraphics:Rt,foregroundGraphics:Ft,canvasPreRenderers:Yt,title:Ht,categoryAccessor:Xt,brush:Gt,onBrush:Vt,decay:qt,pulse:Kt,transition:Zt,staleness:Ut,heatmapAggregation:Qt,heatmapXBins:Jt,heatmapYBins:te,showValues:ee,heatmapValueFormat:ne,marginalGraphics:ie,pointIdAccessor:re,xScaleType:oe,yScaleType:le,accessibleTable:se}=o,[he,fe]=Bt(R,F,Y),ge=Object.assign(Object.assign({},Fe),H);if(ie){const t=60;ie.top&&t>ge.top&&(ge.top=t),ie.bottom&&t>ge.bottom&&(ge.bottom=t),ie.left&&t>ge.left&&(ge.left=t),ie.right&&t>ge.right&&(ge.right=t)}const ve=fe[0]-ge.left-ge.right,me=fe[1]-ge.top-ge.bottom,xe="function"==typeof Ft?Ft({size:fe,margin:ge}):Ft,be="function"==typeof Rt?Rt({size:fe,margin:ge}):Rt,ke=null!=mt?mt:kt,Me=e(null),Pe=e(null),Se=e(0),_e=e(!1),Le=we(t=>t.theme),[De,Te]=n(0),[We,$e]=n(null),Ce=e(null),Oe=e(null),[Ne,ze]=n(null),[Ie,Be]=n(!1),[je,He]=n([]),[Ve,qe]=n([]),Ke=e(()=>{}),Ze="streaming"===x||["bar","swarm","waterfall"].includes(m),Ue=r(()=>({chartType:m,runtimeMode:Ze?"streaming":"bounded",windowSize:O,windowMode:C,arrowOfTime:Ze?$:"right",extentPadding:B,xAccessor:Ze?void 0:E,yAccessor:Ze?void 0:A,timeAccessor:Ze?N:void 0,valueAccessor:W,colorAccessor:M,sizeAccessor:P,groupAccessor:S,categoryAccessor:Xt,lineDataAccessor:_,xScaleType:oe,yScaleType:le,xExtent:z,yExtent:I,sizeRange:j,binSize:T,normalize:D,boundsAccessor:tt,boundsStyle:et,y0Accessor:nt,gradientFill:"boolean"==typeof it?it?{topOpacity:.8,bottomOpacity:.05}:void 0:it,openAccessor:rt,highAccessor:ot,lowAccessor:at,closeAccessor:lt,candlestickStyle:st,lineStyle:V,pointStyle:q,areaStyle:K,swarmStyle:U,waterfallStyle:Z,colorScheme:J,barColors:Q,annotations:wt,decay:qt,pulse:Kt,transition:Zt,staleness:Ut,heatmapAggregation:Qt,heatmapXBins:Jt,heatmapYBins:te,showValues:ee,heatmapValueFormat:ne,pointIdAccessor:re,curve:L}),[m,O,C,$,B,E,A,N,W,oe,le,M,P,S,Xt,_,z,I,j,T,D,tt,et,nt,it,rt,ot,at,lt,st,V,q,K,U,Z,J,Q,wt,qt,Kt,Zt,Ut,Qt,Jt,te,ee,ne,Ze,re,L]),Qe=e(null);Qe.current||(Qe.current=new St(Ue));const Je=l(()=>{Se.current||(Se.current=requestAnimationFrame(()=>Ke.current()))},[]);i(()=>{var t;null===(t=Qe.current)||void 0===t||t.updateConfig(Ue),_e.current=!0,Je()},[Ue,Je]),i(()=>{_e.current=!0,Je()},[Le,Je]);const tn=e(null);tn.current||(tn.current=new ut(t=>{const e=Qe.current;e&&e.ingest(t)&&(_e.current=!0,Je())},{chunkThreshold:k,chunkSize:w})),i(()=>{var t;null===(t=tn.current)||void 0===t||t.updateChunkOptions({chunkThreshold:k,chunkSize:w})},[k,w]);const en=l(t=>{var e;null===(e=tn.current)||void 0===e||e.push(t)},[]),nn=l(t=>{var e;null===(e=tn.current)||void 0===e||e.pushMany(t)},[]),rn=l(()=>{var t,e;null===(t=tn.current)||void 0===t||t.clear(),null===(e=Qe.current)||void 0===e||e.clear(),_e.current=!0,Je()},[Je]);u(a,()=>({push:en,pushMany:nn,clear:rn,getData:()=>{var t,e,n;return null===(t=tn.current)||void 0===t||t.flush(),null!==(n=null===(e=Qe.current)||void 0===e?void 0:e.getData())&&void 0!==n?n:[]},getScales:()=>{var t,e;return null!==(e=null===(t=Qe.current)||void 0===t?void 0:t.scales)&&void 0!==e?e:null},getExtents:()=>{var t,e;return null!==(e=null===(t=Qe.current)||void 0===t?void 0:t.getExtents())&&void 0!==e?e:null}}),[en,nn,rn]),i(()=>{var t;b&&(null===(t=tn.current)||void 0===t||t.setBoundedData(b))},[b]);const on=e(()=>{}),an=e(()=>{});on.current=t=>{if(!ke)return;const e=Me.current;if(!e)return;const n=e.getBoundingClientRect(),i=t.clientX-n.left-ge.left,r=t.clientY-n.top-ge.top;if(0>i||i>ve||0>r||r>me)return void(Ce.current&&(Ce.current=null,Oe.current=null,ze(null),bt&&(bt(null),_e.current=!0),Je()));const o=Qe.current;if(!o||0===o.scene.length)return;const a=function(t,e,n,i=30,r){let o=null,a=!1;if(r){const t=r.find(e,n,i);if(t){const r=Dt(t,e,n);r&&i>r.distance&&(o=r,a=!0)}}for(const l of t){let t=null;switch(l.type){case"point":if(r&&a)break;t=Dt(l,e,n);break;case"line":t=Tt(l,e,n);break;case"rect":t=$t(l,e,n);break;case"heatcell":t=Ct(l,e,n);break;case"area":if(!1===l.interactive)break;t=Nt(l,e,n);break;case"candlestick":t=Ot(l,e,n)}t&&i>t.distance&&(o&&t.distance>=o.distance||(o=t))}return o}(o.scene,i,r,30,o.quadtree);if(!a)return void(Ce.current&&(Ce.current=null,Oe.current=null,ze(null),bt&&bt(null),Je()));const l=a.datum||{},s=Object.assign(Object.assign({},"object"!=typeof l||null===l||Array.isArray(l)?{}:l),{data:l,time:a.x,value:a.y,x:a.x,y:a.y});Ce.current=s,Oe.current=a.node,ze(s),bt&&(bt(s),_e.current=!0),Je()},an.current=()=>{Ce.current&&(Ce.current=null,Oe.current=null,ze(null),bt&&(bt(null),_e.current=!0),Je())},l(t=>on.current(t),[]);const ln=l(()=>an.current(),[]),sn=e(-1),cn=l(t=>{const e=Qe.current;if(!e||0===e.scene.length)return;const n=function(t){const e=[];for(const n of t)switch(n.type){case"point":e.push({x:n.x,y:n.y,datum:n.datum});break;case"line":{const t=n,i=Array.isArray(t.datum)?t.datum:[];for(let n=0;t.path.length>n&&i.length>n;n++)e.push({x:t.path[n][0],y:t.path[n][1],datum:i[n]});break}case"area":{const t=n,i=Array.isArray(t.datum)?t.datum:[];for(let n=0;t.topPath.length>n&&i.length>n;n++)e.push({x:t.topPath[n][0],y:t.topPath[n][1],datum:i[n]});break}case"rect":case"heatcell":e.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum})}return e.sort((t,e)=>t.x-e.x||t.y-e.y),e}(e.scene);if(0===n.length)return;const i=0>sn.current?-1:sn.current,r=It(t.key,0>i?-1:i,n.length);if(null===r)return;if(t.preventDefault(),0>r)return sn.current=-1,Ce.current=null,Oe.current=null,ze(null),bt&&bt(null),void Je();const o=0>i?0:r;sn.current=o;const a=function(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})}(n[o]);Ce.current=a,ze(a),bt&&bt(a),Je()},[bt,Je]),un=l(t=>{sn.current=-1,on.current(t)},[]);Ke.current=()=>{var t,e;Se.current=0;const n=Me.current,i=Pe.current;if(!n||!i)return;const r=Qe.current;if(!r)return;const o="undefined"!=typeof performance?performance.now():Date.now(),a=r.advanceTransition(o),l=_e.current||a;l&&!a&&r.computeScene({width:ve,height:me});const s=Ae(),c=function(t){if(!t)return Ye;const e=getComputedStyle(t),n=e.getPropertyValue("--semiotic-border").trim(),i=e.getPropertyValue("--semiotic-text-secondary").trim(),r=e.getPropertyValue("--semiotic-bg").trim(),o=i||e.getPropertyValue("--text-secondary").trim(),a=e.getPropertyValue("--text-primary").trim(),l=n||e.getPropertyValue("--surface-3").trim(),s=r||e.getPropertyValue("--surface-0").trim();return o||a||n?{axisStroke:l||Ye.axisStroke,tickText:o||Ye.tickText,crosshair:o?o+"66":Ye.crosshair,hoverFill:s?s+"4D":Ye.hoverFill,hoverStroke:o?o+"99":Ye.hoverStroke,pointRing:s||Ye.pointRing}:Ye}(n),u=null!==(t=null==Ut?void 0:Ut.threshold)&&void 0!==t?t:5e3,h=Ut&&r.lastIngestTime>0&&o-r.lastIngestTime>u;if(l){const t=Ee(n,fe,ge,s);if(t){t.clearRect(-ge.left,-ge.top,fe[0],fe[1]),h&&(t.globalAlpha=null!==(e=null==Ut?void 0:Ut.dimOpacity)&&void 0!==e?e:.5);const i=getComputedStyle(n).getPropertyValue("--semiotic-bg").trim(),o=G||(i&&"transparent"!==i?i:null);if(o&&(t.fillStyle=o,t.fillRect(-ge.left,-ge.top,fe[0],fe[1])),t.save(),"function"==typeof t.rect&&(t.beginPath(),t.rect(0,0,ve,me),t.clip()),Yt&&r.scales)for(const e of Yt)t.save(),e(t,r.scene,r.scales,{width:ve,height:me}),t.restore();const a=Re[m];if(a&&r.scales)for(const e of a)e(t,r.scene,r.scales,{width:ve,height:me});t.restore(),h&&(t.globalAlpha=1)}}{const t=Ee(i,fe,ge,s);if(t&&(t.clearRect(-ge.left,-ge.top,fe[0],fe[1]),ke&&Ce.current&&r.scales&&function(t,e,n,i,r,o,a){if(!1===r.crosshair)return;t.save();const l="object"==typeof r.crosshair?r.crosshair:{};t.strokeStyle=l.stroke||a.crosshair,t.lineWidth=l.strokeWidth||1,t.setLineDash(l.strokeDasharray?l.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),t.beginPath(),t.moveTo(e.x,0),t.lineTo(e.x,i),t.stroke(),t.beginPath(),t.moveTo(0,e.y),t.lineTo(n,e.y),t.stroke(),t.restore(),t.beginPath(),t.arc(e.x,e.y,4,0,2*Math.PI),t.fillStyle="#007bff",t.fill(),t.strokeStyle=a.pointRing,t.lineWidth=2,t.stroke()}(t,Ce.current,ve,me,"object"==typeof ke?ke:{},0,c),Oe.current&&Array.isArray(mt))){const e=mt.find(t=>t&&"object"==typeof t&&"highlight"===t.type);e&&function(t,e,n,i){var r;if(!n)return;const o=n.group;if(void 0!==o)for(const n of e){if("line"!==n.type)continue;if(n.group!==o)continue;if(2>n.path.length)continue;const e="function"==typeof i.style?i.style(n.datum):i.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!==(r=e.opacity)&&void 0!==r?r:1,t.stroke(),t.restore()}}(t,r.scene,Oe.current,e)}}l&&n&&n.setAttribute("aria-label",de(r.scene,m+" chart"));const d=_e.current;if(_e.current=!1,d&&r.scales&&((!We||We.x.domain()[0]!==r.scales.x.domain()[0]||We.x.domain()[1]!==r.scales.x.domain()[1]||We.y.domain()[0]!==r.scales.y.domain()[0]||We.y.domain()[1]!==r.scales.y.domain()[1]||We.x.range()[0]!==r.scales.x.range()[0]||We.x.range()[1]!==r.scales.x.range()[1]||We.y.range()[0]!==r.scales.y.range()[0]||We.y.range()[1]!==r.scales.y.range()[1])&&$e(r.scales),ie)){const t=r.getData(),e="function"==typeof E?E:t=>t[E||"x"],n="function"==typeof A?A:t=>t[A||"y"];He(t.map(t=>e(t)).filter(t=>"number"==typeof t&&isFinite(t))),qe(t.map(t=>n(t)).filter(t=>"number"==typeof t&&isFinite(t)))}d&&wt&&wt.length>0&&Te(t=>t+1),(null==Ut?void 0:Ut.showBadge)&&Be(!!h),(a||r.hasActivePulses)&&(Se.current=requestAnimationFrame(()=>Ke.current()))},i(()=>(Je(),()=>{Se.current&&(cancelAnimationFrame(Se.current),Se.current=0)}),[Je]),i(()=>{_e.current=!0,Je()},[m,ve,me,ct,G,V,Yt,Je]),jt(Ut,Qe,_e,Je,Ie,Be);const hn=ke&&Ne?xt?xt(Ne):t.createElement(Xe,{hover:Ne}):null,dn=hn?t.createElement("div",{className:"stream-frame-tooltip",style:{position:"absolute",left:ge.left+Ne.x,top:ge.top+Ne.y,transform:`translate(${Ne.x>.7*ve?"calc(-100% - 12px)":"12px"}, ${.3*me>Ne.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:1,width:"max-content"}},hn):null,fn=sn.current>=0&&Ne?t.createElement("svg",{style:{position:"absolute",left:0,top:0,width:fe[0],height:fe[1],pointerEvents:"none",zIndex:2}},t.createElement("circle",{cx:Ne.x+ge.left,cy:Ne.y+ge.top,r:8,fill:"none",stroke:"var(--accent, #6366f1)",strokeWidth:2,strokeDasharray:"4,2"})):null;if(ue){const e=Qe.current;e&&b&&(e.ingest({inserts:b,bounded:!0}),e.computeScene({width:ve,height:me}));const n=null!==(s=null==e?void 0:e.scene)&&void 0!==s?s:[],i=null!==(c=null==e?void 0:e.scales)&&void 0!==c?c:null;return t.createElement("div",{className:"stream-xy-frame"+(X?" "+X:""),role:"img","aria-label":"string"==typeof Ht?Ht:"XY chart",style:{position:"relative",width:fe[0],height:fe[1]}},t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:fe[0],height:fe[1],style:{position:"absolute",left:0,top:0}},be,t.createElement("g",{transform:`translate(${ge.left},${ge.top})`},G&&t.createElement("rect",{x:0,y:0,width:ve,height:me,fill:G}),n.map((e,n)=>function(e,n){var i,r,o;switch(e.type){case"line":{const i=e;if(0===i.path.length)return null;const r="M"+i.path.map(([t,e])=>`${t},${e}`).join("L");return t.createElement("path",{key:"line-"+n,d:r,fill:"none",stroke:i.style.stroke||"#4e79a7",strokeWidth:i.style.strokeWidth||2,strokeDasharray:i.style.strokeDasharray,opacity:i.style.opacity})}case"area":{const o=e;if(0===o.topPath.length)return null;const a=o.topPath.map(([t,e])=>`${t},${e}`).join("L"),l=[...o.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L");return t.createElement("path",{key:"area-"+n,d:`M${a}L${l}Z`,fill:o.style.fill||"#4e79a7",fillOpacity:null!==(r=null!==(i=o.style.fillOpacity)&&void 0!==i?i:o.style.opacity)&&void 0!==r?r:.7,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})}case"point":return t.createElement("circle",{key:"point-"+n,cx:e.x,cy:e.y,r:e.r,fill:e.style.fill||"#4e79a7",opacity:null!==(o=e.style.opacity)&&void 0!==o?o:.8,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth});case"rect":return t.createElement("rect",{key:"rect-"+n,x:e.x,y:e.y,width:e.w,height:e.h,fill:e.style.fill||"#4e79a7",opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth});case"heatcell":{const i=e;if(i.showValues&&null!=i.value&&i.w>=20&&i.h>=20){const e=i.valueFormat?i.valueFormat(i.value):Number.isInteger(i.value)?i.value+"":100>Math.abs(i.value)?1>Math.abs(i.value)?i.value.toPrecision(3):i.value.toFixed(1):i.value.toFixed(0),[r,o,a]=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]}(i.fill),l=.299*r+.587*o+.114*a>128?"#000":"#fff",s=Math.max(10,Math.min(16,.3*Math.min(i.w,i.h)));return t.createElement("g",{key:"heatcell-"+n},t.createElement("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:i.fill}),t.createElement("text",{x:i.x+i.w/2,y:i.y+i.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:l,fontSize:s+"px"},e))}return t.createElement("rect",{key:"heatcell-"+n,x:i.x,y:i.y,width:i.w,height:i.h,fill:i.fill})}case"candlestick":{const i=e,r=Math.min(i.openY,i.closeY),o=Math.max(Math.abs(i.openY-i.closeY),1),a=i.isUp?i.upColor:i.downColor;return t.createElement("g",{key:"candle-"+n},t.createElement("line",{x1:i.x,y1:i.highY,x2:i.x,y2:i.lowY,stroke:i.wickColor,strokeWidth:i.wickWidth}),t.createElement("rect",{x:i.x-i.bodyWidth/2,y:r,width:i.bodyWidth,height:o,fill:a,stroke:a,strokeWidth:1}))}default:return null}}(e,n)).filter(Boolean))),t.createElement(ce,{width:ve,height:me,totalWidth:fe[0],totalHeight:fe[1],margin:ge,scales:i,showAxes:ct,axes:ht,xLabel:dt,yLabel:ft,xFormat:yt||pt,yFormat:gt||vt,showGrid:At,title:Ht,legend:Mt,legendHoverBehavior:Pt,legendClickBehavior:_t,legendHighlightedCategory:Lt,legendIsolatedCategories:Wt,legendPosition:zt,foregroundGraphics:xe,marginalGraphics:ie,xValues:[],yValues:[],annotations:wt,svgAnnotationRules:Et,annotationFrame:0,xAccessor:"string"==typeof E?E:"string"==typeof N?N:void 0,yAccessor:"string"==typeof A?A:"string"==typeof W?W:void 0,annotationData: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}))}return t.createElement("div",{ref:he,className:"stream-xy-frame"+(X?" "+X:""),role:"img","aria-label":"string"==typeof Ht?Ht:"XY chart",tabIndex:0,style:{position:"relative",width:F?"100%":fe[0],height:Y?"100%":fe[1],overflow:"visible"},onMouseMove:ke?un:void 0,onMouseLeave:ke?ln:void 0,onKeyDown:cn},be&&t.createElement("svg",{style:{position:"absolute",left:0,top:0,width:fe[0],height:fe[1],pointerEvents:"none"}},be),t.createElement(ae,{width:ve,height:me,totalWidth:fe[0],totalHeight:fe[1],margin:ge,scales:We,showAxes:ct,axes:ht,showGrid:At,xFormat:yt||pt,yFormat:gt||vt}),t.createElement("canvas",{ref:Me,"aria-label":de(null!==(d=null===(h=Qe.current)||void 0===h?void 0:h.scene)&&void 0!==d?d:[],m+" chart"),style:{position:"absolute",left:0,top:0}}),t.createElement("canvas",{ref:Pe,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),t.createElement(pe,{hoverPoint:Ne}),se&&t.createElement(ye,{scene:null!==(y=null===(f=Qe.current)||void 0===f?void 0:f.scene)&&void 0!==y?y:[],chartType:m+" chart"}),t.createElement(ce,{width:ve,height:me,totalWidth:fe[0],totalHeight:fe[1],margin:ge,scales:We,showAxes:ct,axes:ht,xLabel:dt,yLabel:ft,xFormat:yt||pt,yFormat:gt||vt,showGrid:At,title:Ht,legend:Mt,legendHoverBehavior:Pt,legendClickBehavior:_t,legendHighlightedCategory:Lt,legendIsolatedCategories:Wt,legendPosition:zt,foregroundGraphics:xe,marginalGraphics:ie,xValues:je,yValues:Ve,annotations:wt,svgAnnotationRules:Et,annotationFrame:De,xAccessor:"string"==typeof E?E:"string"==typeof N?N:void 0,yAccessor:"string"==typeof A?A:"string"==typeof W?W:void 0,annotationData:null===(g=Qe.current)||void 0===g?void 0:g.getData(),pointNodes:null===(p=Qe.current)||void 0===p?void 0:p.scene.filter(t=>"point"===t.type),curve:"string"==typeof L?L:void 0,underlayRendered:!0}),(Gt||Vt)&&t.createElement(Ge,{width:ve,height:me,totalWidth:fe[0],totalHeight:fe[1],margin:ge,dimension:null!==(v=null==Gt?void 0:Gt.dimension)&&void 0!==v?v:"xy",scales:We,onBrush:null!=Vt?Vt:()=>{}}),(null==Ut?void 0:Ut.showBadge)&&t.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===Ut.badgePosition?{top:4,left:4}:"bottom-left"===Ut.badgePosition?{bottom:4,left:4}:"bottom-right"===Ut.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:Ie?"#dc3545":"#28a745",color:"white"})},Ie?"STALE":"LIVE"),fn,dn)});Ve.displayName="StreamXYFrame";const qe={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},Ke={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class Ze{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,i){var r;for(let o=0;this.capacity>o;o++){const a=this.particles[o];if(!a.active)continue;const l=n[a.edgeIndex];if(!l||!l.bezier){a.active=!1;continue}const s=i&&null!==(r=i[a.edgeIndex])&&void 0!==r?r:1;if(a.t+=t*e*s*(l.bezier.circular?.3:1),a.t>=1){a.active=!1;continue}const c=Ue(l.bezier,a.t,a.offset);a.x=c.x,a.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 Ue(t,e,n){if(t.circular&&t.segments)return function(t,e,n,i){const r=t.length,o=e*r,a=Math.min(Math.floor(o),r-1),l=o-a,[s,c,u,h]=t[a],d=Qe(s,c,u,h,l),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*i*2,d.y+=t*n*i*2}return d}(t.segments,e,n,t.halfWidth);if(!t.points)return{x:0,y:0};const[i,r,o,a]=t.points,l=Qe(i,r,o,a,e),s=a.x-i.x,c=a.y-i.y,u=Math.sqrt(s*s+c*c);if(u>.001){const e=s/u;l.x+=-c/u*n*t.halfWidth*2,l.y+=e*n*t.halfWidth*2}return l}function Qe(t,e,n,i,r){const o=1-r,a=o*o,l=a*o,s=r*r,c=s*r;return{x:l*t.x+3*a*r*e.x+3*o*s*n.x+c*i.x,y:l*t.y+3*a*r*e.y+3*o*s*n.y+c*i.y}}function Je(t,e){var n=t.get(e);if(!n)throw Error("missing: "+e);return n}function tn(t,e){var n,i=[],r=[],o=[],a={},l=[];function s(t){o[t]=!1,a.hasOwnProperty(t)&&Object.keys(a[t]).forEach(function(e){delete a[t][e],o[e]&&s(e)})}function c(t){var e,i,h=!1;for(r.push(t),o[t]=!0,e=0;l[t].length>e;e++)(i=l[t][e])===n?(u(n,r),h=!0):o[i]||(h=c(i));if(h)s(t);else for(e=0;l[t].length>e;e++){var d=a[i=l[t][e]];d||(a[i]=d={}),d[i]=!0}return r.pop(),h}function u(t,e){var n=[].concat(e).concat(t);i.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,i=function(t){for(var e=t.length,n=Array(e),i=Array(e),r=Array(e),o=Array(e),a=Array(e),l=Array(e),s=0;e>s;++s)n[s]=-1,i[s]=0,r[s]=!1,o[s]=0,a[s]=-1,l[s]=[];var c,u=0,h=[],d=[];function f(e){var s=[e],c=[e];for(n[e]=i[e]=u,r[e]=!0,u+=1;c.length>0;){var f=t[e=c[c.length-1]];if(f.length>o[e]){for(var y=o[e];f.length>y;++y){var g=f[y];if(0>n[g]){n[g]=i[g]=u,r[g]=!0,u+=1,s.push(g),c.push(g);break}r[g]&&(i[e]=0|Math.min(i[e],i[g])),0>a[g]||l[e].push(a[g])}o[e]=y}else{if(i[e]===n[e]){var p=[],v=[],m=0;for(y=s.length-1;y>=0;--y){var x=s[y];if(r[x]=!1,p.push(x),v.push(l[x]),m+=l[x].length,a[x]=h.length,x===e){s.length=y;break}}h.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];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),r=i.components.filter(function(t){return t.length>1}),o=1/0,a=0;r.length>a;a++)for(var l=0;r[a].length>l;l++)o>r[a][l]&&(o=r[a][l],n=a);var s=r[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:o,adjList:c}}n=0;for(var d=t.length;d>n;){var f=h(n);if(n=f.leastVertex,l=f.adjList){for(var y=0;l.length>y;y++)for(var g=0;l[y].length>g;g++){var p=l[y][g];o[+p]=!1,a[p]={}}c(n),n+=1}else n=d}return i}function en(t){return t.y0-t.y1>0?"up":"down"}function nn(t,e){return e(t.source)==e(t.target)}function rn(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 on(t){return t.target.x0-t.source.x1}function an(t,e){var n=sn(t),i=on(e)/Math.tan(n);return"up"==en(t)?t.y1-i:t.y1+i}function ln(t,e){var n=sn(t),i=on(e)/Math.tan(n);return"up"==en(t)?t.y1+i:t.y1-i}function sn(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function cn(t,e){return e(t)}function un(t){return dn(t.source)}function hn(t){return dn(t.target)}function dn(t){return(t.y0+t.y1)/2}function fn(t){return t.virtual?0:t.value}function yn(t,e){var n=0;t.sourceLinks.forEach(function(t){n=t.circular&&!nn(t,e)?n+1:n});var i=0;return t.targetLinks.forEach(function(t){i=t.circular&&!nn(t,e)?i+1:i}),n+i}function gn(t){return t.target.depth}function pn(t,e){return t.sourceLinks.length?t.depth:e-1}function vn(t,e){return t.y0-e.y0}function mn(t,e){return e.y0-t.y0}function xn(t,e){return t.y1-e.y1}function bn(t,e){return e.y1-t.y1}function kn(t,e){return En(t.source,e.source)||t.index-e.index}function wn(t,e){return En(t.target,e.target)||t.index-e.index}function En(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function An(t,e){return Mn(t)==Mn(e)?"bottom"==t.circularLinkType?mn(t,e):vn(t,e):Mn(e)-Mn(t)}function Mn(t){return t.target.column-t.source.column}function Pn(t,e){return Sn(t)==Sn(e)}function Sn(t){return t.y0-t.y1>0?"up":"down"}function _n(t,e,n,i,r){let o=t;var a=Math.max(8,.15*(o.y1-o.y0));o.links.forEach(function(t){t.circular&&(t._circularWidth=Math.min(t.width,a))});var l=P(o.links,function(t){return t.source.y0});o.links.forEach(function(t){t.circular&&(t.circularPathData={})});var s=o.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}),Ln(o.links.filter(function(t){return"top"==t.circularLinkType}),e,n),Ln(o.links.filter(function(t){return"bottom"==t.circularLinkType}),e,n),o.links.forEach(function(t){if(t.circular){if(t.circularPathData.arcRadius=t._circularWidth+i,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,nn(t,e)&&rn(t))t.circularPathData.rightSmallArcRadius=i+t._circularWidth/2,t.circularPathData.rightLargeArcRadius=i+t._circularWidth/2,t.circularPathData.leftSmallArcRadius=i+t._circularWidth/2,t.circularPathData.leftLargeArcRadius=i+t._circularWidth/2,"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=t.source.y1+r+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-r-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius);else{var a=t.source.column,s=t.circularLinkType,c=o.links.filter(function(t){return t.source.column==a&&t.circularLinkType==s});c.sort("bottom"==t.circularLinkType?mn:vn);var u=0;c.forEach(function(e,r){e.circularLinkID==t.circularLinkID&&(t.circularPathData.rightSmallArcRadius=i+t._circularWidth/2+u,t.circularPathData.rightLargeArcRadius=i+t._circularWidth/2+r*n+u),u+=e._circularWidth||e.width}),a=t.target.column,(c=o.links.filter(function(t){return t.target.column==a&&t.circularLinkType==s})).sort("bottom"==t.circularLinkType?bn:xn),u=0,c.forEach(function(e,r){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=i+t._circularWidth/2+u,t.circularPathData.leftLargeArcRadius=i+t._circularWidth/2+r*n+u),u+=e._circularWidth||e.width}),"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=Math.max(o.y1,t.source.y1,t.target.y1)+r+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=l-r-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,i=t.target.x0,r=t.y1,o=(e+i)/2;return"M"+e+","+n+"C"+o+","+n+" "+o+","+r+" "+i+","+r}(t)}),o}function Ln(t,e,n){t.sort(An);var i=t.filter(function(t){return!t._circularStub});return t.forEach(function(t,r){var o=0;if(t._circularStub)t.circularPathData.verticalBuffer=0;else if(nn(t,e)&&rn(t))t.circularPathData.verticalBuffer=o+t._circularWidth/2;else{for(var a=0;i.length>a;a++){var l=i[a];if(l!==t&&l.circularPathData&&void 0!==l.circularPathData.verticalBuffer&&Dn(t,l)){var s=l.circularPathData.verticalBuffer+(l._circularWidth||l.width)/2+n;o=s>o?s:o}}t.circularPathData.verticalBuffer=o+t._circularWidth/2}}),t}function Dn(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}function Tn(t){return function(){return t}}function Wn(t){return t.index}function $n(t){return t.nodes}function Cn(t){return t.links}function On(t,e,n){var i=S(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});i.forEach(function(r,o){var a=r.length;if(e)r.sort(e);else if(o>0){var l=new Map;r.forEach(function(t,e){var n,i,r,o=(i=0,r=0,(n=t).targetLinks.forEach(function(t){if(!t.circular){var e=t.value||1;r+=dn(t.source)*e,i+=e}}),n.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;r+=dn(t.target)*e,i+=e}}),i>0?r/i:NaN);l.set(t,{bc:o,idx:e})}),r.sort(function(t,e){var n=l.get(t),i=l.get(e),r=n.bc,o=i.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(r)||isNaN(o)?isNaN(r)?isNaN(o)?n.idx-i.idx:1:-1:r-o})}else r.sort(function(t,e){return t.circularLinkType==e.circularLinkType?yn(e,n)-yn(t,n):"top"==t.circularLinkType&&"bottom"==e.circularLinkType||"top"==t.circularLinkType&&0==e.partOfCycle||0==t.partOfCycle&&"bottom"==e.circularLinkType?-1:0});r.forEach(function(e,r){e.depth==i.length-1&&1==a||0==e.depth&&1==a?(e.y0=t.y1/2-e.value*t.ky,e.y1=e.y0+e.value*t.ky):e.partOfCycle?0==yn(e,n)?(e.y0=t.y1/2+r,e.y1=e.y0+e.value*t.ky):"top"==e.circularLinkType?(e.y0=t.y0+r,e.y1=e.y0+e.value*t.ky):(e.y0=t.y1-e.value*t.ky-r,e.y1=e.y0+e.value*t.ky):0==t.y0||0==t.y1?(e.y0=(t.y1-t.y0)/a*r,e.y1=e.y0+e.value*t.ky):(e.y0=(t.y1-t.y0)/2-a/2+r,e.y1=e.y0+e.value*t.ky)})})}function Nn(t,e,n,i,r,o){var a=S(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 l=1,s=o;s>0;--s)c(l*=.99,n),u();function c(e,n){var i=a.length;a.forEach(function(r){var o=r.length,a=r[0].depth;r.forEach(function(r){var l;if(r.sourceLinks.length||r.targetLinks.length)if(r.partOfCycle&&yn(r,n)>0){var s=D(r.sourceLinks,hn),c=D(r.targetLinks,un),u=s&&c?(s+c)/2:s||c;if(u){var h=(u-dn(r))*e*.3;r.y0+=h,r.y1+=h}}else if(0==a&&1==o)r.y0=t.y1/2-(l=r.y1-r.y0)/2,r.y1=t.y1/2+l/2;else if(a==i-1&&1==o)r.y0=t.y1/2-(l=r.y1-r.y0)/2,r.y1=t.y1/2+l/2;else if(1==r.targetLinks.length&&1==r.targetLinks[0].source.sourceLinks.length)l=r.y1-r.y0,r.y0=r.targetLinks[0].source.y0,r.y1=r.y0+l;else{var d=D(r.sourceLinks,hn),f=D(r.targetLinks,un),y=((d&&f?(d+f)/2:d||f)-dn(r))*e;r.y0+=y,r.y1+=y}})})}function u(){a.forEach(function(n){var o,a,l,s=t.y0,c=n.length;for(n.sort(e||En),l=0;c>l;++l)(a=s-(o=n[l]).y0)>0&&(o.y0+=a,o.y1+=a),s=o.y1+i;if((a=s-i-t.y1)>0)for(s=o.y0-=a,o.y1-=a,l=c-2;l>=0;--l)(a=(o=n[l]).y1+r-s)>0&&(o.y0-=a,o.y1-=a),s=o.y0})}}function zn(t){t.nodes.forEach(function(t){t.sourceLinks.sort(wn),t.targetLinks.sort(kn)}),t.nodes.forEach(function(t){var e=t.y0,n=e,i=t.y1,r=i;t.sourceLinks.forEach(function(t){t.circular?(t.y0=i-t.width/2,i-=t.width):(t.y0=e+t.width/2,e+=t.width)}),t.targetLinks.forEach(function(t){t.circular?(t.y1=r-t.width/2,r-=t.width):(t.y1=n+t.width/2,n+=t.width)})})}function In(){var t=0,e=0,n=1,i=1,r=24,o=8,a=null,l=Wn,s=pn,c=void 0,u=32,h=2,d=$n,f=Cn;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=i,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 T(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 i=t.source,r=t.target;"object"!=typeof i&&(i=t.source=Je(n,i)),"object"!=typeof r&&(r=t.target=Je(n,r)),i.sourceLinks.push(t),r.targetLinks.push(t)})}(d,l),function(t,e){var n=0;if(null==e){for(var i=[],r=0;t.links.length>r;r++){var o=t.links[r],a=o.source.index,l=o.target.index;i[a]||(i[a]=[]),i[l]||(i[l]=[]),-1===i[a].indexOf(l)&&i[a].push(l)}var s=tn(i);s.sort(function(t,e){return t.length-e.length});var c={};for(r=0;s.length>r;r++){var u=s[r].slice(-2);c[u[0]]||(c[u[0]]={}),c[u[0]][u[1]]=!0}t.links.forEach(function(t){var e=t.target.index,i=t.source.index;e===i||c[i]&&c[i][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,i=0;t.links.forEach(function(r){r.circular&&(r.circularLinkType=r.source.circularLinkType||r.target.circularLinkType?r.source.circularLinkType?r.source.circularLinkType:r.target.circularLinkType:i>n?"top":"bottom","top"==r.circularLinkType?n++:i++,t.nodes.forEach(function(t){cn(t,e)!=cn(r.source,e)&&cn(t,e)!=cn(r.target,e)||(t.circularLinkType=r.circularLinkType)}))}),t.links.forEach(function(t){t.circular&&(t.source.circularLinkType==t.target.circularLinkType&&(t.circularLinkType=t.source.circularLinkType),nn(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(d,l),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max(L(t.sourceLinks,fn),L(t.targetLinks,fn)),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 i,r,o;if(null!=e){t.nodes.sort(function(t,n){return e(t)<e(n)?-1:1});var a=0,l=e(t.nodes[0]);t.nodes.forEach(function(t){a=e(t)==l?a:a+1,l=e(t)==l?l:e(t),t.column=a})}for(i=t.nodes,r=[],o=0;i.length;++o,i=r,r=[])i.forEach(function(t){t.depth=o,t.sourceLinks.forEach(function(t){0>r.indexOf(t.target)&&!t.circular&&r.push(t.target)})});for(i=t.nodes,r=[],o=0;i.length;++o,i=r,r=[])i.forEach(function(t){t.height=o,t.targetLinks.forEach(function(t){0>r.indexOf(t.source)&&!t.circular&&r.push(t.source)})});t.nodes.forEach(function(t){t.column=null==e?n(t,o):t.column})}(d,c,s);var f=o;if(null!==a){var y=S(d.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,(i-e)*a/(g-1)))}(function(t,e,n){var i=S(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 r=P(i,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/L(e,function(t){return t.value})});t.ky=r,t.links.forEach(function(e){e.width=e.value*t.ky});var o=_(t.nodes,function(t){return t.column});t.nodes.forEach(o>0?function(e){e.x0=t.x0+e.column*((t.x1-t.x0-n)/o),e.x1=e.x0+n}:function(e){e.x0=t.x0,e.x1=e.x0+n})})(d,f,r),On(d,c,l),Nn(d,c,l,f,f,u),zn(d),_n(d,l,h,10,8),On(d,c,l),Nn(d,c,l,f,f,u),zn(d),_n(d,l,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 i=n.links.filter(function(n){return cn(n.source,e)==cn(t,e)}),r=i.length;r>1&&i.sort(function(t,e){if(!t.circular&&!e.circular){if(t.target.column==e.target.column)return t.y1-e.y1;if(!Pn(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var n=an(e,t);return t.y1-n}if(e.target.column>t.target.column)return an(t,e)-e.y1}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.target.column===e.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.target.column===e.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:"top"==t.circularLinkType?-1:1:void 0});var o=t.y0;i.forEach(function(t){t.y0=o+t.width/2,o+=t.width}),i.forEach(function(e,n){if("bottom"==e.circularLinkType){for(var o=n+1,a=0;r>o;o++)a+=i[o].width;e.y0=t.y1-a-e.width/2}})})}(d,l),function(t,e){let n=t;n.nodes.forEach(function(t){var i=n.links.filter(function(n){return cn(n.target,e)==cn(t,e)}),r=i.length;r>1&&i.sort(function(t,e){if(!t.circular&&!e.circular){if(t.source.column==e.source.column)return t.y0-e.y0;if(!Pn(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var n=ln(e,t);return t.y0-n}if(e.source.column>t.source.column)return ln(t,e)-e.y0}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:t.source.column-e.source.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:e.source.column-t.source.column:"top"==t.circularLinkType?-1:1:void 0});var o=t.y0;i.forEach(function(t){t.y1=o+t.width/2,o+=t.width}),i.forEach(function(e,n){if("bottom"==e.circularLinkType){for(var o=n+1,a=0;r>o;o++)a+=i[o].width;e.y1=t.y1-a-e.width/2}})})}(d,l),function(t){var e=t.nodes,n=t.links,i=!1,r=!1;if(n.forEach(function(t){"top"==t.circularLinkType?i=!0:"bottom"==t.circularLinkType&&(r=!0)}),0==i||0==r){var o=P(e,function(t){return t.y0}),a=_(e,function(t){return t.y1}),l=(t.y1-t.y0)/(a-o);function s(e){return(e-o)/(a-o)*(t.y1-t.y0)+t.y0}1>l?(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*l})):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),_n(d,l,h,10,8)}(y),y}return y.update=function(t){return zn(t),_n(t,l,h,10,8),t},y.nodeWidth=function(t){return arguments.length?(r=+t,y):r},y.nodePadding=function(t){return arguments.length?(o=+t,y):o},y.nodePaddingRatio=function(t){return arguments.length?(a=+t,y):a},y.nodes=function(t){return arguments.length?(d="function"==typeof t?t:Tn(t),y):d},y.links=function(t){return arguments.length?(f="function"==typeof t?t:Tn(t),y):f},y.nodeId=function(t){return arguments.length?(l="function"==typeof t?t:Tn(t),y):l},y.nodeAlign=function(t){return arguments.length?(s="function"==typeof t?t:Tn(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(r){return arguments.length?(t=+r[0][0],e=+r[0][1],n=+r[1][0],i=+r[1][1],y):[[t,e],[n,i]]},y.size=function(r){return arguments.length?(t=e=0,n=+r[0],i=+r[1],y):[n-t,i-e]},y}const Bn=t=>{let e,n,i,r,o,a,l,s,c;return"down"===t.direction?(e=t.y0-t.sankeyWidth/2,n=t.y1-t.sankeyWidth/2,i=t.y1+t.sankeyWidth/2,r=t.y0+t.sankeyWidth/2,o=t.source.y1,a=t.target.y0,l=et(o,a),s=l(.5),c=l(.5),`M${e},${o}C${e},${s} ${n},${c} ${n},${a}L${i},${a}C${i},${c} ${r},${s} ${r},${o}Z`):(e=t.source.x1,n=t.target.x0,l=et(e,n),i=l(.5),r=l(.5),o=t.y0-t.sankeyWidth/2,a=t.y1-t.sankeyWidth/2,s=t.y1+t.sankeyWidth/2,c=t.y0+t.sankeyWidth/2,`M${e},${o}C${i},${o} ${r},${a} ${n},${a}L${n},${s}C${r},${s} ${i},${c} ${e},${c}Z`)};function jn(t){var e;const n=t.sankeyWidth/2,i=(null!==(e=t._circularWidth)&&void 0!==e?e:t.sankeyWidth)/2,r=t.circularPathData;if(!r)return null;if("down"===t.direction)return null;if(t._circularStub){const e=r.sourceX,i=r.sourceY,o=r.targetX,a=r.targetY;if("object"!=typeof t.source||!t.source||"object"!=typeof t.target||!t.target)return null;const l=Math.max(15,Math.min(40,.33*(r.rightFullExtent-e))),s=Math.max(15,Math.min(40,.33*(o-r.leftFullExtent)));return`M${e},${i-n}L${e+l},${i-n}L${e+l},${i+n}L${e},${i+n}ZM${o},${a-n}L${o-s},${a-n}L${o-s},${a+n}L${o},${a+n}Z`}const o=r.sourceX,a=r.sourceY,l=r.targetX,s=r.targetY,c=r.rightFullExtent,u=r.leftFullExtent,h=r.verticalFullExtent,d="bottom"===t.circularLinkType?1:-1,f=Math.max(4,Math.min(i,15));return`M${o},${a-d*n}L${c},${a-d*n}L${c+i},${a-d*n+d*f}L${c+i},${h+d*i-d*f}L${c+i-f},${h+d*i}L${u-i+f},${h+d*i}L${u-i},${h+d*i-d*f}L${u-i},${s-d*n+d*f}L${u-i+f},${s-d*n}L${l},${s-d*n}L${l},${s+d*n}L${u+i},${s+d*n}L${u+i},${h-d*i}L${c-i},${h-d*i}L${c-i},${a+d*n}L${o},${a+d*n}Z`}const Rn={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(gn))-1:0},justify:pn},Fn={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,i){var r,o,a,l,s,c,u;if(0===t.length)return;const h="vertical"===n.orientation?"down":"right",d=n.nodeAlign||"justify",f=null!==(r=n.nodeWidth)&&void 0!==r?r:15,y=null!==(o=n.nodePaddingRatio)&&void 0!==o?o:.05,g=null!==(a=n.iterations)&&void 0!==a?a: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"===h?[[0,0],[i[1],i[0]]]:[[0,0],[i[0],i[1]]];const x=In().extent(m).links(v).nodes(p).nodeAlign(Rn[d]||pn).nodeId(t=>t.id).nodeWidth(f).iterations(g);x.nodePaddingRatio&&x.nodePaddingRatio(y),x();{let t=1/0,e=-1/0,n=1/0,r=-1/0;for(const i of p)t>i.x0&&(t=i.x0),i.x1>e&&(e=i.x1),n>i.y0&&(n=i.y0),i.y1>r&&(r=i.y1);for(const i of v){if(!i.circular||!i.circularPathData)continue;const o=i.circularPathData,a=(null!==(s=null!==(l=i._circularWidth)&&void 0!==l?l:i.width)&&void 0!==s?s:0)/2;t>o.leftFullExtent-a&&(t=o.leftFullExtent-a),o.rightFullExtent+a>e&&(e=o.rightFullExtent+a),n>o.verticalFullExtent-a&&(n=o.verticalFullExtent-a),o.verticalFullExtent+a>r&&(r=o.verticalFullExtent+a)}const o=e-t,a=r-n,u=i[0],h=i[1];if(o>0&&a>0&&(0>t||0>n||e>u||r>h)){const e=Math.min(u/o,h/a),i=-t*e+(u-o*e)/2,r=-n*e+(h-a*e)/2;for(const t of p)t.x0=t.x0*e+i,t.x1=t.x1*e+i,t.y0=t.y0*e+r,t.y1=t.y1*e+r;for(const t of v)if(t.y0=t.y0*e+r,t.y1=t.y1*e+r,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+i,n.targetX=n.targetX*e+i,n.sourceY=n.sourceY*e+r,n.targetY=n.targetY*e+r,n.rightFullExtent=n.rightFullExtent*e+i,n.leftFullExtent=n.leftFullExtent*e+i,n.verticalFullExtent=n.verticalFullExtent*e+r,n.rightInnerExtent=n.rightInnerExtent*e+i,n.leftInnerExtent=n.leftInnerExtent*e+i,n.verticalRightInnerExtent=n.verticalRightInnerExtent*e+r,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*e+r,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(`${"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,i="object"==typeof e&&null!==e?e.id:e+"",r="object"==typeof n&&null!==n?n.id:n+"",o=k.get(`${i}\0${r}`);if(o){o.y0=t.y0,o.y1=t.y1,o.sankeyWidth=null!==(u=t.width)&&void 0!==u?u:0,o.circular=!!t.circular,o.circularPathData=t.circularPathData,o._circularWidth=t._circularWidth,o._circularStub=t._circularStub,o.path=t.path,o.circularLinkType=t.circularLinkType,o.direction=h;const e=b.get(i),n=b.get(r);e&&(o.source=e),n&&(o.target=n)}}},buildScene(t,e,n,i){var r,o,a,l;const s="vertical"===n.orientation?"down":"right",c=n.nodeStyle,u=n.edgeStyle,h=null!==(r=n.edgeOpacity)&&void 0!==r?r:.5,d=n.edgeColorBy||"source",f=Array.isArray(n.colorScheme)?n.colorScheme:x,y=new Map;t.forEach((t,e)=>{y.set(t.id,f[e%f.length])});const g=[],p=[],v=[];for(const e of t){const t=e.x1-e.x0,n=e.y1-e.y0;if(0>=t||0>=n)continue;const i=c?c(e):{},r={fill:i.fill||y.get(e.id)||"#4d430c",stroke:i.stroke,strokeWidth:i.strokeWidth,opacity:i.opacity};g.push({type:"rect",x:e.x0,y:e.y0,w:t,h:n,style:r,datum:e,id:e.id,label:e.id})}const m=[...e].sort((t,e)=>(e.sankeyWidth||0)-(t.sankeyWidth||0));for(const t of m){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 i="#999";u?i=u(t).fill||i:"target"===d&&n?i=y.get(n.id)||i:e&&(i=y.get(e.id)||i);const r=u?u(t):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,n=t.sankeyWidth/2,l=Math.max(15,Math.min(40,.33*(e.rightFullExtent-e.sourceX))),s=Math.max(15,Math.min(40,.33*(e.targetX-e.leftFullExtent))),c=r.fill||i;p.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-n}L${e.sourceX+l},${e.sourceY-n}L${e.sourceX+l},${e.sourceY+n}L${e.sourceX},${e.sourceY+n}Z`,style:{fill:c,fillOpacity:null!==(o=r.fillOpacity)&&void 0!==o?o:h,stroke:"none",opacity:r.opacity},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+l}}),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!==(a=r.fillOpacity)&&void 0!==a?a:h,stroke:"none",opacity:r.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?jn(t):Bn(t),!s)continue;const c={fill:r.fill||i,fillOpacity:null!==(l=r.fillOpacity)&&void 0!==l?l:h,stroke:r.stroke||"none",strokeWidth:r.strokeWidth,opacity:r.opacity};p.push({type:"bezier",pathD:s,bezierCache:t.bezier,style:c,datum:t})}if(!1!==n.showLabels){const e=(b=n.nodeLabel)?"function"==typeof b?b:t=>t[b]||t.id:null;for(const n of t){const t=n.x1-n.x0,r=n.y1-n.y0;if(0>=t||0>=r)continue;const o=e?e(n):n.id;if(!o)continue;let a,l,c;"down"===s?(a=n.x0+t/2,l=n.y1+14,c="middle"):(i[0]/2>n.x0+t/2?(a=n.x0-6,c="end"):(a=n.x1+6,c="start"),l=n.y0+r/2),v.push({x:a,y:l,text:o+"",anchor:c,baseline:"middle",fontSize:11})}}var b;return{sceneNodes:g,sceneEdges:p,labels:v}}},Yn={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,i){var r,o;if(0===t.length)return;const a=null!==(r=n.forceStrength)&&void 0!==r?r:.1,l=i[0]/2,s=i[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 i=Hn(t.id,e,n);if(i.length>0){let e=0,n=0;for(const t of i)e+=t.x,n+=t.y;const r=Xn(t.id),o=r%360*(Math.PI/180),a=10+r%20;t.x=e/i.length+a*Math.cos(o),t.y=n/i.length+a*Math.sin(o)}else{const e=Xn(t.id),n=e%360*(Math.PI/180),i=15+e%30;t.x=l+i*Math.cos(n),t.y=s+i*Math.sin(n)}}}else{const e=2.399963229728653;for(let n=0;t.length>n;n++){const i=t[n];if(null==i.x||null==i.y||0===i.x&&0===i.y){const t=10*Math.sqrt(n+.5),r=n*e;i.x=l+t*Math.cos(r),i.y=s+t*Math.sin(r)}}}const f=null!==(o=n.iterations)&&void 0!==o?o:Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),y=d?40:f,g=Gn(n.nodeSize,n.nodeSizeRange,t),p=t=>g(t),v=nt().strength(t=>Math.min(2.5,t.weight?t.weight*a:a)).id(t=>t.id),m=it().force("charge",rt().strength(t=>-25*p(t))).force("center",ot(l,s).strength(.8)).force("x",at(l).strength(.15)).force("y",lt(s).strength(.15));if(m.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}));m.force("link",v),m.force("link").links(t)}d?m.alpha(.3):.1>m.alpha()&&m.alpha(1),m.stop();for(let t=0;y>t;++t)m.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(i[0]-t,e.x)),e.y=Math.max(t,Math.min(i[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,i){var r,o,a;const l=n.nodeStyle,s=n.edgeStyle,c=Gn(n.nodeSize,n.nodeSizeRange,t),u=Array.isArray(n.colorScheme)?n.colorScheme:x,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(e),n=l?l(e):{},i={fill:n.fill||h.get(e.id)||"#007bff",stroke:n.stroke||"#fff",strokeWidth:null!==(r=n.strokeWidth)&&void 0!==r?r:2,opacity:n.opacity};d.push({type:"circle",cx:e.x,cy:e.y,r:t,style:i,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 i=s?s(t):{},r={stroke:i.stroke||"#999",strokeWidth:null!==(o=i.strokeWidth)&&void 0!==o?o:1,opacity:null!==(a=i.opacity)&&void 0!==a?a:.6};f.push({type:"line",x1:e.x,y1:e.y,x2:n.x,y2:n.y,style:r,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 i=c(n);y.push({x:n.x,y:n.y-i-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var p;return{sceneNodes:d,sceneEdges:f,labels:y}}};function Hn(t,e,n){const i=[];for(const r of e){const e="string"==typeof r.source?r.source:r.source.id,o="string"==typeof r.target?r.target:r.target.id;let a=null;if(e===t?a=o:o===t&&(a=e),a){const t=n.get(a);!t||0===t.x&&0===t.y||i.push({x:t.x,y:t.y})}}return i}function Xn(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 Gn(t,e,n){var i,r;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const o=e||[5,20],a=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===a.length)return()=>o[0];const l=null!==(i=P(a))&&void 0!==i?i:0,s=null!==(r=_(a))&&void 0!==r?r:1;if(l===s)return()=>(o[0]+o[1])/2;const c=p().domain([l,s]).range(o).clamp(!0);return e=>{var n;const i=null===(n=e.data)||void 0===n?void 0:n[t];return null==i||"number"!=typeof i?o[0]:c(i)}}const Vn=x,qn={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,n,i){if(0===t.length)return;const{padAngle:r=.01,groupWidth:o=20,sortGroups:a}=n,l=Math.min(i[0],i[1])/2,s=l-o,c=i[0]/2,u=i[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),i=f.get(e);if(void 0===n||void 0===i)continue;const r=h(t);g[n][i]=r}const p=ct().padAngle(r);a&&p.sortGroups(a);const v=p(g),m=v.groups,x=Z().innerRadius(s).outerRadius(l);for(const e of m){const n=t[e.index],i=x.centroid(e);n.x=i[0]+c,n.y=i[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),i=b.get(e);n&&(t.source=n),i&&(t.target=i)}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,i=t[e.target.index].id,r=k.get(`${n}\0${i}`)||k.get(`${i}\0${n}`);r&&(r.chordData=e)}},buildScene(t,e,n,i){var r,o;const{groupWidth:a=20,edgeOpacity:l=.5}=n,s=Math.min(i[0],i[1])/2,c=s-a,u=i[0]/2,h=i[1]/2,d=n.nodeStyle,f=n.edgeStyle,y=n.edgeColorBy||"source",g=Array.isArray(n.colorScheme)?n.colorScheme:Vn,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],i=n.arcData;if(!i)continue;let o;o=d?d(n).fill||p.get(n.id)||g[e%g.length]:p.get(n.id)||g[e%g.length];const a=d?d(n):{},l={fill:o,stroke:a.stroke||"black",strokeWidth:null!==(r=a.strokeWidth)&&void 0!==r?r:1,opacity:a.opacity};m.push({type:"arc",cx:u,cy:h,innerR:c,outerR:s,startAngle:i.startAngle-Math.PI/2,endAngle:i.endAngle-Math.PI/2,style:l,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 i=Kn(n,u,h);let r="#999";if(f)r=f(t).fill||r;else{const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;"target"===y&&n?r=p.get(n.id)||r:e&&(r=p.get(e.id)||r)}const a=f?f(t):{},s={fill:r,fillOpacity:null!==(o=a.fillOpacity)&&void 0!==o?o:l,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity};x.push({type:"ribbon",pathD:i,style:s,datum:t})}if(!1!==n.showLabels){const e=(k=n.nodeLabel)?"function"==typeof k?k:t=>t[k]||t.id:null,i=s+12;for(const n of t){const t=n.arcData;if(!t)continue;const r=e?e(n):n.id;if(!r)continue;const o=(t.startAngle+t.endAngle)/2,a=o-Math.PI/2;b.push({x:u+Math.cos(a)*i,y:h+Math.sin(a)*i,text:r+"",anchor:o>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var k;return{sceneNodes:m,sceneEdges:x,labels:b}}};function Kn(t,e,n){const i=t.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!i)return t;const r=[];let o=0;for(;i.length>o;){const t=i[o];if("M"===t||"L"===t)for(r.push(t),o++;i.length>o&&!isNaN(Number(i[o]));)r.push(Number(i[o])+e+""),o++,i.length>o&&!isNaN(Number(i[o]))&&(r.push(Number(i[o])+n+""),o++);else if("C"===t)for(r.push(t),o++;i.length>o&&!isNaN(Number(i[o]));)for(let t=0;3>t&&i.length>o&&!isNaN(Number(i[o]));t++)r.push(Number(i[o])+e+""),o++,i.length>o&&!isNaN(Number(i[o]))&&(r.push(Number(i[o])+n+""),o++);else if("Q"===t)for(r.push(t),o++;i.length>o&&!isNaN(Number(i[o]));)for(let t=0;2>t&&i.length>o&&!isNaN(Number(i[o]));t++)r.push(Number(i[o])+e+""),o++,i.length>o&&!isNaN(Number(i[o]))&&(r.push(Number(i[o])+n+""),o++);else if("A"===t)for(r.push(t),o++;i.length>o&&!isNaN(Number(i[o]));)r.push(i[o++]),i.length>o&&r.push(i[o++]),i.length>o&&r.push(i[o++]),i.length>o&&r.push(i[o++]),i.length>o&&r.push(i[o++]),i.length>o&&(r.push(Number(i[o])+e+""),o++),i.length>o&&(r.push(Number(i[o])+n+""),o++);else"Z"===t||"z"===t?(r.push(t),o++):(r.push(i[o]),o++)}return r.join(" ")}function Zn(t){const[e,n,i]=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*i>150?"#222":"#fff"}const Un={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,n,i){var r;const o=n.__hierarchyRoot;if(!o)return;const a=n.chartType,l=(s=n.childrenAccessor)?"function"==typeof s?s:t=>t[s]:void 0;var s;const c=n.hierarchySum||(t=>{var e;return null!==(e=t.value)&&void 0!==e?e:0}),u=$(o,l);u.sum(c),u.sort((t,e)=>{var n,i;return(null!==(n=e.value)&&void 0!==n?n:0)-(null!==(i=t.value)&&void 0!==i?i:0)});const[h,d]=i;switch(a){case"tree":!function(t,e,n,i){const r=e.treeOrientation||"vertical",o=B();o.size("horizontal"===r?[i,n]:"radial"===r?[2*Math.PI,Math.min(n,i)/2*.8]:[n,i]),o(t)}(u,n,h,d);break;case"cluster":!function(t,e,n,i){const r=e.treeOrientation||"vertical",o=I();o.size("horizontal"===r?[i,n]:"radial"===r?[2*Math.PI,Math.min(n,i)/2*.8]:[n,i]),o(t)}(u,n,h,d);break;case"treemap":!function(t,e,n,i){var r,o;const a=null!==(r=e.padding)&&void 0!==r?r:4,l=null!==(o=e.paddingTop)&&void 0!==o?o:0,s=N().size([n,i]).tile(z).padding(a);l>0&&s.paddingTop(l),s(t)}(u,n,h,d);break;case"circlepack":!function(t,e,n,i){var r;const o=null!==(r=e.padding)&&void 0!==r?r:4;O().size([n,i]).padding(o)(t)}(u,n,h,d);break;case"partition":!function(t,e,n,i){var r;C().size([n,i]).padding(null!==(r=e.padding)&&void 0!==r?r:1)(t)}(u,n,h,d)}const f=u.descendants();t.length=0,e.length=0;const y=new Map;for(let e=0;f.length>e;e++){const i=f[e],o={id:ni(i,n,e),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(r=i.value)&&void 0!==r?r:0,depth:i.depth,data:i.data,createdByFrame:!0};"tree"===a||"cluster"===a?Qn(o,i,n):"treemap"===a||"partition"===a?Jn(o,i):"circlepack"===a&&ti(o,i),o.__hierarchyNode=i,t.push(o),y.set(i,o)}if("tree"===a||"cluster"===a)for(const t of f)if(t.parent){const n=y.get(t.parent),i=y.get(t);n&&i&&e.push({source:n,target:i,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,n,i){const r=n.nodeStyle||(()=>({})),o=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(t,e,n,i,r,o){var a,l,s,c,u;const h=[],d=[],f=[],y=n.treeOrientation||"vertical",g="radial"===y,p=i[0]/2,v=i[1]/2,m="number"==typeof(b=n.nodeSize)?b:5,x=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];var b;for(const e of t){let t=e.x,i=e.y;g&&(t+=p,i+=v);const o=r(e);let l=o.fill||"#4d430c";n.colorByDepth&&void 0!==e.depth&&(l=x[e.depth%x.length]);const s={fill:l,stroke:o.stroke||"#fff",strokeWidth:null!==(a=o.strokeWidth)&&void 0!==a?a:1,opacity:o.opacity};h.push({type:"circle",cx:t,cy:i,r:m,style:s,datum:e,id:e.id,label:e.id,depth:e.depth})}const k=null!==(l=n.edgeOpacity)&&void 0!==l?l:.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 i=e.x,r=e.y,a=n.x,l=n.y;g&&(i+=p,r+=v,a+=p,l+=v);const u=ei(i,r,a,l,y),h=o(t),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:k};d.push({type:"curved",pathD:u,style:f,datum:t})}if(!1!==n.showLabels){const e=ii(n.nodeLabel);for(const n of t){const t=e?e(n):n.id;if(!t)continue;let i,r,o,a=n.x,l=n.y;if(g&&(a+=p,l+=v),g){const t=a-p,e=l-v,n=Math.sqrt(t*t+e*e);n>0?(i=a+t/n*10,r=l+e/n*10,o=0>t?"end":"start"):(i=a,r=l-12,o="middle")}else"horizontal"===y?((null===(u=n.data)||void 0===u?void 0:u.children)&&0!==n.data.children.length?(i=a-m-6,o="end"):(i=a+m+6,o="start"),r=l):(i=a,r=l+m+14,o="middle");f.push({x:i,y:r,text:t+"",anchor:o,baseline:"middle",fontSize:11})}}return{sceneNodes:h,sceneEdges:d,labels:f}}(t,e,n,i,r,o);case"treemap":case"partition":return function(t,e,n,i){var r,o;const a=[],l=[],s=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const n of t){const t=n.x1-n.x0,o=n.y1-n.y0;if(0>=t||0>=o)continue;const l=i(n);let c=l.fill||"#4d430c";e.colorByDepth&&void 0!==n.depth&&(c=s[n.depth%s.length]);const u={fill:c,stroke:l.stroke||"#fff",strokeWidth:null!==(r=l.strokeWidth)&&void 0!==r?r:1,opacity:l.opacity};a.push({type:"rect",x:n.x0,y:n.y0,w:t,h:o,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==e.showLabels){const n=ii(e.nodeLabel),r=e.labelMode||"leaf",a="partition"===e.chartType;for(const c of t){const t=c.x1-c.x0,u=c.y1-c.y0;if(0>=t||0>=u)continue;const h=!((null===(o=c.data)||void 0===o?void 0:o.children)&&c.data.children.length>0);if(!a){if("leaf"===r&&!h)continue;if("parent"===r&&h)continue}const d=n?n(c):c.id;if(!d)continue;if((h?30:40)>t||(h?16:14)>u)continue;let f=i(c).fill||"#4d430c";e.colorByDepth&&void 0!==c.depth&&(f=s[c.depth%s.length]);const y=Zn(f);l.push(h?{x:c.x0+t/2,y:c.y0+u/2,text:d+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,u)/6)),fill:y}:{x:c.x0+4,y:c.y0+12,text:d+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:y})}}return{sceneNodes:a,sceneEdges:[],labels:l}}(t,n,0,r);case"circlepack":return function(t,e,n,i){var r,o,a,l,s;const c=[],u=[],h=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const n of t){const t=null!==(r=n.__radius)&&void 0!==r?r:5;if(0>=t)continue;const l=i(n);let s=l.fill||"#4d430c";e.colorByDepth&&void 0!==n.depth&&(s=h[n.depth%h.length]);const u={fill:s,stroke:l.stroke||"#fff",strokeWidth:null!==(o=l.strokeWidth)&&void 0!==o?o:1,opacity:null!==(a=l.opacity)&&void 0!==a?a:.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=ii(e.nodeLabel);for(const r of t){const t=null!==(l=r.__radius)&&void 0!==l?l:5,o=n?n(r):r.id;if(!o)continue;if(15>t)continue;const a=!((null===(s=r.data)||void 0===s?void 0:s.children)&&r.data.children.length>0);let c=i(r).fill||"#4d430c";if(e.colorByDepth&&void 0!==r.depth&&(c=h[r.depth%h.length]),a){const e=Zn(c);u.push({x:r.x,y:r.y,text:o+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,t/3)),fill:e})}else u.push({x:r.x,y:r.y-t+14,text:o+"",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,r);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Qn(t,e,n){const i=n.treeOrientation||"vertical";if("radial"===i){const n=e.x,i=e.y;t.x=i*Math.cos(n-Math.PI/2),t.y=i*Math.sin(n-Math.PI/2)}else"horizontal"===i?(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 Jn(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 ti(t,e){var n;const i=null!==(n=e.r)&&void 0!==n?n:0;t.x=e.x,t.y=e.y,t.x0=e.x-i,t.x1=e.x+i,t.y0=e.y-i,t.y1=e.y+i,t.width=2*i,t.height=2*i,t.__radius=i}function ei(t,e,n,i,r){if("horizontal"===r){const r=(t+n)/2;return`M ${t},${e} C ${r},${e} ${r},${i} ${n},${i}`}if("radial"===r){const r=(t+n)/2;return`M ${t},${e} Q ${r},${e} ${r},${(e+i)/2} T ${n},${i}`}{const r=(e+i)/2;return`M ${t},${e} C ${t},${r} ${n},${r} ${n},${i}`}}function ni(t,e,n){const i=e.nodeIDAccessor;return"function"==typeof i?i(t.data)+"":"string"==typeof i&&void 0!==t.data[i]?t.data[i]+"":void 0!==t.data.name?t.data.name+"":void 0!==t.data.id?t.data.id+"":"node-"+n}function ii(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 ri(t){const e=t;return e.__orbitState||(e.__orbitState={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()}),e.__orbitState}const oi={sankey:Fn,force:Yn,chord:qn,tree:Un,cluster:Un,treemap:Un,circlepack:Un,partition:Un,orbit:{supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(t,e,n,i){const r=n.__hierarchyRoot;r&&function(t,e,n,i,r){var o,a;const l=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!==(o=n.orbitSize)&&void 0!==o?o:2.95,h=null!==(a=n.orbitEccentricity)&&void 0!==a?a:1,d="number"==typeof u?()=>u:u,f="number"==typeof h?()=>h:h,y=ri(n);y.metaMap.clear(),i.length=0,r.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));i.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,o,a,u,h,g){const v=l(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:h,data:e,parentId:n},M=g?u/d(A)*E:u*E,P=J().value(t=>{var e;return(null===(e=l(t))||void 0===e?void 0:e.length)?4:1}).sort(null),S=P(k),_=f(A);for(let e=0;k.length>e;e++){const l=(S[e].startAngle+S[e].endAngle)/2,c=k[e],u=p(s(c)),d=o+M*Math.sin(l),f=a+M*Math.cos(l)*_;i.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:l,depth:h,parentId:n,eccentricity:_}),r.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,v,m,x,1,!1)}(r,i,n,t,e)},buildScene(t,e,n,i){var r,o,a,l,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=ri(n),i=new Map;for(const e of t)i.set(e.id,e);const r=new Map;for(const[,t]of e.metaMap){if(!t.parentId)continue;const e=i.get(t.parentId);if(!e)continue;const n=`${t.parentId}:${t.ring}`;r.has(n)||r.set(n,{parentX:e.x,parentY:e.y,ring:t.ring,ecc:t.eccentricity})}const o=48,a={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:t,parentY:e,ring:n,ecc:i}]of r)for(let r=0;o>r;r++){const l=r/o*Math.PI*2,s=(r+1)/o*Math.PI*2;f.push({type:"line",x1:t+n*Math.sin(l),y1:e+n*Math.cos(l)*i,x2:t+n*Math.sin(s),y2:e+n*Math.cos(s)*i,style:a,datum:null})}}for(const e of t){if(null==e.x||null==e.y)continue;const t=h(e),n=c?c(e):{},i={fill:n.fill||"#6366f1",stroke:n.stroke||"#fff",strokeWidth:null!==(r=n.strokeWidth)&&void 0!==r?r:1,opacity:null!==(o=n.opacity)&&void 0!==o?o:0===(null!==(a=e.depth)&&void 0!==a?a:0)?1:.85};d.push({type:"circle",cx:e.x,cy:e.y,r:t,style:i,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(n);if(4>=t)continue;const i="function"==typeof e?e(n):e&&null!==(s=null===(l=n.data)||void 0===l?void 0:l[e])&&void 0!==s?s:n.id;y.push({x:n.x,y:n.y+t+12,text:i+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:d,sceneEdges:f,labels:y}},tick:(t,e,n,i,r)=>!1!==n.orbitAnimated&&(function(t,e){var n,i;const r=ri(e),o=null!==(n=e.orbitSpeed)&&void 0!==n?n:.25,a=null!==(i=e.orbitRevolution)&&void 0!==i?i: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),l=(("undefined"!=typeof performance?performance.now():Date.now())-r.startTime)/1e3,s=o*(Math.PI/6),c=new Map;for(const e of t)c.set(e.id,e);for(const e of t){const t=r.metaMap.get(e.id);if(!t||!t.parentId)continue;const n=c.get(t.parentId);if(!n)continue;const i=t.angle+l*s*a({id:e.id,depth:t.depth,data:e.data,parentId:t.parentId});e.x=n.x+t.ring*Math.sin(i),e.y=n.y+t.ring*Math.cos(i)*t.eccentricity,e.x0=e.x,e.x1=e.x,e.y0=e.y,e.y1=e.y}}(t,n),!0)}};function ai(t){return oi[t]}class li{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({},qe),t.tensionConfig),"sankey"===t.chartType&&t.showParticles&&(this.particlePool=new Ze(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({},qe),t.tensionConfig),"sankey"===t.chartType&&t.showParticles&&!this.particlePool&&(this.particlePool=new Ze(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:i="id",sourceAccessor:r="source",targetAccessor:o="target",valueAccessor:a="value"}=this.config,l="function"==typeof i?i:t=>t[i],s="function"==typeof r?r:t=>t[r],c="function"==typeof o?o:t=>t[o],u="function"==typeof a?a:t=>{var e;return null!==(e=t[a])&&void 0!==e?e:1};this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const e of t){const t=l(e)+"";this.nodes.set(t,Object.assign(Object.assign({},si(t)),{data:e}))}for(const t of e){const e=s(t)+"",n=c(t)+"",i=Number(u(t))||1;this.nodes.has(e)||this.nodes.set(e,Object.assign(Object.assign({},si(e)),{data:t})),this.nodes.has(n)||this.nodes.set(n,Object.assign(Object.assign({},si(n)),{data:t})),this.edges.set(`${e}\0${n}`,{source:e,target:n,value:i,y0:0,y1:0,sankeyWidth:0,data:t})}this.runLayout(n)}edgeKey(t,e){return`${t}\0${e}`}ingestEdge(t){const{source:e,target:n,value:i}=t,r=0===this.nodes.size;let o=!1;const a="undefined"!=typeof performance?performance.now():Date.now();this.lastIngestTime=a,this._decaySortedNodes=null,this.nodes.has(e)||(this.nodes.set(e,si(e)),this.nodeTimestamps.set(e,a),this.tension+=this.tensionConfig.newNode,o=!0),this.nodes.has(n)||(this.nodes.set(n,si(n)),this.nodeTimestamps.set(n,a),this.tension+=this.tensionConfig.newNode,o=!0);const l=this.edgeKey(e,n),s=this.edges.get(l);return s?(s.value+=i,this.edgeTimestamps.set(l,a),this.tension+=this.tensionConfig.weightChange):(this.edges.set(l,{source:e,target:n,value:i,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(l,a),this.tension+=this.tensionConfig.newEdge,o=!0),r||o||this.tension>=this.tensionConfig.threshold}runLayout(t){var e,n,i,r,o,a;const l=ai(this.config.chartType);if(!l)return;let s=Array.from(this.nodes.values()),c=Array.from(this.edges.values());if(0===s.length&&!l.hierarchical)return;if(this.prepareForRelayout(),l.supportsStreaming&&!l.hierarchical){const t=new Map;for(const l of s)if(void 0!==l._prevX0){const s=(null!==(e=l._prevX1)&&void 0!==e?e:0)-(null!==(n=l._prevX0)&&void 0!==n?n:0),c=(null!==(i=l._prevY1)&&void 0!==i?i:0)-(null!==(r=l._prevY0)&&void 0!==r?r:0);t.set(l.id,{x:(null!==(o=l._prevX0)&&void 0!==o?o:0)+s/2,y:(null!==(a=l._prevY0)&&void 0!==a?a:0)+c/2})}else 0===l.x&&0===l.y||t.set(l.id,{x:l.x,y:l.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(l.computeLayout(s,c,this.config,t),delete this.config.__previousPositions,l.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(const t of c)this.edges.set(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t)}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=ai(this.config.chartType);if(!e)return;const n=Array.from(this.nodes.values()),i=Array.from(this.edges.values()),{sceneNodes:r,sceneEdges:o,labels:a}=e.buildScene(n,i,this.config,t);this.sceneNodes=r,this.sceneEdges=o,this.labels=a}get isAnimating(){const t=ai(this.config.chartType);return!!(null==t?void 0:t.supportsAnimation)&&!1!==this.config.orbitAnimated}tickAnimation(t,e){const n=ai(this.config.chartType);if(!(null==n?void 0:n.tick))return!1;const i=Array.from(this.nodes.values()),r=Array.from(this.edges.values());return n.tick(i,r,this.config,t,e)}advanceTransition(t){if(!this.transition)return!1;const e=Mt(t,this.transition),n=At(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 i=(t.sankeyWidth||1)/2;if("down"===t.direction){const r=e.y1,o=n.y0,a=et(r,o);return{circular:!1,points:[{x:t.y0,y:r},{x:t.y0,y:a(.5)},{x:t.y1,y:a(.5)},{x:t.y1,y:o}],halfWidth:i}}const r=e.x1,o=n.x0,a=et(r,o);return{circular:!1,points:[{x:r,y:t.y0},{x:a(.5),y:t.y0},{x:a(.5),y:t.y1},{x:o,y:t.y1}],halfWidth:i}}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))),i=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-i,y:n.targetY},{x:n.targetX-.66*i,y:n.targetY},{x:n.targetX-.33*i,y:n.targetY},{x:n.targetX,y:n.targetY}]],halfWidth:e}}let i;i="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 r=[];for(let t=0;i.length-1>t;t++){const e=i[t],n=i[t+1],o=n.x-e.x,a=n.y-e.y;r.push([e,{x:e.x+o/3,y:e.y+a/3},{x:e.x+2*o/3,y:e.y+2*a/3},n])}return{circular:!0,segments:r,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,i,r,o;const a=this.config.pulse;if(!a)return;const l=null!==(e=a.duration)&&void 0!==e?e:500,s=null!==(n=a.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",c=null!==(i=a.glowRadius)&&void 0!==i?i:4;for(const e of this.sceneNodes){const n=e.id;if(!n)continue;const i=this.nodeTimestamps.get(n);if(!i)continue;const r=t-i;l>r&&(e._pulseIntensity=1-r/l,e._pulseColor=s,e._pulseGlowRadius=c)}for(const e of this.sceneEdges){const n=e.datum;if(!n)continue;const i="object"==typeof n.source?null===(r=n.source)||void 0===r?void 0:r.id:n.source,a="object"==typeof n.target?null===(o=n.target)||void 0===o?void 0:o.id:n.target;if(!i||!a)continue;const c=this.edgeTimestamps.get(`${i}\0${a}`);if(!c)continue;const u=t-c;l>u&&(e._pulseIntensity=1-u/l,e._pulseColor=s)}}applyDecay(){var t,e,n,i,r;const o=this.config.decay;if(!o)return;const a=null!==(t=o.minOpacity)&&void 0!==t?t:.1,l=this.nodeTimestamps.size;if(1>=l)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=l-1-u;let d;switch(o.type){case"linear":d=a+(1-h/(l-1))*(1-a);break;case"exponential":{const t=null!==(e=o.halfLife)&&void 0!==e?e:l/2;d=a+Math.pow(.5,h/t)*(1-a);break}case"step":d=(null!==(n=o.stepThreshold)&&void 0!==n?n:.5*l)>h?1:a;break;default:d=1}const f=null!==(r=null===(i=t.style)||void 0===i?void 0:i.opacity)&&void 0!==r?r: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 i=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,i),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 i=this.config.thresholds;if(!i)return;const r=null!==(e=i.warningColor)&&void 0!==e?e:"#f59e0b",o=null!==(n=i.criticalColor)&&void 0!==n?n:"#ef4444",a=!1!==i.pulse;for(const e of this.sceneNodes){const n=e.id;if(!n)continue;const l=this.nodes.get(n);if(!l)continue;const s=i.metric(l);let c=null;void 0===i.critical||i.critical>s?void 0===i.warning||i.warning>s||(c=r):c=o,c&&(e.style=Object.assign(Object.assign({},e.style),{fill:c}),a&&(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 si(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 ci(t,e,n,i,r=30){let o=null,a=r,l=1/0;for(const e of t){const t=ui(e,n,i);if(t)if("rect"===e.type){const n=e.w*e.h;l>n&&(o=t,l=n)}else a>t.distance&&(o=t,a=t.distance)}if(o)return o;for(const t of e){const e=yi(t,n,i);e&&a>e.distance&&(o=e,a=e.distance)}return o}function ui(t,e,n){switch(t.type){case"circle":return function(t,e,n){const i=e-t.cx,r=n-t.cy,o=Math.sqrt(i*i+r*r);return o>Math.max(t.r,5)+5?null:{type:"node",datum:t.datum,x:t.cx,y:t.cy,distance:o}}(t,e,n);case"rect":return function(t,e,n){const i=_t(e,n,t);return i.hit?{type:"node",datum:t.datum,x:i.cx,y:i.cy,distance:0}:null}(t,e,n);case"arc":return function(t,e,n){const i=e-t.cx,r=n-t.cy,o=Math.sqrt(i*i+r*r);if(t.innerR-2>o||o>t.outerR+2)return null;const a=Lt(Math.atan2(r,i)),l=Lt(t.startAngle),s=Lt(t.endAngle);if(l>s?a>=l||s>=a:a>=l&&s>=a){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 hi=null,di=null;function fi(){return di||(hi=document.createElement("canvas"),hi.width=1,hi.height=1,di=hi.getContext("2d")),di}function yi(t,e,n){switch(t.type){case"bezier":return function(t,e,n){var i,r;if(!t.pathD)return null;try{const o=new Path2D(t.pathD),a=fi();if(!a)return null;if(a.isPointInPath(o,e,n)){const o="object"==typeof(null===(i=t.datum)||void 0===i?void 0:i.source)?t.datum.source:null,a="object"==typeof(null===(r=t.datum)||void 0===r?void 0:r.target)?t.datum.target:null;return{type:"edge",datum:t.datum,x:o&&a?(o.x1+a.x0)/2:e,y:t.datum?(t.datum.y0+t.datum.y1)/2:n,distance:0}}const l=a.lineWidth;a.lineWidth=10;const s=a.isPointInStroke(o,e,n);if(a.lineWidth=l,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 i=t.x2-t.x1,r=t.y2-t.y1,o=i*i+r*r;if(0===o)return null;let a=((e-t.x1)*i+(n-t.y1)*r)/o;a=Math.max(0,Math.min(1,a));const l=t.x1+a*i,s=t.y1+a*r,c=Math.sqrt(Math.pow(e-l,2)+Math.pow(n-s,2));return c>5?null:{type:"edge",datum:t.datum,x:l,y:s,distance:c}}(t,e,n);case"ribbon":case"curved":return function(t,e,n){if(!t.pathD)return null;try{const i=new Path2D(t.pathD),r=fi();if(!r)return null;if(r.isPointInPath(i,e,n))return{type:"edge",datum:t.datum,x:e,y:n,distance:0};const o=r.lineWidth;r.lineWidth=10;const a=r.isPointInStroke(i,e,n);if(r.lineWidth=o,a)return{type:"edge",datum:t.datum,x:e,y:n,distance:4}}catch(t){}return null}(t,e,n);default:return null}}function gi(e){const{width:n,height:i,totalWidth:r,totalHeight:o,margin:a,labels:l,title:s,legend:c,legendHoverBehavior:u,legendClickBehavior:h,legendHighlightedCategory:d,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:r,height:o,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(${a.left},${a.top})`},l.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,r)=>{if(m){const o=m(e,r,{width:n,height:i,sceneNodes:p});if(o)return t.createElement(t.Fragment,{key:"annotation-"+r},o)}return null}),g),s&&"string"==typeof s?t.createElement("text",{x:r/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor"},s):s?t.createElement("foreignObject",{x:0,y:0,width:r,height:a.top},s):null,Vt({legend:c,totalWidth:r,totalHeight:o,margin:a,legendPosition:y,title:s,legendHoverBehavior:u,legendClickBehavior:h,legendHighlightedCategory:d,legendIsolatedCategories:f})),null==v?void 0:v.filter(t=>"widget"===t.type&&t.nodeId&&p).map((e,n)=>{var i,r,o,l,s,c,u,h,d;const f=p.find(t=>{var n,i,r,o,a;return t.id===e.nodeId||(null===(n=t.datum)||void 0===n?void 0:n.id)===e.nodeId||(null===(r=null===(i=t.datum)||void 0===i?void 0:i.data)||void 0===r?void 0:r.id)===e.nodeId||(null===(a=null===(o=t.datum)||void 0===o?void 0:o.data)||void 0===a?void 0:a.name)===e.nodeId});if(!f)return null;const y=a.left+(null!==(i=f.cx)&&void 0!==i?i:null!=f.x&&null!=f.w?f.x+f.w/2:null!==(r=f.x)&&void 0!==r?r:0),g=a.top+(null!==(o=f.cy)&&void 0!==o?o:null!=f.y&&null!=f.h?f.y+f.h/2:null!==(l=f.y)&&void 0!==l?l: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!==(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+v-x/2,top:g+m-b/2,width:x,height:b,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:5}},k)}))}function pi(t,e){var n,i,r,o,a,l;if(!e.pathD)return;t.save();const s=new Path2D(e.pathD);if(e.style.fill&&"none"!==e.style.fill){const a=e._gradient;if(a){const r=t.createLinearGradient(a.x0,0,a.x1,0),o=null!==(i=null!==(n=e.style.fillOpacity)&&void 0!==n?n:e.style.opacity)&&void 0!==i?i:.5,l=e.style.fill;r.addColorStop(0,1===a.from?l:"transparent"),r.addColorStop(1,1===a.to?l:"transparent"),t.fillStyle=r,t.globalAlpha=o}else t.fillStyle=e.style.fill,t.globalAlpha=null!==(o=null!==(r=e.style.fillOpacity)&&void 0!==r?r:e.style.opacity)&&void 0!==o?o:.5;t.fill(s)}e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=e.style.stroke,t.lineWidth=null!==(a=e.style.strokeWidth)&&void 0!==a?a:.5,t.globalAlpha=.5*(null!==(l=e.style.opacity)&&void 0!==l?l: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 vi(t,e){var n,i;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!==(i=e.style.strokeWidth)&&void 0!==i?i: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 mi(t,e){var n,i,r,o;if(!e.pathD)return;t.save();const a=new Path2D(e.pathD);e.style.fill&&"none"!==e.style.fill&&(t.fillStyle=e.style.fill,t.globalAlpha=null!==(i=null!==(n=e.style.fillOpacity)&&void 0!==n?n:e.style.opacity)&&void 0!==i?i:.5,t.fill(a)),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=e.style.stroke,t.lineWidth=null!==(r=e.style.strokeWidth)&&void 0!==r?r:.5,t.globalAlpha=.3*(null!==(o=e.style.opacity)&&void 0!==o?o:1),t.stroke(a)),e._pulseIntensity&&e._pulseIntensity>0&&(t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.globalAlpha=.25*e._pulseIntensity,t.fill(a)),t.restore()}function xi(t,e){var n,i;if(!e.pathD)return;t.save();const r=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(r),e.style.fill&&"none"!==e.style.fill&&(t.fillStyle=e.style.fill,t.globalAlpha=null!==(i=e.style.fillOpacity)&&void 0!==i?i:.1,t.fill(r)),t.restore()}gi.displayName="NetworkSVGOverlay";const bi={top:20,right:80,bottom:20,left:80},ki={top:40,right:40,bottom:40,left:40},wi=new Set(["chord","force","circlepack","orbit"]),Ei=[800,600],Ai={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 Mi({data:e}){var n,i,r,o,a,l;if("edge"===e.type){const n=e.data;return t.createElement("div",{className:"semiotic-tooltip",style:Ai},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 a=c;for(;a;){const t=null!==(o=null!==(i=null===(n=a.data)||void 0===n?void 0:n.name)&&void 0!==i?i:null===(r=a.data)||void 0===r?void 0:r.id)&&void 0!==o?o:s.id;null!=t&&e.unshift(t+""),a=a.parent}e.length>1&&e.shift();const l=e.length-1;return t.createElement("div",{className:"semiotic-tooltip",style:Ai},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===l?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===(a=s.sourceLinks)||void 0===a?void 0:a.length)||0)+((null===(l=s.targetLinks)||void 0===l?void 0:l.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:Ai},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 Pi=c(function(o,a){var s,c,h,d,f,y,g,p,v,m,x;const{chartType:b,nodes:k,edges:w,data:E,initialEdges:A,nodeIDAccessor:M="id",sourceAccessor:P="source",targetAccessor:S="target",valueAccessor:_="value",childrenAccessor:L,hierarchySum:D,orientation:T="horizontal",nodeAlign:W="justify",nodePaddingRatio:$=.05,nodeWidth:C=15,iterations:O=300,forceStrength:N=.1,padAngle:z=.01,groupWidth:I=20,sortGroups:B,edgeSort:j,treeOrientation:R="vertical",edgeType:F="curve",padding:Y,paddingTop:H,tensionConfig:X,showParticles:G=!1,particleStyle:V,nodeStyle:q,edgeStyle:K,colorBy:U,colorScheme:Q="category10",edgeColorBy:J="source",edgeOpacity:tt=.5,colorByDepth:et=!1,nodeSize:nt=8,nodeSizeRange:it=[5,20],nodeLabel:rt,showLabels:ot=!0,labelMode:at,size:lt=Ei,responsiveWidth:st,responsiveHeight:ct,margin:ut,className:ht,background:dt,enableHover:ft=!0,tooltipContent:yt,customHoverBehavior:gt,customClickBehavior:pt,onObservation:vt,chartId:mt,onTopologyChange:xt,annotations:bt,svgAnnotationRules:kt,legend:Et,legendPosition:At,legendHoverBehavior:Mt,legendClickBehavior:Pt,legendHighlightedCategory:St,legendIsolatedCategories:_t,title:Lt,foregroundGraphics:Dt,backgroundGraphics:Tt,decay:Wt,pulse:$t,staleness:Ct,thresholds:Ot,accessibleTable:Nt,orbitMode:zt,orbitSize:Rt,orbitSpeed:Ft,orbitRevolution:Yt,orbitRevolutionStyle:Ht,orbitEccentricity:Xt,orbitShowRings:Gt,orbitAnimated:Vt}=o,qt=wi.has(b)?ki:bi,[Kt,Zt]=Bt(lt,st,ct),Ut=Object.assign(Object.assign({},qt),ut),Qt=Zt[0]-Ut.left-Ut.right,Jt=Zt[1]-Ut.top-Ut.bottom,te="function"==typeof Dt?Dt({size:Zt,margin:Ut}):Dt,ee=r(()=>Object.assign(Object.assign({},qe),X),[X]),ne=r(()=>Object.assign(Object.assign({},Ke),V),[V]),ie=r(()=>({chartType:b,nodeIDAccessor:M,sourceAccessor:P,targetAccessor:S,valueAccessor:_,childrenAccessor:L,hierarchySum:D,orientation:T,nodeAlign:W,nodePaddingRatio:$,nodeWidth:C,iterations:O,forceStrength:N,padAngle:z,groupWidth:I,sortGroups:B,edgeSort:j,treeOrientation:R,edgeType:F,padding:Y,paddingTop:H,tensionConfig:ee,showParticles:G,particleStyle:ne,nodeStyle:q,edgeStyle:K,nodeLabel:rt,showLabels:ot,labelMode:at,colorBy:U,colorScheme:Q,edgeColorBy:J,edgeOpacity:tt,colorByDepth:et,nodeSize:nt,nodeSizeRange:it,decay:Wt,pulse:$t,staleness:Ct,thresholds:Ot,orbitMode:zt,orbitSize:Rt,orbitSpeed:Ft,orbitRevolution:Yt,orbitRevolutionStyle:Ht,orbitEccentricity:Xt,orbitShowRings:Gt,orbitAnimated:Vt}),[b,M,P,S,_,L,D,T,W,$,C,O,N,z,I,B,j,R,F,Y,H,ee,G,ne,q,K,rt,ot,at,U,Q,J,tt,et,nt,it,Wt,$t,Ct,Ot,zt,Rt,Ft,Yt,Ht,Xt,Gt,Vt]),re=e(null),oe=e(0),ae=e(0),le=e(!0),se=we(t=>t.theme),ce=e(()=>{}),he=e(null);he.current||(he.current=new li(ie));const[de,ye]=n(null),[ve,me]=n(0),[xe,be]=n(0),[ke,Me]=n(!1),Pe=e(null),Se=e(new Map),_e=e(0),Te=l(t=>{if("function"==typeof U)return U(t)+"";if("string"==typeof U&&t.data){const e=t.data[U];if(void 0!==e){if(!Se.current.has(e+"")){const t=Array.isArray(Q)?Q:wt;Se.current.set(e+"",t[_e.current++%t.length])}return Se.current.get(e+"")}}if(!Se.current.has(t.id)){const e=Array.isArray(Q)?Q:wt;Se.current.set(t.id,e[_e.current++%e.length])}return Se.current.get(t.id)},[U,Q]),We=l(t=>{if("function"==typeof J)return J(t);const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;return"target"===J&&n?Te(n):e?Te(e):"#999"},[J,Te]),$e=l(t=>{if(!(null==V?void 0:V.colorBy))return We(t);const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;return"target"===ne.colorBy&&n?Te(n):e?Te(e):"#999"},[null==V?void 0:V.colorBy,ne.colorBy,Te,We]),Ce="sankey"===b&&G||!!$t||null!==(c=null===(s=he.current)||void 0===s?void 0:s.isAnimating)&&void 0!==c&&c,Oe=l(()=>{oe.current&&!Ce||oe.current||(oe.current=requestAnimationFrame(()=>ce.current()))},[Ce]);i(()=>{var t;null===(t=he.current)||void 0===t||t.updateConfig(ie),le.current=!0,Oe()},[ie,Oe]),i(()=>{le.current=!0,Oe()},[se,Oe]);const Ne=l(()=>{const t=he.current;if(!t)return;t.runLayout([Qt,Jt]),t.buildScene([Qt,Jt]),le.current=!0;const e=Array.isArray(Q)?Q:wt,n=Array.from(t.nodes.values());for(let t=0;n.length>t;t++){const i=n[t];Se.current.has(i.id)||Se.current.set(i.id,e[t%e.length])}if(_e.current=n.length,me(t.layoutVersion),xt){const{nodes:e,edges:n}=t.getLayoutData();xt(e,n)}},[Qt,Jt,xt,Q]),ze=l(t=>{const e=he.current;e&&(e.ingestEdge(t)&&Ne(),Oe())},[Ne,Oe]),Ie=l(t=>{const e=he.current;if(!e)return;let n=!1;for(const i of t)e.ingestEdge(i)&&(n=!0);n&&Ne(),Oe()},[Ne,Oe]),Be=l(()=>{var t;null===(t=he.current)||void 0===t||t.clear(),Se.current.clear(),_e.current=0,me(0),ye(null),Pe.current=null,le.current=!0,Oe()},[Oe]),je=l(()=>{const t=he.current;t&&(t.tension+=999,Ne(),Oe())},[Ne,Oe]);u(a,()=>({push:ze,pushMany:Ie,clear:Be,getTopology:()=>{var t,e;return null!==(e=null===(t=he.current)||void 0===t?void 0:t.getLayoutData())&&void 0!==e?e:{nodes:[],edges:[]}},getTopologyDiff:()=>{const t=he.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:je,getTension:()=>{var t,e;return null!==(e=null===(t=he.current)||void 0===t?void 0:t.tension)&&void 0!==e?e:0}}),[ze,Ie,Be,je]);const Re=["tree","cluster","treemap","circlepack","partition","orbit"].includes(b),Fe=Re?E||(Array.isArray(w)?void 0:w):void 0;i(()=>{const t=he.current;if(t)if(Re&&Fe)t.ingestHierarchy(Fe,[Qt,Jt]),t.buildScene([Qt,Jt]),le.current=!0,Oe();else{const e=k||[],n=Array.isArray(w)?w:[];if(0===e.length&&0===n.length)return;t.ingestBounded(e,n,[Qt,Jt]),t.buildScene([Qt,Jt]);const i=Array.isArray(Q)?Q:wt,r=Array.from(t.nodes.values());for(let t=0;r.length>t;t++){const e=r[t];Se.current.has(e.id)||Se.current.set(e.id,i[t%i.length])}_e.current=r.length,le.current=!0,Oe()}},[k,w,E,Fe,Re,Qt,Jt,ie,Oe,Q]),i(()=>{A&&A.length>0&&Ie(A)},[]);const Ye=l(t=>{if(gt&>(t),vt){const e=Date.now();vt(t?{type:"hover",datum:t.data||{},x:t.x,y:t.y,timestamp:e,chartType:"StreamNetworkFrame",chartId:mt}:{type:"hover-end",timestamp:e,chartType:"StreamNetworkFrame",chartId:mt})}},[gt,vt,mt]),He=l(t=>{if(pt&&pt(t),vt){const e=Date.now();vt(t?{type:"click",datum:t.data||{},x:t.x,y:t.y,timestamp:e,chartType:"StreamNetworkFrame",chartId:mt}:{type:"click-end",timestamp:e,chartType:"StreamNetworkFrame",chartId:mt})}},[pt,vt,mt]),Xe=e(()=>{}),Ge=e(()=>{});Xe.current=t=>{if(!ft)return;const e=re.current;if(!e)return;const n=e.getBoundingClientRect(),i=t.clientX-n.left-Ut.left,r=t.clientY-n.top-Ut.top;if(0>i||i>Qt||0>r||r>Jt)return void(Pe.current&&(Pe.current=null,ye(null),Ye&&(Ye(null),le.current=!0),Oe()));const o=he.current;if(!o)return;const a=ci(o.sceneNodes,o.sceneEdges,i,r);if(!a)return void(Pe.current&&(Pe.current=null,ye(null),Ye&&(Ye(null),le.current=!0),Oe()));const l=a.datum||{},s=Object.assign(Object.assign({},"object"!=typeof l||null===l||Array.isArray(l)?{}:l),{type:a.type,data:l,x:a.x,y:a.y});Pe.current=s,ye(s),Ye&&(Ye(s),le.current=!0),Oe()},Ge.current=()=>{Pe.current&&(Pe.current=null,ye(null),Ye&&(Ye(null),le.current=!0),Oe())};const Ve=e(()=>{});Ve.current=t=>{if(!pt&&!vt)return;const e=re.current;if(!e)return;const n=e.getBoundingClientRect(),i=t.clientX-n.left-Ut.left,r=t.clientY-n.top-Ut.top;if(0>i||i>Qt||0>r||r>Jt)return;const o=he.current;if(!o)return;const a=ci(o.sceneNodes,o.sceneEdges,i,r);if(a){const t=a.datum||{};He(Object.assign(Object.assign({},"object"!=typeof t||null===t||Array.isArray(t)?{}:t),{type:a.type,data:t,x:a.x,y:a.y}))}else He(null)},l(t=>Xe.current(t),[]);const Ze=l(()=>Ge.current(),[]),Ue=l(t=>Ve.current(t),[]),Qe=e(-1),Je=l(t=>{const e=he.current;if(!e)return;const n=function(t){const e=[];for(const n of t)"circle"===n.type&&null!=n.cx?e.push({x:n.cx,y:n.cy,datum:n.datum}):"rect"===n.type&&null!=n.x?e.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum}):"arc"===n.type&&null!=n.cx&&e.push({x:n.cx,y:n.cy,datum:n.datum});return e.sort((t,e)=>t.x-e.x||t.y-e.y),e}(e.sceneNodes);if(0===n.length)return;const i=Qe.current,r=It(t.key,0>i?-1:i,n.length);if(null===r)return;if(t.preventDefault(),0>r)return Qe.current=-1,Pe.current=null,ye(null),Ye&&(Ye(null),le.current=!0),void Oe();const o=0>i?0:r;Qe.current=o;const a=n[o],l=a.datum||{},s=Object.assign(Object.assign({},"object"!=typeof l||null===l||Array.isArray(l)?{}:l),{type:"node",data:l,x:a.x,y:a.y});Pe.current=s,ye(s),Ye&&(Ye(s),le.current=!0),Oe()},[Ye,Oe]),tn=l(t=>{Qe.current=-1,Xe.current(t)},[]);ce.current=()=>{var t,e,n,i,r,o,a;oe.current=0;const l=re.current;if(!l)return;const s=l.getContext("2d");if(!s)return;const c=he.current;if(!c)return;const u=performance.now(),h=ae.current?Math.min((u-ae.current)/1e3,.1):.016;ae.current=u;const d=c.advanceTransition(u),f=c.tickAnimation([Qt,Jt],h);(d||le.current||f)&&c.buildScene([Qt,Jt]);const y=Ae();if(!Ee(l,Zt,Ut,y))return;s.clearRect(-Ut.left,-Ut.top,Zt[0],Zt[1]),dt&&(s.fillStyle=dt,s.fillRect(0,0,Qt,Jt)),Wt&&c.applyDecay(),$t&&c.applyPulse(u),Ot&&c.applyThresholds(u),c.applyTopologyDiff(u);const g=null!==(t=null==Ct?void 0:Ct.threshold)&&void 0!==t?t:5e3,p=Ct&&c.lastIngestTime>0&&u-c.lastIngestTime>g;if(p&&(s.globalAlpha=null!==(e=null==Ct?void 0:Ct.dimOpacity)&&void 0!==e?e:.5),function(t,e){for(const n of e)switch(n.type){case"bezier":pi(t,n);break;case"line":vi(t,n);break;case"ribbon":mi(t,n);break;case"curved":xi(t,n)}}(s,c.sceneEdges),function(t,e){var n,i,r;for(const o of e){if("rect"!==o.type)continue;const e=o;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!==(i=e.style.strokeWidth)&&void 0!==i?i:1,t.globalAlpha=null!==(r=e.style.opacity)&&void 0!==r?r:1,t.strokeRect(e.x,e.y,e.w,e.h)),Le(t,e),t.restore())}}(s,c.sceneNodes),function(t,e){var n,i,r;for(const o of e){if("circle"!==o.type)continue;const e=o;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!==(i=e.style.strokeWidth)&&void 0!==i?i:1,t.globalAlpha=null!==(r=e.style.opacity)&&void 0!==r?r:1,t.stroke()),De(t,e),t.restore())}}(s,c.sceneNodes),function(t,e){var n,i,r;for(const o of e){if("arc"!==o.type)continue;const e=o;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!==(i=e.style.strokeWidth)&&void 0!==i?i:1,t.globalAlpha=null!==(r=e.style.opacity)&&void 0!==r?r:1,t.stroke()),t.restore()}}(s,c.sceneNodes),G&&c.particlePool&&!p){const t=Array.from(c.edges.values());if(t.length>0){!function(t,e,n,i){var r,o;const a=null!==(r=i.spawnRate)&&void 0!==r?r:Ke.spawnRate,l=null!==(o=i.maxPerEdge)&&void 0!==o?o:Ke.maxPerEdge;for(let i=0;e.length>i;i++){const r=e[i];if(!r.bezier)continue;if(t.countForEdge(i)>=l)continue;const o=r.value*a*n*(r.bezier.circular?.3:1),s=Math.floor(o),c=o-s;let u=s;Math.random()<c&&u++;for(let e=0;u>e&&t.countForEdge(i)<l;e++)t.spawn(i)}}(c.particlePool,t,h,ne);const e=.5*(null!==(n=ne.speedMultiplier)&&void 0!==n?n:1);let i;if(ne.proportionalSpeed){const e=t.reduce((t,e)=>Math.max(t,e.value||1),1);i=t.map(t=>.3+(t.value||1)/e*1.7)}c.particlePool.step(h,e,t,i),function(t,e,n,i,r){var o,a;const l=null!==(o=i.radius)&&void 0!==o?o:Ke.radius,s=null!==(a=i.opacity)&&void 0!==a?a:Ke.opacity;t.globalAlpha=s;for(let o=0;e.particles.length>o;o++){const a=e.particles[o];if(!a.active)continue;const s=n[a.edgeIndex];if(s){if("function"==typeof i.color){const e="object"==typeof s.source?s.source:null;t.fillStyle=e?i.color(s,e):"#666"}else t.fillStyle=i.color&&"inherit"!==i.color?i.color:r(s);t.beginPath(),t.arc(a.x,a.y,l,0,2*Math.PI),t.fill()}}t.globalAlpha=1}(s,c.particlePool,t,ne,$e)}}p&&(s.globalAlpha=1);const v=le.current;if(le.current=!1,v||d||f){const t=re.current;t&&t.setAttribute("aria-label",fe(null!==(r=null===(i=c.sceneNodes)||void 0===i?void 0:i.length)&&void 0!==r?r:0,null!==(a=null===(o=c.sceneEdges)||void 0===o?void 0:o.length)&&void 0!==a?a:0,"Network chart"))}(v||d||f)&&be(t=>t+1),(Ce||d||f||c.hasActivePulses||c.hasActiveThresholds||c.hasActiveTopologyDiff)&&(oe.current=requestAnimationFrame(()=>ce.current()))},i(()=>(Oe(),()=>{oe.current&&(cancelAnimationFrame(oe.current),oe.current=0)}),[Oe]),i(()=>{le.current=!0,Oe()},[b,Qt,Jt,dt,Oe]),jt(Ct,he,le,Oe,ke,Me);const en=ft&&de?t.createElement("div",{className:"stream-network-tooltip",style:{position:"absolute",left:Ut.left+de.x,top:Ut.top+de.y,transform:`translate(${de.x>.6*Qt?"calc(-100% - 12px)":"12px"}, ${.3*Jt>de.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:2,width:"max-content"}},yt?yt(de):t.createElement(Mi,{data:de})):null;if(ue){const e=he.current;if(e){const t=["tree","cluster","treemap","circlepack","partition","orbit"].includes(b),n=t?E||(Array.isArray(w)?void 0:w):void 0;if(t&&n)e.ingestHierarchy(n,[Qt,Jt]),e.buildScene([Qt,Jt]);else{const t=k||[],n=Array.isArray(w)?w:[];(t.length>0||n.length>0)&&(e.ingestBounded(t,n,[Qt,Jt]),e.buildScene([Qt,Jt]))}}const n=null!==(h=null==e?void 0:e.sceneNodes)&&void 0!==h?h:[],i=null!==(d=null==e?void 0:e.sceneEdges)&&void 0!==d?d:[],r=null!==(f=null==e?void 0:e.labels)&&void 0!==f?f:[];return t.createElement("div",{className:"stream-network-frame"+(ht?" "+ht:""),role:"img","aria-label":"string"==typeof Lt?Lt:"Network chart",style:{position:"relative",width:Zt[0],height:Zt[1]}},t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:Zt[0],height:Zt[1],style:{position:"absolute",left:0,top:0}},Tt&&t.createElement("g",{transform:`translate(${Ut.left},${Ut.top})`},Tt),t.createElement("g",{transform:`translate(${Ut.left},${Ut.top})`},dt&&t.createElement("rect",{x:0,y:0,width:Qt,height:Jt,fill:dt}),i.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":case"ribbon":return t.createElement("path",{key:"net-edge-"+n,d:e.pathD,fill:e.style.fill||"#999",fillOpacity:e.style.fillOpacity,stroke:e.style.stroke||"none",strokeWidth:e.style.strokeWidth,opacity:e.style.opacity});case"curved":return t.createElement("path",{key:"net-edge-"+n,d:e.pathD,fill:e.style.fill||"none",stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity});default:return null}}(e,n)).filter(Boolean),n.map((e,n)=>function(e,n){switch(e.type){case"circle":return t.createElement("circle",{key:"net-circle-"+n,cx:e.cx,cy:e.cy,r:e.r,fill:e.style.fill||"#4e79a7",stroke:e.style.stroke,strokeWidth:e.style.strokeWidth,opacity:e.style.opacity});case"rect":return t.createElement("rect",{key:"net-rect-"+n,x:e.x,y:e.y,width:e.w,height:e.h,fill:e.style.fill||"#4e79a7",stroke:e.style.stroke,strokeWidth:e.style.strokeWidth,opacity:e.style.opacity});case"arc":{const i=e,r=Z().innerRadius(i.innerR).outerRadius(i.outerR).startAngle(i.startAngle).endAngle(i.endAngle)({})||"";return t.createElement("path",{key:"net-arc-"+n,d:r,transform:`translate(${i.cx},${i.cy})`,fill:i.style.fill||"#4e79a7",stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})}default:return null}}(e,n)).filter(Boolean),r.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(gi,{width:Qt,height:Jt,totalWidth:Zt[0],totalHeight:Zt[1],margin:Ut,labels:r,sceneNodes:n,title:Lt,legend:Et,legendPosition:At,legendHoverBehavior:Mt,legendClickBehavior:Pt,legendHighlightedCategory:St,legendIsolatedCategories:_t,foregroundGraphics:te,annotations:bt,svgAnnotationRules:kt,annotationFrame:0}))}const nn=he.current;return t.createElement("div",{ref:Kt,className:"stream-network-frame"+(ht?" "+ht:""),role:"img","aria-label":"string"==typeof Lt?Lt:"Network chart",tabIndex:0,style:{position:"relative",width:st?"100%":Zt[0],height:ct?"100%":Zt[1],overflow:"visible"},onMouseMove:ft?tn:void 0,onMouseLeave:ft?Ze:void 0,onClick:pt||vt?Ue:void 0,onKeyDown:Je},Tt&&t.createElement("svg",{style:{position:"absolute",top:0,left:0,width:Zt[0],height:Zt[1],pointerEvents:"none"}},t.createElement("g",{transform:`translate(${Ut.left},${Ut.top})`},Tt)),t.createElement("canvas",{ref:re,"aria-label":fe(null!==(g=null===(y=null==nn?void 0:nn.sceneNodes)||void 0===y?void 0:y.length)&&void 0!==g?g:0,null!==(v=null===(p=null==nn?void 0:nn.sceneEdges)||void 0===p?void 0:p.length)&&void 0!==v?v:0,"Network chart"),style:{position:"absolute",top:0,left:0}}),t.createElement(pe,{hoverPoint:de}),Nt&&t.createElement(ge,{nodes:null!==(m=null==nn?void 0:nn.sceneNodes)&&void 0!==m?m:[],edges:null!==(x=null==nn?void 0:nn.sceneEdges)&&void 0!==x?x:[],chartType:"Network chart"}),t.createElement(gi,{width:Qt,height:Jt,totalWidth:Zt[0],totalHeight:Zt[1],margin:Ut,labels:(null==nn?void 0:nn.labels)||[],sceneNodes:null==nn?void 0:nn.sceneNodes,title:Lt,legend:Et,legendPosition:At,legendHoverBehavior:Mt,legendClickBehavior:Pt,legendHighlightedCategory:St,legendIsolatedCategories:_t,foregroundGraphics:te,annotations:bt,svgAnnotationRules:kt,annotationFrame:xe}),en,(null==Ct?void 0:Ct.showBadge)&&t.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===Ct.badgePosition?{top:4,left:4}:"bottom-left"===Ct.badgePosition?{bottom:4,left:4}:"bottom-right"===Ct.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{background:ke?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"})},ke?"STALE":"LIVE"))});function Si(t){const e=[];for(const[n,i]of Object.entries(t.fields))if("point"===i.type)e.push(t=>i.values.has(t[n]));else{const[t,r]=i.range;e.push(e=>{const i=e[n];return i>=t&&r>=i})}return t=>e.every(e=>e(t))}function _i(t,e){let n=t.get(e);return n||(n={name:e,resolution:"union",clauses:new Map},t.set(e,n)),n}Pi.displayName="StreamNetworkFrame";const[Li,Di]=ve(t=>({selections:new Map,setClause(e,n){t(t=>{const i=new Map(t.selections),r=_i(i,e),o=new Map(r.clauses);return o.set(n.clientId,n),i.set(e,Object.assign(Object.assign({},r),{clauses:o})),{selections:i}})},clearClause(e,n){t(t=>{const i=t.selections.get(e);if(!i)return{};const r=new Map(t.selections),o=new Map(i.clauses);return o.delete(n),r.set(e,Object.assign(Object.assign({},i),{clauses:o})),{selections:r}})},setResolution(e,n){t(t=>{const i=new Map(t.selections),r=_i(i,e);return i.set(e,Object.assign(Object.assign({},r),{resolution:n})),{selections:i}})},clearSelection(e){t(t=>{const n=new Map(t.selections),i=n.get(e);return i&&n.set(e,Object.assign(Object.assign({},i),{clauses:new Map})),{selections:n}})}})),[Ti,Wi]=ve(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 $i(t){const e=h(),n=t.clientId||e,{name:i}=t,o=Di(t=>t.selections.get(i)),a=Di(t=>t.setClause),s=Di(t=>t.clearClause),c=r(()=>!!o&&o.clauses.size>0,[o]);return{predicate:r(()=>o&&0!==o.clauses.size?function(t,e){const n=[];for(const[i,r]of t.clauses)"crossfilter"===t.resolution&&i===e||n.push(Si(r));return 0===n.length?()=>!0:"intersect"===t.resolution?t=>n.every(e=>e(t)):t=>n.some(e=>e(t))}(o,n):()=>!0,[o,n]),isActive:c,selectPoints:l(t=>{const e={};for(const[n,i]of Object.entries(t))e[n]={type:"point",values:new Set(i)};a(i,{clientId:n,type:"point",fields:e})},[n,i,a]),selectInterval:l(t=>{const e={};for(const[n,i]of Object.entries(t))e[n]={type:"interval",range:i};a(i,{clientId:n,type:"interval",fields:e})},[n,i,a]),clear:l(()=>{s(i,n)},[s,i,n]),clientId:n}}function Ci({selection:t,linkedHover:e,fallbackFields:n=[],unwrapData:i=!1,onObservation:r,chartType:o,chartId:a}){const s=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}:null}(e,n),c=$i({name:(null==t?void 0:t.name)||"__unused__"}),u=function(t){const e=t.name||"hover",{fields:n}=t,{predicate:i,isActive:r,selectPoints:o,clear:a}=$i({name:e});return{onHover:l(t=>{if(!t)return void a();const e={};for(const i of n){const n=t[i];void 0!==n&&(e[i]=[n])}Object.keys(e).length>0&&o(e)},[n,o,a,e]),predicate:i,isActive:r}}({name:(null==s?void 0:s.name)||"hover",fields:(null==s?void 0:s.fields)||n||[]}),h=Wi(t=>t.pushObservation);return{activeSelectionHook:t?{isActive:c.isActive,predicate:c.predicate}:null,customHoverBehavior:l(t=>{var n,i;if(e)if(t){let e=t.data||t.datum||t;Array.isArray(e)&&(e=e[0]),u.onHover(e)}else u.onHover(null);if(r||h){const e={timestamp:Date.now(),chartType:o||"unknown",chartId:a};if(t){let o=t.data||t.datum||t;Array.isArray(o)&&(o=o[0]);const a=Object.assign(Object.assign({},e),{type:"hover",datum:o||{},x:null!==(n=t.x)&&void 0!==n?n:0,y:null!==(i=t.y)&&void 0!==i?i:0});r&&r(a),h&&h(a)}else{const t=Object.assign(Object.assign({},e),{type:"hover-end"});r&&r(t),h&&h(t)}}},[e,u,r,o,a,h]),customClickBehavior:l(t=>{var e,n;if(r||h){const i={timestamp:Date.now(),chartType:o||"unknown",chartId:a};if(t){let o=t.data||t.datum||t;Array.isArray(o)&&(o=o[0]);const a=Object.assign(Object.assign({},i),{type:"click",datum:o||{},x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(n=t.y)&&void 0!==n?n:0});r&&r(a),h&&h(a)}else{const t=Object.assign(Object.assign({},i),{type:"click-end"});r&&r(t),h&&h(t)}}},[r,h,o,a])}}const Oi={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 Ni(t,e,n){var i,r,o,a,l,s;const c=Oi[t||"primary"],u="context"===t||"sparkline"===t;return{width:null!==(i=e.width)&&void 0!==i?i:c.width,height:null!==(r=e.height)&&void 0!==r?r:c.height,showAxes:c.showAxes,showGrid:null!==(o=e.showGrid)&&void 0!==o?o:c.showGrid,enableHover:null!==(a=e.enableHover)&&void 0!==a?a:!!e.linkedHover||c.enableHover,showLegend:null!==(l=e.showLegend)&&void 0!==l?l:c.showLegend,showLabels:null!==(s=e.showLabels)&&void 0!==s?s:c.showLabels,title:u?void 0:e.title,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:c.marginDefaults}}"undefined"!=typeof process&&process;const zi={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"},Ii={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function Bi(e,n,i,r){return!1===r||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?t.createElement("div",{style:Object.assign(Object.assign({},zi),{width:n,height:i})},r||"No data available"):null}function ji(e,n,i){if(!e)return null;const r=Math.min(5,Math.floor(i/40)),o=Math.max(8,Math.floor(i/(3*r))),a=Math.max(6,Math.floor(i/(2.5*r))),l=Math.floor((i-(r*(o+a)-a))/2);return t.createElement("div",{style:{width:n,height:i,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"}},Array.from({length:r},(e,i)=>t.createElement("div",{key:i,className:"semiotic-loading-bar",style:Object.assign(Object.assign({},Ii),{position:"absolute",top:l+i*(o+a),left:Math.floor(.1*n),width:30+(37*i+13)%50+"%",height:o,opacity:.5+i%2*.2})})))}const Ri=c(function(n,i){var r,o,a,s;const c=Ni(n.mode,{width:null!==(o=null===(r=n.size)||void 0===r?void 0:r[0])&&void 0!==o?o:n.width,height:null!==(s=null===(a=n.size)||void 0===a?void 0:a[1])&&void 0!==s?s: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:v,timeAccessor:m,valueAccessor:x,timeExtent:b,valueExtent:k,extentPadding:w,stroke:E="#007bff",strokeWidth:A=2,strokeDasharray:M,background:P,tooltipContent:S,tooltip:_,onHover:L,annotations:D,svgAnnotationRules:T,tickFormatTime:W,tickFormatValue:$,decay:C,pulse:O,staleness:N,transition:z,linkedHover:I,selection:B,onObservation:j,chartId:R,loading:F,emptyContent:Y,emphasis:H,legendPosition:X}=n,G=c.showAxes,V=c.enableHover,q=null!=d?d:c.marginDefaults,K=null!=h?h:[c.width,c.height],Z=null!=S?S:_,U=e(null),{customHoverBehavior:Q}=Ci({selection:B,linkedHover:I,unwrapData:!0,onObservation:j,chartType:"RealtimeLineChart",chartId:R}),J=l(t=>{L&&L(t),Q(t)},[L,Q]);u(i,()=>({push:t=>{var e;return null===(e=U.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=U.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=U.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=U.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const tt=ji(F,K[0],K[1]);if(tt)return tt;const et=Bi(v,K[0],K[1],Y);if(et)return et;const nt={stroke:E,strokeWidth:A,strokeDasharray:M};return t.createElement(Ve,{ref:U,chartType:"line",runtimeMode:"streaming",size:K,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:P,hoverAnnotation:V,tooltipContent:Z,customHoverBehavior:J,annotations:D,svgAnnotationRules:T,tickFormatTime:W,tickFormatValue:$,decay:C,pulse:O,staleness:N,transition:z,legendPosition:X})});Ri.displayName="RealtimeLineChart";const Fi=c(function(n,i){var r,o,a,s;const c=Ni(n.mode,{width:null!==(o=null===(r=n.size)||void 0===r?void 0:r[0])&&void 0!==o?o:n.width,height:null!==(s=null===(a=n.size)||void 0===a?void 0:a[1])&&void 0!==s?s:n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0}),{binSize:h,size:d,margin:f,className:y,arrowOfTime:g="right",windowMode:p="sliding",windowSize:v=200,data:m,timeAccessor:x,valueAccessor:b,timeExtent:k,valueExtent:w,extentPadding:E,categoryAccessor:A,colors:M,fill:P,stroke:S,strokeWidth:_,gap:L,background:D,tooltipContent:T,tooltip:W,onHover:$,annotations:C,svgAnnotationRules:O,tickFormatTime:N,tickFormatValue:z,linkedHover:I,selection:B,decay:j,pulse:R,staleness:F,transition:Y,onObservation:H,chartId:X,loading:G,emptyContent:V,emphasis:q,legendPosition:K}=n,Z=c.showAxes,U=c.enableHover,Q=null!=f?f:c.marginDefaults,J=null!=d?d:[c.width,c.height],tt=null!=T?T:W,et=e(null),{customHoverBehavior:nt}=Ci({selection:B,linkedHover:I,unwrapData:!0,onObservation:H,chartType:"RealtimeTemporalHistogram",chartId:X}),it=l(t=>{$&&$(t),nt(t)},[$,nt]);u(i,()=>({push:t=>{var e;return null===(e=et.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=et.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=et.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=et.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const rt=ji(G,J[0],J[1]);if(rt)return rt;const ot=Bi(m,J[0],J[1],V);if(ot)return ot;const at={};return null!=P&&(at.fill=P),null!=S&&(at.stroke=S),null!=_&&(at.strokeWidth=_),null!=L&&(at.gap=L),t.createElement(Ve,{ref:et,chartType:"bar",runtimeMode:"streaming",size:J,margin:Q,className:q?`${y||""} semiotic-emphasis-${q}`.trim():y,arrowOfTime:g,windowMode:p,windowSize:v,data:m,timeAccessor:x,valueAccessor:b,xExtent:k,yExtent:w,extentPadding:E,binSize:h,categoryAccessor:A,barColors:M,barStyle:at,showAxes:Z,background:D,hoverAnnotation:U,tooltipContent:tt,customHoverBehavior:it,annotations:C,svgAnnotationRules:O,tickFormatTime:N,tickFormatValue:z,decay:j,pulse:R,staleness:F,transition:Y,legendPosition:K})});Fi.displayName="RealtimeTemporalHistogram";const Yi=Fi,Hi=c(function(n,i){var r,o,a,s;const c=Ni(n.mode,{width:null!==(o=null===(r=n.size)||void 0===r?void 0:r[0])&&void 0!==o?o:n.width,height:null!==(s=null===(a=n.size)||void 0===a?void 0:a[1])&&void 0!==s?s: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:v,timeAccessor:m,valueAccessor:x,timeExtent:b,valueExtent:k,extentPadding:w,categoryAccessor:E,colors:A,radius:M,fill:P,opacity:S,stroke:_,strokeWidth:L,background:D,tooltipContent:T,tooltip:W,onHover:$,annotations:C,svgAnnotationRules:O,tickFormatTime:N,tickFormatValue:z,linkedHover:I,selection:B,onObservation:j,chartId:R,loading:F,emptyContent:Y,emphasis:H,legendPosition:X}=n,G=c.showAxes,V=c.enableHover,q=null!=d?d:c.marginDefaults,K=null!=h?h:[c.width,c.height],Z=null!=T?T:W,U=e(null),{customHoverBehavior:Q}=Ci({selection:B,linkedHover:I,unwrapData:!0,onObservation:j,chartType:"RealtimeSwarmChart",chartId:R}),J=l(t=>{$&&$(t),Q(t)},[$,Q]);u(i,()=>({push:t=>{var e;return null===(e=U.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=U.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=U.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=U.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const tt=ji(F,K[0],K[1]);if(tt)return tt;const et=Bi(v,K[0],K[1],Y);if(et)return et;const nt={};return null!=M&&(nt.radius=M),null!=P&&(nt.fill=P),null!=S&&(nt.opacity=S),null!=_&&(nt.stroke=_),null!=L&&(nt.strokeWidth=L),t.createElement(Ve,{ref:U,chartType:"swarm",runtimeMode:"streaming",size:K,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:D,hoverAnnotation:V,tooltipContent:Z,customHoverBehavior:J,annotations:C,svgAnnotationRules:O,tickFormatTime:N,tickFormatValue:z,legendPosition:X})});Hi.displayName="RealtimeSwarmChart";const Xi=c(function(n,i){var r,o,a,s;const c=Ni(n.mode,{width:null!==(o=null===(r=n.size)||void 0===r?void 0:r[0])&&void 0!==o?o:n.width,height:null!==(s=null===(a=n.size)||void 0===a?void 0:a[1])&&void 0!==s?s: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:v,timeAccessor:m,valueAccessor:x,timeExtent:b,valueExtent:k,extentPadding:w,positiveColor:E,negativeColor:A,connectorStroke:M,connectorWidth:P,gap:S,stroke:_,strokeWidth:L,background:D,tooltipContent:T,tooltip:W,onHover:$,annotations:C,svgAnnotationRules:O,tickFormatTime:N,tickFormatValue:z,linkedHover:I,selection:B,onObservation:j,chartId:R,loading:F,emptyContent:Y,emphasis:H,legendPosition:X}=n,G=c.showAxes,V=c.enableHover,q=null!=d?d:c.marginDefaults,K=null!=h?h:[c.width,c.height],Z=null!=T?T:W,U=e(null),{customHoverBehavior:Q}=Ci({selection:B,linkedHover:I,unwrapData:!0,onObservation:j,chartType:"RealtimeWaterfallChart",chartId:R}),J=l(t=>{$&&$(t),Q(t)},[$,Q]);u(i,()=>({push:t=>{var e;return null===(e=U.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=U.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=U.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=U.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const tt=ji(F,K[0],K[1]);if(tt)return tt;const et=Bi(v,K[0],K[1],Y);if(et)return et;const nt={};return null!=E&&(nt.positiveColor=E),null!=A&&(nt.negativeColor=A),null!=M&&(nt.connectorStroke=M),null!=P&&(nt.connectorWidth=P),null!=S&&(nt.gap=S),null!=_&&(nt.stroke=_),null!=L&&(nt.strokeWidth=L),t.createElement(Ve,{ref:U,chartType:"waterfall",runtimeMode:"streaming",size:K,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:D,hoverAnnotation:V,tooltipContent:Z,customHoverBehavior:J,annotations:C,svgAnnotationRules:O,tickFormatTime:N,tickFormatValue:z,legendPosition:X})});Xi.displayName="RealtimeWaterfallChart";const Gi=c(function(n,i){var r,o,a,s;const c=Ni(n.mode,{width:null!==(o=null===(r=n.size)||void 0===r?void 0:r[0])&&void 0!==o?o:n.width,height:null!==(s=null===(a=n.size)||void 0===a?void 0:a[1])&&void 0!==s?s: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:v,timeAccessor:m,valueAccessor:x,categoryAccessor:b,timeExtent:k,valueExtent:w,extentPadding:E,heatmapXBins:A=20,heatmapYBins:M=20,aggregation:P="count",background:S,tooltipContent:_,tooltip:L,onHover:D,annotations:T,svgAnnotationRules:W,tickFormatTime:$,tickFormatValue:C,decay:O,pulse:N,staleness:z,linkedHover:I,selection:B,onObservation:j,chartId:R,loading:F,emptyContent:Y,emphasis:H,legendPosition:X}=n,G=c.showAxes,V=c.enableHover,q=null!=d?d:c.marginDefaults,K=null!=h?h:[c.width,c.height],Z=null!=_?_:L,U=e(null),{customHoverBehavior:Q}=Ci({selection:B,linkedHover:I,unwrapData:!0,onObservation:j,chartType:"RealtimeHeatmap",chartId:R}),J=l(t=>{D&&D(t),Q(t)},[D,Q]);u(i,()=>({push:t=>{var e;return null===(e=U.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=U.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=U.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=U.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const tt=ji(F,K[0],K[1]);if(tt)return tt;const et=Bi(v,K[0],K[1],Y);return et||t.createElement(Ve,{ref:U,chartType:"heatmap",runtimeMode:"streaming",size:K,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:P,showAxes:G,background:S,hoverAnnotation:V,tooltipContent:Z,customHoverBehavior:J,annotations:T,svgAnnotationRules:W,tickFormatTime:$,tickFormatValue:C,decay:O,pulse:N,staleness:z,legendPosition:X})});Gi.displayName="RealtimeHeatmap";export{dt as IncrementalExtent,Gi as RealtimeHeatmap,Yi as RealtimeHistogram,Ri as RealtimeLineChart,Hi as RealtimeSwarmChart,Xi as RealtimeWaterfallChart,ht as RingBuffer,Pi as StreamNetworkFrame,Ve as StreamXYFrame};
|
|
1
|
+
import*as t from"react";import{useRef as e,useState as n,useEffect as i,useMemo as r,createContext as o,useContext as l,useCallback as a,useSyncExternalStore as s,forwardRef as c,useImperativeHandle as u,useId as h}from"react";import{brushX as d,brushY as f,brush as y}from"d3-brush";import{select as g}from"d3-selection";import{scaleLinear as p,scaleSequential as v,scaleLog as m}from"d3-scale";import{schemeCategory10 as x,interpolateViridis as b,interpolateGreens as k,interpolateReds as w,interpolateBlues as E}from"d3-scale-chromatic";import{quadtree as A}from"d3-quadtree";import{bin as M,min as P,groups as S,max as _,sum as L,mean as D,group as T}from"d3-array";import{packEnclose as $,hierarchy as W,partition as C,pack as O,treemap as N,treemapBinary as z,cluster as I,tree as B}from"d3-hierarchy";import{area as j,curveCatmullRom as R,curveCardinal as F,curveBasis as Y,curveStepBefore as H,curveStepAfter as X,curveStep as G,curveMonotoneY as V,curveMonotoneX as q,curveLinear as K,arc as U,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 it,forceManyBody as rt,forceCenter as ot,forceX as lt,forceY as at}from"d3-force";import{ribbon as st,chord as ct}from"d3-chord";class ut{constructor(t,e){var n,i;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!==(i=null==e?void 0:e.chunkSize)&&void 0!==i?i: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 i=Math.min(e+this.chunkSize,t.length);this.callback({inserts:t.slice(e,i),bounded:!1}),e=i,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 ht{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 dt{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 ft(t,e,n,i,r){const o=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/i)*i;let c=o.get(s);if(c||(c={start:s,end:s+i,total:0,categories:new Map},o.set(s,c)),c.total+=a,r){const t=r(l);c.categories.set(t,(c.categories.get(t)||0)+a)}}return o}function yt(t,e,n,i,r,o){const l=[];for(const r of t){const t=n(r),o=i(r);null==t||null==o||Number.isNaN(t)||Number.isNaN(o)||l.push({px:e.x(t),py:e.y(o),rawY:o,d:r})}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:r,datum:c,group:o}}function gt(t,e,n,i,r,o,l,a){const s=[];for(const o of t){const t=n(o),l=i(o);if(null==t||null==l||Number.isNaN(t)||Number.isNaN(l))continue;const c=e.x(t),u=a?a(o):r;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:o,datum:t,group:l}}function pt(t,e,n,i,r,o,l){const a=n(t),s=i(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:r,style:o,datum:t};return void 0!==l&&(c.pointId=l),c}function vt(t,e,n,i,r,o,l){return{type:"rect",x:t,y:e,w:n,h:i,style:r,datum:o,group:l}}function mt(t,e,n,i,r,o,l){const a={type:"heatcell",x:t,y:e,w:n,h:i,fill:r,datum:o};return(null==l?void 0:l.showValues)&&(a.showValues=!0,a.value=l.value,l.valueFormat&&(a.valueFormat=l.valueFormat)),a}function xt(t,e){return t===e||typeof t==typeof e&&"function"==typeof t&&"function"==typeof e&&""+t==""+e}function bt(t,e){if("function"==typeof t)return e=>+t(e);const n=t||e;return t=>+t[n]}function kt(t,e){if("function"==typeof t)return t;const n=t||e;return t=>t[n]}function wt(t,e){return"function"==typeof t?t:t?e=>e[t]+"":void 0}const Et=x,At=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];function Mt(t,e="ease-out-cubic"){return"linear"===e?t:1-Math.pow(1-t,3)}function Pt(t,e){return Math.min((t-e.startTime)/e.duration,1)}function St(t,e,n){return t+(e-t)*n}class _t{constructor(t){this.xExtent=new dt,this.yExtent=new dt,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._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 ht(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=bt(t.timeAccessor||t.xAccessor,"time"),this.getY=bt(t.valueAccessor||t.yAccessor,"value")):(this.getX=bt(t.xAccessor,"x"),this.getY=bt(t.yAccessor,"y")),this.getGroup=wt(t.groupAccessor),this.getCategory=wt(t.categoryAccessor),this.getSize=t.sizeAccessor?bt(t.sizeAccessor,"size"):void 0,this.getColor=wt(t.colorAccessor),this.getBounds=t.boundsAccessor?bt(t.boundsAccessor,"bounds"):void 0,this.getY0=t.y0Accessor?bt(t.y0Accessor,"y0"):void 0,this.getPointId=wt(t.pointIdAccessor),"candlestick"===t.chartType&&(this.getOpen=bt(t.openAccessor,"open"),this.getHigh=bt(t.highAccessor,"high"),this.getLow=bt(t.lowAccessor,"low"),this.getClose=bt(t.closeAccessor,"close")),t.pulse&&(this.timestampBuffer=new ht(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?bt(this.config.timeAccessor||this.config.xAccessor,"time"):bt(this.config.xAccessor,"x"),this.xIsDate=!1,t.inserts.length>0){const e=t.inserts[0],n=this.config.xAccessor,i="function"==typeof n?n(e):e[n||"x"],r=i instanceof Date,o="string"==typeof i&&i.length>=10&&!isNaN(new Date(i).getTime())&&isNaN(Number(i));if(this.xIsDate=r||o,o){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,i,r,o,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!==(i=a.yExtent[0])&&void 0!==i?i:h[0],null!==(r=a.yExtent[1])&&void 0!==r?r: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),i=this.getY(e);null==t||null==i||Number.isNaN(t)||Number.isNaN(i)||n.set(t,(n.get(t)||0)+i)}let i=0;for(const t of n.values())t>i&&(i=t);f=[0,i+(i>0?i*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,i,r){const o=ft(t,e,n,i,r);if(0===o.size)return[0,0];let l=0;for(const t of o.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,i=0,r=0;for(const o of t){const t=e(o);null==t||Number.isNaN(t)||(r+=t,n>r&&(n=r),r>i&&(i=r))}return[n,i]}(s,this.getY),n=e-t,i=n>0?n*a.extentPadding:1;f=[Math.min(0,t-Math.abs(i)),Math.max(0,e+Math.abs(i))]}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===(o=a.yExtent)||void 0===o?void 0:o[0],i=null===(l=a.yExtent)||void 0===l?void 0:l[1];f=[null!=n?f[0]:f[0]-e,null!=i?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:p().domain(d).range(e),y:p().domain(f).range([t.height,0])}}else{const e="down"===a.arrowOfTime?[0,t.height]:[t.height,0];this.scales={x:p().domain(f).range([0,t.width]),y:p().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 m().domain(t).range(n).clamp(!0)}return p().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>_t.QUADTREE_THRESHOLD?A().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 i of t.path)i[0]*=e,i[1]*=n;break;case"area":for(const i of t.topPath)i[0]*=e,i[1]*=n;for(const i of t.bottomPath)i[0]*=e,i[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 i=this.scales.x.domain(),r=this.scales.y.domain(),o=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 m().domain(t).range(n).clamp(!0)}return p().domain(e).range(n)};this.scales={x:a(this.config.xScaleType,i,[o[0]*e,o[1]*e]),y:a(this.config.yScaleType,r,[l[0]*n,l[1]*n])},this.lastLayout={width:t.width,height:t.height},this.rebuildQuadtree(),this.version++}buildSceneNodes(t,e){const{config:n,scales:i}=this;if(!i||0===e.length)return[];switch(n.chartType){case"line":return this.buildLineScene(e);case"area":return this.buildAreaScene(e);case"stackedarea":return this.buildStackedAreaScene(e);case"scatter":case"bubble":return this.buildPointScene(e);case"heatmap":return this.buildHeatmapScene(e,t);case"bar":return this.buildBarScene(e);case"swarm":return this.buildSwarmScene(e);case"waterfall":return this.buildWaterfallScene(e,t);case"candlestick":return this.buildCandlestickScene(e,t);default:return[]}}buildLineScene(t){var e;const n=this.groupData(t),i=[],r=null===(e=this.config.annotations)||void 0===e?void 0:e.filter(t=>"threshold"===t.type&&t.color).map(t=>({value:t.value,color:t.color,thresholdType:t.thresholdType||"greater"}));if(this.getBounds)for(const t of n){const e=this.buildBoundsForGroup(t.data,t.key);e&&i.push(e)}for(const t of n){const e=this.resolveLineStyle(t.key,t.data[0]),n=yt(t.data,this.scales,this.getX,this.getY,e,t.key);r&&r.length>0&&(n.colorThresholds=r),this.config.curve&&"linear"!==this.config.curve&&(n.curve=this.config.curve),i.push(n)}return i}buildAreaScene(t){const e=this.groupData(t),n=[],i=this.scales.y.domain()[0];for(const t of e){const e=this.resolveAreaStyle(t.key,t.data[0]),r=gt(t.data,this.scales,this.getX,this.getY,i,e,t.key,this.getY0);this.config.gradientFill&&(r.fillGradient=this.config.gradientFill),this.config.curve&&"linear"!==this.config.curve&&(r.curve=this.config.curve),n.push(r)}return n}buildStackedAreaScene(t){const e=this.groupData(t);return e.sort((t,e)=>e.key>t.key?-1:t.key>e.key?1:0),function(t,e,n,i,r,o,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 r of e.data){const e=n(r),o=i(r);null==e||null==o||Number.isNaN(e)||Number.isNaN(o)||t.set(e,(t.get(e)||0)+o)}u.set(e.key,t)}let h;if(o){h=new Map;for(const e of c){let n=0;for(const i of t)n+=(null===(a=u.get(i.key))||void 0===a?void 0:a.get(e))||0;h.set(e,n||1)}}const d=[],f=new Map;for(const t of c)f.set(t,0);for(const n of t){const t=u.get(n.key),i=[],a=[];for(const n of c){let r=t.get(n)||0;const l=f.get(n);o&&(r/=h.get(n));const s=e.x(n);a.push([s,e.y(l)]),i.push([s,e.y(l+r)]),f.set(n,l+r)}const s={type:"area",topPath:i,bottomPath:a,style:r(n.key,n.data[0]),datum:n.data,group:n.key};l&&(s.curve=l),d.push(s)}return d}(e,this.scales,this.getX,this.getY,(t,e)=>this.resolveAreaStyle(t,e),this.config.normalize,this.config.curve&&"linear"!==this.config.curve?this.config.curve:void 0)}buildPointScene(t){const e=[],n="bubble"===this.config.chartType?10:5,i=this.config.sizeRange||[3,15];let r=null;if(this.getSize&&!this.config.pointStyle){const e=t.map(t=>this.getSize(t)).filter(t=>null!=t&&!Number.isNaN(t));if(e.length>0){let t=1/0,n=-1/0;for(const i of e)t>i&&(t=i),i>n&&(n=i);r=e=>t===n?(i[0]+i[1])/2:i[0]+(e-t)/(n-t)*(i[1]-i[0])}}const o=this.getColor?this.resolveColorMap(t):null;for(const i of t){let t=this.config.pointStyle?this.config.pointStyle(i):{fill:"#4e79a7",opacity:.8},l=t.r||n;if(r&&this.getSize){const t=this.getSize(i);null==t||Number.isNaN(t)||(l=r(t))}if(o&&this.getColor&&!t.fill){const e=this.getColor(i);e&&o.has(e)&&(t=Object.assign(Object.assign({},t),{fill:o.get(e)}))}const a=this.getPointId?this.getPointId(i)+"":void 0,s=pt(i,this.scales,this.getX,this.getY,l,t,a);s&&e.push(s)}return e}buildHeatmapScene(t,e){const n=[];if(this.config.heatmapAggregation)return this.buildStreamingHeatmapScene(t,e);const i=bt(this.config.valueAccessor,"value"),r=kt(this.config.xAccessor,"x"),o=kt(this.config.yAccessor,"y"),l=new Set,a=new Set;for(const e of t)l.add(r(e)),a.add(o(e));const s=Array.from(l),c=Array.from(a),u=s.every(t=>"number"==typeof t&&!isNaN(t)),h=c.every(t=>"number"==typeof t&&!isNaN(t)),d=u?s.sort((t,e)=>t-e):s,f=h?c.sort((t,e)=>t-e):c;if(0===d.length||0===f.length)return n;const y=e.width/d.length,g=e.height/f.length,p=new Map;for(const e of t){const t=`${r(e)}\0${o(e)}`;p.set(t,{val:i(e),datum:e})}let m=1/0,x=-1/0;for(const{val:t}of p.values())m>t&&(m=t),t>x&&(x=t);const A=v({blues:E,reds:w,greens:k,viridis:b}["string"==typeof this.config.colorScheme?this.config.colorScheme:"blues"]||E).domain([m,x]);for(let t=0;d.length>t;t++)for(let e=0;f.length>e;e++){const i=p.get(`${d[t]}\0${f[e]}`);if(!i)continue;const r=A(i.val);n.push(mt(t*y,(f.length-1-e)*g,y,g,r,i.datum,this.config.showValues?{value:i.val,showValues:!0,valueFormat:this.config.heatmapValueFormat}:void 0))}return n}buildStreamingHeatmapScene(t,e){var n,i,r;const o=[],l=null!==(n=this.config.heatmapXBins)&&void 0!==n?n:20,a=null!==(i=this.config.heatmapYBins)&&void 0!==i?i:20,s=null!==(r=this.config.heatmapAggregation)&&void 0!==r?r:"count",c=bt(this.config.valueAccessor,"value");if(!this.scales||0===t.length)return o;const[u,h]=this.scales.x.domain(),[d,f]=this.scales.y.domain(),y=(h-u||1)/l,g=(f-d||1)/a,p=new Map;for(const e of t){const t=this.getX(e),n=this.getY(e),i=Math.min(Math.floor((t-u)/y),l-1),r=Math.min(Math.floor((n-d)/g),a-1);if(0>i||0>r)continue;const o=`${i}_${r}`;let s=p.get(o);s||(s={sum:0,count:0,data:[]},p.set(o,s)),s.count++,s.sum+=c(e),s.data.push(e)}let v=1/0,m=-1/0;const x=new Map;for(const[t,e]of p){let n;switch(s){case"sum":n=e.sum;break;case"mean":n=e.count>0?e.sum/e.count:0;break;default:n=e.count}x.set(t,n),v>n&&(v=n),n>m&&(m=n)}const b=m-v||1,k=e.width/l,w=e.height/a;for(const[t,e]of x){const[n,i]=t.split("_"),r=+n,l=+i,s=(e-v)/b,c=`rgb(${Math.round(220-180*s)},${Math.round(220-100*s)},${Math.round(255-50*s)})`,u=p.get(t);o.push(mt(r*k,(a-1-l)*w,k,w,c,{xi:r,yi:l,value:e,count:u.count,sum:u.sum,data:u.data},this.config.showValues?{value:e,showValues:!0,valueFormat:this.config.heatmapValueFormat}:void 0))}return o}buildBarScene(t){var e;if(!this.config.binSize)return[];const n=ft(t,this.getX,this.getY,this.config.binSize,this.getCategory);if(0===n.size)return[];let i=null;if(this.getCategory){const t=new Set;for(const e of n.values())for(const n of e.categories.keys())t.add(n);const e=this.config.barColors?Object.keys(this.config.barColors):[],r=new Set(e),o=Array.from(t).filter(t=>!r.has(t)).sort(),l=e.filter(e=>t.has(e)),a=l.join("\0")+""+o.join("\0");this._barCategoryCache&&this._barCategoryCache.key===a?i=this._barCategoryCache.order:(i=[...l,...o],this._barCategoryCache={key:a,order:i})}const r=[],o=this.scales,[l,a]=o.x.domain();for(const t of n.values()){const n=Math.max(t.start,l),s=Math.min(t.end,a);if(n>=s)continue;const c=o.x(n),u=o.x(s),h=Math.abs(u-c),d=h>2?1:0,f=Math.min(c,u)+d/2,y=Math.max(h-d,1);if(y>0)if(i&&t.categories.size>0){let n=0;for(const l of i){const i=t.categories.get(l)||0;if(0===i)continue;const a=o.y(n),s=o.y(n+i);r.push(vt(f,Math.min(a,s),y,Math.abs(a-s),{fill:(null===(e=this.config.barColors)||void 0===e?void 0:e[l])||"#4e79a7"},{binStart:t.start,binEnd:t.end,total:t.total,category:l,categoryValue:i},l)),n+=i}}else{const e=o.y(0),n=o.y(t.total);r.push(vt(f,Math.min(e,n),y,Math.abs(e-n),{fill:"#007bff"},{binStart:t.start,binEnd:t.end,total:t.total}))}}return r}buildSwarmScene(t){var e,n,i,r;const o=[],l=this.config.swarmStyle||{},a=null!==(e=l.radius)&&void 0!==e?e:3,s=null!==(n=l.fill)&&void 0!==n?n:"#007bff",c=null!==(i=l.opacity)&&void 0!==i?i:.7,u=l.stroke,h=l.strokeWidth;for(const e of t){const t=this.getX(e),n=this.getY(e);if(null==n||Number.isNaN(n))continue;const i=this.scales.x(t),l=this.scales.y(n);let d=s;if(this.getCategory){const t=this.getCategory(e);d=(null===(r=this.config.barColors)||void 0===r?void 0:r[t])||d}const f={type:"point",x:i,y:l,r:a,style:{fill:d,opacity:c,stroke:u,strokeWidth:h},datum:e};this.getPointId&&(f.pointId=this.getPointId(e)+""),o.push(f)}return o}buildWaterfallScene(t,e){var n,i,r;const o=[],l=this.scales,a=this.config.waterfallStyle,s=t.filter(t=>{const e=this.getY(t);return null!=e&&!Number.isNaN(e)});if(0===s.length)return o;const c=null!==(n=null==a?void 0:a.positiveColor)&&void 0!==n?n:"#28a745",u=null!==(i=null==a?void 0:a.negativeColor)&&void 0!==i?i:"#dc3545",h=null!==(r=null==a?void 0:a.gap)&&void 0!==r?r:1,d=null==a?void 0:a.stroke,f=null==a?void 0:a.strokeWidth;let y=0;for(let t=0;s.length>t;t++){const n=s[t],i=this.getX(n),r=this.getY(n),g=y+r;let p;p=s.length-1>t?this.getX(s[t+1])-i:t>0?i-this.getX(s[t-1]):0;const v=l.x(i),m=0!==p?l.x(i+p):v+e.width/10,x=Math.min(v,m)+h/2,b=Math.max(v,m)-h/2-x;if(0>=b){y=g;continue}const k=l.y(y),w=l.y(g);o.push(vt(x,Math.min(k,w),b,Math.abs(k-w),{fill:0>r?u:c,stroke:d,strokeWidth:f},Object.assign(Object.assign({},n),{baseline:y,cumEnd:g,delta:r,_connectorStroke:null==a?void 0:a.connectorStroke,_connectorWidth:null==a?void 0:a.connectorWidth}))),y=g}return o}buildCandlestickScene(t,e){if(!(this.getOpen&&this.getHigh&&this.getLow&&this.getClose&&this.scales))return[];const n=[],i=this.config.candlestickStyle||{},r=i.upColor||"#28a745",o=i.downColor||"#dc3545",l=i.wickColor||"#333",a=i.wickWidth||1,s=t.map(t=>this.getX(t)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let c=i.bodyWidth||6;if(!i.bodyWidth&&s.length>1){let t=1/0;for(let e=1;s.length>e;e++){const n=Math.abs(this.scales.x(s[e])-this.scales.x(s[e-1]));n>0&&t>n&&(t=n)}t!==1/0&&(c=Math.max(2,Math.min(.6*t,20)))}for(const e of t){const t=this.getX(e);if(null==t||Number.isNaN(t))continue;const i=this.getOpen(e),s=this.getHigh(e),u=this.getLow(e),h=this.getClose(e);if([i,s,u,h].some(t=>null==t||Number.isNaN(t)))continue;const d=h>=i;n.push({type:"candlestick",x:this.scales.x(t),openY:this.scales.y(i),closeY:this.scales.y(h),highY:this.scales.y(s),lowY:this.scales.y(u),bodyWidth:c,upColor:r,downColor:o,wickColor:l,wickWidth:a,isUp:d,datum:e})}return n}buildBoundsForGroup(t,e){if(!this.getBounds||!this.scales)return null;const n=[],i=[];for(const e of t){const t=this.getX(e),r=this.getY(e);if(null==t||null==r||Number.isNaN(t)||Number.isNaN(r))continue;const o=this.getBounds(e),l=this.scales.x(t);if(o&&0!==o)n.push([l,this.scales.y(r+o)]),i.push([l,this.scales.y(r-o)]);else{const t=this.scales.y(r);n.push([l,t]),i.push([l,t])}}return 2>n.length?null:{type:"area",topPath:n,bottomPath:i,style:this.resolveBoundsStyle(e,t[0]),datum:t,group:e,interactive:!1}}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){var n,i,r;const o=this.config.decay;if(!o||1>=e)return 1;const l=null!==(n=o.minOpacity)&&void 0!==n?n:.1,a=e-1-t;switch(o.type){case"linear":return l+(1-a/(e-1))*(1-l);case"exponential":{const t=null!==(i=o.halfLife)&&void 0!==i?i:e/2;return l+Math.pow(.5,a/t)*(1-l)}case"step":return(null!==(r=o.stepThreshold)&&void 0!==r?r:.5*e)>a?1:l;default:return 1}}applyDecay(t,e){var n,i;if(!this.config.decay)return;const r=e.length;if(1>=r)return;const o=new Map;for(let t=0;e.length>t;t++)o.set(e[t],t);for(const e of t){if("line"===e.type){const t=Array.isArray(e.datum)?e.datum:[];if(2>t.length)continue;const n=Array(t.length);let i=!1;for(let e=0;t.length>e;e++){const l=o.get(t[e]);null!=l?(n[e]=this.computeDecayOpacity(l,r),1>n[e]&&(i=!0)):n[e]=1}i&&(e._decayOpacities=n);continue}if("area"===e.type){const t=Array.isArray(e.datum)?e.datum:[],n=e.topPath?e.topPath.length:t.length;if(2>n)continue;if(t.length===n){const i=Array(n);let l=!1;for(let e=0;t.length>e;e++){const n=o.get(t[e]);null!=n?(i[e]=this.computeDecayOpacity(n,r),1>i[e]&&(l=!0)):i[e]=1}l&&(e._decayOpacities=i)}else{let i=1;for(const e of t){const t=o.get(e);if(null!=t){const e=this.computeDecayOpacity(t,r);i>e&&(i=e)}}if(1>i){const t=Array(n);t.fill(i),e._decayOpacities=t}}continue}const t=o.get(e.datum);if(null==t)continue;const l=this.computeDecayOpacity(t,r);if("heatcell"===e.type)e.style={opacity:l};else if("candlestick"===e.type)e._decayOpacity=l;else{const t=null!==(i=null===(n=e.style)||void 0===n?void 0:n.opacity)&&void 0!==i?i:1;e.style=Object.assign(Object.assign({},e.style),{opacity:t*l})}}}computePulseIntensity(t,e){var n;const i=this.config.pulse;if(!i)return 0;const r=null!==(n=i.duration)&&void 0!==n?n:500,o=e-t;return r>o?1-o/r:0}applyPulse(t,e){var n,i;if(!this.config.pulse||!this.timestampBuffer)return;const r="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(n=this.config.pulse.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",l=null!==(i=this.config.pulse.glowRadius)&&void 0!==i?i:4,a=new Map;for(let t=0;e.length>t;t++)a.set(e[t],t);for(const e of t){if("line"===e.type)continue;if("area"===e.type){const t=Array.isArray(e.datum)?e.datum:[e.datum];let n=0;for(const e of t){const t=a.get(e);if(null==t)continue;const i=this.timestampBuffer.get(t);if(null==i)continue;const o=this.computePulseIntensity(i,r);o>n&&(n=o)}n>0&&(e._pulseIntensity=n,e._pulseColor=o);continue}const t=a.get(e.datum);if(null==t)continue;const n=this.timestampBuffer.get(t);if(null==n)continue;const i=this.computePulseIntensity(n,r);i>0&&(e._pulseIntensity=i,e._pulseColor=o,e._pulseGlowRadius=l)}}get hasActivePulses(){var t;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const e="undefined"!=typeof performance?performance.now():Date.now(),n=null!==(t=this.config.pulse.duration)&&void 0!==t?t:500,i=this.timestampBuffer.peek();return null!=i&&n>e-i}snapshotPositions(){var t,e,n;this.prevPositionMap.clear(),this.prevPathMap.clear();for(let i=0;this.scene.length>i;i++){const r=this.scene[i],o=this.getNodeIdentity(r,i);o&&("point"===r.type?this.prevPositionMap.set(o,{x:r.x,y:r.y,r:r.r,opacity:r.style.opacity}):"rect"===r.type?this.prevPositionMap.set(o,{x:r.x,y:r.y,w:r.w,h:r.h,opacity:r.style.opacity}):"heatcell"===r.type?this.prevPositionMap.set(o,{x:r.x,y:r.y,w:r.w,h:r.h,opacity:null===(t=r.style)||void 0===t?void 0:t.opacity}):"candlestick"===r.type?this.prevPositionMap.set(o,{x:r.x,y:r.openY}):"line"===r.type?this.prevPathMap.set(o,{path:r.path.map(t=>[t[0],t[1]]),opacity:null===(e=r.style)||void 0===e?void 0:e.opacity}):"area"===r.type&&this.prevPathMap.set(o,{topPath:r.topPath.map(t=>[t[0],t[1]]),bottomPath:r.bottomPath.map(t=>[t[0],t[1]]),opacity:null===(n=r.style)||void 0===n?void 0:n.opacity}))}}getNodeIdentity(t,e){var n,i,r,o;switch(t.type){case"point":if(t.pointId)return"p:"+t.pointId;if("streaming"===this.config.runtimeMode&&t.datum){if(this.getCategory)return`p:${this.getCategory(t.datum)}:${this.getY(t.datum)}`;const e=this.getX(t.datum),n=this.getY(t.datum);if(null!=e&&null!=n)return`p:${e}:${n}`}return"p:"+e;case"rect":return`r:${t.group||""}:${null!==(o=null!==(i=null===(n=t.datum)||void 0===n?void 0:n.binStart)&&void 0!==i?i:null===(r=t.datum)||void 0===r?void 0:r.category)&&void 0!==o?o:e}`;case"heatcell":return`h:${t.x}_${t.y}`;case"candlestick":return null==t.datum?"c:"+e:"c:"+this.getX(t.datum);case"line":return"l:"+(t.group||"_default");case"area":return"a:"+(t.group||"_default");default:return null}}startTransition(){var t,e,n,i,r,o,l,a,s,c,u,h,d,f,y,g,p,v,m,x,b,k,w,E,A,M;if(!this.config.transition||0===this.prevPositionMap.size&&0===this.prevPathMap.size)return;const P=null!==(t=this.config.transition.duration)&&void 0!==t?t:300;if(this.exitNodes.length>0){const t=new Set(this.exitNodes);this.scene=this.scene.filter(e=>!t.has(e)),this.exitNodes=[]}let S=!1;const _=new Set,L=new Set;for(let t=0;this.scene.length>t;t++){const p=this.scene[t],v=this.getNodeIdentity(p,t);if(!v)continue;if(p._transitionKey=v,"line"===p.type||"area"===p.type){const t=this.prevPathMap.get(v);if(t){if(L.add(v),"line"===p.type&&t.path&&t.path.length===p.path.length){p._targetPath=p.path.map(t=>[t[0],t[1]]),p._prevPath=t.path;for(let e=0;p.path.length>e;e++)p.path[e]=[t.path[e][0],t.path[e][1]];S=!0}else if("area"===p.type&&t.topPath&&t.bottomPath&&t.topPath.length===p.topPath.length&&t.bottomPath.length===p.bottomPath.length){p._targetTopPath=p.topPath.map(t=>[t[0],t[1]]),p._targetBottomPath=p.bottomPath.map(t=>[t[0],t[1]]),p._prevTopPath=t.topPath,p._prevBottomPath=t.bottomPath;for(let e=0;p.topPath.length>e;e++)p.topPath[e]=[t.topPath[e][0],t.topPath[e][1]];for(let e=0;p.bottomPath.length>e;e++)p.bottomPath[e]=[t.bottomPath[e][0],t.bottomPath[e][1]];S=!0}p._targetOpacity=null!==(e=p.style.opacity)&&void 0!==e?e:1}else p._targetOpacity=null!==(n=p.style.opacity)&&void 0!==n?n:1,p.style=Object.assign(Object.assign({},p.style),{opacity:0}),S=!0;continue}const m=this.prevPositionMap.get(v);if("point"===p.type)if(m){_.add(v);const t={x:p.x,y:p.y,r:p.r};p._targetOpacity=null!==(i=p.style.opacity)&&void 0!==i?i:1,m.x===t.x&&m.y===t.y||(p._targetX=t.x,p._targetY=t.y,p._targetR=t.r,p.x=m.x,p.y=m.y,p.r=null!==(r=m.r)&&void 0!==r?r:p.r,S=!0)}else p._targetOpacity=null!==(o=p.style.opacity)&&void 0!==o?o:1,p.style=Object.assign(Object.assign({},p.style),{opacity:0}),S=!0;else if("rect"===p.type)if(m){_.add(v);const t={x:p.x,y:p.y,w:p.w,h:p.h};p._targetOpacity=null!==(l=p.style.opacity)&&void 0!==l?l:1,m.x===t.x&&m.y===t.y&&m.w===t.w&&m.h===t.h||(p._targetX=t.x,p._targetY=t.y,p._targetW=t.w,p._targetH=t.h,p.x=m.x,p.y=m.y,p.w=null!==(a=m.w)&&void 0!==a?a:p.w,p.h=null!==(s=m.h)&&void 0!==s?s:p.h,S=!0)}else p._targetOpacity=null!==(c=p.style.opacity)&&void 0!==c?c:1,p.style=Object.assign(Object.assign({},p.style),{opacity:0}),S=!0;else if("heatcell"===p.type)if(m){_.add(v);const t={x:p.x,y:p.y,w:p.w,h:p.h};p._targetOpacity=null!==(h=null===(u=p.style)||void 0===u?void 0:u.opacity)&&void 0!==h?h:1,m.x===t.x&&m.y===t.y||(p._targetX=t.x,p._targetY=t.y,p._targetW=t.w,p._targetH=t.h,p.x=m.x,p.y=m.y,p.w=null!==(d=m.w)&&void 0!==d?d:p.w,p.h=null!==(f=m.h)&&void 0!==f?f:p.h,S=!0)}else p._targetOpacity=null!==(g=null===(y=p.style)||void 0===y?void 0:y.opacity)&&void 0!==g?g:1,p.style=Object.assign(Object.assign({},p.style||{}),{opacity:0}),S=!0}for(const[t,e]of this.prevPathMap)if(!L.has(t))if(t.startsWith("l:")&&e.path){const n={type:"line",path:e.path.map(t=>[t[0],t[1]]),group:t.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:null!==(p=e.opacity)&&void 0!==p?p:1},_targetOpacity:0,_transitionKey:t,datum:null};this.exitNodes.push(n),S=!0}else if(t.startsWith("a:")&&e.topPath&&e.bottomPath){const n={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!==(v=e.opacity)&&void 0!==v?v:1},_targetOpacity:0,_transitionKey:t,datum:null};this.exitNodes.push(n),S=!0}for(const[t,e]of this.prevPositionMap)if(!_.has(t)){if(t.startsWith("p:")){const n={type:"point",x:e.x,y:e.y,r:null!==(m=e.r)&&void 0!==m?m:3,style:{opacity:null!==(x=e.opacity)&&void 0!==x?x:1},datum:null,_targetOpacity:0,_transitionKey:t};this.exitNodes.push(n)}else if(t.startsWith("r:")){const n={type:"rect",x:e.x,y:e.y,w:null!==(b=e.w)&&void 0!==b?b:0,h:null!==(k=e.h)&&void 0!==k?k:0,style:{opacity:null!==(w=e.opacity)&&void 0!==w?w:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t};this.exitNodes.push(n)}else if(t.startsWith("h:")){const n={type:"heatcell",x:e.x,y:e.y,w:null!==(E=e.w)&&void 0!==E?E:0,h:null!==(A=e.h)&&void 0!==A?A:0,fill:"#999",datum:null,style:{opacity:null!==(M=e.opacity)&&void 0!==M?M:1},_targetOpacity:0,_transitionKey:t};this.exitNodes.push(n)}S=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),S&&(this.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:P})}advanceTransition(t){var e,n,i,r,o,l;if(!this.activeTransition)return!1;const a=Pt(t,this.activeTransition),s=Mt(a,"linear"===(null===(e=this.config.transition)||void 0===e?void 0:e.easing)?"linear":"ease-out-cubic");for(const t of this.scene){const e=t._transitionKey;if("point"===t.type){if(void 0!==t._targetOpacity){const i=e?this.prevPositionMap.get(e):void 0,r=i?null!==(n=i.opacity)&&void 0!==n?n:1:0;t.style.opacity=St(r,t._targetOpacity,s)}if(void 0===t._targetX)continue;if(!e)continue;const i=this.prevPositionMap.get(e);if(!i)continue;t.x=St(i.x,t._targetX,s),t.y=St(i.y,t._targetY,s),void 0!==t._targetR&&void 0!==i.r&&(t.r=St(i.r,t._targetR,s))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const n=e?this.prevPositionMap.get(e):void 0,r=n?null!==(i=n.opacity)&&void 0!==i?i:1:0;t.style.opacity=St(r,t._targetOpacity,s)}if(void 0===t._targetX)continue;if(!e)continue;const n=this.prevPositionMap.get(e);if(!n)continue;t.x=St(n.x,t._targetX,s),t.y=St(n.y,t._targetY,s),void 0!==n.w&&(t.w=St(n.w,t._targetW,s)),void 0!==n.h&&(t.h=St(n.h,t._targetH,s))}else if("heatcell"===t.type){if(void 0!==t._targetOpacity){const n=e?this.prevPositionMap.get(e):void 0,i=n?null!==(r=n.opacity)&&void 0!==r?r:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:St(i,t._targetOpacity,s)})}if(void 0===t._targetX)continue;if(!e)continue;const n=this.prevPositionMap.get(e);if(!n)continue;t.x=St(n.x,t._targetX,s),t.y=St(n.y,t._targetY,s),void 0!==n.w&&(t.w=St(n.w,t._targetW,s)),void 0!==n.h&&(t.h=St(n.h,t._targetH,s))}else if("line"===t.type){if(void 0!==t._targetOpacity){const e=void 0===t._prevPath&&t._targetOpacity>0?0:null!==(o=t.style.opacity)&&void 0!==o?o:1;t.style=Object.assign(Object.assign({},t.style),{opacity:St(e,t._targetOpacity,s)})}const e=t._prevPath,n=t._targetPath;if(e&&n&&e.length===t.path.length)for(let i=0;t.path.length>i;i++)t.path[i][0]=St(e[i][0],n[i][0],s),t.path[i][1]=St(e[i][1],n[i][1],s)}else if("area"===t.type){if(void 0!==t._targetOpacity){const e=void 0===t._prevTopPath&&t._targetOpacity>0?0:null!==(l=t.style.opacity)&&void 0!==l?l:1;t.style=Object.assign(Object.assign({},t.style),{opacity:St(e,t._targetOpacity,s)})}const e=t._prevTopPath,n=t._prevBottomPath,i=t._targetTopPath,r=t._targetBottomPath;if(e&&i&&e.length===t.topPath.length)for(let n=0;t.topPath.length>n;n++)t.topPath[n][0]=St(e[n][0],i[n][0],s),t.topPath[n][1]=St(e[n][1],i[n][1],s);if(n&&r&&n.length===t.bottomPath.length)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e][0]=St(n[e][0],r[e][0],s),t.bottomPath[e][1]=St(n[e][1],r[e][1],s)}}if(a>=1){for(const t of this.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(this.exitNodes.length>0){const t=new Set(this.exitNodes);this.scene=this.scene.filter(e=>!t.has(e)),this.exitNodes=[]}return this.activeTransition=null,!1}return!0}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(),i=n.join("\0");if(this._colorMapCache&&this._colorMapCache.key===i)return this._colorMapCache.map;const r=Array.isArray(this.config.colorScheme)?this.config.colorScheme:At,o=new Map;for(let t=0;n.length>t;t++)o.set(n[t],r[t%r.length]);return this._colorMapCache={key:i,map:o},o}resolveLineStyle(t,e){const n=this.config.lineStyle;if("function"==typeof n){const i=n(e||{},t);if(i&&!i.stroke&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},i),{stroke:e})}return i}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 i=this.config.lineStyle;if("function"==typeof i){const n=i(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 i&&"object"==typeof i?{fill:i.fill||i.stroke||"#4e79a7",fillOpacity:null!==(n=i.fillOpacity)&&void 0!==n?n:.7,stroke:i.stroke||"#4e79a7",strokeWidth:i.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:At,i=n[this._groupColorMap.size%n.length];return this._groupColorMap.set(t,i),i}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}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._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,i,r;const o=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!==o.chartType||"runtimeMode"in t&&t.runtimeMode!==o.runtimeMode;if(a||void 0!==t.xAccessor||void 0!==t.yAccessor||void 0!==t.timeAccessor||void 0!==t.valueAccessor){const s=a||!xt(null!==(e=t.xAccessor)&&void 0!==e?e:t.timeAccessor,null!==(n=o.xAccessor)&&void 0!==n?n:o.timeAccessor),c=a||!xt(null!==(i=t.yAccessor)&&void 0!==i?i:t.valueAccessor,null!==(r=o.yAccessor)&&void 0!==r?r:o.valueAccessor);(s||c)&&(["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?(this.getX=bt(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=bt(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=bt(this.config.xAccessor,"x"),this.getY=bt(this.config.yAccessor,"y")),l=!0)}if("groupAccessor"in t&&!xt(t.groupAccessor,o.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?wt(this.config.groupAccessor):void 0,l=!0),"categoryAccessor"in t&&!xt(t.categoryAccessor,o.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?wt(this.config.categoryAccessor):void 0,l=!0),"sizeAccessor"in t&&!xt(t.sizeAccessor,o.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?bt(this.config.sizeAccessor,"size"):void 0,l=!0),"colorAccessor"in t&&!xt(t.colorAccessor,o.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?wt(this.config.colorAccessor):void 0,l=!0),"y0Accessor"in t&&!xt(t.y0Accessor,o.y0Accessor)&&(this.getY0=this.config.y0Accessor?bt(this.config.y0Accessor,"y0"):void 0,l=!0),"pointIdAccessor"in t&&!xt(t.pointIdAccessor,o.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?wt(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]!==o[n]){l=!0;break}}l&&(this.needsFullRebuild=!0)}}function Lt(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 Dt(t){let e=t%(2*Math.PI);return 0>e&&(e+=2*Math.PI),e}function Tt(t,e,n){const i=e-t.x,r=n-t.y,o=Math.sqrt(i*i+r*r);return o>t.r+5?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:o}}function $t(t,e,n){var i,r,o,l;if(0===t.path.length)return null;const a=It(t.path,e);if(0>a)return null;const[s,c]=t.path[a];let u;if(t.path.length>1){let i=1/0;const r=Math.max(0,a-1),o=Math.min(t.path.length-2,a);for(let l=r;o>=l;l++){const[r,o]=t.path[l],[a,s]=t.path[l+1],c=Wt(e,n,r,o,a,s);i>c&&(i=c)}u=i}else{const t=e-s,i=n-c;u=Math.sqrt(t*t+i*i)}const h=null!==(l=null!==(r=null===(i=t.style)||void 0===i?void 0:i.strokeWidth)&&void 0!==r?r:null===(o=t.style)||void 0===o?void 0:o.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 Wt(t,e,n,i,r,o){const l=r-n,a=o-i,s=l*l+a*a;if(0===s)return Math.sqrt(Math.pow(t-n,2)+Math.pow(e-i,2));let c=((t-n)*l+(e-i)*a)/s;c=Math.max(0,Math.min(1,c));const u=i+c*a;return Math.sqrt(Math.pow(t-(n+c*l),2)+Math.pow(e-u,2))}function Ct(t,e,n){const i=Lt(e,n,t);return i.hit?{node:t,datum:t.datum,x:i.cx,y:i.cy,distance:0}:null}function Ot(t,e,n){const i=Lt(e,n,t);return i.hit?{node:t,datum:t.datum,x:i.cx,y:i.cy,distance:0}:null}function Nt(t,e,n){const i=t.bodyWidth/2,r=Math.min(t.openY,t.closeY);if(!(t.x-i-3>e||e>t.x+i+3||t.highY-3>n||n>t.lowY+3)){const i=r+Math.max(Math.max(t.openY,t.closeY)-r,1)/2,o=e-t.x,l=n-i;return{node:t,datum:t.datum,x:t.x,y:i,distance:Math.sqrt(o*o+l*l)}}return null}function zt(t,e,n){if(0===t.topPath.length)return null;const i=It(t.topPath,e);if(0>i)return null;const[r,o]=t.topPath[i],l=e-r,a=n-o,s=Math.sqrt(l*l+a*a);return{node:t,datum:Array.isArray(t.datum)&&t.datum[i]?t.datum[i]:t.datum,x:r,y:o,distance:s}}function It(t,e){if(0===t.length)return-1;let n=0,i=t.length-1;for(;i>n;){const r=n+i>>1;e>t[r][0]?n=r+1:i=r}return n>0&&Math.abs(t[n][0]-e)>=Math.abs(t[n-1][0]-e)?n-1:n}function Bt(t,e,n){switch(t){case"ArrowRight":case"ArrowDown":return n-1>e?e+1:e;case"ArrowLeft":case"ArrowUp":return e>0?e-1:e;case"Home":return 0;case"End":return n-1;case"Escape":return-1;default:return null}}function jt(t,r,o){const l=e(null),[a,s]=n(null);return i(()=>{if(!r&&!o)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()},[r,o]),[l,[r&&a?a.w:t[0],o&&a?a.h:t[1]]]}function Rt(t,e,n,r,o,l){i(()=>{if(!t)return;const i=setInterval(()=>{var i;const a=e.current;if(!a||0===a.lastIngestTime)return;const s="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(i=t.threshold)&&void 0!==i?i:5e3,u=s-a.lastIngestTime>c;u!==o&&(l(u),n.current=!0,r())},1e3);return()=>clearInterval(i)},[t,o,r])}_t.QUADTREE_THRESHOLD=500;const Ft={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 Yt(t,e,n,i){let r;return r="function"==typeof n?n(t):(0,Ft[n])(i(t,e)),r}function Ht(){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 Xt(t,e,n){return n&&n.size>0?n.has(t.label)?1:.3:null!=e?t.label===e?1:.3:1}function Gt({config:e,orientation:n="vertical",width:i=100}){const{colorFn:r,domain:o,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(i,200),a=Math.max(0,(i-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:r(o[0]+n*(o[1]-o[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(o[0])),t.createElement("text",{x:a+n,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(o[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:r(o[1]-n*(o[1]-o[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(o[1])),t.createElement("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(o[0])))}function Vt(e){const{legendGroups:n,customClickBehavior:i,customHoverBehavior:r,highlightedCategory:o,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)},[]),v="vertical"===h?(({legendGroups:e,width:n,customClickBehavior:i,customHoverBehavior:r,highlightedCategory:o,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,i,r,o,l,a,s,c,u)=>{const{type:h="fill",styleFn:d,items:f}=e,y=[];let g=0;const p=!(!n&&!i),v="isolate"===u||void 0===u&&null!=o;return f.forEach((e,u)=>{const m=Yt(e,u,h,d),x=Xt(e,r,o),b=o&&o.size>0&&o.has(e.label);y.push(t.createElement("g",{key:"legend-item-"+u,transform:`translate(0,${g})`,onClick:n?()=>n(e):void 0,onMouseEnter:i?()=>i(e):void 0,onMouseLeave:i?()=>i(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!=r&&e.label===r||void 0,"aria-label":e.label,onKeyDown:p?t=>{var i;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===(i=t.currentTarget.parentElement)||void 0===i?void 0:i.children[e];n instanceof SVGElement&&n.focus()}}:void 0,onFocus:p?t=>{c(s,u),i&&i(e);const n=t.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:p?t=>{i&&i(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(Ht,null),t.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label))),g+=22}),y})(e,i,r,o,l,a,s,f,c,u))),h+=22*e.items.length+8}),d})({legendGroups:n||[],width:c,customClickBehavior:i,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:l,focusedGroupIndex:d,focusedItemIndex:y,onFocusedIndexChange:p,legendInteraction:a}):(({legendGroups:e,height:n,width:i,customClickBehavior:r,customHoverBehavior:o,highlightedCategory:l,isolatedCategories:a,focusedGroupIndex:s,focusedItemIndex:c,onFocusedIndexChange:u,legendInteraction:h})=>{let d=0;const f=[];e.forEach((e,n)=>{let i=0;e.label&&(i+=16);const y=((e,n,i,r,o,l,a,s,c,u)=>{const{type:h="fill",styleFn:d,items:f}=e,y=[];let g=0;const p=!(!n&&!i),v="isolate"===u||void 0===u&&null!=o;return f.forEach((e,u)=>{const m=Yt(e,u,h,d),x=Xt(e,r,o),b=o&&o.size>0&&o.has(e.label);y.push(t.createElement("g",{key:"legend-item-"+u,transform:`translate(${g},0)`,onClick:n?()=>n(e):void 0,onMouseEnter:i?()=>i(e):void 0,onMouseLeave:i?()=>i(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!=r&&e.label===r||void 0,"aria-label":e.label,onKeyDown:p?t=>{var i;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)+f.length)%f.length;c(s,e);const n=null===(i=t.currentTarget.parentElement)||void 0===i?void 0:i.children[e];n instanceof SVGElement&&n.focus()}}:void 0,onFocus:p?t=>{c(s,u),i&&i(e);const n=t.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:p?t=>{i&&i(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(Ht,null),t.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label))),g+=26+7*e.label.length}),{items:y,offset:g}})(e,r,o,l,a,s,c,n,u,h);i+=y.offset+5,f.push(Object.assign(Object.assign({label:e.label},y),{offset:i})),d+=i+12});let y=Math.max(0,(i-d)/2);const g=[];return f.forEach((i,r)=>{const o=e[r];o.label&&(g.push(t.createElement("text",{key:"legend-text-"+r,transform:`translate(${y},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},o.label)),y+=16),g.push(t.createElement("g",{key:"legend-group-"+r,className:"legend-item",transform:`translate(${y},0)`},i.items)),y+=i.offset+5,e[r+1]&&g.push(t.createElement("line",{key:"legend-top-line legend-symbol-"+r,stroke:"gray",x1:y,y1:-8,x2:y,y2:n+0+8})),y+=12}),t.createElement("g",null,g)})({legendGroups:n||[],title:s,height:u,width:c,customClickBehavior:i,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:l,focusedGroupIndex:d,focusedItemIndex:y,onFocusedIndexChange:p,legendInteraction:a}),m=!(!i&&!r);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"===h&&t.createElement("text",{className:"legend-title",y:16,x:c/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)"},s),v)}function qt(e){const{legend:n,totalWidth:i,totalHeight:r,margin:o,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=o.top):"top"===l?(y=0,g=a?32:8):"bottom"===l?(y=0,g=r-o.bottom+50):(y=i-o.right+10,g=o.top),t.createElement("g",{transform:`translate(${y}, ${g})`},function(t){return"object"==typeof t&&null!==t&&"gradient"in t}(n)?t.createElement(Gt,{config:n.gradient,orientation:f?"horizontal":"vertical",width:f?i:100}):function(t){return"object"==typeof t&&null!==t&&"legendGroups"in t}(n)?t.createElement(Vt,{legendGroups:n.legendGroups,title:"",width:f?i:100,orientation:f?"horizontal":"vertical",customHoverBehavior:s,customClickBehavior:c,highlightedCategory:u,isolatedCategories:h,legendInteraction:d}):n)}function Kt(t){return"string"==typeof t?{type:t}:t}function Ut({orient:e,config:n,values:i,scale:o,size:l,length:a}){const s=function(t){var e,n,i,r,o;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!==(i=t.fillOpacity)&&void 0!==i?i:.5,stroke:null!==(r=t.stroke)&&void 0!==r?r:"none",strokeWidth:null!==(o=t.strokeWidth)&&void 0!==o?o:1}}(n),c="top"===e||"bottom"===e,u=r(()=>{if(0===i.length)return null;const n=o.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 i=e[Math.floor(.25*n)],r=e[Math.floor(.5*n)],o=e[Math.floor(.75*n)],l=o-i;return{q1:i,median:r,q3:o,whiskerLow:Math.max(e[0],i-1.5*l),whiskerHigh:Math.min(e[n-1],o+1.5*l)}}(i);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=o(l),i=o(u),r=o(a),c=o(h),g=o(d),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,i),y:"top"===e?v-y-f:v+y,width:Math.abs(i-n),height:f,fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),t.createElement("line",{x1:r,y1:"top"===e?v-y-f:v+y,x2:r,y2:"top"===e?v-y:v+y+f,stroke:s.fill,strokeWidth:2}))}{const n=o(l),i=o(u),r=o(a),c=o(h),g=o(d),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,i),width:f,height:Math.abs(i-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:r,x2:"left"===e?v-y:v+y+f,y2:r,stroke:s.fill,strokeWidth:2}))}}const u=M().domain(n).thresholds(s.bins)(i);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,i)=>{if(null==n.x0||null==n.x1)return null;const l=n.length/h*r;if(c){const r=o(n.x0),a=o(n.x1)-o(n.x0);return t.createElement("rect",{key:i,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=o(n.x0),a=o(n.x1)-o(n.x0);return t.createElement("rect",{key:i,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,i=[];for(const t of u){if(null==t.x0||null==t.x1)continue;const l=t.length/h*(r/2),a=o((t.x0+t.x1)/2);i.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=o((l.x0+l.x1)/2);i.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:i.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,i=null!=u[0].x0?o(u[0].x0):0;n.push(`M${i},${t}`);for(const t of u){if(null==t.x0||null==t.x1)continue;const i=t.length/h*r,l=o((t.x0+t.x1)/2);n.push(`L${l},${"top"===e?-i-4:i+4}`)}const l=null!=u[u.length-1].x1?o(u[u.length-1].x1):a;n.push(`L${l},${t}`),n.push("Z")}else{const t=0,i=null!=u[0].x0?o(u[0].x0):0;n.push(`M${t},${i}`);for(const t of u){if(null==t.x0||null==t.x1)continue;const i=t.length/h*r,l=o((t.x0+t.x1)/2);n.push(`L${"left"===e?-i-4:i+4},${l}`)}const l=null!=u[u.length-1].x1?o(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},[i,o,s,l,a,e,c,4]);return u?t.createElement("g",{className:"marginal-"+e,"data-testid":"marginal-"+e},u):null}function Zt(t,e=120,n=8){if(!t)return[];const i=Math.max(1,Math.floor(e/n)),r=t.split(/\s+/),o=[];let l="";for(const t of r)l&&l.length+1+t.length>i?(o.push(l),l=t):l=l?`${l} ${t}`:t;return l&&o.push(l),o}function Qt(t,e,n,i){return"curly"===t?i?`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`:i?`M0,0 L${n},0 L${n},${e} L0,${e}`:`M0,0 L0,${n} L${e},${n} L${e},0`}function Jt(e){const{x:n=0,y:i=0,dx:r,dy:o,nx:l,ny:a,note:s,connector:c,subject:u,type:h,color:d,className:f,disable:y,events:g={},"data-testid":p}=e,v=new Set(Array.isArray(y)?y:[]);let m=r||0,x=o||0;null!=l&&(m=l-n),null!=a&&(x=a-i);const b="string"==typeof h?h:"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},${i})`,"data-testid":p},g),!v.has("connector")&&function(e,n,i,r,o,l){const a=[];let s=0,c=0;if("callout-circle"!==o&&"label"!==o||!(null==l?void 0:l.radius)){if("callout-rect"===o&&l){const t=l.width||0,i=l.height||0;if(t>0||i>0){const r=t/2,o=i/2,l=e-r,a=n-o;if(0!==l||0!==a){const e=Math.abs(l),n=Math.abs(a),u=t/2,h=i/2,d=e*h>n*u?u/e:h/n;s=r+l*d,c=o+a*d}}}else if("bracket"===o&&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 i=Math.atan2(n,e);s=Math.cos(i)*t,c=Math.sin(i)*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:r||"currentColor"})),"arrow"===(null==i?void 0:i.end))){const i=10,o=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+i*Math.cos(l+o)},${c+i*Math.sin(l+o)}L${s+i*Math.cos(l-o)},${c+i*Math.sin(l-o)}Z`,fill:r||"currentColor",stroke:"none"}))}return t.createElement("g",{className:"annotation-connector"},a)}(m,x,c,d,b,u),!v.has("subject")&&function(e,n,i,r,o){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:i||"currentColor"}));break}case"callout-rect":{const e=(null==n?void 0:n.width)||0,r=(null==n?void 0:n.height)||0;(e>0||r>0)&&a.push(t.createElement("rect",{key:"subject-rect",width:e,height:r,fill:"none",stroke:i||"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=r||0,l=o||0;if(void 0!==(null==n?void 0:n.x)){const r=(n.x||0)-e;a.push(t.createElement("line",{key:"threshold-line",x1:r,y1:(n.y1||0)-l,x2:r,y2:(n.y2||0)-l,stroke:i||"currentColor",strokeDasharray:"5,5"}))}else if(void 0!==(null==n?void 0:n.y)){const r=(n.y||0)-l;a.push(t.createElement("line",{key:"threshold-line",x1:(n.x1||0)-e,y1:r,x2:(n.x2||0)-e,y2:r,stroke:i||"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:i||"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:i||"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:Qt((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:i||"currentColor"}));break}}return t.createElement("g",{className:"annotation-subject"},a)}(b,u,d,n,i),!v.has("note")&&function(e,n,i,r){if(!e)return t.createElement("g",{className:"annotation-note"});const{label:o,title:l,orientation:a,align:s,wrap:c=120,noWrap:u}=e;if(!o&&!l)return t.createElement("g",{className:"annotation-note"});let h=a;h||(h=Math.abs(n)>Math.abs(i)?"leftRight":"topBottom");let d=s;d&&"dynamic"!==d||(d="topBottom"===h?0>n?"right":"left":0>i?"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]:Zt(l,c):[],p=o?u?[o]:Zt(o,c):[],v="leftRight"===h?"end"===f?-4:4:0;let m=0;const x=[];g.length>0&&(x.push(t.createElement("text",{key:"annotation-note-title",className:"annotation-note-title",fill:r||void 0,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:r||void 0,textAnchor:f,y:m},p.map((e,n)=>t.createElement("tspan",{key:n,x:v,dy:0===n?0:y},e))));let b=null;if((l||o)&&(0!==n||0!==i))if("topBottom"===h){const e=Math.min(c,120);let n=0,i=e;"end"===f?(n=-e,i=0):"middle"===f&&(n=-e/2,i=e/2),b=t.createElement("line",{className:"note-line",x1:n,x2:i,y1:0,y2:0,stroke:r||"currentColor"})}else{const e=(g.length+p.length)*y+(p.length>0?y:0);let n=0,i=e;"bottom"===d?(n=-e,i=0):"middle"===d&&(n=-e/2,i=e/2),b=t.createElement("line",{className:"note-line",x1:0,x2:0,y1:n,y2:i,stroke:r||"currentColor"})}const k=Math.max(0,g.length+p.length-1)*y;let w=0;return"topBottom"===h?w=0>i?-(k+2):18:"leftRight"===h&&(w="middle"===d?-(k+y+(p.length>0&&g.length>0?2:0))/2+8:"bottom"===d||0>i?-(k+2):18),t.createElement("g",{className:"annotation-note",transform:`translate(${n},${i})`},t.createElement("g",{className:"annotation-note-content",transform:0!==w?`translate(0,${w})`:void 0},x),b)}(s,m,x,d))}function te(e){var n,i;const{noteData:r}=e,{screenCoordinates:o}=r,l="string"==typeof r.type?r.type:"label",a=r.eventListeners||r.events||{};if(r.coordinates&&o){const e=r.nx||o[0][0]+(null!==(n=r.dx)&&void 0!==n?n:0),a=r.ny||o[0][1]+(null!==(i=r.dy)&&void 0!==i?i:0),s=o.map((n,i)=>{const o=Object.assign({},r,{note:0===i?r.note:{label:""},x:n[0],y:n[1],nx:e,ny:a});return t.createElement(Jt,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+i},o,{type:l}))});return t.createElement("g",null,s)}const s=r.note||{title:"none",label:r.label};return t.createElement(Jt,Object.assign({"data-testid":"semiotic-annotation",key:`${s.label}-${s.title}-${r.i}`,events:a},r,{type:l}))}const ee={linear:K,monotoneX:q,monotoneY:V,step:G,stepAfter:X,stepBefore:H,basis:Y,cardinal:F,catmullRom:R};function ne(t,e){var n,i,r;const o=null!==(i=null===(n=e.scales)||void 0===n?void 0:n.x)&&void 0!==i?i:null===(r=e.scales)||void 0===r?void 0:r.time;return o?null!=t.x?o(t.x):e.xAccessor&&null!=t[e.xAccessor]?o(t[e.xAccessor]):null:null}function ie(t,e){var n,i,r;const o=null!==(i=null===(n=e.scales)||void 0===n?void 0:n.y)&&void 0!==i?i:null===(r=e.scales)||void 0===r?void 0:r.value;return o?null!=t.y?o(t.y):e.yAccessor&&null!=t[e.yAccessor]?o(t[e.yAccessor]):null:null}function re(t,e,n){var i,r,o,l;const a=t.anchor||"fixed";if("latest"===a){if(null!=t.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let r=n.pointNodes.length-1;r>=0;r--){const o=n.pointNodes[r];if(o.pointId===t.pointId){const t={x:o.x,y:o.y};return null===(i=n.stickyPositionCache)||void 0===i||i.set(e,t),t}}const o=function(t){var e,n,i,r,o,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===(i=t.scales)||void 0===i?void 0:i.time,u=null!==(o=null===(r=t.scales)||void 0===r?void 0:r.y)&&void 0!==o?o: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 o&&(null===(r=n.stickyPositionCache)||void 0===r||r.set(e,o)),o}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=ne(t,n),c=ie(t,n)),null!=s&&null!=c)return null===(o=n.stickyPositionCache)||void 0===o||o.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 oe(t,e,n,i=50){return!(-i>t||t>(n.width||0)+i||-i>e||e>(n.height||0)+i)}function le(t,e,n){if("left"===t||"right"===t){const i="left"===t?n:0,r="left"===t?-1:1,o=Math.ceil(e/8);let l="M0,"+i;for(let t=0;o>t;t++){const n=8*(t+1);l+=`L${Math.min(8*t+4,e)},${i+4*r}`,l+=`L${Math.min(n,e)},${i}`}return l}{const i="bottom"===t?0:e,r="bottom"===t?1:-1,o=Math.ceil(n/8);let l=`M${i},0`;for(let t=0;o>t;t++){const e=8*(t+1);l+=`L${i+4*r},${Math.min(8*t+4,n)}`,l+=`L${i},${Math.min(e,n)}`}return l}}function ae(e){const{width:n,height:i,totalWidth:o,totalHeight:l,margin:a,scales:s,showAxes:c,axes:u,showGrid:h,xFormat:d,yFormat:f}=e,y=r(()=>{var t;if(!s)return[];const e=null==u?void 0:u.find(t=>"bottom"===t.orient),i=(null==e?void 0:e.tickFormat)||d||se,r=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5,o=s.x.ticks(Math.min(r,Math.max(2,Math.floor(n/70)))),l=o.map(t=>t.valueOf()),a=o.map((t,e)=>({value:t,pixel:s.x(t),label:i(t,e,l)})),c=a.reduce((t,e)=>Math.max(t,6.5*e.label.length),0);return ce(a,Math.max(55,c+8))},[s,u,d,n]),g=r(()=>{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||se,r=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5;return ce(s.y.ticks(Math.min(r,Math.max(2,Math.floor(i/30)))).map(t=>({value:t,pixel:s.y(t),label:n(t)})),22)},[s,u,f,i]),p=h&&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:o,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:i,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1})),g.map((e,i)=>t.createElement("line",{key:"ygrid-"+i,x1:0,y1:e.pixel,x2:n,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),b&&!w&&t.createElement("line",{x1:0,y1:i,x2:n,y2:i,stroke:A,strokeWidth:1}),w&&t.createElement("path",{d:le("bottom",n,i),fill:"none",stroke:A,strokeWidth:1}),k&&!E&&t.createElement("line",{x1:0,y1:0,x2:0,y2:i,stroke:A,strokeWidth:1}),E&&t.createElement("path",{d:le("left",n,i),fill:"none",stroke:A,strokeWidth:1})))}function se(t,e,n){return Math.round(100*t)/100+""}function ce(t,e){if(2>=t.length)return t;const n=[t[0]];for(let i=1;t.length-1>i;i++)e>Math.abs(t[i].pixel-n[n.length-1].pixel)||n.push(t[i]);const i=t[t.length-1];return e>Math.abs(i.pixel-n[n.length-1].pixel)?n[n.length-1]=i:n.push(i),n}function ue(t,e){return t instanceof Date&&(!(e&&e instanceof Date)||t.getFullYear()!==e.getFullYear()||t.getMonth()!==e.getMonth()||t.getDate()!==e.getDate())}function he(n){var i,o;const{width:l,height:a,totalWidth:s,totalHeight:c,margin:u,scales:h,showAxes:d,axes:f,xLabel:y,yLabel:g,yLabelRight:p,xFormat:v,yFormat:m,showGrid:x,title:b,legend:k,legendHoverBehavior:w,legendClickBehavior:E,legendHighlightedCategory:A,legendIsolatedCategories:M,legendPosition:P="right",foregroundGraphics:S,marginalGraphics:_,xValues:L,yValues:D,annotations:T,svgAnnotationRules:W,xAccessor:C,yAccessor:O,annotationData:N,pointNodes:z,curve:I,underlayRendered:B,children:R}=n,F=r(()=>{var t;if(!d||!h)return[];const e=null==f?void 0:f.find(t=>"bottom"===t.orient),n=(null==e?void 0:e.tickFormat)||v||se,i=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5,r=h.x.ticks(Math.min(i,Math.max(2,Math.floor(l/70)))),o=r.map(t=>t.valueOf()),a=r.map((t,e)=>({value:t,pixel:h.x(t),label:n(t,e,o)})),s=a.reduce((t,e)=>Math.max(t,6.5*e.label.length),0);return ce(a,Math.max(55,s+8))},[d,h,f,v,l]),Y=r(()=>{var t;if(!d||!h)return[];const e=null==f?void 0:f.find(t=>"left"===t.orient),n=(null==e?void 0:e.tickFormat)||m||se,i=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5;return ce(h.y.ticks(Math.min(i,Math.max(2,Math.floor(a/30)))).map(t=>({value:t,pixel:h.y(t),label:n(t)})),22)},[d,h,f,m,a]),H=r(()=>{var t;if(!d||!h)return[];const e=null==f?void 0:f.find(t=>"right"===t.orient);if(!e)return[];const n=e.tickFormat||m||se,i=null!==(t=e.ticks)&&void 0!==t?t:5;return ce(h.y.ticks(Math.min(i,Math.max(2,Math.floor(a/30)))).map(t=>({value:t,pixel:h.y(t),label:n(t)})),22)},[d,h,f,m,a]),X=e(new Map),G=e(null!==(i=null==T?void 0:T.length)&&void 0!==i?i:0),V=null!==(o=null==T?void 0:T.length)&&void 0!==o?o:0;G.current!==V&&(G.current=V,X.current=new Map);const q=r(()=>{if(!T||0===T.length)return null;const e=function(e,n,i){var r,o,l,a,s,c,u,h,d,f,y,g,p,v,m,x,b,k,w,E,A,M,P,S,_,L,D,T,W,C,O,N,z,I,B,R,F,Y,H,X,G,V,q,U;switch(e.type){case"label":{const r=re(e,n,i);if(!r)return null;const{x:o,y:l}=r;return oe(o,l,i)?t.createElement(te,{key:"ann-"+n,noteData:{x:o,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 r=re(e,n,i);if(!r)return null;const{x:o,y:l}=r;return oe(o,l,i)?t.createElement(te,{key:"ann-"+n,noteData:{x:o,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 r=ne(e,i);if(null==r)return null;const o=e.color||"#f97316";return t.createElement("g",{key:"ann-"+n},t.createElement("line",{x1:r,y1:0,x2:r,y2:i.height||0,stroke:o,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&t.createElement("text",{x:r+4,y:12,fill:o,fontSize:12,fontWeight:"bold"},e.label))}case"y-threshold":{const r=ie(e,i);if(null==r)return null;const o=e.color||"#f97316";return t.createElement("g",{key:"ann-"+n},t.createElement("line",{x1:0,y1:r,x2:i.width||0,y2:r,stroke:o,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&t.createElement("text",{x:(i.width||0)-4,y:r-4,textAnchor:"end",fill:o,fontSize:12,fontWeight:"bold"},e.label))}case"enclose":{const r=(e.coordinates||[]).map(t=>({x:ne(Object.assign(Object.assign({},t),{type:"point"}),i),y:ie(Object.assign(Object.assign({},t),{type:"point"}),i),r:1})).filter(t=>null!=t.x&&null!=t.y);if(2>r.length)return null;const o=$(r),l=e.padding||10;return t.createElement("g",{key:"ann-"+n},t.createElement("circle",{cx:o.x,cy:o.y,r:o.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:o.x,y:o.y-o.r-l-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12},e.label))}case"rect-enclose":{const r=(e.coordinates||[]).map(t=>({x:ne(Object.assign(Object.assign({},t),{type:"point"}),i),y:ie(Object.assign(Object.assign({},t),{type:"point"}),i)})).filter(t=>null!=t.x&&null!=t.y);if(2>r.length)return null;const o=e.padding||10,l=r.map(t=>t.x),a=r.map(t=>t.y),s=Math.min(...l)-o,c=Math.max(...l)+o,u=Math.min(...a)-o,h=Math.max(...a)+o;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 r=i.data||[],o="function"==typeof e.filter?r.filter(e.filter):e.field&&null!=e.value?r.filter(t=>t[e.field]===e.value):[],l={stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return t.createElement("g",{key:"ann-"+n},o.map((n,r)=>{const o=ne(n,i),a=ie(n,i);if(null==o||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-"+r,cx:o,cy:a,r:s},c))}))}case"bracket":{const r=ne(e,i),o=ie(e,i);return t.createElement(te,{key:"ann-"+n,noteData:{x:null!=r?r:0,y:null!=o?o:0,dx:e.dx||0,dy:e.dy||0,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"bracket",subject:{type:e.bracketType||"curly",width:e.width,height:e.height,depth:e.depth||30},color:e.color}})}case"trend":{const h=i.data||[];if(2>h.length)return null;const d=i.xAccessor||"x",f=i.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!==(o=null===(r=i.scales)||void 0===r?void 0:r.x)&&void 0!==o?o:null===(l=i.scales)||void 0===l?void 0:l.time,p=null!==(s=null===(a=i.scales)||void 0===a?void 0:a.y)&&void 0!==s?s:null===(c=i.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 i=t.slice().sort((t,e)=>t[0]-e[0]),r=i.map(t=>t[0]),o=i.map(t=>t[1]),l=Math.max(2,Math.ceil(e*n)),a=[];for(let t=0;n>t;t++){const e=r[t],i=r.map(t=>Math.abs(t-e)),s=i.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:i[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*r[t],d+=e*o[t],f+=e*r[t]*r[t],y+=e*r[t]*o[t])}if(0===u){a.push([e,o[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"===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 r=null!==(d=null===(h=i.scales)||void 0===h?void 0:h.y)&&void 0!==d?d:null===(f=i.scales)||void 0===f?void 0:f.value,o=null!==(y=null==r?void 0:r(e.y0))&&void 0!==y?y:0,l=null!==(g=null==r?void 0:r(e.y1))&&void 0!==g?g:i.height||0;return t.createElement("g",{key:"ann-"+n},t.createElement("rect",{x:0,y:Math.min(o,l),width:i.width||0,height:Math.abs(l-o),fill:e.fill||"var(--semiotic-primary, #6366f1)",fillOpacity:e.fillOpacity||.1}),e.label&&t.createElement("text",{x:(i.width||0)-4,y:Math.min(o,l)-4,textAnchor:"end",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11},e.label))}case"envelope":{const r=i.data||[];if(2>r.length)return null;const o=i.xAccessor||"x",l=null!==(v=null===(p=i.scales)||void 0===p?void 0:p.x)&&void 0!==v?v:null===(m=i.scales)||void 0===m?void 0:m.time,a=null!==(b=null===(x=i.scales)||void 0===x?void 0:x.y)&&void 0!==b?b:null===(k=i.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=r.filter(t=>null!=t[s]&&null!=t[c]&&!(u&&!u(t))).sort((t,e)=>t[o]-e[o]);if(2>h.length)return null;const d=ee[i.curve||"linear"]||K,f=j().x(t=>l(t[o])).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][o])+4,y:a(h[h.length-1][s])-4,fill:y,fontSize:11},e.label))}case"anomaly-band":{const r=i.data||[];if(2>r.length)return null;const o=i.yAccessor||"y",l=null!==(A=null===(E=i.scales)||void 0===E?void 0:E.x)&&void 0!==A?A:null===(M=i.scales)||void 0===M?void 0:M.time,a=null!==(S=null===(P=i.scales)||void 0===P?void 0:P.y)&&void 0!==S?S:null===(_=i.scales)||void 0===_?void 0:_.value;if(!l||!a)return null;const s=r.map(t=>t[o]).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!==(L=e.threshold)&&void 0!==L?L:2,f=c-d*h,y=!1!==e.showBand,g=e.fill||"#6366f1",p=null!==(D=e.fillOpacity)&&void 0!==D?D:.1,v=e.anomalyColor||"#ef4444",m=null!==(T=e.anomalyRadius)&&void 0!==T?T:6,x=a(c+d*h),b=a(f),k=r.filter(t=>{const e=t[o];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:i.width||0,height:Math.abs(b-x),fill:g,fillOpacity:p}),k.map((e,n)=>{const r=ne(e,i),o=ie(e,i);return null==r||null==o?null:t.createElement("circle",{key:"anomaly-"+n,cx:r,cy:o,r:m,fill:v,fillOpacity:.7,stroke:v,strokeWidth:1.5})}),e.label&&t.createElement("text",{x:(i.width||0)-4,y:Math.min(x,b)-4,textAnchor:"end",fill:g,fontSize:11},e.label))}case"forecast":{const r=i.data||[];if(3>r.length)return null;const o=i.xAccessor||"x",l=i.yAccessor||"y",a=null!==(C=null===(W=i.scales)||void 0===W?void 0:W.x)&&void 0!==C?C:null===(O=i.scales)||void 0===O?void 0:O.time,s=null!==(z=null===(N=i.scales)||void 0===N?void 0:N.y)&&void 0!==z?z:null===(I=i.scales)||void 0===I?void 0:I.value;if(!a||!s)return null;const c=r.map(t=>[t[o],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,i)=>t+n*Math.pow(e,i),0)}else{const t=c.length;let e=0,n=0,i=0,r=0;for(const[t,o]of c)e+=t,n+=o,i+=t*t,r+=t*o;const o=t*i-e*e;if(1e-12>Math.abs(o))return null;const l=(t*r-e*n)/o,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,v=.99>p?.95>p?.9>p?1:1.645:1.96:2.576,m=null!==(R=e.steps)&&void 0!==R?R:5,x=c[h-1][0],b=(x-c[0][0])/Math.max(h-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/h+(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))}`,P=e.strokeColor||"#6366f1";return t.createElement("g",{key:"ann-"+n},t.createElement("path",{d:E,fill:e.fill||"#6366f1",fillOpacity:null!==(F=e.fillOpacity)&&void 0!==F?F:.15,stroke:"none"}),t.createElement("polyline",{points:`${M} ${A}`,fill:"none",stroke:P,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:P,fontSize:11},e.label))}case"widget":{let r=null,o=null;if(null!=e.px&&null!=e.py)r=e.px,o=e.py;else{const t=re(e,n,i);if(!t)return null;r=t.x,o=t.y}if(null==r||null==o)return null;if(!oe(r,o,i))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!==(U=e.content)&&void 0!==U?U:t.createElement("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info"},"ℹ️");return t.createElement("foreignObject",{key:"ann-"+n,x:r+l-s/2,y:o+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 r=re(e,n,i);if(!r)return null;const{x:o,y:l}=r;return t.createElement("text",{key:"ann-text-"+n,x:o+(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)}default:return null}},n={scales:h?{x:h.x,y:h.y,time:h.x,value:h.y}:null,timeAxis:"x",xAccessor:C,yAccessor:O,width:l,height:a,data:N,frameType:"xy",pointNodes:z,curve:I,stickyPositionCache:X.current};return T.map((t,i)=>{if(W){const r=W(t,i,n);return null!=r?r:e(t,i,n)}return e(t,i,n)}).filter(Boolean)},[T,W,l,a,C,O,N,h,z,I]);return d||b||k||S||_||q&&q.length>0||x||R?t.createElement("svg",{role:"img",width:s,height:c,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"}},t.createElement("title",null,"string"==typeof b?b:"XY Chart"),t.createElement("desc",null,"string"==typeof b?b+" — XY data visualization":"XY data visualization"),t.createElement("g",{transform:`translate(${u.left},${u.top})`},x&&h&&!B&&t.createElement("g",{className:"stream-grid"},F.map((e,n)=>t.createElement("line",{key:"xgrid-"+n,x1:e.pixel,y1:0,x2:e.pixel,y2:a,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1})),Y.map((e,n)=>t.createElement("line",{key:"ygrid-"+n,x1:0,y1:e.pixel,x2:l,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),d&&h&&(()=>{const e=null==f?void 0:f.find(t=>"left"===t.orient),n=null==f?void 0:f.find(t=>"bottom"===t.orient),i=!e||!1!==e.baseline,r=(null==e?void 0:e.jaggedBase)||!1,o=(null==n?void 0:n.jaggedBase)||!1,s=null==n?void 0:n.landmarkTicks,c=null==e?void 0:e.landmarkTicks,h="var(--semiotic-border, #ccc)",d="var(--semiotic-text-secondary, var(--semiotic-text, #666))",v="var(--semiotic-text, #333)";return t.createElement("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"}},!B&&(!n||!1!==n.baseline)&&!o&&t.createElement("line",{x1:0,y1:a,x2:l,y2:a,stroke:h,strokeWidth:1}),!B&&o&&t.createElement("path",{d:le("bottom",l,a),fill:"none",stroke:h,strokeWidth:1}),F.map((e,n)=>{const i=!!s&&("function"==typeof s?s(e.value,n):ue(e.value,n>0?F[n-1].value:void 0));return t.createElement("g",{key:"xtick-"+n,transform:`translate(${e.pixel},${a})`},t.createElement("line",{y2:5,stroke:h,strokeWidth:1}),t.createElement("text",{y:18,textAnchor:"middle",fontSize:i?11:10,fontWeight:i?600:400,fill:d,style:{userSelect:"none"}},e.label))}),y&&t.createElement("text",{x:l/2,y:a+40,textAnchor:"middle",fontSize:12,fill:v,style:{userSelect:"none"}},y),!B&&i&&!r&&t.createElement("line",{x1:0,y1:0,x2:0,y2:a,stroke:h,strokeWidth:1}),!B&&r&&t.createElement("path",{d:le("left",l,a),fill:"none",stroke:h,strokeWidth:1}),Y.map((e,n)=>{const i=!!c&&("function"==typeof c?c(e.value,n):ue(e.value,n>0?Y[n-1].value:void 0));return t.createElement("g",{key:"ytick-"+n,transform:`translate(0,${e.pixel})`},t.createElement("line",{x2:-5,stroke:h,strokeWidth:1}),t.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:i?11:10,fontWeight:i?600:400,fill:d,style:{userSelect:"none"}},e.label))}),(()=>{const n=(null==e?void 0:e.label)||g;return n?t.createElement("text",{x:15-u.left,y:a/2,textAnchor:"middle",fontSize:12,fill:v,transform:`rotate(-90, ${15-u.left}, ${a/2})`,style:{userSelect:"none"}},n):null})(),(()=>{const e=null==f?void 0:f.find(t=>"right"===t.orient);if(!e||0===H.length)return null;const n=e.landmarkTicks,i=e.label||p;return t.createElement(t.Fragment,null,!1!==e.baseline&&t.createElement("line",{x1:l,y1:0,x2:l,y2:a,stroke:h,strokeWidth:1}),H.map((e,i)=>{const r=!!n&&("function"==typeof n?n(e.value,i):ue(e.value,i>0?H[i-1].value:void 0));return t.createElement("g",{key:"ytick-r-"+i,transform:`translate(${l},${e.pixel})`},t.createElement("line",{x2:5,stroke:h,strokeWidth:1}),t.createElement("text",{x:8,textAnchor:"start",dominantBaseline:"middle",fontSize:r?11:10,fontWeight:r?600:400,fill:d,style:{userSelect:"none"}},e.label))}),i&&t.createElement("text",{x:l+u.right-15,y:a/2,textAnchor:"middle",fontSize:12,fill:v,transform:`rotate(90, ${l+u.right-15}, ${a/2})`,style:{userSelect:"none"}},i))})())})(),q,_&&h&&L&&D&&t.createElement(t.Fragment,null,_.top&&t.createElement("g",{transform:"translate(0, 0)"},t.createElement(Ut,{orient:"top",config:Kt(_.top),values:L,scale:h.x,size:u.top,length:l})),_.bottom&&t.createElement("g",{transform:`translate(0, ${a})`},t.createElement(Ut,{orient:"bottom",config:Kt(_.bottom),values:L,scale:h.x,size:u.bottom,length:l})),_.left&&t.createElement("g",{transform:"translate(0, 0)"},t.createElement(Ut,{orient:"left",config:Kt(_.left),values:D,scale:h.y,size:u.left,length:a})),_.right&&t.createElement("g",{transform:`translate(${l}, 0)`},t.createElement(Ut,{orient:"right",config:Kt(_.right),values:D,scale:h.y,size:u.right,length:a}))),S,R),b&&t.createElement("text",{x:s/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof b?b:null),qt({legend:k,totalWidth:s,totalHeight:c,margin:u,legendPosition:P,title:b,legendHoverBehavior:w,legendClickBehavior:E,legendHighlightedCategory:A,legendIsolatedCategories:M})):null}function de(t,e="#4e79a7"){return t&&"string"==typeof t?t:e}const fe="undefined"==typeof window||"undefined"==typeof document,ye={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 i=[],r={point:"points",line:"lines",area:"areas",rect:"bars",heatcell:"cells",circle:"nodes",candlestick:"candlesticks"},o=["point","line","area","rect","heatcell","circle","candlestick"],l=Object.keys(n).sort((t,e)=>{const n=o.indexOf(t),i=o.indexOf(e);return(-1===n?999:n)-(-1===i?999:i)});for(const t of l)i.push(`${n[t]} ${r[t]||t}`);return`${e}, ${i.join(", ")}`}function pe(t,e,n){const i=[];return t>0&&i.push(t+" nodes"),e>0&&i.push(e+" edges"),0===i.length?n+", empty":`${n}, ${i.join(", ")}`}function ve({scene:e,chartType:n}){var i,r,o,l;const a=[];for(const t of e){if(a.length>=50)break;"point"===t.type?a.push({label:"Point",values:{x:Math.round(100*t.x)/100+"",y:Math.round(100*t.y)/100+""}}):"rect"===t.type?a.push({label:"Bar",values:{category:(null===(i=t.datum)||void 0===i?void 0:i.category)||"",value:Math.round(100*(null!==(o=null===(r=t.datum)||void 0===r?void 0:r.value)&&void 0!==o?o:0))/100+""}}):"heatcell"===t.type&&a.push({label:"Cell",values:{x:Math.round(100*t.x)/100+"",y:Math.round(100*t.y)/100+"",value:Math.round(100*(null!==(l=t.value)&&void 0!==l?l:0))/100+""}})}if(0===a.length)return null;const s=new Set;for(const t of a)for(const e of Object.keys(t.values))s.add(e);const c=Array.from(s);return t.createElement("table",{style:ye,role:"table","aria-label":"Data table for "+n},t.createElement("thead",null,t.createElement("tr",null,c.map(e=>t.createElement("th",{key:e},e)))),t.createElement("tbody",null,a.map((e,n)=>t.createElement("tr",{key:n},c.map(n=>{var i;return t.createElement("td",{key:n},null!==(i=e.values[n])&&void 0!==i?i:"")}))),e.length>50&&t.createElement("tr",null,t.createElement("td",{colSpan:c.length},"...and ",e.length-50," more items"))))}function me({nodes:e,chartType:n}){var i,r,o,l,a;const s=[];for(const t of e){if(s.length>=50)break;s.push({values:{id:(null===(i=t.datum)||void 0===i?void 0:i.id)||t.id||"",x:Math.round(100*(null!==(o=null!==(r=t.cx)&&void 0!==r?r:t.x)&&void 0!==o?o:0))/100+"",y:Math.round(100*(null!==(a=null!==(l=t.cy)&&void 0!==l?l:t.y)&&void 0!==a?a:0))/100+""}})}if(0===s.length)return null;const c=new Set;for(const t of s)for(const e of Object.keys(t.values))c.add(e);const u=Array.from(c);return t.createElement("table",{style:ye,role:"table","aria-label":"Data table for "+n},t.createElement("thead",null,t.createElement("tr",null,u.map(e=>t.createElement("th",{key:e},e)))),t.createElement("tbody",null,s.map((e,n)=>t.createElement("tr",{key:n},u.map(n=>{var i;return t.createElement("td",{key:n},null!==(i=e.values[n])&&void 0!==i?i:"")}))),e.length>50&&t.createElement("tr",null,t.createElement("td",{colSpan:u.length},"...and ",e.length-50," more items"))))}function xe({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:ye},n)}function be(n){const i=o(null),c=ke(n);return[function({children:e}){const o=r(()=>ke(n),[]);return t.createElement(i.Provider,{value:o,children:e})},t=>{var n;const r=null!==(n=l(i))&&void 0!==n?n:c,o=e(t);o.current=t;const u=a(()=>o.current(r.getState()),[r]),h=a(()=>o.current(r.getState()),[r]);return s(r.subscribe,u,h)}]}function ke(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 we={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}},Ee={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}},Ae={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"},[Me,Pe]=be(t=>({theme:we,setTheme(e){t(t=>{if("light"===e)return{theme:we};if("dark"===e)return{theme:Ee};if("high-contrast"===e)return{theme:Ae};if(e.mode&&"auto"!==e.mode){const t="dark"===e.mode?Ee:we;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 Se(t,e,n,i){const r=t.getContext("2d");if(!r)return null;const o=e[0]*i,l=e[1]*i,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===o&&t.height===l||(t.width=o,t.height=l),r.setTransform(i,0,0,i,0,0),r.translate(n.left,n.top),r}function _e(){return"undefined"!=typeof window&&window.devicePixelRatio||1}function Le(t){switch(t){case"monotoneX":return q;case"monotoneY":return V;case"cardinal":return F;case"catmullRom":return R;case"step":return G;case"stepBefore":return H;case"stepAfter":return X;case"basis":return Y;case"natural":return Q;default:return null}}function De(t,e,n){let i=n;for(const n of e)"lesser"===n.thresholdType?n.value>t&&(i=n.color):t>n.value&&(i=n.color);return i}function Te(t,e,n,i,r,o){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],i=e[t][1]-e[t-1][1];l.push(l[t-1]+Math.sqrt(n*n+i*i))}const a=l[l.length-1];if(0===a)return;const s=Math.min(.2*a,40);t.strokeStyle=n,t.lineWidth=i,t.lineCap=o;for(let n=0;e.length-1>n;n++){const i=(l[n]+l[n+1])/2;let o=r;s>i&&(o*=i/s),s>a-i&&(o*=(a-i)/s),t.globalAlpha=Math.max(0,o),t.beginPath(),t.moveTo(e[n][0],e[n][1]),t.lineTo(e[n+1][0],e[n+1][1]),t.stroke()}}function $e(t){return!(!t._pulseIntensity||0>=t._pulseIntensity)}function We(t,e,n=.3){$e(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 Ce(t,e,n=.6){var i,r,o,l,a;if(!$e(e))return;const s=null!==(i=e._pulseGlowRadius)&&void 0!==i?i:4,c=e.r+s*e._pulseIntensity,u=null!==(o=null!==(r=e.cx)&&void 0!==r?r:e.x)&&void 0!==o?o: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 Oe(t,e,n,i=.35){$e(e)&&(t.globalAlpha=e._pulseIntensity*i,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fill())}function Ne(t){switch(t){case"monotoneX":return q;case"monotoneY":return V;case"cardinal":return F;case"catmullRom":return R;case"step":return G;case"stepBefore":return H;case"stepAfter":return X;case"basis":return Y;case"natural":return Q;default:return null}}function ze(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 Ie(t,e){const n=Ne(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 i=j().x(t=>t[0]).y0((t,n)=>e.bottomPath[n][1]).y1(t=>t[1]).curve(n).context(t);t.beginPath(),i(e.topPath)}}const Be=(t,e,n,i)=>{var r,o,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",i=e._decayOpacities;if(i&&i.length===e.topPath.length){const o=null!==(r=e.style.fillOpacity)&&void 0!==r?r:.7;t.fillStyle=n;for(let n=0;e.topPath.length-1>n;n++)t.globalAlpha=.5*(i[n]+i[n+1])*o,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*(i[n]+i[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!==(o=e.style.opacity)&&void 0!==o?o:1;if(Ie(t,e),e.fillGradient){let i=1/0;for(const t of e.topPath)i>t[1]&&(i=t[1]);let r=-1/0;for(const t of e.bottomPath)t[1]>r&&(r=t[1]);const o=ze("string"==typeof n?n:"#4e79a7"),l=e.fillGradient.topOpacity,s=e.fillGradient.bottomOpacity,c=t.createLinearGradient(0,i,0,r);c.addColorStop(0,`rgba(${o[0]},${o[1]},${o[2]},${l})`),c.addColorStop(1,`rgba(${o[0]},${o[1]},${o[2]},${s})`),t.fillStyle=c,t.globalAlpha=a}else{const i=null!==(l=e.style.fillOpacity)&&void 0!==l?l:.7;t.globalAlpha=i*a,t.fillStyle=n}if(t.fill(),e._pulseIntensity&&e._pulseIntensity>0&&(Ie(t,e),Oe(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=Ne(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}},je=(t,e,n,i)=>{var r;const o=e.filter(t=>"point"===t.type);t.save();try{for(const e of o){t.beginPath(),t.arc(e.x,e.y,e.r,0,2*Math.PI);const n=null!==(r=e.style.opacity)&&void 0!==r?r: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()),Ce(t,e),t.globalAlpha=1}}finally{t.restore()}},Re=(t,e,n,i)=>{const r=e.filter(t=>"rect"===t.type);for(const e of r)null!=e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.icon?Fe(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))),We(t,e),t.globalAlpha=1};function Fe(t,e){const n=e.style.icon,i=e.style.iconPadding||2,r=Math.min(e.w,e.h)-i;if(0>=r)return;const o=e.h>e.w;if(t.save(),t.beginPath(),t.rect(e.x,e.y,e.w,e.h),t.clip(),o){const o=r+i,l=e.x+(e.w-r)/2;for(let i=e.y+e.h-r;i>=e.y-r;i-=o)t.drawImage(n,l,i,r,r)}else{const o=r+i,l=e.y+(e.h-r)/2;for(let i=e.x;e.x+e.w>i;i+=o)t.drawImage(n,i,l,r,r)}t.restore()}function Ye(t){const[e,n,i]=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*i>128?"#000":"#fff"}function He(t){return Number.isInteger(t)?t+"":100>Math.abs(t)?1>Math.abs(t)?t.toPrecision(3):t.toFixed(1):t.toFixed(0)}const Xe=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Ge(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`${Xe[e.getUTCMonth()]} ${e.getUTCDate()}`}:5*n>e?t=>{const e=new Date(t);return`${Xe[e.getUTCMonth()]} ${e.getUTCFullYear()}`}:t=>new Date(t).getUTCFullYear()+""}const Ve={line:[Be,(t,e,n,i)=>{var r,o;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!==(r=a.style.opacity)&&void 0!==r?r:1;Te(t,a.path,s,c,g,a.style.strokeLinecap||"butt"),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt";continue}const d=Le(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!==(o=a.style.opacity)&&void 0!==o?o: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,i){t.beginPath(),t.strokeStyle=e,t.moveTo(n,i),w=!0}function A(){w&&(t.stroke(),w=!1)}for(let M=0;a.path.length>M;M++){const[P,S]=a.path[M],_=h[M],L=De(_,u,s);if(null!==m&&null!==k&&null!==b){if(L===k)t.lineTo(P,S);else{const D=[];for(const T of u){const $=T.value;(b>$||$>_)&&($>b||_>$)||b===$||_===$||D.push({t:($-b)/(_-b)})}D.sort((t,e)=>t.t-e.t);for(const W of D){const C=m+(P-m)*W.t,O=x+(S-x)*W.t,N=De(b+(_-b)*Math.min(W.t+1e-4,1),u,s);t.lineTo(C,O),A(),E(N,C,O)}t.lineTo(P,S)}m=P,x=S,b=_,k=L}else E(L,P,S),m=P,x=S,b=_,k=L}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[z,I]=a.path[0];t.moveTo(z,I);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[R,F]=a.path[0];t.moveTo(R,F);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],i.height),t.lineTo(j,i.height),t.closePath(),t.fill()}t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt"}}],area:[Be],stackedarea:[Be],scatter:[je],bubble:[je],heatmap:[(t,e,n,i)=>{const r=e.filter(t=>"heatcell"===t.type);t.save();try{for(const e of r){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),We(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):He(e.value),i=Math.max(10,Math.min(16,.3*Math.min(e.w,e.h))),r=e.x+e.w/2,o=e.y+e.h/2;t.fillStyle=Ye(e.fill),t.font=i+"px sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText(n,r,o)}}}finally{t.restore()}}],bar:[Re],swarm:[je],waterfall:[(t,e,n,i)=>{var r,o,l;Re(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!==(r=null==s?void 0:s._connectorWidth)&&void 0!==r?r:1,t.setLineDash([]);for(let e=0;a.length-1>e;e++){const i=a[e],r=a[e+1];if(!(null===(o=i.datum)||void 0===o?void 0:o.cumEnd)||!(null===(l=r.datum)||void 0===l?void 0:l.baseline))continue;const s=n.y(i.datum.cumEnd),c=i.x+i.w,u=r.x;t.beginPath(),t.moveTo(c,s),t.lineTo(u,s),t.stroke()}t.restore()}}],candlestick:[(t,e,n,i)=>{for(const n of e){if("candlestick"!==n.type)continue;const e=n;t.save();const i=e._decayOpacity;null!=i&&1!==i&&(t.globalAlpha=i),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 r=Math.min(e.openY,e.closeY),o=Math.abs(e.openY-e.closeY),l=e.isUp?e.upColor:e.downColor;t.fillStyle=l,t.fillRect(e.x-e.bodyWidth/2,r,e.bodyWidth,Math.max(o,1)),t.strokeStyle=l,t.lineWidth=1,t.strokeRect(e.x-e.bodyWidth/2,r,e.bodyWidth,Math.max(o,1)),t.restore()}}]},qe={top:20,right:20,bottom:30,left:40},Ke={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"},Ue={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 Ze({hover:e}){const n=t=>Number.isInteger(t)?t+"":t.toFixed(2);return t.createElement("div",{className:"semiotic-tooltip",style:Ue},t.createElement("div",{style:{fontWeight:600,marginBottom:2}},n(e.value)),t.createElement("div",{style:{opacity:.7,fontSize:11}},n(e.time)))}function Qe({width:n,height:r,totalWidth:o,totalHeight:l,margin:a,dimension:s,scales:c,onBrush:u}){const h=e(null),p=e(null),v=e(u);v.current=u;const m=e(c);return m.current=c,i(()=>{if(!h.current)return;const t=g(h.current).select(".brush-g"),e="x"===s?d():"y"===s?f():y();return e.extent([[0,0],[n,r]]),e.on("brush end",t=>{const e=m.current;if(!e)return;if(!t.selection)return void v.current(null);let i,o;if("x"===s){const[n,l]=t.selection;i=[e.x.invert(n),e.x.invert(l)],o=[e.y.invert(r),e.y.invert(0)]}else if("y"===s){const[r,l]=t.selection;i=[e.x.invert(0),e.x.invert(n)],o=[e.y.invert(l),e.y.invert(r)]}else{const[[n,r],[l,a]]=t.selection;i=[e.x.invert(n),e.x.invert(l)],o=[e.y.invert(a),e.y.invert(r)]}v.current({x:i,y:o})}),t.call(e),p.current=e,t.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{e.on("brush end",null),p.current=null}},[n,r,s]),t.createElement("svg",{ref:h,width:o,height:l,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},t.createElement("g",{className:"brush-g",transform:`translate(${a.left},${a.top})`}))}const Je=c(function(o,l){var s,c,h,d,f,y,g,p,v;const{chartType:m,runtimeMode:x,data:b,chunkThreshold:k,chunkSize:w,xAccessor:E,yAccessor:A,colorAccessor:M,sizeAccessor:P,groupAccessor:S,lineDataAccessor:_,curve:L,normalize:D,binSize:T,valueAccessor:$,arrowOfTime:W="right",windowMode:C="sliding",windowSize:O=200,timeAccessor:N,xExtent:z,yExtent:I,extentPadding:B=.1,sizeRange:j,size:R=[500,300],responsiveWidth:F,responsiveHeight:Y,margin:H,className:X,background:G,lineStyle:V,pointStyle:q,areaStyle:K,waterfallStyle:U,swarmStyle:Z,barColors:Q,colorScheme:J,boundsAccessor:tt,boundsStyle:et,y0Accessor:nt,gradientFill:it,openAccessor:rt,highAccessor:ot,lowAccessor:lt,closeAccessor:at,candlestickStyle:st,showAxes:ct=!0,axes:ht,xLabel:dt,yLabel:ft,yLabelRight:yt,xFormat:gt,yFormat:pt,tickFormatTime:vt,tickFormatValue:mt,hoverAnnotation:xt,tooltipContent:bt,customHoverBehavior:kt,enableHover:wt,annotations:Et,svgAnnotationRules:At,showGrid:Mt,legend:Pt,legendHoverBehavior:St,legendClickBehavior:Lt,legendHighlightedCategory:Dt,legendIsolatedCategories:Wt,legendPosition:It,backgroundGraphics:Ft,foregroundGraphics:Yt,canvasPreRenderers:Ht,svgPreRenderers:Xt,title:Gt,categoryAccessor:Vt,brush:qt,onBrush:Kt,decay:Ut,pulse:Zt,transition:Qt,staleness:Jt,heatmapAggregation:te,heatmapXBins:ee,heatmapYBins:ne,showValues:ie,heatmapValueFormat:re,marginalGraphics:oe,pointIdAccessor:le,xScaleType:se,yScaleType:ce,accessibleTable:ue}=o,[ye,pe]=jt(R,F,Y),me=Object.assign(Object.assign({},qe),H);if(oe){const t=60;oe.top&&t>me.top&&(me.top=t),oe.bottom&&t>me.bottom&&(me.bottom=t),oe.left&&t>me.left&&(me.left=t),oe.right&&t>me.right&&(me.right=t)}const be=pe[0]-me.left-me.right,ke=pe[1]-me.top-me.bottom,we="function"==typeof Yt?Yt({size:pe,margin:me}):Yt,Ee="function"==typeof Ft?Ft({size:pe,margin:me}):Ft,Ae=null!=xt?xt:wt,Me=e(null),Le=e(null),De=e(0),Te=e(!1),$e=Pe(t=>t.theme),[We,Ce]=n(0),[Oe,Ne]=n(null),ze=e(null),Ie=e(null),[Be,je]=n(null),[Re,Fe]=n(!1),[Ye,He]=n([]),[Xe,Ue]=n([]),Je=e(()=>{}),tn="streaming"===x||["bar","swarm","waterfall"].includes(m),en=r(()=>({chartType:m,runtimeMode:tn?"streaming":"bounded",windowSize:O,windowMode:C,arrowOfTime:tn?W:"right",extentPadding:B,xAccessor:tn?void 0:E,yAccessor:tn?void 0:A,timeAccessor:tn?N:void 0,valueAccessor:$,colorAccessor:M,sizeAccessor:P,groupAccessor:S,categoryAccessor:Vt,lineDataAccessor:_,xScaleType:se,yScaleType:ce,xExtent:z,yExtent:I,sizeRange:j,binSize:T,normalize:D,boundsAccessor:tt,boundsStyle:et,y0Accessor:nt,gradientFill:"boolean"==typeof it?it?{topOpacity:.8,bottomOpacity:.05}:void 0:it,openAccessor:rt,highAccessor:ot,lowAccessor:lt,closeAccessor:at,candlestickStyle:st,lineStyle:V,pointStyle:q,areaStyle:K,swarmStyle:Z,waterfallStyle:U,colorScheme:J,barColors:Q,annotations:Et,decay:Ut,pulse:Zt,transition:Qt,staleness:Jt,heatmapAggregation:te,heatmapXBins:ee,heatmapYBins:ne,showValues:ie,heatmapValueFormat:re,pointIdAccessor:le,curve:L}),[m,O,C,W,B,E,A,N,$,se,ce,M,P,S,Vt,_,z,I,j,T,D,tt,et,nt,it,rt,ot,lt,at,st,V,q,K,Z,U,J,Q,Et,Ut,Zt,Qt,Jt,te,ee,ne,ie,re,tn,le,L]),nn=e(null);nn.current||(nn.current=new _t(en));const rn=a(()=>{De.current||(De.current=requestAnimationFrame(()=>Je.current()))},[]);i(()=>{var t;null===(t=nn.current)||void 0===t||t.updateConfig(en),Te.current=!0,rn()},[en,rn]),i(()=>{Te.current=!0,rn()},[$e,rn]);const on=e(null);on.current||(on.current=new ut(t=>{const e=nn.current;e&&e.ingest(t)&&(Te.current=!0,rn())},{chunkThreshold:k,chunkSize:w})),i(()=>{var t;null===(t=on.current)||void 0===t||t.updateChunkOptions({chunkThreshold:k,chunkSize:w})},[k,w]);const ln=a(t=>{var e;null===(e=on.current)||void 0===e||e.push(t)},[]),an=a(t=>{var e;null===(e=on.current)||void 0===e||e.pushMany(t)},[]),sn=a(()=>{var t,e;null===(t=on.current)||void 0===t||t.clear(),null===(e=nn.current)||void 0===e||e.clear(),Te.current=!0,rn()},[rn]);u(l,()=>({push:ln,pushMany:an,clear:sn,getData:()=>{var t,e,n;return null===(t=on.current)||void 0===t||t.flush(),null!==(n=null===(e=nn.current)||void 0===e?void 0:e.getData())&&void 0!==n?n:[]},getScales:()=>{var t,e;return null!==(e=null===(t=nn.current)||void 0===t?void 0:t.scales)&&void 0!==e?e:null},getExtents:()=>{var t,e;return null!==(e=null===(t=nn.current)||void 0===t?void 0:t.getExtents())&&void 0!==e?e:null}}),[ln,an,sn]),i(()=>{var t;b&&(null===(t=on.current)||void 0===t||t.setBoundedData(b))},[b]);const cn=e(()=>{}),un=e(()=>{});cn.current=t=>{if(!Ae)return;const e=Me.current;if(!e)return;const n=e.getBoundingClientRect(),i=t.clientX-n.left-me.left,r=t.clientY-n.top-me.top;if(0>i||i>be||0>r||r>ke)return void(ze.current&&(ze.current=null,Ie.current=null,je(null),kt&&(kt(null),Te.current=!0),rn()));const o=nn.current;if(!o||0===o.scene.length)return;const l=function(t,e,n,i=30,r){let o=null,l=!1;if(r){const t=r.find(e,n,i);if(t){const r=Tt(t,e,n);r&&i>r.distance&&(o=r,l=!0)}}for(const a of t){let t=null;switch(a.type){case"point":if(r&&l)break;t=Tt(a,e,n);break;case"line":t=$t(a,e,n);break;case"rect":t=Ct(a,e,n);break;case"heatcell":t=Ot(a,e,n);break;case"area":if(!1===a.interactive)break;t=zt(a,e,n);break;case"candlestick":t=Nt(a,e,n)}t&&i>t.distance&&(o&&t.distance>=o.distance||(o=t))}return o}(o.scene,i,r,30,o.quadtree);if(!l)return void(ze.current&&(ze.current=null,Ie.current=null,je(null),kt&&kt(null),rn()));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});ze.current=s,Ie.current=l.node,je(s),kt&&(kt(s),Te.current=!0),rn()},un.current=()=>{ze.current&&(ze.current=null,Ie.current=null,je(null),kt&&(kt(null),Te.current=!0),rn())},a(t=>cn.current(t),[]);const hn=a(()=>un.current(),[]),dn=e(-1),fn=a(t=>{const e=nn.current;if(!e||0===e.scene.length)return;const n=function(t){const e=[];for(const n of t)switch(n.type){case"point":e.push({x:n.x,y:n.y,datum:n.datum});break;case"line":{const t=n,i=Array.isArray(t.datum)?t.datum:[];for(let n=0;t.path.length>n&&i.length>n;n++)e.push({x:t.path[n][0],y:t.path[n][1],datum:i[n]});break}case"area":{const t=n,i=Array.isArray(t.datum)?t.datum:[];for(let n=0;t.topPath.length>n&&i.length>n;n++)e.push({x:t.topPath[n][0],y:t.topPath[n][1],datum:i[n]});break}case"rect":case"heatcell":e.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum})}return e.sort((t,e)=>t.x-e.x||t.y-e.y),e}(e.scene);if(0===n.length)return;const i=0>dn.current?-1:dn.current,r=Bt(t.key,0>i?-1:i,n.length);if(null===r)return;if(t.preventDefault(),0>r)return dn.current=-1,ze.current=null,Ie.current=null,je(null),kt&&kt(null),void rn();const o=0>i?0:r;dn.current=o;const l=function(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})}(n[o]);ze.current=l,je(l),kt&&kt(l),rn()},[kt,rn]),yn=a(t=>{dn.current=-1,cn.current(t)},[]);Je.current=()=>{var t,e;De.current=0;const n=Me.current,i=Le.current;if(!n||!i)return;const r=nn.current;if(!r)return;const o="undefined"!=typeof performance?performance.now():Date.now(),l=r.advanceTransition(o),a=Te.current||l;a&&!l&&r.computeScene({width:be,height:ke});const s=_e(),c=function(t){if(!t)return Ke;const e=getComputedStyle(t),n=e.getPropertyValue("--semiotic-border").trim(),i=e.getPropertyValue("--semiotic-text-secondary").trim(),r=e.getPropertyValue("--semiotic-bg").trim(),o=i||e.getPropertyValue("--text-secondary").trim(),l=e.getPropertyValue("--text-primary").trim(),a=n||e.getPropertyValue("--surface-3").trim(),s=r||e.getPropertyValue("--surface-0").trim();return o||l||n?{axisStroke:a||Ke.axisStroke,tickText:o||Ke.tickText,crosshair:o?o+"66":Ke.crosshair,hoverFill:s?s+"4D":Ke.hoverFill,hoverStroke:o?o+"99":Ke.hoverStroke,pointRing:s||Ke.pointRing}:Ke}(n),u=null!==(t=null==Jt?void 0:Jt.threshold)&&void 0!==t?t:5e3,h=Jt&&r.lastIngestTime>0&&o-r.lastIngestTime>u;if(a){const t=Se(n,pe,me,s);if(t){t.clearRect(-me.left,-me.top,pe[0],pe[1]),h&&(t.globalAlpha=null!==(e=null==Jt?void 0:Jt.dimOpacity)&&void 0!==e?e:.5);const i=getComputedStyle(n).getPropertyValue("--semiotic-bg").trim(),o=G||(i&&"transparent"!==i?i:null);if(o&&(t.fillStyle=o,t.fillRect(-me.left,-me.top,pe[0],pe[1])),t.save(),"function"==typeof t.rect&&(t.beginPath(),t.rect(0,0,be,ke),t.clip()),Ht&&r.scales)for(const e of Ht)t.save(),e(t,r.scene,r.scales,{width:be,height:ke}),t.restore();const l=Ve[m];if(l&&r.scales)for(const e of l)e(t,r.scene,r.scales,{width:be,height:ke});t.restore(),h&&(t.globalAlpha=1)}}{const t=Se(i,pe,me,s);if(t&&(t.clearRect(-me.left,-me.top,pe[0],pe[1]),Ae&&ze.current&&r.scales&&function(t,e,n,i,r,o,l){var a;if(!1===r.crosshair)return;t.save();const s="object"==typeof r.crosshair?r.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,i),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=r.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}(o)||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,ze.current,be,ke,"object"==typeof Ae?Ae:{},Ie.current,c),Ie.current&&Array.isArray(xt))){const e=xt.find(t=>t&&"object"==typeof t&&"highlight"===t.type);e&&function(t,e,n,i){var r;if(!n)return;const o=n.group;if(void 0!==o)for(const n of e){if("line"!==n.type)continue;if(n.group!==o)continue;if(2>n.path.length)continue;const e="function"==typeof i.style?i.style(n.datum):i.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!==(r=e.opacity)&&void 0!==r?r:1,t.stroke(),t.restore()}}(t,r.scene,Ie.current,e)}}a&&n&&n.setAttribute("aria-label",ge(r.scene,m+" chart"));const d=Te.current;if(Te.current=!1,d&&r.scales&&((!Oe||Oe.x.domain()[0]!==r.scales.x.domain()[0]||Oe.x.domain()[1]!==r.scales.x.domain()[1]||Oe.y.domain()[0]!==r.scales.y.domain()[0]||Oe.y.domain()[1]!==r.scales.y.domain()[1]||Oe.x.range()[0]!==r.scales.x.range()[0]||Oe.x.range()[1]!==r.scales.x.range()[1]||Oe.y.range()[0]!==r.scales.y.range()[0]||Oe.y.range()[1]!==r.scales.y.range()[1])&&Ne(r.scales),oe)){const t=r.getData(),e="function"==typeof E?E:t=>t[E||"x"],n="function"==typeof A?A:t=>t[A||"y"];He(t.map(t=>e(t)).filter(t=>"number"==typeof t&&isFinite(t))),Ue(t.map(t=>n(t)).filter(t=>"number"==typeof t&&isFinite(t)))}d&&Et&&Et.length>0&&Ce(t=>t+1),(null==Jt?void 0:Jt.showBadge)&&Fe(!!h),(l||r.hasActivePulses)&&(De.current=requestAnimationFrame(()=>Je.current()))},i(()=>(rn(),()=>{De.current&&(cancelAnimationFrame(De.current),De.current=0)}),[rn]),i(()=>{Te.current=!0,rn()},[m,be,ke,ct,G,V,Ht,rn]),Rt(Jt,nn,Te,rn,Re,Fe);const gn=r(()=>{if(gt||vt)return;const t=nn.current;return(null==t?void 0:t.xIsDate)&&Oe?Ge(Oe.x.domain()):void 0},[gt,vt,Oe]),pn=gt||vt||gn,vn=Ae&&Be?bt?bt(Be):t.createElement(Ze,{hover:Be}):null,mn=vn?t.createElement("div",{className:"stream-frame-tooltip",style:{position:"absolute",left:me.left+Be.x,top:me.top+Be.y,transform:`translate(${Be.x>.7*be?"calc(-100% - 12px)":"12px"}, ${.3*ke>Be.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:1,width:"max-content"}},vn):null,xn=dn.current>=0&&Be?t.createElement("svg",{style:{position:"absolute",left:0,top:0,width:pe[0],height:pe[1],pointerEvents:"none",zIndex:2}},t.createElement("circle",{cx:Be.x+me.left,cy:Be.y+me.top,r:8,fill:"none",stroke:"var(--accent, #6366f1)",strokeWidth:2,strokeDasharray:"4,2"})):null;if(fe){const e=nn.current;e&&b&&(e.ingest({inserts:b,bounded:!0}),e.computeScene({width:be,height:ke}));const n=null!==(s=null==e?void 0:e.scene)&&void 0!==s?s:[],i=null!==(c=null==e?void 0:e.scales)&&void 0!==c?c:null,r=pn||(()=>{if((null==e?void 0:e.xIsDate)&&i)return Ge(i.x.domain())})();return t.createElement("div",{className:"stream-xy-frame"+(X?" "+X:""),role:"img","aria-label":"string"==typeof Gt?Gt:"XY chart",style:{position:"relative",width:pe[0],height:pe[1]}},t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:pe[0],height:pe[1],style:{position:"absolute",left:0,top:0}},Ee,t.createElement("g",{transform:`translate(${me.left},${me.top})`},G&&t.createElement("rect",{x:0,y:0,width:be,height:ke,fill:G}),Xt&&i&&Xt.map((e,r)=>t.createElement(t.Fragment,{key:"svgpre-"+r},e(n,i,{width:be,height:ke}))),n.map((e,n)=>function(e,n){var i,r,o;switch(e.type){case"line":{const i=e;if(0===i.path.length)return null;const r="M"+i.path.map(([t,e])=>`${t},${e}`).join("L");return t.createElement("path",{key:"line-"+n,d:r,fill:"none",stroke:i.style.stroke||"#4e79a7",strokeWidth:i.style.strokeWidth||2,strokeDasharray:i.style.strokeDasharray,opacity:i.style.opacity})}case"area":{const o=e;if(0===o.topPath.length)return null;const l=o.topPath.map(([t,e])=>`${t},${e}`).join("L"),a=[...o.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L");return t.createElement("path",{key:"area-"+n,d:`M${l}L${a}Z`,fill:de(o.style.fill),fillOpacity:null!==(r=null!==(i=o.style.fillOpacity)&&void 0!==i?i:o.style.opacity)&&void 0!==r?r:.7,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})}case"point":{const i=e;return t.createElement("circle",{key:"point-"+n,cx:i.x,cy:i.y,r:i.r,fill:de(i.style.fill),opacity:null!==(o=i.style.opacity)&&void 0!==o?o:.8,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})}case"rect":{const i=e;return t.createElement("rect",{key:"rect-"+n,x:i.x,y:i.y,width:i.w,height:i.h,fill:de(i.style.fill),opacity:i.style.opacity,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})}case"heatcell":{const i=e;if(i.showValues&&null!=i.value&&i.w>=20&&i.h>=20){const e=i.valueFormat?i.valueFormat(i.value):Number.isInteger(i.value)?i.value+"":100>Math.abs(i.value)?1>Math.abs(i.value)?i.value.toPrecision(3):i.value.toFixed(1):i.value.toFixed(0),[r,o,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]}(i.fill),a=.299*r+.587*o+.114*l>128?"#000":"#fff",s=Math.max(10,Math.min(16,.3*Math.min(i.w,i.h)));return t.createElement("g",{key:"heatcell-"+n},t.createElement("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:i.fill}),t.createElement("text",{x:i.x+i.w/2,y:i.y+i.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:a,fontSize:s+"px"},e))}return t.createElement("rect",{key:"heatcell-"+n,x:i.x,y:i.y,width:i.w,height:i.h,fill:i.fill})}case"candlestick":{const i=e,r=Math.min(i.openY,i.closeY),o=Math.max(Math.abs(i.openY-i.closeY),1),l=i.isUp?i.upColor:i.downColor;return t.createElement("g",{key:"candle-"+n},t.createElement("line",{x1:i.x,y1:i.highY,x2:i.x,y2:i.lowY,stroke:i.wickColor,strokeWidth:i.wickWidth}),t.createElement("rect",{x:i.x-i.bodyWidth/2,y:r,width:i.bodyWidth,height:o,fill:l,stroke:l,strokeWidth:1}))}default:return null}}(e,n)).filter(Boolean))),t.createElement(he,{width:be,height:ke,totalWidth:pe[0],totalHeight:pe[1],margin:me,scales:i,showAxes:ct,axes:ht,xLabel:dt,yLabel:ft,yLabelRight:yt,xFormat:r,yFormat:pt||mt,showGrid:Mt,title:Gt,legend:Pt,legendHoverBehavior:St,legendClickBehavior:Lt,legendHighlightedCategory:Dt,legendIsolatedCategories:Wt,legendPosition:It,foregroundGraphics:we,marginalGraphics:oe,xValues:[],yValues:[],annotations:Et,svgAnnotationRules:At,annotationFrame:0,xAccessor:"string"==typeof E?E:"string"==typeof N?N:void 0,yAccessor:"string"==typeof A?A:"string"==typeof $?$:void 0,annotationData: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}))}return t.createElement("div",{ref:ye,className:"stream-xy-frame"+(X?" "+X:""),role:"img","aria-label":"string"==typeof Gt?Gt:"XY chart",tabIndex:0,style:{position:"relative",width:F?"100%":pe[0],height:Y?"100%":pe[1],overflow:"visible"},onMouseMove:Ae?yn:void 0,onMouseLeave:Ae?hn:void 0,onKeyDown:fn},Ee&&t.createElement("svg",{style:{position:"absolute",left:0,top:0,width:pe[0],height:pe[1],pointerEvents:"none"}},Ee),t.createElement(ae,{width:be,height:ke,totalWidth:pe[0],totalHeight:pe[1],margin:me,scales:Oe,showAxes:ct,axes:ht,showGrid:Mt,xFormat:pn,yFormat:pt||mt}),t.createElement("canvas",{ref:Me,"aria-label":ge(null!==(d=null===(h=nn.current)||void 0===h?void 0:h.scene)&&void 0!==d?d:[],m+" chart"),style:{position:"absolute",left:0,top:0}}),t.createElement("canvas",{ref:Le,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),t.createElement(xe,{hoverPoint:Be}),ue&&t.createElement(ve,{scene:null!==(y=null===(f=nn.current)||void 0===f?void 0:f.scene)&&void 0!==y?y:[],chartType:m+" chart"}),t.createElement(he,{width:be,height:ke,totalWidth:pe[0],totalHeight:pe[1],margin:me,scales:Oe,showAxes:ct,axes:ht,xLabel:dt,yLabel:ft,yLabelRight:yt,xFormat:pn,yFormat:pt||mt,showGrid:Mt,title:Gt,legend:Pt,legendHoverBehavior:St,legendClickBehavior:Lt,legendHighlightedCategory:Dt,legendIsolatedCategories:Wt,legendPosition:It,foregroundGraphics:we,marginalGraphics:oe,xValues:Ye,yValues:Xe,annotations:Et,svgAnnotationRules:At,annotationFrame:We,xAccessor:"string"==typeof E?E:"string"==typeof N?N:void 0,yAccessor:"string"==typeof A?A:"string"==typeof $?$:void 0,annotationData:null===(g=nn.current)||void 0===g?void 0:g.getData(),pointNodes:null===(p=nn.current)||void 0===p?void 0:p.scene.filter(t=>"point"===t.type),curve:"string"==typeof L?L:void 0,underlayRendered:!0}),(qt||Kt)&&t.createElement(Qe,{width:be,height:ke,totalWidth:pe[0],totalHeight:pe[1],margin:me,dimension:null!==(v=null==qt?void 0:qt.dimension)&&void 0!==v?v:"xy",scales:Oe,onBrush:null!=Kt?Kt:()=>{}}),(null==Jt?void 0:Jt.showBadge)&&t.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===Jt.badgePosition?{top:4,left:4}:"bottom-left"===Jt.badgePosition?{bottom:4,left:4}:"bottom-right"===Jt.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:Re?"#dc3545":"#28a745",color:"white"})},Re?"STALE":"LIVE"),xn,mn)});Je.displayName="StreamXYFrame";const tn={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},en={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class nn{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,i){var r;for(let o=0;this.capacity>o;o++){const l=this.particles[o];if(!l.active)continue;const a=n[l.edgeIndex];if(!a||!a.bezier){l.active=!1;continue}const s=i&&null!==(r=i[l.edgeIndex])&&void 0!==r?r:1;if(l.t+=t*e*s*(a.bezier.circular?.3:1),l.t>=1){l.active=!1;continue}const c=rn(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 rn(t,e,n){if(t.circular&&t.segments)return function(t,e,n,i){const r=t.length,o=e*r,l=Math.min(Math.floor(o),r-1),a=o-l,[s,c,u,h]=t[l],d=on(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*i*2,d.y+=t*n*i*2}return d}(t.segments,e,n,t.halfWidth);if(!t.points)return{x:0,y:0};const[i,r,o,l]=t.points,a=on(i,r,o,l,e),s=l.x-i.x,c=l.y-i.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 on(t,e,n,i,r){const o=1-r,l=o*o,a=l*o,s=r*r,c=s*r;return{x:a*t.x+3*l*r*e.x+3*o*s*n.x+c*i.x,y:a*t.y+3*l*r*e.y+3*o*s*n.y+c*i.y}}function ln(t,e){var n=t.get(e);if(!n)throw Error("missing: "+e);return n}function an(t,e){var n,i=[],r=[],o=[],l={},a=[];function s(t){o[t]=!1,l.hasOwnProperty(t)&&Object.keys(l[t]).forEach(function(e){delete l[t][e],o[e]&&s(e)})}function c(t){var e,i,h=!1;for(r.push(t),o[t]=!0,e=0;a[t].length>e;e++)(i=a[t][e])===n?(u(n,r),h=!0):o[i]||(h=c(i));if(h)s(t);else for(e=0;a[t].length>e;e++){var d=l[i=a[t][e]];d||(l[i]=d={}),d[i]=!0}return r.pop(),h}function u(t,e){var n=[].concat(e).concat(t);i.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,i=function(t){for(var e=t.length,n=Array(e),i=Array(e),r=Array(e),o=Array(e),l=Array(e),a=Array(e),s=0;e>s;++s)n[s]=-1,i[s]=0,r[s]=!1,o[s]=0,l[s]=-1,a[s]=[];var c,u=0,h=[],d=[];function f(e){var s=[e],c=[e];for(n[e]=i[e]=u,r[e]=!0,u+=1;c.length>0;){var f=t[e=c[c.length-1]];if(f.length>o[e]){for(var y=o[e];f.length>y;++y){var g=f[y];if(0>n[g]){n[g]=i[g]=u,r[g]=!0,u+=1,s.push(g),c.push(g);break}r[g]&&(i[e]=0|Math.min(i[e],i[g])),0>l[g]||a[e].push(l[g])}o[e]=y}else{if(i[e]===n[e]){var p=[],v=[],m=0;for(y=s.length-1;y>=0;--y){var x=s[y];if(r[x]=!1,p.push(x),v.push(a[x]),m+=a[x].length,l[x]=h.length,x===e){s.length=y;break}}h.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];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),r=i.components.filter(function(t){return t.length>1}),o=1/0,l=0;r.length>l;l++)for(var a=0;r[l].length>a;a++)o>r[l][a]&&(o=r[l][a],n=l);var s=r[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:o,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];o[+p]=!1,l[p]={}}c(n),n+=1}else n=d}return i}function sn(t){return t.y0-t.y1>0?"up":"down"}function cn(t,e){return e(t.source)==e(t.target)}function un(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 hn(t){return t.target.x0-t.source.x1}function dn(t,e){var n=yn(t),i=hn(e)/Math.tan(n);return"up"==sn(t)?t.y1-i:t.y1+i}function fn(t,e){var n=yn(t),i=hn(e)/Math.tan(n);return"up"==sn(t)?t.y1+i:t.y1-i}function yn(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function gn(t,e){return e(t)}function pn(t){return mn(t.source)}function vn(t){return mn(t.target)}function mn(t){return(t.y0+t.y1)/2}function xn(t){return t.virtual?0:t.value}function bn(t,e){var n=0;t.sourceLinks.forEach(function(t){n=t.circular&&!cn(t,e)?n+1:n});var i=0;return t.targetLinks.forEach(function(t){i=t.circular&&!cn(t,e)?i+1:i}),n+i}function kn(t){return t.target.depth}function wn(t,e){return t.sourceLinks.length?t.depth:e-1}function En(t,e){return t.y0-e.y0}function An(t,e){return e.y0-t.y0}function Mn(t,e){return t.y1-e.y1}function Pn(t,e){return e.y1-t.y1}function Sn(t,e){return Ln(t.source,e.source)||t.index-e.index}function _n(t,e){return Ln(t.target,e.target)||t.index-e.index}function Ln(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function Dn(t,e){return Tn(t)==Tn(e)?"bottom"==t.circularLinkType?An(t,e):En(t,e):Tn(e)-Tn(t)}function Tn(t){return t.target.column-t.source.column}function $n(t,e){return Wn(t)==Wn(e)}function Wn(t){return t.y0-t.y1>0?"up":"down"}function Cn(t,e,n,i,r){let o=t;var l=Math.max(8,.15*(o.y1-o.y0));o.links.forEach(function(t){t.circular&&(t._circularWidth=Math.min(t.width,l))});var a=P(o.links,function(t){return t.source.y0});o.links.forEach(function(t){t.circular&&(t.circularPathData={})});var s=o.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}),On(o.links.filter(function(t){return"top"==t.circularLinkType}),e,n),On(o.links.filter(function(t){return"bottom"==t.circularLinkType}),e,n),o.links.forEach(function(t){if(t.circular){if(t.circularPathData.arcRadius=t._circularWidth+i,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,cn(t,e)&&un(t))t.circularPathData.rightSmallArcRadius=i+t._circularWidth/2,t.circularPathData.rightLargeArcRadius=i+t._circularWidth/2,t.circularPathData.leftSmallArcRadius=i+t._circularWidth/2,t.circularPathData.leftLargeArcRadius=i+t._circularWidth/2,"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=t.source.y1+r+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-r-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=o.links.filter(function(t){return t.source.column==l&&t.circularLinkType==s});c.sort("bottom"==t.circularLinkType?An:En);var u=0;c.forEach(function(e,r){e.circularLinkID==t.circularLinkID&&(t.circularPathData.rightSmallArcRadius=i+t._circularWidth/2+u,t.circularPathData.rightLargeArcRadius=i+t._circularWidth/2+r*n+u),u+=e._circularWidth||e.width}),l=t.target.column,(c=o.links.filter(function(t){return t.target.column==l&&t.circularLinkType==s})).sort("bottom"==t.circularLinkType?Pn:Mn),u=0,c.forEach(function(e,r){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=i+t._circularWidth/2+u,t.circularPathData.leftLargeArcRadius=i+t._circularWidth/2+r*n+u),u+=e._circularWidth||e.width}),"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=Math.max(o.y1,t.source.y1,t.target.y1)+r+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-r-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,i=t.target.x0,r=t.y1,o=(e+i)/2;return"M"+e+","+n+"C"+o+","+n+" "+o+","+r+" "+i+","+r}(t)}),o}function On(t,e,n){t.sort(Dn);var i=t.filter(function(t){return!t._circularStub});return t.forEach(function(t,r){var o=0;if(t._circularStub)t.circularPathData.verticalBuffer=0;else if(cn(t,e)&&un(t))t.circularPathData.verticalBuffer=o+t._circularWidth/2;else{for(var l=0;i.length>l;l++){var a=i[l];if(a!==t&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&Nn(t,a)){var s=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+n;o=s>o?s:o}}t.circularPathData.verticalBuffer=o+t._circularWidth/2}}),t}function Nn(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}function zn(t){return function(){return t}}function In(t){return t.index}function Bn(t){return t.nodes}function jn(t){return t.links}function Rn(t,e,n){var i=S(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});i.forEach(function(r,o){var l=r.length;if(e)r.sort(e);else if(o>0){var a=new Map;r.forEach(function(t,e){var n,i,r,o=(i=0,r=0,(n=t).targetLinks.forEach(function(t){if(!t.circular){var e=t.value||1;r+=mn(t.source)*e,i+=e}}),n.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;r+=mn(t.target)*e,i+=e}}),i>0?r/i:NaN);a.set(t,{bc:o,idx:e})}),r.sort(function(t,e){var n=a.get(t),i=a.get(e),r=n.bc,o=i.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(r)||isNaN(o)?isNaN(r)?isNaN(o)?n.idx-i.idx:1:-1:r-o})}else r.sort(function(t,e){return t.circularLinkType==e.circularLinkType?bn(e,n)-bn(t,n):"top"==t.circularLinkType&&"bottom"==e.circularLinkType||"top"==t.circularLinkType&&0==e.partOfCycle||0==t.partOfCycle&&"bottom"==e.circularLinkType?-1:0});r.forEach(function(e,r){e.depth==i.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==bn(e,n)?(e.y0=t.y1/2+r,e.y1=e.y0+e.value*t.ky):"top"==e.circularLinkType?(e.y0=t.y0+r,e.y1=e.y0+e.value*t.ky):(e.y0=t.y1-e.value*t.ky-r,e.y1=e.y0+e.value*t.ky):0==t.y0||0==t.y1?(e.y0=(t.y1-t.y0)/l*r,e.y1=e.y0+e.value*t.ky):(e.y0=(t.y1-t.y0)/2-l/2+r,e.y1=e.y0+e.value*t.ky)})})}function Fn(t,e,n,i,r,o){var l=S(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=o;s>0;--s)c(a*=.99,n),u();function c(e,n){var i=l.length;l.forEach(function(r){var o=r.length,l=r[0].depth;r.forEach(function(r){var a;if(r.sourceLinks.length||r.targetLinks.length)if(r.partOfCycle&&bn(r,n)>0){var s=D(r.sourceLinks,vn),c=D(r.targetLinks,pn),u=s&&c?(s+c)/2:s||c;if(u){var h=(u-mn(r))*e*.3;r.y0+=h,r.y1+=h}}else if(0==l&&1==o)r.y0=t.y1/2-(a=r.y1-r.y0)/2,r.y1=t.y1/2+a/2;else if(l==i-1&&1==o)r.y0=t.y1/2-(a=r.y1-r.y0)/2,r.y1=t.y1/2+a/2;else if(1==r.targetLinks.length&&1==r.targetLinks[0].source.sourceLinks.length)a=r.y1-r.y0,r.y0=r.targetLinks[0].source.y0,r.y1=r.y0+a;else{var d=D(r.sourceLinks,vn),f=D(r.targetLinks,pn),y=((d&&f?(d+f)/2:d||f)-mn(r))*e;r.y0+=y,r.y1+=y}})})}function u(){l.forEach(function(n){var o,l,a,s=t.y0,c=n.length;for(n.sort(e||Ln),a=0;c>a;++a)(l=s-(o=n[a]).y0)>0&&(o.y0+=l,o.y1+=l),s=o.y1+i;if((l=s-i-t.y1)>0)for(s=o.y0-=l,o.y1-=l,a=c-2;a>=0;--a)(l=(o=n[a]).y1+r-s)>0&&(o.y0-=l,o.y1-=l),s=o.y0})}}function Yn(t){t.nodes.forEach(function(t){t.sourceLinks.sort(_n),t.targetLinks.sort(Sn)}),t.nodes.forEach(function(t){var e=t.y0,n=e,i=t.y1,r=i;t.sourceLinks.forEach(function(t){t.circular?(t.y0=i-t.width/2,i-=t.width):(t.y0=e+t.width/2,e+=t.width)}),t.targetLinks.forEach(function(t){t.circular?(t.y1=r-t.width/2,r-=t.width):(t.y1=n+t.width/2,n+=t.width)})})}function Hn(){var t=0,e=0,n=1,i=1,r=24,o=8,l=null,a=In,s=wn,c=void 0,u=32,h=2,d=Bn,f=jn;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=i,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 T(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 i=t.source,r=t.target;"object"!=typeof i&&(i=t.source=ln(n,i)),"object"!=typeof r&&(r=t.target=ln(n,r)),i.sourceLinks.push(t),r.targetLinks.push(t)})}(d,a),function(t,e){var n=0;if(null==e){for(var i=[],r=0;t.links.length>r;r++){var o=t.links[r],l=o.source.index,a=o.target.index;i[l]||(i[l]=[]),i[a]||(i[a]=[]),-1===i[l].indexOf(a)&&i[l].push(a)}var s=an(i);s.sort(function(t,e){return t.length-e.length});var c={};for(r=0;s.length>r;r++){var u=s[r].slice(-2);c[u[0]]||(c[u[0]]={}),c[u[0]][u[1]]=!0}t.links.forEach(function(t){var e=t.target.index,i=t.source.index;e===i||c[i]&&c[i][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,i=0;t.links.forEach(function(r){r.circular&&(r.circularLinkType=r.source.circularLinkType||r.target.circularLinkType?r.source.circularLinkType?r.source.circularLinkType:r.target.circularLinkType:i>n?"top":"bottom","top"==r.circularLinkType?n++:i++,t.nodes.forEach(function(t){gn(t,e)!=gn(r.source,e)&&gn(t,e)!=gn(r.target,e)||(t.circularLinkType=r.circularLinkType)}))}),t.links.forEach(function(t){t.circular&&(t.source.circularLinkType==t.target.circularLinkType&&(t.circularLinkType=t.source.circularLinkType),cn(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(d,a),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max(L(t.sourceLinks,xn),L(t.targetLinks,xn)),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 i,r,o;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(i=t.nodes,r=[],o=0;i.length;++o,i=r,r=[])i.forEach(function(t){t.depth=o,t.sourceLinks.forEach(function(t){0>r.indexOf(t.target)&&!t.circular&&r.push(t.target)})});for(i=t.nodes,r=[],o=0;i.length;++o,i=r,r=[])i.forEach(function(t){t.height=o,t.targetLinks.forEach(function(t){0>r.indexOf(t.source)&&!t.circular&&r.push(t.source)})});t.nodes.forEach(function(t){t.column=null==e?n(t,o):t.column})}(d,c,s);var f=o;if(null!==l){var y=S(d.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,(i-e)*l/(g-1)))}(function(t,e,n){var i=S(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 r=P(i,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/L(e,function(t){return t.value})});t.ky=r,t.links.forEach(function(e){e.width=e.value*t.ky});var o=_(t.nodes,function(t){return t.column});t.nodes.forEach(o>0?function(e){e.x0=t.x0+e.column*((t.x1-t.x0-n)/o),e.x1=e.x0+n}:function(e){e.x0=t.x0,e.x1=e.x0+n})})(d,f,r),Rn(d,c,a),Fn(d,c,a,f,f,u),Yn(d),Cn(d,a,h,10,8),Rn(d,c,a),Fn(d,c,a,f,f,u),Yn(d),Cn(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 i=n.links.filter(function(n){return gn(n.source,e)==gn(t,e)}),r=i.length;r>1&&i.sort(function(t,e){if(!t.circular&&!e.circular){if(t.target.column==e.target.column)return t.y1-e.y1;if(!$n(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var n=dn(e,t);return t.y1-n}if(e.target.column>t.target.column)return dn(t,e)-e.y1}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.target.column===e.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.target.column===e.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:"top"==t.circularLinkType?-1:1:void 0});var o=t.y0;i.forEach(function(t){t.y0=o+t.width/2,o+=t.width}),i.forEach(function(e,n){if("bottom"==e.circularLinkType){for(var o=n+1,l=0;r>o;o++)l+=i[o].width;e.y0=t.y1-l-e.width/2}})})}(d,a),function(t,e){let n=t;n.nodes.forEach(function(t){var i=n.links.filter(function(n){return gn(n.target,e)==gn(t,e)}),r=i.length;r>1&&i.sort(function(t,e){if(!t.circular&&!e.circular){if(t.source.column==e.source.column)return t.y0-e.y0;if(!$n(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var n=fn(e,t);return t.y0-n}if(e.source.column>t.source.column)return fn(t,e)-e.y0}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:t.source.column-e.source.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:e.source.column-t.source.column:"top"==t.circularLinkType?-1:1:void 0});var o=t.y0;i.forEach(function(t){t.y1=o+t.width/2,o+=t.width}),i.forEach(function(e,n){if("bottom"==e.circularLinkType){for(var o=n+1,l=0;r>o;o++)l+=i[o].width;e.y1=t.y1-l-e.width/2}})})}(d,a),function(t){var e=t.nodes,n=t.links,i=!1,r=!1;if(n.forEach(function(t){"top"==t.circularLinkType?i=!0:"bottom"==t.circularLinkType&&(r=!0)}),0==i||0==r){var o=P(e,function(t){return t.y0}),l=_(e,function(t){return t.y1}),a=(t.y1-t.y0)/(l-o);function s(e){return(e-o)/(l-o)*(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),Cn(d,a,h,10,8)}(y),y}return y.update=function(t){return Yn(t),Cn(t,a,h,10,8),t},y.nodeWidth=function(t){return arguments.length?(r=+t,y):r},y.nodePadding=function(t){return arguments.length?(o=+t,y):o},y.nodePaddingRatio=function(t){return arguments.length?(l=+t,y):l},y.nodes=function(t){return arguments.length?(d="function"==typeof t?t:zn(t),y):d},y.links=function(t){return arguments.length?(f="function"==typeof t?t:zn(t),y):f},y.nodeId=function(t){return arguments.length?(a="function"==typeof t?t:zn(t),y):a},y.nodeAlign=function(t){return arguments.length?(s="function"==typeof t?t:zn(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(r){return arguments.length?(t=+r[0][0],e=+r[0][1],n=+r[1][0],i=+r[1][1],y):[[t,e],[n,i]]},y.size=function(r){return arguments.length?(t=e=0,n=+r[0],i=+r[1],y):[n-t,i-e]},y}const Xn=t=>{let e,n,i,r,o,l,a,s,c;return"down"===t.direction?(e=t.y0-t.sankeyWidth/2,n=t.y1-t.sankeyWidth/2,i=t.y1+t.sankeyWidth/2,r=t.y0+t.sankeyWidth/2,o=t.source.x1,l=t.target.x0,a=et(o,l),s=a(.5),c=a(.5),`M${e},${o}C${e},${s} ${n},${c} ${n},${l}L${i},${l}C${i},${c} ${r},${s} ${r},${o}Z`):(e=t.source.x1,n=t.target.x0,a=et(e,n),i=a(.5),r=a(.5),o=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},${o}C${i},${o} ${r},${l} ${n},${l}L${n},${s}C${r},${s} ${i},${c} ${e},${c}Z`)};function Gn(t){var e;const n=t.sankeyWidth/2,i=(null!==(e=t._circularWidth)&&void 0!==e?e:t.sankeyWidth)/2,r=t.circularPathData;if(!r)return null;if("down"===t.direction)return null;if(t._circularStub){const e=r.sourceX,i=r.sourceY,o=r.targetX,l=r.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*(r.rightFullExtent-e))),s=Math.max(15,Math.min(40,.33*(o-r.leftFullExtent)));return`M${e},${i-n}L${e+a},${i-n}L${e+a},${i+n}L${e},${i+n}ZM${o},${l-n}L${o-s},${l-n}L${o-s},${l+n}L${o},${l+n}Z`}const o=r.sourceX,l=r.sourceY,a=r.targetX,s=r.targetY,c=r.rightFullExtent,u=r.leftFullExtent,h=r.verticalFullExtent,d="bottom"===t.circularLinkType?1:-1,f=Math.max(4,Math.min(i,15));return`M${o},${l-d*n}L${c},${l-d*n}L${c+i},${l-d*n+d*f}L${c+i},${h+d*i-d*f}L${c+i-f},${h+d*i}L${u-i+f},${h+d*i}L${u-i},${h+d*i-d*f}L${u-i},${s-d*n+d*f}L${u-i+f},${s-d*n}L${a},${s-d*n}L${a},${s+d*n}L${u+i},${s+d*n}L${u+i},${h-d*i}L${c-i},${h-d*i}L${c-i},${l+d*n}L${o},${l+d*n}Z`}const Vn={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(kn))-1:0},justify:wn},qn={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,i){var r,o,l,a,s,c,u;if(0===t.length)return;const h="vertical"===n.orientation?"down":"right",d=n.nodeAlign||"justify",f=null!==(r=n.nodeWidth)&&void 0!==r?r:15,y=null!==(o=n.nodePaddingRatio)&&void 0!==o?o:.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"===h?[[0,0],[i[1],i[0]]]:[[0,0],[i[0],i[1]]];const x=Hn().extent(m).links(v).nodes(p).nodeAlign(Vn[d]||wn).nodeId(t=>t.id).nodeWidth(f).iterations(g);x.nodePaddingRatio&&x.nodePaddingRatio(y),x();{let t=1/0,e=-1/0,n=1/0,r=-1/0;for(const i of p)t>i.x0&&(t=i.x0),i.x1>e&&(e=i.x1),n>i.y0&&(n=i.y0),i.y1>r&&(r=i.y1);for(const i of v){if(!i.circular||!i.circularPathData)continue;const o=i.circularPathData,l=(null!==(s=null!==(a=i._circularWidth)&&void 0!==a?a:i.width)&&void 0!==s?s:0)/2;t>o.leftFullExtent-l&&(t=o.leftFullExtent-l),o.rightFullExtent+l>e&&(e=o.rightFullExtent+l),n>o.verticalFullExtent-l&&(n=o.verticalFullExtent-l),o.verticalFullExtent+l>r&&(r=o.verticalFullExtent+l)}const o=e-t,l=r-n,u=i[0],h=i[1];if(o>0&&l>0&&(0>t||0>n||e>u||r>h)){const e=Math.min(u/o,h/l),i=-t*e+(u-o*e)/2,r=-n*e+(h-l*e)/2;for(const t of p)t.x0=t.x0*e+i,t.x1=t.x1*e+i,t.y0=t.y0*e+r,t.y1=t.y1*e+r;for(const t of v)if(t.y0=t.y0*e+r,t.y1=t.y1*e+r,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+i,n.targetX=n.targetX*e+i,n.sourceY=n.sourceY*e+r,n.targetY=n.targetY*e+r,n.rightFullExtent=n.rightFullExtent*e+i,n.leftFullExtent=n.leftFullExtent*e+i,n.verticalFullExtent=n.verticalFullExtent*e+r,n.rightInnerExtent=n.rightInnerExtent*e+i,n.leftInnerExtent=n.leftInnerExtent*e+i,n.verticalRightInnerExtent=n.verticalRightInnerExtent*e+r,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*e+r,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,i="object"==typeof e&&null!==e?e.id:e+"",r="object"==typeof n&&null!==n?n.id:n+"",o=k.get(t._edgeKey?t._edgeKey:`${i}\0${r}`);if(o){o.y0=t.y0,o.y1=t.y1,o.sankeyWidth=null!==(u=t.width)&&void 0!==u?u:0,o.circular=!!t.circular,o.circularPathData=t.circularPathData,o._circularWidth=t._circularWidth,o._circularStub=t._circularStub,o.path=t.path,o.circularLinkType=t.circularLinkType,o.direction=h;const e=b.get(i),n=b.get(r);e&&(o.source=e),n&&(o.target=n)}}},buildScene(t,e,n,i){var r,o,l,a;const s="vertical"===n.orientation?"down":"right",c=n.nodeStyle,u=n.edgeStyle,h=null!==(r=n.edgeOpacity)&&void 0!==r?r:.5,d=n.edgeColorBy||"source",f=Array.isArray(n.colorScheme)?n.colorScheme:x,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 i=c?c(e):{},r={fill:i.fill||y.get(e.id)||"#4d430c",stroke:i.stroke,strokeWidth:i.strokeWidth,opacity:i.opacity};m.set(e.id,("string"==typeof r.fill?r.fill:null)||y.get(e.id)||"#4d430c"),g.push("down"===s?{type:"rect",x:e.y0,y:e.x0,w:n,h:t,style:r,datum:e,id:e.id,label:e.id}:{type:"rect",x:e.x0,y:e.y0,w:t,h:n,style:r,datum:e,id:e.id,label:e.id})}const b=[...e].sort((t,e)=>(e.sankeyWidth||0)-(t.sankeyWidth||0));for(const t of b){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 i="#999";i="function"==typeof d?d(t)||i:"target"===d?m.get(n.id)||y.get(n.id)||i:m.get(e.id)||y.get(e.id)||i;const r=u?u(t):{};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=r.fill||i;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!==(o=r.fillOpacity)&&void 0!==o?o:h,stroke:"none",opacity:r.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=r.fillOpacity)&&void 0!==l?l:h,stroke:"none",opacity:r.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?Gn(t):Xn(t),!s)continue;const c={fill:r.fill||i,fillOpacity:null!==(a=r.fillOpacity)&&void 0!==a?a:h,stroke:r.stroke||"none",strokeWidth:r.strokeWidth,opacity:r.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,r=n.y1-n.y0;if(0>=t||0>=r)continue;const o=e?e(n):n.id;if(!o)continue;let l,a,c;"down"===s?(l=n.y0+(n.y1-n.y0)/2,a=n.x1+14,c="middle"):(i[0]/2>n.x0+t/2?(l=n.x0-6,c="end"):(l=n.x1+6,c="start"),a=n.y0+r/2),v.push({x:l,y:a,text:o+"",anchor:c,baseline:"middle",fontSize:11})}}var k;return{sceneNodes:g,sceneEdges:p,labels:v}}},Kn={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,i){var r,o;if(0===t.length)return;const l=null!==(r=n.forceStrength)&&void 0!==r?r:.1,a=i[0]/2,s=i[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 i=Un(t.id,e,n);if(i.length>0){let e=0,n=0;for(const t of i)e+=t.x,n+=t.y;const r=Zn(t.id),o=r%360*(Math.PI/180),l=10+r%20;t.x=e/i.length+l*Math.cos(o),t.y=n/i.length+l*Math.sin(o)}else{const e=Zn(t.id),n=e%360*(Math.PI/180),i=15+e%30;t.x=a+i*Math.cos(n),t.y=s+i*Math.sin(n)}}}else{const e=2.399963229728653;for(let n=0;t.length>n;n++){const i=t[n];if(null==i.x||null==i.y||0===i.x&&0===i.y){const t=10*Math.sqrt(n+.5),r=n*e;i.x=a+t*Math.cos(r),i.y=s+t*Math.sin(r)}}}const f=null!==(o=n.iterations)&&void 0!==o?o:Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),y=d?40:f,g=Qn(n.nodeSize,n.nodeSizeRange,t),p=t=>g(t),v=nt().strength(t=>Math.min(2.5,t.weight?t.weight*l:l)).id(t=>t.id),m=it().force("charge",rt().strength(t=>-25*p(t))).force("center",ot(a,s).strength(.8)).force("x",lt(a).strength(.15)).force("y",at(s).strength(.15));if(m.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}));m.force("link",v),m.force("link").links(t)}d?m.alpha(.3):.1>m.alpha()&&m.alpha(1),m.stop();for(let t=0;y>t;++t)m.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(i[0]-t,e.x)),e.y=Math.max(t,Math.min(i[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,i){var r,o,l;const a=n.nodeStyle,s=n.edgeStyle,c=Qn(n.nodeSize,n.nodeSizeRange,t),u=Array.isArray(n.colorScheme)?n.colorScheme:x,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(e),n=a?a(e):{},i={fill:n.fill||h.get(e.id)||"#007bff",stroke:n.stroke||"#fff",strokeWidth:null!==(r=n.strokeWidth)&&void 0!==r?r:2,opacity:n.opacity};d.push({type:"circle",cx:e.x,cy:e.y,r:t,style:i,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 i=s?s(t):{},r={stroke:i.stroke||"#999",strokeWidth:null!==(o=i.strokeWidth)&&void 0!==o?o:1,opacity:null!==(l=i.opacity)&&void 0!==l?l:.6};f.push({type:"line",x1:e.x,y1:e.y,x2:n.x,y2:n.y,style:r,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 i=c(n);y.push({x:n.x,y:n.y-i-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var p;return{sceneNodes:d,sceneEdges:f,labels:y}}};function Un(t,e,n){const i=[];for(const r of e){const e="string"==typeof r.source?r.source:r.source.id,o="string"==typeof r.target?r.target:r.target.id;let l=null;if(e===t?l=o:o===t&&(l=e),l){const t=n.get(l);!t||0===t.x&&0===t.y||i.push({x:t.x,y:t.y})}}return i}function Zn(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 Qn(t,e,n){var i,r;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const o=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()=>o[0];const a=null!==(i=P(l))&&void 0!==i?i:0,s=null!==(r=_(l))&&void 0!==r?r:1;if(a===s)return()=>(o[0]+o[1])/2;const c=p().domain([a,s]).range(o).clamp(!0);return e=>{var n;const i=null===(n=e.data)||void 0===n?void 0:n[t];return null==i||"number"!=typeof i?o[0]:c(i)}}const Jn=x,ti={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,n,i){if(0===t.length)return;const{padAngle:r=.01,groupWidth:o=20,sortGroups:l}=n,a=Math.min(i[0],i[1])/2,s=a-o,c=i[0]/2,u=i[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),i=f.get(e);if(void 0===n||void 0===i)continue;const r=h(t);g[n][i]=r}const p=ct().padAngle(r);l&&p.sortGroups(l);const v=p(g),m=v.groups,x=U().innerRadius(s).outerRadius(a);for(const e of m){const n=t[e.index],i=x.centroid(e);n.x=i[0]+c,n.y=i[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),i=b.get(e);n&&(t.source=n),i&&(t.target=i)}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,i=t[e.target.index].id,r=k.get(`${n}\0${i}`)||k.get(`${i}\0${n}`);r&&(r.chordData=e)}},buildScene(t,e,n,i){var r,o;const{groupWidth:l=20,edgeOpacity:a=.5}=n,s=Math.min(i[0],i[1])/2,c=s-l,u=i[0]/2,h=i[1]/2,d=n.nodeStyle,f=n.edgeStyle,y=n.edgeColorBy||"source",g=Array.isArray(n.colorScheme)?n.colorScheme:Jn,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],i=n.arcData;if(!i)continue;let o;o=d?d(n).fill||p.get(n.id)||g[e%g.length]:p.get(n.id)||g[e%g.length];const l=d?d(n):{},a={fill:o,stroke:l.stroke||"black",strokeWidth:null!==(r=l.strokeWidth)&&void 0!==r?r:1,opacity:l.opacity};m.push({type:"arc",cx:u,cy:h,innerR:c,outerR:s,startAngle:i.startAngle-Math.PI/2,endAngle:i.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 i=ei(n,u,h);let r="#999";if(f)r=f(t).fill||r;else{const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;"target"===y&&n?r=p.get(n.id)||r:e&&(r=p.get(e.id)||r)}const l=f?f(t):{},s={fill:r,fillOpacity:null!==(o=l.fillOpacity)&&void 0!==o?o:a,stroke:l.stroke||"none",strokeWidth:l.strokeWidth,opacity:l.opacity};x.push({type:"ribbon",pathD:i,style:s,datum:t})}if(!1!==n.showLabels){const e=(k=n.nodeLabel)?"function"==typeof k?k:t=>t[k]||t.id:null,i=s+12;for(const n of t){const t=n.arcData;if(!t)continue;const r=e?e(n):n.id;if(!r)continue;const o=(t.startAngle+t.endAngle)/2,l=o-Math.PI/2;b.push({x:u+Math.cos(l)*i,y:h+Math.sin(l)*i,text:r+"",anchor:o>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var k;return{sceneNodes:m,sceneEdges:x,labels:b}}};function ei(t,e,n){const i=t.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!i)return t;const r=[];let o=0;for(;i.length>o;){const t=i[o];if("M"===t||"L"===t)for(r.push(t),o++;i.length>o&&!isNaN(Number(i[o]));)r.push(Number(i[o])+e+""),o++,i.length>o&&!isNaN(Number(i[o]))&&(r.push(Number(i[o])+n+""),o++);else if("C"===t)for(r.push(t),o++;i.length>o&&!isNaN(Number(i[o]));)for(let t=0;3>t&&i.length>o&&!isNaN(Number(i[o]));t++)r.push(Number(i[o])+e+""),o++,i.length>o&&!isNaN(Number(i[o]))&&(r.push(Number(i[o])+n+""),o++);else if("Q"===t)for(r.push(t),o++;i.length>o&&!isNaN(Number(i[o]));)for(let t=0;2>t&&i.length>o&&!isNaN(Number(i[o]));t++)r.push(Number(i[o])+e+""),o++,i.length>o&&!isNaN(Number(i[o]))&&(r.push(Number(i[o])+n+""),o++);else if("A"===t)for(r.push(t),o++;i.length>o&&!isNaN(Number(i[o]));)r.push(i[o++]),i.length>o&&r.push(i[o++]),i.length>o&&r.push(i[o++]),i.length>o&&r.push(i[o++]),i.length>o&&r.push(i[o++]),i.length>o&&(r.push(Number(i[o])+e+""),o++),i.length>o&&(r.push(Number(i[o])+n+""),o++);else"Z"===t||"z"===t?(r.push(t),o++):(r.push(i[o]),o++)}return r.join(" ")}function ni(t){const[e,n,i]=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*i>150?"#222":"#fff"}const ii={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,n,i){var r;const o=n.__hierarchyRoot;if(!o)return;const l=n.chartType,a=(s=n.childrenAccessor)?"function"==typeof s?s:t=>t[s]:void 0;var s;const c=n.hierarchySum||(t=>{var e;return null!==(e=t.value)&&void 0!==e?e:0}),u=W(o,a);u.sum(c),u.sort((t,e)=>{var n,i;return(null!==(n=e.value)&&void 0!==n?n:0)-(null!==(i=t.value)&&void 0!==i?i:0)});const[h,d]=i;switch(l){case"tree":!function(t,e,n,i){const r=e.treeOrientation||"vertical",o=B();o.size("horizontal"===r?[i,n]:"radial"===r?[2*Math.PI,Math.min(n,i)/2*.8]:[n,i]),o(t)}(u,n,h,d);break;case"cluster":!function(t,e,n,i){const r=e.treeOrientation||"vertical",o=I();o.size("horizontal"===r?[i,n]:"radial"===r?[2*Math.PI,Math.min(n,i)/2*.8]:[n,i]),o(t)}(u,n,h,d);break;case"treemap":!function(t,e,n,i){var r,o;const l=null!==(r=e.padding)&&void 0!==r?r:4,a=null!==(o=e.paddingTop)&&void 0!==o?o:0,s=N().size([n,i]).tile(z).padding(l);a>0&&s.paddingTop(a),s(t)}(u,n,h,d);break;case"circlepack":!function(t,e,n,i){var r;const o=null!==(r=e.padding)&&void 0!==r?r:4;O().size([n,i]).padding(o)(t)}(u,n,h,d);break;case"partition":!function(t,e,n,i){var r;C().size([n,i]).padding(null!==(r=e.padding)&&void 0!==r?r:1)(t)}(u,n,h,d)}const f=u.descendants();t.length=0,e.length=0;const y=new Map;for(let e=0;f.length>e;e++){const i=f[e],o={id:si(i,n,e),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(r=i.value)&&void 0!==r?r:0,depth:i.depth,data:i.data,createdByFrame:!0};"tree"===l||"cluster"===l?ri(o,i,n):"treemap"===l||"partition"===l?oi(o,i):"circlepack"===l&&li(o,i),o.__hierarchyNode=i,t.push(o),y.set(i,o)}if("tree"===l||"cluster"===l)for(const t of f)if(t.parent){const n=y.get(t.parent),i=y.get(t);n&&i&&e.push({source:n,target:i,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,n,i){const r=n.nodeStyle||(()=>({})),o=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(t,e,n,i,r,o){var l,a,s,c,u;const h=[],d=[],f=[],y=n.treeOrientation||"vertical",g="radial"===y,p=i[0]/2,v=i[1]/2,m="number"==typeof(b=n.nodeSize)?b:5,x=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];var b;for(const e of t){let t=e.x,i=e.y;g&&(t+=p,i+=v);const o=r(e);let a=o.fill||"#4d430c";n.colorByDepth&&void 0!==e.depth&&(a=x[e.depth%x.length]);const s={fill:a,stroke:o.stroke||"#fff",strokeWidth:null!==(l=o.strokeWidth)&&void 0!==l?l:1,opacity:o.opacity};h.push({type:"circle",cx:t,cy:i,r:m,style:s,datum:e,id:e.id,label:e.id,depth:e.depth})}const k=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 i=e.x,r=e.y,l=n.x,a=n.y;g&&(i+=p,r+=v,l+=p,a+=v);const u=ai(i,r,l,a,y),h=o(t),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:k};d.push({type:"curved",pathD:u,style:f,datum:t})}if(!1!==n.showLabels){const e=ci(n.nodeLabel);for(const n of t){const t=e?e(n):n.id;if(!t)continue;let i,r,o,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?(i=l+t/n*10,r=a+e/n*10,o=0>t?"end":"start"):(i=l,r=a-12,o="middle")}else"horizontal"===y?((null===(u=n.data)||void 0===u?void 0:u.children)&&0!==n.data.children.length?(i=l-m-6,o="end"):(i=l+m+6,o="start"),r=a):(i=l,r=a+m+14,o="middle");f.push({x:i,y:r,text:t+"",anchor:o,baseline:"middle",fontSize:11})}}return{sceneNodes:h,sceneEdges:d,labels:f}}(t,e,n,i,r,o);case"treemap":case"partition":return function(t,e,n,i){var r,o;const l=[],a=[],s=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const n of t){const t=n.x1-n.x0,o=n.y1-n.y0;if(0>=t||0>=o)continue;const a=i(n);let c=a.fill||"#4d430c";e.colorByDepth&&void 0!==n.depth&&(c=s[n.depth%s.length]);const u={fill:c,stroke:a.stroke||"#fff",strokeWidth:null!==(r=a.strokeWidth)&&void 0!==r?r:1,opacity:a.opacity};l.push({type:"rect",x:n.x0,y:n.y0,w:t,h:o,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==e.showLabels){const n=ci(e.nodeLabel),r=e.labelMode||"leaf",l="partition"===e.chartType;for(const c of t){const t=c.x1-c.x0,u=c.y1-c.y0;if(0>=t||0>=u)continue;const h=!((null===(o=c.data)||void 0===o?void 0:o.children)&&c.data.children.length>0);if(!l){if("leaf"===r&&!h)continue;if("parent"===r&&h)continue}const d=n?n(c):c.id;if(!d)continue;if((h?30:40)>t||(h?16:14)>u)continue;let f=i(c).fill||"#4d430c";e.colorByDepth&&void 0!==c.depth&&(f=s[c.depth%s.length]);const y=ni(f);a.push(h?{x:c.x0+t/2,y:c.y0+u/2,text:d+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,u)/6)),fill:y}:{x:c.x0+4,y:c.y0+12,text:d+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:y})}}return{sceneNodes:l,sceneEdges:[],labels:a}}(t,n,0,r);case"circlepack":return function(t,e,n,i){var r,o,l,a,s;const c=[],u=[],h=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const n of t){const t=null!==(r=n.__radius)&&void 0!==r?r:5;if(0>=t)continue;const a=i(n);let s=a.fill||"#4d430c";e.colorByDepth&&void 0!==n.depth&&(s=h[n.depth%h.length]);const u={fill:s,stroke:a.stroke||"#fff",strokeWidth:null!==(o=a.strokeWidth)&&void 0!==o?o: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=ci(e.nodeLabel);for(const r of t){const t=null!==(a=r.__radius)&&void 0!==a?a:5,o=n?n(r):r.id;if(!o)continue;if(15>t)continue;const l=!((null===(s=r.data)||void 0===s?void 0:s.children)&&r.data.children.length>0);let c=i(r).fill||"#4d430c";if(e.colorByDepth&&void 0!==r.depth&&(c=h[r.depth%h.length]),l){const e=ni(c);u.push({x:r.x,y:r.y,text:o+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,t/3)),fill:e})}else u.push({x:r.x,y:r.y-t+14,text:o+"",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,r);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function ri(t,e,n){const i=n.treeOrientation||"vertical";if("radial"===i){const n=e.x,i=e.y;t.x=i*Math.cos(n-Math.PI/2),t.y=i*Math.sin(n-Math.PI/2)}else"horizontal"===i?(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 oi(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 li(t,e){var n;const i=null!==(n=e.r)&&void 0!==n?n:0;t.x=e.x,t.y=e.y,t.x0=e.x-i,t.x1=e.x+i,t.y0=e.y-i,t.y1=e.y+i,t.width=2*i,t.height=2*i,t.__radius=i}function ai(t,e,n,i,r){if("horizontal"===r){const r=(t+n)/2;return`M ${t},${e} C ${r},${e} ${r},${i} ${n},${i}`}if("radial"===r){const r=(t+n)/2;return`M ${t},${e} Q ${r},${e} ${r},${(e+i)/2} T ${n},${i}`}{const r=(e+i)/2;return`M ${t},${e} C ${t},${r} ${n},${r} ${n},${i}`}}function si(t,e,n){const i=e.nodeIDAccessor;return"function"==typeof i?i(t.data)+"":"string"==typeof i&&void 0!==t.data[i]?t.data[i]+"":void 0!==t.data.name?t.data.name+"":void 0!==t.data.id?t.data.id+"":"node-"+n}function ci(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 ui(t){const e=t;return e.__orbitState||(e.__orbitState={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()}),e.__orbitState}const hi={sankey:qn,force:Kn,chord:ti,tree:ii,cluster:ii,treemap:ii,circlepack:ii,partition:ii,orbit:{supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(t,e,n,i){const r=n.__hierarchyRoot;r&&function(t,e,n,i,r){var o,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!==(o=n.orbitSize)&&void 0!==o?o: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=ui(n);y.metaMap.clear(),i.length=0,r.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));i.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,o,l,u,h,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:h,data:e,parentId:n},M=g?u/d(A)*E:u*E,P=J().value(t=>{var e;return(null===(e=a(t))||void 0===e?void 0:e.length)?4:1}).sort(null),S=P(k),_=f(A);for(let e=0;k.length>e;e++){const a=(S[e].startAngle+S[e].endAngle)/2,c=k[e],u=p(s(c)),d=o+M*Math.sin(a),f=l+M*Math.cos(a)*_;i.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:_}),r.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,v,m,x,1,!1)}(r,i,n,t,e)},buildScene(t,e,n,i){var r,o,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=ui(n),i=new Map;for(const e of t)i.set(e.id,e);const r=new Map;for(const[,t]of e.metaMap){if(!t.parentId)continue;const e=i.get(t.parentId);if(!e)continue;const n=`${t.parentId}:${t.ring}`;r.has(n)||r.set(n,{parentX:e.x,parentY:e.y,ring:t.ring,ecc:t.eccentricity})}const o=48,l={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:t,parentY:e,ring:n,ecc:i}]of r)for(let r=0;o>r;r++){const a=r/o*Math.PI*2,s=(r+1)/o*Math.PI*2;f.push({type:"line",x1:t+n*Math.sin(a),y1:e+n*Math.cos(a)*i,x2:t+n*Math.sin(s),y2:e+n*Math.cos(s)*i,style:l,datum:null})}}for(const e of t){if(null==e.x||null==e.y)continue;const t=h(e),n=c?c(e):{},i={fill:n.fill||"#6366f1",stroke:n.stroke||"#fff",strokeWidth:null!==(r=n.strokeWidth)&&void 0!==r?r:1,opacity:null!==(o=n.opacity)&&void 0!==o?o: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:i,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(n);if(4>=t)continue;const i="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:i+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:d,sceneEdges:f,labels:y}},tick:(t,e,n,i,r)=>!1!==n.orbitAnimated&&(function(t,e){var n,i;const r=ui(e),o=null!==(n=e.orbitSpeed)&&void 0!==n?n:.25,l=null!==(i=e.orbitRevolution)&&void 0!==i?i: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())-r.startTime)/1e3,s=o*(Math.PI/6),c=new Map;for(const e of t)c.set(e.id,e);for(const e of t){const t=r.metaMap.get(e.id);if(!t||!t.parentId)continue;const n=c.get(t.parentId);if(!n)continue;const i=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(i),e.y=n.y+t.ring*Math.cos(i)*t.eccentricity,e.x0=e.x,e.x1=e.x,e.y0=e.y,e.y1=e.y}}(t,n),!0)}};function di(t){return hi[t]}class fi{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({},tn),t.tensionConfig),"sankey"===t.chartType&&t.showParticles&&(this.particlePool=new nn(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({},tn),t.tensionConfig),"sankey"===t.chartType&&t.showParticles&&!this.particlePool&&(this.particlePool=new nn(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:i="id",sourceAccessor:r="source",targetAccessor:o="target",valueAccessor:l="value"}=this.config,a="function"==typeof i?i:t=>t[i],s="function"==typeof r?r:t=>t[r],c="function"==typeof o?o:t=>t[o],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({},yi(t)),{data:e}))}for(let t=0;e.length>t;t++){const n=e[t],i=s(n)+"",r=c(n)+"",o=Number(u(n))||1;this.nodes.has(i)||this.nodes.set(i,Object.assign(Object.assign({},yi(i)),{data:n})),this.nodes.has(r)||this.nodes.set(r,Object.assign(Object.assign({},yi(r)),{data:n}));const l=`${i}\0${r}\0${t}`;this.edges.set(l,{source:i,target:r,value:o,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:i}=t,r=0===this.nodes.size;let o=!1;const l="undefined"!=typeof performance?performance.now():Date.now();this.lastIngestTime=l,this._decaySortedNodes=null,this.nodes.has(e)||(this.nodes.set(e,yi(e)),this.nodeTimestamps.set(e,l),this.tension+=this.tensionConfig.newNode,o=!0),this.nodes.has(n)||(this.nodes.set(n,yi(n)),this.nodeTimestamps.set(n,l),this.tension+=this.tensionConfig.newNode,o=!0);const a=this.edgeKey(e,n),s=this.edges.get(a);let c=!1;return s?(s.value+=i,this.edgeTimestamps.set(a,l),this.tension+=this.tensionConfig.weightChange,c=!0):(this.edges.set(a,{source:e,target:n,value:i,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(a,l),this.tension+=this.tensionConfig.newEdge,o=!0),r||o||c||this.tension>=this.tensionConfig.threshold}runLayout(t){var e,n,i,r,o,l;const a=di(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!==(i=a._prevY1)&&void 0!==i?i:0)-(null!==(r=a._prevY0)&&void 0!==r?r:0);t.set(a.id,{x:(null!==(o=a._prevX0)&&void 0!==o?o: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=di(this.config.chartType);if(!e)return;const n=Array.from(this.nodes.values()),i=Array.from(this.edges.values()),{sceneNodes:r,sceneEdges:o,labels:l}=e.buildScene(n,i,this.config,t);this.sceneNodes=r,this.sceneEdges=o,this.labels=l}get isAnimating(){const t=di(this.config.chartType);return!!(null==t?void 0:t.supportsAnimation)&&!1!==this.config.orbitAnimated}tickAnimation(t,e){const n=di(this.config.chartType);if(!(null==n?void 0:n.tick))return!1;const i=Array.from(this.nodes.values()),r=Array.from(this.edges.values());return n.tick(i,r,this.config,t,e)}advanceTransition(t){if(!this.transition)return!1;const e=Pt(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=St(t._prevX0,t._targetX0,n),t.x1=St(t._prevX1,t._targetX1,n),t.y0=St(t._prevY0,t._targetY0,n),t.y1=St(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=St(t._prevY0,t._targetY0,n),t.y1=St(t._prevY1,t._targetY1,n),t.sankeyWidth=St(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 i=(t.sankeyWidth||1)/2;if("down"===t.direction){const r=e.x1,o=n.x0,l=et(r,o);return{circular:!1,points:[{x:t.y0,y:r},{x:t.y0,y:l(.5)},{x:t.y1,y:l(.5)},{x:t.y1,y:o}],halfWidth:i}}const r=e.x1,o=n.x0,l=et(r,o);return{circular:!1,points:[{x:r,y:t.y0},{x:l(.5),y:t.y0},{x:l(.5),y:t.y1},{x:o,y:t.y1}],halfWidth:i}}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))),i=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-i,y:n.targetY},{x:n.targetX-.66*i,y:n.targetY},{x:n.targetX-.33*i,y:n.targetY},{x:n.targetX,y:n.targetY}]],halfWidth:e}}let i;i="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 r=[];for(let t=0;i.length-1>t;t++){const e=i[t],n=i[t+1],o=n.x-e.x,l=n.y-e.y;r.push([e,{x:e.x+o/3,y:e.y+l/3},{x:e.x+2*o/3,y:e.y+2*l/3},n])}return{circular:!0,segments:r,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,i,r,o;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!==(i=l.glowRadius)&&void 0!==i?i:4;for(const e of this.sceneNodes){const n=e.id;if(!n)continue;const i=this.nodeTimestamps.get(n);if(!i)continue;const r=t-i;a>r&&(e._pulseIntensity=1-r/a,e._pulseColor=s,e._pulseGlowRadius=c)}for(const e of this.sceneEdges){const n=e.datum;if(!n)continue;const i="object"==typeof n.source?null===(r=n.source)||void 0===r?void 0:r.id:n.source,l="object"==typeof n.target?null===(o=n.target)||void 0===o?void 0:o.id:n.target;if(!i||!l)continue;const c=this.edgeTimestamps.get(`${i}\0${l}`);if(!c)continue;const u=t-c;a>u&&(e._pulseIntensity=1-u/a,e._pulseColor=s)}}applyDecay(){var t,e,n,i,r;const o=this.config.decay;if(!o)return;const l=null!==(t=o.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(o.type){case"linear":d=l+(1-h/(a-1))*(1-l);break;case"exponential":{const t=null!==(e=o.halfLife)&&void 0!==e?e:a/2;d=l+Math.pow(.5,h/t)*(1-l);break}case"step":d=(null!==(n=o.stepThreshold)&&void 0!==n?n:.5*a)>h?1:l;break;default:d=1}const f=null!==(r=null===(i=t.style)||void 0===i?void 0:i.opacity)&&void 0!==r?r: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 i=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,i),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 i=this.config.thresholds;if(!i)return;const r=null!==(e=i.warningColor)&&void 0!==e?e:"#f59e0b",o=null!==(n=i.criticalColor)&&void 0!==n?n:"#ef4444",l=!1!==i.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=i.metric(a);let c=null;void 0===i.critical||i.critical>s?void 0===i.warning||i.warning>s||(c=r):c=o,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 yi(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 gi(t,e,n,i,r=30){let o=null,l=r,a=1/0;for(const e of t){const t=pi(e,n,i);if(t)if("rect"===e.type){const n=e.w*e.h;a>n&&(o=t,a=n)}else l>t.distance&&(o=t,l=t.distance)}if(o)return o;for(const t of e){const e=bi(t,n,i);e&&l>e.distance&&(o=e,l=e.distance)}return o}function pi(t,e,n){switch(t.type){case"circle":return function(t,e,n){const i=e-t.cx,r=n-t.cy,o=Math.sqrt(i*i+r*r);return o>Math.max(t.r,5)+5?null:{type:"node",datum:t.datum,x:t.cx,y:t.cy,distance:o}}(t,e,n);case"rect":return function(t,e,n){const i=Lt(e,n,t);return i.hit?{type:"node",datum:t.datum,x:i.cx,y:i.cy,distance:0}:null}(t,e,n);case"arc":return function(t,e,n){const i=e-t.cx,r=n-t.cy,o=Math.sqrt(i*i+r*r);if(t.innerR-2>o||o>t.outerR+2)return null;const l=Dt(Math.atan2(r,i)),a=Dt(t.startAngle),s=Dt(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 vi=null,mi=null;function xi(){return mi||(vi=document.createElement("canvas"),vi.width=1,vi.height=1,mi=vi.getContext("2d")),mi}function bi(t,e,n){switch(t.type){case"bezier":return function(t,e,n){var i,r;if(!t.pathD)return null;try{const o=new Path2D(t.pathD),l=xi();if(!l)return null;if(l.isPointInPath(o,e,n)){const o="object"==typeof(null===(i=t.datum)||void 0===i?void 0:i.source)?t.datum.source:null,l="object"==typeof(null===(r=t.datum)||void 0===r?void 0:r.target)?t.datum.target:null;return{type:"edge",datum:t.datum,x:o&&l?(o.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(o,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 i=t.x2-t.x1,r=t.y2-t.y1,o=i*i+r*r;if(0===o)return null;let l=((e-t.x1)*i+(n-t.y1)*r)/o;l=Math.max(0,Math.min(1,l));const a=t.x1+l*i,s=t.y1+l*r,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 i=new Path2D(t.pathD),r=xi();if(!r)return null;if(r.isPointInPath(i,e,n))return{type:"edge",datum:t.datum,x:e,y:n,distance:0};const o=r.lineWidth;r.lineWidth=10;const l=r.isPointInStroke(i,e,n);if(r.lineWidth=o,l)return{type:"edge",datum:t.datum,x:e,y:n,distance:4}}catch(t){}return null}(t,e,n);default:return null}}function ki(e){const{width:n,height:i,totalWidth:r,totalHeight:o,margin:l,labels:a,title:s,legend:c,legendHoverBehavior:u,legendClickBehavior:h,legendHighlightedCategory:d,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:r,height:o,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,r)=>{if(m){const o=m(e,r,{width:n,height:i,sceneNodes:p});if(o)return t.createElement(t.Fragment,{key:"annotation-"+r},o)}return null}),g),s&&"string"==typeof s?t.createElement("text",{x:r/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor"},s):s?t.createElement("foreignObject",{x:0,y:0,width:r,height:l.top},s):null,qt({legend:c,totalWidth:r,totalHeight:o,margin:l,legendPosition:y,title:s,legendHoverBehavior:u,legendClickBehavior:h,legendHighlightedCategory:d,legendIsolatedCategories:f})),null==v?void 0:v.filter(t=>"widget"===t.type&&t.nodeId&&p).map((e,n)=>{var i,r,o,a,s,c,u,h,d;const f=p.find(t=>{var n,i,r,o,l;return t.id===e.nodeId||(null===(n=t.datum)||void 0===n?void 0:n.id)===e.nodeId||(null===(r=null===(i=t.datum)||void 0===i?void 0:i.data)||void 0===r?void 0:r.id)===e.nodeId||(null===(l=null===(o=t.datum)||void 0===o?void 0:o.data)||void 0===l?void 0:l.name)===e.nodeId});if(!f)return null;const y=l.left+(null!==(i=f.cx)&&void 0!==i?i:null!=f.x&&null!=f.w?f.x+f.w/2:null!==(r=f.x)&&void 0!==r?r:0),g=l.top+(null!==(o=f.cy)&&void 0!==o?o: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!==(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+v-x/2,top:g+m-b/2,width:x,height:b,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:5}},k)}))}function wi(t,e){var n,i,r,o,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 r=t.createLinearGradient(l.x0,0,l.x1,0),o=null!==(i=null!==(n=e.style.fillOpacity)&&void 0!==n?n:e.style.opacity)&&void 0!==i?i:.5,a="string"==typeof e.style.fill?e.style.fill:"#999";r.addColorStop(0,1===l.from?a:"transparent"),r.addColorStop(1,1===l.to?a:"transparent"),t.fillStyle=r,t.globalAlpha=o}else t.fillStyle=e.style.fill,t.globalAlpha=null!==(o=null!==(r=e.style.fillOpacity)&&void 0!==r?r:e.style.opacity)&&void 0!==o?o:.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 Ei(t,e){var n,i;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!==(i=e.style.strokeWidth)&&void 0!==i?i: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 Ai(t,e){var n,i,r,o;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!==(i=null!==(n=e.style.fillOpacity)&&void 0!==n?n:e.style.opacity)&&void 0!==i?i:.5,t.fill(l)),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=e.style.stroke,t.lineWidth=null!==(r=e.style.strokeWidth)&&void 0!==r?r:.5,t.globalAlpha=.3*(null!==(o=e.style.opacity)&&void 0!==o?o: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 Mi(t,e){var n,i;if(!e.pathD)return;t.save();const r=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(r),e.style.fill&&"none"!==e.style.fill&&(t.fillStyle=e.style.fill,t.globalAlpha=null!==(i=e.style.fillOpacity)&&void 0!==i?i:.1,t.fill(r)),t.restore()}ki.displayName="NetworkSVGOverlay";const Pi={top:20,right:80,bottom:20,left:80},Si={top:40,right:40,bottom:40,left:40},_i=new Set(["chord","force","circlepack","orbit"]),Li=[800,600],Di={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 Ti({data:e}){var n,i,r,o,l,a;if("edge"===e.type){const n=e.data;return t.createElement("div",{className:"semiotic-tooltip",style:Di},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!==(o=null!==(i=null===(n=l.data)||void 0===n?void 0:n.name)&&void 0!==i?i:null===(r=l.data)||void 0===r?void 0:r.id)&&void 0!==o?o: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:Di},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:Di},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 $i=c(function(o,l){var s,c,h,d,f,y,g,p,v,m,x;const{chartType:b,nodes:k,edges:w,data:E,initialEdges:A,nodeIDAccessor:M="id",sourceAccessor:P="source",targetAccessor:S="target",valueAccessor:_="value",childrenAccessor:L,hierarchySum:D,orientation:T="horizontal",nodeAlign:$="justify",nodePaddingRatio:W=.05,nodeWidth:C=15,iterations:O=300,forceStrength:N=.1,padAngle:z=.01,groupWidth:I=20,sortGroups:B,edgeSort:j,treeOrientation:R="vertical",edgeType:F="curve",padding:Y,paddingTop:H,tensionConfig:X,showParticles:G=!1,particleStyle:V,nodeStyle:q,edgeStyle:K,colorBy:Z,colorScheme:Q="category10",edgeColorBy:J="source",edgeOpacity:tt=.5,colorByDepth:et=!1,nodeSize:nt=8,nodeSizeRange:it=[5,20],nodeLabel:rt,showLabels:ot=!0,labelMode:lt,size:at=Li,responsiveWidth:st,responsiveHeight:ct,margin:ut,className:ht,background:dt,enableHover:ft=!0,tooltipContent:yt,customHoverBehavior:gt,customClickBehavior:pt,onObservation:vt,chartId:mt,onTopologyChange:xt,annotations:bt,svgAnnotationRules:kt,legend:wt,legendPosition:At,legendHoverBehavior:Mt,legendClickBehavior:Pt,legendHighlightedCategory:St,legendIsolatedCategories:_t,title:Lt,foregroundGraphics:Dt,backgroundGraphics:Tt,decay:$t,pulse:Wt,staleness:Ct,thresholds:Ot,accessibleTable:Nt,orbitMode:zt,orbitSize:It,orbitSpeed:Ft,orbitRevolution:Yt,orbitRevolutionStyle:Ht,orbitEccentricity:Xt,orbitShowRings:Gt,orbitAnimated:Vt}=o,qt=_i.has(b)?Si:Pi,[Kt,Ut]=jt(at,st,ct),Zt=Object.assign(Object.assign({},qt),ut),Qt=Ut[0]-Zt.left-Zt.right,Jt=Ut[1]-Zt.top-Zt.bottom,te="function"==typeof Dt?Dt({size:Ut,margin:Zt}):Dt,ee=r(()=>Object.assign(Object.assign({},tn),X),[X]),ne=r(()=>Object.assign(Object.assign({},en),V),[V]),ie=r(()=>({chartType:b,nodeIDAccessor:M,sourceAccessor:P,targetAccessor:S,valueAccessor:_,childrenAccessor:L,hierarchySum:D,orientation:T,nodeAlign:$,nodePaddingRatio:W,nodeWidth:C,iterations:O,forceStrength:N,padAngle:z,groupWidth:I,sortGroups:B,edgeSort:j,treeOrientation:R,edgeType:F,padding:Y,paddingTop:H,tensionConfig:ee,showParticles:G,particleStyle:ne,nodeStyle:q,edgeStyle:K,nodeLabel:rt,showLabels:ot,labelMode:lt,colorBy:Z,colorScheme:Q,edgeColorBy:J,edgeOpacity:tt,colorByDepth:et,nodeSize:nt,nodeSizeRange:it,decay:$t,pulse:Wt,staleness:Ct,thresholds:Ot,orbitMode:zt,orbitSize:It,orbitSpeed:Ft,orbitRevolution:Yt,orbitRevolutionStyle:Ht,orbitEccentricity:Xt,orbitShowRings:Gt,orbitAnimated:Vt}),[b,M,P,S,_,L,D,T,$,W,C,O,N,z,I,B,j,R,F,Y,H,ee,G,ne,q,K,rt,ot,lt,Z,Q,J,tt,et,nt,it,$t,Wt,Ct,Ot,zt,It,Ft,Yt,Ht,Xt,Gt,Vt]),re=e(null),oe=e(0),le=e(0),ae=e(!0),se=Pe(t=>t.theme),ce=e(()=>{}),ue=e(null);ue.current||(ue.current=new fi(ie));const[he,ye]=n(null),[ge,ve]=n(0),[be,ke]=n(0),[we,Ee]=n(!1),Ae=e(null),Me=e(new Map),Le=e(0),De=a(t=>{if("function"==typeof Z)return Z(t)+"";if("string"==typeof Z&&t.data){const e=t.data[Z];if(void 0!==e){if(!Me.current.has(e+"")){const t=Array.isArray(Q)?Q:Et;Me.current.set(e+"",t[Le.current++%t.length])}return Me.current.get(e+"")}}if(Me.current.has(t.id))return Me.current.get(t.id);const e=Array.isArray(Q)?Q:Et,n=Z?e[Le.current++%e.length]:e[0];return Me.current.set(t.id,n),n},[Z,Q]),Te=a(t=>{if("function"==typeof J)return J(t);const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;return"target"===J&&n?De(n):e?De(e):"#999"},[J,De]),$e=a(t=>{if(!(null==V?void 0:V.colorBy))return Te(t);const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;return"target"===ne.colorBy&&n?De(n):e?De(e):"#999"},[null==V?void 0:V.colorBy,ne.colorBy,De,Te]),Oe="sankey"===b&&G||!!Wt||null!==(c=null===(s=ue.current)||void 0===s?void 0:s.isAnimating)&&void 0!==c&&c,Ne=a(()=>{oe.current&&!Oe||oe.current||(oe.current=requestAnimationFrame(()=>ce.current()))},[Oe]);i(()=>{var t;null===(t=ue.current)||void 0===t||t.updateConfig(ie),ae.current=!0,Ne()},[ie,Ne]),i(()=>{ae.current=!0,Ne()},[se,Ne]);const ze=a(()=>{var t;const e=ue.current;if(!e)return;e.runLayout([Qt,Jt]),e.buildScene([Qt,Jt]),ae.current=!0;for(const n of e.sceneNodes)n.id&&"string"==typeof(null===(t=n.style)||void 0===t?void 0:t.fill)&&Me.current.set(n.id,n.style.fill);const n=Array.isArray(Q)?Q:Et,i=Array.from(e.nodes.values());for(let t=0;i.length>t;t++){const e=i[t];Me.current.has(e.id)||Me.current.set(e.id,n[t%n.length])}if(Le.current=i.length,ve(e.layoutVersion),xt){const{nodes:t,edges:n}=e.getLayoutData();xt(t,n)}},[Qt,Jt,xt,Q]),Ie=a(t=>{const e=ue.current;e&&(e.ingestEdge(t)&&ze(),Ne())},[ze,Ne]),Be=a(t=>{const e=ue.current;if(!e)return;let n=!1;for(const i of t)e.ingestEdge(i)&&(n=!0);n&&ze(),Ne()},[ze,Ne]),je=a(()=>{var t;null===(t=ue.current)||void 0===t||t.clear(),Me.current.clear(),Le.current=0,ve(0),ye(null),Ae.current=null,ae.current=!0,Ne()},[Ne]),Re=a(()=>{const t=ue.current;t&&(t.tension+=999,ze(),Ne())},[ze,Ne]);u(l,()=>({push:Ie,pushMany:Be,clear:je,getTopology:()=>{var t,e;return null!==(e=null===(t=ue.current)||void 0===t?void 0:t.getLayoutData())&&void 0!==e?e:{nodes:[],edges:[]}},getTopologyDiff:()=>{const t=ue.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:Re,getTension:()=>{var t,e;return null!==(e=null===(t=ue.current)||void 0===t?void 0:t.tension)&&void 0!==e?e:0}}),[Ie,Be,je,Re]);const Fe=["tree","cluster","treemap","circlepack","partition","orbit"].includes(b),Ye=Fe?E||(Array.isArray(w)?void 0:w):void 0;i(()=>{var t;const e=ue.current;if(e)if(Fe&&Ye)e.ingestHierarchy(Ye,[Qt,Jt]),e.buildScene([Qt,Jt]),ae.current=!0,Ne();else{const n=k||[],i=Array.isArray(w)?w:[];if(0===n.length&&0===i.length)return;e.ingestBounded(n,i,[Qt,Jt]),e.buildScene([Qt,Jt]);for(const n of e.sceneNodes)n.id&&(null===(t=n.style)||void 0===t?void 0:t.fill)&&Me.current.set(n.id,n.style.fill+"");const r=Array.isArray(Q)?Q:Et,o=Array.from(e.nodes.values());for(let t=0;o.length>t;t++){const e=o[t];Me.current.has(e.id)||Me.current.set(e.id,r[t%r.length])}Le.current=o.length,ae.current=!0,Ne()}},[k,w,E,Ye,Fe,Qt,Jt,ie,Ne,Q]),i(()=>{A&&A.length>0&&Be(A)},[]);const He=a(t=>{if(gt&>(t),vt){const e=Date.now();vt(t?{type:"hover",datum:t.data||{},x:t.x,y:t.y,timestamp:e,chartType:"StreamNetworkFrame",chartId:mt}:{type:"hover-end",timestamp:e,chartType:"StreamNetworkFrame",chartId:mt})}},[gt,vt,mt]),Xe=a(t=>{if(pt&&pt(t),vt){const e=Date.now();vt(t?{type:"click",datum:t.data||{},x:t.x,y:t.y,timestamp:e,chartType:"StreamNetworkFrame",chartId:mt}:{type:"click-end",timestamp:e,chartType:"StreamNetworkFrame",chartId:mt})}},[pt,vt,mt]),Ge=e(()=>{}),Ve=e(()=>{});Ge.current=t=>{if(!ft)return;const e=re.current;if(!e)return;const n=e.getBoundingClientRect(),i=t.clientX-n.left-Zt.left,r=t.clientY-n.top-Zt.top;if(0>i||i>Qt||0>r||r>Jt)return void(Ae.current&&(Ae.current=null,ye(null),He&&(He(null),ae.current=!0),Ne()));const o=ue.current;if(!o)return;const l=gi(o.sceneNodes,o.sceneEdges,i,r);if(!l)return void(Ae.current&&(Ae.current=null,ye(null),He&&(He(null),ae.current=!0),Ne()));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});Ae.current=s,ye(s),He&&(He(s),ae.current=!0),Ne()},Ve.current=()=>{Ae.current&&(Ae.current=null,ye(null),He&&(He(null),ae.current=!0),Ne())};const qe=e(()=>{});qe.current=t=>{if(!pt&&!vt)return;const e=re.current;if(!e)return;const n=e.getBoundingClientRect(),i=t.clientX-n.left-Zt.left,r=t.clientY-n.top-Zt.top;if(0>i||i>Qt||0>r||r>Jt)return;const o=ue.current;if(!o)return;const l=gi(o.sceneNodes,o.sceneEdges,i,r);if(l){const t=l.datum||{};Xe(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 Xe(null)},a(t=>Ge.current(t),[]);const Ke=a(()=>Ve.current(),[]),Ue=a(t=>qe.current(t),[]),Ze=e(-1),Qe=a(t=>{const e=ue.current;if(!e)return;const n=function(t){const e=[];for(const n of t)"circle"===n.type&&null!=n.cx?e.push({x:n.cx,y:n.cy,datum:n.datum}):"rect"===n.type&&null!=n.x?e.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum}):"arc"===n.type&&null!=n.cx&&e.push({x:n.cx,y:n.cy,datum:n.datum});return e.sort((t,e)=>t.x-e.x||t.y-e.y),e}(e.sceneNodes);if(0===n.length)return;const i=Ze.current,r=Bt(t.key,0>i?-1:i,n.length);if(null===r)return;if(t.preventDefault(),0>r)return Ze.current=-1,Ae.current=null,ye(null),He&&(He(null),ae.current=!0),void Ne();const o=0>i?0:r;Ze.current=o;const l=n[o],a=l.datum||{},s=Object.assign(Object.assign({},"object"!=typeof a||null===a||Array.isArray(a)?{}:a),{type:"node",data:a,x:l.x,y:l.y});Ae.current=s,ye(s),He&&(He(s),ae.current=!0),Ne()},[He,Ne]),Je=a(t=>{Ze.current=-1,Ge.current(t)},[]);ce.current=()=>{var t,e,n,i,r,o,l;oe.current=0;const a=re.current;if(!a)return;const s=a.getContext("2d");if(!s)return;const c=ue.current;if(!c)return;const u=performance.now(),h=le.current?Math.min((u-le.current)/1e3,.1):.016;le.current=u;const d=c.advanceTransition(u),f=c.tickAnimation([Qt,Jt],h);(d||ae.current||f)&&c.buildScene([Qt,Jt]);const y=_e();if(!Se(a,Ut,Zt,y))return;s.clearRect(-Zt.left,-Zt.top,Ut[0],Ut[1]),dt&&(s.fillStyle=dt,s.fillRect(0,0,Qt,Jt)),$t&&c.applyDecay(),Wt&&c.applyPulse(u),Ot&&c.applyThresholds(u),c.applyTopologyDiff(u);const g=null!==(t=null==Ct?void 0:Ct.threshold)&&void 0!==t?t:5e3,p=Ct&&c.lastIngestTime>0&&u-c.lastIngestTime>g;if(p&&(s.globalAlpha=null!==(e=null==Ct?void 0:Ct.dimOpacity)&&void 0!==e?e:.5),function(t,e){for(const n of e)switch(n.type){case"bezier":wi(t,n);break;case"line":Ei(t,n);break;case"ribbon":Ai(t,n);break;case"curved":Mi(t,n)}}(s,c.sceneEdges),function(t,e){var n,i,r;for(const o of e){if("rect"!==o.type)continue;const e=o;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!==(i=e.style.strokeWidth)&&void 0!==i?i:1,t.globalAlpha=null!==(r=e.style.opacity)&&void 0!==r?r:1,t.strokeRect(e.x,e.y,e.w,e.h)),We(t,e),t.restore())}}(s,c.sceneNodes),function(t,e){var n,i,r;for(const o of e){if("circle"!==o.type)continue;const e=o;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!==(i=e.style.strokeWidth)&&void 0!==i?i:1,t.globalAlpha=null!==(r=e.style.opacity)&&void 0!==r?r:1,t.stroke()),Ce(t,e),t.restore())}}(s,c.sceneNodes),function(t,e){var n,i,r;for(const o of e){if("arc"!==o.type)continue;const e=o;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!==(i=e.style.strokeWidth)&&void 0!==i?i:1,t.globalAlpha=null!==(r=e.style.opacity)&&void 0!==r?r:1,t.stroke()),t.restore()}}(s,c.sceneNodes),G&&c.particlePool&&!p){const t=Array.from(c.edges.values());if(t.length>0){!function(t,e,n,i){var r,o;const l=null!==(r=i.spawnRate)&&void 0!==r?r:en.spawnRate,a=null!==(o=i.maxPerEdge)&&void 0!==o?o:en.maxPerEdge;for(let i=0;e.length>i;i++){const r=e[i];if(!r.bezier)continue;if(t.countForEdge(i)>=a)continue;const o=r.value*l*n*(r.bezier.circular?.3:1),s=Math.floor(o),c=o-s;let u=s;Math.random()<c&&u++;for(let e=0;u>e&&t.countForEdge(i)<a;e++)t.spawn(i)}}(c.particlePool,t,h,ne);const e=.5*(null!==(n=ne.speedMultiplier)&&void 0!==n?n:1);let i;if(ne.proportionalSpeed){const e=t.reduce((t,e)=>Math.max(t,e.value||1),1);i=t.map(t=>.3+(t.value||1)/e*1.7)}c.particlePool.step(h,e,t,i),function(t,e,n,i,r){var o,l;const a=null!==(o=i.radius)&&void 0!==o?o:en.radius,s=null!==(l=i.opacity)&&void 0!==l?l:en.opacity;t.globalAlpha=s;for(let o=0;e.particles.length>o;o++){const l=e.particles[o];if(!l.active)continue;const s=n[l.edgeIndex];if(s){if("function"==typeof i.color){const e="object"==typeof s.source?s.source:null;t.fillStyle=e?i.color(s,e):"#666"}else t.fillStyle=i.color&&"inherit"!==i.color?i.color:r(s);t.beginPath(),t.arc(l.x,l.y,a,0,2*Math.PI),t.fill()}}t.globalAlpha=1}(s,c.particlePool,t,ne,$e)}}p&&(s.globalAlpha=1);const v=ae.current;if(ae.current=!1,v||d||f){const t=re.current;t&&t.setAttribute("aria-label",pe(null!==(r=null===(i=c.sceneNodes)||void 0===i?void 0:i.length)&&void 0!==r?r:0,null!==(l=null===(o=c.sceneEdges)||void 0===o?void 0:o.length)&&void 0!==l?l:0,"Network chart"))}(v||d||f)&&ke(t=>t+1),(Oe||d||f||c.hasActivePulses||c.hasActiveThresholds||c.hasActiveTopologyDiff)&&(oe.current=requestAnimationFrame(()=>ce.current()))},i(()=>(Ne(),()=>{oe.current&&(cancelAnimationFrame(oe.current),oe.current=0)}),[Ne]),i(()=>{ae.current=!0,Ne()},[b,Qt,Jt,dt,Ne]),Rt(Ct,ue,ae,Ne,we,Ee);const nn=ft&&he?t.createElement("div",{className:"stream-network-tooltip",style:{position:"absolute",left:Zt.left+he.x,top:Zt.top+he.y,transform:`translate(${he.x>.6*Qt?"calc(-100% - 12px)":"12px"}, ${.3*Jt>he.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:2,width:"max-content"}},yt?yt(he):t.createElement(Ti,{data:he})):null;if(fe){const e=ue.current;if(e){const t=["tree","cluster","treemap","circlepack","partition","orbit"].includes(b),n=t?E||(Array.isArray(w)?void 0:w):void 0;if(t&&n)e.ingestHierarchy(n,[Qt,Jt]),e.buildScene([Qt,Jt]);else{const t=k||[],n=Array.isArray(w)?w:[];(t.length>0||n.length>0)&&(e.ingestBounded(t,n,[Qt,Jt]),e.buildScene([Qt,Jt]))}}const n=null!==(h=null==e?void 0:e.sceneNodes)&&void 0!==h?h:[],i=null!==(d=null==e?void 0:e.sceneEdges)&&void 0!==d?d:[],r=null!==(f=null==e?void 0:e.labels)&&void 0!==f?f:[];return t.createElement("div",{className:"stream-network-frame"+(ht?" "+ht:""),role:"img","aria-label":"string"==typeof Lt?Lt:"Network chart",style:{position:"relative",width:Ut[0],height:Ut[1]}},t.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:Ut[0],height:Ut[1],style:{position:"absolute",left:0,top:0}},Tt&&t.createElement("g",{transform:`translate(${Zt.left},${Zt.top})`},Tt),t.createElement("g",{transform:`translate(${Zt.left},${Zt.top})`},dt&&t.createElement("rect",{x:0,y:0,width:Qt,height:Jt,fill:dt}),i.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 i=e;return t.createElement("path",{key:"net-edge-"+n,d:i.pathD,fill:de(i.style.fill,"#999"),fillOpacity:i.style.fillOpacity,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})}case"ribbon":{const i=e;return t.createElement("path",{key:"net-edge-"+n,d:i.pathD,fill:de(i.style.fill,"#999"),fillOpacity:i.style.fillOpacity,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})}case"curved":{const i=e;return t.createElement("path",{key:"net-edge-"+n,d:i.pathD,fill:de(i.style.fill,"none"),stroke:i.style.stroke||"#999",strokeWidth:i.style.strokeWidth||1,opacity:i.style.opacity})}default:return null}}(e,n)).filter(Boolean),n.map((e,n)=>function(e,n){switch(e.type){case"circle":{const i=e;return t.createElement("circle",{key:"net-circle-"+n,cx:i.cx,cy:i.cy,r:i.r,fill:de(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})}case"rect":{const i=e;return t.createElement("rect",{key:"net-rect-"+n,x:i.x,y:i.y,width:i.w,height:i.h,fill:de(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})}case"arc":{const i=e,r=U().innerRadius(i.innerR).outerRadius(i.outerR).startAngle(i.startAngle).endAngle(i.endAngle)({})||"";return t.createElement("path",{key:"net-arc-"+n,d:r,transform:`translate(${i.cx},${i.cy})`,fill:de(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})}default:return null}}(e,n)).filter(Boolean),r.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(ki,{width:Qt,height:Jt,totalWidth:Ut[0],totalHeight:Ut[1],margin:Zt,labels:r,sceneNodes:n,title:Lt,legend:wt,legendPosition:At,legendHoverBehavior:Mt,legendClickBehavior:Pt,legendHighlightedCategory:St,legendIsolatedCategories:_t,foregroundGraphics:te,annotations:bt,svgAnnotationRules:kt,annotationFrame:0}))}const rn=ue.current;return t.createElement("div",{ref:Kt,className:"stream-network-frame"+(ht?" "+ht:""),role:"img","aria-label":"string"==typeof Lt?Lt:"Network chart",tabIndex:0,style:{position:"relative",width:st?"100%":Ut[0],height:ct?"100%":Ut[1],overflow:"visible"},onMouseMove:ft?Je:void 0,onMouseLeave:ft?Ke:void 0,onClick:pt||vt?Ue:void 0,onKeyDown:Qe},Tt&&t.createElement("svg",{overflow:"visible",style:{position:"absolute",top:0,left:0,width:Ut[0],height:Ut[1],pointerEvents:"none",overflow:"visible"}},t.createElement("g",{transform:`translate(${Zt.left},${Zt.top})`},Tt)),t.createElement("canvas",{ref:re,"aria-label":pe(null!==(g=null===(y=null==rn?void 0:rn.sceneNodes)||void 0===y?void 0:y.length)&&void 0!==g?g:0,null!==(v=null===(p=null==rn?void 0:rn.sceneEdges)||void 0===p?void 0:p.length)&&void 0!==v?v:0,"Network chart"),style:{position:"absolute",top:0,left:0}}),t.createElement(xe,{hoverPoint:he}),Nt&&t.createElement(me,{nodes:null!==(m=null==rn?void 0:rn.sceneNodes)&&void 0!==m?m:[],edges:null!==(x=null==rn?void 0:rn.sceneEdges)&&void 0!==x?x:[],chartType:"Network chart"}),t.createElement(ki,{width:Qt,height:Jt,totalWidth:Ut[0],totalHeight:Ut[1],margin:Zt,labels:(null==rn?void 0:rn.labels)||[],sceneNodes:null==rn?void 0:rn.sceneNodes,title:Lt,legend:wt,legendPosition:At,legendHoverBehavior:Mt,legendClickBehavior:Pt,legendHighlightedCategory:St,legendIsolatedCategories:_t,foregroundGraphics:te,annotations:bt,svgAnnotationRules:kt,annotationFrame:be}),nn,(null==Ct?void 0:Ct.showBadge)&&t.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===Ct.badgePosition?{top:4,left:4}:"bottom-left"===Ct.badgePosition?{bottom:4,left:4}:"bottom-right"===Ct.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{background:we?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"})},we?"STALE":"LIVE"))});function Wi(t){const e=[];for(const[n,i]of Object.entries(t.fields))if("point"===i.type)e.push(t=>i.values.has(t[n]));else{const[t,r]=i.range;e.push(e=>{const i=e[n];return i>=t&&r>=i})}return t=>e.every(e=>e(t))}function Ci(t,e){let n=t.get(e);return n||(n={name:e,resolution:"union",clauses:new Map},t.set(e,n)),n}$i.displayName="StreamNetworkFrame";const[Oi,Ni]=be(t=>({selections:new Map,setClause(e,n){t(t=>{const i=new Map(t.selections),r=Ci(i,e),o=new Map(r.clauses);return o.set(n.clientId,n),i.set(e,Object.assign(Object.assign({},r),{clauses:o})),{selections:i}})},clearClause(e,n){t(t=>{const i=t.selections.get(e);if(!i)return{};const r=new Map(t.selections),o=new Map(i.clauses);return o.delete(n),r.set(e,Object.assign(Object.assign({},i),{clauses:o})),{selections:r}})},setResolution(e,n){t(t=>{const i=new Map(t.selections),r=Ci(i,e);return i.set(e,Object.assign(Object.assign({},r),{resolution:n})),{selections:i}})},clearSelection(e){t(t=>{const n=new Map(t.selections),i=n.get(e);return i&&n.set(e,Object.assign(Object.assign({},i),{clauses:new Map})),{selections:n}})}})),[zi,Ii]=be(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 Bi(t){const e=h(),n=t.clientId||e,{name:i}=t,o=Ni(t=>t.selections.get(i)),l=Ni(t=>t.setClause),s=Ni(t=>t.clearClause),c=r(()=>!!o&&o.clauses.size>0,[o]);return{predicate:r(()=>o&&0!==o.clauses.size?function(t,e){const n=[];for(const[i,r]of t.clauses)"crossfilter"===t.resolution&&i===e||n.push(Wi(r));return 0===n.length?()=>!0:"intersect"===t.resolution?t=>n.every(e=>e(t)):t=>n.some(e=>e(t))}(o,n):()=>!0,[o,n]),isActive:c,selectPoints:a(t=>{const e={};for(const[n,i]of Object.entries(t))e[n]={type:"point",values:new Set(i)};l(i,{clientId:n,type:"point",fields:e})},[n,i,l]),selectInterval:a(t=>{const e={};for(const[n,i]of Object.entries(t))e[n]={type:"interval",range:i};l(i,{clientId:n,type:"interval",fields:e})},[n,i,l]),clear:a(()=>{s(i,n)},[s,i,n]),clientId:n}}function ji({selection:t,linkedHover:e,fallbackFields:n=[],unwrapData:i=!1,onObservation:r,chartType:o,chartId:l}){const s=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}:null}(e,n),c=Bi({name:(null==t?void 0:t.name)||"__unused__"}),u=function(t){const e=t.name||"hover",{fields:n}=t,{predicate:i,isActive:r,selectPoints:o,clear:l}=Bi({name:e});return{onHover:a(t=>{if(!t)return void l();const e={};for(const i of n){const n=t[i];void 0!==n&&(e[i]=[n])}Object.keys(e).length>0&&o(e)},[n,o,l,e]),predicate:i,isActive:r}}({name:(null==s?void 0:s.name)||"hover",fields:(null==s?void 0:s.fields)||n||[]}),h=Ii(t=>t.pushObservation);return{activeSelectionHook:t?{isActive:c.isActive,predicate:c.predicate}:null,customHoverBehavior:a(t=>{var n,i;if(e)if(t){let e=t.data||t.datum||t;Array.isArray(e)&&(e=e[0]),u.onHover(e)}else u.onHover(null);if(r||h){const e={timestamp:Date.now(),chartType:o||"unknown",chartId:l};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!==(i=t.y)&&void 0!==i?i:0});r&&r(l),h&&h(l)}else{const t=Object.assign(Object.assign({},e),{type:"hover-end"});r&&r(t),h&&h(t)}}},[e,u,r,o,l,h]),customClickBehavior:a(t=>{var e,n;if(r||h){const i={timestamp:Date.now(),chartType:o||"unknown",chartId:l};if(t){let o=t.data||t.datum||t;Array.isArray(o)&&(o=o[0]);const l=Object.assign(Object.assign({},i),{type:"click",datum:o||{},x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(n=t.y)&&void 0!==n?n:0});r&&r(l),h&&h(l)}else{const t=Object.assign(Object.assign({},i),{type:"click-end"});r&&r(t),h&&h(t)}}},[r,h,o,l])}}const Ri={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 Fi(t,e,n){var i,r,o,l,a,s;const c=Ri[t||"primary"],u="context"===t||"sparkline"===t;return{width:null!==(i=e.width)&&void 0!==i?i:c.width,height:null!==(r=e.height)&&void 0!==r?r:c.height,showAxes:c.showAxes,showGrid:null!==(o=e.showGrid)&&void 0!==o?o: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,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:Yi(c.marginDefaults,e.showCategoryTicks,e.orientation)}}function Yi(t,e,n){if(!1!==e)return t;const i=Object.assign({},t);return"horizontal"===n?i.left=Math.min(i.left,15):i.bottom=Math.min(i.bottom,15),i}"undefined"!=typeof process&&process;const Hi={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"},Xi={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function Gi(e,n,i,r){return!1===r||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?t.createElement("div",{style:Object.assign(Object.assign({},Hi),{width:n,height:i})},r||"No data available"):null}function Vi(e,n,i){if(!e)return null;const r=Math.min(5,Math.floor(i/40)),o=Math.max(8,Math.floor(i/(3*r))),l=Math.max(6,Math.floor(i/(2.5*r))),a=Math.floor((i-(r*(o+l)-l))/2);return t.createElement("div",{style:{width:n,height:i,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"}},Array.from({length:r},(e,i)=>t.createElement("div",{key:i,className:"semiotic-loading-bar",style:Object.assign(Object.assign({},Xi),{position:"absolute",top:a+i*(o+l),left:Math.floor(.1*n),width:30+(37*i+13)%50+"%",height:o,opacity:.5+i%2*.2})})))}const qi=c(function(n,i){var r,o,l,s;const c=Fi(n.mode,{width:null!==(o=null===(r=n.size)||void 0===r?void 0:r[0])&&void 0!==o?o:n.width,height:null!==(s=null===(l=n.size)||void 0===l?void 0:l[1])&&void 0!==s?s: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:v,timeAccessor:m,valueAccessor:x,timeExtent:b,valueExtent:k,extentPadding:w,stroke:E="#007bff",strokeWidth:A=2,strokeDasharray:M,background:P,tooltipContent:S,tooltip:_,onHover:L,annotations:D,svgAnnotationRules:T,tickFormatTime:$,tickFormatValue:W,decay:C,pulse:O,staleness:N,transition:z,linkedHover:I,selection:B,onObservation:j,chartId:R,loading:F,emptyContent:Y,emphasis:H,legendPosition:X}=n,G=c.showAxes,V=c.enableHover,q=null!=d?d:c.marginDefaults,K=null!=h?h:[c.width,c.height],U=null!=S?S:_,Z=e(null),{customHoverBehavior:Q}=ji({selection:B,linkedHover:I,unwrapData:!0,onObservation:j,chartType:"RealtimeLineChart",chartId:R}),J=a(t=>{L&&L(t),Q(t)},[L,Q]);u(i,()=>({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=Vi(F,K[0],K[1]),et=tt?null:Gi(v,K[0],K[1],Y),nt={stroke:E,strokeWidth:A,strokeDasharray:M};return tt||et||t.createElement(Je,{ref:Z,chartType:"line",runtimeMode:"streaming",size:K,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:P,hoverAnnotation:V,tooltipContent:U,customHoverBehavior:J,annotations:D,svgAnnotationRules:T,tickFormatTime:$,tickFormatValue:W,decay:C,pulse:O,staleness:N,transition:z,legendPosition:X})});qi.displayName="RealtimeLineChart";const Ki=c(function(n,i){var r,o,l,s;const c=Fi(n.mode,{width:null!==(o=null===(r=n.size)||void 0===r?void 0:r[0])&&void 0!==o?o:n.width,height:null!==(s=null===(l=n.size)||void 0===l?void 0:l[1])&&void 0!==s?s:n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0}),{binSize:h,size:d,margin:f,className:y,arrowOfTime:g="right",windowMode:p="sliding",windowSize:v=200,data:m,timeAccessor:x,valueAccessor:b,timeExtent:k,valueExtent:w,extentPadding:E,categoryAccessor:A,colors:M,fill:P,stroke:S,strokeWidth:_,gap:L,background:D,tooltipContent:T,tooltip:$,onHover:W,annotations:C,svgAnnotationRules:O,tickFormatTime:N,tickFormatValue:z,linkedHover:I,selection:B,decay:j,pulse:R,staleness:F,transition:Y,onObservation:H,chartId:X,loading:G,emptyContent:V,emphasis:q,legendPosition:K}=n,U=c.showAxes,Z=c.enableHover,Q=null!=f?f:c.marginDefaults,J=null!=d?d:[c.width,c.height],tt=null!=T?T:$,et=e(null),{customHoverBehavior:nt}=ji({selection:B,linkedHover:I,unwrapData:!0,onObservation:H,chartType:"RealtimeTemporalHistogram",chartId:X}),it=a(t=>{W&&W(t),nt(t)},[W,nt]);u(i,()=>({push:t=>{var e;return null===(e=et.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=et.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=et.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=et.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const rt=Vi(G,J[0],J[1]),ot=rt?null:Gi(m,J[0],J[1],V),lt={};return null!=P&&(lt.fill=P),null!=S&&(lt.stroke=S),null!=_&&(lt.strokeWidth=_),null!=L&&(lt.gap=L),rt||ot||t.createElement(Je,{ref:et,chartType:"bar",runtimeMode:"streaming",size:J,margin:Q,className:q?`${y||""} semiotic-emphasis-${q}`.trim():y,arrowOfTime:g,windowMode:p,windowSize:v,data:m,timeAccessor:x,valueAccessor:b,xExtent:k,yExtent:w,extentPadding:E,binSize:h,categoryAccessor:A,barColors:M,barStyle:lt,showAxes:U,background:D,hoverAnnotation:Z,tooltipContent:tt,customHoverBehavior:it,annotations:C,svgAnnotationRules:O,tickFormatTime:N,tickFormatValue:z,decay:j,pulse:R,staleness:F,transition:Y,legendPosition:K})});Ki.displayName="RealtimeTemporalHistogram";const Ui=Ki,Zi=c(function(n,i){var r,o,l,s;const c=Fi(n.mode,{width:null!==(o=null===(r=n.size)||void 0===r?void 0:r[0])&&void 0!==o?o:n.width,height:null!==(s=null===(l=n.size)||void 0===l?void 0:l[1])&&void 0!==s?s: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:v,timeAccessor:m,valueAccessor:x,timeExtent:b,valueExtent:k,extentPadding:w,categoryAccessor:E,colors:A,radius:M,fill:P,opacity:S,stroke:_,strokeWidth:L,background:D,tooltipContent:T,tooltip:$,onHover:W,annotations:C,svgAnnotationRules:O,tickFormatTime:N,tickFormatValue:z,linkedHover:I,selection:B,onObservation:j,chartId:R,loading:F,emptyContent:Y,emphasis:H,legendPosition:X}=n,G=c.showAxes,V=c.enableHover,q=null!=d?d:c.marginDefaults,K=null!=h?h:[c.width,c.height],U=null!=T?T:$,Z=e(null),{customHoverBehavior:Q}=ji({selection:B,linkedHover:I,unwrapData:!0,onObservation:j,chartType:"RealtimeSwarmChart",chartId:R}),J=a(t=>{W&&W(t),Q(t)},[W,Q]);u(i,()=>({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=Vi(F,K[0],K[1]),et=tt?null:Gi(v,K[0],K[1],Y),nt={};return null!=M&&(nt.radius=M),null!=P&&(nt.fill=P),null!=S&&(nt.opacity=S),null!=_&&(nt.stroke=_),null!=L&&(nt.strokeWidth=L),tt||et||t.createElement(Je,{ref:Z,chartType:"swarm",runtimeMode:"streaming",size:K,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:D,hoverAnnotation:V,tooltipContent:U,customHoverBehavior:J,annotations:C,svgAnnotationRules:O,tickFormatTime:N,tickFormatValue:z,legendPosition:X})});Zi.displayName="RealtimeSwarmChart";const Qi=c(function(n,i){var r,o,l,s;const c=Fi(n.mode,{width:null!==(o=null===(r=n.size)||void 0===r?void 0:r[0])&&void 0!==o?o:n.width,height:null!==(s=null===(l=n.size)||void 0===l?void 0:l[1])&&void 0!==s?s: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:v,timeAccessor:m,valueAccessor:x,timeExtent:b,valueExtent:k,extentPadding:w,positiveColor:E,negativeColor:A,connectorStroke:M,connectorWidth:P,gap:S,stroke:_,strokeWidth:L,background:D,tooltipContent:T,tooltip:$,onHover:W,annotations:C,svgAnnotationRules:O,tickFormatTime:N,tickFormatValue:z,linkedHover:I,selection:B,onObservation:j,chartId:R,loading:F,emptyContent:Y,emphasis:H,legendPosition:X}=n,G=c.showAxes,V=c.enableHover,q=null!=d?d:c.marginDefaults,K=null!=h?h:[c.width,c.height],U=null!=T?T:$,Z=e(null),{customHoverBehavior:Q}=ji({selection:B,linkedHover:I,unwrapData:!0,onObservation:j,chartType:"RealtimeWaterfallChart",chartId:R}),J=a(t=>{W&&W(t),Q(t)},[W,Q]);u(i,()=>({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=Vi(F,K[0],K[1]),et=tt?null:Gi(v,K[0],K[1],Y),nt={};return null!=E&&(nt.positiveColor=E),null!=A&&(nt.negativeColor=A),null!=M&&(nt.connectorStroke=M),null!=P&&(nt.connectorWidth=P),null!=S&&(nt.gap=S),null!=_&&(nt.stroke=_),null!=L&&(nt.strokeWidth=L),tt||et||t.createElement(Je,{ref:Z,chartType:"waterfall",runtimeMode:"streaming",size:K,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:D,hoverAnnotation:V,tooltipContent:U,customHoverBehavior:J,annotations:C,svgAnnotationRules:O,tickFormatTime:N,tickFormatValue:z,legendPosition:X})});Qi.displayName="RealtimeWaterfallChart";const Ji=c(function(n,i){var r,o,l,s;const c=Fi(n.mode,{width:null!==(o=null===(r=n.size)||void 0===r?void 0:r[0])&&void 0!==o?o:n.width,height:null!==(s=null===(l=n.size)||void 0===l?void 0:l[1])&&void 0!==s?s: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:v,timeAccessor:m,valueAccessor:x,categoryAccessor:b,timeExtent:k,valueExtent:w,extentPadding:E,heatmapXBins:A=20,heatmapYBins:M=20,aggregation:P="count",background:S,tooltipContent:_,tooltip:L,onHover:D,annotations:T,svgAnnotationRules:$,tickFormatTime:W,tickFormatValue:C,decay:O,pulse:N,staleness:z,linkedHover:I,selection:B,onObservation:j,chartId:R,loading:F,emptyContent:Y,emphasis:H,legendPosition:X}=n,G=c.showAxes,V=c.enableHover,q=null!=d?d:c.marginDefaults,K=null!=h?h:[c.width,c.height],U=null!=_?_:L,Z=e(null),{customHoverBehavior:Q}=ji({selection:B,linkedHover:I,unwrapData:!0,onObservation:j,chartType:"RealtimeHeatmap",chartId:R}),J=a(t=>{D&&D(t),Q(t)},[D,Q]);u(i,()=>({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=Vi(F,K[0],K[1]),et=tt?null:Gi(v,K[0],K[1],Y);return tt||et||t.createElement(Je,{ref:Z,chartType:"heatmap",runtimeMode:"streaming",size:K,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:P,showAxes:G,background:S,hoverAnnotation:V,tooltipContent:U,customHoverBehavior:J,annotations:T,svgAnnotationRules:$,tickFormatTime:W,tickFormatValue:C,decay:O,pulse:N,staleness:z,legendPosition:X})});Ji.displayName="RealtimeHeatmap";export{dt as IncrementalExtent,Ji as RealtimeHeatmap,Ui as RealtimeHistogram,qi as RealtimeLineChart,Zi as RealtimeSwarmChart,Qi as RealtimeWaterfallChart,ht as RingBuffer,$i as StreamNetworkFrame,Je as StreamXYFrame};
|