semiotic 3.1.0 → 3.1.2

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.
@@ -1 +1 @@
1
- "use strict";const t=require("react"),e=require("d3-brush"),n=require("d3-selection"),i=require("d3-scale"),r=require("d3-scale-chromatic"),o=require("d3-quadtree"),a=require("d3-array"),l=require("d3-hierarchy"),s=require("d3-shape"),c=require("regression"),u=require("d3-interpolate"),h=require("d3-force"),d=require("d3-chord");function f(t){return t&&t.__esModule?t:{default:t}}function y(t){if(t&&t.__esModule)return t;const e=Object.create(null);if(t)for(const n in t)if("default"!==n){const i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,i.get?i:{enumerable:!0,get:function(){return t[n]}})}return e.default=t,Object.freeze(e)}const g=y(t),p=f(c);class v{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 m{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 x{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 b(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 k(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 w(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 E(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 A(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 M(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 S(t,e){if("function"==typeof t)return e=>+t(e);const n=t||e;return t=>+t[n]}function P(t,e){if("function"==typeof t)return t;const n=t||e;return t=>t[n]}function _(t,e){return"function"==typeof t?t:t?e=>e[t]+"":void 0}const L=r.schemeCategory10,C=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];function D(t,e="ease-out-cubic"){return"linear"===e?t:1-Math.pow(1-t,3)}function T(t,e){return Math.min((t-e.startTime)/e.duration,1)}function W(t,e,n){return t+(e-t)*n}class ${constructor(t){this.xExtent=new x,this.yExtent=new x,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 m(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=S(t.timeAccessor||t.xAccessor,"time"),this.getY=S(t.valueAccessor||t.yAccessor,"value")):(this.getX=S(t.xAccessor,"x"),this.getY=S(t.yAccessor,"y")),this.getGroup=_(t.groupAccessor),this.getCategory=_(t.categoryAccessor),this.getSize=t.sizeAccessor?S(t.sizeAccessor,"size"):void 0,this.getColor=_(t.colorAccessor),this.getBounds=t.boundsAccessor?S(t.boundsAccessor,"bounds"):void 0,this.getY0=t.y0Accessor?S(t.y0Accessor,"y0"):void 0,this.getPointId=_(t.pointIdAccessor),"candlestick"===t.chartType&&(this.getOpen=S(t.openAccessor,"open"),this.getHigh=S(t.highAccessor,"high"),this.getLow=S(t.lowAccessor,"low"),this.getClose=S(t.closeAccessor,"close")),t.pulse&&(this.timestampBuffer=new m(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,r,o,a,l;const{config:s,buffer:c}=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(c,this.getX),this.yExtent.dirty)if("candlestick"===s.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const t of c)this.yExtent.push(this.getHigh(t)),this.yExtent.push(this.getLow(t))}else this.yExtent.recalculate(c,this.getY);const u=this.getBufferArray(),h=this.xExtent.extent,d=this.yExtent.extent;let f=s.xExtent?[null!==(e=s.xExtent[0])&&void 0!==e?e:h[0],null!==(n=s.xExtent[1])&&void 0!==n?n:h[1]]:h,y=s.yExtent?[null!==(r=s.yExtent[0])&&void 0!==r?r:d[0],null!==(o=s.yExtent[1])&&void 0!==o?o:d[1]]:d;const g=s.yExtent&&null!=s.yExtent[0]&&null!=s.yExtent[1];if("stackedarea"===s.chartType&&!g&&c.size>0)if(s.normalize)y=[0,1+s.extentPadding];else{const t=`${c.size}:${this._ingestVersion}`;if(this._stackExtentCache&&this._stackExtentCache.key===t)y=this._stackExtentCache.yDomain;else{const e=this.groupData(u),n=new Map;for(const t of e)for(const e of t.data){const t=this.getX(e),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);y=[0,i+(i>0?i*s.extentPadding:1)],this._stackExtentCache={key:t,yDomain:y}}}else if("bar"===s.chartType&&s.binSize&&!g&&c.size>0){const[,t]=function(t,e,n,i,r){const o=b(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]}(c,this.getX,this.getY,s.binSize,this.getCategory);y=[0,t+t*s.extentPadding]}else if("waterfall"===s.chartType&&!g&&c.size>0){const[t,e]=function(t,e){let n=0,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]}(c,this.getY),n=e-t,i=n>0?n*s.extentPadding:1;y=[Math.min(0,t-Math.abs(i)),Math.max(0,e+Math.abs(i))]}else if(!g&&y[0]!==1/0){if(this.getBounds)for(const t of u){const e=this.getY(t),n=this.getBounds(t);null!=e&&!Number.isNaN(e)&&n&&(e+n>y[1]&&(y[1]=e+n),y[0]>e-n&&(y[0]=e-n))}const t=y[1]-y[0],e=t>0?t*s.extentPadding:1,n=null===(a=s.yExtent)||void 0===a?void 0:a[0],i=null===(l=s.yExtent)||void 0===l?void 0:l[1];y=[null!=n?y[0]:y[0]-e,null!=i?y[1]:y[1]+e],"log"===s.yScaleType&&0>=y[0]&&d[0]>0&&(y[0]=null!=n?y[0]:d[0]/(1+s.extentPadding))}if(f[0]!==1/0&&f[1]!==-1/0||(f=[0,1]),y[0]!==1/0&&y[1]!==-1/0||(y=[0,1]),"streaming"===s.runtimeMode)if("x"==("up"===(p=s.arrowOfTime)||"down"===p?"y":"x")){const e="right"===s.arrowOfTime?[0,t.width]:[t.width,0];this.scales={x:i.scaleLinear().domain(f).range(e),y:i.scaleLinear().domain(y).range([t.height,0])}}else{const e="down"===s.arrowOfTime?[0,t.height]:[t.height,0];this.scales={x:i.scaleLinear().domain(y).range([0,t.width]),y:i.scaleLinear().domain(f).range(e)}}else{const e=(t,e,n)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return i.scaleLog().domain(t).range(n).clamp(!0)}return i.scaleLinear().domain(e).range(n)};this.scales={x:e(s.xScaleType,f,[0,t.width]),y:e(s.yScaleType,y,[t.height,0])}}var p;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(t,u),this.config.decay&&this.applyDecay(this.scene,u),this.config.pulse&&this.applyPulse(this.scene,u),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.rebuildQuadtree(),this.needsFullRebuild=!1,this.lastLayout={width:t.width,height:t.height},this.version++}rebuildQuadtree(){const t=this.config.chartType;if("scatter"!==t&&"bubble"!==t)return void(this._quadtree=null);const e=this.scene.filter(t=>"point"===t.type);this._quadtree=e.length>$.QUADTREE_THRESHOLD?o.quadtree().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 r=this.scales.x.domain(),o=this.scales.y.domain(),a=this.scales.x.range(),l=this.scales.y.range(),s=(t,e,n)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return i.scaleLog().domain(t).range(n).clamp(!0)}return i.scaleLinear().domain(e).range(n)};this.scales={x:s(this.config.xScaleType,r,[a[0]*e,a[1]*e]),y:s(this.config.yScaleType,o,[l[0]*n,l[1]*n])},this.lastLayout={width:t.width,height:t.height},this.rebuildQuadtree(),this.version++}buildSceneNodes(t,e){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=k(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=w(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=E(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 o=S(this.config.valueAccessor,"value"),a=P(this.config.xAccessor,"x"),l=P(this.config.yAccessor,"y"),s=new Set,c=new Set;for(const e of t)s.add(a(e)),c.add(l(e));const u=Array.from(s),h=Array.from(c),d=u.every(t=>"number"==typeof t&&!isNaN(t)),f=h.every(t=>"number"==typeof t&&!isNaN(t)),y=d?u.sort((t,e)=>t-e):u,g=f?h.sort((t,e)=>t-e):h;if(0===y.length||0===g.length)return n;const p=e.width/y.length,v=e.height/g.length,m=new Map;for(const e of t){const t=`${a(e)}\0${l(e)}`;m.set(t,{val:o(e),datum:e})}let x=1/0,b=-1/0;for(const{val:t}of m.values())x>t&&(x=t),t>b&&(b=t);const k=i.scaleSequential({blues:r.interpolateBlues,reds:r.interpolateReds,greens:r.interpolateGreens,viridis:r.interpolateViridis}["string"==typeof this.config.colorScheme?this.config.colorScheme:"blues"]||r.interpolateBlues).domain([x,b]);for(let t=0;y.length>t;t++)for(let e=0;g.length>e;e++){const i=m.get(`${y[t]}\0${g[e]}`);if(!i)continue;const r=k(i.val);n.push(M(t*p,(g.length-1-e)*v,p,v,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=S(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(M(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=b(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(A(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(A(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(A(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 S=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 P=!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]];P=!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]];P=!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}),P=!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,P=!0)}else p._targetOpacity=null!==(o=p.style.opacity)&&void 0!==o?o:1,p.style=Object.assign(Object.assign({},p.style),{opacity:0}),P=!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,P=!0)}else p._targetOpacity=null!==(c=p.style.opacity)&&void 0!==c?c:1,p.style=Object.assign(Object.assign({},p.style),{opacity:0}),P=!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,P=!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}),P=!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),P=!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),P=!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)}P=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),P&&(this.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:S})}advanceTransition(t){var e,n,i,r,o,a;if(!this.activeTransition)return!1;const l=T(t,this.activeTransition),s=D(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=W(r,t._targetOpacity,s)}if(void 0===t._targetX)continue;if(!e)continue;const i=this.prevPositionMap.get(e);if(!i)continue;t.x=W(i.x,t._targetX,s),t.y=W(i.y,t._targetY,s),void 0!==t._targetR&&void 0!==i.r&&(t.r=W(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=W(r,t._targetOpacity,s)}if(void 0===t._targetX)continue;if(!e)continue;const n=this.prevPositionMap.get(e);if(!n)continue;t.x=W(n.x,t._targetX,s),t.y=W(n.y,t._targetY,s),void 0!==n.w&&(t.w=W(n.w,t._targetW,s)),void 0!==n.h&&(t.h=W(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:W(i,t._targetOpacity,s)})}if(void 0===t._targetX)continue;if(!e)continue;const n=this.prevPositionMap.get(e);if(!n)continue;t.x=W(n.x,t._targetX,s),t.y=W(n.y,t._targetY,s),void 0!==n.w&&(t.w=W(n.w,t._targetW,s)),void 0!==n.h&&(t.h=W(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:W(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]=W(e[i][0],n[i][0],s),t.path[i][1]=W(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:W(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]=W(e[n][0],i[n][0],s),t.topPath[n][1]=W(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]=W(n[e][0],r[e][0],s),t.bottomPath[e][1]=W(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:C,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:C,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=S(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=S(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=S(this.config.xAccessor,"x"),this.getY=S(this.config.yAccessor,"y"))),void 0!==t.groupAccessor&&(this.getGroup=_(this.config.groupAccessor)),void 0!==t.categoryAccessor&&(this.getCategory=_(this.config.categoryAccessor)),void 0!==t.sizeAccessor&&(this.getSize=this.config.sizeAccessor?S(this.config.sizeAccessor,"size"):void 0),void 0!==t.colorAccessor&&(this.getColor=_(this.config.colorAccessor)),void 0!==t.y0Accessor&&(this.getY0=this.config.y0Accessor?S(this.config.y0Accessor,"y0"):void 0),void 0!==t.pointIdAccessor&&(this.getPointId=_(this.config.pointIdAccessor)),this.needsFullRebuild=!0}}function N(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 O(t){let e=t%(2*Math.PI);return 0>e&&(e+=2*Math.PI),e}function z(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 I(t,e,n){var i,r,o,a;if(0===t.path.length)return null;const l=H(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=R(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 R(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 B(t,e,n){const i=N(e,n,t);return i.hit?{node:t,datum:t.datum,x:i.cx,y:i.cy,distance:0}:null}function j(t,e,n){const i=N(e,n,t);return i.hit?{node:t,datum:t.datum,x:i.cx,y:i.cy,distance:0}:null}function F(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 Y(t,e,n){if(0===t.topPath.length)return null;const i=H(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 H(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 X(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 G(e,n,i){const r=t.useRef(null),[o,a]=t.useState(null);return t.useEffect(()=>{if(!n&&!i)return;const t=r.current;if(!t)return;const e=new ResizeObserver(t=>{for(const e of t){const{width:t,height:n}=e.contentRect;a(e=>e&&e.w===t&&e.h===n?e:{w:t,h:n})}});return e.observe(t),()=>e.disconnect()},[n,i]),[r,[n&&o?o.w:e[0],i&&o?o.h:e[1]]]}function q(e,n,i,r,o,a){t.useEffect(()=>{if(!e)return;const t=setInterval(()=>{var t;const l=n.current;if(!l||0===l.lastIngestTime)return;const s="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(t=e.threshold)&&void 0!==t?t:5e3,u=s-l.lastIngestTime>c;u!==o&&(a(u),i.current=!0,r())},1e3);return()=>clearInterval(t)},[e,o,r])}$.QUADTREE_THRESHOLD=500;const V={fill:t=>g.createElement("rect",{style:t,width:16,height:16}),line:t=>g.createElement("line",{style:t,x1:0,y1:0,x2:16,y2:16})};function K(t,e,n,i){let r;return r="function"==typeof n?n(t):(0,V[n])(i(t,e)),r}function Z(){return g.createElement("path",{d:"M4,8.8 L7.2,12 L12.8,4.8",fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function U(t,e,n){return n&&n.size>0?n.has(t.label)?1:.3:null!=e?t.label===e?1:.3:1}function Q({config:t,orientation:e="vertical",width:n=100}){const{colorFn:i,domain:r,label:o,format:a}=t,l=a||(t=>Math.round(100*t)/100+""),s="grad-legend-"+g.useId();if("horizontal"===e){const t=12,e=Math.min(n,200),a=Math.max(0,(n-e)/2),c=[];for(let t=0;64>=t;t++){const e=t/64;c.push(g.createElement("stop",{key:t,offset:100*e+"%",stopColor:i(r[0]+e*(r[1]-r[0]))}))}return g.createElement("g",{"aria-label":o||"Gradient legend"},g.createElement("defs",null,g.createElement("linearGradient",{id:s,x1:"0%",y1:"0%",x2:"100%",y2:"0%"},c)),o&&g.createElement("text",{x:a+e/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},o),g.createElement("rect",{x:a,y:0,width:e,height:t,fill:`url(#${s})`,rx:2}),g.createElement("text",{x:a,y:t+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},l(r[0])),g.createElement("text",{x:a+e,y:t+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},l(r[1])))}const c=[];for(let t=0;64>=t;t++){const e=t/64;c.push(g.createElement("stop",{key:t,offset:100*e+"%",stopColor:i(r[1]-e*(r[1]-r[0]))}))}return g.createElement("g",{"aria-label":o||"Gradient legend"},o&&g.createElement("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},o),g.createElement("defs",null,g.createElement("linearGradient",{id:s,x1:"0%",y1:"0%",x2:"0%",y2:"100%"},c)),g.createElement("rect",{x:0,y:0,width:14,height:100,fill:`url(#${s})`,rx:2}),g.createElement("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},l(r[1])),g.createElement("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},l(r[0])))}function J(t){const{legendGroups:e,customClickBehavior:n,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:o,legendInteraction:a,title:l="Legend",width:s=100,height:c=20,orientation:u="vertical"}=t,[h,d]=g.useState(0),[f,y]=g.useState(0),p=g.useCallback((t,e)=>{d(t),y(e)},[]),v="vertical"===u?(({legendGroups:t,width:e,customClickBehavior:n,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:o,focusedGroupIndex:a,focusedItemIndex:l,onFocusedIndexChange:s,legendInteraction:c})=>{let u=24;const h=[];return t.forEach((t,d)=>{u+=5,h.push(g.createElement("line",{key:"legend-top-line legend-symbol-"+d,stroke:"gray",x1:0,y1:u,x2:e,y2:u})),u+=8,t.label&&(u+=16,h.push(g.createElement("text",{key:"legend-text-"+d,y:u,className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},t.label)),u+=8),h.push(g.createElement("g",{key:"legend-group-"+d,className:"legend-item",transform:`translate(0,${u})`},((t,e,n,i,r,o,a,l,s,c)=>{const{type:u="fill",styleFn:h,items:d}=t,f=[];let y=0;const p=!(!e&&!n),v="isolate"===c||void 0===c&&null!=r;return d.forEach((t,c)=>{const m=K(t,c,u,h),x=U(t,i,r),b=r&&r.size>0&&r.has(t.label);f.push(g.createElement("g",{key:"legend-item-"+c,transform:`translate(0,${y})`,onClick:e?()=>e(t):void 0,onMouseEnter:n?()=>n(t):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:p?l===o&&c===a?0:-1:void 0,role:p?"option":void 0,"aria-selected":p&&v?b||!1:void 0,"aria-current":p&&!v&&null!=i&&t.label===i||void 0,"aria-label":t.label,onKeyDown:p?n=>{var i;if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),e&&e(t)),"ArrowDown"===n.key||"ArrowUp"===n.key){n.preventDefault();const t=(c+("ArrowDown"===n.key?1:-1)+d.length)%d.length;s(l,t);const e=null===(i=n.currentTarget.parentElement)||void 0===i?void 0:i.children[t];e instanceof SVGElement&&e.focus()}}:void 0,onFocus:p?e=>{s(l,c),n&&n(t);const i=e.currentTarget.querySelector(".semiotic-legend-focus-ring");i&&i.setAttribute("visibility","visible")}:void 0,onBlur:p?t=>{n&&n(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&&g.createElement("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*t.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),m,b&&g.createElement(Z,null),g.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},t.label))),y+=22}),f})(t,n,i,r,o,a,l,d,s,c))),u+=22*t.items.length+8}),h})({legendGroups:e||[],width:s,customClickBehavior:n,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:o,focusedGroupIndex:h,focusedItemIndex:f,onFocusedIndexChange:p,legendInteraction:a}):(({legendGroups:t,height:e,width:n,customClickBehavior:i,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:a,focusedGroupIndex:l,focusedItemIndex:s,onFocusedIndexChange:c,legendInteraction:u})=>{let h=0;const d=[];t.forEach((t,e)=>{let n=0;t.label&&(n+=16);const f=((t,e,n,i,r,o,a,l,s,c)=>{const{type:u="fill",styleFn:h,items:d}=t,f=[];let y=0;const p=!(!e&&!n),v="isolate"===c||void 0===c&&null!=r;return d.forEach((t,c)=>{const m=K(t,c,u,h),x=U(t,i,r),b=r&&r.size>0&&r.has(t.label);f.push(g.createElement("g",{key:"legend-item-"+c,transform:`translate(${y},0)`,onClick:e?()=>e(t):void 0,onMouseEnter:n?()=>n(t):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:p?l===o&&c===a?0:-1:void 0,role:p?"option":void 0,"aria-selected":p&&v?b||!1:void 0,"aria-current":p&&!v&&null!=i&&t.label===i||void 0,"aria-label":t.label,onKeyDown:p?n=>{var i;if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),e&&e(t)),"ArrowRight"===n.key||"ArrowLeft"===n.key){n.preventDefault();const t=(c+("ArrowRight"===n.key?1:-1)+d.length)%d.length;s(l,t);const e=null===(i=n.currentTarget.parentElement)||void 0===i?void 0:i.children[t];e instanceof SVGElement&&e.focus()}}:void 0,onFocus:p?e=>{s(l,c),n&&n(t);const i=e.currentTarget.querySelector(".semiotic-legend-focus-ring");i&&i.setAttribute("visibility","visible")}:void 0,onBlur:p?t=>{n&&n(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&&g.createElement("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*t.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),m,b&&g.createElement(Z,null),g.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},t.label))),y+=26+7*t.label.length}),{items:f,offset:y}})(t,i,r,o,a,l,s,e,c,u);n+=f.offset+5,d.push(Object.assign(Object.assign({label:t.label},f),{offset:n})),h+=n+12});let f=Math.max(0,(n-h)/2);const y=[];return d.forEach((n,i)=>{const r=t[i];r.label&&(y.push(g.createElement("text",{key:"legend-text-"+i,transform:`translate(${f},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},r.label)),f+=16),y.push(g.createElement("g",{key:"legend-group-"+i,className:"legend-item",transform:`translate(${f},0)`},n.items)),f+=n.offset+5,t[i+1]&&y.push(g.createElement("line",{key:"legend-top-line legend-symbol-"+i,stroke:"gray",x1:f,y1:-8,x2:f,y2:e+0+8})),f+=12}),g.createElement("g",null,y)})({legendGroups:e||[],title:l,height:c,width:s,customClickBehavior:n,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:o,focusedGroupIndex:h,focusedItemIndex:f,onFocusedIndexChange:p,legendInteraction:a}),m=!(!n&&!i);return g.createElement("g",{role:m?"listbox":void 0,"aria-multiselectable":!(!m||"isolate"!==a&&(void 0!==a||null==o))||void 0,"aria-label":"Chart legend"},void 0!==l&&""!==l&&"vertical"===u&&g.createElement("text",{className:"legend-title",y:16,x:s/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)"},l),v)}function tt(t){const{legend:e,totalWidth:n,totalHeight:i,margin:r,legendPosition:o="right",title:a,legendHoverBehavior:l,legendClickBehavior:s,legendHighlightedCategory:c,legendIsolatedCategories:u,legendInteraction:h}=t;if(!e)return null;const d="top"===o||"bottom"===o;let f,y;return"left"===o?(f=4,y=r.top):"top"===o?(f=0,y=a?32:8):"bottom"===o?(f=0,y=i-r.bottom+50):(f=n-r.right+10,y=r.top),g.createElement("g",{transform:`translate(${f}, ${y})`},function(t){return"object"==typeof t&&null!==t&&"gradient"in t}(e)?g.createElement(Q,{config:e.gradient,orientation:d?"horizontal":"vertical",width:d?n:100}):function(t){return"object"==typeof t&&null!==t&&"legendGroups"in t}(e)?g.createElement(J,{legendGroups:e.legendGroups,title:"",width:d?n:100,orientation:d?"horizontal":"vertical",customHoverBehavior:l,customClickBehavior:s,highlightedCategory:c,isolatedCategories:u,legendInteraction:h}):e)}function et(t){return"string"==typeof t?{type:t}:t}function nt({orient:e,config:n,values:i,scale:r,size:o,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=t.useMemo(()=>{if(0===i.length)return null;const t=r.domain(),n=o-8;if("boxplot"===s.type){const t=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(!t)return null;const{q1:o,median:a,q3:l,whiskerLow:u,whiskerHigh:h}=t,d=Math.min(.5*n,20),f=(n-d)/2+4;if(c){const t=r(o),n=r(l),i=r(a),c=r(u),y=r(h),p="top"===e?-1:1,v=0;return g.createElement("g",{"data-testid":"marginal-boxplot-"+e},g.createElement("line",{x1:c,y1:v+p*(f+d/2),x2:y,y2:v+p*(f+d/2),stroke:s.fill,strokeWidth:s.strokeWidth}),g.createElement("line",{x1:c,y1:v+p*f,x2:c,y2:v+p*(f+d),stroke:s.fill,strokeWidth:s.strokeWidth}),g.createElement("line",{x1:y,y1:v+p*f,x2:y,y2:v+p*(f+d),stroke:s.fill,strokeWidth:s.strokeWidth}),g.createElement("rect",{x:Math.min(t,n),y:"top"===e?v-f-d:v+f,width:Math.abs(n-t),height:d,fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),g.createElement("line",{x1:i,y1:"top"===e?v-f-d:v+f,x2:i,y2:"top"===e?v-f:v+f+d,stroke:s.fill,strokeWidth:2}))}{const t=r(o),n=r(l),i=r(a),c=r(u),y=r(h),p="left"===e?-1:1,v=0;return g.createElement("g",{"data-testid":"marginal-boxplot-"+e},g.createElement("line",{x1:v+p*(f+d/2),y1:c,x2:v+p*(f+d/2),y2:y,stroke:s.fill,strokeWidth:s.strokeWidth}),g.createElement("line",{x1:v+p*f,y1:c,x2:v+p*(f+d),y2:c,stroke:s.fill,strokeWidth:s.strokeWidth}),g.createElement("line",{x1:v+p*f,y1:y,x2:v+p*(f+d),y2:y,stroke:s.fill,strokeWidth:s.strokeWidth}),g.createElement("rect",{x:"left"===e?v-f-d:v+f,y:Math.min(t,n),width:d,height:Math.abs(n-t),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),g.createElement("line",{x1:"left"===e?v-f-d:v+f,y1:i,x2:"left"===e?v-f:v+f+d,y2:i,stroke:s.fill,strokeWidth:2}))}}const u=a.bin().domain(t).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 g.createElement("g",{"data-testid":"marginal-histogram-"+e},u.map((t,i)=>{if(null==t.x0||null==t.x1)return null;const o=t.length/h*n;if(c){const n=r(t.x0),a=r(t.x1)-r(t.x0);return g.createElement("rect",{key:i,x:n,y:"top"===e?-4-o:4,width:Math.max(a,.5),height:o,fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth})}{const n=r(t.x0),a=r(t.x1)-r(t.x0);return g.createElement("rect",{key:i,x:"left"===e?-4-o:4,y:Math.min(n,n+a),width:o,height:Math.abs(a),fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth})}}));if("violin"===s.type){const t=n/2+4,i=[];for(const o of u){if(null==o.x0||null==o.x1)continue;const a=o.length/h*(n/2),l=r((o.x0+o.x1)/2);i.push(c?`${l},${"top"===e?-(t-a):t-a}`:`${"left"===e?-(t-a):t-a},${l}`)}for(let o=u.length-1;o>=0;o--){const a=u[o];if(null==a.x0||null==a.x1)continue;const l=a.length/h*(n/2),s=r((a.x0+a.x1)/2);i.push(c?`${s},${"top"===e?-(t+l):t+l}`:`${"left"===e?-(t+l):t+l},${s}`)}return g.createElement("g",{"data-testid":"marginal-violin-"+e},g.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 t=[];if(c){const i=0,o=null!=u[0].x0?r(u[0].x0):0;t.push(`M${o},${i}`);for(const i of u){if(null==i.x0||null==i.x1)continue;const o=i.length/h*n,a=r((i.x0+i.x1)/2);t.push(`L${a},${"top"===e?-o-4:o+4}`)}const a=null!=u[u.length-1].x1?r(u[u.length-1].x1):l;t.push(`L${a},${i}`),t.push("Z")}else{const i=0,o=null!=u[0].x0?r(u[0].x0):0;t.push(`M${i},${o}`);for(const i of u){if(null==i.x0||null==i.x1)continue;const o=i.length/h*n,a=r((i.x0+i.x1)/2);t.push(`L${"left"===e?-o-4:o+4},${a}`)}const a=null!=u[u.length-1].x1?r(u[u.length-1].x1):l;t.push(`L${i},${a}`),t.push("Z")}return g.createElement("g",{"data-testid":"marginal-ridgeline-"+e},g.createElement("path",{d:t.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}))}return null},[i,r,s,o,l,e,c,4]);return u?g.createElement("g",{className:"marginal-"+e,"data-testid":"marginal-"+e},u):null}function it(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 rt(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 ot(t){const{x:e=0,y:n=0,dx:i,dy:r,nx:o,ny:a,note:l,connector:s,subject:c,type:u,color:h,className:d,disable:f,events:y={},"data-testid":p}=t,v=new Set(Array.isArray(f)?f:[]);let m=i||0,x=r||0;null!=o&&(m=o-e),null!=a&&(x=a-n);const b="string"==typeof u?u:"label";if("bracket"===b&&c&&0===m&&0===x)if(void 0!==c.width){m=c.width/2;const t=c.depth||30;x=t+(0>t?-5:5)}else if(void 0!==c.height){const t=c.depth||30;m=t+(0>t?-5:5),x=c.height/2}return g.createElement("g",Object.assign({className:("annotation "+(d||"")).trim(),transform:`translate(${e},${n})`,"data-testid":p},y),!v.has("connector")&&function(t,e,n,i,r,o){const a=[];let l=0,s=0;if("callout-circle"!==r&&"label"!==r||!(null==o?void 0:o.radius)){if("callout-rect"===r&&o){const n=o.width||0,i=o.height||0;if(n>0||i>0){const r=n/2,o=i/2,a=t-r,c=e-o;if(0!==a||0!==c){const t=Math.abs(a),e=Math.abs(c),u=n/2,h=i/2,d=t*h>e*u?u/t:h/e;l=r+a*d,s=o+c*d}}}else if("bracket"===r&&o){const t=o.width,e=o.height,n=o.depth||30;void 0!==t?(l=t/2,s=n):void 0!==e&&(l=n,s=e/2)}}else{const n=(o.radius||0)+(o.radiusPadding||0);if(n>0&&(0!==t||0!==e)){const i=Math.atan2(e,t);l=Math.cos(i)*n,s=Math.sin(i)*n}}if(Math.sqrt(Math.pow(t-l,2)+Math.pow(e-s,2))>.5&&(a.push(g.createElement("line",{key:"connector-line",x1:l,y1:s,x2:t,y2:e,stroke:i||"currentColor"})),"arrow"===(null==n?void 0:n.end))){const n=10,r=16/180*Math.PI,o=Math.atan2(e-s,t-l);a.push(g.createElement("path",{key:"connector-arrow",d:`M${l},${s}L${l+n*Math.cos(o+r)},${s+n*Math.sin(o+r)}L${l+n*Math.cos(o-r)},${s+n*Math.sin(o-r)}Z`,fill:i||"currentColor",stroke:"none"}))}return g.createElement("g",{className:"annotation-connector"},a)}(m,x,s,h,b,c),!v.has("subject")&&function(t,e,n,i,r){var o;const a=[];switch(t){case"callout-circle":{const t=((null==e?void 0:e.radius)||0)+((null==e?void 0:e.radiusPadding)||0);t>0&&a.push(g.createElement("circle",{key:"subject-circle",r:t,fill:"none",stroke:n||"currentColor"}));break}case"callout-rect":{const t=(null==e?void 0:e.width)||0,i=(null==e?void 0:e.height)||0;(t>0||i>0)&&a.push(g.createElement("rect",{key:"subject-rect",width:t,height:i,fill:"none",stroke:n||"currentColor"}));break}case"callout-custom":(null==e?void 0:e.custom)&&a.push(...Array.isArray(e.custom)?e.custom:[e.custom]);break;case"xy-threshold":{const t=i||0,o=r||0;if(void 0!==(null==e?void 0:e.x)){const i=(e.x||0)-t;a.push(g.createElement("line",{key:"threshold-line",x1:i,y1:(e.y1||0)-o,x2:i,y2:(e.y2||0)-o,stroke:n||"currentColor",strokeDasharray:"5,5"}))}else if(void 0!==(null==e?void 0:e.y)){const i=(e.y||0)-o;a.push(g.createElement("line",{key:"threshold-line",x1:(e.x1||0)-t,y1:i,x2:(e.x2||0)-t,y2:i,stroke:n||"currentColor",strokeDasharray:"5,5"}))}else void 0!==(null==e?void 0:e.x1)||void 0!==(null==e?void 0:e.x2)?a.push(g.createElement("line",{key:"threshold-line",x1:(e.x1||0)-t,y1:0,x2:(e.x2||0)-t,y2:0,stroke:n||"currentColor",strokeDasharray:"5,5"})):void 0===(null==e?void 0:e.y1)&&void 0===(null==e?void 0:e.y2)||a.push(g.createElement("line",{key:"threshold-line",x1:0,y1:(e.y1||0)-o,x2:0,y2:(e.y2||0)-o,stroke:n||"currentColor",strokeDasharray:"5,5"}));break}case"bracket":{const t=null!==(o=null==e?void 0:e.width)&&void 0!==o?o:null==e?void 0:e.height;void 0!==t&&a.push(g.createElement("path",{key:"bracket-path",d:rt((null==e?void 0:e.type)||"curly",t,(null==e?void 0:e.depth)||30,void 0===(null==e?void 0:e.width)),fill:"none",stroke:n||"currentColor"}));break}}return g.createElement("g",{className:"annotation-subject"},a)}(b,c,h,e,n),!v.has("note")&&function(t,e,n,i){if(!t)return g.createElement("g",{className:"annotation-note"});const{label:r,title:o,orientation:a,align:l,wrap:s=120,noWrap:c}=t;if(!r&&!o)return g.createElement("g",{className:"annotation-note"});let u=a;u||(u=Math.abs(e)>Math.abs(n)?"leftRight":"topBottom");let h=l;h&&"dynamic"!==h||(h="topBottom"===u?0>e?"right":"left":0>n?"bottom":"top");let d="start";"topBottom"===u?"right"===h?d="end":"middle"===h&&(d="middle"):d=0>e?"end":"start";const f=16,y=o?c?[o]:it(o,s):[],p=r?c?[r]:it(r,s):[],v="leftRight"===u?"end"===d?-4:4:0;let m=0;const x=[];y.length>0&&(x.push(g.createElement("text",{key:"annotation-note-title",className:"annotation-note-title",fill:i||void 0,textAnchor:d,fontWeight:"bold"},y.map((t,e)=>g.createElement("tspan",{key:e,x:v,dy:0===e?0:f},t)))),m=y.length*f),p.length>0&&x.push(g.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:i||void 0,textAnchor:d,y:m},p.map((t,e)=>g.createElement("tspan",{key:e,x:v,dy:0===e?0:f},t))));let b=null;if((o||r)&&(0!==e||0!==n))if("topBottom"===u){const t=Math.min(s,120);let e=0,n=t;"end"===d?(e=-t,n=0):"middle"===d&&(e=-t/2,n=t/2),b=g.createElement("line",{className:"note-line",x1:e,x2:n,y1:0,y2:0,stroke:i||"currentColor"})}else{const t=(y.length+p.length)*f+(p.length>0?f:0);let e=0,n=t;"bottom"===h?(e=-t,n=0):"middle"===h&&(e=-t/2,n=t/2),b=g.createElement("line",{className:"note-line",x1:0,x2:0,y1:e,y2:n,stroke:i||"currentColor"})}const k=Math.max(0,y.length+p.length-1)*f;let w=0;return"topBottom"===u?w=0>n?-(k+2):18:"leftRight"===u&&(w="middle"===h?-(k+f+(p.length>0&&y.length>0?2:0))/2+8:"bottom"===h||0>n?-(k+2):18),g.createElement("g",{className:"annotation-note",transform:`translate(${e},${n})`},g.createElement("g",{className:"annotation-note-content",transform:0!==w?`translate(0,${w})`:void 0},x),b)}(l,m,x,h))}function at(t){var e,n;const{noteData:i}=t,{screenCoordinates:r}=i,o="string"==typeof i.type?i.type:"label",a=i.eventListeners||i.events||{};if(i.coordinates&&r){const t=i.nx||r[0][0]+(null!==(e=i.dx)&&void 0!==e?e:0),a=i.ny||r[0][1]+(null!==(n=i.dy)&&void 0!==n?n:0),l=r.map((e,n)=>{const r=Object.assign({},i,{note:0===n?i.note:{label:""},x:e[0],y:e[1],nx:t,ny:a});return g.createElement(ot,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+n},r,{type:o}))});return g.createElement("g",null,l)}const l=i.note||{title:"none",label:i.label};return g.createElement(ot,Object.assign({"data-testid":"semiotic-annotation",key:`${l.label}-${l.title}-${i.i}`,events:a},i,{type:o}))}const lt={linear:s.curveLinear,monotoneX:s.curveMonotoneX,monotoneY:s.curveMonotoneY,step:s.curveStep,stepAfter:s.curveStepAfter,stepBefore:s.curveStepBefore,basis:s.curveBasis,cardinal:s.curveCardinal,catmullRom:s.curveCatmullRom};function st(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 ct(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 ut(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=st(t,n),c=ct(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 ht(t,e,n,i=50){return!(-i>t||t>(n.width||0)+i||-i>e||e>(n.height||0)+i)}function dt(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 ft(e){const{width:n,height:i,totalWidth:r,totalHeight:o,margin:a,scales:l,showAxes:s,axes:c,showGrid:u,xFormat:h,yFormat:d}=e,f=t.useMemo(()=>{var t;if(!l)return[];const e=null==c?void 0:c.find(t=>"bottom"===t.orient),i=(null==e?void 0:e.tickFormat)||h||yt,r=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5;return l.x.ticks(Math.min(r,Math.max(2,Math.floor(n/70)))).map(t=>({value:t,pixel:l.x(t),label:i(t)}))},[l,c,h,n]),y=t.useMemo(()=>{var t;if(!l)return[];const e=null==c?void 0:c.find(t=>"left"===t.orient),n=(null==e?void 0:e.tickFormat)||d||yt,r=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5;return l.y.ticks(Math.min(r,Math.max(2,Math.floor(i/30)))).map(t=>({value:t,pixel:l.y(t),label:n(t)}))},[l,c,d,i]),p=u&&l,v=s&&l;if(!p&&!v)return null;const m=null==c?void 0:c.find(t=>"bottom"===t.orient),x=null==c?void 0:c.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 g.createElement("svg",{width:r,height:o,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},g.createElement("g",{transform:`translate(${a.left},${a.top})`},p&&g.createElement("g",{className:"stream-grid"},f.map((t,e)=>g.createElement("line",{key:"xgrid-"+e,x1:t.pixel,y1:0,x2:t.pixel,y2:i,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1})),y.map((t,e)=>g.createElement("line",{key:"ygrid-"+e,x1:0,y1:t.pixel,x2:n,y2:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),b&&!w&&g.createElement("line",{x1:0,y1:i,x2:n,y2:i,stroke:A,strokeWidth:1}),w&&g.createElement("path",{d:dt("bottom",n,i),fill:"none",stroke:A,strokeWidth:1}),k&&!E&&g.createElement("line",{x1:0,y1:0,x2:0,y2:i,stroke:A,strokeWidth:1}),E&&g.createElement("path",{d:dt("left",n,i),fill:"none",stroke:A,strokeWidth:1})))}function yt(t){return Math.round(100*t)/100+""}function gt(t,e){return t instanceof Date&&(!(e&&e instanceof Date)||t.getFullYear()!==e.getFullYear()||t.getMonth()!==e.getMonth()||t.getDate()!==e.getDate())}function pt(e){var n,i;const{width:r,height:o,totalWidth:a,totalHeight:c,margin:u,scales:h,showAxes:d,axes:f,xLabel:y,yLabel:v,xFormat:m,yFormat:x,showGrid:b,title:k,legend:w,legendHoverBehavior:E,legendClickBehavior:A,legendHighlightedCategory:M,legendIsolatedCategories:S,legendPosition:P="right",foregroundGraphics:_,marginalGraphics:L,xValues:C,yValues:D,annotations:T,svgAnnotationRules:W,xAccessor:$,yAccessor:N,annotationData:O,pointNodes:z,curve:I,underlayRendered:R,children:B}=e,j=t.useMemo(()=>{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)||m||yt,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(r/70)))).map(t=>({value:t,pixel:h.x(t),label:n(t)}))},[d,h,f,m,r]),F=t.useMemo(()=>{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)||x||yt,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(o/30)))).map(t=>({value:t,pixel:h.y(t),label:n(t)}))},[d,h,f,x,o]),Y=t.useRef(new Map),H=t.useRef(null!==(n=null==T?void 0:T.length)&&void 0!==n?n:0),X=null!==(i=null==T?void 0:T.length)&&void 0!==i?i:0;H.current!==X&&(H.current=X,Y.current=new Map);const G=t.useMemo(()=>{if(!T||0===T.length)return null;const t=function(t,e,n){var i,r,o,a,c,u,h,d,f,y,v,m,x,b,k,w,E,A,M,S,P,_,L,C,D,T,W,$,N,O,z,I,R,B,j,F,Y,H,X,G,q,V,K,Z;switch(t.type){case"label":{const i=ut(t,e,n);if(!i)return null;const{x:r,y:o}=i;return ht(r,o,n)?g.createElement(at,{key:"ann-"+e,noteData:{x:r,y:o,dx:t.dx||30,dy:t.dy||-30,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"label",connector:t.connector||{end:"arrow"},color:t.color}}):null}case"callout":{const i=ut(t,e,n);if(!i)return null;const{x:r,y:o}=i;return ht(r,o,n)?g.createElement(at,{key:"ann-"+e,noteData:{x:r,y:o,dx:t.dx||30,dy:t.dy||-30,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"callout-circle",subject:{radius:t.radius||12},connector:t.connector||{end:"arrow"},color:t.color}}):null}case"x-threshold":{const i=st(t,n);if(null==i)return null;const r=t.color||"#f97316";return g.createElement("g",{key:"ann-"+e},g.createElement("line",{x1:i,y1:0,x2:i,y2:n.height||0,stroke:r,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&g.createElement("text",{x:i+4,y:12,fill:r,fontSize:12,fontWeight:"bold"},t.label))}case"y-threshold":{const i=ct(t,n);if(null==i)return null;const r=t.color||"#f97316";return g.createElement("g",{key:"ann-"+e},g.createElement("line",{x1:0,y1:i,x2:n.width||0,y2:i,stroke:r,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&g.createElement("text",{x:(n.width||0)-4,y:i-4,textAnchor:"end",fill:r,fontSize:12,fontWeight:"bold"},t.label))}case"enclose":{const i=(t.coordinates||[]).map(t=>({x:st(Object.assign(Object.assign({},t),{type:"point"}),n),y:ct(Object.assign(Object.assign({},t),{type:"point"}),n),r:1})).filter(t=>null!=t.x&&null!=t.y);if(2>i.length)return null;const r=l.packEnclose(i),o=t.padding||10;return g.createElement("g",{key:"ann-"+e},g.createElement("circle",{cx:r.x,cy:r.y,r:r.r+o,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&g.createElement("text",{x:r.x,y:r.y-r.r-o-4,textAnchor:"middle",fill:t.color||"#666",fontSize:12},t.label))}case"rect-enclose":{const i=(t.coordinates||[]).map(t=>({x:st(Object.assign(Object.assign({},t),{type:"point"}),n),y:ct(Object.assign(Object.assign({},t),{type:"point"}),n)})).filter(t=>null!=t.x&&null!=t.y);if(2>i.length)return null;const r=t.padding||10,o=i.map(t=>t.x),a=i.map(t=>t.y),l=Math.min(...o)-r,s=Math.max(...o)+r,c=Math.min(...a)-r,u=Math.max(...a)+r;return g.createElement("g",{key:"ann-"+e},g.createElement("rect",{x:l,y:c,width:s-l,height:u-c,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&g.createElement("text",{x:(l+s)/2,y:c-4,textAnchor:"middle",fill:t.color||"#666",fontSize:12},t.label))}case"highlight":{const i=n.data||[],r="function"==typeof t.filter?i.filter(t.filter):t.field&&null!=t.value?i.filter(e=>e[t.field]===t.value):[],o=t.style||{stroke:t.color||"#f97316",strokeWidth:2,fill:"none"};return g.createElement("g",{key:"ann-"+e},r.map((e,i)=>{const r=st(e,n),a=ct(e,n);return null==r||null==a?null:g.createElement("circle",Object.assign({key:"hl-"+i,cx:r,cy:a,r:t.r||6},o))}))}case"bracket":{const i=st(t,n),r=ct(t,n);return g.createElement(at,{key:"ann-"+e,noteData:{x:null!=i?i:0,y:null!=r?r:0,dx:t.dx||0,dy:t.dy||0,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"bracket",subject:{type:t.bracketType||"curly",width:t.width,height:t.height,depth:t.depth||30},color:t.color}})}case"trend":{const l=n.data||[];if(2>l.length)return null;const s=n.xAccessor||"x",d=n.yAccessor||"y",f=l.map(t=>[t[s],t[d]]).filter(t=>null!=t[0]&&null!=t[1]);if(2>f.length)return null;const y=null!==(r=null===(i=n.scales)||void 0===i?void 0:i.x)&&void 0!==r?r:null===(o=n.scales)||void 0===o?void 0:o.time,v=null!==(c=null===(a=n.scales)||void 0===a?void 0:a.y)&&void 0!==c?c:null===(u=n.scales)||void 0===u?void 0:u.value;if(!y||!v)return null;const m=t.method||"linear";let x;x="loess"===m?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}(f,null!==(h=t.bandwidth)&&void 0!==h?h:.3):("polynomial"===m?p.default.polynomial(f,{order:t.order||2}):p.default.linear(f)).points;const b=x.map(([t,e])=>`${y(t)},${v(e)}`).join(" "),k=t.color||"#6366f1";return g.createElement("g",{key:"ann-"+e},g.createElement("polyline",{points:b,fill:"none",stroke:k,strokeWidth:t.strokeWidth||2,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&g.createElement("text",{x:y(x[x.length-1][0])+4,y:v(x[x.length-1][1])-4,fill:k,fontSize:11},t.label))}case"band":{const i=null!==(f=null===(d=n.scales)||void 0===d?void 0:d.y)&&void 0!==f?f:null===(y=n.scales)||void 0===y?void 0:y.value,r=null!==(v=null==i?void 0:i(t.y0))&&void 0!==v?v:0,o=null!==(m=null==i?void 0:i(t.y1))&&void 0!==m?m:n.height||0;return g.createElement("g",{key:"ann-"+e},g.createElement("rect",{x:0,y:Math.min(r,o),width:n.width||0,height:Math.abs(o-r),fill:t.fill||"#6366f1",fillOpacity:t.fillOpacity||.1}),t.label&&g.createElement("text",{x:(n.width||0)-4,y:Math.min(r,o)-4,textAnchor:"end",fill:t.color||"#6366f1",fontSize:11},t.label))}case"envelope":{const i=n.data||[];if(2>i.length)return null;const r=n.xAccessor||"x",o=null!==(b=null===(x=n.scales)||void 0===x?void 0:x.x)&&void 0!==b?b:null===(k=n.scales)||void 0===k?void 0:k.time,a=null!==(E=null===(w=n.scales)||void 0===w?void 0:w.y)&&void 0!==E?E:null===(A=n.scales)||void 0===A?void 0:A.value;if(!o||!a)return null;const l=t.upperAccessor||"upperBounds",c=t.lowerAccessor||"lowerBounds",u=t.filter,h=i.filter(t=>null!=t[l]&&null!=t[c]&&!(u&&!u(t))).sort((t,e)=>t[r]-e[r]);if(2>h.length)return null;const d=lt[n.curve||"linear"]||s.curveLinear,f=s.area().x(t=>o(t[r])).y0(t=>a(t[c])).y1(t=>a(t[l])).curve(d)(h);if(!f)return null;const y=t.fill||"#6366f1";return g.createElement("g",{key:"ann-"+e},g.createElement("path",{d:f,fill:y,fillOpacity:null!==(M=t.fillOpacity)&&void 0!==M?M:.15,stroke:"none"}),t.label&&h.length>0&&g.createElement("text",{x:o(h[h.length-1][r])+4,y:a(h[h.length-1][l])-4,fill:y,fontSize:11},t.label))}case"anomaly-band":{const i=n.data||[];if(2>i.length)return null;const r=n.yAccessor||"y",o=null!==(P=null===(S=n.scales)||void 0===S?void 0:S.x)&&void 0!==P?P:null===(_=n.scales)||void 0===_?void 0:_.time,a=null!==(C=null===(L=n.scales)||void 0===L?void 0:L.y)&&void 0!==C?C:null===(D=n.scales)||void 0===D?void 0:D.value;if(!o||!a)return null;const l=i.map(t=>t[r]).filter(t=>null!=t&&isFinite(t));if(2>l.length)return null;const s=l.reduce((t,e)=>t+e,0)/l.length,c=l.reduce((t,e)=>t+Math.pow(e-s,2),0)/l.length,u=Math.sqrt(c),h=null!==(T=t.threshold)&&void 0!==T?T:2,d=s-h*u,f=!1!==t.showBand,y=t.fill||"#6366f1",p=null!==(W=t.fillOpacity)&&void 0!==W?W:.1,v=t.anomalyColor||"#ef4444",m=null!==($=t.anomalyRadius)&&void 0!==$?$:6,x=a(s+h*u),b=a(d),k=i.filter(t=>{const e=t[r];return null!=e&&Math.abs(e-s)>h*u});return g.createElement("g",{key:"ann-"+e},f&&g.createElement("rect",{x:0,y:Math.min(x,b),width:n.width||0,height:Math.abs(b-x),fill:y,fillOpacity:p}),k.map((t,e)=>{const i=st(t,n),r=ct(t,n);return null==i||null==r?null:g.createElement("circle",{key:"anomaly-"+e,cx:i,cy:r,r:m,fill:v,fillOpacity:.7,stroke:v,strokeWidth:1.5})}),t.label&&g.createElement("text",{x:(n.width||0)-4,y:Math.min(x,b)-4,textAnchor:"end",fill:y,fontSize:11},t.label))}case"forecast":{const i=n.data||[];if(3>i.length)return null;const r=n.xAccessor||"x",o=n.yAccessor||"y",a=null!==(O=null===(N=n.scales)||void 0===N?void 0:N.x)&&void 0!==O?O:null===(z=n.scales)||void 0===z?void 0:z.time,l=null!==(R=null===(I=n.scales)||void 0===I?void 0:I.y)&&void 0!==R?R:null===(B=n.scales)||void 0===B?void 0:B.value;if(!a||!l)return null;const s=i.map(t=>[t[r],t[o]]).filter(t=>null!=t[0]&&null!=t[1]&&isFinite(t[0])&&isFinite(t[1])).sort((t,e)=>t[0]-e[0]);if(3>s.length)return null;let c;if("polynomial"===(t.method||"linear")){const e=p.default.polynomial(s,{order:t.order||2}).equation;c=t=>e.reduce((e,n,i)=>e+n*Math.pow(t,i),0)}else{const t=s.length;let e=0,n=0,i=0,r=0;for(const[t,o]of s)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;c=t=>l+a*t}const u=s.length,h=s.map(([t,e])=>e-c(t)).reduce((t,e)=>t+e*e,0),d=Math.sqrt(h/Math.max(u-2,1)),f=s.reduce((t,e)=>t+e[0],0)/u,y=s.reduce((t,e)=>t+Math.pow(e[0]-f,2),0),v=null!==(j=t.confidence)&&void 0!==j?j:.95,m=.99>v?.95>v?.9>v?1:1.645:1.96:2.576,x=null!==(F=t.steps)&&void 0!==F?F:5,b=s[u-1][0],k=(b-s[0][0])/Math.max(u-1,1),w=[];for(let t=1;x>=t;t++)w.push(b+t*k);const E=[];for(const t of w){const e=c(t),n=d*Math.sqrt(1+1/u+(y>0?Math.pow(t-f,2)/y:0))*m;E.push({x:t,yCenter:e,yUpper:e+n,yLower:e-n})}const A=`M${E.map(t=>`${a(t.x)},${l(t.yUpper)}`).join(" L")} L${E.slice().reverse().map(t=>`${a(t.x)},${l(t.yLower)}`).join(" L")} Z`,M=E.map(t=>`${a(t.x)},${l(t.yCenter)}`).join(" "),S=`${a(b)},${l(c(b))}`,P=t.strokeColor||"#6366f1";return g.createElement("g",{key:"ann-"+e},g.createElement("path",{d:A,fill:t.fill||"#6366f1",fillOpacity:null!==(Y=t.fillOpacity)&&void 0!==Y?Y:.15,stroke:"none"}),g.createElement("polyline",{points:`${S} ${M}`,fill:"none",stroke:P,strokeWidth:null!==(H=t.strokeWidth)&&void 0!==H?H:2,strokeDasharray:null!==(X=t.strokeDasharray)&&void 0!==X?X:"6,3"}),t.label&&E.length>0&&g.createElement("text",{x:a(E[E.length-1].x)+4,y:l(E[E.length-1].yCenter)-4,fill:P,fontSize:11},t.label))}case"widget":{let i=null,r=null;if(null!=t.px&&null!=t.py)i=t.px,r=t.py;else{const o=ut(t,e,n);if(!o)return null;i=o.x,r=o.y}if(null==i||null==r)return null;if(!ht(i,r,n))return null;const o=null!==(G=t.dx)&&void 0!==G?G:0,a=null!==(q=t.dy)&&void 0!==q?q:0,l=null!==(V=t.width)&&void 0!==V?V:32,s=null!==(K=t.height)&&void 0!==K?K:32,c=null!==(Z=t.content)&&void 0!==Z?Z:g.createElement("span",{style:{fontSize:18,cursor:"default"},title:t.label||"Info"},"ℹ️");return g.createElement("foreignObject",{key:"ann-"+e,x:i+o-l/2,y:r+a-s/2,width:l,height:s,style:{overflow:"visible",pointerEvents:"auto"}},g.createElement("div",{style:{width:l,height:s,display:"flex",alignItems:"center",justifyContent:"center"}},c))}case"text":{const i=ut(t,e,n);if(!i)return null;const{x:r,y:o}=i;return g.createElement("text",{key:"ann-text-"+e,x:r+(t.dx||0),y:o+(t.dy||0),fill:t.color||"var(--semiotic-text, #333)",fontSize:t.fontSize||11,dominantBaseline:"middle",style:{fontFamily:"inherit"}},t.label)}default:return null}},e={scales:h?{x:h.x,y:h.y,time:h.x,value:h.y}:null,timeAxis:"x",xAccessor:$,yAccessor:N,width:r,height:o,data:O,frameType:"xy",pointNodes:z,curve:I,stickyPositionCache:Y.current};return T.map((n,i)=>{if(W){const r=W(n,i,e);return null!=r?r:t(n,i,e)}return t(n,i,e)}).filter(Boolean)},[T,W,r,o,$,N,O,h,z,I]);return d||k||w||_||L||G&&G.length>0||b||B?g.createElement("svg",{role:"img",width:a,height:c,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},g.createElement("title",null,"string"==typeof k?k:"XY Chart"),g.createElement("desc",null,"string"==typeof k?k+" — XY data visualization":"XY data visualization"),g.createElement("g",{transform:`translate(${u.left},${u.top})`},b&&h&&!R&&g.createElement("g",{className:"stream-grid"},j.map((t,e)=>g.createElement("line",{key:"xgrid-"+e,x1:t.pixel,y1:0,x2:t.pixel,y2:o,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1})),F.map((t,e)=>g.createElement("line",{key:"ygrid-"+e,x1:0,y1:t.pixel,x2:r,y2:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),d&&h&&(()=>{const t=null==f?void 0:f.find(t=>"left"===t.orient),e=null==f?void 0:f.find(t=>"bottom"===t.orient),n=!t||!1!==t.baseline,i=(null==t?void 0:t.jaggedBase)||!1,a=(null==e?void 0:e.jaggedBase)||!1,l=null==e?void 0:e.landmarkTicks,s=null==t?void 0:t.landmarkTicks,c="var(--semiotic-border, #ccc)",h="var(--semiotic-text-secondary, #666)",d="var(--semiotic-text, #333)";return g.createElement("g",{className:"stream-axes"},!R&&(!e||!1!==e.baseline)&&!a&&g.createElement("line",{x1:0,y1:o,x2:r,y2:o,stroke:c,strokeWidth:1}),!R&&a&&g.createElement("path",{d:dt("bottom",r,o),fill:"none",stroke:c,strokeWidth:1}),j.map((t,e)=>{const n=!!l&&("function"==typeof l?l(t.value,e):gt(t.value,e>0?j[e-1].value:void 0));return g.createElement("g",{key:"xtick-"+e,transform:`translate(${t.pixel},${o})`},g.createElement("line",{y2:5,stroke:c,strokeWidth:1}),g.createElement("text",{y:18,textAnchor:"middle",fontSize:n?11:10,fontWeight:n?600:400,fill:h,style:{userSelect:"none"}},t.label))}),y&&g.createElement("text",{x:r/2,y:o+40,textAnchor:"middle",fontSize:12,fill:d,style:{userSelect:"none"}},y),!R&&n&&!i&&g.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:c,strokeWidth:1}),!R&&i&&g.createElement("path",{d:dt("left",r,o),fill:"none",stroke:c,strokeWidth:1}),F.map((t,e)=>{const n=!!s&&("function"==typeof s?s(t.value,e):gt(t.value,e>0?F[e-1].value:void 0));return g.createElement("g",{key:"ytick-"+e,transform:`translate(0,${t.pixel})`},g.createElement("line",{x2:-5,stroke:c,strokeWidth:1}),g.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:n?11:10,fontWeight:n?600:400,fill:h,style:{userSelect:"none"}},t.label))}),v&&g.createElement("text",{x:15-u.left,y:o/2,textAnchor:"middle",fontSize:12,fill:d,transform:`rotate(-90, ${15-u.left}, ${o/2})`,style:{userSelect:"none"}},v))})(),G,L&&h&&C&&D&&g.createElement(g.Fragment,null,L.top&&g.createElement("g",{transform:"translate(0, 0)"},g.createElement(nt,{orient:"top",config:et(L.top),values:C,scale:h.x,size:u.top,length:r})),L.bottom&&g.createElement("g",{transform:`translate(0, ${o})`},g.createElement(nt,{orient:"bottom",config:et(L.bottom),values:C,scale:h.x,size:u.bottom,length:r})),L.left&&g.createElement("g",{transform:"translate(0, 0)"},g.createElement(nt,{orient:"left",config:et(L.left),values:D,scale:h.y,size:u.left,length:o})),L.right&&g.createElement("g",{transform:`translate(${r}, 0)`},g.createElement(nt,{orient:"right",config:et(L.right),values:D,scale:h.y,size:u.right,length:o}))),_,B),k&&g.createElement("text",{x:a/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof k?k:null),tt({legend:w,totalWidth:a,totalHeight:c,margin:u,legendPosition:P,title:k,legendHoverBehavior:E,legendClickBehavior:A,legendHighlightedCategory:M,legendIsolatedCategories:S})):null}const vt="undefined"==typeof window||"undefined"==typeof document,mt={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function xt(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 bt(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 kt({scene:t,chartType:e}){var n,i,r,o;const a=[];for(const e of t){if(a.length>=50)break;"point"===e.type?a.push({label:"Point",values:{x:Math.round(100*e.x)/100+"",y:Math.round(100*e.y)/100+""}}):"rect"===e.type?a.push({label:"Bar",values:{category:(null===(n=e.datum)||void 0===n?void 0:n.category)||"",value:Math.round(100*(null!==(r=null===(i=e.datum)||void 0===i?void 0:i.value)&&void 0!==r?r:0))/100+""}}):"heatcell"===e.type&&a.push({label:"Cell",values:{x:Math.round(100*e.x)/100+"",y:Math.round(100*e.y)/100+"",value:Math.round(100*(null!==(o=e.value)&&void 0!==o?o:0))/100+""}})}if(0===a.length)return null;const l=new Set;for(const t of a)for(const e of Object.keys(t.values))l.add(e);const s=Array.from(l);return g.createElement("table",{style:mt,role:"table","aria-label":"Data table for "+e},g.createElement("thead",null,g.createElement("tr",null,s.map(t=>g.createElement("th",{key:t},t)))),g.createElement("tbody",null,a.map((t,e)=>g.createElement("tr",{key:e},s.map(e=>{var n;return g.createElement("td",{key:e},null!==(n=t.values[e])&&void 0!==n?n:"")}))),t.length>50&&g.createElement("tr",null,g.createElement("td",{colSpan:s.length},"...and ",t.length-50," more items"))))}function wt({nodes:t,chartType:e}){var n,i,r,o,a;const l=[];for(const e of t){if(l.length>=50)break;l.push({values:{id:(null===(n=e.datum)||void 0===n?void 0:n.id)||e.id||"",x:Math.round(100*(null!==(r=null!==(i=e.cx)&&void 0!==i?i:e.x)&&void 0!==r?r:0))/100+"",y:Math.round(100*(null!==(a=null!==(o=e.cy)&&void 0!==o?o:e.y)&&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 g.createElement("table",{style:mt,role:"table","aria-label":"Data table for "+e},g.createElement("thead",null,g.createElement("tr",null,c.map(t=>g.createElement("th",{key:t},t)))),g.createElement("tbody",null,l.map((t,e)=>g.createElement("tr",{key:e},c.map(e=>{var n;return g.createElement("td",{key:e},null!==(n=t.values[e])&&void 0!==n?n:"")}))),t.length>50&&g.createElement("tr",null,g.createElement("td",{colSpan:c.length},"...and ",t.length-50," more items"))))}function Et({hoverPoint:t}){let e="";if(t){const n=t.data||t;e="object"==typeof n?"Focused on data point: "+Object.entries(n).filter(([,t])=>"object"!=typeof t&&"function"!=typeof t).map(([t,e])=>`${t}: ${e}`).join(", "):"Focused on data point: "+n}return g.createElement("div",{"aria-live":"polite","aria-atomic":"true",style:mt},e)}function At(e){const n=t.createContext(null),i=Mt(e);return[function({children:i}){const r=t.useMemo(()=>Mt(e),[]);return g.createElement(n.Provider,{value:r,children:i})},e=>{var r;const o=null!==(r=t.useContext(n))&&void 0!==r?r:i,a=t.useRef(e);a.current=e;const l=t.useCallback(()=>a.current(o.getState()),[o]),s=t.useCallback(()=>a.current(o.getState()),[o]);return t.useSyncExternalStore(o.subscribe,l,s)}]}function Mt(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 St={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}},Pt={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}},[_t,Lt]=At(t=>({theme:St,setTheme(e){t(t=>"light"===e?{theme:St}:"dark"===e?{theme:Pt}:{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 Ct(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 Dt(){return"undefined"!=typeof window&&window.devicePixelRatio||1}function Tt(t){switch(t){case"monotoneX":return s.curveMonotoneX;case"monotoneY":return s.curveMonotoneY;case"cardinal":return s.curveCardinal;case"catmullRom":return s.curveCatmullRom;case"step":return s.curveStep;case"stepBefore":return s.curveStepBefore;case"stepAfter":return s.curveStepAfter;case"basis":return s.curveBasis;case"natural":return s.curveNatural;default:return null}}function Wt(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 $t(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 Nt(t){return!(!t._pulseIntensity||0>=t._pulseIntensity)}function Ot(t,e,n=.3){Nt(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 zt(t,e,n=.6){var i,r,o,a,l;if(!Nt(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 It(t,e,n,i=.35){Nt(e)&&(t.globalAlpha=e._pulseIntensity*i,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fill())}function Rt(t){switch(t){case"monotoneX":return s.curveMonotoneX;case"monotoneY":return s.curveMonotoneY;case"cardinal":return s.curveCardinal;case"catmullRom":return s.curveCatmullRom;case"step":return s.curveStep;case"stepBefore":return s.curveStepBefore;case"stepAfter":return s.curveStepAfter;case"basis":return s.curveBasis;case"natural":return s.curveNatural;default:return null}}function Bt(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 jt(t,e){const n=Rt(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=s.area().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 Ft=(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(jt(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=Bt(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&&(jt(t,e),It(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=Rt(e.curve);if(t.beginPath(),n)s.line().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}},Yt=(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()),zt(t,e),t.globalAlpha=1}}finally{t.restore()}},Ht=(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?Xt(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))),Ot(t,e),t.globalAlpha=1};function Xt(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 Gt(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 qt(t){return Number.isInteger(t)?t+"":100>Math.abs(t)?1>Math.abs(t)?t.toPrecision(3):t.toFixed(1):t.toFixed(0)}const Vt={line:[Ft,(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 c=l.style.stroke||"#007bff",u=l.style.strokeWidth||2,h=l.colorThresholds,d=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=u,t.lineCap=l.style.strokeLinecap||"butt",l.style._edgeFade){const p=null!==(r=l.style.opacity)&&void 0!==r?r:1;$t(t,l.path,c,u,p,l.style.strokeLinecap||"butt"),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt";continue}const f=Tt(l.curve),y=h&&h.length>0&&d&&d.length===l.path.length,g=l._decayOpacities;if(g&&g.length===l.path.length&&!y){t.strokeStyle=c;const v=null!==(o=l.style.opacity)&&void 0!==o?o:1;for(let m=0;l.path.length-1>m;m++)t.globalAlpha=.5*(g[m]+g[m+1])*v,t.beginPath(),t.moveTo(l.path[m][0],l.path[m][1]),t.lineTo(l.path[m+1][0],l.path[m+1][1]),t.stroke()}else if(y){let x=null,b=null,k=null,w=null,E=!1;function A(e,n,i){t.beginPath(),t.strokeStyle=e,t.moveTo(n,i),E=!0}function M(){E&&(t.stroke(),E=!1)}for(let S=0;l.path.length>S;S++){const[P,_]=l.path[S],L=d[S],C=Wt(L,h,c);if(null!==x&&null!==w&&null!==k){if(C===w)t.lineTo(P,_);else{const D=[];for(const T of h){const W=T.value;(k>W||W>L)&&(W>k||L>W)||k===W||L===W||D.push({t:(W-k)/(L-k)})}D.sort((t,e)=>t.t-e.t);for(const $ of D){const N=x+(P-x)*$.t,O=b+(_-b)*$.t,z=Wt(k+(L-k)*Math.min($.t+1e-4,1),h,c);t.lineTo(N,O),M(),A(z,N,O)}t.lineTo(P,_)}x=P,b=_,k=L,w=C}else A(C,P,_),x=P,b=_,k=L,w=C}M()}else{if(t.beginPath(),t.strokeStyle=c,f)s.line().x(t=>t[0]).y(t=>t[1]).curve(f).context(t)(l.path);else{const[I,R]=l.path[0];t.moveTo(I,R);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,f&&!y)s.line().x(t=>t[0]).y(t=>t[1]).curve(f).context(t)(l.path);else{const[F,Y]=l.path[0];t.moveTo(F,Y);for(let H=1;l.path.length>H;H++)t.lineTo(l.path[H][0],l.path[H][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:[Ft],stackedarea:[Ft],scatter:[Yt],bubble:[Yt],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),Ot(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):qt(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=Gt(e.fill),t.font=i+"px sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText(n,r,o)}}}finally{t.restore()}}],bar:[Ht],swarm:[Yt],waterfall:[(t,e,n,i)=>{var r,o,a;Ht(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()}}]},Kt={top:20,right:20,bottom:30,left:40},Zt={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"},Ut={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 Qt({hover:t}){const e=t=>Number.isInteger(t)?t+"":t.toFixed(2);return g.createElement("div",{className:"semiotic-tooltip",style:Ut},g.createElement("div",{style:{fontWeight:600,marginBottom:2}},e(t.value)),g.createElement("div",{style:{opacity:.7,fontSize:11}},e(t.time)))}function Jt({width:i,height:r,totalWidth:o,totalHeight:a,margin:l,dimension:s,scales:c,onBrush:u}){const h=t.useRef(null),d=t.useRef(null),f=t.useRef(u);f.current=u;const y=t.useRef(c);return y.current=c,t.useEffect(()=>{if(!h.current)return;const t=n.select(h.current).select(".brush-g"),o="x"===s?e.brushX():"y"===s?e.brushY():e.brush();return o.extent([[0,0],[i,r]]),o.on("brush end",t=>{const e=y.current;if(!e)return;if(!t.selection)return void f.current(null);let n,o;if("x"===s){const[i,a]=t.selection;n=[e.x.invert(i),e.x.invert(a)],o=[e.y.invert(r),e.y.invert(0)]}else if("y"===s){const[r,a]=t.selection;n=[e.x.invert(0),e.x.invert(i)],o=[e.y.invert(a),e.y.invert(r)]}else{const[[i,r],[a,l]]=t.selection;n=[e.x.invert(i),e.x.invert(a)],o=[e.y.invert(l),e.y.invert(r)]}f.current({x:n,y:o})}),t.call(o),d.current=o,t.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{o.on("brush end",null),d.current=null}},[i,r,s]),g.createElement("svg",{ref:h,width:o,height:a,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},g.createElement("g",{className:"brush-g",transform:`translate(${l.left},${l.top})`}))}const te=t.forwardRef(function(e,n){var i,r,o,a,l,s,c,u,h;const{chartType:d,runtimeMode:f,data:y,chunkThreshold:p,chunkSize:m,xAccessor:x,yAccessor:b,colorAccessor:k,sizeAccessor:w,groupAccessor:E,lineDataAccessor:A,curve:M,normalize:S,binSize:P,valueAccessor:_,arrowOfTime:L="right",windowMode:C="sliding",windowSize:D=200,timeAccessor:T,xExtent:W,yExtent:N,extentPadding:O=.1,sizeRange:R,size:H=[500,300],responsiveWidth:V,responsiveHeight:K,margin:Z,className:U,background:Q,lineStyle:J,pointStyle:tt,areaStyle:et,waterfallStyle:nt,swarmStyle:it,barColors:rt,colorScheme:ot,boundsAccessor:at,boundsStyle:lt,y0Accessor:st,gradientFill:ct,openAccessor:ut,highAccessor:ht,lowAccessor:dt,closeAccessor:yt,candlestickStyle:gt,showAxes:mt=!0,axes:bt,xLabel:wt,yLabel:At,xFormat:Mt,yFormat:St,tickFormatTime:Pt,tickFormatValue:_t,hoverAnnotation:Tt,tooltipContent:Wt,customHoverBehavior:$t,enableHover:Nt,annotations:Ot,svgAnnotationRules:zt,showGrid:It,legend:Rt,legendHoverBehavior:Bt,legendClickBehavior:jt,legendHighlightedCategory:Ft,legendIsolatedCategories:Yt,legendPosition:Ht,backgroundGraphics:Xt,foregroundGraphics:Gt,canvasPreRenderers:qt,title:Ut,categoryAccessor:te,brush:ee,onBrush:ne,decay:ie,pulse:re,transition:oe,staleness:ae,heatmapAggregation:le,heatmapXBins:se,heatmapYBins:ce,showValues:ue,heatmapValueFormat:he,marginalGraphics:de,pointIdAccessor:fe,xScaleType:ye,yScaleType:ge,accessibleTable:pe}=e,[ve,me]=G(H,V,K),xe=Object.assign(Object.assign({},Kt),Z);if(de){const t=60;de.top&&t>xe.top&&(xe.top=t),de.bottom&&t>xe.bottom&&(xe.bottom=t),de.left&&t>xe.left&&(xe.left=t),de.right&&t>xe.right&&(xe.right=t)}const be=me[0]-xe.left-xe.right,ke=me[1]-xe.top-xe.bottom,we="function"==typeof Gt?Gt({size:me,margin:xe}):Gt,Ee="function"==typeof Xt?Xt({size:me,margin:xe}):Xt,Ae=null!=Tt?Tt:Nt,Me=t.useRef(null),Se=t.useRef(null),Pe=t.useRef(0),_e=t.useRef(!1),Le=Lt(t=>t.theme),[Ce,De]=t.useState(0),[Te,We]=t.useState(null),$e=t.useRef(null),Ne=t.useRef(null),[Oe,ze]=t.useState(null),[Ie,Re]=t.useState(!1),[Be,je]=t.useState([]),[Fe,Ye]=t.useState([]),He=t.useRef(()=>{}),Xe="streaming"===f||["bar","swarm","waterfall"].includes(d),Ge=t.useMemo(()=>({chartType:d,runtimeMode:Xe?"streaming":"bounded",windowSize:D,windowMode:C,arrowOfTime:Xe?L:"right",extentPadding:O,xAccessor:Xe?void 0:x,yAccessor:Xe?void 0:b,timeAccessor:Xe?T:void 0,valueAccessor:_,colorAccessor:k,sizeAccessor:w,groupAccessor:E,categoryAccessor:te,lineDataAccessor:A,xScaleType:ye,yScaleType:ge,xExtent:W,yExtent:N,sizeRange:R,binSize:P,normalize:S,boundsAccessor:at,boundsStyle:lt,y0Accessor:st,gradientFill:"boolean"==typeof ct?ct?{topOpacity:.8,bottomOpacity:.05}:void 0:ct,openAccessor:ut,highAccessor:ht,lowAccessor:dt,closeAccessor:yt,candlestickStyle:gt,lineStyle:J,pointStyle:tt,areaStyle:et,swarmStyle:it,waterfallStyle:nt,colorScheme:ot,barColors:rt,annotations:Ot,decay:ie,pulse:re,transition:oe,staleness:ae,heatmapAggregation:le,heatmapXBins:se,heatmapYBins:ce,showValues:ue,heatmapValueFormat:he,pointIdAccessor:fe,curve:M}),[d,D,C,L,O,x,b,T,_,ye,ge,k,w,E,te,A,W,N,R,P,S,at,lt,st,ct,ut,ht,dt,yt,gt,J,tt,et,it,nt,ot,rt,Ot,ie,re,oe,ae,le,se,ce,ue,he,Xe,fe,M]),qe=t.useRef(null);qe.current||(qe.current=new $(Ge));const Ve=t.useCallback(()=>{Pe.current||(Pe.current=requestAnimationFrame(()=>He.current()))},[]);t.useEffect(()=>{var t;null===(t=qe.current)||void 0===t||t.updateConfig(Ge),_e.current=!0,Ve()},[Ge,Ve]),t.useEffect(()=>{_e.current=!0,Ve()},[Le,Ve]);const Ke=t.useRef(null);Ke.current||(Ke.current=new v(t=>{const e=qe.current;e&&e.ingest(t)&&(_e.current=!0,Ve())},{chunkThreshold:p,chunkSize:m})),t.useEffect(()=>{var t;null===(t=Ke.current)||void 0===t||t.updateChunkOptions({chunkThreshold:p,chunkSize:m})},[p,m]);const Ze=t.useCallback(t=>{var e;null===(e=Ke.current)||void 0===e||e.push(t)},[]),Ue=t.useCallback(t=>{var e;null===(e=Ke.current)||void 0===e||e.pushMany(t)},[]),Qe=t.useCallback(()=>{var t,e;null===(t=Ke.current)||void 0===t||t.clear(),null===(e=qe.current)||void 0===e||e.clear(),_e.current=!0,Ve()},[Ve]);t.useImperativeHandle(n,()=>({push:Ze,pushMany:Ue,clear:Qe,getData:()=>{var t,e,n;return null===(t=Ke.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}}),[Ze,Ue,Qe]),t.useEffect(()=>{var t;y&&(null===(t=Ke.current)||void 0===t||t.setBoundedData(y))},[y]);const Je=t.useRef(()=>{}),tn=t.useRef(()=>{});Je.current=t=>{if(!Ae)return;const e=Me.current;if(!e)return;const n=e.getBoundingClientRect(),i=t.clientX-n.left-xe.left,r=t.clientY-n.top-xe.top;if(0>i||i>be||0>r||r>ke)return void($e.current&&($e.current=null,Ne.current=null,ze(null),$t&&($t(null),_e.current=!0),Ve()));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=z(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=z(l,e,n);break;case"line":t=I(l,e,n);break;case"rect":t=B(l,e,n);break;case"heatcell":t=j(l,e,n);break;case"area":if(!1===l.interactive)break;t=Y(l,e,n);break;case"candlestick":t=F(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($e.current&&($e.current=null,Ne.current=null,ze(null),$t&&$t(null),Ve()));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});$e.current=s,Ne.current=a.node,ze(s),$t&&($t(s),_e.current=!0),Ve()},tn.current=()=>{$e.current&&($e.current=null,Ne.current=null,ze(null),$t&&($t(null),_e.current=!0),Ve())},t.useCallback(t=>Je.current(t),[]);const en=t.useCallback(()=>tn.current(),[]),nn=t.useRef(-1),rn=t.useCallback(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>nn.current?-1:nn.current,r=X(t.key,0>i?-1:i,n.length);if(null===r)return;if(t.preventDefault(),0>r)return nn.current=-1,$e.current=null,Ne.current=null,ze(null),$t&&$t(null),void Ve();const o=0>i?0:r;nn.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]);$e.current=a,ze(a),$t&&$t(a),Ve()},[$t,Ve]),on=t.useCallback(t=>{nn.current=-1,Je.current(t)},[]);He.current=()=>{var t,e;Pe.current=0;const n=Me.current,i=Se.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:be,height:ke});const s=Dt(),c=function(t){if(!t)return Zt;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||Zt.axisStroke,tickText:o||Zt.tickText,crosshair:o?o+"66":Zt.crosshair,hoverFill:s?s+"4D":Zt.hoverFill,hoverStroke:o?o+"99":Zt.hoverStroke,pointRing:s||Zt.pointRing}:Zt}(n),u=null!==(t=null==ae?void 0:ae.threshold)&&void 0!==t?t:5e3,h=ae&&r.lastIngestTime>0&&o-r.lastIngestTime>u;if(l){const t=Ct(n,me,xe,s);if(t){t.clearRect(-xe.left,-xe.top,me[0],me[1]),h&&(t.globalAlpha=null!==(e=null==ae?void 0:ae.dimOpacity)&&void 0!==e?e:.5);const i=getComputedStyle(n).getPropertyValue("--semiotic-bg").trim(),o=Q||(i&&"transparent"!==i?i:null);if(o&&(t.fillStyle=o,t.fillRect(-xe.left,-xe.top,me[0],me[1])),t.save(),"function"==typeof t.rect&&(t.beginPath(),t.rect(0,0,be,ke),t.clip()),qt&&r.scales)for(const e of qt)t.save(),e(t,r.scene,r.scales,{width:be,height:ke}),t.restore();const a=Vt[d];if(a&&r.scales)for(const e of a)e(t,r.scene,r.scales,{width:be,height:ke});t.restore(),h&&(t.globalAlpha=1)}}{const t=Ct(i,me,xe,s);if(t&&(Ae&&$e.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,$e.current,be,ke,"object"==typeof Ae?Ae:{},0,c),Ne.current&&Array.isArray(Tt))){const e=Tt.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,Ne.current,e)}}l&&n&&n.setAttribute("aria-label",xt(r.scene,d+" chart"));const f=_e.current;if(_e.current=!1,f&&r.scales&&((!Te||Te.x.domain()[0]!==r.scales.x.domain()[0]||Te.x.domain()[1]!==r.scales.x.domain()[1]||Te.y.domain()[0]!==r.scales.y.domain()[0]||Te.y.domain()[1]!==r.scales.y.domain()[1]||Te.x.range()[0]!==r.scales.x.range()[0]||Te.x.range()[1]!==r.scales.x.range()[1]||Te.y.range()[0]!==r.scales.y.range()[0]||Te.y.range()[1]!==r.scales.y.range()[1])&&We(r.scales),de)){const t=r.getData(),e="function"==typeof x?x:t=>t[x||"x"],n="function"==typeof b?b:t=>t[b||"y"];je(t.map(t=>e(t)).filter(t=>"number"==typeof t&&isFinite(t))),Ye(t.map(t=>n(t)).filter(t=>"number"==typeof t&&isFinite(t)))}f&&Ot&&Ot.length>0&&De(t=>t+1),(null==ae?void 0:ae.showBadge)&&Re(!!h),(a||r.hasActivePulses)&&(Pe.current=requestAnimationFrame(()=>He.current()))},t.useEffect(()=>(Ve(),()=>{Pe.current&&(cancelAnimationFrame(Pe.current),Pe.current=0)}),[Ve]),t.useEffect(()=>{_e.current=!0,Ve()},[d,be,ke,mt,Q,J,qt,Ve]),q(ae,qe,_e,Ve,Ie,Re);const an=Ae&&Oe?Wt?Wt(Oe):g.createElement(Qt,{hover:Oe}):null,ln=an?g.createElement("div",{className:"stream-frame-tooltip",style:{position:"absolute",left:xe.left+Oe.x,top:xe.top+Oe.y,transform:`translate(${Oe.x>.7*be?"calc(-100% - 12px)":"12px"}, ${.3*ke>Oe.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:1,width:"max-content"}},an):null,sn=nn.current>=0&&Oe?g.createElement("svg",{style:{position:"absolute",left:0,top:0,width:me[0],height:me[1],pointerEvents:"none",zIndex:2}},g.createElement("circle",{cx:Oe.x+xe.left,cy:Oe.y+xe.top,r:8,fill:"none",stroke:"var(--accent, #6366f1)",strokeWidth:2,strokeDasharray:"4,2"})):null;if(vt){const t=qe.current;t&&y&&(t.ingest({inserts:y,bounded:!0}),t.computeScene({width:be,height:ke}));const e=null!==(i=null==t?void 0:t.scene)&&void 0!==i?i:[],n=null!==(r=null==t?void 0:t.scales)&&void 0!==r?r:null;return g.createElement("div",{className:"stream-xy-frame"+(U?" "+U:""),role:"img","aria-label":"string"==typeof Ut?Ut:"XY chart",style:{position:"relative",width:me[0],height:me[1]}},g.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:me[0],height:me[1],style:{position:"absolute",left:0,top:0}},Ee,g.createElement("g",{transform:`translate(${xe.left},${xe.top})`},Q&&g.createElement("rect",{x:0,y:0,width:be,height:ke,fill:Q}),e.map((t,e)=>function(t,e){var n,i,r;switch(t.type){case"line":{const n=t;if(0===n.path.length)return null;const i="M"+n.path.map(([t,e])=>`${t},${e}`).join("L");return g.createElement("path",{key:"line-"+e,d:i,fill:"none",stroke:n.style.stroke||"#4e79a7",strokeWidth:n.style.strokeWidth||2,strokeDasharray:n.style.strokeDasharray,opacity:n.style.opacity})}case"area":{const r=t;if(0===r.topPath.length)return null;const o=r.topPath.map(([t,e])=>`${t},${e}`).join("L"),a=[...r.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L");return g.createElement("path",{key:"area-"+e,d:`M${o}L${a}Z`,fill:r.style.fill||"#4e79a7",fillOpacity:null!==(i=null!==(n=r.style.fillOpacity)&&void 0!==n?n:r.style.opacity)&&void 0!==i?i:.7,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})}case"point":return g.createElement("circle",{key:"point-"+e,cx:t.x,cy:t.y,r:t.r,fill:t.style.fill||"#4e79a7",opacity:null!==(r=t.style.opacity)&&void 0!==r?r:.8,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth});case"rect":return g.createElement("rect",{key:"rect-"+e,x:t.x,y:t.y,width:t.w,height:t.h,fill:t.style.fill||"#4e79a7",opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth});case"heatcell":{const n=t;if(n.showValues&&null!=n.value&&n.w>=20&&n.h>=20){const t=n.valueFormat?n.valueFormat(n.value):Number.isInteger(n.value)?n.value+"":100>Math.abs(n.value)?1>Math.abs(n.value)?n.value.toPrecision(3):n.value.toFixed(1):n.value.toFixed(0),[i,r,o]=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]}(n.fill),a=.299*i+.587*r+.114*o>128?"#000":"#fff",l=Math.max(10,Math.min(16,.3*Math.min(n.w,n.h)));return g.createElement("g",{key:"heatcell-"+e},g.createElement("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill}),g.createElement("text",{x:n.x+n.w/2,y:n.y+n.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:a,fontSize:l+"px"},t))}return g.createElement("rect",{key:"heatcell-"+e,x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill})}case"candlestick":{const n=t,i=Math.min(n.openY,n.closeY),r=Math.max(Math.abs(n.openY-n.closeY),1),o=n.isUp?n.upColor:n.downColor;return g.createElement("g",{key:"candle-"+e},g.createElement("line",{x1:n.x,y1:n.highY,x2:n.x,y2:n.lowY,stroke:n.wickColor,strokeWidth:n.wickWidth}),g.createElement("rect",{x:n.x-n.bodyWidth/2,y:i,width:n.bodyWidth,height:r,fill:o,stroke:o,strokeWidth:1}))}default:return null}}(t,e)).filter(Boolean))),g.createElement(pt,{width:be,height:ke,totalWidth:me[0],totalHeight:me[1],margin:xe,scales:n,showAxes:mt,axes:bt,xLabel:wt,yLabel:At,xFormat:Mt||Pt,yFormat:St||_t,showGrid:It,title:Ut,legend:Rt,legendHoverBehavior:Bt,legendClickBehavior:jt,legendHighlightedCategory:Ft,legendIsolatedCategories:Yt,legendPosition:Ht,foregroundGraphics:we,marginalGraphics:de,xValues:[],yValues:[],annotations:Ot,svgAnnotationRules:zt,annotationFrame:0,xAccessor:"string"==typeof x?x:"string"==typeof T?T:void 0,yAccessor:"string"==typeof b?b:"string"==typeof _?_:void 0,annotationData:null==t?void 0:t.getData(),pointNodes:null==t?void 0:t.scene.filter(t=>"point"===t.type),curve:"string"==typeof M?M:void 0}))}return g.createElement("div",{ref:ve,className:"stream-xy-frame"+(U?" "+U:""),role:"img","aria-label":"string"==typeof Ut?Ut:"XY chart",tabIndex:0,style:{position:"relative",width:V?"100%":me[0],height:K?"100%":me[1],overflow:"visible"},onMouseMove:Ae?on:void 0,onMouseLeave:Ae?en:void 0,onKeyDown:rn},Ee&&g.createElement("svg",{style:{position:"absolute",left:0,top:0,width:me[0],height:me[1],pointerEvents:"none"}},Ee),g.createElement(ft,{width:be,height:ke,totalWidth:me[0],totalHeight:me[1],margin:xe,scales:Te,showAxes:mt,axes:bt,showGrid:It,xFormat:Mt||Pt,yFormat:St||_t}),g.createElement("canvas",{ref:Me,"aria-label":xt(null!==(a=null===(o=qe.current)||void 0===o?void 0:o.scene)&&void 0!==a?a:[],d+" chart"),style:{position:"absolute",left:0,top:0}}),g.createElement("canvas",{ref:Se,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),g.createElement(Et,{hoverPoint:Oe}),pe&&g.createElement(kt,{scene:null!==(s=null===(l=qe.current)||void 0===l?void 0:l.scene)&&void 0!==s?s:[],chartType:d+" chart"}),g.createElement(pt,{width:be,height:ke,totalWidth:me[0],totalHeight:me[1],margin:xe,scales:Te,showAxes:mt,axes:bt,xLabel:wt,yLabel:At,xFormat:Mt||Pt,yFormat:St||_t,showGrid:It,title:Ut,legend:Rt,legendHoverBehavior:Bt,legendClickBehavior:jt,legendHighlightedCategory:Ft,legendIsolatedCategories:Yt,legendPosition:Ht,foregroundGraphics:we,marginalGraphics:de,xValues:Be,yValues:Fe,annotations:Ot,svgAnnotationRules:zt,annotationFrame:Ce,xAccessor:"string"==typeof x?x:"string"==typeof T?T:void 0,yAccessor:"string"==typeof b?b:"string"==typeof _?_:void 0,annotationData:null===(c=qe.current)||void 0===c?void 0:c.getData(),pointNodes:null===(u=qe.current)||void 0===u?void 0:u.scene.filter(t=>"point"===t.type),curve:"string"==typeof M?M:void 0,underlayRendered:!0}),(ee||ne)&&g.createElement(Jt,{width:be,height:ke,totalWidth:me[0],totalHeight:me[1],margin:xe,dimension:null!==(h=null==ee?void 0:ee.dimension)&&void 0!==h?h:"xy",scales:Te,onBrush:null!=ne?ne:()=>{}}),(null==ae?void 0:ae.showBadge)&&g.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===ae.badgePosition?{top:4,left:4}:"bottom-left"===ae.badgePosition?{bottom:4,left:4}:"bottom-right"===ae.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"),sn,ln)});te.displayName="StreamXYFrame";const ee={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},ne={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class ie{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=re(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 re(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=oe(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=oe(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 oe(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 ae(t,e){var n=t.get(e);if(!n)throw Error("missing: "+e);return n}function le(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 se(t){return t.y0-t.y1>0?"up":"down"}function ce(t,e){return e(t.source)==e(t.target)}function ue(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 he(t){return t.target.x0-t.source.x1}function de(t,e){var n=ye(t),i=he(e)/Math.tan(n);return"up"==se(t)?t.y1-i:t.y1+i}function fe(t,e){var n=ye(t),i=he(e)/Math.tan(n);return"up"==se(t)?t.y1+i:t.y1-i}function ye(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function ge(t,e){return e(t)}function pe(t){return me(t.source)}function ve(t){return me(t.target)}function me(t){return(t.y0+t.y1)/2}function xe(t){return t.virtual?0:t.value}function be(t,e){var n=0;t.sourceLinks.forEach(function(t){n=t.circular&&!ce(t,e)?n+1:n});var i=0;return t.targetLinks.forEach(function(t){i=t.circular&&!ce(t,e)?i+1:i}),n+i}function ke(t){return t.target.depth}function we(t,e){return t.sourceLinks.length?t.depth:e-1}function Ee(t,e){return t.y0-e.y0}function Ae(t,e){return e.y0-t.y0}function Me(t,e){return t.y1-e.y1}function Se(t,e){return e.y1-t.y1}function Pe(t,e){return Le(t.source,e.source)||t.index-e.index}function _e(t,e){return Le(t.target,e.target)||t.index-e.index}function Le(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function Ce(t,e){return De(t)==De(e)?"bottom"==t.circularLinkType?Ae(t,e):Ee(t,e):De(e)-De(t)}function De(t){return t.target.column-t.source.column}function Te(t,e){return We(t)==We(e)}function We(t){return t.y0-t.y1>0?"up":"down"}function $e(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 s=a.min(o.links,function(t){return t.source.y0});o.links.forEach(function(t){t.circular&&(t.circularPathData={})});var c=o.links.filter(function(t){return t.circular});return c.sort(function(t,e){return e.value-t.value}),c.forEach(function(t,e){t._circularStub=e>=4}),Ne(o.links.filter(function(t){return"top"==t.circularLinkType}),e,n),Ne(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,ce(t,e)&&ue(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,l=t.circularLinkType,c=o.links.filter(function(t){return t.source.column==a&&t.circularLinkType==l});c.sort("bottom"==t.circularLinkType?Ae:Ee);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==l})).sort("bottom"==t.circularLinkType?Se:Me),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=s-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 Ne(t,e,n){t.sort(Ce);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(ce(t,e)&&ue(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&&Oe(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 Oe(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}function ze(t){return function(){return t}}function Ie(t){return t.index}function Re(t){return t.nodes}function Be(t){return t.links}function je(t,e,n){var i=a.groups(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+=me(t.source)*e,i+=e}}),n.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;r+=me(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?be(e,n)-be(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==be(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 Fe(t,e,n,i,r,o){var l=a.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});h();for(var s=1,c=o;c>0;--c)u(s*=.99,n),h();function u(e,n){var i=l.length;l.forEach(function(r){var o=r.length,l=r[0].depth;r.forEach(function(r){var s;if(r.sourceLinks.length||r.targetLinks.length)if(r.partOfCycle&&be(r,n)>0){var c=a.mean(r.sourceLinks,ve),u=a.mean(r.targetLinks,pe),h=c&&u?(c+u)/2:c||u;if(h){var d=(h-me(r))*e*.3;r.y0+=d,r.y1+=d}}else if(0==l&&1==o)r.y0=t.y1/2-(s=r.y1-r.y0)/2,r.y1=t.y1/2+s/2;else if(l==i-1&&1==o)r.y0=t.y1/2-(s=r.y1-r.y0)/2,r.y1=t.y1/2+s/2;else if(1==r.targetLinks.length&&1==r.targetLinks[0].source.sourceLinks.length)s=r.y1-r.y0,r.y0=r.targetLinks[0].source.y0,r.y1=r.y0+s;else{var f=a.mean(r.sourceLinks,ve),y=a.mean(r.targetLinks,pe),g=((f&&y?(f+y)/2:f||y)-me(r))*e;r.y0+=g,r.y1+=g}})})}function h(){l.forEach(function(n){var o,a,l,s=t.y0,c=n.length;for(n.sort(e||Le),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 Ye(t){t.nodes.forEach(function(t){t.sourceLinks.sort(_e),t.targetLinks.sort(Pe)}),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 He(){var t=0,e=0,n=1,i=1,r=24,o=8,l=null,s=Ie,c=we,u=void 0,h=32,d=2,f=Re,y=Be;function g(){var g={nodes:f.apply(null,arguments),links:y.apply(null,arguments)};return function(f){f.x0=t,f.y0=e,f.x1=n,f.y1=i,f.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 a.group(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=ae(n,i)),"object"!=typeof r&&(r=t.target=ae(n,r)),i.sourceLinks.push(t),r.targetLinks.push(t)})}(f,s),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=le(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++)})}(f,u),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){ge(t,e)!=ge(r.source,e)&&ge(t,e)!=ge(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),ce(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(f,s),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max(a.sum(t.sourceLinks,xe),a.sum(t.targetLinks,xe)),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)})})}(f),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})}(f,u,c);var y=o;if(null!==l){var g=a.groups(f.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),p=a.max(g,function(t){return t.length});p>1&&(y=Math.max(1,(i-e)*l/(p-1)))}(function(t,e,n){var i=a.groups(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=a.min(i,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/a.sum(e,function(t){return t.value})});t.ky=r,t.links.forEach(function(e){e.width=e.value*t.ky});var o=a.max(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})})(f,y,r),je(f,u,s),Fe(f,u,s,y,y,h),Ye(f),$e(f,s,d,10,8),je(f,u,s),Fe(f,u,s,y,y,h),Ye(f),$e(f,s,d,10,8),function(t,e){let n=t;n.nodes.forEach(function(t){t.y+(t.y1-t.y0)>n.y1&&(t.y=t.y-(t.y+(t.y1-t.y0)-n.y1));var i=n.links.filter(function(n){return ge(n.source,e)==ge(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(!Te(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var n=de(e,t);return t.y1-n}if(e.target.column>t.target.column)return de(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}})})}(f,s),function(t,e){let n=t;n.nodes.forEach(function(t){var i=n.links.filter(function(n){return ge(n.target,e)==ge(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(!Te(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var n=fe(e,t);return t.y0-n}if(e.source.column>t.source.column)return fe(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}})})}(f,s),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=a.min(e,function(t){return t.y0}),l=a.max(e,function(t){return t.y1}),s=(t.y1-t.y0)/(l-o);function c(e){return(e-o)/(l-o)*(t.y1-t.y0)+t.y0}1>s?(e.forEach(function(t){t.y0=c(t.y0),t.y1=c(t.y1)}),n.forEach(function(t){t.y0=c(t.y0),t.y1=c(t.y1),t.width=t.width*s})):e.forEach(function(t){var e=t.y1-t.y0,n=c(t.y0)-t.y0;t.y0=c(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})})}}(f),$e(f,s,d,10,8)}(g),g}return g.update=function(t){return Ye(t),$e(t,s,d,10,8),t},g.nodeWidth=function(t){return arguments.length?(r=+t,g):r},g.nodePadding=function(t){return arguments.length?(o=+t,g):o},g.nodePaddingRatio=function(t){return arguments.length?(l=+t,g):l},g.nodes=function(t){return arguments.length?(f="function"==typeof t?t:ze(t),g):f},g.links=function(t){return arguments.length?(y="function"==typeof t?t:ze(t),g):y},g.nodeId=function(t){return arguments.length?(s="function"==typeof t?t:ze(t),g):s},g.nodeAlign=function(t){return arguments.length?(c="function"==typeof t?t:ze(t),g):c},g.nodeSort=function(t){return arguments.length?(u=t,g):u},g.iterations=function(t){return arguments.length?(h=+t,g):h},g.circularLinkGap=function(t){return arguments.length?(d=+t,g):d},g.extent=function(r){return arguments.length?(t=+r[0][0],e=+r[0][1],n=+r[1][0],i=+r[1][1],g):[[t,e],[n,i]]},g.size=function(r){return arguments.length?(t=e=0,n=+r[0],i=+r[1],g):[n-t,i-e]},g}const Xe=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=u.interpolateNumber(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=u.interpolateNumber(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 Ge(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 qe={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(ke))-1:0},justify:we},Ve={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=He().extent(m).links(v).nodes(p).nodeAlign(qe[d]||we).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 o,a,l,s;const c="vertical"===n.orientation?"down":"right",u=n.nodeStyle,h=n.edgeStyle,d=null!==(o=n.edgeOpacity)&&void 0!==o?o:.5,f=n.edgeColorBy||"source",y=Array.isArray(n.colorScheme)?n.colorScheme:r.schemeCategory10,g=new Map;t.forEach((t,e)=>{g.set(t.id,y[e%y.length])});const p=[],v=[],m=[];for(const e of t){const t=e.x1-e.x0,n=e.y1-e.y0;if(0>=t||0>=n)continue;const i=u?u(e):{},r={fill:i.fill||g.get(e.id)||"#4d430c",stroke:i.stroke,strokeWidth:i.strokeWidth,opacity:i.opacity};p.push({type:"rect",x:e.x0,y:e.y0,w:t,h:n,style:r,datum:e,id:e.id,label:e.id})}const x=[...e].sort((t,e)=>(e.sankeyWidth||0)-(t.sankeyWidth||0));for(const t of x){if(!t.sankeyWidth||0>=t.sankeyWidth)continue;const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;if(!e||!n)continue;let i="#999";h?i=h(t).fill||i:"target"===f&&n?i=g.get(n.id)||i:e&&(i=g.get(e.id)||i);const r=h?h(t):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,n=t.sankeyWidth/2,o=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;v.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-n}L${e.sourceX+o},${e.sourceY-n}L${e.sourceX+o},${e.sourceY+n}L${e.sourceX},${e.sourceY+n}Z`,style:{fill:c,fillOpacity:null!==(a=r.fillOpacity)&&void 0!==a?a:d,stroke:"none",opacity:r.opacity},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+o}}),v.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:d,stroke:"none",opacity:r.opacity},datum:t,_gradient:{direction:"left",from:0,to:1,x0:e.targetX-s,x1:e.targetX}});continue}let o;if(o=t.circular&&t.circularPathData?Ge(t):Xe(t),!o)continue;const c={fill:r.fill||i,fillOpacity:null!==(s=r.fillOpacity)&&void 0!==s?s:d,stroke:r.stroke||"none",strokeWidth:r.strokeWidth,opacity:r.opacity};v.push({type:"bezier",pathD:o,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,s;"down"===c?(a=n.x0+t/2,l=n.y1+14,s="middle"):(i[0]/2>n.x0+t/2?(a=n.x0-6,s="end"):(a=n.x1+6,s="start"),l=n.y0+r/2),m.push({x:a,y:l,text:o+"",anchor:s,baseline:"middle",fontSize:11})}}var b;return{sceneNodes:p,sceneEdges:v,labels:m}}},Ke={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 d=[];for(const e of t){const t=null!=e.x&&null!=e.y&&(0!==e.x||0!==e.y),n=null==c?void 0:c.get(e.id);t?u++:n?(e.x=n.x,e.y=n.y,u++):d.push(e)}const f=u>0&&.3>=(t.length>0?d.length/t.length:1);if(f){const n=new Map;for(const e of t)n.set(e.id,e);for(const t of d){const i=Ze(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=Ue(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=Ue(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 y=null!==(o=n.iterations)&&void 0!==o?o:Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),g=f?40:y,p=Qe(n.nodeSize,n.nodeSizeRange,t),v=t=>p(t),m=h.forceLink().strength(t=>Math.min(2.5,t.weight?t.weight*a:a)).id(t=>t.id),x=h.forceSimulation().force("charge",h.forceManyBody().strength(t=>-25*v(t))).force("center",h.forceCenter(l,s).strength(.8)).force("x",h.forceX(l).strength(.15)).force("y",h.forceY(s).strength(.15));if(x.nodes(t),e.length>0){const t=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id}));x.force("link",m),x.force("link").links(t)}f?x.alpha(.3):.1>x.alpha()&&x.alpha(1),x.stop();for(let t=0;g>t;++t)x.tick();for(const e of t){if(null==e.x||null==e.y)continue;const t=v(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 b=new Map;for(const e of t)b.set(e.id,e);for(const t of e){if("string"==typeof t.source){const e=b.get(t.source);e&&(t.source=e)}if("string"==typeof t.target){const e=b.get(t.target);e&&(t.target=e)}}},buildScene(t,e,n,i){var o,a,l;const s=n.nodeStyle,c=n.edgeStyle,u=Qe(n.nodeSize,n.nodeSizeRange,t),h=Array.isArray(n.colorScheme)?n.colorScheme:r.schemeCategory10,d=new Map;t.forEach((t,e)=>{d.set(t.id,h[e%h.length])});const f=[],y=[],g=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=u(e),n=s?s(e):{},i={fill:n.fill||d.get(e.id)||"#007bff",stroke:n.stroke||"#fff",strokeWidth:null!==(o=n.strokeWidth)&&void 0!==o?o:2,opacity:n.opacity};f.push({type:"circle",cx:e.x,cy:e.y,r:t,style:i,datum:e,id:e.id,label:e.id})}const p=new Map;for(const e of t)p.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:p.get(t.source),n="object"==typeof t.target?t.target:p.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=c?c(t):{},r={stroke:i.stroke||"#999",strokeWidth:null!==(a=i.strokeWidth)&&void 0!==a?a:1,opacity:null!==(l=i.opacity)&&void 0!==l?l:.6};y.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=(v=n.nodeLabel)?"function"==typeof v?v:t=>t[v]||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=u(n);g.push({x:n.x,y:n.y-i-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var v;return{sceneNodes:f,sceneEdges:y,labels:g}}};function Ze(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 Ue(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 Qe(t,e,n){var r,o;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const l=e||[5,20],s=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===s.length)return()=>l[0];const c=null!==(r=a.min(s))&&void 0!==r?r:0,u=null!==(o=a.max(s))&&void 0!==o?o:1;if(c===u)return()=>(l[0]+l[1])/2;const h=i.scaleLinear().domain([c,u]).range(l).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?l[0]:h(i)}}const Je=r.schemeCategory10,tn={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,c=l-o,u=i[0]/2,h=i[1]/2,f=(y=n.valueAccessor)?"function"==typeof y?y:t=>{var e;return null!==(e=t[y])&&void 0!==e?e:1}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:1};var y;const g=new Map;for(let e=0;t.length>e;e++)g.set(t[e].id,e);const p=t.length,v=Array.from({length:p},()=>Array.from({length:p},()=>0));for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=g.get("string"==typeof t.source?t.source:t.source.id),i=g.get(e);if(void 0===n||void 0===i)continue;const r=f(t);v[n][i]=r}const m=d.chord().padAngle(r);a&&m.sortGroups(a);const x=m(v),b=x.groups,k=s.arc().innerRadius(c).outerRadius(l);for(const e of b){const n=t[e.index],i=k.centroid(e);n.x=i[0]+u,n.y=i[1]+h,n.arcData={startAngle:e.startAngle,endAngle:e.endAngle}}const w=new Map;for(const e of t)w.set(e.id,e);for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=w.get("string"==typeof t.source?t.source:t.source.id),i=w.get(e);n&&(t.source=n),i&&(t.target=i)}const E=new Map;for(const t of e)E.set(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const e of x){const n=t[e.source.index].id,i=t[e.target.index].id,r=E.get(`${n}\0${i}`)||E.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,f=n.nodeStyle,y=n.edgeStyle,g=n.edgeColorBy||"source",p=Array.isArray(n.colorScheme)?n.colorScheme:Je,v=new Map;t.forEach((t,e)=>{v.set(t.id,p[e%p.length])});const m=d.ribbon().radius(c),x=[],b=[],k=[];for(let e=0;t.length>e;e++){const n=t[e],i=n.arcData;if(!i)continue;let o;o=f?f(n).fill||v.get(n.id)||p[e%p.length]:v.get(n.id)||p[e%p.length];const a=f?f(n):{},l={fill:o,stroke:a.stroke||"black",strokeWidth:null!==(r=a.strokeWidth)&&void 0!==r?r:1,opacity:a.opacity};x.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=m(e);if(!n)continue;const i=en(n,u,h);let r="#999";if(y)r=y(t).fill||r;else{const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;"target"===g&&n?r=v.get(n.id)||r:e&&(r=v.get(e.id)||r)}const a=y?y(t):{},s={fill:r,fillOpacity:null!==(o=a.fillOpacity)&&void 0!==o?o:l,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity};b.push({type:"ribbon",pathD:i,style:s,datum:t})}if(!1!==n.showLabels){const e=(w=n.nodeLabel)?"function"==typeof w?w:t=>t[w]||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;k.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 w;return{sceneNodes:x,sceneEdges:b,labels:k}}};function en(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 nn(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 rn={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,n,i){var r;const o=n.__hierarchyRoot;if(!o)return;const a=n.chartType,s=(c=n.childrenAccessor)?"function"==typeof c?c:t=>t[c]:void 0;var c;const u=n.hierarchySum||(t=>{var e;return null!==(e=t.value)&&void 0!==e?e:0}),h=l.hierarchy(o,s);h.sum(u),h.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[d,f]=i;switch(a){case"tree":!function(t,e,n,i){const r=e.treeOrientation||"vertical",o=l.tree();o.size("horizontal"===r?[i,n]:"radial"===r?[2*Math.PI,Math.min(n,i)/2*.8]:[n,i]),o(t)}(h,n,d,f);break;case"cluster":!function(t,e,n,i){const r=e.treeOrientation||"vertical",o=l.cluster();o.size("horizontal"===r?[i,n]:"radial"===r?[2*Math.PI,Math.min(n,i)/2*.8]:[n,i]),o(t)}(h,n,d,f);break;case"treemap":!function(t,e,n,i){var r,o;const a=null!==(r=e.padding)&&void 0!==r?r:4,s=null!==(o=e.paddingTop)&&void 0!==o?o:0,c=l.treemap().size([n,i]).tile(l.treemapBinary).padding(a);s>0&&c.paddingTop(s),c(t)}(h,n,d,f);break;case"circlepack":!function(t,e,n,i){var r;const o=null!==(r=e.padding)&&void 0!==r?r:4;l.pack().size([n,i]).padding(o)(t)}(h,n,d,f);break;case"partition":!function(t,e,n,i){var r;l.partition().size([n,i]).padding(null!==(r=e.padding)&&void 0!==r?r:1)(t)}(h,n,d,f)}const y=h.descendants();t.length=0,e.length=0;const g=new Map;for(let e=0;y.length>e;e++){const i=y[e],o={id:cn(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?on(o,i,n):"treemap"===a||"partition"===a?an(o,i):"circlepack"===a&&ln(o,i),o.__hierarchyNode=i,t.push(o),g.set(i,o)}if("tree"===a||"cluster"===a)for(const t of y)if(t.parent){const n=g.get(t.parent),i=g.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=sn(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=un(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=un(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=nn(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=un(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=nn(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 on(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 an(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 ln(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 sn(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 cn(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 un(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 hn(t){const e=t;return e.__orbitState||(e.__orbitState={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()}),e.__orbitState}const dn={sankey:Ve,force:Ke,chord:tn,tree:rn,cluster:rn,treemap:rn,circlepack:rn,partition:rn,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),c=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),u=function(t){if(Array.isArray(t))return t;switch(t){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(n.orbitMode),h=null!==(o=n.orbitSize)&&void 0!==o?o:2.95,d=null!==(a=n.orbitEccentricity)&&void 0!==a?a:1,f="number"==typeof h?()=>h:h,y="number"==typeof d?()=>d:d,g=hn(n);g.metaMap.clear(),i.length=0,r.length=0;const p=new Map;function v(t){var e;const n=null!==(e=p.get(t))&&void 0!==e?e:0;return p.set(t,n+1),0===n?t:`${t}__${n}`}const m=e[0]/2,x=e[1]/2,b=Math.min(e[0],e[1])/2*.85,k=v(c(t));i.push({id:k,x:m,y:x,x0:m,x1:m,y0:x,y1:x,width:0,height:0,value:0,depth:0,data:t}),g.metaMap.set(k,{ring:b,angle:0,depth:0,parentId:null,eccentricity:1}),function t(e,n,o,a,h,d,p){const m=l(e);if(!(null==m?void 0:m.length))return;const x=m.length;let b=0,k=0,w=0;for(;x>k;)k+=u[Math.min(w,u.length-1)],w++,b++;let E=0;for(let x=0;b>x;x++){const k=u[Math.min(x,u.length-1)],w=m.slice(E,E+k);if(!w.length)break;const A=(x+1)/b,M={id:n,depth:d,data:e,parentId:n},S=p?h/f(M)*A:h*A,P=s.pie().value(t=>{var e;return(null===(e=l(t))||void 0===e?void 0:e.length)?4:1}).sort(null),_=P(w),L=y(M);for(let e=0;w.length>e;e++){const l=(_[e].startAngle+_[e].endAngle)/2,s=w[e],u=v(c(s)),h=o+S*Math.sin(l),f=a+S*Math.cos(l)*L;i.push({id:u,x:h,y:f,x0:h,x1:h,y0:f,y1:f,width:0,height:0,value:0,depth:d,data:s}),g.metaMap.set(u,{ring:S,angle:l,depth:d,parentId:n,eccentricity:L}),r.push({source:n,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:u}}),t(s,u,h,f,S,d+1,!0)}E+=k}}(t,k,m,x,b,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=hn(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=hn(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 fn(t){return dn[t]}class yn{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({},ee),t.tensionConfig),"sankey"===t.chartType&&t.showParticles&&(this.particlePool=new ie(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({},ee),t.tensionConfig),"sankey"===t.chartType&&t.showParticles&&!this.particlePool&&(this.particlePool=new ie(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({},gn(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({},gn(e)),{data:t})),this.nodes.has(n)||this.nodes.set(n,Object.assign(Object.assign({},gn(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,gn(e)),this.nodeTimestamps.set(e,a),this.tension+=this.tensionConfig.newNode,o=!0),this.nodes.has(n)||(this.nodes.set(n,gn(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=fn(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=fn(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=fn(this.config.chartType);return!!(null==t?void 0:t.supportsAnimation)&&!1!==this.config.orbitAnimated}tickAnimation(t,e){const n=fn(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=T(t,this.transition),n=D(e);for(const t of this.nodes.values())void 0===t._targetX0||void 0===t._prevX0||0===t._prevX0&&0===t._prevX1||(t.x0=W(t._prevX0,t._targetX0,n),t.x1=W(t._prevX1,t._targetX1,n),t.y0=W(t._prevY0,t._targetY0,n),t.y1=W(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=W(t._prevY0,t._targetY0,n),t.y1=W(t._prevY1,t._targetY1,n),t.sankeyWidth=W(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=u.interpolateNumber(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=u.interpolateNumber(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 gn(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 pn(t,e,n,i,r=30){let o=null,a=r,l=1/0;for(const e of t){const t=vn(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=kn(t,n,i);e&&a>e.distance&&(o=e,a=e.distance)}return o}function vn(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=N(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=O(Math.atan2(r,i)),l=O(t.startAngle),s=O(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 mn=null,xn=null;function bn(){return xn||(mn=document.createElement("canvas"),mn.width=1,mn.height=1,xn=mn.getContext("2d")),xn}function kn(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=bn();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=bn();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 wn(t){const{width:e,height:n,totalWidth:i,totalHeight:r,margin:o,labels:a,title:l,legend:s,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:h,legendIsolatedCategories:d,legendPosition:f="right",foregroundGraphics:y,sceneNodes:p,annotations:v,svgAnnotationRules:m}=t;return g.createElement(g.Fragment,null,g.createElement("svg",{role:"img",width:i,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},g.createElement("title",null,"string"==typeof l?l:"Network Chart"),g.createElement("desc",null,"string"==typeof l?l+" — network data visualization":"Network data visualization"),g.createElement("g",{transform:`translate(${o.left},${o.top})`},a.map((t,e)=>g.createElement("text",{key:"label-"+e,x:t.x,y:t.y,textAnchor:t.anchor||"start",dominantBaseline:t.baseline||"middle",fontSize:t.fontSize||11,fontWeight:t.fontWeight,fill:t.fill||"currentColor",stroke:t.stroke,strokeWidth:t.strokeWidth,paintOrder:t.paintOrder,style:{pointerEvents:"none"}},t.text)),v&&v.filter(t=>"widget"!==t.type).map((t,i)=>{if(m){const r=m(t,i,{width:e,height:n,sceneNodes:p});if(r)return g.createElement(g.Fragment,{key:"annotation-"+i},r)}return null}),y),l&&"string"==typeof l?g.createElement("text",{x:i/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor"},l):l?g.createElement("foreignObject",{x:0,y:0,width:i,height:o.top},l):null,tt({legend:s,totalWidth:i,totalHeight:r,margin:o,legendPosition:f,title:l,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:h,legendIsolatedCategories:d})),null==v?void 0:v.filter(t=>"widget"===t.type&&t.nodeId&&p).map((t,e)=>{var n,i,r,a,l,s,c,u,h;const d=p.find(e=>{var n,i,r,o,a;return e.id===t.nodeId||(null===(n=e.datum)||void 0===n?void 0:n.id)===t.nodeId||(null===(r=null===(i=e.datum)||void 0===i?void 0:i.data)||void 0===r?void 0:r.id)===t.nodeId||(null===(a=null===(o=e.datum)||void 0===o?void 0:o.data)||void 0===a?void 0:a.name)===t.nodeId});if(!d)return null;const f=o.left+(null!==(n=d.cx)&&void 0!==n?n:null!=d.x&&null!=d.w?d.x+d.w/2:null!==(i=d.x)&&void 0!==i?i:0),y=o.top+(null!==(r=d.cy)&&void 0!==r?r:null!=d.y&&null!=d.h?d.y+d.h/2:null!==(a=d.y)&&void 0!==a?a:0),v=null!==(l=t.dx)&&void 0!==l?l:0,m=null!==(s=t.dy)&&void 0!==s?s:-16,x=null!==(c=t.width)&&void 0!==c?c:32,b=null!==(u=t.height)&&void 0!==u?u:32,k=null!==(h=t.content)&&void 0!==h?h:g.createElement("span",{style:{fontSize:18,cursor:"default"}},"ℹ️");return g.createElement("div",{key:"widget-"+e,style:{position:"absolute",left:f+v-x/2,top:y+m-b/2,width:x,height:b,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:5}},k)}))}function En(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 An(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 Mn(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 Sn(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()}wn.displayName="NetworkSVGOverlay";const Pn={top:20,right:80,bottom:20,left:80},_n={top:40,right:40,bottom:40,left:40},Ln=new Set(["chord","force","circlepack","orbit"]),Cn=[800,600],Dn={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 Tn({data:t}){var e,n,i,r,o,a;if("edge"===t.type){const e=t.data;return g.createElement("div",{className:"semiotic-tooltip",style:Dn},g.createElement("div",{style:{fontWeight:600}},"object"==typeof e.source?e.source.id:e.source," → ","object"==typeof e.target?e.target.id:e.target),null!=e.value&&g.createElement("div",{style:{marginTop:4,opacity:.8}},"Value:"," ","number"==typeof e.value?e.value.toLocaleString():e.value+""))}const l=t.data,s=null==l?void 0:l.__hierarchyNode;if(s){const t=[];let o=s;for(;o;){const a=null!==(r=null!==(n=null===(e=o.data)||void 0===e?void 0:e.name)&&void 0!==n?n:null===(i=o.data)||void 0===i?void 0:i.id)&&void 0!==r?r:l.id;null!=a&&t.unshift(a+""),o=o.parent}t.length>1&&t.shift();const a=t.length-1;return g.createElement("div",{className:"semiotic-tooltip",style:Dn},g.createElement("div",null,t.map((t,e)=>g.createElement("span",{key:e},e>0&&g.createElement("span",{style:{margin:"0 3px",opacity:.5}}," → "),e===a?g.createElement("strong",null,t):g.createElement("span",{style:{opacity:.7}},t)))),null!=l.value&&l.value>0&&g.createElement("div",{style:{marginTop:4,opacity:.8}},"number"==typeof l.value?l.value.toLocaleString():l.value+""))}const c=((null===(o=l.sourceLinks)||void 0===o?void 0:o.length)||0)+((null===(a=l.targetLinks)||void 0===a?void 0:a.length)||0),u=(l.sourceLinks||[]).reduce((t,e)=>t+(e.value||0),0)+(l.targetLinks||[]).reduce((t,e)=>t+(e.value||0),0);return g.createElement("div",{className:"semiotic-tooltip",style:Dn},g.createElement("div",{style:{fontWeight:600}},l.id),null!=l.value&&l.value>0&&g.createElement("div",{style:{marginTop:4,opacity:.8}},"Total:"," ","number"==typeof l.value?l.value.toLocaleString():l.value+""),c>0&&g.createElement("div",{style:{marginTop:4,opacity:.8}},"Connections: ",c,u!==c&&` (weighted: ${u.toLocaleString()})`))}const Wn=t.forwardRef(function(e,n){var i,r,o,a,l,c,u,h,d,f,y;const{chartType:p,nodes:v,edges:m,data:x,initialEdges:b,nodeIDAccessor:k="id",sourceAccessor:w="source",targetAccessor:E="target",valueAccessor:A="value",childrenAccessor:M,hierarchySum:S,orientation:P="horizontal",nodeAlign:_="justify",nodePaddingRatio:C=.05,nodeWidth:D=15,iterations:T=300,forceStrength:W=.1,padAngle:$=.01,groupWidth:N=20,sortGroups:O,edgeSort:z,treeOrientation:I="vertical",edgeType:R="curve",padding:B,paddingTop:j,tensionConfig:F,showParticles:Y=!1,particleStyle:H,nodeStyle:V,edgeStyle:K,colorBy:Z,colorScheme:U="category10",edgeColorBy:Q="source",edgeOpacity:J=.5,colorByDepth:tt=!1,nodeSize:et=8,nodeSizeRange:nt=[5,20],nodeLabel:it,showLabels:rt=!0,labelMode:ot,size:at=Cn,responsiveWidth:lt,responsiveHeight:st,margin:ct,className:ut,background:ht,enableHover:dt=!0,tooltipContent:ft,customHoverBehavior:yt,customClickBehavior:gt,onObservation:pt,chartId:mt,onTopologyChange:xt,annotations:kt,svgAnnotationRules:At,legend:Mt,legendPosition:St,legendHoverBehavior:Pt,legendClickBehavior:_t,legendHighlightedCategory:Tt,legendIsolatedCategories:Wt,title:$t,foregroundGraphics:Nt,backgroundGraphics:It,decay:Rt,pulse:Bt,staleness:jt,thresholds:Ft,accessibleTable:Yt,orbitMode:Ht,orbitSize:Xt,orbitSpeed:Gt,orbitRevolution:qt,orbitRevolutionStyle:Vt,orbitEccentricity:Kt,orbitShowRings:Zt,orbitAnimated:Ut}=e,Qt=Ln.has(p)?_n:Pn,[Jt,te]=G(at,lt,st),ie=Object.assign(Object.assign({},Qt),ct),re=te[0]-ie.left-ie.right,oe=te[1]-ie.top-ie.bottom,ae="function"==typeof Nt?Nt({size:te,margin:ie}):Nt,le=t.useMemo(()=>Object.assign(Object.assign({},ee),F),[F]),se=t.useMemo(()=>Object.assign(Object.assign({},ne),H),[H]),ce=t.useMemo(()=>({chartType:p,nodeIDAccessor:k,sourceAccessor:w,targetAccessor:E,valueAccessor:A,childrenAccessor:M,hierarchySum:S,orientation:P,nodeAlign:_,nodePaddingRatio:C,nodeWidth:D,iterations:T,forceStrength:W,padAngle:$,groupWidth:N,sortGroups:O,edgeSort:z,treeOrientation:I,edgeType:R,padding:B,paddingTop:j,tensionConfig:le,showParticles:Y,particleStyle:se,nodeStyle:V,edgeStyle:K,nodeLabel:it,showLabels:rt,labelMode:ot,colorBy:Z,colorScheme:U,edgeColorBy:Q,edgeOpacity:J,colorByDepth:tt,nodeSize:et,nodeSizeRange:nt,decay:Rt,pulse:Bt,staleness:jt,thresholds:Ft,orbitMode:Ht,orbitSize:Xt,orbitSpeed:Gt,orbitRevolution:qt,orbitRevolutionStyle:Vt,orbitEccentricity:Kt,orbitShowRings:Zt,orbitAnimated:Ut}),[p,k,w,E,A,M,S,P,_,C,D,T,W,$,N,O,z,I,R,B,j,le,Y,se,V,K,it,rt,ot,Z,U,Q,J,tt,et,nt,Rt,Bt,jt,Ft,Ht,Xt,Gt,qt,Vt,Kt,Zt,Ut]),ue=t.useRef(null),he=t.useRef(0),de=t.useRef(0),fe=t.useRef(!0),ye=Lt(t=>t.theme),ge=t.useRef(()=>{}),pe=t.useRef(null);pe.current||(pe.current=new yn(ce));const[ve,me]=t.useState(null),[xe,be]=t.useState(0),[ke,we]=t.useState(0),[Ee,Ae]=t.useState(!1),Me=t.useRef(null),Se=t.useRef(new Map),Pe=t.useRef(0),_e=t.useCallback(t=>{if("function"==typeof Z)return Z(t)+"";if("string"==typeof Z&&t.data){const e=t.data[Z];if(void 0!==e){if(!Se.current.has(e+"")){const t=Array.isArray(U)?U:L;Se.current.set(e+"",t[Pe.current++%t.length])}return Se.current.get(e+"")}}if(!Se.current.has(t.id)){const e=Array.isArray(U)?U:L;Se.current.set(t.id,e[Pe.current++%e.length])}return Se.current.get(t.id)},[Z,U]),Le=t.useCallback(t=>{if("function"==typeof Q)return Q(t);const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;return"target"===Q&&n?_e(n):e?_e(e):"#999"},[Q,_e]),Ce=t.useCallback(t=>{if(!(null==H?void 0:H.colorBy))return Le(t);const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;return"target"===se.colorBy&&n?_e(n):e?_e(e):"#999"},[null==H?void 0:H.colorBy,se.colorBy,_e,Le]),De="sankey"===p&&Y||!!Bt||null!==(r=null===(i=pe.current)||void 0===i?void 0:i.isAnimating)&&void 0!==r&&r,Te=t.useCallback(()=>{he.current&&!De||he.current||(he.current=requestAnimationFrame(()=>ge.current()))},[De]);t.useEffect(()=>{var t;null===(t=pe.current)||void 0===t||t.updateConfig(ce),fe.current=!0,Te()},[ce,Te]),t.useEffect(()=>{fe.current=!0,Te()},[ye,Te]);const We=t.useCallback(()=>{const t=pe.current;if(!t)return;t.runLayout([re,oe]),t.buildScene([re,oe]),fe.current=!0;const e=Array.isArray(U)?U:L,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(Pe.current=n.length,be(t.layoutVersion),xt){const{nodes:e,edges:n}=t.getLayoutData();xt(e,n)}},[re,oe,xt,U]),$e=t.useCallback(t=>{const e=pe.current;e&&(e.ingestEdge(t)&&We(),Te())},[We,Te]),Ne=t.useCallback(t=>{const e=pe.current;if(!e)return;let n=!1;for(const i of t)e.ingestEdge(i)&&(n=!0);n&&We(),Te()},[We,Te]),Oe=t.useCallback(()=>{var t;null===(t=pe.current)||void 0===t||t.clear(),Se.current.clear(),Pe.current=0,be(0),me(null),Me.current=null,fe.current=!0,Te()},[Te]),ze=t.useCallback(()=>{const t=pe.current;t&&(t.tension+=999,We(),Te())},[We,Te]);t.useImperativeHandle(n,()=>({push:$e,pushMany:Ne,clear:Oe,getTopology:()=>{var t,e;return null!==(e=null===(t=pe.current)||void 0===t?void 0:t.getLayoutData())&&void 0!==e?e:{nodes:[],edges:[]}},getTopologyDiff:()=>{const t=pe.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:ze,getTension:()=>{var t,e;return null!==(e=null===(t=pe.current)||void 0===t?void 0:t.tension)&&void 0!==e?e:0}}),[$e,Ne,Oe,ze]);const Ie=["tree","cluster","treemap","circlepack","partition","orbit"].includes(p),Re=Ie?x||(Array.isArray(m)?void 0:m):void 0;t.useEffect(()=>{const t=pe.current;if(t)if(Ie&&Re)t.ingestHierarchy(Re,[re,oe]),t.buildScene([re,oe]),fe.current=!0,Te();else{const e=v||[],n=Array.isArray(m)?m:[];if(0===e.length&&0===n.length)return;t.ingestBounded(e,n,[re,oe]),t.buildScene([re,oe]);const i=Array.isArray(U)?U:L,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])}Pe.current=r.length,fe.current=!0,Te()}},[v,m,x,Re,Ie,re,oe,ce,Te,U]),t.useEffect(()=>{b&&b.length>0&&Ne(b)},[]);const Be=t.useCallback(t=>{if(yt&&yt(t),pt){const e=Date.now();pt(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})}},[yt,pt,mt]),je=t.useCallback(t=>{if(gt&&gt(t),pt){const e=Date.now();pt(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})}},[gt,pt,mt]),Fe=t.useRef(()=>{}),Ye=t.useRef(()=>{});Fe.current=t=>{if(!dt)return;const e=ue.current;if(!e)return;const n=e.getBoundingClientRect(),i=t.clientX-n.left-ie.left,r=t.clientY-n.top-ie.top;if(0>i||i>re||0>r||r>oe)return void(Me.current&&(Me.current=null,me(null),Be&&(Be(null),fe.current=!0),Te()));const o=pe.current;if(!o)return;const a=pn(o.sceneNodes,o.sceneEdges,i,r);if(!a)return void(Me.current&&(Me.current=null,me(null),Be&&(Be(null),fe.current=!0),Te()));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});Me.current=s,me(s),Be&&(Be(s),fe.current=!0),Te()},Ye.current=()=>{Me.current&&(Me.current=null,me(null),Be&&(Be(null),fe.current=!0),Te())};const He=t.useRef(()=>{});He.current=t=>{if(!gt&&!pt)return;const e=ue.current;if(!e)return;const n=e.getBoundingClientRect(),i=t.clientX-n.left-ie.left,r=t.clientY-n.top-ie.top;if(0>i||i>re||0>r||r>oe)return;const o=pe.current;if(!o)return;const a=pn(o.sceneNodes,o.sceneEdges,i,r);if(a){const t=a.datum||{};je(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 je(null)},t.useCallback(t=>Fe.current(t),[]);const Xe=t.useCallback(()=>Ye.current(),[]),Ge=t.useCallback(t=>He.current(t),[]),qe=t.useRef(-1),Ve=t.useCallback(t=>{const e=pe.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=X(t.key,0>i?-1:i,n.length);if(null===r)return;if(t.preventDefault(),0>r)return qe.current=-1,Me.current=null,me(null),Be&&(Be(null),fe.current=!0),void Te();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});Me.current=s,me(s),Be&&(Be(s),fe.current=!0),Te()},[Be,Te]),Ke=t.useCallback(t=>{qe.current=-1,Fe.current(t)},[]);ge.current=()=>{var t,e,n,i,r,o,a;he.current=0;const l=ue.current;if(!l)return;const s=l.getContext("2d");if(!s)return;const c=pe.current;if(!c)return;const u=performance.now(),h=de.current?Math.min((u-de.current)/1e3,.1):.016;de.current=u;const d=c.advanceTransition(u),f=c.tickAnimation([re,oe],h);(d||fe.current||f)&&c.buildScene([re,oe]);const y=Dt();if(!Ct(l,te,ie,y))return;s.clearRect(-ie.left,-ie.top,te[0],te[1]),ht&&(s.fillStyle=ht,s.fillRect(0,0,re,oe)),Rt&&c.applyDecay(),Bt&&c.applyPulse(u),Ft&&c.applyThresholds(u),c.applyTopologyDiff(u);const g=null!==(t=null==jt?void 0:jt.threshold)&&void 0!==t?t:5e3,p=jt&&c.lastIngestTime>0&&u-c.lastIngestTime>g;if(p&&(s.globalAlpha=null!==(e=null==jt?void 0:jt.dimOpacity)&&void 0!==e?e:.5),function(t,e){for(const n of e)switch(n.type){case"bezier":En(t,n);break;case"line":An(t,n);break;case"ribbon":Mn(t,n);break;case"curved":Sn(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)),Ot(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()),zt(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),Y&&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:ne.spawnRate,l=null!==(o=i.maxPerEdge)&&void 0!==o?o:ne.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,se);const e=.5*(null!==(n=se.speedMultiplier)&&void 0!==n?n:1);let i;if(se.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:ne.radius,s=null!==(a=i.opacity)&&void 0!==a?a:ne.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,se,Ce)}}p&&(s.globalAlpha=1);const v=fe.current;if(fe.current=!1,v||d||f){const t=ue.current;t&&t.setAttribute("aria-label",bt(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)&&we(t=>t+1),(De||d||f||c.hasActivePulses||c.hasActiveThresholds||c.hasActiveTopologyDiff)&&(he.current=requestAnimationFrame(()=>ge.current()))},t.useEffect(()=>(Te(),()=>{he.current&&(cancelAnimationFrame(he.current),he.current=0)}),[Te]),t.useEffect(()=>{fe.current=!0,Te()},[p,re,oe,ht,Te]),q(jt,pe,fe,Te,Ee,Ae);const Ze=dt&&ve?g.createElement("div",{className:"stream-network-tooltip",style:{position:"absolute",left:ie.left+ve.x,top:ie.top+ve.y,transform:`translate(${ve.x>.6*re?"calc(-100% - 12px)":"12px"}, ${.3*oe>ve.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:2,width:"max-content"}},ft?ft(ve):g.createElement(Tn,{data:ve})):null;if(vt){const t=pe.current;if(t){const e=["tree","cluster","treemap","circlepack","partition","orbit"].includes(p),n=e?x||(Array.isArray(m)?void 0:m):void 0;if(e&&n)t.ingestHierarchy(n,[re,oe]),t.buildScene([re,oe]);else{const e=v||[],n=Array.isArray(m)?m:[];(e.length>0||n.length>0)&&(t.ingestBounded(e,n,[re,oe]),t.buildScene([re,oe]))}}const e=null!==(o=null==t?void 0:t.sceneNodes)&&void 0!==o?o:[],n=null!==(a=null==t?void 0:t.sceneEdges)&&void 0!==a?a:[],i=null!==(l=null==t?void 0:t.labels)&&void 0!==l?l:[];return g.createElement("div",{className:"stream-network-frame"+(ut?" "+ut:""),role:"img","aria-label":"string"==typeof $t?$t:"Network chart",style:{position:"relative",width:te[0],height:te[1]}},g.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:te[0],height:te[1],style:{position:"absolute",left:0,top:0}},It&&g.createElement("g",{transform:`translate(${ie.left},${ie.top})`},It),g.createElement("g",{transform:`translate(${ie.left},${ie.top})`},ht&&g.createElement("rect",{x:0,y:0,width:re,height:oe,fill:ht}),n.map((t,e)=>function(t,e){switch(t.type){case"line":return g.createElement("line",{key:"net-edge-"+e,x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.stroke||"#999",strokeWidth:t.style.strokeWidth||1,opacity:t.style.opacity});case"bezier":case"ribbon":return g.createElement("path",{key:"net-edge-"+e,d:t.pathD,fill:t.style.fill||"#999",fillOpacity:t.style.fillOpacity,stroke:t.style.stroke||"none",strokeWidth:t.style.strokeWidth,opacity:t.style.opacity});case"curved":return g.createElement("path",{key:"net-edge-"+e,d:t.pathD,fill:t.style.fill||"none",stroke:t.style.stroke||"#999",strokeWidth:t.style.strokeWidth||1,opacity:t.style.opacity});default:return null}}(t,e)).filter(Boolean),e.map((t,e)=>function(t,e){switch(t.type){case"circle":return g.createElement("circle",{key:"net-circle-"+e,cx:t.cx,cy:t.cy,r:t.r,fill:t.style.fill||"#4e79a7",stroke:t.style.stroke,strokeWidth:t.style.strokeWidth,opacity:t.style.opacity});case"rect":return g.createElement("rect",{key:"net-rect-"+e,x:t.x,y:t.y,width:t.w,height:t.h,fill:t.style.fill||"#4e79a7",stroke:t.style.stroke,strokeWidth:t.style.strokeWidth,opacity:t.style.opacity});case"arc":{const n=t,i=s.arc().innerRadius(n.innerR).outerRadius(n.outerR).startAngle(n.startAngle).endAngle(n.endAngle)({})||"";return g.createElement("path",{key:"net-arc-"+e,d:i,transform:`translate(${n.cx},${n.cy})`,fill:n.style.fill||"#4e79a7",stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})}default:return null}}(t,e)).filter(Boolean),i.map((t,e)=>function(t,e){return g.createElement("text",{key:"net-label-"+e,x:t.x,y:t.y,textAnchor:t.anchor||"middle",dominantBaseline:t.baseline||"auto",fontSize:t.fontSize||11,fontWeight:t.fontWeight,fill:t.fill||"#333",stroke:t.stroke,strokeWidth:t.strokeWidth,paintOrder:t.paintOrder},t.text)}(t,e)).filter(Boolean))),g.createElement(wn,{width:re,height:oe,totalWidth:te[0],totalHeight:te[1],margin:ie,labels:i,sceneNodes:e,title:$t,legend:Mt,legendPosition:St,legendHoverBehavior:Pt,legendClickBehavior:_t,legendHighlightedCategory:Tt,legendIsolatedCategories:Wt,foregroundGraphics:ae,annotations:kt,svgAnnotationRules:At,annotationFrame:0}))}const Ue=pe.current;return g.createElement("div",{ref:Jt,className:"stream-network-frame"+(ut?" "+ut:""),role:"img","aria-label":"string"==typeof $t?$t:"Network chart",tabIndex:0,style:{position:"relative",width:lt?"100%":te[0],height:st?"100%":te[1],overflow:"visible"},onMouseMove:dt?Ke:void 0,onMouseLeave:dt?Xe:void 0,onClick:gt||pt?Ge:void 0,onKeyDown:Ve},It&&g.createElement("svg",{style:{position:"absolute",top:0,left:0,width:te[0],height:te[1],pointerEvents:"none"}},g.createElement("g",{transform:`translate(${ie.left},${ie.top})`},It)),g.createElement("canvas",{ref:ue,"aria-label":bt(null!==(u=null===(c=null==Ue?void 0:Ue.sceneNodes)||void 0===c?void 0:c.length)&&void 0!==u?u:0,null!==(d=null===(h=null==Ue?void 0:Ue.sceneEdges)||void 0===h?void 0:h.length)&&void 0!==d?d:0,"Network chart"),style:{position:"absolute",top:0,left:0}}),g.createElement(Et,{hoverPoint:ve}),Yt&&g.createElement(wt,{nodes:null!==(f=null==Ue?void 0:Ue.sceneNodes)&&void 0!==f?f:[],edges:null!==(y=null==Ue?void 0:Ue.sceneEdges)&&void 0!==y?y:[],chartType:"Network chart"}),g.createElement(wn,{width:re,height:oe,totalWidth:te[0],totalHeight:te[1],margin:ie,labels:(null==Ue?void 0:Ue.labels)||[],sceneNodes:null==Ue?void 0:Ue.sceneNodes,title:$t,legend:Mt,legendPosition:St,legendHoverBehavior:Pt,legendClickBehavior:_t,legendHighlightedCategory:Tt,legendIsolatedCategories:Wt,foregroundGraphics:ae,annotations:kt,svgAnnotationRules:At,annotationFrame:ke}),Ze,(null==jt?void 0:jt.showBadge)&&g.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}),{background:Ee?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"})},Ee?"STALE":"LIVE"))});function $n(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 Nn(t,e){let n=t.get(e);return n||(n={name:e,resolution:"union",clauses:new Map},t.set(e,n)),n}Wn.displayName="StreamNetworkFrame";const[On,zn]=At(t=>({selections:new Map,setClause(e,n){t(t=>{const i=new Map(t.selections),r=Nn(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=Nn(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}})}})),[In,Rn]=At(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 Bn(e){const n=t.useId(),i=e.clientId||n,{name:r}=e,o=zn(t=>t.selections.get(r)),a=zn(t=>t.setClause),l=zn(t=>t.clearClause),s=t.useMemo(()=>!!o&&o.clauses.size>0,[o]);return{predicate:t.useMemo(()=>o&&0!==o.clauses.size?function(t,e){const n=[];for(const[i,r]of t.clauses)"crossfilter"===t.resolution&&i===e||n.push($n(r));return 0===n.length?()=>!0:"intersect"===t.resolution?t=>n.every(e=>e(t)):t=>n.some(e=>e(t))}(o,i):()=>!0,[o,i]),isActive:s,selectPoints:t.useCallback(t=>{const e={};for(const[n,i]of Object.entries(t))e[n]={type:"point",values:new Set(i)};a(r,{clientId:i,type:"point",fields:e})},[i,r,a]),selectInterval:t.useCallback(t=>{const e={};for(const[n,i]of Object.entries(t))e[n]={type:"interval",range:i};a(r,{clientId:i,type:"interval",fields:e})},[i,r,a]),clear:t.useCallback(()=>{l(r,i)},[l,r,i]),clientId:i}}function jn({selection:e,linkedHover:n,fallbackFields:i=[],unwrapData:r=!1,onObservation:o,chartType:a,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}(n,i),c=Bn({name:(null==e?void 0:e.name)||"__unused__"}),u=function(e){const n=e.name||"hover",{fields:i}=e,{predicate:r,isActive:o,selectPoints:a,clear:l}=Bn({name:n});return{onHover:t.useCallback(t=>{if(!t)return void l();const e={};for(const n of i){const i=t[n];void 0!==i&&(e[n]=[i])}Object.keys(e).length>0&&a(e)},[i,a,l,n]),predicate:r,isActive:o}}({name:(null==s?void 0:s.name)||"hover",fields:(null==s?void 0:s.fields)||i||[]}),h=Rn(t=>t.pushObservation);return{activeSelectionHook:e?{isActive:c.isActive,predicate:c.predicate}:null,customHoverBehavior:t.useCallback(t=>{var e,i;if(n)if(t){let e=t.data||t.datum||t;Array.isArray(e)&&(e=e[0]),u.onHover(e)}else u.onHover(null);if(o||h){const n={timestamp:Date.now(),chartType:a||"unknown",chartId:l};if(t){let r=t.data||t.datum||t;Array.isArray(r)&&(r=r[0]);const a=Object.assign(Object.assign({},n),{type:"hover",datum:r||{},x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(i=t.y)&&void 0!==i?i:0});o&&o(a),h&&h(a)}else{const t=Object.assign(Object.assign({},n),{type:"hover-end"});o&&o(t),h&&h(t)}}},[n,u,o,a,l,h]),customClickBehavior:t.useCallback(t=>{var e,n;if(o||h){const i={timestamp:Date.now(),chartType:a||"unknown",chartId:l};if(t){let r=t.data||t.datum||t;Array.isArray(r)&&(r=r[0]);const a=Object.assign(Object.assign({},i),{type:"click",datum:r||{},x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(n=t.y)&&void 0!==n?n:0});o&&o(a),h&&h(a)}else{const t=Object.assign(Object.assign({},i),{type:"click-end"});o&&o(t),h&&h(t)}}},[o,h,a,l])}}const Fn={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 Yn(t,e,n){var i,r,o,a,l,s;const c=Fn[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 Hn={display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #999)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"},Xn={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function Gn(t,e,n,i){return!1===i||null==t||Array.isArray(t)&&t.length>0?null:Array.isArray(t)?g.createElement("div",{style:Object.assign(Object.assign({},Hn),{width:e,height:n})},i||"No data available"):null}function qn(t,e,n){if(!t)return null;const i=Math.min(5,Math.floor(n/40)),r=Math.max(8,Math.floor(n/(3*i))),o=Math.max(6,Math.floor(n/(2.5*i))),a=Math.floor((n-(i*(r+o)-o))/2);return g.createElement("div",{style:{width:e,height:n,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"}},Array.from({length:i},(t,n)=>g.createElement("div",{key:n,className:"semiotic-loading-bar",style:Object.assign(Object.assign({},Xn),{position:"absolute",top:a+n*(r+o),left:Math.floor(.1*e),width:30+(37*n+13)%50+"%",height:r,opacity:.5+n%2*.2})})))}const Vn=t.forwardRef(function(e,n){var i,r,o,a;const l=Yn(e.mode,{width:null!==(r=null===(i=e.size)||void 0===i?void 0:i[0])&&void 0!==r?r:e.width,height:null!==(a=null===(o=e.size)||void 0===o?void 0:o[1])&&void 0!==a?a:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{size:s,margin:c,className:u,arrowOfTime:h="right",windowMode:d="sliding",windowSize:f=200,data:y,timeAccessor:p,valueAccessor:v,timeExtent:m,valueExtent:x,extentPadding:b,stroke:k="#007bff",strokeWidth:w=2,strokeDasharray:E,background:A,tooltipContent:M,tooltip:S,onHover:P,annotations:_,svgAnnotationRules:L,tickFormatTime:C,tickFormatValue:D,decay:T,pulse:W,staleness:$,transition:N,linkedHover:O,selection:z,onObservation:I,chartId:R,loading:B,emptyContent:j,emphasis:F,legendPosition:Y}=e,H=l.showAxes,X=l.enableHover,G=null!=c?c:l.marginDefaults,q=null!=s?s:[l.width,l.height],V=null!=M?M:S,K=t.useRef(null),{customHoverBehavior:Z}=jn({selection:z,linkedHover:O,unwrapData:!0,onObservation:I,chartType:"RealtimeLineChart",chartId:R}),U=t.useCallback(t=>{P&&P(t),Z(t)},[P,Z]);t.useImperativeHandle(n,()=>({push:t=>{var e;return null===(e=K.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=K.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=K.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=K.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const Q=qn(B,q[0],q[1]);if(Q)return Q;const J=Gn(y,q[0],q[1],j);if(J)return J;const tt={stroke:k,strokeWidth:w,strokeDasharray:E};return g.createElement(te,{ref:K,chartType:"line",runtimeMode:"streaming",size:q,margin:G,className:F?`${u||""} semiotic-emphasis-${F}`.trim():u,arrowOfTime:h,windowMode:d,windowSize:f,data:y,timeAccessor:p,valueAccessor:v,xExtent:m,yExtent:x,extentPadding:b,lineStyle:tt,showAxes:H,background:A,hoverAnnotation:X,tooltipContent:V,customHoverBehavior:U,annotations:_,svgAnnotationRules:L,tickFormatTime:C,tickFormatValue:D,decay:T,pulse:W,staleness:$,transition:N,legendPosition:Y})});Vn.displayName="RealtimeLineChart";const Kn=t.forwardRef(function(e,n){var i,r,o,a;const l=Yn(e.mode,{width:null!==(r=null===(i=e.size)||void 0===i?void 0:i[0])&&void 0!==r?r:e.width,height:null!==(a=null===(o=e.size)||void 0===o?void 0:o[1])&&void 0!==a?a:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{binSize:s,size:c,margin:u,className:h,arrowOfTime:d="right",windowMode:f="sliding",windowSize:y=200,data:p,timeAccessor:v,valueAccessor:m,timeExtent:x,valueExtent:b,extentPadding:k,categoryAccessor:w,colors:E,fill:A,stroke:M,strokeWidth:S,gap:P,background:_,tooltipContent:L,tooltip:C,onHover:D,annotations:T,svgAnnotationRules:W,tickFormatTime:$,tickFormatValue:N,linkedHover:O,selection:z,decay:I,pulse:R,staleness:B,transition:j,onObservation:F,chartId:Y,loading:H,emptyContent:X,emphasis:G,legendPosition:q}=e,V=l.showAxes,K=l.enableHover,Z=null!=u?u:l.marginDefaults,U=null!=c?c:[l.width,l.height],Q=null!=L?L:C,J=t.useRef(null),{customHoverBehavior:tt}=jn({selection:z,linkedHover:O,unwrapData:!0,onObservation:F,chartType:"RealtimeTemporalHistogram",chartId:Y}),et=t.useCallback(t=>{D&&D(t),tt(t)},[D,tt]);t.useImperativeHandle(n,()=>({push:t=>{var e;return null===(e=J.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=J.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=J.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=J.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const nt=qn(H,U[0],U[1]);if(nt)return nt;const it=Gn(p,U[0],U[1],X);if(it)return it;const rt={};return null!=A&&(rt.fill=A),null!=M&&(rt.stroke=M),null!=S&&(rt.strokeWidth=S),null!=P&&(rt.gap=P),g.createElement(te,{ref:J,chartType:"bar",runtimeMode:"streaming",size:U,margin:Z,className:G?`${h||""} semiotic-emphasis-${G}`.trim():h,arrowOfTime:d,windowMode:f,windowSize:y,data:p,timeAccessor:v,valueAccessor:m,xExtent:x,yExtent:b,extentPadding:k,binSize:s,categoryAccessor:w,barColors:E,barStyle:rt,showAxes:V,background:_,hoverAnnotation:K,tooltipContent:Q,customHoverBehavior:et,annotations:T,svgAnnotationRules:W,tickFormatTime:$,tickFormatValue:N,decay:I,pulse:R,staleness:B,transition:j,legendPosition:q})});Kn.displayName="RealtimeTemporalHistogram";const Zn=Kn,Un=t.forwardRef(function(e,n){var i,r,o,a;const l=Yn(e.mode,{width:null!==(r=null===(i=e.size)||void 0===i?void 0:i[0])&&void 0!==r?r:e.width,height:null!==(a=null===(o=e.size)||void 0===o?void 0:o[1])&&void 0!==a?a:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{size:s,margin:c,className:u,arrowOfTime:h="right",windowMode:d="sliding",windowSize:f=200,data:y,timeAccessor:p,valueAccessor:v,timeExtent:m,valueExtent:x,extentPadding:b,categoryAccessor:k,colors:w,radius:E,fill:A,opacity:M,stroke:S,strokeWidth:P,background:_,tooltipContent:L,tooltip:C,onHover:D,annotations:T,svgAnnotationRules:W,tickFormatTime:$,tickFormatValue:N,linkedHover:O,selection:z,onObservation:I,chartId:R,loading:B,emptyContent:j,emphasis:F,legendPosition:Y}=e,H=l.showAxes,X=l.enableHover,G=null!=c?c:l.marginDefaults,q=null!=s?s:[l.width,l.height],V=null!=L?L:C,K=t.useRef(null),{customHoverBehavior:Z}=jn({selection:z,linkedHover:O,unwrapData:!0,onObservation:I,chartType:"RealtimeSwarmChart",chartId:R}),U=t.useCallback(t=>{D&&D(t),Z(t)},[D,Z]);t.useImperativeHandle(n,()=>({push:t=>{var e;return null===(e=K.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=K.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=K.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=K.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const Q=qn(B,q[0],q[1]);if(Q)return Q;const J=Gn(y,q[0],q[1],j);if(J)return J;const tt={};return null!=E&&(tt.radius=E),null!=A&&(tt.fill=A),null!=M&&(tt.opacity=M),null!=S&&(tt.stroke=S),null!=P&&(tt.strokeWidth=P),g.createElement(te,{ref:K,chartType:"swarm",runtimeMode:"streaming",size:q,margin:G,className:F?`${u||""} semiotic-emphasis-${F}`.trim():u,arrowOfTime:h,windowMode:d,windowSize:f,data:y,timeAccessor:p,valueAccessor:v,xExtent:m,yExtent:x,extentPadding:b,categoryAccessor:k,barColors:w,swarmStyle:tt,showAxes:H,background:_,hoverAnnotation:X,tooltipContent:V,customHoverBehavior:U,annotations:T,svgAnnotationRules:W,tickFormatTime:$,tickFormatValue:N,legendPosition:Y})});Un.displayName="RealtimeSwarmChart";const Qn=t.forwardRef(function(e,n){var i,r,o,a;const l=Yn(e.mode,{width:null!==(r=null===(i=e.size)||void 0===i?void 0:i[0])&&void 0!==r?r:e.width,height:null!==(a=null===(o=e.size)||void 0===o?void 0:o[1])&&void 0!==a?a:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{size:s,margin:c,className:u,arrowOfTime:h="right",windowMode:d="sliding",windowSize:f=200,data:y,timeAccessor:p,valueAccessor:v,timeExtent:m,valueExtent:x,extentPadding:b,positiveColor:k,negativeColor:w,connectorStroke:E,connectorWidth:A,gap:M,stroke:S,strokeWidth:P,background:_,tooltipContent:L,tooltip:C,onHover:D,annotations:T,svgAnnotationRules:W,tickFormatTime:$,tickFormatValue:N,linkedHover:O,selection:z,onObservation:I,chartId:R,loading:B,emptyContent:j,emphasis:F,legendPosition:Y}=e,H=l.showAxes,X=l.enableHover,G=null!=c?c:l.marginDefaults,q=null!=s?s:[l.width,l.height],V=null!=L?L:C,K=t.useRef(null),{customHoverBehavior:Z}=jn({selection:z,linkedHover:O,unwrapData:!0,onObservation:I,chartType:"RealtimeWaterfallChart",chartId:R}),U=t.useCallback(t=>{D&&D(t),Z(t)},[D,Z]);t.useImperativeHandle(n,()=>({push:t=>{var e;return null===(e=K.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=K.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=K.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=K.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const Q=qn(B,q[0],q[1]);if(Q)return Q;const J=Gn(y,q[0],q[1],j);if(J)return J;const tt={};return null!=k&&(tt.positiveColor=k),null!=w&&(tt.negativeColor=w),null!=E&&(tt.connectorStroke=E),null!=A&&(tt.connectorWidth=A),null!=M&&(tt.gap=M),null!=S&&(tt.stroke=S),null!=P&&(tt.strokeWidth=P),g.createElement(te,{ref:K,chartType:"waterfall",runtimeMode:"streaming",size:q,margin:G,className:F?`${u||""} semiotic-emphasis-${F}`.trim():u,arrowOfTime:h,windowMode:d,windowSize:f,data:y,timeAccessor:p,valueAccessor:v,xExtent:m,yExtent:x,extentPadding:b,waterfallStyle:tt,showAxes:H,background:_,hoverAnnotation:X,tooltipContent:V,customHoverBehavior:U,annotations:T,svgAnnotationRules:W,tickFormatTime:$,tickFormatValue:N,legendPosition:Y})});Qn.displayName="RealtimeWaterfallChart";const Jn=t.forwardRef(function(e,n){var i,r,o,a;const l=Yn(e.mode,{width:null!==(r=null===(i=e.size)||void 0===i?void 0:i[0])&&void 0!==r?r:e.width,height:null!==(a=null===(o=e.size)||void 0===o?void 0:o[1])&&void 0!==a?a:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{size:s,margin:c,className:u,arrowOfTime:h="right",windowMode:d="sliding",windowSize:f=200,data:y,timeAccessor:p,valueAccessor:v,categoryAccessor:m,timeExtent:x,valueExtent:b,extentPadding:k,heatmapXBins:w=20,heatmapYBins:E=20,aggregation:A="count",background:M,tooltipContent:S,tooltip:P,onHover:_,annotations:L,svgAnnotationRules:C,tickFormatTime:D,tickFormatValue:T,decay:W,pulse:$,staleness:N,linkedHover:O,selection:z,onObservation:I,chartId:R,loading:B,emptyContent:j,emphasis:F,legendPosition:Y}=e,H=l.showAxes,X=l.enableHover,G=null!=c?c:l.marginDefaults,q=null!=s?s:[l.width,l.height],V=null!=S?S:P,K=t.useRef(null),{customHoverBehavior:Z}=jn({selection:z,linkedHover:O,unwrapData:!0,onObservation:I,chartType:"RealtimeHeatmap",chartId:R}),U=t.useCallback(t=>{_&&_(t),Z(t)},[_,Z]);t.useImperativeHandle(n,()=>({push:t=>{var e;return null===(e=K.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=K.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=K.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=K.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const Q=qn(B,q[0],q[1]);if(Q)return Q;const J=Gn(y,q[0],q[1],j);return J||g.createElement(te,{ref:K,chartType:"heatmap",runtimeMode:"streaming",size:q,margin:G,className:F?`${u||""} semiotic-emphasis-${F}`.trim():u,arrowOfTime:h,windowMode:d,windowSize:f,data:y,timeAccessor:p,valueAccessor:v,categoryAccessor:m,xExtent:x,yExtent:b,extentPadding:k,heatmapXBins:w,heatmapYBins:E,heatmapAggregation:A,showAxes:H,background:M,hoverAnnotation:X,tooltipContent:V,customHoverBehavior:U,annotations:L,svgAnnotationRules:C,tickFormatTime:D,tickFormatValue:T,decay:W,pulse:$,staleness:N,legendPosition:Y})});Jn.displayName="RealtimeHeatmap",exports.IncrementalExtent=x,exports.RealtimeHeatmap=Jn,exports.RealtimeHistogram=Zn,exports.RealtimeLineChart=Vn,exports.RealtimeSwarmChart=Un,exports.RealtimeWaterfallChart=Qn,exports.RingBuffer=m,exports.StreamNetworkFrame=Wn,exports.StreamXYFrame=te;
1
+ "use strict";const t=require("react"),e=require("d3-brush"),n=require("d3-selection"),i=require("d3-scale"),r=require("d3-scale-chromatic"),o=require("d3-quadtree"),a=require("d3-array"),l=require("d3-hierarchy"),s=require("d3-shape"),c=require("regression"),u=require("d3-interpolate"),h=require("d3-force"),d=require("d3-chord");function f(t){return t&&t.__esModule?t:{default:t}}function y(t){if(t&&t.__esModule)return t;const e=Object.create(null);if(t)for(const n in t)if("default"!==n){const i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,i.get?i:{enumerable:!0,get:function(){return t[n]}})}return e.default=t,Object.freeze(e)}const g=y(t),p=f(c);class v{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 m{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 x{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 b(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 k(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 w(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 E(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 A(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 M(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 S(t,e){if("function"==typeof t)return e=>+t(e);const n=t||e;return t=>+t[n]}function P(t,e){if("function"==typeof t)return t;const n=t||e;return t=>t[n]}function _(t,e){return"function"==typeof t?t:t?e=>e[t]+"":void 0}const L=r.schemeCategory10,C=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];function D(t,e="ease-out-cubic"){return"linear"===e?t:1-Math.pow(1-t,3)}function T(t,e){return Math.min((t-e.startTime)/e.duration,1)}function W(t,e,n){return t+(e-t)*n}class ${constructor(t){this.xExtent=new x,this.yExtent=new x,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 m(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=S(t.timeAccessor||t.xAccessor,"time"),this.getY=S(t.valueAccessor||t.yAccessor,"value")):(this.getX=S(t.xAccessor,"x"),this.getY=S(t.yAccessor,"y")),this.getGroup=_(t.groupAccessor),this.getCategory=_(t.categoryAccessor),this.getSize=t.sizeAccessor?S(t.sizeAccessor,"size"):void 0,this.getColor=_(t.colorAccessor),this.getBounds=t.boundsAccessor?S(t.boundsAccessor,"bounds"):void 0,this.getY0=t.y0Accessor?S(t.y0Accessor,"y0"):void 0,this.getPointId=_(t.pointIdAccessor),"candlestick"===t.chartType&&(this.getOpen=S(t.openAccessor,"open"),this.getHigh=S(t.highAccessor,"high"),this.getLow=S(t.lowAccessor,"low"),this.getClose=S(t.closeAccessor,"close")),t.pulse&&(this.timestampBuffer=new m(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,r,o,a,l;const{config:s,buffer:c}=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(c,this.getX),this.yExtent.dirty)if("candlestick"===s.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const t of c)this.yExtent.push(this.getHigh(t)),this.yExtent.push(this.getLow(t))}else this.yExtent.recalculate(c,this.getY);const u=this.getBufferArray(),h=this.xExtent.extent,d=this.yExtent.extent;let f=s.xExtent?[null!==(e=s.xExtent[0])&&void 0!==e?e:h[0],null!==(n=s.xExtent[1])&&void 0!==n?n:h[1]]:h,y=s.yExtent?[null!==(r=s.yExtent[0])&&void 0!==r?r:d[0],null!==(o=s.yExtent[1])&&void 0!==o?o:d[1]]:d;const g=s.yExtent&&null!=s.yExtent[0]&&null!=s.yExtent[1];if("stackedarea"===s.chartType&&!g&&c.size>0)if(s.normalize)y=[0,1+s.extentPadding];else{const t=`${c.size}:${this._ingestVersion}`;if(this._stackExtentCache&&this._stackExtentCache.key===t)y=this._stackExtentCache.yDomain;else{const e=this.groupData(u),n=new Map;for(const t of e)for(const e of t.data){const t=this.getX(e),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);y=[0,i+(i>0?i*s.extentPadding:1)],this._stackExtentCache={key:t,yDomain:y}}}else if("bar"===s.chartType&&s.binSize&&!g&&c.size>0){const[,t]=function(t,e,n,i,r){const o=b(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]}(c,this.getX,this.getY,s.binSize,this.getCategory);y=[0,t+t*s.extentPadding]}else if("waterfall"===s.chartType&&!g&&c.size>0){const[t,e]=function(t,e){let n=0,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]}(c,this.getY),n=e-t,i=n>0?n*s.extentPadding:1;y=[Math.min(0,t-Math.abs(i)),Math.max(0,e+Math.abs(i))]}else if(!g&&y[0]!==1/0){if(this.getBounds)for(const t of u){const e=this.getY(t),n=this.getBounds(t);null!=e&&!Number.isNaN(e)&&n&&(e+n>y[1]&&(y[1]=e+n),y[0]>e-n&&(y[0]=e-n))}const t=y[1]-y[0],e=t>0?t*s.extentPadding:1,n=null===(a=s.yExtent)||void 0===a?void 0:a[0],i=null===(l=s.yExtent)||void 0===l?void 0:l[1];y=[null!=n?y[0]:y[0]-e,null!=i?y[1]:y[1]+e],"log"===s.yScaleType&&0>=y[0]&&d[0]>0&&(y[0]=null!=n?y[0]:d[0]/(1+s.extentPadding))}if(f[0]!==1/0&&f[1]!==-1/0||(f=[0,1]),y[0]!==1/0&&y[1]!==-1/0||(y=[0,1]),"streaming"===s.runtimeMode)if("x"==("up"===(p=s.arrowOfTime)||"down"===p?"y":"x")){const e="right"===s.arrowOfTime?[0,t.width]:[t.width,0];this.scales={x:i.scaleLinear().domain(f).range(e),y:i.scaleLinear().domain(y).range([t.height,0])}}else{const e="down"===s.arrowOfTime?[0,t.height]:[t.height,0];this.scales={x:i.scaleLinear().domain(y).range([0,t.width]),y:i.scaleLinear().domain(f).range(e)}}else{const e=(t,e,n)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return i.scaleLog().domain(t).range(n).clamp(!0)}return i.scaleLinear().domain(e).range(n)};this.scales={x:e(s.xScaleType,f,[0,t.width]),y:e(s.yScaleType,y,[t.height,0])}}var p;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(t,u),this.config.decay&&this.applyDecay(this.scene,u),this.config.pulse&&this.applyPulse(this.scene,u),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.rebuildQuadtree(),this.needsFullRebuild=!1,this.lastLayout={width:t.width,height:t.height},this.version++}rebuildQuadtree(){const t=this.config.chartType;if("scatter"!==t&&"bubble"!==t)return void(this._quadtree=null);const e=this.scene.filter(t=>"point"===t.type);this._quadtree=e.length>$.QUADTREE_THRESHOLD?o.quadtree().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 r=this.scales.x.domain(),o=this.scales.y.domain(),a=this.scales.x.range(),l=this.scales.y.range(),s=(t,e,n)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return i.scaleLog().domain(t).range(n).clamp(!0)}return i.scaleLinear().domain(e).range(n)};this.scales={x:s(this.config.xScaleType,r,[a[0]*e,a[1]*e]),y:s(this.config.yScaleType,o,[l[0]*n,l[1]*n])},this.lastLayout={width:t.width,height:t.height},this.rebuildQuadtree(),this.version++}buildSceneNodes(t,e){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=k(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=w(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=E(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 o=S(this.config.valueAccessor,"value"),a=P(this.config.xAccessor,"x"),l=P(this.config.yAccessor,"y"),s=new Set,c=new Set;for(const e of t)s.add(a(e)),c.add(l(e));const u=Array.from(s),h=Array.from(c),d=u.every(t=>"number"==typeof t&&!isNaN(t)),f=h.every(t=>"number"==typeof t&&!isNaN(t)),y=d?u.sort((t,e)=>t-e):u,g=f?h.sort((t,e)=>t-e):h;if(0===y.length||0===g.length)return n;const p=e.width/y.length,v=e.height/g.length,m=new Map;for(const e of t){const t=`${a(e)}\0${l(e)}`;m.set(t,{val:o(e),datum:e})}let x=1/0,b=-1/0;for(const{val:t}of m.values())x>t&&(x=t),t>b&&(b=t);const k=i.scaleSequential({blues:r.interpolateBlues,reds:r.interpolateReds,greens:r.interpolateGreens,viridis:r.interpolateViridis}["string"==typeof this.config.colorScheme?this.config.colorScheme:"blues"]||r.interpolateBlues).domain([x,b]);for(let t=0;y.length>t;t++)for(let e=0;g.length>e;e++){const i=m.get(`${y[t]}\0${g[e]}`);if(!i)continue;const r=k(i.val);n.push(M(t*p,(g.length-1-e)*v,p,v,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=S(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(M(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=b(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(A(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(A(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(A(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 S=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 P=!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]];P=!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]];P=!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}),P=!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,P=!0)}else p._targetOpacity=null!==(o=p.style.opacity)&&void 0!==o?o:1,p.style=Object.assign(Object.assign({},p.style),{opacity:0}),P=!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,P=!0)}else p._targetOpacity=null!==(c=p.style.opacity)&&void 0!==c?c:1,p.style=Object.assign(Object.assign({},p.style),{opacity:0}),P=!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,P=!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}),P=!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),P=!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),P=!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)}P=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),P&&(this.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:S})}advanceTransition(t){var e,n,i,r,o,a;if(!this.activeTransition)return!1;const l=T(t,this.activeTransition),s=D(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=W(r,t._targetOpacity,s)}if(void 0===t._targetX)continue;if(!e)continue;const i=this.prevPositionMap.get(e);if(!i)continue;t.x=W(i.x,t._targetX,s),t.y=W(i.y,t._targetY,s),void 0!==t._targetR&&void 0!==i.r&&(t.r=W(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=W(r,t._targetOpacity,s)}if(void 0===t._targetX)continue;if(!e)continue;const n=this.prevPositionMap.get(e);if(!n)continue;t.x=W(n.x,t._targetX,s),t.y=W(n.y,t._targetY,s),void 0!==n.w&&(t.w=W(n.w,t._targetW,s)),void 0!==n.h&&(t.h=W(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:W(i,t._targetOpacity,s)})}if(void 0===t._targetX)continue;if(!e)continue;const n=this.prevPositionMap.get(e);if(!n)continue;t.x=W(n.x,t._targetX,s),t.y=W(n.y,t._targetY,s),void 0!==n.w&&(t.w=W(n.w,t._targetW,s)),void 0!==n.h&&(t.h=W(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:W(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]=W(e[i][0],n[i][0],s),t.path[i][1]=W(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:W(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]=W(e[n][0],i[n][0],s),t.topPath[n][1]=W(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]=W(n[e][0],r[e][0],s),t.bottomPath[e][1]=W(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:C,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:C,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=S(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=S(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=S(this.config.xAccessor,"x"),this.getY=S(this.config.yAccessor,"y"))),void 0!==t.groupAccessor&&(this.getGroup=_(this.config.groupAccessor)),void 0!==t.categoryAccessor&&(this.getCategory=_(this.config.categoryAccessor)),void 0!==t.sizeAccessor&&(this.getSize=this.config.sizeAccessor?S(this.config.sizeAccessor,"size"):void 0),void 0!==t.colorAccessor&&(this.getColor=_(this.config.colorAccessor)),void 0!==t.y0Accessor&&(this.getY0=this.config.y0Accessor?S(this.config.y0Accessor,"y0"):void 0),void 0!==t.pointIdAccessor&&(this.getPointId=_(this.config.pointIdAccessor)),this.needsFullRebuild=!0}}function N(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 O(t){let e=t%(2*Math.PI);return 0>e&&(e+=2*Math.PI),e}function z(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 I(t,e,n){var i,r,o,a;if(0===t.path.length)return null;const l=H(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=R(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 R(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 B(t,e,n){const i=N(e,n,t);return i.hit?{node:t,datum:t.datum,x:i.cx,y:i.cy,distance:0}:null}function j(t,e,n){const i=N(e,n,t);return i.hit?{node:t,datum:t.datum,x:i.cx,y:i.cy,distance:0}:null}function F(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 Y(t,e,n){if(0===t.topPath.length)return null;const i=H(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 H(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 X(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 G(e,n,i){const r=t.useRef(null),[o,a]=t.useState(null);return t.useEffect(()=>{if(!n&&!i)return;const t=r.current;if(!t)return;const e=new ResizeObserver(t=>{for(const e of t){const{width:t,height:n}=e.contentRect;a(e=>e&&e.w===t&&e.h===n?e:{w:t,h:n})}});return e.observe(t),()=>e.disconnect()},[n,i]),[r,[n&&o?o.w:e[0],i&&o?o.h:e[1]]]}function q(e,n,i,r,o,a){t.useEffect(()=>{if(!e)return;const t=setInterval(()=>{var t;const l=n.current;if(!l||0===l.lastIngestTime)return;const s="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(t=e.threshold)&&void 0!==t?t:5e3,u=s-l.lastIngestTime>c;u!==o&&(a(u),i.current=!0,r())},1e3);return()=>clearInterval(t)},[e,o,r])}$.QUADTREE_THRESHOLD=500;const V={fill:t=>g.createElement("rect",{style:t,width:16,height:16}),line:t=>g.createElement("line",{style:t,x1:0,y1:0,x2:16,y2:16})};function K(t,e,n,i){let r;return r="function"==typeof n?n(t):(0,V[n])(i(t,e)),r}function Z(){return g.createElement("path",{d:"M4,8.8 L7.2,12 L12.8,4.8",fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function U(t,e,n){return n&&n.size>0?n.has(t.label)?1:.3:null!=e?t.label===e?1:.3:1}function Q({config:t,orientation:e="vertical",width:n=100}){const{colorFn:i,domain:r,label:o,format:a}=t,l=a||(t=>Math.round(100*t)/100+""),s="grad-legend-"+g.useId();if("horizontal"===e){const t=12,e=Math.min(n,200),a=Math.max(0,(n-e)/2),c=[];for(let t=0;64>=t;t++){const e=t/64;c.push(g.createElement("stop",{key:t,offset:100*e+"%",stopColor:i(r[0]+e*(r[1]-r[0]))}))}return g.createElement("g",{"aria-label":o||"Gradient legend"},g.createElement("defs",null,g.createElement("linearGradient",{id:s,x1:"0%",y1:"0%",x2:"100%",y2:"0%"},c)),o&&g.createElement("text",{x:a+e/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},o),g.createElement("rect",{x:a,y:0,width:e,height:t,fill:`url(#${s})`,rx:2}),g.createElement("text",{x:a,y:t+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},l(r[0])),g.createElement("text",{x:a+e,y:t+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},l(r[1])))}const c=[];for(let t=0;64>=t;t++){const e=t/64;c.push(g.createElement("stop",{key:t,offset:100*e+"%",stopColor:i(r[1]-e*(r[1]-r[0]))}))}return g.createElement("g",{"aria-label":o||"Gradient legend"},o&&g.createElement("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},o),g.createElement("defs",null,g.createElement("linearGradient",{id:s,x1:"0%",y1:"0%",x2:"0%",y2:"100%"},c)),g.createElement("rect",{x:0,y:0,width:14,height:100,fill:`url(#${s})`,rx:2}),g.createElement("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},l(r[1])),g.createElement("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},l(r[0])))}function J(t){const{legendGroups:e,customClickBehavior:n,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:o,legendInteraction:a,title:l="Legend",width:s=100,height:c=20,orientation:u="vertical"}=t,[h,d]=g.useState(0),[f,y]=g.useState(0),p=g.useCallback((t,e)=>{d(t),y(e)},[]),v="vertical"===u?(({legendGroups:t,width:e,customClickBehavior:n,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:o,focusedGroupIndex:a,focusedItemIndex:l,onFocusedIndexChange:s,legendInteraction:c})=>{let u=24;const h=[];return t.forEach((t,d)=>{u+=5,h.push(g.createElement("line",{key:"legend-top-line legend-symbol-"+d,stroke:"gray",x1:0,y1:u,x2:e,y2:u})),u+=8,t.label&&(u+=16,h.push(g.createElement("text",{key:"legend-text-"+d,y:u,className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},t.label)),u+=8),h.push(g.createElement("g",{key:"legend-group-"+d,className:"legend-item",transform:`translate(0,${u})`},((t,e,n,i,r,o,a,l,s,c)=>{const{type:u="fill",styleFn:h,items:d}=t,f=[];let y=0;const p=!(!e&&!n),v="isolate"===c||void 0===c&&null!=r;return d.forEach((t,c)=>{const m=K(t,c,u,h),x=U(t,i,r),b=r&&r.size>0&&r.has(t.label);f.push(g.createElement("g",{key:"legend-item-"+c,transform:`translate(0,${y})`,onClick:e?()=>e(t):void 0,onMouseEnter:n?()=>n(t):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:p?l===o&&c===a?0:-1:void 0,role:p?"option":void 0,"aria-selected":p&&v?b||!1:void 0,"aria-current":p&&!v&&null!=i&&t.label===i||void 0,"aria-label":t.label,onKeyDown:p?n=>{var i;if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),e&&e(t)),"ArrowDown"===n.key||"ArrowUp"===n.key){n.preventDefault();const t=(c+("ArrowDown"===n.key?1:-1)+d.length)%d.length;s(l,t);const e=null===(i=n.currentTarget.parentElement)||void 0===i?void 0:i.children[t];e instanceof SVGElement&&e.focus()}}:void 0,onFocus:p?e=>{s(l,c),n&&n(t);const i=e.currentTarget.querySelector(".semiotic-legend-focus-ring");i&&i.setAttribute("visibility","visible")}:void 0,onBlur:p?t=>{n&&n(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&&g.createElement("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*t.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),m,b&&g.createElement(Z,null),g.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},t.label))),y+=22}),f})(t,n,i,r,o,a,l,d,s,c))),u+=22*t.items.length+8}),h})({legendGroups:e||[],width:s,customClickBehavior:n,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:o,focusedGroupIndex:h,focusedItemIndex:f,onFocusedIndexChange:p,legendInteraction:a}):(({legendGroups:t,height:e,width:n,customClickBehavior:i,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:a,focusedGroupIndex:l,focusedItemIndex:s,onFocusedIndexChange:c,legendInteraction:u})=>{let h=0;const d=[];t.forEach((t,e)=>{let n=0;t.label&&(n+=16);const f=((t,e,n,i,r,o,a,l,s,c)=>{const{type:u="fill",styleFn:h,items:d}=t,f=[];let y=0;const p=!(!e&&!n),v="isolate"===c||void 0===c&&null!=r;return d.forEach((t,c)=>{const m=K(t,c,u,h),x=U(t,i,r),b=r&&r.size>0&&r.has(t.label);f.push(g.createElement("g",{key:"legend-item-"+c,transform:`translate(${y},0)`,onClick:e?()=>e(t):void 0,onMouseEnter:n?()=>n(t):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:p?l===o&&c===a?0:-1:void 0,role:p?"option":void 0,"aria-selected":p&&v?b||!1:void 0,"aria-current":p&&!v&&null!=i&&t.label===i||void 0,"aria-label":t.label,onKeyDown:p?n=>{var i;if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),e&&e(t)),"ArrowRight"===n.key||"ArrowLeft"===n.key){n.preventDefault();const t=(c+("ArrowRight"===n.key?1:-1)+d.length)%d.length;s(l,t);const e=null===(i=n.currentTarget.parentElement)||void 0===i?void 0:i.children[t];e instanceof SVGElement&&e.focus()}}:void 0,onFocus:p?e=>{s(l,c),n&&n(t);const i=e.currentTarget.querySelector(".semiotic-legend-focus-ring");i&&i.setAttribute("visibility","visible")}:void 0,onBlur:p?t=>{n&&n(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&&g.createElement("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*t.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),m,b&&g.createElement(Z,null),g.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},t.label))),y+=26+7*t.label.length}),{items:f,offset:y}})(t,i,r,o,a,l,s,e,c,u);n+=f.offset+5,d.push(Object.assign(Object.assign({label:t.label},f),{offset:n})),h+=n+12});let f=Math.max(0,(n-h)/2);const y=[];return d.forEach((n,i)=>{const r=t[i];r.label&&(y.push(g.createElement("text",{key:"legend-text-"+i,transform:`translate(${f},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},r.label)),f+=16),y.push(g.createElement("g",{key:"legend-group-"+i,className:"legend-item",transform:`translate(${f},0)`},n.items)),f+=n.offset+5,t[i+1]&&y.push(g.createElement("line",{key:"legend-top-line legend-symbol-"+i,stroke:"gray",x1:f,y1:-8,x2:f,y2:e+0+8})),f+=12}),g.createElement("g",null,y)})({legendGroups:e||[],title:l,height:c,width:s,customClickBehavior:n,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:o,focusedGroupIndex:h,focusedItemIndex:f,onFocusedIndexChange:p,legendInteraction:a}),m=!(!n&&!i);return g.createElement("g",{role:m?"listbox":void 0,"aria-multiselectable":!(!m||"isolate"!==a&&(void 0!==a||null==o))||void 0,"aria-label":"Chart legend"},void 0!==l&&""!==l&&"vertical"===u&&g.createElement("text",{className:"legend-title",y:16,x:s/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)"},l),v)}function tt(t){const{legend:e,totalWidth:n,totalHeight:i,margin:r,legendPosition:o="right",title:a,legendHoverBehavior:l,legendClickBehavior:s,legendHighlightedCategory:c,legendIsolatedCategories:u,legendInteraction:h}=t;if(!e)return null;const d="top"===o||"bottom"===o;let f,y;return"left"===o?(f=4,y=r.top):"top"===o?(f=0,y=a?32:8):"bottom"===o?(f=0,y=i-r.bottom+50):(f=n-r.right+10,y=r.top),g.createElement("g",{transform:`translate(${f}, ${y})`},function(t){return"object"==typeof t&&null!==t&&"gradient"in t}(e)?g.createElement(Q,{config:e.gradient,orientation:d?"horizontal":"vertical",width:d?n:100}):function(t){return"object"==typeof t&&null!==t&&"legendGroups"in t}(e)?g.createElement(J,{legendGroups:e.legendGroups,title:"",width:d?n:100,orientation:d?"horizontal":"vertical",customHoverBehavior:l,customClickBehavior:s,highlightedCategory:c,isolatedCategories:u,legendInteraction:h}):e)}function et(t){return"string"==typeof t?{type:t}:t}function nt({orient:e,config:n,values:i,scale:r,size:o,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=t.useMemo(()=>{if(0===i.length)return null;const t=r.domain(),n=o-8;if("boxplot"===s.type){const t=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(!t)return null;const{q1:o,median:a,q3:l,whiskerLow:u,whiskerHigh:h}=t,d=Math.min(.5*n,20),f=(n-d)/2+4;if(c){const t=r(o),n=r(l),i=r(a),c=r(u),y=r(h),p="top"===e?-1:1,v=0;return g.createElement("g",{"data-testid":"marginal-boxplot-"+e},g.createElement("line",{x1:c,y1:v+p*(f+d/2),x2:y,y2:v+p*(f+d/2),stroke:s.fill,strokeWidth:s.strokeWidth}),g.createElement("line",{x1:c,y1:v+p*f,x2:c,y2:v+p*(f+d),stroke:s.fill,strokeWidth:s.strokeWidth}),g.createElement("line",{x1:y,y1:v+p*f,x2:y,y2:v+p*(f+d),stroke:s.fill,strokeWidth:s.strokeWidth}),g.createElement("rect",{x:Math.min(t,n),y:"top"===e?v-f-d:v+f,width:Math.abs(n-t),height:d,fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),g.createElement("line",{x1:i,y1:"top"===e?v-f-d:v+f,x2:i,y2:"top"===e?v-f:v+f+d,stroke:s.fill,strokeWidth:2}))}{const t=r(o),n=r(l),i=r(a),c=r(u),y=r(h),p="left"===e?-1:1,v=0;return g.createElement("g",{"data-testid":"marginal-boxplot-"+e},g.createElement("line",{x1:v+p*(f+d/2),y1:c,x2:v+p*(f+d/2),y2:y,stroke:s.fill,strokeWidth:s.strokeWidth}),g.createElement("line",{x1:v+p*f,y1:c,x2:v+p*(f+d),y2:c,stroke:s.fill,strokeWidth:s.strokeWidth}),g.createElement("line",{x1:v+p*f,y1:y,x2:v+p*(f+d),y2:y,stroke:s.fill,strokeWidth:s.strokeWidth}),g.createElement("rect",{x:"left"===e?v-f-d:v+f,y:Math.min(t,n),width:d,height:Math.abs(n-t),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),g.createElement("line",{x1:"left"===e?v-f-d:v+f,y1:i,x2:"left"===e?v-f:v+f+d,y2:i,stroke:s.fill,strokeWidth:2}))}}const u=a.bin().domain(t).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 g.createElement("g",{"data-testid":"marginal-histogram-"+e},u.map((t,i)=>{if(null==t.x0||null==t.x1)return null;const o=t.length/h*n;if(c){const n=r(t.x0),a=r(t.x1)-r(t.x0);return g.createElement("rect",{key:i,x:n,y:"top"===e?-4-o:4,width:Math.max(a,.5),height:o,fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth})}{const n=r(t.x0),a=r(t.x1)-r(t.x0);return g.createElement("rect",{key:i,x:"left"===e?-4-o:4,y:Math.min(n,n+a),width:o,height:Math.abs(a),fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth})}}));if("violin"===s.type){const t=n/2+4,i=[];for(const o of u){if(null==o.x0||null==o.x1)continue;const a=o.length/h*(n/2),l=r((o.x0+o.x1)/2);i.push(c?`${l},${"top"===e?-(t-a):t-a}`:`${"left"===e?-(t-a):t-a},${l}`)}for(let o=u.length-1;o>=0;o--){const a=u[o];if(null==a.x0||null==a.x1)continue;const l=a.length/h*(n/2),s=r((a.x0+a.x1)/2);i.push(c?`${s},${"top"===e?-(t+l):t+l}`:`${"left"===e?-(t+l):t+l},${s}`)}return g.createElement("g",{"data-testid":"marginal-violin-"+e},g.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 t=[];if(c){const i=0,o=null!=u[0].x0?r(u[0].x0):0;t.push(`M${o},${i}`);for(const i of u){if(null==i.x0||null==i.x1)continue;const o=i.length/h*n,a=r((i.x0+i.x1)/2);t.push(`L${a},${"top"===e?-o-4:o+4}`)}const a=null!=u[u.length-1].x1?r(u[u.length-1].x1):l;t.push(`L${a},${i}`),t.push("Z")}else{const i=0,o=null!=u[0].x0?r(u[0].x0):0;t.push(`M${i},${o}`);for(const i of u){if(null==i.x0||null==i.x1)continue;const o=i.length/h*n,a=r((i.x0+i.x1)/2);t.push(`L${"left"===e?-o-4:o+4},${a}`)}const a=null!=u[u.length-1].x1?r(u[u.length-1].x1):l;t.push(`L${i},${a}`),t.push("Z")}return g.createElement("g",{"data-testid":"marginal-ridgeline-"+e},g.createElement("path",{d:t.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}))}return null},[i,r,s,o,l,e,c,4]);return u?g.createElement("g",{className:"marginal-"+e,"data-testid":"marginal-"+e},u):null}function it(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 rt(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 ot(t){const{x:e=0,y:n=0,dx:i,dy:r,nx:o,ny:a,note:l,connector:s,subject:c,type:u,color:h,className:d,disable:f,events:y={},"data-testid":p}=t,v=new Set(Array.isArray(f)?f:[]);let m=i||0,x=r||0;null!=o&&(m=o-e),null!=a&&(x=a-n);const b="string"==typeof u?u:"label";if("bracket"===b&&c&&0===m&&0===x)if(void 0!==c.width){m=c.width/2;const t=c.depth||30;x=t+(0>t?-5:5)}else if(void 0!==c.height){const t=c.depth||30;m=t+(0>t?-5:5),x=c.height/2}return g.createElement("g",Object.assign({className:("annotation "+(d||"")).trim(),transform:`translate(${e},${n})`,"data-testid":p},y),!v.has("connector")&&function(t,e,n,i,r,o){const a=[];let l=0,s=0;if("callout-circle"!==r&&"label"!==r||!(null==o?void 0:o.radius)){if("callout-rect"===r&&o){const n=o.width||0,i=o.height||0;if(n>0||i>0){const r=n/2,o=i/2,a=t-r,c=e-o;if(0!==a||0!==c){const t=Math.abs(a),e=Math.abs(c),u=n/2,h=i/2,d=t*h>e*u?u/t:h/e;l=r+a*d,s=o+c*d}}}else if("bracket"===r&&o){const t=o.width,e=o.height,n=o.depth||30;void 0!==t?(l=t/2,s=n):void 0!==e&&(l=n,s=e/2)}}else{const n=(o.radius||0)+(o.radiusPadding||0);if(n>0&&(0!==t||0!==e)){const i=Math.atan2(e,t);l=Math.cos(i)*n,s=Math.sin(i)*n}}if(Math.sqrt(Math.pow(t-l,2)+Math.pow(e-s,2))>.5&&(a.push(g.createElement("line",{key:"connector-line",x1:l,y1:s,x2:t,y2:e,stroke:i||"currentColor"})),"arrow"===(null==n?void 0:n.end))){const n=10,r=16/180*Math.PI,o=Math.atan2(e-s,t-l);a.push(g.createElement("path",{key:"connector-arrow",d:`M${l},${s}L${l+n*Math.cos(o+r)},${s+n*Math.sin(o+r)}L${l+n*Math.cos(o-r)},${s+n*Math.sin(o-r)}Z`,fill:i||"currentColor",stroke:"none"}))}return g.createElement("g",{className:"annotation-connector"},a)}(m,x,s,h,b,c),!v.has("subject")&&function(t,e,n,i,r){var o;const a=[];switch(t){case"callout-circle":{const t=((null==e?void 0:e.radius)||0)+((null==e?void 0:e.radiusPadding)||0);t>0&&a.push(g.createElement("circle",{key:"subject-circle",r:t,fill:"none",stroke:n||"currentColor"}));break}case"callout-rect":{const t=(null==e?void 0:e.width)||0,i=(null==e?void 0:e.height)||0;(t>0||i>0)&&a.push(g.createElement("rect",{key:"subject-rect",width:t,height:i,fill:"none",stroke:n||"currentColor"}));break}case"callout-custom":(null==e?void 0:e.custom)&&a.push(...Array.isArray(e.custom)?e.custom:[e.custom]);break;case"xy-threshold":{const t=i||0,o=r||0;if(void 0!==(null==e?void 0:e.x)){const i=(e.x||0)-t;a.push(g.createElement("line",{key:"threshold-line",x1:i,y1:(e.y1||0)-o,x2:i,y2:(e.y2||0)-o,stroke:n||"currentColor",strokeDasharray:"5,5"}))}else if(void 0!==(null==e?void 0:e.y)){const i=(e.y||0)-o;a.push(g.createElement("line",{key:"threshold-line",x1:(e.x1||0)-t,y1:i,x2:(e.x2||0)-t,y2:i,stroke:n||"currentColor",strokeDasharray:"5,5"}))}else void 0!==(null==e?void 0:e.x1)||void 0!==(null==e?void 0:e.x2)?a.push(g.createElement("line",{key:"threshold-line",x1:(e.x1||0)-t,y1:0,x2:(e.x2||0)-t,y2:0,stroke:n||"currentColor",strokeDasharray:"5,5"})):void 0===(null==e?void 0:e.y1)&&void 0===(null==e?void 0:e.y2)||a.push(g.createElement("line",{key:"threshold-line",x1:0,y1:(e.y1||0)-o,x2:0,y2:(e.y2||0)-o,stroke:n||"currentColor",strokeDasharray:"5,5"}));break}case"bracket":{const t=null!==(o=null==e?void 0:e.width)&&void 0!==o?o:null==e?void 0:e.height;void 0!==t&&a.push(g.createElement("path",{key:"bracket-path",d:rt((null==e?void 0:e.type)||"curly",t,(null==e?void 0:e.depth)||30,void 0===(null==e?void 0:e.width)),fill:"none",stroke:n||"currentColor"}));break}}return g.createElement("g",{className:"annotation-subject"},a)}(b,c,h,e,n),!v.has("note")&&function(t,e,n,i){if(!t)return g.createElement("g",{className:"annotation-note"});const{label:r,title:o,orientation:a,align:l,wrap:s=120,noWrap:c}=t;if(!r&&!o)return g.createElement("g",{className:"annotation-note"});let u=a;u||(u=Math.abs(e)>Math.abs(n)?"leftRight":"topBottom");let h=l;h&&"dynamic"!==h||(h="topBottom"===u?0>e?"right":"left":0>n?"bottom":"top");let d="start";"topBottom"===u?"right"===h?d="end":"middle"===h&&(d="middle"):d=0>e?"end":"start";const f=16,y=o?c?[o]:it(o,s):[],p=r?c?[r]:it(r,s):[],v="leftRight"===u?"end"===d?-4:4:0;let m=0;const x=[];y.length>0&&(x.push(g.createElement("text",{key:"annotation-note-title",className:"annotation-note-title",fill:i||void 0,textAnchor:d,fontWeight:"bold"},y.map((t,e)=>g.createElement("tspan",{key:e,x:v,dy:0===e?0:f},t)))),m=y.length*f),p.length>0&&x.push(g.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:i||void 0,textAnchor:d,y:m},p.map((t,e)=>g.createElement("tspan",{key:e,x:v,dy:0===e?0:f},t))));let b=null;if((o||r)&&(0!==e||0!==n))if("topBottom"===u){const t=Math.min(s,120);let e=0,n=t;"end"===d?(e=-t,n=0):"middle"===d&&(e=-t/2,n=t/2),b=g.createElement("line",{className:"note-line",x1:e,x2:n,y1:0,y2:0,stroke:i||"currentColor"})}else{const t=(y.length+p.length)*f+(p.length>0?f:0);let e=0,n=t;"bottom"===h?(e=-t,n=0):"middle"===h&&(e=-t/2,n=t/2),b=g.createElement("line",{className:"note-line",x1:0,x2:0,y1:e,y2:n,stroke:i||"currentColor"})}const k=Math.max(0,y.length+p.length-1)*f;let w=0;return"topBottom"===u?w=0>n?-(k+2):18:"leftRight"===u&&(w="middle"===h?-(k+f+(p.length>0&&y.length>0?2:0))/2+8:"bottom"===h||0>n?-(k+2):18),g.createElement("g",{className:"annotation-note",transform:`translate(${e},${n})`},g.createElement("g",{className:"annotation-note-content",transform:0!==w?`translate(0,${w})`:void 0},x),b)}(l,m,x,h))}function at(t){var e,n;const{noteData:i}=t,{screenCoordinates:r}=i,o="string"==typeof i.type?i.type:"label",a=i.eventListeners||i.events||{};if(i.coordinates&&r){const t=i.nx||r[0][0]+(null!==(e=i.dx)&&void 0!==e?e:0),a=i.ny||r[0][1]+(null!==(n=i.dy)&&void 0!==n?n:0),l=r.map((e,n)=>{const r=Object.assign({},i,{note:0===n?i.note:{label:""},x:e[0],y:e[1],nx:t,ny:a});return g.createElement(ot,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+n},r,{type:o}))});return g.createElement("g",null,l)}const l=i.note||{title:"none",label:i.label};return g.createElement(ot,Object.assign({"data-testid":"semiotic-annotation",key:`${l.label}-${l.title}-${i.i}`,events:a},i,{type:o}))}const lt={linear:s.curveLinear,monotoneX:s.curveMonotoneX,monotoneY:s.curveMonotoneY,step:s.curveStep,stepAfter:s.curveStepAfter,stepBefore:s.curveStepBefore,basis:s.curveBasis,cardinal:s.curveCardinal,catmullRom:s.curveCatmullRom};function st(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 ct(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 ut(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=st(t,n),c=ct(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 ht(t,e,n,i=50){return!(-i>t||t>(n.width||0)+i||-i>e||e>(n.height||0)+i)}function dt(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 ft(e){const{width:n,height:i,totalWidth:r,totalHeight:o,margin:a,scales:l,showAxes:s,axes:c,showGrid:u,xFormat:h,yFormat:d}=e,f=t.useMemo(()=>{var t;if(!l)return[];const e=null==c?void 0:c.find(t=>"bottom"===t.orient),i=(null==e?void 0:e.tickFormat)||h||yt,r=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5;return l.x.ticks(Math.min(r,Math.max(2,Math.floor(n/70)))).map(t=>({value:t,pixel:l.x(t),label:i(t)}))},[l,c,h,n]),y=t.useMemo(()=>{var t;if(!l)return[];const e=null==c?void 0:c.find(t=>"left"===t.orient),n=(null==e?void 0:e.tickFormat)||d||yt,r=null!==(t=null==e?void 0:e.ticks)&&void 0!==t?t:5;return l.y.ticks(Math.min(r,Math.max(2,Math.floor(i/30)))).map(t=>({value:t,pixel:l.y(t),label:n(t)}))},[l,c,d,i]),p=u&&l,v=s&&l;if(!p&&!v)return null;const m=null==c?void 0:c.find(t=>"bottom"===t.orient),x=null==c?void 0:c.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 g.createElement("svg",{width:r,height:o,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},g.createElement("g",{transform:`translate(${a.left},${a.top})`},p&&g.createElement("g",{className:"stream-grid"},f.map((t,e)=>g.createElement("line",{key:"xgrid-"+e,x1:t.pixel,y1:0,x2:t.pixel,y2:i,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1})),y.map((t,e)=>g.createElement("line",{key:"ygrid-"+e,x1:0,y1:t.pixel,x2:n,y2:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),b&&!w&&g.createElement("line",{x1:0,y1:i,x2:n,y2:i,stroke:A,strokeWidth:1}),w&&g.createElement("path",{d:dt("bottom",n,i),fill:"none",stroke:A,strokeWidth:1}),k&&!E&&g.createElement("line",{x1:0,y1:0,x2:0,y2:i,stroke:A,strokeWidth:1}),E&&g.createElement("path",{d:dt("left",n,i),fill:"none",stroke:A,strokeWidth:1})))}function yt(t){return Math.round(100*t)/100+""}function gt(t,e){return t instanceof Date&&(!(e&&e instanceof Date)||t.getFullYear()!==e.getFullYear()||t.getMonth()!==e.getMonth()||t.getDate()!==e.getDate())}function pt(e){var n,i;const{width:r,height:o,totalWidth:a,totalHeight:c,margin:u,scales:h,showAxes:d,axes:f,xLabel:y,yLabel:v,xFormat:m,yFormat:x,showGrid:b,title:k,legend:w,legendHoverBehavior:E,legendClickBehavior:A,legendHighlightedCategory:M,legendIsolatedCategories:S,legendPosition:P="right",foregroundGraphics:_,marginalGraphics:L,xValues:C,yValues:D,annotations:T,svgAnnotationRules:W,xAccessor:$,yAccessor:N,annotationData:O,pointNodes:z,curve:I,underlayRendered:R,children:B}=e,j=t.useMemo(()=>{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)||m||yt,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(r/70)))).map(t=>({value:t,pixel:h.x(t),label:n(t)}))},[d,h,f,m,r]),F=t.useMemo(()=>{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)||x||yt,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(o/30)))).map(t=>({value:t,pixel:h.y(t),label:n(t)}))},[d,h,f,x,o]),Y=t.useRef(new Map),H=t.useRef(null!==(n=null==T?void 0:T.length)&&void 0!==n?n:0),X=null!==(i=null==T?void 0:T.length)&&void 0!==i?i:0;H.current!==X&&(H.current=X,Y.current=new Map);const G=t.useMemo(()=>{if(!T||0===T.length)return null;const t=function(t,e,n){var i,r,o,a,c,u,h,d,f,y,v,m,x,b,k,w,E,A,M,S,P,_,L,C,D,T,W,$,N,O,z,I,R,B,j,F,Y,H,X,G,q,V,K,Z;switch(t.type){case"label":{const i=ut(t,e,n);if(!i)return null;const{x:r,y:o}=i;return ht(r,o,n)?g.createElement(at,{key:"ann-"+e,noteData:{x:r,y:o,dx:t.dx||30,dy:t.dy||-30,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"label",connector:t.connector||{end:"arrow"},color:t.color}}):null}case"callout":{const i=ut(t,e,n);if(!i)return null;const{x:r,y:o}=i;return ht(r,o,n)?g.createElement(at,{key:"ann-"+e,noteData:{x:r,y:o,dx:t.dx||30,dy:t.dy||-30,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"callout-circle",subject:{radius:t.radius||12},connector:t.connector||{end:"arrow"},color:t.color}}):null}case"x-threshold":{const i=st(t,n);if(null==i)return null;const r=t.color||"#f97316";return g.createElement("g",{key:"ann-"+e},g.createElement("line",{x1:i,y1:0,x2:i,y2:n.height||0,stroke:r,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&g.createElement("text",{x:i+4,y:12,fill:r,fontSize:12,fontWeight:"bold"},t.label))}case"y-threshold":{const i=ct(t,n);if(null==i)return null;const r=t.color||"#f97316";return g.createElement("g",{key:"ann-"+e},g.createElement("line",{x1:0,y1:i,x2:n.width||0,y2:i,stroke:r,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&g.createElement("text",{x:(n.width||0)-4,y:i-4,textAnchor:"end",fill:r,fontSize:12,fontWeight:"bold"},t.label))}case"enclose":{const i=(t.coordinates||[]).map(t=>({x:st(Object.assign(Object.assign({},t),{type:"point"}),n),y:ct(Object.assign(Object.assign({},t),{type:"point"}),n),r:1})).filter(t=>null!=t.x&&null!=t.y);if(2>i.length)return null;const r=l.packEnclose(i),o=t.padding||10;return g.createElement("g",{key:"ann-"+e},g.createElement("circle",{cx:r.x,cy:r.y,r:r.r+o,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&g.createElement("text",{x:r.x,y:r.y-r.r-o-4,textAnchor:"middle",fill:t.color||"#666",fontSize:12},t.label))}case"rect-enclose":{const i=(t.coordinates||[]).map(t=>({x:st(Object.assign(Object.assign({},t),{type:"point"}),n),y:ct(Object.assign(Object.assign({},t),{type:"point"}),n)})).filter(t=>null!=t.x&&null!=t.y);if(2>i.length)return null;const r=t.padding||10,o=i.map(t=>t.x),a=i.map(t=>t.y),l=Math.min(...o)-r,s=Math.max(...o)+r,c=Math.min(...a)-r,u=Math.max(...a)+r;return g.createElement("g",{key:"ann-"+e},g.createElement("rect",{x:l,y:c,width:s-l,height:u-c,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&g.createElement("text",{x:(l+s)/2,y:c-4,textAnchor:"middle",fill:t.color||"#666",fontSize:12},t.label))}case"highlight":{const i=n.data||[],r="function"==typeof t.filter?i.filter(t.filter):t.field&&null!=t.value?i.filter(e=>e[t.field]===t.value):[],o=t.style||{stroke:t.color||"#f97316",strokeWidth:2,fill:"none"};return g.createElement("g",{key:"ann-"+e},r.map((e,i)=>{const r=st(e,n),a=ct(e,n);return null==r||null==a?null:g.createElement("circle",Object.assign({key:"hl-"+i,cx:r,cy:a,r:t.r||6},o))}))}case"bracket":{const i=st(t,n),r=ct(t,n);return g.createElement(at,{key:"ann-"+e,noteData:{x:null!=i?i:0,y:null!=r?r:0,dx:t.dx||0,dy:t.dy||0,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"bracket",subject:{type:t.bracketType||"curly",width:t.width,height:t.height,depth:t.depth||30},color:t.color}})}case"trend":{const l=n.data||[];if(2>l.length)return null;const s=n.xAccessor||"x",d=n.yAccessor||"y",f=l.map(t=>[t[s],t[d]]).filter(t=>null!=t[0]&&null!=t[1]);if(2>f.length)return null;const y=null!==(r=null===(i=n.scales)||void 0===i?void 0:i.x)&&void 0!==r?r:null===(o=n.scales)||void 0===o?void 0:o.time,v=null!==(c=null===(a=n.scales)||void 0===a?void 0:a.y)&&void 0!==c?c:null===(u=n.scales)||void 0===u?void 0:u.value;if(!y||!v)return null;const m=t.method||"linear";let x;x="loess"===m?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}(f,null!==(h=t.bandwidth)&&void 0!==h?h:.3):("polynomial"===m?p.default.polynomial(f,{order:t.order||2}):p.default.linear(f)).points;const b=x.map(([t,e])=>`${y(t)},${v(e)}`).join(" "),k=t.color||"#6366f1";return g.createElement("g",{key:"ann-"+e},g.createElement("polyline",{points:b,fill:"none",stroke:k,strokeWidth:t.strokeWidth||2,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&g.createElement("text",{x:y(x[x.length-1][0])+4,y:v(x[x.length-1][1])-4,fill:k,fontSize:11},t.label))}case"band":{const i=null!==(f=null===(d=n.scales)||void 0===d?void 0:d.y)&&void 0!==f?f:null===(y=n.scales)||void 0===y?void 0:y.value,r=null!==(v=null==i?void 0:i(t.y0))&&void 0!==v?v:0,o=null!==(m=null==i?void 0:i(t.y1))&&void 0!==m?m:n.height||0;return g.createElement("g",{key:"ann-"+e},g.createElement("rect",{x:0,y:Math.min(r,o),width:n.width||0,height:Math.abs(o-r),fill:t.fill||"#6366f1",fillOpacity:t.fillOpacity||.1}),t.label&&g.createElement("text",{x:(n.width||0)-4,y:Math.min(r,o)-4,textAnchor:"end",fill:t.color||"#6366f1",fontSize:11},t.label))}case"envelope":{const i=n.data||[];if(2>i.length)return null;const r=n.xAccessor||"x",o=null!==(b=null===(x=n.scales)||void 0===x?void 0:x.x)&&void 0!==b?b:null===(k=n.scales)||void 0===k?void 0:k.time,a=null!==(E=null===(w=n.scales)||void 0===w?void 0:w.y)&&void 0!==E?E:null===(A=n.scales)||void 0===A?void 0:A.value;if(!o||!a)return null;const l=t.upperAccessor||"upperBounds",c=t.lowerAccessor||"lowerBounds",u=t.filter,h=i.filter(t=>null!=t[l]&&null!=t[c]&&!(u&&!u(t))).sort((t,e)=>t[r]-e[r]);if(2>h.length)return null;const d=lt[n.curve||"linear"]||s.curveLinear,f=s.area().x(t=>o(t[r])).y0(t=>a(t[c])).y1(t=>a(t[l])).curve(d)(h);if(!f)return null;const y=t.fill||"#6366f1";return g.createElement("g",{key:"ann-"+e},g.createElement("path",{d:f,fill:y,fillOpacity:null!==(M=t.fillOpacity)&&void 0!==M?M:.15,stroke:"none"}),t.label&&h.length>0&&g.createElement("text",{x:o(h[h.length-1][r])+4,y:a(h[h.length-1][l])-4,fill:y,fontSize:11},t.label))}case"anomaly-band":{const i=n.data||[];if(2>i.length)return null;const r=n.yAccessor||"y",o=null!==(P=null===(S=n.scales)||void 0===S?void 0:S.x)&&void 0!==P?P:null===(_=n.scales)||void 0===_?void 0:_.time,a=null!==(C=null===(L=n.scales)||void 0===L?void 0:L.y)&&void 0!==C?C:null===(D=n.scales)||void 0===D?void 0:D.value;if(!o||!a)return null;const l=i.map(t=>t[r]).filter(t=>null!=t&&isFinite(t));if(2>l.length)return null;const s=l.reduce((t,e)=>t+e,0)/l.length,c=l.reduce((t,e)=>t+Math.pow(e-s,2),0)/l.length,u=Math.sqrt(c),h=null!==(T=t.threshold)&&void 0!==T?T:2,d=s-h*u,f=!1!==t.showBand,y=t.fill||"#6366f1",p=null!==(W=t.fillOpacity)&&void 0!==W?W:.1,v=t.anomalyColor||"#ef4444",m=null!==($=t.anomalyRadius)&&void 0!==$?$:6,x=a(s+h*u),b=a(d),k=i.filter(t=>{const e=t[r];return null!=e&&Math.abs(e-s)>h*u});return g.createElement("g",{key:"ann-"+e},f&&g.createElement("rect",{x:0,y:Math.min(x,b),width:n.width||0,height:Math.abs(b-x),fill:y,fillOpacity:p}),k.map((t,e)=>{const i=st(t,n),r=ct(t,n);return null==i||null==r?null:g.createElement("circle",{key:"anomaly-"+e,cx:i,cy:r,r:m,fill:v,fillOpacity:.7,stroke:v,strokeWidth:1.5})}),t.label&&g.createElement("text",{x:(n.width||0)-4,y:Math.min(x,b)-4,textAnchor:"end",fill:y,fontSize:11},t.label))}case"forecast":{const i=n.data||[];if(3>i.length)return null;const r=n.xAccessor||"x",o=n.yAccessor||"y",a=null!==(O=null===(N=n.scales)||void 0===N?void 0:N.x)&&void 0!==O?O:null===(z=n.scales)||void 0===z?void 0:z.time,l=null!==(R=null===(I=n.scales)||void 0===I?void 0:I.y)&&void 0!==R?R:null===(B=n.scales)||void 0===B?void 0:B.value;if(!a||!l)return null;const s=i.map(t=>[t[r],t[o]]).filter(t=>null!=t[0]&&null!=t[1]&&isFinite(t[0])&&isFinite(t[1])).sort((t,e)=>t[0]-e[0]);if(3>s.length)return null;let c;if("polynomial"===(t.method||"linear")){const e=p.default.polynomial(s,{order:t.order||2}).equation;c=t=>e.reduce((e,n,i)=>e+n*Math.pow(t,i),0)}else{const t=s.length;let e=0,n=0,i=0,r=0;for(const[t,o]of s)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;c=t=>l+a*t}const u=s.length,h=s.map(([t,e])=>e-c(t)).reduce((t,e)=>t+e*e,0),d=Math.sqrt(h/Math.max(u-2,1)),f=s.reduce((t,e)=>t+e[0],0)/u,y=s.reduce((t,e)=>t+Math.pow(e[0]-f,2),0),v=null!==(j=t.confidence)&&void 0!==j?j:.95,m=.99>v?.95>v?.9>v?1:1.645:1.96:2.576,x=null!==(F=t.steps)&&void 0!==F?F:5,b=s[u-1][0],k=(b-s[0][0])/Math.max(u-1,1),w=[];for(let t=1;x>=t;t++)w.push(b+t*k);const E=[];for(const t of w){const e=c(t),n=d*Math.sqrt(1+1/u+(y>0?Math.pow(t-f,2)/y:0))*m;E.push({x:t,yCenter:e,yUpper:e+n,yLower:e-n})}const A=`M${E.map(t=>`${a(t.x)},${l(t.yUpper)}`).join(" L")} L${E.slice().reverse().map(t=>`${a(t.x)},${l(t.yLower)}`).join(" L")} Z`,M=E.map(t=>`${a(t.x)},${l(t.yCenter)}`).join(" "),S=`${a(b)},${l(c(b))}`,P=t.strokeColor||"#6366f1";return g.createElement("g",{key:"ann-"+e},g.createElement("path",{d:A,fill:t.fill||"#6366f1",fillOpacity:null!==(Y=t.fillOpacity)&&void 0!==Y?Y:.15,stroke:"none"}),g.createElement("polyline",{points:`${S} ${M}`,fill:"none",stroke:P,strokeWidth:null!==(H=t.strokeWidth)&&void 0!==H?H:2,strokeDasharray:null!==(X=t.strokeDasharray)&&void 0!==X?X:"6,3"}),t.label&&E.length>0&&g.createElement("text",{x:a(E[E.length-1].x)+4,y:l(E[E.length-1].yCenter)-4,fill:P,fontSize:11},t.label))}case"widget":{let i=null,r=null;if(null!=t.px&&null!=t.py)i=t.px,r=t.py;else{const o=ut(t,e,n);if(!o)return null;i=o.x,r=o.y}if(null==i||null==r)return null;if(!ht(i,r,n))return null;const o=null!==(G=t.dx)&&void 0!==G?G:0,a=null!==(q=t.dy)&&void 0!==q?q:0,l=null!==(V=t.width)&&void 0!==V?V:32,s=null!==(K=t.height)&&void 0!==K?K:32,c=null!==(Z=t.content)&&void 0!==Z?Z:g.createElement("span",{style:{fontSize:18,cursor:"default"},title:t.label||"Info"},"ℹ️");return g.createElement("foreignObject",{key:"ann-"+e,x:i+o-l/2,y:r+a-s/2,width:l,height:s,style:{overflow:"visible",pointerEvents:"auto"}},g.createElement("div",{style:{width:l,height:s,display:"flex",alignItems:"center",justifyContent:"center"}},c))}case"text":{const i=ut(t,e,n);if(!i)return null;const{x:r,y:o}=i;return g.createElement("text",{key:"ann-text-"+e,x:r+(t.dx||0),y:o+(t.dy||0),fill:t.color||"var(--semiotic-text, #333)",fontSize:t.fontSize||11,dominantBaseline:"middle",style:{fontFamily:"inherit"}},t.label)}default:return null}},e={scales:h?{x:h.x,y:h.y,time:h.x,value:h.y}:null,timeAxis:"x",xAccessor:$,yAccessor:N,width:r,height:o,data:O,frameType:"xy",pointNodes:z,curve:I,stickyPositionCache:Y.current};return T.map((n,i)=>{if(W){const r=W(n,i,e);return null!=r?r:t(n,i,e)}return t(n,i,e)}).filter(Boolean)},[T,W,r,o,$,N,O,h,z,I]);return d||k||w||_||L||G&&G.length>0||b||B?g.createElement("svg",{role:"img",width:a,height:c,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},g.createElement("title",null,"string"==typeof k?k:"XY Chart"),g.createElement("desc",null,"string"==typeof k?k+" — XY data visualization":"XY data visualization"),g.createElement("g",{transform:`translate(${u.left},${u.top})`},b&&h&&!R&&g.createElement("g",{className:"stream-grid"},j.map((t,e)=>g.createElement("line",{key:"xgrid-"+e,x1:t.pixel,y1:0,x2:t.pixel,y2:o,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1})),F.map((t,e)=>g.createElement("line",{key:"ygrid-"+e,x1:0,y1:t.pixel,x2:r,y2:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),d&&h&&(()=>{const t=null==f?void 0:f.find(t=>"left"===t.orient),e=null==f?void 0:f.find(t=>"bottom"===t.orient),n=!t||!1!==t.baseline,i=(null==t?void 0:t.jaggedBase)||!1,a=(null==e?void 0:e.jaggedBase)||!1,l=null==e?void 0:e.landmarkTicks,s=null==t?void 0:t.landmarkTicks,c="var(--semiotic-border, #ccc)",h="var(--semiotic-text-secondary, #666)",d="var(--semiotic-text, #333)";return g.createElement("g",{className:"stream-axes"},!R&&(!e||!1!==e.baseline)&&!a&&g.createElement("line",{x1:0,y1:o,x2:r,y2:o,stroke:c,strokeWidth:1}),!R&&a&&g.createElement("path",{d:dt("bottom",r,o),fill:"none",stroke:c,strokeWidth:1}),j.map((t,e)=>{const n=!!l&&("function"==typeof l?l(t.value,e):gt(t.value,e>0?j[e-1].value:void 0));return g.createElement("g",{key:"xtick-"+e,transform:`translate(${t.pixel},${o})`},g.createElement("line",{y2:5,stroke:c,strokeWidth:1}),g.createElement("text",{y:18,textAnchor:"middle",fontSize:n?11:10,fontWeight:n?600:400,fill:h,style:{userSelect:"none"}},t.label))}),y&&g.createElement("text",{x:r/2,y:o+40,textAnchor:"middle",fontSize:12,fill:d,style:{userSelect:"none"}},y),!R&&n&&!i&&g.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:c,strokeWidth:1}),!R&&i&&g.createElement("path",{d:dt("left",r,o),fill:"none",stroke:c,strokeWidth:1}),F.map((t,e)=>{const n=!!s&&("function"==typeof s?s(t.value,e):gt(t.value,e>0?F[e-1].value:void 0));return g.createElement("g",{key:"ytick-"+e,transform:`translate(0,${t.pixel})`},g.createElement("line",{x2:-5,stroke:c,strokeWidth:1}),g.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:n?11:10,fontWeight:n?600:400,fill:h,style:{userSelect:"none"}},t.label))}),v&&g.createElement("text",{x:15-u.left,y:o/2,textAnchor:"middle",fontSize:12,fill:d,transform:`rotate(-90, ${15-u.left}, ${o/2})`,style:{userSelect:"none"}},v))})(),G,L&&h&&C&&D&&g.createElement(g.Fragment,null,L.top&&g.createElement("g",{transform:"translate(0, 0)"},g.createElement(nt,{orient:"top",config:et(L.top),values:C,scale:h.x,size:u.top,length:r})),L.bottom&&g.createElement("g",{transform:`translate(0, ${o})`},g.createElement(nt,{orient:"bottom",config:et(L.bottom),values:C,scale:h.x,size:u.bottom,length:r})),L.left&&g.createElement("g",{transform:"translate(0, 0)"},g.createElement(nt,{orient:"left",config:et(L.left),values:D,scale:h.y,size:u.left,length:o})),L.right&&g.createElement("g",{transform:`translate(${r}, 0)`},g.createElement(nt,{orient:"right",config:et(L.right),values:D,scale:h.y,size:u.right,length:o}))),_,B),k&&g.createElement("text",{x:a/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof k?k:null),tt({legend:w,totalWidth:a,totalHeight:c,margin:u,legendPosition:P,title:k,legendHoverBehavior:E,legendClickBehavior:A,legendHighlightedCategory:M,legendIsolatedCategories:S})):null}const vt="undefined"==typeof window||"undefined"==typeof document,mt={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function xt(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 bt(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 kt({scene:t,chartType:e}){var n,i,r,o;const a=[];for(const e of t){if(a.length>=50)break;"point"===e.type?a.push({label:"Point",values:{x:Math.round(100*e.x)/100+"",y:Math.round(100*e.y)/100+""}}):"rect"===e.type?a.push({label:"Bar",values:{category:(null===(n=e.datum)||void 0===n?void 0:n.category)||"",value:Math.round(100*(null!==(r=null===(i=e.datum)||void 0===i?void 0:i.value)&&void 0!==r?r:0))/100+""}}):"heatcell"===e.type&&a.push({label:"Cell",values:{x:Math.round(100*e.x)/100+"",y:Math.round(100*e.y)/100+"",value:Math.round(100*(null!==(o=e.value)&&void 0!==o?o:0))/100+""}})}if(0===a.length)return null;const l=new Set;for(const t of a)for(const e of Object.keys(t.values))l.add(e);const s=Array.from(l);return g.createElement("table",{style:mt,role:"table","aria-label":"Data table for "+e},g.createElement("thead",null,g.createElement("tr",null,s.map(t=>g.createElement("th",{key:t},t)))),g.createElement("tbody",null,a.map((t,e)=>g.createElement("tr",{key:e},s.map(e=>{var n;return g.createElement("td",{key:e},null!==(n=t.values[e])&&void 0!==n?n:"")}))),t.length>50&&g.createElement("tr",null,g.createElement("td",{colSpan:s.length},"...and ",t.length-50," more items"))))}function wt({nodes:t,chartType:e}){var n,i,r,o,a;const l=[];for(const e of t){if(l.length>=50)break;l.push({values:{id:(null===(n=e.datum)||void 0===n?void 0:n.id)||e.id||"",x:Math.round(100*(null!==(r=null!==(i=e.cx)&&void 0!==i?i:e.x)&&void 0!==r?r:0))/100+"",y:Math.round(100*(null!==(a=null!==(o=e.cy)&&void 0!==o?o:e.y)&&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 g.createElement("table",{style:mt,role:"table","aria-label":"Data table for "+e},g.createElement("thead",null,g.createElement("tr",null,c.map(t=>g.createElement("th",{key:t},t)))),g.createElement("tbody",null,l.map((t,e)=>g.createElement("tr",{key:e},c.map(e=>{var n;return g.createElement("td",{key:e},null!==(n=t.values[e])&&void 0!==n?n:"")}))),t.length>50&&g.createElement("tr",null,g.createElement("td",{colSpan:c.length},"...and ",t.length-50," more items"))))}function Et({hoverPoint:t}){let e="";if(t){const n=t.data||t;e="object"==typeof n?"Focused on data point: "+Object.entries(n).filter(([,t])=>"object"!=typeof t&&"function"!=typeof t).map(([t,e])=>`${t}: ${e}`).join(", "):"Focused on data point: "+n}return g.createElement("div",{"aria-live":"polite","aria-atomic":"true",style:mt},e)}function At(e){const n=t.createContext(null),i=Mt(e);return[function({children:i}){const r=t.useMemo(()=>Mt(e),[]);return g.createElement(n.Provider,{value:r,children:i})},e=>{var r;const o=null!==(r=t.useContext(n))&&void 0!==r?r:i,a=t.useRef(e);a.current=e;const l=t.useCallback(()=>a.current(o.getState()),[o]),s=t.useCallback(()=>a.current(o.getState()),[o]);return t.useSyncExternalStore(o.subscribe,l,s)}]}function Mt(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 St={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}},Pt={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}},[_t,Lt]=At(t=>({theme:St,setTheme(e){t(t=>"light"===e?{theme:St}:"dark"===e?{theme:Pt}:{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 Ct(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 Dt(){return"undefined"!=typeof window&&window.devicePixelRatio||1}function Tt(t){switch(t){case"monotoneX":return s.curveMonotoneX;case"monotoneY":return s.curveMonotoneY;case"cardinal":return s.curveCardinal;case"catmullRom":return s.curveCatmullRom;case"step":return s.curveStep;case"stepBefore":return s.curveStepBefore;case"stepAfter":return s.curveStepAfter;case"basis":return s.curveBasis;case"natural":return s.curveNatural;default:return null}}function Wt(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 $t(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 Nt(t){return!(!t._pulseIntensity||0>=t._pulseIntensity)}function Ot(t,e,n=.3){Nt(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 zt(t,e,n=.6){var i,r,o,a,l;if(!Nt(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 It(t,e,n,i=.35){Nt(e)&&(t.globalAlpha=e._pulseIntensity*i,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fill())}function Rt(t){switch(t){case"monotoneX":return s.curveMonotoneX;case"monotoneY":return s.curveMonotoneY;case"cardinal":return s.curveCardinal;case"catmullRom":return s.curveCatmullRom;case"step":return s.curveStep;case"stepBefore":return s.curveStepBefore;case"stepAfter":return s.curveStepAfter;case"basis":return s.curveBasis;case"natural":return s.curveNatural;default:return null}}function Bt(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 jt(t,e){const n=Rt(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=s.area().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 Ft=(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(jt(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=Bt(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&&(jt(t,e),It(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=Rt(e.curve);if(t.beginPath(),n)s.line().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}},Yt=(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()),zt(t,e),t.globalAlpha=1}}finally{t.restore()}},Ht=(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?Xt(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))),Ot(t,e),t.globalAlpha=1};function Xt(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 Gt(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 qt(t){return Number.isInteger(t)?t+"":100>Math.abs(t)?1>Math.abs(t)?t.toPrecision(3):t.toFixed(1):t.toFixed(0)}const Vt={line:[Ft,(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 c=l.style.stroke||"#007bff",u=l.style.strokeWidth||2,h=l.colorThresholds,d=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=u,t.lineCap=l.style.strokeLinecap||"butt",l.style._edgeFade){const p=null!==(r=l.style.opacity)&&void 0!==r?r:1;$t(t,l.path,c,u,p,l.style.strokeLinecap||"butt"),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt";continue}const f=Tt(l.curve),y=h&&h.length>0&&d&&d.length===l.path.length,g=l._decayOpacities;if(g&&g.length===l.path.length&&!y){t.strokeStyle=c;const v=null!==(o=l.style.opacity)&&void 0!==o?o:1;for(let m=0;l.path.length-1>m;m++)t.globalAlpha=.5*(g[m]+g[m+1])*v,t.beginPath(),t.moveTo(l.path[m][0],l.path[m][1]),t.lineTo(l.path[m+1][0],l.path[m+1][1]),t.stroke()}else if(y){let x=null,b=null,k=null,w=null,E=!1;function A(e,n,i){t.beginPath(),t.strokeStyle=e,t.moveTo(n,i),E=!0}function M(){E&&(t.stroke(),E=!1)}for(let S=0;l.path.length>S;S++){const[P,_]=l.path[S],L=d[S],C=Wt(L,h,c);if(null!==x&&null!==w&&null!==k){if(C===w)t.lineTo(P,_);else{const D=[];for(const T of h){const W=T.value;(k>W||W>L)&&(W>k||L>W)||k===W||L===W||D.push({t:(W-k)/(L-k)})}D.sort((t,e)=>t.t-e.t);for(const $ of D){const N=x+(P-x)*$.t,O=b+(_-b)*$.t,z=Wt(k+(L-k)*Math.min($.t+1e-4,1),h,c);t.lineTo(N,O),M(),A(z,N,O)}t.lineTo(P,_)}x=P,b=_,k=L,w=C}else A(C,P,_),x=P,b=_,k=L,w=C}M()}else{if(t.beginPath(),t.strokeStyle=c,f)s.line().x(t=>t[0]).y(t=>t[1]).curve(f).context(t)(l.path);else{const[I,R]=l.path[0];t.moveTo(I,R);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,f&&!y)s.line().x(t=>t[0]).y(t=>t[1]).curve(f).context(t)(l.path);else{const[F,Y]=l.path[0];t.moveTo(F,Y);for(let H=1;l.path.length>H;H++)t.lineTo(l.path[H][0],l.path[H][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:[Ft],stackedarea:[Ft],scatter:[Yt],bubble:[Yt],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),Ot(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):qt(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=Gt(e.fill),t.font=i+"px sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText(n,r,o)}}}finally{t.restore()}}],bar:[Ht],swarm:[Yt],waterfall:[(t,e,n,i)=>{var r,o,a;Ht(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()}}]},Kt={top:20,right:20,bottom:30,left:40},Zt={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"},Ut={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 Qt({hover:t}){const e=t=>Number.isInteger(t)?t+"":t.toFixed(2);return g.createElement("div",{className:"semiotic-tooltip",style:Ut},g.createElement("div",{style:{fontWeight:600,marginBottom:2}},e(t.value)),g.createElement("div",{style:{opacity:.7,fontSize:11}},e(t.time)))}function Jt({width:i,height:r,totalWidth:o,totalHeight:a,margin:l,dimension:s,scales:c,onBrush:u}){const h=t.useRef(null),d=t.useRef(null),f=t.useRef(u);f.current=u;const y=t.useRef(c);return y.current=c,t.useEffect(()=>{if(!h.current)return;const t=n.select(h.current).select(".brush-g"),o="x"===s?e.brushX():"y"===s?e.brushY():e.brush();return o.extent([[0,0],[i,r]]),o.on("brush end",t=>{const e=y.current;if(!e)return;if(!t.selection)return void f.current(null);let n,o;if("x"===s){const[i,a]=t.selection;n=[e.x.invert(i),e.x.invert(a)],o=[e.y.invert(r),e.y.invert(0)]}else if("y"===s){const[r,a]=t.selection;n=[e.x.invert(0),e.x.invert(i)],o=[e.y.invert(a),e.y.invert(r)]}else{const[[i,r],[a,l]]=t.selection;n=[e.x.invert(i),e.x.invert(a)],o=[e.y.invert(l),e.y.invert(r)]}f.current({x:n,y:o})}),t.call(o),d.current=o,t.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{o.on("brush end",null),d.current=null}},[i,r,s]),g.createElement("svg",{ref:h,width:o,height:a,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},g.createElement("g",{className:"brush-g",transform:`translate(${l.left},${l.top})`}))}const te=t.forwardRef(function(e,n){var i,r,o,a,l,s,c,u,h;const{chartType:d,runtimeMode:f,data:y,chunkThreshold:p,chunkSize:m,xAccessor:x,yAccessor:b,colorAccessor:k,sizeAccessor:w,groupAccessor:E,lineDataAccessor:A,curve:M,normalize:S,binSize:P,valueAccessor:_,arrowOfTime:L="right",windowMode:C="sliding",windowSize:D=200,timeAccessor:T,xExtent:W,yExtent:N,extentPadding:O=.1,sizeRange:R,size:H=[500,300],responsiveWidth:V,responsiveHeight:K,margin:Z,className:U,background:Q,lineStyle:J,pointStyle:tt,areaStyle:et,waterfallStyle:nt,swarmStyle:it,barColors:rt,colorScheme:ot,boundsAccessor:at,boundsStyle:lt,y0Accessor:st,gradientFill:ct,openAccessor:ut,highAccessor:ht,lowAccessor:dt,closeAccessor:yt,candlestickStyle:gt,showAxes:mt=!0,axes:bt,xLabel:wt,yLabel:At,xFormat:Mt,yFormat:St,tickFormatTime:Pt,tickFormatValue:_t,hoverAnnotation:Tt,tooltipContent:Wt,customHoverBehavior:$t,enableHover:Nt,annotations:Ot,svgAnnotationRules:zt,showGrid:It,legend:Rt,legendHoverBehavior:Bt,legendClickBehavior:jt,legendHighlightedCategory:Ft,legendIsolatedCategories:Yt,legendPosition:Ht,backgroundGraphics:Xt,foregroundGraphics:Gt,canvasPreRenderers:qt,title:Ut,categoryAccessor:te,brush:ee,onBrush:ne,decay:ie,pulse:re,transition:oe,staleness:ae,heatmapAggregation:le,heatmapXBins:se,heatmapYBins:ce,showValues:ue,heatmapValueFormat:he,marginalGraphics:de,pointIdAccessor:fe,xScaleType:ye,yScaleType:ge,accessibleTable:pe}=e,[ve,me]=G(H,V,K),xe=Object.assign(Object.assign({},Kt),Z);if(de){const t=60;de.top&&t>xe.top&&(xe.top=t),de.bottom&&t>xe.bottom&&(xe.bottom=t),de.left&&t>xe.left&&(xe.left=t),de.right&&t>xe.right&&(xe.right=t)}const be=me[0]-xe.left-xe.right,ke=me[1]-xe.top-xe.bottom,we="function"==typeof Gt?Gt({size:me,margin:xe}):Gt,Ee="function"==typeof Xt?Xt({size:me,margin:xe}):Xt,Ae=null!=Tt?Tt:Nt,Me=t.useRef(null),Se=t.useRef(null),Pe=t.useRef(0),_e=t.useRef(!1),Le=Lt(t=>t.theme),[Ce,De]=t.useState(0),[Te,We]=t.useState(null),$e=t.useRef(null),Ne=t.useRef(null),[Oe,ze]=t.useState(null),[Ie,Re]=t.useState(!1),[Be,je]=t.useState([]),[Fe,Ye]=t.useState([]),He=t.useRef(()=>{}),Xe="streaming"===f||["bar","swarm","waterfall"].includes(d),Ge=t.useMemo(()=>({chartType:d,runtimeMode:Xe?"streaming":"bounded",windowSize:D,windowMode:C,arrowOfTime:Xe?L:"right",extentPadding:O,xAccessor:Xe?void 0:x,yAccessor:Xe?void 0:b,timeAccessor:Xe?T:void 0,valueAccessor:_,colorAccessor:k,sizeAccessor:w,groupAccessor:E,categoryAccessor:te,lineDataAccessor:A,xScaleType:ye,yScaleType:ge,xExtent:W,yExtent:N,sizeRange:R,binSize:P,normalize:S,boundsAccessor:at,boundsStyle:lt,y0Accessor:st,gradientFill:"boolean"==typeof ct?ct?{topOpacity:.8,bottomOpacity:.05}:void 0:ct,openAccessor:ut,highAccessor:ht,lowAccessor:dt,closeAccessor:yt,candlestickStyle:gt,lineStyle:J,pointStyle:tt,areaStyle:et,swarmStyle:it,waterfallStyle:nt,colorScheme:ot,barColors:rt,annotations:Ot,decay:ie,pulse:re,transition:oe,staleness:ae,heatmapAggregation:le,heatmapXBins:se,heatmapYBins:ce,showValues:ue,heatmapValueFormat:he,pointIdAccessor:fe,curve:M}),[d,D,C,L,O,x,b,T,_,ye,ge,k,w,E,te,A,W,N,R,P,S,at,lt,st,ct,ut,ht,dt,yt,gt,J,tt,et,it,nt,ot,rt,Ot,ie,re,oe,ae,le,se,ce,ue,he,Xe,fe,M]),qe=t.useRef(null);qe.current||(qe.current=new $(Ge));const Ve=t.useCallback(()=>{Pe.current||(Pe.current=requestAnimationFrame(()=>He.current()))},[]);t.useEffect(()=>{var t;null===(t=qe.current)||void 0===t||t.updateConfig(Ge),_e.current=!0,Ve()},[Ge,Ve]),t.useEffect(()=>{_e.current=!0,Ve()},[Le,Ve]);const Ke=t.useRef(null);Ke.current||(Ke.current=new v(t=>{const e=qe.current;e&&e.ingest(t)&&(_e.current=!0,Ve())},{chunkThreshold:p,chunkSize:m})),t.useEffect(()=>{var t;null===(t=Ke.current)||void 0===t||t.updateChunkOptions({chunkThreshold:p,chunkSize:m})},[p,m]);const Ze=t.useCallback(t=>{var e;null===(e=Ke.current)||void 0===e||e.push(t)},[]),Ue=t.useCallback(t=>{var e;null===(e=Ke.current)||void 0===e||e.pushMany(t)},[]),Qe=t.useCallback(()=>{var t,e;null===(t=Ke.current)||void 0===t||t.clear(),null===(e=qe.current)||void 0===e||e.clear(),_e.current=!0,Ve()},[Ve]);t.useImperativeHandle(n,()=>({push:Ze,pushMany:Ue,clear:Qe,getData:()=>{var t,e,n;return null===(t=Ke.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}}),[Ze,Ue,Qe]),t.useEffect(()=>{var t;y&&(null===(t=Ke.current)||void 0===t||t.setBoundedData(y))},[y]);const Je=t.useRef(()=>{}),tn=t.useRef(()=>{});Je.current=t=>{if(!Ae)return;const e=Me.current;if(!e)return;const n=e.getBoundingClientRect(),i=t.clientX-n.left-xe.left,r=t.clientY-n.top-xe.top;if(0>i||i>be||0>r||r>ke)return void($e.current&&($e.current=null,Ne.current=null,ze(null),$t&&($t(null),_e.current=!0),Ve()));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=z(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=z(l,e,n);break;case"line":t=I(l,e,n);break;case"rect":t=B(l,e,n);break;case"heatcell":t=j(l,e,n);break;case"area":if(!1===l.interactive)break;t=Y(l,e,n);break;case"candlestick":t=F(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($e.current&&($e.current=null,Ne.current=null,ze(null),$t&&$t(null),Ve()));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});$e.current=s,Ne.current=a.node,ze(s),$t&&($t(s),_e.current=!0),Ve()},tn.current=()=>{$e.current&&($e.current=null,Ne.current=null,ze(null),$t&&($t(null),_e.current=!0),Ve())},t.useCallback(t=>Je.current(t),[]);const en=t.useCallback(()=>tn.current(),[]),nn=t.useRef(-1),rn=t.useCallback(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>nn.current?-1:nn.current,r=X(t.key,0>i?-1:i,n.length);if(null===r)return;if(t.preventDefault(),0>r)return nn.current=-1,$e.current=null,Ne.current=null,ze(null),$t&&$t(null),void Ve();const o=0>i?0:r;nn.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]);$e.current=a,ze(a),$t&&$t(a),Ve()},[$t,Ve]),on=t.useCallback(t=>{nn.current=-1,Je.current(t)},[]);He.current=()=>{var t,e;Pe.current=0;const n=Me.current,i=Se.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:be,height:ke});const s=Dt(),c=function(t){if(!t)return Zt;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||Zt.axisStroke,tickText:o||Zt.tickText,crosshair:o?o+"66":Zt.crosshair,hoverFill:s?s+"4D":Zt.hoverFill,hoverStroke:o?o+"99":Zt.hoverStroke,pointRing:s||Zt.pointRing}:Zt}(n),u=null!==(t=null==ae?void 0:ae.threshold)&&void 0!==t?t:5e3,h=ae&&r.lastIngestTime>0&&o-r.lastIngestTime>u;if(l){const t=Ct(n,me,xe,s);if(t){t.clearRect(-xe.left,-xe.top,me[0],me[1]),h&&(t.globalAlpha=null!==(e=null==ae?void 0:ae.dimOpacity)&&void 0!==e?e:.5);const i=getComputedStyle(n).getPropertyValue("--semiotic-bg").trim(),o=Q||(i&&"transparent"!==i?i:null);if(o&&(t.fillStyle=o,t.fillRect(-xe.left,-xe.top,me[0],me[1])),t.save(),"function"==typeof t.rect&&(t.beginPath(),t.rect(0,0,be,ke),t.clip()),qt&&r.scales)for(const e of qt)t.save(),e(t,r.scene,r.scales,{width:be,height:ke}),t.restore();const a=Vt[d];if(a&&r.scales)for(const e of a)e(t,r.scene,r.scales,{width:be,height:ke});t.restore(),h&&(t.globalAlpha=1)}}{const t=Ct(i,me,xe,s);if(t&&(t.clearRect(-xe.left,-xe.top,me[0],me[1]),Ae&&$e.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,$e.current,be,ke,"object"==typeof Ae?Ae:{},0,c),Ne.current&&Array.isArray(Tt))){const e=Tt.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,Ne.current,e)}}l&&n&&n.setAttribute("aria-label",xt(r.scene,d+" chart"));const f=_e.current;if(_e.current=!1,f&&r.scales&&((!Te||Te.x.domain()[0]!==r.scales.x.domain()[0]||Te.x.domain()[1]!==r.scales.x.domain()[1]||Te.y.domain()[0]!==r.scales.y.domain()[0]||Te.y.domain()[1]!==r.scales.y.domain()[1]||Te.x.range()[0]!==r.scales.x.range()[0]||Te.x.range()[1]!==r.scales.x.range()[1]||Te.y.range()[0]!==r.scales.y.range()[0]||Te.y.range()[1]!==r.scales.y.range()[1])&&We(r.scales),de)){const t=r.getData(),e="function"==typeof x?x:t=>t[x||"x"],n="function"==typeof b?b:t=>t[b||"y"];je(t.map(t=>e(t)).filter(t=>"number"==typeof t&&isFinite(t))),Ye(t.map(t=>n(t)).filter(t=>"number"==typeof t&&isFinite(t)))}f&&Ot&&Ot.length>0&&De(t=>t+1),(null==ae?void 0:ae.showBadge)&&Re(!!h),(a||r.hasActivePulses)&&(Pe.current=requestAnimationFrame(()=>He.current()))},t.useEffect(()=>(Ve(),()=>{Pe.current&&(cancelAnimationFrame(Pe.current),Pe.current=0)}),[Ve]),t.useEffect(()=>{_e.current=!0,Ve()},[d,be,ke,mt,Q,J,qt,Ve]),q(ae,qe,_e,Ve,Ie,Re);const an=Ae&&Oe?Wt?Wt(Oe):g.createElement(Qt,{hover:Oe}):null,ln=an?g.createElement("div",{className:"stream-frame-tooltip",style:{position:"absolute",left:xe.left+Oe.x,top:xe.top+Oe.y,transform:`translate(${Oe.x>.7*be?"calc(-100% - 12px)":"12px"}, ${.3*ke>Oe.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:1,width:"max-content"}},an):null,sn=nn.current>=0&&Oe?g.createElement("svg",{style:{position:"absolute",left:0,top:0,width:me[0],height:me[1],pointerEvents:"none",zIndex:2}},g.createElement("circle",{cx:Oe.x+xe.left,cy:Oe.y+xe.top,r:8,fill:"none",stroke:"var(--accent, #6366f1)",strokeWidth:2,strokeDasharray:"4,2"})):null;if(vt){const t=qe.current;t&&y&&(t.ingest({inserts:y,bounded:!0}),t.computeScene({width:be,height:ke}));const e=null!==(i=null==t?void 0:t.scene)&&void 0!==i?i:[],n=null!==(r=null==t?void 0:t.scales)&&void 0!==r?r:null;return g.createElement("div",{className:"stream-xy-frame"+(U?" "+U:""),role:"img","aria-label":"string"==typeof Ut?Ut:"XY chart",style:{position:"relative",width:me[0],height:me[1]}},g.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:me[0],height:me[1],style:{position:"absolute",left:0,top:0}},Ee,g.createElement("g",{transform:`translate(${xe.left},${xe.top})`},Q&&g.createElement("rect",{x:0,y:0,width:be,height:ke,fill:Q}),e.map((t,e)=>function(t,e){var n,i,r;switch(t.type){case"line":{const n=t;if(0===n.path.length)return null;const i="M"+n.path.map(([t,e])=>`${t},${e}`).join("L");return g.createElement("path",{key:"line-"+e,d:i,fill:"none",stroke:n.style.stroke||"#4e79a7",strokeWidth:n.style.strokeWidth||2,strokeDasharray:n.style.strokeDasharray,opacity:n.style.opacity})}case"area":{const r=t;if(0===r.topPath.length)return null;const o=r.topPath.map(([t,e])=>`${t},${e}`).join("L"),a=[...r.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L");return g.createElement("path",{key:"area-"+e,d:`M${o}L${a}Z`,fill:r.style.fill||"#4e79a7",fillOpacity:null!==(i=null!==(n=r.style.fillOpacity)&&void 0!==n?n:r.style.opacity)&&void 0!==i?i:.7,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})}case"point":return g.createElement("circle",{key:"point-"+e,cx:t.x,cy:t.y,r:t.r,fill:t.style.fill||"#4e79a7",opacity:null!==(r=t.style.opacity)&&void 0!==r?r:.8,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth});case"rect":return g.createElement("rect",{key:"rect-"+e,x:t.x,y:t.y,width:t.w,height:t.h,fill:t.style.fill||"#4e79a7",opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth});case"heatcell":{const n=t;if(n.showValues&&null!=n.value&&n.w>=20&&n.h>=20){const t=n.valueFormat?n.valueFormat(n.value):Number.isInteger(n.value)?n.value+"":100>Math.abs(n.value)?1>Math.abs(n.value)?n.value.toPrecision(3):n.value.toFixed(1):n.value.toFixed(0),[i,r,o]=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]}(n.fill),a=.299*i+.587*r+.114*o>128?"#000":"#fff",l=Math.max(10,Math.min(16,.3*Math.min(n.w,n.h)));return g.createElement("g",{key:"heatcell-"+e},g.createElement("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill}),g.createElement("text",{x:n.x+n.w/2,y:n.y+n.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:a,fontSize:l+"px"},t))}return g.createElement("rect",{key:"heatcell-"+e,x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill})}case"candlestick":{const n=t,i=Math.min(n.openY,n.closeY),r=Math.max(Math.abs(n.openY-n.closeY),1),o=n.isUp?n.upColor:n.downColor;return g.createElement("g",{key:"candle-"+e},g.createElement("line",{x1:n.x,y1:n.highY,x2:n.x,y2:n.lowY,stroke:n.wickColor,strokeWidth:n.wickWidth}),g.createElement("rect",{x:n.x-n.bodyWidth/2,y:i,width:n.bodyWidth,height:r,fill:o,stroke:o,strokeWidth:1}))}default:return null}}(t,e)).filter(Boolean))),g.createElement(pt,{width:be,height:ke,totalWidth:me[0],totalHeight:me[1],margin:xe,scales:n,showAxes:mt,axes:bt,xLabel:wt,yLabel:At,xFormat:Mt||Pt,yFormat:St||_t,showGrid:It,title:Ut,legend:Rt,legendHoverBehavior:Bt,legendClickBehavior:jt,legendHighlightedCategory:Ft,legendIsolatedCategories:Yt,legendPosition:Ht,foregroundGraphics:we,marginalGraphics:de,xValues:[],yValues:[],annotations:Ot,svgAnnotationRules:zt,annotationFrame:0,xAccessor:"string"==typeof x?x:"string"==typeof T?T:void 0,yAccessor:"string"==typeof b?b:"string"==typeof _?_:void 0,annotationData:null==t?void 0:t.getData(),pointNodes:null==t?void 0:t.scene.filter(t=>"point"===t.type),curve:"string"==typeof M?M:void 0}))}return g.createElement("div",{ref:ve,className:"stream-xy-frame"+(U?" "+U:""),role:"img","aria-label":"string"==typeof Ut?Ut:"XY chart",tabIndex:0,style:{position:"relative",width:V?"100%":me[0],height:K?"100%":me[1],overflow:"visible"},onMouseMove:Ae?on:void 0,onMouseLeave:Ae?en:void 0,onKeyDown:rn},Ee&&g.createElement("svg",{style:{position:"absolute",left:0,top:0,width:me[0],height:me[1],pointerEvents:"none"}},Ee),g.createElement(ft,{width:be,height:ke,totalWidth:me[0],totalHeight:me[1],margin:xe,scales:Te,showAxes:mt,axes:bt,showGrid:It,xFormat:Mt||Pt,yFormat:St||_t}),g.createElement("canvas",{ref:Me,"aria-label":xt(null!==(a=null===(o=qe.current)||void 0===o?void 0:o.scene)&&void 0!==a?a:[],d+" chart"),style:{position:"absolute",left:0,top:0}}),g.createElement("canvas",{ref:Se,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),g.createElement(Et,{hoverPoint:Oe}),pe&&g.createElement(kt,{scene:null!==(s=null===(l=qe.current)||void 0===l?void 0:l.scene)&&void 0!==s?s:[],chartType:d+" chart"}),g.createElement(pt,{width:be,height:ke,totalWidth:me[0],totalHeight:me[1],margin:xe,scales:Te,showAxes:mt,axes:bt,xLabel:wt,yLabel:At,xFormat:Mt||Pt,yFormat:St||_t,showGrid:It,title:Ut,legend:Rt,legendHoverBehavior:Bt,legendClickBehavior:jt,legendHighlightedCategory:Ft,legendIsolatedCategories:Yt,legendPosition:Ht,foregroundGraphics:we,marginalGraphics:de,xValues:Be,yValues:Fe,annotations:Ot,svgAnnotationRules:zt,annotationFrame:Ce,xAccessor:"string"==typeof x?x:"string"==typeof T?T:void 0,yAccessor:"string"==typeof b?b:"string"==typeof _?_:void 0,annotationData:null===(c=qe.current)||void 0===c?void 0:c.getData(),pointNodes:null===(u=qe.current)||void 0===u?void 0:u.scene.filter(t=>"point"===t.type),curve:"string"==typeof M?M:void 0,underlayRendered:!0}),(ee||ne)&&g.createElement(Jt,{width:be,height:ke,totalWidth:me[0],totalHeight:me[1],margin:xe,dimension:null!==(h=null==ee?void 0:ee.dimension)&&void 0!==h?h:"xy",scales:Te,onBrush:null!=ne?ne:()=>{}}),(null==ae?void 0:ae.showBadge)&&g.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===ae.badgePosition?{top:4,left:4}:"bottom-left"===ae.badgePosition?{bottom:4,left:4}:"bottom-right"===ae.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"),sn,ln)});te.displayName="StreamXYFrame";const ee={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},ne={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class ie{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=re(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 re(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=oe(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=oe(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 oe(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 ae(t,e){var n=t.get(e);if(!n)throw Error("missing: "+e);return n}function le(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 se(t){return t.y0-t.y1>0?"up":"down"}function ce(t,e){return e(t.source)==e(t.target)}function ue(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 he(t){return t.target.x0-t.source.x1}function de(t,e){var n=ye(t),i=he(e)/Math.tan(n);return"up"==se(t)?t.y1-i:t.y1+i}function fe(t,e){var n=ye(t),i=he(e)/Math.tan(n);return"up"==se(t)?t.y1+i:t.y1-i}function ye(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function ge(t,e){return e(t)}function pe(t){return me(t.source)}function ve(t){return me(t.target)}function me(t){return(t.y0+t.y1)/2}function xe(t){return t.virtual?0:t.value}function be(t,e){var n=0;t.sourceLinks.forEach(function(t){n=t.circular&&!ce(t,e)?n+1:n});var i=0;return t.targetLinks.forEach(function(t){i=t.circular&&!ce(t,e)?i+1:i}),n+i}function ke(t){return t.target.depth}function we(t,e){return t.sourceLinks.length?t.depth:e-1}function Ee(t,e){return t.y0-e.y0}function Ae(t,e){return e.y0-t.y0}function Me(t,e){return t.y1-e.y1}function Se(t,e){return e.y1-t.y1}function Pe(t,e){return Le(t.source,e.source)||t.index-e.index}function _e(t,e){return Le(t.target,e.target)||t.index-e.index}function Le(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function Ce(t,e){return De(t)==De(e)?"bottom"==t.circularLinkType?Ae(t,e):Ee(t,e):De(e)-De(t)}function De(t){return t.target.column-t.source.column}function Te(t,e){return We(t)==We(e)}function We(t){return t.y0-t.y1>0?"up":"down"}function $e(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 s=a.min(o.links,function(t){return t.source.y0});o.links.forEach(function(t){t.circular&&(t.circularPathData={})});var c=o.links.filter(function(t){return t.circular});return c.sort(function(t,e){return e.value-t.value}),c.forEach(function(t,e){t._circularStub=e>=4}),Ne(o.links.filter(function(t){return"top"==t.circularLinkType}),e,n),Ne(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,ce(t,e)&&ue(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,l=t.circularLinkType,c=o.links.filter(function(t){return t.source.column==a&&t.circularLinkType==l});c.sort("bottom"==t.circularLinkType?Ae:Ee);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==l})).sort("bottom"==t.circularLinkType?Se:Me),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=s-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 Ne(t,e,n){t.sort(Ce);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(ce(t,e)&&ue(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&&Oe(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 Oe(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}function ze(t){return function(){return t}}function Ie(t){return t.index}function Re(t){return t.nodes}function Be(t){return t.links}function je(t,e,n){var i=a.groups(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+=me(t.source)*e,i+=e}}),n.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;r+=me(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?be(e,n)-be(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==be(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 Fe(t,e,n,i,r,o){var l=a.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});h();for(var s=1,c=o;c>0;--c)u(s*=.99,n),h();function u(e,n){var i=l.length;l.forEach(function(r){var o=r.length,l=r[0].depth;r.forEach(function(r){var s;if(r.sourceLinks.length||r.targetLinks.length)if(r.partOfCycle&&be(r,n)>0){var c=a.mean(r.sourceLinks,ve),u=a.mean(r.targetLinks,pe),h=c&&u?(c+u)/2:c||u;if(h){var d=(h-me(r))*e*.3;r.y0+=d,r.y1+=d}}else if(0==l&&1==o)r.y0=t.y1/2-(s=r.y1-r.y0)/2,r.y1=t.y1/2+s/2;else if(l==i-1&&1==o)r.y0=t.y1/2-(s=r.y1-r.y0)/2,r.y1=t.y1/2+s/2;else if(1==r.targetLinks.length&&1==r.targetLinks[0].source.sourceLinks.length)s=r.y1-r.y0,r.y0=r.targetLinks[0].source.y0,r.y1=r.y0+s;else{var f=a.mean(r.sourceLinks,ve),y=a.mean(r.targetLinks,pe),g=((f&&y?(f+y)/2:f||y)-me(r))*e;r.y0+=g,r.y1+=g}})})}function h(){l.forEach(function(n){var o,a,l,s=t.y0,c=n.length;for(n.sort(e||Le),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 Ye(t){t.nodes.forEach(function(t){t.sourceLinks.sort(_e),t.targetLinks.sort(Pe)}),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 He(){var t=0,e=0,n=1,i=1,r=24,o=8,l=null,s=Ie,c=we,u=void 0,h=32,d=2,f=Re,y=Be;function g(){var g={nodes:f.apply(null,arguments),links:y.apply(null,arguments)};return function(f){f.x0=t,f.y0=e,f.x1=n,f.y1=i,f.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 a.group(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=ae(n,i)),"object"!=typeof r&&(r=t.target=ae(n,r)),i.sourceLinks.push(t),r.targetLinks.push(t)})}(f,s),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=le(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++)})}(f,u),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){ge(t,e)!=ge(r.source,e)&&ge(t,e)!=ge(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),ce(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(f,s),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max(a.sum(t.sourceLinks,xe),a.sum(t.targetLinks,xe)),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)})})}(f),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})}(f,u,c);var y=o;if(null!==l){var g=a.groups(f.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),p=a.max(g,function(t){return t.length});p>1&&(y=Math.max(1,(i-e)*l/(p-1)))}(function(t,e,n){var i=a.groups(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=a.min(i,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/a.sum(e,function(t){return t.value})});t.ky=r,t.links.forEach(function(e){e.width=e.value*t.ky});var o=a.max(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})})(f,y,r),je(f,u,s),Fe(f,u,s,y,y,h),Ye(f),$e(f,s,d,10,8),je(f,u,s),Fe(f,u,s,y,y,h),Ye(f),$e(f,s,d,10,8),function(t,e){let n=t;n.nodes.forEach(function(t){t.y+(t.y1-t.y0)>n.y1&&(t.y=t.y-(t.y+(t.y1-t.y0)-n.y1));var i=n.links.filter(function(n){return ge(n.source,e)==ge(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(!Te(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var n=de(e,t);return t.y1-n}if(e.target.column>t.target.column)return de(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}})})}(f,s),function(t,e){let n=t;n.nodes.forEach(function(t){var i=n.links.filter(function(n){return ge(n.target,e)==ge(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(!Te(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var n=fe(e,t);return t.y0-n}if(e.source.column>t.source.column)return fe(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}})})}(f,s),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=a.min(e,function(t){return t.y0}),l=a.max(e,function(t){return t.y1}),s=(t.y1-t.y0)/(l-o);function c(e){return(e-o)/(l-o)*(t.y1-t.y0)+t.y0}1>s?(e.forEach(function(t){t.y0=c(t.y0),t.y1=c(t.y1)}),n.forEach(function(t){t.y0=c(t.y0),t.y1=c(t.y1),t.width=t.width*s})):e.forEach(function(t){var e=t.y1-t.y0,n=c(t.y0)-t.y0;t.y0=c(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})})}}(f),$e(f,s,d,10,8)}(g),g}return g.update=function(t){return Ye(t),$e(t,s,d,10,8),t},g.nodeWidth=function(t){return arguments.length?(r=+t,g):r},g.nodePadding=function(t){return arguments.length?(o=+t,g):o},g.nodePaddingRatio=function(t){return arguments.length?(l=+t,g):l},g.nodes=function(t){return arguments.length?(f="function"==typeof t?t:ze(t),g):f},g.links=function(t){return arguments.length?(y="function"==typeof t?t:ze(t),g):y},g.nodeId=function(t){return arguments.length?(s="function"==typeof t?t:ze(t),g):s},g.nodeAlign=function(t){return arguments.length?(c="function"==typeof t?t:ze(t),g):c},g.nodeSort=function(t){return arguments.length?(u=t,g):u},g.iterations=function(t){return arguments.length?(h=+t,g):h},g.circularLinkGap=function(t){return arguments.length?(d=+t,g):d},g.extent=function(r){return arguments.length?(t=+r[0][0],e=+r[0][1],n=+r[1][0],i=+r[1][1],g):[[t,e],[n,i]]},g.size=function(r){return arguments.length?(t=e=0,n=+r[0],i=+r[1],g):[n-t,i-e]},g}const Xe=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=u.interpolateNumber(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=u.interpolateNumber(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 Ge(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 qe={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(ke))-1:0},justify:we},Ve={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=He().extent(m).links(v).nodes(p).nodeAlign(qe[d]||we).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 o,a,l,s;const c="vertical"===n.orientation?"down":"right",u=n.nodeStyle,h=n.edgeStyle,d=null!==(o=n.edgeOpacity)&&void 0!==o?o:.5,f=n.edgeColorBy||"source",y=Array.isArray(n.colorScheme)?n.colorScheme:r.schemeCategory10,g=new Map;t.forEach((t,e)=>{g.set(t.id,y[e%y.length])});const p=[],v=[],m=[];for(const e of t){const t=e.x1-e.x0,n=e.y1-e.y0;if(0>=t||0>=n)continue;const i=u?u(e):{},r={fill:i.fill||g.get(e.id)||"#4d430c",stroke:i.stroke,strokeWidth:i.strokeWidth,opacity:i.opacity};p.push({type:"rect",x:e.x0,y:e.y0,w:t,h:n,style:r,datum:e,id:e.id,label:e.id})}const x=[...e].sort((t,e)=>(e.sankeyWidth||0)-(t.sankeyWidth||0));for(const t of x){if(!t.sankeyWidth||0>=t.sankeyWidth)continue;const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;if(!e||!n)continue;let i="#999";h?i=h(t).fill||i:"target"===f&&n?i=g.get(n.id)||i:e&&(i=g.get(e.id)||i);const r=h?h(t):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,n=t.sankeyWidth/2,o=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;v.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-n}L${e.sourceX+o},${e.sourceY-n}L${e.sourceX+o},${e.sourceY+n}L${e.sourceX},${e.sourceY+n}Z`,style:{fill:c,fillOpacity:null!==(a=r.fillOpacity)&&void 0!==a?a:d,stroke:"none",opacity:r.opacity},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+o}}),v.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:d,stroke:"none",opacity:r.opacity},datum:t,_gradient:{direction:"left",from:0,to:1,x0:e.targetX-s,x1:e.targetX}});continue}let o;if(o=t.circular&&t.circularPathData?Ge(t):Xe(t),!o)continue;const c={fill:r.fill||i,fillOpacity:null!==(s=r.fillOpacity)&&void 0!==s?s:d,stroke:r.stroke||"none",strokeWidth:r.strokeWidth,opacity:r.opacity};v.push({type:"bezier",pathD:o,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,s;"down"===c?(a=n.x0+t/2,l=n.y1+14,s="middle"):(i[0]/2>n.x0+t/2?(a=n.x0-6,s="end"):(a=n.x1+6,s="start"),l=n.y0+r/2),m.push({x:a,y:l,text:o+"",anchor:s,baseline:"middle",fontSize:11})}}var b;return{sceneNodes:p,sceneEdges:v,labels:m}}},Ke={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 d=[];for(const e of t){const t=null!=e.x&&null!=e.y&&(0!==e.x||0!==e.y),n=null==c?void 0:c.get(e.id);t?u++:n?(e.x=n.x,e.y=n.y,u++):d.push(e)}const f=u>0&&.3>=(t.length>0?d.length/t.length:1);if(f){const n=new Map;for(const e of t)n.set(e.id,e);for(const t of d){const i=Ze(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=Ue(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=Ue(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 y=null!==(o=n.iterations)&&void 0!==o?o:Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),g=f?40:y,p=Qe(n.nodeSize,n.nodeSizeRange,t),v=t=>p(t),m=h.forceLink().strength(t=>Math.min(2.5,t.weight?t.weight*a:a)).id(t=>t.id),x=h.forceSimulation().force("charge",h.forceManyBody().strength(t=>-25*v(t))).force("center",h.forceCenter(l,s).strength(.8)).force("x",h.forceX(l).strength(.15)).force("y",h.forceY(s).strength(.15));if(x.nodes(t),e.length>0){const t=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id}));x.force("link",m),x.force("link").links(t)}f?x.alpha(.3):.1>x.alpha()&&x.alpha(1),x.stop();for(let t=0;g>t;++t)x.tick();for(const e of t){if(null==e.x||null==e.y)continue;const t=v(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 b=new Map;for(const e of t)b.set(e.id,e);for(const t of e){if("string"==typeof t.source){const e=b.get(t.source);e&&(t.source=e)}if("string"==typeof t.target){const e=b.get(t.target);e&&(t.target=e)}}},buildScene(t,e,n,i){var o,a,l;const s=n.nodeStyle,c=n.edgeStyle,u=Qe(n.nodeSize,n.nodeSizeRange,t),h=Array.isArray(n.colorScheme)?n.colorScheme:r.schemeCategory10,d=new Map;t.forEach((t,e)=>{d.set(t.id,h[e%h.length])});const f=[],y=[],g=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=u(e),n=s?s(e):{},i={fill:n.fill||d.get(e.id)||"#007bff",stroke:n.stroke||"#fff",strokeWidth:null!==(o=n.strokeWidth)&&void 0!==o?o:2,opacity:n.opacity};f.push({type:"circle",cx:e.x,cy:e.y,r:t,style:i,datum:e,id:e.id,label:e.id})}const p=new Map;for(const e of t)p.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:p.get(t.source),n="object"==typeof t.target?t.target:p.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=c?c(t):{},r={stroke:i.stroke||"#999",strokeWidth:null!==(a=i.strokeWidth)&&void 0!==a?a:1,opacity:null!==(l=i.opacity)&&void 0!==l?l:.6};y.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=(v=n.nodeLabel)?"function"==typeof v?v:t=>t[v]||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=u(n);g.push({x:n.x,y:n.y-i-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var v;return{sceneNodes:f,sceneEdges:y,labels:g}}};function Ze(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 Ue(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 Qe(t,e,n){var r,o;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const l=e||[5,20],s=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===s.length)return()=>l[0];const c=null!==(r=a.min(s))&&void 0!==r?r:0,u=null!==(o=a.max(s))&&void 0!==o?o:1;if(c===u)return()=>(l[0]+l[1])/2;const h=i.scaleLinear().domain([c,u]).range(l).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?l[0]:h(i)}}const Je=r.schemeCategory10,tn={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,c=l-o,u=i[0]/2,h=i[1]/2,f=(y=n.valueAccessor)?"function"==typeof y?y:t=>{var e;return null!==(e=t[y])&&void 0!==e?e:1}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:1};var y;const g=new Map;for(let e=0;t.length>e;e++)g.set(t[e].id,e);const p=t.length,v=Array.from({length:p},()=>Array.from({length:p},()=>0));for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=g.get("string"==typeof t.source?t.source:t.source.id),i=g.get(e);if(void 0===n||void 0===i)continue;const r=f(t);v[n][i]=r}const m=d.chord().padAngle(r);a&&m.sortGroups(a);const x=m(v),b=x.groups,k=s.arc().innerRadius(c).outerRadius(l);for(const e of b){const n=t[e.index],i=k.centroid(e);n.x=i[0]+u,n.y=i[1]+h,n.arcData={startAngle:e.startAngle,endAngle:e.endAngle}}const w=new Map;for(const e of t)w.set(e.id,e);for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=w.get("string"==typeof t.source?t.source:t.source.id),i=w.get(e);n&&(t.source=n),i&&(t.target=i)}const E=new Map;for(const t of e)E.set(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const e of x){const n=t[e.source.index].id,i=t[e.target.index].id,r=E.get(`${n}\0${i}`)||E.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,f=n.nodeStyle,y=n.edgeStyle,g=n.edgeColorBy||"source",p=Array.isArray(n.colorScheme)?n.colorScheme:Je,v=new Map;t.forEach((t,e)=>{v.set(t.id,p[e%p.length])});const m=d.ribbon().radius(c),x=[],b=[],k=[];for(let e=0;t.length>e;e++){const n=t[e],i=n.arcData;if(!i)continue;let o;o=f?f(n).fill||v.get(n.id)||p[e%p.length]:v.get(n.id)||p[e%p.length];const a=f?f(n):{},l={fill:o,stroke:a.stroke||"black",strokeWidth:null!==(r=a.strokeWidth)&&void 0!==r?r:1,opacity:a.opacity};x.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=m(e);if(!n)continue;const i=en(n,u,h);let r="#999";if(y)r=y(t).fill||r;else{const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;"target"===g&&n?r=v.get(n.id)||r:e&&(r=v.get(e.id)||r)}const a=y?y(t):{},s={fill:r,fillOpacity:null!==(o=a.fillOpacity)&&void 0!==o?o:l,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity};b.push({type:"ribbon",pathD:i,style:s,datum:t})}if(!1!==n.showLabels){const e=(w=n.nodeLabel)?"function"==typeof w?w:t=>t[w]||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;k.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 w;return{sceneNodes:x,sceneEdges:b,labels:k}}};function en(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 nn(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 rn={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,n,i){var r;const o=n.__hierarchyRoot;if(!o)return;const a=n.chartType,s=(c=n.childrenAccessor)?"function"==typeof c?c:t=>t[c]:void 0;var c;const u=n.hierarchySum||(t=>{var e;return null!==(e=t.value)&&void 0!==e?e:0}),h=l.hierarchy(o,s);h.sum(u),h.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[d,f]=i;switch(a){case"tree":!function(t,e,n,i){const r=e.treeOrientation||"vertical",o=l.tree();o.size("horizontal"===r?[i,n]:"radial"===r?[2*Math.PI,Math.min(n,i)/2*.8]:[n,i]),o(t)}(h,n,d,f);break;case"cluster":!function(t,e,n,i){const r=e.treeOrientation||"vertical",o=l.cluster();o.size("horizontal"===r?[i,n]:"radial"===r?[2*Math.PI,Math.min(n,i)/2*.8]:[n,i]),o(t)}(h,n,d,f);break;case"treemap":!function(t,e,n,i){var r,o;const a=null!==(r=e.padding)&&void 0!==r?r:4,s=null!==(o=e.paddingTop)&&void 0!==o?o:0,c=l.treemap().size([n,i]).tile(l.treemapBinary).padding(a);s>0&&c.paddingTop(s),c(t)}(h,n,d,f);break;case"circlepack":!function(t,e,n,i){var r;const o=null!==(r=e.padding)&&void 0!==r?r:4;l.pack().size([n,i]).padding(o)(t)}(h,n,d,f);break;case"partition":!function(t,e,n,i){var r;l.partition().size([n,i]).padding(null!==(r=e.padding)&&void 0!==r?r:1)(t)}(h,n,d,f)}const y=h.descendants();t.length=0,e.length=0;const g=new Map;for(let e=0;y.length>e;e++){const i=y[e],o={id:cn(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?on(o,i,n):"treemap"===a||"partition"===a?an(o,i):"circlepack"===a&&ln(o,i),o.__hierarchyNode=i,t.push(o),g.set(i,o)}if("tree"===a||"cluster"===a)for(const t of y)if(t.parent){const n=g.get(t.parent),i=g.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=sn(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=un(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=un(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=nn(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=un(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=nn(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 on(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 an(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 ln(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 sn(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 cn(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 un(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 hn(t){const e=t;return e.__orbitState||(e.__orbitState={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()}),e.__orbitState}const dn={sankey:Ve,force:Ke,chord:tn,tree:rn,cluster:rn,treemap:rn,circlepack:rn,partition:rn,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),c=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),u=function(t){if(Array.isArray(t))return t;switch(t){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(n.orbitMode),h=null!==(o=n.orbitSize)&&void 0!==o?o:2.95,d=null!==(a=n.orbitEccentricity)&&void 0!==a?a:1,f="number"==typeof h?()=>h:h,y="number"==typeof d?()=>d:d,g=hn(n);g.metaMap.clear(),i.length=0,r.length=0;const p=new Map;function v(t){var e;const n=null!==(e=p.get(t))&&void 0!==e?e:0;return p.set(t,n+1),0===n?t:`${t}__${n}`}const m=e[0]/2,x=e[1]/2,b=Math.min(e[0],e[1])/2*.85,k=v(c(t));i.push({id:k,x:m,y:x,x0:m,x1:m,y0:x,y1:x,width:0,height:0,value:0,depth:0,data:t}),g.metaMap.set(k,{ring:b,angle:0,depth:0,parentId:null,eccentricity:1}),function t(e,n,o,a,h,d,p){const m=l(e);if(!(null==m?void 0:m.length))return;const x=m.length;let b=0,k=0,w=0;for(;x>k;)k+=u[Math.min(w,u.length-1)],w++,b++;let E=0;for(let x=0;b>x;x++){const k=u[Math.min(x,u.length-1)],w=m.slice(E,E+k);if(!w.length)break;const A=(x+1)/b,M={id:n,depth:d,data:e,parentId:n},S=p?h/f(M)*A:h*A,P=s.pie().value(t=>{var e;return(null===(e=l(t))||void 0===e?void 0:e.length)?4:1}).sort(null),_=P(w),L=y(M);for(let e=0;w.length>e;e++){const l=(_[e].startAngle+_[e].endAngle)/2,s=w[e],u=v(c(s)),h=o+S*Math.sin(l),f=a+S*Math.cos(l)*L;i.push({id:u,x:h,y:f,x0:h,x1:h,y0:f,y1:f,width:0,height:0,value:0,depth:d,data:s}),g.metaMap.set(u,{ring:S,angle:l,depth:d,parentId:n,eccentricity:L}),r.push({source:n,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:u}}),t(s,u,h,f,S,d+1,!0)}E+=k}}(t,k,m,x,b,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=hn(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=hn(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 fn(t){return dn[t]}class yn{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({},ee),t.tensionConfig),"sankey"===t.chartType&&t.showParticles&&(this.particlePool=new ie(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({},ee),t.tensionConfig),"sankey"===t.chartType&&t.showParticles&&!this.particlePool&&(this.particlePool=new ie(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({},gn(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({},gn(e)),{data:t})),this.nodes.has(n)||this.nodes.set(n,Object.assign(Object.assign({},gn(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,gn(e)),this.nodeTimestamps.set(e,a),this.tension+=this.tensionConfig.newNode,o=!0),this.nodes.has(n)||(this.nodes.set(n,gn(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=fn(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=fn(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=fn(this.config.chartType);return!!(null==t?void 0:t.supportsAnimation)&&!1!==this.config.orbitAnimated}tickAnimation(t,e){const n=fn(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=T(t,this.transition),n=D(e);for(const t of this.nodes.values())void 0===t._targetX0||void 0===t._prevX0||0===t._prevX0&&0===t._prevX1||(t.x0=W(t._prevX0,t._targetX0,n),t.x1=W(t._prevX1,t._targetX1,n),t.y0=W(t._prevY0,t._targetY0,n),t.y1=W(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=W(t._prevY0,t._targetY0,n),t.y1=W(t._prevY1,t._targetY1,n),t.sankeyWidth=W(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=u.interpolateNumber(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=u.interpolateNumber(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 gn(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 pn(t,e,n,i,r=30){let o=null,a=r,l=1/0;for(const e of t){const t=vn(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=kn(t,n,i);e&&a>e.distance&&(o=e,a=e.distance)}return o}function vn(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=N(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=O(Math.atan2(r,i)),l=O(t.startAngle),s=O(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 mn=null,xn=null;function bn(){return xn||(mn=document.createElement("canvas"),mn.width=1,mn.height=1,xn=mn.getContext("2d")),xn}function kn(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=bn();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=bn();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 wn(t){const{width:e,height:n,totalWidth:i,totalHeight:r,margin:o,labels:a,title:l,legend:s,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:h,legendIsolatedCategories:d,legendPosition:f="right",foregroundGraphics:y,sceneNodes:p,annotations:v,svgAnnotationRules:m}=t;return g.createElement(g.Fragment,null,g.createElement("svg",{role:"img",width:i,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},g.createElement("title",null,"string"==typeof l?l:"Network Chart"),g.createElement("desc",null,"string"==typeof l?l+" — network data visualization":"Network data visualization"),g.createElement("g",{transform:`translate(${o.left},${o.top})`},a.map((t,e)=>g.createElement("text",{key:"label-"+e,x:t.x,y:t.y,textAnchor:t.anchor||"start",dominantBaseline:t.baseline||"middle",fontSize:t.fontSize||11,fontWeight:t.fontWeight,fill:t.fill||"currentColor",stroke:t.stroke,strokeWidth:t.strokeWidth,paintOrder:t.paintOrder,style:{pointerEvents:"none"}},t.text)),v&&v.filter(t=>"widget"!==t.type).map((t,i)=>{if(m){const r=m(t,i,{width:e,height:n,sceneNodes:p});if(r)return g.createElement(g.Fragment,{key:"annotation-"+i},r)}return null}),y),l&&"string"==typeof l?g.createElement("text",{x:i/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor"},l):l?g.createElement("foreignObject",{x:0,y:0,width:i,height:o.top},l):null,tt({legend:s,totalWidth:i,totalHeight:r,margin:o,legendPosition:f,title:l,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:h,legendIsolatedCategories:d})),null==v?void 0:v.filter(t=>"widget"===t.type&&t.nodeId&&p).map((t,e)=>{var n,i,r,a,l,s,c,u,h;const d=p.find(e=>{var n,i,r,o,a;return e.id===t.nodeId||(null===(n=e.datum)||void 0===n?void 0:n.id)===t.nodeId||(null===(r=null===(i=e.datum)||void 0===i?void 0:i.data)||void 0===r?void 0:r.id)===t.nodeId||(null===(a=null===(o=e.datum)||void 0===o?void 0:o.data)||void 0===a?void 0:a.name)===t.nodeId});if(!d)return null;const f=o.left+(null!==(n=d.cx)&&void 0!==n?n:null!=d.x&&null!=d.w?d.x+d.w/2:null!==(i=d.x)&&void 0!==i?i:0),y=o.top+(null!==(r=d.cy)&&void 0!==r?r:null!=d.y&&null!=d.h?d.y+d.h/2:null!==(a=d.y)&&void 0!==a?a:0),v=null!==(l=t.dx)&&void 0!==l?l:0,m=null!==(s=t.dy)&&void 0!==s?s:-16,x=null!==(c=t.width)&&void 0!==c?c:32,b=null!==(u=t.height)&&void 0!==u?u:32,k=null!==(h=t.content)&&void 0!==h?h:g.createElement("span",{style:{fontSize:18,cursor:"default"}},"ℹ️");return g.createElement("div",{key:"widget-"+e,style:{position:"absolute",left:f+v-x/2,top:y+m-b/2,width:x,height:b,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:5}},k)}))}function En(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 An(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 Mn(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 Sn(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()}wn.displayName="NetworkSVGOverlay";const Pn={top:20,right:80,bottom:20,left:80},_n={top:40,right:40,bottom:40,left:40},Ln=new Set(["chord","force","circlepack","orbit"]),Cn=[800,600],Dn={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 Tn({data:t}){var e,n,i,r,o,a;if("edge"===t.type){const e=t.data;return g.createElement("div",{className:"semiotic-tooltip",style:Dn},g.createElement("div",{style:{fontWeight:600}},"object"==typeof e.source?e.source.id:e.source," → ","object"==typeof e.target?e.target.id:e.target),null!=e.value&&g.createElement("div",{style:{marginTop:4,opacity:.8}},"Value:"," ","number"==typeof e.value?e.value.toLocaleString():e.value+""))}const l=t.data,s=null==l?void 0:l.__hierarchyNode;if(s){const t=[];let o=s;for(;o;){const a=null!==(r=null!==(n=null===(e=o.data)||void 0===e?void 0:e.name)&&void 0!==n?n:null===(i=o.data)||void 0===i?void 0:i.id)&&void 0!==r?r:l.id;null!=a&&t.unshift(a+""),o=o.parent}t.length>1&&t.shift();const a=t.length-1;return g.createElement("div",{className:"semiotic-tooltip",style:Dn},g.createElement("div",null,t.map((t,e)=>g.createElement("span",{key:e},e>0&&g.createElement("span",{style:{margin:"0 3px",opacity:.5}}," → "),e===a?g.createElement("strong",null,t):g.createElement("span",{style:{opacity:.7}},t)))),null!=l.value&&l.value>0&&g.createElement("div",{style:{marginTop:4,opacity:.8}},"number"==typeof l.value?l.value.toLocaleString():l.value+""))}const c=((null===(o=l.sourceLinks)||void 0===o?void 0:o.length)||0)+((null===(a=l.targetLinks)||void 0===a?void 0:a.length)||0),u=(l.sourceLinks||[]).reduce((t,e)=>t+(e.value||0),0)+(l.targetLinks||[]).reduce((t,e)=>t+(e.value||0),0);return g.createElement("div",{className:"semiotic-tooltip",style:Dn},g.createElement("div",{style:{fontWeight:600}},l.id),null!=l.value&&l.value>0&&g.createElement("div",{style:{marginTop:4,opacity:.8}},"Total:"," ","number"==typeof l.value?l.value.toLocaleString():l.value+""),c>0&&g.createElement("div",{style:{marginTop:4,opacity:.8}},"Connections: ",c,u!==c&&` (weighted: ${u.toLocaleString()})`))}const Wn=t.forwardRef(function(e,n){var i,r,o,a,l,c,u,h,d,f,y;const{chartType:p,nodes:v,edges:m,data:x,initialEdges:b,nodeIDAccessor:k="id",sourceAccessor:w="source",targetAccessor:E="target",valueAccessor:A="value",childrenAccessor:M,hierarchySum:S,orientation:P="horizontal",nodeAlign:_="justify",nodePaddingRatio:C=.05,nodeWidth:D=15,iterations:T=300,forceStrength:W=.1,padAngle:$=.01,groupWidth:N=20,sortGroups:O,edgeSort:z,treeOrientation:I="vertical",edgeType:R="curve",padding:B,paddingTop:j,tensionConfig:F,showParticles:Y=!1,particleStyle:H,nodeStyle:V,edgeStyle:K,colorBy:Z,colorScheme:U="category10",edgeColorBy:Q="source",edgeOpacity:J=.5,colorByDepth:tt=!1,nodeSize:et=8,nodeSizeRange:nt=[5,20],nodeLabel:it,showLabels:rt=!0,labelMode:ot,size:at=Cn,responsiveWidth:lt,responsiveHeight:st,margin:ct,className:ut,background:ht,enableHover:dt=!0,tooltipContent:ft,customHoverBehavior:yt,customClickBehavior:gt,onObservation:pt,chartId:mt,onTopologyChange:xt,annotations:kt,svgAnnotationRules:At,legend:Mt,legendPosition:St,legendHoverBehavior:Pt,legendClickBehavior:_t,legendHighlightedCategory:Tt,legendIsolatedCategories:Wt,title:$t,foregroundGraphics:Nt,backgroundGraphics:It,decay:Rt,pulse:Bt,staleness:jt,thresholds:Ft,accessibleTable:Yt,orbitMode:Ht,orbitSize:Xt,orbitSpeed:Gt,orbitRevolution:qt,orbitRevolutionStyle:Vt,orbitEccentricity:Kt,orbitShowRings:Zt,orbitAnimated:Ut}=e,Qt=Ln.has(p)?_n:Pn,[Jt,te]=G(at,lt,st),ie=Object.assign(Object.assign({},Qt),ct),re=te[0]-ie.left-ie.right,oe=te[1]-ie.top-ie.bottom,ae="function"==typeof Nt?Nt({size:te,margin:ie}):Nt,le=t.useMemo(()=>Object.assign(Object.assign({},ee),F),[F]),se=t.useMemo(()=>Object.assign(Object.assign({},ne),H),[H]),ce=t.useMemo(()=>({chartType:p,nodeIDAccessor:k,sourceAccessor:w,targetAccessor:E,valueAccessor:A,childrenAccessor:M,hierarchySum:S,orientation:P,nodeAlign:_,nodePaddingRatio:C,nodeWidth:D,iterations:T,forceStrength:W,padAngle:$,groupWidth:N,sortGroups:O,edgeSort:z,treeOrientation:I,edgeType:R,padding:B,paddingTop:j,tensionConfig:le,showParticles:Y,particleStyle:se,nodeStyle:V,edgeStyle:K,nodeLabel:it,showLabels:rt,labelMode:ot,colorBy:Z,colorScheme:U,edgeColorBy:Q,edgeOpacity:J,colorByDepth:tt,nodeSize:et,nodeSizeRange:nt,decay:Rt,pulse:Bt,staleness:jt,thresholds:Ft,orbitMode:Ht,orbitSize:Xt,orbitSpeed:Gt,orbitRevolution:qt,orbitRevolutionStyle:Vt,orbitEccentricity:Kt,orbitShowRings:Zt,orbitAnimated:Ut}),[p,k,w,E,A,M,S,P,_,C,D,T,W,$,N,O,z,I,R,B,j,le,Y,se,V,K,it,rt,ot,Z,U,Q,J,tt,et,nt,Rt,Bt,jt,Ft,Ht,Xt,Gt,qt,Vt,Kt,Zt,Ut]),ue=t.useRef(null),he=t.useRef(0),de=t.useRef(0),fe=t.useRef(!0),ye=Lt(t=>t.theme),ge=t.useRef(()=>{}),pe=t.useRef(null);pe.current||(pe.current=new yn(ce));const[ve,me]=t.useState(null),[xe,be]=t.useState(0),[ke,we]=t.useState(0),[Ee,Ae]=t.useState(!1),Me=t.useRef(null),Se=t.useRef(new Map),Pe=t.useRef(0),_e=t.useCallback(t=>{if("function"==typeof Z)return Z(t)+"";if("string"==typeof Z&&t.data){const e=t.data[Z];if(void 0!==e){if(!Se.current.has(e+"")){const t=Array.isArray(U)?U:L;Se.current.set(e+"",t[Pe.current++%t.length])}return Se.current.get(e+"")}}if(!Se.current.has(t.id)){const e=Array.isArray(U)?U:L;Se.current.set(t.id,e[Pe.current++%e.length])}return Se.current.get(t.id)},[Z,U]),Le=t.useCallback(t=>{if("function"==typeof Q)return Q(t);const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;return"target"===Q&&n?_e(n):e?_e(e):"#999"},[Q,_e]),Ce=t.useCallback(t=>{if(!(null==H?void 0:H.colorBy))return Le(t);const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;return"target"===se.colorBy&&n?_e(n):e?_e(e):"#999"},[null==H?void 0:H.colorBy,se.colorBy,_e,Le]),De="sankey"===p&&Y||!!Bt||null!==(r=null===(i=pe.current)||void 0===i?void 0:i.isAnimating)&&void 0!==r&&r,Te=t.useCallback(()=>{he.current&&!De||he.current||(he.current=requestAnimationFrame(()=>ge.current()))},[De]);t.useEffect(()=>{var t;null===(t=pe.current)||void 0===t||t.updateConfig(ce),fe.current=!0,Te()},[ce,Te]),t.useEffect(()=>{fe.current=!0,Te()},[ye,Te]);const We=t.useCallback(()=>{const t=pe.current;if(!t)return;t.runLayout([re,oe]),t.buildScene([re,oe]),fe.current=!0;const e=Array.isArray(U)?U:L,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(Pe.current=n.length,be(t.layoutVersion),xt){const{nodes:e,edges:n}=t.getLayoutData();xt(e,n)}},[re,oe,xt,U]),$e=t.useCallback(t=>{const e=pe.current;e&&(e.ingestEdge(t)&&We(),Te())},[We,Te]),Ne=t.useCallback(t=>{const e=pe.current;if(!e)return;let n=!1;for(const i of t)e.ingestEdge(i)&&(n=!0);n&&We(),Te()},[We,Te]),Oe=t.useCallback(()=>{var t;null===(t=pe.current)||void 0===t||t.clear(),Se.current.clear(),Pe.current=0,be(0),me(null),Me.current=null,fe.current=!0,Te()},[Te]),ze=t.useCallback(()=>{const t=pe.current;t&&(t.tension+=999,We(),Te())},[We,Te]);t.useImperativeHandle(n,()=>({push:$e,pushMany:Ne,clear:Oe,getTopology:()=>{var t,e;return null!==(e=null===(t=pe.current)||void 0===t?void 0:t.getLayoutData())&&void 0!==e?e:{nodes:[],edges:[]}},getTopologyDiff:()=>{const t=pe.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:ze,getTension:()=>{var t,e;return null!==(e=null===(t=pe.current)||void 0===t?void 0:t.tension)&&void 0!==e?e:0}}),[$e,Ne,Oe,ze]);const Ie=["tree","cluster","treemap","circlepack","partition","orbit"].includes(p),Re=Ie?x||(Array.isArray(m)?void 0:m):void 0;t.useEffect(()=>{const t=pe.current;if(t)if(Ie&&Re)t.ingestHierarchy(Re,[re,oe]),t.buildScene([re,oe]),fe.current=!0,Te();else{const e=v||[],n=Array.isArray(m)?m:[];if(0===e.length&&0===n.length)return;t.ingestBounded(e,n,[re,oe]),t.buildScene([re,oe]);const i=Array.isArray(U)?U:L,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])}Pe.current=r.length,fe.current=!0,Te()}},[v,m,x,Re,Ie,re,oe,ce,Te,U]),t.useEffect(()=>{b&&b.length>0&&Ne(b)},[]);const Be=t.useCallback(t=>{if(yt&&yt(t),pt){const e=Date.now();pt(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})}},[yt,pt,mt]),je=t.useCallback(t=>{if(gt&&gt(t),pt){const e=Date.now();pt(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})}},[gt,pt,mt]),Fe=t.useRef(()=>{}),Ye=t.useRef(()=>{});Fe.current=t=>{if(!dt)return;const e=ue.current;if(!e)return;const n=e.getBoundingClientRect(),i=t.clientX-n.left-ie.left,r=t.clientY-n.top-ie.top;if(0>i||i>re||0>r||r>oe)return void(Me.current&&(Me.current=null,me(null),Be&&(Be(null),fe.current=!0),Te()));const o=pe.current;if(!o)return;const a=pn(o.sceneNodes,o.sceneEdges,i,r);if(!a)return void(Me.current&&(Me.current=null,me(null),Be&&(Be(null),fe.current=!0),Te()));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});Me.current=s,me(s),Be&&(Be(s),fe.current=!0),Te()},Ye.current=()=>{Me.current&&(Me.current=null,me(null),Be&&(Be(null),fe.current=!0),Te())};const He=t.useRef(()=>{});He.current=t=>{if(!gt&&!pt)return;const e=ue.current;if(!e)return;const n=e.getBoundingClientRect(),i=t.clientX-n.left-ie.left,r=t.clientY-n.top-ie.top;if(0>i||i>re||0>r||r>oe)return;const o=pe.current;if(!o)return;const a=pn(o.sceneNodes,o.sceneEdges,i,r);if(a){const t=a.datum||{};je(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 je(null)},t.useCallback(t=>Fe.current(t),[]);const Xe=t.useCallback(()=>Ye.current(),[]),Ge=t.useCallback(t=>He.current(t),[]),qe=t.useRef(-1),Ve=t.useCallback(t=>{const e=pe.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=X(t.key,0>i?-1:i,n.length);if(null===r)return;if(t.preventDefault(),0>r)return qe.current=-1,Me.current=null,me(null),Be&&(Be(null),fe.current=!0),void Te();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});Me.current=s,me(s),Be&&(Be(s),fe.current=!0),Te()},[Be,Te]),Ke=t.useCallback(t=>{qe.current=-1,Fe.current(t)},[]);ge.current=()=>{var t,e,n,i,r,o,a;he.current=0;const l=ue.current;if(!l)return;const s=l.getContext("2d");if(!s)return;const c=pe.current;if(!c)return;const u=performance.now(),h=de.current?Math.min((u-de.current)/1e3,.1):.016;de.current=u;const d=c.advanceTransition(u),f=c.tickAnimation([re,oe],h);(d||fe.current||f)&&c.buildScene([re,oe]);const y=Dt();if(!Ct(l,te,ie,y))return;s.clearRect(-ie.left,-ie.top,te[0],te[1]),ht&&(s.fillStyle=ht,s.fillRect(0,0,re,oe)),Rt&&c.applyDecay(),Bt&&c.applyPulse(u),Ft&&c.applyThresholds(u),c.applyTopologyDiff(u);const g=null!==(t=null==jt?void 0:jt.threshold)&&void 0!==t?t:5e3,p=jt&&c.lastIngestTime>0&&u-c.lastIngestTime>g;if(p&&(s.globalAlpha=null!==(e=null==jt?void 0:jt.dimOpacity)&&void 0!==e?e:.5),function(t,e){for(const n of e)switch(n.type){case"bezier":En(t,n);break;case"line":An(t,n);break;case"ribbon":Mn(t,n);break;case"curved":Sn(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)),Ot(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()),zt(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),Y&&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:ne.spawnRate,l=null!==(o=i.maxPerEdge)&&void 0!==o?o:ne.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,se);const e=.5*(null!==(n=se.speedMultiplier)&&void 0!==n?n:1);let i;if(se.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:ne.radius,s=null!==(a=i.opacity)&&void 0!==a?a:ne.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,se,Ce)}}p&&(s.globalAlpha=1);const v=fe.current;if(fe.current=!1,v||d||f){const t=ue.current;t&&t.setAttribute("aria-label",bt(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)&&we(t=>t+1),(De||d||f||c.hasActivePulses||c.hasActiveThresholds||c.hasActiveTopologyDiff)&&(he.current=requestAnimationFrame(()=>ge.current()))},t.useEffect(()=>(Te(),()=>{he.current&&(cancelAnimationFrame(he.current),he.current=0)}),[Te]),t.useEffect(()=>{fe.current=!0,Te()},[p,re,oe,ht,Te]),q(jt,pe,fe,Te,Ee,Ae);const Ze=dt&&ve?g.createElement("div",{className:"stream-network-tooltip",style:{position:"absolute",left:ie.left+ve.x,top:ie.top+ve.y,transform:`translate(${ve.x>.6*re?"calc(-100% - 12px)":"12px"}, ${.3*oe>ve.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:2,width:"max-content"}},ft?ft(ve):g.createElement(Tn,{data:ve})):null;if(vt){const t=pe.current;if(t){const e=["tree","cluster","treemap","circlepack","partition","orbit"].includes(p),n=e?x||(Array.isArray(m)?void 0:m):void 0;if(e&&n)t.ingestHierarchy(n,[re,oe]),t.buildScene([re,oe]);else{const e=v||[],n=Array.isArray(m)?m:[];(e.length>0||n.length>0)&&(t.ingestBounded(e,n,[re,oe]),t.buildScene([re,oe]))}}const e=null!==(o=null==t?void 0:t.sceneNodes)&&void 0!==o?o:[],n=null!==(a=null==t?void 0:t.sceneEdges)&&void 0!==a?a:[],i=null!==(l=null==t?void 0:t.labels)&&void 0!==l?l:[];return g.createElement("div",{className:"stream-network-frame"+(ut?" "+ut:""),role:"img","aria-label":"string"==typeof $t?$t:"Network chart",style:{position:"relative",width:te[0],height:te[1]}},g.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:te[0],height:te[1],style:{position:"absolute",left:0,top:0}},It&&g.createElement("g",{transform:`translate(${ie.left},${ie.top})`},It),g.createElement("g",{transform:`translate(${ie.left},${ie.top})`},ht&&g.createElement("rect",{x:0,y:0,width:re,height:oe,fill:ht}),n.map((t,e)=>function(t,e){switch(t.type){case"line":return g.createElement("line",{key:"net-edge-"+e,x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.stroke||"#999",strokeWidth:t.style.strokeWidth||1,opacity:t.style.opacity});case"bezier":case"ribbon":return g.createElement("path",{key:"net-edge-"+e,d:t.pathD,fill:t.style.fill||"#999",fillOpacity:t.style.fillOpacity,stroke:t.style.stroke||"none",strokeWidth:t.style.strokeWidth,opacity:t.style.opacity});case"curved":return g.createElement("path",{key:"net-edge-"+e,d:t.pathD,fill:t.style.fill||"none",stroke:t.style.stroke||"#999",strokeWidth:t.style.strokeWidth||1,opacity:t.style.opacity});default:return null}}(t,e)).filter(Boolean),e.map((t,e)=>function(t,e){switch(t.type){case"circle":return g.createElement("circle",{key:"net-circle-"+e,cx:t.cx,cy:t.cy,r:t.r,fill:t.style.fill||"#4e79a7",stroke:t.style.stroke,strokeWidth:t.style.strokeWidth,opacity:t.style.opacity});case"rect":return g.createElement("rect",{key:"net-rect-"+e,x:t.x,y:t.y,width:t.w,height:t.h,fill:t.style.fill||"#4e79a7",stroke:t.style.stroke,strokeWidth:t.style.strokeWidth,opacity:t.style.opacity});case"arc":{const n=t,i=s.arc().innerRadius(n.innerR).outerRadius(n.outerR).startAngle(n.startAngle).endAngle(n.endAngle)({})||"";return g.createElement("path",{key:"net-arc-"+e,d:i,transform:`translate(${n.cx},${n.cy})`,fill:n.style.fill||"#4e79a7",stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})}default:return null}}(t,e)).filter(Boolean),i.map((t,e)=>function(t,e){return g.createElement("text",{key:"net-label-"+e,x:t.x,y:t.y,textAnchor:t.anchor||"middle",dominantBaseline:t.baseline||"auto",fontSize:t.fontSize||11,fontWeight:t.fontWeight,fill:t.fill||"#333",stroke:t.stroke,strokeWidth:t.strokeWidth,paintOrder:t.paintOrder},t.text)}(t,e)).filter(Boolean))),g.createElement(wn,{width:re,height:oe,totalWidth:te[0],totalHeight:te[1],margin:ie,labels:i,sceneNodes:e,title:$t,legend:Mt,legendPosition:St,legendHoverBehavior:Pt,legendClickBehavior:_t,legendHighlightedCategory:Tt,legendIsolatedCategories:Wt,foregroundGraphics:ae,annotations:kt,svgAnnotationRules:At,annotationFrame:0}))}const Ue=pe.current;return g.createElement("div",{ref:Jt,className:"stream-network-frame"+(ut?" "+ut:""),role:"img","aria-label":"string"==typeof $t?$t:"Network chart",tabIndex:0,style:{position:"relative",width:lt?"100%":te[0],height:st?"100%":te[1],overflow:"visible"},onMouseMove:dt?Ke:void 0,onMouseLeave:dt?Xe:void 0,onClick:gt||pt?Ge:void 0,onKeyDown:Ve},It&&g.createElement("svg",{style:{position:"absolute",top:0,left:0,width:te[0],height:te[1],pointerEvents:"none"}},g.createElement("g",{transform:`translate(${ie.left},${ie.top})`},It)),g.createElement("canvas",{ref:ue,"aria-label":bt(null!==(u=null===(c=null==Ue?void 0:Ue.sceneNodes)||void 0===c?void 0:c.length)&&void 0!==u?u:0,null!==(d=null===(h=null==Ue?void 0:Ue.sceneEdges)||void 0===h?void 0:h.length)&&void 0!==d?d:0,"Network chart"),style:{position:"absolute",top:0,left:0}}),g.createElement(Et,{hoverPoint:ve}),Yt&&g.createElement(wt,{nodes:null!==(f=null==Ue?void 0:Ue.sceneNodes)&&void 0!==f?f:[],edges:null!==(y=null==Ue?void 0:Ue.sceneEdges)&&void 0!==y?y:[],chartType:"Network chart"}),g.createElement(wn,{width:re,height:oe,totalWidth:te[0],totalHeight:te[1],margin:ie,labels:(null==Ue?void 0:Ue.labels)||[],sceneNodes:null==Ue?void 0:Ue.sceneNodes,title:$t,legend:Mt,legendPosition:St,legendHoverBehavior:Pt,legendClickBehavior:_t,legendHighlightedCategory:Tt,legendIsolatedCategories:Wt,foregroundGraphics:ae,annotations:kt,svgAnnotationRules:At,annotationFrame:ke}),Ze,(null==jt?void 0:jt.showBadge)&&g.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}),{background:Ee?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"})},Ee?"STALE":"LIVE"))});function $n(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 Nn(t,e){let n=t.get(e);return n||(n={name:e,resolution:"union",clauses:new Map},t.set(e,n)),n}Wn.displayName="StreamNetworkFrame";const[On,zn]=At(t=>({selections:new Map,setClause(e,n){t(t=>{const i=new Map(t.selections),r=Nn(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=Nn(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}})}})),[In,Rn]=At(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 Bn(e){const n=t.useId(),i=e.clientId||n,{name:r}=e,o=zn(t=>t.selections.get(r)),a=zn(t=>t.setClause),l=zn(t=>t.clearClause),s=t.useMemo(()=>!!o&&o.clauses.size>0,[o]);return{predicate:t.useMemo(()=>o&&0!==o.clauses.size?function(t,e){const n=[];for(const[i,r]of t.clauses)"crossfilter"===t.resolution&&i===e||n.push($n(r));return 0===n.length?()=>!0:"intersect"===t.resolution?t=>n.every(e=>e(t)):t=>n.some(e=>e(t))}(o,i):()=>!0,[o,i]),isActive:s,selectPoints:t.useCallback(t=>{const e={};for(const[n,i]of Object.entries(t))e[n]={type:"point",values:new Set(i)};a(r,{clientId:i,type:"point",fields:e})},[i,r,a]),selectInterval:t.useCallback(t=>{const e={};for(const[n,i]of Object.entries(t))e[n]={type:"interval",range:i};a(r,{clientId:i,type:"interval",fields:e})},[i,r,a]),clear:t.useCallback(()=>{l(r,i)},[l,r,i]),clientId:i}}function jn({selection:e,linkedHover:n,fallbackFields:i=[],unwrapData:r=!1,onObservation:o,chartType:a,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}(n,i),c=Bn({name:(null==e?void 0:e.name)||"__unused__"}),u=function(e){const n=e.name||"hover",{fields:i}=e,{predicate:r,isActive:o,selectPoints:a,clear:l}=Bn({name:n});return{onHover:t.useCallback(t=>{if(!t)return void l();const e={};for(const n of i){const i=t[n];void 0!==i&&(e[n]=[i])}Object.keys(e).length>0&&a(e)},[i,a,l,n]),predicate:r,isActive:o}}({name:(null==s?void 0:s.name)||"hover",fields:(null==s?void 0:s.fields)||i||[]}),h=Rn(t=>t.pushObservation);return{activeSelectionHook:e?{isActive:c.isActive,predicate:c.predicate}:null,customHoverBehavior:t.useCallback(t=>{var e,i;if(n)if(t){let e=t.data||t.datum||t;Array.isArray(e)&&(e=e[0]),u.onHover(e)}else u.onHover(null);if(o||h){const n={timestamp:Date.now(),chartType:a||"unknown",chartId:l};if(t){let r=t.data||t.datum||t;Array.isArray(r)&&(r=r[0]);const a=Object.assign(Object.assign({},n),{type:"hover",datum:r||{},x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(i=t.y)&&void 0!==i?i:0});o&&o(a),h&&h(a)}else{const t=Object.assign(Object.assign({},n),{type:"hover-end"});o&&o(t),h&&h(t)}}},[n,u,o,a,l,h]),customClickBehavior:t.useCallback(t=>{var e,n;if(o||h){const i={timestamp:Date.now(),chartType:a||"unknown",chartId:l};if(t){let r=t.data||t.datum||t;Array.isArray(r)&&(r=r[0]);const a=Object.assign(Object.assign({},i),{type:"click",datum:r||{},x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(n=t.y)&&void 0!==n?n:0});o&&o(a),h&&h(a)}else{const t=Object.assign(Object.assign({},i),{type:"click-end"});o&&o(t),h&&h(t)}}},[o,h,a,l])}}const Fn={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 Yn(t,e,n){var i,r,o,a,l,s;const c=Fn[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 Hn={display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #999)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"},Xn={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function Gn(t,e,n,i){return!1===i||null==t||Array.isArray(t)&&t.length>0?null:Array.isArray(t)?g.createElement("div",{style:Object.assign(Object.assign({},Hn),{width:e,height:n})},i||"No data available"):null}function qn(t,e,n){if(!t)return null;const i=Math.min(5,Math.floor(n/40)),r=Math.max(8,Math.floor(n/(3*i))),o=Math.max(6,Math.floor(n/(2.5*i))),a=Math.floor((n-(i*(r+o)-o))/2);return g.createElement("div",{style:{width:e,height:n,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"}},Array.from({length:i},(t,n)=>g.createElement("div",{key:n,className:"semiotic-loading-bar",style:Object.assign(Object.assign({},Xn),{position:"absolute",top:a+n*(r+o),left:Math.floor(.1*e),width:30+(37*n+13)%50+"%",height:r,opacity:.5+n%2*.2})})))}const Vn=t.forwardRef(function(e,n){var i,r,o,a;const l=Yn(e.mode,{width:null!==(r=null===(i=e.size)||void 0===i?void 0:i[0])&&void 0!==r?r:e.width,height:null!==(a=null===(o=e.size)||void 0===o?void 0:o[1])&&void 0!==a?a:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{size:s,margin:c,className:u,arrowOfTime:h="right",windowMode:d="sliding",windowSize:f=200,data:y,timeAccessor:p,valueAccessor:v,timeExtent:m,valueExtent:x,extentPadding:b,stroke:k="#007bff",strokeWidth:w=2,strokeDasharray:E,background:A,tooltipContent:M,tooltip:S,onHover:P,annotations:_,svgAnnotationRules:L,tickFormatTime:C,tickFormatValue:D,decay:T,pulse:W,staleness:$,transition:N,linkedHover:O,selection:z,onObservation:I,chartId:R,loading:B,emptyContent:j,emphasis:F,legendPosition:Y}=e,H=l.showAxes,X=l.enableHover,G=null!=c?c:l.marginDefaults,q=null!=s?s:[l.width,l.height],V=null!=M?M:S,K=t.useRef(null),{customHoverBehavior:Z}=jn({selection:z,linkedHover:O,unwrapData:!0,onObservation:I,chartType:"RealtimeLineChart",chartId:R}),U=t.useCallback(t=>{P&&P(t),Z(t)},[P,Z]);t.useImperativeHandle(n,()=>({push:t=>{var e;return null===(e=K.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=K.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=K.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=K.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const Q=qn(B,q[0],q[1]);if(Q)return Q;const J=Gn(y,q[0],q[1],j);if(J)return J;const tt={stroke:k,strokeWidth:w,strokeDasharray:E};return g.createElement(te,{ref:K,chartType:"line",runtimeMode:"streaming",size:q,margin:G,className:F?`${u||""} semiotic-emphasis-${F}`.trim():u,arrowOfTime:h,windowMode:d,windowSize:f,data:y,timeAccessor:p,valueAccessor:v,xExtent:m,yExtent:x,extentPadding:b,lineStyle:tt,showAxes:H,background:A,hoverAnnotation:X,tooltipContent:V,customHoverBehavior:U,annotations:_,svgAnnotationRules:L,tickFormatTime:C,tickFormatValue:D,decay:T,pulse:W,staleness:$,transition:N,legendPosition:Y})});Vn.displayName="RealtimeLineChart";const Kn=t.forwardRef(function(e,n){var i,r,o,a;const l=Yn(e.mode,{width:null!==(r=null===(i=e.size)||void 0===i?void 0:i[0])&&void 0!==r?r:e.width,height:null!==(a=null===(o=e.size)||void 0===o?void 0:o[1])&&void 0!==a?a:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{binSize:s,size:c,margin:u,className:h,arrowOfTime:d="right",windowMode:f="sliding",windowSize:y=200,data:p,timeAccessor:v,valueAccessor:m,timeExtent:x,valueExtent:b,extentPadding:k,categoryAccessor:w,colors:E,fill:A,stroke:M,strokeWidth:S,gap:P,background:_,tooltipContent:L,tooltip:C,onHover:D,annotations:T,svgAnnotationRules:W,tickFormatTime:$,tickFormatValue:N,linkedHover:O,selection:z,decay:I,pulse:R,staleness:B,transition:j,onObservation:F,chartId:Y,loading:H,emptyContent:X,emphasis:G,legendPosition:q}=e,V=l.showAxes,K=l.enableHover,Z=null!=u?u:l.marginDefaults,U=null!=c?c:[l.width,l.height],Q=null!=L?L:C,J=t.useRef(null),{customHoverBehavior:tt}=jn({selection:z,linkedHover:O,unwrapData:!0,onObservation:F,chartType:"RealtimeTemporalHistogram",chartId:Y}),et=t.useCallback(t=>{D&&D(t),tt(t)},[D,tt]);t.useImperativeHandle(n,()=>({push:t=>{var e;return null===(e=J.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=J.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=J.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=J.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const nt=qn(H,U[0],U[1]);if(nt)return nt;const it=Gn(p,U[0],U[1],X);if(it)return it;const rt={};return null!=A&&(rt.fill=A),null!=M&&(rt.stroke=M),null!=S&&(rt.strokeWidth=S),null!=P&&(rt.gap=P),g.createElement(te,{ref:J,chartType:"bar",runtimeMode:"streaming",size:U,margin:Z,className:G?`${h||""} semiotic-emphasis-${G}`.trim():h,arrowOfTime:d,windowMode:f,windowSize:y,data:p,timeAccessor:v,valueAccessor:m,xExtent:x,yExtent:b,extentPadding:k,binSize:s,categoryAccessor:w,barColors:E,barStyle:rt,showAxes:V,background:_,hoverAnnotation:K,tooltipContent:Q,customHoverBehavior:et,annotations:T,svgAnnotationRules:W,tickFormatTime:$,tickFormatValue:N,decay:I,pulse:R,staleness:B,transition:j,legendPosition:q})});Kn.displayName="RealtimeTemporalHistogram";const Zn=Kn,Un=t.forwardRef(function(e,n){var i,r,o,a;const l=Yn(e.mode,{width:null!==(r=null===(i=e.size)||void 0===i?void 0:i[0])&&void 0!==r?r:e.width,height:null!==(a=null===(o=e.size)||void 0===o?void 0:o[1])&&void 0!==a?a:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{size:s,margin:c,className:u,arrowOfTime:h="right",windowMode:d="sliding",windowSize:f=200,data:y,timeAccessor:p,valueAccessor:v,timeExtent:m,valueExtent:x,extentPadding:b,categoryAccessor:k,colors:w,radius:E,fill:A,opacity:M,stroke:S,strokeWidth:P,background:_,tooltipContent:L,tooltip:C,onHover:D,annotations:T,svgAnnotationRules:W,tickFormatTime:$,tickFormatValue:N,linkedHover:O,selection:z,onObservation:I,chartId:R,loading:B,emptyContent:j,emphasis:F,legendPosition:Y}=e,H=l.showAxes,X=l.enableHover,G=null!=c?c:l.marginDefaults,q=null!=s?s:[l.width,l.height],V=null!=L?L:C,K=t.useRef(null),{customHoverBehavior:Z}=jn({selection:z,linkedHover:O,unwrapData:!0,onObservation:I,chartType:"RealtimeSwarmChart",chartId:R}),U=t.useCallback(t=>{D&&D(t),Z(t)},[D,Z]);t.useImperativeHandle(n,()=>({push:t=>{var e;return null===(e=K.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=K.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=K.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=K.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const Q=qn(B,q[0],q[1]);if(Q)return Q;const J=Gn(y,q[0],q[1],j);if(J)return J;const tt={};return null!=E&&(tt.radius=E),null!=A&&(tt.fill=A),null!=M&&(tt.opacity=M),null!=S&&(tt.stroke=S),null!=P&&(tt.strokeWidth=P),g.createElement(te,{ref:K,chartType:"swarm",runtimeMode:"streaming",size:q,margin:G,className:F?`${u||""} semiotic-emphasis-${F}`.trim():u,arrowOfTime:h,windowMode:d,windowSize:f,data:y,timeAccessor:p,valueAccessor:v,xExtent:m,yExtent:x,extentPadding:b,categoryAccessor:k,barColors:w,swarmStyle:tt,showAxes:H,background:_,hoverAnnotation:X,tooltipContent:V,customHoverBehavior:U,annotations:T,svgAnnotationRules:W,tickFormatTime:$,tickFormatValue:N,legendPosition:Y})});Un.displayName="RealtimeSwarmChart";const Qn=t.forwardRef(function(e,n){var i,r,o,a;const l=Yn(e.mode,{width:null!==(r=null===(i=e.size)||void 0===i?void 0:i[0])&&void 0!==r?r:e.width,height:null!==(a=null===(o=e.size)||void 0===o?void 0:o[1])&&void 0!==a?a:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{size:s,margin:c,className:u,arrowOfTime:h="right",windowMode:d="sliding",windowSize:f=200,data:y,timeAccessor:p,valueAccessor:v,timeExtent:m,valueExtent:x,extentPadding:b,positiveColor:k,negativeColor:w,connectorStroke:E,connectorWidth:A,gap:M,stroke:S,strokeWidth:P,background:_,tooltipContent:L,tooltip:C,onHover:D,annotations:T,svgAnnotationRules:W,tickFormatTime:$,tickFormatValue:N,linkedHover:O,selection:z,onObservation:I,chartId:R,loading:B,emptyContent:j,emphasis:F,legendPosition:Y}=e,H=l.showAxes,X=l.enableHover,G=null!=c?c:l.marginDefaults,q=null!=s?s:[l.width,l.height],V=null!=L?L:C,K=t.useRef(null),{customHoverBehavior:Z}=jn({selection:z,linkedHover:O,unwrapData:!0,onObservation:I,chartType:"RealtimeWaterfallChart",chartId:R}),U=t.useCallback(t=>{D&&D(t),Z(t)},[D,Z]);t.useImperativeHandle(n,()=>({push:t=>{var e;return null===(e=K.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=K.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=K.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=K.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const Q=qn(B,q[0],q[1]);if(Q)return Q;const J=Gn(y,q[0],q[1],j);if(J)return J;const tt={};return null!=k&&(tt.positiveColor=k),null!=w&&(tt.negativeColor=w),null!=E&&(tt.connectorStroke=E),null!=A&&(tt.connectorWidth=A),null!=M&&(tt.gap=M),null!=S&&(tt.stroke=S),null!=P&&(tt.strokeWidth=P),g.createElement(te,{ref:K,chartType:"waterfall",runtimeMode:"streaming",size:q,margin:G,className:F?`${u||""} semiotic-emphasis-${F}`.trim():u,arrowOfTime:h,windowMode:d,windowSize:f,data:y,timeAccessor:p,valueAccessor:v,xExtent:m,yExtent:x,extentPadding:b,waterfallStyle:tt,showAxes:H,background:_,hoverAnnotation:X,tooltipContent:V,customHoverBehavior:U,annotations:T,svgAnnotationRules:W,tickFormatTime:$,tickFormatValue:N,legendPosition:Y})});Qn.displayName="RealtimeWaterfallChart";const Jn=t.forwardRef(function(e,n){var i,r,o,a;const l=Yn(e.mode,{width:null!==(r=null===(i=e.size)||void 0===i?void 0:i[0])&&void 0!==r?r:e.width,height:null!==(a=null===(o=e.size)||void 0===o?void 0:o[1])&&void 0!==a?a:e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0}),{size:s,margin:c,className:u,arrowOfTime:h="right",windowMode:d="sliding",windowSize:f=200,data:y,timeAccessor:p,valueAccessor:v,categoryAccessor:m,timeExtent:x,valueExtent:b,extentPadding:k,heatmapXBins:w=20,heatmapYBins:E=20,aggregation:A="count",background:M,tooltipContent:S,tooltip:P,onHover:_,annotations:L,svgAnnotationRules:C,tickFormatTime:D,tickFormatValue:T,decay:W,pulse:$,staleness:N,linkedHover:O,selection:z,onObservation:I,chartId:R,loading:B,emptyContent:j,emphasis:F,legendPosition:Y}=e,H=l.showAxes,X=l.enableHover,G=null!=c?c:l.marginDefaults,q=null!=s?s:[l.width,l.height],V=null!=S?S:P,K=t.useRef(null),{customHoverBehavior:Z}=jn({selection:z,linkedHover:O,unwrapData:!0,onObservation:I,chartType:"RealtimeHeatmap",chartId:R}),U=t.useCallback(t=>{_&&_(t),Z(t)},[_,Z]);t.useImperativeHandle(n,()=>({push:t=>{var e;return null===(e=K.current)||void 0===e?void 0:e.push(t)},pushMany:t=>{var e;return null===(e=K.current)||void 0===e?void 0:e.pushMany(t)},clear:()=>{var t;return null===(t=K.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,e;return null!==(e=null===(t=K.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[]}}));const Q=qn(B,q[0],q[1]);if(Q)return Q;const J=Gn(y,q[0],q[1],j);return J||g.createElement(te,{ref:K,chartType:"heatmap",runtimeMode:"streaming",size:q,margin:G,className:F?`${u||""} semiotic-emphasis-${F}`.trim():u,arrowOfTime:h,windowMode:d,windowSize:f,data:y,timeAccessor:p,valueAccessor:v,categoryAccessor:m,xExtent:x,yExtent:b,extentPadding:k,heatmapXBins:w,heatmapYBins:E,heatmapAggregation:A,showAxes:H,background:M,hoverAnnotation:X,tooltipContent:V,customHoverBehavior:U,annotations:L,svgAnnotationRules:C,tickFormatTime:D,tickFormatValue:T,decay:W,pulse:$,staleness:N,legendPosition:Y})});Jn.displayName="RealtimeHeatmap",exports.IncrementalExtent=x,exports.RealtimeHeatmap=Jn,exports.RealtimeHistogram=Zn,exports.RealtimeLineChart=Vn,exports.RealtimeSwarmChart=Un,exports.RealtimeWaterfallChart=Qn,exports.RingBuffer=m,exports.StreamNetworkFrame=Wn,exports.StreamXYFrame=te;