semiotic 3.0.0-beta.6 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import*as e from"react";import{useRef as t,useState as n,useEffect as o,useMemo as r,forwardRef as i,useCallback as a,useImperativeHandle as s,useContext as l,createContext as c,useLayoutEffect as u,useId as d}from"react";import{brushX as h,brushY as g,brush as p}from"d3-brush";import{select as y}from"d3-selection";import{scaleLinear as f,scaleBand as m,scaleOrdinal as v,scaleSequential as b}from"d3-scale";import{bin as x,quantile as w,min as k,groups as A,max as E,sum as S,mean as O,group as L}from"d3-array";import{packEnclose as j,hierarchy as P,partition as M,pack as N,treemap as D,treemapBinary as C,cluster as T,tree as B}from"d3-hierarchy";import{interpolateNumber as W}from"d3-interpolate";import{schemeCategory10 as H,interpolatePlasma as $,interpolateViridis as _,interpolatePurples as z,interpolateOranges as I,interpolateGreens as R,interpolateReds as F,interpolateBlues as Y,schemeSet3 as G,schemeTableau10 as X}from"d3-scale-chromatic";import{forceLink as q,forceSimulation as V,forceManyBody as U,forceX as Z,forceY as Q}from"d3-force";import{ribbon as K,chord as J}from"d3-chord";import{arc as ee}from"d3-shape";const te=5e3;class ne{constructor(e){this.lastBoundedData=null,this.chunkTimer=0,this.callback=e}clearLastData(){this.lastBoundedData=null,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(e){if(e===this.lastBoundedData)return;if(this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),5e3>=e.length)return void this.callback({inserts:e,bounded:!0});this.callback({inserts:e.slice(0,te),bounded:!0,totalSize:e.length});let t=te;const n=()=>{if(t>=e.length)return;if(e!==this.lastBoundedData)return;const o=Math.min(t+te,e.length);this.callback({inserts:e.slice(t,o),bounded:!1}),t=o,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}push(e){this.callback({inserts:[e],bounded:!1})}pushMany(e){0!==e.length&&this.callback({inserts:e,bounded:!1})}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null}}class oe{constructor(e){if(this._capacity=e,this.head=0,this._size=0,1>e)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(e)}push(e){let t;return this._size===this._capacity?t=this.buffer[this.head]:this._size++,this.buffer[this.head]=e,this.head=(this.head+1)%this._capacity,t}pushMany(e){const t=[];for(const n of e){const e=this.push(n);void 0!==e&&t.push(e)}return t}get(e){if(e>=0&&this._size>e)return this.buffer[(this.head-this._size+e+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let e=0;const t=this;return{next:()=>t._size>e?{done:!1,value:t.get(e++)}:{done:!0,value:void 0}}}toArray(){const e=[];for(const t of this)e.push(t);return e}resize(e){if(1>e)throw Error("RingBuffer capacity must be at least 1");const t=this.toArray(),n=[];for(;t.length>e;)n.push(t.shift());this._capacity=e,this.buffer=Array(e),this.head=0,this._size=0;for(const e of t)this.push(e);return n}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}}class re{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(e){Number.isNaN(e)||(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}evict(e){e!==this._min&&e!==this._max||(this._dirty=!0)}recalculate(e,t){this._min=1/0,this._max=-1/0;for(const n of e){const e=t?t(n):n;Number.isNaN(e)||(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}this._dirty=!1}clear(){this._min=1/0,this._max=-1/0,this._dirty=!1}get extent(){return[this._min,this._max]}get min(){return this._min}get max(){return this._max}get dirty(){return this._dirty}}function ie(e,t,n,o,r){const i=new Map;for(const a of e){const e=t(a),s=n(a);if(null==e||null==s||Number.isNaN(e)||Number.isNaN(s))continue;const l=Math.floor(e/o)*o;let c=i.get(l);if(c||(c={start:l,end:l+o,total:0,categories:new Map},i.set(l,c)),c.total+=s,r){const e=r(a);c.categories.set(e,(c.categories.get(e)||0)+s)}}return i}function ae(e,t,n,o,r,i){const a=[],s=[];for(const r of e){const e=n(r),i=o(r);null==e||null==i||Number.isNaN(e)||Number.isNaN(i)||(a.push([t.x(e),t.y(i)]),s.push(i))}return{type:"line",path:a,rawValues:s,style:r,datum:e,group:i}}function se(e,t,n,o,r,i,a,s){const l=[],c=[];for(const i of e){const e=n(i),a=o(i);if(null==e||null==a||Number.isNaN(e)||Number.isNaN(a))continue;const u=t.x(e);l.push([u,t.y(a)]);const d=s?s(i):r;c.push([u,t.y(d)])}return{type:"area",topPath:l,bottomPath:c,style:i,datum:e,group:a}}function le(e,t,n,o,r,i,a){const s=n(e),l=o(e);if(null==s||null==l||Number.isNaN(s)||Number.isNaN(l))return null;const c={type:"point",x:t.x(s),y:t.y(l),r:r,style:i,datum:e};return void 0!==a&&(c.pointId=a),c}function ce(e,t,n,o,r,i,a){return{type:"rect",x:e,y:t,w:n,h:o,style:r,datum:i,group:a}}function ue(e,t,n,o,r,i){return{type:"heatcell",x:e,y:t,w:n,h:o,fill:r,datum:i}}function de(e,t){if("function"==typeof e)return t=>+e(t);const n=e||t;return e=>+e[n]}function he(e,t){return"function"==typeof e?e:e?t=>t[e]+"":t?e=>e[t]+"":void 0}class ge{constructor(e){this.xExtent=new re,this.yExtent=new re,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.lastIngestTime=0,this.scales=null,this.scene=[],this.version=0,this.config=e,this.buffer=new oe(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=de(e.timeAccessor||e.xAccessor,"time"),this.getY=de(e.valueAccessor||e.yAccessor,"value")):(this.getX=de(e.xAccessor,"x"),this.getY=de(e.yAccessor,"y")),this.getGroup=he(e.groupAccessor),this.getCategory=he(e.categoryAccessor),this.getSize=e.sizeAccessor?de(e.sizeAccessor,"size"):void 0,this.getColor=he(e.colorAccessor),this.getBounds=e.boundsAccessor?de(e.boundsAccessor,"bounds"):void 0,this.getY0=e.y0Accessor?de(e.y0Accessor,"y0"):void 0,this.getPointId=he(e.pointIdAccessor),"candlestick"===e.chartType&&(this.getOpen=de(e.openAccessor,"open"),this.getHigh=de(e.highAccessor,"high"),this.getLow=de(e.lowAccessor,"low"),this.getClose=de(e.closeAccessor,"close")),e.pulse&&(this.timestampBuffer=new oe(e.windowSize))}ingest(e){const t="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=t,e.bounded){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const n=e.totalSize||e.inserts.length;n>this.buffer.capacity&&(this.buffer.resize(n),this.timestampBuffer&&n>this.timestampBuffer.capacity&&this.timestampBuffer.resize(n));for(const n of e.inserts)this.buffer.push(n),this.timestampBuffer&&this.timestampBuffer.push(t),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):(this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n)))}else for(const n of e.inserts){"growing"===this.config.windowMode&&this.buffer.full&&(this.growingCap*=2,this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap));const e=this.buffer.push(n);this.timestampBuffer&&this.timestampBuffer.push(t),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):(this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n))),null!=e&&(this.xExtent.evict(this.getX(e)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(e)),this.yExtent.evict(this.getLow(e))):this.yExtent.evict(this.getY(e)))}return!0}computeScene(e){var t,n,o,r,i,a;const{config:s,buffer:l}=this;if(this.xExtent.dirty&&this.xExtent.recalculate(l,this.getX),this.yExtent.dirty)if("candlestick"===s.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const e of l)this.yExtent.push(this.getHigh(e)),this.yExtent.push(this.getLow(e))}else this.yExtent.recalculate(l,this.getY);const c=this.xExtent.extent,u=this.yExtent.extent;let d=s.xExtent?[null!==(t=s.xExtent[0])&&void 0!==t?t:c[0],null!==(n=s.xExtent[1])&&void 0!==n?n:c[1]]:c,h=s.yExtent?[null!==(o=s.yExtent[0])&&void 0!==o?o:u[0],null!==(r=s.yExtent[1])&&void 0!==r?r:u[1]]:u;const g=s.yExtent&&null!=s.yExtent[0]&&null!=s.yExtent[1];if("stackedarea"===s.chartType&&!g&&l.size>0)if(s.normalize)h=[0,1+s.extentPadding];else{const e=l.toArray(),t=this.groupData(e),n=new Map;for(const e of t)for(const t of e.data){const e=this.getX(t),o=this.getY(t);null==e||null==o||Number.isNaN(e)||Number.isNaN(o)||n.set(e,(n.get(e)||0)+o)}let o=0;for(const e of n.values())e>o&&(o=e);h=[0,o+(o>0?o*s.extentPadding:1)]}else if("bar"===s.chartType&&s.binSize&&!g&&l.size>0){const[,e]=function(e,t,n,o,r){const i=ie(e,t,n,o,r);if(0===i.size)return[0,0];let a=0;for(const e of i.values())e.total>a&&(a=e.total);return[0,a]}(l,this.getX,this.getY,s.binSize,this.getCategory);h=[0,e+e*s.extentPadding]}else if("waterfall"===s.chartType&&!g&&l.size>0){const[e,t]=function(e,t){let n=0,o=0,r=0;for(const i of e){const e=t(i);null==e||Number.isNaN(e)||(r+=e,n>r&&(n=r),r>o&&(o=r))}return[n,o]}(l,this.getY),n=t-e,o=n>0?n*s.extentPadding:1;h=[Math.min(0,e-Math.abs(o)),Math.max(0,t+Math.abs(o))]}else if(!g&&h[0]!==1/0){if(this.getBounds){const e=l.toArray();for(const t of e){const e=this.getY(t),n=this.getBounds(t);null!=e&&!Number.isNaN(e)&&n&&(e+n>h[1]&&(h[1]=e+n),h[0]>e-n&&(h[0]=e-n))}}const e=h[1]-h[0],t=e>0?e*s.extentPadding:1,n=null===(i=s.yExtent)||void 0===i?void 0:i[0],o=null===(a=s.yExtent)||void 0===a?void 0:a[1];h=[null!=n?h[0]:h[0]-t,null!=o?h[1]:h[1]+t]}if(d[0]!==1/0&&d[1]!==-1/0||(d=[0,1]),h[0]!==1/0&&h[1]!==-1/0||(h=[0,1]),void 0!==s.arrowOfTime)if("x"==("up"===(p=s.arrowOfTime)||"down"===p?"y":"x")){const t="right"===s.arrowOfTime?[0,e.width]:[e.width,0];this.scales={x:f().domain(d).range(t),y:f().domain(h).range([e.height,0])}}else{const t="down"===s.arrowOfTime?[0,e.height]:[e.height,0];this.scales={x:f().domain(h).range([0,e.width]),y:f().domain(d).range(t)}}else this.scales={x:f().domain(d).range([0,e.width]),y:f().domain(h).range([e.height,0])};var p;this.config.transition&&this.scene.length>0&&this.snapshotPositions();const y=l.toArray();this.scene=this.buildSceneNodes(e),this.config.decay&&this.applyDecay(this.scene,y),this.config.pulse&&this.applyPulse(this.scene,y),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++}buildSceneNodes(e){const{config:t,buffer:n,scales:o}=this;if(!o||0===n.size)return[];const r=n.toArray();switch(t.chartType){case"line":return this.buildLineScene(r);case"area":return this.buildAreaScene(r);case"stackedarea":return this.buildStackedAreaScene(r);case"scatter":case"bubble":return this.buildPointScene(r);case"heatmap":return this.buildHeatmapScene(r,e);case"bar":return this.buildBarScene(r);case"swarm":return this.buildSwarmScene(r);case"waterfall":return this.buildWaterfallScene(r,e);case"candlestick":return this.buildCandlestickScene(r,e);default:return[]}}buildLineScene(e){var t;const n=this.groupData(e),o=[],r=null===(t=this.config.annotations)||void 0===t?void 0:t.filter(e=>"threshold"===e.type&&e.color).map(e=>({value:e.value,color:e.color,thresholdType:e.thresholdType||"greater"}));if(this.getBounds)for(const e of n){const t=this.buildBoundsForGroup(e.data,e.key);t&&o.push(t)}for(const e of n){const t=this.resolveLineStyle(e.key,e.data[0]),n=ae(e.data,this.scales,this.getX,this.getY,t,e.key);r&&r.length>0&&(n.colorThresholds=r),o.push(n)}return o}buildAreaScene(e){const t=this.groupData(e),n=[],o=this.scales.y.domain()[0];for(const e of t){const t=this.resolveAreaStyle(e.key,e.data[0]),r=se(e.data,this.scales,this.getX,this.getY,o,t,e.key,this.getY0);this.config.gradientFill&&(r.fillGradient=this.config.gradientFill),n.push(r)}return n}buildStackedAreaScene(e){const t=this.groupData(e);return t.sort((e,t)=>t.key>e.key?-1:e.key>t.key?1:0),function(e,t,n,o,r,i){var a;const s=new Set;for(const t of e)for(const e of t.data){const t=n(e);null==t||Number.isNaN(t)||s.add(t)}const l=Array.from(s).sort((e,t)=>e-t),c=new Map;for(const t of e){const e=new Map;for(const r of t.data){const t=n(r),i=o(r);null==t||null==i||Number.isNaN(t)||Number.isNaN(i)||e.set(t,(e.get(t)||0)+i)}c.set(t.key,e)}let u;if(i){u=new Map;for(const t of l){let n=0;for(const o of e)n+=(null===(a=c.get(o.key))||void 0===a?void 0:a.get(t))||0;u.set(t,n||1)}}const d=[],h=new Map;for(const e of l)h.set(e,0);for(const n of e){const e=c.get(n.key),o=[],a=[];for(const n of l){let r=e.get(n)||0;const s=h.get(n);i&&(r/=u.get(n));const l=t.x(n);a.push([l,t.y(s)]),o.push([l,t.y(s+r)]),h.set(n,s+r)}d.push({type:"area",topPath:o,bottomPath:a,style:r(n.key,n.data[0]),datum:n.data,group:n.key})}return d}(t,this.scales,this.getX,this.getY,(e,t)=>this.resolveAreaStyle(e,t),this.config.normalize)}buildPointScene(e){const t=[],n="bubble"===this.config.chartType?10:5,o=this.config.sizeRange||[3,15];let r=null;if(this.getSize&&!this.config.pointStyle){const t=e.map(e=>this.getSize(e)).filter(e=>null!=e&&!Number.isNaN(e));if(t.length>0){const e=Math.min(...t),n=Math.max(...t);r=t=>e===n?(o[0]+o[1])/2:o[0]+(t-e)/(n-e)*(o[1]-o[0])}}let i=null;if(this.getColor&&!this.config.pointStyle){const t=new Set;for(const n of e){const e=this.getColor(n);e&&t.add(e)}const n=Array.isArray(this.config.colorScheme)?this.config.colorScheme:["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];i=new Map;let o=0;for(const e of t)i.set(e,n[o%n.length]),o++}for(const o of e){let e=this.config.pointStyle?this.config.pointStyle(o):{fill:"#4e79a7",opacity:.8},a=e.r||n;if(r&&this.getSize){const e=this.getSize(o);null==e||Number.isNaN(e)||(a=r(e))}if(i&&this.getColor){const t=this.getColor(o);t&&i.has(t)&&(e=Object.assign(Object.assign({},e),{fill:i.get(t)}))}const s=this.getPointId?this.getPointId(o)+"":void 0,l=le(o,this.scales,this.getX,this.getY,a,e,s);l&&t.push(l)}return t}buildHeatmapScene(e,t){const n=[];if(this.config.heatmapAggregation)return this.buildStreamingHeatmapScene(e,t);const o=de(this.config.valueAccessor,"value"),r=new Set,i=new Set;for(const t of e)r.add(this.getX(t)),i.add(this.getY(t));const a=Array.from(r).sort((e,t)=>e-t),s=Array.from(i).sort((e,t)=>e-t);if(0===a.length||0===s.length)return n;const l=t.width/a.length,c=t.height/s.length,u=new Map;for(const t of e){const e=`${this.getX(t)}_${this.getY(t)}`;u.set(e,{val:o(t),datum:t})}let d=1/0,h=-1/0;for(const{val:e}of u.values())d>e&&(d=e),e>h&&(h=e);const g=h-d||1;for(let e=0;a.length>e;e++)for(let t=0;s.length>t;t++){const o=u.get(`${a[e]}_${s[t]}`);if(!o)continue;const r=(o.val-d)/g;n.push(ue(e*l,(s.length-1-t)*c,l,c,`rgb(${Math.round(220-180*r)},${Math.round(220-100*r)},${Math.round(255-50*r)})`,o.datum))}return n}buildStreamingHeatmapScene(e,t){var n,o,r;const i=[],a=null!==(n=this.config.heatmapXBins)&&void 0!==n?n:20,s=null!==(o=this.config.heatmapYBins)&&void 0!==o?o:20,l=null!==(r=this.config.heatmapAggregation)&&void 0!==r?r:"count",c=de(this.config.valueAccessor,"value");if(!this.scales||0===e.length)return i;const[u,d]=this.scales.x.domain(),[h,g]=this.scales.y.domain(),p=(d-u||1)/a,y=(g-h||1)/s,f=new Map;for(const t of e){const e=this.getX(t),n=this.getY(t),o=Math.min(Math.floor((e-u)/p),a-1),r=Math.min(Math.floor((n-h)/y),s-1);if(0>o||0>r)continue;const i=`${o}_${r}`;let l=f.get(i);l||(l={sum:0,count:0,data:[]},f.set(i,l)),l.count++,l.sum+=c(t),l.data.push(t)}let m=1/0,v=-1/0;const b=new Map;for(const[e,t]of f){let n;switch(l){case"sum":n=t.sum;break;case"mean":n=t.count>0?t.sum/t.count:0;break;default:n=t.count}b.set(e,n),m>n&&(m=n),n>v&&(v=n)}const x=v-m||1,w=t.width/a,k=t.height/s;for(const[e,t]of b){const[n,o]=e.split("_"),r=+n,a=+o,l=(t-m)/x,c=`rgb(${Math.round(220-180*l)},${Math.round(220-100*l)},${Math.round(255-50*l)})`,u=f.get(e);i.push(ue(r*w,(s-1-a)*k,w,k,c,{xi:r,yi:a,value:t,count:u.count,sum:u.sum,data:u.data}))}return i}buildBarScene(e){var t;if(!this.config.binSize)return[];const n=ie(e,this.getX,this.getY,this.config.binSize,this.getCategory);if(0===n.size)return[];let o=null;if(this.getCategory){const e=new Set;for(const t of n.values())for(const n of t.categories.keys())e.add(n);const t=this.config.barColors?Object.keys(this.config.barColors):[],r=new Set(t),i=Array.from(e).filter(e=>!r.has(e)).sort();o=[...t.filter(t=>e.has(t)),...i]}const r=[],i=this.scales,[a,s]=i.x.domain();for(const e of n.values()){const n=Math.max(e.start,a),l=Math.min(e.end,s);if(n>=l)continue;const c=i.x(n),u=i.x(l),d=Math.min(c,u)+.5,h=Math.max(c,u)-.5-d;if(h>0)if(o&&e.categories.size>0){let n=0;for(const a of o){const o=e.categories.get(a)||0;if(0===o)continue;const s=i.y(n),l=i.y(n+o);r.push(ce(d,Math.min(s,l),h,Math.abs(s-l),{fill:(null===(t=this.config.barColors)||void 0===t?void 0:t[a])||"#4e79a7"},{binStart:e.start,binEnd:e.end,total:e.total,category:a,categoryValue:o},a)),n+=o}}else{const t=i.y(0),n=i.y(e.total);r.push(ce(d,Math.min(t,n),h,Math.abs(t-n),{fill:"#007bff"},{binStart:e.start,binEnd:e.end,total:e.total}))}}return r}buildSwarmScene(e){var t,n,o,r;const i=[],a=this.config.swarmStyle||{},s=null!==(t=a.radius)&&void 0!==t?t:3,l=null!==(n=a.fill)&&void 0!==n?n:"#007bff",c=null!==(o=a.opacity)&&void 0!==o?o:.7,u=a.stroke,d=a.strokeWidth;for(const t of e){const e=this.getX(t),n=this.getY(t);if(null==n||Number.isNaN(n))continue;const o=this.scales.x(e),a=this.scales.y(n);let h=l;if(this.getCategory){const e=this.getCategory(t);h=(null===(r=this.config.barColors)||void 0===r?void 0:r[e])||h}const g={type:"point",x:o,y:a,r:s,style:{fill:h,opacity:c,stroke:u,strokeWidth:d},datum:t};this.getPointId&&(g.pointId=this.getPointId(t)+""),i.push(g)}return i}buildWaterfallScene(e,t){var n,o,r;const i=[],a=this.scales,s=this.config.waterfallStyle,l=e.filter(e=>{const t=this.getY(e);return null!=t&&!Number.isNaN(t)});if(0===l.length)return i;const c=null!==(n=null==s?void 0:s.positiveColor)&&void 0!==n?n:"#28a745",u=null!==(o=null==s?void 0:s.negativeColor)&&void 0!==o?o:"#dc3545",d=null!==(r=null==s?void 0:s.gap)&&void 0!==r?r:1,h=null==s?void 0:s.stroke,g=null==s?void 0:s.strokeWidth;let p=0;for(let e=0;l.length>e;e++){const n=l[e],o=this.getX(n),r=this.getY(n),y=p+r;let f;f=l.length-1>e?this.getX(l[e+1])-o:e>0?o-this.getX(l[e-1]):0;const m=a.x(o),v=0!==f?a.x(o+f):m+t.width/10,b=Math.min(m,v)+d/2,x=Math.max(m,v)-d/2-b;if(0>=x){p=y;continue}const w=a.y(p),k=a.y(y);i.push(ce(b,Math.min(w,k),x,Math.abs(w-k),{fill:0>r?u:c,stroke:h,strokeWidth:g},Object.assign(Object.assign({},n),{baseline:p,cumEnd:y,delta:r,_connectorStroke:null==s?void 0:s.connectorStroke,_connectorWidth:null==s?void 0:s.connectorWidth}))),p=y}return i}buildCandlestickScene(e,t){if(!(this.getOpen&&this.getHigh&&this.getLow&&this.getClose&&this.scales))return[];const n=[],o=this.config.candlestickStyle||{},r=o.upColor||"#28a745",i=o.downColor||"#dc3545",a=o.wickColor||"#333",s=o.wickWidth||1,l=e.map(e=>this.getX(e)).filter(e=>null!=e&&!Number.isNaN(e)).sort((e,t)=>e-t);let c=o.bodyWidth||6;if(!o.bodyWidth&&l.length>1){let e=1/0;for(let t=1;l.length>t;t++){const n=Math.abs(this.scales.x(l[t])-this.scales.x(l[t-1]));n>0&&e>n&&(e=n)}e!==1/0&&(c=Math.max(2,Math.min(.6*e,20)))}for(const t of e){const e=this.getX(t);if(null==e||Number.isNaN(e))continue;const o=this.getOpen(t),l=this.getHigh(t),u=this.getLow(t),d=this.getClose(t);if([o,l,u,d].some(e=>null==e||Number.isNaN(e)))continue;const h=d>=o;n.push({type:"candlestick",x:this.scales.x(e),openY:this.scales.y(o),closeY:this.scales.y(d),highY:this.scales.y(l),lowY:this.scales.y(u),bodyWidth:c,upColor:r,downColor:i,wickColor:a,wickWidth:s,isUp:h,datum:t})}return n}buildBoundsForGroup(e,t){if(!this.getBounds||!this.scales)return null;const n=[],o=[];for(const t of e){const e=this.getX(t),r=this.getY(t);if(null==e||null==r||Number.isNaN(e)||Number.isNaN(r))continue;const i=this.getBounds(t),a=this.scales.x(e);if(i&&0!==i)n.push([a,this.scales.y(r+i)]),o.push([a,this.scales.y(r-i)]);else{const e=this.scales.y(r);n.push([a,e]),o.push([a,e])}}return 2>n.length?null:{type:"area",topPath:n,bottomPath:o,style:this.resolveBoundsStyle(t,e[0]),datum:e,group:t,interactive:!1}}resolveBoundsStyle(e,t){const n=this.config.boundsStyle;return"function"==typeof n?n(t||{},e):n&&"object"==typeof n?n:{fill:this.resolveLineStyle(e,t).stroke||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(e,t){var n,o,r;const i=this.config.decay;if(!i||1>=t)return 1;const a=null!==(n=i.minOpacity)&&void 0!==n?n:.1,s=t-1-e;switch(i.type){case"linear":return a+(1-s/(t-1))*(1-a);case"exponential":{const e=null!==(o=i.halfLife)&&void 0!==o?o:t/2;return a+Math.pow(.5,s/e)*(1-a)}case"step":return(null!==(r=i.stepThreshold)&&void 0!==r?r:.5*t)>s?1:a;default:return 1}}applyDecay(e,t){var n,o;if(!this.config.decay)return;const r=t.length;if(1>=r)return;const i=new Map;for(let e=0;t.length>e;e++)i.set(t[e],e);for(const t of e){if("line"===t.type||"area"===t.type)continue;const e=i.get(t.datum);if(null==e)continue;const a=this.computeDecayOpacity(e,r);if("heatcell"===t.type)t.style={opacity:a};else if("candlestick"===t.type)t._decayOpacity=a;else{const e=null!==(o=null===(n=t.style)||void 0===n?void 0:n.opacity)&&void 0!==o?o:1;t.style=Object.assign(Object.assign({},t.style),{opacity:e*a})}}}computePulseIntensity(e,t){var n;const o=this.config.pulse;if(!o)return 0;const r=null!==(n=o.duration)&&void 0!==n?n:500,i=t-e;return r>i?1-i/r:0}applyPulse(e,t){var n,o;if(!this.config.pulse||!this.timestampBuffer)return;const r="undefined"!=typeof performance?performance.now():Date.now(),i=null!==(n=this.config.pulse.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",a=null!==(o=this.config.pulse.glowRadius)&&void 0!==o?o:4,s=new Map;for(let e=0;t.length>e;e++)s.set(t[e],e);for(const t of e){if("line"===t.type||"area"===t.type)continue;const e=s.get(t.datum);if(null==e)continue;const n=this.timestampBuffer.get(e);if(null==n)continue;const o=this.computePulseIntensity(n,r);o>0&&(t._pulseIntensity=o,t._pulseColor=i,t._pulseGlowRadius=a)}}get hasActivePulses(){var e;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const t="undefined"!=typeof performance?performance.now():Date.now(),n=null!==(e=this.config.pulse.duration)&&void 0!==e?e:500,o=this.timestampBuffer.peek();return null!=o&&n>t-o}snapshotPositions(){this.prevPositionMap.clear();for(let e=0;this.scene.length>e;e++){const t=this.scene[e],n=this.getNodeIdentity(t,e);n&&("point"===t.type?this.prevPositionMap.set(n,{x:t.x,y:t.y,r:t.r}):"rect"===t.type||"heatcell"===t.type?this.prevPositionMap.set(n,{x:t.x,y:t.y,w:t.w,h:t.h}):"candlestick"===t.type&&this.prevPositionMap.set(n,{x:t.x,y:t.openY}))}}getNodeIdentity(e,t){var n,o,r,i;switch(e.type){case"point":return`p:${void 0===e.datum?t:this.getX(e.datum)}_${this.getY(e.datum)}`;case"rect":return`r:${e.group||""}:${null!==(i=null!==(o=null===(n=e.datum)||void 0===n?void 0:n.binStart)&&void 0!==o?o:null===(r=e.datum)||void 0===r?void 0:r.category)&&void 0!==i?i:t}`;case"heatcell":return`h:${e.x}_${e.y}`;case"candlestick":return"c:"+this.getX(e.datum);default:return null}}startTransition(){var e,t,n,o,r,i;if(!this.config.transition||0===this.prevPositionMap.size)return;const a=null!==(e=this.config.transition.duration)&&void 0!==e?e:300;let s=!1;for(let e=0;this.scene.length>e;e++){const a=this.scene[e],l=this.getNodeIdentity(a,e);if(!l)continue;const c=this.prevPositionMap.get(l);if(c)if("point"===a.type){const e={x:a.x,y:a.y,r:a.r};c.x===e.x&&c.y===e.y||(a._targetX=e.x,a._targetY=e.y,a._targetR=e.r,a.x=c.x,a.y=c.y,a.r=null!==(t=c.r)&&void 0!==t?t:a.r,s=!0)}else if("rect"===a.type){const e={x:a.x,y:a.y,w:a.w,h:a.h};c.x===e.x&&c.y===e.y&&c.w===e.w&&c.h===e.h||(a._targetX=e.x,a._targetY=e.y,a._targetW=e.w,a._targetH=e.h,a.x=c.x,a.y=c.y,a.w=null!==(n=c.w)&&void 0!==n?n:a.w,a.h=null!==(o=c.h)&&void 0!==o?o:a.h,s=!0)}else if("heatcell"===a.type){const e={x:a.x,y:a.y,w:a.w,h:a.h};c.x===e.x&&c.y===e.y||(a._targetX=e.x,a._targetY=e.y,a._targetW=e.w,a._targetH=e.h,a.x=c.x,a.y=c.y,a.w=null!==(r=c.w)&&void 0!==r?r:a.w,a.h=null!==(i=c.h)&&void 0!==i?i:a.h,s=!0)}}s&&(this.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:a})}advanceTransition(e){var t;if(!this.activeTransition)return!1;const n=Math.min((e-this.activeTransition.startTime)/this.activeTransition.duration,1),o="linear"===(null===(t=this.config.transition)||void 0===t?void 0:t.easing)?n:1-Math.pow(1-n,3);for(const e of this.scene)if("point"===e.type){if(void 0===e._targetX)continue;const t=this.getNodeIdentity(e,0);if(!t)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=n.x+(e._targetX-n.x)*o,e.y=n.y+(e._targetY-n.y)*o,void 0!==e._targetR&&void 0!==n.r&&(e.r=n.r+(e._targetR-n.r)*o)}else if("rect"===e.type){if(void 0===e._targetX)continue;const t=this.getNodeIdentity(e,0);if(!t)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=n.x+(e._targetX-n.x)*o,e.y=n.y+(e._targetY-n.y)*o,void 0!==n.w&&(e.w=n.w+(e._targetW-n.w)*o),void 0!==n.h&&(e.h=n.h+(e._targetH-n.h)*o)}else if("heatcell"===e.type){if(void 0===e._targetX)continue;const t=this.getNodeIdentity(e,0);if(!t)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=n.x+(e._targetX-n.x)*o,e.y=n.y+(e._targetY-n.y)*o,void 0!==n.w&&(e.w=n.w+(e._targetW-n.w)*o),void 0!==n.h&&(e.h=n.h+(e._targetH-n.h)*o)}if(n>=1){for(const e of this.scene)if("point"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,void 0!==e._targetR&&(e.r=e._targetR),e._targetX=void 0,e._targetY=void 0,e._targetR=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("heatcell"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}return this.activeTransition=null,!1}return!0}groupData(e){if(!this.getGroup)return[{key:"_default",data:e}];const t=new Map;for(const n of e){const e=this.getGroup(n);t.has(e)||t.set(e,[]),t.get(e).push(n)}return Array.from(t.entries()).map(([e,t])=>({key:e,data:t}))}resolveLineStyle(e,t){const n=this.config.lineStyle;return"function"==typeof n?n(t||{},e):n&&"object"==typeof n?{stroke:n.stroke||"#007bff",strokeWidth:n.strokeWidth||2,strokeDasharray:n.strokeDasharray,fill:n.fill,fillOpacity:n.fillOpacity,opacity:n.opacity}:{stroke:"#007bff",strokeWidth:2}}resolveAreaStyle(e,t){var n;if(this.config.areaStyle)return this.config.areaStyle(t||{});const o=this.config.lineStyle;return"function"==typeof o?o(t||{},e):o&&"object"==typeof o?{fill:o.fill||o.stroke||"#4e79a7",fillOpacity:null!==(n=o.fillOpacity)&&void 0!==n?n:.7,stroke:o.stroke||"#4e79a7",strokeWidth:o.strokeWidth||2}:{fill:"#4e79a7",fillOpacity:.7,stroke:"#4e79a7",strokeWidth:2}}getData(){return this.buffer.toArray()}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],this.version++}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}updateConfig(e){Object.assign(this.config,e)}}function pe(e,t,n){const o=t-e.x,r=n-e.y,i=Math.sqrt(o*o+r*r);return i>e.r+5?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:i}}function ye(e,t,n){if(0===e.path.length)return null;const o=xe(e.path,t);if(0>o)return null;const[r,i]=e.path[o],a=t-r,s=n-i,l=Math.sqrt(a*a+s*s);return{node:e,datum:Array.isArray(e.datum)&&e.datum[o]?e.datum[o]:e.datum,x:r,y:i,distance:l}}function fe(e,t,n){return e.x>t||t>e.x+e.w||e.y>n||n>e.y+e.h?null:{node:e,datum:e.datum,x:e.x+e.w/2,y:e.y+e.h/2,distance:0}}function me(e,t,n){return e.x>t||t>e.x+e.w||e.y>n||n>e.y+e.h?null:{node:e,datum:e.datum,x:e.x+e.w/2,y:e.y+e.h/2,distance:0}}function ve(e,t,n){const o=e.bodyWidth/2,r=Math.min(e.openY,e.closeY);if(!(e.x-o-3>t||t>e.x+o+3||e.highY-3>n||n>e.lowY+3)){const o=r+Math.max(Math.max(e.openY,e.closeY)-r,1)/2,i=t-e.x,a=n-o;return{node:e,datum:e.datum,x:e.x,y:o,distance:Math.sqrt(i*i+a*a)}}return null}function be(e,t,n){if(0===e.topPath.length)return null;const o=xe(e.topPath,t);if(0>o)return null;const[r,i]=e.topPath[o],a=t-r,s=n-i;return{node:e,datum:e.datum,x:r,y:i,distance:Math.sqrt(a*a+s*s)}}function xe(e,t){if(0===e.length)return-1;let n=0,o=e.length-1;for(;o>n;){const r=n+o>>1;t>e[r][0]?n=r+1:o=r}return n>0&&Math.abs(e[n][0]-t)>=Math.abs(e[n-1][0]-t)?n-1:n}function we(e,t,n){switch(e){case"ArrowRight":case"ArrowDown":return n-1>t?t+1:t;case"ArrowLeft":case"ArrowUp":return t>0?t-1:t;case"Home":return 0;case"End":return n-1;case"Escape":return-1;default:return null}}function ke(e){return{data:e.datum,x:e.x,y:e.y,time:e.x,value:e.y}}function Ae(e,r,i){const a=t(null),[s,l]=n(null);return o(()=>{if(!r&&!i)return;const e=a.current;if(!e)return;const t=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;l(t=>t&&t.w===e&&t.h===n?t:{w:e,h:n})}});return t.observe(e),()=>t.disconnect()},[r,i]),[a,[r&&s?s.w:e[0],i&&s?s.h:e[1]]]}const Ee={fill:t=>e.createElement("rect",{style:t,width:20,height:20}),line:t=>e.createElement("line",{style:t,x1:0,y1:0,x2:20,y2:20})};function Se(e,t,n,o){let r;return r="function"==typeof n?n(e):(0,Ee[n])(o(e,t)),r}function Oe(t){const{legendGroups:n,customClickBehavior:o,title:r="Legend",width:i=100,height:a=20,orientation:s="vertical"}=t,l="vertical"===s?(({legendGroups:t,width:n,customClickBehavior:o})=>{let r=30;const i=[];return t.forEach((t,a)=>{r+=5,i.push(e.createElement("line",{key:"legend-top-line legend-symbol-"+a,stroke:"gray",x1:0,y1:r,x2:n,y2:r})),r+=10,t.label&&(r+=20,i.push(e.createElement("text",{key:"legend-text-"+a,y:r,className:"legend-group-label"},t.label)),r+=10),i.push(e.createElement("g",{key:"legend-group-"+a,className:"legend-item",transform:`translate(0,${r})`},((t,n)=>{const{type:o="fill",styleFn:r,items:i}=t,a=[];let s=0;return i.forEach((t,i)=>{const l=Se(t,i,o,r);a.push(e.createElement("g",{key:"legend-item-"+i,transform:`translate(0,${s})`,onClick:n?()=>n(t):void 0,style:{cursor:n?"pointer":"default"}},l,e.createElement("text",{y:15,x:30},t.label))),s+=25}),a})(t,o))),r+=25*t.items.length+10}),i})({legendGroups:n,width:i,customClickBehavior:o}):(({legendGroups:t,title:n,height:o,customClickBehavior:r})=>{let i=0;const a=[],s=!1===n?10:40;return t.forEach((n,l)=>{n.label&&(a.push(e.createElement("text",{key:"legend-text-"+l,transform:`translate(${i},${s}) rotate(90)`,textAnchor:"start",className:"legend-group-label"},n.label)),i+=20);const c=((t,n)=>{const{type:o="fill",styleFn:r,items:i}=t,a=[];let s=0;return i.forEach((t,i)=>{const l=Se(t,i,o,r);a.push(e.createElement("g",{key:"legend-item-"+i,transform:`translate(${s},0)`,onClick:n?()=>n(t):void 0,style:{cursor:n?"pointer":"default"}},l,e.createElement("text",{y:15,x:25},t.label))),s+=35,s+=8*t.label.length}),{items:a,offset:s}})(n,r);a.push(e.createElement("g",{key:"legend-group-"+l,className:"legend-item",transform:`translate(${i},${s})`},c.items)),i+=c.offset+5,t[l+1]&&a.push(e.createElement("line",{key:"legend-top-line legend-symbol-"+l,stroke:"gray",x1:i,y1:s-10,x2:i,y2:o+s+10})),i+=15}),e.createElement("g",null,!1!==n&&e.createElement("line",{x1:0,x2:i+10,y1:s-10,y2:s-10,stroke:"gray",className:"title-neatline"}),a)})({legendGroups:n,title:r,height:a,customClickBehavior:o});return e.createElement("g",null,void 0!==r&&e.createElement("text",{className:"legend-title",y:20,x:"horizontal"===s?0:i/2,textAnchor:"horizontal"===s?"start":"middle"},r),l)}function Le(e){return"string"==typeof e?{type:e}:e}function je({orient:t,config:n,values:o,scale:i,size:a,length:s}){const l=function(e){var t,n,o,r,i;return{type:e.type,bins:null!==(t=e.bins)&&void 0!==t?t:20,fill:null!==(n=e.fill)&&void 0!==n?n:"#4e79a7",fillOpacity:null!==(o=e.fillOpacity)&&void 0!==o?o:.5,stroke:null!==(r=e.stroke)&&void 0!==r?r:"none",strokeWidth:null!==(i=e.strokeWidth)&&void 0!==i?i:1}}(n),c="top"===t||"bottom"===t,u=r(()=>{if(0===o.length)return null;const n=i.domain(),r=a-8;if("boxplot"===l.type){const n=function(e){const t=[...e].sort((e,t)=>e-t),n=t.length;if(0===n)return null;const o=t[Math.floor(.25*n)],r=t[Math.floor(.5*n)],i=t[Math.floor(.75*n)],a=i-o;return{q1:o,median:r,q3:i,whiskerLow:Math.max(t[0],o-1.5*a),whiskerHigh:Math.min(t[n-1],i+1.5*a)}}(o);if(!n)return null;const{q1:a,median:s,q3:u,whiskerLow:d,whiskerHigh:h}=n,g=Math.min(.5*r,20),p=(r-g)/2+4;if(c){const n=i(a),o=i(u),r=i(s),c=i(d),y=i(h),f="top"===t?-1:1,m=0;return e.createElement("g",{"data-testid":"marginal-boxplot-"+t},e.createElement("line",{x1:c,y1:m+f*(p+g/2),x2:y,y2:m+f*(p+g/2),stroke:l.fill,strokeWidth:l.strokeWidth}),e.createElement("line",{x1:c,y1:m+f*p,x2:c,y2:m+f*(p+g),stroke:l.fill,strokeWidth:l.strokeWidth}),e.createElement("line",{x1:y,y1:m+f*p,x2:y,y2:m+f*(p+g),stroke:l.fill,strokeWidth:l.strokeWidth}),e.createElement("rect",{x:Math.min(n,o),y:"top"===t?m-p-g:m+p,width:Math.abs(o-n),height:g,fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}),e.createElement("line",{x1:r,y1:"top"===t?m-p-g:m+p,x2:r,y2:"top"===t?m-p:m+p+g,stroke:l.fill,strokeWidth:2}))}{const n=i(a),o=i(u),r=i(s),c=i(d),y=i(h),f="left"===t?-1:1,m=0;return e.createElement("g",{"data-testid":"marginal-boxplot-"+t},e.createElement("line",{x1:m+f*(p+g/2),y1:c,x2:m+f*(p+g/2),y2:y,stroke:l.fill,strokeWidth:l.strokeWidth}),e.createElement("line",{x1:m+f*p,y1:c,x2:m+f*(p+g),y2:c,stroke:l.fill,strokeWidth:l.strokeWidth}),e.createElement("line",{x1:m+f*p,y1:y,x2:m+f*(p+g),y2:y,stroke:l.fill,strokeWidth:l.strokeWidth}),e.createElement("rect",{x:"left"===t?m-p-g:m+p,y:Math.min(n,o),width:g,height:Math.abs(o-n),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}),e.createElement("line",{x1:"left"===t?m-p-g:m+p,y1:r,x2:"left"===t?m-p:m+p+g,y2:r,stroke:l.fill,strokeWidth:2}))}}const u=x().domain(n).thresholds(l.bins)(o);if(0===u.length)return null;const d=Math.max(...u.map(e=>e.length));if(0===d)return null;if("histogram"===l.type)return e.createElement("g",{"data-testid":"marginal-histogram-"+t},u.map((n,o)=>{if(null==n.x0||null==n.x1)return null;const a=n.length/d*r;if(c){const r=i(n.x0),s=i(n.x1)-i(n.x0);return e.createElement("rect",{key:o,x:r,y:"top"===t?-4-a:4,width:Math.max(s,.5),height:a,fill:l.fill,fillOpacity:l.fillOpacity,stroke:l.stroke,strokeWidth:l.strokeWidth})}{const r=i(n.x0),s=i(n.x1)-i(n.x0);return e.createElement("rect",{key:o,x:"left"===t?-4-a:4,y:Math.min(r,r+s),width:a,height:Math.abs(s),fill:l.fill,fillOpacity:l.fillOpacity,stroke:l.stroke,strokeWidth:l.strokeWidth})}}));if("violin"===l.type){const n=r/2+4,o=[];for(const e of u){if(null==e.x0||null==e.x1)continue;const a=e.length/d*(r/2),s=i((e.x0+e.x1)/2);o.push(c?`${s},${"top"===t?-(n-a):n-a}`:`${"left"===t?-(n-a):n-a},${s}`)}for(let e=u.length-1;e>=0;e--){const a=u[e];if(null==a.x0||null==a.x1)continue;const s=a.length/d*(r/2),l=i((a.x0+a.x1)/2);o.push(c?`${l},${"top"===t?-(n+s):n+s}`:`${"left"===t?-(n+s):n+s},${l}`)}return e.createElement("g",{"data-testid":"marginal-violin-"+t},e.createElement("polygon",{points:o.join(" "),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}))}if("ridgeline"===l.type){const n=[];if(c){const e=0,o=null!=u[0].x0?i(u[0].x0):0;n.push(`M${o},${e}`);for(const e of u){if(null==e.x0||null==e.x1)continue;const o=e.length/d*r,a=i((e.x0+e.x1)/2);n.push(`L${a},${"top"===t?-o-4:o+4}`)}const a=null!=u[u.length-1].x1?i(u[u.length-1].x1):s;n.push(`L${a},${e}`),n.push("Z")}else{const e=0,o=null!=u[0].x0?i(u[0].x0):0;n.push(`M${e},${o}`);for(const e of u){if(null==e.x0||null==e.x1)continue;const o=e.length/d*r,a=i((e.x0+e.x1)/2);n.push(`L${"left"===t?-o-4:o+4},${a}`)}const a=null!=u[u.length-1].x1?i(u[u.length-1].x1):s;n.push(`L${e},${a}`),n.push("Z")}return e.createElement("g",{"data-testid":"marginal-ridgeline-"+t},e.createElement("path",{d:n.join(" "),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}))}return null},[o,i,l,a,s,t,c,4]);return u?e.createElement("g",{className:"marginal-"+t,"data-testid":"marginal-"+t},u):null}function Pe(e,t=120,n=8){if(!e)return[];const o=Math.max(1,Math.floor(t/n)),r=e.split(/\s+/),i=[];let a="";for(const e of r)a&&a.length+1+e.length>o?(i.push(a),a=e):a=a?`${a} ${e}`:e;return a&&i.push(a),i}function Me(e,t,n,o){return"curly"===e?o?`M0,0 C${.6*n},0 ${.4*n},${t/2} ${n},${t/2} C${.4*n},${t/2} ${.6*n},${t} 0,${t}`:`M0,0 C0,${.6*n} ${t/2},${.4*n} ${t/2},${n} C${t/2},${.4*n} ${t},${.6*n} ${t},0`:o?`M0,0 L${n},0 L${n},${t} L0,${t}`:`M0,0 L0,${n} L${t},${n} L${t},0`}function Ne(t){const{x:n=0,y:o=0,dx:r,dy:i,nx:a,ny:s,note:l,connector:c,subject:u,type:d,color:h,className:g,disable:p,events:y={},"data-testid":f}=t,m=new Set(Array.isArray(p)?p:[]);let v=r||0,b=i||0;null!=a&&(v=a-n),null!=s&&(b=s-o);const x="string"==typeof d?d:"label";if("bracket"===x&&u&&0===v&&0===b)if(void 0!==u.width){v=u.width/2;const e=u.depth||30;b=e+(0>e?-5:5)}else if(void 0!==u.height){const e=u.depth||30;v=e+(0>e?-5:5),b=u.height/2}return e.createElement("g",Object.assign({className:("annotation "+(g||"")).trim(),transform:`translate(${n},${o})`,"data-testid":f},y),!m.has("connector")&&function(t,n,o,r,i,a){const s=[];let l=0,c=0;if("callout-circle"!==i&&"label"!==i||!(null==a?void 0:a.radius)){if("callout-rect"===i&&a){const e=a.width||0,o=a.height||0;if(e>0||o>0){const r=e/2,i=o/2,a=t-r,s=n-i;if(0!==a||0!==s){const t=Math.abs(a),n=Math.abs(s),u=e/2,d=o/2,h=t*d>n*u?u/t:d/n;l=r+a*h,c=i+s*h}}}else if("bracket"===i&&a){const e=a.width,t=a.height,n=a.depth||30;void 0!==e?(l=e/2,c=n):void 0!==t&&(l=n,c=t/2)}}else{const e=(a.radius||0)+(a.radiusPadding||0);if(e>0&&(0!==t||0!==n)){const o=Math.atan2(n,t);l=Math.cos(o)*e,c=Math.sin(o)*e}}if(Math.sqrt(Math.pow(t-l,2)+Math.pow(n-c,2))>.5&&(s.push(e.createElement("line",{key:"connector-line",x1:l,y1:c,x2:t,y2:n,stroke:r||"currentColor"})),"arrow"===(null==o?void 0:o.end))){const o=10,i=16/180*Math.PI,a=Math.atan2(n-c,t-l);s.push(e.createElement("path",{key:"connector-arrow",d:`M${l},${c}L${l+o*Math.cos(a+i)},${c+o*Math.sin(a+i)}L${l+o*Math.cos(a-i)},${c+o*Math.sin(a-i)}Z`,fill:r||"currentColor",stroke:"none"}))}return e.createElement("g",{className:"annotation-connector"},s)}(v,b,c,h,x,u),!m.has("subject")&&function(t,n,o,r,i){var a;const s=[];switch(t){case"callout-circle":{const t=((null==n?void 0:n.radius)||0)+((null==n?void 0:n.radiusPadding)||0);t>0&&s.push(e.createElement("circle",{key:"subject-circle",r:t,fill:"none",stroke:o||"currentColor"}));break}case"callout-rect":{const t=(null==n?void 0:n.width)||0,r=(null==n?void 0:n.height)||0;(t>0||r>0)&&s.push(e.createElement("rect",{key:"subject-rect",width:t,height:r,fill:"none",stroke:o||"currentColor"}));break}case"callout-custom":(null==n?void 0:n.custom)&&s.push(...Array.isArray(n.custom)?n.custom:[n.custom]);break;case"xy-threshold":{const t=r||0,a=i||0;if(void 0!==(null==n?void 0:n.x)){const r=(n.x||0)-t;s.push(e.createElement("line",{key:"threshold-line",x1:r,y1:(n.y1||0)-a,x2:r,y2:(n.y2||0)-a,stroke:o||"currentColor",strokeDasharray:"5,5"}))}else if(void 0!==(null==n?void 0:n.y)){const r=(n.y||0)-a;s.push(e.createElement("line",{key:"threshold-line",x1:(n.x1||0)-t,y1:r,x2:(n.x2||0)-t,y2:r,stroke:o||"currentColor",strokeDasharray:"5,5"}))}else void 0!==(null==n?void 0:n.x1)||void 0!==(null==n?void 0:n.x2)?s.push(e.createElement("line",{key:"threshold-line",x1:(n.x1||0)-t,y1:0,x2:(n.x2||0)-t,y2:0,stroke:o||"currentColor",strokeDasharray:"5,5"})):void 0===(null==n?void 0:n.y1)&&void 0===(null==n?void 0:n.y2)||s.push(e.createElement("line",{key:"threshold-line",x1:0,y1:(n.y1||0)-a,x2:0,y2:(n.y2||0)-a,stroke:o||"currentColor",strokeDasharray:"5,5"}));break}case"bracket":{const t=null!==(a=null==n?void 0:n.width)&&void 0!==a?a:null==n?void 0:n.height;void 0!==t&&s.push(e.createElement("path",{key:"bracket-path",d:Me((null==n?void 0:n.type)||"curly",t,(null==n?void 0:n.depth)||30,void 0===(null==n?void 0:n.width)),fill:"none",stroke:o||"currentColor"}));break}}return e.createElement("g",{className:"annotation-subject"},s)}(x,u,h,n,o),!m.has("note")&&function(t,n,o,r){if(!t)return e.createElement("g",{className:"annotation-note"});const{label:i,title:a,orientation:s,align:l,wrap:c=120,noWrap:u}=t;if(!i&&!a)return e.createElement("g",{className:"annotation-note"});let d=s;d||(d=Math.abs(n)>Math.abs(o)?"leftRight":"topBottom");let h=l;h&&"dynamic"!==h||(h="topBottom"===d?0>n?"right":"left":0>o?"bottom":"top");let g="start";"topBottom"===d?"right"===h?g="end":"middle"===h&&(g="middle"):g=0>n?"end":"start";const p=16,y=a?u?[a]:Pe(a,c):[],f=i?u?[i]:Pe(i,c):[],m="leftRight"===d?"end"===g?-4:4:0;let v=0;const b=[];y.length>0&&(b.push(e.createElement("text",{key:"annotation-note-title",className:"annotation-note-title",fill:r||void 0,textAnchor:g,fontWeight:"bold"},y.map((t,n)=>e.createElement("tspan",{key:n,x:m,dy:0===n?0:p},t)))),v=y.length*p),f.length>0&&b.push(e.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:r||void 0,textAnchor:g,y:v},f.map((t,n)=>e.createElement("tspan",{key:n,x:m,dy:0===n?0:p},t))));let x=null;if((a||i)&&(0!==n||0!==o))if("topBottom"===d){const t=Math.min(c,120);let n=0,o=t;"end"===g?(n=-t,o=0):"middle"===g&&(n=-t/2,o=t/2),x=e.createElement("line",{className:"note-line",x1:n,x2:o,y1:0,y2:0,stroke:r||"currentColor"})}else{const t=(y.length+f.length)*p+(f.length>0?p:0);let n=0,o=t;"bottom"===h?(n=-t,o=0):"middle"===h&&(n=-t/2,o=t/2),x=e.createElement("line",{className:"note-line",x1:0,x2:0,y1:n,y2:o,stroke:r||"currentColor"})}const w=Math.max(0,y.length+f.length-1)*p;let k=0;return"topBottom"===d?k=0>o?-(w+2):18:"leftRight"===d&&(k="middle"===h?-(w+p+(f.length>0&&y.length>0?2:0))/2+8:"bottom"===h||0>o?-(w+2):18),e.createElement("g",{className:"annotation-note",transform:`translate(${n},${o})`},e.createElement("g",{className:"annotation-note-content",transform:0!==k?`translate(0,${k})`:void 0},b),x)}(l,v,b,h))}function De(t){var n,o;const{noteData:r}=t,{screenCoordinates:i}=r,a="string"==typeof r.type?r.type:"label",s=r.eventListeners||r.events||{};if(r.coordinates&&i){const t=r.nx||i[0][0]+(null!==(n=r.dx)&&void 0!==n?n:0),s=r.ny||i[0][1]+(null!==(o=r.dy)&&void 0!==o?o:0),l=i.map((n,o)=>{const i=Object.assign({},r,{note:0===o?r.note:{label:""},x:n[0],y:n[1],nx:t,ny:s});return e.createElement(Ne,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+o},i,{type:a}))});return e.createElement("g",null,l)}const l=r.note||{title:"none",label:r.label};return e.createElement(Ne,Object.assign({"data-testid":"semiotic-annotation",key:`${l.label}-${l.title}-${r.i}`,events:s},r,{type:a}))}function Ce(e,t){var n,o,r;const i=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.x)&&void 0!==o?o:null===(r=t.scales)||void 0===r?void 0:r.time;return i?null!=e.x?i(e.x):t.xAccessor&&null!=e[t.xAccessor]?i(e[t.xAccessor]):null:null}function Te(e,t){var n,o,r;const i=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.y)&&void 0!==o?o:null===(r=t.scales)||void 0===r?void 0:r.value;return i?null!=e.y?i(e.y):t.yAccessor&&null!=e[t.yAccessor]?i(e[t.yAccessor]):null:null}function Be(e,t,n,o=50){return!(-o>e||e>(n.width||0)+o||-o>t||t>(n.height||0)+o)}function We(t){return function(t,n,o){var r,i,a,s,l,c,u,d,h,g,p,y,f,m,v,b,x,w,k,A,E,S,O,L,P,M,N,D,C,T,B,W,H,$,_,z,I,R,F;switch(t.type){case"label":{let r=null,i=null;if(null!=t.pointId&&o.pointNodes){const e=o.pointNodes.find(e=>e.pointId===t.pointId);if(!e)return null;r=e.x,i=e.y}else r=Ce(t,o),i=Te(t,o);return null==r||null==i?null:Be(r,i,o)?e.createElement(De,{key:"ann-"+n,noteData:{x:r,y:i,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":{let r=null,i=null;if(null!=t.pointId&&o.pointNodes){const e=o.pointNodes.find(e=>e.pointId===t.pointId);if(!e)return null;r=e.x,i=e.y}else r=Ce(t,o),i=Te(t,o);return null==r||null==i?null:Be(r,i,o)?e.createElement(De,{key:"ann-"+n,noteData:{x:r,y:i,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 r=Ce(t,o);if(null==r)return null;const i=t.color||"#f97316";return e.createElement("g",{key:"ann-"+n},e.createElement("line",{x1:r,y1:0,x2:r,y2:o.height||0,stroke:i,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&e.createElement("text",{x:r+4,y:12,fill:i,fontSize:12,fontWeight:"bold"},t.label))}case"y-threshold":{const r=Te(t,o);if(null==r)return null;const i=t.color||"#f97316";return e.createElement("g",{key:"ann-"+n},e.createElement("line",{x1:0,y1:r,x2:o.width||0,y2:r,stroke:i,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&e.createElement("text",{x:(o.width||0)-4,y:r-4,textAnchor:"end",fill:i,fontSize:12,fontWeight:"bold"},t.label))}case"enclose":{const r=(t.coordinates||[]).map(e=>({x:Ce(Object.assign(Object.assign({},e),{type:"point"}),o),y:Te(Object.assign(Object.assign({},e),{type:"point"}),o),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>r.length)return null;const i=j(r),a=t.padding||10;return e.createElement("g",{key:"ann-"+n},e.createElement("circle",{cx:i.x,cy:i.y,r:i.r+a,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&e.createElement("text",{x:i.x,y:i.y-i.r-a-4,textAnchor:"middle",fill:t.color||"#666",fontSize:12},t.label))}case"rect-enclose":{const r=(t.coordinates||[]).map(e=>({x:Ce(Object.assign(Object.assign({},e),{type:"point"}),o),y:Te(Object.assign(Object.assign({},e),{type:"point"}),o)})).filter(e=>null!=e.x&&null!=e.y);if(2>r.length)return null;const i=t.padding||10,a=r.map(e=>e.x),s=r.map(e=>e.y),l=Math.min(...a)-i,c=Math.max(...a)+i,u=Math.min(...s)-i,d=Math.max(...s)+i;return e.createElement("g",{key:"ann-"+n},e.createElement("rect",{x:l,y:u,width:c-l,height:d-u,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&e.createElement("text",{x:(l+c)/2,y:u-4,textAnchor:"middle",fill:t.color||"#666",fontSize:12},t.label))}case"highlight":{const r=o.data||[],i="function"==typeof t.filter?r.filter(t.filter):t.field&&null!=t.value?r.filter(e=>e[t.field]===t.value):[],a=t.style||{stroke:t.color||"#f97316",strokeWidth:2,fill:"none"};return e.createElement("g",{key:"ann-"+n},i.map((n,r)=>{const i=Ce(n,o),s=Te(n,o);return null==i||null==s?null:e.createElement("circle",Object.assign({key:r,cx:i,cy:s,r:t.r||6},a))}))}case"bracket":{const r=Ce(t,o),i=Te(t,o);return e.createElement(De,{key:"ann-"+n,noteData:{x:null!=r?r:0,y:null!=i?i: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 d=o.data||[];if(2>d.length)return null;const h=o.xAccessor||"x",g=o.yAccessor||"y",p=d.map(e=>[e[h],e[g]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>p.length)return null;const y=null!==(i=null===(r=o.scales)||void 0===r?void 0:r.x)&&void 0!==i?i:null===(a=o.scales)||void 0===a?void 0:a.time,f=null!==(l=null===(s=o.scales)||void 0===s?void 0:s.y)&&void 0!==l?l:null===(c=o.scales)||void 0===c?void 0:c.value;if(!y||!f)return null;const m=t.method||"linear";let v;if("loess"===m)v=function(e,t=.3){const n=e.length;if(2>n)return e.slice();const o=e.slice().sort((e,t)=>e[0]-t[0]),r=o.map(e=>e[0]),i=o.map(e=>e[1]),a=Math.max(2,Math.ceil(t*n)),s=[];for(let e=0;n>e;e++){const t=r[e],o=r.map(e=>Math.abs(e-t)),l=o.slice().sort((e,t)=>e-t)[Math.min(a-1,n-1)]||1,c=[];for(let e=0;n>e;e++){const t=0===l?0:o[e]/l;c[e]=1>t?Math.pow(1-Math.pow(t,3),3):0}let u=0,d=0,h=0,g=0,p=0;for(let e=0;n>e;e++){const t=c[e];0!==t&&(u+=t,d+=t*r[e],h+=t*i[e],g+=t*r[e]*r[e],p+=t*r[e]*i[e])}if(0===u){s.push([t,i[e]]);continue}const y=u*g-d*d;if(1e-12>Math.abs(y))s.push([t,h/u]);else{const e=(u*p-d*h)/y;s.push([t,(h-e*d)/u+e*t])}}return s}(p,null!==(u=t.bandwidth)&&void 0!==u?u:.3);else{let e;try{const n=require("regression");e="polynomial"===m?n.polynomial(p,{order:t.order||2}):n.linear(p)}catch(e){return null}v=e.points}const b=v.map(([e,t])=>`${y(e)},${f(t)}`).join(" "),x=t.color||"#6366f1";return e.createElement("g",{key:"ann-"+n},e.createElement("polyline",{points:b,fill:"none",stroke:x,strokeWidth:t.strokeWidth||2,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&e.createElement("text",{x:y(v[v.length-1][0])+4,y:f(v[v.length-1][1])-4,fill:x,fontSize:11},t.label))}case"band":{const r=null!==(h=null===(d=o.scales)||void 0===d?void 0:d.y)&&void 0!==h?h:null===(g=o.scales)||void 0===g?void 0:g.value,i=null!==(p=null==r?void 0:r(t.y0))&&void 0!==p?p:0,a=null!==(y=null==r?void 0:r(t.y1))&&void 0!==y?y:o.height||0;return e.createElement("g",{key:"ann-"+n},e.createElement("rect",{x:0,y:Math.min(i,a),width:o.width||0,height:Math.abs(a-i),fill:t.fill||"#6366f1",fillOpacity:t.fillOpacity||.1}),t.label&&e.createElement("text",{x:(o.width||0)-4,y:Math.min(i,a)-4,textAnchor:"end",fill:t.color||"#6366f1",fontSize:11},t.label))}case"envelope":{const r=o.data||[];if(2>r.length)return null;const i=o.xAccessor||"x",a=null!==(m=null===(f=o.scales)||void 0===f?void 0:f.x)&&void 0!==m?m:null===(v=o.scales)||void 0===v?void 0:v.time,s=null!==(x=null===(b=o.scales)||void 0===b?void 0:b.y)&&void 0!==x?x:null===(w=o.scales)||void 0===w?void 0:w.value;if(!a||!s)return null;const l=t.upperAccessor||"upperBounds",c=t.lowerAccessor||"lowerBounds",u=t.filter,d=r.filter(e=>null!=e[l]&&null!=e[c]&&!(u&&!u(e))).sort((e,t)=>e[i]-t[i]);if(2>d.length)return null;const h=d.map(e=>`${a(e[i])},${s(e[l])}`).join(" L"),g=d.slice().reverse().map(e=>`${a(e[i])},${s(e[c])}`).join(" L"),p=t.fill||"#6366f1";return e.createElement("g",{key:"ann-"+n},e.createElement("path",{d:`M${h} L${g} Z`,fill:p,fillOpacity:null!==(k=t.fillOpacity)&&void 0!==k?k:.15,stroke:"none"}),t.label&&d.length>0&&e.createElement("text",{x:a(d[d.length-1][i])+4,y:s(d[d.length-1][l])-4,fill:p,fontSize:11},t.label))}case"anomaly-band":{const r=o.data||[];if(2>r.length)return null;const i=o.yAccessor||"y",a=null!==(E=null===(A=o.scales)||void 0===A?void 0:A.x)&&void 0!==E?E:null===(S=o.scales)||void 0===S?void 0:S.time,s=null!==(L=null===(O=o.scales)||void 0===O?void 0:O.y)&&void 0!==L?L:null===(P=o.scales)||void 0===P?void 0:P.value;if(!a||!s)return null;const l=r.map(e=>e[i]).filter(e=>null!=e&&isFinite(e));if(2>l.length)return null;const c=l.reduce((e,t)=>e+t,0)/l.length,u=l.reduce((e,t)=>e+Math.pow(t-c,2),0)/l.length,d=Math.sqrt(u),h=null!==(M=t.threshold)&&void 0!==M?M:2,g=c-h*d,p=!1!==t.showBand,y=t.fill||"#6366f1",f=null!==(N=t.fillOpacity)&&void 0!==N?N:.1,m=t.anomalyColor||"#ef4444",v=null!==(D=t.anomalyRadius)&&void 0!==D?D:6,b=s(c+h*d),x=s(g),w=r.filter(e=>{const t=e[i];return null!=t&&Math.abs(t-c)>h*d});return e.createElement("g",{key:"ann-"+n},p&&e.createElement("rect",{x:0,y:Math.min(b,x),width:o.width||0,height:Math.abs(x-b),fill:y,fillOpacity:f}),w.map((t,n)=>{const r=Ce(t,o),i=Te(t,o);return null==r||null==i?null:e.createElement("circle",{key:n,cx:r,cy:i,r:v,fill:m,fillOpacity:.7,stroke:m,strokeWidth:1.5})}),t.label&&e.createElement("text",{x:(o.width||0)-4,y:Math.min(b,x)-4,textAnchor:"end",fill:y,fontSize:11},t.label))}case"forecast":{const r=o.data||[];if(3>r.length)return null;const i=o.xAccessor||"x",a=o.yAccessor||"y",s=null!==(T=null===(C=o.scales)||void 0===C?void 0:C.x)&&void 0!==T?T:null===(B=o.scales)||void 0===B?void 0:B.time,l=null!==(H=null===(W=o.scales)||void 0===W?void 0:W.y)&&void 0!==H?H:null===($=o.scales)||void 0===$?void 0:$.value;if(!s||!l)return null;const c=r.map(e=>[e[i],e[a]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]);if(3>c.length)return null;let u;if("polynomial"===(t.method||"linear"))try{const e=require("regression").polynomial(c,{order:t.order||2}).equation;u=t=>e.reduce((e,n,o)=>e+n*Math.pow(t,o),0)}catch(e){return null}else{const e=c.length;let t=0,n=0,o=0,r=0;for(const[e,i]of c)t+=e,n+=i,o+=e*e,r+=e*i;const i=e*o-t*t;if(1e-12>Math.abs(i))return null;const a=(e*r-t*n)/i,s=(n-a*t)/e;u=e=>s+a*e}const d=c.length,h=c.map(([e,t])=>t-u(e)).reduce((e,t)=>e+t*t,0),g=Math.sqrt(h/Math.max(d-2,1)),p=c.reduce((e,t)=>e+t[0],0)/d,y=c.reduce((e,t)=>e+Math.pow(t[0]-p,2),0),f=null!==(_=t.confidence)&&void 0!==_?_:.95,m=.99>f?.95>f?.9>f?1:1.645:1.96:2.576,v=null!==(z=t.steps)&&void 0!==z?z:5,b=c[d-1][0],x=(b-c[0][0])/Math.max(d-1,1),w=[];for(let e=1;v>=e;e++)w.push(b+e*x);const k=[];for(const e of w){const t=u(e),n=g*Math.sqrt(1+1/d+(y>0?Math.pow(e-p,2)/y:0))*m;k.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const A=`M${k.map(e=>`${s(e.x)},${l(e.yUpper)}`).join(" L")} L${k.slice().reverse().map(e=>`${s(e.x)},${l(e.yLower)}`).join(" L")} Z`,E=k.map(e=>`${s(e.x)},${l(e.yCenter)}`).join(" "),S=`${s(b)},${l(u(b))}`,O=t.strokeColor||"#6366f1";return e.createElement("g",{key:"ann-"+n},e.createElement("path",{d:A,fill:t.fill||"#6366f1",fillOpacity:null!==(I=t.fillOpacity)&&void 0!==I?I:.15,stroke:"none"}),e.createElement("polyline",{points:`${S} ${E}`,fill:"none",stroke:O,strokeWidth:null!==(R=t.strokeWidth)&&void 0!==R?R:2,strokeDasharray:null!==(F=t.strokeDasharray)&&void 0!==F?F:"6,3"}),t.label&&k.length>0&&e.createElement("text",{x:s(k[k.length-1].x)+4,y:l(k[k.length-1].yCenter)-4,fill:O,fontSize:11},t.label))}default:return null}}}function He(e,t,n){if("left"===e||"right"===e){const o="left"===e?n:0,r="left"===e?-1:1,i=Math.ceil(t/8);let a="M0,"+o;for(let e=0;i>e;e++){const n=8*(e+1);a+=`L${Math.min(8*e+4,t)},${o+4*r}`,a+=`L${Math.min(n,t)},${o}`}return a}{const o="bottom"===e?0:t,r="bottom"===e?1:-1,i=Math.ceil(n/8);let a=`M${o},0`;for(let e=0;i>e;e++){const t=8*(e+1);a+=`L${o+4*r},${Math.min(8*e+4,n)}`,a+=`L${o},${Math.min(t,n)}`}return a}}function $e(e){return Math.round(100*e)/100+""}function _e(t){const{width:n,height:o,totalWidth:i,totalHeight:a,margin:s,scales:l,showAxes:c,axes:u,xLabel:d,yLabel:h,xFormat:g,yFormat:p,showGrid:y,title:f,legend:m,foregroundGraphics:v,marginalGraphics:b,xValues:x,yValues:w,annotations:k,svgAnnotationRules:A,annotationFrame:E,xAccessor:S,yAccessor:O,annotationData:L,pointNodes:j,children:P}=t,M=r(()=>c&&l?l.x.ticks(5).map(e=>({value:e,pixel:l.x(e),label:(g||$e)(e)})):[],[c,l,g]),N=r(()=>c&&l?l.y.ticks(5).map(e=>({value:e,pixel:l.y(e),label:(p||$e)(e)})):[],[c,l,p]),D=r(()=>{if(!k||0===k.length)return null;const e=We(),t={scales:l?{x:l.x,y:l.y,time:l.x,value:l.y}:null,timeAxis:"x",xAccessor:S,yAccessor:O,width:n,height:o,data:L,frameType:"xy",pointNodes:j};return k.map((n,o)=>{if(A){const r=A(n,o,t);return null!=r?r:e(n,o,t)}return e(n,o,t)}).filter(Boolean)},[k,A,n,o,E,S,O,L]);return c||f||m||v||b||D&&D.length>0||y||P?e.createElement("svg",{width:i,height:a,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},e.createElement("g",{transform:`translate(${s.left},${s.top})`},y&&l&&e.createElement("g",{className:"stream-grid"},M.map((t,n)=>e.createElement("line",{key:"xgrid-"+n,x1:t.pixel,y1:0,x2:t.pixel,y2:o,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1})),N.map((t,o)=>e.createElement("line",{key:"ygrid-"+o,x1:0,y1:t.pixel,x2:n,y2:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),c&&l&&(()=>{const t=null==u?void 0:u.find(e=>"left"===e.orient),r=null==u?void 0:u.find(e=>"bottom"===e.orient),i=!t||!1!==t.baseline,a=(null==t?void 0:t.jaggedBase)||!1,l=(null==r?void 0:r.jaggedBase)||!1,c="var(--semiotic-border, #ccc)",g="var(--semiotic-text-secondary, #666)",p="var(--semiotic-text, #333)";return e.createElement("g",{className:"stream-axes"},(!r||!1!==r.baseline)&&!l&&e.createElement("line",{x1:0,y1:o,x2:n,y2:o,stroke:c,strokeWidth:1}),l&&e.createElement("path",{d:He("bottom",n,o),fill:"none",stroke:c,strokeWidth:1}),M.map((t,n)=>e.createElement("g",{key:"xtick-"+n,transform:`translate(${t.pixel},${o})`},e.createElement("line",{y2:5,stroke:c,strokeWidth:1}),e.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:g,style:{userSelect:"none"}},t.label))),d&&e.createElement("text",{x:n/2,y:o+40,textAnchor:"middle",fontSize:12,fill:p,style:{userSelect:"none"}},d),i&&!a&&e.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:c,strokeWidth:1}),a&&e.createElement("path",{d:He("left",n,o),fill:"none",stroke:c,strokeWidth:1}),N.map((t,n)=>e.createElement("g",{key:"ytick-"+n,transform:`translate(0,${t.pixel})`},e.createElement("line",{x2:-5,stroke:c,strokeWidth:1}),e.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:g,style:{userSelect:"none"}},t.label))),h&&e.createElement("text",{x:15-s.left,y:o/2,textAnchor:"middle",fontSize:12,fill:p,transform:`rotate(-90, ${15-s.left}, ${o/2})`,style:{userSelect:"none"}},h))})(),D,b&&l&&x&&w&&e.createElement(e.Fragment,null,b.top&&e.createElement("g",{transform:"translate(0, 0)"},e.createElement(je,{orient:"top",config:Le(b.top),values:x,scale:l.x,size:s.top,length:n})),b.bottom&&e.createElement("g",{transform:`translate(0, ${o})`},e.createElement(je,{orient:"bottom",config:Le(b.bottom),values:x,scale:l.x,size:s.bottom,length:n})),b.left&&e.createElement("g",{transform:"translate(0, 0)"},e.createElement(je,{orient:"left",config:Le(b.left),values:w,scale:l.y,size:s.left,length:o})),b.right&&e.createElement("g",{transform:`translate(${n}, 0)`},e.createElement(je,{orient:"right",config:Le(b.right),values:w,scale:l.y,size:s.right,length:o}))),v,P),f&&e.createElement("text",{x:i/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof f?f:null),m&&e.createElement("g",{transform:`translate(${i-s.right+10}, ${s.top})`},function(t){return"object"==typeof t&&null!==t&&!e.isValidElement(t)&&"legendGroups"in t}(m)?e.createElement(Oe,{legendGroups:m.legendGroups,title:"",width:100}):m)):null}function ze(e,t,n){let o=n;for(const n of t)"lesser"===n.thresholdType?n.value>e&&(o=n.color):e>n.value&&(o=n.color);return o}function Ie(e){if(e.startsWith("#")){const t=4===e.length?e[1]+e[1]+e[2]+e[2]+e[3]+e[3]:e.slice(1,7);return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[78,121,167]}const Re=(e,t,n,o)=>{var r;const i=t.filter(e=>"area"===e.type);for(const t of i){if(2>t.topPath.length)continue;e.beginPath();const[n,o]=t.topPath[0];e.moveTo(n,o);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1]);for(let n=t.bottomPath.length-1;n>=0;n--)e.lineTo(t.bottomPath[n][0],t.bottomPath[n][1]);e.closePath();const i=t.style.fill||"#4e79a7";if(t.fillGradient){const n=Math.min(...t.topPath.map(e=>e[1])),o=Math.max(...t.bottomPath.map(e=>e[1])),r=e.createLinearGradient(0,n,0,o);r.addColorStop(0,i),r.addColorStop(1,i),e.fillStyle=r;const a=Ie(i),s=t.fillGradient.topOpacity,l=t.fillGradient.bottomOpacity,c=e.createLinearGradient(0,n,0,o);c.addColorStop(0,`rgba(${a[0]},${a[1]},${a[2]},${s})`),c.addColorStop(1,`rgba(${a[0]},${a[1]},${a[2]},${l})`),e.fillStyle=c,e.globalAlpha=1}else{const n=null!==(r=t.style.fillOpacity)&&void 0!==r?r:.7;e.globalAlpha=n,e.fillStyle=i}if(e.fill(),t.style.stroke&&"none"!==t.style.stroke){e.globalAlpha=1,e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]),e.beginPath(),e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1]);e.stroke()}e.globalAlpha=1}},Fe=(e,t,n,o)=>{var r,i;const a=t.filter(e=>"point"===e.type);for(const t of a){e.beginPath(),e.arc(t.x,t.y,t.r,0,2*Math.PI);const n=null!==(r=t.style.opacity)&&void 0!==r?r:t.style.fillOpacity;if(null!=n&&(e.globalAlpha=n),e.fillStyle=t.style.fill||"#4e79a7",e.fill(),t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()),t._pulseIntensity&&t._pulseIntensity>0){const n=null!==(i=t._pulseGlowRadius)&&void 0!==i?i:4,o=t.r+n*t._pulseIntensity;e.beginPath(),e.arc(t.x,t.y,o,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=.6*t._pulseIntensity,e.stroke()}e.globalAlpha=1}},Ye=(e,t,n,o)=>{const r=t.filter(e=>"rect"===e.type);for(const t of r)null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.icon?Ge(e,t):(e.fillStyle=t.style.fill||"#007bff",e.fillRect(t.x,t.y,t.w,t.h),t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.strokeRect(t.x,t.y,t.w,t.h))),t._pulseIntensity&&t._pulseIntensity>0&&(e.globalAlpha=.3*t._pulseIntensity,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h)),e.globalAlpha=1};function Ge(e,t){const n=t.style.icon,o=t.style.iconPadding||2,r=Math.min(t.w,t.w)-o;if(0>=r)return;const i=t.h>t.w;if(e.save(),e.beginPath(),e.rect(t.x,t.y,t.w,t.h),e.clip(),i){const i=r+o,a=t.x+(t.w-r)/2;for(let o=t.y+t.h-r;o>=t.y-r;o-=i)e.drawImage(n,a,o,r,r)}else{const i=r+o,a=t.y+(t.h-r)/2;for(let o=t.x;t.x+t.w>o;o+=i)e.drawImage(n,o,a,r,r)}e.restore()}const Xe={line:[Re,(e,t,n,o)=>{const r=t.filter(e=>"line"===e.type);for(const i of r){if(2>i.path.length)continue;const a=i.style.stroke||"#007bff",s=i.style.strokeWidth||2,l=i.colorThresholds,c=i.rawValues;if(e.setLineDash(i.style.strokeDasharray?i.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=i.style.opacity&&(e.globalAlpha=i.style.opacity),e.lineWidth=s,l&&0!==l.length&&c&&c.length===i.path.length){let u=null,d=null,h=null,g=null,p=!1;function y(t,n,o){e.beginPath(),e.strokeStyle=t,e.moveTo(n,o),p=!0}function f(){p&&(e.stroke(),p=!1)}for(let m=0;i.path.length>m;m++){const[v,b]=i.path[m],x=c[m],w=ze(x,l,a);if(null!==u&&null!==g&&null!==h){if(w===g)e.lineTo(v,b);else{const k=[];for(const A of l){const E=A.value;(h>E||E>x)&&(E>h||x>E)||h===E||x===E||k.push({t:(E-h)/(x-h)})}k.sort((e,t)=>e.t-t.t);for(const S of k){const O=u+(v-u)*S.t,L=d+(b-d)*S.t,j=ze(h+(x-h)*Math.min(S.t+1e-4,1),l,a);e.lineTo(O,L),f(),y(j,O,L)}e.lineTo(v,b)}u=v,d=b,h=x,g=w}else y(w,v,b),u=v,d=b,h=x,g=w}f()}else{e.beginPath(),e.strokeStyle=a;const[P,M]=i.path[0];e.moveTo(P,M);for(let N=1;i.path.length>N;N++)e.lineTo(i.path[N][0],i.path[N][1]);e.stroke()}if(i.style.fill&&i.style.fillOpacity&&i.style.fillOpacity>0){e.beginPath(),e.globalAlpha=i.style.fillOpacity,e.fillStyle=i.style.fill;const[D,C]=i.path[0];e.moveTo(D,C);for(let B=1;i.path.length>B;B++)e.lineTo(i.path[B][0],i.path[B][1]);const T=i.path[0][0];e.lineTo(i.path[i.path.length-1][0],o.height),e.lineTo(T,o.height),e.closePath(),e.fill()}e.globalAlpha=1,e.setLineDash([])}}],area:[Re],stackedarea:[Re],scatter:[Fe],bubble:[Fe],heatmap:[(e,t,n,o)=>{const r=t.filter(e=>"heatcell"===e.type);for(const t of r){const n=t.style;null!=(null==n?void 0:n.opacity)&&(e.globalAlpha=n.opacity),e.fillStyle=t.fill,e.fillRect(t.x,t.y,t.w,t.h),e.strokeStyle="#fff",e.lineWidth=1,e.strokeRect(t.x,t.y,t.w,t.h),t._pulseIntensity&&t._pulseIntensity>0&&(e.globalAlpha=.3*t._pulseIntensity,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h)),e.globalAlpha=1}}],bar:[Ye],swarm:[Fe],waterfall:[(e,t,n,o)=>{var r,i,a;Ye(e,t);const s=t.filter(e=>"rect"===e.type);if(2>s.length)return;const l=s[0].datum,c=null==l?void 0:l._connectorStroke;if(c){e.save(),e.strokeStyle=c,e.lineWidth=null!==(r=null==l?void 0:l._connectorWidth)&&void 0!==r?r:1,e.setLineDash([]);for(let t=0;s.length-1>t;t++){const o=s[t],r=s[t+1];if(!(null===(i=o.datum)||void 0===i?void 0:i.cumEnd)||!(null===(a=r.datum)||void 0===a?void 0:a.baseline))continue;const l=n.y(o.datum.cumEnd),c=o.x+o.w,u=r.x;e.beginPath(),e.moveTo(c,l),e.lineTo(u,l),e.stroke()}e.restore()}}],candlestick:[(e,t,n,o)=>{for(const n of t){if("candlestick"!==n.type)continue;const t=n;e.beginPath(),e.moveTo(t.x,t.highY),e.lineTo(t.x,t.lowY),e.strokeStyle=t.wickColor,e.lineWidth=t.wickWidth,e.stroke();const o=Math.min(t.openY,t.closeY),r=Math.abs(t.openY-t.closeY),i=t.isUp?t.upColor:t.downColor;e.fillStyle=i,e.fillRect(t.x-t.bodyWidth/2,o,t.bodyWidth,Math.max(r,1)),e.strokeStyle=i,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,o,t.bodyWidth,Math.max(r,1))}}]},qe={top:20,right:20,bottom:30,left:40},Ve={axisStroke:"#ccc",tickText:"#666",crosshair:"rgba(0, 0, 0, 0.25)",hoverFill:"rgba(255, 255, 255, 0.3)",hoverStroke:"rgba(0, 0, 0, 0.4)",pointRing:"white"},Ue={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,lineHeight:1.5,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function Ze({hover:t}){const n=e=>Number.isInteger(e)?e+"":e.toFixed(2);return e.createElement("div",{className:"semiotic-tooltip",style:Ue},e.createElement("div",{style:{fontWeight:600,marginBottom:2}},n(t.value)),e.createElement("div",{style:{opacity:.7,fontSize:11}},n(t.time)))}function Qe({width:n,height:r,totalWidth:i,totalHeight:a,margin:s,dimension:l,scales:c,onBrush:u}){const d=t(null),f=t(null);return o(()=>{if(!d.current)return;const e=y(d.current).select(".brush-g"),t="x"===l?h():"y"===l?g():p();return t.extent([[0,0],[n,r]]),t.on("brush end",e=>{if(!c)return;if(!e.selection)return void u(null);let t,o;if("x"===l){const[n,i]=e.selection;t=[c.x.invert(n),c.x.invert(i)],o=[c.y.invert(r),c.y.invert(0)]}else if("y"===l){const[r,i]=e.selection;t=[c.x.invert(0),c.x.invert(n)],o=[c.y.invert(i),c.y.invert(r)]}else{const[[n,r],[i,a]]=e.selection;t=[c.x.invert(n),c.x.invert(i)],o=[c.y.invert(a),c.y.invert(r)]}u({x:t,y:o})}),e.call(t),f.current=t,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{t.on("brush end",null),f.current=null}},[n,r,l,c,u]),e.createElement("svg",{ref:d,width:i,height:a,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},e.createElement("g",{className:"brush-g",transform:`translate(${s.left},${s.top})`}))}const Ke=i(function(i,l){var c,u,d;const{chartType:h,runtimeMode:g,data:p,xAccessor:y,yAccessor:f,colorAccessor:m,sizeAccessor:v,groupAccessor:b,lineDataAccessor:x,normalize:w,binSize:k,valueAccessor:A,arrowOfTime:E="right",windowMode:S="sliding",windowSize:O=200,timeAccessor:L,xExtent:j,yExtent:P,extentPadding:M=.1,sizeRange:N,size:D=[500,300],responsiveWidth:C,responsiveHeight:T,margin:B,className:W,background:H,lineStyle:$,pointStyle:_,areaStyle:z,waterfallStyle:I,swarmStyle:R,barColors:F,colorScheme:Y,boundsAccessor:G,boundsStyle:X,y0Accessor:q,gradientFill:V,openAccessor:U,highAccessor:Z,lowAccessor:Q,closeAccessor:K,candlestickStyle:J,showAxes:ee=!0,axes:te,xLabel:oe,yLabel:re,xFormat:ie,yFormat:ae,tickFormatTime:se,tickFormatValue:le,hoverAnnotation:ce,tooltipContent:ue,customHoverBehavior:de,enableHover:he,annotations:xe,svgAnnotationRules:Ee,showGrid:Se,legend:Oe,backgroundGraphics:Le,foregroundGraphics:je,title:Pe,categoryAccessor:Me,brush:Ne,onBrush:De,decay:Ce,pulse:Te,transition:Be,staleness:We,heatmapAggregation:He,heatmapXBins:$e,heatmapYBins:ze,marginalGraphics:Ie,pointIdAccessor:Re}=i,[Fe,Ye]=Ae(D,C,T),Ge=Object.assign(Object.assign({},qe),B);if(Ie){const e=60;Ie.top&&e>Ge.top&&(Ge.top=e),Ie.bottom&&e>Ge.bottom&&(Ge.bottom=e),Ie.left&&e>Ge.left&&(Ge.left=e),Ie.right&&e>Ge.right&&(Ge.right=e)}const Ue=Ye[0]-Ge.left-Ge.right,Ke=Ye[1]-Ge.top-Ge.bottom,Je=null!=ce?ce:he,et=t(null),tt=t(0),nt=t(!1),[ot,rt]=n(0),[it,at]=n(null),st=t(null),lt=t(null),[ct,ut]=n(null),[dt,ht]=n(!1),[gt,pt]=n([]),[yt,ft]=n([]),mt=t(()=>{}),vt="streaming"===g||["bar","swarm","waterfall"].includes(h),bt=r(()=>({chartType:h,runtimeMode:vt?"streaming":"bounded",windowSize:O,windowMode:S,arrowOfTime:vt?E:"right",extentPadding:M,xAccessor:vt?void 0:y,yAccessor:vt?void 0:f,timeAccessor:vt?L:void 0,valueAccessor:A,colorAccessor:m,sizeAccessor:v,groupAccessor:b,categoryAccessor:Me,lineDataAccessor:x,xExtent:j,yExtent:P,sizeRange:N,binSize:k,normalize:w,boundsAccessor:G,boundsStyle:X,y0Accessor:q,gradientFill:"boolean"==typeof V?V?{topOpacity:.8,bottomOpacity:.05}:void 0:V,openAccessor:U,highAccessor:Z,lowAccessor:Q,closeAccessor:K,candlestickStyle:J,lineStyle:$,pointStyle:_,areaStyle:z,swarmStyle:R,waterfallStyle:I,colorScheme:Y,barColors:F,annotations:xe,decay:Ce,pulse:Te,transition:Be,staleness:We,heatmapAggregation:He,heatmapXBins:$e,heatmapYBins:ze,pointIdAccessor:Re}),[h,O,S,E,M,y,f,L,A,m,v,b,Me,x,j,P,N,k,w,G,X,q,V,U,Z,Q,K,J,$,_,z,R,I,Y,F,xe,Ce,Te,Be,We,He,$e,ze,vt,Re]),xt=t(null);xt.current||(xt.current=new ge(bt));const wt=a(()=>{tt.current||(tt.current=requestAnimationFrame(()=>mt.current()))},[]);o(()=>{var e;null===(e=xt.current)||void 0===e||e.updateConfig(bt),nt.current=!0,wt()},[bt,wt]);const kt=t(null);kt.current||(kt.current=new ne(e=>{const t=xt.current;t&&t.ingest(e)&&(nt.current=!0,wt())}));const At=a(e=>{var t;null===(t=kt.current)||void 0===t||t.push(e)},[]),Et=a(e=>{var t;null===(t=kt.current)||void 0===t||t.pushMany(e)},[]),St=a(()=>{var e,t;null===(e=kt.current)||void 0===e||e.clear(),null===(t=xt.current)||void 0===t||t.clear(),nt.current=!0,wt()},[wt]);s(l,()=>({push:At,pushMany:Et,clear:St,getData:()=>{var e,t;return null!==(t=null===(e=xt.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=xt.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null},getExtents:()=>{var e,t;return null!==(t=null===(e=xt.current)||void 0===e?void 0:e.getExtents())&&void 0!==t?t:null}}),[At,Et,St]),o(()=>{var e;if(p)return null===(e=kt.current)||void 0===e||e.setBoundedData(p),()=>{var e;null===(e=kt.current)||void 0===e||e.clearLastData()}},[p]);const Ot=t(()=>{}),Lt=t(()=>{});Ot.current=e=>{if(!Je)return;const t=et.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-Ge.left,r=e.clientY-n.top-Ge.top;if(0>o||o>Ue||0>r||r>Ke)return void(st.current&&(st.current=null,lt.current=null,ut(null),de&&(de(null),nt.current=!0),wt()));const i=xt.current;if(!i||0===i.scene.length)return;const a=function(e,t,n,o=30){let r=null;for(const i of e){let e=null;switch(i.type){case"point":e=pe(i,t,n);break;case"line":e=ye(i,t,n);break;case"rect":e=fe(i,t,n);break;case"heatcell":e=me(i,t,n);break;case"area":if(!1===i.interactive)break;e=be(i,t,n);break;case"candlestick":e=ve(i,t,n)}e&&o>e.distance&&(r&&e.distance>=r.distance||(r=e))}return r}(i.scene,o,r);if(!a)return void(st.current&&(st.current=null,lt.current=null,ut(null),de&&de(null),wt()));const s={data:a.datum,time:a.x,value:a.y,x:a.x,y:a.y};st.current=s,lt.current=a.node,ut(s),de&&(de(s),nt.current=!0),wt()},Lt.current=()=>{st.current&&(st.current=null,lt.current=null,ut(null),de&&(de(null),nt.current=!0),wt())},a(e=>Ot.current(e),[]);const jt=a(()=>Lt.current(),[]),Pt=t(-1),Mt=a(e=>{const t=xt.current;if(!t||0===t.scene.length)return;const n=function(e){const t=[];for(const n of e)switch(n.type){case"point":t.push({x:n.x,y:n.y,datum:n.datum});break;case"line":{const e=n,o=Array.isArray(e.datum)?e.datum:[];for(let n=0;e.path.length>n&&o.length>n;n++)t.push({x:e.path[n][0],y:e.path[n][1],datum:o[n]});break}case"area":{const e=n,o=Array.isArray(e.datum)?e.datum:[];for(let n=0;e.topPath.length>n&&o.length>n;n++)t.push({x:e.topPath[n][0],y:e.topPath[n][1],datum:o[n]});break}case"rect":case"heatcell":t.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum})}return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}(t.scene);if(0===n.length)return;const o=0>Pt.current?-1:Pt.current,r=we(e.key,0>o?-1:o,n.length);if(null===r)return;if(e.preventDefault(),0>r)return Pt.current=-1,st.current=null,lt.current=null,ut(null),de&&de(null),void wt();const i=0>o?0:r;Pt.current=i;const a=ke(n[i]);st.current=a,ut(a),de&&de(a),wt()},[de,wt]),Nt=a(e=>{Pt.current=-1,Ot.current(e)},[]);mt.current=()=>{var e,t;tt.current=0;const n=et.current;if(!n)return;const o=n.getContext("2d");if(!o)return;const r=xt.current;if(!r)return;const i="undefined"!=typeof performance?performance.now():Date.now(),a=r.advanceTransition(i);a||r.computeScene({width:Ue,height:Ke});const s="undefined"!=typeof window&&window.devicePixelRatio||1;n.width=Ye[0]*s,n.height=Ye[1]*s,n.style.width=Ye[0]+"px",n.style.height=Ye[1]+"px",o.scale(s,s),o.translate(Ge.left,Ge.top),o.clearRect(-Ge.left,-Ge.top,Ye[0],Ye[1]);const l=function(e){if(!e)return Ve;const t=getComputedStyle(e),n=t.getPropertyValue("--semiotic-border").trim(),o=t.getPropertyValue("--semiotic-text-secondary").trim(),r=t.getPropertyValue("--semiotic-bg").trim(),i=o||t.getPropertyValue("--text-secondary").trim(),a=t.getPropertyValue("--text-primary").trim(),s=n||t.getPropertyValue("--surface-3").trim(),l=r||t.getPropertyValue("--surface-0").trim();return i||a||n?{axisStroke:s||Ve.axisStroke,tickText:i||Ve.tickText,crosshair:i?i+"66":Ve.crosshair,hoverFill:l?l+"4D":Ve.hoverFill,hoverStroke:i?i+"99":Ve.hoverStroke,pointRing:l||Ve.pointRing}:Ve}(n),c=null!==(e=null==We?void 0:We.threshold)&&void 0!==e?e:5e3,u=We&&r.lastIngestTime>0&&i-r.lastIngestTime>c;u&&(o.globalAlpha=null!==(t=null==We?void 0:We.dimOpacity)&&void 0!==t?t:.5);const d=n?getComputedStyle(n).getPropertyValue("--semiotic-bg").trim():"",g=H||(d&&"transparent"!==d?d:null);g&&(o.fillStyle=g,o.fillRect(-Ge.left,-Ge.top,Ye[0],Ye[1])),o.save(),"function"==typeof o.rect&&(o.beginPath(),o.rect(0,0,Ue,Ke),o.clip());const p=Xe[h];if(p&&r.scales)for(const e of p)e(o,r.scene,r.scales,{width:Ue,height:Ke});if(o.restore(),u&&(o.globalAlpha=1),Je&&st.current&&r.scales&&function(e,t,n,o,r,i,a){if(!1===r.crosshair)return;e.save();const s="object"==typeof r.crosshair?r.crosshair:{};e.strokeStyle=s.stroke||a.crosshair,e.lineWidth=s.strokeWidth||1,e.setLineDash(s.strokeDasharray?s.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),e.beginPath(),e.moveTo(t.x,0),e.lineTo(t.x,o),e.stroke(),e.beginPath(),e.moveTo(0,t.y),e.lineTo(n,t.y),e.stroke(),e.restore(),e.beginPath(),e.arc(t.x,t.y,4,0,2*Math.PI),e.fillStyle="#007bff",e.fill(),e.strokeStyle=a.pointRing,e.lineWidth=2,e.stroke()}(o,st.current,Ue,Ke,"object"==typeof Je?Je:{},0,l),lt.current&&Array.isArray(ce)){const e=ce.find(e=>e&&"object"==typeof e&&"highlight"===e.type);e&&function(e,t,n,o){var r;if(!n)return;const i=n.group;if(void 0!==i)for(const n of t){if("line"!==n.type)continue;if(n.group!==i)continue;if(2>n.path.length)continue;const t="function"==typeof o.style?o.style(n.datum):o.style||{};e.save(),e.beginPath(),e.moveTo(n.path[0][0],n.path[0][1]);for(let t=1;n.path.length>t;t++)e.lineTo(n.path[t][0],n.path[t][1]);e.strokeStyle=t.stroke||n.style.stroke||"#007bff",e.lineWidth=t.strokeWidth||(n.style.strokeWidth||2)+2,e.globalAlpha=null!==(r=t.opacity)&&void 0!==r?r:1,e.stroke(),e.restore()}}(o,r.scene,lt.current,e)}const m=nt.current;if(nt.current=!1,m&&r.scales&&(at(r.scales),Ie)){const e=r.getData(),t="function"==typeof y?y:e=>e[y||"x"],n="function"==typeof f?f:e=>e[f||"y"];pt(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),ft(e.map(e=>n(e)).filter(e=>"number"==typeof e&&isFinite(e)))}m&&xe&&xe.length>0&&rt(e=>e+1),(null==We?void 0:We.showBadge)&&ht(!!u),(a||r.hasActivePulses)&&(tt.current=requestAnimationFrame(()=>mt.current()))},o(()=>(wt(),()=>{tt.current&&(cancelAnimationFrame(tt.current),tt.current=0)}),[wt]),o(()=>{nt.current=!0,wt()},[h,Ue,Ke,ee,H,$,wt]),o(()=>{if(!We)return;const e=setInterval(()=>{var e;const t=xt.current;if(!t||0===t.lastIngestTime)return;const n="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(e=We.threshold)&&void 0!==e?e:5e3,r=n-t.lastIngestTime>o;r!==dt&&(ht(r),nt.current=!0,wt())},1e3);return()=>clearInterval(e)},[We,dt,wt]);const Dt=Je&&ct?ue?ue(ct):e.createElement(Ze,{hover:ct}):null,Ct=Dt?e.createElement("div",{className:"stream-frame-tooltip",style:{position:"absolute",left:Ge.left+ct.x,top:Ge.top+ct.y,transform:`translate(${ct.x>.7*Ue?"calc(-100% - 12px)":"12px"}, ${.3*Ke>ct.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:1}},Dt):null,Tt=Pt.current>=0&&ct?e.createElement("svg",{style:{position:"absolute",left:0,top:0,width:Ye[0],height:Ye[1],pointerEvents:"none",zIndex:2}},e.createElement("circle",{cx:ct.x+Ge.left,cy:ct.y+Ge.top,r:8,fill:"none",stroke:"var(--accent, #6366f1)",strokeWidth:2,strokeDasharray:"4,2"})):null;return e.createElement("div",{ref:Fe,className:"stream-xy-frame"+(W?" "+W:""),role:"img","aria-label":"string"==typeof Pe?Pe:"XY chart",tabIndex:0,style:{position:"relative",width:C?"100%":Ye[0],height:T?"100%":Ye[1]},onMouseMove:Je?Nt:void 0,onMouseLeave:Je?jt:void 0,onKeyDown:Mt},Le&&e.createElement("svg",{style:{position:"absolute",left:0,top:0,width:Ye[0],height:Ye[1],pointerEvents:"none"}},Le),e.createElement("canvas",{ref:et,style:{position:"absolute",left:0,top:0}}),e.createElement(_e,{width:Ue,height:Ke,totalWidth:Ye[0],totalHeight:Ye[1],margin:Ge,scales:it,showAxes:ee,axes:te,xLabel:oe,yLabel:re,xFormat:ie||se,yFormat:ae||le,showGrid:Se,title:Pe,legend:Oe,foregroundGraphics:je,marginalGraphics:Ie,xValues:gt,yValues:yt,annotations:xe,svgAnnotationRules:Ee,annotationFrame:ot,xAccessor:"string"==typeof y?y:"string"==typeof L?L:void 0,yAccessor:"string"==typeof f?f:"string"==typeof A?A:void 0,annotationData:null===(c=xt.current)||void 0===c?void 0:c.getData(),pointNodes:null===(u=xt.current)||void 0===u?void 0:u.scene.filter(e=>"point"===e.type)}),(Ne||De)&&e.createElement(Qe,{width:Ue,height:Ke,totalWidth:Ye[0],totalHeight:Ye[1],margin:Ge,dimension:null!==(d=null==Ne?void 0:Ne.dimension)&&void 0!==d?d:"xy",scales:it,onBrush:null!=De?De:()=>{}}),(null==We?void 0:We.showBadge)&&e.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===We.badgePosition?{top:4,left:4}:"bottom-left"===We.badgePosition?{bottom:4,left:4}:"bottom-right"===We.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:dt?"#dc3545":"#28a745",color:"white"})},dt?"STALE":"LIVE"),Tt,Ct)});function Je(e,t){const{columns:n,config:o,resolvePieceStyle:r}=e,i=[],a=Math.min(t.width,t.height)/2-4,s="donut"===o.chartType?o.innerRadius||60:0,l=-Math.PI/2+(o.startAngle||0)*Math.PI/180,c=2*Math.PI;for(const e of Object.values(n)){const t=l+e.pctStart*c,n=l+(e.pctStart+e.pct)*c,o=r(e.pieceData[0],e.name);i.push({type:"wedge",cx:0,cy:0,innerRadius:s,outerRadius:a,startAngle:t,endAngle:n,style:o,datum:e.pieceData,category:e.name})}return i}function et(e){var t,n,o;const r=e.length,i=e[0],a=e[r-1];return{n:r,min:i,q1:null!==(t=w(e,.25))&&void 0!==t?t:i,median:null!==(n=w(e,.5))&&void 0!==n?n:(i+a)/2,q3:null!==(o=w(e,.75))&&void 0!==o?o:a,max:a,mean:e.reduce((e,t)=>e+t,0)/r}}Ke.displayName="StreamXYFrame";const tt={bar:function(e,t){const{scales:n,columns:o,config:r,getR:i,getStack:a,resolvePieceStyle:s}=e,{r:l,projection:c}=n,u=[],d="vertical"===c,h="horizontal"===c,g=r.normalize;for(const e of Object.values(o)){const t=new Map;for(const n of e.pieceData){const e=a?a(n):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const o=t.get(e);o.total+=i(n),o.pieces.push(n)}let n=0;if(g)for(const e of t.values())n+=Math.abs(e.total);let o=0,r=0;for(const[i,c]of t){let t=c.total;g&&n>0&&(t/=n);const p=s(c.pieces[0],a?i:e.name),y=Object.assign(Object.assign({},c.pieces[0]),{__aggregateValue:c.total,__pieceCount:c.pieces.length,category:e.name});if(d){const n=l(0>t?r:o+t),a=0>t?l(r+t)-l(r):l(o)-l(o+t);u.push(ce(e.x,n,e.width,Math.abs(a),p,y,i)),0>t?r+=t:o+=t}else if(h){const n=l(0>t?r+t:o),a=0>t?l(r)-l(r+t):l(o+t)-l(o);u.push(ce(n,e.x,Math.abs(a),e.width,p,y,i)),0>t?r+=t:o+=t}}}return u},clusterbar:function(e,t){const{scales:n,columns:o,getR:r,getGroup:i,resolvePieceStyle:a}=e,{r:s,projection:l}=n,c=[],u="vertical"===l,d=[],h=new Set;for(const e of Object.values(o))for(const t of e.pieceData){const e=i?i(t):"_default";h.has(e)||(h.add(e),d.push(e))}const g=d.length||1;for(const e of Object.values(o)){const t=e.width/g,n=new Map;for(const t of e.pieceData){const e=i?i(t):"_default";n.has(e)||n.set(e,[]),n.get(e).push(t)}for(let o=0;d.length>o;o++){const i=n.get(d[o])||[];for(const n of i){const i=r(n),l=a(n,e.name);if(u){const r=e.x+o*t,a=s(0),u=s(i);c.push(ce(r,Math.min(a,u),t,Math.abs(a-u),l,n,d[o]))}else{const r=e.x+o*t,a=s(0),u=s(i);c.push(ce(Math.min(a,u),r,Math.abs(u-a),t,l,n,d[o]))}}}}return c},point:function(e,t){var n,o;const{scales:r,columns:i,getR:a,multiScales:s,resolvePieceStyle:l}=e,{r:c,projection:u}=r,d=[],h="vertical"===u,g="radial"===u,p=s.length>0,y=2*Math.PI,f=-Math.PI/2;for(const e of Object.values(i))for(const t of e.pieceData){const r=null!==(n=t.__rIndex)&&void 0!==n?n:0,i=null!==(o=t.__rValue)&&void 0!==o?o:a(t),u=p&&s[r]||c,m=l(t,e.name),v=m.r||5;let b,x;if(g){const t=f+(e.pctStart+e.pct/2)*y,n=u(i);b=Math.cos(t)*n,x=Math.sin(t)*n}else h?(b=e.middle,x=u(i)):(b=u(i),x=e.middle);d.push({type:"point",x:b,y:x,r:v,style:m,datum:t})}return d},swarm:function(e,t){const{scales:n,columns:o,getR:r,resolvePieceStyle:i}=e,{r:a,projection:s}=n,l=[],c="vertical"===s;for(const e of Object.values(o)){const t=e.width/2;for(let n=0;e.pieceData.length>n;n++){const o=e.pieceData[n],s=r(o),u=i(o,e.name),d=u.r||4,h=(7919*n%100/100-.5)*t*.8,g=c?e.middle+h:a(s),p=c?a(s):e.middle+h;l.push({type:"point",x:g,y:p,r:d,style:u,datum:o})}}return l},pie:Je,donut:Je,boxplot:function(e,t){var n,o,r,i,a;const{scales:s,columns:l,config:c,getR:u,resolveSummaryStyle:d}=e,{r:h,projection:g}=s,p=[],y="vertical"===g,f=!1!==c.showOutliers;for(const e of Object.values(l)){const t=e.pieceData.map(e=>u(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(0===t.length)continue;const s=t[0],l=t[t.length-1],c=null!==(n=w(t,.25))&&void 0!==n?n:s,g=null!==(o=w(t,.5))&&void 0!==o?o:(s+l)/2,m=null!==(r=w(t,.75))&&void 0!==r?r:l,v=m-c,b=c-1.5*v,x=m+1.5*v,k=null!==(i=t.find(e=>e>=b))&&void 0!==i?i:s,A=null!==(a=[...t].reverse().find(e=>x>=e))&&void 0!==a?a:l,E=d(e.pieceData[0],e.name),S=[];if(f)for(const t of e.pieceData){const n=u(t);if(b>n||n>x){const o=y?e.middle:h(n),r=y?h(n):e.middle;S.push({px:o,py:r,value:n,datum:t})}}if(p.push({type:"boxplot",x:y?e.middle:0,y:y?0:e.middle,projection:y?"vertical":"horizontal",columnWidth:.6*e.width,minPos:h(k),q1Pos:h(c),medianPos:h(g),q3Pos:h(m),maxPos:h(A),stats:{min:k,q1:c,median:g,q3:m,max:A},style:E,datum:e.pieceData,category:e.name,outliers:S}),f)for(const e of S)p.push({type:"point",x:e.px,y:e.py,r:3,style:{fill:E.fill||"#999",opacity:.6},datum:e.datum})}return p},violin:function(e,t){var n,o,r;const{scales:i,columns:a,config:s,getR:l,resolveSummaryStyle:c}=e,{r:u,projection:d}=i,h=[],g="vertical"===d,p=s.bins||20,y=!1!==s.showIQR;for(const e of Object.values(a)){const t=e.pieceData.map(e=>l(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const i=t[0],a=t[t.length-1],s=(a-i)/p||1,d=Array(p).fill(0);for(const e of t)d[Math.min(Math.floor((e-i)/s),p-1)]++;const f=Math.max(...d,1),m=e.width/2*.9;let v="";if(g){for(let t=0;p>t;t++){const n=u(i+(t+.5)*s),o=d[t]/f*m;v+=0===t?`M ${e.middle+o} ${n}`:` L ${e.middle+o} ${n}`}for(let t=p-1;t>=0;t--){const n=u(i+(t+.5)*s);v+=` L ${e.middle-d[t]/f*m} ${n}`}v+=" Z"}else{for(let t=0;p>t;t++){const n=u(i+(t+.5)*s),o=d[t]/f*m;v+=0===t?`M ${n} ${e.middle-o}`:` L ${n} ${e.middle-o}`}for(let t=p-1;t>=0;t--)v+=` L ${u(i+(t+.5)*s)} ${e.middle+d[t]/f*m}`;v+=" Z"}const b=c(e.pieceData[0],e.name);let x;if(y&&t.length>=4){const s=null!==(n=w(t,.25))&&void 0!==n?n:i,l=null!==(o=w(t,.5))&&void 0!==o?o:(i+a)/2,c=null!==(r=w(t,.75))&&void 0!==r?r:a;x={q1Pos:u(s),medianPos:u(l),q3Pos:u(c),centerPos:e.middle,isVertical:g}}const k=g?{x:e.x,y:Math.min(u(a),u(i)),width:e.width,height:Math.abs(u(a)-u(i))}:{x:Math.min(u(i),u(a)),y:e.x,width:Math.abs(u(a)-u(i)),height:e.width};h.push({type:"violin",pathString:v,translateX:0,translateY:0,bounds:k,iqrLine:x,stats:et(t),style:b,datum:e.pieceData,category:e.name})}return h},histogram:function(e,t){const{scales:n,columns:o,config:r,getR:i,resolveSummaryStyle:a}=e,{r:s}=n,l=[],c=r.bins||25,u=r.normalize;for(const e of Object.values(o)){const t=e.pieceData.map(e=>i(e)).filter(e=>null!=e&&!isNaN(e));if(0===t.length)continue;const n=Math.min(...t),o=(Math.max(...t)-n)/c||1,r=Array(c).fill(0);for(const e of t)r[Math.min(Math.floor((e-n)/o),c-1)]++;const d=t.length,h=Math.max(...r,1),g=a(e.pieceData[0],e.name);for(let t=0;c>t;t++){if(0===r[t])continue;const i=(u?r[t]/d:r[t]/h)*e.width*.9,a=s(n+t*o),c=s(n+(t+1)*o);l.push(ce(Math.min(a,c),e.x+e.width-i,Math.abs(c-a),i,g,{bin:t,count:r[t],range:[n+t*o,n+(t+1)*o],category:e.name},e.name))}}return l},ridgeline:function(e,t){var n;const{scales:o,columns:r,config:i,getR:a,resolveSummaryStyle:s}=e,{r:l,projection:c}=o,u=[],d=i.bins||20,h="horizontal"===c,g=i.amplitude||1.5;for(const e of Object.values(r)){const t=e.pieceData.map(e=>a(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const o=t[0],r=t[t.length-1],i=(r-o)/d||1,c=Array(d).fill(0);for(const e of t)c[Math.min(Math.floor((e-o)/i),d-1)]++;const p=Math.max(...c,1),y=s(e.pieceData[0],e.name),f=e.width*g;let m="";if(h){const t=e.x+e.width;m=`M ${l(o)} ${t}`;for(let e=0;d>e;e++)m+=` L ${l(o+(e+.5)*i)} ${t-c[e]/p*f}`;m+=` L ${l(r)} ${t} Z`}else{const t=e.x;m=`M ${t} ${l(o)}`;for(let e=0;d>e;e++){const n=l(o+(e+.5)*i);m+=` L ${t+c[e]/p*f} ${n}`}m+=` L ${t} ${l(r)} Z`}const v=h?{x:Math.min(l(o),l(r)),y:e.x,width:Math.abs(l(r)-l(o)),height:e.width}:{x:e.x,y:Math.min(l(r),l(o)),width:e.width,height:Math.abs(l(r)-l(o))};u.push({type:"violin",pathString:m,translateX:0,translateY:0,bounds:v,stats:et(t),style:Object.assign(Object.assign({},y),{fillOpacity:null!==(n=y.fillOpacity)&&void 0!==n?n:.5}),datum:e.pieceData,category:e.name})}return u},timeline:function(e,t){const{scales:n,columns:o,getRawRange:r,resolvePieceStyle:i}=e,{r:a,projection:s}=n,l=[],c="horizontal"===s;for(const e of Object.values(o))for(const t of e.pieceData){const n=r(t);if(!n)continue;const[o,s]=n,u=i(t,e.name);if(c){const n=a(Math.min(o,s)),r=a(Math.max(o,s));l.push(ce(n,e.x,r-n,e.width,u,t,e.name))}else{const n=a(Math.max(o,s)),r=a(Math.min(o,s));l.push(ce(e.x,n,e.width,r-n,u,t,e.name))}}return l}};class nt{constructor(e){this.rExtent=new re,this.rExtents=[],this.rAccessors=[],this.categories=new Set,this._colorSchemeMap=null,this._colorSchemeIndex=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.lastIngestTime=0,this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.version=0,this.config=e,this.buffer=new oe(e.windowSize),this.getO=he(e.oAccessor||e.categoryAccessor,"category");const t="streaming"===e.runtimeMode,n=e.rAccessor;Array.isArray(n)?(this.rAccessors=n.map(e=>de(e,"value")),this.getR=this.rAccessors[0],this.rExtents=n.map(()=>new re)):(this.getR=de(t&&(e.timeAccessor||e.valueAccessor)&&e.valueAccessor||n,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=he(e.stackBy),this.getGroup=he(e.groupBy),this.getColor=he(e.colorAccessor),this.getConnector=he(e.connectorAccessor),e.pulse&&(this.timestampBuffer=new oe(e.windowSize))}ingest(e){const t="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=t,e.bounded){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const n=e.totalSize||e.inserts.length;n>this.buffer.capacity&&(this.buffer.resize(n),this.timestampBuffer&&n>this.timestampBuffer.capacity&&this.timestampBuffer.resize(n));for(const n of e.inserts)this.buffer.push(n),this.timestampBuffer&&this.timestampBuffer.push(t),this.categories.add(this.getO(n)),this.pushValueExtent(n)}else for(const n of e.inserts){const e=this.buffer.push(n);this.timestampBuffer&&this.timestampBuffer.push(t),this.categories.add(this.getO(n)),this.pushValueExtent(n),null!=e&&this.evictValueExtent(e)}return!0}pushValueExtent(e){if("timeline"===this.config.chartType){const t=this.getRawRange(e);t&&(this.rExtent.push(t[0]),this.rExtent.push(t[1]))}else if(this.rAccessors.length>1){for(let t=0;this.rAccessors.length>t;t++)this.rExtents[t].push(this.rAccessors[t](e));this.rExtent.push(this.getR(e))}else this.rExtent.push(this.getR(e))}evictValueExtent(e){if("timeline"===this.config.chartType){const t=this.getRawRange(e);t&&(this.rExtent.evict(t[0]),this.rExtent.evict(t[1]))}else if(this.rAccessors.length>1){for(let t=0;this.rAccessors.length>t;t++)this.rExtents[t].evict(this.rAccessors[t](e));this.rExtent.evict(this.getR(e))}else this.rExtent.evict(this.getR(e))}getRawRange(e){const t=this.config.rAccessor;if(!t)return null;const n="function"==typeof t?t(e):e[t];return Array.isArray(n)&&n.length>=2?[+n[0],+n[1]]:null}computeScene(e){const{config:t,buffer:n}=this;if(0===n.size)return this.scales=null,this.scene=[],this.columns={},void this.version++;this.rExtent.dirty&&this.rExtent.recalculate(n,this.getR);const o=n.toArray(),r=t.projection||"vertical",i=t.oExtent||this.resolveCategories(o),a=this.computeValueDomain(o,i),s="horizontal"===r,l=null!=t.barPadding?t.barPadding/("vertical"===r?e.width:e.height):.1;let c,u;if("radial"===r){c=m().domain(i).range([0,1]).padding(0);const n=Math.min(e.width,e.height)/2,o=t.innerRadius||0;u=f().domain(a).range([o,n])}else s?(c=m().domain(i).range([0,e.height]).padding(l),u=f().domain(a).range([0,e.width])):(c=m().domain(i).range([0,e.width]).padding(l),u=f().domain(a).range([e.height,0]));this.scales={o:c,r:u,projection:r},this.multiScales=this.rAccessors.length>1&&t.multiAxis?this.rAccessors.map((o,r)=>{const i=this.rExtents[r];i.dirty&&i.recalculate(n,o);let[a,l]=i.extent;a===1/0&&(a=0,l=1);const c=l-a,u=c>0?c*(t.extentPadding||.05):1;return a-=u,l+=u,a>0&&(a=0),s?f().domain([a,l]).range([0,e.width]):f().domain([a,l]).range([e.height,0])}):[];let d=o;this.rAccessors.length>1&&(d=o.flatMap(e=>this.rAccessors.map((t,n)=>Object.assign(Object.assign({},e),{__rIndex:n,__rValue:t(e),__rName:this.resolveRAccessorName(n)})))),this.columns=this.buildColumns(d,i,c,r,e),this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(d,e),this.config.decay&&this.applyDecay(this.scene,o),this.config.pulse&&this.applyPulse(this.scene,o),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++}resolveRAccessorName(e){const t=Array.isArray(this.config.rAccessor)?this.config.rAccessor[e]:this.config.rAccessor;return"string"==typeof t?t:"value"+e}resolveCategories(e){const t=Array.from(this.categories),n=this.config.oSort;if("streaming"===this.config.runtimeMode&&void 0===n)return t;if(!1===n)return t;if("function"==typeof n)return t.sort(n);const o=new Map;for(const t of e){const e=this.getO(t);o.set(e,(o.get(e)||0)+Math.abs(this.getR(t)))}return t.sort("asc"===n?(e,t)=>(o.get(e)||0)-(o.get(t)||0):(e,t)=>(o.get(t)||0)-(o.get(e)||0))}computeValueDomain(e,t){var n,o;const r=this.config.chartType,i=this.config.extentPadding||.05;if("radial"===this.config.projection&&("pie"===r||"donut"===r))return[0,1];let a=0,s=0;if("bar"===r&&this.getStack){const t=new Map,n=new Map;for(const o of e){const e=this.getO(o),r=this.getR(o);0>r?n.set(e,(n.get(e)||0)+r):t.set(e,(t.get(e)||0)+r)}for(const e of t.values())e>s&&(s=e);for(const e of n.values())a>e&&(a=e)}else if("bar"===r){const t=new Map;for(const n of e){const e=this.getO(n),o=this.getR(n);t.set(e,(t.get(e)||0)+o)}for(const e of t.values())e>s&&(s=e),a>e&&(a=e)}else if("clusterbar"===r)for(const t of e){const e=this.getR(t);e>s&&(s=e),a>e&&(a=e)}else{const e=this.rExtent.extent[0],t=this.rExtent.extent[1];e!==1/0&&(a=e),t!==-1/0&&(s=t)}this.config.rExtent&&(null!=this.config.rExtent[0]&&(a=this.config.rExtent[0]),null!=this.config.rExtent[1]&&(s=this.config.rExtent[1]));const l=s-a,c=l>0?l*i:1;return(null===(n=this.config.rExtent)||void 0===n?void 0:n[0])||(a-=c),(null===(o=this.config.rExtent)||void 0===o?void 0:o[1])||(s+=c),"bar"!==r&&"clusterbar"!==r||(a>0&&(a=0),0>s&&(s=0)),[a,s]}buildColumns(e,t,n,o,r){var i;const a={},s=new Map;for(const t of e){const e=this.getO(t);s.has(e)||s.set(e,[]),s.get(e).push(t)}let l=0;if("radial"===o)for(const t of e)l+=Math.abs(this.getR(t));const c=this.config.dynamicColumnWidth;let u=null;if(c&&"radial"!==o){u=new Map;let e=0;for(const n of t){const t=s.get(n)||[];let o;o="string"==typeof c?t.reduce((e,t)=>e+(Number(t[c])||0),0):c(t),u.set(n,o),e+=o}const i=("horizontal"===o?r.height:r.width)-n.padding()*n.step()*t.length;if(e>0)for(const[t,n]of u)u.set(t,n/e*i)}let d=0,h=0;for(const e of t){const t=s.get(e)||[],o=t.reduce((e,t)=>e+Math.abs(this.getR(t)),0),r=l>0?o/l:0;let c,g;u?(c=h,g=u.get(e)||n.bandwidth(),h+=g+n.padding()*n.step()):(c=null!==(i=n(e))&&void 0!==i?i:0,g=n.bandwidth()),a[e]={name:e,x:c,y:0,width:g,middle:c+g/2,padding:n.padding()*n.step(),pieceData:t,pct:r,pctStart:d},d+=r}return a}getSceneContext(){return{scales:this.scales,columns:this.columns,config:this.config,getR:this.getR,getStack:this.getStack,getGroup:this.getGroup,getColor:this.getColor,getConnector:this.getConnector,getO:this.getO,multiScales:this.multiScales,rAccessors:this.rAccessors,resolvePieceStyle:(e,t)=>this.resolvePieceStyle(e,t),resolveSummaryStyle:(e,t)=>this.resolveSummaryStyle(e,t),getRawRange:e=>this.getRawRange(e)}}buildSceneNodes(e,t){if(!this.scales)return[];const n=this.getSceneContext(),o=tt[this.config.chartType];let r=o?o(n,t):[];if(this.getConnector&&this.scales){const e=function(e,t){const{scales:n,config:o,getConnector:r,getO:i}=e;if(!r||!n)return[];const a=[],{projection:s}=n,l=new Map;for(const e of t){if("point"!==e.type&&"rect"!==e.type)continue;const t=e.datum;if(!t)continue;const n=r(t);if(!n)continue;let o,a;"point"===e.type?(o=e.x,a=e.y):(o=e.x+e.w/2,a=e.y+("vertical"===s?0:e.h/2)),l.has(n)||l.set(n,[]),l.get(n).push({x:o,y:a,datum:t,category:i(t)})}const c=n.o.domain(),u=o.connectorStyle;for(const[e,t]of l)if(t.length>=2){t.sort((e,t)=>c.indexOf(e.category)-c.indexOf(t.category));for(let n=0;t.length-1>n;n++){const o=t[n],r=t[n+1],i="function"==typeof u?u(o.datum):u||{stroke:"#999",strokeWidth:1,opacity:.5};a.push({type:"connector",x1:o.x,y1:o.y,x2:r.x,y2:r.y,style:i,datum:o.datum,group:e})}}return a}(n,r);r=[...e,...r]}return r}resolvePieceStyle(e,t){return"function"==typeof this.config.pieceStyle?this.config.pieceStyle(e,t):this.config.pieceStyle&&"object"==typeof this.config.pieceStyle?this.config.pieceStyle:this.config.barColors&&t?{fill:this.config.barColors[t]||"#007bff"}:t?{fill:this.getColorFromScheme(t)}:{fill:"#007bff"}}getColorFromScheme(e){this._colorSchemeMap||(this._colorSchemeMap=new Map);const t=this._colorSchemeMap.get(e);if(t)return t;const n=Array.isArray(this.config.colorScheme)?this.config.colorScheme:["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],o=n[this._colorSchemeIndex%n.length];return this._colorSchemeIndex++,this._colorSchemeMap.set(e,o),o}resolveSummaryStyle(e,t){return"function"==typeof this.config.summaryStyle?this.config.summaryStyle(e,t):this.config.summaryStyle&&"object"==typeof this.config.summaryStyle?this.config.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}computeDecayOpacity(e,t){var n,o,r;const i=this.config.decay;if(!i||1>=t)return 1;const a=null!==(n=i.minOpacity)&&void 0!==n?n:.1,s=t-1-e;switch(i.type){case"linear":return a+(1-s/(t-1))*(1-a);case"exponential":{const e=null!==(o=i.halfLife)&&void 0!==o?o:t/2;return a+Math.pow(.5,s/e)*(1-a)}case"step":return(null!==(r=i.stepThreshold)&&void 0!==r?r:.5*t)>s?1:a;default:return 1}}applyDecay(e,t){var n,o;if(!this.config.decay)return;const r=t.length;if(1>=r)return;const i=new Map;for(let e=0;t.length>e;e++)i.set(t[e],e);for(const t of e){if("connector"===t.type||"violin"===t.type||"boxplot"===t.type||"wedge"===t.type)continue;const e=i.get(t.datum);if(null==e)continue;const a=this.computeDecayOpacity(e,r),s=null!==(o=null===(n=t.style)||void 0===n?void 0:n.opacity)&&void 0!==o?o:1;t.style=Object.assign(Object.assign({},t.style),{opacity:s*a})}}applyPulse(e,t){var n,o,r;if(!this.config.pulse||!this.timestampBuffer)return;const i="undefined"!=typeof performance?performance.now():Date.now(),a=null!==(n=this.config.pulse.duration)&&void 0!==n?n:500,s=null!==(o=this.config.pulse.color)&&void 0!==o?o:"rgba(255,255,255,0.6)",l=null!==(r=this.config.pulse.glowRadius)&&void 0!==r?r:4,c=new Map;for(let e=0;t.length>e;e++)c.set(t[e],e);for(const t of e){if("connector"===t.type||"violin"===t.type||"boxplot"===t.type||"wedge"===t.type)continue;const e=c.get(t.datum);if(null==e)continue;const n=this.timestampBuffer.get(e);if(null==n)continue;const o=i-n;a>o&&(t._pulseIntensity=1-o/a,t._pulseColor=s,t._pulseGlowRadius=l)}}get hasActivePulses(){var e;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const t="undefined"!=typeof performance?performance.now():Date.now(),n=null!==(e=this.config.pulse.duration)&&void 0!==e?e:500,o=this.timestampBuffer.peek();return null!=o&&n>t-o}snapshotPositions(){var e,t;this.prevPositionMap.clear();for(let n=0;this.scene.length>n;n++){const o=this.scene[n];if("point"===o.type)this.prevPositionMap.set("p:"+n,{x:o.x,y:o.y,r:o.r});else if("rect"===o.type){const r=`r:${o.group||""}:${null!==(t=null===(e=o.datum)||void 0===e?void 0:e.category)&&void 0!==t?t:n}`;this.prevPositionMap.set(r,{x:o.x,y:o.y,w:o.w,h:o.h})}}}startTransition(){var e,t,n,o,r;if(!this.config.transition||0===this.prevPositionMap.size)return;const i=null!==(e=this.config.transition.duration)&&void 0!==e?e:300;let a=!1;for(let e=0;this.scene.length>e;e++){const i=this.scene[e];let s=null;if("point"===i.type?s="p:"+e:"rect"===i.type&&(s=`r:${i.group||""}:${null!==(n=null===(t=i.datum)||void 0===t?void 0:t.category)&&void 0!==n?n:e}`),!s)continue;const l=this.prevPositionMap.get(s);l&&("point"===i.type?l.x===i.x&&l.y===i.y||(i._targetX=i.x,i._targetY=i.y,i.x=l.x,i.y=l.y,a=!0):"rect"===i.type&&(l.x===i.x&&l.y===i.y&&l.w===i.w&&l.h===i.h||(i._targetX=i.x,i._targetY=i.y,i._targetW=i.w,i._targetH=i.h,i.x=l.x,i.y=l.y,i.w=null!==(o=l.w)&&void 0!==o?o:i.w,i.h=null!==(r=l.h)&&void 0!==r?r:i.h,a=!0)))}a&&(this.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:i})}advanceTransition(e){var t,n,o;if(!this.activeTransition)return!1;const r=Math.min((e-this.activeTransition.startTime)/this.activeTransition.duration,1),i="linear"===(null===(t=this.config.transition)||void 0===t?void 0:t.easing)?r:1-Math.pow(1-r,3);for(const e of this.scene)if("point"===e.type){if(void 0===e._targetX)continue;const t=this.prevPositionMap.get("p:0");if(!t)continue;e.x=t.x+(e._targetX-t.x)*i,e.y=t.y+(e._targetY-t.y)*i}else if("rect"===e.type){if(void 0===e._targetX)continue;const t=`r:${e.group||""}:${null!==(o=null===(n=e.datum)||void 0===n?void 0:n.category)&&void 0!==o?o:0}`,r=this.prevPositionMap.get(t);if(!r)continue;e.x=r.x+(e._targetX-r.x)*i,e.y=r.y+(e._targetY-r.y)*i,void 0!==r.w&&(e.w=r.w+(e._targetW-r.w)*i,e.h=r.h+(e._targetH-r.h)*i)}if(r>=1){for(const e of this.scene)if("point"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e._targetX=void 0,e._targetY=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}return this.activeTransition=null,!1}return!0}getData(){return this.buffer.toArray()}clear(){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],this.columns={},this.version++}get size(){return this.buffer.size}getOAccessor(){return this.getO}getRAccessor(){return this.getR}updateConfig(e){e.colorScheme!==this.config.colorScheme&&(this._colorSchemeMap=null,this._colorSchemeIndex=0),Object.assign(this.config,e)}}function ot(e,t,n){return e.x>t||t>e.x+e.w||e.y>n||n>e.y+e.h?null:{datum:e.datum,x:e.x+e.w/2,y:e.y,distance:0,category:e.group}}function rt(e,t,n){const o=t-e.x,r=n-e.y,i=Math.sqrt(o*o+r*r);return i>Math.max(e.r,5)?null:{datum:e.datum,x:e.x,y:e.y,distance:i}}function it(e,t,n){const o=t-e.cx,r=n-e.cy,i=Math.sqrt(o*o+r*r);if(e.innerRadius>i||i>e.outerRadius)return null;let a=Math.atan2(r,o);0>a&&(a+=2*Math.PI);let s=e.startAngle%(2*Math.PI),l=e.endAngle%(2*Math.PI);if(0>s&&(s+=2*Math.PI),0>l&&(l+=2*Math.PI),!(s>l?a>=s||l>=a:a>=s&&l>=a))return null;const c=(e.startAngle+e.endAngle)/2,u=(e.innerRadius+e.outerRadius)/2;return{datum:e.datum,x:e.cx+Math.cos(c)*u,y:e.cy+Math.sin(c)*u,distance:0,category:e.category}}function at(e,t,n){const o=e.columnWidth/2,r=e.stats?Object.assign(Object.assign({},e.stats),{n:Array.isArray(e.datum)?e.datum.length:0,mean:(e.stats.q1+e.stats.median+e.stats.q3)/3}):void 0;if("vertical"===e.projection){if(!(e.x-o>t||t>e.x+o||Math.min(e.minPos,e.maxPos)>n||n>Math.max(e.minPos,e.maxPos)))return{datum:e.datum,x:e.x,y:e.medianPos,distance:0,category:e.category,stats:r}}else{const i=e.y-o,a=e.y+o;if(!(Math.min(e.minPos,e.maxPos)>t||t>Math.max(e.minPos,e.maxPos)||i>n||n>a))return{datum:e.datum,x:e.medianPos,y:e.y,distance:0,category:e.category,stats:r}}return null}function st(e,t,n){if(!e.bounds)return null;const{x:o,y:r,width:i,height:a}=e.bounds;return o>t||t>o+i||r>n||n>r+a?null:{datum:e.datum,x:o+i/2,y:r+a/2,distance:0,category:e.category,stats:e.stats}}function lt(e){return Math.round(100*e)/100+""}function ct(t){const{width:n,height:o,totalWidth:i,totalHeight:a,margin:s,scales:l,showAxes:c,oLabel:u,rLabel:d,oFormat:h,rFormat:g,showGrid:p,title:y,legend:f,foregroundGraphics:m,annotations:v,svgAnnotationRules:b,annotationFrame:x,xAccessor:w,yAccessor:k,annotationData:A,children:E}=t,S="radial"===(null==l?void 0:l.projection),O="horizontal"===(null==l?void 0:l.projection),L=r(()=>c&&l&&!S?l.o.domain().map(e=>{var t;return{value:e,pixel:(null!==(t=l.o(e))&&void 0!==t?t:0)+l.o.bandwidth()/2,label:h?h(e):e}}):[],[c,l,h,S]),j=r(()=>c&&l&&!S?l.r.ticks(5).map(e=>({value:e,pixel:l.r(e),label:(g||lt)(e)})):[],[c,l,g,S]),P=r(()=>{if(!v||0===v.length)return null;const e=We(),t={scales:l?{x:l.r,y:l.r,time:l.r,value:l.r}:null,timeAxis:"x",xAccessor:w,yAccessor:k,width:n,height:o,data:A,frameType:"ordinal"};return v.map((n,o)=>{if(b){const r=b(n,o,t);return null!=r?r:e(n,o,t)}return e(n,o,t)}).filter(Boolean)},[v,b,n,o,x,w,k,A]);return c||y||f||m||P&&P.length>0||p||E?e.createElement("svg",{width:i,height:a,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},e.createElement("g",{transform:`translate(${s.left},${s.top})`},p&&l&&!S&&e.createElement("g",{className:"ordinal-grid"},j.map((t,r)=>e.createElement("line",{key:"grid-"+r,x1:O?t.pixel:0,y1:O?0:t.pixel,x2:O?t.pixel:n,y2:O?o:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),c&&l&&!S&&e.createElement("g",{className:"ordinal-axes"},O?e.createElement(e.Fragment,null,e.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),L.map((t,n)=>e.createElement("g",{key:"cat-"+n,transform:`translate(0,${t.pixel})`},e.createElement("line",{x2:-5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),e.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"}},t.label))),u&&e.createElement("text",{x:15-s.left,y:o/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",transform:`rotate(-90, ${15-s.left}, ${o/2})`,style:{userSelect:"none"}},u),e.createElement("line",{x1:0,y1:o,x2:n,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),j.map((t,n)=>e.createElement("g",{key:"val-"+n,transform:`translate(${t.pixel},${o})`},e.createElement("line",{y2:5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),e.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"}},t.label))),d&&e.createElement("text",{x:n/2,y:o+40,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},d)):e.createElement(e.Fragment,null,e.createElement("line",{x1:0,y1:o,x2:n,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),L.map((t,n)=>e.createElement("g",{key:"cat-"+n,transform:`translate(${t.pixel},${o})`},e.createElement("line",{y2:5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),e.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"}},t.label))),u&&e.createElement("text",{x:n/2,y:o+40,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},u),e.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),j.map((t,n)=>e.createElement("g",{key:"val-"+n,transform:`translate(0,${t.pixel})`},e.createElement("line",{x2:-5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),e.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"}},t.label))),d&&e.createElement("text",{x:15-s.left,y:o/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",transform:`rotate(-90, ${15-s.left}, ${o/2})`,style:{userSelect:"none"}},d))),P,m,E),y&&e.createElement("text",{x:i/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof y?y:null),f&&e.createElement("g",{transform:`translate(${i-s.right+10}, ${s.top})`},function(t){return"object"==typeof t&&null!==t&&!e.isValidElement(t)&&"legendGroups"in t}(f)?e.createElement(Oe,{legendGroups:f.legendGroups,title:"",width:100}):f)):null}const ut=(e,t,n,o)=>{const r=t.filter(e=>"wedge"===e.type);for(const t of r)e.beginPath(),t.innerRadius>0?(e.arc(t.cx,t.cy,t.outerRadius,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerRadius,t.endAngle,t.startAngle,!0)):(e.moveTo(t.cx,t.cy),e.arc(t.cx,t.cy,t.outerRadius,t.startAngle,t.endAngle)),e.closePath(),null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),null!=t.style.fillOpacity&&(e.globalAlpha=t.style.fillOpacity),e.fillStyle=t.style.fill||"#007bff",e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()),e.globalAlpha=1},dt=(e,t,n,o)=>{var r,i;const a=t.filter(e=>"violin"===e.type);for(const t of a){e.save(),(t.translateX||t.translateY)&&e.translate(t.translateX,t.translateY);const n=new Path2D(t.pathString);if(e.globalAlpha=null!==(i=null!==(r=t.style.fillOpacity)&&void 0!==r?r:t.style.opacity)&&void 0!==i?i:.6,e.fillStyle=t.style.fill||"#007bff",e.fill(n),e.globalAlpha=1,t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke(n)),t.iqrLine){e.strokeStyle="#333",e.lineWidth=2,e.globalAlpha=.8;const n=t.iqrLine.centerPos,o=!1!==t.iqrLine.isVertical;e.beginPath(),o?(e.moveTo(n,t.iqrLine.q1Pos),e.lineTo(n,t.iqrLine.q3Pos)):(e.moveTo(t.iqrLine.q1Pos,n),e.lineTo(t.iqrLine.q3Pos,n)),e.stroke(),e.beginPath(),o?e.arc(n,t.iqrLine.medianPos,3,0,2*Math.PI):e.arc(t.iqrLine.medianPos,n,3,0,2*Math.PI),e.fillStyle="#fff",e.fill(),e.strokeStyle="#333",e.lineWidth=1,e.stroke(),e.globalAlpha=1}e.restore()}},ht=(e,t,n,o)=>{var r,i,a;const s=t.filter(e=>"connector"===e.type);if(0===s.length)return;const l=new Map;for(const e of s){const t=e.group||"_default";l.has(t)||l.set(t,[]),l.get(t).push(e)}for(const[,t]of l){if(0===t.length)continue;const n=t[0].style;if(n.fill&&"none"!==n.fill){e.beginPath(),e.moveTo(t[0].x1,t[0].y1);for(const n of t)e.lineTo(n.x2,n.y2);e.closePath(),e.globalAlpha=null!==(i=null!==(r=n.fillOpacity)&&void 0!==r?r:n.opacity)&&void 0!==i?i:.3,e.fillStyle=n.fill,e.fill(),e.globalAlpha=1}for(const n of t)e.beginPath(),e.moveTo(n.x1,n.y1),e.lineTo(n.x2,n.y2),e.strokeStyle=n.style.stroke||n.style.fill||"#999",e.lineWidth=n.style.strokeWidth||1,e.globalAlpha=null!==(a=n.style.opacity)&&void 0!==a?a:.5,e.stroke(),e.globalAlpha=1}},gt=e=>[ht,...e],pt={bar:gt([Ye]),clusterbar:gt([Ye]),point:gt([Fe]),swarm:gt([Fe]),pie:[ut],donut:[ut],boxplot:gt([(e,t,n,o)=>{var r,i;const a=t.filter(e=>"boxplot"===e.type);for(const t of a){const n=t.columnWidth/2,o="vertical"===t.projection,a=t.style.fill||"#007bff",s=t.style.stroke||"#333",l=t.style.strokeWidth||1,c=null!==(i=null!==(r=t.style.fillOpacity)&&void 0!==r?r:t.style.opacity)&&void 0!==i?i:.6;if(e.save(),e.strokeStyle=s,e.lineWidth=l,e.beginPath(),o?(e.moveTo(t.x,t.minPos),e.lineTo(t.x,t.maxPos)):(e.moveTo(t.minPos,t.y),e.lineTo(t.maxPos,t.y)),e.stroke(),e.beginPath(),o?(e.moveTo(t.x-.4*n,t.minPos),e.lineTo(t.x+.4*n,t.minPos),e.moveTo(t.x-.4*n,t.maxPos),e.lineTo(t.x+.4*n,t.maxPos)):(e.moveTo(t.minPos,t.y-.4*n),e.lineTo(t.minPos,t.y+.4*n),e.moveTo(t.maxPos,t.y-.4*n),e.lineTo(t.maxPos,t.y+.4*n)),e.stroke(),e.globalAlpha=c,e.fillStyle=a,o){const o=Math.min(t.q1Pos,t.q3Pos),r=Math.abs(t.q3Pos-t.q1Pos);e.fillRect(t.x-n,o,t.columnWidth,r),e.globalAlpha=1,e.strokeRect(t.x-n,o,t.columnWidth,r)}else{const o=Math.min(t.q1Pos,t.q3Pos),r=Math.abs(t.q3Pos-t.q1Pos);e.fillRect(o,t.y-n,r,t.columnWidth),e.globalAlpha=1,e.strokeRect(o,t.y-n,r,t.columnWidth)}e.strokeStyle="#fff",e.lineWidth=2,e.beginPath(),o?(e.moveTo(t.x-n,t.medianPos),e.lineTo(t.x+n,t.medianPos)):(e.moveTo(t.medianPos,t.y-n),e.lineTo(t.medianPos,t.y+n)),e.stroke(),e.restore()}},Fe]),violin:gt([dt]),histogram:gt([Ye]),ridgeline:gt([dt]),timeline:gt([Ye])},yt={top:50,right:40,bottom:60,left:70},ft={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:"4px",fontSize:"13px",lineHeight:"1.4",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function mt({hover:t}){var n,o,r,i;const a=t.data||{},s=t.stats,l=t.category;if(Array.isArray(a)){const t=l||(null===(n=a[0])||void 0===n?void 0:n.category)||"";if(s)return e.createElement("div",{className:"semiotic-tooltip",style:ft},t&&e.createElement("div",{style:{fontWeight:"bold"}},t+""),e.createElement("div",null,"n = ",s.n),e.createElement("div",null,"Min: ",s.min.toLocaleString()),e.createElement("div",null,"Q1: ",s.q1.toLocaleString()),e.createElement("div",null,"Median: ",s.median.toLocaleString()),e.createElement("div",null,"Q3: ",s.q3.toLocaleString()),e.createElement("div",null,"Max: ",s.max.toLocaleString()),e.createElement("div",{style:{opacity:.8}},"Mean: ",s.mean.toLocaleString(void 0,{maximumFractionDigits:2})));const o=a.length;return e.createElement("div",{className:"semiotic-tooltip",style:ft},t&&e.createElement("div",{style:{fontWeight:"bold"}},t+""),e.createElement("div",null,o," items"))}if(null!=a.bin&&null!=a.count){const t=a.range||[];return e.createElement("div",{className:"semiotic-tooltip",style:ft},a.category&&e.createElement("div",{style:{fontWeight:"bold"}},a.category+""),e.createElement("div",null,"Count: ",a.count),2===t.length&&e.createElement("div",{style:{opacity:.8}},Number(t[0]).toFixed(1)," – ",Number(t[1]).toFixed(1)))}const c=a.category||a.name||a.group||a.__rName||"",u=null!==(i=null!==(r=null!==(o=a.value)&&void 0!==o?o:a.__rValue)&&void 0!==r?r:a.pct)&&void 0!==i?i:"";if(!c&&""===u){const t=Object.entries(a).filter(([e])=>!e.startsWith("_")&&"data"!==e);return e.createElement("div",{className:"semiotic-tooltip",style:ft},t.map(([t,n])=>e.createElement("div",{key:t},e.createElement("span",{style:{opacity:.7}},t,":")," ","number"==typeof n?n.toLocaleString():n+"")))}return e.createElement("div",{className:"semiotic-tooltip",style:ft},c&&e.createElement("div",{style:{fontWeight:"bold"}},c+""),""!==u&&e.createElement("div",null,"number"==typeof u?u.toLocaleString():u+""))}const vt=i(function(i,l){var c;const{chartType:u,runtimeMode:d,data:h,oAccessor:g="category",rAccessor:p="value",colorAccessor:y,stackBy:f,groupBy:m,multiAxis:v,timeAccessor:b,valueAccessor:x,categoryAccessor:w,projection:k="vertical",size:A=[600,400],responsiveWidth:E,responsiveHeight:S,margin:O,barPadding:L,innerRadius:j,normalize:P,startAngle:M,dynamicColumnWidth:N,bins:D,showOutliers:C,showIQR:T,amplitude:B,connectorAccessor:W,connectorStyle:H,rExtent:$,oExtent:_,extentPadding:z=.05,oSort:I,windowMode:R="sliding",windowSize:F=200,pieceStyle:Y,summaryStyle:G,colorScheme:X,barColors:q,showAxes:V=!0,oLabel:U,rLabel:Z,oFormat:Q,rFormat:K,enableHover:J=!0,hoverAnnotation:ee,tooltipContent:te,customHoverBehavior:oe,annotations:re,svgAnnotationRules:ie,showGrid:ae=!1,legend:se,backgroundGraphics:le,foregroundGraphics:ce,title:ue,className:de,background:he,centerContent:ge,decay:pe,pulse:ye,transition:fe,staleness:me}=i,[ve,be]=Ae(A,E,S),xe=r(()=>Object.assign(Object.assign({},yt),O),[O]),Ee=be[0]-xe.left-xe.right,Se=be[1]-xe.top-xe.bottom,Oe=t(null),Le=t(!0),je=t(0),Pe=t(null),Me=t(()=>{}),[Ne,De]=n(null),[Ce,Te]=n(null),[Be,We]=n(0),[He,$e]=n(!1),_e=J||ee,ze="streaming"===d,Ie=r(()=>({chartType:u,runtimeMode:ze?"streaming":"bounded",windowSize:F,windowMode:R,extentPadding:z,projection:k,oAccessor:ze?void 0:g,rAccessor:ze?void 0:p,colorAccessor:y,stackBy:f,groupBy:m,multiAxis:v,timeAccessor:ze?b:void 0,valueAccessor:ze?x||("string"==typeof p||"function"==typeof p?p:void 0):void 0,categoryAccessor:ze?w||g:void 0,rExtent:$,oExtent:_,barPadding:L,innerRadius:j,normalize:P,startAngle:M,dynamicColumnWidth:N,bins:D,showOutliers:C,showIQR:T,amplitude:B,connectorAccessor:W,connectorStyle:H,oSort:I,pieceStyle:Y,summaryStyle:G,colorScheme:X,barColors:q,decay:pe,pulse:ye,transition:fe,staleness:me}),[u,F,R,z,k,g,p,y,f,m,v,b,x,w,$,_,L,j,P,M,N,D,C,T,B,W,H,I,Y,G,X,q,pe,ye,fe,me,ze]),Re=t(null);Re.current||(Re.current=new nt(Ie));const Fe=a(()=>{je.current||(je.current=requestAnimationFrame(()=>Me.current()))},[]);o(()=>{var e;null===(e=Re.current)||void 0===e||e.updateConfig(Ie),Le.current=!0,Fe()},[Ie,Fe]);const Ye=t(null);Ye.current||(Ye.current=new ne(e=>{const t=Re.current;t&&t.ingest(e)&&(Le.current=!0,Fe())}));const Ge=a(e=>{var t;null===(t=Ye.current)||void 0===t||t.push(e)},[]),Xe=a(e=>{var t;null===(t=Ye.current)||void 0===t||t.pushMany(e)},[]),qe=a(()=>{var e,t;null===(e=Ye.current)||void 0===e||e.clear(),null===(t=Re.current)||void 0===t||t.clear(),Le.current=!0,Fe()},[Fe]);s(l,()=>({push:Ge,pushMany:Xe,clear:qe,getData:()=>{var e,t;return null!==(t=null===(e=Re.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=Re.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null}}),[Ge,Xe,qe]),o(()=>{var e;if(h)return null===(e=Ye.current)||void 0===e||e.setBoundedData(h),()=>{var e;null===(e=Ye.current)||void 0===e||e.clearLastData()}},[h]);const Ve=t(()=>{}),Ue=t(()=>{});Ve.current=e=>{if(!_e)return;const t=Oe.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-xe.left,r=e.clientY-n.top-xe.top;if(0>o||o>Ee||0>r||r>Se)return void(Pe.current&&(Pe.current=null,De(null),oe&&oe(null),Fe()));const i=Re.current;if(!i||0===i.scene.length)return;const a="radial"===k,s=function(e,t,n,o=30){let r=null;for(const i of e){let e=null;switch(i.type){case"rect":e=ot(i,t,n);break;case"point":e=rt(i,t,n);break;case"wedge":e=it(i,t,n);break;case"boxplot":e=at(i,t,n);break;case"violin":e=st(i,t,n)}e&&o>e.distance&&(r&&e.distance>=r.distance||(r=e))}return r}(i.scene,a?o-Ee/2:o,a?r-Se/2:r);if(!s)return void(Pe.current&&(Pe.current=null,De(null),oe&&oe(null),Fe()));const l=Object.assign(Object.assign({data:s.datum,time:s.x,value:s.y,x:s.x,y:s.y},s.stats&&{stats:s.stats}),s.category&&{category:s.category});Pe.current=l,De(l),oe&&(oe(l),Le.current=!0),Fe()},Ue.current=()=>{Pe.current&&(Pe.current=null,De(null),oe&&(oe(null),Le.current=!0),Fe())},a(e=>Ve.current(e),[]);const Ze=a(()=>Ue.current(),[]),Qe=t(-1),Ke=a(e=>{const t=Re.current;if(!t||0===t.scene.length)return;const n=function(e){const t=[];for(const n of e)if("rect"===n.type&&null!=n.x)t.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum});else if("point"===n.type)t.push({x:n.x,y:n.y,datum:n.datum});else if("wedge"===n.type&&null!=n.cx){const e=((n.startAngle||0)+(n.endAngle||0))/2,o=((n.innerRadius||0)+(n.outerRadius||50))/2;t.push({x:n.cx+Math.cos(e)*o,y:n.cy+Math.sin(e)*o,datum:n.datum})}return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}(t.scene);if(0===n.length)return;const o=Qe.current,r=we(e.key,0>o?-1:o,n.length);if(null===r)return;if(e.preventDefault(),0>r)return Qe.current=-1,Pe.current=null,De(null),oe&&oe(null),void Fe();const i=0>o?0:r;Qe.current=i;const a=ke(n[i]);Pe.current=a,De(a),oe&&oe(a),Fe()},[oe,Fe]),Je=a(e=>{Qe.current=-1,Ve.current(e)},[]);Me.current=()=>{var e,t;je.current=0;const n=Oe.current;if(!n)return;const o=n.getContext("2d");if(!o)return;const r=Re.current;if(!r)return;const i="undefined"!=typeof performance?performance.now():Date.now(),a=r.advanceTransition(i),s=Le.current;s&&!a&&(r.computeScene({width:Ee,height:Se}),Le.current=!1);const l="undefined"!=typeof window&&window.devicePixelRatio||1;n.width=be[0]*l,n.height=be[1]*l,n.style.width=be[0]+"px",n.style.height=be[1]+"px",o.scale(l,l),o.clearRect(0,0,be[0],be[1]);const c=null!==(e=null==me?void 0:me.threshold)&&void 0!==e?e:5e3,d=me&&r.lastIngestTime>0&&i-r.lastIngestTime>c;d&&(o.globalAlpha=null!==(t=null==me?void 0:me.dimOpacity)&&void 0!==t?t:.5);const h=n?getComputedStyle(n).getPropertyValue("--semiotic-bg").trim():"",g=he||(h&&"transparent"!==h?h:null);g&&(o.fillStyle=g,o.fillRect(0,0,be[0],be[1]));const p="radial"===k;p?(o.save(),o.translate(xe.left+Ee/2,xe.top+Se/2)):o.translate(xe.left,xe.top);const y=pt[u]||[],f={width:Ee,height:Se};for(const e of y)e(o,r.scene,r.scales,f);p&&o.restore(),d&&(o.globalAlpha=1),s&&r.scales&&(Te(r.scales),We(e=>e+1)),(null==me?void 0:me.showBadge)&&$e(!!d),(a||r.hasActivePulses)&&(je.current=requestAnimationFrame(()=>Me.current()))},o(()=>(Fe(),()=>{je.current&&(cancelAnimationFrame(je.current),je.current=0)}),[Fe]),o(()=>{Le.current=!0,Fe()},[u,Ee,Se,V,he,Fe]),o(()=>{if(!me)return;const e=setInterval(()=>{var e;const t=Re.current;if(!t||0===t.lastIngestTime)return;const n="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(e=me.threshold)&&void 0!==e?e:5e3,r=n-t.lastIngestTime>o;r!==He&&($e(r),Le.current=!0,Fe())},1e3);return()=>clearInterval(e)},[me,He,Fe]);const et=_e&&Ne?te?te(Ne):e.createElement(mt,{hover:Ne}):null,tt="radial"===k,lt=Ne?tt?Ne.x+Ee/2:Ne.x:0,ut=Ne?tt?Ne.y+Se/2:Ne.y:0,dt=et?e.createElement("div",{className:"stream-ordinal-tooltip",style:{position:"absolute",left:xe.left+lt,top:xe.top+ut,transform:`translate(${lt>.7*Ee?"calc(-100% - 12px)":"12px"}, ${.3*Se>ut?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:1}},et):null;return e.createElement("div",{ref:ve,className:"stream-ordinal-frame"+(de?" "+de:""),role:"img","aria-label":"string"==typeof ue?ue:"Ordinal chart",tabIndex:0,style:{position:"relative",width:E?"100%":be[0],height:S?"100%":be[1]},onMouseMove:_e?Je:void 0,onMouseLeave:_e?Ze:void 0,onKeyDown:Ke},le&&e.createElement("svg",{style:{position:"absolute",top:0,left:0,width:be[0],height:be[1],pointerEvents:"none"}},e.createElement("g",{transform:`translate(${xe.left},${xe.top})`},le)),e.createElement("canvas",{ref:Oe,style:{position:"absolute",top:0,left:0,width:be[0],height:be[1]}}),e.createElement(ct,{width:Ee,height:Se,totalWidth:be[0],totalHeight:be[1],margin:xe,scales:Ce,showAxes:V,oLabel:U,rLabel:Z,oFormat:Q,rFormat:K,showGrid:ae,title:ue,legend:se,foregroundGraphics:ce,annotations:re,svgAnnotationRules:ie,annotationFrame:Be,xAccessor:"string"==typeof g?g:void 0,yAccessor:"string"==typeof p?p:void 0,annotationData:null===(c=Re.current)||void 0===c?void 0:c.getData()}),ge&&"radial"===k&&e.createElement("div",{style:{position:"absolute",left:xe.left+Ee/2,top:xe.top+Se/2,transform:"translate(-50%, -50%)",pointerEvents:"none",textAlign:"center"}},ge),(null==me?void 0:me.showBadge)&&e.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===me.badgePosition?{top:4,left:4}:"bottom-left"===me.badgePosition?{bottom:4,left:4}:"bottom-right"===me.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:He?"#dc3545":"#28a745",color:"white"})},He?"STALE":"LIVE"),dt)});vt.displayName="StreamOrdinalFrame";const bt={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},xt={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class wt{constructor(e){this.capacity=e,this.particles=Array(e);for(let t=0;e>t;t++)this.particles[t]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0}}spawn(e){for(let t=0;this.capacity>t;t++){const n=this.particles[t];if(!n.active)return n.active=!0,n.t=0,n.offset=Math.random()-.5,n.edgeIndex=e,n.x=0,n.y=0,n}return null}step(e,t,n,o){var r;for(let i=0;this.capacity>i;i++){const a=this.particles[i];if(!a.active)continue;const s=n[a.edgeIndex];if(!s||!s.bezier){a.active=!1;continue}const l=o&&null!==(r=o[a.edgeIndex])&&void 0!==r?r:1;if(a.t+=e*t*l*(s.bezier.circular?.3:1),a.t>=1){a.active=!1;continue}const c=kt(s.bezier,a.t,a.offset);a.x=c.x,a.y=c.y}}countForEdge(e){let t=0;for(let n=0;this.capacity>n;n++)this.particles[n].active&&this.particles[n].edgeIndex===e&&t++;return t}clear(){for(let e=0;this.capacity>e;e++)this.particles[e].active=!1}resize(e){if(this.capacity>=e)return;const t=this.particles;this.particles=Array(e);for(let n=0;e>n;n++)this.particles[n]=t.length>n?t[n]:{t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0};this.capacity=e}}function kt(e,t,n){if(e.circular&&e.segments)return function(e,t,n,o){const r=e.length,i=t*r,a=Math.min(Math.floor(i),r-1),s=i-a,[l,c,u,d]=e[a],h=At(l,c,u,d,s),g=d.x-l.x,p=d.y-l.y,y=Math.sqrt(g*g+p*p);if(y>.001){const e=g/y;h.x+=-p/y*n*o*2,h.y+=e*n*o*2}return h}(e.segments,t,n,e.halfWidth);if(!e.points)return{x:0,y:0};const[o,r,i,a]=e.points,s=At(o,r,i,a,t),l=a.x-o.x,c=a.y-o.y,u=Math.sqrt(l*l+c*c);if(u>.001){const t=l/u;s.x+=-c/u*n*e.halfWidth*2,s.y+=t*n*e.halfWidth*2}return s}function At(e,t,n,o,r){const i=1-r,a=i*i,s=a*i,l=r*r,c=l*r;return{x:s*e.x+3*a*r*t.x+3*i*l*n.x+c*o.x,y:s*e.y+3*a*r*t.y+3*i*l*n.y+c*o.y}}function Et(e,t){var n=e.get(t);if(!n)throw Error("missing: "+t);return n}function St(e,t){var n,o=[],r=[],i=[],a={},s=[];function l(e){i[e]=!1,a.hasOwnProperty(e)&&Object.keys(a[e]).forEach(function(t){delete a[e][t],i[t]&&l(t)})}function c(e){var t,o,d=!1;for(r.push(e),i[e]=!0,t=0;s[e].length>t;t++)(o=s[e][t])===n?(u(n,r),d=!0):i[o]||(d=c(o));if(d)l(e);else for(t=0;s[e].length>t;t++){var h=a[o=s[e][t]];h||(a[o]=h={}),h[o]=!0}return r.pop(),d}function u(e,t){var n=[].concat(t).concat(e);o.push(n)}function d(t){!function(t){for(var n=0;e.length>n;n++)n>=t&&e[n]||(e[n]=[]),e[n]=e[n].filter(function(e){return e>=t})}(t);for(var n,o=function(e){for(var t=e.length,n=Array(t),o=Array(t),r=Array(t),i=Array(t),a=Array(t),s=Array(t),l=0;t>l;++l)n[l]=-1,o[l]=0,r[l]=!1,i[l]=0,a[l]=-1,s[l]=[];var c,u=0,d=[],h=[];function g(t){var l=[t],c=[t];for(n[t]=o[t]=u,r[t]=!0,u+=1;c.length>0;){var g=e[t=c[c.length-1]];if(g.length>i[t]){for(var p=i[t];g.length>p;++p){var y=g[p];if(0>n[y]){n[y]=o[y]=u,r[y]=!0,u+=1,l.push(y),c.push(y);break}r[y]&&(o[t]=0|Math.min(o[t],o[y])),0>a[y]||s[t].push(a[y])}i[t]=p}else{if(o[t]===n[t]){var f=[],m=[],v=0;for(p=l.length-1;p>=0;--p){var b=l[p];if(r[b]=!1,f.push(b),m.push(s[b]),v+=s[b].length,a[b]=d.length,b===t){l.length=p;break}}d.push(f);var x=Array(v);for(p=0;m.length>p;p++)for(var w=0;m[p].length>w;w++)x[--v]=m[p][w];h.push(x)}c.pop()}}}for(l=0;t>l;++l)0>n[l]&&g(l);for(l=0;h.length>l;l++){var p=h[l];if(0!==p.length){p.sort(function(e,t){return e-t}),c=[p[0]];for(var y=1;p.length>y;y++)p[y]!==p[y-1]&&c.push(p[y]);h[l]=c}}return{components:d,adjacencyList:h}}(e),r=o.components.filter(function(e){return e.length>1}),i=1/0,a=0;r.length>a;a++)for(var s=0;r[a].length>s;s++)i>r[a][s]&&(i=r[a][s],n=a);var l=r[n];if(!l)return!1;var c=e.map(function(e,t){return-1===l.indexOf(t)?[]:e.filter(function(e){return-1!==l.indexOf(e)})});return{leastVertex:i,adjList:c}}n=0;for(var h=e.length;h>n;){var g=d(n);if(n=g.leastVertex,s=g.adjList){for(var p=0;s.length>p;p++)for(var y=0;s[p].length>y;y++){var f=s[p][y];i[+f]=!1,a[f]={}}c(n),n+=1}else n=h}return o}function Ot(e){return e.y0-e.y1>0?"up":"down"}function Lt(e,t){return t(e.source)==t(e.target)}function jt(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var n=0;return e.target.targetLinks.forEach(function(e){n=e.circular?n+1:n}),1>=t&&1>=n}function Pt(e){return e.target.x0-e.source.x1}function Mt(e,t){var n=Dt(e),o=Pt(t)/Math.tan(n);return"up"==Ot(e)?e.y1-o:e.y1+o}function Nt(e,t){var n=Dt(e),o=Pt(t)/Math.tan(n);return"up"==Ot(e)?e.y1+o:e.y1-o}function Dt(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function Ct(e,t){return t(e)}function Tt(e){return Wt(e.source)}function Bt(e){return Wt(e.target)}function Wt(e){return(e.y0+e.y1)/2}function Ht(e){return e.virtual?0:e.value}function $t(e,t){var n=0;e.sourceLinks.forEach(function(e){n=e.circular&&!Lt(e,t)?n+1:n});var o=0;return e.targetLinks.forEach(function(e){o=e.circular&&!Lt(e,t)?o+1:o}),n+o}function _t(e){return e.target.depth}function zt(e,t){return e.sourceLinks.length?e.depth:t-1}function It(e,t){return e.y0-t.y0}function Rt(e,t){return t.y0-e.y0}function Ft(e,t){return e.y1-t.y1}function Yt(e,t){return t.y1-e.y1}function Gt(e,t){return qt(e.source,t.source)||e.index-t.index}function Xt(e,t){return qt(e.target,t.target)||e.index-t.index}function qt(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function Vt(e,t){return Ut(e)==Ut(t)?"bottom"==e.circularLinkType?Rt(e,t):It(e,t):Ut(t)-Ut(e)}function Ut(e){return e.target.column-e.source.column}function Zt(e,t){return Qt(e)==Qt(t)}function Qt(e){return e.y0-e.y1>0?"up":"down"}function Kt(e,t,n,o,r){let i=e;var a=Math.max(8,.15*(i.y1-i.y0));i.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,a))});var s=k(i.links,function(e){return e.source.y0});i.links.forEach(function(e){e.circular&&(e.circularPathData={})});var l=i.links.filter(function(e){return e.circular});return l.sort(function(e,t){return t.value-e.value}),l.forEach(function(e,t){e._circularStub=t>=4}),Jt(i.links.filter(function(e){return"top"==e.circularLinkType}),t,n),Jt(i.links.filter(function(e){return"bottom"==e.circularLinkType}),t,n),i.links.forEach(function(e){if(e.circular){if(e.circularPathData.arcRadius=e._circularWidth+o,e.circularPathData.rightNodeBuffer=5,e.circularPathData.leftNodeBuffer=5,e.circularPathData.sourceWidth=e.source.x1-e.source.x0,e.circularPathData.sourceX=e.source.x0+e.circularPathData.sourceWidth,e.circularPathData.targetX=e.target.x0,e.circularPathData.sourceY=e.y0,e.circularPathData.targetY=e.y1,Lt(e,t)&&jt(e))e.circularPathData.rightSmallArcRadius=o+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=o+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=o+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=o+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+r+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=e.source.y0-r-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius);else{var a=e.source.column,l=e.circularLinkType,c=i.links.filter(function(e){return e.source.column==a&&e.circularLinkType==l});c.sort("bottom"==e.circularLinkType?Rt:It);var u=0;c.forEach(function(t,r){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=o+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=o+e._circularWidth/2+r*n+u),u+=t._circularWidth||t.width}),a=e.target.column,(c=i.links.filter(function(e){return e.target.column==a&&e.circularLinkType==l})).sort("bottom"==e.circularLinkType?Yt:Ft),u=0,c.forEach(function(t,r){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=o+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=o+e._circularWidth/2+r*n+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(i.y1,e.source.y1,e.target.y1)+r+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=s-r-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius)}e.circularPathData.rightInnerExtent=e.circularPathData.sourceX+e.circularPathData.rightNodeBuffer,e.circularPathData.leftInnerExtent=e.circularPathData.targetX-e.circularPathData.leftNodeBuffer,e.circularPathData.rightFullExtent=e.circularPathData.sourceX+e.circularPathData.rightLargeArcRadius+e.circularPathData.rightNodeBuffer,e.circularPathData.leftFullExtent=e.circularPathData.targetX-e.circularPathData.leftLargeArcRadius-e.circularPathData.leftNodeBuffer}e.path=e.circular?function(e){return"top"==e.circularLinkType?"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 0 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY-e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 0 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 0 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY-e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 0 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY:"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 1 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY+e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 1 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 1 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY+e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 1 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY}(e):function(e){var t=e.source.x1,n=e.y0,o=e.target.x0,r=e.y1,i=(t+o)/2;return"M"+t+","+n+"C"+i+","+n+" "+i+","+r+" "+o+","+r}(e)}),i}function Jt(e,t,n){e.sort(Vt);var o=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,r){var i=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(Lt(e,t)&&jt(e))e.circularPathData.verticalBuffer=i+e._circularWidth/2;else{for(var a=0;o.length>a;a++){var s=o[a];if(s!==e&&s.circularPathData&&void 0!==s.circularPathData.verticalBuffer&&en(e,s)){var l=s.circularPathData.verticalBuffer+(s._circularWidth||s.width)/2+n;i=l>i?l:i}}e.circularPathData.verticalBuffer=i+e._circularWidth/2}}),e}function en(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}function tn(e){return function(){return e}}function nn(e){return e.index}function on(e){return e.nodes}function rn(e){return e.links}function an(e,t,n){var o=A(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});o.forEach(function(r){var i=r.length;r.sort(t||function(e,t){return e.circularLinkType==t.circularLinkType?$t(t,n)-$t(e,n):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0}),r.forEach(function(t,r){t.depth==o.length-1&&1==i||0==t.depth&&1==i?(t.y0=e.y1/2-t.value*e.ky,t.y1=t.y0+t.value*e.ky):t.partOfCycle?0==$t(t,n)?(t.y0=e.y1/2+r,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+r,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-r,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/i*r,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-i/2+r,t.y1=t.y0+t.value*e.ky)})})}function sn(e,t,n,o,r,i){var a=A(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});u();for(var s=1,l=i;l>0;--l)c(s*=.99,n),u();function c(t,n){var o=a.length;a.forEach(function(r){var i=r.length,a=r[0].depth;r.forEach(function(r){var s;if(r.sourceLinks.length||r.targetLinks.length)if(r.partOfCycle&&$t(r,n)>0){var l=O(r.sourceLinks,Bt),c=O(r.targetLinks,Tt),u=l&&c?(l+c)/2:l||c;if(u){var d=(u-Wt(r))*t*.3;r.y0+=d,r.y1+=d}}else if(0==a&&1==i)r.y0=e.y1/2-(s=r.y1-r.y0)/2,r.y1=e.y1/2+s/2;else if(a==o-1&&1==i)r.y0=e.y1/2-(s=r.y1-r.y0)/2,r.y1=e.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 h=O(r.sourceLinks,Bt),g=O(r.targetLinks,Tt),p=((h&&g?(h+g)/2:h||g)-Wt(r))*t;r.y0+=p,r.y1+=p}})})}function u(){a.forEach(function(n){var i,a,s,l=e.y0,c=n.length;for(n.sort(t||qt),s=0;c>s;++s)(a=l-(i=n[s]).y0)>0&&(i.y0+=a,i.y1+=a),l=i.y1+o;if((a=l-o-e.y1)>0)for(l=i.y0-=a,i.y1-=a,s=c-2;s>=0;--s)(a=(i=n[s]).y1+r-l)>0&&(i.y0-=a,i.y1-=a),l=i.y0})}}function ln(e){e.nodes.forEach(function(e){e.sourceLinks.sort(Xt),e.targetLinks.sort(Gt)}),e.nodes.forEach(function(e){var t=e.y0,n=t,o=e.y1,r=o;e.sourceLinks.forEach(function(e){e.circular?(e.y0=o-e.width/2,o-=e.width):(e.y0=t+e.width/2,t+=e.width)}),e.targetLinks.forEach(function(e){e.circular?(e.y1=r-e.width/2,r-=e.width):(e.y1=n+e.width/2,n+=e.width)})})}function cn(){var e=0,t=0,n=1,o=1,r=24,i=8,a=null,s=nn,l=zt,c=void 0,u=32,d=2,h=on,g=rn;function p(){var p={nodes:h.apply(null,arguments),links:g.apply(null,arguments)};return function(h){h.x0=e,h.y0=t,h.x1=n,h.y1=o,h.py=0,function(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var n=function(e,t){var n=new Map;return L(e,t).forEach(function(e,t){n.set(t,e[0])}),n}(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var o=e.source,r=e.target;"object"!=typeof o&&(o=e.source=Et(n,o)),"object"!=typeof r&&(r=e.target=Et(n,r)),o.sourceLinks.push(e),r.targetLinks.push(e)})}(h,s),function(e,t){var n=0;if(null==t){for(var o=[],r=0;e.links.length>r;r++){var i=e.links[r],a=i.source.index,s=i.target.index;o[a]||(o[a]=[]),o[s]||(o[s]=[]),-1===o[a].indexOf(s)&&o[a].push(s)}var l=St(o);l.sort(function(e,t){return e.length-t.length});var c={};for(r=0;l.length>r;r++){var u=l[r].slice(-2);c[u[0]]||(c[u[0]]={}),c[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,o=e.source.index;t===o||c[o]&&c[o][t]?(e.circular=!0,e.circularLinkID=n++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=n++)})}(h,c),function(e,t){var n=0,o=0;e.links.forEach(function(r){r.circular&&(r.circularLinkType=r.source.circularLinkType||r.target.circularLinkType?r.source.circularLinkType?r.source.circularLinkType:r.target.circularLinkType:o>n?"top":"bottom","top"==r.circularLinkType?n++:o++,e.nodes.forEach(function(e){Ct(e,t)!=Ct(r.source,t)&&Ct(e,t)!=Ct(r.target,t)||(e.circularLinkType=r.circularLinkType)}))}),e.links.forEach(function(e){e.circular&&(e.source.circularLinkType==e.target.circularLinkType&&(e.circularLinkType=e.source.circularLinkType),Lt(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(h,s),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(S(e.sourceLinks,Ht),S(e.targetLinks,Ht)),e.sourceLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)}),e.targetLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)})})}(h),function(e,t,n){var o,r,i;if(null!=t){e.nodes.sort(function(e,n){return t(e)<t(n)?-1:1});var a=0,s=t(e.nodes[0]);e.nodes.forEach(function(e){a=t(e)==s?a:a+1,s=t(e)==s?s:t(e),e.column=a})}for(o=e.nodes,r=[],i=0;o.length;++i,o=r,r=[])o.forEach(function(e){e.depth=i,e.sourceLinks.forEach(function(e){0>r.indexOf(e.target)&&!e.circular&&r.push(e.target)})});for(o=e.nodes,r=[],i=0;o.length;++i,o=r,r=[])o.forEach(function(e){e.height=i,e.targetLinks.forEach(function(e){0>r.indexOf(e.source)&&!e.circular&&r.push(e.source)})});e.nodes.forEach(function(e){e.column=null==t?n(e,i):e.column})}(h,c,l);var g=i;if(null!==a){var p=A(h.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),y=E(p,function(e){return e.length});y>1&&(g=Math.max(1,(o-t)*a/(y-1)))}(function(e,t,n){var o=A(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});e.py=t;var r=k(o,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/S(t,function(e){return e.value})});e.ky=r,e.links.forEach(function(t){t.width=t.value*e.ky});var i=E(e.nodes,function(e){return e.column});e.nodes.forEach(i>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-n)/i),t.x1=t.x0+n}:function(t){t.x0=e.x0,t.x1=t.x0+n})})(h,g,r),an(h,c,s),sn(h,c,s,g,g,u),ln(h),Kt(h,s,d,10,8),an(h,c,s),sn(h,c,s,g,g,u),ln(h),Kt(h,s,d,10,8),function(e,t){let n=e;n.nodes.forEach(function(e){e.y+(e.y1-e.y0)>n.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-n.y1));var o=n.links.filter(function(n){return Ct(n.source,t)==Ct(e,t)}),r=o.length;r>1&&o.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!Zt(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var n=Mt(t,e);return e.y1-n}if(t.target.column>e.target.column)return Mt(e,t)-t.y1}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.target.column===t.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.target.column===t.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;o.forEach(function(e){e.y0=i+e.width/2,i+=e.width}),o.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,a=0;r>i;i++)a+=o[i].width;t.y0=e.y1-a-t.width/2}})})}(h,s),function(e,t){let n=e;n.nodes.forEach(function(e){var o=n.links.filter(function(n){return Ct(n.target,t)==Ct(e,t)}),r=o.length;r>1&&o.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!Zt(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var n=Nt(t,e);return e.y0-n}if(t.source.column>e.source.column)return Nt(e,t)-t.y0}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:e.source.column-t.source.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:t.source.column-e.source.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;o.forEach(function(e){e.y1=i+e.width/2,i+=e.width}),o.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,a=0;r>i;i++)a+=o[i].width;t.y1=e.y1-a-t.width/2}})})}(h,s),function(e){var t=e.nodes,n=e.links,o=!1,r=!1;if(n.forEach(function(e){"top"==e.circularLinkType?o=!0:"bottom"==e.circularLinkType&&(r=!0)}),0==o||0==r){var i=k(t,function(e){return e.y0}),a=E(t,function(e){return e.y1}),s=(e.y1-e.y0)/(a-i);function l(t){return(t-i)/(a-i)*(e.y1-e.y0)+e.y0}1>s?(t.forEach(function(e){e.y0=l(e.y0),e.y1=l(e.y1)}),n.forEach(function(e){e.y0=l(e.y0),e.y1=l(e.y1),e.width=e.width*s})):t.forEach(function(e){var t=e.y1-e.y0,n=l(e.y0)-e.y0;e.y0=l(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+n}),e.targetLinks.forEach(function(e){e.y1=e.y1+n})})}}(h),Kt(h,s,d,10,8)}(p),p}return p.update=function(e){return ln(e),Kt(e,s,d,10,8),e},p.nodeWidth=function(e){return arguments.length?(r=+e,p):r},p.nodePadding=function(e){return arguments.length?(i=+e,p):i},p.nodePaddingRatio=function(e){return arguments.length?(a=+e,p):a},p.nodes=function(e){return arguments.length?(h="function"==typeof e?e:tn(e),p):h},p.links=function(e){return arguments.length?(g="function"==typeof e?e:tn(e),p):g},p.nodeId=function(e){return arguments.length?(s="function"==typeof e?e:tn(e),p):s},p.nodeAlign=function(e){return arguments.length?(l="function"==typeof e?e:tn(e),p):l},p.nodeSort=function(e){return arguments.length?(c=e,p):c},p.iterations=function(e){return arguments.length?(u=+e,p):u},p.circularLinkGap=function(e){return arguments.length?(d=+e,p):d},p.extent=function(r){return arguments.length?(e=+r[0][0],t=+r[0][1],n=+r[1][0],o=+r[1][1],p):[[e,t],[n,o]]},p.size=function(r){return arguments.length?(e=t=0,n=+r[0],o=+r[1],p):[n-e,o-t]},p}const un=e=>{let t,n,o,r,i,a,s,l,c;return"down"===e.direction?(t=e.y0-e.sankeyWidth/2,n=e.y1-e.sankeyWidth/2,o=e.y1+e.sankeyWidth/2,r=e.y0+e.sankeyWidth/2,i=e.source.y1,a=e.target.y0,s=W(i,a),l=s(.5),c=s(.5),`M${t},${i}C${t},${l} ${n},${c} ${n},${a}L${o},${a}C${o},${c} ${r},${l} ${r},${i}Z`):(t=e.source.x1,n=e.target.x0,s=W(t,n),o=s(.5),r=s(.5),i=e.y0-e.sankeyWidth/2,a=e.y1-e.sankeyWidth/2,l=e.y1+e.sankeyWidth/2,c=e.y0+e.sankeyWidth/2,`M${t},${i}C${o},${i} ${r},${a} ${n},${a}L${n},${l}C${r},${l} ${o},${c} ${t},${c}Z`)};function dn(e){var t;const n=e.sankeyWidth/2,o=(null!==(t=e._circularWidth)&&void 0!==t?t:e.sankeyWidth)/2,r=e.circularPathData;if(!r)return null;if("down"===e.direction)return null;if(e._circularStub){const t=r.sourceX,o=r.sourceY,i=r.targetX,a=r.targetY;if("object"!=typeof e.source||!e.source||"object"!=typeof e.target||!e.target)return null;const s=Math.max(15,Math.min(40,.33*(r.rightFullExtent-t))),l=Math.max(15,Math.min(40,.33*(i-r.leftFullExtent)));return`M${t},${o-n}L${t+s},${o-n}L${t+s},${o+n}L${t},${o+n}ZM${i},${a-n}L${i-l},${a-n}L${i-l},${a+n}L${i},${a+n}Z`}const i=r.sourceX,a=r.sourceY,s=r.targetX,l=r.targetY,c=r.rightFullExtent,u=r.leftFullExtent,d=r.verticalFullExtent,h="bottom"===e.circularLinkType?1:-1,g=Math.max(4,Math.min(o,15));return`M${i},${a-h*n}L${c},${a-h*n}L${c+o},${a-h*n+h*g}L${c+o},${d+h*o-h*g}L${c+o-g},${d+h*o}L${u-o+g},${d+h*o}L${u-o},${d+h*o-h*g}L${u-o},${l-h*n+h*g}L${u-o+g},${l-h*n}L${s},${l-h*n}L${s},${l+h*n}L${u+o},${l+h*n}L${u+o},${d-h*o}L${c-o},${d-h*o}L${c-o},${a+h*n}L${i},${a+h*n}Z`}const hn={left:function(e){return e.depth},right:function(e,t){return t-1-e.height},center:function(e){return e.targetLinks.length?e.depth:e.sourceLinks.length?Math.min.apply(Math,e.sourceLinks.map(_t))-1:0},justify:zt},gn={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,o){var r,i,a,s,l,c,u;if(0===e.length)return;const d="vertical"===n.orientation?"down":"right",h=n.nodeAlign||"justify",g=null!==(r=n.nodeWidth)&&void 0!==r?r:15,p=null!==(i=n.nodePaddingRatio)&&void 0!==i?i:.05,y=null!==(a=n.iterations)&&void 0!==a?a:100,f=e.map(e=>Object.assign({},e)),m=t.map(e=>Object.assign(Object.assign({},e),{source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id,value:Math.sqrt(Math.max(1,e.value||1))}));let v;v="down"===d?[[0,0],[o[1],o[0]]]:[[0,0],[o[0],o[1]]];const b=cn().extent(v).links(m).nodes(f).nodeAlign(hn[h]||zt).nodeId(e=>e.id).nodeWidth(g).iterations(y);b.nodePaddingRatio&&b.nodePaddingRatio(p),b();{let e=1/0,t=-1/0,n=1/0,r=-1/0;for(const o of f)e>o.x0&&(e=o.x0),o.x1>t&&(t=o.x1),n>o.y0&&(n=o.y0),o.y1>r&&(r=o.y1);for(const o of m){if(!o.circular||!o.circularPathData)continue;const i=o.circularPathData,a=(null!==(l=null!==(s=o._circularWidth)&&void 0!==s?s:o.width)&&void 0!==l?l:0)/2;e>i.leftFullExtent-a&&(e=i.leftFullExtent-a),i.rightFullExtent+a>t&&(t=i.rightFullExtent+a),n>i.verticalFullExtent-a&&(n=i.verticalFullExtent-a),i.verticalFullExtent+a>r&&(r=i.verticalFullExtent+a)}const i=t-e,a=r-n,u=o[0],d=o[1];if(i>0&&a>0&&(0>e||0>n||t>u||r>d)){const t=Math.min(u/i,d/a),o=-e*t+(u-i*t)/2,r=-n*t+(d-a*t)/2;for(const e of f)e.x0=e.x0*t+o,e.x1=e.x1*t+o,e.y0=e.y0*t+r,e.y1=e.y1*t+r;for(const e of m)if(e.y0=e.y0*t+r,e.y1=e.y1*t+r,e.width=(null!==(c=e.width)&&void 0!==c?c:0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){const n=e.circularPathData;n.sourceX=n.sourceX*t+o,n.targetX=n.targetX*t+o,n.sourceY=n.sourceY*t+r,n.targetY=n.targetY*t+r,n.rightFullExtent=n.rightFullExtent*t+o,n.leftFullExtent=n.leftFullExtent*t+o,n.verticalFullExtent=n.verticalFullExtent*t+r,n.rightInnerExtent=n.rightInnerExtent*t+o,n.leftInnerExtent=n.leftInnerExtent*t+o,n.verticalRightInnerExtent=n.verticalRightInnerExtent*t+r,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*t+r,n.rightSmallArcRadius*=t,n.rightLargeArcRadius*=t,n.leftSmallArcRadius*=t,n.leftLargeArcRadius*=t,n.sourceWidth*=t,n.rightNodeBuffer*=t,n.leftNodeBuffer*=t,n.arcRadius*=t}}}const x=new Map;for(const t of e)x.set(t.id,t);for(const e of f){const t=x.get(e.id);t&&(t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.value=e.value,t.depth=e.depth,t.sourceLinks=e.sourceLinks,t.targetLinks=e.targetLinks,t.width=e.x1-e.x0,t.height=e.y1-e.y0,t.x=e.x0+(e.x1-e.x0)/2,t.y=e.y0+(e.y1-e.y0)/2)}const w=new Map;for(const e of t)w.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const e of m){const t=e.source,n=e.target,o="object"==typeof t&&null!==t?t.id:t+"",r="object"==typeof n&&null!==n?n.id:n+"",i=w.get(`${o}\0${r}`);if(i){i.y0=e.y0,i.y1=e.y1,i.sankeyWidth=null!==(u=e.width)&&void 0!==u?u:0,i.circular=!!e.circular,i.circularPathData=e.circularPathData,i._circularWidth=e._circularWidth,i._circularStub=e._circularStub,i.path=e.path,i.circularLinkType=e.circularLinkType,i.direction=d;const t=x.get(o),n=x.get(r);t&&(i.source=t),n&&(i.target=n)}}},buildScene(e,t,n,o){var r,i,a,s;const l="vertical"===n.orientation?"down":"right",c=n.nodeStyle,u=n.edgeStyle,d=null!==(r=n.edgeOpacity)&&void 0!==r?r:.5,h=n.edgeColorBy||"source",g=Array.isArray(n.colorScheme)?n.colorScheme:H,p=new Map;e.forEach((e,t)=>{p.set(e.id,g[t%g.length])});const y=[],f=[],m=[];for(const t of e){const e=t.x1-t.x0,n=t.y1-t.y0;if(0>=e||0>=n)continue;const o=c?c(t):{},r={fill:o.fill||p.get(t.id)||"#4d430c",stroke:o.stroke,strokeWidth:o.strokeWidth,opacity:o.opacity};y.push({type:"rect",x:t.x0,y:t.y0,w:e,h:n,style:r,datum:t,id:t.id,label:t.id})}const v=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of v){if(!e.sankeyWidth||0>=e.sankeyWidth)continue;const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;if(!t||!n)continue;let o="#999";u?o=u(e).fill||o:"target"===h&&n?o=p.get(n.id)||o:t&&(o=p.get(t.id)||o);const r=u?u(e):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,n=e.sankeyWidth/2,s=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),l=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),c=r.fill||o;f.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-n}L${t.sourceX+s},${t.sourceY-n}L${t.sourceX+s},${t.sourceY+n}L${t.sourceX},${t.sourceY+n}Z`,style:{fill:c,fillOpacity:null!==(i=r.fillOpacity)&&void 0!==i?i:d,stroke:"none",opacity:r.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+s}}),f.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-n}L${t.targetX-l},${t.targetY-n}L${t.targetX-l},${t.targetY+n}L${t.targetX},${t.targetY+n}Z`,style:{fill:c,fillOpacity:null!==(a=r.fillOpacity)&&void 0!==a?a:d,stroke:"none",opacity:r.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-l,x1:t.targetX}});continue}let l;if(l=e.circular&&e.circularPathData?dn(e):un(e),!l)continue;const c={fill:r.fill||o,fillOpacity:null!==(s=r.fillOpacity)&&void 0!==s?s:d,stroke:r.stroke||"none",strokeWidth:r.strokeWidth,opacity:r.opacity};f.push({type:"bezier",pathD:l,bezierCache:e.bezier,style:c,datum:e})}if(!1!==n.showLabels){const t=(b=n.nodeLabel)?"function"==typeof b?b:e=>e[b]||e.id:null;for(const n of e){const e=n.x1-n.x0,r=n.y1-n.y0;if(0>=e||0>=r)continue;const i=t?t(n):n.id;if(!i)continue;let a,s,c;"down"===l?(a=n.x0+e/2,s=n.y1+14,c="middle"):(o[0]/2>n.x0+e/2?(a=n.x0-6,c="end"):(a=n.x1+6,c="start"),s=n.y0+r/2),m.push({x:a,y:s,text:i+"",anchor:c,baseline:"middle",fontSize:11})}}var b;return{sceneNodes:y,sceneEdges:f,labels:m}}},pn={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,n,o){var r,i;if(0===e.length)return;const a=null!==(r=n.iterations)&&void 0!==r?r:Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),s=null!==(i=n.forceStrength)&&void 0!==i?i:.1,l=o[0]/2,c=o[1]/2;for(let t=0;e.length>t;t++){const n=e[t];if(null==n.x||null==n.y||0===n.x&&0===n.y){const e=10*Math.sqrt(t+.5),o=2.399963229728653*t;n.x=l+e*Math.cos(o),n.y=c+e*Math.sin(o)}}const u=yn(n.nodeSize,n.nodeSizeRange,e),d=q().strength(e=>Math.min(2.5,e.weight?e.weight*s:s)).id(e=>e.id),h=o[1]/o[0],g=V().force("charge",U().strength(e=>-25*(e=>u(e))(e))).force("x",Z(o[0]/2).strength(.1*h)).force("y",Q(o[1]/2).strength(.1));if(g.nodes(e),t.length>0){const e=t.map(e=>Object.assign(Object.assign({},e),{source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id}));g.force("link",d),g.force("link").links(e)}.1>g.alpha()&&g.alpha(1),g.stop();for(let e=0;a>e;++e)g.tick();const p=new Map;for(const t of e)p.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=p.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=p.get(e.target);t&&(e.target=t)}}},buildScene(e,t,n,o){var r,i,a;const s=n.nodeStyle,l=n.edgeStyle,c=yn(n.nodeSize,n.nodeSizeRange,e),u=Array.isArray(n.colorScheme)?n.colorScheme:H,d=new Map;e.forEach((e,t)=>{d.set(e.id,u[t%u.length])});const h=[],g=[],p=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=c(t),n=s?s(t):{},o={fill:n.fill||d.get(t.id)||"#007bff",stroke:n.stroke||"#fff",strokeWidth:null!==(r=n.strokeWidth)&&void 0!==r?r:2,opacity:n.opacity};h.push({type:"circle",cx:t.x,cy:t.y,r:e,style:o,datum:t,id:t.id,label:t.id})}const y=new Map;for(const t of e)y.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:y.get(e.source),n="object"==typeof e.target?e.target:y.get(e.target);if(!t||!n)continue;if(null==t.x||null==t.y)continue;if(null==n.x||null==n.y)continue;const o=l?l(e):{},r={stroke:o.stroke||"#999",strokeWidth:null!==(i=o.strokeWidth)&&void 0!==i?i:1,opacity:null!==(a=o.opacity)&&void 0!==a?a:.6};g.push({type:"line",x1:t.x,y1:t.y,x2:n.x,y2:n.y,style:r,datum:e})}if(!1!==n.showLabels){const t=(f=n.nodeLabel)?"function"==typeof f?f:e=>e[f]||e.id:null;for(const n of e){if(null==n.x||null==n.y)continue;const e=t?t(n):n.id;if(!e)continue;const o=c(n);p.push({x:n.x,y:n.y-o-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var f;return{sceneNodes:h,sceneEdges:g,labels:p}}};function yn(e,t,n){var o,r;if(null==e)return()=>8;if("number"==typeof e)return()=>e;if("function"==typeof e)return t=>e(t)||8;const i=t||[5,20],a=n.map(t=>{var n;return null===(n=t.data)||void 0===n?void 0:n[e]}).filter(e=>null!=e&&"number"==typeof e);if(0===a.length)return()=>i[0];const s=null!==(o=k(a))&&void 0!==o?o:0,l=null!==(r=E(a))&&void 0!==r?r:1;if(s===l)return()=>(i[0]+i[1])/2;const c=f().domain([s,l]).range(i).clamp(!0);return t=>{var n;const o=null===(n=t.data)||void 0===n?void 0:n[e];return null==o||"number"!=typeof o?i[0]:c(o)}}const fn=H,mn={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,n,o){if(0===e.length)return;const{padAngle:r=.01,groupWidth:i=20,sortGroups:a}=n,s=Math.min(o[0],o[1])/2,l=s-i,c=o[0]/2,u=o[1]/2,d=(h=n.valueAccessor)?"function"==typeof h?h:e=>{var t;return null!==(t=e[h])&&void 0!==t?t:1}:e=>{var t;return null!==(t=e.value)&&void 0!==t?t:1};var h;const g=new Map;for(let t=0;e.length>t;t++)g.set(e[t].id,t);const p=e.length,y=Array.from({length:p},()=>Array.from({length:p},()=>0));for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,n=g.get("string"==typeof e.source?e.source:e.source.id),o=g.get(t);if(void 0===n||void 0===o)continue;const r=d(e);y[n][o]=r}const f=J().padAngle(r);a&&f.sortGroups(a);const m=f(y),v=m.groups,b=ee().innerRadius(l).outerRadius(s);for(const t of v){const n=e[t.index],o=b.centroid(t);n.x=o[0]+c,n.y=o[1]+u,n.arcData={startAngle:t.startAngle,endAngle:t.endAngle}}const x=new Map;for(const t of e)x.set(t.id,t);for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,n=x.get("string"==typeof e.source?e.source:e.source.id),o=x.get(t);n&&(e.source=n),o&&(e.target=o)}const w=new Map;for(const e of t)w.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const t of m){const n=e[t.source.index].id,o=e[t.target.index].id,r=w.get(`${n}\0${o}`)||w.get(`${o}\0${n}`);r&&(r.chordData=t)}},buildScene(e,t,n,o){var r,i;const{groupWidth:a=20,edgeOpacity:s=.5}=n,l=Math.min(o[0],o[1])/2,c=l-a,u=o[0]/2,d=o[1]/2,h=n.nodeStyle,g=n.edgeStyle,p=n.edgeColorBy||"source",y=Array.isArray(n.colorScheme)?n.colorScheme:fn,f=new Map;e.forEach((e,t)=>{f.set(e.id,y[t%y.length])});const m=K().radius(c),v=[],b=[],x=[];for(let t=0;e.length>t;t++){const n=e[t],o=n.arcData;if(!o)continue;let i;i=h?h(n).fill||f.get(n.id)||y[t%y.length]:f.get(n.id)||y[t%y.length];const a=h?h(n):{},s={fill:i,stroke:a.stroke||"black",strokeWidth:null!==(r=a.strokeWidth)&&void 0!==r?r:1,opacity:a.opacity};v.push({type:"arc",cx:u,cy:d,innerR:c,outerR:l,startAngle:o.startAngle-Math.PI/2,endAngle:o.endAngle-Math.PI/2,style:s,datum:n,id:n.id,label:n.id})}for(const e of t){const t=e.chordData;if(!t)continue;const n=m(t);if(!n)continue;const o=vn(n,u,d);let r="#999";if(g)r=g(e).fill||r;else{const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;"target"===p&&n?r=f.get(n.id)||r:t&&(r=f.get(t.id)||r)}const a=g?g(e):{},l={fill:r,fillOpacity:null!==(i=a.fillOpacity)&&void 0!==i?i:s,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity};b.push({type:"ribbon",pathD:o,style:l,datum:e})}if(!1!==n.showLabels){const t=(w=n.nodeLabel)?"function"==typeof w?w:e=>e[w]||e.id:null,o=l+12;for(const n of e){const e=n.arcData;if(!e)continue;const r=t?t(n):n.id;if(!r)continue;const i=(e.startAngle+e.endAngle)/2,a=i-Math.PI/2;x.push({x:u+Math.cos(a)*o,y:d+Math.sin(a)*o,text:r+"",anchor:i>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var w;return{sceneNodes:v,sceneEdges:b,labels:x}}};function vn(e,t,n){const o=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!o)return e;const r=[];let i=0;for(;o.length>i;){const e=o[i];if("M"===e||"L"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)r.push(Number(o[i])+t+""),i++,o.length>i&&!isNaN(Number(o[i]))&&(r.push(Number(o[i])+n+""),i++);else if("C"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)for(let e=0;3>e&&o.length>i&&!isNaN(Number(o[i]));e++)r.push(Number(o[i])+t+""),i++,o.length>i&&!isNaN(Number(o[i]))&&(r.push(Number(o[i])+n+""),i++);else if("Q"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)for(let e=0;2>e&&o.length>i&&!isNaN(Number(o[i]));e++)r.push(Number(o[i])+t+""),i++,o.length>i&&!isNaN(Number(o[i]))&&(r.push(Number(o[i])+n+""),i++);else if("A"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&(r.push(Number(o[i])+t+""),i++),o.length>i&&(r.push(Number(o[i])+n+""),i++);else"Z"===e||"z"===e?(r.push(e),i++):(r.push(o[i]),i++)}return r.join(" ")}const bn={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,n,o){var r;const i=n.__hierarchyRoot;if(!i)return;const a=n.chartType,s=(l=n.childrenAccessor)?"function"==typeof l?l:e=>e[l]:void 0;var l;const c=n.hierarchySum||(e=>{var t;return null!==(t=e.value)&&void 0!==t?t:0}),u=P(i,s);u.sum(c),u.sort((e,t)=>{var n,o;return(null!==(n=t.value)&&void 0!==n?n:0)-(null!==(o=e.value)&&void 0!==o?o:0)});const[d,h]=o;switch(a){case"tree":!function(e,t,n,o){const r=t.treeOrientation||"vertical",i=B();i.size("horizontal"===r?[o,n]:"radial"===r?[2*Math.PI,Math.min(n,o)/2*.8]:[n,o]),i(e)}(u,n,d,h);break;case"cluster":!function(e,t,n,o){const r=t.treeOrientation||"vertical",i=T();i.size("horizontal"===r?[o,n]:"radial"===r?[2*Math.PI,Math.min(n,o)/2*.8]:[n,o]),i(e)}(u,n,d,h);break;case"treemap":!function(e,t,n,o){var r,i;const a=null!==(r=t.padding)&&void 0!==r?r:4,s=null!==(i=t.paddingTop)&&void 0!==i?i:0,l=D().size([n,o]).tile(C).padding(a);s>0&&l.paddingTop(s),l(e)}(u,n,d,h);break;case"circlepack":!function(e,t,n,o){var r;const i=null!==(r=t.padding)&&void 0!==r?r:4;N().size([n,o]).padding(i)(e)}(u,n,d,h);break;case"partition":!function(e,t,n,o){var r;M().size([n,o]).padding(null!==(r=t.padding)&&void 0!==r?r:1)(e)}(u,n,d,h)}const g=u.descendants();e.length=0,t.length=0;const p=new Map;for(let t=0;g.length>t;t++){const o=g[t],i={id:En(o,n,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(r=o.value)&&void 0!==r?r:0,depth:o.depth,data:o.data,createdByFrame:!0};"tree"===a||"cluster"===a?xn(i,o,n):"treemap"===a||"partition"===a?wn(i,o):"circlepack"===a&&kn(i,o),i.__hierarchyNode=o,e.push(i),p.set(o,i)}if("tree"===a||"cluster"===a)for(const e of g)if(e.parent){const n=p.get(e.parent),o=p.get(e);n&&o&&t.push({source:n,target:o,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,n,o){const r=n.nodeStyle||(()=>({})),i=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(e,t,n,o,r,i){var a,s,l,c,u;const d=[],h=[],g=[],p=n.treeOrientation||"vertical",y="radial"===p,f=o[0]/2,m=o[1]/2,v="number"==typeof(x=n.nodeSize)?x:5,b=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];var x;for(const t of e){let e=t.x,o=t.y;y&&(e+=f,o+=m);const i=r(t);let s=i.fill||"#4d430c";n.colorByDepth&&void 0!==t.depth&&(s=b[t.depth%b.length]);const l={fill:s,stroke:i.stroke||"#fff",strokeWidth:null!==(a=i.strokeWidth)&&void 0!==a?a:1,opacity:i.opacity};d.push({type:"circle",cx:e,cy:o,r:v,style:l,datum:t,id:t.id,label:t.id,depth:t.depth})}const w=null!==(s=n.edgeOpacity)&&void 0!==s?s:.5;for(const e of t){const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;if(!t||!n)continue;let o=t.x,r=t.y,a=n.x,s=n.y;y&&(o+=f,r+=m,a+=f,s+=m);const u=An(o,r,a,s,p),d=i(e),g={fill:"none",stroke:d.stroke||"#999",strokeWidth:null!==(l=d.strokeWidth)&&void 0!==l?l:1.5,opacity:null!==(c=d.opacity)&&void 0!==c?c:w};h.push({type:"curved",pathD:u,style:g,datum:e})}if(!1!==n.showLabels){const t=Sn(n.nodeLabel);for(const n of e){const e=t?t(n):n.id;if(!e)continue;let o,r,i,a=n.x,s=n.y;if(y&&(a+=f,s+=m),y){const e=a-f,t=s-m,n=Math.sqrt(e*e+t*t);n>0?(o=a+e/n*10,r=s+t/n*10,i=0>e?"end":"start"):(o=a,r=s-12,i="middle")}else"horizontal"===p?((null===(u=n.data)||void 0===u?void 0:u.children)&&0!==n.data.children.length?(o=a-v-6,i="end"):(o=a+v+6,i="start"),r=s):(o=a,r=s+v+14,i="middle");g.push({x:o,y:r,text:e+"",anchor:i,baseline:"middle",fontSize:11})}}return{sceneNodes:d,sceneEdges:h,labels:g}}(e,t,n,o,r,i);case"treemap":case"partition":return function(e,t,n,o){var r,i;const a=[],s=[],l=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const n of e){const e=n.x1-n.x0,i=n.y1-n.y0;if(0>=e||0>=i)continue;const s=o(n);let c=s.fill||"#4d430c";t.colorByDepth&&void 0!==n.depth&&(c=l[n.depth%l.length]);const u={fill:c,stroke:s.stroke||"#fff",strokeWidth:null!==(r=s.strokeWidth)&&void 0!==r?r:1,opacity:s.opacity};a.push({type:"rect",x:n.x0,y:n.y0,w:e,h:i,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=Sn(t.nodeLabel);for(const o of e){const e=o.x1-o.x0,r=o.y1-o.y0;if(0>=e||0>=r)continue;if((null===(i=o.data)||void 0===i?void 0:i.children)&&o.data.children.length>0&&"partition"!==t.chartType)continue;const a=n?n(o):o.id;a&&(30>e||16>r||s.push({x:o.x0+e/2,y:o.y0+r/2,text:a+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,r)/6))}))}}return{sceneNodes:a,sceneEdges:[],labels:s}}(e,n,0,r);case"circlepack":return function(e,t,n,o){var r,i,a,s,l;const c=[],u=[],d=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const n of e){const e=null!==(r=n.__radius)&&void 0!==r?r:5;if(0>=e)continue;const s=o(n);let l=s.fill||"#4d430c";t.colorByDepth&&void 0!==n.depth&&(l=d[n.depth%d.length]);const u={fill:l,stroke:s.stroke||"#fff",strokeWidth:null!==(i=s.strokeWidth)&&void 0!==i?i:1,opacity:null!==(a=s.opacity)&&void 0!==a?a:.7};c.push({type:"circle",cx:n.x,cy:n.y,r:e,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=Sn(t.nodeLabel);for(const t of e){const e=null!==(s=t.__radius)&&void 0!==s?s:5,o=n?n(t):t.id;if(!o)continue;if(15>e)continue;const r=!((null===(l=t.data)||void 0===l?void 0:l.children)&&t.data.children.length>0);u.push({x:t.x,y:r?t.y:t.y-e+14,text:o+"",anchor:"middle",baseline:r?"middle":"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:r?void 0:"#000",stroke:r?void 0:"#fff",strokeWidth:r?void 0:3,paintOrder:r?void 0:"stroke"})}}return{sceneNodes:c,sceneEdges:[],labels:u}}(e,n,0,r);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function xn(e,t,n){const o=n.treeOrientation||"vertical";if("radial"===o){const n=t.x,o=t.y;e.x=o*Math.cos(n-Math.PI/2),e.y=o*Math.sin(n-Math.PI/2)}else"horizontal"===o?(e.x=t.y,e.y=t.x):(e.x=t.x,e.y=t.y);e.x0=e.x-5,e.x1=e.x+5,e.y0=e.y-5,e.y1=e.y+5,e.width=10,e.height=10}function wn(e,t){e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.x=(t.x0+t.x1)/2,e.y=(t.y0+t.y1)/2,e.width=t.x1-t.x0,e.height=t.y1-t.y0}function kn(e,t){var n;const o=null!==(n=t.r)&&void 0!==n?n:0;e.x=t.x,e.y=t.y,e.x0=t.x-o,e.x1=t.x+o,e.y0=t.y-o,e.y1=t.y+o,e.width=2*o,e.height=2*o,e.__radius=o}function An(e,t,n,o,r){if("horizontal"===r){const r=(e+n)/2;return`M ${e},${t} C ${r},${t} ${r},${o} ${n},${o}`}if("radial"===r){const r=(e+n)/2;return`M ${e},${t} Q ${r},${t} ${r},${(t+o)/2} T ${n},${o}`}{const r=(t+o)/2;return`M ${e},${t} C ${e},${r} ${n},${r} ${n},${o}`}}function En(e,t,n){const o=t.nodeIDAccessor;return"function"==typeof o?o(e.data)+"":"string"==typeof o&&void 0!==e.data[o]?e.data[o]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+n}function Sn(e){return e?"function"==typeof e?e:t=>{var n;return(null===(n=t.data)||void 0===n?void 0:n[e])||t[e]||t.id}:null}const On={sankey:gn,force:pn,chord:mn,tree:bn,cluster:bn,treemap:bn,circlepack:bn,partition:bn};function Ln(e){return On[e]}class jn{constructor(e){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.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.config=e,this.tensionConfig=Object.assign(Object.assign({},bt),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&(this.particlePool=new wt(2e3))}updateConfig(e){this.config=e,this.tensionConfig=Object.assign(Object.assign({},bt),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&!this.particlePool&&(this.particlePool=new wt(2e3))}ingestHierarchy(e,t){this.nodes.clear(),this.edges.clear(),this.config.__hierarchyRoot=e,this.runLayout(t)}ingestBounded(e,t,n){const{nodeIDAccessor:o="id",sourceAccessor:r="source",targetAccessor:i="target",valueAccessor:a="value"}=this.config,s="function"==typeof o?o:e=>e[o],l="function"==typeof r?r:e=>e[r],c="function"==typeof i?i:e=>e[i],u="function"==typeof a?a:e=>{var t;return null!==(t=e[a])&&void 0!==t?t:1};this.nodes.clear(),this.edges.clear();for(const t of e){const e=s(t)+"";this.nodes.set(e,Object.assign(Object.assign({},Pn(e)),{data:t}))}for(const e of t){const t=l(e)+"",n=c(e)+"",o=Number(u(e))||1;this.nodes.has(t)||this.nodes.set(t,Object.assign(Object.assign({},Pn(t)),{data:e})),this.nodes.has(n)||this.nodes.set(n,Object.assign(Object.assign({},Pn(n)),{data:e})),this.edges.set(`${t}\0${n}`,{source:t,target:n,value:o,y0:0,y1:0,sankeyWidth:0,data:e})}this.runLayout(n)}edgeKey(e,t){return`${e}\0${t}`}ingestEdge(e){const{source:t,target:n,value:o}=e,r=0===this.nodes.size;let i=!1;const a="undefined"!=typeof performance?performance.now():Date.now();this.lastIngestTime=a,this.nodes.has(t)||(this.nodes.set(t,Pn(t)),this.nodeTimestamps.set(t,a),this.tension+=this.tensionConfig.newNode,i=!0),this.nodes.has(n)||(this.nodes.set(n,Pn(n)),this.nodeTimestamps.set(n,a),this.tension+=this.tensionConfig.newNode,i=!0);const s=this.edgeKey(t,n),l=this.edges.get(s);return l?(l.value+=o,this.edgeTimestamps.set(s,a),this.tension+=this.tensionConfig.weightChange):(this.edges.set(s,{source:t,target:n,value:o,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(s,a),this.tension+=this.tensionConfig.newEdge,i=!0),r||i||this.tension>=this.tensionConfig.threshold}runLayout(e){const t=Ln(this.config.chartType);if(!t)return;let n=Array.from(this.nodes.values()),o=Array.from(this.edges.values());if(0===n.length&&!t.hierarchical)return;if(this.prepareForRelayout(),t.computeLayout(n,o,this.config,e),t.hierarchical&&n.length>0){this.nodes.clear(),this.edges.clear();for(const e of n)this.nodes.set(e.id,e);for(const e of o)this.edges.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e)}this.finalizeLayout(),this.saveTargetPositions(),n.some(e=>void 0!==e._prevX0&&(0!==e._prevX0||0!==e._prevX1||0!==e._prevY0||0!==e._prevY1))&&this.tensionConfig.transitionDuration>0&&(this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:this.tensionConfig.transitionDuration});const r=new Set(this.nodes.keys()),i=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const e of r)this.previousNodeIds.has(e)||this.addedNodes.add(e);for(const e of this.previousNodeIds)r.has(e)||this.removedNodes.add(e);for(const e of i)this.previousEdgeKeys.has(e)||this.addedEdges.add(e);for(const e of this.previousEdgeKeys)i.has(e)||this.removedEdges.add(e);(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=r,this.previousEdgeKeys=i,this.layoutVersion++}buildScene(e){const t=Ln(this.config.chartType);if(!t)return;const n=Array.from(this.nodes.values()),o=Array.from(this.edges.values()),{sceneNodes:r,sceneEdges:i,labels:a}=t.buildScene(n,o,this.config,e);this.sceneNodes=r,this.sceneEdges=i,this.labels=a}advanceTransition(e){if(!this.transition)return!1;const t=Math.min((e-this.transition.startTime)/this.transition.duration,1),n=1-Math.pow(1-t,3);for(const e of this.nodes.values())void 0===e._targetX0||void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=e._prevX0+(e._targetX0-e._prevX0)*n,e.x1=e._prevX1+(e._targetX1-e._prevX1)*n,e.y0=e._prevY0+(e._targetY0-e._prevY0)*n,e.y1=e._prevY1+(e._targetY1-e._prevY1)*n);for(const e of this.edges.values())void 0!==e._targetY0&&void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=e._prevY0+(e._targetY0-e._prevY0)*n,e.y1=e._prevY1+(e._targetY1-e._prevY1)*n,e.sankeyWidth=e._prevSankeyWidth+(e._targetSankeyWidth-e._prevSankeyWidth)*n);return this.rebuildAllBeziers(),1>t||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){for(const e of this.nodes.values())e._prevX0=e.x0,e._prevX1=e.x1,e._prevY0=e.y0,e._prevY1=e.y1;for(const e of this.edges.values())e._prevY0=e.y0,e._prevY1=e.y1,e._prevSankeyWidth=e.sankeyWidth}finalizeLayout(){const e="vertical"===this.config.orientation?"down":"right";for(const e of this.nodes.values())if(0!==e.x0||0!==e.x1||0!==e.y0||0!==e.y1)e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;else{const t=5;e.x0=e.x-t,e.x1=e.x+t,e.y0=e.y-t,e.y1=e.y+t,e.width=2*t,e.height=2*t}for(const t of this.edges.values())t.direction=e,this.updateEdgeBezier(t);this.tension=0}saveTargetPositions(){for(const e of this.nodes.values())e._targetX0=e.x0,e._targetX1=e.x1,e._targetY0=e.y0,e._targetY1=e.y1;for(const e of this.edges.values())e._targetY0=e.y0,e._targetY1=e.y1,e._targetSankeyWidth=e.sankeyWidth}restorePreviousPositions(){for(const e of this.nodes.values())void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=e._prevX0,e.x1=e._prevX1,e.y0=e._prevY0,e.y1=e._prevY1);for(const e of this.edges.values())void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=e._prevY0,e.y1=e._prevY1,e.sankeyWidth=e._prevSankeyWidth);this.rebuildAllBeziers()}snapToTargets(){for(const e of this.nodes.values())void 0!==e._targetX0&&(e.x0=e._targetX0,e.x1=e._targetX1,e.y0=e._targetY0,e.y1=e._targetY1);for(const e of this.edges.values())void 0!==e._targetY0&&(e.y0=e._targetY0,e.y1=e._targetY1,e.sankeyWidth=e._targetSankeyWidth);this.rebuildAllBeziers()}updateEdgeBezier(e){const t="string"==typeof e.source?this.nodes.get(e.source):e.source,n="string"==typeof e.target?this.nodes.get(e.target):e.target;t&&n&&(e.bezier=e.circular&&e.circularPathData?this.buildCircularBezier(e):this.buildStandardBezier(e,t,n))}buildStandardBezier(e,t,n){const o=(e.sankeyWidth||1)/2;if("down"===e.direction){const r=t.y1,i=n.y0,a=W(r,i);return{circular:!1,points:[{x:e.y0,y:r},{x:e.y0,y:a(.5)},{x:e.y1,y:a(.5)},{x:e.y1,y:i}],halfWidth:o}}const r=t.x1,i=n.x0,a=W(r,i);return{circular:!1,points:[{x:r,y:e.y0},{x:a(.5),y:e.y0},{x:a(.5),y:e.y1},{x:i,y:e.y1}],halfWidth:o}}buildCircularBezier(e){const t=(e._circularWidth||e.sankeyWidth||1)/2,n=e.circularPathData;if(e._circularStub){const e=Math.max(15,Math.min(40,.33*(n.rightFullExtent-n.sourceX))),o=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*e,y:n.sourceY},{x:n.sourceX+.66*e,y:n.sourceY},{x:n.sourceX+e,y:n.sourceY}],[{x:n.targetX-o,y:n.targetY},{x:n.targetX-.66*o,y:n.targetY},{x:n.targetX-.33*o,y:n.targetY},{x:n.targetX,y:n.targetY}]],halfWidth:t}}let o;o="down"===e.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 e=0;o.length-1>e;e++){const t=o[e],n=o[e+1],i=n.x-t.x,a=n.y-t.y;r.push([t,{x:t.x+i/3,y:t.y+a/3},{x:t.x+2*i/3,y:t.y+2*a/3},n])}return{circular:!0,segments:r,halfWidth:t}}rebuildAllBeziers(){for(const e of this.nodes.values())e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;for(const e of this.edges.values())this.updateEdgeBezier(e)}applyPulse(e){var t,n,o,r,i;const a=this.config.pulse;if(!a)return;const s=null!==(t=a.duration)&&void 0!==t?t:500,l=null!==(n=a.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",c=null!==(o=a.glowRadius)&&void 0!==o?o:4;for(const t of this.sceneNodes){const n=t.id;if(!n)continue;const o=this.nodeTimestamps.get(n);if(!o)continue;const r=e-o;s>r&&(t._pulseIntensity=1-r/s,t._pulseColor=l,t._pulseGlowRadius=c)}for(const t of this.sceneEdges){const n=t.datum;if(!n)continue;const o="object"==typeof n.source?null===(r=n.source)||void 0===r?void 0:r.id:n.source,a="object"==typeof n.target?null===(i=n.target)||void 0===i?void 0:i.id:n.target;if(!o||!a)continue;const c=this.edgeTimestamps.get(`${o}\0${a}`);if(!c)continue;const u=e-c;s>u&&(t._pulseIntensity=1-u/s,t._pulseColor=l)}}applyDecay(){var e,t,n,o,r;const i=this.config.decay;if(!i)return;const a=null!==(e=i.minOpacity)&&void 0!==e?e:.1,s=this.nodeTimestamps.size;if(1>=s)return;const l=Array.from(this.nodeTimestamps.entries()).sort((e,t)=>e[1]-t[1]),c=new Map;for(let e=0;l.length>e;e++)c.set(l[e][0],e);for(const e of this.sceneNodes){const l=e.id;if(!l)continue;const u=c.get(l);if(void 0===u)continue;const d=s-1-u;let h;switch(i.type){case"linear":h=a+(1-d/(s-1))*(1-a);break;case"exponential":{const e=null!==(t=i.halfLife)&&void 0!==t?t:s/2;h=a+Math.pow(.5,d/e)*(1-a);break}case"step":h=(null!==(n=i.stepThreshold)&&void 0!==n?n:.5*s)>d?1:a;break;default:h=1}const g=null!==(r=null===(o=e.style)||void 0===o?void 0:o.opacity)&&void 0!==r?r:1;e.style=Object.assign(Object.assign({},e.style),{opacity:g*h})}}applyTopologyDiff(e){var t;if(0===this.addedNodes.size)return;const n=e-this.lastTopologyChangeTime;if(n>=2e3)return;const o=1-n/2e3;for(const e of this.sceneNodes){const n=e.id;n&&this.addedNodes.has(n)&&(e._pulseIntensity=Math.max(null!==(t=e._pulseIntensity)&&void 0!==t?t:0,o),e._pulseColor="rgba(34, 197, 94, 0.7)",e._pulseGlowRadius=8)}}get hasActiveTopologyDiff(){return 0!==this.addedNodes.size&&2e3>("undefined"!=typeof performance?performance.now():Date.now())-this.lastTopologyChangeTime}applyThresholds(e){var t,n;const o=this.config.thresholds;if(!o)return;const r=null!==(t=o.warningColor)&&void 0!==t?t:"#f59e0b",i=null!==(n=o.criticalColor)&&void 0!==n?n:"#ef4444",a=!1!==o.pulse;for(const t of this.sceneNodes){const n=t.id;if(!n)continue;const s=this.nodes.get(n);if(!s)continue;const l=o.metric(s);let c=null;void 0===o.critical||o.critical>l?void 0===o.warning||o.warning>l||(c=r):c=i,c&&(t.style=Object.assign(Object.assign({},t.style),{fill:c}),a&&(t._pulseIntensity=.6+.4*Math.sin(e/300),t._pulseColor=c,t._pulseGlowRadius=6))}}get hasActiveThresholds(){const e=this.config.thresholds;if(!e)return!1;for(const t of this.nodes.values()){const n=e.metric(t);if(void 0!==e.warning&&n>=e.warning||void 0!==e.critical&&n>=e.critical)return!0}return!1}get hasActivePulses(){var e;const t=this.config.pulse;if(!t||0===this.lastIngestTime)return!1;const n="undefined"!=typeof performance?performance.now():Date.now();return(null!==(e=t.duration)&&void 0!==e?e: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.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.transition=null,this.lastIngestTime=0,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.particlePool&&this.particlePool.clear()}}function Pn(e){return{id:e,x0:0,x1:0,y0:0,y1:0,x:0,y:0,width:0,height:0,value:0,createdByFrame:!0}}function Mn(e,t,n,o,r=30){let i=null,a=r,s=1/0;for(const t of e){const e=Nn(t,n,o);if(e)if("rect"===t.type){const n=t.w*t.h;s>n&&(i=e,s=n)}else a>e.distance&&(i=e,a=e.distance)}if(i)return i;for(const e of t){const t=Dn(e,n,o);t&&a>t.distance&&(i=t,a=t.distance)}return i}function Nn(e,t,n){switch(e.type){case"circle":return function(e,t,n){const o=t-e.cx,r=n-e.cy,i=Math.sqrt(o*o+r*r);return i>Math.max(e.r,5)+5?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:i}}(e,t,n);case"rect":return function(e,t,n){return e.x>t||t>e.x+e.w||e.y>n||n>e.y+e.h?null:{type:"node",datum:e.datum,x:e.x+e.w/2,y:e.y+e.h/2,distance:0}}(e,t,n);case"arc":return function(e,t,n){const o=t-e.cx,r=n-e.cy,i=Math.sqrt(o*o+r*r);if(e.innerR-2>i||i>e.outerR+2)return null;let a=Math.atan2(r,o);0>a&&(a+=2*Math.PI);let s,l=e.startAngle,c=e.endAngle;if(0>l&&(l+=2*Math.PI),0>c&&(c+=2*Math.PI),s=l>c?a>=l||c>=a:a>=l&&c>=a,s){const t=(e.startAngle+e.endAngle)/2,n=(e.innerR+e.outerR)/2;return{type:"node",datum:e.datum,x:e.cx+n*Math.cos(t),y:e.cy+n*Math.sin(t),distance:0}}return null}(e,t,n);default:return null}}function Dn(e,t,n){switch(e.type){case"bezier":return function(e,t,n){var o,r;if(!e.pathD)return null;try{const i=new Path2D(e.pathD),a=document.createElement("canvas").getContext("2d");if(!a)return null;if(a.isPointInPath(i,t,n)){const i="object"==typeof(null===(o=e.datum)||void 0===o?void 0:o.source)?e.datum.source:null,a="object"==typeof(null===(r=e.datum)||void 0===r?void 0:r.target)?e.datum.target:null;return{type:"edge",datum:e.datum,x:i&&a?(i.x1+a.x0)/2:t,y:e.datum?(e.datum.y0+e.datum.y1)/2:n,distance:0}}}catch(e){}return null}(e,t,n);case"line":return function(e,t,n){const o=e.x2-e.x1,r=e.y2-e.y1,i=o*o+r*r;if(0===i)return null;let a=((t-e.x1)*o+(n-e.y1)*r)/i;a=Math.max(0,Math.min(1,a));const s=e.x1+a*o,l=e.y1+a*r,c=Math.sqrt(Math.pow(t-s,2)+Math.pow(n-l,2));return c>5?null:{type:"edge",datum:e.datum,x:s,y:l,distance:c}}(e,t,n);case"ribbon":case"curved":return function(e,t,n){if(!e.pathD)return null;try{const o=new Path2D(e.pathD),r=document.createElement("canvas").getContext("2d");if(!r)return null;if(r.isPointInPath(o,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0}}catch(e){}return null}(e,t,n);default:return null}}function Cn(t){const{width:n,height:o,totalWidth:r,totalHeight:i,margin:a,labels:s,title:l,legend:c,foregroundGraphics:u,annotations:d,svgAnnotationRules:h}=t;return e.createElement("svg",{width:r,height:i,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},e.createElement("g",{transform:`translate(${a.left},${a.top})`},s.map((t,n)=>e.createElement("text",{key:"label-"+n,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)),d&&h&&d.map((t,r)=>{const i=h(t,r,{width:n,height:o});return i?e.createElement(e.Fragment,{key:"annotation-"+r},i):null}),u),l&&"string"==typeof l?e.createElement("text",{x:r/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor"},l):l?e.createElement("foreignObject",{x:0,y:0,width:r,height:a.top},l):null,c&&"object"==typeof c&&"legendGroups"in c?e.createElement("g",{transform:`translate(${r-a.right+10},${a.top})`},c.legendGroups.map((t,n)=>{var o;return e.createElement("g",{key:"legend-group-"+n},null===(o=t.items)||void 0===o?void 0:o.map((t,n)=>e.createElement("g",{key:"legend-item-"+n,transform:`translate(0,${20*n})`},e.createElement("rect",{x:0,y:0,width:12,height:12,fill:t.color,rx:2}),e.createElement("text",{x:18,y:10,fontSize:11,fill:"currentColor"},t.label))))})):c?e.createElement("g",{transform:`translate(${r-a.right+10},${a.top})`},c):null)}function Tn(e,t){var n,o,r,i,a,s;if(!t.pathD)return;e.save();const l=new Path2D(t.pathD);if(t.style.fill&&"none"!==t.style.fill){const a=t._gradient;if(a){const r=e.createLinearGradient(a.x0,0,a.x1,0),i=null!==(o=null!==(n=t.style.fillOpacity)&&void 0!==n?n:t.style.opacity)&&void 0!==o?o:.5,s=t.style.fill;r.addColorStop(0,1===a.from?s:"transparent"),r.addColorStop(1,1===a.to?s:"transparent"),e.fillStyle=r,e.globalAlpha=i}else e.fillStyle=t.style.fill,e.globalAlpha=null!==(i=null!==(r=t.style.fillOpacity)&&void 0!==r?r:t.style.opacity)&&void 0!==i?i:.5;e.fill(l)}t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(a=t.style.strokeWidth)&&void 0!==a?a:.5,e.globalAlpha=.5*(null!==(s=t.style.opacity)&&void 0!==s?s:1),e.stroke(l)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.2*t._pulseIntensity,e.fill(l)),e.restore()}function Bn(e,t){var n,o;e.save(),e.strokeStyle=t.style.stroke||"#999",e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.strokeDasharray&&e.setLineDash(t.style.strokeDasharray.split(/[\s,]+/).map(Number)),e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke(),t._pulseIntensity&&t._pulseIntensity>0&&(e.setLineDash([]),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=(null!==(o=t.style.strokeWidth)&&void 0!==o?o:1)+3*t._pulseIntensity,e.globalAlpha=.4*t._pulseIntensity,e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke()),e.restore()}function Wn(e,t){var n,o,r,i;if(!t.pathD)return;e.save();const a=new Path2D(t.pathD);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=t.style.fill,e.globalAlpha=null!==(o=null!==(n=t.style.fillOpacity)&&void 0!==n?n:t.style.opacity)&&void 0!==o?o:.5,e.fill(a)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(r=t.style.strokeWidth)&&void 0!==r?r:.5,e.globalAlpha=.3*(null!==(i=t.style.opacity)&&void 0!==i?i:1),e.stroke(a)),e.restore()}function Hn(e,t){var n,o;if(!t.pathD)return;e.save();const r=new Path2D(t.pathD);e.strokeStyle=t.style.stroke||"#999",e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.stroke(r),t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=t.style.fill,e.globalAlpha=null!==(o=t.style.fillOpacity)&&void 0!==o?o:.1,e.fill(r)),e.restore()}Cn.displayName="NetworkSVGOverlay";const $n={category10:H,tableau10:X,set3:G,blues:Y,reds:F,greens:R,oranges:I,purples:z,viridis:_,plasma:$},_n=H,zn=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"];function In(e,t,n){if("function"==typeof t)return t(e);const o=e[t];return n?n(o):_n[Math.abs(function(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n),t&=t;return Math.abs(t)}(o+""))%_n.length]}function Rn(e,t,n="category10"){const o=Array.from(new Set(e.map(e=>e[t]))),r=o.every(e=>"number"==typeof e||!isNaN(Number(e)));if(Array.isArray(n))return v().domain(o).range(n).unknown("#999");const i=$n[n]||$n.category10;if(r&&"function"==typeof i)return e=>i(Number(e)/Math.max(...o.map(Number)));{const e=Array.isArray(i)?i:_n;return v().domain(o).range(e).unknown("#999")}}function Fn(e,t,n=[3,20],o){let r;if(r="function"==typeof t?t(e):e[t],!o)return r;const[i,a]=o,[s,l]=n;return a===i?(s+l)/2:s+(r-i)/(a-i)*(l-s)}const Yn={top:20,right:80,bottom:20,left:80},Gn={top:40,right:40,bottom:40,left:40},Xn=new Set(["chord","force","circlepack"]),qn=[800,600],Vn={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 Un({data:t}){var n,o,r,i,a,s;if("edge"===t.type){const n=t.data;return e.createElement("div",{className:"semiotic-tooltip",style:Vn},e.createElement("div",{style:{fontWeight:600}},"object"==typeof n.source?n.source.id:n.source," → ","object"==typeof n.target?n.target.id:n.target),null!=n.value&&e.createElement("div",{style:{marginTop:4,opacity:.8}},"Value:"," ","number"==typeof n.value?n.value.toLocaleString():n.value+""))}const l=t.data,c=null==l?void 0:l.__hierarchyNode;if(c){const t=[];let a=c;for(;a;){const e=null!==(i=null!==(o=null===(n=a.data)||void 0===n?void 0:n.name)&&void 0!==o?o:null===(r=a.data)||void 0===r?void 0:r.id)&&void 0!==i?i:l.id;null!=e&&t.unshift(e+""),a=a.parent}t.length>1&&t.shift();const s=t.length-1;return e.createElement("div",{className:"semiotic-tooltip",style:Vn},e.createElement("div",null,t.map((t,n)=>e.createElement("span",{key:n},n>0&&e.createElement("span",{style:{margin:"0 3px",opacity:.5}}," → "),n===s?e.createElement("strong",null,t):e.createElement("span",{style:{opacity:.7}},t)))),null!=l.value&&l.value>0&&e.createElement("div",{style:{marginTop:4,opacity:.8}},"number"==typeof l.value?l.value.toLocaleString():l.value+""))}const u=((null===(a=l.sourceLinks)||void 0===a?void 0:a.length)||0)+((null===(s=l.targetLinks)||void 0===s?void 0:s.length)||0),d=(l.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(l.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0);return e.createElement("div",{className:"semiotic-tooltip",style:Vn},e.createElement("div",{style:{fontWeight:600}},l.id),null!=l.value&&l.value>0&&e.createElement("div",{style:{marginTop:4,opacity:.8}},"Total:"," ","number"==typeof l.value?l.value.toLocaleString():l.value+""),u>0&&e.createElement("div",{style:{marginTop:4,opacity:.8}},"Connections: ",u,d!==u&&` (weighted: ${d.toLocaleString()})`))}const Zn=i(function(i,l){const{chartType:c,nodes:u,edges:d,data:h,initialEdges:g,nodeIDAccessor:p="id",sourceAccessor:y="source",targetAccessor:f="target",valueAccessor:m="value",childrenAccessor:v,hierarchySum:b,orientation:x="horizontal",nodeAlign:w="justify",nodePaddingRatio:k=.05,nodeWidth:A=15,iterations:E=300,forceStrength:S=.1,padAngle:O=.01,groupWidth:L=20,sortGroups:j,edgeSort:P,treeOrientation:M="vertical",edgeType:N="curve",padding:D,paddingTop:C,tensionConfig:T,showParticles:B=!1,particleStyle:W,nodeStyle:H,edgeStyle:$,colorBy:_,colorScheme:z="category10",edgeColorBy:I="source",edgeOpacity:R=.5,colorByDepth:F=!1,nodeSize:Y=8,nodeSizeRange:G=[5,20],nodeLabel:X,showLabels:q=!0,size:V=qn,responsiveWidth:U,responsiveHeight:Z,margin:Q,className:K,background:J,enableHover:ee=!0,tooltipContent:te,customHoverBehavior:ne,customClickBehavior:oe,onObservation:re,chartId:ie,onTopologyChange:ae,annotations:se,svgAnnotationRules:le,legend:ce,title:ue,foregroundGraphics:de,backgroundGraphics:he,decay:ge,pulse:pe,staleness:ye,thresholds:fe}=i,me=Xn.has(c)?Gn:Yn,[ve,be]=Ae(V,U,Z),xe=Object.assign(Object.assign({},me),Q),ke=be[0]-xe.left-xe.right,Ee=be[1]-xe.top-xe.bottom,Se=r(()=>Object.assign(Object.assign({},bt),T),[T]),Oe=r(()=>Object.assign(Object.assign({},xt),W),[W]),Le=r(()=>({chartType:c,nodeIDAccessor:p,sourceAccessor:y,targetAccessor:f,valueAccessor:m,childrenAccessor:v,hierarchySum:b,orientation:x,nodeAlign:w,nodePaddingRatio:k,nodeWidth:A,iterations:E,forceStrength:S,padAngle:O,groupWidth:L,sortGroups:j,edgeSort:P,treeOrientation:M,edgeType:N,padding:D,paddingTop:C,tensionConfig:Se,showParticles:B,particleStyle:Oe,nodeStyle:H,edgeStyle:$,nodeLabel:X,showLabels:q,colorBy:_,colorScheme:z,edgeColorBy:I,edgeOpacity:R,colorByDepth:F,nodeSize:Y,nodeSizeRange:G,decay:ge,pulse:pe,staleness:ye,thresholds:fe}),[c,p,y,f,m,v,b,x,w,k,A,E,S,O,L,j,P,M,N,D,C,Se,B,Oe,H,$,X,q,_,z,I,R,F,Y,G,ge,pe,ye,fe]),je=t(null),Pe=t(0),Me=t(0),Ne=t(!0),De=t(()=>{}),Ce=t(null);Ce.current||(Ce.current=new jn(Le));const[Te,Be]=n(null),[We,He]=n(0),[$e,_e]=n(0),[ze,Ie]=n(!1),Re=t(null),Fe=t(new Map),Ye=t(0),Ge=a(e=>{if("function"==typeof _)return _(e);if("string"==typeof _&&e.data){const t=e.data[_];if(void 0!==t){if(!Fe.current.has(t+"")){const e=Array.isArray(z)?z:_n;Fe.current.set(t+"",e[Ye.current++%e.length])}return Fe.current.get(t+"")}}if(!Fe.current.has(e.id)){const t=Array.isArray(z)?z:_n;Fe.current.set(e.id,t[Ye.current++%t.length])}return Fe.current.get(e.id)},[_,z]),Xe=a(e=>{if("function"==typeof I)return I(e);const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;return"target"===I&&n?Ge(n):t?Ge(t):"#999"},[I,Ge]),qe=a(e=>{if(!(null==W?void 0:W.colorBy))return Xe(e);const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;return"target"===Oe.colorBy&&n?Ge(n):t?Ge(t):"#999"},[null==W?void 0:W.colorBy,Oe.colorBy,Ge,Xe]),Ve="sankey"===c&&B||!!pe,Ue=a(()=>{Pe.current&&!Ve||Pe.current||(Pe.current=requestAnimationFrame(()=>De.current()))},[Ve]);o(()=>{var e;null===(e=Ce.current)||void 0===e||e.updateConfig(Le),Ne.current=!0,Ue()},[Le,Ue]);const Ze=a(()=>{const e=Ce.current;if(!e)return;e.runLayout([ke,Ee]),e.buildScene([ke,Ee]),Ne.current=!0;const t=Array.isArray(z)?z:_n,n=Array.from(e.nodes.values());for(let e=0;n.length>e;e++){const o=n[e];Fe.current.has(o.id)||Fe.current.set(o.id,t[e%t.length])}if(Ye.current=n.length,He(e.layoutVersion),ae){const{nodes:t,edges:n}=e.getLayoutData();ae(t,n)}},[ke,Ee,ae,z]),Qe=a(e=>{const t=Ce.current;t&&(t.ingestEdge(e)&&Ze(),Ue())},[Ze,Ue]),Ke=a(e=>{const t=Ce.current;if(!t)return;let n=!1;for(const o of e)t.ingestEdge(o)&&(n=!0);n&&Ze(),Ue()},[Ze,Ue]),Je=a(()=>{var e;null===(e=Ce.current)||void 0===e||e.clear(),Fe.current.clear(),Ye.current=0,He(0),Be(null),Re.current=null,Ne.current=!0,Ue()},[Ue]),et=a(()=>{const e=Ce.current;e&&(e.tension+=999,Ze(),Ue())},[Ze,Ue]);s(l,()=>({push:Qe,pushMany:Ke,clear:Je,getTopology:()=>{var e,t;return null!==(t=null===(e=Ce.current)||void 0===e?void 0:e.getLayoutData())&&void 0!==t?t:{nodes:[],edges:[]}},getTopologyDiff:()=>{const e=Ce.current;return e?{addedNodes:Array.from(e.addedNodes),removedNodes:Array.from(e.removedNodes),addedEdges:Array.from(e.addedEdges),removedEdges:Array.from(e.removedEdges)}:{addedNodes:[],removedNodes:[],addedEdges:[],removedEdges:[]}},relayout:et,getTension:()=>{var e,t;return null!==(t=null===(e=Ce.current)||void 0===e?void 0:e.tension)&&void 0!==t?t:0}}),[Qe,Ke,Je,et]);const tt=["tree","cluster","treemap","circlepack","partition"].includes(c),nt=tt?h||(Array.isArray(d)?void 0:d):void 0;o(()=>{const e=Ce.current;if(e)if(tt&&nt)e.ingestHierarchy(nt,[ke,Ee]),e.buildScene([ke,Ee]),Ne.current=!0,Ue();else{const t=u||[],n=Array.isArray(d)?d:[];if(0===t.length&&0===n.length)return;e.ingestBounded(t,n,[ke,Ee]),e.buildScene([ke,Ee]);const o=Array.isArray(z)?z:_n,r=Array.from(e.nodes.values());for(let e=0;r.length>e;e++){const t=r[e];Fe.current.has(t.id)||Fe.current.set(t.id,o[e%o.length])}Ye.current=r.length,Ne.current=!0,Ue()}},[u,d,h,nt,tt,ke,Ee,Le,Ue,z]),o(()=>{g&&g.length>0&&Ke(g)},[]);const ot=a(e=>{if(ne&&ne(e),re){const t=Date.now();re(e?{type:"hover",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:ie}:{type:"hover-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:ie})}},[ne,re,ie]),rt=a(e=>{if(oe&&oe(e),re){const t=Date.now();re(e?{type:"click",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:ie}:{type:"click-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:ie})}},[oe,re,ie]),it=t(()=>{}),at=t(()=>{});it.current=e=>{if(!ee)return;const t=je.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-xe.left,r=e.clientY-n.top-xe.top;if(0>o||o>ke||0>r||r>Ee)return void(Re.current&&(Re.current=null,Be(null),ot&&(ot(null),Ne.current=!0),Ue()));const i=Ce.current;if(!i)return;const a=Mn(i.sceneNodes,i.sceneEdges,o,r);if(!a)return void(Re.current&&(Re.current=null,Be(null),ot&&(ot(null),Ne.current=!0),Ue()));const s={type:a.type,data:a.datum,x:a.x,y:a.y};Re.current=s,Be(s),ot&&(ot(s),Ne.current=!0),Ue()},at.current=()=>{Re.current&&(Re.current=null,Be(null),ot&&(ot(null),Ne.current=!0),Ue())};const st=t(()=>{});st.current=e=>{if(!oe&&!re)return;const t=je.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-xe.left,r=e.clientY-n.top-xe.top;if(0>o||o>ke||0>r||r>Ee)return;const i=Ce.current;if(!i)return;const a=Mn(i.sceneNodes,i.sceneEdges,o,r);rt(a?{type:a.type,data:a.datum,x:a.x,y:a.y}:null)},a(e=>it.current(e),[]);const lt=a(()=>at.current(),[]),ct=a(e=>st.current(e),[]),ut=t(-1),dt=a(e=>{const t=Ce.current;if(!t)return;const n=function(e){const t=[];for(const n of e)"circle"===n.type&&null!=n.cx?t.push({x:n.cx,y:n.cy,datum:n.datum}):"rect"===n.type&&null!=n.x?t.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum}):"arc"===n.type&&null!=n.cx&&t.push({x:n.cx,y:n.cy,datum:n.datum});return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}(t.sceneNodes);if(0===n.length)return;const o=ut.current,r=we(e.key,0>o?-1:o,n.length);if(null===r)return;if(e.preventDefault(),0>r)return ut.current=-1,Re.current=null,Be(null),ot&&(ot(null),Ne.current=!0),void Ue();const i=0>o?0:r;ut.current=i;const a=n[i],s={type:"node",data:a.datum,x:a.x,y:a.y};Re.current=s,Be(s),ot&&(ot(s),Ne.current=!0),Ue()},[ot,Ue]),ht=a(e=>{ut.current=-1,it.current(e)},[]);De.current=()=>{var e,t,n;Pe.current=0;const o=je.current;if(!o)return;const r=o.getContext("2d");if(!r)return;const i=Ce.current;if(!i)return;const a=performance.now(),s=Me.current?Math.min((a-Me.current)/1e3,.1):.016;Me.current=a;const l=i.advanceTransition(a);(l||Ne.current)&&i.buildScene([ke,Ee]);const c="undefined"!=typeof window&&window.devicePixelRatio||1;o.width=be[0]*c,o.height=be[1]*c,o.style.width=be[0]+"px",o.style.height=be[1]+"px",r.scale(c,c),r.translate(xe.left,xe.top),r.clearRect(-xe.left,-xe.top,be[0],be[1]),J&&(r.fillStyle=J,r.fillRect(0,0,ke,Ee)),ge&&i.applyDecay(),pe&&i.applyPulse(a),fe&&i.applyThresholds(a),i.applyTopologyDiff(a);const u=null!==(e=null==ye?void 0:ye.threshold)&&void 0!==e?e:5e3,d=ye&&i.lastIngestTime>0&&a-i.lastIngestTime>u;if(d&&(r.globalAlpha=null!==(t=null==ye?void 0:ye.dimOpacity)&&void 0!==t?t:.5),function(e,t){for(const n of t)switch(n.type){case"bezier":Tn(e,n);break;case"line":Bn(e,n);break;case"ribbon":Wn(e,n);break;case"curved":Hn(e,n)}}(r,i.sceneEdges),function(e,t){var n,o,r;for(const i of t){if("rect"!==i.type)continue;const t=i;t.w>0&&t.h>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(n=t.style.opacity)&&void 0!==n?n:1)*t.style.fillOpacity),e.fillRect(t.x,t.y,t.w,t.h)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(o=t.style.strokeWidth)&&void 0!==o?o:1,e.globalAlpha=null!==(r=t.style.opacity)&&void 0!==r?r:1,e.strokeRect(t.x,t.y,t.w,t.h)),t._pulseIntensity&&t._pulseIntensity>0&&(e.globalAlpha=.3*t._pulseIntensity,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h)),e.restore())}}(r,i.sceneNodes),function(e,t){var n,o,r,i;for(const a of t){if("circle"!==a.type)continue;const t=a;if(t.r>0){if(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.r,0,2*Math.PI),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(n=t.style.opacity)&&void 0!==n?n:1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(o=t.style.strokeWidth)&&void 0!==o?o:1,e.globalAlpha=null!==(r=t.style.opacity)&&void 0!==r?r:1,e.stroke()),t._pulseIntensity&&t._pulseIntensity>0){const n=null!==(i=t._pulseGlowRadius)&&void 0!==i?i:4,o=t.r+n*t._pulseIntensity;e.beginPath(),e.arc(t.cx,t.cy,o,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=.6*t._pulseIntensity,e.stroke()}e.restore()}}}(r,i.sceneNodes),function(e,t){var n,o,r;for(const i of t){if("arc"!==i.type)continue;const t=i;e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.outerR,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerR,t.endAngle,t.startAngle,!0),e.closePath(),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(n=t.style.opacity)&&void 0!==n?n:1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(o=t.style.strokeWidth)&&void 0!==o?o:1,e.globalAlpha=null!==(r=t.style.opacity)&&void 0!==r?r:1,e.stroke()),e.restore()}}(r,i.sceneNodes),B&&i.particlePool&&!d){const e=Array.from(i.edges.values());if(e.length>0){!function(e,t,n,o){var r,i;const a=null!==(r=o.spawnRate)&&void 0!==r?r:xt.spawnRate,s=null!==(i=o.maxPerEdge)&&void 0!==i?i:xt.maxPerEdge;for(let o=0;t.length>o;o++){const r=t[o];if(!r.bezier)continue;if(e.countForEdge(o)>=s)continue;const i=r.value*a*n*(r.bezier.circular?.3:1),l=Math.floor(i),c=i-l;let u=l;Math.random()<c&&u++;for(let t=0;u>t&&e.countForEdge(o)<s;t++)e.spawn(o)}}(i.particlePool,e,s,Oe);const t=.5*(null!==(n=Oe.speedMultiplier)&&void 0!==n?n:1);let o;if(Oe.proportionalSpeed){const t=e.reduce((e,t)=>Math.max(e,t.value||1),1);o=e.map(e=>.3+(e.value||1)/t*1.7)}i.particlePool.step(s,t,e,o),function(e,t,n,o,r){var i,a;const s=null!==(i=o.radius)&&void 0!==i?i:xt.radius,l=null!==(a=o.opacity)&&void 0!==a?a:xt.opacity;e.globalAlpha=l;for(let i=0;t.particles.length>i;i++){const a=t.particles[i];if(!a.active)continue;const l=n[a.edgeIndex];if(l){if("function"==typeof o.color){const t="object"==typeof l.source?l.source:null;e.fillStyle=t?o.color(l,t):"#666"}else e.fillStyle=o.color&&"inherit"!==o.color?o.color:r(l);e.beginPath(),e.arc(a.x,a.y,s,0,2*Math.PI),e.fill()}}e.globalAlpha=1}(r,i.particlePool,e,Oe,qe)}}d&&(r.globalAlpha=1);const h=Ne.current;Ne.current=!1,(h||l)&&_e(e=>e+1),(Ve||l||i.hasActivePulses||i.hasActiveThresholds||i.hasActiveTopologyDiff)&&(Pe.current=requestAnimationFrame(()=>De.current()))},o(()=>(Ue(),()=>{Pe.current&&(cancelAnimationFrame(Pe.current),Pe.current=0)}),[Ue]),o(()=>{Ne.current=!0,Ue()},[c,ke,Ee,J,Ue]),o(()=>{if(!ye)return;const e=setInterval(()=>{var e;const t=Ce.current;if(!t||0===t.lastIngestTime)return;const n="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(e=ye.threshold)&&void 0!==e?e:5e3,r=n-t.lastIngestTime>o;r!==ze&&(Ie(r),Ne.current=!0,Ue())},1e3);return()=>clearInterval(e)},[ye,ze,Ue]);const gt=ee&&Te?e.createElement("div",{className:"stream-network-tooltip",style:{position:"absolute",left:xe.left+Te.x,top:xe.top+Te.y,transform:`translate(${Te.x>.6*ke?"calc(-100% - 12px)":"12px"}, ${.3*Ee>Te.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:2}},te?te(Te):e.createElement(Un,{data:Te})):null,pt=Ce.current;return e.createElement("div",{ref:ve,className:"stream-network-frame"+(K?" "+K:""),role:"img","aria-label":"string"==typeof ue?ue:"Network chart",tabIndex:0,style:{position:"relative",width:U?"100%":be[0],height:Z?"100%":be[1]},onMouseMove:ee?ht:void 0,onMouseLeave:ee?lt:void 0,onClick:oe||re?ct:void 0,onKeyDown:dt},he&&e.createElement("svg",{style:{position:"absolute",top:0,left:0,width:be[0],height:be[1],pointerEvents:"none"}},e.createElement("g",{transform:`translate(${xe.left},${xe.top})`},he)),e.createElement("canvas",{ref:je,style:{position:"absolute",top:0,left:0}}),e.createElement(Cn,{width:ke,height:Ee,totalWidth:be[0],totalHeight:be[1],margin:xe,labels:(null==pt?void 0:pt.labels)||[],title:ue,legend:ce,foregroundGraphics:de,annotations:se,svgAnnotationRules:le,annotationFrame:$e}),gt,(null==ye?void 0:ye.showBadge)&&e.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===ye.badgePosition?{top:4,left:4}:"bottom-left"===ye.badgePosition?{bottom:4,left:4}:"bottom-right"===ye.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{background:ze?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"})},ze?"STALE":"LIVE"))});Zn.displayName="StreamNetworkFrame";const Qn={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"8px 12px",borderRadius:"4px",fontSize:"14px",lineHeight:"1.5",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"};function Kn(e,t){return"function"==typeof t?t(e):e[t]}function Jn(e,t){return t?t(e):null==e?"":"number"==typeof e?e.toLocaleString():e instanceof Date?e.toLocaleDateString():"object"==typeof e&&null!==e?void 0!==e.id?e.id+"":void 0!==e.name?e.name+"":JSON.stringify(e):e+""}function eo(t={}){const{fields:n,title:o,format:r,style:i={},className:a=""}=t;return t=>{if(!t||"object"!=typeof t)return null;let s;const l=[];if(o){const e=Kn(t,o);s=Jn(e,r)}if(n&&n.length>0)n.forEach(e=>{let n,o,i;"string"==typeof e?(n=e,o=e,i=r):(n=e.label,o=e.accessor||e.key||"",i=e.format||r);const a=Kn(t,o);l.push({label:n,value:Jn(a,i)})});else if(!o){const e=["value","y","name","id","label"];for(const n of e)if(void 0!==t[n]){s=Jn(t[n],r);break}if(!s){const e=Object.keys(t).filter(e=>!e.startsWith("_"));e.length>0&&(s=Jn(t[e[0]],r))}}const c=Object.assign(Object.assign({},Qn),i);return e.createElement("div",{className:("semiotic-tooltip "+a).trim(),style:c},s&&e.createElement("div",{style:{fontWeight:l.length>0?"bold":"normal"}},s),l.map((t,n)=>e.createElement("div",{key:n,style:{marginTop:0===n&&s?"4px":0}},t.label&&e.createElement("span",null,t.label,": "),t.value)))}}function to(t={}){const{fields:n=[],title:o,format:r,style:i={},className:a="",showLabels:s=!0,separator:l=": "}=t;return t=>{if(!t||"object"!=typeof t)return null;const c=[];if(o){const e=Kn(t,o);c.push({value:Jn(e,r)})}n&&Array.isArray(n)&&n.length>0?n.forEach(e=>{let n,o,i;"string"==typeof e?(n=e,o=e,i=r):(n=e.label,o=e.accessor||e.key||"",i=e.format||r);const a=Jn(Kn(t,o),i);c.push({label:s?n:void 0,value:a})}):Object.keys(t).filter(e=>!e.startsWith("_")&&"data"!==e).forEach(e=>{c.push({label:s?e:void 0,value:Jn(t[e],r)})});const u=Object.assign(Object.assign({},Qn),i);return Array.isArray(c)&&0!==c.length?e.createElement("div",{className:("semiotic-tooltip semiotic-tooltip-multiline "+a).trim(),style:u},c.map((t,n)=>e.createElement("div",{key:n,style:{marginBottom:c.length-1>n?"4px":0}},t.label&&e.createElement("strong",null,t.label,l),t.value))):null}}function no(e){return!0===e||("function"==typeof e?e:!1!==e&&void 0!==e&&("object"!=typeof e||null===e||!("fields"in e)&&!("title"in e)||eo(e)))}function oo(e){return"string"==typeof e?e:"value"}function ro(e){return null==e?"–":"number"==typeof e?Math.abs(e)>9999?e.toLocaleString():e+"":e instanceof Date?e.toLocaleDateString():e+""}function io(e,t){return"function"==typeof t?t(e):e[t]}function ao(t){return n=>{const o=n.data;return o?e.createElement("div",{className:"semiotic-tooltip",style:Qn},t.map((t,n)=>{const r=ro(io(o,t.accessor));return e.createElement("div",{key:n,style:n>0?{marginTop:2}:void 0},e.createElement("span",{style:{opacity:.8}},t.label,": "),e.createElement("span",{style:{fontWeight:"color"===t.role||"group"===t.role?"bold":"normal"}},r))})):null}}function so({categoryAccessor:t,valueAccessor:n,groupAccessor:o,groupLabel:r,pieData:i=!1}){return a=>{var s;const l=i?(null===(s=a.data)||void 0===s?void 0:s[0])||a.data||a:a.data||a,c=io(l,t),u=io(l,n),d=o?io(l,o):void 0;return e.createElement("div",{className:"semiotic-tooltip",style:Qn},e.createElement("div",{style:{fontWeight:"bold"}},ro(c)),e.createElement("div",{style:{marginTop:4}},ro(u)),null!=d&&e.createElement("div",{style:{marginTop:2,opacity:.8}},r||oo(o),": ",ro(d)))}}const lo=c(null);function co({colors:t,categories:n,colorScheme:o="category10",children:i}){const a=r(()=>{if(t)return t;if(n){const e=Array.isArray(o)?o:$n[o]||_n,t={};for(let o=0;n.length>o;o++)t[n[o]]=e[o%e.length];return t}return{}},[t,n,o]);return e.createElement(lo.Provider,{value:a},i)}function uo(){return l(lo)}function ho(e){return e?"string"==typeof e?{name:e}:e:null}function go(e,t,n){return t?o=>{var r;const i=Object.assign({},e(o));if(t.isActive)if(t.predicate(o))(null==n?void 0:n.selectedStyle)&&Object.assign(i,n.selectedStyle);else{const e=null!==(r=null==n?void 0:n.unselectedOpacity)&&void 0!==r?r:.2;i.opacity=e,i.fillOpacity=e,i.strokeOpacity=e,(null==n?void 0:n.unselectedStyle)&&Object.assign(i,n.unselectedStyle)}return i}:e}function po(t){const o=c(null),i=yo(t);return[function({children:n}){const i=r(()=>yo(t),[]);return e.createElement(o.Provider,{value:i,children:n})},e=>{var t;const r=null!==(t=l(o))&&void 0!==t?t:i;return function(e,t){const[o,r]=n(t);return u(()=>e(()=>r(t)),[e]),o}(r.subscribe,()=>e(r.getState()))}]}function yo(e){const t=new EventTarget;let n=e(function(e){n=Object.assign(Object.assign({},n),e(n)),t.dispatchEvent(new CustomEvent("update"))});return{getState:()=>n,subscribe:function(e){return t.addEventListener("update",e),()=>t.removeEventListener("update",e)}}}function fo(e){const t=[];for(const[n,o]of Object.entries(e.fields))if("point"===o.type)t.push(e=>o.values.has(e[n]));else{const[e,r]=o.range;t.push(t=>{const o=t[n];return o>=e&&r>=o})}return e=>t.every(t=>t(e))}function mo(e,t){const n=[];for(const[o,r]of e.clauses)"crossfilter"===e.resolution&&o===t||n.push(fo(r));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}function vo(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}co.displayName="CategoryColorProvider";const[bo,xo]=po(e=>({selections:new Map,setClause(t,n){e(e=>{const o=new Map(e.selections),r=vo(o,t),i=new Map(r.clauses);return i.set(n.clientId,n),o.set(t,Object.assign(Object.assign({},r),{clauses:i})),{selections:o}})},clearClause(t,n){e(e=>{const o=e.selections.get(t);if(!o)return{};const r=new Map(e.selections),i=new Map(o.clauses);return i.delete(n),r.set(t,Object.assign(Object.assign({},o),{clauses:i})),{selections:r}})},setResolution(t,n){e(e=>{const o=new Map(e.selections),r=vo(o,t);return o.set(t,Object.assign(Object.assign({},r),{resolution:n})),{selections:o}})},clearSelection(t){e(e=>{const n=new Map(e.selections),o=n.get(t);return o&&n.set(t,Object.assign(Object.assign({},o),{clauses:new Map})),{selections:n}})}}));function wo(e){const t=d(),n=e.clientId||t,{name:o}=e,i=xo(e=>e.selections.get(o)),s=xo(e=>e.setClause),l=xo(e=>e.clearClause),c=r(()=>!!i&&i.clauses.size>0,[i]);return{predicate:r(()=>i&&0!==i.clauses.size?mo(i,n):()=>!0,[i,n]),isActive:c,selectPoints:a(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"point",values:new Set(o)};s(o,{clientId:n,type:"point",fields:t})},[n,o,s]),selectInterval:a(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"interval",range:o};s(o,{clientId:n,type:"interval",fields:t})},[n,o,s]),clear:a(()=>{l(o,n)},[l,o,n]),clientId:n}}function ko(e){const t=e.name||"hover",{fields:n}=e,{predicate:o,isActive:r,selectPoints:i,clear:s}=wo({name:t});return{onHover:a(e=>{if(!e)return void s();const t={};for(const o of n){const n=e[o];void 0!==n&&(t[o]=[n])}Object.keys(t).length>0&&i(t)},[n,i,s,t]),predicate:o,isActive:r}}function Ao(e){const{name:t,xField:n,yField:o}=e,{predicate:i,isActive:s,selectInterval:l,clear:c}=wo({name:t}),u=n&&o?"xyBrush":n?"xBrush":"yBrush",d=a(e=>{if(!e)return void c();const t={};"xyBrush"===u&&Array.isArray(e)&&2===e.length?(n&&(t[n]=[Math.min(e[0][0],e[1][0]),Math.max(e[0][0],e[1][0])]),o&&(t[o]=[Math.min(e[0][1],e[1][1]),Math.max(e[0][1],e[1][1])])):"xBrush"===u&&Array.isArray(e)?n&&(t[n]=[Math.min(...e),Math.max(...e)]):"yBrush"===u&&Array.isArray(e)&&o&&(t[o]=[Math.min(...e),Math.max(...e)]),Object.keys(t).length>0&&l(t)},[u,n,o,l,c]);return{brushInteraction:r(()=>({brush:u,during:d,end:d}),[u,d]),predicate:i,isActive:s,clear:c}}function Eo(e,t,n){const o=xo(e=>e.selections.get(t));return r(()=>{if(!o||0===o.clauses.size)return e;const t=mo(o,n);return e.filter(t)},[e,o,n])}const[So,Oo]=po(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const n=e.observations;return n.push(t),n.length>e.maxObservations&&n.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}})),Lo="#007bff";function jo(e){return"function"==typeof e?e:t=>t[e]}function Po(e,t,n="category10"){const o=uo();return r(()=>{if(t&&"function"!=typeof t)return o&&Object.keys(o).length>0?r=>o[r]||Rn(e,t,n)(r):Rn(e,t,n)},[e,t,n,o])}function Mo(e,t,n){return r(()=>{if(!t)return e;const o=[...e];if("function"==typeof t)return o.sort(t);const r=jo(n);return o.sort("asc"===t?(e,t)=>r(e)-r(t):(e,t)=>r(t)-r(e))},[e,t,n])}function No({selection:e,linkedHover:t,fallbackFields:n=[],unwrapData:o=!1,onObservation:r,chartType:i,chartId:s}){const l=function(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields}:null}(t,n),c=wo({name:(null==e?void 0:e.name)||"__unused__"}),u=ko({name:(null==l?void 0:l.name)||"hover",fields:(null==l?void 0:l.fields)||n||[]}),d=Oo(e=>e.pushObservation),h=e?{isActive:c.isActive,predicate:c.predicate}:null,g=a(e=>{var n,o;if(t)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]),u.onHover(t)}else u.onHover(null);if(r||d){const t={timestamp:Date.now(),chartType:i||"unknown",chartId:s};if(e){let i=e.data||e.datum||e;Array.isArray(i)&&(i=i[0]);const a=Object.assign(Object.assign({},t),{type:"hover",datum:i||{},x:null!==(n=e.x)&&void 0!==n?n:0,y:null!==(o=e.y)&&void 0!==o?o:0});r&&r(a),d&&d(a)}else{const e=Object.assign(Object.assign({},t),{type:"hover-end"});r&&r(e),d&&d(e)}}},[t,u,r,i,s,d]),p=a(e=>{var t,n;if(r||d){const o={timestamp:Date.now(),chartType:i||"unknown",chartId:s};if(e){let i=e.data||e.datum||e;Array.isArray(i)&&(i=i[0]);const a=Object.assign(Object.assign({},o),{type:"click",datum:i||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0});r&&r(a),d&&d(a)}else{const e=Object.assign(Object.assign({},o),{type:"click-end"});r&&r(e),d&&d(e)}}},[r,d,i,s]);return{activeSelectionHook:h,customHoverBehavior:g,customClickBehavior:p}}function Do({data:e,colorBy:t,colorScale:n,showLegend:o,userMargin:i,defaults:a={top:50,bottom:60,left:70,right:40}}){const s=void 0!==o?o:!!t,l=r(()=>{if(s&&t)return function({data:e,colorBy:t,colorScale:n,getColor:o,strokeColor:r,strokeWidth:i}){const a=Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t]))).map(r=>{const i=e.find("function"==typeof t?e=>t(e)===r:e=>e[t]===r),a=i?o(i,t,n):n?n(r):"#000000";return{label:r+"",color:a}});return{legendGroups:[{styleFn:e=>{const t={fill:e.color,stroke:e.color};return void 0!==r&&(t.stroke=r),void 0!==i&&(t.strokeWidth=i),t},type:"fill",items:a,label:""}]}}({data:e,colorBy:t,colorScale:n,getColor:In})},[s,t,e,n]),c=r(()=>{const e=Object.assign(Object.assign({},a),i);return l&&120>e.right&&(e.right=120),e},[a,i,l]);return{legend:l,margin:c}}const Co={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 To(e,t,n){var o,r,i,a,s,l;const c=Co[e||"primary"],u="context"===e||"sparkline"===e;return{width:null!==(o=t.width)&&void 0!==o?o:e&&"primary"!==e||!(null==n?void 0:n.width)?c.width:n.width,height:null!==(r=t.height)&&void 0!==r?r:e&&"primary"!==e||!(null==n?void 0:n.height)?c.height:n.height,showAxes:c.showAxes,showGrid:null!==(i=t.showGrid)&&void 0!==i?i:c.showGrid,enableHover:null!==(a=t.enableHover)&&void 0!==a?a:!!t.linkedHover||c.enableHover,showLegend:null!==(s=t.showLegend)&&void 0!==s?s:c.showLegend,showLabels:null!==(l=t.showLabels)&&void 0!==l?l:c.showLabels,title:u?void 0:t.title,xLabel:u?void 0:t.xLabel,yLabel:u?void 0:t.yLabel,categoryLabel:u?void 0:t.categoryLabel,valueLabel:u?void 0:t.valueLabel,marginDefaults:c.marginDefaults}}function Bo({componentName:t,message:n,width:o,height:r}){return e.createElement("div",{role:"alert",style:{width:o,height:Math.max(r,120),display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed rgba(128, 128, 128, 0.4)",borderRadius:8,background:"rgba(128, 128, 128, 0.04)",padding:24,boxSizing:"border-box"}},e.createElement("div",{style:{textAlign:"center",maxWidth:400}},e.createElement("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"}},t),e.createElement("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5}},n)))}class Wo extends e.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){var n,o;null===(o=(n=this.props).onError)||void 0===o||o.call(n,e,t)}render(){if(this.state.error){const{fallback:t}=this.props,n=this.state.error;return"function"==typeof t?t(n):void 0!==t?t:e.createElement(Bo,{componentName:"ChartErrorBoundary",message:n.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}var Ho;const $o="undefined"!=typeof process&&"production"!==(null===(Ho=process.env)||void 0===Ho?void 0:Ho.NODE_ENV);function _o({componentName:t,width:n,height:o,children:r}){return e.createElement(Wo,{fallback:r=>e.createElement(Bo,{componentName:t,message:r.message,width:n,height:o})},r)}function zo(e,t,n,o){if(!$o)return;if(!t||0===t.length)return;if("string"!=typeof o)return;const r=t[0];if(!r||"object"!=typeof r)return;if(o in r)return;const i=Object.keys(r).join(", ");console.warn(`[semiotic] ${e}: ${n} "${o}" not found in data. Available keys: ${i}`)}function Io(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:e}function Ro(e,t){if(0===t.length)return null;const n=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(n)||n.includes(e.toLowerCase()))||t[0]}function Fo({componentName:e,data:t,accessors:n,requiredProps:o}){if(o)for(const[t,n]of Object.entries(o))if(null==n)return`${e}: ${t} is required. Provide a field name or function.`;if(!t||!Array.isArray(t)||0===t.length)return e+": No data provided. Pass a non-empty array to the data prop.";if(!Array.isArray(t)&&"object"==typeof t)return e+": data should be an array, but received an object. If this is hierarchical data, use TreeDiagram, Treemap, or CirclePack instead.";if(n){const o=Io(t).find(e=>e&&"object"==typeof e);if(o){const t=Object.keys(o);for(const[r,i]of Object.entries(n))if(i&&"string"==typeof i&&!(i in o)){const n=Ro(i,t),o=n?` Try ${r}="${n}".`:"";return`${e}: ${r} "${i}" not found in data. Available fields: ${t.join(", ")}.${o}`}}}return null}function Yo({componentName:e,data:t,dataLabel:n="data"}){return null==t?`${e}: No ${n} provided. Pass a hierarchical object with children: { name: "root", children: [...] }.`:Array.isArray(t)?`${e}: ${n} should be a single root object, not an array. Expected: { name: "root", children: [...] }. If you have flat data, use LineChart, BarChart, or Scatterplot instead.`:null}function Go({componentName:e,nodes:t,edges:n,nodesRequired:o=!1,edgesRequired:r=!0,accessors:i}){if(r&&(!n||!Array.isArray(n)||0===n.length))return e+': No edges provided. Pass a non-empty array: edges={[{ source: "A", target: "B", value: 10 }, ...]}.';if(o&&(!t||!Array.isArray(t)||0===t.length))return e+': No nodes provided. Pass a non-empty array: nodes={[{ id: "A" }, { id: "B" }, ...]}.';if(i&&t&&t.length>0){const n=Io(t).find(e=>e&&"object"==typeof e);if(n){const t=Object.keys(n);for(const[o,r]of Object.entries(i))if(r&&"string"==typeof r&&!(r in n)){const n=Ro(r,t),i=n?` Try ${o}="${n}".`:"";return`${e}: ${o} "${r}" not found in node data. Available fields: ${t.join(", ")}.${i}`}}}return null}function Xo(t){const n=To(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:o,margin:i,className:a,xFormat:s,yFormat:l,xAccessor:c="x",yAccessor:u="y",colorBy:d,colorScheme:h="category10",sizeBy:g,sizeRange:p=[3,15],pointRadius:y=5,pointOpacity:f=.8,tooltip:m,marginalGraphics:v,pointIdAccessor:b,annotations:x,frameProps:w={},selection:k,linkedHover:A,linkedBrush:E,onObservation:S,chartId:O}=t,L=n.width,j=n.height,P=n.enableHover,M=n.showGrid,N=n.showLegend,D=n.title,C=n.xLabel,T=n.yLabel,B=o||[];zo("Scatterplot",B,"xAccessor",c),zo("Scatterplot",B,"yAccessor",u);const{activeSelectionHook:W,customHoverBehavior:H}=No({selection:k,linkedHover:A,fallbackFields:d?["string"==typeof d?d:""]:[],onObservation:S,chartType:"Scatterplot",chartId:O}),$=ho(E);Ao({name:(null==$?void 0:$.name)||"__unused_brush__",xField:(null==$?void 0:$.xField)||("string"==typeof c?c:void 0),yField:(null==$?void 0:$.yField)||("string"==typeof u?u:void 0)});const _=Po(B,d,h),z=r(()=>{if(!g||0===B.length)return;const e=B.map(e=>"function"==typeof g?g(e):e[g]);return[Math.min(...e),Math.max(...e)]},[B,g]),I=r(()=>e=>{const t={fillOpacity:f};return t.fill=d?In(e,d,_):Lo,t.r=g?Fn(e,g,p,z):y,t},[d,_,g,p,z,y,f]),R=r(()=>go(I,W,k),[I,W,k]),{legend:F,margin:Y}=Do({data:B,colorBy:d,colorScale:_,showLegend:N,userMargin:i,defaults:n.marginDefaults}),G=r(()=>ao([{label:C||oo(c),accessor:c,role:"x"},{label:T||oo(u),accessor:u,role:"y"},...d?[{label:oo(d),accessor:d,role:"color"}]:[],...g?[{label:oo(g),accessor:g,role:"size"}]:[]]),[c,u,C,T,d,g]),X=Fo({componentName:"Scatterplot",data:B,accessors:{xAccessor:c,yAccessor:u}});if(X)return e.createElement(Bo,{componentName:"Scatterplot",message:X,width:L,height:j});const q=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter",data:B,xAccessor:c,yAccessor:u,colorAccessor:d||void 0,sizeAccessor:g||void 0,sizeRange:p,pointStyle:R,colorScheme:h,size:[L,j],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Y,showAxes:n.showAxes,xLabel:C,yLabel:T,xFormat:s,yFormat:l,enableHover:P,showGrid:M},F&&{legend:F}),D&&{title:D}),a&&{className:a}),{tooltipContent:m?no(m):G}),(A||S)&&{customHoverBehavior:H}),v&&{marginalGraphics:v}),b&&{pointIdAccessor:b}),x&&x.length>0&&{annotations:x}),w);return e.createElement(_o,{componentName:"Scatterplot",width:L,height:j},e.createElement(Ke,Object.assign({},q)))}function qo(t){const n=To(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:o,className:i,xFormat:a,yFormat:s,xAccessor:l="x",yAccessor:c="y",orderAccessor:u,orderLabel:d,pointRadius:h=4,tooltip:g,pointIdAccessor:p,annotations:y,frameProps:f={},selection:m,linkedHover:v,onObservation:b,chartId:x}=t,w=n.width,k=n.height,A=n.enableHover,E=n.showGrid,S=n.title,O=n.xLabel,L=n.yLabel,j=o||[],P=r(()=>{if(!u||0===j.length)return j;const e="function"==typeof u?u:e=>e[u];return[...j].sort((t,n)=>{const o=e(t),r=e(n);return(o instanceof Date?o.getTime():+o)-(r instanceof Date?r.getTime():+r)})},[j,u]);zo("ConnectedScatterplot",P,"xAccessor",l),zo("ConnectedScatterplot",P,"yAccessor",c);const{activeSelectionHook:M,customHoverBehavior:N}=No({selection:m,linkedHover:v,fallbackFields:[],onObservation:b,chartType:"ConnectedScatterplot",chartId:x}),D=P.length,C=D>0&&100>D,T=r(()=>0===D?[]:P.map((e,t)=>_(1===D?.5:t/(D-1))),[P,D]);r(()=>null,[D]);const B=r(()=>{if(D>=2)return(t,n,o)=>{var r,i;if("connected-lines"!==t.type)return null;const a=o.scales;if(!a)return null;const s=null!==(r=a.x)&&void 0!==r?r:a.time,u=null!==(i=a.y)&&void 0!==i?i:a.value;if(!s||!u)return null;const d="string"==typeof l?e=>e[l]:l,g="string"==typeof c?e=>e[c]:c,p=[];for(let t=0;P.length-1>t;t++){const n=P[t],o=P[t+1],r=s(d(n)),i=u(g(n)),a=s(d(o)),l=u(g(o)),c=T[t];C&&p.push(e.createElement("line",{key:"halo-"+t,x1:r,y1:i,x2:a,y2:l,stroke:"white",strokeWidth:h+2,strokeOpacity:.5,strokeLinecap:"round"})),p.push(e.createElement("line",{key:"conn-"+t,x1:r,y1:i,x2:a,y2:l,stroke:c,strokeWidth:h,strokeLinecap:"round"}))}return e.createElement("g",{key:"ann-"+n},p)}},[P,T,h,C,l,c,D]),W=r(()=>e=>{const t=P.indexOf(e);return{fill:t>=0&&T.length>t?T[t]:"#6366f1",stroke:"white",strokeWidth:1,r:h,fillOpacity:1}},[P,T,h]),H=r(()=>go(W,M,m),[W,M,m]),$=Object.assign({top:50,right:40,bottom:60,left:70},t.margin),z=d||("string"==typeof u?u:"Order"),I=r(()=>ao([{label:O||oo(l),accessor:l,role:"x"},{label:L||oo(c),accessor:c,role:"y"},...u?[{label:z,accessor:u,role:"group"}]:[]]),[l,c,O,L,u,z]),R=Fo({componentName:"ConnectedScatterplot",data:P,accessors:{xAccessor:l,yAccessor:c}});if(R)return e.createElement(Bo,{componentName:"ConnectedScatterplot",message:R,width:w,height:k});const F=r(()=>[{type:"connected-lines"},...y||[]],[y]),Y=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter",data:P,xAccessor:l,yAccessor:c,pointStyle:H,size:[w,k],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:$,showAxes:n.showAxes,xLabel:O,yLabel:L,xFormat:a,yFormat:s,enableHover:A,showGrid:E},S&&{title:S}),i&&{className:i}),{tooltipContent:g?no(g):I}),(v||b)&&{customHoverBehavior:N}),p&&{pointIdAccessor:p}),{annotations:F,svgAnnotationRules:B}),f);return e.createElement(_o,{componentName:"ConnectedScatterplot",width:w,height:k},e.createElement(Ke,Object.assign({},Y)))}Xo.displayName="Scatterplot",qo.displayName="ConnectedScatterplot";const Vo="__forecastSegment";function Uo(e,t){return"function"==typeof t?t(e):!!e[t]}function Zo(t){var n,o;const i=To(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:a,margin:s,className:l,xFormat:c,yFormat:u,xAccessor:d="x",yAccessor:h="y",lineBy:g,lineDataAccessor:p="coordinates",colorBy:y,colorScheme:f="category10",curve:m="linear",showPoints:v=!1,pointRadius:b=3,fillArea:x=!1,areaOpacity:w=.3,lineWidth:k=2,tooltip:A,pointIdAccessor:E,annotations:S,anomaly:O,forecast:L,frameProps:j={},selection:P,linkedHover:M,onObservation:N,chartId:D}=t,C=i.width,T=i.height,B=i.enableHover,W=i.showGrid,H=i.showLegend,$=i.title,_=i.xLabel,z=i.yLabel,I=a||[];zo("LineChart",I,"xAccessor",d),zo("LineChart",I,"yAccessor",h);const R="string"==typeof d?d:"x",F="string"==typeof h?h:"y",Y=r(()=>L?function(e,t,n,o,r){return(i=o).isTraining||i.isForecast||i.isAnomaly||i.upperBounds||i.lowerBounds?function(e,t,n,o,r){var i,a,s;const{isTraining:l,isForecast:c,isAnomaly:u,upperBounds:d,lowerBounds:h,color:g="#6366f1",bandOpacity:p=.15,anomalyColor:y="#ef4444",anomalyRadius:f=6,label:m}=o,v=e.map(e=>{let t="observed";return c&&Uo(e,c)?t="forecast":l&&Uo(e,l)&&(t="training"),Object.assign(Object.assign({},e),{[Vo]:t})}),b=[];if(d&&h){const e="string"==typeof d?d:"__envUpper",t="string"==typeof h?h:"__envLower";if("function"==typeof d||"function"==typeof h)for(const n of v)"function"==typeof d&&(n[e]=d(n)),"function"==typeof h&&(n[t]=h(n));b.push({type:"envelope",upperAccessor:e,lowerAccessor:t,fill:g,fillOpacity:p,label:m})}return u&&b.push({type:"highlight",filter:e=>Uo(e,u),color:y,r:f,style:{stroke:y,strokeWidth:1.5,fill:y,fillOpacity:.7}}),r&&b.push({type:"anomaly-band",threshold:null!==(i=r.threshold)&&void 0!==i?i:2,showBand:!1!==r.showBand,fill:r.bandColor||"#6366f1",fillOpacity:null!==(a=r.bandOpacity)&&void 0!==a?a:.1,anomalyColor:r.anomalyColor||"#ef4444",anomalyRadius:null!==(s=r.anomalyRadius)&&void 0!==s?s:6,label:r.label}),{processedData:v,annotations:b}}(e,0,0,o,r):function(e,t,n,o,r){var i,a,s;const{trainEnd:l,steps:c=10,confidence:u=.95,color:d="#6366f1",bandOpacity:h=.15,label:g}=o;if(null==l)return{processedData:e,annotations:[]};const p=[],y=[];for(const n of e)n[t]>l?y.push(Object.assign(Object.assign({},n),{[Vo]:"observed"})):p.push(Object.assign(Object.assign({},n),{[Vo]:"training"}));const f=p.map(e=>[e[t],e[n]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]),m=[],v=[];if(f.length>=3){const o=f.length;let r=0,i=0,a=0,s=0;for(const[e,t]of f)r+=e,i+=t,a+=e*e,s+=e*t;const l=o*a-r*r;if(Math.abs(l)>1e-12){const a=(o*s-r*i)/l,p=(i-a*r)/o,y=e=>p+a*e,b=f.map(([e,t])=>t-y(e)).reduce((e,t)=>e+t*t,0),x=Math.sqrt(b/Math.max(o-2,1)),w=f.reduce((e,t)=>e+t[0],0)/o,k=f.reduce((e,t)=>e+Math.pow(t[0]-w,2),0),A=.99>u?.95>u?.9>u?1:1.645:1.96:2.576,E=e.map(e=>e[t]).filter(e=>null!=e&&isFinite(e)),S=Math.max(...E),O=f.length>1?(f[o-1][0]-f[0][0])/(o-1):1;for(let e=1;c>=e;e++){const r=S+e*O,i=y(r),a=x*Math.sqrt(1+1/o+(k>0?Math.pow(r-w,2)/k:0))*A;v.push({[t]:r,[n]:i,[Vo]:"forecast",__forecastUpper:i+a,__forecastLower:i-a})}m.push({type:"envelope",upperAccessor:"__forecastUpper",lowerAccessor:"__forecastLower",fill:d,fillOpacity:h,label:g})}}return m.push({type:"x-threshold",x:l,color:"#94a3b8",strokeWidth:1,strokeDasharray:"4,2",label:"Train / Forecast"}),r&&m.push({type:"anomaly-band",threshold:null!==(i=r.threshold)&&void 0!==i?i:2,showBand:!1!==r.showBand,fill:r.bandColor||"#6366f1",fillOpacity:null!==(a=r.bandOpacity)&&void 0!==a?a:.1,anomalyColor:r.anomalyColor||"#ef4444",anomalyRadius:null!==(s=r.anomalyRadius)&&void 0!==s?s:6,label:r.label}),{processedData:[...p,...y,...v],annotations:m}}(e,t,n,o,r);var i}(I,R,F,L,O):null,[I,L,O,R,F]),G=r(()=>Y?Y.annotations:O?function(e){var t,n,o;return[{type:"anomaly-band",threshold:null!==(t=e.threshold)&&void 0!==t?t:2,showBand:!1!==e.showBand,fill:e.bandColor||"#6366f1",fillOpacity:null!==(n=e.bandOpacity)&&void 0!==n?n:.1,anomalyColor:e.anomalyColor||"#ef4444",anomalyRadius:null!==(o=e.anomalyRadius)&&void 0!==o?o:6,label:e.label}]}(O):[],[Y,O]),X=Y?Y.processedData:I,q=L&&!g?Vo:g,{activeSelectionHook:V,customHoverBehavior:U}=No({selection:P,linkedHover:M,fallbackFields:y?["string"==typeof y?y:""]:[],onObservation:N,chartType:"LineChart",chartId:D}),Z=void 0!==(null===(n=X[0])||void 0===n?void 0:n[p]),Q=r(()=>{if(Z)return X;if(q){const e=X.reduce((e,t)=>{const n="function"==typeof q?q(t):t[q];if(!e[n]){const t={[p]:[]};"string"==typeof q&&(t[q]=n),e[n]=t}return e[n][p].push(t),e},{});return Object.values(e)}return[{[p]:X}]},[X,q,p,Z]),K=Po(X,y,f),J=r(()=>e=>{const t={strokeWidth:k};return t.stroke=y?In(e,y,K):Lo,x&&(t.fill=t.stroke,t.fillOpacity=w),t},[y,K,k,x,w]),ee=r(()=>L?function(e,t){var n,o;const r=null!==(n=t.trainDasharray)&&void 0!==n?n:"8,4",i=null!==(o=t.forecastDasharray)&&void 0!==o?o:"4,4",a=t.color||"#6366f1";return t=>{const n=e(t),o=t[Vo];return"training"===o?Object.assign(Object.assign({},n),{strokeDasharray:r}):"forecast"===o?Object.assign(Object.assign({},n),{stroke:a,strokeDasharray:i}):n}}(J,L):J,[J,L]),te=r(()=>go(ee,V,P),[ee,V,P]),ne=r(()=>{if(v)return e=>{const t={r:b,fillOpacity:1};return t.fill=y?In(e.parentLine||e,y,K):Lo,t}},[v,b,y,K]),oe=x?"area":"line",{legend:re,margin:ie}=Do({data:Q,colorBy:y,colorScale:K,showLegend:H,userMargin:s,defaults:i.marginDefaults}),ae=g||y,se=r(()=>ao([{label:_||oo(d),accessor:d,role:"x"},{label:z||oo(h),accessor:h,role:"y"},...ae?[{label:oo(ae),accessor:ae,role:"group"}]:[]]),[d,h,_,z,ae]),le=Fo({componentName:"LineChart",data:Z?(null===(o=X[0])||void 0===o?void 0:o[p])||[]:I,accessors:{xAccessor:d,yAccessor:h}});if(le)return e.createElement(Bo,{componentName:"LineChart",message:le,width:C,height:T});const ce=r(()=>Z||q?Q.flatMap(e=>{const t=e[p]||[];return q&&"string"==typeof q?t.map(t=>Object.assign(Object.assign({},t),{[q]:e[q]})):t}):X,[Q,p,Z,q,X]),ue=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:oe,data:ce,xAccessor:d,yAccessor:h,groupAccessor:q||void 0,curve:m,lineStyle:te},v&&{pointStyle:ne}),{size:[C,T],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:ie,showAxes:i.showAxes,xLabel:_,yLabel:z,xFormat:c,yFormat:u,enableHover:B,showGrid:W}),re&&{legend:re}),$&&{title:$}),l&&{className:l}),{tooltipContent:A?no(A):se}),(M||N)&&{customHoverBehavior:U}),E&&{pointIdAccessor:E}),((null==S?void 0:S.length)||G.length)&&{annotations:[...S||[],...G]}),j);return e.createElement(_o,{componentName:"LineChart",width:C,height:T},e.createElement(Ke,Object.assign({},ue)))}function Qo(t){var n;const o=To(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:i,margin:a,className:s,xFormat:l,yFormat:c,xAccessor:u="x",yAccessor:d="y",areaBy:h,y0Accessor:g,gradientFill:p=!1,lineDataAccessor:y="coordinates",colorBy:f,colorScheme:m="category10",curve:v="monotoneX",areaOpacity:b=.7,showLine:x=!0,lineWidth:w=2,tooltip:k,annotations:A,frameProps:E={},selection:S,linkedHover:O,onObservation:L,chartId:j}=t,P=o.width,M=o.height,N=o.enableHover,D=o.showGrid,C=o.showLegend,T=o.title,B=o.xLabel,W=o.yLabel,H=i||[];zo("AreaChart",H,"xAccessor",u),zo("AreaChart",H,"yAccessor",d);const{activeSelectionHook:$,customHoverBehavior:_}=No({selection:S,linkedHover:O,fallbackFields:f?["string"==typeof f?f:""]:[],onObservation:L,chartType:"AreaChart",chartId:j}),z=void 0!==(null===(n=H[0])||void 0===n?void 0:n[y]),I=r(()=>{if(z)return H;if(h){const e=H.reduce((e,t)=>{const n="function"==typeof h?h(t):t[h];if(!e[n]){const t={[y]:[]};"string"==typeof h&&(t[h]=n),e[n]=t}return e[n][y].push(t),e},{});return Object.values(e)}return[{[y]:H}]},[H,h,y,z]),R=Po(H,f,m),F=r(()=>e=>{const t={},n=f?In(e,f,R):Lo;return t.fill=n,t.fillOpacity=b,x?(t.stroke=n,t.strokeWidth=w):t.stroke="none",t},[f,R,b,x,w]),Y=r(()=>go(F,$,S),[F,$,S]),{legend:G,margin:X}=Do({data:I,colorBy:f,colorScale:R,showLegend:C,userMargin:a,defaults:o.marginDefaults}),q=h||f,V=r(()=>ao([{label:B||oo(u),accessor:u,role:"x"},{label:W||oo(d),accessor:d,role:"y"},...q?[{label:oo(q),accessor:q,role:"group"}]:[]]),[u,d,B,W,q]),U=Fo({componentName:"AreaChart",data:H,accessors:{xAccessor:u,yAccessor:d}});if(U)return e.createElement(Bo,{componentName:"AreaChart",message:U,width:P,height:M});const Z=r(()=>z||h?I.flatMap(e=>{const t=e[y]||[];return h&&"string"==typeof h?t.map(t=>Object.assign(Object.assign({},t),{[h]:e[h]})):t}):H,[I,y,z,h,H]),Q=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"area",data:Z,xAccessor:u,yAccessor:d,groupAccessor:h||void 0},g&&{y0Accessor:g}),p&&{gradientFill:p}),{curve:v,lineStyle:Y,size:[P,M],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:X,showAxes:o.showAxes,xLabel:B,yLabel:W,xFormat:l,yFormat:c,enableHover:N,showGrid:D}),G&&{legend:G}),T&&{title:T}),s&&{className:s}),{tooltipContent:k?no(k):V}),(O||L)&&{customHoverBehavior:_}),A&&A.length>0&&{annotations:A}),E);return e.createElement(_o,{componentName:"AreaChart",width:P,height:M},e.createElement(Ke,Object.assign({},Q)))}function Ko(t){var n;const o=To(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:i,margin:a,className:s,xFormat:l,yFormat:c,xAccessor:u="x",yAccessor:d="y",areaBy:h,lineDataAccessor:g="coordinates",colorBy:p,colorScheme:y="category10",curve:f="monotoneX",areaOpacity:m=.7,showLine:v=!0,lineWidth:b=2,normalize:x=!1,tooltip:w,annotations:k,frameProps:A={},selection:E,linkedHover:S,onObservation:O,chartId:L}=t,j=o.width,P=o.height,M=o.enableHover,N=o.showGrid,D=o.showLegend,C=o.title,T=o.xLabel,B=o.yLabel,W=i||[],{activeSelectionHook:H,customHoverBehavior:$}=No({selection:E,linkedHover:S,fallbackFields:p?["string"==typeof p?p:""]:[],onObservation:O,chartType:"StackedAreaChart",chartId:L}),_=void 0!==(null===(n=W[0])||void 0===n?void 0:n[g]),z=r(()=>{if(_)return W;if(h){const e=W.reduce((e,t)=>{const n="function"==typeof h?h(t):t[h];if(!e[n]){const t={[g]:[]};"string"==typeof h&&(t[h]=n),e[n]=t}return e[n][g].push(t),e},{});return Object.values(e)}return[{[g]:W}]},[W,h,g,_]),I=Po(W,p,y),R=r(()=>e=>{const t={},n=p?In(e,p,I):Lo;return t.fill=n,t.fillOpacity=m,v?(t.stroke=n,t.strokeWidth=b):t.stroke="none",t},[p,I,m,v,b]),F=r(()=>go(R,H,E),[R,H,E]),{legend:Y,margin:G}=Do({data:z,colorBy:p,colorScale:I,showLegend:D,userMargin:a,defaults:o.marginDefaults}),X=h||p,q=r(()=>ao([{label:T||oo(u),accessor:u,role:"x"},{label:B||oo(d),accessor:d,role:"y"},...X?[{label:oo(X),accessor:X,role:"group"}]:[]]),[u,d,T,B,X]),V=Fo({componentName:"StackedAreaChart",data:W,accessors:{xAccessor:u,yAccessor:d}});if(V)return e.createElement(Bo,{componentName:"StackedAreaChart",message:V,width:j,height:P});const U=r(()=>_||h?z.flatMap(e=>{const t=e[g]||[];return h&&"string"==typeof h?t.map(t=>Object.assign(Object.assign({},t),{[h]:e[h]})):t}):W,[z,g,_,h,W]),Z=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"stackedarea",data:U,xAccessor:u,yAccessor:d,groupAccessor:h||void 0,curve:f,normalize:x,lineStyle:F,size:[j,P],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:G,showAxes:o.showAxes,xLabel:T,yLabel:B,xFormat:l,yFormat:c,enableHover:M,showGrid:N},Y&&{legend:Y}),C&&{title:C}),s&&{className:s}),{tooltipContent:w?no(w):q}),(S||O)&&{customHoverBehavior:$}),k&&k.length>0&&{annotations:k}),A);return e.createElement(_o,{componentName:"StackedAreaChart",width:j,height:P},e.createElement(Ke,Object.assign({},Z)))}function Jo(t){const n=To(t.mode,{width:t.width,height:t.height,showGrid:void 0,enableHover:t.enableHover,showLegend:void 0,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:o,margin:i,className:a,xAccessor:s="x",yAccessor:l="y",valueAccessor:c="value",xFormat:u,yFormat:d,colorScheme:h="blues",customColorScale:g,showValues:p=!1,valueFormat:y,cellBorderColor:f="#fff",cellBorderWidth:m=1,tooltip:v,annotations:x,frameProps:w={},selection:k,linkedHover:A,onObservation:E,chartId:S}=t,O=n.width,L=n.height,j=n.enableHover,P=n.title,M=n.xLabel,N=n.yLabel,D=o||[],{margin:C}=Do({data:D,colorBy:void 0,colorScale:void 0,showLegend:!1,userMargin:i,defaults:n.marginDefaults}),{activeSelectionHook:T,customHoverBehavior:B}=No({selection:k,linkedHover:A,fallbackFields:[],onObservation:E,chartType:"Heatmap",chartId:S}),W=r(()=>"function"==typeof c?e=>c(e):e=>e[c],[c]),H=r(()=>{const e=D.map(W);return[Math.min(...e),Math.max(...e)]},[D,W]),$=r(()=>"custom"===h&&g?g:b({blues:Y,reds:F,greens:R,viridis:_}[h]||Y).domain(H),[h,g,H]);r(()=>{const e=jo(s),t=jo(l);return{xBinCount:new Set(D.map(e)).size,yBinCount:new Set(D.map(t)).size}},[D,s,l]),r(()=>({coordinates:D}),[D]);const z=r(()=>e=>{const t=W(e);return{fill:$(t),stroke:f,strokeWidth:m}},[W,$,f,m]);r(()=>go(z,T,k),[z,T,k]),r(()=>{if(!p)return;const t=(H[0]+H[1])/2;return(n,o)=>{const r=W(n),i=y?y(r):r+"";return e.createElement("text",{textAnchor:"middle",dominantBaseline:"middle",fill:W(n)>t?"#fff":"#000",fontSize:"12px"},i)}},[p,W,y,H]);const I=r(()=>ao([{label:M||oo(s),accessor:s,role:"x"},{label:N||oo(l),accessor:l,role:"y"},{label:oo(c),accessor:c,role:"value"}]),[s,l,M,N,c]),G=Fo({componentName:"Heatmap",data:D,accessors:{xAccessor:s,yAccessor:l,valueAccessor:c}});if(G)return e.createElement(Bo,{componentName:"Heatmap",message:G,width:O,height:L});const X=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"heatmap",data:D,xAccessor:s,yAccessor:l,valueAccessor:c,size:[O,L],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:C,showAxes:n.showAxes,xLabel:M,yLabel:N,xFormat:u,yFormat:d,enableHover:j},P&&{title:P}),a&&{className:a}),{tooltipContent:v?no(v):I}),(A||E)&&{customHoverBehavior:B}),x&&x.length>0&&{annotations:x}),w);return e.createElement(_o,{componentName:"Heatmap",width:O,height:L},e.createElement(Ke,Object.assign({},X)))}function er(t){const n=To(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:o,margin:i,className:a,xFormat:s,yFormat:l,xAccessor:c="x",yAccessor:u="y",sizeBy:d,sizeRange:h=[5,40],colorBy:g,colorScheme:p="category10",bubbleOpacity:y=.6,bubbleStrokeWidth:f=1,bubbleStrokeColor:m="white",tooltip:v,marginalGraphics:b,pointIdAccessor:x,annotations:w,frameProps:k={},selection:A,linkedHover:E,linkedBrush:S,onObservation:O,chartId:L}=t,j=n.width,P=n.height,M=n.enableHover,N=n.showGrid,D=n.showLegend,C=n.title,T=n.xLabel,B=n.yLabel,W=o||[],{activeSelectionHook:H,customHoverBehavior:$}=No({selection:A,linkedHover:E,fallbackFields:g?["string"==typeof g?g:""]:[],onObservation:O,chartType:"BubbleChart",chartId:L}),_=ho(S);Ao({name:(null==_?void 0:_.name)||"__unused_brush__",xField:(null==_?void 0:_.xField)||("string"==typeof c?c:void 0),yField:(null==_?void 0:_.yField)||("string"==typeof u?u:void 0)});const z=Po(W,g,p),I=r(()=>{const e=W.map(e=>"function"==typeof d?d(e):e[d]);return[Math.min(...e),Math.max(...e)]},[W,d]),R=r(()=>e=>{const t={fillOpacity:y,strokeWidth:f,stroke:m};return t.fill=g?In(e,g,z):Lo,t.r=Fn(e,d,h,I),t},[g,z,d,h,I,y,f,m]),F=r(()=>go(R,H,A),[R,H,A]),{legend:Y,margin:G}=Do({data:W,colorBy:g,colorScale:z,showLegend:D,userMargin:i,defaults:n.marginDefaults}),X=r(()=>ao([{label:T||oo(c),accessor:c,role:"x"},{label:B||oo(u),accessor:u,role:"y"},{label:oo(d),accessor:d,role:"size"},...g?[{label:oo(g),accessor:g,role:"color"}]:[]]),[c,u,T,B,d,g]),q=Fo({componentName:"BubbleChart",data:W,accessors:{xAccessor:c,yAccessor:u},requiredProps:{sizeBy:d}});if(q)return e.createElement(Bo,{componentName:"BubbleChart",message:q,width:j,height:P});const V=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bubble",data:W,xAccessor:c,yAccessor:u,colorAccessor:g||void 0,sizeAccessor:d,sizeRange:h,pointStyle:F,colorScheme:p,size:[j,P],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:G,showAxes:n.showAxes,xLabel:T,yLabel:B,xFormat:s,yFormat:l,enableHover:M,showGrid:N},Y&&{legend:Y}),C&&{title:C}),a&&{className:a}),{tooltipContent:v?no(v):X}),(E||O)&&{customHoverBehavior:$}),b&&{marginalGraphics:b}),x&&{pointIdAccessor:x}),w&&w.length>0&&{annotations:w}),k);return e.createElement(_o,{componentName:"BubbleChart",width:j,height:P},e.createElement(Ke,Object.assign({},V)))}function tr(e={}){const{limit:t=50,types:n,chartId:o}=e,i=Oo(e=>e.version),a=Oo(e=>e.observations),s=Oo(e=>e.clearObservations),l=r(()=>{let e=a;if(n&&n.length>0){const t=new Set(n);e=e.filter(e=>t.has(e.type))}return o&&(e=e.filter(e=>e.chartId===o)),e.length>t&&(e=e.slice(e.length-t)),e},[a,n,o,t,i]);return{observations:l,latest:l.length>0?l[l.length-1]:null,clear:s}}function nr({selections:e}){const t=xo(e=>e.setResolution);return o(()=>{for(const[n,o]of Object.entries(e))o.resolution&&t(n,o.resolution)},[e,t]),null}function or({children:t,selections:n}){return e.createElement(bo,null,e.createElement(So,null,n&&e.createElement(nr,{selections:n}),t))}Zo.displayName="LineChart",Qo.displayName="AreaChart",Ko.displayName="StackedAreaChart",Jo.displayName="Heatmap",er.displayName="BubbleChart";const rr="__splomIdx",ir={top:4,bottom:4,left:4,right:4};function ar({frameRef:n,cellSize:r,onBrush:i}){const a=t(null),s=r-ir.left-ir.right,l=r-ir.top-ir.bottom;return o(()=>{if(!a.current)return;const e=y(a.current).select(".brush-g"),t=p().extent([[0,0],[s,l]]).on("brush end",e=>{var t;const o=null===(t=n.current)||void 0===t?void 0:t.getScales();if(!o)return;if(!e.selection)return void i(null);const[[r,a],[s,l]]=e.selection,c=[[o.x.invert(r),o.y.invert(a)],[o.x.invert(s),o.y.invert(l)]];i(c)});return e.call(t),e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{t.on("brush end",null)}},[s,l,n,i]),e.createElement("svg",{ref:a,width:r,height:r,style:{position:"absolute",top:0,left:0}},e.createElement("g",{className:"brush-g",transform:`translate(${ir.left},${ir.top})`}))}function sr({data:n,xField:o,yField:r,cellSize:i,pointRadius:s,pointOpacity:l,colorBy:c,colorScale:u,brushSelectionName:d,hoverSelectionName:h,unselectedOpacity:g,mode:p,onPointHover:y}){const f=t(null),m=wo({name:d,clientId:`splom-${o}-${r}`}),v=Ao({name:d,xField:o,yField:r}),b=wo({name:h,clientId:"splom-hover-source"}),x=b.selectPoints,w=a(e=>{e?v.brushInteraction.during(e):v.brushInteraction.end(null)},[v.brushInteraction]),k=a(e=>{if(!e)return void(null==y||y(null));const t=e.data,n=null==t?void 0:t[rr];void 0!==n&&(x({[rr]:[n]}),null==y||y(t,e.x+ir.left,e.y+ir.top))},[x,y]),A=a(e=>{const t={opacity:l,r:s};return t.fill=c?In(e,c,u):Lo,"hover"===p?b.isActive&&b.predicate(e)?(t.opacity=1,t.r=2.5*s,t.stroke="#333",t.strokeWidth=1.5):b.isActive&&(t.opacity=.6*l):m.isActive&&!m.predicate(e)&&(t.opacity=g),t},[c,u,l,s,p,m.isActive,m.predicate,b.isActive,b.predicate,g]);return e.createElement("div",{style:{position:"relative",width:i,height:i}},e.createElement(Ke,{ref:f,chartType:"scatter",data:n,size:[i,i],xAccessor:o,yAccessor:r,pointStyle:A,margin:ir,showAxes:!1,enableHover:"hover"===p,customHoverBehavior:"hover"===p?k:void 0,tooltipContent:"hover"===p?()=>null:void 0}),"brush"===p&&e.createElement(ar,{frameRef:f,cellSize:i,xField:o,yField:r,onBrush:w}))}function lr({data:t,field:n,label:o,cellSize:i,bins:a,brushSelectionName:s,hoverSelectionName:l,mode:c}){const u=wo({name:s,clientId:"splom-diag-"+n}),d=wo({name:l,clientId:`splom-diag-${n}-hover`}),h="hover"===c?d:u,g=h.isActive,p=h.predicate,y=r(()=>{const e=t.map(e=>e[n]).filter(e=>null!=e&&!isNaN(e));if(0===e.length)return{bars:[],selectedBars:[],max:0};const o=Math.min(...e),r=(Math.max(...e)-o)/a||1,s=Array(a).fill(0),l=Array(a).fill(0);for(const e of t){const t=e[n];if(null==t||isNaN(t))continue;const i=Math.min(Math.floor((t-o)/r),a-1);s[i]++,g&&!p(e)||l[i]++}const c=Math.max(...s,1);return{bars:s.map((e,t)=>({x:t/a*i,w:i/a-1,h:e/c*(i-24),count:e})),selectedBars:l.map((e,t)=>({x:t/a*i,w:i/a-1,h:e/c*(i-24),count:e})),max:c}},[t,n,a,i,g,p]);return e.createElement("svg",{width:i,height:i,style:{overflow:"hidden"}},e.createElement("text",{x:i/2,y:14,textAnchor:"middle",fontSize:11,fontWeight:"bold",fill:"#333"},o),y.bars.map((t,n)=>e.createElement("rect",{key:"bg-"+n,x:t.x,y:i-t.h,width:Math.max(t.w,1),height:t.h,fill:"#ccc",opacity:g?.3:.6})),g&&y.selectedBars.map((t,n)=>e.createElement("rect",{key:"sel-"+n,x:t.x,y:i-t.h,width:Math.max(t.w,1),height:t.h,fill:Lo,opacity:.7})))}function cr({label:t,cellSize:n}){return e.createElement("svg",{width:n,height:n},e.createElement("text",{x:n/2,y:n/2,textAnchor:"middle",dominantBaseline:"middle",fontSize:12,fontWeight:"bold",fill:"#333"},t))}function ur(t){const{data:o,fields:i,fieldLabels:s={},colorBy:l,colorScheme:c="category10",cellSize:u=150,cellGap:d=4,pointRadius:h=2,pointOpacity:g=.5,diagonal:p="histogram",histogramBins:y=20,brushMode:f="crossfilter",hoverMode:m=!0,unselectedOpacity:v=.1,showGrid:b=!1,tooltip:x,showLegend:w,idAccessor:k,className:A,onObservation:E,chartId:S}=t,O="splom",L="splom-hover",j=m?"hover":f?"brush":"hover",P=xo(e=>e.clearSelection),[M,N]=n(null),D=a(()=>{P(L),N(null)},[P,L]),C=r(()=>(o||[]).map((e,t)=>void 0!==e[rr]?e:Object.assign(Object.assign({},e),{[rr]:t})),[o]),T=Po(C,l,c),B=void 0!==w?w:!!l,W=r(()=>{if(!B||!l)return null;const e="string"==typeof l?l:null;return e?[...new Set(C.map(t=>t[e]))].map(e=>({label:e+"",color:T?T(e+""):Lo})):null},[B,l,C,T]),H=r(()=>({display:"grid",gridTemplateColumns:"40px "+i.map(()=>u+"px").join(" "),gridTemplateRows:i.map(()=>u+"px").join(" ")+" 40px",gap:d+"px",width:"fit-content"}),[i,u,d,40]);return e.createElement("div",{className:A,style:{position:"relative"}},W&&e.createElement("div",{style:{display:"flex",gap:12,marginBottom:8,flexWrap:"wrap"}},W.map(t=>e.createElement("div",{key:t.label,style:{display:"flex",alignItems:"center",gap:4}},e.createElement("span",{style:{display:"inline-block",width:10,height:10,borderRadius:"50%",backgroundColor:t.color}}),e.createElement("span",{style:{fontSize:11}},t.label)))),e.createElement("div",{style:H,onMouseLeave:"hover"===j?D:void 0},i.map((t,n)=>e.createElement(e.Fragment,{key:"row-"+t},e.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",writingMode:"vertical-rl",transform:"rotate(180deg)",fontSize:11,fontWeight:"bold",color:"#333"}},s[t]||t),i.map((o,r)=>n===r?"label"===p?e.createElement(cr,{key:"diag-"+t,label:s[t]||t,cellSize:u}):e.createElement(lr,{key:"diag-"+t,data:C,field:t,label:s[t]||t,cellSize:u,bins:y,colorBy:l,colorScale:T,brushSelectionName:O,hoverSelectionName:L,unselectedOpacity:v,mode:j}):e.createElement(sr,{key:`cell-${t}-${o}`,data:C,xField:o,yField:t,fieldLabels:s,cellSize:u,pointRadius:h,pointOpacity:g,colorBy:l,colorScale:T,brushSelectionName:O,hoverSelectionName:L,unselectedOpacity:v,showGrid:b,tooltip:x,mode:j,onPointHover:"hover"===j?(e,i,a)=>{e?(N({datum:e,xField:o,yField:t,colIndex:r,rowIndex:n,px:null!=i?i:0,py:null!=a?a:0}),E&&E({type:"hover",datum:e,x:null!=i?i:0,y:null!=a?a:0,timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:S})):(N(null),E&&E({type:"hover-end",timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:S}))}:void 0})))),e.createElement("div",null)," ",i.map(t=>e.createElement("div",{key:"col-label-"+t,style:{display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:"bold",color:"#333"}},s[t]||t))),M&&"hover"===j&&(()=>{const t=M.datum,n=s[M.xField]||M.xField,o=s[M.yField]||M.yField,r=l?"function"==typeof l?l(t):t[l]:null,i=k?"function"==typeof k?k(t):t[k]:"Row "+t[rr];return e.createElement("div",{style:{position:"absolute",left:40+M.colIndex*(u+d)+M.px,top:M.rowIndex*(u+d)+M.py-8,transform:"translate(-50%, -100%)",color:"#333",background:"rgba(255,255,255,0.95)",border:"1px solid #ddd",borderRadius:3,padding:"4px 8px",fontSize:11,lineHeight:1.4,whiteSpace:"nowrap",pointerEvents:"none",zIndex:10}},e.createElement("div",{style:{fontWeight:"bold",marginBottom:2}},i+""),e.createElement("div",null,n,": ",null!=t[M.xField]?Number(t[M.xField]).toFixed(1):"–"),e.createElement("div",null,o,": ",null!=t[M.yField]?Number(t[M.yField]).toFixed(1):"–"),null!=r&&e.createElement("div",{style:{opacity:.8}},"string"==typeof l?l:"group",": ",r+""))})())}function dr(t){const{brushMode:n="crossfilter",hoverMode:o=!0}=t,r={};return!o&&n&&(r.splom={resolution:n}),o&&(r["splom-hover"]={resolution:"union"}),e.createElement(or,{selections:r},e.createElement(ur,Object.assign({},t)))}function hr({width:n,height:r,margin:i,scales:a,brushDirection:s,extent:l,onBrush:c}){const u=t(null),d=t(null),p=t(!1),f=n+i.left+i.right,m=r+i.top+i.bottom;return o(()=>{if(!u.current||!a)return;const e=y(u.current).select(".brush-group"),t="x"===s?h().extent([[0,0],[n,r]]):g().extent([[0,0],[n,r]]);return t.on("brush end",e=>{if(p.current)return;if(!e.sourceEvent)return;const t=e.selection;if(!t)return void c(null);const n=("x"===s?a.x:a.y).invert;if(!n)return;const o=[n(t[0]),n(t[1])];c(o)}),e.call(t),d.current=t,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.2).attr("stroke","steelblue").attr("stroke-width",1),()=>{t.on("brush end",null)}},[a,n,r,s,c]),o(()=>{if(!d.current||!a||!u.current)return;const e=y(u.current).select(".brush-group"),t="x"===s?a.x:a.y;if(p.current=!0,l){const n=[t(l[0]),t(l[1])];e.call(d.current.move,n)}else e.call(d.current.move,null);p.current=!1},[l,a,s]),e.createElement("svg",{ref:u,width:f,height:m,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},e.createElement("g",{className:"brush-group",transform:`translate(${i.left},${i.top})`}))}function gr(i){var s,l;const{data:c,width:u=600,height:d=400,margin:h,className:g,title:p,xLabel:y,yLabel:f,xFormat:m,yFormat:v,xAccessor:b="x",yAccessor:x="y",lineBy:w,lineDataAccessor:k="coordinates",colorBy:A,colorScheme:E="category10",curve:S="linear",lineWidth:O=2,fillArea:L=!1,areaOpacity:j=.3,showPoints:P=!1,pointRadius:M=3,enableHover:N=!0,showGrid:D=!1,showLegend:C,tooltip:T,minimap:B={},renderBefore:W=!1,onBrush:H,brushExtent:$,frameProps:_={}}=i,z=c||[],[I,R]=n(null),F=null!=$?$:I,Y=a(e=>{$||R(e),null==H||H(e)},[$,H]),G=t(null),[X,q]=n(null);o(()=>{const e=()=>{var t,n;const o=null===(n=null===(t=G.current)||void 0===t?void 0:t.getScales)||void 0===n?void 0:n.call(t);o?q(o):requestAnimationFrame(e)};requestAnimationFrame(e)},[c]);const V=void 0!==(null===(s=z[0])||void 0===s?void 0:s[k]),U=r(()=>{if(V)return z;if(w){const e=z.reduce((e,t)=>{const n="function"==typeof w?w(t):t[w];if(!e[n]){const t={[k]:[]};"string"==typeof w&&(t[w]=n),e[n]=t}return e[n][k].push(t),e},{});return Object.values(e)}return[{[k]:z}]},[z,w,k,V]),Z=r(()=>V||w?U.flatMap(e=>{const t=e[k]||[];return w&&"string"==typeof w?t.map(t=>Object.assign(Object.assign({},t),{[w]:e[w]})):t}):z,[U,k,V,w,z]),Q=Po(z,A,E),K=r(()=>e=>{const t={strokeWidth:O};return t.stroke=A?In(e,A,Q):Lo,L&&(t.fill=t.stroke,t.fillOpacity=j),t},[A,Q,O,L,j]),J=r(()=>B.lineStyle?B.lineStyle:e=>{const t={strokeWidth:1};return t.stroke=A?In(e,A,Q):Lo,t},[A,Q,B.lineStyle]),ee=r(()=>{if(P)return e=>{const t={r:M,fillOpacity:1};return t.fill=A?In(e.parentLine||e,A,Q):Lo,t}},[P,M,A,Q]),{legend:te,margin:ne}=Do({data:U,colorBy:A,colorScale:Q,showLegend:C,userMargin:h}),oe=B.height||60,re=r(()=>{var e,t,n,o,r,i,a,s;return{top:null!==(t=null===(e=B.margin)||void 0===e?void 0:e.top)&&void 0!==t?t:0,bottom:null!==(o=null===(n=B.margin)||void 0===n?void 0:n.bottom)&&void 0!==o?o:20,left:null!==(i=null===(r=B.margin)||void 0===r?void 0:r.left)&&void 0!==i?i:ne.left,right:null!==(s=null===(a=B.margin)||void 0===a?void 0:a.right)&&void 0!==s?s:ne.right}},[B.margin,ne]),ie=B.brushDirection||"x",ae=Fo({componentName:"MinimapChart",data:z,accessors:{xAccessor:b,yAccessor:x}});if(ae)return e.createElement(Bo,{componentName:"MinimapChart",message:ae,width:u,height:d});const se=L?"area":"line",le=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:se,data:Z,xAccessor:b,yAccessor:x,groupAccessor:w||void 0,curve:S,lineStyle:K},P&&{pointStyle:ee}),{size:[u,d],responsiveWidth:i.responsiveWidth,responsiveHeight:i.responsiveHeight,margin:ne,showAxes:!0,xLabel:y,yLabel:f,xFormat:m,yFormat:v,enableHover:N,showGrid:D}),te&&{legend:te}),p&&{title:p}),T&&{tooltipContent:no(T)}),F&&{xExtent:F}),_),ce={chartType:se,data:Z,xAccessor:b,yAccessor:x,groupAccessor:w||void 0,curve:S,lineStyle:J,size:[u,oe+re.top+re.bottom],margin:re,showAxes:null!==(l=B.showAxes)&&void 0!==l&&l,background:B.background,enableHover:!1},ue=e.createElement("div",{key:"minimap",style:{position:"relative",width:u,overflow:"hidden"}},e.createElement(Ke,Object.assign({ref:G},ce)),e.createElement(hr,{width:u-re.left-re.right,height:oe,margin:re,scales:X,brushDirection:ie,extent:F,onBrush:Y})),de=e.createElement("div",{key:"main",style:{overflow:"hidden"}},e.createElement(Ke,Object.assign({},le)));return e.createElement("div",{className:"minimap-chart"+(g?" "+g:"")},W?ue:de,W?de:ue)}function pr(t){const n=To(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:i,className:a,categoryAccessor:s="category",valueAccessor:l="value",orientation:c="vertical",valueFormat:u,colorBy:d,colorScheme:h="category10",sort:g=!1,barPadding:p=5,tooltip:y,annotations:f,frameProps:m={},selection:v,linkedHover:b,onObservation:x,chartId:w}=t,k=n.width,A=n.height,E=n.enableHover,S=n.showGrid,O=n.showLegend,L=n.title,j=n.categoryLabel,P=n.valueLabel,M=o||[];zo("BarChart",M,"categoryAccessor",s),zo("BarChart",M,"valueAccessor",l);const{activeSelectionHook:N,customHoverBehavior:D}=No({selection:v,linkedHover:b,fallbackFields:d?["string"==typeof d?d:""]:[],unwrapData:!0,onObservation:x,chartType:"BarChart",chartId:w}),C=Mo(M,g,l),T=Po(M,d,h),B=r(()=>e=>{const t={};return t.fill=d?In(e,d,T):Lo,t},[d,T]),W=r(()=>go(B,N,v),[B,N,v]),{legend:H,margin:$}=Do({data:C,colorBy:d,colorScale:T,showLegend:O,userMargin:i,defaults:n.marginDefaults}),_=r(()=>so({categoryAccessor:s,valueAccessor:l,groupAccessor:d&&d!==s?d:void 0,groupLabel:"string"==typeof d?d:"group"}),[s,l,d]),z=Fo({componentName:"BarChart",data:M,accessors:{categoryAccessor:s,valueAccessor:l}});if(z)return e.createElement(Bo,{componentName:"BarChart",message:z,width:k,height:A});const I=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bar",data:C,oAccessor:s,rAccessor:l,projection:"horizontal"===c?"horizontal":"vertical",pieceStyle:W,size:[k,A],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:$,barPadding:p,enableHover:E,showAxes:n.showAxes,oLabel:j,rLabel:P,rFormat:u,showGrid:S,oSort:g},H&&{legend:H}),L&&{title:L}),a&&{className:a}),{tooltipContent:y?no(y):_}),(b||x)&&{customHoverBehavior:D}),f&&f.length>0&&{annotations:f}),m);return e.createElement(_o,{componentName:"BarChart",width:k,height:A},e.createElement(vt,Object.assign({},I)))}function yr(t){const n=To(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:i,className:a,categoryAccessor:s="category",stackBy:l,valueAccessor:c="value",orientation:u="vertical",valueFormat:d,colorBy:h,colorScheme:g="category10",normalize:p=!1,barPadding:y=5,tooltip:f,annotations:m,frameProps:v={},selection:b,linkedHover:x,onObservation:w,chartId:k}=t,A=n.width,E=n.height,S=n.enableHover,O=n.showGrid,L=n.showLegend,j=n.title,P=n.categoryLabel,M=n.valueLabel,N=o||[],D=h||l,{activeSelectionHook:C,customHoverBehavior:T}=No({selection:b,linkedHover:x,fallbackFields:D?["string"==typeof D?D:""]:[],unwrapData:!0,onObservation:w,chartType:"StackedBarChart",chartId:k}),B=Po(N,D,g),W=r(()=>e=>D?{fill:In(e,D,B)}:{fill:Lo},[D,B]),H=r(()=>go(W,C,b),[W,C,b]),{legend:$,margin:_}=Do({data:N,colorBy:D,colorScale:B,showLegend:L,userMargin:i,defaults:n.marginDefaults}),z=r(()=>so({categoryAccessor:l,valueAccessor:c,groupAccessor:s}),[l,s,c]),I=Fo({componentName:"StackedBarChart",data:N,accessors:{categoryAccessor:s,valueAccessor:c},requiredProps:{stackBy:l}});if(I)return e.createElement(Bo,{componentName:"StackedBarChart",message:I,width:A,height:E});const R=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bar",data:N,oAccessor:s,rAccessor:c,stackBy:l,normalize:p,projection:"horizontal"===u?"horizontal":"vertical",pieceStyle:H,size:[A,E],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:_,barPadding:y,enableHover:S,showAxes:n.showAxes,oLabel:P,rLabel:M,rFormat:d,showGrid:O},$&&{legend:$}),j&&{title:j}),a&&{className:a}),{tooltipContent:f?no(f):z}),(x||w)&&{customHoverBehavior:T}),m&&m.length>0&&{annotations:m}),v);return e.createElement(_o,{componentName:"StackedBarChart",width:A,height:E},e.createElement(vt,Object.assign({},R)))}function fr(t){const n=To(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:i,className:a,categoryAccessor:s="category",valueAccessor:l="value",orientation:c="vertical",valueFormat:u,colorBy:d,colorScheme:h="category10",sizeBy:g,sizeRange:p=[3,8],pointRadius:y=4,pointOpacity:f=.7,categoryPadding:m=20,tooltip:v,annotations:b,frameProps:x={},selection:w,linkedHover:k,onObservation:A,chartId:E}=t,S=n.width,O=n.height,L=n.enableHover,j=n.showGrid,P=n.showLegend,M=n.title,N=n.categoryLabel,D=n.valueLabel,C=o||[],{activeSelectionHook:T,customHoverBehavior:B}=No({selection:w,linkedHover:k,fallbackFields:d?["string"==typeof d?d:""]:["string"==typeof s?s:""],unwrapData:!0,onObservation:A,chartType:"SwarmPlot",chartId:E}),W=Po(C,d,h),H=r(()=>{if(!g)return;const e=C.map(e=>"function"==typeof g?g(e):e[g]);return[Math.min(...e),Math.max(...e)]},[C,g]),$=r(()=>e=>{const t={fillOpacity:f};return t.fill=d?In(e,d,W):Lo,t.r=g?Fn(e,g,p,H):y,t},[d,W,g,p,H,y,f]),_=r(()=>go($,T,w),[$,T,w]),{legend:z,margin:I}=Do({data:C,colorBy:d,colorScale:W,showLegend:P,userMargin:i,defaults:n.marginDefaults}),R=r(()=>so({categoryAccessor:s,valueAccessor:l,groupAccessor:d||void 0}),[s,l,d]),F=Fo({componentName:"SwarmPlot",data:C,accessors:{categoryAccessor:s,valueAccessor:l}});if(F)return e.createElement(Bo,{componentName:"SwarmPlot",message:F,width:S,height:O});const Y=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"swarm",data:C,oAccessor:s,rAccessor:l,projection:"horizontal"===c?"horizontal":"vertical",pieceStyle:_,size:[S,O],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:I,barPadding:m,enableHover:L,showAxes:n.showAxes,oLabel:N,rLabel:D,rFormat:u,showGrid:j},z&&{legend:z}),M&&{title:M}),a&&{className:a}),{tooltipContent:v?no(v):R}),(k||A)&&{customHoverBehavior:B}),b&&b.length>0&&{annotations:b}),x);return e.createElement(_o,{componentName:"SwarmPlot",width:S,height:O},e.createElement(vt,Object.assign({},Y)))}function mr(t){const n=To(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:i,className:a,categoryAccessor:s="category",valueAccessor:l="value",orientation:c="vertical",valueFormat:u,colorBy:d,colorScheme:h="category10",showOutliers:g=!0,categoryPadding:p=20,tooltip:y,annotations:f,frameProps:m={},selection:v,linkedHover:b,onObservation:x,chartId:w}=t,k=n.width,A=n.height,E=n.enableHover,S=n.showGrid,O=n.showLegend,L=n.title,j=n.categoryLabel,P=n.valueLabel,M=o||[],{activeSelectionHook:N,customHoverBehavior:D}=No({selection:v,linkedHover:b,fallbackFields:d?["string"==typeof d?d:""]:["string"==typeof s?s:""],unwrapData:!0,onObservation:x,chartType:"BoxPlot",chartId:w}),C=Po(M,d,h),T=r(()=>e=>{const t=d?In(e,d,C):Lo;return{fill:t,stroke:t,fillOpacity:.8}},[d,C]),B=r(()=>go(T,N,v),[T,N,v]),{legend:W,margin:H}=Do({data:M,colorBy:d,colorScale:C,showLegend:O,userMargin:i,defaults:n.marginDefaults}),$=r(()=>t=>{const n=t.stats||(t.data||t).stats||{};return e.createElement("div",{className:"semiotic-tooltip",style:Qn},e.createElement("div",{style:{fontWeight:"bold",marginBottom:"4px"}},(t.category||(t.data||t).category||"")+""),null!=n.median&&e.createElement(e.Fragment,null,null!=n.n&&e.createElement("div",null,"n = ",n.n),e.createElement("div",null,"Median: ",n.median.toLocaleString()),e.createElement("div",null,"Q1: ",n.q1.toLocaleString()),e.createElement("div",null,"Q3: ",n.q3.toLocaleString()),e.createElement("div",null,"Min: ",n.min.toLocaleString()),e.createElement("div",null,"Max: ",n.max.toLocaleString())))},[]),_=Fo({componentName:"BoxPlot",data:M,accessors:{categoryAccessor:s,valueAccessor:l}});if(_)return e.createElement(Bo,{componentName:"BoxPlot",message:_,width:k,height:A});const z=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"boxplot",data:M,oAccessor:s,rAccessor:l,projection:"horizontal"===c?"horizontal":"vertical",summaryStyle:B,showOutliers:g,size:[k,A],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:H,barPadding:p,enableHover:E,showAxes:n.showAxes,oLabel:j,rLabel:P,rFormat:u,showGrid:S},W&&{legend:W}),L&&{title:L}),a&&{className:a}),{tooltipContent:y?no(y):$}),(b||x)&&{customHoverBehavior:D}),f&&f.length>0&&{annotations:f}),m);return e.createElement(_o,{componentName:"BoxPlot",width:k,height:A},e.createElement(vt,Object.assign({},z)))}function vr(t){const n=To(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:i,className:a,categoryAccessor:s="category",valueAccessor:l="value",bins:c=25,relative:u=!1,valueFormat:d,colorBy:h,colorScheme:g="category10",categoryPadding:p=20,tooltip:y,annotations:f,frameProps:m={},selection:v,linkedHover:b,onObservation:x,chartId:w}=t,k=n.width,A=n.height,E=n.enableHover,S=n.showGrid,O=n.showLegend,L=n.title,j=n.categoryLabel,P=n.valueLabel,M=o||[],{activeSelectionHook:N,customHoverBehavior:D}=No({selection:v,linkedHover:b,fallbackFields:h?["string"==typeof h?h:""]:["string"==typeof s?s:""],unwrapData:!0,onObservation:x,chartType:"Histogram",chartId:w}),C=Po(M,h,g),T=r(()=>e=>{const t=h?In(e,h,C):Lo;return{fill:t,stroke:t,fillOpacity:.8}},[h,C]),B=r(()=>go(T,N,v),[T,N,v]),{legend:W,margin:H}=Do({data:M,colorBy:h,colorScale:C,showLegend:O,userMargin:i,defaults:n.marginDefaults}),$=r(()=>t=>{const n=t.data||t,o=n.category||t.category||"",r=n.count,i=n.range;return e.createElement("div",{className:"semiotic-tooltip",style:Qn},o&&e.createElement("div",{style:{fontWeight:"bold"}},o+""),null!=r&&e.createElement("div",null,"Count: ",r),i&&2===i.length&&e.createElement("div",{style:{opacity:.8}},Number(i[0]).toFixed(1)," – ",Number(i[1]).toFixed(1)))},[]),_=Fo({componentName:"Histogram",data:M,accessors:{categoryAccessor:s,valueAccessor:l}});if(_)return e.createElement(Bo,{componentName:"Histogram",message:_,width:k,height:A});const z=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"histogram",data:M,oAccessor:s,rAccessor:l,projection:"horizontal",summaryStyle:B,bins:c,normalize:u,size:[k,A],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:H,barPadding:p,enableHover:E,showAxes:n.showAxes,oLabel:j,rLabel:P,rFormat:d,showGrid:S},W&&{legend:W}),L&&{title:L}),a&&{className:a}),{tooltipContent:y?no(y):$}),(b||x)&&{customHoverBehavior:D}),f&&f.length>0&&{annotations:f}),m);return e.createElement(_o,{componentName:"Histogram",width:k,height:A},e.createElement(vt,Object.assign({},z)))}function br(t){const n=To(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:i,className:a,categoryAccessor:s="category",valueAccessor:l="value",orientation:c="vertical",bins:u=25,showIQR:d=!0,valueFormat:h,colorBy:g,colorScheme:p="category10",categoryPadding:y=20,tooltip:f,annotations:m,frameProps:v={},selection:b,linkedHover:x,onObservation:w,chartId:k}=t,A=n.width,E=n.height,S=n.enableHover,O=n.showGrid,L=n.showLegend,j=n.title,P=n.categoryLabel,M=n.valueLabel,N=o||[],{activeSelectionHook:D,customHoverBehavior:C}=No({selection:b,linkedHover:x,fallbackFields:g?["string"==typeof g?g:""]:["string"==typeof s?s:""],unwrapData:!0,onObservation:w,chartType:"ViolinPlot",chartId:k}),T=Po(N,g,p),B=r(()=>e=>{const t=g?In(e,g,T):Lo;return{fill:t,stroke:t,fillOpacity:.6}},[g,T]),W=r(()=>go(B,D,b),[B,D,b]),{legend:H,margin:$}=Do({data:N,colorBy:g,colorScale:T,showLegend:L,userMargin:i,defaults:n.marginDefaults}),_=r(()=>t=>{var n;const o=t.category||t.data&&(null===(n=t.data[0])||void 0===n?void 0:n.category)||"",r=t.stats;if(r)return e.createElement("div",{className:"semiotic-tooltip",style:Qn},o&&e.createElement("div",{style:{fontWeight:"bold"}},o+""),e.createElement("div",null,"n = ",r.n),e.createElement("div",null,"Min: ",r.min.toLocaleString()),e.createElement("div",null,"Q1: ",r.q1.toLocaleString()),e.createElement("div",null,"Median: ",r.median.toLocaleString()),e.createElement("div",null,"Q3: ",r.q3.toLocaleString()),e.createElement("div",null,"Max: ",r.max.toLocaleString()),e.createElement("div",{style:{opacity:.8}},"Mean: ",r.mean.toLocaleString(void 0,{maximumFractionDigits:2})));const i=(Array.isArray(t.data)?t.data:[]).map(e=>{const t="function"==typeof l?l(e):e[l];return Number(t)}).filter(e=>!isNaN(e)).sort((e,t)=>e-t),a=i.length,s=a>0?i[Math.floor(a/2)]:null;return e.createElement("div",{className:"semiotic-tooltip",style:Qn},o&&e.createElement("div",{style:{fontWeight:"bold"}},o+""),a>0&&e.createElement("div",null,"n = ",a),null!=s&&e.createElement("div",null,"Median: ",s.toLocaleString()))},[l]),z=Fo({componentName:"ViolinPlot",data:N,accessors:{categoryAccessor:s,valueAccessor:l}});if(z)return e.createElement(Bo,{componentName:"ViolinPlot",message:z,width:A,height:E});const I=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"violin",data:N,oAccessor:s,rAccessor:l,projection:"horizontal"===c?"horizontal":"vertical",summaryStyle:W,bins:u,showIQR:d,size:[A,E],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:$,barPadding:y,enableHover:S,showAxes:n.showAxes,oLabel:P,rLabel:M,rFormat:h,showGrid:O},H&&{legend:H}),j&&{title:j}),a&&{className:a}),{tooltipContent:f?no(f):_}),(x||w)&&{customHoverBehavior:C}),m&&m.length>0&&{annotations:m}),v);return e.createElement(_o,{componentName:"ViolinPlot",width:A,height:E},e.createElement(vt,Object.assign({},I)))}function xr(t){const n=To(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:i,className:a,categoryAccessor:s="category",valueAccessor:l="value",orientation:c="horizontal",bins:u=20,amplitude:d=1.5,valueFormat:h,colorBy:g,colorScheme:p="category10",categoryPadding:y=5,tooltip:f,annotations:m,frameProps:v={},selection:b,linkedHover:x,onObservation:w,chartId:k}=t,A=n.width,E=n.height,S=n.enableHover,O=n.showGrid,L=n.showLegend,j=n.title,P=n.categoryLabel,M=n.valueLabel,N=o||[],{activeSelectionHook:D,customHoverBehavior:C}=No({selection:b,linkedHover:x,fallbackFields:g?["string"==typeof g?g:""]:["string"==typeof s?s:""],unwrapData:!0,onObservation:w,chartType:"RidgelinePlot",chartId:k}),T=Po(N,g,p),B=r(()=>e=>{const t=g?In(e,g,T):Lo;return{fill:t,stroke:t,fillOpacity:.5}},[g,T]),W=r(()=>go(B,D,b),[B,D,b]),{legend:H,margin:$}=Do({data:N,colorBy:g,colorScale:T,showLegend:L,userMargin:i,defaults:n.marginDefaults}),_=r(()=>t=>{var n;const o=t.category||t.data&&(null===(n=t.data[0])||void 0===n?void 0:n.category)||"",r=t.stats;return r?e.createElement("div",{className:"semiotic-tooltip",style:Qn},o&&e.createElement("div",{style:{fontWeight:"bold"}},o+""),e.createElement("div",null,"n = ",r.n),e.createElement("div",null,"Min: ",r.min.toLocaleString()),e.createElement("div",null,"Q1: ",r.q1.toLocaleString()),e.createElement("div",null,"Median: ",r.median.toLocaleString()),e.createElement("div",null,"Q3: ",r.q3.toLocaleString()),e.createElement("div",null,"Max: ",r.max.toLocaleString()),e.createElement("div",{style:{opacity:.8}},"Mean: ",r.mean.toLocaleString(void 0,{maximumFractionDigits:2}))):e.createElement("div",{className:"semiotic-tooltip",style:Qn},e.createElement("div",{style:{fontWeight:"bold"}},o+""))},[]),z=Fo({componentName:"RidgelinePlot",data:N,accessors:{categoryAccessor:s,valueAccessor:l}});if(z)return e.createElement(Bo,{componentName:"RidgelinePlot",message:z,width:A,height:E});const I=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"ridgeline",data:N,oAccessor:s,rAccessor:l,projection:"horizontal"===c?"horizontal":"vertical",summaryStyle:W,bins:u,size:[A,E],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:$,barPadding:y,enableHover:S,showAxes:n.showAxes,oLabel:P,rLabel:M,rFormat:h,showGrid:O,oSort:!1},H&&{legend:H}),j&&{title:j}),a&&{className:a}),{tooltipContent:f?no(f):_}),(x||w)&&{customHoverBehavior:C}),m&&m.length>0&&{annotations:m}),v);return I.amplitude=d,e.createElement(_o,{componentName:"RidgelinePlot",width:A,height:E},e.createElement(vt,Object.assign({},I)))}function wr(t){var n;const o=To(t.mode,{width:t.width,height:t.height,showGrid:null===(n=t.showGrid)||void 0===n||n,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:i,margin:a,className:s,categoryAccessor:l="category",valueAccessor:c="value",orientation:u="horizontal",valueFormat:d,colorBy:h,colorScheme:g="category10",sort:p=!0,dotRadius:y=5,categoryPadding:f=10,tooltip:m,annotations:v,frameProps:b={},selection:x,linkedHover:w,onObservation:k,chartId:A}=t,E=o.width,S=o.height,O=o.enableHover,L=o.showGrid,j=o.showLegend,P=o.title,M=o.categoryLabel,N=o.valueLabel,D=i||[],{activeSelectionHook:C,customHoverBehavior:T}=No({selection:x,linkedHover:w,fallbackFields:h?["string"==typeof h?h:""]:["string"==typeof l?l:""],unwrapData:!0,onObservation:k,chartType:"DotPlot",chartId:A}),B=Mo(D,p,c),W=Po(D,h,g),H=r(()=>e=>{const t={r:y,fillOpacity:.8};return t.fill=h?In(e,h,W):Lo,t},[h,W,y]),$=r(()=>go(H,C,x),[H,C,x]),{legend:_,margin:z}=Do({data:B,colorBy:h,colorScale:W,showLegend:j,userMargin:a,defaults:o.marginDefaults}),I=r(()=>so({categoryAccessor:l,valueAccessor:c}),[l,c]),R=Fo({componentName:"DotPlot",data:D,accessors:{categoryAccessor:l,valueAccessor:c}});if(R)return e.createElement(Bo,{componentName:"DotPlot",message:R,width:E,height:S});const F=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"point",data:B,oAccessor:l,rAccessor:c,projection:"horizontal"===u?"horizontal":"vertical",pieceStyle:$,size:[E,S],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:z,barPadding:f,enableHover:O,showAxes:o.showAxes,oLabel:M,rLabel:N,rFormat:d,showGrid:L,oSort:p},_&&{legend:_}),P&&{title:P}),s&&{className:s}),{tooltipContent:m?no(m):I}),(w||k)&&{customHoverBehavior:T}),v&&v.length>0&&{annotations:v}),b);return e.createElement(_o,{componentName:"DotPlot",width:E,height:S},e.createElement(vt,Object.assign({},F)))}function kr(t){var n,o;const i=To(t.mode,{width:null!==(n=t.width)&&void 0!==n?n:400,height:null!==(o=t.height)&&void 0!==o?o:400,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title}),{data:a,margin:s,className:l,categoryAccessor:c="category",valueAccessor:u="value",colorBy:d,colorScheme:h="category10",startAngle:g=0,tooltip:p,annotations:y,frameProps:f={},selection:m,linkedHover:v,onObservation:b,chartId:x}=t,w=i.width,k=i.height,A=i.enableHover,E=i.showLegend,S=i.title,O=a||[],L=d||c,{activeSelectionHook:j,customHoverBehavior:P}=No({selection:m,linkedHover:v,fallbackFields:L?["string"==typeof L?L:""]:[],unwrapData:!0,onObservation:b,chartType:"PieChart",chartId:x}),M=Po(O,L,h),N=r(()=>e=>L?{fill:In(e,L,M)}:{fill:Lo},[L,M]),D=r(()=>go(N,j,m),[N,j,m]),{legend:C,margin:T}=Do({data:O,colorBy:L,colorScale:M,showLegend:E,userMargin:s,defaults:i.marginDefaults}),B=r(()=>so({categoryAccessor:c,valueAccessor:u,groupAccessor:d&&d!==c?d:void 0,groupLabel:"string"==typeof d?d:"group",pieData:!0}),[c,u,d]),W=Fo({componentName:"PieChart",data:O,accessors:{categoryAccessor:c,valueAccessor:u}});if(W)return e.createElement(Bo,{componentName:"PieChart",message:W,width:w,height:k});const H=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"pie",data:O,oAccessor:c,rAccessor:u,projection:"radial",pieceStyle:D,startAngle:g,size:[w,k],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:T,enableHover:A,showAxes:!1},C&&{legend:C}),S&&{title:S}),l&&{className:l}),{tooltipContent:p?no(p):B}),(v||b)&&{customHoverBehavior:P}),y&&y.length>0&&{annotations:y}),f);return e.createElement(_o,{componentName:"PieChart",width:w,height:k},e.createElement(vt,Object.assign({},H)))}function Ar(t){var n,o;const i=To(t.mode,{width:null!==(n=t.width)&&void 0!==n?n:400,height:null!==(o=t.height)&&void 0!==o?o:400,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,linkedHover:t.linkedHover}),{data:a,margin:s,className:l,categoryAccessor:c="category",valueAccessor:u="value",innerRadius:d=60,centerContent:h,colorBy:g,colorScheme:p="category10",startAngle:y=0,tooltip:f,annotations:m,frameProps:v={},selection:b,linkedHover:x,onObservation:w,chartId:k}=t,A=i.width,E=i.height,S=i.enableHover,O=i.showLegend,L=i.title,j=a||[],P=g||c,{activeSelectionHook:M,customHoverBehavior:N}=No({selection:b,linkedHover:x,fallbackFields:P?["string"==typeof P?P:""]:[],unwrapData:!0,onObservation:w,chartType:"DonutChart",chartId:k}),D=Po(j,P,p),C=r(()=>e=>P?{fill:In(e,P,D)}:{fill:Lo},[P,D]),T=r(()=>go(C,M,b),[C,M,b]),{legend:B,margin:W}=Do({data:j,colorBy:P,colorScale:D,showLegend:O,userMargin:s,defaults:i.marginDefaults}),H=r(()=>so({categoryAccessor:c,valueAccessor:u,groupAccessor:g&&g!==c?g:void 0,groupLabel:"string"==typeof g?g:"group",pieData:!0}),[c,u,g]),$=Fo({componentName:"DonutChart",data:j,accessors:{categoryAccessor:c,valueAccessor:u}});if($)return e.createElement(Bo,{componentName:"DonutChart",message:$,width:A,height:E});const _=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"donut",data:j,oAccessor:c,rAccessor:u,projection:"radial",pieceStyle:T,innerRadius:d,startAngle:y,centerContent:h,size:[A,E],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:W,enableHover:S,showAxes:!1},B&&{legend:B}),L&&{title:L}),l&&{className:l}),{tooltipContent:f?no(f):H}),(x||w)&&{customHoverBehavior:N}),m&&m.length>0&&{annotations:m}),v);return e.createElement(_o,{componentName:"DonutChart",width:A,height:E},e.createElement(vt,Object.assign({},_)))}function Er(t){const n=To(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:i,className:a,categoryAccessor:s="category",groupBy:l,valueAccessor:c="value",orientation:u="vertical",valueFormat:d,colorBy:h,colorScheme:g="category10",barPadding:p=5,tooltip:y,annotations:f,frameProps:m={},selection:v,linkedHover:b,onObservation:x,chartId:w}=t,k=n.width,A=n.height,E=n.enableHover,S=n.showGrid,O=n.showLegend,L=n.title,j=n.categoryLabel,P=n.valueLabel,M=o||[],N=h||l,{activeSelectionHook:D,customHoverBehavior:C}=No({selection:v,linkedHover:b,fallbackFields:N?["string"==typeof N?N:""]:[],unwrapData:!0,onObservation:x,chartType:"GroupedBarChart",chartId:w}),T=Po(M,N,g),B=r(()=>e=>N?{fill:In(e,N,T)}:{fill:Lo},[N,T]),W=r(()=>go(B,D,v),[B,D,v]),{legend:H,margin:$}=Do({data:M,colorBy:N,colorScale:T,showLegend:O,userMargin:i,defaults:n.marginDefaults}),_=r(()=>so({categoryAccessor:l,valueAccessor:c,groupAccessor:s}),[l,s,c]),z=Fo({componentName:"GroupedBarChart",data:M,accessors:{categoryAccessor:s,valueAccessor:c},requiredProps:{groupBy:l}});if(z)return e.createElement(Bo,{componentName:"GroupedBarChart",message:z,width:k,height:A});const I=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"clusterbar",data:M,oAccessor:s,rAccessor:c,groupBy:l,projection:"horizontal"===u?"horizontal":"vertical",pieceStyle:W,size:[k,A],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:$,barPadding:p,enableHover:E,showAxes:n.showAxes,oLabel:j,rLabel:P,rFormat:d,showGrid:S},H&&{legend:H}),L&&{title:L}),a&&{className:a}),{tooltipContent:y?no(y):_}),(b||x)&&{customHoverBehavior:C}),f&&f.length>0&&{annotations:f}),m);return e.createElement(_o,{componentName:"GroupedBarChart",width:k,height:A},e.createElement(vt,Object.assign({},I)))}function Sr(t){var n;const o=To(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLegend:t.showLegend,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{nodes:i,edges:a,margin:s,className:l,nodeIDAccessor:c="id",sourceAccessor:u="source",targetAccessor:d="target",nodeLabel:h,colorBy:g,colorScheme:p="category10",nodeSize:y=8,nodeSizeRange:f=[5,20],edgeWidth:m=1,edgeColor:v="#999",edgeOpacity:b=.6,iterations:x=300,forceStrength:w=.1,tooltip:k,frameProps:A={},onObservation:E,chartId:S,selection:O,linkedHover:L}=t,j=o.width,P=o.height,M=o.enableHover,N=o.showLegend,D=null!==(n=o.showLabels)&&void 0!==n&&n,C=o.title,T=i||[],B=a||[],W=Po(T,g,p),H=r(()=>e=>{const t={};return t.fill=g?In(e.data||e,g,W):Lo,"number"==typeof y&&(t.r=y),t},[g,W,y]),$=r(()=>e=>({stroke:v,strokeWidth:"number"==typeof m?m:"function"==typeof m?m(e):e[m]||1,opacity:b}),[m,v,b]),_=r(()=>{if(D&&h)return"function"==typeof h?h:e=>e[h]},[D,h]),{legend:z,margin:I}=Do({data:T,colorBy:g,colorScale:W,showLegend:N,userMargin:s,defaults:o.marginDefaults}),{customHoverBehavior:R}=No({selection:O,linkedHover:L,fallbackFields:g?["string"==typeof g?g:""]:[],unwrapData:!0,onObservation:E,chartType:"ForceDirectedGraph",chartId:S}),F=Go({componentName:"ForceDirectedGraph",nodes:i,edges:a,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:c}});return F?e.createElement(Bo,{componentName:"ForceDirectedGraph",message:F,width:j,height:P}):e.createElement(_o,{componentName:"ForceDirectedGraph",width:j,height:P},e.createElement(Zn,Object.assign({chartType:"force",nodes:T,edges:B,size:[j,P],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:I,nodeIDAccessor:c,sourceAccessor:u,targetAccessor:d,iterations:x,forceStrength:w,nodeStyle:H,edgeStyle:$,colorBy:g,colorScheme:p,nodeSize:y,nodeSizeRange:f,nodeLabel:_,showLabels:D,enableHover:M,tooltipContent:k?e=>no(k)(e.data):void 0,customHoverBehavior:L||E?R:void 0,legend:z,className:l,title:C},A)))}function Or(e,t){if(!e)return[];const n=[],o=e=>{n.push(e);const r="function"==typeof t?t(e):e[t];r&&Array.isArray(r)&&r.forEach(o)};return o(e),n}function Lr(e,t,n,o){if(e&&e.length>0)return e;const r=new Set;return t.forEach(e=>{const t="function"==typeof n?n(e):e[n],i="function"==typeof o?o(e):e[o];r.add(t),r.add(i)}),Array.from(r).map(e=>({id:e}))}function jr(e){return"function"==typeof e?e:t=>t[e]||1}function Pr({edgeColorBy:e,colorBy:t,colorScale:n,nodeStyleFn:o,edgeOpacity:r,baseStyle:i={}}){return a=>{const s=Object.assign({fillOpacity:r},i);if("function"==typeof e)s.fill=e(a);else if("source"===e){const e="object"==typeof a.source?a.source:null;t&&e?s.fill=In(e.data||e,t,n):e&&(s.fill=o(e,e.index).fill)}else if("target"===e){const e="object"==typeof a.target?a.target:null;t&&e?s.fill=In(e.data||e,t,n):e&&(s.fill=o(e,e.index).fill)}else"gradient"===e&&(s.fill="#999",s.fillOpacity=.7*r);return s}}function Mr(t){var n;const o=To(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{nodes:i,edges:a,margin:s,className:l,sourceAccessor:c="source",targetAccessor:u="target",valueAccessor:d="value",nodeIdAccessor:h="id",colorBy:g,colorScheme:p="category10",edgeColorBy:y="source",padAngle:f=.01,groupWidth:m=20,sortGroups:v,nodeLabel:b,edgeOpacity:x=.5,tooltip:w,frameProps:k={},onObservation:A,chartId:E,selection:S,linkedHover:O}=t,L=o.width,j=o.height,P=o.enableHover,M=null===(n=o.showLabels)||void 0===n||n,N=o.title,D=a||[],C=r(()=>Lr(i,D,c,u),[i,D,c,u]),T=Po(C,g,p),B=r(()=>(e,t)=>{var n,o;const r={stroke:"black",strokeWidth:1};if(g)r.fill=In(e.data||e,g,T);else{const i=Array.isArray(p)?p:$n[p]||_n,a=Array.isArray(i)?i:_n,s=null!==(o=null!==(n=e.index)&&void 0!==n?n:t)&&void 0!==o?o:0;r.fill=a[s%a.length]}return r},[g,T,p]),W=r(()=>Pr({edgeColorBy:y,colorBy:g,colorScale:T,nodeStyleFn:B,edgeOpacity:x,baseStyle:{stroke:"black",strokeWidth:.5,strokeOpacity:x}}),[y,g,T,B,x]),H=r(()=>{if(!M)return;const e=b||h;return"function"==typeof e?e:t=>t[e]},[M,b,h]),$=Object.assign(Object.assign({},o.marginDefaults),s),{customHoverBehavior:_}=No({selection:S,linkedHover:O,fallbackFields:g?["string"==typeof g?g:""]:[],unwrapData:!0,onObservation:A,chartType:"ChordDiagram",chartId:E}),z=Go({componentName:"ChordDiagram",edges:a,edgesRequired:!0});return z?e.createElement(Bo,{componentName:"ChordDiagram",message:z,width:L,height:j}):e.createElement(_o,{componentName:"ChordDiagram",width:L,height:j},e.createElement(Zn,Object.assign({chartType:"chord",nodes:C,edges:D,size:[L,j],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:$,nodeIDAccessor:h,sourceAccessor:c,targetAccessor:u,valueAccessor:d,padAngle:f,groupWidth:m,sortGroups:v,nodeStyle:B,edgeStyle:W,colorBy:g,colorScheme:p,edgeColorBy:y,edgeOpacity:x,nodeLabel:H,showLabels:M,enableHover:P,tooltipContent:w?e=>no(w)(e.data):void 0,customHoverBehavior:O||A?_:void 0,className:l,title:N},k)))}function Nr(t){var n;const o=To(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:800,height:600}),{nodes:i,edges:a,margin:s,className:l,sourceAccessor:c="source",targetAccessor:u="target",valueAccessor:d="value",nodeIdAccessor:h="id",colorBy:g,colorScheme:p="category10",edgeColorBy:y="source",orientation:f="horizontal",nodeAlign:m="justify",nodePaddingRatio:v=.05,nodeWidth:b=15,nodeLabel:x,edgeOpacity:w=.5,edgeSort:k,tooltip:A,frameProps:E={},onObservation:S,chartId:O,selection:L,linkedHover:j}=t,P=o.width,M=o.height,N=o.enableHover,D=null===(n=o.showLabels)||void 0===n||n,C=o.title,T=a||[],B=r(()=>Lr(i,T,c,u),[i,T,c,u]),W=Po(B,g,p),H=r(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=g?In(e.data||e,g,W):"#4d430c",t},[g,W]),$=r(()=>Pr({edgeColorBy:y,colorBy:g,colorScale:W,nodeStyleFn:H,edgeOpacity:w,baseStyle:{stroke:"none",strokeWidth:0}}),[y,g,W,H,w]),_=r(()=>{if(!D)return;const e=x||h;return"function"==typeof e?e:t=>t[e]},[D,x,h]),z=Object.assign(Object.assign({},o.marginDefaults),s),{customHoverBehavior:I,customClickBehavior:R}=No({selection:L,linkedHover:j,fallbackFields:g?["string"==typeof g?g:""]:[],unwrapData:!0,onObservation:S,chartType:"SankeyDiagram",chartId:O}),F=Go({componentName:"SankeyDiagram",edges:a,edgesRequired:!0});return F?e.createElement(Bo,{componentName:"SankeyDiagram",message:F,width:P,height:M}):e.createElement(_o,{componentName:"SankeyDiagram",width:P,height:M},e.createElement(Zn,Object.assign({chartType:"sankey",nodes:B,edges:T,size:[P,M],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:z,nodeIDAccessor:h,sourceAccessor:c,targetAccessor:u,valueAccessor:d,orientation:f,nodeAlign:m,nodePaddingRatio:v,nodeWidth:b,nodeStyle:H,edgeStyle:$,colorBy:g,colorScheme:p,edgeColorBy:y,edgeOpacity:w,edgeSort:k,nodeLabel:_,showLabels:D,enableHover:N,tooltipContent:A?e=>no(A)(e.data):void 0,customHoverBehavior:j||S?I:void 0,customClickBehavior:S?R:void 0,className:l,title:C},E)))}function Dr(t){var n;const o=To(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{data:i,margin:a,className:s,layout:l="tree",orientation:c="vertical",childrenAccessor:u="children",valueAccessor:d="value",nodeIdAccessor:h="name",colorBy:g,colorScheme:p="category10",colorByDepth:y=!1,edgeStyle:f="curve",nodeLabel:m,nodeSize:v=5,tooltip:b,frameProps:x={},onObservation:w,chartId:k,selection:A,linkedHover:E}=t,S=o.width,O=o.height,L=o.enableHover,j=null===(n=o.showLabels)||void 0===n||n,P=o.title,M=Po(r(()=>Or(i,u),[i,u]),y?void 0:g,p),N=r(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=y?zn[(e.depth||0)%zn.length]:g?In(e.data||e,g,M):Lo,t},[g,y,M]),D=r(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),C=r(()=>{if("treemap"===l||"circlepack"===l||"partition"===l)return jr(d)},[l,d]),T=Object.assign(Object.assign({},o.marginDefaults),a),{customHoverBehavior:B}=No({selection:A,linkedHover:E,fallbackFields:g?["string"==typeof g?g:""]:[],unwrapData:!0,onObservation:w,chartType:"TreeDiagram",chartId:k}),W=Yo({componentName:"TreeDiagram",data:i});return W?e.createElement(Bo,{componentName:"TreeDiagram",message:W,width:S,height:O}):e.createElement(_o,{componentName:"TreeDiagram",width:S,height:O},e.createElement(Zn,Object.assign({chartType:l,data:i,size:[S,O],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:T,nodeIDAccessor:h,childrenAccessor:u,hierarchySum:C,treeOrientation:c,edgeType:f,nodeStyle:N,edgeStyle:D,colorBy:g,colorScheme:p,colorByDepth:y,nodeSize:v,nodeLabel:j?m||h:void 0,showLabels:j,enableHover:L,tooltipContent:b?e=>no(b)(e.data):void 0,customHoverBehavior:E||w?B:void 0,className:s,title:P},x)))}function Cr(t){var n;const o=To(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,linkedHover:t.linkedHover},{width:600,height:600}),{data:i,margin:s,className:l,childrenAccessor:c="children",valueAccessor:u="value",nodeIdAccessor:d="name",colorBy:h,colorScheme:g="category10",colorByDepth:p=!1,labelMode:y="leaf",nodeLabel:f,padding:m=4,paddingTop:v,tooltip:b,frameProps:x={},selection:w,linkedHover:k,onObservation:A,chartId:E}=t,S=o.width,O=o.height,L=o.enableHover,j=null===(n=o.showLabels)||void 0===n||n,P=o.title,{activeSelectionHook:M,customHoverBehavior:N}=No({selection:w,linkedHover:k,fallbackFields:h?["string"==typeof h?h:""]:[],onObservation:A,chartType:"Treemap",chartId:E}),D=a(e=>{if(!e)return N(null);const t=e.data||e;N({data:(null==t?void 0:t.data)||t})},[N]),C=Po(r(()=>Or(i,c),[i,c]),p?void 0:h,g),T=r(()=>e=>{const t={stroke:"#fff",strokeWidth:1,strokeOpacity:.8};return t.fill=p?zn[(e.depth||0)%zn.length]:h?In(e.data||e,h,C):Lo,t},[h,p,C]),B=r(()=>M?e=>{var t;const n=Object.assign({},T(e));if(M.isActive)if(M.predicate(e.data||e))(null==w?void 0:w.selectedStyle)&&Object.assign(n,w.selectedStyle);else{const e=null!==(t=null==w?void 0:w.unselectedOpacity)&&void 0!==t?t:.2;n.opacity=e,n.fillOpacity=e,n.strokeOpacity=e,(null==w?void 0:w.unselectedStyle)&&Object.assign(n,w.unselectedStyle)}return n}:T,[T,M,w]),W=r(()=>jr(u),[u]),H=void 0!==v?v:j&&"parent"===y?18:void 0,$=Object.assign(Object.assign({},o.marginDefaults),s),_=Yo({componentName:"Treemap",data:i});return _?e.createElement(Bo,{componentName:"Treemap",message:_,width:S,height:O}):e.createElement(_o,{componentName:"Treemap",width:S,height:O},e.createElement(Zn,Object.assign({chartType:"treemap",data:i,size:[S,O],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:$,nodeIDAccessor:d,childrenAccessor:c,hierarchySum:W,padding:m,paddingTop:H,nodeStyle:B,colorBy:h,colorScheme:g,colorByDepth:p,nodeLabel:j?f||d:void 0,showLabels:j,enableHover:L,tooltipContent:b?e=>no(b)(e.data):void 0},(k||A)&&{customHoverBehavior:D},{className:l,title:P},x)))}function Tr(t){var n;const o=To(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{data:i,margin:a,className:s,childrenAccessor:l="children",valueAccessor:c="value",nodeIdAccessor:u="name",colorBy:d,colorScheme:h="category10",colorByDepth:g=!1,nodeLabel:p,circleOpacity:y=.7,padding:f=4,tooltip:m,frameProps:v={},onObservation:b,chartId:x,selection:w,linkedHover:k}=t,A=o.width,E=o.height,S=o.enableHover,O=null===(n=o.showLabels)||void 0===n||n,L=o.title,j=Po(r(()=>Or(i,l),[i,l]),g?void 0:d,h),P=r(()=>e=>{const t={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:y};return t.fill=g?zn[(e.depth||0)%zn.length]:d?In(e.data||e,d,j):Lo,t},[d,g,j,y]),M=r(()=>jr(c),[c]),N=Object.assign(Object.assign({},o.marginDefaults),a),{customHoverBehavior:D}=No({selection:w,linkedHover:k,fallbackFields:d?["string"==typeof d?d:""]:[],unwrapData:!0,onObservation:b,chartType:"CirclePack",chartId:x}),C=Yo({componentName:"CirclePack",data:i});return C?e.createElement(Bo,{componentName:"CirclePack",message:C,width:A,height:E}):e.createElement(_o,{componentName:"CirclePack",width:A,height:E},e.createElement(Zn,Object.assign({chartType:"circlepack",data:i,size:[A,E],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:N,nodeIDAccessor:u,childrenAccessor:l,hierarchySum:M,padding:f,nodeStyle:P,colorBy:d,colorScheme:h,colorByDepth:g,nodeLabel:O?p||u:void 0,showLabels:O,enableHover:S,tooltipContent:m?e=>no(m)(e.data):void 0,customHoverBehavior:k||b?D:void 0,className:s,title:L},v)))}dr.displayName="ScatterplotMatrix",gr.displayName="MinimapChart",pr.displayName="BarChart",yr.displayName="StackedBarChart",fr.displayName="SwarmPlot",mr.displayName="BoxPlot",vr.displayName="Histogram",br.displayName="ViolinPlot",xr.displayName="RidgelinePlot",wr.displayName="DotPlot",kr.displayName="PieChart",Ar.displayName="DonutChart",Er.displayName="GroupedBarChart",Sr.displayName="ForceDirectedGraph",Mr.displayName="ChordDiagram",Nr.displayName="SankeyDiagram",Dr.displayName="TreeDiagram",Cr.displayName="Treemap",Tr.displayName="CirclePack";const Br=i(function(n,o){var r,i,l,c;const u=To(n.mode,{width:null!==(i=null===(r=n.size)||void 0===r?void 0:r[0])&&void 0!==i?i:n.width,height:null!==(c=null===(l=n.size)||void 0===l?void 0:l[1])&&void 0!==c?c:n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0}),{size:d,margin:h,className:g,arrowOfTime:p="right",windowMode:y="sliding",windowSize:f=200,data:m,timeAccessor:v,valueAccessor:b,timeExtent:x,valueExtent:w,extentPadding:k,stroke:A="#007bff",strokeWidth:E=2,strokeDasharray:S,background:O,tooltipContent:L,tooltip:j,onHover:P,annotations:M,svgAnnotationRules:N,tickFormatTime:D,tickFormatValue:C,decay:T,pulse:B,staleness:W,transition:H,linkedHover:$,onObservation:_,chartId:z}=n,I=u.showAxes,R=u.enableHover,F=null!=h?h:u.marginDefaults,Y=null!=d?d:[u.width,u.height],G=null!=L?L:j,X=t(null),{customHoverBehavior:q}=No({linkedHover:$,unwrapData:!0,onObservation:_,chartType:"RealtimeLineChart",chartId:z}),V=a(e=>{P&&P(e),q(e)},[P,q]);return s(o,()=>({push:e=>{var t;return null===(t=X.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=X.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=X.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=X.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}})),e.createElement(Ke,{ref:X,chartType:"line",runtimeMode:"streaming",size:Y,margin:F,className:g,arrowOfTime:p,windowMode:y,windowSize:f,data:m,timeAccessor:v,valueAccessor:b,xExtent:x,yExtent:w,extentPadding:k,lineStyle:{stroke:A,strokeWidth:E,strokeDasharray:S},showAxes:I,background:O,hoverAnnotation:R,tooltipContent:G,customHoverBehavior:V,annotations:M,svgAnnotationRules:N,tickFormatTime:D,tickFormatValue:C,decay:T,pulse:B,staleness:W,transition:H})});Br.displayName="RealtimeLineChart";const Wr=i(function(n,o){var r,i,l,c;const u=To(n.mode,{width:null!==(i=null===(r=n.size)||void 0===r?void 0:r[0])&&void 0!==i?i:n.width,height:null!==(c=null===(l=n.size)||void 0===l?void 0:l[1])&&void 0!==c?c:n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0}),{binSize:d,size:h,margin:g,className:p,arrowOfTime:y="right",windowMode:f="sliding",windowSize:m=200,data:v,timeAccessor:b,valueAccessor:x,timeExtent:w,valueExtent:k,extentPadding:A,categoryAccessor:E,colors:S,fill:O,stroke:L,strokeWidth:j,gap:P,background:M,tooltipContent:N,tooltip:D,onHover:C,annotations:T,svgAnnotationRules:B,tickFormatTime:W,tickFormatValue:H,linkedHover:$,decay:_,pulse:z,staleness:I,transition:R,onObservation:F,chartId:Y}=n,G=u.showAxes,X=u.enableHover,q=null!=g?g:u.marginDefaults,V=null!=h?h:[u.width,u.height],U=null!=N?N:D,Z=t(null),{customHoverBehavior:Q}=No({linkedHover:$,unwrapData:!0,onObservation:F,chartType:"RealtimeTemporalHistogram",chartId:Y}),K=a(e=>{C&&C(e),Q(e)},[C,Q]);s(o,()=>({push:e=>{var t;return null===(t=Z.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=Z.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=Z.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=Z.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const J={};return null!=O&&(J.fill=O),null!=L&&(J.stroke=L),null!=j&&(J.strokeWidth=j),null!=P&&(J.gap=P),e.createElement(Ke,{ref:Z,chartType:"bar",runtimeMode:"streaming",size:V,margin:q,className:p,arrowOfTime:y,windowMode:f,windowSize:m,data:v,timeAccessor:b,valueAccessor:x,xExtent:w,yExtent:k,extentPadding:A,binSize:d,categoryAccessor:E,barColors:S,barStyle:J,showAxes:G,background:M,hoverAnnotation:X,tooltipContent:U,customHoverBehavior:K,annotations:T,svgAnnotationRules:B,tickFormatTime:W,tickFormatValue:H,decay:_,pulse:z,staleness:I,transition:R})});Wr.displayName="RealtimeTemporalHistogram";const Hr=Wr,$r=i(function(n,o){var r,i,l,c;const u=To(n.mode,{width:null!==(i=null===(r=n.size)||void 0===r?void 0:r[0])&&void 0!==i?i:n.width,height:null!==(c=null===(l=n.size)||void 0===l?void 0:l[1])&&void 0!==c?c:n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0}),{size:d,margin:h,className:g,arrowOfTime:p="right",windowMode:y="sliding",windowSize:f=200,data:m,timeAccessor:v,valueAccessor:b,timeExtent:x,valueExtent:w,extentPadding:k,categoryAccessor:A,colors:E,radius:S,fill:O,opacity:L,stroke:j,strokeWidth:P,background:M,tooltipContent:N,tooltip:D,onHover:C,annotations:T,svgAnnotationRules:B,tickFormatTime:W,tickFormatValue:H,linkedHover:$,onObservation:_,chartId:z}=n,I=u.showAxes,R=u.enableHover,F=null!=h?h:u.marginDefaults,Y=null!=d?d:[u.width,u.height],G=null!=N?N:D,X=t(null),{customHoverBehavior:q}=No({linkedHover:$,unwrapData:!0,onObservation:_,chartType:"RealtimeSwarmChart",chartId:z}),V=a(e=>{C&&C(e),q(e)},[C,q]);s(o,()=>({push:e=>{var t;return null===(t=X.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=X.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=X.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=X.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const U={};return null!=S&&(U.radius=S),null!=O&&(U.fill=O),null!=L&&(U.opacity=L),null!=j&&(U.stroke=j),null!=P&&(U.strokeWidth=P),e.createElement(Ke,{ref:X,chartType:"swarm",runtimeMode:"streaming",size:Y,margin:F,className:g,arrowOfTime:p,windowMode:y,windowSize:f,data:m,timeAccessor:v,valueAccessor:b,xExtent:x,yExtent:w,extentPadding:k,categoryAccessor:A,barColors:E,swarmStyle:U,showAxes:I,background:M,hoverAnnotation:R,tooltipContent:G,customHoverBehavior:V,annotations:T,svgAnnotationRules:B,tickFormatTime:W,tickFormatValue:H})});$r.displayName="RealtimeSwarmChart";const _r=i(function(n,o){var r,i,l,c;const u=To(n.mode,{width:null!==(i=null===(r=n.size)||void 0===r?void 0:r[0])&&void 0!==i?i:n.width,height:null!==(c=null===(l=n.size)||void 0===l?void 0:l[1])&&void 0!==c?c:n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0}),{size:d,margin:h,className:g,arrowOfTime:p="right",windowMode:y="sliding",windowSize:f=200,data:m,timeAccessor:v,valueAccessor:b,timeExtent:x,valueExtent:w,extentPadding:k,positiveColor:A,negativeColor:E,connectorStroke:S,connectorWidth:O,gap:L,stroke:j,strokeWidth:P,background:M,tooltipContent:N,tooltip:D,onHover:C,annotations:T,svgAnnotationRules:B,tickFormatTime:W,tickFormatValue:H,linkedHover:$,onObservation:_,chartId:z}=n,I=u.showAxes,R=u.enableHover,F=null!=h?h:u.marginDefaults,Y=null!=d?d:[u.width,u.height],G=null!=N?N:D,X=t(null),{customHoverBehavior:q}=No({linkedHover:$,unwrapData:!0,onObservation:_,chartType:"RealtimeWaterfallChart",chartId:z}),V=a(e=>{C&&C(e),q(e)},[C,q]);s(o,()=>({push:e=>{var t;return null===(t=X.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=X.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=X.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=X.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const U={};return null!=A&&(U.positiveColor=A),null!=E&&(U.negativeColor=E),null!=S&&(U.connectorStroke=S),null!=O&&(U.connectorWidth=O),null!=L&&(U.gap=L),null!=j&&(U.stroke=j),null!=P&&(U.strokeWidth=P),e.createElement(Ke,{ref:X,chartType:"waterfall",runtimeMode:"streaming",size:Y,margin:F,className:g,arrowOfTime:p,windowMode:y,windowSize:f,data:m,timeAccessor:v,valueAccessor:b,xExtent:x,yExtent:w,extentPadding:k,waterfallStyle:U,showAxes:I,background:M,hoverAnnotation:R,tooltipContent:G,customHoverBehavior:V,annotations:T,svgAnnotationRules:B,tickFormatTime:W,tickFormatValue:H})});_r.displayName="RealtimeWaterfallChart";const zr=i(function(n,o){var r,i,l,c;const u=To(n.mode,{width:null!==(i=null===(r=n.size)||void 0===r?void 0:r[0])&&void 0!==i?i:n.width,height:null!==(c=null===(l=n.size)||void 0===l?void 0:l[1])&&void 0!==c?c:n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0}),{size:d,margin:h,className:g,arrowOfTime:p="right",windowMode:y="sliding",windowSize:f=200,data:m,timeAccessor:v,valueAccessor:b,categoryAccessor:x,timeExtent:w,valueExtent:k,extentPadding:A,heatmapXBins:E=20,heatmapYBins:S=20,aggregation:O="count",background:L,tooltipContent:j,tooltip:P,onHover:M,annotations:N,svgAnnotationRules:D,tickFormatTime:C,tickFormatValue:T,decay:B,pulse:W,staleness:H,linkedHover:$,onObservation:_,chartId:z}=n,I=u.showAxes,R=u.enableHover,F=null!=h?h:u.marginDefaults,Y=null!=d?d:[u.width,u.height],G=null!=j?j:P,X=t(null),{customHoverBehavior:q}=No({linkedHover:$,unwrapData:!0,onObservation:_,chartType:"RealtimeHeatmap",chartId:z}),V=a(e=>{M&&M(e),q(e)},[M,q]);return s(o,()=>({push:e=>{var t;return null===(t=X.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=X.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=X.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=X.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}})),e.createElement(Ke,{ref:X,chartType:"heatmap",runtimeMode:"streaming",size:Y,margin:F,className:g,arrowOfTime:p,windowMode:y,windowSize:f,data:m,timeAccessor:v,valueAccessor:b,categoryAccessor:x,xExtent:w,yExtent:k,extentPadding:A,heatmapXBins:E,heatmapYBins:S,heatmapAggregation:O,showAxes:I,background:L,hoverAnnotation:R,tooltipContent:G,customHoverBehavior:V,annotations:N,svgAnnotationRules:D,tickFormatTime:C,tickFormatValue:T,decay:B,pulse:W,staleness:H})});function Ir(e){if(null==e)return"";if("number"!=typeof e)return e+"";if(!isFinite(e))return e+"";if(0===e)return"0";const t=parseFloat(e.toPrecision(12)),n=Math.abs(t);return 1e9>n?1e6>n?1e4>n?Number.isInteger(t)?t+"":parseFloat(t.toPrecision(6))+"":parseFloat((t/1e3).toPrecision(3))+"K":parseFloat((t/1e6).toPrecision(3))+"M":parseFloat((t/1e9).toPrecision(3))+"B"}zr.displayName="RealtimeHeatmap";const Rr={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}},Fr={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}},[Yr,Gr]=po(e=>({theme:Rr,setTheme(t){e(e=>"light"===t?{theme:Rr}:"dark"===t?{theme:Fr}:{theme:Object.assign(Object.assign(Object.assign({},e.theme),t),{colors:Object.assign(Object.assign({},e.theme.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.theme.typography),t.typography||{})})})}}));function Xr({theme:t}){const n=Gr(e=>e.setTheme);return e.useEffect(()=>{void 0!==t&&n(t)},[t,n]),null}function qr({children:t}){const n=Gr(e=>e.theme);return e.createElement("div",{style:{position:"relative","--semiotic-bg":n.colors.background,"--semiotic-text":n.colors.text,"--semiotic-text-secondary":n.colors.textSecondary,"--semiotic-grid":n.colors.grid,"--semiotic-border":n.colors.border,"--semiotic-primary":n.colors.primary,"--semiotic-font-family":n.typography.fontFamily}},t)}function Vr({theme:t,children:n}){return e.createElement(Yr,null,e.createElement(Xr,{theme:t}),e.createElement(qr,null,n))}function Ur(){return Gr(e=>e.theme)}function Zr(e,t,n,o){return new(n||(n=Promise))(function(r,i){function a(e){try{l(o.next(e))}catch(e){i(e)}}function s(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){e.done?r(e.value):function(e){return e instanceof n?e:new n(function(t){t(e)})}(e.value).then(a,s)}l((o=o.apply(e,t||[])).next())})}function Qr(e,t){return Zr(this,void 0,void 0,function*(){const{format:n="svg",filename:o="chart",scale:r=2,background:i="white"}=t||{},a=e.querySelector("svg");if(!a)throw Error("No SVG element found in the container");const s=a.cloneNode(!0),l=a.getBoundingClientRect();if(s.getAttribute("width")||s.setAttribute("width",l.width+""),s.getAttribute("height")||s.setAttribute("height",l.height+""),s.getAttribute("xmlns")||s.setAttribute("xmlns","http://www.w3.org/2000/svg"),Kr(a,s),"svg"===n){const e=(new XMLSerializer).serializeToString(s);Jr(new Blob([e],{type:"image/svg+xml;charset=utf-8"}),o+".svg")}else{const e=l.width*r,t=l.height*r,n=(new XMLSerializer).serializeToString(s),a=new Blob([n],{type:"image/svg+xml;charset=utf-8"}),c=URL.createObjectURL(a),u=new Image;u.width=l.width,u.height=l.height,yield new Promise((n,a)=>{u.onload=()=>{const s=document.createElement("canvas");s.width=e,s.height=t;const l=s.getContext("2d");l.fillStyle=i,l.fillRect(0,0,e,t),l.scale(r,r),l.drawImage(u,0,0),s.toBlob(e=>{e?(Jr(e,o+".png"),n()):a(Error("Failed to create PNG blob"))},"image/png"),URL.revokeObjectURL(c)},u.onerror=()=>{URL.revokeObjectURL(c),a(Error("Failed to load SVG image"))},u.src=c})}})}function Kr(e,t){var n;const o=e.children,r=t.children,i=window.getComputedStyle(e),a=["fill","stroke","stroke-width","stroke-dasharray","opacity","fill-opacity","stroke-opacity","font-family","font-size","font-weight","text-anchor","dominant-baseline"];for(const e of a){const o=i.getPropertyValue(e);o&&"none"!==o&&""!==o&&(null===(n=t.style)||void 0===n||n.setProperty(e,o))}for(let e=0;Math.min(o.length,r.length)>e;e++)Kr(o[e],r[e])}function Jr(e,t){const n=URL.createObjectURL(e),o=document.createElement("a");o.href=n,o.download=t,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(n)}"function"==typeof SuppressedError&&SuppressedError;const ei={width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["function","object"]},frameProps:{type:"object"}},ti={xLabel:{type:"string"},yLabel:{type:"string"},xFormat:{type:"function"},yFormat:{type:"function"}},ni={categoryLabel:{type:"string"},valueLabel:{type:"string"},valueFormat:{type:"function"}},oi=["linear","monotoneX","monotoneY","step","stepAfter","stepBefore","basis","cardinal","catmullRom"],ri=["vertical","horizontal"],ii={LineChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},ei),ti),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},lineBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:oi},lineWidth:{type:"number"},showPoints:{type:"boolean"},pointRadius:{type:"number"},fillArea:{type:"boolean"},areaOpacity:{type:"number"}})},AreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},ei),ti),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:oi},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"}})},StackedAreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},ei),ti),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:oi},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"},normalize:{type:"boolean"}})},Scatterplot:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},ei),ti),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"}})},BubbleChart:{required:["data","sizeBy"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},ei),ti),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},bubbleOpacity:{type:"number"},bubbleStrokeWidth:{type:"number"},bubbleStrokeColor:{type:"string"}})},Heatmap:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},ei),ti),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},colorScheme:{type:"string",enum:["blues","reds","greens","viridis","custom"]},customColorScale:{type:["object","function"]},showValues:{type:"boolean"},valueFormat:{type:"function"},cellBorderColor:{type:"string"},cellBorderWidth:{type:"number"}})},BarChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},ei),ni),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:ri},sort:{type:["boolean","string","function"]},barPadding:{type:"number"}})},StackedBarChart:{required:["data","stackBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},ei),ni),{data:{type:"array"},categoryAccessor:{type:["string","function"]},stackBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:ri},normalize:{type:"boolean"},barPadding:{type:"number"}})},GroupedBarChart:{required:["data","groupBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},ei),ni),{data:{type:"array"},categoryAccessor:{type:["string","function"]},groupBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:ri},barPadding:{type:"number"}})},SwarmPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},ei),ni),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:ri},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"},categoryPadding:{type:"number"}})},BoxPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},ei),ni),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:ri},showOutliers:{type:"boolean"},outlierRadius:{type:"number"},categoryPadding:{type:"number"}})},Histogram:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},ei),ni),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},bins:{type:"number"},relative:{type:"boolean"},categoryPadding:{type:"number"}})},ViolinPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},ei),ni),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:ri},bins:{type:"number"},curve:{type:"string"},showIQR:{type:"boolean"},categoryPadding:{type:"number"}})},DotPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},ei),ni),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:ri},sort:{type:["boolean","string","function"]},dotRadius:{type:"number"},categoryPadding:{type:"number"}})},PieChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},ei),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},startAngle:{type:"number"},slicePadding:{type:"number"}})},DonutChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},ei),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},innerRadius:{type:"number"},centerContent:{type:["object","string","number"]},startAngle:{type:"number"},slicePadding:{type:"number"}})},ForceDirectedGraph:{required:["nodes","edges"],dataShape:"network",dataAccessors:["nodeIDAccessor","sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},ei),{nodes:{type:"array"},edges:{type:"array"},nodeIDAccessor:{type:["string","function"]},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},nodeLabel:{type:["string","function"]},nodeSize:{type:["number","string","function"]},nodeSizeRange:{type:"array"},edgeWidth:{type:["number","string","function"]},edgeColor:{type:"string"},edgeOpacity:{type:"number"},iterations:{type:"number"},forceStrength:{type:"number"},showLabels:{type:"boolean"}})},SankeyDiagram:{required:["edges"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},ei),{nodes:{type:"array"},edges:{type:"array"},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},edgeColorBy:{type:["string","function"],enum:["source","target","gradient"]},orientation:{type:"string",enum:ri},nodeAlign:{type:"string",enum:["justify","left","right","center"]},nodePaddingRatio:{type:"number"},nodeWidth:{type:"number"},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},edgeOpacity:{type:"number"},edgeSort:{type:"function"}})},ChordDiagram:{required:["edges"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},ei),{nodes:{type:"array"},edges:{type:"array"},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},edgeColorBy:{type:["string","function"],enum:["source","target"]},padAngle:{type:"number"},groupWidth:{type:"number"},sortGroups:{type:"function"},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},edgeOpacity:{type:"number"}})},TreeDiagram:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},ei),{data:{type:"object"},layout:{type:"string",enum:["tree","cluster","partition","treemap","circlepack"]},orientation:{type:"string",enum:["vertical","horizontal","radial"]},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},edgeStyle:{type:"string",enum:["line","curve"]},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},nodeSize:{type:"number"}})},Treemap:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},ei),{data:{type:"object"},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},showLabels:{type:"boolean"},nodeLabel:{type:["string","function"]}})},CirclePack:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},ei),{data:{type:"object"},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},showLabels:{type:"boolean"},nodeLabel:{type:["string","function"]},circleOpacity:{type:"number"}})},RealtimeLineChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},stroke:{type:"string"},strokeWidth:{type:"number"},strokeDasharray:{type:"string"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeHistogram:{required:["binSize"],dataShape:"realtime",dataAccessors:[],props:{binSize:{type:"number"},size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},colors:{type:"object"},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},fill:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},gap:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeSwarmChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},colors:{type:"object"},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},radius:{type:"number"},fill:{type:"string"},opacity:{type:"number"},stroke:{type:"string"},strokeWidth:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeWaterfallChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},positiveColor:{type:"string"},negativeColor:{type:"string"},connectorStroke:{type:"string"},connectorWidth:{type:"number"},gap:{type:"number"},stroke:{type:"string"},strokeWidth:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeHeatmap:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},heatmapXBins:{type:"number"},heatmapYBins:{type:"number"},aggregation:{type:"string",enum:["count","sum","mean"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"}}}},ai=new Set(["tooltip","onObservation","xFormat","yFormat","valueFormat","svgAnnotationRules","tooltipContent","onHover","tickFormatTime","tickFormatValue","edgeSort","sortGroups","centerContent","frameProps","controls","oFormat","rFormat","oSort","pieceStyle","summaryStyle","nodeStyle","edgeStyle","customHoverBehavior","customClickBehavior","customDoubleClickBehavior","onBrush","onTopologyChange","backgroundGraphics","foregroundGraphics","legend"]),si=new Set(["data","nodes","edges"]),li="function"==typeof structuredClone?structuredClone:e=>JSON.parse(JSON.stringify(e));function ci(e,t,n){if(!ii[e])throw Error(`Unknown component "${e}". Known components: ${Object.keys(ii).join(", ")}`);const o=!1!==(null==n?void 0:n.includeData),r={};for(const[e,n]of Object.entries(t))null!=n&&(ai.has(e)||!o&&si.has(e)||"function"!=typeof n&&((null==n?void 0:n.$$typeof)||(r[e]=li(n))));return Object.assign({component:e,props:r,version:"1",createdAt:(new Date).toISOString()},(null==n?void 0:n.selections)?{selections:n.selections}:{})}function ui(e){if(!e.component||!e.props)throw Error("Invalid chart config: missing component or props");if(!ii[e.component])throw Error(`Unknown component "${e.component}". This config may require a newer version of semiotic.`);return{componentName:e.component,props:li(e.props)}}function di(e){const t=JSON.stringify(e);return"sc="+btoa(unescape(encodeURIComponent(t))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function hi(e){const t=new URLSearchParams(e.includes("?")?e.split("?")[1]:e).get("sc");if(!t)throw Error("No chart config found in URL (missing 'sc' parameter)");const n=t.replace(/-/g,"+").replace(/_/g,"/"),o=decodeURIComponent(escape(atob(n)));return JSON.parse(o)}function gi(e){return Zr(this,arguments,void 0,function*(e,t="json"){const n="jsx"===t?pi(e):JSON.stringify(e,null,2);if("undefined"==typeof navigator||!navigator.clipboard)throw Error("Clipboard API not available. copyConfig requires a browser environment.");yield navigator.clipboard.writeText(n)})}function pi(e){const{component:t,props:n}=e,o=["<"+t];for(const[e,t]of Object.entries(n))if("string"==typeof t)o.push(` ${e}="${t}"`);else if("boolean"==typeof t&&!0===t)o.push(" "+e);else if("boolean"==typeof t&&!1===t)o.push(` ${e}={false}`);else if("number"==typeof t)o.push(` ${e}={${t}}`);else{const n=JSON.stringify(t);o.push(80>n.length?` ${e}={${n}}`:` ${e}={${JSON.stringify(t,null,2)}}`)}return o.push("/>"),o.join("\n")}function yi(e){const t={};for(const[n,o]of e){const e=[];for(const[,t]of o.clauses){const n={};for(const[e,o]of Object.entries(t.fields))n[e]="point"===o.type?{type:"point",values:Array.from(o.values)}:{type:"interval",range:o.range};e.push({clientId:t.clientId,type:t.type,fields:n})}t[n]={name:o.name,resolution:o.resolution,clauses:e}}return t}function fi(e){const t=new Map;for(const[n,o]of Object.entries(e)){const e=new Map;for(const t of o.clauses){const n={};for(const[e,o]of Object.entries(t.fields))n[e]="point"===o.type?{type:"point",values:new Set(o.values)}:{type:"interval",range:o.range};e.set(t.clientId,{clientId:t.clientId,type:t.type,fields:n})}t.set(n,{name:o.name,resolution:o.resolution,clauses:e})}return t}function mi(e){return"nominal"===e||"ordinal"===e}function vi(e){return"quantitative"===e||"temporal"===e}const bi={category10:"category10",category20:"category20",category20b:"category20",category20c:"category20",accent:"accent",dark2:"dark2",paired:"paired",pastel1:"pastel1",pastel2:"pastel2",set1:"set1",set2:"set2",set3:"set3",tableau10:"category10",tableau20:"category20"},xi={linear:"linear","monotone-x":"monotoneX","monotone-y":"monotoneY",monotone:"monotoneX",step:"step","step-after":"stepAfter","step-before":"stepBefore",basis:"basis",cardinal:"cardinal","catmull-rom":"catmullRom"},wi={sum:"sum",mean:"mean",average:"mean",count:"count",min:"min",max:"max",median:"mean"};function ki(e){var t,n,o,r,i,a,s,l,c,u,d,h,g,p;const y=[],{type:f,markProps:m}=function(e){if("string"==typeof e)return{type:e,markProps:{}};const{type:t}=e;return{type:t,markProps:function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&0>t.indexOf(o)&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);o.length>r;r++)0>t.indexOf(o[r])&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n}(e,["type"])}}(e.mark),v=e.encoding||{},b=v.x,x=v.y,w=v.color,k=v.size,A=v.theta,E=v.opacity;let S;(null===(t=e.data)||void 0===t?void 0:t.values)?S=e.data.values:(null===(n=e.data)||void 0===n?void 0:n.url)&&y.push("data.url is not supported — only inline data.values can be translated. Provide data manually."),e.transform&&e.transform.length>0&&y.push("Vega-Lite transforms are not supported. Pre-transform your data before passing to fromVegaLite()."),e.layer&&y.push('Layered specs ("layer") are not supported. Only single-mark specs can be translated.'),(e.hconcat||e.vconcat||e.concat)&&y.push('Concatenated views ("hconcat"/"vconcat"/"concat") are not supported. Translate each sub-spec individually.'),(e.facet||e.encoding&&e.encoding.facet||e.encoding&&(e.encoding.row||e.encoding.column))&&y.push("Faceted views are not supported. Use Semiotic's LinkedCharts or render multiple charts manually."),e.repeat&&y.push('Repeated views ("repeat") are not supported. Translate each field combination individually.'),(e.params||e.selection)&&y.push("Selections/params are not supported. Use Semiotic's LinkedCharts and selection props for interactivity.");const O={};e.width&&(O.width=e.width),e.height&&(O.height=e.height);const L=function(e){if(e)return"string"==typeof e?e:e.text}(e.title);if(L&&(O.title=L),(null==w?void 0:w.field)&&(O.colorBy=w.field,null===(o=w.scale)||void 0===o?void 0:o.scheme)){const e=bi[w.scale.scheme];e&&(O.colorScheme=e)}void 0!==(null==E?void 0:E.value)&&(O.pointOpacity=E.value);const j=null==b?void 0:b.aggregate,P=null==x?void 0:x.aggregate;if(S&&(j||P)){const e=P?x:b,t=P?b:x,n=wi[e.aggregate];if(n&&(null==t?void 0:t.field)&&e.field)S=function(e,t){const{groupBy:n,value:o,agg:r="sum"}=t,i=new Map;for(const t of e){const e=t[n]+"";i.has(e)||i.set(e,[]),i.get(e).push(Number(t[o]))}const a=[];for(const[e,t]of i){let o;switch(r){case"count":o=t.length;break;case"mean":o=t.reduce((e,t)=>e+t,0)/t.length;break;case"min":o=Math.min(...t);break;case"max":o=Math.max(...t);break;default:o=t.reduce((e,t)=>e+t,0)}a.push({[n]:e,value:o})}return a}(S,{groupBy:t.field,value:e.field,agg:n});else if(("count"===n||"count"===e.aggregate)&&(null==t?void 0:t.field)&&S){const e=new Map;for(const n of S){const o=n[t.field]+"";e.set(o,(e.get(o)||0)+1)}S=Array.from(e,([e,n])=>({[t.field]:e,value:n}))}}if((null==b?void 0:b.bin)||(null==x?void 0:x.bin)){const e="Histogram";S&&(O.data=S),(null==b?void 0:b.bin)?(O.valueAccessor=b.field,(null==x?void 0:x.field)&&(O.categoryAccessor=x.field),(null===(r=b.axis)||void 0===r?void 0:r.title)&&(O.valueLabel=b.axis.title)):(null==x?void 0:x.bin)&&(O.valueAccessor=x.field,(null==b?void 0:b.field)&&(O.categoryAccessor=b.field),(null===(i=x.axis)||void 0===i?void 0:i.title)&&(O.valueLabel=x.axis.title));const t="object"==typeof((null==b?void 0:b.bin)||(null==x?void 0:x.bin))?(null===(a=null==b?void 0:b.bin)||void 0===a?void 0:a.maxbins)||(null===(s=null==x?void 0:x.bin)||void 0===s?void 0:s.maxbins):void 0;return t&&(O.bins=t),Ei(e,O,y)}let M;switch(f){case"bar":M=function(e,t,n,o,r,i,a){var s,l,c,u,d,h;let g;return(null==n?void 0:n.field)&&!1!==(null==e?void 0:e.stack)&&!1!==(null==t?void 0:t.stack)&&null!==(null==e?void 0:e.stack)&&null!==(null==t?void 0:t.stack)?(g="StackedBarChart",o.stackBy=n.field):g="BarChart",mi(null==e?void 0:e.type)&&vi(null==t?void 0:t.type)?(o.categoryAccessor=e.field,o.valueAccessor=a?"value":t.field,(null===(s=null==e?void 0:e.axis)||void 0===s?void 0:s.title)&&(o.categoryLabel=e.axis.title),(null===(l=null==t?void 0:t.axis)||void 0===l?void 0:l.title)&&(o.valueLabel=t.axis.title)):vi(null==e?void 0:e.type)&&mi(null==t?void 0:t.type)?(o.categoryAccessor=t.field,o.valueAccessor=i?"value":e.field,o.orientation="horizontal",(null===(c=null==t?void 0:t.axis)||void 0===c?void 0:c.title)&&(o.categoryLabel=t.axis.title),(null===(u=null==e?void 0:e.axis)||void 0===u?void 0:u.title)&&(o.valueLabel=e.axis.title)):((null==e?void 0:e.field)&&(o.categoryAccessor=e.field),(null==t?void 0:t.field)&&(o.valueAccessor=a?"value":t.field),(null===(d=null==e?void 0:e.axis)||void 0===d?void 0:d.title)&&(o.categoryLabel=e.axis.title),(null===(h=null==t?void 0:t.axis)||void 0===h?void 0:h.title)&&(o.valueLabel=t.axis.title)),r&&(o.data=r),g}(b,x,w,O,S,j,P);break;case"line":if(M="LineChart",Ai(b,x,O,j,P),(null==w?void 0:w.field)&&(O.lineBy=w.field),m.interpolate){const e=xi[m.interpolate];e&&(O.curve=e)}!0===m.point&&(O.showPoints=!0),S&&(O.data=S);break;case"area":if((null==w?void 0:w.field)?(M="StackedAreaChart",O.areaBy=w.field):M="AreaChart",Ai(b,x,O,j,P),m.interpolate){const e=xi[m.interpolate];e&&(O.curve=e)}void 0!==m.opacity&&(O.areaOpacity=m.opacity),S&&(O.data=S);break;case"point":case"circle":case"square":(null==k?void 0:k.field)?(M="BubbleChart",O.sizeBy=k.field,(null===(l=k.scale)||void 0===l?void 0:l.range)&&(O.sizeRange=k.scale.range)):M="Scatterplot",Ai(b,x,O,j,P),S&&(O.data=S);break;case"rect":M="Heatmap",(null==b?void 0:b.field)&&(O.xAccessor=b.field),(null==x?void 0:x.field)&&(O.yAccessor=x.field),(null==w?void 0:w.field)&&(O.valueAccessor=w.field,delete O.colorBy),(null===(c=null==b?void 0:b.axis)||void 0===c?void 0:c.title)&&(O.xLabel=b.axis.title),(null===(u=null==x?void 0:x.axis)||void 0===u?void 0:u.title)&&(O.yLabel=x.axis.title),S&&(O.data=S);break;case"arc":m.innerRadius&&m.innerRadius>0?(M="DonutChart",O.innerRadius=m.innerRadius):M="PieChart",(null==A?void 0:A.field)?O.valueAccessor=A.field:(null==x?void 0:x.field)&&(O.valueAccessor=P?"value":x.field),(null==w?void 0:w.field)&&(O.categoryAccessor=w.field),(null==b?void 0:b.field)&&!(null==A?void 0:A.field)&&(O.categoryAccessor=b.field),S&&(O.data=S);break;case"tick":M="DotPlot",mi(null==b?void 0:b.type)?(O.categoryAccessor=b.field,(null==x?void 0:x.field)&&(O.valueAccessor=P?"value":x.field),(null===(d=null==b?void 0:b.axis)||void 0===d?void 0:d.title)&&(O.categoryLabel=b.axis.title),(null===(h=null==x?void 0:x.axis)||void 0===h?void 0:h.title)&&(O.valueLabel=x.axis.title)):mi(null==x?void 0:x.type)?(O.categoryAccessor=x.field,(null==b?void 0:b.field)&&(O.valueAccessor=j?"value":b.field),O.orientation="horizontal",(null===(g=null==x?void 0:x.axis)||void 0===g?void 0:g.title)&&(O.categoryLabel=x.axis.title),(null===(p=null==b?void 0:b.axis)||void 0===p?void 0:p.title)&&(O.valueLabel=b.axis.title)):((null==b?void 0:b.field)&&(O.categoryAccessor=b.field),(null==x?void 0:x.field)&&(O.valueAccessor=P?"value":x.field)),S&&(O.data=S);break;default:y.push(`Unsupported mark type "${f}". Defaulting to Scatterplot.`),M="Scatterplot",Ai(b,x,O,j,P),S&&(O.data=S)}return Ei(M,O,y)}function Ai(e,t,n,o,r){var i,a;(null==e?void 0:e.field)&&(n.xAccessor=o?"value":e.field),(null==t?void 0:t.field)&&(n.yAccessor=r?"value":t.field),(null===(i=null==e?void 0:e.axis)||void 0===i?void 0:i.title)&&(n.xLabel=e.axis.title),(null===(a=null==t?void 0:t.axis)||void 0===a?void 0:a.title)&&(n.yLabel=t.axis.title)}function Ei(e,t,n){const o={component:e,props:t,version:"1",createdAt:(new Date).toISOString()};if(n.length>0){o.warnings=n;for(const e of n)console.warn("[semiotic/fromVegaLite] "+e)}return o}const Si={live:{bg:"#22c55e",color:"#fff"},stale:{bg:"#ef4444",color:"#fff"},paused:{bg:"#eab308",color:"#000"},error:{bg:"#ef4444",color:"#fff"},static:{bg:"#6b7280",color:"#fff"}};function Oi({height:t}){return e.createElement("div",{style:{width:"100%",height:t,background:"linear-gradient(90deg, var(--semiotic-border, #e0e0e0) 25%, var(--semiotic-bg, #f5f5f5) 50%, var(--semiotic-border, #e0e0e0) 75%)",backgroundSize:"200% 100%",animation:"semiotic-skeleton-pulse 1.5s ease-in-out infinite",borderRadius:4}})}function Li({error:t}){return e.createElement("div",{role:"alert",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",minHeight:120,padding:24,boxSizing:"border-box"}},e.createElement("div",{style:{textAlign:"center",maxWidth:400,fontSize:14,color:"var(--semiotic-text-secondary, #666)",lineHeight:1.5}},t))}const ji=e.forwardRef(function({title:t,subtitle:n,children:o,width:r="100%",height:i=400,actions:a,chartConfig:s,controls:l,loading:c=!1,error:u,errorBoundary:d=!1,status:h,detailsPanel:g,className:p,style:y},f){const m=e.useRef(null),v=e.useRef(null),[b,x]=e.useState(!1),w=!1!==(null==a?void 0:a.export)&&void 0!==(null==a?void 0:a.export),k=!1!==(null==a?void 0:a.fullscreen)&&void 0!==(null==a?void 0:a.fullscreen),A=!1!==(null==a?void 0:a.copyConfig)&&void 0!==(null==a?void 0:a.copyConfig)&&s,E="object"==typeof(null==a?void 0:a.export)?a.export:{},S="object"==typeof(null==a?void 0:a.copyConfig)?a.copyConfig.format:"json",O=e.useCallback(e=>Zr(this,void 0,void 0,function*(){v.current&&(yield Qr(v.current,Object.assign(Object.assign({},E),e)))}),[E]),L=e.useCallback(()=>{m.current&&(document.fullscreenElement?document.exitFullscreen().catch(()=>{}):m.current.requestFullscreen().catch(()=>{}))},[]),j=e.useCallback(e=>Zr(this,void 0,void 0,function*(){s&&(yield gi(s,e||S||"json"))}),[s,S]);e.useEffect(()=>{const e=()=>{x(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",e),()=>document.removeEventListener("fullscreenchange",e)},[]),e.useImperativeHandle(f,()=>({export:O,toggleFullscreen:L,copyConfig:j,element:m.current}),[O,L,j]);const P=t||n||l||w||k||A||h,M=c?e.createElement(Oi,{height:i}):u?e.createElement(Li,{error:u}):d?e.createElement(Wo,null,o):o;return e.createElement(e.Fragment,null,e.createElement("style",{dangerouslySetInnerHTML:{__html:"@keyframes semiotic-skeleton-pulse {\n 0% { background-position: 200% 0; }\n 100% { background-position: -200% 0; }\n}"}}),e.createElement("div",{ref:m,className:"semiotic-chart-container"+(p?" "+p:""),style:Object.assign(Object.assign({width:r,border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:8,overflow:"hidden",background:"var(--semiotic-bg, #fff)",position:"relative"},b?{display:"flex",flexDirection:"column",width:"100%",height:"100%"}:{}),y)},P&&e.createElement("div",{className:"semiotic-chart-header",style:{padding:"12px 16px",display:"flex",justifyContent:"space-between",alignItems:"flex-start",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"}},e.createElement("div",{className:"semiotic-chart-title-area"},t&&e.createElement("div",{className:"semiotic-chart-title",style:{fontSize:14,fontWeight:600,color:"var(--semiotic-text, #333)"}},t),n&&e.createElement("div",{className:"semiotic-chart-subtitle",style:{fontSize:12,color:"var(--semiotic-text-secondary, #666)",marginTop:t?2:0}},n)),e.createElement("div",{className:"semiotic-chart-toolbar",style:{display:"flex",alignItems:"center",gap:4}},l,w&&e.createElement("button",{className:"semiotic-chart-action",onClick:()=>O(),title:"Export chart",style:Pi},e.createElement("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("path",{d:"M7 2v8M3.5 7L7 10.5 10.5 7"}),e.createElement("path",{d:"M2 12h10"}))),k&&e.createElement("button",{className:"semiotic-chart-action",onClick:L,title:b?"Exit fullscreen":"Fullscreen",style:Pi},e.createElement("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},b?e.createElement(e.Fragment,null,e.createElement("path",{d:"M9 1v4h4"}),e.createElement("path",{d:"M5 13V9H1"}),e.createElement("path",{d:"M13 5H9V1"}),e.createElement("path",{d:"M1 9h4v4"})):e.createElement(e.Fragment,null,e.createElement("path",{d:"M1 5V1h4"}),e.createElement("path",{d:"M13 9v4H9"}),e.createElement("path",{d:"M9 1h4v4"}),e.createElement("path",{d:"M5 13H1V9"})))),A&&e.createElement("button",{className:"semiotic-chart-action",onClick:()=>j(),title:"Copy config",style:Pi},e.createElement("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("rect",{x:"5",y:"5",width:"8",height:"8",rx:"1"}),e.createElement("path",{d:"M9 5V2a1 1 0 00-1-1H2a1 1 0 00-1 1v6a1 1 0 001 1h3"}))),h&&e.createElement("div",{className:"semiotic-chart-status",style:{padding:"2px 8px",borderRadius:4,fontSize:10,fontWeight:700,letterSpacing:"0.05em",textTransform:"uppercase",background:Si[h].bg,color:Si[h].color,lineHeight:"18px"}},h))),e.createElement("div",{className:"semiotic-chart-body",ref:v,style:Object.assign({position:"relative",overflow:"hidden"},b?{flex:1}:{height:i})},M,g)))}),Pi={width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",border:"none",background:"transparent",cursor:"pointer",borderRadius:4,color:"var(--semiotic-text-secondary, #666)",padding:0};function Mi({children:t,columns:n="auto",minCellWidth:o=300,gap:r=16,className:i,style:a}){return e.createElement("div",{className:"semiotic-chart-grid"+(i?" "+i:""),style:Object.assign({display:"grid",gridTemplateColumns:"auto"===n?`repeat(auto-fill, minmax(${o}px, 1fr))`:`repeat(${n}, 1fr)`,gap:r,width:"100%"},a)},t)}function Ni({children:t,context:n,position:o="right",contextSize:r=250,gap:i=12,className:a,style:s}){const l="left"===o||"right"===o,c="left"===o||"top"===o,u=Object.assign({display:"flex",flexDirection:l?c?"row-reverse":"row":c?"column-reverse":"column",gap:i,width:"100%"},s),d=l?{flex:`0 0 ${r}px`,width:r,minHeight:0}:{flex:`0 0 ${r}px`,height:r,minWidth:0};return e.createElement("div",{className:"semiotic-context-layout"+(a?" "+a:""),style:u},e.createElement("div",{style:{flex:"1 1 0%",minWidth:0,minHeight:0}},t),e.createElement("div",{style:d},n))}Mi.displayName="ChartGrid",Ni.displayName="ContextLayout";function Di({children:r,position:i="right",size:s=300,trigger:l="click",chartId:c,observation:u,dismissOnEmpty:d=!0,showClose:h=!0,onToggle:g,className:p,style:y}){const[f,m]=n(null),[v,b]=n(null),[x,w]=n(!1),[k,A]=n(!1),E=t(null),S=t(),O="click"===l?["click","click-end"]:["hover","hover-end"],{latest:L}=tr({types:O,chartId:c,limit:1}),j=void 0!==u?u:L;o(()=>{if(j)if("click"===j.type||"hover"===j.type){const e=j;m(e.datum),b(e),x||(w(!0),A(!0),clearTimeout(S.current),S.current=setTimeout(()=>A(!1),200))}else!d||"click-end"!==j.type&&"hover-end"!==j.type||P()},[j]),o(()=>{null==g||g(x)},[x,g]);const P=a(()=>{A(!0),w(!1),clearTimeout(S.current),S.current=setTimeout(()=>{A(!1),m(null),b(null)},200)},[]);if(o(()=>()=>clearTimeout(S.current),[]),!f&&!k)return null;const M=f&&v?r(f,v):null;if(null===M&&!k)return null;const N=function(e,t,n,o){const r={position:"absolute",background:"var(--semiotic-bg, #fff)",borderColor:"var(--semiotic-border, #e0e0e0)",borderStyle:"solid",borderWidth:0,boxSizing:"border-box",zIndex:10,display:"flex",flexDirection:"column",transition:o?"transform 200ms ease-out, opacity 200ms ease-out":void 0};return Object.assign(Object.assign({},r),"right"===e?{top:0,right:0,width:t,height:"100%",borderLeftWidth:1,padding:"12px 16px",transform:n?"translateX(0)":`translateX(${t}px)`,opacity:n?1:0}:"bottom"===e?{bottom:0,left:0,width:"100%",height:t,borderTopWidth:1,padding:"12px 16px",transform:n?"translateY(0)":`translateY(${t}px)`,opacity:n?1:0}:{top:"50%",left:"50%",transform:n?"translate(-50%, -50%) scale(1)":"translate(-50%, -50%) scale(0.95)",opacity:n?1:0,width:Math.min(t,400),maxHeight:"80%",borderWidth:1,borderRadius:8,padding:"16px 20px",boxShadow:"0 8px 32px rgba(0,0,0,0.12)"})}(i,s,x,k);return e.createElement("div",{ref:E,className:`semiotic-details-panel semiotic-details-${i}${p?" "+p:""}`,style:Object.assign(Object.assign({},N),y)},h&&e.createElement("button",{className:"semiotic-details-close",onClick:P,"aria-label":"Close details",style:Ci},e.createElement("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"},e.createElement("path",{d:"M2 2l8 8M10 2l-8 8"}))),e.createElement("div",{className:"semiotic-details-content",style:{overflow:"auto",flex:1}},M))}const Ci={position:"absolute",top:8,right:8,width:20,height:20,display:"flex",alignItems:"center",justifyContent:"center",border:"none",background:"transparent",cursor:"pointer",borderRadius:4,color:"var(--semiotic-text-secondary, #666)",padding:0,zIndex:1};Di.displayName="DetailsPanel";export{Qo as AreaChart,pr as BarChart,mr as BoxPlot,er as BubbleChart,co as CategoryColorProvider,ji as ChartContainer,Wo as ChartErrorBoundary,Mi as ChartGrid,Mr as ChordDiagram,Tr as CirclePack,qo as ConnectedScatterplot,Ni as ContextLayout,Fr as DARK_THEME,Di as DetailsPanel,Ar as DonutChart,wr as DotPlot,Sr as ForceDirectedGraph,Er as GroupedBarChart,Jo as Heatmap,vr as Histogram,re as IncrementalExtent,Rr as LIGHT_THEME,Zo as LineChart,or as LinkedCharts,gr as MinimapChart,to as MultiLineTooltip,kr as PieChart,zr as RealtimeHeatmap,Hr as RealtimeHistogram,Br as RealtimeLineChart,$r as RealtimeSwarmChart,Wr as RealtimeTemporalHistogram,_r as RealtimeWaterfallChart,xr as RidgelinePlot,oe as RingBuffer,Nr as SankeyDiagram,Xo as Scatterplot,dr as ScatterplotMatrix,Ko as StackedAreaChart,yr as StackedBarChart,Zn as StreamNetworkFrame,vt as StreamOrdinalFrame,Ke as StreamXYFrame,fr as SwarmPlot,Vr as ThemeProvider,eo as Tooltip,Dr as TreeDiagram,Cr as Treemap,br as ViolinPlot,pi as configToJSX,gi as copyConfig,fi as deserializeSelections,Qr as exportChart,ui as fromConfig,hi as fromURL,ki as fromVegaLite,no as normalizeTooltip,yi as serializeSelections,Ir as smartTickFormat,ci as toConfig,di as toURL,Ao as useBrushSelection,uo as useCategoryColors,tr as useChartObserver,Eo as useFilteredData,ko as useLinkedHover,wo as useSelection,Ur as useTheme};
1
+ import*as e from"react";import{useRef as t,useState as n,useEffect as o,useMemo as r,forwardRef as i,useCallback as a,useImperativeHandle as s,useContext as l,createContext as c,useLayoutEffect as u,useId as d}from"react";import{brushX as h,brushY as g,brush as p}from"d3-brush";import{select as y}from"d3-selection";import{scaleLinear as f,scaleBand as m,scaleOrdinal as v,scaleSequential as b}from"d3-scale";import{bin as x,quantile as w,min as k,groups as A,max as E,sum as S,mean as O,group as L}from"d3-array";import{packEnclose as j,hierarchy as P,partition as M,pack as N,treemap as D,treemapBinary as C,cluster as T,tree as B}from"d3-hierarchy";import{interpolateNumber as W}from"d3-interpolate";import{schemeCategory10 as H,interpolatePlasma as $,interpolateViridis as _,interpolatePurples as z,interpolateOranges as I,interpolateGreens as R,interpolateReds as F,interpolateBlues as Y,schemeSet3 as G,schemeTableau10 as X}from"d3-scale-chromatic";import{forceLink as q,forceSimulation as V,forceManyBody as U,forceX as Z,forceY as Q}from"d3-force";import{ribbon as K,chord as J}from"d3-chord";import{arc as ee}from"d3-shape";const te=5e3;class ne{constructor(e){this.lastBoundedData=null,this.chunkTimer=0,this.callback=e}clearLastData(){this.lastBoundedData=null,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(e){if(this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),5e3>=e.length)return void this.callback({inserts:e,bounded:!0});this.callback({inserts:e.slice(0,te),bounded:!0,totalSize:e.length});let t=te;const n=()=>{if(t>=e.length)return;if(e!==this.lastBoundedData)return;const o=Math.min(t+te,e.length);this.callback({inserts:e.slice(t,o),bounded:!1}),t=o,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}push(e){this.callback({inserts:[e],bounded:!1})}pushMany(e){0!==e.length&&this.callback({inserts:e,bounded:!1})}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null}}class oe{constructor(e){if(this._capacity=e,this.head=0,this._size=0,1>e)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(e)}push(e){let t;return this._size===this._capacity?t=this.buffer[this.head]:this._size++,this.buffer[this.head]=e,this.head=(this.head+1)%this._capacity,t}pushMany(e){const t=[];for(const n of e){const e=this.push(n);void 0!==e&&t.push(e)}return t}get(e){if(e>=0&&this._size>e)return this.buffer[(this.head-this._size+e+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let e=0;const t=this;return{next:()=>t._size>e?{done:!1,value:t.get(e++)}:{done:!0,value:void 0}}}toArray(){const e=[];for(const t of this)e.push(t);return e}resize(e){if(1>e)throw Error("RingBuffer capacity must be at least 1");const t=this.toArray(),n=[];for(;t.length>e;)n.push(t.shift());this._capacity=e,this.buffer=Array(e),this.head=0,this._size=0;for(const e of t)this.push(e);return n}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}}class re{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(e){Number.isNaN(e)||(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}evict(e){e!==this._min&&e!==this._max||(this._dirty=!0)}recalculate(e,t){this._min=1/0,this._max=-1/0;for(const n of e){const e=t?t(n):n;Number.isNaN(e)||(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}this._dirty=!1}clear(){this._min=1/0,this._max=-1/0,this._dirty=!1}get extent(){return[this._min,this._max]}get min(){return this._min}get max(){return this._max}get dirty(){return this._dirty}}function ie(e,t,n,o,r){const i=new Map;for(const a of e){const e=t(a),s=n(a);if(null==e||null==s||Number.isNaN(e)||Number.isNaN(s))continue;const l=Math.floor(e/o)*o;let c=i.get(l);if(c||(c={start:l,end:l+o,total:0,categories:new Map},i.set(l,c)),c.total+=s,r){const e=r(a);c.categories.set(e,(c.categories.get(e)||0)+s)}}return i}function ae(e,t,n,o,r,i){const a=[],s=[];for(const r of e){const e=n(r),i=o(r);null==e||null==i||Number.isNaN(e)||Number.isNaN(i)||(a.push([t.x(e),t.y(i)]),s.push(i))}return{type:"line",path:a,rawValues:s,style:r,datum:e,group:i}}function se(e,t,n,o,r,i,a,s){const l=[],c=[];for(const i of e){const e=n(i),a=o(i);if(null==e||null==a||Number.isNaN(e)||Number.isNaN(a))continue;const u=t.x(e);l.push([u,t.y(a)]);const d=s?s(i):r;c.push([u,t.y(d)])}return{type:"area",topPath:l,bottomPath:c,style:i,datum:e,group:a}}function le(e,t,n,o,r,i,a){const s=n(e),l=o(e);if(null==s||null==l||Number.isNaN(s)||Number.isNaN(l))return null;const c={type:"point",x:t.x(s),y:t.y(l),r:r,style:i,datum:e};return void 0!==a&&(c.pointId=a),c}function ce(e,t,n,o,r,i,a){return{type:"rect",x:e,y:t,w:n,h:o,style:r,datum:i,group:a}}function ue(e,t,n,o,r,i){return{type:"heatcell",x:e,y:t,w:n,h:o,fill:r,datum:i}}function de(e,t){if("function"==typeof e)return t=>+e(t);const n=e||t;return e=>+e[n]}function he(e,t){return"function"==typeof e?e:e?t=>t[e]+"":t?e=>e[t]+"":void 0}class ge{constructor(e){this.xExtent=new re,this.yExtent=new re,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.lastIngestTime=0,this.scales=null,this.scene=[],this.version=0,this.config=e,this.buffer=new oe(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=de(e.timeAccessor||e.xAccessor,"time"),this.getY=de(e.valueAccessor||e.yAccessor,"value")):(this.getX=de(e.xAccessor,"x"),this.getY=de(e.yAccessor,"y")),this.getGroup=he(e.groupAccessor),this.getCategory=he(e.categoryAccessor),this.getSize=e.sizeAccessor?de(e.sizeAccessor,"size"):void 0,this.getColor=he(e.colorAccessor),this.getBounds=e.boundsAccessor?de(e.boundsAccessor,"bounds"):void 0,this.getY0=e.y0Accessor?de(e.y0Accessor,"y0"):void 0,this.getPointId=he(e.pointIdAccessor),"candlestick"===e.chartType&&(this.getOpen=de(e.openAccessor,"open"),this.getHigh=de(e.highAccessor,"high"),this.getLow=de(e.lowAccessor,"low"),this.getClose=de(e.closeAccessor,"close")),e.pulse&&(this.timestampBuffer=new oe(e.windowSize))}ingest(e){const t="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=t,e.bounded){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const n=e.totalSize||e.inserts.length;n>this.buffer.capacity&&(this.buffer.resize(n),this.timestampBuffer&&n>this.timestampBuffer.capacity&&this.timestampBuffer.resize(n));for(const n of e.inserts)this.buffer.push(n),this.timestampBuffer&&this.timestampBuffer.push(t),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):(this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n)))}else for(const n of e.inserts){"growing"===this.config.windowMode&&this.buffer.full&&(this.growingCap*=2,this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap));const e=this.buffer.push(n);this.timestampBuffer&&this.timestampBuffer.push(t),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):(this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n))),null!=e&&(this.xExtent.evict(this.getX(e)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(e)),this.yExtent.evict(this.getLow(e))):this.yExtent.evict(this.getY(e)))}return!0}computeScene(e){var t,n,o,r,i,a;const{config:s,buffer:l}=this;if(this.xExtent.dirty&&this.xExtent.recalculate(l,this.getX),this.yExtent.dirty)if("candlestick"===s.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const e of l)this.yExtent.push(this.getHigh(e)),this.yExtent.push(this.getLow(e))}else this.yExtent.recalculate(l,this.getY);const c=this.xExtent.extent,u=this.yExtent.extent;let d=s.xExtent?[null!==(t=s.xExtent[0])&&void 0!==t?t:c[0],null!==(n=s.xExtent[1])&&void 0!==n?n:c[1]]:c,h=s.yExtent?[null!==(o=s.yExtent[0])&&void 0!==o?o:u[0],null!==(r=s.yExtent[1])&&void 0!==r?r:u[1]]:u;const g=s.yExtent&&null!=s.yExtent[0]&&null!=s.yExtent[1];if("stackedarea"===s.chartType&&!g&&l.size>0)if(s.normalize)h=[0,1+s.extentPadding];else{const e=l.toArray(),t=this.groupData(e),n=new Map;for(const e of t)for(const t of e.data){const e=this.getX(t),o=this.getY(t);null==e||null==o||Number.isNaN(e)||Number.isNaN(o)||n.set(e,(n.get(e)||0)+o)}let o=0;for(const e of n.values())e>o&&(o=e);h=[0,o+(o>0?o*s.extentPadding:1)]}else if("bar"===s.chartType&&s.binSize&&!g&&l.size>0){const[,e]=function(e,t,n,o,r){const i=ie(e,t,n,o,r);if(0===i.size)return[0,0];let a=0;for(const e of i.values())e.total>a&&(a=e.total);return[0,a]}(l,this.getX,this.getY,s.binSize,this.getCategory);h=[0,e+e*s.extentPadding]}else if("waterfall"===s.chartType&&!g&&l.size>0){const[e,t]=function(e,t){let n=0,o=0,r=0;for(const i of e){const e=t(i);null==e||Number.isNaN(e)||(r+=e,n>r&&(n=r),r>o&&(o=r))}return[n,o]}(l,this.getY),n=t-e,o=n>0?n*s.extentPadding:1;h=[Math.min(0,e-Math.abs(o)),Math.max(0,t+Math.abs(o))]}else if(!g&&h[0]!==1/0){if(this.getBounds){const e=l.toArray();for(const t of e){const e=this.getY(t),n=this.getBounds(t);null!=e&&!Number.isNaN(e)&&n&&(e+n>h[1]&&(h[1]=e+n),h[0]>e-n&&(h[0]=e-n))}}const e=h[1]-h[0],t=e>0?e*s.extentPadding:1,n=null===(i=s.yExtent)||void 0===i?void 0:i[0],o=null===(a=s.yExtent)||void 0===a?void 0:a[1];h=[null!=n?h[0]:h[0]-t,null!=o?h[1]:h[1]+t]}if(d[0]!==1/0&&d[1]!==-1/0||(d=[0,1]),h[0]!==1/0&&h[1]!==-1/0||(h=[0,1]),void 0!==s.arrowOfTime)if("x"==("up"===(p=s.arrowOfTime)||"down"===p?"y":"x")){const t="right"===s.arrowOfTime?[0,e.width]:[e.width,0];this.scales={x:f().domain(d).range(t),y:f().domain(h).range([e.height,0])}}else{const t="down"===s.arrowOfTime?[0,e.height]:[e.height,0];this.scales={x:f().domain(h).range([0,e.width]),y:f().domain(d).range(t)}}else this.scales={x:f().domain(d).range([0,e.width]),y:f().domain(h).range([e.height,0])};var p;this.config.transition&&this.scene.length>0&&this.snapshotPositions();const y=l.toArray();this.scene=this.buildSceneNodes(e),this.config.decay&&this.applyDecay(this.scene,y),this.config.pulse&&this.applyPulse(this.scene,y),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++}buildSceneNodes(e){const{config:t,buffer:n,scales:o}=this;if(!o||0===n.size)return[];const r=n.toArray();switch(t.chartType){case"line":return this.buildLineScene(r);case"area":return this.buildAreaScene(r);case"stackedarea":return this.buildStackedAreaScene(r);case"scatter":case"bubble":return this.buildPointScene(r);case"heatmap":return this.buildHeatmapScene(r,e);case"bar":return this.buildBarScene(r);case"swarm":return this.buildSwarmScene(r);case"waterfall":return this.buildWaterfallScene(r,e);case"candlestick":return this.buildCandlestickScene(r,e);default:return[]}}buildLineScene(e){var t;const n=this.groupData(e),o=[],r=null===(t=this.config.annotations)||void 0===t?void 0:t.filter(e=>"threshold"===e.type&&e.color).map(e=>({value:e.value,color:e.color,thresholdType:e.thresholdType||"greater"}));if(this.getBounds)for(const e of n){const t=this.buildBoundsForGroup(e.data,e.key);t&&o.push(t)}for(const e of n){const t=this.resolveLineStyle(e.key,e.data[0]),n=ae(e.data,this.scales,this.getX,this.getY,t,e.key);r&&r.length>0&&(n.colorThresholds=r),o.push(n)}return o}buildAreaScene(e){const t=this.groupData(e),n=[],o=this.scales.y.domain()[0];for(const e of t){const t=this.resolveAreaStyle(e.key,e.data[0]),r=se(e.data,this.scales,this.getX,this.getY,o,t,e.key,this.getY0);this.config.gradientFill&&(r.fillGradient=this.config.gradientFill),n.push(r)}return n}buildStackedAreaScene(e){const t=this.groupData(e);return t.sort((e,t)=>t.key>e.key?-1:e.key>t.key?1:0),function(e,t,n,o,r,i){var a;const s=new Set;for(const t of e)for(const e of t.data){const t=n(e);null==t||Number.isNaN(t)||s.add(t)}const l=Array.from(s).sort((e,t)=>e-t),c=new Map;for(const t of e){const e=new Map;for(const r of t.data){const t=n(r),i=o(r);null==t||null==i||Number.isNaN(t)||Number.isNaN(i)||e.set(t,(e.get(t)||0)+i)}c.set(t.key,e)}let u;if(i){u=new Map;for(const t of l){let n=0;for(const o of e)n+=(null===(a=c.get(o.key))||void 0===a?void 0:a.get(t))||0;u.set(t,n||1)}}const d=[],h=new Map;for(const e of l)h.set(e,0);for(const n of e){const e=c.get(n.key),o=[],a=[];for(const n of l){let r=e.get(n)||0;const s=h.get(n);i&&(r/=u.get(n));const l=t.x(n);a.push([l,t.y(s)]),o.push([l,t.y(s+r)]),h.set(n,s+r)}d.push({type:"area",topPath:o,bottomPath:a,style:r(n.key,n.data[0]),datum:n.data,group:n.key})}return d}(t,this.scales,this.getX,this.getY,(e,t)=>this.resolveAreaStyle(e,t),this.config.normalize)}buildPointScene(e){const t=[],n="bubble"===this.config.chartType?10:5,o=this.config.sizeRange||[3,15];let r=null;if(this.getSize&&!this.config.pointStyle){const t=e.map(e=>this.getSize(e)).filter(e=>null!=e&&!Number.isNaN(e));if(t.length>0){const e=Math.min(...t),n=Math.max(...t);r=t=>e===n?(o[0]+o[1])/2:o[0]+(t-e)/(n-e)*(o[1]-o[0])}}let i=null;if(this.getColor&&!this.config.pointStyle){const t=new Set;for(const n of e){const e=this.getColor(n);e&&t.add(e)}const n=Array.isArray(this.config.colorScheme)?this.config.colorScheme:["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];i=new Map;let o=0;for(const e of t)i.set(e,n[o%n.length]),o++}for(const o of e){let e=this.config.pointStyle?this.config.pointStyle(o):{fill:"#4e79a7",opacity:.8},a=e.r||n;if(r&&this.getSize){const e=this.getSize(o);null==e||Number.isNaN(e)||(a=r(e))}if(i&&this.getColor){const t=this.getColor(o);t&&i.has(t)&&(e=Object.assign(Object.assign({},e),{fill:i.get(t)}))}const s=this.getPointId?this.getPointId(o)+"":void 0,l=le(o,this.scales,this.getX,this.getY,a,e,s);l&&t.push(l)}return t}buildHeatmapScene(e,t){const n=[];if(this.config.heatmapAggregation)return this.buildStreamingHeatmapScene(e,t);const o=de(this.config.valueAccessor,"value"),r=new Set,i=new Set;for(const t of e)r.add(this.getX(t)),i.add(this.getY(t));const a=Array.from(r).sort((e,t)=>e-t),s=Array.from(i).sort((e,t)=>e-t);if(0===a.length||0===s.length)return n;const l=t.width/a.length,c=t.height/s.length,u=new Map;for(const t of e){const e=`${this.getX(t)}_${this.getY(t)}`;u.set(e,{val:o(t),datum:t})}let d=1/0,h=-1/0;for(const{val:e}of u.values())d>e&&(d=e),e>h&&(h=e);const g=h-d||1;for(let e=0;a.length>e;e++)for(let t=0;s.length>t;t++){const o=u.get(`${a[e]}_${s[t]}`);if(!o)continue;const r=(o.val-d)/g;n.push(ue(e*l,(s.length-1-t)*c,l,c,`rgb(${Math.round(220-180*r)},${Math.round(220-100*r)},${Math.round(255-50*r)})`,o.datum))}return n}buildStreamingHeatmapScene(e,t){var n,o,r;const i=[],a=null!==(n=this.config.heatmapXBins)&&void 0!==n?n:20,s=null!==(o=this.config.heatmapYBins)&&void 0!==o?o:20,l=null!==(r=this.config.heatmapAggregation)&&void 0!==r?r:"count",c=de(this.config.valueAccessor,"value");if(!this.scales||0===e.length)return i;const[u,d]=this.scales.x.domain(),[h,g]=this.scales.y.domain(),p=(d-u||1)/a,y=(g-h||1)/s,f=new Map;for(const t of e){const e=this.getX(t),n=this.getY(t),o=Math.min(Math.floor((e-u)/p),a-1),r=Math.min(Math.floor((n-h)/y),s-1);if(0>o||0>r)continue;const i=`${o}_${r}`;let l=f.get(i);l||(l={sum:0,count:0,data:[]},f.set(i,l)),l.count++,l.sum+=c(t),l.data.push(t)}let m=1/0,v=-1/0;const b=new Map;for(const[e,t]of f){let n;switch(l){case"sum":n=t.sum;break;case"mean":n=t.count>0?t.sum/t.count:0;break;default:n=t.count}b.set(e,n),m>n&&(m=n),n>v&&(v=n)}const x=v-m||1,w=t.width/a,k=t.height/s;for(const[e,t]of b){const[n,o]=e.split("_"),r=+n,a=+o,l=(t-m)/x,c=`rgb(${Math.round(220-180*l)},${Math.round(220-100*l)},${Math.round(255-50*l)})`,u=f.get(e);i.push(ue(r*w,(s-1-a)*k,w,k,c,{xi:r,yi:a,value:t,count:u.count,sum:u.sum,data:u.data}))}return i}buildBarScene(e){var t;if(!this.config.binSize)return[];const n=ie(e,this.getX,this.getY,this.config.binSize,this.getCategory);if(0===n.size)return[];let o=null;if(this.getCategory){const e=new Set;for(const t of n.values())for(const n of t.categories.keys())e.add(n);const t=this.config.barColors?Object.keys(this.config.barColors):[],r=new Set(t),i=Array.from(e).filter(e=>!r.has(e)).sort();o=[...t.filter(t=>e.has(t)),...i]}const r=[],i=this.scales,[a,s]=i.x.domain();for(const e of n.values()){const n=Math.max(e.start,a),l=Math.min(e.end,s);if(n>=l)continue;const c=i.x(n),u=i.x(l),d=Math.min(c,u)+.5,h=Math.max(c,u)-.5-d;if(h>0)if(o&&e.categories.size>0){let n=0;for(const a of o){const o=e.categories.get(a)||0;if(0===o)continue;const s=i.y(n),l=i.y(n+o);r.push(ce(d,Math.min(s,l),h,Math.abs(s-l),{fill:(null===(t=this.config.barColors)||void 0===t?void 0:t[a])||"#4e79a7"},{binStart:e.start,binEnd:e.end,total:e.total,category:a,categoryValue:o},a)),n+=o}}else{const t=i.y(0),n=i.y(e.total);r.push(ce(d,Math.min(t,n),h,Math.abs(t-n),{fill:"#007bff"},{binStart:e.start,binEnd:e.end,total:e.total}))}}return r}buildSwarmScene(e){var t,n,o,r;const i=[],a=this.config.swarmStyle||{},s=null!==(t=a.radius)&&void 0!==t?t:3,l=null!==(n=a.fill)&&void 0!==n?n:"#007bff",c=null!==(o=a.opacity)&&void 0!==o?o:.7,u=a.stroke,d=a.strokeWidth;for(const t of e){const e=this.getX(t),n=this.getY(t);if(null==n||Number.isNaN(n))continue;const o=this.scales.x(e),a=this.scales.y(n);let h=l;if(this.getCategory){const e=this.getCategory(t);h=(null===(r=this.config.barColors)||void 0===r?void 0:r[e])||h}const g={type:"point",x:o,y:a,r:s,style:{fill:h,opacity:c,stroke:u,strokeWidth:d},datum:t};this.getPointId&&(g.pointId=this.getPointId(t)+""),i.push(g)}return i}buildWaterfallScene(e,t){var n,o,r;const i=[],a=this.scales,s=this.config.waterfallStyle,l=e.filter(e=>{const t=this.getY(e);return null!=t&&!Number.isNaN(t)});if(0===l.length)return i;const c=null!==(n=null==s?void 0:s.positiveColor)&&void 0!==n?n:"#28a745",u=null!==(o=null==s?void 0:s.negativeColor)&&void 0!==o?o:"#dc3545",d=null!==(r=null==s?void 0:s.gap)&&void 0!==r?r:1,h=null==s?void 0:s.stroke,g=null==s?void 0:s.strokeWidth;let p=0;for(let e=0;l.length>e;e++){const n=l[e],o=this.getX(n),r=this.getY(n),y=p+r;let f;f=l.length-1>e?this.getX(l[e+1])-o:e>0?o-this.getX(l[e-1]):0;const m=a.x(o),v=0!==f?a.x(o+f):m+t.width/10,b=Math.min(m,v)+d/2,x=Math.max(m,v)-d/2-b;if(0>=x){p=y;continue}const w=a.y(p),k=a.y(y);i.push(ce(b,Math.min(w,k),x,Math.abs(w-k),{fill:0>r?u:c,stroke:h,strokeWidth:g},Object.assign(Object.assign({},n),{baseline:p,cumEnd:y,delta:r,_connectorStroke:null==s?void 0:s.connectorStroke,_connectorWidth:null==s?void 0:s.connectorWidth}))),p=y}return i}buildCandlestickScene(e,t){if(!(this.getOpen&&this.getHigh&&this.getLow&&this.getClose&&this.scales))return[];const n=[],o=this.config.candlestickStyle||{},r=o.upColor||"#28a745",i=o.downColor||"#dc3545",a=o.wickColor||"#333",s=o.wickWidth||1,l=e.map(e=>this.getX(e)).filter(e=>null!=e&&!Number.isNaN(e)).sort((e,t)=>e-t);let c=o.bodyWidth||6;if(!o.bodyWidth&&l.length>1){let e=1/0;for(let t=1;l.length>t;t++){const n=Math.abs(this.scales.x(l[t])-this.scales.x(l[t-1]));n>0&&e>n&&(e=n)}e!==1/0&&(c=Math.max(2,Math.min(.6*e,20)))}for(const t of e){const e=this.getX(t);if(null==e||Number.isNaN(e))continue;const o=this.getOpen(t),l=this.getHigh(t),u=this.getLow(t),d=this.getClose(t);if([o,l,u,d].some(e=>null==e||Number.isNaN(e)))continue;const h=d>=o;n.push({type:"candlestick",x:this.scales.x(e),openY:this.scales.y(o),closeY:this.scales.y(d),highY:this.scales.y(l),lowY:this.scales.y(u),bodyWidth:c,upColor:r,downColor:i,wickColor:a,wickWidth:s,isUp:h,datum:t})}return n}buildBoundsForGroup(e,t){if(!this.getBounds||!this.scales)return null;const n=[],o=[];for(const t of e){const e=this.getX(t),r=this.getY(t);if(null==e||null==r||Number.isNaN(e)||Number.isNaN(r))continue;const i=this.getBounds(t),a=this.scales.x(e);if(i&&0!==i)n.push([a,this.scales.y(r+i)]),o.push([a,this.scales.y(r-i)]);else{const e=this.scales.y(r);n.push([a,e]),o.push([a,e])}}return 2>n.length?null:{type:"area",topPath:n,bottomPath:o,style:this.resolveBoundsStyle(t,e[0]),datum:e,group:t,interactive:!1}}resolveBoundsStyle(e,t){const n=this.config.boundsStyle;return"function"==typeof n?n(t||{},e):n&&"object"==typeof n?n:{fill:this.resolveLineStyle(e,t).stroke||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(e,t){var n,o,r;const i=this.config.decay;if(!i||1>=t)return 1;const a=null!==(n=i.minOpacity)&&void 0!==n?n:.1,s=t-1-e;switch(i.type){case"linear":return a+(1-s/(t-1))*(1-a);case"exponential":{const e=null!==(o=i.halfLife)&&void 0!==o?o:t/2;return a+Math.pow(.5,s/e)*(1-a)}case"step":return(null!==(r=i.stepThreshold)&&void 0!==r?r:.5*t)>s?1:a;default:return 1}}applyDecay(e,t){var n,o;if(!this.config.decay)return;const r=t.length;if(1>=r)return;const i=new Map;for(let e=0;t.length>e;e++)i.set(t[e],e);for(const t of e){if("line"===t.type||"area"===t.type)continue;const e=i.get(t.datum);if(null==e)continue;const a=this.computeDecayOpacity(e,r);if("heatcell"===t.type)t.style={opacity:a};else if("candlestick"===t.type)t._decayOpacity=a;else{const e=null!==(o=null===(n=t.style)||void 0===n?void 0:n.opacity)&&void 0!==o?o:1;t.style=Object.assign(Object.assign({},t.style),{opacity:e*a})}}}computePulseIntensity(e,t){var n;const o=this.config.pulse;if(!o)return 0;const r=null!==(n=o.duration)&&void 0!==n?n:500,i=t-e;return r>i?1-i/r:0}applyPulse(e,t){var n,o;if(!this.config.pulse||!this.timestampBuffer)return;const r="undefined"!=typeof performance?performance.now():Date.now(),i=null!==(n=this.config.pulse.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",a=null!==(o=this.config.pulse.glowRadius)&&void 0!==o?o:4,s=new Map;for(let e=0;t.length>e;e++)s.set(t[e],e);for(const t of e){if("line"===t.type||"area"===t.type)continue;const e=s.get(t.datum);if(null==e)continue;const n=this.timestampBuffer.get(e);if(null==n)continue;const o=this.computePulseIntensity(n,r);o>0&&(t._pulseIntensity=o,t._pulseColor=i,t._pulseGlowRadius=a)}}get hasActivePulses(){var e;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const t="undefined"!=typeof performance?performance.now():Date.now(),n=null!==(e=this.config.pulse.duration)&&void 0!==e?e:500,o=this.timestampBuffer.peek();return null!=o&&n>t-o}snapshotPositions(){this.prevPositionMap.clear();for(let e=0;this.scene.length>e;e++){const t=this.scene[e],n=this.getNodeIdentity(t,e);n&&("point"===t.type?this.prevPositionMap.set(n,{x:t.x,y:t.y,r:t.r}):"rect"===t.type||"heatcell"===t.type?this.prevPositionMap.set(n,{x:t.x,y:t.y,w:t.w,h:t.h}):"candlestick"===t.type&&this.prevPositionMap.set(n,{x:t.x,y:t.openY}))}}getNodeIdentity(e,t){var n,o,r,i;switch(e.type){case"point":return`p:${void 0===e.datum?t:this.getX(e.datum)}_${this.getY(e.datum)}`;case"rect":return`r:${e.group||""}:${null!==(i=null!==(o=null===(n=e.datum)||void 0===n?void 0:n.binStart)&&void 0!==o?o:null===(r=e.datum)||void 0===r?void 0:r.category)&&void 0!==i?i:t}`;case"heatcell":return`h:${e.x}_${e.y}`;case"candlestick":return"c:"+this.getX(e.datum);default:return null}}startTransition(){var e,t,n,o,r,i;if(!this.config.transition||0===this.prevPositionMap.size)return;const a=null!==(e=this.config.transition.duration)&&void 0!==e?e:300;let s=!1;for(let e=0;this.scene.length>e;e++){const a=this.scene[e],l=this.getNodeIdentity(a,e);if(!l)continue;const c=this.prevPositionMap.get(l);if(c)if("point"===a.type){const e={x:a.x,y:a.y,r:a.r};c.x===e.x&&c.y===e.y||(a._targetX=e.x,a._targetY=e.y,a._targetR=e.r,a.x=c.x,a.y=c.y,a.r=null!==(t=c.r)&&void 0!==t?t:a.r,s=!0)}else if("rect"===a.type){const e={x:a.x,y:a.y,w:a.w,h:a.h};c.x===e.x&&c.y===e.y&&c.w===e.w&&c.h===e.h||(a._targetX=e.x,a._targetY=e.y,a._targetW=e.w,a._targetH=e.h,a.x=c.x,a.y=c.y,a.w=null!==(n=c.w)&&void 0!==n?n:a.w,a.h=null!==(o=c.h)&&void 0!==o?o:a.h,s=!0)}else if("heatcell"===a.type){const e={x:a.x,y:a.y,w:a.w,h:a.h};c.x===e.x&&c.y===e.y||(a._targetX=e.x,a._targetY=e.y,a._targetW=e.w,a._targetH=e.h,a.x=c.x,a.y=c.y,a.w=null!==(r=c.w)&&void 0!==r?r:a.w,a.h=null!==(i=c.h)&&void 0!==i?i:a.h,s=!0)}}s&&(this.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:a})}advanceTransition(e){var t;if(!this.activeTransition)return!1;const n=Math.min((e-this.activeTransition.startTime)/this.activeTransition.duration,1),o="linear"===(null===(t=this.config.transition)||void 0===t?void 0:t.easing)?n:1-Math.pow(1-n,3);for(const e of this.scene)if("point"===e.type){if(void 0===e._targetX)continue;const t=this.getNodeIdentity(e,0);if(!t)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=n.x+(e._targetX-n.x)*o,e.y=n.y+(e._targetY-n.y)*o,void 0!==e._targetR&&void 0!==n.r&&(e.r=n.r+(e._targetR-n.r)*o)}else if("rect"===e.type){if(void 0===e._targetX)continue;const t=this.getNodeIdentity(e,0);if(!t)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=n.x+(e._targetX-n.x)*o,e.y=n.y+(e._targetY-n.y)*o,void 0!==n.w&&(e.w=n.w+(e._targetW-n.w)*o),void 0!==n.h&&(e.h=n.h+(e._targetH-n.h)*o)}else if("heatcell"===e.type){if(void 0===e._targetX)continue;const t=this.getNodeIdentity(e,0);if(!t)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=n.x+(e._targetX-n.x)*o,e.y=n.y+(e._targetY-n.y)*o,void 0!==n.w&&(e.w=n.w+(e._targetW-n.w)*o),void 0!==n.h&&(e.h=n.h+(e._targetH-n.h)*o)}if(n>=1){for(const e of this.scene)if("point"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,void 0!==e._targetR&&(e.r=e._targetR),e._targetX=void 0,e._targetY=void 0,e._targetR=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("heatcell"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}return this.activeTransition=null,!1}return!0}groupData(e){if(!this.getGroup)return[{key:"_default",data:e}];const t=new Map;for(const n of e){const e=this.getGroup(n);t.has(e)||t.set(e,[]),t.get(e).push(n)}return Array.from(t.entries()).map(([e,t])=>({key:e,data:t}))}resolveLineStyle(e,t){const n=this.config.lineStyle;return"function"==typeof n?n(t||{},e):n&&"object"==typeof n?{stroke:n.stroke||"#007bff",strokeWidth:n.strokeWidth||2,strokeDasharray:n.strokeDasharray,fill:n.fill,fillOpacity:n.fillOpacity,opacity:n.opacity}:{stroke:"#007bff",strokeWidth:2}}resolveAreaStyle(e,t){var n;if(this.config.areaStyle)return this.config.areaStyle(t||{});const o=this.config.lineStyle;return"function"==typeof o?o(t||{},e):o&&"object"==typeof o?{fill:o.fill||o.stroke||"#4e79a7",fillOpacity:null!==(n=o.fillOpacity)&&void 0!==n?n:.7,stroke:o.stroke||"#4e79a7",strokeWidth:o.strokeWidth||2}:{fill:"#4e79a7",fillOpacity:.7,stroke:"#4e79a7",strokeWidth:2}}getData(){return this.buffer.toArray()}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],this.version++}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}updateConfig(e){Object.assign(this.config,e)}}function pe(e,t,n){const o=t-e.x,r=n-e.y,i=Math.sqrt(o*o+r*r);return i>e.r+5?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:i}}function ye(e,t,n){if(0===e.path.length)return null;const o=xe(e.path,t);if(0>o)return null;const[r,i]=e.path[o],a=t-r,s=n-i,l=Math.sqrt(a*a+s*s);return{node:e,datum:Array.isArray(e.datum)&&e.datum[o]?e.datum[o]:e.datum,x:r,y:i,distance:l}}function fe(e,t,n){return e.x>t||t>e.x+e.w||e.y>n||n>e.y+e.h?null:{node:e,datum:e.datum,x:e.x+e.w/2,y:e.y+e.h/2,distance:0}}function me(e,t,n){return e.x>t||t>e.x+e.w||e.y>n||n>e.y+e.h?null:{node:e,datum:e.datum,x:e.x+e.w/2,y:e.y+e.h/2,distance:0}}function ve(e,t,n){const o=e.bodyWidth/2,r=Math.min(e.openY,e.closeY);if(!(e.x-o-3>t||t>e.x+o+3||e.highY-3>n||n>e.lowY+3)){const o=r+Math.max(Math.max(e.openY,e.closeY)-r,1)/2,i=t-e.x,a=n-o;return{node:e,datum:e.datum,x:e.x,y:o,distance:Math.sqrt(i*i+a*a)}}return null}function be(e,t,n){if(0===e.topPath.length)return null;const o=xe(e.topPath,t);if(0>o)return null;const[r,i]=e.topPath[o],a=t-r,s=n-i;return{node:e,datum:e.datum,x:r,y:i,distance:Math.sqrt(a*a+s*s)}}function xe(e,t){if(0===e.length)return-1;let n=0,o=e.length-1;for(;o>n;){const r=n+o>>1;t>e[r][0]?n=r+1:o=r}return n>0&&Math.abs(e[n][0]-t)>=Math.abs(e[n-1][0]-t)?n-1:n}function we(e,t,n){switch(e){case"ArrowRight":case"ArrowDown":return n-1>t?t+1:t;case"ArrowLeft":case"ArrowUp":return t>0?t-1:t;case"Home":return 0;case"End":return n-1;case"Escape":return-1;default:return null}}function ke(e){return{data:e.datum,x:e.x,y:e.y,time:e.x,value:e.y}}function Ae(e,r,i){const a=t(null),[s,l]=n(null);return o(()=>{if(!r&&!i)return;const e=a.current;if(!e)return;const t=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;l(t=>t&&t.w===e&&t.h===n?t:{w:e,h:n})}});return t.observe(e),()=>t.disconnect()},[r,i]),[a,[r&&s?s.w:e[0],i&&s?s.h:e[1]]]}const Ee={fill:t=>e.createElement("rect",{style:t,width:20,height:20}),line:t=>e.createElement("line",{style:t,x1:0,y1:0,x2:20,y2:20})};function Se(e,t,n,o){let r;return r="function"==typeof n?n(e):(0,Ee[n])(o(e,t)),r}function Oe(t){const{legendGroups:n,customClickBehavior:o,title:r="Legend",width:i=100,height:a=20,orientation:s="vertical"}=t,l="vertical"===s?(({legendGroups:t,width:n,customClickBehavior:o})=>{let r=30;const i=[];return t.forEach((t,a)=>{r+=5,i.push(e.createElement("line",{key:"legend-top-line legend-symbol-"+a,stroke:"gray",x1:0,y1:r,x2:n,y2:r})),r+=10,t.label&&(r+=20,i.push(e.createElement("text",{key:"legend-text-"+a,y:r,className:"legend-group-label"},t.label)),r+=10),i.push(e.createElement("g",{key:"legend-group-"+a,className:"legend-item",transform:`translate(0,${r})`},((t,n)=>{const{type:o="fill",styleFn:r,items:i}=t,a=[];let s=0;return i.forEach((t,i)=>{const l=Se(t,i,o,r);a.push(e.createElement("g",{key:"legend-item-"+i,transform:`translate(0,${s})`,onClick:n?()=>n(t):void 0,style:{cursor:n?"pointer":"default"}},l,e.createElement("text",{y:15,x:30},t.label))),s+=25}),a})(t,o))),r+=25*t.items.length+10}),i})({legendGroups:n,width:i,customClickBehavior:o}):(({legendGroups:t,title:n,height:o,customClickBehavior:r})=>{let i=0;const a=[],s=!1===n?10:40;return t.forEach((n,l)=>{n.label&&(a.push(e.createElement("text",{key:"legend-text-"+l,transform:`translate(${i},${s}) rotate(90)`,textAnchor:"start",className:"legend-group-label"},n.label)),i+=20);const c=((t,n)=>{const{type:o="fill",styleFn:r,items:i}=t,a=[];let s=0;return i.forEach((t,i)=>{const l=Se(t,i,o,r);a.push(e.createElement("g",{key:"legend-item-"+i,transform:`translate(${s},0)`,onClick:n?()=>n(t):void 0,style:{cursor:n?"pointer":"default"}},l,e.createElement("text",{y:15,x:25},t.label))),s+=35,s+=8*t.label.length}),{items:a,offset:s}})(n,r);a.push(e.createElement("g",{key:"legend-group-"+l,className:"legend-item",transform:`translate(${i},${s})`},c.items)),i+=c.offset+5,t[l+1]&&a.push(e.createElement("line",{key:"legend-top-line legend-symbol-"+l,stroke:"gray",x1:i,y1:s-10,x2:i,y2:o+s+10})),i+=15}),e.createElement("g",null,!1!==n&&e.createElement("line",{x1:0,x2:i+10,y1:s-10,y2:s-10,stroke:"gray",className:"title-neatline"}),a)})({legendGroups:n,title:r,height:a,customClickBehavior:o});return e.createElement("g",null,void 0!==r&&e.createElement("text",{className:"legend-title",y:20,x:"horizontal"===s?0:i/2,textAnchor:"horizontal"===s?"start":"middle"},r),l)}function Le(e){return"string"==typeof e?{type:e}:e}function je({orient:t,config:n,values:o,scale:i,size:a,length:s}){const l=function(e){var t,n,o,r,i;return{type:e.type,bins:null!==(t=e.bins)&&void 0!==t?t:20,fill:null!==(n=e.fill)&&void 0!==n?n:"#4e79a7",fillOpacity:null!==(o=e.fillOpacity)&&void 0!==o?o:.5,stroke:null!==(r=e.stroke)&&void 0!==r?r:"none",strokeWidth:null!==(i=e.strokeWidth)&&void 0!==i?i:1}}(n),c="top"===t||"bottom"===t,u=r(()=>{if(0===o.length)return null;const n=i.domain(),r=a-8;if("boxplot"===l.type){const n=function(e){const t=[...e].sort((e,t)=>e-t),n=t.length;if(0===n)return null;const o=t[Math.floor(.25*n)],r=t[Math.floor(.5*n)],i=t[Math.floor(.75*n)],a=i-o;return{q1:o,median:r,q3:i,whiskerLow:Math.max(t[0],o-1.5*a),whiskerHigh:Math.min(t[n-1],i+1.5*a)}}(o);if(!n)return null;const{q1:a,median:s,q3:u,whiskerLow:d,whiskerHigh:h}=n,g=Math.min(.5*r,20),p=(r-g)/2+4;if(c){const n=i(a),o=i(u),r=i(s),c=i(d),y=i(h),f="top"===t?-1:1,m=0;return e.createElement("g",{"data-testid":"marginal-boxplot-"+t},e.createElement("line",{x1:c,y1:m+f*(p+g/2),x2:y,y2:m+f*(p+g/2),stroke:l.fill,strokeWidth:l.strokeWidth}),e.createElement("line",{x1:c,y1:m+f*p,x2:c,y2:m+f*(p+g),stroke:l.fill,strokeWidth:l.strokeWidth}),e.createElement("line",{x1:y,y1:m+f*p,x2:y,y2:m+f*(p+g),stroke:l.fill,strokeWidth:l.strokeWidth}),e.createElement("rect",{x:Math.min(n,o),y:"top"===t?m-p-g:m+p,width:Math.abs(o-n),height:g,fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}),e.createElement("line",{x1:r,y1:"top"===t?m-p-g:m+p,x2:r,y2:"top"===t?m-p:m+p+g,stroke:l.fill,strokeWidth:2}))}{const n=i(a),o=i(u),r=i(s),c=i(d),y=i(h),f="left"===t?-1:1,m=0;return e.createElement("g",{"data-testid":"marginal-boxplot-"+t},e.createElement("line",{x1:m+f*(p+g/2),y1:c,x2:m+f*(p+g/2),y2:y,stroke:l.fill,strokeWidth:l.strokeWidth}),e.createElement("line",{x1:m+f*p,y1:c,x2:m+f*(p+g),y2:c,stroke:l.fill,strokeWidth:l.strokeWidth}),e.createElement("line",{x1:m+f*p,y1:y,x2:m+f*(p+g),y2:y,stroke:l.fill,strokeWidth:l.strokeWidth}),e.createElement("rect",{x:"left"===t?m-p-g:m+p,y:Math.min(n,o),width:g,height:Math.abs(o-n),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}),e.createElement("line",{x1:"left"===t?m-p-g:m+p,y1:r,x2:"left"===t?m-p:m+p+g,y2:r,stroke:l.fill,strokeWidth:2}))}}const u=x().domain(n).thresholds(l.bins)(o);if(0===u.length)return null;const d=Math.max(...u.map(e=>e.length));if(0===d)return null;if("histogram"===l.type)return e.createElement("g",{"data-testid":"marginal-histogram-"+t},u.map((n,o)=>{if(null==n.x0||null==n.x1)return null;const a=n.length/d*r;if(c){const r=i(n.x0),s=i(n.x1)-i(n.x0);return e.createElement("rect",{key:o,x:r,y:"top"===t?-4-a:4,width:Math.max(s,.5),height:a,fill:l.fill,fillOpacity:l.fillOpacity,stroke:l.stroke,strokeWidth:l.strokeWidth})}{const r=i(n.x0),s=i(n.x1)-i(n.x0);return e.createElement("rect",{key:o,x:"left"===t?-4-a:4,y:Math.min(r,r+s),width:a,height:Math.abs(s),fill:l.fill,fillOpacity:l.fillOpacity,stroke:l.stroke,strokeWidth:l.strokeWidth})}}));if("violin"===l.type){const n=r/2+4,o=[];for(const e of u){if(null==e.x0||null==e.x1)continue;const a=e.length/d*(r/2),s=i((e.x0+e.x1)/2);o.push(c?`${s},${"top"===t?-(n-a):n-a}`:`${"left"===t?-(n-a):n-a},${s}`)}for(let e=u.length-1;e>=0;e--){const a=u[e];if(null==a.x0||null==a.x1)continue;const s=a.length/d*(r/2),l=i((a.x0+a.x1)/2);o.push(c?`${l},${"top"===t?-(n+s):n+s}`:`${"left"===t?-(n+s):n+s},${l}`)}return e.createElement("g",{"data-testid":"marginal-violin-"+t},e.createElement("polygon",{points:o.join(" "),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}))}if("ridgeline"===l.type){const n=[];if(c){const e=0,o=null!=u[0].x0?i(u[0].x0):0;n.push(`M${o},${e}`);for(const e of u){if(null==e.x0||null==e.x1)continue;const o=e.length/d*r,a=i((e.x0+e.x1)/2);n.push(`L${a},${"top"===t?-o-4:o+4}`)}const a=null!=u[u.length-1].x1?i(u[u.length-1].x1):s;n.push(`L${a},${e}`),n.push("Z")}else{const e=0,o=null!=u[0].x0?i(u[0].x0):0;n.push(`M${e},${o}`);for(const e of u){if(null==e.x0||null==e.x1)continue;const o=e.length/d*r,a=i((e.x0+e.x1)/2);n.push(`L${"left"===t?-o-4:o+4},${a}`)}const a=null!=u[u.length-1].x1?i(u[u.length-1].x1):s;n.push(`L${e},${a}`),n.push("Z")}return e.createElement("g",{"data-testid":"marginal-ridgeline-"+t},e.createElement("path",{d:n.join(" "),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}))}return null},[o,i,l,a,s,t,c,4]);return u?e.createElement("g",{className:"marginal-"+t,"data-testid":"marginal-"+t},u):null}function Pe(e,t=120,n=8){if(!e)return[];const o=Math.max(1,Math.floor(t/n)),r=e.split(/\s+/),i=[];let a="";for(const e of r)a&&a.length+1+e.length>o?(i.push(a),a=e):a=a?`${a} ${e}`:e;return a&&i.push(a),i}function Me(e,t,n,o){return"curly"===e?o?`M0,0 C${.6*n},0 ${.4*n},${t/2} ${n},${t/2} C${.4*n},${t/2} ${.6*n},${t} 0,${t}`:`M0,0 C0,${.6*n} ${t/2},${.4*n} ${t/2},${n} C${t/2},${.4*n} ${t},${.6*n} ${t},0`:o?`M0,0 L${n},0 L${n},${t} L0,${t}`:`M0,0 L0,${n} L${t},${n} L${t},0`}function Ne(t){const{x:n=0,y:o=0,dx:r,dy:i,nx:a,ny:s,note:l,connector:c,subject:u,type:d,color:h,className:g,disable:p,events:y={},"data-testid":f}=t,m=new Set(Array.isArray(p)?p:[]);let v=r||0,b=i||0;null!=a&&(v=a-n),null!=s&&(b=s-o);const x="string"==typeof d?d:"label";if("bracket"===x&&u&&0===v&&0===b)if(void 0!==u.width){v=u.width/2;const e=u.depth||30;b=e+(0>e?-5:5)}else if(void 0!==u.height){const e=u.depth||30;v=e+(0>e?-5:5),b=u.height/2}return e.createElement("g",Object.assign({className:("annotation "+(g||"")).trim(),transform:`translate(${n},${o})`,"data-testid":f},y),!m.has("connector")&&function(t,n,o,r,i,a){const s=[];let l=0,c=0;if("callout-circle"!==i&&"label"!==i||!(null==a?void 0:a.radius)){if("callout-rect"===i&&a){const e=a.width||0,o=a.height||0;if(e>0||o>0){const r=e/2,i=o/2,a=t-r,s=n-i;if(0!==a||0!==s){const t=Math.abs(a),n=Math.abs(s),u=e/2,d=o/2,h=t*d>n*u?u/t:d/n;l=r+a*h,c=i+s*h}}}else if("bracket"===i&&a){const e=a.width,t=a.height,n=a.depth||30;void 0!==e?(l=e/2,c=n):void 0!==t&&(l=n,c=t/2)}}else{const e=(a.radius||0)+(a.radiusPadding||0);if(e>0&&(0!==t||0!==n)){const o=Math.atan2(n,t);l=Math.cos(o)*e,c=Math.sin(o)*e}}if(Math.sqrt(Math.pow(t-l,2)+Math.pow(n-c,2))>.5&&(s.push(e.createElement("line",{key:"connector-line",x1:l,y1:c,x2:t,y2:n,stroke:r||"currentColor"})),"arrow"===(null==o?void 0:o.end))){const o=10,i=16/180*Math.PI,a=Math.atan2(n-c,t-l);s.push(e.createElement("path",{key:"connector-arrow",d:`M${l},${c}L${l+o*Math.cos(a+i)},${c+o*Math.sin(a+i)}L${l+o*Math.cos(a-i)},${c+o*Math.sin(a-i)}Z`,fill:r||"currentColor",stroke:"none"}))}return e.createElement("g",{className:"annotation-connector"},s)}(v,b,c,h,x,u),!m.has("subject")&&function(t,n,o,r,i){var a;const s=[];switch(t){case"callout-circle":{const t=((null==n?void 0:n.radius)||0)+((null==n?void 0:n.radiusPadding)||0);t>0&&s.push(e.createElement("circle",{key:"subject-circle",r:t,fill:"none",stroke:o||"currentColor"}));break}case"callout-rect":{const t=(null==n?void 0:n.width)||0,r=(null==n?void 0:n.height)||0;(t>0||r>0)&&s.push(e.createElement("rect",{key:"subject-rect",width:t,height:r,fill:"none",stroke:o||"currentColor"}));break}case"callout-custom":(null==n?void 0:n.custom)&&s.push(...Array.isArray(n.custom)?n.custom:[n.custom]);break;case"xy-threshold":{const t=r||0,a=i||0;if(void 0!==(null==n?void 0:n.x)){const r=(n.x||0)-t;s.push(e.createElement("line",{key:"threshold-line",x1:r,y1:(n.y1||0)-a,x2:r,y2:(n.y2||0)-a,stroke:o||"currentColor",strokeDasharray:"5,5"}))}else if(void 0!==(null==n?void 0:n.y)){const r=(n.y||0)-a;s.push(e.createElement("line",{key:"threshold-line",x1:(n.x1||0)-t,y1:r,x2:(n.x2||0)-t,y2:r,stroke:o||"currentColor",strokeDasharray:"5,5"}))}else void 0!==(null==n?void 0:n.x1)||void 0!==(null==n?void 0:n.x2)?s.push(e.createElement("line",{key:"threshold-line",x1:(n.x1||0)-t,y1:0,x2:(n.x2||0)-t,y2:0,stroke:o||"currentColor",strokeDasharray:"5,5"})):void 0===(null==n?void 0:n.y1)&&void 0===(null==n?void 0:n.y2)||s.push(e.createElement("line",{key:"threshold-line",x1:0,y1:(n.y1||0)-a,x2:0,y2:(n.y2||0)-a,stroke:o||"currentColor",strokeDasharray:"5,5"}));break}case"bracket":{const t=null!==(a=null==n?void 0:n.width)&&void 0!==a?a:null==n?void 0:n.height;void 0!==t&&s.push(e.createElement("path",{key:"bracket-path",d:Me((null==n?void 0:n.type)||"curly",t,(null==n?void 0:n.depth)||30,void 0===(null==n?void 0:n.width)),fill:"none",stroke:o||"currentColor"}));break}}return e.createElement("g",{className:"annotation-subject"},s)}(x,u,h,n,o),!m.has("note")&&function(t,n,o,r){if(!t)return e.createElement("g",{className:"annotation-note"});const{label:i,title:a,orientation:s,align:l,wrap:c=120,noWrap:u}=t;if(!i&&!a)return e.createElement("g",{className:"annotation-note"});let d=s;d||(d=Math.abs(n)>Math.abs(o)?"leftRight":"topBottom");let h=l;h&&"dynamic"!==h||(h="topBottom"===d?0>n?"right":"left":0>o?"bottom":"top");let g="start";"topBottom"===d?"right"===h?g="end":"middle"===h&&(g="middle"):g=0>n?"end":"start";const p=16,y=a?u?[a]:Pe(a,c):[],f=i?u?[i]:Pe(i,c):[],m="leftRight"===d?"end"===g?-4:4:0;let v=0;const b=[];y.length>0&&(b.push(e.createElement("text",{key:"annotation-note-title",className:"annotation-note-title",fill:r||void 0,textAnchor:g,fontWeight:"bold"},y.map((t,n)=>e.createElement("tspan",{key:n,x:m,dy:0===n?0:p},t)))),v=y.length*p),f.length>0&&b.push(e.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:r||void 0,textAnchor:g,y:v},f.map((t,n)=>e.createElement("tspan",{key:n,x:m,dy:0===n?0:p},t))));let x=null;if((a||i)&&(0!==n||0!==o))if("topBottom"===d){const t=Math.min(c,120);let n=0,o=t;"end"===g?(n=-t,o=0):"middle"===g&&(n=-t/2,o=t/2),x=e.createElement("line",{className:"note-line",x1:n,x2:o,y1:0,y2:0,stroke:r||"currentColor"})}else{const t=(y.length+f.length)*p+(f.length>0?p:0);let n=0,o=t;"bottom"===h?(n=-t,o=0):"middle"===h&&(n=-t/2,o=t/2),x=e.createElement("line",{className:"note-line",x1:0,x2:0,y1:n,y2:o,stroke:r||"currentColor"})}const w=Math.max(0,y.length+f.length-1)*p;let k=0;return"topBottom"===d?k=0>o?-(w+2):18:"leftRight"===d&&(k="middle"===h?-(w+p+(f.length>0&&y.length>0?2:0))/2+8:"bottom"===h||0>o?-(w+2):18),e.createElement("g",{className:"annotation-note",transform:`translate(${n},${o})`},e.createElement("g",{className:"annotation-note-content",transform:0!==k?`translate(0,${k})`:void 0},b),x)}(l,v,b,h))}function De(t){var n,o;const{noteData:r}=t,{screenCoordinates:i}=r,a="string"==typeof r.type?r.type:"label",s=r.eventListeners||r.events||{};if(r.coordinates&&i){const t=r.nx||i[0][0]+(null!==(n=r.dx)&&void 0!==n?n:0),s=r.ny||i[0][1]+(null!==(o=r.dy)&&void 0!==o?o:0),l=i.map((n,o)=>{const i=Object.assign({},r,{note:0===o?r.note:{label:""},x:n[0],y:n[1],nx:t,ny:s});return e.createElement(Ne,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+o},i,{type:a}))});return e.createElement("g",null,l)}const l=r.note||{title:"none",label:r.label};return e.createElement(Ne,Object.assign({"data-testid":"semiotic-annotation",key:`${l.label}-${l.title}-${r.i}`,events:s},r,{type:a}))}function Ce(e,t){var n,o,r;const i=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.x)&&void 0!==o?o:null===(r=t.scales)||void 0===r?void 0:r.time;return i?null!=e.x?i(e.x):t.xAccessor&&null!=e[t.xAccessor]?i(e[t.xAccessor]):null:null}function Te(e,t){var n,o,r;const i=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.y)&&void 0!==o?o:null===(r=t.scales)||void 0===r?void 0:r.value;return i?null!=e.y?i(e.y):t.yAccessor&&null!=e[t.yAccessor]?i(e[t.yAccessor]):null:null}function Be(e,t,n,o=50){return!(-o>e||e>(n.width||0)+o||-o>t||t>(n.height||0)+o)}function We(t){return function(t,n,o){var r,i,a,s,l,c,u,d,h,g,p,y,f,m,v,b,x,w,k,A,E,S,O,L,P,M,N,D,C,T,B,W,H,$,_,z,I,R,F;switch(t.type){case"label":{let r=null,i=null;if(null!=t.pointId&&o.pointNodes){const e=o.pointNodes.find(e=>e.pointId===t.pointId);if(!e)return null;r=e.x,i=e.y}else r=Ce(t,o),i=Te(t,o);return null==r||null==i?null:Be(r,i,o)?e.createElement(De,{key:"ann-"+n,noteData:{x:r,y:i,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":{let r=null,i=null;if(null!=t.pointId&&o.pointNodes){const e=o.pointNodes.find(e=>e.pointId===t.pointId);if(!e)return null;r=e.x,i=e.y}else r=Ce(t,o),i=Te(t,o);return null==r||null==i?null:Be(r,i,o)?e.createElement(De,{key:"ann-"+n,noteData:{x:r,y:i,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 r=Ce(t,o);if(null==r)return null;const i=t.color||"#f97316";return e.createElement("g",{key:"ann-"+n},e.createElement("line",{x1:r,y1:0,x2:r,y2:o.height||0,stroke:i,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&e.createElement("text",{x:r+4,y:12,fill:i,fontSize:12,fontWeight:"bold"},t.label))}case"y-threshold":{const r=Te(t,o);if(null==r)return null;const i=t.color||"#f97316";return e.createElement("g",{key:"ann-"+n},e.createElement("line",{x1:0,y1:r,x2:o.width||0,y2:r,stroke:i,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&e.createElement("text",{x:(o.width||0)-4,y:r-4,textAnchor:"end",fill:i,fontSize:12,fontWeight:"bold"},t.label))}case"enclose":{const r=(t.coordinates||[]).map(e=>({x:Ce(Object.assign(Object.assign({},e),{type:"point"}),o),y:Te(Object.assign(Object.assign({},e),{type:"point"}),o),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>r.length)return null;const i=j(r),a=t.padding||10;return e.createElement("g",{key:"ann-"+n},e.createElement("circle",{cx:i.x,cy:i.y,r:i.r+a,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&e.createElement("text",{x:i.x,y:i.y-i.r-a-4,textAnchor:"middle",fill:t.color||"#666",fontSize:12},t.label))}case"rect-enclose":{const r=(t.coordinates||[]).map(e=>({x:Ce(Object.assign(Object.assign({},e),{type:"point"}),o),y:Te(Object.assign(Object.assign({},e),{type:"point"}),o)})).filter(e=>null!=e.x&&null!=e.y);if(2>r.length)return null;const i=t.padding||10,a=r.map(e=>e.x),s=r.map(e=>e.y),l=Math.min(...a)-i,c=Math.max(...a)+i,u=Math.min(...s)-i,d=Math.max(...s)+i;return e.createElement("g",{key:"ann-"+n},e.createElement("rect",{x:l,y:u,width:c-l,height:d-u,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&e.createElement("text",{x:(l+c)/2,y:u-4,textAnchor:"middle",fill:t.color||"#666",fontSize:12},t.label))}case"highlight":{const r=o.data||[],i="function"==typeof t.filter?r.filter(t.filter):t.field&&null!=t.value?r.filter(e=>e[t.field]===t.value):[],a=t.style||{stroke:t.color||"#f97316",strokeWidth:2,fill:"none"};return e.createElement("g",{key:"ann-"+n},i.map((n,r)=>{const i=Ce(n,o),s=Te(n,o);return null==i||null==s?null:e.createElement("circle",Object.assign({key:r,cx:i,cy:s,r:t.r||6},a))}))}case"bracket":{const r=Ce(t,o),i=Te(t,o);return e.createElement(De,{key:"ann-"+n,noteData:{x:null!=r?r:0,y:null!=i?i: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 d=o.data||[];if(2>d.length)return null;const h=o.xAccessor||"x",g=o.yAccessor||"y",p=d.map(e=>[e[h],e[g]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>p.length)return null;const y=null!==(i=null===(r=o.scales)||void 0===r?void 0:r.x)&&void 0!==i?i:null===(a=o.scales)||void 0===a?void 0:a.time,f=null!==(l=null===(s=o.scales)||void 0===s?void 0:s.y)&&void 0!==l?l:null===(c=o.scales)||void 0===c?void 0:c.value;if(!y||!f)return null;const m=t.method||"linear";let v;if("loess"===m)v=function(e,t=.3){const n=e.length;if(2>n)return e.slice();const o=e.slice().sort((e,t)=>e[0]-t[0]),r=o.map(e=>e[0]),i=o.map(e=>e[1]),a=Math.max(2,Math.ceil(t*n)),s=[];for(let e=0;n>e;e++){const t=r[e],o=r.map(e=>Math.abs(e-t)),l=o.slice().sort((e,t)=>e-t)[Math.min(a-1,n-1)]||1,c=[];for(let e=0;n>e;e++){const t=0===l?0:o[e]/l;c[e]=1>t?Math.pow(1-Math.pow(t,3),3):0}let u=0,d=0,h=0,g=0,p=0;for(let e=0;n>e;e++){const t=c[e];0!==t&&(u+=t,d+=t*r[e],h+=t*i[e],g+=t*r[e]*r[e],p+=t*r[e]*i[e])}if(0===u){s.push([t,i[e]]);continue}const y=u*g-d*d;if(1e-12>Math.abs(y))s.push([t,h/u]);else{const e=(u*p-d*h)/y;s.push([t,(h-e*d)/u+e*t])}}return s}(p,null!==(u=t.bandwidth)&&void 0!==u?u:.3);else{let e;try{const n=require("regression");e="polynomial"===m?n.polynomial(p,{order:t.order||2}):n.linear(p)}catch(e){return null}v=e.points}const b=v.map(([e,t])=>`${y(e)},${f(t)}`).join(" "),x=t.color||"#6366f1";return e.createElement("g",{key:"ann-"+n},e.createElement("polyline",{points:b,fill:"none",stroke:x,strokeWidth:t.strokeWidth||2,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&e.createElement("text",{x:y(v[v.length-1][0])+4,y:f(v[v.length-1][1])-4,fill:x,fontSize:11},t.label))}case"band":{const r=null!==(h=null===(d=o.scales)||void 0===d?void 0:d.y)&&void 0!==h?h:null===(g=o.scales)||void 0===g?void 0:g.value,i=null!==(p=null==r?void 0:r(t.y0))&&void 0!==p?p:0,a=null!==(y=null==r?void 0:r(t.y1))&&void 0!==y?y:o.height||0;return e.createElement("g",{key:"ann-"+n},e.createElement("rect",{x:0,y:Math.min(i,a),width:o.width||0,height:Math.abs(a-i),fill:t.fill||"#6366f1",fillOpacity:t.fillOpacity||.1}),t.label&&e.createElement("text",{x:(o.width||0)-4,y:Math.min(i,a)-4,textAnchor:"end",fill:t.color||"#6366f1",fontSize:11},t.label))}case"envelope":{const r=o.data||[];if(2>r.length)return null;const i=o.xAccessor||"x",a=null!==(m=null===(f=o.scales)||void 0===f?void 0:f.x)&&void 0!==m?m:null===(v=o.scales)||void 0===v?void 0:v.time,s=null!==(x=null===(b=o.scales)||void 0===b?void 0:b.y)&&void 0!==x?x:null===(w=o.scales)||void 0===w?void 0:w.value;if(!a||!s)return null;const l=t.upperAccessor||"upperBounds",c=t.lowerAccessor||"lowerBounds",u=t.filter,d=r.filter(e=>null!=e[l]&&null!=e[c]&&!(u&&!u(e))).sort((e,t)=>e[i]-t[i]);if(2>d.length)return null;const h=d.map(e=>`${a(e[i])},${s(e[l])}`).join(" L"),g=d.slice().reverse().map(e=>`${a(e[i])},${s(e[c])}`).join(" L"),p=t.fill||"#6366f1";return e.createElement("g",{key:"ann-"+n},e.createElement("path",{d:`M${h} L${g} Z`,fill:p,fillOpacity:null!==(k=t.fillOpacity)&&void 0!==k?k:.15,stroke:"none"}),t.label&&d.length>0&&e.createElement("text",{x:a(d[d.length-1][i])+4,y:s(d[d.length-1][l])-4,fill:p,fontSize:11},t.label))}case"anomaly-band":{const r=o.data||[];if(2>r.length)return null;const i=o.yAccessor||"y",a=null!==(E=null===(A=o.scales)||void 0===A?void 0:A.x)&&void 0!==E?E:null===(S=o.scales)||void 0===S?void 0:S.time,s=null!==(L=null===(O=o.scales)||void 0===O?void 0:O.y)&&void 0!==L?L:null===(P=o.scales)||void 0===P?void 0:P.value;if(!a||!s)return null;const l=r.map(e=>e[i]).filter(e=>null!=e&&isFinite(e));if(2>l.length)return null;const c=l.reduce((e,t)=>e+t,0)/l.length,u=l.reduce((e,t)=>e+Math.pow(t-c,2),0)/l.length,d=Math.sqrt(u),h=null!==(M=t.threshold)&&void 0!==M?M:2,g=c-h*d,p=!1!==t.showBand,y=t.fill||"#6366f1",f=null!==(N=t.fillOpacity)&&void 0!==N?N:.1,m=t.anomalyColor||"#ef4444",v=null!==(D=t.anomalyRadius)&&void 0!==D?D:6,b=s(c+h*d),x=s(g),w=r.filter(e=>{const t=e[i];return null!=t&&Math.abs(t-c)>h*d});return e.createElement("g",{key:"ann-"+n},p&&e.createElement("rect",{x:0,y:Math.min(b,x),width:o.width||0,height:Math.abs(x-b),fill:y,fillOpacity:f}),w.map((t,n)=>{const r=Ce(t,o),i=Te(t,o);return null==r||null==i?null:e.createElement("circle",{key:n,cx:r,cy:i,r:v,fill:m,fillOpacity:.7,stroke:m,strokeWidth:1.5})}),t.label&&e.createElement("text",{x:(o.width||0)-4,y:Math.min(b,x)-4,textAnchor:"end",fill:y,fontSize:11},t.label))}case"forecast":{const r=o.data||[];if(3>r.length)return null;const i=o.xAccessor||"x",a=o.yAccessor||"y",s=null!==(T=null===(C=o.scales)||void 0===C?void 0:C.x)&&void 0!==T?T:null===(B=o.scales)||void 0===B?void 0:B.time,l=null!==(H=null===(W=o.scales)||void 0===W?void 0:W.y)&&void 0!==H?H:null===($=o.scales)||void 0===$?void 0:$.value;if(!s||!l)return null;const c=r.map(e=>[e[i],e[a]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]);if(3>c.length)return null;let u;if("polynomial"===(t.method||"linear"))try{const e=require("regression").polynomial(c,{order:t.order||2}).equation;u=t=>e.reduce((e,n,o)=>e+n*Math.pow(t,o),0)}catch(e){return null}else{const e=c.length;let t=0,n=0,o=0,r=0;for(const[e,i]of c)t+=e,n+=i,o+=e*e,r+=e*i;const i=e*o-t*t;if(1e-12>Math.abs(i))return null;const a=(e*r-t*n)/i,s=(n-a*t)/e;u=e=>s+a*e}const d=c.length,h=c.map(([e,t])=>t-u(e)).reduce((e,t)=>e+t*t,0),g=Math.sqrt(h/Math.max(d-2,1)),p=c.reduce((e,t)=>e+t[0],0)/d,y=c.reduce((e,t)=>e+Math.pow(t[0]-p,2),0),f=null!==(_=t.confidence)&&void 0!==_?_:.95,m=.99>f?.95>f?.9>f?1:1.645:1.96:2.576,v=null!==(z=t.steps)&&void 0!==z?z:5,b=c[d-1][0],x=(b-c[0][0])/Math.max(d-1,1),w=[];for(let e=1;v>=e;e++)w.push(b+e*x);const k=[];for(const e of w){const t=u(e),n=g*Math.sqrt(1+1/d+(y>0?Math.pow(e-p,2)/y:0))*m;k.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const A=`M${k.map(e=>`${s(e.x)},${l(e.yUpper)}`).join(" L")} L${k.slice().reverse().map(e=>`${s(e.x)},${l(e.yLower)}`).join(" L")} Z`,E=k.map(e=>`${s(e.x)},${l(e.yCenter)}`).join(" "),S=`${s(b)},${l(u(b))}`,O=t.strokeColor||"#6366f1";return e.createElement("g",{key:"ann-"+n},e.createElement("path",{d:A,fill:t.fill||"#6366f1",fillOpacity:null!==(I=t.fillOpacity)&&void 0!==I?I:.15,stroke:"none"}),e.createElement("polyline",{points:`${S} ${E}`,fill:"none",stroke:O,strokeWidth:null!==(R=t.strokeWidth)&&void 0!==R?R:2,strokeDasharray:null!==(F=t.strokeDasharray)&&void 0!==F?F:"6,3"}),t.label&&k.length>0&&e.createElement("text",{x:s(k[k.length-1].x)+4,y:l(k[k.length-1].yCenter)-4,fill:O,fontSize:11},t.label))}default:return null}}}function He(e,t,n){if("left"===e||"right"===e){const o="left"===e?n:0,r="left"===e?-1:1,i=Math.ceil(t/8);let a="M0,"+o;for(let e=0;i>e;e++){const n=8*(e+1);a+=`L${Math.min(8*e+4,t)},${o+4*r}`,a+=`L${Math.min(n,t)},${o}`}return a}{const o="bottom"===e?0:t,r="bottom"===e?1:-1,i=Math.ceil(n/8);let a=`M${o},0`;for(let e=0;i>e;e++){const t=8*(e+1);a+=`L${o+4*r},${Math.min(8*e+4,n)}`,a+=`L${o},${Math.min(t,n)}`}return a}}function $e(e){return Math.round(100*e)/100+""}function _e(t){const{width:n,height:o,totalWidth:i,totalHeight:a,margin:s,scales:l,showAxes:c,axes:u,xLabel:d,yLabel:h,xFormat:g,yFormat:p,showGrid:y,title:f,legend:m,foregroundGraphics:v,marginalGraphics:b,xValues:x,yValues:w,annotations:k,svgAnnotationRules:A,annotationFrame:E,xAccessor:S,yAccessor:O,annotationData:L,pointNodes:j,children:P}=t,M=r(()=>c&&l?l.x.ticks(5).map(e=>({value:e,pixel:l.x(e),label:(g||$e)(e)})):[],[c,l,g]),N=r(()=>c&&l?l.y.ticks(5).map(e=>({value:e,pixel:l.y(e),label:(p||$e)(e)})):[],[c,l,p]),D=r(()=>{if(!k||0===k.length)return null;const e=We(),t={scales:l?{x:l.x,y:l.y,time:l.x,value:l.y}:null,timeAxis:"x",xAccessor:S,yAccessor:O,width:n,height:o,data:L,frameType:"xy",pointNodes:j};return k.map((n,o)=>{if(A){const r=A(n,o,t);return null!=r?r:e(n,o,t)}return e(n,o,t)}).filter(Boolean)},[k,A,n,o,E,S,O,L]);return c||f||m||v||b||D&&D.length>0||y||P?e.createElement("svg",{width:i,height:a,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},e.createElement("g",{transform:`translate(${s.left},${s.top})`},y&&l&&e.createElement("g",{className:"stream-grid"},M.map((t,n)=>e.createElement("line",{key:"xgrid-"+n,x1:t.pixel,y1:0,x2:t.pixel,y2:o,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1})),N.map((t,o)=>e.createElement("line",{key:"ygrid-"+o,x1:0,y1:t.pixel,x2:n,y2:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),c&&l&&(()=>{const t=null==u?void 0:u.find(e=>"left"===e.orient),r=null==u?void 0:u.find(e=>"bottom"===e.orient),i=!t||!1!==t.baseline,a=(null==t?void 0:t.jaggedBase)||!1,l=(null==r?void 0:r.jaggedBase)||!1,c="var(--semiotic-border, #ccc)",g="var(--semiotic-text-secondary, #666)",p="var(--semiotic-text, #333)";return e.createElement("g",{className:"stream-axes"},(!r||!1!==r.baseline)&&!l&&e.createElement("line",{x1:0,y1:o,x2:n,y2:o,stroke:c,strokeWidth:1}),l&&e.createElement("path",{d:He("bottom",n,o),fill:"none",stroke:c,strokeWidth:1}),M.map((t,n)=>e.createElement("g",{key:"xtick-"+n,transform:`translate(${t.pixel},${o})`},e.createElement("line",{y2:5,stroke:c,strokeWidth:1}),e.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:g,style:{userSelect:"none"}},t.label))),d&&e.createElement("text",{x:n/2,y:o+40,textAnchor:"middle",fontSize:12,fill:p,style:{userSelect:"none"}},d),i&&!a&&e.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:c,strokeWidth:1}),a&&e.createElement("path",{d:He("left",n,o),fill:"none",stroke:c,strokeWidth:1}),N.map((t,n)=>e.createElement("g",{key:"ytick-"+n,transform:`translate(0,${t.pixel})`},e.createElement("line",{x2:-5,stroke:c,strokeWidth:1}),e.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:g,style:{userSelect:"none"}},t.label))),h&&e.createElement("text",{x:15-s.left,y:o/2,textAnchor:"middle",fontSize:12,fill:p,transform:`rotate(-90, ${15-s.left}, ${o/2})`,style:{userSelect:"none"}},h))})(),D,b&&l&&x&&w&&e.createElement(e.Fragment,null,b.top&&e.createElement("g",{transform:"translate(0, 0)"},e.createElement(je,{orient:"top",config:Le(b.top),values:x,scale:l.x,size:s.top,length:n})),b.bottom&&e.createElement("g",{transform:`translate(0, ${o})`},e.createElement(je,{orient:"bottom",config:Le(b.bottom),values:x,scale:l.x,size:s.bottom,length:n})),b.left&&e.createElement("g",{transform:"translate(0, 0)"},e.createElement(je,{orient:"left",config:Le(b.left),values:w,scale:l.y,size:s.left,length:o})),b.right&&e.createElement("g",{transform:`translate(${n}, 0)`},e.createElement(je,{orient:"right",config:Le(b.right),values:w,scale:l.y,size:s.right,length:o}))),v,P),f&&e.createElement("text",{x:i/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof f?f:null),m&&e.createElement("g",{transform:`translate(${i-s.right+10}, ${s.top})`},function(t){return"object"==typeof t&&null!==t&&!e.isValidElement(t)&&"legendGroups"in t}(m)?e.createElement(Oe,{legendGroups:m.legendGroups,title:"",width:100}):m)):null}function ze(e,t,n){let o=n;for(const n of t)"lesser"===n.thresholdType?n.value>e&&(o=n.color):e>n.value&&(o=n.color);return o}function Ie(e){if(e.startsWith("#")){const t=4===e.length?e[1]+e[1]+e[2]+e[2]+e[3]+e[3]:e.slice(1,7);return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[78,121,167]}const Re=(e,t,n,o)=>{var r;const i=t.filter(e=>"area"===e.type);for(const t of i){if(2>t.topPath.length)continue;e.beginPath();const[n,o]=t.topPath[0];e.moveTo(n,o);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1]);for(let n=t.bottomPath.length-1;n>=0;n--)e.lineTo(t.bottomPath[n][0],t.bottomPath[n][1]);e.closePath();const i=t.style.fill||"#4e79a7";if(t.fillGradient){const n=Math.min(...t.topPath.map(e=>e[1])),o=Math.max(...t.bottomPath.map(e=>e[1])),r=e.createLinearGradient(0,n,0,o);r.addColorStop(0,i),r.addColorStop(1,i),e.fillStyle=r;const a=Ie(i),s=t.fillGradient.topOpacity,l=t.fillGradient.bottomOpacity,c=e.createLinearGradient(0,n,0,o);c.addColorStop(0,`rgba(${a[0]},${a[1]},${a[2]},${s})`),c.addColorStop(1,`rgba(${a[0]},${a[1]},${a[2]},${l})`),e.fillStyle=c,e.globalAlpha=1}else{const n=null!==(r=t.style.fillOpacity)&&void 0!==r?r:.7;e.globalAlpha=n,e.fillStyle=i}if(e.fill(),t.style.stroke&&"none"!==t.style.stroke){e.globalAlpha=1,e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]),e.beginPath(),e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1]);e.stroke()}e.globalAlpha=1}},Fe=(e,t,n,o)=>{var r,i;const a=t.filter(e=>"point"===e.type);for(const t of a){e.beginPath(),e.arc(t.x,t.y,t.r,0,2*Math.PI);const n=null!==(r=t.style.opacity)&&void 0!==r?r:t.style.fillOpacity;if(null!=n&&(e.globalAlpha=n),e.fillStyle=t.style.fill||"#4e79a7",e.fill(),t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()),t._pulseIntensity&&t._pulseIntensity>0){const n=null!==(i=t._pulseGlowRadius)&&void 0!==i?i:4,o=t.r+n*t._pulseIntensity;e.beginPath(),e.arc(t.x,t.y,o,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=.6*t._pulseIntensity,e.stroke()}e.globalAlpha=1}},Ye=(e,t,n,o)=>{const r=t.filter(e=>"rect"===e.type);for(const t of r)null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.icon?Ge(e,t):(e.fillStyle=t.style.fill||"#007bff",e.fillRect(t.x,t.y,t.w,t.h),t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.strokeRect(t.x,t.y,t.w,t.h))),t._pulseIntensity&&t._pulseIntensity>0&&(e.globalAlpha=.3*t._pulseIntensity,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h)),e.globalAlpha=1};function Ge(e,t){const n=t.style.icon,o=t.style.iconPadding||2,r=Math.min(t.w,t.w)-o;if(0>=r)return;const i=t.h>t.w;if(e.save(),e.beginPath(),e.rect(t.x,t.y,t.w,t.h),e.clip(),i){const i=r+o,a=t.x+(t.w-r)/2;for(let o=t.y+t.h-r;o>=t.y-r;o-=i)e.drawImage(n,a,o,r,r)}else{const i=r+o,a=t.y+(t.h-r)/2;for(let o=t.x;t.x+t.w>o;o+=i)e.drawImage(n,o,a,r,r)}e.restore()}const Xe={line:[Re,(e,t,n,o)=>{const r=t.filter(e=>"line"===e.type);for(const i of r){if(2>i.path.length)continue;const a=i.style.stroke||"#007bff",s=i.style.strokeWidth||2,l=i.colorThresholds,c=i.rawValues;if(e.setLineDash(i.style.strokeDasharray?i.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=i.style.opacity&&(e.globalAlpha=i.style.opacity),e.lineWidth=s,l&&0!==l.length&&c&&c.length===i.path.length){let u=null,d=null,h=null,g=null,p=!1;function y(t,n,o){e.beginPath(),e.strokeStyle=t,e.moveTo(n,o),p=!0}function f(){p&&(e.stroke(),p=!1)}for(let m=0;i.path.length>m;m++){const[v,b]=i.path[m],x=c[m],w=ze(x,l,a);if(null!==u&&null!==g&&null!==h){if(w===g)e.lineTo(v,b);else{const k=[];for(const A of l){const E=A.value;(h>E||E>x)&&(E>h||x>E)||h===E||x===E||k.push({t:(E-h)/(x-h)})}k.sort((e,t)=>e.t-t.t);for(const S of k){const O=u+(v-u)*S.t,L=d+(b-d)*S.t,j=ze(h+(x-h)*Math.min(S.t+1e-4,1),l,a);e.lineTo(O,L),f(),y(j,O,L)}e.lineTo(v,b)}u=v,d=b,h=x,g=w}else y(w,v,b),u=v,d=b,h=x,g=w}f()}else{e.beginPath(),e.strokeStyle=a;const[P,M]=i.path[0];e.moveTo(P,M);for(let N=1;i.path.length>N;N++)e.lineTo(i.path[N][0],i.path[N][1]);e.stroke()}if(i.style.fill&&i.style.fillOpacity&&i.style.fillOpacity>0){e.beginPath(),e.globalAlpha=i.style.fillOpacity,e.fillStyle=i.style.fill;const[D,C]=i.path[0];e.moveTo(D,C);for(let B=1;i.path.length>B;B++)e.lineTo(i.path[B][0],i.path[B][1]);const T=i.path[0][0];e.lineTo(i.path[i.path.length-1][0],o.height),e.lineTo(T,o.height),e.closePath(),e.fill()}e.globalAlpha=1,e.setLineDash([])}}],area:[Re],stackedarea:[Re],scatter:[Fe],bubble:[Fe],heatmap:[(e,t,n,o)=>{const r=t.filter(e=>"heatcell"===e.type);for(const t of r){const n=t.style;null!=(null==n?void 0:n.opacity)&&(e.globalAlpha=n.opacity),e.fillStyle=t.fill,e.fillRect(t.x,t.y,t.w,t.h),e.strokeStyle="#fff",e.lineWidth=1,e.strokeRect(t.x,t.y,t.w,t.h),t._pulseIntensity&&t._pulseIntensity>0&&(e.globalAlpha=.3*t._pulseIntensity,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h)),e.globalAlpha=1}}],bar:[Ye],swarm:[Fe],waterfall:[(e,t,n,o)=>{var r,i,a;Ye(e,t);const s=t.filter(e=>"rect"===e.type);if(2>s.length)return;const l=s[0].datum,c=null==l?void 0:l._connectorStroke;if(c){e.save(),e.strokeStyle=c,e.lineWidth=null!==(r=null==l?void 0:l._connectorWidth)&&void 0!==r?r:1,e.setLineDash([]);for(let t=0;s.length-1>t;t++){const o=s[t],r=s[t+1];if(!(null===(i=o.datum)||void 0===i?void 0:i.cumEnd)||!(null===(a=r.datum)||void 0===a?void 0:a.baseline))continue;const l=n.y(o.datum.cumEnd),c=o.x+o.w,u=r.x;e.beginPath(),e.moveTo(c,l),e.lineTo(u,l),e.stroke()}e.restore()}}],candlestick:[(e,t,n,o)=>{for(const n of t){if("candlestick"!==n.type)continue;const t=n;e.beginPath(),e.moveTo(t.x,t.highY),e.lineTo(t.x,t.lowY),e.strokeStyle=t.wickColor,e.lineWidth=t.wickWidth,e.stroke();const o=Math.min(t.openY,t.closeY),r=Math.abs(t.openY-t.closeY),i=t.isUp?t.upColor:t.downColor;e.fillStyle=i,e.fillRect(t.x-t.bodyWidth/2,o,t.bodyWidth,Math.max(r,1)),e.strokeStyle=i,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,o,t.bodyWidth,Math.max(r,1))}}]},qe={top:20,right:20,bottom:30,left:40},Ve={axisStroke:"#ccc",tickText:"#666",crosshair:"rgba(0, 0, 0, 0.25)",hoverFill:"rgba(255, 255, 255, 0.3)",hoverStroke:"rgba(0, 0, 0, 0.4)",pointRing:"white"},Ue={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,lineHeight:1.5,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function Ze({hover:t}){const n=e=>Number.isInteger(e)?e+"":e.toFixed(2);return e.createElement("div",{className:"semiotic-tooltip",style:Ue},e.createElement("div",{style:{fontWeight:600,marginBottom:2}},n(t.value)),e.createElement("div",{style:{opacity:.7,fontSize:11}},n(t.time)))}function Qe({width:n,height:r,totalWidth:i,totalHeight:a,margin:s,dimension:l,scales:c,onBrush:u}){const d=t(null),f=t(null);return o(()=>{if(!d.current)return;const e=y(d.current).select(".brush-g"),t="x"===l?h():"y"===l?g():p();return t.extent([[0,0],[n,r]]),t.on("brush end",e=>{if(!c)return;if(!e.selection)return void u(null);let t,o;if("x"===l){const[n,i]=e.selection;t=[c.x.invert(n),c.x.invert(i)],o=[c.y.invert(r),c.y.invert(0)]}else if("y"===l){const[r,i]=e.selection;t=[c.x.invert(0),c.x.invert(n)],o=[c.y.invert(i),c.y.invert(r)]}else{const[[n,r],[i,a]]=e.selection;t=[c.x.invert(n),c.x.invert(i)],o=[c.y.invert(a),c.y.invert(r)]}u({x:t,y:o})}),e.call(t),f.current=t,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{t.on("brush end",null),f.current=null}},[n,r,l,c,u]),e.createElement("svg",{ref:d,width:i,height:a,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},e.createElement("g",{className:"brush-g",transform:`translate(${s.left},${s.top})`}))}const Ke=i(function(i,l){var c,u,d;const{chartType:h,runtimeMode:g,data:p,xAccessor:y,yAccessor:f,colorAccessor:m,sizeAccessor:v,groupAccessor:b,lineDataAccessor:x,normalize:w,binSize:k,valueAccessor:A,arrowOfTime:E="right",windowMode:S="sliding",windowSize:O=200,timeAccessor:L,xExtent:j,yExtent:P,extentPadding:M=.1,sizeRange:N,size:D=[500,300],responsiveWidth:C,responsiveHeight:T,margin:B,className:W,background:H,lineStyle:$,pointStyle:_,areaStyle:z,waterfallStyle:I,swarmStyle:R,barColors:F,colorScheme:Y,boundsAccessor:G,boundsStyle:X,y0Accessor:q,gradientFill:V,openAccessor:U,highAccessor:Z,lowAccessor:Q,closeAccessor:K,candlestickStyle:J,showAxes:ee=!0,axes:te,xLabel:oe,yLabel:re,xFormat:ie,yFormat:ae,tickFormatTime:se,tickFormatValue:le,hoverAnnotation:ce,tooltipContent:ue,customHoverBehavior:de,enableHover:he,annotations:xe,svgAnnotationRules:Ee,showGrid:Se,legend:Oe,backgroundGraphics:Le,foregroundGraphics:je,title:Pe,categoryAccessor:Me,brush:Ne,onBrush:De,decay:Ce,pulse:Te,transition:Be,staleness:We,heatmapAggregation:He,heatmapXBins:$e,heatmapYBins:ze,marginalGraphics:Ie,pointIdAccessor:Re}=i,[Fe,Ye]=Ae(D,C,T),Ge=Object.assign(Object.assign({},qe),B);if(Ie){const e=60;Ie.top&&e>Ge.top&&(Ge.top=e),Ie.bottom&&e>Ge.bottom&&(Ge.bottom=e),Ie.left&&e>Ge.left&&(Ge.left=e),Ie.right&&e>Ge.right&&(Ge.right=e)}const Ue=Ye[0]-Ge.left-Ge.right,Ke=Ye[1]-Ge.top-Ge.bottom,Je=null!=ce?ce:he,et=t(null),tt=t(0),nt=t(!1),[ot,rt]=n(0),[it,at]=n(null),st=t(null),lt=t(null),[ct,ut]=n(null),[dt,ht]=n(!1),[gt,pt]=n([]),[yt,ft]=n([]),mt=t(()=>{}),vt="streaming"===g||["bar","swarm","waterfall"].includes(h),bt=r(()=>({chartType:h,runtimeMode:vt?"streaming":"bounded",windowSize:O,windowMode:S,arrowOfTime:vt?E:"right",extentPadding:M,xAccessor:vt?void 0:y,yAccessor:vt?void 0:f,timeAccessor:vt?L:void 0,valueAccessor:A,colorAccessor:m,sizeAccessor:v,groupAccessor:b,categoryAccessor:Me,lineDataAccessor:x,xExtent:j,yExtent:P,sizeRange:N,binSize:k,normalize:w,boundsAccessor:G,boundsStyle:X,y0Accessor:q,gradientFill:"boolean"==typeof V?V?{topOpacity:.8,bottomOpacity:.05}:void 0:V,openAccessor:U,highAccessor:Z,lowAccessor:Q,closeAccessor:K,candlestickStyle:J,lineStyle:$,pointStyle:_,areaStyle:z,swarmStyle:R,waterfallStyle:I,colorScheme:Y,barColors:F,annotations:xe,decay:Ce,pulse:Te,transition:Be,staleness:We,heatmapAggregation:He,heatmapXBins:$e,heatmapYBins:ze,pointIdAccessor:Re}),[h,O,S,E,M,y,f,L,A,m,v,b,Me,x,j,P,N,k,w,G,X,q,V,U,Z,Q,K,J,$,_,z,R,I,Y,F,xe,Ce,Te,Be,We,He,$e,ze,vt,Re]),xt=t(null);xt.current||(xt.current=new ge(bt));const wt=a(()=>{tt.current||(tt.current=requestAnimationFrame(()=>mt.current()))},[]);o(()=>{var e;null===(e=xt.current)||void 0===e||e.updateConfig(bt),nt.current=!0,wt()},[bt,wt]);const kt=t(null);kt.current||(kt.current=new ne(e=>{const t=xt.current;t&&t.ingest(e)&&(nt.current=!0,wt())}));const At=a(e=>{var t;null===(t=kt.current)||void 0===t||t.push(e)},[]),Et=a(e=>{var t;null===(t=kt.current)||void 0===t||t.pushMany(e)},[]),St=a(()=>{var e,t;null===(e=kt.current)||void 0===e||e.clear(),null===(t=xt.current)||void 0===t||t.clear(),nt.current=!0,wt()},[wt]);s(l,()=>({push:At,pushMany:Et,clear:St,getData:()=>{var e,t;return null!==(t=null===(e=xt.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=xt.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null},getExtents:()=>{var e,t;return null!==(t=null===(e=xt.current)||void 0===e?void 0:e.getExtents())&&void 0!==t?t:null}}),[At,Et,St]),o(()=>{var e;p&&(null===(e=kt.current)||void 0===e||e.setBoundedData(p))},[p]);const Ot=t(()=>{}),Lt=t(()=>{});Ot.current=e=>{if(!Je)return;const t=et.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-Ge.left,r=e.clientY-n.top-Ge.top;if(0>o||o>Ue||0>r||r>Ke)return void(st.current&&(st.current=null,lt.current=null,ut(null),de&&(de(null),nt.current=!0),wt()));const i=xt.current;if(!i||0===i.scene.length)return;const a=function(e,t,n,o=30){let r=null;for(const i of e){let e=null;switch(i.type){case"point":e=pe(i,t,n);break;case"line":e=ye(i,t,n);break;case"rect":e=fe(i,t,n);break;case"heatcell":e=me(i,t,n);break;case"area":if(!1===i.interactive)break;e=be(i,t,n);break;case"candlestick":e=ve(i,t,n)}e&&o>e.distance&&(r&&e.distance>=r.distance||(r=e))}return r}(i.scene,o,r);if(!a)return void(st.current&&(st.current=null,lt.current=null,ut(null),de&&de(null),wt()));const s={data:a.datum,time:a.x,value:a.y,x:a.x,y:a.y};st.current=s,lt.current=a.node,ut(s),de&&(de(s),nt.current=!0),wt()},Lt.current=()=>{st.current&&(st.current=null,lt.current=null,ut(null),de&&(de(null),nt.current=!0),wt())},a(e=>Ot.current(e),[]);const jt=a(()=>Lt.current(),[]),Pt=t(-1),Mt=a(e=>{const t=xt.current;if(!t||0===t.scene.length)return;const n=function(e){const t=[];for(const n of e)switch(n.type){case"point":t.push({x:n.x,y:n.y,datum:n.datum});break;case"line":{const e=n,o=Array.isArray(e.datum)?e.datum:[];for(let n=0;e.path.length>n&&o.length>n;n++)t.push({x:e.path[n][0],y:e.path[n][1],datum:o[n]});break}case"area":{const e=n,o=Array.isArray(e.datum)?e.datum:[];for(let n=0;e.topPath.length>n&&o.length>n;n++)t.push({x:e.topPath[n][0],y:e.topPath[n][1],datum:o[n]});break}case"rect":case"heatcell":t.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum})}return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}(t.scene);if(0===n.length)return;const o=0>Pt.current?-1:Pt.current,r=we(e.key,0>o?-1:o,n.length);if(null===r)return;if(e.preventDefault(),0>r)return Pt.current=-1,st.current=null,lt.current=null,ut(null),de&&de(null),void wt();const i=0>o?0:r;Pt.current=i;const a=ke(n[i]);st.current=a,ut(a),de&&de(a),wt()},[de,wt]),Nt=a(e=>{Pt.current=-1,Ot.current(e)},[]);mt.current=()=>{var e,t;tt.current=0;const n=et.current;if(!n)return;const o=n.getContext("2d");if(!o)return;const r=xt.current;if(!r)return;const i="undefined"!=typeof performance?performance.now():Date.now(),a=r.advanceTransition(i);a||r.computeScene({width:Ue,height:Ke});const s="undefined"!=typeof window&&window.devicePixelRatio||1;n.width=Ye[0]*s,n.height=Ye[1]*s,n.style.width=Ye[0]+"px",n.style.height=Ye[1]+"px",o.scale(s,s),o.translate(Ge.left,Ge.top),o.clearRect(-Ge.left,-Ge.top,Ye[0],Ye[1]);const l=function(e){if(!e)return Ve;const t=getComputedStyle(e),n=t.getPropertyValue("--semiotic-border").trim(),o=t.getPropertyValue("--semiotic-text-secondary").trim(),r=t.getPropertyValue("--semiotic-bg").trim(),i=o||t.getPropertyValue("--text-secondary").trim(),a=t.getPropertyValue("--text-primary").trim(),s=n||t.getPropertyValue("--surface-3").trim(),l=r||t.getPropertyValue("--surface-0").trim();return i||a||n?{axisStroke:s||Ve.axisStroke,tickText:i||Ve.tickText,crosshair:i?i+"66":Ve.crosshair,hoverFill:l?l+"4D":Ve.hoverFill,hoverStroke:i?i+"99":Ve.hoverStroke,pointRing:l||Ve.pointRing}:Ve}(n),c=null!==(e=null==We?void 0:We.threshold)&&void 0!==e?e:5e3,u=We&&r.lastIngestTime>0&&i-r.lastIngestTime>c;u&&(o.globalAlpha=null!==(t=null==We?void 0:We.dimOpacity)&&void 0!==t?t:.5);const d=n?getComputedStyle(n).getPropertyValue("--semiotic-bg").trim():"",g=H||(d&&"transparent"!==d?d:null);g&&(o.fillStyle=g,o.fillRect(-Ge.left,-Ge.top,Ye[0],Ye[1])),o.save(),"function"==typeof o.rect&&(o.beginPath(),o.rect(0,0,Ue,Ke),o.clip());const p=Xe[h];if(p&&r.scales)for(const e of p)e(o,r.scene,r.scales,{width:Ue,height:Ke});if(o.restore(),u&&(o.globalAlpha=1),Je&&st.current&&r.scales&&function(e,t,n,o,r,i,a){if(!1===r.crosshair)return;e.save();const s="object"==typeof r.crosshair?r.crosshair:{};e.strokeStyle=s.stroke||a.crosshair,e.lineWidth=s.strokeWidth||1,e.setLineDash(s.strokeDasharray?s.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),e.beginPath(),e.moveTo(t.x,0),e.lineTo(t.x,o),e.stroke(),e.beginPath(),e.moveTo(0,t.y),e.lineTo(n,t.y),e.stroke(),e.restore(),e.beginPath(),e.arc(t.x,t.y,4,0,2*Math.PI),e.fillStyle="#007bff",e.fill(),e.strokeStyle=a.pointRing,e.lineWidth=2,e.stroke()}(o,st.current,Ue,Ke,"object"==typeof Je?Je:{},0,l),lt.current&&Array.isArray(ce)){const e=ce.find(e=>e&&"object"==typeof e&&"highlight"===e.type);e&&function(e,t,n,o){var r;if(!n)return;const i=n.group;if(void 0!==i)for(const n of t){if("line"!==n.type)continue;if(n.group!==i)continue;if(2>n.path.length)continue;const t="function"==typeof o.style?o.style(n.datum):o.style||{};e.save(),e.beginPath(),e.moveTo(n.path[0][0],n.path[0][1]);for(let t=1;n.path.length>t;t++)e.lineTo(n.path[t][0],n.path[t][1]);e.strokeStyle=t.stroke||n.style.stroke||"#007bff",e.lineWidth=t.strokeWidth||(n.style.strokeWidth||2)+2,e.globalAlpha=null!==(r=t.opacity)&&void 0!==r?r:1,e.stroke(),e.restore()}}(o,r.scene,lt.current,e)}const m=nt.current;if(nt.current=!1,m&&r.scales&&(at(r.scales),Ie)){const e=r.getData(),t="function"==typeof y?y:e=>e[y||"x"],n="function"==typeof f?f:e=>e[f||"y"];pt(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),ft(e.map(e=>n(e)).filter(e=>"number"==typeof e&&isFinite(e)))}m&&xe&&xe.length>0&&rt(e=>e+1),(null==We?void 0:We.showBadge)&&ht(!!u),(a||r.hasActivePulses)&&(tt.current=requestAnimationFrame(()=>mt.current()))},o(()=>(wt(),()=>{tt.current&&(cancelAnimationFrame(tt.current),tt.current=0)}),[wt]),o(()=>{nt.current=!0,wt()},[h,Ue,Ke,ee,H,$,wt]),o(()=>{if(!We)return;const e=setInterval(()=>{var e;const t=xt.current;if(!t||0===t.lastIngestTime)return;const n="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(e=We.threshold)&&void 0!==e?e:5e3,r=n-t.lastIngestTime>o;r!==dt&&(ht(r),nt.current=!0,wt())},1e3);return()=>clearInterval(e)},[We,dt,wt]);const Dt=Je&&ct?ue?ue(ct):e.createElement(Ze,{hover:ct}):null,Ct=Dt?e.createElement("div",{className:"stream-frame-tooltip",style:{position:"absolute",left:Ge.left+ct.x,top:Ge.top+ct.y,transform:`translate(${ct.x>.7*Ue?"calc(-100% - 12px)":"12px"}, ${.3*Ke>ct.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:1}},Dt):null,Tt=Pt.current>=0&&ct?e.createElement("svg",{style:{position:"absolute",left:0,top:0,width:Ye[0],height:Ye[1],pointerEvents:"none",zIndex:2}},e.createElement("circle",{cx:ct.x+Ge.left,cy:ct.y+Ge.top,r:8,fill:"none",stroke:"var(--accent, #6366f1)",strokeWidth:2,strokeDasharray:"4,2"})):null;return e.createElement("div",{ref:Fe,className:"stream-xy-frame"+(W?" "+W:""),role:"img","aria-label":"string"==typeof Pe?Pe:"XY chart",tabIndex:0,style:{position:"relative",width:C?"100%":Ye[0],height:T?"100%":Ye[1]},onMouseMove:Je?Nt:void 0,onMouseLeave:Je?jt:void 0,onKeyDown:Mt},Le&&e.createElement("svg",{style:{position:"absolute",left:0,top:0,width:Ye[0],height:Ye[1],pointerEvents:"none"}},Le),e.createElement("canvas",{ref:et,style:{position:"absolute",left:0,top:0}}),e.createElement(_e,{width:Ue,height:Ke,totalWidth:Ye[0],totalHeight:Ye[1],margin:Ge,scales:it,showAxes:ee,axes:te,xLabel:oe,yLabel:re,xFormat:ie||se,yFormat:ae||le,showGrid:Se,title:Pe,legend:Oe,foregroundGraphics:je,marginalGraphics:Ie,xValues:gt,yValues:yt,annotations:xe,svgAnnotationRules:Ee,annotationFrame:ot,xAccessor:"string"==typeof y?y:"string"==typeof L?L:void 0,yAccessor:"string"==typeof f?f:"string"==typeof A?A:void 0,annotationData:null===(c=xt.current)||void 0===c?void 0:c.getData(),pointNodes:null===(u=xt.current)||void 0===u?void 0:u.scene.filter(e=>"point"===e.type)}),(Ne||De)&&e.createElement(Qe,{width:Ue,height:Ke,totalWidth:Ye[0],totalHeight:Ye[1],margin:Ge,dimension:null!==(d=null==Ne?void 0:Ne.dimension)&&void 0!==d?d:"xy",scales:it,onBrush:null!=De?De:()=>{}}),(null==We?void 0:We.showBadge)&&e.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===We.badgePosition?{top:4,left:4}:"bottom-left"===We.badgePosition?{bottom:4,left:4}:"bottom-right"===We.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:dt?"#dc3545":"#28a745",color:"white"})},dt?"STALE":"LIVE"),Tt,Ct)});function Je(e,t){const{columns:n,config:o,resolvePieceStyle:r}=e,i=[],a=Math.min(t.width,t.height)/2-4,s="donut"===o.chartType?o.innerRadius||60:0,l=-Math.PI/2+(o.startAngle||0)*Math.PI/180,c=2*Math.PI;for(const e of Object.values(n)){const t=l+e.pctStart*c,n=l+(e.pctStart+e.pct)*c,o=r(e.pieceData[0],e.name);i.push({type:"wedge",cx:0,cy:0,innerRadius:s,outerRadius:a,startAngle:t,endAngle:n,style:o,datum:e.pieceData,category:e.name})}return i}function et(e){var t,n,o;const r=e.length,i=e[0],a=e[r-1];return{n:r,min:i,q1:null!==(t=w(e,.25))&&void 0!==t?t:i,median:null!==(n=w(e,.5))&&void 0!==n?n:(i+a)/2,q3:null!==(o=w(e,.75))&&void 0!==o?o:a,max:a,mean:e.reduce((e,t)=>e+t,0)/r}}Ke.displayName="StreamXYFrame";const tt={bar:function(e,t){const{scales:n,columns:o,config:r,getR:i,getStack:a,resolvePieceStyle:s}=e,{r:l,projection:c}=n,u=[],d="vertical"===c,h="horizontal"===c,g=r.normalize;for(const e of Object.values(o)){const t=new Map;for(const n of e.pieceData){const e=a?a(n):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const o=t.get(e);o.total+=i(n),o.pieces.push(n)}let n=0;if(g)for(const e of t.values())n+=Math.abs(e.total);let o=0,r=0;for(const[i,c]of t){let t=c.total;g&&n>0&&(t/=n);const p=s(c.pieces[0],a?i:e.name),y=Object.assign(Object.assign({},c.pieces[0]),{__aggregateValue:c.total,__pieceCount:c.pieces.length,category:e.name});if(d){const n=l(0>t?r:o+t),a=0>t?l(r+t)-l(r):l(o)-l(o+t);u.push(ce(e.x,n,e.width,Math.abs(a),p,y,i)),0>t?r+=t:o+=t}else if(h){const n=l(0>t?r+t:o),a=0>t?l(r)-l(r+t):l(o+t)-l(o);u.push(ce(n,e.x,Math.abs(a),e.width,p,y,i)),0>t?r+=t:o+=t}}}return u},clusterbar:function(e,t){const{scales:n,columns:o,getR:r,getGroup:i,resolvePieceStyle:a}=e,{r:s,projection:l}=n,c=[],u="vertical"===l,d=[],h=new Set;for(const e of Object.values(o))for(const t of e.pieceData){const e=i?i(t):"_default";h.has(e)||(h.add(e),d.push(e))}const g=d.length||1;for(const e of Object.values(o)){const t=e.width/g,n=new Map;for(const t of e.pieceData){const e=i?i(t):"_default";n.has(e)||n.set(e,[]),n.get(e).push(t)}for(let o=0;d.length>o;o++){const i=n.get(d[o])||[];for(const n of i){const i=r(n),l=a(n,e.name);if(u){const r=e.x+o*t,a=s(0),u=s(i);c.push(ce(r,Math.min(a,u),t,Math.abs(a-u),l,n,d[o]))}else{const r=e.x+o*t,a=s(0),u=s(i);c.push(ce(Math.min(a,u),r,Math.abs(u-a),t,l,n,d[o]))}}}}return c},point:function(e,t){var n,o;const{scales:r,columns:i,getR:a,multiScales:s,resolvePieceStyle:l}=e,{r:c,projection:u}=r,d=[],h="vertical"===u,g="radial"===u,p=s.length>0,y=2*Math.PI,f=-Math.PI/2;for(const e of Object.values(i))for(const t of e.pieceData){const r=null!==(n=t.__rIndex)&&void 0!==n?n:0,i=null!==(o=t.__rValue)&&void 0!==o?o:a(t),u=p&&s[r]||c,m=l(t,e.name),v=m.r||5;let b,x;if(g){const t=f+(e.pctStart+e.pct/2)*y,n=u(i);b=Math.cos(t)*n,x=Math.sin(t)*n}else h?(b=e.middle,x=u(i)):(b=u(i),x=e.middle);d.push({type:"point",x:b,y:x,r:v,style:m,datum:t})}return d},swarm:function(e,t){const{scales:n,columns:o,getR:r,resolvePieceStyle:i}=e,{r:a,projection:s}=n,l=[],c="vertical"===s;for(const e of Object.values(o)){const t=e.width/2;for(let n=0;e.pieceData.length>n;n++){const o=e.pieceData[n],s=r(o),u=i(o,e.name),d=u.r||4,h=(7919*n%100/100-.5)*t*.8,g=c?e.middle+h:a(s),p=c?a(s):e.middle+h;l.push({type:"point",x:g,y:p,r:d,style:u,datum:o})}}return l},pie:Je,donut:Je,boxplot:function(e,t){var n,o,r,i,a;const{scales:s,columns:l,config:c,getR:u,resolveSummaryStyle:d}=e,{r:h,projection:g}=s,p=[],y="vertical"===g,f=!1!==c.showOutliers;for(const e of Object.values(l)){const t=e.pieceData.map(e=>u(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(0===t.length)continue;const s=t[0],l=t[t.length-1],c=null!==(n=w(t,.25))&&void 0!==n?n:s,g=null!==(o=w(t,.5))&&void 0!==o?o:(s+l)/2,m=null!==(r=w(t,.75))&&void 0!==r?r:l,v=m-c,b=c-1.5*v,x=m+1.5*v,k=null!==(i=t.find(e=>e>=b))&&void 0!==i?i:s,A=null!==(a=[...t].reverse().find(e=>x>=e))&&void 0!==a?a:l,E=d(e.pieceData[0],e.name),S=[];if(f)for(const t of e.pieceData){const n=u(t);if(b>n||n>x){const o=y?e.middle:h(n),r=y?h(n):e.middle;S.push({px:o,py:r,value:n,datum:t})}}if(p.push({type:"boxplot",x:y?e.middle:0,y:y?0:e.middle,projection:y?"vertical":"horizontal",columnWidth:.6*e.width,minPos:h(k),q1Pos:h(c),medianPos:h(g),q3Pos:h(m),maxPos:h(A),stats:{min:k,q1:c,median:g,q3:m,max:A},style:E,datum:e.pieceData,category:e.name,outliers:S}),f)for(const e of S)p.push({type:"point",x:e.px,y:e.py,r:3,style:{fill:E.fill||"#999",opacity:.6},datum:e.datum})}return p},violin:function(e,t){var n,o,r;const{scales:i,columns:a,config:s,getR:l,resolveSummaryStyle:c}=e,{r:u,projection:d}=i,h=[],g="vertical"===d,p=s.bins||20,y=!1!==s.showIQR;for(const e of Object.values(a)){const t=e.pieceData.map(e=>l(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const i=t[0],a=t[t.length-1],s=(a-i)/p||1,d=Array(p).fill(0);for(const e of t)d[Math.min(Math.floor((e-i)/s),p-1)]++;const f=Math.max(...d,1),m=e.width/2*.9;let v="";if(g){for(let t=0;p>t;t++){const n=u(i+(t+.5)*s),o=d[t]/f*m;v+=0===t?`M ${e.middle+o} ${n}`:` L ${e.middle+o} ${n}`}for(let t=p-1;t>=0;t--){const n=u(i+(t+.5)*s);v+=` L ${e.middle-d[t]/f*m} ${n}`}v+=" Z"}else{for(let t=0;p>t;t++){const n=u(i+(t+.5)*s),o=d[t]/f*m;v+=0===t?`M ${n} ${e.middle-o}`:` L ${n} ${e.middle-o}`}for(let t=p-1;t>=0;t--)v+=` L ${u(i+(t+.5)*s)} ${e.middle+d[t]/f*m}`;v+=" Z"}const b=c(e.pieceData[0],e.name);let x;if(y&&t.length>=4){const s=null!==(n=w(t,.25))&&void 0!==n?n:i,l=null!==(o=w(t,.5))&&void 0!==o?o:(i+a)/2,c=null!==(r=w(t,.75))&&void 0!==r?r:a;x={q1Pos:u(s),medianPos:u(l),q3Pos:u(c),centerPos:e.middle,isVertical:g}}const k=g?{x:e.x,y:Math.min(u(a),u(i)),width:e.width,height:Math.abs(u(a)-u(i))}:{x:Math.min(u(i),u(a)),y:e.x,width:Math.abs(u(a)-u(i)),height:e.width};h.push({type:"violin",pathString:v,translateX:0,translateY:0,bounds:k,iqrLine:x,stats:et(t),style:b,datum:e.pieceData,category:e.name})}return h},histogram:function(e,t){const{scales:n,columns:o,config:r,getR:i,resolveSummaryStyle:a}=e,{r:s}=n,l=[],c=r.bins||25,u=r.normalize;for(const e of Object.values(o)){const t=e.pieceData.map(e=>i(e)).filter(e=>null!=e&&!isNaN(e));if(0===t.length)continue;const n=Math.min(...t),o=(Math.max(...t)-n)/c||1,r=Array(c).fill(0);for(const e of t)r[Math.min(Math.floor((e-n)/o),c-1)]++;const d=t.length,h=Math.max(...r,1),g=a(e.pieceData[0],e.name);for(let t=0;c>t;t++){if(0===r[t])continue;const i=(u?r[t]/d:r[t]/h)*e.width*.9,a=s(n+t*o),c=s(n+(t+1)*o);l.push(ce(Math.min(a,c),e.x+e.width-i,Math.abs(c-a),i,g,{bin:t,count:r[t],range:[n+t*o,n+(t+1)*o],category:e.name},e.name))}}return l},ridgeline:function(e,t){var n;const{scales:o,columns:r,config:i,getR:a,resolveSummaryStyle:s}=e,{r:l,projection:c}=o,u=[],d=i.bins||20,h="horizontal"===c,g=i.amplitude||1.5;for(const e of Object.values(r)){const t=e.pieceData.map(e=>a(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const o=t[0],r=t[t.length-1],i=(r-o)/d||1,c=Array(d).fill(0);for(const e of t)c[Math.min(Math.floor((e-o)/i),d-1)]++;const p=Math.max(...c,1),y=s(e.pieceData[0],e.name),f=e.width*g;let m="";if(h){const t=e.x+e.width;m=`M ${l(o)} ${t}`;for(let e=0;d>e;e++)m+=` L ${l(o+(e+.5)*i)} ${t-c[e]/p*f}`;m+=` L ${l(r)} ${t} Z`}else{const t=e.x;m=`M ${t} ${l(o)}`;for(let e=0;d>e;e++){const n=l(o+(e+.5)*i);m+=` L ${t+c[e]/p*f} ${n}`}m+=` L ${t} ${l(r)} Z`}const v=h?{x:Math.min(l(o),l(r)),y:e.x,width:Math.abs(l(r)-l(o)),height:e.width}:{x:e.x,y:Math.min(l(r),l(o)),width:e.width,height:Math.abs(l(r)-l(o))};u.push({type:"violin",pathString:m,translateX:0,translateY:0,bounds:v,stats:et(t),style:Object.assign(Object.assign({},y),{fillOpacity:null!==(n=y.fillOpacity)&&void 0!==n?n:.5}),datum:e.pieceData,category:e.name})}return u},timeline:function(e,t){const{scales:n,columns:o,getRawRange:r,resolvePieceStyle:i}=e,{r:a,projection:s}=n,l=[],c="horizontal"===s;for(const e of Object.values(o))for(const t of e.pieceData){const n=r(t);if(!n)continue;const[o,s]=n,u=i(t,e.name);if(c){const n=a(Math.min(o,s)),r=a(Math.max(o,s));l.push(ce(n,e.x,r-n,e.width,u,t,e.name))}else{const n=a(Math.max(o,s)),r=a(Math.min(o,s));l.push(ce(e.x,n,e.width,r-n,u,t,e.name))}}return l}};class nt{constructor(e){this.rExtent=new re,this.rExtents=[],this.rAccessors=[],this.categories=new Set,this._colorSchemeMap=null,this._colorSchemeIndex=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.lastIngestTime=0,this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.version=0,this.config=e,this.buffer=new oe(e.windowSize),this.getO=he(e.oAccessor||e.categoryAccessor,"category");const t="streaming"===e.runtimeMode,n=e.rAccessor;Array.isArray(n)?(this.rAccessors=n.map(e=>de(e,"value")),this.getR=this.rAccessors[0],this.rExtents=n.map(()=>new re)):(this.getR=de(t&&(e.timeAccessor||e.valueAccessor)&&e.valueAccessor||n,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=he(e.stackBy),this.getGroup=he(e.groupBy),this.getColor=he(e.colorAccessor),this.getConnector=he(e.connectorAccessor),e.pulse&&(this.timestampBuffer=new oe(e.windowSize))}ingest(e){const t="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=t,e.bounded){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const n=e.totalSize||e.inserts.length;n>this.buffer.capacity&&(this.buffer.resize(n),this.timestampBuffer&&n>this.timestampBuffer.capacity&&this.timestampBuffer.resize(n));for(const n of e.inserts)this.buffer.push(n),this.timestampBuffer&&this.timestampBuffer.push(t),this.categories.add(this.getO(n)),this.pushValueExtent(n)}else for(const n of e.inserts){const e=this.buffer.push(n);this.timestampBuffer&&this.timestampBuffer.push(t),this.categories.add(this.getO(n)),this.pushValueExtent(n),null!=e&&this.evictValueExtent(e)}return!0}pushValueExtent(e){if("timeline"===this.config.chartType){const t=this.getRawRange(e);t&&(this.rExtent.push(t[0]),this.rExtent.push(t[1]))}else if(this.rAccessors.length>1){for(let t=0;this.rAccessors.length>t;t++)this.rExtents[t].push(this.rAccessors[t](e));this.rExtent.push(this.getR(e))}else this.rExtent.push(this.getR(e))}evictValueExtent(e){if("timeline"===this.config.chartType){const t=this.getRawRange(e);t&&(this.rExtent.evict(t[0]),this.rExtent.evict(t[1]))}else if(this.rAccessors.length>1){for(let t=0;this.rAccessors.length>t;t++)this.rExtents[t].evict(this.rAccessors[t](e));this.rExtent.evict(this.getR(e))}else this.rExtent.evict(this.getR(e))}getRawRange(e){const t=this.config.rAccessor;if(!t)return null;const n="function"==typeof t?t(e):e[t];return Array.isArray(n)&&n.length>=2?[+n[0],+n[1]]:null}computeScene(e){const{config:t,buffer:n}=this;if(0===n.size)return this.scales=null,this.scene=[],this.columns={},void this.version++;this.rExtent.dirty&&this.rExtent.recalculate(n,this.getR);const o=n.toArray(),r=t.projection||"vertical",i=t.oExtent||this.resolveCategories(o),a=this.computeValueDomain(o,i),s="horizontal"===r,l=null!=t.barPadding?t.barPadding/("vertical"===r?e.width:e.height):.1;let c,u;if("radial"===r){c=m().domain(i).range([0,1]).padding(0);const n=Math.min(e.width,e.height)/2,o=t.innerRadius||0;u=f().domain(a).range([o,n])}else s?(c=m().domain(i).range([0,e.height]).padding(l),u=f().domain(a).range([0,e.width])):(c=m().domain(i).range([0,e.width]).padding(l),u=f().domain(a).range([e.height,0]));this.scales={o:c,r:u,projection:r},this.multiScales=this.rAccessors.length>1&&t.multiAxis?this.rAccessors.map((o,r)=>{const i=this.rExtents[r];i.dirty&&i.recalculate(n,o);let[a,l]=i.extent;a===1/0&&(a=0,l=1);const c=l-a,u=c>0?c*(t.extentPadding||.05):1;return a-=u,l+=u,a>0&&(a=0),s?f().domain([a,l]).range([0,e.width]):f().domain([a,l]).range([e.height,0])}):[];let d=o;this.rAccessors.length>1&&(d=o.flatMap(e=>this.rAccessors.map((t,n)=>Object.assign(Object.assign({},e),{__rIndex:n,__rValue:t(e),__rName:this.resolveRAccessorName(n)})))),this.columns=this.buildColumns(d,i,c,r,e),this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(d,e),this.config.decay&&this.applyDecay(this.scene,o),this.config.pulse&&this.applyPulse(this.scene,o),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++}resolveRAccessorName(e){const t=Array.isArray(this.config.rAccessor)?this.config.rAccessor[e]:this.config.rAccessor;return"string"==typeof t?t:"value"+e}resolveCategories(e){const t=Array.from(this.categories),n=this.config.oSort;if("streaming"===this.config.runtimeMode&&void 0===n)return t;if(!1===n)return t;if("function"==typeof n)return t.sort(n);const o=new Map;for(const t of e){const e=this.getO(t);o.set(e,(o.get(e)||0)+Math.abs(this.getR(t)))}return t.sort("asc"===n?(e,t)=>(o.get(e)||0)-(o.get(t)||0):(e,t)=>(o.get(t)||0)-(o.get(e)||0))}computeValueDomain(e,t){var n,o;const r=this.config.chartType,i=this.config.extentPadding||.05;if("radial"===this.config.projection&&("pie"===r||"donut"===r))return[0,1];let a=0,s=0;if("bar"===r&&this.getStack){const t=new Map,n=new Map;for(const o of e){const e=this.getO(o),r=this.getR(o);0>r?n.set(e,(n.get(e)||0)+r):t.set(e,(t.get(e)||0)+r)}for(const e of t.values())e>s&&(s=e);for(const e of n.values())a>e&&(a=e)}else if("bar"===r){const t=new Map;for(const n of e){const e=this.getO(n),o=this.getR(n);t.set(e,(t.get(e)||0)+o)}for(const e of t.values())e>s&&(s=e),a>e&&(a=e)}else if("clusterbar"===r)for(const t of e){const e=this.getR(t);e>s&&(s=e),a>e&&(a=e)}else{const e=this.rExtent.extent[0],t=this.rExtent.extent[1];e!==1/0&&(a=e),t!==-1/0&&(s=t)}this.config.rExtent&&(null!=this.config.rExtent[0]&&(a=this.config.rExtent[0]),null!=this.config.rExtent[1]&&(s=this.config.rExtent[1]));const l=s-a,c=l>0?l*i:1;return(null===(n=this.config.rExtent)||void 0===n?void 0:n[0])||(a-=c),(null===(o=this.config.rExtent)||void 0===o?void 0:o[1])||(s+=c),"bar"!==r&&"clusterbar"!==r||(a>0&&(a=0),0>s&&(s=0)),[a,s]}buildColumns(e,t,n,o,r){var i;const a={},s=new Map;for(const t of e){const e=this.getO(t);s.has(e)||s.set(e,[]),s.get(e).push(t)}let l=0;if("radial"===o)for(const t of e)l+=Math.abs(this.getR(t));const c=this.config.dynamicColumnWidth;let u=null;if(c&&"radial"!==o){u=new Map;let e=0;for(const n of t){const t=s.get(n)||[];let o;o="string"==typeof c?t.reduce((e,t)=>e+(Number(t[c])||0),0):c(t),u.set(n,o),e+=o}const i=("horizontal"===o?r.height:r.width)-n.padding()*n.step()*t.length;if(e>0)for(const[t,n]of u)u.set(t,n/e*i)}let d=0,h=0;for(const e of t){const t=s.get(e)||[],o=t.reduce((e,t)=>e+Math.abs(this.getR(t)),0),r=l>0?o/l:0;let c,g;u?(c=h,g=u.get(e)||n.bandwidth(),h+=g+n.padding()*n.step()):(c=null!==(i=n(e))&&void 0!==i?i:0,g=n.bandwidth()),a[e]={name:e,x:c,y:0,width:g,middle:c+g/2,padding:n.padding()*n.step(),pieceData:t,pct:r,pctStart:d},d+=r}return a}getSceneContext(){return{scales:this.scales,columns:this.columns,config:this.config,getR:this.getR,getStack:this.getStack,getGroup:this.getGroup,getColor:this.getColor,getConnector:this.getConnector,getO:this.getO,multiScales:this.multiScales,rAccessors:this.rAccessors,resolvePieceStyle:(e,t)=>this.resolvePieceStyle(e,t),resolveSummaryStyle:(e,t)=>this.resolveSummaryStyle(e,t),getRawRange:e=>this.getRawRange(e)}}buildSceneNodes(e,t){if(!this.scales)return[];const n=this.getSceneContext(),o=tt[this.config.chartType];let r=o?o(n,t):[];if(this.getConnector&&this.scales){const e=function(e,t){const{scales:n,config:o,getConnector:r,getO:i}=e;if(!r||!n)return[];const a=[],{projection:s}=n,l=new Map;for(const e of t){if("point"!==e.type&&"rect"!==e.type)continue;const t=e.datum;if(!t)continue;const n=r(t);if(!n)continue;let o,a;"point"===e.type?(o=e.x,a=e.y):(o=e.x+e.w/2,a=e.y+("vertical"===s?0:e.h/2)),l.has(n)||l.set(n,[]),l.get(n).push({x:o,y:a,datum:t,category:i(t)})}const c=n.o.domain(),u=o.connectorStyle;for(const[e,t]of l)if(t.length>=2){t.sort((e,t)=>c.indexOf(e.category)-c.indexOf(t.category));for(let n=0;t.length-1>n;n++){const o=t[n],r=t[n+1],i="function"==typeof u?u(o.datum):u||{stroke:"#999",strokeWidth:1,opacity:.5};a.push({type:"connector",x1:o.x,y1:o.y,x2:r.x,y2:r.y,style:i,datum:o.datum,group:e})}}return a}(n,r);r=[...e,...r]}return r}resolvePieceStyle(e,t){return"function"==typeof this.config.pieceStyle?this.config.pieceStyle(e,t):this.config.pieceStyle&&"object"==typeof this.config.pieceStyle?this.config.pieceStyle:this.config.barColors&&t?{fill:this.config.barColors[t]||"#007bff"}:t?{fill:this.getColorFromScheme(t)}:{fill:"#007bff"}}getColorFromScheme(e){this._colorSchemeMap||(this._colorSchemeMap=new Map);const t=this._colorSchemeMap.get(e);if(t)return t;const n=Array.isArray(this.config.colorScheme)?this.config.colorScheme:["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],o=n[this._colorSchemeIndex%n.length];return this._colorSchemeIndex++,this._colorSchemeMap.set(e,o),o}resolveSummaryStyle(e,t){return"function"==typeof this.config.summaryStyle?this.config.summaryStyle(e,t):this.config.summaryStyle&&"object"==typeof this.config.summaryStyle?this.config.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}computeDecayOpacity(e,t){var n,o,r;const i=this.config.decay;if(!i||1>=t)return 1;const a=null!==(n=i.minOpacity)&&void 0!==n?n:.1,s=t-1-e;switch(i.type){case"linear":return a+(1-s/(t-1))*(1-a);case"exponential":{const e=null!==(o=i.halfLife)&&void 0!==o?o:t/2;return a+Math.pow(.5,s/e)*(1-a)}case"step":return(null!==(r=i.stepThreshold)&&void 0!==r?r:.5*t)>s?1:a;default:return 1}}applyDecay(e,t){var n,o;if(!this.config.decay)return;const r=t.length;if(1>=r)return;const i=new Map;for(let e=0;t.length>e;e++)i.set(t[e],e);for(const t of e){if("connector"===t.type||"violin"===t.type||"boxplot"===t.type||"wedge"===t.type)continue;const e=i.get(t.datum);if(null==e)continue;const a=this.computeDecayOpacity(e,r),s=null!==(o=null===(n=t.style)||void 0===n?void 0:n.opacity)&&void 0!==o?o:1;t.style=Object.assign(Object.assign({},t.style),{opacity:s*a})}}applyPulse(e,t){var n,o,r;if(!this.config.pulse||!this.timestampBuffer)return;const i="undefined"!=typeof performance?performance.now():Date.now(),a=null!==(n=this.config.pulse.duration)&&void 0!==n?n:500,s=null!==(o=this.config.pulse.color)&&void 0!==o?o:"rgba(255,255,255,0.6)",l=null!==(r=this.config.pulse.glowRadius)&&void 0!==r?r:4,c=new Map;for(let e=0;t.length>e;e++)c.set(t[e],e);for(const t of e){if("connector"===t.type||"violin"===t.type||"boxplot"===t.type||"wedge"===t.type)continue;const e=c.get(t.datum);if(null==e)continue;const n=this.timestampBuffer.get(e);if(null==n)continue;const o=i-n;a>o&&(t._pulseIntensity=1-o/a,t._pulseColor=s,t._pulseGlowRadius=l)}}get hasActivePulses(){var e;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const t="undefined"!=typeof performance?performance.now():Date.now(),n=null!==(e=this.config.pulse.duration)&&void 0!==e?e:500,o=this.timestampBuffer.peek();return null!=o&&n>t-o}snapshotPositions(){var e,t;this.prevPositionMap.clear();for(let n=0;this.scene.length>n;n++){const o=this.scene[n];if("point"===o.type)this.prevPositionMap.set("p:"+n,{x:o.x,y:o.y,r:o.r});else if("rect"===o.type){const r=`r:${o.group||""}:${null!==(t=null===(e=o.datum)||void 0===e?void 0:e.category)&&void 0!==t?t:n}`;this.prevPositionMap.set(r,{x:o.x,y:o.y,w:o.w,h:o.h})}}}startTransition(){var e,t,n,o,r;if(!this.config.transition||0===this.prevPositionMap.size)return;const i=null!==(e=this.config.transition.duration)&&void 0!==e?e:300;let a=!1;for(let e=0;this.scene.length>e;e++){const i=this.scene[e];let s=null;if("point"===i.type?s="p:"+e:"rect"===i.type&&(s=`r:${i.group||""}:${null!==(n=null===(t=i.datum)||void 0===t?void 0:t.category)&&void 0!==n?n:e}`),!s)continue;const l=this.prevPositionMap.get(s);l&&("point"===i.type?l.x===i.x&&l.y===i.y||(i._targetX=i.x,i._targetY=i.y,i.x=l.x,i.y=l.y,a=!0):"rect"===i.type&&(l.x===i.x&&l.y===i.y&&l.w===i.w&&l.h===i.h||(i._targetX=i.x,i._targetY=i.y,i._targetW=i.w,i._targetH=i.h,i.x=l.x,i.y=l.y,i.w=null!==(o=l.w)&&void 0!==o?o:i.w,i.h=null!==(r=l.h)&&void 0!==r?r:i.h,a=!0)))}a&&(this.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:i})}advanceTransition(e){var t,n,o;if(!this.activeTransition)return!1;const r=Math.min((e-this.activeTransition.startTime)/this.activeTransition.duration,1),i="linear"===(null===(t=this.config.transition)||void 0===t?void 0:t.easing)?r:1-Math.pow(1-r,3);for(const e of this.scene)if("point"===e.type){if(void 0===e._targetX)continue;const t=this.prevPositionMap.get("p:0");if(!t)continue;e.x=t.x+(e._targetX-t.x)*i,e.y=t.y+(e._targetY-t.y)*i}else if("rect"===e.type){if(void 0===e._targetX)continue;const t=`r:${e.group||""}:${null!==(o=null===(n=e.datum)||void 0===n?void 0:n.category)&&void 0!==o?o:0}`,r=this.prevPositionMap.get(t);if(!r)continue;e.x=r.x+(e._targetX-r.x)*i,e.y=r.y+(e._targetY-r.y)*i,void 0!==r.w&&(e.w=r.w+(e._targetW-r.w)*i,e.h=r.h+(e._targetH-r.h)*i)}if(r>=1){for(const e of this.scene)if("point"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e._targetX=void 0,e._targetY=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}return this.activeTransition=null,!1}return!0}getData(){return this.buffer.toArray()}clear(){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],this.columns={},this.version++}get size(){return this.buffer.size}getOAccessor(){return this.getO}getRAccessor(){return this.getR}updateConfig(e){e.colorScheme!==this.config.colorScheme&&(this._colorSchemeMap=null,this._colorSchemeIndex=0),Object.assign(this.config,e)}}function ot(e,t,n){return e.x>t||t>e.x+e.w||e.y>n||n>e.y+e.h?null:{datum:e.datum,x:e.x+e.w/2,y:e.y,distance:0,category:e.group}}function rt(e,t,n){const o=t-e.x,r=n-e.y,i=Math.sqrt(o*o+r*r);return i>Math.max(e.r,5)?null:{datum:e.datum,x:e.x,y:e.y,distance:i}}function it(e,t,n){const o=t-e.cx,r=n-e.cy,i=Math.sqrt(o*o+r*r);if(e.innerRadius>i||i>e.outerRadius)return null;let a=Math.atan2(r,o);0>a&&(a+=2*Math.PI);let s=e.startAngle%(2*Math.PI),l=e.endAngle%(2*Math.PI);if(0>s&&(s+=2*Math.PI),0>l&&(l+=2*Math.PI),!(s>l?a>=s||l>=a:a>=s&&l>=a))return null;const c=(e.startAngle+e.endAngle)/2,u=(e.innerRadius+e.outerRadius)/2;return{datum:e.datum,x:e.cx+Math.cos(c)*u,y:e.cy+Math.sin(c)*u,distance:0,category:e.category}}function at(e,t,n){const o=e.columnWidth/2,r=e.stats?Object.assign(Object.assign({},e.stats),{n:Array.isArray(e.datum)?e.datum.length:0,mean:(e.stats.q1+e.stats.median+e.stats.q3)/3}):void 0;if("vertical"===e.projection){if(!(e.x-o>t||t>e.x+o||Math.min(e.minPos,e.maxPos)>n||n>Math.max(e.minPos,e.maxPos)))return{datum:e.datum,x:e.x,y:e.medianPos,distance:0,category:e.category,stats:r}}else{const i=e.y-o,a=e.y+o;if(!(Math.min(e.minPos,e.maxPos)>t||t>Math.max(e.minPos,e.maxPos)||i>n||n>a))return{datum:e.datum,x:e.medianPos,y:e.y,distance:0,category:e.category,stats:r}}return null}function st(e,t,n){if(!e.bounds)return null;const{x:o,y:r,width:i,height:a}=e.bounds;return o>t||t>o+i||r>n||n>r+a?null:{datum:e.datum,x:o+i/2,y:r+a/2,distance:0,category:e.category,stats:e.stats}}function lt(e){return Math.round(100*e)/100+""}function ct(t){const{width:n,height:o,totalWidth:i,totalHeight:a,margin:s,scales:l,showAxes:c,oLabel:u,rLabel:d,oFormat:h,rFormat:g,showGrid:p,title:y,legend:f,foregroundGraphics:m,annotations:v,svgAnnotationRules:b,annotationFrame:x,xAccessor:w,yAccessor:k,annotationData:A,children:E}=t,S="radial"===(null==l?void 0:l.projection),O="horizontal"===(null==l?void 0:l.projection),L=r(()=>c&&l&&!S?l.o.domain().map(e=>{var t;return{value:e,pixel:(null!==(t=l.o(e))&&void 0!==t?t:0)+l.o.bandwidth()/2,label:h?h(e):e}}):[],[c,l,h,S]),j=r(()=>c&&l&&!S?l.r.ticks(5).map(e=>({value:e,pixel:l.r(e),label:(g||lt)(e)})):[],[c,l,g,S]),P=r(()=>{if(!v||0===v.length)return null;const e=We(),t={scales:l?{x:l.r,y:l.r,time:l.r,value:l.r}:null,timeAxis:"x",xAccessor:w,yAccessor:k,width:n,height:o,data:A,frameType:"ordinal"};return v.map((n,o)=>{if(b){const r=b(n,o,t);return null!=r?r:e(n,o,t)}return e(n,o,t)}).filter(Boolean)},[v,b,n,o,x,w,k,A]);return c||y||f||m||P&&P.length>0||p||E?e.createElement("svg",{width:i,height:a,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},e.createElement("g",{transform:`translate(${s.left},${s.top})`},p&&l&&!S&&e.createElement("g",{className:"ordinal-grid"},j.map((t,r)=>e.createElement("line",{key:"grid-"+r,x1:O?t.pixel:0,y1:O?0:t.pixel,x2:O?t.pixel:n,y2:O?o:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),c&&l&&!S&&e.createElement("g",{className:"ordinal-axes"},O?e.createElement(e.Fragment,null,e.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),L.map((t,n)=>e.createElement("g",{key:"cat-"+n,transform:`translate(0,${t.pixel})`},e.createElement("line",{x2:-5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),e.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"}},t.label))),u&&e.createElement("text",{x:15-s.left,y:o/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",transform:`rotate(-90, ${15-s.left}, ${o/2})`,style:{userSelect:"none"}},u),e.createElement("line",{x1:0,y1:o,x2:n,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),j.map((t,n)=>e.createElement("g",{key:"val-"+n,transform:`translate(${t.pixel},${o})`},e.createElement("line",{y2:5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),e.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"}},t.label))),d&&e.createElement("text",{x:n/2,y:o+40,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},d)):e.createElement(e.Fragment,null,e.createElement("line",{x1:0,y1:o,x2:n,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),L.map((t,n)=>e.createElement("g",{key:"cat-"+n,transform:`translate(${t.pixel},${o})`},e.createElement("line",{y2:5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),e.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"}},t.label))),u&&e.createElement("text",{x:n/2,y:o+40,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},u),e.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),j.map((t,n)=>e.createElement("g",{key:"val-"+n,transform:`translate(0,${t.pixel})`},e.createElement("line",{x2:-5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),e.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"}},t.label))),d&&e.createElement("text",{x:15-s.left,y:o/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",transform:`rotate(-90, ${15-s.left}, ${o/2})`,style:{userSelect:"none"}},d))),P,m,E),y&&e.createElement("text",{x:i/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof y?y:null),f&&e.createElement("g",{transform:`translate(${i-s.right+10}, ${s.top})`},function(t){return"object"==typeof t&&null!==t&&!e.isValidElement(t)&&"legendGroups"in t}(f)?e.createElement(Oe,{legendGroups:f.legendGroups,title:"",width:100}):f)):null}const ut=(e,t,n,o)=>{const r=t.filter(e=>"wedge"===e.type);for(const t of r)e.beginPath(),t.innerRadius>0?(e.arc(t.cx,t.cy,t.outerRadius,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerRadius,t.endAngle,t.startAngle,!0)):(e.moveTo(t.cx,t.cy),e.arc(t.cx,t.cy,t.outerRadius,t.startAngle,t.endAngle)),e.closePath(),null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),null!=t.style.fillOpacity&&(e.globalAlpha=t.style.fillOpacity),e.fillStyle=t.style.fill||"#007bff",e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()),e.globalAlpha=1},dt=(e,t,n,o)=>{var r,i;const a=t.filter(e=>"violin"===e.type);for(const t of a){e.save(),(t.translateX||t.translateY)&&e.translate(t.translateX,t.translateY);const n=new Path2D(t.pathString);if(e.globalAlpha=null!==(i=null!==(r=t.style.fillOpacity)&&void 0!==r?r:t.style.opacity)&&void 0!==i?i:.6,e.fillStyle=t.style.fill||"#007bff",e.fill(n),e.globalAlpha=1,t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke(n)),t.iqrLine){e.strokeStyle="#333",e.lineWidth=2,e.globalAlpha=.8;const n=t.iqrLine.centerPos,o=!1!==t.iqrLine.isVertical;e.beginPath(),o?(e.moveTo(n,t.iqrLine.q1Pos),e.lineTo(n,t.iqrLine.q3Pos)):(e.moveTo(t.iqrLine.q1Pos,n),e.lineTo(t.iqrLine.q3Pos,n)),e.stroke(),e.beginPath(),o?e.arc(n,t.iqrLine.medianPos,3,0,2*Math.PI):e.arc(t.iqrLine.medianPos,n,3,0,2*Math.PI),e.fillStyle="#fff",e.fill(),e.strokeStyle="#333",e.lineWidth=1,e.stroke(),e.globalAlpha=1}e.restore()}},ht=(e,t,n,o)=>{var r,i,a;const s=t.filter(e=>"connector"===e.type);if(0===s.length)return;const l=new Map;for(const e of s){const t=e.group||"_default";l.has(t)||l.set(t,[]),l.get(t).push(e)}for(const[,t]of l){if(0===t.length)continue;const n=t[0].style;if(n.fill&&"none"!==n.fill){e.beginPath(),e.moveTo(t[0].x1,t[0].y1);for(const n of t)e.lineTo(n.x2,n.y2);e.closePath(),e.globalAlpha=null!==(i=null!==(r=n.fillOpacity)&&void 0!==r?r:n.opacity)&&void 0!==i?i:.3,e.fillStyle=n.fill,e.fill(),e.globalAlpha=1}for(const n of t)e.beginPath(),e.moveTo(n.x1,n.y1),e.lineTo(n.x2,n.y2),e.strokeStyle=n.style.stroke||n.style.fill||"#999",e.lineWidth=n.style.strokeWidth||1,e.globalAlpha=null!==(a=n.style.opacity)&&void 0!==a?a:.5,e.stroke(),e.globalAlpha=1}},gt=e=>[ht,...e],pt={bar:gt([Ye]),clusterbar:gt([Ye]),point:gt([Fe]),swarm:gt([Fe]),pie:[ut],donut:[ut],boxplot:gt([(e,t,n,o)=>{var r,i;const a=t.filter(e=>"boxplot"===e.type);for(const t of a){const n=t.columnWidth/2,o="vertical"===t.projection,a=t.style.fill||"#007bff",s=t.style.stroke||"#333",l=t.style.strokeWidth||1,c=null!==(i=null!==(r=t.style.fillOpacity)&&void 0!==r?r:t.style.opacity)&&void 0!==i?i:.6;if(e.save(),e.strokeStyle=s,e.lineWidth=l,e.beginPath(),o?(e.moveTo(t.x,t.minPos),e.lineTo(t.x,t.maxPos)):(e.moveTo(t.minPos,t.y),e.lineTo(t.maxPos,t.y)),e.stroke(),e.beginPath(),o?(e.moveTo(t.x-.4*n,t.minPos),e.lineTo(t.x+.4*n,t.minPos),e.moveTo(t.x-.4*n,t.maxPos),e.lineTo(t.x+.4*n,t.maxPos)):(e.moveTo(t.minPos,t.y-.4*n),e.lineTo(t.minPos,t.y+.4*n),e.moveTo(t.maxPos,t.y-.4*n),e.lineTo(t.maxPos,t.y+.4*n)),e.stroke(),e.globalAlpha=c,e.fillStyle=a,o){const o=Math.min(t.q1Pos,t.q3Pos),r=Math.abs(t.q3Pos-t.q1Pos);e.fillRect(t.x-n,o,t.columnWidth,r),e.globalAlpha=1,e.strokeRect(t.x-n,o,t.columnWidth,r)}else{const o=Math.min(t.q1Pos,t.q3Pos),r=Math.abs(t.q3Pos-t.q1Pos);e.fillRect(o,t.y-n,r,t.columnWidth),e.globalAlpha=1,e.strokeRect(o,t.y-n,r,t.columnWidth)}e.strokeStyle="#fff",e.lineWidth=2,e.beginPath(),o?(e.moveTo(t.x-n,t.medianPos),e.lineTo(t.x+n,t.medianPos)):(e.moveTo(t.medianPos,t.y-n),e.lineTo(t.medianPos,t.y+n)),e.stroke(),e.restore()}},Fe]),violin:gt([dt]),histogram:gt([Ye]),ridgeline:gt([dt]),timeline:gt([Ye])},yt={top:50,right:40,bottom:60,left:70},ft={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:"4px",fontSize:"13px",lineHeight:"1.4",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function mt({hover:t}){var n,o,r,i;const a=t.data||{},s=t.stats,l=t.category;if(Array.isArray(a)){const t=l||(null===(n=a[0])||void 0===n?void 0:n.category)||"";if(s)return e.createElement("div",{className:"semiotic-tooltip",style:ft},t&&e.createElement("div",{style:{fontWeight:"bold"}},t+""),e.createElement("div",null,"n = ",s.n),e.createElement("div",null,"Min: ",s.min.toLocaleString()),e.createElement("div",null,"Q1: ",s.q1.toLocaleString()),e.createElement("div",null,"Median: ",s.median.toLocaleString()),e.createElement("div",null,"Q3: ",s.q3.toLocaleString()),e.createElement("div",null,"Max: ",s.max.toLocaleString()),e.createElement("div",{style:{opacity:.8}},"Mean: ",s.mean.toLocaleString(void 0,{maximumFractionDigits:2})));const o=a.length;return e.createElement("div",{className:"semiotic-tooltip",style:ft},t&&e.createElement("div",{style:{fontWeight:"bold"}},t+""),e.createElement("div",null,o," items"))}if(null!=a.bin&&null!=a.count){const t=a.range||[];return e.createElement("div",{className:"semiotic-tooltip",style:ft},a.category&&e.createElement("div",{style:{fontWeight:"bold"}},a.category+""),e.createElement("div",null,"Count: ",a.count),2===t.length&&e.createElement("div",{style:{opacity:.8}},Number(t[0]).toFixed(1)," – ",Number(t[1]).toFixed(1)))}const c=a.category||a.name||a.group||a.__rName||"",u=null!==(i=null!==(r=null!==(o=a.value)&&void 0!==o?o:a.__rValue)&&void 0!==r?r:a.pct)&&void 0!==i?i:"";if(!c&&""===u){const t=Object.entries(a).filter(([e])=>!e.startsWith("_")&&"data"!==e);return e.createElement("div",{className:"semiotic-tooltip",style:ft},t.map(([t,n])=>e.createElement("div",{key:t},e.createElement("span",{style:{opacity:.7}},t,":")," ","number"==typeof n?n.toLocaleString():n+"")))}return e.createElement("div",{className:"semiotic-tooltip",style:ft},c&&e.createElement("div",{style:{fontWeight:"bold"}},c+""),""!==u&&e.createElement("div",null,"number"==typeof u?u.toLocaleString():u+""))}const vt=i(function(i,l){var c;const{chartType:u,runtimeMode:d,data:h,oAccessor:g="category",rAccessor:p="value",colorAccessor:y,stackBy:f,groupBy:m,multiAxis:v,timeAccessor:b,valueAccessor:x,categoryAccessor:w,projection:k="vertical",size:A=[600,400],responsiveWidth:E,responsiveHeight:S,margin:O,barPadding:L,innerRadius:j,normalize:P,startAngle:M,dynamicColumnWidth:N,bins:D,showOutliers:C,showIQR:T,amplitude:B,connectorAccessor:W,connectorStyle:H,rExtent:$,oExtent:_,extentPadding:z=.05,oSort:I,windowMode:R="sliding",windowSize:F=200,pieceStyle:Y,summaryStyle:G,colorScheme:X,barColors:q,showAxes:V=!0,oLabel:U,rLabel:Z,oFormat:Q,rFormat:K,enableHover:J=!0,hoverAnnotation:ee,tooltipContent:te,customHoverBehavior:oe,annotations:re,svgAnnotationRules:ie,showGrid:ae=!1,legend:se,backgroundGraphics:le,foregroundGraphics:ce,title:ue,className:de,background:he,centerContent:ge,decay:pe,pulse:ye,transition:fe,staleness:me}=i,[ve,be]=Ae(A,E,S),xe=r(()=>Object.assign(Object.assign({},yt),O),[O]),Ee=be[0]-xe.left-xe.right,Se=be[1]-xe.top-xe.bottom,Oe=t(null),Le=t(!0),je=t(0),Pe=t(null),Me=t(()=>{}),[Ne,De]=n(null),[Ce,Te]=n(null),[Be,We]=n(0),[He,$e]=n(!1),_e=J||ee,ze="streaming"===d,Ie=r(()=>({chartType:u,runtimeMode:ze?"streaming":"bounded",windowSize:F,windowMode:R,extentPadding:z,projection:k,oAccessor:ze?void 0:g,rAccessor:ze?void 0:p,colorAccessor:y,stackBy:f,groupBy:m,multiAxis:v,timeAccessor:ze?b:void 0,valueAccessor:ze?x||("string"==typeof p||"function"==typeof p?p:void 0):void 0,categoryAccessor:ze?w||g:void 0,rExtent:$,oExtent:_,barPadding:L,innerRadius:j,normalize:P,startAngle:M,dynamicColumnWidth:N,bins:D,showOutliers:C,showIQR:T,amplitude:B,connectorAccessor:W,connectorStyle:H,oSort:I,pieceStyle:Y,summaryStyle:G,colorScheme:X,barColors:q,decay:pe,pulse:ye,transition:fe,staleness:me}),[u,F,R,z,k,g,p,y,f,m,v,b,x,w,$,_,L,j,P,M,N,D,C,T,B,W,H,I,Y,G,X,q,pe,ye,fe,me,ze]),Re=t(null);Re.current||(Re.current=new nt(Ie));const Fe=a(()=>{je.current||(je.current=requestAnimationFrame(()=>Me.current()))},[]);o(()=>{var e;null===(e=Re.current)||void 0===e||e.updateConfig(Ie),Le.current=!0,Fe()},[Ie,Fe]);const Ye=t(null);Ye.current||(Ye.current=new ne(e=>{const t=Re.current;t&&t.ingest(e)&&(Le.current=!0,Fe())}));const Ge=a(e=>{var t;null===(t=Ye.current)||void 0===t||t.push(e)},[]),Xe=a(e=>{var t;null===(t=Ye.current)||void 0===t||t.pushMany(e)},[]),qe=a(()=>{var e,t;null===(e=Ye.current)||void 0===e||e.clear(),null===(t=Re.current)||void 0===t||t.clear(),Le.current=!0,Fe()},[Fe]);s(l,()=>({push:Ge,pushMany:Xe,clear:qe,getData:()=>{var e,t;return null!==(t=null===(e=Re.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=Re.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null}}),[Ge,Xe,qe]),o(()=>{var e;h&&(null===(e=Ye.current)||void 0===e||e.setBoundedData(h))},[h]);const Ve=t(()=>{}),Ue=t(()=>{});Ve.current=e=>{if(!_e)return;const t=Oe.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-xe.left,r=e.clientY-n.top-xe.top;if(0>o||o>Ee||0>r||r>Se)return void(Pe.current&&(Pe.current=null,De(null),oe&&oe(null),Fe()));const i=Re.current;if(!i||0===i.scene.length)return;const a="radial"===k,s=function(e,t,n,o=30){let r=null;for(const i of e){let e=null;switch(i.type){case"rect":e=ot(i,t,n);break;case"point":e=rt(i,t,n);break;case"wedge":e=it(i,t,n);break;case"boxplot":e=at(i,t,n);break;case"violin":e=st(i,t,n)}e&&o>e.distance&&(r&&e.distance>=r.distance||(r=e))}return r}(i.scene,a?o-Ee/2:o,a?r-Se/2:r);if(!s)return void(Pe.current&&(Pe.current=null,De(null),oe&&oe(null),Fe()));const l=Object.assign(Object.assign({data:s.datum,time:s.x,value:s.y,x:s.x,y:s.y},s.stats&&{stats:s.stats}),s.category&&{category:s.category});Pe.current=l,De(l),oe&&(oe(l),Le.current=!0),Fe()},Ue.current=()=>{Pe.current&&(Pe.current=null,De(null),oe&&(oe(null),Le.current=!0),Fe())},a(e=>Ve.current(e),[]);const Ze=a(()=>Ue.current(),[]),Qe=t(-1),Ke=a(e=>{const t=Re.current;if(!t||0===t.scene.length)return;const n=function(e){const t=[];for(const n of e)if("rect"===n.type&&null!=n.x)t.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum});else if("point"===n.type)t.push({x:n.x,y:n.y,datum:n.datum});else if("wedge"===n.type&&null!=n.cx){const e=((n.startAngle||0)+(n.endAngle||0))/2,o=((n.innerRadius||0)+(n.outerRadius||50))/2;t.push({x:n.cx+Math.cos(e)*o,y:n.cy+Math.sin(e)*o,datum:n.datum})}return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}(t.scene);if(0===n.length)return;const o=Qe.current,r=we(e.key,0>o?-1:o,n.length);if(null===r)return;if(e.preventDefault(),0>r)return Qe.current=-1,Pe.current=null,De(null),oe&&oe(null),void Fe();const i=0>o?0:r;Qe.current=i;const a=ke(n[i]);Pe.current=a,De(a),oe&&oe(a),Fe()},[oe,Fe]),Je=a(e=>{Qe.current=-1,Ve.current(e)},[]);Me.current=()=>{var e,t;je.current=0;const n=Oe.current;if(!n)return;const o=n.getContext("2d");if(!o)return;const r=Re.current;if(!r)return;const i="undefined"!=typeof performance?performance.now():Date.now(),a=r.advanceTransition(i),s=Le.current;s&&!a&&(r.computeScene({width:Ee,height:Se}),Le.current=!1);const l="undefined"!=typeof window&&window.devicePixelRatio||1;n.width=be[0]*l,n.height=be[1]*l,n.style.width=be[0]+"px",n.style.height=be[1]+"px",o.scale(l,l),o.clearRect(0,0,be[0],be[1]);const c=null!==(e=null==me?void 0:me.threshold)&&void 0!==e?e:5e3,d=me&&r.lastIngestTime>0&&i-r.lastIngestTime>c;d&&(o.globalAlpha=null!==(t=null==me?void 0:me.dimOpacity)&&void 0!==t?t:.5);const h=n?getComputedStyle(n).getPropertyValue("--semiotic-bg").trim():"",g=he||(h&&"transparent"!==h?h:null);g&&(o.fillStyle=g,o.fillRect(0,0,be[0],be[1]));const p="radial"===k;p?(o.save(),o.translate(xe.left+Ee/2,xe.top+Se/2)):o.translate(xe.left,xe.top);const y=pt[u]||[],f={width:Ee,height:Se};for(const e of y)e(o,r.scene,r.scales,f);p&&o.restore(),d&&(o.globalAlpha=1),s&&r.scales&&(Te(r.scales),We(e=>e+1)),(null==me?void 0:me.showBadge)&&$e(!!d),(a||r.hasActivePulses)&&(je.current=requestAnimationFrame(()=>Me.current()))},o(()=>(Fe(),()=>{je.current&&(cancelAnimationFrame(je.current),je.current=0)}),[Fe]),o(()=>{Le.current=!0,Fe()},[u,Ee,Se,V,he,Fe]),o(()=>{if(!me)return;const e=setInterval(()=>{var e;const t=Re.current;if(!t||0===t.lastIngestTime)return;const n="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(e=me.threshold)&&void 0!==e?e:5e3,r=n-t.lastIngestTime>o;r!==He&&($e(r),Le.current=!0,Fe())},1e3);return()=>clearInterval(e)},[me,He,Fe]);const et=_e&&Ne?te?te(Ne):e.createElement(mt,{hover:Ne}):null,tt="radial"===k,lt=Ne?tt?Ne.x+Ee/2:Ne.x:0,ut=Ne?tt?Ne.y+Se/2:Ne.y:0,dt=et?e.createElement("div",{className:"stream-ordinal-tooltip",style:{position:"absolute",left:xe.left+lt,top:xe.top+ut,transform:`translate(${lt>.7*Ee?"calc(-100% - 12px)":"12px"}, ${.3*Se>ut?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:1}},et):null;return e.createElement("div",{ref:ve,className:"stream-ordinal-frame"+(de?" "+de:""),role:"img","aria-label":"string"==typeof ue?ue:"Ordinal chart",tabIndex:0,style:{position:"relative",width:E?"100%":be[0],height:S?"100%":be[1]},onMouseMove:_e?Je:void 0,onMouseLeave:_e?Ze:void 0,onKeyDown:Ke},le&&e.createElement("svg",{style:{position:"absolute",top:0,left:0,width:be[0],height:be[1],pointerEvents:"none"}},e.createElement("g",{transform:`translate(${xe.left},${xe.top})`},le)),e.createElement("canvas",{ref:Oe,style:{position:"absolute",top:0,left:0,width:be[0],height:be[1]}}),e.createElement(ct,{width:Ee,height:Se,totalWidth:be[0],totalHeight:be[1],margin:xe,scales:Ce,showAxes:V,oLabel:U,rLabel:Z,oFormat:Q,rFormat:K,showGrid:ae,title:ue,legend:se,foregroundGraphics:ce,annotations:re,svgAnnotationRules:ie,annotationFrame:Be,xAccessor:"string"==typeof g?g:void 0,yAccessor:"string"==typeof p?p:void 0,annotationData:null===(c=Re.current)||void 0===c?void 0:c.getData()}),ge&&"radial"===k&&e.createElement("div",{style:{position:"absolute",left:xe.left+Ee/2,top:xe.top+Se/2,transform:"translate(-50%, -50%)",pointerEvents:"none",textAlign:"center"}},ge),(null==me?void 0:me.showBadge)&&e.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===me.badgePosition?{top:4,left:4}:"bottom-left"===me.badgePosition?{bottom:4,left:4}:"bottom-right"===me.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:He?"#dc3545":"#28a745",color:"white"})},He?"STALE":"LIVE"),dt)});vt.displayName="StreamOrdinalFrame";const bt={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},xt={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class wt{constructor(e){this.capacity=e,this.particles=Array(e);for(let t=0;e>t;t++)this.particles[t]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0}}spawn(e){for(let t=0;this.capacity>t;t++){const n=this.particles[t];if(!n.active)return n.active=!0,n.t=0,n.offset=Math.random()-.5,n.edgeIndex=e,n.x=0,n.y=0,n}return null}step(e,t,n,o){var r;for(let i=0;this.capacity>i;i++){const a=this.particles[i];if(!a.active)continue;const s=n[a.edgeIndex];if(!s||!s.bezier){a.active=!1;continue}const l=o&&null!==(r=o[a.edgeIndex])&&void 0!==r?r:1;if(a.t+=e*t*l*(s.bezier.circular?.3:1),a.t>=1){a.active=!1;continue}const c=kt(s.bezier,a.t,a.offset);a.x=c.x,a.y=c.y}}countForEdge(e){let t=0;for(let n=0;this.capacity>n;n++)this.particles[n].active&&this.particles[n].edgeIndex===e&&t++;return t}clear(){for(let e=0;this.capacity>e;e++)this.particles[e].active=!1}resize(e){if(this.capacity>=e)return;const t=this.particles;this.particles=Array(e);for(let n=0;e>n;n++)this.particles[n]=t.length>n?t[n]:{t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0};this.capacity=e}}function kt(e,t,n){if(e.circular&&e.segments)return function(e,t,n,o){const r=e.length,i=t*r,a=Math.min(Math.floor(i),r-1),s=i-a,[l,c,u,d]=e[a],h=At(l,c,u,d,s),g=d.x-l.x,p=d.y-l.y,y=Math.sqrt(g*g+p*p);if(y>.001){const e=g/y;h.x+=-p/y*n*o*2,h.y+=e*n*o*2}return h}(e.segments,t,n,e.halfWidth);if(!e.points)return{x:0,y:0};const[o,r,i,a]=e.points,s=At(o,r,i,a,t),l=a.x-o.x,c=a.y-o.y,u=Math.sqrt(l*l+c*c);if(u>.001){const t=l/u;s.x+=-c/u*n*e.halfWidth*2,s.y+=t*n*e.halfWidth*2}return s}function At(e,t,n,o,r){const i=1-r,a=i*i,s=a*i,l=r*r,c=l*r;return{x:s*e.x+3*a*r*t.x+3*i*l*n.x+c*o.x,y:s*e.y+3*a*r*t.y+3*i*l*n.y+c*o.y}}function Et(e,t){var n=e.get(t);if(!n)throw Error("missing: "+t);return n}function St(e,t){var n,o=[],r=[],i=[],a={},s=[];function l(e){i[e]=!1,a.hasOwnProperty(e)&&Object.keys(a[e]).forEach(function(t){delete a[e][t],i[t]&&l(t)})}function c(e){var t,o,d=!1;for(r.push(e),i[e]=!0,t=0;s[e].length>t;t++)(o=s[e][t])===n?(u(n,r),d=!0):i[o]||(d=c(o));if(d)l(e);else for(t=0;s[e].length>t;t++){var h=a[o=s[e][t]];h||(a[o]=h={}),h[o]=!0}return r.pop(),d}function u(e,t){var n=[].concat(t).concat(e);o.push(n)}function d(t){!function(t){for(var n=0;e.length>n;n++)n>=t&&e[n]||(e[n]=[]),e[n]=e[n].filter(function(e){return e>=t})}(t);for(var n,o=function(e){for(var t=e.length,n=Array(t),o=Array(t),r=Array(t),i=Array(t),a=Array(t),s=Array(t),l=0;t>l;++l)n[l]=-1,o[l]=0,r[l]=!1,i[l]=0,a[l]=-1,s[l]=[];var c,u=0,d=[],h=[];function g(t){var l=[t],c=[t];for(n[t]=o[t]=u,r[t]=!0,u+=1;c.length>0;){var g=e[t=c[c.length-1]];if(g.length>i[t]){for(var p=i[t];g.length>p;++p){var y=g[p];if(0>n[y]){n[y]=o[y]=u,r[y]=!0,u+=1,l.push(y),c.push(y);break}r[y]&&(o[t]=0|Math.min(o[t],o[y])),0>a[y]||s[t].push(a[y])}i[t]=p}else{if(o[t]===n[t]){var f=[],m=[],v=0;for(p=l.length-1;p>=0;--p){var b=l[p];if(r[b]=!1,f.push(b),m.push(s[b]),v+=s[b].length,a[b]=d.length,b===t){l.length=p;break}}d.push(f);var x=Array(v);for(p=0;m.length>p;p++)for(var w=0;m[p].length>w;w++)x[--v]=m[p][w];h.push(x)}c.pop()}}}for(l=0;t>l;++l)0>n[l]&&g(l);for(l=0;h.length>l;l++){var p=h[l];if(0!==p.length){p.sort(function(e,t){return e-t}),c=[p[0]];for(var y=1;p.length>y;y++)p[y]!==p[y-1]&&c.push(p[y]);h[l]=c}}return{components:d,adjacencyList:h}}(e),r=o.components.filter(function(e){return e.length>1}),i=1/0,a=0;r.length>a;a++)for(var s=0;r[a].length>s;s++)i>r[a][s]&&(i=r[a][s],n=a);var l=r[n];if(!l)return!1;var c=e.map(function(e,t){return-1===l.indexOf(t)?[]:e.filter(function(e){return-1!==l.indexOf(e)})});return{leastVertex:i,adjList:c}}n=0;for(var h=e.length;h>n;){var g=d(n);if(n=g.leastVertex,s=g.adjList){for(var p=0;s.length>p;p++)for(var y=0;s[p].length>y;y++){var f=s[p][y];i[+f]=!1,a[f]={}}c(n),n+=1}else n=h}return o}function Ot(e){return e.y0-e.y1>0?"up":"down"}function Lt(e,t){return t(e.source)==t(e.target)}function jt(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var n=0;return e.target.targetLinks.forEach(function(e){n=e.circular?n+1:n}),1>=t&&1>=n}function Pt(e){return e.target.x0-e.source.x1}function Mt(e,t){var n=Dt(e),o=Pt(t)/Math.tan(n);return"up"==Ot(e)?e.y1-o:e.y1+o}function Nt(e,t){var n=Dt(e),o=Pt(t)/Math.tan(n);return"up"==Ot(e)?e.y1+o:e.y1-o}function Dt(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function Ct(e,t){return t(e)}function Tt(e){return Wt(e.source)}function Bt(e){return Wt(e.target)}function Wt(e){return(e.y0+e.y1)/2}function Ht(e){return e.virtual?0:e.value}function $t(e,t){var n=0;e.sourceLinks.forEach(function(e){n=e.circular&&!Lt(e,t)?n+1:n});var o=0;return e.targetLinks.forEach(function(e){o=e.circular&&!Lt(e,t)?o+1:o}),n+o}function _t(e){return e.target.depth}function zt(e,t){return e.sourceLinks.length?e.depth:t-1}function It(e,t){return e.y0-t.y0}function Rt(e,t){return t.y0-e.y0}function Ft(e,t){return e.y1-t.y1}function Yt(e,t){return t.y1-e.y1}function Gt(e,t){return qt(e.source,t.source)||e.index-t.index}function Xt(e,t){return qt(e.target,t.target)||e.index-t.index}function qt(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function Vt(e,t){return Ut(e)==Ut(t)?"bottom"==e.circularLinkType?Rt(e,t):It(e,t):Ut(t)-Ut(e)}function Ut(e){return e.target.column-e.source.column}function Zt(e,t){return Qt(e)==Qt(t)}function Qt(e){return e.y0-e.y1>0?"up":"down"}function Kt(e,t,n,o,r){let i=e;var a=Math.max(8,.15*(i.y1-i.y0));i.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,a))});var s=k(i.links,function(e){return e.source.y0});i.links.forEach(function(e){e.circular&&(e.circularPathData={})});var l=i.links.filter(function(e){return e.circular});return l.sort(function(e,t){return t.value-e.value}),l.forEach(function(e,t){e._circularStub=t>=4}),Jt(i.links.filter(function(e){return"top"==e.circularLinkType}),t,n),Jt(i.links.filter(function(e){return"bottom"==e.circularLinkType}),t,n),i.links.forEach(function(e){if(e.circular){if(e.circularPathData.arcRadius=e._circularWidth+o,e.circularPathData.rightNodeBuffer=5,e.circularPathData.leftNodeBuffer=5,e.circularPathData.sourceWidth=e.source.x1-e.source.x0,e.circularPathData.sourceX=e.source.x0+e.circularPathData.sourceWidth,e.circularPathData.targetX=e.target.x0,e.circularPathData.sourceY=e.y0,e.circularPathData.targetY=e.y1,Lt(e,t)&&jt(e))e.circularPathData.rightSmallArcRadius=o+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=o+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=o+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=o+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+r+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=e.source.y0-r-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius);else{var a=e.source.column,l=e.circularLinkType,c=i.links.filter(function(e){return e.source.column==a&&e.circularLinkType==l});c.sort("bottom"==e.circularLinkType?Rt:It);var u=0;c.forEach(function(t,r){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=o+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=o+e._circularWidth/2+r*n+u),u+=t._circularWidth||t.width}),a=e.target.column,(c=i.links.filter(function(e){return e.target.column==a&&e.circularLinkType==l})).sort("bottom"==e.circularLinkType?Yt:Ft),u=0,c.forEach(function(t,r){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=o+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=o+e._circularWidth/2+r*n+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(i.y1,e.source.y1,e.target.y1)+r+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=s-r-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius)}e.circularPathData.rightInnerExtent=e.circularPathData.sourceX+e.circularPathData.rightNodeBuffer,e.circularPathData.leftInnerExtent=e.circularPathData.targetX-e.circularPathData.leftNodeBuffer,e.circularPathData.rightFullExtent=e.circularPathData.sourceX+e.circularPathData.rightLargeArcRadius+e.circularPathData.rightNodeBuffer,e.circularPathData.leftFullExtent=e.circularPathData.targetX-e.circularPathData.leftLargeArcRadius-e.circularPathData.leftNodeBuffer}e.path=e.circular?function(e){return"top"==e.circularLinkType?"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 0 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY-e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 0 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 0 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY-e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 0 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY:"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 1 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY+e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 1 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 1 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY+e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 1 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY}(e):function(e){var t=e.source.x1,n=e.y0,o=e.target.x0,r=e.y1,i=(t+o)/2;return"M"+t+","+n+"C"+i+","+n+" "+i+","+r+" "+o+","+r}(e)}),i}function Jt(e,t,n){e.sort(Vt);var o=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,r){var i=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(Lt(e,t)&&jt(e))e.circularPathData.verticalBuffer=i+e._circularWidth/2;else{for(var a=0;o.length>a;a++){var s=o[a];if(s!==e&&s.circularPathData&&void 0!==s.circularPathData.verticalBuffer&&en(e,s)){var l=s.circularPathData.verticalBuffer+(s._circularWidth||s.width)/2+n;i=l>i?l:i}}e.circularPathData.verticalBuffer=i+e._circularWidth/2}}),e}function en(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}function tn(e){return function(){return e}}function nn(e){return e.index}function on(e){return e.nodes}function rn(e){return e.links}function an(e,t,n){var o=A(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});o.forEach(function(r){var i=r.length;r.sort(t||function(e,t){return e.circularLinkType==t.circularLinkType?$t(t,n)-$t(e,n):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0}),r.forEach(function(t,r){t.depth==o.length-1&&1==i||0==t.depth&&1==i?(t.y0=e.y1/2-t.value*e.ky,t.y1=t.y0+t.value*e.ky):t.partOfCycle?0==$t(t,n)?(t.y0=e.y1/2+r,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+r,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-r,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/i*r,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-i/2+r,t.y1=t.y0+t.value*e.ky)})})}function sn(e,t,n,o,r,i){var a=A(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});u();for(var s=1,l=i;l>0;--l)c(s*=.99,n),u();function c(t,n){var o=a.length;a.forEach(function(r){var i=r.length,a=r[0].depth;r.forEach(function(r){var s;if(r.sourceLinks.length||r.targetLinks.length)if(r.partOfCycle&&$t(r,n)>0){var l=O(r.sourceLinks,Bt),c=O(r.targetLinks,Tt),u=l&&c?(l+c)/2:l||c;if(u){var d=(u-Wt(r))*t*.3;r.y0+=d,r.y1+=d}}else if(0==a&&1==i)r.y0=e.y1/2-(s=r.y1-r.y0)/2,r.y1=e.y1/2+s/2;else if(a==o-1&&1==i)r.y0=e.y1/2-(s=r.y1-r.y0)/2,r.y1=e.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 h=O(r.sourceLinks,Bt),g=O(r.targetLinks,Tt),p=((h&&g?(h+g)/2:h||g)-Wt(r))*t;r.y0+=p,r.y1+=p}})})}function u(){a.forEach(function(n){var i,a,s,l=e.y0,c=n.length;for(n.sort(t||qt),s=0;c>s;++s)(a=l-(i=n[s]).y0)>0&&(i.y0+=a,i.y1+=a),l=i.y1+o;if((a=l-o-e.y1)>0)for(l=i.y0-=a,i.y1-=a,s=c-2;s>=0;--s)(a=(i=n[s]).y1+r-l)>0&&(i.y0-=a,i.y1-=a),l=i.y0})}}function ln(e){e.nodes.forEach(function(e){e.sourceLinks.sort(Xt),e.targetLinks.sort(Gt)}),e.nodes.forEach(function(e){var t=e.y0,n=t,o=e.y1,r=o;e.sourceLinks.forEach(function(e){e.circular?(e.y0=o-e.width/2,o-=e.width):(e.y0=t+e.width/2,t+=e.width)}),e.targetLinks.forEach(function(e){e.circular?(e.y1=r-e.width/2,r-=e.width):(e.y1=n+e.width/2,n+=e.width)})})}function cn(){var e=0,t=0,n=1,o=1,r=24,i=8,a=null,s=nn,l=zt,c=void 0,u=32,d=2,h=on,g=rn;function p(){var p={nodes:h.apply(null,arguments),links:g.apply(null,arguments)};return function(h){h.x0=e,h.y0=t,h.x1=n,h.y1=o,h.py=0,function(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var n=function(e,t){var n=new Map;return L(e,t).forEach(function(e,t){n.set(t,e[0])}),n}(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var o=e.source,r=e.target;"object"!=typeof o&&(o=e.source=Et(n,o)),"object"!=typeof r&&(r=e.target=Et(n,r)),o.sourceLinks.push(e),r.targetLinks.push(e)})}(h,s),function(e,t){var n=0;if(null==t){for(var o=[],r=0;e.links.length>r;r++){var i=e.links[r],a=i.source.index,s=i.target.index;o[a]||(o[a]=[]),o[s]||(o[s]=[]),-1===o[a].indexOf(s)&&o[a].push(s)}var l=St(o);l.sort(function(e,t){return e.length-t.length});var c={};for(r=0;l.length>r;r++){var u=l[r].slice(-2);c[u[0]]||(c[u[0]]={}),c[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,o=e.source.index;t===o||c[o]&&c[o][t]?(e.circular=!0,e.circularLinkID=n++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=n++)})}(h,c),function(e,t){var n=0,o=0;e.links.forEach(function(r){r.circular&&(r.circularLinkType=r.source.circularLinkType||r.target.circularLinkType?r.source.circularLinkType?r.source.circularLinkType:r.target.circularLinkType:o>n?"top":"bottom","top"==r.circularLinkType?n++:o++,e.nodes.forEach(function(e){Ct(e,t)!=Ct(r.source,t)&&Ct(e,t)!=Ct(r.target,t)||(e.circularLinkType=r.circularLinkType)}))}),e.links.forEach(function(e){e.circular&&(e.source.circularLinkType==e.target.circularLinkType&&(e.circularLinkType=e.source.circularLinkType),Lt(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(h,s),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(S(e.sourceLinks,Ht),S(e.targetLinks,Ht)),e.sourceLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)}),e.targetLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)})})}(h),function(e,t,n){var o,r,i;if(null!=t){e.nodes.sort(function(e,n){return t(e)<t(n)?-1:1});var a=0,s=t(e.nodes[0]);e.nodes.forEach(function(e){a=t(e)==s?a:a+1,s=t(e)==s?s:t(e),e.column=a})}for(o=e.nodes,r=[],i=0;o.length;++i,o=r,r=[])o.forEach(function(e){e.depth=i,e.sourceLinks.forEach(function(e){0>r.indexOf(e.target)&&!e.circular&&r.push(e.target)})});for(o=e.nodes,r=[],i=0;o.length;++i,o=r,r=[])o.forEach(function(e){e.height=i,e.targetLinks.forEach(function(e){0>r.indexOf(e.source)&&!e.circular&&r.push(e.source)})});e.nodes.forEach(function(e){e.column=null==t?n(e,i):e.column})}(h,c,l);var g=i;if(null!==a){var p=A(h.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),y=E(p,function(e){return e.length});y>1&&(g=Math.max(1,(o-t)*a/(y-1)))}(function(e,t,n){var o=A(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});e.py=t;var r=k(o,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/S(t,function(e){return e.value})});e.ky=r,e.links.forEach(function(t){t.width=t.value*e.ky});var i=E(e.nodes,function(e){return e.column});e.nodes.forEach(i>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-n)/i),t.x1=t.x0+n}:function(t){t.x0=e.x0,t.x1=t.x0+n})})(h,g,r),an(h,c,s),sn(h,c,s,g,g,u),ln(h),Kt(h,s,d,10,8),an(h,c,s),sn(h,c,s,g,g,u),ln(h),Kt(h,s,d,10,8),function(e,t){let n=e;n.nodes.forEach(function(e){e.y+(e.y1-e.y0)>n.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-n.y1));var o=n.links.filter(function(n){return Ct(n.source,t)==Ct(e,t)}),r=o.length;r>1&&o.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!Zt(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var n=Mt(t,e);return e.y1-n}if(t.target.column>e.target.column)return Mt(e,t)-t.y1}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.target.column===t.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.target.column===t.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;o.forEach(function(e){e.y0=i+e.width/2,i+=e.width}),o.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,a=0;r>i;i++)a+=o[i].width;t.y0=e.y1-a-t.width/2}})})}(h,s),function(e,t){let n=e;n.nodes.forEach(function(e){var o=n.links.filter(function(n){return Ct(n.target,t)==Ct(e,t)}),r=o.length;r>1&&o.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!Zt(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var n=Nt(t,e);return e.y0-n}if(t.source.column>e.source.column)return Nt(e,t)-t.y0}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:e.source.column-t.source.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:t.source.column-e.source.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;o.forEach(function(e){e.y1=i+e.width/2,i+=e.width}),o.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,a=0;r>i;i++)a+=o[i].width;t.y1=e.y1-a-t.width/2}})})}(h,s),function(e){var t=e.nodes,n=e.links,o=!1,r=!1;if(n.forEach(function(e){"top"==e.circularLinkType?o=!0:"bottom"==e.circularLinkType&&(r=!0)}),0==o||0==r){var i=k(t,function(e){return e.y0}),a=E(t,function(e){return e.y1}),s=(e.y1-e.y0)/(a-i);function l(t){return(t-i)/(a-i)*(e.y1-e.y0)+e.y0}1>s?(t.forEach(function(e){e.y0=l(e.y0),e.y1=l(e.y1)}),n.forEach(function(e){e.y0=l(e.y0),e.y1=l(e.y1),e.width=e.width*s})):t.forEach(function(e){var t=e.y1-e.y0,n=l(e.y0)-e.y0;e.y0=l(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+n}),e.targetLinks.forEach(function(e){e.y1=e.y1+n})})}}(h),Kt(h,s,d,10,8)}(p),p}return p.update=function(e){return ln(e),Kt(e,s,d,10,8),e},p.nodeWidth=function(e){return arguments.length?(r=+e,p):r},p.nodePadding=function(e){return arguments.length?(i=+e,p):i},p.nodePaddingRatio=function(e){return arguments.length?(a=+e,p):a},p.nodes=function(e){return arguments.length?(h="function"==typeof e?e:tn(e),p):h},p.links=function(e){return arguments.length?(g="function"==typeof e?e:tn(e),p):g},p.nodeId=function(e){return arguments.length?(s="function"==typeof e?e:tn(e),p):s},p.nodeAlign=function(e){return arguments.length?(l="function"==typeof e?e:tn(e),p):l},p.nodeSort=function(e){return arguments.length?(c=e,p):c},p.iterations=function(e){return arguments.length?(u=+e,p):u},p.circularLinkGap=function(e){return arguments.length?(d=+e,p):d},p.extent=function(r){return arguments.length?(e=+r[0][0],t=+r[0][1],n=+r[1][0],o=+r[1][1],p):[[e,t],[n,o]]},p.size=function(r){return arguments.length?(e=t=0,n=+r[0],o=+r[1],p):[n-e,o-t]},p}const un=e=>{let t,n,o,r,i,a,s,l,c;return"down"===e.direction?(t=e.y0-e.sankeyWidth/2,n=e.y1-e.sankeyWidth/2,o=e.y1+e.sankeyWidth/2,r=e.y0+e.sankeyWidth/2,i=e.source.y1,a=e.target.y0,s=W(i,a),l=s(.5),c=s(.5),`M${t},${i}C${t},${l} ${n},${c} ${n},${a}L${o},${a}C${o},${c} ${r},${l} ${r},${i}Z`):(t=e.source.x1,n=e.target.x0,s=W(t,n),o=s(.5),r=s(.5),i=e.y0-e.sankeyWidth/2,a=e.y1-e.sankeyWidth/2,l=e.y1+e.sankeyWidth/2,c=e.y0+e.sankeyWidth/2,`M${t},${i}C${o},${i} ${r},${a} ${n},${a}L${n},${l}C${r},${l} ${o},${c} ${t},${c}Z`)};function dn(e){var t;const n=e.sankeyWidth/2,o=(null!==(t=e._circularWidth)&&void 0!==t?t:e.sankeyWidth)/2,r=e.circularPathData;if(!r)return null;if("down"===e.direction)return null;if(e._circularStub){const t=r.sourceX,o=r.sourceY,i=r.targetX,a=r.targetY;if("object"!=typeof e.source||!e.source||"object"!=typeof e.target||!e.target)return null;const s=Math.max(15,Math.min(40,.33*(r.rightFullExtent-t))),l=Math.max(15,Math.min(40,.33*(i-r.leftFullExtent)));return`M${t},${o-n}L${t+s},${o-n}L${t+s},${o+n}L${t},${o+n}ZM${i},${a-n}L${i-l},${a-n}L${i-l},${a+n}L${i},${a+n}Z`}const i=r.sourceX,a=r.sourceY,s=r.targetX,l=r.targetY,c=r.rightFullExtent,u=r.leftFullExtent,d=r.verticalFullExtent,h="bottom"===e.circularLinkType?1:-1,g=Math.max(4,Math.min(o,15));return`M${i},${a-h*n}L${c},${a-h*n}L${c+o},${a-h*n+h*g}L${c+o},${d+h*o-h*g}L${c+o-g},${d+h*o}L${u-o+g},${d+h*o}L${u-o},${d+h*o-h*g}L${u-o},${l-h*n+h*g}L${u-o+g},${l-h*n}L${s},${l-h*n}L${s},${l+h*n}L${u+o},${l+h*n}L${u+o},${d-h*o}L${c-o},${d-h*o}L${c-o},${a+h*n}L${i},${a+h*n}Z`}const hn={left:function(e){return e.depth},right:function(e,t){return t-1-e.height},center:function(e){return e.targetLinks.length?e.depth:e.sourceLinks.length?Math.min.apply(Math,e.sourceLinks.map(_t))-1:0},justify:zt},gn={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,o){var r,i,a,s,l,c,u;if(0===e.length)return;const d="vertical"===n.orientation?"down":"right",h=n.nodeAlign||"justify",g=null!==(r=n.nodeWidth)&&void 0!==r?r:15,p=null!==(i=n.nodePaddingRatio)&&void 0!==i?i:.05,y=null!==(a=n.iterations)&&void 0!==a?a:100,f=e.map(e=>Object.assign({},e)),m=t.map(e=>Object.assign(Object.assign({},e),{source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id,value:Math.sqrt(Math.max(1,e.value||1))}));let v;v="down"===d?[[0,0],[o[1],o[0]]]:[[0,0],[o[0],o[1]]];const b=cn().extent(v).links(m).nodes(f).nodeAlign(hn[h]||zt).nodeId(e=>e.id).nodeWidth(g).iterations(y);b.nodePaddingRatio&&b.nodePaddingRatio(p),b();{let e=1/0,t=-1/0,n=1/0,r=-1/0;for(const o of f)e>o.x0&&(e=o.x0),o.x1>t&&(t=o.x1),n>o.y0&&(n=o.y0),o.y1>r&&(r=o.y1);for(const o of m){if(!o.circular||!o.circularPathData)continue;const i=o.circularPathData,a=(null!==(l=null!==(s=o._circularWidth)&&void 0!==s?s:o.width)&&void 0!==l?l:0)/2;e>i.leftFullExtent-a&&(e=i.leftFullExtent-a),i.rightFullExtent+a>t&&(t=i.rightFullExtent+a),n>i.verticalFullExtent-a&&(n=i.verticalFullExtent-a),i.verticalFullExtent+a>r&&(r=i.verticalFullExtent+a)}const i=t-e,a=r-n,u=o[0],d=o[1];if(i>0&&a>0&&(0>e||0>n||t>u||r>d)){const t=Math.min(u/i,d/a),o=-e*t+(u-i*t)/2,r=-n*t+(d-a*t)/2;for(const e of f)e.x0=e.x0*t+o,e.x1=e.x1*t+o,e.y0=e.y0*t+r,e.y1=e.y1*t+r;for(const e of m)if(e.y0=e.y0*t+r,e.y1=e.y1*t+r,e.width=(null!==(c=e.width)&&void 0!==c?c:0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){const n=e.circularPathData;n.sourceX=n.sourceX*t+o,n.targetX=n.targetX*t+o,n.sourceY=n.sourceY*t+r,n.targetY=n.targetY*t+r,n.rightFullExtent=n.rightFullExtent*t+o,n.leftFullExtent=n.leftFullExtent*t+o,n.verticalFullExtent=n.verticalFullExtent*t+r,n.rightInnerExtent=n.rightInnerExtent*t+o,n.leftInnerExtent=n.leftInnerExtent*t+o,n.verticalRightInnerExtent=n.verticalRightInnerExtent*t+r,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*t+r,n.rightSmallArcRadius*=t,n.rightLargeArcRadius*=t,n.leftSmallArcRadius*=t,n.leftLargeArcRadius*=t,n.sourceWidth*=t,n.rightNodeBuffer*=t,n.leftNodeBuffer*=t,n.arcRadius*=t}}}const x=new Map;for(const t of e)x.set(t.id,t);for(const e of f){const t=x.get(e.id);t&&(t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.value=e.value,t.depth=e.depth,t.sourceLinks=e.sourceLinks,t.targetLinks=e.targetLinks,t.width=e.x1-e.x0,t.height=e.y1-e.y0,t.x=e.x0+(e.x1-e.x0)/2,t.y=e.y0+(e.y1-e.y0)/2)}const w=new Map;for(const e of t)w.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const e of m){const t=e.source,n=e.target,o="object"==typeof t&&null!==t?t.id:t+"",r="object"==typeof n&&null!==n?n.id:n+"",i=w.get(`${o}\0${r}`);if(i){i.y0=e.y0,i.y1=e.y1,i.sankeyWidth=null!==(u=e.width)&&void 0!==u?u:0,i.circular=!!e.circular,i.circularPathData=e.circularPathData,i._circularWidth=e._circularWidth,i._circularStub=e._circularStub,i.path=e.path,i.circularLinkType=e.circularLinkType,i.direction=d;const t=x.get(o),n=x.get(r);t&&(i.source=t),n&&(i.target=n)}}},buildScene(e,t,n,o){var r,i,a,s;const l="vertical"===n.orientation?"down":"right",c=n.nodeStyle,u=n.edgeStyle,d=null!==(r=n.edgeOpacity)&&void 0!==r?r:.5,h=n.edgeColorBy||"source",g=Array.isArray(n.colorScheme)?n.colorScheme:H,p=new Map;e.forEach((e,t)=>{p.set(e.id,g[t%g.length])});const y=[],f=[],m=[];for(const t of e){const e=t.x1-t.x0,n=t.y1-t.y0;if(0>=e||0>=n)continue;const o=c?c(t):{},r={fill:o.fill||p.get(t.id)||"#4d430c",stroke:o.stroke,strokeWidth:o.strokeWidth,opacity:o.opacity};y.push({type:"rect",x:t.x0,y:t.y0,w:e,h:n,style:r,datum:t,id:t.id,label:t.id})}const v=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of v){if(!e.sankeyWidth||0>=e.sankeyWidth)continue;const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;if(!t||!n)continue;let o="#999";u?o=u(e).fill||o:"target"===h&&n?o=p.get(n.id)||o:t&&(o=p.get(t.id)||o);const r=u?u(e):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,n=e.sankeyWidth/2,s=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),l=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),c=r.fill||o;f.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-n}L${t.sourceX+s},${t.sourceY-n}L${t.sourceX+s},${t.sourceY+n}L${t.sourceX},${t.sourceY+n}Z`,style:{fill:c,fillOpacity:null!==(i=r.fillOpacity)&&void 0!==i?i:d,stroke:"none",opacity:r.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+s}}),f.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-n}L${t.targetX-l},${t.targetY-n}L${t.targetX-l},${t.targetY+n}L${t.targetX},${t.targetY+n}Z`,style:{fill:c,fillOpacity:null!==(a=r.fillOpacity)&&void 0!==a?a:d,stroke:"none",opacity:r.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-l,x1:t.targetX}});continue}let l;if(l=e.circular&&e.circularPathData?dn(e):un(e),!l)continue;const c={fill:r.fill||o,fillOpacity:null!==(s=r.fillOpacity)&&void 0!==s?s:d,stroke:r.stroke||"none",strokeWidth:r.strokeWidth,opacity:r.opacity};f.push({type:"bezier",pathD:l,bezierCache:e.bezier,style:c,datum:e})}if(!1!==n.showLabels){const t=(b=n.nodeLabel)?"function"==typeof b?b:e=>e[b]||e.id:null;for(const n of e){const e=n.x1-n.x0,r=n.y1-n.y0;if(0>=e||0>=r)continue;const i=t?t(n):n.id;if(!i)continue;let a,s,c;"down"===l?(a=n.x0+e/2,s=n.y1+14,c="middle"):(o[0]/2>n.x0+e/2?(a=n.x0-6,c="end"):(a=n.x1+6,c="start"),s=n.y0+r/2),m.push({x:a,y:s,text:i+"",anchor:c,baseline:"middle",fontSize:11})}}var b;return{sceneNodes:y,sceneEdges:f,labels:m}}},pn={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,n,o){var r,i;if(0===e.length)return;const a=null!==(r=n.iterations)&&void 0!==r?r:Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),s=null!==(i=n.forceStrength)&&void 0!==i?i:.1,l=o[0]/2,c=o[1]/2;for(let t=0;e.length>t;t++){const n=e[t];if(null==n.x||null==n.y||0===n.x&&0===n.y){const e=10*Math.sqrt(t+.5),o=2.399963229728653*t;n.x=l+e*Math.cos(o),n.y=c+e*Math.sin(o)}}const u=yn(n.nodeSize,n.nodeSizeRange,e),d=q().strength(e=>Math.min(2.5,e.weight?e.weight*s:s)).id(e=>e.id),h=o[1]/o[0],g=V().force("charge",U().strength(e=>-25*(e=>u(e))(e))).force("x",Z(o[0]/2).strength(.1*h)).force("y",Q(o[1]/2).strength(.1));if(g.nodes(e),t.length>0){const e=t.map(e=>Object.assign(Object.assign({},e),{source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id}));g.force("link",d),g.force("link").links(e)}.1>g.alpha()&&g.alpha(1),g.stop();for(let e=0;a>e;++e)g.tick();const p=new Map;for(const t of e)p.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=p.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=p.get(e.target);t&&(e.target=t)}}},buildScene(e,t,n,o){var r,i,a;const s=n.nodeStyle,l=n.edgeStyle,c=yn(n.nodeSize,n.nodeSizeRange,e),u=Array.isArray(n.colorScheme)?n.colorScheme:H,d=new Map;e.forEach((e,t)=>{d.set(e.id,u[t%u.length])});const h=[],g=[],p=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=c(t),n=s?s(t):{},o={fill:n.fill||d.get(t.id)||"#007bff",stroke:n.stroke||"#fff",strokeWidth:null!==(r=n.strokeWidth)&&void 0!==r?r:2,opacity:n.opacity};h.push({type:"circle",cx:t.x,cy:t.y,r:e,style:o,datum:t,id:t.id,label:t.id})}const y=new Map;for(const t of e)y.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:y.get(e.source),n="object"==typeof e.target?e.target:y.get(e.target);if(!t||!n)continue;if(null==t.x||null==t.y)continue;if(null==n.x||null==n.y)continue;const o=l?l(e):{},r={stroke:o.stroke||"#999",strokeWidth:null!==(i=o.strokeWidth)&&void 0!==i?i:1,opacity:null!==(a=o.opacity)&&void 0!==a?a:.6};g.push({type:"line",x1:t.x,y1:t.y,x2:n.x,y2:n.y,style:r,datum:e})}if(!1!==n.showLabels){const t=(f=n.nodeLabel)?"function"==typeof f?f:e=>e[f]||e.id:null;for(const n of e){if(null==n.x||null==n.y)continue;const e=t?t(n):n.id;if(!e)continue;const o=c(n);p.push({x:n.x,y:n.y-o-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var f;return{sceneNodes:h,sceneEdges:g,labels:p}}};function yn(e,t,n){var o,r;if(null==e)return()=>8;if("number"==typeof e)return()=>e;if("function"==typeof e)return t=>e(t)||8;const i=t||[5,20],a=n.map(t=>{var n;return null===(n=t.data)||void 0===n?void 0:n[e]}).filter(e=>null!=e&&"number"==typeof e);if(0===a.length)return()=>i[0];const s=null!==(o=k(a))&&void 0!==o?o:0,l=null!==(r=E(a))&&void 0!==r?r:1;if(s===l)return()=>(i[0]+i[1])/2;const c=f().domain([s,l]).range(i).clamp(!0);return t=>{var n;const o=null===(n=t.data)||void 0===n?void 0:n[e];return null==o||"number"!=typeof o?i[0]:c(o)}}const fn=H,mn={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,n,o){if(0===e.length)return;const{padAngle:r=.01,groupWidth:i=20,sortGroups:a}=n,s=Math.min(o[0],o[1])/2,l=s-i,c=o[0]/2,u=o[1]/2,d=(h=n.valueAccessor)?"function"==typeof h?h:e=>{var t;return null!==(t=e[h])&&void 0!==t?t:1}:e=>{var t;return null!==(t=e.value)&&void 0!==t?t:1};var h;const g=new Map;for(let t=0;e.length>t;t++)g.set(e[t].id,t);const p=e.length,y=Array.from({length:p},()=>Array.from({length:p},()=>0));for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,n=g.get("string"==typeof e.source?e.source:e.source.id),o=g.get(t);if(void 0===n||void 0===o)continue;const r=d(e);y[n][o]=r}const f=J().padAngle(r);a&&f.sortGroups(a);const m=f(y),v=m.groups,b=ee().innerRadius(l).outerRadius(s);for(const t of v){const n=e[t.index],o=b.centroid(t);n.x=o[0]+c,n.y=o[1]+u,n.arcData={startAngle:t.startAngle,endAngle:t.endAngle}}const x=new Map;for(const t of e)x.set(t.id,t);for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,n=x.get("string"==typeof e.source?e.source:e.source.id),o=x.get(t);n&&(e.source=n),o&&(e.target=o)}const w=new Map;for(const e of t)w.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const t of m){const n=e[t.source.index].id,o=e[t.target.index].id,r=w.get(`${n}\0${o}`)||w.get(`${o}\0${n}`);r&&(r.chordData=t)}},buildScene(e,t,n,o){var r,i;const{groupWidth:a=20,edgeOpacity:s=.5}=n,l=Math.min(o[0],o[1])/2,c=l-a,u=o[0]/2,d=o[1]/2,h=n.nodeStyle,g=n.edgeStyle,p=n.edgeColorBy||"source",y=Array.isArray(n.colorScheme)?n.colorScheme:fn,f=new Map;e.forEach((e,t)=>{f.set(e.id,y[t%y.length])});const m=K().radius(c),v=[],b=[],x=[];for(let t=0;e.length>t;t++){const n=e[t],o=n.arcData;if(!o)continue;let i;i=h?h(n).fill||f.get(n.id)||y[t%y.length]:f.get(n.id)||y[t%y.length];const a=h?h(n):{},s={fill:i,stroke:a.stroke||"black",strokeWidth:null!==(r=a.strokeWidth)&&void 0!==r?r:1,opacity:a.opacity};v.push({type:"arc",cx:u,cy:d,innerR:c,outerR:l,startAngle:o.startAngle-Math.PI/2,endAngle:o.endAngle-Math.PI/2,style:s,datum:n,id:n.id,label:n.id})}for(const e of t){const t=e.chordData;if(!t)continue;const n=m(t);if(!n)continue;const o=vn(n,u,d);let r="#999";if(g)r=g(e).fill||r;else{const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;"target"===p&&n?r=f.get(n.id)||r:t&&(r=f.get(t.id)||r)}const a=g?g(e):{},l={fill:r,fillOpacity:null!==(i=a.fillOpacity)&&void 0!==i?i:s,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity};b.push({type:"ribbon",pathD:o,style:l,datum:e})}if(!1!==n.showLabels){const t=(w=n.nodeLabel)?"function"==typeof w?w:e=>e[w]||e.id:null,o=l+12;for(const n of e){const e=n.arcData;if(!e)continue;const r=t?t(n):n.id;if(!r)continue;const i=(e.startAngle+e.endAngle)/2,a=i-Math.PI/2;x.push({x:u+Math.cos(a)*o,y:d+Math.sin(a)*o,text:r+"",anchor:i>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var w;return{sceneNodes:v,sceneEdges:b,labels:x}}};function vn(e,t,n){const o=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!o)return e;const r=[];let i=0;for(;o.length>i;){const e=o[i];if("M"===e||"L"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)r.push(Number(o[i])+t+""),i++,o.length>i&&!isNaN(Number(o[i]))&&(r.push(Number(o[i])+n+""),i++);else if("C"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)for(let e=0;3>e&&o.length>i&&!isNaN(Number(o[i]));e++)r.push(Number(o[i])+t+""),i++,o.length>i&&!isNaN(Number(o[i]))&&(r.push(Number(o[i])+n+""),i++);else if("Q"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)for(let e=0;2>e&&o.length>i&&!isNaN(Number(o[i]));e++)r.push(Number(o[i])+t+""),i++,o.length>i&&!isNaN(Number(o[i]))&&(r.push(Number(o[i])+n+""),i++);else if("A"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&(r.push(Number(o[i])+t+""),i++),o.length>i&&(r.push(Number(o[i])+n+""),i++);else"Z"===e||"z"===e?(r.push(e),i++):(r.push(o[i]),i++)}return r.join(" ")}const bn={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,n,o){var r;const i=n.__hierarchyRoot;if(!i)return;const a=n.chartType,s=(l=n.childrenAccessor)?"function"==typeof l?l:e=>e[l]:void 0;var l;const c=n.hierarchySum||(e=>{var t;return null!==(t=e.value)&&void 0!==t?t:0}),u=P(i,s);u.sum(c),u.sort((e,t)=>{var n,o;return(null!==(n=t.value)&&void 0!==n?n:0)-(null!==(o=e.value)&&void 0!==o?o:0)});const[d,h]=o;switch(a){case"tree":!function(e,t,n,o){const r=t.treeOrientation||"vertical",i=B();i.size("horizontal"===r?[o,n]:"radial"===r?[2*Math.PI,Math.min(n,o)/2*.8]:[n,o]),i(e)}(u,n,d,h);break;case"cluster":!function(e,t,n,o){const r=t.treeOrientation||"vertical",i=T();i.size("horizontal"===r?[o,n]:"radial"===r?[2*Math.PI,Math.min(n,o)/2*.8]:[n,o]),i(e)}(u,n,d,h);break;case"treemap":!function(e,t,n,o){var r,i;const a=null!==(r=t.padding)&&void 0!==r?r:4,s=null!==(i=t.paddingTop)&&void 0!==i?i:0,l=D().size([n,o]).tile(C).padding(a);s>0&&l.paddingTop(s),l(e)}(u,n,d,h);break;case"circlepack":!function(e,t,n,o){var r;const i=null!==(r=t.padding)&&void 0!==r?r:4;N().size([n,o]).padding(i)(e)}(u,n,d,h);break;case"partition":!function(e,t,n,o){var r;M().size([n,o]).padding(null!==(r=t.padding)&&void 0!==r?r:1)(e)}(u,n,d,h)}const g=u.descendants();e.length=0,t.length=0;const p=new Map;for(let t=0;g.length>t;t++){const o=g[t],i={id:En(o,n,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(r=o.value)&&void 0!==r?r:0,depth:o.depth,data:o.data,createdByFrame:!0};"tree"===a||"cluster"===a?xn(i,o,n):"treemap"===a||"partition"===a?wn(i,o):"circlepack"===a&&kn(i,o),i.__hierarchyNode=o,e.push(i),p.set(o,i)}if("tree"===a||"cluster"===a)for(const e of g)if(e.parent){const n=p.get(e.parent),o=p.get(e);n&&o&&t.push({source:n,target:o,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,n,o){const r=n.nodeStyle||(()=>({})),i=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(e,t,n,o,r,i){var a,s,l,c,u;const d=[],h=[],g=[],p=n.treeOrientation||"vertical",y="radial"===p,f=o[0]/2,m=o[1]/2,v="number"==typeof(x=n.nodeSize)?x:5,b=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];var x;for(const t of e){let e=t.x,o=t.y;y&&(e+=f,o+=m);const i=r(t);let s=i.fill||"#4d430c";n.colorByDepth&&void 0!==t.depth&&(s=b[t.depth%b.length]);const l={fill:s,stroke:i.stroke||"#fff",strokeWidth:null!==(a=i.strokeWidth)&&void 0!==a?a:1,opacity:i.opacity};d.push({type:"circle",cx:e,cy:o,r:v,style:l,datum:t,id:t.id,label:t.id,depth:t.depth})}const w=null!==(s=n.edgeOpacity)&&void 0!==s?s:.5;for(const e of t){const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;if(!t||!n)continue;let o=t.x,r=t.y,a=n.x,s=n.y;y&&(o+=f,r+=m,a+=f,s+=m);const u=An(o,r,a,s,p),d=i(e),g={fill:"none",stroke:d.stroke||"#999",strokeWidth:null!==(l=d.strokeWidth)&&void 0!==l?l:1.5,opacity:null!==(c=d.opacity)&&void 0!==c?c:w};h.push({type:"curved",pathD:u,style:g,datum:e})}if(!1!==n.showLabels){const t=Sn(n.nodeLabel);for(const n of e){const e=t?t(n):n.id;if(!e)continue;let o,r,i,a=n.x,s=n.y;if(y&&(a+=f,s+=m),y){const e=a-f,t=s-m,n=Math.sqrt(e*e+t*t);n>0?(o=a+e/n*10,r=s+t/n*10,i=0>e?"end":"start"):(o=a,r=s-12,i="middle")}else"horizontal"===p?((null===(u=n.data)||void 0===u?void 0:u.children)&&0!==n.data.children.length?(o=a-v-6,i="end"):(o=a+v+6,i="start"),r=s):(o=a,r=s+v+14,i="middle");g.push({x:o,y:r,text:e+"",anchor:i,baseline:"middle",fontSize:11})}}return{sceneNodes:d,sceneEdges:h,labels:g}}(e,t,n,o,r,i);case"treemap":case"partition":return function(e,t,n,o){var r,i;const a=[],s=[],l=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const n of e){const e=n.x1-n.x0,i=n.y1-n.y0;if(0>=e||0>=i)continue;const s=o(n);let c=s.fill||"#4d430c";t.colorByDepth&&void 0!==n.depth&&(c=l[n.depth%l.length]);const u={fill:c,stroke:s.stroke||"#fff",strokeWidth:null!==(r=s.strokeWidth)&&void 0!==r?r:1,opacity:s.opacity};a.push({type:"rect",x:n.x0,y:n.y0,w:e,h:i,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=Sn(t.nodeLabel);for(const o of e){const e=o.x1-o.x0,r=o.y1-o.y0;if(0>=e||0>=r)continue;if((null===(i=o.data)||void 0===i?void 0:i.children)&&o.data.children.length>0&&"partition"!==t.chartType)continue;const a=n?n(o):o.id;a&&(30>e||16>r||s.push({x:o.x0+e/2,y:o.y0+r/2,text:a+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,r)/6))}))}}return{sceneNodes:a,sceneEdges:[],labels:s}}(e,n,0,r);case"circlepack":return function(e,t,n,o){var r,i,a,s,l;const c=[],u=[],d=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];for(const n of e){const e=null!==(r=n.__radius)&&void 0!==r?r:5;if(0>=e)continue;const s=o(n);let l=s.fill||"#4d430c";t.colorByDepth&&void 0!==n.depth&&(l=d[n.depth%d.length]);const u={fill:l,stroke:s.stroke||"#fff",strokeWidth:null!==(i=s.strokeWidth)&&void 0!==i?i:1,opacity:null!==(a=s.opacity)&&void 0!==a?a:.7};c.push({type:"circle",cx:n.x,cy:n.y,r:e,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=Sn(t.nodeLabel);for(const t of e){const e=null!==(s=t.__radius)&&void 0!==s?s:5,o=n?n(t):t.id;if(!o)continue;if(15>e)continue;const r=!((null===(l=t.data)||void 0===l?void 0:l.children)&&t.data.children.length>0);u.push({x:t.x,y:r?t.y:t.y-e+14,text:o+"",anchor:"middle",baseline:r?"middle":"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:r?void 0:"#000",stroke:r?void 0:"#fff",strokeWidth:r?void 0:3,paintOrder:r?void 0:"stroke"})}}return{sceneNodes:c,sceneEdges:[],labels:u}}(e,n,0,r);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function xn(e,t,n){const o=n.treeOrientation||"vertical";if("radial"===o){const n=t.x,o=t.y;e.x=o*Math.cos(n-Math.PI/2),e.y=o*Math.sin(n-Math.PI/2)}else"horizontal"===o?(e.x=t.y,e.y=t.x):(e.x=t.x,e.y=t.y);e.x0=e.x-5,e.x1=e.x+5,e.y0=e.y-5,e.y1=e.y+5,e.width=10,e.height=10}function wn(e,t){e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.x=(t.x0+t.x1)/2,e.y=(t.y0+t.y1)/2,e.width=t.x1-t.x0,e.height=t.y1-t.y0}function kn(e,t){var n;const o=null!==(n=t.r)&&void 0!==n?n:0;e.x=t.x,e.y=t.y,e.x0=t.x-o,e.x1=t.x+o,e.y0=t.y-o,e.y1=t.y+o,e.width=2*o,e.height=2*o,e.__radius=o}function An(e,t,n,o,r){if("horizontal"===r){const r=(e+n)/2;return`M ${e},${t} C ${r},${t} ${r},${o} ${n},${o}`}if("radial"===r){const r=(e+n)/2;return`M ${e},${t} Q ${r},${t} ${r},${(t+o)/2} T ${n},${o}`}{const r=(t+o)/2;return`M ${e},${t} C ${e},${r} ${n},${r} ${n},${o}`}}function En(e,t,n){const o=t.nodeIDAccessor;return"function"==typeof o?o(e.data)+"":"string"==typeof o&&void 0!==e.data[o]?e.data[o]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+n}function Sn(e){return e?"function"==typeof e?e:t=>{var n;return(null===(n=t.data)||void 0===n?void 0:n[e])||t[e]||t.id}:null}const On={sankey:gn,force:pn,chord:mn,tree:bn,cluster:bn,treemap:bn,circlepack:bn,partition:bn};function Ln(e){return On[e]}class jn{constructor(e){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.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.config=e,this.tensionConfig=Object.assign(Object.assign({},bt),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&(this.particlePool=new wt(2e3))}updateConfig(e){this.config=e,this.tensionConfig=Object.assign(Object.assign({},bt),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&!this.particlePool&&(this.particlePool=new wt(2e3))}ingestHierarchy(e,t){this.nodes.clear(),this.edges.clear(),this.config.__hierarchyRoot=e,this.runLayout(t)}ingestBounded(e,t,n){const{nodeIDAccessor:o="id",sourceAccessor:r="source",targetAccessor:i="target",valueAccessor:a="value"}=this.config,s="function"==typeof o?o:e=>e[o],l="function"==typeof r?r:e=>e[r],c="function"==typeof i?i:e=>e[i],u="function"==typeof a?a:e=>{var t;return null!==(t=e[a])&&void 0!==t?t:1};this.nodes.clear(),this.edges.clear();for(const t of e){const e=s(t)+"";this.nodes.set(e,Object.assign(Object.assign({},Pn(e)),{data:t}))}for(const e of t){const t=l(e)+"",n=c(e)+"",o=Number(u(e))||1;this.nodes.has(t)||this.nodes.set(t,Object.assign(Object.assign({},Pn(t)),{data:e})),this.nodes.has(n)||this.nodes.set(n,Object.assign(Object.assign({},Pn(n)),{data:e})),this.edges.set(`${t}\0${n}`,{source:t,target:n,value:o,y0:0,y1:0,sankeyWidth:0,data:e})}this.runLayout(n)}edgeKey(e,t){return`${e}\0${t}`}ingestEdge(e){const{source:t,target:n,value:o}=e,r=0===this.nodes.size;let i=!1;const a="undefined"!=typeof performance?performance.now():Date.now();this.lastIngestTime=a,this.nodes.has(t)||(this.nodes.set(t,Pn(t)),this.nodeTimestamps.set(t,a),this.tension+=this.tensionConfig.newNode,i=!0),this.nodes.has(n)||(this.nodes.set(n,Pn(n)),this.nodeTimestamps.set(n,a),this.tension+=this.tensionConfig.newNode,i=!0);const s=this.edgeKey(t,n),l=this.edges.get(s);return l?(l.value+=o,this.edgeTimestamps.set(s,a),this.tension+=this.tensionConfig.weightChange):(this.edges.set(s,{source:t,target:n,value:o,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(s,a),this.tension+=this.tensionConfig.newEdge,i=!0),r||i||this.tension>=this.tensionConfig.threshold}runLayout(e){const t=Ln(this.config.chartType);if(!t)return;let n=Array.from(this.nodes.values()),o=Array.from(this.edges.values());if(0===n.length&&!t.hierarchical)return;if(this.prepareForRelayout(),t.computeLayout(n,o,this.config,e),t.hierarchical&&n.length>0){this.nodes.clear(),this.edges.clear();for(const e of n)this.nodes.set(e.id,e);for(const e of o)this.edges.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e)}this.finalizeLayout(),this.saveTargetPositions(),n.some(e=>void 0!==e._prevX0&&(0!==e._prevX0||0!==e._prevX1||0!==e._prevY0||0!==e._prevY1))&&this.tensionConfig.transitionDuration>0&&(this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:this.tensionConfig.transitionDuration});const r=new Set(this.nodes.keys()),i=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const e of r)this.previousNodeIds.has(e)||this.addedNodes.add(e);for(const e of this.previousNodeIds)r.has(e)||this.removedNodes.add(e);for(const e of i)this.previousEdgeKeys.has(e)||this.addedEdges.add(e);for(const e of this.previousEdgeKeys)i.has(e)||this.removedEdges.add(e);(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=r,this.previousEdgeKeys=i,this.layoutVersion++}buildScene(e){const t=Ln(this.config.chartType);if(!t)return;const n=Array.from(this.nodes.values()),o=Array.from(this.edges.values()),{sceneNodes:r,sceneEdges:i,labels:a}=t.buildScene(n,o,this.config,e);this.sceneNodes=r,this.sceneEdges=i,this.labels=a}advanceTransition(e){if(!this.transition)return!1;const t=Math.min((e-this.transition.startTime)/this.transition.duration,1),n=1-Math.pow(1-t,3);for(const e of this.nodes.values())void 0===e._targetX0||void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=e._prevX0+(e._targetX0-e._prevX0)*n,e.x1=e._prevX1+(e._targetX1-e._prevX1)*n,e.y0=e._prevY0+(e._targetY0-e._prevY0)*n,e.y1=e._prevY1+(e._targetY1-e._prevY1)*n);for(const e of this.edges.values())void 0!==e._targetY0&&void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=e._prevY0+(e._targetY0-e._prevY0)*n,e.y1=e._prevY1+(e._targetY1-e._prevY1)*n,e.sankeyWidth=e._prevSankeyWidth+(e._targetSankeyWidth-e._prevSankeyWidth)*n);return this.rebuildAllBeziers(),1>t||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){for(const e of this.nodes.values())e._prevX0=e.x0,e._prevX1=e.x1,e._prevY0=e.y0,e._prevY1=e.y1;for(const e of this.edges.values())e._prevY0=e.y0,e._prevY1=e.y1,e._prevSankeyWidth=e.sankeyWidth}finalizeLayout(){const e="vertical"===this.config.orientation?"down":"right";for(const e of this.nodes.values())if(0!==e.x0||0!==e.x1||0!==e.y0||0!==e.y1)e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;else{const t=5;e.x0=e.x-t,e.x1=e.x+t,e.y0=e.y-t,e.y1=e.y+t,e.width=2*t,e.height=2*t}for(const t of this.edges.values())t.direction=e,this.updateEdgeBezier(t);this.tension=0}saveTargetPositions(){for(const e of this.nodes.values())e._targetX0=e.x0,e._targetX1=e.x1,e._targetY0=e.y0,e._targetY1=e.y1;for(const e of this.edges.values())e._targetY0=e.y0,e._targetY1=e.y1,e._targetSankeyWidth=e.sankeyWidth}restorePreviousPositions(){for(const e of this.nodes.values())void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=e._prevX0,e.x1=e._prevX1,e.y0=e._prevY0,e.y1=e._prevY1);for(const e of this.edges.values())void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=e._prevY0,e.y1=e._prevY1,e.sankeyWidth=e._prevSankeyWidth);this.rebuildAllBeziers()}snapToTargets(){for(const e of this.nodes.values())void 0!==e._targetX0&&(e.x0=e._targetX0,e.x1=e._targetX1,e.y0=e._targetY0,e.y1=e._targetY1);for(const e of this.edges.values())void 0!==e._targetY0&&(e.y0=e._targetY0,e.y1=e._targetY1,e.sankeyWidth=e._targetSankeyWidth);this.rebuildAllBeziers()}updateEdgeBezier(e){const t="string"==typeof e.source?this.nodes.get(e.source):e.source,n="string"==typeof e.target?this.nodes.get(e.target):e.target;t&&n&&(e.bezier=e.circular&&e.circularPathData?this.buildCircularBezier(e):this.buildStandardBezier(e,t,n))}buildStandardBezier(e,t,n){const o=(e.sankeyWidth||1)/2;if("down"===e.direction){const r=t.y1,i=n.y0,a=W(r,i);return{circular:!1,points:[{x:e.y0,y:r},{x:e.y0,y:a(.5)},{x:e.y1,y:a(.5)},{x:e.y1,y:i}],halfWidth:o}}const r=t.x1,i=n.x0,a=W(r,i);return{circular:!1,points:[{x:r,y:e.y0},{x:a(.5),y:e.y0},{x:a(.5),y:e.y1},{x:i,y:e.y1}],halfWidth:o}}buildCircularBezier(e){const t=(e._circularWidth||e.sankeyWidth||1)/2,n=e.circularPathData;if(e._circularStub){const e=Math.max(15,Math.min(40,.33*(n.rightFullExtent-n.sourceX))),o=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*e,y:n.sourceY},{x:n.sourceX+.66*e,y:n.sourceY},{x:n.sourceX+e,y:n.sourceY}],[{x:n.targetX-o,y:n.targetY},{x:n.targetX-.66*o,y:n.targetY},{x:n.targetX-.33*o,y:n.targetY},{x:n.targetX,y:n.targetY}]],halfWidth:t}}let o;o="down"===e.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 e=0;o.length-1>e;e++){const t=o[e],n=o[e+1],i=n.x-t.x,a=n.y-t.y;r.push([t,{x:t.x+i/3,y:t.y+a/3},{x:t.x+2*i/3,y:t.y+2*a/3},n])}return{circular:!0,segments:r,halfWidth:t}}rebuildAllBeziers(){for(const e of this.nodes.values())e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;for(const e of this.edges.values())this.updateEdgeBezier(e)}applyPulse(e){var t,n,o,r,i;const a=this.config.pulse;if(!a)return;const s=null!==(t=a.duration)&&void 0!==t?t:500,l=null!==(n=a.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",c=null!==(o=a.glowRadius)&&void 0!==o?o:4;for(const t of this.sceneNodes){const n=t.id;if(!n)continue;const o=this.nodeTimestamps.get(n);if(!o)continue;const r=e-o;s>r&&(t._pulseIntensity=1-r/s,t._pulseColor=l,t._pulseGlowRadius=c)}for(const t of this.sceneEdges){const n=t.datum;if(!n)continue;const o="object"==typeof n.source?null===(r=n.source)||void 0===r?void 0:r.id:n.source,a="object"==typeof n.target?null===(i=n.target)||void 0===i?void 0:i.id:n.target;if(!o||!a)continue;const c=this.edgeTimestamps.get(`${o}\0${a}`);if(!c)continue;const u=e-c;s>u&&(t._pulseIntensity=1-u/s,t._pulseColor=l)}}applyDecay(){var e,t,n,o,r;const i=this.config.decay;if(!i)return;const a=null!==(e=i.minOpacity)&&void 0!==e?e:.1,s=this.nodeTimestamps.size;if(1>=s)return;const l=Array.from(this.nodeTimestamps.entries()).sort((e,t)=>e[1]-t[1]),c=new Map;for(let e=0;l.length>e;e++)c.set(l[e][0],e);for(const e of this.sceneNodes){const l=e.id;if(!l)continue;const u=c.get(l);if(void 0===u)continue;const d=s-1-u;let h;switch(i.type){case"linear":h=a+(1-d/(s-1))*(1-a);break;case"exponential":{const e=null!==(t=i.halfLife)&&void 0!==t?t:s/2;h=a+Math.pow(.5,d/e)*(1-a);break}case"step":h=(null!==(n=i.stepThreshold)&&void 0!==n?n:.5*s)>d?1:a;break;default:h=1}const g=null!==(r=null===(o=e.style)||void 0===o?void 0:o.opacity)&&void 0!==r?r:1;e.style=Object.assign(Object.assign({},e.style),{opacity:g*h})}}applyTopologyDiff(e){var t;if(0===this.addedNodes.size)return;const n=e-this.lastTopologyChangeTime;if(n>=2e3)return;const o=1-n/2e3;for(const e of this.sceneNodes){const n=e.id;n&&this.addedNodes.has(n)&&(e._pulseIntensity=Math.max(null!==(t=e._pulseIntensity)&&void 0!==t?t:0,o),e._pulseColor="rgba(34, 197, 94, 0.7)",e._pulseGlowRadius=8)}}get hasActiveTopologyDiff(){return 0!==this.addedNodes.size&&2e3>("undefined"!=typeof performance?performance.now():Date.now())-this.lastTopologyChangeTime}applyThresholds(e){var t,n;const o=this.config.thresholds;if(!o)return;const r=null!==(t=o.warningColor)&&void 0!==t?t:"#f59e0b",i=null!==(n=o.criticalColor)&&void 0!==n?n:"#ef4444",a=!1!==o.pulse;for(const t of this.sceneNodes){const n=t.id;if(!n)continue;const s=this.nodes.get(n);if(!s)continue;const l=o.metric(s);let c=null;void 0===o.critical||o.critical>l?void 0===o.warning||o.warning>l||(c=r):c=i,c&&(t.style=Object.assign(Object.assign({},t.style),{fill:c}),a&&(t._pulseIntensity=.6+.4*Math.sin(e/300),t._pulseColor=c,t._pulseGlowRadius=6))}}get hasActiveThresholds(){const e=this.config.thresholds;if(!e)return!1;for(const t of this.nodes.values()){const n=e.metric(t);if(void 0!==e.warning&&n>=e.warning||void 0!==e.critical&&n>=e.critical)return!0}return!1}get hasActivePulses(){var e;const t=this.config.pulse;if(!t||0===this.lastIngestTime)return!1;const n="undefined"!=typeof performance?performance.now():Date.now();return(null!==(e=t.duration)&&void 0!==e?e: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.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.transition=null,this.lastIngestTime=0,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.particlePool&&this.particlePool.clear()}}function Pn(e){return{id:e,x0:0,x1:0,y0:0,y1:0,x:0,y:0,width:0,height:0,value:0,createdByFrame:!0}}function Mn(e,t,n,o,r=30){let i=null,a=r,s=1/0;for(const t of e){const e=Nn(t,n,o);if(e)if("rect"===t.type){const n=t.w*t.h;s>n&&(i=e,s=n)}else a>e.distance&&(i=e,a=e.distance)}if(i)return i;for(const e of t){const t=Dn(e,n,o);t&&a>t.distance&&(i=t,a=t.distance)}return i}function Nn(e,t,n){switch(e.type){case"circle":return function(e,t,n){const o=t-e.cx,r=n-e.cy,i=Math.sqrt(o*o+r*r);return i>Math.max(e.r,5)+5?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:i}}(e,t,n);case"rect":return function(e,t,n){return e.x>t||t>e.x+e.w||e.y>n||n>e.y+e.h?null:{type:"node",datum:e.datum,x:e.x+e.w/2,y:e.y+e.h/2,distance:0}}(e,t,n);case"arc":return function(e,t,n){const o=t-e.cx,r=n-e.cy,i=Math.sqrt(o*o+r*r);if(e.innerR-2>i||i>e.outerR+2)return null;let a=Math.atan2(r,o);0>a&&(a+=2*Math.PI);let s,l=e.startAngle,c=e.endAngle;if(0>l&&(l+=2*Math.PI),0>c&&(c+=2*Math.PI),s=l>c?a>=l||c>=a:a>=l&&c>=a,s){const t=(e.startAngle+e.endAngle)/2,n=(e.innerR+e.outerR)/2;return{type:"node",datum:e.datum,x:e.cx+n*Math.cos(t),y:e.cy+n*Math.sin(t),distance:0}}return null}(e,t,n);default:return null}}function Dn(e,t,n){switch(e.type){case"bezier":return function(e,t,n){var o,r;if(!e.pathD)return null;try{const i=new Path2D(e.pathD),a=document.createElement("canvas").getContext("2d");if(!a)return null;if(a.isPointInPath(i,t,n)){const i="object"==typeof(null===(o=e.datum)||void 0===o?void 0:o.source)?e.datum.source:null,a="object"==typeof(null===(r=e.datum)||void 0===r?void 0:r.target)?e.datum.target:null;return{type:"edge",datum:e.datum,x:i&&a?(i.x1+a.x0)/2:t,y:e.datum?(e.datum.y0+e.datum.y1)/2:n,distance:0}}}catch(e){}return null}(e,t,n);case"line":return function(e,t,n){const o=e.x2-e.x1,r=e.y2-e.y1,i=o*o+r*r;if(0===i)return null;let a=((t-e.x1)*o+(n-e.y1)*r)/i;a=Math.max(0,Math.min(1,a));const s=e.x1+a*o,l=e.y1+a*r,c=Math.sqrt(Math.pow(t-s,2)+Math.pow(n-l,2));return c>5?null:{type:"edge",datum:e.datum,x:s,y:l,distance:c}}(e,t,n);case"ribbon":case"curved":return function(e,t,n){if(!e.pathD)return null;try{const o=new Path2D(e.pathD),r=document.createElement("canvas").getContext("2d");if(!r)return null;if(r.isPointInPath(o,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0}}catch(e){}return null}(e,t,n);default:return null}}function Cn(t){const{width:n,height:o,totalWidth:r,totalHeight:i,margin:a,labels:s,title:l,legend:c,foregroundGraphics:u,annotations:d,svgAnnotationRules:h}=t;return e.createElement("svg",{width:r,height:i,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},e.createElement("g",{transform:`translate(${a.left},${a.top})`},s.map((t,n)=>e.createElement("text",{key:"label-"+n,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)),d&&h&&d.map((t,r)=>{const i=h(t,r,{width:n,height:o});return i?e.createElement(e.Fragment,{key:"annotation-"+r},i):null}),u),l&&"string"==typeof l?e.createElement("text",{x:r/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor"},l):l?e.createElement("foreignObject",{x:0,y:0,width:r,height:a.top},l):null,c&&"object"==typeof c&&"legendGroups"in c?e.createElement("g",{transform:`translate(${r-a.right+10},${a.top})`},c.legendGroups.map((t,n)=>{var o;return e.createElement("g",{key:"legend-group-"+n},null===(o=t.items)||void 0===o?void 0:o.map((t,n)=>e.createElement("g",{key:"legend-item-"+n,transform:`translate(0,${20*n})`},e.createElement("rect",{x:0,y:0,width:12,height:12,fill:t.color,rx:2}),e.createElement("text",{x:18,y:10,fontSize:11,fill:"currentColor"},t.label))))})):c?e.createElement("g",{transform:`translate(${r-a.right+10},${a.top})`},c):null)}function Tn(e,t){var n,o,r,i,a,s;if(!t.pathD)return;e.save();const l=new Path2D(t.pathD);if(t.style.fill&&"none"!==t.style.fill){const a=t._gradient;if(a){const r=e.createLinearGradient(a.x0,0,a.x1,0),i=null!==(o=null!==(n=t.style.fillOpacity)&&void 0!==n?n:t.style.opacity)&&void 0!==o?o:.5,s=t.style.fill;r.addColorStop(0,1===a.from?s:"transparent"),r.addColorStop(1,1===a.to?s:"transparent"),e.fillStyle=r,e.globalAlpha=i}else e.fillStyle=t.style.fill,e.globalAlpha=null!==(i=null!==(r=t.style.fillOpacity)&&void 0!==r?r:t.style.opacity)&&void 0!==i?i:.5;e.fill(l)}t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(a=t.style.strokeWidth)&&void 0!==a?a:.5,e.globalAlpha=.5*(null!==(s=t.style.opacity)&&void 0!==s?s:1),e.stroke(l)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.2*t._pulseIntensity,e.fill(l)),e.restore()}function Bn(e,t){var n,o;e.save(),e.strokeStyle=t.style.stroke||"#999",e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.strokeDasharray&&e.setLineDash(t.style.strokeDasharray.split(/[\s,]+/).map(Number)),e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke(),t._pulseIntensity&&t._pulseIntensity>0&&(e.setLineDash([]),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=(null!==(o=t.style.strokeWidth)&&void 0!==o?o:1)+3*t._pulseIntensity,e.globalAlpha=.4*t._pulseIntensity,e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke()),e.restore()}function Wn(e,t){var n,o,r,i;if(!t.pathD)return;e.save();const a=new Path2D(t.pathD);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=t.style.fill,e.globalAlpha=null!==(o=null!==(n=t.style.fillOpacity)&&void 0!==n?n:t.style.opacity)&&void 0!==o?o:.5,e.fill(a)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(r=t.style.strokeWidth)&&void 0!==r?r:.5,e.globalAlpha=.3*(null!==(i=t.style.opacity)&&void 0!==i?i:1),e.stroke(a)),e.restore()}function Hn(e,t){var n,o;if(!t.pathD)return;e.save();const r=new Path2D(t.pathD);e.strokeStyle=t.style.stroke||"#999",e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.stroke(r),t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=t.style.fill,e.globalAlpha=null!==(o=t.style.fillOpacity)&&void 0!==o?o:.1,e.fill(r)),e.restore()}Cn.displayName="NetworkSVGOverlay";const $n={category10:H,tableau10:X,set3:G,blues:Y,reds:F,greens:R,oranges:I,purples:z,viridis:_,plasma:$},_n=H,zn=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"];function In(e,t,n){if("function"==typeof t)return t(e);const o=e[t];return n?n(o):_n[Math.abs(function(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n),t&=t;return Math.abs(t)}(o+""))%_n.length]}function Rn(e,t,n="category10"){const o=Array.from(new Set(e.map(e=>e[t]))),r=o.every(e=>"number"==typeof e||!isNaN(Number(e)));if(Array.isArray(n))return v().domain(o).range(n).unknown("#999");const i=$n[n]||$n.category10;if(r&&"function"==typeof i)return e=>i(Number(e)/Math.max(...o.map(Number)));{const e=Array.isArray(i)?i:_n;return v().domain(o).range(e).unknown("#999")}}function Fn(e,t,n=[3,20],o){let r;if(r="function"==typeof t?t(e):e[t],!o)return r;const[i,a]=o,[s,l]=n;return a===i?(s+l)/2:s+(r-i)/(a-i)*(l-s)}const Yn={top:20,right:80,bottom:20,left:80},Gn={top:40,right:40,bottom:40,left:40},Xn=new Set(["chord","force","circlepack"]),qn=[800,600],Vn={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 Un({data:t}){var n,o,r,i,a,s;if("edge"===t.type){const n=t.data;return e.createElement("div",{className:"semiotic-tooltip",style:Vn},e.createElement("div",{style:{fontWeight:600}},"object"==typeof n.source?n.source.id:n.source," → ","object"==typeof n.target?n.target.id:n.target),null!=n.value&&e.createElement("div",{style:{marginTop:4,opacity:.8}},"Value:"," ","number"==typeof n.value?n.value.toLocaleString():n.value+""))}const l=t.data,c=null==l?void 0:l.__hierarchyNode;if(c){const t=[];let a=c;for(;a;){const e=null!==(i=null!==(o=null===(n=a.data)||void 0===n?void 0:n.name)&&void 0!==o?o:null===(r=a.data)||void 0===r?void 0:r.id)&&void 0!==i?i:l.id;null!=e&&t.unshift(e+""),a=a.parent}t.length>1&&t.shift();const s=t.length-1;return e.createElement("div",{className:"semiotic-tooltip",style:Vn},e.createElement("div",null,t.map((t,n)=>e.createElement("span",{key:n},n>0&&e.createElement("span",{style:{margin:"0 3px",opacity:.5}}," → "),n===s?e.createElement("strong",null,t):e.createElement("span",{style:{opacity:.7}},t)))),null!=l.value&&l.value>0&&e.createElement("div",{style:{marginTop:4,opacity:.8}},"number"==typeof l.value?l.value.toLocaleString():l.value+""))}const u=((null===(a=l.sourceLinks)||void 0===a?void 0:a.length)||0)+((null===(s=l.targetLinks)||void 0===s?void 0:s.length)||0),d=(l.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(l.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0);return e.createElement("div",{className:"semiotic-tooltip",style:Vn},e.createElement("div",{style:{fontWeight:600}},l.id),null!=l.value&&l.value>0&&e.createElement("div",{style:{marginTop:4,opacity:.8}},"Total:"," ","number"==typeof l.value?l.value.toLocaleString():l.value+""),u>0&&e.createElement("div",{style:{marginTop:4,opacity:.8}},"Connections: ",u,d!==u&&` (weighted: ${d.toLocaleString()})`))}const Zn=i(function(i,l){const{chartType:c,nodes:u,edges:d,data:h,initialEdges:g,nodeIDAccessor:p="id",sourceAccessor:y="source",targetAccessor:f="target",valueAccessor:m="value",childrenAccessor:v,hierarchySum:b,orientation:x="horizontal",nodeAlign:w="justify",nodePaddingRatio:k=.05,nodeWidth:A=15,iterations:E=300,forceStrength:S=.1,padAngle:O=.01,groupWidth:L=20,sortGroups:j,edgeSort:P,treeOrientation:M="vertical",edgeType:N="curve",padding:D,paddingTop:C,tensionConfig:T,showParticles:B=!1,particleStyle:W,nodeStyle:H,edgeStyle:$,colorBy:_,colorScheme:z="category10",edgeColorBy:I="source",edgeOpacity:R=.5,colorByDepth:F=!1,nodeSize:Y=8,nodeSizeRange:G=[5,20],nodeLabel:X,showLabels:q=!0,size:V=qn,responsiveWidth:U,responsiveHeight:Z,margin:Q,className:K,background:J,enableHover:ee=!0,tooltipContent:te,customHoverBehavior:ne,customClickBehavior:oe,onObservation:re,chartId:ie,onTopologyChange:ae,annotations:se,svgAnnotationRules:le,legend:ce,title:ue,foregroundGraphics:de,backgroundGraphics:he,decay:ge,pulse:pe,staleness:ye,thresholds:fe}=i,me=Xn.has(c)?Gn:Yn,[ve,be]=Ae(V,U,Z),xe=Object.assign(Object.assign({},me),Q),ke=be[0]-xe.left-xe.right,Ee=be[1]-xe.top-xe.bottom,Se=r(()=>Object.assign(Object.assign({},bt),T),[T]),Oe=r(()=>Object.assign(Object.assign({},xt),W),[W]),Le=r(()=>({chartType:c,nodeIDAccessor:p,sourceAccessor:y,targetAccessor:f,valueAccessor:m,childrenAccessor:v,hierarchySum:b,orientation:x,nodeAlign:w,nodePaddingRatio:k,nodeWidth:A,iterations:E,forceStrength:S,padAngle:O,groupWidth:L,sortGroups:j,edgeSort:P,treeOrientation:M,edgeType:N,padding:D,paddingTop:C,tensionConfig:Se,showParticles:B,particleStyle:Oe,nodeStyle:H,edgeStyle:$,nodeLabel:X,showLabels:q,colorBy:_,colorScheme:z,edgeColorBy:I,edgeOpacity:R,colorByDepth:F,nodeSize:Y,nodeSizeRange:G,decay:ge,pulse:pe,staleness:ye,thresholds:fe}),[c,p,y,f,m,v,b,x,w,k,A,E,S,O,L,j,P,M,N,D,C,Se,B,Oe,H,$,X,q,_,z,I,R,F,Y,G,ge,pe,ye,fe]),je=t(null),Pe=t(0),Me=t(0),Ne=t(!0),De=t(()=>{}),Ce=t(null);Ce.current||(Ce.current=new jn(Le));const[Te,Be]=n(null),[We,He]=n(0),[$e,_e]=n(0),[ze,Ie]=n(!1),Re=t(null),Fe=t(new Map),Ye=t(0),Ge=a(e=>{if("function"==typeof _)return _(e);if("string"==typeof _&&e.data){const t=e.data[_];if(void 0!==t){if(!Fe.current.has(t+"")){const e=Array.isArray(z)?z:_n;Fe.current.set(t+"",e[Ye.current++%e.length])}return Fe.current.get(t+"")}}if(!Fe.current.has(e.id)){const t=Array.isArray(z)?z:_n;Fe.current.set(e.id,t[Ye.current++%t.length])}return Fe.current.get(e.id)},[_,z]),Xe=a(e=>{if("function"==typeof I)return I(e);const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;return"target"===I&&n?Ge(n):t?Ge(t):"#999"},[I,Ge]),qe=a(e=>{if(!(null==W?void 0:W.colorBy))return Xe(e);const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;return"target"===Oe.colorBy&&n?Ge(n):t?Ge(t):"#999"},[null==W?void 0:W.colorBy,Oe.colorBy,Ge,Xe]),Ve="sankey"===c&&B||!!pe,Ue=a(()=>{Pe.current&&!Ve||Pe.current||(Pe.current=requestAnimationFrame(()=>De.current()))},[Ve]);o(()=>{var e;null===(e=Ce.current)||void 0===e||e.updateConfig(Le),Ne.current=!0,Ue()},[Le,Ue]);const Ze=a(()=>{const e=Ce.current;if(!e)return;e.runLayout([ke,Ee]),e.buildScene([ke,Ee]),Ne.current=!0;const t=Array.isArray(z)?z:_n,n=Array.from(e.nodes.values());for(let e=0;n.length>e;e++){const o=n[e];Fe.current.has(o.id)||Fe.current.set(o.id,t[e%t.length])}if(Ye.current=n.length,He(e.layoutVersion),ae){const{nodes:t,edges:n}=e.getLayoutData();ae(t,n)}},[ke,Ee,ae,z]),Qe=a(e=>{const t=Ce.current;t&&(t.ingestEdge(e)&&Ze(),Ue())},[Ze,Ue]),Ke=a(e=>{const t=Ce.current;if(!t)return;let n=!1;for(const o of e)t.ingestEdge(o)&&(n=!0);n&&Ze(),Ue()},[Ze,Ue]),Je=a(()=>{var e;null===(e=Ce.current)||void 0===e||e.clear(),Fe.current.clear(),Ye.current=0,He(0),Be(null),Re.current=null,Ne.current=!0,Ue()},[Ue]),et=a(()=>{const e=Ce.current;e&&(e.tension+=999,Ze(),Ue())},[Ze,Ue]);s(l,()=>({push:Qe,pushMany:Ke,clear:Je,getTopology:()=>{var e,t;return null!==(t=null===(e=Ce.current)||void 0===e?void 0:e.getLayoutData())&&void 0!==t?t:{nodes:[],edges:[]}},getTopologyDiff:()=>{const e=Ce.current;return e?{addedNodes:Array.from(e.addedNodes),removedNodes:Array.from(e.removedNodes),addedEdges:Array.from(e.addedEdges),removedEdges:Array.from(e.removedEdges)}:{addedNodes:[],removedNodes:[],addedEdges:[],removedEdges:[]}},relayout:et,getTension:()=>{var e,t;return null!==(t=null===(e=Ce.current)||void 0===e?void 0:e.tension)&&void 0!==t?t:0}}),[Qe,Ke,Je,et]);const tt=["tree","cluster","treemap","circlepack","partition"].includes(c),nt=tt?h||(Array.isArray(d)?void 0:d):void 0;o(()=>{const e=Ce.current;if(e)if(tt&&nt)e.ingestHierarchy(nt,[ke,Ee]),e.buildScene([ke,Ee]),Ne.current=!0,Ue();else{const t=u||[],n=Array.isArray(d)?d:[];if(0===t.length&&0===n.length)return;e.ingestBounded(t,n,[ke,Ee]),e.buildScene([ke,Ee]);const o=Array.isArray(z)?z:_n,r=Array.from(e.nodes.values());for(let e=0;r.length>e;e++){const t=r[e];Fe.current.has(t.id)||Fe.current.set(t.id,o[e%o.length])}Ye.current=r.length,Ne.current=!0,Ue()}},[u,d,h,nt,tt,ke,Ee,Le,Ue,z]),o(()=>{g&&g.length>0&&Ke(g)},[]);const ot=a(e=>{if(ne&&ne(e),re){const t=Date.now();re(e?{type:"hover",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:ie}:{type:"hover-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:ie})}},[ne,re,ie]),rt=a(e=>{if(oe&&oe(e),re){const t=Date.now();re(e?{type:"click",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:ie}:{type:"click-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:ie})}},[oe,re,ie]),it=t(()=>{}),at=t(()=>{});it.current=e=>{if(!ee)return;const t=je.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-xe.left,r=e.clientY-n.top-xe.top;if(0>o||o>ke||0>r||r>Ee)return void(Re.current&&(Re.current=null,Be(null),ot&&(ot(null),Ne.current=!0),Ue()));const i=Ce.current;if(!i)return;const a=Mn(i.sceneNodes,i.sceneEdges,o,r);if(!a)return void(Re.current&&(Re.current=null,Be(null),ot&&(ot(null),Ne.current=!0),Ue()));const s={type:a.type,data:a.datum,x:a.x,y:a.y};Re.current=s,Be(s),ot&&(ot(s),Ne.current=!0),Ue()},at.current=()=>{Re.current&&(Re.current=null,Be(null),ot&&(ot(null),Ne.current=!0),Ue())};const st=t(()=>{});st.current=e=>{if(!oe&&!re)return;const t=je.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-xe.left,r=e.clientY-n.top-xe.top;if(0>o||o>ke||0>r||r>Ee)return;const i=Ce.current;if(!i)return;const a=Mn(i.sceneNodes,i.sceneEdges,o,r);rt(a?{type:a.type,data:a.datum,x:a.x,y:a.y}:null)},a(e=>it.current(e),[]);const lt=a(()=>at.current(),[]),ct=a(e=>st.current(e),[]),ut=t(-1),dt=a(e=>{const t=Ce.current;if(!t)return;const n=function(e){const t=[];for(const n of e)"circle"===n.type&&null!=n.cx?t.push({x:n.cx,y:n.cy,datum:n.datum}):"rect"===n.type&&null!=n.x?t.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum}):"arc"===n.type&&null!=n.cx&&t.push({x:n.cx,y:n.cy,datum:n.datum});return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}(t.sceneNodes);if(0===n.length)return;const o=ut.current,r=we(e.key,0>o?-1:o,n.length);if(null===r)return;if(e.preventDefault(),0>r)return ut.current=-1,Re.current=null,Be(null),ot&&(ot(null),Ne.current=!0),void Ue();const i=0>o?0:r;ut.current=i;const a=n[i],s={type:"node",data:a.datum,x:a.x,y:a.y};Re.current=s,Be(s),ot&&(ot(s),Ne.current=!0),Ue()},[ot,Ue]),ht=a(e=>{ut.current=-1,it.current(e)},[]);De.current=()=>{var e,t,n;Pe.current=0;const o=je.current;if(!o)return;const r=o.getContext("2d");if(!r)return;const i=Ce.current;if(!i)return;const a=performance.now(),s=Me.current?Math.min((a-Me.current)/1e3,.1):.016;Me.current=a;const l=i.advanceTransition(a);(l||Ne.current)&&i.buildScene([ke,Ee]);const c="undefined"!=typeof window&&window.devicePixelRatio||1;o.width=be[0]*c,o.height=be[1]*c,o.style.width=be[0]+"px",o.style.height=be[1]+"px",r.scale(c,c),r.translate(xe.left,xe.top),r.clearRect(-xe.left,-xe.top,be[0],be[1]),J&&(r.fillStyle=J,r.fillRect(0,0,ke,Ee)),ge&&i.applyDecay(),pe&&i.applyPulse(a),fe&&i.applyThresholds(a),i.applyTopologyDiff(a);const u=null!==(e=null==ye?void 0:ye.threshold)&&void 0!==e?e:5e3,d=ye&&i.lastIngestTime>0&&a-i.lastIngestTime>u;if(d&&(r.globalAlpha=null!==(t=null==ye?void 0:ye.dimOpacity)&&void 0!==t?t:.5),function(e,t){for(const n of t)switch(n.type){case"bezier":Tn(e,n);break;case"line":Bn(e,n);break;case"ribbon":Wn(e,n);break;case"curved":Hn(e,n)}}(r,i.sceneEdges),function(e,t){var n,o,r;for(const i of t){if("rect"!==i.type)continue;const t=i;t.w>0&&t.h>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(n=t.style.opacity)&&void 0!==n?n:1)*t.style.fillOpacity),e.fillRect(t.x,t.y,t.w,t.h)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(o=t.style.strokeWidth)&&void 0!==o?o:1,e.globalAlpha=null!==(r=t.style.opacity)&&void 0!==r?r:1,e.strokeRect(t.x,t.y,t.w,t.h)),t._pulseIntensity&&t._pulseIntensity>0&&(e.globalAlpha=.3*t._pulseIntensity,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h)),e.restore())}}(r,i.sceneNodes),function(e,t){var n,o,r,i;for(const a of t){if("circle"!==a.type)continue;const t=a;if(t.r>0){if(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.r,0,2*Math.PI),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(n=t.style.opacity)&&void 0!==n?n:1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(o=t.style.strokeWidth)&&void 0!==o?o:1,e.globalAlpha=null!==(r=t.style.opacity)&&void 0!==r?r:1,e.stroke()),t._pulseIntensity&&t._pulseIntensity>0){const n=null!==(i=t._pulseGlowRadius)&&void 0!==i?i:4,o=t.r+n*t._pulseIntensity;e.beginPath(),e.arc(t.cx,t.cy,o,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=.6*t._pulseIntensity,e.stroke()}e.restore()}}}(r,i.sceneNodes),function(e,t){var n,o,r;for(const i of t){if("arc"!==i.type)continue;const t=i;e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.outerR,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerR,t.endAngle,t.startAngle,!0),e.closePath(),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(n=t.style.opacity)&&void 0!==n?n:1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(o=t.style.strokeWidth)&&void 0!==o?o:1,e.globalAlpha=null!==(r=t.style.opacity)&&void 0!==r?r:1,e.stroke()),e.restore()}}(r,i.sceneNodes),B&&i.particlePool&&!d){const e=Array.from(i.edges.values());if(e.length>0){!function(e,t,n,o){var r,i;const a=null!==(r=o.spawnRate)&&void 0!==r?r:xt.spawnRate,s=null!==(i=o.maxPerEdge)&&void 0!==i?i:xt.maxPerEdge;for(let o=0;t.length>o;o++){const r=t[o];if(!r.bezier)continue;if(e.countForEdge(o)>=s)continue;const i=r.value*a*n*(r.bezier.circular?.3:1),l=Math.floor(i),c=i-l;let u=l;Math.random()<c&&u++;for(let t=0;u>t&&e.countForEdge(o)<s;t++)e.spawn(o)}}(i.particlePool,e,s,Oe);const t=.5*(null!==(n=Oe.speedMultiplier)&&void 0!==n?n:1);let o;if(Oe.proportionalSpeed){const t=e.reduce((e,t)=>Math.max(e,t.value||1),1);o=e.map(e=>.3+(e.value||1)/t*1.7)}i.particlePool.step(s,t,e,o),function(e,t,n,o,r){var i,a;const s=null!==(i=o.radius)&&void 0!==i?i:xt.radius,l=null!==(a=o.opacity)&&void 0!==a?a:xt.opacity;e.globalAlpha=l;for(let i=0;t.particles.length>i;i++){const a=t.particles[i];if(!a.active)continue;const l=n[a.edgeIndex];if(l){if("function"==typeof o.color){const t="object"==typeof l.source?l.source:null;e.fillStyle=t?o.color(l,t):"#666"}else e.fillStyle=o.color&&"inherit"!==o.color?o.color:r(l);e.beginPath(),e.arc(a.x,a.y,s,0,2*Math.PI),e.fill()}}e.globalAlpha=1}(r,i.particlePool,e,Oe,qe)}}d&&(r.globalAlpha=1);const h=Ne.current;Ne.current=!1,(h||l)&&_e(e=>e+1),(Ve||l||i.hasActivePulses||i.hasActiveThresholds||i.hasActiveTopologyDiff)&&(Pe.current=requestAnimationFrame(()=>De.current()))},o(()=>(Ue(),()=>{Pe.current&&(cancelAnimationFrame(Pe.current),Pe.current=0)}),[Ue]),o(()=>{Ne.current=!0,Ue()},[c,ke,Ee,J,Ue]),o(()=>{if(!ye)return;const e=setInterval(()=>{var e;const t=Ce.current;if(!t||0===t.lastIngestTime)return;const n="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(e=ye.threshold)&&void 0!==e?e:5e3,r=n-t.lastIngestTime>o;r!==ze&&(Ie(r),Ne.current=!0,Ue())},1e3);return()=>clearInterval(e)},[ye,ze,Ue]);const gt=ee&&Te?e.createElement("div",{className:"stream-network-tooltip",style:{position:"absolute",left:xe.left+Te.x,top:xe.top+Te.y,transform:`translate(${Te.x>.6*ke?"calc(-100% - 12px)":"12px"}, ${.3*Ee>Te.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:2}},te?te(Te):e.createElement(Un,{data:Te})):null,pt=Ce.current;return e.createElement("div",{ref:ve,className:"stream-network-frame"+(K?" "+K:""),role:"img","aria-label":"string"==typeof ue?ue:"Network chart",tabIndex:0,style:{position:"relative",width:U?"100%":be[0],height:Z?"100%":be[1]},onMouseMove:ee?ht:void 0,onMouseLeave:ee?lt:void 0,onClick:oe||re?ct:void 0,onKeyDown:dt},he&&e.createElement("svg",{style:{position:"absolute",top:0,left:0,width:be[0],height:be[1],pointerEvents:"none"}},e.createElement("g",{transform:`translate(${xe.left},${xe.top})`},he)),e.createElement("canvas",{ref:je,style:{position:"absolute",top:0,left:0}}),e.createElement(Cn,{width:ke,height:Ee,totalWidth:be[0],totalHeight:be[1],margin:xe,labels:(null==pt?void 0:pt.labels)||[],title:ue,legend:ce,foregroundGraphics:de,annotations:se,svgAnnotationRules:le,annotationFrame:$e}),gt,(null==ye?void 0:ye.showBadge)&&e.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===ye.badgePosition?{top:4,left:4}:"bottom-left"===ye.badgePosition?{bottom:4,left:4}:"bottom-right"===ye.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{background:ze?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"})},ze?"STALE":"LIVE"))});Zn.displayName="StreamNetworkFrame";const Qn={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"8px 12px",borderRadius:"4px",fontSize:"14px",lineHeight:"1.5",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"};function Kn(e,t){return"function"==typeof t?t(e):e[t]}function Jn(e,t){return t?t(e):null==e?"":"number"==typeof e?e.toLocaleString():e instanceof Date?e.toLocaleDateString():"object"==typeof e&&null!==e?void 0!==e.id?e.id+"":void 0!==e.name?e.name+"":JSON.stringify(e):e+""}function eo(t={}){const{fields:n,title:o,format:r,style:i={},className:a=""}=t;return t=>{if(!t||"object"!=typeof t)return null;let s;const l=[];if(o){const e=Kn(t,o);s=Jn(e,r)}if(n&&n.length>0)n.forEach(e=>{let n,o,i;"string"==typeof e?(n=e,o=e,i=r):(n=e.label,o=e.accessor||e.key||"",i=e.format||r);const a=Kn(t,o);l.push({label:n,value:Jn(a,i)})});else if(!o){const e=["value","y","name","id","label"];for(const n of e)if(void 0!==t[n]){s=Jn(t[n],r);break}if(!s){const e=Object.keys(t).filter(e=>!e.startsWith("_"));e.length>0&&(s=Jn(t[e[0]],r))}}const c=Object.assign(Object.assign({},Qn),i);return e.createElement("div",{className:("semiotic-tooltip "+a).trim(),style:c},s&&e.createElement("div",{style:{fontWeight:l.length>0?"bold":"normal"}},s),l.map((t,n)=>e.createElement("div",{key:n,style:{marginTop:0===n&&s?"4px":0}},t.label&&e.createElement("span",null,t.label,": "),t.value)))}}function to(t={}){const{fields:n=[],title:o,format:r,style:i={},className:a="",showLabels:s=!0,separator:l=": "}=t;return t=>{if(!t||"object"!=typeof t)return null;const c=[];if(o){const e=Kn(t,o);c.push({value:Jn(e,r)})}n&&Array.isArray(n)&&n.length>0?n.forEach(e=>{let n,o,i;"string"==typeof e?(n=e,o=e,i=r):(n=e.label,o=e.accessor||e.key||"",i=e.format||r);const a=Jn(Kn(t,o),i);c.push({label:s?n:void 0,value:a})}):Object.keys(t).filter(e=>!e.startsWith("_")&&"data"!==e).forEach(e=>{c.push({label:s?e:void 0,value:Jn(t[e],r)})});const u=Object.assign(Object.assign({},Qn),i);return Array.isArray(c)&&0!==c.length?e.createElement("div",{className:("semiotic-tooltip semiotic-tooltip-multiline "+a).trim(),style:u},c.map((t,n)=>e.createElement("div",{key:n,style:{marginBottom:c.length-1>n?"4px":0}},t.label&&e.createElement("strong",null,t.label,l),t.value))):null}}function no(e){return!0===e||("function"==typeof e?e:!1!==e&&void 0!==e&&("object"!=typeof e||null===e||!("fields"in e)&&!("title"in e)||eo(e)))}function oo(e){return"string"==typeof e?e:"value"}function ro(e){return null==e?"–":"number"==typeof e?Math.abs(e)>9999?e.toLocaleString():e+"":e instanceof Date?e.toLocaleDateString():e+""}function io(e,t){return"function"==typeof t?t(e):e[t]}function ao(t){return n=>{const o=n.data;return o?e.createElement("div",{className:"semiotic-tooltip",style:Qn},t.map((t,n)=>{const r=ro(io(o,t.accessor));return e.createElement("div",{key:n,style:n>0?{marginTop:2}:void 0},e.createElement("span",{style:{opacity:.8}},t.label,": "),e.createElement("span",{style:{fontWeight:"color"===t.role||"group"===t.role?"bold":"normal"}},r))})):null}}function so({categoryAccessor:t,valueAccessor:n,groupAccessor:o,groupLabel:r,pieData:i=!1}){return a=>{var s;const l=i?(null===(s=a.data)||void 0===s?void 0:s[0])||a.data||a:a.data||a,c=io(l,t),u=io(l,n),d=o?io(l,o):void 0;return e.createElement("div",{className:"semiotic-tooltip",style:Qn},e.createElement("div",{style:{fontWeight:"bold"}},ro(c)),e.createElement("div",{style:{marginTop:4}},ro(u)),null!=d&&e.createElement("div",{style:{marginTop:2,opacity:.8}},r||oo(o),": ",ro(d)))}}const lo=c(null);function co({colors:t,categories:n,colorScheme:o="category10",children:i}){const a=r(()=>{if(t)return t;if(n){const e=Array.isArray(o)?o:$n[o]||_n,t={};for(let o=0;n.length>o;o++)t[n[o]]=e[o%e.length];return t}return{}},[t,n,o]);return e.createElement(lo.Provider,{value:a},i)}function uo(){return l(lo)}function ho(e){return e?"string"==typeof e?{name:e}:e:null}function go(e,t,n){return t?o=>{var r;const i=Object.assign({},e(o));if(t.isActive)if(t.predicate(o))(null==n?void 0:n.selectedStyle)&&Object.assign(i,n.selectedStyle);else{const e=null!==(r=null==n?void 0:n.unselectedOpacity)&&void 0!==r?r:.2;i.opacity=e,i.fillOpacity=e,i.strokeOpacity=e,(null==n?void 0:n.unselectedStyle)&&Object.assign(i,n.unselectedStyle)}return i}:e}function po(t){const o=c(null),i=yo(t);return[function({children:n}){const i=r(()=>yo(t),[]);return e.createElement(o.Provider,{value:i,children:n})},e=>{var t;const r=null!==(t=l(o))&&void 0!==t?t:i;return function(e,t){const[o,r]=n(t);return u(()=>e(()=>r(t)),[e]),o}(r.subscribe,()=>e(r.getState()))}]}function yo(e){const t=new EventTarget;let n=e(function(e){n=Object.assign(Object.assign({},n),e(n)),t.dispatchEvent(new CustomEvent("update"))});return{getState:()=>n,subscribe:function(e){return t.addEventListener("update",e),()=>t.removeEventListener("update",e)}}}function fo(e){const t=[];for(const[n,o]of Object.entries(e.fields))if("point"===o.type)t.push(e=>o.values.has(e[n]));else{const[e,r]=o.range;t.push(t=>{const o=t[n];return o>=e&&r>=o})}return e=>t.every(t=>t(e))}function mo(e,t){const n=[];for(const[o,r]of e.clauses)"crossfilter"===e.resolution&&o===t||n.push(fo(r));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}function vo(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}co.displayName="CategoryColorProvider";const[bo,xo]=po(e=>({selections:new Map,setClause(t,n){e(e=>{const o=new Map(e.selections),r=vo(o,t),i=new Map(r.clauses);return i.set(n.clientId,n),o.set(t,Object.assign(Object.assign({},r),{clauses:i})),{selections:o}})},clearClause(t,n){e(e=>{const o=e.selections.get(t);if(!o)return{};const r=new Map(e.selections),i=new Map(o.clauses);return i.delete(n),r.set(t,Object.assign(Object.assign({},o),{clauses:i})),{selections:r}})},setResolution(t,n){e(e=>{const o=new Map(e.selections),r=vo(o,t);return o.set(t,Object.assign(Object.assign({},r),{resolution:n})),{selections:o}})},clearSelection(t){e(e=>{const n=new Map(e.selections),o=n.get(t);return o&&n.set(t,Object.assign(Object.assign({},o),{clauses:new Map})),{selections:n}})}}));function wo(e){const t=d(),n=e.clientId||t,{name:o}=e,i=xo(e=>e.selections.get(o)),s=xo(e=>e.setClause),l=xo(e=>e.clearClause),c=r(()=>!!i&&i.clauses.size>0,[i]);return{predicate:r(()=>i&&0!==i.clauses.size?mo(i,n):()=>!0,[i,n]),isActive:c,selectPoints:a(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"point",values:new Set(o)};s(o,{clientId:n,type:"point",fields:t})},[n,o,s]),selectInterval:a(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"interval",range:o};s(o,{clientId:n,type:"interval",fields:t})},[n,o,s]),clear:a(()=>{l(o,n)},[l,o,n]),clientId:n}}function ko(e){const t=e.name||"hover",{fields:n}=e,{predicate:o,isActive:r,selectPoints:i,clear:s}=wo({name:t});return{onHover:a(e=>{if(!e)return void s();const t={};for(const o of n){const n=e[o];void 0!==n&&(t[o]=[n])}Object.keys(t).length>0&&i(t)},[n,i,s,t]),predicate:o,isActive:r}}function Ao(e){const{name:t,xField:n,yField:o}=e,{predicate:i,isActive:s,selectInterval:l,clear:c}=wo({name:t}),u=n&&o?"xyBrush":n?"xBrush":"yBrush",d=a(e=>{if(!e)return void c();const t={};"xyBrush"===u&&Array.isArray(e)&&2===e.length?(n&&(t[n]=[Math.min(e[0][0],e[1][0]),Math.max(e[0][0],e[1][0])]),o&&(t[o]=[Math.min(e[0][1],e[1][1]),Math.max(e[0][1],e[1][1])])):"xBrush"===u&&Array.isArray(e)?n&&(t[n]=[Math.min(...e),Math.max(...e)]):"yBrush"===u&&Array.isArray(e)&&o&&(t[o]=[Math.min(...e),Math.max(...e)]),Object.keys(t).length>0&&l(t)},[u,n,o,l,c]);return{brushInteraction:r(()=>({brush:u,during:d,end:d}),[u,d]),predicate:i,isActive:s,clear:c}}function Eo(e,t,n){const o=xo(e=>e.selections.get(t));return r(()=>{if(!o||0===o.clauses.size)return e;const t=mo(o,n);return e.filter(t)},[e,o,n])}const[So,Oo]=po(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const n=e.observations;return n.push(t),n.length>e.maxObservations&&n.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}})),Lo="#007bff";function jo(e){return"function"==typeof e?e:t=>t[e]}function Po(e,t,n="category10"){const o=uo();return r(()=>{if(t&&"function"!=typeof t)return o&&Object.keys(o).length>0?r=>o[r]||Rn(e,t,n)(r):Rn(e,t,n)},[e,t,n,o])}function Mo(e,t,n){return r(()=>{if(!t)return e;const o=[...e];if("function"==typeof t)return o.sort(t);const r=jo(n);return o.sort("asc"===t?(e,t)=>r(e)-r(t):(e,t)=>r(t)-r(e))},[e,t,n])}function No({selection:e,linkedHover:t,fallbackFields:n=[],unwrapData:o=!1,onObservation:r,chartType:i,chartId:s}){const l=function(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields}:null}(t,n),c=wo({name:(null==e?void 0:e.name)||"__unused__"}),u=ko({name:(null==l?void 0:l.name)||"hover",fields:(null==l?void 0:l.fields)||n||[]}),d=Oo(e=>e.pushObservation),h=e?{isActive:c.isActive,predicate:c.predicate}:null,g=a(e=>{var n,o;if(t)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]),u.onHover(t)}else u.onHover(null);if(r||d){const t={timestamp:Date.now(),chartType:i||"unknown",chartId:s};if(e){let i=e.data||e.datum||e;Array.isArray(i)&&(i=i[0]);const a=Object.assign(Object.assign({},t),{type:"hover",datum:i||{},x:null!==(n=e.x)&&void 0!==n?n:0,y:null!==(o=e.y)&&void 0!==o?o:0});r&&r(a),d&&d(a)}else{const e=Object.assign(Object.assign({},t),{type:"hover-end"});r&&r(e),d&&d(e)}}},[t,u,r,i,s,d]),p=a(e=>{var t,n;if(r||d){const o={timestamp:Date.now(),chartType:i||"unknown",chartId:s};if(e){let i=e.data||e.datum||e;Array.isArray(i)&&(i=i[0]);const a=Object.assign(Object.assign({},o),{type:"click",datum:i||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0});r&&r(a),d&&d(a)}else{const e=Object.assign(Object.assign({},o),{type:"click-end"});r&&r(e),d&&d(e)}}},[r,d,i,s]);return{activeSelectionHook:h,customHoverBehavior:g,customClickBehavior:p}}function Do({data:e,colorBy:t,colorScale:n,showLegend:o,userMargin:i,defaults:a={top:50,bottom:60,left:70,right:40}}){const s=void 0!==o?o:!!t,l=r(()=>{if(s&&t)return function({data:e,colorBy:t,colorScale:n,getColor:o,strokeColor:r,strokeWidth:i}){const a=Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t]))).map(r=>{const i=e.find("function"==typeof t?e=>t(e)===r:e=>e[t]===r),a=i?o(i,t,n):n?n(r):"#000000";return{label:r+"",color:a}});return{legendGroups:[{styleFn:e=>{const t={fill:e.color,stroke:e.color};return void 0!==r&&(t.stroke=r),void 0!==i&&(t.strokeWidth=i),t},type:"fill",items:a,label:""}]}}({data:e,colorBy:t,colorScale:n,getColor:In})},[s,t,e,n]),c=r(()=>{const e=Object.assign(Object.assign({},a),i);return l&&120>e.right&&(e.right=120),e},[a,i,l]);return{legend:l,margin:c}}const Co={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 To(e,t,n){var o,r,i,a,s,l;const c=Co[e||"primary"],u="context"===e||"sparkline"===e;return{width:null!==(o=t.width)&&void 0!==o?o:e&&"primary"!==e||!(null==n?void 0:n.width)?c.width:n.width,height:null!==(r=t.height)&&void 0!==r?r:e&&"primary"!==e||!(null==n?void 0:n.height)?c.height:n.height,showAxes:c.showAxes,showGrid:null!==(i=t.showGrid)&&void 0!==i?i:c.showGrid,enableHover:null!==(a=t.enableHover)&&void 0!==a?a:!!t.linkedHover||c.enableHover,showLegend:null!==(s=t.showLegend)&&void 0!==s?s:c.showLegend,showLabels:null!==(l=t.showLabels)&&void 0!==l?l:c.showLabels,title:u?void 0:t.title,xLabel:u?void 0:t.xLabel,yLabel:u?void 0:t.yLabel,categoryLabel:u?void 0:t.categoryLabel,valueLabel:u?void 0:t.valueLabel,marginDefaults:c.marginDefaults}}function Bo({componentName:t,message:n,width:o,height:r}){return e.createElement("div",{role:"alert",style:{width:o,height:Math.max(r,120),display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed rgba(128, 128, 128, 0.4)",borderRadius:8,background:"rgba(128, 128, 128, 0.04)",padding:24,boxSizing:"border-box"}},e.createElement("div",{style:{textAlign:"center",maxWidth:400}},e.createElement("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"}},t),e.createElement("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5}},n)))}class Wo extends e.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){var n,o;null===(o=(n=this.props).onError)||void 0===o||o.call(n,e,t)}render(){if(this.state.error){const{fallback:t}=this.props,n=this.state.error;return"function"==typeof t?t(n):void 0!==t?t:e.createElement(Bo,{componentName:"ChartErrorBoundary",message:n.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}var Ho;const $o="undefined"!=typeof process&&"production"!==(null===(Ho=process.env)||void 0===Ho?void 0:Ho.NODE_ENV);function _o({componentName:t,width:n,height:o,children:r}){return e.createElement(Wo,{fallback:r=>e.createElement(Bo,{componentName:t,message:r.message,width:n,height:o})},r)}function zo(e,t,n,o){if(!$o)return;if(!t||0===t.length)return;if("string"!=typeof o)return;const r=t[0];if(!r||"object"!=typeof r)return;if(o in r)return;const i=Object.keys(r).join(", ");console.warn(`[semiotic] ${e}: ${n} "${o}" not found in data. Available keys: ${i}`)}function Io(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:e}function Ro(e,t){if(0===t.length)return null;const n=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(n)||n.includes(e.toLowerCase()))||t[0]}function Fo({componentName:e,data:t,accessors:n,requiredProps:o}){if(o)for(const[t,n]of Object.entries(o))if(null==n)return`${e}: ${t} is required. Provide a field name or function.`;if(!t||!Array.isArray(t)||0===t.length)return e+": No data provided. Pass a non-empty array to the data prop.";if(!Array.isArray(t)&&"object"==typeof t)return e+": data should be an array, but received an object. If this is hierarchical data, use TreeDiagram, Treemap, or CirclePack instead.";if(n){const o=Io(t).find(e=>e&&"object"==typeof e);if(o){const t=Object.keys(o);for(const[r,i]of Object.entries(n))if(i&&"string"==typeof i&&!(i in o)){const n=Ro(i,t),o=n?` Try ${r}="${n}".`:"";return`${e}: ${r} "${i}" not found in data. Available fields: ${t.join(", ")}.${o}`}}}return null}function Yo({componentName:e,data:t,dataLabel:n="data"}){return null==t?`${e}: No ${n} provided. Pass a hierarchical object with children: { name: "root", children: [...] }.`:Array.isArray(t)?`${e}: ${n} should be a single root object, not an array. Expected: { name: "root", children: [...] }. If you have flat data, use LineChart, BarChart, or Scatterplot instead.`:null}function Go({componentName:e,nodes:t,edges:n,nodesRequired:o=!1,edgesRequired:r=!0,accessors:i}){if(r&&(!n||!Array.isArray(n)||0===n.length))return e+': No edges provided. Pass a non-empty array: edges={[{ source: "A", target: "B", value: 10 }, ...]}.';if(o&&(!t||!Array.isArray(t)||0===t.length))return e+': No nodes provided. Pass a non-empty array: nodes={[{ id: "A" }, { id: "B" }, ...]}.';if(i&&t&&t.length>0){const n=Io(t).find(e=>e&&"object"==typeof e);if(n){const t=Object.keys(n);for(const[o,r]of Object.entries(i))if(r&&"string"==typeof r&&!(r in n)){const n=Ro(r,t),i=n?` Try ${o}="${n}".`:"";return`${e}: ${o} "${r}" not found in node data. Available fields: ${t.join(", ")}.${i}`}}}return null}function Xo(t){const n=To(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:o,margin:i,className:a,xFormat:s,yFormat:l,xAccessor:c="x",yAccessor:u="y",colorBy:d,colorScheme:h="category10",sizeBy:g,sizeRange:p=[3,15],pointRadius:y=5,pointOpacity:f=.8,tooltip:m,marginalGraphics:v,pointIdAccessor:b,annotations:x,frameProps:w={},selection:k,linkedHover:A,linkedBrush:E,onObservation:S,chartId:O}=t,L=n.width,j=n.height,P=n.enableHover,M=n.showGrid,N=n.showLegend,D=n.title,C=n.xLabel,T=n.yLabel,B=o||[];zo("Scatterplot",B,"xAccessor",c),zo("Scatterplot",B,"yAccessor",u);const{activeSelectionHook:W,customHoverBehavior:H}=No({selection:k,linkedHover:A,fallbackFields:d?["string"==typeof d?d:""]:[],onObservation:S,chartType:"Scatterplot",chartId:O}),$=ho(E);Ao({name:(null==$?void 0:$.name)||"__unused_brush__",xField:(null==$?void 0:$.xField)||("string"==typeof c?c:void 0),yField:(null==$?void 0:$.yField)||("string"==typeof u?u:void 0)});const _=Po(B,d,h),z=r(()=>{if(!g||0===B.length)return;const e=B.map(e=>"function"==typeof g?g(e):e[g]);return[Math.min(...e),Math.max(...e)]},[B,g]),I=r(()=>e=>{const t={fillOpacity:f};return t.fill=d?In(e,d,_):Lo,t.r=g?Fn(e,g,p,z):y,t},[d,_,g,p,z,y,f]),R=r(()=>go(I,W,k),[I,W,k]),{legend:F,margin:Y}=Do({data:B,colorBy:d,colorScale:_,showLegend:N,userMargin:i,defaults:n.marginDefaults}),G=r(()=>ao([{label:C||oo(c),accessor:c,role:"x"},{label:T||oo(u),accessor:u,role:"y"},...d?[{label:oo(d),accessor:d,role:"color"}]:[],...g?[{label:oo(g),accessor:g,role:"size"}]:[]]),[c,u,C,T,d,g]),X=Fo({componentName:"Scatterplot",data:B,accessors:{xAccessor:c,yAccessor:u}});if(X)return e.createElement(Bo,{componentName:"Scatterplot",message:X,width:L,height:j});const q=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter",data:B,xAccessor:c,yAccessor:u,colorAccessor:d||void 0,sizeAccessor:g||void 0,sizeRange:p,pointStyle:R,colorScheme:h,size:[L,j],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Y,showAxes:n.showAxes,xLabel:C,yLabel:T,xFormat:s,yFormat:l,enableHover:P,showGrid:M},F&&{legend:F}),D&&{title:D}),a&&{className:a}),{tooltipContent:m?no(m):G}),(A||S)&&{customHoverBehavior:H}),v&&{marginalGraphics:v}),b&&{pointIdAccessor:b}),x&&x.length>0&&{annotations:x}),w);return e.createElement(_o,{componentName:"Scatterplot",width:L,height:j},e.createElement(Ke,Object.assign({},q)))}function qo(t){const n=To(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:o,className:i,xFormat:a,yFormat:s,xAccessor:l="x",yAccessor:c="y",orderAccessor:u,orderLabel:d,pointRadius:h=4,tooltip:g,pointIdAccessor:p,annotations:y,frameProps:f={},selection:m,linkedHover:v,onObservation:b,chartId:x}=t,w=n.width,k=n.height,A=n.enableHover,E=n.showGrid,S=n.title,O=n.xLabel,L=n.yLabel,j=o||[],P=r(()=>{if(!u||0===j.length)return j;const e="function"==typeof u?u:e=>e[u];return[...j].sort((t,n)=>{const o=e(t),r=e(n);return(o instanceof Date?o.getTime():+o)-(r instanceof Date?r.getTime():+r)})},[j,u]);zo("ConnectedScatterplot",P,"xAccessor",l),zo("ConnectedScatterplot",P,"yAccessor",c);const{activeSelectionHook:M,customHoverBehavior:N}=No({selection:m,linkedHover:v,fallbackFields:[],onObservation:b,chartType:"ConnectedScatterplot",chartId:x}),D=P.length,C=D>0&&100>D,T=r(()=>0===D?[]:P.map((e,t)=>_(1===D?.5:t/(D-1))),[P,D]);r(()=>null,[D]);const B=r(()=>{if(D>=2)return(t,n,o)=>{var r,i;if("connected-lines"!==t.type)return null;const a=o.scales;if(!a)return null;const s=null!==(r=a.x)&&void 0!==r?r:a.time,u=null!==(i=a.y)&&void 0!==i?i:a.value;if(!s||!u)return null;const d="string"==typeof l?e=>e[l]:l,g="string"==typeof c?e=>e[c]:c,p=[];for(let t=0;P.length-1>t;t++){const n=P[t],o=P[t+1],r=s(d(n)),i=u(g(n)),a=s(d(o)),l=u(g(o)),c=T[t];C&&p.push(e.createElement("line",{key:"halo-"+t,x1:r,y1:i,x2:a,y2:l,stroke:"white",strokeWidth:h+2,strokeOpacity:.5,strokeLinecap:"round"})),p.push(e.createElement("line",{key:"conn-"+t,x1:r,y1:i,x2:a,y2:l,stroke:c,strokeWidth:h,strokeLinecap:"round"}))}return e.createElement("g",{key:"ann-"+n},p)}},[P,T,h,C,l,c,D]),W=r(()=>e=>{const t=P.indexOf(e);return{fill:t>=0&&T.length>t?T[t]:"#6366f1",stroke:"white",strokeWidth:1,r:h,fillOpacity:1}},[P,T,h]),H=r(()=>go(W,M,m),[W,M,m]),$=Object.assign({top:50,right:40,bottom:60,left:70},t.margin),z=d||("string"==typeof u?u:"Order"),I=r(()=>ao([{label:O||oo(l),accessor:l,role:"x"},{label:L||oo(c),accessor:c,role:"y"},...u?[{label:z,accessor:u,role:"group"}]:[]]),[l,c,O,L,u,z]),R=Fo({componentName:"ConnectedScatterplot",data:P,accessors:{xAccessor:l,yAccessor:c}});if(R)return e.createElement(Bo,{componentName:"ConnectedScatterplot",message:R,width:w,height:k});const F=r(()=>[{type:"connected-lines"},...y||[]],[y]),Y=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter",data:P,xAccessor:l,yAccessor:c,pointStyle:H,size:[w,k],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:$,showAxes:n.showAxes,xLabel:O,yLabel:L,xFormat:a,yFormat:s,enableHover:A,showGrid:E},S&&{title:S}),i&&{className:i}),{tooltipContent:g?no(g):I}),(v||b)&&{customHoverBehavior:N}),p&&{pointIdAccessor:p}),{annotations:F,svgAnnotationRules:B}),f);return e.createElement(_o,{componentName:"ConnectedScatterplot",width:w,height:k},e.createElement(Ke,Object.assign({},Y)))}Xo.displayName="Scatterplot",qo.displayName="ConnectedScatterplot";const Vo="__forecastSegment";function Uo(e,t){return"function"==typeof t?t(e):!!e[t]}function Zo(t){var n,o;const i=To(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:a,margin:s,className:l,xFormat:c,yFormat:u,xAccessor:d="x",yAccessor:h="y",lineBy:g,lineDataAccessor:p="coordinates",colorBy:y,colorScheme:f="category10",curve:m="linear",showPoints:v=!1,pointRadius:b=3,fillArea:x=!1,areaOpacity:w=.3,lineWidth:k=2,tooltip:A,pointIdAccessor:E,annotations:S,anomaly:O,forecast:L,frameProps:j={},selection:P,linkedHover:M,onObservation:N,chartId:D}=t,C=i.width,T=i.height,B=i.enableHover,W=i.showGrid,H=i.showLegend,$=i.title,_=i.xLabel,z=i.yLabel,I=a||[];zo("LineChart",I,"xAccessor",d),zo("LineChart",I,"yAccessor",h);const R="string"==typeof d?d:"x",F="string"==typeof h?h:"y",Y=r(()=>L?function(e,t,n,o,r){return(i=o).isTraining||i.isForecast||i.isAnomaly||i.upperBounds||i.lowerBounds?function(e,t,n,o,r){var i,a,s;const{isTraining:l,isForecast:c,isAnomaly:u,upperBounds:d,lowerBounds:h,color:g="#6366f1",bandOpacity:p=.15,anomalyColor:y="#ef4444",anomalyRadius:f=6,label:m}=o,v=e.map(e=>{let t="observed";return c&&Uo(e,c)?t="forecast":l&&Uo(e,l)&&(t="training"),Object.assign(Object.assign({},e),{[Vo]:t})}),b=[];if(d&&h){const e="string"==typeof d?d:"__envUpper",t="string"==typeof h?h:"__envLower";if("function"==typeof d||"function"==typeof h)for(const n of v)"function"==typeof d&&(n[e]=d(n)),"function"==typeof h&&(n[t]=h(n));b.push({type:"envelope",upperAccessor:e,lowerAccessor:t,fill:g,fillOpacity:p,label:m})}return u&&b.push({type:"highlight",filter:e=>Uo(e,u),color:y,r:f,style:{stroke:y,strokeWidth:1.5,fill:y,fillOpacity:.7}}),r&&b.push({type:"anomaly-band",threshold:null!==(i=r.threshold)&&void 0!==i?i:2,showBand:!1!==r.showBand,fill:r.bandColor||"#6366f1",fillOpacity:null!==(a=r.bandOpacity)&&void 0!==a?a:.1,anomalyColor:r.anomalyColor||"#ef4444",anomalyRadius:null!==(s=r.anomalyRadius)&&void 0!==s?s:6,label:r.label}),{processedData:v,annotations:b}}(e,0,0,o,r):function(e,t,n,o,r){var i,a,s;const{trainEnd:l,steps:c=10,confidence:u=.95,color:d="#6366f1",bandOpacity:h=.15,label:g}=o;if(null==l)return{processedData:e,annotations:[]};const p=[],y=[];for(const n of e)n[t]>l?y.push(Object.assign(Object.assign({},n),{[Vo]:"observed"})):p.push(Object.assign(Object.assign({},n),{[Vo]:"training"}));const f=p.map(e=>[e[t],e[n]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]),m=[],v=[];if(f.length>=3){const o=f.length;let r=0,i=0,a=0,s=0;for(const[e,t]of f)r+=e,i+=t,a+=e*e,s+=e*t;const l=o*a-r*r;if(Math.abs(l)>1e-12){const a=(o*s-r*i)/l,p=(i-a*r)/o,y=e=>p+a*e,b=f.map(([e,t])=>t-y(e)).reduce((e,t)=>e+t*t,0),x=Math.sqrt(b/Math.max(o-2,1)),w=f.reduce((e,t)=>e+t[0],0)/o,k=f.reduce((e,t)=>e+Math.pow(t[0]-w,2),0),A=.99>u?.95>u?.9>u?1:1.645:1.96:2.576,E=e.map(e=>e[t]).filter(e=>null!=e&&isFinite(e)),S=Math.max(...E),O=f.length>1?(f[o-1][0]-f[0][0])/(o-1):1;for(let e=1;c>=e;e++){const r=S+e*O,i=y(r),a=x*Math.sqrt(1+1/o+(k>0?Math.pow(r-w,2)/k:0))*A;v.push({[t]:r,[n]:i,[Vo]:"forecast",__forecastUpper:i+a,__forecastLower:i-a})}m.push({type:"envelope",upperAccessor:"__forecastUpper",lowerAccessor:"__forecastLower",fill:d,fillOpacity:h,label:g})}}return m.push({type:"x-threshold",x:l,color:"#94a3b8",strokeWidth:1,strokeDasharray:"4,2",label:"Train / Forecast"}),r&&m.push({type:"anomaly-band",threshold:null!==(i=r.threshold)&&void 0!==i?i:2,showBand:!1!==r.showBand,fill:r.bandColor||"#6366f1",fillOpacity:null!==(a=r.bandOpacity)&&void 0!==a?a:.1,anomalyColor:r.anomalyColor||"#ef4444",anomalyRadius:null!==(s=r.anomalyRadius)&&void 0!==s?s:6,label:r.label}),{processedData:[...p,...y,...v],annotations:m}}(e,t,n,o,r);var i}(I,R,F,L,O):null,[I,L,O,R,F]),G=r(()=>Y?Y.annotations:O?function(e){var t,n,o;return[{type:"anomaly-band",threshold:null!==(t=e.threshold)&&void 0!==t?t:2,showBand:!1!==e.showBand,fill:e.bandColor||"#6366f1",fillOpacity:null!==(n=e.bandOpacity)&&void 0!==n?n:.1,anomalyColor:e.anomalyColor||"#ef4444",anomalyRadius:null!==(o=e.anomalyRadius)&&void 0!==o?o:6,label:e.label}]}(O):[],[Y,O]),X=Y?Y.processedData:I,q=L&&!g?Vo:g,{activeSelectionHook:V,customHoverBehavior:U}=No({selection:P,linkedHover:M,fallbackFields:y?["string"==typeof y?y:""]:[],onObservation:N,chartType:"LineChart",chartId:D}),Z=void 0!==(null===(n=X[0])||void 0===n?void 0:n[p]),Q=r(()=>{if(Z)return X;if(q){const e=X.reduce((e,t)=>{const n="function"==typeof q?q(t):t[q];if(!e[n]){const t={[p]:[]};"string"==typeof q&&(t[q]=n),e[n]=t}return e[n][p].push(t),e},{});return Object.values(e)}return[{[p]:X}]},[X,q,p,Z]),K=Po(X,y,f),J=r(()=>e=>{const t={strokeWidth:k};return t.stroke=y?In(e,y,K):Lo,x&&(t.fill=t.stroke,t.fillOpacity=w),t},[y,K,k,x,w]),ee=r(()=>L?function(e,t){var n,o;const r=null!==(n=t.trainDasharray)&&void 0!==n?n:"8,4",i=null!==(o=t.forecastDasharray)&&void 0!==o?o:"4,4",a=t.color||"#6366f1";return t=>{const n=e(t),o=t[Vo];return"training"===o?Object.assign(Object.assign({},n),{strokeDasharray:r}):"forecast"===o?Object.assign(Object.assign({},n),{stroke:a,strokeDasharray:i}):n}}(J,L):J,[J,L]),te=r(()=>go(ee,V,P),[ee,V,P]),ne=r(()=>{if(v)return e=>{const t={r:b,fillOpacity:1};return t.fill=y?In(e.parentLine||e,y,K):Lo,t}},[v,b,y,K]),oe=x?"area":"line",{legend:re,margin:ie}=Do({data:Q,colorBy:y,colorScale:K,showLegend:H,userMargin:s,defaults:i.marginDefaults}),ae=g||y,se=r(()=>ao([{label:_||oo(d),accessor:d,role:"x"},{label:z||oo(h),accessor:h,role:"y"},...ae?[{label:oo(ae),accessor:ae,role:"group"}]:[]]),[d,h,_,z,ae]),le=Fo({componentName:"LineChart",data:Z?(null===(o=X[0])||void 0===o?void 0:o[p])||[]:I,accessors:{xAccessor:d,yAccessor:h}});if(le)return e.createElement(Bo,{componentName:"LineChart",message:le,width:C,height:T});const ce=r(()=>Z||q?Q.flatMap(e=>{const t=e[p]||[];return q&&"string"==typeof q?t.map(t=>Object.assign(Object.assign({},t),{[q]:e[q]})):t}):X,[Q,p,Z,q,X]),ue=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:oe,data:ce,xAccessor:d,yAccessor:h,groupAccessor:q||void 0,curve:m,lineStyle:te},v&&{pointStyle:ne}),{size:[C,T],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:ie,showAxes:i.showAxes,xLabel:_,yLabel:z,xFormat:c,yFormat:u,enableHover:B,showGrid:W}),re&&{legend:re}),$&&{title:$}),l&&{className:l}),{tooltipContent:A?no(A):se}),(M||N)&&{customHoverBehavior:U}),E&&{pointIdAccessor:E}),((null==S?void 0:S.length)||G.length)&&{annotations:[...S||[],...G]}),j);return e.createElement(_o,{componentName:"LineChart",width:C,height:T},e.createElement(Ke,Object.assign({},ue)))}function Qo(t){var n;const o=To(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:i,margin:a,className:s,xFormat:l,yFormat:c,xAccessor:u="x",yAccessor:d="y",areaBy:h,y0Accessor:g,gradientFill:p=!1,lineDataAccessor:y="coordinates",colorBy:f,colorScheme:m="category10",curve:v="monotoneX",areaOpacity:b=.7,showLine:x=!0,lineWidth:w=2,tooltip:k,annotations:A,frameProps:E={},selection:S,linkedHover:O,onObservation:L,chartId:j}=t,P=o.width,M=o.height,N=o.enableHover,D=o.showGrid,C=o.showLegend,T=o.title,B=o.xLabel,W=o.yLabel,H=i||[];zo("AreaChart",H,"xAccessor",u),zo("AreaChart",H,"yAccessor",d);const{activeSelectionHook:$,customHoverBehavior:_}=No({selection:S,linkedHover:O,fallbackFields:f?["string"==typeof f?f:""]:[],onObservation:L,chartType:"AreaChart",chartId:j}),z=void 0!==(null===(n=H[0])||void 0===n?void 0:n[y]),I=r(()=>{if(z)return H;if(h){const e=H.reduce((e,t)=>{const n="function"==typeof h?h(t):t[h];if(!e[n]){const t={[y]:[]};"string"==typeof h&&(t[h]=n),e[n]=t}return e[n][y].push(t),e},{});return Object.values(e)}return[{[y]:H}]},[H,h,y,z]),R=Po(H,f,m),F=r(()=>e=>{const t={},n=f?In(e,f,R):Lo;return t.fill=n,t.fillOpacity=b,x?(t.stroke=n,t.strokeWidth=w):t.stroke="none",t},[f,R,b,x,w]),Y=r(()=>go(F,$,S),[F,$,S]),{legend:G,margin:X}=Do({data:I,colorBy:f,colorScale:R,showLegend:C,userMargin:a,defaults:o.marginDefaults}),q=h||f,V=r(()=>ao([{label:B||oo(u),accessor:u,role:"x"},{label:W||oo(d),accessor:d,role:"y"},...q?[{label:oo(q),accessor:q,role:"group"}]:[]]),[u,d,B,W,q]),U=Fo({componentName:"AreaChart",data:H,accessors:{xAccessor:u,yAccessor:d}});if(U)return e.createElement(Bo,{componentName:"AreaChart",message:U,width:P,height:M});const Z=r(()=>z||h?I.flatMap(e=>{const t=e[y]||[];return h&&"string"==typeof h?t.map(t=>Object.assign(Object.assign({},t),{[h]:e[h]})):t}):H,[I,y,z,h,H]),Q=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"area",data:Z,xAccessor:u,yAccessor:d,groupAccessor:h||void 0},g&&{y0Accessor:g}),p&&{gradientFill:p}),{curve:v,lineStyle:Y,size:[P,M],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:X,showAxes:o.showAxes,xLabel:B,yLabel:W,xFormat:l,yFormat:c,enableHover:N,showGrid:D}),G&&{legend:G}),T&&{title:T}),s&&{className:s}),{tooltipContent:k?no(k):V}),(O||L)&&{customHoverBehavior:_}),A&&A.length>0&&{annotations:A}),E);return e.createElement(_o,{componentName:"AreaChart",width:P,height:M},e.createElement(Ke,Object.assign({},Q)))}function Ko(t){var n;const o=To(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:i,margin:a,className:s,xFormat:l,yFormat:c,xAccessor:u="x",yAccessor:d="y",areaBy:h,lineDataAccessor:g="coordinates",colorBy:p,colorScheme:y="category10",curve:f="monotoneX",areaOpacity:m=.7,showLine:v=!0,lineWidth:b=2,normalize:x=!1,tooltip:w,annotations:k,frameProps:A={},selection:E,linkedHover:S,onObservation:O,chartId:L}=t,j=o.width,P=o.height,M=o.enableHover,N=o.showGrid,D=o.showLegend,C=o.title,T=o.xLabel,B=o.yLabel,W=i||[],{activeSelectionHook:H,customHoverBehavior:$}=No({selection:E,linkedHover:S,fallbackFields:p?["string"==typeof p?p:""]:[],onObservation:O,chartType:"StackedAreaChart",chartId:L}),_=void 0!==(null===(n=W[0])||void 0===n?void 0:n[g]),z=r(()=>{if(_)return W;if(h){const e=W.reduce((e,t)=>{const n="function"==typeof h?h(t):t[h];if(!e[n]){const t={[g]:[]};"string"==typeof h&&(t[h]=n),e[n]=t}return e[n][g].push(t),e},{});return Object.values(e)}return[{[g]:W}]},[W,h,g,_]),I=Po(W,p,y),R=r(()=>e=>{const t={},n=p?In(e,p,I):Lo;return t.fill=n,t.fillOpacity=m,v?(t.stroke=n,t.strokeWidth=b):t.stroke="none",t},[p,I,m,v,b]),F=r(()=>go(R,H,E),[R,H,E]),{legend:Y,margin:G}=Do({data:z,colorBy:p,colorScale:I,showLegend:D,userMargin:a,defaults:o.marginDefaults}),X=h||p,q=r(()=>ao([{label:T||oo(u),accessor:u,role:"x"},{label:B||oo(d),accessor:d,role:"y"},...X?[{label:oo(X),accessor:X,role:"group"}]:[]]),[u,d,T,B,X]),V=Fo({componentName:"StackedAreaChart",data:W,accessors:{xAccessor:u,yAccessor:d}});if(V)return e.createElement(Bo,{componentName:"StackedAreaChart",message:V,width:j,height:P});const U=r(()=>_||h?z.flatMap(e=>{const t=e[g]||[];return h&&"string"==typeof h?t.map(t=>Object.assign(Object.assign({},t),{[h]:e[h]})):t}):W,[z,g,_,h,W]),Z=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"stackedarea",data:U,xAccessor:u,yAccessor:d,groupAccessor:h||void 0,curve:f,normalize:x,lineStyle:F,size:[j,P],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:G,showAxes:o.showAxes,xLabel:T,yLabel:B,xFormat:l,yFormat:c,enableHover:M,showGrid:N},Y&&{legend:Y}),C&&{title:C}),s&&{className:s}),{tooltipContent:w?no(w):q}),(S||O)&&{customHoverBehavior:$}),k&&k.length>0&&{annotations:k}),A);return e.createElement(_o,{componentName:"StackedAreaChart",width:j,height:P},e.createElement(Ke,Object.assign({},Z)))}function Jo(t){const n=To(t.mode,{width:t.width,height:t.height,showGrid:void 0,enableHover:t.enableHover,showLegend:void 0,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:o,margin:i,className:a,xAccessor:s="x",yAccessor:l="y",valueAccessor:c="value",xFormat:u,yFormat:d,colorScheme:h="blues",customColorScale:g,showValues:p=!1,valueFormat:y,cellBorderColor:f="#fff",cellBorderWidth:m=1,tooltip:v,annotations:x,frameProps:w={},selection:k,linkedHover:A,onObservation:E,chartId:S}=t,O=n.width,L=n.height,j=n.enableHover,P=n.title,M=n.xLabel,N=n.yLabel,D=o||[],{margin:C}=Do({data:D,colorBy:void 0,colorScale:void 0,showLegend:!1,userMargin:i,defaults:n.marginDefaults}),{activeSelectionHook:T,customHoverBehavior:B}=No({selection:k,linkedHover:A,fallbackFields:[],onObservation:E,chartType:"Heatmap",chartId:S}),W=r(()=>"function"==typeof c?e=>c(e):e=>e[c],[c]),H=r(()=>{const e=D.map(W);return[Math.min(...e),Math.max(...e)]},[D,W]),$=r(()=>"custom"===h&&g?g:b({blues:Y,reds:F,greens:R,viridis:_}[h]||Y).domain(H),[h,g,H]);r(()=>{const e=jo(s),t=jo(l);return{xBinCount:new Set(D.map(e)).size,yBinCount:new Set(D.map(t)).size}},[D,s,l]),r(()=>({coordinates:D}),[D]);const z=r(()=>e=>{const t=W(e);return{fill:$(t),stroke:f,strokeWidth:m}},[W,$,f,m]);r(()=>go(z,T,k),[z,T,k]),r(()=>{if(!p)return;const t=(H[0]+H[1])/2;return(n,o)=>{const r=W(n),i=y?y(r):r+"";return e.createElement("text",{textAnchor:"middle",dominantBaseline:"middle",fill:W(n)>t?"#fff":"#000",fontSize:"12px"},i)}},[p,W,y,H]);const I=r(()=>ao([{label:M||oo(s),accessor:s,role:"x"},{label:N||oo(l),accessor:l,role:"y"},{label:oo(c),accessor:c,role:"value"}]),[s,l,M,N,c]),G=Fo({componentName:"Heatmap",data:D,accessors:{xAccessor:s,yAccessor:l,valueAccessor:c}});if(G)return e.createElement(Bo,{componentName:"Heatmap",message:G,width:O,height:L});const X=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"heatmap",data:D,xAccessor:s,yAccessor:l,valueAccessor:c,size:[O,L],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:C,showAxes:n.showAxes,xLabel:M,yLabel:N,xFormat:u,yFormat:d,enableHover:j},P&&{title:P}),a&&{className:a}),{tooltipContent:v?no(v):I}),(A||E)&&{customHoverBehavior:B}),x&&x.length>0&&{annotations:x}),w);return e.createElement(_o,{componentName:"Heatmap",width:O,height:L},e.createElement(Ke,Object.assign({},X)))}function er(t){const n=To(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:o,margin:i,className:a,xFormat:s,yFormat:l,xAccessor:c="x",yAccessor:u="y",sizeBy:d,sizeRange:h=[5,40],colorBy:g,colorScheme:p="category10",bubbleOpacity:y=.6,bubbleStrokeWidth:f=1,bubbleStrokeColor:m="white",tooltip:v,marginalGraphics:b,pointIdAccessor:x,annotations:w,frameProps:k={},selection:A,linkedHover:E,linkedBrush:S,onObservation:O,chartId:L}=t,j=n.width,P=n.height,M=n.enableHover,N=n.showGrid,D=n.showLegend,C=n.title,T=n.xLabel,B=n.yLabel,W=o||[],{activeSelectionHook:H,customHoverBehavior:$}=No({selection:A,linkedHover:E,fallbackFields:g?["string"==typeof g?g:""]:[],onObservation:O,chartType:"BubbleChart",chartId:L}),_=ho(S);Ao({name:(null==_?void 0:_.name)||"__unused_brush__",xField:(null==_?void 0:_.xField)||("string"==typeof c?c:void 0),yField:(null==_?void 0:_.yField)||("string"==typeof u?u:void 0)});const z=Po(W,g,p),I=r(()=>{const e=W.map(e=>"function"==typeof d?d(e):e[d]);return[Math.min(...e),Math.max(...e)]},[W,d]),R=r(()=>e=>{const t={fillOpacity:y,strokeWidth:f,stroke:m};return t.fill=g?In(e,g,z):Lo,t.r=Fn(e,d,h,I),t},[g,z,d,h,I,y,f,m]),F=r(()=>go(R,H,A),[R,H,A]),{legend:Y,margin:G}=Do({data:W,colorBy:g,colorScale:z,showLegend:D,userMargin:i,defaults:n.marginDefaults}),X=r(()=>ao([{label:T||oo(c),accessor:c,role:"x"},{label:B||oo(u),accessor:u,role:"y"},{label:oo(d),accessor:d,role:"size"},...g?[{label:oo(g),accessor:g,role:"color"}]:[]]),[c,u,T,B,d,g]),q=Fo({componentName:"BubbleChart",data:W,accessors:{xAccessor:c,yAccessor:u},requiredProps:{sizeBy:d}});if(q)return e.createElement(Bo,{componentName:"BubbleChart",message:q,width:j,height:P});const V=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bubble",data:W,xAccessor:c,yAccessor:u,colorAccessor:g||void 0,sizeAccessor:d,sizeRange:h,pointStyle:F,colorScheme:p,size:[j,P],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:G,showAxes:n.showAxes,xLabel:T,yLabel:B,xFormat:s,yFormat:l,enableHover:M,showGrid:N},Y&&{legend:Y}),C&&{title:C}),a&&{className:a}),{tooltipContent:v?no(v):X}),(E||O)&&{customHoverBehavior:$}),b&&{marginalGraphics:b}),x&&{pointIdAccessor:x}),w&&w.length>0&&{annotations:w}),k);return e.createElement(_o,{componentName:"BubbleChart",width:j,height:P},e.createElement(Ke,Object.assign({},V)))}function tr(e={}){const{limit:t=50,types:n,chartId:o}=e,i=Oo(e=>e.version),a=Oo(e=>e.observations),s=Oo(e=>e.clearObservations),l=r(()=>{let e=a;if(n&&n.length>0){const t=new Set(n);e=e.filter(e=>t.has(e.type))}return o&&(e=e.filter(e=>e.chartId===o)),e.length>t&&(e=e.slice(e.length-t)),e},[a,n,o,t,i]);return{observations:l,latest:l.length>0?l[l.length-1]:null,clear:s}}function nr({selections:e}){const t=xo(e=>e.setResolution);return o(()=>{for(const[n,o]of Object.entries(e))o.resolution&&t(n,o.resolution)},[e,t]),null}function or({children:t,selections:n}){return e.createElement(bo,null,e.createElement(So,null,n&&e.createElement(nr,{selections:n}),t))}Zo.displayName="LineChart",Qo.displayName="AreaChart",Ko.displayName="StackedAreaChart",Jo.displayName="Heatmap",er.displayName="BubbleChart";const rr="__splomIdx",ir={top:4,bottom:4,left:4,right:4};function ar({frameRef:n,cellSize:r,onBrush:i}){const a=t(null),s=r-ir.left-ir.right,l=r-ir.top-ir.bottom;return o(()=>{if(!a.current)return;const e=y(a.current).select(".brush-g"),t=p().extent([[0,0],[s,l]]).on("brush end",e=>{var t;const o=null===(t=n.current)||void 0===t?void 0:t.getScales();if(!o)return;if(!e.selection)return void i(null);const[[r,a],[s,l]]=e.selection,c=[[o.x.invert(r),o.y.invert(a)],[o.x.invert(s),o.y.invert(l)]];i(c)});return e.call(t),e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{t.on("brush end",null)}},[s,l,n,i]),e.createElement("svg",{ref:a,width:r,height:r,style:{position:"absolute",top:0,left:0}},e.createElement("g",{className:"brush-g",transform:`translate(${ir.left},${ir.top})`}))}function sr({data:n,xField:o,yField:r,cellSize:i,pointRadius:s,pointOpacity:l,colorBy:c,colorScale:u,brushSelectionName:d,hoverSelectionName:h,unselectedOpacity:g,mode:p,onPointHover:y}){const f=t(null),m=wo({name:d,clientId:`splom-${o}-${r}`}),v=Ao({name:d,xField:o,yField:r}),b=wo({name:h,clientId:"splom-hover-source"}),x=b.selectPoints,w=a(e=>{e?v.brushInteraction.during(e):v.brushInteraction.end(null)},[v.brushInteraction]),k=a(e=>{if(!e)return void(null==y||y(null));const t=e.data,n=null==t?void 0:t[rr];void 0!==n&&(x({[rr]:[n]}),null==y||y(t,e.x+ir.left,e.y+ir.top))},[x,y]),A=a(e=>{const t={opacity:l,r:s};return t.fill=c?In(e,c,u):Lo,"hover"===p?b.isActive&&b.predicate(e)?(t.opacity=1,t.r=2.5*s,t.stroke="#333",t.strokeWidth=1.5):b.isActive&&(t.opacity=.6*l):m.isActive&&!m.predicate(e)&&(t.opacity=g),t},[c,u,l,s,p,m.isActive,m.predicate,b.isActive,b.predicate,g]);return e.createElement("div",{style:{position:"relative",width:i,height:i}},e.createElement(Ke,{ref:f,chartType:"scatter",data:n,size:[i,i],xAccessor:o,yAccessor:r,pointStyle:A,margin:ir,showAxes:!1,enableHover:"hover"===p,customHoverBehavior:"hover"===p?k:void 0,tooltipContent:"hover"===p?()=>null:void 0}),"brush"===p&&e.createElement(ar,{frameRef:f,cellSize:i,xField:o,yField:r,onBrush:w}))}function lr({data:t,field:n,label:o,cellSize:i,bins:a,brushSelectionName:s,hoverSelectionName:l,mode:c}){const u=wo({name:s,clientId:"splom-diag-"+n}),d=wo({name:l,clientId:`splom-diag-${n}-hover`}),h="hover"===c?d:u,g=h.isActive,p=h.predicate,y=r(()=>{const e=t.map(e=>e[n]).filter(e=>null!=e&&!isNaN(e));if(0===e.length)return{bars:[],selectedBars:[],max:0};const o=Math.min(...e),r=(Math.max(...e)-o)/a||1,s=Array(a).fill(0),l=Array(a).fill(0);for(const e of t){const t=e[n];if(null==t||isNaN(t))continue;const i=Math.min(Math.floor((t-o)/r),a-1);s[i]++,g&&!p(e)||l[i]++}const c=Math.max(...s,1);return{bars:s.map((e,t)=>({x:t/a*i,w:i/a-1,h:e/c*(i-24),count:e})),selectedBars:l.map((e,t)=>({x:t/a*i,w:i/a-1,h:e/c*(i-24),count:e})),max:c}},[t,n,a,i,g,p]);return e.createElement("svg",{width:i,height:i,style:{overflow:"hidden"}},e.createElement("text",{x:i/2,y:14,textAnchor:"middle",fontSize:11,fontWeight:"bold",fill:"#333"},o),y.bars.map((t,n)=>e.createElement("rect",{key:"bg-"+n,x:t.x,y:i-t.h,width:Math.max(t.w,1),height:t.h,fill:"#ccc",opacity:g?.3:.6})),g&&y.selectedBars.map((t,n)=>e.createElement("rect",{key:"sel-"+n,x:t.x,y:i-t.h,width:Math.max(t.w,1),height:t.h,fill:Lo,opacity:.7})))}function cr({label:t,cellSize:n}){return e.createElement("svg",{width:n,height:n},e.createElement("text",{x:n/2,y:n/2,textAnchor:"middle",dominantBaseline:"middle",fontSize:12,fontWeight:"bold",fill:"#333"},t))}function ur(t){const{data:o,fields:i,fieldLabels:s={},colorBy:l,colorScheme:c="category10",cellSize:u=150,cellGap:d=4,pointRadius:h=2,pointOpacity:g=.5,diagonal:p="histogram",histogramBins:y=20,brushMode:f="crossfilter",hoverMode:m=!0,unselectedOpacity:v=.1,showGrid:b=!1,tooltip:x,showLegend:w,idAccessor:k,className:A,onObservation:E,chartId:S}=t,O="splom",L="splom-hover",j=m?"hover":f?"brush":"hover",P=xo(e=>e.clearSelection),[M,N]=n(null),D=a(()=>{P(L),N(null)},[P,L]),C=r(()=>(o||[]).map((e,t)=>void 0!==e[rr]?e:Object.assign(Object.assign({},e),{[rr]:t})),[o]),T=Po(C,l,c),B=void 0!==w?w:!!l,W=r(()=>{if(!B||!l)return null;const e="string"==typeof l?l:null;return e?[...new Set(C.map(t=>t[e]))].map(e=>({label:e+"",color:T?T(e+""):Lo})):null},[B,l,C,T]),H=r(()=>({display:"grid",gridTemplateColumns:"40px "+i.map(()=>u+"px").join(" "),gridTemplateRows:i.map(()=>u+"px").join(" ")+" 40px",gap:d+"px",width:"fit-content"}),[i,u,d,40]);return e.createElement("div",{className:A,style:{position:"relative"}},W&&e.createElement("div",{style:{display:"flex",gap:12,marginBottom:8,flexWrap:"wrap"}},W.map(t=>e.createElement("div",{key:t.label,style:{display:"flex",alignItems:"center",gap:4}},e.createElement("span",{style:{display:"inline-block",width:10,height:10,borderRadius:"50%",backgroundColor:t.color}}),e.createElement("span",{style:{fontSize:11}},t.label)))),e.createElement("div",{style:H,onMouseLeave:"hover"===j?D:void 0},i.map((t,n)=>e.createElement(e.Fragment,{key:"row-"+t},e.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",writingMode:"vertical-rl",transform:"rotate(180deg)",fontSize:11,fontWeight:"bold",color:"#333"}},s[t]||t),i.map((o,r)=>n===r?"label"===p?e.createElement(cr,{key:"diag-"+t,label:s[t]||t,cellSize:u}):e.createElement(lr,{key:"diag-"+t,data:C,field:t,label:s[t]||t,cellSize:u,bins:y,colorBy:l,colorScale:T,brushSelectionName:O,hoverSelectionName:L,unselectedOpacity:v,mode:j}):e.createElement(sr,{key:`cell-${t}-${o}`,data:C,xField:o,yField:t,fieldLabels:s,cellSize:u,pointRadius:h,pointOpacity:g,colorBy:l,colorScale:T,brushSelectionName:O,hoverSelectionName:L,unselectedOpacity:v,showGrid:b,tooltip:x,mode:j,onPointHover:"hover"===j?(e,i,a)=>{e?(N({datum:e,xField:o,yField:t,colIndex:r,rowIndex:n,px:null!=i?i:0,py:null!=a?a:0}),E&&E({type:"hover",datum:e,x:null!=i?i:0,y:null!=a?a:0,timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:S})):(N(null),E&&E({type:"hover-end",timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:S}))}:void 0})))),e.createElement("div",null)," ",i.map(t=>e.createElement("div",{key:"col-label-"+t,style:{display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:"bold",color:"#333"}},s[t]||t))),M&&"hover"===j&&(()=>{const t=M.datum,n=s[M.xField]||M.xField,o=s[M.yField]||M.yField,r=l?"function"==typeof l?l(t):t[l]:null,i=k?"function"==typeof k?k(t):t[k]:"Row "+t[rr];return e.createElement("div",{style:{position:"absolute",left:40+M.colIndex*(u+d)+M.px,top:M.rowIndex*(u+d)+M.py-8,transform:"translate(-50%, -100%)",color:"#333",background:"rgba(255,255,255,0.95)",border:"1px solid #ddd",borderRadius:3,padding:"4px 8px",fontSize:11,lineHeight:1.4,whiteSpace:"nowrap",pointerEvents:"none",zIndex:10}},e.createElement("div",{style:{fontWeight:"bold",marginBottom:2}},i+""),e.createElement("div",null,n,": ",null!=t[M.xField]?Number(t[M.xField]).toFixed(1):"–"),e.createElement("div",null,o,": ",null!=t[M.yField]?Number(t[M.yField]).toFixed(1):"–"),null!=r&&e.createElement("div",{style:{opacity:.8}},"string"==typeof l?l:"group",": ",r+""))})())}function dr(t){const{brushMode:n="crossfilter",hoverMode:o=!0}=t,r={};return!o&&n&&(r.splom={resolution:n}),o&&(r["splom-hover"]={resolution:"union"}),e.createElement(or,{selections:r},e.createElement(ur,Object.assign({},t)))}function hr({width:n,height:r,margin:i,scales:a,brushDirection:s,extent:l,onBrush:c}){const u=t(null),d=t(null),p=t(!1),f=n+i.left+i.right,m=r+i.top+i.bottom;return o(()=>{if(!u.current||!a)return;const e=y(u.current).select(".brush-group"),t="x"===s?h().extent([[0,0],[n,r]]):g().extent([[0,0],[n,r]]);return t.on("brush end",e=>{if(p.current)return;if(!e.sourceEvent)return;const t=e.selection;if(!t)return void c(null);const n=("x"===s?a.x:a.y).invert;if(!n)return;const o=[n(t[0]),n(t[1])];c(o)}),e.call(t),d.current=t,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.2).attr("stroke","steelblue").attr("stroke-width",1),()=>{t.on("brush end",null)}},[a,n,r,s,c]),o(()=>{if(!d.current||!a||!u.current)return;const e=y(u.current).select(".brush-group"),t="x"===s?a.x:a.y;if(p.current=!0,l){const n=[t(l[0]),t(l[1])];e.call(d.current.move,n)}else e.call(d.current.move,null);p.current=!1},[l,a,s]),e.createElement("svg",{ref:u,width:f,height:m,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},e.createElement("g",{className:"brush-group",transform:`translate(${i.left},${i.top})`}))}function gr(i){var s,l;const{data:c,width:u=600,height:d=400,margin:h,className:g,title:p,xLabel:y,yLabel:f,xFormat:m,yFormat:v,xAccessor:b="x",yAccessor:x="y",lineBy:w,lineDataAccessor:k="coordinates",colorBy:A,colorScheme:E="category10",curve:S="linear",lineWidth:O=2,fillArea:L=!1,areaOpacity:j=.3,showPoints:P=!1,pointRadius:M=3,enableHover:N=!0,showGrid:D=!1,showLegend:C,tooltip:T,minimap:B={},renderBefore:W=!1,onBrush:H,brushExtent:$,frameProps:_={}}=i,z=c||[],[I,R]=n(null),F=null!=$?$:I,Y=a(e=>{$||R(e),null==H||H(e)},[$,H]),G=t(null),[X,q]=n(null);o(()=>{const e=()=>{var t,n;const o=null===(n=null===(t=G.current)||void 0===t?void 0:t.getScales)||void 0===n?void 0:n.call(t);o?q(o):requestAnimationFrame(e)};requestAnimationFrame(e)},[c]);const V=void 0!==(null===(s=z[0])||void 0===s?void 0:s[k]),U=r(()=>{if(V)return z;if(w){const e=z.reduce((e,t)=>{const n="function"==typeof w?w(t):t[w];if(!e[n]){const t={[k]:[]};"string"==typeof w&&(t[w]=n),e[n]=t}return e[n][k].push(t),e},{});return Object.values(e)}return[{[k]:z}]},[z,w,k,V]),Z=r(()=>V||w?U.flatMap(e=>{const t=e[k]||[];return w&&"string"==typeof w?t.map(t=>Object.assign(Object.assign({},t),{[w]:e[w]})):t}):z,[U,k,V,w,z]),Q=Po(z,A,E),K=r(()=>e=>{const t={strokeWidth:O};return t.stroke=A?In(e,A,Q):Lo,L&&(t.fill=t.stroke,t.fillOpacity=j),t},[A,Q,O,L,j]),J=r(()=>B.lineStyle?B.lineStyle:e=>{const t={strokeWidth:1};return t.stroke=A?In(e,A,Q):Lo,t},[A,Q,B.lineStyle]),ee=r(()=>{if(P)return e=>{const t={r:M,fillOpacity:1};return t.fill=A?In(e.parentLine||e,A,Q):Lo,t}},[P,M,A,Q]),{legend:te,margin:ne}=Do({data:U,colorBy:A,colorScale:Q,showLegend:C,userMargin:h}),oe=B.height||60,re=r(()=>{var e,t,n,o,r,i,a,s;return{top:null!==(t=null===(e=B.margin)||void 0===e?void 0:e.top)&&void 0!==t?t:0,bottom:null!==(o=null===(n=B.margin)||void 0===n?void 0:n.bottom)&&void 0!==o?o:20,left:null!==(i=null===(r=B.margin)||void 0===r?void 0:r.left)&&void 0!==i?i:ne.left,right:null!==(s=null===(a=B.margin)||void 0===a?void 0:a.right)&&void 0!==s?s:ne.right}},[B.margin,ne]),ie=B.brushDirection||"x",ae=Fo({componentName:"MinimapChart",data:z,accessors:{xAccessor:b,yAccessor:x}});if(ae)return e.createElement(Bo,{componentName:"MinimapChart",message:ae,width:u,height:d});const se=L?"area":"line",le=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:se,data:Z,xAccessor:b,yAccessor:x,groupAccessor:w||void 0,curve:S,lineStyle:K},P&&{pointStyle:ee}),{size:[u,d],responsiveWidth:i.responsiveWidth,responsiveHeight:i.responsiveHeight,margin:ne,showAxes:!0,xLabel:y,yLabel:f,xFormat:m,yFormat:v,enableHover:N,showGrid:D}),te&&{legend:te}),p&&{title:p}),T&&{tooltipContent:no(T)}),F&&{xExtent:F}),_),ce={chartType:se,data:Z,xAccessor:b,yAccessor:x,groupAccessor:w||void 0,curve:S,lineStyle:J,size:[u,oe+re.top+re.bottom],margin:re,showAxes:null!==(l=B.showAxes)&&void 0!==l&&l,background:B.background,enableHover:!1},ue=e.createElement("div",{key:"minimap",style:{position:"relative",width:u,overflow:"hidden"}},e.createElement(Ke,Object.assign({ref:G},ce)),e.createElement(hr,{width:u-re.left-re.right,height:oe,margin:re,scales:X,brushDirection:ie,extent:F,onBrush:Y})),de=e.createElement("div",{key:"main",style:{overflow:"hidden"}},e.createElement(Ke,Object.assign({},le)));return e.createElement("div",{className:"minimap-chart"+(g?" "+g:"")},W?ue:de,W?de:ue)}function pr(t){const n=To(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:i,className:a,categoryAccessor:s="category",valueAccessor:l="value",orientation:c="vertical",valueFormat:u,colorBy:d,colorScheme:h="category10",sort:g=!1,barPadding:p=5,tooltip:y,annotations:f,frameProps:m={},selection:v,linkedHover:b,onObservation:x,chartId:w}=t,k=n.width,A=n.height,E=n.enableHover,S=n.showGrid,O=n.showLegend,L=n.title,j=n.categoryLabel,P=n.valueLabel,M=o||[];zo("BarChart",M,"categoryAccessor",s),zo("BarChart",M,"valueAccessor",l);const{activeSelectionHook:N,customHoverBehavior:D}=No({selection:v,linkedHover:b,fallbackFields:d?["string"==typeof d?d:""]:[],unwrapData:!0,onObservation:x,chartType:"BarChart",chartId:w}),C=Mo(M,g,l),T=Po(M,d,h),B=r(()=>e=>{const t={};return t.fill=d?In(e,d,T):Lo,t},[d,T]),W=r(()=>go(B,N,v),[B,N,v]),{legend:H,margin:$}=Do({data:C,colorBy:d,colorScale:T,showLegend:O,userMargin:i,defaults:n.marginDefaults}),_=r(()=>so({categoryAccessor:s,valueAccessor:l,groupAccessor:d&&d!==s?d:void 0,groupLabel:"string"==typeof d?d:"group"}),[s,l,d]),z=Fo({componentName:"BarChart",data:M,accessors:{categoryAccessor:s,valueAccessor:l}});if(z)return e.createElement(Bo,{componentName:"BarChart",message:z,width:k,height:A});const I=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bar",data:C,oAccessor:s,rAccessor:l,projection:"horizontal"===c?"horizontal":"vertical",pieceStyle:W,size:[k,A],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:$,barPadding:p,enableHover:E,showAxes:n.showAxes,oLabel:j,rLabel:P,rFormat:u,showGrid:S,oSort:g},H&&{legend:H}),L&&{title:L}),a&&{className:a}),{tooltipContent:y?no(y):_}),(b||x)&&{customHoverBehavior:D}),f&&f.length>0&&{annotations:f}),m);return e.createElement(_o,{componentName:"BarChart",width:k,height:A},e.createElement(vt,Object.assign({},I)))}function yr(t){const n=To(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:i,className:a,categoryAccessor:s="category",stackBy:l,valueAccessor:c="value",orientation:u="vertical",valueFormat:d,colorBy:h,colorScheme:g="category10",normalize:p=!1,barPadding:y=5,tooltip:f,annotations:m,frameProps:v={},selection:b,linkedHover:x,onObservation:w,chartId:k}=t,A=n.width,E=n.height,S=n.enableHover,O=n.showGrid,L=n.showLegend,j=n.title,P=n.categoryLabel,M=n.valueLabel,N=o||[],D=h||l,{activeSelectionHook:C,customHoverBehavior:T}=No({selection:b,linkedHover:x,fallbackFields:D?["string"==typeof D?D:""]:[],unwrapData:!0,onObservation:w,chartType:"StackedBarChart",chartId:k}),B=Po(N,D,g),W=r(()=>e=>D?{fill:In(e,D,B)}:{fill:Lo},[D,B]),H=r(()=>go(W,C,b),[W,C,b]),{legend:$,margin:_}=Do({data:N,colorBy:D,colorScale:B,showLegend:L,userMargin:i,defaults:n.marginDefaults}),z=r(()=>so({categoryAccessor:l,valueAccessor:c,groupAccessor:s}),[l,s,c]),I=Fo({componentName:"StackedBarChart",data:N,accessors:{categoryAccessor:s,valueAccessor:c},requiredProps:{stackBy:l}});if(I)return e.createElement(Bo,{componentName:"StackedBarChart",message:I,width:A,height:E});const R=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bar",data:N,oAccessor:s,rAccessor:c,stackBy:l,normalize:p,projection:"horizontal"===u?"horizontal":"vertical",pieceStyle:H,size:[A,E],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:_,barPadding:y,enableHover:S,showAxes:n.showAxes,oLabel:P,rLabel:M,rFormat:d,showGrid:O},$&&{legend:$}),j&&{title:j}),a&&{className:a}),{tooltipContent:f?no(f):z}),(x||w)&&{customHoverBehavior:T}),m&&m.length>0&&{annotations:m}),v);return e.createElement(_o,{componentName:"StackedBarChart",width:A,height:E},e.createElement(vt,Object.assign({},R)))}function fr(t){const n=To(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:i,className:a,categoryAccessor:s="category",valueAccessor:l="value",orientation:c="vertical",valueFormat:u,colorBy:d,colorScheme:h="category10",sizeBy:g,sizeRange:p=[3,8],pointRadius:y=4,pointOpacity:f=.7,categoryPadding:m=20,tooltip:v,annotations:b,frameProps:x={},selection:w,linkedHover:k,onObservation:A,chartId:E}=t,S=n.width,O=n.height,L=n.enableHover,j=n.showGrid,P=n.showLegend,M=n.title,N=n.categoryLabel,D=n.valueLabel,C=o||[],{activeSelectionHook:T,customHoverBehavior:B}=No({selection:w,linkedHover:k,fallbackFields:d?["string"==typeof d?d:""]:["string"==typeof s?s:""],unwrapData:!0,onObservation:A,chartType:"SwarmPlot",chartId:E}),W=Po(C,d,h),H=r(()=>{if(!g)return;const e=C.map(e=>"function"==typeof g?g(e):e[g]);return[Math.min(...e),Math.max(...e)]},[C,g]),$=r(()=>e=>{const t={fillOpacity:f};return t.fill=d?In(e,d,W):Lo,t.r=g?Fn(e,g,p,H):y,t},[d,W,g,p,H,y,f]),_=r(()=>go($,T,w),[$,T,w]),{legend:z,margin:I}=Do({data:C,colorBy:d,colorScale:W,showLegend:P,userMargin:i,defaults:n.marginDefaults}),R=r(()=>so({categoryAccessor:s,valueAccessor:l,groupAccessor:d||void 0}),[s,l,d]),F=Fo({componentName:"SwarmPlot",data:C,accessors:{categoryAccessor:s,valueAccessor:l}});if(F)return e.createElement(Bo,{componentName:"SwarmPlot",message:F,width:S,height:O});const Y=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"swarm",data:C,oAccessor:s,rAccessor:l,projection:"horizontal"===c?"horizontal":"vertical",pieceStyle:_,size:[S,O],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:I,barPadding:m,enableHover:L,showAxes:n.showAxes,oLabel:N,rLabel:D,rFormat:u,showGrid:j},z&&{legend:z}),M&&{title:M}),a&&{className:a}),{tooltipContent:v?no(v):R}),(k||A)&&{customHoverBehavior:B}),b&&b.length>0&&{annotations:b}),x);return e.createElement(_o,{componentName:"SwarmPlot",width:S,height:O},e.createElement(vt,Object.assign({},Y)))}function mr(t){const n=To(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:i,className:a,categoryAccessor:s="category",valueAccessor:l="value",orientation:c="vertical",valueFormat:u,colorBy:d,colorScheme:h="category10",showOutliers:g=!0,categoryPadding:p=20,tooltip:y,annotations:f,frameProps:m={},selection:v,linkedHover:b,onObservation:x,chartId:w}=t,k=n.width,A=n.height,E=n.enableHover,S=n.showGrid,O=n.showLegend,L=n.title,j=n.categoryLabel,P=n.valueLabel,M=o||[],{activeSelectionHook:N,customHoverBehavior:D}=No({selection:v,linkedHover:b,fallbackFields:d?["string"==typeof d?d:""]:["string"==typeof s?s:""],unwrapData:!0,onObservation:x,chartType:"BoxPlot",chartId:w}),C=Po(M,d,h),T=r(()=>e=>{const t=d?In(e,d,C):Lo;return{fill:t,stroke:t,fillOpacity:.8}},[d,C]),B=r(()=>go(T,N,v),[T,N,v]),{legend:W,margin:H}=Do({data:M,colorBy:d,colorScale:C,showLegend:O,userMargin:i,defaults:n.marginDefaults}),$=r(()=>t=>{const n=t.stats||(t.data||t).stats||{};return e.createElement("div",{className:"semiotic-tooltip",style:Qn},e.createElement("div",{style:{fontWeight:"bold",marginBottom:"4px"}},(t.category||(t.data||t).category||"")+""),null!=n.median&&e.createElement(e.Fragment,null,null!=n.n&&e.createElement("div",null,"n = ",n.n),e.createElement("div",null,"Median: ",n.median.toLocaleString()),e.createElement("div",null,"Q1: ",n.q1.toLocaleString()),e.createElement("div",null,"Q3: ",n.q3.toLocaleString()),e.createElement("div",null,"Min: ",n.min.toLocaleString()),e.createElement("div",null,"Max: ",n.max.toLocaleString())))},[]),_=Fo({componentName:"BoxPlot",data:M,accessors:{categoryAccessor:s,valueAccessor:l}});if(_)return e.createElement(Bo,{componentName:"BoxPlot",message:_,width:k,height:A});const z=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"boxplot",data:M,oAccessor:s,rAccessor:l,projection:"horizontal"===c?"horizontal":"vertical",summaryStyle:B,showOutliers:g,size:[k,A],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:H,barPadding:p,enableHover:E,showAxes:n.showAxes,oLabel:j,rLabel:P,rFormat:u,showGrid:S},W&&{legend:W}),L&&{title:L}),a&&{className:a}),{tooltipContent:y?no(y):$}),(b||x)&&{customHoverBehavior:D}),f&&f.length>0&&{annotations:f}),m);return e.createElement(_o,{componentName:"BoxPlot",width:k,height:A},e.createElement(vt,Object.assign({},z)))}function vr(t){const n=To(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:i,className:a,categoryAccessor:s="category",valueAccessor:l="value",bins:c=25,relative:u=!1,valueFormat:d,colorBy:h,colorScheme:g="category10",categoryPadding:p=20,tooltip:y,annotations:f,frameProps:m={},selection:v,linkedHover:b,onObservation:x,chartId:w}=t,k=n.width,A=n.height,E=n.enableHover,S=n.showGrid,O=n.showLegend,L=n.title,j=n.categoryLabel,P=n.valueLabel,M=o||[],{activeSelectionHook:N,customHoverBehavior:D}=No({selection:v,linkedHover:b,fallbackFields:h?["string"==typeof h?h:""]:["string"==typeof s?s:""],unwrapData:!0,onObservation:x,chartType:"Histogram",chartId:w}),C=Po(M,h,g),T=r(()=>e=>{const t=h?In(e,h,C):Lo;return{fill:t,stroke:t,fillOpacity:.8}},[h,C]),B=r(()=>go(T,N,v),[T,N,v]),{legend:W,margin:H}=Do({data:M,colorBy:h,colorScale:C,showLegend:O,userMargin:i,defaults:n.marginDefaults}),$=r(()=>t=>{const n=t.data||t,o=n.category||t.category||"",r=n.count,i=n.range;return e.createElement("div",{className:"semiotic-tooltip",style:Qn},o&&e.createElement("div",{style:{fontWeight:"bold"}},o+""),null!=r&&e.createElement("div",null,"Count: ",r),i&&2===i.length&&e.createElement("div",{style:{opacity:.8}},Number(i[0]).toFixed(1)," – ",Number(i[1]).toFixed(1)))},[]),_=Fo({componentName:"Histogram",data:M,accessors:{categoryAccessor:s,valueAccessor:l}});if(_)return e.createElement(Bo,{componentName:"Histogram",message:_,width:k,height:A});const z=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"histogram",data:M,oAccessor:s,rAccessor:l,projection:"horizontal",summaryStyle:B,bins:c,normalize:u,size:[k,A],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:H,barPadding:p,enableHover:E,showAxes:n.showAxes,oLabel:j,rLabel:P,rFormat:d,showGrid:S},W&&{legend:W}),L&&{title:L}),a&&{className:a}),{tooltipContent:y?no(y):$}),(b||x)&&{customHoverBehavior:D}),f&&f.length>0&&{annotations:f}),m);return e.createElement(_o,{componentName:"Histogram",width:k,height:A},e.createElement(vt,Object.assign({},z)))}function br(t){const n=To(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:i,className:a,categoryAccessor:s="category",valueAccessor:l="value",orientation:c="vertical",bins:u=25,showIQR:d=!0,valueFormat:h,colorBy:g,colorScheme:p="category10",categoryPadding:y=20,tooltip:f,annotations:m,frameProps:v={},selection:b,linkedHover:x,onObservation:w,chartId:k}=t,A=n.width,E=n.height,S=n.enableHover,O=n.showGrid,L=n.showLegend,j=n.title,P=n.categoryLabel,M=n.valueLabel,N=o||[],{activeSelectionHook:D,customHoverBehavior:C}=No({selection:b,linkedHover:x,fallbackFields:g?["string"==typeof g?g:""]:["string"==typeof s?s:""],unwrapData:!0,onObservation:w,chartType:"ViolinPlot",chartId:k}),T=Po(N,g,p),B=r(()=>e=>{const t=g?In(e,g,T):Lo;return{fill:t,stroke:t,fillOpacity:.6}},[g,T]),W=r(()=>go(B,D,b),[B,D,b]),{legend:H,margin:$}=Do({data:N,colorBy:g,colorScale:T,showLegend:L,userMargin:i,defaults:n.marginDefaults}),_=r(()=>t=>{var n;const o=t.category||t.data&&(null===(n=t.data[0])||void 0===n?void 0:n.category)||"",r=t.stats;if(r)return e.createElement("div",{className:"semiotic-tooltip",style:Qn},o&&e.createElement("div",{style:{fontWeight:"bold"}},o+""),e.createElement("div",null,"n = ",r.n),e.createElement("div",null,"Min: ",r.min.toLocaleString()),e.createElement("div",null,"Q1: ",r.q1.toLocaleString()),e.createElement("div",null,"Median: ",r.median.toLocaleString()),e.createElement("div",null,"Q3: ",r.q3.toLocaleString()),e.createElement("div",null,"Max: ",r.max.toLocaleString()),e.createElement("div",{style:{opacity:.8}},"Mean: ",r.mean.toLocaleString(void 0,{maximumFractionDigits:2})));const i=(Array.isArray(t.data)?t.data:[]).map(e=>{const t="function"==typeof l?l(e):e[l];return Number(t)}).filter(e=>!isNaN(e)).sort((e,t)=>e-t),a=i.length,s=a>0?i[Math.floor(a/2)]:null;return e.createElement("div",{className:"semiotic-tooltip",style:Qn},o&&e.createElement("div",{style:{fontWeight:"bold"}},o+""),a>0&&e.createElement("div",null,"n = ",a),null!=s&&e.createElement("div",null,"Median: ",s.toLocaleString()))},[l]),z=Fo({componentName:"ViolinPlot",data:N,accessors:{categoryAccessor:s,valueAccessor:l}});if(z)return e.createElement(Bo,{componentName:"ViolinPlot",message:z,width:A,height:E});const I=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"violin",data:N,oAccessor:s,rAccessor:l,projection:"horizontal"===c?"horizontal":"vertical",summaryStyle:W,bins:u,showIQR:d,size:[A,E],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:$,barPadding:y,enableHover:S,showAxes:n.showAxes,oLabel:P,rLabel:M,rFormat:h,showGrid:O},H&&{legend:H}),j&&{title:j}),a&&{className:a}),{tooltipContent:f?no(f):_}),(x||w)&&{customHoverBehavior:C}),m&&m.length>0&&{annotations:m}),v);return e.createElement(_o,{componentName:"ViolinPlot",width:A,height:E},e.createElement(vt,Object.assign({},I)))}function xr(t){const n=To(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:i,className:a,categoryAccessor:s="category",valueAccessor:l="value",orientation:c="horizontal",bins:u=20,amplitude:d=1.5,valueFormat:h,colorBy:g,colorScheme:p="category10",categoryPadding:y=5,tooltip:f,annotations:m,frameProps:v={},selection:b,linkedHover:x,onObservation:w,chartId:k}=t,A=n.width,E=n.height,S=n.enableHover,O=n.showGrid,L=n.showLegend,j=n.title,P=n.categoryLabel,M=n.valueLabel,N=o||[],{activeSelectionHook:D,customHoverBehavior:C}=No({selection:b,linkedHover:x,fallbackFields:g?["string"==typeof g?g:""]:["string"==typeof s?s:""],unwrapData:!0,onObservation:w,chartType:"RidgelinePlot",chartId:k}),T=Po(N,g,p),B=r(()=>e=>{const t=g?In(e,g,T):Lo;return{fill:t,stroke:t,fillOpacity:.5}},[g,T]),W=r(()=>go(B,D,b),[B,D,b]),{legend:H,margin:$}=Do({data:N,colorBy:g,colorScale:T,showLegend:L,userMargin:i,defaults:n.marginDefaults}),_=r(()=>t=>{var n;const o=t.category||t.data&&(null===(n=t.data[0])||void 0===n?void 0:n.category)||"",r=t.stats;return r?e.createElement("div",{className:"semiotic-tooltip",style:Qn},o&&e.createElement("div",{style:{fontWeight:"bold"}},o+""),e.createElement("div",null,"n = ",r.n),e.createElement("div",null,"Min: ",r.min.toLocaleString()),e.createElement("div",null,"Q1: ",r.q1.toLocaleString()),e.createElement("div",null,"Median: ",r.median.toLocaleString()),e.createElement("div",null,"Q3: ",r.q3.toLocaleString()),e.createElement("div",null,"Max: ",r.max.toLocaleString()),e.createElement("div",{style:{opacity:.8}},"Mean: ",r.mean.toLocaleString(void 0,{maximumFractionDigits:2}))):e.createElement("div",{className:"semiotic-tooltip",style:Qn},e.createElement("div",{style:{fontWeight:"bold"}},o+""))},[]),z=Fo({componentName:"RidgelinePlot",data:N,accessors:{categoryAccessor:s,valueAccessor:l}});if(z)return e.createElement(Bo,{componentName:"RidgelinePlot",message:z,width:A,height:E});const I=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"ridgeline",data:N,oAccessor:s,rAccessor:l,projection:"horizontal"===c?"horizontal":"vertical",summaryStyle:W,bins:u,size:[A,E],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:$,barPadding:y,enableHover:S,showAxes:n.showAxes,oLabel:P,rLabel:M,rFormat:h,showGrid:O,oSort:!1},H&&{legend:H}),j&&{title:j}),a&&{className:a}),{tooltipContent:f?no(f):_}),(x||w)&&{customHoverBehavior:C}),m&&m.length>0&&{annotations:m}),v);return I.amplitude=d,e.createElement(_o,{componentName:"RidgelinePlot",width:A,height:E},e.createElement(vt,Object.assign({},I)))}function wr(t){var n;const o=To(t.mode,{width:t.width,height:t.height,showGrid:null===(n=t.showGrid)||void 0===n||n,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:i,margin:a,className:s,categoryAccessor:l="category",valueAccessor:c="value",orientation:u="horizontal",valueFormat:d,colorBy:h,colorScheme:g="category10",sort:p=!0,dotRadius:y=5,categoryPadding:f=10,tooltip:m,annotations:v,frameProps:b={},selection:x,linkedHover:w,onObservation:k,chartId:A}=t,E=o.width,S=o.height,O=o.enableHover,L=o.showGrid,j=o.showLegend,P=o.title,M=o.categoryLabel,N=o.valueLabel,D=i||[],{activeSelectionHook:C,customHoverBehavior:T}=No({selection:x,linkedHover:w,fallbackFields:h?["string"==typeof h?h:""]:["string"==typeof l?l:""],unwrapData:!0,onObservation:k,chartType:"DotPlot",chartId:A}),B=Mo(D,p,c),W=Po(D,h,g),H=r(()=>e=>{const t={r:y,fillOpacity:.8};return t.fill=h?In(e,h,W):Lo,t},[h,W,y]),$=r(()=>go(H,C,x),[H,C,x]),{legend:_,margin:z}=Do({data:B,colorBy:h,colorScale:W,showLegend:j,userMargin:a,defaults:o.marginDefaults}),I=r(()=>so({categoryAccessor:l,valueAccessor:c}),[l,c]),R=Fo({componentName:"DotPlot",data:D,accessors:{categoryAccessor:l,valueAccessor:c}});if(R)return e.createElement(Bo,{componentName:"DotPlot",message:R,width:E,height:S});const F=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"point",data:B,oAccessor:l,rAccessor:c,projection:"horizontal"===u?"horizontal":"vertical",pieceStyle:$,size:[E,S],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:z,barPadding:f,enableHover:O,showAxes:o.showAxes,oLabel:M,rLabel:N,rFormat:d,showGrid:L,oSort:p},_&&{legend:_}),P&&{title:P}),s&&{className:s}),{tooltipContent:m?no(m):I}),(w||k)&&{customHoverBehavior:T}),v&&v.length>0&&{annotations:v}),b);return e.createElement(_o,{componentName:"DotPlot",width:E,height:S},e.createElement(vt,Object.assign({},F)))}function kr(t){var n,o;const i=To(t.mode,{width:null!==(n=t.width)&&void 0!==n?n:400,height:null!==(o=t.height)&&void 0!==o?o:400,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title}),{data:a,margin:s,className:l,categoryAccessor:c="category",valueAccessor:u="value",colorBy:d,colorScheme:h="category10",startAngle:g=0,tooltip:p,annotations:y,frameProps:f={},selection:m,linkedHover:v,onObservation:b,chartId:x}=t,w=i.width,k=i.height,A=i.enableHover,E=i.showLegend,S=i.title,O=a||[],L=d||c,{activeSelectionHook:j,customHoverBehavior:P}=No({selection:m,linkedHover:v,fallbackFields:L?["string"==typeof L?L:""]:[],unwrapData:!0,onObservation:b,chartType:"PieChart",chartId:x}),M=Po(O,L,h),N=r(()=>e=>L?{fill:In(e,L,M)}:{fill:Lo},[L,M]),D=r(()=>go(N,j,m),[N,j,m]),{legend:C,margin:T}=Do({data:O,colorBy:L,colorScale:M,showLegend:E,userMargin:s,defaults:i.marginDefaults}),B=r(()=>so({categoryAccessor:c,valueAccessor:u,groupAccessor:d&&d!==c?d:void 0,groupLabel:"string"==typeof d?d:"group",pieData:!0}),[c,u,d]),W=Fo({componentName:"PieChart",data:O,accessors:{categoryAccessor:c,valueAccessor:u}});if(W)return e.createElement(Bo,{componentName:"PieChart",message:W,width:w,height:k});const H=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"pie",data:O,oAccessor:c,rAccessor:u,projection:"radial",pieceStyle:D,startAngle:g,size:[w,k],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:T,enableHover:A,showAxes:!1},C&&{legend:C}),S&&{title:S}),l&&{className:l}),{tooltipContent:p?no(p):B}),(v||b)&&{customHoverBehavior:P}),y&&y.length>0&&{annotations:y}),f);return e.createElement(_o,{componentName:"PieChart",width:w,height:k},e.createElement(vt,Object.assign({},H)))}function Ar(t){var n,o;const i=To(t.mode,{width:null!==(n=t.width)&&void 0!==n?n:400,height:null!==(o=t.height)&&void 0!==o?o:400,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,linkedHover:t.linkedHover}),{data:a,margin:s,className:l,categoryAccessor:c="category",valueAccessor:u="value",innerRadius:d=60,centerContent:h,colorBy:g,colorScheme:p="category10",startAngle:y=0,tooltip:f,annotations:m,frameProps:v={},selection:b,linkedHover:x,onObservation:w,chartId:k}=t,A=i.width,E=i.height,S=i.enableHover,O=i.showLegend,L=i.title,j=a||[],P=g||c,{activeSelectionHook:M,customHoverBehavior:N}=No({selection:b,linkedHover:x,fallbackFields:P?["string"==typeof P?P:""]:[],unwrapData:!0,onObservation:w,chartType:"DonutChart",chartId:k}),D=Po(j,P,p),C=r(()=>e=>P?{fill:In(e,P,D)}:{fill:Lo},[P,D]),T=r(()=>go(C,M,b),[C,M,b]),{legend:B,margin:W}=Do({data:j,colorBy:P,colorScale:D,showLegend:O,userMargin:s,defaults:i.marginDefaults}),H=r(()=>so({categoryAccessor:c,valueAccessor:u,groupAccessor:g&&g!==c?g:void 0,groupLabel:"string"==typeof g?g:"group",pieData:!0}),[c,u,g]),$=Fo({componentName:"DonutChart",data:j,accessors:{categoryAccessor:c,valueAccessor:u}});if($)return e.createElement(Bo,{componentName:"DonutChart",message:$,width:A,height:E});const _=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"donut",data:j,oAccessor:c,rAccessor:u,projection:"radial",pieceStyle:T,innerRadius:d,startAngle:y,centerContent:h,size:[A,E],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:W,enableHover:S,showAxes:!1},B&&{legend:B}),L&&{title:L}),l&&{className:l}),{tooltipContent:f?no(f):H}),(x||w)&&{customHoverBehavior:N}),m&&m.length>0&&{annotations:m}),v);return e.createElement(_o,{componentName:"DonutChart",width:A,height:E},e.createElement(vt,Object.assign({},_)))}function Er(t){const n=To(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:i,className:a,categoryAccessor:s="category",groupBy:l,valueAccessor:c="value",orientation:u="vertical",valueFormat:d,colorBy:h,colorScheme:g="category10",barPadding:p=5,tooltip:y,annotations:f,frameProps:m={},selection:v,linkedHover:b,onObservation:x,chartId:w}=t,k=n.width,A=n.height,E=n.enableHover,S=n.showGrid,O=n.showLegend,L=n.title,j=n.categoryLabel,P=n.valueLabel,M=o||[],N=h||l,{activeSelectionHook:D,customHoverBehavior:C}=No({selection:v,linkedHover:b,fallbackFields:N?["string"==typeof N?N:""]:[],unwrapData:!0,onObservation:x,chartType:"GroupedBarChart",chartId:w}),T=Po(M,N,g),B=r(()=>e=>N?{fill:In(e,N,T)}:{fill:Lo},[N,T]),W=r(()=>go(B,D,v),[B,D,v]),{legend:H,margin:$}=Do({data:M,colorBy:N,colorScale:T,showLegend:O,userMargin:i,defaults:n.marginDefaults}),_=r(()=>so({categoryAccessor:l,valueAccessor:c,groupAccessor:s}),[l,s,c]),z=Fo({componentName:"GroupedBarChart",data:M,accessors:{categoryAccessor:s,valueAccessor:c},requiredProps:{groupBy:l}});if(z)return e.createElement(Bo,{componentName:"GroupedBarChart",message:z,width:k,height:A});const I=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"clusterbar",data:M,oAccessor:s,rAccessor:c,groupBy:l,projection:"horizontal"===u?"horizontal":"vertical",pieceStyle:W,size:[k,A],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:$,barPadding:p,enableHover:E,showAxes:n.showAxes,oLabel:j,rLabel:P,rFormat:d,showGrid:S},H&&{legend:H}),L&&{title:L}),a&&{className:a}),{tooltipContent:y?no(y):_}),(b||x)&&{customHoverBehavior:C}),f&&f.length>0&&{annotations:f}),m);return e.createElement(_o,{componentName:"GroupedBarChart",width:k,height:A},e.createElement(vt,Object.assign({},I)))}function Sr(t){var n;const o=To(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLegend:t.showLegend,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{nodes:i,edges:a,margin:s,className:l,nodeIDAccessor:c="id",sourceAccessor:u="source",targetAccessor:d="target",nodeLabel:h,colorBy:g,colorScheme:p="category10",nodeSize:y=8,nodeSizeRange:f=[5,20],edgeWidth:m=1,edgeColor:v="#999",edgeOpacity:b=.6,iterations:x=300,forceStrength:w=.1,tooltip:k,frameProps:A={},onObservation:E,chartId:S,selection:O,linkedHover:L}=t,j=o.width,P=o.height,M=o.enableHover,N=o.showLegend,D=null!==(n=o.showLabels)&&void 0!==n&&n,C=o.title,T=i||[],B=a||[],W=Po(T,g,p),H=r(()=>e=>{const t={};return t.fill=g?In(e.data||e,g,W):Lo,"number"==typeof y&&(t.r=y),t},[g,W,y]),$=r(()=>e=>({stroke:v,strokeWidth:"number"==typeof m?m:"function"==typeof m?m(e):e[m]||1,opacity:b}),[m,v,b]),_=r(()=>{if(D&&h)return"function"==typeof h?h:e=>e[h]},[D,h]),{legend:z,margin:I}=Do({data:T,colorBy:g,colorScale:W,showLegend:N,userMargin:s,defaults:o.marginDefaults}),{customHoverBehavior:R}=No({selection:O,linkedHover:L,fallbackFields:g?["string"==typeof g?g:""]:[],unwrapData:!0,onObservation:E,chartType:"ForceDirectedGraph",chartId:S}),F=Go({componentName:"ForceDirectedGraph",nodes:i,edges:a,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:c}});return F?e.createElement(Bo,{componentName:"ForceDirectedGraph",message:F,width:j,height:P}):e.createElement(_o,{componentName:"ForceDirectedGraph",width:j,height:P},e.createElement(Zn,Object.assign({chartType:"force",nodes:T,edges:B,size:[j,P],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:I,nodeIDAccessor:c,sourceAccessor:u,targetAccessor:d,iterations:x,forceStrength:w,nodeStyle:H,edgeStyle:$,colorBy:g,colorScheme:p,nodeSize:y,nodeSizeRange:f,nodeLabel:_,showLabels:D,enableHover:M,tooltipContent:k?e=>no(k)(e.data):void 0,customHoverBehavior:L||E?R:void 0,legend:z,className:l,title:C},A)))}function Or(e,t){if(!e)return[];const n=[],o=e=>{n.push(e);const r="function"==typeof t?t(e):e[t];r&&Array.isArray(r)&&r.forEach(o)};return o(e),n}function Lr(e,t,n,o){if(e&&e.length>0)return e;const r=new Set;return t.forEach(e=>{const t="function"==typeof n?n(e):e[n],i="function"==typeof o?o(e):e[o];r.add(t),r.add(i)}),Array.from(r).map(e=>({id:e}))}function jr(e){return"function"==typeof e?e:t=>t[e]||1}function Pr({edgeColorBy:e,colorBy:t,colorScale:n,nodeStyleFn:o,edgeOpacity:r,baseStyle:i={}}){return a=>{const s=Object.assign({fillOpacity:r},i);if("function"==typeof e)s.fill=e(a);else if("source"===e){const e="object"==typeof a.source?a.source:null;t&&e?s.fill=In(e.data||e,t,n):e&&(s.fill=o(e,e.index).fill)}else if("target"===e){const e="object"==typeof a.target?a.target:null;t&&e?s.fill=In(e.data||e,t,n):e&&(s.fill=o(e,e.index).fill)}else"gradient"===e&&(s.fill="#999",s.fillOpacity=.7*r);return s}}function Mr(t){var n;const o=To(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{nodes:i,edges:a,margin:s,className:l,sourceAccessor:c="source",targetAccessor:u="target",valueAccessor:d="value",nodeIdAccessor:h="id",colorBy:g,colorScheme:p="category10",edgeColorBy:y="source",padAngle:f=.01,groupWidth:m=20,sortGroups:v,nodeLabel:b,edgeOpacity:x=.5,tooltip:w,frameProps:k={},onObservation:A,chartId:E,selection:S,linkedHover:O}=t,L=o.width,j=o.height,P=o.enableHover,M=null===(n=o.showLabels)||void 0===n||n,N=o.title,D=a||[],C=r(()=>Lr(i,D,c,u),[i,D,c,u]),T=Po(C,g,p),B=r(()=>(e,t)=>{var n,o;const r={stroke:"black",strokeWidth:1};if(g)r.fill=In(e.data||e,g,T);else{const i=Array.isArray(p)?p:$n[p]||_n,a=Array.isArray(i)?i:_n,s=null!==(o=null!==(n=e.index)&&void 0!==n?n:t)&&void 0!==o?o:0;r.fill=a[s%a.length]}return r},[g,T,p]),W=r(()=>Pr({edgeColorBy:y,colorBy:g,colorScale:T,nodeStyleFn:B,edgeOpacity:x,baseStyle:{stroke:"black",strokeWidth:.5,strokeOpacity:x}}),[y,g,T,B,x]),H=r(()=>{if(!M)return;const e=b||h;return"function"==typeof e?e:t=>t[e]},[M,b,h]),$=Object.assign(Object.assign({},o.marginDefaults),s),{customHoverBehavior:_}=No({selection:S,linkedHover:O,fallbackFields:g?["string"==typeof g?g:""]:[],unwrapData:!0,onObservation:A,chartType:"ChordDiagram",chartId:E}),z=Go({componentName:"ChordDiagram",edges:a,edgesRequired:!0});return z?e.createElement(Bo,{componentName:"ChordDiagram",message:z,width:L,height:j}):e.createElement(_o,{componentName:"ChordDiagram",width:L,height:j},e.createElement(Zn,Object.assign({chartType:"chord",nodes:C,edges:D,size:[L,j],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:$,nodeIDAccessor:h,sourceAccessor:c,targetAccessor:u,valueAccessor:d,padAngle:f,groupWidth:m,sortGroups:v,nodeStyle:B,edgeStyle:W,colorBy:g,colorScheme:p,edgeColorBy:y,edgeOpacity:x,nodeLabel:H,showLabels:M,enableHover:P,tooltipContent:w?e=>no(w)(e.data):void 0,customHoverBehavior:O||A?_:void 0,className:l,title:N},k)))}function Nr(t){var n;const o=To(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:800,height:600}),{nodes:i,edges:a,margin:s,className:l,sourceAccessor:c="source",targetAccessor:u="target",valueAccessor:d="value",nodeIdAccessor:h="id",colorBy:g,colorScheme:p="category10",edgeColorBy:y="source",orientation:f="horizontal",nodeAlign:m="justify",nodePaddingRatio:v=.05,nodeWidth:b=15,nodeLabel:x,edgeOpacity:w=.5,edgeSort:k,tooltip:A,frameProps:E={},onObservation:S,chartId:O,selection:L,linkedHover:j}=t,P=o.width,M=o.height,N=o.enableHover,D=null===(n=o.showLabels)||void 0===n||n,C=o.title,T=a||[],B=r(()=>Lr(i,T,c,u),[i,T,c,u]),W=Po(B,g,p),H=r(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=g?In(e.data||e,g,W):"#4d430c",t},[g,W]),$=r(()=>Pr({edgeColorBy:y,colorBy:g,colorScale:W,nodeStyleFn:H,edgeOpacity:w,baseStyle:{stroke:"none",strokeWidth:0}}),[y,g,W,H,w]),_=r(()=>{if(!D)return;const e=x||h;return"function"==typeof e?e:t=>t[e]},[D,x,h]),z=Object.assign(Object.assign({},o.marginDefaults),s),{customHoverBehavior:I,customClickBehavior:R}=No({selection:L,linkedHover:j,fallbackFields:g?["string"==typeof g?g:""]:[],unwrapData:!0,onObservation:S,chartType:"SankeyDiagram",chartId:O}),F=Go({componentName:"SankeyDiagram",edges:a,edgesRequired:!0});return F?e.createElement(Bo,{componentName:"SankeyDiagram",message:F,width:P,height:M}):e.createElement(_o,{componentName:"SankeyDiagram",width:P,height:M},e.createElement(Zn,Object.assign({chartType:"sankey",nodes:B,edges:T,size:[P,M],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:z,nodeIDAccessor:h,sourceAccessor:c,targetAccessor:u,valueAccessor:d,orientation:f,nodeAlign:m,nodePaddingRatio:v,nodeWidth:b,nodeStyle:H,edgeStyle:$,colorBy:g,colorScheme:p,edgeColorBy:y,edgeOpacity:w,edgeSort:k,nodeLabel:_,showLabels:D,enableHover:N,tooltipContent:A?e=>no(A)(e.data):void 0,customHoverBehavior:j||S?I:void 0,customClickBehavior:S?R:void 0,className:l,title:C},E)))}function Dr(t){var n;const o=To(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{data:i,margin:a,className:s,layout:l="tree",orientation:c="vertical",childrenAccessor:u="children",valueAccessor:d="value",nodeIdAccessor:h="name",colorBy:g,colorScheme:p="category10",colorByDepth:y=!1,edgeStyle:f="curve",nodeLabel:m,nodeSize:v=5,tooltip:b,frameProps:x={},onObservation:w,chartId:k,selection:A,linkedHover:E}=t,S=o.width,O=o.height,L=o.enableHover,j=null===(n=o.showLabels)||void 0===n||n,P=o.title,M=Po(r(()=>Or(i,u),[i,u]),y?void 0:g,p),N=r(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=y?zn[(e.depth||0)%zn.length]:g?In(e.data||e,g,M):Lo,t},[g,y,M]),D=r(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),C=r(()=>{if("treemap"===l||"circlepack"===l||"partition"===l)return jr(d)},[l,d]),T=Object.assign(Object.assign({},o.marginDefaults),a),{customHoverBehavior:B}=No({selection:A,linkedHover:E,fallbackFields:g?["string"==typeof g?g:""]:[],unwrapData:!0,onObservation:w,chartType:"TreeDiagram",chartId:k}),W=Yo({componentName:"TreeDiagram",data:i});return W?e.createElement(Bo,{componentName:"TreeDiagram",message:W,width:S,height:O}):e.createElement(_o,{componentName:"TreeDiagram",width:S,height:O},e.createElement(Zn,Object.assign({chartType:l,data:i,size:[S,O],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:T,nodeIDAccessor:h,childrenAccessor:u,hierarchySum:C,treeOrientation:c,edgeType:f,nodeStyle:N,edgeStyle:D,colorBy:g,colorScheme:p,colorByDepth:y,nodeSize:v,nodeLabel:j?m||h:void 0,showLabels:j,enableHover:L,tooltipContent:b?e=>no(b)(e.data):void 0,customHoverBehavior:E||w?B:void 0,className:s,title:P},x)))}function Cr(t){var n;const o=To(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,linkedHover:t.linkedHover},{width:600,height:600}),{data:i,margin:s,className:l,childrenAccessor:c="children",valueAccessor:u="value",nodeIdAccessor:d="name",colorBy:h,colorScheme:g="category10",colorByDepth:p=!1,labelMode:y="leaf",nodeLabel:f,padding:m=4,paddingTop:v,tooltip:b,frameProps:x={},selection:w,linkedHover:k,onObservation:A,chartId:E}=t,S=o.width,O=o.height,L=o.enableHover,j=null===(n=o.showLabels)||void 0===n||n,P=o.title,{activeSelectionHook:M,customHoverBehavior:N}=No({selection:w,linkedHover:k,fallbackFields:h?["string"==typeof h?h:""]:[],onObservation:A,chartType:"Treemap",chartId:E}),D=a(e=>{if(!e)return N(null);const t=e.data||e;N({data:(null==t?void 0:t.data)||t})},[N]),C=Po(r(()=>Or(i,c),[i,c]),p?void 0:h,g),T=r(()=>e=>{const t={stroke:"#fff",strokeWidth:1,strokeOpacity:.8};return t.fill=p?zn[(e.depth||0)%zn.length]:h?In(e.data||e,h,C):Lo,t},[h,p,C]),B=r(()=>M?e=>{var t;const n=Object.assign({},T(e));if(M.isActive)if(M.predicate(e.data||e))(null==w?void 0:w.selectedStyle)&&Object.assign(n,w.selectedStyle);else{const e=null!==(t=null==w?void 0:w.unselectedOpacity)&&void 0!==t?t:.2;n.opacity=e,n.fillOpacity=e,n.strokeOpacity=e,(null==w?void 0:w.unselectedStyle)&&Object.assign(n,w.unselectedStyle)}return n}:T,[T,M,w]),W=r(()=>jr(u),[u]),H=void 0!==v?v:j&&"parent"===y?18:void 0,$=Object.assign(Object.assign({},o.marginDefaults),s),_=Yo({componentName:"Treemap",data:i});return _?e.createElement(Bo,{componentName:"Treemap",message:_,width:S,height:O}):e.createElement(_o,{componentName:"Treemap",width:S,height:O},e.createElement(Zn,Object.assign({chartType:"treemap",data:i,size:[S,O],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:$,nodeIDAccessor:d,childrenAccessor:c,hierarchySum:W,padding:m,paddingTop:H,nodeStyle:B,colorBy:h,colorScheme:g,colorByDepth:p,nodeLabel:j?f||d:void 0,showLabels:j,enableHover:L,tooltipContent:b?e=>no(b)(e.data):void 0},(k||A)&&{customHoverBehavior:D},{className:l,title:P},x)))}function Tr(t){var n;const o=To(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title},{width:600,height:600}),{data:i,margin:a,className:s,childrenAccessor:l="children",valueAccessor:c="value",nodeIdAccessor:u="name",colorBy:d,colorScheme:h="category10",colorByDepth:g=!1,nodeLabel:p,circleOpacity:y=.7,padding:f=4,tooltip:m,frameProps:v={},onObservation:b,chartId:x,selection:w,linkedHover:k}=t,A=o.width,E=o.height,S=o.enableHover,O=null===(n=o.showLabels)||void 0===n||n,L=o.title,j=Po(r(()=>Or(i,l),[i,l]),g?void 0:d,h),P=r(()=>e=>{const t={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:y};return t.fill=g?zn[(e.depth||0)%zn.length]:d?In(e.data||e,d,j):Lo,t},[d,g,j,y]),M=r(()=>jr(c),[c]),N=Object.assign(Object.assign({},o.marginDefaults),a),{customHoverBehavior:D}=No({selection:w,linkedHover:k,fallbackFields:d?["string"==typeof d?d:""]:[],unwrapData:!0,onObservation:b,chartType:"CirclePack",chartId:x}),C=Yo({componentName:"CirclePack",data:i});return C?e.createElement(Bo,{componentName:"CirclePack",message:C,width:A,height:E}):e.createElement(_o,{componentName:"CirclePack",width:A,height:E},e.createElement(Zn,Object.assign({chartType:"circlepack",data:i,size:[A,E],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:N,nodeIDAccessor:u,childrenAccessor:l,hierarchySum:M,padding:f,nodeStyle:P,colorBy:d,colorScheme:h,colorByDepth:g,nodeLabel:O?p||u:void 0,showLabels:O,enableHover:S,tooltipContent:m?e=>no(m)(e.data):void 0,customHoverBehavior:k||b?D:void 0,className:s,title:L},v)))}dr.displayName="ScatterplotMatrix",gr.displayName="MinimapChart",pr.displayName="BarChart",yr.displayName="StackedBarChart",fr.displayName="SwarmPlot",mr.displayName="BoxPlot",vr.displayName="Histogram",br.displayName="ViolinPlot",xr.displayName="RidgelinePlot",wr.displayName="DotPlot",kr.displayName="PieChart",Ar.displayName="DonutChart",Er.displayName="GroupedBarChart",Sr.displayName="ForceDirectedGraph",Mr.displayName="ChordDiagram",Nr.displayName="SankeyDiagram",Dr.displayName="TreeDiagram",Cr.displayName="Treemap",Tr.displayName="CirclePack";const Br=i(function(n,o){var r,i,l,c;const u=To(n.mode,{width:null!==(i=null===(r=n.size)||void 0===r?void 0:r[0])&&void 0!==i?i:n.width,height:null!==(c=null===(l=n.size)||void 0===l?void 0:l[1])&&void 0!==c?c:n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0}),{size:d,margin:h,className:g,arrowOfTime:p="right",windowMode:y="sliding",windowSize:f=200,data:m,timeAccessor:v,valueAccessor:b,timeExtent:x,valueExtent:w,extentPadding:k,stroke:A="#007bff",strokeWidth:E=2,strokeDasharray:S,background:O,tooltipContent:L,tooltip:j,onHover:P,annotations:M,svgAnnotationRules:N,tickFormatTime:D,tickFormatValue:C,decay:T,pulse:B,staleness:W,transition:H,linkedHover:$,onObservation:_,chartId:z}=n,I=u.showAxes,R=u.enableHover,F=null!=h?h:u.marginDefaults,Y=null!=d?d:[u.width,u.height],G=null!=L?L:j,X=t(null),{customHoverBehavior:q}=No({linkedHover:$,unwrapData:!0,onObservation:_,chartType:"RealtimeLineChart",chartId:z}),V=a(e=>{P&&P(e),q(e)},[P,q]);return s(o,()=>({push:e=>{var t;return null===(t=X.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=X.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=X.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=X.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}})),e.createElement(Ke,{ref:X,chartType:"line",runtimeMode:"streaming",size:Y,margin:F,className:g,arrowOfTime:p,windowMode:y,windowSize:f,data:m,timeAccessor:v,valueAccessor:b,xExtent:x,yExtent:w,extentPadding:k,lineStyle:{stroke:A,strokeWidth:E,strokeDasharray:S},showAxes:I,background:O,hoverAnnotation:R,tooltipContent:G,customHoverBehavior:V,annotations:M,svgAnnotationRules:N,tickFormatTime:D,tickFormatValue:C,decay:T,pulse:B,staleness:W,transition:H})});Br.displayName="RealtimeLineChart";const Wr=i(function(n,o){var r,i,l,c;const u=To(n.mode,{width:null!==(i=null===(r=n.size)||void 0===r?void 0:r[0])&&void 0!==i?i:n.width,height:null!==(c=null===(l=n.size)||void 0===l?void 0:l[1])&&void 0!==c?c:n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0}),{binSize:d,size:h,margin:g,className:p,arrowOfTime:y="right",windowMode:f="sliding",windowSize:m=200,data:v,timeAccessor:b,valueAccessor:x,timeExtent:w,valueExtent:k,extentPadding:A,categoryAccessor:E,colors:S,fill:O,stroke:L,strokeWidth:j,gap:P,background:M,tooltipContent:N,tooltip:D,onHover:C,annotations:T,svgAnnotationRules:B,tickFormatTime:W,tickFormatValue:H,linkedHover:$,decay:_,pulse:z,staleness:I,transition:R,onObservation:F,chartId:Y}=n,G=u.showAxes,X=u.enableHover,q=null!=g?g:u.marginDefaults,V=null!=h?h:[u.width,u.height],U=null!=N?N:D,Z=t(null),{customHoverBehavior:Q}=No({linkedHover:$,unwrapData:!0,onObservation:F,chartType:"RealtimeTemporalHistogram",chartId:Y}),K=a(e=>{C&&C(e),Q(e)},[C,Q]);s(o,()=>({push:e=>{var t;return null===(t=Z.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=Z.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=Z.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=Z.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const J={};return null!=O&&(J.fill=O),null!=L&&(J.stroke=L),null!=j&&(J.strokeWidth=j),null!=P&&(J.gap=P),e.createElement(Ke,{ref:Z,chartType:"bar",runtimeMode:"streaming",size:V,margin:q,className:p,arrowOfTime:y,windowMode:f,windowSize:m,data:v,timeAccessor:b,valueAccessor:x,xExtent:w,yExtent:k,extentPadding:A,binSize:d,categoryAccessor:E,barColors:S,barStyle:J,showAxes:G,background:M,hoverAnnotation:X,tooltipContent:U,customHoverBehavior:K,annotations:T,svgAnnotationRules:B,tickFormatTime:W,tickFormatValue:H,decay:_,pulse:z,staleness:I,transition:R})});Wr.displayName="RealtimeTemporalHistogram";const Hr=Wr,$r=i(function(n,o){var r,i,l,c;const u=To(n.mode,{width:null!==(i=null===(r=n.size)||void 0===r?void 0:r[0])&&void 0!==i?i:n.width,height:null!==(c=null===(l=n.size)||void 0===l?void 0:l[1])&&void 0!==c?c:n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0}),{size:d,margin:h,className:g,arrowOfTime:p="right",windowMode:y="sliding",windowSize:f=200,data:m,timeAccessor:v,valueAccessor:b,timeExtent:x,valueExtent:w,extentPadding:k,categoryAccessor:A,colors:E,radius:S,fill:O,opacity:L,stroke:j,strokeWidth:P,background:M,tooltipContent:N,tooltip:D,onHover:C,annotations:T,svgAnnotationRules:B,tickFormatTime:W,tickFormatValue:H,linkedHover:$,onObservation:_,chartId:z}=n,I=u.showAxes,R=u.enableHover,F=null!=h?h:u.marginDefaults,Y=null!=d?d:[u.width,u.height],G=null!=N?N:D,X=t(null),{customHoverBehavior:q}=No({linkedHover:$,unwrapData:!0,onObservation:_,chartType:"RealtimeSwarmChart",chartId:z}),V=a(e=>{C&&C(e),q(e)},[C,q]);s(o,()=>({push:e=>{var t;return null===(t=X.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=X.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=X.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=X.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const U={};return null!=S&&(U.radius=S),null!=O&&(U.fill=O),null!=L&&(U.opacity=L),null!=j&&(U.stroke=j),null!=P&&(U.strokeWidth=P),e.createElement(Ke,{ref:X,chartType:"swarm",runtimeMode:"streaming",size:Y,margin:F,className:g,arrowOfTime:p,windowMode:y,windowSize:f,data:m,timeAccessor:v,valueAccessor:b,xExtent:x,yExtent:w,extentPadding:k,categoryAccessor:A,barColors:E,swarmStyle:U,showAxes:I,background:M,hoverAnnotation:R,tooltipContent:G,customHoverBehavior:V,annotations:T,svgAnnotationRules:B,tickFormatTime:W,tickFormatValue:H})});$r.displayName="RealtimeSwarmChart";const _r=i(function(n,o){var r,i,l,c;const u=To(n.mode,{width:null!==(i=null===(r=n.size)||void 0===r?void 0:r[0])&&void 0!==i?i:n.width,height:null!==(c=null===(l=n.size)||void 0===l?void 0:l[1])&&void 0!==c?c:n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0}),{size:d,margin:h,className:g,arrowOfTime:p="right",windowMode:y="sliding",windowSize:f=200,data:m,timeAccessor:v,valueAccessor:b,timeExtent:x,valueExtent:w,extentPadding:k,positiveColor:A,negativeColor:E,connectorStroke:S,connectorWidth:O,gap:L,stroke:j,strokeWidth:P,background:M,tooltipContent:N,tooltip:D,onHover:C,annotations:T,svgAnnotationRules:B,tickFormatTime:W,tickFormatValue:H,linkedHover:$,onObservation:_,chartId:z}=n,I=u.showAxes,R=u.enableHover,F=null!=h?h:u.marginDefaults,Y=null!=d?d:[u.width,u.height],G=null!=N?N:D,X=t(null),{customHoverBehavior:q}=No({linkedHover:$,unwrapData:!0,onObservation:_,chartType:"RealtimeWaterfallChart",chartId:z}),V=a(e=>{C&&C(e),q(e)},[C,q]);s(o,()=>({push:e=>{var t;return null===(t=X.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=X.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=X.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=X.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const U={};return null!=A&&(U.positiveColor=A),null!=E&&(U.negativeColor=E),null!=S&&(U.connectorStroke=S),null!=O&&(U.connectorWidth=O),null!=L&&(U.gap=L),null!=j&&(U.stroke=j),null!=P&&(U.strokeWidth=P),e.createElement(Ke,{ref:X,chartType:"waterfall",runtimeMode:"streaming",size:Y,margin:F,className:g,arrowOfTime:p,windowMode:y,windowSize:f,data:m,timeAccessor:v,valueAccessor:b,xExtent:x,yExtent:w,extentPadding:k,waterfallStyle:U,showAxes:I,background:M,hoverAnnotation:R,tooltipContent:G,customHoverBehavior:V,annotations:T,svgAnnotationRules:B,tickFormatTime:W,tickFormatValue:H})});_r.displayName="RealtimeWaterfallChart";const zr=i(function(n,o){var r,i,l,c;const u=To(n.mode,{width:null!==(i=null===(r=n.size)||void 0===r?void 0:r[0])&&void 0!==i?i:n.width,height:null!==(c=null===(l=n.size)||void 0===l?void 0:l[1])&&void 0!==c?c:n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0}),{size:d,margin:h,className:g,arrowOfTime:p="right",windowMode:y="sliding",windowSize:f=200,data:m,timeAccessor:v,valueAccessor:b,categoryAccessor:x,timeExtent:w,valueExtent:k,extentPadding:A,heatmapXBins:E=20,heatmapYBins:S=20,aggregation:O="count",background:L,tooltipContent:j,tooltip:P,onHover:M,annotations:N,svgAnnotationRules:D,tickFormatTime:C,tickFormatValue:T,decay:B,pulse:W,staleness:H,linkedHover:$,onObservation:_,chartId:z}=n,I=u.showAxes,R=u.enableHover,F=null!=h?h:u.marginDefaults,Y=null!=d?d:[u.width,u.height],G=null!=j?j:P,X=t(null),{customHoverBehavior:q}=No({linkedHover:$,unwrapData:!0,onObservation:_,chartType:"RealtimeHeatmap",chartId:z}),V=a(e=>{M&&M(e),q(e)},[M,q]);return s(o,()=>({push:e=>{var t;return null===(t=X.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=X.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=X.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=X.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}})),e.createElement(Ke,{ref:X,chartType:"heatmap",runtimeMode:"streaming",size:Y,margin:F,className:g,arrowOfTime:p,windowMode:y,windowSize:f,data:m,timeAccessor:v,valueAccessor:b,categoryAccessor:x,xExtent:w,yExtent:k,extentPadding:A,heatmapXBins:E,heatmapYBins:S,heatmapAggregation:O,showAxes:I,background:L,hoverAnnotation:R,tooltipContent:G,customHoverBehavior:V,annotations:N,svgAnnotationRules:D,tickFormatTime:C,tickFormatValue:T,decay:B,pulse:W,staleness:H})});function Ir(e){if(null==e)return"";if("number"!=typeof e)return e+"";if(!isFinite(e))return e+"";if(0===e)return"0";const t=parseFloat(e.toPrecision(12)),n=Math.abs(t);return 1e9>n?1e6>n?1e4>n?Number.isInteger(t)?t+"":parseFloat(t.toPrecision(6))+"":parseFloat((t/1e3).toPrecision(3))+"K":parseFloat((t/1e6).toPrecision(3))+"M":parseFloat((t/1e9).toPrecision(3))+"B"}zr.displayName="RealtimeHeatmap";const Rr={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}},Fr={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}},[Yr,Gr]=po(e=>({theme:Rr,setTheme(t){e(e=>"light"===t?{theme:Rr}:"dark"===t?{theme:Fr}:{theme:Object.assign(Object.assign(Object.assign({},e.theme),t),{colors:Object.assign(Object.assign({},e.theme.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.theme.typography),t.typography||{})})})}}));function Xr({theme:t}){const n=Gr(e=>e.setTheme);return e.useEffect(()=>{void 0!==t&&n(t)},[t,n]),null}function qr({children:t}){const n=Gr(e=>e.theme);return e.createElement("div",{style:{position:"relative","--semiotic-bg":n.colors.background,"--semiotic-text":n.colors.text,"--semiotic-text-secondary":n.colors.textSecondary,"--semiotic-grid":n.colors.grid,"--semiotic-border":n.colors.border,"--semiotic-primary":n.colors.primary,"--semiotic-font-family":n.typography.fontFamily}},t)}function Vr({theme:t,children:n}){return e.createElement(Yr,null,e.createElement(Xr,{theme:t}),e.createElement(qr,null,n))}function Ur(){return Gr(e=>e.theme)}function Zr(e,t,n,o){return new(n||(n=Promise))(function(r,i){function a(e){try{l(o.next(e))}catch(e){i(e)}}function s(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){e.done?r(e.value):function(e){return e instanceof n?e:new n(function(t){t(e)})}(e.value).then(a,s)}l((o=o.apply(e,t||[])).next())})}function Qr(e,t){return Zr(this,void 0,void 0,function*(){const{format:n="svg",filename:o="chart",scale:r=2,background:i="white"}=t||{},a=e.querySelector("svg");if(!a)throw Error("No SVG element found in the container");const s=a.cloneNode(!0),l=a.getBoundingClientRect();if(s.getAttribute("width")||s.setAttribute("width",l.width+""),s.getAttribute("height")||s.setAttribute("height",l.height+""),s.getAttribute("xmlns")||s.setAttribute("xmlns","http://www.w3.org/2000/svg"),Kr(a,s),"svg"===n){const e=(new XMLSerializer).serializeToString(s);Jr(new Blob([e],{type:"image/svg+xml;charset=utf-8"}),o+".svg")}else{const e=l.width*r,t=l.height*r,n=(new XMLSerializer).serializeToString(s),a=new Blob([n],{type:"image/svg+xml;charset=utf-8"}),c=URL.createObjectURL(a),u=new Image;u.width=l.width,u.height=l.height,yield new Promise((n,a)=>{u.onload=()=>{const s=document.createElement("canvas");s.width=e,s.height=t;const l=s.getContext("2d");l.fillStyle=i,l.fillRect(0,0,e,t),l.scale(r,r),l.drawImage(u,0,0),s.toBlob(e=>{e?(Jr(e,o+".png"),n()):a(Error("Failed to create PNG blob"))},"image/png"),URL.revokeObjectURL(c)},u.onerror=()=>{URL.revokeObjectURL(c),a(Error("Failed to load SVG image"))},u.src=c})}})}function Kr(e,t){var n;const o=e.children,r=t.children,i=window.getComputedStyle(e),a=["fill","stroke","stroke-width","stroke-dasharray","opacity","fill-opacity","stroke-opacity","font-family","font-size","font-weight","text-anchor","dominant-baseline"];for(const e of a){const o=i.getPropertyValue(e);o&&"none"!==o&&""!==o&&(null===(n=t.style)||void 0===n||n.setProperty(e,o))}for(let e=0;Math.min(o.length,r.length)>e;e++)Kr(o[e],r[e])}function Jr(e,t){const n=URL.createObjectURL(e),o=document.createElement("a");o.href=n,o.download=t,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(n)}"function"==typeof SuppressedError&&SuppressedError;const ei={width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["function","object"]},frameProps:{type:"object"}},ti={xLabel:{type:"string"},yLabel:{type:"string"},xFormat:{type:"function"},yFormat:{type:"function"}},ni={categoryLabel:{type:"string"},valueLabel:{type:"string"},valueFormat:{type:"function"}},oi=["linear","monotoneX","monotoneY","step","stepAfter","stepBefore","basis","cardinal","catmullRom"],ri=["vertical","horizontal"],ii={LineChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},ei),ti),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},lineBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:oi},lineWidth:{type:"number"},showPoints:{type:"boolean"},pointRadius:{type:"number"},fillArea:{type:"boolean"},areaOpacity:{type:"number"}})},AreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},ei),ti),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:oi},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"}})},StackedAreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},ei),ti),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:oi},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"},normalize:{type:"boolean"}})},Scatterplot:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},ei),ti),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"}})},BubbleChart:{required:["data","sizeBy"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},ei),ti),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},bubbleOpacity:{type:"number"},bubbleStrokeWidth:{type:"number"},bubbleStrokeColor:{type:"string"}})},Heatmap:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},ei),ti),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},colorScheme:{type:"string",enum:["blues","reds","greens","viridis","custom"]},customColorScale:{type:["object","function"]},showValues:{type:"boolean"},valueFormat:{type:"function"},cellBorderColor:{type:"string"},cellBorderWidth:{type:"number"}})},BarChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},ei),ni),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:ri},sort:{type:["boolean","string","function"]},barPadding:{type:"number"}})},StackedBarChart:{required:["data","stackBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},ei),ni),{data:{type:"array"},categoryAccessor:{type:["string","function"]},stackBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:ri},normalize:{type:"boolean"},barPadding:{type:"number"}})},GroupedBarChart:{required:["data","groupBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},ei),ni),{data:{type:"array"},categoryAccessor:{type:["string","function"]},groupBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:ri},barPadding:{type:"number"}})},SwarmPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},ei),ni),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:ri},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"},categoryPadding:{type:"number"}})},BoxPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},ei),ni),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:ri},showOutliers:{type:"boolean"},outlierRadius:{type:"number"},categoryPadding:{type:"number"}})},Histogram:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},ei),ni),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},bins:{type:"number"},relative:{type:"boolean"},categoryPadding:{type:"number"}})},ViolinPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},ei),ni),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:ri},bins:{type:"number"},curve:{type:"string"},showIQR:{type:"boolean"},categoryPadding:{type:"number"}})},DotPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},ei),ni),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:ri},sort:{type:["boolean","string","function"]},dotRadius:{type:"number"},categoryPadding:{type:"number"}})},PieChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},ei),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},startAngle:{type:"number"},slicePadding:{type:"number"}})},DonutChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},ei),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},innerRadius:{type:"number"},centerContent:{type:["object","string","number"]},startAngle:{type:"number"},slicePadding:{type:"number"}})},ForceDirectedGraph:{required:["nodes","edges"],dataShape:"network",dataAccessors:["nodeIDAccessor","sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},ei),{nodes:{type:"array"},edges:{type:"array"},nodeIDAccessor:{type:["string","function"]},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},nodeLabel:{type:["string","function"]},nodeSize:{type:["number","string","function"]},nodeSizeRange:{type:"array"},edgeWidth:{type:["number","string","function"]},edgeColor:{type:"string"},edgeOpacity:{type:"number"},iterations:{type:"number"},forceStrength:{type:"number"},showLabels:{type:"boolean"}})},SankeyDiagram:{required:["edges"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},ei),{nodes:{type:"array"},edges:{type:"array"},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},edgeColorBy:{type:["string","function"],enum:["source","target","gradient"]},orientation:{type:"string",enum:ri},nodeAlign:{type:"string",enum:["justify","left","right","center"]},nodePaddingRatio:{type:"number"},nodeWidth:{type:"number"},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},edgeOpacity:{type:"number"},edgeSort:{type:"function"}})},ChordDiagram:{required:["edges"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},ei),{nodes:{type:"array"},edges:{type:"array"},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},edgeColorBy:{type:["string","function"],enum:["source","target"]},padAngle:{type:"number"},groupWidth:{type:"number"},sortGroups:{type:"function"},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},edgeOpacity:{type:"number"}})},TreeDiagram:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},ei),{data:{type:"object"},layout:{type:"string",enum:["tree","cluster","partition","treemap","circlepack"]},orientation:{type:"string",enum:["vertical","horizontal","radial"]},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},edgeStyle:{type:"string",enum:["line","curve"]},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},nodeSize:{type:"number"}})},Treemap:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},ei),{data:{type:"object"},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},showLabels:{type:"boolean"},nodeLabel:{type:["string","function"]}})},CirclePack:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},ei),{data:{type:"object"},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},showLabels:{type:"boolean"},nodeLabel:{type:["string","function"]},circleOpacity:{type:"number"}})},RealtimeLineChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},stroke:{type:"string"},strokeWidth:{type:"number"},strokeDasharray:{type:"string"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeHistogram:{required:["binSize"],dataShape:"realtime",dataAccessors:[],props:{binSize:{type:"number"},size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},colors:{type:"object"},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},fill:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},gap:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeSwarmChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},colors:{type:"object"},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},radius:{type:"number"},fill:{type:"string"},opacity:{type:"number"},stroke:{type:"string"},strokeWidth:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeWaterfallChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},positiveColor:{type:"string"},negativeColor:{type:"string"},connectorStroke:{type:"string"},connectorWidth:{type:"number"},gap:{type:"number"},stroke:{type:"string"},strokeWidth:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeHeatmap:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},heatmapXBins:{type:"number"},heatmapYBins:{type:"number"},aggregation:{type:"string",enum:["count","sum","mean"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"}}}},ai=new Set(["tooltip","onObservation","xFormat","yFormat","valueFormat","svgAnnotationRules","tooltipContent","onHover","tickFormatTime","tickFormatValue","edgeSort","sortGroups","centerContent","frameProps","controls","oFormat","rFormat","oSort","pieceStyle","summaryStyle","nodeStyle","edgeStyle","customHoverBehavior","customClickBehavior","customDoubleClickBehavior","onBrush","onTopologyChange","backgroundGraphics","foregroundGraphics","legend"]),si=new Set(["data","nodes","edges"]),li="function"==typeof structuredClone?structuredClone:e=>JSON.parse(JSON.stringify(e));function ci(e,t,n){if(!ii[e])throw Error(`Unknown component "${e}". Known components: ${Object.keys(ii).join(", ")}`);const o=!1!==(null==n?void 0:n.includeData),r={};for(const[e,n]of Object.entries(t))null!=n&&(ai.has(e)||!o&&si.has(e)||"function"!=typeof n&&((null==n?void 0:n.$$typeof)||(r[e]=li(n))));return Object.assign({component:e,props:r,version:"1",createdAt:(new Date).toISOString()},(null==n?void 0:n.selections)?{selections:n.selections}:{})}function ui(e){if(!e.component||!e.props)throw Error("Invalid chart config: missing component or props");if(!ii[e.component])throw Error(`Unknown component "${e.component}". This config may require a newer version of semiotic.`);return{componentName:e.component,props:li(e.props)}}function di(e){const t=JSON.stringify(e);return"sc="+btoa(unescape(encodeURIComponent(t))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function hi(e){const t=new URLSearchParams(e.includes("?")?e.split("?")[1]:e).get("sc");if(!t)throw Error("No chart config found in URL (missing 'sc' parameter)");const n=t.replace(/-/g,"+").replace(/_/g,"/"),o=decodeURIComponent(escape(atob(n)));return JSON.parse(o)}function gi(e){return Zr(this,arguments,void 0,function*(e,t="json"){const n="jsx"===t?pi(e):JSON.stringify(e,null,2);if("undefined"==typeof navigator||!navigator.clipboard)throw Error("Clipboard API not available. copyConfig requires a browser environment.");yield navigator.clipboard.writeText(n)})}function pi(e){const{component:t,props:n}=e,o=["<"+t];for(const[e,t]of Object.entries(n))if("string"==typeof t)o.push(` ${e}="${t}"`);else if("boolean"==typeof t&&!0===t)o.push(" "+e);else if("boolean"==typeof t&&!1===t)o.push(` ${e}={false}`);else if("number"==typeof t)o.push(` ${e}={${t}}`);else{const n=JSON.stringify(t);o.push(80>n.length?` ${e}={${n}}`:` ${e}={${JSON.stringify(t,null,2)}}`)}return o.push("/>"),o.join("\n")}function yi(e){const t={};for(const[n,o]of e){const e=[];for(const[,t]of o.clauses){const n={};for(const[e,o]of Object.entries(t.fields))n[e]="point"===o.type?{type:"point",values:Array.from(o.values)}:{type:"interval",range:o.range};e.push({clientId:t.clientId,type:t.type,fields:n})}t[n]={name:o.name,resolution:o.resolution,clauses:e}}return t}function fi(e){const t=new Map;for(const[n,o]of Object.entries(e)){const e=new Map;for(const t of o.clauses){const n={};for(const[e,o]of Object.entries(t.fields))n[e]="point"===o.type?{type:"point",values:new Set(o.values)}:{type:"interval",range:o.range};e.set(t.clientId,{clientId:t.clientId,type:t.type,fields:n})}t.set(n,{name:o.name,resolution:o.resolution,clauses:e})}return t}function mi(e){return"nominal"===e||"ordinal"===e}function vi(e){return"quantitative"===e||"temporal"===e}const bi={category10:"category10",category20:"category20",category20b:"category20",category20c:"category20",accent:"accent",dark2:"dark2",paired:"paired",pastel1:"pastel1",pastel2:"pastel2",set1:"set1",set2:"set2",set3:"set3",tableau10:"category10",tableau20:"category20"},xi={linear:"linear","monotone-x":"monotoneX","monotone-y":"monotoneY",monotone:"monotoneX",step:"step","step-after":"stepAfter","step-before":"stepBefore",basis:"basis",cardinal:"cardinal","catmull-rom":"catmullRom"},wi={sum:"sum",mean:"mean",average:"mean",count:"count",min:"min",max:"max",median:"mean"};function ki(e){var t,n,o,r,i,a,s,l,c,u,d,h,g,p;const y=[],{type:f,markProps:m}=function(e){if("string"==typeof e)return{type:e,markProps:{}};const{type:t}=e;return{type:t,markProps:function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&0>t.indexOf(o)&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);o.length>r;r++)0>t.indexOf(o[r])&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n}(e,["type"])}}(e.mark),v=e.encoding||{},b=v.x,x=v.y,w=v.color,k=v.size,A=v.theta,E=v.opacity;let S;(null===(t=e.data)||void 0===t?void 0:t.values)?S=e.data.values:(null===(n=e.data)||void 0===n?void 0:n.url)&&y.push("data.url is not supported — only inline data.values can be translated. Provide data manually."),e.transform&&e.transform.length>0&&y.push("Vega-Lite transforms are not supported. Pre-transform your data before passing to fromVegaLite()."),e.layer&&y.push('Layered specs ("layer") are not supported. Only single-mark specs can be translated.'),(e.hconcat||e.vconcat||e.concat)&&y.push('Concatenated views ("hconcat"/"vconcat"/"concat") are not supported. Translate each sub-spec individually.'),(e.facet||e.encoding&&e.encoding.facet||e.encoding&&(e.encoding.row||e.encoding.column))&&y.push("Faceted views are not supported. Use Semiotic's LinkedCharts or render multiple charts manually."),e.repeat&&y.push('Repeated views ("repeat") are not supported. Translate each field combination individually.'),(e.params||e.selection)&&y.push("Selections/params are not supported. Use Semiotic's LinkedCharts and selection props for interactivity.");const O={};e.width&&(O.width=e.width),e.height&&(O.height=e.height);const L=function(e){if(e)return"string"==typeof e?e:e.text}(e.title);if(L&&(O.title=L),(null==w?void 0:w.field)&&(O.colorBy=w.field,null===(o=w.scale)||void 0===o?void 0:o.scheme)){const e=bi[w.scale.scheme];e&&(O.colorScheme=e)}void 0!==(null==E?void 0:E.value)&&(O.pointOpacity=E.value);const j=null==b?void 0:b.aggregate,P=null==x?void 0:x.aggregate;if(S&&(j||P)){const e=P?x:b,t=P?b:x,n=wi[e.aggregate];if(n&&(null==t?void 0:t.field)&&e.field)S=function(e,t){const{groupBy:n,value:o,agg:r="sum"}=t,i=new Map;for(const t of e){const e=t[n]+"";i.has(e)||i.set(e,[]),i.get(e).push(Number(t[o]))}const a=[];for(const[e,t]of i){let o;switch(r){case"count":o=t.length;break;case"mean":o=t.reduce((e,t)=>e+t,0)/t.length;break;case"min":o=Math.min(...t);break;case"max":o=Math.max(...t);break;default:o=t.reduce((e,t)=>e+t,0)}a.push({[n]:e,value:o})}return a}(S,{groupBy:t.field,value:e.field,agg:n});else if(("count"===n||"count"===e.aggregate)&&(null==t?void 0:t.field)&&S){const e=new Map;for(const n of S){const o=n[t.field]+"";e.set(o,(e.get(o)||0)+1)}S=Array.from(e,([e,n])=>({[t.field]:e,value:n}))}}if((null==b?void 0:b.bin)||(null==x?void 0:x.bin)){const e="Histogram";S&&(O.data=S),(null==b?void 0:b.bin)?(O.valueAccessor=b.field,(null==x?void 0:x.field)&&(O.categoryAccessor=x.field),(null===(r=b.axis)||void 0===r?void 0:r.title)&&(O.valueLabel=b.axis.title)):(null==x?void 0:x.bin)&&(O.valueAccessor=x.field,(null==b?void 0:b.field)&&(O.categoryAccessor=b.field),(null===(i=x.axis)||void 0===i?void 0:i.title)&&(O.valueLabel=x.axis.title));const t="object"==typeof((null==b?void 0:b.bin)||(null==x?void 0:x.bin))?(null===(a=null==b?void 0:b.bin)||void 0===a?void 0:a.maxbins)||(null===(s=null==x?void 0:x.bin)||void 0===s?void 0:s.maxbins):void 0;return t&&(O.bins=t),Ei(e,O,y)}let M;switch(f){case"bar":M=function(e,t,n,o,r,i,a){var s,l,c,u,d,h;let g;return(null==n?void 0:n.field)&&!1!==(null==e?void 0:e.stack)&&!1!==(null==t?void 0:t.stack)&&null!==(null==e?void 0:e.stack)&&null!==(null==t?void 0:t.stack)?(g="StackedBarChart",o.stackBy=n.field):g="BarChart",mi(null==e?void 0:e.type)&&vi(null==t?void 0:t.type)?(o.categoryAccessor=e.field,o.valueAccessor=a?"value":t.field,(null===(s=null==e?void 0:e.axis)||void 0===s?void 0:s.title)&&(o.categoryLabel=e.axis.title),(null===(l=null==t?void 0:t.axis)||void 0===l?void 0:l.title)&&(o.valueLabel=t.axis.title)):vi(null==e?void 0:e.type)&&mi(null==t?void 0:t.type)?(o.categoryAccessor=t.field,o.valueAccessor=i?"value":e.field,o.orientation="horizontal",(null===(c=null==t?void 0:t.axis)||void 0===c?void 0:c.title)&&(o.categoryLabel=t.axis.title),(null===(u=null==e?void 0:e.axis)||void 0===u?void 0:u.title)&&(o.valueLabel=e.axis.title)):((null==e?void 0:e.field)&&(o.categoryAccessor=e.field),(null==t?void 0:t.field)&&(o.valueAccessor=a?"value":t.field),(null===(d=null==e?void 0:e.axis)||void 0===d?void 0:d.title)&&(o.categoryLabel=e.axis.title),(null===(h=null==t?void 0:t.axis)||void 0===h?void 0:h.title)&&(o.valueLabel=t.axis.title)),r&&(o.data=r),g}(b,x,w,O,S,j,P);break;case"line":if(M="LineChart",Ai(b,x,O,j,P),(null==w?void 0:w.field)&&(O.lineBy=w.field),m.interpolate){const e=xi[m.interpolate];e&&(O.curve=e)}!0===m.point&&(O.showPoints=!0),S&&(O.data=S);break;case"area":if((null==w?void 0:w.field)?(M="StackedAreaChart",O.areaBy=w.field):M="AreaChart",Ai(b,x,O,j,P),m.interpolate){const e=xi[m.interpolate];e&&(O.curve=e)}void 0!==m.opacity&&(O.areaOpacity=m.opacity),S&&(O.data=S);break;case"point":case"circle":case"square":(null==k?void 0:k.field)?(M="BubbleChart",O.sizeBy=k.field,(null===(l=k.scale)||void 0===l?void 0:l.range)&&(O.sizeRange=k.scale.range)):M="Scatterplot",Ai(b,x,O,j,P),S&&(O.data=S);break;case"rect":M="Heatmap",(null==b?void 0:b.field)&&(O.xAccessor=b.field),(null==x?void 0:x.field)&&(O.yAccessor=x.field),(null==w?void 0:w.field)&&(O.valueAccessor=w.field,delete O.colorBy),(null===(c=null==b?void 0:b.axis)||void 0===c?void 0:c.title)&&(O.xLabel=b.axis.title),(null===(u=null==x?void 0:x.axis)||void 0===u?void 0:u.title)&&(O.yLabel=x.axis.title),S&&(O.data=S);break;case"arc":m.innerRadius&&m.innerRadius>0?(M="DonutChart",O.innerRadius=m.innerRadius):M="PieChart",(null==A?void 0:A.field)?O.valueAccessor=A.field:(null==x?void 0:x.field)&&(O.valueAccessor=P?"value":x.field),(null==w?void 0:w.field)&&(O.categoryAccessor=w.field),(null==b?void 0:b.field)&&!(null==A?void 0:A.field)&&(O.categoryAccessor=b.field),S&&(O.data=S);break;case"tick":M="DotPlot",mi(null==b?void 0:b.type)?(O.categoryAccessor=b.field,(null==x?void 0:x.field)&&(O.valueAccessor=P?"value":x.field),(null===(d=null==b?void 0:b.axis)||void 0===d?void 0:d.title)&&(O.categoryLabel=b.axis.title),(null===(h=null==x?void 0:x.axis)||void 0===h?void 0:h.title)&&(O.valueLabel=x.axis.title)):mi(null==x?void 0:x.type)?(O.categoryAccessor=x.field,(null==b?void 0:b.field)&&(O.valueAccessor=j?"value":b.field),O.orientation="horizontal",(null===(g=null==x?void 0:x.axis)||void 0===g?void 0:g.title)&&(O.categoryLabel=x.axis.title),(null===(p=null==b?void 0:b.axis)||void 0===p?void 0:p.title)&&(O.valueLabel=b.axis.title)):((null==b?void 0:b.field)&&(O.categoryAccessor=b.field),(null==x?void 0:x.field)&&(O.valueAccessor=P?"value":x.field)),S&&(O.data=S);break;default:y.push(`Unsupported mark type "${f}". Defaulting to Scatterplot.`),M="Scatterplot",Ai(b,x,O,j,P),S&&(O.data=S)}return Ei(M,O,y)}function Ai(e,t,n,o,r){var i,a;(null==e?void 0:e.field)&&(n.xAccessor=o?"value":e.field),(null==t?void 0:t.field)&&(n.yAccessor=r?"value":t.field),(null===(i=null==e?void 0:e.axis)||void 0===i?void 0:i.title)&&(n.xLabel=e.axis.title),(null===(a=null==t?void 0:t.axis)||void 0===a?void 0:a.title)&&(n.yLabel=t.axis.title)}function Ei(e,t,n){const o={component:e,props:t,version:"1",createdAt:(new Date).toISOString()};if(n.length>0){o.warnings=n;for(const e of n)console.warn("[semiotic/fromVegaLite] "+e)}return o}const Si={live:{bg:"#22c55e",color:"#fff"},stale:{bg:"#ef4444",color:"#fff"},paused:{bg:"#eab308",color:"#000"},error:{bg:"#ef4444",color:"#fff"},static:{bg:"#6b7280",color:"#fff"}};function Oi({height:t}){return e.createElement("div",{style:{width:"100%",height:t,background:"linear-gradient(90deg, var(--semiotic-border, #e0e0e0) 25%, var(--semiotic-bg, #f5f5f5) 50%, var(--semiotic-border, #e0e0e0) 75%)",backgroundSize:"200% 100%",animation:"semiotic-skeleton-pulse 1.5s ease-in-out infinite",borderRadius:4}})}function Li({error:t}){return e.createElement("div",{role:"alert",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",minHeight:120,padding:24,boxSizing:"border-box"}},e.createElement("div",{style:{textAlign:"center",maxWidth:400,fontSize:14,color:"var(--semiotic-text-secondary, #666)",lineHeight:1.5}},t))}const ji=e.forwardRef(function({title:t,subtitle:n,children:o,width:r="100%",height:i=400,actions:a,chartConfig:s,controls:l,loading:c=!1,error:u,errorBoundary:d=!1,status:h,detailsPanel:g,className:p,style:y},f){const m=e.useRef(null),v=e.useRef(null),[b,x]=e.useState(!1),w=!1!==(null==a?void 0:a.export)&&void 0!==(null==a?void 0:a.export),k=!1!==(null==a?void 0:a.fullscreen)&&void 0!==(null==a?void 0:a.fullscreen),A=!1!==(null==a?void 0:a.copyConfig)&&void 0!==(null==a?void 0:a.copyConfig)&&s,E="object"==typeof(null==a?void 0:a.export)?a.export:{},S="object"==typeof(null==a?void 0:a.copyConfig)?a.copyConfig.format:"json",O=e.useCallback(e=>Zr(this,void 0,void 0,function*(){v.current&&(yield Qr(v.current,Object.assign(Object.assign({},E),e)))}),[E]),L=e.useCallback(()=>{m.current&&(document.fullscreenElement?document.exitFullscreen().catch(()=>{}):m.current.requestFullscreen().catch(()=>{}))},[]),j=e.useCallback(e=>Zr(this,void 0,void 0,function*(){s&&(yield gi(s,e||S||"json"))}),[s,S]);e.useEffect(()=>{const e=()=>{x(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",e),()=>document.removeEventListener("fullscreenchange",e)},[]),e.useImperativeHandle(f,()=>({export:O,toggleFullscreen:L,copyConfig:j,element:m.current}),[O,L,j]);const P=t||n||l||w||k||A||h,M=c?e.createElement(Oi,{height:i}):u?e.createElement(Li,{error:u}):d?e.createElement(Wo,null,o):o;return e.createElement(e.Fragment,null,e.createElement("style",{dangerouslySetInnerHTML:{__html:"@keyframes semiotic-skeleton-pulse {\n 0% { background-position: 200% 0; }\n 100% { background-position: -200% 0; }\n}"}}),e.createElement("div",{ref:m,className:"semiotic-chart-container"+(p?" "+p:""),style:Object.assign(Object.assign({width:r,border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:8,overflow:"hidden",background:"var(--semiotic-bg, #fff)",position:"relative"},b?{display:"flex",flexDirection:"column",width:"100%",height:"100%"}:{}),y)},P&&e.createElement("div",{className:"semiotic-chart-header",style:{padding:"12px 16px",display:"flex",justifyContent:"space-between",alignItems:"flex-start",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"}},e.createElement("div",{className:"semiotic-chart-title-area"},t&&e.createElement("div",{className:"semiotic-chart-title",style:{fontSize:14,fontWeight:600,color:"var(--semiotic-text, #333)"}},t),n&&e.createElement("div",{className:"semiotic-chart-subtitle",style:{fontSize:12,color:"var(--semiotic-text-secondary, #666)",marginTop:t?2:0}},n)),e.createElement("div",{className:"semiotic-chart-toolbar",style:{display:"flex",alignItems:"center",gap:4}},l,w&&e.createElement("button",{className:"semiotic-chart-action",onClick:()=>O(),title:"Export chart",style:Pi},e.createElement("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("path",{d:"M7 2v8M3.5 7L7 10.5 10.5 7"}),e.createElement("path",{d:"M2 12h10"}))),k&&e.createElement("button",{className:"semiotic-chart-action",onClick:L,title:b?"Exit fullscreen":"Fullscreen",style:Pi},e.createElement("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},b?e.createElement(e.Fragment,null,e.createElement("path",{d:"M9 1v4h4"}),e.createElement("path",{d:"M5 13V9H1"}),e.createElement("path",{d:"M13 5H9V1"}),e.createElement("path",{d:"M1 9h4v4"})):e.createElement(e.Fragment,null,e.createElement("path",{d:"M1 5V1h4"}),e.createElement("path",{d:"M13 9v4H9"}),e.createElement("path",{d:"M9 1h4v4"}),e.createElement("path",{d:"M5 13H1V9"})))),A&&e.createElement("button",{className:"semiotic-chart-action",onClick:()=>j(),title:"Copy config",style:Pi},e.createElement("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("rect",{x:"5",y:"5",width:"8",height:"8",rx:"1"}),e.createElement("path",{d:"M9 5V2a1 1 0 00-1-1H2a1 1 0 00-1 1v6a1 1 0 001 1h3"}))),h&&e.createElement("div",{className:"semiotic-chart-status",style:{padding:"2px 8px",borderRadius:4,fontSize:10,fontWeight:700,letterSpacing:"0.05em",textTransform:"uppercase",background:Si[h].bg,color:Si[h].color,lineHeight:"18px"}},h))),e.createElement("div",{className:"semiotic-chart-body",ref:v,style:Object.assign({position:"relative",overflow:"hidden"},b?{flex:1}:{height:i})},M,g)))}),Pi={width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",border:"none",background:"transparent",cursor:"pointer",borderRadius:4,color:"var(--semiotic-text-secondary, #666)",padding:0};function Mi({children:t,columns:n="auto",minCellWidth:o=300,gap:r=16,className:i,style:a}){return e.createElement("div",{className:"semiotic-chart-grid"+(i?" "+i:""),style:Object.assign({display:"grid",gridTemplateColumns:"auto"===n?`repeat(auto-fill, minmax(${o}px, 1fr))`:`repeat(${n}, 1fr)`,gap:r,width:"100%"},a)},t)}function Ni({children:t,context:n,position:o="right",contextSize:r=250,gap:i=12,className:a,style:s}){const l="left"===o||"right"===o,c="left"===o||"top"===o,u=Object.assign({display:"flex",flexDirection:l?c?"row-reverse":"row":c?"column-reverse":"column",gap:i,width:"100%"},s),d=l?{flex:`0 0 ${r}px`,width:r,minHeight:0}:{flex:`0 0 ${r}px`,height:r,minWidth:0};return e.createElement("div",{className:"semiotic-context-layout"+(a?" "+a:""),style:u},e.createElement("div",{style:{flex:"1 1 0%",minWidth:0,minHeight:0}},t),e.createElement("div",{style:d},n))}Mi.displayName="ChartGrid",Ni.displayName="ContextLayout";function Di({children:r,position:i="right",size:s=300,trigger:l="click",chartId:c,observation:u,dismissOnEmpty:d=!0,showClose:h=!0,onToggle:g,className:p,style:y}){const[f,m]=n(null),[v,b]=n(null),[x,w]=n(!1),[k,A]=n(!1),E=t(null),S=t(),O="click"===l?["click","click-end"]:["hover","hover-end"],{latest:L}=tr({types:O,chartId:c,limit:1}),j=void 0!==u?u:L;o(()=>{if(j)if("click"===j.type||"hover"===j.type){const e=j;m(e.datum),b(e),x||(w(!0),A(!0),clearTimeout(S.current),S.current=setTimeout(()=>A(!1),200))}else!d||"click-end"!==j.type&&"hover-end"!==j.type||P()},[j]),o(()=>{null==g||g(x)},[x,g]);const P=a(()=>{A(!0),w(!1),clearTimeout(S.current),S.current=setTimeout(()=>{A(!1),m(null),b(null)},200)},[]);if(o(()=>()=>clearTimeout(S.current),[]),!f&&!k)return null;const M=f&&v?r(f,v):null;if(null===M&&!k)return null;const N=function(e,t,n,o){const r={position:"absolute",background:"var(--semiotic-bg, #fff)",borderColor:"var(--semiotic-border, #e0e0e0)",borderStyle:"solid",borderWidth:0,boxSizing:"border-box",zIndex:10,display:"flex",flexDirection:"column",transition:o?"transform 200ms ease-out, opacity 200ms ease-out":void 0};return Object.assign(Object.assign({},r),"right"===e?{top:0,right:0,width:t,height:"100%",borderLeftWidth:1,padding:"12px 16px",transform:n?"translateX(0)":`translateX(${t}px)`,opacity:n?1:0}:"bottom"===e?{bottom:0,left:0,width:"100%",height:t,borderTopWidth:1,padding:"12px 16px",transform:n?"translateY(0)":`translateY(${t}px)`,opacity:n?1:0}:{top:"50%",left:"50%",transform:n?"translate(-50%, -50%) scale(1)":"translate(-50%, -50%) scale(0.95)",opacity:n?1:0,width:Math.min(t,400),maxHeight:"80%",borderWidth:1,borderRadius:8,padding:"16px 20px",boxShadow:"0 8px 32px rgba(0,0,0,0.12)"})}(i,s,x,k);return e.createElement("div",{ref:E,className:`semiotic-details-panel semiotic-details-${i}${p?" "+p:""}`,style:Object.assign(Object.assign({},N),y)},h&&e.createElement("button",{className:"semiotic-details-close",onClick:P,"aria-label":"Close details",style:Ci},e.createElement("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"},e.createElement("path",{d:"M2 2l8 8M10 2l-8 8"}))),e.createElement("div",{className:"semiotic-details-content",style:{overflow:"auto",flex:1}},M))}const Ci={position:"absolute",top:8,right:8,width:20,height:20,display:"flex",alignItems:"center",justifyContent:"center",border:"none",background:"transparent",cursor:"pointer",borderRadius:4,color:"var(--semiotic-text-secondary, #666)",padding:0,zIndex:1};Di.displayName="DetailsPanel";export{Qo as AreaChart,pr as BarChart,mr as BoxPlot,er as BubbleChart,co as CategoryColorProvider,ji as ChartContainer,Wo as ChartErrorBoundary,Mi as ChartGrid,Mr as ChordDiagram,Tr as CirclePack,qo as ConnectedScatterplot,Ni as ContextLayout,Fr as DARK_THEME,Di as DetailsPanel,Ar as DonutChart,wr as DotPlot,Sr as ForceDirectedGraph,Er as GroupedBarChart,Jo as Heatmap,vr as Histogram,re as IncrementalExtent,Rr as LIGHT_THEME,Zo as LineChart,or as LinkedCharts,gr as MinimapChart,to as MultiLineTooltip,kr as PieChart,zr as RealtimeHeatmap,Hr as RealtimeHistogram,Br as RealtimeLineChart,$r as RealtimeSwarmChart,Wr as RealtimeTemporalHistogram,_r as RealtimeWaterfallChart,xr as RidgelinePlot,oe as RingBuffer,Nr as SankeyDiagram,Xo as Scatterplot,dr as ScatterplotMatrix,Ko as StackedAreaChart,yr as StackedBarChart,Zn as StreamNetworkFrame,vt as StreamOrdinalFrame,Ke as StreamXYFrame,fr as SwarmPlot,Vr as ThemeProvider,eo as Tooltip,Dr as TreeDiagram,Cr as Treemap,br as ViolinPlot,pi as configToJSX,gi as copyConfig,fi as deserializeSelections,Qr as exportChart,ui as fromConfig,hi as fromURL,ki as fromVegaLite,no as normalizeTooltip,yi as serializeSelections,Ir as smartTickFormat,ci as toConfig,di as toURL,Ao as useBrushSelection,uo as useCategoryColors,tr as useChartObserver,Eo as useFilteredData,ko as useLinkedHover,wo as useSelection,Ur as useTheme};