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.
- package/CLAUDE.md +1 -1
- package/README.md +2 -2
- package/dist/ordinal.min.js +1 -1
- package/dist/ordinal.module.min.js +1 -1
- package/dist/realtime.min.js +1 -1
- package/dist/realtime.module.min.js +1 -1
- package/dist/semiotic-ai.min.js +1 -1
- package/dist/semiotic-ai.module.min.js +1 -1
- package/dist/semiotic.min.js +1 -1
- package/dist/semiotic.module.min.js +1 -1
- package/dist/xy.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +6 -5
package/dist/xy.module.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"react";import{useRef as t,useState as n,useEffect as o,useMemo as i,forwardRef as s,useCallback as r,useImperativeHandle as l,useContext as a,createContext as c,useLayoutEffect as h,useId as u}from"react";import{brushX as d,brushY as f,brush as p}from"d3-brush";import{select as y}from"d3-selection";import{scaleLinear as g,scaleOrdinal as m,scaleSequential as v}from"d3-scale";import{bin as b}from"d3-array";import{packEnclose as x}from"d3-hierarchy";import{schemeCategory10 as w,interpolatePlasma as k,interpolateViridis as A,interpolatePurples as E,interpolateOranges as S,interpolateGreens as O,interpolateReds as M,interpolateBlues as N,schemeSet3 as j,schemeTableau10 as L}from"d3-scale-chromatic";const W=5e3;class _{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,W),bounded:!0,totalSize:e.length});let t=W;const n=()=>{if(t>=e.length)return;if(e!==this.lastBoundedData)return;const o=Math.min(t+W,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 ${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 C{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 B(e,t,n,o,i){const s=new Map;for(const r of e){const e=t(r),l=n(r);if(null==e||null==l||Number.isNaN(e)||Number.isNaN(l))continue;const a=Math.floor(e/o)*o;let c=s.get(a);if(c||(c={start:a,end:a+o,total:0,categories:new Map},s.set(a,c)),c.total+=l,i){const e=i(r);c.categories.set(e,(c.categories.get(e)||0)+l)}}return s}function H(e,t,n,o,i,s){const r=[],l=[];for(const i of e){const e=n(i),s=o(i);null==e||null==s||Number.isNaN(e)||Number.isNaN(s)||(r.push([t.x(e),t.y(s)]),l.push(s))}return{type:"line",path:r,rawValues:l,style:i,datum:e,group:s}}function z(e,t,n,o,i,s,r,l){const a=[],c=[];for(const s of e){const e=n(s),r=o(s);if(null==e||null==r||Number.isNaN(e)||Number.isNaN(r))continue;const h=t.x(e);a.push([h,t.y(r)]);const u=l?l(s):i;c.push([h,t.y(u)])}return{type:"area",topPath:a,bottomPath:c,style:s,datum:e,group:r}}function T(e,t,n,o,i,s,r){const l=n(e),a=o(e);if(null==l||null==a||Number.isNaN(l)||Number.isNaN(a))return null;const c={type:"point",x:t.x(l),y:t.y(a),r:i,style:s,datum:e};return void 0!==r&&(c.pointId=r),c}function F(e,t,n,o,i,s,r){return{type:"rect",x:e,y:t,w:n,h:o,style:i,datum:s,group:r}}function P(e,t,n,o,i,s){return{type:"heatcell",x:e,y:t,w:n,h:o,fill:i,datum:s}}function I(e,t){if("function"==typeof e)return t=>+e(t);const n=e||t;return e=>+e[n]}function D(e,t){return"function"==typeof e?e:e?t=>t[e]+"":void 0}class G{constructor(e){this.xExtent=new C,this.yExtent=new C,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 $(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=I(e.timeAccessor||e.xAccessor,"time"),this.getY=I(e.valueAccessor||e.yAccessor,"value")):(this.getX=I(e.xAccessor,"x"),this.getY=I(e.yAccessor,"y")),this.getGroup=D(e.groupAccessor),this.getCategory=D(e.categoryAccessor),this.getSize=e.sizeAccessor?I(e.sizeAccessor,"size"):void 0,this.getColor=D(e.colorAccessor),this.getBounds=e.boundsAccessor?I(e.boundsAccessor,"bounds"):void 0,this.getY0=e.y0Accessor?I(e.y0Accessor,"y0"):void 0,this.getPointId=D(e.pointIdAccessor),"candlestick"===e.chartType&&(this.getOpen=I(e.openAccessor,"open"),this.getHigh=I(e.highAccessor,"high"),this.getLow=I(e.lowAccessor,"low"),this.getClose=I(e.closeAccessor,"close")),e.pulse&&(this.timestampBuffer=new $(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,i,s,r;const{config:l,buffer:a}=this;if(this.xExtent.dirty&&this.xExtent.recalculate(a,this.getX),this.yExtent.dirty)if("candlestick"===l.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const e of a)this.yExtent.push(this.getHigh(e)),this.yExtent.push(this.getLow(e))}else this.yExtent.recalculate(a,this.getY);const c=this.xExtent.extent,h=this.yExtent.extent;let u=l.xExtent?[null!==(t=l.xExtent[0])&&void 0!==t?t:c[0],null!==(n=l.xExtent[1])&&void 0!==n?n:c[1]]:c,d=l.yExtent?[null!==(o=l.yExtent[0])&&void 0!==o?o:h[0],null!==(i=l.yExtent[1])&&void 0!==i?i:h[1]]:h;const f=l.yExtent&&null!=l.yExtent[0]&&null!=l.yExtent[1];if("stackedarea"===l.chartType&&!f&&a.size>0)if(l.normalize)d=[0,1+l.extentPadding];else{const e=a.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);d=[0,o+(o>0?o*l.extentPadding:1)]}else if("bar"===l.chartType&&l.binSize&&!f&&a.size>0){const[,e]=function(e,t,n,o,i){const s=B(e,t,n,o,i);if(0===s.size)return[0,0];let r=0;for(const e of s.values())e.total>r&&(r=e.total);return[0,r]}(a,this.getX,this.getY,l.binSize,this.getCategory);d=[0,e+e*l.extentPadding]}else if("waterfall"===l.chartType&&!f&&a.size>0){const[e,t]=function(e,t){let n=0,o=0,i=0;for(const s of e){const e=t(s);null==e||Number.isNaN(e)||(i+=e,n>i&&(n=i),i>o&&(o=i))}return[n,o]}(a,this.getY),n=t-e,o=n>0?n*l.extentPadding:1;d=[Math.min(0,e-Math.abs(o)),Math.max(0,t+Math.abs(o))]}else if(!f&&d[0]!==1/0){if(this.getBounds){const e=a.toArray();for(const t of e){const e=this.getY(t),n=this.getBounds(t);null!=e&&!Number.isNaN(e)&&n&&(e+n>d[1]&&(d[1]=e+n),d[0]>e-n&&(d[0]=e-n))}}const e=d[1]-d[0],t=e>0?e*l.extentPadding:1,n=null===(s=l.yExtent)||void 0===s?void 0:s[0],o=null===(r=l.yExtent)||void 0===r?void 0:r[1];d=[null!=n?d[0]:d[0]-t,null!=o?d[1]:d[1]+t]}if(u[0]!==1/0&&u[1]!==-1/0||(u=[0,1]),d[0]!==1/0&&d[1]!==-1/0||(d=[0,1]),void 0!==l.arrowOfTime)if("x"==("up"===(p=l.arrowOfTime)||"down"===p?"y":"x")){const t="right"===l.arrowOfTime?[0,e.width]:[e.width,0];this.scales={x:g().domain(u).range(t),y:g().domain(d).range([e.height,0])}}else{const t="down"===l.arrowOfTime?[0,e.height]:[e.height,0];this.scales={x:g().domain(d).range([0,e.width]),y:g().domain(u).range(t)}}else this.scales={x:g().domain(u).range([0,e.width]),y:g().domain(d).range([e.height,0])};var p;this.config.transition&&this.scene.length>0&&this.snapshotPositions();const y=a.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 i=n.toArray();switch(t.chartType){case"line":return this.buildLineScene(i);case"area":return this.buildAreaScene(i);case"stackedarea":return this.buildStackedAreaScene(i);case"scatter":case"bubble":return this.buildPointScene(i);case"heatmap":return this.buildHeatmapScene(i,e);case"bar":return this.buildBarScene(i);case"swarm":return this.buildSwarmScene(i);case"waterfall":return this.buildWaterfallScene(i,e);case"candlestick":return this.buildCandlestickScene(i,e);default:return[]}}buildLineScene(e){var t;const n=this.groupData(e),o=[],i=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=H(e.data,this.scales,this.getX,this.getY,t,e.key);i&&i.length>0&&(n.colorThresholds=i),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]),i=z(e.data,this.scales,this.getX,this.getY,o,t,e.key,this.getY0);this.config.gradientFill&&(i.fillGradient=this.config.gradientFill),n.push(i)}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,i,s){var r;const l=new Set;for(const t of e)for(const e of t.data){const t=n(e);null==t||Number.isNaN(t)||l.add(t)}const a=Array.from(l).sort((e,t)=>e-t),c=new Map;for(const t of e){const e=new Map;for(const i of t.data){const t=n(i),s=o(i);null==t||null==s||Number.isNaN(t)||Number.isNaN(s)||e.set(t,(e.get(t)||0)+s)}c.set(t.key,e)}let h;if(s){h=new Map;for(const t of a){let n=0;for(const o of e)n+=(null===(r=c.get(o.key))||void 0===r?void 0:r.get(t))||0;h.set(t,n||1)}}const u=[],d=new Map;for(const e of a)d.set(e,0);for(const n of e){const e=c.get(n.key),o=[],r=[];for(const n of a){let i=e.get(n)||0;const l=d.get(n);s&&(i/=h.get(n));const a=t.x(n);r.push([a,t.y(l)]),o.push([a,t.y(l+i)]),d.set(n,l+i)}u.push({type:"area",topPath:o,bottomPath:r,style:i(n.key,n.data[0]),datum:n.data,group:n.key})}return u}(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 i=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);i=t=>e===n?(o[0]+o[1])/2:o[0]+(t-e)/(n-e)*(o[1]-o[0])}}let s=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"];s=new Map;let o=0;for(const e of t)s.set(e,n[o%n.length]),o++}for(const o of e){let e=this.config.pointStyle?this.config.pointStyle(o):{fill:"#4e79a7",opacity:.8},r=e.r||n;if(i&&this.getSize){const e=this.getSize(o);null==e||Number.isNaN(e)||(r=i(e))}if(s&&this.getColor){const t=this.getColor(o);t&&s.has(t)&&(e=Object.assign(Object.assign({},e),{fill:s.get(t)}))}const l=this.getPointId?this.getPointId(o)+"":void 0,a=T(o,this.scales,this.getX,this.getY,r,e,l);a&&t.push(a)}return t}buildHeatmapScene(e,t){const n=[];if(this.config.heatmapAggregation)return this.buildStreamingHeatmapScene(e,t);const o=I(this.config.valueAccessor,"value"),i=new Set,s=new Set;for(const t of e)i.add(this.getX(t)),s.add(this.getY(t));const r=Array.from(i).sort((e,t)=>e-t),l=Array.from(s).sort((e,t)=>e-t);if(0===r.length||0===l.length)return n;const a=t.width/r.length,c=t.height/l.length,h=new Map;for(const t of e){const e=`${this.getX(t)}_${this.getY(t)}`;h.set(e,{val:o(t),datum:t})}let u=1/0,d=-1/0;for(const{val:e}of h.values())u>e&&(u=e),e>d&&(d=e);const f=d-u||1;for(let e=0;r.length>e;e++)for(let t=0;l.length>t;t++){const o=h.get(`${r[e]}_${l[t]}`);if(!o)continue;const i=(o.val-u)/f;n.push(P(e*a,(l.length-1-t)*c,a,c,`rgb(${Math.round(220-180*i)},${Math.round(220-100*i)},${Math.round(255-50*i)})`,o.datum))}return n}buildStreamingHeatmapScene(e,t){var n,o,i;const s=[],r=null!==(n=this.config.heatmapXBins)&&void 0!==n?n:20,l=null!==(o=this.config.heatmapYBins)&&void 0!==o?o:20,a=null!==(i=this.config.heatmapAggregation)&&void 0!==i?i:"count",c=I(this.config.valueAccessor,"value");if(!this.scales||0===e.length)return s;const[h,u]=this.scales.x.domain(),[d,f]=this.scales.y.domain(),p=(u-h||1)/r,y=(f-d||1)/l,g=new Map;for(const t of e){const e=this.getX(t),n=this.getY(t),o=Math.min(Math.floor((e-h)/p),r-1),i=Math.min(Math.floor((n-d)/y),l-1);if(0>o||0>i)continue;const s=`${o}_${i}`;let a=g.get(s);a||(a={sum:0,count:0,data:[]},g.set(s,a)),a.count++,a.sum+=c(t),a.data.push(t)}let m=1/0,v=-1/0;const b=new Map;for(const[e,t]of g){let n;switch(a){case"sum":n=t.sum;break;case"mean":n=t.count>0?t.sum/t.count:0;break;default:n=t.count}b.set(e,n),m>n&&(m=n),n>v&&(v=n)}const x=v-m||1,w=t.width/r,k=t.height/l;for(const[e,t]of b){const[n,o]=e.split("_"),i=+n,r=+o,a=(t-m)/x,c=`rgb(${Math.round(220-180*a)},${Math.round(220-100*a)},${Math.round(255-50*a)})`,h=g.get(e);s.push(P(i*w,(l-1-r)*k,w,k,c,{xi:i,yi:r,value:t,count:h.count,sum:h.sum,data:h.data}))}return s}buildBarScene(e){var t;if(!this.config.binSize)return[];const n=B(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):[],i=new Set(t),s=Array.from(e).filter(e=>!i.has(e)).sort();o=[...t.filter(t=>e.has(t)),...s]}const i=[],s=this.scales,[r,l]=s.x.domain();for(const e of n.values()){const n=Math.max(e.start,r),a=Math.min(e.end,l);if(n>=a)continue;const c=s.x(n),h=s.x(a),u=Math.min(c,h)+.5,d=Math.max(c,h)-.5-u;if(d>0)if(o&&e.categories.size>0){let n=0;for(const r of o){const o=e.categories.get(r)||0;if(0===o)continue;const l=s.y(n),a=s.y(n+o);i.push(F(u,Math.min(l,a),d,Math.abs(l-a),{fill:(null===(t=this.config.barColors)||void 0===t?void 0:t[r])||"#4e79a7"},{binStart:e.start,binEnd:e.end,total:e.total,category:r,categoryValue:o},r)),n+=o}}else{const t=s.y(0),n=s.y(e.total);i.push(F(u,Math.min(t,n),d,Math.abs(t-n),{fill:"#007bff"},{binStart:e.start,binEnd:e.end,total:e.total}))}}return i}buildSwarmScene(e){var t,n,o,i;const s=[],r=this.config.swarmStyle||{},l=null!==(t=r.radius)&&void 0!==t?t:3,a=null!==(n=r.fill)&&void 0!==n?n:"#007bff",c=null!==(o=r.opacity)&&void 0!==o?o:.7,h=r.stroke,u=r.strokeWidth;for(const t of e){const e=this.getX(t),n=this.getY(t);if(null==n||Number.isNaN(n))continue;const o=this.scales.x(e),r=this.scales.y(n);let d=a;if(this.getCategory){const e=this.getCategory(t);d=(null===(i=this.config.barColors)||void 0===i?void 0:i[e])||d}const f={type:"point",x:o,y:r,r:l,style:{fill:d,opacity:c,stroke:h,strokeWidth:u},datum:t};this.getPointId&&(f.pointId=this.getPointId(t)+""),s.push(f)}return s}buildWaterfallScene(e,t){var n,o,i;const s=[],r=this.scales,l=this.config.waterfallStyle,a=e.filter(e=>{const t=this.getY(e);return null!=t&&!Number.isNaN(t)});if(0===a.length)return s;const c=null!==(n=null==l?void 0:l.positiveColor)&&void 0!==n?n:"#28a745",h=null!==(o=null==l?void 0:l.negativeColor)&&void 0!==o?o:"#dc3545",u=null!==(i=null==l?void 0:l.gap)&&void 0!==i?i:1,d=null==l?void 0:l.stroke,f=null==l?void 0:l.strokeWidth;let p=0;for(let e=0;a.length>e;e++){const n=a[e],o=this.getX(n),i=this.getY(n),y=p+i;let g;g=a.length-1>e?this.getX(a[e+1])-o:e>0?o-this.getX(a[e-1]):0;const m=r.x(o),v=0!==g?r.x(o+g):m+t.width/10,b=Math.min(m,v)+u/2,x=Math.max(m,v)-u/2-b;if(0>=x){p=y;continue}const w=r.y(p),k=r.y(y);s.push(F(b,Math.min(w,k),x,Math.abs(w-k),{fill:0>i?h:c,stroke:d,strokeWidth:f},Object.assign(Object.assign({},n),{baseline:p,cumEnd:y,delta:i,_connectorStroke:null==l?void 0:l.connectorStroke,_connectorWidth:null==l?void 0:l.connectorWidth}))),p=y}return s}buildCandlestickScene(e,t){if(!(this.getOpen&&this.getHigh&&this.getLow&&this.getClose&&this.scales))return[];const n=[],o=this.config.candlestickStyle||{},i=o.upColor||"#28a745",s=o.downColor||"#dc3545",r=o.wickColor||"#333",l=o.wickWidth||1,a=e.map(e=>this.getX(e)).filter(e=>null!=e&&!Number.isNaN(e)).sort((e,t)=>e-t);let c=o.bodyWidth||6;if(!o.bodyWidth&&a.length>1){let e=1/0;for(let t=1;a.length>t;t++){const n=Math.abs(this.scales.x(a[t])-this.scales.x(a[t-1]));n>0&&e>n&&(e=n)}e!==1/0&&(c=Math.max(2,Math.min(.6*e,20)))}for(const t of e){const e=this.getX(t);if(null==e||Number.isNaN(e))continue;const o=this.getOpen(t),a=this.getHigh(t),h=this.getLow(t),u=this.getClose(t);if([o,a,h,u].some(e=>null==e||Number.isNaN(e)))continue;const d=u>=o;n.push({type:"candlestick",x:this.scales.x(e),openY:this.scales.y(o),closeY:this.scales.y(u),highY:this.scales.y(a),lowY:this.scales.y(h),bodyWidth:c,upColor:i,downColor:s,wickColor:r,wickWidth:l,isUp:d,datum:t})}return n}buildBoundsForGroup(e,t){if(!this.getBounds||!this.scales)return null;const n=[],o=[];for(const t of e){const e=this.getX(t),i=this.getY(t);if(null==e||null==i||Number.isNaN(e)||Number.isNaN(i))continue;const s=this.getBounds(t),r=this.scales.x(e);if(s&&0!==s)n.push([r,this.scales.y(i+s)]),o.push([r,this.scales.y(i-s)]);else{const e=this.scales.y(i);n.push([r,e]),o.push([r,e])}}return 2>n.length?null:{type:"area",topPath:n,bottomPath:o,style:this.resolveBoundsStyle(t,e[0]),datum:e,group:t,interactive:!1}}resolveBoundsStyle(e,t){const n=this.config.boundsStyle;return"function"==typeof n?n(t||{},e):n&&"object"==typeof n?n:{fill:this.resolveLineStyle(e,t).stroke||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(e,t){var n,o,i;const s=this.config.decay;if(!s||1>=t)return 1;const r=null!==(n=s.minOpacity)&&void 0!==n?n:.1,l=t-1-e;switch(s.type){case"linear":return r+(1-l/(t-1))*(1-r);case"exponential":{const e=null!==(o=s.halfLife)&&void 0!==o?o:t/2;return r+Math.pow(.5,l/e)*(1-r)}case"step":return(null!==(i=s.stepThreshold)&&void 0!==i?i:.5*t)>l?1:r;default:return 1}}applyDecay(e,t){var n,o;if(!this.config.decay)return;const i=t.length;if(1>=i)return;const 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 r=this.computeDecayOpacity(e,i);if("heatcell"===t.type)t.style={opacity:r};else if("candlestick"===t.type)t._decayOpacity=r;else{const e=null!==(o=null===(n=t.style)||void 0===n?void 0:n.opacity)&&void 0!==o?o:1;t.style=Object.assign(Object.assign({},t.style),{opacity:e*r})}}}computePulseIntensity(e,t){var n;const o=this.config.pulse;if(!o)return 0;const i=null!==(n=o.duration)&&void 0!==n?n:500,s=t-e;return i>s?1-s/i:0}applyPulse(e,t){var n,o;if(!this.config.pulse||!this.timestampBuffer)return;const i="undefined"!=typeof performance?performance.now():Date.now(),s=null!==(n=this.config.pulse.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",r=null!==(o=this.config.pulse.glowRadius)&&void 0!==o?o:4,l=new Map;for(let e=0;t.length>e;e++)l.set(t[e],e);for(const t of e){if("line"===t.type||"area"===t.type)continue;const e=l.get(t.datum);if(null==e)continue;const n=this.timestampBuffer.get(e);if(null==n)continue;const o=this.computePulseIntensity(n,i);o>0&&(t._pulseIntensity=o,t._pulseColor=s,t._pulseGlowRadius=r)}}get hasActivePulses(){var e;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const t="undefined"!=typeof performance?performance.now():Date.now(),n=null!==(e=this.config.pulse.duration)&&void 0!==e?e:500,o=this.timestampBuffer.peek();return null!=o&&n>t-o}snapshotPositions(){this.prevPositionMap.clear();for(let e=0;this.scene.length>e;e++){const t=this.scene[e],n=this.getNodeIdentity(t,e);n&&("point"===t.type?this.prevPositionMap.set(n,{x:t.x,y:t.y,r:t.r}):"rect"===t.type||"heatcell"===t.type?this.prevPositionMap.set(n,{x:t.x,y:t.y,w:t.w,h:t.h}):"candlestick"===t.type&&this.prevPositionMap.set(n,{x:t.x,y:t.openY}))}}getNodeIdentity(e,t){var n,o,i,s;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!==(s=null!==(o=null===(n=e.datum)||void 0===n?void 0:n.binStart)&&void 0!==o?o:null===(i=e.datum)||void 0===i?void 0:i.category)&&void 0!==s?s: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,i,s;if(!this.config.transition||0===this.prevPositionMap.size)return;const r=null!==(e=this.config.transition.duration)&&void 0!==e?e:300;let l=!1;for(let e=0;this.scene.length>e;e++){const r=this.scene[e],a=this.getNodeIdentity(r,e);if(!a)continue;const c=this.prevPositionMap.get(a);if(c)if("point"===r.type){const e={x:r.x,y:r.y,r:r.r};c.x===e.x&&c.y===e.y||(r._targetX=e.x,r._targetY=e.y,r._targetR=e.r,r.x=c.x,r.y=c.y,r.r=null!==(t=c.r)&&void 0!==t?t:r.r,l=!0)}else if("rect"===r.type){const e={x:r.x,y:r.y,w:r.w,h:r.h};c.x===e.x&&c.y===e.y&&c.w===e.w&&c.h===e.h||(r._targetX=e.x,r._targetY=e.y,r._targetW=e.w,r._targetH=e.h,r.x=c.x,r.y=c.y,r.w=null!==(n=c.w)&&void 0!==n?n:r.w,r.h=null!==(o=c.h)&&void 0!==o?o:r.h,l=!0)}else if("heatcell"===r.type){const e={x:r.x,y:r.y,w:r.w,h:r.h};c.x===e.x&&c.y===e.y||(r._targetX=e.x,r._targetY=e.y,r._targetW=e.w,r._targetH=e.h,r.x=c.x,r.y=c.y,r.w=null!==(i=c.w)&&void 0!==i?i:r.w,r.h=null!==(s=c.h)&&void 0!==s?s:r.h,l=!0)}}l&&(this.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:r})}advanceTransition(e){var t;if(!this.activeTransition)return!1;const n=Math.min((e-this.activeTransition.startTime)/this.activeTransition.duration,1),o="linear"===(null===(t=this.config.transition)||void 0===t?void 0:t.easing)?n:1-Math.pow(1-n,3);for(const e of this.scene)if("point"===e.type){if(void 0===e._targetX)continue;const t=this.getNodeIdentity(e,0);if(!t)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=n.x+(e._targetX-n.x)*o,e.y=n.y+(e._targetY-n.y)*o,void 0!==e._targetR&&void 0!==n.r&&(e.r=n.r+(e._targetR-n.r)*o)}else if("rect"===e.type){if(void 0===e._targetX)continue;const t=this.getNodeIdentity(e,0);if(!t)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=n.x+(e._targetX-n.x)*o,e.y=n.y+(e._targetY-n.y)*o,void 0!==n.w&&(e.w=n.w+(e._targetW-n.w)*o),void 0!==n.h&&(e.h=n.h+(e._targetH-n.h)*o)}else if("heatcell"===e.type){if(void 0===e._targetX)continue;const t=this.getNodeIdentity(e,0);if(!t)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=n.x+(e._targetX-n.x)*o,e.y=n.y+(e._targetY-n.y)*o,void 0!==n.w&&(e.w=n.w+(e._targetW-n.w)*o),void 0!==n.h&&(e.h=n.h+(e._targetH-n.h)*o)}if(n>=1){for(const e of this.scene)if("point"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,void 0!==e._targetR&&(e.r=e._targetR),e._targetX=void 0,e._targetY=void 0,e._targetR=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("heatcell"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}return this.activeTransition=null,!1}return!0}groupData(e){if(!this.getGroup)return[{key:"_default",data:e}];const t=new Map;for(const n of e){const e=this.getGroup(n);t.has(e)||t.set(e,[]),t.get(e).push(n)}return Array.from(t.entries()).map(([e,t])=>({key:e,data:t}))}resolveLineStyle(e,t){const n=this.config.lineStyle;return"function"==typeof n?n(t||{},e):n&&"object"==typeof n?{stroke:n.stroke||"#007bff",strokeWidth:n.strokeWidth||2,strokeDasharray:n.strokeDasharray,fill:n.fill,fillOpacity:n.fillOpacity,opacity:n.opacity}:{stroke:"#007bff",strokeWidth:2}}resolveAreaStyle(e,t){var n;if(this.config.areaStyle)return this.config.areaStyle(t||{});const o=this.config.lineStyle;return"function"==typeof o?o(t||{},e):o&&"object"==typeof o?{fill:o.fill||o.stroke||"#4e79a7",fillOpacity:null!==(n=o.fillOpacity)&&void 0!==n?n:.7,stroke:o.stroke||"#4e79a7",strokeWidth:o.strokeWidth||2}:{fill:"#4e79a7",fillOpacity:.7,stroke:"#4e79a7",strokeWidth:2}}getData(){return this.buffer.toArray()}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],this.version++}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}updateConfig(e){Object.assign(this.config,e)}}function R(e,t,n){const o=t-e.x,i=n-e.y,s=Math.sqrt(o*o+i*i);return s>e.r+5?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:s}}function Y(e,t,n){if(0===e.path.length)return null;const o=Z(e.path,t);if(0>o)return null;const[i,s]=e.path[o],r=t-i,l=n-s,a=Math.sqrt(r*r+l*l);return{node:e,datum:Array.isArray(e.datum)&&e.datum[o]?e.datum[o]:e.datum,x:i,y:s,distance:a}}function X(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 q(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 V(e,t,n){const o=e.bodyWidth/2,i=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=i+Math.max(Math.max(e.openY,e.closeY)-i,1)/2,s=t-e.x,r=n-o;return{node:e,datum:e.datum,x:e.x,y:o,distance:Math.sqrt(s*s+r*r)}}return null}function U(e,t,n){if(0===e.topPath.length)return null;const o=Z(e.topPath,t);if(0>o)return null;const[i,s]=e.topPath[o],r=t-i,l=n-s;return{node:e,datum:e.datum,x:i,y:s,distance:Math.sqrt(r*r+l*l)}}function Z(e,t){if(0===e.length)return-1;let n=0,o=e.length-1;for(;o>n;){const i=n+o>>1;t>e[i][0]?n=i+1:o=i}return n>0&&Math.abs(e[n][0]-t)>=Math.abs(e[n-1][0]-t)?n-1:n}const J={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 K(e,t,n,o){let i;return i="function"==typeof n?n(e):(0,J[n])(o(e,t)),i}function Q(t){const{legendGroups:n,customClickBehavior:o,title:i="Legend",width:s=100,height:r=20,orientation:l="vertical"}=t,a="vertical"===l?(({legendGroups:t,width:n,customClickBehavior:o})=>{let i=30;const s=[];return t.forEach((t,r)=>{i+=5,s.push(e.createElement("line",{key:"legend-top-line legend-symbol-"+r,stroke:"gray",x1:0,y1:i,x2:n,y2:i})),i+=10,t.label&&(i+=20,s.push(e.createElement("text",{key:"legend-text-"+r,y:i,className:"legend-group-label"},t.label)),i+=10),s.push(e.createElement("g",{key:"legend-group-"+r,className:"legend-item",transform:`translate(0,${i})`},((t,n)=>{const{type:o="fill",styleFn:i,items:s}=t,r=[];let l=0;return s.forEach((t,s)=>{const a=K(t,s,o,i);r.push(e.createElement("g",{key:"legend-item-"+s,transform:`translate(0,${l})`,onClick:n?()=>n(t):void 0,style:{cursor:n?"pointer":"default"}},a,e.createElement("text",{y:15,x:30},t.label))),l+=25}),r})(t,o))),i+=25*t.items.length+10}),s})({legendGroups:n,width:s,customClickBehavior:o}):(({legendGroups:t,title:n,height:o,customClickBehavior:i})=>{let s=0;const r=[],l=!1===n?10:40;return t.forEach((n,a)=>{n.label&&(r.push(e.createElement("text",{key:"legend-text-"+a,transform:`translate(${s},${l}) rotate(90)`,textAnchor:"start",className:"legend-group-label"},n.label)),s+=20);const c=((t,n)=>{const{type:o="fill",styleFn:i,items:s}=t,r=[];let l=0;return s.forEach((t,s)=>{const a=K(t,s,o,i);r.push(e.createElement("g",{key:"legend-item-"+s,transform:`translate(${l},0)`,onClick:n?()=>n(t):void 0,style:{cursor:n?"pointer":"default"}},a,e.createElement("text",{y:15,x:25},t.label))),l+=35,l+=8*t.label.length}),{items:r,offset:l}})(n,i);r.push(e.createElement("g",{key:"legend-group-"+a,className:"legend-item",transform:`translate(${s},${l})`},c.items)),s+=c.offset+5,t[a+1]&&r.push(e.createElement("line",{key:"legend-top-line legend-symbol-"+a,stroke:"gray",x1:s,y1:l-10,x2:s,y2:o+l+10})),s+=15}),e.createElement("g",null,!1!==n&&e.createElement("line",{x1:0,x2:s+10,y1:l-10,y2:l-10,stroke:"gray",className:"title-neatline"}),r)})({legendGroups:n,title:i,height:r,customClickBehavior:o});return e.createElement("g",null,void 0!==i&&e.createElement("text",{className:"legend-title",y:20,x:"horizontal"===l?0:s/2,textAnchor:"horizontal"===l?"start":"middle"},i),a)}function ee(e){return"string"==typeof e?{type:e}:e}function te({orient:t,config:n,values:o,scale:s,size:r,length:l}){const a=function(e){var t,n,o,i,s;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!==(i=e.stroke)&&void 0!==i?i:"none",strokeWidth:null!==(s=e.strokeWidth)&&void 0!==s?s:1}}(n),c="top"===t||"bottom"===t,h=i(()=>{if(0===o.length)return null;const n=s.domain(),i=r-8;if("boxplot"===a.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)],i=t[Math.floor(.5*n)],s=t[Math.floor(.75*n)],r=s-o;return{q1:o,median:i,q3:s,whiskerLow:Math.max(t[0],o-1.5*r),whiskerHigh:Math.min(t[n-1],s+1.5*r)}}(o);if(!n)return null;const{q1:r,median:l,q3:h,whiskerLow:u,whiskerHigh:d}=n,f=Math.min(.5*i,20),p=(i-f)/2+4;if(c){const n=s(r),o=s(h),i=s(l),c=s(u),y=s(d),g="top"===t?-1:1,m=0;return e.createElement("g",{"data-testid":"marginal-boxplot-"+t},e.createElement("line",{x1:c,y1:m+g*(p+f/2),x2:y,y2:m+g*(p+f/2),stroke:a.fill,strokeWidth:a.strokeWidth}),e.createElement("line",{x1:c,y1:m+g*p,x2:c,y2:m+g*(p+f),stroke:a.fill,strokeWidth:a.strokeWidth}),e.createElement("line",{x1:y,y1:m+g*p,x2:y,y2:m+g*(p+f),stroke:a.fill,strokeWidth:a.strokeWidth}),e.createElement("rect",{x:Math.min(n,o),y:"top"===t?m-p-f:m+p,width:Math.abs(o-n),height:f,fill:a.fill,fillOpacity:a.fillOpacity,stroke:"none"===a.stroke?a.fill:a.stroke,strokeWidth:a.strokeWidth}),e.createElement("line",{x1:i,y1:"top"===t?m-p-f:m+p,x2:i,y2:"top"===t?m-p:m+p+f,stroke:a.fill,strokeWidth:2}))}{const n=s(r),o=s(h),i=s(l),c=s(u),y=s(d),g="left"===t?-1:1,m=0;return e.createElement("g",{"data-testid":"marginal-boxplot-"+t},e.createElement("line",{x1:m+g*(p+f/2),y1:c,x2:m+g*(p+f/2),y2:y,stroke:a.fill,strokeWidth:a.strokeWidth}),e.createElement("line",{x1:m+g*p,y1:c,x2:m+g*(p+f),y2:c,stroke:a.fill,strokeWidth:a.strokeWidth}),e.createElement("line",{x1:m+g*p,y1:y,x2:m+g*(p+f),y2:y,stroke:a.fill,strokeWidth:a.strokeWidth}),e.createElement("rect",{x:"left"===t?m-p-f:m+p,y:Math.min(n,o),width:f,height:Math.abs(o-n),fill:a.fill,fillOpacity:a.fillOpacity,stroke:"none"===a.stroke?a.fill:a.stroke,strokeWidth:a.strokeWidth}),e.createElement("line",{x1:"left"===t?m-p-f:m+p,y1:i,x2:"left"===t?m-p:m+p+f,y2:i,stroke:a.fill,strokeWidth:2}))}}const h=b().domain(n).thresholds(a.bins)(o);if(0===h.length)return null;const u=Math.max(...h.map(e=>e.length));if(0===u)return null;if("histogram"===a.type)return e.createElement("g",{"data-testid":"marginal-histogram-"+t},h.map((n,o)=>{if(null==n.x0||null==n.x1)return null;const r=n.length/u*i;if(c){const i=s(n.x0),l=s(n.x1)-s(n.x0);return e.createElement("rect",{key:o,x:i,y:"top"===t?-4-r:4,width:Math.max(l,.5),height:r,fill:a.fill,fillOpacity:a.fillOpacity,stroke:a.stroke,strokeWidth:a.strokeWidth})}{const i=s(n.x0),l=s(n.x1)-s(n.x0);return e.createElement("rect",{key:o,x:"left"===t?-4-r:4,y:Math.min(i,i+l),width:r,height:Math.abs(l),fill:a.fill,fillOpacity:a.fillOpacity,stroke:a.stroke,strokeWidth:a.strokeWidth})}}));if("violin"===a.type){const n=i/2+4,o=[];for(const e of h){if(null==e.x0||null==e.x1)continue;const r=e.length/u*(i/2),l=s((e.x0+e.x1)/2);o.push(c?`${l},${"top"===t?-(n-r):n-r}`:`${"left"===t?-(n-r):n-r},${l}`)}for(let e=h.length-1;e>=0;e--){const r=h[e];if(null==r.x0||null==r.x1)continue;const l=r.length/u*(i/2),a=s((r.x0+r.x1)/2);o.push(c?`${a},${"top"===t?-(n+l):n+l}`:`${"left"===t?-(n+l):n+l},${a}`)}return e.createElement("g",{"data-testid":"marginal-violin-"+t},e.createElement("polygon",{points:o.join(" "),fill:a.fill,fillOpacity:a.fillOpacity,stroke:"none"===a.stroke?a.fill:a.stroke,strokeWidth:a.strokeWidth}))}if("ridgeline"===a.type){const n=[];if(c){const e=0,o=null!=h[0].x0?s(h[0].x0):0;n.push(`M${o},${e}`);for(const e of h){if(null==e.x0||null==e.x1)continue;const o=e.length/u*i,r=s((e.x0+e.x1)/2);n.push(`L${r},${"top"===t?-o-4:o+4}`)}const r=null!=h[h.length-1].x1?s(h[h.length-1].x1):l;n.push(`L${r},${e}`),n.push("Z")}else{const e=0,o=null!=h[0].x0?s(h[0].x0):0;n.push(`M${e},${o}`);for(const e of h){if(null==e.x0||null==e.x1)continue;const o=e.length/u*i,r=s((e.x0+e.x1)/2);n.push(`L${"left"===t?-o-4:o+4},${r}`)}const r=null!=h[h.length-1].x1?s(h[h.length-1].x1):l;n.push(`L${e},${r}`),n.push("Z")}return e.createElement("g",{"data-testid":"marginal-ridgeline-"+t},e.createElement("path",{d:n.join(" "),fill:a.fill,fillOpacity:a.fillOpacity,stroke:"none"===a.stroke?a.fill:a.stroke,strokeWidth:a.strokeWidth}))}return null},[o,s,a,r,l,t,c,4]);return h?e.createElement("g",{className:"marginal-"+t,"data-testid":"marginal-"+t},h):null}function ne(e,t=120,n=8){if(!e)return[];const o=Math.max(1,Math.floor(t/n)),i=e.split(/\s+/),s=[];let r="";for(const e of i)r&&r.length+1+e.length>o?(s.push(r),r=e):r=r?`${r} ${e}`:e;return r&&s.push(r),s}function oe(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 ie(t){const{x:n=0,y:o=0,dx:i,dy:s,nx:r,ny:l,note:a,connector:c,subject:h,type:u,color:d,className:f,disable:p,events:y={},"data-testid":g}=t,m=new Set(Array.isArray(p)?p:[]);let v=i||0,b=s||0;null!=r&&(v=r-n),null!=l&&(b=l-o);const x="string"==typeof u?u:"label";if("bracket"===x&&h&&0===v&&0===b)if(void 0!==h.width){v=h.width/2;const e=h.depth||30;b=e+(0>e?-5:5)}else if(void 0!==h.height){const e=h.depth||30;v=e+(0>e?-5:5),b=h.height/2}return e.createElement("g",Object.assign({className:("annotation "+(f||"")).trim(),transform:`translate(${n},${o})`,"data-testid":g},y),!m.has("connector")&&function(t,n,o,i,s,r){const l=[];let a=0,c=0;if("callout-circle"!==s&&"label"!==s||!(null==r?void 0:r.radius)){if("callout-rect"===s&&r){const e=r.width||0,o=r.height||0;if(e>0||o>0){const i=e/2,s=o/2,r=t-i,l=n-s;if(0!==r||0!==l){const t=Math.abs(r),n=Math.abs(l),h=e/2,u=o/2,d=t*u>n*h?h/t:u/n;a=i+r*d,c=s+l*d}}}else if("bracket"===s&&r){const e=r.width,t=r.height,n=r.depth||30;void 0!==e?(a=e/2,c=n):void 0!==t&&(a=n,c=t/2)}}else{const e=(r.radius||0)+(r.radiusPadding||0);if(e>0&&(0!==t||0!==n)){const o=Math.atan2(n,t);a=Math.cos(o)*e,c=Math.sin(o)*e}}if(Math.sqrt(Math.pow(t-a,2)+Math.pow(n-c,2))>.5&&(l.push(e.createElement("line",{key:"connector-line",x1:a,y1:c,x2:t,y2:n,stroke:i||"currentColor"})),"arrow"===(null==o?void 0:o.end))){const o=10,s=16/180*Math.PI,r=Math.atan2(n-c,t-a);l.push(e.createElement("path",{key:"connector-arrow",d:`M${a},${c}L${a+o*Math.cos(r+s)},${c+o*Math.sin(r+s)}L${a+o*Math.cos(r-s)},${c+o*Math.sin(r-s)}Z`,fill:i||"currentColor",stroke:"none"}))}return e.createElement("g",{className:"annotation-connector"},l)}(v,b,c,d,x,h),!m.has("subject")&&function(t,n,o,i,s){var r;const l=[];switch(t){case"callout-circle":{const t=((null==n?void 0:n.radius)||0)+((null==n?void 0:n.radiusPadding)||0);t>0&&l.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,i=(null==n?void 0:n.height)||0;(t>0||i>0)&&l.push(e.createElement("rect",{key:"subject-rect",width:t,height:i,fill:"none",stroke:o||"currentColor"}));break}case"callout-custom":(null==n?void 0:n.custom)&&l.push(...Array.isArray(n.custom)?n.custom:[n.custom]);break;case"xy-threshold":{const t=i||0,r=s||0;if(void 0!==(null==n?void 0:n.x)){const i=(n.x||0)-t;l.push(e.createElement("line",{key:"threshold-line",x1:i,y1:(n.y1||0)-r,x2:i,y2:(n.y2||0)-r,stroke:o||"currentColor",strokeDasharray:"5,5"}))}else if(void 0!==(null==n?void 0:n.y)){const i=(n.y||0)-r;l.push(e.createElement("line",{key:"threshold-line",x1:(n.x1||0)-t,y1:i,x2:(n.x2||0)-t,y2:i,stroke:o||"currentColor",strokeDasharray:"5,5"}))}else void 0!==(null==n?void 0:n.x1)||void 0!==(null==n?void 0:n.x2)?l.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)||l.push(e.createElement("line",{key:"threshold-line",x1:0,y1:(n.y1||0)-r,x2:0,y2:(n.y2||0)-r,stroke:o||"currentColor",strokeDasharray:"5,5"}));break}case"bracket":{const t=null!==(r=null==n?void 0:n.width)&&void 0!==r?r:null==n?void 0:n.height;void 0!==t&&l.push(e.createElement("path",{key:"bracket-path",d:oe((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"},l)}(x,h,d,n,o),!m.has("note")&&function(t,n,o,i){if(!t)return e.createElement("g",{className:"annotation-note"});const{label:s,title:r,orientation:l,align:a,wrap:c=120,noWrap:h}=t;if(!s&&!r)return e.createElement("g",{className:"annotation-note"});let u=l;u||(u=Math.abs(n)>Math.abs(o)?"leftRight":"topBottom");let d=a;d&&"dynamic"!==d||(d="topBottom"===u?0>n?"right":"left":0>o?"bottom":"top");let f="start";"topBottom"===u?"right"===d?f="end":"middle"===d&&(f="middle"):f=0>n?"end":"start";const p=16,y=r?h?[r]:ne(r,c):[],g=s?h?[s]:ne(s,c):[],m="leftRight"===u?"end"===f?-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:i||void 0,textAnchor:f,fontWeight:"bold"},y.map((t,n)=>e.createElement("tspan",{key:n,x:m,dy:0===n?0:p},t)))),v=y.length*p),g.length>0&&b.push(e.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:i||void 0,textAnchor:f,y:v},g.map((t,n)=>e.createElement("tspan",{key:n,x:m,dy:0===n?0:p},t))));let x=null;if((r||s)&&(0!==n||0!==o))if("topBottom"===u){const t=Math.min(c,120);let n=0,o=t;"end"===f?(n=-t,o=0):"middle"===f&&(n=-t/2,o=t/2),x=e.createElement("line",{className:"note-line",x1:n,x2:o,y1:0,y2:0,stroke:i||"currentColor"})}else{const t=(y.length+g.length)*p+(g.length>0?p:0);let n=0,o=t;"bottom"===d?(n=-t,o=0):"middle"===d&&(n=-t/2,o=t/2),x=e.createElement("line",{className:"note-line",x1:0,x2:0,y1:n,y2:o,stroke:i||"currentColor"})}const w=Math.max(0,y.length+g.length-1)*p;let k=0;return"topBottom"===u?k=0>o?-(w+2):18:"leftRight"===u&&(k="middle"===d?-(w+p+(g.length>0&&y.length>0?2:0))/2+8:"bottom"===d||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)}(a,v,b,d))}function se(t){var n,o;const{noteData:i}=t,{screenCoordinates:s}=i,r="string"==typeof i.type?i.type:"label",l=i.eventListeners||i.events||{};if(i.coordinates&&s){const t=i.nx||s[0][0]+(null!==(n=i.dx)&&void 0!==n?n:0),l=i.ny||s[0][1]+(null!==(o=i.dy)&&void 0!==o?o:0),a=s.map((n,o)=>{const s=Object.assign({},i,{note:0===o?i.note:{label:""},x:n[0],y:n[1],nx:t,ny:l});return e.createElement(ie,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+o},s,{type:r}))});return e.createElement("g",null,a)}const a=i.note||{title:"none",label:i.label};return e.createElement(ie,Object.assign({"data-testid":"semiotic-annotation",key:`${a.label}-${a.title}-${i.i}`,events:l},i,{type:r}))}function re(e,t){var n,o,i;const s=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.x)&&void 0!==o?o:null===(i=t.scales)||void 0===i?void 0:i.time;return s?null!=e.x?s(e.x):t.xAccessor&&null!=e[t.xAccessor]?s(e[t.xAccessor]):null:null}function le(e,t){var n,o,i;const s=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.y)&&void 0!==o?o:null===(i=t.scales)||void 0===i?void 0:i.value;return s?null!=e.y?s(e.y):t.yAccessor&&null!=e[t.yAccessor]?s(e[t.yAccessor]):null:null}function ae(e,t,n,o=50){return!(-o>e||e>(n.width||0)+o||-o>t||t>(n.height||0)+o)}function ce(e,t,n){if("left"===e||"right"===e){const o="left"===e?n:0,i="left"===e?-1:1,s=Math.ceil(t/8);let r="M0,"+o;for(let e=0;s>e;e++){const n=8*(e+1);r+=`L${Math.min(8*e+4,t)},${o+4*i}`,r+=`L${Math.min(n,t)},${o}`}return r}{const o="bottom"===e?0:t,i="bottom"===e?1:-1,s=Math.ceil(n/8);let r=`M${o},0`;for(let e=0;s>e;e++){const t=8*(e+1);r+=`L${o+4*i},${Math.min(8*e+4,n)}`,r+=`L${o},${Math.min(t,n)}`}return r}}function he(e){return Math.round(100*e)/100+""}function ue(t){const{width:n,height:o,totalWidth:s,totalHeight:r,margin:l,scales:a,showAxes:c,axes:h,xLabel:u,yLabel:d,xFormat:f,yFormat:p,showGrid:y,title:g,legend:m,foregroundGraphics:v,marginalGraphics:b,xValues:w,yValues:k,annotations:A,svgAnnotationRules:E,annotationFrame:S,xAccessor:O,yAccessor:M,annotationData:N,pointNodes:j,children:L}=t,W=i(()=>c&&a?a.x.ticks(5).map(e=>({value:e,pixel:a.x(e),label:(f||he)(e)})):[],[c,a,f]),_=i(()=>c&&a?a.y.ticks(5).map(e=>({value:e,pixel:a.y(e),label:(p||he)(e)})):[],[c,a,p]),$=i(()=>{if(!A||0===A.length)return null;const t=function(t,n,o){var i,s,r,l,a,c,h,u,d,f,p,y,g,m,v,b,w,k,A,E,S,O,M,N,j,L,W,_,$,C,B,H,z,T,F,P,I,D,G;switch(t.type){case"label":{let i=null,s=null;if(null!=t.pointId&&o.pointNodes){const e=o.pointNodes.find(e=>e.pointId===t.pointId);if(!e)return null;i=e.x,s=e.y}else i=re(t,o),s=le(t,o);return null==i||null==s?null:ae(i,s,o)?e.createElement(se,{key:"ann-"+n,noteData:{x:i,y:s,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 i=null,s=null;if(null!=t.pointId&&o.pointNodes){const e=o.pointNodes.find(e=>e.pointId===t.pointId);if(!e)return null;i=e.x,s=e.y}else i=re(t,o),s=le(t,o);return null==i||null==s?null:ae(i,s,o)?e.createElement(se,{key:"ann-"+n,noteData:{x:i,y:s,dx:t.dx||30,dy:t.dy||-30,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"callout-circle",subject:{radius:t.radius||12},connector:t.connector||{end:"arrow"},color:t.color}}):null}case"x-threshold":{const i=re(t,o);if(null==i)return null;const s=t.color||"#f97316";return e.createElement("g",{key:"ann-"+n},e.createElement("line",{x1:i,y1:0,x2:i,y2:o.height||0,stroke:s,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&e.createElement("text",{x:i+4,y:12,fill:s,fontSize:12,fontWeight:"bold"},t.label))}case"y-threshold":{const i=le(t,o);if(null==i)return null;const s=t.color||"#f97316";return e.createElement("g",{key:"ann-"+n},e.createElement("line",{x1:0,y1:i,x2:o.width||0,y2:i,stroke:s,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&e.createElement("text",{x:(o.width||0)-4,y:i-4,textAnchor:"end",fill:s,fontSize:12,fontWeight:"bold"},t.label))}case"enclose":{const i=(t.coordinates||[]).map(e=>({x:re(Object.assign(Object.assign({},e),{type:"point"}),o),y:le(Object.assign(Object.assign({},e),{type:"point"}),o),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>i.length)return null;const s=x(i),r=t.padding||10;return e.createElement("g",{key:"ann-"+n},e.createElement("circle",{cx:s.x,cy:s.y,r:s.r+r,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&e.createElement("text",{x:s.x,y:s.y-s.r-r-4,textAnchor:"middle",fill:t.color||"#666",fontSize:12},t.label))}case"rect-enclose":{const i=(t.coordinates||[]).map(e=>({x:re(Object.assign(Object.assign({},e),{type:"point"}),o),y:le(Object.assign(Object.assign({},e),{type:"point"}),o)})).filter(e=>null!=e.x&&null!=e.y);if(2>i.length)return null;const s=t.padding||10,r=i.map(e=>e.x),l=i.map(e=>e.y),a=Math.min(...r)-s,c=Math.max(...r)+s,h=Math.min(...l)-s,u=Math.max(...l)+s;return e.createElement("g",{key:"ann-"+n},e.createElement("rect",{x:a,y:h,width:c-a,height:u-h,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&e.createElement("text",{x:(a+c)/2,y:h-4,textAnchor:"middle",fill:t.color||"#666",fontSize:12},t.label))}case"highlight":{const i=o.data||[],s="function"==typeof t.filter?i.filter(t.filter):t.field&&null!=t.value?i.filter(e=>e[t.field]===t.value):[],r=t.style||{stroke:t.color||"#f97316",strokeWidth:2,fill:"none"};return e.createElement("g",{key:"ann-"+n},s.map((n,i)=>{const s=re(n,o),l=le(n,o);return null==s||null==l?null:e.createElement("circle",Object.assign({key:i,cx:s,cy:l,r:t.r||6},r))}))}case"bracket":{const i=re(t,o),s=le(t,o);return e.createElement(se,{key:"ann-"+n,noteData:{x:null!=i?i:0,y:null!=s?s: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 u=o.data||[];if(2>u.length)return null;const d=o.xAccessor||"x",f=o.yAccessor||"y",p=u.map(e=>[e[d],e[f]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>p.length)return null;const y=null!==(s=null===(i=o.scales)||void 0===i?void 0:i.x)&&void 0!==s?s:null===(r=o.scales)||void 0===r?void 0:r.time,g=null!==(a=null===(l=o.scales)||void 0===l?void 0:l.y)&&void 0!==a?a:null===(c=o.scales)||void 0===c?void 0:c.value;if(!y||!g)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]),i=o.map(e=>e[0]),s=o.map(e=>e[1]),r=Math.max(2,Math.ceil(t*n)),l=[];for(let e=0;n>e;e++){const t=i[e],o=i.map(e=>Math.abs(e-t)),a=o.slice().sort((e,t)=>e-t)[Math.min(r-1,n-1)]||1,c=[];for(let e=0;n>e;e++){const t=0===a?0:o[e]/a;c[e]=1>t?Math.pow(1-Math.pow(t,3),3):0}let h=0,u=0,d=0,f=0,p=0;for(let e=0;n>e;e++){const t=c[e];0!==t&&(h+=t,u+=t*i[e],d+=t*s[e],f+=t*i[e]*i[e],p+=t*i[e]*s[e])}if(0===h){l.push([t,s[e]]);continue}const y=h*f-u*u;if(1e-12>Math.abs(y))l.push([t,d/h]);else{const e=(h*p-u*d)/y;l.push([t,(d-e*u)/h+e*t])}}return l}(p,null!==(h=t.bandwidth)&&void 0!==h?h:.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)},${g(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:g(v[v.length-1][1])-4,fill:x,fontSize:11},t.label))}case"band":{const i=null!==(d=null===(u=o.scales)||void 0===u?void 0:u.y)&&void 0!==d?d:null===(f=o.scales)||void 0===f?void 0:f.value,s=null!==(p=null==i?void 0:i(t.y0))&&void 0!==p?p:0,r=null!==(y=null==i?void 0:i(t.y1))&&void 0!==y?y:o.height||0;return e.createElement("g",{key:"ann-"+n},e.createElement("rect",{x:0,y:Math.min(s,r),width:o.width||0,height:Math.abs(r-s),fill:t.fill||"#6366f1",fillOpacity:t.fillOpacity||.1}),t.label&&e.createElement("text",{x:(o.width||0)-4,y:Math.min(s,r)-4,textAnchor:"end",fill:t.color||"#6366f1",fontSize:11},t.label))}case"envelope":{const i=o.data||[];if(2>i.length)return null;const s=o.xAccessor||"x",r=null!==(m=null===(g=o.scales)||void 0===g?void 0:g.x)&&void 0!==m?m:null===(v=o.scales)||void 0===v?void 0:v.time,l=null!==(w=null===(b=o.scales)||void 0===b?void 0:b.y)&&void 0!==w?w:null===(k=o.scales)||void 0===k?void 0:k.value;if(!r||!l)return null;const a=t.upperAccessor||"upperBounds",c=t.lowerAccessor||"lowerBounds",h=t.filter,u=i.filter(e=>null!=e[a]&&null!=e[c]&&!(h&&!h(e))).sort((e,t)=>e[s]-t[s]);if(2>u.length)return null;const d=u.map(e=>`${r(e[s])},${l(e[a])}`).join(" L"),f=u.slice().reverse().map(e=>`${r(e[s])},${l(e[c])}`).join(" L"),p=t.fill||"#6366f1";return e.createElement("g",{key:"ann-"+n},e.createElement("path",{d:`M${d} L${f} Z`,fill:p,fillOpacity:null!==(A=t.fillOpacity)&&void 0!==A?A:.15,stroke:"none"}),t.label&&u.length>0&&e.createElement("text",{x:r(u[u.length-1][s])+4,y:l(u[u.length-1][a])-4,fill:p,fontSize:11},t.label))}case"anomaly-band":{const i=o.data||[];if(2>i.length)return null;const s=o.yAccessor||"y",r=null!==(S=null===(E=o.scales)||void 0===E?void 0:E.x)&&void 0!==S?S:null===(O=o.scales)||void 0===O?void 0:O.time,l=null!==(N=null===(M=o.scales)||void 0===M?void 0:M.y)&&void 0!==N?N:null===(j=o.scales)||void 0===j?void 0:j.value;if(!r||!l)return null;const a=i.map(e=>e[s]).filter(e=>null!=e&&isFinite(e));if(2>a.length)return null;const c=a.reduce((e,t)=>e+t,0)/a.length,h=a.reduce((e,t)=>e+Math.pow(t-c,2),0)/a.length,u=Math.sqrt(h),d=null!==(L=t.threshold)&&void 0!==L?L:2,f=c-d*u,p=!1!==t.showBand,y=t.fill||"#6366f1",g=null!==(W=t.fillOpacity)&&void 0!==W?W:.1,m=t.anomalyColor||"#ef4444",v=null!==(_=t.anomalyRadius)&&void 0!==_?_:6,b=l(c+d*u),x=l(f),w=i.filter(e=>{const t=e[s];return null!=t&&Math.abs(t-c)>d*u});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:g}),w.map((t,n)=>{const i=re(t,o),s=le(t,o);return null==i||null==s?null:e.createElement("circle",{key:n,cx:i,cy:s,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 i=o.data||[];if(3>i.length)return null;const s=o.xAccessor||"x",r=o.yAccessor||"y",l=null!==(C=null===($=o.scales)||void 0===$?void 0:$.x)&&void 0!==C?C:null===(B=o.scales)||void 0===B?void 0:B.time,a=null!==(z=null===(H=o.scales)||void 0===H?void 0:H.y)&&void 0!==z?z:null===(T=o.scales)||void 0===T?void 0:T.value;if(!l||!a)return null;const c=i.map(e=>[e[s],e[r]]).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 h;if("polynomial"===(t.method||"linear"))try{const e=require("regression").polynomial(c,{order:t.order||2}).equation;h=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,i=0;for(const[e,s]of c)t+=e,n+=s,o+=e*e,i+=e*s;const s=e*o-t*t;if(1e-12>Math.abs(s))return null;const r=(e*i-t*n)/s,l=(n-r*t)/e;h=e=>l+r*e}const u=c.length,d=c.map(([e,t])=>t-h(e)).reduce((e,t)=>e+t*t,0),f=Math.sqrt(d/Math.max(u-2,1)),p=c.reduce((e,t)=>e+t[0],0)/u,y=c.reduce((e,t)=>e+Math.pow(t[0]-p,2),0),g=null!==(F=t.confidence)&&void 0!==F?F:.95,m=.99>g?.95>g?.9>g?1:1.645:1.96:2.576,v=null!==(P=t.steps)&&void 0!==P?P:5,b=c[u-1][0],x=(b-c[0][0])/Math.max(u-1,1),w=[];for(let e=1;v>=e;e++)w.push(b+e*x);const k=[];for(const e of w){const t=h(e),n=f*Math.sqrt(1+1/u+(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=>`${l(e.x)},${a(e.yUpper)}`).join(" L")} L${k.slice().reverse().map(e=>`${l(e.x)},${a(e.yLower)}`).join(" L")} Z`,E=k.map(e=>`${l(e.x)},${a(e.yCenter)}`).join(" "),S=`${l(b)},${a(h(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!==(D=t.strokeWidth)&&void 0!==D?D:2,strokeDasharray:null!==(G=t.strokeDasharray)&&void 0!==G?G:"6,3"}),t.label&&k.length>0&&e.createElement("text",{x:l(k[k.length-1].x)+4,y:a(k[k.length-1].yCenter)-4,fill:O,fontSize:11},t.label))}default:return null}},i={scales:a?{x:a.x,y:a.y,time:a.x,value:a.y}:null,timeAxis:"x",xAccessor:O,yAccessor:M,width:n,height:o,data:N,frameType:"xy",pointNodes:j};return A.map((e,n)=>{if(E){const o=E(e,n,i);return null!=o?o:t(e,n,i)}return t(e,n,i)}).filter(Boolean)},[A,E,n,o,S,O,M,N]);return c||g||m||v||b||$&&$.length>0||y||L?e.createElement("svg",{width:s,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},e.createElement("g",{transform:`translate(${l.left},${l.top})`},y&&a&&e.createElement("g",{className:"stream-grid"},W.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})),_.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&&a&&(()=>{const t=null==h?void 0:h.find(e=>"left"===e.orient),i=null==h?void 0:h.find(e=>"bottom"===e.orient),s=!t||!1!==t.baseline,r=(null==t?void 0:t.jaggedBase)||!1,a=(null==i?void 0:i.jaggedBase)||!1,c="var(--semiotic-border, #ccc)",f="var(--semiotic-text-secondary, #666)",p="var(--semiotic-text, #333)";return e.createElement("g",{className:"stream-axes"},(!i||!1!==i.baseline)&&!a&&e.createElement("line",{x1:0,y1:o,x2:n,y2:o,stroke:c,strokeWidth:1}),a&&e.createElement("path",{d:ce("bottom",n,o),fill:"none",stroke:c,strokeWidth:1}),W.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:f,style:{userSelect:"none"}},t.label))),u&&e.createElement("text",{x:n/2,y:o+40,textAnchor:"middle",fontSize:12,fill:p,style:{userSelect:"none"}},u),s&&!r&&e.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:c,strokeWidth:1}),r&&e.createElement("path",{d:ce("left",n,o),fill:"none",stroke:c,strokeWidth:1}),_.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:f,style:{userSelect:"none"}},t.label))),d&&e.createElement("text",{x:15-l.left,y:o/2,textAnchor:"middle",fontSize:12,fill:p,transform:`rotate(-90, ${15-l.left}, ${o/2})`,style:{userSelect:"none"}},d))})(),$,b&&a&&w&&k&&e.createElement(e.Fragment,null,b.top&&e.createElement("g",{transform:"translate(0, 0)"},e.createElement(te,{orient:"top",config:ee(b.top),values:w,scale:a.x,size:l.top,length:n})),b.bottom&&e.createElement("g",{transform:`translate(0, ${o})`},e.createElement(te,{orient:"bottom",config:ee(b.bottom),values:w,scale:a.x,size:l.bottom,length:n})),b.left&&e.createElement("g",{transform:"translate(0, 0)"},e.createElement(te,{orient:"left",config:ee(b.left),values:k,scale:a.y,size:l.left,length:o})),b.right&&e.createElement("g",{transform:`translate(${n}, 0)`},e.createElement(te,{orient:"right",config:ee(b.right),values:k,scale:a.y,size:l.right,length:o}))),v,L),g&&e.createElement("text",{x:s/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof g?g:null),m&&e.createElement("g",{transform:`translate(${s-l.right+10}, ${l.top})`},"object"==typeof(C=m)&&null!==C&&!e.isValidElement(C)&&"legendGroups"in C?e.createElement(Q,{legendGroups:m.legendGroups,title:"",width:100}):m)):null;var C}function de(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 fe(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 pe=(e,t,n,o)=>{var i;const s=t.filter(e=>"area"===e.type);for(const t of s){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 s=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])),i=e.createLinearGradient(0,n,0,o);i.addColorStop(0,s),i.addColorStop(1,s),e.fillStyle=i;const r=fe(s),l=t.fillGradient.topOpacity,a=t.fillGradient.bottomOpacity,c=e.createLinearGradient(0,n,0,o);c.addColorStop(0,`rgba(${r[0]},${r[1]},${r[2]},${l})`),c.addColorStop(1,`rgba(${r[0]},${r[1]},${r[2]},${a})`),e.fillStyle=c,e.globalAlpha=1}else{const n=null!==(i=t.style.fillOpacity)&&void 0!==i?i:.7;e.globalAlpha=n,e.fillStyle=s}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}},ye=(e,t,n,o)=>{var i,s;const r=t.filter(e=>"point"===e.type);for(const t of r){e.beginPath(),e.arc(t.x,t.y,t.r,0,2*Math.PI);const n=null!==(i=t.style.opacity)&&void 0!==i?i: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!==(s=t._pulseGlowRadius)&&void 0!==s?s: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}},ge=(e,t,n,o)=>{const i=t.filter(e=>"rect"===e.type);for(const t of i)null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.icon?me(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 me(e,t){const n=t.style.icon,o=t.style.iconPadding||2,i=Math.min(t.w,t.w)-o;if(0>=i)return;const s=t.h>t.w;if(e.save(),e.beginPath(),e.rect(t.x,t.y,t.w,t.h),e.clip(),s){const s=i+o,r=t.x+(t.w-i)/2;for(let o=t.y+t.h-i;o>=t.y-i;o-=s)e.drawImage(n,r,o,i,i)}else{const s=i+o,r=t.y+(t.h-i)/2;for(let o=t.x;t.x+t.w>o;o+=s)e.drawImage(n,o,r,i,i)}e.restore()}const ve={line:[pe,(e,t,n,o)=>{const i=t.filter(e=>"line"===e.type);for(const s of i){if(2>s.path.length)continue;const r=s.style.stroke||"#007bff",l=s.style.strokeWidth||2,a=s.colorThresholds,c=s.rawValues;if(e.setLineDash(s.style.strokeDasharray?s.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=s.style.opacity&&(e.globalAlpha=s.style.opacity),e.lineWidth=l,a&&0!==a.length&&c&&c.length===s.path.length){let h=null,u=null,d=null,f=null,p=!1;function y(t,n,o){e.beginPath(),e.strokeStyle=t,e.moveTo(n,o),p=!0}function g(){p&&(e.stroke(),p=!1)}for(let m=0;s.path.length>m;m++){const[v,b]=s.path[m],x=c[m],w=de(x,a,r);if(null!==h&&null!==f&&null!==d){if(w===f)e.lineTo(v,b);else{const k=[];for(const A of a){const E=A.value;(d>E||E>x)&&(E>d||x>E)||d===E||x===E||k.push({t:(E-d)/(x-d)})}k.sort((e,t)=>e.t-t.t);for(const S of k){const O=h+(v-h)*S.t,M=u+(b-u)*S.t,N=de(d+(x-d)*Math.min(S.t+1e-4,1),a,r);e.lineTo(O,M),g(),y(N,O,M)}e.lineTo(v,b)}h=v,u=b,d=x,f=w}else y(w,v,b),h=v,u=b,d=x,f=w}g()}else{e.beginPath(),e.strokeStyle=r;const[j,L]=s.path[0];e.moveTo(j,L);for(let W=1;s.path.length>W;W++)e.lineTo(s.path[W][0],s.path[W][1]);e.stroke()}if(s.style.fill&&s.style.fillOpacity&&s.style.fillOpacity>0){e.beginPath(),e.globalAlpha=s.style.fillOpacity,e.fillStyle=s.style.fill;const[_,$]=s.path[0];e.moveTo(_,$);for(let B=1;s.path.length>B;B++)e.lineTo(s.path[B][0],s.path[B][1]);const C=s.path[0][0];e.lineTo(s.path[s.path.length-1][0],o.height),e.lineTo(C,o.height),e.closePath(),e.fill()}e.globalAlpha=1,e.setLineDash([])}}],area:[pe],stackedarea:[pe],scatter:[ye],bubble:[ye],heatmap:[(e,t,n,o)=>{const i=t.filter(e=>"heatcell"===e.type);for(const t of i){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:[ge],swarm:[ye],waterfall:[(e,t,n,o)=>{var i,s,r;ge(e,t);const l=t.filter(e=>"rect"===e.type);if(2>l.length)return;const a=l[0].datum,c=null==a?void 0:a._connectorStroke;if(c){e.save(),e.strokeStyle=c,e.lineWidth=null!==(i=null==a?void 0:a._connectorWidth)&&void 0!==i?i:1,e.setLineDash([]);for(let t=0;l.length-1>t;t++){const o=l[t],i=l[t+1];if(!(null===(s=o.datum)||void 0===s?void 0:s.cumEnd)||!(null===(r=i.datum)||void 0===r?void 0:r.baseline))continue;const a=n.y(o.datum.cumEnd),c=o.x+o.w,h=i.x;e.beginPath(),e.moveTo(c,a),e.lineTo(h,a),e.stroke()}e.restore()}}],candlestick:[(e,t,n,o)=>{for(const n of t){if("candlestick"!==n.type)continue;const t=n;e.beginPath(),e.moveTo(t.x,t.highY),e.lineTo(t.x,t.lowY),e.strokeStyle=t.wickColor,e.lineWidth=t.wickWidth,e.stroke();const o=Math.min(t.openY,t.closeY),i=Math.abs(t.openY-t.closeY),s=t.isUp?t.upColor:t.downColor;e.fillStyle=s,e.fillRect(t.x-t.bodyWidth/2,o,t.bodyWidth,Math.max(i,1)),e.strokeStyle=s,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,o,t.bodyWidth,Math.max(i,1))}}]},be={top:20,right:20,bottom:30,left:40},xe={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"},we={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 ke({hover:t}){const n=e=>Number.isInteger(e)?e+"":e.toFixed(2);return e.createElement("div",{className:"semiotic-tooltip",style:we},e.createElement("div",{style:{fontWeight:600,marginBottom:2}},n(t.value)),e.createElement("div",{style:{opacity:.7,fontSize:11}},n(t.time)))}function Ae({width:n,height:i,totalWidth:s,totalHeight:r,margin:l,dimension:a,scales:c,onBrush:h}){const u=t(null),g=t(null);return o(()=>{if(!u.current)return;const e=y(u.current).select(".brush-g"),t="x"===a?d():"y"===a?f():p();return t.extent([[0,0],[n,i]]),t.on("brush end",e=>{if(!c)return;if(!e.selection)return void h(null);let t,o;if("x"===a){const[n,s]=e.selection;t=[c.x.invert(n),c.x.invert(s)],o=[c.y.invert(i),c.y.invert(0)]}else if("y"===a){const[i,s]=e.selection;t=[c.x.invert(0),c.x.invert(n)],o=[c.y.invert(s),c.y.invert(i)]}else{const[[n,i],[s,r]]=e.selection;t=[c.x.invert(n),c.x.invert(s)],o=[c.y.invert(r),c.y.invert(i)]}h({x:t,y:o})}),e.call(t),g.current=t,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{t.on("brush end",null),g.current=null}},[n,i,a,c,h]),e.createElement("svg",{ref:u,width:s,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},e.createElement("g",{className:"brush-g",transform:`translate(${l.left},${l.top})`}))}const Ee=s(function(s,a){var c,h,u;const{chartType:d,runtimeMode:f,data:p,xAccessor:y,yAccessor:g,colorAccessor:m,sizeAccessor:v,groupAccessor:b,lineDataAccessor:x,normalize:w,binSize:k,valueAccessor:A,arrowOfTime:E="right",windowMode:S="sliding",windowSize:O=200,timeAccessor:M,xExtent:N,yExtent:j,extentPadding:L=.1,sizeRange:W,size:$=[500,300],responsiveWidth:C,responsiveHeight:B,margin:H,className:z,background:T,lineStyle:F,pointStyle:P,areaStyle:I,waterfallStyle:D,swarmStyle:Z,barColors:J,colorScheme:K,boundsAccessor:Q,boundsStyle:ee,y0Accessor:te,gradientFill:ne,openAccessor:oe,highAccessor:ie,lowAccessor:se,closeAccessor:re,candlestickStyle:le,showAxes:ae=!0,axes:ce,xLabel:he,yLabel:de,xFormat:fe,yFormat:pe,tickFormatTime:ye,tickFormatValue:ge,hoverAnnotation:me,tooltipContent:we,customHoverBehavior:Ee,enableHover:Se,annotations:Oe,svgAnnotationRules:Me,showGrid:Ne,legend:je,backgroundGraphics:Le,foregroundGraphics:We,title:_e,categoryAccessor:$e,brush:Ce,onBrush:Be,decay:He,pulse:ze,transition:Te,staleness:Fe,heatmapAggregation:Pe,heatmapXBins:Ie,heatmapYBins:De,marginalGraphics:Ge,pointIdAccessor:Re}=s,[Ye,Xe]=function(e,i,s){const r=t(null),[l,a]=n(null);return o(()=>{if(!i&&!s)return;const e=r.current;if(!e)return;const t=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;a(t=>t&&t.w===e&&t.h===n?t:{w:e,h:n})}});return t.observe(e),()=>t.disconnect()},[i,s]),[r,[i&&l?l.w:e[0],s&&l?l.h:e[1]]]}($,C,B),qe=Object.assign(Object.assign({},be),H);if(Ge){const e=60;Ge.top&&e>qe.top&&(qe.top=e),Ge.bottom&&e>qe.bottom&&(qe.bottom=e),Ge.left&&e>qe.left&&(qe.left=e),Ge.right&&e>qe.right&&(qe.right=e)}const Ve=Xe[0]-qe.left-qe.right,Ue=Xe[1]-qe.top-qe.bottom,Ze=null!=me?me:Se,Je=t(null),Ke=t(0),Qe=t(!1),[et,tt]=n(0),[nt,ot]=n(null),it=t(null),st=t(null),[rt,lt]=n(null),[at,ct]=n(!1),[ht,ut]=n([]),[dt,ft]=n([]),pt=t(()=>{}),yt="streaming"===f||["bar","swarm","waterfall"].includes(d),gt=i(()=>({chartType:d,runtimeMode:yt?"streaming":"bounded",windowSize:O,windowMode:S,arrowOfTime:yt?E:"right",extentPadding:L,xAccessor:yt?void 0:y,yAccessor:yt?void 0:g,timeAccessor:yt?M:void 0,valueAccessor:A,colorAccessor:m,sizeAccessor:v,groupAccessor:b,categoryAccessor:$e,lineDataAccessor:x,xExtent:N,yExtent:j,sizeRange:W,binSize:k,normalize:w,boundsAccessor:Q,boundsStyle:ee,y0Accessor:te,gradientFill:"boolean"==typeof ne?ne?{topOpacity:.8,bottomOpacity:.05}:void 0:ne,openAccessor:oe,highAccessor:ie,lowAccessor:se,closeAccessor:re,candlestickStyle:le,lineStyle:F,pointStyle:P,areaStyle:I,swarmStyle:Z,waterfallStyle:D,colorScheme:K,barColors:J,annotations:Oe,decay:He,pulse:ze,transition:Te,staleness:Fe,heatmapAggregation:Pe,heatmapXBins:Ie,heatmapYBins:De,pointIdAccessor:Re}),[d,O,S,E,L,y,g,M,A,m,v,b,$e,x,N,j,W,k,w,Q,ee,te,ne,oe,ie,se,re,le,F,P,I,Z,D,K,J,Oe,He,ze,Te,Fe,Pe,Ie,De,yt,Re]),mt=t(null);mt.current||(mt.current=new G(gt));const vt=r(()=>{Ke.current||(Ke.current=requestAnimationFrame(()=>pt.current()))},[]);o(()=>{var e;null===(e=mt.current)||void 0===e||e.updateConfig(gt),Qe.current=!0,vt()},[gt,vt]);const bt=t(null);bt.current||(bt.current=new _(e=>{const t=mt.current;t&&t.ingest(e)&&(Qe.current=!0,vt())}));const xt=r(e=>{var t;null===(t=bt.current)||void 0===t||t.push(e)},[]),wt=r(e=>{var t;null===(t=bt.current)||void 0===t||t.pushMany(e)},[]),kt=r(()=>{var e,t;null===(e=bt.current)||void 0===e||e.clear(),null===(t=mt.current)||void 0===t||t.clear(),Qe.current=!0,vt()},[vt]);l(a,()=>({push:xt,pushMany:wt,clear:kt,getData:()=>{var e,t;return null!==(t=null===(e=mt.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=mt.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null},getExtents:()=>{var e,t;return null!==(t=null===(e=mt.current)||void 0===e?void 0:e.getExtents())&&void 0!==t?t:null}}),[xt,wt,kt]),o(()=>{var e;if(p)return null===(e=bt.current)||void 0===e||e.setBoundedData(p),()=>{var e;null===(e=bt.current)||void 0===e||e.clearLastData()}},[p]);const At=t(()=>{}),Et=t(()=>{});At.current=e=>{if(!Ze)return;const t=Je.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-qe.left,i=e.clientY-n.top-qe.top;if(0>o||o>Ve||0>i||i>Ue)return void(it.current&&(it.current=null,st.current=null,lt(null),Ee&&(Ee(null),Qe.current=!0),vt()));const s=mt.current;if(!s||0===s.scene.length)return;const r=function(e,t,n,o=30){let i=null;for(const s of e){let e=null;switch(s.type){case"point":e=R(s,t,n);break;case"line":e=Y(s,t,n);break;case"rect":e=X(s,t,n);break;case"heatcell":e=q(s,t,n);break;case"area":if(!1===s.interactive)break;e=U(s,t,n);break;case"candlestick":e=V(s,t,n)}e&&o>e.distance&&(i&&e.distance>=i.distance||(i=e))}return i}(s.scene,o,i);if(!r)return void(it.current&&(it.current=null,st.current=null,lt(null),Ee&&Ee(null),vt()));const l={data:r.datum,time:r.x,value:r.y,x:r.x,y:r.y};it.current=l,st.current=r.node,lt(l),Ee&&(Ee(l),Qe.current=!0),vt()},Et.current=()=>{it.current&&(it.current=null,st.current=null,lt(null),Ee&&(Ee(null),Qe.current=!0),vt())},r(e=>At.current(e),[]);const St=r(()=>Et.current(),[]),Ot=t(-1),Mt=r(e=>{const t=mt.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>Ot.current?-1:Ot.current,i=function(e,t,n){switch(e){case"ArrowRight":case"ArrowDown":return n-1>t?t+1:t;case"ArrowLeft":case"ArrowUp":return t>0?t-1:t;case"Home":return 0;case"End":return n-1;case"Escape":return-1;default:return null}}(e.key,0>o?-1:o,n.length);if(null===i)return;if(e.preventDefault(),0>i)return Ot.current=-1,it.current=null,st.current=null,lt(null),Ee&&Ee(null),void vt();const s=0>o?0:i;Ot.current=s;const r={data:(l=n[s]).datum,x:l.x,y:l.y,time:l.x,value:l.y};var l;it.current=r,lt(r),Ee&&Ee(r),vt()},[Ee,vt]),Nt=r(e=>{Ot.current=-1,At.current(e)},[]);pt.current=()=>{var e,t;Ke.current=0;const n=Je.current;if(!n)return;const o=n.getContext("2d");if(!o)return;const i=mt.current;if(!i)return;const s="undefined"!=typeof performance?performance.now():Date.now(),r=i.advanceTransition(s);r||i.computeScene({width:Ve,height:Ue});const l="undefined"!=typeof window&&window.devicePixelRatio||1;n.width=Xe[0]*l,n.height=Xe[1]*l,n.style.width=Xe[0]+"px",n.style.height=Xe[1]+"px",o.scale(l,l),o.translate(qe.left,qe.top),o.clearRect(-qe.left,-qe.top,Xe[0],Xe[1]);const a=function(e){if(!e)return xe;const t=getComputedStyle(e),n=t.getPropertyValue("--semiotic-border").trim(),o=t.getPropertyValue("--semiotic-text-secondary").trim(),i=t.getPropertyValue("--semiotic-bg").trim(),s=o||t.getPropertyValue("--text-secondary").trim(),r=t.getPropertyValue("--text-primary").trim(),l=n||t.getPropertyValue("--surface-3").trim(),a=i||t.getPropertyValue("--surface-0").trim();return s||r||n?{axisStroke:l||xe.axisStroke,tickText:s||xe.tickText,crosshair:s?s+"66":xe.crosshair,hoverFill:a?a+"4D":xe.hoverFill,hoverStroke:s?s+"99":xe.hoverStroke,pointRing:a||xe.pointRing}:xe}(n),c=null!==(e=null==Fe?void 0:Fe.threshold)&&void 0!==e?e:5e3,h=Fe&&i.lastIngestTime>0&&s-i.lastIngestTime>c;h&&(o.globalAlpha=null!==(t=null==Fe?void 0:Fe.dimOpacity)&&void 0!==t?t:.5);const u=n?getComputedStyle(n).getPropertyValue("--semiotic-bg").trim():"",f=T||(u&&"transparent"!==u?u:null);f&&(o.fillStyle=f,o.fillRect(-qe.left,-qe.top,Xe[0],Xe[1])),o.save(),"function"==typeof o.rect&&(o.beginPath(),o.rect(0,0,Ve,Ue),o.clip());const p=ve[d];if(p&&i.scales)for(const e of p)e(o,i.scene,i.scales,{width:Ve,height:Ue});if(o.restore(),h&&(o.globalAlpha=1),Ze&&it.current&&i.scales&&function(e,t,n,o,i,s,r){if(!1===i.crosshair)return;e.save();const l="object"==typeof i.crosshair?i.crosshair:{};e.strokeStyle=l.stroke||r.crosshair,e.lineWidth=l.strokeWidth||1,e.setLineDash(l.strokeDasharray?l.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),e.beginPath(),e.moveTo(t.x,0),e.lineTo(t.x,o),e.stroke(),e.beginPath(),e.moveTo(0,t.y),e.lineTo(n,t.y),e.stroke(),e.restore(),e.beginPath(),e.arc(t.x,t.y,4,0,2*Math.PI),e.fillStyle="#007bff",e.fill(),e.strokeStyle=r.pointRing,e.lineWidth=2,e.stroke()}(o,it.current,Ve,Ue,"object"==typeof Ze?Ze:{},0,a),st.current&&Array.isArray(me)){const e=me.find(e=>e&&"object"==typeof e&&"highlight"===e.type);e&&function(e,t,n,o){var i;if(!n)return;const s=n.group;if(void 0!==s)for(const n of t){if("line"!==n.type)continue;if(n.group!==s)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!==(i=t.opacity)&&void 0!==i?i:1,e.stroke(),e.restore()}}(o,i.scene,st.current,e)}const m=Qe.current;if(Qe.current=!1,m&&i.scales&&(ot(i.scales),Ge)){const e=i.getData(),t="function"==typeof y?y:e=>e[y||"x"],n="function"==typeof g?g:e=>e[g||"y"];ut(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&&Oe&&Oe.length>0&&tt(e=>e+1),(null==Fe?void 0:Fe.showBadge)&&ct(!!h),(r||i.hasActivePulses)&&(Ke.current=requestAnimationFrame(()=>pt.current()))},o(()=>(vt(),()=>{Ke.current&&(cancelAnimationFrame(Ke.current),Ke.current=0)}),[vt]),o(()=>{Qe.current=!0,vt()},[d,Ve,Ue,ae,T,F,vt]),o(()=>{if(!Fe)return;const e=setInterval(()=>{var e;const t=mt.current;if(!t||0===t.lastIngestTime)return;const n="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(e=Fe.threshold)&&void 0!==e?e:5e3,i=n-t.lastIngestTime>o;i!==at&&(ct(i),Qe.current=!0,vt())},1e3);return()=>clearInterval(e)},[Fe,at,vt]);const jt=Ze&&rt?we?we(rt):e.createElement(ke,{hover:rt}):null,Lt=jt?e.createElement("div",{className:"stream-frame-tooltip",style:{position:"absolute",left:qe.left+rt.x,top:qe.top+rt.y,transform:`translate(${rt.x>.7*Ve?"calc(-100% - 12px)":"12px"}, ${.3*Ue>rt.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:1}},jt):null,Wt=Ot.current>=0&&rt?e.createElement("svg",{style:{position:"absolute",left:0,top:0,width:Xe[0],height:Xe[1],pointerEvents:"none",zIndex:2}},e.createElement("circle",{cx:rt.x+qe.left,cy:rt.y+qe.top,r:8,fill:"none",stroke:"var(--accent, #6366f1)",strokeWidth:2,strokeDasharray:"4,2"})):null;return e.createElement("div",{ref:Ye,className:"stream-xy-frame"+(z?" "+z:""),role:"img","aria-label":"string"==typeof _e?_e:"XY chart",tabIndex:0,style:{position:"relative",width:C?"100%":Xe[0],height:B?"100%":Xe[1]},onMouseMove:Ze?Nt:void 0,onMouseLeave:Ze?St:void 0,onKeyDown:Mt},Le&&e.createElement("svg",{style:{position:"absolute",left:0,top:0,width:Xe[0],height:Xe[1],pointerEvents:"none"}},Le),e.createElement("canvas",{ref:Je,style:{position:"absolute",left:0,top:0}}),e.createElement(ue,{width:Ve,height:Ue,totalWidth:Xe[0],totalHeight:Xe[1],margin:qe,scales:nt,showAxes:ae,axes:ce,xLabel:he,yLabel:de,xFormat:fe||ye,yFormat:pe||ge,showGrid:Ne,title:_e,legend:je,foregroundGraphics:We,marginalGraphics:Ge,xValues:ht,yValues:dt,annotations:Oe,svgAnnotationRules:Me,annotationFrame:et,xAccessor:"string"==typeof y?y:"string"==typeof M?M:void 0,yAccessor:"string"==typeof g?g:"string"==typeof A?A:void 0,annotationData:null===(c=mt.current)||void 0===c?void 0:c.getData(),pointNodes:null===(h=mt.current)||void 0===h?void 0:h.scene.filter(e=>"point"===e.type)}),(Ce||Be)&&e.createElement(Ae,{width:Ve,height:Ue,totalWidth:Xe[0],totalHeight:Xe[1],margin:qe,dimension:null!==(u=null==Ce?void 0:Ce.dimension)&&void 0!==u?u:"xy",scales:nt,onBrush:null!=Be?Be:()=>{}}),(null==Fe?void 0:Fe.showBadge)&&e.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===Fe.badgePosition?{top:4,left:4}:"bottom-left"===Fe.badgePosition?{bottom:4,left:4}:"bottom-right"===Fe.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:at?"#dc3545":"#28a745",color:"white"})},at?"STALE":"LIVE"),Wt,Lt)});Ee.displayName="StreamXYFrame";const Se={category10:w,tableau10:L,set3:j,blues:N,reds:M,greens:O,oranges:S,purples:E,viridis:A,plasma:k},Oe=w;function Me(e,t,n){if("function"==typeof t)return t(e);const o=e[t];return n?n(o):Oe[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+""))%Oe.length]}function Ne(e,t,n="category10"){const o=Array.from(new Set(e.map(e=>e[t]))),i=o.every(e=>"number"==typeof e||!isNaN(Number(e)));if(Array.isArray(n))return m().domain(o).range(n).unknown("#999");const s=Se[n]||Se.category10;if(i&&"function"==typeof s)return e=>s(Number(e)/Math.max(...o.map(Number)));{const e=Array.isArray(s)?s:Oe;return m().domain(o).range(e).unknown("#999")}}function je(e,t,n=[3,20],o){let i;if(i="function"==typeof t?t(e):e[t],!o)return i;const[s,r]=o,[l,a]=n;return r===s?(l+a)/2:l+(i-s)/(r-s)*(a-l)}const Le=c(null);function We(e){return e?"string"==typeof e?{name:e}:e:null}function _e(e,t,n){return t?o=>{var i;const s=Object.assign({},e(o));if(t.isActive)if(t.predicate(o))(null==n?void 0:n.selectedStyle)&&Object.assign(s,n.selectedStyle);else{const e=null!==(i=null==n?void 0:n.unselectedOpacity)&&void 0!==i?i:.2;s.opacity=e,s.fillOpacity=e,s.strokeOpacity=e,(null==n?void 0:n.unselectedStyle)&&Object.assign(s,n.unselectedStyle)}return s}:e}function $e(t){const o=c(null),s=Ce(t);return[function({children:n}){const s=i(()=>Ce(t),[]);return e.createElement(o.Provider,{value:s,children:n})},e=>{var t;const i=null!==(t=a(o))&&void 0!==t?t:s;return function(e,t){const[o,i]=n(t);return h(()=>e(()=>i(t)),[e]),o}(i.subscribe,()=>e(i.getState()))}]}function Ce(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 Be(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,i]=o.range;t.push(t=>{const o=t[n];return o>=e&&i>=o})}return e=>t.every(t=>t(e))}function He(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}const[ze,Te]=$e(e=>({selections:new Map,setClause(t,n){e(e=>{const o=new Map(e.selections),i=He(o,t),s=new Map(i.clauses);return s.set(n.clientId,n),o.set(t,Object.assign(Object.assign({},i),{clauses:s})),{selections:o}})},clearClause(t,n){e(e=>{const o=e.selections.get(t);if(!o)return{};const i=new Map(e.selections),s=new Map(o.clauses);return s.delete(n),i.set(t,Object.assign(Object.assign({},o),{clauses:s})),{selections:i}})},setResolution(t,n){e(e=>{const o=new Map(e.selections),i=He(o,t);return o.set(t,Object.assign(Object.assign({},i),{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 Fe(e){const t=u(),n=e.clientId||t,{name:o}=e,s=Te(e=>e.selections.get(o)),l=Te(e=>e.setClause),a=Te(e=>e.clearClause),c=i(()=>!!s&&s.clauses.size>0,[s]);return{predicate:i(()=>s&&0!==s.clauses.size?function(e,t){const n=[];for(const[o,i]of e.clauses)"crossfilter"===e.resolution&&o===t||n.push(Be(i));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(s,n):()=>!0,[s,n]),isActive:c,selectPoints:r(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"point",values:new Set(o)};l(o,{clientId:n,type:"point",fields:t})},[n,o,l]),selectInterval:r(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"interval",range:o};l(o,{clientId:n,type:"interval",fields:t})},[n,o,l]),clear:r(()=>{a(o,n)},[a,o,n]),clientId:n}}function Pe(e){const{name:t,xField:n,yField:o}=e,{predicate:s,isActive:l,selectInterval:a,clear:c}=Fe({name:t}),h=n&&o?"xyBrush":n?"xBrush":"yBrush",u=r(e=>{if(!e)return void c();const t={};"xyBrush"===h&&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"===h&&Array.isArray(e)?n&&(t[n]=[Math.min(...e),Math.max(...e)]):"yBrush"===h&&Array.isArray(e)&&o&&(t[o]=[Math.min(...e),Math.max(...e)]),Object.keys(t).length>0&&a(t)},[h,n,o,a,c]);return{brushInteraction:i(()=>({brush:h,during:u,end:u}),[h,u]),predicate:s,isActive:l,clear:c}}const[Ie,De]=$e(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}))}})),Ge="#007bff";function Re(e){return"function"==typeof e?e:t=>t[e]}function Ye(e,t,n="category10"){const o=a(Le);return i(()=>{if(t&&"function"!=typeof t)return o&&Object.keys(o).length>0?i=>o[i]||Ne(e,t,n)(i):Ne(e,t,n)},[e,t,n,o])}function Xe({selection:e,linkedHover:t,fallbackFields:n=[],unwrapData:o=!1,onObservation:i,chartType:s,chartId:l}){const a=function(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields}:null}(t,n),c=Fe({name:(null==e?void 0:e.name)||"__unused__"}),h=function(e){const t=e.name||"hover",{fields:n}=e,{predicate:o,isActive:i,selectPoints:s,clear:l}=Fe({name:t});return{onHover:r(e=>{if(!e)return void l();const t={};for(const o of n){const n=e[o];void 0!==n&&(t[o]=[n])}Object.keys(t).length>0&&s(t)},[n,s,l,t]),predicate:o,isActive:i}}({name:(null==a?void 0:a.name)||"hover",fields:(null==a?void 0:a.fields)||n||[]}),u=De(e=>e.pushObservation),d=e?{isActive:c.isActive,predicate:c.predicate}:null,f=r(e=>{var n,o;if(t)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]),h.onHover(t)}else h.onHover(null);if(i||u){const t={timestamp:Date.now(),chartType:s||"unknown",chartId:l};if(e){let s=e.data||e.datum||e;Array.isArray(s)&&(s=s[0]);const r=Object.assign(Object.assign({},t),{type:"hover",datum:s||{},x:null!==(n=e.x)&&void 0!==n?n:0,y:null!==(o=e.y)&&void 0!==o?o:0});i&&i(r),u&&u(r)}else{const e=Object.assign(Object.assign({},t),{type:"hover-end"});i&&i(e),u&&u(e)}}},[t,h,i,s,l,u]),p=r(e=>{var t,n;if(i||u){const o={timestamp:Date.now(),chartType:s||"unknown",chartId:l};if(e){let s=e.data||e.datum||e;Array.isArray(s)&&(s=s[0]);const r=Object.assign(Object.assign({},o),{type:"click",datum:s||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0});i&&i(r),u&&u(r)}else{const e=Object.assign(Object.assign({},o),{type:"click-end"});i&&i(e),u&&u(e)}}},[i,u,s,l]);return{activeSelectionHook:d,customHoverBehavior:f,customClickBehavior:p}}function qe({data:e,colorBy:t,colorScale:n,showLegend:o,userMargin:s,defaults:r={top:50,bottom:60,left:70,right:40}}){const l=void 0!==o?o:!!t,a=i(()=>{if(l&&t)return function({data:e,colorBy:t,colorScale:n,getColor:o,strokeColor:i,strokeWidth:s}){return{legendGroups:[{styleFn:e=>{const t={fill:e.color,stroke:e.color};return void 0!==i&&(t.stroke=i),void 0!==s&&(t.strokeWidth=s),t},type:"fill",items:Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t]))).map(i=>{const s=e.find("function"==typeof t?e=>t(e)===i:e=>e[t]===i),r=s?o(s,t,n):n?n(i):"#000000";return{label:i+"",color:r}}),label:""}]}}({data:e,colorBy:t,colorScale:n,getColor:Me})},[l,t,e,n]),c=i(()=>{const e=Object.assign(Object.assign({},r),s);return a&&120>e.right&&(e.right=120),e},[r,s,a]);return{legend:a,margin:c}}const Ve={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 Ue(e,t,n){var o,i,s,r,l,a;const c=Ve[e||"primary"],h="context"===e||"sparkline"===e;return{width:null!==(o=t.width)&&void 0!==o?o:c.width,height:null!==(i=t.height)&&void 0!==i?i:c.height,showAxes:c.showAxes,showGrid:null!==(s=t.showGrid)&&void 0!==s?s:c.showGrid,enableHover:null!==(r=t.enableHover)&&void 0!==r?r:!!t.linkedHover||c.enableHover,showLegend:null!==(l=t.showLegend)&&void 0!==l?l:c.showLegend,showLabels:null!==(a=t.showLabels)&&void 0!==a?a:c.showLabels,title:h?void 0:t.title,xLabel:h?void 0:t.xLabel,yLabel:h?void 0:t.yLabel,categoryLabel:h?void 0:t.categoryLabel,valueLabel:h?void 0:t.valueLabel,marginDefaults:c.marginDefaults}}const Ze={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 Je(e,t){return"function"==typeof t?t(e):e[t]}function Ke(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 Qe(t){return!0===t||("function"==typeof t?t:!1!==t&&void 0!==t&&("object"!=typeof t||null===t||!("fields"in t)&&!("title"in t)||function(t={}){const{fields:n,title:o,format:i,style:s={},className:r=""}=t;return t=>{if(!t||"object"!=typeof t)return null;let l;const a=[];if(o){const e=Je(t,o);l=Ke(e,i)}if(n&&n.length>0)n.forEach(e=>{let n,o,s;"string"==typeof e?(n=e,o=e,s=i):(n=e.label,o=e.accessor||e.key||"",s=e.format||i);const r=Je(t,o);a.push({label:n,value:Ke(r,s)})});else if(!o){const e=["value","y","name","id","label"];for(const n of e)if(void 0!==t[n]){l=Ke(t[n],i);break}if(!l){const e=Object.keys(t).filter(e=>!e.startsWith("_"));e.length>0&&(l=Ke(t[e[0]],i))}}const c=Object.assign(Object.assign({},Ze),s);return e.createElement("div",{className:("semiotic-tooltip "+r).trim(),style:c},l&&e.createElement("div",{style:{fontWeight:a.length>0?"bold":"normal"}},l),a.map((t,n)=>e.createElement("div",{key:n,style:{marginTop:0===n&&l?"4px":0}},t.label&&e.createElement("span",null,t.label,": "),t.value)))}}(t)))}function et(e){return"string"==typeof e?e:"value"}function tt(t){return n=>{const o=n.data;return o?e.createElement("div",{className:"semiotic-tooltip",style:Ze},t.map((t,n)=>{const i=function(e,t){return"function"==typeof t?t(e):e[t]}(o,t.accessor),s=null==(r=i)?"–":"number"==typeof r?Math.abs(r)>9999?r.toLocaleString():r+"":r instanceof Date?r.toLocaleDateString():r+"";var r;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"}},s))})):null}}function nt({componentName:t,message:n,width:o,height:i}){return e.createElement("div",{role:"alert",style:{width:o,height:Math.max(i,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 ot 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(nt,{componentName:"ChartErrorBoundary",message:n.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}var it;const st="undefined"!=typeof process&&"production"!==(null===(it=process.env)||void 0===it?void 0:it.NODE_ENV);function rt({componentName:t,width:n,height:o,children:i}){return e.createElement(ot,{fallback:i=>e.createElement(nt,{componentName:t,message:i.message,width:n,height:o})},i)}function lt(e,t,n,o){if(!st)return;if(!t||0===t.length)return;if("string"!=typeof o)return;const i=t[0];if(!i||"object"!=typeof i)return;if(o in i)return;const s=Object.keys(i).join(", ");console.warn(`[semiotic] ${e}: ${n} "${o}" not found in data. Available keys: ${s}`)}function at(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 ct({componentName:e,data:t,accessors:n,requiredProps:o}){if(o)for(const[t,n]of Object.entries(o))if(null==n)return`${e}: ${t} is required. Provide a field name or function.`;if(!t||!Array.isArray(t)||0===t.length)return e+": No data provided. Pass a non-empty array to the data prop.";if(!Array.isArray(t)&&"object"==typeof t)return e+": data should be an array, but received an object. If this is hierarchical data, use TreeDiagram, Treemap, or CirclePack instead.";if(n){const o=function(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:e}(t).find(e=>e&&"object"==typeof e);if(o){const t=Object.keys(o);for(const[i,s]of Object.entries(n))if(s&&"string"==typeof s&&!(s in o)){const n=at(s,t),o=n?` Try ${i}="${n}".`:"";return`${e}: ${i} "${s}" not found in data. Available fields: ${t.join(", ")}.${o}`}}}return null}const ht="__forecastSegment";function ut(e,t){return"function"==typeof t?t(e):!!e[t]}function dt(t){var n,o;const s=Ue(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:r,margin:l,className:a,xFormat:c,yFormat:h,xAccessor:u="x",yAccessor:d="y",lineBy:f,lineDataAccessor:p="coordinates",colorBy:y,colorScheme:g="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:M,frameProps:N={},selection:j,linkedHover:L,onObservation:W,chartId:_}=t,$=s.width,C=s.height,B=s.enableHover,H=s.showGrid,z=s.showLegend,T=s.title,F=s.xLabel,P=s.yLabel,I=r||[];lt("LineChart",I,"xAccessor",u),lt("LineChart",I,"yAccessor",d);const D="string"==typeof u?u:"x",G="string"==typeof d?d:"y",R=i(()=>M?function(e,t,n,o,i){return(s=o).isTraining||s.isForecast||s.isAnomaly||s.upperBounds||s.lowerBounds?function(e,t,n,o,i){var s,r,l;const{isTraining:a,isForecast:c,isAnomaly:h,upperBounds:u,lowerBounds:d,color:f="#6366f1",bandOpacity:p=.15,anomalyColor:y="#ef4444",anomalyRadius:g=6,label:m}=o,v=e.map(e=>{let t="observed";return c&&ut(e,c)?t="forecast":a&&ut(e,a)&&(t="training"),Object.assign(Object.assign({},e),{[ht]:t})}),b=[];if(u&&d){const e="string"==typeof u?u:"__envUpper",t="string"==typeof d?d:"__envLower";if("function"==typeof u||"function"==typeof d)for(const n of v)"function"==typeof u&&(n[e]=u(n)),"function"==typeof d&&(n[t]=d(n));b.push({type:"envelope",upperAccessor:e,lowerAccessor:t,fill:f,fillOpacity:p,label:m})}return h&&b.push({type:"highlight",filter:e=>ut(e,h),color:y,r:g,style:{stroke:y,strokeWidth:1.5,fill:y,fillOpacity:.7}}),i&&b.push({type:"anomaly-band",threshold:null!==(s=i.threshold)&&void 0!==s?s:2,showBand:!1!==i.showBand,fill:i.bandColor||"#6366f1",fillOpacity:null!==(r=i.bandOpacity)&&void 0!==r?r:.1,anomalyColor:i.anomalyColor||"#ef4444",anomalyRadius:null!==(l=i.anomalyRadius)&&void 0!==l?l:6,label:i.label}),{processedData:v,annotations:b}}(e,0,0,o,i):function(e,t,n,o,i){var s,r,l;const{trainEnd:a,steps:c=10,confidence:h=.95,color:u="#6366f1",bandOpacity:d=.15,label:f}=o;if(null==a)return{processedData:e,annotations:[]};const p=[],y=[];for(const n of e)n[t]>a?y.push(Object.assign(Object.assign({},n),{[ht]:"observed"})):p.push(Object.assign(Object.assign({},n),{[ht]:"training"}));const g=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(g.length>=3){const o=g.length;let i=0,s=0,r=0,l=0;for(const[e,t]of g)i+=e,s+=t,r+=e*e,l+=e*t;const a=o*r-i*i;if(Math.abs(a)>1e-12){const r=(o*l-i*s)/a,p=(s-r*i)/o,y=e=>p+r*e,b=g.map(([e,t])=>t-y(e)).reduce((e,t)=>e+t*t,0),x=Math.sqrt(b/Math.max(o-2,1)),w=g.reduce((e,t)=>e+t[0],0)/o,k=g.reduce((e,t)=>e+Math.pow(t[0]-w,2),0),A=.99>h?.95>h?.9>h?1:1.645:1.96:2.576,E=e.map(e=>e[t]).filter(e=>null!=e&&isFinite(e)),S=Math.max(...E),O=g.length>1?(g[o-1][0]-g[0][0])/(o-1):1;for(let e=1;c>=e;e++){const i=S+e*O,s=y(i),r=x*Math.sqrt(1+1/o+(k>0?Math.pow(i-w,2)/k:0))*A;v.push({[t]:i,[n]:s,[ht]:"forecast",__forecastUpper:s+r,__forecastLower:s-r})}m.push({type:"envelope",upperAccessor:"__forecastUpper",lowerAccessor:"__forecastLower",fill:u,fillOpacity:d,label:f})}}return m.push({type:"x-threshold",x:a,color:"#94a3b8",strokeWidth:1,strokeDasharray:"4,2",label:"Train / Forecast"}),i&&m.push({type:"anomaly-band",threshold:null!==(s=i.threshold)&&void 0!==s?s:2,showBand:!1!==i.showBand,fill:i.bandColor||"#6366f1",fillOpacity:null!==(r=i.bandOpacity)&&void 0!==r?r:.1,anomalyColor:i.anomalyColor||"#ef4444",anomalyRadius:null!==(l=i.anomalyRadius)&&void 0!==l?l:6,label:i.label}),{processedData:[...p,...y,...v],annotations:m}}(e,t,n,o,i);var s}(I,D,G,M,O):null,[I,M,O,D,G]),Y=i(()=>R?R.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):[],[R,O]),X=R?R.processedData:I,q=M&&!f?ht:f,{activeSelectionHook:V,customHoverBehavior:U}=Xe({selection:j,linkedHover:L,fallbackFields:y?["string"==typeof y?y:""]:[],onObservation:W,chartType:"LineChart",chartId:_}),Z=void 0!==(null===(n=X[0])||void 0===n?void 0:n[p]),J=i(()=>{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=Ye(X,y,g),Q=i(()=>e=>{const t={strokeWidth:k};return t.stroke=y?Me(e,y,K):Ge,x&&(t.fill=t.stroke,t.fillOpacity=w),t},[y,K,k,x,w]),ee=i(()=>M?function(e,t){var n,o;const i=null!==(n=t.trainDasharray)&&void 0!==n?n:"8,4",s=null!==(o=t.forecastDasharray)&&void 0!==o?o:"4,4",r=t.color||"#6366f1";return t=>{const n=e(t),o=t[ht];return"training"===o?Object.assign(Object.assign({},n),{strokeDasharray:i}):"forecast"===o?Object.assign(Object.assign({},n),{stroke:r,strokeDasharray:s}):n}}(Q,M):Q,[Q,M]),te=i(()=>_e(ee,V,j),[ee,V,j]),ne=i(()=>{if(v)return e=>{const t={r:b,fillOpacity:1};return t.fill=y?Me(e.parentLine||e,y,K):Ge,t}},[v,b,y,K]),oe=x?"area":"line",{legend:ie,margin:se}=qe({data:J,colorBy:y,colorScale:K,showLegend:z,userMargin:l,defaults:s.marginDefaults}),re=f||y,le=i(()=>tt([{label:F||et(u),accessor:u,role:"x"},{label:P||et(d),accessor:d,role:"y"},...re?[{label:et(re),accessor:re,role:"group"}]:[]]),[u,d,F,P,re]),ae=ct({componentName:"LineChart",data:Z?(null===(o=X[0])||void 0===o?void 0:o[p])||[]:I,accessors:{xAccessor:u,yAccessor:d}});if(ae)return e.createElement(nt,{componentName:"LineChart",message:ae,width:$,height:C});const ce=i(()=>Z||q?J.flatMap(e=>{const t=e[p]||[];return q&&"string"==typeof q?t.map(t=>Object.assign(Object.assign({},t),{[q]:e[q]})):t}):X,[J,p,Z,q,X]),he=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:u,yAccessor:d,groupAccessor:q||void 0,curve:m,lineStyle:te},v&&{pointStyle:ne}),{size:[$,C],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:se,showAxes:s.showAxes,xLabel:F,yLabel:P,xFormat:c,yFormat:h,enableHover:B,showGrid:H}),ie&&{legend:ie}),T&&{title:T}),a&&{className:a}),{tooltipContent:A?Qe(A):le}),(L||W)&&{customHoverBehavior:U}),E&&{pointIdAccessor:E}),((null==S?void 0:S.length)||Y.length)&&{annotations:[...S||[],...Y]}),N);return e.createElement(rt,{componentName:"LineChart",width:$,height:C},e.createElement(Ee,Object.assign({},he)))}function ft(t){var n;const o=Ue(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:s,margin:r,className:l,xFormat:a,yFormat:c,xAccessor:h="x",yAccessor:u="y",areaBy:d,y0Accessor:f,gradientFill:p=!1,lineDataAccessor:y="coordinates",colorBy:g,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:M,chartId:N}=t,j=o.width,L=o.height,W=o.enableHover,_=o.showGrid,$=o.showLegend,C=o.title,B=o.xLabel,H=o.yLabel,z=s||[];lt("AreaChart",z,"xAccessor",h),lt("AreaChart",z,"yAccessor",u);const{activeSelectionHook:T,customHoverBehavior:F}=Xe({selection:S,linkedHover:O,fallbackFields:g?["string"==typeof g?g:""]:[],onObservation:M,chartType:"AreaChart",chartId:N}),P=void 0!==(null===(n=z[0])||void 0===n?void 0:n[y]),I=i(()=>{if(P)return z;if(d){const e=z.reduce((e,t)=>{const n="function"==typeof d?d(t):t[d];if(!e[n]){const t={[y]:[]};"string"==typeof d&&(t[d]=n),e[n]=t}return e[n][y].push(t),e},{});return Object.values(e)}return[{[y]:z}]},[z,d,y,P]),D=Ye(z,g,m),G=i(()=>e=>{const t={},n=g?Me(e,g,D):Ge;return t.fill=n,t.fillOpacity=b,x?(t.stroke=n,t.strokeWidth=w):t.stroke="none",t},[g,D,b,x,w]),R=i(()=>_e(G,T,S),[G,T,S]),{legend:Y,margin:X}=qe({data:I,colorBy:g,colorScale:D,showLegend:$,userMargin:r,defaults:o.marginDefaults}),q=d||g,V=i(()=>tt([{label:B||et(h),accessor:h,role:"x"},{label:H||et(u),accessor:u,role:"y"},...q?[{label:et(q),accessor:q,role:"group"}]:[]]),[h,u,B,H,q]),U=ct({componentName:"AreaChart",data:z,accessors:{xAccessor:h,yAccessor:u}});if(U)return e.createElement(nt,{componentName:"AreaChart",message:U,width:j,height:L});const Z=i(()=>P||d?I.flatMap(e=>{const t=e[y]||[];return d&&"string"==typeof d?t.map(t=>Object.assign(Object.assign({},t),{[d]:e[d]})):t}):z,[I,y,P,d,z]),J=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"area",data:Z,xAccessor:h,yAccessor:u,groupAccessor:d||void 0},f&&{y0Accessor:f}),p&&{gradientFill:p}),{curve:v,lineStyle:R,size:[j,L],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:X,showAxes:o.showAxes,xLabel:B,yLabel:H,xFormat:a,yFormat:c,enableHover:W,showGrid:_}),Y&&{legend:Y}),C&&{title:C}),l&&{className:l}),{tooltipContent:k?Qe(k):V}),(O||M)&&{customHoverBehavior:F}),A&&A.length>0&&{annotations:A}),E);return e.createElement(rt,{componentName:"AreaChart",width:j,height:L},e.createElement(Ee,Object.assign({},J)))}function pt(t){var n;const o=Ue(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:s,margin:r,className:l,xFormat:a,yFormat:c,xAccessor:h="x",yAccessor:u="y",areaBy:d,lineDataAccessor:f="coordinates",colorBy:p,colorScheme:y="category10",curve:g="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:M}=t,N=o.width,j=o.height,L=o.enableHover,W=o.showGrid,_=o.showLegend,$=o.title,C=o.xLabel,B=o.yLabel,H=s||[],{activeSelectionHook:z,customHoverBehavior:T}=Xe({selection:E,linkedHover:S,fallbackFields:p?["string"==typeof p?p:""]:[],onObservation:O,chartType:"StackedAreaChart",chartId:M}),F=void 0!==(null===(n=H[0])||void 0===n?void 0:n[f]),P=i(()=>{if(F)return H;if(d){const e=H.reduce((e,t)=>{const n="function"==typeof d?d(t):t[d];if(!e[n]){const t={[f]:[]};"string"==typeof d&&(t[d]=n),e[n]=t}return e[n][f].push(t),e},{});return Object.values(e)}return[{[f]:H}]},[H,d,f,F]),I=Ye(H,p,y),D=i(()=>e=>{const t={},n=p?Me(e,p,I):Ge;return t.fill=n,t.fillOpacity=m,v?(t.stroke=n,t.strokeWidth=b):t.stroke="none",t},[p,I,m,v,b]),G=i(()=>_e(D,z,E),[D,z,E]),{legend:R,margin:Y}=qe({data:P,colorBy:p,colorScale:I,showLegend:_,userMargin:r,defaults:o.marginDefaults}),X=d||p,q=i(()=>tt([{label:C||et(h),accessor:h,role:"x"},{label:B||et(u),accessor:u,role:"y"},...X?[{label:et(X),accessor:X,role:"group"}]:[]]),[h,u,C,B,X]),V=ct({componentName:"StackedAreaChart",data:H,accessors:{xAccessor:h,yAccessor:u}});if(V)return e.createElement(nt,{componentName:"StackedAreaChart",message:V,width:N,height:j});const U=i(()=>F||d?P.flatMap(e=>{const t=e[f]||[];return d&&"string"==typeof d?t.map(t=>Object.assign(Object.assign({},t),{[d]:e[d]})):t}):H,[P,f,F,d,H]),Z=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"stackedarea",data:U,xAccessor:h,yAccessor:u,groupAccessor:d||void 0,curve:g,normalize:x,lineStyle:G,size:[N,j],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Y,showAxes:o.showAxes,xLabel:C,yLabel:B,xFormat:a,yFormat:c,enableHover:L,showGrid:W},R&&{legend:R}),$&&{title:$}),l&&{className:l}),{tooltipContent:w?Qe(w):q}),(S||O)&&{customHoverBehavior:T}),k&&k.length>0&&{annotations:k}),A);return e.createElement(rt,{componentName:"StackedAreaChart",width:N,height:j},e.createElement(Ee,Object.assign({},Z)))}function yt(t){const n=Ue(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:o,margin:s,className:r,xFormat:l,yFormat:a,xAccessor:c="x",yAccessor:h="y",colorBy:u,colorScheme:d="category10",sizeBy:f,sizeRange:p=[3,15],pointRadius:y=5,pointOpacity:g=.8,tooltip:m,marginalGraphics:v,pointIdAccessor:b,annotations:x,frameProps:w={},selection:k,linkedHover:A,linkedBrush:E,onObservation:S,chartId:O}=t,M=n.width,N=n.height,j=n.enableHover,L=n.showGrid,W=n.showLegend,_=n.title,$=n.xLabel,C=n.yLabel,B=o||[];lt("Scatterplot",B,"xAccessor",c),lt("Scatterplot",B,"yAccessor",h);const{activeSelectionHook:H,customHoverBehavior:z}=Xe({selection:k,linkedHover:A,fallbackFields:u?["string"==typeof u?u:""]:[],onObservation:S,chartType:"Scatterplot",chartId:O}),T=We(E);Pe({name:(null==T?void 0:T.name)||"__unused_brush__",xField:(null==T?void 0:T.xField)||("string"==typeof c?c:void 0),yField:(null==T?void 0:T.yField)||("string"==typeof h?h:void 0)});const F=Ye(B,u,d),P=i(()=>{if(!f||0===B.length)return;const e=B.map(e=>"function"==typeof f?f(e):e[f]);return[Math.min(...e),Math.max(...e)]},[B,f]),I=i(()=>e=>{const t={fillOpacity:g};return t.fill=u?Me(e,u,F):Ge,t.r=f?je(e,f,p,P):y,t},[u,F,f,p,P,y,g]),D=i(()=>_e(I,H,k),[I,H,k]),{legend:G,margin:R}=qe({data:B,colorBy:u,colorScale:F,showLegend:W,userMargin:s,defaults:n.marginDefaults}),Y=i(()=>tt([{label:$||et(c),accessor:c,role:"x"},{label:C||et(h),accessor:h,role:"y"},...u?[{label:et(u),accessor:u,role:"color"}]:[],...f?[{label:et(f),accessor:f,role:"size"}]:[]]),[c,h,$,C,u,f]),X=ct({componentName:"Scatterplot",data:B,accessors:{xAccessor:c,yAccessor:h}});if(X)return e.createElement(nt,{componentName:"Scatterplot",message:X,width:M,height:N});const q=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter",data:B,xAccessor:c,yAccessor:h,colorAccessor:u||void 0,sizeAccessor:f||void 0,sizeRange:p,pointStyle:D,colorScheme:d,size:[M,N],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:R,showAxes:n.showAxes,xLabel:$,yLabel:C,xFormat:l,yFormat:a,enableHover:j,showGrid:L},G&&{legend:G}),_&&{title:_}),r&&{className:r}),{tooltipContent:m?Qe(m):Y}),(A||S)&&{customHoverBehavior:z}),v&&{marginalGraphics:v}),b&&{pointIdAccessor:b}),x&&x.length>0&&{annotations:x}),w);return e.createElement(rt,{componentName:"Scatterplot",width:M,height:N},e.createElement(Ee,Object.assign({},q)))}function gt(t){const n=Ue(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:o,className:s,xFormat:r,yFormat:l,xAccessor:a="x",yAccessor:c="y",orderAccessor:h,orderLabel:u,pointRadius:d=4,tooltip:f,pointIdAccessor:p,annotations:y,frameProps:g={},selection:m,linkedHover:v,onObservation:b,chartId:x}=t,w=n.width,k=n.height,E=n.enableHover,S=n.showGrid,O=n.title,M=n.xLabel,N=n.yLabel,j=o||[],L=i(()=>{if(!h||0===j.length)return j;const e="function"==typeof h?h:e=>e[h];return[...j].sort((t,n)=>{const o=e(t),i=e(n);return(o instanceof Date?o.getTime():+o)-(i instanceof Date?i.getTime():+i)})},[j,h]);lt("ConnectedScatterplot",L,"xAccessor",a),lt("ConnectedScatterplot",L,"yAccessor",c);const{activeSelectionHook:W,customHoverBehavior:_}=Xe({selection:m,linkedHover:v,fallbackFields:[],onObservation:b,chartType:"ConnectedScatterplot",chartId:x}),$=L.length,C=$>0&&100>$,B=i(()=>0===$?[]:L.map((e,t)=>A(1===$?.5:t/($-1))),[L,$]);i(()=>null,[$]);const H=i(()=>{if($>=2)return(t,n,o)=>{var i,s;if("connected-lines"!==t.type)return null;const r=o.scales;if(!r)return null;const l=null!==(i=r.x)&&void 0!==i?i:r.time,h=null!==(s=r.y)&&void 0!==s?s:r.value;if(!l||!h)return null;const u="string"==typeof a?e=>e[a]:a,f="string"==typeof c?e=>e[c]:c,p=[];for(let t=0;L.length-1>t;t++){const n=L[t],o=L[t+1],i=l(u(n)),s=h(f(n)),r=l(u(o)),a=h(f(o)),c=B[t];C&&p.push(e.createElement("line",{key:"halo-"+t,x1:i,y1:s,x2:r,y2:a,stroke:"white",strokeWidth:d+2,strokeOpacity:.5,strokeLinecap:"round"})),p.push(e.createElement("line",{key:"conn-"+t,x1:i,y1:s,x2:r,y2:a,stroke:c,strokeWidth:d,strokeLinecap:"round"}))}return e.createElement("g",{key:"ann-"+n},p)}},[L,B,d,C,a,c,$]),z=i(()=>e=>{const t=L.indexOf(e);return{fill:t>=0&&B.length>t?B[t]:"#6366f1",stroke:"white",strokeWidth:1,r:d,fillOpacity:1}},[L,B,d]),T=i(()=>_e(z,W,m),[z,W,m]),F=Object.assign({top:50,right:40,bottom:60,left:70},t.margin),P=u||("string"==typeof h?h:"Order"),I=i(()=>tt([{label:M||et(a),accessor:a,role:"x"},{label:N||et(c),accessor:c,role:"y"},...h?[{label:P,accessor:h,role:"group"}]:[]]),[a,c,M,N,h,P]),D=ct({componentName:"ConnectedScatterplot",data:L,accessors:{xAccessor:a,yAccessor:c}});if(D)return e.createElement(nt,{componentName:"ConnectedScatterplot",message:D,width:w,height:k});const G=i(()=>[{type:"connected-lines"},...y||[]],[y]),R=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter",data:L,xAccessor:a,yAccessor:c,pointStyle:T,size:[w,k],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:F,showAxes:n.showAxes,xLabel:M,yLabel:N,xFormat:r,yFormat:l,enableHover:E,showGrid:S},O&&{title:O}),s&&{className:s}),{tooltipContent:f?Qe(f):I}),(v||b)&&{customHoverBehavior:_}),p&&{pointIdAccessor:p}),{annotations:G,svgAnnotationRules:H}),g);return e.createElement(rt,{componentName:"ConnectedScatterplot",width:w,height:k},e.createElement(Ee,Object.assign({},R)))}function mt(t){const n=Ue(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:o,margin:s,className:r,xFormat:l,yFormat:a,xAccessor:c="x",yAccessor:h="y",sizeBy:u,sizeRange:d=[5,40],colorBy:f,colorScheme:p="category10",bubbleOpacity:y=.6,bubbleStrokeWidth:g=1,bubbleStrokeColor:m="white",tooltip:v,marginalGraphics:b,pointIdAccessor:x,annotations:w,frameProps:k={},selection:A,linkedHover:E,linkedBrush:S,onObservation:O,chartId:M}=t,N=n.width,j=n.height,L=n.enableHover,W=n.showGrid,_=n.showLegend,$=n.title,C=n.xLabel,B=n.yLabel,H=o||[],{activeSelectionHook:z,customHoverBehavior:T}=Xe({selection:A,linkedHover:E,fallbackFields:f?["string"==typeof f?f:""]:[],onObservation:O,chartType:"BubbleChart",chartId:M}),F=We(S);Pe({name:(null==F?void 0:F.name)||"__unused_brush__",xField:(null==F?void 0:F.xField)||("string"==typeof c?c:void 0),yField:(null==F?void 0:F.yField)||("string"==typeof h?h:void 0)});const P=Ye(H,f,p),I=i(()=>{const e=H.map(e=>"function"==typeof u?u(e):e[u]);return[Math.min(...e),Math.max(...e)]},[H,u]),D=i(()=>e=>{const t={fillOpacity:y,strokeWidth:g,stroke:m};return t.fill=f?Me(e,f,P):Ge,t.r=je(e,u,d,I),t},[f,P,u,d,I,y,g,m]),G=i(()=>_e(D,z,A),[D,z,A]),{legend:R,margin:Y}=qe({data:H,colorBy:f,colorScale:P,showLegend:_,userMargin:s,defaults:n.marginDefaults}),X=i(()=>tt([{label:C||et(c),accessor:c,role:"x"},{label:B||et(h),accessor:h,role:"y"},{label:et(u),accessor:u,role:"size"},...f?[{label:et(f),accessor:f,role:"color"}]:[]]),[c,h,C,B,u,f]),q=ct({componentName:"BubbleChart",data:H,accessors:{xAccessor:c,yAccessor:h},requiredProps:{sizeBy:u}});if(q)return e.createElement(nt,{componentName:"BubbleChart",message:q,width:N,height:j});const V=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bubble",data:H,xAccessor:c,yAccessor:h,colorAccessor:f||void 0,sizeAccessor:u,sizeRange:d,pointStyle:G,colorScheme:p,size:[N,j],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Y,showAxes:n.showAxes,xLabel:C,yLabel:B,xFormat:l,yFormat:a,enableHover:L,showGrid:W},R&&{legend:R}),$&&{title:$}),r&&{className:r}),{tooltipContent:v?Qe(v):X}),(E||O)&&{customHoverBehavior:T}),b&&{marginalGraphics:b}),x&&{pointIdAccessor:x}),w&&w.length>0&&{annotations:w}),k);return e.createElement(rt,{componentName:"BubbleChart",width:N,height:j},e.createElement(Ee,Object.assign({},V)))}function vt(t){const n=Ue(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:s,className:r,xAccessor:l="x",yAccessor:a="y",valueAccessor:c="value",xFormat:h,yFormat:u,colorScheme:d="blues",customColorScale:f,showValues:p=!1,valueFormat:y,cellBorderColor:g="#fff",cellBorderWidth:m=1,tooltip:b,annotations:x,frameProps:w={},selection:k,linkedHover:E,onObservation:S,chartId:j}=t,L=n.width,W=n.height,_=n.enableHover,$=n.title,C=n.xLabel,B=n.yLabel,H=o||[],{margin:z}=qe({data:H,colorBy:void 0,colorScale:void 0,showLegend:!1,userMargin:s,defaults:n.marginDefaults}),{activeSelectionHook:T,customHoverBehavior:F}=Xe({selection:k,linkedHover:E,fallbackFields:[],onObservation:S,chartType:"Heatmap",chartId:j}),P=i(()=>"function"==typeof c?e=>c(e):e=>e[c],[c]),I=i(()=>{const e=H.map(P);return[Math.min(...e),Math.max(...e)]},[H,P]),D=i(()=>"custom"===d&&f?f:v({blues:N,reds:M,greens:O,viridis:A}[d]||N).domain(I),[d,f,I]);i(()=>{const e=Re(l),t=Re(a);return{xBinCount:new Set(H.map(e)).size,yBinCount:new Set(H.map(t)).size}},[H,l,a]),i(()=>({coordinates:H}),[H]);const G=i(()=>e=>{const t=P(e);return{fill:D(t),stroke:g,strokeWidth:m}},[P,D,g,m]);i(()=>_e(G,T,k),[G,T,k]),i(()=>{if(!p)return;const t=(I[0]+I[1])/2;return(n,o)=>{const i=P(n),s=y?y(i):i+"";return e.createElement("text",{textAnchor:"middle",dominantBaseline:"middle",fill:P(n)>t?"#fff":"#000",fontSize:"12px"},s)}},[p,P,y,I]);const R=i(()=>tt([{label:C||et(l),accessor:l,role:"x"},{label:B||et(a),accessor:a,role:"y"},{label:et(c),accessor:c,role:"value"}]),[l,a,C,B,c]),Y=ct({componentName:"Heatmap",data:H,accessors:{xAccessor:l,yAccessor:a,valueAccessor:c}});if(Y)return e.createElement(nt,{componentName:"Heatmap",message:Y,width:L,height:W});const X=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"heatmap",data:H,xAccessor:l,yAccessor:a,valueAccessor:c,size:[L,W],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:z,showAxes:n.showAxes,xLabel:C,yLabel:B,xFormat:h,yFormat:u,enableHover:_},$&&{title:$}),r&&{className:r}),{tooltipContent:b?Qe(b):R}),(E||S)&&{customHoverBehavior:F}),x&&x.length>0&&{annotations:x}),w);return e.createElement(rt,{componentName:"Heatmap",width:L,height:W},e.createElement(Ee,Object.assign({},X)))}function bt({selections:e}){const t=Te(e=>e.setResolution);return o(()=>{for(const[n,o]of Object.entries(e))o.resolution&&t(n,o.resolution)},[e,t]),null}function xt({children:t,selections:n}){return e.createElement(ze,null,e.createElement(Ie,null,n&&e.createElement(bt,{selections:n}),t))}dt.displayName="LineChart",ft.displayName="AreaChart",pt.displayName="StackedAreaChart",yt.displayName="Scatterplot",gt.displayName="ConnectedScatterplot",mt.displayName="BubbleChart",vt.displayName="Heatmap";const wt="__splomIdx",kt={top:4,bottom:4,left:4,right:4};function At({frameRef:n,cellSize:i,onBrush:s}){const r=t(null),l=i-kt.left-kt.right,a=i-kt.top-kt.bottom;return o(()=>{if(!r.current)return;const e=y(r.current).select(".brush-g"),t=p().extent([[0,0],[l,a]]).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 s(null);const[[i,r],[l,a]]=e.selection,c=[[o.x.invert(i),o.y.invert(r)],[o.x.invert(l),o.y.invert(a)]];s(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)}},[l,a,n,s]),e.createElement("svg",{ref:r,width:i,height:i,style:{position:"absolute",top:0,left:0}},e.createElement("g",{className:"brush-g",transform:`translate(${kt.left},${kt.top})`}))}function Et({data:n,xField:o,yField:i,cellSize:s,pointRadius:l,pointOpacity:a,colorBy:c,colorScale:h,brushSelectionName:u,hoverSelectionName:d,unselectedOpacity:f,mode:p,onPointHover:y}){const g=t(null),m=Fe({name:u,clientId:`splom-${o}-${i}`}),v=Pe({name:u,xField:o,yField:i}),b=Fe({name:d,clientId:"splom-hover-source"}),x=b.selectPoints,w=r(e=>{e?v.brushInteraction.during(e):v.brushInteraction.end(null)},[v.brushInteraction]),k=r(e=>{if(!e)return void(null==y||y(null));const t=e.data,n=null==t?void 0:t[wt];void 0!==n&&(x({[wt]:[n]}),null==y||y(t,e.x+kt.left,e.y+kt.top))},[x,y]),A=r(e=>{const t={opacity:a,r:l};return t.fill=c?Me(e,c,h):Ge,"hover"===p?b.isActive&&b.predicate(e)?(t.opacity=1,t.r=2.5*l,t.stroke="#333",t.strokeWidth=1.5):b.isActive&&(t.opacity=.6*a):m.isActive&&!m.predicate(e)&&(t.opacity=f),t},[c,h,a,l,p,m.isActive,m.predicate,b.isActive,b.predicate,f]);return e.createElement("div",{style:{position:"relative",width:s,height:s}},e.createElement(Ee,{ref:g,chartType:"scatter",data:n,size:[s,s],xAccessor:o,yAccessor:i,pointStyle:A,margin:kt,showAxes:!1,enableHover:"hover"===p,customHoverBehavior:"hover"===p?k:void 0,tooltipContent:"hover"===p?()=>null:void 0}),"brush"===p&&e.createElement(At,{frameRef:g,cellSize:s,xField:o,yField:i,onBrush:w}))}function St({data:t,field:n,label:o,cellSize:s,bins:r,brushSelectionName:l,hoverSelectionName:a,mode:c}){const h=Fe({name:l,clientId:"splom-diag-"+n}),u=Fe({name:a,clientId:`splom-diag-${n}-hover`}),d="hover"===c?u:h,f=d.isActive,p=d.predicate,y=i(()=>{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),i=(Math.max(...e)-o)/r||1,l=Array(r).fill(0),a=Array(r).fill(0);for(const e of t){const t=e[n];if(null==t||isNaN(t))continue;const s=Math.min(Math.floor((t-o)/i),r-1);l[s]++,f&&!p(e)||a[s]++}const c=Math.max(...l,1);return{bars:l.map((e,t)=>({x:t/r*s,w:s/r-1,h:e/c*(s-24),count:e})),selectedBars:a.map((e,t)=>({x:t/r*s,w:s/r-1,h:e/c*(s-24),count:e})),max:c}},[t,n,r,s,f,p]);return e.createElement("svg",{width:s,height:s,style:{overflow:"hidden"}},e.createElement("text",{x:s/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:s-t.h,width:Math.max(t.w,1),height:t.h,fill:"#ccc",opacity:f?.3:.6})),f&&y.selectedBars.map((t,n)=>e.createElement("rect",{key:"sel-"+n,x:t.x,y:s-t.h,width:Math.max(t.w,1),height:t.h,fill:Ge,opacity:.7})))}function Ot({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 Mt(t){const{data:o,fields:s,fieldLabels:l={},colorBy:a,colorScheme:c="category10",cellSize:h=150,cellGap:u=4,pointRadius:d=2,pointOpacity:f=.5,diagonal:p="histogram",histogramBins:y=20,brushMode:g="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",M="splom-hover",N=m?"hover":g?"brush":"hover",j=Te(e=>e.clearSelection),[L,W]=n(null),_=r(()=>{j(M),W(null)},[j,M]),$=i(()=>(o||[]).map((e,t)=>void 0!==e[wt]?e:Object.assign(Object.assign({},e),{[wt]:t})),[o]),C=Ye($,a,c),B=void 0!==w?w:!!a,H=i(()=>{if(!B||!a)return null;const e="string"==typeof a?a:null;return e?[...new Set($.map(t=>t[e]))].map(e=>({label:e+"",color:C?C(e+""):Ge})):null},[B,a,$,C]),z=i(()=>({display:"grid",gridTemplateColumns:"40px "+s.map(()=>h+"px").join(" "),gridTemplateRows:s.map(()=>h+"px").join(" ")+" 40px",gap:u+"px",width:"fit-content"}),[s,h,u,40]);return e.createElement("div",{className:A,style:{position:"relative"}},H&&e.createElement("div",{style:{display:"flex",gap:12,marginBottom:8,flexWrap:"wrap"}},H.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:z,onMouseLeave:"hover"===N?_:void 0},s.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"}},l[t]||t),s.map((o,i)=>n===i?"label"===p?e.createElement(Ot,{key:"diag-"+t,label:l[t]||t,cellSize:h}):e.createElement(St,{key:"diag-"+t,data:$,field:t,label:l[t]||t,cellSize:h,bins:y,colorBy:a,colorScale:C,brushSelectionName:O,hoverSelectionName:M,unselectedOpacity:v,mode:N}):e.createElement(Et,{key:`cell-${t}-${o}`,data:$,xField:o,yField:t,fieldLabels:l,cellSize:h,pointRadius:d,pointOpacity:f,colorBy:a,colorScale:C,brushSelectionName:O,hoverSelectionName:M,unselectedOpacity:v,showGrid:b,tooltip:x,mode:N,onPointHover:"hover"===N?(e,s,r)=>{e?(W({datum:e,xField:o,yField:t,colIndex:i,rowIndex:n,px:null!=s?s:0,py:null!=r?r:0}),E&&E({type:"hover",datum:e,x:null!=s?s:0,y:null!=r?r:0,timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:S})):(W(null),E&&E({type:"hover-end",timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:S}))}:void 0})))),e.createElement("div",null)," ",s.map(t=>e.createElement("div",{key:"col-label-"+t,style:{display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:"bold",color:"#333"}},l[t]||t))),L&&"hover"===N&&(()=>{const t=L.datum,n=l[L.xField]||L.xField,o=l[L.yField]||L.yField,i=a?"function"==typeof a?a(t):t[a]:null,s=k?"function"==typeof k?k(t):t[k]:"Row "+t[wt];return e.createElement("div",{style:{position:"absolute",left:40+L.colIndex*(h+u)+L.px,top:L.rowIndex*(h+u)+L.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}},s+""),e.createElement("div",null,n,": ",null!=t[L.xField]?Number(t[L.xField]).toFixed(1):"–"),e.createElement("div",null,o,": ",null!=t[L.yField]?Number(t[L.yField]).toFixed(1):"–"),null!=i&&e.createElement("div",{style:{opacity:.8}},"string"==typeof a?a:"group",": ",i+""))})())}function Nt(t){const{brushMode:n="crossfilter",hoverMode:o=!0}=t,i={};return!o&&n&&(i.splom={resolution:n}),o&&(i["splom-hover"]={resolution:"union"}),e.createElement(xt,{selections:i},e.createElement(Mt,Object.assign({},t)))}function jt({width:n,height:i,margin:s,scales:r,brushDirection:l,extent:a,onBrush:c}){const h=t(null),u=t(null),p=t(!1),g=n+s.left+s.right,m=i+s.top+s.bottom;return o(()=>{if(!h.current||!r)return;const e=y(h.current).select(".brush-group"),t="x"===l?d().extent([[0,0],[n,i]]):f().extent([[0,0],[n,i]]);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"===l?r.x:r.y).invert;if(!n)return;const o=[n(t[0]),n(t[1])];c(o)}),e.call(t),u.current=t,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.2).attr("stroke","steelblue").attr("stroke-width",1),()=>{t.on("brush end",null)}},[r,n,i,l,c]),o(()=>{if(!u.current||!r||!h.current)return;const e=y(h.current).select(".brush-group"),t="x"===l?r.x:r.y;if(p.current=!0,a){const n=[t(a[0]),t(a[1])];e.call(u.current.move,n)}else e.call(u.current.move,null);p.current=!1},[a,r,l]),e.createElement("svg",{ref:h,width:g,height:m,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},e.createElement("g",{className:"brush-group",transform:`translate(${s.left},${s.top})`}))}function Lt(s){var l,a;const{data:c,width:h=600,height:u=400,margin:d,className:f,title:p,xLabel:y,yLabel:g,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:M=!1,areaOpacity:N=.3,showPoints:j=!1,pointRadius:L=3,enableHover:W=!0,showGrid:_=!1,showLegend:$,tooltip:C,minimap:B={},renderBefore:H=!1,onBrush:z,brushExtent:T,frameProps:F={}}=s,P=c||[],[I,D]=n(null),G=null!=T?T:I,R=r(e=>{T||D(e),null==z||z(e)},[T,z]),Y=t(null),[X,q]=n(null);o(()=>{const e=()=>{var t,n;const o=null===(n=null===(t=Y.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===(l=P[0])||void 0===l?void 0:l[k]),U=i(()=>{if(V)return P;if(w){const e=P.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]:P}]},[P,w,k,V]),Z=i(()=>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}):P,[U,k,V,w,P]),J=Ye(P,A,E),K=i(()=>e=>{const t={strokeWidth:O};return t.stroke=A?Me(e,A,J):Ge,M&&(t.fill=t.stroke,t.fillOpacity=N),t},[A,J,O,M,N]),Q=i(()=>B.lineStyle?B.lineStyle:e=>{const t={strokeWidth:1};return t.stroke=A?Me(e,A,J):Ge,t},[A,J,B.lineStyle]),ee=i(()=>{if(j)return e=>{const t={r:L,fillOpacity:1};return t.fill=A?Me(e.parentLine||e,A,J):Ge,t}},[j,L,A,J]),{legend:te,margin:ne}=qe({data:U,colorBy:A,colorScale:J,showLegend:$,userMargin:d}),oe=B.height||60,ie=i(()=>{var e,t,n,o,i,s,r,l;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!==(s=null===(i=B.margin)||void 0===i?void 0:i.left)&&void 0!==s?s:ne.left,right:null!==(l=null===(r=B.margin)||void 0===r?void 0:r.right)&&void 0!==l?l:ne.right}},[B.margin,ne]),se=B.brushDirection||"x",re=ct({componentName:"MinimapChart",data:P,accessors:{xAccessor:b,yAccessor:x}});if(re)return e.createElement(nt,{componentName:"MinimapChart",message:re,width:h,height:u});const le=M?"area":"line",ae=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:le,data:Z,xAccessor:b,yAccessor:x,groupAccessor:w||void 0,curve:S,lineStyle:K},j&&{pointStyle:ee}),{size:[h,u],responsiveWidth:s.responsiveWidth,responsiveHeight:s.responsiveHeight,margin:ne,showAxes:!0,xLabel:y,yLabel:g,xFormat:m,yFormat:v,enableHover:W,showGrid:_}),te&&{legend:te}),p&&{title:p}),C&&{tooltipContent:Qe(C)}),G&&{xExtent:G}),F),ce={chartType:le,data:Z,xAccessor:b,yAccessor:x,groupAccessor:w||void 0,curve:S,lineStyle:Q,size:[h,oe+ie.top+ie.bottom],margin:ie,showAxes:null!==(a=B.showAxes)&&void 0!==a&&a,background:B.background,enableHover:!1},he=e.createElement("div",{key:"minimap",style:{position:"relative",width:h,overflow:"hidden"}},e.createElement(Ee,Object.assign({ref:Y},ce)),e.createElement(jt,{width:h-ie.left-ie.right,height:oe,margin:ie,scales:X,brushDirection:se,extent:G,onBrush:R})),ue=e.createElement("div",{key:"main",style:{overflow:"hidden"}},e.createElement(Ee,Object.assign({},ae)));return e.createElement("div",{className:"minimap-chart"+(f?" "+f:"")},H?he:ue,H?ue:he)}Nt.displayName="ScatterplotMatrix",Lt.displayName="MinimapChart";export{ft as AreaChart,mt as BubbleChart,gt as ConnectedScatterplot,vt as Heatmap,dt as LineChart,Lt as MinimapChart,yt as Scatterplot,Nt as ScatterplotMatrix,pt as StackedAreaChart,Ee as StreamXYFrame};
|
|
1
|
+
import*as e from"react";import{useRef as t,useState as n,useEffect as o,useMemo as i,forwardRef as s,useCallback as r,useImperativeHandle as l,useContext as a,createContext as c,useLayoutEffect as h,useId as u}from"react";import{brushX as d,brushY as f,brush as p}from"d3-brush";import{select as y}from"d3-selection";import{scaleLinear as g,scaleOrdinal as m,scaleSequential as v}from"d3-scale";import{bin as b}from"d3-array";import{packEnclose as x}from"d3-hierarchy";import{schemeCategory10 as w,interpolatePlasma as k,interpolateViridis as A,interpolatePurples as E,interpolateOranges as S,interpolateGreens as O,interpolateReds as M,interpolateBlues as N,schemeSet3 as j,schemeTableau10 as L}from"d3-scale-chromatic";const W=5e3;class _{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,W),bounded:!0,totalSize:e.length});let t=W;const n=()=>{if(t>=e.length)return;if(e!==this.lastBoundedData)return;const o=Math.min(t+W,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 ${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 C{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 B(e,t,n,o,i){const s=new Map;for(const r of e){const e=t(r),l=n(r);if(null==e||null==l||Number.isNaN(e)||Number.isNaN(l))continue;const a=Math.floor(e/o)*o;let c=s.get(a);if(c||(c={start:a,end:a+o,total:0,categories:new Map},s.set(a,c)),c.total+=l,i){const e=i(r);c.categories.set(e,(c.categories.get(e)||0)+l)}}return s}function H(e,t,n,o,i,s){const r=[],l=[];for(const i of e){const e=n(i),s=o(i);null==e||null==s||Number.isNaN(e)||Number.isNaN(s)||(r.push([t.x(e),t.y(s)]),l.push(s))}return{type:"line",path:r,rawValues:l,style:i,datum:e,group:s}}function z(e,t,n,o,i,s,r,l){const a=[],c=[];for(const s of e){const e=n(s),r=o(s);if(null==e||null==r||Number.isNaN(e)||Number.isNaN(r))continue;const h=t.x(e);a.push([h,t.y(r)]);const u=l?l(s):i;c.push([h,t.y(u)])}return{type:"area",topPath:a,bottomPath:c,style:s,datum:e,group:r}}function T(e,t,n,o,i,s,r){const l=n(e),a=o(e);if(null==l||null==a||Number.isNaN(l)||Number.isNaN(a))return null;const c={type:"point",x:t.x(l),y:t.y(a),r:i,style:s,datum:e};return void 0!==r&&(c.pointId=r),c}function F(e,t,n,o,i,s,r){return{type:"rect",x:e,y:t,w:n,h:o,style:i,datum:s,group:r}}function P(e,t,n,o,i,s){return{type:"heatcell",x:e,y:t,w:n,h:o,fill:i,datum:s}}function I(e,t){if("function"==typeof e)return t=>+e(t);const n=e||t;return e=>+e[n]}function D(e,t){return"function"==typeof e?e:e?t=>t[e]+"":void 0}class G{constructor(e){this.xExtent=new C,this.yExtent=new C,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 $(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=I(e.timeAccessor||e.xAccessor,"time"),this.getY=I(e.valueAccessor||e.yAccessor,"value")):(this.getX=I(e.xAccessor,"x"),this.getY=I(e.yAccessor,"y")),this.getGroup=D(e.groupAccessor),this.getCategory=D(e.categoryAccessor),this.getSize=e.sizeAccessor?I(e.sizeAccessor,"size"):void 0,this.getColor=D(e.colorAccessor),this.getBounds=e.boundsAccessor?I(e.boundsAccessor,"bounds"):void 0,this.getY0=e.y0Accessor?I(e.y0Accessor,"y0"):void 0,this.getPointId=D(e.pointIdAccessor),"candlestick"===e.chartType&&(this.getOpen=I(e.openAccessor,"open"),this.getHigh=I(e.highAccessor,"high"),this.getLow=I(e.lowAccessor,"low"),this.getClose=I(e.closeAccessor,"close")),e.pulse&&(this.timestampBuffer=new $(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,i,s,r;const{config:l,buffer:a}=this;if(this.xExtent.dirty&&this.xExtent.recalculate(a,this.getX),this.yExtent.dirty)if("candlestick"===l.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const e of a)this.yExtent.push(this.getHigh(e)),this.yExtent.push(this.getLow(e))}else this.yExtent.recalculate(a,this.getY);const c=this.xExtent.extent,h=this.yExtent.extent;let u=l.xExtent?[null!==(t=l.xExtent[0])&&void 0!==t?t:c[0],null!==(n=l.xExtent[1])&&void 0!==n?n:c[1]]:c,d=l.yExtent?[null!==(o=l.yExtent[0])&&void 0!==o?o:h[0],null!==(i=l.yExtent[1])&&void 0!==i?i:h[1]]:h;const f=l.yExtent&&null!=l.yExtent[0]&&null!=l.yExtent[1];if("stackedarea"===l.chartType&&!f&&a.size>0)if(l.normalize)d=[0,1+l.extentPadding];else{const e=a.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);d=[0,o+(o>0?o*l.extentPadding:1)]}else if("bar"===l.chartType&&l.binSize&&!f&&a.size>0){const[,e]=function(e,t,n,o,i){const s=B(e,t,n,o,i);if(0===s.size)return[0,0];let r=0;for(const e of s.values())e.total>r&&(r=e.total);return[0,r]}(a,this.getX,this.getY,l.binSize,this.getCategory);d=[0,e+e*l.extentPadding]}else if("waterfall"===l.chartType&&!f&&a.size>0){const[e,t]=function(e,t){let n=0,o=0,i=0;for(const s of e){const e=t(s);null==e||Number.isNaN(e)||(i+=e,n>i&&(n=i),i>o&&(o=i))}return[n,o]}(a,this.getY),n=t-e,o=n>0?n*l.extentPadding:1;d=[Math.min(0,e-Math.abs(o)),Math.max(0,t+Math.abs(o))]}else if(!f&&d[0]!==1/0){if(this.getBounds){const e=a.toArray();for(const t of e){const e=this.getY(t),n=this.getBounds(t);null!=e&&!Number.isNaN(e)&&n&&(e+n>d[1]&&(d[1]=e+n),d[0]>e-n&&(d[0]=e-n))}}const e=d[1]-d[0],t=e>0?e*l.extentPadding:1,n=null===(s=l.yExtent)||void 0===s?void 0:s[0],o=null===(r=l.yExtent)||void 0===r?void 0:r[1];d=[null!=n?d[0]:d[0]-t,null!=o?d[1]:d[1]+t]}if(u[0]!==1/0&&u[1]!==-1/0||(u=[0,1]),d[0]!==1/0&&d[1]!==-1/0||(d=[0,1]),void 0!==l.arrowOfTime)if("x"==("up"===(p=l.arrowOfTime)||"down"===p?"y":"x")){const t="right"===l.arrowOfTime?[0,e.width]:[e.width,0];this.scales={x:g().domain(u).range(t),y:g().domain(d).range([e.height,0])}}else{const t="down"===l.arrowOfTime?[0,e.height]:[e.height,0];this.scales={x:g().domain(d).range([0,e.width]),y:g().domain(u).range(t)}}else this.scales={x:g().domain(u).range([0,e.width]),y:g().domain(d).range([e.height,0])};var p;this.config.transition&&this.scene.length>0&&this.snapshotPositions();const y=a.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 i=n.toArray();switch(t.chartType){case"line":return this.buildLineScene(i);case"area":return this.buildAreaScene(i);case"stackedarea":return this.buildStackedAreaScene(i);case"scatter":case"bubble":return this.buildPointScene(i);case"heatmap":return this.buildHeatmapScene(i,e);case"bar":return this.buildBarScene(i);case"swarm":return this.buildSwarmScene(i);case"waterfall":return this.buildWaterfallScene(i,e);case"candlestick":return this.buildCandlestickScene(i,e);default:return[]}}buildLineScene(e){var t;const n=this.groupData(e),o=[],i=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=H(e.data,this.scales,this.getX,this.getY,t,e.key);i&&i.length>0&&(n.colorThresholds=i),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]),i=z(e.data,this.scales,this.getX,this.getY,o,t,e.key,this.getY0);this.config.gradientFill&&(i.fillGradient=this.config.gradientFill),n.push(i)}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,i,s){var r;const l=new Set;for(const t of e)for(const e of t.data){const t=n(e);null==t||Number.isNaN(t)||l.add(t)}const a=Array.from(l).sort((e,t)=>e-t),c=new Map;for(const t of e){const e=new Map;for(const i of t.data){const t=n(i),s=o(i);null==t||null==s||Number.isNaN(t)||Number.isNaN(s)||e.set(t,(e.get(t)||0)+s)}c.set(t.key,e)}let h;if(s){h=new Map;for(const t of a){let n=0;for(const o of e)n+=(null===(r=c.get(o.key))||void 0===r?void 0:r.get(t))||0;h.set(t,n||1)}}const u=[],d=new Map;for(const e of a)d.set(e,0);for(const n of e){const e=c.get(n.key),o=[],r=[];for(const n of a){let i=e.get(n)||0;const l=d.get(n);s&&(i/=h.get(n));const a=t.x(n);r.push([a,t.y(l)]),o.push([a,t.y(l+i)]),d.set(n,l+i)}u.push({type:"area",topPath:o,bottomPath:r,style:i(n.key,n.data[0]),datum:n.data,group:n.key})}return u}(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 i=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);i=t=>e===n?(o[0]+o[1])/2:o[0]+(t-e)/(n-e)*(o[1]-o[0])}}let s=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"];s=new Map;let o=0;for(const e of t)s.set(e,n[o%n.length]),o++}for(const o of e){let e=this.config.pointStyle?this.config.pointStyle(o):{fill:"#4e79a7",opacity:.8},r=e.r||n;if(i&&this.getSize){const e=this.getSize(o);null==e||Number.isNaN(e)||(r=i(e))}if(s&&this.getColor){const t=this.getColor(o);t&&s.has(t)&&(e=Object.assign(Object.assign({},e),{fill:s.get(t)}))}const l=this.getPointId?this.getPointId(o)+"":void 0,a=T(o,this.scales,this.getX,this.getY,r,e,l);a&&t.push(a)}return t}buildHeatmapScene(e,t){const n=[];if(this.config.heatmapAggregation)return this.buildStreamingHeatmapScene(e,t);const o=I(this.config.valueAccessor,"value"),i=new Set,s=new Set;for(const t of e)i.add(this.getX(t)),s.add(this.getY(t));const r=Array.from(i).sort((e,t)=>e-t),l=Array.from(s).sort((e,t)=>e-t);if(0===r.length||0===l.length)return n;const a=t.width/r.length,c=t.height/l.length,h=new Map;for(const t of e){const e=`${this.getX(t)}_${this.getY(t)}`;h.set(e,{val:o(t),datum:t})}let u=1/0,d=-1/0;for(const{val:e}of h.values())u>e&&(u=e),e>d&&(d=e);const f=d-u||1;for(let e=0;r.length>e;e++)for(let t=0;l.length>t;t++){const o=h.get(`${r[e]}_${l[t]}`);if(!o)continue;const i=(o.val-u)/f;n.push(P(e*a,(l.length-1-t)*c,a,c,`rgb(${Math.round(220-180*i)},${Math.round(220-100*i)},${Math.round(255-50*i)})`,o.datum))}return n}buildStreamingHeatmapScene(e,t){var n,o,i;const s=[],r=null!==(n=this.config.heatmapXBins)&&void 0!==n?n:20,l=null!==(o=this.config.heatmapYBins)&&void 0!==o?o:20,a=null!==(i=this.config.heatmapAggregation)&&void 0!==i?i:"count",c=I(this.config.valueAccessor,"value");if(!this.scales||0===e.length)return s;const[h,u]=this.scales.x.domain(),[d,f]=this.scales.y.domain(),p=(u-h||1)/r,y=(f-d||1)/l,g=new Map;for(const t of e){const e=this.getX(t),n=this.getY(t),o=Math.min(Math.floor((e-h)/p),r-1),i=Math.min(Math.floor((n-d)/y),l-1);if(0>o||0>i)continue;const s=`${o}_${i}`;let a=g.get(s);a||(a={sum:0,count:0,data:[]},g.set(s,a)),a.count++,a.sum+=c(t),a.data.push(t)}let m=1/0,v=-1/0;const b=new Map;for(const[e,t]of g){let n;switch(a){case"sum":n=t.sum;break;case"mean":n=t.count>0?t.sum/t.count:0;break;default:n=t.count}b.set(e,n),m>n&&(m=n),n>v&&(v=n)}const x=v-m||1,w=t.width/r,k=t.height/l;for(const[e,t]of b){const[n,o]=e.split("_"),i=+n,r=+o,a=(t-m)/x,c=`rgb(${Math.round(220-180*a)},${Math.round(220-100*a)},${Math.round(255-50*a)})`,h=g.get(e);s.push(P(i*w,(l-1-r)*k,w,k,c,{xi:i,yi:r,value:t,count:h.count,sum:h.sum,data:h.data}))}return s}buildBarScene(e){var t;if(!this.config.binSize)return[];const n=B(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):[],i=new Set(t),s=Array.from(e).filter(e=>!i.has(e)).sort();o=[...t.filter(t=>e.has(t)),...s]}const i=[],s=this.scales,[r,l]=s.x.domain();for(const e of n.values()){const n=Math.max(e.start,r),a=Math.min(e.end,l);if(n>=a)continue;const c=s.x(n),h=s.x(a),u=Math.min(c,h)+.5,d=Math.max(c,h)-.5-u;if(d>0)if(o&&e.categories.size>0){let n=0;for(const r of o){const o=e.categories.get(r)||0;if(0===o)continue;const l=s.y(n),a=s.y(n+o);i.push(F(u,Math.min(l,a),d,Math.abs(l-a),{fill:(null===(t=this.config.barColors)||void 0===t?void 0:t[r])||"#4e79a7"},{binStart:e.start,binEnd:e.end,total:e.total,category:r,categoryValue:o},r)),n+=o}}else{const t=s.y(0),n=s.y(e.total);i.push(F(u,Math.min(t,n),d,Math.abs(t-n),{fill:"#007bff"},{binStart:e.start,binEnd:e.end,total:e.total}))}}return i}buildSwarmScene(e){var t,n,o,i;const s=[],r=this.config.swarmStyle||{},l=null!==(t=r.radius)&&void 0!==t?t:3,a=null!==(n=r.fill)&&void 0!==n?n:"#007bff",c=null!==(o=r.opacity)&&void 0!==o?o:.7,h=r.stroke,u=r.strokeWidth;for(const t of e){const e=this.getX(t),n=this.getY(t);if(null==n||Number.isNaN(n))continue;const o=this.scales.x(e),r=this.scales.y(n);let d=a;if(this.getCategory){const e=this.getCategory(t);d=(null===(i=this.config.barColors)||void 0===i?void 0:i[e])||d}const f={type:"point",x:o,y:r,r:l,style:{fill:d,opacity:c,stroke:h,strokeWidth:u},datum:t};this.getPointId&&(f.pointId=this.getPointId(t)+""),s.push(f)}return s}buildWaterfallScene(e,t){var n,o,i;const s=[],r=this.scales,l=this.config.waterfallStyle,a=e.filter(e=>{const t=this.getY(e);return null!=t&&!Number.isNaN(t)});if(0===a.length)return s;const c=null!==(n=null==l?void 0:l.positiveColor)&&void 0!==n?n:"#28a745",h=null!==(o=null==l?void 0:l.negativeColor)&&void 0!==o?o:"#dc3545",u=null!==(i=null==l?void 0:l.gap)&&void 0!==i?i:1,d=null==l?void 0:l.stroke,f=null==l?void 0:l.strokeWidth;let p=0;for(let e=0;a.length>e;e++){const n=a[e],o=this.getX(n),i=this.getY(n),y=p+i;let g;g=a.length-1>e?this.getX(a[e+1])-o:e>0?o-this.getX(a[e-1]):0;const m=r.x(o),v=0!==g?r.x(o+g):m+t.width/10,b=Math.min(m,v)+u/2,x=Math.max(m,v)-u/2-b;if(0>=x){p=y;continue}const w=r.y(p),k=r.y(y);s.push(F(b,Math.min(w,k),x,Math.abs(w-k),{fill:0>i?h:c,stroke:d,strokeWidth:f},Object.assign(Object.assign({},n),{baseline:p,cumEnd:y,delta:i,_connectorStroke:null==l?void 0:l.connectorStroke,_connectorWidth:null==l?void 0:l.connectorWidth}))),p=y}return s}buildCandlestickScene(e,t){if(!(this.getOpen&&this.getHigh&&this.getLow&&this.getClose&&this.scales))return[];const n=[],o=this.config.candlestickStyle||{},i=o.upColor||"#28a745",s=o.downColor||"#dc3545",r=o.wickColor||"#333",l=o.wickWidth||1,a=e.map(e=>this.getX(e)).filter(e=>null!=e&&!Number.isNaN(e)).sort((e,t)=>e-t);let c=o.bodyWidth||6;if(!o.bodyWidth&&a.length>1){let e=1/0;for(let t=1;a.length>t;t++){const n=Math.abs(this.scales.x(a[t])-this.scales.x(a[t-1]));n>0&&e>n&&(e=n)}e!==1/0&&(c=Math.max(2,Math.min(.6*e,20)))}for(const t of e){const e=this.getX(t);if(null==e||Number.isNaN(e))continue;const o=this.getOpen(t),a=this.getHigh(t),h=this.getLow(t),u=this.getClose(t);if([o,a,h,u].some(e=>null==e||Number.isNaN(e)))continue;const d=u>=o;n.push({type:"candlestick",x:this.scales.x(e),openY:this.scales.y(o),closeY:this.scales.y(u),highY:this.scales.y(a),lowY:this.scales.y(h),bodyWidth:c,upColor:i,downColor:s,wickColor:r,wickWidth:l,isUp:d,datum:t})}return n}buildBoundsForGroup(e,t){if(!this.getBounds||!this.scales)return null;const n=[],o=[];for(const t of e){const e=this.getX(t),i=this.getY(t);if(null==e||null==i||Number.isNaN(e)||Number.isNaN(i))continue;const s=this.getBounds(t),r=this.scales.x(e);if(s&&0!==s)n.push([r,this.scales.y(i+s)]),o.push([r,this.scales.y(i-s)]);else{const e=this.scales.y(i);n.push([r,e]),o.push([r,e])}}return 2>n.length?null:{type:"area",topPath:n,bottomPath:o,style:this.resolveBoundsStyle(t,e[0]),datum:e,group:t,interactive:!1}}resolveBoundsStyle(e,t){const n=this.config.boundsStyle;return"function"==typeof n?n(t||{},e):n&&"object"==typeof n?n:{fill:this.resolveLineStyle(e,t).stroke||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(e,t){var n,o,i;const s=this.config.decay;if(!s||1>=t)return 1;const r=null!==(n=s.minOpacity)&&void 0!==n?n:.1,l=t-1-e;switch(s.type){case"linear":return r+(1-l/(t-1))*(1-r);case"exponential":{const e=null!==(o=s.halfLife)&&void 0!==o?o:t/2;return r+Math.pow(.5,l/e)*(1-r)}case"step":return(null!==(i=s.stepThreshold)&&void 0!==i?i:.5*t)>l?1:r;default:return 1}}applyDecay(e,t){var n,o;if(!this.config.decay)return;const i=t.length;if(1>=i)return;const 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 r=this.computeDecayOpacity(e,i);if("heatcell"===t.type)t.style={opacity:r};else if("candlestick"===t.type)t._decayOpacity=r;else{const e=null!==(o=null===(n=t.style)||void 0===n?void 0:n.opacity)&&void 0!==o?o:1;t.style=Object.assign(Object.assign({},t.style),{opacity:e*r})}}}computePulseIntensity(e,t){var n;const o=this.config.pulse;if(!o)return 0;const i=null!==(n=o.duration)&&void 0!==n?n:500,s=t-e;return i>s?1-s/i:0}applyPulse(e,t){var n,o;if(!this.config.pulse||!this.timestampBuffer)return;const i="undefined"!=typeof performance?performance.now():Date.now(),s=null!==(n=this.config.pulse.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",r=null!==(o=this.config.pulse.glowRadius)&&void 0!==o?o:4,l=new Map;for(let e=0;t.length>e;e++)l.set(t[e],e);for(const t of e){if("line"===t.type||"area"===t.type)continue;const e=l.get(t.datum);if(null==e)continue;const n=this.timestampBuffer.get(e);if(null==n)continue;const o=this.computePulseIntensity(n,i);o>0&&(t._pulseIntensity=o,t._pulseColor=s,t._pulseGlowRadius=r)}}get hasActivePulses(){var e;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const t="undefined"!=typeof performance?performance.now():Date.now(),n=null!==(e=this.config.pulse.duration)&&void 0!==e?e:500,o=this.timestampBuffer.peek();return null!=o&&n>t-o}snapshotPositions(){this.prevPositionMap.clear();for(let e=0;this.scene.length>e;e++){const t=this.scene[e],n=this.getNodeIdentity(t,e);n&&("point"===t.type?this.prevPositionMap.set(n,{x:t.x,y:t.y,r:t.r}):"rect"===t.type||"heatcell"===t.type?this.prevPositionMap.set(n,{x:t.x,y:t.y,w:t.w,h:t.h}):"candlestick"===t.type&&this.prevPositionMap.set(n,{x:t.x,y:t.openY}))}}getNodeIdentity(e,t){var n,o,i,s;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!==(s=null!==(o=null===(n=e.datum)||void 0===n?void 0:n.binStart)&&void 0!==o?o:null===(i=e.datum)||void 0===i?void 0:i.category)&&void 0!==s?s: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,i,s;if(!this.config.transition||0===this.prevPositionMap.size)return;const r=null!==(e=this.config.transition.duration)&&void 0!==e?e:300;let l=!1;for(let e=0;this.scene.length>e;e++){const r=this.scene[e],a=this.getNodeIdentity(r,e);if(!a)continue;const c=this.prevPositionMap.get(a);if(c)if("point"===r.type){const e={x:r.x,y:r.y,r:r.r};c.x===e.x&&c.y===e.y||(r._targetX=e.x,r._targetY=e.y,r._targetR=e.r,r.x=c.x,r.y=c.y,r.r=null!==(t=c.r)&&void 0!==t?t:r.r,l=!0)}else if("rect"===r.type){const e={x:r.x,y:r.y,w:r.w,h:r.h};c.x===e.x&&c.y===e.y&&c.w===e.w&&c.h===e.h||(r._targetX=e.x,r._targetY=e.y,r._targetW=e.w,r._targetH=e.h,r.x=c.x,r.y=c.y,r.w=null!==(n=c.w)&&void 0!==n?n:r.w,r.h=null!==(o=c.h)&&void 0!==o?o:r.h,l=!0)}else if("heatcell"===r.type){const e={x:r.x,y:r.y,w:r.w,h:r.h};c.x===e.x&&c.y===e.y||(r._targetX=e.x,r._targetY=e.y,r._targetW=e.w,r._targetH=e.h,r.x=c.x,r.y=c.y,r.w=null!==(i=c.w)&&void 0!==i?i:r.w,r.h=null!==(s=c.h)&&void 0!==s?s:r.h,l=!0)}}l&&(this.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:r})}advanceTransition(e){var t;if(!this.activeTransition)return!1;const n=Math.min((e-this.activeTransition.startTime)/this.activeTransition.duration,1),o="linear"===(null===(t=this.config.transition)||void 0===t?void 0:t.easing)?n:1-Math.pow(1-n,3);for(const e of this.scene)if("point"===e.type){if(void 0===e._targetX)continue;const t=this.getNodeIdentity(e,0);if(!t)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=n.x+(e._targetX-n.x)*o,e.y=n.y+(e._targetY-n.y)*o,void 0!==e._targetR&&void 0!==n.r&&(e.r=n.r+(e._targetR-n.r)*o)}else if("rect"===e.type){if(void 0===e._targetX)continue;const t=this.getNodeIdentity(e,0);if(!t)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=n.x+(e._targetX-n.x)*o,e.y=n.y+(e._targetY-n.y)*o,void 0!==n.w&&(e.w=n.w+(e._targetW-n.w)*o),void 0!==n.h&&(e.h=n.h+(e._targetH-n.h)*o)}else if("heatcell"===e.type){if(void 0===e._targetX)continue;const t=this.getNodeIdentity(e,0);if(!t)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=n.x+(e._targetX-n.x)*o,e.y=n.y+(e._targetY-n.y)*o,void 0!==n.w&&(e.w=n.w+(e._targetW-n.w)*o),void 0!==n.h&&(e.h=n.h+(e._targetH-n.h)*o)}if(n>=1){for(const e of this.scene)if("point"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,void 0!==e._targetR&&(e.r=e._targetR),e._targetX=void 0,e._targetY=void 0,e._targetR=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("heatcell"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}return this.activeTransition=null,!1}return!0}groupData(e){if(!this.getGroup)return[{key:"_default",data:e}];const t=new Map;for(const n of e){const e=this.getGroup(n);t.has(e)||t.set(e,[]),t.get(e).push(n)}return Array.from(t.entries()).map(([e,t])=>({key:e,data:t}))}resolveLineStyle(e,t){const n=this.config.lineStyle;return"function"==typeof n?n(t||{},e):n&&"object"==typeof n?{stroke:n.stroke||"#007bff",strokeWidth:n.strokeWidth||2,strokeDasharray:n.strokeDasharray,fill:n.fill,fillOpacity:n.fillOpacity,opacity:n.opacity}:{stroke:"#007bff",strokeWidth:2}}resolveAreaStyle(e,t){var n;if(this.config.areaStyle)return this.config.areaStyle(t||{});const o=this.config.lineStyle;return"function"==typeof o?o(t||{},e):o&&"object"==typeof o?{fill:o.fill||o.stroke||"#4e79a7",fillOpacity:null!==(n=o.fillOpacity)&&void 0!==n?n:.7,stroke:o.stroke||"#4e79a7",strokeWidth:o.strokeWidth||2}:{fill:"#4e79a7",fillOpacity:.7,stroke:"#4e79a7",strokeWidth:2}}getData(){return this.buffer.toArray()}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],this.version++}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}updateConfig(e){Object.assign(this.config,e)}}function R(e,t,n){const o=t-e.x,i=n-e.y,s=Math.sqrt(o*o+i*i);return s>e.r+5?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:s}}function Y(e,t,n){if(0===e.path.length)return null;const o=Z(e.path,t);if(0>o)return null;const[i,s]=e.path[o],r=t-i,l=n-s,a=Math.sqrt(r*r+l*l);return{node:e,datum:Array.isArray(e.datum)&&e.datum[o]?e.datum[o]:e.datum,x:i,y:s,distance:a}}function X(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 q(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 V(e,t,n){const o=e.bodyWidth/2,i=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=i+Math.max(Math.max(e.openY,e.closeY)-i,1)/2,s=t-e.x,r=n-o;return{node:e,datum:e.datum,x:e.x,y:o,distance:Math.sqrt(s*s+r*r)}}return null}function U(e,t,n){if(0===e.topPath.length)return null;const o=Z(e.topPath,t);if(0>o)return null;const[i,s]=e.topPath[o],r=t-i,l=n-s;return{node:e,datum:e.datum,x:i,y:s,distance:Math.sqrt(r*r+l*l)}}function Z(e,t){if(0===e.length)return-1;let n=0,o=e.length-1;for(;o>n;){const i=n+o>>1;t>e[i][0]?n=i+1:o=i}return n>0&&Math.abs(e[n][0]-t)>=Math.abs(e[n-1][0]-t)?n-1:n}const J={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 K(e,t,n,o){let i;return i="function"==typeof n?n(e):(0,J[n])(o(e,t)),i}function Q(t){const{legendGroups:n,customClickBehavior:o,title:i="Legend",width:s=100,height:r=20,orientation:l="vertical"}=t,a="vertical"===l?(({legendGroups:t,width:n,customClickBehavior:o})=>{let i=30;const s=[];return t.forEach((t,r)=>{i+=5,s.push(e.createElement("line",{key:"legend-top-line legend-symbol-"+r,stroke:"gray",x1:0,y1:i,x2:n,y2:i})),i+=10,t.label&&(i+=20,s.push(e.createElement("text",{key:"legend-text-"+r,y:i,className:"legend-group-label"},t.label)),i+=10),s.push(e.createElement("g",{key:"legend-group-"+r,className:"legend-item",transform:`translate(0,${i})`},((t,n)=>{const{type:o="fill",styleFn:i,items:s}=t,r=[];let l=0;return s.forEach((t,s)=>{const a=K(t,s,o,i);r.push(e.createElement("g",{key:"legend-item-"+s,transform:`translate(0,${l})`,onClick:n?()=>n(t):void 0,style:{cursor:n?"pointer":"default"}},a,e.createElement("text",{y:15,x:30},t.label))),l+=25}),r})(t,o))),i+=25*t.items.length+10}),s})({legendGroups:n,width:s,customClickBehavior:o}):(({legendGroups:t,title:n,height:o,customClickBehavior:i})=>{let s=0;const r=[],l=!1===n?10:40;return t.forEach((n,a)=>{n.label&&(r.push(e.createElement("text",{key:"legend-text-"+a,transform:`translate(${s},${l}) rotate(90)`,textAnchor:"start",className:"legend-group-label"},n.label)),s+=20);const c=((t,n)=>{const{type:o="fill",styleFn:i,items:s}=t,r=[];let l=0;return s.forEach((t,s)=>{const a=K(t,s,o,i);r.push(e.createElement("g",{key:"legend-item-"+s,transform:`translate(${l},0)`,onClick:n?()=>n(t):void 0,style:{cursor:n?"pointer":"default"}},a,e.createElement("text",{y:15,x:25},t.label))),l+=35,l+=8*t.label.length}),{items:r,offset:l}})(n,i);r.push(e.createElement("g",{key:"legend-group-"+a,className:"legend-item",transform:`translate(${s},${l})`},c.items)),s+=c.offset+5,t[a+1]&&r.push(e.createElement("line",{key:"legend-top-line legend-symbol-"+a,stroke:"gray",x1:s,y1:l-10,x2:s,y2:o+l+10})),s+=15}),e.createElement("g",null,!1!==n&&e.createElement("line",{x1:0,x2:s+10,y1:l-10,y2:l-10,stroke:"gray",className:"title-neatline"}),r)})({legendGroups:n,title:i,height:r,customClickBehavior:o});return e.createElement("g",null,void 0!==i&&e.createElement("text",{className:"legend-title",y:20,x:"horizontal"===l?0:s/2,textAnchor:"horizontal"===l?"start":"middle"},i),a)}function ee(e){return"string"==typeof e?{type:e}:e}function te({orient:t,config:n,values:o,scale:s,size:r,length:l}){const a=function(e){var t,n,o,i,s;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!==(i=e.stroke)&&void 0!==i?i:"none",strokeWidth:null!==(s=e.strokeWidth)&&void 0!==s?s:1}}(n),c="top"===t||"bottom"===t,h=i(()=>{if(0===o.length)return null;const n=s.domain(),i=r-8;if("boxplot"===a.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)],i=t[Math.floor(.5*n)],s=t[Math.floor(.75*n)],r=s-o;return{q1:o,median:i,q3:s,whiskerLow:Math.max(t[0],o-1.5*r),whiskerHigh:Math.min(t[n-1],s+1.5*r)}}(o);if(!n)return null;const{q1:r,median:l,q3:h,whiskerLow:u,whiskerHigh:d}=n,f=Math.min(.5*i,20),p=(i-f)/2+4;if(c){const n=s(r),o=s(h),i=s(l),c=s(u),y=s(d),g="top"===t?-1:1,m=0;return e.createElement("g",{"data-testid":"marginal-boxplot-"+t},e.createElement("line",{x1:c,y1:m+g*(p+f/2),x2:y,y2:m+g*(p+f/2),stroke:a.fill,strokeWidth:a.strokeWidth}),e.createElement("line",{x1:c,y1:m+g*p,x2:c,y2:m+g*(p+f),stroke:a.fill,strokeWidth:a.strokeWidth}),e.createElement("line",{x1:y,y1:m+g*p,x2:y,y2:m+g*(p+f),stroke:a.fill,strokeWidth:a.strokeWidth}),e.createElement("rect",{x:Math.min(n,o),y:"top"===t?m-p-f:m+p,width:Math.abs(o-n),height:f,fill:a.fill,fillOpacity:a.fillOpacity,stroke:"none"===a.stroke?a.fill:a.stroke,strokeWidth:a.strokeWidth}),e.createElement("line",{x1:i,y1:"top"===t?m-p-f:m+p,x2:i,y2:"top"===t?m-p:m+p+f,stroke:a.fill,strokeWidth:2}))}{const n=s(r),o=s(h),i=s(l),c=s(u),y=s(d),g="left"===t?-1:1,m=0;return e.createElement("g",{"data-testid":"marginal-boxplot-"+t},e.createElement("line",{x1:m+g*(p+f/2),y1:c,x2:m+g*(p+f/2),y2:y,stroke:a.fill,strokeWidth:a.strokeWidth}),e.createElement("line",{x1:m+g*p,y1:c,x2:m+g*(p+f),y2:c,stroke:a.fill,strokeWidth:a.strokeWidth}),e.createElement("line",{x1:m+g*p,y1:y,x2:m+g*(p+f),y2:y,stroke:a.fill,strokeWidth:a.strokeWidth}),e.createElement("rect",{x:"left"===t?m-p-f:m+p,y:Math.min(n,o),width:f,height:Math.abs(o-n),fill:a.fill,fillOpacity:a.fillOpacity,stroke:"none"===a.stroke?a.fill:a.stroke,strokeWidth:a.strokeWidth}),e.createElement("line",{x1:"left"===t?m-p-f:m+p,y1:i,x2:"left"===t?m-p:m+p+f,y2:i,stroke:a.fill,strokeWidth:2}))}}const h=b().domain(n).thresholds(a.bins)(o);if(0===h.length)return null;const u=Math.max(...h.map(e=>e.length));if(0===u)return null;if("histogram"===a.type)return e.createElement("g",{"data-testid":"marginal-histogram-"+t},h.map((n,o)=>{if(null==n.x0||null==n.x1)return null;const r=n.length/u*i;if(c){const i=s(n.x0),l=s(n.x1)-s(n.x0);return e.createElement("rect",{key:o,x:i,y:"top"===t?-4-r:4,width:Math.max(l,.5),height:r,fill:a.fill,fillOpacity:a.fillOpacity,stroke:a.stroke,strokeWidth:a.strokeWidth})}{const i=s(n.x0),l=s(n.x1)-s(n.x0);return e.createElement("rect",{key:o,x:"left"===t?-4-r:4,y:Math.min(i,i+l),width:r,height:Math.abs(l),fill:a.fill,fillOpacity:a.fillOpacity,stroke:a.stroke,strokeWidth:a.strokeWidth})}}));if("violin"===a.type){const n=i/2+4,o=[];for(const e of h){if(null==e.x0||null==e.x1)continue;const r=e.length/u*(i/2),l=s((e.x0+e.x1)/2);o.push(c?`${l},${"top"===t?-(n-r):n-r}`:`${"left"===t?-(n-r):n-r},${l}`)}for(let e=h.length-1;e>=0;e--){const r=h[e];if(null==r.x0||null==r.x1)continue;const l=r.length/u*(i/2),a=s((r.x0+r.x1)/2);o.push(c?`${a},${"top"===t?-(n+l):n+l}`:`${"left"===t?-(n+l):n+l},${a}`)}return e.createElement("g",{"data-testid":"marginal-violin-"+t},e.createElement("polygon",{points:o.join(" "),fill:a.fill,fillOpacity:a.fillOpacity,stroke:"none"===a.stroke?a.fill:a.stroke,strokeWidth:a.strokeWidth}))}if("ridgeline"===a.type){const n=[];if(c){const e=0,o=null!=h[0].x0?s(h[0].x0):0;n.push(`M${o},${e}`);for(const e of h){if(null==e.x0||null==e.x1)continue;const o=e.length/u*i,r=s((e.x0+e.x1)/2);n.push(`L${r},${"top"===t?-o-4:o+4}`)}const r=null!=h[h.length-1].x1?s(h[h.length-1].x1):l;n.push(`L${r},${e}`),n.push("Z")}else{const e=0,o=null!=h[0].x0?s(h[0].x0):0;n.push(`M${e},${o}`);for(const e of h){if(null==e.x0||null==e.x1)continue;const o=e.length/u*i,r=s((e.x0+e.x1)/2);n.push(`L${"left"===t?-o-4:o+4},${r}`)}const r=null!=h[h.length-1].x1?s(h[h.length-1].x1):l;n.push(`L${e},${r}`),n.push("Z")}return e.createElement("g",{"data-testid":"marginal-ridgeline-"+t},e.createElement("path",{d:n.join(" "),fill:a.fill,fillOpacity:a.fillOpacity,stroke:"none"===a.stroke?a.fill:a.stroke,strokeWidth:a.strokeWidth}))}return null},[o,s,a,r,l,t,c,4]);return h?e.createElement("g",{className:"marginal-"+t,"data-testid":"marginal-"+t},h):null}function ne(e,t=120,n=8){if(!e)return[];const o=Math.max(1,Math.floor(t/n)),i=e.split(/\s+/),s=[];let r="";for(const e of i)r&&r.length+1+e.length>o?(s.push(r),r=e):r=r?`${r} ${e}`:e;return r&&s.push(r),s}function oe(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 ie(t){const{x:n=0,y:o=0,dx:i,dy:s,nx:r,ny:l,note:a,connector:c,subject:h,type:u,color:d,className:f,disable:p,events:y={},"data-testid":g}=t,m=new Set(Array.isArray(p)?p:[]);let v=i||0,b=s||0;null!=r&&(v=r-n),null!=l&&(b=l-o);const x="string"==typeof u?u:"label";if("bracket"===x&&h&&0===v&&0===b)if(void 0!==h.width){v=h.width/2;const e=h.depth||30;b=e+(0>e?-5:5)}else if(void 0!==h.height){const e=h.depth||30;v=e+(0>e?-5:5),b=h.height/2}return e.createElement("g",Object.assign({className:("annotation "+(f||"")).trim(),transform:`translate(${n},${o})`,"data-testid":g},y),!m.has("connector")&&function(t,n,o,i,s,r){const l=[];let a=0,c=0;if("callout-circle"!==s&&"label"!==s||!(null==r?void 0:r.radius)){if("callout-rect"===s&&r){const e=r.width||0,o=r.height||0;if(e>0||o>0){const i=e/2,s=o/2,r=t-i,l=n-s;if(0!==r||0!==l){const t=Math.abs(r),n=Math.abs(l),h=e/2,u=o/2,d=t*u>n*h?h/t:u/n;a=i+r*d,c=s+l*d}}}else if("bracket"===s&&r){const e=r.width,t=r.height,n=r.depth||30;void 0!==e?(a=e/2,c=n):void 0!==t&&(a=n,c=t/2)}}else{const e=(r.radius||0)+(r.radiusPadding||0);if(e>0&&(0!==t||0!==n)){const o=Math.atan2(n,t);a=Math.cos(o)*e,c=Math.sin(o)*e}}if(Math.sqrt(Math.pow(t-a,2)+Math.pow(n-c,2))>.5&&(l.push(e.createElement("line",{key:"connector-line",x1:a,y1:c,x2:t,y2:n,stroke:i||"currentColor"})),"arrow"===(null==o?void 0:o.end))){const o=10,s=16/180*Math.PI,r=Math.atan2(n-c,t-a);l.push(e.createElement("path",{key:"connector-arrow",d:`M${a},${c}L${a+o*Math.cos(r+s)},${c+o*Math.sin(r+s)}L${a+o*Math.cos(r-s)},${c+o*Math.sin(r-s)}Z`,fill:i||"currentColor",stroke:"none"}))}return e.createElement("g",{className:"annotation-connector"},l)}(v,b,c,d,x,h),!m.has("subject")&&function(t,n,o,i,s){var r;const l=[];switch(t){case"callout-circle":{const t=((null==n?void 0:n.radius)||0)+((null==n?void 0:n.radiusPadding)||0);t>0&&l.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,i=(null==n?void 0:n.height)||0;(t>0||i>0)&&l.push(e.createElement("rect",{key:"subject-rect",width:t,height:i,fill:"none",stroke:o||"currentColor"}));break}case"callout-custom":(null==n?void 0:n.custom)&&l.push(...Array.isArray(n.custom)?n.custom:[n.custom]);break;case"xy-threshold":{const t=i||0,r=s||0;if(void 0!==(null==n?void 0:n.x)){const i=(n.x||0)-t;l.push(e.createElement("line",{key:"threshold-line",x1:i,y1:(n.y1||0)-r,x2:i,y2:(n.y2||0)-r,stroke:o||"currentColor",strokeDasharray:"5,5"}))}else if(void 0!==(null==n?void 0:n.y)){const i=(n.y||0)-r;l.push(e.createElement("line",{key:"threshold-line",x1:(n.x1||0)-t,y1:i,x2:(n.x2||0)-t,y2:i,stroke:o||"currentColor",strokeDasharray:"5,5"}))}else void 0!==(null==n?void 0:n.x1)||void 0!==(null==n?void 0:n.x2)?l.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)||l.push(e.createElement("line",{key:"threshold-line",x1:0,y1:(n.y1||0)-r,x2:0,y2:(n.y2||0)-r,stroke:o||"currentColor",strokeDasharray:"5,5"}));break}case"bracket":{const t=null!==(r=null==n?void 0:n.width)&&void 0!==r?r:null==n?void 0:n.height;void 0!==t&&l.push(e.createElement("path",{key:"bracket-path",d:oe((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"},l)}(x,h,d,n,o),!m.has("note")&&function(t,n,o,i){if(!t)return e.createElement("g",{className:"annotation-note"});const{label:s,title:r,orientation:l,align:a,wrap:c=120,noWrap:h}=t;if(!s&&!r)return e.createElement("g",{className:"annotation-note"});let u=l;u||(u=Math.abs(n)>Math.abs(o)?"leftRight":"topBottom");let d=a;d&&"dynamic"!==d||(d="topBottom"===u?0>n?"right":"left":0>o?"bottom":"top");let f="start";"topBottom"===u?"right"===d?f="end":"middle"===d&&(f="middle"):f=0>n?"end":"start";const p=16,y=r?h?[r]:ne(r,c):[],g=s?h?[s]:ne(s,c):[],m="leftRight"===u?"end"===f?-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:i||void 0,textAnchor:f,fontWeight:"bold"},y.map((t,n)=>e.createElement("tspan",{key:n,x:m,dy:0===n?0:p},t)))),v=y.length*p),g.length>0&&b.push(e.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:i||void 0,textAnchor:f,y:v},g.map((t,n)=>e.createElement("tspan",{key:n,x:m,dy:0===n?0:p},t))));let x=null;if((r||s)&&(0!==n||0!==o))if("topBottom"===u){const t=Math.min(c,120);let n=0,o=t;"end"===f?(n=-t,o=0):"middle"===f&&(n=-t/2,o=t/2),x=e.createElement("line",{className:"note-line",x1:n,x2:o,y1:0,y2:0,stroke:i||"currentColor"})}else{const t=(y.length+g.length)*p+(g.length>0?p:0);let n=0,o=t;"bottom"===d?(n=-t,o=0):"middle"===d&&(n=-t/2,o=t/2),x=e.createElement("line",{className:"note-line",x1:0,x2:0,y1:n,y2:o,stroke:i||"currentColor"})}const w=Math.max(0,y.length+g.length-1)*p;let k=0;return"topBottom"===u?k=0>o?-(w+2):18:"leftRight"===u&&(k="middle"===d?-(w+p+(g.length>0&&y.length>0?2:0))/2+8:"bottom"===d||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)}(a,v,b,d))}function se(t){var n,o;const{noteData:i}=t,{screenCoordinates:s}=i,r="string"==typeof i.type?i.type:"label",l=i.eventListeners||i.events||{};if(i.coordinates&&s){const t=i.nx||s[0][0]+(null!==(n=i.dx)&&void 0!==n?n:0),l=i.ny||s[0][1]+(null!==(o=i.dy)&&void 0!==o?o:0),a=s.map((n,o)=>{const s=Object.assign({},i,{note:0===o?i.note:{label:""},x:n[0],y:n[1],nx:t,ny:l});return e.createElement(ie,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+o},s,{type:r}))});return e.createElement("g",null,a)}const a=i.note||{title:"none",label:i.label};return e.createElement(ie,Object.assign({"data-testid":"semiotic-annotation",key:`${a.label}-${a.title}-${i.i}`,events:l},i,{type:r}))}function re(e,t){var n,o,i;const s=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.x)&&void 0!==o?o:null===(i=t.scales)||void 0===i?void 0:i.time;return s?null!=e.x?s(e.x):t.xAccessor&&null!=e[t.xAccessor]?s(e[t.xAccessor]):null:null}function le(e,t){var n,o,i;const s=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.y)&&void 0!==o?o:null===(i=t.scales)||void 0===i?void 0:i.value;return s?null!=e.y?s(e.y):t.yAccessor&&null!=e[t.yAccessor]?s(e[t.yAccessor]):null:null}function ae(e,t,n,o=50){return!(-o>e||e>(n.width||0)+o||-o>t||t>(n.height||0)+o)}function ce(e,t,n){if("left"===e||"right"===e){const o="left"===e?n:0,i="left"===e?-1:1,s=Math.ceil(t/8);let r="M0,"+o;for(let e=0;s>e;e++){const n=8*(e+1);r+=`L${Math.min(8*e+4,t)},${o+4*i}`,r+=`L${Math.min(n,t)},${o}`}return r}{const o="bottom"===e?0:t,i="bottom"===e?1:-1,s=Math.ceil(n/8);let r=`M${o},0`;for(let e=0;s>e;e++){const t=8*(e+1);r+=`L${o+4*i},${Math.min(8*e+4,n)}`,r+=`L${o},${Math.min(t,n)}`}return r}}function he(e){return Math.round(100*e)/100+""}function ue(t){const{width:n,height:o,totalWidth:s,totalHeight:r,margin:l,scales:a,showAxes:c,axes:h,xLabel:u,yLabel:d,xFormat:f,yFormat:p,showGrid:y,title:g,legend:m,foregroundGraphics:v,marginalGraphics:b,xValues:w,yValues:k,annotations:A,svgAnnotationRules:E,annotationFrame:S,xAccessor:O,yAccessor:M,annotationData:N,pointNodes:j,children:L}=t,W=i(()=>c&&a?a.x.ticks(5).map(e=>({value:e,pixel:a.x(e),label:(f||he)(e)})):[],[c,a,f]),_=i(()=>c&&a?a.y.ticks(5).map(e=>({value:e,pixel:a.y(e),label:(p||he)(e)})):[],[c,a,p]),$=i(()=>{if(!A||0===A.length)return null;const t=function(t,n,o){var i,s,r,l,a,c,h,u,d,f,p,y,g,m,v,b,w,k,A,E,S,O,M,N,j,L,W,_,$,C,B,H,z,T,F,P,I,D,G;switch(t.type){case"label":{let i=null,s=null;if(null!=t.pointId&&o.pointNodes){const e=o.pointNodes.find(e=>e.pointId===t.pointId);if(!e)return null;i=e.x,s=e.y}else i=re(t,o),s=le(t,o);return null==i||null==s?null:ae(i,s,o)?e.createElement(se,{key:"ann-"+n,noteData:{x:i,y:s,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 i=null,s=null;if(null!=t.pointId&&o.pointNodes){const e=o.pointNodes.find(e=>e.pointId===t.pointId);if(!e)return null;i=e.x,s=e.y}else i=re(t,o),s=le(t,o);return null==i||null==s?null:ae(i,s,o)?e.createElement(se,{key:"ann-"+n,noteData:{x:i,y:s,dx:t.dx||30,dy:t.dy||-30,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"callout-circle",subject:{radius:t.radius||12},connector:t.connector||{end:"arrow"},color:t.color}}):null}case"x-threshold":{const i=re(t,o);if(null==i)return null;const s=t.color||"#f97316";return e.createElement("g",{key:"ann-"+n},e.createElement("line",{x1:i,y1:0,x2:i,y2:o.height||0,stroke:s,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&e.createElement("text",{x:i+4,y:12,fill:s,fontSize:12,fontWeight:"bold"},t.label))}case"y-threshold":{const i=le(t,o);if(null==i)return null;const s=t.color||"#f97316";return e.createElement("g",{key:"ann-"+n},e.createElement("line",{x1:0,y1:i,x2:o.width||0,y2:i,stroke:s,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&e.createElement("text",{x:(o.width||0)-4,y:i-4,textAnchor:"end",fill:s,fontSize:12,fontWeight:"bold"},t.label))}case"enclose":{const i=(t.coordinates||[]).map(e=>({x:re(Object.assign(Object.assign({},e),{type:"point"}),o),y:le(Object.assign(Object.assign({},e),{type:"point"}),o),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>i.length)return null;const s=x(i),r=t.padding||10;return e.createElement("g",{key:"ann-"+n},e.createElement("circle",{cx:s.x,cy:s.y,r:s.r+r,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&e.createElement("text",{x:s.x,y:s.y-s.r-r-4,textAnchor:"middle",fill:t.color||"#666",fontSize:12},t.label))}case"rect-enclose":{const i=(t.coordinates||[]).map(e=>({x:re(Object.assign(Object.assign({},e),{type:"point"}),o),y:le(Object.assign(Object.assign({},e),{type:"point"}),o)})).filter(e=>null!=e.x&&null!=e.y);if(2>i.length)return null;const s=t.padding||10,r=i.map(e=>e.x),l=i.map(e=>e.y),a=Math.min(...r)-s,c=Math.max(...r)+s,h=Math.min(...l)-s,u=Math.max(...l)+s;return e.createElement("g",{key:"ann-"+n},e.createElement("rect",{x:a,y:h,width:c-a,height:u-h,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&e.createElement("text",{x:(a+c)/2,y:h-4,textAnchor:"middle",fill:t.color||"#666",fontSize:12},t.label))}case"highlight":{const i=o.data||[],s="function"==typeof t.filter?i.filter(t.filter):t.field&&null!=t.value?i.filter(e=>e[t.field]===t.value):[],r=t.style||{stroke:t.color||"#f97316",strokeWidth:2,fill:"none"};return e.createElement("g",{key:"ann-"+n},s.map((n,i)=>{const s=re(n,o),l=le(n,o);return null==s||null==l?null:e.createElement("circle",Object.assign({key:i,cx:s,cy:l,r:t.r||6},r))}))}case"bracket":{const i=re(t,o),s=le(t,o);return e.createElement(se,{key:"ann-"+n,noteData:{x:null!=i?i:0,y:null!=s?s: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 u=o.data||[];if(2>u.length)return null;const d=o.xAccessor||"x",f=o.yAccessor||"y",p=u.map(e=>[e[d],e[f]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>p.length)return null;const y=null!==(s=null===(i=o.scales)||void 0===i?void 0:i.x)&&void 0!==s?s:null===(r=o.scales)||void 0===r?void 0:r.time,g=null!==(a=null===(l=o.scales)||void 0===l?void 0:l.y)&&void 0!==a?a:null===(c=o.scales)||void 0===c?void 0:c.value;if(!y||!g)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]),i=o.map(e=>e[0]),s=o.map(e=>e[1]),r=Math.max(2,Math.ceil(t*n)),l=[];for(let e=0;n>e;e++){const t=i[e],o=i.map(e=>Math.abs(e-t)),a=o.slice().sort((e,t)=>e-t)[Math.min(r-1,n-1)]||1,c=[];for(let e=0;n>e;e++){const t=0===a?0:o[e]/a;c[e]=1>t?Math.pow(1-Math.pow(t,3),3):0}let h=0,u=0,d=0,f=0,p=0;for(let e=0;n>e;e++){const t=c[e];0!==t&&(h+=t,u+=t*i[e],d+=t*s[e],f+=t*i[e]*i[e],p+=t*i[e]*s[e])}if(0===h){l.push([t,s[e]]);continue}const y=h*f-u*u;if(1e-12>Math.abs(y))l.push([t,d/h]);else{const e=(h*p-u*d)/y;l.push([t,(d-e*u)/h+e*t])}}return l}(p,null!==(h=t.bandwidth)&&void 0!==h?h:.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)},${g(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:g(v[v.length-1][1])-4,fill:x,fontSize:11},t.label))}case"band":{const i=null!==(d=null===(u=o.scales)||void 0===u?void 0:u.y)&&void 0!==d?d:null===(f=o.scales)||void 0===f?void 0:f.value,s=null!==(p=null==i?void 0:i(t.y0))&&void 0!==p?p:0,r=null!==(y=null==i?void 0:i(t.y1))&&void 0!==y?y:o.height||0;return e.createElement("g",{key:"ann-"+n},e.createElement("rect",{x:0,y:Math.min(s,r),width:o.width||0,height:Math.abs(r-s),fill:t.fill||"#6366f1",fillOpacity:t.fillOpacity||.1}),t.label&&e.createElement("text",{x:(o.width||0)-4,y:Math.min(s,r)-4,textAnchor:"end",fill:t.color||"#6366f1",fontSize:11},t.label))}case"envelope":{const i=o.data||[];if(2>i.length)return null;const s=o.xAccessor||"x",r=null!==(m=null===(g=o.scales)||void 0===g?void 0:g.x)&&void 0!==m?m:null===(v=o.scales)||void 0===v?void 0:v.time,l=null!==(w=null===(b=o.scales)||void 0===b?void 0:b.y)&&void 0!==w?w:null===(k=o.scales)||void 0===k?void 0:k.value;if(!r||!l)return null;const a=t.upperAccessor||"upperBounds",c=t.lowerAccessor||"lowerBounds",h=t.filter,u=i.filter(e=>null!=e[a]&&null!=e[c]&&!(h&&!h(e))).sort((e,t)=>e[s]-t[s]);if(2>u.length)return null;const d=u.map(e=>`${r(e[s])},${l(e[a])}`).join(" L"),f=u.slice().reverse().map(e=>`${r(e[s])},${l(e[c])}`).join(" L"),p=t.fill||"#6366f1";return e.createElement("g",{key:"ann-"+n},e.createElement("path",{d:`M${d} L${f} Z`,fill:p,fillOpacity:null!==(A=t.fillOpacity)&&void 0!==A?A:.15,stroke:"none"}),t.label&&u.length>0&&e.createElement("text",{x:r(u[u.length-1][s])+4,y:l(u[u.length-1][a])-4,fill:p,fontSize:11},t.label))}case"anomaly-band":{const i=o.data||[];if(2>i.length)return null;const s=o.yAccessor||"y",r=null!==(S=null===(E=o.scales)||void 0===E?void 0:E.x)&&void 0!==S?S:null===(O=o.scales)||void 0===O?void 0:O.time,l=null!==(N=null===(M=o.scales)||void 0===M?void 0:M.y)&&void 0!==N?N:null===(j=o.scales)||void 0===j?void 0:j.value;if(!r||!l)return null;const a=i.map(e=>e[s]).filter(e=>null!=e&&isFinite(e));if(2>a.length)return null;const c=a.reduce((e,t)=>e+t,0)/a.length,h=a.reduce((e,t)=>e+Math.pow(t-c,2),0)/a.length,u=Math.sqrt(h),d=null!==(L=t.threshold)&&void 0!==L?L:2,f=c-d*u,p=!1!==t.showBand,y=t.fill||"#6366f1",g=null!==(W=t.fillOpacity)&&void 0!==W?W:.1,m=t.anomalyColor||"#ef4444",v=null!==(_=t.anomalyRadius)&&void 0!==_?_:6,b=l(c+d*u),x=l(f),w=i.filter(e=>{const t=e[s];return null!=t&&Math.abs(t-c)>d*u});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:g}),w.map((t,n)=>{const i=re(t,o),s=le(t,o);return null==i||null==s?null:e.createElement("circle",{key:n,cx:i,cy:s,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 i=o.data||[];if(3>i.length)return null;const s=o.xAccessor||"x",r=o.yAccessor||"y",l=null!==(C=null===($=o.scales)||void 0===$?void 0:$.x)&&void 0!==C?C:null===(B=o.scales)||void 0===B?void 0:B.time,a=null!==(z=null===(H=o.scales)||void 0===H?void 0:H.y)&&void 0!==z?z:null===(T=o.scales)||void 0===T?void 0:T.value;if(!l||!a)return null;const c=i.map(e=>[e[s],e[r]]).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 h;if("polynomial"===(t.method||"linear"))try{const e=require("regression").polynomial(c,{order:t.order||2}).equation;h=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,i=0;for(const[e,s]of c)t+=e,n+=s,o+=e*e,i+=e*s;const s=e*o-t*t;if(1e-12>Math.abs(s))return null;const r=(e*i-t*n)/s,l=(n-r*t)/e;h=e=>l+r*e}const u=c.length,d=c.map(([e,t])=>t-h(e)).reduce((e,t)=>e+t*t,0),f=Math.sqrt(d/Math.max(u-2,1)),p=c.reduce((e,t)=>e+t[0],0)/u,y=c.reduce((e,t)=>e+Math.pow(t[0]-p,2),0),g=null!==(F=t.confidence)&&void 0!==F?F:.95,m=.99>g?.95>g?.9>g?1:1.645:1.96:2.576,v=null!==(P=t.steps)&&void 0!==P?P:5,b=c[u-1][0],x=(b-c[0][0])/Math.max(u-1,1),w=[];for(let e=1;v>=e;e++)w.push(b+e*x);const k=[];for(const e of w){const t=h(e),n=f*Math.sqrt(1+1/u+(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=>`${l(e.x)},${a(e.yUpper)}`).join(" L")} L${k.slice().reverse().map(e=>`${l(e.x)},${a(e.yLower)}`).join(" L")} Z`,E=k.map(e=>`${l(e.x)},${a(e.yCenter)}`).join(" "),S=`${l(b)},${a(h(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!==(D=t.strokeWidth)&&void 0!==D?D:2,strokeDasharray:null!==(G=t.strokeDasharray)&&void 0!==G?G:"6,3"}),t.label&&k.length>0&&e.createElement("text",{x:l(k[k.length-1].x)+4,y:a(k[k.length-1].yCenter)-4,fill:O,fontSize:11},t.label))}default:return null}},i={scales:a?{x:a.x,y:a.y,time:a.x,value:a.y}:null,timeAxis:"x",xAccessor:O,yAccessor:M,width:n,height:o,data:N,frameType:"xy",pointNodes:j};return A.map((e,n)=>{if(E){const o=E(e,n,i);return null!=o?o:t(e,n,i)}return t(e,n,i)}).filter(Boolean)},[A,E,n,o,S,O,M,N]);return c||g||m||v||b||$&&$.length>0||y||L?e.createElement("svg",{width:s,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},e.createElement("g",{transform:`translate(${l.left},${l.top})`},y&&a&&e.createElement("g",{className:"stream-grid"},W.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})),_.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&&a&&(()=>{const t=null==h?void 0:h.find(e=>"left"===e.orient),i=null==h?void 0:h.find(e=>"bottom"===e.orient),s=!t||!1!==t.baseline,r=(null==t?void 0:t.jaggedBase)||!1,a=(null==i?void 0:i.jaggedBase)||!1,c="var(--semiotic-border, #ccc)",f="var(--semiotic-text-secondary, #666)",p="var(--semiotic-text, #333)";return e.createElement("g",{className:"stream-axes"},(!i||!1!==i.baseline)&&!a&&e.createElement("line",{x1:0,y1:o,x2:n,y2:o,stroke:c,strokeWidth:1}),a&&e.createElement("path",{d:ce("bottom",n,o),fill:"none",stroke:c,strokeWidth:1}),W.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:f,style:{userSelect:"none"}},t.label))),u&&e.createElement("text",{x:n/2,y:o+40,textAnchor:"middle",fontSize:12,fill:p,style:{userSelect:"none"}},u),s&&!r&&e.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:c,strokeWidth:1}),r&&e.createElement("path",{d:ce("left",n,o),fill:"none",stroke:c,strokeWidth:1}),_.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:f,style:{userSelect:"none"}},t.label))),d&&e.createElement("text",{x:15-l.left,y:o/2,textAnchor:"middle",fontSize:12,fill:p,transform:`rotate(-90, ${15-l.left}, ${o/2})`,style:{userSelect:"none"}},d))})(),$,b&&a&&w&&k&&e.createElement(e.Fragment,null,b.top&&e.createElement("g",{transform:"translate(0, 0)"},e.createElement(te,{orient:"top",config:ee(b.top),values:w,scale:a.x,size:l.top,length:n})),b.bottom&&e.createElement("g",{transform:`translate(0, ${o})`},e.createElement(te,{orient:"bottom",config:ee(b.bottom),values:w,scale:a.x,size:l.bottom,length:n})),b.left&&e.createElement("g",{transform:"translate(0, 0)"},e.createElement(te,{orient:"left",config:ee(b.left),values:k,scale:a.y,size:l.left,length:o})),b.right&&e.createElement("g",{transform:`translate(${n}, 0)`},e.createElement(te,{orient:"right",config:ee(b.right),values:k,scale:a.y,size:l.right,length:o}))),v,L),g&&e.createElement("text",{x:s/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof g?g:null),m&&e.createElement("g",{transform:`translate(${s-l.right+10}, ${l.top})`},"object"==typeof(C=m)&&null!==C&&!e.isValidElement(C)&&"legendGroups"in C?e.createElement(Q,{legendGroups:m.legendGroups,title:"",width:100}):m)):null;var C}function de(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 fe(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 pe=(e,t,n,o)=>{var i;const s=t.filter(e=>"area"===e.type);for(const t of s){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 s=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])),i=e.createLinearGradient(0,n,0,o);i.addColorStop(0,s),i.addColorStop(1,s),e.fillStyle=i;const r=fe(s),l=t.fillGradient.topOpacity,a=t.fillGradient.bottomOpacity,c=e.createLinearGradient(0,n,0,o);c.addColorStop(0,`rgba(${r[0]},${r[1]},${r[2]},${l})`),c.addColorStop(1,`rgba(${r[0]},${r[1]},${r[2]},${a})`),e.fillStyle=c,e.globalAlpha=1}else{const n=null!==(i=t.style.fillOpacity)&&void 0!==i?i:.7;e.globalAlpha=n,e.fillStyle=s}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}},ye=(e,t,n,o)=>{var i,s;const r=t.filter(e=>"point"===e.type);for(const t of r){e.beginPath(),e.arc(t.x,t.y,t.r,0,2*Math.PI);const n=null!==(i=t.style.opacity)&&void 0!==i?i: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!==(s=t._pulseGlowRadius)&&void 0!==s?s: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}},ge=(e,t,n,o)=>{const i=t.filter(e=>"rect"===e.type);for(const t of i)null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.icon?me(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 me(e,t){const n=t.style.icon,o=t.style.iconPadding||2,i=Math.min(t.w,t.w)-o;if(0>=i)return;const s=t.h>t.w;if(e.save(),e.beginPath(),e.rect(t.x,t.y,t.w,t.h),e.clip(),s){const s=i+o,r=t.x+(t.w-i)/2;for(let o=t.y+t.h-i;o>=t.y-i;o-=s)e.drawImage(n,r,o,i,i)}else{const s=i+o,r=t.y+(t.h-i)/2;for(let o=t.x;t.x+t.w>o;o+=s)e.drawImage(n,o,r,i,i)}e.restore()}const ve={line:[pe,(e,t,n,o)=>{const i=t.filter(e=>"line"===e.type);for(const s of i){if(2>s.path.length)continue;const r=s.style.stroke||"#007bff",l=s.style.strokeWidth||2,a=s.colorThresholds,c=s.rawValues;if(e.setLineDash(s.style.strokeDasharray?s.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=s.style.opacity&&(e.globalAlpha=s.style.opacity),e.lineWidth=l,a&&0!==a.length&&c&&c.length===s.path.length){let h=null,u=null,d=null,f=null,p=!1;function y(t,n,o){e.beginPath(),e.strokeStyle=t,e.moveTo(n,o),p=!0}function g(){p&&(e.stroke(),p=!1)}for(let m=0;s.path.length>m;m++){const[v,b]=s.path[m],x=c[m],w=de(x,a,r);if(null!==h&&null!==f&&null!==d){if(w===f)e.lineTo(v,b);else{const k=[];for(const A of a){const E=A.value;(d>E||E>x)&&(E>d||x>E)||d===E||x===E||k.push({t:(E-d)/(x-d)})}k.sort((e,t)=>e.t-t.t);for(const S of k){const O=h+(v-h)*S.t,M=u+(b-u)*S.t,N=de(d+(x-d)*Math.min(S.t+1e-4,1),a,r);e.lineTo(O,M),g(),y(N,O,M)}e.lineTo(v,b)}h=v,u=b,d=x,f=w}else y(w,v,b),h=v,u=b,d=x,f=w}g()}else{e.beginPath(),e.strokeStyle=r;const[j,L]=s.path[0];e.moveTo(j,L);for(let W=1;s.path.length>W;W++)e.lineTo(s.path[W][0],s.path[W][1]);e.stroke()}if(s.style.fill&&s.style.fillOpacity&&s.style.fillOpacity>0){e.beginPath(),e.globalAlpha=s.style.fillOpacity,e.fillStyle=s.style.fill;const[_,$]=s.path[0];e.moveTo(_,$);for(let B=1;s.path.length>B;B++)e.lineTo(s.path[B][0],s.path[B][1]);const C=s.path[0][0];e.lineTo(s.path[s.path.length-1][0],o.height),e.lineTo(C,o.height),e.closePath(),e.fill()}e.globalAlpha=1,e.setLineDash([])}}],area:[pe],stackedarea:[pe],scatter:[ye],bubble:[ye],heatmap:[(e,t,n,o)=>{const i=t.filter(e=>"heatcell"===e.type);for(const t of i){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:[ge],swarm:[ye],waterfall:[(e,t,n,o)=>{var i,s,r;ge(e,t);const l=t.filter(e=>"rect"===e.type);if(2>l.length)return;const a=l[0].datum,c=null==a?void 0:a._connectorStroke;if(c){e.save(),e.strokeStyle=c,e.lineWidth=null!==(i=null==a?void 0:a._connectorWidth)&&void 0!==i?i:1,e.setLineDash([]);for(let t=0;l.length-1>t;t++){const o=l[t],i=l[t+1];if(!(null===(s=o.datum)||void 0===s?void 0:s.cumEnd)||!(null===(r=i.datum)||void 0===r?void 0:r.baseline))continue;const a=n.y(o.datum.cumEnd),c=o.x+o.w,h=i.x;e.beginPath(),e.moveTo(c,a),e.lineTo(h,a),e.stroke()}e.restore()}}],candlestick:[(e,t,n,o)=>{for(const n of t){if("candlestick"!==n.type)continue;const t=n;e.beginPath(),e.moveTo(t.x,t.highY),e.lineTo(t.x,t.lowY),e.strokeStyle=t.wickColor,e.lineWidth=t.wickWidth,e.stroke();const o=Math.min(t.openY,t.closeY),i=Math.abs(t.openY-t.closeY),s=t.isUp?t.upColor:t.downColor;e.fillStyle=s,e.fillRect(t.x-t.bodyWidth/2,o,t.bodyWidth,Math.max(i,1)),e.strokeStyle=s,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,o,t.bodyWidth,Math.max(i,1))}}]},be={top:20,right:20,bottom:30,left:40},xe={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"},we={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 ke({hover:t}){const n=e=>Number.isInteger(e)?e+"":e.toFixed(2);return e.createElement("div",{className:"semiotic-tooltip",style:we},e.createElement("div",{style:{fontWeight:600,marginBottom:2}},n(t.value)),e.createElement("div",{style:{opacity:.7,fontSize:11}},n(t.time)))}function Ae({width:n,height:i,totalWidth:s,totalHeight:r,margin:l,dimension:a,scales:c,onBrush:h}){const u=t(null),g=t(null);return o(()=>{if(!u.current)return;const e=y(u.current).select(".brush-g"),t="x"===a?d():"y"===a?f():p();return t.extent([[0,0],[n,i]]),t.on("brush end",e=>{if(!c)return;if(!e.selection)return void h(null);let t,o;if("x"===a){const[n,s]=e.selection;t=[c.x.invert(n),c.x.invert(s)],o=[c.y.invert(i),c.y.invert(0)]}else if("y"===a){const[i,s]=e.selection;t=[c.x.invert(0),c.x.invert(n)],o=[c.y.invert(s),c.y.invert(i)]}else{const[[n,i],[s,r]]=e.selection;t=[c.x.invert(n),c.x.invert(s)],o=[c.y.invert(r),c.y.invert(i)]}h({x:t,y:o})}),e.call(t),g.current=t,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{t.on("brush end",null),g.current=null}},[n,i,a,c,h]),e.createElement("svg",{ref:u,width:s,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},e.createElement("g",{className:"brush-g",transform:`translate(${l.left},${l.top})`}))}const Ee=s(function(s,a){var c,h,u;const{chartType:d,runtimeMode:f,data:p,xAccessor:y,yAccessor:g,colorAccessor:m,sizeAccessor:v,groupAccessor:b,lineDataAccessor:x,normalize:w,binSize:k,valueAccessor:A,arrowOfTime:E="right",windowMode:S="sliding",windowSize:O=200,timeAccessor:M,xExtent:N,yExtent:j,extentPadding:L=.1,sizeRange:W,size:$=[500,300],responsiveWidth:C,responsiveHeight:B,margin:H,className:z,background:T,lineStyle:F,pointStyle:P,areaStyle:I,waterfallStyle:D,swarmStyle:Z,barColors:J,colorScheme:K,boundsAccessor:Q,boundsStyle:ee,y0Accessor:te,gradientFill:ne,openAccessor:oe,highAccessor:ie,lowAccessor:se,closeAccessor:re,candlestickStyle:le,showAxes:ae=!0,axes:ce,xLabel:he,yLabel:de,xFormat:fe,yFormat:pe,tickFormatTime:ye,tickFormatValue:ge,hoverAnnotation:me,tooltipContent:we,customHoverBehavior:Ee,enableHover:Se,annotations:Oe,svgAnnotationRules:Me,showGrid:Ne,legend:je,backgroundGraphics:Le,foregroundGraphics:We,title:_e,categoryAccessor:$e,brush:Ce,onBrush:Be,decay:He,pulse:ze,transition:Te,staleness:Fe,heatmapAggregation:Pe,heatmapXBins:Ie,heatmapYBins:De,marginalGraphics:Ge,pointIdAccessor:Re}=s,[Ye,Xe]=function(e,i,s){const r=t(null),[l,a]=n(null);return o(()=>{if(!i&&!s)return;const e=r.current;if(!e)return;const t=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;a(t=>t&&t.w===e&&t.h===n?t:{w:e,h:n})}});return t.observe(e),()=>t.disconnect()},[i,s]),[r,[i&&l?l.w:e[0],s&&l?l.h:e[1]]]}($,C,B),qe=Object.assign(Object.assign({},be),H);if(Ge){const e=60;Ge.top&&e>qe.top&&(qe.top=e),Ge.bottom&&e>qe.bottom&&(qe.bottom=e),Ge.left&&e>qe.left&&(qe.left=e),Ge.right&&e>qe.right&&(qe.right=e)}const Ve=Xe[0]-qe.left-qe.right,Ue=Xe[1]-qe.top-qe.bottom,Ze=null!=me?me:Se,Je=t(null),Ke=t(0),Qe=t(!1),[et,tt]=n(0),[nt,ot]=n(null),it=t(null),st=t(null),[rt,lt]=n(null),[at,ct]=n(!1),[ht,ut]=n([]),[dt,ft]=n([]),pt=t(()=>{}),yt="streaming"===f||["bar","swarm","waterfall"].includes(d),gt=i(()=>({chartType:d,runtimeMode:yt?"streaming":"bounded",windowSize:O,windowMode:S,arrowOfTime:yt?E:"right",extentPadding:L,xAccessor:yt?void 0:y,yAccessor:yt?void 0:g,timeAccessor:yt?M:void 0,valueAccessor:A,colorAccessor:m,sizeAccessor:v,groupAccessor:b,categoryAccessor:$e,lineDataAccessor:x,xExtent:N,yExtent:j,sizeRange:W,binSize:k,normalize:w,boundsAccessor:Q,boundsStyle:ee,y0Accessor:te,gradientFill:"boolean"==typeof ne?ne?{topOpacity:.8,bottomOpacity:.05}:void 0:ne,openAccessor:oe,highAccessor:ie,lowAccessor:se,closeAccessor:re,candlestickStyle:le,lineStyle:F,pointStyle:P,areaStyle:I,swarmStyle:Z,waterfallStyle:D,colorScheme:K,barColors:J,annotations:Oe,decay:He,pulse:ze,transition:Te,staleness:Fe,heatmapAggregation:Pe,heatmapXBins:Ie,heatmapYBins:De,pointIdAccessor:Re}),[d,O,S,E,L,y,g,M,A,m,v,b,$e,x,N,j,W,k,w,Q,ee,te,ne,oe,ie,se,re,le,F,P,I,Z,D,K,J,Oe,He,ze,Te,Fe,Pe,Ie,De,yt,Re]),mt=t(null);mt.current||(mt.current=new G(gt));const vt=r(()=>{Ke.current||(Ke.current=requestAnimationFrame(()=>pt.current()))},[]);o(()=>{var e;null===(e=mt.current)||void 0===e||e.updateConfig(gt),Qe.current=!0,vt()},[gt,vt]);const bt=t(null);bt.current||(bt.current=new _(e=>{const t=mt.current;t&&t.ingest(e)&&(Qe.current=!0,vt())}));const xt=r(e=>{var t;null===(t=bt.current)||void 0===t||t.push(e)},[]),wt=r(e=>{var t;null===(t=bt.current)||void 0===t||t.pushMany(e)},[]),kt=r(()=>{var e,t;null===(e=bt.current)||void 0===e||e.clear(),null===(t=mt.current)||void 0===t||t.clear(),Qe.current=!0,vt()},[vt]);l(a,()=>({push:xt,pushMany:wt,clear:kt,getData:()=>{var e,t;return null!==(t=null===(e=mt.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=mt.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null},getExtents:()=>{var e,t;return null!==(t=null===(e=mt.current)||void 0===e?void 0:e.getExtents())&&void 0!==t?t:null}}),[xt,wt,kt]),o(()=>{var e;p&&(null===(e=bt.current)||void 0===e||e.setBoundedData(p))},[p]);const At=t(()=>{}),Et=t(()=>{});At.current=e=>{if(!Ze)return;const t=Je.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-qe.left,i=e.clientY-n.top-qe.top;if(0>o||o>Ve||0>i||i>Ue)return void(it.current&&(it.current=null,st.current=null,lt(null),Ee&&(Ee(null),Qe.current=!0),vt()));const s=mt.current;if(!s||0===s.scene.length)return;const r=function(e,t,n,o=30){let i=null;for(const s of e){let e=null;switch(s.type){case"point":e=R(s,t,n);break;case"line":e=Y(s,t,n);break;case"rect":e=X(s,t,n);break;case"heatcell":e=q(s,t,n);break;case"area":if(!1===s.interactive)break;e=U(s,t,n);break;case"candlestick":e=V(s,t,n)}e&&o>e.distance&&(i&&e.distance>=i.distance||(i=e))}return i}(s.scene,o,i);if(!r)return void(it.current&&(it.current=null,st.current=null,lt(null),Ee&&Ee(null),vt()));const l={data:r.datum,time:r.x,value:r.y,x:r.x,y:r.y};it.current=l,st.current=r.node,lt(l),Ee&&(Ee(l),Qe.current=!0),vt()},Et.current=()=>{it.current&&(it.current=null,st.current=null,lt(null),Ee&&(Ee(null),Qe.current=!0),vt())},r(e=>At.current(e),[]);const St=r(()=>Et.current(),[]),Ot=t(-1),Mt=r(e=>{const t=mt.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>Ot.current?-1:Ot.current,i=function(e,t,n){switch(e){case"ArrowRight":case"ArrowDown":return n-1>t?t+1:t;case"ArrowLeft":case"ArrowUp":return t>0?t-1:t;case"Home":return 0;case"End":return n-1;case"Escape":return-1;default:return null}}(e.key,0>o?-1:o,n.length);if(null===i)return;if(e.preventDefault(),0>i)return Ot.current=-1,it.current=null,st.current=null,lt(null),Ee&&Ee(null),void vt();const s=0>o?0:i;Ot.current=s;const r={data:(l=n[s]).datum,x:l.x,y:l.y,time:l.x,value:l.y};var l;it.current=r,lt(r),Ee&&Ee(r),vt()},[Ee,vt]),Nt=r(e=>{Ot.current=-1,At.current(e)},[]);pt.current=()=>{var e,t;Ke.current=0;const n=Je.current;if(!n)return;const o=n.getContext("2d");if(!o)return;const i=mt.current;if(!i)return;const s="undefined"!=typeof performance?performance.now():Date.now(),r=i.advanceTransition(s);r||i.computeScene({width:Ve,height:Ue});const l="undefined"!=typeof window&&window.devicePixelRatio||1;n.width=Xe[0]*l,n.height=Xe[1]*l,n.style.width=Xe[0]+"px",n.style.height=Xe[1]+"px",o.scale(l,l),o.translate(qe.left,qe.top),o.clearRect(-qe.left,-qe.top,Xe[0],Xe[1]);const a=function(e){if(!e)return xe;const t=getComputedStyle(e),n=t.getPropertyValue("--semiotic-border").trim(),o=t.getPropertyValue("--semiotic-text-secondary").trim(),i=t.getPropertyValue("--semiotic-bg").trim(),s=o||t.getPropertyValue("--text-secondary").trim(),r=t.getPropertyValue("--text-primary").trim(),l=n||t.getPropertyValue("--surface-3").trim(),a=i||t.getPropertyValue("--surface-0").trim();return s||r||n?{axisStroke:l||xe.axisStroke,tickText:s||xe.tickText,crosshair:s?s+"66":xe.crosshair,hoverFill:a?a+"4D":xe.hoverFill,hoverStroke:s?s+"99":xe.hoverStroke,pointRing:a||xe.pointRing}:xe}(n),c=null!==(e=null==Fe?void 0:Fe.threshold)&&void 0!==e?e:5e3,h=Fe&&i.lastIngestTime>0&&s-i.lastIngestTime>c;h&&(o.globalAlpha=null!==(t=null==Fe?void 0:Fe.dimOpacity)&&void 0!==t?t:.5);const u=n?getComputedStyle(n).getPropertyValue("--semiotic-bg").trim():"",f=T||(u&&"transparent"!==u?u:null);f&&(o.fillStyle=f,o.fillRect(-qe.left,-qe.top,Xe[0],Xe[1])),o.save(),"function"==typeof o.rect&&(o.beginPath(),o.rect(0,0,Ve,Ue),o.clip());const p=ve[d];if(p&&i.scales)for(const e of p)e(o,i.scene,i.scales,{width:Ve,height:Ue});if(o.restore(),h&&(o.globalAlpha=1),Ze&&it.current&&i.scales&&function(e,t,n,o,i,s,r){if(!1===i.crosshair)return;e.save();const l="object"==typeof i.crosshair?i.crosshair:{};e.strokeStyle=l.stroke||r.crosshair,e.lineWidth=l.strokeWidth||1,e.setLineDash(l.strokeDasharray?l.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),e.beginPath(),e.moveTo(t.x,0),e.lineTo(t.x,o),e.stroke(),e.beginPath(),e.moveTo(0,t.y),e.lineTo(n,t.y),e.stroke(),e.restore(),e.beginPath(),e.arc(t.x,t.y,4,0,2*Math.PI),e.fillStyle="#007bff",e.fill(),e.strokeStyle=r.pointRing,e.lineWidth=2,e.stroke()}(o,it.current,Ve,Ue,"object"==typeof Ze?Ze:{},0,a),st.current&&Array.isArray(me)){const e=me.find(e=>e&&"object"==typeof e&&"highlight"===e.type);e&&function(e,t,n,o){var i;if(!n)return;const s=n.group;if(void 0!==s)for(const n of t){if("line"!==n.type)continue;if(n.group!==s)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!==(i=t.opacity)&&void 0!==i?i:1,e.stroke(),e.restore()}}(o,i.scene,st.current,e)}const m=Qe.current;if(Qe.current=!1,m&&i.scales&&(ot(i.scales),Ge)){const e=i.getData(),t="function"==typeof y?y:e=>e[y||"x"],n="function"==typeof g?g:e=>e[g||"y"];ut(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&&Oe&&Oe.length>0&&tt(e=>e+1),(null==Fe?void 0:Fe.showBadge)&&ct(!!h),(r||i.hasActivePulses)&&(Ke.current=requestAnimationFrame(()=>pt.current()))},o(()=>(vt(),()=>{Ke.current&&(cancelAnimationFrame(Ke.current),Ke.current=0)}),[vt]),o(()=>{Qe.current=!0,vt()},[d,Ve,Ue,ae,T,F,vt]),o(()=>{if(!Fe)return;const e=setInterval(()=>{var e;const t=mt.current;if(!t||0===t.lastIngestTime)return;const n="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(e=Fe.threshold)&&void 0!==e?e:5e3,i=n-t.lastIngestTime>o;i!==at&&(ct(i),Qe.current=!0,vt())},1e3);return()=>clearInterval(e)},[Fe,at,vt]);const jt=Ze&&rt?we?we(rt):e.createElement(ke,{hover:rt}):null,Lt=jt?e.createElement("div",{className:"stream-frame-tooltip",style:{position:"absolute",left:qe.left+rt.x,top:qe.top+rt.y,transform:`translate(${rt.x>.7*Ve?"calc(-100% - 12px)":"12px"}, ${.3*Ue>rt.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:1}},jt):null,Wt=Ot.current>=0&&rt?e.createElement("svg",{style:{position:"absolute",left:0,top:0,width:Xe[0],height:Xe[1],pointerEvents:"none",zIndex:2}},e.createElement("circle",{cx:rt.x+qe.left,cy:rt.y+qe.top,r:8,fill:"none",stroke:"var(--accent, #6366f1)",strokeWidth:2,strokeDasharray:"4,2"})):null;return e.createElement("div",{ref:Ye,className:"stream-xy-frame"+(z?" "+z:""),role:"img","aria-label":"string"==typeof _e?_e:"XY chart",tabIndex:0,style:{position:"relative",width:C?"100%":Xe[0],height:B?"100%":Xe[1]},onMouseMove:Ze?Nt:void 0,onMouseLeave:Ze?St:void 0,onKeyDown:Mt},Le&&e.createElement("svg",{style:{position:"absolute",left:0,top:0,width:Xe[0],height:Xe[1],pointerEvents:"none"}},Le),e.createElement("canvas",{ref:Je,style:{position:"absolute",left:0,top:0}}),e.createElement(ue,{width:Ve,height:Ue,totalWidth:Xe[0],totalHeight:Xe[1],margin:qe,scales:nt,showAxes:ae,axes:ce,xLabel:he,yLabel:de,xFormat:fe||ye,yFormat:pe||ge,showGrid:Ne,title:_e,legend:je,foregroundGraphics:We,marginalGraphics:Ge,xValues:ht,yValues:dt,annotations:Oe,svgAnnotationRules:Me,annotationFrame:et,xAccessor:"string"==typeof y?y:"string"==typeof M?M:void 0,yAccessor:"string"==typeof g?g:"string"==typeof A?A:void 0,annotationData:null===(c=mt.current)||void 0===c?void 0:c.getData(),pointNodes:null===(h=mt.current)||void 0===h?void 0:h.scene.filter(e=>"point"===e.type)}),(Ce||Be)&&e.createElement(Ae,{width:Ve,height:Ue,totalWidth:Xe[0],totalHeight:Xe[1],margin:qe,dimension:null!==(u=null==Ce?void 0:Ce.dimension)&&void 0!==u?u:"xy",scales:nt,onBrush:null!=Be?Be:()=>{}}),(null==Fe?void 0:Fe.showBadge)&&e.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===Fe.badgePosition?{top:4,left:4}:"bottom-left"===Fe.badgePosition?{bottom:4,left:4}:"bottom-right"===Fe.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:at?"#dc3545":"#28a745",color:"white"})},at?"STALE":"LIVE"),Wt,Lt)});Ee.displayName="StreamXYFrame";const Se={category10:w,tableau10:L,set3:j,blues:N,reds:M,greens:O,oranges:S,purples:E,viridis:A,plasma:k},Oe=w;function Me(e,t,n){if("function"==typeof t)return t(e);const o=e[t];return n?n(o):Oe[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+""))%Oe.length]}function Ne(e,t,n="category10"){const o=Array.from(new Set(e.map(e=>e[t]))),i=o.every(e=>"number"==typeof e||!isNaN(Number(e)));if(Array.isArray(n))return m().domain(o).range(n).unknown("#999");const s=Se[n]||Se.category10;if(i&&"function"==typeof s)return e=>s(Number(e)/Math.max(...o.map(Number)));{const e=Array.isArray(s)?s:Oe;return m().domain(o).range(e).unknown("#999")}}function je(e,t,n=[3,20],o){let i;if(i="function"==typeof t?t(e):e[t],!o)return i;const[s,r]=o,[l,a]=n;return r===s?(l+a)/2:l+(i-s)/(r-s)*(a-l)}const Le=c(null);function We(e){return e?"string"==typeof e?{name:e}:e:null}function _e(e,t,n){return t?o=>{var i;const s=Object.assign({},e(o));if(t.isActive)if(t.predicate(o))(null==n?void 0:n.selectedStyle)&&Object.assign(s,n.selectedStyle);else{const e=null!==(i=null==n?void 0:n.unselectedOpacity)&&void 0!==i?i:.2;s.opacity=e,s.fillOpacity=e,s.strokeOpacity=e,(null==n?void 0:n.unselectedStyle)&&Object.assign(s,n.unselectedStyle)}return s}:e}function $e(t){const o=c(null),s=Ce(t);return[function({children:n}){const s=i(()=>Ce(t),[]);return e.createElement(o.Provider,{value:s,children:n})},e=>{var t;const i=null!==(t=a(o))&&void 0!==t?t:s;return function(e,t){const[o,i]=n(t);return h(()=>e(()=>i(t)),[e]),o}(i.subscribe,()=>e(i.getState()))}]}function Ce(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 Be(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,i]=o.range;t.push(t=>{const o=t[n];return o>=e&&i>=o})}return e=>t.every(t=>t(e))}function He(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}const[ze,Te]=$e(e=>({selections:new Map,setClause(t,n){e(e=>{const o=new Map(e.selections),i=He(o,t),s=new Map(i.clauses);return s.set(n.clientId,n),o.set(t,Object.assign(Object.assign({},i),{clauses:s})),{selections:o}})},clearClause(t,n){e(e=>{const o=e.selections.get(t);if(!o)return{};const i=new Map(e.selections),s=new Map(o.clauses);return s.delete(n),i.set(t,Object.assign(Object.assign({},o),{clauses:s})),{selections:i}})},setResolution(t,n){e(e=>{const o=new Map(e.selections),i=He(o,t);return o.set(t,Object.assign(Object.assign({},i),{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 Fe(e){const t=u(),n=e.clientId||t,{name:o}=e,s=Te(e=>e.selections.get(o)),l=Te(e=>e.setClause),a=Te(e=>e.clearClause),c=i(()=>!!s&&s.clauses.size>0,[s]);return{predicate:i(()=>s&&0!==s.clauses.size?function(e,t){const n=[];for(const[o,i]of e.clauses)"crossfilter"===e.resolution&&o===t||n.push(Be(i));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(s,n):()=>!0,[s,n]),isActive:c,selectPoints:r(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"point",values:new Set(o)};l(o,{clientId:n,type:"point",fields:t})},[n,o,l]),selectInterval:r(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"interval",range:o};l(o,{clientId:n,type:"interval",fields:t})},[n,o,l]),clear:r(()=>{a(o,n)},[a,o,n]),clientId:n}}function Pe(e){const{name:t,xField:n,yField:o}=e,{predicate:s,isActive:l,selectInterval:a,clear:c}=Fe({name:t}),h=n&&o?"xyBrush":n?"xBrush":"yBrush",u=r(e=>{if(!e)return void c();const t={};"xyBrush"===h&&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"===h&&Array.isArray(e)?n&&(t[n]=[Math.min(...e),Math.max(...e)]):"yBrush"===h&&Array.isArray(e)&&o&&(t[o]=[Math.min(...e),Math.max(...e)]),Object.keys(t).length>0&&a(t)},[h,n,o,a,c]);return{brushInteraction:i(()=>({brush:h,during:u,end:u}),[h,u]),predicate:s,isActive:l,clear:c}}const[Ie,De]=$e(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}))}})),Ge="#007bff";function Re(e){return"function"==typeof e?e:t=>t[e]}function Ye(e,t,n="category10"){const o=a(Le);return i(()=>{if(t&&"function"!=typeof t)return o&&Object.keys(o).length>0?i=>o[i]||Ne(e,t,n)(i):Ne(e,t,n)},[e,t,n,o])}function Xe({selection:e,linkedHover:t,fallbackFields:n=[],unwrapData:o=!1,onObservation:i,chartType:s,chartId:l}){const a=function(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields}:null}(t,n),c=Fe({name:(null==e?void 0:e.name)||"__unused__"}),h=function(e){const t=e.name||"hover",{fields:n}=e,{predicate:o,isActive:i,selectPoints:s,clear:l}=Fe({name:t});return{onHover:r(e=>{if(!e)return void l();const t={};for(const o of n){const n=e[o];void 0!==n&&(t[o]=[n])}Object.keys(t).length>0&&s(t)},[n,s,l,t]),predicate:o,isActive:i}}({name:(null==a?void 0:a.name)||"hover",fields:(null==a?void 0:a.fields)||n||[]}),u=De(e=>e.pushObservation),d=e?{isActive:c.isActive,predicate:c.predicate}:null,f=r(e=>{var n,o;if(t)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]),h.onHover(t)}else h.onHover(null);if(i||u){const t={timestamp:Date.now(),chartType:s||"unknown",chartId:l};if(e){let s=e.data||e.datum||e;Array.isArray(s)&&(s=s[0]);const r=Object.assign(Object.assign({},t),{type:"hover",datum:s||{},x:null!==(n=e.x)&&void 0!==n?n:0,y:null!==(o=e.y)&&void 0!==o?o:0});i&&i(r),u&&u(r)}else{const e=Object.assign(Object.assign({},t),{type:"hover-end"});i&&i(e),u&&u(e)}}},[t,h,i,s,l,u]),p=r(e=>{var t,n;if(i||u){const o={timestamp:Date.now(),chartType:s||"unknown",chartId:l};if(e){let s=e.data||e.datum||e;Array.isArray(s)&&(s=s[0]);const r=Object.assign(Object.assign({},o),{type:"click",datum:s||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0});i&&i(r),u&&u(r)}else{const e=Object.assign(Object.assign({},o),{type:"click-end"});i&&i(e),u&&u(e)}}},[i,u,s,l]);return{activeSelectionHook:d,customHoverBehavior:f,customClickBehavior:p}}function qe({data:e,colorBy:t,colorScale:n,showLegend:o,userMargin:s,defaults:r={top:50,bottom:60,left:70,right:40}}){const l=void 0!==o?o:!!t,a=i(()=>{if(l&&t)return function({data:e,colorBy:t,colorScale:n,getColor:o,strokeColor:i,strokeWidth:s}){return{legendGroups:[{styleFn:e=>{const t={fill:e.color,stroke:e.color};return void 0!==i&&(t.stroke=i),void 0!==s&&(t.strokeWidth=s),t},type:"fill",items:Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t]))).map(i=>{const s=e.find("function"==typeof t?e=>t(e)===i:e=>e[t]===i),r=s?o(s,t,n):n?n(i):"#000000";return{label:i+"",color:r}}),label:""}]}}({data:e,colorBy:t,colorScale:n,getColor:Me})},[l,t,e,n]),c=i(()=>{const e=Object.assign(Object.assign({},r),s);return a&&120>e.right&&(e.right=120),e},[r,s,a]);return{legend:a,margin:c}}const Ve={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 Ue(e,t,n){var o,i,s,r,l,a;const c=Ve[e||"primary"],h="context"===e||"sparkline"===e;return{width:null!==(o=t.width)&&void 0!==o?o:c.width,height:null!==(i=t.height)&&void 0!==i?i:c.height,showAxes:c.showAxes,showGrid:null!==(s=t.showGrid)&&void 0!==s?s:c.showGrid,enableHover:null!==(r=t.enableHover)&&void 0!==r?r:!!t.linkedHover||c.enableHover,showLegend:null!==(l=t.showLegend)&&void 0!==l?l:c.showLegend,showLabels:null!==(a=t.showLabels)&&void 0!==a?a:c.showLabels,title:h?void 0:t.title,xLabel:h?void 0:t.xLabel,yLabel:h?void 0:t.yLabel,categoryLabel:h?void 0:t.categoryLabel,valueLabel:h?void 0:t.valueLabel,marginDefaults:c.marginDefaults}}const Ze={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 Je(e,t){return"function"==typeof t?t(e):e[t]}function Ke(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 Qe(t){return!0===t||("function"==typeof t?t:!1!==t&&void 0!==t&&("object"!=typeof t||null===t||!("fields"in t)&&!("title"in t)||function(t={}){const{fields:n,title:o,format:i,style:s={},className:r=""}=t;return t=>{if(!t||"object"!=typeof t)return null;let l;const a=[];if(o){const e=Je(t,o);l=Ke(e,i)}if(n&&n.length>0)n.forEach(e=>{let n,o,s;"string"==typeof e?(n=e,o=e,s=i):(n=e.label,o=e.accessor||e.key||"",s=e.format||i);const r=Je(t,o);a.push({label:n,value:Ke(r,s)})});else if(!o){const e=["value","y","name","id","label"];for(const n of e)if(void 0!==t[n]){l=Ke(t[n],i);break}if(!l){const e=Object.keys(t).filter(e=>!e.startsWith("_"));e.length>0&&(l=Ke(t[e[0]],i))}}const c=Object.assign(Object.assign({},Ze),s);return e.createElement("div",{className:("semiotic-tooltip "+r).trim(),style:c},l&&e.createElement("div",{style:{fontWeight:a.length>0?"bold":"normal"}},l),a.map((t,n)=>e.createElement("div",{key:n,style:{marginTop:0===n&&l?"4px":0}},t.label&&e.createElement("span",null,t.label,": "),t.value)))}}(t)))}function et(e){return"string"==typeof e?e:"value"}function tt(t){return n=>{const o=n.data;return o?e.createElement("div",{className:"semiotic-tooltip",style:Ze},t.map((t,n)=>{const i=function(e,t){return"function"==typeof t?t(e):e[t]}(o,t.accessor),s=null==(r=i)?"–":"number"==typeof r?Math.abs(r)>9999?r.toLocaleString():r+"":r instanceof Date?r.toLocaleDateString():r+"";var r;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"}},s))})):null}}function nt({componentName:t,message:n,width:o,height:i}){return e.createElement("div",{role:"alert",style:{width:o,height:Math.max(i,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 ot 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(nt,{componentName:"ChartErrorBoundary",message:n.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}var it;const st="undefined"!=typeof process&&"production"!==(null===(it=process.env)||void 0===it?void 0:it.NODE_ENV);function rt({componentName:t,width:n,height:o,children:i}){return e.createElement(ot,{fallback:i=>e.createElement(nt,{componentName:t,message:i.message,width:n,height:o})},i)}function lt(e,t,n,o){if(!st)return;if(!t||0===t.length)return;if("string"!=typeof o)return;const i=t[0];if(!i||"object"!=typeof i)return;if(o in i)return;const s=Object.keys(i).join(", ");console.warn(`[semiotic] ${e}: ${n} "${o}" not found in data. Available keys: ${s}`)}function at(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 ct({componentName:e,data:t,accessors:n,requiredProps:o}){if(o)for(const[t,n]of Object.entries(o))if(null==n)return`${e}: ${t} is required. Provide a field name or function.`;if(!t||!Array.isArray(t)||0===t.length)return e+": No data provided. Pass a non-empty array to the data prop.";if(!Array.isArray(t)&&"object"==typeof t)return e+": data should be an array, but received an object. If this is hierarchical data, use TreeDiagram, Treemap, or CirclePack instead.";if(n){const o=function(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:e}(t).find(e=>e&&"object"==typeof e);if(o){const t=Object.keys(o);for(const[i,s]of Object.entries(n))if(s&&"string"==typeof s&&!(s in o)){const n=at(s,t),o=n?` Try ${i}="${n}".`:"";return`${e}: ${i} "${s}" not found in data. Available fields: ${t.join(", ")}.${o}`}}}return null}const ht="__forecastSegment";function ut(e,t){return"function"==typeof t?t(e):!!e[t]}function dt(t){var n,o;const s=Ue(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:r,margin:l,className:a,xFormat:c,yFormat:h,xAccessor:u="x",yAccessor:d="y",lineBy:f,lineDataAccessor:p="coordinates",colorBy:y,colorScheme:g="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:M,frameProps:N={},selection:j,linkedHover:L,onObservation:W,chartId:_}=t,$=s.width,C=s.height,B=s.enableHover,H=s.showGrid,z=s.showLegend,T=s.title,F=s.xLabel,P=s.yLabel,I=r||[];lt("LineChart",I,"xAccessor",u),lt("LineChart",I,"yAccessor",d);const D="string"==typeof u?u:"x",G="string"==typeof d?d:"y",R=i(()=>M?function(e,t,n,o,i){return(s=o).isTraining||s.isForecast||s.isAnomaly||s.upperBounds||s.lowerBounds?function(e,t,n,o,i){var s,r,l;const{isTraining:a,isForecast:c,isAnomaly:h,upperBounds:u,lowerBounds:d,color:f="#6366f1",bandOpacity:p=.15,anomalyColor:y="#ef4444",anomalyRadius:g=6,label:m}=o,v=e.map(e=>{let t="observed";return c&&ut(e,c)?t="forecast":a&&ut(e,a)&&(t="training"),Object.assign(Object.assign({},e),{[ht]:t})}),b=[];if(u&&d){const e="string"==typeof u?u:"__envUpper",t="string"==typeof d?d:"__envLower";if("function"==typeof u||"function"==typeof d)for(const n of v)"function"==typeof u&&(n[e]=u(n)),"function"==typeof d&&(n[t]=d(n));b.push({type:"envelope",upperAccessor:e,lowerAccessor:t,fill:f,fillOpacity:p,label:m})}return h&&b.push({type:"highlight",filter:e=>ut(e,h),color:y,r:g,style:{stroke:y,strokeWidth:1.5,fill:y,fillOpacity:.7}}),i&&b.push({type:"anomaly-band",threshold:null!==(s=i.threshold)&&void 0!==s?s:2,showBand:!1!==i.showBand,fill:i.bandColor||"#6366f1",fillOpacity:null!==(r=i.bandOpacity)&&void 0!==r?r:.1,anomalyColor:i.anomalyColor||"#ef4444",anomalyRadius:null!==(l=i.anomalyRadius)&&void 0!==l?l:6,label:i.label}),{processedData:v,annotations:b}}(e,0,0,o,i):function(e,t,n,o,i){var s,r,l;const{trainEnd:a,steps:c=10,confidence:h=.95,color:u="#6366f1",bandOpacity:d=.15,label:f}=o;if(null==a)return{processedData:e,annotations:[]};const p=[],y=[];for(const n of e)n[t]>a?y.push(Object.assign(Object.assign({},n),{[ht]:"observed"})):p.push(Object.assign(Object.assign({},n),{[ht]:"training"}));const g=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(g.length>=3){const o=g.length;let i=0,s=0,r=0,l=0;for(const[e,t]of g)i+=e,s+=t,r+=e*e,l+=e*t;const a=o*r-i*i;if(Math.abs(a)>1e-12){const r=(o*l-i*s)/a,p=(s-r*i)/o,y=e=>p+r*e,b=g.map(([e,t])=>t-y(e)).reduce((e,t)=>e+t*t,0),x=Math.sqrt(b/Math.max(o-2,1)),w=g.reduce((e,t)=>e+t[0],0)/o,k=g.reduce((e,t)=>e+Math.pow(t[0]-w,2),0),A=.99>h?.95>h?.9>h?1:1.645:1.96:2.576,E=e.map(e=>e[t]).filter(e=>null!=e&&isFinite(e)),S=Math.max(...E),O=g.length>1?(g[o-1][0]-g[0][0])/(o-1):1;for(let e=1;c>=e;e++){const i=S+e*O,s=y(i),r=x*Math.sqrt(1+1/o+(k>0?Math.pow(i-w,2)/k:0))*A;v.push({[t]:i,[n]:s,[ht]:"forecast",__forecastUpper:s+r,__forecastLower:s-r})}m.push({type:"envelope",upperAccessor:"__forecastUpper",lowerAccessor:"__forecastLower",fill:u,fillOpacity:d,label:f})}}return m.push({type:"x-threshold",x:a,color:"#94a3b8",strokeWidth:1,strokeDasharray:"4,2",label:"Train / Forecast"}),i&&m.push({type:"anomaly-band",threshold:null!==(s=i.threshold)&&void 0!==s?s:2,showBand:!1!==i.showBand,fill:i.bandColor||"#6366f1",fillOpacity:null!==(r=i.bandOpacity)&&void 0!==r?r:.1,anomalyColor:i.anomalyColor||"#ef4444",anomalyRadius:null!==(l=i.anomalyRadius)&&void 0!==l?l:6,label:i.label}),{processedData:[...p,...y,...v],annotations:m}}(e,t,n,o,i);var s}(I,D,G,M,O):null,[I,M,O,D,G]),Y=i(()=>R?R.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):[],[R,O]),X=R?R.processedData:I,q=M&&!f?ht:f,{activeSelectionHook:V,customHoverBehavior:U}=Xe({selection:j,linkedHover:L,fallbackFields:y?["string"==typeof y?y:""]:[],onObservation:W,chartType:"LineChart",chartId:_}),Z=void 0!==(null===(n=X[0])||void 0===n?void 0:n[p]),J=i(()=>{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=Ye(X,y,g),Q=i(()=>e=>{const t={strokeWidth:k};return t.stroke=y?Me(e,y,K):Ge,x&&(t.fill=t.stroke,t.fillOpacity=w),t},[y,K,k,x,w]),ee=i(()=>M?function(e,t){var n,o;const i=null!==(n=t.trainDasharray)&&void 0!==n?n:"8,4",s=null!==(o=t.forecastDasharray)&&void 0!==o?o:"4,4",r=t.color||"#6366f1";return t=>{const n=e(t),o=t[ht];return"training"===o?Object.assign(Object.assign({},n),{strokeDasharray:i}):"forecast"===o?Object.assign(Object.assign({},n),{stroke:r,strokeDasharray:s}):n}}(Q,M):Q,[Q,M]),te=i(()=>_e(ee,V,j),[ee,V,j]),ne=i(()=>{if(v)return e=>{const t={r:b,fillOpacity:1};return t.fill=y?Me(e.parentLine||e,y,K):Ge,t}},[v,b,y,K]),oe=x?"area":"line",{legend:ie,margin:se}=qe({data:J,colorBy:y,colorScale:K,showLegend:z,userMargin:l,defaults:s.marginDefaults}),re=f||y,le=i(()=>tt([{label:F||et(u),accessor:u,role:"x"},{label:P||et(d),accessor:d,role:"y"},...re?[{label:et(re),accessor:re,role:"group"}]:[]]),[u,d,F,P,re]),ae=ct({componentName:"LineChart",data:Z?(null===(o=X[0])||void 0===o?void 0:o[p])||[]:I,accessors:{xAccessor:u,yAccessor:d}});if(ae)return e.createElement(nt,{componentName:"LineChart",message:ae,width:$,height:C});const ce=i(()=>Z||q?J.flatMap(e=>{const t=e[p]||[];return q&&"string"==typeof q?t.map(t=>Object.assign(Object.assign({},t),{[q]:e[q]})):t}):X,[J,p,Z,q,X]),he=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:u,yAccessor:d,groupAccessor:q||void 0,curve:m,lineStyle:te},v&&{pointStyle:ne}),{size:[$,C],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:se,showAxes:s.showAxes,xLabel:F,yLabel:P,xFormat:c,yFormat:h,enableHover:B,showGrid:H}),ie&&{legend:ie}),T&&{title:T}),a&&{className:a}),{tooltipContent:A?Qe(A):le}),(L||W)&&{customHoverBehavior:U}),E&&{pointIdAccessor:E}),((null==S?void 0:S.length)||Y.length)&&{annotations:[...S||[],...Y]}),N);return e.createElement(rt,{componentName:"LineChart",width:$,height:C},e.createElement(Ee,Object.assign({},he)))}function ft(t){var n;const o=Ue(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:s,margin:r,className:l,xFormat:a,yFormat:c,xAccessor:h="x",yAccessor:u="y",areaBy:d,y0Accessor:f,gradientFill:p=!1,lineDataAccessor:y="coordinates",colorBy:g,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:M,chartId:N}=t,j=o.width,L=o.height,W=o.enableHover,_=o.showGrid,$=o.showLegend,C=o.title,B=o.xLabel,H=o.yLabel,z=s||[];lt("AreaChart",z,"xAccessor",h),lt("AreaChart",z,"yAccessor",u);const{activeSelectionHook:T,customHoverBehavior:F}=Xe({selection:S,linkedHover:O,fallbackFields:g?["string"==typeof g?g:""]:[],onObservation:M,chartType:"AreaChart",chartId:N}),P=void 0!==(null===(n=z[0])||void 0===n?void 0:n[y]),I=i(()=>{if(P)return z;if(d){const e=z.reduce((e,t)=>{const n="function"==typeof d?d(t):t[d];if(!e[n]){const t={[y]:[]};"string"==typeof d&&(t[d]=n),e[n]=t}return e[n][y].push(t),e},{});return Object.values(e)}return[{[y]:z}]},[z,d,y,P]),D=Ye(z,g,m),G=i(()=>e=>{const t={},n=g?Me(e,g,D):Ge;return t.fill=n,t.fillOpacity=b,x?(t.stroke=n,t.strokeWidth=w):t.stroke="none",t},[g,D,b,x,w]),R=i(()=>_e(G,T,S),[G,T,S]),{legend:Y,margin:X}=qe({data:I,colorBy:g,colorScale:D,showLegend:$,userMargin:r,defaults:o.marginDefaults}),q=d||g,V=i(()=>tt([{label:B||et(h),accessor:h,role:"x"},{label:H||et(u),accessor:u,role:"y"},...q?[{label:et(q),accessor:q,role:"group"}]:[]]),[h,u,B,H,q]),U=ct({componentName:"AreaChart",data:z,accessors:{xAccessor:h,yAccessor:u}});if(U)return e.createElement(nt,{componentName:"AreaChart",message:U,width:j,height:L});const Z=i(()=>P||d?I.flatMap(e=>{const t=e[y]||[];return d&&"string"==typeof d?t.map(t=>Object.assign(Object.assign({},t),{[d]:e[d]})):t}):z,[I,y,P,d,z]),J=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"area",data:Z,xAccessor:h,yAccessor:u,groupAccessor:d||void 0},f&&{y0Accessor:f}),p&&{gradientFill:p}),{curve:v,lineStyle:R,size:[j,L],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:X,showAxes:o.showAxes,xLabel:B,yLabel:H,xFormat:a,yFormat:c,enableHover:W,showGrid:_}),Y&&{legend:Y}),C&&{title:C}),l&&{className:l}),{tooltipContent:k?Qe(k):V}),(O||M)&&{customHoverBehavior:F}),A&&A.length>0&&{annotations:A}),E);return e.createElement(rt,{componentName:"AreaChart",width:j,height:L},e.createElement(Ee,Object.assign({},J)))}function pt(t){var n;const o=Ue(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:s,margin:r,className:l,xFormat:a,yFormat:c,xAccessor:h="x",yAccessor:u="y",areaBy:d,lineDataAccessor:f="coordinates",colorBy:p,colorScheme:y="category10",curve:g="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:M}=t,N=o.width,j=o.height,L=o.enableHover,W=o.showGrid,_=o.showLegend,$=o.title,C=o.xLabel,B=o.yLabel,H=s||[],{activeSelectionHook:z,customHoverBehavior:T}=Xe({selection:E,linkedHover:S,fallbackFields:p?["string"==typeof p?p:""]:[],onObservation:O,chartType:"StackedAreaChart",chartId:M}),F=void 0!==(null===(n=H[0])||void 0===n?void 0:n[f]),P=i(()=>{if(F)return H;if(d){const e=H.reduce((e,t)=>{const n="function"==typeof d?d(t):t[d];if(!e[n]){const t={[f]:[]};"string"==typeof d&&(t[d]=n),e[n]=t}return e[n][f].push(t),e},{});return Object.values(e)}return[{[f]:H}]},[H,d,f,F]),I=Ye(H,p,y),D=i(()=>e=>{const t={},n=p?Me(e,p,I):Ge;return t.fill=n,t.fillOpacity=m,v?(t.stroke=n,t.strokeWidth=b):t.stroke="none",t},[p,I,m,v,b]),G=i(()=>_e(D,z,E),[D,z,E]),{legend:R,margin:Y}=qe({data:P,colorBy:p,colorScale:I,showLegend:_,userMargin:r,defaults:o.marginDefaults}),X=d||p,q=i(()=>tt([{label:C||et(h),accessor:h,role:"x"},{label:B||et(u),accessor:u,role:"y"},...X?[{label:et(X),accessor:X,role:"group"}]:[]]),[h,u,C,B,X]),V=ct({componentName:"StackedAreaChart",data:H,accessors:{xAccessor:h,yAccessor:u}});if(V)return e.createElement(nt,{componentName:"StackedAreaChart",message:V,width:N,height:j});const U=i(()=>F||d?P.flatMap(e=>{const t=e[f]||[];return d&&"string"==typeof d?t.map(t=>Object.assign(Object.assign({},t),{[d]:e[d]})):t}):H,[P,f,F,d,H]),Z=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"stackedarea",data:U,xAccessor:h,yAccessor:u,groupAccessor:d||void 0,curve:g,normalize:x,lineStyle:G,size:[N,j],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Y,showAxes:o.showAxes,xLabel:C,yLabel:B,xFormat:a,yFormat:c,enableHover:L,showGrid:W},R&&{legend:R}),$&&{title:$}),l&&{className:l}),{tooltipContent:w?Qe(w):q}),(S||O)&&{customHoverBehavior:T}),k&&k.length>0&&{annotations:k}),A);return e.createElement(rt,{componentName:"StackedAreaChart",width:N,height:j},e.createElement(Ee,Object.assign({},Z)))}function yt(t){const n=Ue(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:o,margin:s,className:r,xFormat:l,yFormat:a,xAccessor:c="x",yAccessor:h="y",colorBy:u,colorScheme:d="category10",sizeBy:f,sizeRange:p=[3,15],pointRadius:y=5,pointOpacity:g=.8,tooltip:m,marginalGraphics:v,pointIdAccessor:b,annotations:x,frameProps:w={},selection:k,linkedHover:A,linkedBrush:E,onObservation:S,chartId:O}=t,M=n.width,N=n.height,j=n.enableHover,L=n.showGrid,W=n.showLegend,_=n.title,$=n.xLabel,C=n.yLabel,B=o||[];lt("Scatterplot",B,"xAccessor",c),lt("Scatterplot",B,"yAccessor",h);const{activeSelectionHook:H,customHoverBehavior:z}=Xe({selection:k,linkedHover:A,fallbackFields:u?["string"==typeof u?u:""]:[],onObservation:S,chartType:"Scatterplot",chartId:O}),T=We(E);Pe({name:(null==T?void 0:T.name)||"__unused_brush__",xField:(null==T?void 0:T.xField)||("string"==typeof c?c:void 0),yField:(null==T?void 0:T.yField)||("string"==typeof h?h:void 0)});const F=Ye(B,u,d),P=i(()=>{if(!f||0===B.length)return;const e=B.map(e=>"function"==typeof f?f(e):e[f]);return[Math.min(...e),Math.max(...e)]},[B,f]),I=i(()=>e=>{const t={fillOpacity:g};return t.fill=u?Me(e,u,F):Ge,t.r=f?je(e,f,p,P):y,t},[u,F,f,p,P,y,g]),D=i(()=>_e(I,H,k),[I,H,k]),{legend:G,margin:R}=qe({data:B,colorBy:u,colorScale:F,showLegend:W,userMargin:s,defaults:n.marginDefaults}),Y=i(()=>tt([{label:$||et(c),accessor:c,role:"x"},{label:C||et(h),accessor:h,role:"y"},...u?[{label:et(u),accessor:u,role:"color"}]:[],...f?[{label:et(f),accessor:f,role:"size"}]:[]]),[c,h,$,C,u,f]),X=ct({componentName:"Scatterplot",data:B,accessors:{xAccessor:c,yAccessor:h}});if(X)return e.createElement(nt,{componentName:"Scatterplot",message:X,width:M,height:N});const q=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter",data:B,xAccessor:c,yAccessor:h,colorAccessor:u||void 0,sizeAccessor:f||void 0,sizeRange:p,pointStyle:D,colorScheme:d,size:[M,N],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:R,showAxes:n.showAxes,xLabel:$,yLabel:C,xFormat:l,yFormat:a,enableHover:j,showGrid:L},G&&{legend:G}),_&&{title:_}),r&&{className:r}),{tooltipContent:m?Qe(m):Y}),(A||S)&&{customHoverBehavior:z}),v&&{marginalGraphics:v}),b&&{pointIdAccessor:b}),x&&x.length>0&&{annotations:x}),w);return e.createElement(rt,{componentName:"Scatterplot",width:M,height:N},e.createElement(Ee,Object.assign({},q)))}function gt(t){const n=Ue(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:o,className:s,xFormat:r,yFormat:l,xAccessor:a="x",yAccessor:c="y",orderAccessor:h,orderLabel:u,pointRadius:d=4,tooltip:f,pointIdAccessor:p,annotations:y,frameProps:g={},selection:m,linkedHover:v,onObservation:b,chartId:x}=t,w=n.width,k=n.height,E=n.enableHover,S=n.showGrid,O=n.title,M=n.xLabel,N=n.yLabel,j=o||[],L=i(()=>{if(!h||0===j.length)return j;const e="function"==typeof h?h:e=>e[h];return[...j].sort((t,n)=>{const o=e(t),i=e(n);return(o instanceof Date?o.getTime():+o)-(i instanceof Date?i.getTime():+i)})},[j,h]);lt("ConnectedScatterplot",L,"xAccessor",a),lt("ConnectedScatterplot",L,"yAccessor",c);const{activeSelectionHook:W,customHoverBehavior:_}=Xe({selection:m,linkedHover:v,fallbackFields:[],onObservation:b,chartType:"ConnectedScatterplot",chartId:x}),$=L.length,C=$>0&&100>$,B=i(()=>0===$?[]:L.map((e,t)=>A(1===$?.5:t/($-1))),[L,$]);i(()=>null,[$]);const H=i(()=>{if($>=2)return(t,n,o)=>{var i,s;if("connected-lines"!==t.type)return null;const r=o.scales;if(!r)return null;const l=null!==(i=r.x)&&void 0!==i?i:r.time,h=null!==(s=r.y)&&void 0!==s?s:r.value;if(!l||!h)return null;const u="string"==typeof a?e=>e[a]:a,f="string"==typeof c?e=>e[c]:c,p=[];for(let t=0;L.length-1>t;t++){const n=L[t],o=L[t+1],i=l(u(n)),s=h(f(n)),r=l(u(o)),a=h(f(o)),c=B[t];C&&p.push(e.createElement("line",{key:"halo-"+t,x1:i,y1:s,x2:r,y2:a,stroke:"white",strokeWidth:d+2,strokeOpacity:.5,strokeLinecap:"round"})),p.push(e.createElement("line",{key:"conn-"+t,x1:i,y1:s,x2:r,y2:a,stroke:c,strokeWidth:d,strokeLinecap:"round"}))}return e.createElement("g",{key:"ann-"+n},p)}},[L,B,d,C,a,c,$]),z=i(()=>e=>{const t=L.indexOf(e);return{fill:t>=0&&B.length>t?B[t]:"#6366f1",stroke:"white",strokeWidth:1,r:d,fillOpacity:1}},[L,B,d]),T=i(()=>_e(z,W,m),[z,W,m]),F=Object.assign({top:50,right:40,bottom:60,left:70},t.margin),P=u||("string"==typeof h?h:"Order"),I=i(()=>tt([{label:M||et(a),accessor:a,role:"x"},{label:N||et(c),accessor:c,role:"y"},...h?[{label:P,accessor:h,role:"group"}]:[]]),[a,c,M,N,h,P]),D=ct({componentName:"ConnectedScatterplot",data:L,accessors:{xAccessor:a,yAccessor:c}});if(D)return e.createElement(nt,{componentName:"ConnectedScatterplot",message:D,width:w,height:k});const G=i(()=>[{type:"connected-lines"},...y||[]],[y]),R=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter",data:L,xAccessor:a,yAccessor:c,pointStyle:T,size:[w,k],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:F,showAxes:n.showAxes,xLabel:M,yLabel:N,xFormat:r,yFormat:l,enableHover:E,showGrid:S},O&&{title:O}),s&&{className:s}),{tooltipContent:f?Qe(f):I}),(v||b)&&{customHoverBehavior:_}),p&&{pointIdAccessor:p}),{annotations:G,svgAnnotationRules:H}),g);return e.createElement(rt,{componentName:"ConnectedScatterplot",width:w,height:k},e.createElement(Ee,Object.assign({},R)))}function mt(t){const n=Ue(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:o,margin:s,className:r,xFormat:l,yFormat:a,xAccessor:c="x",yAccessor:h="y",sizeBy:u,sizeRange:d=[5,40],colorBy:f,colorScheme:p="category10",bubbleOpacity:y=.6,bubbleStrokeWidth:g=1,bubbleStrokeColor:m="white",tooltip:v,marginalGraphics:b,pointIdAccessor:x,annotations:w,frameProps:k={},selection:A,linkedHover:E,linkedBrush:S,onObservation:O,chartId:M}=t,N=n.width,j=n.height,L=n.enableHover,W=n.showGrid,_=n.showLegend,$=n.title,C=n.xLabel,B=n.yLabel,H=o||[],{activeSelectionHook:z,customHoverBehavior:T}=Xe({selection:A,linkedHover:E,fallbackFields:f?["string"==typeof f?f:""]:[],onObservation:O,chartType:"BubbleChart",chartId:M}),F=We(S);Pe({name:(null==F?void 0:F.name)||"__unused_brush__",xField:(null==F?void 0:F.xField)||("string"==typeof c?c:void 0),yField:(null==F?void 0:F.yField)||("string"==typeof h?h:void 0)});const P=Ye(H,f,p),I=i(()=>{const e=H.map(e=>"function"==typeof u?u(e):e[u]);return[Math.min(...e),Math.max(...e)]},[H,u]),D=i(()=>e=>{const t={fillOpacity:y,strokeWidth:g,stroke:m};return t.fill=f?Me(e,f,P):Ge,t.r=je(e,u,d,I),t},[f,P,u,d,I,y,g,m]),G=i(()=>_e(D,z,A),[D,z,A]),{legend:R,margin:Y}=qe({data:H,colorBy:f,colorScale:P,showLegend:_,userMargin:s,defaults:n.marginDefaults}),X=i(()=>tt([{label:C||et(c),accessor:c,role:"x"},{label:B||et(h),accessor:h,role:"y"},{label:et(u),accessor:u,role:"size"},...f?[{label:et(f),accessor:f,role:"color"}]:[]]),[c,h,C,B,u,f]),q=ct({componentName:"BubbleChart",data:H,accessors:{xAccessor:c,yAccessor:h},requiredProps:{sizeBy:u}});if(q)return e.createElement(nt,{componentName:"BubbleChart",message:q,width:N,height:j});const V=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bubble",data:H,xAccessor:c,yAccessor:h,colorAccessor:f||void 0,sizeAccessor:u,sizeRange:d,pointStyle:G,colorScheme:p,size:[N,j],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Y,showAxes:n.showAxes,xLabel:C,yLabel:B,xFormat:l,yFormat:a,enableHover:L,showGrid:W},R&&{legend:R}),$&&{title:$}),r&&{className:r}),{tooltipContent:v?Qe(v):X}),(E||O)&&{customHoverBehavior:T}),b&&{marginalGraphics:b}),x&&{pointIdAccessor:x}),w&&w.length>0&&{annotations:w}),k);return e.createElement(rt,{componentName:"BubbleChart",width:N,height:j},e.createElement(Ee,Object.assign({},V)))}function vt(t){const n=Ue(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:s,className:r,xAccessor:l="x",yAccessor:a="y",valueAccessor:c="value",xFormat:h,yFormat:u,colorScheme:d="blues",customColorScale:f,showValues:p=!1,valueFormat:y,cellBorderColor:g="#fff",cellBorderWidth:m=1,tooltip:b,annotations:x,frameProps:w={},selection:k,linkedHover:E,onObservation:S,chartId:j}=t,L=n.width,W=n.height,_=n.enableHover,$=n.title,C=n.xLabel,B=n.yLabel,H=o||[],{margin:z}=qe({data:H,colorBy:void 0,colorScale:void 0,showLegend:!1,userMargin:s,defaults:n.marginDefaults}),{activeSelectionHook:T,customHoverBehavior:F}=Xe({selection:k,linkedHover:E,fallbackFields:[],onObservation:S,chartType:"Heatmap",chartId:j}),P=i(()=>"function"==typeof c?e=>c(e):e=>e[c],[c]),I=i(()=>{const e=H.map(P);return[Math.min(...e),Math.max(...e)]},[H,P]),D=i(()=>"custom"===d&&f?f:v({blues:N,reds:M,greens:O,viridis:A}[d]||N).domain(I),[d,f,I]);i(()=>{const e=Re(l),t=Re(a);return{xBinCount:new Set(H.map(e)).size,yBinCount:new Set(H.map(t)).size}},[H,l,a]),i(()=>({coordinates:H}),[H]);const G=i(()=>e=>{const t=P(e);return{fill:D(t),stroke:g,strokeWidth:m}},[P,D,g,m]);i(()=>_e(G,T,k),[G,T,k]),i(()=>{if(!p)return;const t=(I[0]+I[1])/2;return(n,o)=>{const i=P(n),s=y?y(i):i+"";return e.createElement("text",{textAnchor:"middle",dominantBaseline:"middle",fill:P(n)>t?"#fff":"#000",fontSize:"12px"},s)}},[p,P,y,I]);const R=i(()=>tt([{label:C||et(l),accessor:l,role:"x"},{label:B||et(a),accessor:a,role:"y"},{label:et(c),accessor:c,role:"value"}]),[l,a,C,B,c]),Y=ct({componentName:"Heatmap",data:H,accessors:{xAccessor:l,yAccessor:a,valueAccessor:c}});if(Y)return e.createElement(nt,{componentName:"Heatmap",message:Y,width:L,height:W});const X=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"heatmap",data:H,xAccessor:l,yAccessor:a,valueAccessor:c,size:[L,W],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:z,showAxes:n.showAxes,xLabel:C,yLabel:B,xFormat:h,yFormat:u,enableHover:_},$&&{title:$}),r&&{className:r}),{tooltipContent:b?Qe(b):R}),(E||S)&&{customHoverBehavior:F}),x&&x.length>0&&{annotations:x}),w);return e.createElement(rt,{componentName:"Heatmap",width:L,height:W},e.createElement(Ee,Object.assign({},X)))}function bt({selections:e}){const t=Te(e=>e.setResolution);return o(()=>{for(const[n,o]of Object.entries(e))o.resolution&&t(n,o.resolution)},[e,t]),null}function xt({children:t,selections:n}){return e.createElement(ze,null,e.createElement(Ie,null,n&&e.createElement(bt,{selections:n}),t))}dt.displayName="LineChart",ft.displayName="AreaChart",pt.displayName="StackedAreaChart",yt.displayName="Scatterplot",gt.displayName="ConnectedScatterplot",mt.displayName="BubbleChart",vt.displayName="Heatmap";const wt="__splomIdx",kt={top:4,bottom:4,left:4,right:4};function At({frameRef:n,cellSize:i,onBrush:s}){const r=t(null),l=i-kt.left-kt.right,a=i-kt.top-kt.bottom;return o(()=>{if(!r.current)return;const e=y(r.current).select(".brush-g"),t=p().extent([[0,0],[l,a]]).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 s(null);const[[i,r],[l,a]]=e.selection,c=[[o.x.invert(i),o.y.invert(r)],[o.x.invert(l),o.y.invert(a)]];s(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)}},[l,a,n,s]),e.createElement("svg",{ref:r,width:i,height:i,style:{position:"absolute",top:0,left:0}},e.createElement("g",{className:"brush-g",transform:`translate(${kt.left},${kt.top})`}))}function Et({data:n,xField:o,yField:i,cellSize:s,pointRadius:l,pointOpacity:a,colorBy:c,colorScale:h,brushSelectionName:u,hoverSelectionName:d,unselectedOpacity:f,mode:p,onPointHover:y}){const g=t(null),m=Fe({name:u,clientId:`splom-${o}-${i}`}),v=Pe({name:u,xField:o,yField:i}),b=Fe({name:d,clientId:"splom-hover-source"}),x=b.selectPoints,w=r(e=>{e?v.brushInteraction.during(e):v.brushInteraction.end(null)},[v.brushInteraction]),k=r(e=>{if(!e)return void(null==y||y(null));const t=e.data,n=null==t?void 0:t[wt];void 0!==n&&(x({[wt]:[n]}),null==y||y(t,e.x+kt.left,e.y+kt.top))},[x,y]),A=r(e=>{const t={opacity:a,r:l};return t.fill=c?Me(e,c,h):Ge,"hover"===p?b.isActive&&b.predicate(e)?(t.opacity=1,t.r=2.5*l,t.stroke="#333",t.strokeWidth=1.5):b.isActive&&(t.opacity=.6*a):m.isActive&&!m.predicate(e)&&(t.opacity=f),t},[c,h,a,l,p,m.isActive,m.predicate,b.isActive,b.predicate,f]);return e.createElement("div",{style:{position:"relative",width:s,height:s}},e.createElement(Ee,{ref:g,chartType:"scatter",data:n,size:[s,s],xAccessor:o,yAccessor:i,pointStyle:A,margin:kt,showAxes:!1,enableHover:"hover"===p,customHoverBehavior:"hover"===p?k:void 0,tooltipContent:"hover"===p?()=>null:void 0}),"brush"===p&&e.createElement(At,{frameRef:g,cellSize:s,xField:o,yField:i,onBrush:w}))}function St({data:t,field:n,label:o,cellSize:s,bins:r,brushSelectionName:l,hoverSelectionName:a,mode:c}){const h=Fe({name:l,clientId:"splom-diag-"+n}),u=Fe({name:a,clientId:`splom-diag-${n}-hover`}),d="hover"===c?u:h,f=d.isActive,p=d.predicate,y=i(()=>{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),i=(Math.max(...e)-o)/r||1,l=Array(r).fill(0),a=Array(r).fill(0);for(const e of t){const t=e[n];if(null==t||isNaN(t))continue;const s=Math.min(Math.floor((t-o)/i),r-1);l[s]++,f&&!p(e)||a[s]++}const c=Math.max(...l,1);return{bars:l.map((e,t)=>({x:t/r*s,w:s/r-1,h:e/c*(s-24),count:e})),selectedBars:a.map((e,t)=>({x:t/r*s,w:s/r-1,h:e/c*(s-24),count:e})),max:c}},[t,n,r,s,f,p]);return e.createElement("svg",{width:s,height:s,style:{overflow:"hidden"}},e.createElement("text",{x:s/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:s-t.h,width:Math.max(t.w,1),height:t.h,fill:"#ccc",opacity:f?.3:.6})),f&&y.selectedBars.map((t,n)=>e.createElement("rect",{key:"sel-"+n,x:t.x,y:s-t.h,width:Math.max(t.w,1),height:t.h,fill:Ge,opacity:.7})))}function Ot({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 Mt(t){const{data:o,fields:s,fieldLabels:l={},colorBy:a,colorScheme:c="category10",cellSize:h=150,cellGap:u=4,pointRadius:d=2,pointOpacity:f=.5,diagonal:p="histogram",histogramBins:y=20,brushMode:g="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",M="splom-hover",N=m?"hover":g?"brush":"hover",j=Te(e=>e.clearSelection),[L,W]=n(null),_=r(()=>{j(M),W(null)},[j,M]),$=i(()=>(o||[]).map((e,t)=>void 0!==e[wt]?e:Object.assign(Object.assign({},e),{[wt]:t})),[o]),C=Ye($,a,c),B=void 0!==w?w:!!a,H=i(()=>{if(!B||!a)return null;const e="string"==typeof a?a:null;return e?[...new Set($.map(t=>t[e]))].map(e=>({label:e+"",color:C?C(e+""):Ge})):null},[B,a,$,C]),z=i(()=>({display:"grid",gridTemplateColumns:"40px "+s.map(()=>h+"px").join(" "),gridTemplateRows:s.map(()=>h+"px").join(" ")+" 40px",gap:u+"px",width:"fit-content"}),[s,h,u,40]);return e.createElement("div",{className:A,style:{position:"relative"}},H&&e.createElement("div",{style:{display:"flex",gap:12,marginBottom:8,flexWrap:"wrap"}},H.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:z,onMouseLeave:"hover"===N?_:void 0},s.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"}},l[t]||t),s.map((o,i)=>n===i?"label"===p?e.createElement(Ot,{key:"diag-"+t,label:l[t]||t,cellSize:h}):e.createElement(St,{key:"diag-"+t,data:$,field:t,label:l[t]||t,cellSize:h,bins:y,colorBy:a,colorScale:C,brushSelectionName:O,hoverSelectionName:M,unselectedOpacity:v,mode:N}):e.createElement(Et,{key:`cell-${t}-${o}`,data:$,xField:o,yField:t,fieldLabels:l,cellSize:h,pointRadius:d,pointOpacity:f,colorBy:a,colorScale:C,brushSelectionName:O,hoverSelectionName:M,unselectedOpacity:v,showGrid:b,tooltip:x,mode:N,onPointHover:"hover"===N?(e,s,r)=>{e?(W({datum:e,xField:o,yField:t,colIndex:i,rowIndex:n,px:null!=s?s:0,py:null!=r?r:0}),E&&E({type:"hover",datum:e,x:null!=s?s:0,y:null!=r?r:0,timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:S})):(W(null),E&&E({type:"hover-end",timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:S}))}:void 0})))),e.createElement("div",null)," ",s.map(t=>e.createElement("div",{key:"col-label-"+t,style:{display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:"bold",color:"#333"}},l[t]||t))),L&&"hover"===N&&(()=>{const t=L.datum,n=l[L.xField]||L.xField,o=l[L.yField]||L.yField,i=a?"function"==typeof a?a(t):t[a]:null,s=k?"function"==typeof k?k(t):t[k]:"Row "+t[wt];return e.createElement("div",{style:{position:"absolute",left:40+L.colIndex*(h+u)+L.px,top:L.rowIndex*(h+u)+L.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}},s+""),e.createElement("div",null,n,": ",null!=t[L.xField]?Number(t[L.xField]).toFixed(1):"–"),e.createElement("div",null,o,": ",null!=t[L.yField]?Number(t[L.yField]).toFixed(1):"–"),null!=i&&e.createElement("div",{style:{opacity:.8}},"string"==typeof a?a:"group",": ",i+""))})())}function Nt(t){const{brushMode:n="crossfilter",hoverMode:o=!0}=t,i={};return!o&&n&&(i.splom={resolution:n}),o&&(i["splom-hover"]={resolution:"union"}),e.createElement(xt,{selections:i},e.createElement(Mt,Object.assign({},t)))}function jt({width:n,height:i,margin:s,scales:r,brushDirection:l,extent:a,onBrush:c}){const h=t(null),u=t(null),p=t(!1),g=n+s.left+s.right,m=i+s.top+s.bottom;return o(()=>{if(!h.current||!r)return;const e=y(h.current).select(".brush-group"),t="x"===l?d().extent([[0,0],[n,i]]):f().extent([[0,0],[n,i]]);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"===l?r.x:r.y).invert;if(!n)return;const o=[n(t[0]),n(t[1])];c(o)}),e.call(t),u.current=t,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.2).attr("stroke","steelblue").attr("stroke-width",1),()=>{t.on("brush end",null)}},[r,n,i,l,c]),o(()=>{if(!u.current||!r||!h.current)return;const e=y(h.current).select(".brush-group"),t="x"===l?r.x:r.y;if(p.current=!0,a){const n=[t(a[0]),t(a[1])];e.call(u.current.move,n)}else e.call(u.current.move,null);p.current=!1},[a,r,l]),e.createElement("svg",{ref:h,width:g,height:m,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},e.createElement("g",{className:"brush-group",transform:`translate(${s.left},${s.top})`}))}function Lt(s){var l,a;const{data:c,width:h=600,height:u=400,margin:d,className:f,title:p,xLabel:y,yLabel:g,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:M=!1,areaOpacity:N=.3,showPoints:j=!1,pointRadius:L=3,enableHover:W=!0,showGrid:_=!1,showLegend:$,tooltip:C,minimap:B={},renderBefore:H=!1,onBrush:z,brushExtent:T,frameProps:F={}}=s,P=c||[],[I,D]=n(null),G=null!=T?T:I,R=r(e=>{T||D(e),null==z||z(e)},[T,z]),Y=t(null),[X,q]=n(null);o(()=>{const e=()=>{var t,n;const o=null===(n=null===(t=Y.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===(l=P[0])||void 0===l?void 0:l[k]),U=i(()=>{if(V)return P;if(w){const e=P.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]:P}]},[P,w,k,V]),Z=i(()=>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}):P,[U,k,V,w,P]),J=Ye(P,A,E),K=i(()=>e=>{const t={strokeWidth:O};return t.stroke=A?Me(e,A,J):Ge,M&&(t.fill=t.stroke,t.fillOpacity=N),t},[A,J,O,M,N]),Q=i(()=>B.lineStyle?B.lineStyle:e=>{const t={strokeWidth:1};return t.stroke=A?Me(e,A,J):Ge,t},[A,J,B.lineStyle]),ee=i(()=>{if(j)return e=>{const t={r:L,fillOpacity:1};return t.fill=A?Me(e.parentLine||e,A,J):Ge,t}},[j,L,A,J]),{legend:te,margin:ne}=qe({data:U,colorBy:A,colorScale:J,showLegend:$,userMargin:d}),oe=B.height||60,ie=i(()=>{var e,t,n,o,i,s,r,l;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!==(s=null===(i=B.margin)||void 0===i?void 0:i.left)&&void 0!==s?s:ne.left,right:null!==(l=null===(r=B.margin)||void 0===r?void 0:r.right)&&void 0!==l?l:ne.right}},[B.margin,ne]),se=B.brushDirection||"x",re=ct({componentName:"MinimapChart",data:P,accessors:{xAccessor:b,yAccessor:x}});if(re)return e.createElement(nt,{componentName:"MinimapChart",message:re,width:h,height:u});const le=M?"area":"line",ae=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:le,data:Z,xAccessor:b,yAccessor:x,groupAccessor:w||void 0,curve:S,lineStyle:K},j&&{pointStyle:ee}),{size:[h,u],responsiveWidth:s.responsiveWidth,responsiveHeight:s.responsiveHeight,margin:ne,showAxes:!0,xLabel:y,yLabel:g,xFormat:m,yFormat:v,enableHover:W,showGrid:_}),te&&{legend:te}),p&&{title:p}),C&&{tooltipContent:Qe(C)}),G&&{xExtent:G}),F),ce={chartType:le,data:Z,xAccessor:b,yAccessor:x,groupAccessor:w||void 0,curve:S,lineStyle:Q,size:[h,oe+ie.top+ie.bottom],margin:ie,showAxes:null!==(a=B.showAxes)&&void 0!==a&&a,background:B.background,enableHover:!1},he=e.createElement("div",{key:"minimap",style:{position:"relative",width:h,overflow:"hidden"}},e.createElement(Ee,Object.assign({ref:Y},ce)),e.createElement(jt,{width:h-ie.left-ie.right,height:oe,margin:ie,scales:X,brushDirection:se,extent:G,onBrush:R})),ue=e.createElement("div",{key:"main",style:{overflow:"hidden"}},e.createElement(Ee,Object.assign({},ae)));return e.createElement("div",{className:"minimap-chart"+(f?" "+f:"")},H?he:ue,H?ue:he)}Nt.displayName="ScatterplotMatrix",Lt.displayName="MinimapChart";export{ft as AreaChart,mt as BubbleChart,gt as ConnectedScatterplot,vt as Heatmap,dt as LineChart,Lt as MinimapChart,yt as Scatterplot,Nt as ScatterplotMatrix,pt as StackedAreaChart,Ee as StreamXYFrame};
|