semiotic 3.0.0-beta.6 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import*as e from"react";import{useRef as t,useState as n,useEffect as o,useMemo as i,forwardRef as r,useCallback as s,useImperativeHandle as a,useContext as l,createContext as c,useLayoutEffect as h,useId as u}from"react";import{scaleBand as d,scaleLinear as g,scaleOrdinal as m}from"d3-scale";import{quantile as f}from"d3-array";import{packEnclose as p}from"d3-hierarchy";import{schemeCategory10 as y,interpolatePlasma as v,interpolateViridis as b,interpolatePurples as x,interpolateOranges as w,interpolateGreens as A,interpolateReds as k,interpolateBlues as E,schemeSet3 as S,schemeTableau10 as O}from"d3-scale-chromatic";const M=5e3;class j{constructor(e){this.lastBoundedData=null,this.chunkTimer=0,this.callback=e}clearLastData(){this.lastBoundedData=null,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(e){if(e===this.lastBoundedData)return;if(this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),5e3>=e.length)return void this.callback({inserts:e,bounded:!0});this.callback({inserts:e.slice(0,M),bounded:!0,totalSize:e.length});let t=M;const n=()=>{if(t>=e.length)return;if(e!==this.lastBoundedData)return;const o=Math.min(t+M,e.length);this.callback({inserts:e.slice(t,o),bounded:!1}),t=o,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}push(e){this.callback({inserts:[e],bounded:!1})}pushMany(e){0!==e.length&&this.callback({inserts:e,bounded:!1})}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null}}class L{constructor(e){if(this._capacity=e,this.head=0,this._size=0,1>e)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(e)}push(e){let t;return this._size===this._capacity?t=this.buffer[this.head]:this._size++,this.buffer[this.head]=e,this.head=(this.head+1)%this._capacity,t}pushMany(e){const t=[];for(const n of e){const e=this.push(n);void 0!==e&&t.push(e)}return t}get(e){if(e>=0&&this._size>e)return this.buffer[(this.head-this._size+e+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let e=0;const t=this;return{next:()=>t._size>e?{done:!1,value:t.get(e++)}:{done:!0,value:void 0}}}toArray(){const e=[];for(const t of this)e.push(t);return e}resize(e){if(1>e)throw Error("RingBuffer capacity must be at least 1");const t=this.toArray(),n=[];for(;t.length>e;)n.push(t.shift());this._capacity=e,this.buffer=Array(e),this.head=0,this._size=0;for(const e of t)this.push(e);return n}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}}class P{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 H(e,t){if("function"==typeof e)return t=>+e(t);const n=e||t;return e=>+e[n]}function N(e,t){return"function"==typeof e?e:e?t=>t[e]+"":t?e=>e[t]+"":void 0}function $(e,t,n,o,i,r,s){return{type:"rect",x:e,y:t,w:n,h:o,style:i,datum:r,group:s}}function _(e,t){const{columns:n,config:o,resolvePieceStyle:i}=e,r=[],s=Math.min(t.width,t.height)/2-4,a="donut"===o.chartType?o.innerRadius||60:0,l=-Math.PI/2+(o.startAngle||0)*Math.PI/180,c=2*Math.PI;for(const e of Object.values(n)){const t=l+e.pctStart*c,n=l+(e.pctStart+e.pct)*c,o=i(e.pieceData[0],e.name);r.push({type:"wedge",cx:0,cy:0,innerRadius:a,outerRadius:s,startAngle:t,endAngle:n,style:o,datum:e.pieceData,category:e.name})}return r}function B(e){var t,n,o;const i=e.length,r=e[0],s=e[i-1];return{n:i,min:r,q1:null!==(t=f(e,.25))&&void 0!==t?t:r,median:null!==(n=f(e,.5))&&void 0!==n?n:(r+s)/2,q3:null!==(o=f(e,.75))&&void 0!==o?o:s,max:s,mean:e.reduce((e,t)=>e+t,0)/i}}const D={bar:function(e,t){const{scales:n,columns:o,config:i,getR:r,getStack:s,resolvePieceStyle:a}=e,{r:l,projection:c}=n,h=[],u="vertical"===c,d="horizontal"===c,g=i.normalize;for(const e of Object.values(o)){const t=new Map;for(const n of e.pieceData){const e=s?s(n):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const o=t.get(e);o.total+=r(n),o.pieces.push(n)}let n=0;if(g)for(const e of t.values())n+=Math.abs(e.total);let o=0,i=0;for(const[r,c]of t){let t=c.total;g&&n>0&&(t/=n);const m=a(c.pieces[0],s?r:e.name),f=Object.assign(Object.assign({},c.pieces[0]),{__aggregateValue:c.total,__pieceCount:c.pieces.length,category:e.name});if(u){const n=l(0>t?i:o+t),s=0>t?l(i+t)-l(i):l(o)-l(o+t);h.push($(e.x,n,e.width,Math.abs(s),m,f,r)),0>t?i+=t:o+=t}else if(d){const n=l(0>t?i+t:o),s=0>t?l(i)-l(i+t):l(o+t)-l(o);h.push($(n,e.x,Math.abs(s),e.width,m,f,r)),0>t?i+=t:o+=t}}}return h},clusterbar:function(e,t){const{scales:n,columns:o,getR:i,getGroup:r,resolvePieceStyle:s}=e,{r:a,projection:l}=n,c=[],h="vertical"===l,u=[],d=new Set;for(const e of Object.values(o))for(const t of e.pieceData){const e=r?r(t):"_default";d.has(e)||(d.add(e),u.push(e))}const g=u.length||1;for(const e of Object.values(o)){const t=e.width/g,n=new Map;for(const t of e.pieceData){const e=r?r(t):"_default";n.has(e)||n.set(e,[]),n.get(e).push(t)}for(let o=0;u.length>o;o++){const r=n.get(u[o])||[];for(const n of r){const r=i(n),l=s(n,e.name);if(h){const i=e.x+o*t,s=a(0),h=a(r);c.push($(i,Math.min(s,h),t,Math.abs(s-h),l,n,u[o]))}else{const i=e.x+o*t,s=a(0),h=a(r);c.push($(Math.min(s,h),i,Math.abs(h-s),t,l,n,u[o]))}}}}return c},point:function(e,t){var n,o;const{scales:i,columns:r,getR:s,multiScales:a,resolvePieceStyle:l}=e,{r:c,projection:h}=i,u=[],d="vertical"===h,g="radial"===h,m=a.length>0,f=2*Math.PI,p=-Math.PI/2;for(const e of Object.values(r))for(const t of e.pieceData){const i=null!==(n=t.__rIndex)&&void 0!==n?n:0,r=null!==(o=t.__rValue)&&void 0!==o?o:s(t),h=m&&a[i]||c,y=l(t,e.name),v=y.r||5;let b,x;if(g){const t=p+(e.pctStart+e.pct/2)*f,n=h(r);b=Math.cos(t)*n,x=Math.sin(t)*n}else d?(b=e.middle,x=h(r)):(b=h(r),x=e.middle);u.push({type:"point",x:b,y:x,r:v,style:y,datum:t})}return u},swarm:function(e,t){const{scales:n,columns:o,getR:i,resolvePieceStyle:r}=e,{r:s,projection:a}=n,l=[],c="vertical"===a;for(const e of Object.values(o)){const t=e.width/2;for(let n=0;e.pieceData.length>n;n++){const o=e.pieceData[n],a=i(o),h=r(o,e.name),u=h.r||4,d=(7919*n%100/100-.5)*t*.8,g=c?e.middle+d:s(a),m=c?s(a):e.middle+d;l.push({type:"point",x:g,y:m,r:u,style:h,datum:o})}}return l},pie:_,donut:_,boxplot:function(e,t){var n,o,i,r,s;const{scales:a,columns:l,config:c,getR:h,resolveSummaryStyle:u}=e,{r:d,projection:g}=a,m=[],p="vertical"===g,y=!1!==c.showOutliers;for(const e of Object.values(l)){const t=e.pieceData.map(e=>h(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(0===t.length)continue;const a=t[0],l=t[t.length-1],c=null!==(n=f(t,.25))&&void 0!==n?n:a,g=null!==(o=f(t,.5))&&void 0!==o?o:(a+l)/2,v=null!==(i=f(t,.75))&&void 0!==i?i:l,b=v-c,x=c-1.5*b,w=v+1.5*b,A=null!==(r=t.find(e=>e>=x))&&void 0!==r?r:a,k=null!==(s=[...t].reverse().find(e=>w>=e))&&void 0!==s?s:l,E=u(e.pieceData[0],e.name),S=[];if(y)for(const t of e.pieceData){const n=h(t);if(x>n||n>w){const o=p?e.middle:d(n),i=p?d(n):e.middle;S.push({px:o,py:i,value:n,datum:t})}}if(m.push({type:"boxplot",x:p?e.middle:0,y:p?0:e.middle,projection:p?"vertical":"horizontal",columnWidth:.6*e.width,minPos:d(A),q1Pos:d(c),medianPos:d(g),q3Pos:d(v),maxPos:d(k),stats:{min:A,q1:c,median:g,q3:v,max:k},style:E,datum:e.pieceData,category:e.name,outliers:S}),y)for(const e of S)m.push({type:"point",x:e.px,y:e.py,r:3,style:{fill:E.fill||"#999",opacity:.6},datum:e.datum})}return m},violin:function(e,t){var n,o,i;const{scales:r,columns:s,config:a,getR:l,resolveSummaryStyle:c}=e,{r:h,projection:u}=r,d=[],g="vertical"===u,m=a.bins||20,p=!1!==a.showIQR;for(const e of Object.values(s)){const t=e.pieceData.map(e=>l(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const r=t[0],s=t[t.length-1],a=(s-r)/m||1,u=Array(m).fill(0);for(const e of t)u[Math.min(Math.floor((e-r)/a),m-1)]++;const y=Math.max(...u,1),v=e.width/2*.9;let b="";if(g){for(let t=0;m>t;t++){const n=h(r+(t+.5)*a),o=u[t]/y*v;b+=0===t?`M ${e.middle+o} ${n}`:` L ${e.middle+o} ${n}`}for(let t=m-1;t>=0;t--){const n=h(r+(t+.5)*a);b+=` L ${e.middle-u[t]/y*v} ${n}`}b+=" Z"}else{for(let t=0;m>t;t++){const n=h(r+(t+.5)*a),o=u[t]/y*v;b+=0===t?`M ${n} ${e.middle-o}`:` L ${n} ${e.middle-o}`}for(let t=m-1;t>=0;t--)b+=` L ${h(r+(t+.5)*a)} ${e.middle+u[t]/y*v}`;b+=" Z"}const x=c(e.pieceData[0],e.name);let w;if(p&&t.length>=4){const a=null!==(n=f(t,.25))&&void 0!==n?n:r,l=null!==(o=f(t,.5))&&void 0!==o?o:(r+s)/2,c=null!==(i=f(t,.75))&&void 0!==i?i:s;w={q1Pos:h(a),medianPos:h(l),q3Pos:h(c),centerPos:e.middle,isVertical:g}}const A=g?{x:e.x,y:Math.min(h(s),h(r)),width:e.width,height:Math.abs(h(s)-h(r))}:{x:Math.min(h(r),h(s)),y:e.x,width:Math.abs(h(s)-h(r)),height:e.width};d.push({type:"violin",pathString:b,translateX:0,translateY:0,bounds:A,iqrLine:w,stats:B(t),style:x,datum:e.pieceData,category:e.name})}return d},histogram:function(e,t){const{scales:n,columns:o,config:i,getR:r,resolveSummaryStyle:s}=e,{r:a}=n,l=[],c=i.bins||25,h=i.normalize;for(const e of Object.values(o)){const t=e.pieceData.map(e=>r(e)).filter(e=>null!=e&&!isNaN(e));if(0===t.length)continue;const n=Math.min(...t),o=(Math.max(...t)-n)/c||1,i=Array(c).fill(0);for(const e of t)i[Math.min(Math.floor((e-n)/o),c-1)]++;const u=t.length,d=Math.max(...i,1),g=s(e.pieceData[0],e.name);for(let t=0;c>t;t++){if(0===i[t])continue;const r=(h?i[t]/u:i[t]/d)*e.width*.9,s=a(n+t*o),c=a(n+(t+1)*o);l.push($(Math.min(s,c),e.x+e.width-r,Math.abs(c-s),r,g,{bin:t,count:i[t],range:[n+t*o,n+(t+1)*o],category:e.name},e.name))}}return l},ridgeline:function(e,t){var n;const{scales:o,columns:i,config:r,getR:s,resolveSummaryStyle:a}=e,{r:l,projection:c}=o,h=[],u=r.bins||20,d="horizontal"===c,g=r.amplitude||1.5;for(const e of Object.values(i)){const t=e.pieceData.map(e=>s(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const o=t[0],i=t[t.length-1],r=(i-o)/u||1,c=Array(u).fill(0);for(const e of t)c[Math.min(Math.floor((e-o)/r),u-1)]++;const m=Math.max(...c,1),f=a(e.pieceData[0],e.name),p=e.width*g;let y="";if(d){const t=e.x+e.width;y=`M ${l(o)} ${t}`;for(let e=0;u>e;e++)y+=` L ${l(o+(e+.5)*r)} ${t-c[e]/m*p}`;y+=` L ${l(i)} ${t} Z`}else{const t=e.x;y=`M ${t} ${l(o)}`;for(let e=0;u>e;e++){const n=l(o+(e+.5)*r);y+=` L ${t+c[e]/m*p} ${n}`}y+=` L ${t} ${l(i)} Z`}const v=d?{x:Math.min(l(o),l(i)),y:e.x,width:Math.abs(l(i)-l(o)),height:e.width}:{x:e.x,y:Math.min(l(i),l(o)),width:e.width,height:Math.abs(l(i)-l(o))};h.push({type:"violin",pathString:y,translateX:0,translateY:0,bounds:v,stats:B(t),style:Object.assign(Object.assign({},f),{fillOpacity:null!==(n=f.fillOpacity)&&void 0!==n?n:.5}),datum:e.pieceData,category:e.name})}return h},timeline:function(e,t){const{scales:n,columns:o,getRawRange:i,resolvePieceStyle:r}=e,{r:s,projection:a}=n,l=[],c="horizontal"===a;for(const e of Object.values(o))for(const t of e.pieceData){const n=i(t);if(!n)continue;const[o,a]=n,h=r(t,e.name);if(c){const n=s(Math.min(o,a)),i=s(Math.max(o,a));l.push($(n,e.x,i-n,e.width,h,t,e.name))}else{const n=s(Math.max(o,a)),i=s(Math.min(o,a));l.push($(e.x,n,e.width,i-n,h,t,e.name))}}return l}};class C{constructor(e){this.rExtent=new P,this.rExtents=[],this.rAccessors=[],this.categories=new Set,this._colorSchemeMap=null,this._colorSchemeIndex=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.lastIngestTime=0,this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.version=0,this.config=e,this.buffer=new L(e.windowSize),this.getO=N(e.oAccessor||e.categoryAccessor,"category");const t="streaming"===e.runtimeMode,n=e.rAccessor;Array.isArray(n)?(this.rAccessors=n.map(e=>H(e,"value")),this.getR=this.rAccessors[0],this.rExtents=n.map(()=>new P)):(this.getR=H(t&&(e.timeAccessor||e.valueAccessor)&&e.valueAccessor||n,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=N(e.stackBy),this.getGroup=N(e.groupBy),this.getColor=N(e.colorAccessor),this.getConnector=N(e.connectorAccessor),e.pulse&&(this.timestampBuffer=new L(e.windowSize))}ingest(e){const t="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=t,e.bounded){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const n=e.totalSize||e.inserts.length;n>this.buffer.capacity&&(this.buffer.resize(n),this.timestampBuffer&&n>this.timestampBuffer.capacity&&this.timestampBuffer.resize(n));for(const n of e.inserts)this.buffer.push(n),this.timestampBuffer&&this.timestampBuffer.push(t),this.categories.add(this.getO(n)),this.pushValueExtent(n)}else for(const n of e.inserts){const e=this.buffer.push(n);this.timestampBuffer&&this.timestampBuffer.push(t),this.categories.add(this.getO(n)),this.pushValueExtent(n),null!=e&&this.evictValueExtent(e)}return!0}pushValueExtent(e){if("timeline"===this.config.chartType){const t=this.getRawRange(e);t&&(this.rExtent.push(t[0]),this.rExtent.push(t[1]))}else if(this.rAccessors.length>1){for(let t=0;this.rAccessors.length>t;t++)this.rExtents[t].push(this.rAccessors[t](e));this.rExtent.push(this.getR(e))}else this.rExtent.push(this.getR(e))}evictValueExtent(e){if("timeline"===this.config.chartType){const t=this.getRawRange(e);t&&(this.rExtent.evict(t[0]),this.rExtent.evict(t[1]))}else if(this.rAccessors.length>1){for(let t=0;this.rAccessors.length>t;t++)this.rExtents[t].evict(this.rAccessors[t](e));this.rExtent.evict(this.getR(e))}else this.rExtent.evict(this.getR(e))}getRawRange(e){const t=this.config.rAccessor;if(!t)return null;const n="function"==typeof t?t(e):e[t];return Array.isArray(n)&&n.length>=2?[+n[0],+n[1]]:null}computeScene(e){const{config:t,buffer:n}=this;if(0===n.size)return this.scales=null,this.scene=[],this.columns={},void this.version++;this.rExtent.dirty&&this.rExtent.recalculate(n,this.getR);const o=n.toArray(),i=t.projection||"vertical",r=t.oExtent||this.resolveCategories(o),s=this.computeValueDomain(o,r),a="horizontal"===i,l=null!=t.barPadding?t.barPadding/("vertical"===i?e.width:e.height):.1;let c,h;if("radial"===i){c=d().domain(r).range([0,1]).padding(0);const n=Math.min(e.width,e.height)/2,o=t.innerRadius||0;h=g().domain(s).range([o,n])}else a?(c=d().domain(r).range([0,e.height]).padding(l),h=g().domain(s).range([0,e.width])):(c=d().domain(r).range([0,e.width]).padding(l),h=g().domain(s).range([e.height,0]));this.scales={o:c,r:h,projection:i},this.multiScales=this.rAccessors.length>1&&t.multiAxis?this.rAccessors.map((o,i)=>{const r=this.rExtents[i];r.dirty&&r.recalculate(n,o);let[s,l]=r.extent;s===1/0&&(s=0,l=1);const c=l-s,h=c>0?c*(t.extentPadding||.05):1;return s-=h,l+=h,s>0&&(s=0),a?g().domain([s,l]).range([0,e.width]):g().domain([s,l]).range([e.height,0])}):[];let u=o;this.rAccessors.length>1&&(u=o.flatMap(e=>this.rAccessors.map((t,n)=>Object.assign(Object.assign({},e),{__rIndex:n,__rValue:t(e),__rName:this.resolveRAccessorName(n)})))),this.columns=this.buildColumns(u,r,c,i,e),this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(u,e),this.config.decay&&this.applyDecay(this.scene,o),this.config.pulse&&this.applyPulse(this.scene,o),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++}resolveRAccessorName(e){const t=Array.isArray(this.config.rAccessor)?this.config.rAccessor[e]:this.config.rAccessor;return"string"==typeof t?t:"value"+e}resolveCategories(e){const t=Array.from(this.categories),n=this.config.oSort;if("streaming"===this.config.runtimeMode&&void 0===n)return t;if(!1===n)return t;if("function"==typeof n)return t.sort(n);const o=new Map;for(const t of e){const e=this.getO(t);o.set(e,(o.get(e)||0)+Math.abs(this.getR(t)))}return t.sort("asc"===n?(e,t)=>(o.get(e)||0)-(o.get(t)||0):(e,t)=>(o.get(t)||0)-(o.get(e)||0))}computeValueDomain(e,t){var n,o;const i=this.config.chartType,r=this.config.extentPadding||.05;if("radial"===this.config.projection&&("pie"===i||"donut"===i))return[0,1];let s=0,a=0;if("bar"===i&&this.getStack){const t=new Map,n=new Map;for(const o of e){const e=this.getO(o),i=this.getR(o);0>i?n.set(e,(n.get(e)||0)+i):t.set(e,(t.get(e)||0)+i)}for(const e of t.values())e>a&&(a=e);for(const e of n.values())s>e&&(s=e)}else if("bar"===i){const t=new Map;for(const n of e){const e=this.getO(n),o=this.getR(n);t.set(e,(t.get(e)||0)+o)}for(const e of t.values())e>a&&(a=e),s>e&&(s=e)}else if("clusterbar"===i)for(const t of e){const e=this.getR(t);e>a&&(a=e),s>e&&(s=e)}else{const e=this.rExtent.extent[0],t=this.rExtent.extent[1];e!==1/0&&(s=e),t!==-1/0&&(a=t)}this.config.rExtent&&(null!=this.config.rExtent[0]&&(s=this.config.rExtent[0]),null!=this.config.rExtent[1]&&(a=this.config.rExtent[1]));const l=a-s,c=l>0?l*r:1;return(null===(n=this.config.rExtent)||void 0===n?void 0:n[0])||(s-=c),(null===(o=this.config.rExtent)||void 0===o?void 0:o[1])||(a+=c),"bar"!==i&&"clusterbar"!==i||(s>0&&(s=0),0>a&&(a=0)),[s,a]}buildColumns(e,t,n,o,i){var r;const s={},a=new Map;for(const t of e){const e=this.getO(t);a.has(e)||a.set(e,[]),a.get(e).push(t)}let l=0;if("radial"===o)for(const t of e)l+=Math.abs(this.getR(t));const c=this.config.dynamicColumnWidth;let h=null;if(c&&"radial"!==o){h=new Map;let e=0;for(const n of t){const t=a.get(n)||[];let o;o="string"==typeof c?t.reduce((e,t)=>e+(Number(t[c])||0),0):c(t),h.set(n,o),e+=o}const r=("horizontal"===o?i.height:i.width)-n.padding()*n.step()*t.length;if(e>0)for(const[t,n]of h)h.set(t,n/e*r)}let u=0,d=0;for(const e of t){const t=a.get(e)||[],o=t.reduce((e,t)=>e+Math.abs(this.getR(t)),0),i=l>0?o/l:0;let c,g;h?(c=d,g=h.get(e)||n.bandwidth(),d+=g+n.padding()*n.step()):(c=null!==(r=n(e))&&void 0!==r?r:0,g=n.bandwidth()),s[e]={name:e,x:c,y:0,width:g,middle:c+g/2,padding:n.padding()*n.step(),pieceData:t,pct:i,pctStart:u},u+=i}return s}getSceneContext(){return{scales:this.scales,columns:this.columns,config:this.config,getR:this.getR,getStack:this.getStack,getGroup:this.getGroup,getColor:this.getColor,getConnector:this.getConnector,getO:this.getO,multiScales:this.multiScales,rAccessors:this.rAccessors,resolvePieceStyle:(e,t)=>this.resolvePieceStyle(e,t),resolveSummaryStyle:(e,t)=>this.resolveSummaryStyle(e,t),getRawRange:e=>this.getRawRange(e)}}buildSceneNodes(e,t){if(!this.scales)return[];const n=this.getSceneContext(),o=D[this.config.chartType];let i=o?o(n,t):[];if(this.getConnector&&this.scales){const e=function(e,t){const{scales:n,config:o,getConnector:i,getO:r}=e;if(!i||!n)return[];const s=[],{projection:a}=n,l=new Map;for(const e of t){if("point"!==e.type&&"rect"!==e.type)continue;const t=e.datum;if(!t)continue;const n=i(t);if(!n)continue;let o,s;"point"===e.type?(o=e.x,s=e.y):(o=e.x+e.w/2,s=e.y+("vertical"===a?0:e.h/2)),l.has(n)||l.set(n,[]),l.get(n).push({x:o,y:s,datum:t,category:r(t)})}const c=n.o.domain(),h=o.connectorStyle;for(const[e,t]of l)if(t.length>=2){t.sort((e,t)=>c.indexOf(e.category)-c.indexOf(t.category));for(let n=0;t.length-1>n;n++){const o=t[n],i=t[n+1],r="function"==typeof h?h(o.datum):h||{stroke:"#999",strokeWidth:1,opacity:.5};s.push({type:"connector",x1:o.x,y1:o.y,x2:i.x,y2:i.y,style:r,datum:o.datum,group:e})}}return s}(n,i);i=[...e,...i]}return i}resolvePieceStyle(e,t){return"function"==typeof this.config.pieceStyle?this.config.pieceStyle(e,t):this.config.pieceStyle&&"object"==typeof this.config.pieceStyle?this.config.pieceStyle:this.config.barColors&&t?{fill:this.config.barColors[t]||"#007bff"}:t?{fill:this.getColorFromScheme(t)}:{fill:"#007bff"}}getColorFromScheme(e){this._colorSchemeMap||(this._colorSchemeMap=new Map);const t=this._colorSchemeMap.get(e);if(t)return t;const n=Array.isArray(this.config.colorScheme)?this.config.colorScheme:["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],o=n[this._colorSchemeIndex%n.length];return this._colorSchemeIndex++,this._colorSchemeMap.set(e,o),o}resolveSummaryStyle(e,t){return"function"==typeof this.config.summaryStyle?this.config.summaryStyle(e,t):this.config.summaryStyle&&"object"==typeof this.config.summaryStyle?this.config.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}computeDecayOpacity(e,t){var n,o,i;const r=this.config.decay;if(!r||1>=t)return 1;const s=null!==(n=r.minOpacity)&&void 0!==n?n:.1,a=t-1-e;switch(r.type){case"linear":return s+(1-a/(t-1))*(1-s);case"exponential":{const e=null!==(o=r.halfLife)&&void 0!==o?o:t/2;return s+Math.pow(.5,a/e)*(1-s)}case"step":return(null!==(i=r.stepThreshold)&&void 0!==i?i:.5*t)>a?1:s;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("connector"===t.type||"violin"===t.type||"boxplot"===t.type||"wedge"===t.type)continue;const e=r.get(t.datum);if(null==e)continue;const s=this.computeDecayOpacity(e,i),a=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:a*s})}}applyPulse(e,t){var n,o,i;if(!this.config.pulse||!this.timestampBuffer)return;const r="undefined"!=typeof performance?performance.now():Date.now(),s=null!==(n=this.config.pulse.duration)&&void 0!==n?n:500,a=null!==(o=this.config.pulse.color)&&void 0!==o?o:"rgba(255,255,255,0.6)",l=null!==(i=this.config.pulse.glowRadius)&&void 0!==i?i:4,c=new Map;for(let e=0;t.length>e;e++)c.set(t[e],e);for(const t of e){if("connector"===t.type||"violin"===t.type||"boxplot"===t.type||"wedge"===t.type)continue;const e=c.get(t.datum);if(null==e)continue;const n=this.timestampBuffer.get(e);if(null==n)continue;const o=r-n;s>o&&(t._pulseIntensity=1-o/s,t._pulseColor=a,t._pulseGlowRadius=l)}}get hasActivePulses(){var e;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const t="undefined"!=typeof performance?performance.now():Date.now(),n=null!==(e=this.config.pulse.duration)&&void 0!==e?e:500,o=this.timestampBuffer.peek();return null!=o&&n>t-o}snapshotPositions(){var e,t;this.prevPositionMap.clear();for(let n=0;this.scene.length>n;n++){const o=this.scene[n];if("point"===o.type)this.prevPositionMap.set("p:"+n,{x:o.x,y:o.y,r:o.r});else if("rect"===o.type){const i=`r:${o.group||""}:${null!==(t=null===(e=o.datum)||void 0===e?void 0:e.category)&&void 0!==t?t:n}`;this.prevPositionMap.set(i,{x:o.x,y:o.y,w:o.w,h:o.h})}}}startTransition(){var e,t,n,o,i;if(!this.config.transition||0===this.prevPositionMap.size)return;const r=null!==(e=this.config.transition.duration)&&void 0!==e?e:300;let s=!1;for(let e=0;this.scene.length>e;e++){const r=this.scene[e];let a=null;if("point"===r.type?a="p:"+e:"rect"===r.type&&(a=`r:${r.group||""}:${null!==(n=null===(t=r.datum)||void 0===t?void 0:t.category)&&void 0!==n?n:e}`),!a)continue;const l=this.prevPositionMap.get(a);l&&("point"===r.type?l.x===r.x&&l.y===r.y||(r._targetX=r.x,r._targetY=r.y,r.x=l.x,r.y=l.y,s=!0):"rect"===r.type&&(l.x===r.x&&l.y===r.y&&l.w===r.w&&l.h===r.h||(r._targetX=r.x,r._targetY=r.y,r._targetW=r.w,r._targetH=r.h,r.x=l.x,r.y=l.y,r.w=null!==(o=l.w)&&void 0!==o?o:r.w,r.h=null!==(i=l.h)&&void 0!==i?i:r.h,s=!0)))}s&&(this.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:r})}advanceTransition(e){var t,n,o;if(!this.activeTransition)return!1;const i=Math.min((e-this.activeTransition.startTime)/this.activeTransition.duration,1),r="linear"===(null===(t=this.config.transition)||void 0===t?void 0:t.easing)?i:1-Math.pow(1-i,3);for(const e of this.scene)if("point"===e.type){if(void 0===e._targetX)continue;const t=this.prevPositionMap.get("p:0");if(!t)continue;e.x=t.x+(e._targetX-t.x)*r,e.y=t.y+(e._targetY-t.y)*r}else if("rect"===e.type){if(void 0===e._targetX)continue;const t=`r:${e.group||""}:${null!==(o=null===(n=e.datum)||void 0===n?void 0:n.category)&&void 0!==o?o:0}`,i=this.prevPositionMap.get(t);if(!i)continue;e.x=i.x+(e._targetX-i.x)*r,e.y=i.y+(e._targetY-i.y)*r,void 0!==i.w&&(e.w=i.w+(e._targetW-i.w)*r,e.h=i.h+(e._targetH-i.h)*r)}if(i>=1){for(const e of this.scene)if("point"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e._targetX=void 0,e._targetY=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}return this.activeTransition=null,!1}return!0}getData(){return this.buffer.toArray()}clear(){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],this.columns={},this.version++}get size(){return this.buffer.size}getOAccessor(){return this.getO}getRAccessor(){return this.getR}updateConfig(e){e.colorScheme!==this.config.colorScheme&&(this._colorSchemeMap=null,this._colorSchemeIndex=0),Object.assign(this.config,e)}}function z(e,t,n){return e.x>t||t>e.x+e.w||e.y>n||n>e.y+e.h?null:{datum:e.datum,x:e.x+e.w/2,y:e.y,distance:0,category:e.group}}function W(e,t,n){const o=t-e.x,i=n-e.y,r=Math.sqrt(o*o+i*i);return r>Math.max(e.r,5)?null:{datum:e.datum,x:e.x,y:e.y,distance:r}}function T(e,t,n){const o=t-e.cx,i=n-e.cy,r=Math.sqrt(o*o+i*i);if(e.innerRadius>r||r>e.outerRadius)return null;let s=Math.atan2(i,o);0>s&&(s+=2*Math.PI);let a=e.startAngle%(2*Math.PI),l=e.endAngle%(2*Math.PI);if(0>a&&(a+=2*Math.PI),0>l&&(l+=2*Math.PI),!(a>l?s>=a||l>=s:s>=a&&l>=s))return null;const c=(e.startAngle+e.endAngle)/2,h=(e.innerRadius+e.outerRadius)/2;return{datum:e.datum,x:e.cx+Math.cos(c)*h,y:e.cy+Math.sin(c)*h,distance:0,category:e.category}}function R(e,t,n){const o=e.columnWidth/2,i=e.stats?Object.assign(Object.assign({},e.stats),{n:Array.isArray(e.datum)?e.datum.length:0,mean:(e.stats.q1+e.stats.median+e.stats.q3)/3}):void 0;if("vertical"===e.projection){if(!(e.x-o>t||t>e.x+o||Math.min(e.minPos,e.maxPos)>n||n>Math.max(e.minPos,e.maxPos)))return{datum:e.datum,x:e.x,y:e.medianPos,distance:0,category:e.category,stats:i}}else{const r=e.y-o,s=e.y+o;if(!(Math.min(e.minPos,e.maxPos)>t||t>Math.max(e.minPos,e.maxPos)||r>n||n>s))return{datum:e.datum,x:e.medianPos,y:e.y,distance:0,category:e.category,stats:i}}return null}function I(e,t,n){if(!e.bounds)return null;const{x:o,y:i,width:r,height:s}=e.bounds;return o>t||t>o+r||i>n||n>i+s?null:{datum:e.datum,x:o+r/2,y:i+s/2,distance:0,category:e.category,stats:e.stats}}const G={fill:t=>e.createElement("rect",{style:t,width:20,height:20}),line:t=>e.createElement("line",{style:t,x1:0,y1:0,x2:20,y2:20})};function F(e,t,n,o){let i;return i="function"==typeof n?n(e):(0,G[n])(o(e,t)),i}function q(t){const{legendGroups:n,customClickBehavior:o,title:i="Legend",width:r=100,height:s=20,orientation:a="vertical"}=t,l="vertical"===a?(({legendGroups:t,width:n,customClickBehavior:o})=>{let i=30;const r=[];return t.forEach((t,s)=>{i+=5,r.push(e.createElement("line",{key:"legend-top-line legend-symbol-"+s,stroke:"gray",x1:0,y1:i,x2:n,y2:i})),i+=10,t.label&&(i+=20,r.push(e.createElement("text",{key:"legend-text-"+s,y:i,className:"legend-group-label"},t.label)),i+=10),r.push(e.createElement("g",{key:"legend-group-"+s,className:"legend-item",transform:`translate(0,${i})`},((t,n)=>{const{type:o="fill",styleFn:i,items:r}=t,s=[];let a=0;return r.forEach((t,r)=>{const l=F(t,r,o,i);s.push(e.createElement("g",{key:"legend-item-"+r,transform:`translate(0,${a})`,onClick:n?()=>n(t):void 0,style:{cursor:n?"pointer":"default"}},l,e.createElement("text",{y:15,x:30},t.label))),a+=25}),s})(t,o))),i+=25*t.items.length+10}),r})({legendGroups:n,width:r,customClickBehavior:o}):(({legendGroups:t,title:n,height:o,customClickBehavior:i})=>{let r=0;const s=[],a=!1===n?10:40;return t.forEach((n,l)=>{n.label&&(s.push(e.createElement("text",{key:"legend-text-"+l,transform:`translate(${r},${a}) rotate(90)`,textAnchor:"start",className:"legend-group-label"},n.label)),r+=20);const c=((t,n)=>{const{type:o="fill",styleFn:i,items:r}=t,s=[];let a=0;return r.forEach((t,r)=>{const l=F(t,r,o,i);s.push(e.createElement("g",{key:"legend-item-"+r,transform:`translate(${a},0)`,onClick:n?()=>n(t):void 0,style:{cursor:n?"pointer":"default"}},l,e.createElement("text",{y:15,x:25},t.label))),a+=35,a+=8*t.label.length}),{items:s,offset:a}})(n,i);s.push(e.createElement("g",{key:"legend-group-"+l,className:"legend-item",transform:`translate(${r},${a})`},c.items)),r+=c.offset+5,t[l+1]&&s.push(e.createElement("line",{key:"legend-top-line legend-symbol-"+l,stroke:"gray",x1:r,y1:a-10,x2:r,y2:o+a+10})),r+=15}),e.createElement("g",null,!1!==n&&e.createElement("line",{x1:0,x2:r+10,y1:a-10,y2:a-10,stroke:"gray",className:"title-neatline"}),s)})({legendGroups:n,title:i,height:s,customClickBehavior:o});return e.createElement("g",null,void 0!==i&&e.createElement("text",{className:"legend-title",y:20,x:"horizontal"===a?0:r/2,textAnchor:"horizontal"===a?"start":"middle"},i),l)}function V(e,t=120,n=8){if(!e)return[];const o=Math.max(1,Math.floor(t/n)),i=e.split(/\s+/),r=[];let s="";for(const e of i)s&&s.length+1+e.length>o?(r.push(s),s=e):s=s?`${s} ${e}`:e;return s&&r.push(s),r}function X(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 Y(t){const{x:n=0,y:o=0,dx:i,dy:r,nx:s,ny:a,note:l,connector:c,subject:h,type:u,color:d,className:g,disable:m,events:f={},"data-testid":p}=t,y=new Set(Array.isArray(m)?m:[]);let v=i||0,b=r||0;null!=s&&(v=s-n),null!=a&&(b=a-o);const x="string"==typeof u?u:"label";if("bracket"===x&&h&&0===v&&0===b)if(void 0!==h.width){v=h.width/2;const e=h.depth||30;b=e+(0>e?-5:5)}else if(void 0!==h.height){const e=h.depth||30;v=e+(0>e?-5:5),b=h.height/2}return e.createElement("g",Object.assign({className:("annotation "+(g||"")).trim(),transform:`translate(${n},${o})`,"data-testid":p},f),!y.has("connector")&&function(t,n,o,i,r,s){const a=[];let l=0,c=0;if("callout-circle"!==r&&"label"!==r||!(null==s?void 0:s.radius)){if("callout-rect"===r&&s){const e=s.width||0,o=s.height||0;if(e>0||o>0){const i=e/2,r=o/2,s=t-i,a=n-r;if(0!==s||0!==a){const t=Math.abs(s),n=Math.abs(a),h=e/2,u=o/2,d=t*u>n*h?h/t:u/n;l=i+s*d,c=r+a*d}}}else if("bracket"===r&&s){const e=s.width,t=s.height,n=s.depth||30;void 0!==e?(l=e/2,c=n):void 0!==t&&(l=n,c=t/2)}}else{const e=(s.radius||0)+(s.radiusPadding||0);if(e>0&&(0!==t||0!==n)){const o=Math.atan2(n,t);l=Math.cos(o)*e,c=Math.sin(o)*e}}if(Math.sqrt(Math.pow(t-l,2)+Math.pow(n-c,2))>.5&&(a.push(e.createElement("line",{key:"connector-line",x1:l,y1:c,x2:t,y2:n,stroke:i||"currentColor"})),"arrow"===(null==o?void 0:o.end))){const o=10,r=16/180*Math.PI,s=Math.atan2(n-c,t-l);a.push(e.createElement("path",{key:"connector-arrow",d:`M${l},${c}L${l+o*Math.cos(s+r)},${c+o*Math.sin(s+r)}L${l+o*Math.cos(s-r)},${c+o*Math.sin(s-r)}Z`,fill:i||"currentColor",stroke:"none"}))}return e.createElement("g",{className:"annotation-connector"},a)}(v,b,c,d,x,h),!y.has("subject")&&function(t,n,o,i,r){var s;const a=[];switch(t){case"callout-circle":{const t=((null==n?void 0:n.radius)||0)+((null==n?void 0:n.radiusPadding)||0);t>0&&a.push(e.createElement("circle",{key:"subject-circle",r:t,fill:"none",stroke:o||"currentColor"}));break}case"callout-rect":{const t=(null==n?void 0:n.width)||0,i=(null==n?void 0:n.height)||0;(t>0||i>0)&&a.push(e.createElement("rect",{key:"subject-rect",width:t,height:i,fill:"none",stroke:o||"currentColor"}));break}case"callout-custom":(null==n?void 0:n.custom)&&a.push(...Array.isArray(n.custom)?n.custom:[n.custom]);break;case"xy-threshold":{const t=i||0,s=r||0;if(void 0!==(null==n?void 0:n.x)){const i=(n.x||0)-t;a.push(e.createElement("line",{key:"threshold-line",x1:i,y1:(n.y1||0)-s,x2:i,y2:(n.y2||0)-s,stroke:o||"currentColor",strokeDasharray:"5,5"}))}else if(void 0!==(null==n?void 0:n.y)){const i=(n.y||0)-s;a.push(e.createElement("line",{key:"threshold-line",x1:(n.x1||0)-t,y1:i,x2:(n.x2||0)-t,y2:i,stroke:o||"currentColor",strokeDasharray:"5,5"}))}else void 0!==(null==n?void 0:n.x1)||void 0!==(null==n?void 0:n.x2)?a.push(e.createElement("line",{key:"threshold-line",x1:(n.x1||0)-t,y1:0,x2:(n.x2||0)-t,y2:0,stroke:o||"currentColor",strokeDasharray:"5,5"})):void 0===(null==n?void 0:n.y1)&&void 0===(null==n?void 0:n.y2)||a.push(e.createElement("line",{key:"threshold-line",x1:0,y1:(n.y1||0)-s,x2:0,y2:(n.y2||0)-s,stroke:o||"currentColor",strokeDasharray:"5,5"}));break}case"bracket":{const t=null!==(s=null==n?void 0:n.width)&&void 0!==s?s:null==n?void 0:n.height;void 0!==t&&a.push(e.createElement("path",{key:"bracket-path",d:X((null==n?void 0:n.type)||"curly",t,(null==n?void 0:n.depth)||30,void 0===(null==n?void 0:n.width)),fill:"none",stroke:o||"currentColor"}));break}}return e.createElement("g",{className:"annotation-subject"},a)}(x,h,d,n,o),!y.has("note")&&function(t,n,o,i){if(!t)return e.createElement("g",{className:"annotation-note"});const{label:r,title:s,orientation:a,align:l,wrap:c=120,noWrap:h}=t;if(!r&&!s)return e.createElement("g",{className:"annotation-note"});let u=a;u||(u=Math.abs(n)>Math.abs(o)?"leftRight":"topBottom");let d=l;d&&"dynamic"!==d||(d="topBottom"===u?0>n?"right":"left":0>o?"bottom":"top");let g="start";"topBottom"===u?"right"===d?g="end":"middle"===d&&(g="middle"):g=0>n?"end":"start";const m=16,f=s?h?[s]:V(s,c):[],p=r?h?[r]:V(r,c):[],y="leftRight"===u?"end"===g?-4:4:0;let v=0;const b=[];f.length>0&&(b.push(e.createElement("text",{key:"annotation-note-title",className:"annotation-note-title",fill:i||void 0,textAnchor:g,fontWeight:"bold"},f.map((t,n)=>e.createElement("tspan",{key:n,x:y,dy:0===n?0:m},t)))),v=f.length*m),p.length>0&&b.push(e.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:i||void 0,textAnchor:g,y:v},p.map((t,n)=>e.createElement("tspan",{key:n,x:y,dy:0===n?0:m},t))));let x=null;if((s||r)&&(0!==n||0!==o))if("topBottom"===u){const t=Math.min(c,120);let n=0,o=t;"end"===g?(n=-t,o=0):"middle"===g&&(n=-t/2,o=t/2),x=e.createElement("line",{className:"note-line",x1:n,x2:o,y1:0,y2:0,stroke:i||"currentColor"})}else{const t=(f.length+p.length)*m+(p.length>0?m:0);let n=0,o=t;"bottom"===d?(n=-t,o=0):"middle"===d&&(n=-t/2,o=t/2),x=e.createElement("line",{className:"note-line",x1:0,x2:0,y1:n,y2:o,stroke:i||"currentColor"})}const w=Math.max(0,f.length+p.length-1)*m;let A=0;return"topBottom"===u?A=0>o?-(w+2):18:"leftRight"===u&&(A="middle"===d?-(w+m+(p.length>0&&f.length>0?2:0))/2+8:"bottom"===d||0>o?-(w+2):18),e.createElement("g",{className:"annotation-note",transform:`translate(${n},${o})`},e.createElement("g",{className:"annotation-note-content",transform:0!==A?`translate(0,${A})`:void 0},b),x)}(l,v,b,d))}function Q(t){var n,o;const{noteData:i}=t,{screenCoordinates:r}=i,s="string"==typeof i.type?i.type:"label",a=i.eventListeners||i.events||{};if(i.coordinates&&r){const t=i.nx||r[0][0]+(null!==(n=i.dx)&&void 0!==n?n:0),a=i.ny||r[0][1]+(null!==(o=i.dy)&&void 0!==o?o:0),l=r.map((n,o)=>{const r=Object.assign({},i,{note:0===o?i.note:{label:""},x:n[0],y:n[1],nx:t,ny:a});return e.createElement(Y,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+o},r,{type:s}))});return e.createElement("g",null,l)}const l=i.note||{title:"none",label:i.label};return e.createElement(Y,Object.assign({"data-testid":"semiotic-annotation",key:`${l.label}-${l.title}-${i.i}`,events:a},i,{type:s}))}function Z(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 U(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 J(e,t,n,o=50){return!(-o>e||e>(n.width||0)+o||-o>t||t>(n.height||0)+o)}function K(e){return Math.round(100*e)/100+""}function ee(t){const{width:n,height:o,totalWidth:r,totalHeight:s,margin:a,scales:l,showAxes:c,oLabel:h,rLabel:u,oFormat:d,rFormat:g,showGrid:m,title:f,legend:y,foregroundGraphics:v,annotations:b,svgAnnotationRules:x,annotationFrame:w,xAccessor:A,yAccessor:k,annotationData:E,children:S}=t,O="radial"===(null==l?void 0:l.projection),M="horizontal"===(null==l?void 0:l.projection),j=i(()=>c&&l&&!O?l.o.domain().map(e=>{var t;return{value:e,pixel:(null!==(t=l.o(e))&&void 0!==t?t:0)+l.o.bandwidth()/2,label:d?d(e):e}}):[],[c,l,d,O]),L=i(()=>c&&l&&!O?l.r.ticks(5).map(e=>({value:e,pixel:l.r(e),label:(g||K)(e)})):[],[c,l,g,O]),P=i(()=>{if(!b||0===b.length)return null;const t=function(t,n,o){var i,r,s,a,l,c,h,u,d,g,m,f,y,v,b,x,w,A,k,E,S,O,M,j,L,P,H,N,$,_,B,D,C,z,W,T,R,I,G;switch(t.type){case"label":{let i=null,r=null;if(null!=t.pointId&&o.pointNodes){const e=o.pointNodes.find(e=>e.pointId===t.pointId);if(!e)return null;i=e.x,r=e.y}else i=Z(t,o),r=U(t,o);return null==i||null==r?null:J(i,r,o)?e.createElement(Q,{key:"ann-"+n,noteData:{x:i,y:r,dx:t.dx||30,dy:t.dy||-30,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"label",connector:t.connector||{end:"arrow"},color:t.color}}):null}case"callout":{let i=null,r=null;if(null!=t.pointId&&o.pointNodes){const e=o.pointNodes.find(e=>e.pointId===t.pointId);if(!e)return null;i=e.x,r=e.y}else i=Z(t,o),r=U(t,o);return null==i||null==r?null:J(i,r,o)?e.createElement(Q,{key:"ann-"+n,noteData:{x:i,y:r,dx:t.dx||30,dy:t.dy||-30,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"callout-circle",subject:{radius:t.radius||12},connector:t.connector||{end:"arrow"},color:t.color}}):null}case"x-threshold":{const i=Z(t,o);if(null==i)return null;const r=t.color||"#f97316";return e.createElement("g",{key:"ann-"+n},e.createElement("line",{x1:i,y1:0,x2:i,y2:o.height||0,stroke:r,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&e.createElement("text",{x:i+4,y:12,fill:r,fontSize:12,fontWeight:"bold"},t.label))}case"y-threshold":{const i=U(t,o);if(null==i)return null;const r=t.color||"#f97316";return e.createElement("g",{key:"ann-"+n},e.createElement("line",{x1:0,y1:i,x2:o.width||0,y2:i,stroke:r,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&e.createElement("text",{x:(o.width||0)-4,y:i-4,textAnchor:"end",fill:r,fontSize:12,fontWeight:"bold"},t.label))}case"enclose":{const i=(t.coordinates||[]).map(e=>({x:Z(Object.assign(Object.assign({},e),{type:"point"}),o),y:U(Object.assign(Object.assign({},e),{type:"point"}),o),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>i.length)return null;const r=p(i),s=t.padding||10;return e.createElement("g",{key:"ann-"+n},e.createElement("circle",{cx:r.x,cy:r.y,r:r.r+s,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&e.createElement("text",{x:r.x,y:r.y-r.r-s-4,textAnchor:"middle",fill:t.color||"#666",fontSize:12},t.label))}case"rect-enclose":{const i=(t.coordinates||[]).map(e=>({x:Z(Object.assign(Object.assign({},e),{type:"point"}),o),y:U(Object.assign(Object.assign({},e),{type:"point"}),o)})).filter(e=>null!=e.x&&null!=e.y);if(2>i.length)return null;const r=t.padding||10,s=i.map(e=>e.x),a=i.map(e=>e.y),l=Math.min(...s)-r,c=Math.max(...s)+r,h=Math.min(...a)-r,u=Math.max(...a)+r;return e.createElement("g",{key:"ann-"+n},e.createElement("rect",{x:l,y:h,width:c-l,height:u-h,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&e.createElement("text",{x:(l+c)/2,y:h-4,textAnchor:"middle",fill:t.color||"#666",fontSize:12},t.label))}case"highlight":{const i=o.data||[],r="function"==typeof t.filter?i.filter(t.filter):t.field&&null!=t.value?i.filter(e=>e[t.field]===t.value):[],s=t.style||{stroke:t.color||"#f97316",strokeWidth:2,fill:"none"};return e.createElement("g",{key:"ann-"+n},r.map((n,i)=>{const r=Z(n,o),a=U(n,o);return null==r||null==a?null:e.createElement("circle",Object.assign({key:i,cx:r,cy:a,r:t.r||6},s))}))}case"bracket":{const i=Z(t,o),r=U(t,o);return e.createElement(Q,{key:"ann-"+n,noteData:{x:null!=i?i:0,y:null!=r?r:0,dx:t.dx||0,dy:t.dy||0,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"bracket",subject:{type:t.bracketType||"curly",width:t.width,height:t.height,depth:t.depth||30},color:t.color}})}case"trend":{const u=o.data||[];if(2>u.length)return null;const d=o.xAccessor||"x",g=o.yAccessor||"y",m=u.map(e=>[e[d],e[g]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>m.length)return null;const f=null!==(r=null===(i=o.scales)||void 0===i?void 0:i.x)&&void 0!==r?r:null===(s=o.scales)||void 0===s?void 0:s.time,p=null!==(l=null===(a=o.scales)||void 0===a?void 0:a.y)&&void 0!==l?l:null===(c=o.scales)||void 0===c?void 0:c.value;if(!f||!p)return null;const y=t.method||"linear";let v;if("loess"===y)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]),s=Math.max(2,Math.ceil(t*n)),a=[];for(let e=0;n>e;e++){const t=i[e],o=i.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 h=0,u=0,d=0,g=0,m=0;for(let e=0;n>e;e++){const t=c[e];0!==t&&(h+=t,u+=t*i[e],d+=t*r[e],g+=t*i[e]*i[e],m+=t*i[e]*r[e])}if(0===h){a.push([t,r[e]]);continue}const f=h*g-u*u;if(1e-12>Math.abs(f))a.push([t,d/h]);else{const e=(h*m-u*d)/f;a.push([t,(d-e*u)/h+e*t])}}return a}(m,null!==(h=t.bandwidth)&&void 0!==h?h:.3);else{let e;try{const n=require("regression");e="polynomial"===y?n.polynomial(m,{order:t.order||2}):n.linear(m)}catch(e){return null}v=e.points}const b=v.map(([e,t])=>`${f(e)},${p(t)}`).join(" "),x=t.color||"#6366f1";return e.createElement("g",{key:"ann-"+n},e.createElement("polyline",{points:b,fill:"none",stroke:x,strokeWidth:t.strokeWidth||2,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&e.createElement("text",{x:f(v[v.length-1][0])+4,y:p(v[v.length-1][1])-4,fill:x,fontSize:11},t.label))}case"band":{const i=null!==(d=null===(u=o.scales)||void 0===u?void 0:u.y)&&void 0!==d?d:null===(g=o.scales)||void 0===g?void 0:g.value,r=null!==(m=null==i?void 0:i(t.y0))&&void 0!==m?m:0,s=null!==(f=null==i?void 0:i(t.y1))&&void 0!==f?f:o.height||0;return e.createElement("g",{key:"ann-"+n},e.createElement("rect",{x:0,y:Math.min(r,s),width:o.width||0,height:Math.abs(s-r),fill:t.fill||"#6366f1",fillOpacity:t.fillOpacity||.1}),t.label&&e.createElement("text",{x:(o.width||0)-4,y:Math.min(r,s)-4,textAnchor:"end",fill:t.color||"#6366f1",fontSize:11},t.label))}case"envelope":{const i=o.data||[];if(2>i.length)return null;const r=o.xAccessor||"x",s=null!==(v=null===(y=o.scales)||void 0===y?void 0:y.x)&&void 0!==v?v:null===(b=o.scales)||void 0===b?void 0:b.time,a=null!==(w=null===(x=o.scales)||void 0===x?void 0:x.y)&&void 0!==w?w:null===(A=o.scales)||void 0===A?void 0:A.value;if(!s||!a)return null;const l=t.upperAccessor||"upperBounds",c=t.lowerAccessor||"lowerBounds",h=t.filter,u=i.filter(e=>null!=e[l]&&null!=e[c]&&!(h&&!h(e))).sort((e,t)=>e[r]-t[r]);if(2>u.length)return null;const d=u.map(e=>`${s(e[r])},${a(e[l])}`).join(" L"),g=u.slice().reverse().map(e=>`${s(e[r])},${a(e[c])}`).join(" L"),m=t.fill||"#6366f1";return e.createElement("g",{key:"ann-"+n},e.createElement("path",{d:`M${d} L${g} Z`,fill:m,fillOpacity:null!==(k=t.fillOpacity)&&void 0!==k?k:.15,stroke:"none"}),t.label&&u.length>0&&e.createElement("text",{x:s(u[u.length-1][r])+4,y:a(u[u.length-1][l])-4,fill:m,fontSize:11},t.label))}case"anomaly-band":{const i=o.data||[];if(2>i.length)return null;const r=o.yAccessor||"y",s=null!==(S=null===(E=o.scales)||void 0===E?void 0:E.x)&&void 0!==S?S:null===(O=o.scales)||void 0===O?void 0:O.time,a=null!==(j=null===(M=o.scales)||void 0===M?void 0:M.y)&&void 0!==j?j:null===(L=o.scales)||void 0===L?void 0:L.value;if(!s||!a)return null;const l=i.map(e=>e[r]).filter(e=>null!=e&&isFinite(e));if(2>l.length)return null;const c=l.reduce((e,t)=>e+t,0)/l.length,h=l.reduce((e,t)=>e+Math.pow(t-c,2),0)/l.length,u=Math.sqrt(h),d=null!==(P=t.threshold)&&void 0!==P?P:2,g=c-d*u,m=!1!==t.showBand,f=t.fill||"#6366f1",p=null!==(H=t.fillOpacity)&&void 0!==H?H:.1,y=t.anomalyColor||"#ef4444",v=null!==(N=t.anomalyRadius)&&void 0!==N?N:6,b=a(c+d*u),x=a(g),w=i.filter(e=>{const t=e[r];return null!=t&&Math.abs(t-c)>d*u});return e.createElement("g",{key:"ann-"+n},m&&e.createElement("rect",{x:0,y:Math.min(b,x),width:o.width||0,height:Math.abs(x-b),fill:f,fillOpacity:p}),w.map((t,n)=>{const i=Z(t,o),r=U(t,o);return null==i||null==r?null:e.createElement("circle",{key:n,cx:i,cy:r,r:v,fill:y,fillOpacity:.7,stroke:y,strokeWidth:1.5})}),t.label&&e.createElement("text",{x:(o.width||0)-4,y:Math.min(b,x)-4,textAnchor:"end",fill:f,fontSize:11},t.label))}case"forecast":{const i=o.data||[];if(3>i.length)return null;const r=o.xAccessor||"x",s=o.yAccessor||"y",a=null!==(_=null===($=o.scales)||void 0===$?void 0:$.x)&&void 0!==_?_:null===(B=o.scales)||void 0===B?void 0:B.time,l=null!==(C=null===(D=o.scales)||void 0===D?void 0:D.y)&&void 0!==C?C:null===(z=o.scales)||void 0===z?void 0:z.value;if(!a||!l)return null;const c=i.map(e=>[e[r],e[s]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]);if(3>c.length)return null;let h;if("polynomial"===(t.method||"linear"))try{const e=require("regression").polynomial(c,{order:t.order||2}).equation;h=t=>e.reduce((e,n,o)=>e+n*Math.pow(t,o),0)}catch(e){return null}else{const e=c.length;let t=0,n=0,o=0,i=0;for(const[e,r]of c)t+=e,n+=r,o+=e*e,i+=e*r;const r=e*o-t*t;if(1e-12>Math.abs(r))return null;const s=(e*i-t*n)/r,a=(n-s*t)/e;h=e=>a+s*e}const u=c.length,d=c.map(([e,t])=>t-h(e)).reduce((e,t)=>e+t*t,0),g=Math.sqrt(d/Math.max(u-2,1)),m=c.reduce((e,t)=>e+t[0],0)/u,f=c.reduce((e,t)=>e+Math.pow(t[0]-m,2),0),p=null!==(W=t.confidence)&&void 0!==W?W:.95,y=.99>p?.95>p?.9>p?1:1.645:1.96:2.576,v=null!==(T=t.steps)&&void 0!==T?T:5,b=c[u-1][0],x=(b-c[0][0])/Math.max(u-1,1),w=[];for(let e=1;v>=e;e++)w.push(b+e*x);const A=[];for(const e of w){const t=h(e),n=g*Math.sqrt(1+1/u+(f>0?Math.pow(e-m,2)/f:0))*y;A.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const k=`M${A.map(e=>`${a(e.x)},${l(e.yUpper)}`).join(" L")} L${A.slice().reverse().map(e=>`${a(e.x)},${l(e.yLower)}`).join(" L")} Z`,E=A.map(e=>`${a(e.x)},${l(e.yCenter)}`).join(" "),S=`${a(b)},${l(h(b))}`,O=t.strokeColor||"#6366f1";return e.createElement("g",{key:"ann-"+n},e.createElement("path",{d:k,fill:t.fill||"#6366f1",fillOpacity:null!==(R=t.fillOpacity)&&void 0!==R?R:.15,stroke:"none"}),e.createElement("polyline",{points:`${S} ${E}`,fill:"none",stroke:O,strokeWidth:null!==(I=t.strokeWidth)&&void 0!==I?I:2,strokeDasharray:null!==(G=t.strokeDasharray)&&void 0!==G?G:"6,3"}),t.label&&A.length>0&&e.createElement("text",{x:a(A[A.length-1].x)+4,y:l(A[A.length-1].yCenter)-4,fill:O,fontSize:11},t.label))}default:return null}},i={scales:l?{x:l.r,y:l.r,time:l.r,value:l.r}:null,timeAxis:"x",xAccessor:A,yAccessor:k,width:n,height:o,data:E,frameType:"ordinal"};return b.map((e,n)=>{if(x){const o=x(e,n,i);return null!=o?o:t(e,n,i)}return t(e,n,i)}).filter(Boolean)},[b,x,n,o,w,A,k,E]);return c||f||y||v||P&&P.length>0||m||S?e.createElement("svg",{width:r,height:s,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},e.createElement("g",{transform:`translate(${a.left},${a.top})`},m&&l&&!O&&e.createElement("g",{className:"ordinal-grid"},L.map((t,i)=>e.createElement("line",{key:"grid-"+i,x1:M?t.pixel:0,y1:M?0:t.pixel,x2:M?t.pixel:n,y2:M?o:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),c&&l&&!O&&e.createElement("g",{className:"ordinal-axes"},M?e.createElement(e.Fragment,null,e.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),j.map((t,n)=>e.createElement("g",{key:"cat-"+n,transform:`translate(0,${t.pixel})`},e.createElement("line",{x2:-5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),e.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"}},t.label))),h&&e.createElement("text",{x:15-a.left,y:o/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",transform:`rotate(-90, ${15-a.left}, ${o/2})`,style:{userSelect:"none"}},h),e.createElement("line",{x1:0,y1:o,x2:n,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),L.map((t,n)=>e.createElement("g",{key:"val-"+n,transform:`translate(${t.pixel},${o})`},e.createElement("line",{y2:5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),e.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"}},t.label))),u&&e.createElement("text",{x:n/2,y:o+40,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},u)):e.createElement(e.Fragment,null,e.createElement("line",{x1:0,y1:o,x2:n,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),j.map((t,n)=>e.createElement("g",{key:"cat-"+n,transform:`translate(${t.pixel},${o})`},e.createElement("line",{y2:5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),e.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"}},t.label))),h&&e.createElement("text",{x:n/2,y:o+40,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},h),e.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),L.map((t,n)=>e.createElement("g",{key:"val-"+n,transform:`translate(0,${t.pixel})`},e.createElement("line",{x2:-5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),e.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"}},t.label))),u&&e.createElement("text",{x:15-a.left,y:o/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",transform:`rotate(-90, ${15-a.left}, ${o/2})`,style:{userSelect:"none"}},u))),P,v,S),f&&e.createElement("text",{x:r/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof f?f:null),y&&e.createElement("g",{transform:`translate(${r-a.right+10}, ${a.top})`},"object"==typeof(H=y)&&null!==H&&!e.isValidElement(H)&&"legendGroups"in H?e.createElement(q,{legendGroups:y.legendGroups,title:"",width:100}):y)):null;var H}const te=(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?ne(e,t):(e.fillStyle=t.style.fill||"#007bff",e.fillRect(t.x,t.y,t.w,t.h),t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.strokeRect(t.x,t.y,t.w,t.h))),t._pulseIntensity&&t._pulseIntensity>0&&(e.globalAlpha=.3*t._pulseIntensity,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h)),e.globalAlpha=1};function ne(e,t){const n=t.style.icon,o=t.style.iconPadding||2,i=Math.min(t.w,t.w)-o;if(0>=i)return;const 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,s=t.x+(t.w-i)/2;for(let o=t.y+t.h-i;o>=t.y-i;o-=r)e.drawImage(n,s,o,i,i)}else{const r=i+o,s=t.y+(t.h-i)/2;for(let o=t.x;t.x+t.w>o;o+=r)e.drawImage(n,o,s,i,i)}e.restore()}const oe=(e,t,n,o)=>{var i,r;const s=t.filter(e=>"point"===e.type);for(const t of s){e.beginPath(),e.arc(t.x,t.y,t.r,0,2*Math.PI);const n=null!==(i=t.style.opacity)&&void 0!==i?i:t.style.fillOpacity;if(null!=n&&(e.globalAlpha=n),e.fillStyle=t.style.fill||"#4e79a7",e.fill(),t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()),t._pulseIntensity&&t._pulseIntensity>0){const n=null!==(r=t._pulseGlowRadius)&&void 0!==r?r:4,o=t.r+n*t._pulseIntensity;e.beginPath(),e.arc(t.x,t.y,o,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=.6*t._pulseIntensity,e.stroke()}e.globalAlpha=1}},ie=(e,t,n,o)=>{const i=t.filter(e=>"wedge"===e.type);for(const t of i)e.beginPath(),t.innerRadius>0?(e.arc(t.cx,t.cy,t.outerRadius,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerRadius,t.endAngle,t.startAngle,!0)):(e.moveTo(t.cx,t.cy),e.arc(t.cx,t.cy,t.outerRadius,t.startAngle,t.endAngle)),e.closePath(),null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),null!=t.style.fillOpacity&&(e.globalAlpha=t.style.fillOpacity),e.fillStyle=t.style.fill||"#007bff",e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()),e.globalAlpha=1},re=(e,t,n,o)=>{var i,r;const s=t.filter(e=>"violin"===e.type);for(const t of s){e.save(),(t.translateX||t.translateY)&&e.translate(t.translateX,t.translateY);const n=new Path2D(t.pathString);if(e.globalAlpha=null!==(r=null!==(i=t.style.fillOpacity)&&void 0!==i?i:t.style.opacity)&&void 0!==r?r:.6,e.fillStyle=t.style.fill||"#007bff",e.fill(n),e.globalAlpha=1,t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke(n)),t.iqrLine){e.strokeStyle="#333",e.lineWidth=2,e.globalAlpha=.8;const n=t.iqrLine.centerPos,o=!1!==t.iqrLine.isVertical;e.beginPath(),o?(e.moveTo(n,t.iqrLine.q1Pos),e.lineTo(n,t.iqrLine.q3Pos)):(e.moveTo(t.iqrLine.q1Pos,n),e.lineTo(t.iqrLine.q3Pos,n)),e.stroke(),e.beginPath(),o?e.arc(n,t.iqrLine.medianPos,3,0,2*Math.PI):e.arc(t.iqrLine.medianPos,n,3,0,2*Math.PI),e.fillStyle="#fff",e.fill(),e.strokeStyle="#333",e.lineWidth=1,e.stroke(),e.globalAlpha=1}e.restore()}},se=(e,t,n,o)=>{var i,r,s;const a=t.filter(e=>"connector"===e.type);if(0===a.length)return;const l=new Map;for(const e of a){const t=e.group||"_default";l.has(t)||l.set(t,[]),l.get(t).push(e)}for(const[,t]of l){if(0===t.length)continue;const n=t[0].style;if(n.fill&&"none"!==n.fill){e.beginPath(),e.moveTo(t[0].x1,t[0].y1);for(const n of t)e.lineTo(n.x2,n.y2);e.closePath(),e.globalAlpha=null!==(r=null!==(i=n.fillOpacity)&&void 0!==i?i:n.opacity)&&void 0!==r?r:.3,e.fillStyle=n.fill,e.fill(),e.globalAlpha=1}for(const n of t)e.beginPath(),e.moveTo(n.x1,n.y1),e.lineTo(n.x2,n.y2),e.strokeStyle=n.style.stroke||n.style.fill||"#999",e.lineWidth=n.style.strokeWidth||1,e.globalAlpha=null!==(s=n.style.opacity)&&void 0!==s?s:.5,e.stroke(),e.globalAlpha=1}},ae=e=>[se,...e],le={bar:ae([te]),clusterbar:ae([te]),point:ae([oe]),swarm:ae([oe]),pie:[ie],donut:[ie],boxplot:ae([(e,t,n,o)=>{var i,r;const s=t.filter(e=>"boxplot"===e.type);for(const t of s){const n=t.columnWidth/2,o="vertical"===t.projection,s=t.style.fill||"#007bff",a=t.style.stroke||"#333",l=t.style.strokeWidth||1,c=null!==(r=null!==(i=t.style.fillOpacity)&&void 0!==i?i:t.style.opacity)&&void 0!==r?r:.6;if(e.save(),e.strokeStyle=a,e.lineWidth=l,e.beginPath(),o?(e.moveTo(t.x,t.minPos),e.lineTo(t.x,t.maxPos)):(e.moveTo(t.minPos,t.y),e.lineTo(t.maxPos,t.y)),e.stroke(),e.beginPath(),o?(e.moveTo(t.x-.4*n,t.minPos),e.lineTo(t.x+.4*n,t.minPos),e.moveTo(t.x-.4*n,t.maxPos),e.lineTo(t.x+.4*n,t.maxPos)):(e.moveTo(t.minPos,t.y-.4*n),e.lineTo(t.minPos,t.y+.4*n),e.moveTo(t.maxPos,t.y-.4*n),e.lineTo(t.maxPos,t.y+.4*n)),e.stroke(),e.globalAlpha=c,e.fillStyle=s,o){const o=Math.min(t.q1Pos,t.q3Pos),i=Math.abs(t.q3Pos-t.q1Pos);e.fillRect(t.x-n,o,t.columnWidth,i),e.globalAlpha=1,e.strokeRect(t.x-n,o,t.columnWidth,i)}else{const o=Math.min(t.q1Pos,t.q3Pos),i=Math.abs(t.q3Pos-t.q1Pos);e.fillRect(o,t.y-n,i,t.columnWidth),e.globalAlpha=1,e.strokeRect(o,t.y-n,i,t.columnWidth)}e.strokeStyle="#fff",e.lineWidth=2,e.beginPath(),o?(e.moveTo(t.x-n,t.medianPos),e.lineTo(t.x+n,t.medianPos)):(e.moveTo(t.medianPos,t.y-n),e.lineTo(t.medianPos,t.y+n)),e.stroke(),e.restore()}},oe]),violin:ae([re]),histogram:ae([te]),ridgeline:ae([re]),timeline:ae([te])},ce={top:50,right:40,bottom:60,left:70},he={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:"4px",fontSize:"13px",lineHeight:"1.4",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function ue({hover:t}){var n,o,i,r;const s=t.data||{},a=t.stats,l=t.category;if(Array.isArray(s)){const t=l||(null===(n=s[0])||void 0===n?void 0:n.category)||"";if(a)return e.createElement("div",{className:"semiotic-tooltip",style:he},t&&e.createElement("div",{style:{fontWeight:"bold"}},t+""),e.createElement("div",null,"n = ",a.n),e.createElement("div",null,"Min: ",a.min.toLocaleString()),e.createElement("div",null,"Q1: ",a.q1.toLocaleString()),e.createElement("div",null,"Median: ",a.median.toLocaleString()),e.createElement("div",null,"Q3: ",a.q3.toLocaleString()),e.createElement("div",null,"Max: ",a.max.toLocaleString()),e.createElement("div",{style:{opacity:.8}},"Mean: ",a.mean.toLocaleString(void 0,{maximumFractionDigits:2})));const o=s.length;return e.createElement("div",{className:"semiotic-tooltip",style:he},t&&e.createElement("div",{style:{fontWeight:"bold"}},t+""),e.createElement("div",null,o," items"))}if(null!=s.bin&&null!=s.count){const t=s.range||[];return e.createElement("div",{className:"semiotic-tooltip",style:he},s.category&&e.createElement("div",{style:{fontWeight:"bold"}},s.category+""),e.createElement("div",null,"Count: ",s.count),2===t.length&&e.createElement("div",{style:{opacity:.8}},Number(t[0]).toFixed(1)," – ",Number(t[1]).toFixed(1)))}const c=s.category||s.name||s.group||s.__rName||"",h=null!==(r=null!==(i=null!==(o=s.value)&&void 0!==o?o:s.__rValue)&&void 0!==i?i:s.pct)&&void 0!==r?r:"";if(!c&&""===h){const t=Object.entries(s).filter(([e])=>!e.startsWith("_")&&"data"!==e);return e.createElement("div",{className:"semiotic-tooltip",style:he},t.map(([t,n])=>e.createElement("div",{key:t},e.createElement("span",{style:{opacity:.7}},t,":")," ","number"==typeof n?n.toLocaleString():n+"")))}return e.createElement("div",{className:"semiotic-tooltip",style:he},c&&e.createElement("div",{style:{fontWeight:"bold"}},c+""),""!==h&&e.createElement("div",null,"number"==typeof h?h.toLocaleString():h+""))}const de=r(function(r,l){var c;const{chartType:h,runtimeMode:u,data:d,oAccessor:g="category",rAccessor:m="value",colorAccessor:f,stackBy:p,groupBy:y,multiAxis:v,timeAccessor:b,valueAccessor:x,categoryAccessor:w,projection:A="vertical",size:k=[600,400],responsiveWidth:E,responsiveHeight:S,margin:O,barPadding:M,innerRadius:L,normalize:P,startAngle:H,dynamicColumnWidth:N,bins:$,showOutliers:_,showIQR:B,amplitude:D,connectorAccessor:G,connectorStyle:F,rExtent:q,oExtent:V,extentPadding:X=.05,oSort:Y,windowMode:Q="sliding",windowSize:Z=200,pieceStyle:U,summaryStyle:J,colorScheme:K,barColors:te,showAxes:ne=!0,oLabel:oe,rLabel:ie,oFormat:re,rFormat:se,enableHover:ae=!0,hoverAnnotation:he,tooltipContent:de,customHoverBehavior:ge,annotations:me,svgAnnotationRules:fe,showGrid:pe=!1,legend:ye,backgroundGraphics:ve,foregroundGraphics:be,title:xe,className:we,background:Ae,centerContent:ke,decay:Ee,pulse:Se,transition:Oe,staleness:Me}=r,[je,Le]=function(e,i,r){const s=t(null),[a,l]=n(null);return o(()=>{if(!i&&!r)return;const e=s.current;if(!e)return;const t=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;l(t=>t&&t.w===e&&t.h===n?t:{w:e,h:n})}});return t.observe(e),()=>t.disconnect()},[i,r]),[s,[i&&a?a.w:e[0],r&&a?a.h:e[1]]]}(k,E,S),Pe=i(()=>Object.assign(Object.assign({},ce),O),[O]),He=Le[0]-Pe.left-Pe.right,Ne=Le[1]-Pe.top-Pe.bottom,$e=t(null),_e=t(!0),Be=t(0),De=t(null),Ce=t(()=>{}),[ze,We]=n(null),[Te,Re]=n(null),[Ie,Ge]=n(0),[Fe,qe]=n(!1),Ve=ae||he,Xe="streaming"===u,Ye=i(()=>({chartType:h,runtimeMode:Xe?"streaming":"bounded",windowSize:Z,windowMode:Q,extentPadding:X,projection:A,oAccessor:Xe?void 0:g,rAccessor:Xe?void 0:m,colorAccessor:f,stackBy:p,groupBy:y,multiAxis:v,timeAccessor:Xe?b:void 0,valueAccessor:Xe?x||("string"==typeof m||"function"==typeof m?m:void 0):void 0,categoryAccessor:Xe?w||g:void 0,rExtent:q,oExtent:V,barPadding:M,innerRadius:L,normalize:P,startAngle:H,dynamicColumnWidth:N,bins:$,showOutliers:_,showIQR:B,amplitude:D,connectorAccessor:G,connectorStyle:F,oSort:Y,pieceStyle:U,summaryStyle:J,colorScheme:K,barColors:te,decay:Ee,pulse:Se,transition:Oe,staleness:Me}),[h,Z,Q,X,A,g,m,f,p,y,v,b,x,w,q,V,M,L,P,H,N,$,_,B,D,G,F,Y,U,J,K,te,Ee,Se,Oe,Me,Xe]),Qe=t(null);Qe.current||(Qe.current=new C(Ye));const Ze=s(()=>{Be.current||(Be.current=requestAnimationFrame(()=>Ce.current()))},[]);o(()=>{var e;null===(e=Qe.current)||void 0===e||e.updateConfig(Ye),_e.current=!0,Ze()},[Ye,Ze]);const Ue=t(null);Ue.current||(Ue.current=new j(e=>{const t=Qe.current;t&&t.ingest(e)&&(_e.current=!0,Ze())}));const Je=s(e=>{var t;null===(t=Ue.current)||void 0===t||t.push(e)},[]),Ke=s(e=>{var t;null===(t=Ue.current)||void 0===t||t.pushMany(e)},[]),et=s(()=>{var e,t;null===(e=Ue.current)||void 0===e||e.clear(),null===(t=Qe.current)||void 0===t||t.clear(),_e.current=!0,Ze()},[Ze]);a(l,()=>({push:Je,pushMany:Ke,clear:et,getData:()=>{var e,t;return null!==(t=null===(e=Qe.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=Qe.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null}}),[Je,Ke,et]),o(()=>{var e;if(d)return null===(e=Ue.current)||void 0===e||e.setBoundedData(d),()=>{var e;null===(e=Ue.current)||void 0===e||e.clearLastData()}},[d]);const tt=t(()=>{}),nt=t(()=>{});tt.current=e=>{if(!Ve)return;const t=$e.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-Pe.left,i=e.clientY-n.top-Pe.top;if(0>o||o>He||0>i||i>Ne)return void(De.current&&(De.current=null,We(null),ge&&ge(null),Ze()));const r=Qe.current;if(!r||0===r.scene.length)return;const s="radial"===A,a=function(e,t,n,o=30){let i=null;for(const r of e){let e=null;switch(r.type){case"rect":e=z(r,t,n);break;case"point":e=W(r,t,n);break;case"wedge":e=T(r,t,n);break;case"boxplot":e=R(r,t,n);break;case"violin":e=I(r,t,n)}e&&o>e.distance&&(i&&e.distance>=i.distance||(i=e))}return i}(r.scene,s?o-He/2:o,s?i-Ne/2:i);if(!a)return void(De.current&&(De.current=null,We(null),ge&&ge(null),Ze()));const l=Object.assign(Object.assign({data:a.datum,time:a.x,value:a.y,x:a.x,y:a.y},a.stats&&{stats:a.stats}),a.category&&{category:a.category});De.current=l,We(l),ge&&(ge(l),_e.current=!0),Ze()},nt.current=()=>{De.current&&(De.current=null,We(null),ge&&(ge(null),_e.current=!0),Ze())},s(e=>tt.current(e),[]);const ot=s(()=>nt.current(),[]),it=t(-1),rt=s(e=>{const t=Qe.current;if(!t||0===t.scene.length)return;const n=function(e){const t=[];for(const n of e)if("rect"===n.type&&null!=n.x)t.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum});else if("point"===n.type)t.push({x:n.x,y:n.y,datum:n.datum});else if("wedge"===n.type&&null!=n.cx){const e=((n.startAngle||0)+(n.endAngle||0))/2,o=((n.innerRadius||0)+(n.outerRadius||50))/2;t.push({x:n.cx+Math.cos(e)*o,y:n.cy+Math.sin(e)*o,datum:n.datum})}return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}(t.scene);if(0===n.length)return;const o=it.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 it.current=-1,De.current=null,We(null),ge&&ge(null),void Ze();const r=0>o?0:i;it.current=r;const s={data:(a=n[r]).datum,x:a.x,y:a.y,time:a.x,value:a.y};var a;De.current=s,We(s),ge&&ge(s),Ze()},[ge,Ze]),st=s(e=>{it.current=-1,tt.current(e)},[]);Ce.current=()=>{var e,t;Be.current=0;const n=$e.current;if(!n)return;const o=n.getContext("2d");if(!o)return;const i=Qe.current;if(!i)return;const r="undefined"!=typeof performance?performance.now():Date.now(),s=i.advanceTransition(r),a=_e.current;a&&!s&&(i.computeScene({width:He,height:Ne}),_e.current=!1);const l="undefined"!=typeof window&&window.devicePixelRatio||1;n.width=Le[0]*l,n.height=Le[1]*l,n.style.width=Le[0]+"px",n.style.height=Le[1]+"px",o.scale(l,l),o.clearRect(0,0,Le[0],Le[1]);const c=null!==(e=null==Me?void 0:Me.threshold)&&void 0!==e?e:5e3,u=Me&&i.lastIngestTime>0&&r-i.lastIngestTime>c;u&&(o.globalAlpha=null!==(t=null==Me?void 0:Me.dimOpacity)&&void 0!==t?t:.5);const d=n?getComputedStyle(n).getPropertyValue("--semiotic-bg").trim():"",g=Ae||(d&&"transparent"!==d?d:null);g&&(o.fillStyle=g,o.fillRect(0,0,Le[0],Le[1]));const m="radial"===A;m?(o.save(),o.translate(Pe.left+He/2,Pe.top+Ne/2)):o.translate(Pe.left,Pe.top);const f=le[h]||[],p={width:He,height:Ne};for(const e of f)e(o,i.scene,i.scales,p);m&&o.restore(),u&&(o.globalAlpha=1),a&&i.scales&&(Re(i.scales),Ge(e=>e+1)),(null==Me?void 0:Me.showBadge)&&qe(!!u),(s||i.hasActivePulses)&&(Be.current=requestAnimationFrame(()=>Ce.current()))},o(()=>(Ze(),()=>{Be.current&&(cancelAnimationFrame(Be.current),Be.current=0)}),[Ze]),o(()=>{_e.current=!0,Ze()},[h,He,Ne,ne,Ae,Ze]),o(()=>{if(!Me)return;const e=setInterval(()=>{var e;const t=Qe.current;if(!t||0===t.lastIngestTime)return;const n="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(e=Me.threshold)&&void 0!==e?e:5e3,i=n-t.lastIngestTime>o;i!==Fe&&(qe(i),_e.current=!0,Ze())},1e3);return()=>clearInterval(e)},[Me,Fe,Ze]);const at=Ve&&ze?de?de(ze):e.createElement(ue,{hover:ze}):null,lt="radial"===A,ct=ze?lt?ze.x+He/2:ze.x:0,ht=ze?lt?ze.y+Ne/2:ze.y:0,ut=at?e.createElement("div",{className:"stream-ordinal-tooltip",style:{position:"absolute",left:Pe.left+ct,top:Pe.top+ht,transform:`translate(${ct>.7*He?"calc(-100% - 12px)":"12px"}, ${.3*Ne>ht?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:1}},at):null;return e.createElement("div",{ref:je,className:"stream-ordinal-frame"+(we?" "+we:""),role:"img","aria-label":"string"==typeof xe?xe:"Ordinal chart",tabIndex:0,style:{position:"relative",width:E?"100%":Le[0],height:S?"100%":Le[1]},onMouseMove:Ve?st:void 0,onMouseLeave:Ve?ot:void 0,onKeyDown:rt},ve&&e.createElement("svg",{style:{position:"absolute",top:0,left:0,width:Le[0],height:Le[1],pointerEvents:"none"}},e.createElement("g",{transform:`translate(${Pe.left},${Pe.top})`},ve)),e.createElement("canvas",{ref:$e,style:{position:"absolute",top:0,left:0,width:Le[0],height:Le[1]}}),e.createElement(ee,{width:He,height:Ne,totalWidth:Le[0],totalHeight:Le[1],margin:Pe,scales:Te,showAxes:ne,oLabel:oe,rLabel:ie,oFormat:re,rFormat:se,showGrid:pe,title:xe,legend:ye,foregroundGraphics:be,annotations:me,svgAnnotationRules:fe,annotationFrame:Ie,xAccessor:"string"==typeof g?g:void 0,yAccessor:"string"==typeof m?m:void 0,annotationData:null===(c=Qe.current)||void 0===c?void 0:c.getData()}),ke&&"radial"===A&&e.createElement("div",{style:{position:"absolute",left:Pe.left+He/2,top:Pe.top+Ne/2,transform:"translate(-50%, -50%)",pointerEvents:"none",textAlign:"center"}},ke),(null==Me?void 0:Me.showBadge)&&e.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===Me.badgePosition?{top:4,left:4}:"bottom-left"===Me.badgePosition?{bottom:4,left:4}:"bottom-right"===Me.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:Fe?"#dc3545":"#28a745",color:"white"})},Fe?"STALE":"LIVE"),ut)});de.displayName="StreamOrdinalFrame";const ge={category10:y,tableau10:O,set3:S,blues:E,reds:k,greens:A,oranges:w,purples:x,viridis:b,plasma:v},me=y;function fe(e,t,n){if("function"==typeof t)return t(e);const o=e[t];return n?n(o):me[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+""))%me.length]}function pe(e,t,n="category10"){const o=Array.from(new Set(e.map(e=>e[t]))),i=o.every(e=>"number"==typeof e||!isNaN(Number(e)));if(Array.isArray(n))return m().domain(o).range(n).unknown("#999");const r=ge[n]||ge.category10;if(i&&"function"==typeof r)return e=>r(Number(e)/Math.max(...o.map(Number)));{const e=Array.isArray(r)?r:me;return m().domain(o).range(e).unknown("#999")}}const ye=c(null);function ve(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}function be(t){const o=c(null),r=xe(t);return[function({children:n}){const r=i(()=>xe(t),[]);return e.createElement(o.Provider,{value:r,children:n})},e=>{var t;const i=null!==(t=l(o))&&void 0!==t?t:r;return function(e,t){const[o,i]=n(t);return h(()=>e(()=>i(t)),[e]),o}(i.subscribe,()=>e(i.getState()))}]}function xe(e){const t=new EventTarget;let n=e(function(e){n=Object.assign(Object.assign({},n),e(n)),t.dispatchEvent(new CustomEvent("update"))});return{getState:()=>n,subscribe:function(e){return t.addEventListener("update",e),()=>t.removeEventListener("update",e)}}}function we(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 Ae(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}const[ke,Ee]=be(e=>({selections:new Map,setClause(t,n){e(e=>{const o=new Map(e.selections),i=Ae(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=Ae(o,t);return o.set(t,Object.assign(Object.assign({},i),{resolution:n})),{selections:o}})},clearSelection(t){e(e=>{const n=new Map(e.selections),o=n.get(t);return o&&n.set(t,Object.assign(Object.assign({},o),{clauses:new Map})),{selections:n}})}}));function Se(e){const t=u(),n=e.clientId||t,{name:o}=e,r=Ee(e=>e.selections.get(o)),a=Ee(e=>e.setClause),l=Ee(e=>e.clearClause),c=i(()=>!!r&&r.clauses.size>0,[r]);return{predicate:i(()=>r&&0!==r.clauses.size?function(e,t){const n=[];for(const[o,i]of e.clauses)"crossfilter"===e.resolution&&o===t||n.push(we(i));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(r,n):()=>!0,[r,n]),isActive:c,selectPoints:s(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"point",values:new Set(o)};a(o,{clientId:n,type:"point",fields:t})},[n,o,a]),selectInterval:s(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"interval",range:o};a(o,{clientId:n,type:"interval",fields:t})},[n,o,a]),clear:s(()=>{l(o,n)},[l,o,n]),clientId:n}}const[Oe,Me]=be(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}))}})),je="#007bff";function Le(e,t,n="category10"){const o=l(ye);return i(()=>{if(t&&"function"!=typeof t)return o&&Object.keys(o).length>0?i=>o[i]||pe(e,t,n)(i):pe(e,t,n)},[e,t,n,o])}function Pe(e,t,n){return i(()=>{if(!t)return e;const o=[...e];if("function"==typeof t)return o.sort(t);const i="function"==typeof(r=n)?r:e=>e[r];var r;return o.sort("asc"===t?(e,t)=>i(e)-i(t):(e,t)=>i(t)-i(e))},[e,t,n])}function He({selection:e,linkedHover:t,fallbackFields:n=[],unwrapData:o=!1,onObservation:i,chartType:r,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}(t,n),c=Se({name:(null==e?void 0:e.name)||"__unused__"}),h=function(e){const t=e.name||"hover",{fields:n}=e,{predicate:o,isActive:i,selectPoints:r,clear:a}=Se({name:t});return{onHover:s(e=>{if(!e)return void a();const t={};for(const o of n){const n=e[o];void 0!==n&&(t[o]=[n])}Object.keys(t).length>0&&r(t)},[n,r,a,t]),predicate:o,isActive:i}}({name:(null==l?void 0:l.name)||"hover",fields:(null==l?void 0:l.fields)||n||[]}),u=Me(e=>e.pushObservation),d=e?{isActive:c.isActive,predicate:c.predicate}:null,g=s(e=>{var n,o;if(t)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]),h.onHover(t)}else h.onHover(null);if(i||u){const t={timestamp:Date.now(),chartType:r||"unknown",chartId:a};if(e){let r=e.data||e.datum||e;Array.isArray(r)&&(r=r[0]);const s=Object.assign(Object.assign({},t),{type:"hover",datum:r||{},x:null!==(n=e.x)&&void 0!==n?n:0,y:null!==(o=e.y)&&void 0!==o?o:0});i&&i(s),u&&u(s)}else{const e=Object.assign(Object.assign({},t),{type:"hover-end"});i&&i(e),u&&u(e)}}},[t,h,i,r,a,u]),m=s(e=>{var t,n;if(i||u){const o={timestamp:Date.now(),chartType:r||"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),u&&u(s)}else{const e=Object.assign(Object.assign({},o),{type:"click-end"});i&&i(e),u&&u(e)}}},[i,u,r,a]);return{activeSelectionHook:d,customHoverBehavior:g,customClickBehavior:m}}function Ne({data:e,colorBy:t,colorScale:n,showLegend:o,userMargin:r,defaults:s={top:50,bottom:60,left:70,right:40}}){const a=void 0!==o?o:!!t,l=i(()=>{if(a&&t)return function({data:e,colorBy:t,colorScale:n,getColor:o,strokeColor:i,strokeWidth:r}){return{legendGroups:[{styleFn:e=>{const t={fill:e.color,stroke:e.color};return void 0!==i&&(t.stroke=i),void 0!==r&&(t.strokeWidth=r),t},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),s=r?o(r,t,n):n?n(i):"#000000";return{label:i+"",color:s}}),label:""}]}}({data:e,colorBy:t,colorScale:n,getColor:fe})},[a,t,e,n]),c=i(()=>{const e=Object.assign(Object.assign({},s),r);return l&&120>e.right&&(e.right=120),e},[s,r,l]);return{legend:l,margin:c}}const $e={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 _e(e,t,n){var o,i,r,s,a,l;const c=$e[e||"primary"],h="context"===e||"sparkline"===e;return{width:null!==(o=t.width)&&void 0!==o?o:c.width,height:null!==(i=t.height)&&void 0!==i?i:c.height,showAxes:c.showAxes,showGrid:null!==(r=t.showGrid)&&void 0!==r?r:c.showGrid,enableHover:null!==(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:h?void 0:t.title,xLabel:h?void 0:t.xLabel,yLabel:h?void 0:t.yLabel,categoryLabel:h?void 0:t.categoryLabel,valueLabel:h?void 0:t.valueLabel,marginDefaults:c.marginDefaults}}const Be={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 De(e,t){return"function"==typeof t?t(e):e[t]}function Ce(e,t){return t?t(e):null==e?"":"number"==typeof e?e.toLocaleString():e instanceof Date?e.toLocaleDateString():"object"==typeof e&&null!==e?void 0!==e.id?e.id+"":void 0!==e.name?e.name+"":JSON.stringify(e):e+""}function ze(t){return!0===t||("function"==typeof t?t:!1!==t&&void 0!==t&&("object"!=typeof t||null===t||!("fields"in t)&&!("title"in t)||function(t={}){const{fields:n,title:o,format:i,style:r={},className:s=""}=t;return t=>{if(!t||"object"!=typeof t)return null;let a;const l=[];if(o){const e=De(t,o);a=Ce(e,i)}if(n&&n.length>0)n.forEach(e=>{let n,o,r;"string"==typeof e?(n=e,o=e,r=i):(n=e.label,o=e.accessor||e.key||"",r=e.format||i);const s=De(t,o);l.push({label:n,value:Ce(s,r)})});else if(!o){const e=["value","y","name","id","label"];for(const n of e)if(void 0!==t[n]){a=Ce(t[n],i);break}if(!a){const e=Object.keys(t).filter(e=>!e.startsWith("_"));e.length>0&&(a=Ce(t[e[0]],i))}}const c=Object.assign(Object.assign({},Be),r);return e.createElement("div",{className:("semiotic-tooltip "+s).trim(),style:c},a&&e.createElement("div",{style:{fontWeight:l.length>0?"bold":"normal"}},a),l.map((t,n)=>e.createElement("div",{key:n,style:{marginTop:0===n&&a?"4px":0}},t.label&&e.createElement("span",null,t.label,": "),t.value)))}}(t)))}function We(e){return null==e?"–":"number"==typeof e?Math.abs(e)>9999?e.toLocaleString():e+"":e instanceof Date?e.toLocaleDateString():e+""}function Te(e,t){return"function"==typeof t?t(e):e[t]}function Re({categoryAccessor:t,valueAccessor:n,groupAccessor:o,groupLabel:i,pieData:r=!1}){return s=>{var a;const l=r?(null===(a=s.data)||void 0===a?void 0:a[0])||s.data||s:s.data||s,c=Te(l,t),h=Te(l,n),u=o?Te(l,o):void 0;return e.createElement("div",{className:"semiotic-tooltip",style:Be},e.createElement("div",{style:{fontWeight:"bold"}},We(c)),e.createElement("div",{style:{marginTop:4}},We(h)),null!=u&&e.createElement("div",{style:{marginTop:2,opacity:.8}},i||("string"==typeof(d=o)?d:"value"),": ",We(u)));var d}}function Ie({componentName:t,message:n,width:o,height:i}){return e.createElement("div",{role:"alert",style:{width:o,height:Math.max(i,120),display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed rgba(128, 128, 128, 0.4)",borderRadius:8,background:"rgba(128, 128, 128, 0.04)",padding:24,boxSizing:"border-box"}},e.createElement("div",{style:{textAlign:"center",maxWidth:400}},e.createElement("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"}},t),e.createElement("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5}},n)))}class Ge extends e.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){var n,o;null===(o=(n=this.props).onError)||void 0===o||o.call(n,e,t)}render(){if(this.state.error){const{fallback:t}=this.props,n=this.state.error;return"function"==typeof t?t(n):void 0!==t?t:e.createElement(Ie,{componentName:"ChartErrorBoundary",message:n.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}var Fe;const qe="undefined"!=typeof process&&"production"!==(null===(Fe=process.env)||void 0===Fe?void 0:Fe.NODE_ENV);function Ve({componentName:t,width:n,height:o,children:i}){return e.createElement(Ge,{fallback:i=>e.createElement(Ie,{componentName:t,message:i.message,width:n,height:o})},i)}function Xe(e,t,n,o){if(!qe)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 Ye(e,t){if(0===t.length)return null;const n=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(n)||n.includes(e.toLowerCase()))||t[0]}function Qe({componentName:e,data:t,accessors:n,requiredProps:o}){if(o)for(const[t,n]of Object.entries(o))if(null==n)return`${e}: ${t} is required. Provide a field name or function.`;if(!t||!Array.isArray(t)||0===t.length)return e+": No data provided. Pass a non-empty array to the data prop.";if(!Array.isArray(t)&&"object"==typeof t)return e+": data should be an array, but received an object. If this is hierarchical data, use TreeDiagram, Treemap, or CirclePack instead.";if(n){const o=function(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:e}(t).find(e=>e&&"object"==typeof e);if(o){const t=Object.keys(o);for(const[i,r]of Object.entries(n))if(r&&"string"==typeof r&&!(r in o)){const n=Ye(r,t),o=n?` Try ${i}="${n}".`:"";return`${e}: ${i} "${r}" not found in data. Available fields: ${t.join(", ")}.${o}`}}}return null}function Ze(t){const n=_e(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:r,className:s,categoryAccessor:a="category",valueAccessor:l="value",orientation:c="vertical",valueFormat:h,colorBy:u,colorScheme:d="category10",sort:g=!1,barPadding:m=5,tooltip:f,annotations:p,frameProps:y={},selection:v,linkedHover:b,onObservation:x,chartId:w}=t,A=n.width,k=n.height,E=n.enableHover,S=n.showGrid,O=n.showLegend,M=n.title,j=n.categoryLabel,L=n.valueLabel,P=o||[];Xe("BarChart",P,"categoryAccessor",a),Xe("BarChart",P,"valueAccessor",l);const{activeSelectionHook:H,customHoverBehavior:N}=He({selection:v,linkedHover:b,fallbackFields:u?["string"==typeof u?u:""]:[],unwrapData:!0,onObservation:x,chartType:"BarChart",chartId:w}),$=Pe(P,g,l),_=Le(P,u,d),B=i(()=>e=>{const t={};return t.fill=u?fe(e,u,_):je,t},[u,_]),D=i(()=>ve(B,H,v),[B,H,v]),{legend:C,margin:z}=Ne({data:$,colorBy:u,colorScale:_,showLegend:O,userMargin:r,defaults:n.marginDefaults}),W=i(()=>Re({categoryAccessor:a,valueAccessor:l,groupAccessor:u&&u!==a?u:void 0,groupLabel:"string"==typeof u?u:"group"}),[a,l,u]),T=Qe({componentName:"BarChart",data:P,accessors:{categoryAccessor:a,valueAccessor:l}});if(T)return e.createElement(Ie,{componentName:"BarChart",message:T,width:A,height:k});const R=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bar",data:$,oAccessor:a,rAccessor:l,projection:"horizontal"===c?"horizontal":"vertical",pieceStyle:D,size:[A,k],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:z,barPadding:m,enableHover:E,showAxes:n.showAxes,oLabel:j,rLabel:L,rFormat:h,showGrid:S,oSort:g},C&&{legend:C}),M&&{title:M}),s&&{className:s}),{tooltipContent:f?ze(f):W}),(b||x)&&{customHoverBehavior:N}),p&&p.length>0&&{annotations:p}),y);return e.createElement(Ve,{componentName:"BarChart",width:A,height:k},e.createElement(de,Object.assign({},R)))}function Ue(t){const n=_e(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:r,className:s,categoryAccessor:a="category",stackBy:l,valueAccessor:c="value",orientation:h="vertical",valueFormat:u,colorBy:d,colorScheme:g="category10",normalize:m=!1,barPadding:f=5,tooltip:p,annotations:y,frameProps:v={},selection:b,linkedHover:x,onObservation:w,chartId:A}=t,k=n.width,E=n.height,S=n.enableHover,O=n.showGrid,M=n.showLegend,j=n.title,L=n.categoryLabel,P=n.valueLabel,H=o||[],N=d||l,{activeSelectionHook:$,customHoverBehavior:_}=He({selection:b,linkedHover:x,fallbackFields:N?["string"==typeof N?N:""]:[],unwrapData:!0,onObservation:w,chartType:"StackedBarChart",chartId:A}),B=Le(H,N,g),D=i(()=>e=>N?{fill:fe(e,N,B)}:{fill:je},[N,B]),C=i(()=>ve(D,$,b),[D,$,b]),{legend:z,margin:W}=Ne({data:H,colorBy:N,colorScale:B,showLegend:M,userMargin:r,defaults:n.marginDefaults}),T=i(()=>Re({categoryAccessor:l,valueAccessor:c,groupAccessor:a}),[l,a,c]),R=Qe({componentName:"StackedBarChart",data:H,accessors:{categoryAccessor:a,valueAccessor:c},requiredProps:{stackBy:l}});if(R)return e.createElement(Ie,{componentName:"StackedBarChart",message:R,width:k,height:E});const I=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bar",data:H,oAccessor:a,rAccessor:c,stackBy:l,normalize:m,projection:"horizontal"===h?"horizontal":"vertical",pieceStyle:C,size:[k,E],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:W,barPadding:f,enableHover:S,showAxes:n.showAxes,oLabel:L,rLabel:P,rFormat:u,showGrid:O},z&&{legend:z}),j&&{title:j}),s&&{className:s}),{tooltipContent:p?ze(p):T}),(x||w)&&{customHoverBehavior:_}),y&&y.length>0&&{annotations:y}),v);return e.createElement(Ve,{componentName:"StackedBarChart",width:k,height:E},e.createElement(de,Object.assign({},I)))}function Je(t){const n=_e(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:r,className:s,categoryAccessor:a="category",groupBy:l,valueAccessor:c="value",orientation:h="vertical",valueFormat:u,colorBy:d,colorScheme:g="category10",barPadding:m=5,tooltip:f,annotations:p,frameProps:y={},selection:v,linkedHover:b,onObservation:x,chartId:w}=t,A=n.width,k=n.height,E=n.enableHover,S=n.showGrid,O=n.showLegend,M=n.title,j=n.categoryLabel,L=n.valueLabel,P=o||[],H=d||l,{activeSelectionHook:N,customHoverBehavior:$}=He({selection:v,linkedHover:b,fallbackFields:H?["string"==typeof H?H:""]:[],unwrapData:!0,onObservation:x,chartType:"GroupedBarChart",chartId:w}),_=Le(P,H,g),B=i(()=>e=>H?{fill:fe(e,H,_)}:{fill:je},[H,_]),D=i(()=>ve(B,N,v),[B,N,v]),{legend:C,margin:z}=Ne({data:P,colorBy:H,colorScale:_,showLegend:O,userMargin:r,defaults:n.marginDefaults}),W=i(()=>Re({categoryAccessor:l,valueAccessor:c,groupAccessor:a}),[l,a,c]),T=Qe({componentName:"GroupedBarChart",data:P,accessors:{categoryAccessor:a,valueAccessor:c},requiredProps:{groupBy:l}});if(T)return e.createElement(Ie,{componentName:"GroupedBarChart",message:T,width:A,height:k});const R=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"clusterbar",data:P,oAccessor:a,rAccessor:c,groupBy:l,projection:"horizontal"===h?"horizontal":"vertical",pieceStyle:D,size:[A,k],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:z,barPadding:m,enableHover:E,showAxes:n.showAxes,oLabel:j,rLabel:L,rFormat:u,showGrid:S},C&&{legend:C}),M&&{title:M}),s&&{className:s}),{tooltipContent:f?ze(f):W}),(b||x)&&{customHoverBehavior:$}),p&&p.length>0&&{annotations:p}),y);return e.createElement(Ve,{componentName:"GroupedBarChart",width:A,height:k},e.createElement(de,Object.assign({},R)))}function Ke(t){const n=_e(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:r,className:s,categoryAccessor:a="category",valueAccessor:l="value",orientation:c="vertical",valueFormat:h,colorBy:u,colorScheme:d="category10",sizeBy:g,sizeRange:m=[3,8],pointRadius:f=4,pointOpacity:p=.7,categoryPadding:y=20,tooltip:v,annotations:b,frameProps:x={},selection:w,linkedHover:A,onObservation:k,chartId:E}=t,S=n.width,O=n.height,M=n.enableHover,j=n.showGrid,L=n.showLegend,P=n.title,H=n.categoryLabel,N=n.valueLabel,$=o||[],{activeSelectionHook:_,customHoverBehavior:B}=He({selection:w,linkedHover:A,fallbackFields:u?["string"==typeof u?u:""]:["string"==typeof a?a:""],unwrapData:!0,onObservation:k,chartType:"SwarmPlot",chartId:E}),D=Le($,u,d),C=i(()=>{if(!g)return;const e=$.map(e=>"function"==typeof g?g(e):e[g]);return[Math.min(...e),Math.max(...e)]},[$,g]),z=i(()=>e=>{const t={fillOpacity:p};return t.fill=u?fe(e,u,D):je,t.r=g?function(e,t,n=[3,20],o){let i;if(i="function"==typeof t?t(e):e[t],!o)return i;const[r,s]=o,[a,l]=n;return s===r?(a+l)/2:a+(i-r)/(s-r)*(l-a)}(e,g,m,C):f,t},[u,D,g,m,C,f,p]),W=i(()=>ve(z,_,w),[z,_,w]),{legend:T,margin:R}=Ne({data:$,colorBy:u,colorScale:D,showLegend:L,userMargin:r,defaults:n.marginDefaults}),I=i(()=>Re({categoryAccessor:a,valueAccessor:l,groupAccessor:u||void 0}),[a,l,u]),G=Qe({componentName:"SwarmPlot",data:$,accessors:{categoryAccessor:a,valueAccessor:l}});if(G)return e.createElement(Ie,{componentName:"SwarmPlot",message:G,width:S,height:O});const F=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"swarm",data:$,oAccessor:a,rAccessor:l,projection:"horizontal"===c?"horizontal":"vertical",pieceStyle:W,size:[S,O],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:R,barPadding:y,enableHover:M,showAxes:n.showAxes,oLabel:H,rLabel:N,rFormat:h,showGrid:j},T&&{legend:T}),P&&{title:P}),s&&{className:s}),{tooltipContent:v?ze(v):I}),(A||k)&&{customHoverBehavior:B}),b&&b.length>0&&{annotations:b}),x);return e.createElement(Ve,{componentName:"SwarmPlot",width:S,height:O},e.createElement(de,Object.assign({},F)))}function et(t){const n=_e(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:r,className:s,categoryAccessor:a="category",valueAccessor:l="value",orientation:c="vertical",valueFormat:h,colorBy:u,colorScheme:d="category10",showOutliers:g=!0,categoryPadding:m=20,tooltip:f,annotations:p,frameProps:y={},selection:v,linkedHover:b,onObservation:x,chartId:w}=t,A=n.width,k=n.height,E=n.enableHover,S=n.showGrid,O=n.showLegend,M=n.title,j=n.categoryLabel,L=n.valueLabel,P=o||[],{activeSelectionHook:H,customHoverBehavior:N}=He({selection:v,linkedHover:b,fallbackFields:u?["string"==typeof u?u:""]:["string"==typeof a?a:""],unwrapData:!0,onObservation:x,chartType:"BoxPlot",chartId:w}),$=Le(P,u,d),_=i(()=>e=>{const t=u?fe(e,u,$):je;return{fill:t,stroke:t,fillOpacity:.8}},[u,$]),B=i(()=>ve(_,H,v),[_,H,v]),{legend:D,margin:C}=Ne({data:P,colorBy:u,colorScale:$,showLegend:O,userMargin:r,defaults:n.marginDefaults}),z=i(()=>t=>{const n=t.stats||(t.data||t).stats||{};return e.createElement("div",{className:"semiotic-tooltip",style:Be},e.createElement("div",{style:{fontWeight:"bold",marginBottom:"4px"}},(t.category||(t.data||t).category||"")+""),null!=n.median&&e.createElement(e.Fragment,null,null!=n.n&&e.createElement("div",null,"n = ",n.n),e.createElement("div",null,"Median: ",n.median.toLocaleString()),e.createElement("div",null,"Q1: ",n.q1.toLocaleString()),e.createElement("div",null,"Q3: ",n.q3.toLocaleString()),e.createElement("div",null,"Min: ",n.min.toLocaleString()),e.createElement("div",null,"Max: ",n.max.toLocaleString())))},[]),W=Qe({componentName:"BoxPlot",data:P,accessors:{categoryAccessor:a,valueAccessor:l}});if(W)return e.createElement(Ie,{componentName:"BoxPlot",message:W,width:A,height:k});const T=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"boxplot",data:P,oAccessor:a,rAccessor:l,projection:"horizontal"===c?"horizontal":"vertical",summaryStyle:B,showOutliers:g,size:[A,k],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:C,barPadding:m,enableHover:E,showAxes:n.showAxes,oLabel:j,rLabel:L,rFormat:h,showGrid:S},D&&{legend:D}),M&&{title:M}),s&&{className:s}),{tooltipContent:f?ze(f):z}),(b||x)&&{customHoverBehavior:N}),p&&p.length>0&&{annotations:p}),y);return e.createElement(Ve,{componentName:"BoxPlot",width:A,height:k},e.createElement(de,Object.assign({},T)))}function tt(t){const n=_e(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:r,className:s,categoryAccessor:a="category",valueAccessor:l="value",bins:c=25,relative:h=!1,valueFormat:u,colorBy:d,colorScheme:g="category10",categoryPadding:m=20,tooltip:f,annotations:p,frameProps:y={},selection:v,linkedHover:b,onObservation:x,chartId:w}=t,A=n.width,k=n.height,E=n.enableHover,S=n.showGrid,O=n.showLegend,M=n.title,j=n.categoryLabel,L=n.valueLabel,P=o||[],{activeSelectionHook:H,customHoverBehavior:N}=He({selection:v,linkedHover:b,fallbackFields:d?["string"==typeof d?d:""]:["string"==typeof a?a:""],unwrapData:!0,onObservation:x,chartType:"Histogram",chartId:w}),$=Le(P,d,g),_=i(()=>e=>{const t=d?fe(e,d,$):je;return{fill:t,stroke:t,fillOpacity:.8}},[d,$]),B=i(()=>ve(_,H,v),[_,H,v]),{legend:D,margin:C}=Ne({data:P,colorBy:d,colorScale:$,showLegend:O,userMargin:r,defaults:n.marginDefaults}),z=i(()=>t=>{const n=t.data||t,o=n.category||t.category||"",i=n.count,r=n.range;return e.createElement("div",{className:"semiotic-tooltip",style:Be},o&&e.createElement("div",{style:{fontWeight:"bold"}},o+""),null!=i&&e.createElement("div",null,"Count: ",i),r&&2===r.length&&e.createElement("div",{style:{opacity:.8}},Number(r[0]).toFixed(1)," – ",Number(r[1]).toFixed(1)))},[]),W=Qe({componentName:"Histogram",data:P,accessors:{categoryAccessor:a,valueAccessor:l}});if(W)return e.createElement(Ie,{componentName:"Histogram",message:W,width:A,height:k});const T=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"histogram",data:P,oAccessor:a,rAccessor:l,projection:"horizontal",summaryStyle:B,bins:c,normalize:h,size:[A,k],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:C,barPadding:m,enableHover:E,showAxes:n.showAxes,oLabel:j,rLabel:L,rFormat:u,showGrid:S},D&&{legend:D}),M&&{title:M}),s&&{className:s}),{tooltipContent:f?ze(f):z}),(b||x)&&{customHoverBehavior:N}),p&&p.length>0&&{annotations:p}),y);return e.createElement(Ve,{componentName:"Histogram",width:A,height:k},e.createElement(de,Object.assign({},T)))}function nt(t){const n=_e(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:r,className:s,categoryAccessor:a="category",valueAccessor:l="value",orientation:c="vertical",bins:h=25,showIQR:u=!0,valueFormat:d,colorBy:g,colorScheme:m="category10",categoryPadding:f=20,tooltip:p,annotations:y,frameProps:v={},selection:b,linkedHover:x,onObservation:w,chartId:A}=t,k=n.width,E=n.height,S=n.enableHover,O=n.showGrid,M=n.showLegend,j=n.title,L=n.categoryLabel,P=n.valueLabel,H=o||[],{activeSelectionHook:N,customHoverBehavior:$}=He({selection:b,linkedHover:x,fallbackFields:g?["string"==typeof g?g:""]:["string"==typeof a?a:""],unwrapData:!0,onObservation:w,chartType:"ViolinPlot",chartId:A}),_=Le(H,g,m),B=i(()=>e=>{const t=g?fe(e,g,_):je;return{fill:t,stroke:t,fillOpacity:.6}},[g,_]),D=i(()=>ve(B,N,b),[B,N,b]),{legend:C,margin:z}=Ne({data:H,colorBy:g,colorScale:_,showLegend:M,userMargin:r,defaults:n.marginDefaults}),W=i(()=>t=>{var n;const o=t.category||t.data&&(null===(n=t.data[0])||void 0===n?void 0:n.category)||"",i=t.stats;if(i)return e.createElement("div",{className:"semiotic-tooltip",style:Be},o&&e.createElement("div",{style:{fontWeight:"bold"}},o+""),e.createElement("div",null,"n = ",i.n),e.createElement("div",null,"Min: ",i.min.toLocaleString()),e.createElement("div",null,"Q1: ",i.q1.toLocaleString()),e.createElement("div",null,"Median: ",i.median.toLocaleString()),e.createElement("div",null,"Q3: ",i.q3.toLocaleString()),e.createElement("div",null,"Max: ",i.max.toLocaleString()),e.createElement("div",{style:{opacity:.8}},"Mean: ",i.mean.toLocaleString(void 0,{maximumFractionDigits:2})));const r=(Array.isArray(t.data)?t.data:[]).map(e=>{const t="function"==typeof l?l(e):e[l];return Number(t)}).filter(e=>!isNaN(e)).sort((e,t)=>e-t),s=r.length,a=s>0?r[Math.floor(s/2)]:null;return e.createElement("div",{className:"semiotic-tooltip",style:Be},o&&e.createElement("div",{style:{fontWeight:"bold"}},o+""),s>0&&e.createElement("div",null,"n = ",s),null!=a&&e.createElement("div",null,"Median: ",a.toLocaleString()))},[l]),T=Qe({componentName:"ViolinPlot",data:H,accessors:{categoryAccessor:a,valueAccessor:l}});if(T)return e.createElement(Ie,{componentName:"ViolinPlot",message:T,width:k,height:E});const R=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"violin",data:H,oAccessor:a,rAccessor:l,projection:"horizontal"===c?"horizontal":"vertical",summaryStyle:D,bins:h,showIQR:u,size:[k,E],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:z,barPadding:f,enableHover:S,showAxes:n.showAxes,oLabel:L,rLabel:P,rFormat:d,showGrid:O},C&&{legend:C}),j&&{title:j}),s&&{className:s}),{tooltipContent:p?ze(p):W}),(x||w)&&{customHoverBehavior:$}),y&&y.length>0&&{annotations:y}),v);return e.createElement(Ve,{componentName:"ViolinPlot",width:k,height:E},e.createElement(de,Object.assign({},R)))}function ot(t){var n;const o=_e(t.mode,{width:t.width,height:t.height,showGrid:null===(n=t.showGrid)||void 0===n||n,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:r,margin:s,className:a,categoryAccessor:l="category",valueAccessor:c="value",orientation:h="horizontal",valueFormat:u,colorBy:d,colorScheme:g="category10",sort:m=!0,dotRadius:f=5,categoryPadding:p=10,tooltip:y,annotations:v,frameProps:b={},selection:x,linkedHover:w,onObservation:A,chartId:k}=t,E=o.width,S=o.height,O=o.enableHover,M=o.showGrid,j=o.showLegend,L=o.title,P=o.categoryLabel,H=o.valueLabel,N=r||[],{activeSelectionHook:$,customHoverBehavior:_}=He({selection:x,linkedHover:w,fallbackFields:d?["string"==typeof d?d:""]:["string"==typeof l?l:""],unwrapData:!0,onObservation:A,chartType:"DotPlot",chartId:k}),B=Pe(N,m,c),D=Le(N,d,g),C=i(()=>e=>{const t={r:f,fillOpacity:.8};return t.fill=d?fe(e,d,D):je,t},[d,D,f]),z=i(()=>ve(C,$,x),[C,$,x]),{legend:W,margin:T}=Ne({data:B,colorBy:d,colorScale:D,showLegend:j,userMargin:s,defaults:o.marginDefaults}),R=i(()=>Re({categoryAccessor:l,valueAccessor:c}),[l,c]),I=Qe({componentName:"DotPlot",data:N,accessors:{categoryAccessor:l,valueAccessor:c}});if(I)return e.createElement(Ie,{componentName:"DotPlot",message:I,width:E,height:S});const G=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"point",data:B,oAccessor:l,rAccessor:c,projection:"horizontal"===h?"horizontal":"vertical",pieceStyle:z,size:[E,S],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:T,barPadding:p,enableHover:O,showAxes:o.showAxes,oLabel:P,rLabel:H,rFormat:u,showGrid:M,oSort:m},W&&{legend:W}),L&&{title:L}),a&&{className:a}),{tooltipContent:y?ze(y):R}),(w||A)&&{customHoverBehavior:_}),v&&v.length>0&&{annotations:v}),b);return e.createElement(Ve,{componentName:"DotPlot",width:E,height:S},e.createElement(de,Object.assign({},G)))}function it(t){var n,o;const r=_e(t.mode,{width:null!==(n=t.width)&&void 0!==n?n:400,height:null!==(o=t.height)&&void 0!==o?o:400,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title}),{data:s,margin:a,className:l,categoryAccessor:c="category",valueAccessor:h="value",colorBy:u,colorScheme:d="category10",startAngle:g=0,tooltip:m,annotations:f,frameProps:p={},selection:y,linkedHover:v,onObservation:b,chartId:x}=t,w=r.width,A=r.height,k=r.enableHover,E=r.showLegend,S=r.title,O=s||[],M=u||c,{activeSelectionHook:j,customHoverBehavior:L}=He({selection:y,linkedHover:v,fallbackFields:M?["string"==typeof M?M:""]:[],unwrapData:!0,onObservation:b,chartType:"PieChart",chartId:x}),P=Le(O,M,d),H=i(()=>e=>M?{fill:fe(e,M,P)}:{fill:je},[M,P]),N=i(()=>ve(H,j,y),[H,j,y]),{legend:$,margin:_}=Ne({data:O,colorBy:M,colorScale:P,showLegend:E,userMargin:a,defaults:r.marginDefaults}),B=i(()=>Re({categoryAccessor:c,valueAccessor:h,groupAccessor:u&&u!==c?u:void 0,groupLabel:"string"==typeof u?u:"group",pieData:!0}),[c,h,u]),D=Qe({componentName:"PieChart",data:O,accessors:{categoryAccessor:c,valueAccessor:h}});if(D)return e.createElement(Ie,{componentName:"PieChart",message:D,width:w,height:A});const C=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"pie",data:O,oAccessor:c,rAccessor:h,projection:"radial",pieceStyle:N,startAngle:g,size:[w,A],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:_,enableHover:k,showAxes:!1},$&&{legend:$}),S&&{title:S}),l&&{className:l}),{tooltipContent:m?ze(m):B}),(v||b)&&{customHoverBehavior:L}),f&&f.length>0&&{annotations:f}),p);return e.createElement(Ve,{componentName:"PieChart",width:w,height:A},e.createElement(de,Object.assign({},C)))}function rt(t){var n,o;const r=_e(t.mode,{width:null!==(n=t.width)&&void 0!==n?n:400,height:null!==(o=t.height)&&void 0!==o?o:400,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,linkedHover:t.linkedHover}),{data:s,margin:a,className:l,categoryAccessor:c="category",valueAccessor:h="value",innerRadius:u=60,centerContent:d,colorBy:g,colorScheme:m="category10",startAngle:f=0,tooltip:p,annotations:y,frameProps:v={},selection:b,linkedHover:x,onObservation:w,chartId:A}=t,k=r.width,E=r.height,S=r.enableHover,O=r.showLegend,M=r.title,j=s||[],L=g||c,{activeSelectionHook:P,customHoverBehavior:H}=He({selection:b,linkedHover:x,fallbackFields:L?["string"==typeof L?L:""]:[],unwrapData:!0,onObservation:w,chartType:"DonutChart",chartId:A}),N=Le(j,L,m),$=i(()=>e=>L?{fill:fe(e,L,N)}:{fill:je},[L,N]),_=i(()=>ve($,P,b),[$,P,b]),{legend:B,margin:D}=Ne({data:j,colorBy:L,colorScale:N,showLegend:O,userMargin:a,defaults:r.marginDefaults}),C=i(()=>Re({categoryAccessor:c,valueAccessor:h,groupAccessor:g&&g!==c?g:void 0,groupLabel:"string"==typeof g?g:"group",pieData:!0}),[c,h,g]),z=Qe({componentName:"DonutChart",data:j,accessors:{categoryAccessor:c,valueAccessor:h}});if(z)return e.createElement(Ie,{componentName:"DonutChart",message:z,width:k,height:E});const W=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"donut",data:j,oAccessor:c,rAccessor:h,projection:"radial",pieceStyle:_,innerRadius:u,startAngle:f,centerContent:d,size:[k,E],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:D,enableHover:S,showAxes:!1},B&&{legend:B}),M&&{title:M}),l&&{className:l}),{tooltipContent:p?ze(p):C}),(x||w)&&{customHoverBehavior:H}),y&&y.length>0&&{annotations:y}),v);return e.createElement(Ve,{componentName:"DonutChart",width:k,height:E},e.createElement(de,Object.assign({},W)))}Ze.displayName="BarChart",Ue.displayName="StackedBarChart",Je.displayName="GroupedBarChart",Ke.displayName="SwarmPlot",et.displayName="BoxPlot",tt.displayName="Histogram",nt.displayName="ViolinPlot",ot.displayName="DotPlot",it.displayName="PieChart",rt.displayName="DonutChart";export{Ze as BarChart,et as BoxPlot,rt as DonutChart,ot as DotPlot,Je as GroupedBarChart,tt as Histogram,it as PieChart,Ue as StackedBarChart,de as StreamOrdinalFrame,Ke as SwarmPlot,nt as ViolinPlot};
1
+ import*as e from"react";import{useRef as t,useState as n,useEffect as o,useMemo as i,forwardRef as r,useCallback as s,useImperativeHandle as a,useContext as l,createContext as c,useLayoutEffect as h,useId as u}from"react";import{scaleBand as d,scaleLinear as g,scaleOrdinal as m}from"d3-scale";import{quantile as f}from"d3-array";import{packEnclose as p}from"d3-hierarchy";import{schemeCategory10 as y,interpolatePlasma as v,interpolateViridis as b,interpolatePurples as x,interpolateOranges as w,interpolateGreens as A,interpolateReds as k,interpolateBlues as E,schemeSet3 as S,schemeTableau10 as O}from"d3-scale-chromatic";const M=5e3;class j{constructor(e){this.lastBoundedData=null,this.chunkTimer=0,this.callback=e}clearLastData(){this.lastBoundedData=null,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(e){if(this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),5e3>=e.length)return void this.callback({inserts:e,bounded:!0});this.callback({inserts:e.slice(0,M),bounded:!0,totalSize:e.length});let t=M;const n=()=>{if(t>=e.length)return;if(e!==this.lastBoundedData)return;const o=Math.min(t+M,e.length);this.callback({inserts:e.slice(t,o),bounded:!1}),t=o,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}push(e){this.callback({inserts:[e],bounded:!1})}pushMany(e){0!==e.length&&this.callback({inserts:e,bounded:!1})}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null}}class L{constructor(e){if(this._capacity=e,this.head=0,this._size=0,1>e)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(e)}push(e){let t;return this._size===this._capacity?t=this.buffer[this.head]:this._size++,this.buffer[this.head]=e,this.head=(this.head+1)%this._capacity,t}pushMany(e){const t=[];for(const n of e){const e=this.push(n);void 0!==e&&t.push(e)}return t}get(e){if(e>=0&&this._size>e)return this.buffer[(this.head-this._size+e+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let e=0;const t=this;return{next:()=>t._size>e?{done:!1,value:t.get(e++)}:{done:!0,value:void 0}}}toArray(){const e=[];for(const t of this)e.push(t);return e}resize(e){if(1>e)throw Error("RingBuffer capacity must be at least 1");const t=this.toArray(),n=[];for(;t.length>e;)n.push(t.shift());this._capacity=e,this.buffer=Array(e),this.head=0,this._size=0;for(const e of t)this.push(e);return n}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}}class P{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 H(e,t){if("function"==typeof e)return t=>+e(t);const n=e||t;return e=>+e[n]}function N(e,t){return"function"==typeof e?e:e?t=>t[e]+"":t?e=>e[t]+"":void 0}function $(e,t,n,o,i,r,s){return{type:"rect",x:e,y:t,w:n,h:o,style:i,datum:r,group:s}}function _(e,t){const{columns:n,config:o,resolvePieceStyle:i}=e,r=[],s=Math.min(t.width,t.height)/2-4,a="donut"===o.chartType?o.innerRadius||60:0,l=-Math.PI/2+(o.startAngle||0)*Math.PI/180,c=2*Math.PI;for(const e of Object.values(n)){const t=l+e.pctStart*c,n=l+(e.pctStart+e.pct)*c,o=i(e.pieceData[0],e.name);r.push({type:"wedge",cx:0,cy:0,innerRadius:a,outerRadius:s,startAngle:t,endAngle:n,style:o,datum:e.pieceData,category:e.name})}return r}function B(e){var t,n,o;const i=e.length,r=e[0],s=e[i-1];return{n:i,min:r,q1:null!==(t=f(e,.25))&&void 0!==t?t:r,median:null!==(n=f(e,.5))&&void 0!==n?n:(r+s)/2,q3:null!==(o=f(e,.75))&&void 0!==o?o:s,max:s,mean:e.reduce((e,t)=>e+t,0)/i}}const C={bar:function(e,t){const{scales:n,columns:o,config:i,getR:r,getStack:s,resolvePieceStyle:a}=e,{r:l,projection:c}=n,h=[],u="vertical"===c,d="horizontal"===c,g=i.normalize;for(const e of Object.values(o)){const t=new Map;for(const n of e.pieceData){const e=s?s(n):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const o=t.get(e);o.total+=r(n),o.pieces.push(n)}let n=0;if(g)for(const e of t.values())n+=Math.abs(e.total);let o=0,i=0;for(const[r,c]of t){let t=c.total;g&&n>0&&(t/=n);const m=a(c.pieces[0],s?r:e.name),f=Object.assign(Object.assign({},c.pieces[0]),{__aggregateValue:c.total,__pieceCount:c.pieces.length,category:e.name});if(u){const n=l(0>t?i:o+t),s=0>t?l(i+t)-l(i):l(o)-l(o+t);h.push($(e.x,n,e.width,Math.abs(s),m,f,r)),0>t?i+=t:o+=t}else if(d){const n=l(0>t?i+t:o),s=0>t?l(i)-l(i+t):l(o+t)-l(o);h.push($(n,e.x,Math.abs(s),e.width,m,f,r)),0>t?i+=t:o+=t}}}return h},clusterbar:function(e,t){const{scales:n,columns:o,getR:i,getGroup:r,resolvePieceStyle:s}=e,{r:a,projection:l}=n,c=[],h="vertical"===l,u=[],d=new Set;for(const e of Object.values(o))for(const t of e.pieceData){const e=r?r(t):"_default";d.has(e)||(d.add(e),u.push(e))}const g=u.length||1;for(const e of Object.values(o)){const t=e.width/g,n=new Map;for(const t of e.pieceData){const e=r?r(t):"_default";n.has(e)||n.set(e,[]),n.get(e).push(t)}for(let o=0;u.length>o;o++){const r=n.get(u[o])||[];for(const n of r){const r=i(n),l=s(n,e.name);if(h){const i=e.x+o*t,s=a(0),h=a(r);c.push($(i,Math.min(s,h),t,Math.abs(s-h),l,n,u[o]))}else{const i=e.x+o*t,s=a(0),h=a(r);c.push($(Math.min(s,h),i,Math.abs(h-s),t,l,n,u[o]))}}}}return c},point:function(e,t){var n,o;const{scales:i,columns:r,getR:s,multiScales:a,resolvePieceStyle:l}=e,{r:c,projection:h}=i,u=[],d="vertical"===h,g="radial"===h,m=a.length>0,f=2*Math.PI,p=-Math.PI/2;for(const e of Object.values(r))for(const t of e.pieceData){const i=null!==(n=t.__rIndex)&&void 0!==n?n:0,r=null!==(o=t.__rValue)&&void 0!==o?o:s(t),h=m&&a[i]||c,y=l(t,e.name),v=y.r||5;let b,x;if(g){const t=p+(e.pctStart+e.pct/2)*f,n=h(r);b=Math.cos(t)*n,x=Math.sin(t)*n}else d?(b=e.middle,x=h(r)):(b=h(r),x=e.middle);u.push({type:"point",x:b,y:x,r:v,style:y,datum:t})}return u},swarm:function(e,t){const{scales:n,columns:o,getR:i,resolvePieceStyle:r}=e,{r:s,projection:a}=n,l=[],c="vertical"===a;for(const e of Object.values(o)){const t=e.width/2;for(let n=0;e.pieceData.length>n;n++){const o=e.pieceData[n],a=i(o),h=r(o,e.name),u=h.r||4,d=(7919*n%100/100-.5)*t*.8,g=c?e.middle+d:s(a),m=c?s(a):e.middle+d;l.push({type:"point",x:g,y:m,r:u,style:h,datum:o})}}return l},pie:_,donut:_,boxplot:function(e,t){var n,o,i,r,s;const{scales:a,columns:l,config:c,getR:h,resolveSummaryStyle:u}=e,{r:d,projection:g}=a,m=[],p="vertical"===g,y=!1!==c.showOutliers;for(const e of Object.values(l)){const t=e.pieceData.map(e=>h(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(0===t.length)continue;const a=t[0],l=t[t.length-1],c=null!==(n=f(t,.25))&&void 0!==n?n:a,g=null!==(o=f(t,.5))&&void 0!==o?o:(a+l)/2,v=null!==(i=f(t,.75))&&void 0!==i?i:l,b=v-c,x=c-1.5*b,w=v+1.5*b,A=null!==(r=t.find(e=>e>=x))&&void 0!==r?r:a,k=null!==(s=[...t].reverse().find(e=>w>=e))&&void 0!==s?s:l,E=u(e.pieceData[0],e.name),S=[];if(y)for(const t of e.pieceData){const n=h(t);if(x>n||n>w){const o=p?e.middle:d(n),i=p?d(n):e.middle;S.push({px:o,py:i,value:n,datum:t})}}if(m.push({type:"boxplot",x:p?e.middle:0,y:p?0:e.middle,projection:p?"vertical":"horizontal",columnWidth:.6*e.width,minPos:d(A),q1Pos:d(c),medianPos:d(g),q3Pos:d(v),maxPos:d(k),stats:{min:A,q1:c,median:g,q3:v,max:k},style:E,datum:e.pieceData,category:e.name,outliers:S}),y)for(const e of S)m.push({type:"point",x:e.px,y:e.py,r:3,style:{fill:E.fill||"#999",opacity:.6},datum:e.datum})}return m},violin:function(e,t){var n,o,i;const{scales:r,columns:s,config:a,getR:l,resolveSummaryStyle:c}=e,{r:h,projection:u}=r,d=[],g="vertical"===u,m=a.bins||20,p=!1!==a.showIQR;for(const e of Object.values(s)){const t=e.pieceData.map(e=>l(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const r=t[0],s=t[t.length-1],a=(s-r)/m||1,u=Array(m).fill(0);for(const e of t)u[Math.min(Math.floor((e-r)/a),m-1)]++;const y=Math.max(...u,1),v=e.width/2*.9;let b="";if(g){for(let t=0;m>t;t++){const n=h(r+(t+.5)*a),o=u[t]/y*v;b+=0===t?`M ${e.middle+o} ${n}`:` L ${e.middle+o} ${n}`}for(let t=m-1;t>=0;t--){const n=h(r+(t+.5)*a);b+=` L ${e.middle-u[t]/y*v} ${n}`}b+=" Z"}else{for(let t=0;m>t;t++){const n=h(r+(t+.5)*a),o=u[t]/y*v;b+=0===t?`M ${n} ${e.middle-o}`:` L ${n} ${e.middle-o}`}for(let t=m-1;t>=0;t--)b+=` L ${h(r+(t+.5)*a)} ${e.middle+u[t]/y*v}`;b+=" Z"}const x=c(e.pieceData[0],e.name);let w;if(p&&t.length>=4){const a=null!==(n=f(t,.25))&&void 0!==n?n:r,l=null!==(o=f(t,.5))&&void 0!==o?o:(r+s)/2,c=null!==(i=f(t,.75))&&void 0!==i?i:s;w={q1Pos:h(a),medianPos:h(l),q3Pos:h(c),centerPos:e.middle,isVertical:g}}const A=g?{x:e.x,y:Math.min(h(s),h(r)),width:e.width,height:Math.abs(h(s)-h(r))}:{x:Math.min(h(r),h(s)),y:e.x,width:Math.abs(h(s)-h(r)),height:e.width};d.push({type:"violin",pathString:b,translateX:0,translateY:0,bounds:A,iqrLine:w,stats:B(t),style:x,datum:e.pieceData,category:e.name})}return d},histogram:function(e,t){const{scales:n,columns:o,config:i,getR:r,resolveSummaryStyle:s}=e,{r:a}=n,l=[],c=i.bins||25,h=i.normalize;for(const e of Object.values(o)){const t=e.pieceData.map(e=>r(e)).filter(e=>null!=e&&!isNaN(e));if(0===t.length)continue;const n=Math.min(...t),o=(Math.max(...t)-n)/c||1,i=Array(c).fill(0);for(const e of t)i[Math.min(Math.floor((e-n)/o),c-1)]++;const u=t.length,d=Math.max(...i,1),g=s(e.pieceData[0],e.name);for(let t=0;c>t;t++){if(0===i[t])continue;const r=(h?i[t]/u:i[t]/d)*e.width*.9,s=a(n+t*o),c=a(n+(t+1)*o);l.push($(Math.min(s,c),e.x+e.width-r,Math.abs(c-s),r,g,{bin:t,count:i[t],range:[n+t*o,n+(t+1)*o],category:e.name},e.name))}}return l},ridgeline:function(e,t){var n;const{scales:o,columns:i,config:r,getR:s,resolveSummaryStyle:a}=e,{r:l,projection:c}=o,h=[],u=r.bins||20,d="horizontal"===c,g=r.amplitude||1.5;for(const e of Object.values(i)){const t=e.pieceData.map(e=>s(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const o=t[0],i=t[t.length-1],r=(i-o)/u||1,c=Array(u).fill(0);for(const e of t)c[Math.min(Math.floor((e-o)/r),u-1)]++;const m=Math.max(...c,1),f=a(e.pieceData[0],e.name),p=e.width*g;let y="";if(d){const t=e.x+e.width;y=`M ${l(o)} ${t}`;for(let e=0;u>e;e++)y+=` L ${l(o+(e+.5)*r)} ${t-c[e]/m*p}`;y+=` L ${l(i)} ${t} Z`}else{const t=e.x;y=`M ${t} ${l(o)}`;for(let e=0;u>e;e++){const n=l(o+(e+.5)*r);y+=` L ${t+c[e]/m*p} ${n}`}y+=` L ${t} ${l(i)} Z`}const v=d?{x:Math.min(l(o),l(i)),y:e.x,width:Math.abs(l(i)-l(o)),height:e.width}:{x:e.x,y:Math.min(l(i),l(o)),width:e.width,height:Math.abs(l(i)-l(o))};h.push({type:"violin",pathString:y,translateX:0,translateY:0,bounds:v,stats:B(t),style:Object.assign(Object.assign({},f),{fillOpacity:null!==(n=f.fillOpacity)&&void 0!==n?n:.5}),datum:e.pieceData,category:e.name})}return h},timeline:function(e,t){const{scales:n,columns:o,getRawRange:i,resolvePieceStyle:r}=e,{r:s,projection:a}=n,l=[],c="horizontal"===a;for(const e of Object.values(o))for(const t of e.pieceData){const n=i(t);if(!n)continue;const[o,a]=n,h=r(t,e.name);if(c){const n=s(Math.min(o,a)),i=s(Math.max(o,a));l.push($(n,e.x,i-n,e.width,h,t,e.name))}else{const n=s(Math.max(o,a)),i=s(Math.min(o,a));l.push($(e.x,n,e.width,i-n,h,t,e.name))}}return l}};class D{constructor(e){this.rExtent=new P,this.rExtents=[],this.rAccessors=[],this.categories=new Set,this._colorSchemeMap=null,this._colorSchemeIndex=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.lastIngestTime=0,this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.version=0,this.config=e,this.buffer=new L(e.windowSize),this.getO=N(e.oAccessor||e.categoryAccessor,"category");const t="streaming"===e.runtimeMode,n=e.rAccessor;Array.isArray(n)?(this.rAccessors=n.map(e=>H(e,"value")),this.getR=this.rAccessors[0],this.rExtents=n.map(()=>new P)):(this.getR=H(t&&(e.timeAccessor||e.valueAccessor)&&e.valueAccessor||n,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=N(e.stackBy),this.getGroup=N(e.groupBy),this.getColor=N(e.colorAccessor),this.getConnector=N(e.connectorAccessor),e.pulse&&(this.timestampBuffer=new L(e.windowSize))}ingest(e){const t="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=t,e.bounded){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const n=e.totalSize||e.inserts.length;n>this.buffer.capacity&&(this.buffer.resize(n),this.timestampBuffer&&n>this.timestampBuffer.capacity&&this.timestampBuffer.resize(n));for(const n of e.inserts)this.buffer.push(n),this.timestampBuffer&&this.timestampBuffer.push(t),this.categories.add(this.getO(n)),this.pushValueExtent(n)}else for(const n of e.inserts){const e=this.buffer.push(n);this.timestampBuffer&&this.timestampBuffer.push(t),this.categories.add(this.getO(n)),this.pushValueExtent(n),null!=e&&this.evictValueExtent(e)}return!0}pushValueExtent(e){if("timeline"===this.config.chartType){const t=this.getRawRange(e);t&&(this.rExtent.push(t[0]),this.rExtent.push(t[1]))}else if(this.rAccessors.length>1){for(let t=0;this.rAccessors.length>t;t++)this.rExtents[t].push(this.rAccessors[t](e));this.rExtent.push(this.getR(e))}else this.rExtent.push(this.getR(e))}evictValueExtent(e){if("timeline"===this.config.chartType){const t=this.getRawRange(e);t&&(this.rExtent.evict(t[0]),this.rExtent.evict(t[1]))}else if(this.rAccessors.length>1){for(let t=0;this.rAccessors.length>t;t++)this.rExtents[t].evict(this.rAccessors[t](e));this.rExtent.evict(this.getR(e))}else this.rExtent.evict(this.getR(e))}getRawRange(e){const t=this.config.rAccessor;if(!t)return null;const n="function"==typeof t?t(e):e[t];return Array.isArray(n)&&n.length>=2?[+n[0],+n[1]]:null}computeScene(e){const{config:t,buffer:n}=this;if(0===n.size)return this.scales=null,this.scene=[],this.columns={},void this.version++;this.rExtent.dirty&&this.rExtent.recalculate(n,this.getR);const o=n.toArray(),i=t.projection||"vertical",r=t.oExtent||this.resolveCategories(o),s=this.computeValueDomain(o,r),a="horizontal"===i,l=null!=t.barPadding?t.barPadding/("vertical"===i?e.width:e.height):.1;let c,h;if("radial"===i){c=d().domain(r).range([0,1]).padding(0);const n=Math.min(e.width,e.height)/2,o=t.innerRadius||0;h=g().domain(s).range([o,n])}else a?(c=d().domain(r).range([0,e.height]).padding(l),h=g().domain(s).range([0,e.width])):(c=d().domain(r).range([0,e.width]).padding(l),h=g().domain(s).range([e.height,0]));this.scales={o:c,r:h,projection:i},this.multiScales=this.rAccessors.length>1&&t.multiAxis?this.rAccessors.map((o,i)=>{const r=this.rExtents[i];r.dirty&&r.recalculate(n,o);let[s,l]=r.extent;s===1/0&&(s=0,l=1);const c=l-s,h=c>0?c*(t.extentPadding||.05):1;return s-=h,l+=h,s>0&&(s=0),a?g().domain([s,l]).range([0,e.width]):g().domain([s,l]).range([e.height,0])}):[];let u=o;this.rAccessors.length>1&&(u=o.flatMap(e=>this.rAccessors.map((t,n)=>Object.assign(Object.assign({},e),{__rIndex:n,__rValue:t(e),__rName:this.resolveRAccessorName(n)})))),this.columns=this.buildColumns(u,r,c,i,e),this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(u,e),this.config.decay&&this.applyDecay(this.scene,o),this.config.pulse&&this.applyPulse(this.scene,o),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++}resolveRAccessorName(e){const t=Array.isArray(this.config.rAccessor)?this.config.rAccessor[e]:this.config.rAccessor;return"string"==typeof t?t:"value"+e}resolveCategories(e){const t=Array.from(this.categories),n=this.config.oSort;if("streaming"===this.config.runtimeMode&&void 0===n)return t;if(!1===n)return t;if("function"==typeof n)return t.sort(n);const o=new Map;for(const t of e){const e=this.getO(t);o.set(e,(o.get(e)||0)+Math.abs(this.getR(t)))}return t.sort("asc"===n?(e,t)=>(o.get(e)||0)-(o.get(t)||0):(e,t)=>(o.get(t)||0)-(o.get(e)||0))}computeValueDomain(e,t){var n,o;const i=this.config.chartType,r=this.config.extentPadding||.05;if("radial"===this.config.projection&&("pie"===i||"donut"===i))return[0,1];let s=0,a=0;if("bar"===i&&this.getStack){const t=new Map,n=new Map;for(const o of e){const e=this.getO(o),i=this.getR(o);0>i?n.set(e,(n.get(e)||0)+i):t.set(e,(t.get(e)||0)+i)}for(const e of t.values())e>a&&(a=e);for(const e of n.values())s>e&&(s=e)}else if("bar"===i){const t=new Map;for(const n of e){const e=this.getO(n),o=this.getR(n);t.set(e,(t.get(e)||0)+o)}for(const e of t.values())e>a&&(a=e),s>e&&(s=e)}else if("clusterbar"===i)for(const t of e){const e=this.getR(t);e>a&&(a=e),s>e&&(s=e)}else{const e=this.rExtent.extent[0],t=this.rExtent.extent[1];e!==1/0&&(s=e),t!==-1/0&&(a=t)}this.config.rExtent&&(null!=this.config.rExtent[0]&&(s=this.config.rExtent[0]),null!=this.config.rExtent[1]&&(a=this.config.rExtent[1]));const l=a-s,c=l>0?l*r:1;return(null===(n=this.config.rExtent)||void 0===n?void 0:n[0])||(s-=c),(null===(o=this.config.rExtent)||void 0===o?void 0:o[1])||(a+=c),"bar"!==i&&"clusterbar"!==i||(s>0&&(s=0),0>a&&(a=0)),[s,a]}buildColumns(e,t,n,o,i){var r;const s={},a=new Map;for(const t of e){const e=this.getO(t);a.has(e)||a.set(e,[]),a.get(e).push(t)}let l=0;if("radial"===o)for(const t of e)l+=Math.abs(this.getR(t));const c=this.config.dynamicColumnWidth;let h=null;if(c&&"radial"!==o){h=new Map;let e=0;for(const n of t){const t=a.get(n)||[];let o;o="string"==typeof c?t.reduce((e,t)=>e+(Number(t[c])||0),0):c(t),h.set(n,o),e+=o}const r=("horizontal"===o?i.height:i.width)-n.padding()*n.step()*t.length;if(e>0)for(const[t,n]of h)h.set(t,n/e*r)}let u=0,d=0;for(const e of t){const t=a.get(e)||[],o=t.reduce((e,t)=>e+Math.abs(this.getR(t)),0),i=l>0?o/l:0;let c,g;h?(c=d,g=h.get(e)||n.bandwidth(),d+=g+n.padding()*n.step()):(c=null!==(r=n(e))&&void 0!==r?r:0,g=n.bandwidth()),s[e]={name:e,x:c,y:0,width:g,middle:c+g/2,padding:n.padding()*n.step(),pieceData:t,pct:i,pctStart:u},u+=i}return s}getSceneContext(){return{scales:this.scales,columns:this.columns,config:this.config,getR:this.getR,getStack:this.getStack,getGroup:this.getGroup,getColor:this.getColor,getConnector:this.getConnector,getO:this.getO,multiScales:this.multiScales,rAccessors:this.rAccessors,resolvePieceStyle:(e,t)=>this.resolvePieceStyle(e,t),resolveSummaryStyle:(e,t)=>this.resolveSummaryStyle(e,t),getRawRange:e=>this.getRawRange(e)}}buildSceneNodes(e,t){if(!this.scales)return[];const n=this.getSceneContext(),o=C[this.config.chartType];let i=o?o(n,t):[];if(this.getConnector&&this.scales){const e=function(e,t){const{scales:n,config:o,getConnector:i,getO:r}=e;if(!i||!n)return[];const s=[],{projection:a}=n,l=new Map;for(const e of t){if("point"!==e.type&&"rect"!==e.type)continue;const t=e.datum;if(!t)continue;const n=i(t);if(!n)continue;let o,s;"point"===e.type?(o=e.x,s=e.y):(o=e.x+e.w/2,s=e.y+("vertical"===a?0:e.h/2)),l.has(n)||l.set(n,[]),l.get(n).push({x:o,y:s,datum:t,category:r(t)})}const c=n.o.domain(),h=o.connectorStyle;for(const[e,t]of l)if(t.length>=2){t.sort((e,t)=>c.indexOf(e.category)-c.indexOf(t.category));for(let n=0;t.length-1>n;n++){const o=t[n],i=t[n+1],r="function"==typeof h?h(o.datum):h||{stroke:"#999",strokeWidth:1,opacity:.5};s.push({type:"connector",x1:o.x,y1:o.y,x2:i.x,y2:i.y,style:r,datum:o.datum,group:e})}}return s}(n,i);i=[...e,...i]}return i}resolvePieceStyle(e,t){return"function"==typeof this.config.pieceStyle?this.config.pieceStyle(e,t):this.config.pieceStyle&&"object"==typeof this.config.pieceStyle?this.config.pieceStyle:this.config.barColors&&t?{fill:this.config.barColors[t]||"#007bff"}:t?{fill:this.getColorFromScheme(t)}:{fill:"#007bff"}}getColorFromScheme(e){this._colorSchemeMap||(this._colorSchemeMap=new Map);const t=this._colorSchemeMap.get(e);if(t)return t;const n=Array.isArray(this.config.colorScheme)?this.config.colorScheme:["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],o=n[this._colorSchemeIndex%n.length];return this._colorSchemeIndex++,this._colorSchemeMap.set(e,o),o}resolveSummaryStyle(e,t){return"function"==typeof this.config.summaryStyle?this.config.summaryStyle(e,t):this.config.summaryStyle&&"object"==typeof this.config.summaryStyle?this.config.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}computeDecayOpacity(e,t){var n,o,i;const r=this.config.decay;if(!r||1>=t)return 1;const s=null!==(n=r.minOpacity)&&void 0!==n?n:.1,a=t-1-e;switch(r.type){case"linear":return s+(1-a/(t-1))*(1-s);case"exponential":{const e=null!==(o=r.halfLife)&&void 0!==o?o:t/2;return s+Math.pow(.5,a/e)*(1-s)}case"step":return(null!==(i=r.stepThreshold)&&void 0!==i?i:.5*t)>a?1:s;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("connector"===t.type||"violin"===t.type||"boxplot"===t.type||"wedge"===t.type)continue;const e=r.get(t.datum);if(null==e)continue;const s=this.computeDecayOpacity(e,i),a=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:a*s})}}applyPulse(e,t){var n,o,i;if(!this.config.pulse||!this.timestampBuffer)return;const r="undefined"!=typeof performance?performance.now():Date.now(),s=null!==(n=this.config.pulse.duration)&&void 0!==n?n:500,a=null!==(o=this.config.pulse.color)&&void 0!==o?o:"rgba(255,255,255,0.6)",l=null!==(i=this.config.pulse.glowRadius)&&void 0!==i?i:4,c=new Map;for(let e=0;t.length>e;e++)c.set(t[e],e);for(const t of e){if("connector"===t.type||"violin"===t.type||"boxplot"===t.type||"wedge"===t.type)continue;const e=c.get(t.datum);if(null==e)continue;const n=this.timestampBuffer.get(e);if(null==n)continue;const o=r-n;s>o&&(t._pulseIntensity=1-o/s,t._pulseColor=a,t._pulseGlowRadius=l)}}get hasActivePulses(){var e;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const t="undefined"!=typeof performance?performance.now():Date.now(),n=null!==(e=this.config.pulse.duration)&&void 0!==e?e:500,o=this.timestampBuffer.peek();return null!=o&&n>t-o}snapshotPositions(){var e,t;this.prevPositionMap.clear();for(let n=0;this.scene.length>n;n++){const o=this.scene[n];if("point"===o.type)this.prevPositionMap.set("p:"+n,{x:o.x,y:o.y,r:o.r});else if("rect"===o.type){const i=`r:${o.group||""}:${null!==(t=null===(e=o.datum)||void 0===e?void 0:e.category)&&void 0!==t?t:n}`;this.prevPositionMap.set(i,{x:o.x,y:o.y,w:o.w,h:o.h})}}}startTransition(){var e,t,n,o,i;if(!this.config.transition||0===this.prevPositionMap.size)return;const r=null!==(e=this.config.transition.duration)&&void 0!==e?e:300;let s=!1;for(let e=0;this.scene.length>e;e++){const r=this.scene[e];let a=null;if("point"===r.type?a="p:"+e:"rect"===r.type&&(a=`r:${r.group||""}:${null!==(n=null===(t=r.datum)||void 0===t?void 0:t.category)&&void 0!==n?n:e}`),!a)continue;const l=this.prevPositionMap.get(a);l&&("point"===r.type?l.x===r.x&&l.y===r.y||(r._targetX=r.x,r._targetY=r.y,r.x=l.x,r.y=l.y,s=!0):"rect"===r.type&&(l.x===r.x&&l.y===r.y&&l.w===r.w&&l.h===r.h||(r._targetX=r.x,r._targetY=r.y,r._targetW=r.w,r._targetH=r.h,r.x=l.x,r.y=l.y,r.w=null!==(o=l.w)&&void 0!==o?o:r.w,r.h=null!==(i=l.h)&&void 0!==i?i:r.h,s=!0)))}s&&(this.activeTransition={startTime:"undefined"!=typeof performance?performance.now():Date.now(),duration:r})}advanceTransition(e){var t,n,o;if(!this.activeTransition)return!1;const i=Math.min((e-this.activeTransition.startTime)/this.activeTransition.duration,1),r="linear"===(null===(t=this.config.transition)||void 0===t?void 0:t.easing)?i:1-Math.pow(1-i,3);for(const e of this.scene)if("point"===e.type){if(void 0===e._targetX)continue;const t=this.prevPositionMap.get("p:0");if(!t)continue;e.x=t.x+(e._targetX-t.x)*r,e.y=t.y+(e._targetY-t.y)*r}else if("rect"===e.type){if(void 0===e._targetX)continue;const t=`r:${e.group||""}:${null!==(o=null===(n=e.datum)||void 0===n?void 0:n.category)&&void 0!==o?o:0}`,i=this.prevPositionMap.get(t);if(!i)continue;e.x=i.x+(e._targetX-i.x)*r,e.y=i.y+(e._targetY-i.y)*r,void 0!==i.w&&(e.w=i.w+(e._targetW-i.w)*r,e.h=i.h+(e._targetH-i.h)*r)}if(i>=1){for(const e of this.scene)if("point"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e._targetX=void 0,e._targetY=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}return this.activeTransition=null,!1}return!0}getData(){return this.buffer.toArray()}clear(){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],this.columns={},this.version++}get size(){return this.buffer.size}getOAccessor(){return this.getO}getRAccessor(){return this.getR}updateConfig(e){e.colorScheme!==this.config.colorScheme&&(this._colorSchemeMap=null,this._colorSchemeIndex=0),Object.assign(this.config,e)}}function z(e,t,n){return e.x>t||t>e.x+e.w||e.y>n||n>e.y+e.h?null:{datum:e.datum,x:e.x+e.w/2,y:e.y,distance:0,category:e.group}}function W(e,t,n){const o=t-e.x,i=n-e.y,r=Math.sqrt(o*o+i*i);return r>Math.max(e.r,5)?null:{datum:e.datum,x:e.x,y:e.y,distance:r}}function T(e,t,n){const o=t-e.cx,i=n-e.cy,r=Math.sqrt(o*o+i*i);if(e.innerRadius>r||r>e.outerRadius)return null;let s=Math.atan2(i,o);0>s&&(s+=2*Math.PI);let a=e.startAngle%(2*Math.PI),l=e.endAngle%(2*Math.PI);if(0>a&&(a+=2*Math.PI),0>l&&(l+=2*Math.PI),!(a>l?s>=a||l>=s:s>=a&&l>=s))return null;const c=(e.startAngle+e.endAngle)/2,h=(e.innerRadius+e.outerRadius)/2;return{datum:e.datum,x:e.cx+Math.cos(c)*h,y:e.cy+Math.sin(c)*h,distance:0,category:e.category}}function R(e,t,n){const o=e.columnWidth/2,i=e.stats?Object.assign(Object.assign({},e.stats),{n:Array.isArray(e.datum)?e.datum.length:0,mean:(e.stats.q1+e.stats.median+e.stats.q3)/3}):void 0;if("vertical"===e.projection){if(!(e.x-o>t||t>e.x+o||Math.min(e.minPos,e.maxPos)>n||n>Math.max(e.minPos,e.maxPos)))return{datum:e.datum,x:e.x,y:e.medianPos,distance:0,category:e.category,stats:i}}else{const r=e.y-o,s=e.y+o;if(!(Math.min(e.minPos,e.maxPos)>t||t>Math.max(e.minPos,e.maxPos)||r>n||n>s))return{datum:e.datum,x:e.medianPos,y:e.y,distance:0,category:e.category,stats:i}}return null}function I(e,t,n){if(!e.bounds)return null;const{x:o,y:i,width:r,height:s}=e.bounds;return o>t||t>o+r||i>n||n>i+s?null:{datum:e.datum,x:o+r/2,y:i+s/2,distance:0,category:e.category,stats:e.stats}}const G={fill:t=>e.createElement("rect",{style:t,width:20,height:20}),line:t=>e.createElement("line",{style:t,x1:0,y1:0,x2:20,y2:20})};function F(e,t,n,o){let i;return i="function"==typeof n?n(e):(0,G[n])(o(e,t)),i}function q(t){const{legendGroups:n,customClickBehavior:o,title:i="Legend",width:r=100,height:s=20,orientation:a="vertical"}=t,l="vertical"===a?(({legendGroups:t,width:n,customClickBehavior:o})=>{let i=30;const r=[];return t.forEach((t,s)=>{i+=5,r.push(e.createElement("line",{key:"legend-top-line legend-symbol-"+s,stroke:"gray",x1:0,y1:i,x2:n,y2:i})),i+=10,t.label&&(i+=20,r.push(e.createElement("text",{key:"legend-text-"+s,y:i,className:"legend-group-label"},t.label)),i+=10),r.push(e.createElement("g",{key:"legend-group-"+s,className:"legend-item",transform:`translate(0,${i})`},((t,n)=>{const{type:o="fill",styleFn:i,items:r}=t,s=[];let a=0;return r.forEach((t,r)=>{const l=F(t,r,o,i);s.push(e.createElement("g",{key:"legend-item-"+r,transform:`translate(0,${a})`,onClick:n?()=>n(t):void 0,style:{cursor:n?"pointer":"default"}},l,e.createElement("text",{y:15,x:30},t.label))),a+=25}),s})(t,o))),i+=25*t.items.length+10}),r})({legendGroups:n,width:r,customClickBehavior:o}):(({legendGroups:t,title:n,height:o,customClickBehavior:i})=>{let r=0;const s=[],a=!1===n?10:40;return t.forEach((n,l)=>{n.label&&(s.push(e.createElement("text",{key:"legend-text-"+l,transform:`translate(${r},${a}) rotate(90)`,textAnchor:"start",className:"legend-group-label"},n.label)),r+=20);const c=((t,n)=>{const{type:o="fill",styleFn:i,items:r}=t,s=[];let a=0;return r.forEach((t,r)=>{const l=F(t,r,o,i);s.push(e.createElement("g",{key:"legend-item-"+r,transform:`translate(${a},0)`,onClick:n?()=>n(t):void 0,style:{cursor:n?"pointer":"default"}},l,e.createElement("text",{y:15,x:25},t.label))),a+=35,a+=8*t.label.length}),{items:s,offset:a}})(n,i);s.push(e.createElement("g",{key:"legend-group-"+l,className:"legend-item",transform:`translate(${r},${a})`},c.items)),r+=c.offset+5,t[l+1]&&s.push(e.createElement("line",{key:"legend-top-line legend-symbol-"+l,stroke:"gray",x1:r,y1:a-10,x2:r,y2:o+a+10})),r+=15}),e.createElement("g",null,!1!==n&&e.createElement("line",{x1:0,x2:r+10,y1:a-10,y2:a-10,stroke:"gray",className:"title-neatline"}),s)})({legendGroups:n,title:i,height:s,customClickBehavior:o});return e.createElement("g",null,void 0!==i&&e.createElement("text",{className:"legend-title",y:20,x:"horizontal"===a?0:r/2,textAnchor:"horizontal"===a?"start":"middle"},i),l)}function V(e,t=120,n=8){if(!e)return[];const o=Math.max(1,Math.floor(t/n)),i=e.split(/\s+/),r=[];let s="";for(const e of i)s&&s.length+1+e.length>o?(r.push(s),s=e):s=s?`${s} ${e}`:e;return s&&r.push(s),r}function X(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 Y(t){const{x:n=0,y:o=0,dx:i,dy:r,nx:s,ny:a,note:l,connector:c,subject:h,type:u,color:d,className:g,disable:m,events:f={},"data-testid":p}=t,y=new Set(Array.isArray(m)?m:[]);let v=i||0,b=r||0;null!=s&&(v=s-n),null!=a&&(b=a-o);const x="string"==typeof u?u:"label";if("bracket"===x&&h&&0===v&&0===b)if(void 0!==h.width){v=h.width/2;const e=h.depth||30;b=e+(0>e?-5:5)}else if(void 0!==h.height){const e=h.depth||30;v=e+(0>e?-5:5),b=h.height/2}return e.createElement("g",Object.assign({className:("annotation "+(g||"")).trim(),transform:`translate(${n},${o})`,"data-testid":p},f),!y.has("connector")&&function(t,n,o,i,r,s){const a=[];let l=0,c=0;if("callout-circle"!==r&&"label"!==r||!(null==s?void 0:s.radius)){if("callout-rect"===r&&s){const e=s.width||0,o=s.height||0;if(e>0||o>0){const i=e/2,r=o/2,s=t-i,a=n-r;if(0!==s||0!==a){const t=Math.abs(s),n=Math.abs(a),h=e/2,u=o/2,d=t*u>n*h?h/t:u/n;l=i+s*d,c=r+a*d}}}else if("bracket"===r&&s){const e=s.width,t=s.height,n=s.depth||30;void 0!==e?(l=e/2,c=n):void 0!==t&&(l=n,c=t/2)}}else{const e=(s.radius||0)+(s.radiusPadding||0);if(e>0&&(0!==t||0!==n)){const o=Math.atan2(n,t);l=Math.cos(o)*e,c=Math.sin(o)*e}}if(Math.sqrt(Math.pow(t-l,2)+Math.pow(n-c,2))>.5&&(a.push(e.createElement("line",{key:"connector-line",x1:l,y1:c,x2:t,y2:n,stroke:i||"currentColor"})),"arrow"===(null==o?void 0:o.end))){const o=10,r=16/180*Math.PI,s=Math.atan2(n-c,t-l);a.push(e.createElement("path",{key:"connector-arrow",d:`M${l},${c}L${l+o*Math.cos(s+r)},${c+o*Math.sin(s+r)}L${l+o*Math.cos(s-r)},${c+o*Math.sin(s-r)}Z`,fill:i||"currentColor",stroke:"none"}))}return e.createElement("g",{className:"annotation-connector"},a)}(v,b,c,d,x,h),!y.has("subject")&&function(t,n,o,i,r){var s;const a=[];switch(t){case"callout-circle":{const t=((null==n?void 0:n.radius)||0)+((null==n?void 0:n.radiusPadding)||0);t>0&&a.push(e.createElement("circle",{key:"subject-circle",r:t,fill:"none",stroke:o||"currentColor"}));break}case"callout-rect":{const t=(null==n?void 0:n.width)||0,i=(null==n?void 0:n.height)||0;(t>0||i>0)&&a.push(e.createElement("rect",{key:"subject-rect",width:t,height:i,fill:"none",stroke:o||"currentColor"}));break}case"callout-custom":(null==n?void 0:n.custom)&&a.push(...Array.isArray(n.custom)?n.custom:[n.custom]);break;case"xy-threshold":{const t=i||0,s=r||0;if(void 0!==(null==n?void 0:n.x)){const i=(n.x||0)-t;a.push(e.createElement("line",{key:"threshold-line",x1:i,y1:(n.y1||0)-s,x2:i,y2:(n.y2||0)-s,stroke:o||"currentColor",strokeDasharray:"5,5"}))}else if(void 0!==(null==n?void 0:n.y)){const i=(n.y||0)-s;a.push(e.createElement("line",{key:"threshold-line",x1:(n.x1||0)-t,y1:i,x2:(n.x2||0)-t,y2:i,stroke:o||"currentColor",strokeDasharray:"5,5"}))}else void 0!==(null==n?void 0:n.x1)||void 0!==(null==n?void 0:n.x2)?a.push(e.createElement("line",{key:"threshold-line",x1:(n.x1||0)-t,y1:0,x2:(n.x2||0)-t,y2:0,stroke:o||"currentColor",strokeDasharray:"5,5"})):void 0===(null==n?void 0:n.y1)&&void 0===(null==n?void 0:n.y2)||a.push(e.createElement("line",{key:"threshold-line",x1:0,y1:(n.y1||0)-s,x2:0,y2:(n.y2||0)-s,stroke:o||"currentColor",strokeDasharray:"5,5"}));break}case"bracket":{const t=null!==(s=null==n?void 0:n.width)&&void 0!==s?s:null==n?void 0:n.height;void 0!==t&&a.push(e.createElement("path",{key:"bracket-path",d:X((null==n?void 0:n.type)||"curly",t,(null==n?void 0:n.depth)||30,void 0===(null==n?void 0:n.width)),fill:"none",stroke:o||"currentColor"}));break}}return e.createElement("g",{className:"annotation-subject"},a)}(x,h,d,n,o),!y.has("note")&&function(t,n,o,i){if(!t)return e.createElement("g",{className:"annotation-note"});const{label:r,title:s,orientation:a,align:l,wrap:c=120,noWrap:h}=t;if(!r&&!s)return e.createElement("g",{className:"annotation-note"});let u=a;u||(u=Math.abs(n)>Math.abs(o)?"leftRight":"topBottom");let d=l;d&&"dynamic"!==d||(d="topBottom"===u?0>n?"right":"left":0>o?"bottom":"top");let g="start";"topBottom"===u?"right"===d?g="end":"middle"===d&&(g="middle"):g=0>n?"end":"start";const m=16,f=s?h?[s]:V(s,c):[],p=r?h?[r]:V(r,c):[],y="leftRight"===u?"end"===g?-4:4:0;let v=0;const b=[];f.length>0&&(b.push(e.createElement("text",{key:"annotation-note-title",className:"annotation-note-title",fill:i||void 0,textAnchor:g,fontWeight:"bold"},f.map((t,n)=>e.createElement("tspan",{key:n,x:y,dy:0===n?0:m},t)))),v=f.length*m),p.length>0&&b.push(e.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:i||void 0,textAnchor:g,y:v},p.map((t,n)=>e.createElement("tspan",{key:n,x:y,dy:0===n?0:m},t))));let x=null;if((s||r)&&(0!==n||0!==o))if("topBottom"===u){const t=Math.min(c,120);let n=0,o=t;"end"===g?(n=-t,o=0):"middle"===g&&(n=-t/2,o=t/2),x=e.createElement("line",{className:"note-line",x1:n,x2:o,y1:0,y2:0,stroke:i||"currentColor"})}else{const t=(f.length+p.length)*m+(p.length>0?m:0);let n=0,o=t;"bottom"===d?(n=-t,o=0):"middle"===d&&(n=-t/2,o=t/2),x=e.createElement("line",{className:"note-line",x1:0,x2:0,y1:n,y2:o,stroke:i||"currentColor"})}const w=Math.max(0,f.length+p.length-1)*m;let A=0;return"topBottom"===u?A=0>o?-(w+2):18:"leftRight"===u&&(A="middle"===d?-(w+m+(p.length>0&&f.length>0?2:0))/2+8:"bottom"===d||0>o?-(w+2):18),e.createElement("g",{className:"annotation-note",transform:`translate(${n},${o})`},e.createElement("g",{className:"annotation-note-content",transform:0!==A?`translate(0,${A})`:void 0},b),x)}(l,v,b,d))}function Q(t){var n,o;const{noteData:i}=t,{screenCoordinates:r}=i,s="string"==typeof i.type?i.type:"label",a=i.eventListeners||i.events||{};if(i.coordinates&&r){const t=i.nx||r[0][0]+(null!==(n=i.dx)&&void 0!==n?n:0),a=i.ny||r[0][1]+(null!==(o=i.dy)&&void 0!==o?o:0),l=r.map((n,o)=>{const r=Object.assign({},i,{note:0===o?i.note:{label:""},x:n[0],y:n[1],nx:t,ny:a});return e.createElement(Y,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+o},r,{type:s}))});return e.createElement("g",null,l)}const l=i.note||{title:"none",label:i.label};return e.createElement(Y,Object.assign({"data-testid":"semiotic-annotation",key:`${l.label}-${l.title}-${i.i}`,events:a},i,{type:s}))}function Z(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 U(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 J(e,t,n,o=50){return!(-o>e||e>(n.width||0)+o||-o>t||t>(n.height||0)+o)}function K(e){return Math.round(100*e)/100+""}function ee(t){const{width:n,height:o,totalWidth:r,totalHeight:s,margin:a,scales:l,showAxes:c,oLabel:h,rLabel:u,oFormat:d,rFormat:g,showGrid:m,title:f,legend:y,foregroundGraphics:v,annotations:b,svgAnnotationRules:x,annotationFrame:w,xAccessor:A,yAccessor:k,annotationData:E,children:S}=t,O="radial"===(null==l?void 0:l.projection),M="horizontal"===(null==l?void 0:l.projection),j=i(()=>c&&l&&!O?l.o.domain().map(e=>{var t;return{value:e,pixel:(null!==(t=l.o(e))&&void 0!==t?t:0)+l.o.bandwidth()/2,label:d?d(e):e}}):[],[c,l,d,O]),L=i(()=>c&&l&&!O?l.r.ticks(5).map(e=>({value:e,pixel:l.r(e),label:(g||K)(e)})):[],[c,l,g,O]),P=i(()=>{if(!b||0===b.length)return null;const t=function(t,n,o){var i,r,s,a,l,c,h,u,d,g,m,f,y,v,b,x,w,A,k,E,S,O,M,j,L,P,H,N,$,_,B,C,D,z,W,T,R,I,G;switch(t.type){case"label":{let i=null,r=null;if(null!=t.pointId&&o.pointNodes){const e=o.pointNodes.find(e=>e.pointId===t.pointId);if(!e)return null;i=e.x,r=e.y}else i=Z(t,o),r=U(t,o);return null==i||null==r?null:J(i,r,o)?e.createElement(Q,{key:"ann-"+n,noteData:{x:i,y:r,dx:t.dx||30,dy:t.dy||-30,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"label",connector:t.connector||{end:"arrow"},color:t.color}}):null}case"callout":{let i=null,r=null;if(null!=t.pointId&&o.pointNodes){const e=o.pointNodes.find(e=>e.pointId===t.pointId);if(!e)return null;i=e.x,r=e.y}else i=Z(t,o),r=U(t,o);return null==i||null==r?null:J(i,r,o)?e.createElement(Q,{key:"ann-"+n,noteData:{x:i,y:r,dx:t.dx||30,dy:t.dy||-30,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"callout-circle",subject:{radius:t.radius||12},connector:t.connector||{end:"arrow"},color:t.color}}):null}case"x-threshold":{const i=Z(t,o);if(null==i)return null;const r=t.color||"#f97316";return e.createElement("g",{key:"ann-"+n},e.createElement("line",{x1:i,y1:0,x2:i,y2:o.height||0,stroke:r,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&e.createElement("text",{x:i+4,y:12,fill:r,fontSize:12,fontWeight:"bold"},t.label))}case"y-threshold":{const i=U(t,o);if(null==i)return null;const r=t.color||"#f97316";return e.createElement("g",{key:"ann-"+n},e.createElement("line",{x1:0,y1:i,x2:o.width||0,y2:i,stroke:r,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&e.createElement("text",{x:(o.width||0)-4,y:i-4,textAnchor:"end",fill:r,fontSize:12,fontWeight:"bold"},t.label))}case"enclose":{const i=(t.coordinates||[]).map(e=>({x:Z(Object.assign(Object.assign({},e),{type:"point"}),o),y:U(Object.assign(Object.assign({},e),{type:"point"}),o),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>i.length)return null;const r=p(i),s=t.padding||10;return e.createElement("g",{key:"ann-"+n},e.createElement("circle",{cx:r.x,cy:r.y,r:r.r+s,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&e.createElement("text",{x:r.x,y:r.y-r.r-s-4,textAnchor:"middle",fill:t.color||"#666",fontSize:12},t.label))}case"rect-enclose":{const i=(t.coordinates||[]).map(e=>({x:Z(Object.assign(Object.assign({},e),{type:"point"}),o),y:U(Object.assign(Object.assign({},e),{type:"point"}),o)})).filter(e=>null!=e.x&&null!=e.y);if(2>i.length)return null;const r=t.padding||10,s=i.map(e=>e.x),a=i.map(e=>e.y),l=Math.min(...s)-r,c=Math.max(...s)+r,h=Math.min(...a)-r,u=Math.max(...a)+r;return e.createElement("g",{key:"ann-"+n},e.createElement("rect",{x:l,y:h,width:c-l,height:u-h,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&e.createElement("text",{x:(l+c)/2,y:h-4,textAnchor:"middle",fill:t.color||"#666",fontSize:12},t.label))}case"highlight":{const i=o.data||[],r="function"==typeof t.filter?i.filter(t.filter):t.field&&null!=t.value?i.filter(e=>e[t.field]===t.value):[],s=t.style||{stroke:t.color||"#f97316",strokeWidth:2,fill:"none"};return e.createElement("g",{key:"ann-"+n},r.map((n,i)=>{const r=Z(n,o),a=U(n,o);return null==r||null==a?null:e.createElement("circle",Object.assign({key:i,cx:r,cy:a,r:t.r||6},s))}))}case"bracket":{const i=Z(t,o),r=U(t,o);return e.createElement(Q,{key:"ann-"+n,noteData:{x:null!=i?i:0,y:null!=r?r:0,dx:t.dx||0,dy:t.dy||0,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"bracket",subject:{type:t.bracketType||"curly",width:t.width,height:t.height,depth:t.depth||30},color:t.color}})}case"trend":{const u=o.data||[];if(2>u.length)return null;const d=o.xAccessor||"x",g=o.yAccessor||"y",m=u.map(e=>[e[d],e[g]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>m.length)return null;const f=null!==(r=null===(i=o.scales)||void 0===i?void 0:i.x)&&void 0!==r?r:null===(s=o.scales)||void 0===s?void 0:s.time,p=null!==(l=null===(a=o.scales)||void 0===a?void 0:a.y)&&void 0!==l?l:null===(c=o.scales)||void 0===c?void 0:c.value;if(!f||!p)return null;const y=t.method||"linear";let v;if("loess"===y)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]),s=Math.max(2,Math.ceil(t*n)),a=[];for(let e=0;n>e;e++){const t=i[e],o=i.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 h=0,u=0,d=0,g=0,m=0;for(let e=0;n>e;e++){const t=c[e];0!==t&&(h+=t,u+=t*i[e],d+=t*r[e],g+=t*i[e]*i[e],m+=t*i[e]*r[e])}if(0===h){a.push([t,r[e]]);continue}const f=h*g-u*u;if(1e-12>Math.abs(f))a.push([t,d/h]);else{const e=(h*m-u*d)/f;a.push([t,(d-e*u)/h+e*t])}}return a}(m,null!==(h=t.bandwidth)&&void 0!==h?h:.3);else{let e;try{const n=require("regression");e="polynomial"===y?n.polynomial(m,{order:t.order||2}):n.linear(m)}catch(e){return null}v=e.points}const b=v.map(([e,t])=>`${f(e)},${p(t)}`).join(" "),x=t.color||"#6366f1";return e.createElement("g",{key:"ann-"+n},e.createElement("polyline",{points:b,fill:"none",stroke:x,strokeWidth:t.strokeWidth||2,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&e.createElement("text",{x:f(v[v.length-1][0])+4,y:p(v[v.length-1][1])-4,fill:x,fontSize:11},t.label))}case"band":{const i=null!==(d=null===(u=o.scales)||void 0===u?void 0:u.y)&&void 0!==d?d:null===(g=o.scales)||void 0===g?void 0:g.value,r=null!==(m=null==i?void 0:i(t.y0))&&void 0!==m?m:0,s=null!==(f=null==i?void 0:i(t.y1))&&void 0!==f?f:o.height||0;return e.createElement("g",{key:"ann-"+n},e.createElement("rect",{x:0,y:Math.min(r,s),width:o.width||0,height:Math.abs(s-r),fill:t.fill||"#6366f1",fillOpacity:t.fillOpacity||.1}),t.label&&e.createElement("text",{x:(o.width||0)-4,y:Math.min(r,s)-4,textAnchor:"end",fill:t.color||"#6366f1",fontSize:11},t.label))}case"envelope":{const i=o.data||[];if(2>i.length)return null;const r=o.xAccessor||"x",s=null!==(v=null===(y=o.scales)||void 0===y?void 0:y.x)&&void 0!==v?v:null===(b=o.scales)||void 0===b?void 0:b.time,a=null!==(w=null===(x=o.scales)||void 0===x?void 0:x.y)&&void 0!==w?w:null===(A=o.scales)||void 0===A?void 0:A.value;if(!s||!a)return null;const l=t.upperAccessor||"upperBounds",c=t.lowerAccessor||"lowerBounds",h=t.filter,u=i.filter(e=>null!=e[l]&&null!=e[c]&&!(h&&!h(e))).sort((e,t)=>e[r]-t[r]);if(2>u.length)return null;const d=u.map(e=>`${s(e[r])},${a(e[l])}`).join(" L"),g=u.slice().reverse().map(e=>`${s(e[r])},${a(e[c])}`).join(" L"),m=t.fill||"#6366f1";return e.createElement("g",{key:"ann-"+n},e.createElement("path",{d:`M${d} L${g} Z`,fill:m,fillOpacity:null!==(k=t.fillOpacity)&&void 0!==k?k:.15,stroke:"none"}),t.label&&u.length>0&&e.createElement("text",{x:s(u[u.length-1][r])+4,y:a(u[u.length-1][l])-4,fill:m,fontSize:11},t.label))}case"anomaly-band":{const i=o.data||[];if(2>i.length)return null;const r=o.yAccessor||"y",s=null!==(S=null===(E=o.scales)||void 0===E?void 0:E.x)&&void 0!==S?S:null===(O=o.scales)||void 0===O?void 0:O.time,a=null!==(j=null===(M=o.scales)||void 0===M?void 0:M.y)&&void 0!==j?j:null===(L=o.scales)||void 0===L?void 0:L.value;if(!s||!a)return null;const l=i.map(e=>e[r]).filter(e=>null!=e&&isFinite(e));if(2>l.length)return null;const c=l.reduce((e,t)=>e+t,0)/l.length,h=l.reduce((e,t)=>e+Math.pow(t-c,2),0)/l.length,u=Math.sqrt(h),d=null!==(P=t.threshold)&&void 0!==P?P:2,g=c-d*u,m=!1!==t.showBand,f=t.fill||"#6366f1",p=null!==(H=t.fillOpacity)&&void 0!==H?H:.1,y=t.anomalyColor||"#ef4444",v=null!==(N=t.anomalyRadius)&&void 0!==N?N:6,b=a(c+d*u),x=a(g),w=i.filter(e=>{const t=e[r];return null!=t&&Math.abs(t-c)>d*u});return e.createElement("g",{key:"ann-"+n},m&&e.createElement("rect",{x:0,y:Math.min(b,x),width:o.width||0,height:Math.abs(x-b),fill:f,fillOpacity:p}),w.map((t,n)=>{const i=Z(t,o),r=U(t,o);return null==i||null==r?null:e.createElement("circle",{key:n,cx:i,cy:r,r:v,fill:y,fillOpacity:.7,stroke:y,strokeWidth:1.5})}),t.label&&e.createElement("text",{x:(o.width||0)-4,y:Math.min(b,x)-4,textAnchor:"end",fill:f,fontSize:11},t.label))}case"forecast":{const i=o.data||[];if(3>i.length)return null;const r=o.xAccessor||"x",s=o.yAccessor||"y",a=null!==(_=null===($=o.scales)||void 0===$?void 0:$.x)&&void 0!==_?_:null===(B=o.scales)||void 0===B?void 0:B.time,l=null!==(D=null===(C=o.scales)||void 0===C?void 0:C.y)&&void 0!==D?D:null===(z=o.scales)||void 0===z?void 0:z.value;if(!a||!l)return null;const c=i.map(e=>[e[r],e[s]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]);if(3>c.length)return null;let h;if("polynomial"===(t.method||"linear"))try{const e=require("regression").polynomial(c,{order:t.order||2}).equation;h=t=>e.reduce((e,n,o)=>e+n*Math.pow(t,o),0)}catch(e){return null}else{const e=c.length;let t=0,n=0,o=0,i=0;for(const[e,r]of c)t+=e,n+=r,o+=e*e,i+=e*r;const r=e*o-t*t;if(1e-12>Math.abs(r))return null;const s=(e*i-t*n)/r,a=(n-s*t)/e;h=e=>a+s*e}const u=c.length,d=c.map(([e,t])=>t-h(e)).reduce((e,t)=>e+t*t,0),g=Math.sqrt(d/Math.max(u-2,1)),m=c.reduce((e,t)=>e+t[0],0)/u,f=c.reduce((e,t)=>e+Math.pow(t[0]-m,2),0),p=null!==(W=t.confidence)&&void 0!==W?W:.95,y=.99>p?.95>p?.9>p?1:1.645:1.96:2.576,v=null!==(T=t.steps)&&void 0!==T?T:5,b=c[u-1][0],x=(b-c[0][0])/Math.max(u-1,1),w=[];for(let e=1;v>=e;e++)w.push(b+e*x);const A=[];for(const e of w){const t=h(e),n=g*Math.sqrt(1+1/u+(f>0?Math.pow(e-m,2)/f:0))*y;A.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const k=`M${A.map(e=>`${a(e.x)},${l(e.yUpper)}`).join(" L")} L${A.slice().reverse().map(e=>`${a(e.x)},${l(e.yLower)}`).join(" L")} Z`,E=A.map(e=>`${a(e.x)},${l(e.yCenter)}`).join(" "),S=`${a(b)},${l(h(b))}`,O=t.strokeColor||"#6366f1";return e.createElement("g",{key:"ann-"+n},e.createElement("path",{d:k,fill:t.fill||"#6366f1",fillOpacity:null!==(R=t.fillOpacity)&&void 0!==R?R:.15,stroke:"none"}),e.createElement("polyline",{points:`${S} ${E}`,fill:"none",stroke:O,strokeWidth:null!==(I=t.strokeWidth)&&void 0!==I?I:2,strokeDasharray:null!==(G=t.strokeDasharray)&&void 0!==G?G:"6,3"}),t.label&&A.length>0&&e.createElement("text",{x:a(A[A.length-1].x)+4,y:l(A[A.length-1].yCenter)-4,fill:O,fontSize:11},t.label))}default:return null}},i={scales:l?{x:l.r,y:l.r,time:l.r,value:l.r}:null,timeAxis:"x",xAccessor:A,yAccessor:k,width:n,height:o,data:E,frameType:"ordinal"};return b.map((e,n)=>{if(x){const o=x(e,n,i);return null!=o?o:t(e,n,i)}return t(e,n,i)}).filter(Boolean)},[b,x,n,o,w,A,k,E]);return c||f||y||v||P&&P.length>0||m||S?e.createElement("svg",{width:r,height:s,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},e.createElement("g",{transform:`translate(${a.left},${a.top})`},m&&l&&!O&&e.createElement("g",{className:"ordinal-grid"},L.map((t,i)=>e.createElement("line",{key:"grid-"+i,x1:M?t.pixel:0,y1:M?0:t.pixel,x2:M?t.pixel:n,y2:M?o:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),c&&l&&!O&&e.createElement("g",{className:"ordinal-axes"},M?e.createElement(e.Fragment,null,e.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),j.map((t,n)=>e.createElement("g",{key:"cat-"+n,transform:`translate(0,${t.pixel})`},e.createElement("line",{x2:-5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),e.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"}},t.label))),h&&e.createElement("text",{x:15-a.left,y:o/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",transform:`rotate(-90, ${15-a.left}, ${o/2})`,style:{userSelect:"none"}},h),e.createElement("line",{x1:0,y1:o,x2:n,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),L.map((t,n)=>e.createElement("g",{key:"val-"+n,transform:`translate(${t.pixel},${o})`},e.createElement("line",{y2:5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),e.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"}},t.label))),u&&e.createElement("text",{x:n/2,y:o+40,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},u)):e.createElement(e.Fragment,null,e.createElement("line",{x1:0,y1:o,x2:n,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),j.map((t,n)=>e.createElement("g",{key:"cat-"+n,transform:`translate(${t.pixel},${o})`},e.createElement("line",{y2:5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),e.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"}},t.label))),h&&e.createElement("text",{x:n/2,y:o+40,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},h),e.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),L.map((t,n)=>e.createElement("g",{key:"val-"+n,transform:`translate(0,${t.pixel})`},e.createElement("line",{x2:-5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),e.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"}},t.label))),u&&e.createElement("text",{x:15-a.left,y:o/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",transform:`rotate(-90, ${15-a.left}, ${o/2})`,style:{userSelect:"none"}},u))),P,v,S),f&&e.createElement("text",{x:r/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof f?f:null),y&&e.createElement("g",{transform:`translate(${r-a.right+10}, ${a.top})`},"object"==typeof(H=y)&&null!==H&&!e.isValidElement(H)&&"legendGroups"in H?e.createElement(q,{legendGroups:y.legendGroups,title:"",width:100}):y)):null;var H}const te=(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?ne(e,t):(e.fillStyle=t.style.fill||"#007bff",e.fillRect(t.x,t.y,t.w,t.h),t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.strokeRect(t.x,t.y,t.w,t.h))),t._pulseIntensity&&t._pulseIntensity>0&&(e.globalAlpha=.3*t._pulseIntensity,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h)),e.globalAlpha=1};function ne(e,t){const n=t.style.icon,o=t.style.iconPadding||2,i=Math.min(t.w,t.w)-o;if(0>=i)return;const 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,s=t.x+(t.w-i)/2;for(let o=t.y+t.h-i;o>=t.y-i;o-=r)e.drawImage(n,s,o,i,i)}else{const r=i+o,s=t.y+(t.h-i)/2;for(let o=t.x;t.x+t.w>o;o+=r)e.drawImage(n,o,s,i,i)}e.restore()}const oe=(e,t,n,o)=>{var i,r;const s=t.filter(e=>"point"===e.type);for(const t of s){e.beginPath(),e.arc(t.x,t.y,t.r,0,2*Math.PI);const n=null!==(i=t.style.opacity)&&void 0!==i?i:t.style.fillOpacity;if(null!=n&&(e.globalAlpha=n),e.fillStyle=t.style.fill||"#4e79a7",e.fill(),t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()),t._pulseIntensity&&t._pulseIntensity>0){const n=null!==(r=t._pulseGlowRadius)&&void 0!==r?r:4,o=t.r+n*t._pulseIntensity;e.beginPath(),e.arc(t.x,t.y,o,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=.6*t._pulseIntensity,e.stroke()}e.globalAlpha=1}},ie=(e,t,n,o)=>{const i=t.filter(e=>"wedge"===e.type);for(const t of i)e.beginPath(),t.innerRadius>0?(e.arc(t.cx,t.cy,t.outerRadius,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerRadius,t.endAngle,t.startAngle,!0)):(e.moveTo(t.cx,t.cy),e.arc(t.cx,t.cy,t.outerRadius,t.startAngle,t.endAngle)),e.closePath(),null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),null!=t.style.fillOpacity&&(e.globalAlpha=t.style.fillOpacity),e.fillStyle=t.style.fill||"#007bff",e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()),e.globalAlpha=1},re=(e,t,n,o)=>{var i,r;const s=t.filter(e=>"violin"===e.type);for(const t of s){e.save(),(t.translateX||t.translateY)&&e.translate(t.translateX,t.translateY);const n=new Path2D(t.pathString);if(e.globalAlpha=null!==(r=null!==(i=t.style.fillOpacity)&&void 0!==i?i:t.style.opacity)&&void 0!==r?r:.6,e.fillStyle=t.style.fill||"#007bff",e.fill(n),e.globalAlpha=1,t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke(n)),t.iqrLine){e.strokeStyle="#333",e.lineWidth=2,e.globalAlpha=.8;const n=t.iqrLine.centerPos,o=!1!==t.iqrLine.isVertical;e.beginPath(),o?(e.moveTo(n,t.iqrLine.q1Pos),e.lineTo(n,t.iqrLine.q3Pos)):(e.moveTo(t.iqrLine.q1Pos,n),e.lineTo(t.iqrLine.q3Pos,n)),e.stroke(),e.beginPath(),o?e.arc(n,t.iqrLine.medianPos,3,0,2*Math.PI):e.arc(t.iqrLine.medianPos,n,3,0,2*Math.PI),e.fillStyle="#fff",e.fill(),e.strokeStyle="#333",e.lineWidth=1,e.stroke(),e.globalAlpha=1}e.restore()}},se=(e,t,n,o)=>{var i,r,s;const a=t.filter(e=>"connector"===e.type);if(0===a.length)return;const l=new Map;for(const e of a){const t=e.group||"_default";l.has(t)||l.set(t,[]),l.get(t).push(e)}for(const[,t]of l){if(0===t.length)continue;const n=t[0].style;if(n.fill&&"none"!==n.fill){e.beginPath(),e.moveTo(t[0].x1,t[0].y1);for(const n of t)e.lineTo(n.x2,n.y2);e.closePath(),e.globalAlpha=null!==(r=null!==(i=n.fillOpacity)&&void 0!==i?i:n.opacity)&&void 0!==r?r:.3,e.fillStyle=n.fill,e.fill(),e.globalAlpha=1}for(const n of t)e.beginPath(),e.moveTo(n.x1,n.y1),e.lineTo(n.x2,n.y2),e.strokeStyle=n.style.stroke||n.style.fill||"#999",e.lineWidth=n.style.strokeWidth||1,e.globalAlpha=null!==(s=n.style.opacity)&&void 0!==s?s:.5,e.stroke(),e.globalAlpha=1}},ae=e=>[se,...e],le={bar:ae([te]),clusterbar:ae([te]),point:ae([oe]),swarm:ae([oe]),pie:[ie],donut:[ie],boxplot:ae([(e,t,n,o)=>{var i,r;const s=t.filter(e=>"boxplot"===e.type);for(const t of s){const n=t.columnWidth/2,o="vertical"===t.projection,s=t.style.fill||"#007bff",a=t.style.stroke||"#333",l=t.style.strokeWidth||1,c=null!==(r=null!==(i=t.style.fillOpacity)&&void 0!==i?i:t.style.opacity)&&void 0!==r?r:.6;if(e.save(),e.strokeStyle=a,e.lineWidth=l,e.beginPath(),o?(e.moveTo(t.x,t.minPos),e.lineTo(t.x,t.maxPos)):(e.moveTo(t.minPos,t.y),e.lineTo(t.maxPos,t.y)),e.stroke(),e.beginPath(),o?(e.moveTo(t.x-.4*n,t.minPos),e.lineTo(t.x+.4*n,t.minPos),e.moveTo(t.x-.4*n,t.maxPos),e.lineTo(t.x+.4*n,t.maxPos)):(e.moveTo(t.minPos,t.y-.4*n),e.lineTo(t.minPos,t.y+.4*n),e.moveTo(t.maxPos,t.y-.4*n),e.lineTo(t.maxPos,t.y+.4*n)),e.stroke(),e.globalAlpha=c,e.fillStyle=s,o){const o=Math.min(t.q1Pos,t.q3Pos),i=Math.abs(t.q3Pos-t.q1Pos);e.fillRect(t.x-n,o,t.columnWidth,i),e.globalAlpha=1,e.strokeRect(t.x-n,o,t.columnWidth,i)}else{const o=Math.min(t.q1Pos,t.q3Pos),i=Math.abs(t.q3Pos-t.q1Pos);e.fillRect(o,t.y-n,i,t.columnWidth),e.globalAlpha=1,e.strokeRect(o,t.y-n,i,t.columnWidth)}e.strokeStyle="#fff",e.lineWidth=2,e.beginPath(),o?(e.moveTo(t.x-n,t.medianPos),e.lineTo(t.x+n,t.medianPos)):(e.moveTo(t.medianPos,t.y-n),e.lineTo(t.medianPos,t.y+n)),e.stroke(),e.restore()}},oe]),violin:ae([re]),histogram:ae([te]),ridgeline:ae([re]),timeline:ae([te])},ce={top:50,right:40,bottom:60,left:70},he={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:"4px",fontSize:"13px",lineHeight:"1.4",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function ue({hover:t}){var n,o,i,r;const s=t.data||{},a=t.stats,l=t.category;if(Array.isArray(s)){const t=l||(null===(n=s[0])||void 0===n?void 0:n.category)||"";if(a)return e.createElement("div",{className:"semiotic-tooltip",style:he},t&&e.createElement("div",{style:{fontWeight:"bold"}},t+""),e.createElement("div",null,"n = ",a.n),e.createElement("div",null,"Min: ",a.min.toLocaleString()),e.createElement("div",null,"Q1: ",a.q1.toLocaleString()),e.createElement("div",null,"Median: ",a.median.toLocaleString()),e.createElement("div",null,"Q3: ",a.q3.toLocaleString()),e.createElement("div",null,"Max: ",a.max.toLocaleString()),e.createElement("div",{style:{opacity:.8}},"Mean: ",a.mean.toLocaleString(void 0,{maximumFractionDigits:2})));const o=s.length;return e.createElement("div",{className:"semiotic-tooltip",style:he},t&&e.createElement("div",{style:{fontWeight:"bold"}},t+""),e.createElement("div",null,o," items"))}if(null!=s.bin&&null!=s.count){const t=s.range||[];return e.createElement("div",{className:"semiotic-tooltip",style:he},s.category&&e.createElement("div",{style:{fontWeight:"bold"}},s.category+""),e.createElement("div",null,"Count: ",s.count),2===t.length&&e.createElement("div",{style:{opacity:.8}},Number(t[0]).toFixed(1)," – ",Number(t[1]).toFixed(1)))}const c=s.category||s.name||s.group||s.__rName||"",h=null!==(r=null!==(i=null!==(o=s.value)&&void 0!==o?o:s.__rValue)&&void 0!==i?i:s.pct)&&void 0!==r?r:"";if(!c&&""===h){const t=Object.entries(s).filter(([e])=>!e.startsWith("_")&&"data"!==e);return e.createElement("div",{className:"semiotic-tooltip",style:he},t.map(([t,n])=>e.createElement("div",{key:t},e.createElement("span",{style:{opacity:.7}},t,":")," ","number"==typeof n?n.toLocaleString():n+"")))}return e.createElement("div",{className:"semiotic-tooltip",style:he},c&&e.createElement("div",{style:{fontWeight:"bold"}},c+""),""!==h&&e.createElement("div",null,"number"==typeof h?h.toLocaleString():h+""))}const de=r(function(r,l){var c;const{chartType:h,runtimeMode:u,data:d,oAccessor:g="category",rAccessor:m="value",colorAccessor:f,stackBy:p,groupBy:y,multiAxis:v,timeAccessor:b,valueAccessor:x,categoryAccessor:w,projection:A="vertical",size:k=[600,400],responsiveWidth:E,responsiveHeight:S,margin:O,barPadding:M,innerRadius:L,normalize:P,startAngle:H,dynamicColumnWidth:N,bins:$,showOutliers:_,showIQR:B,amplitude:C,connectorAccessor:G,connectorStyle:F,rExtent:q,oExtent:V,extentPadding:X=.05,oSort:Y,windowMode:Q="sliding",windowSize:Z=200,pieceStyle:U,summaryStyle:J,colorScheme:K,barColors:te,showAxes:ne=!0,oLabel:oe,rLabel:ie,oFormat:re,rFormat:se,enableHover:ae=!0,hoverAnnotation:he,tooltipContent:de,customHoverBehavior:ge,annotations:me,svgAnnotationRules:fe,showGrid:pe=!1,legend:ye,backgroundGraphics:ve,foregroundGraphics:be,title:xe,className:we,background:Ae,centerContent:ke,decay:Ee,pulse:Se,transition:Oe,staleness:Me}=r,[je,Le]=function(e,i,r){const s=t(null),[a,l]=n(null);return o(()=>{if(!i&&!r)return;const e=s.current;if(!e)return;const t=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;l(t=>t&&t.w===e&&t.h===n?t:{w:e,h:n})}});return t.observe(e),()=>t.disconnect()},[i,r]),[s,[i&&a?a.w:e[0],r&&a?a.h:e[1]]]}(k,E,S),Pe=i(()=>Object.assign(Object.assign({},ce),O),[O]),He=Le[0]-Pe.left-Pe.right,Ne=Le[1]-Pe.top-Pe.bottom,$e=t(null),_e=t(!0),Be=t(0),Ce=t(null),De=t(()=>{}),[ze,We]=n(null),[Te,Re]=n(null),[Ie,Ge]=n(0),[Fe,qe]=n(!1),Ve=ae||he,Xe="streaming"===u,Ye=i(()=>({chartType:h,runtimeMode:Xe?"streaming":"bounded",windowSize:Z,windowMode:Q,extentPadding:X,projection:A,oAccessor:Xe?void 0:g,rAccessor:Xe?void 0:m,colorAccessor:f,stackBy:p,groupBy:y,multiAxis:v,timeAccessor:Xe?b:void 0,valueAccessor:Xe?x||("string"==typeof m||"function"==typeof m?m:void 0):void 0,categoryAccessor:Xe?w||g:void 0,rExtent:q,oExtent:V,barPadding:M,innerRadius:L,normalize:P,startAngle:H,dynamicColumnWidth:N,bins:$,showOutliers:_,showIQR:B,amplitude:C,connectorAccessor:G,connectorStyle:F,oSort:Y,pieceStyle:U,summaryStyle:J,colorScheme:K,barColors:te,decay:Ee,pulse:Se,transition:Oe,staleness:Me}),[h,Z,Q,X,A,g,m,f,p,y,v,b,x,w,q,V,M,L,P,H,N,$,_,B,C,G,F,Y,U,J,K,te,Ee,Se,Oe,Me,Xe]),Qe=t(null);Qe.current||(Qe.current=new D(Ye));const Ze=s(()=>{Be.current||(Be.current=requestAnimationFrame(()=>De.current()))},[]);o(()=>{var e;null===(e=Qe.current)||void 0===e||e.updateConfig(Ye),_e.current=!0,Ze()},[Ye,Ze]);const Ue=t(null);Ue.current||(Ue.current=new j(e=>{const t=Qe.current;t&&t.ingest(e)&&(_e.current=!0,Ze())}));const Je=s(e=>{var t;null===(t=Ue.current)||void 0===t||t.push(e)},[]),Ke=s(e=>{var t;null===(t=Ue.current)||void 0===t||t.pushMany(e)},[]),et=s(()=>{var e,t;null===(e=Ue.current)||void 0===e||e.clear(),null===(t=Qe.current)||void 0===t||t.clear(),_e.current=!0,Ze()},[Ze]);a(l,()=>({push:Je,pushMany:Ke,clear:et,getData:()=>{var e,t;return null!==(t=null===(e=Qe.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=Qe.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null}}),[Je,Ke,et]),o(()=>{var e;d&&(null===(e=Ue.current)||void 0===e||e.setBoundedData(d))},[d]);const tt=t(()=>{}),nt=t(()=>{});tt.current=e=>{if(!Ve)return;const t=$e.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-Pe.left,i=e.clientY-n.top-Pe.top;if(0>o||o>He||0>i||i>Ne)return void(Ce.current&&(Ce.current=null,We(null),ge&&ge(null),Ze()));const r=Qe.current;if(!r||0===r.scene.length)return;const s="radial"===A,a=function(e,t,n,o=30){let i=null;for(const r of e){let e=null;switch(r.type){case"rect":e=z(r,t,n);break;case"point":e=W(r,t,n);break;case"wedge":e=T(r,t,n);break;case"boxplot":e=R(r,t,n);break;case"violin":e=I(r,t,n)}e&&o>e.distance&&(i&&e.distance>=i.distance||(i=e))}return i}(r.scene,s?o-He/2:o,s?i-Ne/2:i);if(!a)return void(Ce.current&&(Ce.current=null,We(null),ge&&ge(null),Ze()));const l=Object.assign(Object.assign({data:a.datum,time:a.x,value:a.y,x:a.x,y:a.y},a.stats&&{stats:a.stats}),a.category&&{category:a.category});Ce.current=l,We(l),ge&&(ge(l),_e.current=!0),Ze()},nt.current=()=>{Ce.current&&(Ce.current=null,We(null),ge&&(ge(null),_e.current=!0),Ze())},s(e=>tt.current(e),[]);const ot=s(()=>nt.current(),[]),it=t(-1),rt=s(e=>{const t=Qe.current;if(!t||0===t.scene.length)return;const n=function(e){const t=[];for(const n of e)if("rect"===n.type&&null!=n.x)t.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum});else if("point"===n.type)t.push({x:n.x,y:n.y,datum:n.datum});else if("wedge"===n.type&&null!=n.cx){const e=((n.startAngle||0)+(n.endAngle||0))/2,o=((n.innerRadius||0)+(n.outerRadius||50))/2;t.push({x:n.cx+Math.cos(e)*o,y:n.cy+Math.sin(e)*o,datum:n.datum})}return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}(t.scene);if(0===n.length)return;const o=it.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 it.current=-1,Ce.current=null,We(null),ge&&ge(null),void Ze();const r=0>o?0:i;it.current=r;const s={data:(a=n[r]).datum,x:a.x,y:a.y,time:a.x,value:a.y};var a;Ce.current=s,We(s),ge&&ge(s),Ze()},[ge,Ze]),st=s(e=>{it.current=-1,tt.current(e)},[]);De.current=()=>{var e,t;Be.current=0;const n=$e.current;if(!n)return;const o=n.getContext("2d");if(!o)return;const i=Qe.current;if(!i)return;const r="undefined"!=typeof performance?performance.now():Date.now(),s=i.advanceTransition(r),a=_e.current;a&&!s&&(i.computeScene({width:He,height:Ne}),_e.current=!1);const l="undefined"!=typeof window&&window.devicePixelRatio||1;n.width=Le[0]*l,n.height=Le[1]*l,n.style.width=Le[0]+"px",n.style.height=Le[1]+"px",o.scale(l,l),o.clearRect(0,0,Le[0],Le[1]);const c=null!==(e=null==Me?void 0:Me.threshold)&&void 0!==e?e:5e3,u=Me&&i.lastIngestTime>0&&r-i.lastIngestTime>c;u&&(o.globalAlpha=null!==(t=null==Me?void 0:Me.dimOpacity)&&void 0!==t?t:.5);const d=n?getComputedStyle(n).getPropertyValue("--semiotic-bg").trim():"",g=Ae||(d&&"transparent"!==d?d:null);g&&(o.fillStyle=g,o.fillRect(0,0,Le[0],Le[1]));const m="radial"===A;m?(o.save(),o.translate(Pe.left+He/2,Pe.top+Ne/2)):o.translate(Pe.left,Pe.top);const f=le[h]||[],p={width:He,height:Ne};for(const e of f)e(o,i.scene,i.scales,p);m&&o.restore(),u&&(o.globalAlpha=1),a&&i.scales&&(Re(i.scales),Ge(e=>e+1)),(null==Me?void 0:Me.showBadge)&&qe(!!u),(s||i.hasActivePulses)&&(Be.current=requestAnimationFrame(()=>De.current()))},o(()=>(Ze(),()=>{Be.current&&(cancelAnimationFrame(Be.current),Be.current=0)}),[Ze]),o(()=>{_e.current=!0,Ze()},[h,He,Ne,ne,Ae,Ze]),o(()=>{if(!Me)return;const e=setInterval(()=>{var e;const t=Qe.current;if(!t||0===t.lastIngestTime)return;const n="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(e=Me.threshold)&&void 0!==e?e:5e3,i=n-t.lastIngestTime>o;i!==Fe&&(qe(i),_e.current=!0,Ze())},1e3);return()=>clearInterval(e)},[Me,Fe,Ze]);const at=Ve&&ze?de?de(ze):e.createElement(ue,{hover:ze}):null,lt="radial"===A,ct=ze?lt?ze.x+He/2:ze.x:0,ht=ze?lt?ze.y+Ne/2:ze.y:0,ut=at?e.createElement("div",{className:"stream-ordinal-tooltip",style:{position:"absolute",left:Pe.left+ct,top:Pe.top+ht,transform:`translate(${ct>.7*He?"calc(-100% - 12px)":"12px"}, ${.3*Ne>ht?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:1}},at):null;return e.createElement("div",{ref:je,className:"stream-ordinal-frame"+(we?" "+we:""),role:"img","aria-label":"string"==typeof xe?xe:"Ordinal chart",tabIndex:0,style:{position:"relative",width:E?"100%":Le[0],height:S?"100%":Le[1]},onMouseMove:Ve?st:void 0,onMouseLeave:Ve?ot:void 0,onKeyDown:rt},ve&&e.createElement("svg",{style:{position:"absolute",top:0,left:0,width:Le[0],height:Le[1],pointerEvents:"none"}},e.createElement("g",{transform:`translate(${Pe.left},${Pe.top})`},ve)),e.createElement("canvas",{ref:$e,style:{position:"absolute",top:0,left:0,width:Le[0],height:Le[1]}}),e.createElement(ee,{width:He,height:Ne,totalWidth:Le[0],totalHeight:Le[1],margin:Pe,scales:Te,showAxes:ne,oLabel:oe,rLabel:ie,oFormat:re,rFormat:se,showGrid:pe,title:xe,legend:ye,foregroundGraphics:be,annotations:me,svgAnnotationRules:fe,annotationFrame:Ie,xAccessor:"string"==typeof g?g:void 0,yAccessor:"string"==typeof m?m:void 0,annotationData:null===(c=Qe.current)||void 0===c?void 0:c.getData()}),ke&&"radial"===A&&e.createElement("div",{style:{position:"absolute",left:Pe.left+He/2,top:Pe.top+Ne/2,transform:"translate(-50%, -50%)",pointerEvents:"none",textAlign:"center"}},ke),(null==Me?void 0:Me.showBadge)&&e.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===Me.badgePosition?{top:4,left:4}:"bottom-left"===Me.badgePosition?{bottom:4,left:4}:"bottom-right"===Me.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:Fe?"#dc3545":"#28a745",color:"white"})},Fe?"STALE":"LIVE"),ut)});de.displayName="StreamOrdinalFrame";const ge={category10:y,tableau10:O,set3:S,blues:E,reds:k,greens:A,oranges:w,purples:x,viridis:b,plasma:v},me=y;function fe(e,t,n){if("function"==typeof t)return t(e);const o=e[t];return n?n(o):me[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+""))%me.length]}function pe(e,t,n="category10"){const o=Array.from(new Set(e.map(e=>e[t]))),i=o.every(e=>"number"==typeof e||!isNaN(Number(e)));if(Array.isArray(n))return m().domain(o).range(n).unknown("#999");const r=ge[n]||ge.category10;if(i&&"function"==typeof r)return e=>r(Number(e)/Math.max(...o.map(Number)));{const e=Array.isArray(r)?r:me;return m().domain(o).range(e).unknown("#999")}}const ye=c(null);function ve(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}function be(t){const o=c(null),r=xe(t);return[function({children:n}){const r=i(()=>xe(t),[]);return e.createElement(o.Provider,{value:r,children:n})},e=>{var t;const i=null!==(t=l(o))&&void 0!==t?t:r;return function(e,t){const[o,i]=n(t);return h(()=>e(()=>i(t)),[e]),o}(i.subscribe,()=>e(i.getState()))}]}function xe(e){const t=new EventTarget;let n=e(function(e){n=Object.assign(Object.assign({},n),e(n)),t.dispatchEvent(new CustomEvent("update"))});return{getState:()=>n,subscribe:function(e){return t.addEventListener("update",e),()=>t.removeEventListener("update",e)}}}function we(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 Ae(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}const[ke,Ee]=be(e=>({selections:new Map,setClause(t,n){e(e=>{const o=new Map(e.selections),i=Ae(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=Ae(o,t);return o.set(t,Object.assign(Object.assign({},i),{resolution:n})),{selections:o}})},clearSelection(t){e(e=>{const n=new Map(e.selections),o=n.get(t);return o&&n.set(t,Object.assign(Object.assign({},o),{clauses:new Map})),{selections:n}})}}));function Se(e){const t=u(),n=e.clientId||t,{name:o}=e,r=Ee(e=>e.selections.get(o)),a=Ee(e=>e.setClause),l=Ee(e=>e.clearClause),c=i(()=>!!r&&r.clauses.size>0,[r]);return{predicate:i(()=>r&&0!==r.clauses.size?function(e,t){const n=[];for(const[o,i]of e.clauses)"crossfilter"===e.resolution&&o===t||n.push(we(i));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(r,n):()=>!0,[r,n]),isActive:c,selectPoints:s(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"point",values:new Set(o)};a(o,{clientId:n,type:"point",fields:t})},[n,o,a]),selectInterval:s(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"interval",range:o};a(o,{clientId:n,type:"interval",fields:t})},[n,o,a]),clear:s(()=>{l(o,n)},[l,o,n]),clientId:n}}const[Oe,Me]=be(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}))}})),je="#007bff";function Le(e,t,n="category10"){const o=l(ye);return i(()=>{if(t&&"function"!=typeof t)return o&&Object.keys(o).length>0?i=>o[i]||pe(e,t,n)(i):pe(e,t,n)},[e,t,n,o])}function Pe(e,t,n){return i(()=>{if(!t)return e;const o=[...e];if("function"==typeof t)return o.sort(t);const i="function"==typeof(r=n)?r:e=>e[r];var r;return o.sort("asc"===t?(e,t)=>i(e)-i(t):(e,t)=>i(t)-i(e))},[e,t,n])}function He({selection:e,linkedHover:t,fallbackFields:n=[],unwrapData:o=!1,onObservation:i,chartType:r,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}(t,n),c=Se({name:(null==e?void 0:e.name)||"__unused__"}),h=function(e){const t=e.name||"hover",{fields:n}=e,{predicate:o,isActive:i,selectPoints:r,clear:a}=Se({name:t});return{onHover:s(e=>{if(!e)return void a();const t={};for(const o of n){const n=e[o];void 0!==n&&(t[o]=[n])}Object.keys(t).length>0&&r(t)},[n,r,a,t]),predicate:o,isActive:i}}({name:(null==l?void 0:l.name)||"hover",fields:(null==l?void 0:l.fields)||n||[]}),u=Me(e=>e.pushObservation),d=e?{isActive:c.isActive,predicate:c.predicate}:null,g=s(e=>{var n,o;if(t)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]),h.onHover(t)}else h.onHover(null);if(i||u){const t={timestamp:Date.now(),chartType:r||"unknown",chartId:a};if(e){let r=e.data||e.datum||e;Array.isArray(r)&&(r=r[0]);const s=Object.assign(Object.assign({},t),{type:"hover",datum:r||{},x:null!==(n=e.x)&&void 0!==n?n:0,y:null!==(o=e.y)&&void 0!==o?o:0});i&&i(s),u&&u(s)}else{const e=Object.assign(Object.assign({},t),{type:"hover-end"});i&&i(e),u&&u(e)}}},[t,h,i,r,a,u]),m=s(e=>{var t,n;if(i||u){const o={timestamp:Date.now(),chartType:r||"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),u&&u(s)}else{const e=Object.assign(Object.assign({},o),{type:"click-end"});i&&i(e),u&&u(e)}}},[i,u,r,a]);return{activeSelectionHook:d,customHoverBehavior:g,customClickBehavior:m}}function Ne({data:e,colorBy:t,colorScale:n,showLegend:o,userMargin:r,defaults:s={top:50,bottom:60,left:70,right:40}}){const a=void 0!==o?o:!!t,l=i(()=>{if(a&&t)return function({data:e,colorBy:t,colorScale:n,getColor:o,strokeColor:i,strokeWidth:r}){return{legendGroups:[{styleFn:e=>{const t={fill:e.color,stroke:e.color};return void 0!==i&&(t.stroke=i),void 0!==r&&(t.strokeWidth=r),t},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),s=r?o(r,t,n):n?n(i):"#000000";return{label:i+"",color:s}}),label:""}]}}({data:e,colorBy:t,colorScale:n,getColor:fe})},[a,t,e,n]),c=i(()=>{const e=Object.assign(Object.assign({},s),r);return l&&120>e.right&&(e.right=120),e},[s,r,l]);return{legend:l,margin:c}}const $e={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 _e(e,t,n){var o,i,r,s,a,l;const c=$e[e||"primary"],h="context"===e||"sparkline"===e;return{width:null!==(o=t.width)&&void 0!==o?o:c.width,height:null!==(i=t.height)&&void 0!==i?i:c.height,showAxes:c.showAxes,showGrid:null!==(r=t.showGrid)&&void 0!==r?r:c.showGrid,enableHover:null!==(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:h?void 0:t.title,xLabel:h?void 0:t.xLabel,yLabel:h?void 0:t.yLabel,categoryLabel:h?void 0:t.categoryLabel,valueLabel:h?void 0:t.valueLabel,marginDefaults:c.marginDefaults}}const Be={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 Ce(e,t){return"function"==typeof t?t(e):e[t]}function De(e,t){return t?t(e):null==e?"":"number"==typeof e?e.toLocaleString():e instanceof Date?e.toLocaleDateString():"object"==typeof e&&null!==e?void 0!==e.id?e.id+"":void 0!==e.name?e.name+"":JSON.stringify(e):e+""}function ze(t){return!0===t||("function"==typeof t?t:!1!==t&&void 0!==t&&("object"!=typeof t||null===t||!("fields"in t)&&!("title"in t)||function(t={}){const{fields:n,title:o,format:i,style:r={},className:s=""}=t;return t=>{if(!t||"object"!=typeof t)return null;let a;const l=[];if(o){const e=Ce(t,o);a=De(e,i)}if(n&&n.length>0)n.forEach(e=>{let n,o,r;"string"==typeof e?(n=e,o=e,r=i):(n=e.label,o=e.accessor||e.key||"",r=e.format||i);const s=Ce(t,o);l.push({label:n,value:De(s,r)})});else if(!o){const e=["value","y","name","id","label"];for(const n of e)if(void 0!==t[n]){a=De(t[n],i);break}if(!a){const e=Object.keys(t).filter(e=>!e.startsWith("_"));e.length>0&&(a=De(t[e[0]],i))}}const c=Object.assign(Object.assign({},Be),r);return e.createElement("div",{className:("semiotic-tooltip "+s).trim(),style:c},a&&e.createElement("div",{style:{fontWeight:l.length>0?"bold":"normal"}},a),l.map((t,n)=>e.createElement("div",{key:n,style:{marginTop:0===n&&a?"4px":0}},t.label&&e.createElement("span",null,t.label,": "),t.value)))}}(t)))}function We(e){return null==e?"–":"number"==typeof e?Math.abs(e)>9999?e.toLocaleString():e+"":e instanceof Date?e.toLocaleDateString():e+""}function Te(e,t){return"function"==typeof t?t(e):e[t]}function Re({categoryAccessor:t,valueAccessor:n,groupAccessor:o,groupLabel:i,pieData:r=!1}){return s=>{var a;const l=r?(null===(a=s.data)||void 0===a?void 0:a[0])||s.data||s:s.data||s,c=Te(l,t),h=Te(l,n),u=o?Te(l,o):void 0;return e.createElement("div",{className:"semiotic-tooltip",style:Be},e.createElement("div",{style:{fontWeight:"bold"}},We(c)),e.createElement("div",{style:{marginTop:4}},We(h)),null!=u&&e.createElement("div",{style:{marginTop:2,opacity:.8}},i||("string"==typeof(d=o)?d:"value"),": ",We(u)));var d}}function Ie({componentName:t,message:n,width:o,height:i}){return e.createElement("div",{role:"alert",style:{width:o,height:Math.max(i,120),display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed rgba(128, 128, 128, 0.4)",borderRadius:8,background:"rgba(128, 128, 128, 0.04)",padding:24,boxSizing:"border-box"}},e.createElement("div",{style:{textAlign:"center",maxWidth:400}},e.createElement("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"}},t),e.createElement("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5}},n)))}class Ge extends e.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){var n,o;null===(o=(n=this.props).onError)||void 0===o||o.call(n,e,t)}render(){if(this.state.error){const{fallback:t}=this.props,n=this.state.error;return"function"==typeof t?t(n):void 0!==t?t:e.createElement(Ie,{componentName:"ChartErrorBoundary",message:n.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}var Fe;const qe="undefined"!=typeof process&&"production"!==(null===(Fe=process.env)||void 0===Fe?void 0:Fe.NODE_ENV);function Ve({componentName:t,width:n,height:o,children:i}){return e.createElement(Ge,{fallback:i=>e.createElement(Ie,{componentName:t,message:i.message,width:n,height:o})},i)}function Xe(e,t,n,o){if(!qe)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 Ye(e,t){if(0===t.length)return null;const n=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(n)||n.includes(e.toLowerCase()))||t[0]}function Qe({componentName:e,data:t,accessors:n,requiredProps:o}){if(o)for(const[t,n]of Object.entries(o))if(null==n)return`${e}: ${t} is required. Provide a field name or function.`;if(!t||!Array.isArray(t)||0===t.length)return e+": No data provided. Pass a non-empty array to the data prop.";if(!Array.isArray(t)&&"object"==typeof t)return e+": data should be an array, but received an object. If this is hierarchical data, use TreeDiagram, Treemap, or CirclePack instead.";if(n){const o=function(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:e}(t).find(e=>e&&"object"==typeof e);if(o){const t=Object.keys(o);for(const[i,r]of Object.entries(n))if(r&&"string"==typeof r&&!(r in o)){const n=Ye(r,t),o=n?` Try ${i}="${n}".`:"";return`${e}: ${i} "${r}" not found in data. Available fields: ${t.join(", ")}.${o}`}}}return null}function Ze(t){const n=_e(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:r,className:s,categoryAccessor:a="category",valueAccessor:l="value",orientation:c="vertical",valueFormat:h,colorBy:u,colorScheme:d="category10",sort:g=!1,barPadding:m=5,tooltip:f,annotations:p,frameProps:y={},selection:v,linkedHover:b,onObservation:x,chartId:w}=t,A=n.width,k=n.height,E=n.enableHover,S=n.showGrid,O=n.showLegend,M=n.title,j=n.categoryLabel,L=n.valueLabel,P=o||[];Xe("BarChart",P,"categoryAccessor",a),Xe("BarChart",P,"valueAccessor",l);const{activeSelectionHook:H,customHoverBehavior:N}=He({selection:v,linkedHover:b,fallbackFields:u?["string"==typeof u?u:""]:[],unwrapData:!0,onObservation:x,chartType:"BarChart",chartId:w}),$=Pe(P,g,l),_=Le(P,u,d),B=i(()=>e=>{const t={};return t.fill=u?fe(e,u,_):je,t},[u,_]),C=i(()=>ve(B,H,v),[B,H,v]),{legend:D,margin:z}=Ne({data:$,colorBy:u,colorScale:_,showLegend:O,userMargin:r,defaults:n.marginDefaults}),W=i(()=>Re({categoryAccessor:a,valueAccessor:l,groupAccessor:u&&u!==a?u:void 0,groupLabel:"string"==typeof u?u:"group"}),[a,l,u]),T=Qe({componentName:"BarChart",data:P,accessors:{categoryAccessor:a,valueAccessor:l}});if(T)return e.createElement(Ie,{componentName:"BarChart",message:T,width:A,height:k});const R=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bar",data:$,oAccessor:a,rAccessor:l,projection:"horizontal"===c?"horizontal":"vertical",pieceStyle:C,size:[A,k],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:z,barPadding:m,enableHover:E,showAxes:n.showAxes,oLabel:j,rLabel:L,rFormat:h,showGrid:S,oSort:g},D&&{legend:D}),M&&{title:M}),s&&{className:s}),{tooltipContent:f?ze(f):W}),(b||x)&&{customHoverBehavior:N}),p&&p.length>0&&{annotations:p}),y);return e.createElement(Ve,{componentName:"BarChart",width:A,height:k},e.createElement(de,Object.assign({},R)))}function Ue(t){const n=_e(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:r,className:s,categoryAccessor:a="category",stackBy:l,valueAccessor:c="value",orientation:h="vertical",valueFormat:u,colorBy:d,colorScheme:g="category10",normalize:m=!1,barPadding:f=5,tooltip:p,annotations:y,frameProps:v={},selection:b,linkedHover:x,onObservation:w,chartId:A}=t,k=n.width,E=n.height,S=n.enableHover,O=n.showGrid,M=n.showLegend,j=n.title,L=n.categoryLabel,P=n.valueLabel,H=o||[],N=d||l,{activeSelectionHook:$,customHoverBehavior:_}=He({selection:b,linkedHover:x,fallbackFields:N?["string"==typeof N?N:""]:[],unwrapData:!0,onObservation:w,chartType:"StackedBarChart",chartId:A}),B=Le(H,N,g),C=i(()=>e=>N?{fill:fe(e,N,B)}:{fill:je},[N,B]),D=i(()=>ve(C,$,b),[C,$,b]),{legend:z,margin:W}=Ne({data:H,colorBy:N,colorScale:B,showLegend:M,userMargin:r,defaults:n.marginDefaults}),T=i(()=>Re({categoryAccessor:l,valueAccessor:c,groupAccessor:a}),[l,a,c]),R=Qe({componentName:"StackedBarChart",data:H,accessors:{categoryAccessor:a,valueAccessor:c},requiredProps:{stackBy:l}});if(R)return e.createElement(Ie,{componentName:"StackedBarChart",message:R,width:k,height:E});const I=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bar",data:H,oAccessor:a,rAccessor:c,stackBy:l,normalize:m,projection:"horizontal"===h?"horizontal":"vertical",pieceStyle:D,size:[k,E],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:W,barPadding:f,enableHover:S,showAxes:n.showAxes,oLabel:L,rLabel:P,rFormat:u,showGrid:O},z&&{legend:z}),j&&{title:j}),s&&{className:s}),{tooltipContent:p?ze(p):T}),(x||w)&&{customHoverBehavior:_}),y&&y.length>0&&{annotations:y}),v);return e.createElement(Ve,{componentName:"StackedBarChart",width:k,height:E},e.createElement(de,Object.assign({},I)))}function Je(t){const n=_e(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:r,className:s,categoryAccessor:a="category",groupBy:l,valueAccessor:c="value",orientation:h="vertical",valueFormat:u,colorBy:d,colorScheme:g="category10",barPadding:m=5,tooltip:f,annotations:p,frameProps:y={},selection:v,linkedHover:b,onObservation:x,chartId:w}=t,A=n.width,k=n.height,E=n.enableHover,S=n.showGrid,O=n.showLegend,M=n.title,j=n.categoryLabel,L=n.valueLabel,P=o||[],H=d||l,{activeSelectionHook:N,customHoverBehavior:$}=He({selection:v,linkedHover:b,fallbackFields:H?["string"==typeof H?H:""]:[],unwrapData:!0,onObservation:x,chartType:"GroupedBarChart",chartId:w}),_=Le(P,H,g),B=i(()=>e=>H?{fill:fe(e,H,_)}:{fill:je},[H,_]),C=i(()=>ve(B,N,v),[B,N,v]),{legend:D,margin:z}=Ne({data:P,colorBy:H,colorScale:_,showLegend:O,userMargin:r,defaults:n.marginDefaults}),W=i(()=>Re({categoryAccessor:l,valueAccessor:c,groupAccessor:a}),[l,a,c]),T=Qe({componentName:"GroupedBarChart",data:P,accessors:{categoryAccessor:a,valueAccessor:c},requiredProps:{groupBy:l}});if(T)return e.createElement(Ie,{componentName:"GroupedBarChart",message:T,width:A,height:k});const R=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"clusterbar",data:P,oAccessor:a,rAccessor:c,groupBy:l,projection:"horizontal"===h?"horizontal":"vertical",pieceStyle:C,size:[A,k],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:z,barPadding:m,enableHover:E,showAxes:n.showAxes,oLabel:j,rLabel:L,rFormat:u,showGrid:S},D&&{legend:D}),M&&{title:M}),s&&{className:s}),{tooltipContent:f?ze(f):W}),(b||x)&&{customHoverBehavior:$}),p&&p.length>0&&{annotations:p}),y);return e.createElement(Ve,{componentName:"GroupedBarChart",width:A,height:k},e.createElement(de,Object.assign({},R)))}function Ke(t){const n=_e(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:r,className:s,categoryAccessor:a="category",valueAccessor:l="value",orientation:c="vertical",valueFormat:h,colorBy:u,colorScheme:d="category10",sizeBy:g,sizeRange:m=[3,8],pointRadius:f=4,pointOpacity:p=.7,categoryPadding:y=20,tooltip:v,annotations:b,frameProps:x={},selection:w,linkedHover:A,onObservation:k,chartId:E}=t,S=n.width,O=n.height,M=n.enableHover,j=n.showGrid,L=n.showLegend,P=n.title,H=n.categoryLabel,N=n.valueLabel,$=o||[],{activeSelectionHook:_,customHoverBehavior:B}=He({selection:w,linkedHover:A,fallbackFields:u?["string"==typeof u?u:""]:["string"==typeof a?a:""],unwrapData:!0,onObservation:k,chartType:"SwarmPlot",chartId:E}),C=Le($,u,d),D=i(()=>{if(!g)return;const e=$.map(e=>"function"==typeof g?g(e):e[g]);return[Math.min(...e),Math.max(...e)]},[$,g]),z=i(()=>e=>{const t={fillOpacity:p};return t.fill=u?fe(e,u,C):je,t.r=g?function(e,t,n=[3,20],o){let i;if(i="function"==typeof t?t(e):e[t],!o)return i;const[r,s]=o,[a,l]=n;return s===r?(a+l)/2:a+(i-r)/(s-r)*(l-a)}(e,g,m,D):f,t},[u,C,g,m,D,f,p]),W=i(()=>ve(z,_,w),[z,_,w]),{legend:T,margin:R}=Ne({data:$,colorBy:u,colorScale:C,showLegend:L,userMargin:r,defaults:n.marginDefaults}),I=i(()=>Re({categoryAccessor:a,valueAccessor:l,groupAccessor:u||void 0}),[a,l,u]),G=Qe({componentName:"SwarmPlot",data:$,accessors:{categoryAccessor:a,valueAccessor:l}});if(G)return e.createElement(Ie,{componentName:"SwarmPlot",message:G,width:S,height:O});const F=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"swarm",data:$,oAccessor:a,rAccessor:l,projection:"horizontal"===c?"horizontal":"vertical",pieceStyle:W,size:[S,O],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:R,barPadding:y,enableHover:M,showAxes:n.showAxes,oLabel:H,rLabel:N,rFormat:h,showGrid:j},T&&{legend:T}),P&&{title:P}),s&&{className:s}),{tooltipContent:v?ze(v):I}),(A||k)&&{customHoverBehavior:B}),b&&b.length>0&&{annotations:b}),x);return e.createElement(Ve,{componentName:"SwarmPlot",width:S,height:O},e.createElement(de,Object.assign({},F)))}function et(t){const n=_e(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:r,className:s,categoryAccessor:a="category",valueAccessor:l="value",orientation:c="vertical",valueFormat:h,colorBy:u,colorScheme:d="category10",showOutliers:g=!0,categoryPadding:m=20,tooltip:f,annotations:p,frameProps:y={},selection:v,linkedHover:b,onObservation:x,chartId:w}=t,A=n.width,k=n.height,E=n.enableHover,S=n.showGrid,O=n.showLegend,M=n.title,j=n.categoryLabel,L=n.valueLabel,P=o||[],{activeSelectionHook:H,customHoverBehavior:N}=He({selection:v,linkedHover:b,fallbackFields:u?["string"==typeof u?u:""]:["string"==typeof a?a:""],unwrapData:!0,onObservation:x,chartType:"BoxPlot",chartId:w}),$=Le(P,u,d),_=i(()=>e=>{const t=u?fe(e,u,$):je;return{fill:t,stroke:t,fillOpacity:.8}},[u,$]),B=i(()=>ve(_,H,v),[_,H,v]),{legend:C,margin:D}=Ne({data:P,colorBy:u,colorScale:$,showLegend:O,userMargin:r,defaults:n.marginDefaults}),z=i(()=>t=>{const n=t.stats||(t.data||t).stats||{};return e.createElement("div",{className:"semiotic-tooltip",style:Be},e.createElement("div",{style:{fontWeight:"bold",marginBottom:"4px"}},(t.category||(t.data||t).category||"")+""),null!=n.median&&e.createElement(e.Fragment,null,null!=n.n&&e.createElement("div",null,"n = ",n.n),e.createElement("div",null,"Median: ",n.median.toLocaleString()),e.createElement("div",null,"Q1: ",n.q1.toLocaleString()),e.createElement("div",null,"Q3: ",n.q3.toLocaleString()),e.createElement("div",null,"Min: ",n.min.toLocaleString()),e.createElement("div",null,"Max: ",n.max.toLocaleString())))},[]),W=Qe({componentName:"BoxPlot",data:P,accessors:{categoryAccessor:a,valueAccessor:l}});if(W)return e.createElement(Ie,{componentName:"BoxPlot",message:W,width:A,height:k});const T=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"boxplot",data:P,oAccessor:a,rAccessor:l,projection:"horizontal"===c?"horizontal":"vertical",summaryStyle:B,showOutliers:g,size:[A,k],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:D,barPadding:m,enableHover:E,showAxes:n.showAxes,oLabel:j,rLabel:L,rFormat:h,showGrid:S},C&&{legend:C}),M&&{title:M}),s&&{className:s}),{tooltipContent:f?ze(f):z}),(b||x)&&{customHoverBehavior:N}),p&&p.length>0&&{annotations:p}),y);return e.createElement(Ve,{componentName:"BoxPlot",width:A,height:k},e.createElement(de,Object.assign({},T)))}function tt(t){const n=_e(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:r,className:s,categoryAccessor:a="category",valueAccessor:l="value",bins:c=25,relative:h=!1,valueFormat:u,colorBy:d,colorScheme:g="category10",categoryPadding:m=20,tooltip:f,annotations:p,frameProps:y={},selection:v,linkedHover:b,onObservation:x,chartId:w}=t,A=n.width,k=n.height,E=n.enableHover,S=n.showGrid,O=n.showLegend,M=n.title,j=n.categoryLabel,L=n.valueLabel,P=o||[],{activeSelectionHook:H,customHoverBehavior:N}=He({selection:v,linkedHover:b,fallbackFields:d?["string"==typeof d?d:""]:["string"==typeof a?a:""],unwrapData:!0,onObservation:x,chartType:"Histogram",chartId:w}),$=Le(P,d,g),_=i(()=>e=>{const t=d?fe(e,d,$):je;return{fill:t,stroke:t,fillOpacity:.8}},[d,$]),B=i(()=>ve(_,H,v),[_,H,v]),{legend:C,margin:D}=Ne({data:P,colorBy:d,colorScale:$,showLegend:O,userMargin:r,defaults:n.marginDefaults}),z=i(()=>t=>{const n=t.data||t,o=n.category||t.category||"",i=n.count,r=n.range;return e.createElement("div",{className:"semiotic-tooltip",style:Be},o&&e.createElement("div",{style:{fontWeight:"bold"}},o+""),null!=i&&e.createElement("div",null,"Count: ",i),r&&2===r.length&&e.createElement("div",{style:{opacity:.8}},Number(r[0]).toFixed(1)," – ",Number(r[1]).toFixed(1)))},[]),W=Qe({componentName:"Histogram",data:P,accessors:{categoryAccessor:a,valueAccessor:l}});if(W)return e.createElement(Ie,{componentName:"Histogram",message:W,width:A,height:k});const T=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"histogram",data:P,oAccessor:a,rAccessor:l,projection:"horizontal",summaryStyle:B,bins:c,normalize:h,size:[A,k],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:D,barPadding:m,enableHover:E,showAxes:n.showAxes,oLabel:j,rLabel:L,rFormat:u,showGrid:S},C&&{legend:C}),M&&{title:M}),s&&{className:s}),{tooltipContent:f?ze(f):z}),(b||x)&&{customHoverBehavior:N}),p&&p.length>0&&{annotations:p}),y);return e.createElement(Ve,{componentName:"Histogram",width:A,height:k},e.createElement(de,Object.assign({},T)))}function nt(t){const n=_e(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:o,margin:r,className:s,categoryAccessor:a="category",valueAccessor:l="value",orientation:c="vertical",bins:h=25,showIQR:u=!0,valueFormat:d,colorBy:g,colorScheme:m="category10",categoryPadding:f=20,tooltip:p,annotations:y,frameProps:v={},selection:b,linkedHover:x,onObservation:w,chartId:A}=t,k=n.width,E=n.height,S=n.enableHover,O=n.showGrid,M=n.showLegend,j=n.title,L=n.categoryLabel,P=n.valueLabel,H=o||[],{activeSelectionHook:N,customHoverBehavior:$}=He({selection:b,linkedHover:x,fallbackFields:g?["string"==typeof g?g:""]:["string"==typeof a?a:""],unwrapData:!0,onObservation:w,chartType:"ViolinPlot",chartId:A}),_=Le(H,g,m),B=i(()=>e=>{const t=g?fe(e,g,_):je;return{fill:t,stroke:t,fillOpacity:.6}},[g,_]),C=i(()=>ve(B,N,b),[B,N,b]),{legend:D,margin:z}=Ne({data:H,colorBy:g,colorScale:_,showLegend:M,userMargin:r,defaults:n.marginDefaults}),W=i(()=>t=>{var n;const o=t.category||t.data&&(null===(n=t.data[0])||void 0===n?void 0:n.category)||"",i=t.stats;if(i)return e.createElement("div",{className:"semiotic-tooltip",style:Be},o&&e.createElement("div",{style:{fontWeight:"bold"}},o+""),e.createElement("div",null,"n = ",i.n),e.createElement("div",null,"Min: ",i.min.toLocaleString()),e.createElement("div",null,"Q1: ",i.q1.toLocaleString()),e.createElement("div",null,"Median: ",i.median.toLocaleString()),e.createElement("div",null,"Q3: ",i.q3.toLocaleString()),e.createElement("div",null,"Max: ",i.max.toLocaleString()),e.createElement("div",{style:{opacity:.8}},"Mean: ",i.mean.toLocaleString(void 0,{maximumFractionDigits:2})));const r=(Array.isArray(t.data)?t.data:[]).map(e=>{const t="function"==typeof l?l(e):e[l];return Number(t)}).filter(e=>!isNaN(e)).sort((e,t)=>e-t),s=r.length,a=s>0?r[Math.floor(s/2)]:null;return e.createElement("div",{className:"semiotic-tooltip",style:Be},o&&e.createElement("div",{style:{fontWeight:"bold"}},o+""),s>0&&e.createElement("div",null,"n = ",s),null!=a&&e.createElement("div",null,"Median: ",a.toLocaleString()))},[l]),T=Qe({componentName:"ViolinPlot",data:H,accessors:{categoryAccessor:a,valueAccessor:l}});if(T)return e.createElement(Ie,{componentName:"ViolinPlot",message:T,width:k,height:E});const R=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"violin",data:H,oAccessor:a,rAccessor:l,projection:"horizontal"===c?"horizontal":"vertical",summaryStyle:C,bins:h,showIQR:u,size:[k,E],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:z,barPadding:f,enableHover:S,showAxes:n.showAxes,oLabel:L,rLabel:P,rFormat:d,showGrid:O},D&&{legend:D}),j&&{title:j}),s&&{className:s}),{tooltipContent:p?ze(p):W}),(x||w)&&{customHoverBehavior:$}),y&&y.length>0&&{annotations:y}),v);return e.createElement(Ve,{componentName:"ViolinPlot",width:k,height:E},e.createElement(de,Object.assign({},R)))}function ot(t){var n;const o=_e(t.mode,{width:t.width,height:t.height,showGrid:null===(n=t.showGrid)||void 0===n||n,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel}),{data:r,margin:s,className:a,categoryAccessor:l="category",valueAccessor:c="value",orientation:h="horizontal",valueFormat:u,colorBy:d,colorScheme:g="category10",sort:m=!0,dotRadius:f=5,categoryPadding:p=10,tooltip:y,annotations:v,frameProps:b={},selection:x,linkedHover:w,onObservation:A,chartId:k}=t,E=o.width,S=o.height,O=o.enableHover,M=o.showGrid,j=o.showLegend,L=o.title,P=o.categoryLabel,H=o.valueLabel,N=r||[],{activeSelectionHook:$,customHoverBehavior:_}=He({selection:x,linkedHover:w,fallbackFields:d?["string"==typeof d?d:""]:["string"==typeof l?l:""],unwrapData:!0,onObservation:A,chartType:"DotPlot",chartId:k}),B=Pe(N,m,c),C=Le(N,d,g),D=i(()=>e=>{const t={r:f,fillOpacity:.8};return t.fill=d?fe(e,d,C):je,t},[d,C,f]),z=i(()=>ve(D,$,x),[D,$,x]),{legend:W,margin:T}=Ne({data:B,colorBy:d,colorScale:C,showLegend:j,userMargin:s,defaults:o.marginDefaults}),R=i(()=>Re({categoryAccessor:l,valueAccessor:c}),[l,c]),I=Qe({componentName:"DotPlot",data:N,accessors:{categoryAccessor:l,valueAccessor:c}});if(I)return e.createElement(Ie,{componentName:"DotPlot",message:I,width:E,height:S});const G=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"point",data:B,oAccessor:l,rAccessor:c,projection:"horizontal"===h?"horizontal":"vertical",pieceStyle:z,size:[E,S],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:T,barPadding:p,enableHover:O,showAxes:o.showAxes,oLabel:P,rLabel:H,rFormat:u,showGrid:M,oSort:m},W&&{legend:W}),L&&{title:L}),a&&{className:a}),{tooltipContent:y?ze(y):R}),(w||A)&&{customHoverBehavior:_}),v&&v.length>0&&{annotations:v}),b);return e.createElement(Ve,{componentName:"DotPlot",width:E,height:S},e.createElement(de,Object.assign({},G)))}function it(t){var n,o;const r=_e(t.mode,{width:null!==(n=t.width)&&void 0!==n?n:400,height:null!==(o=t.height)&&void 0!==o?o:400,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title}),{data:s,margin:a,className:l,categoryAccessor:c="category",valueAccessor:h="value",colorBy:u,colorScheme:d="category10",startAngle:g=0,tooltip:m,annotations:f,frameProps:p={},selection:y,linkedHover:v,onObservation:b,chartId:x}=t,w=r.width,A=r.height,k=r.enableHover,E=r.showLegend,S=r.title,O=s||[],M=u||c,{activeSelectionHook:j,customHoverBehavior:L}=He({selection:y,linkedHover:v,fallbackFields:M?["string"==typeof M?M:""]:[],unwrapData:!0,onObservation:b,chartType:"PieChart",chartId:x}),P=Le(O,M,d),H=i(()=>e=>M?{fill:fe(e,M,P)}:{fill:je},[M,P]),N=i(()=>ve(H,j,y),[H,j,y]),{legend:$,margin:_}=Ne({data:O,colorBy:M,colorScale:P,showLegend:E,userMargin:a,defaults:r.marginDefaults}),B=i(()=>Re({categoryAccessor:c,valueAccessor:h,groupAccessor:u&&u!==c?u:void 0,groupLabel:"string"==typeof u?u:"group",pieData:!0}),[c,h,u]),C=Qe({componentName:"PieChart",data:O,accessors:{categoryAccessor:c,valueAccessor:h}});if(C)return e.createElement(Ie,{componentName:"PieChart",message:C,width:w,height:A});const D=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"pie",data:O,oAccessor:c,rAccessor:h,projection:"radial",pieceStyle:N,startAngle:g,size:[w,A],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:_,enableHover:k,showAxes:!1},$&&{legend:$}),S&&{title:S}),l&&{className:l}),{tooltipContent:m?ze(m):B}),(v||b)&&{customHoverBehavior:L}),f&&f.length>0&&{annotations:f}),p);return e.createElement(Ve,{componentName:"PieChart",width:w,height:A},e.createElement(de,Object.assign({},D)))}function rt(t){var n,o;const r=_e(t.mode,{width:null!==(n=t.width)&&void 0!==n?n:400,height:null!==(o=t.height)&&void 0!==o?o:400,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,linkedHover:t.linkedHover}),{data:s,margin:a,className:l,categoryAccessor:c="category",valueAccessor:h="value",innerRadius:u=60,centerContent:d,colorBy:g,colorScheme:m="category10",startAngle:f=0,tooltip:p,annotations:y,frameProps:v={},selection:b,linkedHover:x,onObservation:w,chartId:A}=t,k=r.width,E=r.height,S=r.enableHover,O=r.showLegend,M=r.title,j=s||[],L=g||c,{activeSelectionHook:P,customHoverBehavior:H}=He({selection:b,linkedHover:x,fallbackFields:L?["string"==typeof L?L:""]:[],unwrapData:!0,onObservation:w,chartType:"DonutChart",chartId:A}),N=Le(j,L,m),$=i(()=>e=>L?{fill:fe(e,L,N)}:{fill:je},[L,N]),_=i(()=>ve($,P,b),[$,P,b]),{legend:B,margin:C}=Ne({data:j,colorBy:L,colorScale:N,showLegend:O,userMargin:a,defaults:r.marginDefaults}),D=i(()=>Re({categoryAccessor:c,valueAccessor:h,groupAccessor:g&&g!==c?g:void 0,groupLabel:"string"==typeof g?g:"group",pieData:!0}),[c,h,g]),z=Qe({componentName:"DonutChart",data:j,accessors:{categoryAccessor:c,valueAccessor:h}});if(z)return e.createElement(Ie,{componentName:"DonutChart",message:z,width:k,height:E});const W=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"donut",data:j,oAccessor:c,rAccessor:h,projection:"radial",pieceStyle:_,innerRadius:u,startAngle:f,centerContent:d,size:[k,E],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:C,enableHover:S,showAxes:!1},B&&{legend:B}),M&&{title:M}),l&&{className:l}),{tooltipContent:p?ze(p):D}),(x||w)&&{customHoverBehavior:H}),y&&y.length>0&&{annotations:y}),v);return e.createElement(Ve,{componentName:"DonutChart",width:k,height:E},e.createElement(de,Object.assign({},W)))}Ze.displayName="BarChart",Ue.displayName="StackedBarChart",Je.displayName="GroupedBarChart",Ke.displayName="SwarmPlot",et.displayName="BoxPlot",tt.displayName="Histogram",nt.displayName="ViolinPlot",ot.displayName="DotPlot",it.displayName="PieChart",rt.displayName="DonutChart";export{Ze as BarChart,et as BoxPlot,rt as DonutChart,ot as DotPlot,Je as GroupedBarChart,tt as Histogram,it as PieChart,Ue as StackedBarChart,de as StreamOrdinalFrame,Ke as SwarmPlot,nt as ViolinPlot};