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.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("react"),t=require("d3-brush"),n=require("d3-selection"),o=require("d3-scale"),i=require("d3-scale-chromatic"),r=require("d3-quadtree"),l=require("d3-array"),s=require("d3-hierarchy"),a=require("d3-shape"),c=require("regression");function u(e){return e&&e.__esModule?e:{default:e}}function h(e){if(e&&e.__esModule)return e;const t=Object.create(null);if(e)for(const n in e)if("default"!==n){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:function(){return e[n]}})}return t.default=e,Object.freeze(t)}const d=h(e),f=u(c);class g{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 p{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 y{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 m(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 v(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 b(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),u=s?s(r):i;a.push({px:c,topY:t.y(l),botY:t.y(u)})}a.sort((e,t)=>e.px-t.px);const c=Array(a.length),u=Array(a.length);for(let e=0;a.length>e;e++){const t=a[e];c[e]=[t.px,t.topY],u[e]=[t.px,t.botY]}return{type:"area",topPath:c,bottomPath:u,style:r,datum:e,group:l}}function x(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 k(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 w(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 A(e,t){if("function"==typeof e)return t=>+e(t);const n=e||t;return e=>+e[n]}function M(e,t){if("function"==typeof e)return e;const n=e||t;return e=>e[n]}function S(e,t){return"function"==typeof e?e:e?t=>t[e]+"":void 0}const E={category10:i.schemeCategory10,tableau10:i.schemeTableau10,set3:i.schemeSet3,blues:i.interpolateBlues,reds:i.interpolateReds,greens:i.interpolateGreens,oranges:i.interpolateOranges,purples:i.interpolatePurples,viridis:i.interpolateViridis,plasma:i.interpolatePlasma},O=i.schemeCategory10,C=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],j=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 P(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")||j.has(t)}(o)?n(o):o}const o=e[t];return n?n(o):O[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+""))%O.length]}function _(e,t,n="category10"){const i=Array.from(new Set(e.map(e=>null==e?void 0:e[t]).filter(e=>null!=e))),r=i.every(e=>"number"==typeof e||!isNaN(Number(e)));if(Array.isArray(n))return o.scaleOrdinal().domain(i).range(n).unknown("#999");const l=E[n]||E.category10;if(r&&"function"==typeof l){let e=-1/0;for(const t of i){const n=Number(t);n>e&&(e=n)}return t=>l(Number(t)/e)}{const e=Array.isArray(l)?l:O;return o.scaleOrdinal().domain(i).range(e).unknown("#999")}}function L(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 B(e,t,n){return e+(t-e)*n}class N{constructor(e){this.xExtent=new y,this.yExtent=new y,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 p(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=A(e.timeAccessor||e.xAccessor,"time"),this.getY=A(e.valueAccessor||e.yAccessor,"value")):(this.getX=A(e.xAccessor,"x"),this.getY=A(e.yAccessor,"y")),this.getGroup=S(e.groupAccessor),this.getCategory=S(e.categoryAccessor),this.getSize=e.sizeAccessor?A(e.sizeAccessor,"size"):void 0,this.getColor=S(e.colorAccessor),this.getBounds=e.boundsAccessor?A(e.boundsAccessor,"bounds"):void 0,this.getY0=e.y0Accessor?A(e.y0Accessor,"y0"):void 0,this.getPointId=S(e.pointIdAccessor),"candlestick"===e.chartType&&(this.getOpen=A(e.openAccessor,"open"),this.getHigh=A(e.highAccessor,"high"),this.getLow=A(e.lowAccessor,"low"),this.getClose=A(e.closeAccessor,"close")),e.pulse&&(this.timestampBuffer=new p(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,i,r,l,s;const{config:a,buffer:c}=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(c,this.getX),this.yExtent.dirty)if("candlestick"===a.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const e of c)this.yExtent.push(this.getHigh(e)),this.yExtent.push(this.getLow(e))}else this.yExtent.recalculate(c,this.getY);const u=this.getBufferArray(),h=this.xExtent.extent,d=this.yExtent.extent;let f=a.xExtent?[null!==(t=a.xExtent[0])&&void 0!==t?t:h[0],null!==(n=a.xExtent[1])&&void 0!==n?n:h[1]]:h,g=a.yExtent?[null!==(i=a.yExtent[0])&&void 0!==i?i:d[0],null!==(r=a.yExtent[1])&&void 0!==r?r:d[1]]:d;const p=a.yExtent&&null!=a.yExtent[0]&&null!=a.yExtent[1];if("stackedarea"===a.chartType&&!p&&c.size>0)if(a.normalize)g=[0,1+a.extentPadding];else{const e=`${c.size}:${this._ingestVersion}`;if(this._stackExtentCache&&this._stackExtentCache.key===e)g=this._stackExtentCache.yDomain;else{const t=this.groupData(u),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&&c.size>0){const[,e]=function(e,t,n,o,i){const r=m(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]}(c,this.getX,this.getY,a.binSize,this.getCategory);g=[0,e+e*a.extentPadding]}else if("waterfall"===a.chartType&&!p&&c.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]}(c,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 u){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===(l=a.yExtent)||void 0===l?void 0:l[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]&&d[0]>0&&(g[0]=null!=n?g[0]:d[0]/(1+a.extentPadding))}if(f[0]!==1/0&&f[1]!==-1/0||(f=[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:o.scaleLinear().domain(f).range(t),y:o.scaleLinear().domain(g).range([e.height,0])}}else{const t="down"===a.arrowOfTime?[0,e.height]:[e.height,0];this.scales={x:o.scaleLinear().domain(g).range([0,e.width]),y:o.scaleLinear().domain(f).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 o.scaleLog().domain(e).range(n).clamp(!0)}return o.scaleLinear().domain(t).range(n)};this.scales={x:t(a.xScaleType,f,[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,u),this.config.decay&&this.applyDecay(this.scene,u),this.config.pulse&&this.applyPulse(this.scene,u),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.rebuildQuadtree(),this.needsFullRebuild=!1,this.lastLayout={width: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>N.QUADTREE_THRESHOLD?r.quadtree().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 i=this.scales.x.domain(),r=this.scales.y.domain(),l=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 o.scaleLog().domain(e).range(n).clamp(!0)}return o.scaleLinear().domain(t).range(n)};this.scales={x:a(this.config.xScaleType,i,[l[0]*t,l[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=[],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=v(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=b(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),u=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)}u.set(t.key,e)}let h;if(r){h=new Map;for(const t of c){let n=0;for(const o of e)n+=(null===(s=u.get(o.key))||void 0===s?void 0:s.get(t))||0;h.set(t,n||1)}}const d=[],f=new Map;for(const e of c)f.set(e,0);for(const n of e){const e=u.get(n.key),o=[],s=[];for(const n of c){let i=e.get(n)||0;const l=f.get(n);r&&(i/=h.get(n));const a=t.x(n);s.push([a,t.y(l)]),o.push([a,t.y(l+i)]),f.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=x(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 r=A(this.config.valueAccessor,"value"),l=M(this.config.xAccessor,"x"),s=M(this.config.yAccessor,"y"),a=new Set,c=new Set;for(const t of e)a.add(l(t)),c.add(s(t));const u=Array.from(a),h=Array.from(c),d=u.every(e=>"number"==typeof e&&!isNaN(e)),f=h.every(e=>"number"==typeof e&&!isNaN(e)),g=d?u.sort((e,t)=>e-t):u,p=f?h.sort((e,t)=>e-t):h;if(0===g.length||0===p.length)return n;const y=t.width/g.length,m=t.height/p.length,v=new Map;for(const t of e){const e=`${l(t)}\0${s(t)}`;v.set(e,{val:r(t),datum:t})}let b=1/0,x=-1/0;for(const{val:e}of v.values())b>e&&(b=e),e>x&&(x=e);const k=o.scaleSequential({blues:i.interpolateBlues,reds:i.interpolateReds,greens:i.interpolateGreens,viridis:i.interpolateViridis}["string"==typeof this.config.colorScheme?this.config.colorScheme:"blues"]||i.interpolateBlues).domain([b,x]);for(let e=0;g.length>e;e++)for(let t=0;p.length>t;t++){const o=v.get(`${g[e]}\0${p[t]}`);if(!o)continue;const i=k(o.val);n.push(w(e*y,(p.length-1-t)*m,y,m,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=A(this.config.valueAccessor,"value");if(!this.scales||0===e.length)return r;const[u,h]=this.scales.x.domain(),[d,f]=this.scales.y.domain(),g=(h-u||1)/l,p=(f-d||1)/s,y=new Map;for(const t of e){const e=this.getX(t),n=this.getY(t),o=Math.min(Math.floor((e-u)/g),l-1),i=Math.min(Math.floor((n-d)/p),s-1);if(0>o||0>i)continue;const r=`${o}_${i}`;let a=y.get(r);a||(a={sum:0,count:0,data:[]},y.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 y){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,M=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)})`,u=y.get(e);r.push(w(i*k,(s-1-l)*M,k,M,c,{xi:i,yi:l,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 r}buildBarScene(e){var t;if(!this.config.binSize)return[];const n=m(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),u=r.x(a),h=Math.abs(u-c),d=h>2?1:0,f=Math.min(c,u)+d/2,g=Math.max(h-d,1);if(g>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(k(f,Math.min(s,a),g,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(k(f,Math.min(t,n),g,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,u=l.stroke,h=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 f={type:"point",x:o,y:l,r:s,style:{fill:d,opacity:c,stroke:u,strokeWidth:h},datum:t};this.getPointId&&(f.pointId=this.getPointId(t)+""),r.push(f)}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",u=null!==(o=null==s?void 0:s.negativeColor)&&void 0!==o?o:"#dc3545",h=null!==(i=null==s?void 0:s.gap)&&void 0!==i?i:1,d=null==s?void 0:s.stroke,f=null==s?void 0:s.strokeWidth;let g=0;for(let e=0;a.length>e;e++){const n=a[e],o=this.getX(n),i=this.getY(n),p=g+i;let y;y=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!==y?l.x(o+y):m+t.width/10,b=Math.min(m,v)+h/2,x=Math.max(m,v)-h/2-b;if(0>=x){g=p;continue}const w=l.y(g),A=l.y(p);r.push(k(b,Math.min(w,A),x,Math.abs(w-A),{fill:0>i?u:c,stroke:d,strokeWidth:f},Object.assign(Object.assign({},n),{baseline:g,cumEnd:p,delta:i,_connectorStroke:null==s?void 0:s.connectorStroke,_connectorWidth:null==s?void 0:s.connectorWidth}))),g=p}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),u=this.getLow(t),h=this.getClose(t);if([o,a,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(a),lowY:this.scales.y(u),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,u,h,d,f,g,p,y,m,v,b,x,k,w,A,M,S;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 O=!1;const C=new Set,j=new Set;for(let e=0;this.scene.length>e;e++){const y=this.scene[e],m=this.getNodeIdentity(y,e);if(!m)continue;if(y._transitionKey=m,"line"===y.type||"area"===y.type){const e=this.prevPathMap.get(m);if(e){if(j.add(m),"line"===y.type&&e.path&&e.path.length===y.path.length){y._targetPath=y.path.map(e=>[e[0],e[1]]),y._prevPath=e.path;for(let t=0;y.path.length>t;t++)y.path[t]=[e.path[t][0],e.path[t][1]];O=!0}else if("area"===y.type&&e.topPath&&e.bottomPath&&e.topPath.length===y.topPath.length&&e.bottomPath.length===y.bottomPath.length){y._targetTopPath=y.topPath.map(e=>[e[0],e[1]]),y._targetBottomPath=y.bottomPath.map(e=>[e[0],e[1]]),y._prevTopPath=e.topPath,y._prevBottomPath=e.bottomPath;for(let t=0;y.topPath.length>t;t++)y.topPath[t]=[e.topPath[t][0],e.topPath[t][1]];for(let t=0;y.bottomPath.length>t;t++)y.bottomPath[t]=[e.bottomPath[t][0],e.bottomPath[t][1]];O=!0}y._targetOpacity=null!==(t=y.style.opacity)&&void 0!==t?t:1}else y._targetOpacity=null!==(n=y.style.opacity)&&void 0!==n?n:1,y.style=Object.assign(Object.assign({},y.style),{opacity:0}),O=!0;continue}const v=this.prevPositionMap.get(m);if("point"===y.type)if(v){C.add(m);const e={x:y.x,y:y.y,r:y.r};y._targetOpacity=null!==(o=y.style.opacity)&&void 0!==o?o:1,v.x===e.x&&v.y===e.y||(y._targetX=e.x,y._targetY=e.y,y._targetR=e.r,y.x=v.x,y.y=v.y,y.r=null!==(i=v.r)&&void 0!==i?i:y.r,O=!0)}else y._targetOpacity=null!==(r=y.style.opacity)&&void 0!==r?r:1,y.style=Object.assign(Object.assign({},y.style),{opacity:0}),O=!0;else if("rect"===y.type)if(v){C.add(m);const e={x:y.x,y:y.y,w:y.w,h:y.h};y._targetOpacity=null!==(l=y.style.opacity)&&void 0!==l?l:1,v.x===e.x&&v.y===e.y&&v.w===e.w&&v.h===e.h||(y._targetX=e.x,y._targetY=e.y,y._targetW=e.w,y._targetH=e.h,y.x=v.x,y.y=v.y,y.w=null!==(s=v.w)&&void 0!==s?s:y.w,y.h=null!==(a=v.h)&&void 0!==a?a:y.h,O=!0)}else y._targetOpacity=null!==(c=y.style.opacity)&&void 0!==c?c:1,y.style=Object.assign(Object.assign({},y.style),{opacity:0}),O=!0;else if("heatcell"===y.type)if(v){C.add(m);const e={x:y.x,y:y.y,w:y.w,h:y.h};y._targetOpacity=null!==(h=null===(u=y.style)||void 0===u?void 0:u.opacity)&&void 0!==h?h:1,v.x===e.x&&v.y===e.y||(y._targetX=e.x,y._targetY=e.y,y._targetW=e.w,y._targetH=e.h,y.x=v.x,y.y=v.y,y.w=null!==(d=v.w)&&void 0!==d?d:y.w,y.h=null!==(f=v.h)&&void 0!==f?f:y.h,O=!0)}else y._targetOpacity=null!==(p=null===(g=y.style)||void 0===g?void 0:g.opacity)&&void 0!==p?p:1,y.style=Object.assign(Object.assign({},y.style||{}),{opacity:0}),O=!0}for(const[e,t]of this.prevPathMap)if(!j.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!==(y=t.opacity)&&void 0!==y?y:1},_targetOpacity:0,_transitionKey:e,datum:null};this.exitNodes.push(n),O=!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),O=!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!==(M=t.h)&&void 0!==M?M:0,fill:"#999",datum:null,style:{opacity:null!==(S=t.opacity)&&void 0!==S?S:1},_targetOpacity:0,_transitionKey:e};this.exitNodes.push(n)}O=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),O&&(this.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:E})}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=B(i,e._targetOpacity,a)}if(void 0===e._targetX)continue;if(!t)continue;const o=this.prevPositionMap.get(t);if(!o)continue;e.x=B(o.x,e._targetX,a),e.y=B(o.y,e._targetY,a),void 0!==e._targetR&&void 0!==o.r&&(e.r=B(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=B(i,e._targetOpacity,a)}if(void 0===e._targetX)continue;if(!t)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=B(n.x,e._targetX,a),e.y=B(n.y,e._targetY,a),void 0!==n.w&&(e.w=B(n.w,e._targetW,a)),void 0!==n.h&&(e.h=B(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:B(o,e._targetOpacity,a)})}if(void 0===e._targetX)continue;if(!t)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=B(n.x,e._targetX,a),e.y=B(n.y,e._targetY,a),void 0!==n.w&&(e.w=B(n.w,e._targetW,a)),void 0!==n.h&&(e.h=B(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:B(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]=B(t[o][0],n[o][0],a),e.path[o][1]=B(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:B(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]=B(t[n][0],o[n][0],a),e.topPath[n][1]=B(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]=B(n[t][0],i[t][0],a),e.bottomPath[t][1]=B(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:C,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:C,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=A(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=A(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=A(this.config.xAccessor,"x"),this.getY=A(this.config.yAccessor,"y"))),void 0!==e.groupAccessor&&(this.getGroup=S(this.config.groupAccessor)),void 0!==e.categoryAccessor&&(this.getCategory=S(this.config.categoryAccessor)),void 0!==e.sizeAccessor&&(this.getSize=this.config.sizeAccessor?A(this.config.sizeAccessor,"size"):void 0),void 0!==e.colorAccessor&&(this.getColor=S(this.config.colorAccessor)),void 0!==e.y0Accessor&&(this.getY0=this.config.y0Accessor?A(this.config.y0Accessor,"y0"):void 0),void 0!==e.pointIdAccessor&&(this.getPointId=S(this.config.pointIdAccessor)),this.needsFullRebuild=!0}}function H(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 W(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 z(e,t,n){var o,i,r,l;if(0===e.path.length)return null;const s=R(e.path,t);if(0>s)return null;const[a,c]=e.path[s];let u;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=T(t,n,i,r,s,a);o>c&&(o=c)}u=o}else{const e=t-a,o=n-c;u=Math.sqrt(e*e+o*o)}const h=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 u>Math.max(5,h/2+2)?null:{node:e,datum:Array.isArray(e.datum)&&e.datum[s]?e.datum[s]:e.datum,x:a,y:c,distance:u}}function T(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 u=o+c*s;return Math.sqrt(Math.pow(e-(n+c*l),2)+Math.pow(t-u,2))}function F(e,t,n){const o=H(t,n,e);return o.hit?{node:e,datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}function I(e,t,n){const o=H(t,n,e);return o.hit?{node:e,datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}function $(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 D(e,t,n){if(0===e.topPath.length)return null;const o=R(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 R(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}N.QUADTREE_THRESHOLD=500;const G={fill:e=>d.createElement("rect",{style:e,width:16,height:16}),line:e=>d.createElement("line",{style:e,x1:0,y1:0,x2:16,y2:16})};function Y(e,t,n,o){let i;return i="function"==typeof n?n(e):(0,G[n])(o(e,t)),i}function q(){return d.createElement("path",{d:"M4,8.8 L7.2,12 L12.8,4.8",fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function X(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}function V({config:e,orientation:t="vertical",width:n=100}){const{colorFn:o,domain:i,label:r,format:l}=e,s=l||(e=>Math.round(100*e)/100+""),a="grad-legend-"+d.useId();if("horizontal"===t){const e=12,t=Math.min(n,200),l=Math.max(0,(n-t)/2),c=[];for(let e=0;64>=e;e++){const t=e/64;c.push(d.createElement("stop",{key:e,offset:100*t+"%",stopColor:o(i[0]+t*(i[1]-i[0]))}))}return d.createElement("g",{"aria-label":r||"Gradient legend"},d.createElement("defs",null,d.createElement("linearGradient",{id:a,x1:"0%",y1:"0%",x2:"100%",y2:"0%"},c)),r&&d.createElement("text",{x:l+t/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},r),d.createElement("rect",{x:l,y:0,width:t,height:e,fill:`url(#${a})`,rx:2}),d.createElement("text",{x:l,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(i[0])),d.createElement("text",{x:l+t,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(i[1])))}const c=[];for(let e=0;64>=e;e++){const t=e/64;c.push(d.createElement("stop",{key:e,offset:100*t+"%",stopColor:o(i[1]-t*(i[1]-i[0]))}))}return d.createElement("g",{"aria-label":r||"Gradient legend"},r&&d.createElement("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},r),d.createElement("defs",null,d.createElement("linearGradient",{id:a,x1:"0%",y1:"0%",x2:"0%",y2:"100%"},c)),d.createElement("rect",{x:0,y:0,width:14,height:100,fill:`url(#${a})`,rx:2}),d.createElement("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(i[1])),d.createElement("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(i[0])))}function Q(e){const{legendGroups:t,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:r,legendInteraction:l,title:s="Legend",width:a=100,height:c=20,orientation:u="vertical"}=e,[h,f]=d.useState(0),[g,p]=d.useState(0),y=d.useCallback((e,t)=>{f(e),p(t)},[]),m="vertical"===u?(({legendGroups:e,width:t,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:r,focusedGroupIndex:l,focusedItemIndex:s,onFocusedIndexChange:a,legendInteraction:c})=>{let u=24;const h=[];return e.forEach((e,f)=>{u+=5,h.push(d.createElement("line",{key:"legend-top-line legend-symbol-"+f,stroke:"gray",x1:0,y1:u,x2:t,y2:u})),u+=8,e.label&&(u+=16,h.push(d.createElement("text",{key:"legend-text-"+f,y:u,className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label)),u+=8),h.push(d.createElement("g",{key:"legend-group-"+f,className:"legend-item",transform:`translate(0,${u})`},((e,t,n,o,i,r,l,s,a,c)=>{const{type:u="fill",styleFn:h,items:f}=e,g=[];let p=0;const y=!(!t&&!n),m="isolate"===c||void 0===c&&null!=i;return f.forEach((e,c)=>{const v=Y(e,c,u,h),b=X(e,o,i),x=i&&i.size>0&&i.has(e.label);g.push(d.createElement("g",{key:"legend-item-"+c,transform:`translate(0,${p})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:y?s===r&&c===l?0:-1:void 0,role:y?"option":void 0,"aria-selected":y&&m?x||!1:void 0,"aria-current":y&&!m&&null!=o&&e.label===o||void 0,"aria-label":e.label,onKeyDown:y?n=>{var o;if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowDown"===n.key||"ArrowUp"===n.key){n.preventDefault();const e=(c+("ArrowDown"===n.key?1:-1)+f.length)%f.length;a(s,e);const t=null===(o=n.currentTarget.parentElement)||void 0===o?void 0:o.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:y?t=>{a(s,c),n&&n(e);const o=t.currentTarget.querySelector(".semiotic-legend-focus-ring");o&&o.setAttribute("visibility","visible")}:void 0,onBlur:y?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:y?"pointer":"default",opacity:b,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},y&&d.createElement("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*e.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),v,x&&d.createElement(q,null),d.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label))),p+=22}),g})(e,n,o,i,r,l,s,f,a,c))),u+=22*e.items.length+8}),h})({legendGroups:t||[],width:a,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:r,focusedGroupIndex:h,focusedItemIndex:g,onFocusedIndexChange:y,legendInteraction:l}):(({legendGroups:e,height:t,width:n,customClickBehavior:o,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:l,focusedGroupIndex:s,focusedItemIndex:a,onFocusedIndexChange:c,legendInteraction:u})=>{let h=0;const f=[];e.forEach((e,t)=>{let n=0;e.label&&(n+=16);const g=((e,t,n,o,i,r,l,s,a,c)=>{const{type:u="fill",styleFn:h,items:f}=e,g=[];let p=0;const y=!(!t&&!n),m="isolate"===c||void 0===c&&null!=i;return f.forEach((e,c)=>{const v=Y(e,c,u,h),b=X(e,o,i),x=i&&i.size>0&&i.has(e.label);g.push(d.createElement("g",{key:"legend-item-"+c,transform:`translate(${p},0)`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:y?s===r&&c===l?0:-1:void 0,role:y?"option":void 0,"aria-selected":y&&m?x||!1:void 0,"aria-current":y&&!m&&null!=o&&e.label===o||void 0,"aria-label":e.label,onKeyDown:y?n=>{var o;if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowRight"===n.key||"ArrowLeft"===n.key){n.preventDefault();const e=(c+("ArrowRight"===n.key?1:-1)+f.length)%f.length;a(s,e);const t=null===(o=n.currentTarget.parentElement)||void 0===o?void 0:o.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:y?t=>{a(s,c),n&&n(e);const o=t.currentTarget.querySelector(".semiotic-legend-focus-ring");o&&o.setAttribute("visibility","visible")}:void 0,onBlur:y?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:y?"pointer":"default",opacity:b,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},y&&d.createElement("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*e.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),v,x&&d.createElement(q,null),d.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label))),p+=26+7*e.label.length}),{items:g,offset:p}})(e,o,i,r,l,s,a,t,c,u);n+=g.offset+5,f.push(Object.assign(Object.assign({label:e.label},g),{offset:n})),h+=n+12});let g=Math.max(0,(n-h)/2);const p=[];return f.forEach((n,o)=>{const i=e[o];i.label&&(p.push(d.createElement("text",{key:"legend-text-"+o,transform:`translate(${g},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},i.label)),g+=16),p.push(d.createElement("g",{key:"legend-group-"+o,className:"legend-item",transform:`translate(${g},0)`},n.items)),g+=n.offset+5,e[o+1]&&p.push(d.createElement("line",{key:"legend-top-line legend-symbol-"+o,stroke:"gray",x1:g,y1:-8,x2:g,y2:t+0+8})),g+=12}),d.createElement("g",null,p)})({legendGroups:t||[],title:s,height:c,width:a,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:r,focusedGroupIndex:h,focusedItemIndex:g,onFocusedIndexChange:y,legendInteraction:l}),v=!(!n&&!o);return d.createElement("g",{role:v?"listbox":void 0,"aria-multiselectable":!(!v||"isolate"!==l&&(void 0!==l||null==r))||void 0,"aria-label":"Chart legend"},void 0!==s&&""!==s&&"vertical"===u&&d.createElement("text",{className:"legend-title",y:16,x:a/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)"},s),m)}function U(e){return"string"==typeof e?{type:e}:e}function K({orient:t,config:n,values:o,scale:i,size:r,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,u=e.useMemo(()=>{if(0===o.length)return null;const e=i.domain(),n=r-8;if("boxplot"===a.type){const e=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(!e)return null;const{q1:r,median:l,q3:s,whiskerLow:u,whiskerHigh:h}=e,f=Math.min(.5*n,20),g=(n-f)/2+4;if(c){const e=i(r),n=i(s),o=i(l),c=i(u),p=i(h),y="top"===t?-1:1,m=0;return d.createElement("g",{"data-testid":"marginal-boxplot-"+t},d.createElement("line",{x1:c,y1:m+y*(g+f/2),x2:p,y2:m+y*(g+f/2),stroke:a.fill,strokeWidth:a.strokeWidth}),d.createElement("line",{x1:c,y1:m+y*g,x2:c,y2:m+y*(g+f),stroke:a.fill,strokeWidth:a.strokeWidth}),d.createElement("line",{x1:p,y1:m+y*g,x2:p,y2:m+y*(g+f),stroke:a.fill,strokeWidth:a.strokeWidth}),d.createElement("rect",{x:Math.min(e,n),y:"top"===t?m-g-f:m+g,width:Math.abs(n-e),height:f,fill:a.fill,fillOpacity:a.fillOpacity,stroke:"none"===a.stroke?a.fill:a.stroke,strokeWidth:a.strokeWidth}),d.createElement("line",{x1:o,y1:"top"===t?m-g-f:m+g,x2:o,y2:"top"===t?m-g:m+g+f,stroke:a.fill,strokeWidth:2}))}{const e=i(r),n=i(s),o=i(l),c=i(u),p=i(h),y="left"===t?-1:1,m=0;return d.createElement("g",{"data-testid":"marginal-boxplot-"+t},d.createElement("line",{x1:m+y*(g+f/2),y1:c,x2:m+y*(g+f/2),y2:p,stroke:a.fill,strokeWidth:a.strokeWidth}),d.createElement("line",{x1:m+y*g,y1:c,x2:m+y*(g+f),y2:c,stroke:a.fill,strokeWidth:a.strokeWidth}),d.createElement("line",{x1:m+y*g,y1:p,x2:m+y*(g+f),y2:p,stroke:a.fill,strokeWidth:a.strokeWidth}),d.createElement("rect",{x:"left"===t?m-g-f:m+g,y:Math.min(e,n),width:f,height:Math.abs(n-e),fill:a.fill,fillOpacity:a.fillOpacity,stroke:"none"===a.stroke?a.fill:a.stroke,strokeWidth:a.strokeWidth}),d.createElement("line",{x1:"left"===t?m-g-f:m+g,y1:o,x2:"left"===t?m-g:m+g+f,y2:o,stroke:a.fill,strokeWidth:2}))}}const u=l.bin().domain(e).thresholds(a.bins)(o);if(0===u.length)return null;const h=Math.max(...u.map(e=>e.length));if(0===h)return null;if("histogram"===a.type)return d.createElement("g",{"data-testid":"marginal-histogram-"+t},u.map((e,o)=>{if(null==e.x0||null==e.x1)return null;const r=e.length/h*n;if(c){const n=i(e.x0),l=i(e.x1)-i(e.x0);return d.createElement("rect",{key:o,x:n,y:"top"===t?-4-r:4,width:Math.max(l,.5),height:r,fill:a.fill,fillOpacity:a.fillOpacity,stroke:a.stroke,strokeWidth:a.strokeWidth})}{const n=i(e.x0),l=i(e.x1)-i(e.x0);return d.createElement("rect",{key:o,x:"left"===t?-4-r:4,y:Math.min(n,n+l),width:r,height:Math.abs(l),fill:a.fill,fillOpacity:a.fillOpacity,stroke:a.stroke,strokeWidth:a.strokeWidth})}}));if("violin"===a.type){const e=n/2+4,o=[];for(const r of u){if(null==r.x0||null==r.x1)continue;const l=r.length/h*(n/2),s=i((r.x0+r.x1)/2);o.push(c?`${s},${"top"===t?-(e-l):e-l}`:`${"left"===t?-(e-l):e-l},${s}`)}for(let r=u.length-1;r>=0;r--){const l=u[r];if(null==l.x0||null==l.x1)continue;const s=l.length/h*(n/2),a=i((l.x0+l.x1)/2);o.push(c?`${a},${"top"===t?-(e+s):e+s}`:`${"left"===t?-(e+s):e+s},${a}`)}return d.createElement("g",{"data-testid":"marginal-violin-"+t},d.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 e=[];if(c){const o=0,r=null!=u[0].x0?i(u[0].x0):0;e.push(`M${r},${o}`);for(const o of u){if(null==o.x0||null==o.x1)continue;const r=o.length/h*n,l=i((o.x0+o.x1)/2);e.push(`L${l},${"top"===t?-r-4:r+4}`)}const l=null!=u[u.length-1].x1?i(u[u.length-1].x1):s;e.push(`L${l},${o}`),e.push("Z")}else{const o=0,r=null!=u[0].x0?i(u[0].x0):0;e.push(`M${o},${r}`);for(const o of u){if(null==o.x0||null==o.x1)continue;const r=o.length/h*n,l=i((o.x0+o.x1)/2);e.push(`L${"left"===t?-r-4:r+4},${l}`)}const l=null!=u[u.length-1].x1?i(u[u.length-1].x1):s;e.push(`L${o},${l}`),e.push("Z")}return d.createElement("g",{"data-testid":"marginal-ridgeline-"+t},d.createElement("path",{d:e.join(" "),fill:a.fill,fillOpacity:a.fillOpacity,stroke:"none"===a.stroke?a.fill:a.stroke,strokeWidth:a.strokeWidth}))}return null},[o,i,a,r,s,t,c,4]);return u?d.createElement("g",{className:"marginal-"+t,"data-testid":"marginal-"+t},u):null}function Z(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 J(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 ee(e){const{x:t=0,y:n=0,dx:o,dy:i,nx:r,ny:l,note:s,connector:a,subject:c,type:u,color:h,className:f,disable:g,events:p={},"data-testid":y}=e,m=new Set(Array.isArray(g)?g:[]);let v=o||0,b=i||0;null!=r&&(v=r-t),null!=l&&(b=l-n);const x="string"==typeof u?u:"label";if("bracket"===x&&c&&0===v&&0===b)if(void 0!==c.width){v=c.width/2;const e=c.depth||30;b=e+(0>e?-5:5)}else if(void 0!==c.height){const e=c.depth||30;v=e+(0>e?-5:5),b=c.height/2}return d.createElement("g",Object.assign({className:("annotation "+(f||"")).trim(),transform:`translate(${t},${n})`,"data-testid":y},p),!m.has("connector")&&function(e,t,n,o,i,r){const l=[];let s=0,a=0;if("callout-circle"!==i&&"label"!==i||!(null==r?void 0:r.radius)){if("callout-rect"===i&&r){const n=r.width||0,o=r.height||0;if(n>0||o>0){const i=n/2,r=o/2,l=e-i,c=t-r;if(0!==l||0!==c){const e=Math.abs(l),t=Math.abs(c),u=n/2,h=o/2,d=e*h>t*u?u/e:h/t;s=i+l*d,a=r+c*d}}}else if("bracket"===i&&r){const e=r.width,t=r.height,n=r.depth||30;void 0!==e?(s=e/2,a=n):void 0!==t&&(s=n,a=t/2)}}else{const n=(r.radius||0)+(r.radiusPadding||0);if(n>0&&(0!==e||0!==t)){const o=Math.atan2(t,e);s=Math.cos(o)*n,a=Math.sin(o)*n}}if(Math.sqrt(Math.pow(e-s,2)+Math.pow(t-a,2))>.5&&(l.push(d.createElement("line",{key:"connector-line",x1:s,y1:a,x2:e,y2:t,stroke:o||"currentColor"})),"arrow"===(null==n?void 0:n.end))){const n=10,i=16/180*Math.PI,r=Math.atan2(t-a,e-s);l.push(d.createElement("path",{key:"connector-arrow",d:`M${s},${a}L${s+n*Math.cos(r+i)},${a+n*Math.sin(r+i)}L${s+n*Math.cos(r-i)},${a+n*Math.sin(r-i)}Z`,fill:o||"currentColor",stroke:"none"}))}return d.createElement("g",{className:"annotation-connector"},l)}(v,b,a,h,x,c),!m.has("subject")&&function(e,t,n,o,i){var r;const l=[];switch(e){case"callout-circle":{const e=((null==t?void 0:t.radius)||0)+((null==t?void 0:t.radiusPadding)||0);e>0&&l.push(d.createElement("circle",{key:"subject-circle",r:e,fill:"none",stroke:n||"currentColor"}));break}case"callout-rect":{const e=(null==t?void 0:t.width)||0,o=(null==t?void 0:t.height)||0;(e>0||o>0)&&l.push(d.createElement("rect",{key:"subject-rect",width:e,height:o,fill:"none",stroke:n||"currentColor"}));break}case"callout-custom":(null==t?void 0:t.custom)&&l.push(...Array.isArray(t.custom)?t.custom:[t.custom]);break;case"xy-threshold":{const e=o||0,r=i||0;if(void 0!==(null==t?void 0:t.x)){const o=(t.x||0)-e;l.push(d.createElement("line",{key:"threshold-line",x1:o,y1:(t.y1||0)-r,x2:o,y2:(t.y2||0)-r,stroke:n||"currentColor",strokeDasharray:"5,5"}))}else if(void 0!==(null==t?void 0:t.y)){const o=(t.y||0)-r;l.push(d.createElement("line",{key:"threshold-line",x1:(t.x1||0)-e,y1:o,x2:(t.x2||0)-e,y2:o,stroke:n||"currentColor",strokeDasharray:"5,5"}))}else void 0!==(null==t?void 0:t.x1)||void 0!==(null==t?void 0:t.x2)?l.push(d.createElement("line",{key:"threshold-line",x1:(t.x1||0)-e,y1:0,x2:(t.x2||0)-e,y2:0,stroke:n||"currentColor",strokeDasharray:"5,5"})):void 0===(null==t?void 0:t.y1)&&void 0===(null==t?void 0:t.y2)||l.push(d.createElement("line",{key:"threshold-line",x1:0,y1:(t.y1||0)-r,x2:0,y2:(t.y2||0)-r,stroke:n||"currentColor",strokeDasharray:"5,5"}));break}case"bracket":{const e=null!==(r=null==t?void 0:t.width)&&void 0!==r?r:null==t?void 0:t.height;void 0!==e&&l.push(d.createElement("path",{key:"bracket-path",d:J((null==t?void 0:t.type)||"curly",e,(null==t?void 0:t.depth)||30,void 0===(null==t?void 0:t.width)),fill:"none",stroke:n||"currentColor"}));break}}return d.createElement("g",{className:"annotation-subject"},l)}(x,c,h,t,n),!m.has("note")&&function(e,t,n,o){if(!e)return d.createElement("g",{className:"annotation-note"});const{label:i,title:r,orientation:l,align:s,wrap:a=120,noWrap:c}=e;if(!i&&!r)return d.createElement("g",{className:"annotation-note"});let u=l;u||(u=Math.abs(t)>Math.abs(n)?"leftRight":"topBottom");let h=s;h&&"dynamic"!==h||(h="topBottom"===u?0>t?"right":"left":0>n?"bottom":"top");let f="start";"topBottom"===u?"right"===h?f="end":"middle"===h&&(f="middle"):f=0>t?"end":"start";const g=16,p=r?c?[r]:Z(r,a):[],y=i?c?[i]:Z(i,a):[],m="leftRight"===u?"end"===f?-4:4:0;let v=0;const b=[];p.length>0&&(b.push(d.createElement("text",{key:"annotation-note-title",className:"annotation-note-title",fill:o||void 0,textAnchor:f,fontWeight:"bold"},p.map((e,t)=>d.createElement("tspan",{key:t,x:m,dy:0===t?0:g},e)))),v=p.length*g),y.length>0&&b.push(d.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:o||void 0,textAnchor:f,y:v},y.map((e,t)=>d.createElement("tspan",{key:t,x:m,dy:0===t?0:g},e))));let x=null;if((r||i)&&(0!==t||0!==n))if("topBottom"===u){const e=Math.min(a,120);let t=0,n=e;"end"===f?(t=-e,n=0):"middle"===f&&(t=-e/2,n=e/2),x=d.createElement("line",{className:"note-line",x1:t,x2:n,y1:0,y2:0,stroke:o||"currentColor"})}else{const e=(p.length+y.length)*g+(y.length>0?g:0);let t=0,n=e;"bottom"===h?(t=-e,n=0):"middle"===h&&(t=-e/2,n=e/2),x=d.createElement("line",{className:"note-line",x1:0,x2:0,y1:t,y2:n,stroke:o||"currentColor"})}const k=Math.max(0,p.length+y.length-1)*g;let w=0;return"topBottom"===u?w=0>n?-(k+2):18:"leftRight"===u&&(w="middle"===h?-(k+g+(y.length>0&&p.length>0?2:0))/2+8:"bottom"===h||0>n?-(k+2):18),d.createElement("g",{className:"annotation-note",transform:`translate(${t},${n})`},d.createElement("g",{className:"annotation-note-content",transform:0!==w?`translate(0,${w})`:void 0},b),x)}(s,v,b,h))}function te(e){var t,n;const{noteData:o}=e,{screenCoordinates:i}=o,r="string"==typeof o.type?o.type:"label",l=o.eventListeners||o.events||{};if(o.coordinates&&i){const e=o.nx||i[0][0]+(null!==(t=o.dx)&&void 0!==t?t:0),l=o.ny||i[0][1]+(null!==(n=o.dy)&&void 0!==n?n:0),s=i.map((t,n)=>{const i=Object.assign({},o,{note:0===n?o.note:{label:""},x:t[0],y:t[1],nx:e,ny:l});return d.createElement(ee,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+n},i,{type:r}))});return d.createElement("g",null,s)}const s=o.note||{title:"none",label:o.label};return d.createElement(ee,Object.assign({"data-testid":"semiotic-annotation",key:`${s.label}-${s.title}-${o.i}`,events:l},o,{type:r}))}const ne={linear:a.curveLinear,monotoneX:a.curveMonotoneX,monotoneY:a.curveMonotoneY,step:a.curveStep,stepAfter:a.curveStepAfter,stepBefore:a.curveStepBefore,basis:a.curveBasis,cardinal:a.curveCardinal,catmullRom:a.curveCatmullRom};function oe(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 ie(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 re(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,u=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||!u)return null;const h=a[e.xAccessor||"x"],d=a[e.yAccessor||"y"];return null==h||null==d?null:{x:c(h),y:u(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=oe(e,n),c=ie(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 le(e,t,n,o=50){return!(-o>e||e>(n.width||0)+o||-o>t||t>(n.height||0)+o)}function se(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 ae(t){const{width:n,height:o,totalWidth:i,totalHeight:r,margin:l,scales:s,showAxes:a,axes:c,showGrid:u,xFormat:h,yFormat:f}=t,g=e.useMemo(()=>{var e;if(!s)return[];const t=null==c?void 0:c.find(e=>"bottom"===e.orient),o=(null==t?void 0:t.tickFormat)||h||ce,i=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;return s.x.ticks(Math.min(i,Math.max(2,Math.floor(n/70)))).map(e=>({value:e,pixel:s.x(e),label:o(e)}))},[s,c,h,n]),p=e.useMemo(()=>{var e;if(!s)return[];const t=null==c?void 0:c.find(e=>"left"===e.orient),n=(null==t?void 0:t.tickFormat)||f||ce,i=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;return s.y.ticks(Math.min(i,Math.max(2,Math.floor(o/30)))).map(e=>({value:e,pixel:s.y(e),label:n(e)}))},[s,c,f,o]),y=u&&s,m=a&&s;if(!y&&!m)return null;const v=null==c?void 0:c.find(e=>"bottom"===e.orient),b=null==c?void 0:c.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,M="var(--semiotic-border, #ccc)";return d.createElement("svg",{width:i,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},d.createElement("g",{transform:`translate(${l.left},${l.top})`},y&&d.createElement("g",{className:"stream-grid"},g.map((e,t)=>d.createElement("line",{key:"xgrid-"+t,x1:e.pixel,y1:0,x2:e.pixel,y2:o,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1})),p.map((e,t)=>d.createElement("line",{key:"ygrid-"+t,x1:0,y1:e.pixel,x2:n,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),x&&!w&&d.createElement("line",{x1:0,y1:o,x2:n,y2:o,stroke:M,strokeWidth:1}),w&&d.createElement("path",{d:se("bottom",n,o),fill:"none",stroke:M,strokeWidth:1}),k&&!A&&d.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:M,strokeWidth:1}),A&&d.createElement("path",{d:se("left",n,o),fill:"none",stroke:M,strokeWidth:1})))}function ce(e){return Math.round(100*e)/100+""}function ue(e,t){return e instanceof Date&&(!(t&&t instanceof Date)||e.getFullYear()!==t.getFullYear()||e.getMonth()!==t.getMonth()||e.getDate()!==t.getDate())}function he(t){var n,o;const{width:i,height:r,totalWidth:l,totalHeight:c,margin:u,scales:h,showAxes:g,axes:p,xLabel:y,yLabel:m,xFormat:v,yFormat:b,showGrid:x,title:k,legend:w,legendHoverBehavior:A,legendClickBehavior:M,legendHighlightedCategory:S,legendIsolatedCategories:E,legendPosition:O="right",foregroundGraphics:C,marginalGraphics:j,xValues:P,yValues:_,annotations:L,svgAnnotationRules:B,xAccessor:N,yAccessor:H,annotationData:W,pointNodes:z,curve:T,underlayRendered:F,children:I}=t,$=e.useMemo(()=>{var e;if(!g||!h)return[];const t=null==p?void 0:p.find(e=>"bottom"===e.orient),n=(null==t?void 0:t.tickFormat)||v||ce,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(i/70)))).map(e=>({value:e,pixel:h.x(e),label:n(e)}))},[g,h,p,v,i]),D=e.useMemo(()=>{var e;if(!g||!h)return[];const t=null==p?void 0:p.find(e=>"left"===e.orient),n=(null==t?void 0:t.tickFormat)||b||ce,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(r/30)))).map(e=>({value:e,pixel:h.y(e),label:n(e)}))},[g,h,p,b,r]),R=e.useRef(new Map),G=e.useRef(null!==(n=null==L?void 0:L.length)&&void 0!==n?n:0),Y=null!==(o=null==L?void 0:L.length)&&void 0!==o?o:0;G.current!==Y&&(G.current=Y,R.current=new Map);const q=e.useMemo(()=>{if(!L||0===L.length)return null;const e=function(e,t,n){var o,i,r,l,c,u,h,g,p,y,m,v,b,x,k,w,A,M,S,E,O,C,j,P,_,L,B,N,H,W,z,T,F,I,$,D,R,G,Y,q,X,V,Q,U;switch(e.type){case"label":{const o=re(e,t,n);if(!o)return null;const{x:i,y:r}=o;return le(i,r,n)?d.createElement(te,{key:"ann-"+t,noteData:{x:i,y:r,dx:e.dx||30,dy:e.dy||-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"label",connector:e.connector||{end:"arrow"},color:e.color}}):null}case"callout":{const o=re(e,t,n);if(!o)return null;const{x:i,y:r}=o;return le(i,r,n)?d.createElement(te,{key:"ann-"+t,noteData:{x:i,y:r,dx:e.dx||30,dy:e.dy||-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"callout-circle",subject:{radius:e.radius||12},connector:e.connector||{end:"arrow"},color:e.color}}):null}case"x-threshold":{const o=oe(e,n);if(null==o)return null;const i=e.color||"#f97316";return d.createElement("g",{key:"ann-"+t},d.createElement("line",{x1:o,y1:0,x2:o,y2:n.height||0,stroke:i,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&d.createElement("text",{x:o+4,y:12,fill:i,fontSize:12,fontWeight:"bold"},e.label))}case"y-threshold":{const o=ie(e,n);if(null==o)return null;const i=e.color||"#f97316";return d.createElement("g",{key:"ann-"+t},d.createElement("line",{x1:0,y1:o,x2:n.width||0,y2:o,stroke:i,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&d.createElement("text",{x:(n.width||0)-4,y:o-4,textAnchor:"end",fill:i,fontSize:12,fontWeight:"bold"},e.label))}case"enclose":{const o=(e.coordinates||[]).map(e=>({x:oe(Object.assign(Object.assign({},e),{type:"point"}),n),y:ie(Object.assign(Object.assign({},e),{type:"point"}),n),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>o.length)return null;const i=s.packEnclose(o),r=e.padding||10;return d.createElement("g",{key:"ann-"+t},d.createElement("circle",{cx:i.x,cy:i.y,r:i.r+r,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&d.createElement("text",{x:i.x,y:i.y-i.r-r-4,textAnchor:"middle",fill:e.color||"#666",fontSize:12},e.label))}case"rect-enclose":{const o=(e.coordinates||[]).map(e=>({x:oe(Object.assign(Object.assign({},e),{type:"point"}),n),y:ie(Object.assign(Object.assign({},e),{type:"point"}),n)})).filter(e=>null!=e.x&&null!=e.y);if(2>o.length)return null;const i=e.padding||10,r=o.map(e=>e.x),l=o.map(e=>e.y),s=Math.min(...r)-i,a=Math.max(...r)+i,c=Math.min(...l)-i,u=Math.max(...l)+i;return d.createElement("g",{key:"ann-"+t},d.createElement("rect",{x:s,y:c,width:a-s,height:u-c,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&d.createElement("text",{x:(s+a)/2,y:c-4,textAnchor:"middle",fill:e.color||"#666",fontSize:12},e.label))}case"highlight":{const o=n.data||[],i="function"==typeof e.filter?o.filter(e.filter):e.field&&null!=e.value?o.filter(t=>t[e.field]===e.value):[],r=e.style||{stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return d.createElement("g",{key:"ann-"+t},i.map((t,o)=>{const i=oe(t,n),l=ie(t,n);return null==i||null==l?null:d.createElement("circle",Object.assign({key:"hl-"+o,cx:i,cy:l,r:e.r||6},r))}))}case"bracket":{const o=oe(e,n),i=ie(e,n);return d.createElement(te,{key:"ann-"+t,noteData:{x:null!=o?o:0,y:null!=i?i:0,dx:e.dx||0,dy:e.dy||0,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"bracket",subject:{type:e.bracketType||"curly",width:e.width,height:e.height,depth:e.depth||30},color:e.color}})}case"trend":{const s=n.data||[];if(2>s.length)return null;const a=n.xAccessor||"x",g=n.yAccessor||"y",p=s.map(e=>[e[a],e[g]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>p.length)return null;const y=null!==(i=null===(o=n.scales)||void 0===o?void 0:o.x)&&void 0!==i?i:null===(r=n.scales)||void 0===r?void 0:r.time,m=null!==(c=null===(l=n.scales)||void 0===l?void 0:l.y)&&void 0!==c?c:null===(u=n.scales)||void 0===u?void 0:u.value;if(!y||!m)return null;const v=e.method||"linear";let b;b="loess"===v?function(e,t=.3){const n=e.length;if(2>n)return e.slice();const o=e.slice().sort((e,t)=>e[0]-t[0]),i=o.map(e=>e[0]),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 u=0,h=0,d=0,f=0,g=0;for(let e=0;n>e;e++){const t=c[e];0!==t&&(u+=t,h+=t*i[e],d+=t*r[e],f+=t*i[e]*i[e],g+=t*i[e]*r[e])}if(0===u){s.push([t,r[e]]);continue}const p=u*f-h*h;if(1e-12>Math.abs(p))s.push([t,d/u]);else{const e=(u*g-h*d)/p;s.push([t,(d-e*h)/u+e*t])}}return s}(p,null!==(h=e.bandwidth)&&void 0!==h?h:.3):("polynomial"===v?f.default.polynomial(p,{order:e.order||2}):f.default.linear(p)).points;const x=b.map(([e,t])=>`${y(e)},${m(t)}`).join(" "),k=e.color||"#6366f1";return d.createElement("g",{key:"ann-"+t},d.createElement("polyline",{points:x,fill:"none",stroke:k,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&d.createElement("text",{x:y(b[b.length-1][0])+4,y:m(b[b.length-1][1])-4,fill:k,fontSize:11},e.label))}case"band":{const o=null!==(p=null===(g=n.scales)||void 0===g?void 0:g.y)&&void 0!==p?p:null===(y=n.scales)||void 0===y?void 0:y.value,i=null!==(m=null==o?void 0:o(e.y0))&&void 0!==m?m:0,r=null!==(v=null==o?void 0:o(e.y1))&&void 0!==v?v:n.height||0;return d.createElement("g",{key:"ann-"+t},d.createElement("rect",{x:0,y:Math.min(i,r),width:n.width||0,height:Math.abs(r-i),fill:e.fill||"#6366f1",fillOpacity:e.fillOpacity||.1}),e.label&&d.createElement("text",{x:(n.width||0)-4,y:Math.min(i,r)-4,textAnchor:"end",fill:e.color||"#6366f1",fontSize:11},e.label))}case"envelope":{const o=n.data||[];if(2>o.length)return null;const i=n.xAccessor||"x",r=null!==(x=null===(b=n.scales)||void 0===b?void 0:b.x)&&void 0!==x?x:null===(k=n.scales)||void 0===k?void 0:k.time,l=null!==(A=null===(w=n.scales)||void 0===w?void 0:w.y)&&void 0!==A?A:null===(M=n.scales)||void 0===M?void 0:M.value;if(!r||!l)return null;const s=e.upperAccessor||"upperBounds",c=e.lowerAccessor||"lowerBounds",u=e.filter,h=o.filter(e=>null!=e[s]&&null!=e[c]&&!(u&&!u(e))).sort((e,t)=>e[i]-t[i]);if(2>h.length)return null;const f=ne[n.curve||"linear"]||a.curveLinear,g=a.area().x(e=>r(e[i])).y0(e=>l(e[c])).y1(e=>l(e[s])).curve(f)(h);if(!g)return null;const p=e.fill||"#6366f1";return d.createElement("g",{key:"ann-"+t},d.createElement("path",{d:g,fill:p,fillOpacity:null!==(S=e.fillOpacity)&&void 0!==S?S:.15,stroke:"none"}),e.label&&h.length>0&&d.createElement("text",{x:r(h[h.length-1][i])+4,y:l(h[h.length-1][s])-4,fill:p,fontSize:11},e.label))}case"anomaly-band":{const o=n.data||[];if(2>o.length)return null;const i=n.yAccessor||"y",r=null!==(O=null===(E=n.scales)||void 0===E?void 0:E.x)&&void 0!==O?O:null===(C=n.scales)||void 0===C?void 0:C.time,l=null!==(P=null===(j=n.scales)||void 0===j?void 0:j.y)&&void 0!==P?P:null===(_=n.scales)||void 0===_?void 0:_.value;if(!r||!l)return null;const s=o.map(e=>e[i]).filter(e=>null!=e&&isFinite(e));if(2>s.length)return null;const a=s.reduce((e,t)=>e+t,0)/s.length,c=s.reduce((e,t)=>e+Math.pow(t-a,2),0)/s.length,u=Math.sqrt(c),h=null!==(L=e.threshold)&&void 0!==L?L:2,f=a-h*u,g=!1!==e.showBand,p=e.fill||"#6366f1",y=null!==(B=e.fillOpacity)&&void 0!==B?B:.1,m=e.anomalyColor||"#ef4444",v=null!==(N=e.anomalyRadius)&&void 0!==N?N:6,b=l(a+h*u),x=l(f),k=o.filter(e=>{const t=e[i];return null!=t&&Math.abs(t-a)>h*u});return d.createElement("g",{key:"ann-"+t},g&&d.createElement("rect",{x:0,y:Math.min(b,x),width:n.width||0,height:Math.abs(x-b),fill:p,fillOpacity:y}),k.map((e,t)=>{const o=oe(e,n),i=ie(e,n);return null==o||null==i?null:d.createElement("circle",{key:"anomaly-"+t,cx:o,cy:i,r:v,fill:m,fillOpacity:.7,stroke:m,strokeWidth:1.5})}),e.label&&d.createElement("text",{x:(n.width||0)-4,y:Math.min(b,x)-4,textAnchor:"end",fill:p,fontSize:11},e.label))}case"forecast":{const o=n.data||[];if(3>o.length)return null;const i=n.xAccessor||"x",r=n.yAccessor||"y",l=null!==(W=null===(H=n.scales)||void 0===H?void 0:H.x)&&void 0!==W?W:null===(z=n.scales)||void 0===z?void 0:z.time,s=null!==(F=null===(T=n.scales)||void 0===T?void 0:T.y)&&void 0!==F?F:null===(I=n.scales)||void 0===I?void 0:I.value;if(!l||!s)return null;const a=o.map(e=>[e[i],e[r]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]);if(3>a.length)return null;let c;if("polynomial"===(e.method||"linear")){const t=f.default.polynomial(a,{order:e.order||2}).equation;c=e=>t.reduce((t,n,o)=>t+n*Math.pow(e,o),0)}else{const e=a.length;let t=0,n=0,o=0,i=0;for(const[e,r]of a)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;c=e=>s+l*e}const u=a.length,h=a.map(([e,t])=>t-c(e)).reduce((e,t)=>e+t*t,0),g=Math.sqrt(h/Math.max(u-2,1)),p=a.reduce((e,t)=>e+t[0],0)/u,y=a.reduce((e,t)=>e+Math.pow(t[0]-p,2),0),m=null!==($=e.confidence)&&void 0!==$?$:.95,v=.99>m?.95>m?.9>m?1:1.645:1.96:2.576,b=null!==(D=e.steps)&&void 0!==D?D:5,x=a[u-1][0],k=(x-a[0][0])/Math.max(u-1,1),w=[];for(let e=1;b>=e;e++)w.push(x+e*k);const A=[];for(const e of w){const t=c(e),n=g*Math.sqrt(1+1/u+(y>0?Math.pow(e-p,2)/y:0))*v;A.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const M=`M${A.map(e=>`${l(e.x)},${s(e.yUpper)}`).join(" L")} L${A.slice().reverse().map(e=>`${l(e.x)},${s(e.yLower)}`).join(" L")} Z`,S=A.map(e=>`${l(e.x)},${s(e.yCenter)}`).join(" "),E=`${l(x)},${s(c(x))}`,O=e.strokeColor||"#6366f1";return d.createElement("g",{key:"ann-"+t},d.createElement("path",{d:M,fill:e.fill||"#6366f1",fillOpacity:null!==(R=e.fillOpacity)&&void 0!==R?R:.15,stroke:"none"}),d.createElement("polyline",{points:`${E} ${S}`,fill:"none",stroke:O,strokeWidth:null!==(G=e.strokeWidth)&&void 0!==G?G:2,strokeDasharray:null!==(Y=e.strokeDasharray)&&void 0!==Y?Y:"6,3"}),e.label&&A.length>0&&d.createElement("text",{x:l(A[A.length-1].x)+4,y:s(A[A.length-1].yCenter)-4,fill:O,fontSize:11},e.label))}case"widget":{let o=null,i=null;if(null!=e.px&&null!=e.py)o=e.px,i=e.py;else{const r=re(e,t,n);if(!r)return null;o=r.x,i=r.y}if(null==o||null==i)return null;if(!le(o,i,n))return null;const r=null!==(q=e.dx)&&void 0!==q?q:0,l=null!==(X=e.dy)&&void 0!==X?X:0,s=null!==(V=e.width)&&void 0!==V?V:32,a=null!==(Q=e.height)&&void 0!==Q?Q:32,c=null!==(U=e.content)&&void 0!==U?U:d.createElement("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info"},"ℹ️");return d.createElement("foreignObject",{key:"ann-"+t,x:o+r-s/2,y:i+l-a/2,width:s,height:a,style:{overflow:"visible",pointerEvents:"auto"}},d.createElement("div",{style:{width:s,height:a,display:"flex",alignItems:"center",justifyContent:"center"}},c))}case"text":{const o=re(e,t,n);if(!o)return null;const{x:i,y:r}=o;return d.createElement("text",{key:"ann-text-"+t,x:i+(e.dx||0),y:r+(e.dy||0),fill:e.color||"var(--semiotic-text, #333)",fontSize:e.fontSize||11,dominantBaseline:"middle",style:{fontFamily:"inherit"}},e.label)}default:return null}},t={scales:h?{x:h.x,y:h.y,time:h.x,value:h.y}:null,timeAxis:"x",xAccessor:N,yAccessor:H,width:i,height:r,data:W,frameType:"xy",pointNodes:z,curve:T,stickyPositionCache:R.current};return L.map((n,o)=>{if(B){const i=B(n,o,t);return null!=i?i:e(n,o,t)}return e(n,o,t)}).filter(Boolean)},[L,B,i,r,N,H,W,h,z,T]);return g||k||w||C||j||q&&q.length>0||x||I?d.createElement("svg",{role:"img",width:l,height:c,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},d.createElement("title",null,"string"==typeof k?k:"XY Chart"),d.createElement("desc",null,"string"==typeof k?k+" — XY data visualization":"XY data visualization"),d.createElement("g",{transform:`translate(${u.left},${u.top})`},x&&h&&!F&&d.createElement("g",{className:"stream-grid"},$.map((e,t)=>d.createElement("line",{key:"xgrid-"+t,x1:e.pixel,y1:0,x2:e.pixel,y2:r,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1})),D.map((e,t)=>d.createElement("line",{key:"ygrid-"+t,x1:0,y1:e.pixel,x2:i,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),g&&h&&(()=>{const e=null==p?void 0:p.find(e=>"left"===e.orient),t=null==p?void 0:p.find(e=>"bottom"===e.orient),n=!e||!1!==e.baseline,o=(null==e?void 0:e.jaggedBase)||!1,l=(null==t?void 0:t.jaggedBase)||!1,s=null==t?void 0:t.landmarkTicks,a=null==e?void 0:e.landmarkTicks,c="var(--semiotic-border, #ccc)",h="var(--semiotic-text-secondary, #666)",f="var(--semiotic-text, #333)";return d.createElement("g",{className:"stream-axes"},!F&&(!t||!1!==t.baseline)&&!l&&d.createElement("line",{x1:0,y1:r,x2:i,y2:r,stroke:c,strokeWidth:1}),!F&&l&&d.createElement("path",{d:se("bottom",i,r),fill:"none",stroke:c,strokeWidth:1}),$.map((e,t)=>{const n=!!s&&("function"==typeof s?s(e.value,t):ue(e.value,t>0?$[t-1].value:void 0));return d.createElement("g",{key:"xtick-"+t,transform:`translate(${e.pixel},${r})`},d.createElement("line",{y2:5,stroke:c,strokeWidth:1}),d.createElement("text",{y:18,textAnchor:"middle",fontSize:n?11:10,fontWeight:n?600:400,fill:h,style:{userSelect:"none"}},e.label))}),y&&d.createElement("text",{x:i/2,y:r+40,textAnchor:"middle",fontSize:12,fill:f,style:{userSelect:"none"}},y),!F&&n&&!o&&d.createElement("line",{x1:0,y1:0,x2:0,y2:r,stroke:c,strokeWidth:1}),!F&&o&&d.createElement("path",{d:se("left",i,r),fill:"none",stroke:c,strokeWidth:1}),D.map((e,t)=>{const n=!!a&&("function"==typeof a?a(e.value,t):ue(e.value,t>0?D[t-1].value:void 0));return d.createElement("g",{key:"ytick-"+t,transform:`translate(0,${e.pixel})`},d.createElement("line",{x2:-5,stroke:c,strokeWidth:1}),d.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:n?11:10,fontWeight:n?600:400,fill:h,style:{userSelect:"none"}},e.label))}),m&&d.createElement("text",{x:15-u.left,y:r/2,textAnchor:"middle",fontSize:12,fill:f,transform:`rotate(-90, ${15-u.left}, ${r/2})`,style:{userSelect:"none"}},m))})(),q,j&&h&&P&&_&&d.createElement(d.Fragment,null,j.top&&d.createElement("g",{transform:"translate(0, 0)"},d.createElement(K,{orient:"top",config:U(j.top),values:P,scale:h.x,size:u.top,length:i})),j.bottom&&d.createElement("g",{transform:`translate(0, ${r})`},d.createElement(K,{orient:"bottom",config:U(j.bottom),values:P,scale:h.x,size:u.bottom,length:i})),j.left&&d.createElement("g",{transform:"translate(0, 0)"},d.createElement(K,{orient:"left",config:U(j.left),values:_,scale:h.y,size:u.left,length:r})),j.right&&d.createElement("g",{transform:`translate(${i}, 0)`},d.createElement(K,{orient:"right",config:U(j.right),values:_,scale:h.y,size:u.right,length:r}))),C,I),k&&d.createElement("text",{x:l/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof k?k:null),function(e){const{legend:t,totalWidth:n,totalHeight:o,margin:i,legendPosition:r="right",title:l,legendHoverBehavior:s,legendClickBehavior:a,legendHighlightedCategory:c,legendIsolatedCategories:u,legendInteraction:h}=e;if(!t)return null;const f="top"===r||"bottom"===r;let g,p;return"left"===r?(g=4,p=i.top):"top"===r?(g=0,p=l?32:8):"bottom"===r?(g=0,p=o-i.bottom+50):(g=n-i.right+10,p=i.top),d.createElement("g",{transform:`translate(${g}, ${p})`},"object"==typeof(y=t)&&null!==y&&"gradient"in y?d.createElement(V,{config:t.gradient,orientation:f?"horizontal":"vertical",width:f?n:100}):function(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}(t)?d.createElement(Q,{legendGroups:t.legendGroups,title:"",width:f?n:100,orientation:f?"horizontal":"vertical",customHoverBehavior:s,customClickBehavior:a,highlightedCategory:c,isolatedCategories:u,legendInteraction:h}):t);var y}({legend:w,totalWidth:l,totalHeight:c,margin:u,legendPosition:O,title:k,legendHoverBehavior:A,legendClickBehavior:M,legendHighlightedCategory:S,legendIsolatedCategories:E})):null}const de="undefined"==typeof window||"undefined"==typeof document,fe={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function ge(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 pe({scene:e,chartType:t}){var n,o,i,r;const l=[];for(const t of e){if(l.length>=50)break;"point"===t.type?l.push({label:"Point",values:{x:Math.round(100*t.x)/100+"",y:Math.round(100*t.y)/100+""}}):"rect"===t.type?l.push({label:"Bar",values:{category:(null===(n=t.datum)||void 0===n?void 0:n.category)||"",value:Math.round(100*(null!==(i=null===(o=t.datum)||void 0===o?void 0:o.value)&&void 0!==i?i:0))/100+""}}):"heatcell"===t.type&&l.push({label:"Cell",values:{x:Math.round(100*t.x)/100+"",y:Math.round(100*t.y)/100+"",value:Math.round(100*(null!==(r=t.value)&&void 0!==r?r:0))/100+""}})}if(0===l.length)return null;const s=new Set;for(const e of l)for(const t of Object.keys(e.values))s.add(t);const a=Array.from(s);return d.createElement("table",{style:fe,role:"table","aria-label":"Data table for "+t},d.createElement("thead",null,d.createElement("tr",null,a.map(e=>d.createElement("th",{key:e},e)))),d.createElement("tbody",null,l.map((e,t)=>d.createElement("tr",{key:t},a.map(t=>{var n;return d.createElement("td",{key:t},null!==(n=e.values[t])&&void 0!==n?n:"")}))),e.length>50&&d.createElement("tr",null,d.createElement("td",{colSpan:a.length},"...and ",e.length-50," more items"))))}function ye({hoverPoint:e}){let t="";if(e){const n=e.data||e;t="object"==typeof n?"Focused on data point: "+Object.entries(n).filter(([,e])=>"object"!=typeof e&&"function"!=typeof e).map(([e,t])=>`${e}: ${t}`).join(", "):"Focused on data point: "+n}return d.createElement("div",{"aria-live":"polite","aria-atomic":"true",style:fe},t)}function me(t){const n=e.createContext(null),o=ve(t);return[function({children:o}){const i=e.useMemo(()=>ve(t),[]);return d.createElement(n.Provider,{value:i,children:o})},t=>{var i;const r=null!==(i=e.useContext(n))&&void 0!==i?i:o,l=e.useRef(t);l.current=t;const s=e.useCallback(()=>l.current(r.getState()),[r]),a=e.useCallback(()=>l.current(r.getState()),[r]);return e.useSyncExternalStore(r.subscribe,s,a)}]}function ve(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 be={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}},xe={mode:"dark",colors:{primary:"#4fc3f7",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",background:"#1a1a2e",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},[ke,we]=me(e=>({theme:be,setTheme(t){e(e=>"light"===t?{theme:be}:"dark"===t?{theme:xe}:{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 Ae(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 Me(e){switch(e){case"monotoneX":return a.curveMonotoneX;case"monotoneY":return a.curveMonotoneY;case"cardinal":return a.curveCardinal;case"catmullRom":return a.curveCatmullRom;case"step":return a.curveStep;case"stepBefore":return a.curveStepBefore;case"stepAfter":return a.curveStepAfter;case"basis":return a.curveBasis;case"natural":return a.curveNatural;default:return null}}function Se(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 Ee(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 Oe(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function Ce(e,t,n=.3){Oe(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 je(e,t,n=.6){var o,i,r,l,s;if(!Oe(t))return;const a=null!==(o=t._pulseGlowRadius)&&void 0!==o?o:4,c=t.r+a*t._pulseIntensity,u=null!==(r=null!==(i=t.cx)&&void 0!==i?i:t.x)&&void 0!==r?r:0,h=null!==(s=null!==(l=t.cy)&&void 0!==l?l:t.y)&&void 0!==s?s: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 Pe(e,t,n,o=.35){Oe(t)&&(e.globalAlpha=t._pulseIntensity*o,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fill())}function _e(e){switch(e){case"monotoneX":return a.curveMonotoneX;case"monotoneY":return a.curveMonotoneY;case"cardinal":return a.curveCardinal;case"catmullRom":return a.curveCatmullRom;case"step":return a.curveStep;case"stepBefore":return a.curveStepBefore;case"stepAfter":return a.curveStepAfter;case"basis":return a.curveBasis;case"natural":return a.curveNatural;default:return null}}function Le(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 Be(e,t){const n=_e(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=a.area().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 Ne=(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(Be(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=Le(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&&(Be(e,t),Pe(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=_e(t.curve);if(e.beginPath(),n)a.line().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}},He=(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()),je(e,t),e.globalAlpha=1}}finally{e.restore()}},We=(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?ze(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))),Ce(e,t),e.globalAlpha=1};function ze(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 Te(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 Fe(e){return Number.isInteger(e)?e+"":100>Math.abs(e)?1>Math.abs(e)?e.toPrecision(3):e.toFixed(1):e.toFixed(0)}const Ie={line:[Ne,(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 c=s.style.stroke||"#007bff",u=s.style.strokeWidth||2,h=s.colorThresholds,d=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=u,e.lineCap=s.style.strokeLinecap||"butt",s.style._edgeFade){const y=null!==(i=s.style.opacity)&&void 0!==i?i:1;Ee(e,s.path,c,u,y,s.style.strokeLinecap||"butt"),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt";continue}const f=Me(s.curve),g=h&&h.length>0&&d&&d.length===s.path.length,p=s._decayOpacities;if(p&&p.length===s.path.length&&!g){e.strokeStyle=c;const m=null!==(r=s.style.opacity)&&void 0!==r?r:1;for(let v=0;s.path.length-1>v;v++)e.globalAlpha=.5*(p[v]+p[v+1])*m,e.beginPath(),e.moveTo(s.path[v][0],s.path[v][1]),e.lineTo(s.path[v+1][0],s.path[v+1][1]),e.stroke()}else if(g){let b=null,x=null,k=null,w=null,A=!1;function M(t,n,o){e.beginPath(),e.strokeStyle=t,e.moveTo(n,o),A=!0}function S(){A&&(e.stroke(),A=!1)}for(let E=0;s.path.length>E;E++){const[O,C]=s.path[E],j=d[E],P=Se(j,h,c);if(null!==b&&null!==w&&null!==k){if(P===w)e.lineTo(O,C);else{const _=[];for(const L of h){const B=L.value;(k>B||B>j)&&(B>k||j>B)||k===B||j===B||_.push({t:(B-k)/(j-k)})}_.sort((e,t)=>e.t-t.t);for(const N of _){const H=b+(O-b)*N.t,W=x+(C-x)*N.t,z=Se(k+(j-k)*Math.min(N.t+1e-4,1),h,c);e.lineTo(H,W),S(),M(z,H,W)}e.lineTo(O,C)}b=O,x=C,k=j,w=P}else M(P,O,C),b=O,x=C,k=j,w=P}S()}else{if(e.beginPath(),e.strokeStyle=c,f)a.line().x(e=>e[0]).y(e=>e[1]).curve(f).context(e)(s.path);else{const[T,F]=s.path[0];e.moveTo(T,F);for(let I=1;s.path.length>I;I++)e.lineTo(s.path[I][0],s.path[I][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,f&&!g)a.line().x(e=>e[0]).y(e=>e[1]).curve(f).context(e)(s.path);else{const[D,R]=s.path[0];e.moveTo(D,R);for(let G=1;s.path.length>G;G++)e.lineTo(s.path[G][0],s.path[G][1])}const $=s.path[0][0];e.lineTo(s.path[s.path.length-1][0],o.height),e.lineTo($,o.height),e.closePath(),e.fill()}e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt"}}],area:[Ne],stackedarea:[Ne],scatter:[He],bubble:[He],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),Ce(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):Fe(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=Te(t.fill),e.font=o+"px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(n,i,r)}}}finally{e.restore()}}],bar:[We],swarm:[He],waterfall:[(e,t,n,o)=>{var i,r,l;We(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,u=i.x;e.beginPath(),e.moveTo(c,a),e.lineTo(u,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()}}]},$e={top:20,right:20,bottom:30,left:40},De={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"},Re={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 Ge({hover:e}){const t=e=>Number.isInteger(e)?e+"":e.toFixed(2);return d.createElement("div",{className:"semiotic-tooltip",style:Re},d.createElement("div",{style:{fontWeight:600,marginBottom:2}},t(e.value)),d.createElement("div",{style:{opacity:.7,fontSize:11}},t(e.time)))}function Ye({width:o,height:i,totalWidth:r,totalHeight:l,margin:s,dimension:a,scales:c,onBrush:u}){const h=e.useRef(null),f=e.useRef(null),g=e.useRef(u);g.current=u;const p=e.useRef(c);return p.current=c,e.useEffect(()=>{if(!h.current)return;const e=n.select(h.current).select(".brush-g"),r="x"===a?t.brushX():"y"===a?t.brushY():t.brush();return r.extent([[0,0],[o,i]]),r.on("brush end",e=>{const t=p.current;if(!t)return;if(!e.selection)return void g.current(null);let n,r;if("x"===a){const[o,l]=e.selection;n=[t.x.invert(o),t.x.invert(l)],r=[t.y.invert(i),t.y.invert(0)]}else if("y"===a){const[i,l]=e.selection;n=[t.x.invert(0),t.x.invert(o)],r=[t.y.invert(l),t.y.invert(i)]}else{const[[o,i],[l,s]]=e.selection;n=[t.x.invert(o),t.x.invert(l)],r=[t.y.invert(s),t.y.invert(i)]}g.current({x:n,y:r})}),e.call(r),f.current=r,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{r.on("brush end",null),f.current=null}},[o,i,a]),d.createElement("svg",{ref:h,width:r,height:l,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},d.createElement("g",{className:"brush-g",transform:`translate(${s.left},${s.top})`}))}const qe=e.forwardRef(function(t,n){var o,i,r,l,s,a,c,u,h;const{chartType:f,runtimeMode:p,data:y,chunkThreshold:m,chunkSize:v,xAccessor:b,yAccessor:x,colorAccessor:k,sizeAccessor:w,groupAccessor:A,lineDataAccessor:M,curve:S,normalize:E,binSize:O,valueAccessor:C,arrowOfTime:j="right",windowMode:P="sliding",windowSize:_=200,timeAccessor:L,xExtent:B,yExtent:H,extentPadding:T=.1,sizeRange:R,size:G=[500,300],responsiveWidth:Y,responsiveHeight:q,margin:X,className:V,background:Q,lineStyle:U,pointStyle:K,areaStyle:Z,waterfallStyle:J,swarmStyle:ee,barColors:te,colorScheme:ne,boundsAccessor:oe,boundsStyle:ie,y0Accessor:re,gradientFill:le,openAccessor:se,highAccessor:ce,lowAccessor:ue,closeAccessor:fe,candlestickStyle:me,showAxes:ve=!0,axes:be,xLabel:xe,yLabel:ke,xFormat:Me,yFormat:Se,tickFormatTime:Ee,tickFormatValue:Oe,hoverAnnotation:Ce,tooltipContent:je,customHoverBehavior:Pe,enableHover:_e,annotations:Le,svgAnnotationRules:Be,showGrid:Ne,legend:He,legendHoverBehavior:We,legendClickBehavior:ze,legendHighlightedCategory:Te,legendIsolatedCategories:Fe,legendPosition:Re,backgroundGraphics:qe,foregroundGraphics:Xe,canvasPreRenderers:Ve,title:Qe,categoryAccessor:Ue,brush:Ke,onBrush:Ze,decay:Je,pulse:et,transition:tt,staleness:nt,heatmapAggregation:ot,heatmapXBins:it,heatmapYBins:rt,showValues:lt,heatmapValueFormat:st,marginalGraphics:at,pointIdAccessor:ct,xScaleType:ut,yScaleType:ht,accessibleTable:dt}=t,[ft,gt]=function(t,n,o){const i=e.useRef(null),[r,l]=e.useState(null);return e.useEffect(()=>{if(!n&&!o)return;const e=i.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()},[n,o]),[i,[n&&r?r.w:t[0],o&&r?r.h:t[1]]]}(G,Y,q),pt=Object.assign(Object.assign({},$e),X);if(at){const e=60;at.top&&e>pt.top&&(pt.top=e),at.bottom&&e>pt.bottom&&(pt.bottom=e),at.left&&e>pt.left&&(pt.left=e),at.right&&e>pt.right&&(pt.right=e)}const yt=gt[0]-pt.left-pt.right,mt=gt[1]-pt.top-pt.bottom,vt="function"==typeof Xe?Xe({size:gt,margin:pt}):Xe,bt="function"==typeof qe?qe({size:gt,margin:pt}):qe,xt=null!=Ce?Ce:_e,kt=e.useRef(null),wt=e.useRef(null),At=e.useRef(0),Mt=e.useRef(!1),St=we(e=>e.theme),[Et,Ot]=e.useState(0),[Ct,jt]=e.useState(null),Pt=e.useRef(null),_t=e.useRef(null),[Lt,Bt]=e.useState(null),[Nt,Ht]=e.useState(!1),[Wt,zt]=e.useState([]),[Tt,Ft]=e.useState([]),It=e.useRef(()=>{}),$t="streaming"===p||["bar","swarm","waterfall"].includes(f),Dt=e.useMemo(()=>({chartType:f,runtimeMode:$t?"streaming":"bounded",windowSize:_,windowMode:P,arrowOfTime:$t?j:"right",extentPadding:T,xAccessor:$t?void 0:b,yAccessor:$t?void 0:x,timeAccessor:$t?L:void 0,valueAccessor:C,colorAccessor:k,sizeAccessor:w,groupAccessor:A,categoryAccessor:Ue,lineDataAccessor:M,xScaleType:ut,yScaleType:ht,xExtent:B,yExtent:H,sizeRange:R,binSize:O,normalize:E,boundsAccessor:oe,boundsStyle:ie,y0Accessor:re,gradientFill:"boolean"==typeof le?le?{topOpacity:.8,bottomOpacity:.05}:void 0:le,openAccessor:se,highAccessor:ce,lowAccessor:ue,closeAccessor:fe,candlestickStyle:me,lineStyle:U,pointStyle:K,areaStyle:Z,swarmStyle:ee,waterfallStyle:J,colorScheme:ne,barColors:te,annotations:Le,decay:Je,pulse:et,transition:tt,staleness:nt,heatmapAggregation:ot,heatmapXBins:it,heatmapYBins:rt,showValues:lt,heatmapValueFormat:st,pointIdAccessor:ct,curve:S}),[f,_,P,j,T,b,x,L,C,ut,ht,k,w,A,Ue,M,B,H,R,O,E,oe,ie,re,le,se,ce,ue,fe,me,U,K,Z,ee,J,ne,te,Le,Je,et,tt,nt,ot,it,rt,lt,st,$t,ct,S]),Rt=e.useRef(null);Rt.current||(Rt.current=new N(Dt));const Gt=e.useCallback(()=>{At.current||(At.current=requestAnimationFrame(()=>It.current()))},[]);e.useEffect(()=>{var e;null===(e=Rt.current)||void 0===e||e.updateConfig(Dt),Mt.current=!0,Gt()},[Dt,Gt]),e.useEffect(()=>{Mt.current=!0,Gt()},[St,Gt]);const Yt=e.useRef(null);Yt.current||(Yt.current=new g(e=>{const t=Rt.current;t&&t.ingest(e)&&(Mt.current=!0,Gt())},{chunkThreshold:m,chunkSize:v})),e.useEffect(()=>{var e;null===(e=Yt.current)||void 0===e||e.updateChunkOptions({chunkThreshold:m,chunkSize:v})},[m,v]);const qt=e.useCallback(e=>{var t;null===(t=Yt.current)||void 0===t||t.push(e)},[]),Xt=e.useCallback(e=>{var t;null===(t=Yt.current)||void 0===t||t.pushMany(e)},[]),Vt=e.useCallback(()=>{var e,t;null===(e=Yt.current)||void 0===e||e.clear(),null===(t=Rt.current)||void 0===t||t.clear(),Mt.current=!0,Gt()},[Gt]);e.useImperativeHandle(n,()=>({push:qt,pushMany:Xt,clear:Vt,getData:()=>{var e,t,n;return null===(e=Yt.current)||void 0===e||e.flush(),null!==(n=null===(t=Rt.current)||void 0===t?void 0:t.getData())&&void 0!==n?n:[]},getScales:()=>{var e,t;return null!==(t=null===(e=Rt.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null},getExtents:()=>{var e,t;return null!==(t=null===(e=Rt.current)||void 0===e?void 0:e.getExtents())&&void 0!==t?t:null}}),[qt,Xt,Vt]),e.useEffect(()=>{var e;y&&(null===(e=Yt.current)||void 0===e||e.setBoundedData(y))},[y]);const Qt=e.useRef(()=>{}),Ut=e.useRef(()=>{});Qt.current=e=>{if(!xt)return;const t=kt.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-pt.left,i=e.clientY-n.top-pt.top;if(0>o||o>yt||0>i||i>mt)return void(Pt.current&&(Pt.current=null,_t.current=null,Bt(null),Pe&&(Pe(null),Mt.current=!0),Gt()));const r=Rt.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=W(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=W(s,t,n);break;case"line":e=z(s,t,n);break;case"rect":e=F(s,t,n);break;case"heatcell":e=I(s,t,n);break;case"area":if(!1===s.interactive)break;e=D(s,t,n);break;case"candlestick":e=$(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(Pt.current&&(Pt.current=null,_t.current=null,Bt(null),Pe&&Pe(null),Gt()));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});Pt.current=a,_t.current=l.node,Bt(a),Pe&&(Pe(a),Mt.current=!0),Gt()},Ut.current=()=>{Pt.current&&(Pt.current=null,_t.current=null,Bt(null),Pe&&(Pe(null),Mt.current=!0),Gt())},e.useCallback(e=>Qt.current(e),[]);const Kt=e.useCallback(()=>Ut.current(),[]),Zt=e.useRef(-1),Jt=e.useCallback(e=>{const t=Rt.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>Zt.current?-1:Zt.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 Zt.current=-1,Pt.current=null,_t.current=null,Bt(null),Pe&&Pe(null),void Gt();const r=0>o?0:i;Zt.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]);Pt.current=l,Bt(l),Pe&&Pe(l),Gt()},[Pe,Gt]),en=e.useCallback(e=>{Zt.current=-1,Qt.current(e)},[]);It.current=()=>{var e,t;At.current=0;const n=kt.current,o=wt.current;if(!n||!o)return;const i=Rt.current;if(!i)return;const r="undefined"!=typeof performance?performance.now():Date.now(),l=i.advanceTransition(r),s=Mt.current||l;s&&!l&&i.computeScene({width:yt,height:mt});const a="undefined"!=typeof window&&window.devicePixelRatio||1,c=function(e){if(!e)return De;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||De.axisStroke,tickText:r||De.tickText,crosshair:r?r+"66":De.crosshair,hoverFill:a?a+"4D":De.hoverFill,hoverStroke:r?r+"99":De.hoverStroke,pointRing:a||De.pointRing}:De}(n),u=null!==(e=null==nt?void 0:nt.threshold)&&void 0!==e?e:5e3,h=nt&&i.lastIngestTime>0&&r-i.lastIngestTime>u;if(s){const e=Ae(n,gt,pt,a);if(e){e.clearRect(-pt.left,-pt.top,gt[0],gt[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(),r=Q||(o&&"transparent"!==o?o:null);if(r&&(e.fillStyle=r,e.fillRect(-pt.left,-pt.top,gt[0],gt[1])),e.save(),"function"==typeof e.rect&&(e.beginPath(),e.rect(0,0,yt,mt),e.clip()),Ve&&i.scales)for(const t of Ve)e.save(),t(e,i.scene,i.scales,{width:yt,height:mt}),e.restore();const l=Ie[f];if(l&&i.scales)for(const t of l)t(e,i.scene,i.scales,{width:yt,height:mt});e.restore(),h&&(e.globalAlpha=1)}}{const e=Ae(o,gt,pt,a);if(e&&(xt&&Pt.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,Pt.current,yt,mt,"object"==typeof xt?xt:{},0,c),_t.current&&Array.isArray(Ce))){const t=Ce.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,_t.current,t)}}s&&n&&n.setAttribute("aria-label",ge(i.scene,f+" chart"));const d=Mt.current;if(Mt.current=!1,d&&i.scales&&((!Ct||Ct.x.domain()[0]!==i.scales.x.domain()[0]||Ct.x.domain()[1]!==i.scales.x.domain()[1]||Ct.y.domain()[0]!==i.scales.y.domain()[0]||Ct.y.domain()[1]!==i.scales.y.domain()[1]||Ct.x.range()[0]!==i.scales.x.range()[0]||Ct.x.range()[1]!==i.scales.x.range()[1]||Ct.y.range()[0]!==i.scales.y.range()[0]||Ct.y.range()[1]!==i.scales.y.range()[1])&&jt(i.scales),at)){const e=i.getData(),t="function"==typeof b?b:e=>e[b||"x"],n="function"==typeof x?x:e=>e[x||"y"];zt(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),Ft(e.map(e=>n(e)).filter(e=>"number"==typeof e&&isFinite(e)))}d&&Le&&Le.length>0&&Ot(e=>e+1),(null==nt?void 0:nt.showBadge)&&Ht(!!h),(l||i.hasActivePulses)&&(At.current=requestAnimationFrame(()=>It.current()))},e.useEffect(()=>(Gt(),()=>{At.current&&(cancelAnimationFrame(At.current),At.current=0)}),[Gt]),e.useEffect(()=>{Mt.current=!0,Gt()},[f,yt,mt,ve,Q,U,Ve,Gt]),function(t,n,o,i,r,l){e.useEffect(()=>{if(!t)return;const e=setInterval(()=>{var e;const s=n.current;if(!s||0===s.lastIngestTime)return;const a="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(e=t.threshold)&&void 0!==e?e:5e3,u=a-s.lastIngestTime>c;u!==r&&(l(u),o.current=!0,i())},1e3);return()=>clearInterval(e)},[t,r,i])}(nt,Rt,Mt,Gt,Nt,Ht);const tn=xt&&Lt?je?je(Lt):d.createElement(Ge,{hover:Lt}):null,nn=tn?d.createElement("div",{className:"stream-frame-tooltip",style:{position:"absolute",left:pt.left+Lt.x,top:pt.top+Lt.y,transform:`translate(${Lt.x>.7*yt?"calc(-100% - 12px)":"12px"}, ${.3*mt>Lt.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:1,width:"max-content"}},tn):null,on=Zt.current>=0&&Lt?d.createElement("svg",{style:{position:"absolute",left:0,top:0,width:gt[0],height:gt[1],pointerEvents:"none",zIndex:2}},d.createElement("circle",{cx:Lt.x+pt.left,cy:Lt.y+pt.top,r:8,fill:"none",stroke:"var(--accent, #6366f1)",strokeWidth:2,strokeDasharray:"4,2"})):null;if(de){const e=Rt.current;e&&y&&(e.ingest({inserts:y,bounded:!0}),e.computeScene({width:yt,height:mt}));const t=null!==(o=null==e?void 0:e.scene)&&void 0!==o?o:[],n=null!==(i=null==e?void 0:e.scales)&&void 0!==i?i:null;return d.createElement("div",{className:"stream-xy-frame"+(V?" "+V:""),role:"img","aria-label":"string"==typeof Qe?Qe:"XY chart",style:{position:"relative",width:gt[0],height:gt[1]}},d.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:gt[0],height:gt[1],style:{position:"absolute",left:0,top:0}},bt,d.createElement("g",{transform:`translate(${pt.left},${pt.top})`},Q&&d.createElement("rect",{x:0,y:0,width:yt,height:mt,fill:Q}),t.map((e,t)=>function(e,t){var n,o,i;switch(e.type){case"line":{const n=e;if(0===n.path.length)return null;const o="M"+n.path.map(([e,t])=>`${e},${t}`).join("L");return d.createElement("path",{key:"line-"+t,d:o,fill:"none",stroke:n.style.stroke||"#4e79a7",strokeWidth:n.style.strokeWidth||2,strokeDasharray:n.style.strokeDasharray,opacity:n.style.opacity})}case"area":{const i=e;if(0===i.topPath.length)return null;const r=i.topPath.map(([e,t])=>`${e},${t}`).join("L"),l=[...i.bottomPath].reverse().map(([e,t])=>`${e},${t}`).join("L");return d.createElement("path",{key:"area-"+t,d:`M${r}L${l}Z`,fill:i.style.fill||"#4e79a7",fillOpacity:null!==(o=null!==(n=i.style.fillOpacity)&&void 0!==n?n:i.style.opacity)&&void 0!==o?o:.7,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})}case"point":return d.createElement("circle",{key:"point-"+t,cx:e.x,cy:e.y,r:e.r,fill:e.style.fill||"#4e79a7",opacity:null!==(i=e.style.opacity)&&void 0!==i?i:.8,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth});case"rect":return d.createElement("rect",{key:"rect-"+t,x:e.x,y:e.y,width:e.w,height:e.h,fill:e.style.fill||"#4e79a7",opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth});case"heatcell":{const n=e;if(n.showValues&&null!=n.value&&n.w>=20&&n.h>=20){const e=n.valueFormat?n.valueFormat(n.value):Number.isInteger(n.value)?n.value+"":100>Math.abs(n.value)?1>Math.abs(n.value)?n.value.toPrecision(3):n.value.toFixed(1):n.value.toFixed(0),[o,i,r]=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]}(n.fill),l=.299*o+.587*i+.114*r>128?"#000":"#fff",s=Math.max(10,Math.min(16,.3*Math.min(n.w,n.h)));return d.createElement("g",{key:"heatcell-"+t},d.createElement("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill}),d.createElement("text",{x:n.x+n.w/2,y:n.y+n.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:l,fontSize:s+"px"},e))}return d.createElement("rect",{key:"heatcell-"+t,x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill})}case"candlestick":{const n=e,o=Math.min(n.openY,n.closeY),i=Math.max(Math.abs(n.openY-n.closeY),1),r=n.isUp?n.upColor:n.downColor;return d.createElement("g",{key:"candle-"+t},d.createElement("line",{x1:n.x,y1:n.highY,x2:n.x,y2:n.lowY,stroke:n.wickColor,strokeWidth:n.wickWidth}),d.createElement("rect",{x:n.x-n.bodyWidth/2,y:o,width:n.bodyWidth,height:i,fill:r,stroke:r,strokeWidth:1}))}default:return null}}(e,t)).filter(Boolean))),d.createElement(he,{width:yt,height:mt,totalWidth:gt[0],totalHeight:gt[1],margin:pt,scales:n,showAxes:ve,axes:be,xLabel:xe,yLabel:ke,xFormat:Me||Ee,yFormat:Se||Oe,showGrid:Ne,title:Qe,legend:He,legendHoverBehavior:We,legendClickBehavior:ze,legendHighlightedCategory:Te,legendIsolatedCategories:Fe,legendPosition:Re,foregroundGraphics:vt,marginalGraphics:at,xValues:[],yValues:[],annotations:Le,svgAnnotationRules:Be,annotationFrame:0,xAccessor:"string"==typeof b?b:"string"==typeof L?L:void 0,yAccessor:"string"==typeof x?x:"string"==typeof C?C:void 0,annotationData:null==e?void 0:e.getData(),pointNodes:null==e?void 0:e.scene.filter(e=>"point"===e.type),curve:"string"==typeof S?S:void 0}))}return d.createElement("div",{ref:ft,className:"stream-xy-frame"+(V?" "+V:""),role:"img","aria-label":"string"==typeof Qe?Qe:"XY chart",tabIndex:0,style:{position:"relative",width:Y?"100%":gt[0],height:q?"100%":gt[1],overflow:"visible"},onMouseMove:xt?en:void 0,onMouseLeave:xt?Kt:void 0,onKeyDown:Jt},bt&&d.createElement("svg",{style:{position:"absolute",left:0,top:0,width:gt[0],height:gt[1],pointerEvents:"none"}},bt),d.createElement(ae,{width:yt,height:mt,totalWidth:gt[0],totalHeight:gt[1],margin:pt,scales:Ct,showAxes:ve,axes:be,showGrid:Ne,xFormat:Me||Ee,yFormat:Se||Oe}),d.createElement("canvas",{ref:kt,"aria-label":ge(null!==(l=null===(r=Rt.current)||void 0===r?void 0:r.scene)&&void 0!==l?l:[],f+" chart"),style:{position:"absolute",left:0,top:0}}),d.createElement("canvas",{ref:wt,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),d.createElement(ye,{hoverPoint:Lt}),dt&&d.createElement(pe,{scene:null!==(a=null===(s=Rt.current)||void 0===s?void 0:s.scene)&&void 0!==a?a:[],chartType:f+" chart"}),d.createElement(he,{width:yt,height:mt,totalWidth:gt[0],totalHeight:gt[1],margin:pt,scales:Ct,showAxes:ve,axes:be,xLabel:xe,yLabel:ke,xFormat:Me||Ee,yFormat:Se||Oe,showGrid:Ne,title:Qe,legend:He,legendHoverBehavior:We,legendClickBehavior:ze,legendHighlightedCategory:Te,legendIsolatedCategories:Fe,legendPosition:Re,foregroundGraphics:vt,marginalGraphics:at,xValues:Wt,yValues:Tt,annotations:Le,svgAnnotationRules:Be,annotationFrame:Et,xAccessor:"string"==typeof b?b:"string"==typeof L?L:void 0,yAccessor:"string"==typeof x?x:"string"==typeof C?C:void 0,annotationData:null===(c=Rt.current)||void 0===c?void 0:c.getData(),pointNodes:null===(u=Rt.current)||void 0===u?void 0:u.scene.filter(e=>"point"===e.type),curve:"string"==typeof S?S:void 0,underlayRendered:!0}),(Ke||Ze)&&d.createElement(Ye,{width:yt,height:mt,totalWidth:gt[0],totalHeight:gt[1],margin:pt,dimension:null!==(h=null==Ke?void 0:Ke.dimension)&&void 0!==h?h:"xy",scales:Ct,onBrush:null!=Ze?Ze:()=>{}}),(null==nt?void 0:nt.showBadge)&&d.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:Nt?"#dc3545":"#28a745",color:"white"})},Nt?"STALE":"LIVE"),on,nn)});qe.displayName="StreamXYFrame";const Xe=e.createContext(null);function Ve(){return e.useContext(Xe)}function Qe(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 Ue(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}const[Ke,Ze]=me(e=>({selections:new Map,setClause(t,n){e(e=>{const o=new Map(e.selections),i=Ue(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=Ue(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}})}})),[Je,et]=me(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 tt(t){const n=e.useId(),o=t.clientId||n,{name:i}=t,r=Ze(e=>e.selections.get(i)),l=Ze(e=>e.setClause),s=Ze(e=>e.clearClause),a=e.useMemo(()=>!!r&&r.clauses.size>0,[r]);return{predicate:e.useMemo(()=>r&&0!==r.clauses.size?function(e,t){const n=[];for(const[o,i]of e.clauses)"crossfilter"===e.resolution&&o===t||n.push(Qe(i));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(r,o):()=>!0,[r,o]),isActive:a,selectPoints:e.useCallback(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"point",values:new Set(o)};l(i,{clientId:o,type:"point",fields:t})},[o,i,l]),selectInterval:e.useCallback(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"interval",range:o};l(i,{clientId:o,type:"interval",fields:t})},[o,i,l]),clear:e.useCallback(()=>{s(i,o)},[s,i,o]),clientId:o}}function nt(t){const n=t.name||"hover",{fields:o}=t,{predicate:i,isActive:r,selectPoints:l,clear:s}=tt({name:n});return{onHover:e.useCallback(e=>{if(!e)return void s();const t={};for(const n of o){const o=e[n];void 0!==o&&(t[n]=[o])}Object.keys(t).length>0&&l(t)},[o,l,s,n]),predicate:i,isActive:r}}function ot(t){const{name:n,xField:o,yField:i}=t,{predicate:r,isActive:l,selectInterval:s,clear:a}=tt({name:n}),c=o&&i?"xyBrush":o?"xBrush":"yBrush",u=e.useCallback(e=>{if(!e)return void a();const t={};"xyBrush"===c&&Array.isArray(e)&&2===e.length?(o&&(t[o]=[Math.min(e[0][0],e[1][0]),Math.max(e[0][0],e[1][0])]),i&&(t[i]=[Math.min(e[0][1],e[1][1]),Math.max(e[0][1],e[1][1])])):"xBrush"===c&&Array.isArray(e)?o&&(t[o]=[Math.min(...e),Math.max(...e)]):"yBrush"===c&&Array.isArray(e)&&i&&(t[i]=[Math.min(...e),Math.max(...e)]),Object.keys(t).length>0&&s(t)},[c,o,i,s,a]);return{brushInteraction:e.useMemo(()=>({brush:c,during:u,end:u}),[c,u]),predicate:r,isActive:l,clear:a}}const it=e.createContext(!1);function rt({selections:t}){const n=Ze(e=>e.setResolution);return e.useEffect(()=>{for(const[e,o]of Object.entries(t))o.resolution&&n(e,o.resolution)},[t,n]),null}function lt({categoryColors:t,interaction:n,selectionName:o,field:i}){const r=Object.entries(t);if(0===r.length)return null;const l=r.map(([e])=>e),s=[{styleFn:e=>({fill:e.color||"#333",stroke:e.color||"#333"}),type:"fill",items:r.map(([e,t])=>({label:e,color:t})),label:""}],a=nt({name:o,fields:[i]}),c=tt({name:o,clientId:"__linked-legend-isolate__"}),[u,h]=e.useState(new Set),[f,g]=e.useState(null),p=e.useRef(c.selectPoints);p.current=c.selectPoints;const y=e.useRef(c.clear);y.current=c.clear,e.useEffect(()=>{"isolate"===n&&(u.size>0?p.current({[i]:Array.from(u)}):y.current())},[n,u,i]);const m=e.useCallback(e=>{"highlight"===n&&(e?(g(e.label),a.onHover({[i]:e.label})):(g(null),a.onHover(null)))},[n,i,a]),v=e.useCallback(e=>{"isolate"===n&&h(t=>{const n=new Set(t);return n.has(e.label)?n.delete(e.label):n.add(e.label),n.size===l.length?new Set:n})},[n,l.length]);return d.createElement("svg",{width:"100%",height:30,style:{display:"block",overflow:"visible"}},d.createElement(Q,{legendGroups:s,title:!1,orientation:"horizontal",height:20,customHoverBehavior:"highlight"===n?m:void 0,customClickBehavior:"isolate"===n?v:void 0,highlightedCategory:f,isolatedCategories:u}))}function st({children:e,selections:t,showLegend:n,legendPosition:o="top",legendInteraction:i="none",legendSelectionName:r="legend",legendField:l="category"}){const s=Ve(),a=void 0!==n?n:!(!s||0>=Object.keys(s).length);return d.createElement(Ke,null,d.createElement(Je,null,t&&d.createElement(rt,{selections:t}),d.createElement(it.Provider,{value:a},a&&"top"===o&&s&&d.createElement(lt,{categoryColors:s,interaction:i,selectionName:r,field:l}),e,a&&"bottom"===o&&s&&d.createElement(lt,{categoryColors:s,interaction:i,selectionName:r,field:l}))))}function at({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 ct(e){return e?"string"==typeof e?{name:e}:e:null}function ut(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 ht="#007bff";function dt(e){return"function"==typeof e?e:t=>t[e]}function ft(t,n,o="category10"){const i=Ve();return e.useMemo(()=>{if(n){if(0===t.length)return i&&Object.keys(i).length>0?e=>i[e]||"#999":void 0;if("function"==typeof n){const e=Array.from(new Set(t.map(e=>n(e)+"")));return i&&Object.keys(i).length>0?e=>i[e]||"#999":_(e.map(e=>({_cat:e})),"_cat",o)}if(i&&Object.keys(i).length>0){const e=_(t,n,o);return t=>i[t]||e(t)}return _(t,n,o)}},[t,n,o,i])}function gt({selection:t,linkedHover:n,fallbackFields:o=[],unwrapData:i=!1,onObservation:r,chartType:l,chartId:s}){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}(n,o),c=tt({name:(null==t?void 0:t.name)||"__unused__"}),u=nt({name:(null==a?void 0:a.name)||"hover",fields:(null==a?void 0:a.fields)||o||[]}),h=et(e=>e.pushObservation),d=t?{isActive:c.isActive,predicate:c.predicate}:null,f=e.useCallback(e=>{var t,o;if(n)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 n={timestamp:Date.now(),chartType:l||"unknown",chartId:s};if(e){let i=e.data||e.datum||e;Array.isArray(i)&&(i=i[0]);const l=Object.assign(Object.assign({},n),{type:"hover",datum:i||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(o=e.y)&&void 0!==o?o:0});r&&r(l),h&&h(l)}else{const e=Object.assign(Object.assign({},n),{type:"hover-end"});r&&r(e),h&&h(e)}}},[n,u,r,l,s,h]),g=e.useCallback(e=>{var t,n;if(r||h){const o={timestamp:Date.now(),chartType:l||"unknown",chartId:s};if(e){let i=e.data||e.datum||e;Array.isArray(i)&&(i=i[0]);const l=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(l),h&&h(l)}else{const e=Object.assign(Object.assign({},o),{type:"click-end"});r&&r(e),h&&h(e)}}},[r,h,l,s]);return{activeSelectionHook:d,customHoverBehavior:f,customClickBehavior:g}}function pt({data:t,colorBy:n,colorScale:o,showLegend:i,legendPosition:r="right",userMargin:l,defaults:s={top:50,bottom:60,left:70,right:40}}){const a=e.useContext(it),c=void 0!==i?i:!a&&!!n,u=e.useMemo(()=>{if(c&&n)return at({data:t,colorBy:n,colorScale:o,getColor:P})},[c,n,t,o]),h=e.useMemo(()=>{const e=Object.assign(Object.assign({},s),l);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},[s,l,u,r]);return{legend:u,margin:h,legendPosition:r}}function yt(t,n,o){const[i,r]=e.useState(null),[l,s]=e.useState(new Set),a=e.useCallback(e=>{"highlight"===t&&r(e?e.label:null)},[t]),c=e.useCallback(e=>{"isolate"===t&&s(t=>{const n=new Set(t);return n.has(e.label)?n.delete(e.label):n.add(e.label),n.size===o.length?new Set:n})},[t,o.length]),u=e.useMemo(()=>{if(!t||"none"===t||!n)return null;const e="string"==typeof n?n:null;return"highlight"===t&&null!=i?{isActive:!0,predicate:t=>(e?t[e]:"function"==typeof n?n(t):null)===i}:"isolate"===t&&l.size>0?{isActive:!0,predicate:t=>{const o=e?t[e]:"function"==typeof n?n(t):null;return l.has(o)}}:null},[t,n,i,l]);return{highlightedCategory:"highlight"===t?i:null,isolatedCategories:"isolate"===t?l:new Set,onLegendHover:a,onLegendClick:c,legendSelectionHook:u}}const mt={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 vt(e,t,n){var o,i,r,l,s,a;const c=mt[e||"primary"],u="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: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 bt={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 xt(e,t){return"function"==typeof t?t(e):e[t]}function kt(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 wt(e={}){const{fields:t,title:n,format:o,style:i={},className:r=""}=e;return e=>{if(!e||"object"!=typeof e)return null;let l;const s=[];if(n){const t=xt(e,n);l=kt(t,o)}if(t&&t.length>0)t.forEach(t=>{let n,i,r;"string"==typeof t?(n=t,i=t,r=o):(n=t.label,i=t.accessor||t.key||"",r=t.format||o);const l=xt(e,i);s.push({label:n,value:kt(l,r)})});else if(!n){const t=["value","y","name","id","label"];for(const n of t)if(void 0!==e[n]){l=kt(e[n],o);break}if(!l){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(l=kt(e[t[0]],o))}}const a=Object.assign(Object.assign({},bt),i);return d.createElement("div",{className:("semiotic-tooltip "+r).trim(),style:a},l&&d.createElement("div",{style:{fontWeight:s.length>0?"bold":"normal"}},l),s.map((e,t)=>d.createElement("div",{key:t,style:{marginTop:0===t&&l?"4px":0}},e.label&&d.createElement("span",null,e.label,": "),e.value)))}}function At(e){if(!0===e)return wt();if("function"==typeof e){const t=e;return e=>{const n=t(!e||"object"!=typeof e.data||null===e.data||"node"!==e.type&&"edge"!==e.type?e:e.data);return null==n?null:d.createElement("div",{className:"semiotic-tooltip",style:bt},n)}}return!1!==e&&void 0!==e&&("object"==typeof e&&null!==e&&("fields"in e||"title"in e)?wt(e):wt())}function Mt(e){return"string"==typeof e?e:"value"}function St(e){return null==e?"–":"number"==typeof e?Math.abs(e)>9999?e.toLocaleString():e+"":e instanceof Date?e.toLocaleDateString():e+""}function Et(e,t){return"function"==typeof t?t(e):e[t]}function Ot(e){const t=e.find(e=>"title"===e.role),n=e.filter(e=>"title"!==e.role);return e=>{const o=e.data;if(!o)return null;const i=t?St(Et(o,t.accessor)):null;return d.createElement("div",{className:"semiotic-tooltip",style:bt},i&&d.createElement("div",{style:{fontWeight:"bold",marginBottom:n.length>0?4:0}},i),n.map((e,t)=>{const n=St(Et(o,e.accessor));return d.createElement("div",{key:t,style:t>0?{marginTop:2}:void 0},d.createElement("span",{style:{opacity:.7}},e.label,": "),d.createElement("span",null,n))}))}}function Ct({componentName:e,message:t,width:n,height:o}){return d.createElement("div",{role:"alert",style:{width:n,height:Math.max(o,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"}},d.createElement("div",{style:{textAlign:"center",maxWidth:400}},d.createElement("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"}},e),d.createElement("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5}},t)))}class jt extends d.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:e}=this.props,t=this.state.error;return"function"==typeof e?e(t):void 0!==e?e:d.createElement(Ct,{componentName:"ChartErrorBoundary",message:t.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}var Pt;const _t="undefined"!=typeof process&&"production"!==(null===(Pt=process.env)||void 0===Pt?void 0:Pt.NODE_ENV);function Lt({componentName:e,width:t,height:n,children:o}){return d.createElement(jt,{fallback:o=>d.createElement(Ct,{componentName:e,message:o.message,width:t,height:n})},o)}const Bt={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"},Nt={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function Ht(e,t,n,o){return!1===o||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?d.createElement("div",{style:Object.assign(Object.assign({},Bt),{width:t,height:n})},o||"No data available"):null}function Wt(e,t,n){if(!e)return null;const o=Math.min(5,Math.floor(n/40)),i=Math.max(8,Math.floor(n/(3*o))),r=Math.max(6,Math.floor(n/(2.5*o))),l=Math.floor((n-(o*(i+r)-r))/2);return d.createElement("div",{style:{width:t,height:n,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"}},Array.from({length:o},(e,n)=>d.createElement("div",{key:n,className:"semiotic-loading-bar",style:Object.assign(Object.assign({},Nt),{position:"absolute",top:l+n*(i+r),left:Math.floor(.1*t),width:30+(37*n+13)%50+"%",height:i,opacity:.5+n%2*.2})})))}function zt(e,t,n,o){if(!_t)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 Tt(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 Ft(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=Tt(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 It({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=Ft(r,t),o=n?` Try ${i}="${n}".`:"";return`${e}: ${i} "${r}" not found in data. Available fields: ${t.join(", ")}.${o}`}}}return null}function $t(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 Dt=null;function Rt(){return $t(this,void 0,void 0,function*(){return Dt||(Dt=yield Promise.resolve().then(function(){return dn})),Dt})}const Gt=e.forwardRef(function(t,n){var o,i;const r=e.useRef(null);e.useImperativeHandle(n,()=>({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=vt(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:s,margin:a,className:c,xFormat:u,yFormat:h,xAccessor:f="x",yAccessor:g="y",lineBy:p,lineDataAccessor:y="coordinates",colorBy:m,colorScheme:v="category10",curve:b="linear",showPoints:x=!1,pointRadius:k=3,fillArea:w=!1,areaOpacity:A=.3,lineWidth:M=2,tooltip:S,pointIdAccessor:E,annotations:O,directLabel:C,gapStrategy:j="break",anomaly:_,forecast:L,frameProps:B={},selection:N,linkedHover:H,onObservation:W,chartId:z,loading:T,emptyContent:F,legendInteraction:I,legendPosition:$,xScaleType:D,yScaleType:R}=t,G=l.width,Y=l.height,q=l.enableHover,X=l.showGrid,V=l.showLegend,Q=l.title,U=l.xLabel,K=l.yLabel,Z=Wt(T,G,Y);if(Z)return Z;const J=Ht(s,G,Y,F);if(J)return J;const ee=s||[];zt("LineChart",ee,"xAccessor",f),zt("LineChart",ee,"yAccessor",g);const te="string"==typeof f?f:"x",ne="string"==typeof g?g:"y",[oe,ie]=e.useState(null),[re,le]=e.useState([]);e.useEffect(()=>{if(!L&&!_)return;let e=!1;return ie(null),le([]),L?function(...e){return $t(this,void 0,void 0,function*(){return(yield Rt()).buildForecast(...e)})}(ee,te,ne,L,_).then(t=>{e||(ie(t),le(t.annotations))}).catch(()=>{e||(ie(null),le([]))}):_&&function(...e){return $t(this,void 0,void 0,function*(){return(yield Rt()).buildAnomalyAnnotations(...e)})}(_).then(t=>{e||(ie(null),le(t))}).catch(()=>{e||le([])}),()=>{e=!0}},[ee,L,_,te,ne]);const se=oe?oe.processedData:ee,ae=L&&!p?"__forecastSegment":p,{activeSelectionHook:ce,customHoverBehavior:ue}=gt({selection:N,linkedHover:H,fallbackFields:m?["string"==typeof m?m:""]:[],onObservation:W,chartType:"LineChart",chartId:z}),he=e.useCallback(e=>{const t="function"==typeof f?f(e):e[f],n="function"==typeof g?g(e):e[g];return null==t||null==n||Number.isNaN(t)||Number.isNaN(n)},[f,g]),de=void 0!==(null===(o=se[0])||void 0===o?void 0:o[y]),fe=e.useMemo(()=>{if(de)return se;if(ae){const e=se.reduce((e,t)=>{const n="function"==typeof ae?ae(t):t[ae];if(!e[n]){const t={[y]:[]};"string"==typeof ae&&(t[ae]=n),e[n]=t}return e[n][y].push(t),e},{});return Object.values(e)}return[{[y]:se}]},[se,ae,y,de]),{gapProcessedLineData:ge,hasGaps:pe}=e.useMemo(()=>{if("interpolate"===j){let e=!1;const t=[];for(const n of fe){const o=(n[y]||[]).filter(t=>!he(t)||(e=!0,!1));o.length>0&&t.push(Object.assign(Object.assign({},n),{[y]:o}))}return{gapProcessedLineData:t,hasGaps:e}}if("break"===j){let e=!1;const t=[];for(const n of fe){const o=n[y]||[];let i=[],r=0;const l=ae&&"string"==typeof ae?n[ae]:void 0;for(const s of o)if(he(s))e=!0,i.length>0&&(t.push(Object.assign(Object.assign({},n),{[y]: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),{[y]:i}))}return{gapProcessedLineData:t,hasGaps:e}}if("zero"===j){let e=!1;const t="string"==typeof g?g:"y",n=[];for(const o of fe){const i=o[y]||[],r=[];for(const n of i)he(n)?(e=!0,r.push(Object.assign(Object.assign({},n),{[t]:0}))):r.push(n);n.push(Object.assign(Object.assign({},o),{[y]:r}))}return{gapProcessedLineData:n,hasGaps:e}}return{gapProcessedLineData:fe,hasGaps:!1}},[fe,j,y,he,ae,g]),ye=ft(se,m,v),me=e.useMemo(()=>{if(!m)return[];const e=new Set;for(const t of se){const n="function"==typeof m?m(t):t[m];null!=n&&e.add(n+"")}return Array.from(e)},[se,m]),ve=yt(I,m,me),be=e.useMemo(()=>ve.legendSelectionHook?ve.legendSelectionHook:ce,[ve.legendSelectionHook,ce]),xe=e.useMemo(()=>e=>{const t={strokeWidth:M};return m?ye&&(t.stroke=P(e,m,ye),w&&(t.fill=t.stroke,t.fillOpacity=A)):(t.stroke=ht,w&&(t.fill=ht,t.fillOpacity=A)),t},[m,ye,M,w,A]),[ke,we]=e.useState(null);e.useEffect(()=>{if(!L)return void we(null);let e=!1;return function(...e){return $t(this,void 0,void 0,function*(){return(yield Rt()).createSegmentLineStyle(...e)})}(xe,L).then(t=>{e||we(()=>t)}).catch(()=>{e||we(null)}),()=>{e=!0}},[xe,L]);const Ae=ke||xe,Me=e.useMemo(()=>ut(Ae,be,N),[Ae,be,N]),Se=e.useMemo(()=>{if(x)return e=>{const t={r:k,fillOpacity:1};return m?ye&&(t.fill=P(e.parentLine||e,m,ye)):t.fill=ht,t}},[x,k,m,ye]),Ee=w?"area":"line",Oe="object"==typeof C?C:{},Ce=Oe.position||"end",je=Oe.fontSize||11,Pe=e.useMemo(()=>{var e,t;if(!C||!m)return[];const n="function"==typeof f?f:e=>e[f],o="function"==typeof g?g:e=>e[g],i="function"==typeof m?m:e=>e[m],r=new Map;for(const n of ge){const o=n[y]||[];if(0===o.length)continue;const l="end"===Ce?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 f?f:"x"]:n(t),["string"==typeof g?g:"y"]:o(t),dx:"end"===Ce?6:-6,dy:0,color:ye?ye(e):ht,fontSize:je}));l.sort((e,t)=>{const n="string"==typeof g?g:"y";return e[n]-t[n]});for(let e=1;l.length>e;e++){const t="string"==typeof g?g:"y",n=l[e-1],o=l[e];je+2>Math.abs(o[t]+o.dy-(n[t]+n.dy))&&(o.dy+=je+2)}return l},[C,m,ye,ge,y,f,g,Ce,je]),_e=(!C||void 0!==V)&&V,Le=e.useMemo(()=>{if(!C)return l.marginDefaults;const e=Pe.reduce((e,t)=>{var n;const o=((null===(n=t.label)||void 0===n?void 0:n.length)||0)*(.6*je);return Math.max(e,o)},0),t=e+10,n="end"===Ce?"right":"left";return Object.assign(Object.assign({},l.marginDefaults),{[n]:Math.max(l.marginDefaults[n]||0,t)})},[C,Pe,je,Ce,l.marginDefaults]),{legend:Be,margin:Ne,legendPosition:He}=pt({data:ge,colorBy:m,colorScale:ye,showLegend:_e,legendPosition:$,userMargin:a,defaults:Le}),We=p||m,ze=e.useMemo(()=>Ot([{label:U||Mt(f),accessor:f,role:"x"},{label:K||Mt(g),accessor:g,role:"y"},...We?[{label:Mt(We),accessor:We,role:"group"}]:[]]),[f,g,U,K,We]),Te=It({componentName:"LineChart",data:de?(null===(i=se[0])||void 0===i?void 0:i[y])||[]:s,accessors:{xAccessor:f,yAccessor:g}});if(Te)return d.createElement(Ct,{componentName:"LineChart",message:Te,width:G,height:Y});const Fe=e.useMemo(()=>de||ae||pe?ge.flatMap(e=>{const t=e[y]||[];return ae&&"string"==typeof ae?t.map(t=>Object.assign(Object.assign({},t),{[ae]:e[ae]})):t}):se,[ge,y,de,ae,se,pe]),Ie=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:Ee},null!=s&&{data:Fe}),{xAccessor:f,yAccessor:g,xScaleType:D,yScaleType:R,groupAccessor:"break"===j&&pe?"_gapSegment":ae||void 0,curve:b,lineStyle:Me}),x&&{pointStyle:Se}),{size:[G,Y],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Ne,showAxes:l.showAxes,xLabel:U,yLabel:K,xFormat:u,yFormat:h,enableHover:q,showGrid:X}),Be&&{legend:Be,legendPosition:He}),I&&"none"!==I&&{legendHoverBehavior:ve.onLegendHover,legendClickBehavior:ve.onLegendClick,legendHighlightedCategory:ve.highlightedCategory,legendIsolatedCategories:ve.isolatedCategories}),Q&&{title:Q}),c&&{className:c}),{tooltipContent:!1===S?()=>null:At(S)||ze}),(H||W)&&{customHoverBehavior:ue}),E&&{pointIdAccessor:E}),((null==O?void 0:O.length)||re.length||Pe.length)&&{annotations:[...O||[],...re,...Pe]}),B);return d.createElement(Lt,{componentName:"LineChart",width:G,height:Y},d.createElement(qe,Object.assign({ref:r},Ie)))});Gt.displayName="LineChart";const Yt=e.forwardRef(function(t,n){var o;const i=e.useRef(null);e.useImperativeHandle(n,()=>({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 r=vt(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:l,margin:s,className:a,xFormat:c,yFormat:u,xAccessor:h="x",yAccessor:f="y",areaBy:g,y0Accessor:p,gradientFill:y=!1,lineDataAccessor:m="coordinates",colorBy:v,colorScheme:b="category10",curve:x="monotoneX",areaOpacity:k=.7,showLine:w=!0,lineWidth:A=2,tooltip:M,annotations:S,frameProps:E={},selection:O,linkedHover:C,onObservation:j,chartId:_,loading:L,emptyContent:B,legendInteraction:N,legendPosition:H}=t,W=r.width,z=r.height,T=r.enableHover,F=r.showGrid,I=r.showLegend,$=r.title,D=r.xLabel,R=r.yLabel,G=Wt(L,W,z);if(G)return G;const Y=Ht(l,W,z,B);if(Y)return Y;const q=l||[];zt("AreaChart",q,"xAccessor",h),zt("AreaChart",q,"yAccessor",f);const{activeSelectionHook:X,customHoverBehavior:V}=gt({selection:O,linkedHover:C,fallbackFields:v?["string"==typeof v?v:""]:[],onObservation:j,chartType:"AreaChart",chartId:_}),Q=void 0!==(null===(o=q[0])||void 0===o?void 0:o[m]),U=e.useMemo(()=>{if(Q)return q;if(g){const e=q.reduce((e,t)=>{const n="function"==typeof g?g(t):t[g];if(!e[n]){const t={[m]:[]};"string"==typeof g&&(t[g]=n),e[n]=t}return e[n][m].push(t),e},{});return Object.values(e)}return[{[m]:q}]},[q,g,m,Q]),K=ft(q,v,b),Z=e.useMemo(()=>{if(!v)return[];const e=new Set;for(const t of q){const n="function"==typeof v?v(t):t[v];null!=n&&e.add(n+"")}return Array.from(e)},[q,v]),J=yt(N,v,Z),ee=e.useMemo(()=>J.legendSelectionHook?J.legendSelectionHook:X,[J.legendSelectionHook,X]),te=e.useMemo(()=>e=>{const t={};if(v){if(K){const n=P(e,v,K);t.fill=n,w?(t.stroke=n,t.strokeWidth=A):t.stroke="none"}}else t.fill=ht,w?(t.stroke=ht,t.strokeWidth=A):t.stroke="none";return t.fillOpacity=k,t},[v,K,k,w,A]),ne=e.useMemo(()=>ut(te,ee,O),[te,ee,O]),{legend:oe,margin:ie,legendPosition:re}=pt({data:U,colorBy:v,colorScale:K,showLegend:I,legendPosition:H,userMargin:s,defaults:r.marginDefaults}),le=g||v,se=e.useMemo(()=>Ot([{label:D||Mt(h),accessor:h,role:"x"},{label:R||Mt(f),accessor:f,role:"y"},...le?[{label:Mt(le),accessor:le,role:"group"}]:[]]),[h,f,D,R,le]),ae=It({componentName:"AreaChart",data:l,accessors:{xAccessor:h,yAccessor:f}});if(ae)return d.createElement(Ct,{componentName:"AreaChart",message:ae,width:W,height:z});const ce=e.useMemo(()=>Q||g?U.flatMap(e=>{const t=e[m]||[];return g&&"string"==typeof g?t.map(t=>Object.assign(Object.assign({},t),{[g]:e[g]})):t}):q,[U,m,Q,g,q]),ue=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:ce}),{xAccessor:h,yAccessor:f,groupAccessor:g||void 0}),p&&{y0Accessor:p}),y&&{gradientFill:y}),{curve:x,lineStyle:ne,size:[W,z],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:ie,showAxes:r.showAxes,xLabel:D,yLabel:R,xFormat:c,yFormat:u,enableHover:T,showGrid:F}),oe&&{legend:oe,legendPosition:re}),N&&"none"!==N&&{legendHoverBehavior:J.onLegendHover,legendClickBehavior:J.onLegendClick,legendHighlightedCategory:J.highlightedCategory,legendIsolatedCategories:J.isolatedCategories}),$&&{title:$}),a&&{className:a}),{tooltipContent:!1===M?()=>null:At(M)||se}),(C||j)&&{customHoverBehavior:V}),S&&S.length>0&&{annotations:S}),E);return d.createElement(Lt,{componentName:"AreaChart",width:W,height:z},d.createElement(qe,Object.assign({ref:i},ue)))});Yt.displayName="AreaChart";const qt=e.forwardRef(function(t,n){var o;const i=e.useRef(null),r=vt(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:l,margin:s,className:a,xFormat:c,yFormat:u,xAccessor:h="x",yAccessor:f="y",areaBy:g,lineDataAccessor:p="coordinates",colorBy:y,colorScheme:m="category10",curve:v="monotoneX",areaOpacity:b=.7,showLine:x=!0,lineWidth:k=2,normalize:w=!1,tooltip:A,annotations:M,frameProps:S={},selection:E,linkedHover:O,onObservation:j,chartId:_,loading:L,emptyContent:B,legendInteraction:N,legendPosition:H}=t,W=r.width,z=r.height,T=r.enableHover,F=r.showGrid,I=r.showLegend,$=r.title,D=r.xLabel,R=r.yLabel,G=Wt(L,W,z);if(G)return G;const Y=Ht(l,W,z,B);if(Y)return Y;const q=l||[],X=function({isPushMode:t,colorBy:n,colorScheme:o,showLegend:i,legendPosition:r="right"}){const l=e.useRef(new Set),s=e.useRef([]),[a,c]=e.useState(0),u=e.useCallback(e=>{if(!n)return null;const t="function"==typeof n?n(e):e[n];return null!=t?t+"":null},[n]),h=e.useCallback(e=>{if(!t||!n)return;let o=!1;for(const t of e){if(!t||"object"!=typeof t)continue;const e=u(t);null==e||l.current.has(e)||(l.current.add(e),s.current.push(e),o=!0)}o&&c(e=>e+1)},[t,n,u]),d=e.useCallback(e=>t=>{h([t]),e(t)},[h]),f=e.useCallback(e=>t=>{h(t),e(t)},[h]),g=e.useCallback(()=>{l.current=new Set,s.current=[],c(e=>e+1)},[]),p=e.useMemo(()=>{if(!t||!n||!1===i)return;const e=s.current;if(0===e.length)return;const r=Array.isArray(o)?o:C,l=new Map;for(let t=0;e.length>t;t++)l.set(e[t],r[t%r.length]);const a="string"==typeof n?n:"__streamCat";return at({data:e.map(e=>({[a]:e})),colorBy:a,colorScale:e=>l.get(e)||"#999",getColor:P})},[t,n,i,o,a]),y=e.useMemo(()=>{if(p)return"right"===r?{right:110}:"left"===r?{left:110}:"top"===r?{top:50}:"bottom"===r?{bottom:80}:{right:110}},[p,r]);return{wrapPush:d,wrapPushMany:f,resetCategories:g,streamingLegend:p,streamingMarginAdjust:y}}({isPushMode:void 0===l,colorBy:y||g,colorScheme:m,showLegend:I,legendPosition:H}),V=e.useCallback(X.wrapPush(e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.push(e)}),[X.wrapPush]),Q=e.useCallback(X.wrapPushMany(e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.pushMany(e)}),[X.wrapPushMany]);e.useImperativeHandle(n,()=>({push:V,pushMany:Q,clear:()=>{var e;X.resetCategories(),null===(e=i.current)||void 0===e||e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=i.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}),[V,Q,X.resetCategories]);const{activeSelectionHook:U,customHoverBehavior:K}=gt({selection:E,linkedHover:O,fallbackFields:y?["string"==typeof y?y:""]:[],onObservation:j,chartType:"StackedAreaChart",chartId:_}),Z=void 0!==(null===(o=q[0])||void 0===o?void 0:o[p]),J=e.useMemo(()=>{if(Z)return q;if(g){const e=q.reduce((e,t)=>{const n="function"==typeof g?g(t):t[g];if(!e[n]){const t={[p]:[]};"string"==typeof g&&(t[g]=n),e[n]=t}return e[n][p].push(t),e},{});return Object.values(e)}return[{[p]:q}]},[q,g,p,Z]),ee=ft(q,y,m),te=e.useMemo(()=>{if(!y)return[];const e=new Set;for(const t of q){const n="function"==typeof y?y(t):t[y];null!=n&&e.add(n+"")}return Array.from(e)},[q,y]),ne=yt(N,y,te),oe=e.useMemo(()=>ne.legendSelectionHook?ne.legendSelectionHook:U,[ne.legendSelectionHook,U]),ie=e.useMemo(()=>e=>{const t={};if(y&&ee){const n=P(e,y,ee);t.fill=n,x?(t.stroke=n,t.strokeWidth=k):t.stroke="none"}else y||(t.fill=ht,t.stroke=x?ht:"none",x&&(t.strokeWidth=k));return t.fillOpacity=b,t},[y,ee,b,x,k]),re=e.useMemo(()=>ut(ie,oe,E),[ie,oe,E]),{legend:le,margin:se,legendPosition:ae}=pt({data:J,colorBy:y,colorScale:ee,showLegend:I,legendPosition:H,userMargin:s,defaults:r.marginDefaults}),ce=X.streamingLegend||le,ue=H||ae,he=e.useMemo(()=>{if(X.streamingMarginAdjust){const e=Object.assign({},se);for(const[t,n]of Object.entries(X.streamingMarginAdjust))n>e[t]&&(e[t]=n);return e}return se},[se,X.streamingMarginAdjust]),de=g||y,fe=e.useMemo(()=>Ot([{label:D||Mt(h),accessor:h,role:"x"},{label:R||Mt(f),accessor:f,role:"y"},...de?[{label:Mt(de),accessor:de,role:"group"}]:[]]),[h,f,D,R,de]),ge=It({componentName:"StackedAreaChart",data:l,accessors:{xAccessor:h,yAccessor:f}});if(ge)return d.createElement(Ct,{componentName:"StackedAreaChart",message:ge,width:W,height:z});const pe=e.useMemo(()=>Z||g?J.flatMap(e=>{const t=e[p]||[];return g&&"string"==typeof g?t.map(t=>Object.assign(Object.assign({},t),{[g]:e[g]})):t}):q,[J,p,Z,g,q]),ye=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"stackedarea"},null!=l&&{data:pe}),{xAccessor:h,yAccessor:f,groupAccessor:g||void 0,curve:v,normalize:w,lineStyle:re,size:[W,z],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:he,showAxes:r.showAxes,xLabel:D,yLabel:R,xFormat:c,yFormat:u,enableHover:T,showGrid:F}),ce&&{legend:ce,legendPosition:ue}),N&&"none"!==N&&{legendHoverBehavior:ne.onLegendHover,legendClickBehavior:ne.onLegendClick,legendHighlightedCategory:ne.highlightedCategory,legendIsolatedCategories:ne.isolatedCategories}),$&&{title:$}),a&&{className:a}),{tooltipContent:!1===A?()=>null:At(A)||fe}),(O||j)&&{customHoverBehavior:K}),M&&M.length>0&&{annotations:M}),S);return d.createElement(Lt,{componentName:"StackedAreaChart",width:W,height:z},d.createElement(qe,Object.assign({ref:i},ye)))});qt.displayName="StackedAreaChart";const Xt=e.forwardRef(function(t,n){const o=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=o.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=o.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const i=vt(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:r,margin:l,className:s,xFormat:a,yFormat:c,xAccessor:u="x",yAccessor:h="y",colorBy:f,colorScheme:g="category10",sizeBy:p,sizeRange:y=[3,15],pointRadius:m=5,pointOpacity:v=.8,tooltip:b,marginalGraphics:x,pointIdAccessor:k,annotations:w,frameProps:A={},selection:M,linkedHover:S,linkedBrush:E,onObservation:O,chartId:C,loading:j,emptyContent:_,legendInteraction:B,legendPosition:N}=t,H=i.width,W=i.height,z=i.enableHover,T=i.showGrid,F=i.title,I=i.xLabel,$=i.yLabel,D=r||[],R=function(t){const{data:n,rawData:o,colorBy:i,colorScheme:r,legendInteraction:l,legendPosition:s,selection:a,linkedHover:c,fallbackFields:u,unwrapData:h=!1,onObservation:d,chartType:f,chartId:g,showLegend:p,userMargin:y,marginDefaults:m,loading:v,emptyContent:b,width:x,height:k}=t,{activeSelectionHook:w,customHoverBehavior:A,customClickBehavior:M}=gt({selection:a,linkedHover:c,fallbackFields:u,unwrapData:h,onObservation:d,chartType:f,chartId:g}),S=ft(n,i,r),E=e.useMemo(()=>{if(!i)return[];const e=new Set;for(const t of n){const n="function"==typeof i?i(t):t[i];null!=n&&e.add(n+"")}return Array.from(e)},[n,i]),O=yt(l,i,E),C=e.useMemo(()=>O.legendSelectionHook?O.legendSelectionHook:w,[O.legendSelectionHook,w]),{legend:j,margin:P,legendPosition:_}=pt({data:n,colorBy:i,colorScale:S,showLegend:p,legendPosition:s,userMargin:y,defaults:m}),L=e.useMemo(()=>{const e={};return j&&(e.legend=j,e.legendPosition=_),l&&"none"!==l&&(e.legendHoverBehavior=O.onLegendHover,e.legendClickBehavior=O.onLegendClick,e.legendHighlightedCategory=O.highlightedCategory,e.legendIsolatedCategories=O.isolatedCategories),e},[j,_,l,O.onLegendHover,O.onLegendClick,O.highlightedCategory,O.isolatedCategories]),B=Wt(v,x,k),N=B?null:Ht(o,x,k,b);return{colorScale:S,allCategories:E,legendState:O,effectiveSelectionHook:C,activeSelectionHook:w,customHoverBehavior:A,customClickBehavior:M,legend:j,margin:P,legendPosition:_,earlyReturn:B||N||null,legendBehaviorProps:L}}({data:D,rawData:r,colorBy:f,colorScheme:g,legendInteraction:B,legendPosition:N,selection:M,linkedHover:S,fallbackFields:f?["string"==typeof f?f:""]:[],unwrapData:!1,onObservation:O,chartType:"Scatterplot",chartId:C,showLegend:i.showLegend,userMargin:l,marginDefaults:i.marginDefaults,loading:j,emptyContent:_,width:H,height:W}),G=ct(E),Y=ot({name:(null==G?void 0:G.name)||"__unused_brush__",xField:(null==G?void 0:G.xField)||("string"==typeof u?u:void 0),yField:(null==G?void 0:G.yField)||("string"==typeof h?h:void 0)}),q=G?"xyBrush"===Y.brushInteraction.brush?"xy":"xBrush"===Y.brushInteraction.brush?"x":"y":void 0,X=d.useRef(Y.brushInteraction);X.current=Y.brushInteraction;const V=e.useCallback(e=>{const t=X.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(R.earlyReturn)return R.earlyReturn;zt("Scatterplot",D,"xAccessor",u),zt("Scatterplot",D,"yAccessor",h);const Q=e.useMemo(()=>{if(!p||0===D.length)return;const e=D.map(e=>"function"==typeof p?p(e):e[p]);return[Math.min(...e),Math.max(...e)]},[D,p]),U=e.useMemo(()=>e=>{const t={fillOpacity:v};return f?R.colorScale&&(t.fill=P(e,f,R.colorScale)):t.fill=ht,t.r=p?L(e,p,y,Q):m,t},[f,R.colorScale,p,y,Q,m,v]),K=e.useMemo(()=>ut(U,R.effectiveSelectionHook,M),[U,R.effectiveSelectionHook,M]),Z=e.useMemo(()=>Ot([{label:I||Mt(u),accessor:u,role:"x"},{label:$||Mt(h),accessor:h,role:"y"},...f?[{label:Mt(f),accessor:f,role:"color"}]:[],...p?[{label:Mt(p),accessor:p,role:"size"}]:[]]),[u,h,I,$,f,p]),J=It({componentName:"Scatterplot",data:r,accessors:{xAccessor:u,yAccessor:h}});if(J)return d.createElement(Ct,{componentName:"Scatterplot",message:J,width:H,height:W});const ee=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!=r&&{data:D}),{xAccessor:u,yAccessor:h,colorAccessor:f||void 0,sizeAccessor:p||void 0,sizeRange:y,pointStyle:K,colorScheme:g,size:[H,W],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:R.margin,showAxes:i.showAxes,xLabel:I,yLabel:$,xFormat:a,yFormat:c,enableHover:z,showGrid:T}),R.legendBehaviorProps),F&&{title:F}),s&&{className:s}),{tooltipContent:!1===b?()=>null:At(b)||Z}),(S||O)&&{customHoverBehavior:R.customHoverBehavior}),x&&{marginalGraphics:x}),k&&{pointIdAccessor:k}),w&&w.length>0&&{annotations:w}),G&&{brush:{dimension:q},onBrush:V}),A);return d.createElement(Lt,{componentName:"Scatterplot",width:H,height:W},d.createElement(qe,Object.assign({ref:o},ee)))});function Vt(e,t){return i.interpolateViridis(1===t?.5:e/(t-1))}Xt.displayName="Scatterplot";const Qt=e.forwardRef(function(t,n){const o=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=o.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=o.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const i=vt(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:r,className:l,xFormat:s,yFormat:a,xAccessor:c="x",yAccessor:u="y",orderAccessor:h,orderLabel:f,pointRadius:g=4,tooltip:p,pointIdAccessor:y,annotations:m,frameProps:v={},selection:b,linkedHover:x,onObservation:k,chartId:w,loading:A,emptyContent:M,legendInteraction:S}=t,E=i.width,O=i.height,C=i.enableHover,j=i.showGrid,P=i.title,_=i.xLabel,L=i.yLabel,B=r||[],N=e.useMemo(()=>{if(!h||0===B.length)return B;const e="function"==typeof h?h:e=>e[h];return[...B].sort((t,n)=>{const o=e(t),i=e(n);return(o instanceof Date?o.getTime():+o)-(i instanceof Date?i.getTime():+i)})},[B,h]);zt("ConnectedScatterplot",N,"xAccessor",c),zt("ConnectedScatterplot",N,"yAccessor",u);const{activeSelectionHook:H,customHoverBehavior:W}=gt({selection:b,linkedHover:x,fallbackFields:[],onObservation:k,chartType:"ConnectedScatterplot",chartId:w}),z=yt(S,void 0,[]),T=e.useMemo(()=>z.legendSelectionHook?z.legendSelectionHook:H,[z.legendSelectionHook,H]),F=e.useMemo(()=>(e,t)=>{var n,o;const i=t.filter(e=>"point"===e.type);if(2>i.length)return;const r=null==T?void 0:T.isActive,l=null==T?void 0:T.predicate,s=100>i.length,a=i.length;e.lineCap="round";for(let t=0;a-1>t;t++){const c=i[t],u=i[t+1],h=Vt(t,a),d=!r||!l||l(null!==(n=c.datum)&&void 0!==n?n:c)||l(null!==(o=u.datum)&&void 0!==o?o:u),f=r?d?1:.2:1;s&&(e.beginPath(),e.moveTo(c.x,c.y),e.lineTo(u.x,u.y),e.strokeStyle="white",e.lineWidth=g+2,e.globalAlpha=.5*f,e.stroke()),e.beginPath(),e.moveTo(c.x,c.y),e.lineTo(u.x,u.y),e.strokeStyle=h,e.lineWidth=g,e.globalAlpha=f,e.stroke()}e.globalAlpha=1},[g,T]),I=e.useMemo(()=>[F],[F]),$=e.useRef({idx:0,total:0}),D=e.useMemo(()=>{const e="function"==typeof c?c:e=>e[c],t="function"==typeof u?u:e=>e[u];return n=>{var i,r;const l=$.current;if(0===l.idx){const n=null!==(r=null===(i=o.current)||void 0===i?void 0:i.getData())&&void 0!==r?r:N;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?Vt(a,s):"#6366f1",stroke:"white",strokeWidth:1,r:g,fillOpacity:1}}},[g,N.length,c,u]),R=e.useMemo(()=>ut(D,T,b),[D,T,b]),G=Object.assign({top:50,right:40,bottom:60,left:70},t.margin),Y=f||("string"==typeof h?h:"Order"),q=e.useMemo(()=>Ot([{label:_||Mt(c),accessor:c,role:"x"},{label:L||Mt(u),accessor:u,role:"y"},...h?[{label:Y,accessor:h,role:"group"}]:[]]),[c,u,_,L,h,Y]),X=It({componentName:"ConnectedScatterplot",data:r,accessors:{xAccessor:c,yAccessor:u}}),V=Wt(A,E,O);if(V)return V;const Q=Ht(r,E,O,M);if(Q)return Q;if(X)return d.createElement(Ct,{componentName:"ConnectedScatterplot",message:X,width:E,height:O});const U=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter"},null!=r&&{data:N}),{xAccessor:c,yAccessor:u,pointStyle:R,size:[E,O],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:G,showAxes:i.showAxes,xLabel:_,yLabel:L,xFormat:s,yFormat:a,enableHover:C,showGrid:j}),P&&{title:P}),l&&{className:l}),{tooltipContent:!1===p?()=>null:At(p)||q}),(x||k)&&{customHoverBehavior:W}),y&&{pointIdAccessor:y}),{canvasPreRenderers:I}),m&&m.length>0&&{annotations:m}),v);return d.createElement(Lt,{componentName:"ConnectedScatterplot",width:E,height:O},d.createElement(qe,Object.assign({ref:o},U)))});Qt.displayName="ConnectedScatterplot";const Ut=e.forwardRef(function(t,n){const o=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=o.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=o.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const i=vt(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:r,margin:l,className:s,xFormat:a,yFormat:c,xAccessor:u="x",yAccessor:h="y",sizeBy:f,sizeRange:g=[5,40],colorBy:p,colorScheme:y="category10",bubbleOpacity:m=.6,bubbleStrokeWidth:v=1,bubbleStrokeColor:b="white",tooltip:x,marginalGraphics:k,pointIdAccessor:w,annotations:A,frameProps:M={},selection:S,linkedHover:E,linkedBrush:O,onObservation:C,chartId:j,loading:_,emptyContent:B,legendInteraction:N,legendPosition:H}=t,W=i.width,z=i.height,T=i.enableHover,F=i.showGrid,I=i.showLegend,$=i.title,D=i.xLabel,R=i.yLabel,G=Wt(_,W,z);if(G)return G;const Y=Ht(r,W,z,B);if(Y)return Y;const q=r||[],{activeSelectionHook:X,customHoverBehavior:V}=gt({selection:S,linkedHover:E,fallbackFields:p?["string"==typeof p?p:""]:[],onObservation:C,chartType:"BubbleChart",chartId:j}),Q=ct(O);ot({name:(null==Q?void 0:Q.name)||"__unused_brush__",xField:(null==Q?void 0:Q.xField)||("string"==typeof u?u:void 0),yField:(null==Q?void 0:Q.yField)||("string"==typeof h?h:void 0)});const U=ft(q,p,y),K=e.useMemo(()=>{if(!p)return[];const e=new Set;for(const t of q){const n="function"==typeof p?p(t):t[p];null!=n&&e.add(n+"")}return Array.from(e)},[q,p]),Z=yt(N,p,K),J=e.useMemo(()=>Z.legendSelectionHook?Z.legendSelectionHook:X,[Z.legendSelectionHook,X]),ee=e.useMemo(()=>{const e=q.map(e=>"function"==typeof f?f(e):e[f]);return[Math.min(...e),Math.max(...e)]},[q,f]),te=e.useMemo(()=>e=>{const t={fillOpacity:m,strokeWidth:v,stroke:b};return p?U&&(t.fill=P(e,p,U)):t.fill=ht,t.r=L(e,f,g,ee),t},[p,U,f,g,ee,m,v,b]),ne=e.useMemo(()=>ut(te,J,S),[te,J,S]),{legend:oe,margin:ie,legendPosition:re}=pt({data:q,colorBy:p,colorScale:U,showLegend:I,legendPosition:H,userMargin:l,defaults:i.marginDefaults}),le=e.useMemo(()=>Ot([{label:D||Mt(u),accessor:u,role:"x"},{label:R||Mt(h),accessor:h,role:"y"},{label:Mt(f),accessor:f,role:"size"},...p?[{label:Mt(p),accessor:p,role:"color"}]:[]]),[u,h,D,R,f,p]),se=It({componentName:"BubbleChart",data:r,accessors:{xAccessor:u,yAccessor:h},requiredProps:{sizeBy:f}});if(se)return d.createElement(Ct,{componentName:"BubbleChart",message:se,width:W,height:z});const ae=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!=r&&{data:q}),{xAccessor:u,yAccessor:h,colorAccessor:p||void 0,sizeAccessor:f,sizeRange:g,pointStyle:ne,colorScheme:y,size:[W,z],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:ie,showAxes:i.showAxes,xLabel:D,yLabel:R,xFormat:a,yFormat:c,enableHover:T,showGrid:F}),oe&&{legend:oe,legendPosition:re}),N&&"none"!==N&&{legendHoverBehavior:Z.onLegendHover,legendClickBehavior:Z.onLegendClick,legendHighlightedCategory:Z.highlightedCategory,legendIsolatedCategories:Z.isolatedCategories}),$&&{title:$}),s&&{className:s}),{tooltipContent:!1===x?()=>null:At(x)||le}),(E||C)&&{customHoverBehavior:V}),k&&{marginalGraphics:k}),w&&{pointIdAccessor:w}),A&&A.length>0&&{annotations:A}),M);return d.createElement(Lt,{componentName:"BubbleChart",width:W,height:z},d.createElement(qe,Object.assign({ref:o},ae)))});Ut.displayName="BubbleChart";const Kt=e.forwardRef(function(t,n){const r=e.useRef(null);e.useImperativeHandle(n,()=>({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=vt(t.mode,{width:t.width,height:t.height,showGrid:void 0,enableHover:t.enableHover,showLegend:void 0,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:s,margin:a,className:c,xAccessor:u="x",yAccessor:h="y",valueAccessor:f="value",xFormat:g,yFormat:p,colorScheme:y="blues",customColorScale:m,showValues:v=!1,valueFormat:b,cellBorderColor:x="#fff",cellBorderWidth:k=1,tooltip:w,annotations:A,frameProps:M={},selection:S,linkedHover:E,onObservation:O,chartId:C,loading:j,emptyContent:P,showLegend:_,legendPosition:L,legendInteraction:B}=t,N=l.width,H=l.height,W=l.enableHover,z=l.title,T=l.xLabel,F=l.yLabel,I=Wt(j,N,H);if(I)return I;const $=Ht(s,N,H,P);if($)return $;const D=s||[],R=null!=_&&_,G=null!=L?L:"right",{margin:Y}=pt({data:D,colorBy:R?"value":void 0,colorScale:void 0,showLegend:R,legendPosition:G,userMargin:a,defaults:l.marginDefaults}),{activeSelectionHook:q,customHoverBehavior:X}=gt({selection:S,linkedHover:E,fallbackFields:[],onObservation:O,chartType:"Heatmap",chartId:C}),V=yt(B,void 0,[]),Q=e.useMemo(()=>V.legendSelectionHook?V.legendSelectionHook:q,[V.legendSelectionHook,q]),U=e.useMemo(()=>"function"==typeof f?e=>f(e):e=>e[f],[f]),K=e.useMemo(()=>{const e=D.map(U);return[Math.min(...e),Math.max(...e)]},[D,U]),Z=e.useMemo(()=>"custom"===y&&m?m:o.scaleSequential({blues:i.interpolateBlues,reds:i.interpolateReds,greens:i.interpolateGreens,viridis:i.interpolateViridis}[y]||i.interpolateBlues).domain(K),[y,m,K]);e.useMemo(()=>{const e=dt(u),t=dt(h);return{xBinCount:new Set(D.map(e)).size,yBinCount:new Set(D.map(t)).size}},[D,u,h]),e.useMemo(()=>({coordinates:D}),[D]);const J=e.useMemo(()=>e=>{const t=U(e);return{fill:Z(t),stroke:x,strokeWidth:k}},[U,Z,x,k]);e.useMemo(()=>ut(J,Q,S),[J,Q,S]);const ee=e.useMemo(()=>Ot([{label:T||Mt(u),accessor:u,role:"x"},{label:F||Mt(h),accessor:h,role:"y"},{label:Mt(f),accessor:f,role:"value"}]),[u,h,T,F,f]),te=It({componentName:"Heatmap",data:s,accessors:{xAccessor:u,yAccessor:h,valueAccessor:f}});if(te)return d.createElement(Ct,{componentName:"Heatmap",message:te,width:N,height:H});const ne=e.useMemo(()=>{if(R)return{gradient:{colorFn:e=>Z(e),domain:K,label:"string"==typeof f?f:"value",format:b}}},[R,Z,K,f,b]),oe=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"heatmap"},null!=s&&{data:D}),{xAccessor:u,yAccessor:h,valueAccessor:f,colorScheme:"custom"!==y?y:void 0,showValues:v,heatmapValueFormat:b,size:[N,H],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Y,showAxes:l.showAxes,xLabel:T,yLabel:F,xFormat:g,yFormat:p,enableHover:W}),ne&&{legend:ne,legendPosition:G}),z&&{title:z}),c&&{className:c}),{tooltipContent:!1===w?()=>null:At(w)||ee}),(E||O)&&{customHoverBehavior:X}),A&&A.length>0&&{annotations:A}),M);return d.createElement(Lt,{componentName:"Heatmap",width:N,height:H},d.createElement(qe,Object.assign({ref:r},oe)))});Kt.displayName="Heatmap";const Zt="__splomIdx",Jt={top:4,bottom:4,left:4,right:4};function en({frameRef:o,cellSize:i,onBrush:r}){const l=e.useRef(null),s=i-Jt.left-Jt.right,a=i-Jt.top-Jt.bottom;return e.useEffect(()=>{if(!l.current)return;const e=n.select(l.current).select(".brush-g"),i=t.brush().extent([[0,0],[s,a]]).on("brush end",e=>{var t;const n=null===(t=o.current)||void 0===t?void 0:t.getScales();if(!n)return;if(!e.selection)return void r(null);const[[i,l],[s,a]]=e.selection,c=[[n.x.invert(i),n.y.invert(l)],[n.x.invert(s),n.y.invert(a)]];r(c)});return e.call(i),e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{i.on("brush end",null)}},[s,a,o,r]),d.createElement("svg",{ref:l,width:i,height:i,style:{position:"absolute",top:0,left:0}},d.createElement("g",{className:"brush-g",transform:`translate(${Jt.left},${Jt.top})`}))}function tn({data:t,xField:n,yField:o,cellSize:i,pointRadius:r,pointOpacity:l,colorBy:s,colorScale:a,brushSelectionName:c,hoverSelectionName:u,unselectedOpacity:h,mode:f,onPointHover:g}){const p=e.useRef(null),y=tt({name:c,clientId:`splom-${n}-${o}`}),m=ot({name:c,xField:n,yField:o}),v=tt({name:u,clientId:"splom-hover-source"}),b=v.selectPoints,x=e.useCallback(e=>{e?m.brushInteraction.during(e):m.brushInteraction.end(null)},[m.brushInteraction]),k=e.useCallback(e=>{if(!e)return void(null==g||g(null));const t=e.data,n=null==t?void 0:t[Zt];void 0!==n&&(b({[Zt]:[n]}),null==g||g(t,e.x+Jt.left,e.y+Jt.top))},[b,g]),w=e.useCallback(e=>{const t={opacity:l,r:r};return t.fill=s?P(e,s,a):ht,"hover"===f?v.isActive&&v.predicate(e)?(t.opacity=1,t.r=2.5*r,t.stroke="#333",t.strokeWidth=1.5):v.isActive&&(t.opacity=.6*l):y.isActive&&!y.predicate(e)&&(t.opacity=h),t},[s,a,l,r,f,y.isActive,y.predicate,v.isActive,v.predicate,h]);return d.createElement("div",{style:{position:"relative",width:i,height:i}},d.createElement(qe,{ref:p,chartType:"scatter",data:t,size:[i,i],xAccessor:n,yAccessor:o,pointStyle:w,margin:Jt,showAxes:!1,enableHover:"hover"===f,customHoverBehavior:"hover"===f?k:void 0,tooltipContent:"hover"===f?()=>null:void 0}),"brush"===f&&d.createElement(en,{frameRef:p,cellSize:i,xField:n,yField:o,onBrush:x}))}function nn({data:t,field:n,label:o,cellSize:i,bins:r,colorBy:l,colorScale:s,brushSelectionName:a,hoverSelectionName:c,mode:u}){const h=tt({name:a,clientId:"splom-diag-"+n}),f=tt({name:c,clientId:`splom-diag-${n}-hover`}),g="hover"===u?f:h,p=g.isActive,y=g.predicate,m=e.useMemo(()=>{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),s=(Math.max(...e)-o)/r||1,a="string"==typeof l?l:null,c=a?[...new Set(t.map(e=>e[a]).filter(e=>null!=e).map(String))]:[],u=new Map(c.map((e,t)=>[e,t])),h=Array(r).fill(0),d=Array(r).fill(0),f=Array.from({length:r},()=>Array(c.length).fill(0)),g=Array.from({length:r},()=>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)/s),r-1);if(h[i]++,p&&!y(e)||d[i]++,a){const t=u.get(e[a]+"");void 0!==t&&(f[i][t]++,p&&!y(e)||g[i][t]++)}}const m=Math.max(...h,1),v=f.map((e,t)=>{let n=0;return e.map((e,o)=>{const l=e/m*(i-24),s={x:t/r*i,w:i/r-1,h:l,y0:n,category:c[o]};return n+=l,s})}),b=g.map((e,t)=>{let n=0;return e.map((e,o)=>{const l=e/m*(i-24),s={x:t/r*i,w:i/r-1,h:l,y0:n,category:c[o]};return n+=l,s})});return{bars:h.map((e,t)=>({x:t/r*i,w:i/r-1,h:e/m*(i-24),count:e})),selectedBars:d.map((e,t)=>({x:t/r*i,w:i/r-1,h:e/m*(i-24),count:e})),categoryBars:v,selectedCategoryBars:b,max:m,categories:c}},[t,n,r,i,p,y,l]);return d.createElement("svg",{width:i,height:i,style:{overflow:"hidden"}},d.createElement("text",{x:i/2,y:14,textAnchor:"middle",fontSize:11,fontWeight:"bold",fill:"#333"},o),m.categories.length>0?m.categoryBars.map((e,t)=>e.map((e,n)=>d.createElement("rect",{key:`bg-${t}-${n}`,x:e.x,y:i-e.y0-e.h,width:Math.max(e.w,1),height:e.h,fill:s?s(e.category):ht,opacity:p?.3:.6}))):m.bars.map((e,t)=>d.createElement("rect",{key:"bg-"+t,x:e.x,y:i-e.h,width:Math.max(e.w,1),height:e.h,fill:ht,opacity:p?.3:.6})),p&&(m.categories.length>0?m.selectedCategoryBars.map((e,t)=>e.map((e,n)=>d.createElement("rect",{key:`sel-${t}-${n}`,x:e.x,y:i-e.y0-e.h,width:Math.max(e.w,1),height:e.h,fill:s?s(e.category):ht,opacity:.7}))):m.selectedBars.map((e,t)=>d.createElement("rect",{key:"sel-"+t,x:e.x,y:i-e.h,width:Math.max(e.w,1),height:e.h,fill:ht,opacity:.7}))))}function on({label:e,cellSize:t}){return d.createElement("svg",{width:t,height:t},d.createElement("text",{x:t/2,y:t/2,textAnchor:"middle",dominantBaseline:"middle",fontSize:12,fontWeight:"bold",fill:"#333"},e))}function rn(t){const{data:n,fields:o,fieldLabels:i={},colorBy:r,colorScheme:l="category10",cellSize:s=150,cellGap:a=4,pointRadius:c=2,pointOpacity:u=.5,diagonal:h="histogram",histogramBins:f=20,brushMode:g="crossfilter",hoverMode:p=!0,unselectedOpacity:y=.1,showGrid:m=!1,tooltip:v,showLegend:b,idAccessor:x,className:k,onObservation:w,chartId:A}=t,M="splom",S="splom-hover",E=p?"hover":g?"brush":"hover",O=Ze(e=>e.clearSelection),[C,j]=e.useState(null),P=e.useCallback(()=>{O(S),j(null)},[O,S]),_=e.useMemo(()=>(n||[]).map((e,t)=>void 0!==e[Zt]?e:Object.assign(Object.assign({},e),{[Zt]:t})),[n]),L=ft(_,r,l),B=void 0!==b?b:!!r,N=e.useMemo(()=>{if(!B||!r)return null;const e="string"==typeof r?r:null;return e?[...new Set(_.map(t=>t[e]))].map(e=>({label:e+"",color:L?L(e+""):ht})):null},[B,r,_,L]),H=e.useMemo(()=>({display:"grid",gridTemplateColumns:"40px "+o.map(()=>s+"px").join(" "),gridTemplateRows:o.map(()=>s+"px").join(" ")+" 40px",gap:a+"px",width:"fit-content"}),[o,s,a,40]);return d.createElement("div",{className:k,style:{position:"relative"}},N&&d.createElement("div",{style:{display:"flex",gap:12,marginBottom:8,flexWrap:"wrap"}},N.map(e=>d.createElement("div",{key:e.label,style:{display:"flex",alignItems:"center",gap:4}},d.createElement("span",{style:{display:"inline-block",width:10,height:10,borderRadius:"50%",backgroundColor:e.color}}),d.createElement("span",{style:{fontSize:11}},e.label)))),d.createElement("div",{style:H,onMouseLeave:"hover"===E?P:void 0},o.map((e,t)=>d.createElement(d.Fragment,{key:"row-"+e},d.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",writingMode:"vertical-rl",transform:"rotate(180deg)",fontSize:11,fontWeight:"bold",color:"#333"}},i[e]||e),o.map((n,o)=>t===o?"label"===h?d.createElement(on,{key:"diag-"+e,label:i[e]||e,cellSize:s}):d.createElement(nn,{key:"diag-"+e,data:_,field:e,label:i[e]||e,cellSize:s,bins:f,colorBy:r,colorScale:L,brushSelectionName:M,hoverSelectionName:S,unselectedOpacity:y,mode:E}):d.createElement(tn,{key:`cell-${e}-${n}`,data:_,xField:n,yField:e,fieldLabels:i,cellSize:s,pointRadius:c,pointOpacity:u,colorBy:r,colorScale:L,brushSelectionName:M,hoverSelectionName:S,unselectedOpacity:y,showGrid:m,tooltip:v,mode:E,onPointHover:"hover"===E?(i,r,l)=>{i?(j({datum:i,xField:n,yField:e,colIndex:o,rowIndex:t,px:null!=r?r:0,py:null!=l?l:0}),w&&w({type:"hover",datum:i,x:null!=r?r:0,y:null!=l?l:0,timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:A})):(j(null),w&&w({type:"hover-end",timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:A}))}:void 0})))),d.createElement("div",null)," ",o.map(e=>d.createElement("div",{key:"col-label-"+e,style:{display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:"bold",color:"#333"}},i[e]||e))),C&&"hover"===E&&(()=>{const e=C.datum,t=i[C.xField]||C.xField,n=i[C.yField]||C.yField,o=r?"function"==typeof r?r(e):e[r]:null,l=x?"function"==typeof x?x(e):e[x]:"Row "+e[Zt];return d.createElement("div",{style:{position:"absolute",left:40+C.colIndex*(s+a)+C.px,top:C.rowIndex*(s+a)+C.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}},d.createElement("div",{style:{fontWeight:"bold",marginBottom:2}},l+""),d.createElement("div",null,t,": ",null!=e[C.xField]?Number(e[C.xField]).toFixed(1):"–"),d.createElement("div",null,n,": ",null!=e[C.yField]?Number(e[C.yField]).toFixed(1):"–"),null!=o&&d.createElement("div",{style:{opacity:.8}},"string"==typeof r?r:"group",": ",o+""))})())}function ln(e){const{brushMode:t="crossfilter",hoverMode:n=!0}=e,o={};return!n&&t&&(o.splom={resolution:t}),n&&(o["splom-hover"]={resolution:"union"}),d.createElement(st,{selections:o},d.createElement(rn,Object.assign({},e)))}function sn({width:o,height:i,margin:r,scales:l,brushDirection:s,extent:a,onBrush:c}){const u=e.useRef(null),h=e.useRef(null),f=e.useRef(!1),g=o+r.left+r.right,p=i+r.top+r.bottom;return e.useEffect(()=>{if(!u.current||!l)return;const e=n.select(u.current).select(".brush-group"),r="x"===s?t.brushX().extent([[0,0],[o,i]]):t.brushY().extent([[0,0],[o,i]]);return r.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(r),h.current=r,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.2).attr("stroke","steelblue").attr("stroke-width",1),()=>{r.on("brush end",null)}},[l,o,i,s,c]),e.useEffect(()=>{if(!h.current||!l||!u.current)return;const e=n.select(u.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(h.current.move,n)}else e.call(h.current.move,null);f.current=!1},[a,l,s]),d.createElement("svg",{ref:u,width:g,height:p,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},d.createElement("g",{className:"brush-group",transform:`translate(${r.left},${r.top})`}))}function an(t){var n,o;const{data:i,width:r=600,height:l=400,margin:s,className:a,title:c,xLabel:u,yLabel:h,xFormat:f,yFormat:g,xAccessor:p="x",yAccessor:y="y",lineBy:m,lineDataAccessor:v="coordinates",colorBy:b,colorScheme:x="category10",curve:k="linear",lineWidth:w=2,fillArea:A=!1,areaOpacity:M=.3,showPoints:S=!1,pointRadius:E=3,enableHover:O=!0,showGrid:C=!1,showLegend:j,legendPosition:_,tooltip:L,minimap:B={},renderBefore:N=!1,onBrush:H,brushExtent:W,frameProps:z={},loading:T,emptyContent:F}=t,I=Wt(T,r,l);if(I)return I;const $=Ht(i,r,l,F);if($)return $;const D=i||[],[R,G]=e.useState(null),Y=null!=W?W:R,q=e.useCallback(e=>{W||G(e),null==H||H(e)},[W,H]),X=e.useRef(null),[V,Q]=e.useState(null);e.useEffect(()=>{const e=()=>{var t,n;const o=null===(n=null===(t=X.current)||void 0===t?void 0:t.getScales)||void 0===n?void 0:n.call(t);o?Q(o):requestAnimationFrame(e)};requestAnimationFrame(e)},[i]);const U=void 0!==(null===(n=D[0])||void 0===n?void 0:n[v]),K=e.useMemo(()=>{if(U)return D;if(m){const e=D.reduce((e,t)=>{const n="function"==typeof m?m(t):t[m];if(!e[n]){const t={[v]:[]};"string"==typeof m&&(t[m]=n),e[n]=t}return e[n][v].push(t),e},{});return Object.values(e)}return[{[v]:D}]},[D,m,v,U]),Z=e.useMemo(()=>U||m?K.flatMap(e=>{const t=e[v]||[];return m&&"string"==typeof m?t.map(t=>Object.assign(Object.assign({},t),{[m]:e[m]})):t}):D,[K,v,U,m,D]),J=ft(D,b,x),ee=e.useMemo(()=>e=>{const t={strokeWidth:w};return t.stroke=b?P(e,b,J):ht,A&&(t.fill=t.stroke,t.fillOpacity=M),t},[b,J,w,A,M]),te=e.useMemo(()=>B.lineStyle?B.lineStyle:e=>{const t={strokeWidth:1};return t.stroke=b?P(e,b,J):ht,t},[b,J,B.lineStyle]),ne=e.useMemo(()=>{if(S)return e=>{const t={r:E,fillOpacity:1};return t.fill=b?P(e.parentLine||e,b,J):ht,t}},[S,E,b,J]),{legend:oe,margin:ie,legendPosition:re}=pt({data:K,colorBy:b,colorScale:J,showLegend:j,legendPosition:_,userMargin:s}),le=B.height||60,se=e.useMemo(()=>{var e,t,n,o,i,r,l,s;return{top:null!==(t=null===(e=B.margin)||void 0===e?void 0:e.top)&&void 0!==t?t:0,bottom:null!==(o=null===(n=B.margin)||void 0===n?void 0:n.bottom)&&void 0!==o?o:20,left:null!==(r=null===(i=B.margin)||void 0===i?void 0:i.left)&&void 0!==r?r:ie.left,right:null!==(s=null===(l=B.margin)||void 0===l?void 0:l.right)&&void 0!==s?s:ie.right}},[B.margin,ie]),ae=B.brushDirection||"x",ce=It({componentName:"MinimapChart",data:i,accessors:{xAccessor:p,yAccessor:y}});if(ce)return d.createElement(Ct,{componentName:"MinimapChart",message:ce,width:r,height:l});const ue=A?"area":"line",he=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:ue,data:Z,xAccessor:p,yAccessor:y,groupAccessor:m||void 0,curve:k,lineStyle:ee},S&&{pointStyle:ne}),{size:[r,l],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:ie,showAxes:!0,xLabel:u,yLabel:h,xFormat:f,yFormat:g,enableHover:O,showGrid:C}),oe&&{legend:oe,legendPosition:re}),c&&{title:c}),L&&{tooltipContent:At(L)||void 0}),Y&&{xExtent:Y}),z),de={chartType:ue,data:Z,xAccessor:p,yAccessor:y,groupAccessor:m||void 0,curve:k,lineStyle:te,size:[r,le+se.top+se.bottom],margin:se,showAxes:null!==(o=B.showAxes)&&void 0!==o&&o,background:B.background,enableHover:!1},fe=d.createElement("div",{key:"minimap",style:{position:"relative",width:r,overflow:"hidden"}},d.createElement(qe,Object.assign({ref:X},de)),d.createElement(sn,{width:r-se.left-se.right,height:le,margin:se,scales:V,brushDirection:ae,extent:Y,onBrush:q})),ge=d.createElement("div",{key:"main",style:{overflow:"hidden"}},d.createElement(qe,Object.assign({},he)));return d.createElement(Lt,{componentName:"MinimapChart",width:r,height:l},d.createElement("div",{className:"minimap-chart"+(a?" "+a:"")},N?fe:ge,N?ge:fe))}ln.displayName="ScatterplotMatrix",an.displayName="MinimapChart";const cn=e.forwardRef(function(t,n){const o=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=o.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=o.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const i=vt(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:r,margin:l,className:s,xFormat:a,yFormat:c,xAccessor:u="x",yAccessor:h="y",xCenter:f,yCenter:g,quadrants:p,centerlineStyle:y={},showQuadrantLabels:m=!0,quadrantLabelSize:v=12,colorBy:b,colorScheme:x="category10",sizeBy:k,sizeRange:w=[3,15],pointRadius:A=5,pointOpacity:M=.8,tooltip:S,pointIdAccessor:E,annotations:O,frameProps:C={},selection:j,linkedHover:_,onObservation:B,chartId:N,loading:H,emptyContent:W,legendInteraction:z,legendPosition:T}=t,F=i.width,I=i.height,$=i.enableHover,D=i.showGrid,R=i.showLegend,G=i.title,Y=i.xLabel,q=i.yLabel,X=Wt(H,F,I);if(X)return X;const V=Ht(r,F,I,W);if(V)return V;const Q=r||[];zt("QuadrantChart",Q,"xAccessor",u),zt("QuadrantChart",Q,"yAccessor",h);const{activeSelectionHook:U,customHoverBehavior:K}=gt({selection:j,linkedHover:_,fallbackFields:"string"==typeof b?[b]:[],onObservation:B,chartType:"QuadrantChart",chartId:N}),Z=ft(Q,b,x),J=e.useMemo(()=>{if(!b)return[];const e=new Set;for(const t of Q){const n="function"==typeof b?b(t):t[b];null!=n&&e.add(n+"")}return Array.from(e)},[Q,b]),ee=yt(z,b,J),te=e.useMemo(()=>ee.legendSelectionHook?ee.legendSelectionHook:U,[ee.legendSelectionHook,U]),ne=e.useMemo(()=>{if(!Q.length)return;const e="function"==typeof u?u:e=>+e[u],t="function"==typeof h?h:e=>+e[h];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!=f&&isFinite(f)&&(n>f&&(n=f),f>o&&(o=f)),null!=g&&isFinite(g)&&(i>g&&(i=g),g>r&&(r=g)),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,u,h,f,g]),oe=e.useMemo(()=>{if(!k||0===Q.length)return;const e=Q.map(e=>"function"==typeof k?k(e):e[k]).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0!==e.length?[Math.min(...e),Math.max(...e)]:void 0},[Q,k]),ie=e.useMemo(()=>"function"==typeof u?u:e=>+e[u],[u]),re=e.useMemo(()=>"function"==typeof h?h:e=>+e[h],[h]),le=e.useMemo(()=>e=>{const t={fillOpacity:M};if(b)Z&&(t.fill=P(e,b,Z));else{const n=ie(e),o=re(e),i=null!=f?n>=f:void 0,r=null!=g?o>=g:void 0;t.fill=void 0===r||void 0===i?ht:r&&i?p.topRight.color:r&&!i?p.topLeft.color:!r&&i?p.bottomRight.color:p.bottomLeft.color}return t.r=k?L(e,k,w,oe):A,t},[b,Z,k,w,oe,A,M,ie,re,f,g,p]),se=e.useMemo(()=>ut(le,te,j),[le,te,j]),{legend:ae,margin:ce,legendPosition:ue}=pt({data:Q,colorBy:b,colorScale:Z,showLegend:R,legendPosition:T,userMargin:l,defaults:i.marginDefaults}),he=e.useMemo(()=>{if(!Q.length)return;const e=new Set;"string"==typeof u&&e.add(u),"string"==typeof h&&e.add(h),"string"==typeof b&&e.add(b),"string"==typeof k&&e.add(k);const t=Q[0];for(const n of Object.keys(t))if(!n.startsWith("_")&&!e.has(n)&&"string"==typeof t[n])return n},[Q,u,h,b,k]),de=e.useMemo(()=>Ot([...he?[{label:he,accessor:he,role:"title"}]:[],{label:Y||Mt(u),accessor:u,role:"x"},{label:q||Mt(h),accessor:h,role:"y"},...b?[{label:Mt(b),accessor:b,role:"color"}]:[],...k?[{label:Mt(k),accessor:k,role:"size"}]:[]]),[he,u,h,Y,q,b,k]),fe=It({componentName:"QuadrantChart",data:r,accessors:{xAccessor:u,yAccessor:h}});if(fe)return d.createElement(Ct,{componentName:"QuadrantChart",message:fe,width:F,height:I});const ge=e.useMemo(()=>{var e;const t={stroke:y.stroke||"#999",strokeWidth:null!==(e=y.strokeWidth)&&void 0!==e?e:1,dashArray:y.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!=f?o.x(f):l/2,c=null!=g?o.y(g):s/2;if(null!=f&&!isFinite(a))return;if(null!=g&&!isFinite(c))return;const u=Math.max(0,Math.min(l,a)),h=Math.max(0,Math.min(s,c)),d=[{config:p.topLeft,x:0,y:0,w:u,h:h},{config:p.topRight,x:u,y:0,w:l-u,h:h},{config:p.bottomLeft,x:0,y:h,w:u,h:s-h},{config:p.bottomRight,x:u,y:h,w:l-u,h:s-h}];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(u,0),e.lineTo(u,s),e.stroke(),e.beginPath(),e.moveTo(0,h),e.lineTo(l,h),e.stroke(),e.setLineDash([])}]},[f,g,p,y]),pe=e.useMemo(()=>m?[...ge,(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!=f?n.x(f):i/2,s=null!=g?n.y(g):r/2;(null==f||isFinite(l))&&(null==g||isFinite(s))&&(e.font=`600 ${v}px sans-serif`,e.globalAlpha=.5,e.fillStyle=p.topLeft.color,e.textAlign="left",e.textBaseline="top",e.fillText(p.topLeft.label,8,8),e.fillStyle=p.topRight.color,e.textAlign="right",e.textBaseline="top",e.fillText(p.topRight.label,i-8,8),e.fillStyle=p.bottomLeft.color,e.textAlign="left",e.textBaseline="bottom",e.fillText(p.bottomLeft.label,8,r-8),e.fillStyle=p.bottomRight.color,e.textAlign="right",e.textBaseline="bottom",e.fillText(p.bottomRight.label,i-8,r-8),e.globalAlpha=1)}]:ge,[ge,m,v,p,f,g]),ye=e.useMemo(()=>{const e=C.canvasPreRenderers||[];return[...pe,...e]},[pe,C.canvasPreRenderers]),me=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!=r&&{data:Q}),{xAccessor:u,yAccessor:h,colorAccessor:b||void 0,sizeAccessor:k||void 0,sizeRange:w,pointStyle:se,colorScheme:x,size:[F,I],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:ce,showAxes:i.showAxes,xLabel:Y,yLabel:q,xFormat:a,yFormat:c,enableHover:$,showGrid:D}),ne&&{xExtent:ne.xExtent,yExtent:ne.yExtent}),ae&&{legend:ae,legendPosition:ue}),z&&"none"!==z&&{legendHoverBehavior:ee.onLegendHover,legendClickBehavior:ee.onLegendClick,legendHighlightedCategory:ee.highlightedCategory,legendIsolatedCategories:ee.isolatedCategories}),G&&{title:G}),s&&{className:s}),{tooltipContent:!1===S?()=>null:!0===S||void 0===S?de:At(S)||de}),(_||B)&&{customHoverBehavior:K}),E&&{pointIdAccessor:E}),O&&O.length>0&&{annotations:O}),{canvasPreRenderers:ye}),C),ye.length>0&&{canvasPreRenderers:ye});return d.createElement(Lt,{componentName:"QuadrantChart",width:F,height:I},d.createElement(qe,Object.assign({ref:o},me)))});cn.displayName="QuadrantChart";const un="__forecastSegment";function hn(e,t){return"function"==typeof t?t(e):!!e[t]}const dn=Object.freeze({__proto__:null,SEGMENT_FIELD:un,buildAnomalyAnnotations:function(e){var t,n,o;return[{type:"anomaly-band",threshold:null!==(t=e.threshold)&&void 0!==t?t:2,showBand:!1!==e.showBand,fill:e.bandColor||"#6366f1",fillOpacity:null!==(n=e.bandOpacity)&&void 0!==n?n:.1,anomalyColor:e.anomalyColor||"#ef4444",anomalyRadius:null!==(o=e.anomalyRadius)&&void 0!==o?o:6,label:e.label}]},buildForecast:function(e,t,n,o,i){return(r=o).isTraining||r.isForecast||r.isAnomaly||r.upperBounds||r.lowerBounds?function(e,t,n,o,i){var r,l,s;const{isTraining:a,isForecast:c,isAnomaly:u,upperBounds:h,lowerBounds:d,color:f="#6366f1",bandOpacity:g=.15,anomalyColor:p="#ef4444",anomalyRadius:y=6,label:m}=o,v=e.map(e=>{let t="observed";return c&&hn(e,c)?t="forecast":a&&hn(e,a)&&(t="training"),Object.assign(Object.assign({},e),{[un]:t})}),b=[];for(let e=0;v.length>e;e++)b.push(v[e]),v.length-1>e&&v[e][un]!==v[e+1][un]&&b.push(Object.assign(Object.assign({},v[e]),{[un]:v[e+1][un]}));const x=[];if(h&&d){const e="string"==typeof h?h:"__envUpper",t="string"==typeof d?d:"__envLower";if("function"==typeof h||"function"==typeof d)for(const n of b)"function"==typeof h&&(n[e]=h(n)),"function"==typeof d&&(n[t]=d(n));x.push({type:"envelope",upperAccessor:e,lowerAccessor:t,fill:f,fillOpacity:g,label:m})}return u&&x.push({type:"highlight",filter:e=>hn(e,u),color:p,r:y,style:{stroke:p,strokeWidth:1.5,fill:p,fillOpacity:.7}}),i&&x.push({type:"anomaly-band",threshold:null!==(r=i.threshold)&&void 0!==r?r:2,showBand:!1!==i.showBand,fill:i.bandColor||"#6366f1",fillOpacity:null!==(l=i.bandOpacity)&&void 0!==l?l:.1,anomalyColor:i.anomalyColor||"#ef4444",anomalyRadius:null!==(s=i.anomalyRadius)&&void 0!==s?s:6,label:i.label}),{processedData:b,annotations:x}}(e,0,0,o,i):function(e,t,n,o,i){var r,l,s;const{trainEnd:a,steps:c=10,confidence:u=.95,color:h="#6366f1",bandOpacity:d=.15,label:f}=o;if(null==a)return{processedData:e,annotations:[]};const g=[],p=[];for(const n of e)n[t]>a?p.push(Object.assign(Object.assign({},n),{[un]:"observed"})):g.push(Object.assign(Object.assign({},n),{[un]:"training"}));const y=g.map(e=>[e[t],e[n]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]),m=[],v=[];if(y.length>=3){const o=y.length;let i=0,r=0,l=0,s=0;for(const[e,t]of y)i+=e,r+=t,l+=e*e,s+=e*t;const a=o*l-i*i;if(Math.abs(a)>1e-12){const l=(o*s-i*r)/a,g=(r-l*i)/o,p=e=>g+l*e,b=y.map(([e,t])=>t-p(e)).reduce((e,t)=>e+t*t,0),x=Math.sqrt(b/Math.max(o-2,1)),k=y.reduce((e,t)=>e+t[0],0)/o,w=y.reduce((e,t)=>e+Math.pow(t[0]-k,2),0),A=.99>u?.95>u?.9>u?1:1.645:1.96:2.576,M=e.map(e=>e[t]).filter(e=>null!=e&&isFinite(e)),S=Math.max(...M),E=y.length>1?(y[o-1][0]-y[0][0])/(o-1):1;for(let e=1;c>=e;e++){const i=S+e*E,r=p(i),l=x*Math.sqrt(1+1/o+(w>0?Math.pow(i-k,2)/w:0))*A;v.push({[t]:i,[n]:r,[un]:"forecast",__forecastUpper:r+l,__forecastLower:r-l})}m.push({type:"envelope",upperAccessor:"__forecastUpper",lowerAccessor:"__forecastLower",fill:h,fillOpacity:d,label:f})}}m.push({type:"x-threshold",x:a,color:"#94a3b8",strokeWidth:1,strokeDasharray:"4,2",label:"Train / Forecast"}),i&&m.push({type:"anomaly-band",threshold:null!==(r=i.threshold)&&void 0!==r?r:2,showBand:!1!==i.showBand,fill:i.bandColor||"#6366f1",fillOpacity:null!==(l=i.bandOpacity)&&void 0!==l?l:.1,anomalyColor:i.anomalyColor||"#ef4444",anomalyRadius:null!==(s=i.anomalyRadius)&&void 0!==s?s:6,label:i.label});const b=[];if(b.push(...g),g.length>0&&p.length>0&&b.push(Object.assign(Object.assign({},g[g.length-1]),{[un]:"observed"})),b.push(...p),v.length>0){const e=p.length>0?p[p.length-1]:g[g.length-1];e&&b.push(Object.assign(Object.assign({},e),{[un]:"forecast"})),b.push(...v)}return{processedData:b,annotations:m}}(e,t,n,o,i);var r},createSegmentLineStyle:function(e,t){var n,o;const i=null!==(n=t.trainDasharray)&&void 0!==n?n:"8,4",r=null!==(o=t.forecastDasharray)&&void 0!==o?o:"4,4",l=t.color||"#6366f1";return t=>{const n=e(t),o=t[un];return"training"===o?Object.assign(Object.assign({},n),{strokeDasharray:i}):"forecast"===o?Object.assign(Object.assign({},n),{stroke:l,strokeDasharray:r}):n}}});exports.AreaChart=Yt,exports.BubbleChart=Ut,exports.ConnectedScatterplot=Qt,exports.Heatmap=Kt,exports.LineChart=Gt,exports.MinimapChart=an,exports.QuadrantChart=cn,exports.Scatterplot=Xt,exports.ScatterplotMatrix=ln,exports.StackedAreaChart=qt,exports.StreamXYFrame=qe;
|
|
1
|
+
"use strict";const e=require("react"),t=require("d3-brush"),n=require("d3-selection"),o=require("d3-scale"),r=require("d3-scale-chromatic"),i=require("d3-quadtree"),s=require("d3-array"),a=require("d3-hierarchy"),l=require("d3-shape"),c=require("regression");function u(e){return e&&e.__esModule?e:{default:e}}function h(e){if(e&&e.__esModule)return e;const t=Object.create(null);if(e)for(const n in e)if("default"!==n){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:function(){return e[n]}})}return t.default=e,Object.freeze(t)}const d=h(e),g=u(c);class p{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 y{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 f{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 m(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 v(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 b(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 x(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 k(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 w(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 A(e,t){if("function"==typeof e)return t=>+e(t);const n=e||t;return e=>+e[n]}function S(e,t){if("function"==typeof e)return e;const n=e||t;return e=>e[n]}function O(e,t){return"function"==typeof e?e:e?t=>t[e]+"":void 0}const M={category10:r.schemeCategory10,tableau10:r.schemeTableau10,set3:r.schemeSet3,blues:r.interpolateBlues,reds:r.interpolateReds,greens:r.interpolateGreens,oranges:r.interpolateOranges,purples:r.interpolatePurples,viridis:r.interpolateViridis,plasma:r.interpolatePlasma},E=r.schemeCategory10,j=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],C=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 P(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")||C.has(t)}(o)?n(o):o}const o=e[t];return n?n(o):E[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+""))%E.length]}function _(e,t,n="category10"){const r=Array.from(new Set(e.map(e=>null==e?void 0:e[t]).filter(e=>null!=e))),i=r.every(e=>"number"==typeof e||!isNaN(Number(e)));if(Array.isArray(n))return o.scaleOrdinal().domain(r).range(n).unknown("#999");const s=M[n]||M.category10;if(i&&"function"==typeof s){let e=-1/0;for(const t of r){const n=Number(t);n>e&&(e=n)}return t=>s(Number(t)/e)}{const e=Array.isArray(s)?s:E;return o.scaleOrdinal().domain(r).range(e).unknown("#999")}}function L(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 B(e,t,n){return e+(t-e)*n}class N{constructor(e){this.xExtent=new f,this.yExtent=new f,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 y(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=A(e.timeAccessor||e.xAccessor,"time"),this.getY=A(e.valueAccessor||e.yAccessor,"value")):(this.getX=A(e.xAccessor,"x"),this.getY=A(e.yAccessor,"y")),this.getGroup=O(e.groupAccessor),this.getCategory=O(e.categoryAccessor),this.getSize=e.sizeAccessor?A(e.sizeAccessor,"size"):void 0,this.getColor=O(e.colorAccessor),this.getBounds=e.boundsAccessor?A(e.boundsAccessor,"bounds"):void 0,this.getY0=e.y0Accessor?A(e.y0Accessor,"y0"):void 0,this.getPointId=O(e.pointIdAccessor),"candlestick"===e.chartType&&(this.getOpen=A(e.openAccessor,"open"),this.getHigh=A(e.highAccessor,"high"),this.getLow=A(e.lowAccessor,"low"),this.getClose=A(e.closeAccessor,"close")),e.pulse&&(this.timestampBuffer=new y(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,r,i,s,a;const{config:l,buffer:c}=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(c,this.getX),this.yExtent.dirty)if("candlestick"===l.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const e of c)this.yExtent.push(this.getHigh(e)),this.yExtent.push(this.getLow(e))}else this.yExtent.recalculate(c,this.getY);const u=this.getBufferArray(),h=this.xExtent.extent,d=this.yExtent.extent;let g=l.xExtent?[null!==(t=l.xExtent[0])&&void 0!==t?t:h[0],null!==(n=l.xExtent[1])&&void 0!==n?n:h[1]]:h,p=l.yExtent?[null!==(r=l.yExtent[0])&&void 0!==r?r:d[0],null!==(i=l.yExtent[1])&&void 0!==i?i:d[1]]:d;const y=l.yExtent&&null!=l.yExtent[0]&&null!=l.yExtent[1];if("stackedarea"===l.chartType&&!y&&c.size>0)if(l.normalize)p=[0,1+l.extentPadding];else{const e=`${c.size}:${this._ingestVersion}`;if(this._stackExtentCache&&this._stackExtentCache.key===e)p=this._stackExtentCache.yDomain;else{const t=this.groupData(u),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);p=[0,o+(o>0?o*l.extentPadding:1)],this._stackExtentCache={key:e,yDomain:p}}}else if("bar"===l.chartType&&l.binSize&&!y&&c.size>0){const[,e]=function(e,t,n,o,r){const i=m(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]}(c,this.getX,this.getY,l.binSize,this.getCategory);p=[0,e+e*l.extentPadding]}else if("waterfall"===l.chartType&&!y&&c.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]}(c,this.getY),n=t-e,o=n>0?n*l.extentPadding:1;p=[Math.min(0,e-Math.abs(o)),Math.max(0,t+Math.abs(o))]}else if(!y&&p[0]!==1/0){if(this.getBounds)for(const e of u){const t=this.getY(e),n=this.getBounds(e);null!=t&&!Number.isNaN(t)&&n&&(t+n>p[1]&&(p[1]=t+n),p[0]>t-n&&(p[0]=t-n))}const e=p[1]-p[0],t=e>0?e*l.extentPadding:1,n=null===(s=l.yExtent)||void 0===s?void 0:s[0],o=null===(a=l.yExtent)||void 0===a?void 0:a[1];p=[null!=n?p[0]:p[0]-t,null!=o?p[1]:p[1]+t],"log"===l.yScaleType&&0>=p[0]&&d[0]>0&&(p[0]=null!=n?p[0]:d[0]/(1+l.extentPadding))}if(g[0]!==1/0&&g[1]!==-1/0||(g=[0,1]),p[0]!==1/0&&p[1]!==-1/0||(p=[0,1]),"streaming"===l.runtimeMode)if("x"==("up"===(f=l.arrowOfTime)||"down"===f?"y":"x")){const t="right"===l.arrowOfTime?[0,e.width]:[e.width,0];this.scales={x:o.scaleLinear().domain(g).range(t),y:o.scaleLinear().domain(p).range([e.height,0])}}else{const t="down"===l.arrowOfTime?[0,e.height]:[e.height,0];this.scales={x:o.scaleLinear().domain(p).range([0,e.width]),y:o.scaleLinear().domain(g).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 o.scaleLog().domain(e).range(n).clamp(!0)}return o.scaleLinear().domain(t).range(n)};this.scales={x:t(l.xScaleType,g,[0,e.width]),y:t(l.yScaleType,p,[e.height,0])}}var f;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(e,u),this.config.decay&&this.applyDecay(this.scene,u),this.config.pulse&&this.applyPulse(this.scene,u),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.rebuildQuadtree(),this.needsFullRebuild=!1,this.lastLayout={width: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>N.QUADTREE_THRESHOLD?i.quadtree().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 r=this.scales.x.domain(),i=this.scales.y.domain(),s=this.scales.x.range(),a=this.scales.y.range(),l=(e,t,n)=>{if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return o.scaleLog().domain(e).range(n).clamp(!0)}return o.scaleLinear().domain(t).range(n)};this.scales={x:l(this.config.xScaleType,r,[s[0]*t,s[1]*t]),y:l(this.config.yScaleType,i,[a[0]*n,a[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=v(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=b(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=x(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 i=A(this.config.valueAccessor,"value"),s=S(this.config.xAccessor,"x"),a=S(this.config.yAccessor,"y"),l=new Set,c=new Set;for(const t of e)l.add(s(t)),c.add(a(t));const u=Array.from(l),h=Array.from(c),d=u.every(e=>"number"==typeof e&&!isNaN(e)),g=h.every(e=>"number"==typeof e&&!isNaN(e)),p=d?u.sort((e,t)=>e-t):u,y=g?h.sort((e,t)=>e-t):h;if(0===p.length||0===y.length)return n;const f=t.width/p.length,m=t.height/y.length,v=new Map;for(const t of e){const e=`${s(t)}\0${a(t)}`;v.set(e,{val:i(t),datum:t})}let b=1/0,x=-1/0;for(const{val:e}of v.values())b>e&&(b=e),e>x&&(x=e);const k=o.scaleSequential({blues:r.interpolateBlues,reds:r.interpolateReds,greens:r.interpolateGreens,viridis:r.interpolateViridis}["string"==typeof this.config.colorScheme?this.config.colorScheme:"blues"]||r.interpolateBlues).domain([b,x]);for(let e=0;p.length>e;e++)for(let t=0;y.length>t;t++){const o=v.get(`${p[e]}\0${y[t]}`);if(!o)continue;const r=k(o.val);n.push(w(e*f,(y.length-1-t)*m,f,m,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=A(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,S=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(w(r*k,(a-1-s)*S,k,S,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=m(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(k(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(k(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 w=s.y(p),A=s.y(y);i.push(k(b,Math.min(w,A),x,Math.abs(w-A),{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 M=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 E=!1;const j=new Set,C=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(C.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]];E=!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]];E=!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}),E=!0;continue}const v=this.prevPositionMap.get(m);if("point"===f.type)if(v){j.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,E=!0)}else f._targetOpacity=null!==(i=f.style.opacity)&&void 0!==i?i:1,f.style=Object.assign(Object.assign({},f.style),{opacity:0}),E=!0;else if("rect"===f.type)if(v){j.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,E=!0)}else f._targetOpacity=null!==(c=f.style.opacity)&&void 0!==c?c:1,f.style=Object.assign(Object.assign({},f.style),{opacity:0}),E=!0;else if("heatcell"===f.type)if(v){j.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,E=!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}),E=!0}for(const[e,t]of this.prevPathMap)if(!C.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),E=!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),E=!0}for(const[e,t]of this.prevPositionMap)if(!j.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)}E=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),E&&(this.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:M})}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=B(r,e._targetOpacity,l)}if(void 0===e._targetX)continue;if(!t)continue;const o=this.prevPositionMap.get(t);if(!o)continue;e.x=B(o.x,e._targetX,l),e.y=B(o.y,e._targetY,l),void 0!==e._targetR&&void 0!==o.r&&(e.r=B(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=B(r,e._targetOpacity,l)}if(void 0===e._targetX)continue;if(!t)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=B(n.x,e._targetX,l),e.y=B(n.y,e._targetY,l),void 0!==n.w&&(e.w=B(n.w,e._targetW,l)),void 0!==n.h&&(e.h=B(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:B(o,e._targetOpacity,l)})}if(void 0===e._targetX)continue;if(!t)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=B(n.x,e._targetX,l),e.y=B(n.y,e._targetY,l),void 0!==n.w&&(e.w=B(n.w,e._targetW,l)),void 0!==n.h&&(e.h=B(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:B(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]=B(t[o][0],n[o][0],l),e.path[o][1]=B(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:B(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]=B(t[n][0],o[n][0],l),e.topPath[n][1]=B(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]=B(n[t][0],r[t][0],l),e.bottomPath[t][1]=B(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:j,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:j,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=A(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=A(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=A(this.config.xAccessor,"x"),this.getY=A(this.config.yAccessor,"y"))),void 0!==e.groupAccessor&&(this.getGroup=O(this.config.groupAccessor)),void 0!==e.categoryAccessor&&(this.getCategory=O(this.config.categoryAccessor)),void 0!==e.sizeAccessor&&(this.getSize=this.config.sizeAccessor?A(this.config.sizeAccessor,"size"):void 0),void 0!==e.colorAccessor&&(this.getColor=O(this.config.colorAccessor)),void 0!==e.y0Accessor&&(this.getY0=this.config.y0Accessor?A(this.config.y0Accessor,"y0"):void 0),void 0!==e.pointIdAccessor&&(this.getPointId=O(this.config.pointIdAccessor)),this.needsFullRebuild=!0}}function H(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 z(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 $(e,t,n){var o,r,i,s;if(0===e.path.length)return null;const a=R(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=T(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 T(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 W(e,t,n){const o=H(t,n,e);return o.hit?{node:e,datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}function I(e,t,n){const o=H(t,n,e);return o.hit?{node:e,datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}function F(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 D(e,t,n){if(0===e.topPath.length)return null;const o=R(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 R(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}N.QUADTREE_THRESHOLD=500;const G={fill:e=>d.createElement("rect",{style:e,width:16,height:16}),line:e=>d.createElement("line",{style:e,x1:0,y1:0,x2:16,y2:16})};function q(e,t,n,o){let r;return r="function"==typeof n?n(e):(0,G[n])(o(e,t)),r}function Y(){return d.createElement("path",{d:"M4,8.8 L7.2,12 L12.8,4.8",fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function X(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}function V({config:e,orientation:t="vertical",width:n=100}){const{colorFn:o,domain:r,label:i,format:s}=e,a=s||(e=>Math.round(100*e)/100+""),l="grad-legend-"+d.useId();if("horizontal"===t){const e=12,t=Math.min(n,200),s=Math.max(0,(n-t)/2),c=[];for(let e=0;64>=e;e++){const t=e/64;c.push(d.createElement("stop",{key:e,offset:100*t+"%",stopColor:o(r[0]+t*(r[1]-r[0]))}))}return d.createElement("g",{"aria-label":i||"Gradient legend"},d.createElement("defs",null,d.createElement("linearGradient",{id:l,x1:"0%",y1:"0%",x2:"100%",y2:"0%"},c)),i&&d.createElement("text",{x:s+t/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},i),d.createElement("rect",{x:s,y:0,width:t,height:e,fill:`url(#${l})`,rx:2}),d.createElement("text",{x:s,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},a(r[0])),d.createElement("text",{x:s+t,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},a(r[1])))}const c=[];for(let e=0;64>=e;e++){const t=e/64;c.push(d.createElement("stop",{key:e,offset:100*t+"%",stopColor:o(r[1]-t*(r[1]-r[0]))}))}return d.createElement("g",{"aria-label":i||"Gradient legend"},i&&d.createElement("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},i),d.createElement("defs",null,d.createElement("linearGradient",{id:l,x1:"0%",y1:"0%",x2:"0%",y2:"100%"},c)),d.createElement("rect",{x:0,y:0,width:14,height:100,fill:`url(#${l})`,rx:2}),d.createElement("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},a(r[1])),d.createElement("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},a(r[0])))}function Q(e){const{legendGroups:t,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,legendInteraction:s,title:a="Legend",width:l=100,height:c=20,orientation:u="vertical"}=e,[h,g]=d.useState(0),[p,y]=d.useState(0),f=d.useCallback((e,t)=>{g(e),y(t)},[]),m="vertical"===u?(({legendGroups:e,width:t,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,focusedGroupIndex:s,focusedItemIndex:a,onFocusedIndexChange:l,legendInteraction:c})=>{let u=24;const h=[];return e.forEach((e,g)=>{u+=5,h.push(d.createElement("line",{key:"legend-top-line legend-symbol-"+g,stroke:"gray",x1:0,y1:u,x2:t,y2:u})),u+=8,e.label&&(u+=16,h.push(d.createElement("text",{key:"legend-text-"+g,y:u,className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label)),u+=8),h.push(d.createElement("g",{key:"legend-group-"+g,className:"legend-item",transform:`translate(0,${u})`},((e,t,n,o,r,i,s,a,l,c)=>{const{type:u="fill",styleFn:h,items:g}=e,p=[];let y=0;const f=!(!t&&!n),m="isolate"===c||void 0===c&&null!=r;return g.forEach((e,c)=>{const v=q(e,c,u,h),b=X(e,o,r),x=r&&r.size>0&&r.has(e.label);p.push(d.createElement("g",{key:"legend-item-"+c,transform:`translate(0,${y})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:f?a===i&&c===s?0:-1:void 0,role:f?"option":void 0,"aria-selected":f&&m?x||!1:void 0,"aria-current":f&&!m&&null!=o&&e.label===o||void 0,"aria-label":e.label,onKeyDown:f?n=>{var o;if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowDown"===n.key||"ArrowUp"===n.key){n.preventDefault();const e=(c+("ArrowDown"===n.key?1:-1)+g.length)%g.length;l(a,e);const t=null===(o=n.currentTarget.parentElement)||void 0===o?void 0:o.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:f?t=>{l(a,c),n&&n(e);const o=t.currentTarget.querySelector(".semiotic-legend-focus-ring");o&&o.setAttribute("visibility","visible")}:void 0,onBlur:f?e=>{n&&n(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&&d.createElement("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*e.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),v,x&&d.createElement(Y,null),d.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label))),y+=22}),p})(e,n,o,r,i,s,a,g,l,c))),u+=22*e.items.length+8}),h})({legendGroups:t||[],width:l,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,focusedGroupIndex:h,focusedItemIndex:p,onFocusedIndexChange:f,legendInteraction:s}):(({legendGroups:e,height:t,width:n,customClickBehavior:o,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:s,focusedGroupIndex:a,focusedItemIndex:l,onFocusedIndexChange:c,legendInteraction:u})=>{let h=0;const g=[];e.forEach((e,t)=>{let n=0;e.label&&(n+=16);const p=((e,t,n,o,r,i,s,a,l,c)=>{const{type:u="fill",styleFn:h,items:g}=e,p=[];let y=0;const f=!(!t&&!n),m="isolate"===c||void 0===c&&null!=r;return g.forEach((e,c)=>{const v=q(e,c,u,h),b=X(e,o,r),x=r&&r.size>0&&r.has(e.label);p.push(d.createElement("g",{key:"legend-item-"+c,transform:`translate(${y},0)`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:f?a===i&&c===s?0:-1:void 0,role:f?"option":void 0,"aria-selected":f&&m?x||!1:void 0,"aria-current":f&&!m&&null!=o&&e.label===o||void 0,"aria-label":e.label,onKeyDown:f?n=>{var o;if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowRight"===n.key||"ArrowLeft"===n.key){n.preventDefault();const e=(c+("ArrowRight"===n.key?1:-1)+g.length)%g.length;l(a,e);const t=null===(o=n.currentTarget.parentElement)||void 0===o?void 0:o.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:f?t=>{l(a,c),n&&n(e);const o=t.currentTarget.querySelector(".semiotic-legend-focus-ring");o&&o.setAttribute("visibility","visible")}:void 0,onBlur:f?e=>{n&&n(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&&d.createElement("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*e.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),v,x&&d.createElement(Y,null),d.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label))),y+=26+7*e.label.length}),{items:p,offset:y}})(e,o,r,i,s,a,l,t,c,u);n+=p.offset+5,g.push(Object.assign(Object.assign({label:e.label},p),{offset:n})),h+=n+12});let p=Math.max(0,(n-h)/2);const y=[];return g.forEach((n,o)=>{const r=e[o];r.label&&(y.push(d.createElement("text",{key:"legend-text-"+o,transform:`translate(${p},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},r.label)),p+=16),y.push(d.createElement("g",{key:"legend-group-"+o,className:"legend-item",transform:`translate(${p},0)`},n.items)),p+=n.offset+5,e[o+1]&&y.push(d.createElement("line",{key:"legend-top-line legend-symbol-"+o,stroke:"gray",x1:p,y1:-8,x2:p,y2:t+0+8})),p+=12}),d.createElement("g",null,y)})({legendGroups:t||[],title:a,height:c,width:l,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,focusedGroupIndex:h,focusedItemIndex:p,onFocusedIndexChange:f,legendInteraction:s}),v=!(!n&&!o);return d.createElement("g",{role:v?"listbox":void 0,"aria-multiselectable":!(!v||"isolate"!==s&&(void 0!==s||null==i))||void 0,"aria-label":"Chart legend"},void 0!==a&&""!==a&&"vertical"===u&&d.createElement("text",{className:"legend-title",y:16,x:l/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)"},a),m)}function U(e){return"string"==typeof e?{type:e}:e}function K({orient:t,config:n,values:o,scale:r,size:i,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=e.useMemo(()=>{if(0===o.length)return null;const e=r.domain(),n=i-8;if("boxplot"===l.type){const e=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(!e)return null;const{q1:i,median:s,q3:a,whiskerLow:u,whiskerHigh:h}=e,g=Math.min(.5*n,20),p=(n-g)/2+4;if(c){const e=r(i),n=r(a),o=r(s),c=r(u),y=r(h),f="top"===t?-1:1,m=0;return d.createElement("g",{"data-testid":"marginal-boxplot-"+t},d.createElement("line",{x1:c,y1:m+f*(p+g/2),x2:y,y2:m+f*(p+g/2),stroke:l.fill,strokeWidth:l.strokeWidth}),d.createElement("line",{x1:c,y1:m+f*p,x2:c,y2:m+f*(p+g),stroke:l.fill,strokeWidth:l.strokeWidth}),d.createElement("line",{x1:y,y1:m+f*p,x2:y,y2:m+f*(p+g),stroke:l.fill,strokeWidth:l.strokeWidth}),d.createElement("rect",{x:Math.min(e,n),y:"top"===t?m-p-g:m+p,width:Math.abs(n-e),height:g,fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}),d.createElement("line",{x1:o,y1:"top"===t?m-p-g:m+p,x2:o,y2:"top"===t?m-p:m+p+g,stroke:l.fill,strokeWidth:2}))}{const e=r(i),n=r(a),o=r(s),c=r(u),y=r(h),f="left"===t?-1:1,m=0;return d.createElement("g",{"data-testid":"marginal-boxplot-"+t},d.createElement("line",{x1:m+f*(p+g/2),y1:c,x2:m+f*(p+g/2),y2:y,stroke:l.fill,strokeWidth:l.strokeWidth}),d.createElement("line",{x1:m+f*p,y1:c,x2:m+f*(p+g),y2:c,stroke:l.fill,strokeWidth:l.strokeWidth}),d.createElement("line",{x1:m+f*p,y1:y,x2:m+f*(p+g),y2:y,stroke:l.fill,strokeWidth:l.strokeWidth}),d.createElement("rect",{x:"left"===t?m-p-g:m+p,y:Math.min(e,n),width:g,height:Math.abs(n-e),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}),d.createElement("line",{x1:"left"===t?m-p-g:m+p,y1:o,x2:"left"===t?m-p:m+p+g,y2:o,stroke:l.fill,strokeWidth:2}))}}const u=s.bin().domain(e).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 d.createElement("g",{"data-testid":"marginal-histogram-"+t},u.map((e,o)=>{if(null==e.x0||null==e.x1)return null;const i=e.length/h*n;if(c){const n=r(e.x0),s=r(e.x1)-r(e.x0);return d.createElement("rect",{key:o,x:n,y:"top"===t?-4-i:4,width:Math.max(s,.5),height:i,fill:l.fill,fillOpacity:l.fillOpacity,stroke:l.stroke,strokeWidth:l.strokeWidth})}{const n=r(e.x0),s=r(e.x1)-r(e.x0);return d.createElement("rect",{key:o,x:"left"===t?-4-i:4,y:Math.min(n,n+s),width:i,height:Math.abs(s),fill:l.fill,fillOpacity:l.fillOpacity,stroke:l.stroke,strokeWidth:l.strokeWidth})}}));if("violin"===l.type){const e=n/2+4,o=[];for(const i of u){if(null==i.x0||null==i.x1)continue;const s=i.length/h*(n/2),a=r((i.x0+i.x1)/2);o.push(c?`${a},${"top"===t?-(e-s):e-s}`:`${"left"===t?-(e-s):e-s},${a}`)}for(let i=u.length-1;i>=0;i--){const s=u[i];if(null==s.x0||null==s.x1)continue;const a=s.length/h*(n/2),l=r((s.x0+s.x1)/2);o.push(c?`${l},${"top"===t?-(e+a):e+a}`:`${"left"===t?-(e+a):e+a},${l}`)}return d.createElement("g",{"data-testid":"marginal-violin-"+t},d.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 e=[];if(c){const o=0,i=null!=u[0].x0?r(u[0].x0):0;e.push(`M${i},${o}`);for(const o of u){if(null==o.x0||null==o.x1)continue;const i=o.length/h*n,s=r((o.x0+o.x1)/2);e.push(`L${s},${"top"===t?-i-4:i+4}`)}const s=null!=u[u.length-1].x1?r(u[u.length-1].x1):a;e.push(`L${s},${o}`),e.push("Z")}else{const o=0,i=null!=u[0].x0?r(u[0].x0):0;e.push(`M${o},${i}`);for(const o of u){if(null==o.x0||null==o.x1)continue;const i=o.length/h*n,s=r((o.x0+o.x1)/2);e.push(`L${"left"===t?-i-4:i+4},${s}`)}const s=null!=u[u.length-1].x1?r(u[u.length-1].x1):a;e.push(`L${o},${s}`),e.push("Z")}return d.createElement("g",{"data-testid":"marginal-ridgeline-"+t},d.createElement("path",{d:e.join(" "),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}))}return null},[o,r,l,i,a,t,c,4]);return u?d.createElement("g",{className:"marginal-"+t,"data-testid":"marginal-"+t},u):null}function Z(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 J(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 ee(e){const{x:t=0,y:n=0,dx:o,dy:r,nx:i,ny:s,note:a,connector:l,subject:c,type:u,color:h,className:g,disable:p,events:y={},"data-testid":f}=e,m=new Set(Array.isArray(p)?p:[]);let v=o||0,b=r||0;null!=i&&(v=i-t),null!=s&&(b=s-n);const x="string"==typeof u?u:"label";if("bracket"===x&&c&&0===v&&0===b)if(void 0!==c.width){v=c.width/2;const e=c.depth||30;b=e+(0>e?-5:5)}else if(void 0!==c.height){const e=c.depth||30;v=e+(0>e?-5:5),b=c.height/2}return d.createElement("g",Object.assign({className:("annotation "+(g||"")).trim(),transform:`translate(${t},${n})`,"data-testid":f},y),!m.has("connector")&&function(e,t,n,o,r,i){const s=[];let a=0,l=0;if("callout-circle"!==r&&"label"!==r||!(null==i?void 0:i.radius)){if("callout-rect"===r&&i){const n=i.width||0,o=i.height||0;if(n>0||o>0){const r=n/2,i=o/2,s=e-r,c=t-i;if(0!==s||0!==c){const e=Math.abs(s),t=Math.abs(c),u=n/2,h=o/2,d=e*h>t*u?u/e:h/t;a=r+s*d,l=i+c*d}}}else if("bracket"===r&&i){const e=i.width,t=i.height,n=i.depth||30;void 0!==e?(a=e/2,l=n):void 0!==t&&(a=n,l=t/2)}}else{const n=(i.radius||0)+(i.radiusPadding||0);if(n>0&&(0!==e||0!==t)){const o=Math.atan2(t,e);a=Math.cos(o)*n,l=Math.sin(o)*n}}if(Math.sqrt(Math.pow(e-a,2)+Math.pow(t-l,2))>.5&&(s.push(d.createElement("line",{key:"connector-line",x1:a,y1:l,x2:e,y2:t,stroke:o||"currentColor"})),"arrow"===(null==n?void 0:n.end))){const n=10,r=16/180*Math.PI,i=Math.atan2(t-l,e-a);s.push(d.createElement("path",{key:"connector-arrow",d:`M${a},${l}L${a+n*Math.cos(i+r)},${l+n*Math.sin(i+r)}L${a+n*Math.cos(i-r)},${l+n*Math.sin(i-r)}Z`,fill:o||"currentColor",stroke:"none"}))}return d.createElement("g",{className:"annotation-connector"},s)}(v,b,l,h,x,c),!m.has("subject")&&function(e,t,n,o,r){var i;const s=[];switch(e){case"callout-circle":{const e=((null==t?void 0:t.radius)||0)+((null==t?void 0:t.radiusPadding)||0);e>0&&s.push(d.createElement("circle",{key:"subject-circle",r:e,fill:"none",stroke:n||"currentColor"}));break}case"callout-rect":{const e=(null==t?void 0:t.width)||0,o=(null==t?void 0:t.height)||0;(e>0||o>0)&&s.push(d.createElement("rect",{key:"subject-rect",width:e,height:o,fill:"none",stroke:n||"currentColor"}));break}case"callout-custom":(null==t?void 0:t.custom)&&s.push(...Array.isArray(t.custom)?t.custom:[t.custom]);break;case"xy-threshold":{const e=o||0,i=r||0;if(void 0!==(null==t?void 0:t.x)){const o=(t.x||0)-e;s.push(d.createElement("line",{key:"threshold-line",x1:o,y1:(t.y1||0)-i,x2:o,y2:(t.y2||0)-i,stroke:n||"currentColor",strokeDasharray:"5,5"}))}else if(void 0!==(null==t?void 0:t.y)){const o=(t.y||0)-i;s.push(d.createElement("line",{key:"threshold-line",x1:(t.x1||0)-e,y1:o,x2:(t.x2||0)-e,y2:o,stroke:n||"currentColor",strokeDasharray:"5,5"}))}else void 0!==(null==t?void 0:t.x1)||void 0!==(null==t?void 0:t.x2)?s.push(d.createElement("line",{key:"threshold-line",x1:(t.x1||0)-e,y1:0,x2:(t.x2||0)-e,y2:0,stroke:n||"currentColor",strokeDasharray:"5,5"})):void 0===(null==t?void 0:t.y1)&&void 0===(null==t?void 0:t.y2)||s.push(d.createElement("line",{key:"threshold-line",x1:0,y1:(t.y1||0)-i,x2:0,y2:(t.y2||0)-i,stroke:n||"currentColor",strokeDasharray:"5,5"}));break}case"bracket":{const e=null!==(i=null==t?void 0:t.width)&&void 0!==i?i:null==t?void 0:t.height;void 0!==e&&s.push(d.createElement("path",{key:"bracket-path",d:J((null==t?void 0:t.type)||"curly",e,(null==t?void 0:t.depth)||30,void 0===(null==t?void 0:t.width)),fill:"none",stroke:n||"currentColor"}));break}}return d.createElement("g",{className:"annotation-subject"},s)}(x,c,h,t,n),!m.has("note")&&function(e,t,n,o){if(!e)return d.createElement("g",{className:"annotation-note"});const{label:r,title:i,orientation:s,align:a,wrap:l=120,noWrap:c}=e;if(!r&&!i)return d.createElement("g",{className:"annotation-note"});let u=s;u||(u=Math.abs(t)>Math.abs(n)?"leftRight":"topBottom");let h=a;h&&"dynamic"!==h||(h="topBottom"===u?0>t?"right":"left":0>n?"bottom":"top");let g="start";"topBottom"===u?"right"===h?g="end":"middle"===h&&(g="middle"):g=0>t?"end":"start";const p=16,y=i?c?[i]:Z(i,l):[],f=r?c?[r]:Z(r,l):[],m="leftRight"===u?"end"===g?-4:4:0;let v=0;const b=[];y.length>0&&(b.push(d.createElement("text",{key:"annotation-note-title",className:"annotation-note-title",fill:o||void 0,textAnchor:g,fontWeight:"bold"},y.map((e,t)=>d.createElement("tspan",{key:t,x:m,dy:0===t?0:p},e)))),v=y.length*p),f.length>0&&b.push(d.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:o||void 0,textAnchor:g,y:v},f.map((e,t)=>d.createElement("tspan",{key:t,x:m,dy:0===t?0:p},e))));let x=null;if((i||r)&&(0!==t||0!==n))if("topBottom"===u){const e=Math.min(l,120);let t=0,n=e;"end"===g?(t=-e,n=0):"middle"===g&&(t=-e/2,n=e/2),x=d.createElement("line",{className:"note-line",x1:t,x2:n,y1:0,y2:0,stroke:o||"currentColor"})}else{const e=(y.length+f.length)*p+(f.length>0?p:0);let t=0,n=e;"bottom"===h?(t=-e,n=0):"middle"===h&&(t=-e/2,n=e/2),x=d.createElement("line",{className:"note-line",x1:0,x2:0,y1:t,y2:n,stroke:o||"currentColor"})}const k=Math.max(0,y.length+f.length-1)*p;let w=0;return"topBottom"===u?w=0>n?-(k+2):18:"leftRight"===u&&(w="middle"===h?-(k+p+(f.length>0&&y.length>0?2:0))/2+8:"bottom"===h||0>n?-(k+2):18),d.createElement("g",{className:"annotation-note",transform:`translate(${t},${n})`},d.createElement("g",{className:"annotation-note-content",transform:0!==w?`translate(0,${w})`:void 0},b),x)}(a,v,b,h))}function te(e){var t,n;const{noteData:o}=e,{screenCoordinates:r}=o,i="string"==typeof o.type?o.type:"label",s=o.eventListeners||o.events||{};if(o.coordinates&&r){const e=o.nx||r[0][0]+(null!==(t=o.dx)&&void 0!==t?t:0),s=o.ny||r[0][1]+(null!==(n=o.dy)&&void 0!==n?n:0),a=r.map((t,n)=>{const r=Object.assign({},o,{note:0===n?o.note:{label:""},x:t[0],y:t[1],nx:e,ny:s});return d.createElement(ee,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+n},r,{type:i}))});return d.createElement("g",null,a)}const a=o.note||{title:"none",label:o.label};return d.createElement(ee,Object.assign({"data-testid":"semiotic-annotation",key:`${a.label}-${a.title}-${o.i}`,events:s},o,{type:i}))}const ne={linear:l.curveLinear,monotoneX:l.curveMonotoneX,monotoneY:l.curveMonotoneY,step:l.curveStep,stepAfter:l.curveStepAfter,stepBefore:l.curveStepBefore,basis:l.curveBasis,cardinal:l.curveCardinal,catmullRom:l.curveCatmullRom};function oe(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 re(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 ie(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=oe(e,n),c=re(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 se(e,t,n,o=50){return!(-o>e||e>(n.width||0)+o||-o>t||t>(n.height||0)+o)}function ae(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 le(t){const{width:n,height:o,totalWidth:r,totalHeight:i,margin:s,scales:a,showAxes:l,axes:c,showGrid:u,xFormat:h,yFormat:g}=t,p=e.useMemo(()=>{var e;if(!a)return[];const t=null==c?void 0:c.find(e=>"bottom"===e.orient),o=(null==t?void 0:t.tickFormat)||h||ce,r=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;return a.x.ticks(Math.min(r,Math.max(2,Math.floor(n/70)))).map(e=>({value:e,pixel:a.x(e),label:o(e)}))},[a,c,h,n]),y=e.useMemo(()=>{var e;if(!a)return[];const t=null==c?void 0:c.find(e=>"left"===e.orient),n=(null==t?void 0:t.tickFormat)||g||ce,r=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;return a.y.ticks(Math.min(r,Math.max(2,Math.floor(o/30)))).map(e=>({value:e,pixel:a.y(e),label:n(e)}))},[a,c,g,o]),f=u&&a,m=l&&a;if(!f&&!m)return null;const v=null==c?void 0:c.find(e=>"bottom"===e.orient),b=null==c?void 0:c.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 d.createElement("svg",{width:r,height:i,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},d.createElement("g",{transform:`translate(${s.left},${s.top})`},f&&d.createElement("g",{className:"stream-grid"},p.map((e,t)=>d.createElement("line",{key:"xgrid-"+t,x1:e.pixel,y1:0,x2:e.pixel,y2:o,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1})),y.map((e,t)=>d.createElement("line",{key:"ygrid-"+t,x1:0,y1:e.pixel,x2:n,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),x&&!w&&d.createElement("line",{x1:0,y1:o,x2:n,y2:o,stroke:S,strokeWidth:1}),w&&d.createElement("path",{d:ae("bottom",n,o),fill:"none",stroke:S,strokeWidth:1}),k&&!A&&d.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:S,strokeWidth:1}),A&&d.createElement("path",{d:ae("left",n,o),fill:"none",stroke:S,strokeWidth:1})))}function ce(e){return Math.round(100*e)/100+""}function ue(e,t){return e instanceof Date&&(!(t&&t instanceof Date)||e.getFullYear()!==t.getFullYear()||e.getMonth()!==t.getMonth()||e.getDate()!==t.getDate())}function he(t){var n,o;const{width:r,height:i,totalWidth:s,totalHeight:c,margin:u,scales:h,showAxes:p,axes:y,xLabel:f,yLabel:m,xFormat:v,yFormat:b,showGrid:x,title:k,legend:w,legendHoverBehavior:A,legendClickBehavior:S,legendHighlightedCategory:O,legendIsolatedCategories:M,legendPosition:E="right",foregroundGraphics:j,marginalGraphics:C,xValues:P,yValues:_,annotations:L,svgAnnotationRules:B,xAccessor:N,yAccessor:H,annotationData:z,pointNodes:$,curve:T,underlayRendered:W,children:I}=t,F=e.useMemo(()=>{var e;if(!p||!h)return[];const t=null==y?void 0:y.find(e=>"bottom"===e.orient),n=(null==t?void 0:t.tickFormat)||v||ce,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(r/70)))).map(e=>({value:e,pixel:h.x(e),label:n(e)}))},[p,h,y,v,r]),D=e.useMemo(()=>{var e;if(!p||!h)return[];const t=null==y?void 0:y.find(e=>"left"===e.orient),n=(null==t?void 0:t.tickFormat)||b||ce,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(i/30)))).map(e=>({value:e,pixel:h.y(e),label:n(e)}))},[p,h,y,b,i]),R=e.useRef(new Map),G=e.useRef(null!==(n=null==L?void 0:L.length)&&void 0!==n?n:0),q=null!==(o=null==L?void 0:L.length)&&void 0!==o?o:0;G.current!==q&&(G.current=q,R.current=new Map);const Y=e.useMemo(()=>{if(!L||0===L.length)return null;const e=function(e,t,n){var o,r,i,s,c,u,h,p,y,f,m,v,b,x,k,w,A,S,O,M,E,j,C,P,_,L,B,N,H,z,$,T,W,I,F,D,R,G,q,Y,X,V,Q,U;switch(e.type){case"label":{const o=ie(e,t,n);if(!o)return null;const{x:r,y:i}=o;return se(r,i,n)?d.createElement(te,{key:"ann-"+t,noteData:{x:r,y:i,dx:e.dx||30,dy:e.dy||-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"label",connector:e.connector||{end:"arrow"},color:e.color}}):null}case"callout":{const o=ie(e,t,n);if(!o)return null;const{x:r,y:i}=o;return se(r,i,n)?d.createElement(te,{key:"ann-"+t,noteData:{x:r,y:i,dx:e.dx||30,dy:e.dy||-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"callout-circle",subject:{radius:e.radius||12},connector:e.connector||{end:"arrow"},color:e.color}}):null}case"x-threshold":{const o=oe(e,n);if(null==o)return null;const r=e.color||"#f97316";return d.createElement("g",{key:"ann-"+t},d.createElement("line",{x1:o,y1:0,x2:o,y2:n.height||0,stroke:r,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&d.createElement("text",{x:o+4,y:12,fill:r,fontSize:12,fontWeight:"bold"},e.label))}case"y-threshold":{const o=re(e,n);if(null==o)return null;const r=e.color||"#f97316";return d.createElement("g",{key:"ann-"+t},d.createElement("line",{x1:0,y1:o,x2:n.width||0,y2:o,stroke:r,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&d.createElement("text",{x:(n.width||0)-4,y:o-4,textAnchor:"end",fill:r,fontSize:12,fontWeight:"bold"},e.label))}case"enclose":{const o=(e.coordinates||[]).map(e=>({x:oe(Object.assign(Object.assign({},e),{type:"point"}),n),y:re(Object.assign(Object.assign({},e),{type:"point"}),n),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>o.length)return null;const r=a.packEnclose(o),i=e.padding||10;return d.createElement("g",{key:"ann-"+t},d.createElement("circle",{cx:r.x,cy:r.y,r:r.r+i,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&d.createElement("text",{x:r.x,y:r.y-r.r-i-4,textAnchor:"middle",fill:e.color||"#666",fontSize:12},e.label))}case"rect-enclose":{const o=(e.coordinates||[]).map(e=>({x:oe(Object.assign(Object.assign({},e),{type:"point"}),n),y:re(Object.assign(Object.assign({},e),{type:"point"}),n)})).filter(e=>null!=e.x&&null!=e.y);if(2>o.length)return null;const r=e.padding||10,i=o.map(e=>e.x),s=o.map(e=>e.y),a=Math.min(...i)-r,l=Math.max(...i)+r,c=Math.min(...s)-r,u=Math.max(...s)+r;return d.createElement("g",{key:"ann-"+t},d.createElement("rect",{x:a,y:c,width:l-a,height:u-c,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&d.createElement("text",{x:(a+l)/2,y:c-4,textAnchor:"middle",fill:e.color||"#666",fontSize:12},e.label))}case"highlight":{const o=n.data||[],r="function"==typeof e.filter?o.filter(e.filter):e.field&&null!=e.value?o.filter(t=>t[e.field]===e.value):[],i=e.style||{stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return d.createElement("g",{key:"ann-"+t},r.map((t,o)=>{const r=oe(t,n),s=re(t,n);return null==r||null==s?null:d.createElement("circle",Object.assign({key:"hl-"+o,cx:r,cy:s,r:e.r||6},i))}))}case"bracket":{const o=oe(e,n),r=re(e,n);return d.createElement(te,{key:"ann-"+t,noteData:{x:null!=o?o:0,y:null!=r?r:0,dx:e.dx||0,dy:e.dy||0,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"bracket",subject:{type:e.bracketType||"curly",width:e.width,height:e.height,depth:e.depth||30},color:e.color}})}case"trend":{const a=n.data||[];if(2>a.length)return null;const l=n.xAccessor||"x",p=n.yAccessor||"y",y=a.map(e=>[e[l],e[p]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>y.length)return null;const f=null!==(r=null===(o=n.scales)||void 0===o?void 0:o.x)&&void 0!==r?r:null===(i=n.scales)||void 0===i?void 0:i.time,m=null!==(c=null===(s=n.scales)||void 0===s?void 0:s.y)&&void 0!==c?c:null===(u=n.scales)||void 0===u?void 0:u.value;if(!f||!m)return null;const v=e.method||"linear";let b;b="loess"===v?function(e,t=.3){const n=e.length;if(2>n)return e.slice();const o=e.slice().sort((e,t)=>e[0]-t[0]),r=o.map(e=>e[0]),i=o.map(e=>e[1]),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}(y,null!==(h=e.bandwidth)&&void 0!==h?h:.3):("polynomial"===v?g.default.polynomial(y,{order:e.order||2}):g.default.linear(y)).points;const x=b.map(([e,t])=>`${f(e)},${m(t)}`).join(" "),k=e.color||"#6366f1";return d.createElement("g",{key:"ann-"+t},d.createElement("polyline",{points:x,fill:"none",stroke:k,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&d.createElement("text",{x:f(b[b.length-1][0])+4,y:m(b[b.length-1][1])-4,fill:k,fontSize:11},e.label))}case"band":{const o=null!==(y=null===(p=n.scales)||void 0===p?void 0:p.y)&&void 0!==y?y:null===(f=n.scales)||void 0===f?void 0:f.value,r=null!==(m=null==o?void 0:o(e.y0))&&void 0!==m?m:0,i=null!==(v=null==o?void 0:o(e.y1))&&void 0!==v?v:n.height||0;return d.createElement("g",{key:"ann-"+t},d.createElement("rect",{x:0,y:Math.min(r,i),width:n.width||0,height:Math.abs(i-r),fill:e.fill||"#6366f1",fillOpacity:e.fillOpacity||.1}),e.label&&d.createElement("text",{x:(n.width||0)-4,y:Math.min(r,i)-4,textAnchor:"end",fill:e.color||"#6366f1",fontSize:11},e.label))}case"envelope":{const o=n.data||[];if(2>o.length)return null;const r=n.xAccessor||"x",i=null!==(x=null===(b=n.scales)||void 0===b?void 0:b.x)&&void 0!==x?x:null===(k=n.scales)||void 0===k?void 0:k.time,s=null!==(A=null===(w=n.scales)||void 0===w?void 0:w.y)&&void 0!==A?A:null===(S=n.scales)||void 0===S?void 0:S.value;if(!i||!s)return null;const a=e.upperAccessor||"upperBounds",c=e.lowerAccessor||"lowerBounds",u=e.filter,h=o.filter(e=>null!=e[a]&&null!=e[c]&&!(u&&!u(e))).sort((e,t)=>e[r]-t[r]);if(2>h.length)return null;const g=ne[n.curve||"linear"]||l.curveLinear,p=l.area().x(e=>i(e[r])).y0(e=>s(e[c])).y1(e=>s(e[a])).curve(g)(h);if(!p)return null;const y=e.fill||"#6366f1";return d.createElement("g",{key:"ann-"+t},d.createElement("path",{d:p,fill:y,fillOpacity:null!==(O=e.fillOpacity)&&void 0!==O?O:.15,stroke:"none"}),e.label&&h.length>0&&d.createElement("text",{x:i(h[h.length-1][r])+4,y:s(h[h.length-1][a])-4,fill:y,fontSize:11},e.label))}case"anomaly-band":{const o=n.data||[];if(2>o.length)return null;const r=n.yAccessor||"y",i=null!==(E=null===(M=n.scales)||void 0===M?void 0:M.x)&&void 0!==E?E:null===(j=n.scales)||void 0===j?void 0:j.time,s=null!==(P=null===(C=n.scales)||void 0===C?void 0:C.y)&&void 0!==P?P:null===(_=n.scales)||void 0===_?void 0:_.value;if(!i||!s)return null;const a=o.map(e=>e[r]).filter(e=>null!=e&&isFinite(e));if(2>a.length)return null;const l=a.reduce((e,t)=>e+t,0)/a.length,c=a.reduce((e,t)=>e+Math.pow(t-l,2),0)/a.length,u=Math.sqrt(c),h=null!==(L=e.threshold)&&void 0!==L?L:2,g=l-h*u,p=!1!==e.showBand,y=e.fill||"#6366f1",f=null!==(B=e.fillOpacity)&&void 0!==B?B:.1,m=e.anomalyColor||"#ef4444",v=null!==(N=e.anomalyRadius)&&void 0!==N?N:6,b=s(l+h*u),x=s(g),k=o.filter(e=>{const t=e[r];return null!=t&&Math.abs(t-l)>h*u});return d.createElement("g",{key:"ann-"+t},p&&d.createElement("rect",{x:0,y:Math.min(b,x),width:n.width||0,height:Math.abs(x-b),fill:y,fillOpacity:f}),k.map((e,t)=>{const o=oe(e,n),r=re(e,n);return null==o||null==r?null:d.createElement("circle",{key:"anomaly-"+t,cx:o,cy:r,r:v,fill:m,fillOpacity:.7,stroke:m,strokeWidth:1.5})}),e.label&&d.createElement("text",{x:(n.width||0)-4,y:Math.min(b,x)-4,textAnchor:"end",fill:y,fontSize:11},e.label))}case"forecast":{const o=n.data||[];if(3>o.length)return null;const r=n.xAccessor||"x",i=n.yAccessor||"y",s=null!==(z=null===(H=n.scales)||void 0===H?void 0:H.x)&&void 0!==z?z:null===($=n.scales)||void 0===$?void 0:$.time,a=null!==(W=null===(T=n.scales)||void 0===T?void 0:T.y)&&void 0!==W?W:null===(I=n.scales)||void 0===I?void 0:I.value;if(!s||!a)return null;const l=o.map(e=>[e[r],e[i]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]);if(3>l.length)return null;let c;if("polynomial"===(e.method||"linear")){const t=g.default.polynomial(l,{order:e.order||2}).equation;c=e=>t.reduce((t,n,o)=>t+n*Math.pow(e,o),0)}else{const e=l.length;let t=0,n=0,o=0,r=0;for(const[e,i]of l)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;c=e=>a+s*e}const u=l.length,h=l.map(([e,t])=>t-c(e)).reduce((e,t)=>e+t*t,0),p=Math.sqrt(h/Math.max(u-2,1)),y=l.reduce((e,t)=>e+t[0],0)/u,f=l.reduce((e,t)=>e+Math.pow(t[0]-y,2),0),m=null!==(F=e.confidence)&&void 0!==F?F:.95,v=.99>m?.95>m?.9>m?1:1.645:1.96:2.576,b=null!==(D=e.steps)&&void 0!==D?D:5,x=l[u-1][0],k=(x-l[0][0])/Math.max(u-1,1),w=[];for(let e=1;b>=e;e++)w.push(x+e*k);const A=[];for(const e of w){const t=c(e),n=p*Math.sqrt(1+1/u+(f>0?Math.pow(e-y,2)/f:0))*v;A.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const S=`M${A.map(e=>`${s(e.x)},${a(e.yUpper)}`).join(" L")} L${A.slice().reverse().map(e=>`${s(e.x)},${a(e.yLower)}`).join(" L")} Z`,O=A.map(e=>`${s(e.x)},${a(e.yCenter)}`).join(" "),M=`${s(x)},${a(c(x))}`,E=e.strokeColor||"#6366f1";return d.createElement("g",{key:"ann-"+t},d.createElement("path",{d:S,fill:e.fill||"#6366f1",fillOpacity:null!==(R=e.fillOpacity)&&void 0!==R?R:.15,stroke:"none"}),d.createElement("polyline",{points:`${M} ${O}`,fill:"none",stroke:E,strokeWidth:null!==(G=e.strokeWidth)&&void 0!==G?G:2,strokeDasharray:null!==(q=e.strokeDasharray)&&void 0!==q?q:"6,3"}),e.label&&A.length>0&&d.createElement("text",{x:s(A[A.length-1].x)+4,y:a(A[A.length-1].yCenter)-4,fill:E,fontSize:11},e.label))}case"widget":{let o=null,r=null;if(null!=e.px&&null!=e.py)o=e.px,r=e.py;else{const i=ie(e,t,n);if(!i)return null;o=i.x,r=i.y}if(null==o||null==r)return null;if(!se(o,r,n))return null;const i=null!==(Y=e.dx)&&void 0!==Y?Y:0,s=null!==(X=e.dy)&&void 0!==X?X:0,a=null!==(V=e.width)&&void 0!==V?V:32,l=null!==(Q=e.height)&&void 0!==Q?Q:32,c=null!==(U=e.content)&&void 0!==U?U:d.createElement("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info"},"ℹ️");return d.createElement("foreignObject",{key:"ann-"+t,x:o+i-a/2,y:r+s-l/2,width:a,height:l,style:{overflow:"visible",pointerEvents:"auto"}},d.createElement("div",{style:{width:a,height:l,display:"flex",alignItems:"center",justifyContent:"center"}},c))}case"text":{const o=ie(e,t,n);if(!o)return null;const{x:r,y:i}=o;return d.createElement("text",{key:"ann-text-"+t,x:r+(e.dx||0),y:i+(e.dy||0),fill:e.color||"var(--semiotic-text, #333)",fontSize:e.fontSize||11,dominantBaseline:"middle",style:{fontFamily:"inherit"}},e.label)}default:return null}},t={scales:h?{x:h.x,y:h.y,time:h.x,value:h.y}:null,timeAxis:"x",xAccessor:N,yAccessor:H,width:r,height:i,data:z,frameType:"xy",pointNodes:$,curve:T,stickyPositionCache:R.current};return L.map((n,o)=>{if(B){const r=B(n,o,t);return null!=r?r:e(n,o,t)}return e(n,o,t)}).filter(Boolean)},[L,B,r,i,N,H,z,h,$,T]);return p||k||w||j||C||Y&&Y.length>0||x||I?d.createElement("svg",{role:"img",width:s,height:c,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},d.createElement("title",null,"string"==typeof k?k:"XY Chart"),d.createElement("desc",null,"string"==typeof k?k+" — XY data visualization":"XY data visualization"),d.createElement("g",{transform:`translate(${u.left},${u.top})`},x&&h&&!W&&d.createElement("g",{className:"stream-grid"},F.map((e,t)=>d.createElement("line",{key:"xgrid-"+t,x1:e.pixel,y1:0,x2:e.pixel,y2:i,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1})),D.map((e,t)=>d.createElement("line",{key:"ygrid-"+t,x1:0,y1:e.pixel,x2:r,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),p&&h&&(()=>{const e=null==y?void 0:y.find(e=>"left"===e.orient),t=null==y?void 0:y.find(e=>"bottom"===e.orient),n=!e||!1!==e.baseline,o=(null==e?void 0:e.jaggedBase)||!1,s=(null==t?void 0:t.jaggedBase)||!1,a=null==t?void 0:t.landmarkTicks,l=null==e?void 0:e.landmarkTicks,c="var(--semiotic-border, #ccc)",h="var(--semiotic-text-secondary, #666)",g="var(--semiotic-text, #333)";return d.createElement("g",{className:"stream-axes"},!W&&(!t||!1!==t.baseline)&&!s&&d.createElement("line",{x1:0,y1:i,x2:r,y2:i,stroke:c,strokeWidth:1}),!W&&s&&d.createElement("path",{d:ae("bottom",r,i),fill:"none",stroke:c,strokeWidth:1}),F.map((e,t)=>{const n=!!a&&("function"==typeof a?a(e.value,t):ue(e.value,t>0?F[t-1].value:void 0));return d.createElement("g",{key:"xtick-"+t,transform:`translate(${e.pixel},${i})`},d.createElement("line",{y2:5,stroke:c,strokeWidth:1}),d.createElement("text",{y:18,textAnchor:"middle",fontSize:n?11:10,fontWeight:n?600:400,fill:h,style:{userSelect:"none"}},e.label))}),f&&d.createElement("text",{x:r/2,y:i+40,textAnchor:"middle",fontSize:12,fill:g,style:{userSelect:"none"}},f),!W&&n&&!o&&d.createElement("line",{x1:0,y1:0,x2:0,y2:i,stroke:c,strokeWidth:1}),!W&&o&&d.createElement("path",{d:ae("left",r,i),fill:"none",stroke:c,strokeWidth:1}),D.map((e,t)=>{const n=!!l&&("function"==typeof l?l(e.value,t):ue(e.value,t>0?D[t-1].value:void 0));return d.createElement("g",{key:"ytick-"+t,transform:`translate(0,${e.pixel})`},d.createElement("line",{x2:-5,stroke:c,strokeWidth:1}),d.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:n?11:10,fontWeight:n?600:400,fill:h,style:{userSelect:"none"}},e.label))}),m&&d.createElement("text",{x:15-u.left,y:i/2,textAnchor:"middle",fontSize:12,fill:g,transform:`rotate(-90, ${15-u.left}, ${i/2})`,style:{userSelect:"none"}},m))})(),Y,C&&h&&P&&_&&d.createElement(d.Fragment,null,C.top&&d.createElement("g",{transform:"translate(0, 0)"},d.createElement(K,{orient:"top",config:U(C.top),values:P,scale:h.x,size:u.top,length:r})),C.bottom&&d.createElement("g",{transform:`translate(0, ${i})`},d.createElement(K,{orient:"bottom",config:U(C.bottom),values:P,scale:h.x,size:u.bottom,length:r})),C.left&&d.createElement("g",{transform:"translate(0, 0)"},d.createElement(K,{orient:"left",config:U(C.left),values:_,scale:h.y,size:u.left,length:i})),C.right&&d.createElement("g",{transform:`translate(${r}, 0)`},d.createElement(K,{orient:"right",config:U(C.right),values:_,scale:h.y,size:u.right,length:i}))),j,I),k&&d.createElement("text",{x:s/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof k?k:null),function(e){const{legend:t,totalWidth:n,totalHeight:o,margin:r,legendPosition:i="right",title:s,legendHoverBehavior:a,legendClickBehavior:l,legendHighlightedCategory:c,legendIsolatedCategories:u,legendInteraction:h}=e;if(!t)return null;const g="top"===i||"bottom"===i;let p,y;return"left"===i?(p=4,y=r.top):"top"===i?(p=0,y=s?32:8):"bottom"===i?(p=0,y=o-r.bottom+50):(p=n-r.right+10,y=r.top),d.createElement("g",{transform:`translate(${p}, ${y})`},"object"==typeof(f=t)&&null!==f&&"gradient"in f?d.createElement(V,{config:t.gradient,orientation:g?"horizontal":"vertical",width:g?n:100}):function(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}(t)?d.createElement(Q,{legendGroups:t.legendGroups,title:"",width:g?n:100,orientation:g?"horizontal":"vertical",customHoverBehavior:a,customClickBehavior:l,highlightedCategory:c,isolatedCategories:u,legendInteraction:h}):t);var f}({legend:w,totalWidth:s,totalHeight:c,margin:u,legendPosition:E,title:k,legendHoverBehavior:A,legendClickBehavior:S,legendHighlightedCategory:O,legendIsolatedCategories:M})):null}const de="undefined"==typeof window||"undefined"==typeof document,ge={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function pe(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 ye({scene:e,chartType:t}){var n,o,r,i;const s=[];for(const t of e){if(s.length>=50)break;"point"===t.type?s.push({label:"Point",values:{x:Math.round(100*t.x)/100+"",y:Math.round(100*t.y)/100+""}}):"rect"===t.type?s.push({label:"Bar",values:{category:(null===(n=t.datum)||void 0===n?void 0:n.category)||"",value:Math.round(100*(null!==(r=null===(o=t.datum)||void 0===o?void 0:o.value)&&void 0!==r?r:0))/100+""}}):"heatcell"===t.type&&s.push({label:"Cell",values:{x:Math.round(100*t.x)/100+"",y:Math.round(100*t.y)/100+"",value:Math.round(100*(null!==(i=t.value)&&void 0!==i?i: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 l=Array.from(a);return d.createElement("table",{style:ge,role:"table","aria-label":"Data table for "+t},d.createElement("thead",null,d.createElement("tr",null,l.map(e=>d.createElement("th",{key:e},e)))),d.createElement("tbody",null,s.map((e,t)=>d.createElement("tr",{key:t},l.map(t=>{var n;return d.createElement("td",{key:t},null!==(n=e.values[t])&&void 0!==n?n:"")}))),e.length>50&&d.createElement("tr",null,d.createElement("td",{colSpan:l.length},"...and ",e.length-50," more items"))))}function fe({hoverPoint:e}){let t="";if(e){const n=e.data||e;t="object"==typeof n?"Focused on data point: "+Object.entries(n).filter(([,e])=>"object"!=typeof e&&"function"!=typeof e).map(([e,t])=>`${e}: ${t}`).join(", "):"Focused on data point: "+n}return d.createElement("div",{"aria-live":"polite","aria-atomic":"true",style:ge},t)}function me(t){const n=e.createContext(null),o=ve(t);return[function({children:o}){const r=e.useMemo(()=>ve(t),[]);return d.createElement(n.Provider,{value:r,children:o})},t=>{var r;const i=null!==(r=e.useContext(n))&&void 0!==r?r:o,s=e.useRef(t);s.current=t;const a=e.useCallback(()=>s.current(i.getState()),[i]),l=e.useCallback(()=>s.current(i.getState()),[i]);return e.useSyncExternalStore(i.subscribe,a,l)}]}function ve(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 be={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}},xe={mode:"dark",colors:{primary:"#4fc3f7",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",background:"#1a1a2e",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},[ke,we]=me(e=>({theme:be,setTheme(t){e(e=>"light"===t?{theme:be}:"dark"===t?{theme:xe}:{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 Ae(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 Se(e){switch(e){case"monotoneX":return l.curveMonotoneX;case"monotoneY":return l.curveMonotoneY;case"cardinal":return l.curveCardinal;case"catmullRom":return l.curveCatmullRom;case"step":return l.curveStep;case"stepBefore":return l.curveStepBefore;case"stepAfter":return l.curveStepAfter;case"basis":return l.curveBasis;case"natural":return l.curveNatural;default:return null}}function Oe(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 Me(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 Ee(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function je(e,t,n=.3){Ee(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 Ce(e,t,n=.6){var o,r,i,s,a;if(!Ee(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 Pe(e,t,n,o=.35){Ee(t)&&(e.globalAlpha=t._pulseIntensity*o,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fill())}function _e(e){switch(e){case"monotoneX":return l.curveMonotoneX;case"monotoneY":return l.curveMonotoneY;case"cardinal":return l.curveCardinal;case"catmullRom":return l.curveCatmullRom;case"step":return l.curveStep;case"stepBefore":return l.curveStepBefore;case"stepAfter":return l.curveStepAfter;case"basis":return l.curveBasis;case"natural":return l.curveNatural;default:return null}}function Le(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 Be(e,t){const n=_e(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=l.area().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 Ne=(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(Be(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=Le(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&&(Be(e,t),Pe(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=_e(t.curve);if(e.beginPath(),n)l.line().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}},He=(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()),Ce(e,t),e.globalAlpha=1}}finally{e.restore()}},ze=(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?$e(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))),je(e,t),e.globalAlpha=1};function $e(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 Te(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 We(e){return Number.isInteger(e)?e+"":100>Math.abs(e)?1>Math.abs(e)?e.toPrecision(3):e.toFixed(1):e.toFixed(0)}const Ie={line:[Ne,(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 c=a.style.stroke||"#007bff",u=a.style.strokeWidth||2,h=a.colorThresholds,d=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=u,e.lineCap=a.style.strokeLinecap||"butt",a.style._edgeFade){const f=null!==(r=a.style.opacity)&&void 0!==r?r:1;Me(e,a.path,c,u,f,a.style.strokeLinecap||"butt"),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt";continue}const g=Se(a.curve),p=h&&h.length>0&&d&&d.length===a.path.length,y=a._decayOpacities;if(y&&y.length===a.path.length&&!p){e.strokeStyle=c;const m=null!==(i=a.style.opacity)&&void 0!==i?i:1;for(let v=0;a.path.length-1>v;v++)e.globalAlpha=.5*(y[v]+y[v+1])*m,e.beginPath(),e.moveTo(a.path[v][0],a.path[v][1]),e.lineTo(a.path[v+1][0],a.path[v+1][1]),e.stroke()}else if(p){let b=null,x=null,k=null,w=null,A=!1;function S(t,n,o){e.beginPath(),e.strokeStyle=t,e.moveTo(n,o),A=!0}function O(){A&&(e.stroke(),A=!1)}for(let M=0;a.path.length>M;M++){const[E,j]=a.path[M],C=d[M],P=Oe(C,h,c);if(null!==b&&null!==w&&null!==k){if(P===w)e.lineTo(E,j);else{const _=[];for(const L of h){const B=L.value;(k>B||B>C)&&(B>k||C>B)||k===B||C===B||_.push({t:(B-k)/(C-k)})}_.sort((e,t)=>e.t-t.t);for(const N of _){const H=b+(E-b)*N.t,z=x+(j-x)*N.t,$=Oe(k+(C-k)*Math.min(N.t+1e-4,1),h,c);e.lineTo(H,z),O(),S($,H,z)}e.lineTo(E,j)}b=E,x=j,k=C,w=P}else S(P,E,j),b=E,x=j,k=C,w=P}O()}else{if(e.beginPath(),e.strokeStyle=c,g)l.line().x(e=>e[0]).y(e=>e[1]).curve(g).context(e)(a.path);else{const[T,W]=a.path[0];e.moveTo(T,W);for(let I=1;a.path.length>I;I++)e.lineTo(a.path[I][0],a.path[I][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,g&&!p)l.line().x(e=>e[0]).y(e=>e[1]).curve(g).context(e)(a.path);else{const[D,R]=a.path[0];e.moveTo(D,R);for(let G=1;a.path.length>G;G++)e.lineTo(a.path[G][0],a.path[G][1])}const F=a.path[0][0];e.lineTo(a.path[a.path.length-1][0],o.height),e.lineTo(F,o.height),e.closePath(),e.fill()}e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt"}}],area:[Ne],stackedarea:[Ne],scatter:[He],bubble:[He],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),je(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):We(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=Te(t.fill),e.font=o+"px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(n,r,i)}}}finally{e.restore()}}],bar:[ze],swarm:[He],waterfall:[(e,t,n,o)=>{var r,i,s;ze(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()}}]},Fe={top:20,right:20,bottom:30,left:40},De={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"},Re={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 Ge({hover:e}){const t=e=>Number.isInteger(e)?e+"":e.toFixed(2);return d.createElement("div",{className:"semiotic-tooltip",style:Re},d.createElement("div",{style:{fontWeight:600,marginBottom:2}},t(e.value)),d.createElement("div",{style:{opacity:.7,fontSize:11}},t(e.time)))}function qe({width:o,height:r,totalWidth:i,totalHeight:s,margin:a,dimension:l,scales:c,onBrush:u}){const h=e.useRef(null),g=e.useRef(null),p=e.useRef(u);p.current=u;const y=e.useRef(c);return y.current=c,e.useEffect(()=>{if(!h.current)return;const e=n.select(h.current).select(".brush-g"),i="x"===l?t.brushX():"y"===l?t.brushY():t.brush();return i.extent([[0,0],[o,r]]),i.on("brush end",e=>{const t=y.current;if(!t)return;if(!e.selection)return void p.current(null);let n,i;if("x"===l){const[o,s]=e.selection;n=[t.x.invert(o),t.x.invert(s)],i=[t.y.invert(r),t.y.invert(0)]}else if("y"===l){const[r,s]=e.selection;n=[t.x.invert(0),t.x.invert(o)],i=[t.y.invert(s),t.y.invert(r)]}else{const[[o,r],[s,a]]=e.selection;n=[t.x.invert(o),t.x.invert(s)],i=[t.y.invert(a),t.y.invert(r)]}p.current({x:n,y:i})}),e.call(i),g.current=i,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{i.on("brush end",null),g.current=null}},[o,r,l]),d.createElement("svg",{ref:h,width:i,height:s,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},d.createElement("g",{className:"brush-g",transform:`translate(${a.left},${a.top})`}))}const Ye=e.forwardRef(function(t,n){var o,r,i,s,a,l,c,u,h;const{chartType:g,runtimeMode:y,data:f,chunkThreshold:m,chunkSize:v,xAccessor:b,yAccessor:x,colorAccessor:k,sizeAccessor:w,groupAccessor:A,lineDataAccessor:S,curve:O,normalize:M,binSize:E,valueAccessor:j,arrowOfTime:C="right",windowMode:P="sliding",windowSize:_=200,timeAccessor:L,xExtent:B,yExtent:H,extentPadding:T=.1,sizeRange:R,size:G=[500,300],responsiveWidth:q,responsiveHeight:Y,margin:X,className:V,background:Q,lineStyle:U,pointStyle:K,areaStyle:Z,waterfallStyle:J,swarmStyle:ee,barColors:te,colorScheme:ne,boundsAccessor:oe,boundsStyle:re,y0Accessor:ie,gradientFill:se,openAccessor:ae,highAccessor:ce,lowAccessor:ue,closeAccessor:ge,candlestickStyle:me,showAxes:ve=!0,axes:be,xLabel:xe,yLabel:ke,xFormat:Se,yFormat:Oe,tickFormatTime:Me,tickFormatValue:Ee,hoverAnnotation:je,tooltipContent:Ce,customHoverBehavior:Pe,enableHover:_e,annotations:Le,svgAnnotationRules:Be,showGrid:Ne,legend:He,legendHoverBehavior:ze,legendClickBehavior:$e,legendHighlightedCategory:Te,legendIsolatedCategories:We,legendPosition:Re,backgroundGraphics:Ye,foregroundGraphics:Xe,canvasPreRenderers:Ve,title:Qe,categoryAccessor:Ue,brush:Ke,onBrush:Ze,decay:Je,pulse:et,transition:tt,staleness:nt,heatmapAggregation:ot,heatmapXBins:rt,heatmapYBins:it,showValues:st,heatmapValueFormat:at,marginalGraphics:lt,pointIdAccessor:ct,xScaleType:ut,yScaleType:ht,accessibleTable:dt}=t,[gt,pt]=function(t,n,o){const r=e.useRef(null),[i,s]=e.useState(null);return e.useEffect(()=>{if(!n&&!o)return;const e=r.current;if(!e)return;const t=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;s(t=>t&&t.w===e&&t.h===n?t:{w:e,h:n})}});return t.observe(e),()=>t.disconnect()},[n,o]),[r,[n&&i?i.w:t[0],o&&i?i.h:t[1]]]}(G,q,Y),yt=Object.assign(Object.assign({},Fe),X);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,vt="function"==typeof Xe?Xe({size:pt,margin:yt}):Xe,bt="function"==typeof Ye?Ye({size:pt,margin:yt}):Ye,xt=null!=je?je:_e,kt=e.useRef(null),wt=e.useRef(null),At=e.useRef(0),St=e.useRef(!1),Ot=we(e=>e.theme),[Mt,Et]=e.useState(0),[jt,Ct]=e.useState(null),Pt=e.useRef(null),_t=e.useRef(null),[Lt,Bt]=e.useState(null),[Nt,Ht]=e.useState(!1),[zt,$t]=e.useState([]),[Tt,Wt]=e.useState([]),It=e.useRef(()=>{}),Ft="streaming"===y||["bar","swarm","waterfall"].includes(g),Dt=e.useMemo(()=>({chartType:g,runtimeMode:Ft?"streaming":"bounded",windowSize:_,windowMode:P,arrowOfTime:Ft?C:"right",extentPadding:T,xAccessor:Ft?void 0:b,yAccessor:Ft?void 0:x,timeAccessor:Ft?L:void 0,valueAccessor:j,colorAccessor:k,sizeAccessor:w,groupAccessor:A,categoryAccessor:Ue,lineDataAccessor:S,xScaleType:ut,yScaleType:ht,xExtent:B,yExtent:H,sizeRange:R,binSize:E,normalize:M,boundsAccessor:oe,boundsStyle:re,y0Accessor:ie,gradientFill:"boolean"==typeof se?se?{topOpacity:.8,bottomOpacity:.05}:void 0:se,openAccessor:ae,highAccessor:ce,lowAccessor:ue,closeAccessor:ge,candlestickStyle:me,lineStyle:U,pointStyle:K,areaStyle:Z,swarmStyle:ee,waterfallStyle:J,colorScheme:ne,barColors:te,annotations:Le,decay:Je,pulse:et,transition:tt,staleness:nt,heatmapAggregation:ot,heatmapXBins:rt,heatmapYBins:it,showValues:st,heatmapValueFormat:at,pointIdAccessor:ct,curve:O}),[g,_,P,C,T,b,x,L,j,ut,ht,k,w,A,Ue,S,B,H,R,E,M,oe,re,ie,se,ae,ce,ue,ge,me,U,K,Z,ee,J,ne,te,Le,Je,et,tt,nt,ot,rt,it,st,at,Ft,ct,O]),Rt=e.useRef(null);Rt.current||(Rt.current=new N(Dt));const Gt=e.useCallback(()=>{At.current||(At.current=requestAnimationFrame(()=>It.current()))},[]);e.useEffect(()=>{var e;null===(e=Rt.current)||void 0===e||e.updateConfig(Dt),St.current=!0,Gt()},[Dt,Gt]),e.useEffect(()=>{St.current=!0,Gt()},[Ot,Gt]);const qt=e.useRef(null);qt.current||(qt.current=new p(e=>{const t=Rt.current;t&&t.ingest(e)&&(St.current=!0,Gt())},{chunkThreshold:m,chunkSize:v})),e.useEffect(()=>{var e;null===(e=qt.current)||void 0===e||e.updateChunkOptions({chunkThreshold:m,chunkSize:v})},[m,v]);const Yt=e.useCallback(e=>{var t;null===(t=qt.current)||void 0===t||t.push(e)},[]),Xt=e.useCallback(e=>{var t;null===(t=qt.current)||void 0===t||t.pushMany(e)},[]),Vt=e.useCallback(()=>{var e,t;null===(e=qt.current)||void 0===e||e.clear(),null===(t=Rt.current)||void 0===t||t.clear(),St.current=!0,Gt()},[Gt]);e.useImperativeHandle(n,()=>({push:Yt,pushMany:Xt,clear:Vt,getData:()=>{var e,t,n;return null===(e=qt.current)||void 0===e||e.flush(),null!==(n=null===(t=Rt.current)||void 0===t?void 0:t.getData())&&void 0!==n?n:[]},getScales:()=>{var e,t;return null!==(t=null===(e=Rt.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null},getExtents:()=>{var e,t;return null!==(t=null===(e=Rt.current)||void 0===e?void 0:e.getExtents())&&void 0!==t?t:null}}),[Yt,Xt,Vt]),e.useEffect(()=>{var e;f&&(null===(e=qt.current)||void 0===e||e.setBoundedData(f))},[f]);const Qt=e.useRef(()=>{}),Ut=e.useRef(()=>{});Qt.current=e=>{if(!xt)return;const t=kt.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(Pt.current&&(Pt.current=null,_t.current=null,Bt(null),Pe&&(Pe(null),St.current=!0),Gt()));const i=Rt.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=z(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=z(a,t,n);break;case"line":e=$(a,t,n);break;case"rect":e=W(a,t,n);break;case"heatcell":e=I(a,t,n);break;case"area":if(!1===a.interactive)break;e=D(a,t,n);break;case"candlestick":e=F(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(Pt.current&&(Pt.current=null,_t.current=null,Bt(null),Pe&&Pe(null),Gt()));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});Pt.current=l,_t.current=s.node,Bt(l),Pe&&(Pe(l),St.current=!0),Gt()},Ut.current=()=>{Pt.current&&(Pt.current=null,_t.current=null,Bt(null),Pe&&(Pe(null),St.current=!0),Gt())},e.useCallback(e=>Qt.current(e),[]);const Kt=e.useCallback(()=>Ut.current(),[]),Zt=e.useRef(-1),Jt=e.useCallback(e=>{const t=Rt.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>Zt.current?-1:Zt.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 Zt.current=-1,Pt.current=null,_t.current=null,Bt(null),Pe&&Pe(null),void Gt();const i=0>o?0:r;Zt.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]);Pt.current=s,Bt(s),Pe&&Pe(s),Gt()},[Pe,Gt]),en=e.useCallback(e=>{Zt.current=-1,Qt.current(e)},[]);It.current=()=>{var e,t;At.current=0;const n=kt.current,o=wt.current;if(!n||!o)return;const r=Rt.current;if(!r)return;const i="undefined"!=typeof performance?performance.now():Date.now(),s=r.advanceTransition(i),a=St.current||s;a&&!s&&r.computeScene({width:ft,height:mt});const l="undefined"!=typeof window&&window.devicePixelRatio||1,c=function(e){if(!e)return De;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||De.axisStroke,tickText:i||De.tickText,crosshair:i?i+"66":De.crosshair,hoverFill:l?l+"4D":De.hoverFill,hoverStroke:i?i+"99":De.hoverStroke,pointRing:l||De.pointRing}:De}(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=Ae(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=Q||(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()),Ve&&r.scales)for(const t of Ve)e.save(),t(e,r.scene,r.scales,{width:ft,height:mt}),e.restore();const s=Ie[g];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=Ae(o,pt,yt,l);if(e&&(e.clearRect(-yt.left,-yt.top,pt[0],pt[1]),xt&&Pt.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,Pt.current,ft,mt,"object"==typeof xt?xt:{},0,c),_t.current&&Array.isArray(je))){const t=je.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,_t.current,t)}}a&&n&&n.setAttribute("aria-label",pe(r.scene,g+" chart"));const d=St.current;if(St.current=!1,d&&r.scales&&((!jt||jt.x.domain()[0]!==r.scales.x.domain()[0]||jt.x.domain()[1]!==r.scales.x.domain()[1]||jt.y.domain()[0]!==r.scales.y.domain()[0]||jt.y.domain()[1]!==r.scales.y.domain()[1]||jt.x.range()[0]!==r.scales.x.range()[0]||jt.x.range()[1]!==r.scales.x.range()[1]||jt.y.range()[0]!==r.scales.y.range()[0]||jt.y.range()[1]!==r.scales.y.range()[1])&&Ct(r.scales),lt)){const e=r.getData(),t="function"==typeof b?b:e=>e[b||"x"],n="function"==typeof x?x:e=>e[x||"y"];$t(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),Wt(e.map(e=>n(e)).filter(e=>"number"==typeof e&&isFinite(e)))}d&&Le&&Le.length>0&&Et(e=>e+1),(null==nt?void 0:nt.showBadge)&&Ht(!!h),(s||r.hasActivePulses)&&(At.current=requestAnimationFrame(()=>It.current()))},e.useEffect(()=>(Gt(),()=>{At.current&&(cancelAnimationFrame(At.current),At.current=0)}),[Gt]),e.useEffect(()=>{St.current=!0,Gt()},[g,ft,mt,ve,Q,U,Ve,Gt]),function(t,n,o,r,i,s){e.useEffect(()=>{if(!t)return;const e=setInterval(()=>{var e;const a=n.current;if(!a||0===a.lastIngestTime)return;const l="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(e=t.threshold)&&void 0!==e?e:5e3,u=l-a.lastIngestTime>c;u!==i&&(s(u),o.current=!0,r())},1e3);return()=>clearInterval(e)},[t,i,r])}(nt,Rt,St,Gt,Nt,Ht);const tn=xt&&Lt?Ce?Ce(Lt):d.createElement(Ge,{hover:Lt}):null,nn=tn?d.createElement("div",{className:"stream-frame-tooltip",style:{position:"absolute",left:yt.left+Lt.x,top:yt.top+Lt.y,transform:`translate(${Lt.x>.7*ft?"calc(-100% - 12px)":"12px"}, ${.3*mt>Lt.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:1,width:"max-content"}},tn):null,on=Zt.current>=0&&Lt?d.createElement("svg",{style:{position:"absolute",left:0,top:0,width:pt[0],height:pt[1],pointerEvents:"none",zIndex:2}},d.createElement("circle",{cx:Lt.x+yt.left,cy:Lt.y+yt.top,r:8,fill:"none",stroke:"var(--accent, #6366f1)",strokeWidth:2,strokeDasharray:"4,2"})):null;if(de){const e=Rt.current;e&&f&&(e.ingest({inserts:f,bounded:!0}),e.computeScene({width:ft,height:mt}));const t=null!==(o=null==e?void 0:e.scene)&&void 0!==o?o:[],n=null!==(r=null==e?void 0:e.scales)&&void 0!==r?r:null;return d.createElement("div",{className:"stream-xy-frame"+(V?" "+V:""),role:"img","aria-label":"string"==typeof Qe?Qe:"XY chart",style:{position:"relative",width:pt[0],height:pt[1]}},d.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:pt[0],height:pt[1],style:{position:"absolute",left:0,top:0}},bt,d.createElement("g",{transform:`translate(${yt.left},${yt.top})`},Q&&d.createElement("rect",{x:0,y:0,width:ft,height:mt,fill:Q}),t.map((e,t)=>function(e,t){var n,o,r;switch(e.type){case"line":{const n=e;if(0===n.path.length)return null;const o="M"+n.path.map(([e,t])=>`${e},${t}`).join("L");return d.createElement("path",{key:"line-"+t,d:o,fill:"none",stroke:n.style.stroke||"#4e79a7",strokeWidth:n.style.strokeWidth||2,strokeDasharray:n.style.strokeDasharray,opacity:n.style.opacity})}case"area":{const r=e;if(0===r.topPath.length)return null;const i=r.topPath.map(([e,t])=>`${e},${t}`).join("L"),s=[...r.bottomPath].reverse().map(([e,t])=>`${e},${t}`).join("L");return d.createElement("path",{key:"area-"+t,d:`M${i}L${s}Z`,fill:r.style.fill||"#4e79a7",fillOpacity:null!==(o=null!==(n=r.style.fillOpacity)&&void 0!==n?n:r.style.opacity)&&void 0!==o?o:.7,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})}case"point":return d.createElement("circle",{key:"point-"+t,cx:e.x,cy:e.y,r:e.r,fill:e.style.fill||"#4e79a7",opacity:null!==(r=e.style.opacity)&&void 0!==r?r:.8,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth});case"rect":return d.createElement("rect",{key:"rect-"+t,x:e.x,y:e.y,width:e.w,height:e.h,fill:e.style.fill||"#4e79a7",opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth});case"heatcell":{const n=e;if(n.showValues&&null!=n.value&&n.w>=20&&n.h>=20){const e=n.valueFormat?n.valueFormat(n.value):Number.isInteger(n.value)?n.value+"":100>Math.abs(n.value)?1>Math.abs(n.value)?n.value.toPrecision(3):n.value.toFixed(1):n.value.toFixed(0),[o,r,i]=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]}(n.fill),s=.299*o+.587*r+.114*i>128?"#000":"#fff",a=Math.max(10,Math.min(16,.3*Math.min(n.w,n.h)));return d.createElement("g",{key:"heatcell-"+t},d.createElement("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill}),d.createElement("text",{x:n.x+n.w/2,y:n.y+n.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:s,fontSize:a+"px"},e))}return d.createElement("rect",{key:"heatcell-"+t,x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill})}case"candlestick":{const n=e,o=Math.min(n.openY,n.closeY),r=Math.max(Math.abs(n.openY-n.closeY),1),i=n.isUp?n.upColor:n.downColor;return d.createElement("g",{key:"candle-"+t},d.createElement("line",{x1:n.x,y1:n.highY,x2:n.x,y2:n.lowY,stroke:n.wickColor,strokeWidth:n.wickWidth}),d.createElement("rect",{x:n.x-n.bodyWidth/2,y:o,width:n.bodyWidth,height:r,fill:i,stroke:i,strokeWidth:1}))}default:return null}}(e,t)).filter(Boolean))),d.createElement(he,{width:ft,height:mt,totalWidth:pt[0],totalHeight:pt[1],margin:yt,scales:n,showAxes:ve,axes:be,xLabel:xe,yLabel:ke,xFormat:Se||Me,yFormat:Oe||Ee,showGrid:Ne,title:Qe,legend:He,legendHoverBehavior:ze,legendClickBehavior:$e,legendHighlightedCategory:Te,legendIsolatedCategories:We,legendPosition:Re,foregroundGraphics:vt,marginalGraphics:lt,xValues:[],yValues:[],annotations:Le,svgAnnotationRules:Be,annotationFrame:0,xAccessor:"string"==typeof b?b:"string"==typeof L?L:void 0,yAccessor:"string"==typeof x?x:"string"==typeof j?j:void 0,annotationData:null==e?void 0:e.getData(),pointNodes:null==e?void 0:e.scene.filter(e=>"point"===e.type),curve:"string"==typeof O?O:void 0}))}return d.createElement("div",{ref:gt,className:"stream-xy-frame"+(V?" "+V:""),role:"img","aria-label":"string"==typeof Qe?Qe:"XY chart",tabIndex:0,style:{position:"relative",width:q?"100%":pt[0],height:Y?"100%":pt[1],overflow:"visible"},onMouseMove:xt?en:void 0,onMouseLeave:xt?Kt:void 0,onKeyDown:Jt},bt&&d.createElement("svg",{style:{position:"absolute",left:0,top:0,width:pt[0],height:pt[1],pointerEvents:"none"}},bt),d.createElement(le,{width:ft,height:mt,totalWidth:pt[0],totalHeight:pt[1],margin:yt,scales:jt,showAxes:ve,axes:be,showGrid:Ne,xFormat:Se||Me,yFormat:Oe||Ee}),d.createElement("canvas",{ref:kt,"aria-label":pe(null!==(s=null===(i=Rt.current)||void 0===i?void 0:i.scene)&&void 0!==s?s:[],g+" chart"),style:{position:"absolute",left:0,top:0}}),d.createElement("canvas",{ref:wt,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),d.createElement(fe,{hoverPoint:Lt}),dt&&d.createElement(ye,{scene:null!==(l=null===(a=Rt.current)||void 0===a?void 0:a.scene)&&void 0!==l?l:[],chartType:g+" chart"}),d.createElement(he,{width:ft,height:mt,totalWidth:pt[0],totalHeight:pt[1],margin:yt,scales:jt,showAxes:ve,axes:be,xLabel:xe,yLabel:ke,xFormat:Se||Me,yFormat:Oe||Ee,showGrid:Ne,title:Qe,legend:He,legendHoverBehavior:ze,legendClickBehavior:$e,legendHighlightedCategory:Te,legendIsolatedCategories:We,legendPosition:Re,foregroundGraphics:vt,marginalGraphics:lt,xValues:zt,yValues:Tt,annotations:Le,svgAnnotationRules:Be,annotationFrame:Mt,xAccessor:"string"==typeof b?b:"string"==typeof L?L:void 0,yAccessor:"string"==typeof x?x:"string"==typeof j?j:void 0,annotationData:null===(c=Rt.current)||void 0===c?void 0:c.getData(),pointNodes:null===(u=Rt.current)||void 0===u?void 0:u.scene.filter(e=>"point"===e.type),curve:"string"==typeof O?O:void 0,underlayRendered:!0}),(Ke||Ze)&&d.createElement(qe,{width:ft,height:mt,totalWidth:pt[0],totalHeight:pt[1],margin:yt,dimension:null!==(h=null==Ke?void 0:Ke.dimension)&&void 0!==h?h:"xy",scales:jt,onBrush:null!=Ze?Ze:()=>{}}),(null==nt?void 0:nt.showBadge)&&d.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:Nt?"#dc3545":"#28a745",color:"white"})},Nt?"STALE":"LIVE"),on,nn)});Ye.displayName="StreamXYFrame";const Xe=e.createContext(null);function Ve(){return e.useContext(Xe)}function Qe(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 Ue(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}const[Ke,Ze]=me(e=>({selections:new Map,setClause(t,n){e(e=>{const o=new Map(e.selections),r=Ue(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=Ue(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}})}})),[Je,et]=me(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 tt(t){const n=e.useId(),o=t.clientId||n,{name:r}=t,i=Ze(e=>e.selections.get(r)),s=Ze(e=>e.setClause),a=Ze(e=>e.clearClause),l=e.useMemo(()=>!!i&&i.clauses.size>0,[i]);return{predicate:e.useMemo(()=>i&&0!==i.clauses.size?function(e,t){const n=[];for(const[o,r]of e.clauses)"crossfilter"===e.resolution&&o===t||n.push(Qe(r));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(i,o):()=>!0,[i,o]),isActive:l,selectPoints:e.useCallback(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"point",values:new Set(o)};s(r,{clientId:o,type:"point",fields:t})},[o,r,s]),selectInterval:e.useCallback(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"interval",range:o};s(r,{clientId:o,type:"interval",fields:t})},[o,r,s]),clear:e.useCallback(()=>{a(r,o)},[a,r,o]),clientId:o}}function nt(t){const n=t.name||"hover",{fields:o}=t,{predicate:r,isActive:i,selectPoints:s,clear:a}=tt({name:n});return{onHover:e.useCallback(e=>{if(!e)return void a();const t={};for(const n of o){const o=e[n];void 0!==o&&(t[n]=[o])}Object.keys(t).length>0&&s(t)},[o,s,a,n]),predicate:r,isActive:i}}function ot(t){const{name:n,xField:o,yField:r}=t,{predicate:i,isActive:s,selectInterval:a,clear:l}=tt({name:n}),c=o&&r?"xyBrush":o?"xBrush":"yBrush",u=e.useCallback(e=>{if(!e)return void l();const t={};"xyBrush"===c&&Array.isArray(e)&&2===e.length?(o&&(t[o]=[Math.min(e[0][0],e[1][0]),Math.max(e[0][0],e[1][0])]),r&&(t[r]=[Math.min(e[0][1],e[1][1]),Math.max(e[0][1],e[1][1])])):"xBrush"===c&&Array.isArray(e)?o&&(t[o]=[Math.min(...e),Math.max(...e)]):"yBrush"===c&&Array.isArray(e)&&r&&(t[r]=[Math.min(...e),Math.max(...e)]),Object.keys(t).length>0&&a(t)},[c,o,r,a,l]);return{brushInteraction:e.useMemo(()=>({brush:c,during:u,end:u}),[c,u]),predicate:i,isActive:s,clear:l}}const rt=e.createContext(!1);function it({selections:t}){const n=Ze(e=>e.setResolution);return e.useEffect(()=>{for(const[e,o]of Object.entries(t))o.resolution&&n(e,o.resolution)},[t,n]),null}function st({categoryColors:t,interaction:n,selectionName:o,field:r}){const i=Object.entries(t);if(0===i.length)return null;const s=i.map(([e])=>e),a=[{styleFn:e=>({fill:e.color||"#333",stroke:e.color||"#333"}),type:"fill",items:i.map(([e,t])=>({label:e,color:t})),label:""}],l=nt({name:o,fields:[r]}),c=tt({name:o,clientId:"__linked-legend-isolate__"}),[u,h]=e.useState(new Set),[g,p]=e.useState(null),y=e.useRef(c.selectPoints);y.current=c.selectPoints;const f=e.useRef(c.clear);f.current=c.clear,e.useEffect(()=>{"isolate"===n&&(u.size>0?y.current({[r]:Array.from(u)}):f.current())},[n,u,r]);const m=e.useCallback(e=>{"highlight"===n&&(e?(p(e.label),l.onHover({[r]:e.label})):(p(null),l.onHover(null)))},[n,r,l]),v=e.useCallback(e=>{"isolate"===n&&h(t=>{const n=new Set(t);return n.has(e.label)?n.delete(e.label):n.add(e.label),n.size===s.length?new Set:n})},[n,s.length]);return d.createElement("svg",{width:"100%",height:30,style:{display:"block",overflow:"visible"}},d.createElement(Q,{legendGroups:a,title:!1,orientation:"horizontal",height:20,customHoverBehavior:"highlight"===n?m:void 0,customClickBehavior:"isolate"===n?v:void 0,highlightedCategory:g,isolatedCategories:u}))}function at({children:e,selections:t,showLegend:n,legendPosition:o="top",legendInteraction:r="none",legendSelectionName:i="legend",legendField:s="category"}){const a=Ve(),l=void 0!==n?n:!(!a||0>=Object.keys(a).length);return d.createElement(Ke,null,d.createElement(Je,null,t&&d.createElement(it,{selections:t}),d.createElement(rt.Provider,{value:l},l&&"top"===o&&a&&d.createElement(st,{categoryColors:a,interaction:r,selectionName:i,field:s}),e,l&&"bottom"===o&&a&&d.createElement(st,{categoryColors:a,interaction:r,selectionName:i,field:s}))))}function lt({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 ct(e){return e?"string"==typeof e?{name:e}:e:null}function ut(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 ht="#007bff";function dt(e){return"function"==typeof e?e:t=>t[e]}function gt(t,n,o="category10"){const r=Ve();return e.useMemo(()=>{if(n){if(0===t.length)return r&&Object.keys(r).length>0?e=>r[e]||"#999":void 0;if("function"==typeof n){const e=Array.from(new Set(t.map(e=>n(e)+"")));return r&&Object.keys(r).length>0?e=>r[e]||"#999":_(e.map(e=>({_cat:e})),"_cat",o)}if(r&&Object.keys(r).length>0){const e=_(t,n,o);return t=>r[t]||e(t)}return _(t,n,o)}},[t,n,o,r])}function pt({selection:t,linkedHover:n,fallbackFields:o=[],unwrapData:r=!1,onObservation:i,chartType:s,chartId:a}){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}(n,o),c=tt({name:(null==t?void 0:t.name)||"__unused__"}),u=nt({name:(null==l?void 0:l.name)||"hover",fields:(null==l?void 0:l.fields)||o||[]}),h=et(e=>e.pushObservation),d=t?{isActive:c.isActive,predicate:c.predicate}:null,g=e.useCallback(e=>{var t,o;if(n)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]),u.onHover(t)}else u.onHover(null);if(i||h){const n={timestamp:Date.now(),chartType:s||"unknown",chartId:a};if(e){let r=e.data||e.datum||e;Array.isArray(r)&&(r=r[0]);const s=Object.assign(Object.assign({},n),{type:"hover",datum:r||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(o=e.y)&&void 0!==o?o:0});i&&i(s),h&&h(s)}else{const e=Object.assign(Object.assign({},n),{type:"hover-end"});i&&i(e),h&&h(e)}}},[n,u,i,s,a,h]),p=e.useCallback(e=>{var t,n;if(i||h){const o={timestamp:Date.now(),chartType:s||"unknown",chartId:a};if(e){let r=e.data||e.datum||e;Array.isArray(r)&&(r=r[0]);const s=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(s),h&&h(s)}else{const e=Object.assign(Object.assign({},o),{type:"click-end"});i&&i(e),h&&h(e)}}},[i,h,s,a]);return{activeSelectionHook:d,customHoverBehavior:g,customClickBehavior:p}}function yt({data:t,colorBy:n,colorScale:o,showLegend:r,legendPosition:i="right",userMargin:s,defaults:a={top:50,bottom:60,left:70,right:40}}){const l=e.useContext(rt),c=void 0!==r?r:!l&&!!n,u=e.useMemo(()=>{if(c&&n)return lt({data:t,colorBy:n,colorScale:o,getColor:P})},[c,n,t,o]),h=e.useMemo(()=>{const e=Object.assign(Object.assign({},a),s);return u&&("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},[a,s,u,i]);return{legend:u,margin:h,legendPosition:i}}function ft(t,n,o){const[r,i]=e.useState(null),[s,a]=e.useState(new Set),l=e.useCallback(e=>{"highlight"===t&&i(e?e.label:null)},[t]),c=e.useCallback(e=>{"isolate"===t&&a(t=>{const n=new Set(t);return n.has(e.label)?n.delete(e.label):n.add(e.label),n.size===o.length?new Set:n})},[t,o.length]),u=e.useMemo(()=>{if(!t||"none"===t||!n)return null;const e="string"==typeof n?n:null;return"highlight"===t&&null!=r?{isActive:!0,predicate:t=>(e?t[e]:"function"==typeof n?n(t):null)===r}:"isolate"===t&&s.size>0?{isActive:!0,predicate:t=>{const o=e?t[e]:"function"==typeof n?n(t):null;return s.has(o)}}:null},[t,n,r,s]);return{highlightedCategory:"highlight"===t?r:null,isolatedCategories:"isolate"===t?s:new Set,onLegendHover:l,onLegendClick:c,legendSelectionHook:u}}const mt={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 vt(e,t,n){var o,r,i,s,a,l;const c=mt[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 bt={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 xt(e,t){return"function"==typeof t?t(e):e[t]}function kt(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 wt(e={}){const{fields:t,title:n,format:o,style:r={},className:i=""}=e;return e=>{if(!e||"object"!=typeof e)return null;let s;const a=[];if(n){const t=xt(e,n);s=kt(t,o)}if(t&&t.length>0)t.forEach(t=>{let n,r,i;"string"==typeof t?(n=t,r=t,i=o):(n=t.label,r=t.accessor||t.key||"",i=t.format||o);const s=xt(e,r);a.push({label:n,value:kt(s,i)})});else if(!n){const t=["value","y","name","id","label"];for(const n of t)if(void 0!==e[n]){s=kt(e[n],o);break}if(!s){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(s=kt(e[t[0]],o))}}const l=Object.assign(Object.assign({},bt),r);return d.createElement("div",{className:("semiotic-tooltip "+i).trim(),style:l},s&&d.createElement("div",{style:{fontWeight:a.length>0?"bold":"normal"}},s),a.map((e,t)=>d.createElement("div",{key:t,style:{marginTop:0===t&&s?"4px":0}},e.label&&d.createElement("span",null,e.label,": "),e.value)))}}function At(e){if(!0===e)return wt();if("function"==typeof e){const t=e;return e=>{const n=t(!e||"object"!=typeof e.data||null===e.data||"node"!==e.type&&"edge"!==e.type?e:e.data);return null==n?null:d.createElement("div",{className:"semiotic-tooltip",style:bt},n)}}return!1!==e&&void 0!==e&&("object"==typeof e&&null!==e&&("fields"in e||"title"in e)?wt(e):wt())}function St(e){return"string"==typeof e?e:"value"}function Ot(e){return null==e?"–":"number"==typeof e?Math.abs(e)>9999?e.toLocaleString():e+"":e instanceof Date?e.toLocaleDateString():e+""}function Mt(e,t){return"function"==typeof t?t(e):e[t]}function Et(e){const t=e.find(e=>"title"===e.role),n=e.filter(e=>"title"!==e.role);return e=>{const o=e.data;if(!o)return null;const r=t?Ot(Mt(o,t.accessor)):null;return d.createElement("div",{className:"semiotic-tooltip",style:bt},r&&d.createElement("div",{style:{fontWeight:"bold",marginBottom:n.length>0?4:0}},r),n.map((e,t)=>{const n=Ot(Mt(o,e.accessor));return d.createElement("div",{key:t,style:t>0?{marginTop:2}:void 0},d.createElement("span",{style:{opacity:.7}},e.label,": "),d.createElement("span",null,n))}))}}function jt({componentName:e,message:t,diagnosticHint:n,width:o,height:r}){return d.createElement("div",{role:"alert",style:{width:o,height:Math.max(r,120),display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed rgba(128, 128, 128, 0.4)",borderRadius:8,background:"rgba(128, 128, 128, 0.04)",padding:24,boxSizing:"border-box"}},d.createElement("div",{style:{textAlign:"center",maxWidth:400}},d.createElement("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"}},e),d.createElement("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5}},t),n&&d.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}},n)))}class Ct extends d.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:e}=this.props,t=this.state.error;return"function"==typeof e?e(t):void 0!==e?e:d.createElement(jt,{componentName:"ChartErrorBoundary",message:t.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}function Pt(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 _t(e,t,n=3){let o,r=n+1;for(const n of t){const t=Pt(e.toLowerCase(),n.toLowerCase());r>t&&(r=t,o=n)}return r>n?void 0:o}function Lt(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:e}function Bt(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=_t(e,t,3))&&void 0!==n?n:null)}function Nt({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=Lt(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=Bt(i,t),o=n?` Try ${r}="${n}".`:"";return`${e}: ${r} "${i}" not found in data. Available fields: ${t.join(", ")}.${o}`}}}return null}const Ht={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"}},zt={xLabel:{type:"string"},yLabel:{type:"string"},xFormat:{type:"function"},yFormat:{type:"function"}},$t={categoryLabel:{type:"string"},valueLabel:{type:"string"},valueFormat:{type:"function"}},Tt=["linear","monotoneX","monotoneY","step","stepAfter","stepBefore","basis","cardinal","catmullRom"],Wt=["vertical","horizontal"],It={LineChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Ht),zt),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},lineBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:Tt},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({},Ht),zt),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:Tt},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"}})},StackedAreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Ht),zt),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:Tt},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({},Ht),zt),{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({},Ht),zt),{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({},Ht),zt),{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({},Ht),zt),{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({},Ht),zt),{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({},Ht),$t),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Wt},sort:{type:["boolean","string","function"]},barPadding:{type:"number"}})},StackedBarChart:{required:["data","stackBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Ht),$t),{data:{type:"array"},categoryAccessor:{type:["string","function"]},stackBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Wt},normalize:{type:"boolean"},barPadding:{type:"number"}})},GroupedBarChart:{required:["data","groupBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Ht),$t),{data:{type:"array"},categoryAccessor:{type:["string","function"]},groupBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Wt},barPadding:{type:"number"}})},SwarmPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Ht),$t),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Wt},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({},Ht),$t),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Wt},showOutliers:{type:"boolean"},outlierRadius:{type:"number"},categoryPadding:{type:"number"}})},Histogram:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Ht),$t),{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({},Ht),$t),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Wt},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({},Ht),$t),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Wt},sort:{type:["boolean","string","function"]},dotRadius:{type:"number"},categoryPadding:{type:"number"}})},PieChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},Ht),{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({},Ht),{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({},Ht),{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({},Ht),{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:Wt},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({},Ht),{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({},Ht),{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({},Ht),{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({},Ht),{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({},Ht),{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 Ft(e,t){return(Array.isArray(t)?t:[t]).includes(Array.isArray(e)?"array":typeof e)}const Dt=new Set(["TreeDiagram","Treemap","CirclePack","OrbitDiagram"]),Rt=new Set(["ForceDirectedGraph","SankeyDiagram","ChordDiagram"]),Gt=new Set(["BarChart","StackedBarChart","GroupedBarChart","AreaChart","StackedAreaChart"]),qt=new Set(["LineChart","AreaChart","StackedAreaChart"]),Yt=new Set(["BarChart","StackedBarChart","GroupedBarChart"]);function Xt(e,t){const n=[],o=function(e,t){const n=[],o=It[e];if(!o)return{valid:!1,errors:[`Unknown component "${e}". Valid components: ${Object.keys(It).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(!Ft(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=_t(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=Nt({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=Lt(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=Bt(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 It[e]?(function(e,t,n){const o=It[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=It[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){Dt.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){Rt.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=It[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(!Gt.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(!qt.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=It[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(!Yt.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 Vt;const Qt="undefined"!=typeof process&&"production"!==(null===(Vt=process.env)||void 0===Vt?void 0:Vt.NODE_ENV);function Ut({componentName:e,width:t,height:n,chartProps:o,children:r}){return d.createElement(Ct,{fallback:r=>{let i="";if(Qt&&o)try{const t=Xt(e,o);t.ok||(i=t.diagnoses.map(e=>`${"error"===e.severity?"✗":"⚠"} ${e.message}${e.fix?" — Fix: "+e.fix:""}`).join("\n"))}catch(e){}return d.createElement(jt,{componentName:e,message:r.message,diagnosticHint:i,width:t,height:n})}},r)}const Kt={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"},Zt={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function Jt(e,t,n,o){return!1===o||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?d.createElement("div",{style:Object.assign(Object.assign({},Kt),{width:t,height:n})},o||"No data available"):null}function en(e,t,n){if(!e)return null;const o=Math.min(5,Math.floor(n/40)),r=Math.max(8,Math.floor(n/(3*o))),i=Math.max(6,Math.floor(n/(2.5*o))),s=Math.floor((n-(o*(r+i)-i))/2);return d.createElement("div",{style:{width:t,height:n,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"}},Array.from({length:o},(e,n)=>d.createElement("div",{key:n,className:"semiotic-loading-bar",style:Object.assign(Object.assign({},Zt),{position:"absolute",top:s+n*(r+i),left:Math.floor(.1*t),width:30+(37*n+13)%50+"%",height:r,opacity:.5+n%2*.2})})))}function tn(e,t,n,o){if(!Qt)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 nn(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 on=null;function rn(){return nn(this,void 0,void 0,function*(){return on||(on=yield Promise.resolve().then(function(){return En})),on})}const sn=e.forwardRef(function(t,n){var o,r;const i=e.useRef(null);e.useImperativeHandle(n,()=>({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=vt(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:a,margin:l,className:c,xFormat:u,yFormat:h,xAccessor:g="x",yAccessor:p="y",lineBy:y,lineDataAccessor:f="coordinates",colorBy:m,colorScheme:v="category10",curve:b="linear",showPoints:x=!1,pointRadius:k=3,fillArea:w=!1,areaOpacity:A=.3,lineWidth:S=2,tooltip:O,pointIdAccessor:M,annotations:E,directLabel:j,gapStrategy:C="break",anomaly:_,forecast:L,frameProps:B={},selection:N,linkedHover:H,onObservation:z,chartId:$,loading:T,emptyContent:W,legendInteraction:I,legendPosition:F,xScaleType:D,yScaleType:R}=t,G=s.width,q=s.height,Y=s.enableHover,X=s.showGrid,V=s.showLegend,Q=s.title,U=s.xLabel,K=s.yLabel,Z=en(T,G,q);if(Z)return Z;const J=Jt(a,G,q,W);if(J)return J;const ee=a||[];tn("LineChart",ee,"xAccessor",g),tn("LineChart",ee,"yAccessor",p);const te="string"==typeof g?g:"x",ne="string"==typeof p?p:"y",[oe,re]=e.useState(null),[ie,se]=e.useState([]);e.useEffect(()=>{if(!L&&!_)return;let e=!1;return re(null),se([]),L?function(...e){return nn(this,void 0,void 0,function*(){return(yield rn()).buildForecast(...e)})}(ee,te,ne,L,_).then(t=>{e||(re(t),se(t.annotations))}).catch(()=>{e||(re(null),se([]))}):_&&function(...e){return nn(this,void 0,void 0,function*(){return(yield rn()).buildAnomalyAnnotations(...e)})}(_).then(t=>{e||(re(null),se(t))}).catch(()=>{e||se([])}),()=>{e=!0}},[ee,L,_,te,ne]);const ae=oe?oe.processedData:ee,le=L&&!y?"__forecastSegment":y,{activeSelectionHook:ce,customHoverBehavior:ue}=pt({selection:N,linkedHover:H,fallbackFields:m?["string"==typeof m?m:""]:[],onObservation:z,chartType:"LineChart",chartId:$}),he=e.useCallback(e=>{const t="function"==typeof g?g(e):e[g],n="function"==typeof p?p(e):e[p];return null==t||null==n||Number.isNaN(t)||Number.isNaN(n)},[g,p]),de=void 0!==(null===(o=ae[0])||void 0===o?void 0:o[f]),ge=e.useMemo(()=>{if(de)return ae;if(le){const e=ae.reduce((e,t)=>{const n="function"==typeof le?le(t):t[le];if(!e[n]){const t={[f]:[]};"string"==typeof le&&(t[le]=n),e[n]=t}return e[n][f].push(t),e},{});return Object.values(e)}return[{[f]:ae}]},[ae,le,f,de]),{gapProcessedLineData:pe,hasGaps:ye}=e.useMemo(()=>{if("interpolate"===C){let e=!1;const t=[];for(const n of ge){const o=(n[f]||[]).filter(t=>!he(t)||(e=!0,!1));o.length>0&&t.push(Object.assign(Object.assign({},n),{[f]:o}))}return{gapProcessedLineData:t,hasGaps:e}}if("break"===C){let e=!1;const t=[];for(const n of ge){const o=n[f]||[];let r=[],i=0;const s=le&&"string"==typeof le?n[le]:void 0;for(const a of o)if(he(a))e=!0,r.length>0&&(t.push(Object.assign(Object.assign({},n),{[f]: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),{[f]:r}))}return{gapProcessedLineData:t,hasGaps:e}}if("zero"===C){let e=!1;const t="string"==typeof p?p:"y",n=[];for(const o of ge){const r=o[f]||[],i=[];for(const n of r)he(n)?(e=!0,i.push(Object.assign(Object.assign({},n),{[t]:0}))):i.push(n);n.push(Object.assign(Object.assign({},o),{[f]:i}))}return{gapProcessedLineData:n,hasGaps:e}}return{gapProcessedLineData:ge,hasGaps:!1}},[ge,C,f,he,le,p]),fe=gt(ae,m,v),me=e.useMemo(()=>{if(!m)return[];const e=new Set;for(const t of ae){const n="function"==typeof m?m(t):t[m];null!=n&&e.add(n+"")}return Array.from(e)},[ae,m]),ve=ft(I,m,me),be=e.useMemo(()=>ve.legendSelectionHook?ve.legendSelectionHook:ce,[ve.legendSelectionHook,ce]),xe=e.useMemo(()=>e=>{const t={strokeWidth:S};return m?fe&&(t.stroke=P(e,m,fe),w&&(t.fill=t.stroke,t.fillOpacity=A)):(t.stroke=ht,w&&(t.fill=ht,t.fillOpacity=A)),t},[m,fe,S,w,A]),[ke,we]=e.useState(null);e.useEffect(()=>{if(!L)return void we(null);let e=!1;return function(...e){return nn(this,void 0,void 0,function*(){return(yield rn()).createSegmentLineStyle(...e)})}(xe,L).then(t=>{e||we(()=>t)}).catch(()=>{e||we(null)}),()=>{e=!0}},[xe,L]);const Ae=ke||xe,Se=e.useMemo(()=>ut(Ae,be,N),[Ae,be,N]),Oe=e.useMemo(()=>{if(x)return e=>{const t={r:k,fillOpacity:1};return m?fe&&(t.fill=P(e.parentLine||e,m,fe)):t.fill=ht,t}},[x,k,m,fe]),Me=w?"area":"line",Ee="object"==typeof j?j:{},je=Ee.position||"end",Ce=Ee.fontSize||11,Pe=e.useMemo(()=>{var e,t;if(!j||!m)return[];const n="function"==typeof g?g:e=>e[g],o="function"==typeof p?p:e=>e[p],r="function"==typeof m?m:e=>e[m],i=new Map;for(const n of pe){const o=n[f]||[];if(0===o.length)continue;const s="end"===je?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 g?g:"x"]:n(t),["string"==typeof p?p:"y"]:o(t),dx:"end"===je?6:-6,dy:0,color:fe?fe(e):ht,fontSize:Ce}));s.sort((e,t)=>{const n="string"==typeof p?p:"y";return e[n]-t[n]});for(let e=1;s.length>e;e++){const t="string"==typeof p?p:"y",n=s[e-1],o=s[e];Ce+2>Math.abs(o[t]+o.dy-(n[t]+n.dy))&&(o.dy+=Ce+2)}return s},[j,m,fe,pe,f,g,p,je,Ce]),_e=(!j||void 0!==V)&&V,Le=e.useMemo(()=>{if(!j)return s.marginDefaults;const e=Pe.reduce((e,t)=>{var n;const o=((null===(n=t.label)||void 0===n?void 0:n.length)||0)*(.6*Ce);return Math.max(e,o)},0),t=e+10,n="end"===je?"right":"left";return Object.assign(Object.assign({},s.marginDefaults),{[n]:Math.max(s.marginDefaults[n]||0,t)})},[j,Pe,Ce,je,s.marginDefaults]),{legend:Be,margin:Ne,legendPosition:He}=yt({data:pe,colorBy:m,colorScale:fe,showLegend:_e,legendPosition:F,userMargin:l,defaults:Le}),ze=y||m,$e=e.useMemo(()=>Et([{label:U||St(g),accessor:g,role:"x"},{label:K||St(p),accessor:p,role:"y"},...ze?[{label:St(ze),accessor:ze,role:"group"}]:[]]),[g,p,U,K,ze]),Te=Nt({componentName:"LineChart",data:de?(null===(r=ae[0])||void 0===r?void 0:r[f])||[]:a,accessors:{xAccessor:g,yAccessor:p}});if(Te)return d.createElement(jt,{componentName:"LineChart",message:Te,width:G,height:q});const We=e.useMemo(()=>de||le||ye?pe.flatMap(e=>{const t=e[f]||[];return le&&"string"==typeof le?t.map(t=>Object.assign(Object.assign({},t),{[le]:e[le]})):t}):ae,[pe,f,de,le,ae,ye]),Ie=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:Me},null!=a&&{data:We}),{xAccessor:g,yAccessor:p,xScaleType:D,yScaleType:R,groupAccessor:"break"===C&&ye?"_gapSegment":le||void 0,curve:b,lineStyle:Se}),x&&{pointStyle:Oe}),{size:[G,q],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Ne,showAxes:s.showAxes,xLabel:U,yLabel:K,xFormat:u,yFormat:h,enableHover:Y,showGrid:X}),Be&&{legend:Be,legendPosition:He}),I&&"none"!==I&&{legendHoverBehavior:ve.onLegendHover,legendClickBehavior:ve.onLegendClick,legendHighlightedCategory:ve.highlightedCategory,legendIsolatedCategories:ve.isolatedCategories}),Q&&{title:Q}),c&&{className:c}),{tooltipContent:!1===O?()=>null:At(O)||$e}),(H||z)&&{customHoverBehavior:ue}),M&&{pointIdAccessor:M}),((null==E?void 0:E.length)||ie.length||Pe.length)&&{annotations:[...E||[],...ie,...Pe]}),B);return d.createElement(Ut,{componentName:"LineChart",width:G,height:q},d.createElement(Ye,Object.assign({ref:i},Ie)))});sn.displayName="LineChart";const an=e.forwardRef(function(t,n){var o;const r=e.useRef(null);e.useImperativeHandle(n,()=>({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 i=vt(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:s,margin:a,className:l,xFormat:c,yFormat:u,xAccessor:h="x",yAccessor:g="y",areaBy:p,y0Accessor:y,gradientFill:f=!1,lineDataAccessor:m="coordinates",colorBy:v,colorScheme:b="category10",curve:x="monotoneX",areaOpacity:k=.7,showLine:w=!0,lineWidth:A=2,tooltip:S,annotations:O,frameProps:M={},selection:E,linkedHover:j,onObservation:C,chartId:_,loading:L,emptyContent:B,legendInteraction:N,legendPosition:H}=t,z=i.width,$=i.height,T=i.enableHover,W=i.showGrid,I=i.showLegend,F=i.title,D=i.xLabel,R=i.yLabel,G=en(L,z,$);if(G)return G;const q=Jt(s,z,$,B);if(q)return q;const Y=s||[];tn("AreaChart",Y,"xAccessor",h),tn("AreaChart",Y,"yAccessor",g);const{activeSelectionHook:X,customHoverBehavior:V}=pt({selection:E,linkedHover:j,fallbackFields:v?["string"==typeof v?v:""]:[],onObservation:C,chartType:"AreaChart",chartId:_}),Q=void 0!==(null===(o=Y[0])||void 0===o?void 0:o[m]),U=e.useMemo(()=>{if(Q)return Y;if(p){const e=Y.reduce((e,t)=>{const n="function"==typeof p?p(t):t[p];if(!e[n]){const t={[m]:[]};"string"==typeof p&&(t[p]=n),e[n]=t}return e[n][m].push(t),e},{});return Object.values(e)}return[{[m]:Y}]},[Y,p,m,Q]),K=gt(Y,v,b),Z=e.useMemo(()=>{if(!v)return[];const e=new Set;for(const t of Y){const n="function"==typeof v?v(t):t[v];null!=n&&e.add(n+"")}return Array.from(e)},[Y,v]),J=ft(N,v,Z),ee=e.useMemo(()=>J.legendSelectionHook?J.legendSelectionHook:X,[J.legendSelectionHook,X]),te=e.useMemo(()=>e=>{const t={};if(v){if(K){const n=P(e,v,K);t.fill=n,w?(t.stroke=n,t.strokeWidth=A):t.stroke="none"}}else t.fill=ht,w?(t.stroke=ht,t.strokeWidth=A):t.stroke="none";return t.fillOpacity=k,t},[v,K,k,w,A]),ne=e.useMemo(()=>ut(te,ee,E),[te,ee,E]),{legend:oe,margin:re,legendPosition:ie}=yt({data:U,colorBy:v,colorScale:K,showLegend:I,legendPosition:H,userMargin:a,defaults:i.marginDefaults}),se=p||v,ae=e.useMemo(()=>Et([{label:D||St(h),accessor:h,role:"x"},{label:R||St(g),accessor:g,role:"y"},...se?[{label:St(se),accessor:se,role:"group"}]:[]]),[h,g,D,R,se]),le=Nt({componentName:"AreaChart",data:s,accessors:{xAccessor:h,yAccessor:g}});if(le)return d.createElement(jt,{componentName:"AreaChart",message:le,width:z,height:$});const ce=e.useMemo(()=>Q||p?U.flatMap(e=>{const t=e[m]||[];return p&&"string"==typeof p?t.map(t=>Object.assign(Object.assign({},t),{[p]:e[p]})):t}):Y,[U,m,Q,p,Y]),ue=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!=s&&{data:ce}),{xAccessor:h,yAccessor:g,groupAccessor:p||void 0}),y&&{y0Accessor:y}),f&&{gradientFill:f}),{curve:x,lineStyle:ne,size:[z,$],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:re,showAxes:i.showAxes,xLabel:D,yLabel:R,xFormat:c,yFormat:u,enableHover:T,showGrid:W}),oe&&{legend:oe,legendPosition:ie}),N&&"none"!==N&&{legendHoverBehavior:J.onLegendHover,legendClickBehavior:J.onLegendClick,legendHighlightedCategory:J.highlightedCategory,legendIsolatedCategories:J.isolatedCategories}),F&&{title:F}),l&&{className:l}),{tooltipContent:!1===S?()=>null:At(S)||ae}),(j||C)&&{customHoverBehavior:V}),O&&O.length>0&&{annotations:O}),M);return d.createElement(Ut,{componentName:"AreaChart",width:z,height:$},d.createElement(Ye,Object.assign({ref:r},ue)))});an.displayName="AreaChart";const ln=e.forwardRef(function(t,n){var o;const r=e.useRef(null),i=vt(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:s,margin:a,className:l,xFormat:c,yFormat:u,xAccessor:h="x",yAccessor:g="y",areaBy:p,lineDataAccessor:y="coordinates",colorBy:f,colorScheme:m="category10",curve:v="monotoneX",areaOpacity:b=.7,showLine:x=!0,lineWidth:k=2,normalize:w=!1,tooltip:A,annotations:S,frameProps:O={},selection:M,linkedHover:E,onObservation:C,chartId:_,loading:L,emptyContent:B,legendInteraction:N,legendPosition:H}=t,z=i.width,$=i.height,T=i.enableHover,W=i.showGrid,I=i.showLegend,F=i.title,D=i.xLabel,R=i.yLabel,G=en(L,z,$);if(G)return G;const q=Jt(s,z,$,B);if(q)return q;const Y=s||[],X=function({isPushMode:t,colorBy:n,colorScheme:o,showLegend:r,legendPosition:i="right"}){const s=e.useRef(new Set),a=e.useRef([]),[l,c]=e.useState(0),u=e.useCallback(e=>{if(!n)return null;const t="function"==typeof n?n(e):e[n];return null!=t?t+"":null},[n]),h=e.useCallback(e=>{if(!t||!n)return;let o=!1;for(const t of e){if(!t||"object"!=typeof t)continue;const e=u(t);null==e||s.current.has(e)||(s.current.add(e),a.current.push(e),o=!0)}o&&c(e=>e+1)},[t,n,u]),d=e.useCallback(e=>t=>{h([t]),e(t)},[h]),g=e.useCallback(e=>t=>{h(t),e(t)},[h]),p=e.useCallback(()=>{s.current=new Set,a.current=[],c(e=>e+1)},[]),y=e.useMemo(()=>{if(!t||!n||!1===r)return;const e=a.current;if(0===e.length)return;const i=Array.isArray(o)?o:j,s=new Map;for(let t=0;e.length>t;t++)s.set(e[t],i[t%i.length]);const l="string"==typeof n?n:"__streamCat";return lt({data:e.map(e=>({[l]:e})),colorBy:l,colorScale:e=>s.get(e)||"#999",getColor:P})},[t,n,r,o,l]),f=e.useMemo(()=>{if(y)return"right"===i?{right:110}:"left"===i?{left:110}:"top"===i?{top:50}:"bottom"===i?{bottom:80}:{right:110}},[y,i]);return{wrapPush:d,wrapPushMany:g,resetCategories:p,streamingLegend:y,streamingMarginAdjust:f}}({isPushMode:void 0===s,colorBy:f||p,colorScheme:m,showLegend:I,legendPosition:H}),V=e.useCallback(X.wrapPush(e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)}),[X.wrapPush]),Q=e.useCallback(X.wrapPushMany(e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)}),[X.wrapPushMany]);e.useImperativeHandle(n,()=>({push:V,pushMany:Q,clear:()=>{var e;X.resetCategories(),null===(e=r.current)||void 0===e||e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}),[V,Q,X.resetCategories]);const{activeSelectionHook:U,customHoverBehavior:K}=pt({selection:M,linkedHover:E,fallbackFields:f?["string"==typeof f?f:""]:[],onObservation:C,chartType:"StackedAreaChart",chartId:_}),Z=void 0!==(null===(o=Y[0])||void 0===o?void 0:o[y]),J=e.useMemo(()=>{if(Z)return Y;if(p){const e=Y.reduce((e,t)=>{const n="function"==typeof p?p(t):t[p];if(!e[n]){const t={[y]:[]};"string"==typeof p&&(t[p]=n),e[n]=t}return e[n][y].push(t),e},{});return Object.values(e)}return[{[y]:Y}]},[Y,p,y,Z]),ee=gt(Y,f,m),te=e.useMemo(()=>{if(!f)return[];const e=new Set;for(const t of Y){const n="function"==typeof f?f(t):t[f];null!=n&&e.add(n+"")}return Array.from(e)},[Y,f]),ne=ft(N,f,te),oe=e.useMemo(()=>ne.legendSelectionHook?ne.legendSelectionHook:U,[ne.legendSelectionHook,U]),re=e.useMemo(()=>e=>{const t={};if(f&&ee){const n=P(e,f,ee);t.fill=n,x?(t.stroke=n,t.strokeWidth=k):t.stroke="none"}else f||(t.fill=ht,t.stroke=x?ht:"none",x&&(t.strokeWidth=k));return t.fillOpacity=b,t},[f,ee,b,x,k]),ie=e.useMemo(()=>ut(re,oe,M),[re,oe,M]),{legend:se,margin:ae,legendPosition:le}=yt({data:J,colorBy:f,colorScale:ee,showLegend:I,legendPosition:H,userMargin:a,defaults:i.marginDefaults}),ce=X.streamingLegend||se,ue=H||le,he=e.useMemo(()=>{if(X.streamingMarginAdjust){const e=Object.assign({},ae);for(const[t,n]of Object.entries(X.streamingMarginAdjust))n>e[t]&&(e[t]=n);return e}return ae},[ae,X.streamingMarginAdjust]),de=p||f,ge=e.useMemo(()=>Et([{label:D||St(h),accessor:h,role:"x"},{label:R||St(g),accessor:g,role:"y"},...de?[{label:St(de),accessor:de,role:"group"}]:[]]),[h,g,D,R,de]),pe=Nt({componentName:"StackedAreaChart",data:s,accessors:{xAccessor:h,yAccessor:g}});if(pe)return d.createElement(jt,{componentName:"StackedAreaChart",message:pe,width:z,height:$});const ye=e.useMemo(()=>Z||p?J.flatMap(e=>{const t=e[y]||[];return p&&"string"==typeof p?t.map(t=>Object.assign(Object.assign({},t),{[p]:e[p]})):t}):Y,[J,y,Z,p,Y]),fe=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"stackedarea"},null!=s&&{data:ye}),{xAccessor:h,yAccessor:g,groupAccessor:p||void 0,curve:v,normalize:w,lineStyle:ie,size:[z,$],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:he,showAxes:i.showAxes,xLabel:D,yLabel:R,xFormat:c,yFormat:u,enableHover:T,showGrid:W}),ce&&{legend:ce,legendPosition:ue}),N&&"none"!==N&&{legendHoverBehavior:ne.onLegendHover,legendClickBehavior:ne.onLegendClick,legendHighlightedCategory:ne.highlightedCategory,legendIsolatedCategories:ne.isolatedCategories}),F&&{title:F}),l&&{className:l}),{tooltipContent:!1===A?()=>null:At(A)||ge}),(E||C)&&{customHoverBehavior:K}),S&&S.length>0&&{annotations:S}),O);return d.createElement(Ut,{componentName:"StackedAreaChart",width:z,height:$},d.createElement(Ye,Object.assign({ref:r},fe)))});ln.displayName="StackedAreaChart";const cn=e.forwardRef(function(t,n){const o=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=o.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=o.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const r=vt(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:i,margin:s,className:a,xFormat:l,yFormat:c,xAccessor:u="x",yAccessor:h="y",colorBy:g,colorScheme:p="category10",sizeBy:y,sizeRange:f=[3,15],pointRadius:m=5,pointOpacity:v=.8,tooltip:b,marginalGraphics:x,pointIdAccessor:k,annotations:w,frameProps:A={},selection:S,linkedHover:O,linkedBrush:M,onObservation:E,chartId:j,loading:C,emptyContent:_,legendInteraction:B,legendPosition:N}=t,H=r.width,z=r.height,$=r.enableHover,T=r.showGrid,W=r.title,I=r.xLabel,F=r.yLabel,D=i||[],R=function(t){const{data:n,rawData:o,colorBy:r,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}=t,{activeSelectionHook:w,customHoverBehavior:A,customClickBehavior:S}=pt({selection:l,linkedHover:c,fallbackFields:u,unwrapData:h,onObservation:d,chartType:g,chartId:p}),O=gt(n,r,i),M=e.useMemo(()=>{if(!r)return[];const e=new Set;for(const t of n){const n="function"==typeof r?r(t):t[r];null!=n&&e.add(n+"")}return Array.from(e)},[n,r]),E=ft(s,r,M),j=e.useMemo(()=>E.legendSelectionHook?E.legendSelectionHook:w,[E.legendSelectionHook,w]),{legend:C,margin:P,legendPosition:_}=yt({data:n,colorBy:r,colorScale:O,showLegend:y,legendPosition:a,userMargin:f,defaults:m}),L=e.useMemo(()=>{const e={};return C&&(e.legend=C,e.legendPosition=_),s&&"none"!==s&&(e.legendHoverBehavior=E.onLegendHover,e.legendClickBehavior=E.onLegendClick,e.legendHighlightedCategory=E.highlightedCategory,e.legendIsolatedCategories=E.isolatedCategories),e},[C,_,s,E.onLegendHover,E.onLegendClick,E.highlightedCategory,E.isolatedCategories]),B=en(v,x,k),N=B?null:Jt(o,x,k,b);return{colorScale:O,allCategories:M,legendState:E,effectiveSelectionHook:j,activeSelectionHook:w,customHoverBehavior:A,customClickBehavior:S,legend:C,margin:P,legendPosition:_,earlyReturn:B||N||null,legendBehaviorProps:L}}({data:D,rawData:i,colorBy:g,colorScheme:p,legendInteraction:B,legendPosition:N,selection:S,linkedHover:O,fallbackFields:g?["string"==typeof g?g:""]:[],unwrapData:!1,onObservation:E,chartType:"Scatterplot",chartId:j,showLegend:r.showLegend,userMargin:s,marginDefaults:r.marginDefaults,loading:C,emptyContent:_,width:H,height:z}),G=ct(M),q=ot({name:(null==G?void 0:G.name)||"__unused_brush__",xField:(null==G?void 0:G.xField)||("string"==typeof u?u:void 0),yField:(null==G?void 0:G.yField)||("string"==typeof h?h:void 0)}),Y=G?"xyBrush"===q.brushInteraction.brush?"xy":"xBrush"===q.brushInteraction.brush?"x":"y":void 0,X=d.useRef(q.brushInteraction);X.current=q.brushInteraction;const V=e.useCallback(e=>{const t=X.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(R.earlyReturn)return R.earlyReturn;tn("Scatterplot",D,"xAccessor",u),tn("Scatterplot",D,"yAccessor",h);const Q=e.useMemo(()=>{if(!y||0===D.length)return;const e=D.map(e=>"function"==typeof y?y(e):e[y]);return[Math.min(...e),Math.max(...e)]},[D,y]),U=e.useMemo(()=>e=>{const t={fillOpacity:v};return g?R.colorScale&&(t.fill=P(e,g,R.colorScale)):t.fill=ht,t.r=y?L(e,y,f,Q):m,t},[g,R.colorScale,y,f,Q,m,v]),K=e.useMemo(()=>ut(U,R.effectiveSelectionHook,S),[U,R.effectiveSelectionHook,S]),Z=e.useMemo(()=>Et([{label:I||St(u),accessor:u,role:"x"},{label:F||St(h),accessor:h,role:"y"},...g?[{label:St(g),accessor:g,role:"color"}]:[],...y?[{label:St(y),accessor:y,role:"size"}]:[]]),[u,h,I,F,g,y]),J=Nt({componentName:"Scatterplot",data:i,accessors:{xAccessor:u,yAccessor:h}});if(J)return d.createElement(jt,{componentName:"Scatterplot",message:J,width:H,height:z});const ee=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!=i&&{data:D}),{xAccessor:u,yAccessor:h,colorAccessor:g||void 0,sizeAccessor:y||void 0,sizeRange:f,pointStyle:K,colorScheme:p,size:[H,z],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:R.margin,showAxes:r.showAxes,xLabel:I,yLabel:F,xFormat:l,yFormat:c,enableHover:$,showGrid:T}),R.legendBehaviorProps),W&&{title:W}),a&&{className:a}),{tooltipContent:!1===b?()=>null:At(b)||Z}),(O||E)&&{customHoverBehavior:R.customHoverBehavior}),x&&{marginalGraphics:x}),k&&{pointIdAccessor:k}),w&&w.length>0&&{annotations:w}),G&&{brush:{dimension:Y},onBrush:V}),A);return d.createElement(Ut,{componentName:"Scatterplot",width:H,height:z},d.createElement(Ye,Object.assign({ref:o},ee)))});function un(e,t){return r.interpolateViridis(1===t?.5:e/(t-1))}cn.displayName="Scatterplot";const hn=e.forwardRef(function(t,n){const o=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=o.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=o.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const r=vt(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:i,className:s,xFormat:a,yFormat:l,xAccessor:c="x",yAccessor:u="y",orderAccessor:h,orderLabel:g,pointRadius:p=4,tooltip:y,pointIdAccessor:f,annotations:m,frameProps:v={},selection:b,linkedHover:x,onObservation:k,chartId:w,loading:A,emptyContent:S,legendInteraction:O}=t,M=r.width,E=r.height,j=r.enableHover,C=r.showGrid,P=r.title,_=r.xLabel,L=r.yLabel,B=i||[],N=e.useMemo(()=>{if(!h||0===B.length)return B;const e="function"==typeof h?h:e=>e[h];return[...B].sort((t,n)=>{const o=e(t),r=e(n);return(o instanceof Date?o.getTime():+o)-(r instanceof Date?r.getTime():+r)})},[B,h]);tn("ConnectedScatterplot",N,"xAccessor",c),tn("ConnectedScatterplot",N,"yAccessor",u);const{activeSelectionHook:H,customHoverBehavior:z}=pt({selection:b,linkedHover:x,fallbackFields:[],onObservation:k,chartType:"ConnectedScatterplot",chartId:w}),$=ft(O,void 0,[]),T=e.useMemo(()=>$.legendSelectionHook?$.legendSelectionHook:H,[$.legendSelectionHook,H]),W=e.useMemo(()=>(e,t)=>{var n,o;const r=t.filter(e=>"point"===e.type);if(2>r.length)return;const i=null==T?void 0:T.isActive,s=null==T?void 0:T.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=un(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=p+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=p,e.globalAlpha=g,e.stroke()}e.globalAlpha=1},[p,T]),I=e.useMemo(()=>[W],[W]),F=e.useRef({idx:0,total:0}),D=e.useMemo(()=>{const e="function"==typeof c?c:e=>e[c],t="function"==typeof u?u:e=>e[u];return n=>{var r,i;const s=F.current;if(0===s.idx){const n=null!==(i=null===(r=o.current)||void 0===r?void 0:r.getData())&&void 0!==i?i:N;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?un(l,a):"#6366f1",stroke:"white",strokeWidth:1,r:p,fillOpacity:1}}},[p,N.length,c,u]),R=e.useMemo(()=>ut(D,T,b),[D,T,b]),G=Object.assign({top:50,right:40,bottom:60,left:70},t.margin),q=g||("string"==typeof h?h:"Order"),Y=e.useMemo(()=>Et([{label:_||St(c),accessor:c,role:"x"},{label:L||St(u),accessor:u,role:"y"},...h?[{label:q,accessor:h,role:"group"}]:[]]),[c,u,_,L,h,q]),X=Nt({componentName:"ConnectedScatterplot",data:i,accessors:{xAccessor:c,yAccessor:u}}),V=en(A,M,E);if(V)return V;const Q=Jt(i,M,E,S);if(Q)return Q;if(X)return d.createElement(jt,{componentName:"ConnectedScatterplot",message:X,width:M,height:E});const U=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter"},null!=i&&{data:N}),{xAccessor:c,yAccessor:u,pointStyle:R,size:[M,E],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:G,showAxes:r.showAxes,xLabel:_,yLabel:L,xFormat:a,yFormat:l,enableHover:j,showGrid:C}),P&&{title:P}),s&&{className:s}),{tooltipContent:!1===y?()=>null:At(y)||Y}),(x||k)&&{customHoverBehavior:z}),f&&{pointIdAccessor:f}),{canvasPreRenderers:I}),m&&m.length>0&&{annotations:m}),v);return d.createElement(Ut,{componentName:"ConnectedScatterplot",width:M,height:E},d.createElement(Ye,Object.assign({ref:o},U)))});hn.displayName="ConnectedScatterplot";const dn=e.forwardRef(function(t,n){const o=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=o.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=o.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const r=vt(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:i,margin:s,className:a,xFormat:l,yFormat:c,xAccessor:u="x",yAccessor:h="y",sizeBy:g,sizeRange:p=[5,40],colorBy:y,colorScheme:f="category10",bubbleOpacity:m=.6,bubbleStrokeWidth:v=1,bubbleStrokeColor:b="white",tooltip:x,marginalGraphics:k,pointIdAccessor:w,annotations:A,frameProps:S={},selection:O,linkedHover:M,linkedBrush:E,onObservation:j,chartId:C,loading:_,emptyContent:B,legendInteraction:N,legendPosition:H}=t,z=r.width,$=r.height,T=r.enableHover,W=r.showGrid,I=r.showLegend,F=r.title,D=r.xLabel,R=r.yLabel,G=en(_,z,$);if(G)return G;const q=Jt(i,z,$,B);if(q)return q;const Y=i||[],{activeSelectionHook:X,customHoverBehavior:V}=pt({selection:O,linkedHover:M,fallbackFields:y?["string"==typeof y?y:""]:[],onObservation:j,chartType:"BubbleChart",chartId:C}),Q=ct(E);ot({name:(null==Q?void 0:Q.name)||"__unused_brush__",xField:(null==Q?void 0:Q.xField)||("string"==typeof u?u:void 0),yField:(null==Q?void 0:Q.yField)||("string"==typeof h?h:void 0)});const U=gt(Y,y,f),K=e.useMemo(()=>{if(!y)return[];const e=new Set;for(const t of Y){const n="function"==typeof y?y(t):t[y];null!=n&&e.add(n+"")}return Array.from(e)},[Y,y]),Z=ft(N,y,K),J=e.useMemo(()=>Z.legendSelectionHook?Z.legendSelectionHook:X,[Z.legendSelectionHook,X]),ee=e.useMemo(()=>{const e=Y.map(e=>"function"==typeof g?g(e):e[g]);return[Math.min(...e),Math.max(...e)]},[Y,g]),te=e.useMemo(()=>e=>{const t={fillOpacity:m,strokeWidth:v,stroke:b};return y?U&&(t.fill=P(e,y,U)):t.fill=ht,t.r=L(e,g,p,ee),t},[y,U,g,p,ee,m,v,b]),ne=e.useMemo(()=>ut(te,J,O),[te,J,O]),{legend:oe,margin:re,legendPosition:ie}=yt({data:Y,colorBy:y,colorScale:U,showLegend:I,legendPosition:H,userMargin:s,defaults:r.marginDefaults}),se=e.useMemo(()=>Et([{label:D||St(u),accessor:u,role:"x"},{label:R||St(h),accessor:h,role:"y"},{label:St(g),accessor:g,role:"size"},...y?[{label:St(y),accessor:y,role:"color"}]:[]]),[u,h,D,R,g,y]),ae=Nt({componentName:"BubbleChart",data:i,accessors:{xAccessor:u,yAccessor:h},requiredProps:{sizeBy:g}});if(ae)return d.createElement(jt,{componentName:"BubbleChart",message:ae,width:z,height:$});const le=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!=i&&{data:Y}),{xAccessor:u,yAccessor:h,colorAccessor:y||void 0,sizeAccessor:g,sizeRange:p,pointStyle:ne,colorScheme:f,size:[z,$],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:re,showAxes:r.showAxes,xLabel:D,yLabel:R,xFormat:l,yFormat:c,enableHover:T,showGrid:W}),oe&&{legend:oe,legendPosition:ie}),N&&"none"!==N&&{legendHoverBehavior:Z.onLegendHover,legendClickBehavior:Z.onLegendClick,legendHighlightedCategory:Z.highlightedCategory,legendIsolatedCategories:Z.isolatedCategories}),F&&{title:F}),a&&{className:a}),{tooltipContent:!1===x?()=>null:At(x)||se}),(M||j)&&{customHoverBehavior:V}),k&&{marginalGraphics:k}),w&&{pointIdAccessor:w}),A&&A.length>0&&{annotations:A}),S);return d.createElement(Ut,{componentName:"BubbleChart",width:z,height:$},d.createElement(Ye,Object.assign({ref:o},le)))});dn.displayName="BubbleChart";const gn=e.forwardRef(function(t,n){const i=e.useRef(null);e.useImperativeHandle(n,()=>({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=vt(t.mode,{width:t.width,height:t.height,showGrid:void 0,enableHover:t.enableHover,showLegend:void 0,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:a,margin:l,className:c,xAccessor:u="x",yAccessor:h="y",valueAccessor:g="value",xFormat:p,yFormat:y,colorScheme:f="blues",customColorScale:m,showValues:v=!1,valueFormat:b,cellBorderColor:x="#fff",cellBorderWidth:k=1,tooltip:w,annotations:A,frameProps:S={},selection:O,linkedHover:M,onObservation:E,chartId:j,loading:C,emptyContent:P,showLegend:_,legendPosition:L,legendInteraction:B}=t,N=s.width,H=s.height,z=s.enableHover,$=s.title,T=s.xLabel,W=s.yLabel,I=en(C,N,H);if(I)return I;const F=Jt(a,N,H,P);if(F)return F;const D=a||[],R=null!=_&&_,G=null!=L?L:"right",{margin:q}=yt({data:D,colorBy:R?"value":void 0,colorScale:void 0,showLegend:R,legendPosition:G,userMargin:l,defaults:s.marginDefaults}),{activeSelectionHook:Y,customHoverBehavior:X}=pt({selection:O,linkedHover:M,fallbackFields:[],onObservation:E,chartType:"Heatmap",chartId:j}),V=ft(B,void 0,[]),Q=e.useMemo(()=>V.legendSelectionHook?V.legendSelectionHook:Y,[V.legendSelectionHook,Y]),U=e.useMemo(()=>"function"==typeof g?e=>g(e):e=>e[g],[g]),K=e.useMemo(()=>{const e=D.map(U);return[Math.min(...e),Math.max(...e)]},[D,U]),Z=e.useMemo(()=>"custom"===f&&m?m:o.scaleSequential({blues:r.interpolateBlues,reds:r.interpolateReds,greens:r.interpolateGreens,viridis:r.interpolateViridis}[f]||r.interpolateBlues).domain(K),[f,m,K]);e.useMemo(()=>{const e=dt(u),t=dt(h);return{xBinCount:new Set(D.map(e)).size,yBinCount:new Set(D.map(t)).size}},[D,u,h]),e.useMemo(()=>({coordinates:D}),[D]);const J=e.useMemo(()=>e=>{const t=U(e);return{fill:Z(t),stroke:x,strokeWidth:k}},[U,Z,x,k]);e.useMemo(()=>ut(J,Q,O),[J,Q,O]);const ee=e.useMemo(()=>Et([{label:T||St(u),accessor:u,role:"x"},{label:W||St(h),accessor:h,role:"y"},{label:St(g),accessor:g,role:"value"}]),[u,h,T,W,g]),te=Nt({componentName:"Heatmap",data:a,accessors:{xAccessor:u,yAccessor:h,valueAccessor:g}});if(te)return d.createElement(jt,{componentName:"Heatmap",message:te,width:N,height:H});const ne=e.useMemo(()=>{if(R)return{gradient:{colorFn:e=>Z(e),domain:K,label:"string"==typeof g?g:"value",format:b}}},[R,Z,K,g,b]),oe=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"heatmap"},null!=a&&{data:D}),{xAccessor:u,yAccessor:h,valueAccessor:g,colorScheme:"custom"!==f?f:void 0,showValues:v,heatmapValueFormat:b,size:[N,H],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:q,showAxes:s.showAxes,xLabel:T,yLabel:W,xFormat:p,yFormat:y,enableHover:z}),ne&&{legend:ne,legendPosition:G}),$&&{title:$}),c&&{className:c}),{tooltipContent:!1===w?()=>null:At(w)||ee}),(M||E)&&{customHoverBehavior:X}),A&&A.length>0&&{annotations:A}),S);return d.createElement(Ut,{componentName:"Heatmap",width:N,height:H},d.createElement(Ye,Object.assign({ref:i},oe)))});gn.displayName="Heatmap";const pn="__splomIdx",yn={top:4,bottom:4,left:4,right:4};function fn({frameRef:o,cellSize:r,onBrush:i}){const s=e.useRef(null),a=r-yn.left-yn.right,l=r-yn.top-yn.bottom;return e.useEffect(()=>{if(!s.current)return;const e=n.select(s.current).select(".brush-g"),r=t.brush().extent([[0,0],[a,l]]).on("brush end",e=>{var t;const n=null===(t=o.current)||void 0===t?void 0:t.getScales();if(!n)return;if(!e.selection)return void i(null);const[[r,s],[a,l]]=e.selection,c=[[n.x.invert(r),n.y.invert(s)],[n.x.invert(a),n.y.invert(l)]];i(c)});return e.call(r),e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{r.on("brush end",null)}},[a,l,o,i]),d.createElement("svg",{ref:s,width:r,height:r,style:{position:"absolute",top:0,left:0}},d.createElement("g",{className:"brush-g",transform:`translate(${yn.left},${yn.top})`}))}function mn({data:t,xField:n,yField:o,cellSize:r,pointRadius:i,pointOpacity:s,colorBy:a,colorScale:l,brushSelectionName:c,hoverSelectionName:u,unselectedOpacity:h,mode:g,onPointHover:p}){const y=e.useRef(null),f=tt({name:c,clientId:`splom-${n}-${o}`}),m=ot({name:c,xField:n,yField:o}),v=tt({name:u,clientId:"splom-hover-source"}),b=v.selectPoints,x=e.useCallback(e=>{e?m.brushInteraction.during(e):m.brushInteraction.end(null)},[m.brushInteraction]),k=e.useCallback(e=>{if(!e)return void(null==p||p(null));const t=e.data,n=null==t?void 0:t[pn];void 0!==n&&(b({[pn]:[n]}),null==p||p(t,e.x+yn.left,e.y+yn.top))},[b,p]),w=e.useCallback(e=>{const t={opacity:s,r:i};return t.fill=a?P(e,a,l):ht,"hover"===g?v.isActive&&v.predicate(e)?(t.opacity=1,t.r=2.5*i,t.stroke="#333",t.strokeWidth=1.5):v.isActive&&(t.opacity=.6*s):f.isActive&&!f.predicate(e)&&(t.opacity=h),t},[a,l,s,i,g,f.isActive,f.predicate,v.isActive,v.predicate,h]);return d.createElement("div",{style:{position:"relative",width:r,height:r}},d.createElement(Ye,{ref:y,chartType:"scatter",data:t,size:[r,r],xAccessor:n,yAccessor:o,pointStyle:w,margin:yn,showAxes:!1,enableHover:"hover"===g,customHoverBehavior:"hover"===g?k:void 0,tooltipContent:"hover"===g?()=>null:void 0}),"brush"===g&&d.createElement(fn,{frameRef:y,cellSize:r,xField:n,yField:o,onBrush:x}))}function vn({data:t,field:n,label:o,cellSize:r,bins:i,colorBy:s,colorScale:a,brushSelectionName:l,hoverSelectionName:c,mode:u}){const h=tt({name:l,clientId:"splom-diag-"+n}),g=tt({name:c,clientId:`splom-diag-${n}-hover`}),p="hover"===u?g:h,y=p.isActive,f=p.predicate,m=e.useMemo(()=>{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),a=(Math.max(...e)-o)/i||1,l="string"==typeof s?s: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(i).fill(0),d=Array(i).fill(0),g=Array.from({length:i},()=>Array(c.length).fill(0)),p=Array.from({length:i},()=>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)/a),i-1);if(h[r]++,y&&!f(e)||d[r]++,l){const t=u.get(e[l]+"");void 0!==t&&(g[r][t]++,y&&!f(e)||p[r][t]++)}}const m=Math.max(...h,1),v=g.map((e,t)=>{let n=0;return e.map((e,o)=>{const s=e/m*(r-24),a={x:t/i*r,w:r/i-1,h:s,y0:n,category:c[o]};return n+=s,a})}),b=p.map((e,t)=>{let n=0;return e.map((e,o)=>{const s=e/m*(r-24),a={x:t/i*r,w:r/i-1,h:s,y0:n,category:c[o]};return n+=s,a})});return{bars:h.map((e,t)=>({x:t/i*r,w:r/i-1,h:e/m*(r-24),count:e})),selectedBars:d.map((e,t)=>({x:t/i*r,w:r/i-1,h:e/m*(r-24),count:e})),categoryBars:v,selectedCategoryBars:b,max:m,categories:c}},[t,n,i,r,y,f,s]);return d.createElement("svg",{width:r,height:r,style:{overflow:"hidden"}},d.createElement("text",{x:r/2,y:14,textAnchor:"middle",fontSize:11,fontWeight:"bold",fill:"#333"},o),m.categories.length>0?m.categoryBars.map((e,t)=>e.map((e,n)=>d.createElement("rect",{key:`bg-${t}-${n}`,x:e.x,y:r-e.y0-e.h,width:Math.max(e.w,1),height:e.h,fill:a?a(e.category):ht,opacity:y?.3:.6}))):m.bars.map((e,t)=>d.createElement("rect",{key:"bg-"+t,x:e.x,y:r-e.h,width:Math.max(e.w,1),height:e.h,fill:ht,opacity:y?.3:.6})),y&&(m.categories.length>0?m.selectedCategoryBars.map((e,t)=>e.map((e,n)=>d.createElement("rect",{key:`sel-${t}-${n}`,x:e.x,y:r-e.y0-e.h,width:Math.max(e.w,1),height:e.h,fill:a?a(e.category):ht,opacity:.7}))):m.selectedBars.map((e,t)=>d.createElement("rect",{key:"sel-"+t,x:e.x,y:r-e.h,width:Math.max(e.w,1),height:e.h,fill:ht,opacity:.7}))))}function bn({label:e,cellSize:t}){return d.createElement("svg",{width:t,height:t},d.createElement("text",{x:t/2,y:t/2,textAnchor:"middle",dominantBaseline:"middle",fontSize:12,fontWeight:"bold",fill:"#333"},e))}function xn(t){const{data:n,fields:o,fieldLabels:r={},colorBy:i,colorScheme:s="category10",cellSize:a=150,cellGap:l=4,pointRadius:c=2,pointOpacity:u=.5,diagonal:h="histogram",histogramBins:g=20,brushMode:p="crossfilter",hoverMode:y=!0,unselectedOpacity:f=.1,showGrid:m=!1,tooltip:v,showLegend:b,idAccessor:x,className:k,onObservation:w,chartId:A}=t,S="splom",O="splom-hover",M=y?"hover":p?"brush":"hover",E=Ze(e=>e.clearSelection),[j,C]=e.useState(null),P=e.useCallback(()=>{E(O),C(null)},[E,O]),_=e.useMemo(()=>(n||[]).map((e,t)=>void 0!==e[pn]?e:Object.assign(Object.assign({},e),{[pn]:t})),[n]),L=gt(_,i,s),B=void 0!==b?b:!!i,N=e.useMemo(()=>{if(!B||!i)return null;const e="string"==typeof i?i:null;return e?[...new Set(_.map(t=>t[e]))].map(e=>({label:e+"",color:L?L(e+""):ht})):null},[B,i,_,L]),H=e.useMemo(()=>({display:"grid",gridTemplateColumns:"40px "+o.map(()=>a+"px").join(" "),gridTemplateRows:o.map(()=>a+"px").join(" ")+" 40px",gap:l+"px",width:"fit-content"}),[o,a,l,40]);return d.createElement("div",{className:k,style:{position:"relative"}},N&&d.createElement("div",{style:{display:"flex",gap:12,marginBottom:8,flexWrap:"wrap"}},N.map(e=>d.createElement("div",{key:e.label,style:{display:"flex",alignItems:"center",gap:4}},d.createElement("span",{style:{display:"inline-block",width:10,height:10,borderRadius:"50%",backgroundColor:e.color}}),d.createElement("span",{style:{fontSize:11}},e.label)))),d.createElement("div",{style:H,onMouseLeave:"hover"===M?P:void 0},o.map((e,t)=>d.createElement(d.Fragment,{key:"row-"+e},d.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",writingMode:"vertical-rl",transform:"rotate(180deg)",fontSize:11,fontWeight:"bold",color:"#333"}},r[e]||e),o.map((n,o)=>t===o?"label"===h?d.createElement(bn,{key:"diag-"+e,label:r[e]||e,cellSize:a}):d.createElement(vn,{key:"diag-"+e,data:_,field:e,label:r[e]||e,cellSize:a,bins:g,colorBy:i,colorScale:L,brushSelectionName:S,hoverSelectionName:O,unselectedOpacity:f,mode:M}):d.createElement(mn,{key:`cell-${e}-${n}`,data:_,xField:n,yField:e,fieldLabels:r,cellSize:a,pointRadius:c,pointOpacity:u,colorBy:i,colorScale:L,brushSelectionName:S,hoverSelectionName:O,unselectedOpacity:f,showGrid:m,tooltip:v,mode:M,onPointHover:"hover"===M?(r,i,s)=>{r?(C({datum:r,xField:n,yField:e,colIndex:o,rowIndex:t,px:null!=i?i:0,py:null!=s?s:0}),w&&w({type:"hover",datum:r,x:null!=i?i:0,y:null!=s?s:0,timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:A})):(C(null),w&&w({type:"hover-end",timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:A}))}:void 0})))),d.createElement("div",null)," ",o.map(e=>d.createElement("div",{key:"col-label-"+e,style:{display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:"bold",color:"#333"}},r[e]||e))),j&&"hover"===M&&(()=>{const e=j.datum,t=r[j.xField]||j.xField,n=r[j.yField]||j.yField,o=i?"function"==typeof i?i(e):e[i]:null,s=x?"function"==typeof x?x(e):e[x]:"Row "+e[pn];return d.createElement("div",{style:{position:"absolute",left:40+j.colIndex*(a+l)+j.px,top:j.rowIndex*(a+l)+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}},d.createElement("div",{style:{fontWeight:"bold",marginBottom:2}},s+""),d.createElement("div",null,t,": ",null!=e[j.xField]?Number(e[j.xField]).toFixed(1):"–"),d.createElement("div",null,n,": ",null!=e[j.yField]?Number(e[j.yField]).toFixed(1):"–"),null!=o&&d.createElement("div",{style:{opacity:.8}},"string"==typeof i?i:"group",": ",o+""))})())}function kn(e){const{brushMode:t="crossfilter",hoverMode:n=!0}=e,o={};return!n&&t&&(o.splom={resolution:t}),n&&(o["splom-hover"]={resolution:"union"}),d.createElement(at,{selections:o},d.createElement(xn,Object.assign({},e)))}function wn({width:o,height:r,margin:i,scales:s,brushDirection:a,extent:l,onBrush:c}){const u=e.useRef(null),h=e.useRef(null),g=e.useRef(!1),p=o+i.left+i.right,y=r+i.top+i.bottom;return e.useEffect(()=>{if(!u.current||!s)return;const e=n.select(u.current).select(".brush-group"),i="x"===a?t.brushX().extent([[0,0],[o,r]]):t.brushY().extent([[0,0],[o,r]]);return i.on("brush end",e=>{if(g.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(i),h.current=i,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.2).attr("stroke","steelblue").attr("stroke-width",1),()=>{i.on("brush end",null)}},[s,o,r,a,c]),e.useEffect(()=>{if(!h.current||!s||!u.current)return;const e=n.select(u.current).select(".brush-group"),t="x"===a?s.x:s.y;if(g.current=!0,l){const n=[t(l[0]),t(l[1])];e.call(h.current.move,n)}else e.call(h.current.move,null);g.current=!1},[l,s,a]),d.createElement("svg",{ref:u,width:p,height:y,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},d.createElement("g",{className:"brush-group",transform:`translate(${i.left},${i.top})`}))}function An(t){var n,o;const{data:r,width:i=600,height:s=400,margin:a,className:l,title:c,xLabel:u,yLabel:h,xFormat:g,yFormat:p,xAccessor:y="x",yAccessor:f="y",lineBy:m,lineDataAccessor:v="coordinates",colorBy:b,colorScheme:x="category10",curve:k="linear",lineWidth:w=2,fillArea:A=!1,areaOpacity:S=.3,showPoints:O=!1,pointRadius:M=3,enableHover:E=!0,showGrid:j=!1,showLegend:C,legendPosition:_,tooltip:L,minimap:B={},renderBefore:N=!1,onBrush:H,brushExtent:z,frameProps:$={},loading:T,emptyContent:W}=t,I=en(T,i,s);if(I)return I;const F=Jt(r,i,s,W);if(F)return F;const D=r||[],[R,G]=e.useState(null),q=null!=z?z:R,Y=e.useCallback(e=>{z||G(e),null==H||H(e)},[z,H]),X=e.useRef(null),[V,Q]=e.useState(null);e.useEffect(()=>{const e=()=>{var t,n;const o=null===(n=null===(t=X.current)||void 0===t?void 0:t.getScales)||void 0===n?void 0:n.call(t);o?Q(o):requestAnimationFrame(e)};requestAnimationFrame(e)},[r]);const U=void 0!==(null===(n=D[0])||void 0===n?void 0:n[v]),K=e.useMemo(()=>{if(U)return D;if(m){const e=D.reduce((e,t)=>{const n="function"==typeof m?m(t):t[m];if(!e[n]){const t={[v]:[]};"string"==typeof m&&(t[m]=n),e[n]=t}return e[n][v].push(t),e},{});return Object.values(e)}return[{[v]:D}]},[D,m,v,U]),Z=e.useMemo(()=>U||m?K.flatMap(e=>{const t=e[v]||[];return m&&"string"==typeof m?t.map(t=>Object.assign(Object.assign({},t),{[m]:e[m]})):t}):D,[K,v,U,m,D]),J=gt(D,b,x),ee=e.useMemo(()=>e=>{const t={strokeWidth:w};return t.stroke=b?P(e,b,J):ht,A&&(t.fill=t.stroke,t.fillOpacity=S),t},[b,J,w,A,S]),te=e.useMemo(()=>B.lineStyle?B.lineStyle:e=>{const t={strokeWidth:1};return t.stroke=b?P(e,b,J):ht,t},[b,J,B.lineStyle]),ne=e.useMemo(()=>{if(O)return e=>{const t={r:M,fillOpacity:1};return t.fill=b?P(e.parentLine||e,b,J):ht,t}},[O,M,b,J]),{legend:oe,margin:re,legendPosition:ie}=yt({data:K,colorBy:b,colorScale:J,showLegend:C,legendPosition:_,userMargin:a}),se=B.height||60,ae=e.useMemo(()=>{var e,t,n,o,r,i,s,a;return{top:null!==(t=null===(e=B.margin)||void 0===e?void 0:e.top)&&void 0!==t?t:0,bottom:null!==(o=null===(n=B.margin)||void 0===n?void 0:n.bottom)&&void 0!==o?o:20,left:null!==(i=null===(r=B.margin)||void 0===r?void 0:r.left)&&void 0!==i?i:re.left,right:null!==(a=null===(s=B.margin)||void 0===s?void 0:s.right)&&void 0!==a?a:re.right}},[B.margin,re]),le=B.brushDirection||"x",ce=Nt({componentName:"MinimapChart",data:r,accessors:{xAccessor:y,yAccessor:f}});if(ce)return d.createElement(jt,{componentName:"MinimapChart",message:ce,width:i,height:s});const ue=A?"area":"line",he=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:ue,data:Z,xAccessor:y,yAccessor:f,groupAccessor:m||void 0,curve:k,lineStyle:ee},O&&{pointStyle:ne}),{size:[i,s],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:re,showAxes:!0,xLabel:u,yLabel:h,xFormat:g,yFormat:p,enableHover:E,showGrid:j}),oe&&{legend:oe,legendPosition:ie}),c&&{title:c}),L&&{tooltipContent:At(L)||void 0}),q&&{xExtent:q}),$),de={chartType:ue,data:Z,xAccessor:y,yAccessor:f,groupAccessor:m||void 0,curve:k,lineStyle:te,size:[i,se+ae.top+ae.bottom],margin:ae,showAxes:null!==(o=B.showAxes)&&void 0!==o&&o,background:B.background,enableHover:!1},ge=d.createElement("div",{key:"minimap",style:{position:"relative",width:i,overflow:"hidden"}},d.createElement(Ye,Object.assign({ref:X},de)),d.createElement(wn,{width:i-ae.left-ae.right,height:se,margin:ae,scales:V,brushDirection:le,extent:q,onBrush:Y})),pe=d.createElement("div",{key:"main",style:{overflow:"hidden"}},d.createElement(Ye,Object.assign({},he)));return d.createElement(Ut,{componentName:"MinimapChart",width:i,height:s},d.createElement("div",{className:"minimap-chart"+(l?" "+l:"")},N?ge:pe,N?pe:ge))}kn.displayName="ScatterplotMatrix",An.displayName="MinimapChart";const Sn=e.forwardRef(function(t,n){const o=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=o.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=o.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const r=vt(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:i,margin:s,className:a,xFormat:l,yFormat:c,xAccessor:u="x",yAccessor:h="y",xCenter:g,yCenter:p,quadrants:y,centerlineStyle:f={},showQuadrantLabels:m=!0,quadrantLabelSize:v=12,colorBy:b,colorScheme:x="category10",sizeBy:k,sizeRange:w=[3,15],pointRadius:A=5,pointOpacity:S=.8,tooltip:O,pointIdAccessor:M,annotations:E,frameProps:j={},selection:C,linkedHover:_,onObservation:B,chartId:N,loading:H,emptyContent:z,legendInteraction:$,legendPosition:T}=t,W=r.width,I=r.height,F=r.enableHover,D=r.showGrid,R=r.showLegend,G=r.title,q=r.xLabel,Y=r.yLabel,X=en(H,W,I);if(X)return X;const V=Jt(i,W,I,z);if(V)return V;const Q=i||[];tn("QuadrantChart",Q,"xAccessor",u),tn("QuadrantChart",Q,"yAccessor",h);const{activeSelectionHook:U,customHoverBehavior:K}=pt({selection:C,linkedHover:_,fallbackFields:"string"==typeof b?[b]:[],onObservation:B,chartType:"QuadrantChart",chartId:N}),Z=gt(Q,b,x),J=e.useMemo(()=>{if(!b)return[];const e=new Set;for(const t of Q){const n="function"==typeof b?b(t):t[b];null!=n&&e.add(n+"")}return Array.from(e)},[Q,b]),ee=ft($,b,J),te=e.useMemo(()=>ee.legendSelectionHook?ee.legendSelectionHook:U,[ee.legendSelectionHook,U]),ne=e.useMemo(()=>{if(!Q.length)return;const e="function"==typeof u?u:e=>+e[u],t="function"==typeof h?h:e=>+e[h];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!=g&&isFinite(g)&&(n>g&&(n=g),g>o&&(o=g)),null!=p&&isFinite(p)&&(r>p&&(r=p),p>i&&(i=p)),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,u,h,g,p]),oe=e.useMemo(()=>{if(!k||0===Q.length)return;const e=Q.map(e=>"function"==typeof k?k(e):e[k]).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0!==e.length?[Math.min(...e),Math.max(...e)]:void 0},[Q,k]),re=e.useMemo(()=>"function"==typeof u?u:e=>+e[u],[u]),ie=e.useMemo(()=>"function"==typeof h?h:e=>+e[h],[h]),se=e.useMemo(()=>e=>{const t={fillOpacity:S};if(b)Z&&(t.fill=P(e,b,Z));else{const n=re(e),o=ie(e),r=null!=g?n>=g:void 0,i=null!=p?o>=p:void 0;t.fill=void 0===i||void 0===r?ht:i&&r?y.topRight.color:i&&!r?y.topLeft.color:!i&&r?y.bottomRight.color:y.bottomLeft.color}return t.r=k?L(e,k,w,oe):A,t},[b,Z,k,w,oe,A,S,re,ie,g,p,y]),ae=e.useMemo(()=>ut(se,te,C),[se,te,C]),{legend:le,margin:ce,legendPosition:ue}=yt({data:Q,colorBy:b,colorScale:Z,showLegend:R,legendPosition:T,userMargin:s,defaults:r.marginDefaults}),he=e.useMemo(()=>{if(!Q.length)return;const e=new Set;"string"==typeof u&&e.add(u),"string"==typeof h&&e.add(h),"string"==typeof b&&e.add(b),"string"==typeof k&&e.add(k);const t=Q[0];for(const n of Object.keys(t))if(!n.startsWith("_")&&!e.has(n)&&"string"==typeof t[n])return n},[Q,u,h,b,k]),de=e.useMemo(()=>Et([...he?[{label:he,accessor:he,role:"title"}]:[],{label:q||St(u),accessor:u,role:"x"},{label:Y||St(h),accessor:h,role:"y"},...b?[{label:St(b),accessor:b,role:"color"}]:[],...k?[{label:St(k),accessor:k,role:"size"}]:[]]),[he,u,h,q,Y,b,k]),ge=Nt({componentName:"QuadrantChart",data:i,accessors:{xAccessor:u,yAccessor:h}});if(ge)return d.createElement(jt,{componentName:"QuadrantChart",message:ge,width:W,height:I});const pe=e.useMemo(()=>{var e;const t={stroke:f.stroke||"#999",strokeWidth:null!==(e=f.strokeWidth)&&void 0!==e?e:1,dashArray:f.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!=g?o.x(g):s/2,c=null!=p?o.y(p):a/2;if(null!=g&&!isFinite(l))return;if(null!=p&&!isFinite(c))return;const u=Math.max(0,Math.min(s,l)),h=Math.max(0,Math.min(a,c)),d=[{config:y.topLeft,x:0,y:0,w:u,h:h},{config:y.topRight,x:u,y:0,w:s-u,h:h},{config:y.bottomLeft,x:0,y:h,w:u,h:a-h},{config:y.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([])}]},[g,p,y,f]),ye=e.useMemo(()=>m?[...pe,(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!=g?n.x(g):r/2,a=null!=p?n.y(p):i/2;(null==g||isFinite(s))&&(null==p||isFinite(a))&&(e.font=`600 ${v}px sans-serif`,e.globalAlpha=.5,e.fillStyle=y.topLeft.color,e.textAlign="left",e.textBaseline="top",e.fillText(y.topLeft.label,8,8),e.fillStyle=y.topRight.color,e.textAlign="right",e.textBaseline="top",e.fillText(y.topRight.label,r-8,8),e.fillStyle=y.bottomLeft.color,e.textAlign="left",e.textBaseline="bottom",e.fillText(y.bottomLeft.label,8,i-8),e.fillStyle=y.bottomRight.color,e.textAlign="right",e.textBaseline="bottom",e.fillText(y.bottomRight.label,r-8,i-8),e.globalAlpha=1)}]:pe,[pe,m,v,y,g,p]),fe=e.useMemo(()=>{const e=j.canvasPreRenderers||[];return[...ye,...e]},[ye,j.canvasPreRenderers]),me=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!=i&&{data:Q}),{xAccessor:u,yAccessor:h,colorAccessor:b||void 0,sizeAccessor:k||void 0,sizeRange:w,pointStyle:ae,colorScheme:x,size:[W,I],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:ce,showAxes:r.showAxes,xLabel:q,yLabel:Y,xFormat:l,yFormat:c,enableHover:F,showGrid:D}),ne&&{xExtent:ne.xExtent,yExtent:ne.yExtent}),le&&{legend:le,legendPosition:ue}),$&&"none"!==$&&{legendHoverBehavior:ee.onLegendHover,legendClickBehavior:ee.onLegendClick,legendHighlightedCategory:ee.highlightedCategory,legendIsolatedCategories:ee.isolatedCategories}),G&&{title:G}),a&&{className:a}),{tooltipContent:!1===O?()=>null:!0===O||void 0===O?de:At(O)||de}),(_||B)&&{customHoverBehavior:K}),M&&{pointIdAccessor:M}),E&&E.length>0&&{annotations:E}),{canvasPreRenderers:fe}),j),fe.length>0&&{canvasPreRenderers:fe});return d.createElement(Ut,{componentName:"QuadrantChart",width:W,height:I},d.createElement(Ye,Object.assign({ref:o},me)))});Sn.displayName="QuadrantChart";const On="__forecastSegment";function Mn(e,t){return"function"==typeof t?t(e):!!e[t]}const En=Object.freeze({__proto__:null,SEGMENT_FIELD:On,buildAnomalyAnnotations:function(e){var t,n,o;return[{type:"anomaly-band",threshold:null!==(t=e.threshold)&&void 0!==t?t:2,showBand:!1!==e.showBand,fill:e.bandColor||"#6366f1",fillOpacity:null!==(n=e.bandOpacity)&&void 0!==n?n:.1,anomalyColor:e.anomalyColor||"#ef4444",anomalyRadius:null!==(o=e.anomalyRadius)&&void 0!==o?o:6,label:e.label}]},buildForecast:function(e,t,n,o,r){return(i=o).isTraining||i.isForecast||i.isAnomaly||i.upperBounds||i.lowerBounds?function(e,t,n,o,r){var i,s,a;const{isTraining:l,isForecast:c,isAnomaly:u,upperBounds:h,lowerBounds:d,color:g="#6366f1",bandOpacity:p=.15,anomalyColor:y="#ef4444",anomalyRadius:f=6,label:m}=o,v=e.map(e=>{let t="observed";return c&&Mn(e,c)?t="forecast":l&&Mn(e,l)&&(t="training"),Object.assign(Object.assign({},e),{[On]:t})}),b=[];for(let e=0;v.length>e;e++)b.push(v[e]),v.length-1>e&&v[e][On]!==v[e+1][On]&&b.push(Object.assign(Object.assign({},v[e]),{[On]:v[e+1][On]}));const x=[];if(h&&d){const e="string"==typeof h?h:"__envUpper",t="string"==typeof d?d:"__envLower";if("function"==typeof h||"function"==typeof d)for(const n of b)"function"==typeof h&&(n[e]=h(n)),"function"==typeof d&&(n[t]=d(n));x.push({type:"envelope",upperAccessor:e,lowerAccessor:t,fill:g,fillOpacity:p,label:m})}return u&&x.push({type:"highlight",filter:e=>Mn(e,u),color:y,r:f,style:{stroke:y,strokeWidth:1.5,fill:y,fillOpacity:.7}}),r&&x.push({type:"anomaly-band",threshold:null!==(i=r.threshold)&&void 0!==i?i:2,showBand:!1!==r.showBand,fill:r.bandColor||"#6366f1",fillOpacity:null!==(s=r.bandOpacity)&&void 0!==s?s:.1,anomalyColor:r.anomalyColor||"#ef4444",anomalyRadius:null!==(a=r.anomalyRadius)&&void 0!==a?a:6,label:r.label}),{processedData:b,annotations:x}}(e,0,0,o,r):function(e,t,n,o,r){var i,s,a;const{trainEnd:l,steps:c=10,confidence:u=.95,color:h="#6366f1",bandOpacity:d=.15,label:g}=o;if(null==l)return{processedData:e,annotations:[]};const p=[],y=[];for(const n of e)n[t]>l?y.push(Object.assign(Object.assign({},n),{[On]:"observed"})):p.push(Object.assign(Object.assign({},n),{[On]:"training"}));const f=p.map(e=>[e[t],e[n]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]),m=[],v=[];if(f.length>=3){const o=f.length;let r=0,i=0,s=0,a=0;for(const[e,t]of f)r+=e,i+=t,s+=e*e,a+=e*t;const l=o*s-r*r;if(Math.abs(l)>1e-12){const s=(o*a-r*i)/l,p=(i-s*r)/o,y=e=>p+s*e,b=f.map(([e,t])=>t-y(e)).reduce((e,t)=>e+t*t,0),x=Math.sqrt(b/Math.max(o-2,1)),k=f.reduce((e,t)=>e+t[0],0)/o,w=f.reduce((e,t)=>e+Math.pow(t[0]-k,2),0),A=.99>u?.95>u?.9>u?1:1.645:1.96:2.576,S=e.map(e=>e[t]).filter(e=>null!=e&&isFinite(e)),O=Math.max(...S),M=f.length>1?(f[o-1][0]-f[0][0])/(o-1):1;for(let e=1;c>=e;e++){const r=O+e*M,i=y(r),s=x*Math.sqrt(1+1/o+(w>0?Math.pow(r-k,2)/w:0))*A;v.push({[t]:r,[n]:i,[On]:"forecast",__forecastUpper:i+s,__forecastLower:i-s})}m.push({type:"envelope",upperAccessor:"__forecastUpper",lowerAccessor:"__forecastLower",fill:h,fillOpacity:d,label:g})}}m.push({type:"x-threshold",x:l,color:"#94a3b8",strokeWidth:1,strokeDasharray:"4,2",label:"Train / Forecast"}),r&&m.push({type:"anomaly-band",threshold:null!==(i=r.threshold)&&void 0!==i?i:2,showBand:!1!==r.showBand,fill:r.bandColor||"#6366f1",fillOpacity:null!==(s=r.bandOpacity)&&void 0!==s?s:.1,anomalyColor:r.anomalyColor||"#ef4444",anomalyRadius:null!==(a=r.anomalyRadius)&&void 0!==a?a:6,label:r.label});const b=[];if(b.push(...p),p.length>0&&y.length>0&&b.push(Object.assign(Object.assign({},p[p.length-1]),{[On]:"observed"})),b.push(...y),v.length>0){const e=y.length>0?y[y.length-1]:p[p.length-1];e&&b.push(Object.assign(Object.assign({},e),{[On]:"forecast"})),b.push(...v)}return{processedData:b,annotations:m}}(e,t,n,o,r);var i},createSegmentLineStyle:function(e,t){var n,o;const r=null!==(n=t.trainDasharray)&&void 0!==n?n:"8,4",i=null!==(o=t.forecastDasharray)&&void 0!==o?o:"4,4",s=t.color||"#6366f1";return t=>{const n=e(t),o=t[On];return"training"===o?Object.assign(Object.assign({},n),{strokeDasharray:r}):"forecast"===o?Object.assign(Object.assign({},n),{stroke:s,strokeDasharray:i}):n}}});exports.AreaChart=an,exports.BubbleChart=dn,exports.ConnectedScatterplot=hn,exports.Heatmap=gn,exports.LineChart=sn,exports.MinimapChart=An,exports.QuadrantChart=Sn,exports.Scatterplot=cn,exports.ScatterplotMatrix=kn,exports.StackedAreaChart=ln,exports.StreamXYFrame=Ye;
|