semiotic 3.1.0 → 3.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +104 -0
- package/ai/dist/componentRegistry.js +5 -0
- package/ai/dist/mcp-server.js +378 -46
- package/ai/dist/renderHOCToSVG.js +5 -3
- package/ai/schema.json +1 -1
- package/dist/components/charts/shared/ChartError.d.ts +3 -1
- package/dist/components/charts/shared/withChartWrapper.d.ts +4 -3
- package/dist/geo.min.js +1 -1
- package/dist/geo.module.min.js +1 -1
- package/dist/network.min.js +1 -1
- package/dist/network.module.min.js +1 -1
- package/dist/ordinal.min.js +1 -1
- package/dist/ordinal.module.min.js +1 -1
- package/dist/realtime.min.js +1 -1
- package/dist/realtime.module.min.js +1 -1
- package/dist/semiotic-ai-statisticalOverlays-C1f7TYyD.js +1 -0
- package/dist/semiotic-ai.min.js +1 -1
- package/dist/semiotic-ai.module.min.js +1 -1
- package/dist/semiotic-statisticalOverlays-C1f7TYyD.js +1 -0
- package/dist/semiotic.min.js +1 -1
- package/dist/semiotic.module.min.js +1 -1
- package/dist/xy-statisticalOverlays-C1f7TYyD.js +1 -0
- package/dist/xy.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +50 -4
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,createContext as r,useContext as l,useCallback as s,useSyncExternalStore as a,forwardRef as c,useImperativeHandle as h,useId as u}from"react";import{brushX as d,brushY as g,brush as f}from"d3-brush";import{select as y}from"d3-selection";import{scaleOrdinal as p,scaleLinear as m,scaleSequential as v,scaleLog as b}from"d3-scale";import{schemeCategory10 as x,interpolatePlasma as k,interpolateViridis as w,interpolatePurples as A,interpolateOranges as S,interpolateGreens as E,interpolateReds as O,interpolateBlues as M,schemeSet3 as C,schemeTableau10 as P}from"d3-scale-chromatic";import{quadtree as j}from"d3-quadtree";import{bin as _}from"d3-array";import{packEnclose as L}from"d3-hierarchy";import{area as N,curveCatmullRom as B,curveCardinal as H,curveBasis as W,curveStepBefore as z,curveStepAfter as T,curveStep as F,curveMonotoneY as I,curveMonotoneX as $,curveLinear as D,line as R,curveNatural as G}from"d3-shape";import Y from"regression";class X{constructor(e,t){var n,o;this.lastBoundedData=null,this.chunkTimer=0,this.pushBuffer=[],this.flushScheduled=!1,this.callback=e,this.chunkThreshold=null!==(n=null==t?void 0:t.chunkThreshold)&&void 0!==n?n:5e3,this.chunkSize=null!==(o=null==t?void 0:t.chunkSize)&&void 0!==o?o:5e3}updateChunkOptions(e){null!=e.chunkThreshold&&(this.chunkThreshold=e.chunkThreshold),null!=e.chunkSize&&(this.chunkSize=e.chunkSize)}clearLastData(){this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(e){if(this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.chunkThreshold>=e.length)return void this.callback({inserts:e,bounded:!0});this.callback({inserts:e.slice(0,this.chunkSize),bounded:!0,totalSize:e.length});let t=this.chunkSize;const n=()=>{if(t>=e.length)return;if(e!==this.lastBoundedData)return;const o=Math.min(t+this.chunkSize,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)}flushPushBuffer(){if(this.flushScheduled=!1,0===this.pushBuffer.length)return;const e=this.pushBuffer;this.pushBuffer=[],this.callback({inserts:e,bounded:!1})}scheduleFlush(){this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flushPushBuffer()))}push(e){this.pushBuffer.push(e),this.scheduleFlush()}pushMany(e){if(0!==e.length){for(let t=0;e.length>t;t++)this.pushBuffer.push(e[t]);this.scheduleFlush()}}flush(){this.flushPushBuffer()}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1}}class q{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}}}forEach(e){const t=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)e(this.buffer[(t+n)%this._capacity],n)}toArray(){const e=Array(this._size),t=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)e[n]=this.buffer[(t+n)%this._capacity];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 V{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 Q(e,t,n,o,i){const r=new Map;for(const l of e){const e=t(l),s=n(l);if(null==e||null==s||Number.isNaN(e)||Number.isNaN(s))continue;const a=Math.floor(e/o)*o;let c=r.get(a);if(c||(c={start:a,end:a+o,total:0,categories:new Map},r.set(a,c)),c.total+=s,i){const e=i(l);c.categories.set(e,(c.categories.get(e)||0)+s)}}return r}function K(e,t,n,o,i,r){const l=[];for(const i of e){const e=n(i),r=o(i);null==e||null==r||Number.isNaN(e)||Number.isNaN(r)||l.push({px:t.x(e),py:t.y(r),rawY:r,d:i})}l.sort((e,t)=>e.px-t.px);const s=Array(l.length),a=Array(l.length),c=Array(l.length);for(let e=0;l.length>e;e++){const t=l[e];s[e]=[t.px,t.py],a[e]=t.rawY,c[e]=t.d}return{type:"line",path:s,rawValues:a,style:i,datum:c,group:r}}function U(e,t,n,o,i,r,l,s){const a=[];for(const r of e){const e=n(r),l=o(r);if(null==e||null==l||Number.isNaN(e)||Number.isNaN(l))continue;const c=t.x(e),h=s?s(r):i;a.push({px:c,topY:t.y(l),botY:t.y(h)})}a.sort((e,t)=>e.px-t.px);const c=Array(a.length),h=Array(a.length);for(let e=0;a.length>e;e++){const t=a[e];c[e]=[t.px,t.topY],h[e]=[t.px,t.botY]}return{type:"area",topPath:c,bottomPath:h,style:r,datum:e,group:l}}function Z(e,t,n,o,i,r,l){const s=n(e),a=o(e);if(null==s||null==a||Number.isNaN(s)||Number.isNaN(a))return null;const c={type:"point",x:t.x(s),y:t.y(a),r:i,style:r,datum:e};return void 0!==l&&(c.pointId=l),c}function J(e,t,n,o,i,r,l){return{type:"rect",x:e,y:t,w:n,h:o,style:i,datum:r,group:l}}function ee(e,t,n,o,i,r,l){const s={type:"heatcell",x:e,y:t,w:n,h:o,fill:i,datum:r};return(null==l?void 0:l.showValues)&&(s.showValues=!0,s.value=l.value,l.valueFormat&&(s.valueFormat=l.valueFormat)),s}function te(e,t){if("function"==typeof e)return t=>+e(t);const n=e||t;return e=>+e[n]}function ne(e,t){if("function"==typeof e)return e;const n=e||t;return e=>e[n]}function oe(e,t){return"function"==typeof e?e:e?t=>t[e]+"":void 0}const ie={category10:x,tableau10:P,set3:C,blues:M,reds:O,greens:E,oranges:S,purples:A,viridis:w,plasma:k},re=x,le=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],se=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);function ae(e,t,n){if("function"==typeof t){const o=t(e);return n&&o&&"string"==typeof o&&!function(e){const t=e.toLowerCase();return t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||se.has(t)}(o)?n(o):o}const o=e[t];return n?n(o):re[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+""))%re.length]}function ce(e,t,n="category10"){const o=Array.from(new Set(e.map(e=>null==e?void 0:e[t]).filter(e=>null!=e))),i=o.every(e=>"number"==typeof e||!isNaN(Number(e)));if(Array.isArray(n))return p().domain(o).range(n).unknown("#999");const r=ie[n]||ie.category10;if(i&&"function"==typeof r){let e=-1/0;for(const t of o){const n=Number(t);n>e&&(e=n)}return t=>r(Number(t)/e)}{const e=Array.isArray(r)?r:re;return p().domain(o).range(e).unknown("#999")}}function he(e,t,n=[3,20],o){let i;if(i="function"==typeof t?t(e):e[t],!o)return i;const[r,l]=o,[s,a]=n;return l===r?(s+a)/2:s+(i-r)/(l-r)*(a-s)}function ue(e,t,n){return e+(t-e)*n}class de{constructor(e){this.xExtent=new V,this.yExtent=new V,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.prevPathMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupColorMap=new Map,this._barCategoryCache=null,this._stackExtentCache=null,this._ingestVersion=0,this._bufferArrayCache=null,this._bufferDirty=!0,this.needsFullRebuild=!0,this.lastLayout=null,this.scales=null,this.scene=[],this.version=0,this._quadtree=null,this.config=e,this.buffer=new q(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=te(e.timeAccessor||e.xAccessor,"time"),this.getY=te(e.valueAccessor||e.yAccessor,"value")):(this.getX=te(e.xAccessor,"x"),this.getY=te(e.yAccessor,"y")),this.getGroup=oe(e.groupAccessor),this.getCategory=oe(e.categoryAccessor),this.getSize=e.sizeAccessor?te(e.sizeAccessor,"size"):void 0,this.getColor=oe(e.colorAccessor),this.getBounds=e.boundsAccessor?te(e.boundsAccessor,"bounds"):void 0,this.getY0=e.y0Accessor?te(e.y0Accessor,"y0"):void 0,this.getPointId=oe(e.pointIdAccessor),"candlestick"===e.chartType&&(this.getOpen=te(e.openAccessor,"open"),this.getHigh=te(e.highAccessor,"high"),this.getLow=te(e.lowAccessor,"low"),this.getClose=te(e.closeAccessor,"close")),e.pulse&&(this.timestampBuffer=new q(e.windowSize))}ingest(e){const t="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=t,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,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){if("growing"===this.config.windowMode&&this.buffer.full){const e=this.config.maxCapacity||1e6;e>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,e),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,r,l;const{config:s,buffer:a}=this;if(!this.needsFullRebuild&&this.lastLayout&&this.scene.length>0&&this.scales&&(this.lastLayout.width!==e.width||this.lastLayout.height!==e.height))return void this.remapScene(e);if(this.xExtent.dirty&&this.xExtent.recalculate(a,this.getX),this.yExtent.dirty)if("candlestick"===s.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.getBufferArray(),h=this.xExtent.extent,u=this.yExtent.extent;let d=s.xExtent?[null!==(t=s.xExtent[0])&&void 0!==t?t:h[0],null!==(n=s.xExtent[1])&&void 0!==n?n:h[1]]:h,g=s.yExtent?[null!==(o=s.yExtent[0])&&void 0!==o?o:u[0],null!==(i=s.yExtent[1])&&void 0!==i?i:u[1]]:u;const f=s.yExtent&&null!=s.yExtent[0]&&null!=s.yExtent[1];if("stackedarea"===s.chartType&&!f&&a.size>0)if(s.normalize)g=[0,1+s.extentPadding];else{const e=`${a.size}:${this._ingestVersion}`;if(this._stackExtentCache&&this._stackExtentCache.key===e)g=this._stackExtentCache.yDomain;else{const t=this.groupData(c),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);g=[0,o+(o>0?o*s.extentPadding:1)],this._stackExtentCache={key:e,yDomain:g}}}else if("bar"===s.chartType&&s.binSize&&!f&&a.size>0){const[,e]=function(e,t,n,o,i){const r=Q(e,t,n,o,i);if(0===r.size)return[0,0];let l=0;for(const e of r.values())e.total>l&&(l=e.total);return[0,l]}(a,this.getX,this.getY,s.binSize,this.getCategory);g=[0,e+e*s.extentPadding]}else if("waterfall"===s.chartType&&!f&&a.size>0){const[e,t]=function(e,t){let n=0,o=0,i=0;for(const r of e){const e=t(r);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*s.extentPadding:1;g=[Math.min(0,e-Math.abs(o)),Math.max(0,t+Math.abs(o))]}else if(!f&&g[0]!==1/0){if(this.getBounds)for(const e of c){const t=this.getY(e),n=this.getBounds(e);null!=t&&!Number.isNaN(t)&&n&&(t+n>g[1]&&(g[1]=t+n),g[0]>t-n&&(g[0]=t-n))}const e=g[1]-g[0],t=e>0?e*s.extentPadding:1,n=null===(r=s.yExtent)||void 0===r?void 0:r[0],o=null===(l=s.yExtent)||void 0===l?void 0:l[1];g=[null!=n?g[0]:g[0]-t,null!=o?g[1]:g[1]+t],"log"===s.yScaleType&&0>=g[0]&&u[0]>0&&(g[0]=null!=n?g[0]:u[0]/(1+s.extentPadding))}if(d[0]!==1/0&&d[1]!==-1/0||(d=[0,1]),g[0]!==1/0&&g[1]!==-1/0||(g=[0,1]),"streaming"===s.runtimeMode)if("x"==("up"===(y=s.arrowOfTime)||"down"===y?"y":"x")){const t="right"===s.arrowOfTime?[0,e.width]:[e.width,0];this.scales={x:m().domain(d).range(t),y:m().domain(g).range([e.height,0])}}else{const t="down"===s.arrowOfTime?[0,e.height]:[e.height,0];this.scales={x:m().domain(g).range([0,e.width]),y:m().domain(d).range(t)}}else{const t=(e,t,n)=>{if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return b().domain(e).range(n).clamp(!0)}return m().domain(t).range(n)};this.scales={x:t(s.xScaleType,d,[0,e.width]),y:t(s.yScaleType,g,[e.height,0])}}var y;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(e,c),this.config.decay&&this.applyDecay(this.scene,c),this.config.pulse&&this.applyPulse(this.scene,c),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.rebuildQuadtree(),this.needsFullRebuild=!1,this.lastLayout={width:e.width,height:e.height},this.version++}rebuildQuadtree(){const e=this.config.chartType;if("scatter"!==e&&"bubble"!==e)return void(this._quadtree=null);const t=this.scene.filter(e=>"point"===e.type);this._quadtree=t.length>de.QUADTREE_THRESHOLD?j().x(e=>e.x).y(e=>e.y).addAll(t):null}get quadtree(){return this._quadtree}remapScene(e){const t=e.width/this.lastLayout.width,n=e.height/this.lastLayout.height;for(const e of this.scene)switch(e.type){case"line":for(const o of e.path)o[0]*=t,o[1]*=n;break;case"area":for(const o of e.topPath)o[0]*=t,o[1]*=n;for(const o of e.bottomPath)o[0]*=t,o[1]*=n;break;case"point":e.x*=t,e.y*=n;break;case"rect":case"heatcell":e.x*=t,e.y*=n,e.w*=t,e.h*=n;break;case"candlestick":e.x*=t,e.openY*=n,e.closeY*=n,e.highY*=n,e.lowY*=n}const o=this.scales.x.domain(),i=this.scales.y.domain(),r=this.scales.x.range(),l=this.scales.y.range(),s=(e,t,n)=>{if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return b().domain(e).range(n).clamp(!0)}return m().domain(t).range(n)};this.scales={x:s(this.config.xScaleType,o,[r[0]*t,r[1]*t]),y:s(this.config.yScaleType,i,[l[0]*n,l[1]*n])},this.lastLayout={width:e.width,height:e.height},this.rebuildQuadtree(),this.version++}buildSceneNodes(e,t){const{config:n,scales:o}=this;if(!o||0===t.length)return[];switch(n.chartType){case"line":return this.buildLineScene(t);case"area":return this.buildAreaScene(t);case"stackedarea":return this.buildStackedAreaScene(t);case"scatter":case"bubble":return this.buildPointScene(t);case"heatmap":return this.buildHeatmapScene(t,e);case"bar":return this.buildBarScene(t);case"swarm":return this.buildSwarmScene(t);case"waterfall":return this.buildWaterfallScene(t,e);case"candlestick":return this.buildCandlestickScene(t,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=K(e.data,this.scales,this.getX,this.getY,t,e.key);i&&i.length>0&&(n.colorThresholds=i),this.config.curve&&"linear"!==this.config.curve&&(n.curve=this.config.curve),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=U(e.data,this.scales,this.getX,this.getY,o,t,e.key,this.getY0);this.config.gradientFill&&(i.fillGradient=this.config.gradientFill),this.config.curve&&"linear"!==this.config.curve&&(i.curve=this.config.curve),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,r,l){var s;const a=new Set;for(const t of e)for(const e of t.data){const t=n(e);null==t||Number.isNaN(t)||a.add(t)}const c=Array.from(a).sort((e,t)=>e-t),h=new Map;for(const t of e){const e=new Map;for(const i of t.data){const t=n(i),r=o(i);null==t||null==r||Number.isNaN(t)||Number.isNaN(r)||e.set(t,(e.get(t)||0)+r)}h.set(t.key,e)}let u;if(r){u=new Map;for(const t of c){let n=0;for(const o of e)n+=(null===(s=h.get(o.key))||void 0===s?void 0:s.get(t))||0;u.set(t,n||1)}}const d=[],g=new Map;for(const e of c)g.set(e,0);for(const n of e){const e=h.get(n.key),o=[],s=[];for(const n of c){let i=e.get(n)||0;const l=g.get(n);r&&(i/=u.get(n));const a=t.x(n);s.push([a,t.y(l)]),o.push([a,t.y(l+i)]),g.set(n,l+i)}const a={type:"area",topPath:o,bottomPath:s,style:i(n.key,n.data[0]),datum:n.data,group:n.key};l&&(a.curve=l),d.push(a)}return d}(t,this.scales,this.getX,this.getY,(e,t)=>this.resolveAreaStyle(e,t),this.config.normalize,this.config.curve&&"linear"!==this.config.curve?this.config.curve:void 0)}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){let e=1/0,n=-1/0;for(const o of t)e>o&&(e=o),o>n&&(n=o);i=t=>e===n?(o[0]+o[1])/2:o[0]+(t-e)/(n-e)*(o[1]-o[0])}}const r=this.getColor?this.resolveColorMap(e):null;for(const o of e){let e=this.config.pointStyle?this.config.pointStyle(o):{fill:"#4e79a7",opacity:.8},l=e.r||n;if(i&&this.getSize){const e=this.getSize(o);null==e||Number.isNaN(e)||(l=i(e))}if(r&&this.getColor&&!e.fill){const t=this.getColor(o);t&&r.has(t)&&(e=Object.assign(Object.assign({},e),{fill:r.get(t)}))}const s=this.getPointId?this.getPointId(o)+"":void 0,a=Z(o,this.scales,this.getX,this.getY,l,e,s);a&&t.push(a)}return t}buildHeatmapScene(e,t){const n=[];if(this.config.heatmapAggregation)return this.buildStreamingHeatmapScene(e,t);const o=te(this.config.valueAccessor,"value"),i=ne(this.config.xAccessor,"x"),r=ne(this.config.yAccessor,"y"),l=new Set,s=new Set;for(const t of e)l.add(i(t)),s.add(r(t));const a=Array.from(l),c=Array.from(s),h=a.every(e=>"number"==typeof e&&!isNaN(e)),u=c.every(e=>"number"==typeof e&&!isNaN(e)),d=h?a.sort((e,t)=>e-t):a,g=u?c.sort((e,t)=>e-t):c;if(0===d.length||0===g.length)return n;const f=t.width/d.length,y=t.height/g.length,p=new Map;for(const t of e){const e=`${i(t)}\0${r(t)}`;p.set(e,{val:o(t),datum:t})}let m=1/0,b=-1/0;for(const{val:e}of p.values())m>e&&(m=e),e>b&&(b=e);const x=v({blues:M,reds:O,greens:E,viridis:w}["string"==typeof this.config.colorScheme?this.config.colorScheme:"blues"]||M).domain([m,b]);for(let e=0;d.length>e;e++)for(let t=0;g.length>t;t++){const o=p.get(`${d[e]}\0${g[t]}`);if(!o)continue;const i=x(o.val);n.push(ee(e*f,(g.length-1-t)*y,f,y,i,o.datum,this.config.showValues?{value:o.val,showValues:!0,valueFormat:this.config.heatmapValueFormat}:void 0))}return n}buildStreamingHeatmapScene(e,t){var n,o,i;const r=[],l=null!==(n=this.config.heatmapXBins)&&void 0!==n?n:20,s=null!==(o=this.config.heatmapYBins)&&void 0!==o?o:20,a=null!==(i=this.config.heatmapAggregation)&&void 0!==i?i:"count",c=te(this.config.valueAccessor,"value");if(!this.scales||0===e.length)return r;const[h,u]=this.scales.x.domain(),[d,g]=this.scales.y.domain(),f=(u-h||1)/l,y=(g-d||1)/s,p=new Map;for(const t of e){const e=this.getX(t),n=this.getY(t),o=Math.min(Math.floor((e-h)/f),l-1),i=Math.min(Math.floor((n-d)/y),s-1);if(0>o||0>i)continue;const r=`${o}_${i}`;let a=p.get(r);a||(a={sum:0,count:0,data:[]},p.set(r,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 p){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,k=t.width/l,w=t.height/s;for(const[e,t]of b){const[n,o]=e.split("_"),i=+n,l=+o,a=(t-m)/x,c=`rgb(${Math.round(220-180*a)},${Math.round(220-100*a)},${Math.round(255-50*a)})`,h=p.get(e);r.push(ee(i*k,(s-1-l)*w,k,w,c,{xi:i,yi:l,value:t,count:h.count,sum:h.sum,data:h.data},this.config.showValues?{value:t,showValues:!0,valueFormat:this.config.heatmapValueFormat}:void 0))}return r}buildBarScene(e){var t;if(!this.config.binSize)return[];const n=Q(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),r=Array.from(e).filter(e=>!i.has(e)).sort(),l=t.filter(t=>e.has(t)),s=l.join("\0")+""+r.join("\0");this._barCategoryCache&&this._barCategoryCache.key===s?o=this._barCategoryCache.order:(o=[...l,...r],this._barCategoryCache={key:s,order:o})}const i=[],r=this.scales,[l,s]=r.x.domain();for(const e of n.values()){const n=Math.max(e.start,l),a=Math.min(e.end,s);if(n>=a)continue;const c=r.x(n),h=r.x(a),u=Math.abs(h-c),d=u>2?1:0,g=Math.min(c,h)+d/2,f=Math.max(u-d,1);if(f>0)if(o&&e.categories.size>0){let n=0;for(const l of o){const o=e.categories.get(l)||0;if(0===o)continue;const s=r.y(n),a=r.y(n+o);i.push(J(g,Math.min(s,a),f,Math.abs(s-a),{fill:(null===(t=this.config.barColors)||void 0===t?void 0:t[l])||"#4e79a7"},{binStart:e.start,binEnd:e.end,total:e.total,category:l,categoryValue:o},l)),n+=o}}else{const t=r.y(0),n=r.y(e.total);i.push(J(g,Math.min(t,n),f,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 r=[],l=this.config.swarmStyle||{},s=null!==(t=l.radius)&&void 0!==t?t:3,a=null!==(n=l.fill)&&void 0!==n?n:"#007bff",c=null!==(o=l.opacity)&&void 0!==o?o:.7,h=l.stroke,u=l.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),l=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 g={type:"point",x:o,y:l,r:s,style:{fill:d,opacity:c,stroke:h,strokeWidth:u},datum:t};this.getPointId&&(g.pointId=this.getPointId(t)+""),r.push(g)}return r}buildWaterfallScene(e,t){var n,o,i;const r=[],l=this.scales,s=this.config.waterfallStyle,a=e.filter(e=>{const t=this.getY(e);return null!=t&&!Number.isNaN(t)});if(0===a.length)return r;const c=null!==(n=null==s?void 0:s.positiveColor)&&void 0!==n?n:"#28a745",h=null!==(o=null==s?void 0:s.negativeColor)&&void 0!==o?o:"#dc3545",u=null!==(i=null==s?void 0:s.gap)&&void 0!==i?i:1,d=null==s?void 0:s.stroke,g=null==s?void 0:s.strokeWidth;let f=0;for(let e=0;a.length>e;e++){const n=a[e],o=this.getX(n),i=this.getY(n),y=f+i;let p;p=a.length-1>e?this.getX(a[e+1])-o:e>0?o-this.getX(a[e-1]):0;const m=l.x(o),v=0!==p?l.x(o+p):m+t.width/10,b=Math.min(m,v)+u/2,x=Math.max(m,v)-u/2-b;if(0>=x){f=y;continue}const k=l.y(f),w=l.y(y);r.push(J(b,Math.min(k,w),x,Math.abs(k-w),{fill:0>i?h:c,stroke:d,strokeWidth:g},Object.assign(Object.assign({},n),{baseline:f,cumEnd:y,delta:i,_connectorStroke:null==s?void 0:s.connectorStroke,_connectorWidth:null==s?void 0:s.connectorWidth}))),f=y}return r}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",r=o.downColor||"#dc3545",l=o.wickColor||"#333",s=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:r,wickColor:l,wickWidth:s,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 r=this.getBounds(t),l=this.scales.x(e);if(r&&0!==r)n.push([l,this.scales.y(i+r)]),o.push([l,this.scales.y(i-r)]);else{const e=this.scales.y(i);n.push([l,e]),o.push([l,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 r=this.config.decay;if(!r||1>=t)return 1;const l=null!==(n=r.minOpacity)&&void 0!==n?n:.1,s=t-1-e;switch(r.type){case"linear":return l+(1-s/(t-1))*(1-l);case"exponential":{const e=null!==(o=r.halfLife)&&void 0!==o?o:t/2;return l+Math.pow(.5,s/e)*(1-l)}case"step":return(null!==(i=r.stepThreshold)&&void 0!==i?i:.5*t)>s?1:l;default:return 1}}applyDecay(e,t){var n,o;if(!this.config.decay)return;const i=t.length;if(1>=i)return;const r=new Map;for(let e=0;t.length>e;e++)r.set(t[e],e);for(const t of e){if("line"===t.type){const e=Array.isArray(t.datum)?t.datum:[];if(2>e.length)continue;const n=Array(e.length);let o=!1;for(let t=0;e.length>t;t++){const l=r.get(e[t]);null!=l?(n[t]=this.computeDecayOpacity(l,i),1>n[t]&&(o=!0)):n[t]=1}o&&(t._decayOpacities=n);continue}if("area"===t.type){const e=Array.isArray(t.datum)?t.datum:[],n=t.topPath?t.topPath.length:e.length;if(2>n)continue;if(e.length===n){const o=Array(n);let l=!1;for(let t=0;e.length>t;t++){const n=r.get(e[t]);null!=n?(o[t]=this.computeDecayOpacity(n,i),1>o[t]&&(l=!0)):o[t]=1}l&&(t._decayOpacities=o)}else{let o=1;for(const t of e){const e=r.get(t);if(null!=e){const t=this.computeDecayOpacity(e,i);o>t&&(o=t)}}if(1>o){const e=Array(n);e.fill(o),t._decayOpacities=e}}continue}const e=r.get(t.datum);if(null==e)continue;const l=this.computeDecayOpacity(e,i);if("heatcell"===t.type)t.style={opacity:l};else if("candlestick"===t.type)t._decayOpacity=l;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*l})}}}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,r=t-e;return i>r?1-r/i:0}applyPulse(e,t){var n,o;if(!this.config.pulse||!this.timestampBuffer)return;const i="undefined"!=typeof performance?performance.now():Date.now(),r=null!==(n=this.config.pulse.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",l=null!==(o=this.config.pulse.glowRadius)&&void 0!==o?o:4,s=new Map;for(let e=0;t.length>e;e++)s.set(t[e],e);for(const t of e){if("line"===t.type)continue;if("area"===t.type){const e=Array.isArray(t.datum)?t.datum:[t.datum];let n=0;for(const t of e){const e=s.get(t);if(null==e)continue;const o=this.timestampBuffer.get(e);if(null==o)continue;const r=this.computePulseIntensity(o,i);r>n&&(n=r)}n>0&&(t._pulseIntensity=n,t._pulseColor=r);continue}const e=s.get(t.datum);if(null==e)continue;const n=this.timestampBuffer.get(e);if(null==n)continue;const o=this.computePulseIntensity(n,i);o>0&&(t._pulseIntensity=o,t._pulseColor=r,t._pulseGlowRadius=l)}}get hasActivePulses(){var e;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const t="undefined"!=typeof performance?performance.now():Date.now(),n=null!==(e=this.config.pulse.duration)&&void 0!==e?e:500,o=this.timestampBuffer.peek();return null!=o&&n>t-o}snapshotPositions(){var e,t,n;this.prevPositionMap.clear(),this.prevPathMap.clear();for(let o=0;this.scene.length>o;o++){const i=this.scene[o],r=this.getNodeIdentity(i,o);r&&("point"===i.type?this.prevPositionMap.set(r,{x:i.x,y:i.y,r:i.r,opacity:i.style.opacity}):"rect"===i.type?this.prevPositionMap.set(r,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:i.style.opacity}):"heatcell"===i.type?this.prevPositionMap.set(r,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:null===(e=i.style)||void 0===e?void 0:e.opacity}):"candlestick"===i.type?this.prevPositionMap.set(r,{x:i.x,y:i.openY}):"line"===i.type?this.prevPathMap.set(r,{path:i.path.map(e=>[e[0],e[1]]),opacity:null===(t=i.style)||void 0===t?void 0:t.opacity}):"area"===i.type&&this.prevPathMap.set(r,{topPath:i.topPath.map(e=>[e[0],e[1]]),bottomPath:i.bottomPath.map(e=>[e[0],e[1]]),opacity:null===(n=i.style)||void 0===n?void 0:n.opacity}))}}getNodeIdentity(e,t){var n,o,i,r;switch(e.type){case"point":if(e.pointId)return"p:"+e.pointId;if("streaming"===this.config.runtimeMode&&e.datum){if(this.getCategory)return`p:${this.getCategory(e.datum)}:${this.getY(e.datum)}`;const t=this.getX(e.datum),n=this.getY(e.datum);if(null!=t&&null!=n)return`p:${t}:${n}`}return"p:"+t;case"rect":return`r:${e.group||""}:${null!==(r=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!==r?r:t}`;case"heatcell":return`h:${e.x}_${e.y}`;case"candlestick":return null==e.datum?"c:"+t:"c:"+this.getX(e.datum);case"line":return"l:"+(e.group||"_default");case"area":return"a:"+(e.group||"_default");default:return null}}startTransition(){var e,t,n,o,i,r,l,s,a,c,h,u,d,g,f,y,p,m,v,b,x,k,w,A,S,E;if(!this.config.transition||0===this.prevPositionMap.size&&0===this.prevPathMap.size)return;const O=null!==(e=this.config.transition.duration)&&void 0!==e?e:300;if(this.exitNodes.length>0){const e=new Set(this.exitNodes);this.scene=this.scene.filter(t=>!e.has(t)),this.exitNodes=[]}let M=!1;const C=new Set,P=new Set;for(let e=0;this.scene.length>e;e++){const p=this.scene[e],m=this.getNodeIdentity(p,e);if(!m)continue;if(p._transitionKey=m,"line"===p.type||"area"===p.type){const e=this.prevPathMap.get(m);if(e){if(P.add(m),"line"===p.type&&e.path&&e.path.length===p.path.length){p._targetPath=p.path.map(e=>[e[0],e[1]]),p._prevPath=e.path;for(let t=0;p.path.length>t;t++)p.path[t]=[e.path[t][0],e.path[t][1]];M=!0}else if("area"===p.type&&e.topPath&&e.bottomPath&&e.topPath.length===p.topPath.length&&e.bottomPath.length===p.bottomPath.length){p._targetTopPath=p.topPath.map(e=>[e[0],e[1]]),p._targetBottomPath=p.bottomPath.map(e=>[e[0],e[1]]),p._prevTopPath=e.topPath,p._prevBottomPath=e.bottomPath;for(let t=0;p.topPath.length>t;t++)p.topPath[t]=[e.topPath[t][0],e.topPath[t][1]];for(let t=0;p.bottomPath.length>t;t++)p.bottomPath[t]=[e.bottomPath[t][0],e.bottomPath[t][1]];M=!0}p._targetOpacity=null!==(t=p.style.opacity)&&void 0!==t?t:1}else p._targetOpacity=null!==(n=p.style.opacity)&&void 0!==n?n:1,p.style=Object.assign(Object.assign({},p.style),{opacity:0}),M=!0;continue}const v=this.prevPositionMap.get(m);if("point"===p.type)if(v){C.add(m);const e={x:p.x,y:p.y,r:p.r};p._targetOpacity=null!==(o=p.style.opacity)&&void 0!==o?o:1,v.x===e.x&&v.y===e.y||(p._targetX=e.x,p._targetY=e.y,p._targetR=e.r,p.x=v.x,p.y=v.y,p.r=null!==(i=v.r)&&void 0!==i?i:p.r,M=!0)}else p._targetOpacity=null!==(r=p.style.opacity)&&void 0!==r?r:1,p.style=Object.assign(Object.assign({},p.style),{opacity:0}),M=!0;else if("rect"===p.type)if(v){C.add(m);const e={x:p.x,y:p.y,w:p.w,h:p.h};p._targetOpacity=null!==(l=p.style.opacity)&&void 0!==l?l:1,v.x===e.x&&v.y===e.y&&v.w===e.w&&v.h===e.h||(p._targetX=e.x,p._targetY=e.y,p._targetW=e.w,p._targetH=e.h,p.x=v.x,p.y=v.y,p.w=null!==(s=v.w)&&void 0!==s?s:p.w,p.h=null!==(a=v.h)&&void 0!==a?a:p.h,M=!0)}else p._targetOpacity=null!==(c=p.style.opacity)&&void 0!==c?c:1,p.style=Object.assign(Object.assign({},p.style),{opacity:0}),M=!0;else if("heatcell"===p.type)if(v){C.add(m);const e={x:p.x,y:p.y,w:p.w,h:p.h};p._targetOpacity=null!==(u=null===(h=p.style)||void 0===h?void 0:h.opacity)&&void 0!==u?u:1,v.x===e.x&&v.y===e.y||(p._targetX=e.x,p._targetY=e.y,p._targetW=e.w,p._targetH=e.h,p.x=v.x,p.y=v.y,p.w=null!==(d=v.w)&&void 0!==d?d:p.w,p.h=null!==(g=v.h)&&void 0!==g?g:p.h,M=!0)}else p._targetOpacity=null!==(y=null===(f=p.style)||void 0===f?void 0:f.opacity)&&void 0!==y?y:1,p.style=Object.assign(Object.assign({},p.style||{}),{opacity:0}),M=!0}for(const[e,t]of this.prevPathMap)if(!P.has(e))if(e.startsWith("l:")&&t.path){const n={type:"line",path:t.path.map(e=>[e[0],e[1]]),group:e.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:null!==(p=t.opacity)&&void 0!==p?p:1},_targetOpacity:0,_transitionKey:e,datum:null};this.exitNodes.push(n),M=!0}else if(e.startsWith("a:")&&t.topPath&&t.bottomPath){const n={type:"area",topPath:t.topPath.map(e=>[e[0],e[1]]),bottomPath:t.bottomPath.map(e=>[e[0],e[1]]),group:e.slice(2),style:{fill:"#999",opacity:null!==(m=t.opacity)&&void 0!==m?m:1},_targetOpacity:0,_transitionKey:e,datum:null};this.exitNodes.push(n),M=!0}for(const[e,t]of this.prevPositionMap)if(!C.has(e)){if(e.startsWith("p:")){const n={type:"point",x:t.x,y:t.y,r:null!==(v=t.r)&&void 0!==v?v:3,style:{opacity:null!==(b=t.opacity)&&void 0!==b?b:1},datum:null,_targetOpacity:0,_transitionKey:e};this.exitNodes.push(n)}else if(e.startsWith("r:")){const n={type:"rect",x:t.x,y:t.y,w:null!==(x=t.w)&&void 0!==x?x:0,h:null!==(k=t.h)&&void 0!==k?k:0,style:{opacity:null!==(w=t.opacity)&&void 0!==w?w:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e};this.exitNodes.push(n)}else if(e.startsWith("h:")){const n={type:"heatcell",x:t.x,y:t.y,w:null!==(A=t.w)&&void 0!==A?A:0,h:null!==(S=t.h)&&void 0!==S?S:0,fill:"#999",datum:null,style:{opacity:null!==(E=t.opacity)&&void 0!==E?E:1},_targetOpacity:0,_transitionKey:e};this.exitNodes.push(n)}M=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),M&&(this.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:O})}advanceTransition(e){var t,n,o,i,r,l;if(!this.activeTransition)return!1;const s=function(e,t){return Math.min((e-t.startTime)/t.duration,1)}(e,this.activeTransition),a=function(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}(s,"linear"===(null===(t=this.config.transition)||void 0===t?void 0:t.easing)?"linear":"ease-out-cubic");for(const e of this.scene){const t=e._transitionKey;if("point"===e.type){if(void 0!==e._targetOpacity){const o=t?this.prevPositionMap.get(t):void 0,i=o?null!==(n=o.opacity)&&void 0!==n?n:1:0;e.style.opacity=ue(i,e._targetOpacity,a)}if(void 0===e._targetX)continue;if(!t)continue;const o=this.prevPositionMap.get(t);if(!o)continue;e.x=ue(o.x,e._targetX,a),e.y=ue(o.y,e._targetY,a),void 0!==e._targetR&&void 0!==o.r&&(e.r=ue(o.r,e._targetR,a))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const n=t?this.prevPositionMap.get(t):void 0,i=n?null!==(o=n.opacity)&&void 0!==o?o:1:0;e.style.opacity=ue(i,e._targetOpacity,a)}if(void 0===e._targetX)continue;if(!t)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=ue(n.x,e._targetX,a),e.y=ue(n.y,e._targetY,a),void 0!==n.w&&(e.w=ue(n.w,e._targetW,a)),void 0!==n.h&&(e.h=ue(n.h,e._targetH,a))}else if("heatcell"===e.type){if(void 0!==e._targetOpacity){const n=t?this.prevPositionMap.get(t):void 0,o=n?null!==(i=n.opacity)&&void 0!==i?i:1:0;e.style=Object.assign(Object.assign({},e.style||{}),{opacity:ue(o,e._targetOpacity,a)})}if(void 0===e._targetX)continue;if(!t)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=ue(n.x,e._targetX,a),e.y=ue(n.y,e._targetY,a),void 0!==n.w&&(e.w=ue(n.w,e._targetW,a)),void 0!==n.h&&(e.h=ue(n.h,e._targetH,a))}else if("line"===e.type){if(void 0!==e._targetOpacity){const t=void 0===e._prevPath&&e._targetOpacity>0?0:null!==(r=e.style.opacity)&&void 0!==r?r:1;e.style=Object.assign(Object.assign({},e.style),{opacity:ue(t,e._targetOpacity,a)})}const t=e._prevPath,n=e._targetPath;if(t&&n&&t.length===e.path.length)for(let o=0;e.path.length>o;o++)e.path[o][0]=ue(t[o][0],n[o][0],a),e.path[o][1]=ue(t[o][1],n[o][1],a)}else if("area"===e.type){if(void 0!==e._targetOpacity){const t=void 0===e._prevTopPath&&e._targetOpacity>0?0:null!==(l=e.style.opacity)&&void 0!==l?l:1;e.style=Object.assign(Object.assign({},e.style),{opacity:ue(t,e._targetOpacity,a)})}const t=e._prevTopPath,n=e._prevBottomPath,o=e._targetTopPath,i=e._targetBottomPath;if(t&&o&&t.length===e.topPath.length)for(let n=0;e.topPath.length>n;n++)e.topPath[n][0]=ue(t[n][0],o[n][0],a),e.topPath[n][1]=ue(t[n][1],o[n][1],a);if(n&&i&&n.length===e.bottomPath.length)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t][0]=ue(n[t][0],i[t][0],a),e.bottomPath[t][1]=ue(n[t][1],i[t][1],a)}}if(s>=1){for(const e of this.scene){if(void 0!==e._targetOpacity){const t=e._targetOpacity;e.style=Object.assign(Object.assign({},"line"===e.type||"area"===e.type?e.style:e.style||{}),{opacity:0===t?0:t}),e._targetOpacity=void 0}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}else if("line"===e.type){const t=e._targetPath;if(t)for(let n=0;e.path.length>n;n++)e.path[n]=t[n];e._prevPath=void 0,e._targetPath=void 0}else if("area"===e.type){const t=e._targetTopPath,n=e._targetBottomPath;if(t)for(let n=0;e.topPath.length>n;n++)e.topPath[n]=t[n];if(n)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t]=n[t];e._prevTopPath=void 0,e._prevBottomPath=void 0,e._targetTopPath=void 0,e._targetBottomPath=void 0}}if(this.exitNodes.length>0){const e=new Set(this.exitNodes);this.scene=this.scene.filter(t=>!e.has(t)),this.exitNodes=[]}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}))}resolveColorMap(e){const t=new Set;for(const n of e){const e=this.getColor(n);e&&t.add(e)}const n=Array.from(t).sort(),o=n.join("\0");if(this._colorMapCache&&this._colorMapCache.key===o)return this._colorMapCache.map;const i=Array.isArray(this.config.colorScheme)?this.config.colorScheme:le,r=new Map;for(let e=0;n.length>e;e++)r.set(n[e],i[e%i.length]);return this._colorMapCache={key:o,map:r},r}resolveLineStyle(e,t){const n=this.config.lineStyle;if("function"==typeof n){const o=n(t||{},e);if(o&&!o.stroke&&e){const t=this.resolveGroupColor(e);if(t)return Object.assign(Object.assign({},o),{stroke:t})}return o}return n&&"object"==typeof n?{stroke:n.stroke||"#007bff",strokeWidth:n.strokeWidth||2,strokeDasharray:n.strokeDasharray,fill:n.fill,fillOpacity:n.fillOpacity,opacity:n.opacity}:{stroke:"#007bff",strokeWidth:2}}resolveAreaStyle(e,t){var n;if(this.config.areaStyle){const n=this.config.areaStyle(t||{});if(n&&!n.fill&&e){const t=this.resolveGroupColor(e);if(t)return Object.assign(Object.assign({},n),{fill:t,stroke:n.stroke||t})}return n}const o=this.config.lineStyle;if("function"==typeof o){const n=o(t||{},e);if(n&&!n.fill&&e){const t=this.resolveGroupColor(e);if(t)return Object.assign(Object.assign({},n),{fill:t,stroke:n.stroke||t})}return n}return 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}}resolveGroupColor(e){if(this._colorMapCache){const t=this._colorMapCache.map.get(e);if(t)return t}const t=this._groupColorMap.get(e);if(t)return t;const n=Array.isArray(this.config.colorScheme)?this.config.colorScheme:le,o=n[this._groupColorMap.size%n.length];return this._groupColorMap.set(e,o),o}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.prevPathMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this.needsFullRebuild=!0,this._bufferDirty=!0,this._bufferArrayCache=null,this.lastLayout=null,this.scales=null,this.scene=[],this._quadtree=null,this._colorMapCache=null,this._groupColorMap=new Map,this._barCategoryCache=null,this._stackExtentCache=null,this.version++}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}updateConfig(e){void 0!==e.colorScheme&&(this._colorMapCache=null,this._groupColorMap=new Map),void 0===e.barColors&&void 0===e.colorScheme||(this._barCategoryCache=null),void 0===e.normalize&&void 0===e.extentPadding&&void 0===e.xAccessor&&void 0===e.yAccessor&&void 0===e.groupAccessor&&void 0===e.categoryAccessor&&void 0===e.chartType||(this._stackExtentCache=null),Object.assign(this.config,e),(void 0!==e.xAccessor||void 0!==e.yAccessor||void 0!==e.timeAccessor||void 0!==e.valueAccessor)&&(["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?(this.getX=te(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=te(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=te(this.config.xAccessor,"x"),this.getY=te(this.config.yAccessor,"y"))),void 0!==e.groupAccessor&&(this.getGroup=oe(this.config.groupAccessor)),void 0!==e.categoryAccessor&&(this.getCategory=oe(this.config.categoryAccessor)),void 0!==e.sizeAccessor&&(this.getSize=this.config.sizeAccessor?te(this.config.sizeAccessor,"size"):void 0),void 0!==e.colorAccessor&&(this.getColor=oe(this.config.colorAccessor)),void 0!==e.y0Accessor&&(this.getY0=this.config.y0Accessor?te(this.config.y0Accessor,"y0"):void 0),void 0!==e.pointIdAccessor&&(this.getPointId=oe(this.config.pointIdAccessor)),this.needsFullRebuild=!0}}function ge(e,t,n){return n.x>e||e>n.x+n.w||n.y>t||t>n.y+n.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:n.x+n.w/2,cy:n.y+n.h/2}}function fe(e,t,n){const o=t-e.x,i=n-e.y,r=Math.sqrt(o*o+i*i);return r>e.r+5?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:r}}function ye(e,t,n){var o,i,r,l;if(0===e.path.length)return null;const s=ke(e.path,t);if(0>s)return null;const[a,c]=e.path[s];let h;if(e.path.length>1){let o=1/0;const i=Math.max(0,s-1),r=Math.min(e.path.length-2,s);for(let l=i;r>=l;l++){const[i,r]=e.path[l],[s,a]=e.path[l+1],c=pe(t,n,i,r,s,a);o>c&&(o=c)}h=o}else{const e=t-a,o=n-c;h=Math.sqrt(e*e+o*o)}const u=null!==(l=null!==(i=null===(o=e.style)||void 0===o?void 0:o.strokeWidth)&&void 0!==i?i:null===(r=e.style)||void 0===r?void 0:r.lineWidth)&&void 0!==l?l:1;return h>Math.max(5,u/2+2)?null:{node:e,datum:Array.isArray(e.datum)&&e.datum[s]?e.datum[s]:e.datum,x:a,y:c,distance:h}}function pe(e,t,n,o,i,r){const l=i-n,s=r-o,a=l*l+s*s;if(0===a)return Math.sqrt(Math.pow(e-n,2)+Math.pow(t-o,2));let c=((e-n)*l+(t-o)*s)/a;c=Math.max(0,Math.min(1,c));const h=o+c*s;return Math.sqrt(Math.pow(e-(n+c*l),2)+Math.pow(t-h,2))}function me(e,t,n){const o=ge(t,n,e);return o.hit?{node:e,datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}function ve(e,t,n){const o=ge(t,n,e);return o.hit?{node:e,datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}function be(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,r=t-e.x,l=n-o;return{node:e,datum:e.datum,x:e.x,y:o,distance:Math.sqrt(r*r+l*l)}}return null}function xe(e,t,n){if(0===e.topPath.length)return null;const o=ke(e.topPath,t);if(0>o)return null;const[i,r]=e.topPath[o],l=t-i,s=n-r,a=Math.sqrt(l*l+s*s);return{node:e,datum:Array.isArray(e.datum)&&e.datum[o]?e.datum[o]:e.datum,x:i,y:r,distance:a}}function ke(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}de.QUADTREE_THRESHOLD=500;const we={fill:t=>e.createElement("rect",{style:t,width:16,height:16}),line:t=>e.createElement("line",{style:t,x1:0,y1:0,x2:16,y2:16})};function Ae(e,t,n,o){let i;return i="function"==typeof n?n(e):(0,we[n])(o(e,t)),i}function Se(){return e.createElement("path",{d:"M4,8.8 L7.2,12 L12.8,4.8",fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function Ee(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}function Oe({config:t,orientation:n="vertical",width:o=100}){const{colorFn:i,domain:r,label:l,format:s}=t,a=s||(e=>Math.round(100*e)/100+""),c="grad-legend-"+e.useId();if("horizontal"===n){const t=12,n=Math.min(o,200),s=Math.max(0,(o-n)/2),h=[];for(let t=0;64>=t;t++){const n=t/64;h.push(e.createElement("stop",{key:t,offset:100*n+"%",stopColor:i(r[0]+n*(r[1]-r[0]))}))}return e.createElement("g",{"aria-label":l||"Gradient legend"},e.createElement("defs",null,e.createElement("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"100%",y2:"0%"},h)),l&&e.createElement("text",{x:s+n/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},l),e.createElement("rect",{x:s,y:0,width:n,height:t,fill:`url(#${c})`,rx:2}),e.createElement("text",{x:s,y:t+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},a(r[0])),e.createElement("text",{x:s+n,y:t+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},a(r[1])))}const h=[];for(let t=0;64>=t;t++){const n=t/64;h.push(e.createElement("stop",{key:t,offset:100*n+"%",stopColor:i(r[1]-n*(r[1]-r[0]))}))}return e.createElement("g",{"aria-label":l||"Gradient legend"},l&&e.createElement("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},l),e.createElement("defs",null,e.createElement("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"0%",y2:"100%"},h)),e.createElement("rect",{x:0,y:0,width:14,height:100,fill:`url(#${c})`,rx:2}),e.createElement("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},a(r[1])),e.createElement("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},a(r[0])))}function Me(t){const{legendGroups:n,customClickBehavior:o,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:l,legendInteraction:s,title:a="Legend",width:c=100,height:h=20,orientation:u="vertical"}=t,[d,g]=e.useState(0),[f,y]=e.useState(0),p=e.useCallback((e,t)=>{g(e),y(t)},[]),m="vertical"===u?(({legendGroups:t,width:n,customClickBehavior:o,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:l,focusedGroupIndex:s,focusedItemIndex:a,onFocusedIndexChange:c,legendInteraction:h})=>{let u=24;const d=[];return t.forEach((t,g)=>{u+=5,d.push(e.createElement("line",{key:"legend-top-line legend-symbol-"+g,stroke:"gray",x1:0,y1:u,x2:n,y2:u})),u+=8,t.label&&(u+=16,d.push(e.createElement("text",{key:"legend-text-"+g,y:u,className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},t.label)),u+=8),d.push(e.createElement("g",{key:"legend-group-"+g,className:"legend-item",transform:`translate(0,${u})`},((t,n,o,i,r,l,s,a,c,h)=>{const{type:u="fill",styleFn:d,items:g}=t,f=[];let y=0;const p=!(!n&&!o),m="isolate"===h||void 0===h&&null!=r;return g.forEach((t,h)=>{const v=Ae(t,h,u,d),b=Ee(t,i,r),x=r&&r.size>0&&r.has(t.label);f.push(e.createElement("g",{key:"legend-item-"+h,transform:`translate(0,${y})`,onClick:n?()=>n(t):void 0,onMouseEnter:o?()=>o(t):void 0,onMouseLeave:o?()=>o(null):void 0,tabIndex:p?a===l&&h===s?0:-1:void 0,role:p?"option":void 0,"aria-selected":p&&m?x||!1:void 0,"aria-current":p&&!m&&null!=i&&t.label===i||void 0,"aria-label":t.label,onKeyDown:p?e=>{var o;if("Enter"!==e.key&&" "!==e.key||(e.preventDefault(),n&&n(t)),"ArrowDown"===e.key||"ArrowUp"===e.key){e.preventDefault();const t=(h+("ArrowDown"===e.key?1:-1)+g.length)%g.length;c(a,t);const n=null===(o=e.currentTarget.parentElement)||void 0===o?void 0:o.children[t];n instanceof SVGElement&&n.focus()}}:void 0,onFocus:p?e=>{c(a,h),o&&o(t);const n=e.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:p?e=>{o&&o(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:p?"pointer":"default",opacity:b,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},p&&e.createElement("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*t.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),v,x&&e.createElement(Se,null),e.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},t.label))),y+=22}),f})(t,o,i,r,l,s,a,g,c,h))),u+=22*t.items.length+8}),d})({legendGroups:n||[],width:c,customClickBehavior:o,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:l,focusedGroupIndex:d,focusedItemIndex:f,onFocusedIndexChange:p,legendInteraction:s}):(({legendGroups:t,height:n,width:o,customClickBehavior:i,customHoverBehavior:r,highlightedCategory:l,isolatedCategories:s,focusedGroupIndex:a,focusedItemIndex:c,onFocusedIndexChange:h,legendInteraction:u})=>{let d=0;const g=[];t.forEach((t,n)=>{let o=0;t.label&&(o+=16);const f=((t,n,o,i,r,l,s,a,c,h)=>{const{type:u="fill",styleFn:d,items:g}=t,f=[];let y=0;const p=!(!n&&!o),m="isolate"===h||void 0===h&&null!=r;return g.forEach((t,h)=>{const v=Ae(t,h,u,d),b=Ee(t,i,r),x=r&&r.size>0&&r.has(t.label);f.push(e.createElement("g",{key:"legend-item-"+h,transform:`translate(${y},0)`,onClick:n?()=>n(t):void 0,onMouseEnter:o?()=>o(t):void 0,onMouseLeave:o?()=>o(null):void 0,tabIndex:p?a===l&&h===s?0:-1:void 0,role:p?"option":void 0,"aria-selected":p&&m?x||!1:void 0,"aria-current":p&&!m&&null!=i&&t.label===i||void 0,"aria-label":t.label,onKeyDown:p?e=>{var o;if("Enter"!==e.key&&" "!==e.key||(e.preventDefault(),n&&n(t)),"ArrowRight"===e.key||"ArrowLeft"===e.key){e.preventDefault();const t=(h+("ArrowRight"===e.key?1:-1)+g.length)%g.length;c(a,t);const n=null===(o=e.currentTarget.parentElement)||void 0===o?void 0:o.children[t];n instanceof SVGElement&&n.focus()}}:void 0,onFocus:p?e=>{c(a,h),o&&o(t);const n=e.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:p?e=>{o&&o(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:p?"pointer":"default",opacity:b,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},p&&e.createElement("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*t.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),v,x&&e.createElement(Se,null),e.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},t.label))),y+=26+7*t.label.length}),{items:f,offset:y}})(t,i,r,l,s,a,c,n,h,u);o+=f.offset+5,g.push(Object.assign(Object.assign({label:t.label},f),{offset:o})),d+=o+12});let f=Math.max(0,(o-d)/2);const y=[];return g.forEach((o,i)=>{const r=t[i];r.label&&(y.push(e.createElement("text",{key:"legend-text-"+i,transform:`translate(${f},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},r.label)),f+=16),y.push(e.createElement("g",{key:"legend-group-"+i,className:"legend-item",transform:`translate(${f},0)`},o.items)),f+=o.offset+5,t[i+1]&&y.push(e.createElement("line",{key:"legend-top-line legend-symbol-"+i,stroke:"gray",x1:f,y1:-8,x2:f,y2:n+0+8})),f+=12}),e.createElement("g",null,y)})({legendGroups:n||[],title:a,height:h,width:c,customClickBehavior:o,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:l,focusedGroupIndex:d,focusedItemIndex:f,onFocusedIndexChange:p,legendInteraction:s}),v=!(!o&&!i);return e.createElement("g",{role:v?"listbox":void 0,"aria-multiselectable":!(!v||"isolate"!==s&&(void 0!==s||null==l))||void 0,"aria-label":"Chart legend"},void 0!==a&&""!==a&&"vertical"===u&&e.createElement("text",{className:"legend-title",y:16,x:c/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)"},a),m)}function Ce(e){return"string"==typeof e?{type:e}:e}function Pe({orient:t,config:n,values:o,scale:r,size:l,length:s}){const a=function(e){var t,n,o,i,r;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!==(r=e.strokeWidth)&&void 0!==r?r:1}}(n),c="top"===t||"bottom"===t,h=i(()=>{if(0===o.length)return null;const n=r.domain(),i=l-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)],r=t[Math.floor(.75*n)],l=r-o;return{q1:o,median:i,q3:r,whiskerLow:Math.max(t[0],o-1.5*l),whiskerHigh:Math.min(t[n-1],r+1.5*l)}}(o);if(!n)return null;const{q1:l,median:s,q3:h,whiskerLow:u,whiskerHigh:d}=n,g=Math.min(.5*i,20),f=(i-g)/2+4;if(c){const n=r(l),o=r(h),i=r(s),c=r(u),y=r(d),p="top"===t?-1:1,m=0;return e.createElement("g",{"data-testid":"marginal-boxplot-"+t},e.createElement("line",{x1:c,y1:m+p*(f+g/2),x2:y,y2:m+p*(f+g/2),stroke:a.fill,strokeWidth:a.strokeWidth}),e.createElement("line",{x1:c,y1:m+p*f,x2:c,y2:m+p*(f+g),stroke:a.fill,strokeWidth:a.strokeWidth}),e.createElement("line",{x1:y,y1:m+p*f,x2:y,y2:m+p*(f+g),stroke:a.fill,strokeWidth:a.strokeWidth}),e.createElement("rect",{x:Math.min(n,o),y:"top"===t?m-f-g:m+f,width:Math.abs(o-n),height:g,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-f-g:m+f,x2:i,y2:"top"===t?m-f:m+f+g,stroke:a.fill,strokeWidth:2}))}{const n=r(l),o=r(h),i=r(s),c=r(u),y=r(d),p="left"===t?-1:1,m=0;return e.createElement("g",{"data-testid":"marginal-boxplot-"+t},e.createElement("line",{x1:m+p*(f+g/2),y1:c,x2:m+p*(f+g/2),y2:y,stroke:a.fill,strokeWidth:a.strokeWidth}),e.createElement("line",{x1:m+p*f,y1:c,x2:m+p*(f+g),y2:c,stroke:a.fill,strokeWidth:a.strokeWidth}),e.createElement("line",{x1:m+p*f,y1:y,x2:m+p*(f+g),y2:y,stroke:a.fill,strokeWidth:a.strokeWidth}),e.createElement("rect",{x:"left"===t?m-f-g:m+f,y:Math.min(n,o),width:g,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-f-g:m+f,y1:i,x2:"left"===t?m-f:m+f+g,y2:i,stroke:a.fill,strokeWidth:2}))}}const h=_().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 l=n.length/u*i;if(c){const i=r(n.x0),s=r(n.x1)-r(n.x0);return e.createElement("rect",{key:o,x:i,y:"top"===t?-4-l:4,width:Math.max(s,.5),height:l,fill:a.fill,fillOpacity:a.fillOpacity,stroke:a.stroke,strokeWidth:a.strokeWidth})}{const i=r(n.x0),s=r(n.x1)-r(n.x0);return e.createElement("rect",{key:o,x:"left"===t?-4-l:4,y:Math.min(i,i+s),width:l,height:Math.abs(s),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 l=e.length/u*(i/2),s=r((e.x0+e.x1)/2);o.push(c?`${s},${"top"===t?-(n-l):n-l}`:`${"left"===t?-(n-l):n-l},${s}`)}for(let e=h.length-1;e>=0;e--){const l=h[e];if(null==l.x0||null==l.x1)continue;const s=l.length/u*(i/2),a=r((l.x0+l.x1)/2);o.push(c?`${a},${"top"===t?-(n+s):n+s}`:`${"left"===t?-(n+s):n+s},${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?r(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,l=r((e.x0+e.x1)/2);n.push(`L${l},${"top"===t?-o-4:o+4}`)}const l=null!=h[h.length-1].x1?r(h[h.length-1].x1):s;n.push(`L${l},${e}`),n.push("Z")}else{const e=0,o=null!=h[0].x0?r(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,l=r((e.x0+e.x1)/2);n.push(`L${"left"===t?-o-4:o+4},${l}`)}const l=null!=h[h.length-1].x1?r(h[h.length-1].x1):s;n.push(`L${e},${l}`),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,r,a,l,s,t,c,4]);return h?e.createElement("g",{className:"marginal-"+t,"data-testid":"marginal-"+t},h):null}function je(e,t=120,n=8){if(!e)return[];const o=Math.max(1,Math.floor(t/n)),i=e.split(/\s+/),r=[];let l="";for(const e of i)l&&l.length+1+e.length>o?(r.push(l),l=e):l=l?`${l} ${e}`:e;return l&&r.push(l),r}function _e(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 Le(t){const{x:n=0,y:o=0,dx:i,dy:r,nx:l,ny:s,note:a,connector:c,subject:h,type:u,color:d,className:g,disable:f,events:y={},"data-testid":p}=t,m=new Set(Array.isArray(f)?f:[]);let v=i||0,b=r||0;null!=l&&(v=l-n),null!=s&&(b=s-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 "+(g||"")).trim(),transform:`translate(${n},${o})`,"data-testid":p},y),!m.has("connector")&&function(t,n,o,i,r,l){const s=[];let a=0,c=0;if("callout-circle"!==r&&"label"!==r||!(null==l?void 0:l.radius)){if("callout-rect"===r&&l){const e=l.width||0,o=l.height||0;if(e>0||o>0){const i=e/2,r=o/2,l=t-i,s=n-r;if(0!==l||0!==s){const t=Math.abs(l),n=Math.abs(s),h=e/2,u=o/2,d=t*u>n*h?h/t:u/n;a=i+l*d,c=r+s*d}}}else if("bracket"===r&&l){const e=l.width,t=l.height,n=l.depth||30;void 0!==e?(a=e/2,c=n):void 0!==t&&(a=n,c=t/2)}}else{const e=(l.radius||0)+(l.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&&(s.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,r=16/180*Math.PI,l=Math.atan2(n-c,t-a);s.push(e.createElement("path",{key:"connector-arrow",d:`M${a},${c}L${a+o*Math.cos(l+r)},${c+o*Math.sin(l+r)}L${a+o*Math.cos(l-r)},${c+o*Math.sin(l-r)}Z`,fill:i||"currentColor",stroke:"none"}))}return e.createElement("g",{className:"annotation-connector"},s)}(v,b,c,d,x,h),!m.has("subject")&&function(t,n,o,i,r){var l;const s=[];switch(t){case"callout-circle":{const t=((null==n?void 0:n.radius)||0)+((null==n?void 0:n.radiusPadding)||0);t>0&&s.push(e.createElement("circle",{key:"subject-circle",r:t,fill:"none",stroke:o||"currentColor"}));break}case"callout-rect":{const t=(null==n?void 0:n.width)||0,i=(null==n?void 0:n.height)||0;(t>0||i>0)&&s.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)&&s.push(...Array.isArray(n.custom)?n.custom:[n.custom]);break;case"xy-threshold":{const t=i||0,l=r||0;if(void 0!==(null==n?void 0:n.x)){const i=(n.x||0)-t;s.push(e.createElement("line",{key:"threshold-line",x1:i,y1:(n.y1||0)-l,x2:i,y2:(n.y2||0)-l,stroke:o||"currentColor",strokeDasharray:"5,5"}))}else if(void 0!==(null==n?void 0:n.y)){const i=(n.y||0)-l;s.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)?s.push(e.createElement("line",{key:"threshold-line",x1:(n.x1||0)-t,y1:0,x2:(n.x2||0)-t,y2:0,stroke:o||"currentColor",strokeDasharray:"5,5"})):void 0===(null==n?void 0:n.y1)&&void 0===(null==n?void 0:n.y2)||s.push(e.createElement("line",{key:"threshold-line",x1:0,y1:(n.y1||0)-l,x2:0,y2:(n.y2||0)-l,stroke:o||"currentColor",strokeDasharray:"5,5"}));break}case"bracket":{const t=null!==(l=null==n?void 0:n.width)&&void 0!==l?l:null==n?void 0:n.height;void 0!==t&&s.push(e.createElement("path",{key:"bracket-path",d:_e((null==n?void 0:n.type)||"curly",t,(null==n?void 0:n.depth)||30,void 0===(null==n?void 0:n.width)),fill:"none",stroke:o||"currentColor"}));break}}return e.createElement("g",{className:"annotation-subject"},s)}(x,h,d,n,o),!m.has("note")&&function(t,n,o,i){if(!t)return e.createElement("g",{className:"annotation-note"});const{label:r,title:l,orientation:s,align:a,wrap:c=120,noWrap:h}=t;if(!r&&!l)return e.createElement("g",{className:"annotation-note"});let u=s;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 g="start";"topBottom"===u?"right"===d?g="end":"middle"===d&&(g="middle"):g=0>n?"end":"start";const f=16,y=l?h?[l]:je(l,c):[],p=r?h?[r]:je(r,c):[],m="leftRight"===u?"end"===g?-4:4:0;let v=0;const b=[];y.length>0&&(b.push(e.createElement("text",{key:"annotation-note-title",className:"annotation-note-title",fill:i||void 0,textAnchor:g,fontWeight:"bold"},y.map((t,n)=>e.createElement("tspan",{key:n,x:m,dy:0===n?0:f},t)))),v=y.length*f),p.length>0&&b.push(e.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:i||void 0,textAnchor:g,y:v},p.map((t,n)=>e.createElement("tspan",{key:n,x:m,dy:0===n?0:f},t))));let x=null;if((l||r)&&(0!==n||0!==o))if("topBottom"===u){const t=Math.min(c,120);let n=0,o=t;"end"===g?(n=-t,o=0):"middle"===g&&(n=-t/2,o=t/2),x=e.createElement("line",{className:"note-line",x1:n,x2:o,y1:0,y2:0,stroke:i||"currentColor"})}else{const t=(y.length+p.length)*f+(p.length>0?f: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 k=Math.max(0,y.length+p.length-1)*f;let w=0;return"topBottom"===u?w=0>o?-(k+2):18:"leftRight"===u&&(w="middle"===d?-(k+f+(p.length>0&&y.length>0?2:0))/2+8:"bottom"===d||0>o?-(k+2):18),e.createElement("g",{className:"annotation-note",transform:`translate(${n},${o})`},e.createElement("g",{className:"annotation-note-content",transform:0!==w?`translate(0,${w})`:void 0},b),x)}(a,v,b,d))}function Ne(t){var n,o;const{noteData:i}=t,{screenCoordinates:r}=i,l="string"==typeof i.type?i.type:"label",s=i.eventListeners||i.events||{};if(i.coordinates&&r){const t=i.nx||r[0][0]+(null!==(n=i.dx)&&void 0!==n?n:0),s=i.ny||r[0][1]+(null!==(o=i.dy)&&void 0!==o?o:0),a=r.map((n,o)=>{const r=Object.assign({},i,{note:0===o?i.note:{label:""},x:n[0],y:n[1],nx:t,ny:s});return e.createElement(Le,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+o},r,{type:l}))});return e.createElement("g",null,a)}const a=i.note||{title:"none",label:i.label};return e.createElement(Le,Object.assign({"data-testid":"semiotic-annotation",key:`${a.label}-${a.title}-${i.i}`,events:s},i,{type:l}))}const Be={linear:D,monotoneX:$,monotoneY:I,step:F,stepAfter:T,stepBefore:z,basis:W,cardinal:H,catmullRom:B};function He(e,t){var n,o,i;const r=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 r?null!=e.x?r(e.x):t.xAccessor&&null!=e[t.xAccessor]?r(e[t.xAccessor]):null:null}function We(e,t){var n,o,i;const r=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 r?null!=e.y?r(e.y):t.yAccessor&&null!=e[t.yAccessor]?r(e[t.yAccessor]):null:null}function ze(e,t,n){var o,i,r,l;const s=e.anchor||"fixed";if("latest"===s){if(null!=e.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let i=n.pointNodes.length-1;i>=0;i--){const r=n.pointNodes[i];if(r.pointId===e.pointId){const e={x:r.x,y:r.y};return null===(o=n.stickyPositionCache)||void 0===o||o.set(t,e),e}}const r=function(e){var t,n,o,i,r,l;const s=e.data;if(!s||0===s.length)return null;const a=s[s.length-1],c=null!==(n=null===(t=e.scales)||void 0===t?void 0:t.x)&&void 0!==n?n:null===(o=e.scales)||void 0===o?void 0:o.time,h=null!==(r=null===(i=e.scales)||void 0===i?void 0:i.y)&&void 0!==r?r:null===(l=e.scales)||void 0===l?void 0:l.value;if(!c||!h)return null;const u=a[e.xAccessor||"x"],d=a[e.yAccessor||"y"];return null==u||null==d?null:{x:c(u),y:h(d)}}(n);return r&&(null===(i=n.stickyPositionCache)||void 0===i||i.set(t,r)),r}let a=null,c=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(a=t.x,c=t.y)}if(null!=a&&null!=c||(a=He(e,n),c=We(e,n)),null!=a&&null!=c)return null===(r=n.stickyPositionCache)||void 0===r||r.set(t,{x:a,y:c}),{x:a,y:c};if("sticky"===s){const e=null===(l=n.stickyPositionCache)||void 0===l?void 0:l.get(t);if(e)return e}return null}function Te(e,t,n,o=50){return!(-o>e||e>(n.width||0)+o||-o>t||t>(n.height||0)+o)}function Fe(e,t,n){if("left"===e||"right"===e){const o="left"===e?n:0,i="left"===e?-1:1,r=Math.ceil(t/8);let l="M0,"+o;for(let e=0;r>e;e++){const n=8*(e+1);l+=`L${Math.min(8*e+4,t)},${o+4*i}`,l+=`L${Math.min(n,t)},${o}`}return l}{const o="bottom"===e?0:t,i="bottom"===e?1:-1,r=Math.ceil(n/8);let l=`M${o},0`;for(let e=0;r>e;e++){const t=8*(e+1);l+=`L${o+4*i},${Math.min(8*e+4,n)}`,l+=`L${o},${Math.min(t,n)}`}return l}}function Ie(t){const{width:n,height:o,totalWidth:r,totalHeight:l,margin:s,scales:a,showAxes:c,axes:h,showGrid:u,xFormat:d,yFormat:g}=t,f=i(()=>{var e;if(!a)return[];const t=null==h?void 0:h.find(e=>"bottom"===e.orient),o=(null==t?void 0:t.tickFormat)||d||$e,i=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;return a.x.ticks(Math.min(i,Math.max(2,Math.floor(n/70)))).map(e=>({value:e,pixel:a.x(e),label:o(e)}))},[a,h,d,n]),y=i(()=>{var e;if(!a)return[];const t=null==h?void 0:h.find(e=>"left"===e.orient),n=(null==t?void 0:t.tickFormat)||g||$e,i=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;return a.y.ticks(Math.min(i,Math.max(2,Math.floor(o/30)))).map(e=>({value:e,pixel:a.y(e),label:n(e)}))},[a,h,g,o]),p=u&&a,m=c&&a;if(!p&&!m)return null;const v=null==h?void 0:h.find(e=>"bottom"===e.orient),b=null==h?void 0:h.find(e=>"left"===e.orient),x=m&&(!v||!1!==v.baseline),k=m&&(!b||!1!==b.baseline),w=(null==v?void 0:v.jaggedBase)||!1,A=(null==b?void 0:b.jaggedBase)||!1,S="var(--semiotic-border, #ccc)";return e.createElement("svg",{width:r,height:l,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},e.createElement("g",{transform:`translate(${s.left},${s.top})`},p&&e.createElement("g",{className:"stream-grid"},f.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})),y.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}))),x&&!w&&e.createElement("line",{x1:0,y1:o,x2:n,y2:o,stroke:S,strokeWidth:1}),w&&e.createElement("path",{d:Fe("bottom",n,o),fill:"none",stroke:S,strokeWidth:1}),k&&!A&&e.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:S,strokeWidth:1}),A&&e.createElement("path",{d:Fe("left",n,o),fill:"none",stroke:S,strokeWidth:1})))}function $e(e){return Math.round(100*e)/100+""}function De(e,t){return e instanceof Date&&(!(t&&t instanceof Date)||e.getFullYear()!==t.getFullYear()||e.getMonth()!==t.getMonth()||e.getDate()!==t.getDate())}function Re(n){var o,r;const{width:l,height:s,totalWidth:a,totalHeight:c,margin:h,scales:u,showAxes:d,axes:g,xLabel:f,yLabel:y,xFormat:p,yFormat:m,showGrid:v,title:b,legend:x,legendHoverBehavior:k,legendClickBehavior:w,legendHighlightedCategory:A,legendIsolatedCategories:S,legendPosition:E="right",foregroundGraphics:O,marginalGraphics:M,xValues:C,yValues:P,annotations:j,svgAnnotationRules:_,xAccessor:B,yAccessor:H,annotationData:W,pointNodes:z,curve:T,underlayRendered:F,children:I}=n,$=i(()=>{var e;if(!d||!u)return[];const t=null==g?void 0:g.find(e=>"bottom"===e.orient),n=(null==t?void 0:t.tickFormat)||p||$e,o=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;return u.x.ticks(Math.min(o,Math.max(2,Math.floor(l/70)))).map(e=>({value:e,pixel:u.x(e),label:n(e)}))},[d,u,g,p,l]),R=i(()=>{var e;if(!d||!u)return[];const t=null==g?void 0:g.find(e=>"left"===e.orient),n=(null==t?void 0:t.tickFormat)||m||$e,o=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;return u.y.ticks(Math.min(o,Math.max(2,Math.floor(s/30)))).map(e=>({value:e,pixel:u.y(e),label:n(e)}))},[d,u,g,m,s]),G=t(new Map),X=t(null!==(o=null==j?void 0:j.length)&&void 0!==o?o:0),q=null!==(r=null==j?void 0:j.length)&&void 0!==r?r:0;X.current!==q&&(X.current=q,G.current=new Map);const V=i(()=>{if(!j||0===j.length)return null;const t=function(t,n,o){var i,r,l,s,a,c,h,u,d,g,f,y,p,m,v,b,x,k,w,A,S,E,O,M,C,P,j,_,B,H,W,z,T,F,I,$,R,G,X,q,V,Q,K,U;switch(t.type){case"label":{const i=ze(t,n,o);if(!i)return null;const{x:r,y:l}=i;return Te(r,l,o)?e.createElement(Ne,{key:"ann-"+n,noteData:{x:r,y:l,dx:t.dx||30,dy:t.dy||-30,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"label",connector:t.connector||{end:"arrow"},color:t.color}}):null}case"callout":{const i=ze(t,n,o);if(!i)return null;const{x:r,y:l}=i;return Te(r,l,o)?e.createElement(Ne,{key:"ann-"+n,noteData:{x:r,y:l,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=He(t,o);if(null==i)return null;const r=t.color||"#f97316";return e.createElement("g",{key:"ann-"+n},e.createElement("line",{x1:i,y1:0,x2:i,y2:o.height||0,stroke:r,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&e.createElement("text",{x:i+4,y:12,fill:r,fontSize:12,fontWeight:"bold"},t.label))}case"y-threshold":{const i=We(t,o);if(null==i)return null;const r=t.color||"#f97316";return e.createElement("g",{key:"ann-"+n},e.createElement("line",{x1:0,y1:i,x2:o.width||0,y2:i,stroke:r,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:r,fontSize:12,fontWeight:"bold"},t.label))}case"enclose":{const i=(t.coordinates||[]).map(e=>({x:He(Object.assign(Object.assign({},e),{type:"point"}),o),y:We(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 r=L(i),l=t.padding||10;return e.createElement("g",{key:"ann-"+n},e.createElement("circle",{cx:r.x,cy:r.y,r:r.r+l,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&e.createElement("text",{x:r.x,y:r.y-r.r-l-4,textAnchor:"middle",fill:t.color||"#666",fontSize:12},t.label))}case"rect-enclose":{const i=(t.coordinates||[]).map(e=>({x:He(Object.assign(Object.assign({},e),{type:"point"}),o),y:We(Object.assign(Object.assign({},e),{type:"point"}),o)})).filter(e=>null!=e.x&&null!=e.y);if(2>i.length)return null;const r=t.padding||10,l=i.map(e=>e.x),s=i.map(e=>e.y),a=Math.min(...l)-r,c=Math.max(...l)+r,h=Math.min(...s)-r,u=Math.max(...s)+r;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||[],r="function"==typeof t.filter?i.filter(t.filter):t.field&&null!=t.value?i.filter(e=>e[t.field]===t.value):[],l=t.style||{stroke:t.color||"#f97316",strokeWidth:2,fill:"none"};return e.createElement("g",{key:"ann-"+n},r.map((n,i)=>{const r=He(n,o),s=We(n,o);return null==r||null==s?null:e.createElement("circle",Object.assign({key:"hl-"+i,cx:r,cy:s,r:t.r||6},l))}))}case"bracket":{const i=He(t,o),r=We(t,o);return e.createElement(Ne,{key:"ann-"+n,noteData:{x:null!=i?i:0,y:null!=r?r:0,dx:t.dx||0,dy:t.dy||0,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"bracket",subject:{type:t.bracketType||"curly",width:t.width,height:t.height,depth:t.depth||30},color:t.color}})}case"trend":{const u=o.data||[];if(2>u.length)return null;const d=o.xAccessor||"x",g=o.yAccessor||"y",f=u.map(e=>[e[d],e[g]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>f.length)return null;const y=null!==(r=null===(i=o.scales)||void 0===i?void 0:i.x)&&void 0!==r?r:null===(l=o.scales)||void 0===l?void 0:l.time,p=null!==(a=null===(s=o.scales)||void 0===s?void 0:s.y)&&void 0!==a?a:null===(c=o.scales)||void 0===c?void 0:c.value;if(!y||!p)return null;const m=t.method||"linear";let v;v="loess"===m?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]),r=o.map(e=>e[1]),l=Math.max(2,Math.ceil(t*n)),s=[];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(l-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,g=0,f=0;for(let e=0;n>e;e++){const t=c[e];0!==t&&(h+=t,u+=t*i[e],d+=t*r[e],g+=t*i[e]*i[e],f+=t*i[e]*r[e])}if(0===h){s.push([t,r[e]]);continue}const y=h*g-u*u;if(1e-12>Math.abs(y))s.push([t,d/h]);else{const e=(h*f-u*d)/y;s.push([t,(d-e*u)/h+e*t])}}return s}(f,null!==(h=t.bandwidth)&&void 0!==h?h:.3):("polynomial"===m?Y.polynomial(f,{order:t.order||2}):Y.linear(f)).points;const b=v.map(([e,t])=>`${y(e)},${p(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:p(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===(g=o.scales)||void 0===g?void 0:g.value,r=null!==(f=null==i?void 0:i(t.y0))&&void 0!==f?f:0,l=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(r,l),width:o.width||0,height:Math.abs(l-r),fill:t.fill||"#6366f1",fillOpacity:t.fillOpacity||.1}),t.label&&e.createElement("text",{x:(o.width||0)-4,y:Math.min(r,l)-4,textAnchor:"end",fill:t.color||"#6366f1",fontSize:11},t.label))}case"envelope":{const i=o.data||[];if(2>i.length)return null;const r=o.xAccessor||"x",l=null!==(m=null===(p=o.scales)||void 0===p?void 0:p.x)&&void 0!==m?m:null===(v=o.scales)||void 0===v?void 0:v.time,s=null!==(x=null===(b=o.scales)||void 0===b?void 0:b.y)&&void 0!==x?x:null===(k=o.scales)||void 0===k?void 0:k.value;if(!l||!s)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[r]-t[r]);if(2>u.length)return null;const d=Be[o.curve||"linear"]||D,g=N().x(e=>l(e[r])).y0(e=>s(e[c])).y1(e=>s(e[a])).curve(d)(u);if(!g)return null;const f=t.fill||"#6366f1";return e.createElement("g",{key:"ann-"+n},e.createElement("path",{d:g,fill:f,fillOpacity:null!==(w=t.fillOpacity)&&void 0!==w?w:.15,stroke:"none"}),t.label&&u.length>0&&e.createElement("text",{x:l(u[u.length-1][r])+4,y:s(u[u.length-1][a])-4,fill:f,fontSize:11},t.label))}case"anomaly-band":{const i=o.data||[];if(2>i.length)return null;const r=o.yAccessor||"y",l=null!==(S=null===(A=o.scales)||void 0===A?void 0:A.x)&&void 0!==S?S:null===(E=o.scales)||void 0===E?void 0:E.time,s=null!==(M=null===(O=o.scales)||void 0===O?void 0:O.y)&&void 0!==M?M:null===(C=o.scales)||void 0===C?void 0:C.value;if(!l||!s)return null;const a=i.map(e=>e[r]).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!==(P=t.threshold)&&void 0!==P?P:2,g=c-d*u,f=!1!==t.showBand,y=t.fill||"#6366f1",p=null!==(j=t.fillOpacity)&&void 0!==j?j:.1,m=t.anomalyColor||"#ef4444",v=null!==(_=t.anomalyRadius)&&void 0!==_?_:6,b=s(c+d*u),x=s(g),k=i.filter(e=>{const t=e[r];return null!=t&&Math.abs(t-c)>d*u});return e.createElement("g",{key:"ann-"+n},f&&e.createElement("rect",{x:0,y:Math.min(b,x),width:o.width||0,height:Math.abs(x-b),fill:y,fillOpacity:p}),k.map((t,n)=>{const i=He(t,o),r=We(t,o);return null==i||null==r?null:e.createElement("circle",{key:"anomaly-"+n,cx:i,cy:r,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 r=o.xAccessor||"x",l=o.yAccessor||"y",s=null!==(H=null===(B=o.scales)||void 0===B?void 0:B.x)&&void 0!==H?H:null===(W=o.scales)||void 0===W?void 0:W.time,a=null!==(T=null===(z=o.scales)||void 0===z?void 0:z.y)&&void 0!==T?T:null===(F=o.scales)||void 0===F?void 0:F.value;if(!s||!a)return null;const c=i.map(e=>[e[r],e[l]]).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")){const e=Y.polynomial(c,{order:t.order||2}).equation;h=t=>e.reduce((e,n,o)=>e+n*Math.pow(t,o),0)}else{const e=c.length;let t=0,n=0,o=0,i=0;for(const[e,r]of c)t+=e,n+=r,o+=e*e,i+=e*r;const r=e*o-t*t;if(1e-12>Math.abs(r))return null;const l=(e*i-t*n)/r,s=(n-l*t)/e;h=e=>s+l*e}const u=c.length,d=c.map(([e,t])=>t-h(e)).reduce((e,t)=>e+t*t,0),g=Math.sqrt(d/Math.max(u-2,1)),f=c.reduce((e,t)=>e+t[0],0)/u,y=c.reduce((e,t)=>e+Math.pow(t[0]-f,2),0),p=null!==(I=t.confidence)&&void 0!==I?I:.95,m=.99>p?.95>p?.9>p?1:1.645:1.96:2.576,v=null!==($=t.steps)&&void 0!==$?$:5,b=c[u-1][0],x=(b-c[0][0])/Math.max(u-1,1),k=[];for(let e=1;v>=e;e++)k.push(b+e*x);const w=[];for(const e of k){const t=h(e),n=g*Math.sqrt(1+1/u+(y>0?Math.pow(e-f,2)/y:0))*m;w.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const A=`M${w.map(e=>`${s(e.x)},${a(e.yUpper)}`).join(" L")} L${w.slice().reverse().map(e=>`${s(e.x)},${a(e.yLower)}`).join(" L")} Z`,S=w.map(e=>`${s(e.x)},${a(e.yCenter)}`).join(" "),E=`${s(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!==(R=t.fillOpacity)&&void 0!==R?R:.15,stroke:"none"}),e.createElement("polyline",{points:`${E} ${S}`,fill:"none",stroke:O,strokeWidth:null!==(G=t.strokeWidth)&&void 0!==G?G:2,strokeDasharray:null!==(X=t.strokeDasharray)&&void 0!==X?X:"6,3"}),t.label&&w.length>0&&e.createElement("text",{x:s(w[w.length-1].x)+4,y:a(w[w.length-1].yCenter)-4,fill:O,fontSize:11},t.label))}case"widget":{let i=null,r=null;if(null!=t.px&&null!=t.py)i=t.px,r=t.py;else{const e=ze(t,n,o);if(!e)return null;i=e.x,r=e.y}if(null==i||null==r)return null;if(!Te(i,r,o))return null;const l=null!==(q=t.dx)&&void 0!==q?q:0,s=null!==(V=t.dy)&&void 0!==V?V:0,a=null!==(Q=t.width)&&void 0!==Q?Q:32,c=null!==(K=t.height)&&void 0!==K?K:32,h=null!==(U=t.content)&&void 0!==U?U:e.createElement("span",{style:{fontSize:18,cursor:"default"},title:t.label||"Info"},"ℹ️");return e.createElement("foreignObject",{key:"ann-"+n,x:i+l-a/2,y:r+s-c/2,width:a,height:c,style:{overflow:"visible",pointerEvents:"auto"}},e.createElement("div",{style:{width:a,height:c,display:"flex",alignItems:"center",justifyContent:"center"}},h))}case"text":{const i=ze(t,n,o);if(!i)return null;const{x:r,y:l}=i;return e.createElement("text",{key:"ann-text-"+n,x:r+(t.dx||0),y:l+(t.dy||0),fill:t.color||"var(--semiotic-text, #333)",fontSize:t.fontSize||11,dominantBaseline:"middle",style:{fontFamily:"inherit"}},t.label)}default:return null}},n={scales:u?{x:u.x,y:u.y,time:u.x,value:u.y}:null,timeAxis:"x",xAccessor:B,yAccessor:H,width:l,height:s,data:W,frameType:"xy",pointNodes:z,curve:T,stickyPositionCache:G.current};return j.map((e,o)=>{if(_){const i=_(e,o,n);return null!=i?i:t(e,o,n)}return t(e,o,n)}).filter(Boolean)},[j,_,l,s,B,H,W,u,z,T]);return d||b||x||O||M||V&&V.length>0||v||I?e.createElement("svg",{role:"img",width:a,height:c,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},e.createElement("title",null,"string"==typeof b?b:"XY Chart"),e.createElement("desc",null,"string"==typeof b?b+" — XY data visualization":"XY data visualization"),e.createElement("g",{transform:`translate(${h.left},${h.top})`},v&&u&&!F&&e.createElement("g",{className:"stream-grid"},$.map((t,n)=>e.createElement("line",{key:"xgrid-"+n,x1:t.pixel,y1:0,x2:t.pixel,y2:s,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1})),R.map((t,n)=>e.createElement("line",{key:"ygrid-"+n,x1:0,y1:t.pixel,x2:l,y2:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),d&&u&&(()=>{const t=null==g?void 0:g.find(e=>"left"===e.orient),n=null==g?void 0:g.find(e=>"bottom"===e.orient),o=!t||!1!==t.baseline,i=(null==t?void 0:t.jaggedBase)||!1,r=(null==n?void 0:n.jaggedBase)||!1,a=null==n?void 0:n.landmarkTicks,c=null==t?void 0:t.landmarkTicks,u="var(--semiotic-border, #ccc)",d="var(--semiotic-text-secondary, #666)",p="var(--semiotic-text, #333)";return e.createElement("g",{className:"stream-axes"},!F&&(!n||!1!==n.baseline)&&!r&&e.createElement("line",{x1:0,y1:s,x2:l,y2:s,stroke:u,strokeWidth:1}),!F&&r&&e.createElement("path",{d:Fe("bottom",l,s),fill:"none",stroke:u,strokeWidth:1}),$.map((t,n)=>{const o=!!a&&("function"==typeof a?a(t.value,n):De(t.value,n>0?$[n-1].value:void 0));return e.createElement("g",{key:"xtick-"+n,transform:`translate(${t.pixel},${s})`},e.createElement("line",{y2:5,stroke:u,strokeWidth:1}),e.createElement("text",{y:18,textAnchor:"middle",fontSize:o?11:10,fontWeight:o?600:400,fill:d,style:{userSelect:"none"}},t.label))}),f&&e.createElement("text",{x:l/2,y:s+40,textAnchor:"middle",fontSize:12,fill:p,style:{userSelect:"none"}},f),!F&&o&&!i&&e.createElement("line",{x1:0,y1:0,x2:0,y2:s,stroke:u,strokeWidth:1}),!F&&i&&e.createElement("path",{d:Fe("left",l,s),fill:"none",stroke:u,strokeWidth:1}),R.map((t,n)=>{const o=!!c&&("function"==typeof c?c(t.value,n):De(t.value,n>0?R[n-1].value:void 0));return e.createElement("g",{key:"ytick-"+n,transform:`translate(0,${t.pixel})`},e.createElement("line",{x2:-5,stroke:u,strokeWidth:1}),e.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:o?11:10,fontWeight:o?600:400,fill:d,style:{userSelect:"none"}},t.label))}),y&&e.createElement("text",{x:15-h.left,y:s/2,textAnchor:"middle",fontSize:12,fill:p,transform:`rotate(-90, ${15-h.left}, ${s/2})`,style:{userSelect:"none"}},y))})(),V,M&&u&&C&&P&&e.createElement(e.Fragment,null,M.top&&e.createElement("g",{transform:"translate(0, 0)"},e.createElement(Pe,{orient:"top",config:Ce(M.top),values:C,scale:u.x,size:h.top,length:l})),M.bottom&&e.createElement("g",{transform:`translate(0, ${s})`},e.createElement(Pe,{orient:"bottom",config:Ce(M.bottom),values:C,scale:u.x,size:h.bottom,length:l})),M.left&&e.createElement("g",{transform:"translate(0, 0)"},e.createElement(Pe,{orient:"left",config:Ce(M.left),values:P,scale:u.y,size:h.left,length:s})),M.right&&e.createElement("g",{transform:`translate(${l}, 0)`},e.createElement(Pe,{orient:"right",config:Ce(M.right),values:P,scale:u.y,size:h.right,length:s}))),O,I),b&&e.createElement("text",{x:a/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof b?b:null),function(t){const{legend:n,totalWidth:o,totalHeight:i,margin:r,legendPosition:l="right",title:s,legendHoverBehavior:a,legendClickBehavior:c,legendHighlightedCategory:h,legendIsolatedCategories:u,legendInteraction:d}=t;if(!n)return null;const g="top"===l||"bottom"===l;let f,y;return"left"===l?(f=4,y=r.top):"top"===l?(f=0,y=s?32:8):"bottom"===l?(f=0,y=i-r.bottom+50):(f=o-r.right+10,y=r.top),e.createElement("g",{transform:`translate(${f}, ${y})`},"object"==typeof(p=n)&&null!==p&&"gradient"in p?e.createElement(Oe,{config:n.gradient,orientation:g?"horizontal":"vertical",width:g?o:100}):function(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}(n)?e.createElement(Me,{legendGroups:n.legendGroups,title:"",width:g?o:100,orientation:g?"horizontal":"vertical",customHoverBehavior:a,customClickBehavior:c,highlightedCategory:h,isolatedCategories:u,legendInteraction:d}):n);var p}({legend:x,totalWidth:a,totalHeight:c,margin:h,legendPosition:E,title:b,legendHoverBehavior:k,legendClickBehavior:w,legendHighlightedCategory:A,legendIsolatedCategories:S})):null}const Ge="undefined"==typeof window||"undefined"==typeof document,Ye={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function Xe(e,t){if(!e||0===e.length)return t+", empty";const n={};for(const t of e)n[t.type]=(n[t.type]||0)+1;const o=[],i={point:"points",line:"lines",area:"areas",rect:"bars",heatcell:"cells",circle:"nodes",candlestick:"candlesticks"},r=["point","line","area","rect","heatcell","circle","candlestick"],l=Object.keys(n).sort((e,t)=>{const n=r.indexOf(e),o=r.indexOf(t);return(-1===n?999:n)-(-1===o?999:o)});for(const e of l)o.push(`${n[e]} ${i[e]||e}`);return`${t}, ${o.join(", ")}`}function qe({scene:t,chartType:n}){var o,i,r,l;const s=[];for(const e of t){if(s.length>=50)break;"point"===e.type?s.push({label:"Point",values:{x:Math.round(100*e.x)/100+"",y:Math.round(100*e.y)/100+""}}):"rect"===e.type?s.push({label:"Bar",values:{category:(null===(o=e.datum)||void 0===o?void 0:o.category)||"",value:Math.round(100*(null!==(r=null===(i=e.datum)||void 0===i?void 0:i.value)&&void 0!==r?r:0))/100+""}}):"heatcell"===e.type&&s.push({label:"Cell",values:{x:Math.round(100*e.x)/100+"",y:Math.round(100*e.y)/100+"",value:Math.round(100*(null!==(l=e.value)&&void 0!==l?l:0))/100+""}})}if(0===s.length)return null;const a=new Set;for(const e of s)for(const t of Object.keys(e.values))a.add(t);const c=Array.from(a);return e.createElement("table",{style:Ye,role:"table","aria-label":"Data table for "+n},e.createElement("thead",null,e.createElement("tr",null,c.map(t=>e.createElement("th",{key:t},t)))),e.createElement("tbody",null,s.map((t,n)=>e.createElement("tr",{key:n},c.map(n=>{var o;return e.createElement("td",{key:n},null!==(o=t.values[n])&&void 0!==o?o:"")}))),t.length>50&&e.createElement("tr",null,e.createElement("td",{colSpan:c.length},"...and ",t.length-50," more items"))))}function Ve({hoverPoint:t}){let n="";if(t){const e=t.data||t;n="object"==typeof e?"Focused on data point: "+Object.entries(e).filter(([,e])=>"object"!=typeof e&&"function"!=typeof e).map(([e,t])=>`${e}: ${t}`).join(", "):"Focused on data point: "+e}return e.createElement("div",{"aria-live":"polite","aria-atomic":"true",style:Ye},n)}function Qe(n){const o=r(null),c=Ke(n);return[function({children:t}){const r=i(()=>Ke(n),[]);return e.createElement(o.Provider,{value:r,children:t})},e=>{var n;const i=null!==(n=l(o))&&void 0!==n?n:c,r=t(e);r.current=e;const h=s(()=>r.current(i.getState()),[i]),u=s(()=>r.current(i.getState()),[i]);return a(i.subscribe,h,u)}]}function Ke(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)}}}const Ue={mode:"light",colors:{primary:"#00a2ce",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",background:"transparent",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},Ze={mode:"dark",colors:{primary:"#4fc3f7",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",background:"#1a1a2e",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},[Je,et]=Qe(e=>({theme:Ue,setTheme(t){e(e=>"light"===t?{theme:Ue}:"dark"===t?{theme:Ze}:{theme:Object.assign(Object.assign(Object.assign({},e.theme),t),{colors:Object.assign(Object.assign({},e.theme.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.theme.typography),t.typography||{})})})}}));function tt(e,t,n,o){const i=e.getContext("2d");if(!i)return null;const r=t[0]*o,l=t[1]*o,s=t[0]+"px",a=t[1]+"px";return e.style.width!==s&&(e.style.width=s),e.style.height!==a&&(e.style.height=a),e.width===r&&e.height===l||(e.width=r,e.height=l),i.setTransform(o,0,0,o,0,0),i.translate(n.left,n.top),i}function nt(e){switch(e){case"monotoneX":return $;case"monotoneY":return I;case"cardinal":return H;case"catmullRom":return B;case"step":return F;case"stepBefore":return z;case"stepAfter":return T;case"basis":return W;case"natural":return G;default:return null}}function ot(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 it(e,t,n,o,i,r){if(2>t.length)return;const l=[0];for(let e=1;t.length>e;e++){const n=t[e][0]-t[e-1][0],o=t[e][1]-t[e-1][1];l.push(l[e-1]+Math.sqrt(n*n+o*o))}const s=l[l.length-1];if(0===s)return;const a=Math.min(.2*s,40);e.strokeStyle=n,e.lineWidth=o,e.lineCap=r;for(let n=0;t.length-1>n;n++){const o=(l[n]+l[n+1])/2;let r=i;a>o&&(r*=o/a),a>s-o&&(r*=(s-o)/a),e.globalAlpha=Math.max(0,r),e.beginPath(),e.moveTo(t[n][0],t[n][1]),e.lineTo(t[n+1][0],t[n+1][1]),e.stroke()}}function rt(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function lt(e,t,n=.3){rt(t)&&(e.globalAlpha=t._pulseIntensity*n,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h))}function st(e,t,n=.6){var o,i,r,l,s;if(!rt(t))return;const a=null!==(o=t._pulseGlowRadius)&&void 0!==o?o:4,c=t.r+a*t._pulseIntensity,h=null!==(r=null!==(i=t.cx)&&void 0!==i?i:t.x)&&void 0!==r?r:0,u=null!==(s=null!==(l=t.cy)&&void 0!==l?l:t.y)&&void 0!==s?s:0;e.beginPath(),e.arc(h,u,c,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=t._pulseIntensity*n,e.stroke()}function at(e,t,n,o=.35){rt(t)&&(e.globalAlpha=t._pulseIntensity*o,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fill())}function ct(e){switch(e){case"monotoneX":return $;case"monotoneY":return I;case"cardinal":return H;case"catmullRom":return B;case"step":return F;case"stepBefore":return z;case"stepAfter":return T;case"basis":return W;case"natural":return G;default:return null}}function ht(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]}function ut(e,t){const n=ct(t.curve);if(!n||2>t.topPath.length||2>t.bottomPath.length){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]);for(let n=t.bottomPath.length-1;n>=0;n--)e.lineTo(t.bottomPath[n][0],t.bottomPath[n][1]);e.closePath()}else{const o=N().x(e=>e[0]).y0((e,n)=>t.bottomPath[n][1]).y1(e=>e[1]).curve(n).context(e);e.beginPath(),o(t.topPath)}}const dt=(e,t,n,o)=>{var i,r,l;const s=t.filter(e=>"area"===e.type);for(const t of s){if(2>t.topPath.length)continue;const n=t.style.fill||"#4e79a7",o=t._decayOpacities;if(o&&o.length===t.topPath.length){const r=null!==(i=t.style.fillOpacity)&&void 0!==i?i:.7;e.fillStyle=n;for(let n=0;t.topPath.length-1>n;n++)e.globalAlpha=.5*(o[n]+o[n+1])*r,e.beginPath(),e.moveTo(t.topPath[n][0],t.topPath[n][1]),e.lineTo(t.topPath[n+1][0],t.topPath[n+1][1]),e.lineTo(t.bottomPath[n+1][0],t.bottomPath[n+1][1]),e.lineTo(t.bottomPath[n][0],t.bottomPath[n][1]),e.closePath(),e.fill();if(t.style.stroke&&"none"!==t.style.stroke){e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);for(let n=0;t.topPath.length-1>n;n++)e.globalAlpha=.5*(o[n]+o[n+1]),e.beginPath(),e.moveTo(t.topPath[n][0],t.topPath[n][1]),e.lineTo(t.topPath[n+1][0],t.topPath[n+1][1]),e.stroke()}e.globalAlpha=1;continue}const s=null!==(r=t.style.opacity)&&void 0!==r?r:1;if(ut(e,t),t.fillGradient){let o=1/0;for(const e of t.topPath)o>e[1]&&(o=e[1]);let i=-1/0;for(const e of t.bottomPath)e[1]>i&&(i=e[1]);const r=ht(n),l=t.fillGradient.topOpacity,a=t.fillGradient.bottomOpacity,c=e.createLinearGradient(0,o,0,i);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=s}else{const o=null!==(l=t.style.fillOpacity)&&void 0!==l?l:.7;e.globalAlpha=o*s,e.fillStyle=n}if(e.fill(),t._pulseIntensity&&t._pulseIntensity>0&&(ut(e,t),at(e,t)),t.style.stroke&&"none"!==t.style.stroke){e.globalAlpha=s,e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);const n=ct(t.curve);if(e.beginPath(),n)R().x(e=>e[0]).y(e=>e[1]).curve(n).context(e)(t.topPath);else{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}},gt=(e,t,n,o)=>{var i;const r=t.filter(e=>"point"===e.type);e.save();try{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;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()),st(e,t),e.globalAlpha=1}}finally{e.restore()}},ft=(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?yt(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))),lt(e,t),e.globalAlpha=1};function yt(e,t){const n=t.style.icon,o=t.style.iconPadding||2,i=Math.min(t.w,t.h)-o;if(0>=i)return;const r=t.h>t.w;if(e.save(),e.beginPath(),e.rect(t.x,t.y,t.w,t.h),e.clip(),r){const r=i+o,l=t.x+(t.w-i)/2;for(let o=t.y+t.h-i;o>=t.y-i;o-=r)e.drawImage(n,l,o,i,i)}else{const r=i+o,l=t.y+(t.h-i)/2;for(let o=t.x;t.x+t.w>o;o+=r)e.drawImage(n,o,l,i,i)}e.restore()}function pt(e){const[t,n,o]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*n+.114*o>128?"#000":"#fff"}function mt(e){return Number.isInteger(e)?e+"":100>Math.abs(e)?1>Math.abs(e)?e.toPrecision(3):e.toFixed(1):e.toFixed(0)}const vt={line:[dt,(e,t,n,o)=>{var i,r;const l=t.filter(e=>"line"===e.type);for(const s of l){if(2>s.path.length)continue;const a=s.style.stroke||"#007bff",c=s.style.strokeWidth||2,h=s.colorThresholds,u=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=c,e.lineCap=s.style.strokeLinecap||"butt",s.style._edgeFade){const y=null!==(i=s.style.opacity)&&void 0!==i?i:1;it(e,s.path,a,c,y,s.style.strokeLinecap||"butt"),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt";continue}const d=nt(s.curve),g=h&&h.length>0&&u&&u.length===s.path.length,f=s._decayOpacities;if(f&&f.length===s.path.length&&!g){e.strokeStyle=a;const p=null!==(r=s.style.opacity)&&void 0!==r?r:1;for(let m=0;s.path.length-1>m;m++)e.globalAlpha=.5*(f[m]+f[m+1])*p,e.beginPath(),e.moveTo(s.path[m][0],s.path[m][1]),e.lineTo(s.path[m+1][0],s.path[m+1][1]),e.stroke()}else if(g){let v=null,b=null,x=null,k=null,w=!1;function A(t,n,o){e.beginPath(),e.strokeStyle=t,e.moveTo(n,o),w=!0}function S(){w&&(e.stroke(),w=!1)}for(let E=0;s.path.length>E;E++){const[O,M]=s.path[E],C=u[E],P=ot(C,h,a);if(null!==v&&null!==k&&null!==x){if(P===k)e.lineTo(O,M);else{const j=[];for(const _ of h){const L=_.value;(x>L||L>C)&&(L>x||C>L)||x===L||C===L||j.push({t:(L-x)/(C-x)})}j.sort((e,t)=>e.t-t.t);for(const N of j){const B=v+(O-v)*N.t,H=b+(M-b)*N.t,W=ot(x+(C-x)*Math.min(N.t+1e-4,1),h,a);e.lineTo(B,H),S(),A(W,B,H)}e.lineTo(O,M)}v=O,b=M,x=C,k=P}else A(P,O,M),v=O,b=M,x=C,k=P}S()}else{if(e.beginPath(),e.strokeStyle=a,d)R().x(e=>e[0]).y(e=>e[1]).curve(d).context(e)(s.path);else{const[z,T]=s.path[0];e.moveTo(z,T);for(let F=1;s.path.length>F;F++)e.lineTo(s.path[F][0],s.path[F][1])}e.stroke()}if(s.style.fill&&s.style.fillOpacity&&s.style.fillOpacity>0){if(e.beginPath(),e.globalAlpha=s.style.fillOpacity,e.fillStyle=s.style.fill,d&&!g)R().x(e=>e[0]).y(e=>e[1]).curve(d).context(e)(s.path);else{const[$,D]=s.path[0];e.moveTo($,D);for(let G=1;s.path.length>G;G++)e.lineTo(s.path[G][0],s.path[G][1])}const I=s.path[0][0];e.lineTo(s.path[s.path.length-1][0],o.height),e.lineTo(I,o.height),e.closePath(),e.fill()}e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt"}}],area:[dt],stackedarea:[dt],scatter:[gt],bubble:[gt],heatmap:[(e,t,n,o)=>{const i=t.filter(e=>"heatcell"===e.type);e.save();try{for(const t of i){const n=t.style;if(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),lt(e,t),e.globalAlpha=1,t.showValues&&null!=t.value){if(20>t.w||20>t.h)continue;const n=t.valueFormat?t.valueFormat(t.value):mt(t.value),o=Math.max(10,Math.min(16,.3*Math.min(t.w,t.h))),i=t.x+t.w/2,r=t.y+t.h/2;e.fillStyle=pt(t.fill),e.font=o+"px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(n,i,r)}}}finally{e.restore()}}],bar:[ft],swarm:[gt],waterfall:[(e,t,n,o)=>{var i,r,l;ft(e,t);const s=t.filter(e=>"rect"===e.type);if(2>s.length)return;const a=s[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;s.length-1>t;t++){const o=s[t],i=s[t+1];if(!(null===(r=o.datum)||void 0===r?void 0:r.cumEnd)||!(null===(l=i.datum)||void 0===l?void 0:l.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.save();const o=t._decayOpacity;null!=o&&1!==o&&(e.globalAlpha=o),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 i=Math.min(t.openY,t.closeY),r=Math.abs(t.openY-t.closeY),l=t.isUp?t.upColor:t.downColor;e.fillStyle=l,e.fillRect(t.x-t.bodyWidth/2,i,t.bodyWidth,Math.max(r,1)),e.strokeStyle=l,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,i,t.bodyWidth,Math.max(r,1)),e.restore()}}]},bt={top:20,right:20,bottom:30,left:40},xt={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"},kt={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 wt({hover:t}){const n=e=>Number.isInteger(e)?e+"":e.toFixed(2);return e.createElement("div",{className:"semiotic-tooltip",style:kt},e.createElement("div",{style:{fontWeight:600,marginBottom:2}},n(t.value)),e.createElement("div",{style:{opacity:.7,fontSize:11}},n(t.time)))}function At({width:n,height:i,totalWidth:r,totalHeight:l,margin:s,dimension:a,scales:c,onBrush:h}){const u=t(null),p=t(null),m=t(h);m.current=h;const v=t(c);return v.current=c,o(()=>{if(!u.current)return;const e=y(u.current).select(".brush-g"),t="x"===a?d():"y"===a?g():f();return t.extent([[0,0],[n,i]]),t.on("brush end",e=>{const t=v.current;if(!t)return;if(!e.selection)return void m.current(null);let o,r;if("x"===a){const[n,l]=e.selection;o=[t.x.invert(n),t.x.invert(l)],r=[t.y.invert(i),t.y.invert(0)]}else if("y"===a){const[i,l]=e.selection;o=[t.x.invert(0),t.x.invert(n)],r=[t.y.invert(l),t.y.invert(i)]}else{const[[n,i],[l,s]]=e.selection;o=[t.x.invert(n),t.x.invert(l)],r=[t.y.invert(s),t.y.invert(i)]}m.current({x:o,y:r})}),e.call(t),p.current=t,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{t.on("brush end",null),p.current=null}},[n,i,a]),e.createElement("svg",{ref:u,width:r,height:l,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},e.createElement("g",{className:"brush-g",transform:`translate(${s.left},${s.top})`}))}const St=c(function(r,l){var a,c,u,d,g,f,y,p,m;const{chartType:v,runtimeMode:b,data:x,chunkThreshold:k,chunkSize:w,xAccessor:A,yAccessor:S,colorAccessor:E,sizeAccessor:O,groupAccessor:M,lineDataAccessor:C,curve:P,normalize:j,binSize:_,valueAccessor:L,arrowOfTime:N="right",windowMode:B="sliding",windowSize:H=200,timeAccessor:W,xExtent:z,yExtent:T,extentPadding:F=.1,sizeRange:I,size:$=[500,300],responsiveWidth:D,responsiveHeight:R,margin:G,className:Y,background:q,lineStyle:V,pointStyle:Q,areaStyle:K,waterfallStyle:U,swarmStyle:Z,barColors:J,colorScheme:ee,boundsAccessor:te,boundsStyle:ne,y0Accessor:oe,gradientFill:ie,openAccessor:re,highAccessor:le,lowAccessor:se,closeAccessor:ae,candlestickStyle:ce,showAxes:he=!0,axes:ue,xLabel:ge,yLabel:pe,xFormat:ke,yFormat:we,tickFormatTime:Ae,tickFormatValue:Se,hoverAnnotation:Ee,tooltipContent:Oe,customHoverBehavior:Me,enableHover:Ce,annotations:Pe,svgAnnotationRules:je,showGrid:_e,legend:Le,legendHoverBehavior:Ne,legendClickBehavior:Be,legendHighlightedCategory:He,legendIsolatedCategories:We,legendPosition:ze,backgroundGraphics:Te,foregroundGraphics:Fe,canvasPreRenderers:$e,title:De,categoryAccessor:Ye,brush:Qe,onBrush:Ke,decay:Ue,pulse:Ze,transition:Je,staleness:nt,heatmapAggregation:ot,heatmapXBins:it,heatmapYBins:rt,showValues:lt,heatmapValueFormat:st,marginalGraphics:at,pointIdAccessor:ct,xScaleType:ht,yScaleType:ut,accessibleTable:dt}=r,[gt,ft]=function(e,i,r){const l=t(null),[s,a]=n(null);return o(()=>{if(!i&&!r)return;const e=l.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,r]),[l,[i&&s?s.w:e[0],r&&s?s.h:e[1]]]}($,D,R),yt=Object.assign(Object.assign({},bt),G);if(at){const e=60;at.top&&e>yt.top&&(yt.top=e),at.bottom&&e>yt.bottom&&(yt.bottom=e),at.left&&e>yt.left&&(yt.left=e),at.right&&e>yt.right&&(yt.right=e)}const pt=ft[0]-yt.left-yt.right,mt=ft[1]-yt.top-yt.bottom,kt="function"==typeof Fe?Fe({size:ft,margin:yt}):Fe,St="function"==typeof Te?Te({size:ft,margin:yt}):Te,Et=null!=Ee?Ee:Ce,Ot=t(null),Mt=t(null),Ct=t(0),Pt=t(!1),jt=et(e=>e.theme),[_t,Lt]=n(0),[Nt,Bt]=n(null),Ht=t(null),Wt=t(null),[zt,Tt]=n(null),[Ft,It]=n(!1),[$t,Dt]=n([]),[Rt,Gt]=n([]),Yt=t(()=>{}),Xt="streaming"===b||["bar","swarm","waterfall"].includes(v),qt=i(()=>({chartType:v,runtimeMode:Xt?"streaming":"bounded",windowSize:H,windowMode:B,arrowOfTime:Xt?N:"right",extentPadding:F,xAccessor:Xt?void 0:A,yAccessor:Xt?void 0:S,timeAccessor:Xt?W:void 0,valueAccessor:L,colorAccessor:E,sizeAccessor:O,groupAccessor:M,categoryAccessor:Ye,lineDataAccessor:C,xScaleType:ht,yScaleType:ut,xExtent:z,yExtent:T,sizeRange:I,binSize:_,normalize:j,boundsAccessor:te,boundsStyle:ne,y0Accessor:oe,gradientFill:"boolean"==typeof ie?ie?{topOpacity:.8,bottomOpacity:.05}:void 0:ie,openAccessor:re,highAccessor:le,lowAccessor:se,closeAccessor:ae,candlestickStyle:ce,lineStyle:V,pointStyle:Q,areaStyle:K,swarmStyle:Z,waterfallStyle:U,colorScheme:ee,barColors:J,annotations:Pe,decay:Ue,pulse:Ze,transition:Je,staleness:nt,heatmapAggregation:ot,heatmapXBins:it,heatmapYBins:rt,showValues:lt,heatmapValueFormat:st,pointIdAccessor:ct,curve:P}),[v,H,B,N,F,A,S,W,L,ht,ut,E,O,M,Ye,C,z,T,I,_,j,te,ne,oe,ie,re,le,se,ae,ce,V,Q,K,Z,U,ee,J,Pe,Ue,Ze,Je,nt,ot,it,rt,lt,st,Xt,ct,P]),Vt=t(null);Vt.current||(Vt.current=new de(qt));const Qt=s(()=>{Ct.current||(Ct.current=requestAnimationFrame(()=>Yt.current()))},[]);o(()=>{var e;null===(e=Vt.current)||void 0===e||e.updateConfig(qt),Pt.current=!0,Qt()},[qt,Qt]),o(()=>{Pt.current=!0,Qt()},[jt,Qt]);const Kt=t(null);Kt.current||(Kt.current=new X(e=>{const t=Vt.current;t&&t.ingest(e)&&(Pt.current=!0,Qt())},{chunkThreshold:k,chunkSize:w})),o(()=>{var e;null===(e=Kt.current)||void 0===e||e.updateChunkOptions({chunkThreshold:k,chunkSize:w})},[k,w]);const Ut=s(e=>{var t;null===(t=Kt.current)||void 0===t||t.push(e)},[]),Zt=s(e=>{var t;null===(t=Kt.current)||void 0===t||t.pushMany(e)},[]),Jt=s(()=>{var e,t;null===(e=Kt.current)||void 0===e||e.clear(),null===(t=Vt.current)||void 0===t||t.clear(),Pt.current=!0,Qt()},[Qt]);h(l,()=>({push:Ut,pushMany:Zt,clear:Jt,getData:()=>{var e,t,n;return null===(e=Kt.current)||void 0===e||e.flush(),null!==(n=null===(t=Vt.current)||void 0===t?void 0:t.getData())&&void 0!==n?n:[]},getScales:()=>{var e,t;return null!==(t=null===(e=Vt.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null},getExtents:()=>{var e,t;return null!==(t=null===(e=Vt.current)||void 0===e?void 0:e.getExtents())&&void 0!==t?t:null}}),[Ut,Zt,Jt]),o(()=>{var e;x&&(null===(e=Kt.current)||void 0===e||e.setBoundedData(x))},[x]);const en=t(()=>{}),tn=t(()=>{});en.current=e=>{if(!Et)return;const t=Ot.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-yt.left,i=e.clientY-n.top-yt.top;if(0>o||o>pt||0>i||i>mt)return void(Ht.current&&(Ht.current=null,Wt.current=null,Tt(null),Me&&(Me(null),Pt.current=!0),Qt()));const r=Vt.current;if(!r||0===r.scene.length)return;const l=function(e,t,n,o=30,i){let r=null,l=!1;if(i){const e=i.find(t,n,o);if(e){const i=fe(e,t,n);i&&o>i.distance&&(r=i,l=!0)}}for(const s of e){let e=null;switch(s.type){case"point":if(i&&l)break;e=fe(s,t,n);break;case"line":e=ye(s,t,n);break;case"rect":e=me(s,t,n);break;case"heatcell":e=ve(s,t,n);break;case"area":if(!1===s.interactive)break;e=xe(s,t,n);break;case"candlestick":e=be(s,t,n)}e&&o>e.distance&&(r&&e.distance>=r.distance||(r=e))}return r}(r.scene,o,i,30,r.quadtree);if(!l)return void(Ht.current&&(Ht.current=null,Wt.current=null,Tt(null),Me&&Me(null),Qt()));const s=l.datum||{},a=Object.assign(Object.assign({},"object"!=typeof s||null===s||Array.isArray(s)?{}:s),{data:s,time:l.x,value:l.y,x:l.x,y:l.y});Ht.current=a,Wt.current=l.node,Tt(a),Me&&(Me(a),Pt.current=!0),Qt()},tn.current=()=>{Ht.current&&(Ht.current=null,Wt.current=null,Tt(null),Me&&(Me(null),Pt.current=!0),Qt())},s(e=>en.current(e),[]);const nn=s(()=>tn.current(),[]),on=t(-1),rn=s(e=>{const t=Vt.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>on.current?-1:on.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 on.current=-1,Ht.current=null,Wt.current=null,Tt(null),Me&&Me(null),void Qt();const r=0>o?0:i;on.current=r;const l=function(e){const t=e.datum||{};return Object.assign(Object.assign({},"object"!=typeof t||null===t||Array.isArray(t)?{}:t),{data:t,x:e.x,y:e.y,time:e.x,value:e.y})}(n[r]);Ht.current=l,Tt(l),Me&&Me(l),Qt()},[Me,Qt]),ln=s(e=>{on.current=-1,en.current(e)},[]);Yt.current=()=>{var e,t;Ct.current=0;const n=Ot.current,o=Mt.current;if(!n||!o)return;const i=Vt.current;if(!i)return;const r="undefined"!=typeof performance?performance.now():Date.now(),l=i.advanceTransition(r),s=Pt.current||l;s&&!l&&i.computeScene({width:pt,height:mt});const a="undefined"!=typeof window&&window.devicePixelRatio||1,c=function(e){if(!e)return xt;const t=getComputedStyle(e),n=t.getPropertyValue("--semiotic-border").trim(),o=t.getPropertyValue("--semiotic-text-secondary").trim(),i=t.getPropertyValue("--semiotic-bg").trim(),r=o||t.getPropertyValue("--text-secondary").trim(),l=t.getPropertyValue("--text-primary").trim(),s=n||t.getPropertyValue("--surface-3").trim(),a=i||t.getPropertyValue("--surface-0").trim();return r||l||n?{axisStroke:s||xt.axisStroke,tickText:r||xt.tickText,crosshair:r?r+"66":xt.crosshair,hoverFill:a?a+"4D":xt.hoverFill,hoverStroke:r?r+"99":xt.hoverStroke,pointRing:a||xt.pointRing}:xt}(n),h=null!==(e=null==nt?void 0:nt.threshold)&&void 0!==e?e:5e3,u=nt&&i.lastIngestTime>0&&r-i.lastIngestTime>h;if(s){const e=tt(n,ft,yt,a);if(e){e.clearRect(-yt.left,-yt.top,ft[0],ft[1]),u&&(e.globalAlpha=null!==(t=null==nt?void 0:nt.dimOpacity)&&void 0!==t?t:.5);const o=getComputedStyle(n).getPropertyValue("--semiotic-bg").trim(),r=q||(o&&"transparent"!==o?o:null);if(r&&(e.fillStyle=r,e.fillRect(-yt.left,-yt.top,ft[0],ft[1])),e.save(),"function"==typeof e.rect&&(e.beginPath(),e.rect(0,0,pt,mt),e.clip()),$e&&i.scales)for(const t of $e)e.save(),t(e,i.scene,i.scales,{width:pt,height:mt}),e.restore();const l=vt[v];if(l&&i.scales)for(const t of l)t(e,i.scene,i.scales,{width:pt,height:mt});e.restore(),u&&(e.globalAlpha=1)}}{const e=tt(o,ft,yt,a);if(e&&(Et&&Ht.current&&i.scales&&function(e,t,n,o,i,r,l){if(!1===i.crosshair)return;e.save();const s="object"==typeof i.crosshair?i.crosshair:{};e.strokeStyle=s.stroke||l.crosshair,e.lineWidth=s.strokeWidth||1,e.setLineDash(s.strokeDasharray?s.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),e.beginPath(),e.moveTo(t.x,0),e.lineTo(t.x,o),e.stroke(),e.beginPath(),e.moveTo(0,t.y),e.lineTo(n,t.y),e.stroke(),e.restore(),e.beginPath(),e.arc(t.x,t.y,4,0,2*Math.PI),e.fillStyle="#007bff",e.fill(),e.strokeStyle=l.pointRing,e.lineWidth=2,e.stroke()}(e,Ht.current,pt,mt,"object"==typeof Et?Et:{},0,c),Wt.current&&Array.isArray(Ee))){const t=Ee.find(e=>e&&"object"==typeof e&&"highlight"===e.type);t&&function(e,t,n,o){var i;if(!n)return;const r=n.group;if(void 0!==r)for(const n of t){if("line"!==n.type)continue;if(n.group!==r)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()}}(e,i.scene,Wt.current,t)}}s&&n&&n.setAttribute("aria-label",Xe(i.scene,v+" chart"));const d=Pt.current;if(Pt.current=!1,d&&i.scales&&((!Nt||Nt.x.domain()[0]!==i.scales.x.domain()[0]||Nt.x.domain()[1]!==i.scales.x.domain()[1]||Nt.y.domain()[0]!==i.scales.y.domain()[0]||Nt.y.domain()[1]!==i.scales.y.domain()[1]||Nt.x.range()[0]!==i.scales.x.range()[0]||Nt.x.range()[1]!==i.scales.x.range()[1]||Nt.y.range()[0]!==i.scales.y.range()[0]||Nt.y.range()[1]!==i.scales.y.range()[1])&&Bt(i.scales),at)){const e=i.getData(),t="function"==typeof A?A:e=>e[A||"x"],n="function"==typeof S?S:e=>e[S||"y"];Dt(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),Gt(e.map(e=>n(e)).filter(e=>"number"==typeof e&&isFinite(e)))}d&&Pe&&Pe.length>0&&Lt(e=>e+1),(null==nt?void 0:nt.showBadge)&&It(!!u),(l||i.hasActivePulses)&&(Ct.current=requestAnimationFrame(()=>Yt.current()))},o(()=>(Qt(),()=>{Ct.current&&(cancelAnimationFrame(Ct.current),Ct.current=0)}),[Qt]),o(()=>{Pt.current=!0,Qt()},[v,pt,mt,he,q,V,$e,Qt]),function(e,t,n,i,r,l){o(()=>{if(!e)return;const o=setInterval(()=>{var o;const s=t.current;if(!s||0===s.lastIngestTime)return;const a="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(o=e.threshold)&&void 0!==o?o:5e3,h=a-s.lastIngestTime>c;h!==r&&(l(h),n.current=!0,i())},1e3);return()=>clearInterval(o)},[e,r,i])}(nt,Vt,Pt,Qt,Ft,It);const sn=Et&&zt?Oe?Oe(zt):e.createElement(wt,{hover:zt}):null,an=sn?e.createElement("div",{className:"stream-frame-tooltip",style:{position:"absolute",left:yt.left+zt.x,top:yt.top+zt.y,transform:`translate(${zt.x>.7*pt?"calc(-100% - 12px)":"12px"}, ${.3*mt>zt.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:1,width:"max-content"}},sn):null,cn=on.current>=0&&zt?e.createElement("svg",{style:{position:"absolute",left:0,top:0,width:ft[0],height:ft[1],pointerEvents:"none",zIndex:2}},e.createElement("circle",{cx:zt.x+yt.left,cy:zt.y+yt.top,r:8,fill:"none",stroke:"var(--accent, #6366f1)",strokeWidth:2,strokeDasharray:"4,2"})):null;if(Ge){const t=Vt.current;t&&x&&(t.ingest({inserts:x,bounded:!0}),t.computeScene({width:pt,height:mt}));const n=null!==(a=null==t?void 0:t.scene)&&void 0!==a?a:[],o=null!==(c=null==t?void 0:t.scales)&&void 0!==c?c:null;return e.createElement("div",{className:"stream-xy-frame"+(Y?" "+Y:""),role:"img","aria-label":"string"==typeof De?De:"XY chart",style:{position:"relative",width:ft[0],height:ft[1]}},e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:ft[0],height:ft[1],style:{position:"absolute",left:0,top:0}},St,e.createElement("g",{transform:`translate(${yt.left},${yt.top})`},q&&e.createElement("rect",{x:0,y:0,width:pt,height:mt,fill:q}),n.map((t,n)=>function(t,n){var o,i,r;switch(t.type){case"line":{const o=t;if(0===o.path.length)return null;const i="M"+o.path.map(([e,t])=>`${e},${t}`).join("L");return e.createElement("path",{key:"line-"+n,d:i,fill:"none",stroke:o.style.stroke||"#4e79a7",strokeWidth:o.style.strokeWidth||2,strokeDasharray:o.style.strokeDasharray,opacity:o.style.opacity})}case"area":{const r=t;if(0===r.topPath.length)return null;const l=r.topPath.map(([e,t])=>`${e},${t}`).join("L"),s=[...r.bottomPath].reverse().map(([e,t])=>`${e},${t}`).join("L");return e.createElement("path",{key:"area-"+n,d:`M${l}L${s}Z`,fill:r.style.fill||"#4e79a7",fillOpacity:null!==(i=null!==(o=r.style.fillOpacity)&&void 0!==o?o:r.style.opacity)&&void 0!==i?i:.7,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})}case"point":return e.createElement("circle",{key:"point-"+n,cx:t.x,cy:t.y,r:t.r,fill:t.style.fill||"#4e79a7",opacity:null!==(r=t.style.opacity)&&void 0!==r?r:.8,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth});case"rect":return e.createElement("rect",{key:"rect-"+n,x:t.x,y:t.y,width:t.w,height:t.h,fill:t.style.fill||"#4e79a7",opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth});case"heatcell":{const o=t;if(o.showValues&&null!=o.value&&o.w>=20&&o.h>=20){const t=o.valueFormat?o.valueFormat(o.value):Number.isInteger(o.value)?o.value+"":100>Math.abs(o.value)?1>Math.abs(o.value)?o.value.toPrecision(3):o.value.toFixed(1):o.value.toFixed(0),[i,r,l]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(o.fill),s=.299*i+.587*r+.114*l>128?"#000":"#fff",a=Math.max(10,Math.min(16,.3*Math.min(o.w,o.h)));return e.createElement("g",{key:"heatcell-"+n},e.createElement("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:o.fill}),e.createElement("text",{x:o.x+o.w/2,y:o.y+o.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:s,fontSize:a+"px"},t))}return e.createElement("rect",{key:"heatcell-"+n,x:o.x,y:o.y,width:o.w,height:o.h,fill:o.fill})}case"candlestick":{const o=t,i=Math.min(o.openY,o.closeY),r=Math.max(Math.abs(o.openY-o.closeY),1),l=o.isUp?o.upColor:o.downColor;return e.createElement("g",{key:"candle-"+n},e.createElement("line",{x1:o.x,y1:o.highY,x2:o.x,y2:o.lowY,stroke:o.wickColor,strokeWidth:o.wickWidth}),e.createElement("rect",{x:o.x-o.bodyWidth/2,y:i,width:o.bodyWidth,height:r,fill:l,stroke:l,strokeWidth:1}))}default:return null}}(t,n)).filter(Boolean))),e.createElement(Re,{width:pt,height:mt,totalWidth:ft[0],totalHeight:ft[1],margin:yt,scales:o,showAxes:he,axes:ue,xLabel:ge,yLabel:pe,xFormat:ke||Ae,yFormat:we||Se,showGrid:_e,title:De,legend:Le,legendHoverBehavior:Ne,legendClickBehavior:Be,legendHighlightedCategory:He,legendIsolatedCategories:We,legendPosition:ze,foregroundGraphics:kt,marginalGraphics:at,xValues:[],yValues:[],annotations:Pe,svgAnnotationRules:je,annotationFrame:0,xAccessor:"string"==typeof A?A:"string"==typeof W?W:void 0,yAccessor:"string"==typeof S?S:"string"==typeof L?L:void 0,annotationData:null==t?void 0:t.getData(),pointNodes:null==t?void 0:t.scene.filter(e=>"point"===e.type),curve:"string"==typeof P?P:void 0}))}return e.createElement("div",{ref:gt,className:"stream-xy-frame"+(Y?" "+Y:""),role:"img","aria-label":"string"==typeof De?De:"XY chart",tabIndex:0,style:{position:"relative",width:D?"100%":ft[0],height:R?"100%":ft[1],overflow:"visible"},onMouseMove:Et?ln:void 0,onMouseLeave:Et?nn:void 0,onKeyDown:rn},St&&e.createElement("svg",{style:{position:"absolute",left:0,top:0,width:ft[0],height:ft[1],pointerEvents:"none"}},St),e.createElement(Ie,{width:pt,height:mt,totalWidth:ft[0],totalHeight:ft[1],margin:yt,scales:Nt,showAxes:he,axes:ue,showGrid:_e,xFormat:ke||Ae,yFormat:we||Se}),e.createElement("canvas",{ref:Ot,"aria-label":Xe(null!==(d=null===(u=Vt.current)||void 0===u?void 0:u.scene)&&void 0!==d?d:[],v+" chart"),style:{position:"absolute",left:0,top:0}}),e.createElement("canvas",{ref:Mt,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),e.createElement(Ve,{hoverPoint:zt}),dt&&e.createElement(qe,{scene:null!==(f=null===(g=Vt.current)||void 0===g?void 0:g.scene)&&void 0!==f?f:[],chartType:v+" chart"}),e.createElement(Re,{width:pt,height:mt,totalWidth:ft[0],totalHeight:ft[1],margin:yt,scales:Nt,showAxes:he,axes:ue,xLabel:ge,yLabel:pe,xFormat:ke||Ae,yFormat:we||Se,showGrid:_e,title:De,legend:Le,legendHoverBehavior:Ne,legendClickBehavior:Be,legendHighlightedCategory:He,legendIsolatedCategories:We,legendPosition:ze,foregroundGraphics:kt,marginalGraphics:at,xValues:$t,yValues:Rt,annotations:Pe,svgAnnotationRules:je,annotationFrame:_t,xAccessor:"string"==typeof A?A:"string"==typeof W?W:void 0,yAccessor:"string"==typeof S?S:"string"==typeof L?L:void 0,annotationData:null===(y=Vt.current)||void 0===y?void 0:y.getData(),pointNodes:null===(p=Vt.current)||void 0===p?void 0:p.scene.filter(e=>"point"===e.type),curve:"string"==typeof P?P:void 0,underlayRendered:!0}),(Qe||Ke)&&e.createElement(At,{width:pt,height:mt,totalWidth:ft[0],totalHeight:ft[1],margin:yt,dimension:null!==(m=null==Qe?void 0:Qe.dimension)&&void 0!==m?m:"xy",scales:Nt,onBrush:null!=Ke?Ke:()=>{}}),(null==nt?void 0:nt.showBadge)&&e.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===nt.badgePosition?{top:4,left:4}:"bottom-left"===nt.badgePosition?{bottom:4,left:4}:"bottom-right"===nt.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:Ft?"#dc3545":"#28a745",color:"white"})},Ft?"STALE":"LIVE"),cn,an)});St.displayName="StreamXYFrame";const Et=r(null);function Ot(){return l(Et)}function Mt(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 Ct(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}const[Pt,jt]=Qe(e=>({selections:new Map,setClause(t,n){e(e=>{const o=new Map(e.selections),i=Ct(o,t),r=new Map(i.clauses);return r.set(n.clientId,n),o.set(t,Object.assign(Object.assign({},i),{clauses:r})),{selections:o}})},clearClause(t,n){e(e=>{const o=e.selections.get(t);if(!o)return{};const i=new Map(e.selections),r=new Map(o.clauses);return r.delete(n),i.set(t,Object.assign(Object.assign({},o),{clauses:r})),{selections:i}})},setResolution(t,n){e(e=>{const o=new Map(e.selections),i=Ct(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}})}})),[_t,Lt]=Qe(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}))}}));function Nt(e){const t=u(),n=e.clientId||t,{name:o}=e,r=jt(e=>e.selections.get(o)),l=jt(e=>e.setClause),a=jt(e=>e.clearClause),c=i(()=>!!r&&r.clauses.size>0,[r]);return{predicate:i(()=>r&&0!==r.clauses.size?function(e,t){const n=[];for(const[o,i]of e.clauses)"crossfilter"===e.resolution&&o===t||n.push(Mt(i));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(r,n):()=>!0,[r,n]),isActive:c,selectPoints:s(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:s(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:s(()=>{a(o,n)},[a,o,n]),clientId:n}}function Bt(e){const t=e.name||"hover",{fields:n}=e,{predicate:o,isActive:i,selectPoints:r,clear:l}=Nt({name:t});return{onHover:s(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&&r(t)},[n,r,l,t]),predicate:o,isActive:i}}function Ht(e){const{name:t,xField:n,yField:o}=e,{predicate:r,isActive:l,selectInterval:a,clear:c}=Nt({name:t}),h=n&&o?"xyBrush":n?"xBrush":"yBrush",u=s(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:r,isActive:l,clear:c}}const Wt=r(!1);function zt({selections:e}){const t=jt(e=>e.setResolution);return o(()=>{for(const[n,o]of Object.entries(e))o.resolution&&t(n,o.resolution)},[e,t]),null}function Tt({categoryColors:i,interaction:r,selectionName:l,field:a}){const c=Object.entries(i);if(0===c.length)return null;const h=c.map(([e])=>e),u=[{styleFn:e=>({fill:e.color||"#333",stroke:e.color||"#333"}),type:"fill",items:c.map(([e,t])=>({label:e,color:t})),label:""}],d=Bt({name:l,fields:[a]}),g=Nt({name:l,clientId:"__linked-legend-isolate__"}),[f,y]=n(new Set),[p,m]=n(null),v=t(g.selectPoints);v.current=g.selectPoints;const b=t(g.clear);b.current=g.clear,o(()=>{"isolate"===r&&(f.size>0?v.current({[a]:Array.from(f)}):b.current())},[r,f,a]);const x=s(e=>{"highlight"===r&&(e?(m(e.label),d.onHover({[a]:e.label})):(m(null),d.onHover(null)))},[r,a,d]),k=s(e=>{"isolate"===r&&y(t=>{const n=new Set(t);return n.has(e.label)?n.delete(e.label):n.add(e.label),n.size===h.length?new Set:n})},[r,h.length]);return e.createElement("svg",{width:"100%",height:30,style:{display:"block",overflow:"visible"}},e.createElement(Me,{legendGroups:u,title:!1,orientation:"horizontal",height:20,customHoverBehavior:"highlight"===r?x:void 0,customClickBehavior:"isolate"===r?k:void 0,highlightedCategory:p,isolatedCategories:f}))}function Ft({children:t,selections:n,showLegend:o,legendPosition:i="top",legendInteraction:r="none",legendSelectionName:l="legend",legendField:s="category"}){const a=Ot(),c=void 0!==o?o:!(!a||0>=Object.keys(a).length);return e.createElement(Pt,null,e.createElement(_t,null,n&&e.createElement(zt,{selections:n}),e.createElement(Wt.Provider,{value:c},c&&"top"===i&&a&&e.createElement(Tt,{categoryColors:a,interaction:r,selectionName:l,field:s}),t,c&&"bottom"===i&&a&&e.createElement(Tt,{categoryColors:a,interaction:r,selectionName:l,field:s}))))}function It({data:e,colorBy:t,colorScale:n,getColor:o,strokeColor:i,strokeWidth:r}){return{legendGroups:[{styleFn:e=>{const t=e.color||"#333",n={fill:t,stroke:t};return void 0!==i&&(n.stroke=i),void 0!==r&&(n.strokeWidth=r),n},type:"fill",items:Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t]))).map(i=>{const r=e.find("function"==typeof t?e=>t(e)===i:e=>e[t]===i),l=r?o(r,t,n):n?n(i):"#000000";return{label:i+"",color:l}}),label:""}]}}function $t(e){return e?"string"==typeof e?{name:e}:e:null}function Dt(e,t,n){return t?o=>{var i;const r=Object.assign({},e(o));if(t.isActive)if(t.predicate(o))(null==n?void 0:n.selectedStyle)&&Object.assign(r,n.selectedStyle);else{const e=null!==(i=null==n?void 0:n.unselectedOpacity)&&void 0!==i?i:.2;r.opacity=e,r.fillOpacity=e,r.strokeOpacity=e,(null==n?void 0:n.unselectedStyle)&&Object.assign(r,n.unselectedStyle)}return r}:e}const Rt="#007bff";function Gt(e){return"function"==typeof e?e:t=>t[e]}function Yt(e,t,n="category10"){const o=Ot();return i(()=>{if(t){if(0===e.length)return o&&Object.keys(o).length>0?e=>o[e]||"#999":void 0;if("function"==typeof t){const i=Array.from(new Set(e.map(e=>t(e)+"")));return o&&Object.keys(o).length>0?e=>o[e]||"#999":ce(i.map(e=>({_cat:e})),"_cat",n)}if(o&&Object.keys(o).length>0){const i=ce(e,t,n);return e=>o[e]||i(e)}return ce(e,t,n)}},[e,t,n,o])}function Xt({selection:e,linkedHover:t,fallbackFields:n=[],unwrapData:o=!1,onObservation:i,chartType:r,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=Nt({name:(null==e?void 0:e.name)||"__unused__"}),h=Bt({name:(null==a?void 0:a.name)||"hover",fields:(null==a?void 0:a.fields)||n||[]}),u=Lt(e=>e.pushObservation),d=e?{isActive:c.isActive,predicate:c.predicate}:null,g=s(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:r||"unknown",chartId:l};if(e){let r=e.data||e.datum||e;Array.isArray(r)&&(r=r[0]);const l=Object.assign(Object.assign({},t),{type:"hover",datum:r||{},x:null!==(n=e.x)&&void 0!==n?n:0,y:null!==(o=e.y)&&void 0!==o?o:0});i&&i(l),u&&u(l)}else{const e=Object.assign(Object.assign({},t),{type:"hover-end"});i&&i(e),u&&u(e)}}},[t,h,i,r,l,u]),f=s(e=>{var t,n;if(i||u){const o={timestamp:Date.now(),chartType:r||"unknown",chartId:l};if(e){let r=e.data||e.datum||e;Array.isArray(r)&&(r=r[0]);const l=Object.assign(Object.assign({},o),{type:"click",datum:r||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0});i&&i(l),u&&u(l)}else{const e=Object.assign(Object.assign({},o),{type:"click-end"});i&&i(e),u&&u(e)}}},[i,u,r,l]);return{activeSelectionHook:d,customHoverBehavior:g,customClickBehavior:f}}function qt({data:e,colorBy:t,colorScale:n,showLegend:o,legendPosition:r="right",userMargin:s,defaults:a={top:50,bottom:60,left:70,right:40}}){const c=l(Wt),h=void 0!==o?o:!c&&!!t,u=i(()=>{if(h&&t)return It({data:e,colorBy:t,colorScale:n,getColor:ae})},[h,t,e,n]),d=i(()=>{const e=Object.assign(Object.assign({},a),s);return u&&("right"===r&&110>e.right?e.right=110:"left"===r&&110>e.left?e.left=110:"top"===r&&50>e.top?e.top=50:"bottom"===r&&80>e.bottom&&(e.bottom=80)),e},[a,s,u,r]);return{legend:u,margin:d,legendPosition:r}}function Vt(e,t,o){const[r,l]=n(null),[a,c]=n(new Set),h=s(t=>{"highlight"===e&&l(t?t.label:null)},[e]),u=s(t=>{"isolate"===e&&c(e=>{const n=new Set(e);return n.has(t.label)?n.delete(t.label):n.add(t.label),n.size===o.length?new Set:n})},[e,o.length]),d=i(()=>{if(!e||"none"===e||!t)return null;const n="string"==typeof t?t:null;return"highlight"===e&&null!=r?{isActive:!0,predicate:e=>(n?e[n]:"function"==typeof t?t(e):null)===r}:"isolate"===e&&a.size>0?{isActive:!0,predicate:e=>{const o=n?e[n]:"function"==typeof t?t(e):null;return a.has(o)}}:null},[e,t,r,a]);return{highlightedCategory:"highlight"===e?r:null,isolatedCategories:"isolate"===e?a:new Set,onLegendHover:h,onLegendClick:u,legendSelectionHook:d}}const Qt={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 Kt(e,t,n){var o,i,r,l,s,a;const c=Qt[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!==(r=t.showGrid)&&void 0!==r?r:c.showGrid,enableHover:null!==(l=t.enableHover)&&void 0!==l?l:!!t.linkedHover||c.enableHover,showLegend:null!==(s=t.showLegend)&&void 0!==s?s: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 Ut={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 Zt(e,t){return"function"==typeof t?t(e):e[t]}function Jt(e,t){return t?t(e):null==e?"":"number"==typeof e?Math.abs(e)>9999?e.toLocaleString():e+"":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 en(t={}){const{fields:n,title:o,format:i,style:r={},className:l=""}=t;return t=>{if(!t||"object"!=typeof t)return null;let s;const a=[];if(o){const e=Zt(t,o);s=Jt(e,i)}if(n&&n.length>0)n.forEach(e=>{let n,o,r;"string"==typeof e?(n=e,o=e,r=i):(n=e.label,o=e.accessor||e.key||"",r=e.format||i);const l=Zt(t,o);a.push({label:n,value:Jt(l,r)})});else if(!o){const e=["value","y","name","id","label"];for(const n of e)if(void 0!==t[n]){s=Jt(t[n],i);break}if(!s){const e=Object.keys(t).filter(e=>!e.startsWith("_"));e.length>0&&(s=Jt(t[e[0]],i))}}const c=Object.assign(Object.assign({},Ut),r);return e.createElement("div",{className:("semiotic-tooltip "+l).trim(),style:c},s&&e.createElement("div",{style:{fontWeight:a.length>0?"bold":"normal"}},s),a.map((t,n)=>e.createElement("div",{key:n,style:{marginTop:0===n&&s?"4px":0}},t.label&&e.createElement("span",null,t.label,": "),t.value)))}}function tn(t){if(!0===t)return en();if("function"==typeof t){const n=t;return t=>{const o=n(!t||"object"!=typeof t.data||null===t.data||"node"!==t.type&&"edge"!==t.type?t:t.data);return null==o?null:e.createElement("div",{className:"semiotic-tooltip",style:Ut},o)}}return!1!==t&&void 0!==t&&("object"==typeof t&&null!==t&&("fields"in t||"title"in t)?en(t):en())}function nn(e){return"string"==typeof e?e:"value"}function on(e){return null==e?"–":"number"==typeof e?Math.abs(e)>9999?e.toLocaleString():e+"":e instanceof Date?e.toLocaleDateString():e+""}function rn(e,t){return"function"==typeof t?t(e):e[t]}function ln(t){const n=t.find(e=>"title"===e.role),o=t.filter(e=>"title"!==e.role);return t=>{const i=t.data;if(!i)return null;const r=n?on(rn(i,n.accessor)):null;return e.createElement("div",{className:"semiotic-tooltip",style:Ut},r&&e.createElement("div",{style:{fontWeight:"bold",marginBottom:o.length>0?4:0}},r),o.map((t,n)=>{const o=on(rn(i,t.accessor));return e.createElement("div",{key:n,style:n>0?{marginTop:2}:void 0},e.createElement("span",{style:{opacity:.7}},t.label,": "),e.createElement("span",null,o))}))}}function sn({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 an 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(sn,{componentName:"ChartErrorBoundary",message:n.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}var cn;const hn="undefined"!=typeof process&&"production"!==(null===(cn=process.env)||void 0===cn?void 0:cn.NODE_ENV);function un({componentName:t,width:n,height:o,children:i}){return e.createElement(an,{fallback:i=>e.createElement(sn,{componentName:t,message:i.message,width:n,height:o})},i)}const dn={display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #999)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"},gn={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function fn(t,n,o,i){return!1===i||null==t||Array.isArray(t)&&t.length>0?null:Array.isArray(t)?e.createElement("div",{style:Object.assign(Object.assign({},dn),{width:n,height:o})},i||"No data available"):null}function yn(t,n,o){if(!t)return null;const i=Math.min(5,Math.floor(o/40)),r=Math.max(8,Math.floor(o/(3*i))),l=Math.max(6,Math.floor(o/(2.5*i))),s=Math.floor((o-(i*(r+l)-l))/2);return e.createElement("div",{style:{width:n,height:o,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"}},Array.from({length:i},(t,o)=>e.createElement("div",{key:o,className:"semiotic-loading-bar",style:Object.assign(Object.assign({},gn),{position:"absolute",top:s+o*(r+l),left:Math.floor(.1*n),width:30+(37*o+13)%50+"%",height:r,opacity:.5+o%2*.2})})))}function pn(e,t,n,o){if(!hn)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 r=Object.keys(i).join(", ");console.warn(`[semiotic] ${e}: ${n} "${o}" not found in data. Available keys: ${r}`)}function mn(e,t){const n=e.length,o=t.length,i=Array(o+1);for(let e=0;o>=e;e++)i[e]=e;for(let r=1;n>=r;r++){let n=i[0];i[0]=r;for(let l=1;o>=l;l++){const o=i[l];i[l]=e[r-1]===t[l-1]?n:1+Math.min(n,i[l],i[l-1]),n=o}}return i[o]}function vn(e,t){var n;if(0===t.length)return null;const o=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(o)||o.includes(e.toLowerCase()))||(null!==(n=function(e,t,n=3){let o,i=n+1;for(const n of t){const t=mn(e.toLowerCase(),n.toLowerCase());i>t&&(i=t,o=n)}return i>n?void 0:o}(e,t,3))&&void 0!==n?n:null)}function bn({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(null==t)return null;if(!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,r]of Object.entries(n))if(r&&"string"==typeof r&&!(r in o)){const n=vn(r,t),o=n?` Try ${i}="${n}".`:"";return`${e}: ${i} "${r}" not found in data. Available fields: ${t.join(", ")}.${o}`}}}return null}function xn(e,t,n,o){return new(n||(n=Promise))(function(i,r){function l(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(l,s)}a((o=o.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;let kn=null;function wn(){return xn(this,void 0,void 0,function*(){return kn||(kn=yield import("./xy-statisticalOverlays-C1f7TYyD.js")),kn})}const An=c(function(r,l){var a,c;const u=t(null);h(l,()=>({push:e=>{var t;return null===(t=u.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=u.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=u.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=u.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const d=Kt(r.mode,{width:r.width,height:r.height,showGrid:r.showGrid,enableHover:r.enableHover,showLegend:r.showLegend,title:r.title,xLabel:r.xLabel,yLabel:r.yLabel}),{data:g,margin:f,className:y,xFormat:p,yFormat:m,xAccessor:v="x",yAccessor:b="y",lineBy:x,lineDataAccessor:k="coordinates",colorBy:w,colorScheme:A="category10",curve:S="linear",showPoints:E=!1,pointRadius:O=3,fillArea:M=!1,areaOpacity:C=.3,lineWidth:P=2,tooltip:j,pointIdAccessor:_,annotations:L,directLabel:N,gapStrategy:B="break",anomaly:H,forecast:W,frameProps:z={},selection:T,linkedHover:F,onObservation:I,chartId:$,loading:D,emptyContent:R,legendInteraction:G,legendPosition:Y,xScaleType:X,yScaleType:q}=r,V=d.width,Q=d.height,K=d.enableHover,U=d.showGrid,Z=d.showLegend,J=d.title,ee=d.xLabel,te=d.yLabel,ne=yn(D,V,Q);if(ne)return ne;const oe=fn(g,V,Q,R);if(oe)return oe;const ie=g||[];pn("LineChart",ie,"xAccessor",v),pn("LineChart",ie,"yAccessor",b);const re="string"==typeof v?v:"x",le="string"==typeof b?b:"y",[se,ce]=n(null),[he,ue]=n([]);o(()=>{if(!W&&!H)return;let e=!1;return ce(null),ue([]),W?function(...e){return xn(this,void 0,void 0,function*(){return(yield wn()).buildForecast(...e)})}(ie,re,le,W,H).then(t=>{e||(ce(t),ue(t.annotations))}).catch(()=>{e||(ce(null),ue([]))}):H&&function(...e){return xn(this,void 0,void 0,function*(){return(yield wn()).buildAnomalyAnnotations(...e)})}(H).then(t=>{e||(ce(null),ue(t))}).catch(()=>{e||ue([])}),()=>{e=!0}},[ie,W,H,re,le]);const de=se?se.processedData:ie,ge=W&&!x?"__forecastSegment":x,{activeSelectionHook:fe,customHoverBehavior:ye}=Xt({selection:T,linkedHover:F,fallbackFields:w?["string"==typeof w?w:""]:[],onObservation:I,chartType:"LineChart",chartId:$}),pe=s(e=>{const t="function"==typeof v?v(e):e[v],n="function"==typeof b?b(e):e[b];return null==t||null==n||Number.isNaN(t)||Number.isNaN(n)},[v,b]),me=void 0!==(null===(a=de[0])||void 0===a?void 0:a[k]),ve=i(()=>{if(me)return de;if(ge){const e=de.reduce((e,t)=>{const n="function"==typeof ge?ge(t):t[ge];if(!e[n]){const t={[k]:[]};"string"==typeof ge&&(t[ge]=n),e[n]=t}return e[n][k].push(t),e},{});return Object.values(e)}return[{[k]:de}]},[de,ge,k,me]),{gapProcessedLineData:be,hasGaps:xe}=i(()=>{if("interpolate"===B){let e=!1;const t=[];for(const n of ve){const o=(n[k]||[]).filter(t=>!pe(t)||(e=!0,!1));o.length>0&&t.push(Object.assign(Object.assign({},n),{[k]:o}))}return{gapProcessedLineData:t,hasGaps:e}}if("break"===B){let e=!1;const t=[];for(const n of ve){const o=n[k]||[];let i=[],r=0;const l=ge&&"string"==typeof ge?n[ge]:void 0;for(const s of o)if(pe(s))e=!0,i.length>0&&(t.push(Object.assign(Object.assign({},n),{[k]:i})),i=[],r++);else{const e=null!=l?`${l}__seg${r}`:"__seg"+r;i.push(Object.assign(Object.assign({},s),{_gapSegment:e}))}i.length>0&&t.push(Object.assign(Object.assign({},n),{[k]:i}))}return{gapProcessedLineData:t,hasGaps:e}}if("zero"===B){let e=!1;const t="string"==typeof b?b:"y",n=[];for(const o of ve){const i=o[k]||[],r=[];for(const n of i)pe(n)?(e=!0,r.push(Object.assign(Object.assign({},n),{[t]:0}))):r.push(n);n.push(Object.assign(Object.assign({},o),{[k]:r}))}return{gapProcessedLineData:n,hasGaps:e}}return{gapProcessedLineData:ve,hasGaps:!1}},[ve,B,k,pe,ge,b]),ke=Yt(de,w,A),we=i(()=>{if(!w)return[];const e=new Set;for(const t of de){const n="function"==typeof w?w(t):t[w];null!=n&&e.add(n+"")}return Array.from(e)},[de,w]),Ae=Vt(G,w,we),Se=i(()=>Ae.legendSelectionHook?Ae.legendSelectionHook:fe,[Ae.legendSelectionHook,fe]),Ee=i(()=>e=>{const t={strokeWidth:P};return w?ke&&(t.stroke=ae(e,w,ke),M&&(t.fill=t.stroke,t.fillOpacity=C)):(t.stroke=Rt,M&&(t.fill=Rt,t.fillOpacity=C)),t},[w,ke,P,M,C]),[Oe,Me]=n(null);o(()=>{if(!W)return void Me(null);let e=!1;return function(...e){return xn(this,void 0,void 0,function*(){return(yield wn()).createSegmentLineStyle(...e)})}(Ee,W).then(t=>{e||Me(()=>t)}).catch(()=>{e||Me(null)}),()=>{e=!0}},[Ee,W]);const Ce=Oe||Ee,Pe=i(()=>Dt(Ce,Se,T),[Ce,Se,T]),je=i(()=>{if(E)return e=>{const t={r:O,fillOpacity:1};return w?ke&&(t.fill=ae(e.parentLine||e,w,ke)):t.fill=Rt,t}},[E,O,w,ke]),_e=M?"area":"line",Le="object"==typeof N?N:{},Ne=Le.position||"end",Be=Le.fontSize||11,He=i(()=>{var e,t;if(!N||!w)return[];const n="function"==typeof v?v:e=>e[v],o="function"==typeof b?b:e=>e[b],i="function"==typeof w?w:e=>e[w],r=new Map;for(const n of be){const o=n[k]||[];if(0===o.length)continue;const l="end"===Ne?o[o.length-1]:o[0],s=null!==(t=null!==(e=i(l))&&void 0!==e?e:i(n))&&void 0!==t?t:"";s&&!r.has(s+"")&&r.set(s+"",l)}const l=Array.from(r.entries()).map(([e,t])=>({type:"text",label:e,["string"==typeof v?v:"x"]:n(t),["string"==typeof b?b:"y"]:o(t),dx:"end"===Ne?6:-6,dy:0,color:ke?ke(e):Rt,fontSize:Be}));l.sort((e,t)=>{const n="string"==typeof b?b:"y";return e[n]-t[n]});for(let e=1;l.length>e;e++){const t="string"==typeof b?b:"y",n=l[e-1],o=l[e];Be+2>Math.abs(o[t]+o.dy-(n[t]+n.dy))&&(o.dy+=Be+2)}return l},[N,w,ke,be,k,v,b,Ne,Be]),We=(!N||void 0!==Z)&&Z,ze=i(()=>{if(!N)return d.marginDefaults;const e=He.reduce((e,t)=>{var n;const o=((null===(n=t.label)||void 0===n?void 0:n.length)||0)*(.6*Be);return Math.max(e,o)},0),t=e+10,n="end"===Ne?"right":"left";return Object.assign(Object.assign({},d.marginDefaults),{[n]:Math.max(d.marginDefaults[n]||0,t)})},[N,He,Be,Ne,d.marginDefaults]),{legend:Te,margin:Fe,legendPosition:Ie}=qt({data:be,colorBy:w,colorScale:ke,showLegend:We,legendPosition:Y,userMargin:f,defaults:ze}),$e=x||w,De=i(()=>ln([{label:ee||nn(v),accessor:v,role:"x"},{label:te||nn(b),accessor:b,role:"y"},...$e?[{label:nn($e),accessor:$e,role:"group"}]:[]]),[v,b,ee,te,$e]),Re=bn({componentName:"LineChart",data:me?(null===(c=de[0])||void 0===c?void 0:c[k])||[]:g,accessors:{xAccessor:v,yAccessor:b}});if(Re)return e.createElement(sn,{componentName:"LineChart",message:Re,width:V,height:Q});const Ge=i(()=>me||ge||xe?be.flatMap(e=>{const t=e[k]||[];return ge&&"string"==typeof ge?t.map(t=>Object.assign(Object.assign({},t),{[ge]:e[ge]})):t}):de,[be,k,me,ge,de,xe]),Ye=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:_e},null!=g&&{data:Ge}),{xAccessor:v,yAccessor:b,xScaleType:X,yScaleType:q,groupAccessor:"break"===B&&xe?"_gapSegment":ge||void 0,curve:S,lineStyle:Pe}),E&&{pointStyle:je}),{size:[V,Q],responsiveWidth:r.responsiveWidth,responsiveHeight:r.responsiveHeight,margin:Fe,showAxes:d.showAxes,xLabel:ee,yLabel:te,xFormat:p,yFormat:m,enableHover:K,showGrid:U}),Te&&{legend:Te,legendPosition:Ie}),G&&"none"!==G&&{legendHoverBehavior:Ae.onLegendHover,legendClickBehavior:Ae.onLegendClick,legendHighlightedCategory:Ae.highlightedCategory,legendIsolatedCategories:Ae.isolatedCategories}),J&&{title:J}),y&&{className:y}),{tooltipContent:!1===j?()=>null:tn(j)||De}),(F||I)&&{customHoverBehavior:ye}),_&&{pointIdAccessor:_}),((null==L?void 0:L.length)||he.length||He.length)&&{annotations:[...L||[],...he,...He]}),z);return e.createElement(un,{componentName:"LineChart",width:V,height:Q},e.createElement(St,Object.assign({ref:u},Ye)))});An.displayName="LineChart";const Sn=c(function(n,o){var r;const l=t(null);h(o,()=>({push:e=>{var t;return null===(t=l.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=l.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=l.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=l.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const s=Kt(n.mode,{width:n.width,height:n.height,showGrid:n.showGrid,enableHover:n.enableHover,showLegend:n.showLegend,title:n.title,xLabel:n.xLabel,yLabel:n.yLabel}),{data:a,margin:c,className:u,xFormat:d,yFormat:g,xAccessor:f="x",yAccessor:y="y",areaBy:p,y0Accessor:m,gradientFill:v=!1,lineDataAccessor:b="coordinates",colorBy:x,colorScheme:k="category10",curve:w="monotoneX",areaOpacity:A=.7,showLine:S=!0,lineWidth:E=2,tooltip:O,annotations:M,frameProps:C={},selection:P,linkedHover:j,onObservation:_,chartId:L,loading:N,emptyContent:B,legendInteraction:H,legendPosition:W}=n,z=s.width,T=s.height,F=s.enableHover,I=s.showGrid,$=s.showLegend,D=s.title,R=s.xLabel,G=s.yLabel,Y=yn(N,z,T);if(Y)return Y;const X=fn(a,z,T,B);if(X)return X;const q=a||[];pn("AreaChart",q,"xAccessor",f),pn("AreaChart",q,"yAccessor",y);const{activeSelectionHook:V,customHoverBehavior:Q}=Xt({selection:P,linkedHover:j,fallbackFields:x?["string"==typeof x?x:""]:[],onObservation:_,chartType:"AreaChart",chartId:L}),K=void 0!==(null===(r=q[0])||void 0===r?void 0:r[b]),U=i(()=>{if(K)return q;if(p){const e=q.reduce((e,t)=>{const n="function"==typeof p?p(t):t[p];if(!e[n]){const t={[b]:[]};"string"==typeof p&&(t[p]=n),e[n]=t}return e[n][b].push(t),e},{});return Object.values(e)}return[{[b]:q}]},[q,p,b,K]),Z=Yt(q,x,k),J=i(()=>{if(!x)return[];const e=new Set;for(const t of q){const n="function"==typeof x?x(t):t[x];null!=n&&e.add(n+"")}return Array.from(e)},[q,x]),ee=Vt(H,x,J),te=i(()=>ee.legendSelectionHook?ee.legendSelectionHook:V,[ee.legendSelectionHook,V]),ne=i(()=>e=>{const t={};if(x){if(Z){const n=ae(e,x,Z);t.fill=n,S?(t.stroke=n,t.strokeWidth=E):t.stroke="none"}}else t.fill=Rt,S?(t.stroke=Rt,t.strokeWidth=E):t.stroke="none";return t.fillOpacity=A,t},[x,Z,A,S,E]),oe=i(()=>Dt(ne,te,P),[ne,te,P]),{legend:ie,margin:re,legendPosition:le}=qt({data:U,colorBy:x,colorScale:Z,showLegend:$,legendPosition:W,userMargin:c,defaults:s.marginDefaults}),se=p||x,ce=i(()=>ln([{label:R||nn(f),accessor:f,role:"x"},{label:G||nn(y),accessor:y,role:"y"},...se?[{label:nn(se),accessor:se,role:"group"}]:[]]),[f,y,R,G,se]),he=bn({componentName:"AreaChart",data:a,accessors:{xAccessor:f,yAccessor:y}});if(he)return e.createElement(sn,{componentName:"AreaChart",message:he,width:z,height:T});const ue=i(()=>K||p?U.flatMap(e=>{const t=e[b]||[];return p&&"string"==typeof p?t.map(t=>Object.assign(Object.assign({},t),{[p]:e[p]})):t}):q,[U,b,K,p,q]),de=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"area"},null!=a&&{data:ue}),{xAccessor:f,yAccessor:y,groupAccessor:p||void 0}),m&&{y0Accessor:m}),v&&{gradientFill:v}),{curve:w,lineStyle:oe,size:[z,T],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:re,showAxes:s.showAxes,xLabel:R,yLabel:G,xFormat:d,yFormat:g,enableHover:F,showGrid:I}),ie&&{legend:ie,legendPosition:le}),H&&"none"!==H&&{legendHoverBehavior:ee.onLegendHover,legendClickBehavior:ee.onLegendClick,legendHighlightedCategory:ee.highlightedCategory,legendIsolatedCategories:ee.isolatedCategories}),D&&{title:D}),u&&{className:u}),{tooltipContent:!1===O?()=>null:tn(O)||ce}),(j||_)&&{customHoverBehavior:Q}),M&&M.length>0&&{annotations:M}),C);return e.createElement(un,{componentName:"AreaChart",width:z,height:T},e.createElement(St,Object.assign({ref:l},de)))});Sn.displayName="AreaChart";const En=c(function(o,r){var l;const a=t(null),c=Kt(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,xLabel:o.xLabel,yLabel:o.yLabel}),{data:u,margin:d,className:g,xFormat:f,yFormat:y,xAccessor:p="x",yAccessor:m="y",areaBy:v,lineDataAccessor:b="coordinates",colorBy:x,colorScheme:k="category10",curve:w="monotoneX",areaOpacity:A=.7,showLine:S=!0,lineWidth:E=2,normalize:O=!1,tooltip:M,annotations:C,frameProps:P={},selection:j,linkedHover:_,onObservation:L,chartId:N,loading:B,emptyContent:H,legendInteraction:W,legendPosition:z}=o,T=c.width,F=c.height,I=c.enableHover,$=c.showGrid,D=c.showLegend,R=c.title,G=c.xLabel,Y=c.yLabel,X=yn(B,T,F);if(X)return X;const q=fn(u,T,F,H);if(q)return q;const V=u||[],Q=function({isPushMode:e,colorBy:o,colorScheme:r,showLegend:l,legendPosition:a="right"}){const c=t(new Set),h=t([]),[u,d]=n(0),g=s(e=>{if(!o)return null;const t="function"==typeof o?o(e):e[o];return null!=t?t+"":null},[o]),f=s(t=>{if(!e||!o)return;let n=!1;for(const e of t){if(!e||"object"!=typeof e)continue;const t=g(e);null==t||c.current.has(t)||(c.current.add(t),h.current.push(t),n=!0)}n&&d(e=>e+1)},[e,o,g]),y=s(e=>t=>{f([t]),e(t)},[f]),p=s(e=>t=>{f(t),e(t)},[f]),m=s(()=>{c.current=new Set,h.current=[],d(e=>e+1)},[]),v=i(()=>{if(!e||!o||!1===l)return;const t=h.current;if(0===t.length)return;const n=Array.isArray(r)?r:le,i=new Map;for(let e=0;t.length>e;e++)i.set(t[e],n[e%n.length]);const s="string"==typeof o?o:"__streamCat";return It({data:t.map(e=>({[s]:e})),colorBy:s,colorScale:e=>i.get(e)||"#999",getColor:ae})},[e,o,l,r,u]),b=i(()=>{if(v)return"right"===a?{right:110}:"left"===a?{left:110}:"top"===a?{top:50}:"bottom"===a?{bottom:80}:{right:110}},[v,a]);return{wrapPush:y,wrapPushMany:p,resetCategories:m,streamingLegend:v,streamingMarginAdjust:b}}({isPushMode:void 0===u,colorBy:x||v,colorScheme:k,showLegend:D,legendPosition:z}),K=s(Q.wrapPush(e=>{var t;return null===(t=a.current)||void 0===t?void 0:t.push(e)}),[Q.wrapPush]),U=s(Q.wrapPushMany(e=>{var t;return null===(t=a.current)||void 0===t?void 0:t.pushMany(e)}),[Q.wrapPushMany]);h(r,()=>({push:K,pushMany:U,clear:()=>{var e;Q.resetCategories(),null===(e=a.current)||void 0===e||e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=a.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}),[K,U,Q.resetCategories]);const{activeSelectionHook:Z,customHoverBehavior:J}=Xt({selection:j,linkedHover:_,fallbackFields:x?["string"==typeof x?x:""]:[],onObservation:L,chartType:"StackedAreaChart",chartId:N}),ee=void 0!==(null===(l=V[0])||void 0===l?void 0:l[b]),te=i(()=>{if(ee)return V;if(v){const e=V.reduce((e,t)=>{const n="function"==typeof v?v(t):t[v];if(!e[n]){const t={[b]:[]};"string"==typeof v&&(t[v]=n),e[n]=t}return e[n][b].push(t),e},{});return Object.values(e)}return[{[b]:V}]},[V,v,b,ee]),ne=Yt(V,x,k),oe=i(()=>{if(!x)return[];const e=new Set;for(const t of V){const n="function"==typeof x?x(t):t[x];null!=n&&e.add(n+"")}return Array.from(e)},[V,x]),ie=Vt(W,x,oe),re=i(()=>ie.legendSelectionHook?ie.legendSelectionHook:Z,[ie.legendSelectionHook,Z]),se=i(()=>e=>{const t={};if(x&&ne){const n=ae(e,x,ne);t.fill=n,S?(t.stroke=n,t.strokeWidth=E):t.stroke="none"}else x||(t.fill=Rt,t.stroke=S?Rt:"none",S&&(t.strokeWidth=E));return t.fillOpacity=A,t},[x,ne,A,S,E]),ce=i(()=>Dt(se,re,j),[se,re,j]),{legend:he,margin:ue,legendPosition:de}=qt({data:te,colorBy:x,colorScale:ne,showLegend:D,legendPosition:z,userMargin:d,defaults:c.marginDefaults}),ge=Q.streamingLegend||he,fe=z||de,ye=i(()=>{if(Q.streamingMarginAdjust){const e=Object.assign({},ue);for(const[t,n]of Object.entries(Q.streamingMarginAdjust))n>e[t]&&(e[t]=n);return e}return ue},[ue,Q.streamingMarginAdjust]),pe=v||x,me=i(()=>ln([{label:G||nn(p),accessor:p,role:"x"},{label:Y||nn(m),accessor:m,role:"y"},...pe?[{label:nn(pe),accessor:pe,role:"group"}]:[]]),[p,m,G,Y,pe]),ve=bn({componentName:"StackedAreaChart",data:u,accessors:{xAccessor:p,yAccessor:m}});if(ve)return e.createElement(sn,{componentName:"StackedAreaChart",message:ve,width:T,height:F});const be=i(()=>ee||v?te.flatMap(e=>{const t=e[b]||[];return v&&"string"==typeof v?t.map(t=>Object.assign(Object.assign({},t),{[v]:e[v]})):t}):V,[te,b,ee,v,V]),xe=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"stackedarea"},null!=u&&{data:be}),{xAccessor:p,yAccessor:m,groupAccessor:v||void 0,curve:w,normalize:O,lineStyle:ce,size:[T,F],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:ye,showAxes:c.showAxes,xLabel:G,yLabel:Y,xFormat:f,yFormat:y,enableHover:I,showGrid:$}),ge&&{legend:ge,legendPosition:fe}),W&&"none"!==W&&{legendHoverBehavior:ie.onLegendHover,legendClickBehavior:ie.onLegendClick,legendHighlightedCategory:ie.highlightedCategory,legendIsolatedCategories:ie.isolatedCategories}),R&&{title:R}),g&&{className:g}),{tooltipContent:!1===M?()=>null:tn(M)||me}),(_||L)&&{customHoverBehavior:J}),C&&C.length>0&&{annotations:C}),P);return e.createElement(un,{componentName:"StackedAreaChart",width:T,height:F},e.createElement(St,Object.assign({ref:a},xe)))});En.displayName="StackedAreaChart";const On=c(function(n,o){const r=t(null);h(o,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const l=Kt(n.mode,{width:n.width,height:n.height,showGrid:n.showGrid,enableHover:n.enableHover,showLegend:n.showLegend,title:n.title,xLabel:n.xLabel,yLabel:n.yLabel}),{data:a,margin:c,className:u,xFormat:d,yFormat:g,xAccessor:f="x",yAccessor:y="y",colorBy:p,colorScheme:m="category10",sizeBy:v,sizeRange:b=[3,15],pointRadius:x=5,pointOpacity:k=.8,tooltip:w,marginalGraphics:A,pointIdAccessor:S,annotations:E,frameProps:O={},selection:M,linkedHover:C,linkedBrush:P,onObservation:j,chartId:_,loading:L,emptyContent:N,legendInteraction:B,legendPosition:H}=n,W=l.width,z=l.height,T=l.enableHover,F=l.showGrid,I=l.title,$=l.xLabel,D=l.yLabel,R=a||[],G=function(e){const{data:t,rawData:n,colorBy:o,colorScheme:r,legendInteraction:l,legendPosition:s,selection:a,linkedHover:c,fallbackFields:h,unwrapData:u=!1,onObservation:d,chartType:g,chartId:f,showLegend:y,userMargin:p,marginDefaults:m,loading:v,emptyContent:b,width:x,height:k}=e,{activeSelectionHook:w,customHoverBehavior:A,customClickBehavior:S}=Xt({selection:a,linkedHover:c,fallbackFields:h,unwrapData:u,onObservation:d,chartType:g,chartId:f}),E=Yt(t,o,r),O=i(()=>{if(!o)return[];const e=new Set;for(const n of t){const t="function"==typeof o?o(n):n[o];null!=t&&e.add(t+"")}return Array.from(e)},[t,o]),M=Vt(l,o,O),C=i(()=>M.legendSelectionHook?M.legendSelectionHook:w,[M.legendSelectionHook,w]),{legend:P,margin:j,legendPosition:_}=qt({data:t,colorBy:o,colorScale:E,showLegend:y,legendPosition:s,userMargin:p,defaults:m}),L=i(()=>{const e={};return P&&(e.legend=P,e.legendPosition=_),l&&"none"!==l&&(e.legendHoverBehavior=M.onLegendHover,e.legendClickBehavior=M.onLegendClick,e.legendHighlightedCategory=M.highlightedCategory,e.legendIsolatedCategories=M.isolatedCategories),e},[P,_,l,M.onLegendHover,M.onLegendClick,M.highlightedCategory,M.isolatedCategories]),N=yn(v,x,k),B=N?null:fn(n,x,k,b);return{colorScale:E,allCategories:O,legendState:M,effectiveSelectionHook:C,activeSelectionHook:w,customHoverBehavior:A,customClickBehavior:S,legend:P,margin:j,legendPosition:_,earlyReturn:N||B||null,legendBehaviorProps:L}}({data:R,rawData:a,colorBy:p,colorScheme:m,legendInteraction:B,legendPosition:H,selection:M,linkedHover:C,fallbackFields:p?["string"==typeof p?p:""]:[],unwrapData:!1,onObservation:j,chartType:"Scatterplot",chartId:_,showLegend:l.showLegend,userMargin:c,marginDefaults:l.marginDefaults,loading:L,emptyContent:N,width:W,height:z}),Y=$t(P),X=Ht({name:(null==Y?void 0:Y.name)||"__unused_brush__",xField:(null==Y?void 0:Y.xField)||("string"==typeof f?f:void 0),yField:(null==Y?void 0:Y.yField)||("string"==typeof y?y:void 0)}),q=Y?"xyBrush"===X.brushInteraction.brush?"xy":"xBrush"===X.brushInteraction.brush?"x":"y":void 0,V=e.useRef(X.brushInteraction);V.current=X.brushInteraction;const Q=s(e=>{const t=V.current;t.end(e?"xyBrush"===t.brush?[[e.x[0],e.y[0]],[e.x[1],e.y[1]]]:"xBrush"===t.brush?e.x:e.y:null)},[]);if(G.earlyReturn)return G.earlyReturn;pn("Scatterplot",R,"xAccessor",f),pn("Scatterplot",R,"yAccessor",y);const K=i(()=>{if(!v||0===R.length)return;const e=R.map(e=>"function"==typeof v?v(e):e[v]);return[Math.min(...e),Math.max(...e)]},[R,v]),U=i(()=>e=>{const t={fillOpacity:k};return p?G.colorScale&&(t.fill=ae(e,p,G.colorScale)):t.fill=Rt,t.r=v?he(e,v,b,K):x,t},[p,G.colorScale,v,b,K,x,k]),Z=i(()=>Dt(U,G.effectiveSelectionHook,M),[U,G.effectiveSelectionHook,M]),J=i(()=>ln([{label:$||nn(f),accessor:f,role:"x"},{label:D||nn(y),accessor:y,role:"y"},...p?[{label:nn(p),accessor:p,role:"color"}]:[],...v?[{label:nn(v),accessor:v,role:"size"}]:[]]),[f,y,$,D,p,v]),ee=bn({componentName:"Scatterplot",data:a,accessors:{xAccessor:f,yAccessor:y}});if(ee)return e.createElement(sn,{componentName:"Scatterplot",message:ee,width:W,height:z});const te=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter"},null!=a&&{data:R}),{xAccessor:f,yAccessor:y,colorAccessor:p||void 0,sizeAccessor:v||void 0,sizeRange:b,pointStyle:Z,colorScheme:m,size:[W,z],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:G.margin,showAxes:l.showAxes,xLabel:$,yLabel:D,xFormat:d,yFormat:g,enableHover:T,showGrid:F}),G.legendBehaviorProps),I&&{title:I}),u&&{className:u}),{tooltipContent:!1===w?()=>null:tn(w)||J}),(C||j)&&{customHoverBehavior:G.customHoverBehavior}),A&&{marginalGraphics:A}),S&&{pointIdAccessor:S}),E&&E.length>0&&{annotations:E}),Y&&{brush:{dimension:q},onBrush:Q}),O);return e.createElement(un,{componentName:"Scatterplot",width:W,height:z},e.createElement(St,Object.assign({ref:r},te)))});function Mn(e,t){return w(1===t?.5:e/(t-1))}On.displayName="Scatterplot";const Cn=c(function(n,o){const r=t(null);h(o,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const l=Kt(n.mode,{width:n.width,height:n.height,showGrid:n.showGrid,enableHover:n.enableHover,title:n.title,xLabel:n.xLabel,yLabel:n.yLabel}),{data:s,className:a,xFormat:c,yFormat:u,xAccessor:d="x",yAccessor:g="y",orderAccessor:f,orderLabel:y,pointRadius:p=4,tooltip:m,pointIdAccessor:v,annotations:b,frameProps:x={},selection:k,linkedHover:w,onObservation:A,chartId:S,loading:E,emptyContent:O,legendInteraction:M}=n,C=l.width,P=l.height,j=l.enableHover,_=l.showGrid,L=l.title,N=l.xLabel,B=l.yLabel,H=s||[],W=i(()=>{if(!f||0===H.length)return H;const e="function"==typeof f?f:e=>e[f];return[...H].sort((t,n)=>{const o=e(t),i=e(n);return(o instanceof Date?o.getTime():+o)-(i instanceof Date?i.getTime():+i)})},[H,f]);pn("ConnectedScatterplot",W,"xAccessor",d),pn("ConnectedScatterplot",W,"yAccessor",g);const{activeSelectionHook:z,customHoverBehavior:T}=Xt({selection:k,linkedHover:w,fallbackFields:[],onObservation:A,chartType:"ConnectedScatterplot",chartId:S}),F=Vt(M,void 0,[]),I=i(()=>F.legendSelectionHook?F.legendSelectionHook:z,[F.legendSelectionHook,z]),$=i(()=>(e,t)=>{var n,o;const i=t.filter(e=>"point"===e.type);if(2>i.length)return;const r=null==I?void 0:I.isActive,l=null==I?void 0:I.predicate,s=100>i.length,a=i.length;e.lineCap="round";for(let t=0;a-1>t;t++){const c=i[t],h=i[t+1],u=Mn(t,a),d=!r||!l||l(null!==(n=c.datum)&&void 0!==n?n:c)||l(null!==(o=h.datum)&&void 0!==o?o:h),g=r?d?1:.2:1;s&&(e.beginPath(),e.moveTo(c.x,c.y),e.lineTo(h.x,h.y),e.strokeStyle="white",e.lineWidth=p+2,e.globalAlpha=.5*g,e.stroke()),e.beginPath(),e.moveTo(c.x,c.y),e.lineTo(h.x,h.y),e.strokeStyle=u,e.lineWidth=p,e.globalAlpha=g,e.stroke()}e.globalAlpha=1},[p,I]),D=i(()=>[$],[$]),R=t({idx:0,total:0}),G=i(()=>{const e="function"==typeof d?d:e=>e[d],t="function"==typeof g?g:e=>e[g];return n=>{var o,i;const l=R.current;if(0===l.idx){const n=null!==(i=null===(o=r.current)||void 0===o?void 0:o.getData())&&void 0!==i?i:W;l.total=n.filter(n=>{const o=e(n),i=t(n);return null!=o&&null!=i&&isFinite(o)&&isFinite(i)}).length}const s=l.total,a=l.idx;return l.idx++,s>l.idx||(l.idx=0),{fill:s>0?Mn(a,s):"#6366f1",stroke:"white",strokeWidth:1,r:p,fillOpacity:1}}},[p,W.length,d,g]),Y=i(()=>Dt(G,I,k),[G,I,k]),X=Object.assign({top:50,right:40,bottom:60,left:70},n.margin),q=y||("string"==typeof f?f:"Order"),V=i(()=>ln([{label:N||nn(d),accessor:d,role:"x"},{label:B||nn(g),accessor:g,role:"y"},...f?[{label:q,accessor:f,role:"group"}]:[]]),[d,g,N,B,f,q]),Q=bn({componentName:"ConnectedScatterplot",data:s,accessors:{xAccessor:d,yAccessor:g}}),K=yn(E,C,P);if(K)return K;const U=fn(s,C,P,O);if(U)return U;if(Q)return e.createElement(sn,{componentName:"ConnectedScatterplot",message:Q,width:C,height:P});const Z=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter"},null!=s&&{data:W}),{xAccessor:d,yAccessor:g,pointStyle:Y,size:[C,P],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:X,showAxes:l.showAxes,xLabel:N,yLabel:B,xFormat:c,yFormat:u,enableHover:j,showGrid:_}),L&&{title:L}),a&&{className:a}),{tooltipContent:!1===m?()=>null:tn(m)||V}),(w||A)&&{customHoverBehavior:T}),v&&{pointIdAccessor:v}),{canvasPreRenderers:D}),b&&b.length>0&&{annotations:b}),x);return e.createElement(un,{componentName:"ConnectedScatterplot",width:C,height:P},e.createElement(St,Object.assign({ref:r},Z)))});Cn.displayName="ConnectedScatterplot";const Pn=c(function(n,o){const r=t(null);h(o,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const l=Kt(n.mode,{width:n.width,height:n.height,showGrid:n.showGrid,enableHover:n.enableHover,showLegend:n.showLegend,title:n.title,xLabel:n.xLabel,yLabel:n.yLabel}),{data:s,margin:a,className:c,xFormat:u,yFormat:d,xAccessor:g="x",yAccessor:f="y",sizeBy:y,sizeRange:p=[5,40],colorBy:m,colorScheme:v="category10",bubbleOpacity:b=.6,bubbleStrokeWidth:x=1,bubbleStrokeColor:k="white",tooltip:w,marginalGraphics:A,pointIdAccessor:S,annotations:E,frameProps:O={},selection:M,linkedHover:C,linkedBrush:P,onObservation:j,chartId:_,loading:L,emptyContent:N,legendInteraction:B,legendPosition:H}=n,W=l.width,z=l.height,T=l.enableHover,F=l.showGrid,I=l.showLegend,$=l.title,D=l.xLabel,R=l.yLabel,G=yn(L,W,z);if(G)return G;const Y=fn(s,W,z,N);if(Y)return Y;const X=s||[],{activeSelectionHook:q,customHoverBehavior:V}=Xt({selection:M,linkedHover:C,fallbackFields:m?["string"==typeof m?m:""]:[],onObservation:j,chartType:"BubbleChart",chartId:_}),Q=$t(P);Ht({name:(null==Q?void 0:Q.name)||"__unused_brush__",xField:(null==Q?void 0:Q.xField)||("string"==typeof g?g:void 0),yField:(null==Q?void 0:Q.yField)||("string"==typeof f?f:void 0)});const K=Yt(X,m,v),U=i(()=>{if(!m)return[];const e=new Set;for(const t of X){const n="function"==typeof m?m(t):t[m];null!=n&&e.add(n+"")}return Array.from(e)},[X,m]),Z=Vt(B,m,U),J=i(()=>Z.legendSelectionHook?Z.legendSelectionHook:q,[Z.legendSelectionHook,q]),ee=i(()=>{const e=X.map(e=>"function"==typeof y?y(e):e[y]);return[Math.min(...e),Math.max(...e)]},[X,y]),te=i(()=>e=>{const t={fillOpacity:b,strokeWidth:x,stroke:k};return m?K&&(t.fill=ae(e,m,K)):t.fill=Rt,t.r=he(e,y,p,ee),t},[m,K,y,p,ee,b,x,k]),ne=i(()=>Dt(te,J,M),[te,J,M]),{legend:oe,margin:ie,legendPosition:re}=qt({data:X,colorBy:m,colorScale:K,showLegend:I,legendPosition:H,userMargin:a,defaults:l.marginDefaults}),le=i(()=>ln([{label:D||nn(g),accessor:g,role:"x"},{label:R||nn(f),accessor:f,role:"y"},{label:nn(y),accessor:y,role:"size"},...m?[{label:nn(m),accessor:m,role:"color"}]:[]]),[g,f,D,R,y,m]),se=bn({componentName:"BubbleChart",data:s,accessors:{xAccessor:g,yAccessor:f},requiredProps:{sizeBy:y}});if(se)return e.createElement(sn,{componentName:"BubbleChart",message:se,width:W,height:z});const ce=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bubble"},null!=s&&{data:X}),{xAccessor:g,yAccessor:f,colorAccessor:m||void 0,sizeAccessor:y,sizeRange:p,pointStyle:ne,colorScheme:v,size:[W,z],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:ie,showAxes:l.showAxes,xLabel:D,yLabel:R,xFormat:u,yFormat:d,enableHover:T,showGrid:F}),oe&&{legend:oe,legendPosition:re}),B&&"none"!==B&&{legendHoverBehavior:Z.onLegendHover,legendClickBehavior:Z.onLegendClick,legendHighlightedCategory:Z.highlightedCategory,legendIsolatedCategories:Z.isolatedCategories}),$&&{title:$}),c&&{className:c}),{tooltipContent:!1===w?()=>null:tn(w)||le}),(C||j)&&{customHoverBehavior:V}),A&&{marginalGraphics:A}),S&&{pointIdAccessor:S}),E&&E.length>0&&{annotations:E}),O);return e.createElement(un,{componentName:"BubbleChart",width:W,height:z},e.createElement(St,Object.assign({ref:r},ce)))});Pn.displayName="BubbleChart";const jn=c(function(n,o){const r=t(null);h(o,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const l=Kt(n.mode,{width:n.width,height:n.height,showGrid:void 0,enableHover:n.enableHover,showLegend:void 0,title:n.title,xLabel:n.xLabel,yLabel:n.yLabel}),{data:s,margin:a,className:c,xAccessor:u="x",yAccessor:d="y",valueAccessor:g="value",xFormat:f,yFormat:y,colorScheme:p="blues",customColorScale:m,showValues:b=!1,valueFormat:x,cellBorderColor:k="#fff",cellBorderWidth:A=1,tooltip:S,annotations:C,frameProps:P={},selection:j,linkedHover:_,onObservation:L,chartId:N,loading:B,emptyContent:H,showLegend:W,legendPosition:z,legendInteraction:T}=n,F=l.width,I=l.height,$=l.enableHover,D=l.title,R=l.xLabel,G=l.yLabel,Y=yn(B,F,I);if(Y)return Y;const X=fn(s,F,I,H);if(X)return X;const q=s||[],V=null!=W&&W,Q=null!=z?z:"right",{margin:K}=qt({data:q,colorBy:V?"value":void 0,colorScale:void 0,showLegend:V,legendPosition:Q,userMargin:a,defaults:l.marginDefaults}),{activeSelectionHook:U,customHoverBehavior:Z}=Xt({selection:j,linkedHover:_,fallbackFields:[],onObservation:L,chartType:"Heatmap",chartId:N}),J=Vt(T,void 0,[]),ee=i(()=>J.legendSelectionHook?J.legendSelectionHook:U,[J.legendSelectionHook,U]),te=i(()=>"function"==typeof g?e=>g(e):e=>e[g],[g]),ne=i(()=>{const e=q.map(te);return[Math.min(...e),Math.max(...e)]},[q,te]),oe=i(()=>"custom"===p&&m?m:v({blues:M,reds:O,greens:E,viridis:w}[p]||M).domain(ne),[p,m,ne]);i(()=>{const e=Gt(u),t=Gt(d);return{xBinCount:new Set(q.map(e)).size,yBinCount:new Set(q.map(t)).size}},[q,u,d]),i(()=>({coordinates:q}),[q]);const ie=i(()=>e=>{const t=te(e);return{fill:oe(t),stroke:k,strokeWidth:A}},[te,oe,k,A]);i(()=>Dt(ie,ee,j),[ie,ee,j]);const re=i(()=>ln([{label:R||nn(u),accessor:u,role:"x"},{label:G||nn(d),accessor:d,role:"y"},{label:nn(g),accessor:g,role:"value"}]),[u,d,R,G,g]),le=bn({componentName:"Heatmap",data:s,accessors:{xAccessor:u,yAccessor:d,valueAccessor:g}});if(le)return e.createElement(sn,{componentName:"Heatmap",message:le,width:F,height:I});const se=i(()=>{if(V)return{gradient:{colorFn:e=>oe(e),domain:ne,label:"string"==typeof g?g:"value",format:x}}},[V,oe,ne,g,x]),ae=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"heatmap"},null!=s&&{data:q}),{xAccessor:u,yAccessor:d,valueAccessor:g,colorScheme:"custom"!==p?p:void 0,showValues:b,heatmapValueFormat:x,size:[F,I],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:K,showAxes:l.showAxes,xLabel:R,yLabel:G,xFormat:f,yFormat:y,enableHover:$}),se&&{legend:se,legendPosition:Q}),D&&{title:D}),c&&{className:c}),{tooltipContent:!1===S?()=>null:tn(S)||re}),(_||L)&&{customHoverBehavior:Z}),C&&C.length>0&&{annotations:C}),P);return e.createElement(un,{componentName:"Heatmap",width:F,height:I},e.createElement(St,Object.assign({ref:r},ae)))});jn.displayName="Heatmap";const _n="__splomIdx",Ln={top:4,bottom:4,left:4,right:4};function Nn({frameRef:n,cellSize:i,onBrush:r}){const l=t(null),s=i-Ln.left-Ln.right,a=i-Ln.top-Ln.bottom;return o(()=>{if(!l.current)return;const e=y(l.current).select(".brush-g"),t=f().extent([[0,0],[s,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 r(null);const[[i,l],[s,a]]=e.selection,c=[[o.x.invert(i),o.y.invert(l)],[o.x.invert(s),o.y.invert(a)]];r(c)});return e.call(t),e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{t.on("brush end",null)}},[s,a,n,r]),e.createElement("svg",{ref:l,width:i,height:i,style:{position:"absolute",top:0,left:0}},e.createElement("g",{className:"brush-g",transform:`translate(${Ln.left},${Ln.top})`}))}function Bn({data:n,xField:o,yField:i,cellSize:r,pointRadius:l,pointOpacity:a,colorBy:c,colorScale:h,brushSelectionName:u,hoverSelectionName:d,unselectedOpacity:g,mode:f,onPointHover:y}){const p=t(null),m=Nt({name:u,clientId:`splom-${o}-${i}`}),v=Ht({name:u,xField:o,yField:i}),b=Nt({name:d,clientId:"splom-hover-source"}),x=b.selectPoints,k=s(e=>{e?v.brushInteraction.during(e):v.brushInteraction.end(null)},[v.brushInteraction]),w=s(e=>{if(!e)return void(null==y||y(null));const t=e.data,n=null==t?void 0:t[_n];void 0!==n&&(x({[_n]:[n]}),null==y||y(t,e.x+Ln.left,e.y+Ln.top))},[x,y]),A=s(e=>{const t={opacity:a,r:l};return t.fill=c?ae(e,c,h):Rt,"hover"===f?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=g),t},[c,h,a,l,f,m.isActive,m.predicate,b.isActive,b.predicate,g]);return e.createElement("div",{style:{position:"relative",width:r,height:r}},e.createElement(St,{ref:p,chartType:"scatter",data:n,size:[r,r],xAccessor:o,yAccessor:i,pointStyle:A,margin:Ln,showAxes:!1,enableHover:"hover"===f,customHoverBehavior:"hover"===f?w:void 0,tooltipContent:"hover"===f?()=>null:void 0}),"brush"===f&&e.createElement(Nn,{frameRef:p,cellSize:r,xField:o,yField:i,onBrush:k}))}function Hn({data:t,field:n,label:o,cellSize:r,bins:l,colorBy:s,colorScale:a,brushSelectionName:c,hoverSelectionName:h,mode:u}){const d=Nt({name:c,clientId:"splom-diag-"+n}),g=Nt({name:h,clientId:`splom-diag-${n}-hover`}),f="hover"===u?g:d,y=f.isActive,p=f.predicate,m=i(()=>{const e=t.map(e=>e[n]).filter(e=>null!=e&&!isNaN(e));if(0===e.length)return{bars:[],selectedBars:[],categoryBars:[],selectedCategoryBars:[],max:0,categories:[]};const o=Math.min(...e),i=(Math.max(...e)-o)/l||1,a="string"==typeof s?s:null,c=a?[...new Set(t.map(e=>e[a]).filter(e=>null!=e).map(String))]:[],h=new Map(c.map((e,t)=>[e,t])),u=Array(l).fill(0),d=Array(l).fill(0),g=Array.from({length:l},()=>Array(c.length).fill(0)),f=Array.from({length:l},()=>Array(c.length).fill(0));for(const e of t){const t=e[n];if(null==t||isNaN(t))continue;const r=Math.min(Math.floor((t-o)/i),l-1);if(u[r]++,y&&!p(e)||d[r]++,a){const t=h.get(e[a]+"");void 0!==t&&(g[r][t]++,y&&!p(e)||f[r][t]++)}}const m=Math.max(...u,1),v=g.map((e,t)=>{let n=0;return e.map((e,o)=>{const i=e/m*(r-24),s={x:t/l*r,w:r/l-1,h:i,y0:n,category:c[o]};return n+=i,s})}),b=f.map((e,t)=>{let n=0;return e.map((e,o)=>{const i=e/m*(r-24),s={x:t/l*r,w:r/l-1,h:i,y0:n,category:c[o]};return n+=i,s})});return{bars:u.map((e,t)=>({x:t/l*r,w:r/l-1,h:e/m*(r-24),count:e})),selectedBars:d.map((e,t)=>({x:t/l*r,w:r/l-1,h:e/m*(r-24),count:e})),categoryBars:v,selectedCategoryBars:b,max:m,categories:c}},[t,n,l,r,y,p,s]);return e.createElement("svg",{width:r,height:r,style:{overflow:"hidden"}},e.createElement("text",{x:r/2,y:14,textAnchor:"middle",fontSize:11,fontWeight:"bold",fill:"#333"},o),m.categories.length>0?m.categoryBars.map((t,n)=>t.map((t,o)=>e.createElement("rect",{key:`bg-${n}-${o}`,x:t.x,y:r-t.y0-t.h,width:Math.max(t.w,1),height:t.h,fill:a?a(t.category):Rt,opacity:y?.3:.6}))):m.bars.map((t,n)=>e.createElement("rect",{key:"bg-"+n,x:t.x,y:r-t.h,width:Math.max(t.w,1),height:t.h,fill:Rt,opacity:y?.3:.6})),y&&(m.categories.length>0?m.selectedCategoryBars.map((t,n)=>t.map((t,o)=>e.createElement("rect",{key:`sel-${n}-${o}`,x:t.x,y:r-t.y0-t.h,width:Math.max(t.w,1),height:t.h,fill:a?a(t.category):Rt,opacity:.7}))):m.selectedBars.map((t,n)=>e.createElement("rect",{key:"sel-"+n,x:t.x,y:r-t.h,width:Math.max(t.w,1),height:t.h,fill:Rt,opacity:.7}))))}function Wn({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 zn(t){const{data:o,fields:r,fieldLabels:l={},colorBy:a,colorScheme:c="category10",cellSize:h=150,cellGap:u=4,pointRadius:d=2,pointOpacity:g=.5,diagonal:f="histogram",histogramBins:y=20,brushMode:p="crossfilter",hoverMode:m=!0,unselectedOpacity:v=.1,showGrid:b=!1,tooltip:x,showLegend:k,idAccessor:w,className:A,onObservation:S,chartId:E}=t,O="splom",M="splom-hover",C=m?"hover":p?"brush":"hover",P=jt(e=>e.clearSelection),[j,_]=n(null),L=s(()=>{P(M),_(null)},[P,M]),N=i(()=>(o||[]).map((e,t)=>void 0!==e[_n]?e:Object.assign(Object.assign({},e),{[_n]:t})),[o]),B=Yt(N,a,c),H=void 0!==k?k:!!a,W=i(()=>{if(!H||!a)return null;const e="string"==typeof a?a:null;return e?[...new Set(N.map(t=>t[e]))].map(e=>({label:e+"",color:B?B(e+""):Rt})):null},[H,a,N,B]),z=i(()=>({display:"grid",gridTemplateColumns:"40px "+r.map(()=>h+"px").join(" "),gridTemplateRows:r.map(()=>h+"px").join(" ")+" 40px",gap:u+"px",width:"fit-content"}),[r,h,u,40]);return e.createElement("div",{className:A,style:{position:"relative"}},W&&e.createElement("div",{style:{display:"flex",gap:12,marginBottom:8,flexWrap:"wrap"}},W.map(t=>e.createElement("div",{key:t.label,style:{display:"flex",alignItems:"center",gap:4}},e.createElement("span",{style:{display:"inline-block",width:10,height:10,borderRadius:"50%",backgroundColor:t.color}}),e.createElement("span",{style:{fontSize:11}},t.label)))),e.createElement("div",{style:z,onMouseLeave:"hover"===C?L:void 0},r.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),r.map((o,i)=>n===i?"label"===f?e.createElement(Wn,{key:"diag-"+t,label:l[t]||t,cellSize:h}):e.createElement(Hn,{key:"diag-"+t,data:N,field:t,label:l[t]||t,cellSize:h,bins:y,colorBy:a,colorScale:B,brushSelectionName:O,hoverSelectionName:M,unselectedOpacity:v,mode:C}):e.createElement(Bn,{key:`cell-${t}-${o}`,data:N,xField:o,yField:t,fieldLabels:l,cellSize:h,pointRadius:d,pointOpacity:g,colorBy:a,colorScale:B,brushSelectionName:O,hoverSelectionName:M,unselectedOpacity:v,showGrid:b,tooltip:x,mode:C,onPointHover:"hover"===C?(e,r,l)=>{e?(_({datum:e,xField:o,yField:t,colIndex:i,rowIndex:n,px:null!=r?r:0,py:null!=l?l:0}),S&&S({type:"hover",datum:e,x:null!=r?r:0,y:null!=l?l:0,timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:E})):(_(null),S&&S({type:"hover-end",timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:E}))}:void 0})))),e.createElement("div",null)," ",r.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))),j&&"hover"===C&&(()=>{const t=j.datum,n=l[j.xField]||j.xField,o=l[j.yField]||j.yField,i=a?"function"==typeof a?a(t):t[a]:null,r=w?"function"==typeof w?w(t):t[w]:"Row "+t[_n];return e.createElement("div",{style:{position:"absolute",left:40+j.colIndex*(h+u)+j.px,top:j.rowIndex*(h+u)+j.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}},r+""),e.createElement("div",null,n,": ",null!=t[j.xField]?Number(t[j.xField]).toFixed(1):"–"),e.createElement("div",null,o,": ",null!=t[j.yField]?Number(t[j.yField]).toFixed(1):"–"),null!=i&&e.createElement("div",{style:{opacity:.8}},"string"==typeof a?a:"group",": ",i+""))})())}function Tn(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(Ft,{selections:i},e.createElement(zn,Object.assign({},t)))}function Fn({width:n,height:i,margin:r,scales:l,brushDirection:s,extent:a,onBrush:c}){const h=t(null),u=t(null),f=t(!1),p=n+r.left+r.right,m=i+r.top+r.bottom;return o(()=>{if(!h.current||!l)return;const e=y(h.current).select(".brush-group"),t="x"===s?d().extent([[0,0],[n,i]]):g().extent([[0,0],[n,i]]);return t.on("brush end",e=>{if(f.current)return;if(!e.sourceEvent)return;const t=e.selection;if(!t)return void c(null);const n=("x"===s?l.x:l.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)}},[l,n,i,s,c]),o(()=>{if(!u.current||!l||!h.current)return;const e=y(h.current).select(".brush-group"),t="x"===s?l.x:l.y;if(f.current=!0,a){const n=[t(a[0]),t(a[1])];e.call(u.current.move,n)}else e.call(u.current.move,null);f.current=!1},[a,l,s]),e.createElement("svg",{ref:h,width:p,height:m,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},e.createElement("g",{className:"brush-group",transform:`translate(${r.left},${r.top})`}))}function In(r){var l,a;const{data:c,width:h=600,height:u=400,margin:d,className:g,title:f,xLabel:y,yLabel:p,xFormat:m,yFormat:v,xAccessor:b="x",yAccessor:x="y",lineBy:k,lineDataAccessor:w="coordinates",colorBy:A,colorScheme:S="category10",curve:E="linear",lineWidth:O=2,fillArea:M=!1,areaOpacity:C=.3,showPoints:P=!1,pointRadius:j=3,enableHover:_=!0,showGrid:L=!1,showLegend:N,legendPosition:B,tooltip:H,minimap:W={},renderBefore:z=!1,onBrush:T,brushExtent:F,frameProps:I={},loading:$,emptyContent:D}=r,R=yn($,h,u);if(R)return R;const G=fn(c,h,u,D);if(G)return G;const Y=c||[],[X,q]=n(null),V=null!=F?F:X,Q=s(e=>{F||q(e),null==T||T(e)},[F,T]),K=t(null),[U,Z]=n(null);o(()=>{const e=()=>{var t,n;const o=null===(n=null===(t=K.current)||void 0===t?void 0:t.getScales)||void 0===n?void 0:n.call(t);o?Z(o):requestAnimationFrame(e)};requestAnimationFrame(e)},[c]);const J=void 0!==(null===(l=Y[0])||void 0===l?void 0:l[w]),ee=i(()=>{if(J)return Y;if(k){const e=Y.reduce((e,t)=>{const n="function"==typeof k?k(t):t[k];if(!e[n]){const t={[w]:[]};"string"==typeof k&&(t[k]=n),e[n]=t}return e[n][w].push(t),e},{});return Object.values(e)}return[{[w]:Y}]},[Y,k,w,J]),te=i(()=>J||k?ee.flatMap(e=>{const t=e[w]||[];return k&&"string"==typeof k?t.map(t=>Object.assign(Object.assign({},t),{[k]:e[k]})):t}):Y,[ee,w,J,k,Y]),ne=Yt(Y,A,S),oe=i(()=>e=>{const t={strokeWidth:O};return t.stroke=A?ae(e,A,ne):Rt,M&&(t.fill=t.stroke,t.fillOpacity=C),t},[A,ne,O,M,C]),ie=i(()=>W.lineStyle?W.lineStyle:e=>{const t={strokeWidth:1};return t.stroke=A?ae(e,A,ne):Rt,t},[A,ne,W.lineStyle]),re=i(()=>{if(P)return e=>{const t={r:j,fillOpacity:1};return t.fill=A?ae(e.parentLine||e,A,ne):Rt,t}},[P,j,A,ne]),{legend:le,margin:se,legendPosition:ce}=qt({data:ee,colorBy:A,colorScale:ne,showLegend:N,legendPosition:B,userMargin:d}),he=W.height||60,ue=i(()=>{var e,t,n,o,i,r,l,s;return{top:null!==(t=null===(e=W.margin)||void 0===e?void 0:e.top)&&void 0!==t?t:0,bottom:null!==(o=null===(n=W.margin)||void 0===n?void 0:n.bottom)&&void 0!==o?o:20,left:null!==(r=null===(i=W.margin)||void 0===i?void 0:i.left)&&void 0!==r?r:se.left,right:null!==(s=null===(l=W.margin)||void 0===l?void 0:l.right)&&void 0!==s?s:se.right}},[W.margin,se]),de=W.brushDirection||"x",ge=bn({componentName:"MinimapChart",data:c,accessors:{xAccessor:b,yAccessor:x}});if(ge)return e.createElement(sn,{componentName:"MinimapChart",message:ge,width:h,height:u});const fe=M?"area":"line",ye=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:fe,data:te,xAccessor:b,yAccessor:x,groupAccessor:k||void 0,curve:E,lineStyle:oe},P&&{pointStyle:re}),{size:[h,u],responsiveWidth:r.responsiveWidth,responsiveHeight:r.responsiveHeight,margin:se,showAxes:!0,xLabel:y,yLabel:p,xFormat:m,yFormat:v,enableHover:_,showGrid:L}),le&&{legend:le,legendPosition:ce}),f&&{title:f}),H&&{tooltipContent:tn(H)||void 0}),V&&{xExtent:V}),I),pe={chartType:fe,data:te,xAccessor:b,yAccessor:x,groupAccessor:k||void 0,curve:E,lineStyle:ie,size:[h,he+ue.top+ue.bottom],margin:ue,showAxes:null!==(a=W.showAxes)&&void 0!==a&&a,background:W.background,enableHover:!1},me=e.createElement("div",{key:"minimap",style:{position:"relative",width:h,overflow:"hidden"}},e.createElement(St,Object.assign({ref:K},pe)),e.createElement(Fn,{width:h-ue.left-ue.right,height:he,margin:ue,scales:U,brushDirection:de,extent:V,onBrush:Q})),ve=e.createElement("div",{key:"main",style:{overflow:"hidden"}},e.createElement(St,Object.assign({},ye)));return e.createElement(un,{componentName:"MinimapChart",width:h,height:u},e.createElement("div",{className:"minimap-chart"+(g?" "+g:"")},z?me:ve,z?ve:me))}Tn.displayName="ScatterplotMatrix",In.displayName="MinimapChart";const $n=c(function(n,o){const r=t(null);h(o,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const l=Kt(n.mode,{width:n.width,height:n.height,showGrid:n.showGrid,enableHover:n.enableHover,showLegend:n.showLegend,title:n.title,xLabel:n.xLabel,yLabel:n.yLabel}),{data:s,margin:a,className:c,xFormat:u,yFormat:d,xAccessor:g="x",yAccessor:f="y",xCenter:y,yCenter:p,quadrants:m,centerlineStyle:v={},showQuadrantLabels:b=!0,quadrantLabelSize:x=12,colorBy:k,colorScheme:w="category10",sizeBy:A,sizeRange:S=[3,15],pointRadius:E=5,pointOpacity:O=.8,tooltip:M,pointIdAccessor:C,annotations:P,frameProps:j={},selection:_,linkedHover:L,onObservation:N,chartId:B,loading:H,emptyContent:W,legendInteraction:z,legendPosition:T}=n,F=l.width,I=l.height,$=l.enableHover,D=l.showGrid,R=l.showLegend,G=l.title,Y=l.xLabel,X=l.yLabel,q=yn(H,F,I);if(q)return q;const V=fn(s,F,I,W);if(V)return V;const Q=s||[];pn("QuadrantChart",Q,"xAccessor",g),pn("QuadrantChart",Q,"yAccessor",f);const{activeSelectionHook:K,customHoverBehavior:U}=Xt({selection:_,linkedHover:L,fallbackFields:"string"==typeof k?[k]:[],onObservation:N,chartType:"QuadrantChart",chartId:B}),Z=Yt(Q,k,w),J=i(()=>{if(!k)return[];const e=new Set;for(const t of Q){const n="function"==typeof k?k(t):t[k];null!=n&&e.add(n+"")}return Array.from(e)},[Q,k]),ee=Vt(z,k,J),te=i(()=>ee.legendSelectionHook?ee.legendSelectionHook:K,[ee.legendSelectionHook,K]),ne=i(()=>{if(!Q.length)return;const e="function"==typeof g?g:e=>+e[g],t="function"==typeof f?f:e=>+e[f];let n=1/0,o=-1/0,i=1/0,r=-1/0;for(const l of Q){const s=e(l),a=t(l);isFinite(s)&&(n>s&&(n=s),s>o&&(o=s)),isFinite(a)&&(i>a&&(i=a),a>r&&(r=a))}if(null!=y&&isFinite(y)&&(n>y&&(n=y),y>o&&(o=y)),null!=p&&isFinite(p)&&(i>p&&(i=p),p>r&&(r=p)),n===1/0)return;const l=.1*(o-n)||1,s=.1*(r-i)||1;return{xExtent:[n-l,o+l],yExtent:[i-s,r+s]}},[Q,g,f,y,p]),oe=i(()=>{if(!A||0===Q.length)return;const e=Q.map(e=>"function"==typeof A?A(e):e[A]).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0!==e.length?[Math.min(...e),Math.max(...e)]:void 0},[Q,A]),ie=i(()=>"function"==typeof g?g:e=>+e[g],[g]),re=i(()=>"function"==typeof f?f:e=>+e[f],[f]),le=i(()=>e=>{const t={fillOpacity:O};if(k)Z&&(t.fill=ae(e,k,Z));else{const n=ie(e),o=re(e),i=null!=y?n>=y:void 0,r=null!=p?o>=p:void 0;t.fill=void 0===r||void 0===i?Rt:r&&i?m.topRight.color:r&&!i?m.topLeft.color:!r&&i?m.bottomRight.color:m.bottomLeft.color}return t.r=A?he(e,A,S,oe):E,t},[k,Z,A,S,oe,E,O,ie,re,y,p,m]),se=i(()=>Dt(le,te,_),[le,te,_]),{legend:ce,margin:ue,legendPosition:de}=qt({data:Q,colorBy:k,colorScale:Z,showLegend:R,legendPosition:T,userMargin:a,defaults:l.marginDefaults}),ge=i(()=>{if(!Q.length)return;const e=new Set;"string"==typeof g&&e.add(g),"string"==typeof f&&e.add(f),"string"==typeof k&&e.add(k),"string"==typeof A&&e.add(A);const t=Q[0];for(const n of Object.keys(t))if(!n.startsWith("_")&&!e.has(n)&&"string"==typeof t[n])return n},[Q,g,f,k,A]),fe=i(()=>ln([...ge?[{label:ge,accessor:ge,role:"title"}]:[],{label:Y||nn(g),accessor:g,role:"x"},{label:X||nn(f),accessor:f,role:"y"},...k?[{label:nn(k),accessor:k,role:"color"}]:[],...A?[{label:nn(A),accessor:A,role:"size"}]:[]]),[ge,g,f,Y,X,k,A]),ye=bn({componentName:"QuadrantChart",data:s,accessors:{xAccessor:g,yAccessor:f}});if(ye)return e.createElement(sn,{componentName:"QuadrantChart",message:ye,width:F,height:I});const pe=i(()=>{var e;const t={stroke:v.stroke||"#999",strokeWidth:null!==(e=v.strokeWidth)&&void 0!==e?e:1,dashArray:v.strokeDasharray||[]};return[(e,n,o,i)=>{var r;if(!(null==o?void 0:o.x)||!(null==o?void 0:o.y))return;const l=i.width,s=i.height,a=null!=y?o.x(y):l/2,c=null!=p?o.y(p):s/2;if(null!=y&&!isFinite(a))return;if(null!=p&&!isFinite(c))return;const h=Math.max(0,Math.min(l,a)),u=Math.max(0,Math.min(s,c)),d=[{config:m.topLeft,x:0,y:0,w:h,h:u},{config:m.topRight,x:h,y:0,w:l-h,h:u},{config:m.bottomLeft,x:0,y:u,w:h,h:s-u},{config:m.bottomRight,x:h,y:u,w:l-h,h:s-u}];for(const t of d)t.w>0&&t.h>0&&(e.fillStyle=t.config.color,e.globalAlpha=null!==(r=t.config.opacity)&&void 0!==r?r:.08,e.fillRect(t.x,t.y,t.w,t.h));e.globalAlpha=1,e.strokeStyle=t.stroke,e.lineWidth=t.strokeWidth,t.dashArray.length>0&&e.setLineDash(t.dashArray),e.beginPath(),e.moveTo(h,0),e.lineTo(h,s),e.stroke(),e.beginPath(),e.moveTo(0,u),e.lineTo(l,u),e.stroke(),e.setLineDash([])}]},[y,p,m,v]),me=i(()=>b?[...pe,(e,t,n,o)=>{if(!(null==n?void 0:n.x)||!(null==n?void 0:n.y))return;const i=o.width,r=o.height,l=null!=y?n.x(y):i/2,s=null!=p?n.y(p):r/2;(null==y||isFinite(l))&&(null==p||isFinite(s))&&(e.font=`600 ${x}px sans-serif`,e.globalAlpha=.5,e.fillStyle=m.topLeft.color,e.textAlign="left",e.textBaseline="top",e.fillText(m.topLeft.label,8,8),e.fillStyle=m.topRight.color,e.textAlign="right",e.textBaseline="top",e.fillText(m.topRight.label,i-8,8),e.fillStyle=m.bottomLeft.color,e.textAlign="left",e.textBaseline="bottom",e.fillText(m.bottomLeft.label,8,r-8),e.fillStyle=m.bottomRight.color,e.textAlign="right",e.textBaseline="bottom",e.fillText(m.bottomRight.label,i-8,r-8),e.globalAlpha=1)}]:pe,[pe,b,x,m,y,p]),ve=i(()=>{const e=j.canvasPreRenderers||[];return[...me,...e]},[me,j.canvasPreRenderers]),be=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter"},null!=s&&{data:Q}),{xAccessor:g,yAccessor:f,colorAccessor:k||void 0,sizeAccessor:A||void 0,sizeRange:S,pointStyle:se,colorScheme:w,size:[F,I],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:ue,showAxes:l.showAxes,xLabel:Y,yLabel:X,xFormat:u,yFormat:d,enableHover:$,showGrid:D}),ne&&{xExtent:ne.xExtent,yExtent:ne.yExtent}),ce&&{legend:ce,legendPosition:de}),z&&"none"!==z&&{legendHoverBehavior:ee.onLegendHover,legendClickBehavior:ee.onLegendClick,legendHighlightedCategory:ee.highlightedCategory,legendIsolatedCategories:ee.isolatedCategories}),G&&{title:G}),c&&{className:c}),{tooltipContent:!1===M?()=>null:!0===M||void 0===M?fe:tn(M)||fe}),(L||N)&&{customHoverBehavior:U}),C&&{pointIdAccessor:C}),P&&P.length>0&&{annotations:P}),{canvasPreRenderers:ve}),j),ve.length>0&&{canvasPreRenderers:ve});return e.createElement(un,{componentName:"QuadrantChart",width:F,height:I},e.createElement(St,Object.assign({ref:r},be)))});$n.displayName="QuadrantChart";export{Sn as AreaChart,Pn as BubbleChart,Cn as ConnectedScatterplot,jn as Heatmap,An as LineChart,In as MinimapChart,$n as QuadrantChart,On as Scatterplot,Tn as ScatterplotMatrix,En as StackedAreaChart,St as StreamXYFrame};
|
|
1
|
+
import*as e from"react";import{useRef as t,useState as n,useEffect as o,useMemo as r,createContext as i,useContext as s,useCallback as a,useSyncExternalStore as l,forwardRef as c,useImperativeHandle as u,useId as h}from"react";import{brushX as d,brushY as g,brush as p}from"d3-brush";import{select as y}from"d3-selection";import{scaleOrdinal as f,scaleLinear as m,scaleSequential as v,scaleLog as b}from"d3-scale";import{schemeCategory10 as x,interpolatePlasma as k,interpolateViridis as w,interpolatePurples as A,interpolateOranges as S,interpolateGreens as O,interpolateReds as E,interpolateBlues as j,schemeSet3 as C,schemeTableau10 as M}from"d3-scale-chromatic";import{quadtree as P}from"d3-quadtree";import{bin as _}from"d3-array";import{packEnclose as L}from"d3-hierarchy";import{area as B,curveCatmullRom as N,curveCardinal as H,curveBasis as z,curveStepBefore as $,curveStepAfter as W,curveStep as T,curveMonotoneY as I,curveMonotoneX as F,curveLinear as D,line as R,curveNatural as G}from"d3-shape";import Y from"regression";class q{constructor(e,t){var n,o;this.lastBoundedData=null,this.chunkTimer=0,this.pushBuffer=[],this.flushScheduled=!1,this.callback=e,this.chunkThreshold=null!==(n=null==t?void 0:t.chunkThreshold)&&void 0!==n?n:5e3,this.chunkSize=null!==(o=null==t?void 0:t.chunkSize)&&void 0!==o?o:5e3}updateChunkOptions(e){null!=e.chunkThreshold&&(this.chunkThreshold=e.chunkThreshold),null!=e.chunkSize&&(this.chunkSize=e.chunkSize)}clearLastData(){this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(e){if(this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.chunkThreshold>=e.length)return void this.callback({inserts:e,bounded:!0});this.callback({inserts:e.slice(0,this.chunkSize),bounded:!0,totalSize:e.length});let t=this.chunkSize;const n=()=>{if(t>=e.length)return;if(e!==this.lastBoundedData)return;const o=Math.min(t+this.chunkSize,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)}flushPushBuffer(){if(this.flushScheduled=!1,0===this.pushBuffer.length)return;const e=this.pushBuffer;this.pushBuffer=[],this.callback({inserts:e,bounded:!1})}scheduleFlush(){this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flushPushBuffer()))}push(e){this.pushBuffer.push(e),this.scheduleFlush()}pushMany(e){if(0!==e.length){for(let t=0;e.length>t;t++)this.pushBuffer.push(e[t]);this.scheduleFlush()}}flush(){this.flushPushBuffer()}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1}}class X{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}}}forEach(e){const t=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)e(this.buffer[(t+n)%this._capacity],n)}toArray(){const e=Array(this._size),t=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)e[n]=this.buffer[(t+n)%this._capacity];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 V{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 Q(e,t,n,o,r){const i=new Map;for(const s of e){const e=t(s),a=n(s);if(null==e||null==a||Number.isNaN(e)||Number.isNaN(a))continue;const l=Math.floor(e/o)*o;let c=i.get(l);if(c||(c={start:l,end:l+o,total:0,categories:new Map},i.set(l,c)),c.total+=a,r){const e=r(s);c.categories.set(e,(c.categories.get(e)||0)+a)}}return i}function K(e,t,n,o,r,i){const s=[];for(const r of e){const e=n(r),i=o(r);null==e||null==i||Number.isNaN(e)||Number.isNaN(i)||s.push({px:t.x(e),py:t.y(i),rawY:i,d:r})}s.sort((e,t)=>e.px-t.px);const a=Array(s.length),l=Array(s.length),c=Array(s.length);for(let e=0;s.length>e;e++){const t=s[e];a[e]=[t.px,t.py],l[e]=t.rawY,c[e]=t.d}return{type:"line",path:a,rawValues:l,style:r,datum:c,group:i}}function U(e,t,n,o,r,i,s,a){const l=[];for(const i of e){const e=n(i),s=o(i);if(null==e||null==s||Number.isNaN(e)||Number.isNaN(s))continue;const c=t.x(e),u=a?a(i):r;l.push({px:c,topY:t.y(s),botY:t.y(u)})}l.sort((e,t)=>e.px-t.px);const c=Array(l.length),u=Array(l.length);for(let e=0;l.length>e;e++){const t=l[e];c[e]=[t.px,t.topY],u[e]=[t.px,t.botY]}return{type:"area",topPath:c,bottomPath:u,style:i,datum:e,group:s}}function Z(e,t,n,o,r,i,s){const a=n(e),l=o(e);if(null==a||null==l||Number.isNaN(a)||Number.isNaN(l))return null;const c={type:"point",x:t.x(a),y:t.y(l),r:r,style:i,datum:e};return void 0!==s&&(c.pointId=s),c}function J(e,t,n,o,r,i,s){return{type:"rect",x:e,y:t,w:n,h:o,style:r,datum:i,group:s}}function ee(e,t,n,o,r,i,s){const a={type:"heatcell",x:e,y:t,w:n,h:o,fill:r,datum:i};return(null==s?void 0:s.showValues)&&(a.showValues=!0,a.value=s.value,s.valueFormat&&(a.valueFormat=s.valueFormat)),a}function te(e,t){if("function"==typeof e)return t=>+e(t);const n=e||t;return e=>+e[n]}function ne(e,t){if("function"==typeof e)return e;const n=e||t;return e=>e[n]}function oe(e,t){return"function"==typeof e?e:e?t=>t[e]+"":void 0}const re={category10:x,tableau10:M,set3:C,blues:j,reds:E,greens:O,oranges:S,purples:A,viridis:w,plasma:k},ie=x,se=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],ae=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);function le(e,t,n){if("function"==typeof t){const o=t(e);return n&&o&&"string"==typeof o&&!function(e){const t=e.toLowerCase();return t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||ae.has(t)}(o)?n(o):o}const o=e[t];return n?n(o):ie[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+""))%ie.length]}function ce(e,t,n="category10"){const o=Array.from(new Set(e.map(e=>null==e?void 0:e[t]).filter(e=>null!=e))),r=o.every(e=>"number"==typeof e||!isNaN(Number(e)));if(Array.isArray(n))return f().domain(o).range(n).unknown("#999");const i=re[n]||re.category10;if(r&&"function"==typeof i){let e=-1/0;for(const t of o){const n=Number(t);n>e&&(e=n)}return t=>i(Number(t)/e)}{const e=Array.isArray(i)?i:ie;return f().domain(o).range(e).unknown("#999")}}function ue(e,t,n=[3,20],o){let r;if(r="function"==typeof t?t(e):e[t],!o)return r;const[i,s]=o,[a,l]=n;return s===i?(a+l)/2:a+(r-i)/(s-i)*(l-a)}function he(e,t,n){return e+(t-e)*n}class de{constructor(e){this.xExtent=new V,this.yExtent=new V,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.prevPathMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupColorMap=new Map,this._barCategoryCache=null,this._stackExtentCache=null,this._ingestVersion=0,this._bufferArrayCache=null,this._bufferDirty=!0,this.needsFullRebuild=!0,this.lastLayout=null,this.scales=null,this.scene=[],this.version=0,this._quadtree=null,this.config=e,this.buffer=new X(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=te(e.timeAccessor||e.xAccessor,"time"),this.getY=te(e.valueAccessor||e.yAccessor,"value")):(this.getX=te(e.xAccessor,"x"),this.getY=te(e.yAccessor,"y")),this.getGroup=oe(e.groupAccessor),this.getCategory=oe(e.categoryAccessor),this.getSize=e.sizeAccessor?te(e.sizeAccessor,"size"):void 0,this.getColor=oe(e.colorAccessor),this.getBounds=e.boundsAccessor?te(e.boundsAccessor,"bounds"):void 0,this.getY0=e.y0Accessor?te(e.y0Accessor,"y0"):void 0,this.getPointId=oe(e.pointIdAccessor),"candlestick"===e.chartType&&(this.getOpen=te(e.openAccessor,"open"),this.getHigh=te(e.highAccessor,"high"),this.getLow=te(e.lowAccessor,"low"),this.getClose=te(e.closeAccessor,"close")),e.pulse&&(this.timestampBuffer=new X(e.windowSize))}ingest(e){const t="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=t,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,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){if("growing"===this.config.windowMode&&this.buffer.full){const e=this.config.maxCapacity||1e6;e>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,e),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap))}const e=this.buffer.push(n);this.timestampBuffer&&this.timestampBuffer.push(t),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):(this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n))),null!=e&&(this.xExtent.evict(this.getX(e)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(e)),this.yExtent.evict(this.getLow(e))):this.yExtent.evict(this.getY(e)))}return!0}computeScene(e){var t,n,o,r,i,s;const{config:a,buffer:l}=this;if(!this.needsFullRebuild&&this.lastLayout&&this.scene.length>0&&this.scales&&(this.lastLayout.width!==e.width||this.lastLayout.height!==e.height))return void this.remapScene(e);if(this.xExtent.dirty&&this.xExtent.recalculate(l,this.getX),this.yExtent.dirty)if("candlestick"===a.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const e of l)this.yExtent.push(this.getHigh(e)),this.yExtent.push(this.getLow(e))}else this.yExtent.recalculate(l,this.getY);const c=this.getBufferArray(),u=this.xExtent.extent,h=this.yExtent.extent;let d=a.xExtent?[null!==(t=a.xExtent[0])&&void 0!==t?t:u[0],null!==(n=a.xExtent[1])&&void 0!==n?n:u[1]]:u,g=a.yExtent?[null!==(o=a.yExtent[0])&&void 0!==o?o:h[0],null!==(r=a.yExtent[1])&&void 0!==r?r:h[1]]:h;const p=a.yExtent&&null!=a.yExtent[0]&&null!=a.yExtent[1];if("stackedarea"===a.chartType&&!p&&l.size>0)if(a.normalize)g=[0,1+a.extentPadding];else{const e=`${l.size}:${this._ingestVersion}`;if(this._stackExtentCache&&this._stackExtentCache.key===e)g=this._stackExtentCache.yDomain;else{const t=this.groupData(c),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);g=[0,o+(o>0?o*a.extentPadding:1)],this._stackExtentCache={key:e,yDomain:g}}}else if("bar"===a.chartType&&a.binSize&&!p&&l.size>0){const[,e]=function(e,t,n,o,r){const i=Q(e,t,n,o,r);if(0===i.size)return[0,0];let s=0;for(const e of i.values())e.total>s&&(s=e.total);return[0,s]}(l,this.getX,this.getY,a.binSize,this.getCategory);g=[0,e+e*a.extentPadding]}else if("waterfall"===a.chartType&&!p&&l.size>0){const[e,t]=function(e,t){let n=0,o=0,r=0;for(const i of e){const e=t(i);null==e||Number.isNaN(e)||(r+=e,n>r&&(n=r),r>o&&(o=r))}return[n,o]}(l,this.getY),n=t-e,o=n>0?n*a.extentPadding:1;g=[Math.min(0,e-Math.abs(o)),Math.max(0,t+Math.abs(o))]}else if(!p&&g[0]!==1/0){if(this.getBounds)for(const e of c){const t=this.getY(e),n=this.getBounds(e);null!=t&&!Number.isNaN(t)&&n&&(t+n>g[1]&&(g[1]=t+n),g[0]>t-n&&(g[0]=t-n))}const e=g[1]-g[0],t=e>0?e*a.extentPadding:1,n=null===(i=a.yExtent)||void 0===i?void 0:i[0],o=null===(s=a.yExtent)||void 0===s?void 0:s[1];g=[null!=n?g[0]:g[0]-t,null!=o?g[1]:g[1]+t],"log"===a.yScaleType&&0>=g[0]&&h[0]>0&&(g[0]=null!=n?g[0]:h[0]/(1+a.extentPadding))}if(d[0]!==1/0&&d[1]!==-1/0||(d=[0,1]),g[0]!==1/0&&g[1]!==-1/0||(g=[0,1]),"streaming"===a.runtimeMode)if("x"==("up"===(y=a.arrowOfTime)||"down"===y?"y":"x")){const t="right"===a.arrowOfTime?[0,e.width]:[e.width,0];this.scales={x:m().domain(d).range(t),y:m().domain(g).range([e.height,0])}}else{const t="down"===a.arrowOfTime?[0,e.height]:[e.height,0];this.scales={x:m().domain(g).range([0,e.width]),y:m().domain(d).range(t)}}else{const t=(e,t,n)=>{if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return b().domain(e).range(n).clamp(!0)}return m().domain(t).range(n)};this.scales={x:t(a.xScaleType,d,[0,e.width]),y:t(a.yScaleType,g,[e.height,0])}}var y;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(e,c),this.config.decay&&this.applyDecay(this.scene,c),this.config.pulse&&this.applyPulse(this.scene,c),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.rebuildQuadtree(),this.needsFullRebuild=!1,this.lastLayout={width:e.width,height:e.height},this.version++}rebuildQuadtree(){const e=this.config.chartType;if("scatter"!==e&&"bubble"!==e)return void(this._quadtree=null);const t=this.scene.filter(e=>"point"===e.type);this._quadtree=t.length>de.QUADTREE_THRESHOLD?P().x(e=>e.x).y(e=>e.y).addAll(t):null}get quadtree(){return this._quadtree}remapScene(e){const t=e.width/this.lastLayout.width,n=e.height/this.lastLayout.height;for(const e of this.scene)switch(e.type){case"line":for(const o of e.path)o[0]*=t,o[1]*=n;break;case"area":for(const o of e.topPath)o[0]*=t,o[1]*=n;for(const o of e.bottomPath)o[0]*=t,o[1]*=n;break;case"point":e.x*=t,e.y*=n;break;case"rect":case"heatcell":e.x*=t,e.y*=n,e.w*=t,e.h*=n;break;case"candlestick":e.x*=t,e.openY*=n,e.closeY*=n,e.highY*=n,e.lowY*=n}const o=this.scales.x.domain(),r=this.scales.y.domain(),i=this.scales.x.range(),s=this.scales.y.range(),a=(e,t,n)=>{if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return b().domain(e).range(n).clamp(!0)}return m().domain(t).range(n)};this.scales={x:a(this.config.xScaleType,o,[i[0]*t,i[1]*t]),y:a(this.config.yScaleType,r,[s[0]*n,s[1]*n])},this.lastLayout={width:e.width,height:e.height},this.rebuildQuadtree(),this.version++}buildSceneNodes(e,t){const{config:n,scales:o}=this;if(!o||0===t.length)return[];switch(n.chartType){case"line":return this.buildLineScene(t);case"area":return this.buildAreaScene(t);case"stackedarea":return this.buildStackedAreaScene(t);case"scatter":case"bubble":return this.buildPointScene(t);case"heatmap":return this.buildHeatmapScene(t,e);case"bar":return this.buildBarScene(t);case"swarm":return this.buildSwarmScene(t);case"waterfall":return this.buildWaterfallScene(t,e);case"candlestick":return this.buildCandlestickScene(t,e);default:return[]}}buildLineScene(e){var t;const n=this.groupData(e),o=[],r=null===(t=this.config.annotations)||void 0===t?void 0:t.filter(e=>"threshold"===e.type&&e.color).map(e=>({value:e.value,color:e.color,thresholdType:e.thresholdType||"greater"}));if(this.getBounds)for(const e of n){const t=this.buildBoundsForGroup(e.data,e.key);t&&o.push(t)}for(const e of n){const t=this.resolveLineStyle(e.key,e.data[0]),n=K(e.data,this.scales,this.getX,this.getY,t,e.key);r&&r.length>0&&(n.colorThresholds=r),this.config.curve&&"linear"!==this.config.curve&&(n.curve=this.config.curve),o.push(n)}return o}buildAreaScene(e){const t=this.groupData(e),n=[],o=this.scales.y.domain()[0];for(const e of t){const t=this.resolveAreaStyle(e.key,e.data[0]),r=U(e.data,this.scales,this.getX,this.getY,o,t,e.key,this.getY0);this.config.gradientFill&&(r.fillGradient=this.config.gradientFill),this.config.curve&&"linear"!==this.config.curve&&(r.curve=this.config.curve),n.push(r)}return n}buildStackedAreaScene(e){const t=this.groupData(e);return t.sort((e,t)=>t.key>e.key?-1:e.key>t.key?1:0),function(e,t,n,o,r,i,s){var a;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 c=Array.from(l).sort((e,t)=>e-t),u=new Map;for(const t of e){const e=new Map;for(const r of t.data){const t=n(r),i=o(r);null==t||null==i||Number.isNaN(t)||Number.isNaN(i)||e.set(t,(e.get(t)||0)+i)}u.set(t.key,e)}let h;if(i){h=new Map;for(const t of c){let n=0;for(const o of e)n+=(null===(a=u.get(o.key))||void 0===a?void 0:a.get(t))||0;h.set(t,n||1)}}const d=[],g=new Map;for(const e of c)g.set(e,0);for(const n of e){const e=u.get(n.key),o=[],a=[];for(const n of c){let r=e.get(n)||0;const s=g.get(n);i&&(r/=h.get(n));const l=t.x(n);a.push([l,t.y(s)]),o.push([l,t.y(s+r)]),g.set(n,s+r)}const l={type:"area",topPath:o,bottomPath:a,style:r(n.key,n.data[0]),datum:n.data,group:n.key};s&&(l.curve=s),d.push(l)}return d}(t,this.scales,this.getX,this.getY,(e,t)=>this.resolveAreaStyle(e,t),this.config.normalize,this.config.curve&&"linear"!==this.config.curve?this.config.curve:void 0)}buildPointScene(e){const t=[],n="bubble"===this.config.chartType?10:5,o=this.config.sizeRange||[3,15];let r=null;if(this.getSize&&!this.config.pointStyle){const t=e.map(e=>this.getSize(e)).filter(e=>null!=e&&!Number.isNaN(e));if(t.length>0){let e=1/0,n=-1/0;for(const o of t)e>o&&(e=o),o>n&&(n=o);r=t=>e===n?(o[0]+o[1])/2:o[0]+(t-e)/(n-e)*(o[1]-o[0])}}const i=this.getColor?this.resolveColorMap(e):null;for(const o of e){let e=this.config.pointStyle?this.config.pointStyle(o):{fill:"#4e79a7",opacity:.8},s=e.r||n;if(r&&this.getSize){const e=this.getSize(o);null==e||Number.isNaN(e)||(s=r(e))}if(i&&this.getColor&&!e.fill){const t=this.getColor(o);t&&i.has(t)&&(e=Object.assign(Object.assign({},e),{fill:i.get(t)}))}const a=this.getPointId?this.getPointId(o)+"":void 0,l=Z(o,this.scales,this.getX,this.getY,s,e,a);l&&t.push(l)}return t}buildHeatmapScene(e,t){const n=[];if(this.config.heatmapAggregation)return this.buildStreamingHeatmapScene(e,t);const o=te(this.config.valueAccessor,"value"),r=ne(this.config.xAccessor,"x"),i=ne(this.config.yAccessor,"y"),s=new Set,a=new Set;for(const t of e)s.add(r(t)),a.add(i(t));const l=Array.from(s),c=Array.from(a),u=l.every(e=>"number"==typeof e&&!isNaN(e)),h=c.every(e=>"number"==typeof e&&!isNaN(e)),d=u?l.sort((e,t)=>e-t):l,g=h?c.sort((e,t)=>e-t):c;if(0===d.length||0===g.length)return n;const p=t.width/d.length,y=t.height/g.length,f=new Map;for(const t of e){const e=`${r(t)}\0${i(t)}`;f.set(e,{val:o(t),datum:t})}let m=1/0,b=-1/0;for(const{val:e}of f.values())m>e&&(m=e),e>b&&(b=e);const x=v({blues:j,reds:E,greens:O,viridis:w}["string"==typeof this.config.colorScheme?this.config.colorScheme:"blues"]||j).domain([m,b]);for(let e=0;d.length>e;e++)for(let t=0;g.length>t;t++){const o=f.get(`${d[e]}\0${g[t]}`);if(!o)continue;const r=x(o.val);n.push(ee(e*p,(g.length-1-t)*y,p,y,r,o.datum,this.config.showValues?{value:o.val,showValues:!0,valueFormat:this.config.heatmapValueFormat}:void 0))}return n}buildStreamingHeatmapScene(e,t){var n,o,r;const i=[],s=null!==(n=this.config.heatmapXBins)&&void 0!==n?n:20,a=null!==(o=this.config.heatmapYBins)&&void 0!==o?o:20,l=null!==(r=this.config.heatmapAggregation)&&void 0!==r?r:"count",c=te(this.config.valueAccessor,"value");if(!this.scales||0===e.length)return i;const[u,h]=this.scales.x.domain(),[d,g]=this.scales.y.domain(),p=(h-u||1)/s,y=(g-d||1)/a,f=new Map;for(const t of e){const e=this.getX(t),n=this.getY(t),o=Math.min(Math.floor((e-u)/p),s-1),r=Math.min(Math.floor((n-d)/y),a-1);if(0>o||0>r)continue;const i=`${o}_${r}`;let l=f.get(i);l||(l={sum:0,count:0,data:[]},f.set(i,l)),l.count++,l.sum+=c(t),l.data.push(t)}let m=1/0,v=-1/0;const b=new Map;for(const[e,t]of f){let n;switch(l){case"sum":n=t.sum;break;case"mean":n=t.count>0?t.sum/t.count:0;break;default:n=t.count}b.set(e,n),m>n&&(m=n),n>v&&(v=n)}const x=v-m||1,k=t.width/s,w=t.height/a;for(const[e,t]of b){const[n,o]=e.split("_"),r=+n,s=+o,l=(t-m)/x,c=`rgb(${Math.round(220-180*l)},${Math.round(220-100*l)},${Math.round(255-50*l)})`,u=f.get(e);i.push(ee(r*k,(a-1-s)*w,k,w,c,{xi:r,yi:s,value:t,count:u.count,sum:u.sum,data:u.data},this.config.showValues?{value:t,showValues:!0,valueFormat:this.config.heatmapValueFormat}:void 0))}return i}buildBarScene(e){var t;if(!this.config.binSize)return[];const n=Q(e,this.getX,this.getY,this.config.binSize,this.getCategory);if(0===n.size)return[];let o=null;if(this.getCategory){const e=new Set;for(const t of n.values())for(const n of t.categories.keys())e.add(n);const t=this.config.barColors?Object.keys(this.config.barColors):[],r=new Set(t),i=Array.from(e).filter(e=>!r.has(e)).sort(),s=t.filter(t=>e.has(t)),a=s.join("\0")+""+i.join("\0");this._barCategoryCache&&this._barCategoryCache.key===a?o=this._barCategoryCache.order:(o=[...s,...i],this._barCategoryCache={key:a,order:o})}const r=[],i=this.scales,[s,a]=i.x.domain();for(const e of n.values()){const n=Math.max(e.start,s),l=Math.min(e.end,a);if(n>=l)continue;const c=i.x(n),u=i.x(l),h=Math.abs(u-c),d=h>2?1:0,g=Math.min(c,u)+d/2,p=Math.max(h-d,1);if(p>0)if(o&&e.categories.size>0){let n=0;for(const s of o){const o=e.categories.get(s)||0;if(0===o)continue;const a=i.y(n),l=i.y(n+o);r.push(J(g,Math.min(a,l),p,Math.abs(a-l),{fill:(null===(t=this.config.barColors)||void 0===t?void 0:t[s])||"#4e79a7"},{binStart:e.start,binEnd:e.end,total:e.total,category:s,categoryValue:o},s)),n+=o}}else{const t=i.y(0),n=i.y(e.total);r.push(J(g,Math.min(t,n),p,Math.abs(t-n),{fill:"#007bff"},{binStart:e.start,binEnd:e.end,total:e.total}))}}return r}buildSwarmScene(e){var t,n,o,r;const i=[],s=this.config.swarmStyle||{},a=null!==(t=s.radius)&&void 0!==t?t:3,l=null!==(n=s.fill)&&void 0!==n?n:"#007bff",c=null!==(o=s.opacity)&&void 0!==o?o:.7,u=s.stroke,h=s.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),s=this.scales.y(n);let d=l;if(this.getCategory){const e=this.getCategory(t);d=(null===(r=this.config.barColors)||void 0===r?void 0:r[e])||d}const g={type:"point",x:o,y:s,r:a,style:{fill:d,opacity:c,stroke:u,strokeWidth:h},datum:t};this.getPointId&&(g.pointId=this.getPointId(t)+""),i.push(g)}return i}buildWaterfallScene(e,t){var n,o,r;const i=[],s=this.scales,a=this.config.waterfallStyle,l=e.filter(e=>{const t=this.getY(e);return null!=t&&!Number.isNaN(t)});if(0===l.length)return i;const c=null!==(n=null==a?void 0:a.positiveColor)&&void 0!==n?n:"#28a745",u=null!==(o=null==a?void 0:a.negativeColor)&&void 0!==o?o:"#dc3545",h=null!==(r=null==a?void 0:a.gap)&&void 0!==r?r:1,d=null==a?void 0:a.stroke,g=null==a?void 0:a.strokeWidth;let p=0;for(let e=0;l.length>e;e++){const n=l[e],o=this.getX(n),r=this.getY(n),y=p+r;let f;f=l.length-1>e?this.getX(l[e+1])-o:e>0?o-this.getX(l[e-1]):0;const m=s.x(o),v=0!==f?s.x(o+f):m+t.width/10,b=Math.min(m,v)+h/2,x=Math.max(m,v)-h/2-b;if(0>=x){p=y;continue}const k=s.y(p),w=s.y(y);i.push(J(b,Math.min(k,w),x,Math.abs(k-w),{fill:0>r?u:c,stroke:d,strokeWidth:g},Object.assign(Object.assign({},n),{baseline:p,cumEnd:y,delta:r,_connectorStroke:null==a?void 0:a.connectorStroke,_connectorWidth:null==a?void 0:a.connectorWidth}))),p=y}return i}buildCandlestickScene(e,t){if(!(this.getOpen&&this.getHigh&&this.getLow&&this.getClose&&this.scales))return[];const n=[],o=this.config.candlestickStyle||{},r=o.upColor||"#28a745",i=o.downColor||"#dc3545",s=o.wickColor||"#333",a=o.wickWidth||1,l=e.map(e=>this.getX(e)).filter(e=>null!=e&&!Number.isNaN(e)).sort((e,t)=>e-t);let c=o.bodyWidth||6;if(!o.bodyWidth&&l.length>1){let e=1/0;for(let t=1;l.length>t;t++){const n=Math.abs(this.scales.x(l[t])-this.scales.x(l[t-1]));n>0&&e>n&&(e=n)}e!==1/0&&(c=Math.max(2,Math.min(.6*e,20)))}for(const t of e){const e=this.getX(t);if(null==e||Number.isNaN(e))continue;const o=this.getOpen(t),l=this.getHigh(t),u=this.getLow(t),h=this.getClose(t);if([o,l,u,h].some(e=>null==e||Number.isNaN(e)))continue;const d=h>=o;n.push({type:"candlestick",x:this.scales.x(e),openY:this.scales.y(o),closeY:this.scales.y(h),highY:this.scales.y(l),lowY:this.scales.y(u),bodyWidth:c,upColor:r,downColor:i,wickColor:s,wickWidth:a,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),r=this.getY(t);if(null==e||null==r||Number.isNaN(e)||Number.isNaN(r))continue;const i=this.getBounds(t),s=this.scales.x(e);if(i&&0!==i)n.push([s,this.scales.y(r+i)]),o.push([s,this.scales.y(r-i)]);else{const e=this.scales.y(r);n.push([s,e]),o.push([s,e])}}return 2>n.length?null:{type:"area",topPath:n,bottomPath:o,style:this.resolveBoundsStyle(t,e[0]),datum:e,group:t,interactive:!1}}resolveBoundsStyle(e,t){const n=this.config.boundsStyle;return"function"==typeof n?n(t||{},e):n&&"object"==typeof n?n:{fill:this.resolveLineStyle(e,t).stroke||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(e,t){var n,o,r;const i=this.config.decay;if(!i||1>=t)return 1;const s=null!==(n=i.minOpacity)&&void 0!==n?n:.1,a=t-1-e;switch(i.type){case"linear":return s+(1-a/(t-1))*(1-s);case"exponential":{const e=null!==(o=i.halfLife)&&void 0!==o?o:t/2;return s+Math.pow(.5,a/e)*(1-s)}case"step":return(null!==(r=i.stepThreshold)&&void 0!==r?r:.5*t)>a?1:s;default:return 1}}applyDecay(e,t){var n,o;if(!this.config.decay)return;const r=t.length;if(1>=r)return;const i=new Map;for(let e=0;t.length>e;e++)i.set(t[e],e);for(const t of e){if("line"===t.type){const e=Array.isArray(t.datum)?t.datum:[];if(2>e.length)continue;const n=Array(e.length);let o=!1;for(let t=0;e.length>t;t++){const s=i.get(e[t]);null!=s?(n[t]=this.computeDecayOpacity(s,r),1>n[t]&&(o=!0)):n[t]=1}o&&(t._decayOpacities=n);continue}if("area"===t.type){const e=Array.isArray(t.datum)?t.datum:[],n=t.topPath?t.topPath.length:e.length;if(2>n)continue;if(e.length===n){const o=Array(n);let s=!1;for(let t=0;e.length>t;t++){const n=i.get(e[t]);null!=n?(o[t]=this.computeDecayOpacity(n,r),1>o[t]&&(s=!0)):o[t]=1}s&&(t._decayOpacities=o)}else{let o=1;for(const t of e){const e=i.get(t);if(null!=e){const t=this.computeDecayOpacity(e,r);o>t&&(o=t)}}if(1>o){const e=Array(n);e.fill(o),t._decayOpacities=e}}continue}const e=i.get(t.datum);if(null==e)continue;const s=this.computeDecayOpacity(e,r);if("heatcell"===t.type)t.style={opacity:s};else if("candlestick"===t.type)t._decayOpacity=s;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*s})}}}computePulseIntensity(e,t){var n;const o=this.config.pulse;if(!o)return 0;const r=null!==(n=o.duration)&&void 0!==n?n:500,i=t-e;return r>i?1-i/r:0}applyPulse(e,t){var n,o;if(!this.config.pulse||!this.timestampBuffer)return;const r="undefined"!=typeof performance?performance.now():Date.now(),i=null!==(n=this.config.pulse.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",s=null!==(o=this.config.pulse.glowRadius)&&void 0!==o?o:4,a=new Map;for(let e=0;t.length>e;e++)a.set(t[e],e);for(const t of e){if("line"===t.type)continue;if("area"===t.type){const e=Array.isArray(t.datum)?t.datum:[t.datum];let n=0;for(const t of e){const e=a.get(t);if(null==e)continue;const o=this.timestampBuffer.get(e);if(null==o)continue;const i=this.computePulseIntensity(o,r);i>n&&(n=i)}n>0&&(t._pulseIntensity=n,t._pulseColor=i);continue}const e=a.get(t.datum);if(null==e)continue;const n=this.timestampBuffer.get(e);if(null==n)continue;const o=this.computePulseIntensity(n,r);o>0&&(t._pulseIntensity=o,t._pulseColor=i,t._pulseGlowRadius=s)}}get hasActivePulses(){var e;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const t="undefined"!=typeof performance?performance.now():Date.now(),n=null!==(e=this.config.pulse.duration)&&void 0!==e?e:500,o=this.timestampBuffer.peek();return null!=o&&n>t-o}snapshotPositions(){var e,t,n;this.prevPositionMap.clear(),this.prevPathMap.clear();for(let o=0;this.scene.length>o;o++){const r=this.scene[o],i=this.getNodeIdentity(r,o);i&&("point"===r.type?this.prevPositionMap.set(i,{x:r.x,y:r.y,r:r.r,opacity:r.style.opacity}):"rect"===r.type?this.prevPositionMap.set(i,{x:r.x,y:r.y,w:r.w,h:r.h,opacity:r.style.opacity}):"heatcell"===r.type?this.prevPositionMap.set(i,{x:r.x,y:r.y,w:r.w,h:r.h,opacity:null===(e=r.style)||void 0===e?void 0:e.opacity}):"candlestick"===r.type?this.prevPositionMap.set(i,{x:r.x,y:r.openY}):"line"===r.type?this.prevPathMap.set(i,{path:r.path.map(e=>[e[0],e[1]]),opacity:null===(t=r.style)||void 0===t?void 0:t.opacity}):"area"===r.type&&this.prevPathMap.set(i,{topPath:r.topPath.map(e=>[e[0],e[1]]),bottomPath:r.bottomPath.map(e=>[e[0],e[1]]),opacity:null===(n=r.style)||void 0===n?void 0:n.opacity}))}}getNodeIdentity(e,t){var n,o,r,i;switch(e.type){case"point":if(e.pointId)return"p:"+e.pointId;if("streaming"===this.config.runtimeMode&&e.datum){if(this.getCategory)return`p:${this.getCategory(e.datum)}:${this.getY(e.datum)}`;const t=this.getX(e.datum),n=this.getY(e.datum);if(null!=t&&null!=n)return`p:${t}:${n}`}return"p:"+t;case"rect":return`r:${e.group||""}:${null!==(i=null!==(o=null===(n=e.datum)||void 0===n?void 0:n.binStart)&&void 0!==o?o:null===(r=e.datum)||void 0===r?void 0:r.category)&&void 0!==i?i:t}`;case"heatcell":return`h:${e.x}_${e.y}`;case"candlestick":return null==e.datum?"c:"+t:"c:"+this.getX(e.datum);case"line":return"l:"+(e.group||"_default");case"area":return"a:"+(e.group||"_default");default:return null}}startTransition(){var e,t,n,o,r,i,s,a,l,c,u,h,d,g,p,y,f,m,v,b,x,k,w,A,S,O;if(!this.config.transition||0===this.prevPositionMap.size&&0===this.prevPathMap.size)return;const E=null!==(e=this.config.transition.duration)&&void 0!==e?e:300;if(this.exitNodes.length>0){const e=new Set(this.exitNodes);this.scene=this.scene.filter(t=>!e.has(t)),this.exitNodes=[]}let j=!1;const C=new Set,M=new Set;for(let e=0;this.scene.length>e;e++){const f=this.scene[e],m=this.getNodeIdentity(f,e);if(!m)continue;if(f._transitionKey=m,"line"===f.type||"area"===f.type){const e=this.prevPathMap.get(m);if(e){if(M.add(m),"line"===f.type&&e.path&&e.path.length===f.path.length){f._targetPath=f.path.map(e=>[e[0],e[1]]),f._prevPath=e.path;for(let t=0;f.path.length>t;t++)f.path[t]=[e.path[t][0],e.path[t][1]];j=!0}else if("area"===f.type&&e.topPath&&e.bottomPath&&e.topPath.length===f.topPath.length&&e.bottomPath.length===f.bottomPath.length){f._targetTopPath=f.topPath.map(e=>[e[0],e[1]]),f._targetBottomPath=f.bottomPath.map(e=>[e[0],e[1]]),f._prevTopPath=e.topPath,f._prevBottomPath=e.bottomPath;for(let t=0;f.topPath.length>t;t++)f.topPath[t]=[e.topPath[t][0],e.topPath[t][1]];for(let t=0;f.bottomPath.length>t;t++)f.bottomPath[t]=[e.bottomPath[t][0],e.bottomPath[t][1]];j=!0}f._targetOpacity=null!==(t=f.style.opacity)&&void 0!==t?t:1}else f._targetOpacity=null!==(n=f.style.opacity)&&void 0!==n?n:1,f.style=Object.assign(Object.assign({},f.style),{opacity:0}),j=!0;continue}const v=this.prevPositionMap.get(m);if("point"===f.type)if(v){C.add(m);const e={x:f.x,y:f.y,r:f.r};f._targetOpacity=null!==(o=f.style.opacity)&&void 0!==o?o:1,v.x===e.x&&v.y===e.y||(f._targetX=e.x,f._targetY=e.y,f._targetR=e.r,f.x=v.x,f.y=v.y,f.r=null!==(r=v.r)&&void 0!==r?r:f.r,j=!0)}else f._targetOpacity=null!==(i=f.style.opacity)&&void 0!==i?i:1,f.style=Object.assign(Object.assign({},f.style),{opacity:0}),j=!0;else if("rect"===f.type)if(v){C.add(m);const e={x:f.x,y:f.y,w:f.w,h:f.h};f._targetOpacity=null!==(s=f.style.opacity)&&void 0!==s?s:1,v.x===e.x&&v.y===e.y&&v.w===e.w&&v.h===e.h||(f._targetX=e.x,f._targetY=e.y,f._targetW=e.w,f._targetH=e.h,f.x=v.x,f.y=v.y,f.w=null!==(a=v.w)&&void 0!==a?a:f.w,f.h=null!==(l=v.h)&&void 0!==l?l:f.h,j=!0)}else f._targetOpacity=null!==(c=f.style.opacity)&&void 0!==c?c:1,f.style=Object.assign(Object.assign({},f.style),{opacity:0}),j=!0;else if("heatcell"===f.type)if(v){C.add(m);const e={x:f.x,y:f.y,w:f.w,h:f.h};f._targetOpacity=null!==(h=null===(u=f.style)||void 0===u?void 0:u.opacity)&&void 0!==h?h:1,v.x===e.x&&v.y===e.y||(f._targetX=e.x,f._targetY=e.y,f._targetW=e.w,f._targetH=e.h,f.x=v.x,f.y=v.y,f.w=null!==(d=v.w)&&void 0!==d?d:f.w,f.h=null!==(g=v.h)&&void 0!==g?g:f.h,j=!0)}else f._targetOpacity=null!==(y=null===(p=f.style)||void 0===p?void 0:p.opacity)&&void 0!==y?y:1,f.style=Object.assign(Object.assign({},f.style||{}),{opacity:0}),j=!0}for(const[e,t]of this.prevPathMap)if(!M.has(e))if(e.startsWith("l:")&&t.path){const n={type:"line",path:t.path.map(e=>[e[0],e[1]]),group:e.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:null!==(f=t.opacity)&&void 0!==f?f:1},_targetOpacity:0,_transitionKey:e,datum:null};this.exitNodes.push(n),j=!0}else if(e.startsWith("a:")&&t.topPath&&t.bottomPath){const n={type:"area",topPath:t.topPath.map(e=>[e[0],e[1]]),bottomPath:t.bottomPath.map(e=>[e[0],e[1]]),group:e.slice(2),style:{fill:"#999",opacity:null!==(m=t.opacity)&&void 0!==m?m:1},_targetOpacity:0,_transitionKey:e,datum:null};this.exitNodes.push(n),j=!0}for(const[e,t]of this.prevPositionMap)if(!C.has(e)){if(e.startsWith("p:")){const n={type:"point",x:t.x,y:t.y,r:null!==(v=t.r)&&void 0!==v?v:3,style:{opacity:null!==(b=t.opacity)&&void 0!==b?b:1},datum:null,_targetOpacity:0,_transitionKey:e};this.exitNodes.push(n)}else if(e.startsWith("r:")){const n={type:"rect",x:t.x,y:t.y,w:null!==(x=t.w)&&void 0!==x?x:0,h:null!==(k=t.h)&&void 0!==k?k:0,style:{opacity:null!==(w=t.opacity)&&void 0!==w?w:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e};this.exitNodes.push(n)}else if(e.startsWith("h:")){const n={type:"heatcell",x:t.x,y:t.y,w:null!==(A=t.w)&&void 0!==A?A:0,h:null!==(S=t.h)&&void 0!==S?S:0,fill:"#999",datum:null,style:{opacity:null!==(O=t.opacity)&&void 0!==O?O:1},_targetOpacity:0,_transitionKey:e};this.exitNodes.push(n)}j=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),j&&(this.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:E})}advanceTransition(e){var t,n,o,r,i,s;if(!this.activeTransition)return!1;const a=function(e,t){return Math.min((e-t.startTime)/t.duration,1)}(e,this.activeTransition),l=function(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}(a,"linear"===(null===(t=this.config.transition)||void 0===t?void 0:t.easing)?"linear":"ease-out-cubic");for(const e of this.scene){const t=e._transitionKey;if("point"===e.type){if(void 0!==e._targetOpacity){const o=t?this.prevPositionMap.get(t):void 0,r=o?null!==(n=o.opacity)&&void 0!==n?n:1:0;e.style.opacity=he(r,e._targetOpacity,l)}if(void 0===e._targetX)continue;if(!t)continue;const o=this.prevPositionMap.get(t);if(!o)continue;e.x=he(o.x,e._targetX,l),e.y=he(o.y,e._targetY,l),void 0!==e._targetR&&void 0!==o.r&&(e.r=he(o.r,e._targetR,l))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const n=t?this.prevPositionMap.get(t):void 0,r=n?null!==(o=n.opacity)&&void 0!==o?o:1:0;e.style.opacity=he(r,e._targetOpacity,l)}if(void 0===e._targetX)continue;if(!t)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=he(n.x,e._targetX,l),e.y=he(n.y,e._targetY,l),void 0!==n.w&&(e.w=he(n.w,e._targetW,l)),void 0!==n.h&&(e.h=he(n.h,e._targetH,l))}else if("heatcell"===e.type){if(void 0!==e._targetOpacity){const n=t?this.prevPositionMap.get(t):void 0,o=n?null!==(r=n.opacity)&&void 0!==r?r:1:0;e.style=Object.assign(Object.assign({},e.style||{}),{opacity:he(o,e._targetOpacity,l)})}if(void 0===e._targetX)continue;if(!t)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=he(n.x,e._targetX,l),e.y=he(n.y,e._targetY,l),void 0!==n.w&&(e.w=he(n.w,e._targetW,l)),void 0!==n.h&&(e.h=he(n.h,e._targetH,l))}else if("line"===e.type){if(void 0!==e._targetOpacity){const t=void 0===e._prevPath&&e._targetOpacity>0?0:null!==(i=e.style.opacity)&&void 0!==i?i:1;e.style=Object.assign(Object.assign({},e.style),{opacity:he(t,e._targetOpacity,l)})}const t=e._prevPath,n=e._targetPath;if(t&&n&&t.length===e.path.length)for(let o=0;e.path.length>o;o++)e.path[o][0]=he(t[o][0],n[o][0],l),e.path[o][1]=he(t[o][1],n[o][1],l)}else if("area"===e.type){if(void 0!==e._targetOpacity){const t=void 0===e._prevTopPath&&e._targetOpacity>0?0:null!==(s=e.style.opacity)&&void 0!==s?s:1;e.style=Object.assign(Object.assign({},e.style),{opacity:he(t,e._targetOpacity,l)})}const t=e._prevTopPath,n=e._prevBottomPath,o=e._targetTopPath,r=e._targetBottomPath;if(t&&o&&t.length===e.topPath.length)for(let n=0;e.topPath.length>n;n++)e.topPath[n][0]=he(t[n][0],o[n][0],l),e.topPath[n][1]=he(t[n][1],o[n][1],l);if(n&&r&&n.length===e.bottomPath.length)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t][0]=he(n[t][0],r[t][0],l),e.bottomPath[t][1]=he(n[t][1],r[t][1],l)}}if(a>=1){for(const e of this.scene){if(void 0!==e._targetOpacity){const t=e._targetOpacity;e.style=Object.assign(Object.assign({},"line"===e.type||"area"===e.type?e.style:e.style||{}),{opacity:0===t?0:t}),e._targetOpacity=void 0}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}else if("line"===e.type){const t=e._targetPath;if(t)for(let n=0;e.path.length>n;n++)e.path[n]=t[n];e._prevPath=void 0,e._targetPath=void 0}else if("area"===e.type){const t=e._targetTopPath,n=e._targetBottomPath;if(t)for(let n=0;e.topPath.length>n;n++)e.topPath[n]=t[n];if(n)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t]=n[t];e._prevTopPath=void 0,e._prevBottomPath=void 0,e._targetTopPath=void 0,e._targetBottomPath=void 0}}if(this.exitNodes.length>0){const e=new Set(this.exitNodes);this.scene=this.scene.filter(t=>!e.has(t)),this.exitNodes=[]}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}))}resolveColorMap(e){const t=new Set;for(const n of e){const e=this.getColor(n);e&&t.add(e)}const n=Array.from(t).sort(),o=n.join("\0");if(this._colorMapCache&&this._colorMapCache.key===o)return this._colorMapCache.map;const r=Array.isArray(this.config.colorScheme)?this.config.colorScheme:se,i=new Map;for(let e=0;n.length>e;e++)i.set(n[e],r[e%r.length]);return this._colorMapCache={key:o,map:i},i}resolveLineStyle(e,t){const n=this.config.lineStyle;if("function"==typeof n){const o=n(t||{},e);if(o&&!o.stroke&&e){const t=this.resolveGroupColor(e);if(t)return Object.assign(Object.assign({},o),{stroke:t})}return o}return n&&"object"==typeof n?{stroke:n.stroke||"#007bff",strokeWidth:n.strokeWidth||2,strokeDasharray:n.strokeDasharray,fill:n.fill,fillOpacity:n.fillOpacity,opacity:n.opacity}:{stroke:"#007bff",strokeWidth:2}}resolveAreaStyle(e,t){var n;if(this.config.areaStyle){const n=this.config.areaStyle(t||{});if(n&&!n.fill&&e){const t=this.resolveGroupColor(e);if(t)return Object.assign(Object.assign({},n),{fill:t,stroke:n.stroke||t})}return n}const o=this.config.lineStyle;if("function"==typeof o){const n=o(t||{},e);if(n&&!n.fill&&e){const t=this.resolveGroupColor(e);if(t)return Object.assign(Object.assign({},n),{fill:t,stroke:n.stroke||t})}return n}return 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}}resolveGroupColor(e){if(this._colorMapCache){const t=this._colorMapCache.map.get(e);if(t)return t}const t=this._groupColorMap.get(e);if(t)return t;const n=Array.isArray(this.config.colorScheme)?this.config.colorScheme:se,o=n[this._groupColorMap.size%n.length];return this._groupColorMap.set(e,o),o}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.prevPathMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this.needsFullRebuild=!0,this._bufferDirty=!0,this._bufferArrayCache=null,this.lastLayout=null,this.scales=null,this.scene=[],this._quadtree=null,this._colorMapCache=null,this._groupColorMap=new Map,this._barCategoryCache=null,this._stackExtentCache=null,this.version++}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}updateConfig(e){void 0!==e.colorScheme&&(this._colorMapCache=null,this._groupColorMap=new Map),void 0===e.barColors&&void 0===e.colorScheme||(this._barCategoryCache=null),void 0===e.normalize&&void 0===e.extentPadding&&void 0===e.xAccessor&&void 0===e.yAccessor&&void 0===e.groupAccessor&&void 0===e.categoryAccessor&&void 0===e.chartType||(this._stackExtentCache=null),Object.assign(this.config,e),(void 0!==e.xAccessor||void 0!==e.yAccessor||void 0!==e.timeAccessor||void 0!==e.valueAccessor)&&(["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?(this.getX=te(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=te(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=te(this.config.xAccessor,"x"),this.getY=te(this.config.yAccessor,"y"))),void 0!==e.groupAccessor&&(this.getGroup=oe(this.config.groupAccessor)),void 0!==e.categoryAccessor&&(this.getCategory=oe(this.config.categoryAccessor)),void 0!==e.sizeAccessor&&(this.getSize=this.config.sizeAccessor?te(this.config.sizeAccessor,"size"):void 0),void 0!==e.colorAccessor&&(this.getColor=oe(this.config.colorAccessor)),void 0!==e.y0Accessor&&(this.getY0=this.config.y0Accessor?te(this.config.y0Accessor,"y0"):void 0),void 0!==e.pointIdAccessor&&(this.getPointId=oe(this.config.pointIdAccessor)),this.needsFullRebuild=!0}}function ge(e,t,n){return n.x>e||e>n.x+n.w||n.y>t||t>n.y+n.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:n.x+n.w/2,cy:n.y+n.h/2}}function pe(e,t,n){const o=t-e.x,r=n-e.y,i=Math.sqrt(o*o+r*r);return i>e.r+5?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:i}}function ye(e,t,n){var o,r,i,s;if(0===e.path.length)return null;const a=ke(e.path,t);if(0>a)return null;const[l,c]=e.path[a];let u;if(e.path.length>1){let o=1/0;const r=Math.max(0,a-1),i=Math.min(e.path.length-2,a);for(let s=r;i>=s;s++){const[r,i]=e.path[s],[a,l]=e.path[s+1],c=fe(t,n,r,i,a,l);o>c&&(o=c)}u=o}else{const e=t-l,o=n-c;u=Math.sqrt(e*e+o*o)}const h=null!==(s=null!==(r=null===(o=e.style)||void 0===o?void 0:o.strokeWidth)&&void 0!==r?r:null===(i=e.style)||void 0===i?void 0:i.lineWidth)&&void 0!==s?s:1;return u>Math.max(5,h/2+2)?null:{node:e,datum:Array.isArray(e.datum)&&e.datum[a]?e.datum[a]:e.datum,x:l,y:c,distance:u}}function fe(e,t,n,o,r,i){const s=r-n,a=i-o,l=s*s+a*a;if(0===l)return Math.sqrt(Math.pow(e-n,2)+Math.pow(t-o,2));let c=((e-n)*s+(t-o)*a)/l;c=Math.max(0,Math.min(1,c));const u=o+c*a;return Math.sqrt(Math.pow(e-(n+c*s),2)+Math.pow(t-u,2))}function me(e,t,n){const o=ge(t,n,e);return o.hit?{node:e,datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}function ve(e,t,n){const o=ge(t,n,e);return o.hit?{node:e,datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}function be(e,t,n){const o=e.bodyWidth/2,r=Math.min(e.openY,e.closeY);if(!(e.x-o-3>t||t>e.x+o+3||e.highY-3>n||n>e.lowY+3)){const o=r+Math.max(Math.max(e.openY,e.closeY)-r,1)/2,i=t-e.x,s=n-o;return{node:e,datum:e.datum,x:e.x,y:o,distance:Math.sqrt(i*i+s*s)}}return null}function xe(e,t,n){if(0===e.topPath.length)return null;const o=ke(e.topPath,t);if(0>o)return null;const[r,i]=e.topPath[o],s=t-r,a=n-i,l=Math.sqrt(s*s+a*a);return{node:e,datum:Array.isArray(e.datum)&&e.datum[o]?e.datum[o]:e.datum,x:r,y:i,distance:l}}function ke(e,t){if(0===e.length)return-1;let n=0,o=e.length-1;for(;o>n;){const r=n+o>>1;t>e[r][0]?n=r+1:o=r}return n>0&&Math.abs(e[n][0]-t)>=Math.abs(e[n-1][0]-t)?n-1:n}de.QUADTREE_THRESHOLD=500;const we={fill:t=>e.createElement("rect",{style:t,width:16,height:16}),line:t=>e.createElement("line",{style:t,x1:0,y1:0,x2:16,y2:16})};function Ae(e,t,n,o){let r;return r="function"==typeof n?n(e):(0,we[n])(o(e,t)),r}function Se(){return e.createElement("path",{d:"M4,8.8 L7.2,12 L12.8,4.8",fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function Oe(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}function Ee({config:t,orientation:n="vertical",width:o=100}){const{colorFn:r,domain:i,label:s,format:a}=t,l=a||(e=>Math.round(100*e)/100+""),c="grad-legend-"+e.useId();if("horizontal"===n){const t=12,n=Math.min(o,200),a=Math.max(0,(o-n)/2),u=[];for(let t=0;64>=t;t++){const n=t/64;u.push(e.createElement("stop",{key:t,offset:100*n+"%",stopColor:r(i[0]+n*(i[1]-i[0]))}))}return e.createElement("g",{"aria-label":s||"Gradient legend"},e.createElement("defs",null,e.createElement("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"100%",y2:"0%"},u)),s&&e.createElement("text",{x:a+n/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},s),e.createElement("rect",{x:a,y:0,width:n,height:t,fill:`url(#${c})`,rx:2}),e.createElement("text",{x:a,y:t+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},l(i[0])),e.createElement("text",{x:a+n,y:t+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},l(i[1])))}const u=[];for(let t=0;64>=t;t++){const n=t/64;u.push(e.createElement("stop",{key:t,offset:100*n+"%",stopColor:r(i[1]-n*(i[1]-i[0]))}))}return e.createElement("g",{"aria-label":s||"Gradient legend"},s&&e.createElement("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},s),e.createElement("defs",null,e.createElement("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"0%",y2:"100%"},u)),e.createElement("rect",{x:0,y:0,width:14,height:100,fill:`url(#${c})`,rx:2}),e.createElement("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},l(i[1])),e.createElement("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},l(i[0])))}function je(t){const{legendGroups:n,customClickBehavior:o,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:s,legendInteraction:a,title:l="Legend",width:c=100,height:u=20,orientation:h="vertical"}=t,[d,g]=e.useState(0),[p,y]=e.useState(0),f=e.useCallback((e,t)=>{g(e),y(t)},[]),m="vertical"===h?(({legendGroups:t,width:n,customClickBehavior:o,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:s,focusedGroupIndex:a,focusedItemIndex:l,onFocusedIndexChange:c,legendInteraction:u})=>{let h=24;const d=[];return t.forEach((t,g)=>{h+=5,d.push(e.createElement("line",{key:"legend-top-line legend-symbol-"+g,stroke:"gray",x1:0,y1:h,x2:n,y2:h})),h+=8,t.label&&(h+=16,d.push(e.createElement("text",{key:"legend-text-"+g,y:h,className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},t.label)),h+=8),d.push(e.createElement("g",{key:"legend-group-"+g,className:"legend-item",transform:`translate(0,${h})`},((t,n,o,r,i,s,a,l,c,u)=>{const{type:h="fill",styleFn:d,items:g}=t,p=[];let y=0;const f=!(!n&&!o),m="isolate"===u||void 0===u&&null!=i;return g.forEach((t,u)=>{const v=Ae(t,u,h,d),b=Oe(t,r,i),x=i&&i.size>0&&i.has(t.label);p.push(e.createElement("g",{key:"legend-item-"+u,transform:`translate(0,${y})`,onClick:n?()=>n(t):void 0,onMouseEnter:o?()=>o(t):void 0,onMouseLeave:o?()=>o(null):void 0,tabIndex:f?l===s&&u===a?0:-1:void 0,role:f?"option":void 0,"aria-selected":f&&m?x||!1:void 0,"aria-current":f&&!m&&null!=r&&t.label===r||void 0,"aria-label":t.label,onKeyDown:f?e=>{var o;if("Enter"!==e.key&&" "!==e.key||(e.preventDefault(),n&&n(t)),"ArrowDown"===e.key||"ArrowUp"===e.key){e.preventDefault();const t=(u+("ArrowDown"===e.key?1:-1)+g.length)%g.length;c(l,t);const n=null===(o=e.currentTarget.parentElement)||void 0===o?void 0:o.children[t];n instanceof SVGElement&&n.focus()}}:void 0,onFocus:f?e=>{c(l,u),o&&o(t);const n=e.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:f?e=>{o&&o(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:f?"pointer":"default",opacity:b,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},f&&e.createElement("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*t.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),v,x&&e.createElement(Se,null),e.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},t.label))),y+=22}),p})(t,o,r,i,s,a,l,g,c,u))),h+=22*t.items.length+8}),d})({legendGroups:n||[],width:c,customClickBehavior:o,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:s,focusedGroupIndex:d,focusedItemIndex:p,onFocusedIndexChange:f,legendInteraction:a}):(({legendGroups:t,height:n,width:o,customClickBehavior:r,customHoverBehavior:i,highlightedCategory:s,isolatedCategories:a,focusedGroupIndex:l,focusedItemIndex:c,onFocusedIndexChange:u,legendInteraction:h})=>{let d=0;const g=[];t.forEach((t,n)=>{let o=0;t.label&&(o+=16);const p=((t,n,o,r,i,s,a,l,c,u)=>{const{type:h="fill",styleFn:d,items:g}=t,p=[];let y=0;const f=!(!n&&!o),m="isolate"===u||void 0===u&&null!=i;return g.forEach((t,u)=>{const v=Ae(t,u,h,d),b=Oe(t,r,i),x=i&&i.size>0&&i.has(t.label);p.push(e.createElement("g",{key:"legend-item-"+u,transform:`translate(${y},0)`,onClick:n?()=>n(t):void 0,onMouseEnter:o?()=>o(t):void 0,onMouseLeave:o?()=>o(null):void 0,tabIndex:f?l===s&&u===a?0:-1:void 0,role:f?"option":void 0,"aria-selected":f&&m?x||!1:void 0,"aria-current":f&&!m&&null!=r&&t.label===r||void 0,"aria-label":t.label,onKeyDown:f?e=>{var o;if("Enter"!==e.key&&" "!==e.key||(e.preventDefault(),n&&n(t)),"ArrowRight"===e.key||"ArrowLeft"===e.key){e.preventDefault();const t=(u+("ArrowRight"===e.key?1:-1)+g.length)%g.length;c(l,t);const n=null===(o=e.currentTarget.parentElement)||void 0===o?void 0:o.children[t];n instanceof SVGElement&&n.focus()}}:void 0,onFocus:f?e=>{c(l,u),o&&o(t);const n=e.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:f?e=>{o&&o(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:f?"pointer":"default",opacity:b,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},f&&e.createElement("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*t.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),v,x&&e.createElement(Se,null),e.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},t.label))),y+=26+7*t.label.length}),{items:p,offset:y}})(t,r,i,s,a,l,c,n,u,h);o+=p.offset+5,g.push(Object.assign(Object.assign({label:t.label},p),{offset:o})),d+=o+12});let p=Math.max(0,(o-d)/2);const y=[];return g.forEach((o,r)=>{const i=t[r];i.label&&(y.push(e.createElement("text",{key:"legend-text-"+r,transform:`translate(${p},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},i.label)),p+=16),y.push(e.createElement("g",{key:"legend-group-"+r,className:"legend-item",transform:`translate(${p},0)`},o.items)),p+=o.offset+5,t[r+1]&&y.push(e.createElement("line",{key:"legend-top-line legend-symbol-"+r,stroke:"gray",x1:p,y1:-8,x2:p,y2:n+0+8})),p+=12}),e.createElement("g",null,y)})({legendGroups:n||[],title:l,height:u,width:c,customClickBehavior:o,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:s,focusedGroupIndex:d,focusedItemIndex:p,onFocusedIndexChange:f,legendInteraction:a}),v=!(!o&&!r);return e.createElement("g",{role:v?"listbox":void 0,"aria-multiselectable":!(!v||"isolate"!==a&&(void 0!==a||null==s))||void 0,"aria-label":"Chart legend"},void 0!==l&&""!==l&&"vertical"===h&&e.createElement("text",{className:"legend-title",y:16,x:c/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)"},l),m)}function Ce(e){return"string"==typeof e?{type:e}:e}function Me({orient:t,config:n,values:o,scale:i,size:s,length:a}){const l=function(e){var t,n,o,r,i;return{type:e.type,bins:null!==(t=e.bins)&&void 0!==t?t:20,fill:null!==(n=e.fill)&&void 0!==n?n:"#4e79a7",fillOpacity:null!==(o=e.fillOpacity)&&void 0!==o?o:.5,stroke:null!==(r=e.stroke)&&void 0!==r?r:"none",strokeWidth:null!==(i=e.strokeWidth)&&void 0!==i?i:1}}(n),c="top"===t||"bottom"===t,u=r(()=>{if(0===o.length)return null;const n=i.domain(),r=s-8;if("boxplot"===l.type){const n=function(e){const t=[...e].sort((e,t)=>e-t),n=t.length;if(0===n)return null;const o=t[Math.floor(.25*n)],r=t[Math.floor(.5*n)],i=t[Math.floor(.75*n)],s=i-o;return{q1:o,median:r,q3:i,whiskerLow:Math.max(t[0],o-1.5*s),whiskerHigh:Math.min(t[n-1],i+1.5*s)}}(o);if(!n)return null;const{q1:s,median:a,q3:u,whiskerLow:h,whiskerHigh:d}=n,g=Math.min(.5*r,20),p=(r-g)/2+4;if(c){const n=i(s),o=i(u),r=i(a),c=i(h),y=i(d),f="top"===t?-1:1,m=0;return e.createElement("g",{"data-testid":"marginal-boxplot-"+t},e.createElement("line",{x1:c,y1:m+f*(p+g/2),x2:y,y2:m+f*(p+g/2),stroke:l.fill,strokeWidth:l.strokeWidth}),e.createElement("line",{x1:c,y1:m+f*p,x2:c,y2:m+f*(p+g),stroke:l.fill,strokeWidth:l.strokeWidth}),e.createElement("line",{x1:y,y1:m+f*p,x2:y,y2:m+f*(p+g),stroke:l.fill,strokeWidth:l.strokeWidth}),e.createElement("rect",{x:Math.min(n,o),y:"top"===t?m-p-g:m+p,width:Math.abs(o-n),height:g,fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}),e.createElement("line",{x1:r,y1:"top"===t?m-p-g:m+p,x2:r,y2:"top"===t?m-p:m+p+g,stroke:l.fill,strokeWidth:2}))}{const n=i(s),o=i(u),r=i(a),c=i(h),y=i(d),f="left"===t?-1:1,m=0;return e.createElement("g",{"data-testid":"marginal-boxplot-"+t},e.createElement("line",{x1:m+f*(p+g/2),y1:c,x2:m+f*(p+g/2),y2:y,stroke:l.fill,strokeWidth:l.strokeWidth}),e.createElement("line",{x1:m+f*p,y1:c,x2:m+f*(p+g),y2:c,stroke:l.fill,strokeWidth:l.strokeWidth}),e.createElement("line",{x1:m+f*p,y1:y,x2:m+f*(p+g),y2:y,stroke:l.fill,strokeWidth:l.strokeWidth}),e.createElement("rect",{x:"left"===t?m-p-g:m+p,y:Math.min(n,o),width:g,height:Math.abs(o-n),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}),e.createElement("line",{x1:"left"===t?m-p-g:m+p,y1:r,x2:"left"===t?m-p:m+p+g,y2:r,stroke:l.fill,strokeWidth:2}))}}const u=_().domain(n).thresholds(l.bins)(o);if(0===u.length)return null;const h=Math.max(...u.map(e=>e.length));if(0===h)return null;if("histogram"===l.type)return e.createElement("g",{"data-testid":"marginal-histogram-"+t},u.map((n,o)=>{if(null==n.x0||null==n.x1)return null;const s=n.length/h*r;if(c){const r=i(n.x0),a=i(n.x1)-i(n.x0);return e.createElement("rect",{key:o,x:r,y:"top"===t?-4-s:4,width:Math.max(a,.5),height:s,fill:l.fill,fillOpacity:l.fillOpacity,stroke:l.stroke,strokeWidth:l.strokeWidth})}{const r=i(n.x0),a=i(n.x1)-i(n.x0);return e.createElement("rect",{key:o,x:"left"===t?-4-s:4,y:Math.min(r,r+a),width:s,height:Math.abs(a),fill:l.fill,fillOpacity:l.fillOpacity,stroke:l.stroke,strokeWidth:l.strokeWidth})}}));if("violin"===l.type){const n=r/2+4,o=[];for(const e of u){if(null==e.x0||null==e.x1)continue;const s=e.length/h*(r/2),a=i((e.x0+e.x1)/2);o.push(c?`${a},${"top"===t?-(n-s):n-s}`:`${"left"===t?-(n-s):n-s},${a}`)}for(let e=u.length-1;e>=0;e--){const s=u[e];if(null==s.x0||null==s.x1)continue;const a=s.length/h*(r/2),l=i((s.x0+s.x1)/2);o.push(c?`${l},${"top"===t?-(n+a):n+a}`:`${"left"===t?-(n+a):n+a},${l}`)}return e.createElement("g",{"data-testid":"marginal-violin-"+t},e.createElement("polygon",{points:o.join(" "),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}))}if("ridgeline"===l.type){const n=[];if(c){const e=0,o=null!=u[0].x0?i(u[0].x0):0;n.push(`M${o},${e}`);for(const e of u){if(null==e.x0||null==e.x1)continue;const o=e.length/h*r,s=i((e.x0+e.x1)/2);n.push(`L${s},${"top"===t?-o-4:o+4}`)}const s=null!=u[u.length-1].x1?i(u[u.length-1].x1):a;n.push(`L${s},${e}`),n.push("Z")}else{const e=0,o=null!=u[0].x0?i(u[0].x0):0;n.push(`M${e},${o}`);for(const e of u){if(null==e.x0||null==e.x1)continue;const o=e.length/h*r,s=i((e.x0+e.x1)/2);n.push(`L${"left"===t?-o-4:o+4},${s}`)}const s=null!=u[u.length-1].x1?i(u[u.length-1].x1):a;n.push(`L${e},${s}`),n.push("Z")}return e.createElement("g",{"data-testid":"marginal-ridgeline-"+t},e.createElement("path",{d:n.join(" "),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}))}return null},[o,i,l,s,a,t,c,4]);return u?e.createElement("g",{className:"marginal-"+t,"data-testid":"marginal-"+t},u):null}function Pe(e,t=120,n=8){if(!e)return[];const o=Math.max(1,Math.floor(t/n)),r=e.split(/\s+/),i=[];let s="";for(const e of r)s&&s.length+1+e.length>o?(i.push(s),s=e):s=s?`${s} ${e}`:e;return s&&i.push(s),i}function _e(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 Le(t){const{x:n=0,y:o=0,dx:r,dy:i,nx:s,ny:a,note:l,connector:c,subject:u,type:h,color:d,className:g,disable:p,events:y={},"data-testid":f}=t,m=new Set(Array.isArray(p)?p:[]);let v=r||0,b=i||0;null!=s&&(v=s-n),null!=a&&(b=a-o);const x="string"==typeof h?h:"label";if("bracket"===x&&u&&0===v&&0===b)if(void 0!==u.width){v=u.width/2;const e=u.depth||30;b=e+(0>e?-5:5)}else if(void 0!==u.height){const e=u.depth||30;v=e+(0>e?-5:5),b=u.height/2}return e.createElement("g",Object.assign({className:("annotation "+(g||"")).trim(),transform:`translate(${n},${o})`,"data-testid":f},y),!m.has("connector")&&function(t,n,o,r,i,s){const a=[];let l=0,c=0;if("callout-circle"!==i&&"label"!==i||!(null==s?void 0:s.radius)){if("callout-rect"===i&&s){const e=s.width||0,o=s.height||0;if(e>0||o>0){const r=e/2,i=o/2,s=t-r,a=n-i;if(0!==s||0!==a){const t=Math.abs(s),n=Math.abs(a),u=e/2,h=o/2,d=t*h>n*u?u/t:h/n;l=r+s*d,c=i+a*d}}}else if("bracket"===i&&s){const e=s.width,t=s.height,n=s.depth||30;void 0!==e?(l=e/2,c=n):void 0!==t&&(l=n,c=t/2)}}else{const e=(s.radius||0)+(s.radiusPadding||0);if(e>0&&(0!==t||0!==n)){const o=Math.atan2(n,t);l=Math.cos(o)*e,c=Math.sin(o)*e}}if(Math.sqrt(Math.pow(t-l,2)+Math.pow(n-c,2))>.5&&(a.push(e.createElement("line",{key:"connector-line",x1:l,y1:c,x2:t,y2:n,stroke:r||"currentColor"})),"arrow"===(null==o?void 0:o.end))){const o=10,i=16/180*Math.PI,s=Math.atan2(n-c,t-l);a.push(e.createElement("path",{key:"connector-arrow",d:`M${l},${c}L${l+o*Math.cos(s+i)},${c+o*Math.sin(s+i)}L${l+o*Math.cos(s-i)},${c+o*Math.sin(s-i)}Z`,fill:r||"currentColor",stroke:"none"}))}return e.createElement("g",{className:"annotation-connector"},a)}(v,b,c,d,x,u),!m.has("subject")&&function(t,n,o,r,i){var s;const a=[];switch(t){case"callout-circle":{const t=((null==n?void 0:n.radius)||0)+((null==n?void 0:n.radiusPadding)||0);t>0&&a.push(e.createElement("circle",{key:"subject-circle",r:t,fill:"none",stroke:o||"currentColor"}));break}case"callout-rect":{const t=(null==n?void 0:n.width)||0,r=(null==n?void 0:n.height)||0;(t>0||r>0)&&a.push(e.createElement("rect",{key:"subject-rect",width:t,height:r,fill:"none",stroke:o||"currentColor"}));break}case"callout-custom":(null==n?void 0:n.custom)&&a.push(...Array.isArray(n.custom)?n.custom:[n.custom]);break;case"xy-threshold":{const t=r||0,s=i||0;if(void 0!==(null==n?void 0:n.x)){const r=(n.x||0)-t;a.push(e.createElement("line",{key:"threshold-line",x1:r,y1:(n.y1||0)-s,x2:r,y2:(n.y2||0)-s,stroke:o||"currentColor",strokeDasharray:"5,5"}))}else if(void 0!==(null==n?void 0:n.y)){const r=(n.y||0)-s;a.push(e.createElement("line",{key:"threshold-line",x1:(n.x1||0)-t,y1:r,x2:(n.x2||0)-t,y2:r,stroke:o||"currentColor",strokeDasharray:"5,5"}))}else void 0!==(null==n?void 0:n.x1)||void 0!==(null==n?void 0:n.x2)?a.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)||a.push(e.createElement("line",{key:"threshold-line",x1:0,y1:(n.y1||0)-s,x2:0,y2:(n.y2||0)-s,stroke:o||"currentColor",strokeDasharray:"5,5"}));break}case"bracket":{const t=null!==(s=null==n?void 0:n.width)&&void 0!==s?s:null==n?void 0:n.height;void 0!==t&&a.push(e.createElement("path",{key:"bracket-path",d:_e((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"},a)}(x,u,d,n,o),!m.has("note")&&function(t,n,o,r){if(!t)return e.createElement("g",{className:"annotation-note"});const{label:i,title:s,orientation:a,align:l,wrap:c=120,noWrap:u}=t;if(!i&&!s)return e.createElement("g",{className:"annotation-note"});let h=a;h||(h=Math.abs(n)>Math.abs(o)?"leftRight":"topBottom");let d=l;d&&"dynamic"!==d||(d="topBottom"===h?0>n?"right":"left":0>o?"bottom":"top");let g="start";"topBottom"===h?"right"===d?g="end":"middle"===d&&(g="middle"):g=0>n?"end":"start";const p=16,y=s?u?[s]:Pe(s,c):[],f=i?u?[i]:Pe(i,c):[],m="leftRight"===h?"end"===g?-4:4:0;let v=0;const b=[];y.length>0&&(b.push(e.createElement("text",{key:"annotation-note-title",className:"annotation-note-title",fill:r||void 0,textAnchor:g,fontWeight:"bold"},y.map((t,n)=>e.createElement("tspan",{key:n,x:m,dy:0===n?0:p},t)))),v=y.length*p),f.length>0&&b.push(e.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:r||void 0,textAnchor:g,y:v},f.map((t,n)=>e.createElement("tspan",{key:n,x:m,dy:0===n?0:p},t))));let x=null;if((s||i)&&(0!==n||0!==o))if("topBottom"===h){const t=Math.min(c,120);let n=0,o=t;"end"===g?(n=-t,o=0):"middle"===g&&(n=-t/2,o=t/2),x=e.createElement("line",{className:"note-line",x1:n,x2:o,y1:0,y2:0,stroke:r||"currentColor"})}else{const t=(y.length+f.length)*p+(f.length>0?p:0);let n=0,o=t;"bottom"===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:r||"currentColor"})}const k=Math.max(0,y.length+f.length-1)*p;let w=0;return"topBottom"===h?w=0>o?-(k+2):18:"leftRight"===h&&(w="middle"===d?-(k+p+(f.length>0&&y.length>0?2:0))/2+8:"bottom"===d||0>o?-(k+2):18),e.createElement("g",{className:"annotation-note",transform:`translate(${n},${o})`},e.createElement("g",{className:"annotation-note-content",transform:0!==w?`translate(0,${w})`:void 0},b),x)}(l,v,b,d))}function Be(t){var n,o;const{noteData:r}=t,{screenCoordinates:i}=r,s="string"==typeof r.type?r.type:"label",a=r.eventListeners||r.events||{};if(r.coordinates&&i){const t=r.nx||i[0][0]+(null!==(n=r.dx)&&void 0!==n?n:0),a=r.ny||i[0][1]+(null!==(o=r.dy)&&void 0!==o?o:0),l=i.map((n,o)=>{const i=Object.assign({},r,{note:0===o?r.note:{label:""},x:n[0],y:n[1],nx:t,ny:a});return e.createElement(Le,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+o},i,{type:s}))});return e.createElement("g",null,l)}const l=r.note||{title:"none",label:r.label};return e.createElement(Le,Object.assign({"data-testid":"semiotic-annotation",key:`${l.label}-${l.title}-${r.i}`,events:a},r,{type:s}))}const Ne={linear:D,monotoneX:F,monotoneY:I,step:T,stepAfter:W,stepBefore:$,basis:z,cardinal:H,catmullRom:N};function He(e,t){var n,o,r;const i=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.x)&&void 0!==o?o:null===(r=t.scales)||void 0===r?void 0:r.time;return i?null!=e.x?i(e.x):t.xAccessor&&null!=e[t.xAccessor]?i(e[t.xAccessor]):null:null}function ze(e,t){var n,o,r;const i=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.y)&&void 0!==o?o:null===(r=t.scales)||void 0===r?void 0:r.value;return i?null!=e.y?i(e.y):t.yAccessor&&null!=e[t.yAccessor]?i(e[t.yAccessor]):null:null}function $e(e,t,n){var o,r,i,s;const a=e.anchor||"fixed";if("latest"===a){if(null!=e.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let r=n.pointNodes.length-1;r>=0;r--){const i=n.pointNodes[r];if(i.pointId===e.pointId){const e={x:i.x,y:i.y};return null===(o=n.stickyPositionCache)||void 0===o||o.set(t,e),e}}const i=function(e){var t,n,o,r,i,s;const a=e.data;if(!a||0===a.length)return null;const l=a[a.length-1],c=null!==(n=null===(t=e.scales)||void 0===t?void 0:t.x)&&void 0!==n?n:null===(o=e.scales)||void 0===o?void 0:o.time,u=null!==(i=null===(r=e.scales)||void 0===r?void 0:r.y)&&void 0!==i?i:null===(s=e.scales)||void 0===s?void 0:s.value;if(!c||!u)return null;const h=l[e.xAccessor||"x"],d=l[e.yAccessor||"y"];return null==h||null==d?null:{x:c(h),y:u(d)}}(n);return i&&(null===(r=n.stickyPositionCache)||void 0===r||r.set(t,i)),i}let l=null,c=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(l=t.x,c=t.y)}if(null!=l&&null!=c||(l=He(e,n),c=ze(e,n)),null!=l&&null!=c)return null===(i=n.stickyPositionCache)||void 0===i||i.set(t,{x:l,y:c}),{x:l,y:c};if("sticky"===a){const e=null===(s=n.stickyPositionCache)||void 0===s?void 0:s.get(t);if(e)return e}return null}function We(e,t,n,o=50){return!(-o>e||e>(n.width||0)+o||-o>t||t>(n.height||0)+o)}function Te(e,t,n){if("left"===e||"right"===e){const o="left"===e?n:0,r="left"===e?-1:1,i=Math.ceil(t/8);let s="M0,"+o;for(let e=0;i>e;e++){const n=8*(e+1);s+=`L${Math.min(8*e+4,t)},${o+4*r}`,s+=`L${Math.min(n,t)},${o}`}return s}{const o="bottom"===e?0:t,r="bottom"===e?1:-1,i=Math.ceil(n/8);let s=`M${o},0`;for(let e=0;i>e;e++){const t=8*(e+1);s+=`L${o+4*r},${Math.min(8*e+4,n)}`,s+=`L${o},${Math.min(t,n)}`}return s}}function Ie(t){const{width:n,height:o,totalWidth:i,totalHeight:s,margin:a,scales:l,showAxes:c,axes:u,showGrid:h,xFormat:d,yFormat:g}=t,p=r(()=>{var e;if(!l)return[];const t=null==u?void 0:u.find(e=>"bottom"===e.orient),o=(null==t?void 0:t.tickFormat)||d||Fe,r=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;return l.x.ticks(Math.min(r,Math.max(2,Math.floor(n/70)))).map(e=>({value:e,pixel:l.x(e),label:o(e)}))},[l,u,d,n]),y=r(()=>{var e;if(!l)return[];const t=null==u?void 0:u.find(e=>"left"===e.orient),n=(null==t?void 0:t.tickFormat)||g||Fe,r=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;return l.y.ticks(Math.min(r,Math.max(2,Math.floor(o/30)))).map(e=>({value:e,pixel:l.y(e),label:n(e)}))},[l,u,g,o]),f=h&&l,m=c&&l;if(!f&&!m)return null;const v=null==u?void 0:u.find(e=>"bottom"===e.orient),b=null==u?void 0:u.find(e=>"left"===e.orient),x=m&&(!v||!1!==v.baseline),k=m&&(!b||!1!==b.baseline),w=(null==v?void 0:v.jaggedBase)||!1,A=(null==b?void 0:b.jaggedBase)||!1,S="var(--semiotic-border, #ccc)";return e.createElement("svg",{width:i,height:s,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},e.createElement("g",{transform:`translate(${a.left},${a.top})`},f&&e.createElement("g",{className:"stream-grid"},p.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})),y.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}))),x&&!w&&e.createElement("line",{x1:0,y1:o,x2:n,y2:o,stroke:S,strokeWidth:1}),w&&e.createElement("path",{d:Te("bottom",n,o),fill:"none",stroke:S,strokeWidth:1}),k&&!A&&e.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:S,strokeWidth:1}),A&&e.createElement("path",{d:Te("left",n,o),fill:"none",stroke:S,strokeWidth:1})))}function Fe(e){return Math.round(100*e)/100+""}function De(e,t){return e instanceof Date&&(!(t&&t instanceof Date)||e.getFullYear()!==t.getFullYear()||e.getMonth()!==t.getMonth()||e.getDate()!==t.getDate())}function Re(n){var o,i;const{width:s,height:a,totalWidth:l,totalHeight:c,margin:u,scales:h,showAxes:d,axes:g,xLabel:p,yLabel:y,xFormat:f,yFormat:m,showGrid:v,title:b,legend:x,legendHoverBehavior:k,legendClickBehavior:w,legendHighlightedCategory:A,legendIsolatedCategories:S,legendPosition:O="right",foregroundGraphics:E,marginalGraphics:j,xValues:C,yValues:M,annotations:P,svgAnnotationRules:_,xAccessor:N,yAccessor:H,annotationData:z,pointNodes:$,curve:W,underlayRendered:T,children:I}=n,F=r(()=>{var e;if(!d||!h)return[];const t=null==g?void 0:g.find(e=>"bottom"===e.orient),n=(null==t?void 0:t.tickFormat)||f||Fe,o=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;return h.x.ticks(Math.min(o,Math.max(2,Math.floor(s/70)))).map(e=>({value:e,pixel:h.x(e),label:n(e)}))},[d,h,g,f,s]),R=r(()=>{var e;if(!d||!h)return[];const t=null==g?void 0:g.find(e=>"left"===e.orient),n=(null==t?void 0:t.tickFormat)||m||Fe,o=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;return h.y.ticks(Math.min(o,Math.max(2,Math.floor(a/30)))).map(e=>({value:e,pixel:h.y(e),label:n(e)}))},[d,h,g,m,a]),G=t(new Map),q=t(null!==(o=null==P?void 0:P.length)&&void 0!==o?o:0),X=null!==(i=null==P?void 0:P.length)&&void 0!==i?i:0;q.current!==X&&(q.current=X,G.current=new Map);const V=r(()=>{if(!P||0===P.length)return null;const t=function(t,n,o){var r,i,s,a,l,c,u,h,d,g,p,y,f,m,v,b,x,k,w,A,S,O,E,j,C,M,P,_,N,H,z,$,W,T,I,F,R,G,q,X,V,Q,K,U;switch(t.type){case"label":{const r=$e(t,n,o);if(!r)return null;const{x:i,y:s}=r;return We(i,s,o)?e.createElement(Be,{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":{const r=$e(t,n,o);if(!r)return null;const{x:i,y:s}=r;return We(i,s,o)?e.createElement(Be,{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 r=He(t,o);if(null==r)return null;const i=t.color||"#f97316";return e.createElement("g",{key:"ann-"+n},e.createElement("line",{x1:r,y1:0,x2:r,y2:o.height||0,stroke:i,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&e.createElement("text",{x:r+4,y:12,fill:i,fontSize:12,fontWeight:"bold"},t.label))}case"y-threshold":{const r=ze(t,o);if(null==r)return null;const i=t.color||"#f97316";return e.createElement("g",{key:"ann-"+n},e.createElement("line",{x1:0,y1:r,x2:o.width||0,y2:r,stroke:i,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&e.createElement("text",{x:(o.width||0)-4,y:r-4,textAnchor:"end",fill:i,fontSize:12,fontWeight:"bold"},t.label))}case"enclose":{const r=(t.coordinates||[]).map(e=>({x:He(Object.assign(Object.assign({},e),{type:"point"}),o),y:ze(Object.assign(Object.assign({},e),{type:"point"}),o),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>r.length)return null;const i=L(r),s=t.padding||10;return e.createElement("g",{key:"ann-"+n},e.createElement("circle",{cx:i.x,cy:i.y,r:i.r+s,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&e.createElement("text",{x:i.x,y:i.y-i.r-s-4,textAnchor:"middle",fill:t.color||"#666",fontSize:12},t.label))}case"rect-enclose":{const r=(t.coordinates||[]).map(e=>({x:He(Object.assign(Object.assign({},e),{type:"point"}),o),y:ze(Object.assign(Object.assign({},e),{type:"point"}),o)})).filter(e=>null!=e.x&&null!=e.y);if(2>r.length)return null;const i=t.padding||10,s=r.map(e=>e.x),a=r.map(e=>e.y),l=Math.min(...s)-i,c=Math.max(...s)+i,u=Math.min(...a)-i,h=Math.max(...a)+i;return e.createElement("g",{key:"ann-"+n},e.createElement("rect",{x:l,y:u,width:c-l,height:h-u,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&e.createElement("text",{x:(l+c)/2,y:u-4,textAnchor:"middle",fill:t.color||"#666",fontSize:12},t.label))}case"highlight":{const r=o.data||[],i="function"==typeof t.filter?r.filter(t.filter):t.field&&null!=t.value?r.filter(e=>e[t.field]===t.value):[],s=t.style||{stroke:t.color||"#f97316",strokeWidth:2,fill:"none"};return e.createElement("g",{key:"ann-"+n},i.map((n,r)=>{const i=He(n,o),a=ze(n,o);return null==i||null==a?null:e.createElement("circle",Object.assign({key:"hl-"+r,cx:i,cy:a,r:t.r||6},s))}))}case"bracket":{const r=He(t,o),i=ze(t,o);return e.createElement(Be,{key:"ann-"+n,noteData:{x:null!=r?r:0,y:null!=i?i:0,dx:t.dx||0,dy:t.dy||0,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"bracket",subject:{type:t.bracketType||"curly",width:t.width,height:t.height,depth:t.depth||30},color:t.color}})}case"trend":{const h=o.data||[];if(2>h.length)return null;const d=o.xAccessor||"x",g=o.yAccessor||"y",p=h.map(e=>[e[d],e[g]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>p.length)return null;const y=null!==(i=null===(r=o.scales)||void 0===r?void 0:r.x)&&void 0!==i?i:null===(s=o.scales)||void 0===s?void 0:s.time,f=null!==(l=null===(a=o.scales)||void 0===a?void 0:a.y)&&void 0!==l?l:null===(c=o.scales)||void 0===c?void 0:c.value;if(!y||!f)return null;const m=t.method||"linear";let v;v="loess"===m?function(e,t=.3){const n=e.length;if(2>n)return e.slice();const o=e.slice().sort((e,t)=>e[0]-t[0]),r=o.map(e=>e[0]),i=o.map(e=>e[1]),s=Math.max(2,Math.ceil(t*n)),a=[];for(let e=0;n>e;e++){const t=r[e],o=r.map(e=>Math.abs(e-t)),l=o.slice().sort((e,t)=>e-t)[Math.min(s-1,n-1)]||1,c=[];for(let e=0;n>e;e++){const t=0===l?0:o[e]/l;c[e]=1>t?Math.pow(1-Math.pow(t,3),3):0}let u=0,h=0,d=0,g=0,p=0;for(let e=0;n>e;e++){const t=c[e];0!==t&&(u+=t,h+=t*r[e],d+=t*i[e],g+=t*r[e]*r[e],p+=t*r[e]*i[e])}if(0===u){a.push([t,i[e]]);continue}const y=u*g-h*h;if(1e-12>Math.abs(y))a.push([t,d/u]);else{const e=(u*p-h*d)/y;a.push([t,(d-e*h)/u+e*t])}}return a}(p,null!==(u=t.bandwidth)&&void 0!==u?u:.3):("polynomial"===m?Y.polynomial(p,{order:t.order||2}):Y.linear(p)).points;const b=v.map(([e,t])=>`${y(e)},${f(t)}`).join(" "),x=t.color||"#6366f1";return e.createElement("g",{key:"ann-"+n},e.createElement("polyline",{points:b,fill:"none",stroke:x,strokeWidth:t.strokeWidth||2,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&e.createElement("text",{x:y(v[v.length-1][0])+4,y:f(v[v.length-1][1])-4,fill:x,fontSize:11},t.label))}case"band":{const r=null!==(d=null===(h=o.scales)||void 0===h?void 0:h.y)&&void 0!==d?d:null===(g=o.scales)||void 0===g?void 0:g.value,i=null!==(p=null==r?void 0:r(t.y0))&&void 0!==p?p:0,s=null!==(y=null==r?void 0:r(t.y1))&&void 0!==y?y:o.height||0;return e.createElement("g",{key:"ann-"+n},e.createElement("rect",{x:0,y:Math.min(i,s),width:o.width||0,height:Math.abs(s-i),fill:t.fill||"#6366f1",fillOpacity:t.fillOpacity||.1}),t.label&&e.createElement("text",{x:(o.width||0)-4,y:Math.min(i,s)-4,textAnchor:"end",fill:t.color||"#6366f1",fontSize:11},t.label))}case"envelope":{const r=o.data||[];if(2>r.length)return null;const i=o.xAccessor||"x",s=null!==(m=null===(f=o.scales)||void 0===f?void 0:f.x)&&void 0!==m?m:null===(v=o.scales)||void 0===v?void 0:v.time,a=null!==(x=null===(b=o.scales)||void 0===b?void 0:b.y)&&void 0!==x?x:null===(k=o.scales)||void 0===k?void 0:k.value;if(!s||!a)return null;const l=t.upperAccessor||"upperBounds",c=t.lowerAccessor||"lowerBounds",u=t.filter,h=r.filter(e=>null!=e[l]&&null!=e[c]&&!(u&&!u(e))).sort((e,t)=>e[i]-t[i]);if(2>h.length)return null;const d=Ne[o.curve||"linear"]||D,g=B().x(e=>s(e[i])).y0(e=>a(e[c])).y1(e=>a(e[l])).curve(d)(h);if(!g)return null;const p=t.fill||"#6366f1";return e.createElement("g",{key:"ann-"+n},e.createElement("path",{d:g,fill:p,fillOpacity:null!==(w=t.fillOpacity)&&void 0!==w?w:.15,stroke:"none"}),t.label&&h.length>0&&e.createElement("text",{x:s(h[h.length-1][i])+4,y:a(h[h.length-1][l])-4,fill:p,fontSize:11},t.label))}case"anomaly-band":{const r=o.data||[];if(2>r.length)return null;const i=o.yAccessor||"y",s=null!==(S=null===(A=o.scales)||void 0===A?void 0:A.x)&&void 0!==S?S:null===(O=o.scales)||void 0===O?void 0:O.time,a=null!==(j=null===(E=o.scales)||void 0===E?void 0:E.y)&&void 0!==j?j:null===(C=o.scales)||void 0===C?void 0:C.value;if(!s||!a)return null;const l=r.map(e=>e[i]).filter(e=>null!=e&&isFinite(e));if(2>l.length)return null;const c=l.reduce((e,t)=>e+t,0)/l.length,u=l.reduce((e,t)=>e+Math.pow(t-c,2),0)/l.length,h=Math.sqrt(u),d=null!==(M=t.threshold)&&void 0!==M?M:2,g=c-d*h,p=!1!==t.showBand,y=t.fill||"#6366f1",f=null!==(P=t.fillOpacity)&&void 0!==P?P:.1,m=t.anomalyColor||"#ef4444",v=null!==(_=t.anomalyRadius)&&void 0!==_?_:6,b=a(c+d*h),x=a(g),k=r.filter(e=>{const t=e[i];return null!=t&&Math.abs(t-c)>d*h});return e.createElement("g",{key:"ann-"+n},p&&e.createElement("rect",{x:0,y:Math.min(b,x),width:o.width||0,height:Math.abs(x-b),fill:y,fillOpacity:f}),k.map((t,n)=>{const r=He(t,o),i=ze(t,o);return null==r||null==i?null:e.createElement("circle",{key:"anomaly-"+n,cx:r,cy:i,r:v,fill:m,fillOpacity:.7,stroke:m,strokeWidth:1.5})}),t.label&&e.createElement("text",{x:(o.width||0)-4,y:Math.min(b,x)-4,textAnchor:"end",fill:y,fontSize:11},t.label))}case"forecast":{const r=o.data||[];if(3>r.length)return null;const i=o.xAccessor||"x",s=o.yAccessor||"y",a=null!==(H=null===(N=o.scales)||void 0===N?void 0:N.x)&&void 0!==H?H:null===(z=o.scales)||void 0===z?void 0:z.time,l=null!==(W=null===($=o.scales)||void 0===$?void 0:$.y)&&void 0!==W?W:null===(T=o.scales)||void 0===T?void 0:T.value;if(!a||!l)return null;const c=r.map(e=>[e[i],e[s]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]);if(3>c.length)return null;let u;if("polynomial"===(t.method||"linear")){const e=Y.polynomial(c,{order:t.order||2}).equation;u=t=>e.reduce((e,n,o)=>e+n*Math.pow(t,o),0)}else{const e=c.length;let t=0,n=0,o=0,r=0;for(const[e,i]of c)t+=e,n+=i,o+=e*e,r+=e*i;const i=e*o-t*t;if(1e-12>Math.abs(i))return null;const s=(e*r-t*n)/i,a=(n-s*t)/e;u=e=>a+s*e}const h=c.length,d=c.map(([e,t])=>t-u(e)).reduce((e,t)=>e+t*t,0),g=Math.sqrt(d/Math.max(h-2,1)),p=c.reduce((e,t)=>e+t[0],0)/h,y=c.reduce((e,t)=>e+Math.pow(t[0]-p,2),0),f=null!==(I=t.confidence)&&void 0!==I?I:.95,m=.99>f?.95>f?.9>f?1:1.645:1.96:2.576,v=null!==(F=t.steps)&&void 0!==F?F:5,b=c[h-1][0],x=(b-c[0][0])/Math.max(h-1,1),k=[];for(let e=1;v>=e;e++)k.push(b+e*x);const w=[];for(const e of k){const t=u(e),n=g*Math.sqrt(1+1/h+(y>0?Math.pow(e-p,2)/y:0))*m;w.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const A=`M${w.map(e=>`${a(e.x)},${l(e.yUpper)}`).join(" L")} L${w.slice().reverse().map(e=>`${a(e.x)},${l(e.yLower)}`).join(" L")} Z`,S=w.map(e=>`${a(e.x)},${l(e.yCenter)}`).join(" "),O=`${a(b)},${l(u(b))}`,E=t.strokeColor||"#6366f1";return e.createElement("g",{key:"ann-"+n},e.createElement("path",{d:A,fill:t.fill||"#6366f1",fillOpacity:null!==(R=t.fillOpacity)&&void 0!==R?R:.15,stroke:"none"}),e.createElement("polyline",{points:`${O} ${S}`,fill:"none",stroke:E,strokeWidth:null!==(G=t.strokeWidth)&&void 0!==G?G:2,strokeDasharray:null!==(q=t.strokeDasharray)&&void 0!==q?q:"6,3"}),t.label&&w.length>0&&e.createElement("text",{x:a(w[w.length-1].x)+4,y:l(w[w.length-1].yCenter)-4,fill:E,fontSize:11},t.label))}case"widget":{let r=null,i=null;if(null!=t.px&&null!=t.py)r=t.px,i=t.py;else{const e=$e(t,n,o);if(!e)return null;r=e.x,i=e.y}if(null==r||null==i)return null;if(!We(r,i,o))return null;const s=null!==(X=t.dx)&&void 0!==X?X:0,a=null!==(V=t.dy)&&void 0!==V?V:0,l=null!==(Q=t.width)&&void 0!==Q?Q:32,c=null!==(K=t.height)&&void 0!==K?K:32,u=null!==(U=t.content)&&void 0!==U?U:e.createElement("span",{style:{fontSize:18,cursor:"default"},title:t.label||"Info"},"ℹ️");return e.createElement("foreignObject",{key:"ann-"+n,x:r+s-l/2,y:i+a-c/2,width:l,height:c,style:{overflow:"visible",pointerEvents:"auto"}},e.createElement("div",{style:{width:l,height:c,display:"flex",alignItems:"center",justifyContent:"center"}},u))}case"text":{const r=$e(t,n,o);if(!r)return null;const{x:i,y:s}=r;return e.createElement("text",{key:"ann-text-"+n,x:i+(t.dx||0),y:s+(t.dy||0),fill:t.color||"var(--semiotic-text, #333)",fontSize:t.fontSize||11,dominantBaseline:"middle",style:{fontFamily:"inherit"}},t.label)}default:return null}},n={scales:h?{x:h.x,y:h.y,time:h.x,value:h.y}:null,timeAxis:"x",xAccessor:N,yAccessor:H,width:s,height:a,data:z,frameType:"xy",pointNodes:$,curve:W,stickyPositionCache:G.current};return P.map((e,o)=>{if(_){const r=_(e,o,n);return null!=r?r:t(e,o,n)}return t(e,o,n)}).filter(Boolean)},[P,_,s,a,N,H,z,h,$,W]);return d||b||x||E||j||V&&V.length>0||v||I?e.createElement("svg",{role:"img",width:l,height:c,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},e.createElement("title",null,"string"==typeof b?b:"XY Chart"),e.createElement("desc",null,"string"==typeof b?b+" — XY data visualization":"XY data visualization"),e.createElement("g",{transform:`translate(${u.left},${u.top})`},v&&h&&!T&&e.createElement("g",{className:"stream-grid"},F.map((t,n)=>e.createElement("line",{key:"xgrid-"+n,x1:t.pixel,y1:0,x2:t.pixel,y2:a,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1})),R.map((t,n)=>e.createElement("line",{key:"ygrid-"+n,x1:0,y1:t.pixel,x2:s,y2:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),d&&h&&(()=>{const t=null==g?void 0:g.find(e=>"left"===e.orient),n=null==g?void 0:g.find(e=>"bottom"===e.orient),o=!t||!1!==t.baseline,r=(null==t?void 0:t.jaggedBase)||!1,i=(null==n?void 0:n.jaggedBase)||!1,l=null==n?void 0:n.landmarkTicks,c=null==t?void 0:t.landmarkTicks,h="var(--semiotic-border, #ccc)",d="var(--semiotic-text-secondary, #666)",f="var(--semiotic-text, #333)";return e.createElement("g",{className:"stream-axes"},!T&&(!n||!1!==n.baseline)&&!i&&e.createElement("line",{x1:0,y1:a,x2:s,y2:a,stroke:h,strokeWidth:1}),!T&&i&&e.createElement("path",{d:Te("bottom",s,a),fill:"none",stroke:h,strokeWidth:1}),F.map((t,n)=>{const o=!!l&&("function"==typeof l?l(t.value,n):De(t.value,n>0?F[n-1].value:void 0));return e.createElement("g",{key:"xtick-"+n,transform:`translate(${t.pixel},${a})`},e.createElement("line",{y2:5,stroke:h,strokeWidth:1}),e.createElement("text",{y:18,textAnchor:"middle",fontSize:o?11:10,fontWeight:o?600:400,fill:d,style:{userSelect:"none"}},t.label))}),p&&e.createElement("text",{x:s/2,y:a+40,textAnchor:"middle",fontSize:12,fill:f,style:{userSelect:"none"}},p),!T&&o&&!r&&e.createElement("line",{x1:0,y1:0,x2:0,y2:a,stroke:h,strokeWidth:1}),!T&&r&&e.createElement("path",{d:Te("left",s,a),fill:"none",stroke:h,strokeWidth:1}),R.map((t,n)=>{const o=!!c&&("function"==typeof c?c(t.value,n):De(t.value,n>0?R[n-1].value:void 0));return e.createElement("g",{key:"ytick-"+n,transform:`translate(0,${t.pixel})`},e.createElement("line",{x2:-5,stroke:h,strokeWidth:1}),e.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:o?11:10,fontWeight:o?600:400,fill:d,style:{userSelect:"none"}},t.label))}),y&&e.createElement("text",{x:15-u.left,y:a/2,textAnchor:"middle",fontSize:12,fill:f,transform:`rotate(-90, ${15-u.left}, ${a/2})`,style:{userSelect:"none"}},y))})(),V,j&&h&&C&&M&&e.createElement(e.Fragment,null,j.top&&e.createElement("g",{transform:"translate(0, 0)"},e.createElement(Me,{orient:"top",config:Ce(j.top),values:C,scale:h.x,size:u.top,length:s})),j.bottom&&e.createElement("g",{transform:`translate(0, ${a})`},e.createElement(Me,{orient:"bottom",config:Ce(j.bottom),values:C,scale:h.x,size:u.bottom,length:s})),j.left&&e.createElement("g",{transform:"translate(0, 0)"},e.createElement(Me,{orient:"left",config:Ce(j.left),values:M,scale:h.y,size:u.left,length:a})),j.right&&e.createElement("g",{transform:`translate(${s}, 0)`},e.createElement(Me,{orient:"right",config:Ce(j.right),values:M,scale:h.y,size:u.right,length:a}))),E,I),b&&e.createElement("text",{x:l/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof b?b:null),function(t){const{legend:n,totalWidth:o,totalHeight:r,margin:i,legendPosition:s="right",title:a,legendHoverBehavior:l,legendClickBehavior:c,legendHighlightedCategory:u,legendIsolatedCategories:h,legendInteraction:d}=t;if(!n)return null;const g="top"===s||"bottom"===s;let p,y;return"left"===s?(p=4,y=i.top):"top"===s?(p=0,y=a?32:8):"bottom"===s?(p=0,y=r-i.bottom+50):(p=o-i.right+10,y=i.top),e.createElement("g",{transform:`translate(${p}, ${y})`},"object"==typeof(f=n)&&null!==f&&"gradient"in f?e.createElement(Ee,{config:n.gradient,orientation:g?"horizontal":"vertical",width:g?o:100}):function(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}(n)?e.createElement(je,{legendGroups:n.legendGroups,title:"",width:g?o:100,orientation:g?"horizontal":"vertical",customHoverBehavior:l,customClickBehavior:c,highlightedCategory:u,isolatedCategories:h,legendInteraction:d}):n);var f}({legend:x,totalWidth:l,totalHeight:c,margin:u,legendPosition:O,title:b,legendHoverBehavior:k,legendClickBehavior:w,legendHighlightedCategory:A,legendIsolatedCategories:S})):null}const Ge="undefined"==typeof window||"undefined"==typeof document,Ye={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function qe(e,t){if(!e||0===e.length)return t+", empty";const n={};for(const t of e)n[t.type]=(n[t.type]||0)+1;const o=[],r={point:"points",line:"lines",area:"areas",rect:"bars",heatcell:"cells",circle:"nodes",candlestick:"candlesticks"},i=["point","line","area","rect","heatcell","circle","candlestick"],s=Object.keys(n).sort((e,t)=>{const n=i.indexOf(e),o=i.indexOf(t);return(-1===n?999:n)-(-1===o?999:o)});for(const e of s)o.push(`${n[e]} ${r[e]||e}`);return`${t}, ${o.join(", ")}`}function Xe({scene:t,chartType:n}){var o,r,i,s;const a=[];for(const e of t){if(a.length>=50)break;"point"===e.type?a.push({label:"Point",values:{x:Math.round(100*e.x)/100+"",y:Math.round(100*e.y)/100+""}}):"rect"===e.type?a.push({label:"Bar",values:{category:(null===(o=e.datum)||void 0===o?void 0:o.category)||"",value:Math.round(100*(null!==(i=null===(r=e.datum)||void 0===r?void 0:r.value)&&void 0!==i?i:0))/100+""}}):"heatcell"===e.type&&a.push({label:"Cell",values:{x:Math.round(100*e.x)/100+"",y:Math.round(100*e.y)/100+"",value:Math.round(100*(null!==(s=e.value)&&void 0!==s?s:0))/100+""}})}if(0===a.length)return null;const l=new Set;for(const e of a)for(const t of Object.keys(e.values))l.add(t);const c=Array.from(l);return e.createElement("table",{style:Ye,role:"table","aria-label":"Data table for "+n},e.createElement("thead",null,e.createElement("tr",null,c.map(t=>e.createElement("th",{key:t},t)))),e.createElement("tbody",null,a.map((t,n)=>e.createElement("tr",{key:n},c.map(n=>{var o;return e.createElement("td",{key:n},null!==(o=t.values[n])&&void 0!==o?o:"")}))),t.length>50&&e.createElement("tr",null,e.createElement("td",{colSpan:c.length},"...and ",t.length-50," more items"))))}function Ve({hoverPoint:t}){let n="";if(t){const e=t.data||t;n="object"==typeof e?"Focused on data point: "+Object.entries(e).filter(([,e])=>"object"!=typeof e&&"function"!=typeof e).map(([e,t])=>`${e}: ${t}`).join(", "):"Focused on data point: "+e}return e.createElement("div",{"aria-live":"polite","aria-atomic":"true",style:Ye},n)}function Qe(n){const o=i(null),c=Ke(n);return[function({children:t}){const i=r(()=>Ke(n),[]);return e.createElement(o.Provider,{value:i,children:t})},e=>{var n;const r=null!==(n=s(o))&&void 0!==n?n:c,i=t(e);i.current=e;const u=a(()=>i.current(r.getState()),[r]),h=a(()=>i.current(r.getState()),[r]);return l(r.subscribe,u,h)}]}function Ke(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)}}}const Ue={mode:"light",colors:{primary:"#00a2ce",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",background:"transparent",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},Ze={mode:"dark",colors:{primary:"#4fc3f7",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",background:"#1a1a2e",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},[Je,et]=Qe(e=>({theme:Ue,setTheme(t){e(e=>"light"===t?{theme:Ue}:"dark"===t?{theme:Ze}:{theme:Object.assign(Object.assign(Object.assign({},e.theme),t),{colors:Object.assign(Object.assign({},e.theme.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.theme.typography),t.typography||{})})})}}));function tt(e,t,n,o){const r=e.getContext("2d");if(!r)return null;const i=t[0]*o,s=t[1]*o,a=t[0]+"px",l=t[1]+"px";return e.style.width!==a&&(e.style.width=a),e.style.height!==l&&(e.style.height=l),e.width===i&&e.height===s||(e.width=i,e.height=s),r.setTransform(o,0,0,o,0,0),r.translate(n.left,n.top),r}function nt(e){switch(e){case"monotoneX":return F;case"monotoneY":return I;case"cardinal":return H;case"catmullRom":return N;case"step":return T;case"stepBefore":return $;case"stepAfter":return W;case"basis":return z;case"natural":return G;default:return null}}function ot(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 rt(e,t,n,o,r,i){if(2>t.length)return;const s=[0];for(let e=1;t.length>e;e++){const n=t[e][0]-t[e-1][0],o=t[e][1]-t[e-1][1];s.push(s[e-1]+Math.sqrt(n*n+o*o))}const a=s[s.length-1];if(0===a)return;const l=Math.min(.2*a,40);e.strokeStyle=n,e.lineWidth=o,e.lineCap=i;for(let n=0;t.length-1>n;n++){const o=(s[n]+s[n+1])/2;let i=r;l>o&&(i*=o/l),l>a-o&&(i*=(a-o)/l),e.globalAlpha=Math.max(0,i),e.beginPath(),e.moveTo(t[n][0],t[n][1]),e.lineTo(t[n+1][0],t[n+1][1]),e.stroke()}}function it(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function st(e,t,n=.3){it(t)&&(e.globalAlpha=t._pulseIntensity*n,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h))}function at(e,t,n=.6){var o,r,i,s,a;if(!it(t))return;const l=null!==(o=t._pulseGlowRadius)&&void 0!==o?o:4,c=t.r+l*t._pulseIntensity,u=null!==(i=null!==(r=t.cx)&&void 0!==r?r:t.x)&&void 0!==i?i:0,h=null!==(a=null!==(s=t.cy)&&void 0!==s?s:t.y)&&void 0!==a?a:0;e.beginPath(),e.arc(u,h,c,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=t._pulseIntensity*n,e.stroke()}function lt(e,t,n,o=.35){it(t)&&(e.globalAlpha=t._pulseIntensity*o,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fill())}function ct(e){switch(e){case"monotoneX":return F;case"monotoneY":return I;case"cardinal":return H;case"catmullRom":return N;case"step":return T;case"stepBefore":return $;case"stepAfter":return W;case"basis":return z;case"natural":return G;default:return null}}function ut(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]}function ht(e,t){const n=ct(t.curve);if(!n||2>t.topPath.length||2>t.bottomPath.length){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]);for(let n=t.bottomPath.length-1;n>=0;n--)e.lineTo(t.bottomPath[n][0],t.bottomPath[n][1]);e.closePath()}else{const o=B().x(e=>e[0]).y0((e,n)=>t.bottomPath[n][1]).y1(e=>e[1]).curve(n).context(e);e.beginPath(),o(t.topPath)}}const dt=(e,t,n,o)=>{var r,i,s;const a=t.filter(e=>"area"===e.type);for(const t of a){if(2>t.topPath.length)continue;const n=t.style.fill||"#4e79a7",o=t._decayOpacities;if(o&&o.length===t.topPath.length){const i=null!==(r=t.style.fillOpacity)&&void 0!==r?r:.7;e.fillStyle=n;for(let n=0;t.topPath.length-1>n;n++)e.globalAlpha=.5*(o[n]+o[n+1])*i,e.beginPath(),e.moveTo(t.topPath[n][0],t.topPath[n][1]),e.lineTo(t.topPath[n+1][0],t.topPath[n+1][1]),e.lineTo(t.bottomPath[n+1][0],t.bottomPath[n+1][1]),e.lineTo(t.bottomPath[n][0],t.bottomPath[n][1]),e.closePath(),e.fill();if(t.style.stroke&&"none"!==t.style.stroke){e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);for(let n=0;t.topPath.length-1>n;n++)e.globalAlpha=.5*(o[n]+o[n+1]),e.beginPath(),e.moveTo(t.topPath[n][0],t.topPath[n][1]),e.lineTo(t.topPath[n+1][0],t.topPath[n+1][1]),e.stroke()}e.globalAlpha=1;continue}const a=null!==(i=t.style.opacity)&&void 0!==i?i:1;if(ht(e,t),t.fillGradient){let o=1/0;for(const e of t.topPath)o>e[1]&&(o=e[1]);let r=-1/0;for(const e of t.bottomPath)e[1]>r&&(r=e[1]);const i=ut(n),s=t.fillGradient.topOpacity,l=t.fillGradient.bottomOpacity,c=e.createLinearGradient(0,o,0,r);c.addColorStop(0,`rgba(${i[0]},${i[1]},${i[2]},${s})`),c.addColorStop(1,`rgba(${i[0]},${i[1]},${i[2]},${l})`),e.fillStyle=c,e.globalAlpha=a}else{const o=null!==(s=t.style.fillOpacity)&&void 0!==s?s:.7;e.globalAlpha=o*a,e.fillStyle=n}if(e.fill(),t._pulseIntensity&&t._pulseIntensity>0&&(ht(e,t),lt(e,t)),t.style.stroke&&"none"!==t.style.stroke){e.globalAlpha=a,e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);const n=ct(t.curve);if(e.beginPath(),n)R().x(e=>e[0]).y(e=>e[1]).curve(n).context(e)(t.topPath);else{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}},gt=(e,t,n,o)=>{var r;const i=t.filter(e=>"point"===e.type);e.save();try{for(const t of i){e.beginPath(),e.arc(t.x,t.y,t.r,0,2*Math.PI);const n=null!==(r=t.style.opacity)&&void 0!==r?r:t.style.fillOpacity;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()),at(e,t),e.globalAlpha=1}}finally{e.restore()}},pt=(e,t,n,o)=>{const r=t.filter(e=>"rect"===e.type);for(const t of r)null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.icon?yt(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))),st(e,t),e.globalAlpha=1};function yt(e,t){const n=t.style.icon,o=t.style.iconPadding||2,r=Math.min(t.w,t.h)-o;if(0>=r)return;const i=t.h>t.w;if(e.save(),e.beginPath(),e.rect(t.x,t.y,t.w,t.h),e.clip(),i){const i=r+o,s=t.x+(t.w-r)/2;for(let o=t.y+t.h-r;o>=t.y-r;o-=i)e.drawImage(n,s,o,r,r)}else{const i=r+o,s=t.y+(t.h-r)/2;for(let o=t.x;t.x+t.w>o;o+=i)e.drawImage(n,o,s,r,r)}e.restore()}function ft(e){const[t,n,o]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*n+.114*o>128?"#000":"#fff"}function mt(e){return Number.isInteger(e)?e+"":100>Math.abs(e)?1>Math.abs(e)?e.toPrecision(3):e.toFixed(1):e.toFixed(0)}const vt={line:[dt,(e,t,n,o)=>{var r,i;const s=t.filter(e=>"line"===e.type);for(const a of s){if(2>a.path.length)continue;const l=a.style.stroke||"#007bff",c=a.style.strokeWidth||2,u=a.colorThresholds,h=a.rawValues;if(e.setLineDash(a.style.strokeDasharray?a.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=a.style.opacity&&(e.globalAlpha=a.style.opacity),e.lineWidth=c,e.lineCap=a.style.strokeLinecap||"butt",a.style._edgeFade){const y=null!==(r=a.style.opacity)&&void 0!==r?r:1;rt(e,a.path,l,c,y,a.style.strokeLinecap||"butt"),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt";continue}const d=nt(a.curve),g=u&&u.length>0&&h&&h.length===a.path.length,p=a._decayOpacities;if(p&&p.length===a.path.length&&!g){e.strokeStyle=l;const f=null!==(i=a.style.opacity)&&void 0!==i?i:1;for(let m=0;a.path.length-1>m;m++)e.globalAlpha=.5*(p[m]+p[m+1])*f,e.beginPath(),e.moveTo(a.path[m][0],a.path[m][1]),e.lineTo(a.path[m+1][0],a.path[m+1][1]),e.stroke()}else if(g){let v=null,b=null,x=null,k=null,w=!1;function A(t,n,o){e.beginPath(),e.strokeStyle=t,e.moveTo(n,o),w=!0}function S(){w&&(e.stroke(),w=!1)}for(let O=0;a.path.length>O;O++){const[E,j]=a.path[O],C=h[O],M=ot(C,u,l);if(null!==v&&null!==k&&null!==x){if(M===k)e.lineTo(E,j);else{const P=[];for(const _ of u){const L=_.value;(x>L||L>C)&&(L>x||C>L)||x===L||C===L||P.push({t:(L-x)/(C-x)})}P.sort((e,t)=>e.t-t.t);for(const B of P){const N=v+(E-v)*B.t,H=b+(j-b)*B.t,z=ot(x+(C-x)*Math.min(B.t+1e-4,1),u,l);e.lineTo(N,H),S(),A(z,N,H)}e.lineTo(E,j)}v=E,b=j,x=C,k=M}else A(M,E,j),v=E,b=j,x=C,k=M}S()}else{if(e.beginPath(),e.strokeStyle=l,d)R().x(e=>e[0]).y(e=>e[1]).curve(d).context(e)(a.path);else{const[$,W]=a.path[0];e.moveTo($,W);for(let T=1;a.path.length>T;T++)e.lineTo(a.path[T][0],a.path[T][1])}e.stroke()}if(a.style.fill&&a.style.fillOpacity&&a.style.fillOpacity>0){if(e.beginPath(),e.globalAlpha=a.style.fillOpacity,e.fillStyle=a.style.fill,d&&!g)R().x(e=>e[0]).y(e=>e[1]).curve(d).context(e)(a.path);else{const[F,D]=a.path[0];e.moveTo(F,D);for(let G=1;a.path.length>G;G++)e.lineTo(a.path[G][0],a.path[G][1])}const I=a.path[0][0];e.lineTo(a.path[a.path.length-1][0],o.height),e.lineTo(I,o.height),e.closePath(),e.fill()}e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt"}}],area:[dt],stackedarea:[dt],scatter:[gt],bubble:[gt],heatmap:[(e,t,n,o)=>{const r=t.filter(e=>"heatcell"===e.type);e.save();try{for(const t of r){const n=t.style;if(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),st(e,t),e.globalAlpha=1,t.showValues&&null!=t.value){if(20>t.w||20>t.h)continue;const n=t.valueFormat?t.valueFormat(t.value):mt(t.value),o=Math.max(10,Math.min(16,.3*Math.min(t.w,t.h))),r=t.x+t.w/2,i=t.y+t.h/2;e.fillStyle=ft(t.fill),e.font=o+"px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(n,r,i)}}}finally{e.restore()}}],bar:[pt],swarm:[gt],waterfall:[(e,t,n,o)=>{var r,i,s;pt(e,t);const a=t.filter(e=>"rect"===e.type);if(2>a.length)return;const l=a[0].datum,c=null==l?void 0:l._connectorStroke;if(c){e.save(),e.strokeStyle=c,e.lineWidth=null!==(r=null==l?void 0:l._connectorWidth)&&void 0!==r?r:1,e.setLineDash([]);for(let t=0;a.length-1>t;t++){const o=a[t],r=a[t+1];if(!(null===(i=o.datum)||void 0===i?void 0:i.cumEnd)||!(null===(s=r.datum)||void 0===s?void 0:s.baseline))continue;const l=n.y(o.datum.cumEnd),c=o.x+o.w,u=r.x;e.beginPath(),e.moveTo(c,l),e.lineTo(u,l),e.stroke()}e.restore()}}],candlestick:[(e,t,n,o)=>{for(const n of t){if("candlestick"!==n.type)continue;const t=n;e.save();const o=t._decayOpacity;null!=o&&1!==o&&(e.globalAlpha=o),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 r=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,r,t.bodyWidth,Math.max(i,1)),e.strokeStyle=s,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,r,t.bodyWidth,Math.max(i,1)),e.restore()}}]},bt={top:20,right:20,bottom:30,left:40},xt={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"},kt={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 wt({hover:t}){const n=e=>Number.isInteger(e)?e+"":e.toFixed(2);return e.createElement("div",{className:"semiotic-tooltip",style:kt},e.createElement("div",{style:{fontWeight:600,marginBottom:2}},n(t.value)),e.createElement("div",{style:{opacity:.7,fontSize:11}},n(t.time)))}function At({width:n,height:r,totalWidth:i,totalHeight:s,margin:a,dimension:l,scales:c,onBrush:u}){const h=t(null),f=t(null),m=t(u);m.current=u;const v=t(c);return v.current=c,o(()=>{if(!h.current)return;const e=y(h.current).select(".brush-g"),t="x"===l?d():"y"===l?g():p();return t.extent([[0,0],[n,r]]),t.on("brush end",e=>{const t=v.current;if(!t)return;if(!e.selection)return void m.current(null);let o,i;if("x"===l){const[n,s]=e.selection;o=[t.x.invert(n),t.x.invert(s)],i=[t.y.invert(r),t.y.invert(0)]}else if("y"===l){const[r,s]=e.selection;o=[t.x.invert(0),t.x.invert(n)],i=[t.y.invert(s),t.y.invert(r)]}else{const[[n,r],[s,a]]=e.selection;o=[t.x.invert(n),t.x.invert(s)],i=[t.y.invert(a),t.y.invert(r)]}m.current({x:o,y:i})}),e.call(t),f.current=t,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{t.on("brush end",null),f.current=null}},[n,r,l]),e.createElement("svg",{ref:h,width:i,height:s,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},e.createElement("g",{className:"brush-g",transform:`translate(${a.left},${a.top})`}))}const St=c(function(i,s){var l,c,h,d,g,p,y,f,m;const{chartType:v,runtimeMode:b,data:x,chunkThreshold:k,chunkSize:w,xAccessor:A,yAccessor:S,colorAccessor:O,sizeAccessor:E,groupAccessor:j,lineDataAccessor:C,curve:M,normalize:P,binSize:_,valueAccessor:L,arrowOfTime:B="right",windowMode:N="sliding",windowSize:H=200,timeAccessor:z,xExtent:$,yExtent:W,extentPadding:T=.1,sizeRange:I,size:F=[500,300],responsiveWidth:D,responsiveHeight:R,margin:G,className:Y,background:X,lineStyle:V,pointStyle:Q,areaStyle:K,waterfallStyle:U,swarmStyle:Z,barColors:J,colorScheme:ee,boundsAccessor:te,boundsStyle:ne,y0Accessor:oe,gradientFill:re,openAccessor:ie,highAccessor:se,lowAccessor:ae,closeAccessor:le,candlestickStyle:ce,showAxes:ue=!0,axes:he,xLabel:ge,yLabel:fe,xFormat:ke,yFormat:we,tickFormatTime:Ae,tickFormatValue:Se,hoverAnnotation:Oe,tooltipContent:Ee,customHoverBehavior:je,enableHover:Ce,annotations:Me,svgAnnotationRules:Pe,showGrid:_e,legend:Le,legendHoverBehavior:Be,legendClickBehavior:Ne,legendHighlightedCategory:He,legendIsolatedCategories:ze,legendPosition:$e,backgroundGraphics:We,foregroundGraphics:Te,canvasPreRenderers:Fe,title:De,categoryAccessor:Ye,brush:Qe,onBrush:Ke,decay:Ue,pulse:Ze,transition:Je,staleness:nt,heatmapAggregation:ot,heatmapXBins:rt,heatmapYBins:it,showValues:st,heatmapValueFormat:at,marginalGraphics:lt,pointIdAccessor:ct,xScaleType:ut,yScaleType:ht,accessibleTable:dt}=i,[gt,pt]=function(e,r,i){const s=t(null),[a,l]=n(null);return o(()=>{if(!r&&!i)return;const e=s.current;if(!e)return;const t=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;l(t=>t&&t.w===e&&t.h===n?t:{w:e,h:n})}});return t.observe(e),()=>t.disconnect()},[r,i]),[s,[r&&a?a.w:e[0],i&&a?a.h:e[1]]]}(F,D,R),yt=Object.assign(Object.assign({},bt),G);if(lt){const e=60;lt.top&&e>yt.top&&(yt.top=e),lt.bottom&&e>yt.bottom&&(yt.bottom=e),lt.left&&e>yt.left&&(yt.left=e),lt.right&&e>yt.right&&(yt.right=e)}const ft=pt[0]-yt.left-yt.right,mt=pt[1]-yt.top-yt.bottom,kt="function"==typeof Te?Te({size:pt,margin:yt}):Te,St="function"==typeof We?We({size:pt,margin:yt}):We,Ot=null!=Oe?Oe:Ce,Et=t(null),jt=t(null),Ct=t(0),Mt=t(!1),Pt=et(e=>e.theme),[_t,Lt]=n(0),[Bt,Nt]=n(null),Ht=t(null),zt=t(null),[$t,Wt]=n(null),[Tt,It]=n(!1),[Ft,Dt]=n([]),[Rt,Gt]=n([]),Yt=t(()=>{}),qt="streaming"===b||["bar","swarm","waterfall"].includes(v),Xt=r(()=>({chartType:v,runtimeMode:qt?"streaming":"bounded",windowSize:H,windowMode:N,arrowOfTime:qt?B:"right",extentPadding:T,xAccessor:qt?void 0:A,yAccessor:qt?void 0:S,timeAccessor:qt?z:void 0,valueAccessor:L,colorAccessor:O,sizeAccessor:E,groupAccessor:j,categoryAccessor:Ye,lineDataAccessor:C,xScaleType:ut,yScaleType:ht,xExtent:$,yExtent:W,sizeRange:I,binSize:_,normalize:P,boundsAccessor:te,boundsStyle:ne,y0Accessor:oe,gradientFill:"boolean"==typeof re?re?{topOpacity:.8,bottomOpacity:.05}:void 0:re,openAccessor:ie,highAccessor:se,lowAccessor:ae,closeAccessor:le,candlestickStyle:ce,lineStyle:V,pointStyle:Q,areaStyle:K,swarmStyle:Z,waterfallStyle:U,colorScheme:ee,barColors:J,annotations:Me,decay:Ue,pulse:Ze,transition:Je,staleness:nt,heatmapAggregation:ot,heatmapXBins:rt,heatmapYBins:it,showValues:st,heatmapValueFormat:at,pointIdAccessor:ct,curve:M}),[v,H,N,B,T,A,S,z,L,ut,ht,O,E,j,Ye,C,$,W,I,_,P,te,ne,oe,re,ie,se,ae,le,ce,V,Q,K,Z,U,ee,J,Me,Ue,Ze,Je,nt,ot,rt,it,st,at,qt,ct,M]),Vt=t(null);Vt.current||(Vt.current=new de(Xt));const Qt=a(()=>{Ct.current||(Ct.current=requestAnimationFrame(()=>Yt.current()))},[]);o(()=>{var e;null===(e=Vt.current)||void 0===e||e.updateConfig(Xt),Mt.current=!0,Qt()},[Xt,Qt]),o(()=>{Mt.current=!0,Qt()},[Pt,Qt]);const Kt=t(null);Kt.current||(Kt.current=new q(e=>{const t=Vt.current;t&&t.ingest(e)&&(Mt.current=!0,Qt())},{chunkThreshold:k,chunkSize:w})),o(()=>{var e;null===(e=Kt.current)||void 0===e||e.updateChunkOptions({chunkThreshold:k,chunkSize:w})},[k,w]);const Ut=a(e=>{var t;null===(t=Kt.current)||void 0===t||t.push(e)},[]),Zt=a(e=>{var t;null===(t=Kt.current)||void 0===t||t.pushMany(e)},[]),Jt=a(()=>{var e,t;null===(e=Kt.current)||void 0===e||e.clear(),null===(t=Vt.current)||void 0===t||t.clear(),Mt.current=!0,Qt()},[Qt]);u(s,()=>({push:Ut,pushMany:Zt,clear:Jt,getData:()=>{var e,t,n;return null===(e=Kt.current)||void 0===e||e.flush(),null!==(n=null===(t=Vt.current)||void 0===t?void 0:t.getData())&&void 0!==n?n:[]},getScales:()=>{var e,t;return null!==(t=null===(e=Vt.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null},getExtents:()=>{var e,t;return null!==(t=null===(e=Vt.current)||void 0===e?void 0:e.getExtents())&&void 0!==t?t:null}}),[Ut,Zt,Jt]),o(()=>{var e;x&&(null===(e=Kt.current)||void 0===e||e.setBoundedData(x))},[x]);const en=t(()=>{}),tn=t(()=>{});en.current=e=>{if(!Ot)return;const t=Et.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-yt.left,r=e.clientY-n.top-yt.top;if(0>o||o>ft||0>r||r>mt)return void(Ht.current&&(Ht.current=null,zt.current=null,Wt(null),je&&(je(null),Mt.current=!0),Qt()));const i=Vt.current;if(!i||0===i.scene.length)return;const s=function(e,t,n,o=30,r){let i=null,s=!1;if(r){const e=r.find(t,n,o);if(e){const r=pe(e,t,n);r&&o>r.distance&&(i=r,s=!0)}}for(const a of e){let e=null;switch(a.type){case"point":if(r&&s)break;e=pe(a,t,n);break;case"line":e=ye(a,t,n);break;case"rect":e=me(a,t,n);break;case"heatcell":e=ve(a,t,n);break;case"area":if(!1===a.interactive)break;e=xe(a,t,n);break;case"candlestick":e=be(a,t,n)}e&&o>e.distance&&(i&&e.distance>=i.distance||(i=e))}return i}(i.scene,o,r,30,i.quadtree);if(!s)return void(Ht.current&&(Ht.current=null,zt.current=null,Wt(null),je&&je(null),Qt()));const a=s.datum||{},l=Object.assign(Object.assign({},"object"!=typeof a||null===a||Array.isArray(a)?{}:a),{data:a,time:s.x,value:s.y,x:s.x,y:s.y});Ht.current=l,zt.current=s.node,Wt(l),je&&(je(l),Mt.current=!0),Qt()},tn.current=()=>{Ht.current&&(Ht.current=null,zt.current=null,Wt(null),je&&(je(null),Mt.current=!0),Qt())},a(e=>en.current(e),[]);const nn=a(()=>tn.current(),[]),on=t(-1),rn=a(e=>{const t=Vt.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>on.current?-1:on.current,r=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===r)return;if(e.preventDefault(),0>r)return on.current=-1,Ht.current=null,zt.current=null,Wt(null),je&&je(null),void Qt();const i=0>o?0:r;on.current=i;const s=function(e){const t=e.datum||{};return Object.assign(Object.assign({},"object"!=typeof t||null===t||Array.isArray(t)?{}:t),{data:t,x:e.x,y:e.y,time:e.x,value:e.y})}(n[i]);Ht.current=s,Wt(s),je&&je(s),Qt()},[je,Qt]),sn=a(e=>{on.current=-1,en.current(e)},[]);Yt.current=()=>{var e,t;Ct.current=0;const n=Et.current,o=jt.current;if(!n||!o)return;const r=Vt.current;if(!r)return;const i="undefined"!=typeof performance?performance.now():Date.now(),s=r.advanceTransition(i),a=Mt.current||s;a&&!s&&r.computeScene({width:ft,height:mt});const l="undefined"!=typeof window&&window.devicePixelRatio||1,c=function(e){if(!e)return xt;const t=getComputedStyle(e),n=t.getPropertyValue("--semiotic-border").trim(),o=t.getPropertyValue("--semiotic-text-secondary").trim(),r=t.getPropertyValue("--semiotic-bg").trim(),i=o||t.getPropertyValue("--text-secondary").trim(),s=t.getPropertyValue("--text-primary").trim(),a=n||t.getPropertyValue("--surface-3").trim(),l=r||t.getPropertyValue("--surface-0").trim();return i||s||n?{axisStroke:a||xt.axisStroke,tickText:i||xt.tickText,crosshair:i?i+"66":xt.crosshair,hoverFill:l?l+"4D":xt.hoverFill,hoverStroke:i?i+"99":xt.hoverStroke,pointRing:l||xt.pointRing}:xt}(n),u=null!==(e=null==nt?void 0:nt.threshold)&&void 0!==e?e:5e3,h=nt&&r.lastIngestTime>0&&i-r.lastIngestTime>u;if(a){const e=tt(n,pt,yt,l);if(e){e.clearRect(-yt.left,-yt.top,pt[0],pt[1]),h&&(e.globalAlpha=null!==(t=null==nt?void 0:nt.dimOpacity)&&void 0!==t?t:.5);const o=getComputedStyle(n).getPropertyValue("--semiotic-bg").trim(),i=X||(o&&"transparent"!==o?o:null);if(i&&(e.fillStyle=i,e.fillRect(-yt.left,-yt.top,pt[0],pt[1])),e.save(),"function"==typeof e.rect&&(e.beginPath(),e.rect(0,0,ft,mt),e.clip()),Fe&&r.scales)for(const t of Fe)e.save(),t(e,r.scene,r.scales,{width:ft,height:mt}),e.restore();const s=vt[v];if(s&&r.scales)for(const t of s)t(e,r.scene,r.scales,{width:ft,height:mt});e.restore(),h&&(e.globalAlpha=1)}}{const e=tt(o,pt,yt,l);if(e&&(e.clearRect(-yt.left,-yt.top,pt[0],pt[1]),Ot&&Ht.current&&r.scales&&function(e,t,n,o,r,i,s){if(!1===r.crosshair)return;e.save();const a="object"==typeof r.crosshair?r.crosshair:{};e.strokeStyle=a.stroke||s.crosshair,e.lineWidth=a.strokeWidth||1,e.setLineDash(a.strokeDasharray?a.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=s.pointRing,e.lineWidth=2,e.stroke()}(e,Ht.current,ft,mt,"object"==typeof Ot?Ot:{},0,c),zt.current&&Array.isArray(Oe))){const t=Oe.find(e=>e&&"object"==typeof e&&"highlight"===e.type);t&&function(e,t,n,o){var r;if(!n)return;const i=n.group;if(void 0!==i)for(const n of t){if("line"!==n.type)continue;if(n.group!==i)continue;if(2>n.path.length)continue;const t="function"==typeof o.style?o.style(n.datum):o.style||{};e.save(),e.beginPath(),e.moveTo(n.path[0][0],n.path[0][1]);for(let t=1;n.path.length>t;t++)e.lineTo(n.path[t][0],n.path[t][1]);e.strokeStyle=t.stroke||n.style.stroke||"#007bff",e.lineWidth=t.strokeWidth||(n.style.strokeWidth||2)+2,e.globalAlpha=null!==(r=t.opacity)&&void 0!==r?r:1,e.stroke(),e.restore()}}(e,r.scene,zt.current,t)}}a&&n&&n.setAttribute("aria-label",qe(r.scene,v+" chart"));const d=Mt.current;if(Mt.current=!1,d&&r.scales&&((!Bt||Bt.x.domain()[0]!==r.scales.x.domain()[0]||Bt.x.domain()[1]!==r.scales.x.domain()[1]||Bt.y.domain()[0]!==r.scales.y.domain()[0]||Bt.y.domain()[1]!==r.scales.y.domain()[1]||Bt.x.range()[0]!==r.scales.x.range()[0]||Bt.x.range()[1]!==r.scales.x.range()[1]||Bt.y.range()[0]!==r.scales.y.range()[0]||Bt.y.range()[1]!==r.scales.y.range()[1])&&Nt(r.scales),lt)){const e=r.getData(),t="function"==typeof A?A:e=>e[A||"x"],n="function"==typeof S?S:e=>e[S||"y"];Dt(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),Gt(e.map(e=>n(e)).filter(e=>"number"==typeof e&&isFinite(e)))}d&&Me&&Me.length>0&&Lt(e=>e+1),(null==nt?void 0:nt.showBadge)&&It(!!h),(s||r.hasActivePulses)&&(Ct.current=requestAnimationFrame(()=>Yt.current()))},o(()=>(Qt(),()=>{Ct.current&&(cancelAnimationFrame(Ct.current),Ct.current=0)}),[Qt]),o(()=>{Mt.current=!0,Qt()},[v,ft,mt,ue,X,V,Fe,Qt]),function(e,t,n,r,i,s){o(()=>{if(!e)return;const o=setInterval(()=>{var o;const a=t.current;if(!a||0===a.lastIngestTime)return;const l="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(o=e.threshold)&&void 0!==o?o:5e3,u=l-a.lastIngestTime>c;u!==i&&(s(u),n.current=!0,r())},1e3);return()=>clearInterval(o)},[e,i,r])}(nt,Vt,Mt,Qt,Tt,It);const an=Ot&&$t?Ee?Ee($t):e.createElement(wt,{hover:$t}):null,ln=an?e.createElement("div",{className:"stream-frame-tooltip",style:{position:"absolute",left:yt.left+$t.x,top:yt.top+$t.y,transform:`translate(${$t.x>.7*ft?"calc(-100% - 12px)":"12px"}, ${.3*mt>$t.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:1,width:"max-content"}},an):null,cn=on.current>=0&&$t?e.createElement("svg",{style:{position:"absolute",left:0,top:0,width:pt[0],height:pt[1],pointerEvents:"none",zIndex:2}},e.createElement("circle",{cx:$t.x+yt.left,cy:$t.y+yt.top,r:8,fill:"none",stroke:"var(--accent, #6366f1)",strokeWidth:2,strokeDasharray:"4,2"})):null;if(Ge){const t=Vt.current;t&&x&&(t.ingest({inserts:x,bounded:!0}),t.computeScene({width:ft,height:mt}));const n=null!==(l=null==t?void 0:t.scene)&&void 0!==l?l:[],o=null!==(c=null==t?void 0:t.scales)&&void 0!==c?c:null;return e.createElement("div",{className:"stream-xy-frame"+(Y?" "+Y:""),role:"img","aria-label":"string"==typeof De?De:"XY chart",style:{position:"relative",width:pt[0],height:pt[1]}},e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:pt[0],height:pt[1],style:{position:"absolute",left:0,top:0}},St,e.createElement("g",{transform:`translate(${yt.left},${yt.top})`},X&&e.createElement("rect",{x:0,y:0,width:ft,height:mt,fill:X}),n.map((t,n)=>function(t,n){var o,r,i;switch(t.type){case"line":{const o=t;if(0===o.path.length)return null;const r="M"+o.path.map(([e,t])=>`${e},${t}`).join("L");return e.createElement("path",{key:"line-"+n,d:r,fill:"none",stroke:o.style.stroke||"#4e79a7",strokeWidth:o.style.strokeWidth||2,strokeDasharray:o.style.strokeDasharray,opacity:o.style.opacity})}case"area":{const i=t;if(0===i.topPath.length)return null;const s=i.topPath.map(([e,t])=>`${e},${t}`).join("L"),a=[...i.bottomPath].reverse().map(([e,t])=>`${e},${t}`).join("L");return e.createElement("path",{key:"area-"+n,d:`M${s}L${a}Z`,fill:i.style.fill||"#4e79a7",fillOpacity:null!==(r=null!==(o=i.style.fillOpacity)&&void 0!==o?o:i.style.opacity)&&void 0!==r?r:.7,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})}case"point":return e.createElement("circle",{key:"point-"+n,cx:t.x,cy:t.y,r:t.r,fill:t.style.fill||"#4e79a7",opacity:null!==(i=t.style.opacity)&&void 0!==i?i:.8,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth});case"rect":return e.createElement("rect",{key:"rect-"+n,x:t.x,y:t.y,width:t.w,height:t.h,fill:t.style.fill||"#4e79a7",opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth});case"heatcell":{const o=t;if(o.showValues&&null!=o.value&&o.w>=20&&o.h>=20){const t=o.valueFormat?o.valueFormat(o.value):Number.isInteger(o.value)?o.value+"":100>Math.abs(o.value)?1>Math.abs(o.value)?o.value.toPrecision(3):o.value.toFixed(1):o.value.toFixed(0),[r,i,s]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(o.fill),a=.299*r+.587*i+.114*s>128?"#000":"#fff",l=Math.max(10,Math.min(16,.3*Math.min(o.w,o.h)));return e.createElement("g",{key:"heatcell-"+n},e.createElement("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:o.fill}),e.createElement("text",{x:o.x+o.w/2,y:o.y+o.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:a,fontSize:l+"px"},t))}return e.createElement("rect",{key:"heatcell-"+n,x:o.x,y:o.y,width:o.w,height:o.h,fill:o.fill})}case"candlestick":{const o=t,r=Math.min(o.openY,o.closeY),i=Math.max(Math.abs(o.openY-o.closeY),1),s=o.isUp?o.upColor:o.downColor;return e.createElement("g",{key:"candle-"+n},e.createElement("line",{x1:o.x,y1:o.highY,x2:o.x,y2:o.lowY,stroke:o.wickColor,strokeWidth:o.wickWidth}),e.createElement("rect",{x:o.x-o.bodyWidth/2,y:r,width:o.bodyWidth,height:i,fill:s,stroke:s,strokeWidth:1}))}default:return null}}(t,n)).filter(Boolean))),e.createElement(Re,{width:ft,height:mt,totalWidth:pt[0],totalHeight:pt[1],margin:yt,scales:o,showAxes:ue,axes:he,xLabel:ge,yLabel:fe,xFormat:ke||Ae,yFormat:we||Se,showGrid:_e,title:De,legend:Le,legendHoverBehavior:Be,legendClickBehavior:Ne,legendHighlightedCategory:He,legendIsolatedCategories:ze,legendPosition:$e,foregroundGraphics:kt,marginalGraphics:lt,xValues:[],yValues:[],annotations:Me,svgAnnotationRules:Pe,annotationFrame:0,xAccessor:"string"==typeof A?A:"string"==typeof z?z:void 0,yAccessor:"string"==typeof S?S:"string"==typeof L?L:void 0,annotationData:null==t?void 0:t.getData(),pointNodes:null==t?void 0:t.scene.filter(e=>"point"===e.type),curve:"string"==typeof M?M:void 0}))}return e.createElement("div",{ref:gt,className:"stream-xy-frame"+(Y?" "+Y:""),role:"img","aria-label":"string"==typeof De?De:"XY chart",tabIndex:0,style:{position:"relative",width:D?"100%":pt[0],height:R?"100%":pt[1],overflow:"visible"},onMouseMove:Ot?sn:void 0,onMouseLeave:Ot?nn:void 0,onKeyDown:rn},St&&e.createElement("svg",{style:{position:"absolute",left:0,top:0,width:pt[0],height:pt[1],pointerEvents:"none"}},St),e.createElement(Ie,{width:ft,height:mt,totalWidth:pt[0],totalHeight:pt[1],margin:yt,scales:Bt,showAxes:ue,axes:he,showGrid:_e,xFormat:ke||Ae,yFormat:we||Se}),e.createElement("canvas",{ref:Et,"aria-label":qe(null!==(d=null===(h=Vt.current)||void 0===h?void 0:h.scene)&&void 0!==d?d:[],v+" chart"),style:{position:"absolute",left:0,top:0}}),e.createElement("canvas",{ref:jt,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),e.createElement(Ve,{hoverPoint:$t}),dt&&e.createElement(Xe,{scene:null!==(p=null===(g=Vt.current)||void 0===g?void 0:g.scene)&&void 0!==p?p:[],chartType:v+" chart"}),e.createElement(Re,{width:ft,height:mt,totalWidth:pt[0],totalHeight:pt[1],margin:yt,scales:Bt,showAxes:ue,axes:he,xLabel:ge,yLabel:fe,xFormat:ke||Ae,yFormat:we||Se,showGrid:_e,title:De,legend:Le,legendHoverBehavior:Be,legendClickBehavior:Ne,legendHighlightedCategory:He,legendIsolatedCategories:ze,legendPosition:$e,foregroundGraphics:kt,marginalGraphics:lt,xValues:Ft,yValues:Rt,annotations:Me,svgAnnotationRules:Pe,annotationFrame:_t,xAccessor:"string"==typeof A?A:"string"==typeof z?z:void 0,yAccessor:"string"==typeof S?S:"string"==typeof L?L:void 0,annotationData:null===(y=Vt.current)||void 0===y?void 0:y.getData(),pointNodes:null===(f=Vt.current)||void 0===f?void 0:f.scene.filter(e=>"point"===e.type),curve:"string"==typeof M?M:void 0,underlayRendered:!0}),(Qe||Ke)&&e.createElement(At,{width:ft,height:mt,totalWidth:pt[0],totalHeight:pt[1],margin:yt,dimension:null!==(m=null==Qe?void 0:Qe.dimension)&&void 0!==m?m:"xy",scales:Bt,onBrush:null!=Ke?Ke:()=>{}}),(null==nt?void 0:nt.showBadge)&&e.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===nt.badgePosition?{top:4,left:4}:"bottom-left"===nt.badgePosition?{bottom:4,left:4}:"bottom-right"===nt.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:Tt?"#dc3545":"#28a745",color:"white"})},Tt?"STALE":"LIVE"),cn,ln)});St.displayName="StreamXYFrame";const Ot=i(null);function Et(){return s(Ot)}function jt(e){const t=[];for(const[n,o]of Object.entries(e.fields))if("point"===o.type)t.push(e=>o.values.has(e[n]));else{const[e,r]=o.range;t.push(t=>{const o=t[n];return o>=e&&r>=o})}return e=>t.every(t=>t(e))}function Ct(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}const[Mt,Pt]=Qe(e=>({selections:new Map,setClause(t,n){e(e=>{const o=new Map(e.selections),r=Ct(o,t),i=new Map(r.clauses);return i.set(n.clientId,n),o.set(t,Object.assign(Object.assign({},r),{clauses:i})),{selections:o}})},clearClause(t,n){e(e=>{const o=e.selections.get(t);if(!o)return{};const r=new Map(e.selections),i=new Map(o.clauses);return i.delete(n),r.set(t,Object.assign(Object.assign({},o),{clauses:i})),{selections:r}})},setResolution(t,n){e(e=>{const o=new Map(e.selections),r=Ct(o,t);return o.set(t,Object.assign(Object.assign({},r),{resolution:n})),{selections:o}})},clearSelection(t){e(e=>{const n=new Map(e.selections),o=n.get(t);return o&&n.set(t,Object.assign(Object.assign({},o),{clauses:new Map})),{selections:n}})}})),[_t,Lt]=Qe(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}))}}));function Bt(e){const t=h(),n=e.clientId||t,{name:o}=e,i=Pt(e=>e.selections.get(o)),s=Pt(e=>e.setClause),l=Pt(e=>e.clearClause),c=r(()=>!!i&&i.clauses.size>0,[i]);return{predicate:r(()=>i&&0!==i.clauses.size?function(e,t){const n=[];for(const[o,r]of e.clauses)"crossfilter"===e.resolution&&o===t||n.push(jt(r));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(i,n):()=>!0,[i,n]),isActive:c,selectPoints:a(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"point",values:new Set(o)};s(o,{clientId:n,type:"point",fields:t})},[n,o,s]),selectInterval:a(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"interval",range:o};s(o,{clientId:n,type:"interval",fields:t})},[n,o,s]),clear:a(()=>{l(o,n)},[l,o,n]),clientId:n}}function Nt(e){const t=e.name||"hover",{fields:n}=e,{predicate:o,isActive:r,selectPoints:i,clear:s}=Bt({name:t});return{onHover:a(e=>{if(!e)return void s();const t={};for(const o of n){const n=e[o];void 0!==n&&(t[o]=[n])}Object.keys(t).length>0&&i(t)},[n,i,s,t]),predicate:o,isActive:r}}function Ht(e){const{name:t,xField:n,yField:o}=e,{predicate:i,isActive:s,selectInterval:l,clear:c}=Bt({name:t}),u=n&&o?"xyBrush":n?"xBrush":"yBrush",h=a(e=>{if(!e)return void c();const t={};"xyBrush"===u&&Array.isArray(e)&&2===e.length?(n&&(t[n]=[Math.min(e[0][0],e[1][0]),Math.max(e[0][0],e[1][0])]),o&&(t[o]=[Math.min(e[0][1],e[1][1]),Math.max(e[0][1],e[1][1])])):"xBrush"===u&&Array.isArray(e)?n&&(t[n]=[Math.min(...e),Math.max(...e)]):"yBrush"===u&&Array.isArray(e)&&o&&(t[o]=[Math.min(...e),Math.max(...e)]),Object.keys(t).length>0&&l(t)},[u,n,o,l,c]);return{brushInteraction:r(()=>({brush:u,during:h,end:h}),[u,h]),predicate:i,isActive:s,clear:c}}const zt=i(!1);function $t({selections:e}){const t=Pt(e=>e.setResolution);return o(()=>{for(const[n,o]of Object.entries(e))o.resolution&&t(n,o.resolution)},[e,t]),null}function Wt({categoryColors:r,interaction:i,selectionName:s,field:l}){const c=Object.entries(r);if(0===c.length)return null;const u=c.map(([e])=>e),h=[{styleFn:e=>({fill:e.color||"#333",stroke:e.color||"#333"}),type:"fill",items:c.map(([e,t])=>({label:e,color:t})),label:""}],d=Nt({name:s,fields:[l]}),g=Bt({name:s,clientId:"__linked-legend-isolate__"}),[p,y]=n(new Set),[f,m]=n(null),v=t(g.selectPoints);v.current=g.selectPoints;const b=t(g.clear);b.current=g.clear,o(()=>{"isolate"===i&&(p.size>0?v.current({[l]:Array.from(p)}):b.current())},[i,p,l]);const x=a(e=>{"highlight"===i&&(e?(m(e.label),d.onHover({[l]:e.label})):(m(null),d.onHover(null)))},[i,l,d]),k=a(e=>{"isolate"===i&&y(t=>{const n=new Set(t);return n.has(e.label)?n.delete(e.label):n.add(e.label),n.size===u.length?new Set:n})},[i,u.length]);return e.createElement("svg",{width:"100%",height:30,style:{display:"block",overflow:"visible"}},e.createElement(je,{legendGroups:h,title:!1,orientation:"horizontal",height:20,customHoverBehavior:"highlight"===i?x:void 0,customClickBehavior:"isolate"===i?k:void 0,highlightedCategory:f,isolatedCategories:p}))}function Tt({children:t,selections:n,showLegend:o,legendPosition:r="top",legendInteraction:i="none",legendSelectionName:s="legend",legendField:a="category"}){const l=Et(),c=void 0!==o?o:!(!l||0>=Object.keys(l).length);return e.createElement(Mt,null,e.createElement(_t,null,n&&e.createElement($t,{selections:n}),e.createElement(zt.Provider,{value:c},c&&"top"===r&&l&&e.createElement(Wt,{categoryColors:l,interaction:i,selectionName:s,field:a}),t,c&&"bottom"===r&&l&&e.createElement(Wt,{categoryColors:l,interaction:i,selectionName:s,field:a}))))}function It({data:e,colorBy:t,colorScale:n,getColor:o,strokeColor:r,strokeWidth:i}){return{legendGroups:[{styleFn:e=>{const t=e.color||"#333",n={fill:t,stroke:t};return void 0!==r&&(n.stroke=r),void 0!==i&&(n.strokeWidth=i),n},type:"fill",items:Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t]))).map(r=>{const i=e.find("function"==typeof t?e=>t(e)===r:e=>e[t]===r),s=i?o(i,t,n):n?n(r):"#000000";return{label:r+"",color:s}}),label:""}]}}function Ft(e){return e?"string"==typeof e?{name:e}:e:null}function Dt(e,t,n){return t?o=>{var r;const i=Object.assign({},e(o));if(t.isActive)if(t.predicate(o))(null==n?void 0:n.selectedStyle)&&Object.assign(i,n.selectedStyle);else{const e=null!==(r=null==n?void 0:n.unselectedOpacity)&&void 0!==r?r:.2;i.opacity=e,i.fillOpacity=e,i.strokeOpacity=e,(null==n?void 0:n.unselectedStyle)&&Object.assign(i,n.unselectedStyle)}return i}:e}const Rt="#007bff";function Gt(e){return"function"==typeof e?e:t=>t[e]}function Yt(e,t,n="category10"){const o=Et();return r(()=>{if(t){if(0===e.length)return o&&Object.keys(o).length>0?e=>o[e]||"#999":void 0;if("function"==typeof t){const r=Array.from(new Set(e.map(e=>t(e)+"")));return o&&Object.keys(o).length>0?e=>o[e]||"#999":ce(r.map(e=>({_cat:e})),"_cat",n)}if(o&&Object.keys(o).length>0){const r=ce(e,t,n);return e=>o[e]||r(e)}return ce(e,t,n)}},[e,t,n,o])}function qt({selection:e,linkedHover:t,fallbackFields:n=[],unwrapData:o=!1,onObservation:r,chartType:i,chartId:s}){const l=function(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields}:null}(t,n),c=Bt({name:(null==e?void 0:e.name)||"__unused__"}),u=Nt({name:(null==l?void 0:l.name)||"hover",fields:(null==l?void 0:l.fields)||n||[]}),h=Lt(e=>e.pushObservation),d=e?{isActive:c.isActive,predicate:c.predicate}:null,g=a(e=>{var n,o;if(t)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]),u.onHover(t)}else u.onHover(null);if(r||h){const t={timestamp:Date.now(),chartType:i||"unknown",chartId:s};if(e){let i=e.data||e.datum||e;Array.isArray(i)&&(i=i[0]);const s=Object.assign(Object.assign({},t),{type:"hover",datum:i||{},x:null!==(n=e.x)&&void 0!==n?n:0,y:null!==(o=e.y)&&void 0!==o?o:0});r&&r(s),h&&h(s)}else{const e=Object.assign(Object.assign({},t),{type:"hover-end"});r&&r(e),h&&h(e)}}},[t,u,r,i,s,h]),p=a(e=>{var t,n;if(r||h){const o={timestamp:Date.now(),chartType:i||"unknown",chartId:s};if(e){let i=e.data||e.datum||e;Array.isArray(i)&&(i=i[0]);const s=Object.assign(Object.assign({},o),{type:"click",datum:i||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0});r&&r(s),h&&h(s)}else{const e=Object.assign(Object.assign({},o),{type:"click-end"});r&&r(e),h&&h(e)}}},[r,h,i,s]);return{activeSelectionHook:d,customHoverBehavior:g,customClickBehavior:p}}function Xt({data:e,colorBy:t,colorScale:n,showLegend:o,legendPosition:i="right",userMargin:a,defaults:l={top:50,bottom:60,left:70,right:40}}){const c=s(zt),u=void 0!==o?o:!c&&!!t,h=r(()=>{if(u&&t)return It({data:e,colorBy:t,colorScale:n,getColor:le})},[u,t,e,n]),d=r(()=>{const e=Object.assign(Object.assign({},l),a);return h&&("right"===i&&110>e.right?e.right=110:"left"===i&&110>e.left?e.left=110:"top"===i&&50>e.top?e.top=50:"bottom"===i&&80>e.bottom&&(e.bottom=80)),e},[l,a,h,i]);return{legend:h,margin:d,legendPosition:i}}function Vt(e,t,o){const[i,s]=n(null),[l,c]=n(new Set),u=a(t=>{"highlight"===e&&s(t?t.label:null)},[e]),h=a(t=>{"isolate"===e&&c(e=>{const n=new Set(e);return n.has(t.label)?n.delete(t.label):n.add(t.label),n.size===o.length?new Set:n})},[e,o.length]),d=r(()=>{if(!e||"none"===e||!t)return null;const n="string"==typeof t?t:null;return"highlight"===e&&null!=i?{isActive:!0,predicate:e=>(n?e[n]:"function"==typeof t?t(e):null)===i}:"isolate"===e&&l.size>0?{isActive:!0,predicate:e=>{const o=n?e[n]:"function"==typeof t?t(e):null;return l.has(o)}}:null},[e,t,i,l]);return{highlightedCategory:"highlight"===e?i:null,isolatedCategories:"isolate"===e?l:new Set,onLegendHover:u,onLegendClick:h,legendSelectionHook:d}}const Qt={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 Kt(e,t,n){var o,r,i,s,a,l;const c=Qt[e||"primary"],u="context"===e||"sparkline"===e;return{width:null!==(o=t.width)&&void 0!==o?o:c.width,height:null!==(r=t.height)&&void 0!==r?r:c.height,showAxes:c.showAxes,showGrid:null!==(i=t.showGrid)&&void 0!==i?i:c.showGrid,enableHover:null!==(s=t.enableHover)&&void 0!==s?s:!!t.linkedHover||c.enableHover,showLegend:null!==(a=t.showLegend)&&void 0!==a?a:c.showLegend,showLabels:null!==(l=t.showLabels)&&void 0!==l?l:c.showLabels,title:u?void 0:t.title,xLabel:u?void 0:t.xLabel,yLabel:u?void 0:t.yLabel,categoryLabel:u?void 0:t.categoryLabel,valueLabel:u?void 0:t.valueLabel,marginDefaults:c.marginDefaults}}const Ut={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 Zt(e,t){return"function"==typeof t?t(e):e[t]}function Jt(e,t){return t?t(e):null==e?"":"number"==typeof e?Math.abs(e)>9999?e.toLocaleString():e+"":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 en(t={}){const{fields:n,title:o,format:r,style:i={},className:s=""}=t;return t=>{if(!t||"object"!=typeof t)return null;let a;const l=[];if(o){const e=Zt(t,o);a=Jt(e,r)}if(n&&n.length>0)n.forEach(e=>{let n,o,i;"string"==typeof e?(n=e,o=e,i=r):(n=e.label,o=e.accessor||e.key||"",i=e.format||r);const s=Zt(t,o);l.push({label:n,value:Jt(s,i)})});else if(!o){const e=["value","y","name","id","label"];for(const n of e)if(void 0!==t[n]){a=Jt(t[n],r);break}if(!a){const e=Object.keys(t).filter(e=>!e.startsWith("_"));e.length>0&&(a=Jt(t[e[0]],r))}}const c=Object.assign(Object.assign({},Ut),i);return e.createElement("div",{className:("semiotic-tooltip "+s).trim(),style:c},a&&e.createElement("div",{style:{fontWeight:l.length>0?"bold":"normal"}},a),l.map((t,n)=>e.createElement("div",{key:n,style:{marginTop:0===n&&a?"4px":0}},t.label&&e.createElement("span",null,t.label,": "),t.value)))}}function tn(t){if(!0===t)return en();if("function"==typeof t){const n=t;return t=>{const o=n(!t||"object"!=typeof t.data||null===t.data||"node"!==t.type&&"edge"!==t.type?t:t.data);return null==o?null:e.createElement("div",{className:"semiotic-tooltip",style:Ut},o)}}return!1!==t&&void 0!==t&&("object"==typeof t&&null!==t&&("fields"in t||"title"in t)?en(t):en())}function nn(e){return"string"==typeof e?e:"value"}function on(e){return null==e?"–":"number"==typeof e?Math.abs(e)>9999?e.toLocaleString():e+"":e instanceof Date?e.toLocaleDateString():e+""}function rn(e,t){return"function"==typeof t?t(e):e[t]}function sn(t){const n=t.find(e=>"title"===e.role),o=t.filter(e=>"title"!==e.role);return t=>{const r=t.data;if(!r)return null;const i=n?on(rn(r,n.accessor)):null;return e.createElement("div",{className:"semiotic-tooltip",style:Ut},i&&e.createElement("div",{style:{fontWeight:"bold",marginBottom:o.length>0?4:0}},i),o.map((t,n)=>{const o=on(rn(r,t.accessor));return e.createElement("div",{key:n,style:n>0?{marginTop:2}:void 0},e.createElement("span",{style:{opacity:.7}},t.label,": "),e.createElement("span",null,o))}))}}function an({componentName:t,message:n,diagnosticHint:o,width:r,height:i}){return e.createElement("div",{role:"alert",style:{width:r,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),o&&e.createElement("div",{"data-testid":"semiotic-diagnostic-hint",style:{marginTop:10,padding:"8px 12px",background:"rgba(128, 128, 128, 0.06)",borderRadius:4,fontSize:12,color:"rgba(128, 128, 128, 0.8)",fontFamily:"monospace",textAlign:"left",whiteSpace:"pre-wrap",lineHeight:1.6}},o)))}class ln 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(an,{componentName:"ChartErrorBoundary",message:n.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}function cn(e,t){const n=e.length,o=t.length,r=Array(o+1);for(let e=0;o>=e;e++)r[e]=e;for(let i=1;n>=i;i++){let n=r[0];r[0]=i;for(let s=1;o>=s;s++){const o=r[s];r[s]=e[i-1]===t[s-1]?n:1+Math.min(n,r[s],r[s-1]),n=o}}return r[o]}function un(e,t,n=3){let o,r=n+1;for(const n of t){const t=cn(e.toLowerCase(),n.toLowerCase());r>t&&(r=t,o=n)}return r>n?void 0:o}function hn(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:e}function dn(e,t){var n;if(0===t.length)return null;const o=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(o)||o.includes(e.toLowerCase()))||(null!==(n=un(e,t,3))&&void 0!==n?n:null)}function gn({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(null==t)return null;if(!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=hn(t).find(e=>e&&"object"==typeof e);if(o){const t=Object.keys(o);for(const[r,i]of Object.entries(n))if(i&&"string"==typeof i&&!(i in o)){const n=dn(i,t),o=n?` Try ${r}="${n}".`:"";return`${e}: ${r} "${i}" not found in data. Available fields: ${t.join(", ")}.${o}`}}}return null}const pn={width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},frameProps:{type:"object"}},yn={xLabel:{type:"string"},yLabel:{type:"string"},xFormat:{type:"function"},yFormat:{type:"function"}},fn={categoryLabel:{type:"string"},valueLabel:{type:"string"},valueFormat:{type:"function"}},mn=["linear","monotoneX","monotoneY","step","stepAfter","stepBefore","basis","cardinal","catmullRom"],vn=["vertical","horizontal"],bn={LineChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},pn),yn),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},lineBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:mn},lineWidth:{type:"number"},showPoints:{type:"boolean"},pointRadius:{type:"number"},fillArea:{type:"boolean"},areaOpacity:{type:"number"}})},AreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},pn),yn),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:mn},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"}})},StackedAreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},pn),yn),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:mn},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"},normalize:{type:"boolean"}})},Scatterplot:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},pn),yn),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"}})},BubbleChart:{required:["data","sizeBy"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},pn),yn),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},bubbleOpacity:{type:"number"},bubbleStrokeWidth:{type:"number"},bubbleStrokeColor:{type:"string"}})},Heatmap:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},pn),yn),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},colorScheme:{type:"string",enum:["blues","reds","greens","viridis","custom"]},customColorScale:{type:["object","function"]},showValues:{type:"boolean"},valueFormat:{type:"function"},cellBorderColor:{type:"string"},cellBorderWidth:{type:"number"},showLegend:{type:"boolean"},legendPosition:{type:"string",enum:["right","left","top","bottom"]}})},QuadrantChart:{required:["quadrants"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},pn),yn),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},quadrants:{type:"object"},xCenter:{type:"number"},yCenter:{type:"number"},centerlineStyle:{type:"object"},showQuadrantLabels:{type:"boolean"},quadrantLabelSize:{type:"number"},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"}})},ConnectedScatterplot:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},pn),yn),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},orderAccessor:{type:["string","function"]},orderLabel:{type:"string"},pointRadius:{type:"number"},pointIdAccessor:{type:["string","function"]},annotations:{type:"array"}})},BarChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},pn),fn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:vn},sort:{type:["boolean","string","function"]},barPadding:{type:"number"}})},StackedBarChart:{required:["data","stackBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},pn),fn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},stackBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:vn},normalize:{type:"boolean"},barPadding:{type:"number"}})},GroupedBarChart:{required:["data","groupBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},pn),fn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},groupBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:vn},barPadding:{type:"number"}})},SwarmPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},pn),fn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:vn},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"},categoryPadding:{type:"number"}})},BoxPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},pn),fn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:vn},showOutliers:{type:"boolean"},outlierRadius:{type:"number"},categoryPadding:{type:"number"}})},Histogram:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},pn),fn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},bins:{type:"number"},relative:{type:"boolean"},categoryPadding:{type:"number"}})},ViolinPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},pn),fn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:vn},bins:{type:"number"},curve:{type:"string"},showIQR:{type:"boolean"},categoryPadding:{type:"number"}})},DotPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},pn),fn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:vn},sort:{type:["boolean","string","function"]},dotRadius:{type:"number"},categoryPadding:{type:"number"}})},PieChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},pn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},startAngle:{type:"number"},slicePadding:{type:"number"}})},DonutChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},pn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},innerRadius:{type:"number"},centerContent:{type:["object","string","number"]},startAngle:{type:"number"},slicePadding:{type:"number"}})},ForceDirectedGraph:{required:["nodes","edges"],dataShape:"network",dataAccessors:["nodeIDAccessor","sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},pn),{nodes:{type:"array"},edges:{type:"array"},nodeIDAccessor:{type:["string","function"]},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},nodeLabel:{type:["string","function"]},nodeSize:{type:["number","string","function"]},nodeSizeRange:{type:"array"},edgeWidth:{type:["number","string","function"]},edgeColor:{type:"string"},edgeOpacity:{type:"number"},iterations:{type:"number"},forceStrength:{type:"number"},showLabels:{type:"boolean"}})},SankeyDiagram:{required:["edges"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},pn),{nodes:{type:"array"},edges:{type:"array"},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},edgeColorBy:{type:["string","function"],enum:["source","target","gradient"]},orientation:{type:"string",enum:vn},nodeAlign:{type:"string",enum:["justify","left","right","center"]},nodePaddingRatio:{type:"number"},nodeWidth:{type:"number"},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},edgeOpacity:{type:"number"},edgeSort:{type:"function"}})},ChordDiagram:{required:["edges"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},pn),{nodes:{type:"array"},edges:{type:"array"},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},edgeColorBy:{type:["string","function"],enum:["source","target"]},padAngle:{type:"number"},groupWidth:{type:"number"},sortGroups:{type:"function"},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},edgeOpacity:{type:"number"}})},TreeDiagram:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},pn),{data:{type:"object"},layout:{type:"string",enum:["tree","cluster","partition","treemap","circlepack"]},orientation:{type:"string",enum:["vertical","horizontal","radial"]},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},edgeStyle:{type:"string",enum:["line","curve"]},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},nodeSize:{type:"number"}})},Treemap:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},pn),{data:{type:"object"},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},showLabels:{type:"boolean"},nodeLabel:{type:["string","function"]}})},CirclePack:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},pn),{data:{type:"object"},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},showLabels:{type:"boolean"},nodeLabel:{type:["string","function"]},circleOpacity:{type:"number"}})},OrbitDiagram:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},pn),{data:{type:"object"},childrenAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},orbitMode:{type:["string","array"]},speed:{type:"number"},revolution:{type:"function"},eccentricity:{type:["number","function"]},orbitSize:{type:["number","function"]},nodeRadius:{type:["number","function"]},showRings:{type:"boolean"},showLabels:{type:"boolean"},animated:{type:"boolean"},colorByDepth:{type:"boolean"},annotations:{type:"array"},foregroundGraphics:{type:"object"}})},RealtimeLineChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},stroke:{type:"string"},strokeWidth:{type:"number"},strokeDasharray:{type:"string"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeHistogram:{required:["binSize"],dataShape:"realtime",dataAccessors:[],props:{binSize:{type:"number"},size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},colors:{type:"object"},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},fill:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},gap:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeSwarmChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},colors:{type:"object"},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},radius:{type:"number"},fill:{type:"string"},opacity:{type:"number"},stroke:{type:"string"},strokeWidth:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeWaterfallChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},positiveColor:{type:"string"},negativeColor:{type:"string"},connectorStroke:{type:"string"},connectorWidth:{type:"number"},gap:{type:"number"},stroke:{type:"string"},strokeWidth:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeHeatmap:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},heatmapXBins:{type:"number"},heatmapYBins:{type:"number"},aggregation:{type:"string",enum:["count","sum","mean"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"}}}};function xn(e,t){return(Array.isArray(t)?t:[t]).includes(Array.isArray(e)?"array":typeof e)}const kn=new Set(["TreeDiagram","Treemap","CirclePack","OrbitDiagram"]),wn=new Set(["ForceDirectedGraph","SankeyDiagram","ChordDiagram"]),An=new Set(["BarChart","StackedBarChart","GroupedBarChart","AreaChart","StackedAreaChart"]),Sn=new Set(["LineChart","AreaChart","StackedAreaChart"]),On=new Set(["BarChart","StackedBarChart","GroupedBarChart"]);function En(e,t){const n=[],o=function(e,t){const n=[],o=bn[e];if(!o)return{valid:!1,errors:[`Unknown component "${e}". Valid components: ${Object.keys(bn).join(", ")}`]};for(const r of o.required)null==t[r]&&n.push(`"${r}" is required for ${e}.`);for(const[e,r]of Object.entries(t)){if(null==r)continue;const t=o.props[e];if(t){if(!xn(r,t.type)){const o=Array.isArray(t.type)?t.type.join(" | "):t.type;n.push(`"${e}" should be ${o}, got ${Array.isArray(r)?"array":typeof r}.`);continue}t.enum&&"string"==typeof r&&!t.enum.includes(r)&&n.push(`"${e}" value "${r}" is not valid. Expected one of: ${t.enum.join(", ")}.`)}}const r=Object.keys(o.props),i=new Set(r);for(const o of Object.keys(t))if(void 0!==t[o]&&!i.has(o)){const t=un(o,r),i=t?`Unknown prop "${o}" for ${e}. Did you mean "${t}"?`:`Unknown prop "${o}" for ${e}. Valid props: ${r.join(", ")}.`;n.push(i)}if("array"===o.dataShape){const r=t.data,i={};for(const e of o.dataAccessors){const n=t[e];"string"==typeof n&&(i[e]=n)}const s=gn({componentName:e,data:r,accessors:Object.keys(i).length>0?i:void 0});s&&n.push(s)}else if("object"===o.dataShape){const o=function({componentName:e,data:t,dataLabel:n="data"}){return null==t?`${e}: No ${n} provided. Pass a hierarchical object with children: { name: "root", children: [...] }.`:Array.isArray(t)?`${e}: ${n} should be a single root object, not an array. Expected: { name: "root", children: [...] }. If you have flat data, use LineChart, BarChart, or Scatterplot instead.`:null}({componentName:e,data:t.data});o&&n.push(o)}else if("network"===o.dataShape){const r=function({componentName:e,nodes:t,edges:n,nodesRequired:o=!1,edgesRequired:r=!0,accessors:i}){if(null==t&&null==n)return null;if(r&&(!n||!Array.isArray(n)||0===n.length))return e+': No edges provided. Pass a non-empty array: edges={[{ source: "A", target: "B", value: 10 }, ...]}.';if(o&&(!t||!Array.isArray(t)||0===t.length))return e+': No nodes provided. Pass a non-empty array: nodes={[{ id: "A" }, { id: "B" }, ...]}.';if(i&&t&&t.length>0){const n=hn(t).find(e=>e&&"object"==typeof e);if(n){const t=Object.keys(n);for(const[o,r]of Object.entries(i))if(r&&"string"==typeof r&&!(r in n)){const n=dn(r,t),i=n?` Try ${o}="${n}".`:"";return`${e}: ${o} "${r}" not found in node data. Available fields: ${t.join(", ")}.${i}`}}}return null}({componentName:e,nodes:t.nodes,edges:t.edges,nodesRequired:o.required.includes("nodes"),edgesRequired:o.required.includes("edges")});r&&n.push(r)}return{valid:0===n.length,errors:n}}(e,t);for(const e of o.errors)n.push({severity:"error",code:"VALIDATION",message:e,fix:""});return bn[e]?(function(e,t,n){const o=bn[e];if(o){if("array"===o.dataShape){const e=t.data;e&&Array.isArray(e)&&0===e.length&&n.push({severity:"error",code:"EMPTY_DATA",message:"data is an empty array — chart will render blank.",fix:"Provide at least one data point: data={[{ x: 1, y: 2 }]}."})}"network"===o.dataShape&&t.edges&&Array.isArray(t.edges)&&0===t.edges.length&&n.push({severity:"error",code:"EMPTY_EDGES",message:"edges is an empty array — network chart will render blank.",fix:'Provide at least one edge: edges={[{ source: "A", target: "B" }]}.'})}}(e,t,n),function(e,t,n){const o=t.width,r=t.height;if(void 0===o||"number"==typeof o&&o>0||n.push({severity:"error",code:"BAD_WIDTH",message:`width=${JSON.stringify(o)} — chart needs a positive number.`,fix:"Set width={600} or use responsiveWidth={true}."}),void 0===r||"number"==typeof r&&r>0||n.push({severity:"error",code:"BAD_HEIGHT",message:`height=${JSON.stringify(r)} — chart needs a positive number.`,fix:"Set height={400} or use responsiveHeight={true}."}),t.size&&Array.isArray(t.size)){const[e,o]=t.size;(null!=e&&0>=e||null!=o&&0>=o)&&n.push({severity:"error",code:"BAD_SIZE",message:`size=[${e}, ${o}] — both dimensions must be positive.`,fix:"Set size={[600, 400]}."})}}(0,t,n),function(e,t,n){const o=bn[e];if(!o||"array"!==o.dataShape)return;const r=t.data;if(!r||!Array.isArray(r)||0===r.length)return;const i=r[0];if(!i||"object"!=typeof i)return;const s=Object.keys(i);for(const e of o.dataAccessors){const o=t[e];"string"==typeof o&&(o in i||n.push({severity:"error",code:"ACCESSOR_MISSING",message:`${e}="${o}" not found in data. Available fields: ${s.join(", ")}.`,fix:`Change ${e} to one of: ${s.map(e=>`"${e}"`).join(", ")}.`}))}}(e,t,n),function(e,t,n){kn.has(e)&&Array.isArray(t.data)&&n.push({severity:"error",code:"HIERARCHY_FLAT_ARRAY",message:e+" expects hierarchical data but received a flat array.",fix:'Pass a root object: data={{ name: "root", children: [...] }}. For flat data, use BarChart or LineChart.'})}(e,t,n),function(e,t,n){wn.has(e)&&(t.edges||t.data||n.push({severity:"error",code:"NETWORK_NO_EDGES",message:e+" requires an edges prop.",fix:'Provide edges={[{ source: "A", target: "B", value: 10 }]}.'}))}(e,t,n),function(e,t,n){const o=bn[e];if(!o||"array"!==o.dataShape)return;const r=t.data;if(!r||!Array.isArray(r)||0===r.length)return;const i=r[0];if(!i||"object"!=typeof i)return;const s=t.xAccessor;"string"==typeof s&&i[s]instanceof Date&&!t.xFormat&&n.push({severity:"warning",code:"DATE_NO_FORMAT",message:`xAccessor "${s}" contains Date objects but no xFormat is provided. Axis ticks may display "[object Object]".`,fix:"Add xFormat={d => d.toLocaleDateString()} or use timestamps (d.getTime()) instead of Date objects."})}(e,t,n),function(e,t,n){t.linkedHover&&!t.selection&&n.push({severity:"warning",code:"LINKED_HOVER_NO_SELECTION",message:"linkedHover is set but selection is not — this chart emits hover events but won't highlight from others.",fix:`Add selection={{ name: "${"object"==typeof t.linkedHover&&t.linkedHover.name||"hl"}" }} to receive cross-highlights.`})}(0,t,n),function(e,t,n){var o;if(!An.has(e))return;const r=t.rExtent||t.yExtent;r&&Array.isArray(r)&&r.length>=1&&null!=r[0]&&0!==r[0]&&n.push({severity:"warning",code:"NON_ZERO_BASELINE",message:`${e} has a non-zero baseline (${r[0]}). Bar and area charts should start at zero to avoid exaggerating differences.`,fix:`Remove the custom extent minimum or set it to 0: rExtent={[0, ${null!==(o=r[1])&&void 0!==o?o:"auto"}]}. For trend-focused charts, use LineChart instead.`})}(e,t,n),function(e,t,n){if(!Sn.has(e))return;if(t.gapStrategy)return;const o=t.data;if(!o||!Array.isArray(o)||0===o.length)return;const r=t.yAccessor||"y";"string"==typeof r&&o.some(e=>{const t=e[r];return null==t||Number.isNaN(t)})&&n.push({severity:"warning",code:"DATA_GAPS",message:`Data contains null/undefined/NaN values in "${r}". Default behavior breaks the line at gaps.`,fix:'Set gapStrategy="break" (default), "interpolate", or "zero" to control gap handling.'})}(e,t,n),function(e,t,n){var o,r;const i=null!==(o=t.width)&&void 0!==o?o:600,s=null!==(r=t.height)&&void 0!==r?r:400,a=t.margin;if(!a||"object"!=typeof a)return;const l=(a.left||0)+(a.right||0),c=(a.top||0)+(a.bottom||0);i>l||n.push({severity:"error",code:"MARGIN_OVERFLOW_H",message:`Horizontal margins (${l}px) >= width (${i}px) — no drawing area left.`,fix:"Reduce margin.left/right or increase width."}),s>c||n.push({severity:"error",code:"MARGIN_OVERFLOW_V",message:`Vertical margins (${c}px) >= height (${s}px) — no drawing area left.`,fix:"Reduce margin.top/bottom or increase height."})}(0,t,n),function(e,t,n){var o;const r=bn[e];if(!r||"array"!==r.dataShape)return;const i=t.data;if(!i||!Array.isArray(i)||0===i.length)return;const s=[];t.xAccessor&&"string"==typeof t.xAccessor&&s.push({prop:"xAccessor",name:t.xAccessor}),t.yAccessor&&"string"==typeof t.yAccessor&&s.push({prop:"yAccessor",name:t.yAccessor}),t.valueAccessor&&"string"==typeof t.valueAccessor&&s.push({prop:"valueAccessor",name:t.valueAccessor});const a=Math.min(i.length,5);for(const e of s){let t=!0;for(let n=0;a>n;n++){const r=null===(o=i[n])||void 0===o?void 0:o[e.name];if("number"==typeof r&&Number.isFinite(r)){t=!1;break}}t&&n.push({severity:"error",code:"DEGENERATE_EXTENT",message:`${e.prop}="${e.name}" produces NaN or non-finite values for all sampled data points — chart extents will be invalid.`,fix:`Ensure data[].${e.name} contains finite numbers, or use a function accessor to transform values.`})}}(e,t,n),function(e,t,n){if(!On.has(e))return;const o=t.barPadding;"number"==typeof o&&10>o&&n.push({severity:"warning",code:"BAR_PADDING_INVISIBLE",message:`barPadding=${o} is very small — bars may appear to have no spacing between them.`,fix:"Increase barPadding to at least 10 for visible gaps, e.g. barPadding={12}."})}(e,t,n),function(e,t,n){if("bottom"!==t.legendPosition)return;const o=t.margin;if(!o||"object"!=typeof o)return;const r=o.bottom;"number"==typeof r&&70>r&&n.push({severity:"warning",code:"BOTTOM_MARGIN_WITH_LEGEND",message:`legendPosition="bottom" with margin.bottom=${r}px — legend may overlap axis labels.`,fix:"Increase margin.bottom to at least 70, e.g. margin={{ ...margin, bottom: 80 }}."})}(0,t,n),function(e,t,n){var o;if(!t.showLegend)return;if("right"!==(null!==(o=t.legendPosition)&&void 0!==o?o:"right"))return;const r=t.margin;if(!r||"object"!=typeof r)return;const i=r.right;"number"==typeof i&&100>i&&n.push({severity:"warning",code:"LEGEND_MARGIN_TIGHT",message:`showLegend is true with legendPosition="right" but margin.right=${i}px — legend may be clipped or overlap the chart.`,fix:"Increase margin.right to at least 100, e.g. margin={{ ...margin, right: 120 }}."})}(0,t,n),function(e,t,n){if("Heatmap"!==e)return;const o=t.data;if(!o||!Array.isArray(o)||0===o.length)return;const r=o[0];if(r&&"object"==typeof r)for(const e of["xAccessor","yAccessor"]){const o=t[e];if("string"!=typeof o)continue;const i=r[o];"string"==typeof i&&n.push({severity:"warning",code:"HEATMAP_STRING_ACCESSOR",message:`${e}="${o}" resolves to string values (e.g. "${i}"). Heatmap will use categorical axis handling which may produce unexpected cell layout.`,fix:"If you intend categorical axes this is fine. Otherwise, convert values to numbers before passing data."})}}(e,t,n),{ok:n.every(e=>"warning"===e.severity),diagnoses:n}):{ok:0===n.length,diagnoses:n}}var jn;const Cn="undefined"!=typeof process&&"production"!==(null===(jn=process.env)||void 0===jn?void 0:jn.NODE_ENV);function Mn({componentName:t,width:n,height:o,chartProps:r,children:i}){return e.createElement(ln,{fallback:i=>{let s="";if(Cn&&r)try{const e=En(t,r);e.ok||(s=e.diagnoses.map(e=>`${"error"===e.severity?"✗":"⚠"} ${e.message}${e.fix?" — Fix: "+e.fix:""}`).join("\n"))}catch(e){}return e.createElement(an,{componentName:t,message:i.message,diagnosticHint:s,width:n,height:o})}},i)}const Pn={display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #999)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"},_n={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function Ln(t,n,o,r){return!1===r||null==t||Array.isArray(t)&&t.length>0?null:Array.isArray(t)?e.createElement("div",{style:Object.assign(Object.assign({},Pn),{width:n,height:o})},r||"No data available"):null}function Bn(t,n,o){if(!t)return null;const r=Math.min(5,Math.floor(o/40)),i=Math.max(8,Math.floor(o/(3*r))),s=Math.max(6,Math.floor(o/(2.5*r))),a=Math.floor((o-(r*(i+s)-s))/2);return e.createElement("div",{style:{width:n,height:o,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"}},Array.from({length:r},(t,o)=>e.createElement("div",{key:o,className:"semiotic-loading-bar",style:Object.assign(Object.assign({},_n),{position:"absolute",top:a+o*(i+s),left:Math.floor(.1*n),width:30+(37*o+13)%50+"%",height:i,opacity:.5+o%2*.2})})))}function Nn(e,t,n,o){if(!Cn)return;if(!t||0===t.length)return;if("string"!=typeof o)return;const r=t[0];if(!r||"object"!=typeof r)return;if(o in r)return;const i=Object.keys(r).join(", ");console.warn(`[semiotic] ${e}: ${n} "${o}" not found in data. Available keys: ${i}`)}function Hn(e,t,n,o){return new(n||(n=Promise))(function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((o=o.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;let zn=null;function $n(){return Hn(this,void 0,void 0,function*(){return zn||(zn=yield import("./xy-statisticalOverlays-C1f7TYyD.js")),zn})}const Wn=c(function(i,s){var l,c;const h=t(null);u(s,()=>({push:e=>{var t;return null===(t=h.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=h.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=h.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=h.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const d=Kt(i.mode,{width:i.width,height:i.height,showGrid:i.showGrid,enableHover:i.enableHover,showLegend:i.showLegend,title:i.title,xLabel:i.xLabel,yLabel:i.yLabel}),{data:g,margin:p,className:y,xFormat:f,yFormat:m,xAccessor:v="x",yAccessor:b="y",lineBy:x,lineDataAccessor:k="coordinates",colorBy:w,colorScheme:A="category10",curve:S="linear",showPoints:O=!1,pointRadius:E=3,fillArea:j=!1,areaOpacity:C=.3,lineWidth:M=2,tooltip:P,pointIdAccessor:_,annotations:L,directLabel:B,gapStrategy:N="break",anomaly:H,forecast:z,frameProps:$={},selection:W,linkedHover:T,onObservation:I,chartId:F,loading:D,emptyContent:R,legendInteraction:G,legendPosition:Y,xScaleType:q,yScaleType:X}=i,V=d.width,Q=d.height,K=d.enableHover,U=d.showGrid,Z=d.showLegend,J=d.title,ee=d.xLabel,te=d.yLabel,ne=Bn(D,V,Q);if(ne)return ne;const oe=Ln(g,V,Q,R);if(oe)return oe;const re=g||[];Nn("LineChart",re,"xAccessor",v),Nn("LineChart",re,"yAccessor",b);const ie="string"==typeof v?v:"x",se="string"==typeof b?b:"y",[ae,ce]=n(null),[ue,he]=n([]);o(()=>{if(!z&&!H)return;let e=!1;return ce(null),he([]),z?function(...e){return Hn(this,void 0,void 0,function*(){return(yield $n()).buildForecast(...e)})}(re,ie,se,z,H).then(t=>{e||(ce(t),he(t.annotations))}).catch(()=>{e||(ce(null),he([]))}):H&&function(...e){return Hn(this,void 0,void 0,function*(){return(yield $n()).buildAnomalyAnnotations(...e)})}(H).then(t=>{e||(ce(null),he(t))}).catch(()=>{e||he([])}),()=>{e=!0}},[re,z,H,ie,se]);const de=ae?ae.processedData:re,ge=z&&!x?"__forecastSegment":x,{activeSelectionHook:pe,customHoverBehavior:ye}=qt({selection:W,linkedHover:T,fallbackFields:w?["string"==typeof w?w:""]:[],onObservation:I,chartType:"LineChart",chartId:F}),fe=a(e=>{const t="function"==typeof v?v(e):e[v],n="function"==typeof b?b(e):e[b];return null==t||null==n||Number.isNaN(t)||Number.isNaN(n)},[v,b]),me=void 0!==(null===(l=de[0])||void 0===l?void 0:l[k]),ve=r(()=>{if(me)return de;if(ge){const e=de.reduce((e,t)=>{const n="function"==typeof ge?ge(t):t[ge];if(!e[n]){const t={[k]:[]};"string"==typeof ge&&(t[ge]=n),e[n]=t}return e[n][k].push(t),e},{});return Object.values(e)}return[{[k]:de}]},[de,ge,k,me]),{gapProcessedLineData:be,hasGaps:xe}=r(()=>{if("interpolate"===N){let e=!1;const t=[];for(const n of ve){const o=(n[k]||[]).filter(t=>!fe(t)||(e=!0,!1));o.length>0&&t.push(Object.assign(Object.assign({},n),{[k]:o}))}return{gapProcessedLineData:t,hasGaps:e}}if("break"===N){let e=!1;const t=[];for(const n of ve){const o=n[k]||[];let r=[],i=0;const s=ge&&"string"==typeof ge?n[ge]:void 0;for(const a of o)if(fe(a))e=!0,r.length>0&&(t.push(Object.assign(Object.assign({},n),{[k]:r})),r=[],i++);else{const e=null!=s?`${s}__seg${i}`:"__seg"+i;r.push(Object.assign(Object.assign({},a),{_gapSegment:e}))}r.length>0&&t.push(Object.assign(Object.assign({},n),{[k]:r}))}return{gapProcessedLineData:t,hasGaps:e}}if("zero"===N){let e=!1;const t="string"==typeof b?b:"y",n=[];for(const o of ve){const r=o[k]||[],i=[];for(const n of r)fe(n)?(e=!0,i.push(Object.assign(Object.assign({},n),{[t]:0}))):i.push(n);n.push(Object.assign(Object.assign({},o),{[k]:i}))}return{gapProcessedLineData:n,hasGaps:e}}return{gapProcessedLineData:ve,hasGaps:!1}},[ve,N,k,fe,ge,b]),ke=Yt(de,w,A),we=r(()=>{if(!w)return[];const e=new Set;for(const t of de){const n="function"==typeof w?w(t):t[w];null!=n&&e.add(n+"")}return Array.from(e)},[de,w]),Ae=Vt(G,w,we),Se=r(()=>Ae.legendSelectionHook?Ae.legendSelectionHook:pe,[Ae.legendSelectionHook,pe]),Oe=r(()=>e=>{const t={strokeWidth:M};return w?ke&&(t.stroke=le(e,w,ke),j&&(t.fill=t.stroke,t.fillOpacity=C)):(t.stroke=Rt,j&&(t.fill=Rt,t.fillOpacity=C)),t},[w,ke,M,j,C]),[Ee,je]=n(null);o(()=>{if(!z)return void je(null);let e=!1;return function(...e){return Hn(this,void 0,void 0,function*(){return(yield $n()).createSegmentLineStyle(...e)})}(Oe,z).then(t=>{e||je(()=>t)}).catch(()=>{e||je(null)}),()=>{e=!0}},[Oe,z]);const Ce=Ee||Oe,Me=r(()=>Dt(Ce,Se,W),[Ce,Se,W]),Pe=r(()=>{if(O)return e=>{const t={r:E,fillOpacity:1};return w?ke&&(t.fill=le(e.parentLine||e,w,ke)):t.fill=Rt,t}},[O,E,w,ke]),_e=j?"area":"line",Le="object"==typeof B?B:{},Be=Le.position||"end",Ne=Le.fontSize||11,He=r(()=>{var e,t;if(!B||!w)return[];const n="function"==typeof v?v:e=>e[v],o="function"==typeof b?b:e=>e[b],r="function"==typeof w?w:e=>e[w],i=new Map;for(const n of be){const o=n[k]||[];if(0===o.length)continue;const s="end"===Be?o[o.length-1]:o[0],a=null!==(t=null!==(e=r(s))&&void 0!==e?e:r(n))&&void 0!==t?t:"";a&&!i.has(a+"")&&i.set(a+"",s)}const s=Array.from(i.entries()).map(([e,t])=>({type:"text",label:e,["string"==typeof v?v:"x"]:n(t),["string"==typeof b?b:"y"]:o(t),dx:"end"===Be?6:-6,dy:0,color:ke?ke(e):Rt,fontSize:Ne}));s.sort((e,t)=>{const n="string"==typeof b?b:"y";return e[n]-t[n]});for(let e=1;s.length>e;e++){const t="string"==typeof b?b:"y",n=s[e-1],o=s[e];Ne+2>Math.abs(o[t]+o.dy-(n[t]+n.dy))&&(o.dy+=Ne+2)}return s},[B,w,ke,be,k,v,b,Be,Ne]),ze=(!B||void 0!==Z)&&Z,$e=r(()=>{if(!B)return d.marginDefaults;const e=He.reduce((e,t)=>{var n;const o=((null===(n=t.label)||void 0===n?void 0:n.length)||0)*(.6*Ne);return Math.max(e,o)},0),t=e+10,n="end"===Be?"right":"left";return Object.assign(Object.assign({},d.marginDefaults),{[n]:Math.max(d.marginDefaults[n]||0,t)})},[B,He,Ne,Be,d.marginDefaults]),{legend:We,margin:Te,legendPosition:Ie}=Xt({data:be,colorBy:w,colorScale:ke,showLegend:ze,legendPosition:Y,userMargin:p,defaults:$e}),Fe=x||w,De=r(()=>sn([{label:ee||nn(v),accessor:v,role:"x"},{label:te||nn(b),accessor:b,role:"y"},...Fe?[{label:nn(Fe),accessor:Fe,role:"group"}]:[]]),[v,b,ee,te,Fe]),Re=gn({componentName:"LineChart",data:me?(null===(c=de[0])||void 0===c?void 0:c[k])||[]:g,accessors:{xAccessor:v,yAccessor:b}});if(Re)return e.createElement(an,{componentName:"LineChart",message:Re,width:V,height:Q});const Ge=r(()=>me||ge||xe?be.flatMap(e=>{const t=e[k]||[];return ge&&"string"==typeof ge?t.map(t=>Object.assign(Object.assign({},t),{[ge]:e[ge]})):t}):de,[be,k,me,ge,de,xe]),Ye=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:_e},null!=g&&{data:Ge}),{xAccessor:v,yAccessor:b,xScaleType:q,yScaleType:X,groupAccessor:"break"===N&&xe?"_gapSegment":ge||void 0,curve:S,lineStyle:Me}),O&&{pointStyle:Pe}),{size:[V,Q],responsiveWidth:i.responsiveWidth,responsiveHeight:i.responsiveHeight,margin:Te,showAxes:d.showAxes,xLabel:ee,yLabel:te,xFormat:f,yFormat:m,enableHover:K,showGrid:U}),We&&{legend:We,legendPosition:Ie}),G&&"none"!==G&&{legendHoverBehavior:Ae.onLegendHover,legendClickBehavior:Ae.onLegendClick,legendHighlightedCategory:Ae.highlightedCategory,legendIsolatedCategories:Ae.isolatedCategories}),J&&{title:J}),y&&{className:y}),{tooltipContent:!1===P?()=>null:tn(P)||De}),(T||I)&&{customHoverBehavior:ye}),_&&{pointIdAccessor:_}),((null==L?void 0:L.length)||ue.length||He.length)&&{annotations:[...L||[],...ue,...He]}),$);return e.createElement(Mn,{componentName:"LineChart",width:V,height:Q},e.createElement(St,Object.assign({ref:h},Ye)))});Wn.displayName="LineChart";const Tn=c(function(n,o){var i;const s=t(null);u(o,()=>({push:e=>{var t;return null===(t=s.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=s.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=s.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=s.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const a=Kt(n.mode,{width:n.width,height:n.height,showGrid:n.showGrid,enableHover:n.enableHover,showLegend:n.showLegend,title:n.title,xLabel:n.xLabel,yLabel:n.yLabel}),{data:l,margin:c,className:h,xFormat:d,yFormat:g,xAccessor:p="x",yAccessor:y="y",areaBy:f,y0Accessor:m,gradientFill:v=!1,lineDataAccessor:b="coordinates",colorBy:x,colorScheme:k="category10",curve:w="monotoneX",areaOpacity:A=.7,showLine:S=!0,lineWidth:O=2,tooltip:E,annotations:j,frameProps:C={},selection:M,linkedHover:P,onObservation:_,chartId:L,loading:B,emptyContent:N,legendInteraction:H,legendPosition:z}=n,$=a.width,W=a.height,T=a.enableHover,I=a.showGrid,F=a.showLegend,D=a.title,R=a.xLabel,G=a.yLabel,Y=Bn(B,$,W);if(Y)return Y;const q=Ln(l,$,W,N);if(q)return q;const X=l||[];Nn("AreaChart",X,"xAccessor",p),Nn("AreaChart",X,"yAccessor",y);const{activeSelectionHook:V,customHoverBehavior:Q}=qt({selection:M,linkedHover:P,fallbackFields:x?["string"==typeof x?x:""]:[],onObservation:_,chartType:"AreaChart",chartId:L}),K=void 0!==(null===(i=X[0])||void 0===i?void 0:i[b]),U=r(()=>{if(K)return X;if(f){const e=X.reduce((e,t)=>{const n="function"==typeof f?f(t):t[f];if(!e[n]){const t={[b]:[]};"string"==typeof f&&(t[f]=n),e[n]=t}return e[n][b].push(t),e},{});return Object.values(e)}return[{[b]:X}]},[X,f,b,K]),Z=Yt(X,x,k),J=r(()=>{if(!x)return[];const e=new Set;for(const t of X){const n="function"==typeof x?x(t):t[x];null!=n&&e.add(n+"")}return Array.from(e)},[X,x]),ee=Vt(H,x,J),te=r(()=>ee.legendSelectionHook?ee.legendSelectionHook:V,[ee.legendSelectionHook,V]),ne=r(()=>e=>{const t={};if(x){if(Z){const n=le(e,x,Z);t.fill=n,S?(t.stroke=n,t.strokeWidth=O):t.stroke="none"}}else t.fill=Rt,S?(t.stroke=Rt,t.strokeWidth=O):t.stroke="none";return t.fillOpacity=A,t},[x,Z,A,S,O]),oe=r(()=>Dt(ne,te,M),[ne,te,M]),{legend:re,margin:ie,legendPosition:se}=Xt({data:U,colorBy:x,colorScale:Z,showLegend:F,legendPosition:z,userMargin:c,defaults:a.marginDefaults}),ae=f||x,ce=r(()=>sn([{label:R||nn(p),accessor:p,role:"x"},{label:G||nn(y),accessor:y,role:"y"},...ae?[{label:nn(ae),accessor:ae,role:"group"}]:[]]),[p,y,R,G,ae]),ue=gn({componentName:"AreaChart",data:l,accessors:{xAccessor:p,yAccessor:y}});if(ue)return e.createElement(an,{componentName:"AreaChart",message:ue,width:$,height:W});const he=r(()=>K||f?U.flatMap(e=>{const t=e[b]||[];return f&&"string"==typeof f?t.map(t=>Object.assign(Object.assign({},t),{[f]:e[f]})):t}):X,[U,b,K,f,X]),de=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"area"},null!=l&&{data:he}),{xAccessor:p,yAccessor:y,groupAccessor:f||void 0}),m&&{y0Accessor:m}),v&&{gradientFill:v}),{curve:w,lineStyle:oe,size:[$,W],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:ie,showAxes:a.showAxes,xLabel:R,yLabel:G,xFormat:d,yFormat:g,enableHover:T,showGrid:I}),re&&{legend:re,legendPosition:se}),H&&"none"!==H&&{legendHoverBehavior:ee.onLegendHover,legendClickBehavior:ee.onLegendClick,legendHighlightedCategory:ee.highlightedCategory,legendIsolatedCategories:ee.isolatedCategories}),D&&{title:D}),h&&{className:h}),{tooltipContent:!1===E?()=>null:tn(E)||ce}),(P||_)&&{customHoverBehavior:Q}),j&&j.length>0&&{annotations:j}),C);return e.createElement(Mn,{componentName:"AreaChart",width:$,height:W},e.createElement(St,Object.assign({ref:s},de)))});Tn.displayName="AreaChart";const In=c(function(o,i){var s;const l=t(null),c=Kt(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,xLabel:o.xLabel,yLabel:o.yLabel}),{data:h,margin:d,className:g,xFormat:p,yFormat:y,xAccessor:f="x",yAccessor:m="y",areaBy:v,lineDataAccessor:b="coordinates",colorBy:x,colorScheme:k="category10",curve:w="monotoneX",areaOpacity:A=.7,showLine:S=!0,lineWidth:O=2,normalize:E=!1,tooltip:j,annotations:C,frameProps:M={},selection:P,linkedHover:_,onObservation:L,chartId:B,loading:N,emptyContent:H,legendInteraction:z,legendPosition:$}=o,W=c.width,T=c.height,I=c.enableHover,F=c.showGrid,D=c.showLegend,R=c.title,G=c.xLabel,Y=c.yLabel,q=Bn(N,W,T);if(q)return q;const X=Ln(h,W,T,H);if(X)return X;const V=h||[],Q=function({isPushMode:e,colorBy:o,colorScheme:i,showLegend:s,legendPosition:l="right"}){const c=t(new Set),u=t([]),[h,d]=n(0),g=a(e=>{if(!o)return null;const t="function"==typeof o?o(e):e[o];return null!=t?t+"":null},[o]),p=a(t=>{if(!e||!o)return;let n=!1;for(const e of t){if(!e||"object"!=typeof e)continue;const t=g(e);null==t||c.current.has(t)||(c.current.add(t),u.current.push(t),n=!0)}n&&d(e=>e+1)},[e,o,g]),y=a(e=>t=>{p([t]),e(t)},[p]),f=a(e=>t=>{p(t),e(t)},[p]),m=a(()=>{c.current=new Set,u.current=[],d(e=>e+1)},[]),v=r(()=>{if(!e||!o||!1===s)return;const t=u.current;if(0===t.length)return;const n=Array.isArray(i)?i:se,r=new Map;for(let e=0;t.length>e;e++)r.set(t[e],n[e%n.length]);const a="string"==typeof o?o:"__streamCat";return It({data:t.map(e=>({[a]:e})),colorBy:a,colorScale:e=>r.get(e)||"#999",getColor:le})},[e,o,s,i,h]),b=r(()=>{if(v)return"right"===l?{right:110}:"left"===l?{left:110}:"top"===l?{top:50}:"bottom"===l?{bottom:80}:{right:110}},[v,l]);return{wrapPush:y,wrapPushMany:f,resetCategories:m,streamingLegend:v,streamingMarginAdjust:b}}({isPushMode:void 0===h,colorBy:x||v,colorScheme:k,showLegend:D,legendPosition:$}),K=a(Q.wrapPush(e=>{var t;return null===(t=l.current)||void 0===t?void 0:t.push(e)}),[Q.wrapPush]),U=a(Q.wrapPushMany(e=>{var t;return null===(t=l.current)||void 0===t?void 0:t.pushMany(e)}),[Q.wrapPushMany]);u(i,()=>({push:K,pushMany:U,clear:()=>{var e;Q.resetCategories(),null===(e=l.current)||void 0===e||e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=l.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}),[K,U,Q.resetCategories]);const{activeSelectionHook:Z,customHoverBehavior:J}=qt({selection:P,linkedHover:_,fallbackFields:x?["string"==typeof x?x:""]:[],onObservation:L,chartType:"StackedAreaChart",chartId:B}),ee=void 0!==(null===(s=V[0])||void 0===s?void 0:s[b]),te=r(()=>{if(ee)return V;if(v){const e=V.reduce((e,t)=>{const n="function"==typeof v?v(t):t[v];if(!e[n]){const t={[b]:[]};"string"==typeof v&&(t[v]=n),e[n]=t}return e[n][b].push(t),e},{});return Object.values(e)}return[{[b]:V}]},[V,v,b,ee]),ne=Yt(V,x,k),oe=r(()=>{if(!x)return[];const e=new Set;for(const t of V){const n="function"==typeof x?x(t):t[x];null!=n&&e.add(n+"")}return Array.from(e)},[V,x]),re=Vt(z,x,oe),ie=r(()=>re.legendSelectionHook?re.legendSelectionHook:Z,[re.legendSelectionHook,Z]),ae=r(()=>e=>{const t={};if(x&&ne){const n=le(e,x,ne);t.fill=n,S?(t.stroke=n,t.strokeWidth=O):t.stroke="none"}else x||(t.fill=Rt,t.stroke=S?Rt:"none",S&&(t.strokeWidth=O));return t.fillOpacity=A,t},[x,ne,A,S,O]),ce=r(()=>Dt(ae,ie,P),[ae,ie,P]),{legend:ue,margin:he,legendPosition:de}=Xt({data:te,colorBy:x,colorScale:ne,showLegend:D,legendPosition:$,userMargin:d,defaults:c.marginDefaults}),ge=Q.streamingLegend||ue,pe=$||de,ye=r(()=>{if(Q.streamingMarginAdjust){const e=Object.assign({},he);for(const[t,n]of Object.entries(Q.streamingMarginAdjust))n>e[t]&&(e[t]=n);return e}return he},[he,Q.streamingMarginAdjust]),fe=v||x,me=r(()=>sn([{label:G||nn(f),accessor:f,role:"x"},{label:Y||nn(m),accessor:m,role:"y"},...fe?[{label:nn(fe),accessor:fe,role:"group"}]:[]]),[f,m,G,Y,fe]),ve=gn({componentName:"StackedAreaChart",data:h,accessors:{xAccessor:f,yAccessor:m}});if(ve)return e.createElement(an,{componentName:"StackedAreaChart",message:ve,width:W,height:T});const be=r(()=>ee||v?te.flatMap(e=>{const t=e[b]||[];return v&&"string"==typeof v?t.map(t=>Object.assign(Object.assign({},t),{[v]:e[v]})):t}):V,[te,b,ee,v,V]),xe=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"stackedarea"},null!=h&&{data:be}),{xAccessor:f,yAccessor:m,groupAccessor:v||void 0,curve:w,normalize:E,lineStyle:ce,size:[W,T],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:ye,showAxes:c.showAxes,xLabel:G,yLabel:Y,xFormat:p,yFormat:y,enableHover:I,showGrid:F}),ge&&{legend:ge,legendPosition:pe}),z&&"none"!==z&&{legendHoverBehavior:re.onLegendHover,legendClickBehavior:re.onLegendClick,legendHighlightedCategory:re.highlightedCategory,legendIsolatedCategories:re.isolatedCategories}),R&&{title:R}),g&&{className:g}),{tooltipContent:!1===j?()=>null:tn(j)||me}),(_||L)&&{customHoverBehavior:J}),C&&C.length>0&&{annotations:C}),M);return e.createElement(Mn,{componentName:"StackedAreaChart",width:W,height:T},e.createElement(St,Object.assign({ref:l},xe)))});In.displayName="StackedAreaChart";const Fn=c(function(n,o){const i=t(null);u(o,()=>({push:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=i.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=i.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const s=Kt(n.mode,{width:n.width,height:n.height,showGrid:n.showGrid,enableHover:n.enableHover,showLegend:n.showLegend,title:n.title,xLabel:n.xLabel,yLabel:n.yLabel}),{data:l,margin:c,className:h,xFormat:d,yFormat:g,xAccessor:p="x",yAccessor:y="y",colorBy:f,colorScheme:m="category10",sizeBy:v,sizeRange:b=[3,15],pointRadius:x=5,pointOpacity:k=.8,tooltip:w,marginalGraphics:A,pointIdAccessor:S,annotations:O,frameProps:E={},selection:j,linkedHover:C,linkedBrush:M,onObservation:P,chartId:_,loading:L,emptyContent:B,legendInteraction:N,legendPosition:H}=n,z=s.width,$=s.height,W=s.enableHover,T=s.showGrid,I=s.title,F=s.xLabel,D=s.yLabel,R=l||[],G=function(e){const{data:t,rawData:n,colorBy:o,colorScheme:i,legendInteraction:s,legendPosition:a,selection:l,linkedHover:c,fallbackFields:u,unwrapData:h=!1,onObservation:d,chartType:g,chartId:p,showLegend:y,userMargin:f,marginDefaults:m,loading:v,emptyContent:b,width:x,height:k}=e,{activeSelectionHook:w,customHoverBehavior:A,customClickBehavior:S}=qt({selection:l,linkedHover:c,fallbackFields:u,unwrapData:h,onObservation:d,chartType:g,chartId:p}),O=Yt(t,o,i),E=r(()=>{if(!o)return[];const e=new Set;for(const n of t){const t="function"==typeof o?o(n):n[o];null!=t&&e.add(t+"")}return Array.from(e)},[t,o]),j=Vt(s,o,E),C=r(()=>j.legendSelectionHook?j.legendSelectionHook:w,[j.legendSelectionHook,w]),{legend:M,margin:P,legendPosition:_}=Xt({data:t,colorBy:o,colorScale:O,showLegend:y,legendPosition:a,userMargin:f,defaults:m}),L=r(()=>{const e={};return M&&(e.legend=M,e.legendPosition=_),s&&"none"!==s&&(e.legendHoverBehavior=j.onLegendHover,e.legendClickBehavior=j.onLegendClick,e.legendHighlightedCategory=j.highlightedCategory,e.legendIsolatedCategories=j.isolatedCategories),e},[M,_,s,j.onLegendHover,j.onLegendClick,j.highlightedCategory,j.isolatedCategories]),B=Bn(v,x,k),N=B?null:Ln(n,x,k,b);return{colorScale:O,allCategories:E,legendState:j,effectiveSelectionHook:C,activeSelectionHook:w,customHoverBehavior:A,customClickBehavior:S,legend:M,margin:P,legendPosition:_,earlyReturn:B||N||null,legendBehaviorProps:L}}({data:R,rawData:l,colorBy:f,colorScheme:m,legendInteraction:N,legendPosition:H,selection:j,linkedHover:C,fallbackFields:f?["string"==typeof f?f:""]:[],unwrapData:!1,onObservation:P,chartType:"Scatterplot",chartId:_,showLegend:s.showLegend,userMargin:c,marginDefaults:s.marginDefaults,loading:L,emptyContent:B,width:z,height:$}),Y=Ft(M),q=Ht({name:(null==Y?void 0:Y.name)||"__unused_brush__",xField:(null==Y?void 0:Y.xField)||("string"==typeof p?p:void 0),yField:(null==Y?void 0:Y.yField)||("string"==typeof y?y:void 0)}),X=Y?"xyBrush"===q.brushInteraction.brush?"xy":"xBrush"===q.brushInteraction.brush?"x":"y":void 0,V=e.useRef(q.brushInteraction);V.current=q.brushInteraction;const Q=a(e=>{const t=V.current;t.end(e?"xyBrush"===t.brush?[[e.x[0],e.y[0]],[e.x[1],e.y[1]]]:"xBrush"===t.brush?e.x:e.y:null)},[]);if(G.earlyReturn)return G.earlyReturn;Nn("Scatterplot",R,"xAccessor",p),Nn("Scatterplot",R,"yAccessor",y);const K=r(()=>{if(!v||0===R.length)return;const e=R.map(e=>"function"==typeof v?v(e):e[v]);return[Math.min(...e),Math.max(...e)]},[R,v]),U=r(()=>e=>{const t={fillOpacity:k};return f?G.colorScale&&(t.fill=le(e,f,G.colorScale)):t.fill=Rt,t.r=v?ue(e,v,b,K):x,t},[f,G.colorScale,v,b,K,x,k]),Z=r(()=>Dt(U,G.effectiveSelectionHook,j),[U,G.effectiveSelectionHook,j]),J=r(()=>sn([{label:F||nn(p),accessor:p,role:"x"},{label:D||nn(y),accessor:y,role:"y"},...f?[{label:nn(f),accessor:f,role:"color"}]:[],...v?[{label:nn(v),accessor:v,role:"size"}]:[]]),[p,y,F,D,f,v]),ee=gn({componentName:"Scatterplot",data:l,accessors:{xAccessor:p,yAccessor:y}});if(ee)return e.createElement(an,{componentName:"Scatterplot",message:ee,width:z,height:$});const te=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter"},null!=l&&{data:R}),{xAccessor:p,yAccessor:y,colorAccessor:f||void 0,sizeAccessor:v||void 0,sizeRange:b,pointStyle:Z,colorScheme:m,size:[z,$],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:G.margin,showAxes:s.showAxes,xLabel:F,yLabel:D,xFormat:d,yFormat:g,enableHover:W,showGrid:T}),G.legendBehaviorProps),I&&{title:I}),h&&{className:h}),{tooltipContent:!1===w?()=>null:tn(w)||J}),(C||P)&&{customHoverBehavior:G.customHoverBehavior}),A&&{marginalGraphics:A}),S&&{pointIdAccessor:S}),O&&O.length>0&&{annotations:O}),Y&&{brush:{dimension:X},onBrush:Q}),E);return e.createElement(Mn,{componentName:"Scatterplot",width:z,height:$},e.createElement(St,Object.assign({ref:i},te)))});function Dn(e,t){return w(1===t?.5:e/(t-1))}Fn.displayName="Scatterplot";const Rn=c(function(n,o){const i=t(null);u(o,()=>({push:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=i.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=i.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const s=Kt(n.mode,{width:n.width,height:n.height,showGrid:n.showGrid,enableHover:n.enableHover,title:n.title,xLabel:n.xLabel,yLabel:n.yLabel}),{data:a,className:l,xFormat:c,yFormat:h,xAccessor:d="x",yAccessor:g="y",orderAccessor:p,orderLabel:y,pointRadius:f=4,tooltip:m,pointIdAccessor:v,annotations:b,frameProps:x={},selection:k,linkedHover:w,onObservation:A,chartId:S,loading:O,emptyContent:E,legendInteraction:j}=n,C=s.width,M=s.height,P=s.enableHover,_=s.showGrid,L=s.title,B=s.xLabel,N=s.yLabel,H=a||[],z=r(()=>{if(!p||0===H.length)return H;const e="function"==typeof p?p:e=>e[p];return[...H].sort((t,n)=>{const o=e(t),r=e(n);return(o instanceof Date?o.getTime():+o)-(r instanceof Date?r.getTime():+r)})},[H,p]);Nn("ConnectedScatterplot",z,"xAccessor",d),Nn("ConnectedScatterplot",z,"yAccessor",g);const{activeSelectionHook:$,customHoverBehavior:W}=qt({selection:k,linkedHover:w,fallbackFields:[],onObservation:A,chartType:"ConnectedScatterplot",chartId:S}),T=Vt(j,void 0,[]),I=r(()=>T.legendSelectionHook?T.legendSelectionHook:$,[T.legendSelectionHook,$]),F=r(()=>(e,t)=>{var n,o;const r=t.filter(e=>"point"===e.type);if(2>r.length)return;const i=null==I?void 0:I.isActive,s=null==I?void 0:I.predicate,a=100>r.length,l=r.length;e.lineCap="round";for(let t=0;l-1>t;t++){const c=r[t],u=r[t+1],h=Dn(t,l),d=!i||!s||s(null!==(n=c.datum)&&void 0!==n?n:c)||s(null!==(o=u.datum)&&void 0!==o?o:u),g=i?d?1:.2:1;a&&(e.beginPath(),e.moveTo(c.x,c.y),e.lineTo(u.x,u.y),e.strokeStyle="white",e.lineWidth=f+2,e.globalAlpha=.5*g,e.stroke()),e.beginPath(),e.moveTo(c.x,c.y),e.lineTo(u.x,u.y),e.strokeStyle=h,e.lineWidth=f,e.globalAlpha=g,e.stroke()}e.globalAlpha=1},[f,I]),D=r(()=>[F],[F]),R=t({idx:0,total:0}),G=r(()=>{const e="function"==typeof d?d:e=>e[d],t="function"==typeof g?g:e=>e[g];return n=>{var o,r;const s=R.current;if(0===s.idx){const n=null!==(r=null===(o=i.current)||void 0===o?void 0:o.getData())&&void 0!==r?r:z;s.total=n.filter(n=>{const o=e(n),r=t(n);return null!=o&&null!=r&&isFinite(o)&&isFinite(r)}).length}const a=s.total,l=s.idx;return s.idx++,a>s.idx||(s.idx=0),{fill:a>0?Dn(l,a):"#6366f1",stroke:"white",strokeWidth:1,r:f,fillOpacity:1}}},[f,z.length,d,g]),Y=r(()=>Dt(G,I,k),[G,I,k]),q=Object.assign({top:50,right:40,bottom:60,left:70},n.margin),X=y||("string"==typeof p?p:"Order"),V=r(()=>sn([{label:B||nn(d),accessor:d,role:"x"},{label:N||nn(g),accessor:g,role:"y"},...p?[{label:X,accessor:p,role:"group"}]:[]]),[d,g,B,N,p,X]),Q=gn({componentName:"ConnectedScatterplot",data:a,accessors:{xAccessor:d,yAccessor:g}}),K=Bn(O,C,M);if(K)return K;const U=Ln(a,C,M,E);if(U)return U;if(Q)return e.createElement(an,{componentName:"ConnectedScatterplot",message:Q,width:C,height:M});const Z=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter"},null!=a&&{data:z}),{xAccessor:d,yAccessor:g,pointStyle:Y,size:[C,M],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:q,showAxes:s.showAxes,xLabel:B,yLabel:N,xFormat:c,yFormat:h,enableHover:P,showGrid:_}),L&&{title:L}),l&&{className:l}),{tooltipContent:!1===m?()=>null:tn(m)||V}),(w||A)&&{customHoverBehavior:W}),v&&{pointIdAccessor:v}),{canvasPreRenderers:D}),b&&b.length>0&&{annotations:b}),x);return e.createElement(Mn,{componentName:"ConnectedScatterplot",width:C,height:M},e.createElement(St,Object.assign({ref:i},Z)))});Rn.displayName="ConnectedScatterplot";const Gn=c(function(n,o){const i=t(null);u(o,()=>({push:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=i.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=i.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const s=Kt(n.mode,{width:n.width,height:n.height,showGrid:n.showGrid,enableHover:n.enableHover,showLegend:n.showLegend,title:n.title,xLabel:n.xLabel,yLabel:n.yLabel}),{data:a,margin:l,className:c,xFormat:h,yFormat:d,xAccessor:g="x",yAccessor:p="y",sizeBy:y,sizeRange:f=[5,40],colorBy:m,colorScheme:v="category10",bubbleOpacity:b=.6,bubbleStrokeWidth:x=1,bubbleStrokeColor:k="white",tooltip:w,marginalGraphics:A,pointIdAccessor:S,annotations:O,frameProps:E={},selection:j,linkedHover:C,linkedBrush:M,onObservation:P,chartId:_,loading:L,emptyContent:B,legendInteraction:N,legendPosition:H}=n,z=s.width,$=s.height,W=s.enableHover,T=s.showGrid,I=s.showLegend,F=s.title,D=s.xLabel,R=s.yLabel,G=Bn(L,z,$);if(G)return G;const Y=Ln(a,z,$,B);if(Y)return Y;const q=a||[],{activeSelectionHook:X,customHoverBehavior:V}=qt({selection:j,linkedHover:C,fallbackFields:m?["string"==typeof m?m:""]:[],onObservation:P,chartType:"BubbleChart",chartId:_}),Q=Ft(M);Ht({name:(null==Q?void 0:Q.name)||"__unused_brush__",xField:(null==Q?void 0:Q.xField)||("string"==typeof g?g:void 0),yField:(null==Q?void 0:Q.yField)||("string"==typeof p?p:void 0)});const K=Yt(q,m,v),U=r(()=>{if(!m)return[];const e=new Set;for(const t of q){const n="function"==typeof m?m(t):t[m];null!=n&&e.add(n+"")}return Array.from(e)},[q,m]),Z=Vt(N,m,U),J=r(()=>Z.legendSelectionHook?Z.legendSelectionHook:X,[Z.legendSelectionHook,X]),ee=r(()=>{const e=q.map(e=>"function"==typeof y?y(e):e[y]);return[Math.min(...e),Math.max(...e)]},[q,y]),te=r(()=>e=>{const t={fillOpacity:b,strokeWidth:x,stroke:k};return m?K&&(t.fill=le(e,m,K)):t.fill=Rt,t.r=ue(e,y,f,ee),t},[m,K,y,f,ee,b,x,k]),ne=r(()=>Dt(te,J,j),[te,J,j]),{legend:oe,margin:re,legendPosition:ie}=Xt({data:q,colorBy:m,colorScale:K,showLegend:I,legendPosition:H,userMargin:l,defaults:s.marginDefaults}),se=r(()=>sn([{label:D||nn(g),accessor:g,role:"x"},{label:R||nn(p),accessor:p,role:"y"},{label:nn(y),accessor:y,role:"size"},...m?[{label:nn(m),accessor:m,role:"color"}]:[]]),[g,p,D,R,y,m]),ae=gn({componentName:"BubbleChart",data:a,accessors:{xAccessor:g,yAccessor:p},requiredProps:{sizeBy:y}});if(ae)return e.createElement(an,{componentName:"BubbleChart",message:ae,width:z,height:$});const ce=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bubble"},null!=a&&{data:q}),{xAccessor:g,yAccessor:p,colorAccessor:m||void 0,sizeAccessor:y,sizeRange:f,pointStyle:ne,colorScheme:v,size:[z,$],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:re,showAxes:s.showAxes,xLabel:D,yLabel:R,xFormat:h,yFormat:d,enableHover:W,showGrid:T}),oe&&{legend:oe,legendPosition:ie}),N&&"none"!==N&&{legendHoverBehavior:Z.onLegendHover,legendClickBehavior:Z.onLegendClick,legendHighlightedCategory:Z.highlightedCategory,legendIsolatedCategories:Z.isolatedCategories}),F&&{title:F}),c&&{className:c}),{tooltipContent:!1===w?()=>null:tn(w)||se}),(C||P)&&{customHoverBehavior:V}),A&&{marginalGraphics:A}),S&&{pointIdAccessor:S}),O&&O.length>0&&{annotations:O}),E);return e.createElement(Mn,{componentName:"BubbleChart",width:z,height:$},e.createElement(St,Object.assign({ref:i},ce)))});Gn.displayName="BubbleChart";const Yn=c(function(n,o){const i=t(null);u(o,()=>({push:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=i.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=i.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const s=Kt(n.mode,{width:n.width,height:n.height,showGrid:void 0,enableHover:n.enableHover,showLegend:void 0,title:n.title,xLabel:n.xLabel,yLabel:n.yLabel}),{data:a,margin:l,className:c,xAccessor:h="x",yAccessor:d="y",valueAccessor:g="value",xFormat:p,yFormat:y,colorScheme:f="blues",customColorScale:m,showValues:b=!1,valueFormat:x,cellBorderColor:k="#fff",cellBorderWidth:A=1,tooltip:S,annotations:C,frameProps:M={},selection:P,linkedHover:_,onObservation:L,chartId:B,loading:N,emptyContent:H,showLegend:z,legendPosition:$,legendInteraction:W}=n,T=s.width,I=s.height,F=s.enableHover,D=s.title,R=s.xLabel,G=s.yLabel,Y=Bn(N,T,I);if(Y)return Y;const q=Ln(a,T,I,H);if(q)return q;const X=a||[],V=null!=z&&z,Q=null!=$?$:"right",{margin:K}=Xt({data:X,colorBy:V?"value":void 0,colorScale:void 0,showLegend:V,legendPosition:Q,userMargin:l,defaults:s.marginDefaults}),{activeSelectionHook:U,customHoverBehavior:Z}=qt({selection:P,linkedHover:_,fallbackFields:[],onObservation:L,chartType:"Heatmap",chartId:B}),J=Vt(W,void 0,[]),ee=r(()=>J.legendSelectionHook?J.legendSelectionHook:U,[J.legendSelectionHook,U]),te=r(()=>"function"==typeof g?e=>g(e):e=>e[g],[g]),ne=r(()=>{const e=X.map(te);return[Math.min(...e),Math.max(...e)]},[X,te]),oe=r(()=>"custom"===f&&m?m:v({blues:j,reds:E,greens:O,viridis:w}[f]||j).domain(ne),[f,m,ne]);r(()=>{const e=Gt(h),t=Gt(d);return{xBinCount:new Set(X.map(e)).size,yBinCount:new Set(X.map(t)).size}},[X,h,d]),r(()=>({coordinates:X}),[X]);const re=r(()=>e=>{const t=te(e);return{fill:oe(t),stroke:k,strokeWidth:A}},[te,oe,k,A]);r(()=>Dt(re,ee,P),[re,ee,P]);const ie=r(()=>sn([{label:R||nn(h),accessor:h,role:"x"},{label:G||nn(d),accessor:d,role:"y"},{label:nn(g),accessor:g,role:"value"}]),[h,d,R,G,g]),se=gn({componentName:"Heatmap",data:a,accessors:{xAccessor:h,yAccessor:d,valueAccessor:g}});if(se)return e.createElement(an,{componentName:"Heatmap",message:se,width:T,height:I});const ae=r(()=>{if(V)return{gradient:{colorFn:e=>oe(e),domain:ne,label:"string"==typeof g?g:"value",format:x}}},[V,oe,ne,g,x]),le=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"heatmap"},null!=a&&{data:X}),{xAccessor:h,yAccessor:d,valueAccessor:g,colorScheme:"custom"!==f?f:void 0,showValues:b,heatmapValueFormat:x,size:[T,I],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:K,showAxes:s.showAxes,xLabel:R,yLabel:G,xFormat:p,yFormat:y,enableHover:F}),ae&&{legend:ae,legendPosition:Q}),D&&{title:D}),c&&{className:c}),{tooltipContent:!1===S?()=>null:tn(S)||ie}),(_||L)&&{customHoverBehavior:Z}),C&&C.length>0&&{annotations:C}),M);return e.createElement(Mn,{componentName:"Heatmap",width:T,height:I},e.createElement(St,Object.assign({ref:i},le)))});Yn.displayName="Heatmap";const qn="__splomIdx",Xn={top:4,bottom:4,left:4,right:4};function Vn({frameRef:n,cellSize:r,onBrush:i}){const s=t(null),a=r-Xn.left-Xn.right,l=r-Xn.top-Xn.bottom;return o(()=>{if(!s.current)return;const e=y(s.current).select(".brush-g"),t=p().extent([[0,0],[a,l]]).on("brush end",e=>{var t;const o=null===(t=n.current)||void 0===t?void 0:t.getScales();if(!o)return;if(!e.selection)return void i(null);const[[r,s],[a,l]]=e.selection,c=[[o.x.invert(r),o.y.invert(s)],[o.x.invert(a),o.y.invert(l)]];i(c)});return e.call(t),e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{t.on("brush end",null)}},[a,l,n,i]),e.createElement("svg",{ref:s,width:r,height:r,style:{position:"absolute",top:0,left:0}},e.createElement("g",{className:"brush-g",transform:`translate(${Xn.left},${Xn.top})`}))}function Qn({data:n,xField:o,yField:r,cellSize:i,pointRadius:s,pointOpacity:l,colorBy:c,colorScale:u,brushSelectionName:h,hoverSelectionName:d,unselectedOpacity:g,mode:p,onPointHover:y}){const f=t(null),m=Bt({name:h,clientId:`splom-${o}-${r}`}),v=Ht({name:h,xField:o,yField:r}),b=Bt({name:d,clientId:"splom-hover-source"}),x=b.selectPoints,k=a(e=>{e?v.brushInteraction.during(e):v.brushInteraction.end(null)},[v.brushInteraction]),w=a(e=>{if(!e)return void(null==y||y(null));const t=e.data,n=null==t?void 0:t[qn];void 0!==n&&(x({[qn]:[n]}),null==y||y(t,e.x+Xn.left,e.y+Xn.top))},[x,y]),A=a(e=>{const t={opacity:l,r:s};return t.fill=c?le(e,c,u):Rt,"hover"===p?b.isActive&&b.predicate(e)?(t.opacity=1,t.r=2.5*s,t.stroke="#333",t.strokeWidth=1.5):b.isActive&&(t.opacity=.6*l):m.isActive&&!m.predicate(e)&&(t.opacity=g),t},[c,u,l,s,p,m.isActive,m.predicate,b.isActive,b.predicate,g]);return e.createElement("div",{style:{position:"relative",width:i,height:i}},e.createElement(St,{ref:f,chartType:"scatter",data:n,size:[i,i],xAccessor:o,yAccessor:r,pointStyle:A,margin:Xn,showAxes:!1,enableHover:"hover"===p,customHoverBehavior:"hover"===p?w:void 0,tooltipContent:"hover"===p?()=>null:void 0}),"brush"===p&&e.createElement(Vn,{frameRef:f,cellSize:i,xField:o,yField:r,onBrush:k}))}function Kn({data:t,field:n,label:o,cellSize:i,bins:s,colorBy:a,colorScale:l,brushSelectionName:c,hoverSelectionName:u,mode:h}){const d=Bt({name:c,clientId:"splom-diag-"+n}),g=Bt({name:u,clientId:`splom-diag-${n}-hover`}),p="hover"===h?g:d,y=p.isActive,f=p.predicate,m=r(()=>{const e=t.map(e=>e[n]).filter(e=>null!=e&&!isNaN(e));if(0===e.length)return{bars:[],selectedBars:[],categoryBars:[],selectedCategoryBars:[],max:0,categories:[]};const o=Math.min(...e),r=(Math.max(...e)-o)/s||1,l="string"==typeof a?a:null,c=l?[...new Set(t.map(e=>e[l]).filter(e=>null!=e).map(String))]:[],u=new Map(c.map((e,t)=>[e,t])),h=Array(s).fill(0),d=Array(s).fill(0),g=Array.from({length:s},()=>Array(c.length).fill(0)),p=Array.from({length:s},()=>Array(c.length).fill(0));for(const e of t){const t=e[n];if(null==t||isNaN(t))continue;const i=Math.min(Math.floor((t-o)/r),s-1);if(h[i]++,y&&!f(e)||d[i]++,l){const t=u.get(e[l]+"");void 0!==t&&(g[i][t]++,y&&!f(e)||p[i][t]++)}}const m=Math.max(...h,1),v=g.map((e,t)=>{let n=0;return e.map((e,o)=>{const r=e/m*(i-24),a={x:t/s*i,w:i/s-1,h:r,y0:n,category:c[o]};return n+=r,a})}),b=p.map((e,t)=>{let n=0;return e.map((e,o)=>{const r=e/m*(i-24),a={x:t/s*i,w:i/s-1,h:r,y0:n,category:c[o]};return n+=r,a})});return{bars:h.map((e,t)=>({x:t/s*i,w:i/s-1,h:e/m*(i-24),count:e})),selectedBars:d.map((e,t)=>({x:t/s*i,w:i/s-1,h:e/m*(i-24),count:e})),categoryBars:v,selectedCategoryBars:b,max:m,categories:c}},[t,n,s,i,y,f,a]);return e.createElement("svg",{width:i,height:i,style:{overflow:"hidden"}},e.createElement("text",{x:i/2,y:14,textAnchor:"middle",fontSize:11,fontWeight:"bold",fill:"#333"},o),m.categories.length>0?m.categoryBars.map((t,n)=>t.map((t,o)=>e.createElement("rect",{key:`bg-${n}-${o}`,x:t.x,y:i-t.y0-t.h,width:Math.max(t.w,1),height:t.h,fill:l?l(t.category):Rt,opacity:y?.3:.6}))):m.bars.map((t,n)=>e.createElement("rect",{key:"bg-"+n,x:t.x,y:i-t.h,width:Math.max(t.w,1),height:t.h,fill:Rt,opacity:y?.3:.6})),y&&(m.categories.length>0?m.selectedCategoryBars.map((t,n)=>t.map((t,o)=>e.createElement("rect",{key:`sel-${n}-${o}`,x:t.x,y:i-t.y0-t.h,width:Math.max(t.w,1),height:t.h,fill:l?l(t.category):Rt,opacity:.7}))):m.selectedBars.map((t,n)=>e.createElement("rect",{key:"sel-"+n,x:t.x,y:i-t.h,width:Math.max(t.w,1),height:t.h,fill:Rt,opacity:.7}))))}function Un({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 Zn(t){const{data:o,fields:i,fieldLabels:s={},colorBy:l,colorScheme:c="category10",cellSize:u=150,cellGap:h=4,pointRadius:d=2,pointOpacity:g=.5,diagonal:p="histogram",histogramBins:y=20,brushMode:f="crossfilter",hoverMode:m=!0,unselectedOpacity:v=.1,showGrid:b=!1,tooltip:x,showLegend:k,idAccessor:w,className:A,onObservation:S,chartId:O}=t,E="splom",j="splom-hover",C=m?"hover":f?"brush":"hover",M=Pt(e=>e.clearSelection),[P,_]=n(null),L=a(()=>{M(j),_(null)},[M,j]),B=r(()=>(o||[]).map((e,t)=>void 0!==e[qn]?e:Object.assign(Object.assign({},e),{[qn]:t})),[o]),N=Yt(B,l,c),H=void 0!==k?k:!!l,z=r(()=>{if(!H||!l)return null;const e="string"==typeof l?l:null;return e?[...new Set(B.map(t=>t[e]))].map(e=>({label:e+"",color:N?N(e+""):Rt})):null},[H,l,B,N]),$=r(()=>({display:"grid",gridTemplateColumns:"40px "+i.map(()=>u+"px").join(" "),gridTemplateRows:i.map(()=>u+"px").join(" ")+" 40px",gap:h+"px",width:"fit-content"}),[i,u,h,40]);return e.createElement("div",{className:A,style:{position:"relative"}},z&&e.createElement("div",{style:{display:"flex",gap:12,marginBottom:8,flexWrap:"wrap"}},z.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:$,onMouseLeave:"hover"===C?L:void 0},i.map((t,n)=>e.createElement(e.Fragment,{key:"row-"+t},e.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",writingMode:"vertical-rl",transform:"rotate(180deg)",fontSize:11,fontWeight:"bold",color:"#333"}},s[t]||t),i.map((o,r)=>n===r?"label"===p?e.createElement(Un,{key:"diag-"+t,label:s[t]||t,cellSize:u}):e.createElement(Kn,{key:"diag-"+t,data:B,field:t,label:s[t]||t,cellSize:u,bins:y,colorBy:l,colorScale:N,brushSelectionName:E,hoverSelectionName:j,unselectedOpacity:v,mode:C}):e.createElement(Qn,{key:`cell-${t}-${o}`,data:B,xField:o,yField:t,fieldLabels:s,cellSize:u,pointRadius:d,pointOpacity:g,colorBy:l,colorScale:N,brushSelectionName:E,hoverSelectionName:j,unselectedOpacity:v,showGrid:b,tooltip:x,mode:C,onPointHover:"hover"===C?(e,i,s)=>{e?(_({datum:e,xField:o,yField:t,colIndex:r,rowIndex:n,px:null!=i?i:0,py:null!=s?s:0}),S&&S({type:"hover",datum:e,x:null!=i?i:0,y:null!=s?s:0,timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:O})):(_(null),S&&S({type:"hover-end",timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:O}))}:void 0})))),e.createElement("div",null)," ",i.map(t=>e.createElement("div",{key:"col-label-"+t,style:{display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:"bold",color:"#333"}},s[t]||t))),P&&"hover"===C&&(()=>{const t=P.datum,n=s[P.xField]||P.xField,o=s[P.yField]||P.yField,r=l?"function"==typeof l?l(t):t[l]:null,i=w?"function"==typeof w?w(t):t[w]:"Row "+t[qn];return e.createElement("div",{style:{position:"absolute",left:40+P.colIndex*(u+h)+P.px,top:P.rowIndex*(u+h)+P.py-8,transform:"translate(-50%, -100%)",color:"#333",background:"rgba(255,255,255,0.95)",border:"1px solid #ddd",borderRadius:3,padding:"4px 8px",fontSize:11,lineHeight:1.4,whiteSpace:"nowrap",pointerEvents:"none",zIndex:10}},e.createElement("div",{style:{fontWeight:"bold",marginBottom:2}},i+""),e.createElement("div",null,n,": ",null!=t[P.xField]?Number(t[P.xField]).toFixed(1):"–"),e.createElement("div",null,o,": ",null!=t[P.yField]?Number(t[P.yField]).toFixed(1):"–"),null!=r&&e.createElement("div",{style:{opacity:.8}},"string"==typeof l?l:"group",": ",r+""))})())}function Jn(t){const{brushMode:n="crossfilter",hoverMode:o=!0}=t,r={};return!o&&n&&(r.splom={resolution:n}),o&&(r["splom-hover"]={resolution:"union"}),e.createElement(Tt,{selections:r},e.createElement(Zn,Object.assign({},t)))}function eo({width:n,height:r,margin:i,scales:s,brushDirection:a,extent:l,onBrush:c}){const u=t(null),h=t(null),p=t(!1),f=n+i.left+i.right,m=r+i.top+i.bottom;return o(()=>{if(!u.current||!s)return;const e=y(u.current).select(".brush-group"),t="x"===a?d().extent([[0,0],[n,r]]):g().extent([[0,0],[n,r]]);return t.on("brush end",e=>{if(p.current)return;if(!e.sourceEvent)return;const t=e.selection;if(!t)return void c(null);const n=("x"===a?s.x:s.y).invert;if(!n)return;const o=[n(t[0]),n(t[1])];c(o)}),e.call(t),h.current=t,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.2).attr("stroke","steelblue").attr("stroke-width",1),()=>{t.on("brush end",null)}},[s,n,r,a,c]),o(()=>{if(!h.current||!s||!u.current)return;const e=y(u.current).select(".brush-group"),t="x"===a?s.x:s.y;if(p.current=!0,l){const n=[t(l[0]),t(l[1])];e.call(h.current.move,n)}else e.call(h.current.move,null);p.current=!1},[l,s,a]),e.createElement("svg",{ref:u,width:f,height:m,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},e.createElement("g",{className:"brush-group",transform:`translate(${i.left},${i.top})`}))}function to(i){var s,l;const{data:c,width:u=600,height:h=400,margin:d,className:g,title:p,xLabel:y,yLabel:f,xFormat:m,yFormat:v,xAccessor:b="x",yAccessor:x="y",lineBy:k,lineDataAccessor:w="coordinates",colorBy:A,colorScheme:S="category10",curve:O="linear",lineWidth:E=2,fillArea:j=!1,areaOpacity:C=.3,showPoints:M=!1,pointRadius:P=3,enableHover:_=!0,showGrid:L=!1,showLegend:B,legendPosition:N,tooltip:H,minimap:z={},renderBefore:$=!1,onBrush:W,brushExtent:T,frameProps:I={},loading:F,emptyContent:D}=i,R=Bn(F,u,h);if(R)return R;const G=Ln(c,u,h,D);if(G)return G;const Y=c||[],[q,X]=n(null),V=null!=T?T:q,Q=a(e=>{T||X(e),null==W||W(e)},[T,W]),K=t(null),[U,Z]=n(null);o(()=>{const e=()=>{var t,n;const o=null===(n=null===(t=K.current)||void 0===t?void 0:t.getScales)||void 0===n?void 0:n.call(t);o?Z(o):requestAnimationFrame(e)};requestAnimationFrame(e)},[c]);const J=void 0!==(null===(s=Y[0])||void 0===s?void 0:s[w]),ee=r(()=>{if(J)return Y;if(k){const e=Y.reduce((e,t)=>{const n="function"==typeof k?k(t):t[k];if(!e[n]){const t={[w]:[]};"string"==typeof k&&(t[k]=n),e[n]=t}return e[n][w].push(t),e},{});return Object.values(e)}return[{[w]:Y}]},[Y,k,w,J]),te=r(()=>J||k?ee.flatMap(e=>{const t=e[w]||[];return k&&"string"==typeof k?t.map(t=>Object.assign(Object.assign({},t),{[k]:e[k]})):t}):Y,[ee,w,J,k,Y]),ne=Yt(Y,A,S),oe=r(()=>e=>{const t={strokeWidth:E};return t.stroke=A?le(e,A,ne):Rt,j&&(t.fill=t.stroke,t.fillOpacity=C),t},[A,ne,E,j,C]),re=r(()=>z.lineStyle?z.lineStyle:e=>{const t={strokeWidth:1};return t.stroke=A?le(e,A,ne):Rt,t},[A,ne,z.lineStyle]),ie=r(()=>{if(M)return e=>{const t={r:P,fillOpacity:1};return t.fill=A?le(e.parentLine||e,A,ne):Rt,t}},[M,P,A,ne]),{legend:se,margin:ae,legendPosition:ce}=Xt({data:ee,colorBy:A,colorScale:ne,showLegend:B,legendPosition:N,userMargin:d}),ue=z.height||60,he=r(()=>{var e,t,n,o,r,i,s,a;return{top:null!==(t=null===(e=z.margin)||void 0===e?void 0:e.top)&&void 0!==t?t:0,bottom:null!==(o=null===(n=z.margin)||void 0===n?void 0:n.bottom)&&void 0!==o?o:20,left:null!==(i=null===(r=z.margin)||void 0===r?void 0:r.left)&&void 0!==i?i:ae.left,right:null!==(a=null===(s=z.margin)||void 0===s?void 0:s.right)&&void 0!==a?a:ae.right}},[z.margin,ae]),de=z.brushDirection||"x",ge=gn({componentName:"MinimapChart",data:c,accessors:{xAccessor:b,yAccessor:x}});if(ge)return e.createElement(an,{componentName:"MinimapChart",message:ge,width:u,height:h});const pe=j?"area":"line",ye=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:pe,data:te,xAccessor:b,yAccessor:x,groupAccessor:k||void 0,curve:O,lineStyle:oe},M&&{pointStyle:ie}),{size:[u,h],responsiveWidth:i.responsiveWidth,responsiveHeight:i.responsiveHeight,margin:ae,showAxes:!0,xLabel:y,yLabel:f,xFormat:m,yFormat:v,enableHover:_,showGrid:L}),se&&{legend:se,legendPosition:ce}),p&&{title:p}),H&&{tooltipContent:tn(H)||void 0}),V&&{xExtent:V}),I),fe={chartType:pe,data:te,xAccessor:b,yAccessor:x,groupAccessor:k||void 0,curve:O,lineStyle:re,size:[u,ue+he.top+he.bottom],margin:he,showAxes:null!==(l=z.showAxes)&&void 0!==l&&l,background:z.background,enableHover:!1},me=e.createElement("div",{key:"minimap",style:{position:"relative",width:u,overflow:"hidden"}},e.createElement(St,Object.assign({ref:K},fe)),e.createElement(eo,{width:u-he.left-he.right,height:ue,margin:he,scales:U,brushDirection:de,extent:V,onBrush:Q})),ve=e.createElement("div",{key:"main",style:{overflow:"hidden"}},e.createElement(St,Object.assign({},ye)));return e.createElement(Mn,{componentName:"MinimapChart",width:u,height:h},e.createElement("div",{className:"minimap-chart"+(g?" "+g:"")},$?me:ve,$?ve:me))}Jn.displayName="ScatterplotMatrix",to.displayName="MinimapChart";const no=c(function(n,o){const i=t(null);u(o,()=>({push:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=i.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=i.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const s=Kt(n.mode,{width:n.width,height:n.height,showGrid:n.showGrid,enableHover:n.enableHover,showLegend:n.showLegend,title:n.title,xLabel:n.xLabel,yLabel:n.yLabel}),{data:a,margin:l,className:c,xFormat:h,yFormat:d,xAccessor:g="x",yAccessor:p="y",xCenter:y,yCenter:f,quadrants:m,centerlineStyle:v={},showQuadrantLabels:b=!0,quadrantLabelSize:x=12,colorBy:k,colorScheme:w="category10",sizeBy:A,sizeRange:S=[3,15],pointRadius:O=5,pointOpacity:E=.8,tooltip:j,pointIdAccessor:C,annotations:M,frameProps:P={},selection:_,linkedHover:L,onObservation:B,chartId:N,loading:H,emptyContent:z,legendInteraction:$,legendPosition:W}=n,T=s.width,I=s.height,F=s.enableHover,D=s.showGrid,R=s.showLegend,G=s.title,Y=s.xLabel,q=s.yLabel,X=Bn(H,T,I);if(X)return X;const V=Ln(a,T,I,z);if(V)return V;const Q=a||[];Nn("QuadrantChart",Q,"xAccessor",g),Nn("QuadrantChart",Q,"yAccessor",p);const{activeSelectionHook:K,customHoverBehavior:U}=qt({selection:_,linkedHover:L,fallbackFields:"string"==typeof k?[k]:[],onObservation:B,chartType:"QuadrantChart",chartId:N}),Z=Yt(Q,k,w),J=r(()=>{if(!k)return[];const e=new Set;for(const t of Q){const n="function"==typeof k?k(t):t[k];null!=n&&e.add(n+"")}return Array.from(e)},[Q,k]),ee=Vt($,k,J),te=r(()=>ee.legendSelectionHook?ee.legendSelectionHook:K,[ee.legendSelectionHook,K]),ne=r(()=>{if(!Q.length)return;const e="function"==typeof g?g:e=>+e[g],t="function"==typeof p?p:e=>+e[p];let n=1/0,o=-1/0,r=1/0,i=-1/0;for(const s of Q){const a=e(s),l=t(s);isFinite(a)&&(n>a&&(n=a),a>o&&(o=a)),isFinite(l)&&(r>l&&(r=l),l>i&&(i=l))}if(null!=y&&isFinite(y)&&(n>y&&(n=y),y>o&&(o=y)),null!=f&&isFinite(f)&&(r>f&&(r=f),f>i&&(i=f)),n===1/0)return;const s=.1*(o-n)||1,a=.1*(i-r)||1;return{xExtent:[n-s,o+s],yExtent:[r-a,i+a]}},[Q,g,p,y,f]),oe=r(()=>{if(!A||0===Q.length)return;const e=Q.map(e=>"function"==typeof A?A(e):e[A]).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0!==e.length?[Math.min(...e),Math.max(...e)]:void 0},[Q,A]),re=r(()=>"function"==typeof g?g:e=>+e[g],[g]),ie=r(()=>"function"==typeof p?p:e=>+e[p],[p]),se=r(()=>e=>{const t={fillOpacity:E};if(k)Z&&(t.fill=le(e,k,Z));else{const n=re(e),o=ie(e),r=null!=y?n>=y:void 0,i=null!=f?o>=f:void 0;t.fill=void 0===i||void 0===r?Rt:i&&r?m.topRight.color:i&&!r?m.topLeft.color:!i&&r?m.bottomRight.color:m.bottomLeft.color}return t.r=A?ue(e,A,S,oe):O,t},[k,Z,A,S,oe,O,E,re,ie,y,f,m]),ae=r(()=>Dt(se,te,_),[se,te,_]),{legend:ce,margin:he,legendPosition:de}=Xt({data:Q,colorBy:k,colorScale:Z,showLegend:R,legendPosition:W,userMargin:l,defaults:s.marginDefaults}),ge=r(()=>{if(!Q.length)return;const e=new Set;"string"==typeof g&&e.add(g),"string"==typeof p&&e.add(p),"string"==typeof k&&e.add(k),"string"==typeof A&&e.add(A);const t=Q[0];for(const n of Object.keys(t))if(!n.startsWith("_")&&!e.has(n)&&"string"==typeof t[n])return n},[Q,g,p,k,A]),pe=r(()=>sn([...ge?[{label:ge,accessor:ge,role:"title"}]:[],{label:Y||nn(g),accessor:g,role:"x"},{label:q||nn(p),accessor:p,role:"y"},...k?[{label:nn(k),accessor:k,role:"color"}]:[],...A?[{label:nn(A),accessor:A,role:"size"}]:[]]),[ge,g,p,Y,q,k,A]),ye=gn({componentName:"QuadrantChart",data:a,accessors:{xAccessor:g,yAccessor:p}});if(ye)return e.createElement(an,{componentName:"QuadrantChart",message:ye,width:T,height:I});const fe=r(()=>{var e;const t={stroke:v.stroke||"#999",strokeWidth:null!==(e=v.strokeWidth)&&void 0!==e?e:1,dashArray:v.strokeDasharray||[]};return[(e,n,o,r)=>{var i;if(!(null==o?void 0:o.x)||!(null==o?void 0:o.y))return;const s=r.width,a=r.height,l=null!=y?o.x(y):s/2,c=null!=f?o.y(f):a/2;if(null!=y&&!isFinite(l))return;if(null!=f&&!isFinite(c))return;const u=Math.max(0,Math.min(s,l)),h=Math.max(0,Math.min(a,c)),d=[{config:m.topLeft,x:0,y:0,w:u,h:h},{config:m.topRight,x:u,y:0,w:s-u,h:h},{config:m.bottomLeft,x:0,y:h,w:u,h:a-h},{config:m.bottomRight,x:u,y:h,w:s-u,h:a-h}];for(const t of d)t.w>0&&t.h>0&&(e.fillStyle=t.config.color,e.globalAlpha=null!==(i=t.config.opacity)&&void 0!==i?i:.08,e.fillRect(t.x,t.y,t.w,t.h));e.globalAlpha=1,e.strokeStyle=t.stroke,e.lineWidth=t.strokeWidth,t.dashArray.length>0&&e.setLineDash(t.dashArray),e.beginPath(),e.moveTo(u,0),e.lineTo(u,a),e.stroke(),e.beginPath(),e.moveTo(0,h),e.lineTo(s,h),e.stroke(),e.setLineDash([])}]},[y,f,m,v]),me=r(()=>b?[...fe,(e,t,n,o)=>{if(!(null==n?void 0:n.x)||!(null==n?void 0:n.y))return;const r=o.width,i=o.height,s=null!=y?n.x(y):r/2,a=null!=f?n.y(f):i/2;(null==y||isFinite(s))&&(null==f||isFinite(a))&&(e.font=`600 ${x}px sans-serif`,e.globalAlpha=.5,e.fillStyle=m.topLeft.color,e.textAlign="left",e.textBaseline="top",e.fillText(m.topLeft.label,8,8),e.fillStyle=m.topRight.color,e.textAlign="right",e.textBaseline="top",e.fillText(m.topRight.label,r-8,8),e.fillStyle=m.bottomLeft.color,e.textAlign="left",e.textBaseline="bottom",e.fillText(m.bottomLeft.label,8,i-8),e.fillStyle=m.bottomRight.color,e.textAlign="right",e.textBaseline="bottom",e.fillText(m.bottomRight.label,r-8,i-8),e.globalAlpha=1)}]:fe,[fe,b,x,m,y,f]),ve=r(()=>{const e=P.canvasPreRenderers||[];return[...me,...e]},[me,P.canvasPreRenderers]),be=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter"},null!=a&&{data:Q}),{xAccessor:g,yAccessor:p,colorAccessor:k||void 0,sizeAccessor:A||void 0,sizeRange:S,pointStyle:ae,colorScheme:w,size:[T,I],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:he,showAxes:s.showAxes,xLabel:Y,yLabel:q,xFormat:h,yFormat:d,enableHover:F,showGrid:D}),ne&&{xExtent:ne.xExtent,yExtent:ne.yExtent}),ce&&{legend:ce,legendPosition:de}),$&&"none"!==$&&{legendHoverBehavior:ee.onLegendHover,legendClickBehavior:ee.onLegendClick,legendHighlightedCategory:ee.highlightedCategory,legendIsolatedCategories:ee.isolatedCategories}),G&&{title:G}),c&&{className:c}),{tooltipContent:!1===j?()=>null:!0===j||void 0===j?pe:tn(j)||pe}),(L||B)&&{customHoverBehavior:U}),C&&{pointIdAccessor:C}),M&&M.length>0&&{annotations:M}),{canvasPreRenderers:ve}),P),ve.length>0&&{canvasPreRenderers:ve});return e.createElement(Mn,{componentName:"QuadrantChart",width:T,height:I},e.createElement(St,Object.assign({ref:i},be)))});no.displayName="QuadrantChart";export{Tn as AreaChart,Gn as BubbleChart,Rn as ConnectedScatterplot,Yn as Heatmap,Wn as LineChart,to as MinimapChart,no as QuadrantChart,Fn as Scatterplot,Jn as ScatterplotMatrix,In as StackedAreaChart,St as StreamXYFrame};
|