semiotic 3.3.0 → 3.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +7 -4
- package/ai/schema.json +97 -1
- package/dist/components/charts/ordinal/BarChart.d.ts +2 -0
- package/dist/components/charts/ordinal/DonutChart.d.ts +2 -0
- package/dist/components/charts/ordinal/GroupedBarChart.d.ts +4 -0
- package/dist/components/charts/ordinal/PieChart.d.ts +2 -0
- package/dist/components/charts/ordinal/StackedBarChart.d.ts +4 -0
- package/dist/components/realtime/types.d.ts +42 -3
- package/dist/components/server/renderToStaticSVG.d.ts +1 -0
- package/dist/components/server/serverChartConfigs.d.ts +17 -0
- package/dist/components/server/themeResolver.d.ts +4 -0
- package/dist/components/store/ThemeStore.d.ts +14 -0
- package/dist/components/stream/NetworkPipelineStore.d.ts +7 -1
- package/dist/components/stream/geoTypes.d.ts +4 -4
- package/dist/components/stream/hoverUtils.d.ts +22 -0
- package/dist/components/stream/networkTypes.d.ts +14 -22
- package/dist/components/stream/ordinalTypes.d.ts +10 -0
- package/dist/components/stream/pipelineDecay.d.ts +6 -5
- package/dist/components/stream/types.d.ts +4 -0
- package/dist/geo.min.js +1 -1
- package/dist/geo.module.min.js +1 -1
- package/dist/network.min.js +1 -1
- package/dist/network.module.min.js +1 -1
- package/dist/ordinal.min.js +1 -1
- package/dist/ordinal.module.min.js +1 -1
- package/dist/realtime.min.js +1 -1
- package/dist/realtime.module.min.js +1 -1
- package/dist/semiotic-ai.min.js +1 -1
- package/dist/semiotic-ai.module.min.js +1 -1
- package/dist/semiotic-themes.min.js +1 -1
- package/dist/semiotic-themes.module.min.js +1 -1
- package/dist/semiotic-utils.min.js +1 -1
- package/dist/semiotic-utils.module.min.js +1 -1
- package/dist/semiotic.min.js +1 -1
- package/dist/semiotic.module.min.js +1 -1
- package/dist/server.min.js +1 -1
- package/dist/server.module.min.js +1 -1
- package/dist/xy.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +1 -1
package/dist/semiotic-ai.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("react"),t=require("d3-selection"),n=require("d3-brush"),o=require("d3-scale"),r=require("d3-quadtree"),i=require("d3-scale-chromatic"),a=require("d3-array"),s=require("d3-hierarchy"),l=require("d3-shape"),c=require("regression"),u=require("d3-interpolate"),d=require("d3-force"),h=require("d3-chord");function g(e){return e&&e.__esModule?e:{default:e}}function f(e){if(e&&e.__esModule)return e;const t=Object.create(null);if(e)for(const n in e)if("default"!==n){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:function(){return e[n]}})}return t.default=e,Object.freeze(t)}const p=f(e),y=g(c);function m(e,t){let n=0,o=t.length-1;for(;o>n;){const r=n+o+1>>1;t[r]>e?o=r-1:n=r}return t[n]}function v(e,t){let n=0,o=t.length-1;for(;o>n;){const r=n+o>>1;e>t[r]?n=r+1:o=r}return t[n]}function b({width:o,height:r,totalWidth:i,totalHeight:a,margin:s,dimension:l,scales:c,onBrush:u,binSize:d,snap:h,binBoundaries:g,snapDuring:f,streaming:y}){const b=e.useRef(null),x=e.useRef(null),k=e.useRef(u);k.current=u;const w=e.useRef(c);w.current=c;const A=e.useMemo(()=>g?[...g].sort((e,t)=>e-t):void 0,[g]),S=e.useRef(A);S.current=A;const O=e.useRef(!1),E=e.useRef(null);return e.useEffect(()=>{if(!b.current)return;const e=t.select(b.current).select(".brush-g"),i="x"===l?n.brushX():"y"===l?n.brushY():n.brush();return i.extent([[0,0],[o,r]]),i.on("brush end",t=>{if(O.current)return;const n=w.current;if(!n)return;if(!t.selection)return E.current=null,void k.current(null);let a,s;if("x"===l){const[e,o]=t.selection;a=[n.x.invert(e),n.x.invert(o)],s=[n.y.invert(r),n.y.invert(0)]}else if("y"===l){const[e,r]=t.selection;a=[n.x.invert(0),n.x.invert(o)],s=[n.y.invert(r),n.y.invert(e)]}else{const[[e,o],[r,i]]=t.selection;a=[n.x.invert(e),n.x.invert(r)],s=[n.y.invert(i),n.y.invert(o)]}if("bin"===h&&"y"!==l&&("end"===t.type||"brush"===t.type&&f)){const o=S.current;o&&o.length>0?a=function(e,t){return 0===t.length?e:[m(e[0],t),v(e[1],t)]}(a,o):d&&d>0&&(a=[Math.floor(a[0]/d)*d,Math.ceil(a[1]/d)*d]);const r=n.x(a[0]),s=n.x(a[1]);if(O.current=!0,"x"===l)e.call(i.move,[r,s]);else if("xy"===l){const n=t.selection;e.call(i.move,[[r,n[0][1]],[s,n[1][1]]])}O.current=!1}const c={x:a,y:s};E.current=c,k.current(c)}),e.call(i),x.current=i,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{i.on("brush end",null),x.current=null}},[o,r,l,h,d,f]),e.useEffect(()=>{if(!(y&&c&&x.current&&E.current))return;if(!b.current)return;if("y"===l)return;const e=E.current,n=c.x.domain()[0],o=t.select(b.current).select(".brush-g");if(n>=e.x[1])return O.current=!0,o.call(x.current.move,null),O.current=!1,E.current=null,void k.current(null);let r=e.x[0],i=!1;if(n>e.x[0]){if(r=n,"bin"===h){const e=S.current;e&&e.length>0?r=v(n,e):d&&d>0&&(r=Math.ceil(n/d)*d)}if(r>=e.x[1])return O.current=!0,o.call(x.current.move,null),O.current=!1,E.current=null,void k.current(null);i=!0}const a=c.x(r),s=c.x(e.x[1]);if(O.current=!0,"x"===l)o.call(x.current.move,[a,s]);else{const t=c.y(e.y[1]),n=c.y(e.y[0]);o.call(x.current.move,[[a,t],[s,n]])}if(O.current=!1,i){const t={x:[r,e.x[1]],y:e.y};E.current=t,k.current(t)}},[c,y,l,h,d]),p.createElement("svg",{ref:b,width:i,height:a,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},p.createElement("g",{className:"brush-g",transform:`translate(${s.left},${s.top})`}))}class x{constructor(e,t){var n,o;this.lastBoundedData=null,this.chunkTimer=0,this.pushBuffer=[],this.flushScheduled=!1,this.callback=e,this.chunkThreshold=null!==(n=null==t?void 0:t.chunkThreshold)&&void 0!==n?n:5e3,this.chunkSize=null!==(o=null==t?void 0:t.chunkSize)&&void 0!==o?o:5e3}updateChunkOptions(e){null!=e.chunkThreshold&&(this.chunkThreshold=e.chunkThreshold),null!=e.chunkSize&&(this.chunkSize=e.chunkSize)}clearLastData(){this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(e){if(this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.chunkThreshold>=e.length)return void this.callback({inserts:e,bounded:!0});this.callback({inserts:e.slice(0,this.chunkSize),bounded:!0,totalSize:e.length});let t=this.chunkSize;const n=()=>{if(t>=e.length)return;if(e!==this.lastBoundedData)return;const o=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,o),bounded:!1}),t=o,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}flushPushBuffer(){if(this.flushScheduled=!1,0===this.pushBuffer.length)return;const e=this.pushBuffer;this.pushBuffer=[],this.callback({inserts:e,bounded:!1})}scheduleFlush(){this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flushPushBuffer()))}push(e){this.pushBuffer.push(e),this.scheduleFlush()}pushMany(e){if(0!==e.length){for(let t=0;e.length>t;t++)this.pushBuffer.push(e[t]);this.scheduleFlush()}}flush(){this.flushPushBuffer()}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1}}class k{constructor(e){if(this._capacity=e,this.head=0,this._size=0,1>e)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(e)}push(e){let t;return this._size===this._capacity?t=this.buffer[this.head]:this._size++,this.buffer[this.head]=e,this.head=(this.head+1)%this._capacity,t}pushMany(e){const t=[];for(const n of e){const e=this.push(n);void 0!==e&&t.push(e)}return t}get(e){if(e>=0&&this._size>e)return this.buffer[(this.head-this._size+e+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let e=0;const t=this;return{next:()=>t._size>e?{done:!1,value:t.get(e++)}:{done:!0,value:void 0}}}forEach(e){const t=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)e(this.buffer[(t+n)%this._capacity],n)}toArray(){const e=Array(this._size),t=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)e[n]=this.buffer[(t+n)%this._capacity];return e}resize(e){if(1>e)throw Error("RingBuffer capacity must be at least 1");const t=this.toArray(),n=[];for(;t.length>e;)n.push(t.shift());this._capacity=e,this.buffer=Array(e),this.head=0,this._size=0;for(const e of t)this.push(e);return n}update(e,t){const n=[],o=(this.head-this._size+this._capacity)%this._capacity;for(let r=0;this._size>r;r++){const i=(o+r)%this._capacity,a=this.buffer[i];if(e(a)){let e;e="object"!=typeof a||null===a?a:Array.isArray(a)?[...a]:Object.assign({},a),n.push(e),this.buffer[i]=t(a)}}return n}remove(e){const t=[],n=[];if(this.forEach(o=>{e(o)?n.push(o):t.push(o)}),0===n.length)return n;this.buffer=Array(this._capacity),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 w{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 A(e,t,n,o,r){const i=new Map;for(const a of e){const e=t(a),s=n(a);if(null==e||null==s||Number.isNaN(e)||Number.isNaN(s))continue;const l=Math.floor(e/o)*o;let c=i.get(l);if(c||(c={start:l,end:l+o,total:0,categories:new Map},i.set(l,c)),c.total+=s,r){const e=r(a);c.categories.set(e,(c.categories.get(e)||0)+s)}}return i}function S(e,t){return e===t||typeof e==typeof t&&"function"==typeof e&&"function"==typeof t&&""+e==""+t}function O(e,t){if("function"==typeof e)return t=>+e(t);const n=e||t;return e=>+e[n]}function E(e,t){if("function"==typeof e)return e;const n=e||t;return e=>e[n]}function M(e,t){return"function"==typeof e?e:e?t=>t[e]+"":t?e=>e[t]+"":void 0}const j={category10:i.schemeCategory10,tableau10:i.schemeTableau10,set3:i.schemeSet3,blues:i.interpolateBlues,reds:i.interpolateReds,greens:i.interpolateGreens,oranges:i.interpolateOranges,purples:i.interpolatePurples,viridis:i.interpolateViridis,plasma:i.interpolatePlasma},C=i.schemeCategory10,P=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],L=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"],_=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);function B(e,t,n){if("function"==typeof t){const o=t(e);return n&&o&&"string"==typeof o&&!function(e){const t=e.toLowerCase();return t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||_.has(t)}(o)?n(o):o}const o=null==e?void 0:e[t];return n?n(o):C[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+""))%C.length]}function T(e,t,n="category10"){const r=Array.from(new Set(e.map(e=>null==e?void 0:e[t]).filter(e=>null!=e))),i=r.every(e=>"number"==typeof e||!isNaN(Number(e)));if(Array.isArray(n))return o.scaleOrdinal().domain(r).range(n).unknown("#999");const a=j[n]||j.category10;if(i&&"function"==typeof a){let e=-1/0;for(const t of r){const n=Number(t);n>e&&(e=n)}return t=>a(Number(t)/e)}{const e=Array.isArray(a)?a:C;return o.scaleOrdinal().domain(r).range(e).unknown("#999")}}function N(e,t,n=[3,20],o){let r;if(r="function"==typeof t?t(e):null==e?void 0:e[t],!o)return r;const[i,a]=o,[s,l]=n;return a===i?(s+l)/2:s+(r-i)/(a-i)*(l-s)}function D(e,t,n){var o,r,i;if(1>=n)return 1;const a=null!==(o=e.minOpacity)&&void 0!==o?o:.1,s=n-1-t;switch(e.type){case"linear":return a+(1-s/(n-1))*(1-a);case"exponential":{const t=null!==(r=e.halfLife)&&void 0!==r?r:n/2;return a+Math.pow(.5,s/t)*(1-a)}case"step":return(null!==(i=e.stepThreshold)&&void 0!==i?i:.5*n)>s?1:a;default:return 1}}function I(e,t,n){var o;const r=null!==(o=e.duration)&&void 0!==o?o:500,i=n-t;return r>i?1-i/r:0}function H(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}function R(e,t){return Math.min((e-t.startTime)/t.duration,1)}function W(e,t,n){return e+(t-e)*n}function F(){return"undefined"!=typeof performance?performance.now():Date.now()}function z(e,t,n){var o,r,i,a;switch(t.type){case"point":if(t.pointId)return"p:"+t.pointId;if("streaming"===e.runtimeMode&&t.datum){const n=e.getX(t.datum),o=e.getY(t.datum);if(e.getCategory)return`p:${e.getCategory(t.datum)}:${n}:${o}`;if(null!=n&&null!=o)return`p:${n}:${o}`}return"p:"+n;case"rect":return`r:${t.group||""}:${null!==(a=null!==(r=null===(o=t.datum)||void 0===o?void 0:o.binStart)&&void 0!==r?r:null===(i=t.datum)||void 0===i?void 0:i.category)&&void 0!==a?a:n}`;case"heatcell":return`h:${t.x}_${t.y}`;case"candlestick":return null==t.datum?"c:"+n:"c:"+e.getX(t.datum);case"line":return"l:"+(t.group||"_default");case"area":return"a:"+(t.group||"_default");default:return null}}function $(e,t,n,o,r,i){const a=[];for(const r of e){const e=n(r),i=o(r);null==e||null==i||Number.isNaN(e)||Number.isNaN(i)||a.push({px:t.x(e),py:t.y(i),rawY:i,d:r})}a.sort((e,t)=>e.px-t.px);const s=Array(a.length),l=Array(a.length),c=Array(a.length);for(let e=0;a.length>e;e++){const t=a[e];s[e]=[t.px,t.py],l[e]=t.rawY,c[e]=t.d}return{type:"line",path:s,rawValues:l,style:r,datum:c,group:i}}function G(e,t,n,o,r,i,a,s){const l=[];for(const i of e){const e=n(i),a=o(i);if(null==e||null==a||Number.isNaN(e)||Number.isNaN(a))continue;const c=t.x(e),u=s?s(i):r;l.push({px:c,topY:t.y(a),botY:t.y(u)})}l.sort((e,t)=>e.px-t.px);const c=Array(l.length),u=Array(l.length);for(let e=0;l.length>e;e++){const t=l[e];c[e]=[t.px,t.topY],u[e]=[t.px,t.botY]}return{type:"area",topPath:c,bottomPath:u,style:i,datum:e,group:a}}function Y(e,t,n,o,r,i,a){const s=n(e),l=o(e);if(null==s||null==l||Number.isNaN(s)||Number.isNaN(l))return null;const c={type:"point",x:t.x(s),y:t.y(l),r:r,style:i,datum:e};return void 0!==a&&(c.pointId=a),c}function q(e,t,n,o,r,i,a){return{type:"rect",x:e,y:t,w:n,h:o,style:r,datum:i,group:a}}function X(e,t,n,o,r,i,a){const s={type:"heatcell",x:e,y:t,w:n,h:o,fill:r,datum:i};return(null==a?void 0:a.showValues)&&(s.showValues=!0,s.value=a.value,a.valueFormat&&(s.valueFormat=a.valueFormat)),s}function V(e,t,n){if(!e.getBounds||!e.scales)return null;const o=[],r=[];for(const n of t){const t=e.getX(n),i=e.getY(n);if(null==t||null==i||Number.isNaN(t)||Number.isNaN(i))continue;const a=e.getBounds(n),s=e.scales.x(t);if(a&&0!==a)o.push([s,e.scales.y(i+a)]),r.push([s,e.scales.y(i-a)]);else{const t=e.scales.y(i);o.push([s,t]),r.push([s,t])}}return 2>o.length?null:{type:"area",topPath:o,bottomPath:r,style:e.resolveBoundsStyle(n,t[0]),datum:t,group:n,interactive:!1}}function U(e,t,n,o){var r;if(!e.config.pointStyle)return;const i=null!=o?o:e.getY;for(const o of t){const t=e.resolveGroupColor(o.key);for(const a of o.data){let o=e.config.pointStyle(a);!o.fill&&t&&(o=Object.assign(Object.assign({},o),{fill:t}));const s=null!==(r=o.r)&&void 0!==r?r:3,l=e.getPointId?e.getPointId(a)+"":void 0,c=Y(a,e.scales,e.getX,i,s,o,l);c&&n.push(c)}}}const K={blues:i.interpolateBlues,reds:i.interpolateReds,greens:i.interpolateGreens,viridis:i.interpolateViridis},Q=new Map;class Z{constructor(e){if(this.xExtent=new w,this.yExtent=new w,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.prevPathMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupColorMap=new Map,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this._ingestVersion=0,this._bufferArrayCache=null,this._bufferDirty=!0,this.needsFullRebuild=!0,this.lastLayout=null,this.scales=null,this.scene=[],this.version=0,this.xIsDate=!1,this._quadtree=null,this.config=e,this.buffer=new k(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=O(e.timeAccessor||e.xAccessor,"time"),this.getY=O(e.valueAccessor||e.yAccessor,"value")):(this.getX=O(e.xAccessor,"x"),this.getY=O(e.yAccessor,"y")),this.getGroup=M(e.groupAccessor),this.getCategory=M(e.categoryAccessor),this.getSize=e.sizeAccessor?O(e.sizeAccessor,"size"):void 0,this.getColor=M(e.colorAccessor),this.getBounds=e.boundsAccessor?O(e.boundsAccessor,"bounds"):void 0,this.getY0=e.y0Accessor?O(e.y0Accessor,"y0"):void 0,this.getPointId=M(e.pointIdAccessor),"candlestick"===e.chartType){const t=null!=e.openAccessor,n=null!=e.closeAccessor;this.getOpen=t?O(e.openAccessor,"open"):void 0,this.getHigh=O(e.highAccessor,"high"),this.getLow=O(e.lowAccessor,"low"),this.getClose=n?O(e.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!n}e.pulse&&(this.timestampBuffer=new k(e.windowSize))}ingest(e){const t="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=t,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,e.bounded){if(this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.getX=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?O(this.config.timeAccessor||this.config.xAccessor,"time"):O(this.config.xAccessor,"x"),this.xIsDate=!1,e.inserts.length>0){const t=e.inserts[0],n=this.config.xAccessor,o="function"==typeof n?n(t):t[n||"x"],r=o instanceof Date,i="string"==typeof o&&o.length>=10&&!isNaN(new Date(o).getTime())&&isNaN(Number(o));if(this.xIsDate=r||i,i){const e="string"==typeof n?n:void 0;this.getX=e?t=>+new Date(t[e]):e=>+(n(e)instanceof Date?n(e):new Date(n(e)))}}const n=e.totalSize||e.inserts.length;n>this.buffer.capacity&&(this.buffer.resize(n),this.timestampBuffer&&n>this.timestampBuffer.capacity&&this.timestampBuffer.resize(n));for(const n of e.inserts)this.buffer.push(n),this.timestampBuffer&&this.timestampBuffer.push(t),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):(this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n)))}else for(const n of e.inserts){if("growing"===this.config.windowMode&&this.buffer.full){const e=this.config.maxCapacity||1e6;e>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,e),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap))}const e=this.buffer.push(n);this.timestampBuffer&&this.timestampBuffer.push(t),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):(this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n))),null!=e&&(this.xExtent.evict(this.getX(e)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(e)),this.yExtent.evict(this.getLow(e))):this.yExtent.evict(this.getY(e)))}return!0}computeScene(e){var t,n,r,i,a,s,l;const{config:c,buffer:u}=this;if(!this.needsFullRebuild&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(null!==(t=this.config.scalePadding)&&void 0!==t?t:0)&&(this.lastLayout.width!==e.width||this.lastLayout.height!==e.height))return void this.remapScene(e);if(this.xExtent.dirty&&this.xExtent.recalculate(u,this.getX),this.yExtent.dirty)if("candlestick"===c.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const e of u)this.yExtent.push(this.getHigh(e)),this.yExtent.push(this.getLow(e))}else this.yExtent.recalculate(u,this.getY);const d=this.getBufferArray(),h=this.xExtent.extent,g=this.yExtent.extent;let f=c.xExtent?[null!==(n=c.xExtent[0])&&void 0!==n?n:h[0],null!==(r=c.xExtent[1])&&void 0!==r?r:h[1]]:h,p=c.yExtent?[null!==(i=c.yExtent[0])&&void 0!==i?i:g[0],null!==(a=c.yExtent[1])&&void 0!==a?a:g[1]]:g;const y=c.yExtent&&null!=c.yExtent[0]&&null!=c.yExtent[1];if("stackedarea"===c.chartType&&!y&&u.size>0)if(c.normalize)p=[0,1+c.extentPadding];else{const e=`${u.size}:${this._ingestVersion}`;if(this._stackExtentCache&&this._stackExtentCache.key===e)p=this._stackExtentCache.yDomain;else{const t=this.groupData(d),n=new Map;for(const e of t)for(const t of e.data){const e=this.getX(t),o=this.getY(t);null==e||null==o||Number.isNaN(e)||Number.isNaN(o)||n.set(e,(n.get(e)||0)+o)}let o=0;for(const e of n.values())e>o&&(o=e);p=[0,o+(o>0?o*c.extentPadding:1)],this._stackExtentCache={key:e,yDomain:p}}}else if("bar"===c.chartType&&c.binSize&&!y&&u.size>0){const[,e]=function(e,t,n,o,r){const i=A(e,t,n,o,r);if(0===i.size)return[0,0];let a=0;for(const e of i.values())e.total>a&&(a=e.total);return[0,a]}(u,this.getX,this.getY,c.binSize,this.getCategory);p=[0,e+e*c.extentPadding]}else if("waterfall"===c.chartType&&!y&&u.size>0){const[e,t]=function(e,t){let n=0,o=0,r=0;for(const i of e){const e=t(i);null==e||Number.isNaN(e)||(r+=e,n>r&&(n=r),r>o&&(o=r))}return[n,o]}(u,this.getY),n=t-e,o=n>0?n*c.extentPadding:1;p=[Math.min(0,e-Math.abs(o)),Math.max(0,t+Math.abs(o))]}else if(!y&&p[0]!==1/0){if(this.getBounds)for(const e of d){const t=this.getY(e),n=this.getBounds(e);null!=t&&!Number.isNaN(t)&&n&&(t+n>p[1]&&(p[1]=t+n),p[0]>t-n&&(p[0]=t-n))}const e=p[1]-p[0],t=e>0?e*c.extentPadding:1,n=null===(s=c.yExtent)||void 0===s?void 0:s[0],o=null===(l=c.yExtent)||void 0===l?void 0:l[1];p=[null!=n?p[0]:p[0]-t,null!=o?p[1]:p[1]+t],"log"===c.yScaleType&&0>=p[0]&&g[0]>0&&(p[0]=null!=n?p[0]:g[0]/(1+c.extentPadding))}if(f[0]===1/0||f[1]===-1/0)if("time"===c.xScaleType){const e=Date.now();f=[e-864e5,e]}else f=[0,1];p[0]!==1/0&&p[1]!==-1/0||(p=[0,1]);const m="streaming"===c.runtimeMode,v=Math.max(0,Math.min(c.scalePadding||0,Math.min(e.width,e.height)/2-1));if(m)if("x"==("up"===(b=c.arrowOfTime)||"down"===b?"y":"x")){const t="right"===c.arrowOfTime?[v,e.width-v]:[e.width-v,v];this.scales={x:o.scaleLinear().domain(f).range(t),y:o.scaleLinear().domain(p).range([e.height-v,v])}}else{const t="down"===c.arrowOfTime?[v,e.height-v]:[e.height-v,v];this.scales={x:o.scaleLinear().domain(p).range([v,e.width-v]),y:o.scaleLinear().domain(f).range(t)}}else{const t=(e,t,n)=>{if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return o.scaleLog().domain(e).range(n).clamp(!0)}return"time"===e?o.scaleTime().domain([new Date(t[0]),new Date(t[1])]).range(n):o.scaleLinear().domain(t).range(n)};this.scales={x:t(c.xScaleType,f,[v,e.width-v]),y:t(c.yScaleType,p,[e.height-v,v])}}var b;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(e,d),this.config.decay&&this.applyDecay(this.scene,d),this.config.pulse&&this.applyPulse(this.scene,d),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.rebuildQuadtree(),this.needsFullRebuild=!1,this.lastLayout={width:e.width,height:e.height},this.version++}rebuildQuadtree(){const e=this.config.chartType;if("scatter"!==e&&"bubble"!==e)return void(this._quadtree=null);const t=this.scene.filter(e=>"point"===e.type);this._quadtree=t.length>Z.QUADTREE_THRESHOLD?r.quadtree().x(e=>e.x).y(e=>e.y).addAll(t):null}get quadtree(){return this._quadtree}remapScene(e){const t=e.width/this.lastLayout.width,n=e.height/this.lastLayout.height;for(const e of this.scene)switch(e.type){case"line":for(const o of e.path)o[0]*=t,o[1]*=n;break;case"area":for(const o of e.topPath)o[0]*=t,o[1]*=n;for(const o of e.bottomPath)o[0]*=t,o[1]*=n;break;case"point":e.x*=t,e.y*=n;break;case"rect":case"heatcell":e.x*=t,e.y*=n,e.w*=t,e.h*=n;break;case"candlestick":e.x*=t,e.openY*=n,e.closeY*=n,e.highY*=n,e.lowY*=n}const r=this.scales.x.domain(),i=this.scales.y.domain(),a=this.scales.x.range(),s=this.scales.y.range(),l=(e,t,n)=>{if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return o.scaleLog().domain(e).range(n).clamp(!0)}return"time"===e?o.scaleTime().domain([new Date(t[0]),new Date(t[1])]).range(n):o.scaleLinear().domain(t).range(n)},c=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(e.width,e.height)/2-1)),u=s[1]>s[0];this.scales={x:l(this.config.xScaleType,r,a[0]>a[1]?[e.width-c,c]:[c,e.width-c]),y:l(this.config.yScaleType,i,u?[c,e.height-c]:[e.height-c,c])},this.lastLayout={width:e.width,height:e.height},this.rebuildQuadtree(),this.version++}buildSceneNodes(e,t){var n;const{config:o,scales:r}=this;if(!r||0===t.length)return[];const a={scales:r,config:o,getX:this.getX,getY:this.getY,getY0:this.getY0,getSize:this.getSize,getColor:this.getColor,getGroup:this.getGroup,getCategory:this.getCategory,getPointId:this.getPointId,getBounds:this.getBounds,getOpen:this.getOpen,getHigh:this.getHigh,getLow:this.getLow,getClose:this.getClose,resolveLineStyle:(e,t)=>this.resolveLineStyle(e,t),resolveAreaStyle:(e,t)=>this.resolveAreaStyle(e,t),resolveBoundsStyle:(e,t)=>this.resolveBoundsStyle(e,t),resolveColorMap:e=>this.resolveColorMap(e),resolveGroupColor:e=>this.resolveGroupColor(e),groupData:e=>this.groupData(e),barCategoryCache:this._barCategoryCache};switch(o.chartType){case"line":return function(e,t){var n;const o=e.groupData(t),r=[],i=null===(n=e.config.annotations)||void 0===n?void 0:n.filter(e=>"threshold"===e.type&&e.color).map(e=>({value:e.value,color:e.color,thresholdType:e.thresholdType||"greater"}));if(e.getBounds)for(const t of o){const n=V(e,t.data,t.key);n&&r.push(n)}for(const t of o){const n=e.resolveLineStyle(t.key,t.data[0]),o=$(t.data,e.scales,e.getX,e.getY,n,t.key);i&&i.length>0&&(o.colorThresholds=i),e.config.curve&&"linear"!==e.config.curve&&(o.curve=e.config.curve),e.config.lineGradient&&(o.strokeGradient=e.config.lineGradient),r.push(o)}return U(e,o,r),r}(a,t);case"area":return function(e,t){const n=e.groupData(t),o=[],r=e.scales.y.domain()[0],i=e.getY0?t=>{const n=e.getY0(t);return null==n?r:n}:void 0;for(const t of n){const n=e.resolveAreaStyle(t.key,t.data[0]),a=G(t.data,e.scales,e.getX,e.getY,r,n,t.key,i);e.config.gradientFill&&(a.fillGradient=e.config.gradientFill),e.config.curve&&"linear"!==e.config.curve&&(a.curve=e.config.curve),e.config.lineGradient&&(a.strokeGradient=e.config.lineGradient),o.push(a)}return U(e,n,o),o}(a,t);case"mixed":return function(e,t){const n=e.groupData(t),o=[],r=e.config.areaGroups||new Set,i=e.scales.y.domain()[0],a=e.getY0?t=>{const n=e.getY0(t);return null==n?i:n}:void 0;for(const t of n)if(r.has(t.key)){const n=e.resolveAreaStyle(t.key,t.data[0]),r=G(t.data,e.scales,e.getX,e.getY,i,n,t.key,a);e.config.gradientFill&&(r.fillGradient=e.config.gradientFill),e.config.curve&&"linear"!==e.config.curve&&(r.curve=e.config.curve),e.config.lineGradient&&(r.strokeGradient=e.config.lineGradient),o.push(r)}else{const n=e.resolveLineStyle(t.key,t.data[0]),r=$(t.data,e.scales,e.getX,e.getY,n,t.key);e.config.curve&&"linear"!==e.config.curve&&(r.curve=e.config.curve),e.config.lineGradient&&(r.strokeGradient=e.config.lineGradient),o.push(r)}return U(e,n,o),o}(a,t);case"stackedarea":return function(e,t){const n=e.groupData(t);n.sort((e,t)=>t.key>e.key?-1:e.key>t.key?1:0);const o=e.config.curve&&"linear"!==e.config.curve?e.config.curve:void 0,{nodes:r,stackedTops:i}=function(e,t,n,o,r,i,a){var s;const l=new Set;for(const t of e)for(const e of t.data){const t=n(e);null==t||Number.isNaN(t)||l.add(t)}const c=Array.from(l).sort((e,t)=>e-t),u=new Map;for(const t of e){const e=new Map;for(const r of t.data){const t=n(r),i=o(r);null==t||null==i||Number.isNaN(t)||Number.isNaN(i)||e.set(t,(e.get(t)||0)+i)}u.set(t.key,e)}let d;if(i){d=new Map;for(const t of c){let n=0;for(const o of e)n+=(null===(s=u.get(o.key))||void 0===s?void 0:s.get(t))||0;d.set(t,n||1)}}const h=[],g=new Map,f=new Map;for(const e of c)f.set(e,0);for(const n of e){const e=u.get(n.key),o=[],s=[],l=new Map;for(const n of c){let r=e.get(n)||0;const a=f.get(n);i&&(r/=d.get(n));const c=a+r,u=t.x(n);s.push([u,t.y(a)]),o.push([u,t.y(c)]),f.set(n,c),l.set(n,c)}g.set(n.key,l);const p={type:"area",topPath:o,bottomPath:s,style:r(n.key,n.data[0]),datum:n.data,group:n.key};a&&(p.curve=a),h.push(p)}return{nodes:h,stackedTops:g}}(n,e.scales,e.getX,e.getY,(t,n)=>e.resolveAreaStyle(t,n),e.config.normalize,o),a=r;if(e.config.pointStyle){const t=new WeakMap;for(const o of n){const n=i.get(o.key);if(n)for(const r of o.data){const o=e.getX(r),i=e.getY(r);null==o||Number.isNaN(o)||null==i||Number.isNaN(i)||!n.has(o)||t.set(r,n.get(o))}}const o=n=>{var o;return null!==(o=t.get(n))&&void 0!==o?o:e.getY(n)};U(e,n,a,o)}return a}(a,t);case"scatter":case"bubble":return function(e,t){const n=[],o="bubble"===e.config.chartType?10:5,r=e.config.sizeRange||[3,15];let i=null;if(e.getSize&&!e.config.pointStyle){const n=t.map(t=>e.getSize(t)).filter(e=>null!=e&&!Number.isNaN(e));if(n.length>0){let e=1/0,t=-1/0;for(const o of n)e>o&&(e=o),o>t&&(t=o);i=n=>e===t?(r[0]+r[1])/2:r[0]+(n-e)/(t-e)*(r[1]-r[0])}}const a=e.getColor?e.resolveColorMap(t):null;for(const r of t){let t=e.config.pointStyle?e.config.pointStyle(r):{fill:"#4e79a7",opacity:.8},s=t.r||o;if(i&&e.getSize){const t=e.getSize(r);null==t||Number.isNaN(t)||(s=i(t))}if(a&&e.getColor&&!t.fill){const n=e.getColor(r);n&&a.has(n)&&(t=Object.assign(Object.assign({},t),{fill:a.get(n)}))}const l=e.getPointId?e.getPointId(r)+"":void 0,c=Y(r,e.scales,e.getX,e.getY,s,t,l);c&&n.push(c)}return n}(a,t);case"heatmap":return function(e,t,n){if(e.config.heatmapAggregation)return function(e,t,n){var o,r,i;const a=Math.max(1,Math.floor(null!==(o=e.config.heatmapXBins)&&void 0!==o?o:20)),s=Math.max(1,Math.floor(null!==(r=e.config.heatmapYBins)&&void 0!==r?r:20)),l=null!==(i=e.config.heatmapAggregation)&&void 0!==i?i:"count",c=O(e.config.valueAccessor,"value");if(!e.scales||0===t.length)return[];const[u,d]=e.scales.x.domain(),[h,g]=e.scales.y.domain(),f=(d-u||1)/a,p=(g-h||1)/s,y=a*s;if(y>1e6)return[];const m=new Int32Array(y),v=new Float64Array(y);for(let n=0;t.length>n;n++){const o=t[n],r=e.getX(o),i=e.getY(o);if(!isFinite(r)||!isFinite(i))continue;const l=Math.min(Math.floor((r-u)/f),a-1),d=Math.min(Math.floor((i-h)/p),s-1);if(0>l||0>d)continue;const g=d*a+l;m[g]++;const y=c(o);v[g]+=isFinite(y)?y:0}let b=1/0,x=-1/0;for(let e=0;y>e;e++){if(0===m[e])continue;let t;switch(l){case"sum":t=v[e];break;case"mean":t=v[e]/m[e];break;default:t=m[e]}b>t&&(b=t),t>x&&(x=t)}if(!isFinite(b))return[];const k=x-b||1,w=n.width/a,A=n.height/s,S=e.config.showValues,E=e.config.heatmapValueFormat,M=[];for(let e=0;s>e;e++){const t=e*a;for(let n=0;a>n;n++){const o=t+n;if(0===m[o])continue;let r;switch(l){case"sum":r=v[o];break;case"mean":r=v[o]/m[o];break;default:r=m[o]}const i=(r-b)/k;M.push(X(n*w,(s-1-e)*A,w,A,`rgb(${220-(180*i+.5)|0},${220-(100*i+.5)|0},${255-(50*i+.5)|0})`,{xi:n,yi:e,value:r,count:m[o],sum:v[o]},S?{value:r,showValues:!0,valueFormat:E}:void 0))}}return M}(e,t,n);if(0===t.length)return[];const o=O(e.config.valueAccessor,"value"),r=E(e.config.xAccessor,"x"),a=E(e.config.yAccessor,"y"),s=new Map,l=new Map,c=Array(t.length),u=Array(t.length);for(let e=0;t.length>e;e++){const n=t[e],o=r(n),i=a(n);c[e]=o,u[e]=i,s.has(o)||s.set(o,s.size),l.has(i)||l.set(i,l.size)}const d=s.size,h=l.size;if(0===d||0===h)return[];const g=Array.from(s.keys()),f=Array.from(l.keys()),p=g.every(e=>"number"==typeof e&&!isNaN(e)),y=f.every(e=>"number"==typeof e&&!isNaN(e));if(p){g.sort((e,t)=>e-t),s.clear();for(let e=0;g.length>e;e++)s.set(g[e],e)}if(y){f.sort((e,t)=>e-t),l.clear();for(let e=0;f.length>e;e++)l.set(f[e],e)}const m=new Float64Array(t.length),v=new Float64Array(t.length),b=Array(t.length),x=new Map;let k=0;for(let e=0;t.length>e;e++){const n=t[e],r=s.get(c[e]),i=l.get(u[e]);if(void 0===r||void 0===i)continue;const a=o(n),h=i*d+r,g=x.get(h);let f;void 0!==g?f=g:(f=k++,x.set(h,f)),m[f]=h,v[f]=a,b[f]=n}let w=1/0,A=-1/0;for(let e=0;k>e;e++){const t=v[e];isFinite(t)&&(w>t&&(w=t),t>A&&(A=t))}if(!isFinite(w)||!isFinite(A))return[];const S=function(e){const t=e in K?e:"blues";let n=Q.get(t);if(n)return n;n=Array(256);const o=K[t]||i.interpolateBlues;for(let e=0;256>e;e++)n[e]=o(e/255);return Q.set(t,n),n}("string"==typeof e.config.colorScheme?e.config.colorScheme:"blues"),M=255/(A-w||1),j=n.width/d,C=n.height/h,P=e.config.showValues,L=e.config.heatmapValueFormat,_=[];for(let e=0;k>e;e++){const t=v[e];if(!isFinite(t))continue;const n=m[e],o=n%d;_.push(X(o*j,(h-1-(n-o)/d)*C,j,C,S[Math.min((t-w)*M+.5|0,255)],b[e],P?{value:t,showValues:!0,valueFormat:L}:void 0))}return _}(a,t,e);case"bar":{const e=function(e,t){var n;if(!e.config.binSize)return{nodes:[],binBoundaries:[]};const o=A(t,e.getX,e.getY,e.config.binSize,e.getCategory);if(0===o.size)return{nodes:[],binBoundaries:[]};let r=null;if(e.getCategory){const t=new Set;for(const e of o.values())for(const n of e.categories.keys())t.add(n);const n=e.config.barColors?Object.keys(e.config.barColors):[],i=new Set(n),a=Array.from(t).filter(e=>!i.has(e)).sort(),s=n.filter(e=>t.has(e)),l=s.join("\0")+""+a.join("\0");e.barCategoryCache&&e.barCategoryCache.key===l?r=e.barCategoryCache.order:(r=[...s,...a],e.barCategoryCache={key:l,order:r})}const i=[],a=e.scales,[s,l]=a.x.domain();for(const t of o.values()){const o=Math.max(t.start,s),c=Math.min(t.end,l);if(o>=c)continue;const u=a.x(o),d=a.x(c),h=Math.abs(d-u),g=h>2?1:0,f=Math.min(u,d)+g/2,p=Math.max(h-g,1);if(p>0)if(r&&t.categories.size>0){let o=0;for(const s of r){const r=t.categories.get(s)||0;if(0===r)continue;const l=a.y(o),c=a.y(o+r);i.push(q(f,Math.min(l,c),p,Math.abs(l-c),{fill:(null===(n=e.config.barColors)||void 0===n?void 0:n[s])||"#4e79a7"},{binStart:t.start,binEnd:t.end,total:t.total,category:s,categoryValue:r},s)),o+=r}}else{const e=a.y(0),n=a.y(t.total);i.push(q(f,Math.min(e,n),p,Math.abs(e-n),{fill:"#007bff"},{binStart:t.start,binEnd:t.end,total:t.total}))}}const c=new Set;for(const e of o.values())c.add(e.start),c.add(e.end);return{nodes:i,binBoundaries:Array.from(c).sort((e,t)=>e-t)}}(a,t);return this._barCategoryCache=null!==(n=a.barCategoryCache)&&void 0!==n?n:null,this._binBoundaries=e.binBoundaries,e.nodes}case"swarm":return function(e,t){var n,o,r,i;const a=[],s=e.config.swarmStyle||{},l=null!==(n=s.radius)&&void 0!==n?n:3,c=null!==(o=s.fill)&&void 0!==o?o:"#007bff",u=null!==(r=s.opacity)&&void 0!==r?r:.7,d=s.stroke,h=s.strokeWidth;for(const n of t){const t=e.getX(n),o=e.getY(n);if(null==o||Number.isNaN(o))continue;const r=e.scales.x(t),s=e.scales.y(o);let g=c;if(e.getCategory){const t=e.getCategory(n);g=(null===(i=e.config.barColors)||void 0===i?void 0:i[t])||g}const f={type:"point",x:r,y:s,r:l,style:{fill:g,opacity:u,stroke:d,strokeWidth:h},datum:n};e.getPointId&&(f.pointId=e.getPointId(n)+""),a.push(f)}return a}(a,t);case"waterfall":return function(e,t,n){var o,r,i;const a=[],s=e.scales,l=e.config.waterfallStyle,c=t.filter(t=>{const n=e.getY(t),o=e.getX(t);return null!=n&&!Number.isNaN(n)&&null!=o&&isFinite(o)});if(0===c.length)return a;const u=null!==(o=null==l?void 0:l.positiveColor)&&void 0!==o?o:"#28a745",d=null!==(r=null==l?void 0:l.negativeColor)&&void 0!==r?r:"#dc3545",h=null!==(i=null==l?void 0:l.gap)&&void 0!==i?i:1,g=null==l?void 0:l.stroke,f=null==l?void 0:l.strokeWidth;let p=0;for(let t=0;c.length>t;t++){const o=c[t],r=e.getX(o),i=e.getY(o),y=p+i;let m;m=c.length-1>t?e.getX(c[t+1])-r:t>0?r-e.getX(c[t-1]):0;const v=s.x(r),b=0!==m?s.x(r+m):v+n.width/10,x=Math.min(v,b)+h/2,k=Math.max(v,b)-h/2-x;if(0>=k){p=y;continue}const w=s.y(p),A=s.y(y);a.push(q(x,Math.min(w,A),k,Math.abs(w-A),{fill:0>i?d:u,stroke:g,strokeWidth:f},Object.assign(Object.assign({},o),{baseline:p,cumEnd:y,delta:i,_connectorStroke:null==l?void 0:l.connectorStroke,_connectorWidth:null==l?void 0:l.connectorWidth}))),p=y}return a}(a,t,e);case"candlestick":return function(e,t){var n,o;if(!e.getHigh||!e.getLow||!e.scales)return[];const r=null!==(n=e.config.candlestickRangeMode)&&void 0!==n&&n;if(!(r||e.getOpen&&e.getClose))return[];const i=[],a=e.config.candlestickStyle||{},s=a.rangeColor||"#6366f1",l=r?s:a.upColor||"#28a745",c=r?s:a.downColor||"#dc3545",u=r?s:a.wickColor||"#333",d=a.wickWidth||(r?2:1),h=t.map(t=>e.getX(t)).filter(e=>null!=e&&!Number.isNaN(e)).sort((e,t)=>e-t);let g=r?0:null!==(o=a.bodyWidth)&&void 0!==o?o:0;if(!r&&null==a.bodyWidth&&h.length>1){let t=1/0;for(let n=1;h.length>n;n++){const o=Math.abs(e.scales.x(h[n])-e.scales.x(h[n-1]));o>0&&t>o&&(t=o)}g=t!==1/0?Math.max(2,Math.min(.6*t,20)):6}else r||null!=a.bodyWidth||(g=6);for(const n of t){const t=e.getX(n);if(null==t||Number.isNaN(t))continue;const o=e.getHigh(n),a=e.getLow(n);if(null==o||Number.isNaN(o)||null==a||Number.isNaN(a))continue;const s=r?o:e.getOpen(n),h=r?a:e.getClose(n);if(!r&&[s,h].some(e=>null==e||Number.isNaN(e)))continue;const f=h>=s,p={type:"candlestick",x:e.scales.x(t),openY:e.scales.y(s),closeY:e.scales.y(h),highY:e.scales.y(o),lowY:e.scales.y(a),bodyWidth:g,upColor:l,downColor:c,wickColor:u,wickWidth:d,isUp:f,datum:n};r&&(p.isRange=!0),i.push(p)}return i}(a,t);default:return[]}}resolveBoundsStyle(e,t){const n=this.config.boundsStyle;return"function"==typeof n?n(t||{},e):n&&"object"==typeof n?n:{fill:this.resolveLineStyle(e,t).stroke||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(e,t){const n=this.config.decay;return n&&t>1?D(n,e,t):1}applyDecay(e,t){this.config.decay&&function(e,t,n){var o,r;const i=n.length;if(1>=i)return;const a=new Map;for(let e=0;n.length>e;e++)a.set(n[e],e);for(const n of t){if("line"===n.type){const t=Array.isArray(n.datum)?n.datum:[];if(2>t.length)continue;const o=Array(t.length);let r=!1;for(let n=0;t.length>n;n++){const s=a.get(t[n]);null!=s?(o[n]=D(e,s,i),1>o[n]&&(r=!0)):o[n]=1}r&&(n._decayOpacities=o);continue}if("area"===n.type){const t=Array.isArray(n.datum)?n.datum:[],o=n.topPath?n.topPath.length:t.length;if(2>o)continue;if(t.length===o){const r=Array(o);let s=!1;for(let n=0;t.length>n;n++){const o=a.get(t[n]);null!=o?(r[n]=D(e,o,i),1>r[n]&&(s=!0)):r[n]=1}s&&(n._decayOpacities=r)}else{let r=1;for(const n of t){const t=a.get(n);if(null!=t){const n=D(e,t,i);r>n&&(r=n)}}if(1>r){const e=Array(o);e.fill(r),n._decayOpacities=e}}continue}const t=a.get(n.datum);if(null==t)continue;const s=D(e,t,i);if("heatcell"===n.type)n.style={opacity:s};else if("candlestick"===n.type)n._decayOpacity=s;else{const e=null!==(r=null===(o=n.style)||void 0===o?void 0:o.opacity)&&void 0!==r?r:1;n.style=Object.assign(Object.assign({},n.style),{opacity:e*s})}}}(this.config.decay,e,t)}applyPulse(e,t){this.config.pulse&&this.timestampBuffer&&function(e,t,n,o){var r,i;const a="undefined"!=typeof performance?performance.now():Date.now(),s=null!==(r=e.color)&&void 0!==r?r:"rgba(255,255,255,0.6)",l=null!==(i=e.glowRadius)&&void 0!==i?i:4,c=new Map;for(let e=0;n.length>e;e++)c.set(n[e],e);for(const n of t){if("line"===n.type)continue;if("area"===n.type){const t=Array.isArray(n.datum)?n.datum:[n.datum];let r=0;for(const n of t){const t=c.get(n);if(null==t)continue;const i=o.get(t);if(null==i)continue;const s=I(e,i,a);s>r&&(r=s)}r>0&&(n._pulseIntensity=r,n._pulseColor=s);continue}const t=c.get(n.datum);if(null==t)continue;const r=o.get(t);if(null==r)continue;const i=I(e,r,a);i>0&&(n._pulseIntensity=i,n._pulseColor=s,n._pulseGlowRadius=l)}}(this.config.pulse,e,t,this.timestampBuffer)}get hasActivePulses(){return!!this.config.pulse&&function(e,t){var n;if(!t||0===t.size)return!1;const o="undefined"!=typeof performance?performance.now():Date.now(),r=null!==(n=e.duration)&&void 0!==n?n:500,i=t.peek();return null!=i&&r>o-i}(this.config.pulse,this.timestampBuffer)}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(e,t,n,o){var r,i,a;n.clear(),o.clear();for(let s=0;t.length>s;s++){const l=t[s],c=z(e,l,s);c&&("point"===l.type?n.set(c,{x:l.x,y:l.y,r:l.r,opacity:l.style.opacity}):"rect"===l.type?n.set(c,{x:l.x,y:l.y,w:l.w,h:l.h,opacity:l.style.opacity}):"heatcell"===l.type?n.set(c,{x:l.x,y:l.y,w:l.w,h:l.h,opacity:null===(r=l.style)||void 0===r?void 0:r.opacity}):"candlestick"===l.type?n.set(c,{x:l.x,y:l.openY}):"line"===l.type?o.set(c,{path:l.path.map(e=>[e[0],e[1]]),opacity:null===(i=l.style)||void 0===i?void 0:i.opacity}):"area"===l.type&&o.set(c,{topPath:l.topPath.map(e=>[e[0],e[1]]),bottomPath:l.bottomPath.map(e=>[e[0],e[1]]),opacity:null===(a=l.style)||void 0===a?void 0:a.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}startTransition(){if(!this.config.transition)return;const e=function(e,t,n,o,r){var i,a,s,l,c,u,d,h,g,f,p,y,m,v,b,x,k,w,A,S,O,E,M,j,C,P,L,_;if(0===o.size&&0===r.size)return n;const B=null!==(i=t.duration)&&void 0!==i?i:300;if(n.exitNodes.length>0){const e=new Set(n.exitNodes);n.scene=n.scene.filter(t=>!e.has(t)),n.exitNodes=[]}let T=!1;const N=new Set,D=new Set;for(let t=0;n.scene.length>t;t++){const i=n.scene[t],A=z(e,i,t);if(!A)continue;if(i._transitionKey=A,"line"===i.type||"area"===i.type){const e=r.get(A);if(e){if(D.add(A),"line"===i.type&&e.path&&e.path.length===i.path.length){i._targetPath=i.path.map(e=>[e[0],e[1]]),i._prevPath=e.path;for(let t=0;i.path.length>t;t++)i.path[t]=[e.path[t][0],e.path[t][1]];T=!0}else if("area"===i.type&&e.topPath&&e.bottomPath&&e.topPath.length===i.topPath.length&&e.bottomPath.length===i.bottomPath.length){i._targetTopPath=i.topPath.map(e=>[e[0],e[1]]),i._targetBottomPath=i.bottomPath.map(e=>[e[0],e[1]]),i._prevTopPath=e.topPath,i._prevBottomPath=e.bottomPath;for(let t=0;i.topPath.length>t;t++)i.topPath[t]=[e.topPath[t][0],e.topPath[t][1]];for(let t=0;i.bottomPath.length>t;t++)i.bottomPath[t]=[e.bottomPath[t][0],e.bottomPath[t][1]];T=!0}i._targetOpacity=null!==(a=i.style.opacity)&&void 0!==a?a:1,i._startOpacity=null!==(l=null!==(s=e.opacity)&&void 0!==s?s:i.style.opacity)&&void 0!==l?l:1}else i._targetOpacity=null!==(c=i.style.opacity)&&void 0!==c?c:1,i._startOpacity=0,i.style=Object.assign(Object.assign({},i.style),{opacity:0}),T=!0;continue}const S=o.get(A);if("point"===i.type)if(S){N.add(A);const e={x:i.x,y:i.y,r:i.r};i._targetOpacity=null!==(u=i.style.opacity)&&void 0!==u?u:1,S.x===e.x&&S.y===e.y&&S.r===e.r||(i._targetX=e.x,i._targetY=e.y,i._targetR=e.r,i.x=S.x,i.y=S.y,i.r=null!==(d=S.r)&&void 0!==d?d:i.r,T=!0)}else i._targetOpacity=null!==(h=i.style.opacity)&&void 0!==h?h:1,i.style=Object.assign(Object.assign({},i.style),{opacity:0}),T=!0;else if("rect"===i.type)if(S){N.add(A);const e={x:i.x,y:i.y,w:i.w,h:i.h};i._targetOpacity=null!==(g=i.style.opacity)&&void 0!==g?g:1,S.x===e.x&&S.y===e.y&&S.w===e.w&&S.h===e.h||(i._targetX=e.x,i._targetY=e.y,i._targetW=e.w,i._targetH=e.h,i.x=S.x,i.y=S.y,i.w=null!==(f=S.w)&&void 0!==f?f:i.w,i.h=null!==(p=S.h)&&void 0!==p?p:i.h,T=!0)}else i._targetOpacity=null!==(y=i.style.opacity)&&void 0!==y?y:1,i.style=Object.assign(Object.assign({},i.style),{opacity:0}),T=!0;else if("heatcell"===i.type)if(S){N.add(A);const e={x:i.x,y:i.y,w:i.w,h:i.h};i._targetOpacity=null!==(v=null===(m=i.style)||void 0===m?void 0:m.opacity)&&void 0!==v?v:1,S.x===e.x&&S.y===e.y&&S.w===e.w&&S.h===e.h||(i._targetX=e.x,i._targetY=e.y,i._targetW=e.w,i._targetH=e.h,i.x=S.x,i.y=S.y,i.w=null!==(b=S.w)&&void 0!==b?b:i.w,i.h=null!==(x=S.h)&&void 0!==x?x:i.h,T=!0)}else i._targetOpacity=null!==(w=null===(k=i.style)||void 0===k?void 0:k.opacity)&&void 0!==w?w:1,i.style=Object.assign(Object.assign({},i.style||{}),{opacity:0}),T=!0}for(const[e,t]of r)if(!D.has(e))if(e.startsWith("l:")&&t.path){const o={type:"line",path:t.path.map(e=>[e[0],e[1]]),group:e.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:null!==(A=t.opacity)&&void 0!==A?A:1},_targetOpacity:0,_transitionKey:e,datum:null};n.exitNodes.push(o),T=!0}else if(e.startsWith("a:")&&t.topPath&&t.bottomPath){const o={type:"area",topPath:t.topPath.map(e=>[e[0],e[1]]),bottomPath:t.bottomPath.map(e=>[e[0],e[1]]),group:e.slice(2),style:{fill:"#999",opacity:null!==(S=t.opacity)&&void 0!==S?S:1},_targetOpacity:0,_transitionKey:e,datum:null};n.exitNodes.push(o),T=!0}for(const[e,t]of o)if(!N.has(e)){if(e.startsWith("p:")){const o={type:"point",x:t.x,y:t.y,r:null!==(O=t.r)&&void 0!==O?O:3,style:{opacity:null!==(E=t.opacity)&&void 0!==E?E:1},datum:null,_targetOpacity:0,_transitionKey:e};n.exitNodes.push(o)}else if(e.startsWith("r:")){const o={type:"rect",x:t.x,y:t.y,w:null!==(M=t.w)&&void 0!==M?M:0,h:null!==(j=t.h)&&void 0!==j?j:0,style:{opacity:null!==(C=t.opacity)&&void 0!==C?C:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e};n.exitNodes.push(o)}else if(e.startsWith("h:")){const o={type:"heatcell",x:t.x,y:t.y,w:null!==(P=t.w)&&void 0!==P?P:0,h:null!==(L=t.h)&&void 0!==L?L:0,fill:"#999",datum:null,style:{opacity:null!==(_=t.opacity)&&void 0!==_?_:1},_targetOpacity:0,_transitionKey:e};n.exitNodes.push(o)}T=!0}return n.exitNodes.length>0&&(n.scene=[...n.scene,...n.exitNodes]),T&&(n.activeTransition={startTime:F(),duration:B}),n}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap);this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition}advanceTransition(e){if(!this.activeTransition||!this.config.transition)return!1;const t={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},n=function(e,t,n,o){var r,i,a,s,l;if(!n.activeTransition)return!1;const c=R(e,n.activeTransition),u=H(c,"linear"===t.easing?"linear":"ease-out-cubic");for(const e of n.scene){const t=e._transitionKey;if("point"===e.type){if(void 0!==e._targetOpacity){const n=t?o.get(t):void 0,i=n?null!==(r=n.opacity)&&void 0!==r?r:1:0;e.style.opacity=W(i,e._targetOpacity,u)}if(void 0===e._targetX)continue;if(!t)continue;const n=o.get(t);if(!n)continue;e.x=W(n.x,e._targetX,u),e.y=W(n.y,e._targetY,u),void 0!==e._targetR&&void 0!==n.r&&(e.r=W(n.r,e._targetR,u))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const n=t?o.get(t):void 0,r=n?null!==(i=n.opacity)&&void 0!==i?i:1:0;e.style.opacity=W(r,e._targetOpacity,u)}if(void 0===e._targetX)continue;if(!t)continue;const n=o.get(t);if(!n)continue;e.x=W(n.x,e._targetX,u),e.y=W(n.y,e._targetY,u),void 0!==n.w&&(e.w=W(n.w,e._targetW,u)),void 0!==n.h&&(e.h=W(n.h,e._targetH,u))}else if("heatcell"===e.type){if(void 0!==e._targetOpacity){const n=t?o.get(t):void 0,r=n?null!==(a=n.opacity)&&void 0!==a?a:1:0;e.style=Object.assign(Object.assign({},e.style||{}),{opacity:W(r,e._targetOpacity,u)})}if(void 0===e._targetX)continue;if(!t)continue;const n=o.get(t);if(!n)continue;e.x=W(n.x,e._targetX,u),e.y=W(n.y,e._targetY,u),void 0!==n.w&&(e.w=W(n.w,e._targetW,u)),void 0!==n.h&&(e.h=W(n.h,e._targetH,u))}else if("line"===e.type){if(void 0!==e._targetOpacity){const t=null!==(s=e._startOpacity)&&void 0!==s?s:0;e.style=Object.assign(Object.assign({},e.style),{opacity:W(t,e._targetOpacity,u)})}const t=e._prevPath,n=e._targetPath;if(t&&n&&t.length===e.path.length)for(let o=0;e.path.length>o;o++)e.path[o][0]=W(t[o][0],n[o][0],u),e.path[o][1]=W(t[o][1],n[o][1],u)}else if("area"===e.type){if(void 0!==e._targetOpacity){const t=null!==(l=e._startOpacity)&&void 0!==l?l:0;e.style=Object.assign(Object.assign({},e.style),{opacity:W(t,e._targetOpacity,u)})}const t=e._prevTopPath,n=e._prevBottomPath,o=e._targetTopPath,r=e._targetBottomPath;if(t&&o&&t.length===e.topPath.length)for(let n=0;e.topPath.length>n;n++)e.topPath[n][0]=W(t[n][0],o[n][0],u),e.topPath[n][1]=W(t[n][1],o[n][1],u);if(n&&r&&n.length===e.bottomPath.length)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t][0]=W(n[t][0],r[t][0],u),e.bottomPath[t][1]=W(n[t][1],r[t][1],u)}}if(c>=1){for(const e of n.scene){if(void 0!==e._targetOpacity){const t=e._targetOpacity;e.style=Object.assign(Object.assign({},"line"===e.type||"area"===e.type?e.style:e.style||{}),{opacity:0===t?0:t}),e._targetOpacity=void 0}if("point"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,void 0!==e._targetR&&(e.r=e._targetR),e._targetX=void 0,e._targetY=void 0,e._targetR=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("heatcell"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("line"===e.type){const t=e._targetPath;if(t)for(let n=0;e.path.length>n;n++)e.path[n]=t[n];e._prevPath=void 0,e._targetPath=void 0}else if("area"===e.type){const t=e._targetTopPath,n=e._targetBottomPath;if(t)for(let n=0;e.topPath.length>n;n++)e.topPath[n]=t[n];if(n)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t]=n[t];e._prevTopPath=void 0,e._prevBottomPath=void 0,e._targetTopPath=void 0,e._targetBottomPath=void 0}}if(n.exitNodes.length>0){const e=new Set(n.exitNodes);n.scene=n.scene.filter(t=>!e.has(t)),n.exitNodes=[]}return n.activeTransition=null,!1}return!0}(e,this.config.transition,t,this.prevPositionMap);return this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition,n}groupData(e){if(!this.getGroup)return[{key:"_default",data:e}];const t=new Map;for(const n of e){const e=this.getGroup(n);t.has(e)||t.set(e,[]),t.get(e).push(n)}return Array.from(t.entries()).map(([e,t])=>({key:e,data:t}))}resolveColorMap(e){const t=new Set;for(const n of e){const e=this.getColor(n);e&&t.add(e)}const n=Array.from(t).sort(),o=n.join("\0");if(this._colorMapCache&&this._colorMapCache.key===o)return this._colorMapCache.map;const r=Array.isArray(this.config.colorScheme)?this.config.colorScheme:P,i=new Map;for(let e=0;n.length>e;e++)i.set(n[e],r[e%r.length]);return this._colorMapCache={key:o,map:i},i}resolveLineStyle(e,t){const n=this.config.lineStyle;if("function"==typeof n){const o=n(t||{},e);if(o&&!o.stroke&&e){const t=this.resolveGroupColor(e);if(t)return Object.assign(Object.assign({},o),{stroke:t})}return o}return n&&"object"==typeof n?{stroke:n.stroke||"#007bff",strokeWidth:n.strokeWidth||2,strokeDasharray:n.strokeDasharray,fill:n.fill,fillOpacity:n.fillOpacity,opacity:n.opacity}:{stroke:this.resolveGroupColor(e)||"#007bff",strokeWidth:2}}resolveAreaStyle(e,t){var n;if(this.config.areaStyle){const n=this.config.areaStyle(t||{});if(n&&!n.fill&&e){const t=this.resolveGroupColor(e);if(t)return Object.assign(Object.assign({},n),{fill:t,stroke:n.stroke||t})}return n}const o=this.config.lineStyle;if("function"==typeof o){const n=o(t||{},e);if(n&&!n.fill&&e){const t=this.resolveGroupColor(e);if(t)return Object.assign(Object.assign({},n),{fill:t,stroke:n.stroke||t})}return n}if(o&&"object"==typeof o)return{fill:o.fill||o.stroke||"#4e79a7",fillOpacity:null!==(n=o.fillOpacity)&&void 0!==n?n:.7,stroke:o.stroke||"#4e79a7",strokeWidth:o.strokeWidth||2};const r=this.resolveGroupColor(e)||"#4e79a7";return{fill:r,fillOpacity:.7,stroke:r,strokeWidth:2}}resolveGroupColor(e){if(this._colorMapCache){const t=this._colorMapCache.map.get(e);if(t)return t}const t=this._groupColorMap.get(e);if(t)return t;const n=Array.isArray(this.config.colorScheme)?this.config.colorScheme:P,o=n[this._groupColorMap.size%n.length];return this._groupColorMap.set(e,o),o}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}remove(e){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");const t=new Set(Array.isArray(e)?e:[e]),n=this.getPointId,o=e=>t.has(n(e));if(this.timestampBuffer&&this.timestampBuffer.size>0){const e=this.timestampBuffer.toArray(),t=new Set;this.buffer.forEach((e,n)=>{o(e)&&t.add(n)}),this.timestampBuffer.clear();for(let n=0;e.length>n;n++)t.has(n)||this.timestampBuffer.push(e[n])}const r=this.buffer.remove(o);if(0===r.length)return r;for(const e of r)this.xExtent.evict(this.getX(e)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(e)),this.yExtent.evict(this.getLow(e))):(this.yExtent.evict(this.getY(e)),this.getY0&&this.yExtent.evict(this.getY0(e)));return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,r}update(e,t){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const n=new Set(Array.isArray(e)?e:[e]),o=this.getPointId,r=new Set;this.buffer.forEach((e,t)=>{n.has(o(e))&&r.add(t)});const i=this.buffer.update(e=>n.has(o(e)),t);if(0===i.length)return i;for(const e of i)this.xExtent.evict(this.getX(e)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(e)),this.yExtent.evict(this.getLow(e))):(this.yExtent.evict(this.getY(e)),this.getY0&&this.yExtent.evict(this.getY0(e)));return this.buffer.forEach((e,t)=>{r.has(t)&&(this.xExtent.push(this.getX(e)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(e)),this.yExtent.push(this.getLow(e))):(this.yExtent.push(this.getY(e)),this.getY0&&this.yExtent.push(this.getY0(e))))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,i}getBinBoundaries(){return this._binBoundaries}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.prevPathMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this.needsFullRebuild=!0,this._bufferDirty=!0,this._bufferArrayCache=null,this.lastLayout=null,this.scales=null,this.scene=[],this._quadtree=null,this._colorMapCache=null,this._groupColorMap=new Map,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this.version++}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}updateConfig(e){var t,n,o,r;const i=Object.assign({},this.config);void 0!==e.colorScheme&&(this._colorMapCache=null,this._groupColorMap=new Map),void 0===e.barColors&&void 0===e.colorScheme||(this._barCategoryCache=null),void 0===e.normalize&&void 0===e.extentPadding&&void 0===e.xAccessor&&void 0===e.yAccessor&&void 0===e.groupAccessor&&void 0===e.categoryAccessor&&void 0===e.chartType||(this._stackExtentCache=null);let a=!1;Object.assign(this.config,e);const s="chartType"in e&&e.chartType!==i.chartType||"runtimeMode"in e&&e.runtimeMode!==i.runtimeMode;if(s||void 0!==e.xAccessor||void 0!==e.yAccessor||void 0!==e.timeAccessor||void 0!==e.valueAccessor){const l=s||!S(null!==(t=e.xAccessor)&&void 0!==t?t:e.timeAccessor,null!==(n=i.xAccessor)&&void 0!==n?n:i.timeAccessor),c=s||!S(null!==(o=e.yAccessor)&&void 0!==o?o:e.valueAccessor,null!==(r=i.yAccessor)&&void 0!==r?r:i.valueAccessor);(l||c)&&(["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?(this.getX=O(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=O(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=O(this.config.xAccessor,"x"),this.getY=O(this.config.yAccessor,"y")),a=!0)}if("groupAccessor"in e&&!S(e.groupAccessor,i.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?M(this.config.groupAccessor):void 0,a=!0),"categoryAccessor"in e&&!S(e.categoryAccessor,i.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?M(this.config.categoryAccessor):void 0,a=!0),"sizeAccessor"in e&&!S(e.sizeAccessor,i.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?O(this.config.sizeAccessor,"size"):void 0,a=!0),"colorAccessor"in e&&!S(e.colorAccessor,i.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?M(this.config.colorAccessor):void 0,a=!0),"y0Accessor"in e&&!S(e.y0Accessor,i.y0Accessor)&&(this.getY0=this.config.y0Accessor?O(this.config.y0Accessor,"y0"):void 0,a=!0),"pointIdAccessor"in e&&!S(e.pointIdAccessor,i.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?M(this.config.pointIdAccessor):void 0,a=!0),"candlestick"===this.config.chartType&&("openAccessor"in e&&!S(e.openAccessor,i.openAccessor)||"closeAccessor"in e&&!S(e.closeAccessor,i.closeAccessor)||"highAccessor"in e&&!S(e.highAccessor,i.highAccessor)||"lowAccessor"in e&&!S(e.lowAccessor,i.lowAccessor))){const e=null!=this.config.openAccessor,t=null!=this.config.closeAccessor;this.getOpen=e?O(this.config.openAccessor,"open"):void 0,this.getHigh=O(this.config.highAccessor,"high"),this.getLow=O(this.config.lowAccessor,"low"),this.getClose=t?O(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!t,a=!0}if(!a){const t=Object.keys(e).filter(e=>!e.endsWith("Accessor")&&"timeAccessor"!==e&&"valueAccessor"!==e);for(const n of t)if(e[n]!==i[n]){a=!0;break}}a&&(this.needsFullRebuild=!0)}}function J(e,t,n){return n.x>e||e>n.x+n.w||n.y>t||t>n.y+n.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:n.x+n.w/2,cy:n.y+n.h/2}}function ee(e,t=30){return Math.max((null!=e?e:4)+5,12,t)}function te(e){return e instanceof Date?e:"number"==typeof e&&e>1e9?new Date(e):null}function ne(e,t){const n=te(e);if(!n)return!1;const o=te(t);return!o||n.getFullYear()!==o.getFullYear()||n.getMonth()!==o.getMonth()}function oe(e){let t=e%(2*Math.PI);return 0>t&&(t+=2*Math.PI),t}function re(e,t,n,o=30,r){let i=null,a=!1;if(r){const e=r.find(t,n,o);if(e){const r=ae(e,t,n,o);r&&o>r.distance&&(i=r,a=!0)}}for(const s of e){let e=null;switch(s.type){case"point":if(r&&a)break;e=ae(s,t,n,o);break;case"line":e=se(s,t,n,o);break;case"rect":e=ce(s,t,n);break;case"heatcell":e=ue(s,t,n);break;case"area":if(!1===s.interactive)break;e=he(s,t,n);break;case"candlestick":e=de(s,t,n)}e&&o>e.distance&&(i&&e.distance>=i.distance||(i=e))}return i}function ie(e,t,n){if(0===e.length)return null;const o=ge(e,t);if(0>o)return null;if(Math.abs(e[o][0]-t)>n)return null;let r=o,i=o;o>0&&e[o][0]>=t?(r=o-1,i=o):e.length-1>o&&(r=o,i=o+1);const[a,s]=e[r],[l,c]=e[i];return l===a?s:s+Math.max(0,Math.min(1,(t-a)/(l-a)))*(c-s)}function ae(e,t,n,o=30){const r=t-e.x,i=n-e.y,a=Math.sqrt(r*r+i*i);return a>ee(e.r,o)?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:a}}function se(e,t,n,o=30){var r,i,a,s;if(0===e.path.length)return null;const l=ge(e.path,t);if(0>l)return null;const[c,u]=e.path[l];let d;if(e.path.length>1){let o=1/0;const r=Math.max(0,l-1),i=Math.min(e.path.length-2,l);for(let a=r;i>=a;a++){const[r,i]=e.path[a],[s,l]=e.path[a+1],c=le(t,n,r,i,s,l);o>c&&(o=c)}d=o}else{const e=t-c,o=n-u;d=Math.sqrt(e*e+o*o)}const h=null!==(s=null!==(i=null===(r=e.style)||void 0===r?void 0:r.strokeWidth)&&void 0!==i?i:null===(a=e.style)||void 0===a?void 0:a.lineWidth)&&void 0!==s?s:1;return d>Math.max(5,h/2+2,o)?null:{node:e,datum:Array.isArray(e.datum)&&e.datum[l]?e.datum[l]:e.datum,x:c,y:u,distance:d}}function le(e,t,n,o,r,i){const a=r-n,s=i-o,l=a*a+s*s;if(0===l)return Math.sqrt(Math.pow(e-n,2)+Math.pow(t-o,2));let c=((e-n)*a+(t-o)*s)/l;c=Math.max(0,Math.min(1,c));const u=o+c*s;return Math.sqrt(Math.pow(e-(n+c*a),2)+Math.pow(t-u,2))}function ce(e,t,n){const o=J(t,n,e);return o.hit?{node:e,datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}function ue(e,t,n){const o=J(t,n,e);return o.hit?{node:e,datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}function de(e,t,n){const o=e.bodyWidth/2,r=Math.min(e.openY,e.closeY);if(!(e.x-o-3>t||t>e.x+o+3||e.highY-3>n||n>e.lowY+3)){const o=r+Math.max(Math.max(e.openY,e.closeY)-r,1)/2,i=t-e.x,a=n-o;return{node:e,datum:e.datum,x:e.x,y:o,distance:Math.sqrt(i*i+a*a)}}return null}function he(e,t,n){if(0===e.topPath.length)return null;const o=ge(e.topPath,t);if(0>o)return null;const[r,i]=e.topPath[o],a=t-r,s=n-i,l=Math.sqrt(a*a+s*s);return{node:e,datum:Array.isArray(e.datum)&&e.datum[o]?e.datum[o]:e.datum,x:r,y:i,distance:l}}function ge(e,t){if(0===e.length)return-1;let n=0,o=e.length-1;for(;o>n;){const r=n+o>>1;t>e[r][0]?n=r+1:o=r}return n>0&&Math.abs(e[n][0]-t)>=Math.abs(e[n-1][0]-t)?n-1:n}function fe(e){var t,n;const o=new Map;for(const n of e){const e=null!==(t=n.group)&&void 0!==t?t:"_default";let r=o.get(e);r||(r=[],o.set(e,r)),r.push(n)}for(const e of o.values()){e.sort((e,t)=>e.x-t.x||e.y-t.y);for(let t=0;e.length>t;t++)e[t]._groupIndex=t}const r=Array.from(o.keys()).sort((e,t)=>{const n=o.get(e),r=o.get(t);return(n.length>0?n[0].y:0)-(r.length>0?r[0].y:0)}),i=Array.from(o.values()).flat();i.sort((e,t)=>e.x-t.x||e.y-t.y);const a=new Map;for(let e=0;i.length>e;e++){i[e]._flatIndex=e;const t=null===(n=i[e].datum)||void 0===n?void 0:n.id;null!=t&&a.set(t+"",e)}return{flat:i,groups:r,byGroup:o,idToIdx:a}}function pe(e,t){var n,o;if(0===e.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const r=Math.max(0,Math.min(t,e.flat.length-1)),i=e.flat[r];return{flatIndex:r,group:null!==(n=i.group)&&void 0!==n?n:"_default",indexInGroup:null!==(o=i._groupIndex)&&void 0!==o?o:0}}function ye(e,t,n){const{group:o,indexInGroup:r}=t,i=n.byGroup.get(o);switch(e){case"ArrowRight":return i.length-1>r?i[r+1]._flatIndex:t.flatIndex;case"ArrowLeft":return r>0?i[r-1]._flatIndex:t.flatIndex;case"ArrowDown":{const e=n.groups.indexOf(o);return n.groups.length-1>e?me(n,n.groups[e+1],i[r]):t.flatIndex}case"ArrowUp":{const e=n.groups.indexOf(o);return e>0?me(n,n.groups[e-1],i[r]):t.flatIndex}case"PageDown":return Math.min(t.flatIndex+Math.max(1,Math.floor(.1*n.flat.length)),n.flat.length-1);case"PageUp":return Math.max(t.flatIndex-Math.max(1,Math.floor(.1*n.flat.length)),0);case"Home":return 0;case"End":return n.flat.length-1;case"Escape":return-1;default:return null}}function me(e,t,n){const o=e.byGroup.get(t);let r=0,i=Math.abs(o[0].x-n.x);for(let e=1;o.length>e;e++){const t=Math.abs(o[e].x-n.x);i>t&&(i=t,r=e)}return o[r]._flatIndex}function ve(e){const t=e.datum||{};return Object.assign(Object.assign({},"object"!=typeof t||null===t||Array.isArray(t)?{}:t),{data:t,x:e.x,y:e.y,time:e.x,value:e.y})}function be(t,n,o){const r=e.useRef(null),[i,a]=e.useState(null);return e.useEffect(()=>{if(!n&&!o)return;const e=r.current;if(!e)return;const t=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;a(t=>t&&t.w===e&&t.h===n?t:{w:e,h:n})}});return t.observe(e),()=>t.disconnect()},[n,o]),[r,[n&&i?i.w:t[0],o&&i?i.h:t[1]]]}function xe(t,n,o,r,i,a){e.useEffect(()=>{if(!t)return;const e=setInterval(()=>{var e;const s=n.current;if(!s||0===s.lastIngestTime)return;const l="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(e=t.threshold)&&void 0!==e?e:5e3,u=l-s.lastIngestTime>c;u!==i&&(a(u),o.current=!0,r())},1e3);return()=>clearInterval(e)},[t,i,r])}Z.QUADTREE_THRESHOLD=500;const ke={fill:e=>p.createElement("rect",{style:e,width:16,height:16}),line:e=>p.createElement("line",{style:e,x1:0,y1:0,x2:16,y2:16})};function we(e,t,n,o){let r;return r="function"==typeof n?n(e):(0,ke[n])(o(e,t)),r}function Ae(){return p.createElement("path",{d:"M4,8.8 L7.2,12 L12.8,4.8",fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function Se(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}function Oe({config:e,orientation:t="vertical",width:n=100}){const{colorFn:o,domain:r,label:i,format:a}=e,s=a||(e=>Math.round(100*e)/100+""),l="grad-legend-"+p.useId();if("horizontal"===t){const e=12,t=Math.min(n,200),a=Math.max(0,(n-t)/2),c=[];for(let e=0;64>=e;e++){const t=e/64;c.push(p.createElement("stop",{key:e,offset:100*t+"%",stopColor:o(r[0]+t*(r[1]-r[0]))}))}return p.createElement("g",{"aria-label":i||"Gradient legend"},p.createElement("defs",null,p.createElement("linearGradient",{id:l,x1:"0%",y1:"0%",x2:"100%",y2:"0%"},c)),i&&p.createElement("text",{x:a+t/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},i),p.createElement("rect",{x:a,y:0,width:t,height:e,fill:`url(#${l})`,rx:2}),p.createElement("text",{x:a,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(r[0])),p.createElement("text",{x:a+t,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(r[1])))}const c=[];for(let e=0;64>=e;e++){const t=e/64;c.push(p.createElement("stop",{key:e,offset:100*t+"%",stopColor:o(r[1]-t*(r[1]-r[0]))}))}return p.createElement("g",{"aria-label":i||"Gradient legend"},i&&p.createElement("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},i),p.createElement("defs",null,p.createElement("linearGradient",{id:l,x1:"0%",y1:"0%",x2:"0%",y2:"100%"},c)),p.createElement("rect",{x:0,y:0,width:14,height:100,fill:`url(#${l})`,rx:2}),p.createElement("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(r[1])),p.createElement("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(r[0])))}function Ee(e){const{legendGroups:t,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,legendInteraction:a,title:s="Legend",width:l=100,height:c=20,orientation:u="vertical"}=e,[d,h]=p.useState(0),[g,f]=p.useState(0),y=p.useCallback((e,t)=>{h(e),f(t)},[]),m="vertical"===u?(({legendGroups:e,width:t,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,focusedGroupIndex:a,focusedItemIndex:s,onFocusedIndexChange:l,legendInteraction:c})=>{let u=24;const d=[];return e.forEach((e,h)=>{u+=5,d.push(p.createElement("line",{key:"legend-top-line legend-symbol-"+h,stroke:"gray",x1:0,y1:u,x2:t,y2:u})),u+=8,e.label&&(u+=16,d.push(p.createElement("text",{key:"legend-text-"+h,y:u,className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label)),u+=8),d.push(p.createElement("g",{key:"legend-group-"+h,className:"legend-item",transform:`translate(0,${u})`},((e,t,n,o,r,i,a,s,l,c)=>{const{type:u="fill",styleFn:d,items:h}=e,g=[];let f=0;const y=!(!t&&!n),m="isolate"===c||void 0===c&&null!=r;return h.forEach((e,c)=>{const v=we(e,c,u,d),b=Se(e,o,r),x=r&&r.size>0&&r.has(e.label);g.push(p.createElement("g",{key:"legend-item-"+c,transform:`translate(0,${f})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:y?s===i&&c===a?0:-1:void 0,role:y?"option":void 0,"aria-selected":y&&m?x||!1:void 0,"aria-current":y&&!m&&null!=o&&e.label===o||void 0,"aria-label":e.label,onKeyDown:y?n=>{var o;if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowDown"===n.key||"ArrowUp"===n.key){n.preventDefault();const e=(c+("ArrowDown"===n.key?1:-1)+h.length)%h.length;l(s,e);const t=null===(o=n.currentTarget.parentElement)||void 0===o?void 0:o.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:y?t=>{l(s,c),n&&n(e);const o=t.currentTarget.querySelector(".semiotic-legend-focus-ring");o&&o.setAttribute("visibility","visible")}:void 0,onBlur:y?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:y?"pointer":"default",opacity:b,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},y&&p.createElement("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*e.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),v,x&&p.createElement(Ae,null),p.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label))),f+=22}),g})(e,n,o,r,i,a,s,h,l,c))),u+=22*e.items.length+8}),d})({legendGroups:t||[],width:l,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,focusedGroupIndex:d,focusedItemIndex:g,onFocusedIndexChange:y,legendInteraction:a}):(({legendGroups:e,height:t,width:n,customClickBehavior:o,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:a,focusedGroupIndex:s,focusedItemIndex:l,onFocusedIndexChange:c,legendInteraction:u})=>{let d=0;const h=[];e.forEach((e,t)=>{let g=0;e.label&&(g+=16);const f=((e,t,n,o,r,i,a,s,l,c,u)=>{const{type:d="fill",styleFn:h,items:g}=e,f=[];let y=0,m=0;const v=!(!t&&!n),b="isolate"===c||void 0===c&&null!=r;g.forEach((e,c)=>{const x=we(e,c,d,h),k=Se(e,o,r),w=r&&r.size>0&&r.has(e.label),A=26+7*e.label.length;u&&u>0&&y>0&&y+A>u&&(m++,y=0),f.push(p.createElement("g",{key:"legend-item-"+c,transform:`translate(${y},${22*m})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:v?s===i&&c===a?0:-1:void 0,role:v?"option":void 0,"aria-selected":v&&b?w||!1:void 0,"aria-current":v&&!b&&null!=o&&e.label===o||void 0,"aria-label":e.label,onKeyDown:v?n=>{var o;if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowRight"===n.key||"ArrowLeft"===n.key){n.preventDefault();const e=(c+("ArrowRight"===n.key?1:-1)+g.length)%g.length;l(s,e);const t=null===(o=n.currentTarget.parentElement)||void 0===o?void 0:o.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:v?t=>{l(s,c),n&&n(e);const o=t.currentTarget.querySelector(".semiotic-legend-focus-ring");o&&o.setAttribute("visibility","visible")}:void 0,onBlur:v?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:v?"pointer":"default",opacity:k,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},v&&p.createElement("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*e.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),x,w&&p.createElement(Ae,null),p.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label))),y+=A});let x=0,k=0;for(const e of g){const t=26+7*e.label.length;u&&u>0&&k>0&&k+t>u?(x=Math.max(x,k),k=t):k+=t}x=Math.max(x,k);const w=m+1;return{items:f,offset:x,totalRows:w,totalHeight:22*w}})(e,o,r,i,a,s,l,t,c,u,n);g+=f.offset+5,h.push(Object.assign(Object.assign({label:e.label},f),{offset:g,totalRows:f.totalRows,totalHeight:f.totalHeight})),d+=g+12});let g=d>n?0:Math.max(0,(n-d)/2);const f=[];return h.forEach((n,o)=>{const r=e[o];r.label&&(f.push(p.createElement("text",{key:"legend-text-"+o,transform:`translate(${g},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},r.label)),g+=16),f.push(p.createElement("g",{key:"legend-group-"+o,className:"legend-item",transform:`translate(${g},0)`},n.items)),g+=n.offset+5,e[o+1]&&f.push(p.createElement("line",{key:"legend-top-line legend-symbol-"+o,stroke:"gray",x1:g,y1:-8,x2:g,y2:(n.totalHeight||t)+0+8})),g+=12}),p.createElement("g",null,f)})({legendGroups:t||[],title:s,height:c,width:l,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,focusedGroupIndex:d,focusedItemIndex:g,onFocusedIndexChange:y,legendInteraction:a}),v=!(!n&&!o);return p.createElement("g",{role:v?"listbox":void 0,"aria-multiselectable":!(!v||"isolate"!==a&&(void 0!==a||null==i))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"}},void 0!==s&&""!==s&&"vertical"===u&&p.createElement("text",{className:"legend-title",y:16,x:l/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)"},s),m)}function Me(e){const{legend:t,totalWidth:n,totalHeight:o,margin:r,legendPosition:i="right",title:a,legendHoverBehavior:s,legendClickBehavior:l,legendHighlightedCategory:c,legendIsolatedCategories:u,legendInteraction:d}=e;if(!t)return null;const h="top"===i||"bottom"===i;let g,f;return"left"===i?(g=4,f=r.top):"top"===i?(g=0,f=a?32:8):"bottom"===i?(g=0,f=o-r.bottom+50):(g=n-r.right+10,f=r.top),p.createElement("g",{transform:`translate(${g}, ${f})`},function(e){return"object"==typeof e&&null!==e&&"gradient"in e}(t)?p.createElement(Oe,{config:t.gradient,orientation:h?"horizontal":"vertical",width:h?n:100}):function(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}(t)?p.createElement(Ee,{legendGroups:t.legendGroups,title:"",width:h?n:100,orientation:h?"horizontal":"vertical",customHoverBehavior:s,customClickBehavior:l,highlightedCategory:c,isolatedCategories:u,legendInteraction:d}):t)}function je(e){return"string"==typeof e?{type:e}:e}function Ce({orient:t,config:n,values:o,scale:r,size:i,length:s}){const l=function(e){var t,n,o,r,i;return{type:e.type,bins:null!==(t=e.bins)&&void 0!==t?t:20,fill:null!==(n=e.fill)&&void 0!==n?n:"#4e79a7",fillOpacity:null!==(o=e.fillOpacity)&&void 0!==o?o:.5,stroke:null!==(r=e.stroke)&&void 0!==r?r:"none",strokeWidth:null!==(i=e.strokeWidth)&&void 0!==i?i:1}}(n),c="top"===t||"bottom"===t,u=e.useMemo(()=>{if(0===o.length)return null;const e=r.domain(),n=i-8;if("boxplot"===l.type){const e=function(e){const t=[...e].sort((e,t)=>e-t),n=t.length;if(0===n)return null;const o=t[Math.floor(.25*n)],r=t[Math.floor(.5*n)],i=t[Math.floor(.75*n)],a=i-o;return{q1:o,median:r,q3:i,whiskerLow:Math.max(t[0],o-1.5*a),whiskerHigh:Math.min(t[n-1],i+1.5*a)}}(o);if(!e)return null;const{q1:i,median:a,q3:s,whiskerLow:u,whiskerHigh:d}=e,h=Math.min(.5*n,20),g=(n-h)/2+4;if(c){const e=r(i),n=r(s),o=r(a),c=r(u),f=r(d),y="top"===t?-1:1,m=0;return p.createElement("g",{"data-testid":"marginal-boxplot-"+t},p.createElement("line",{x1:c,y1:m+y*(g+h/2),x2:f,y2:m+y*(g+h/2),stroke:l.fill,strokeWidth:l.strokeWidth}),p.createElement("line",{x1:c,y1:m+y*g,x2:c,y2:m+y*(g+h),stroke:l.fill,strokeWidth:l.strokeWidth}),p.createElement("line",{x1:f,y1:m+y*g,x2:f,y2:m+y*(g+h),stroke:l.fill,strokeWidth:l.strokeWidth}),p.createElement("rect",{x:Math.min(e,n),y:"top"===t?m-g-h:m+g,width:Math.abs(n-e),height:h,fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}),p.createElement("line",{x1:o,y1:"top"===t?m-g-h:m+g,x2:o,y2:"top"===t?m-g:m+g+h,stroke:l.fill,strokeWidth:2}))}{const e=r(i),n=r(s),o=r(a),c=r(u),f=r(d),y="left"===t?-1:1,m=0;return p.createElement("g",{"data-testid":"marginal-boxplot-"+t},p.createElement("line",{x1:m+y*(g+h/2),y1:c,x2:m+y*(g+h/2),y2:f,stroke:l.fill,strokeWidth:l.strokeWidth}),p.createElement("line",{x1:m+y*g,y1:c,x2:m+y*(g+h),y2:c,stroke:l.fill,strokeWidth:l.strokeWidth}),p.createElement("line",{x1:m+y*g,y1:f,x2:m+y*(g+h),y2:f,stroke:l.fill,strokeWidth:l.strokeWidth}),p.createElement("rect",{x:"left"===t?m-g-h:m+g,y:Math.min(e,n),width:h,height:Math.abs(n-e),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}),p.createElement("line",{x1:"left"===t?m-g-h:m+g,y1:o,x2:"left"===t?m-g:m+g+h,y2:o,stroke:l.fill,strokeWidth:2}))}}const u=a.bin().domain(e).thresholds(l.bins)(o);if(0===u.length)return null;const d=Math.max(...u.map(e=>e.length));if(0===d)return null;if("histogram"===l.type)return p.createElement("g",{"data-testid":"marginal-histogram-"+t},u.map((e,o)=>{if(null==e.x0||null==e.x1)return null;const i=e.length/d*n;if(c){const n=r(e.x0),a=r(e.x1)-r(e.x0);return p.createElement("rect",{key:o,x:n,y:"top"===t?-4-i:4,width:Math.max(a,.5),height:i,fill:l.fill,fillOpacity:l.fillOpacity,stroke:l.stroke,strokeWidth:l.strokeWidth})}{const n=r(e.x0),a=r(e.x1)-r(e.x0);return p.createElement("rect",{key:o,x:"left"===t?-4-i:4,y:Math.min(n,n+a),width:i,height:Math.abs(a),fill:l.fill,fillOpacity:l.fillOpacity,stroke:l.stroke,strokeWidth:l.strokeWidth})}}));if("violin"===l.type){const e=n/2+4,o=[];for(const i of u){if(null==i.x0||null==i.x1)continue;const a=i.length/d*(n/2),s=r((i.x0+i.x1)/2);o.push(c?`${s},${"top"===t?-(e-a):e-a}`:`${"left"===t?-(e-a):e-a},${s}`)}for(let i=u.length-1;i>=0;i--){const a=u[i];if(null==a.x0||null==a.x1)continue;const s=a.length/d*(n/2),l=r((a.x0+a.x1)/2);o.push(c?`${l},${"top"===t?-(e+s):e+s}`:`${"left"===t?-(e+s):e+s},${l}`)}return p.createElement("g",{"data-testid":"marginal-violin-"+t},p.createElement("polygon",{points:o.join(" "),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}))}if("ridgeline"===l.type){const e=[];if(c){const o=0,i=null!=u[0].x0?r(u[0].x0):0;e.push(`M${i},${o}`);for(const o of u){if(null==o.x0||null==o.x1)continue;const i=o.length/d*n,a=r((o.x0+o.x1)/2);e.push(`L${a},${"top"===t?-i-4:i+4}`)}const a=null!=u[u.length-1].x1?r(u[u.length-1].x1):s;e.push(`L${a},${o}`),e.push("Z")}else{const o=0,i=null!=u[0].x0?r(u[0].x0):0;e.push(`M${o},${i}`);for(const o of u){if(null==o.x0||null==o.x1)continue;const i=o.length/d*n,a=r((o.x0+o.x1)/2);e.push(`L${"left"===t?-i-4:i+4},${a}`)}const a=null!=u[u.length-1].x1?r(u[u.length-1].x1):s;e.push(`L${o},${a}`),e.push("Z")}return p.createElement("g",{"data-testid":"marginal-ridgeline-"+t},p.createElement("path",{d:e.join(" "),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}))}return null},[o,r,l,i,s,t,c,4]);return u?p.createElement("g",{className:"marginal-"+t,"data-testid":"marginal-"+t},u):null}function Pe(e,t=120,n=8){if(!e)return[];const o=Math.max(1,Math.floor(t/n)),r=e.split(/\s+/),i=[];let a="";for(const e of r)a&&a.length+1+e.length>o?(i.push(a),a=e):a=a?`${a} ${e}`:e;return a&&i.push(a),i}function Le(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 _e(e){const{x:t=0,y:n=0,dx:o,dy:r,nx:i,ny:a,note:s,connector:l,subject:c,type:u,color:d,className:h,disable:g,events:f={},"data-testid":y}=e,m=new Set(Array.isArray(g)?g:[]);let v=o||0,b=r||0;null!=i&&(v=i-t),null!=a&&(b=a-n);const x="string"==typeof u?u:"label";if("bracket"===x&&c&&0===v&&0===b)if(void 0!==c.width){v=c.width/2;const e=c.depth||30;b=e+(0>e?-5:5)}else if(void 0!==c.height){const e=c.depth||30;v=e+(0>e?-5:5),b=c.height/2}return p.createElement("g",Object.assign({className:("annotation "+(h||"")).trim(),transform:`translate(${t},${n})`,"data-testid":y},f),!m.has("connector")&&function(e,t,n,o,r,i){const a=[];let s=0,l=0;if("callout-circle"!==r&&"label"!==r||!(null==i?void 0:i.radius)){if("callout-rect"===r&&i){const n=i.width||0,o=i.height||0;if(n>0||o>0){const r=n/2,i=o/2,a=e-r,c=t-i;if(0!==a||0!==c){const e=Math.abs(a),t=Math.abs(c),u=n/2,d=o/2,h=e*d>t*u?u/e:d/t;s=r+a*h,l=i+c*h}}}else if("bracket"===r&&i){const e=i.width,t=i.height,n=i.depth||30;void 0!==e?(s=e/2,l=n):void 0!==t&&(s=n,l=t/2)}}else{const n=(i.radius||0)+(i.radiusPadding||0);if(n>0&&(0!==e||0!==t)){const o=Math.atan2(t,e);s=Math.cos(o)*n,l=Math.sin(o)*n}}if(Math.sqrt(Math.pow(e-s,2)+Math.pow(t-l,2))>.5&&(a.push(p.createElement("line",{key:"connector-line",x1:s,y1:l,x2:e,y2:t,stroke:o||"var(--semiotic-text-secondary, currentColor)"})),"arrow"===(null==n?void 0:n.end))){const n=10,r=16/180*Math.PI,i=Math.atan2(t-l,e-s);a.push(p.createElement("path",{key:"connector-arrow",d:`M${s},${l}L${s+n*Math.cos(i+r)},${l+n*Math.sin(i+r)}L${s+n*Math.cos(i-r)},${l+n*Math.sin(i-r)}Z`,fill:o||"var(--semiotic-text-secondary, currentColor)",stroke:"none"}))}return p.createElement("g",{className:"annotation-connector"},a)}(v,b,l,d,x,c),!m.has("subject")&&function(e,t,n,o,r){var i;const a=[];switch(e){case"callout-circle":{const e=((null==t?void 0:t.radius)||0)+((null==t?void 0:t.radiusPadding)||0);e>0&&a.push(p.createElement("circle",{key:"subject-circle",r:e,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"}));break}case"callout-rect":{const e=(null==t?void 0:t.width)||0,o=(null==t?void 0:t.height)||0;(e>0||o>0)&&a.push(p.createElement("rect",{key:"subject-rect",width:e,height:o,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"}));break}case"callout-custom":(null==t?void 0:t.custom)&&a.push(...Array.isArray(t.custom)?t.custom:[t.custom]);break;case"xy-threshold":{const e=o||0,i=r||0;if(void 0!==(null==t?void 0:t.x)){const o=(t.x||0)-e;a.push(p.createElement("line",{key:"threshold-line",x1:o,y1:(t.y1||0)-i,x2:o,y2:(t.y2||0)-i,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"}))}else if(void 0!==(null==t?void 0:t.y)){const o=(t.y||0)-i;a.push(p.createElement("line",{key:"threshold-line",x1:(t.x1||0)-e,y1:o,x2:(t.x2||0)-e,y2:o,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"}))}else void 0!==(null==t?void 0:t.x1)||void 0!==(null==t?void 0:t.x2)?a.push(p.createElement("line",{key:"threshold-line",x1:(t.x1||0)-e,y1:0,x2:(t.x2||0)-e,y2:0,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"})):void 0===(null==t?void 0:t.y1)&&void 0===(null==t?void 0:t.y2)||a.push(p.createElement("line",{key:"threshold-line",x1:0,y1:(t.y1||0)-i,x2:0,y2:(t.y2||0)-i,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"}));break}case"bracket":{const e=null!==(i=null==t?void 0:t.width)&&void 0!==i?i:null==t?void 0:t.height;void 0!==e&&a.push(p.createElement("path",{key:"bracket-path",d:Le((null==t?void 0:t.type)||"curly",e,(null==t?void 0:t.depth)||30,void 0===(null==t?void 0:t.width)),fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"}));break}}return p.createElement("g",{className:"annotation-subject"},a)}(x,c,d,t,n),!m.has("note")&&function(e,t,n,o){if(!e)return p.createElement("g",{className:"annotation-note"});const{label:r,title:i,orientation:a,align:s,wrap:l=120,noWrap:c}=e;if(!r&&!i)return p.createElement("g",{className:"annotation-note"});let u=a;u||(u=Math.abs(t)>Math.abs(n)?"leftRight":"topBottom");let d=s;d&&"dynamic"!==d||(d="topBottom"===u?0>t?"right":"left":0>n?"bottom":"top");let h="start";"topBottom"===u?"right"===d?h="end":"middle"===d&&(h="middle"):h=0>t?"end":"start";const g=16,f=i?c?[i]:Pe(i,l):[],y=r?c?[r]:Pe(r,l):[],m="leftRight"===u?"end"===h?-4:4:0;let v=0;const b=[],x=o||"var(--semiotic-text, #333)";f.length>0&&(b.push(p.createElement("text",{key:"annotation-note-title",className:"annotation-note-title",fill:x,textAnchor:h,fontWeight:"bold"},f.map((e,t)=>p.createElement("tspan",{key:t,x:m,dy:0===t?0:g},e)))),v=f.length*g),y.length>0&&b.push(p.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:x,textAnchor:h,y:v},y.map((e,t)=>p.createElement("tspan",{key:t,x:m,dy:0===t?0:g},e))));let k=null;if((i||r)&&(0!==t||0!==n))if("topBottom"===u){const e=Math.min(l,120);let t=0,n=e;"end"===h?(t=-e,n=0):"middle"===h&&(t=-e/2,n=e/2),k=p.createElement("line",{className:"note-line",x1:t,x2:n,y1:0,y2:0,stroke:o||"var(--semiotic-text-secondary, currentColor)"})}else{const e=(f.length+y.length)*g+(y.length>0?g:0);let t=0,n=e;"bottom"===d?(t=-e,n=0):"middle"===d&&(t=-e/2,n=e/2),k=p.createElement("line",{className:"note-line",x1:0,x2:0,y1:t,y2:n,stroke:o||"var(--semiotic-text-secondary, currentColor)"})}const w=Math.max(0,f.length+y.length-1)*g;let A=0;return"topBottom"===u?A=0>n?-(w+2):18:"leftRight"===u&&(A="middle"===d?-(w+g+(y.length>0&&f.length>0?2:0))/2+8:"bottom"===d||0>n?-(w+2):18),p.createElement("g",{className:"annotation-note",transform:`translate(${t},${n})`},p.createElement("g",{className:"annotation-note-content",transform:0!==A?`translate(0,${A})`:void 0},b),k)}(s,v,b,d))}function Be(e){var t,n;const{noteData:o}=e,{screenCoordinates:r}=o,i="string"==typeof o.type?o.type:"label",a=o.eventListeners||o.events||{};if(o.coordinates&&r){const e=o.nx||r[0][0]+(null!==(t=o.dx)&&void 0!==t?t:0),a=o.ny||r[0][1]+(null!==(n=o.dy)&&void 0!==n?n:0),s=r.map((t,n)=>{const r=Object.assign({},o,{note:0===n?o.note:{label:""},x:t[0],y:t[1],nx:e,ny:a});return p.createElement(_e,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+n},r,{type:i}))});return p.createElement("g",null,s)}const s=o.note||{title:"none",label:o.label};return p.createElement(_e,Object.assign({"data-testid":"semiotic-annotation",key:`${s.label}-${s.title}-${o.i}`,events:a},o,{type:i}))}function Te(e,t){var n,o,r;const i=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.x)&&void 0!==o?o:null===(r=t.scales)||void 0===r?void 0:r.time;return i?null!=e.x?i(e.x):t.xAccessor&&null!=e[t.xAccessor]?i(e[t.xAccessor]):null:null}function Ne(e,t){var n,o,r;const i=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.y)&&void 0!==o?o:null===(r=t.scales)||void 0===r?void 0:r.value;return i?null!=e.y?i(e.y):t.yAccessor&&null!=e[t.yAccessor]?i(e[t.yAccessor]):null:null}function De(e,t,n){var o,r,i,a;const s=e.anchor||"fixed";if("latest"===s){if(null!=e.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let r=n.pointNodes.length-1;r>=0;r--){const i=n.pointNodes[r];if(i.pointId===e.pointId){const e={x:i.x,y:i.y};return null===(o=n.stickyPositionCache)||void 0===o||o.set(t,e),e}}const i=function(e){var t,n,o,r,i,a;const s=e.data;if(!s||0===s.length)return null;const l=s[s.length-1],c=null!==(n=null===(t=e.scales)||void 0===t?void 0:t.x)&&void 0!==n?n:null===(o=e.scales)||void 0===o?void 0:o.time,u=null!==(i=null===(r=e.scales)||void 0===r?void 0:r.y)&&void 0!==i?i:null===(a=e.scales)||void 0===a?void 0:a.value;if(!c||!u)return null;const d=l[e.xAccessor||"x"],h=l[e.yAccessor||"y"];return null==d||null==h?null:{x:c(d),y:u(h)}}(n);return i&&(null===(r=n.stickyPositionCache)||void 0===r||r.set(t,i)),i}let l=null,c=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(l=t.x,c=t.y)}if(null!=l&&null!=c||(l=Te(e,n),c=Ne(e,n)),null!=l&&null!=c)return null===(i=n.stickyPositionCache)||void 0===i||i.set(t,{x:l,y:c}),{x:l,y:c};if("sticky"===s){const e=null===(a=n.stickyPositionCache)||void 0===a?void 0:a.get(t);if(e)return e}return null}function Ie(e,t,n,o=50){return!(-o>e||e>(n.width||0)+o||-o>t||t>(n.height||0)+o)}const He={linear:l.curveLinear,monotoneX:l.curveMonotoneX,monotoneY:l.curveMonotoneY,step:l.curveStep,stepAfter:l.curveStepAfter,stepBefore:l.curveStepBefore,basis:l.curveBasis,cardinal:l.curveCardinal,catmullRom:l.curveCatmullRom};function Re(e){return function(e,t,n){var o,r,i,a,c,u,d,h,g,f,m,v,b,x,k,w,A,S,O,E,M,j,C,P,L,_,B,T,N,D,I,H,R,W,F,z,$,G,Y,q,X,V,U,K,Q,Z,J,ee;switch(e.type){case"label":{const o=De(e,t,n);if(!o)return null;const{x:r,y:i}=o;return Ie(r,i,n)?p.createElement(Be,{key:"ann-"+t,noteData:{x:r,y:i,dx:e.dx||30,dy:e.dy||-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"label",connector:e.connector||{end:"arrow"},color:e.color}}):null}case"callout":{const o=De(e,t,n);if(!o)return null;const{x:r,y:i}=o;return Ie(r,i,n)?p.createElement(Be,{key:"ann-"+t,noteData:{x:r,y:i,dx:e.dx||30,dy:e.dy||-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"callout-circle",subject:{radius:e.radius||12},connector:e.connector||{end:"arrow"},color:e.color}}):null}case"x-threshold":{const o=Te(e,n);if(null==o)return null;const r=e.color||"#f97316",i=e.labelPosition||"top";let a;return a="bottom"===i?(n.height||0)-4:"center"===i?(n.height||0)/2:12,p.createElement("g",{key:"ann-"+t},p.createElement("line",{x1:o,y1:0,x2:o,y2:n.height||0,stroke:r,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&p.createElement("text",{x:o+4,y:a,fill:r,fontSize:12,fontWeight:"bold"},e.label))}case"y-threshold":{const o=Ne(e,n);if(null==o)return null;const r=e.color||"#f97316",i=e.labelPosition||"right";let a,s;return"left"===i?(a=4,s="start"):"center"===i?(a=(n.width||0)/2,s="middle"):(a=(n.width||0)-4,s="end"),p.createElement("g",{key:"ann-"+t},p.createElement("line",{x1:0,y1:o,x2:n.width||0,y2:o,stroke:r,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&p.createElement("text",{x:a,y:o-4,textAnchor:s,fill:r,fontSize:12,fontWeight:"bold"},e.label))}case"enclose":{const o=(e.coordinates||[]).map(e=>({x:Te(Object.assign(Object.assign({},e),{type:"point"}),n),y:Ne(Object.assign(Object.assign({},e),{type:"point"}),n),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>o.length)return null;const r=s.packEnclose(o),i=e.padding||10;return p.createElement("g",{key:"ann-"+t},p.createElement("circle",{cx:r.x,cy:r.y,r:r.r+i,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&p.createElement("text",{x:r.x,y:r.y-r.r-i-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12},e.label))}case"rect-enclose":{const o=(e.coordinates||[]).map(e=>({x:Te(Object.assign(Object.assign({},e),{type:"point"}),n),y:Ne(Object.assign(Object.assign({},e),{type:"point"}),n)})).filter(e=>null!=e.x&&null!=e.y);if(2>o.length)return null;const r=e.padding||10,i=o.map(e=>e.x),a=o.map(e=>e.y),s=Math.min(...i)-r,l=Math.max(...i)+r,c=Math.min(...a)-r,u=Math.max(...a)+r;return p.createElement("g",{key:"ann-"+t},p.createElement("rect",{x:s,y:c,width:l-s,height:u-c,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&p.createElement("text",{x:(s+l)/2,y:c-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12},e.label))}case"highlight":{const o=n.data||[],r="function"==typeof e.filter?o.filter(e.filter):e.field&&null!=e.value?o.filter(t=>t[e.field]===e.value):[],i={stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return p.createElement("g",{key:"ann-"+t},r.map((t,o)=>{const r=Te(t,n),a=Ne(t,n);if(null==r||null==a)return null;const s="function"==typeof e.r?e.r(t):e.r||6,l="function"==typeof e.style?e.style(t):e.style||i;return p.createElement("circle",Object.assign({key:"hl-"+o,cx:r,cy:a,r:s},l))}))}case"bracket":{const o=Te(e,n),r=Ne(e,n);return p.createElement(Be,{key:"ann-"+t,noteData:{x:null!=o?o:0,y:null!=r?r:0,dx:e.dx||0,dy:e.dy||0,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"bracket",subject:{type:e.bracketType||"curly",width:e.width,height:e.height,depth:e.depth||30},color:e.color}})}case"trend":{const s=n.data||[];if(2>s.length)return null;const l=n.xAccessor||"x",h=n.yAccessor||"y",g=s.map(e=>[e[l],e[h]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>g.length)return null;const f=null!==(r=null===(o=n.scales)||void 0===o?void 0:o.x)&&void 0!==r?r:null===(i=n.scales)||void 0===i?void 0:i.time,m=null!==(c=null===(a=n.scales)||void 0===a?void 0:a.y)&&void 0!==c?c:null===(u=n.scales)||void 0===u?void 0:u.value;if(!f||!m)return null;const v=e.method||"linear";let b;b="loess"===v?function(e,t=.3){const n=e.length;if(2>n)return e.slice();const o=e.slice().sort((e,t)=>e[0]-t[0]),r=o.map(e=>e[0]),i=o.map(e=>e[1]),a=Math.max(2,Math.ceil(t*n)),s=[];for(let e=0;n>e;e++){const t=r[e],o=r.map(e=>Math.abs(e-t)),l=o.slice().sort((e,t)=>e-t)[Math.min(a-1,n-1)]||1,c=[];for(let e=0;n>e;e++){const t=0===l?0:o[e]/l;c[e]=1>t?Math.pow(1-Math.pow(t,3),3):0}let u=0,d=0,h=0,g=0,f=0;for(let e=0;n>e;e++){const t=c[e];0!==t&&(u+=t,d+=t*r[e],h+=t*i[e],g+=t*r[e]*r[e],f+=t*r[e]*i[e])}if(0===u){s.push([t,i[e]]);continue}const p=u*g-d*d;if(1e-12>Math.abs(p))s.push([t,h/u]);else{const e=(u*f-d*h)/p;s.push([t,(h-e*d)/u+e*t])}}return s}(g,null!==(d=e.bandwidth)&&void 0!==d?d:.3):("polynomial"===v?y.default.polynomial(g,{order:e.order||2}):y.default.linear(g)).points;const x=b.map(([e,t])=>`${f(e)},${m(t)}`).join(" "),k=e.color||"#6366f1";return p.createElement("g",{key:"ann-"+t},p.createElement("polyline",{points:x,fill:"none",stroke:k,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&p.createElement("text",{x:f(b[b.length-1][0])+4,y:m(b[b.length-1][1])-4,fill:k,fontSize:11},e.label))}case"band":{const o=null!==(g=null===(h=n.scales)||void 0===h?void 0:h.y)&&void 0!==g?g:null===(f=n.scales)||void 0===f?void 0:f.value,r=null!==(m=null==o?void 0:o(e.y0))&&void 0!==m?m:0,i=null!==(v=null==o?void 0:o(e.y1))&&void 0!==v?v:n.height||0;return p.createElement("g",{key:"ann-"+t},p.createElement("rect",{x:0,y:Math.min(r,i),width:n.width||0,height:Math.abs(i-r),fill:e.fill||"var(--semiotic-primary, #6366f1)",fillOpacity:e.fillOpacity||.1}),e.label&&p.createElement("text",{x:(n.width||0)-4,y:Math.min(r,i)-4,textAnchor:"end",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11},e.label))}case"envelope":{const o=n.data||[];if(2>o.length)return null;const r=n.xAccessor||"x",i=null!==(x=null===(b=n.scales)||void 0===b?void 0:b.x)&&void 0!==x?x:null===(k=n.scales)||void 0===k?void 0:k.time,a=null!==(A=null===(w=n.scales)||void 0===w?void 0:w.y)&&void 0!==A?A:null===(S=n.scales)||void 0===S?void 0:S.value;if(!i||!a)return null;const s=e.upperAccessor||"upperBounds",c=e.lowerAccessor||"lowerBounds",u=e.filter,d=o.filter(e=>null!=e[s]&&null!=e[c]&&!(u&&!u(e))).sort((e,t)=>e[r]-t[r]);if(2>d.length)return null;const h=He[n.curve||"linear"]||l.curveLinear,g=l.area().x(e=>i(e[r])).y0(e=>a(e[c])).y1(e=>a(e[s])).curve(h)(d);if(!g)return null;const f=e.fill||"#6366f1";return p.createElement("g",{key:"ann-"+t},p.createElement("path",{d:g,fill:f,fillOpacity:null!==(O=e.fillOpacity)&&void 0!==O?O:.15,stroke:"none"}),e.label&&d.length>0&&p.createElement("text",{x:i(d[d.length-1][r])+4,y:a(d[d.length-1][s])-4,fill:f,fontSize:11},e.label))}case"anomaly-band":{const o=n.data||[];if(2>o.length)return null;const r=n.yAccessor||"y",i=null!==(M=null===(E=n.scales)||void 0===E?void 0:E.x)&&void 0!==M?M:null===(j=n.scales)||void 0===j?void 0:j.time,a=null!==(P=null===(C=n.scales)||void 0===C?void 0:C.y)&&void 0!==P?P:null===(L=n.scales)||void 0===L?void 0:L.value;if(!i||!a)return null;const s=o.map(e=>e[r]).filter(e=>null!=e&&isFinite(e));if(2>s.length)return null;const l=s.reduce((e,t)=>e+t,0)/s.length,c=s.reduce((e,t)=>e+Math.pow(t-l,2),0)/s.length,u=Math.sqrt(c),d=null!==(_=e.threshold)&&void 0!==_?_:2,h=l-d*u,g=!1!==e.showBand,f=e.fill||"#6366f1",y=null!==(B=e.fillOpacity)&&void 0!==B?B:.1,m=e.anomalyColor||"#ef4444",v=null!==(T=e.anomalyRadius)&&void 0!==T?T:6,b=a(l+d*u),x=a(h),k=o.filter(e=>{const t=e[r];return null!=t&&Math.abs(t-l)>d*u});return p.createElement("g",{key:"ann-"+t},g&&p.createElement("rect",{x:0,y:Math.min(b,x),width:n.width||0,height:Math.abs(x-b),fill:f,fillOpacity:y}),k.map((e,t)=>{const o=Te(e,n),r=Ne(e,n);return null==o||null==r?null:p.createElement("circle",{key:"anomaly-"+t,cx:o,cy:r,r:v,fill:m,fillOpacity:.7,stroke:m,strokeWidth:1.5})}),e.label&&p.createElement("text",{x:(n.width||0)-4,y:Math.min(b,x)-4,textAnchor:"end",fill:f,fontSize:11},e.label))}case"forecast":{const o=n.data||[];if(3>o.length)return null;const r=n.xAccessor||"x",i=n.yAccessor||"y",a=null!==(D=null===(N=n.scales)||void 0===N?void 0:N.x)&&void 0!==D?D:null===(I=n.scales)||void 0===I?void 0:I.time,s=null!==(R=null===(H=n.scales)||void 0===H?void 0:H.y)&&void 0!==R?R:null===(W=n.scales)||void 0===W?void 0:W.value;if(!a||!s)return null;const l=o.map(e=>[e[r],e[i]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]);if(3>l.length)return null;let c;if("polynomial"===(e.method||"linear")){const t=y.default.polynomial(l,{order:e.order||2}).equation;c=e=>t.reduce((t,n,o)=>t+n*Math.pow(e,o),0)}else{const e=l.length;let t=0,n=0,o=0,r=0;for(const[e,i]of l)t+=e,n+=i,o+=e*e,r+=e*i;const i=e*o-t*t;if(1e-12>Math.abs(i))return null;const a=(e*r-t*n)/i,s=(n-a*t)/e;c=e=>s+a*e}const u=l.length,d=l.map(([e,t])=>t-c(e)).reduce((e,t)=>e+t*t,0),h=Math.sqrt(d/Math.max(u-2,1)),g=l.reduce((e,t)=>e+t[0],0)/u,f=l.reduce((e,t)=>e+Math.pow(t[0]-g,2),0),m=null!==(F=e.confidence)&&void 0!==F?F:.95,v=.99>m?.95>m?.9>m?1:1.645:1.96:2.576,b=null!==(z=e.steps)&&void 0!==z?z:5,x=l[u-1][0],k=(x-l[0][0])/Math.max(u-1,1),w=[];for(let e=1;b>=e;e++)w.push(x+e*k);const A=[];for(const e of w){const t=c(e),n=h*Math.sqrt(1+1/u+(f>0?Math.pow(e-g,2)/f:0))*v;A.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const S=`M${A.map(e=>`${a(e.x)},${s(e.yUpper)}`).join(" L")} L${A.slice().reverse().map(e=>`${a(e.x)},${s(e.yLower)}`).join(" L")} Z`,O=A.map(e=>`${a(e.x)},${s(e.yCenter)}`).join(" "),E=`${a(x)},${s(c(x))}`,M=e.strokeColor||"#6366f1";return p.createElement("g",{key:"ann-"+t},p.createElement("path",{d:S,fill:e.fill||"#6366f1",fillOpacity:null!==($=e.fillOpacity)&&void 0!==$?$:.15,stroke:"none"}),p.createElement("polyline",{points:`${E} ${O}`,fill:"none",stroke:M,strokeWidth:null!==(G=e.strokeWidth)&&void 0!==G?G:2,strokeDasharray:null!==(Y=e.strokeDasharray)&&void 0!==Y?Y:"6,3"}),e.label&&A.length>0&&p.createElement("text",{x:a(A[A.length-1].x)+4,y:s(A[A.length-1].yCenter)-4,fill:M,fontSize:11},e.label))}case"widget":{let o=null,r=null;if(null!=e.px&&null!=e.py)o=e.px,r=e.py;else{const i=De(e,t,n);if(!i)return null;o=i.x,r=i.y}if(null==o||null==r)return null;if(!Ie(o,r,n))return null;const i=null!==(q=e.dx)&&void 0!==q?q:0,a=null!==(X=e.dy)&&void 0!==X?X:0,s=null!==(V=e.width)&&void 0!==V?V:32,l=null!==(U=e.height)&&void 0!==U?U:32,c=null!==(K=e.content)&&void 0!==K?K:p.createElement("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info"},"ℹ️");return p.createElement("foreignObject",{key:"ann-"+t,x:o+i-s/2,y:r+a-l/2,width:s,height:l,style:{overflow:"visible",pointerEvents:"auto"}},p.createElement("div",{style:{width:s,height:l,display:"flex",alignItems:"center",justifyContent:"center"}},c))}case"text":{const o=De(e,t,n);if(!o)return null;const{x:r,y:i}=o;return p.createElement("text",{key:"ann-text-"+t,x:r+(e.dx||0),y:i+(e.dy||0),fill:e.color||"var(--semiotic-text, #333)",fontSize:e.fontSize||11,dominantBaseline:"middle",style:{fontFamily:"inherit"}},e.label)}case"category-highlight":{const o=e.category;if(null==o)return null;const r=null===(Q=n.scales)||void 0===Q?void 0:Q.o,i=null===(Z=n.scales)||void 0===Z?void 0:Z.x,a=null===(J=n.scales)||void 0===J?void 0:J.y,s=(null==r?void 0:r.bandwidth)?r:(null==i?void 0:i.bandwidth)?i:(null==a?void 0:a.bandwidth)?a:null;if(!s)return null;const l=s(o);if(null==l)return null;const c=s.bandwidth(),u=e.color||"var(--semiotic-primary, #4589ff)",d=null!==(ee=e.opacity)&&void 0!==ee?ee:.15,h=e.label;return(n.projection?"vertical"===n.projection:s===i)?p.createElement("g",{key:"ann-"+t},p.createElement("rect",{x:l,y:0,width:c,height:n.height||0,fill:u,fillOpacity:d}),h&&p.createElement("text",{x:l+c/2,y:12,textAnchor:"middle",fill:u,fontSize:12,fontWeight:"bold"},h)):p.createElement("g",{key:"ann-"+t},p.createElement("rect",{x:0,y:l,width:n.width||0,height:c,fill:u,fillOpacity:d}),h&&p.createElement("text",{x:12,y:l+c/2,dominantBaseline:"middle",fill:u,fontSize:12,fontWeight:"bold"},h))}default:return null}}}let We={positions:new Map};const Fe=new Set;function ze(){for(const e of Fe)e()}function $e(e,t){const n=We.positions.get(e);if(null==n?void 0:n.locked)return;if(!n||n.sourceId!==t)return;const o=new Map(We.positions);o.delete(e),We={positions:o},ze()}function Ge(e,t){const n=We.positions.get(e);if(!(null==n?void 0:n.locked))return;if(t&&n.sourceId!==t)return;const o=new Map(We.positions);o.delete(e),We={positions:o},ze()}function Ye(){return We}function qe(e){return Fe.add(e),()=>Fe.delete(e)}const Xe={positions:new Map};function Ve(){return()=>{}}function Ue(){return Xe}function Ke(e){if(e)return"dashed"===e?"6,4":"dotted"===e?"2,4":e}function Qe(e,t,n){if("left"===e||"right"===e){const o="left"===e?n:0,r="left"===e?-1:1,i=Math.ceil(t/8);let a="M0,"+o;for(let e=0;i>e;e++){const n=8*(e+1);a+=`L${Math.min(8*e+4,t)},${o+4*r}`,a+=`L${Math.min(n,t)},${o}`}return a}{const o="bottom"===e?0:t,r="bottom"===e?1:-1,i=Math.ceil(n/8);let a=`M${o},0`;for(let e=0;i>e;e++){const t=8*(e+1);a+=`L${o+4*r},${Math.min(8*e+4,n)}`,a+=`L${o},${Math.min(t,n)}`}return a}}function Ze(t){const{width:n,height:o,totalWidth:r,totalHeight:i,margin:a,scales:s,showAxes:l,axes:c,showGrid:u,xFormat:d,yFormat:h}=t,g=e.useMemo(()=>{var e;if(!s)return[];const t=null==c?void 0:c.find(e=>"bottom"===e.orient),o=(null==t?void 0:t.tickFormat)||d||Je,r=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5,i=s.x.ticks(Math.min(r,Math.max(2,Math.floor(n/70)))),a=i.map(e=>e.valueOf()),l=i.map((e,t)=>({value:e,pixel:s.x(e),label:o(e,t,a)})),u=l.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:"number"==typeof t.label?6.5*(t.label+"").length:60),0);return et(l,Math.max(55,u+8))},[s,c,d,n]),f=e.useMemo(()=>{var e;if(!s)return[];const t=null==c?void 0:c.find(e=>"left"===e.orient),n=(null==t?void 0:t.tickFormat)||h||Je,r=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;return et(s.y.ticks(Math.min(r,Math.max(2,Math.floor(o/30)))).map(e=>({value:e,pixel:s.y(e),label:n(e)})),22)},[s,c,h,o]),y=u&&s,m=l&&s;if(!y&&!m)return null;const v=null==c?void 0:c.find(e=>"bottom"===e.orient),b=null==c?void 0:c.find(e=>"left"===e.orient),x=m&&(!v||!1!==v.baseline),k=m&&(!b||!1!==b.baseline),w=(null==v?void 0:v.jaggedBase)||!1,A=(null==b?void 0:b.jaggedBase)||!1,S="var(--semiotic-border, #ccc)";return p.createElement("svg",{width:r,height:i,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},p.createElement("g",{transform:`translate(${a.left},${a.top})`},y&&(()=>{var e,t;const r=Ke(null===(e=null==c?void 0:c.find(e=>"bottom"===e.orient))||void 0===e?void 0:e.gridStyle),i=Ke(null===(t=null==c?void 0:c.find(e=>"left"===e.orient))||void 0===t?void 0:t.gridStyle);return p.createElement("g",{className:"stream-grid"},g.map((e,t)=>p.createElement("line",{key:"xgrid-"+t,x1:e.pixel,y1:0,x2:e.pixel,y2:o,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r})),f.map((e,t)=>p.createElement("line",{key:"ygrid-"+t,x1:0,y1:e.pixel,x2:n,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:i})))})(),x&&!w&&p.createElement("line",{x1:0,y1:o,x2:n,y2:o,stroke:S,strokeWidth:1}),w&&p.createElement("path",{d:Qe("bottom",n,o),fill:"none",stroke:S,strokeWidth:1}),k&&!A&&p.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:S,strokeWidth:1}),A&&p.createElement("path",{d:Qe("left",n,o),fill:"none",stroke:S,strokeWidth:1})))}function Je(e,t,n){return e instanceof Date?`${e.toLocaleString("en",{month:"short"})} ${e.getDate()}`:"number"==typeof e?Math.round(100*e)/100+"":e+""}function et(e,t){if(2>=e.length)return e;const n=[e[0]];for(let o=1;e.length-1>o;o++)t>Math.abs(e[o].pixel-n[n.length-1].pixel)||n.push(e[o]);const o=e[e.length-1];return t>Math.abs(o.pixel-n[n.length-1].pixel)?n[n.length-1]=o:n.push(o),n}function tt(t){var n,o;const{width:r,height:i,totalWidth:a,totalHeight:s,margin:l,scales:c,showAxes:u,axes:d,xLabel:h,yLabel:g,yLabelRight:f,xFormat:y,yFormat:m,showGrid:v,title:b,legend:x,legendHoverBehavior:k,legendClickBehavior:w,legendHighlightedCategory:A,legendIsolatedCategories:S,legendPosition:O="right",foregroundGraphics:E,marginalGraphics:M,xValues:j,yValues:C,annotations:P,svgAnnotationRules:L,xAccessor:_,yAccessor:B,annotationData:T,pointNodes:N,curve:D,underlayRendered:I,linkedCrosshairName:H,linkedCrosshairSourceId:R,children:W}=t,F=e.useMemo(()=>{var e;if(!u||!c)return[];const t=null==d?void 0:d.find(e=>"bottom"===e.orient),n=(null==t?void 0:t.tickFormat)||y||Je,o=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5,i=c.x.ticks(Math.min(o,Math.max(2,Math.floor(r/70)))),a=i.map(e=>e.valueOf()),s=i.map((e,t)=>({value:e,pixel:c.x(e),label:n(e,t,a)})),l=s.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:"number"==typeof t.label?6.5*(t.label+"").length:60),0),h=(null==t?void 0:t.autoRotate)?Math.max(20,Math.min(l+8,55)):Math.max(55,l+8);let g=et(s,h);if(g.length>1&&(g=g.filter((e,t)=>0===t||e.label+""!=g[t-1].label+"")),(null==t?void 0:t.includeMax)&&g.length>0){const e=c.x.domain()[1],t=c.x(e),o=g[g.length-1].pixel;if(Math.abs(t-o)>1){const r=n(e,g.length,a);h>t-o&&g.length>1&&(g=g.slice(0,-1)),g.push({value:e,pixel:t,label:r})}}return g},[u,c,d,y,r]),z=e.useMemo(()=>{var e;if(!u||!c)return[];const t=null==d?void 0:d.find(e=>"left"===e.orient),n=(null==t?void 0:t.tickFormat)||m||Je,o=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;let r=et(c.y.ticks(Math.min(o,Math.max(2,Math.floor(i/30)))).map(e=>({value:e,pixel:c.y(e),label:n(e)})),22);if(r.length>1&&(r=r.filter((e,t)=>0===t||e.label+""!=r[t-1].label+"")),(null==t?void 0:t.includeMax)&&r.length>0){const e=c.y.domain()[1],t=c.y(e),o=r[r.length-1].pixel;if(Math.abs(t-o)>1){const i=n(e);22>Math.abs(t-o)&&r.length>1&&(r=r.slice(0,-1)),r.push({value:e,pixel:t,label:i})}}return r},[u,c,d,m,i]),$=e.useMemo(()=>{var e;if(!u||!c)return[];const t=null==d?void 0:d.find(e=>"right"===e.orient);if(!t)return[];const n=t.tickFormat||m||Je,o=null!==(e=t.ticks)&&void 0!==e?e:5;return et(c.y.ticks(Math.min(o,Math.max(2,Math.floor(i/30)))).map(e=>({value:e,pixel:c.y(e),label:n(e)})),22)},[u,c,d,m,i]),G=e.useRef(new Map),Y=e.useRef(null!==(n=null==P?void 0:P.length)&&void 0!==n?n:0),q=null!==(o=null==P?void 0:P.length)&&void 0!==o?o:0;Y.current!==q&&(Y.current=q,G.current=new Map);const X=e.useMemo(()=>{if(!P||0===P.length)return null;const e=Re(),t={scales:c?{x:c.x,y:c.y,time:c.x,value:c.y}:null,timeAxis:"x",xAccessor:_,yAccessor:B,width:r,height:i,data:T,frameType:"xy",pointNodes:N,curve:D,stickyPositionCache:G.current};return P.map((n,o)=>{if(L){const r=L(n,o,t);return null!=r?r:e(n,o,t)}return e(n,o,t)}).filter(Boolean)},[P,L,r,i,_,B,T,c,N,D]),V=function(t){var n;const o=e.useSyncExternalStore(t?qe:Ve,t?Ye:Ue,t?Ye:Ue);return t&&null!==(n=o.positions.get(t))&&void 0!==n?n:null}(H);return e.useEffect(()=>{if(!(null==V?void 0:V.locked)||!H)return;const e=e=>{"Escape"===e.key&&Ge(H)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[null==V?void 0:V.locked,H]),u||b||x||E||M||X&&X.length>0||v||W||V?p.createElement("svg",{role:"img",width:a,height:s,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"}},p.createElement("title",null,"string"==typeof b?b:"XY Chart"),p.createElement("desc",null,"string"==typeof b?b+" — XY data visualization":"XY data visualization"),p.createElement("g",{transform:`translate(${l.left},${l.top})`},v&&c&&!I&&(()=>{var e,t;const n=Ke(null===(e=null==d?void 0:d.find(e=>"bottom"===e.orient))||void 0===e?void 0:e.gridStyle),o=Ke(null===(t=null==d?void 0:d.find(e=>"left"===e.orient))||void 0===t?void 0:t.gridStyle);return p.createElement("g",{className:"stream-grid"},F.map((e,t)=>p.createElement("line",{key:"xgrid-"+t,x1:e.pixel,y1:0,x2:e.pixel,y2:i,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:n})),z.map((e,t)=>p.createElement("line",{key:"ygrid-"+t,x1:0,y1:e.pixel,x2:r,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:o})))})(),u&&c&&(()=>{const e=null==d?void 0:d.find(e=>"left"===e.orient),t=null==d?void 0:d.find(e=>"bottom"===e.orient),n=!e||!1!==e.baseline,o=!t||!1!==t.baseline,a=(null==e?void 0:e.jaggedBase)||!1,s=(null==t?void 0:t.jaggedBase)||!1,c=null==t?void 0:t.landmarkTicks,u=null==e?void 0:e.landmarkTicks,y="var(--semiotic-border, #ccc)",m="var(--semiotic-text-secondary, var(--semiotic-text, #666))",v="var(--semiotic-text, #333)",b=!!(null==t?void 0:t.autoRotate)&&F.length>1&&(()=>{const e=r/Math.max(F.length-1,1);return F.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:60),0)+8>e})();return p.createElement("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"}},!I&&o&&!s&&p.createElement("line",{x1:0,y1:i,x2:r,y2:i,stroke:y,strokeWidth:1}),!I&&s&&p.createElement("path",{d:Qe("bottom",r,i),fill:"none",stroke:y,strokeWidth:1}),F.map((e,t)=>{const n=!!c&&("function"==typeof c?c(e.value,t):ne(e.value,t>0?F[t-1].value:void 0));return p.createElement("g",{key:"xtick-"+t,transform:`translate(${e.pixel},${i})`},p.createElement("line",{y2:5,stroke:y,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?p.createElement("text",{y:b?10:18,textAnchor:b?"end":"middle",fontSize:n?11:10,fontWeight:n?600:400,fill:m,style:{userSelect:"none"},transform:b?"rotate(-45)":void 0},e.label):p.createElement("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"}},p.createElement("div",{style:{textAlign:"center",fontSize:10,userSelect:"none"}},e.label)))}),h&&p.createElement("text",{x:r/2,y:i+40,textAnchor:"middle",fontSize:12,fill:v,style:{userSelect:"none"}},h),!I&&n&&!a&&p.createElement("line",{x1:0,y1:0,x2:0,y2:i,stroke:y,strokeWidth:1}),!I&&a&&p.createElement("path",{d:Qe("left",r,i),fill:"none",stroke:y,strokeWidth:1}),z.map((e,t)=>{const n=!!u&&("function"==typeof u?u(e.value,t):ne(e.value,t>0?z[t-1].value:void 0));return p.createElement("g",{key:"ytick-"+t,transform:`translate(0,${e.pixel})`},p.createElement("line",{x2:-5,stroke:y,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?p.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:n?11:10,fontWeight:n?600:400,fill:m,style:{userSelect:"none"}},e.label):p.createElement("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"}},p.createElement("div",{style:{textAlign:"right",fontSize:10,userSelect:"none"}},e.label)))}),(()=>{const t=(null==e?void 0:e.label)||g;return t?p.createElement("text",{x:15-l.left,y:i/2,textAnchor:"middle",fontSize:12,fill:v,transform:`rotate(-90, ${15-l.left}, ${i/2})`,style:{userSelect:"none"}},t):null})(),(()=>{const e=null==d?void 0:d.find(e=>"right"===e.orient);if(!e||0===$.length)return null;const t=e.landmarkTicks,n=e.label||f;return p.createElement(p.Fragment,null,!1!==e.baseline&&p.createElement("line",{x1:r,y1:0,x2:r,y2:i,stroke:y,strokeWidth:1}),$.map((e,n)=>{const o=!!t&&("function"==typeof t?t(e.value,n):ne(e.value,n>0?$[n-1].value:void 0));return p.createElement("g",{key:"ytick-r-"+n,transform:`translate(${r},${e.pixel})`},p.createElement("line",{x2:5,stroke:y,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?p.createElement("text",{x:8,textAnchor:"start",dominantBaseline:"middle",fontSize:o?11:10,fontWeight:o?600:400,fill:m,style:{userSelect:"none"}},e.label):p.createElement("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"}},p.createElement("div",{style:{textAlign:"left",fontSize:10,userSelect:"none"}},e.label)))}),n&&p.createElement("text",{x:r+l.right-15,y:i/2,textAnchor:"middle",fontSize:12,fill:v,transform:`rotate(90, ${r+l.right-15}, ${i/2})`,style:{userSelect:"none"}},n))})())})(),X,M&&c&&j&&C&&p.createElement(p.Fragment,null,M.top&&p.createElement("g",{transform:"translate(0, 0)"},p.createElement(Ce,{orient:"top",config:je(M.top),values:j,scale:c.x,size:l.top,length:r})),M.bottom&&p.createElement("g",{transform:`translate(0, ${i})`},p.createElement(Ce,{orient:"bottom",config:je(M.bottom),values:j,scale:c.x,size:l.bottom,length:r})),M.left&&p.createElement("g",{transform:"translate(0, 0)"},p.createElement(Ce,{orient:"left",config:je(M.left),values:C,scale:c.y,size:l.left,length:i})),M.right&&p.createElement("g",{transform:`translate(${r}, 0)`},p.createElement(Ce,{orient:"right",config:je(M.right),values:C,scale:c.y,size:l.right,length:i}))),E,V&&V.sourceId!==R&&(null==c?void 0:c.x)&&(()=>{const e=c.x(V.xValue);if(null==e||0>e||e>r)return null;const t=V.locked;return p.createElement("line",{x1:e,y1:0,x2:e,y2:i,stroke:t?"white":"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:t?1.5:1,strokeDasharray:t?"6,3":"4,4",pointerEvents:"none"})})(),W),b&&p.createElement("text",{x:a/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof b?b:null),Me({legend:x,totalWidth:a,totalHeight:s,margin:l,legendPosition:O,title:b,legendHoverBehavior:k,legendClickBehavior:w,legendHighlightedCategory:A,legendIsolatedCategories:S})):null}function nt(e,t="#4e79a7"){return e&&"string"==typeof e?e:t}const ot="undefined"==typeof window||"undefined"==typeof document,rt=p.createContext(null);function it({children:e}){const[t,n]=p.useState(!1),o=p.useMemo(()=>({visible:t,setVisible:n}),[t]);return p.createElement(rt.Provider,{value:o},e)}function at(){return p.useContext(rt)}const st={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function lt(e,t){if(!e||0===e.length)return t+", empty";const n={};for(const t of e)n[t.type]=(n[t.type]||0)+1;const o=[],r={point:"points",line:"lines",area:"areas",rect:"bars",heatcell:"cells",circle:"nodes",candlestick:"candlesticks",wedge:"wedges",arc:"arcs",geoarea:"regions"},i=["point","line","area","rect","heatcell","circle","candlestick","wedge","arc","geoarea"],a=Object.keys(n).sort((e,t)=>{const n=i.indexOf(e),o=i.indexOf(t);return(-1===n?999:n)-(-1===o?999:o)});for(const e of a)o.push(`${n[e]} ${r[e]||e}`);return`${t}, ${o.join(", ")}`}function ct(e,t,n){const o=[];return e>0&&o.push(e+" nodes"),t>0&&o.push(t+" edges"),0===o.length?n+", empty":`${n}, ${o.join(", ")}`}const ut=e=>{if(null==e)return"";const t=Math.round(100*e)/100;return Number.isNaN(t)?"":t+""},dt={position:"absolute",top:0,left:0,right:0,zIndex:5,padding:"14px 16px 12px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)",fontFamily:"var(--semiotic-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif)",fontSize:13,lineHeight:1.5,color:"var(--semiotic-text, #333)",background:"var(--semiotic-bg, #fff)",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},ht={marginBottom:8,paddingRight:28,color:"var(--semiotic-text-secondary, #666)",fontSize:12,letterSpacing:"0.01em"},gt={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-border, #e0e0e0)",background:"var(--semiotic-bg, #fff)",cursor:"pointer",color:"var(--semiotic-text-secondary, #666)",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},ft={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},pt={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-border, #e0e0e0)",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-text-secondary, #666)"},yt={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"},mt={textAlign:"left",fontSize:11,color:"var(--semiotic-text-secondary, #999)",marginBottom:4,fontStyle:"italic"};function vt({scene:e,chartType:t,tableId:n,chartTitle:o}){var r;const[i,a]=p.useState(!1),s=at(),l=null!==(r=null==s?void 0:s.visible)&&void 0!==r&&r,c=i||l,u=p.useRef(null),d=o?"Data summary for "+o:n?`Data summary for ${t} ${n}`:"Data summary for "+t,h=p.useCallback(()=>{i||l||a(!0)},[i,l]),g=p.useCallback(e=>{var t;l||(null===(t=u.current)||void 0===t?void 0:t.contains(e.relatedTarget))||a(!1)},[l]);if(!e||0===e.length)return n?p.createElement("span",{id:n,tabIndex:-1,style:st}):null;if(!c)return p.createElement("div",{id:n,tabIndex:-1,onFocus:h,style:st,role:"region","aria-label":d},p.createElement("button",{type:"button",onClick:()=>a(!0)},"View data summary (",e.length," elements)"));const f=function(e){var t,n,o,r,i,a,s,l,c,u,d,h,g,f,p,y,m,v,b,x,k,w,A,S,O;const E=[];if(!Array.isArray(e))return E;for(const M of e)if(M&&"object"==typeof M)try{switch(M.type){case"point":E.push({label:"Point",values:{x:M.x,y:M.y}});break;case"line":{const e=M.path,t=Array.isArray(M.datum)?M.datum:[];if(!Array.isArray(e))break;for(let n=0;e.length>n&&t.length>n;n++){const t=e[n];Array.isArray(t)&&E.push({label:"Line point",values:{x:t[0],y:t[1]}})}break}case"area":{const e=M.topPath,t=Array.isArray(M.datum)?M.datum:[];if(!Array.isArray(e))break;for(let n=0;e.length>n&&t.length>n;n++){const t=e[n];Array.isArray(t)&&E.push({label:"Area point",values:{x:t[0],y:t[1]}})}break}case"rect":{const e=null!=M.datum&&"object"==typeof M.datum?M.datum:{},i=null!==(n=null!==(t=e.category)&&void 0!==t?t:M.group)&&void 0!==n?n:"",a=null!==(r=null!==(o=e.value)&&void 0!==o?o:e.__aggregateValue)&&void 0!==r?r:e.total;E.push({label:"Bar",values:{category:i,value:null!=a?a:""}});break}case"heatcell":E.push({label:"Cell",values:{x:M.x,y:M.y,value:M.value}});break;case"wedge":E.push({label:"Wedge",values:{category:null!==(l=null!==(a=null===(i=M.datum)||void 0===i?void 0:i.category)&&void 0!==a?a:null===(s=M.datum)||void 0===s?void 0:s.label)&&void 0!==l?l:"",value:null!==(u=null===(c=M.datum)||void 0===c?void 0:c.value)&&void 0!==u?u:""}});break;case"circle":E.push({label:"Node",values:{id:null!==(h=null===(d=M.datum)||void 0===d?void 0:d.id)&&void 0!==h?h:"",x:null!==(g=M.cx)&&void 0!==g?g:M.x,y:null!==(f=M.cy)&&void 0!==f?f:M.y}});break;case"arc":E.push({label:"Arc",values:{id:null!==(y=null===(p=M.datum)||void 0===p?void 0:p.id)&&void 0!==y?y:"",x:null!==(m=M.cx)&&void 0!==m?m:M.x,y:null!==(v=M.cy)&&void 0!==v?v:M.y}});break;case"candlestick":E.push({label:"Candlestick",values:{x:M.x,open:M.open,high:M.high,low:M.low,close:M.close}});break;case"geoarea":E.push({label:"Region",values:{name:null!==(A=null!==(k=null===(x=null===(b=M.datum)||void 0===b?void 0:b.properties)||void 0===x?void 0:x.name)&&void 0!==k?k:null===(w=M.datum)||void 0===w?void 0:w.name)&&void 0!==A?A:"",value:null!==(O=null===(S=M.datum)||void 0===S?void 0:S.value)&&void 0!==O?O:""}})}}catch(e){}return E}(e),y=function(e){if(!e||0===e.length)return[];const t=new Set;for(const n of e)if(n&&n.values)for(const e of Object.keys(n.values))t.add(e);const n=[];for(const o of t){const t=[],r=new Set;for(const n of e){if(!n||!n.values)continue;const e=n.values[o];null!=e&&""!==e&&("number"==typeof e&&!Number.isNaN(e)&&Number.isFinite(e)?t.push(e):"number"==typeof e||"object"!=typeof e&&"function"!=typeof e&&r.add(e+""))}if(t.length>0){let e=t[0],r=t[0],i=0;for(const n of t)e>n&&(e=n),n>r&&(r=n),i+=n;n.push({name:o,count:t.length,numeric:!0,min:e,max:r,mean:i/t.length})}else if(r.size>0){const e=Array.from(r);n.push({name:o,count:e.length,numeric:!1,uniqueValues:e.slice(0,5)})}}return n}(f),m=function(e,t){const n=[e+" data points."];for(const e of t)if(e.numeric)n.push(`${e.name}: ${ut(e.min)} to ${ut(e.max)}, mean ${ut(e.mean)}.`);else{const t=e.uniqueValues,o=t.length>3?`${t.slice(0,3).join(", ")}… (${e.count} unique)`:t.join(", ");n.push(`${e.name}: ${o}.`)}return n.join(" ")}(f.length,y),v=f.slice(0,5),b=new Set;for(const e of v)for(const t of Object.keys(e.values))b.add(t);const x=Array.from(b);return p.createElement("div",{ref:u,id:n,tabIndex:-1,onBlur:g,style:dt,role:"region","aria-label":d},p.createElement("button",{type:"button",onClick:()=>{l&&s&&s.setVisible(!1),a(!1)},"aria-label":"Close data summary",style:gt},"×"),p.createElement("div",{role:"note",style:ht},m),p.createElement("table",{role:"table","aria-label":"Sample data for "+t,style:ft},p.createElement("caption",{style:mt},"First ",v.length," of ",f.length," data points"),p.createElement("thead",null,p.createElement("tr",null,p.createElement("th",{style:pt},"type"),x.map(e=>p.createElement("th",{key:e,style:pt},e)))),p.createElement("tbody",null,v.map((e,t)=>p.createElement("tr",{key:t},p.createElement("td",{style:yt},e.label),x.map(t=>{return p.createElement("td",{key:t,style:yt},null==(n=e.values[t])||""===n?"—":"number"==typeof n?Number.isNaN(n)?"—":ut(n):"boolean"==typeof n?n?"true":"false":"object"==typeof n?"—":n+"");var n}))))))}function bt({nodes:e,edges:t,chartType:n,tableId:o,chartTitle:r}){var i,a,s,l,c,u,d,h,g,f,y,m,v,b;const[x,k]=p.useState(!1),w=at(),A=null!==(i=null==w?void 0:w.visible)&&void 0!==i&&i,S=x||A,O=r?"Data summary for "+r:o?`Data summary for ${n} ${o}`:"Data summary for "+n,E=p.useRef(null),M=p.useCallback(()=>{x||A||k(!0)},[x,A]),j=p.useCallback(e=>{var t;A||(null===(t=E.current)||void 0===t?void 0:t.contains(e.relatedTarget))||k(!1)},[A]);if(!e||0===e.length)return o?p.createElement("span",{id:o,tabIndex:-1,style:st}):null;if(!S)return p.createElement("div",{id:o,tabIndex:-1,onFocus:M,style:st,role:"region","aria-label":O},p.createElement("button",{type:"button",onClick:()=>k(!0)},"View data summary (",e.length," nodes, ",t.length," edges)"));const C=Array.isArray(e)?e:[],P=Array.isArray(t)?t:[],L=new Map,_=new Map,B=new Map,T=new Map;for(const e of P){if(!e||"object"!=typeof e)continue;const t=null!==(a=e.datum)&&void 0!==a?a:e,n="object"==typeof t.source?null===(s=t.source)||void 0===s?void 0:s.id:t.source,o="object"==typeof t.target?null===(l=t.target)||void 0===l?void 0:l.id:t.target,r="number"==typeof t.value&&Number.isFinite(t.value)?t.value:0;if(null!=n&&""!==n){const e=n+"";_.set(e,(null!==(c=_.get(e))&&void 0!==c?c:0)+1),T.set(e,(null!==(u=T.get(e))&&void 0!==u?u:0)+r)}if(null!=o&&""!==o){const e=o+"";L.set(e,(null!==(d=L.get(e))&&void 0!==d?d:0)+1),B.set(e,(null!==(h=B.get(e))&&void 0!==h?h:0)+r)}}const N=[];for(let e=0;C.length>e;e++){const t=C[e];if(!t||"object"!=typeof t)continue;const n=null!==(f=null===(g=t.datum)||void 0===g?void 0:g.id)&&void 0!==f?f:t.id,o=null!=n?n+"":"node-"+e,r=null!==(y=L.get(o))&&void 0!==y?y:0,i=null!==(m=_.get(o))&&void 0!==m?m:0,a=null!==(v=B.get(o))&&void 0!==v?v:0,s=null!==(b=T.get(o))&&void 0!==b?b:0;N.push({id:o,degree:r+i,inDeg:r,outDeg:i,wDegree:a+s,wInDeg:a,wOutDeg:s})}N.sort((e,t)=>t.degree-e.degree);let D=0,I=0;if(N.length>0){let e=0;for(const t of N)e+=t.degree,t.degree>I&&(I=t.degree);D=e/N.length}const H=P.some(e=>{var t;const n=null!==(t=null==e?void 0:e.datum)&&void 0!==t?t:e;return"number"==typeof(null==n?void 0:n.value)&&Number.isFinite(n.value)}),R=[`${N.length} nodes, ${P.length} edges.`];N.length>0&&R.push(`Mean degree: ${ut(D)}, max degree: ${I}.`);const W=N.slice(0,5);return p.createElement("div",{ref:E,id:o,tabIndex:-1,onBlur:j,style:dt,role:"region","aria-label":O},p.createElement("button",{type:"button",onClick:()=>{A&&w&&w.setVisible(!1),k(!1)},"aria-label":"Close data summary",style:gt},"×"),p.createElement("div",{role:"note",style:ht},R.join(" ")),p.createElement("table",{role:"table","aria-label":"Node degree summary for "+n,style:ft},p.createElement("caption",{style:mt},"Top ",W.length," of ",N.length," nodes by degree"),p.createElement("thead",null,p.createElement("tr",null,p.createElement("th",{style:pt},"id"),p.createElement("th",{style:pt},"degree"),p.createElement("th",{style:pt},"in"),p.createElement("th",{style:pt},"out"),H&&p.createElement("th",{style:pt},"w. degree"),H&&p.createElement("th",{style:pt},"w. in"),H&&p.createElement("th",{style:pt},"w. out"))),p.createElement("tbody",null,W.map((e,t)=>p.createElement("tr",{key:t},p.createElement("td",{style:yt},e.id),p.createElement("td",{style:yt},e.degree),p.createElement("td",{style:yt},e.inDeg),p.createElement("td",{style:yt},e.outDeg),H&&p.createElement("td",{style:yt},ut(e.wDegree)),H&&p.createElement("td",{style:yt},ut(e.wInDeg)),H&&p.createElement("td",{style:yt},ut(e.wOutDeg)))))))}function xt({summary:e}){return e?p.createElement("div",{role:"note",style:st},e):null}function kt({tableId:e}){return p.createElement("a",{href:"#"+e,style:st,onClick:t=>{t.preventDefault();const n=document.getElementById(e);n&&requestAnimationFrame(()=>n.focus())},onFocus:e=>{Object.assign(e.currentTarget.style,{position:"absolute",width:"auto",height:"auto",overflow:"visible",clip:"auto",whiteSpace:"normal",padding:"4px 8px",background:"var(--semiotic-bg, #fff)",color:"var(--semiotic-text, #000)",border:"2px solid var(--semiotic-focus, #005fcc)",borderRadius:"4px",zIndex:"10",fontSize:"12px",top:"4px",left:"4px"})},onBlur:e=>{const t=e.currentTarget;t.removeAttribute("style"),Object.assign(t.style,st)}},"Skip to data table")}function wt({hoverPoint:e}){let t="";if(e){const n=e.data||e;t="object"==typeof n?"Focused on data point: "+Object.entries(n).filter(([,e])=>"object"!=typeof e&&"function"!=typeof e).map(([e,t])=>`${e}: ${t}`).join(", "):"Focused on data point: "+n}return p.createElement("div",{"aria-live":"polite","aria-atomic":"true",style:st},t)}const At="var(--semiotic-focus, #005fcc)";function St({active:e,hoverPoint:t,margin:n,size:o,shape:r="circle",width:i,height:a}){if(!e||!t)return null;const s=t.x+n.left,l=t.y+n.top;let c;if("rect"===r&&null!=i&&null!=a){const e=Math.max(i,4),t=Math.max(a,4);c=p.createElement("rect",{x:s-e/2-3,y:l-t/2-3,width:e+6,height:t+6,rx:3,fill:"none",stroke:At,strokeWidth:2,strokeDasharray:"4,2"})}else c=p.createElement("circle","wedge"===r?{cx:s,cy:l,r:12,fill:"none",stroke:At,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:s,cy:l,r:8,fill:"none",stroke:At,strokeWidth:2,strokeDasharray:"4,2"});return p.createElement("svg",{style:{position:"absolute",left:0,top:0,width:o[0],height:o[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true"},c)}function Ot({x:e,y:t,containerWidth:n,containerHeight:o,margin:r,children:i,className:a="stream-frame-tooltip",zIndex:s=1}){const l=p.useRef(null),[c,u]=p.useState(null);p.useLayoutEffect(()=>{const e=l.current;if(!e)return;const t=e.getBoundingClientRect();u(e=>e&&e.width===t.width&&e.height===t.height?e:{width:t.width,height:t.height})},[i,a,n,o]);let d;return d=c?`translate(${c.width+12>n-e?"calc(-100% - 12px)":"12px"}, ${c.height+12>o-t?"calc(-100% - 4px)":"4px"})`:`translate(${e>.7*n?"calc(-100% - 12px)":"12px"}, ${.3*o>t?"4px":"calc(-100% - 4px)"})`,p.createElement("div",{ref:l,className:a,style:{position:"absolute",left:r.left+e,top:r.top+t,transform:d,pointerEvents:"none",zIndex:s,width:"max-content"}},i)}function Et(e,t){return"function"==typeof e.addEventListener?(e.addEventListener("change",t),()=>e.removeEventListener("change",t)):(e.addListener(t),()=>e.removeListener(t))}function Mt(){const[t,n]=e.useState(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return e.useEffect(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)");return n(e.matches),Et(e,e=>n(e.matches))},[]),t}function jt(t){const n=e.createContext(null),o=Ct(t);return[function({children:o}){const r=e.useMemo(()=>Ct(t),[]);return p.createElement(n.Provider,{value:r,children:o})},t=>{var r;const i=null!==(r=e.useContext(n))&&void 0!==r?r:o,a=e.useRef(t);a.current=t;const s=e.useCallback(()=>a.current(i.getState()),[i]),l=e.useCallback(()=>a.current(i.getState()),[i]);return e.useSyncExternalStore(i.subscribe,s,l)}]}function Ct(e){const t=new EventTarget;let n=e(function(e){n=Object.assign(Object.assign({},n),e(n)),t.dispatchEvent(new CustomEvent("update"))});return{getState:()=>n,subscribe:function(e){return t.addEventListener("update",e),()=>t.removeEventListener("update",e)}}}const Pt={mode:"light",colors:{primary:"#00a2ce",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",background:"transparent",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},Lt={mode:"dark",colors:{primary:"#4fc3f7",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",background:"#1a1a2e",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},_t={mode:"light",colors:{primary:"#0000cc",categorical:["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],sequential:"blues",diverging:"RdBu",background:"#ffffff",text:"#000000",textSecondary:"#333333",grid:"#999999",border:"#000000",focus:"#0000cc",selection:"#0000cc",selectionOpacity:.1},typography:{fontFamily:"system-ui, sans-serif",titleSize:18,labelSize:14,tickSize:12},tooltip:{background:"#000000",text:"#ffffff",borderRadius:"4px",fontSize:"14px",shadow:"0 2px 8px rgba(0, 0, 0, 0.3)"},borderRadius:"4px"},[Bt,Tt]=jt(e=>({theme:Pt,setTheme(t){e(e=>{if("light"===t)return{theme:Pt};if("dark"===t)return{theme:Lt};if("high-contrast"===t)return{theme:_t};if(t.mode&&"auto"!==t.mode){const e="dark"===t.mode?Lt:Pt;return{theme:Object.assign(Object.assign(Object.assign({},e),t),{colors:Object.assign(Object.assign({},e.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.typography),t.typography||{})})}}return{theme:Object.assign(Object.assign(Object.assign({},e.theme),t),{colors:Object.assign(Object.assign({},e.theme.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.theme.typography),t.typography||{})})}})}}));function Nt(e,t,n,o){const r=e.getContext("2d");if(!r)return null;const i=t[0]*o,a=t[1]*o,s=t[0]+"px",l=t[1]+"px";return e.style.width!==s&&(e.style.width=s),e.style.height!==l&&(e.style.height=l),e.width===i&&e.height===a||(e.width=i,e.height=a),r.setTransform(o,0,0,o,0,0),r.translate(n.left,n.top),r}function Dt(){return"undefined"!=typeof window&&window.devicePixelRatio||1}const It=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,Ht=new WeakMap;function Rt(e,t){var n,o;if(!t)return t;const r=It.exec(t);if(!r)return t;const i=e.canvas;if(!i)return(null===(n=r[2])||void 0===n?void 0:n.trim())||t;let a=Ht.get(i);if(a||(a=new Map,Ht.set(i,a)),a.has(t))return a.get(t);const s=getComputedStyle(i).getPropertyValue(r[1]).trim()||(null===(o=r[2])||void 0===o?void 0:o.trim())||t;return a.set(t,s),s}function Wt(e){Ht.delete(e)}function Ft(e){switch(e){case"monotoneX":return l.curveMonotoneX;case"monotoneY":return l.curveMonotoneY;case"cardinal":return l.curveCardinal;case"catmullRom":return l.curveCatmullRom;case"step":return l.curveStep;case"stepBefore":return l.curveStepBefore;case"stepAfter":return l.curveStepAfter;case"basis":return l.curveBasis;case"natural":return l.curveNatural;default:return null}}function zt(e,t,n){let o=n;for(const n of t)"lesser"===n.thresholdType?n.value>e&&(o=n.color):e>n.value&&(o=n.color);return o}function $t(e,t,n,o,r,i){if(2>t.length)return;const a=[0];for(let e=1;t.length>e;e++){const n=t[e][0]-t[e-1][0],o=t[e][1]-t[e-1][1];a.push(a[e-1]+Math.sqrt(n*n+o*o))}const s=a[a.length-1];if(0===s)return;const l=Math.min(.2*s,40);e.strokeStyle=n,e.lineWidth=o,e.lineCap=i;for(let n=0;t.length-1>n;n++){const o=(a[n]+a[n+1])/2;let i=r;l>o&&(i*=o/l),l>s-o&&(i*=(s-o)/l),e.globalAlpha=Math.max(0,i),e.beginPath(),e.moveTo(t[n][0],t[n][1]),e.lineTo(t[n+1][0],t[n+1][1]),e.stroke()}}const Gt=(e,t,n,o)=>{var r,i;const a=t.filter(e=>"line"===e.type);for(const s of a){if(2>s.path.length)continue;const c=s.style.stroke||"#007bff",u=s.style.strokeWidth||2,d=s.colorThresholds,h=s.rawValues;if(e.setLineDash(s.style.strokeDasharray?s.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=s.style.opacity&&(e.globalAlpha=s.style.opacity),e.lineWidth=u,e.lineCap=s.style.strokeLinecap||"butt",s.style._edgeFade){const y=null!==(r=s.style.opacity)&&void 0!==r?r:1;$t(e,s.path,c,u,y,s.style.strokeLinecap||"butt"),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt";continue}const g=Ft(s.curve),f=d&&d.length>0&&h&&h.length===s.path.length,p=s._decayOpacities;if(p&&p.length===s.path.length&&!f){e.strokeStyle=c;const m=null!==(i=s.style.opacity)&&void 0!==i?i:1;for(let v=0;s.path.length-1>v;v++)e.globalAlpha=.5*(p[v]+p[v+1])*m,e.beginPath(),e.moveTo(s.path[v][0],s.path[v][1]),e.lineTo(s.path[v+1][0],s.path[v+1][1]),e.stroke()}else if(f){let b=null,x=null,k=null,w=null,A=!1;function S(t,n,o){e.beginPath(),e.strokeStyle=t,e.moveTo(n,o),A=!0}function O(){A&&(e.stroke(),A=!1)}for(let E=0;s.path.length>E;E++){const[M,j]=s.path[E],C=h[E],P=zt(C,d,c);if(null!==b&&null!==w&&null!==k){if(P===w)e.lineTo(M,j);else{const L=[];for(const _ of d){const B=_.value;(k>B||B>C)&&(B>k||C>B)||k===B||C===B||L.push({t:(B-k)/(C-k)})}L.sort((e,t)=>e.t-t.t);for(const T of L){const N=b+(M-b)*T.t,D=x+(j-x)*T.t,I=zt(k+(C-k)*Math.min(T.t+1e-4,1),d,c);e.lineTo(N,D),O(),S(I,N,D)}e.lineTo(M,j)}b=M,x=j,k=C,w=P}else S(P,M,j),b=M,x=j,k=C,w=P}O()}else{if(e.beginPath(),!s.strokeGradient||2>s.strokeGradient.colorStops.length||2>s.path.length)e.strokeStyle=c;else{const H=e.createLinearGradient(s.path[0][0],0,s.path[s.path.length-1][0],0);for(const R of s.strokeGradient.colorStops)H.addColorStop(Math.max(0,Math.min(1,R.offset)),R.color);e.strokeStyle=H}if(g)l.line().x(e=>e[0]).y(e=>e[1]).curve(g).context(e)(s.path);else{const[W,F]=s.path[0];e.moveTo(W,F);for(let z=1;s.path.length>z;z++)e.lineTo(s.path[z][0],s.path[z][1])}e.stroke()}if(s.style.fill&&s.style.fillOpacity&&s.style.fillOpacity>0){if(e.beginPath(),e.globalAlpha=s.style.fillOpacity,e.fillStyle=("string"==typeof s.style.fill?Rt(e,s.style.fill):s.style.fill)||s.style.fill,g&&!f)l.line().x(e=>e[0]).y(e=>e[1]).curve(g).context(e)(s.path);else{const[G,Y]=s.path[0];e.moveTo(G,Y);for(let q=1;s.path.length>q;q++)e.lineTo(s.path[q][0],s.path[q][1])}const $=s.path[0][0];e.lineTo(s.path[s.path.length-1][0],o.height),e.lineTo($,o.height),e.closePath(),e.fill()}e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt"}};function Yt(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function qt(e,t,n=.3){Yt(t)&&(e.globalAlpha=t._pulseIntensity*n,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h))}function Xt(e,t,n=.6){var o,r,i,a,s;if(!Yt(t))return;const l=null!==(o=t._pulseGlowRadius)&&void 0!==o?o:4,c=t.r+l*t._pulseIntensity,u=null!==(i=null!==(r=t.cx)&&void 0!==r?r:t.x)&&void 0!==i?i:0,d=null!==(s=null!==(a=t.cy)&&void 0!==a?a:t.y)&&void 0!==s?s:0;e.beginPath(),e.arc(u,d,c,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=t._pulseIntensity*n,e.stroke()}function Vt(e,t,n,o=.35){Yt(t)&&(e.globalAlpha=t._pulseIntensity*o,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fill())}function Ut(e){switch(e){case"monotoneX":return l.curveMonotoneX;case"monotoneY":return l.curveMonotoneY;case"cardinal":return l.curveCardinal;case"catmullRom":return l.curveCatmullRom;case"step":return l.curveStep;case"stepBefore":return l.curveStepBefore;case"stepAfter":return l.curveStepAfter;case"basis":return l.curveBasis;case"natural":return l.curveNatural;default:return null}}function Kt(e){if(e.startsWith("#")){const t=4===e.length?e[1]+e[1]+e[2]+e[2]+e[3]+e[3]:e.slice(1,7);return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[78,121,167]}function Qt(e,t){const n=Ut(t.curve);if(!n||2>t.topPath.length||2>t.bottomPath.length){e.beginPath(),e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1]);for(let n=t.bottomPath.length-1;n>=0;n--)e.lineTo(t.bottomPath[n][0],t.bottomPath[n][1]);e.closePath()}else{const o=l.area().x(e=>e[0]).y0((e,n)=>t.bottomPath[n][1]).y1(e=>e[1]).curve(n).context(e);e.beginPath(),o(t.topPath)}}const Zt=(e,t,n,o)=>{var r,i,a;const s=t.filter(e=>"area"===e.type);for(const t of s){if(2>t.topPath.length)continue;const n=t.style.fill||"#4e79a7",o=t._decayOpacities;if(o&&o.length===t.topPath.length){const i=null!==(r=t.style.fillOpacity)&&void 0!==r?r:.7;e.fillStyle=n;for(let n=0;t.topPath.length-1>n;n++)e.globalAlpha=.5*(o[n]+o[n+1])*i,e.beginPath(),e.moveTo(t.topPath[n][0],t.topPath[n][1]),e.lineTo(t.topPath[n+1][0],t.topPath[n+1][1]),e.lineTo(t.bottomPath[n+1][0],t.bottomPath[n+1][1]),e.lineTo(t.bottomPath[n][0],t.bottomPath[n][1]),e.closePath(),e.fill();if(t.style.stroke&&"none"!==t.style.stroke){e.strokeStyle=Rt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);for(let n=0;t.topPath.length-1>n;n++)e.globalAlpha=.5*(o[n]+o[n+1]),e.beginPath(),e.moveTo(t.topPath[n][0],t.topPath[n][1]),e.lineTo(t.topPath[n+1][0],t.topPath[n+1][1]),e.stroke()}e.globalAlpha=1;continue}const s=null!==(i=t.style.opacity)&&void 0!==i?i:1;if(Qt(e,t),t.fillGradient&&("colorStops"in t.fillGradient&&t.fillGradient.colorStops.length>=2||"topOpacity"in t.fillGradient)&&t.fillGradient){let o=1/0;for(const e of t.topPath)o>e[1]&&(o=e[1]);let r=-1/0;for(const e of t.bottomPath)e[1]>r&&(r=e[1]);const i=e.createLinearGradient(0,o,0,r);if("colorStops"in t.fillGradient)for(const e of t.fillGradient.colorStops){const t=Math.max(0,Math.min(1,e.offset));isNaN(t)||i.addColorStop(t,e.color)}else if("topOpacity"in t.fillGradient){const e=Kt("string"==typeof n?n:"#4e79a7");i.addColorStop(0,`rgba(${e[0]},${e[1]},${e[2]},${t.fillGradient.topOpacity})`),i.addColorStop(1,`rgba(${e[0]},${e[1]},${e[2]},${t.fillGradient.bottomOpacity})`)}e.fillStyle=i,e.globalAlpha=s}else{const o=null!==(a=t.style.fillOpacity)&&void 0!==a?a:.7;e.globalAlpha=o*s,e.fillStyle=n}if(e.fill(),t._pulseIntensity&&t._pulseIntensity>0&&(Qt(e,t),Vt(e,t)),t.style.stroke&&"none"!==t.style.stroke){if(e.globalAlpha=s,!t.strokeGradient||2>t.strokeGradient.colorStops.length||2>t.topPath.length)e.strokeStyle=Rt(e,t.style.stroke)||t.style.stroke;else{const n=e.createLinearGradient(t.topPath[0][0],0,t.topPath[t.topPath.length-1][0],0);for(const e of t.strokeGradient.colorStops)n.addColorStop(Math.max(0,Math.min(1,e.offset)),e.color);e.strokeStyle=n}e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);const n=Ut(t.curve);if(e.beginPath(),n)l.line().x(e=>e[0]).y(e=>e[1]).curve(n).context(e)(t.topPath);else{e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1])}e.stroke()}e.globalAlpha=1}},Jt=(e,t,n,o)=>{var r;const i=t.filter(e=>"point"===e.type);if(0!==i.length){e.save();try{for(const t of i){e.beginPath(),e.arc(t.x,t.y,t.r,0,2*Math.PI);const n=null!==(r=t.style.opacity)&&void 0!==r?r:t.style.fillOpacity;null!=n&&(e.globalAlpha=n),e.fillStyle=("string"==typeof t.style.fill?Rt(e,t.style.fill):t.style.fill)||"#4e79a7",e.fill(),t.style.stroke&&(e.strokeStyle=("string"==typeof t.style.stroke?Rt(e,t.style.stroke):t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()),Xt(e,t),e.globalAlpha=1}}finally{e.restore()}}},en=(e,t,n,o)=>{const r=t.filter(e=>"rect"===e.type);for(const t of r)null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.icon?tn(e,t):(e.fillStyle=("string"==typeof t.style.fill?Rt(e,t.style.fill):t.style.fill)||"#007bff",e.fillRect(t.x,t.y,t.w,t.h),t.style.stroke&&(e.strokeStyle=Rt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.strokeRect(t.x,t.y,t.w,t.h))),qt(e,t),e.globalAlpha=1};function tn(e,t){const n=t.style.icon,o=t.style.iconPadding||2,r=Math.min(t.w,t.h)-o;if(0>=r)return;const i=t.h>t.w;if(e.save(),e.beginPath(),e.rect(t.x,t.y,t.w,t.h),e.clip(),i){const i=r+o,a=t.x+(t.w-r)/2;for(let o=t.y+t.h-r;o>=t.y-r;o-=i)e.drawImage(n,a,o,r,r)}else{const i=r+o,a=t.y+(t.h-r)/2;for(let o=t.x;t.x+t.w>o;o+=i)e.drawImage(n,o,a,r,r)}e.restore()}function nn(e){const[t,n,o]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*n+.114*o>128?"#000":"#fff"}function on(e){return Number.isInteger(e)?e+"":100>Math.abs(e)?1>Math.abs(e)?e.toPrecision(3):e.toFixed(1):e.toFixed(0)}const rn=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function an(e){const t=e[1]-e[0],n=3156e7;return 864e5>t?e=>{const t=new Date(e);return`${(t.getUTCHours()+"").padStart(2,"0")}:${(t.getUTCMinutes()+"").padStart(2,"0")}`}:n>t?e=>{const t=new Date(e);return`${rn[t.getUTCMonth()]} ${t.getUTCDate()}`}:5*n>t?e=>{const t=new Date(e);return`${rn[t.getUTCMonth()]} ${t.getUTCFullYear()}`}:e=>new Date(e).getUTCFullYear()+""}const sn={line:[Zt,Gt,Jt],area:[Zt,Jt],stackedarea:[Zt,Jt],scatter:[Jt],bubble:[Jt],heatmap:[(e,t,n,o)=>{const r=t.filter(e=>"heatcell"===e.type);e.save();try{for(const t of r){const n=t.style;if(null!=(null==n?void 0:n.opacity)&&(e.globalAlpha=n.opacity),e.fillStyle=t.fill,e.fillRect(t.x,t.y,t.w,t.h),e.strokeStyle="#fff",e.lineWidth=1,e.strokeRect(t.x,t.y,t.w,t.h),qt(e,t),e.globalAlpha=1,t.showValues&&null!=t.value){if(20>t.w||20>t.h)continue;const n=t.valueFormat?t.valueFormat(t.value):on(t.value),o=Math.max(10,Math.min(16,.3*Math.min(t.w,t.h))),r=t.x+t.w/2,i=t.y+t.h/2;e.fillStyle=nn(t.fill),e.font=o+"px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(n,r,i)}}}finally{e.restore()}}],bar:[en],swarm:[Jt],waterfall:[(e,t,n,o)=>{var r,i,a;en(e,t);const s=t.filter(e=>"rect"===e.type);if(2>s.length)return;const l=s[0].datum,c=null==l?void 0:l._connectorStroke;if(c){e.save(),e.strokeStyle=c,e.lineWidth=null!==(r=null==l?void 0:l._connectorWidth)&&void 0!==r?r:1,e.setLineDash([]);for(let t=0;s.length-1>t;t++){const o=s[t],r=s[t+1];if(!(null===(i=o.datum)||void 0===i?void 0:i.cumEnd)||!(null===(a=r.datum)||void 0===a?void 0:a.baseline))continue;const l=n.y(o.datum.cumEnd),c=o.x+o.w,u=r.x;e.beginPath(),e.moveTo(c,l),e.lineTo(u,l),e.stroke()}e.restore()}}],candlestick:[(e,t,n,o)=>{for(const n of t){if("candlestick"!==n.type)continue;const t=n;e.save();const o=t._decayOpacity;if(null!=o&&1!==o&&(e.globalAlpha=o),e.beginPath(),e.moveTo(t.x,t.highY),e.lineTo(t.x,t.lowY),e.strokeStyle=t.wickColor,e.lineWidth=t.wickWidth,e.stroke(),t.isRange){const n=Math.max(2*t.wickWidth,4);e.fillStyle=t.wickColor,e.beginPath(),e.arc(t.x,t.highY,n,0,2*Math.PI),e.fill(),e.beginPath(),e.arc(t.x,t.lowY,n,0,2*Math.PI),e.fill()}else if(t.bodyWidth>0){const n=Math.min(t.openY,t.closeY),o=Math.abs(t.openY-t.closeY),r=t.isUp?t.upColor:t.downColor;e.fillStyle=r,e.fillRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(o,1)),e.strokeStyle=r,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(o,1))}e.restore()}}],mixed:[Zt,Gt,Jt]},ln={top:20,right:20,bottom:30,left:40},cn={axisStroke:"#ccc",tickText:"#666",crosshair:"rgba(0, 0, 0, 0.25)",hoverFill:"rgba(255, 255, 255, 0.3)",hoverStroke:"rgba(0, 0, 0, 0.4)",pointRing:"white"},un={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,lineHeight:1.5,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function dn({hover:e}){const t=e=>Number.isInteger(e)?e+"":e.toFixed(2);return p.createElement("div",{className:"semiotic-tooltip",style:un},p.createElement("div",{style:{fontWeight:600,marginBottom:2}},t(e.value)),p.createElement("div",{style:{opacity:.7,fontSize:11}},t(e.time)))}const hn=e.forwardRef(function(t,n){var o,r,i,a,s,l,c,u,d,h,g;const{chartType:f,runtimeMode:y,data:m,chunkThreshold:v,chunkSize:k,xAccessor:w,yAccessor:A,colorAccessor:S,sizeAccessor:O,groupAccessor:E,lineDataAccessor:M,curve:j,normalize:C,binSize:P,valueAccessor:L,arrowOfTime:_="right",windowMode:B="sliding",windowSize:T=200,timeAccessor:N,xExtent:D,yExtent:I,extentPadding:H=.1,scalePadding:R,sizeRange:W,size:F=[500,300],responsiveWidth:z,responsiveHeight:$,margin:G,className:Y,background:q,lineStyle:X,pointStyle:V,areaStyle:U,waterfallStyle:K,swarmStyle:Q,barColors:J,colorScheme:ee,boundsAccessor:te,boundsStyle:ne,y0Accessor:oe,gradientFill:ae,lineGradient:se,areaGroups:le,openAccessor:ce,highAccessor:ue,lowAccessor:de,closeAccessor:he,candlestickStyle:me,showAxes:ke=!0,axes:we,xLabel:Ae,yLabel:Se,yLabelRight:Oe,xFormat:Ee,yFormat:Me,tickFormatTime:je,tickFormatValue:Ce,hoverAnnotation:Pe,tooltipContent:Le,customHoverBehavior:_e,customClickBehavior:Be,enableHover:Te,hoverRadius:Ne=30,tooltipMode:De,annotations:Ie,svgAnnotationRules:He,showGrid:Re,legend:We,legendHoverBehavior:Fe,legendClickBehavior:ze,legendHighlightedCategory:$e,legendIsolatedCategories:Ge,legendPosition:Ye,backgroundGraphics:qe,foregroundGraphics:Xe,canvasPreRenderers:Ve,svgPreRenderers:Ue,title:Ke,categoryAccessor:Qe,brush:Je,onBrush:et,decay:rt,pulse:it,transition:at,staleness:st,heatmapAggregation:ct,heatmapXBins:ut,heatmapYBins:dt,showValues:ht,heatmapValueFormat:gt,marginalGraphics:ft,pointIdAccessor:pt,xScaleType:yt,yScaleType:mt,accessibleTable:bt=!0,description:At,summary:Et,linkedCrosshairName:jt,linkedCrosshairSourceId:Ct}=t,Pt=Mt(),Lt=e.useRef(Pt);Lt.current=Pt;const[_t,Bt]=be(F,z,$),It=Object.assign(Object.assign({},ln),G);if(ft){const e=60;ft.top&&e>It.top&&(It.top=e),ft.bottom&&e>It.bottom&&(It.bottom=e),ft.left&&e>It.left&&(It.left=e),ft.right&&e>It.right&&(It.right=e)}const Ht=Bt[0]-It.left-It.right,Rt=Bt[1]-It.top-It.bottom,Ft="function"==typeof Xe?Xe({size:Bt,margin:It}):Xe,zt="function"==typeof qe?qe({size:Bt,margin:It}):qe,$t=null!=Pe?Pe:Te,Gt=e.useRef(null),Yt=e.useRef(null),qt=e.useRef(0),Xt=e.useRef(!1),Vt=Tt(e=>e.theme),[Ut,Kt]=e.useState(0),[Qt,Zt]=e.useState(null),Jt=e.useRef(null),en=e.useRef(null),[tn,nn]=e.useState(null),[on,rn]=e.useState(!1),[un,hn]=e.useState([]),[gn,fn]=e.useState([]),pn=e.useRef(()=>{}),yn="streaming"===y||["bar","swarm","waterfall"].includes(f),mn=e.useMemo(()=>({chartType:f,runtimeMode:yn?"streaming":"bounded",windowSize:T,windowMode:B,arrowOfTime:yn?_:"right",extentPadding:H,scalePadding:R,xAccessor:yn?void 0:w,yAccessor:yn?void 0:A,timeAccessor:yn?N:void 0,valueAccessor:L,colorAccessor:S,sizeAccessor:O,groupAccessor:E||(M?"_lineGroup":void 0),categoryAccessor:Qe,lineDataAccessor:M,xScaleType:yt,yScaleType:mt,xExtent:D,yExtent:I,sizeRange:W,binSize:P,normalize:C,boundsAccessor:te,boundsStyle:ne,y0Accessor:oe,gradientFill:!0===ae?{topOpacity:.8,bottomOpacity:.05}:!1===ae?void 0:ae,areaGroups:le?new Set(le):void 0,lineGradient:se,openAccessor:ce,highAccessor:ue,lowAccessor:de,closeAccessor:he,candlestickStyle:me,lineStyle:X,pointStyle:V,areaStyle:U,swarmStyle:Q,waterfallStyle:K,colorScheme:ee,barColors:J,annotations:Ie,decay:rt,pulse:it,transition:at,staleness:st,heatmapAggregation:ct,heatmapXBins:ut,heatmapYBins:dt,showValues:ht,heatmapValueFormat:gt,pointIdAccessor:pt,curve:j}),[f,T,B,_,H,R,w,A,N,L,yt,mt,S,O,E,Qe,M,D,I,W,P,C,te,ne,oe,ae,se,le,ce,ue,de,he,me,X,V,U,Q,K,ee,J,Ie,rt,it,at,st,ct,ut,dt,ht,gt,yn,pt,j]),vn=e.useRef(null);vn.current||(vn.current=new Z(mn));const bn=e.useCallback(()=>{qt.current||(qt.current=requestAnimationFrame(()=>pn.current()))},[]);e.useEffect(()=>{var e;null===(e=vn.current)||void 0===e||e.updateConfig(mn),Xt.current=!0,bn()},[mn,bn]),e.useEffect(()=>{Gt.current&&Wt(Gt.current),Xt.current=!0,bn()},[Vt,bn]);const xn=e.useRef(null);xn.current||(xn.current=new x(e=>{const t=vn.current;t&&t.ingest(e)&&(Xt.current=!0,bn())},{chunkThreshold:v,chunkSize:k})),e.useEffect(()=>{var e;null===(e=xn.current)||void 0===e||e.updateChunkOptions({chunkThreshold:v,chunkSize:k})},[v,k]);const kn=e.useCallback(e=>{var t;null===(t=xn.current)||void 0===t||t.push(e)},[]),wn=e.useCallback(e=>{var t;null===(t=xn.current)||void 0===t||t.pushMany(e)},[]),An=e.useCallback(()=>{var e,t;null===(e=xn.current)||void 0===e||e.clear(),null===(t=vn.current)||void 0===t||t.clear(),Xt.current=!0,bn()},[bn]);e.useImperativeHandle(n,()=>({push:kn,pushMany:wn,remove:e=>{var t,n,o;null===(t=xn.current)||void 0===t||t.flush();const r=null!==(o=null===(n=vn.current)||void 0===n?void 0:n.remove(e))&&void 0!==o?o:[];return r.length>0&&(Xt.current=!0,bn()),r},update:(e,t)=>{var n,o,r;null===(n=xn.current)||void 0===n||n.flush();const i=null!==(r=null===(o=vn.current)||void 0===o?void 0:o.update(e,t))&&void 0!==r?r:[];return i.length>0&&(Xt.current=!0,bn()),i},clear:An,getData:()=>{var e,t,n;return null===(e=xn.current)||void 0===e||e.flush(),null!==(n=null===(t=vn.current)||void 0===t?void 0:t.getData())&&void 0!==n?n:[]},getScales:()=>{var e,t;return null!==(t=null===(e=vn.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null},getExtents:()=>{var e,t;return null!==(t=null===(e=vn.current)||void 0===e?void 0:e.getExtents())&&void 0!==t?t:null}}),[kn,wn,An,bn]),e.useEffect(()=>{var e,t;if(m){if(M&&m.length>0&&"object"==typeof m[0]&&null!==m[0]){const t="string"==typeof M?M:"coordinates";if(Array.isArray(m[0][t])){const n=[];for(const e of m){const o=e[t];if(Array.isArray(o)){const t=e.label||e.id||e.key;if(null!=t)for(const e of o)n.push(Object.assign(Object.assign({},e),{_lineGroup:t}));else for(const e of o)n.push(e)}}return void(null===(e=xn.current)||void 0===e||e.setBoundedData(n))}}null===(t=xn.current)||void 0===t||t.setBoundedData(m)}},[m,M]);const Sn=e.useRef(()=>{}),On=e.useRef(()=>{});Sn.current=e=>{if(!$t)return;const t=Gt.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-It.left,r=e.clientY-n.top-It.top;if(0>o||o>Ht||0>r||r>Rt)return void(Jt.current&&(Jt.current=null,en.current=null,nn(null),_e&&(_e(null),Xt.current=!0),bn()));const i=vn.current;if(!i||0===i.scene.length)return;const a=re(i.scene,o,r,Ne,i.quadtree);if(!a)return void(Jt.current&&(Jt.current=null,en.current=null,nn(null),_e&&_e(null),bn()));const s=a.datum||{},l=Object.assign(Object.assign({},"object"!=typeof s||null===s||Array.isArray(s)?{}:s),{data:s,time:a.x,value:a.y,x:a.x,y:a.y});if("multi"===De&&i.scene.length>0&&i.scales){const e=function(e,t,n=30){const o=[];for(const r of e)if("line"===r.type){const e=r;if(2>e.path.length)continue;const i=ie(e.path,t,n);if(null===i)continue;const a=ge(e.path,t);o.push({node:r,datum:Array.isArray(e.datum)&&e.datum[a]?e.datum[a]:e.datum,x:e.path[a][0],y:i,group:e.group,color:e.style.stroke})}else if("area"===r.type){const e=r;if(!1===e.interactive)continue;if(2>e.topPath.length)continue;const i=ie(e.topPath,t,n);if(null===i)continue;const a=ge(e.topPath,t);o.push({node:r,datum:Array.isArray(e.datum)&&e.datum[a]?e.datum[a]:e.datum,x:e.topPath[a][0],y:i,group:e.group,color:"string"==typeof e.style.stroke?e.style.stroke:"string"==typeof e.style.fill?e.style.fill:void 0})}return o}(i.scene,a.x,Ne),t=i.scales.y.invert,n=i.scales.x.invert;if(e.length>0){const o=n?n(a.x):a.x;l.xValue=o,l.xPx=a.x,l.allSeries=e.map(e=>({group:e.group||"",value:t?t(e.y):e.y,valuePx:e.y,color:e.color||"#007bff",datum:e.datum}))}}Jt.current=l,en.current=a.node,nn(l),_e&&(_e(l),Xt.current=!0),bn()},On.current=()=>{Jt.current&&(Jt.current=null,en.current=null,nn(null),_e&&(_e(null),Xt.current=!0),bn())},e.useCallback(e=>Sn.current(e),[]);const En=e.useCallback(()=>On.current(),[]),Mn=e.useRef(()=>{});Mn.current=e=>{if(!Be)return;const t=Gt.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-It.left,r=e.clientY-n.top-It.top;if(0>o||o>Ht||0>r||r>Rt)return void Be(null);const i=vn.current;if(!i||0===i.scene.length)return void Be(null);const a=re(i.scene,o,r,Ne,i.quadtree);if(!a)return void Be(null);const s=a.datum||{},l=Object.assign(Object.assign({},"object"!=typeof s||null===s||Array.isArray(s)?{}:s),{data:s,time:a.x,value:a.y,x:a.x,y:a.y});Be(l)};const jn=e.useCallback(e=>Mn.current(e),[]),Cn=e.useRef(-1),Pn=e.useRef(null),Ln=e.useRef(null),_n=e.useCallback(e=>{const t=vn.current;if(!t||0===t.scene.length)return;const n=t.version;let o;if(Ln.current&&Ln.current.version===n)o=Ln.current.graph;else{const e=function(e){var t,n,o,r;const i=[];for(const a of e)switch(a.type){case"point":i.push({x:a.x,y:a.y,datum:a.datum,shape:"circle",group:null!==(t=a.group)&&void 0!==t?t:"_default"});break;case"line":{const e=a,t=Array.isArray(e.datum)?e.datum:[],o=null!==(n=e.group)&&void 0!==n?n:"_default";for(let n=0;e.path.length>n&&t.length>n;n++)i.push({x:e.path[n][0],y:e.path[n][1],datum:t[n],shape:"circle",group:o});break}case"area":{const e=a,t=Array.isArray(e.datum)?e.datum:[],n=null!==(o=e.group)&&void 0!==o?o:"_default";for(let o=0;e.topPath.length>o&&t.length>o;o++)i.push({x:e.topPath[o][0],y:e.topPath[o][1],datum:t[o],shape:"circle",group:n});break}case"rect":i.push({x:a.x+a.w/2,y:a.y+a.h/2,datum:a.datum,shape:"rect",w:a.w,h:a.h,group:null!==(r=a.group)&&void 0!==r?r:"_default"});break;case"heatcell":i.push({x:a.x+a.w/2,y:a.y+a.h/2,datum:a.datum,shape:"rect",w:a.w,h:a.h,group:"_default"})}return i.sort((e,t)=>e.x-t.x||e.y-t.y),i}(t.scene);if(0===e.length)return;o=fe(e),Ln.current={version:n,graph:o}}const r=Cn.current;if(0>r){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(e.key))return;e.preventDefault(),Cn.current=0;const t=o.flat[0];Pn.current={shape:t.shape,w:t.w,h:t.h};const n=ve(t);return Jt.current=n,nn(n),_e&&_e(n),void bn()}const i=pe(o,r),a=ye(e.key,i,o);if(null===a)return;if(e.preventDefault(),0>a)return Cn.current=-1,Pn.current=null,Jt.current=null,en.current=null,nn(null),_e&&_e(null),void bn();Cn.current=a;const s=o.flat[a];Pn.current={shape:s.shape,w:s.w,h:s.h};const l=ve(s);Jt.current=l,nn(l),_e&&_e(l),bn()},[_e,bn]),Bn=e.useCallback(e=>{Cn.current=-1,Pn.current=null,Sn.current(e)},[]);pn.current=()=>{var e,t;qt.current=0;const n=Gt.current,o=Yt.current;if(!n||!o)return;const r=vn.current;if(!r)return;const i="undefined"!=typeof performance?performance.now():Date.now(),a=r.advanceTransition(Lt.current?i+1e6:i),s=!Lt.current&&a,l=Xt.current||a;l&&!s&&r.computeScene({width:Ht,height:Rt});const c=Dt(),u=function(e){if(!e)return cn;const t=getComputedStyle(e),n=t.getPropertyValue("--semiotic-border").trim(),o=t.getPropertyValue("--semiotic-text-secondary").trim(),r=t.getPropertyValue("--semiotic-bg").trim(),i=o||t.getPropertyValue("--text-secondary").trim(),a=t.getPropertyValue("--text-primary").trim(),s=n||t.getPropertyValue("--surface-3").trim(),l=r||t.getPropertyValue("--surface-0").trim();return i||a||n?{axisStroke:s||cn.axisStroke,tickText:i||cn.tickText,crosshair:i?i+"66":cn.crosshair,hoverFill:l?l+"4D":cn.hoverFill,hoverStroke:i?i+"99":cn.hoverStroke,pointRing:l||cn.pointRing}:cn}(n),d=null!==(e=null==st?void 0:st.threshold)&&void 0!==e?e:5e3,h=st&&r.lastIngestTime>0&&i-r.lastIngestTime>d;if(l){const e=Nt(n,Bt,It,c);if(e){e.clearRect(-It.left,-It.top,Bt[0],Bt[1]),h&&(e.globalAlpha=null!==(t=null==st?void 0:st.dimOpacity)&&void 0!==t?t:.5);const o=getComputedStyle(n).getPropertyValue("--semiotic-bg").trim(),i=q||(o&&"transparent"!==o?o:null);if(i&&(e.fillStyle=i,e.fillRect(-It.left,-It.top,Bt[0],Bt[1])),e.save(),"function"==typeof e.rect&&(e.beginPath(),e.rect(0,0,Ht,Rt),e.clip()),Ve&&r.scales)for(const t of Ve)e.save(),t(e,r.scene,r.scales,{width:Ht,height:Rt}),e.restore();const a=sn[f];if(a&&r.scales)for(const t of a)t(e,r.scene,r.scales,{width:Ht,height:Rt});e.restore(),h&&(e.globalAlpha=1)}}{const e=Nt(o,Bt,It,c);if(e&&(e.clearRect(-It.left,-It.top,Bt[0],Bt[1]),$t&&Jt.current&&r.scales&&function(e,t,n,o,r,i,a){var s,l;if(!1===r.crosshair)return;const c=t.allSeries,u=c&&c.length>0,d=null!==(s=t.xPx)&&void 0!==s?s:t.x;e.save();const h="object"==typeof r.crosshair?r.crosshair:{};if(e.strokeStyle=h.stroke||a.crosshair,e.lineWidth=h.strokeWidth||1,e.setLineDash(h.strokeDasharray?h.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),e.beginPath(),e.moveTo(u?d:t.x,0),e.lineTo(u?d:t.x,o),e.stroke(),u||(e.beginPath(),e.moveTo(0,t.y),e.lineTo(n,t.y),e.stroke()),e.restore(),u){e.lineWidth=2,e.strokeStyle=a.pointRing;for(const t of c)null!=t.valuePx&&(e.beginPath(),e.arc(d,t.valuePx,4,0,2*Math.PI),e.fillStyle=t.color||"#007bff",e.fill(),e.stroke())}else{let n="";try{(null===(l=e.canvas)||void 0===l?void 0:l.parentElement)&&(n=getComputedStyle(e.canvas).getPropertyValue("--semiotic-primary").trim())}catch(e){}const o=r.pointColor||function(e){if(!e)return null;if("heatcell"===e.type)return e.fill||null;if("candlestick"===e.type)return e.isUp?e.upColor:e.downColor;const{style:t}=e;if(!t)return null;const n="string"==typeof t.fill?t.fill:null;return"line"===e.type||"area"===e.type?t.stroke||n||null:n||t.stroke||null}(i)||n||"#007bff";e.beginPath(),e.arc(t.x,t.y,4,0,2*Math.PI),e.fillStyle=o,e.fill(),e.strokeStyle=a.pointRing,e.lineWidth=2,e.stroke()}}(e,Jt.current,Ht,Rt,"object"==typeof $t?$t:{},en.current,u),en.current&&Array.isArray(Pe))){const t=Pe.find(e=>e&&"object"==typeof e&&"highlight"===e.type);t&&function(e,t,n,o){var r;if(!n)return;const i=n.group;if(void 0!==i)for(const n of t){if("line"!==n.type)continue;if(n.group!==i)continue;if(2>n.path.length)continue;const t="function"==typeof o.style?o.style(n.datum):o.style||{};e.save(),e.beginPath(),e.moveTo(n.path[0][0],n.path[0][1]);for(let t=1;n.path.length>t;t++)e.lineTo(n.path[t][0],n.path[t][1]);e.strokeStyle=t.stroke||n.style.stroke||"#007bff",e.lineWidth=t.strokeWidth||(n.style.strokeWidth||2)+2,e.globalAlpha=null!==(r=t.opacity)&&void 0!==r?r:1,e.stroke(),e.restore()}}(e,r.scene,en.current,t)}}l&&n&&n.setAttribute("aria-label",lt(r.scene,f+" chart"));const g=Xt.current;if(Xt.current=!1,g&&r.scales){const e=e=>"object"==typeof e&&null!==e&&"function"==typeof e.valueOf?e.valueOf():e;if((!Qt||e(Qt.x.domain()[0])!==e(r.scales.x.domain()[0])||e(Qt.x.domain()[1])!==e(r.scales.x.domain()[1])||e(Qt.y.domain()[0])!==e(r.scales.y.domain()[0])||e(Qt.y.domain()[1])!==e(r.scales.y.domain()[1])||Qt.x.range()[0]!==r.scales.x.range()[0]||Qt.x.range()[1]!==r.scales.x.range()[1]||Qt.y.range()[0]!==r.scales.y.range()[0]||Qt.y.range()[1]!==r.scales.y.range()[1])&&Zt(r.scales),ft){const e=r.getData(),t="function"==typeof w?w:e=>e[w||"x"],n="function"==typeof A?A:e=>e[A||"y"];hn(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),fn(e.map(e=>n(e)).filter(e=>"number"==typeof e&&isFinite(e)))}}g&&Ie&&Ie.length>0&&Kt(e=>e+1),(null==st?void 0:st.showBadge)&&rn(!!h),(s||r.hasActivePulses)&&(qt.current=requestAnimationFrame(()=>pn.current()))},e.useEffect(()=>(bn(),()=>{qt.current&&(cancelAnimationFrame(qt.current),qt.current=0)}),[bn]),e.useEffect(()=>{Xt.current=!0,bn()},[f,Ht,Rt,ke,q,X,Ve,bn]),xe(st,vn,Xt,bn,on,rn);const Tn=e.useMemo(()=>{if(Ee||je)return;const e=vn.current;return(null==e?void 0:e.xIsDate)&&Qt?an(Qt.x.domain()):void 0},[Ee,je,Qt]),Nn=Ee||je||Tn,Dn=$t&&tn?Le?Le(tn):p.createElement(dn,{hover:tn}):null,In=Dn?p.createElement(Ot,{x:tn.x,y:tn.y,containerWidth:Ht,containerHeight:Rt,margin:It,className:"stream-frame-tooltip"},Dn):null,Hn=Pn.current,Rn=p.createElement(St,{active:Cn.current>=0,hoverPoint:tn,margin:It,size:Bt,shape:null==Hn?void 0:Hn.shape,width:null==Hn?void 0:Hn.w,height:null==Hn?void 0:Hn.h}),Wn=(e,t,n,o)=>"string"==typeof e?{key:e,fn:null}:"function"==typeof e?{key:n,fn:e}:"string"==typeof t?{key:t,fn:null}:"function"==typeof t?{key:o,fn:t}:{key:void 0,fn:null},Fn=Wn(w,N,"__semiotic_resolvedX","__semiotic_resolvedTime"),zn=Wn(A,L,"__semiotic_resolvedY","__semiotic_resolvedValue"),$n=Fn.key,Gn=zn.key,Yn=Ie&&Ie.length>0,qn=e=>{if(!e||!Yn||!Fn.fn&&!zn.fn)return e;let t=!1;const n=e.map(e=>{const n=Fn.fn&&Fn.key&&!(Fn.key in e),o=zn.fn&&zn.key&&!(zn.key in e);if(!n&&!o)return e;t=!0;const r=Object.assign({},e);return n&&(r[Fn.key]=Fn.fn(e)),o&&(r[zn.key]=zn.fn(e)),r});return t?n:e};if(ot){const e=vn.current;e&&m&&(e.ingest({inserts:m,bounded:!0}),e.computeScene({width:Ht,height:Rt}));const t=null!==(o=null==e?void 0:e.scene)&&void 0!==o?o:[],n=null!==(r=null==e?void 0:e.scales)&&void 0!==r?r:null,i=Nn||(()=>{if((null==e?void 0:e.xIsDate)&&n)return an(n.x.domain())})();return p.createElement("div",{className:"stream-xy-frame"+(Y?" "+Y:""),role:"img","aria-label":At||("string"==typeof Ke?Ke:"XY chart"),style:{position:"relative",width:Bt[0],height:Bt[1]}},p.createElement(xt,{summary:Et}),p.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:Bt[0],height:Bt[1],style:{position:"absolute",left:0,top:0}},p.createElement("g",{transform:`translate(${It.left},${It.top})`},zt),p.createElement("g",{transform:`translate(${It.left},${It.top})`},q&&p.createElement("rect",{x:0,y:0,width:Ht,height:Rt,fill:q}),Ue&&n&&Ue.map((e,o)=>p.createElement(p.Fragment,{key:"svgpre-"+o},e(t,n,{width:Ht,height:Rt}))),t.map((e,t)=>function(e,t){var n,o,r;switch(e.type){case"line":{const n=e;if(0===n.path.length)return null;const o="M"+n.path.map(([e,t])=>`${e},${t}`).join("L");return p.createElement("path",{key:"line-"+t,d:o,fill:"none",stroke:n.style.stroke||"#4e79a7",strokeWidth:n.style.strokeWidth||2,strokeDasharray:n.style.strokeDasharray,opacity:n.style.opacity})}case"area":{const r=e;if(0===r.topPath.length)return null;const i=r.topPath.map(([e,t])=>`${e},${t}`).join("L"),a=[...r.bottomPath].reverse().map(([e,t])=>`${e},${t}`).join("L");return p.createElement("path",{key:"area-"+t,d:`M${i}L${a}Z`,fill:nt(r.style.fill),fillOpacity:null!==(o=null!==(n=r.style.fillOpacity)&&void 0!==n?n:r.style.opacity)&&void 0!==o?o:.7,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})}case"point":{const n=e;return p.createElement("circle",{key:"point-"+t,cx:n.x,cy:n.y,r:n.r,fill:nt(n.style.fill),opacity:null!==(r=n.style.opacity)&&void 0!==r?r:.8,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth})}case"rect":{const n=e;return p.createElement("rect",{key:"rect-"+t,x:n.x,y:n.y,width:n.w,height:n.h,fill:nt(n.style.fill),opacity:n.style.opacity,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth})}case"heatcell":{const n=e;if(n.showValues&&null!=n.value&&n.w>=20&&n.h>=20){const e=n.valueFormat?n.valueFormat(n.value):Number.isInteger(n.value)?n.value+"":100>Math.abs(n.value)?1>Math.abs(n.value)?n.value.toPrecision(3):n.value.toFixed(1):n.value.toFixed(0),[o,r,i]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(n.fill),a=.299*o+.587*r+.114*i>128?"#000":"#fff",s=Math.max(10,Math.min(16,.3*Math.min(n.w,n.h)));return p.createElement("g",{key:"heatcell-"+t},p.createElement("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill}),p.createElement("text",{x:n.x+n.w/2,y:n.y+n.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:a,fontSize:s+"px"},e))}return p.createElement("rect",{key:"heatcell-"+t,x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill})}case"candlestick":{const n=e,o=Math.min(n.openY,n.closeY),r=Math.max(Math.abs(n.openY-n.closeY),1),i=n.isUp?n.upColor:n.downColor;return p.createElement("g",{key:"candle-"+t},p.createElement("line",{x1:n.x,y1:n.highY,x2:n.x,y2:n.lowY,stroke:n.wickColor,strokeWidth:n.wickWidth}),p.createElement("rect",{x:n.x-n.bodyWidth/2,y:o,width:n.bodyWidth,height:r,fill:i,stroke:i,strokeWidth:1}))}default:return null}}(e,t)).filter(Boolean))),p.createElement(tt,{width:Ht,height:Rt,totalWidth:Bt[0],totalHeight:Bt[1],margin:It,scales:n,showAxes:ke,axes:we,xLabel:Ae,yLabel:Se,yLabelRight:Oe,xFormat:i,yFormat:Me||Ce,showGrid:Re,title:Ke,legend:We,legendHoverBehavior:Fe,legendClickBehavior:ze,legendHighlightedCategory:$e,legendIsolatedCategories:Ge,legendPosition:Ye,foregroundGraphics:Ft,marginalGraphics:ft,xValues:[],yValues:[],annotations:Ie,svgAnnotationRules:He,annotationFrame:0,xAccessor:$n,yAccessor:Gn,annotationData:qn(null==e?void 0:e.getData()),pointNodes:null==e?void 0:e.scene.filter(e=>"point"===e.type),curve:"string"==typeof j?j:void 0,linkedCrosshairName:jt,linkedCrosshairSourceId:Ct}))}const Xn="semiotic-table-"+p.useId();return p.createElement("div",{ref:_t,className:"stream-xy-frame"+(Y?" "+Y:""),role:"group","aria-label":At||("string"==typeof Ke?Ke:"XY chart"),tabIndex:0,style:{position:"relative",width:z?"100%":Bt[0],height:$?"100%":Bt[1],overflow:"visible"},onKeyDown:_n},bt&&p.createElement(kt,{tableId:Xn}),bt&&p.createElement(vt,{scene:null!==(a=null===(i=vn.current)||void 0===i?void 0:i.scene)&&void 0!==a?a:[],chartType:f+" chart",tableId:Xn,chartTitle:"string"==typeof Ke?Ke:void 0}),p.createElement(xt,{summary:Et}),p.createElement("div",{role:"img","aria-label":At||("string"==typeof Ke?Ke:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:$t?Bn:void 0,onMouseLeave:$t?En:void 0,onClick:Be?jn:void 0},zt&&p.createElement("svg",{style:{position:"absolute",left:0,top:0,width:Bt[0],height:Bt[1],pointerEvents:"none"}},p.createElement("g",{transform:`translate(${It.left},${It.top})`},zt)),p.createElement(Ze,{width:Ht,height:Rt,totalWidth:Bt[0],totalHeight:Bt[1],margin:It,scales:Qt,showAxes:ke,axes:we,showGrid:Re,xFormat:Nn,yFormat:Me||Ce}),p.createElement("canvas",{ref:Gt,"aria-label":lt(null!==(l=null===(s=vn.current)||void 0===s?void 0:s.scene)&&void 0!==l?l:[],f+" chart"),style:{position:"absolute",left:0,top:0}}),p.createElement("canvas",{ref:Yt,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),p.createElement(wt,{hoverPoint:tn}),p.createElement(tt,{width:Ht,height:Rt,totalWidth:Bt[0],totalHeight:Bt[1],margin:It,scales:Qt,showAxes:ke,axes:we,xLabel:Ae,yLabel:Se,yLabelRight:Oe,xFormat:Nn,yFormat:Me||Ce,showGrid:Re,title:Ke,legend:We,legendHoverBehavior:Fe,legendClickBehavior:ze,legendHighlightedCategory:$e,legendIsolatedCategories:Ge,legendPosition:Ye,foregroundGraphics:Ft,marginalGraphics:ft,xValues:un,yValues:gn,annotations:Ie,svgAnnotationRules:He,annotationFrame:Ut,xAccessor:$n,yAccessor:Gn,annotationData:qn(null===(c=vn.current)||void 0===c?void 0:c.getData()),pointNodes:null===(u=vn.current)||void 0===u?void 0:u.scene.filter(e=>"point"===e.type),curve:"string"==typeof j?j:void 0,underlayRendered:!0,linkedCrosshairName:jt,linkedCrosshairSourceId:Ct}),(Je||et)&&p.createElement(b,{width:Ht,height:Rt,totalWidth:Bt[0],totalHeight:Bt[1],margin:It,dimension:null!==(d=null==Je?void 0:Je.dimension)&&void 0!==d?d:"xy",scales:Qt,onBrush:null!=et?et:()=>{},binSize:P,snap:null==Je?void 0:Je.snap,binBoundaries:null!==(h=null==Je?void 0:Je.binBoundaries)&&void 0!==h?h:"bar"===f?null===(g=vn.current)||void 0===g?void 0:g.getBinBoundaries():void 0,snapDuring:null==Je?void 0:Je.snapDuring,streaming:"streaming"===y}),(null==st?void 0:st.showBadge)&&p.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===st.badgePosition?{top:4,left:4}:"bottom-left"===st.badgePosition?{bottom:4,left:4}:"bottom-right"===st.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:on?"#dc3545":"#28a745",color:"white"})},on?"STALE":"LIVE"),Rn,In))});hn.displayName="StreamXYFrame";const gn=e.createContext(null);function fn({colors:t,categories:n,colorScheme:o="category10",children:r}){const i=e.useMemo(()=>{if(t)return t;if(n){const e=Array.isArray(o)?o:j[o]||C,t={};for(let o=0;n.length>o;o++)t[n[o]]=e[o%e.length];return t}return{}},[t,n,o]);return p.createElement(gn.Provider,{value:i},r)}function pn(){return e.useContext(gn)}function yn(e){const t=[];for(const[n,o]of Object.entries(e.fields))if("point"===o.type)t.push(e=>o.values.has(e[n]));else{const[e,r]=o.range;t.push(t=>{const o=t[n];return o>=e&&r>=o})}return e=>t.every(t=>t(e))}function mn(e,t){const n=[];for(const[o,r]of e.clauses)"crossfilter"===e.resolution&&o===t||n.push(yn(r));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}function vn(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}fn.displayName="CategoryColorProvider";const[bn,xn]=jt(e=>({selections:new Map,setClause(t,n){e(e=>{const o=new Map(e.selections),r=vn(o,t),i=new Map(r.clauses);return i.set(n.clientId,n),o.set(t,Object.assign(Object.assign({},r),{clauses:i})),{selections:o}})},clearClause(t,n){e(e=>{const o=e.selections.get(t);if(!o)return{};const r=new Map(e.selections),i=new Map(o.clauses);return i.delete(n),r.set(t,Object.assign(Object.assign({},o),{clauses:i})),{selections:r}})},setResolution(t,n){e(e=>{const o=new Map(e.selections),r=vn(o,t);return o.set(t,Object.assign(Object.assign({},r),{resolution:n})),{selections:o}})},clearSelection(t){e(e=>{const n=new Map(e.selections),o=n.get(t);return o&&n.set(t,Object.assign(Object.assign({},o),{clauses:new Map})),{selections:n}})}})),[kn,wn]=jt(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const n=e.observations;return n.push(t),n.length>e.maxObservations&&n.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}}));function An(t){const n=e.useId(),o=t.clientId||n,{name:r}=t,i=xn(e=>e.selections.get(r)),a=xn(e=>e.setClause),s=xn(e=>e.clearClause),l=e.useMemo(()=>!!i&&i.clauses.size>0,[i]);return{predicate:e.useMemo(()=>i&&0!==i.clauses.size?mn(i,o):()=>!0,[i,o]),isActive:l,selectPoints:e.useCallback(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"point",values:new Set(o)};a(r,{clientId:o,type:"point",fields:t})},[o,r,a]),selectInterval:e.useCallback(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"interval",range:o};a(r,{clientId:o,type:"interval",fields:t})},[o,r,a]),clear:e.useCallback(()=>{s(r,o)},[s,r,o]),clientId:o}}function Sn(t){const n=t.name||"hover",{fields:o}=t,{predicate:r,isActive:i,selectPoints:a,clear:s}=An({name:n});return{onHover:e.useCallback(e=>{if(!e)return void s();const t={};for(const n of o){const o=e[n];void 0!==o&&(t[n]=[o])}Object.keys(t).length>0&&a(t)},[o,a,s,n]),predicate:r,isActive:i}}function On(t){const{name:n,xField:o,yField:r}=t,{predicate:i,isActive:a,selectInterval:s,clear:l}=An({name:n}),c=o&&r?"xyBrush":o?"xBrush":"yBrush",u=e.useCallback(e=>{if(!e)return void l();const t={};"xyBrush"===c&&Array.isArray(e)&&2===e.length?(o&&(t[o]=[Math.min(e[0][0],e[1][0]),Math.max(e[0][0],e[1][0])]),r&&(t[r]=[Math.min(e[0][1],e[1][1]),Math.max(e[0][1],e[1][1])])):"xBrush"===c&&Array.isArray(e)?o&&(t[o]=[Math.min(...e),Math.max(...e)]):"yBrush"===c&&Array.isArray(e)&&r&&(t[r]=[Math.min(...e),Math.max(...e)]),Object.keys(t).length>0&&s(t)},[c,o,r,s,l]);return{brushInteraction:e.useMemo(()=>({brush:c,during:u,end:u}),[c,u]),predicate:i,isActive:a,clear:l}}function En(t={}){const{limit:n=50,types:o,chartId:r}=t,i=wn(e=>e.version),a=wn(e=>e.observations),s=wn(e=>e.clearObservations),l=e.useMemo(()=>{let e=a;if(o&&o.length>0){const t=new Set(o);e=e.filter(e=>t.has(e.type))}return r&&(e=e.filter(e=>e.chartId===r)),e.length>n&&(e=e.slice(e.length-n)),e},[a,o,r,n,i]);return{observations:l,latest:l.length>0?l[l.length-1]:null,clear:s}}const Mn=e.createContext(!1);function jn({selections:t}){const n=xn(e=>e.setResolution);return e.useEffect(()=>{for(const[e,o]of Object.entries(t))o.resolution&&n(e,o.resolution)},[t,n]),null}function Cn({categoryColors:t,interaction:n,selectionName:o,field:r}){const i=Object.entries(t);if(0===i.length)return null;const a=i.map(([e])=>e),s=[{styleFn:e=>({fill:e.color||"#333",stroke:e.color||"#333"}),type:"fill",items:i.map(([e,t])=>({label:e,color:t})),label:""}],l=Sn({name:o,fields:[r]}),c=An({name:o,clientId:"__linked-legend-isolate__"}),[u,d]=e.useState(new Set),[h,g]=e.useState(null),f=e.useRef(c.selectPoints);f.current=c.selectPoints;const y=e.useRef(c.clear);y.current=c.clear,e.useEffect(()=>{"isolate"===n&&(u.size>0?f.current({[r]:Array.from(u)}):y.current())},[n,u,r]);const m=e.useCallback(e=>{"highlight"===n&&(e?(g(e.label),l.onHover({[r]:e.label})):(g(null),l.onHover(null)))},[n,r,l]),v=e.useCallback(e=>{"isolate"===n&&d(t=>{const n=new Set(t);return n.has(e.label)?n.delete(e.label):n.add(e.label),n.size===a.length?new Set:n})},[n,a.length]);return p.createElement("svg",{width:"100%",height:30,style:{display:"block",overflow:"visible"}},p.createElement(Ee,{legendGroups:s,title:!1,orientation:"horizontal",height:20,customHoverBehavior:"highlight"===n?m:void 0,customClickBehavior:"isolate"===n?v:void 0,highlightedCategory:h,isolatedCategories:u}))}function Pn({children:e,selections:t,showLegend:n,legendPosition:o="top",legendInteraction:r="none",legendSelectionName:i="legend",legendField:a="category"}){const s=pn(),l=void 0!==n?n:!(!s||0>=Object.keys(s).length);return p.createElement(bn,null,p.createElement(kn,null,t&&p.createElement(jn,{selections:t}),p.createElement(Mn.Provider,{value:l},l&&"top"===o&&s&&p.createElement(Cn,{categoryColors:s,interaction:r,selectionName:i,field:a}),e,l&&"bottom"===o&&s&&p.createElement(Cn,{categoryColors:s,interaction:r,selectionName:i,field:a}))))}function Ln({data:e,colorBy:t,colorScale:n,getColor:o,strokeColor:r,strokeWidth:i,categories:a}){const s=(a&&a.length>0?a:Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t])))).map((r,i)=>{const a=e.find("function"==typeof t?e=>t(e)===r:e=>e[t]===r),s=a?o(a,t,n):n?n(r):P[i%P.length];return{label:r+"",color:s}});return{legendGroups:[{styleFn:e=>{const t=e.color||"#333",n={fill:t,stroke:t};return void 0!==r&&(n.stroke=r),void 0!==i&&(n.strokeWidth=i),n},type:"fill",items:s,label:""}]}}function _n(e){return e?"string"==typeof e?{name:e}:e:null}function Bn(e,t,n){return t?o=>{var r;const i=Object.assign({},e(o));if(t.isActive)if(t.predicate(o))(null==n?void 0:n.selectedStyle)&&Object.assign(i,n.selectedStyle);else{const e=null!==(r=null==n?void 0:n.unselectedOpacity)&&void 0!==r?r:.2;i.opacity=e,i.fillOpacity=e,i.strokeOpacity=e,(null==n?void 0:n.unselectedStyle)&&Object.assign(i,n.unselectedStyle)}return i}:e}const Tn={light:Pt,dark:Lt,"high-contrast":_t,pastels:{mode:"light",colors:{primary:"#c9a0dc",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#fdf6f0",text:"#4a3728",textSecondary:"#8b7355",grid:"#e8d5c4",border:"#e8d5c4",focus:"#c9a0dc"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#fff5ee",text:"#4a3728",borderRadius:"8px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"10px"},"pastels-dark":{mode:"dark",colors:{primary:"#c9a0dc",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#1a1525",text:"#e8ddf0",textSecondary:"#a899c0",grid:"#3d3455",border:"#3d3455",focus:"#c9a0dc"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#251e35",text:"#e8ddf0",borderRadius:"8px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"10px"},"bi-tool":{mode:"light",colors:{primary:"#2563eb",categorical:["#2563eb","#0d9488","#ea580c","#6b7280"],sequential:"blues",background:"#f5f6f8",text:"#2c3e50",textSecondary:"#7f8c9b",grid:"#d8dce3",border:"#d8dce3",focus:"#2563eb"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#2c3e50",borderRadius:"6px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"8px"},"bi-tool-dark":{mode:"dark",colors:{primary:"#3b82f6",categorical:["#3b82f6","#14b8a6","#f97316","#9ca3af"],sequential:"blues",background:"#111827",text:"#f3f4f6",textSecondary:"#9ca3af",grid:"#374151",border:"#374151",focus:"#3b82f6"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1f2937",text:"#f3f4f6",borderRadius:"6px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"8px"},italian:{mode:"light",colors:{primary:"#cc0000",categorical:["#cc0000","#333333","#c8a415","#4682b4"],sequential:"reds",background:"#fafafa",text:"#1a1a1a",textSecondary:"#666666",grid:"#e0e0e0",border:"#e0e0e0",focus:"#cc0000"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#1a1a1a",borderRadius:"2px",shadow:"0 2px 4px rgba(0, 0, 0, 0.15)"},borderRadius:"2px"},"italian-dark":{mode:"dark",colors:{primary:"#ff3333",categorical:["#ff3333","#aaaaaa","#d4a843","#6aa4d4"],sequential:"reds",background:"#0a0a0a",text:"#f5f5f5",textSecondary:"#aaaaaa",grid:"#333333",border:"#333333",focus:"#ff3333"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1a1a1a",text:"#f5f5f5",borderRadius:"2px",shadow:"0 2px 8px rgba(0, 0, 0, 0.5)"},borderRadius:"2px"},tufte:{mode:"light",colors:{primary:"#8b0000",categorical:["#8b4513","#556b2f","#4a5568","#800020"],sequential:"oranges",background:"#fffff8",text:"#111111",textSecondary:"#555555",grid:"#e0ddd0",border:"#e0ddd0",focus:"#8b0000"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#fffff8",text:"#111111",borderRadius:"2px",shadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},borderRadius:"0px"},"tufte-dark":{mode:"dark",colors:{primary:"#c05050",categorical:["#c08050","#7a8b5a","#8090a0","#a05060"],sequential:"oranges",background:"#1c1b18",text:"#e8e4d8",textSecondary:"#a09880",grid:"#3d3c35",border:"#3d3c35",focus:"#c05050"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#262520",text:"#e8e4d8",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.4)"},borderRadius:"0px"},journalist:{mode:"light",colors:{primary:"#e45050",categorical:["#3a86c8","#e45050","#d4a843","#888888"],sequential:"blues",background:"#ffffff",text:"#222222",textSecondary:"#666666",grid:"#d4d4d4",border:"#d4d4d4",focus:"#e45050"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#f8f8f8",text:"#222222",borderRadius:"4px",shadow:"0 2px 6px rgba(0, 0, 0, 0.12)"},borderRadius:"4px"},"journalist-dark":{mode:"dark",colors:{primary:"#ff6b6b",categorical:["#5a9fd8","#ff6b6b","#e0c060","#aaaaaa"],sequential:"blues",background:"#141414",text:"#ededed",textSecondary:"#a0a0a0",grid:"#383838",border:"#383838",focus:"#ff6b6b"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1e1e1e",text:"#ededed",borderRadius:"4px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"4px"},playful:{mode:"light",colors:{primary:"#8b5cf6",categorical:["#8b5cf6","#ec4899","#06b6d4","#84cc16"],sequential:"viridis",background:"#fdf8ff",text:"#2d1b4e",textSecondary:"#7c5a9e",grid:"#e8d0f8",border:"#e8d0f8",focus:"#8b5cf6"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#2d1b4e",borderRadius:"12px",shadow:"0 4px 12px rgba(139, 92, 246, 0.15)"},borderRadius:"12px"},"playful-dark":{mode:"dark",colors:{primary:"#a78bfa",categorical:["#a78bfa","#f472b6","#22d3ee","#a3e635"],sequential:"viridis",background:"#150a28",text:"#f0e8ff",textSecondary:"#b8a0d8",grid:"#3a2560",border:"#3a2560",focus:"#a78bfa"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1f1138",text:"#f0e8ff",borderRadius:"12px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"12px"},carbon:{mode:"light",colors:{primary:"#0f62fe",categorical:["#6929c4","#1192e8","#005d5d","#9f1853"],sequential:"blues",diverging:"RdBu",background:"#ffffff",text:"#161616",textSecondary:"#525252",grid:"#e0e0e0",border:"#e0e0e0",focus:"#0f62fe"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#161616",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.2)"},borderRadius:"0px"},"carbon-dark":{mode:"dark",colors:{primary:"#4589ff",categorical:["#a56eff","#33b1ff","#08bdba","#ff7eb6"],sequential:"blues",diverging:"RdBu",background:"#161616",text:"#f4f4f4",textSecondary:"#a8a8a8",grid:"#393939",border:"#393939",focus:"#4589ff"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#262626",text:"#f4f4f4",borderRadius:"2px",shadow:"0 4px 12px rgba(0, 0, 0, 0.5)"},borderRadius:"0px"}};function Nn(e){return Tn[e]}const Dn=p.createContext(void 0);function In({theme:e}){const t=Tt(e=>e.setTheme),n=Tt(e=>e.theme),o=p.useRef(n);o.current=n;const r=p.useRef(null);return p.useEffect(()=>{if(void 0!==e)return;if("undefined"==typeof window||!window.matchMedia)return;const n=window.matchMedia("(forced-colors: active)");return n.matches&&(r.current=o.current,t(_t)),Et(n,e=>{var n;e.matches?(r.current=o.current,t(_t)):(t(null!==(n=r.current)&&void 0!==n?n:Pt),r.current=null)})},[e,t]),p.useEffect(()=>{if(void 0!==e)if("string"==typeof e){const n=Nn(e);t(n||e)}else t(e)},[e,t]),null}function Hn({children:e}){var t,n,o,r,i;const a=Tt(e=>e.theme),s=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({position:"relative","--semiotic-bg":a.colors.background,"--semiotic-text":a.colors.text,"--semiotic-text-secondary":a.colors.textSecondary,"--semiotic-grid":a.colors.grid,"--semiotic-border":a.colors.border,"--semiotic-primary":a.colors.primary,"--semiotic-font-family":a.typography.fontFamily},a.colors.focus?{"--semiotic-focus":a.colors.focus}:{}),(null===(t=a.tooltip)||void 0===t?void 0:t.background)?{"--semiotic-tooltip-bg":a.tooltip.background}:{}),(null===(n=a.tooltip)||void 0===n?void 0:n.text)?{"--semiotic-tooltip-text":a.tooltip.text}:{}),(null===(o=a.tooltip)||void 0===o?void 0:o.borderRadius)?{"--semiotic-tooltip-radius":a.tooltip.borderRadius}:{}),(null===(r=a.tooltip)||void 0===r?void 0:r.fontSize)?{"--semiotic-tooltip-font-size":a.tooltip.fontSize}:{}),(null===(i=a.tooltip)||void 0===i?void 0:i.shadow)?{"--semiotic-tooltip-shadow":a.tooltip.shadow}:{}),a.borderRadius?{"--semiotic-border-radius":a.borderRadius}:{}),a.colors.selection?{"--semiotic-selection-color":a.colors.selection}:{}),null!=a.colors.selectionOpacity?{"--semiotic-selection-opacity":a.colors.selectionOpacity+""}:{}),a.colors.diverging?{"--semiotic-diverging":a.colors.diverging}:{}),l=p.useContext(Dn),c={};return l&&(c["data-semiotic-theme"]=l),p.createElement("div",Object.assign({style:s},c),e)}function Rn(){return Tt(e=>e.theme)}const Wn="#007bff";function Fn(){var e;const t=Rn(),n=null===(e=null==t?void 0:t.colors)||void 0===e?void 0:e.categorical;return n&&n.length>0?n:void 0}function zn(e,t,n,o,r){if(e)return e;let i;if(Array.isArray(n))i=n;else if(t&&t.length>0)i=t;else if("string"==typeof n){const e=j[n];Array.isArray(e)&&(i=e)}return i&&0!==i.length?null!=o?(r.has(o)||r.set(o,r.size),i[r.get(o)%i.length]):i[0]:Wn}function $n(e){return"function"==typeof e?e:t=>t[e]}function Gn(t,n,o){const r=pn(),i=Fn();return e.useMemo(()=>{var e;if(!n)return;const a=null!==(e=null!=o?o:i&&i.length>0?i:void 0)&&void 0!==e?e:"category10";if(0!==t.length){if("function"==typeof n){const e=Array.from(new Set(t.map(e=>n(e)+"")));if(r&&Object.keys(r).length>0){const t=T(e.map(e=>({_cat:e})),"_cat",a);return e=>r[e]||t(e)}return T(e.map(e=>({_cat:e})),"_cat",a)}if(r&&Object.keys(r).length>0){const e=T(t,n,a);return t=>r[t]||e(t)}return T(t,n,a)}if(r&&Object.keys(r).length>0){const e=T([{_:"a"}],"_",a);return t=>r[t]||e(t)}},[t,n,o,r,i])}function Yn(t,n,o){return e.useMemo(()=>{if(!n)return t;const e=[...t];if("function"==typeof n)return e.sort(n);const r=$n(o);return e.sort("asc"===n?(e,t)=>r(e)-r(t):(e,t)=>r(t)-r(e))},[t,n,o])}function qn({selection:t,linkedHover:n,fallbackFields:o=[],unwrapData:r=!1,onObservation:i,chartType:a,chartId:s,onClick:l,hoverHighlight:c,colorByField:u}){const d=e.useId(),h=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||t||[],mode:e.mode,xField:e.xField}:null}(n,o),g=An({name:(null==t?void 0:t.name)||"__unused__"}),f=Sn({name:(null==h?void 0:h.name)||"hover",fields:(null==h?void 0:h.fields)||o||[]}),p=wn(e=>e.pushObservation),y=t?{isActive:g.isActive,predicate:g.predicate}:null,[m,v]=e.useState(null),b=u||o[0],x=e.useMemo(()=>{if(!c||null==m||!b)return null;const e=m,t=b;return{isActive:!0,predicate:n=>{var o;return("string"==typeof n[t]?n[t]:(null!==(o=n[t])&&void 0!==o?o:"")+"")===e}}},[c,m,b]),k=e.useCallback(e=>{var t,o;if(n)if(e){let t=e.data||e.datum||e;if(Array.isArray(t)&&(t=t[0]),"x-position"===(null==h?void 0:h.mode)&&h.xField){const e=null==t?void 0:t[h.xField];null!=e&&Number.isFinite(Number(e))&&function(e,t,n){const o=We.positions.get(e);(null==o?void 0:o.locked)||o&&o.xValue===t&&o.sourceId===n||(We={positions:new Map(We.positions).set(e,{xValue:t,sourceId:n})},ze())}(h.name||"hover",Number(e),d)}"x-position"!==(null==h?void 0:h.mode)&&f.onHover(t)}else"x-position"===(null==h?void 0:h.mode)&&$e(h.name||"hover",d),"x-position"!==(null==h?void 0:h.mode)&&f.onHover(null);if(c&&b)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=null==t?void 0:t[b];v(null!=n?n+"":null)}else v(null);if(i||p){const n={timestamp:Date.now(),chartType:a||"unknown",chartId:s};if(e){let r=e.data||e.datum||e;Array.isArray(r)&&(r=r[0]);const a=Object.assign(Object.assign({},n),{type:"hover",datum:r||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(o=e.y)&&void 0!==o?o:0});i&&i(a),p&&p(a)}else{const e=Object.assign(Object.assign({},n),{type:"hover-end"});i&&i(e),p&&p(e)}}},[n,f,h,d,i,a,s,p,c,b]),w=e.useCallback(e=>{var t,n,o,r;if("x-position"===(null==h?void 0:h.mode)&&h.xField&&e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=null==t?void 0:t[h.xField];null!=n&&Number.isFinite(Number(n))&&function(e,t,n){const o=We.positions.get(e);if(null==o?void 0:o.locked){const t=new Map(We.positions);return t.delete(e),We={positions:t},ze(),!1}We={positions:new Map(We.positions).set(e,{xValue:t,sourceId:n,locked:!0})},ze()}(h.name||"hover",Number(n),d)}if(e&&l){let o=e.data||e.datum||e;Array.isArray(o)&&(o=o[0]),l(o,{x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0})}if(i||p){const t={timestamp:Date.now(),chartType:a||"unknown",chartId:s};if(e){let n=e.data||e.datum||e;Array.isArray(n)&&(n=n[0]);const a=Object.assign(Object.assign({},t),{type:"click",datum:n||{},x:null!==(o=e.x)&&void 0!==o?o:0,y:null!==(r=e.y)&&void 0!==r?r:0});i&&i(a),p&&p(a)}else{const e=Object.assign(Object.assign({},t),{type:"click-end"});i&&i(e),p&&p(e)}}},[l,i,p,a,s,h,d]);return e.useEffect(()=>{if("x-position"!==(null==h?void 0:h.mode))return;const e=h.name||"hover";return()=>{Ge(e,d),$e(e,d)}},[null==h?void 0:h.mode,null==h?void 0:h.name,d]),{activeSelectionHook:y,hoverSelectionHook:x,customHoverBehavior:k,customClickBehavior:w,crosshairSourceId:d}}function Xn(e,t){const n="object"==typeof e&&null!==e?e:void 0;if("x-position"===(null==n?void 0:n.mode))return{linkedCrosshairName:n.name||"hover",linkedCrosshairSourceId:t}}function Vn({data:t,colorBy:n,colorScale:o,showLegend:r,legendPosition:i="right",userMargin:a,defaults:s={top:50,bottom:60,left:70,right:40},categories:l}){const c=e.useContext(Mn),u=void 0!==r?r:!c&&!!n,d=e.useMemo(()=>{if(u&&n)return Ln({data:t,colorBy:n,colorScale:o,getColor:B,categories:l})},[u,n,t,o,l]),h=e.useMemo(()=>{const e=Object.assign(Object.assign({},s),a);return d&&("right"===i&&110>e.right?e.right=110:"left"===i&&110>e.left?e.left=110:"top"===i&&50>e.top?e.top=50:"bottom"===i&&80>e.bottom&&(e.bottom=80)),e},[s,a,d,i]);return{legend:d,margin:h,legendPosition:i}}function Un(t,n,o){const[r,i]=e.useState(null),[a,s]=e.useState(new Set),l=e.useCallback(e=>{"highlight"===t&&i(e?e.label:null)},[t]),c=e.useCallback(e=>{"isolate"===t&&s(t=>{const n=new Set(t);return n.has(e.label)?n.delete(e.label):n.add(e.label),n.size===o.length?new Set:n})},[t,o.length]),u=e.useMemo(()=>{if(!t||"none"===t||!n)return null;const e="string"==typeof n?n:null;return"highlight"===t&&null!=r?{isActive:!0,predicate:t=>(e?t[e]:"function"==typeof n?n(t):null)===r}:"isolate"===t&&a.size>0?{isActive:!0,predicate:t=>{const o=e?t[e]:"function"==typeof n?n(t):null;return a.has(o)}}:null},[t,n,r,a]);return{highlightedCategory:"highlight"===t?r:null,isolatedCategories:"isolate"===t?a:new Set,onLegendHover:l,onLegendClick:c,legendSelectionHook:u}}const Kn={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 Qn(e,t,n){var o,r,i,a,s,l,c;const u=Kn[e||"primary"],d="context"===e||"sparkline"===e;return{width:null!==(o=t.width)&&void 0!==o?o:e&&"primary"!==e||!(null==n?void 0:n.width)?u.width:n.width,height:null!==(r=t.height)&&void 0!==r?r:e&&"primary"!==e||!(null==n?void 0:n.height)?u.height:n.height,showAxes:null!==(i=t.showAxes)&&void 0!==i?i:u.showAxes,showGrid:null!==(a=t.showGrid)&&void 0!==a?a:u.showGrid,enableHover:null!==(s=t.enableHover)&&void 0!==s?s:!!t.linkedHover||u.enableHover,showLegend:null!==(l=t.showLegend)&&void 0!==l?l:u.showLegend,showLabels:null!==(c=t.showLabels)&&void 0!==c?c:u.showLabels,title:d?void 0:t.title,description:t.description,summary:t.summary,accessibleTable:t.accessibleTable,xLabel:d?void 0:t.xLabel,yLabel:d?void 0:t.yLabel,categoryLabel:d?void 0:t.categoryLabel,valueLabel:d?void 0:t.valueLabel,marginDefaults:Zn(u.marginDefaults,t.showCategoryTicks,t.orientation)}}function Zn(e,t,n){if(!1!==t)return e;const o=Object.assign({},e);return"horizontal"===n?o.left=Math.min(o.left,15):o.bottom=Math.min(o.bottom,15),o}const Jn={background:"var(--semiotic-tooltip-bg, rgba(0, 0, 0, 0.85))",color:"var(--semiotic-tooltip-text, white)",padding:"8px 12px",borderRadius:"var(--semiotic-tooltip-radius, 6px)",fontSize:"var(--semiotic-tooltip-font-size, 14px)",fontFamily:"var(--semiotic-font-family, inherit)",lineHeight:"1.5",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, 0.15))",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"};function eo(e,t){return"function"==typeof t?t(e):e[t]}function to(e,t){if(t)return t(e);if(null==e)return"";if("number"==typeof e){if(!Number.isFinite(e))return e+"";const t=Number.isInteger(e)?e:parseFloat(e.toPrecision(6));return Math.abs(t)>9999?t.toLocaleString():t+""}return 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 no(e={}){const{fields:t,title:n,format:o,style:r={},className:i=""}=e;return e=>{if(!e||"object"!=typeof e)return null;let a;const s=[];if(n){const t=eo(e,n);a=to(t,o)}if(t&&t.length>0)t.forEach(t=>{let n,r,i;"string"==typeof t?(n=t,r=t,i=o):(n=t.label,r=t.accessor||t.key||"",i=t.format||o);const a=eo(e,r);s.push({label:n,value:to(a,i)})});else if(!n){const t=["value","y","name","id","label"];for(const n of t)if(void 0!==e[n]){a=to(e[n],o);break}if(!a){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(a=to(e[t[0]],o))}}const l=Object.assign(Object.assign({},Jn),r);return p.createElement("div",{className:("semiotic-tooltip "+i).trim(),style:l},a&&p.createElement("div",{style:{fontWeight:s.length>0?"bold":"normal"}},a),s.map((e,t)=>p.createElement("div",{key:t,style:{marginTop:0===t&&a?"4px":0}},e.label&&p.createElement("span",null,e.label,": "),e.value)))}}function oo(e){if(!0===e)return no();if("function"==typeof e){const t=e;return e=>{const n=t(!e||"object"!=typeof e.data||null===e.data||"node"!==e.type&&"edge"!==e.type?e:e.data);return null==n?null:p.createElement("div",{className:"semiotic-tooltip",style:Jn},n)}}return!1!==e&&void 0!==e&&("object"==typeof e&&null!==e&&("fields"in e||"title"in e)?no(e):no())}function ro(e){return"string"==typeof e?e:"value"}function io(e){return null==e?"–":"number"==typeof e?Math.abs(e)>9999?e.toLocaleString():e+"":e instanceof Date?e.toLocaleDateString():e+""}function ao(e,t){return"function"==typeof t?t(e):e[t]}function so(e){const t=e.find(e=>"title"===e.role),n=e.filter(e=>"title"!==e.role);return e=>{const o=e.data;if(!o)return null;const r=t?io(ao(o,t.accessor)):null;return p.createElement("div",{className:"semiotic-tooltip",style:Jn},r&&p.createElement("div",{style:{fontWeight:"bold",marginBottom:n.length>0?4:0}},r),n.map((e,t)=>{const n=io(ao(o,e.accessor));return p.createElement("div",{key:t,style:t>0?{marginTop:2}:void 0},p.createElement("span",{style:{opacity:.7}},e.label,": "),p.createElement("span",null,n))}))}}function lo({categoryAccessor:e,valueAccessor:t,groupAccessor:n,groupLabel:o,pieData:r=!1}){return i=>{var a;const s=r?(null===(a=i.data)||void 0===a?void 0:a[0])||i.data||i:i.data||i,l=ao(s,e),c=ao(s,t),u=n?ao(s,n):void 0;return p.createElement("div",{className:"semiotic-tooltip",style:Jn},p.createElement("div",{style:{fontWeight:"bold"}},io(l)),p.createElement("div",{style:{marginTop:4}},io(c)),null!=u&&p.createElement("div",{style:{marginTop:2,opacity:.8}},o||ro(n),": ",io(u)))}}function co({componentName:e,message:t,diagnosticHint:n,width:o,height:r}){return p.createElement("div",{role:"alert",style:{width:o,height:Math.max(r,120),display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed rgba(128, 128, 128, 0.4)",borderRadius:8,background:"rgba(128, 128, 128, 0.04)",padding:24,boxSizing:"border-box"}},p.createElement("div",{style:{textAlign:"center",maxWidth:400}},p.createElement("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"}},e),p.createElement("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5}},t),n&&p.createElement("div",{"data-testid":"semiotic-diagnostic-hint",style:{marginTop:10,padding:"8px 12px",background:"rgba(128, 128, 128, 0.06)",borderRadius:4,fontSize:12,color:"rgba(128, 128, 128, 0.8)",fontFamily:"monospace",textAlign:"left",whiteSpace:"pre-wrap",lineHeight:1.6}},n)))}class uo extends p.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){var n,o;null===(o=(n=this.props).onError)||void 0===o||o.call(n,e,t)}render(){if(this.state.error){const{fallback:e}=this.props,t=this.state.error;return"function"==typeof e?e(t):void 0!==e?e:p.createElement(co,{componentName:"ChartErrorBoundary",message:t.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}function ho(e,t){const n=e.length,o=t.length,r=Array(o+1);for(let e=0;o>=e;e++)r[e]=e;for(let i=1;n>=i;i++){let n=r[0];r[0]=i;for(let a=1;o>=a;a++){const o=r[a];r[a]=e[i-1]===t[a-1]?n:1+Math.min(n,r[a],r[a-1]),n=o}}return r[o]}function go(e,t,n=3){let o,r=n+1;for(const n of t){const t=ho(e.toLowerCase(),n.toLowerCase());r>t&&(r=t,o=n)}return r>n?void 0:o}function fo(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:e}function po(e,t){var n;if(0===t.length)return null;const o=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(o)||o.includes(e.toLowerCase()))||(null!==(n=go(e,t,3))&&void 0!==n?n:null)}function yo({componentName:e,data:t,accessors:n,requiredProps:o}){if(o)for(const[t,n]of Object.entries(o))if(null==n)return`${e}: ${t} is required. Provide a field name or function.`;if(null==t)return null;if(!Array.isArray(t)||0===t.length)return e+": No data provided. Pass a non-empty array to the data prop.";if(!Array.isArray(t)&&"object"==typeof t)return e+": data should be an array, but received an object. If this is hierarchical data, use TreeDiagram, Treemap, or CirclePack instead.";if(n){const o=fo(t).find(e=>e&&"object"==typeof e);if(o){const t=Object.keys(o);for(const[r,i]of Object.entries(n))if(i&&"string"==typeof i&&!(i in o)){const n=po(i,t),o=n?` Try ${r}="${n}".`:"";return`${e}: ${r} "${i}" not found in data. Available fields: ${t.join(", ")}.${o}`}}}return null}function mo({componentName:e,data:t,dataLabel:n="data"}){return null==t?`${e}: No ${n} provided. Pass a hierarchical object with children: { name: "root", children: [...] }.`:Array.isArray(t)?`${e}: ${n} should be a single root object, not an array. Expected: { name: "root", children: [...] }. If you have flat data, use LineChart, BarChart, or Scatterplot instead.`:null}function vo({componentName:e,nodes:t,edges:n,nodesRequired:o=!1,edgesRequired:r=!0,accessors:i}){if(null==t&&null==n)return null;if(r&&(!n||!Array.isArray(n)||0===n.length))return e+': No edges provided. Pass a non-empty array: edges={[{ source: "A", target: "B", value: 10 }, ...]}.';if(o&&(!t||!Array.isArray(t)||0===t.length))return e+': No nodes provided. Pass a non-empty array: nodes={[{ id: "A" }, { id: "B" }, ...]}.';if(i&&t&&t.length>0){const n=fo(t).find(e=>e&&"object"==typeof e);if(n){const t=Object.keys(n);for(const[o,r]of Object.entries(i))if(r&&"string"==typeof r&&!(r in n)){const n=po(r,t),i=n?` Try ${o}="${n}".`:"";return`${e}: ${o} "${r}" not found in node data. Available fields: ${t.join(", ")}.${i}`}}}return null}const bo={width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},frameProps:{type:"object"},onClick:{type:"function"}},xo={xLabel:{type:"string"},yLabel:{type:"string"},xFormat:{type:"function"},yFormat:{type:"function"}},ko={categoryLabel:{type:"string"},valueLabel:{type:"string"},valueFormat:{type:"function"},categoryFormat:{type:"function"}},wo=["linear","monotoneX","monotoneY","step","stepAfter","stepBefore","basis","cardinal","catmullRom"],Ao=["vertical","horizontal"],So={LineChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},bo),xo),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},lineBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:wo},lineWidth:{type:"number"},showPoints:{type:"boolean"},pointRadius:{type:"number"},fillArea:{type:"boolean"},areaOpacity:{type:"number"}})},AreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},bo),xo),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:wo},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"}})},StackedAreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},bo),xo),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:wo},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"},normalize:{type:"boolean"}})},Scatterplot:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},bo),xo),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"}})},BubbleChart:{required:["data","sizeBy"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},bo),xo),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},bubbleOpacity:{type:"number"},bubbleStrokeWidth:{type:"number"},bubbleStrokeColor:{type:"string"}})},Heatmap:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},bo),xo),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},colorScheme:{type:"string",enum:["blues","reds","greens","viridis","custom"]},customColorScale:{type:["object","function"]},showValues:{type:"boolean"},valueFormat:{type:"function"},cellBorderColor:{type:"string"},cellBorderWidth:{type:"number"},showLegend:{type:"boolean"},legendPosition:{type:"string",enum:["right","left","top","bottom"]}})},QuadrantChart:{required:["quadrants"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},bo),xo),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},quadrants:{type:"object"},xCenter:{type:"number"},yCenter:{type:"number"},centerlineStyle:{type:"object"},showQuadrantLabels:{type:"boolean"},quadrantLabelSize:{type:"number"},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"}})},MultiAxisLineChart:{required:["series"],dataShape:"array",dataAccessors:["xAccessor"],props:Object.assign(Object.assign(Object.assign({},bo),xo),{data:{type:"array"},xAccessor:{type:["string","function"]},series:{type:"array"},colorScheme:{type:["string","array"]},curve:{type:"string"},lineWidth:{type:"number"},annotations:{type:"array"}})},ConnectedScatterplot:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},bo),xo),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},orderAccessor:{type:["string","function"]},orderLabel:{type:"string"},pointRadius:{type:"number"},pointIdAccessor:{type:["string","function"]},annotations:{type:"array"}})},BarChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},bo),ko),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Ao},sort:{type:["boolean","string","function"]},barPadding:{type:"number"}})},StackedBarChart:{required:["data","stackBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},bo),ko),{data:{type:"array"},categoryAccessor:{type:["string","function"]},stackBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Ao},normalize:{type:"boolean"},barPadding:{type:"number"}})},LikertChart:{required:["levels"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor","levelAccessor","countAccessor"],props:Object.assign(Object.assign(Object.assign({},bo),ko),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},levelAccessor:{type:["string","function"]},countAccessor:{type:["string","function"]},levels:{type:"array"},orientation:{type:"string",enum:Ao},barPadding:{type:"number"}})},GroupedBarChart:{required:["data","groupBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},bo),ko),{data:{type:"array"},categoryAccessor:{type:["string","function"]},groupBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Ao},barPadding:{type:"number"}})},SwarmPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},bo),ko),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Ao},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"},categoryPadding:{type:"number"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}})},BoxPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},bo),ko),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Ao},showOutliers:{type:"boolean"},outlierRadius:{type:"number"},categoryPadding:{type:"number"}})},Histogram:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},bo),ko),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},bins:{type:"number"},relative:{type:"boolean"},categoryPadding:{type:"number"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}})},ViolinPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},bo),ko),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Ao},bins:{type:"number"},curve:{type:"string"},showIQR:{type:"boolean"},categoryPadding:{type:"number"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}})},RidgelinePlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},bo),ko),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},bins:{type:"number"},amplitude:{type:"number"},categoryPadding:{type:"number"}})},DotPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},bo),ko),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Ao},sort:{type:["boolean","string","function"]},dotRadius:{type:"number"},categoryPadding:{type:"number"}})},PieChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},bo),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},startAngle:{type:"number"}})},DonutChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},bo),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},innerRadius:{type:"number"},centerContent:{type:["object","string","number"]},startAngle:{type:"number"}})},GaugeChart:{required:["value"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},bo),{value:{type:"number"},min:{type:"number"},max:{type:"number"},thresholds:{type:"array"},arcWidth:{type:"number"},sweep:{type:"number"},showNeedle:{type:"boolean"},needleColor:{type:"string"},centerContent:{type:["object","string","number","function"]},valueFormat:{type:"function"},showScaleLabels:{type:"boolean"},backgroundColor:{type:"string"}})},FunnelChart:{required:["data"],dataShape:"array",dataAccessors:["stepAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},bo),ko),{data:{type:"array"},stepAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},orientation:{type:"string",enum:["horizontal","vertical"]},connectorOpacity:{type:"number"},showCategoryTicks:{type:"boolean"},responsiveWidth:{type:"boolean"},legendPosition:{type:"string",enum:["right","left","top","bottom"]}})},SwimlaneChart:{required:["subcategoryAccessor"],dataShape:"array",dataAccessors:["categoryAccessor","subcategoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},bo),ko),{data:{type:"array"},categoryAccessor:{type:["string","function"]},subcategoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:["horizontal","vertical"]},barPadding:{type:"number"},showCategoryTicks:{type:"boolean"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]},responsiveWidth:{type:"boolean"},legendPosition:{type:"string",enum:["right","left","top","bottom"]}})},ForceDirectedGraph:{required:["nodes","edges"],dataShape:"network",dataAccessors:["nodeIDAccessor","sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},bo),{nodes:{type:"array"},edges:{type:"array"},nodeIDAccessor:{type:["string","function"]},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},nodeLabel:{type:["string","function"]},nodeSize:{type:["number","string","function"]},nodeSizeRange:{type:"array"},edgeWidth:{type:["number","string","function"]},edgeColor:{type:"string"},edgeOpacity:{type:"number"},iterations:{type:"number"},forceStrength:{type:"number"},showLabels:{type:"boolean"}})},SankeyDiagram:{required:["edges"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},bo),{nodes:{type:"array"},edges:{type:"array"},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},edgeColorBy:{type:["string","function"],enum:["source","target","gradient"]},orientation:{type:"string",enum:Ao},nodeAlign:{type:"string",enum:["justify","left","right","center"]},nodePaddingRatio:{type:"number"},nodeWidth:{type:"number"},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},edgeOpacity:{type:"number"},edgeSort:{type:"function"}})},ChordDiagram:{required:["edges"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},bo),{nodes:{type:"array"},edges:{type:"array"},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},edgeColorBy:{type:["string","function"],enum:["source","target"]},padAngle:{type:"number"},groupWidth:{type:"number"},sortGroups:{type:"function"},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},edgeOpacity:{type:"number"}})},TreeDiagram:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},bo),{data:{type:"object"},layout:{type:"string",enum:["tree","cluster","partition","treemap","circlepack"]},orientation:{type:"string",enum:["vertical","horizontal","radial"]},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},edgeStyle:{type:"string",enum:["line","curve"]},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},nodeSize:{type:"number"}})},Treemap:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},bo),{data:{type:"object"},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},showLabels:{type:"boolean"},nodeLabel:{type:["string","function"]}})},CirclePack:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},bo),{data:{type:"object"},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},showLabels:{type:"boolean"},nodeLabel:{type:["string","function"]},circleOpacity:{type:"number"}})},OrbitDiagram:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},bo),{data:{type:"object"},childrenAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},orbitMode:{type:["string","array"]},speed:{type:"number"},revolution:{type:"function"},eccentricity:{type:["number","function"]},orbitSize:{type:["number","function"]},nodeRadius:{type:["number","function"]},showRings:{type:"boolean"},showLabels:{type:"boolean"},animated:{type:"boolean"},colorByDepth:{type:"boolean"},annotations:{type:"array"},foregroundGraphics:{type:"object"}})},RealtimeLineChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},stroke:{type:"string"},strokeWidth:{type:"number"},strokeDasharray:{type:"string"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeHistogram:{required:["binSize"],dataShape:"realtime",dataAccessors:[],props:{binSize:{type:"number"},size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},colors:{type:"object"},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},fill:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},gap:{type:"number"},brush:{type:["boolean","string","object"]},onBrush:{type:"function"},linkedBrush:{type:["string","object"]},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeSwarmChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},colors:{type:"object"},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},radius:{type:"number"},fill:{type:"string"},opacity:{type:"number"},stroke:{type:"string"},strokeWidth:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeWaterfallChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},positiveColor:{type:"string"},negativeColor:{type:"string"},connectorStroke:{type:"string"},connectorWidth:{type:"number"},gap:{type:"number"},stroke:{type:"string"},strokeWidth:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeHeatmap:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},heatmapXBins:{type:"number"},heatmapYBins:{type:"number"},aggregation:{type:"string",enum:["count","sum","mean"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"}}}};function Oo(e,t){return(Array.isArray(t)?t:[t]).includes(Array.isArray(e)?"array":typeof e)}function Eo(e,t){const n=[],o=So[e];if(!o)return{valid:!1,errors:[`Unknown component "${e}". Valid components: ${Object.keys(So).join(", ")}`]};for(const r of o.required)null==t[r]&&n.push(`"${r}" is required for ${e}.`);for(const[e,r]of Object.entries(t)){if(null==r)continue;const t=o.props[e];if(t){if(!Oo(r,t.type)){const o=Array.isArray(t.type)?t.type.join(" | "):t.type;n.push(`"${e}" should be ${o}, got ${Array.isArray(r)?"array":typeof r}.`);continue}t.enum&&"string"==typeof r&&!t.enum.includes(r)&&n.push(`"${e}" value "${r}" is not valid. Expected one of: ${t.enum.join(", ")}.`)}}const r=Object.keys(o.props),i=new Set(r);for(const o of Object.keys(t))if(void 0!==t[o]&&!i.has(o)){const t=go(o,r),i=t?`Unknown prop "${o}" for ${e}. Did you mean "${t}"?`:`Unknown prop "${o}" for ${e}. Valid props: ${r.join(", ")}.`;n.push(i)}if("array"===o.dataShape){const r=t.data,i={};for(const e of o.dataAccessors){const n=t[e];"string"==typeof n&&(i[e]=n)}const a=yo({componentName:e,data:r,accessors:Object.keys(i).length>0?i:void 0});a&&n.push(a)}else if("object"===o.dataShape){const o=mo({componentName:e,data:t.data});o&&n.push(o)}else if("network"===o.dataShape){const r=vo({componentName:e,nodes:t.nodes,edges:t.edges,nodesRequired:o.required.includes("nodes"),edgesRequired:o.required.includes("edges")});r&&n.push(r)}return{valid:0===n.length,errors:n}}const Mo=new Set(["TreeDiagram","Treemap","CirclePack","OrbitDiagram"]),jo=new Set(["ForceDirectedGraph","SankeyDiagram","ChordDiagram"]),Co=new Set(["BarChart","StackedBarChart","GroupedBarChart","AreaChart","StackedAreaChart"]),Po=new Set(["LineChart","AreaChart","StackedAreaChart"]),Lo=new Set(["BarChart","StackedBarChart","GroupedBarChart","FunnelChart"]);function _o(e){const t=e.match(/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i);if(!t)return null;const[n,o,r]=[parseInt(t[1],16)/255,parseInt(t[2],16)/255,parseInt(t[3],16)/255],i=e=>e>.03928?Math.pow((e+.055)/1.055,2.4):e/12.92;return.2126*i(n)+.7152*i(o)+.0722*i(r)}function Bo(e,t){const n=_o(e),o=_o(t);return null===n||null===o?null:(Math.max(n,o)+.05)/(Math.min(n,o)+.05)}const To=["xAccessor","yAccessor","timeAccessor","valueAccessor","categoryAccessor","colorBy","sizeBy","lineBy","areaBy","stackBy","groupBy","orderAccessor","y0Accessor","sourceAccessor","targetAccessor","nodeIDAccessor","childrenAccessor","costAccessor"];function No(e,t){const n=[],o=Eo(e,t);for(const e of o.errors)n.push({severity:"error",code:"VALIDATION",message:e,fix:""});return So[e]?(function(e,t,n){const o=So[e];if(o){if("array"===o.dataShape){const e=t.data;e&&Array.isArray(e)&&0===e.length&&n.push({severity:"error",code:"EMPTY_DATA",message:"data is an empty array — chart will render blank.",fix:"Provide at least one data point: data={[{ x: 1, y: 2 }]}."})}"network"===o.dataShape&&t.edges&&Array.isArray(t.edges)&&0===t.edges.length&&n.push({severity:"error",code:"EMPTY_EDGES",message:"edges is an empty array — network chart will render blank.",fix:'Provide at least one edge: edges={[{ source: "A", target: "B" }]}.'})}}(e,t,n),function(e,t,n){const o=t.width,r=t.height;if(void 0===o||"number"==typeof o&&o>0||n.push({severity:"error",code:"BAD_WIDTH",message:`width=${JSON.stringify(o)} — chart needs a positive number.`,fix:"Set width={600} or use responsiveWidth={true}."}),void 0===r||"number"==typeof r&&r>0||n.push({severity:"error",code:"BAD_HEIGHT",message:`height=${JSON.stringify(r)} — chart needs a positive number.`,fix:"Set height={400} or use responsiveHeight={true}."}),t.size&&Array.isArray(t.size)){const[e,o]=t.size;(null!=e&&0>=e||null!=o&&0>=o)&&n.push({severity:"error",code:"BAD_SIZE",message:`size=[${e}, ${o}] — both dimensions must be positive.`,fix:"Set size={[600, 400]}."})}}(0,t,n),function(e,t,n){const o=So[e];if(!o||"array"!==o.dataShape)return;const r=t.data;if(!r||!Array.isArray(r)||0===r.length)return;const i=r[0];if(!i||"object"!=typeof i)return;const a=Object.keys(i);for(const e of o.dataAccessors){const o=t[e];"string"==typeof o&&(o in i||n.push({severity:"error",code:"ACCESSOR_MISSING",message:`${e}="${o}" not found in data. Available fields: ${a.join(", ")}.`,fix:`Change ${e} to one of: ${a.map(e=>`"${e}"`).join(", ")}.`}))}}(e,t,n),function(e,t,n){Mo.has(e)&&Array.isArray(t.data)&&n.push({severity:"error",code:"HIERARCHY_FLAT_ARRAY",message:e+" expects hierarchical data but received a flat array.",fix:'Pass a root object: data={{ name: "root", children: [...] }}. For flat data, use BarChart or LineChart.'})}(e,t,n),function(e,t,n){jo.has(e)&&(t.edges||t.data||n.push({severity:"error",code:"NETWORK_NO_EDGES",message:e+" requires an edges prop.",fix:'Provide edges={[{ source: "A", target: "B", value: 10 }]}.'}))}(e,t,n),function(e,t,n){const o=So[e];if(!o||"array"!==o.dataShape)return;const r=t.data;if(!r||!Array.isArray(r)||0===r.length)return;const i=r[0];if(!i||"object"!=typeof i)return;const a=t.xAccessor;"string"==typeof a&&i[a]instanceof Date&&!t.xFormat&&n.push({severity:"warning",code:"DATE_NO_FORMAT",message:`xAccessor "${a}" contains Date objects but no xFormat is provided. Axis ticks may display "[object Object]".`,fix:"Add xFormat={d => d.toLocaleDateString()} or use timestamps (d.getTime()) instead of Date objects."})}(e,t,n),function(e,t,n){t.linkedHover&&!t.selection&&n.push({severity:"warning",code:"LINKED_HOVER_NO_SELECTION",message:"linkedHover is set but selection is not — this chart emits hover events but won't highlight from others.",fix:`Add selection={{ name: "${"object"==typeof t.linkedHover&&t.linkedHover.name||"hl"}" }} to receive cross-highlights.`})}(0,t,n),function(e,t,n){var o;if(!Co.has(e))return;const r=t.rExtent||t.yExtent;r&&Array.isArray(r)&&r.length>=1&&null!=r[0]&&0!==r[0]&&n.push({severity:"warning",code:"NON_ZERO_BASELINE",message:`${e} has a non-zero baseline (${r[0]}). Bar and area charts should start at zero to avoid exaggerating differences.`,fix:`Remove the custom extent minimum or set it to 0: rExtent={[0, ${null!==(o=r[1])&&void 0!==o?o:"auto"}]}. For trend-focused charts, use LineChart instead.`})}(e,t,n),function(e,t,n){if(!Po.has(e))return;if(t.gapStrategy)return;const o=t.data;if(!o||!Array.isArray(o)||0===o.length)return;const r=t.yAccessor||"y";"string"==typeof r&&o.some(e=>{const t=e[r];return null==t||Number.isNaN(t)})&&n.push({severity:"warning",code:"DATA_GAPS",message:`Data contains null/undefined/NaN values in "${r}". Default behavior breaks the line at gaps.`,fix:'Set gapStrategy="break" (default), "interpolate", or "zero" to control gap handling.'})}(e,t,n),function(e,t,n){var o,r;const i=null!==(o=t.width)&&void 0!==o?o:600,a=null!==(r=t.height)&&void 0!==r?r:400,s=t.margin;if(!s||"object"!=typeof s)return;const l=(s.left||0)+(s.right||0),c=(s.top||0)+(s.bottom||0);i>l||n.push({severity:"error",code:"MARGIN_OVERFLOW_H",message:`Horizontal margins (${l}px) >= width (${i}px) — no drawing area left.`,fix:"Reduce margin.left/right or increase width."}),a>c||n.push({severity:"error",code:"MARGIN_OVERFLOW_V",message:`Vertical margins (${c}px) >= height (${a}px) — no drawing area left.`,fix:"Reduce margin.top/bottom or increase height."})}(0,t,n),function(e,t,n){var o;const r=So[e];if(!r||"array"!==r.dataShape)return;const i=t.data;if(!i||!Array.isArray(i)||0===i.length)return;const a=[];t.xAccessor&&"string"==typeof t.xAccessor&&a.push({prop:"xAccessor",name:t.xAccessor}),t.yAccessor&&"string"==typeof t.yAccessor&&a.push({prop:"yAccessor",name:t.yAccessor}),t.valueAccessor&&"string"==typeof t.valueAccessor&&a.push({prop:"valueAccessor",name:t.valueAccessor});const s=Math.min(i.length,5);for(const e of a){let t=!0;for(let n=0;s>n;n++){const r=null===(o=i[n])||void 0===o?void 0:o[e.name];if("number"==typeof r&&Number.isFinite(r)){t=!1;break}}t&&n.push({severity:"error",code:"DEGENERATE_EXTENT",message:`${e.prop}="${e.name}" produces NaN or non-finite values for all sampled data points — chart extents will be invalid.`,fix:`Ensure data[].${e.name} contains finite numbers, or use a function accessor to transform values.`})}}(e,t,n),function(e,t,n){if(!Lo.has(e))return;const o=t.barPadding;"number"==typeof o&&10>o&&n.push({severity:"warning",code:"BAR_PADDING_INVISIBLE",message:`barPadding=${o} is very small — bars may appear to have no spacing between them.`,fix:"Increase barPadding to at least 10 for visible gaps, e.g. barPadding={12}."})}(e,t,n),function(e,t,n){if("bottom"!==t.legendPosition)return;const o=t.margin;if(!o||"object"!=typeof o)return;const r=o.bottom;"number"==typeof r&&70>r&&n.push({severity:"warning",code:"BOTTOM_MARGIN_WITH_LEGEND",message:`legendPosition="bottom" with margin.bottom=${r}px — legend may overlap axis labels.`,fix:"Increase margin.bottom to at least 70, e.g. margin={{ ...margin, bottom: 80 }}."})}(0,t,n),function(e,t,n){var o;if(!t.showLegend)return;if("right"!==(null!==(o=t.legendPosition)&&void 0!==o?o:"right"))return;const r=t.margin;if(!r||"object"!=typeof r)return;const i=r.right;"number"==typeof i&&100>i&&n.push({severity:"warning",code:"LEGEND_MARGIN_TIGHT",message:`showLegend is true with legendPosition="right" but margin.right=${i}px — legend may be clipped or overlap the chart.`,fix:"Increase margin.right to at least 100, e.g. margin={{ ...margin, right: 120 }}."})}(0,t,n),function(e,t,n){if("Heatmap"!==e)return;const o=t.data;if(!o||!Array.isArray(o)||0===o.length)return;const r=o[0];if(r&&"object"==typeof r)for(const e of["xAccessor","yAccessor"]){const o=t[e];if("string"!=typeof o)continue;const i=r[o];"string"==typeof i&&n.push({severity:"warning",code:"HEATMAP_STRING_ACCESSOR",message:`${e}="${o}" resolves to string values (e.g. "${i}"). Heatmap will use categorical axis handling which may produce unexpected cell layout.`,fix:"If you intend categorical axes this is fine. Otherwise, convert values to numbers before passing data."})}}(e,t,n),function(e,t,n){const o=t.colorScheme;if(!o||!Array.isArray(o))return;const r="string"==typeof t.background?t.background:"#ffffff";if(!r.startsWith("#"))return;const i=[];for(const e of o){if("string"!=typeof e||!e.startsWith("#"))continue;const t=Bo(e,r);null!==t&&3>t&&i.push(`${e} (${t.toFixed(1)}:1)`)}i.length>0&&n.push({severity:"warning",code:"LOW_COLOR_CONTRAST",message:`${i.length} color(s) in colorScheme have < 3:1 contrast against background "${r}": ${i.join(", ")}. Data marks may be hard to see.`,fix:'Use darker colors on light backgrounds or lighter colors on dark backgrounds. Import COLOR_BLIND_SAFE_CATEGORICAL from "semiotic" for an accessible preset.'})}(0,t,n),function(e,t,n){const o=t.colorScheme;if(!o||!Array.isArray(o)||2>o.length)return;const r=o.filter(e=>"string"==typeof e&&e.startsWith("#"));if(2>r.length)return;const i=[];for(let e=0;r.length-1>e;e++){const t=Bo(r[e],r[e+1]);null!==t&&1.5>t&&i.push(`${r[e]} / ${r[e+1]} (${t.toFixed(1)}:1)`)}i.length>0&&n.push({severity:"warning",code:"LOW_ADJACENT_CONTRAST",message:`${i.length} adjacent color pair(s) in colorScheme have very similar luminance: ${i.join("; ")}. Categories may be hard to distinguish.`,fix:'Alternate light and dark colors in the scheme, or use COLOR_BLIND_SAFE_CATEGORICAL from "semiotic" for a pre-tested palette.'})}(0,t,n),function(e,t,n){const o="string"==typeof t.title&&t.title.trim().length>0,r="string"==typeof t.description&&t.description.trim().length>0,i="string"==typeof t.summary&&t.summary.trim().length>0;o||r||i||n.push({severity:"warning",code:"MISSING_DESCRIPTION",message:'No title, description, or summary provided. Screen readers will use a generic label like "XY chart".',fix:'Add a title="..." prop for a brief label, or description="..." for a detailed aria-label, or summary="..." for a screen-reader-only note describing the chart\'s purpose.'})}(0,t,n),function(e,t,n){const o=[];for(const e of To)"function"==typeof t[e]&&o.push(e);o.length>0&&n.push({severity:"warning",code:"FUNCTION_ACCESSOR",message:`Function accessor${o.length>1?"s":""} detected: ${o.join(", ")}. If defined inline (e.g. \`xAccessor={d => d.value}\`), every parent re-render creates a new reference which may trigger unnecessary scene rebuilds.`,fix:'Use string accessors when possible (e.g. xAccessor="value"), or memoize with useCallback / define outside the component.'})}(0,t,n),{ok:n.every(e=>"warning"===e.severity),diagnoses:n}):{ok:0===n.length,diagnoses:n}}var Do;const Io="undefined"!=typeof process&&"production"!==(null===(Do=process.env)||void 0===Do?void 0:Do.NODE_ENV);function Ho({componentName:e,width:t,height:n,chartProps:o,children:r}){return p.createElement(uo,{fallback:r=>{let i="";if(Io&&o)try{const t=No(e,o);t.ok||(i=t.diagnoses.map(e=>`${"error"===e.severity?"✗":"⚠"} ${e.message}${e.fix?" — Fix: "+e.fix:""}`).join("\n"))}catch(e){}return p.createElement(co,{componentName:e,message:r.message,diagnosticHint:i,width:t,height:n})}},r)}const Ro={display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #999)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"},Wo={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function Fo(e,t,n,o){return!1===o||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?p.createElement("div",{style:Object.assign(Object.assign({},Ro),{width:t,height:n})},o||"No data available"):null}function zo(e,t,n){if(!e)return null;const o=Math.min(5,Math.floor(n/40)),r=Math.max(8,Math.floor(n/(3*o))),i=Math.max(6,Math.floor(n/(2.5*o))),a=Math.floor((n-(o*(r+i)-i))/2);return p.createElement("div",{style:{width:t,height:n,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"}},Array.from({length:o},(e,n)=>p.createElement("div",{key:n,className:"semiotic-loading-bar",style:Object.assign(Object.assign({},Wo),{position:"absolute",top:a+n*(r+i),left:Math.floor(.1*t),width:30+(37*n+13)%50+"%",height:r,opacity:.5+n%2*.2})})))}function $o(e,t,n,o){if(!Io)return;if(!t||0===t.length)return;if("string"!=typeof o)return;const r=t[0];if(!r||"object"!=typeof r)return;if(o in r)return;const i=Object.keys(r).join(", ");console.warn(`[semiotic] ${e}: ${n} "${o}" not found in data. Available keys: ${i}`)}function Go(e,t,n,o){return new(n||(n=Promise))(function(r,i){function a(e){try{l(o.next(e))}catch(e){i(e)}}function s(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){e.done?r(e.value):function(e){return e instanceof n?e:new n(function(t){t(e)})}(e.value).then(a,s)}l((o=o.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const Yo="__forecastSegment";let qo=null;function Xo(){return Go(this,void 0,void 0,function*(){return qo||(qo=yield Promise.resolve().then(function(){return Vs})),qo})}const Vo=e.forwardRef(function(t,n){var o,r;const i=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=i.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=i.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;return null===(e=i.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=i.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const a=Qn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,description:t.description,summary:t.summary,accessibleTable:t.accessibleTable,xLabel:t.xLabel,yLabel:t.yLabel}),{data:s,margin:l,className:c,xFormat:u,yFormat:d,xAccessor:h="x",yAccessor:g="y",lineBy:f,lineDataAccessor:y="coordinates",colorBy:m,colorScheme:v,curve:b="linear",showPoints:x=!1,pointRadius:k=3,fillArea:w=!1,areaOpacity:A=.3,lineWidth:S=2,lineGradient:O,tooltip:E,pointIdAccessor:M,annotations:j,directLabel:C,gapStrategy:P="break",anomaly:L,forecast:_,frameProps:T={},selection:N,linkedHover:D,onObservation:I,onClick:H,hoverHighlight:R,hoverRadius:W,chartId:F,loading:z,emptyContent:$,legendInteraction:G,legendPosition:Y,xScaleType:q,yScaleType:X,color:V}=t,U=a.width,K=a.height,Q=a.enableHover,Z=a.showGrid,J=a.showLegend,ee=a.title,te=a.description,ne=a.summary,oe=a.accessibleTable,re=a.xLabel,ie=a.yLabel,ae=zo(z,U,K),se=ae?null:Fo(s,U,K,$),le=s||[];$o("LineChart",le,"xAccessor",h),$o("LineChart",le,"yAccessor",g);const ce="string"==typeof h?h:"__semiotic_resolvedX",ue="string"==typeof g?g:"__semiotic_resolvedY",[de,he]=e.useState(null),[ge,fe]=e.useState([]),pe=e.useMemo(()=>{if(!_&&!L)return le;const e="function"==typeof h,t="function"==typeof g;return e||t?le.map(n=>{const o=Object.assign({},n);return e&&(o.__semiotic_resolvedX=h(n)),t&&(o.__semiotic_resolvedY=g(n)),o}):le},[le,_,L,h,g]),ye=e.useRef(_),me=e.useRef(L);e.useEffect(()=>{if(!_&&!L)return void((ye.current||me.current)&&(he(null),fe([]),ye.current=_,me.current=L));let e=!1;const t=_!==ye.current||L!==me.current;if(ye.current=_,me.current=L,t&&(he(null),fe([])),_){const t=f&&"string"==typeof f&&"object"==typeof _?Object.assign(Object.assign({},_),{_groupBy:f}):_;(function(...e){return Go(this,void 0,void 0,function*(){return(yield Xo()).buildForecast(...e)})})(pe,ce,ue,t,L).then(t=>{e||(he(t),fe(t.annotations))}).catch(()=>{e||(he(null),fe([]))})}else L&&function(...e){return Go(this,void 0,void 0,function*(){return(yield Xo()).buildAnomalyAnnotations(...e)})}(L).then(t=>{e||(he(null),fe(t))}).catch(()=>{e||fe([])});return()=>{e=!0}},[pe,_,L,ce,ue]);const ve=de?de.processedData:le,be="__compoundGroup",xe=!(!_||!f),ke=xe?be:_?Yo:f,we=e.useMemo(()=>{if(!xe)return ve;const e="function"==typeof f?f:e=>e[f];return ve.map(t=>{const n=Object.assign({},t);return n[be]=`${e(t)}__${t[Yo]||"observed"}`,n})},[ve,xe,f]),Ae=xe?we:ve,Se=e.useMemo(()=>{if(!_)return;const e=_.upperBounds,t=_.lowerBounds;if(!e&&!t)return;const n="function"==typeof e?e:"string"==typeof e?t=>t[e]:null,o="function"==typeof t?t:"string"==typeof t?e=>e[t]:null;let r=1/0,i=-1/0;const a=de?de.processedData:le;for(const e of a){const t="function"==typeof g?g(e):+e[g];if(isFinite(t)&&(r>t&&(r=t),t>i&&(i=t)),n){const t=n(e);null!=t&&isFinite(t)&&(t>i&&(i=t),r>t&&(r=t))}if(o){const t=o(e);null!=t&&isFinite(t)&&(r>t&&(r=t),t>i&&(i=t))}}return isFinite(r)&&isFinite(i)?[r,i]:void 0},[_,de,le,g]),{activeSelectionHook:Oe,hoverSelectionHook:Ee,customHoverBehavior:Me,customClickBehavior:je,crosshairSourceId:Ce}=qn({selection:N,linkedHover:D,fallbackFields:m?["string"==typeof m?m:""]:[],onObservation:I,onClick:H,chartType:"LineChart",chartId:F,hoverHighlight:R,colorByField:"string"==typeof m?m:void 0}),Pe=Xn(D,Ce),Le=e.useCallback(e=>{const t="function"==typeof h?h(e):e[h],n="function"==typeof g?g(e):e[g];return null==t||null==n||Number.isNaN(t)||Number.isNaN(n)},[h,g]),_e=void 0!==(null===(o=Ae[0])||void 0===o?void 0:o[y]),Be=e.useMemo(()=>{if(_e)return Ae;if(ke){const e=Ae.reduce((e,t)=>{const n="function"==typeof ke?ke(t):t[ke];if(!e[n]){const o={[y]:[]};"string"==typeof ke&&(o[ke]=n),xe&&(o[Yo]=t[Yo],"string"==typeof f&&(o[f]=t[f])),e[n]=o}return e[n][y].push(t),e},{});return Object.values(e)}return[{[y]:Ae}]},[Ae,ke,y,_e]),{gapProcessedLineData:Te,hasGaps:Ne}=e.useMemo(()=>{if("interpolate"===P){let e=!1;const t=[];for(const n of Be){const o=(n[y]||[]).filter(t=>!Le(t)||(e=!0,!1));o.length>0&&t.push(Object.assign(Object.assign({},n),{[y]:o}))}return{gapProcessedLineData:t,hasGaps:e}}if("break"===P){let e=!1;const t=[];for(const n of Be){const o=n[y]||[];let r=[],i=0;const a=ke&&"string"==typeof ke?n[ke]:void 0;for(const s of o)if(Le(s))e=!0,r.length>0&&(t.push(Object.assign(Object.assign({},n),{[y]:r})),r=[],i++);else{const e=null!=a?`${a}__seg${i}`:"__seg"+i;r.push(Object.assign(Object.assign({},s),{_gapSegment:e}))}r.length>0&&t.push(Object.assign(Object.assign({},n),{[y]:r}))}return{gapProcessedLineData:t,hasGaps:e}}if("zero"===P){let e=!1;const t="string"==typeof g?g:"y",n=[];for(const o of Be){const r=o[y]||[],i=[];for(const n of r)Le(n)?(e=!0,i.push(Object.assign(Object.assign({},n),{[t]:0}))):i.push(n);n.push(Object.assign(Object.assign({},o),{[y]:i}))}return{gapProcessedLineData:n,hasGaps:e}}return{gapProcessedLineData:Be,hasGaps:!1}},[Be,P,y,Le,ke,g]),De=Gn(ve,m,v),Ie=e.useMemo(()=>{if(!m)return[];const e=new Set;for(const t of ve){const n="function"==typeof m?m(t):t[m];null!=n&&e.add(n+"")}return Array.from(e)},[ve,m]),He=Un(G,m,Ie),Re=e.useMemo(()=>Ee||(He.legendSelectionHook?He.legendSelectionHook:Oe),[Ee,He.legendSelectionHook,Oe]),We=e.useMemo(()=>(e,t)=>{const n={strokeWidth:S},o=!0===w||Array.isArray(w)&&null!=t&&w.includes(t);return m?De&&(n.stroke=B(e,m,De),o&&(n.fill=n.stroke,n.fillOpacity=A)):(n.stroke=V||Wn,o&&(n.fill=V||Wn,n.fillOpacity=A)),n},[m,De,S,w,A,V]),[Fe,ze]=e.useState(null);e.useEffect(()=>{if(!_)return void ze(null);let e=!1;return function(...e){return Go(this,void 0,void 0,function*(){return(yield Xo()).createSegmentLineStyle(...e)})}(We,_).then(t=>{e||ze(()=>t)}).catch(()=>{e||ze(null)}),()=>{e=!0}},[We,_]);const $e=Fe||We,Ge=e.useMemo(()=>Bn($e,Re,N),[$e,Re,N]),Ye=e.useMemo(()=>{if(x)return e=>{const t={r:k,fillOpacity:1};return m?De&&(t.fill=B(e.parentLine||e,m,De)):t.fill=V||Wn,t}},[x,k,m,De,V]),qe=Array.isArray(w)?"mixed":w?"area":"line",Xe="object"==typeof C?C:{},Ve=Xe.position||"end",Ue=Xe.fontSize||11,Ke=e.useMemo(()=>{var e,t;if(!C||!m)return[];const n="function"==typeof h?h:e=>e[h],o="function"==typeof g?g:e=>e[g],r="function"==typeof m?m:e=>e[m],i=new Map;for(const n of Te){const o=n[y]||[];if(0===o.length)continue;const a="end"===Ve?o[o.length-1]:o[0],s=null!==(t=null!==(e=r(a))&&void 0!==e?e:r(n))&&void 0!==t?t:"";s&&!i.has(s+"")&&i.set(s+"",a)}const a=Array.from(i.entries()).map(([e,t])=>({type:"text",label:e,["string"==typeof h?h:"x"]:n(t),["string"==typeof g?g:"y"]:o(t),dx:"end"===Ve?6:-6,dy:0,color:De?De(e):Wn,fontSize:Ue}));a.sort((e,t)=>{const n="string"==typeof g?g:"y";return e[n]-t[n]});for(let e=1;a.length>e;e++){const t="string"==typeof g?g:"y",n=a[e-1],o=a[e];Ue+2>Math.abs(o[t]+o.dy-(n[t]+n.dy))&&(o.dy+=Ue+2)}return a},[C,m,De,Te,y,h,g,Ve,Ue]),Qe=(!C||void 0!==J)&&J,Ze=e.useMemo(()=>{if(!C)return a.marginDefaults;const e=Ke.reduce((e,t)=>{var n;const o=((null===(n=t.label)||void 0===n?void 0:n.length)||0)*(.6*Ue);return Math.max(e,o)},0),t=e+10,n="end"===Ve?"right":"left";return Object.assign(Object.assign({},a.marginDefaults),{[n]:Math.max(a.marginDefaults[n]||0,t)})},[C,Ke,Ue,Ve,a.marginDefaults]),{legend:Je,margin:et,legendPosition:tt}=Vn({data:Te,colorBy:m,colorScale:De,showLegend:Qe,legendPosition:Y,userMargin:l,defaults:Ze}),nt=f||m,ot=e.useMemo(()=>so([{label:re||ro(h),accessor:h,role:"x"},{label:ie||ro(g),accessor:g,role:"y"},...nt?[{label:ro(nt),accessor:nt,role:"group"}]:[]]),[h,g,re,ie,nt]),rt=yo({componentName:"LineChart",data:_e?(null===(r=ve[0])||void 0===r?void 0:r[y])||[]:s,accessors:{xAccessor:h,yAccessor:g}}),it=e.useMemo(()=>_e||ke||Ne?Te.flatMap(e=>{const t=e[y]||[];return ke&&"string"==typeof ke?t.map(t=>Object.assign(Object.assign({},t),{[ke]:e[ke]})):t}):Ae,[Te,y,_e,ke,Ae,Ne]),at=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:qe},Array.isArray(w)&&{areaGroups:w}),O&&{lineGradient:O}),null!=W&&{hoverRadius:W}),null!=s&&{data:it}),{xAccessor:h,yAccessor:g,xScaleType:q,yScaleType:X}),Se&&{yExtent:Se}),{groupAccessor:"break"===P&&Ne?"_gapSegment":ke||void 0,curve:b,lineStyle:Ge}),x&&{pointStyle:Ye}),{size:[U,K],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:et,showAxes:a.showAxes,xLabel:re,yLabel:ie,xFormat:u,yFormat:d,enableHover:Q,showGrid:Z}),Je&&{legend:Je,legendPosition:tt}),G&&"none"!==G&&{legendHoverBehavior:He.onLegendHover,legendClickBehavior:He.onLegendClick,legendHighlightedCategory:He.highlightedCategory,legendIsolatedCategories:He.isolatedCategories}),ee&&{title:ee}),te&&{description:te}),ne&&{summary:ne}),void 0!==oe&&{accessibleTable:oe}),c&&{className:c}),{tooltipContent:!1===E?()=>null:"multi"===E?e=>{var t,n,o,r,i,a,s,l,c,u;const d=e.allSeries;if(!d||0===d.length){const a=null!==(i=null!==(r=null!==(n=null===(t=e.data)||void 0===t?void 0:t.value)&&void 0!==n?n:null===(o=e.data)||void 0===o?void 0:o.y)&&void 0!==r?r:e.value)&&void 0!==i?i:e.y;return p.createElement("div",{className:"semiotic-tooltip",style:Jn},p.createElement("div",null,to(a)))}const h=null!==(u=null!==(l=null!==(a=e.xValue)&&void 0!==a?a:null===(s=e.data)||void 0===s?void 0:s.time)&&void 0!==l?l:null===(c=e.data)||void 0===c?void 0:c.x)&&void 0!==u?u:e.time;return p.createElement("div",{className:"semiotic-tooltip",style:Jn},null!=h&&p.createElement("div",{style:{fontWeight:600,marginBottom:4,fontSize:"0.9em",borderBottom:"1px solid var(--semiotic-border, #eee)",paddingBottom:4}},to(h)),d.map((e,t)=>p.createElement("div",{key:t,style:{display:"flex",alignItems:"center",gap:6,padding:"1px 0"}},p.createElement("span",{style:{width:8,height:8,borderRadius:"50%",backgroundColor:e.color,flexShrink:0}}),p.createElement("span",{style:{flex:1,fontSize:"0.85em"}},e.group),p.createElement("span",{style:{fontWeight:500,fontSize:"0.85em"}},to(e.value)))))}:oo(E)||ot}),"multi"===E&&{tooltipMode:"multi"}),(D||I||H||R)&&{customHoverBehavior:Me}),(I||H||D)&&{customClickBehavior:je}),M&&{pointIdAccessor:M}),((null==j?void 0:j.length)||ge.length||Ke.length)&&{annotations:[...j||[],...ge,...Ke]}),Pe),T);return ae||se||(rt?p.createElement(co,{componentName:"LineChart",message:rt,width:U,height:K}):p.createElement(Ho,{componentName:"LineChart",width:U,height:K},p.createElement(hn,Object.assign({ref:i},at))))});Vo.displayName="LineChart";const Uo=e.forwardRef(function(t,n){var o;const r=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=r.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const i=Qn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:a,margin:s,className:l,xFormat:c,yFormat:u,xAccessor:d="x",yAccessor:h="y",areaBy:g,y0Accessor:f,gradientFill:y=!1,lineDataAccessor:m="coordinates",colorBy:v,colorScheme:b,curve:x="monotoneX",areaOpacity:k=.7,lineGradient:w,showLine:A=!0,lineWidth:S=2,showPoints:O=!1,pointRadius:E=3,tooltip:M,annotations:j,frameProps:C={},selection:P,linkedHover:L,onObservation:_,onClick:T,hoverHighlight:N,chartId:D,loading:I,emptyContent:H,legendInteraction:R,legendPosition:W,color:F}=t,z=i.width,$=i.height,G=i.enableHover,Y=i.showGrid,q=i.showLegend,X=i.title,V=i.description,U=i.summary,K=i.accessibleTable,Q=i.xLabel,Z=i.yLabel,J=zo(I,z,$),ee=J?null:Fo(a,z,$,H),te=a||[];$o("AreaChart",te,"xAccessor",d),$o("AreaChart",te,"yAccessor",h);const{activeSelectionHook:ne,hoverSelectionHook:oe,customHoverBehavior:re,customClickBehavior:ie,crosshairSourceId:ae}=qn({selection:P,linkedHover:L,fallbackFields:v?["string"==typeof v?v:""]:[],onObservation:_,onClick:T,chartType:"AreaChart",chartId:D,hoverHighlight:N,colorByField:"string"==typeof v?v:void 0}),se=Xn(L,ae),le=void 0!==(null===(o=te[0])||void 0===o?void 0:o[m]),ce=e.useMemo(()=>{if(le)return te;if(g){const e=te.reduce((e,t)=>{const n="function"==typeof g?g(t):t[g];if(!e[n]){const t={[m]:[]};"string"==typeof g&&(t[g]=n),e[n]=t}return e[n][m].push(t),e},{});return Object.values(e)}return[{[m]:te}]},[te,g,m,le]),ue=Gn(te,v,b),de=e.useMemo(()=>{if(!v)return[];const e=new Set;for(const t of te){const n="function"==typeof v?v(t):t[v];null!=n&&e.add(n+"")}return Array.from(e)},[te,v]),he=Un(R,v,de),ge=e.useMemo(()=>oe||(he.legendSelectionHook?he.legendSelectionHook:ne),[oe,he.legendSelectionHook,ne]),fe=e.useMemo(()=>e=>{const t={};if(v){if(ue){const n=B(e,v,ue);t.fill=n,A?(t.stroke=n,t.strokeWidth=S):t.stroke="none"}}else{const e=F||Wn;t.fill=e,A?(t.stroke=e,t.strokeWidth=S):t.stroke="none"}return t.fillOpacity=k,t},[v,ue,F,k,A,S]),pe=e.useMemo(()=>Bn(fe,ge,P),[fe,ge,P]),ye=e.useMemo(()=>{if(O)return e=>{const t={r:E,fillOpacity:1};return v?ue&&(t.fill=B(e.parentLine||e,v,ue)):t.fill=Wn,t}},[O,E,v,ue]),{legend:me,margin:ve,legendPosition:be}=Vn({data:ce,colorBy:v,colorScale:ue,showLegend:q,legendPosition:W,userMargin:s,defaults:i.marginDefaults}),xe=g||v,ke=e.useMemo(()=>so([{label:Q||ro(d),accessor:d,role:"x"},{label:Z||ro(h),accessor:h,role:"y"},...xe?[{label:ro(xe),accessor:xe,role:"group"}]:[]]),[d,h,Q,Z,xe]),we=yo({componentName:"AreaChart",data:a,accessors:{xAccessor:d,yAccessor:h}}),Ae=e.useMemo(()=>le||g?ce.flatMap(e=>{const t=e[m]||[];return g&&"string"==typeof g?t.map(t=>Object.assign(Object.assign({},t),{[g]:e[g]})):t}):te,[ce,m,le,g,te]),Se=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"area"},null!=a&&{data:Ae}),{xAccessor:d,yAccessor:h,groupAccessor:g||void 0}),f&&{y0Accessor:f}),y&&{gradientFill:y}),w&&{lineGradient:w}),{curve:x,lineStyle:pe}),O&&ye&&{pointStyle:ye}),{size:[z,$],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:ve,showAxes:i.showAxes,xLabel:Q,yLabel:Z,xFormat:c,yFormat:u,enableHover:G}),t.pointIdAccessor&&{pointIdAccessor:t.pointIdAccessor}),{showGrid:Y}),me&&{legend:me,legendPosition:be}),R&&"none"!==R&&{legendHoverBehavior:he.onLegendHover,legendClickBehavior:he.onLegendClick,legendHighlightedCategory:he.highlightedCategory,legendIsolatedCategories:he.isolatedCategories}),X&&{title:X}),V&&{description:V}),U&&{summary:U}),void 0!==K&&{accessibleTable:K}),l&&{className:l}),{tooltipContent:!1===M?()=>null:oo(M)||ke}),(L||_||T||N)&&{customHoverBehavior:re}),(_||T||L)&&{customClickBehavior:ie}),j&&j.length>0&&{annotations:j}),se),C);return J||ee||(we?p.createElement(co,{componentName:"AreaChart",message:we,width:z,height:$}):p.createElement(Ho,{componentName:"AreaChart",width:z,height:$},p.createElement(hn,Object.assign({ref:r},Se))))});function Ko({isPushMode:t,colorBy:n,colorScheme:o,showLegend:r,legendPosition:i="right"}){const a=e.useRef(new Set),s=e.useRef([]),[l,c]=e.useState(0),u=e.useCallback(e=>{if(!n)return null;const t="function"==typeof n?n(e):e[n];return null!=t?t+"":null},[n]),d=e.useCallback(e=>{if(!t||!n)return;let o=!1;for(const t of e){if(!t||"object"!=typeof t)continue;const e=u(t);null==e||a.current.has(e)||(a.current.add(e),s.current.push(e),o=!0)}o&&c(e=>e+1)},[t,n,u]),h=e.useCallback(e=>t=>{d([t]),e(t)},[d]),g=e.useCallback(e=>t=>{d(t),e(t)},[d]),f=e.useCallback(()=>{a.current=new Set,s.current=[],c(e=>e+1)},[]),p=e.useMemo(()=>{if(!t||!n||!1===r)return;const e=s.current;if(0===e.length)return;const i=Array.isArray(o)?o:P,a=new Map;for(let t=0;e.length>t;t++)a.set(e[t],i[t%i.length]);const l="string"==typeof n?n:"__streamCat";return Ln({data:e.map(e=>({[l]:e})),colorBy:l,colorScale:e=>a.get(e)||"#999",getColor:B})},[t,n,r,o,l]),y=e.useMemo(()=>{if(p)return"right"===i?{right:110}:"left"===i?{left:110}:"top"===i?{top:50}:"bottom"===i?{bottom:80}:{right:110}},[p,i]);return{wrapPush:h,wrapPushMany:g,resetCategories:f,streamingLegend:p,streamingMarginAdjust:y}}Uo.displayName="AreaChart";const Qo=e.forwardRef(function(t,n){var o;const r=e.useRef(null),i=Qn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:a,margin:s,className:l,xFormat:c,yFormat:u,xAccessor:d="x",yAccessor:h="y",areaBy:g,lineDataAccessor:f="coordinates",colorBy:y,colorScheme:m,curve:v="monotoneX",areaOpacity:b=.7,showLine:x=!0,lineWidth:k=2,showPoints:w=!1,pointRadius:A=3,normalize:S=!1,tooltip:O,annotations:E,frameProps:M={},selection:j,linkedHover:C,onObservation:P,onClick:L,hoverHighlight:_,chartId:T,loading:N,emptyContent:D,legendInteraction:I,legendPosition:H,color:R}=t,W=i.width,F=i.height,z=i.enableHover,$=i.showGrid,G=i.showLegend,Y=i.title,q=i.description,X=i.summary,V=i.accessibleTable,U=i.xLabel,K=i.yLabel,Q=zo(N,W,F),Z=Q?null:Fo(a,W,F,D),J=a||[],ee=Ko({isPushMode:void 0===a,colorBy:y||g,colorScheme:m,showLegend:G,legendPosition:H}),te=e.useCallback(ee.wrapPush(e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)}),[ee.wrapPush]),ne=e.useCallback(ee.wrapPushMany(e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)}),[ee.wrapPushMany]);e.useImperativeHandle(n,()=>({push:te,pushMany:ne,remove:e=>{var t,n;return null!==(n=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=r.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;ee.resetCategories(),null===(e=r.current)||void 0===e||e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}),[te,ne,ee.resetCategories]);const{activeSelectionHook:oe,hoverSelectionHook:re,customHoverBehavior:ie,customClickBehavior:ae,crosshairSourceId:se}=qn({selection:j,linkedHover:C,fallbackFields:y?["string"==typeof y?y:""]:[],onObservation:P,onClick:L,chartType:"StackedAreaChart",chartId:T,hoverHighlight:_,colorByField:"string"==typeof y?y:void 0}),le=Xn(C,se),ce=void 0!==(null===(o=J[0])||void 0===o?void 0:o[f]),ue=e.useMemo(()=>{if(ce)return J;if(g){const e=J.reduce((e,t)=>{const n="function"==typeof g?g(t):t[g];if(!e[n]){const t={[f]:[]};"string"==typeof g&&(t[g]=n),e[n]=t}return e[n][f].push(t),e},{});return Object.values(e)}return[{[f]:J}]},[J,g,f,ce]),de=Gn(J,y,m),he=e.useMemo(()=>{if(!y)return[];const e=new Set;for(const t of J){const n="function"==typeof y?y(t):t[y];null!=n&&e.add(n+"")}return Array.from(e)},[J,y]),ge=Un(I,y,he),fe=e.useMemo(()=>re||(ge.legendSelectionHook?ge.legendSelectionHook:oe),[re,ge.legendSelectionHook,oe]),pe=e.useMemo(()=>e=>{const t={};if(y&&de){const n=B(e,y,de);t.fill=n,x?(t.stroke=n,t.strokeWidth=k):t.stroke="none"}else if(!y){const e=R||Wn;t.fill=e,t.stroke=x?e:"none",x&&(t.strokeWidth=k)}return t.fillOpacity=b,t},[y,de,b,x,k,R]),ye=e.useMemo(()=>Bn(pe,fe,j),[pe,fe,j]),me=e.useMemo(()=>{if(w)return e=>{const t={r:A,fillOpacity:1};return y?de&&(t.fill=B(e.parentLine||e,y,de)):t.fill=R||Wn,t}},[w,A,y,de,R]),{legend:ve,margin:be,legendPosition:xe}=Vn({data:ue,colorBy:y,colorScale:de,showLegend:G,legendPosition:H,userMargin:s,defaults:i.marginDefaults}),ke=ee.streamingLegend||ve,we=H||xe,Ae=e.useMemo(()=>{if(ee.streamingMarginAdjust){const e=Object.assign({},be);for(const[t,n]of Object.entries(ee.streamingMarginAdjust))n>e[t]&&(e[t]=n);return e}return be},[be,ee.streamingMarginAdjust]),Se=g||y,Oe=e.useMemo(()=>so([{label:U||ro(d),accessor:d,role:"x"},{label:K||ro(h),accessor:h,role:"y"},...Se?[{label:ro(Se),accessor:Se,role:"group"}]:[]]),[d,h,U,K,Se]),Ee=yo({componentName:"StackedAreaChart",data:a,accessors:{xAccessor:d,yAccessor:h}}),Me=e.useMemo(()=>ce||g?ue.flatMap(e=>{const t=e[f]||[];return g&&"string"==typeof g?t.map(t=>Object.assign(Object.assign({},t),{[g]:e[g]})):t}):J,[ue,f,ce,g,J]),je=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"stackedarea"},null!=a&&{data:Me}),{xAccessor:d,yAccessor:h,groupAccessor:g||void 0,curve:v,normalize:S,lineStyle:ye}),w&&me&&{pointStyle:me}),{size:[W,F],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Ae,showAxes:i.showAxes,xLabel:U,yLabel:K,xFormat:c,yFormat:u,enableHover:z}),t.pointIdAccessor&&{pointIdAccessor:t.pointIdAccessor}),{showGrid:$}),ke&&{legend:ke,legendPosition:we}),I&&"none"!==I&&{legendHoverBehavior:ge.onLegendHover,legendClickBehavior:ge.onLegendClick,legendHighlightedCategory:ge.highlightedCategory,legendIsolatedCategories:ge.isolatedCategories}),Y&&{title:Y}),q&&{description:q}),X&&{summary:X}),void 0!==V&&{accessibleTable:V}),l&&{className:l}),{tooltipContent:!1===O?()=>null:oo(O)||Oe}),(C||P||L||_)&&{customHoverBehavior:ie}),(P||L||C)&&{customClickBehavior:ae}),E&&E.length>0&&{annotations:E}),le),M);return Q||Z||(Ee?p.createElement(co,{componentName:"StackedAreaChart",message:Ee,width:W,height:F}):p.createElement(Ho,{componentName:"StackedAreaChart",width:W,height:F},p.createElement(hn,Object.assign({ref:r},je))))});function Zo(t){const{data:n,rawData:o,colorBy:r,colorScheme:i,legendInteraction:a,legendPosition:s,selection:l,linkedHover:c,fallbackFields:u,unwrapData:d=!1,onObservation:h,chartType:g,chartId:f,showLegend:p,userMargin:y,marginDefaults:m,onClick:v,hoverHighlight:b,loading:x,emptyContent:k,width:w,height:A}=t,S="string"==typeof t.colorBy?t.colorBy:void 0,{activeSelectionHook:O,hoverSelectionHook:E,customHoverBehavior:M,customClickBehavior:j,crosshairSourceId:C}=qn({selection:l,linkedHover:c,fallbackFields:u,unwrapData:d,onObservation:h,chartType:g,chartId:f,onClick:v,hoverHighlight:b,colorByField:S}),P=Xn(c,C),L=Gn(n,r,i),_=e.useMemo(()=>{if(!r)return[];const e=new Set;for(const t of n){const n="function"==typeof r?r(t):t[r];null!=n&&e.add(n+"")}return Array.from(e)},[n,r]),B=Un(a,r,_),T=e.useMemo(()=>E||(B.legendSelectionHook?B.legendSelectionHook:O),[E,B.legendSelectionHook,O]),{legend:N,margin:D,legendPosition:I}=Vn({data:n,colorBy:r,colorScale:L,showLegend:p,legendPosition:s,userMargin:y,defaults:m}),H=e.useMemo(()=>{const e={};return N&&(e.legend=N,e.legendPosition=I),a&&"none"!==a&&(e.legendHoverBehavior=B.onLegendHover,e.legendClickBehavior=B.onLegendClick,e.legendHighlightedCategory=B.highlightedCategory,e.legendIsolatedCategories=B.isolatedCategories),e},[N,I,a,B.onLegendHover,B.onLegendClick,B.highlightedCategory,B.isolatedCategories]),R=zo(x,w,A),W=R?null:Fo(o,w,A,k);return{colorScale:L,allCategories:_,legendState:B,effectiveSelectionHook:T,activeSelectionHook:O,customHoverBehavior:M,customClickBehavior:j,legend:N,margin:D,legendPosition:I,earlyReturn:R||W||null,legendBehaviorProps:H,crosshairProps:P}}Qo.displayName="StackedAreaChart";const Jo=e.forwardRef(function(t,n){const o=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=o.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,r;return null!==(r=null===(n=o.current)||void 0===n?void 0:n.update(e,t))&&void 0!==r?r:[]},clear:()=>{var e;return null===(e=o.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=o.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const r=Qn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:i,margin:a,className:s,xFormat:l,yFormat:c,xAccessor:u="x",yAccessor:d="y",colorBy:h,colorScheme:g,sizeBy:f,sizeRange:y=[3,15],pointRadius:m=5,pointOpacity:v=.8,tooltip:b,marginalGraphics:x,pointIdAccessor:k,annotations:w,frameProps:A={},selection:S,linkedHover:O,linkedBrush:E,onObservation:M,onClick:j,hoverHighlight:C,chartId:P,loading:L,emptyContent:_,legendInteraction:T,legendPosition:D,color:I}=t,H=r.width,R=r.height,W=r.enableHover,F=r.showGrid,z=r.title,$=r.description,G=r.summary,Y=r.accessibleTable,q=r.xLabel,X=r.yLabel,V=i||[],U=Zo({data:V,rawData:i,colorBy:h,colorScheme:g,legendInteraction:T,legendPosition:D,selection:S,linkedHover:O,fallbackFields:h?["string"==typeof h?h:""]:[],unwrapData:!1,onObservation:M,onClick:j,hoverHighlight:C,chartType:"Scatterplot",chartId:P,showLegend:r.showLegend,userMargin:a,marginDefaults:r.marginDefaults,loading:L,emptyContent:_,width:H,height:R}),K=_n(E),Q=On({name:(null==K?void 0:K.name)||"__unused_brush__",xField:(null==K?void 0:K.xField)||("string"==typeof u?u:void 0),yField:(null==K?void 0:K.yField)||("string"==typeof d?d:void 0)}),Z=K?"xyBrush"===Q.brushInteraction.brush?"xy":"xBrush"===Q.brushInteraction.brush?"x":"y":void 0,J=p.useRef(Q.brushInteraction);J.current=Q.brushInteraction;const ee=e.useCallback(e=>{const t=J.current;t.end(e?"xyBrush"===t.brush?[[e.x[0],e.y[0]],[e.x[1],e.y[1]]]:"xBrush"===t.brush?e.x:e.y:null)},[]);if(U.earlyReturn)return U.earlyReturn;$o("Scatterplot",V,"xAccessor",u),$o("Scatterplot",V,"yAccessor",d);const te=e.useMemo(()=>{if(!f||0===V.length)return;const e=V.map(e=>"function"==typeof f?f(e):e[f]);return[Math.min(...e),Math.max(...e)]},[V,f]),ne=e.useMemo(()=>e=>{const t={fillOpacity:v};return h?U.colorScale&&(t.fill=B(e,h,U.colorScale)):t.fill=I||Wn,t.r=f?N(e,f,y,te):m,t},[h,U.colorScale,f,y,te,m,v,I]),oe=e.useMemo(()=>Bn(ne,U.effectiveSelectionHook,S),[ne,U.effectiveSelectionHook,S]),re=e.useMemo(()=>so([{label:q||ro(u),accessor:u,role:"x"},{label:X||ro(d),accessor:d,role:"y"},...h?[{label:ro(h),accessor:h,role:"color"}]:[],...f?[{label:ro(f),accessor:f,role:"size"}]:[]]),[u,d,q,X,h,f]),ie=yo({componentName:"Scatterplot",data:i,accessors:{xAccessor:u,yAccessor:d}});if(ie)return p.createElement(co,{componentName:"Scatterplot",message:ie,width:H,height:R});const ae=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter"},null!=i&&{data:V}),{xAccessor:u,yAccessor:d,colorAccessor:h||void 0,sizeAccessor:f||void 0,sizeRange:y,pointStyle:oe,colorScheme:g,size:[H,R],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:U.margin,showAxes:r.showAxes,xLabel:q,yLabel:X,xFormat:l,yFormat:c,enableHover:W,showGrid:F}),U.legendBehaviorProps),z&&{title:z}),$&&{description:$}),G&&{summary:G}),void 0!==Y&&{accessibleTable:Y}),s&&{className:s}),{tooltipContent:!1===b?()=>null:oo(b)||re}),(O||M||j||C)&&{customHoverBehavior:U.customHoverBehavior}),(M||j||O)&&{customClickBehavior:U.customClickBehavior}),x&&{marginalGraphics:x}),k&&{pointIdAccessor:k}),w&&w.length>0&&{annotations:w}),K&&{brush:{dimension:Z},onBrush:ee}),U.crosshairProps),A);return p.createElement(Ho,{componentName:"Scatterplot",width:H,height:R},p.createElement(hn,Object.assign({ref:o},ae)))});function er(e,t){return i.interpolateViridis(1===t?.5:e/(t-1))}Jo.displayName="Scatterplot";const tr=e.forwardRef(function(t,n){const o=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=o.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,r;return null!==(r=null===(n=o.current)||void 0===n?void 0:n.update(e,t))&&void 0!==r?r:[]},clear:()=>{var e;return null===(e=o.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=o.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const r=Qn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:i,className:a,xFormat:s,yFormat:l,xAccessor:c="x",yAccessor:u="y",orderAccessor:d,orderLabel:h,pointRadius:g=4,tooltip:f,pointIdAccessor:y,annotations:m,frameProps:v={},selection:b,linkedHover:x,onObservation:k,onClick:w,hoverHighlight:A,chartId:S,loading:O,emptyContent:E,legendInteraction:M}=t,j=r.width,C=r.height,P=r.enableHover,L=r.showGrid,_=r.title,B=r.description,T=r.summary,N=r.accessibleTable,D=r.xLabel,I=r.yLabel,H=i||[],{safeData:R,orderMap:W}=e.useMemo(()=>{const e="function"==typeof c?c:e=>e[c],t="function"==typeof u?u:e=>e[u];let n=H;if(d&&H.length>0){const e="function"==typeof d?d:e=>e[d];n=[...H].sort((t,n)=>{const o=e(t),r=e(n);return(o instanceof Date?o.getTime():+o)-(r instanceof Date?r.getTime():+r)})}const o=new WeakMap;let r=0;for(const o of n){const n=e(o),i=t(o);null!=n&&null!=i&&isFinite(n)&&isFinite(i)&&r++}let i=0;for(const a of n){const n=e(a),s=t(a);null!=n&&null!=s&&isFinite(n)&&isFinite(s)&&o.set(a,{idx:i++,total:r})}return{safeData:n,orderMap:o}},[H,d,c,u]);$o("ConnectedScatterplot",R,"xAccessor",c),$o("ConnectedScatterplot",R,"yAccessor",u);const{activeSelectionHook:F,hoverSelectionHook:z,customHoverBehavior:$,customClickBehavior:G,crosshairSourceId:Y}=qn({selection:b,linkedHover:x,fallbackFields:[],onObservation:k,onClick:w,chartType:"ConnectedScatterplot",chartId:S,hoverHighlight:A,colorByField:void 0}),q=Xn(x,Y),X=Un(M,void 0,[]),V=e.useMemo(()=>z||(X.legendSelectionHook?X.legendSelectionHook:F),[z,X.legendSelectionHook,F]),U=e.useMemo(()=>(e,t)=>{var n,o;const r=t.filter(e=>"point"===e.type);if(2>r.length)return;const i=null==V?void 0:V.isActive,a=null==V?void 0:V.predicate,s=100>r.length,l=r.length;e.lineCap="round";for(let t=0;l-1>t;t++){const c=r[t],u=r[t+1],d=er(t,l),h=!i||!a||a(null!==(n=c.datum)&&void 0!==n?n:c)||a(null!==(o=u.datum)&&void 0!==o?o:u),f=i?h?1:.2:1;s&&(e.beginPath(),e.moveTo(c.x,c.y),e.lineTo(u.x,u.y),e.strokeStyle="white",e.lineWidth=g+2,e.globalAlpha=.5*f,e.stroke()),e.beginPath(),e.moveTo(c.x,c.y),e.lineTo(u.x,u.y),e.strokeStyle=d,e.lineWidth=g,e.globalAlpha=f,e.stroke()}e.globalAlpha=1},[g,V]),K=e.useMemo(()=>[U],[U]),Q=e.useMemo(()=>(e,t,n)=>{var o,r;const i=e.filter(e=>"point"===e.type);if(2>i.length)return null;const a=i.length,s=100>a,l=[];for(let e=0;a-1>e;e++){const t=i[e],n=i[e+1],c=er(e,a),u="number"==typeof(null===(o=t.style)||void 0===o?void 0:o.opacity)?t.style.opacity:1,d="number"==typeof(null===(r=n.style)||void 0===r?void 0:r.opacity)?n.style.opacity:1,h=Math.min(u,d);s&&l.push(p.createElement("line",{key:"halo-"+e,x1:t.x,y1:t.y,x2:n.x,y2:n.y,stroke:"white",strokeWidth:g+2,strokeLinecap:"round",opacity:.5*h})),l.push(p.createElement("line",{key:"seg-"+e,x1:t.x,y1:t.y,x2:n.x,y2:n.y,stroke:c,strokeWidth:g,strokeLinecap:"round",opacity:h}))}return p.createElement(p.Fragment,null,l)},[g]),Z=e.useMemo(()=>[Q],[Q]),J=e.useMemo(()=>e=>{var t,n;const o=W.get(e),r=null!==(t=null==o?void 0:o.idx)&&void 0!==t?t:0,i=null!==(n=null==o?void 0:o.total)&&void 0!==n?n:1;return{fill:i>0?er(r,i):"#6366f1",stroke:"white",strokeWidth:1,r:g,fillOpacity:1}},[g,W]),ee=e.useMemo(()=>Bn(J,V,b),[J,V,b]),te=Object.assign({top:50,right:40,bottom:60,left:70},t.margin),ne=h||("string"==typeof d?d:"Order"),oe=e.useMemo(()=>so([{label:D||ro(c),accessor:c,role:"x"},{label:I||ro(u),accessor:u,role:"y"},...d?[{label:ne,accessor:d,role:"group"}]:[]]),[c,u,D,I,d,ne]),re=yo({componentName:"ConnectedScatterplot",data:i,accessors:{xAccessor:c,yAccessor:u}}),ie=zo(O,j,C),ae=ie?null:Fo(i,j,C,E),se=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter"},null!=i&&{data:R}),{xAccessor:c,yAccessor:u,pointStyle:ee,size:[j,C],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:te,showAxes:r.showAxes,xLabel:D,yLabel:I,xFormat:s,yFormat:l,enableHover:P,showGrid:L}),_&&{title:_}),B&&{description:B}),T&&{summary:T}),void 0!==N&&{accessibleTable:N}),a&&{className:a}),{tooltipContent:!1===f?()=>null:oo(f)||oe}),(x||k||w||A)&&{customHoverBehavior:$}),(k||w||x)&&{customClickBehavior:G}),y&&{pointIdAccessor:y}),{canvasPreRenderers:K,svgPreRenderers:Z}),m&&m.length>0&&{annotations:m}),q),v);return ie||ae||(re?p.createElement(co,{componentName:"ConnectedScatterplot",message:re,width:j,height:C}):p.createElement(Ho,{componentName:"ConnectedScatterplot",width:j,height:C},p.createElement(hn,Object.assign({ref:o},se))))});tr.displayName="ConnectedScatterplot";const nr=e.forwardRef(function(t,n){const o=e.useRef(null),r=Qn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:i,margin:a,className:s,xFormat:l,yFormat:c,xAccessor:u="x",yAccessor:d="y",sizeBy:h,sizeRange:g=[5,40],colorBy:f,colorScheme:y,bubbleOpacity:m=.6,bubbleStrokeWidth:v=1,bubbleStrokeColor:b="white",tooltip:x,marginalGraphics:k,pointIdAccessor:w,annotations:A,frameProps:S={},selection:O,linkedHover:E,linkedBrush:M,onObservation:j,onClick:C,hoverHighlight:P,chartId:L,loading:_,emptyContent:T,legendInteraction:D,legendPosition:I,color:H}=t,R=r.width,W=r.height,F=r.enableHover,z=r.showGrid,$=r.showLegend,G=r.title,Y=r.description,q=r.summary,X=r.accessibleTable,V=r.xLabel,U=r.yLabel,K=zo(_,R,W),Q=K?null:Fo(i,R,W,T),Z=i||[],J=void 0===i,ee=e.useRef(null),[te,ne]=e.useState(0),oe=e.useCallback(e=>{if(!J)return;let t=!1;for(const n of e){const e="function"==typeof h?h(n):n[h];null!=e&&isFinite(e)&&(ee.current?(ee.current[0]>e&&(ee.current[0]=e,t=!0),e>ee.current[1]&&(ee.current[1]=e,t=!0)):(ee.current=[e,e],t=!0))}t&&ne(e=>e+1)},[J,h]),re=Ko({isPushMode:J,colorBy:f,colorScheme:y,showLegend:$,legendPosition:I}),ie=e.useCallback(re.wrapPush(e=>{var t;oe([e]),null===(t=o.current)||void 0===t||t.push(e)}),[re.wrapPush,oe]),ae=e.useCallback(re.wrapPushMany(e=>{var t;oe(e),null===(t=o.current)||void 0===t||t.pushMany(e)}),[re.wrapPushMany,oe]);e.useImperativeHandle(n,()=>({push:ie,pushMany:ae,remove:e=>{var t,n;return null!==(n=null===(t=o.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,r;return null!==(r=null===(n=o.current)||void 0===n?void 0:n.update(e,t))&&void 0!==r?r:[]},clear:()=>{var e;re.resetCategories(),ee.current=null,ne(e=>e+1),null===(e=o.current)||void 0===e||e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=o.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}),[ie,ae,re.resetCategories]);const{activeSelectionHook:se,hoverSelectionHook:le,customHoverBehavior:ce,customClickBehavior:ue,crosshairSourceId:de}=qn({selection:O,linkedHover:E,fallbackFields:f?["string"==typeof f?f:""]:[],onObservation:j,onClick:C,chartType:"BubbleChart",chartId:L,hoverHighlight:P,colorByField:"string"==typeof f?f:void 0}),he=Xn(E,de),ge=_n(M);On({name:(null==ge?void 0:ge.name)||"__unused_brush__",xField:(null==ge?void 0:ge.xField)||("string"==typeof u?u:void 0),yField:(null==ge?void 0:ge.yField)||("string"==typeof d?d:void 0)});const fe=Gn(Z,f,y),pe=e.useMemo(()=>{if(!f)return[];const e=new Set;for(const t of Z){const n="function"==typeof f?f(t):t[f];null!=n&&e.add(n+"")}return Array.from(e)},[Z,f]),ye=Un(D,f,pe),me=e.useMemo(()=>le||(ye.legendSelectionHook?ye.legendSelectionHook:se),[le,ye.legendSelectionHook,se]),ve=e.useMemo(()=>{if(J)return ee.current||[0,1];const e=Z.map(e=>"function"==typeof h?h(e):e[h]);return[Math.min(...e),Math.max(...e)]},[Z,h,J,te]),be=e.useMemo(()=>e=>{const t={fillOpacity:m,strokeWidth:v,stroke:b};return f?fe&&(t.fill=B(e,f,fe)):t.fill=H||Wn,t.r=N(e,h,g,ve),t},[f,fe,h,g,ve,m,v,b,H]),xe=e.useMemo(()=>Bn(be,me,O),[be,me,O]),{legend:ke,margin:we,legendPosition:Ae}=Vn({data:Z,colorBy:f,colorScale:fe,showLegend:$,legendPosition:I,userMargin:a,defaults:r.marginDefaults}),Se=re.streamingLegend||ke,Oe=I||Ae,Ee=e.useMemo(()=>{if(re.streamingMarginAdjust){const e=Object.assign({},we);for(const[t,n]of Object.entries(re.streamingMarginAdjust))n>e[t]&&(e[t]=n);return e}return we},[we,re.streamingMarginAdjust]),Me=e.useMemo(()=>so([{label:V||ro(u),accessor:u,role:"x"},{label:U||ro(d),accessor:d,role:"y"},{label:ro(h),accessor:h,role:"size"},...f?[{label:ro(f),accessor:f,role:"color"}]:[]]),[u,d,V,U,h,f]),je=yo({componentName:"BubbleChart",data:i,accessors:{xAccessor:u,yAccessor:d},requiredProps:{sizeBy:h}});if(je)return p.createElement(co,{componentName:"BubbleChart",message:je,width:R,height:W});const Ce=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bubble"},null!=i&&{data:Z}),{xAccessor:u,yAccessor:d,colorAccessor:f||void 0,sizeAccessor:h,sizeRange:g,pointStyle:xe,colorScheme:y,size:[R,W],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Ee,showAxes:r.showAxes,xLabel:V,yLabel:U,xFormat:l,yFormat:c,enableHover:F,showGrid:z}),Se&&{legend:Se,legendPosition:Oe}),D&&"none"!==D&&{legendHoverBehavior:ye.onLegendHover,legendClickBehavior:ye.onLegendClick,legendHighlightedCategory:ye.highlightedCategory,legendIsolatedCategories:ye.isolatedCategories}),G&&{title:G}),Y&&{description:Y}),q&&{summary:q}),void 0!==X&&{accessibleTable:X}),s&&{className:s}),{tooltipContent:!1===x?()=>null:oo(x)||Me}),(E||j||C||P)&&{customHoverBehavior:ce}),(j||C||E)&&{customClickBehavior:ue}),k&&{marginalGraphics:k}),w&&{pointIdAccessor:w}),A&&A.length>0&&{annotations:A}),he),S);return K||Q||p.createElement(Ho,{componentName:"BubbleChart",width:R,height:W},p.createElement(hn,Object.assign({ref:o},Ce)))});nr.displayName="BubbleChart";const or=e.forwardRef(function(t,n){const r=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=r.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const a=Qn(t.mode,{width:t.width,height:t.height,showGrid:void 0,enableHover:t.enableHover,showLegend:void 0,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:s,margin:l,className:c,xAccessor:u="x",yAccessor:d="y",valueAccessor:h="value",xFormat:g,yFormat:f,colorScheme:y="blues",customColorScale:m,showValues:v=!1,valueFormat:b,cellBorderColor:x="#fff",cellBorderWidth:k=1,tooltip:w,annotations:A,frameProps:S={},selection:O,linkedHover:E,onObservation:M,onClick:j,hoverHighlight:C,chartId:P,loading:L,emptyContent:_,showLegend:B,legendPosition:T,legendInteraction:N}=t,D=a.width,I=a.height,H=a.enableHover,R=a.title,W=a.description,F=a.summary,z=a.accessibleTable,$=a.xLabel,G=a.yLabel,Y=zo(L,D,I),q=Y?null:Fo(s,D,I,_),X=s||[],V=null!=B&&B,U=null!=T?T:"right",{margin:K}=Vn({data:X,colorBy:V?"value":void 0,colorScale:void 0,showLegend:V,legendPosition:U,userMargin:l,defaults:a.marginDefaults}),{activeSelectionHook:Q,hoverSelectionHook:Z,customHoverBehavior:J,customClickBehavior:ee,crosshairSourceId:te}=qn({selection:O,linkedHover:E,fallbackFields:[],onObservation:M,onClick:j,chartType:"Heatmap",chartId:P,hoverHighlight:C,colorByField:void 0}),ne=Xn(E,te),oe=Un(N,void 0,[]),re=e.useMemo(()=>Z||(oe.legendSelectionHook?oe.legendSelectionHook:Q),[Z,oe.legendSelectionHook,Q]),ie=e.useMemo(()=>"function"==typeof h?e=>h(e):e=>e[h],[h]),ae=e.useMemo(()=>{const e=X.map(ie);return[Math.min(...e),Math.max(...e)]},[X,ie]),se=e.useMemo(()=>"custom"===y&&m?m:o.scaleSequential({blues:i.interpolateBlues,reds:i.interpolateReds,greens:i.interpolateGreens,viridis:i.interpolateViridis}[y]||i.interpolateBlues).domain(ae),[y,m,ae]);e.useMemo(()=>{const e=$n(u),t=$n(d);return{xBinCount:new Set(X.map(e)).size,yBinCount:new Set(X.map(t)).size}},[X,u,d]),e.useMemo(()=>({coordinates:X}),[X]);const le=e.useMemo(()=>e=>{const t=ie(e);return{fill:se(t),stroke:x,strokeWidth:k}},[ie,se,x,k]);e.useMemo(()=>Bn(le,re,O),[le,re,O]);const ce=e.useMemo(()=>so([{label:$||ro(u),accessor:u,role:"x"},{label:G||ro(d),accessor:d,role:"y"},{label:ro(h),accessor:h,role:"value"}]),[u,d,$,G,h]),ue=yo({componentName:"Heatmap",data:s,accessors:{xAccessor:u,yAccessor:d,valueAccessor:h}}),de=e.useMemo(()=>{if(V)return{gradient:{colorFn:e=>se(e),domain:ae,label:"string"==typeof h?h:"value",format:b}}},[V,se,ae,h,b]),he=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"heatmap"},null!=s&&{data:X}),{xAccessor:u,yAccessor:d,valueAccessor:h,colorScheme:"custom"!==y?y:void 0,showValues:v,heatmapValueFormat:b,size:[D,I],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:K,showAxes:a.showAxes,xLabel:$,yLabel:G,xFormat:g,yFormat:f,enableHover:H}),t.pointIdAccessor&&{pointIdAccessor:t.pointIdAccessor}),de&&{legend:de,legendPosition:U}),R&&{title:R}),W&&{description:W}),F&&{summary:F}),void 0!==z&&{accessibleTable:z}),c&&{className:c}),{tooltipContent:!1===w?()=>null:oo(w)||ce}),(E||M||j||C)&&{customHoverBehavior:J}),(M||j||E)&&{customClickBehavior:ee}),A&&A.length>0&&{annotations:A}),ne),S);return Y||q||(ue?p.createElement(co,{componentName:"Heatmap",message:ue,width:D,height:I}):p.createElement(Ho,{componentName:"Heatmap",width:D,height:I},p.createElement(hn,Object.assign({ref:r},he))))});or.displayName="Heatmap";const rr="__splomIdx",ir={top:4,bottom:4,left:4,right:4};function ar({frameRef:o,cellSize:r,onBrush:i}){const a=e.useRef(null),s=r-ir.left-ir.right,l=r-ir.top-ir.bottom;return e.useEffect(()=>{if(!a.current)return;const e=t.select(a.current).select(".brush-g"),r=n.brush().extent([[0,0],[s,l]]).on("brush end",e=>{var t;const n=null===(t=o.current)||void 0===t?void 0:t.getScales();if(!n)return;if(!e.selection)return void i(null);const[[r,a],[s,l]]=e.selection,c=[[n.x.invert(r),n.y.invert(a)],[n.x.invert(s),n.y.invert(l)]];i(c)});return e.call(r),e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{r.on("brush end",null)}},[s,l,o,i]),p.createElement("svg",{ref:a,width:r,height:r,style:{position:"absolute",top:0,left:0}},p.createElement("g",{className:"brush-g",transform:`translate(${ir.left},${ir.top})`}))}function sr({data:t,xField:n,yField:o,cellSize:r,pointRadius:i,pointOpacity:a,colorBy:s,colorScale:l,brushSelectionName:c,hoverSelectionName:u,unselectedOpacity:d,mode:h,onPointHover:g}){const f=e.useRef(null),y=An({name:c,clientId:`splom-${n}-${o}`}),m=On({name:c,xField:n,yField:o}),v=An({name:u,clientId:"splom-hover-source"}),b=v.selectPoints,x=e.useCallback(e=>{e?m.brushInteraction.during(e):m.brushInteraction.end(null)},[m.brushInteraction]),k=e.useCallback(e=>{if(!e)return void(null==g||g(null));const t=e.data,n=null==t?void 0:t[rr];void 0!==n&&(b({[rr]:[n]}),null==g||g(t,e.x+ir.left,e.y+ir.top))},[b,g]),w=e.useCallback(e=>{const t={opacity:a,r:i};return t.fill=s?B(e,s,l):Wn,"hover"===h?v.isActive&&v.predicate(e)?(t.opacity=1,t.r=2.5*i,t.stroke="#333",t.strokeWidth=1.5):v.isActive&&(t.opacity=.6*a):y.isActive&&!y.predicate(e)&&(t.opacity=d),t},[s,l,a,i,h,y.isActive,y.predicate,v.isActive,v.predicate,d]);return p.createElement("div",{style:{position:"relative",width:r,height:r}},p.createElement(hn,{ref:f,chartType:"scatter",data:t,size:[r,r],xAccessor:n,yAccessor:o,pointStyle:w,margin:ir,showAxes:!1,enableHover:"hover"===h,customHoverBehavior:"hover"===h?k:void 0,tooltipContent:"hover"===h?()=>null:void 0}),"brush"===h&&p.createElement(ar,{frameRef:f,cellSize:r,xField:n,yField:o,onBrush:x}))}function lr({data:t,field:n,label:o,cellSize:r,bins:i,colorBy:a,colorScale:s,brushSelectionName:l,hoverSelectionName:c,mode:u}){const d=An({name:l,clientId:"splom-diag-"+n}),h=An({name:c,clientId:`splom-diag-${n}-hover`}),g="hover"===u?h:d,f=g.isActive,y=g.predicate,m=e.useMemo(()=>{const e=t.map(e=>e[n]).filter(e=>null!=e&&!isNaN(e));if(0===e.length)return{bars:[],selectedBars:[],categoryBars:[],selectedCategoryBars:[],max:0,categories:[]};const o=Math.min(...e),s=(Math.max(...e)-o)/i||1,l="string"==typeof a?a:null,c=l?[...new Set(t.map(e=>e[l]).filter(e=>null!=e).map(String))]:[],u=new Map(c.map((e,t)=>[e,t])),d=Array(i).fill(0),h=Array(i).fill(0),g=Array.from({length:i},()=>Array(c.length).fill(0)),p=Array.from({length:i},()=>Array(c.length).fill(0));for(const e of t){const t=e[n];if(null==t||isNaN(t))continue;const r=Math.min(Math.floor((t-o)/s),i-1);if(d[r]++,f&&!y(e)||h[r]++,l){const t=u.get(e[l]+"");void 0!==t&&(g[r][t]++,f&&!y(e)||p[r][t]++)}}const m=Math.max(...d,1),v=g.map((e,t)=>{let n=0;return e.map((e,o)=>{const a=e/m*(r-24),s={x:t/i*r,w:r/i-1,h:a,y0:n,category:c[o]};return n+=a,s})}),b=p.map((e,t)=>{let n=0;return e.map((e,o)=>{const a=e/m*(r-24),s={x:t/i*r,w:r/i-1,h:a,y0:n,category:c[o]};return n+=a,s})});return{bars:d.map((e,t)=>({x:t/i*r,w:r/i-1,h:e/m*(r-24),count:e})),selectedBars:h.map((e,t)=>({x:t/i*r,w:r/i-1,h:e/m*(r-24),count:e})),categoryBars:v,selectedCategoryBars:b,max:m,categories:c}},[t,n,i,r,f,y,a]);return p.createElement("svg",{width:r,height:r,style:{overflow:"hidden"}},p.createElement("text",{x:r/2,y:14,textAnchor:"middle",fontSize:11,fontWeight:"bold",fill:"#333"},o),m.categories.length>0?m.categoryBars.map((e,t)=>e.map((e,n)=>p.createElement("rect",{key:`bg-${t}-${n}`,x:e.x,y:r-e.y0-e.h,width:Math.max(e.w,1),height:e.h,fill:s?s(e.category):Wn,opacity:f?.3:.6}))):m.bars.map((e,t)=>p.createElement("rect",{key:"bg-"+t,x:e.x,y:r-e.h,width:Math.max(e.w,1),height:e.h,fill:Wn,opacity:f?.3:.6})),f&&(m.categories.length>0?m.selectedCategoryBars.map((e,t)=>e.map((e,n)=>p.createElement("rect",{key:`sel-${t}-${n}`,x:e.x,y:r-e.y0-e.h,width:Math.max(e.w,1),height:e.h,fill:s?s(e.category):Wn,opacity:.7}))):m.selectedBars.map((e,t)=>p.createElement("rect",{key:"sel-"+t,x:e.x,y:r-e.h,width:Math.max(e.w,1),height:e.h,fill:Wn,opacity:.7}))))}function cr({label:e,cellSize:t}){return p.createElement("svg",{width:t,height:t},p.createElement("text",{x:t/2,y:t/2,textAnchor:"middle",dominantBaseline:"middle",fontSize:12,fontWeight:"bold",fill:"#333"},e))}function ur(t){const{data:n,fields:o,fieldLabels:r={},colorBy:i,colorScheme:a,cellSize:s=150,cellGap:l=4,pointRadius:c=2,pointOpacity:u=.5,diagonal:d="histogram",histogramBins:h=20,brushMode:g="crossfilter",hoverMode:f=!0,unselectedOpacity:y=.1,showGrid:m=!1,tooltip:v,showLegend:b,idAccessor:x,className:k,onObservation:w,chartId:A}=t,S="splom",O="splom-hover",E=f?"hover":g?"brush":"hover",M=xn(e=>e.clearSelection),[j,C]=e.useState(null),P=e.useCallback(()=>{M(O),C(null)},[M,O]),L=e.useMemo(()=>(n||[]).map((e,t)=>void 0!==e[rr]?e:Object.assign(Object.assign({},e),{[rr]:t})),[n]),_=Gn(L,i,a),B=void 0!==b?b:!!i,T=e.useMemo(()=>{if(!B||!i)return null;const e="string"==typeof i?i:null;return e?[...new Set(L.map(t=>t[e]))].map(e=>({label:e+"",color:_?_(e+""):Wn})):null},[B,i,L,_]),N=e.useMemo(()=>({display:"grid",gridTemplateColumns:"40px "+o.map(()=>s+"px").join(" "),gridTemplateRows:o.map(()=>s+"px").join(" ")+" 40px",gap:l+"px",width:"fit-content"}),[o,s,l,40]);return p.createElement("div",{className:k,style:{position:"relative"}},T&&p.createElement("div",{style:{display:"flex",gap:12,marginBottom:8,flexWrap:"wrap"}},T.map(e=>p.createElement("div",{key:e.label,style:{display:"flex",alignItems:"center",gap:4}},p.createElement("span",{style:{display:"inline-block",width:10,height:10,borderRadius:"50%",backgroundColor:e.color}}),p.createElement("span",{style:{fontSize:11}},e.label)))),p.createElement("div",{style:N,onMouseLeave:"hover"===E?P:void 0},o.map((e,t)=>p.createElement(p.Fragment,{key:"row-"+e},p.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",writingMode:"vertical-rl",transform:"rotate(180deg)",fontSize:11,fontWeight:"bold",color:"#333"}},r[e]||e),o.map((n,o)=>t===o?"label"===d?p.createElement(cr,{key:"diag-"+e,label:r[e]||e,cellSize:s}):p.createElement(lr,{key:"diag-"+e,data:L,field:e,label:r[e]||e,cellSize:s,bins:h,colorBy:i,colorScale:_,brushSelectionName:S,hoverSelectionName:O,unselectedOpacity:y,mode:E}):p.createElement(sr,{key:`cell-${e}-${n}`,data:L,xField:n,yField:e,fieldLabels:r,cellSize:s,pointRadius:c,pointOpacity:u,colorBy:i,colorScale:_,brushSelectionName:S,hoverSelectionName:O,unselectedOpacity:y,showGrid:m,tooltip:v,mode:E,onPointHover:"hover"===E?(r,i,a)=>{r?(C({datum:r,xField:n,yField:e,colIndex:o,rowIndex:t,px:null!=i?i:0,py:null!=a?a:0}),w&&w({type:"hover",datum:r,x:null!=i?i:0,y:null!=a?a:0,timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:A})):(C(null),w&&w({type:"hover-end",timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:A}))}:void 0})))),p.createElement("div",null)," ",o.map(e=>p.createElement("div",{key:"col-label-"+e,style:{display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:"bold",color:"#333"}},r[e]||e))),j&&"hover"===E&&(()=>{const e=j.datum,t=r[j.xField]||j.xField,n=r[j.yField]||j.yField,o=i?"function"==typeof i?i(e):e[i]:null,a=x?"function"==typeof x?x(e):e[x]:"Row "+e[rr];return p.createElement("div",{style:{position:"absolute",left:40+j.colIndex*(s+l)+j.px,top:j.rowIndex*(s+l)+j.py-8,transform:"translate(-50%, -100%)",color:"#333",background:"rgba(255,255,255,0.95)",border:"1px solid #ddd",borderRadius:3,padding:"4px 8px",fontSize:11,lineHeight:1.4,whiteSpace:"nowrap",pointerEvents:"none",zIndex:10}},p.createElement("div",{style:{fontWeight:"bold",marginBottom:2}},a+""),p.createElement("div",null,t,": ",null!=e[j.xField]?Number(e[j.xField]).toFixed(1):"–"),p.createElement("div",null,n,": ",null!=e[j.yField]?Number(e[j.yField]).toFixed(1):"–"),null!=o&&p.createElement("div",{style:{opacity:.8}},"string"==typeof i?i:"group",": ",o+""))})())}function dr(e){const{brushMode:t="crossfilter",hoverMode:n=!0}=e,o={};return!n&&t&&(o.splom={resolution:t}),n&&(o["splom-hover"]={resolution:"union"}),p.createElement(Pn,{selections:o},p.createElement(ur,Object.assign({},e)))}dr.displayName="ScatterplotMatrix";const hr=e.forwardRef(function(t,n){const o=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=o.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,r;return null!==(r=null===(n=o.current)||void 0===n?void 0:n.update(e,t))&&void 0!==r?r:[]},clear:()=>{var e;return null===(e=o.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=o.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const r=Qn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:i,margin:a,className:s,xFormat:l,yFormat:c,xAccessor:u="x",yAccessor:d="y",xCenter:h,yCenter:g,quadrants:f,centerlineStyle:y={},showQuadrantLabels:m=!0,quadrantLabelSize:v=12,colorBy:b,colorScheme:x,sizeBy:k,sizeRange:w=[3,15],pointRadius:A=5,pointOpacity:S=.8,tooltip:O,pointIdAccessor:E,annotations:M,frameProps:j={},selection:C,linkedHover:P,onObservation:L,onClick:_,hoverHighlight:T,chartId:D,loading:I,emptyContent:H,legendInteraction:R,legendPosition:W,color:F}=t,z=r.width,$=r.height,G=r.enableHover,Y=r.showGrid,q=r.showLegend,X=r.title,V=r.description,U=r.summary,K=r.accessibleTable,Q=r.xLabel,Z=r.yLabel,J=zo(I,z,$),ee=J?null:Fo(i,z,$,H),te=i||[];$o("QuadrantChart",te,"xAccessor",u),$o("QuadrantChart",te,"yAccessor",d);const{activeSelectionHook:ne,hoverSelectionHook:oe,customHoverBehavior:re,customClickBehavior:ie,crosshairSourceId:ae}=qn({selection:C,linkedHover:P,fallbackFields:"string"==typeof b?[b]:[],onObservation:L,onClick:_,chartType:"QuadrantChart",chartId:D,hoverHighlight:T,colorByField:"string"==typeof b?b:void 0}),se=Xn(P,ae),le=Gn(te,b,x),ce=e.useMemo(()=>{if(!b)return[];const e=new Set;for(const t of te){const n="function"==typeof b?b(t):t[b];null!=n&&e.add(n+"")}return Array.from(e)},[te,b]),ue=Un(R,b,ce),de=e.useMemo(()=>oe||(ue.legendSelectionHook?ue.legendSelectionHook:ne),[oe,ue.legendSelectionHook,ne]),he=e.useMemo(()=>{if(!te.length)return;const e="function"==typeof u?u:e=>+e[u],t="function"==typeof d?d:e=>+e[d];let n=1/0,o=-1/0,r=1/0,i=-1/0;for(const a of te){const s=e(a),l=t(a);isFinite(s)&&(n>s&&(n=s),s>o&&(o=s)),isFinite(l)&&(r>l&&(r=l),l>i&&(i=l))}if(null!=h&&isFinite(h)&&(n>h&&(n=h),h>o&&(o=h)),null!=g&&isFinite(g)&&(r>g&&(r=g),g>i&&(i=g)),n===1/0)return;const a=.1*(o-n)||1,s=.1*(i-r)||1;return{xExtent:[n-a,o+a],yExtent:[r-s,i+s]}},[te,u,d,h,g]),ge=e.useMemo(()=>{if(!k||0===te.length)return;const e=te.map(e=>"function"==typeof k?k(e):e[k]).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0!==e.length?[Math.min(...e),Math.max(...e)]:void 0},[te,k]),fe=e.useMemo(()=>"function"==typeof u?u:e=>+e[u],[u]),pe=e.useMemo(()=>"function"==typeof d?d:e=>+e[d],[d]),ye=e.useMemo(()=>e=>{const t={fillOpacity:S};if(b)le&&(t.fill=B(e,b,le));else{const n=fe(e),o=pe(e),r=null!=h?n>=h:void 0,i=null!=g?o>=g:void 0;t.fill=void 0===i||void 0===r?F||Wn:i&&r?f.topRight.color:i&&!r?f.topLeft.color:!i&&r?f.bottomRight.color:f.bottomLeft.color}return t.r=k?N(e,k,w,ge):A,t},[b,le,k,w,ge,A,S,fe,pe,h,g,f,F]),me=e.useMemo(()=>Bn(ye,de,C),[ye,de,C]),{legend:ve,margin:be,legendPosition:xe}=Vn({data:te,colorBy:b,colorScale:le,showLegend:q,legendPosition:W,userMargin:a,defaults:r.marginDefaults}),ke=e.useMemo(()=>{if(!te.length)return;const e=new Set;"string"==typeof u&&e.add(u),"string"==typeof d&&e.add(d),"string"==typeof b&&e.add(b),"string"==typeof k&&e.add(k);const t=te[0];for(const n of Object.keys(t))if(!n.startsWith("_")&&!e.has(n)&&"string"==typeof t[n])return n},[te,u,d,b,k]),we=e.useMemo(()=>so([...ke?[{label:ke,accessor:ke,role:"title"}]:[],{label:Q||ro(u),accessor:u,role:"x"},{label:Z||ro(d),accessor:d,role:"y"},...b?[{label:ro(b),accessor:b,role:"color"}]:[],...k?[{label:ro(k),accessor:k,role:"size"}]:[]]),[ke,u,d,Q,Z,b,k]),Ae=yo({componentName:"QuadrantChart",data:i,accessors:{xAccessor:u,yAccessor:d}}),Se=e.useMemo(()=>{var e;const t={stroke:y.stroke||"#999",strokeWidth:null!==(e=y.strokeWidth)&&void 0!==e?e:1,dashArray:y.strokeDasharray||[]};return[(e,n,o,r)=>{var i;if(!(null==o?void 0:o.x)||!(null==o?void 0:o.y))return;const a=r.width,s=r.height,l=null!=h?o.x(h):a/2,c=null!=g?o.y(g):s/2;if(null!=h&&!isFinite(l))return;if(null!=g&&!isFinite(c))return;const u=Math.max(0,Math.min(a,l)),d=Math.max(0,Math.min(s,c)),p=[{config:f.topLeft,x:0,y:0,w:u,h:d},{config:f.topRight,x:u,y:0,w:a-u,h:d},{config:f.bottomLeft,x:0,y:d,w:u,h:s-d},{config:f.bottomRight,x:u,y:d,w:a-u,h:s-d}];for(const t of p)t.w>0&&t.h>0&&(e.fillStyle=t.config.color,e.globalAlpha=null!==(i=t.config.opacity)&&void 0!==i?i:.08,e.fillRect(t.x,t.y,t.w,t.h));e.globalAlpha=1,e.strokeStyle=t.stroke,e.lineWidth=t.strokeWidth,t.dashArray.length>0&&e.setLineDash(t.dashArray),e.beginPath(),e.moveTo(u,0),e.lineTo(u,s),e.stroke(),e.beginPath(),e.moveTo(0,d),e.lineTo(a,d),e.stroke(),e.setLineDash([])}]},[h,g,f,y]),Oe=e.useMemo(()=>m?[...Se,(e,t,n,o)=>{if(!(null==n?void 0:n.x)||!(null==n?void 0:n.y))return;const r=o.width,i=o.height,a=null!=h?n.x(h):r/2,s=null!=g?n.y(g):i/2;(null==h||isFinite(a))&&(null==g||isFinite(s))&&(e.font=`600 ${v}px sans-serif`,e.globalAlpha=.5,e.fillStyle=f.topLeft.color,e.textAlign="left",e.textBaseline="top",e.fillText(f.topLeft.label,8,8),e.fillStyle=f.topRight.color,e.textAlign="right",e.textBaseline="top",e.fillText(f.topRight.label,r-8,8),e.fillStyle=f.bottomLeft.color,e.textAlign="left",e.textBaseline="bottom",e.fillText(f.bottomLeft.label,8,i-8),e.fillStyle=f.bottomRight.color,e.textAlign="right",e.textBaseline="bottom",e.fillText(f.bottomRight.label,r-8,i-8),e.globalAlpha=1)}]:Se,[Se,m,v,f,h,g]),Ee=e.useMemo(()=>{const e=j.canvasPreRenderers||[];return[...Oe,...e]},[Oe,j.canvasPreRenderers]),Me=e.useMemo(()=>{var e;const t={stroke:y.stroke||"#999",strokeWidth:null!==(e=y.strokeWidth)&&void 0!==e?e:1,dashArray:y.strokeDasharray?Array.isArray(y.strokeDasharray)?y.strokeDasharray.join(","):y.strokeDasharray:void 0};return[(e,n,o)=>{if(!(null==n?void 0:n.x)||!(null==n?void 0:n.y))return null;const r=o.width,i=o.height,a=null!=h?n.x(h):r/2,s=null!=g?n.y(g):i/2;if(null!=h&&!isFinite(a))return null;if(null!=g&&!isFinite(s))return null;const l=Math.max(0,Math.min(r,a)),c=Math.max(0,Math.min(i,s));return p.createElement(p.Fragment,null,[{config:f.topLeft,x:0,y:0,w:l,h:c},{config:f.topRight,x:l,y:0,w:r-l,h:c},{config:f.bottomLeft,x:0,y:c,w:l,h:i-c},{config:f.bottomRight,x:l,y:c,w:r-l,h:i-c}].map((e,t)=>{var n;return e.w>0&&e.h>0?p.createElement("rect",{key:"qf-"+t,x:e.x,y:e.y,width:e.w,height:e.h,fill:e.config.color,opacity:null!==(n=e.config.opacity)&&void 0!==n?n:.08}):null}),p.createElement("line",{x1:l,y1:0,x2:l,y2:i,stroke:t.stroke,strokeWidth:t.strokeWidth,strokeDasharray:t.dashArray}),p.createElement("line",{x1:0,y1:c,x2:r,y2:c,stroke:t.stroke,strokeWidth:t.strokeWidth,strokeDasharray:t.dashArray}),m&&p.createElement(p.Fragment,null,p.createElement("text",{x:8,y:8+v,fill:f.topLeft.color,fontWeight:600,fontSize:v,opacity:.5},f.topLeft.label),p.createElement("text",{x:r-8,y:8+v,fill:f.topRight.color,fontWeight:600,fontSize:v,opacity:.5,textAnchor:"end"},f.topRight.label),p.createElement("text",{x:8,y:i-8,fill:f.bottomLeft.color,fontWeight:600,fontSize:v,opacity:.5},f.bottomLeft.label),p.createElement("text",{x:r-8,y:i-8,fill:f.bottomRight.color,fontWeight:600,fontSize:v,opacity:.5,textAnchor:"end"},f.bottomRight.label)))}]},[h,g,f,y,m,v]),je=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter"},null!=i&&{data:te}),{xAccessor:u,yAccessor:d,colorAccessor:b||void 0,sizeAccessor:k||void 0,sizeRange:w,pointStyle:me,colorScheme:x,size:[z,$],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:be,showAxes:r.showAxes,xLabel:Q,yLabel:Z,xFormat:l,yFormat:c,enableHover:G,showGrid:Y}),he&&{xExtent:he.xExtent,yExtent:he.yExtent}),ve&&{legend:ve,legendPosition:xe}),R&&"none"!==R&&{legendHoverBehavior:ue.onLegendHover,legendClickBehavior:ue.onLegendClick,legendHighlightedCategory:ue.highlightedCategory,legendIsolatedCategories:ue.isolatedCategories}),X&&{title:X}),V&&{description:V}),U&&{summary:U}),void 0!==K&&{accessibleTable:K}),s&&{className:s}),{tooltipContent:!1===O?()=>null:!0===O||void 0===O?we:oo(O)||we}),(P||L||_||T)&&{customHoverBehavior:re}),(L||_||P)&&{customClickBehavior:ie}),E&&{pointIdAccessor:E}),M&&M.length>0&&{annotations:M}),{canvasPreRenderers:Ee}),se),j),Ee.length>0&&{canvasPreRenderers:Ee}),{svgPreRenderers:Me});return J||ee||(Ae?p.createElement(co,{componentName:"QuadrantChart",message:Ae,width:z,height:$}):p.createElement(Ho,{componentName:"QuadrantChart",width:z,height:$},p.createElement(hn,Object.assign({ref:o},je))))});hr.displayName="QuadrantChart";const gr="__ma_unitized",fr="__ma_series";function pr(e,t){const n=t[1]-t[0];return 0===n?.5:(e-t[0])/n}function yr(e,t){return t[0]+e*(t[1]-t[0])}const mr=e.forwardRef(function(t,n){var o,r;const i=e.useRef(null),a=e.useRef([]);e.useImperativeHandle(n,()=>({push:e=>{if(!i.current)return;const n=e;for(let e=0;t.series.length>e&&2>e;e++){const o=t.series[e],r=o.extent||a.current[e];if(!r)continue;const s=("function"==typeof o.yAccessor?o.yAccessor:e=>e[o.yAccessor])(n);null!=s&&isFinite(s)&&i.current.push(Object.assign(Object.assign({},n),{[gr]:pr(s,r),[fr]:o.label||"Series "+(e+1)}))}},pushMany:e=>{if(!i.current)return;const n=[];for(const o of e)for(let e=0;t.series.length>e&&2>e;e++){const r=t.series[e],i=r.extent||a.current[e];if(!i)continue;const s=("function"==typeof r.yAccessor?r.yAccessor:e=>e[r.yAccessor])(o);null!=s&&isFinite(s)&&n.push(Object.assign(Object.assign({},o),{[gr]:pr(s,i),[fr]:r.label||"Series "+(e+1)}))}i.current.pushMany(n)},remove:e=>{var t,n;return null!==(n=null===(t=i.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=i.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;return null===(e=i.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=i.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const s=Qn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,accessibleTable:t.accessibleTable},{width:800,height:400}),{data:l,margin:c,className:u,xFormat:d,xAccessor:h="x",series:g,colorScheme:f,curve:y="monotoneX",lineWidth:m=2,tooltip:v,annotations:b,frameProps:x={},selection:k,linkedHover:w,onObservation:A,onClick:S,hoverHighlight:O,chartId:E,loading:M,emptyContent:P,legendInteraction:L,legendPosition:_}=t,B=s.width,T=s.height,N=s.enableHover,D=s.showGrid,I=null===(o=s.showLegend)||void 0===o||o,H=s.title,R=s.description,W=s.summary,F=s.accessibleTable,z=s.xLabel,$=2===g.length;"undefined"==typeof process||"production"===(null===(r=process.env)||void 0===r?void 0:r.NODE_ENV)||$||console.warn(`[MultiAxisLineChart] Expected exactly 2 series for dual-axis mode, got ${g.length}. Rendering as a standard multi-line chart.`);const G=zo(M,B,T),Y=G?null:Fo(l,B,T,P),q=l||[],X=Fn(),V=e.useMemo(()=>{let e;if(Array.isArray(f))e=f;else if(X&&X.length>0)e=X;else{const t=j[f];e=Array.isArray(t)?t:C}return g.map((t,n)=>t.color||e[n%e.length])},[g,f,X]),U=e.useMemo(()=>g.map((e,t)=>e.label||"Series "+(t+1)),[g]),{unitizedData:K,extents:Q}=e.useMemo(()=>{if(0===q.length){const e=g.map(e=>e.extent||null).filter(Boolean);return e.length===g.length&&(a.current=e),{unitizedData:[],extents:e.length===g.length?e:[]}}const e=g.map(e=>e.extent||function(e,t){let n=1/0,o=-1/0;const r="function"==typeof t?t:e=>e[t];for(const t of e){const e=r(t);null!=e&&isFinite(e)&&(n>e&&(n=e),e>o&&(o=e))}if(!isFinite(n)||!isFinite(o))return[0,1];if(n===o){const e=0===n?1:.1*Math.abs(n);return[n-e,o+e]}return[n,o]}(q,e.yAccessor));if(a.current=e,!$){const t=[];for(const e of q)for(let n=0;g.length>n;n++){const o=g[n],r=("function"==typeof o.yAccessor?o.yAccessor:e=>e[o.yAccessor])(e);null!=r&&t.push(Object.assign(Object.assign({},e),{[gr]:r,[fr]:U[n]}))}return{unitizedData:t,extents:e}}const t=[];for(const n of q)for(let o=0;2>o;o++){const r=g[o],i=("function"==typeof r.yAccessor?r.yAccessor:e=>e[r.yAccessor])(n);null!=i&&t.push(Object.assign(Object.assign({},n),{[gr]:pr(i,e[o]),[fr]:U[o]}))}return{unitizedData:t,extents:e}},[q,g,$,U]),Z=e.useMemo(()=>{if($&&Q.length>=2)return[{orient:"left",label:U[0],tickFormat:g[0].format||(e=>{const t=yr(e,Q[0]);return Number.isInteger(t)?t+"":t.toFixed(1)})},{orient:"right",label:U[1],tickFormat:g[1].format||(e=>{const t=yr(e,Q[1]);return Number.isInteger(t)?t+"":t.toFixed(1)})},{orient:"bottom"}]},[$,Q,g,U]),J=Zo({data:e.useMemo(()=>K.length>0?K:U.map(e=>({[fr]:e})),[K,U]),rawData:l,colorBy:fr,colorScheme:V,legendInteraction:L,legendPosition:_,selection:k,linkedHover:w,fallbackFields:[fr],unwrapData:!1,onObservation:A,onClick:S,hoverHighlight:O,chartType:"MultiAxisLineChart",chartId:E,showLegend:I,userMargin:c,marginDefaults:$?Object.assign(Object.assign({},s.marginDefaults),{left:70,right:70}):s.marginDefaults,loading:M,emptyContent:P,width:B,height:T});if(J.earlyReturn)return J.earlyReturn;const ee=e.useMemo(()=>{const e=new Map;return U.forEach((t,n)=>e.set(t,V[n])),t=>({stroke:e.get(t[fr])||V[0],strokeWidth:m,fill:"none"})},[U,V,m]),te=e.useMemo(()=>Bn(ee,J.effectiveSelectionHook,k),[ee,J.effectiveSelectionHook,k]),ne=e.useMemo(()=>{if(!1===v)return()=>null;return oo(v)||(e=>{var t;const n=e.data||e,o=n[fr],r=U.indexOf(o),i=n[gr],a=$&&r>=0&&Q[r]?yr(i,Q[r]):i,s=r>=0&&(null===(t=g[r])||void 0===t?void 0:t.format)?g[r].format:e=>Number.isInteger(e)?e+"":e.toFixed(2),l="function"==typeof h?h(n):n[h];return p.createElement("div",{style:{padding:"6px 10px",fontFamily:"var(--semiotic-font-family, sans-serif)",fontSize:"var(--semiotic-tooltip-font-size, 13px)"}},p.createElement("div",{style:{fontWeight:600,marginBottom:4,color:V[r]||"inherit"}},o),p.createElement("div",null,`${"string"==typeof h?h:"x"}: ${l}`),p.createElement("div",null,`${o}: ${s(a)}`))})},[v,U,V,Q,$,g,h]),oe=yo({componentName:"MultiAxisLineChart",data:l,accessors:{xAccessor:h}}),re=$?[0,1]:void 0,ie=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"line"},null!=l&&{data:K}),{xAccessor:h,yAccessor:gr,groupAccessor:fr,lineStyle:te,colorScheme:V,size:[B,T],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:J.margin,showAxes:s.showAxes}),Z&&{axes:Z}),{xLabel:z}),$?{}:{yLabel:U[0]}),{xFormat:d}),$&&re&&{yExtent:re}),{enableHover:N}),t.pointIdAccessor&&{pointIdAccessor:t.pointIdAccessor}),{showGrid:D,curve:y}),J.legendBehaviorProps),H&&{title:H}),R&&{description:R}),W&&{summary:W}),void 0!==F&&{accessibleTable:F}),u&&{className:u}),{tooltipContent:ne}),b&&{annotations:b}),(w||A||S||O)&&{customHoverBehavior:J.customHoverBehavior}),(A||S||w)&&{customClickBehavior:J.customClickBehavior}),J.crosshairProps),x);return G||Y||(oe?p.createElement(co,{componentName:"MultiAxisLineChart",message:oe,width:B,height:T}):p.createElement(Ho,{componentName:"MultiAxisLineChart",width:B,height:T},p.createElement(hn,Object.assign({ref:i},ie))))});function vr(e,t){const{columns:n,config:o,resolvePieceStyle:r}=e,i=[],a=Math.min(t.width,t.height)/2-4,s="donut"===o.chartType?o.innerRadius||60:0,l=-Math.PI/2+(o.startAngle||0)*Math.PI/180,c=null!=o.sweepAngle?o.sweepAngle*Math.PI/180:2*Math.PI;for(const e of Object.values(n)){const t=l+e.pctStart*c,n=l+(e.pctStart+e.pct)*c,o=r(e.pieceData[0],e.name);i.push({type:"wedge",cx:0,cy:0,innerRadius:s,outerRadius:a,startAngle:t,endAngle:n,style:o,datum:e.pieceData,category:e.name})}return i}function br(e){var t,n,o;const r=e.length,i=e[0],s=e[r-1];return{n:r,min:i,q1:null!==(t=a.quantile(e,.25))&&void 0!==t?t:i,median:null!==(n=a.quantile(e,.5))&&void 0!==n?n:(i+s)/2,q3:null!==(o=a.quantile(e,.75))&&void 0!==o?o:s,max:s,mean:e.reduce((e,t)=>e+t,0)/r}}mr.displayName="MultiAxisLineChart";const xr={bar:function(e,t){const{scales:n,columns:o,config:r,getR:i,getStack:a,resolvePieceStyle:s}=e,{r:l,projection:c}=n,u=[],d="vertical"===c,h="horizontal"===c,g=r.normalize,f=[];if(a){const e=new Set;for(const t of Object.values(o))for(const n of t.pieceData){const t=a(n);e.has(t)||(e.add(t),f.push(t))}}else f.push("_default");for(const e of Object.values(o)){const t=new Map;for(const n of e.pieceData){const e=a?a(n):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const o=t.get(e);o.total+=i(n),o.pieces.push(n)}let n=0;if(g)for(const e of t.values())n+=Math.abs(e.total);let o=0,r=0;for(const i of f){const c=t.get(i);if(!c)continue;let f=c.total;g&&n>0&&(f/=n);const p=s(c.pieces[0],a?i:e.name),y=Object.assign(Object.assign({},c.pieces[0]),{__aggregateValue:c.total,__pieceCount:c.pieces.length,category:e.name});if(d){const t=l(0>f?r:o+f),n=0>f?l(r+f)-l(r):l(o)-l(o+f);u.push(q(e.x,t,e.width,Math.abs(n),p,y,i)),0>f?r+=f:o+=f}else if(h){const t=l(0>f?r+f:o),n=0>f?l(r)-l(r+f):l(o+f)-l(o);u.push(q(t,e.x,Math.abs(n),e.width,p,y,i)),0>f?r+=f:o+=f}}}return u},clusterbar:function(e,t){const{scales:n,columns:o,getR:r,getGroup:i,resolvePieceStyle:a}=e,{r:s,projection:l}=n,c=[],u="vertical"===l,d=[],h=new Set;for(const e of Object.values(o))for(const t of e.pieceData){const e=i?i(t):"_default";h.has(e)||(h.add(e),d.push(e))}const g=d.length||1;for(const e of Object.values(o)){const t=e.width/g,n=.2*t,o=t-n,l=new Map;for(const t of e.pieceData){const e=i?i(t):"_default";l.has(e)||l.set(e,[]),l.get(e).push(t)}for(let i=0;d.length>i;i++){const h=l.get(d[i])||[];for(const l of h){const h=r(l),g=a(l,d[i]);if(u){const r=e.x+i*t+n/2,a=s(0),u=s(h);c.push(q(r,Math.min(a,u),o,Math.abs(a-u),g,l,d[i]))}else{const r=e.x+i*t+n/2,a=s(0),u=s(h);c.push(q(Math.min(a,u),r,Math.abs(u-a),o,g,l,d[i]))}}}}return c},point:function(e,t){var n,o;const{scales:r,columns:i,getR:a,multiScales:s,resolvePieceStyle:l}=e,{r:c,projection:u}=r,d=[],h="vertical"===u,g="radial"===u,f=s.length>0,p=2*Math.PI,y=-Math.PI/2;for(const e of Object.values(i))for(const t of e.pieceData){const r=null!==(n=t.__rIndex)&&void 0!==n?n:0,i=null!==(o=t.__rValue)&&void 0!==o?o:a(t),u=f&&s[r]||c,m=l(t,e.name),v=m.r||5;let b,x;if(g){const t=y+(e.pctStart+e.pct/2)*p,n=u(i);b=Math.cos(t)*n,x=Math.sin(t)*n}else h?(b=e.middle,x=u(i)):(b=u(i),x=e.middle);d.push({type:"point",x:b,y:x,r:v,style:m,datum:t})}return d},swarm:function(e,t){const{scales:n,columns:o,getR:r,resolvePieceStyle:i}=e,{r:a,projection:s}=n,l=[],c="vertical"===s;for(const e of Object.values(o)){const t=e.width/2;for(let n=0;e.pieceData.length>n;n++){const o=e.pieceData[n],s=r(o),u=i(o,e.name),d=u.r||4,h=(7919*n%100/100-.5)*t*.8,g=c?e.middle+h:a(s),f=c?a(s):e.middle+h;l.push({type:"point",x:g,y:f,r:d,style:u,datum:o})}}return l},pie:vr,donut:vr,boxplot:function(e,t){var n,o,r,i,s;const{scales:l,columns:c,config:u,getR:d,resolveSummaryStyle:h}=e,{r:g,projection:f}=l,p=[],y="vertical"===f,m=!1!==u.showOutliers;for(const e of Object.values(c)){const t=e.pieceData.map(e=>d(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(0===t.length)continue;const l=t[0],c=t[t.length-1],u=null!==(n=a.quantile(t,.25))&&void 0!==n?n:l,f=null!==(o=a.quantile(t,.5))&&void 0!==o?o:(l+c)/2,v=null!==(r=a.quantile(t,.75))&&void 0!==r?r:c,b=v-u,x=u-1.5*b,k=v+1.5*b,w=null!==(i=t.find(e=>e>=x))&&void 0!==i?i:l,A=null!==(s=[...t].reverse().find(e=>k>=e))&&void 0!==s?s:c,S=h(e.pieceData[0],e.name),O=[];if(m)for(const t of e.pieceData){const n=d(t);if(x>n||n>k){const o=y?e.middle:g(n),r=y?g(n):e.middle;O.push({px:o,py:r,value:n,datum:t})}}if(p.push({type:"boxplot",x:y?e.middle:0,y:y?0:e.middle,projection:y?"vertical":"horizontal",columnWidth:.6*e.width,minPos:g(w),q1Pos:g(u),medianPos:g(f),q3Pos:g(v),maxPos:g(A),stats:{n:t.length,min:w,q1:u,median:f,q3:v,max:A,mean:t.reduce((e,t)=>e+t,0)/t.length},style:S,datum:e.pieceData,category:e.name,outliers:O}),m)for(const e of O)p.push({type:"point",x:e.px,y:e.py,r:3,style:{fill:S.fill||"#999",opacity:.6},datum:e.datum})}return p},violin:function(e,t){var n,o,r;const{scales:i,columns:s,config:l,getR:c,resolveSummaryStyle:u}=e,{r:d,projection:h}=i,g=[],f="vertical"===h,p=l.bins||20,y=!1!==l.showIQR;for(const e of Object.values(s)){const t=e.pieceData.map(e=>c(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const i=t[0],s=t[t.length-1],l=(s-i)/p||1,h=Array(p).fill(0);for(const e of t)h[Math.min(Math.floor((e-i)/l),p-1)]++;const m=Math.max(...h,1),v=e.width/2*.9;let b="";if(f){b=`M ${e.middle} ${d(i)}`;for(let t=0;p>t;t++){const n=d(i+(t+.5)*l);b+=` L ${e.middle+h[t]/m*v} ${n}`}b+=` L ${e.middle} ${d(s)}`;for(let t=p-1;t>=0;t--){const n=d(i+(t+.5)*l);b+=` L ${e.middle-h[t]/m*v} ${n}`}b+=" Z"}else{b=`M ${d(i)} ${e.middle}`;for(let t=0;p>t;t++)b+=` L ${d(i+(t+.5)*l)} ${e.middle-h[t]/m*v}`;b+=` L ${d(s)} ${e.middle}`;for(let t=p-1;t>=0;t--)b+=` L ${d(i+(t+.5)*l)} ${e.middle+h[t]/m*v}`;b+=" Z"}const x=u(e.pieceData[0],e.name);let k;if(y&&t.length>=4){const l=null!==(n=a.quantile(t,.25))&&void 0!==n?n:i,c=null!==(o=a.quantile(t,.5))&&void 0!==o?o:(i+s)/2,u=null!==(r=a.quantile(t,.75))&&void 0!==r?r:s;k={q1Pos:d(l),medianPos:d(c),q3Pos:d(u),centerPos:e.middle,isVertical:f}}const w=f?{x:e.x,y:Math.min(d(s),d(i)),width:e.width,height:Math.abs(d(s)-d(i))}:{x:Math.min(d(i),d(s)),y:e.x,width:Math.abs(d(s)-d(i)),height:e.width};g.push({type:"violin",pathString:b,translateX:0,translateY:0,bounds:w,iqrLine:k,stats:br(t),style:x,datum:e.pieceData,category:e.name})}return g},histogram:function(e,t){var n;const{scales:o,columns:r,config:i,getR:a,resolveSummaryStyle:s}=e,{r:l}=o,c=[],u=i.bins||25,d=i.normalize,h=null===(n=l.domain)||void 0===n?void 0:n.call(l),g=h?+h[0]:void 0,f=h?+h[1]:void 0;for(const e of Object.values(r)){const t=e.pieceData.map(e=>a(e)).filter(e=>null!=e&&!isNaN(e));if(0===t.length)continue;const n=null!=g&&isFinite(g)?g:Math.min(...t),o=null!=f&&isFinite(f)?f:Math.max(...t),r=(o-n)/u||1,i=Array(u).fill(0);for(const e of t)n>e||e>o||i[Math.min(Math.floor((e-n)/r),u-1)]++;const h=t.length,p=Math.max(...i,1),y=s(e.pieceData[0],e.name);for(let t=0;u>t;t++){if(0===i[t])continue;const o=(d?i[t]/h:i[t]/p)*e.width*.9,a=l(n+t*r),s=l(n+(t+1)*r);c.push(q(Math.min(a,s),e.x+e.width-o,Math.abs(s-a),o,y,{bin:t,count:i[t],range:[n+t*r,n+(t+1)*r],category:e.name},e.name))}}return c},ridgeline:function(e,t){var n;const{scales:o,columns:r,config:i,getR:a,resolveSummaryStyle:s}=e,{r:l,projection:c}=o,u=[],d=i.bins||20,h="horizontal"===c,g=i.amplitude||1.5;for(const e of Object.values(r)){const t=e.pieceData.map(e=>a(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const o=t[0],r=t[t.length-1],i=(r-o)/d||1,c=Array(d).fill(0);for(const e of t)o>e||e>r||c[Math.min(Math.floor((e-o)/i),d-1)]++;const f=Math.max(...c,1),p=s(e.pieceData[0],e.name),y=e.width*g;let m="";if(h){const t=e.x+e.width;m=`M ${l(o)} ${t}`;for(let e=0;d>e;e++)m+=` L ${l(o+(e+.5)*i)} ${t-c[e]/f*y}`;m+=` L ${l(r)} ${t} Z`}else{const t=e.x;m=`M ${t} ${l(o)}`;for(let e=0;d>e;e++){const n=l(o+(e+.5)*i);m+=` L ${t+c[e]/f*y} ${n}`}m+=` L ${t} ${l(r)} Z`}const v=h?{x:Math.min(l(o),l(r)),y:e.x,width:Math.abs(l(r)-l(o)),height:e.width}:{x:e.x,y:Math.min(l(r),l(o)),width:e.width,height:Math.abs(l(r)-l(o))};u.push({type:"violin",pathString:m,translateX:0,translateY:0,bounds:v,stats:br(t),style:Object.assign(Object.assign({},p),{fillOpacity:null!==(n=p.fillOpacity)&&void 0!==n?n:.5}),datum:e.pieceData,category:e.name})}return u},timeline:function(e,t){const{scales:n,columns:o,getRawRange:r,resolvePieceStyle:i}=e,{r:a,projection:s}=n,l=[],c="horizontal"===s;for(const e of Object.values(o))for(const t of e.pieceData){const n=r(t);if(!n)continue;const[o,s]=n,u=i(t,e.name);if(c){const n=a(Math.min(o,s)),r=a(Math.max(o,s));l.push(q(n,e.x,r-n,e.width,u,t,e.name))}else{const n=a(Math.max(o,s)),r=a(Math.min(o,s));l.push(q(e.x,n,e.width,r-n,u,t,e.name))}}return l},funnel:function(e,t){var n,r,i,a,s,l,c;const{columns:u,getR:d,getStack:h,resolvePieceStyle:g}=e,f=[],p=t.width/2,y=!1!==e.config.showLabels,m=e.scales.o.domain().map(e=>u[e]).filter(Boolean);if(0===m.length)return f;const v=[],b=new Set;for(const e of m)for(const t of e.pieceData){const e=h?h(t):"_default";b.has(e)||(b.add(e),v.push(e))}const x=v.length>1&&"_default"!==v[0],k=[];let w=0;for(const e of m){const t=new Map;let n=0;for(const o of e.pieceData){const e=h?h(o):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const r=t.get(e),i=d(o);r.total+=i,r.pieces.push(o),n+=i}k.push({col:e,groups:t,stepTotal:n}),x||n>w&&(w=n)}if(x)for(const e of k){let t=0,n=0;for(let o=0;v.length>o;o++){const r=e.groups.get(v[o]);r&&(o%2==0?t+=r.total:n+=r.total)}const o=Math.max(t,n);o>w&&(w=o)}if(0===w)return f;const A=new Map;for(const e of v){const t=k[0].groups.get(e);A.set(e,null!==(n=null==t?void 0:t.total)&&void 0!==n?n:0)}const S=k[0].stepTotal,O=x?.95*p:.9*t.width,E=o.scaleLinear().domain([0,w]).range([0,O]),M=null!==(r=e.config.connectorOpacity)&&void 0!==r?r:.3;let j=new Map;for(let e=0;k.length>e;e++){const t=k[e],n=t.col,o=0===e,r=n.width,u=.55*r,d=n.x+(r-u)/2,h=new Map;if(x){let e=0;for(const n of v){const o=t.groups.get(n);o&&(e+=E(o.total))}let r=p,i=p;for(let a=0;v.length>a;a++){const l=v[a],c=t.groups.get(l);if(!c)continue;const m=E(c.total),b=a%2==0,x=b?r:i-m;b?r+=m:i-=m;const k=g(c.pieces[0],l),w=null!==(s=A.get(l))&&void 0!==s?s:c.total,S=w>0?c.total/w*100:0,O=Object.assign(Object.assign({},c.pieces[0]),{__funnelValue:c.total,__funnelPercent:S,__funnelStep:n.name,__funnelIsFirstStep:o,__aggregateValue:c.total,__pieceCount:c.pieces.length,category:l});y&&(0===a&&(O.__funnelStepLabel=n.name,O.__funnelStepLabelX=p,O.__funnelStepLabelY=d,O.__funnelRowWidth=e),O.__funnelValueLabelX=x+m/2,O.__funnelValueLabelY=d,O.__funnelBarW=m),f.push(q(x,d,m,u,k,O,l)),h.set(l,{x:x,y:d,w:m,h:u})}}else{const e=t.stepTotal,r=E(e),s=p-r/2,l=v[0],c="_default"!==l,m=null!==(a=null===(i=t.groups.get(l))||void 0===i?void 0:i.pieces[0])&&void 0!==a?a:n.pieceData[0],b=c?l:n.name,x=g(m,b),k=S>0?e/S*100:0,w=Object.assign(Object.assign({},m),{__funnelValue:e,__funnelPercent:k,__funnelStep:n.name,__funnelIsFirstStep:o,category:c?l:n.name});y&&(w.__funnelStepLabel=n.name,w.__funnelStepLabelX=p,w.__funnelStepLabelY=d,w.__funnelRowWidth=r,w.__funnelValueLabelX=p,w.__funnelValueLabelY=d,w.__funnelBarW=r),f.push(q(s,d,r,u,x,w,b)),h.set(l,{x:s,y:d,w:r,h:u})}if(e>0&&j.size>0){const e=x?v:[v[0]];for(const o of e){const e=j.get(o),r=h.get(o);if(!e||!r)continue;const i=(()=>{const e=t.groups.get(o);return g(e?e.pieces[0]:n.pieceData[0],"_default"===o?n.name:o)})(),a={type:"trapezoid",points:[[e.x,e.y+e.h],[e.x+e.w,e.y+e.h],[r.x+r.w,r.y],[r.x,r.y]],style:{fill:i.fill||"#999",opacity:M},datum:null!==(c=null===(l=t.groups.get(o))||void 0===l?void 0:l.pieces[0])&&void 0!==c?c:n.pieceData[0],category:"_default"===o?n.name:o};f.push(a)}}j=h}return f},"bar-funnel":function(e,t){var n,o,r,i;const{columns:a,getR:s,getStack:l,resolvePieceStyle:c,scales:u}=e,d=[],h=u.o.domain().map(e=>a[e]).filter(Boolean);if(0===h.length)return d;const g=[],f=new Set;for(const e of h)for(const t of e.pieceData){const e=l?l(t):"_default";f.has(e)||(f.add(e),g.push(e))}const p=g.length>1&&"_default"!==g[0],y=[];for(const e of h){const t=new Map;let n=0;for(const o of e.pieceData){const e=l?l(o):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const r=t.get(e),i=s(o);r.total+=i,r.pieces.push(o),n+=i}y.push({col:e,groups:t,stepTotal:n})}const m=new Map;for(const e of g){const t=null===(n=y[0])||void 0===n?void 0:n.groups.get(e);m.set(e,null!==(o=null==t?void 0:t.total)&&void 0!==o?o:0)}const v=u.r,b=p?g.length:1,x=p?.15:0;for(let e=0;y.length>e;e++){const t=y[e],n=t.col,o=0===e,a=e>0?y[e-1]:null,s=n.width/b,l=s*x,u=s-l;for(let e=0;g.length>e;e++){const h=g[e],f=t.groups.get(h);if(!f)continue;const y=f.total,b=null!==(r=m.get(h))&&void 0!==r?r:y,x=b>0?y/b*100:0,k=null==a?void 0:a.groups.get(h),w=null!==(i=null==k?void 0:k.total)&&void 0!==i?i:y,A=o?0:Math.max(0,w-y),S=n.x+e*s+l/2,O=v(y),E=v(0)-O,M=c(f.pieces[0],p?h:n.name),j=Object.assign(Object.assign({},f.pieces[0]),{__barFunnelValue:y,__barFunnelPercent:x,__barFunnelIsFirstStep:o,__barFunnelIsDropoff:!1,__barFunnelStep:n.name,__barFunnelDropoffValue:A,__barFunnelCategory:"_default"===h?void 0:h,category:p?h:n.name,__barFunnelLabelX:S+u/2,__barFunnelLabelY:v(y+A)});if(d.push(q(S,O,u,E,M,j,p?h:n.name)),A>0){const e=v(y+A),t=O-e,o=Object.assign({},M),r=Object.assign(Object.assign({},f.pieces[0]),{__barFunnelValue:A,__barFunnelPercent:b>0?A/b*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:n.name,__barFunnelCategory:"_default"===h?void 0:h,category:p?h:n.name});d.push(q(S,e,u,t,o,r,p?h:n.name))}}}return d},swimlane:function(e,t){const{scales:n,columns:o,getR:r,getStack:i,resolvePieceStyle:a}=e,{r:s,projection:l}=n,c=[],u="horizontal"===l;for(const e of Object.values(o)){let t=0;for(const n of e.pieceData){const o=Math.abs(r(n));if(0===o)continue;const l=i?i(n):e.name,d=a(n,l);if(u){const r=s(t),i=s(t+o);c.push(q(r,e.x,i-r,e.width,d,n,l))}else{const r=s(t+o),i=s(t);c.push(q(e.x,r,e.width,i-r,d,n,l))}t+=o}}return c}};class kr{constructor(e){this.rExtent=new w,this.rExtents=[],this.rAccessors=[],this.categories=new Set,this._hasStreamingData=!1,this._colorSchemeMap=null,this._colorSchemeIndex=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.version=0,this.config=e,this.buffer=new k(e.windowSize),this.getO=M(e.oAccessor||e.categoryAccessor,"category");const t="streaming"===e.runtimeMode,n=e.rAccessor;Array.isArray(n)?(this.rAccessors=n.map(e=>O(e,"value")),this.getR=this.rAccessors[0],this.rExtents=n.map(()=>new w)):(this.getR=O(t&&(e.timeAccessor||e.valueAccessor)&&e.valueAccessor||n,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=M(e.stackBy),this.getGroup=M(e.groupBy),this.getColor=M(e.colorAccessor),this.getConnector=M(e.connectorAccessor),this.getDataId=M(e.dataIdAccessor),e.pulse&&(this.timestampBuffer=new k(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{this._hasStreamingData=!0;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 r=n.toArray(),i=t.projection||"vertical",a=t.oExtent||this.resolveCategories(r),s=this.computeValueDomain(r,a),l="horizontal"===i,c=null!=t.barPadding?t.barPadding/("vertical"===i?e.width:e.height):.1;let u,d;if("radial"===i){u=o.scaleBand().domain(a).range([0,1]).padding(0);const n=Math.min(e.width,e.height)/2,r=t.innerRadius||0;d=o.scaleLinear().domain(s).range([r,n])}else l?(u=o.scaleBand().domain(a).range([0,e.height]).padding(c),d=o.scaleLinear().domain(s).range([0,e.width])):(u=o.scaleBand().domain(a).range([0,e.width]).padding(c),d=o.scaleLinear().domain(s).range([e.height,0]));this.scales={o:u,r:d,projection:i},this.multiScales=this.rAccessors.length>1&&t.multiAxis?this.rAccessors.map((r,i)=>{var a;const s=this.rExtents[i];s.dirty&&s.recalculate(n,r);let[c,u]=s.extent;c===1/0&&(c=0,u=1);const d=null!==(a=t.extentPadding)&&void 0!==a?a:.05,h=u-c,g=h>0?h*d:1;return c-=g,u+=g,c>0&&(c=0),l?o.scaleLinear().domain([c,u]).range([0,e.width]):o.scaleLinear().domain([c,u]).range([e.height,0])}):[];let h=r;this.rAccessors.length>1&&(h=r.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(h,a,u,i,e),this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(h,e),this.config.decay&&this.applyDecay(this.scene,r),this.config.pulse&&this.applyPulse(this.scene,r),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||this._hasStreamingData)&&void 0===n){const n=new Set;for(const t of e)n.add(this.getO(t));const o=Math.max(50,3*n.size);if(this.categories.size>o){let e=this.categories.size-o;for(const t of this.categories){if(0>=e)break;n.has(t)||(this.categories.delete(t),e--)}}return t.filter(e=>n.has(e))}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,r,i,a;const s=this.config.chartType,l=null!==(n=this.config.extentPadding)&&void 0!==n?n:.05;if("radial"===this.config.projection&&("pie"===s||"donut"===s))return[0,1];let c=0,u=0;if("bar"===s&&this.getStack&&this.config.normalize)c=0,u=1;else if("bar"===s&&this.getStack){const t=new Map,n=new Map;for(const o of e){const e=this.getO(o),r=this.getR(o);0>r?n.set(e,(n.get(e)||0)+r):t.set(e,(t.get(e)||0)+r)}for(const e of t.values())e>u&&(u=e);for(const e of n.values())c>e&&(c=e)}else if("bar"===s){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>u&&(u=e),c>e&&(c=e)}else if("swimlane"===s){const t=new Map;for(const n of e){const e=this.getO(n),o=Math.abs(this.getR(n));t.set(e,(t.get(e)||0)+o)}for(const e of t.values())e>u&&(u=e)}else if("clusterbar"===s||"bar-funnel"===s)for(const t of e){const e=this.getR(t);e>u&&(u=e),c>e&&(c=e)}else{const e=this.rExtent.extent[0],t=this.rExtent.extent[1];e!==1/0&&(c=e),t!==-1/0&&(u=t)}this.config.rExtent&&(null!=this.config.rExtent[0]&&(c=this.config.rExtent[0]),null!=this.config.rExtent[1]&&(u=this.config.rExtent[1]));const d="bar"===s||"clusterbar"===s||"bar-funnel"===s||"swimlane"===s;if(d&&null==(null===(o=this.config.rExtent)||void 0===o?void 0:o[0])&&null==(null===(r=this.config.rExtent)||void 0===r?void 0:r[1])&&(c>0&&(c=0),0>u&&(u=0)),"bar-funnel"!==s){const e=u-c,t=e>0?e*l:1;null!=(null===(i=this.config.rExtent)||void 0===i?void 0:i[0])||d&&!this.config.baselinePadding&&0===c||(c-=t),null!=(null===(a=this.config.rExtent)||void 0===a?void 0:a[1])||d&&!this.config.baselinePadding&&0===u||"swimlane"===s||(u+=t)}return[c,u]}buildColumns(e,t,n,o,r){var i;const a={},s=new Map;for(const t of e){const e=this.getO(t);s.has(e)||s.set(e,[]),s.get(e).push(t)}let l=0;if("radial"===o)for(const t of e)l+=Math.abs(this.getR(t));const c=this.config.dynamicColumnWidth;let u=null;if(c&&"radial"!==o){u=new Map;let e=0;for(const n of t){const t=s.get(n)||[];let o;o="string"==typeof c?t.reduce((e,t)=>e+(Number(t[c])||0),0):c(t),u.set(n,o),e+=o}const i=("horizontal"===o?r.height:r.width)-n.padding()*n.step()*t.length;if(e>0)for(const[t,n]of u)u.set(t,n/e*i)}let d=0,h=0;for(const e of t){const t=s.get(e)||[],o=t.reduce((e,t)=>e+Math.abs(this.getR(t)),0),r=l>0?o/l:0;let c,g;u?(c=h,g=u.get(e)||n.bandwidth(),h+=g+n.padding()*n.step()):(c=null!==(i=n(e))&&void 0!==i?i:0,g=n.bandwidth()),a[e]={name:e,x:c,y:0,width:g,middle:c+g/2,padding:n.padding()*n.step(),pieceData:t,pct:r,pctStart:d},d+=r}return a}getSceneContext(){return{scales:this.scales,columns:this.columns,config:this.config,getR:this.getR,getStack:this.getStack,getGroup:this.getGroup,getColor:this.getColor,getConnector:this.getConnector,getO:this.getO,multiScales:this.multiScales,rAccessors:this.rAccessors,resolvePieceStyle:(e,t)=>this.resolvePieceStyle(e,t),resolveSummaryStyle:(e,t)=>this.resolveSummaryStyle(e,t),getRawRange:e=>this.getRawRange(e)}}buildSceneNodes(e,t){if(!this.scales)return[];const n=this.getSceneContext(),o=xr[this.config.chartType];let r=o?o(n,t):[];if(this.getConnector&&this.scales){const e=function(e,t){const{scales:n,config:o,getConnector:r,getO:i}=e;if(!r||!n)return[];const a=[],{projection:s}=n,l=new Map;for(const e of t){if("point"!==e.type&&"rect"!==e.type)continue;const t=e.datum;if(!t)continue;const n=r(t);if(!n)continue;let o,a;"point"===e.type?(o=e.x,a=e.y):(o=e.x+e.w/2,a=e.y+("vertical"===s?0:e.h/2)),l.has(n)||l.set(n,[]),l.get(n).push({x:o,y:a,datum:t,category:i(t)})}const c=n.o.domain(),u=o.connectorStyle;for(const[e,t]of l)if(t.length>=2){t.sort((e,t)=>c.indexOf(e.category)-c.indexOf(t.category));for(let n=0;t.length-1>n;n++){const o=t[n],r=t[n+1],i="function"==typeof u?u(o.datum):u||{stroke:"#999",strokeWidth:1,opacity:.5};a.push({type:"connector",x1:o.x,y1:o.y,x2:r.x,y2:r.y,style:i,datum:o.datum,group:e})}}return a}(n,r);r=[...e,...r]}return r}resolvePieceStyle(e,t){if("function"==typeof this.config.pieceStyle){const n=this.config.pieceStyle(e,t);return n&&!n.fill&&t?Object.assign(Object.assign({},n),{fill:this.getColorFromScheme(t)}):n}return 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:P,o=n[this._colorSchemeIndex%n.length];return this._colorSchemeIndex++,this._colorSchemeMap.set(e,o),o}resolveSummaryStyle(e,t){return"function"==typeof this.config.summaryStyle?this.config.summaryStyle(e,t):this.config.summaryStyle&&"object"==typeof this.config.summaryStyle?this.config.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}computeDecayOpacity(e,t){var n,o,r;const i=this.config.decay;if(!i||1>=t)return 1;const a=null!==(n=i.minOpacity)&&void 0!==n?n:.1,s=t-1-e;switch(i.type){case"linear":return a+(1-s/(t-1))*(1-a);case"exponential":{const e=null!==(o=i.halfLife)&&void 0!==o?o:t/2;return a+Math.pow(.5,s/e)*(1-a)}case"step":return(null!==(r=i.stepThreshold)&&void 0!==r?r:.5*t)>s?1:a;default:return 1}}applyDecay(e,t){var n,o;if(!this.config.decay)return;const r=t.length;if(1>=r)return;const i=new Map;for(let e=0;t.length>e;e++)i.set(t[e],e);for(const t of e){if("connector"===t.type||"violin"===t.type||"boxplot"===t.type||"wedge"===t.type)continue;const e=i.get(t.datum);if(null==e)continue;const a=this.computeDecayOpacity(e,r),s=null!==(o=null===(n=t.style)||void 0===n?void 0:n.opacity)&&void 0!==o?o:1;t.style=Object.assign(Object.assign({},t.style),{opacity:s*a})}}applyPulse(e,t){var n,o,r;if(!this.config.pulse||!this.timestampBuffer)return;const i="undefined"!=typeof performance?performance.now():Date.now(),a=null!==(n=this.config.pulse.duration)&&void 0!==n?n:500,s=null!==(o=this.config.pulse.color)&&void 0!==o?o:"rgba(255,255,255,0.6)",l=null!==(r=this.config.pulse.glowRadius)&&void 0!==r?r:4,c=new Map;for(let e=0;t.length>e;e++)c.set(t[e],e);for(const n of e){if("connector"===n.type||"violin"===n.type||"boxplot"===n.type)continue;if("wedge"===n.type){const e=n.category;if(!e)continue;let o=0;for(let n=0;t.length>n;n++){const r=t[n],s=this.config.oAccessor;if(("function"==typeof s?s(r):r[s||"category"])!==e)continue;const l=this.timestampBuffer.get(n);if(null==l)continue;const c=i-l;if(a>c){const e=1-c/a;e>o&&(o=e)}}o>0&&(n._pulseIntensity=o,n._pulseColor=s);continue}const e=c.get(n.datum);if(null==e)continue;const o=this.timestampBuffer.get(e);if(null==o)continue;const r=i-o;a>r&&(n._pulseIntensity=1-r/a,n._pulseColor=s,n._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}getNodeKey(e,t){var n,o;if("point"===e.type){const n=`p:${e.datum?this.getO(e.datum):""}:${e.datum?this.getR(e.datum):0}`,o=t.get(n)||0;return t.set(n,o+1),`${n}:${o}`}return"rect"===e.type?`r:${e.group||""}:${null!==(o=null===(n=e.datum)||void 0===n?void 0:n.category)&&void 0!==o?o:""}`:null}snapshotPositions(){this.prevPositionMap.clear();const e=new Map;for(let t=0;this.scene.length>t;t++){const n=this.scene[t],o=this.getNodeKey(n,e);o&&("point"===n.type?this.prevPositionMap.set(o,{x:n.x,y:n.y,r:n.r,opacity:n.style.opacity}):"rect"===n.type&&this.prevPositionMap.set(o,{x:n.x,y:n.y,w:n.w,h:n.h,opacity:n.style.opacity}))}}startTransition(){var e,t,n,o,r,i,a,s,l,c,u,d;if(!this.config.transition||0===this.prevPositionMap.size)return;const h=null!==(e=this.config.transition.duration)&&void 0!==e?e:300;if(this.exitNodes.length>0){const e=new Set(this.exitNodes);this.scene=this.scene.filter(t=>!e.has(t)),this.exitNodes=[]}let g=!1;const f=new Set,p=new Map;for(let e=0;this.scene.length>e;e++){const s=this.scene[e],l=this.getNodeKey(s,p);if(!l)continue;s._transitionKey=l;const c=this.prevPositionMap.get(l);"point"===s.type?c?(f.add(l),s._targetOpacity=null!==(t=s.style.opacity)&&void 0!==t?t:1,c.x===s.x&&c.y===s.y||(s._targetX=s.x,s._targetY=s.y,s.x=c.x,s.y=c.y,g=!0)):(s._targetOpacity=null!==(n=s.style.opacity)&&void 0!==n?n:1,s.style=Object.assign(Object.assign({},s.style),{opacity:0}),g=!0):"rect"===s.type&&(c?(f.add(l),s._targetOpacity=null!==(o=s.style.opacity)&&void 0!==o?o:1,c.x===s.x&&c.y===s.y&&c.w===s.w&&c.h===s.h||(s._targetX=s.x,s._targetY=s.y,s._targetW=s.w,s._targetH=s.h,s.x=c.x,s.y=c.y,s.w=null!==(r=c.w)&&void 0!==r?r:s.w,s.h=null!==(i=c.h)&&void 0!==i?i:s.h,g=!0)):(s._targetOpacity=null!==(a=s.style.opacity)&&void 0!==a?a:1,s.style=Object.assign(Object.assign({},s.style),{opacity:0}),g=!0))}this.exitNodes=[];for(const[e,t]of this.prevPositionMap)f.has(e)||(e.startsWith("p:")?this.exitNodes.push({type:"point",x:t.x,y:t.y,r:null!==(s=t.r)&&void 0!==s?s:3,style:{opacity:null!==(l=t.opacity)&&void 0!==l?l:1},datum:null,_targetOpacity:0,_transitionKey:e}):e.startsWith("r:")&&this.exitNodes.push({type:"rect",x:t.x,y:t.y,w:null!==(c=t.w)&&void 0!==c?c:0,h:null!==(u=t.h)&&void 0!==u?u:0,style:{opacity:null!==(d=t.opacity)&&void 0!==d?d:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e}),g=!0);this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),g&&(this.activeTransition={startTime:F(),duration:h})}advanceTransition(e){var t,n,o;if(!this.activeTransition)return!1;const r=R(e,this.activeTransition),i=H(r,"linear"===(null===(t=this.config.transition)||void 0===t?void 0:t.easing)?"linear":"ease-out-cubic");for(const e of this.scene){const t=e._transitionKey;if(t)if("point"===e.type){if(void 0!==e._targetOpacity){const o=this.prevPositionMap.get(t),r=o?null!==(n=o.opacity)&&void 0!==n?n:1:0;e.style.opacity=W(r,e._targetOpacity,i)}if(void 0===e._targetX)continue;const o=this.prevPositionMap.get(t);if(!o)continue;e.x=W(o.x,e._targetX,i),e.y=W(o.y,e._targetY,i)}else if("rect"===e.type){if(void 0!==e._targetOpacity){const n=this.prevPositionMap.get(t),r=n?null!==(o=n.opacity)&&void 0!==o?o:1:0;e.style.opacity=W(r,e._targetOpacity,i)}if(void 0===e._targetX)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=W(n.x,e._targetX,i),e.y=W(n.y,e._targetY,i),void 0!==n.w&&(e.w=W(n.w,e._targetW,i),e.h=W(n.h,e._targetH,i))}}if(r>=1){for(const e of this.scene)if(void 0!==e._targetOpacity&&(e.style=Object.assign(Object.assign({},e.style||{}),{opacity:0===e._targetOpacity?0:e._targetOpacity}),e._targetOpacity=void 0),"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}if(this.exitNodes.length>0){const e=new Set(this.exitNodes);this.scene=this.scene.filter(t=>!e.has(t)),this.exitNodes=[]}return this.activeTransition=null,!1}return!0}getData(){return this.buffer.toArray()}remove(e){if(!this.getDataId)throw Error("remove() requires dataIdAccessor to be configured");const t=new Set(Array.isArray(e)?e:[e]),n=this.getDataId,o=e=>t.has(n(e));if(this.timestampBuffer&&this.timestampBuffer.size>0){const e=this.timestampBuffer.toArray(),t=new Set;this.buffer.forEach((e,n)=>{o(e)&&t.add(n)}),this.timestampBuffer.clear();for(let n=0;e.length>n;n++)t.has(n)||this.timestampBuffer.push(e[n])}const r=this.buffer.remove(o);if(0===r.length)return r;for(const e of r)this.evictValueExtent(e);return this.categories.clear(),this.buffer.forEach(e=>this.categories.add(this.getO(e))),this.version++,r}update(e,t){if(!this.getDataId)throw Error("update() requires dataIdAccessor to be configured");const n=new Set(Array.isArray(e)?e:[e]),o=this.getDataId,r=new Set;this.buffer.forEach((e,t)=>{n.has(o(e))&&r.add(t)});const i=this.buffer.update(e=>n.has(o(e)),t);if(0===i.length)return i;for(const e of i)this.evictValueExtent(e);return this.categories.clear(),this.buffer.forEach((e,t)=>{this.categories.add(this.getO(e)),r.has(t)&&this.pushValueExtent(e)}),this.version++,i}clear(){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this._hasStreamingData=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.exitNodes=[],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){const t=Object.assign({},this.config);if(e.colorScheme!==this.config.colorScheme&&(this._colorSchemeMap=null,this._colorSchemeIndex=0),Object.assign(this.config,e),(void 0!==e.oAccessor||void 0!==e.categoryAccessor)&&(S(e.oAccessor||e.categoryAccessor,t.oAccessor||t.categoryAccessor)||(this.getO=M(this.config.oAccessor||this.config.categoryAccessor,"category"),this.categories.clear())),void 0!==e.rAccessor){const n=Array.isArray(e.rAccessor)?e.rAccessor:[e.rAccessor],o=Array.isArray(t.rAccessor)?t.rAccessor:[t.rAccessor];if(n.length!==o.length||n.some((e,t)=>!S(e,o[t]))){const e=this.config.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(e=>O(e,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new w)):(this.getR=O(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in e&&!S(e.stackBy,t.stackBy)&&(this.getStack=null!=this.config.stackBy?M(this.config.stackBy):void 0),"groupBy"in e&&!S(e.groupBy,t.groupBy)&&(this.getGroup=null!=this.config.groupBy?M(this.config.groupBy):void 0),"colorAccessor"in e&&!S(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?M(this.config.colorAccessor):void 0),"connectorAccessor"in e&&!S(e.connectorAccessor,t.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?M(this.config.connectorAccessor):void 0)}}function wr(e,t,n){const o=J(t,n,e);return o.hit?{datum:e.datum,x:o.cx,y:e.y,distance:0,category:e.group}:null}function Ar(e,t,n,o=30){const r=t-e.x,i=n-e.y,a=Math.sqrt(r*r+i*i);return a>ee(e.r,o)?null:{datum:e.datum,x:e.x,y:e.y,distance:a}}function Sr(e,t,n){const o=t-e.cx,r=n-e.cy,i=Math.sqrt(o*o+r*r);if(e.innerRadius>i||i>e.outerRadius)return null;const a=oe(Math.atan2(r,o)),s=oe(e.startAngle),l=oe(e.endAngle);if(!(s>l?a>=s||l>=a:a>=s&&l>=a))return null;const c=(e.startAngle+e.endAngle)/2,u=(e.innerRadius+e.outerRadius)/2;return{datum:e.datum,x:e.cx+Math.cos(c)*u,y:e.cy+Math.sin(c)*u,distance:0,category:e.category}}function Or(e,t,n){const o=e.columnWidth/2;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:e.stats}}else{const r=e.y-o,i=e.y+o;if(!(Math.min(e.minPos,e.maxPos)>t||t>Math.max(e.minPos,e.maxPos)||r>n||n>i))return{datum:e.datum,x:e.medianPos,y:e.y,distance:0,category:e.category,stats:e.stats}}return null}function Er(e,t,n){if(!e.bounds)return null;const{x:o,y:r,width:i,height:a}=e.bounds;return o>t||t>o+i||r>n||n>r+a?null:{datum:e.datum,x:o+i/2,y:r+a/2,distance:0,category:e.category,stats:e.stats}}function Mr(t){const{width:n,height:o,totalWidth:r,totalHeight:i,margin:a,scales:s,showAxes:l,showGrid:c,rFormat:u}=t,{rTickValues:d}=t,h="radial"===(null==s?void 0:s.projection),g="horizontal"===(null==s?void 0:s.projection),f=e.useMemo(()=>!s||h?[]:(d||s.r.ticks(5)).map(e=>({value:e,pixel:s.r(e),label:(u||jr)(e)})),[s,u,h,d]),y=c&&s&&!h,m=l&&s&&!h;return y||m?p.createElement("svg",{width:r,height:i,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"}},p.createElement("g",{transform:`translate(${a.left},${a.top})`},y&&p.createElement("g",{className:"ordinal-grid"},f.map((e,t)=>p.createElement("line",{key:"grid-"+t,x1:g?e.pixel:0,y1:g?0:e.pixel,x2:g?e.pixel:n,y2:g?o:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),m&&p.createElement(p.Fragment,null,g?p.createElement(p.Fragment,null,p.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),p.createElement("line",{x1:0,y1:o,x2:n,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1})):p.createElement(p.Fragment,null,p.createElement("line",{x1:0,y1:o,x2:n,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),p.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}))))):null}function jr(e){return Math.round(100*e)/100+""}function Cr(t){var n,o;const{width:r,height:i,totalWidth:a,totalHeight:s,margin:l,scales:c,showAxes:u,showCategoryTicks:d,oLabel:h,rLabel:g,oFormat:f,rFormat:y,showGrid:m,title:v,legend:b,legendHoverBehavior:x,legendClickBehavior:k,legendHighlightedCategory:w,legendIsolatedCategories:A,legendPosition:S="right",foregroundGraphics:O,annotations:E,svgAnnotationRules:M,xAccessor:j,yAccessor:C,annotationData:P,underlayRendered:L,children:_}=t,B="radial"===(null==c?void 0:c.projection),T="horizontal"===(null==c?void 0:c.projection),N=!1!==d,D=e.useMemo(()=>u&&N&&c&&!B?c.o.domain().map((e,t)=>{var n;return{value:e,pixel:(null!==(n=c.o(e))&&void 0!==n?n:0)+c.o.bandwidth()/2,label:f?f(e,t):e}}):[],[u,N,c,f,B]),I=t.rTickValues,H=t.tickLabelEdgeAlign,R=e.useMemo(()=>u&&c&&!B?(I||c.r.ticks(5)).map(e=>({value:e,pixel:c.r(e),label:(y||jr)(e)})):[],[u,c,y,B,I]),W=e.useRef(new Map),F=e.useRef(null!==(n=null==E?void 0:E.length)&&void 0!==n?n:0),z=null!==(o=null==E?void 0:E.length)&&void 0!==o?o:0;F.current!==z&&(F.current=z,W.current=new Map);const $=e.useMemo(()=>{if(!E||0===E.length)return null;const e=Re(),t="horizontal"===(null==c?void 0:c.projection),n=(null==c?void 0:c.o)?e=>{var t;return(null!==(t=c.o(e))&&void 0!==t?t:0)+c.o.bandwidth()/2}:null,o={scales:c?{x:t?c.r:n||c.r,y:t&&n||c.r,time:c.r,value:c.r,o:c.o}:null,timeAxis:"x",xAccessor:j,yAccessor:C,width:r,height:i,data:P,frameType:"ordinal",projection:t?"horizontal":"vertical",stickyPositionCache:W.current};return E.map((t,n)=>{if(M){const r=M(t,n,o);return null!=r?r:e(t,n,o)}return e(t,n,o)}).filter(Boolean)},[E,M,r,i,c,j,C,P]);return u||v||b||O||$&&$.length>0||m||_?p.createElement("svg",{role:"img",width:a,height:s,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"}},p.createElement("title",null,"string"==typeof v?v:"Ordinal Chart"),p.createElement("desc",null,"string"==typeof v?v+" — ordinal data visualization":"Ordinal data visualization"),p.createElement("g",{transform:`translate(${l.left},${l.top})`},m&&c&&!B&&!L&&p.createElement("g",{className:"ordinal-grid"},R.map((e,t)=>p.createElement("line",{key:"grid-"+t,x1:T?e.pixel:0,y1:T?0:e.pixel,x2:T?e.pixel:r,y2:T?i:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),u&&c&&!B&&p.createElement("g",{className:"ordinal-axes"},T?p.createElement(p.Fragment,null,!L&&p.createElement("line",{x1:0,y1:0,x2:0,y2:i,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),D.map((e,t)=>p.createElement("g",{key:"cat-"+t,transform:`translate(0,${e.pixel})`},p.createElement("line",{x2:-5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?p.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"}},e.label):p.createElement("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"}},p.createElement("div",{style:{textAlign:"right",fontSize:10,userSelect:"none"}},e.label)))),h&&p.createElement("text",{x:15-l.left,y:i/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",transform:`rotate(-90, ${15-l.left}, ${i/2})`,style:{userSelect:"none"}},h),!L&&p.createElement("line",{x1:0,y1:i,x2:r,y2:i,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),!L&&(null==c?void 0:c.r)&&(()=>{const e=c.r(0);return e>1&&r-1>e?p.createElement("line",{x1:e,y1:0,x2:e,y2:i,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1,strokeDasharray:"4,4"}):null})(),R.map((e,t)=>{const n=H?0===t?"start":t===R.length-1?"end":"middle":"middle";return p.createElement("g",{key:"val-"+t,transform:`translate(${e.pixel},${i})`},p.createElement("line",{y2:5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),p.createElement("text",{y:18,textAnchor:n,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"}},e.label))}),g&&p.createElement("text",{x:r/2,y:i+40,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},g)):p.createElement(p.Fragment,null,!L&&(()=>{const e=(null==c?void 0:c.r)?c.r(0):i,t=0>e||e>i?i:e;return p.createElement("line",{x1:0,y1:t,x2:r,y2:t,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1})})(),D.map((e,t)=>p.createElement("g",{key:"cat-"+t,transform:`translate(${e.pixel},${i})`},p.createElement("line",{y2:5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?p.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"}},e.label):p.createElement("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"}},p.createElement("div",{style:{textAlign:"center",fontSize:10,userSelect:"none"}},e.label)))),h&&p.createElement("text",{x:r/2,y:i+40,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},h),!L&&p.createElement("line",{x1:0,y1:0,x2:0,y2:i,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),R.map((e,t)=>p.createElement("g",{key:"val-"+t,transform:`translate(0,${e.pixel})`},p.createElement("line",{x2:-5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),p.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"}},e.label))),g&&p.createElement("text",{x:15-l.left,y:i/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",transform:`rotate(-90, ${15-l.left}, ${i/2})`,style:{userSelect:"none"}},g))),$,O,_),v&&p.createElement("text",{x:a/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof v?v:null),Me({legend:b,totalWidth:a,totalHeight:s,margin:l,legendPosition:S,title:v,legendHoverBehavior:x,legendClickBehavior:k,legendHighlightedCategory:w,legendIsolatedCategories:A})):null}function Pr({width:o,height:r,totalWidth:i,totalHeight:a,margin:s,scales:l,onBrush:c}){const u=e.useRef(null),d=e.useRef(null),h=e.useRef(c);h.current=c;const g=e.useRef(l);g.current=l;const f=e.useRef(!1),y=e.useRef(null),m="horizontal"===(null==l?void 0:l.projection),v=e.useRef(m);return v.current=m,e.useEffect(()=>{if(!u.current)return;const e=t.select(u.current).select(".brush-g"),i=m?n.brushX():n.brushY();return i.extent([[0,0],[o,r]]),i.on("brush end",e=>{if(f.current)return;const t=g.current;if(!t)return;if(!e.selection)return y.current=null,void h.current(null);const[n,o]=e.selection;let r;r=v.current?[t.r.invert(n),t.r.invert(o)]:[t.r.invert(o),t.r.invert(n)];const i={r:r};y.current=i,h.current(i)}),e.call(i),d.current=i,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{i.on("brush end",null),d.current=null}},[o,r,m]),e.useEffect(()=>{if(!l||!d.current||!y.current)return;if(!u.current)return;const e=y.current,n=t.select(u.current).select(".brush-g"),o=l.r(e.r[0]),r=l.r(e.r[1]);m?(f.current=!0,n.call(d.current.move,[o,r]),f.current=!1):(f.current=!0,n.call(d.current.move,[r,o]),f.current=!1)},[l,m]),p.createElement("svg",{ref:u,width:i,height:a,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},p.createElement("g",{className:"brush-g",transform:`translate(${s.left},${s.top})`,style:{pointerEvents:"all"}}))}function Lr(e,t){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()}const _r=(e,t,n,o)=>{var r,i;const a=t.filter(e=>"wedge"===e.type);for(const t of a)Lr(e,t),e.globalAlpha=null!==(i=null!==(r=t.style.fillOpacity)&&void 0!==r?r:t.style.opacity)&&void 0!==i?i:1,e.fillStyle=("string"==typeof t.style.fill?Rt(e,t.style.fill):t.style.fill)||"#007bff",e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Rt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()),t._pulseIntensity&&t._pulseIntensity>0&&(Lr(e,t),Vt(e,t)),e.globalAlpha=1},Br=(e,t,n,o)=>{var r,i;const a=t.filter(e=>"violin"===e.type);for(const t of a){e.save(),(t.translateX||t.translateY)&&e.translate(t.translateX,t.translateY);const n=new Path2D(t.pathString);if(e.globalAlpha=null!==(i=null!==(r=t.style.fillOpacity)&&void 0!==r?r:t.style.opacity)&&void 0!==i?i:.6,e.fillStyle=("string"==typeof t.style.fill?Rt(e,t.style.fill):t.style.fill)||"#007bff",e.fill(n),e.globalAlpha=1,t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Rt(e,t.style.stroke)||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()}},Tr=(e,t,n,o)=>{var r,i,a;const s=t.filter(e=>"connector"===e.type);if(0===s.length)return;const l=new Map;for(const e of s){const t=e.group||"_default";l.has(t)||l.set(t,[]),l.get(t).push(e)}for(const[,t]of l){if(0===t.length)continue;const n=t[0].style;if(n.fill&&"none"!==n.fill){e.beginPath(),e.moveTo(t[0].x1,t[0].y1);for(const n of t)e.lineTo(n.x2,n.y2);e.closePath(),e.globalAlpha=null!==(i=null!==(r=n.fillOpacity)&&void 0!==r?r:n.opacity)&&void 0!==i?i:.3,e.fillStyle=n.fill,e.fill(),e.globalAlpha=1}for(const n of t)e.beginPath(),e.moveTo(n.x1,n.y1),e.lineTo(n.x2,n.y2),e.strokeStyle=Rt(e,n.style.stroke)||("string"==typeof n.style.fill?Rt(e,n.style.fill):n.style.fill)||"#999",e.lineWidth=n.style.strokeWidth||1,e.globalAlpha=null!==(a=n.style.opacity)&&void 0!==a?a:.5,e.stroke(),e.globalAlpha=1}};function Nr(e){return 1e6>e?1e4>e?1e3>e?e+"":(e/1e3).toFixed(1)+"K":(e/1e3).toFixed(0)+"K":(e/1e6).toFixed(1)+"M"}function Dr(e){return.05>Math.abs(e-Math.round(e))?Math.round(e)+"%":e.toFixed(1)+"%"}let Ir=null;const Hr=new Map;function Rr(e,t){const n=`${e}@${"undefined"!=typeof window&&window.devicePixelRatio||1}`,o=Hr.get(n);if(void 0!==o)return o;const r=function(e={},t){const{background:n="transparent",stroke:o="#000",lineWidth:r=1.5,spacing:i=6,angle:a=45}=e,s=Math.max(8,Math.ceil(2*i));let l;try{l=function(e){return"undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(e,e):(Ir||(Ir=document.createElement("canvas")),Ir.width=e,Ir.height=e,Ir)}(s)}catch(e){return null}const c=l.getContext("2d");if(!c)return null;n&&"transparent"!==n?(c.fillStyle=n,c.fillRect(0,0,s,s)):c.clearRect(0,0,s,s),c.strokeStyle=o,c.lineWidth=r,c.lineCap="square";const u=a*Math.PI/180;if(45===a||-45===a){const e=a>0?1:-1;for(let t=-s;2*s>=t;t+=i)c.beginPath(),c.moveTo(t,0),c.lineTo(t+e*s,s),c.stroke()}else{c.save(),c.translate(s/2,s/2),c.rotate(u);const e=2*s;for(let t=-e;e>=t;t+=i)c.beginPath(),c.moveTo(-e,t),c.lineTo(e,t),c.stroke();c.restore()}return(t||c).createPattern(l,"repeat")}({background:e,stroke:"rgba(255,255,255,0.5)",lineWidth:1.5,spacing:6,angle:45},t);return Hr.set(n,r),r}function Wr(e,t,n,o,r,i){e.moveTo(t+i,n),e.lineTo(t+o-i,n),e.quadraticCurveTo(t+o,n,t+o,n+i),e.lineTo(t+o,n+r-i),e.quadraticCurveTo(t+o,n+r,t+o-i,n+r),e.lineTo(t+i,n+r),e.quadraticCurveTo(t,n+r,t,n+r-i),e.lineTo(t,n+i),e.quadraticCurveTo(t,n,t+i,n),e.closePath()}function Fr(e){return 1e6>e?1e4>e?1e3>e?Math.round(e)+"":(e/1e3).toFixed(1)+"K":(e/1e3).toFixed(0)+"K":(e/1e6).toFixed(1)+"M"}function zr(e){return.05>Math.abs(e-Math.round(e))?Math.round(e)+"%":e.toFixed(1)+"%"}const $r=e=>[Tr,...e],Gr={bar:$r([en]),clusterbar:$r([en]),point:$r([Jt]),swarm:$r([Jt]),pie:[_r],donut:[_r],boxplot:$r([(e,t,n,o)=>{var r,i;const a=t.filter(e=>"boxplot"===e.type);for(const t of a){const n=t.columnWidth/2,o="vertical"===t.projection,a=t.style.fill||"#007bff",s=t.style.stroke||"#333",l=t.style.strokeWidth||1,c=null!==(i=null!==(r=t.style.fillOpacity)&&void 0!==r?r:t.style.opacity)&&void 0!==i?i:.6;if(e.save(),e.strokeStyle=s,e.lineWidth=l,e.beginPath(),o?(e.moveTo(t.x,t.minPos),e.lineTo(t.x,t.maxPos)):(e.moveTo(t.minPos,t.y),e.lineTo(t.maxPos,t.y)),e.stroke(),e.beginPath(),o?(e.moveTo(t.x-.4*n,t.minPos),e.lineTo(t.x+.4*n,t.minPos),e.moveTo(t.x-.4*n,t.maxPos),e.lineTo(t.x+.4*n,t.maxPos)):(e.moveTo(t.minPos,t.y-.4*n),e.lineTo(t.minPos,t.y+.4*n),e.moveTo(t.maxPos,t.y-.4*n),e.lineTo(t.maxPos,t.y+.4*n)),e.stroke(),e.globalAlpha=c,e.fillStyle=a,o){const o=Math.min(t.q1Pos,t.q3Pos),r=Math.abs(t.q3Pos-t.q1Pos);e.fillRect(t.x-n,o,t.columnWidth,r),e.globalAlpha=1,e.strokeRect(t.x-n,o,t.columnWidth,r)}else{const o=Math.min(t.q1Pos,t.q3Pos),r=Math.abs(t.q3Pos-t.q1Pos);e.fillRect(o,t.y-n,r,t.columnWidth),e.globalAlpha=1,e.strokeRect(o,t.y-n,r,t.columnWidth)}e.strokeStyle="#fff",e.lineWidth=2,e.beginPath(),o?(e.moveTo(t.x-n,t.medianPos),e.lineTo(t.x+n,t.medianPos)):(e.moveTo(t.medianPos,t.y-n),e.lineTo(t.medianPos,t.y+n)),e.stroke(),e.restore()}},Jt]),violin:$r([Br]),histogram:$r([en]),ridgeline:$r([Br]),timeline:$r([en]),funnel:[en,(e,t,n,o)=>{var r,i,a,s;const l=t.filter(e=>"trapezoid"===e.type);for(const t of l){const n=t.points;if(n.length>=4){e.globalAlpha=null!==(i=null===(r=t.style)||void 0===r?void 0:r.opacity)&&void 0!==i?i:1,e.beginPath(),e.moveTo(n[0][0],n[0][1]);for(let t=1;n.length>t;t++)e.lineTo(n[t][0],n[t][1]);e.closePath(),e.fillStyle=(null===(a=t.style)||void 0===a?void 0:a.fill)||"#999",e.fill(),(null===(s=t.style)||void 0===s?void 0:s.stroke)&&(e.strokeStyle=Rt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()),e.globalAlpha=1}}},(e,t,n,o)=>{var r,i,a,s;const l=t.filter(e=>"rect"===e.type&&null!=e.datum);if(0!==l.length&&l.some(e=>null!=e.datum.__funnelStepLabel||null!=e.datum.__funnelValueLabelX)){e.textBaseline="top",e.lineJoin="round",e.textAlign="center",e.font="bold 14px sans-serif";for(const t of l){const n=t.datum;if(!n.__funnelStepLabel)continue;const o=n.__funnelStepLabel;if(e.measureText(o).width+16>(null!==(i=null!==(r=n.__funnelRowWidth)&&void 0!==r?r:n.__funnelBarW)&&void 0!==i?i:0))continue;const a=n.__funnelStepLabelX,s=n.__funnelStepLabelY+3;e.strokeStyle="rgba(0,0,0,0.6)",e.lineWidth=3,e.strokeText(o,a,s),e.fillStyle="#fff",e.fillText(o,a,s)}e.font="bold 13px sans-serif";for(const t of l){const n=t.datum;if(null==n.__funnelValueLabelX)continue;const o=null!==(a=n.__funnelBarW)&&void 0!==a?a:0;if(60>o)continue;const r=n.__funnelValue;if(null==r||0===r)continue;const i=n.__funnelPercent,l=!0===n.__funnelIsFirstStep;let c;if(c=l?Nr(r):null!=i?`${Nr(r)} (${Dr(i)})`:Nr(r),e.measureText(c).width+16>o){if(l||null==i)continue;if(c=Nr(r),e.measureText(c).width+16>o)continue}const u=n.__funnelValueLabelX,d=(null!==(s=n.__funnelValueLabelY)&&void 0!==s?s:t.y)+14+5;e.textAlign="center",e.strokeStyle="rgba(0,0,0,0.5)",e.lineWidth=3,e.strokeText(c,u,d),e.fillStyle="#fff",e.fillText(c,u,d)}e.lineWidth=1,e.lineJoin="miter"}}],"bar-funnel":[en,(e,t,n,o)=>{var r,i;const a=t.filter(e=>{var t;return"rect"===e.type&&!0===(null===(t=e.datum)||void 0===t?void 0:t.__barFunnelIsDropoff)});for(const t of a){const n="string"==typeof t.style.fill?t.style.fill:"#999",o=Rr(n,e);e.globalAlpha=null!==(r=t.style.opacity)&&void 0!==r?r:1,e.beginPath(),e.rect(t.x,t.y,t.w,t.h),o?e.fillStyle=o:(e.fillStyle=n,e.globalAlpha=.4*(null!==(i=t.style.opacity)&&void 0!==i?i:1)),e.fill(),e.globalAlpha=1}},(e,t,n,o)=>{const r=t.filter(e=>{var t,n;return"rect"===e.type&&!0!==(null===(t=e.datum)||void 0===t?void 0:t.__barFunnelIsDropoff)&&null!=(null===(n=e.datum)||void 0===n?void 0:n.__barFunnelLabelX)});if(0!==r.length){for(const t of r){const n=t.datum,o=n.__barFunnelValue;if(null==o)continue;if(25>t.w)continue;const r=n.__barFunnelPercent,i=!(!0===n.__barFunnelIsFirstStep)&&null!=r,a=i?zr(r):"",s=Fr(o);e.font="bold 13px sans-serif";const l=i?e.measureText(a).width:0;e.font="11px sans-serif";const c=e.measureText(s).width,u=Math.max(l,c)+12,d=i?32:17,h=n.__barFunnelLabelX,g=h-u/2,f=n.__barFunnelLabelY-d-4;e.save(),e.shadowColor="rgba(0,0,0,0.15)",e.shadowBlur=4,e.shadowOffsetY=1,e.fillStyle="rgba(255,255,255,0.95)",e.beginPath(),Wr(e,g,f,u,d,4),e.fill(),e.restore(),e.strokeStyle="rgba(0,0,0,0.12)",e.lineWidth=.5,e.beginPath(),Wr(e,g,f,u,d,4),e.stroke(),e.textAlign="center",e.textBaseline="top",i?(e.font="bold 13px sans-serif",e.fillStyle="#333",e.fillText(a,h,f+3),e.font="11px sans-serif",e.fillStyle="#666",e.fillText(s,h,f+3+13+2)):(e.font="bold 11px sans-serif",e.fillStyle="#333",e.fillText(s,h,f+3))}e.lineWidth=1}}],swimlane:$r([en])},Yr={top:50,right:40,bottom:60,left:70},qr={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 Xr({hover:e}){var t,n,o,r,i,a;const s=e.data||{},l=e.stats,c=e.category;if(Array.isArray(s)){const e=c||(null===(t=s[0])||void 0===t?void 0:t.category)||"";if(l)return p.createElement("div",{className:"semiotic-tooltip",style:qr},e&&p.createElement("div",{style:{fontWeight:"bold"}},e+""),p.createElement("div",null,"n = ",l.n),p.createElement("div",null,"Min: ",l.min.toLocaleString()),p.createElement("div",null,"Q1: ",l.q1.toLocaleString()),p.createElement("div",null,"Median: ",l.median.toLocaleString()),p.createElement("div",null,"Q3: ",l.q3.toLocaleString()),p.createElement("div",null,"Max: ",l.max.toLocaleString()),p.createElement("div",{style:{opacity:.8}},"Mean: ",l.mean.toLocaleString(void 0,{maximumFractionDigits:2})));const n=s.length;return p.createElement("div",{className:"semiotic-tooltip",style:qr},e&&p.createElement("div",{style:{fontWeight:"bold"}},e+""),p.createElement("div",null,n," items"))}if(null!=s.bin&&null!=s.count){const e=s.range||[];return p.createElement("div",{className:"semiotic-tooltip",style:qr},s.category&&p.createElement("div",{style:{fontWeight:"bold"}},s.category+""),p.createElement("div",null,"Count: ",s.count),2===e.length&&p.createElement("div",{style:{opacity:.8}},Number(e[0]).toFixed(1)," – ",Number(e[1]).toFixed(1)))}const u=e.__oAccessor,d=e.__rAccessor,h=e.__chartType;if("swarm"===h||"point"===h){const e=Object.entries(s).filter(([e])=>!e.startsWith("_")&&"data"!==e);return p.createElement("div",{className:"semiotic-tooltip",style:qr},e.map(([e,t])=>p.createElement("div",{key:e},p.createElement("span",{style:{opacity:.7}},e,":")," ","number"==typeof t?t.toLocaleString():t+"")))}const g=(u&&null!=s[u]?s[u]:null)||s.category||s.name||s.group||s.__rName||"",f=null!==(a=null!==(i=null!==(r=null!==(o=null!==(n=s.__aggregateValue)&&void 0!==n?n:d&&null!=s[d]?s[d]:null)&&void 0!==o?o:s.value)&&void 0!==r?r:s.__rValue)&&void 0!==i?i:s.pct)&&void 0!==a?a:"";if(!g&&""===f){const e=Object.entries(s).filter(([e])=>!e.startsWith("_")&&"data"!==e);return p.createElement("div",{className:"semiotic-tooltip",style:qr},e.map(([e,t])=>p.createElement("div",{key:e},p.createElement("span",{style:{opacity:.7}},e,":")," ","number"==typeof t?t.toLocaleString():t+"")))}return p.createElement("div",{className:"semiotic-tooltip",style:qr},g&&p.createElement("div",{style:{fontWeight:"bold"}},g+""),""!==f&&p.createElement("div",null,"number"==typeof f?f.toLocaleString():f+""))}const Vr=e.forwardRef(function(t,n){var o,r,i,a,s,c,u,d,h,g;const{chartType:f,runtimeMode:y,data:m,oAccessor:v="category",rAccessor:b="value",colorAccessor:k,stackBy:w,groupBy:A,multiAxis:S,timeAccessor:O,valueAccessor:E,categoryAccessor:M,projection:j="vertical",size:C=[600,400],responsiveWidth:P,responsiveHeight:L,margin:_,barPadding:B,baselinePadding:T,innerRadius:N,normalize:D,startAngle:I,sweepAngle:H,dynamicColumnWidth:R,bins:W,showOutliers:F,showIQR:z,amplitude:$,connectorOpacity:G,showLabels:Y,connectorAccessor:q,connectorStyle:X,dataIdAccessor:V,rExtent:U,oExtent:K,extentPadding:Q=.05,oSort:Z,windowMode:J="sliding",windowSize:ee=200,pieceStyle:te,summaryStyle:ne,colorScheme:oe,barColors:re,showAxes:ie=!0,showCategoryTicks:ae,oLabel:se,rLabel:le,oFormat:ce,rFormat:ue,rTickValues:de,tickLabelEdgeAlign:he,enableHover:ge=!0,hoverAnnotation:me,tooltipContent:ke,customHoverBehavior:we,annotations:Ae,svgAnnotationRules:Se,showGrid:Oe=!1,legend:Ee,legendHoverBehavior:Me,legendClickBehavior:je,legendHighlightedCategory:Ce,legendIsolatedCategories:Pe,legendPosition:Le,backgroundGraphics:_e,foregroundGraphics:Be,title:Te,className:Ne,background:De,centerContent:Ie,decay:He,pulse:Re,transition:We,staleness:Fe,brush:ze,onBrush:$e,accessibleTable:Ge=!0,description:Ye,summary:qe}=t,Xe=Mt(),Ve=e.useRef(Xe);Ve.current=Xe;const[Ue,Ke]=be(C,P,L),Qe=e.useMemo(()=>Object.assign(Object.assign({},Yr),_),[_]),Ze=Ke[0]-Qe.left-Qe.right,Je=Ke[1]-Qe.top-Qe.bottom,et="function"==typeof Be?Be({size:Ke,margin:Qe}):Be,tt=e.useRef(null),rt=e.useRef(!0),it=Tt(e=>e.theme),at=e.useRef(0),st=e.useRef(null),ct=e.useRef(()=>{}),[ut,dt]=e.useState(null),[ht,gt]=e.useState(null),[ft,pt]=e.useState(0),[yt,mt]=e.useState(!1),bt=ge||me,At="streaming"===y,Et=e.useMemo(()=>({chartType:f,runtimeMode:At?"streaming":"bounded",windowSize:ee,windowMode:J,extentPadding:Q,projection:j,oAccessor:At?void 0:v,rAccessor:At?void 0:b,colorAccessor:k,stackBy:w,groupBy:A,multiAxis:S,timeAccessor:At?O:void 0,valueAccessor:At?E||("string"==typeof b||"function"==typeof b?b:void 0):void 0,categoryAccessor:At?M||v:void 0,rExtent:U,oExtent:K,barPadding:B,baselinePadding:T,innerRadius:N,normalize:D,startAngle:I,sweepAngle:H,dynamicColumnWidth:R,bins:W,showOutliers:F,showIQR:z,amplitude:$,connectorOpacity:G,showLabels:Y,connectorAccessor:q,connectorStyle:X,dataIdAccessor:V,oSort:Z,pieceStyle:te,summaryStyle:ne,colorScheme:oe,barColors:re,decay:He,pulse:Re,transition:We,staleness:Fe}),[f,ee,J,Q,j,v,b,k,w,A,S,O,E,M,U,K,B,T,N,D,I,H,R,W,F,z,$,G,Y,q,X,V,Z,te,ne,oe,re,He,Re,We,Fe,At]),jt=e.useRef(null);jt.current||(jt.current=new kr(Et));const Ct=e.useCallback(()=>{at.current||(at.current=requestAnimationFrame(()=>ct.current()))},[]);e.useEffect(()=>{var e;null===(e=jt.current)||void 0===e||e.updateConfig(Et),rt.current=!0,Ct()},[Et,Ct]),e.useEffect(()=>{tt.current&&Wt(tt.current),rt.current=!0,Ct()},[it,Ct]);const Pt=e.useRef(null);Pt.current||(Pt.current=new x(e=>{const t=jt.current;t&&t.ingest(e)&&(rt.current=!0,Ct())}));const Lt=e.useCallback(e=>{var t;null===(t=Pt.current)||void 0===t||t.push(e)},[]),_t=e.useCallback(e=>{var t;null===(t=Pt.current)||void 0===t||t.pushMany(e)},[]),Bt=e.useCallback(()=>{var e,t;null===(e=Pt.current)||void 0===e||e.clear(),null===(t=jt.current)||void 0===t||t.clear(),rt.current=!0,Ct()},[Ct]);e.useImperativeHandle(n,()=>({push:Lt,pushMany:_t,remove:e=>{var t,n,o;null===(t=Pt.current)||void 0===t||t.flush();const r=null!==(o=null===(n=jt.current)||void 0===n?void 0:n.remove(e))&&void 0!==o?o:[];return r.length>0&&(rt.current=!0,Ct()),r},update:(e,t)=>{var n,o,r;null===(n=Pt.current)||void 0===n||n.flush();const i=null!==(r=null===(o=jt.current)||void 0===o?void 0:o.update(e,t))&&void 0!==r?r:[];return i.length>0&&(rt.current=!0,Ct()),i},clear:Bt,getData:()=>{var e,t,n;return null===(e=Pt.current)||void 0===e||e.flush(),null!==(n=null===(t=jt.current)||void 0===t?void 0:t.getData())&&void 0!==n?n:[]},getScales:()=>{var e,t;return null!==(t=null===(e=jt.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null}}),[Lt,_t,Bt,Ct]),e.useEffect(()=>{var e;m&&(null===(e=Pt.current)||void 0===e||e.setBoundedData(m))},[m]);const Nt=e.useRef(()=>{}),It=e.useRef(()=>{});Nt.current=e=>{if(!bt)return;const t=tt.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-Qe.left,r=e.clientY-n.top-Qe.top;if(0>o||o>Ze||0>r||r>Je)return void(st.current&&(st.current=null,dt(null),we&&we(null),Ct()));const i=jt.current;if(!i||0===i.scene.length)return;const a="radial"===j,s=function(e,t,n,o=30){let r=null;for(const i of e){let e=null;switch(i.type){case"rect":e=wr(i,t,n);break;case"point":e=Ar(i,t,n,o);break;case"wedge":e=Sr(i,t,n);break;case"boxplot":e=Or(i,t,n);break;case"violin":e=Er(i,t,n)}e&&o>e.distance&&(r&&e.distance>=r.distance||(r=e))}return r}(i.scene,a?o-Ze/2:o,a?r-Je/2:r);if(!s)return void(st.current&&(st.current=null,dt(null),we&&we(null),Ct()));const l=s.datum||{},c=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},"object"!=typeof l||null===l||Array.isArray(l)?{}:l),{data:l,time:s.x,value:s.y,x:s.x,y:s.y}),s.stats&&{stats:s.stats}),s.category&&{category:s.category}),{__oAccessor:"string"==typeof v?v:void 0,__rAccessor:"string"==typeof b?b:void 0,__chartType:f});st.current=c,dt(c),we&&(we(c),rt.current=!0),Ct()},It.current=()=>{st.current&&(st.current=null,dt(null),we&&(we(null),rt.current=!0),Ct())},e.useCallback(e=>Nt.current(e),[]);const Ht=e.useCallback(()=>It.current(),[]),Rt=e.useRef(-1),Ft=e.useRef(null),zt=e.useRef(null),$t=e.useCallback(e=>{const t=jt.current;if(!t||0===t.scene.length)return;const n=t.version;let o;if(zt.current&&zt.current.version===n)o=zt.current.graph;else{const e=function(e){var t,n,o,r;const i=[];for(const a of e)if("rect"===a.type&&null!=a.x){const e=null!==(n=null===(t=a.datum)||void 0===t?void 0:t.category)&&void 0!==n?n:"";i.push({x:a.x+a.w/2,y:a.y+a.h/2,datum:a.datum,shape:"rect",w:a.w,h:a.h,group:null!==(o=a.group)&&void 0!==o?o:e})}else if("point"===a.type)i.push({x:a.x,y:a.y,datum:a.datum,shape:"circle",group:null!==(r=a.group)&&void 0!==r?r:"_default"});else if("wedge"===a.type&&null!=a.cx){const e=((a.startAngle||0)+(a.endAngle||0))/2,t=((a.innerRadius||0)+(a.outerRadius||50))/2;i.push({x:a.cx+Math.cos(e)*t,y:a.cy+Math.sin(e)*t,datum:a.datum,shape:"wedge",group:"_default"})}return i.sort((e,t)=>e.x-t.x||e.y-t.y),i}(t.scene);if(0===e.length)return;o=fe(e),zt.current={version:n,graph:o}}const r=Rt.current;if(0>r){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(e.key))return;e.preventDefault(),Rt.current=0;const t=o.flat[0];Ft.current={shape:t.shape,w:t.w,h:t.h};const n=Object.assign(Object.assign({},ve(t)),{__oAccessor:"string"==typeof v?v:void 0,__rAccessor:"string"==typeof b?b:void 0,__chartType:f});return st.current=n,dt(n),we&&we(n),void Ct()}const i=pe(o,r),a=ye(e.key,i,o);if(null===a)return;if(e.preventDefault(),0>a)return Rt.current=-1,Ft.current=null,st.current=null,dt(null),we&&we(null),void Ct();Rt.current=a;const s=o.flat[a];Ft.current={shape:s.shape,w:s.w,h:s.h};const l=Object.assign(Object.assign({},ve(s)),{__oAccessor:"string"==typeof v?v:void 0,__rAccessor:"string"==typeof b?b:void 0,__chartType:f});st.current=l,dt(l),we&&we(l),Ct()},[we,Ct]),Gt=e.useCallback(e=>{Rt.current=-1,Ft.current=null,Nt.current(e)},[]);ct.current=()=>{var e,t;at.current=0;const n=tt.current;if(!n)return;const o=n.getContext("2d");if(!o)return;const r=jt.current;if(!r)return;const i="undefined"!=typeof performance?performance.now():Date.now(),a=r.advanceTransition(Ve.current?i+1e6:i),s=!Ve.current&&a,l=rt.current;l&&!a&&(r.computeScene({width:Ze,height:Je}),rt.current=!1),(l||s)&&n.setAttribute("aria-label",lt(r.scene,f+" chart"));const c=Dt(),u=Ke[0]*c,d=Ke[1]*c;n.width===u&&n.height===d||(n.width=u,n.height=d,n.style.width=Ke[0]+"px",n.style.height=Ke[1]+"px"),o.setTransform(c,0,0,c,0,0),o.clearRect(0,0,Ke[0],Ke[1]);const h=null!==(e=null==Fe?void 0:Fe.threshold)&&void 0!==e?e:5e3,g=Fe&&r.lastIngestTime>0&&i-r.lastIngestTime>h;g&&(o.globalAlpha=null!==(t=null==Fe?void 0:Fe.dimOpacity)&&void 0!==t?t:.5);const p=n?getComputedStyle(n).getPropertyValue("--semiotic-bg").trim():"",y=De||(p&&"transparent"!==p?p:null);y&&(o.fillStyle=y,o.fillRect(0,0,Ke[0],Ke[1]));const m="radial"===j;o.save(),o.beginPath(),o.rect(Qe.left,Qe.top,Ze,Je),o.clip(),m?(o.save(),o.translate(Qe.left+Ze/2,Qe.top+Je/2)):o.translate(Qe.left,Qe.top);const v=Gr[f]||[],b={width:Ze,height:Je};for(const e of v)e(o,r.scene,r.scales,b);m&&o.restore(),o.restore(),g&&(o.globalAlpha=1),l&&r.scales&&(gt(r.scales),pt(e=>e+1)),(null==Fe?void 0:Fe.showBadge)&&mt(!!g),(s||r.hasActivePulses)&&(at.current=requestAnimationFrame(()=>ct.current()))},e.useEffect(()=>(Ct(),()=>{at.current&&(cancelAnimationFrame(at.current),at.current=0)}),[Ct]),e.useEffect(()=>{rt.current=!0,Ct()},[f,Ze,Je,ie,De,Ct]),xe(Fe,jt,rt,Ct,yt,mt);const Yt=bt&&ut?ke?ke(ut):p.createElement(Xr,{hover:ut}):null,qt="radial"===j,Xt=Yt?p.createElement(Ot,{x:ut?qt?ut.x+Ze/2:ut.x:0,y:ut?qt?ut.y+Je/2:ut.y:0,containerWidth:Ze,containerHeight:Je,margin:Qe,className:"stream-ordinal-tooltip"},Yt):null;if(ot){const e=jt.current;e&&m&&(e.ingest({inserts:m,bounded:!0}),e.computeScene({width:Ze,height:Je}));const t=null!==(o=null==e?void 0:e.scene)&&void 0!==o?o:[],n=null!==(r=null==e?void 0:e.scales)&&void 0!==r?r:null,i="radial"===j,a=i?Qe.left+Ze/2:Qe.left,s=i?Qe.top+Je/2:Qe.top;return p.createElement("div",{className:"stream-ordinal-frame"+(Ne?" "+Ne:""),role:"img","aria-label":Ye||("string"==typeof Te?Te:"Ordinal chart"),style:{position:"relative",width:Ke[0],height:Ke[1]}},p.createElement(xt,{summary:qe}),p.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:Ke[0],height:Ke[1],style:{position:"absolute",left:0,top:0}},_e&&p.createElement("g",{transform:`translate(${Qe.left},${Qe.top})`},_e),p.createElement("g",{transform:`translate(${a},${s})`},De&&p.createElement("rect",{x:0,y:0,width:Ze,height:Je,fill:De}),t.map((e,t)=>function(e,t){var n,o,r,i,a;const s=e.category||e.group||"",c=n=>`ord-${e.type}-${s}-${t}-${n}`,u=`ord-${e.type}-${s}-${t}`;switch(e.type){case"rect":{const t=e;return p.createElement("rect",{key:u,x:t.x,y:t.y,width:t.w,height:t.h,fill:nt(t.style.fill),opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth})}case"point":{const t=e;return p.createElement("circle",{key:u,cx:t.x,cy:t.y,r:t.r,fill:nt(t.style.fill),opacity:null!==(n=t.style.opacity)&&void 0!==n?n:.8,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth})}case"wedge":{const t=e,n=l.arc().innerRadius(t.innerRadius).outerRadius(t.outerRadius).startAngle(t.startAngle).endAngle(t.endAngle)({})||"";return p.createElement("path",{key:u,d:n,transform:`translate(${t.cx},${t.cy})`,fill:nt(t.style.fill),stroke:t.style.stroke,strokeWidth:t.style.strokeWidth,opacity:t.style.opacity})}case"boxplot":{const t=e,n=t.columnWidth/2;return"vertical"===t.projection?p.createElement("g",{key:u},p.createElement("line",{x1:t.x,y1:t.minPos,x2:t.x,y2:t.maxPos,stroke:t.style.stroke||"#333",strokeWidth:1}),p.createElement("rect",{x:t.x-n,y:Math.min(t.q1Pos,t.q3Pos),width:t.columnWidth,height:Math.abs(t.q3Pos-t.q1Pos),fill:nt(t.style.fill),fillOpacity:null!==(o=t.style.fillOpacity)&&void 0!==o?o:.6,stroke:t.style.stroke||"#333",strokeWidth:1}),p.createElement("line",{x1:t.x-n,y1:t.medianPos,x2:t.x+n,y2:t.medianPos,stroke:t.style.stroke||"#333",strokeWidth:2}),p.createElement("line",{x1:t.x-.5*n,y1:t.minPos,x2:t.x+.5*n,y2:t.minPos,stroke:t.style.stroke||"#333",strokeWidth:1}),p.createElement("line",{x1:t.x-.5*n,y1:t.maxPos,x2:t.x+.5*n,y2:t.maxPos,stroke:t.style.stroke||"#333",strokeWidth:1})):p.createElement("g",{key:u},p.createElement("line",{x1:t.minPos,y1:t.y,x2:t.maxPos,y2:t.y,stroke:t.style.stroke||"#333",strokeWidth:1}),p.createElement("rect",{x:Math.min(t.q1Pos,t.q3Pos),y:t.y-n,width:Math.abs(t.q3Pos-t.q1Pos),height:t.columnWidth,fill:nt(t.style.fill),fillOpacity:null!==(r=t.style.fillOpacity)&&void 0!==r?r:.6,stroke:t.style.stroke||"#333",strokeWidth:1}),p.createElement("line",{x1:t.medianPos,y1:t.y-n,x2:t.medianPos,y2:t.y+n,stroke:t.style.stroke||"#333",strokeWidth:2}),p.createElement("line",{x1:t.minPos,y1:t.y-.5*n,x2:t.minPos,y2:t.y+.5*n,stroke:t.style.stroke||"#333",strokeWidth:1}),p.createElement("line",{x1:t.maxPos,y1:t.y-.5*n,x2:t.maxPos,y2:t.y+.5*n,stroke:t.style.stroke||"#333",strokeWidth:1}))}case"violin":{const t=e,n=[p.createElement("path",{key:c("path"),d:t.pathString,transform:t.translateX||t.translateY?`translate(${t.translateX},${t.translateY})`:void 0,fill:nt(t.style.fill),fillOpacity:null!==(i=t.style.fillOpacity)&&void 0!==i?i:.6,stroke:t.style.stroke||"#333",strokeWidth:t.style.strokeWidth||1})];if(t.iqrLine&&t.bounds){const e=t.bounds,o=e.x+e.width/2,r=e.y+e.height/2;e.height>e.width?n.push(p.createElement("line",{key:c("iqr"),x1:o,y1:t.iqrLine.q1Pos,x2:o,y2:t.iqrLine.q3Pos,stroke:t.style.stroke||"#333",strokeWidth:2}),p.createElement("circle",{key:c("med"),cx:o,cy:t.iqrLine.medianPos,r:3,fill:"white",stroke:t.style.stroke||"#333",strokeWidth:1})):n.push(p.createElement("line",{key:c("iqr"),x1:t.iqrLine.q1Pos,y1:r,x2:t.iqrLine.q3Pos,y2:r,stroke:t.style.stroke||"#333",strokeWidth:2}),p.createElement("circle",{key:c("med"),cx:t.iqrLine.medianPos,cy:r,r:3,fill:"white",stroke:t.style.stroke||"#333",strokeWidth:1}))}return p.createElement("g",{key:u},n)}case"connector":return p.createElement("line",{key:u,x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:null!==(a=e.style.opacity)&&void 0!==a?a:.5});case"trapezoid":{const t=e,n=t.points.map(e=>`${e[0]},${e[1]}`).join(" ");return p.createElement("polygon",{key:u,points:n,fill:nt(t.style.fill,"#999"),opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth})}default:return null}}(e,t)).filter(Boolean))),p.createElement(Cr,{width:Ze,height:Je,totalWidth:Ke[0],totalHeight:Ke[1],margin:Qe,scales:n,showAxes:ie,showCategoryTicks:ae,oLabel:se,rLabel:le,oFormat:ce,rFormat:ue,rTickValues:de,tickLabelEdgeAlign:he,showGrid:Oe,title:Te,legend:Ee,legendHoverBehavior:Me,legendClickBehavior:je,legendHighlightedCategory:Ce,legendIsolatedCategories:Pe,legendPosition:Le,foregroundGraphics:et,annotations:Ae,svgAnnotationRules:Se,annotationFrame:0,xAccessor:"string"==typeof v?v:void 0,yAccessor:"string"==typeof b?b:void 0,annotationData:null==e?void 0:e.getData()}),Ie&&"radial"===j&&p.createElement("div",{style:{position:"absolute",left:Qe.left+Ze/2,top:Qe.top+Je/2,transform:"translate(-50%, -50%)",pointerEvents:"none",textAlign:"center"}},Ie))}const Vt="semiotic-table-"+p.useId();return p.createElement("div",{ref:Ue,className:"stream-ordinal-frame"+(Ne?" "+Ne:""),role:"group","aria-label":Ye||("string"==typeof Te?Te:"Ordinal chart"),tabIndex:0,style:{position:"relative",width:P?"100%":Ke[0],height:L?"100%":Ke[1],overflow:"visible"},onKeyDown:$t},Ge&&p.createElement(kt,{tableId:Vt}),Ge&&p.createElement(vt,{scene:null!==(a=null===(i=jt.current)||void 0===i?void 0:i.scene)&&void 0!==a?a:[],chartType:f+" chart",tableId:Vt,chartTitle:"string"==typeof Te?Te:void 0}),p.createElement(xt,{summary:qe}),p.createElement("div",{role:"img","aria-label":Ye||("string"==typeof Te?Te:"Ordinal chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:bt?Gt:void 0,onMouseLeave:bt?Ht:void 0},_e&&p.createElement("svg",{style:{position:"absolute",top:0,left:0,width:Ke[0],height:Ke[1],pointerEvents:"none"}},p.createElement("g",{transform:`translate(${Qe.left},${Qe.top})`},_e)),p.createElement(Mr,{width:Ze,height:Je,totalWidth:Ke[0],totalHeight:Ke[1],margin:Qe,scales:ht,showAxes:ie,showGrid:Oe,rFormat:ue,rTickValues:de}),p.createElement("canvas",{ref:tt,"aria-label":lt(null!==(c=null===(s=jt.current)||void 0===s?void 0:s.scene)&&void 0!==c?c:[],f+" chart"),style:{position:"absolute",top:0,left:0,width:Ke[0],height:Ke[1]}}),p.createElement(wt,{hoverPoint:ut}),p.createElement(Cr,{width:Ze,height:Je,totalWidth:Ke[0],totalHeight:Ke[1],margin:Qe,scales:ht,showAxes:ie,showCategoryTicks:ae,oLabel:se,rLabel:le,oFormat:ce,rFormat:ue,showGrid:Oe,title:Te,legend:Ee,legendHoverBehavior:Me,legendClickBehavior:je,legendHighlightedCategory:Ce,legendIsolatedCategories:Pe,legendPosition:Le,foregroundGraphics:et,annotations:Ae,svgAnnotationRules:Se,annotationFrame:ft,xAccessor:"string"==typeof v?v:void 0,yAccessor:"string"==typeof b?b:void 0,annotationData:null===(u=jt.current)||void 0===u?void 0:u.getData(),underlayRendered:!0}),(ze||$e)&&"radial"!==j&&p.createElement(Pr,{width:Ze,height:Je,totalWidth:Ke[0],totalHeight:Ke[1],margin:Qe,scales:ht,onBrush:$e||(()=>{})}),Ie&&"radial"===j&&p.createElement("div",{style:{position:"absolute",left:Qe.left+Ze/2,top:Qe.top+Je/2,transform:"translate(-50%, -50%)",pointerEvents:"none",textAlign:"center"}},Ie),(null==Fe?void 0:Fe.showBadge)&&p.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===Fe.badgePosition?{top:4,left:4}:"bottom-left"===Fe.badgePosition?{bottom:4,left:4}:"bottom-right"===Fe.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:yt?"#dc3545":"#28a745",color:"white"})},yt?"STALE":"LIVE"),p.createElement(St,{active:Rt.current>=0,hoverPoint:ut,margin:Qe,size:Ke,shape:null===(d=Ft.current)||void 0===d?void 0:d.shape,width:null===(h=Ft.current)||void 0===h?void 0:h.w,height:null===(g=Ft.current)||void 0===g?void 0:g.h}),Xt))});Vr.displayName="StreamOrdinalFrame";const Ur=e.forwardRef(function(t,n){const o=Qn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel,showCategoryTicks:t.showCategoryTicks,orientation:t.orientation}),r=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=r.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const{data:i,margin:a,className:s,categoryAccessor:l="category",valueAccessor:c="value",orientation:u="vertical",valueFormat:d,colorBy:h,colorScheme:g,sort:f=!1,barPadding:y=40,baselinePadding:m=!1,tooltip:v,annotations:b,frameProps:x={},selection:k,linkedHover:w,onObservation:A,onClick:S,hoverHighlight:O,chartId:E,loading:M,emptyContent:j,legendInteraction:C,legendPosition:P,color:L,showCategoryTicks:_,categoryFormat:T,dataIdAccessor:N}=t,D=o.width,I=o.height,H=o.enableHover,R=o.showGrid,W=o.title,F=o.description,z=o.summary,$=o.accessibleTable,G=o.categoryLabel,Y=o.valueLabel,q=i||[],X=Zo({data:q,rawData:i,colorBy:h,colorScheme:g,legendInteraction:C,legendPosition:P,selection:k,linkedHover:w,fallbackFields:h?["string"==typeof h?h:""]:[],unwrapData:!0,onObservation:A,onClick:S,hoverHighlight:O,chartType:"BarChart",chartId:E,showLegend:o.showLegend,userMargin:a,marginDefaults:o.marginDefaults,loading:M,emptyContent:j,width:D,height:I});if(X.earlyReturn)return X.earlyReturn;$o("BarChart",q,"categoryAccessor",l),$o("BarChart",q,"valueAccessor",c);const V=Yn(q,f,c),U=Fn(),K=e.useMemo(()=>new Map,[q]),Q=e.useMemo(()=>(e,t)=>{const n={};return n.fill=h?B(e,h,X.colorScale):zn(L,U,g,void 0,K),n},[h,X.colorScale,L,U,g,K]),Z=e.useMemo(()=>{const e=null==x?void 0:x.pieceStyle;return e&&"function"==typeof e?(t,n)=>Object.assign(Object.assign({},Q(t,n)),e(t,n)||{}):Q},[Q,x]),J=e.useMemo(()=>Bn(Z,X.effectiveSelectionHook,k),[Z,X.effectiveSelectionHook,k]),ee=e.useMemo(()=>lo({categoryAccessor:l,valueAccessor:c,groupAccessor:h&&h!==l?h:void 0,groupLabel:"string"==typeof h?h:"group"}),[l,c,h]),te=yo({componentName:"BarChart",data:i,accessors:{categoryAccessor:l,valueAccessor:c}});if(te)return p.createElement(co,{componentName:"BarChart",message:te,width:D,height:I});const ne=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bar"},null!=i&&{data:V}),{oAccessor:l,rAccessor:c,projection:"horizontal"===u?"horizontal":"vertical",pieceStyle:J,size:[D,I],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:X.margin,barPadding:y}),N&&{dataIdAccessor:N}),{baselinePadding:m,enableHover:H,showAxes:o.showAxes,oLabel:G,rLabel:Y,rFormat:d}),T&&{oFormat:T}),{showGrid:R,showCategoryTicks:_,oSort:f}),X.legendBehaviorProps),W&&{title:W}),F&&{description:F}),z&&{summary:z}),void 0!==$&&{accessibleTable:$}),s&&{className:s}),{tooltipContent:!1===v?()=>null:oo(v)||ee}),(w||A||S||O)&&{customHoverBehavior:X.customHoverBehavior}),(A||S||w)&&{customClickBehavior:X.customClickBehavior}),b&&b.length>0&&{annotations:b}),Object.fromEntries(Object.entries(x).filter(([e])=>"pieceStyle"!==e)));return p.createElement(Ho,{componentName:"BarChart",width:D,height:I},p.createElement(Vr,Object.assign({ref:r},ne)))});function Kr({ref:t,frameRef:n,isPushMode:o,colorBy:r,colorScheme:i,showLegend:a,legendPosition:s,setup:l}){const c=Ko({isPushMode:o,colorBy:r,colorScheme:i,showLegend:a,legendPosition:s}),u=e.useCallback(c.wrapPush(e=>{var t;return null===(t=n.current)||void 0===t?void 0:t.push(e)}),[c.wrapPush]),d=e.useCallback(c.wrapPushMany(e=>{var t;return null===(t=n.current)||void 0===t?void 0:t.pushMany(e)}),[c.wrapPushMany]);return e.useImperativeHandle(t,()=>({push:u,pushMany:d,remove:e=>{var t,o;return null!==(o=null===(t=n.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,r;return null!==(r=null===(o=n.current)||void 0===o?void 0:o.update(e,t))&&void 0!==r?r:[]},clear:()=>{var e;c.resetCategories(),null===(e=n.current)||void 0===e||e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=n.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}),[u,d,c.resetCategories]),{effectiveLegendProps:e.useMemo(()=>c.streamingLegend?Object.assign(Object.assign({},l.legendBehaviorProps),{legend:c.streamingLegend,legendPosition:s||l.legendPosition}):l.legendBehaviorProps,[l.legendBehaviorProps,l.legendPosition,c.streamingLegend,s]),effectiveMargin:e.useMemo(()=>{if(c.streamingMarginAdjust){const e=Object.assign({},l.margin);for(const[t,n]of Object.entries(c.streamingMarginAdjust))n>e[t]&&(e[t]=n);return e}return l.margin},[l.margin,c.streamingMarginAdjust])}}Ur.displayName="BarChart";const Qr=e.forwardRef(function(t,n){const o=Qn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel,showCategoryTicks:t.showCategoryTicks,orientation:t.orientation}),r=e.useRef(null),{data:i,margin:a,className:s,categoryAccessor:l="category",stackBy:c,valueAccessor:u="value",orientation:d="vertical",valueFormat:h,colorBy:g,colorScheme:f,normalize:y=!1,barPadding:m=40,baselinePadding:v=!1,tooltip:b,annotations:x,frameProps:k={},selection:w,linkedHover:A,onObservation:S,onClick:O,hoverHighlight:E,chartId:M,loading:j,emptyContent:C,legendInteraction:P,legendPosition:L,color:_,categoryFormat:T}=t,N=o.width,D=o.height,I=o.enableHover,H=o.showGrid,R=o.showLegend,W=o.title,F=o.description,z=o.summary,$=o.accessibleTable,G=o.categoryLabel,Y=o.valueLabel,q=i||[],X=g||c,V=void 0===i,U=Zo({data:q,rawData:i,colorBy:X,colorScheme:f,legendInteraction:P,legendPosition:L,selection:w,linkedHover:A,fallbackFields:X?["string"==typeof X?X:""]:[],unwrapData:!0,onObservation:S,onClick:O,hoverHighlight:E,chartType:"StackedBarChart",chartId:M,showLegend:R,userMargin:a,marginDefaults:o.marginDefaults,loading:j,emptyContent:C,width:N,height:D});if(U.earlyReturn)return U.earlyReturn;const K=Fn(),Q=e.useMemo(()=>new Map,[q]),Z=e.useMemo(()=>(e,t)=>X?U.colorScale?{fill:B(e,X,U.colorScale)}:{}:{fill:zn(_,K,f,t,Q)},[X,U.colorScale,_,K,f,Q]),J=e.useMemo(()=>{const e=null==k?void 0:k.pieceStyle;return e&&"function"==typeof e?(t,n)=>{const o=Z(t,n),r=e(t,n)||{};return Object.assign(Object.assign({},o),r)}:Z},[Z,k]),ee=e.useMemo(()=>Bn(J,U.effectiveSelectionHook,w),[J,U.effectiveSelectionHook,w]),te=e.useMemo(()=>lo({categoryAccessor:c,valueAccessor:u,groupAccessor:l}),[c,l,u]),ne=yo({componentName:"StackedBarChart",data:i,accessors:{categoryAccessor:l,valueAccessor:u},requiredProps:{stackBy:c}}),{effectiveLegendProps:oe,effectiveMargin:re}=Kr({ref:n,frameRef:r,isPushMode:V,colorBy:X,colorScheme:f,showLegend:R,legendPosition:L,setup:U}),ie=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bar"},null!=i&&{data:q}),{oAccessor:l,rAccessor:u,stackBy:c,normalize:y,projection:"horizontal"===d?"horizontal":"vertical",pieceStyle:ee,size:[N,D],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:re,barPadding:m,baselinePadding:v,enableHover:I}),t.dataIdAccessor&&{dataIdAccessor:t.dataIdAccessor}),{showAxes:o.showAxes,oLabel:G,rLabel:Y,rFormat:h}),T&&{oFormat:T}),{showGrid:H}),oe),W&&{title:W}),F&&{description:F}),z&&{summary:z}),void 0!==$&&{accessibleTable:$}),s&&{className:s}),{tooltipContent:!1===b?()=>null:oo(b)||te}),(A||S||O||E)&&{customHoverBehavior:U.customHoverBehavior}),(S||O||A)&&{customClickBehavior:U.customClickBehavior}),x&&x.length>0&&{annotations:x}),Object.fromEntries(Object.entries(k).filter(([e])=>"pieceStyle"!==e)));return ne?p.createElement(co,{componentName:"StackedBarChart",message:ne,width:N,height:D}):p.createElement(Ho,{componentName:"StackedBarChart",width:N,height:D},p.createElement(Vr,Object.assign({ref:r},ie)))});Qr.displayName="StackedBarChart";const Zr=e.forwardRef(function(t,n){const o=Qn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel,showCategoryTicks:t.showCategoryTicks,orientation:t.orientation}),r=e.useRef(null),{data:i,margin:a,className:s,categoryAccessor:l="category",groupBy:c,valueAccessor:u="value",orientation:d="vertical",valueFormat:h,colorBy:g,colorScheme:f,barPadding:y=60,baselinePadding:m=!1,tooltip:v,annotations:b,frameProps:x={},selection:k,linkedHover:w,onObservation:A,onClick:S,hoverHighlight:O,chartId:E,loading:M,emptyContent:j,legendInteraction:C,legendPosition:P,color:L,categoryFormat:_}=t,T=o.width,N=o.height,D=o.enableHover,I=o.showGrid,H=o.showLegend,R=o.title,W=o.description,F=o.summary,z=o.accessibleTable,$=o.categoryLabel,G=o.valueLabel,Y=i||[],q=g||c,X=void 0===i,V=Zo({data:Y,rawData:i,colorBy:q,colorScheme:f,legendInteraction:C,legendPosition:P,selection:k,linkedHover:w,fallbackFields:q?["string"==typeof q?q:""]:[],unwrapData:!0,onObservation:A,onClick:S,hoverHighlight:O,chartType:"GroupedBarChart",chartId:E,showLegend:H,userMargin:a,marginDefaults:o.marginDefaults,loading:M,emptyContent:j,width:T,height:N});if(V.earlyReturn)return V.earlyReturn;const U=Fn(),K=e.useMemo(()=>new Map,[Y]),Q=e.useMemo(()=>(e,t)=>q?V.colorScale?{fill:B(e,q,V.colorScale)}:{}:{fill:zn(L,U,f,t,K)},[q,V.colorScale,L,U,f,K]),Z=e.useMemo(()=>Bn(Q,V.effectiveSelectionHook,k),[Q,V.effectiveSelectionHook,k]),J=e.useMemo(()=>lo({categoryAccessor:c,valueAccessor:u,groupAccessor:l}),[c,l,u]),ee=yo({componentName:"GroupedBarChart",data:i,accessors:{categoryAccessor:l,valueAccessor:u},requiredProps:{groupBy:c}}),{effectiveLegendProps:te,effectiveMargin:ne}=Kr({ref:n,frameRef:r,isPushMode:X,colorBy:q,colorScheme:f,showLegend:H,legendPosition:P,setup:V}),oe=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"clusterbar"},null!=i&&{data:Y}),{oAccessor:l,rAccessor:u,groupBy:c,projection:"horizontal"===d?"horizontal":"vertical",pieceStyle:Z,size:[T,N],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:ne,barPadding:y,baselinePadding:m,enableHover:D}),t.dataIdAccessor&&{dataIdAccessor:t.dataIdAccessor}),{showAxes:o.showAxes,oLabel:$,rLabel:G,rFormat:h}),_&&{oFormat:_}),{showGrid:I}),te),R&&{title:R}),W&&{description:W}),F&&{summary:F}),void 0!==z&&{accessibleTable:z}),s&&{className:s}),{tooltipContent:!1===v?()=>null:oo(v)||J}),(w||A||S||O)&&{customHoverBehavior:V.customHoverBehavior}),(A||S||w)&&{customClickBehavior:V.customClickBehavior}),b&&b.length>0&&{annotations:b}),Object.fromEntries(Object.entries(x).filter(([e])=>"pieceStyle"!==e)));return ee?p.createElement(co,{componentName:"GroupedBarChart",message:ee,width:T,height:N}):p.createElement(Ho,{componentName:"GroupedBarChart",width:T,height:N},p.createElement(Vr,Object.assign({ref:r},oe)))});function Jr({brushProp:t,onBrushProp:n,linkedBrush:o,valueAccessor:r}){const i=_n("string"==typeof o?o:o?{name:o.name,xField:o.rField}:void 0),a=On({name:(null==i?void 0:i.name)||"__unused_ordinal_brush__",xField:(null==i?void 0:i.xField)||("string"==typeof r?r:"value")}),s=e.useRef(a.brushInteraction);s.current=a.brushInteraction;const l=e.useCallback(e=>{if(i){s.current.end(e?e.r:null)}null==n||n(e)},[n,i]),c=!!(t||o||n);return{hasBrush:c,handleBrush:l,brushStreamProps:c?{brush:{dimension:"r"},onBrush:l}:{}}}Zr.displayName="GroupedBarChart";const ei=e.forwardRef(function(t,n){const o=Qn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel,showCategoryTicks:t.showCategoryTicks,orientation:t.orientation}),r=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=r.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const{data:i,margin:a,className:s,categoryAccessor:l="category",valueAccessor:c="value",orientation:u="vertical",valueFormat:d,colorBy:h,colorScheme:g,sizeBy:f,sizeRange:y=[3,8],pointRadius:m=4,pointOpacity:v=.7,categoryPadding:b=20,tooltip:x,annotations:k,brush:w,onBrush:A,linkedBrush:S,frameProps:O={},selection:E,linkedHover:M,onObservation:j,onClick:C,hoverHighlight:P,chartId:L,loading:_,emptyContent:T,legendInteraction:D,legendPosition:I,color:H,showCategoryTicks:R,categoryFormat:W}=t,F=o.width,z=o.height,$=o.enableHover,G=o.showGrid,Y=o.title,q=o.description,X=o.summary,V=o.accessibleTable,U=o.categoryLabel,K=o.valueLabel,Q=i||[],Z=Zo({data:Q,rawData:i,colorBy:h,colorScheme:g,legendInteraction:D,legendPosition:I,selection:E,linkedHover:M,fallbackFields:h?["string"==typeof h?h:""]:["string"==typeof l?l:""],unwrapData:!0,onObservation:j,onClick:C,hoverHighlight:P,chartType:"SwarmPlot",chartId:L,showLegend:o.showLegend,userMargin:a,marginDefaults:o.marginDefaults,loading:_,emptyContent:T,width:F,height:z}),J=Jr({brushProp:w,onBrushProp:A,linkedBrush:S,valueAccessor:c});if(Z.earlyReturn)return Z.earlyReturn;const ee=e.useMemo(()=>{if(!f)return;const e=Q.map(e=>"function"==typeof f?f(e):e[f]);return[Math.min(...e),Math.max(...e)]},[Q,f]),te=Fn(),ne=e.useMemo(()=>new Map,[Q]),oe=e.useMemo(()=>(e,t)=>{const n={fillOpacity:v};return n.fill=h?B(e,h,Z.colorScale):zn(H,te,g,void 0,ne),n.r=f?N(e,f,y,ee):m,n},[h,Z.colorScale,f,y,ee,m,v,H,te,g,ne]),re=e.useMemo(()=>Bn(oe,Z.effectiveSelectionHook,E),[oe,Z.effectiveSelectionHook,E]),ie=e.useMemo(()=>lo({categoryAccessor:l,valueAccessor:c,groupAccessor:h||void 0}),[l,c,h]),ae=yo({componentName:"SwarmPlot",data:i,accessors:{categoryAccessor:l,valueAccessor:c}});if(ae)return p.createElement(co,{componentName:"SwarmPlot",message:ae,width:F,height:z});const se=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"swarm"},null!=i&&{data:Q}),{oAccessor:l,rAccessor:c,projection:"horizontal"===u?"horizontal":"vertical",pieceStyle:re,size:[F,z],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Z.margin,barPadding:b,enableHover:$}),t.dataIdAccessor&&{dataIdAccessor:t.dataIdAccessor}),{showAxes:o.showAxes,oLabel:U,rLabel:K,rFormat:d}),W&&{oFormat:W}),{showGrid:G,showCategoryTicks:R}),Z.legendBehaviorProps),Y&&{title:Y}),q&&{description:q}),X&&{summary:X}),void 0!==V&&{accessibleTable:V}),s&&{className:s}),{tooltipContent:!1===x?()=>null:oo(x)||ie}),(M||j||C||P)&&{customHoverBehavior:Z.customHoverBehavior}),(j||C||M)&&{customClickBehavior:Z.customClickBehavior}),k&&k.length>0&&{annotations:k}),J.brushStreamProps),Object.fromEntries(Object.entries(O).filter(([e])=>"pieceStyle"!==e)));return p.createElement(Ho,{componentName:"SwarmPlot",width:F,height:z},p.createElement(Vr,Object.assign({ref:r},se)))});function ti(e){return t=>{var n;const o=t.category||t.data&&(null===(n=t.data[0])||void 0===n?void 0:n.category)||"",r=t.stats||(t.data||t).stats;if(r&&null!=r.median)return p.createElement("div",{className:"semiotic-tooltip",style:Jn},o&&p.createElement("div",{style:{fontWeight:"bold"}},o+""),null!=r.n&&p.createElement("div",null,"n = ",r.n),null!=r.min&&p.createElement("div",null,"Min: ",r.min.toLocaleString()),null!=r.q1&&p.createElement("div",null,"Q1: ",r.q1.toLocaleString()),p.createElement("div",null,"Median: ",r.median.toLocaleString()),null!=r.q3&&p.createElement("div",null,"Q3: ",r.q3.toLocaleString()),null!=r.max&&p.createElement("div",null,"Max: ",r.max.toLocaleString()),null!=r.mean&&p.createElement("div",{style:{opacity:.8}},"Mean: ",r.mean.toLocaleString(void 0,{maximumFractionDigits:2})));if(null==e?void 0:e.valueAccessor){const n=e.valueAccessor,r=(Array.isArray(t.data)?t.data:[]).map(e=>Number("function"==typeof n?n(e):e[n])).filter(e=>Number.isFinite(e)).sort((e,t)=>e-t),i=r.length,a=i>0?i%2!=0?r[Math.floor(i/2)]:(r[i/2-1]+r[i/2])/2:null;return p.createElement("div",{className:"semiotic-tooltip",style:Jn},o&&p.createElement("div",{style:{fontWeight:"bold"}},o+""),i>0&&p.createElement("div",null,"n = ",i),null!=a&&p.createElement("div",null,"Median: ",a.toLocaleString()))}return p.createElement("div",{className:"semiotic-tooltip",style:Jn},p.createElement("div",{style:{fontWeight:"bold"}},o+""))}}ei.displayName="SwarmPlot";const ni=e.forwardRef(function(t,n){const o=Qn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel,showCategoryTicks:t.showCategoryTicks,orientation:t.orientation}),r=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=r.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const{data:i,margin:a,className:s,categoryAccessor:l="category",valueAccessor:c="value",orientation:u="vertical",valueFormat:d,colorBy:h,colorScheme:g,showOutliers:f=!0,categoryPadding:y=20,tooltip:m,annotations:v,frameProps:b={},selection:x,linkedHover:k,onObservation:w,onClick:A,hoverHighlight:S,chartId:O,loading:E,emptyContent:M,legendInteraction:j,legendPosition:C,color:P,showCategoryTicks:L,categoryFormat:_}=t,T=o.width,N=o.height,D=o.enableHover,I=o.showGrid,H=o.title,R=o.description,W=o.summary,F=o.accessibleTable,z=o.categoryLabel,$=o.valueLabel,G=i||[],Y=Zo({data:G,rawData:i,colorBy:h,colorScheme:g,legendInteraction:j,legendPosition:C,selection:x,linkedHover:k,fallbackFields:h?["string"==typeof h?h:""]:["string"==typeof l?l:""],unwrapData:!0,onObservation:w,onClick:A,hoverHighlight:S,chartType:"BoxPlot",chartId:O,showLegend:o.showLegend,userMargin:a,marginDefaults:o.marginDefaults,loading:E,emptyContent:M,width:T,height:N});if(Y.earlyReturn)return Y.earlyReturn;const q=Fn(),X=e.useMemo(()=>new Map,[G]),V=e.useMemo(()=>e=>{const t=h?B(e,h,Y.colorScale):zn(P,q,g,void 0,X);return{fill:t,stroke:t,fillOpacity:.8}},[h,Y.colorScale,P,q,g,X]),U=e.useMemo(()=>Bn(V,Y.effectiveSelectionHook,x),[V,Y.effectiveSelectionHook,x]),K=e.useMemo(()=>ti(),[]),Q=yo({componentName:"BoxPlot",data:i,accessors:{categoryAccessor:l,valueAccessor:c}});if(Q)return p.createElement(co,{componentName:"BoxPlot",message:Q,width:T,height:N});const Z=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"boxplot"},null!=i&&{data:G}),{oAccessor:l,rAccessor:c,projection:"horizontal"===u?"horizontal":"vertical",summaryStyle:U,showOutliers:f,size:[T,N],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Y.margin,barPadding:y,enableHover:D}),t.dataIdAccessor&&{dataIdAccessor:t.dataIdAccessor}),{showAxes:o.showAxes,oLabel:z,rLabel:$,rFormat:d}),_&&{oFormat:_}),{showGrid:I,showCategoryTicks:L}),Y.legendBehaviorProps),H&&{title:H}),R&&{description:R}),W&&{summary:W}),void 0!==F&&{accessibleTable:F}),s&&{className:s}),{tooltipContent:!1===m?()=>null:oo(m)||K}),(k||w||A||S)&&{customHoverBehavior:Y.customHoverBehavior}),(w||A||k)&&{customClickBehavior:Y.customClickBehavior}),v&&v.length>0&&{annotations:v}),Object.fromEntries(Object.entries(b).filter(([e])=>"pieceStyle"!==e)));return p.createElement(Ho,{componentName:"BoxPlot",width:T,height:N},p.createElement(Vr,Object.assign({ref:r},Z)))});ni.displayName="BoxPlot";const oi=e.forwardRef(function(t,n){const o=Qn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel,showCategoryTicks:t.showCategoryTicks,orientation:"horizontal"}),r=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=r.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const{data:i,margin:a,className:s,categoryAccessor:l="category",valueAccessor:c="value",bins:u=25,relative:d=!1,valueFormat:h,colorBy:g,colorScheme:f,categoryPadding:y=20,tooltip:m,annotations:v,brush:b,onBrush:x,linkedBrush:k,frameProps:w={},selection:A,linkedHover:S,onObservation:O,onClick:E,hoverHighlight:M,chartId:j,loading:C,emptyContent:P,legendInteraction:L,legendPosition:_,color:T,showCategoryTicks:N,categoryFormat:D}=t,I=o.width,H=o.height,R=o.enableHover,W=o.showGrid,F=o.title,z=o.description,$=o.summary,G=o.accessibleTable,Y=o.categoryLabel,q=o.valueLabel,X=i||[],V=Zo({data:X,rawData:i,colorBy:g,colorScheme:f,legendInteraction:L,legendPosition:_,selection:A,linkedHover:S,fallbackFields:g?["string"==typeof g?g:""]:["string"==typeof l?l:""],unwrapData:!0,onObservation:O,onClick:E,hoverHighlight:M,chartType:"Histogram",chartId:j,showLegend:o.showLegend,userMargin:a,marginDefaults:o.marginDefaults,loading:C,emptyContent:P,width:I,height:H}),U=Jr({brushProp:b,onBrushProp:x,linkedBrush:k,valueAccessor:c});if(V.earlyReturn)return V.earlyReturn;const K=e.useMemo(()=>{if(0===X.length)return;const e="function"==typeof c?c:e=>e[c];let t=1/0,n=-1/0;for(const o of X){const r=e(o);null!=r&&isFinite(r)&&(t>r&&(t=r),r>n&&(n=r))}return t>n?void 0:[t,n]},[X,c]),Q=Fn(),Z=e.useMemo(()=>new Map,[X]),J=e.useMemo(()=>e=>{const t=g?B(e,g,V.colorScale):zn(T,Q,f,void 0,Z);return{fill:t,stroke:t,fillOpacity:.8}},[g,V.colorScale,T,Q,f,Z]),ee=e.useMemo(()=>Bn(J,V.effectiveSelectionHook,A),[J,V.effectiveSelectionHook,A]),te=e.useMemo(()=>e=>{const t=e.data||e,n=t.category||e.category||"",o=t.count,r=t.range;return p.createElement("div",{className:"semiotic-tooltip",style:Jn},n&&p.createElement("div",{style:{fontWeight:"bold"}},n+""),null!=o&&p.createElement("div",null,"Count: ",o),r&&2===r.length&&p.createElement("div",{style:{opacity:.8}},Number(r[0]).toFixed(1)," – ",Number(r[1]).toFixed(1)))},[]),ne=yo({componentName:"Histogram",data:i,accessors:{categoryAccessor:l,valueAccessor:c}});if(ne)return p.createElement(co,{componentName:"Histogram",message:ne,width:I,height:H});const oe=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"histogram"},null!=i&&{data:X}),{oAccessor:l,rAccessor:c,projection:"horizontal",summaryStyle:ee,bins:u,normalize:d}),K&&{rExtent:K}),{size:[I,H],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:V.margin,barPadding:y,enableHover:R}),t.dataIdAccessor&&{dataIdAccessor:t.dataIdAccessor}),{showAxes:o.showAxes,oLabel:Y,rLabel:q,rFormat:h}),D&&{oFormat:D}),{showGrid:W,showCategoryTicks:N}),V.legendBehaviorProps),F&&{title:F}),z&&{description:z}),$&&{summary:$}),void 0!==G&&{accessibleTable:G}),s&&{className:s}),{tooltipContent:!1===m?()=>null:oo(m)||te}),(S||O||E||M)&&{customHoverBehavior:V.customHoverBehavior}),(O||E||S)&&{customClickBehavior:V.customClickBehavior}),v&&v.length>0&&{annotations:v}),U.brushStreamProps),Object.fromEntries(Object.entries(w).filter(([e])=>"pieceStyle"!==e)));return p.createElement(Ho,{componentName:"Histogram",width:I,height:H},p.createElement(Vr,Object.assign({ref:r},oe)))});oi.displayName="Histogram";const ri=e.forwardRef(function(t,n){const o=Qn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel,showCategoryTicks:t.showCategoryTicks,orientation:t.orientation}),r=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=r.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const{data:i,margin:a,className:s,categoryAccessor:l="category",valueAccessor:c="value",orientation:u="vertical",bins:d=25,showIQR:h=!0,valueFormat:g,colorBy:f,colorScheme:y,categoryPadding:m=20,tooltip:v,annotations:b,brush:x,onBrush:k,linkedBrush:w,frameProps:A={},selection:S,linkedHover:O,onObservation:E,onClick:M,hoverHighlight:j,chartId:C,loading:P,emptyContent:L,legendInteraction:_,legendPosition:T,color:N,showCategoryTicks:D,categoryFormat:I}=t,H=o.width,R=o.height,W=o.enableHover,F=o.showGrid,z=o.title,$=o.description,G=o.summary,Y=o.accessibleTable,q=o.categoryLabel,X=o.valueLabel,V=i||[],U=Zo({data:V,rawData:i,colorBy:f,colorScheme:y,legendInteraction:_,legendPosition:T,selection:S,linkedHover:O,fallbackFields:f?["string"==typeof f?f:""]:["string"==typeof l?l:""],unwrapData:!0,onObservation:E,onClick:M,hoverHighlight:j,chartType:"ViolinPlot",chartId:C,showLegend:o.showLegend,userMargin:a,marginDefaults:o.marginDefaults,loading:P,emptyContent:L,width:H,height:R}),K=Jr({brushProp:x,onBrushProp:k,linkedBrush:w,valueAccessor:c});if(U.earlyReturn)return U.earlyReturn;const Q=Fn(),Z=e.useMemo(()=>new Map,[V]),J=e.useMemo(()=>e=>{const t=f?B(e,f,U.colorScale):zn(N,Q,y,void 0,Z);return{fill:t,stroke:t,fillOpacity:.6}},[f,U.colorScale,N,Q,y,Z]),ee=e.useMemo(()=>Bn(J,U.effectiveSelectionHook,S),[J,U.effectiveSelectionHook,S]),te=e.useMemo(()=>ti({valueAccessor:c}),[c]),ne=yo({componentName:"ViolinPlot",data:i,accessors:{categoryAccessor:l,valueAccessor:c}});if(ne)return p.createElement(co,{componentName:"ViolinPlot",message:ne,width:H,height:R});const oe=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"violin"},null!=i&&{data:V}),{oAccessor:l,rAccessor:c,projection:"horizontal"===u?"horizontal":"vertical",summaryStyle:ee,bins:d,showIQR:h,size:[H,R],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:U.margin,barPadding:m,enableHover:W}),t.dataIdAccessor&&{dataIdAccessor:t.dataIdAccessor}),{showAxes:o.showAxes,oLabel:q,rLabel:X,rFormat:g}),I&&{oFormat:I}),{showGrid:F,showCategoryTicks:D}),U.legendBehaviorProps),z&&{title:z}),$&&{description:$}),G&&{summary:G}),void 0!==Y&&{accessibleTable:Y}),s&&{className:s}),{tooltipContent:!1===v?()=>null:oo(v)||te}),(O||E||M||j)&&{customHoverBehavior:U.customHoverBehavior}),(E||M||O)&&{customClickBehavior:U.customClickBehavior}),b&&b.length>0&&{annotations:b}),K.brushStreamProps),Object.fromEntries(Object.entries(A).filter(([e])=>"pieceStyle"!==e)));return p.createElement(Ho,{componentName:"ViolinPlot",width:H,height:R},p.createElement(Vr,Object.assign({ref:r},oe)))});ri.displayName="ViolinPlot";const ii=e.forwardRef(function(t,n){var o;const r=Qn(t.mode,{width:t.width,height:t.height,showGrid:null===(o=t.showGrid)||void 0===o||o,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel,showCategoryTicks:t.showCategoryTicks,orientation:t.orientation}),i=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=i.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=i.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;return null===(e=i.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=i.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const{data:a,margin:s,className:l,categoryAccessor:c="category",valueAccessor:u="value",orientation:d="horizontal",valueFormat:h,colorBy:g,colorScheme:f,sort:y=!0,dotRadius:m=5,categoryPadding:v=10,tooltip:b,annotations:x,frameProps:k={},selection:w,linkedHover:A,onObservation:S,onClick:O,hoverHighlight:E,chartId:M,loading:j,emptyContent:C,legendInteraction:P,legendPosition:L,color:_,categoryFormat:T}=t,N=r.width,D=r.height,I=r.enableHover,H=r.showGrid,R=r.title,W=r.description,F=r.summary,z=r.accessibleTable,$=r.categoryLabel,G=r.valueLabel,Y=a||[],q=Zo({data:Y,rawData:a,colorBy:g,colorScheme:f,legendInteraction:P,legendPosition:L,selection:w,linkedHover:A,fallbackFields:g?["string"==typeof g?g:""]:["string"==typeof c?c:""],unwrapData:!0,onObservation:S,onClick:O,hoverHighlight:E,chartType:"DotPlot",chartId:M,showLegend:r.showLegend,userMargin:s,marginDefaults:r.marginDefaults,loading:j,emptyContent:C,width:N,height:D});if(q.earlyReturn)return q.earlyReturn;const X=Yn(Y,y,u),V=Fn(),U=e.useMemo(()=>new Map,[Y]),K=e.useMemo(()=>(e,t)=>{const n={r:m,fillOpacity:.8};return n.fill=g?B(e,g,q.colorScale):zn(_,V,f,void 0,U),n},[g,q.colorScale,m,_,V,f,U]),Q=e.useMemo(()=>Bn(K,q.effectiveSelectionHook,w),[K,q.effectiveSelectionHook,w]),Z=e.useMemo(()=>lo({categoryAccessor:c,valueAccessor:u}),[c,u]),J=yo({componentName:"DotPlot",data:a,accessors:{categoryAccessor:c,valueAccessor:u}});if(J)return p.createElement(co,{componentName:"DotPlot",message:J,width:N,height:D});const ee=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"point"},null!=a&&{data:X}),{oAccessor:c,rAccessor:u,projection:"horizontal"===d?"horizontal":"vertical",pieceStyle:Q,size:[N,D],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:q.margin,barPadding:v,enableHover:I}),t.dataIdAccessor&&{dataIdAccessor:t.dataIdAccessor}),{showAxes:r.showAxes,oLabel:$,rLabel:G,rFormat:h}),T&&{oFormat:T}),{showGrid:H,oSort:y}),q.legendBehaviorProps),R&&{title:R}),W&&{description:W}),F&&{summary:F}),void 0!==z&&{accessibleTable:z}),l&&{className:l}),{tooltipContent:!1===b?()=>null:oo(b)||Z}),(A||S||O||E)&&{customHoverBehavior:q.customHoverBehavior}),(S||O||A)&&{customClickBehavior:q.customClickBehavior}),x&&x.length>0&&{annotations:x}),Object.fromEntries(Object.entries(k).filter(([e])=>"pieceStyle"!==e)));return p.createElement(Ho,{componentName:"DotPlot",width:N,height:D},p.createElement(Vr,Object.assign({ref:i},ee)))});ii.displayName="DotPlot";const ai=e.forwardRef(function(t,n){const o=Qn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel,showCategoryTicks:t.showCategoryTicks,orientation:t.orientation}),r=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=r.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const{data:i,margin:a,className:s,categoryAccessor:l="category",valueAccessor:c="value",orientation:u="horizontal",bins:d=20,amplitude:h=1.5,valueFormat:g,colorBy:f,colorScheme:y,categoryPadding:m=5,tooltip:v,annotations:b,frameProps:x={},selection:k,linkedHover:w,onObservation:A,onClick:S,hoverHighlight:O,chartId:E,loading:M,emptyContent:j,legendInteraction:C,legendPosition:P,color:L,showCategoryTicks:_,categoryFormat:T}=t,N=o.width,D=o.height,I=o.enableHover,H=o.showGrid,R=o.title,W=o.description,F=o.summary,z=o.accessibleTable,$=o.categoryLabel,G=o.valueLabel,Y=i||[],q=Zo({data:Y,rawData:i,colorBy:f,colorScheme:y,legendInteraction:C,legendPosition:P,selection:k,linkedHover:w,fallbackFields:f?["string"==typeof f?f:""]:["string"==typeof l?l:""],unwrapData:!0,onObservation:A,onClick:S,hoverHighlight:O,chartType:"RidgelinePlot",chartId:E,showLegend:o.showLegend,userMargin:a,marginDefaults:o.marginDefaults,loading:M,emptyContent:j,width:N,height:D});if(q.earlyReturn)return q.earlyReturn;const X=Fn(),V=e.useMemo(()=>new Map,[Y]),U=e.useMemo(()=>e=>{const t=f?B(e,f,q.colorScale):zn(L,X,y,void 0,V);return{fill:t,stroke:t,fillOpacity:.5}},[f,q.colorScale,L,X,y,V]),K=e.useMemo(()=>Bn(U,q.effectiveSelectionHook,k),[U,q.effectiveSelectionHook,k]),Q=e.useMemo(()=>ti(),[]),Z=yo({componentName:"RidgelinePlot",data:i,accessors:{categoryAccessor:l,valueAccessor:c}});if(Z)return p.createElement(co,{componentName:"RidgelinePlot",message:Z,width:N,height:D});const J=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"ridgeline"},null!=i&&{data:Y}),{oAccessor:l,rAccessor:c,projection:"horizontal"===u?"horizontal":"vertical",summaryStyle:K,bins:d,size:[N,D],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:q.margin,barPadding:m,enableHover:I}),t.dataIdAccessor&&{dataIdAccessor:t.dataIdAccessor}),{showAxes:o.showAxes,oLabel:$,rLabel:G,rFormat:g}),T&&{oFormat:T}),{showGrid:H,showCategoryTicks:_,oSort:!1,amplitude:h}),q.legendBehaviorProps),R&&{title:R}),W&&{description:W}),F&&{summary:F}),void 0!==z&&{accessibleTable:z}),s&&{className:s}),{tooltipContent:!1===v?()=>null:oo(v)||Q}),(w||A||S||O)&&{customHoverBehavior:q.customHoverBehavior}),(A||S||w)&&{customClickBehavior:q.customClickBehavior}),b&&b.length>0&&{annotations:b}),Object.fromEntries(Object.entries(x).filter(([e])=>"pieceStyle"!==e)));return p.createElement(Ho,{componentName:"RidgelinePlot",width:N,height:D},p.createElement(Vr,Object.assign({ref:r},J)))});ai.displayName="RidgelinePlot";const si=e.forwardRef(function(t,n){var o,r;const i=Qn(t.mode,{width:null!==(o=t.width)&&void 0!==o?o:400,height:null!==(r=t.height)&&void 0!==r?r:400,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary,showCategoryTicks:t.showCategoryTicks}),a=e.useRef(null),{data:s,margin:l,className:c,categoryAccessor:u="category",valueAccessor:d="value",colorBy:h,colorScheme:g,startAngle:f=0,tooltip:y,annotations:m,frameProps:v={},selection:b,linkedHover:x,onObservation:k,onClick:w,hoverHighlight:A,chartId:S,loading:O,emptyContent:E,legendInteraction:M,legendPosition:j,color:C}=t,P=i.width,L=i.height,_=i.enableHover,T=i.showLegend,N=i.title,D=i.description,I=i.summary,H=i.accessibleTable,R=s||[],W=h||u,F=void 0===s,z=Zo({data:R,rawData:s,colorBy:W,colorScheme:g,legendInteraction:M,legendPosition:j,selection:b,linkedHover:x,fallbackFields:W?["string"==typeof W?W:""]:[],unwrapData:!0,onObservation:k,onClick:w,hoverHighlight:A,chartType:"PieChart",chartId:S,showLegend:T,userMargin:l,marginDefaults:i.marginDefaults,loading:O,emptyContent:E,width:P,height:L});if(z.earlyReturn)return z.earlyReturn;const $=Fn(),G=e.useMemo(()=>new Map,[R]),Y=e.useMemo(()=>(e,t)=>W?z.colorScale?{fill:B(e,W,z.colorScale)}:{}:{fill:zn(C,$,g,t,G)},[W,z.colorScale,C,$,g,G]),q=e.useMemo(()=>{const e=null==v?void 0:v.pieceStyle;return e&&"function"==typeof e?(t,n)=>Object.assign(Object.assign({},Y(t,n)),e(t,n)||{}):Y},[Y,v]),X=e.useMemo(()=>Bn(q,z.effectiveSelectionHook,b),[q,z.effectiveSelectionHook,b]),V=e.useMemo(()=>lo({categoryAccessor:u,valueAccessor:d,groupAccessor:h&&h!==u?h:void 0,groupLabel:"string"==typeof h?h:"group",pieData:!0}),[u,d,h]),U=yo({componentName:"PieChart",data:s,accessors:{categoryAccessor:u,valueAccessor:d}}),{effectiveLegendProps:K,effectiveMargin:Q}=Kr({ref:n,frameRef:a,isPushMode:F,colorBy:W,colorScheme:g,showLegend:T,legendPosition:j,setup:z}),Z=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"pie"},null!=s&&{data:R}),{oAccessor:u,rAccessor:d,projection:"radial",pieceStyle:X,startAngle:f,size:[P,L],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Q,enableHover:_}),t.dataIdAccessor&&{dataIdAccessor:t.dataIdAccessor}),{showAxes:!1}),K),N&&{title:N}),D&&{description:D}),I&&{summary:I}),void 0!==H&&{accessibleTable:H}),c&&{className:c}),{tooltipContent:!1===y?()=>null:oo(y)||V}),(x||k||w||A)&&{customHoverBehavior:z.customHoverBehavior}),(k||w||x)&&{customClickBehavior:z.customClickBehavior}),m&&m.length>0&&{annotations:m}),Object.fromEntries(Object.entries(v).filter(([e])=>"pieceStyle"!==e)));return U?p.createElement(co,{componentName:"PieChart",message:U,width:P,height:L}):p.createElement(Ho,{componentName:"PieChart",width:P,height:L},p.createElement(Vr,Object.assign({ref:a},Z)))});si.displayName="PieChart";const li=e.forwardRef(function(t,n){var o,r;const i=Qn(t.mode,{width:null!==(o=t.width)&&void 0!==o?o:400,height:null!==(r=t.height)&&void 0!==r?r:400,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary,linkedHover:t.linkedHover,showCategoryTicks:t.showCategoryTicks}),a=e.useRef(null),{data:s,margin:l,className:c,categoryAccessor:u="category",valueAccessor:d="value",innerRadius:h=60,centerContent:g,colorBy:f,colorScheme:y,startAngle:m=0,tooltip:v,annotations:b,frameProps:x={},selection:k,linkedHover:w,onObservation:A,onClick:S,hoverHighlight:O,chartId:E,loading:M,emptyContent:j,legendInteraction:C,legendPosition:P,color:L}=t,_=i.width,T=i.height,N=i.enableHover,D=i.showLegend,I=i.title,H=i.description,R=i.summary,W=i.accessibleTable,F=s||[],z=f||u,$=void 0===s,G=Zo({data:F,rawData:s,colorBy:z,colorScheme:y,legendInteraction:C,legendPosition:P,selection:k,linkedHover:w,fallbackFields:z?["string"==typeof z?z:""]:[],unwrapData:!0,onObservation:A,onClick:S,hoverHighlight:O,chartType:"DonutChart",chartId:E,showLegend:D,userMargin:l,marginDefaults:i.marginDefaults,loading:M,emptyContent:j,width:_,height:T});if(G.earlyReturn)return G.earlyReturn;const Y=Fn(),q=e.useMemo(()=>new Map,[F]),X=e.useMemo(()=>(e,t)=>z?G.colorScale?{fill:B(e,z,G.colorScale)}:{}:{fill:zn(L,Y,y,t,q)},[z,G.colorScale,L,Y,y,q]),V=e.useMemo(()=>Bn(X,G.effectiveSelectionHook,k),[X,G.effectiveSelectionHook,k]),U=e.useMemo(()=>lo({categoryAccessor:u,valueAccessor:d,groupAccessor:f&&f!==u?f:void 0,groupLabel:"string"==typeof f?f:"group",pieData:!0}),[u,d,f]),K=yo({componentName:"DonutChart",data:s,accessors:{categoryAccessor:u,valueAccessor:d}}),{effectiveLegendProps:Q,effectiveMargin:Z}=Kr({ref:n,frameRef:a,isPushMode:$,colorBy:z,colorScheme:y,showLegend:D,legendPosition:P,setup:G}),J=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"donut"},null!=s&&{data:F}),{oAccessor:u,rAccessor:d,projection:"radial",pieceStyle:V,innerRadius:h,startAngle:m,centerContent:g,size:[_,T],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Z,enableHover:N}),t.dataIdAccessor&&{dataIdAccessor:t.dataIdAccessor}),{showAxes:!1}),Q),I&&{title:I}),H&&{description:H}),R&&{summary:R}),void 0!==W&&{accessibleTable:W}),c&&{className:c}),{tooltipContent:!1===v?()=>null:oo(v)||U}),(w||A||S||O)&&{customHoverBehavior:G.customHoverBehavior}),(A||S||w)&&{customClickBehavior:G.customClickBehavior}),b&&b.length>0&&{annotations:b}),Object.fromEntries(Object.entries(x).filter(([e])=>"pieceStyle"!==e)));return K?p.createElement(co,{componentName:"DonutChart",message:K,width:_,height:T}):p.createElement(Ho,{componentName:"DonutChart",width:_,height:T},p.createElement(Vr,Object.assign({ref:a},J)))});li.displayName="DonutChart";const ci=e.forwardRef(function(t,n){const o=Qn(t.mode,{width:t.width,height:t.height,showGrid:!1,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary,showCategoryTicks:!1}),r=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=r.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const{data:i,margin:a,className:s,stepAccessor:l="step",valueAccessor:c="value",categoryAccessor:u,colorBy:d,colorScheme:h,orientation:g="horizontal",connectorOpacity:f=.3,showLabels:y=!0,tooltip:m,annotations:v,frameProps:b={},selection:x,linkedHover:k,onObservation:w,onClick:A,hoverHighlight:S,chartId:O,loading:E,emptyContent:M,legendInteraction:j,legendPosition:C,color:P,categoryFormat:L}=t,_="vertical"===g,T=o.width,N=o.height,D=o.enableHover,I=o.title,H=o.description,R=o.summary,W=o.accessibleTable,F=i||[],z=d||u,$=!z,G=Zo({data:F,rawData:i,colorBy:z,colorScheme:h,legendInteraction:j,legendPosition:C,selection:x,linkedHover:k,fallbackFields:z?["string"==typeof z?z:""]:[],unwrapData:!0,onObservation:w,onClick:A,hoverHighlight:S,chartType:"FunnelChart",chartId:O,showLegend:o.showLegend,userMargin:a,marginDefaults:_?{top:I?60:40,right:20,bottom:60,left:60}:{top:I?40:10,right:10,bottom:10,left:10},loading:E,emptyContent:M,width:T,height:N});if(G.earlyReturn)return G.earlyReturn;$o("FunnelChart",F,"stepAccessor",l),$o("FunnelChart",F,"valueAccessor",c);const Y=Fn(),q=e.useMemo(()=>new Map,[F]),X=e.useMemo(()=>{if($)return P||((null==Y?void 0:Y[0])?Y[0]:Array.isArray(h)&&h[0]?h[0]:"#4e79a7")},[$,P,Y,h]),V=e.useMemo(()=>(e,t)=>{const n={};return n.fill=X||(z?B(e,z,G.colorScale):zn(P,Y,h,t,q)),n},[X,z,G.colorScale,P,Y,h,q]),U=e.useMemo(()=>Bn(V,G.effectiveSelectionHook,x),[V,G.effectiveSelectionHook,x]),K=e.useMemo(()=>e=>{var t,n,o,r,i,a;const s=(null==e?void 0:e.data)||e,l=(null==s?void 0:s.__funnelStep)||(null==s?void 0:s.__barFunnelStep)||(null==s?void 0:s.step)||"",c=null!==(o=null!==(n=null!==(t=null==s?void 0:s.__funnelValue)&&void 0!==t?t:null==s?void 0:s.__barFunnelValue)&&void 0!==n?n:null==s?void 0:s.value)&&void 0!==o?o:"",u=null!==(r=null==s?void 0:s.__funnelPercent)&&void 0!==r?r:null==s?void 0:s.__barFunnelPercent,d=null!==(i=null==s?void 0:s.__funnelIsFirstStep)&&void 0!==i?i:null==s?void 0:s.__barFunnelIsFirstStep,h=null==s?void 0:s.__barFunnelIsDropoff,g=null!==(a=null==s?void 0:s.__barFunnelCategory)&&void 0!==a?a:null==s?void 0:s.category,f=null==u||d?"":` (${.05>Math.abs(u-Math.round(u))?Math.round(u)+"%":u.toFixed(1)+"%"})`;return p.createElement("div",{className:"semiotic-tooltip",style:Jn},l&&p.createElement("div",{style:{fontWeight:"bold"}},l+""),g&&g!==l&&p.createElement("div",{style:{marginTop:2,opacity:.8}},g+""),h&&p.createElement("div",{style:{marginTop:2,fontStyle:"italic",opacity:.7}},"Dropoff"),p.createElement("div",{style:{marginTop:4}},c+"",f))},[]),Q=yo({componentName:"FunnelChart",data:i,accessors:{stepAccessor:l,valueAccessor:c}});if(Q)return p.createElement(co,{componentName:"FunnelChart",message:Q,width:T,height:N});const Z=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:_?"bar-funnel":"funnel"},null!=i&&{data:F}),{oAccessor:l,rAccessor:c}),u&&{stackBy:u}),{projection:_?"vertical":"horizontal",barPadding:_?40:0,pieceStyle:U,size:[T,N],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:G.margin,enableHover:D}),t.dataIdAccessor&&{dataIdAccessor:t.dataIdAccessor}),{showAxes:_,showCategoryTicks:_}),L&&{oFormat:L}),{showGrid:_}),!_&&{connectorOpacity:f}),{showLabels:y}),G.legendBehaviorProps),I&&{title:I}),H&&{description:H}),R&&{summary:R}),void 0!==W&&{accessibleTable:W}),s&&{className:s}),{tooltipContent:!1===m?()=>null:!0===m||null==m?K:oo(m)||K}),(k||w||A||S)&&{customHoverBehavior:G.customHoverBehavior}),(w||A||k)&&{customClickBehavior:G.customClickBehavior}),v&&v.length>0&&{annotations:v}),Object.fromEntries(Object.entries(b).filter(([e])=>"pieceStyle"!==e)));return p.createElement(Ho,{componentName:"FunnelChart",width:T,height:N},p.createElement(Vr,Object.assign({ref:r},Z)))});ci.displayName="FunnelChart";const ui="__likert_neutral_neg",di="__likert_neutral_pos";function hi(e,t){if("function"==typeof e)return e;const n=e||t;return e=>e[n]}function gi(e,t,n,o,r,i){const a=new Map,s=new Set(t);for(const l of e){const e=n(l);a.has(e)||a.set(e,new Map);const c=a.get(e);if(o){const e=o(l);if(null==e||!Number.isFinite(e))continue;if(!Number.isInteger(e)){"production"!==process.env.NODE_ENV&&console.warn("[LikertChart] Ignoring non-integer Likert score:",e);continue}const n=e-1;if(0>n||n>=t.length)continue;const r=t[n];c.set(r,(c.get(r)||0)+1)}else if(r&&i){const e=r(l),t=i(l);if(!s.has(e))continue;c.set(e,(c.get(e)||0)+(Number.isFinite(t)?t:0))}}const l=[];for(const[e,n]of a){let o=0;for(const e of t)o+=n.get(e)||0;if(0!==o)for(let r=0;t.length>r;r++){const i=t[r],a=n.get(i)||0;l.push({__likertCategory:e,__likertLevel:i,__likertLevelLabel:i,__likertCount:a,__likertPct:a/o*100,__likertLevelIndex:r})}}return l}function fi(e,t){const n=t.length,o=n%2!=0,r=Math.floor(n/2),i=[];for(const t of e){const e=t.__likertLevelIndex;if(o&&e===r){const e=t.__likertPct/2;i.push(Object.assign(Object.assign({},t),{__likertLevel:ui,__likertPct:-e})),i.push(Object.assign(Object.assign({},t),{__likertLevel:di,__likertPct:e}))}else i.push(r>e?Object.assign(Object.assign({},t),{__likertPct:-t.__likertPct}):t)}return i}function pi(e,t){const n=t.length,o=n%2!=0,r=Math.floor(n/2),i=new Map;for(const t of e){const e=i.get(t.__likertCategory)||[];e.push(t),i.set(t.__likertCategory,e)}const a=[];for(const[,e]of i){const t=new Map;let i,s;for(const n of e)n.__likertLevel===ui?i=n:n.__likertLevel===di?s=n:t.set(n.__likertLevelIndex,n);o&&i&&a.push(i);for(let e=r-1;e>=0;e--){const n=t.get(e);n&&a.push(n)}o&&s&&a.push(s);for(let e=o?r+1:r;n>e;e++){const n=t.get(e);n&&a.push(n)}}return a}const yi=e.forwardRef(function(t,n){const o=Qn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel,showCategoryTicks:t.showCategoryTicks,orientation:t.orientation}),r=e.useRef(null),{data:i,margin:a,className:s,categoryAccessor:l="question",valueAccessor:c,levelAccessor:u,countAccessor:d="count",levels:h,orientation:g="horizontal",colorScheme:f,barPadding:y=20,tooltip:m,annotations:v,frameProps:b={},selection:x,linkedHover:k,onObservation:w,onClick:A,hoverHighlight:S,chartId:O,valueFormat:E,loading:M,emptyContent:j,legendInteraction:C,legendPosition:P,categoryFormat:L}=t,_=o.width,B=o.height,T=o.enableHover,N=o.showGrid,D=o.showLegend,I=o.title,H=o.description,R=o.summary,W=o.accessibleTable,F=o.categoryLabel,z=o.valueLabel,$="horizontal"===g,G=void 0===i,Y=!u,q=e.useMemo(()=>f&&Array.isArray(f)&&f.length>=h.length?f:function(e){const t=["#da1e28","#ff8389","#ffb3b8"],n=["#a6c8ff","#4589ff","#0043ce"],o="#a8a8a8";if(0>=e)return[];if(1===e)return[o];const r=e%2!=0,i=Math.floor(e/2),a=[];for(let e=0;i>e;e++)a.push(t[Math.min(Math.floor(e*t.length/i),t.length-1)]);r&&a.push(o);for(let e=0;i>e;e++)a.push(n[Math.min(Math.floor(e*n.length/i),n.length-1)]);return a}(h.length),[f,h.length]),X=e.useMemo(()=>{const e=new Map;for(let t=0;h.length>t;t++)e.set(h[t],q[t]||"#888");return e},[h,q]),{processedData:V,reAggregate:U,accumulatorRef:K}=function({data:t,levels:n,categoryAccessor:o,valueAccessor:r,levelAccessor:i,countAccessor:a,isDiverging:s,frameRef:l}){const c=!i,u=e.useMemo(()=>hi(o,"question"),[o]),d=e.useMemo(()=>c?hi(r,"score"):null,[c,r]),h=e.useMemo(()=>c?null:hi(i,"level"),[c,i]),g=e.useMemo(()=>c?null:hi(a,"count"),[c,a]),f=t||[],p=e.useRef([]),y=e.useMemo(()=>{if(0===f.length)return[];let e=gi(f,n,u,d,h,g);return s&&(e=fi(e,n),e=pi(e,n)),e},[f,n,u,d,h,g,s]),m=e.useCallback(e=>{var t,o;let r=gi(e,n,u,d,h,g);s&&(r=fi(r,n),r=pi(r,n)),null===(t=l.current)||void 0===t||t.clear(),r.length>0&&(null===(o=l.current)||void 0===o||o.pushMany(r))},[n,u,d,h,g,s,l]);return{processedData:y,reAggregate:m,accumulatorRef:p}}({data:i,levels:h,categoryAccessor:l,valueAccessor:c,levelAccessor:u,countAccessor:d,isDiverging:$,frameRef:r}),Q="__likertLevelLabel",Z=Ko({isPushMode:G,colorBy:Q,colorScheme:q,showLegend:D,legendPosition:P}),J=e.useCallback(Z.wrapPush(e=>{K.current.push(e),U(K.current)}),[Z.wrapPush,U,K]),ee=e.useCallback(Z.wrapPushMany(e=>{K.current.push(...e),U(K.current)}),[Z.wrapPushMany,U,K]);e.useImperativeHandle(n,()=>({push:J,pushMany:ee,remove:e=>{var t,n;return null!==(n=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=r.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;K.current=[],Z.resetCategories(),null===(e=r.current)||void 0===e||e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}),[J,ee,Z.resetCategories,K]);const te=Zo({data:V,rawData:i,colorBy:Q,colorScheme:q,legendInteraction:C,legendPosition:P,selection:x,linkedHover:k,fallbackFields:["__likertLevelLabel"],unwrapData:!0,onObservation:w,onClick:A,hoverHighlight:S,chartType:"LikertChart",chartId:O,showLegend:D,userMargin:a,marginDefaults:o.marginDefaults,loading:M,emptyContent:j,width:_,height:B});if(te.earlyReturn)return te.earlyReturn;const ne=e.useMemo(()=>{const e=h.length;return e%2!=0&&X.get(h[Math.floor(e/2)])||"#888"},[h,X]),oe=e.useMemo(()=>e=>{var t,n;const o=e.__likertLevelLabel||(null===(t=e.data)||void 0===t?void 0:t.__likertLevelLabel),r=e.__likertLevel||(null===(n=e.data)||void 0===n?void 0:n.__likertLevel);if(r===ui||r===di)return{fill:ne};const i=o||r;return i&&X.has(i)?{fill:X.get(i)}:{fill:"#888"}},[X,ne]),re=e.useMemo(()=>Bn(oe,te.effectiveSelectionHook,x),[oe,te.effectiveSelectionHook,x]),ie=e.useMemo(()=>{const e=h.length;return e%2!=0?h[Math.floor(e/2)]:""},[h]),ae=e.useMemo(()=>e=>{const t=e.data||e,n=t.__likertLevel||"Unknown",o=n===ui||n===di?ie:n,r=t.__likertCategory||"",i=Math.abs(t.__likertPct||0),a=n===ui||n===di?2*i:i,s=t.__likertCount||0;return p.createElement("div",{className:"semiotic-tooltip",style:Jn},p.createElement("div",{style:{fontWeight:"bold"}},r),p.createElement("div",{style:{marginTop:4}},`${o}: ${a.toFixed(1)}% (n=${s})`))},[ie]),se=e.useMemo(()=>{if(!h||2>h.length)return"LikertChart requires `levels` with at least 2 entries.";if(c&&u)return"LikertChart: provide either `valueAccessor` (raw responses) or `levelAccessor` + `countAccessor` (pre-aggregated), not both.";if(u&&!d)return"LikertChart: pre-aggregated mode requires both `levelAccessor` and `countAccessor`.";if(void 0!==i&&0===i.length)return null;const e={categoryAccessor:l};return Y?c&&(e.valueAccessor=c):(u&&(e.levelAccessor=u),d&&(e.countAccessor=d)),yo({componentName:"LikertChart",data:i,accessors:e,requiredProps:{levels:h}})},[i,l,c,u,d,h,Y]),le=e.useMemo(()=>[{styleFn:e=>({fill:X.get(e.label)||"#888"}),items:h.map(e=>({label:e})),label:""}],[h,X]),ce=e.useMemo(()=>!1!==D?Object.assign(Object.assign({},te.legendBehaviorProps),{legend:{legendGroups:le},legendPosition:P||te.legendPosition||"bottom"}):te.legendBehaviorProps,[te.legendBehaviorProps,te.legendPosition,P,D,le]),ue=e.useMemo(()=>{const e=Object.assign({},te.margin);if(G&&!1!==D){const t=P||"bottom";"bottom"===t&&80>e.bottom?e.bottom=80:"top"===t&&50>e.top?e.top=50:"right"===t&&110>e.right?e.right=110:"left"===t&&110>e.left&&(e.left=110)}else if(Z.streamingMarginAdjust)for(const[t,n]of Object.entries(Z.streamingMarginAdjust))n>e[t]&&(e[t]=n);return $&&100>e.left&&(e.left=100),e},[te.margin,Z.streamingMarginAdjust,$,G,D,P]),de=e.useMemo(()=>E||($?e=>Math.abs(Number(e)).toFixed(0)+"%":e=>Number(e).toFixed(0)+"%"),[$,E]),he=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bar"},null!=i&&{data:V}),{oAccessor:"__likertCategory",rAccessor:"__likertPct",stackBy:"__likertLevel",normalize:!1,projection:$?"horizontal":"vertical",pieceStyle:re,size:[_,B],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:ue,barPadding:y,enableHover:T}),t.dataIdAccessor&&{dataIdAccessor:t.dataIdAccessor}),{showAxes:o.showAxes,oLabel:F,rLabel:z||($?void 0:"Percentage"),rFormat:de}),L&&{oFormat:L}),{showGrid:N}),ce),I&&{title:I}),H&&{description:H}),R&&{summary:R}),void 0!==W&&{accessibleTable:W}),s&&{className:s}),{tooltipContent:!1===m?()=>null:!0===m?ae:oo(m)||ae}),(k||w||A||S)&&{customHoverBehavior:te.customHoverBehavior}),(w||A||k)&&{customClickBehavior:te.customClickBehavior}),v&&v.length>0&&{annotations:v}),Object.fromEntries(Object.entries(b).filter(([e])=>"pieceStyle"!==e)));return se?p.createElement(co,{componentName:"LikertChart",message:se,width:_,height:B}):p.createElement(Ho,{componentName:"LikertChart",width:_,height:B},p.createElement(Vr,Object.assign({ref:r},he)))});yi.displayName="LikertChart";const mi={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},vi={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class bi{constructor(e){this.capacity=e,this.particles=Array(e);for(let t=0;e>t;t++)this.particles[t]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0}}spawn(e){for(let t=0;this.capacity>t;t++){const n=this.particles[t];if(!n.active)return n.active=!0,n.t=0,n.offset=Math.random()-.5,n.edgeIndex=e,n.x=0,n.y=0,n}return null}step(e,t,n,o){var r;for(let i=0;this.capacity>i;i++){const a=this.particles[i];if(!a.active)continue;const s=n[a.edgeIndex];if(!s||!s.bezier){a.active=!1;continue}const l=o&&null!==(r=o[a.edgeIndex])&&void 0!==r?r:1;if(a.t+=e*t*l*(s.bezier.circular?.3:1),a.t>=1){a.active=!1;continue}const c=xi(s.bezier,a.t,a.offset);a.x=c.x,a.y=c.y}}countForEdge(e){let t=0;for(let n=0;this.capacity>n;n++)this.particles[n].active&&this.particles[n].edgeIndex===e&&t++;return t}clear(){for(let e=0;this.capacity>e;e++)this.particles[e].active=!1}resize(e){if(this.capacity>=e)return;const t=this.particles;this.particles=Array(e);for(let n=0;e>n;n++)this.particles[n]=t.length>n?t[n]:{t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0};this.capacity=e}}function xi(e,t,n){if(e.circular&&e.segments)return function(e,t,n,o){const r=e.length,i=t*r,a=Math.min(Math.floor(i),r-1),s=i-a,[l,c,u,d]=e[a],h=ki(l,c,u,d,s),g=d.x-l.x,f=d.y-l.y,p=Math.sqrt(g*g+f*f);if(p>.001){const e=g/p;h.x+=-f/p*n*o*2,h.y+=e*n*o*2}return h}(e.segments,t,n,e.halfWidth);if(!e.points)return{x:0,y:0};const[o,r,i,a]=e.points,s=ki(o,r,i,a,t),l=a.x-o.x,c=a.y-o.y,u=Math.sqrt(l*l+c*c);if(u>.001){const t=l/u;s.x+=-c/u*n*e.halfWidth*2,s.y+=t*n*e.halfWidth*2}return s}function ki(e,t,n,o,r){const i=1-r,a=i*i,s=a*i,l=r*r,c=l*r;return{x:s*e.x+3*a*r*t.x+3*i*l*n.x+c*o.x,y:s*e.y+3*a*r*t.y+3*i*l*n.y+c*o.y}}function wi(e,t){var n=e.get(t);if(!n)throw Error("missing: "+t);return n}function Ai(e,t){var n,o=[],r=[],i=[],a={},s=[];function l(e){i[e]=!1,a.hasOwnProperty(e)&&Object.keys(a[e]).forEach(function(t){delete a[e][t],i[t]&&l(t)})}function c(e){var t,o,d=!1;for(r.push(e),i[e]=!0,t=0;s[e].length>t;t++)(o=s[e][t])===n?(u(n,r),d=!0):i[o]||(d=c(o));if(d)l(e);else for(t=0;s[e].length>t;t++){var h=a[o=s[e][t]];h||(a[o]=h={}),h[o]=!0}return r.pop(),d}function u(e,t){var n=[].concat(t).concat(e);o.push(n)}function d(t){!function(t){for(var n=0;e.length>n;n++)n>=t&&e[n]||(e[n]=[]),e[n]=e[n].filter(function(e){return e>=t})}(t);for(var n,o=function(e){for(var t=e.length,n=Array(t),o=Array(t),r=Array(t),i=Array(t),a=Array(t),s=Array(t),l=0;t>l;++l)n[l]=-1,o[l]=0,r[l]=!1,i[l]=0,a[l]=-1,s[l]=[];var c,u=0,d=[],h=[];function g(t){var l=[t],c=[t];for(n[t]=o[t]=u,r[t]=!0,u+=1;c.length>0;){var g=e[t=c[c.length-1]];if(g.length>i[t]){for(var f=i[t];g.length>f;++f){var p=g[f];if(0>n[p]){n[p]=o[p]=u,r[p]=!0,u+=1,l.push(p),c.push(p);break}r[p]&&(o[t]=0|Math.min(o[t],o[p])),0>a[p]||s[t].push(a[p])}i[t]=f}else{if(o[t]===n[t]){var y=[],m=[],v=0;for(f=l.length-1;f>=0;--f){var b=l[f];if(r[b]=!1,y.push(b),m.push(s[b]),v+=s[b].length,a[b]=d.length,b===t){l.length=f;break}}d.push(y);var x=Array(v);for(f=0;m.length>f;f++)for(var k=0;m[f].length>k;k++)x[--v]=m[f][k];h.push(x)}c.pop()}}}for(l=0;t>l;++l)0>n[l]&&g(l);for(l=0;h.length>l;l++){var f=h[l];if(0!==f.length){f.sort(function(e,t){return e-t}),c=[f[0]];for(var p=1;f.length>p;p++)f[p]!==f[p-1]&&c.push(f[p]);h[l]=c}}return{components:d,adjacencyList:h}}(e),r=o.components.filter(function(e){return e.length>1}),i=1/0,a=0;r.length>a;a++)for(var s=0;r[a].length>s;s++)i>r[a][s]&&(i=r[a][s],n=a);var l=r[n];if(!l)return!1;var c=e.map(function(e,t){return-1===l.indexOf(t)?[]:e.filter(function(e){return-1!==l.indexOf(e)})});return{leastVertex:i,adjList:c}}n=0;for(var h=e.length;h>n;){var g=d(n);if(n=g.leastVertex,s=g.adjList){for(var f=0;s.length>f;f++)for(var p=0;s[f].length>p;p++){var y=s[f][p];i[+y]=!1,a[y]={}}c(n),n+=1}else n=h}return o}function Si(e){return e.y0-e.y1>0?"up":"down"}function Oi(e,t){return t(e.source)==t(e.target)}function Ei(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var n=0;return e.target.targetLinks.forEach(function(e){n=e.circular?n+1:n}),1>=t&&1>=n}function Mi(e){return e.target.x0-e.source.x1}function ji(e,t){var n=Pi(e),o=Mi(t)/Math.tan(n);return"up"==Si(e)?e.y1-o:e.y1+o}function Ci(e,t){var n=Pi(e),o=Mi(t)/Math.tan(n);return"up"==Si(e)?e.y1+o:e.y1-o}function Pi(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function Li(e,t){return t(e)}function _i(e){return Ti(e.source)}function Bi(e){return Ti(e.target)}function Ti(e){return(e.y0+e.y1)/2}function Ni(e){return e.virtual?0:e.value}function Di(e,t){var n=0;e.sourceLinks.forEach(function(e){n=e.circular&&!Oi(e,t)?n+1:n});var o=0;return e.targetLinks.forEach(function(e){o=e.circular&&!Oi(e,t)?o+1:o}),n+o}function Ii(e){return e.target.depth}function Hi(e,t){return e.sourceLinks.length?e.depth:t-1}function Ri(e,t){return e.y0-t.y0}function Wi(e,t){return t.y0-e.y0}function Fi(e,t){return e.y1-t.y1}function zi(e,t){return t.y1-e.y1}function $i(e,t){return Yi(e.source,t.source)||e.index-t.index}function Gi(e,t){return Yi(e.target,t.target)||e.index-t.index}function Yi(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function qi(e,t){return Xi(e)==Xi(t)?"bottom"==e.circularLinkType?Wi(e,t):Ri(e,t):Xi(t)-Xi(e)}function Xi(e){return e.target.column-e.source.column}function Vi(e,t){return Ui(e)==Ui(t)}function Ui(e){return e.y0-e.y1>0?"up":"down"}function Ki(e,t,n,o,r){let i=e;var s=Math.max(8,.15*(i.y1-i.y0));i.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,s))});var l=a.min(i.links,function(e){return e.source.y0});i.links.forEach(function(e){e.circular&&(e.circularPathData={})});var c=i.links.filter(function(e){return e.circular});return c.sort(function(e,t){return t.value-e.value}),c.forEach(function(e,t){e._circularStub=t>=4}),Qi(i.links.filter(function(e){return"top"==e.circularLinkType}),t,n),Qi(i.links.filter(function(e){return"bottom"==e.circularLinkType}),t,n),i.links.forEach(function(e){if(e.circular){if(e.circularPathData.arcRadius=e._circularWidth+o,e.circularPathData.rightNodeBuffer=5,e.circularPathData.leftNodeBuffer=5,e.circularPathData.sourceWidth=e.source.x1-e.source.x0,e.circularPathData.sourceX=e.source.x0+e.circularPathData.sourceWidth,e.circularPathData.targetX=e.target.x0,e.circularPathData.sourceY=e.y0,e.circularPathData.targetY=e.y1,Oi(e,t)&&Ei(e))e.circularPathData.rightSmallArcRadius=o+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=o+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=o+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=o+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+r+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=e.source.y0-r-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius);else{var a=e.source.column,s=e.circularLinkType,c=i.links.filter(function(e){return e.source.column==a&&e.circularLinkType==s});c.sort("bottom"==e.circularLinkType?Wi:Ri);var u=0;c.forEach(function(t,r){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=o+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=o+e._circularWidth/2+r*n+u),u+=t._circularWidth||t.width}),a=e.target.column,(c=i.links.filter(function(e){return e.target.column==a&&e.circularLinkType==s})).sort("bottom"==e.circularLinkType?zi:Fi),u=0,c.forEach(function(t,r){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=o+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=o+e._circularWidth/2+r*n+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(i.y1,e.source.y1,e.target.y1)+r+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=l-r-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius)}e.circularPathData.rightInnerExtent=e.circularPathData.sourceX+e.circularPathData.rightNodeBuffer,e.circularPathData.leftInnerExtent=e.circularPathData.targetX-e.circularPathData.leftNodeBuffer,e.circularPathData.rightFullExtent=e.circularPathData.sourceX+e.circularPathData.rightLargeArcRadius+e.circularPathData.rightNodeBuffer,e.circularPathData.leftFullExtent=e.circularPathData.targetX-e.circularPathData.leftLargeArcRadius-e.circularPathData.leftNodeBuffer}e.path=e.circular?function(e){return"top"==e.circularLinkType?"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 0 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY-e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 0 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 0 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY-e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 0 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY:"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 1 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY+e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 1 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 1 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY+e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 1 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY}(e):function(e){var t=e.source.x1,n=e.y0,o=e.target.x0,r=e.y1,i=(t+o)/2;return"M"+t+","+n+"C"+i+","+n+" "+i+","+r+" "+o+","+r}(e)}),i}function Qi(e,t,n){e.sort(qi);var o=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,r){var i=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(Oi(e,t)&&Ei(e))e.circularPathData.verticalBuffer=i+e._circularWidth/2;else{for(var a=0;o.length>a;a++){var s=o[a];if(s!==e&&s.circularPathData&&void 0!==s.circularPathData.verticalBuffer&&Zi(e,s)){var l=s.circularPathData.verticalBuffer+(s._circularWidth||s.width)/2+n;i=l>i?l:i}}e.circularPathData.verticalBuffer=i+e._circularWidth/2}}),e}function Zi(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}function Ji(e){return function(){return e}}function ea(e){return e.index}function ta(e){return e.nodes}function na(e){return e.links}function oa(e,t,n){var o=a.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});o.forEach(function(r,i){var a=r.length;if(t)r.sort(t);else if(i>0){var s=new Map;r.forEach(function(e,t){var n,o,r,i=(o=0,r=0,(n=e).targetLinks.forEach(function(e){if(!e.circular){var t=e.value||1;r+=Ti(e.source)*t,o+=t}}),n.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;r+=Ti(e.target)*t,o+=t}}),o>0?r/o:NaN);s.set(e,{bc:i,idx:t})}),r.sort(function(e,t){var n=s.get(e),o=s.get(t),r=n.bc,i=o.bc;if(e.circularLinkType!==t.circularLinkType){if("top"==e.circularLinkType&&"bottom"==t.circularLinkType)return-1;if("bottom"==e.circularLinkType&&"top"==t.circularLinkType)return 1;if("top"==e.circularLinkType)return-1;if("top"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return-1}return isNaN(r)||isNaN(i)?isNaN(r)?isNaN(i)?n.idx-o.idx:1:-1:r-i})}else r.sort(function(e,t){return e.circularLinkType==t.circularLinkType?Di(t,n)-Di(e,n):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0});r.forEach(function(t,r){t.depth==o.length-1&&1==a||0==t.depth&&1==a?(t.y0=e.y1/2-t.value*e.ky,t.y1=t.y0+t.value*e.ky):t.partOfCycle?0==Di(t,n)?(t.y0=e.y1/2+r,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+r,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-r,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/a*r,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-a/2+r,t.y1=t.y0+t.value*e.ky)})})}function ra(e,t,n,o,r,i){var s=a.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});d();for(var l=1,c=i;c>0;--c)u(l*=.99,n),d();function u(t,n){var o=s.length;s.forEach(function(r){var i=r.length,s=r[0].depth;r.forEach(function(r){var l;if(r.sourceLinks.length||r.targetLinks.length)if(r.partOfCycle&&Di(r,n)>0){var c=a.mean(r.sourceLinks,Bi),u=a.mean(r.targetLinks,_i),d=c&&u?(c+u)/2:c||u;if(d){var h=(d-Ti(r))*t*.3;r.y0+=h,r.y1+=h}}else if(0==s&&1==i)r.y0=e.y1/2-(l=r.y1-r.y0)/2,r.y1=e.y1/2+l/2;else if(s==o-1&&1==i)r.y0=e.y1/2-(l=r.y1-r.y0)/2,r.y1=e.y1/2+l/2;else if(1==r.targetLinks.length&&1==r.targetLinks[0].source.sourceLinks.length)l=r.y1-r.y0,r.y0=r.targetLinks[0].source.y0,r.y1=r.y0+l;else{var g=a.mean(r.sourceLinks,Bi),f=a.mean(r.targetLinks,_i),p=((g&&f?(g+f)/2:g||f)-Ti(r))*t;r.y0+=p,r.y1+=p}})})}function d(){s.forEach(function(n){var i,a,s,l=e.y0,c=n.length;for(n.sort(t||Yi),s=0;c>s;++s)(a=l-(i=n[s]).y0)>0&&(i.y0+=a,i.y1+=a),l=i.y1+o;if((a=l-o-e.y1)>0)for(l=i.y0-=a,i.y1-=a,s=c-2;s>=0;--s)(a=(i=n[s]).y1+r-l)>0&&(i.y0-=a,i.y1-=a),l=i.y0})}}function ia(e){e.nodes.forEach(function(e){e.sourceLinks.sort(Gi),e.targetLinks.sort($i)}),e.nodes.forEach(function(e){var t=e.y0,n=t,o=e.y1,r=o;e.sourceLinks.forEach(function(e){e.circular?(e.y0=o-e.width/2,o-=e.width):(e.y0=t+e.width/2,t+=e.width)}),e.targetLinks.forEach(function(e){e.circular?(e.y1=r-e.width/2,r-=e.width):(e.y1=n+e.width/2,n+=e.width)})})}function aa(){var e=0,t=0,n=1,o=1,r=24,i=8,s=null,l=ea,c=Hi,u=void 0,d=32,h=2,g=ta,f=na;function p(){var p={nodes:g.apply(null,arguments),links:f.apply(null,arguments)};return function(g){g.x0=e,g.y0=t,g.x1=n,g.y1=o,g.py=0,function(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var n=function(e,t){var n=new Map;return a.group(e,t).forEach(function(e,t){n.set(t,e[0])}),n}(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var o=e.source,r=e.target;"object"!=typeof o&&(o=e.source=wi(n,o)),"object"!=typeof r&&(r=e.target=wi(n,r)),o.sourceLinks.push(e),r.targetLinks.push(e)})}(g,l),function(e,t){var n=0;if(null==t){for(var o=[],r=0;e.links.length>r;r++){var i=e.links[r],a=i.source.index,s=i.target.index;o[a]||(o[a]=[]),o[s]||(o[s]=[]),-1===o[a].indexOf(s)&&o[a].push(s)}var l=Ai(o);l.sort(function(e,t){return e.length-t.length});var c={};for(r=0;l.length>r;r++){var u=l[r].slice(-2);c[u[0]]||(c[u[0]]={}),c[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,o=e.source.index;t===o||c[o]&&c[o][t]?(e.circular=!0,e.circularLinkID=n++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=n++)})}(g,u),function(e,t){var n=0,o=0;e.links.forEach(function(r){r.circular&&(r.circularLinkType=r.source.circularLinkType||r.target.circularLinkType?r.source.circularLinkType?r.source.circularLinkType:r.target.circularLinkType:o>n?"top":"bottom","top"==r.circularLinkType?n++:o++,e.nodes.forEach(function(e){Li(e,t)!=Li(r.source,t)&&Li(e,t)!=Li(r.target,t)||(e.circularLinkType=r.circularLinkType)}))}),e.links.forEach(function(e){e.circular&&(e.source.circularLinkType==e.target.circularLinkType&&(e.circularLinkType=e.source.circularLinkType),Oi(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(g,l),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(a.sum(e.sourceLinks,Ni),a.sum(e.targetLinks,Ni)),e.sourceLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)}),e.targetLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)})})}(g),function(e,t,n){var o,r,i;if(null!=t){e.nodes.sort(function(e,n){return t(e)<t(n)?-1:1});var a=0,s=t(e.nodes[0]);e.nodes.forEach(function(e){a=t(e)==s?a:a+1,s=t(e)==s?s:t(e),e.column=a})}for(o=e.nodes,r=[],i=0;o.length;++i,o=r,r=[])o.forEach(function(e){e.depth=i,e.sourceLinks.forEach(function(e){0>r.indexOf(e.target)&&!e.circular&&r.push(e.target)})});for(o=e.nodes,r=[],i=0;o.length;++i,o=r,r=[])o.forEach(function(e){e.height=i,e.targetLinks.forEach(function(e){0>r.indexOf(e.source)&&!e.circular&&r.push(e.source)})});e.nodes.forEach(function(e){e.column=null==t?n(e,i):e.column})}(g,u,c);var f=i;if(null!==s){var p=a.groups(g.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),y=a.max(p,function(e){return e.length});y>1&&(f=Math.max(1,(o-t)*s/(y-1)))}(function(e,t,n){var o=a.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});e.py=t;var r=a.min(o,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/a.sum(t,function(e){return e.value})});e.ky=r,e.links.forEach(function(t){t.width=t.value*e.ky});var i=a.max(e.nodes,function(e){return e.column});e.nodes.forEach(i>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-n)/i),t.x1=t.x0+n}:function(t){t.x0=e.x0,t.x1=t.x0+n})})(g,f,r),oa(g,u,l),ra(g,u,l,f,f,d),ia(g),Ki(g,l,h,10,8),oa(g,u,l),ra(g,u,l,f,f,d),ia(g),Ki(g,l,h,10,8),function(e,t){let n=e;n.nodes.forEach(function(e){e.y+(e.y1-e.y0)>n.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-n.y1));var o=n.links.filter(function(n){return Li(n.source,t)==Li(e,t)}),r=o.length;r>1&&o.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!Vi(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var n=ji(t,e);return e.y1-n}if(t.target.column>e.target.column)return ji(e,t)-t.y1}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.target.column===t.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.target.column===t.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;o.forEach(function(e){e.y0=i+e.width/2,i+=e.width}),o.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,a=0;r>i;i++)a+=o[i].width;t.y0=e.y1-a-t.width/2}})})}(g,l),function(e,t){let n=e;n.nodes.forEach(function(e){var o=n.links.filter(function(n){return Li(n.target,t)==Li(e,t)}),r=o.length;r>1&&o.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!Vi(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var n=Ci(t,e);return e.y0-n}if(t.source.column>e.source.column)return Ci(e,t)-t.y0}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:e.source.column-t.source.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:t.source.column-e.source.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;o.forEach(function(e){e.y1=i+e.width/2,i+=e.width}),o.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,a=0;r>i;i++)a+=o[i].width;t.y1=e.y1-a-t.width/2}})})}(g,l),function(e){var t=e.nodes,n=e.links,o=!1,r=!1;if(n.forEach(function(e){"top"==e.circularLinkType?o=!0:"bottom"==e.circularLinkType&&(r=!0)}),0==o||0==r){var i=a.min(t,function(e){return e.y0}),s=a.max(t,function(e){return e.y1}),l=(e.y1-e.y0)/(s-i);function c(t){return(t-i)/(s-i)*(e.y1-e.y0)+e.y0}1>l?(t.forEach(function(e){e.y0=c(e.y0),e.y1=c(e.y1)}),n.forEach(function(e){e.y0=c(e.y0),e.y1=c(e.y1),e.width=e.width*l})):t.forEach(function(e){var t=e.y1-e.y0,n=c(e.y0)-e.y0;e.y0=c(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+n}),e.targetLinks.forEach(function(e){e.y1=e.y1+n})})}}(g),Ki(g,l,h,10,8)}(p),p}return p.update=function(e){return ia(e),Ki(e,l,h,10,8),e},p.nodeWidth=function(e){return arguments.length?(r=+e,p):r},p.nodePadding=function(e){return arguments.length?(i=+e,p):i},p.nodePaddingRatio=function(e){return arguments.length?(s=+e,p):s},p.nodes=function(e){return arguments.length?(g="function"==typeof e?e:Ji(e),p):g},p.links=function(e){return arguments.length?(f="function"==typeof e?e:Ji(e),p):f},p.nodeId=function(e){return arguments.length?(l="function"==typeof e?e:Ji(e),p):l},p.nodeAlign=function(e){return arguments.length?(c="function"==typeof e?e:Ji(e),p):c},p.nodeSort=function(e){return arguments.length?(u=e,p):u},p.iterations=function(e){return arguments.length?(d=+e,p):d},p.circularLinkGap=function(e){return arguments.length?(h=+e,p):h},p.extent=function(r){return arguments.length?(e=+r[0][0],t=+r[0][1],n=+r[1][0],o=+r[1][1],p):[[e,t],[n,o]]},p.size=function(r){return arguments.length?(e=t=0,n=+r[0],o=+r[1],p):[n-e,o-t]},p}const sa=e=>{let t,n,o,r,i,a,s,l,c;return"down"===e.direction?(t=e.y0-e.sankeyWidth/2,n=e.y1-e.sankeyWidth/2,o=e.y1+e.sankeyWidth/2,r=e.y0+e.sankeyWidth/2,i=e.source.x1,a=e.target.x0,s=u.interpolateNumber(i,a),l=s(.5),c=s(.5),`M${t},${i}C${t},${l} ${n},${c} ${n},${a}L${o},${a}C${o},${c} ${r},${l} ${r},${i}Z`):(t=e.source.x1,n=e.target.x0,s=u.interpolateNumber(t,n),o=s(.5),r=s(.5),i=e.y0-e.sankeyWidth/2,a=e.y1-e.sankeyWidth/2,l=e.y1+e.sankeyWidth/2,c=e.y0+e.sankeyWidth/2,`M${t},${i}C${o},${i} ${r},${a} ${n},${a}L${n},${l}C${r},${l} ${o},${c} ${t},${c}Z`)};function la(e){var t;const n=e.sankeyWidth/2,o=(null!==(t=e._circularWidth)&&void 0!==t?t:e.sankeyWidth)/2,r=e.circularPathData;if(!r)return null;if("down"===e.direction)return null;if(e._circularStub){const t=r.sourceX,o=r.sourceY,i=r.targetX,a=r.targetY;if("object"!=typeof e.source||!e.source||"object"!=typeof e.target||!e.target)return null;const s=Math.max(15,Math.min(40,.33*(r.rightFullExtent-t))),l=Math.max(15,Math.min(40,.33*(i-r.leftFullExtent)));return`M${t},${o-n}L${t+s},${o-n}L${t+s},${o+n}L${t},${o+n}ZM${i},${a-n}L${i-l},${a-n}L${i-l},${a+n}L${i},${a+n}Z`}const i=r.sourceX,a=r.sourceY,s=r.targetX,l=r.targetY,c=r.rightFullExtent,u=r.leftFullExtent,d=r.verticalFullExtent,h="bottom"===e.circularLinkType?1:-1,g=Math.max(4,Math.min(o,15));return`M${i},${a-h*n}L${c},${a-h*n}L${c+o},${a-h*n+h*g}L${c+o},${d+h*o-h*g}L${c+o-g},${d+h*o}L${u-o+g},${d+h*o}L${u-o},${d+h*o-h*g}L${u-o},${l-h*n+h*g}L${u-o+g},${l-h*n}L${s},${l-h*n}L${s},${l+h*n}L${u+o},${l+h*n}L${u+o},${d-h*o}L${c-o},${d-h*o}L${c-o},${a+h*n}L${i},${a+h*n}Z`}const ca=new Set,ua=new WeakMap;function da(e,t){if("production"===process.env.NODE_ENV)return e;if(!e||!e.data||"object"!=typeof e.data)return e;let n=ua.get(e);if(n){const e=n.get(t);if(e)return e}else n=new Map,ua.set(e,n);const o=new Proxy(e,{get(e,n,o){if("string"==typeof n&&!(n in e)&&e.data&&n in e.data){const e=`${t}:${n}`;ca.has(e)||(ca.add(e),console.warn(`[Semiotic] "${t}" callback accessed "${n}" on the wrapper object, but it only exists on ".data". Use d.data.${n} (or d.data?.${n}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(e,n,o)}});return n.set(t,o),o}const ha={left:function(e){return e.depth},right:function(e,t){return t-1-e.height},center:function(e){return e.targetLinks.length?e.depth:e.sourceLinks.length?Math.min.apply(Math,e.sourceLinks.map(Ii))-1:0},justify:Hi},ga={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,o){var r,i,a,s,l,c,u;if(0===e.length)return;const d="vertical"===n.orientation?"down":"right",h=n.nodeAlign||"justify",g=null!==(r=n.nodeWidth)&&void 0!==r?r:15,f=null!==(i=n.nodePaddingRatio)&&void 0!==i?i:.05,p=null!==(a=n.iterations)&&void 0!==a?a:100,y=e.map(e=>Object.assign({},e)),m=t.map(e=>Object.assign(Object.assign({},e),{source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id,value:Math.sqrt(Math.max(1,e.value||1))}));let v;v="down"===d?[[0,0],[o[1],o[0]]]:[[0,0],[o[0],o[1]]];const b=aa().extent(v).links(m).nodes(y).nodeAlign(ha[h]||Hi).nodeId(e=>e.id).nodeWidth(g).iterations(p);b.nodePaddingRatio&&b.nodePaddingRatio(f),b();{let e=1/0,t=-1/0,n=1/0,r=-1/0;for(const o of y)e>o.x0&&(e=o.x0),o.x1>t&&(t=o.x1),n>o.y0&&(n=o.y0),o.y1>r&&(r=o.y1);for(const o of m){if(!o.circular||!o.circularPathData)continue;const i=o.circularPathData,a=(null!==(l=null!==(s=o._circularWidth)&&void 0!==s?s:o.width)&&void 0!==l?l:0)/2;e>i.leftFullExtent-a&&(e=i.leftFullExtent-a),i.rightFullExtent+a>t&&(t=i.rightFullExtent+a),n>i.verticalFullExtent-a&&(n=i.verticalFullExtent-a),i.verticalFullExtent+a>r&&(r=i.verticalFullExtent+a)}const i=t-e,a=r-n,u=o[0],d=o[1];if(i>0&&a>0&&(0>e||0>n||t>u||r>d)){const t=Math.min(u/i,d/a),o=-e*t+(u-i*t)/2,r=-n*t+(d-a*t)/2;for(const e of y)e.x0=e.x0*t+o,e.x1=e.x1*t+o,e.y0=e.y0*t+r,e.y1=e.y1*t+r;for(const e of m)if(e.y0=e.y0*t+r,e.y1=e.y1*t+r,e.width=(null!==(c=e.width)&&void 0!==c?c:0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){const n=e.circularPathData;n.sourceX=n.sourceX*t+o,n.targetX=n.targetX*t+o,n.sourceY=n.sourceY*t+r,n.targetY=n.targetY*t+r,n.rightFullExtent=n.rightFullExtent*t+o,n.leftFullExtent=n.leftFullExtent*t+o,n.verticalFullExtent=n.verticalFullExtent*t+r,n.rightInnerExtent=n.rightInnerExtent*t+o,n.leftInnerExtent=n.leftInnerExtent*t+o,n.verticalRightInnerExtent=n.verticalRightInnerExtent*t+r,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*t+r,n.rightSmallArcRadius*=t,n.rightLargeArcRadius*=t,n.leftSmallArcRadius*=t,n.leftLargeArcRadius*=t,n.sourceWidth*=t,n.rightNodeBuffer*=t,n.leftNodeBuffer*=t,n.arcRadius*=t}}}const x=new Map;for(const t of e)x.set(t.id,t);for(const e of y){const t=x.get(e.id);t&&(t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.value=e.value,t.depth=e.depth,t.sourceLinks=e.sourceLinks,t.targetLinks=e.targetLinks,t.width=e.x1-e.x0,t.height=e.y1-e.y0,t.x=e.x0+(e.x1-e.x0)/2,t.y=e.y0+(e.y1-e.y0)/2)}const k=new Map;for(const e of t)k.set(e._edgeKey?e._edgeKey:`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const e of m){const t=e.source,n=e.target,o="object"==typeof t&&null!==t?t.id:t+"",r="object"==typeof n&&null!==n?n.id:n+"",i=k.get(e._edgeKey?e._edgeKey:`${o}\0${r}`);if(i){i.y0=e.y0,i.y1=e.y1,i.sankeyWidth=null!==(u=e.width)&&void 0!==u?u:0,i.circular=!!e.circular,i.circularPathData=e.circularPathData,i._circularWidth=e._circularWidth,i._circularStub=e._circularStub,i.path=e.path,i.circularLinkType=e.circularLinkType,i.direction=d;const t=x.get(o),n=x.get(r);t&&(i.source=t),n&&(i.target=n)}}},buildScene(e,t,n,o){var r,a,s,l;const c="vertical"===n.orientation?"down":"right",u=n.nodeStyle,d=n.edgeStyle,h=null!==(r=n.edgeOpacity)&&void 0!==r?r:.5,g=n.edgeColorBy||"source",f=Array.isArray(n.colorScheme)?n.colorScheme:i.schemeCategory10,p=new Map;e.forEach((e,t)=>{p.set(e.id,f[t%f.length])});const y=[],m=[],v=[],b=new Map;for(const t of e){const e=t.x1-t.x0,n=t.y1-t.y0;if(0>=e||0>=n)continue;const o=u?u(da(t,"nodeStyle")):{},r={fill:o.fill||p.get(t.id)||"#4d430c",stroke:o.stroke,strokeWidth:o.strokeWidth,opacity:o.opacity};b.set(t.id,("string"==typeof r.fill?r.fill:null)||p.get(t.id)||"#4d430c"),y.push("down"===c?{type:"rect",x:t.y0,y:t.x0,w:n,h:e,style:r,datum:t,id:t.id,label:t.id}:{type:"rect",x:t.x0,y:t.y0,w:e,h:n,style:r,datum:t,id:t.id,label:t.id})}const x=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of x){if(!e.sankeyWidth||0>=e.sankeyWidth)continue;const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;if(!t||!n)continue;let o="#999";o="function"==typeof g?g(e)||o:"target"===g?b.get(n.id)||p.get(n.id)||o:b.get(t.id)||p.get(t.id)||o;const r=d?d(da(e,"edgeStyle")):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,n=e.sankeyWidth/2,i=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),l=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),c=r.fill||o;m.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-n}L${t.sourceX+i},${t.sourceY-n}L${t.sourceX+i},${t.sourceY+n}L${t.sourceX},${t.sourceY+n}Z`,style:{fill:c,fillOpacity:null!==(a=r.fillOpacity)&&void 0!==a?a:h,stroke:"none",opacity:r.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+i}}),m.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-n}L${t.targetX-l},${t.targetY-n}L${t.targetX-l},${t.targetY+n}L${t.targetX},${t.targetY+n}Z`,style:{fill:c,fillOpacity:null!==(s=r.fillOpacity)&&void 0!==s?s:h,stroke:"none",opacity:r.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-l,x1:t.targetX}});continue}let i;if(i=e.circular&&e.circularPathData?la(e):sa(e),!i)continue;const c={fill:r.fill||o,fillOpacity:null!==(l=r.fillOpacity)&&void 0!==l?l:h,stroke:r.stroke||"none",strokeWidth:r.strokeWidth,opacity:r.opacity};m.push({type:"bezier",pathD:i,bezierCache:e.bezier,style:c,datum:e})}if(!1!==n.showLabels){const t=(k=n.nodeLabel)?"function"==typeof k?k:e=>e[k]||e.id:null;for(const n of e){const e=n.x1-n.x0,r=n.y1-n.y0;if(0>=e||0>=r)continue;const i=t?t(n):n.id;if(!i)continue;let a,s,l;"down"===c?(a=n.y0+(n.y1-n.y0)/2,s=n.x1+14,l="middle"):(o[0]/2>n.x0+e/2?(a=n.x0-6,l="end"):(a=n.x1+6,l="start"),s=n.y0+r/2),v.push({x:a,y:s,text:i+"",anchor:l,baseline:"middle",fontSize:11})}}var k;return{sceneNodes:y,sceneEdges:m,labels:v}}},fa={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,o){var r,i;if(0===e.length)return;const a=null!==(r=n.forceStrength)&&void 0!==r?r:.1,s=o[0]/2,l=o[1]/2,c=n.__previousPositions;let u=0;const h=[];for(const t of e){const e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),n=null==c?void 0:c.get(t.id);e?u++:n?(t.x=n.x,t.y=n.y,u++):h.push(t)}const g=u>0&&.3>=(e.length>0?h.length/e.length:1);if(g){const n=new Map;for(const t of e)n.set(t.id,t);for(const e of h){const o=pa(e.id,t,n);if(o.length>0){let t=0,n=0;for(const e of o)t+=e.x,n+=e.y;const r=ya(e.id),i=r%360*(Math.PI/180),a=10+r%20;e.x=t/o.length+a*Math.cos(i),e.y=n/o.length+a*Math.sin(i)}else{const t=ya(e.id),n=t%360*(Math.PI/180),o=15+t%30;e.x=s+o*Math.cos(n),e.y=l+o*Math.sin(n)}}}else{const t=2.399963229728653;for(let n=0;e.length>n;n++){const o=e[n];if(null==o.x||null==o.y||0===o.x&&0===o.y){const e=10*Math.sqrt(n+.5),r=n*t;o.x=s+e*Math.cos(r),o.y=l+e*Math.sin(r)}}}const f=null!==(i=n.iterations)&&void 0!==i?i:Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),p=0===n.iterations?0:g?40:f,y=ma(n.nodeSize,n.nodeSizeRange,e),m=e=>y(e);if(p>0){const n=d.forceLink().strength(e=>Math.min(2.5,e.weight?e.weight*a:a)).id(e=>e.id),o=d.forceSimulation().force("charge",d.forceManyBody().strength(e=>-25*m(e))).force("center",d.forceCenter(s,l).strength(.8)).force("x",d.forceX(s).strength(.15)).force("y",d.forceY(l).strength(.15));if(o.nodes(e),t.length>0){const e=t.map(e=>Object.assign(Object.assign({},e),{source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id}));o.force("link",n),o.force("link").links(e)}g?o.alpha(.3):.1>o.alpha()&&o.alpha(1),o.stop();for(let e=0;p>e;++e)o.tick()}for(const t of e){if(null==t.x||null==t.y)continue;const e=m(t);t.x=Math.max(e,Math.min(o[0]-e,t.x)),t.y=Math.max(e,Math.min(o[1]-e,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}const v=new Map;for(const t of e)v.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=v.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=v.get(e.target);t&&(e.target=t)}}},buildScene(e,t,n,o){var r,a,s;const l=n.nodeStyle,c=n.edgeStyle,u=ma(n.nodeSize,n.nodeSizeRange,e),d=Array.isArray(n.colorScheme)?n.colorScheme:i.schemeCategory10,h=new Map;e.forEach((e,t)=>{h.set(e.id,d[t%d.length])});const g=[],f=[],p=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=u(da(t,"nodeSize")),n=l?l(da(t,"nodeStyle")):{},o={fill:n.fill||h.get(t.id)||"#007bff",stroke:n.stroke||"#fff",strokeWidth:null!==(r=n.strokeWidth)&&void 0!==r?r:2,opacity:n.opacity};g.push({type:"circle",cx:t.x,cy:t.y,r:e,style:o,datum:t,id:t.id,label:t.id})}const y=new Map;for(const t of e)y.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:y.get(e.source),n="object"==typeof e.target?e.target:y.get(e.target);if(!t||!n)continue;if(null==t.x||null==t.y)continue;if(null==n.x||null==n.y)continue;const o=c?c(da(e,"edgeStyle")):{},r={stroke:o.stroke||"#999",strokeWidth:null!==(a=o.strokeWidth)&&void 0!==a?a:1,opacity:null!==(s=o.opacity)&&void 0!==s?s:.6};f.push({type:"line",x1:t.x,y1:t.y,x2:n.x,y2:n.y,style:r,datum:e})}if(!1!==n.showLabels){const t=(m=n.nodeLabel)?"function"==typeof m?m:e=>e[m]||e.id:null;for(const n of e){if(null==n.x||null==n.y)continue;const e=t?t(n):n.id;if(!e)continue;const o=u(da(n,"nodeSize"));p.push({x:n.x,y:n.y-o-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var m;return{sceneNodes:g,sceneEdges:f,labels:p}}};function pa(e,t,n){const o=[];for(const r of t){const t="string"==typeof r.source?r.source:r.source.id,i="string"==typeof r.target?r.target:r.target.id;let a=null;if(t===e?a=i:i===e&&(a=t),a){const e=n.get(a);!e||0===e.x&&0===e.y||o.push({x:e.x,y:e.y})}}return o}function ya(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return Math.abs(t)}function ma(e,t,n){var r,i;if(null==e)return()=>8;if("number"==typeof e)return()=>e;if("function"==typeof e)return t=>e(t)||8;const s=t||[5,20],l=n.map(t=>{var n;return null===(n=t.data)||void 0===n?void 0:n[e]}).filter(e=>null!=e&&"number"==typeof e);if(0===l.length)return()=>s[0];const c=null!==(r=a.min(l))&&void 0!==r?r:0,u=null!==(i=a.max(l))&&void 0!==i?i:1;if(c===u)return()=>(s[0]+s[1])/2;const d=o.scaleLinear().domain([c,u]).range(s).clamp(!0);return t=>{var n;const o=null===(n=t.data)||void 0===n?void 0:n[e];return null==o||"number"!=typeof o?s[0]:d(o)}}const va=i.schemeCategory10,ba={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,n,o){if(0===e.length)return;const{padAngle:r=.01,groupWidth:i=20,sortGroups:a}=n,s=Math.min(o[0],o[1])/2,c=s-i,u=o[0]/2,d=o[1]/2,g=(f=n.valueAccessor)?"function"==typeof f?f:e=>{var t;return null!==(t=e[f])&&void 0!==t?t:1}:e=>{var t;return null!==(t=e.value)&&void 0!==t?t:1};var f;const p=new Map;for(let t=0;e.length>t;t++)p.set(e[t].id,t);const y=e.length,m=Array.from({length:y},()=>Array.from({length:y},()=>0));for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,n=p.get("string"==typeof e.source?e.source:e.source.id),o=p.get(t);if(void 0===n||void 0===o)continue;const r=g(e);m[n][o]=r}const v=h.chord().padAngle(r);a&&v.sortGroups(a);const b=v(m),x=b.groups,k=l.arc().innerRadius(c).outerRadius(s);for(const t of x){const n=e[t.index],o=k.centroid(t);n.x=o[0]+u,n.y=o[1]+d,n.arcData={startAngle:t.startAngle,endAngle:t.endAngle}}const w=new Map;for(const t of e)w.set(t.id,t);for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,n=w.get("string"==typeof e.source?e.source:e.source.id),o=w.get(t);n&&(e.source=n),o&&(e.target=o)}const A=new Map;for(const e of t)A.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const t of b){const n=e[t.source.index].id,o=e[t.target.index].id,r=A.get(`${n}\0${o}`)||A.get(`${o}\0${n}`);r&&(r.chordData=t)}},buildScene(e,t,n,o){var r,i;const{groupWidth:a=20,edgeOpacity:s=.5}=n,l=Math.min(o[0],o[1])/2,c=l-a,u=o[0]/2,d=o[1]/2,g=n.nodeStyle,f=n.edgeStyle,p=n.edgeColorBy||"source",y=Array.isArray(n.colorScheme)?n.colorScheme:va,m=new Map;e.forEach((e,t)=>{m.set(e.id,y[t%y.length])});const v=h.ribbon().radius(c),b=[],x=[],k=[];for(let t=0;e.length>t;t++){const n=e[t],o=n.arcData;if(!o)continue;let i;i=g?g(da(n,"nodeStyle")).fill||m.get(n.id)||y[t%y.length]:m.get(n.id)||y[t%y.length];const a=g?g(da(n,"nodeStyle")):{},s={fill:i,stroke:a.stroke||"black",strokeWidth:null!==(r=a.strokeWidth)&&void 0!==r?r:1,opacity:a.opacity};b.push({type:"arc",cx:u,cy:d,innerR:c,outerR:l,startAngle:o.startAngle-Math.PI/2,endAngle:o.endAngle-Math.PI/2,style:s,datum:n,id:n.id,label:n.id})}for(const e of t){const t=e.chordData;if(!t)continue;const n=v(t);if(!n)continue;const o=xa(n,u,d);let r="#999";if(f)r=f(da(e,"edgeStyle")).fill||r;else{const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;"target"===p&&n?r=m.get(n.id)||r:t&&(r=m.get(t.id)||r)}const a=f?f(da(e,"edgeStyle")):{},l={fill:r,fillOpacity:null!==(i=a.fillOpacity)&&void 0!==i?i:s,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity};x.push({type:"ribbon",pathD:o,style:l,datum:e})}if(!1!==n.showLabels){const t=(w=n.nodeLabel)?"function"==typeof w?w:e=>e[w]||e.id:null,o=l+12;for(const n of e){const e=n.arcData;if(!e)continue;const r=t?t(n):n.id;if(!r)continue;const i=(e.startAngle+e.endAngle)/2,a=i-Math.PI/2;k.push({x:u+Math.cos(a)*o,y:d+Math.sin(a)*o,text:r+"",anchor:i>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var w;return{sceneNodes:b,sceneEdges:x,labels:k}}};function xa(e,t,n){const o=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!o)return e;const r=[];let i=0;for(;o.length>i;){const e=o[i];if("M"===e||"L"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)r.push(Number(o[i])+t+""),i++,o.length>i&&!isNaN(Number(o[i]))&&(r.push(Number(o[i])+n+""),i++);else if("C"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)for(let e=0;3>e&&o.length>i&&!isNaN(Number(o[i]));e++)r.push(Number(o[i])+t+""),i++,o.length>i&&!isNaN(Number(o[i]))&&(r.push(Number(o[i])+n+""),i++);else if("Q"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)for(let e=0;2>e&&o.length>i&&!isNaN(Number(o[i]));e++)r.push(Number(o[i])+t+""),i++,o.length>i&&!isNaN(Number(o[i]))&&(r.push(Number(o[i])+n+""),i++);else if("A"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&(r.push(Number(o[i])+t+""),i++),o.length>i&&(r.push(Number(o[i])+n+""),i++);else"Z"===e||"z"===e?(r.push(e),i++):(r.push(o[i]),i++)}return r.join(" ")}const ka=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function wa(e){const[t,n,o]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*n+.114*o>150?"#222":"#fff"}function Aa(e,t,n){const o=t.nodeIDAccessor;return"function"==typeof o?o(e.data)+"":"string"==typeof o&&void 0!==e.data[o]?e.data[o]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+n}function Sa(e){return e?"function"==typeof e?e:t=>{var n;return(null===(n=t.data)||void 0===n?void 0:n[e])||t[e]||t.id}:null}function Oa(e,t,n,o,r){if("horizontal"===r){const r=(e+n)/2;return`M ${e},${t} C ${r},${t} ${r},${o} ${n},${o}`}if("radial"===r){const r=(e+n)/2;return`M ${e},${t} Q ${r},${t} ${r},${(t+o)/2} T ${n},${o}`}{const r=(t+o)/2;return`M ${e},${t} C ${e},${r} ${n},${r} ${n},${o}`}}const Ea={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,n,o){var r;const i=n.__hierarchyRoot;if(!i)return;const a=n.chartType,l=function(e){if(e)return"function"==typeof e?e:t=>t[e]}(n.childrenAccessor),c=n.hierarchySum||(e=>{var t;return null!==(t=e.value)&&void 0!==t?t:0}),u=s.hierarchy(i,l);u.sum(c),u.sort((e,t)=>{var n,o;return(null!==(n=t.value)&&void 0!==n?n:0)-(null!==(o=e.value)&&void 0!==o?o:0)});const[d,h]=o;switch(a){case"tree":!function(e,t,n,o){const r=t.treeOrientation||"vertical",i=s.tree();i.size("horizontal"===r?[o,n]:"radial"===r?[2*Math.PI,Math.min(n,o)/2*.8]:[n,o]),i(e)}(u,n,d,h);break;case"cluster":!function(e,t,n,o){const r=t.treeOrientation||"vertical",i=s.cluster();i.size("horizontal"===r?[o,n]:"radial"===r?[2*Math.PI,Math.min(n,o)/2*.8]:[n,o]),i(e)}(u,n,d,h);break;case"treemap":!function(e,t,n,o){var r,i;const a=null!==(r=t.padding)&&void 0!==r?r:4,l=null!==(i=t.paddingTop)&&void 0!==i?i:0,c=s.treemap().size([n,o]).tile(s.treemapBinary).padding(a);l>0&&c.paddingTop(l),c(e)}(u,n,d,h);break;case"circlepack":!function(e,t,n,o){var r;const i=null!==(r=t.padding)&&void 0!==r?r:4;s.pack().size([n,o]).padding(i)(e)}(u,n,d,h);break;case"partition":!function(e,t,n,o){var r;s.partition().size([n,o]).padding(null!==(r=t.padding)&&void 0!==r?r:1)(e)}(u,n,d,h)}const g=u.descendants();e.length=0,t.length=0;const f=new Map;for(let t=0;g.length>t;t++){const o=g[t],i={id:Aa(o,n,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(r=o.value)&&void 0!==r?r:0,depth:o.depth,data:o.data,createdByFrame:!0};"tree"===a||"cluster"===a?Ma(i,o,n):"treemap"===a||"partition"===a?ja(i,o):"circlepack"===a&&Ca(i,o),i.__hierarchyNode=o,e.push(i),f.set(o,i)}if("tree"===a||"cluster"===a)for(const e of g)if(e.parent){const n=f.get(e.parent),o=f.get(e);n&&o&&t.push({source:n,target:o,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,n,o){const r=n.nodeStyle||(()=>({})),i=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(e,t,n,o,r,i){var a,s,l,c,u;const d=[],h=[],g=[],f=n.treeOrientation||"vertical",p="radial"===f,y=o[0]/2,m=o[1]/2,v="number"==typeof(b=n.nodeSize)?b:5;var b;for(const t of e){let e=t.x,o=t.y;p&&(e+=y,o+=m);const i=r(da(t,"nodeStyle"));let s=i.fill||"#4d430c";n.colorByDepth&&void 0!==t.depth&&(s=ka[t.depth%ka.length]);const l={fill:s,stroke:i.stroke||"#fff",strokeWidth:null!==(a=i.strokeWidth)&&void 0!==a?a:1,opacity:i.opacity};d.push({type:"circle",cx:e,cy:o,r:v,style:l,datum:t,id:t.id,label:t.id,depth:t.depth})}const x=null!==(s=n.edgeOpacity)&&void 0!==s?s:.5;for(const e of t){const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;if(!t||!n)continue;let o=t.x,r=t.y,a=n.x,s=n.y;p&&(o+=y,r+=m,a+=y,s+=m);const u=Oa(o,r,a,s,f),d=i(da(e,"edgeStyle")),g={fill:"none",stroke:d.stroke||"#999",strokeWidth:null!==(l=d.strokeWidth)&&void 0!==l?l:1.5,opacity:null!==(c=d.opacity)&&void 0!==c?c:x};h.push({type:"curved",pathD:u,style:g,datum:e})}if(!1!==n.showLabels){const t=Sa(n.nodeLabel);for(const n of e){const e=t?t(n):n.id;if(!e)continue;let o,r,i,a=n.x,s=n.y;if(p&&(a+=y,s+=m),p){const e=a-y,t=s-m,n=Math.sqrt(e*e+t*t);n>0?(o=a+e/n*10,r=s+t/n*10,i=0>e?"end":"start"):(o=a,r=s-12,i="middle")}else"horizontal"===f?((null===(u=n.data)||void 0===u?void 0:u.children)&&0!==n.data.children.length?(o=a-v-6,i="end"):(o=a+v+6,i="start"),r=s):(o=a,r=s+v+14,i="middle");g.push({x:o,y:r,text:e+"",anchor:i,baseline:"middle",fontSize:11})}}return{sceneNodes:d,sceneEdges:h,labels:g}}(e,t,n,o,r,i);case"treemap":case"partition":return function(e,t,n,o){var r,i;const a=[],s=[];for(const n of e){const e=n.x1-n.x0,i=n.y1-n.y0;if(0>=e||0>=i)continue;const s=o(da(n,"nodeStyle"));let l=s.fill||"#4d430c";t.colorByDepth&&void 0!==n.depth&&(l=ka[n.depth%ka.length]);const c={fill:l,stroke:s.stroke||"#fff",strokeWidth:null!==(r=s.strokeWidth)&&void 0!==r?r:1,opacity:s.opacity};a.push({type:"rect",x:n.x0,y:n.y0,w:e,h:i,style:c,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=Sa(t.nodeLabel),r=t.labelMode||"leaf",a="partition"===t.chartType;for(const l of e){const e=l.x1-l.x0,c=l.y1-l.y0;if(0>=e||0>=c)continue;const u=!((null===(i=l.data)||void 0===i?void 0:i.children)&&l.data.children.length>0);if(!a){if("leaf"===r&&!u)continue;if("parent"===r&&u)continue}const d=n?n(l):l.id;if(!d)continue;if((u?30:40)>e||(u?16:14)>c)continue;let h=o(da(l,"nodeStyle")).fill||"#4d430c";t.colorByDepth&&void 0!==l.depth&&(h=ka[l.depth%ka.length]);const g=wa(h);s.push(u?{x:l.x0+e/2,y:l.y0+c/2,text:d+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,c)/6)),fill:g}:{x:l.x0+4,y:l.y0+12,text:d+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:g})}}return{sceneNodes:a,sceneEdges:[],labels:s}}(e,n,0,r);case"circlepack":return function(e,t,n,o){var r,i,a,s,l;const c=[],u=[];for(const n of e){const e=null!==(r=n.__radius)&&void 0!==r?r:5;if(0>=e)continue;const s=o(da(n,"nodeStyle"));let l=s.fill||"#4d430c";t.colorByDepth&&void 0!==n.depth&&(l=ka[n.depth%ka.length]);const u={fill:l,stroke:s.stroke||"#fff",strokeWidth:null!==(i=s.strokeWidth)&&void 0!==i?i:1,opacity:null!==(a=s.opacity)&&void 0!==a?a:.7};c.push({type:"circle",cx:n.x,cy:n.y,r:e,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=Sa(t.nodeLabel);for(const r of e){const e=null!==(s=r.__radius)&&void 0!==s?s:5,i=n?n(r):r.id;if(!i)continue;if(15>e)continue;const a=!((null===(l=r.data)||void 0===l?void 0:l.children)&&r.data.children.length>0);let c=o(da(r,"nodeStyle")).fill||"#4d430c";if(t.colorByDepth&&void 0!==r.depth&&(c=ka[r.depth%ka.length]),a){const t=wa(c);u.push({x:r.x,y:r.y,text:i+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,e/3)),fill:t})}else u.push({x:r.x,y:r.y-e+14,text:i+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:"#000",stroke:"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:c,sceneEdges:[],labels:u}}(e,n,0,r);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Ma(e,t,n){const o=n.treeOrientation||"vertical";if("radial"===o){const n=t.x,o=t.y;e.x=o*Math.cos(n-Math.PI/2),e.y=o*Math.sin(n-Math.PI/2)}else"horizontal"===o?(e.x=t.y,e.y=t.x):(e.x=t.x,e.y=t.y);e.x0=e.x-5,e.x1=e.x+5,e.y0=e.y-5,e.y1=e.y+5,e.width=10,e.height=10}function ja(e,t){e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.x=(t.x0+t.x1)/2,e.y=(t.y0+t.y1)/2,e.width=t.x1-t.x0,e.height=t.y1-t.y0}function Ca(e,t){var n;const o=null!==(n=t.r)&&void 0!==n?n:0;e.x=t.x,e.y=t.y,e.x0=t.x-o,e.x1=t.x+o,e.y0=t.y-o,e.y1=t.y+o,e.width=2*o,e.height=2*o,e.__radius=o}function Pa(e){const t=e;return t.__orbitState||(t.__orbitState={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()}),t.__orbitState}const La={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,n,o){const r=n.__hierarchyRoot;r&&function(e,t,n,o,r){var i,a;const s=function(e){if("function"==typeof e)return e;const t=e||"children";return e=>e[t]||null}(n.childrenAccessor),c=function(e){if("function"==typeof e)return e;const t=e||"name";return e=>{var n;return(null!==(n=e[t])&&void 0!==n?n:"")+""}}(n.nodeIDAccessor),u=function(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(n.orbitMode),d=null!==(i=n.orbitSize)&&void 0!==i?i:2.95,h=null!==(a=n.orbitEccentricity)&&void 0!==a?a:1,g="number"==typeof d?()=>d:d,f="number"==typeof h?()=>h:h,p=Pa(n);p.metaMap.clear(),o.length=0,r.length=0;const y=new Map;function m(e){var t;const n=null!==(t=y.get(e))&&void 0!==t?t:0;return y.set(e,n+1),0===n?e:`${e}__${n}`}const v=t[0]/2,b=t[1]/2,x=Math.min(t[0],t[1])/2*.85,k=m(c(e));o.push({id:k,x:v,y:b,x0:v,x1:v,y0:b,y1:b,width:0,height:0,value:0,depth:0,data:e}),p.metaMap.set(k,{ring:x,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,n,i,a,d,h,y){const v=s(t);if(!(null==v?void 0:v.length))return;const b=v.length;let x=0,k=0,w=0;for(;b>k;)k+=u[Math.min(w,u.length-1)],w++,x++;let A=0;for(let b=0;x>b;b++){const k=u[Math.min(b,u.length-1)],w=v.slice(A,A+k);if(!w.length)break;const S=(b+1)/x,O={id:n,depth:h,data:t,parentId:n},E=y?d/g(O)*S:d*S,M=l.pie().value(e=>{var t;return(null===(t=s(e))||void 0===t?void 0:t.length)?4:1}).sort(null),j=M(w),C=f(O);for(let t=0;w.length>t;t++){const s=(j[t].startAngle+j[t].endAngle)/2,l=w[t],u=m(c(l)),d=i+E*Math.sin(s),g=a+E*Math.cos(s)*C;o.push({id:u,x:d,y:g,x0:d,x1:d,y0:g,y1:g,width:0,height:0,value:0,depth:h,data:l}),p.metaMap.set(u,{ring:E,angle:s,depth:h,parentId:n,eccentricity:C}),r.push({source:n,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:u}}),e(l,u,d,g,E,h+1,!0)}A+=k}}(e,k,v,b,x,1,!1)}(r,o,n,e,t)},buildScene(e,t,n,o){var r,i,a,s,l;const c=n.nodeStyle,u=n.nodeSize,d="number"==typeof u?()=>u:"function"==typeof u?u:()=>6,h=[],g=[],f=[];if(!1!==n.orbitShowRings){const t=Pa(n),o=new Map;for(const t of e)o.set(t.id,t);const r=new Map;for(const[,e]of t.metaMap){if(!e.parentId)continue;const t=o.get(e.parentId);if(!t)continue;const n=`${e.parentId}:${e.ring}`;r.has(n)||r.set(n,{parentX:t.x,parentY:t.y,ring:e.ring,ecc:e.eccentricity})}const i=48,a={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:e,parentY:t,ring:n,ecc:o}]of r)for(let r=0;i>r;r++){const s=r/i*Math.PI*2,l=(r+1)/i*Math.PI*2;g.push({type:"line",x1:e+n*Math.sin(s),y1:t+n*Math.cos(s)*o,x2:e+n*Math.sin(l),y2:t+n*Math.cos(l)*o,style:a,datum:null})}}for(const t of e){if(null==t.x||null==t.y)continue;const e=d(da(t,"nodeSize")),n=c?c(da(t,"nodeStyle")):{},o={fill:n.fill||"#6366f1",stroke:n.stroke||"#fff",strokeWidth:null!==(r=n.strokeWidth)&&void 0!==r?r:1,opacity:null!==(i=n.opacity)&&void 0!==i?i:0===(null!==(a=t.depth)&&void 0!==a?a:0)?1:.85};h.push({type:"circle",cx:t.x,cy:t.y,r:e,style:o,datum:t,id:t.id,label:t.id,depth:t.depth})}const p=new Map;for(const t of e)p.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:p.get(e.source),n="object"==typeof e.target?e.target:p.get(e.target);t&&n&&(null!=t.x&&null!=n.x&&g.push({type:"line",x1:t.x,y1:t.y,x2:n.x,y2:n.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:e}))}if(n.showLabels){const t=n.nodeLabel;for(const n of e){const e=d(da(n,"nodeSize"));if(4>=e)continue;const o="function"==typeof t?t(n):t&&null!==(l=null===(s=n.data)||void 0===s?void 0:s[t])&&void 0!==l?l:n.id;f.push({x:n.x,y:n.y+e+12,text:o+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:h,sceneEdges:g,labels:f}},tick:(e,t,n,o,r)=>!1!==n.orbitAnimated&&(function(e,t){var n,o;const r=Pa(t),i=null!==(n=t.orbitSpeed)&&void 0!==n?n:.25,a=null!==(o=t.orbitRevolution)&&void 0!==o?o:function(e){switch(e){case"decay":return e=>{var t;return Math.pow(.6,null!==(t=e.depth)&&void 0!==t?t:0)};case"alternate":return e=>{var t;const n=null!==(t=e.depth)&&void 0!==t?t:0;return(n%2==0?1:-1)/(n+1)};default:return e=>{var t;return 1/((null!==(t=e.depth)&&void 0!==t?t:0)+1)}}}(t.orbitRevolutionStyle),s=(("undefined"!=typeof performance?performance.now():Date.now())-r.startTime)/1e3,l=i*(Math.PI/6),c=new Map;for(const t of e)c.set(t.id,t);for(const t of e){const e=r.metaMap.get(t.id);if(!e||!e.parentId)continue;const n=c.get(e.parentId);if(!n)continue;const o=e.angle+s*l*a({id:t.id,depth:e.depth,data:t.data,parentId:e.parentId});t.x=n.x+e.ring*Math.sin(o),t.y=n.y+e.ring*Math.cos(o)*e.eccentricity,t.x0=t.x,t.x1=t.x,t.y0=t.y,t.y1=t.y}}(e,n),!0)},_a={sankey:ga,force:fa,chord:ba,tree:Ea,cluster:Ea,treemap:Ea,circlepack:Ea,partition:Ea,orbit:La};function Ba(e){return _a[e]}class Ta{constructor(e){this.nodes=new Map,this.edges=new Map,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.particlePool=null,this.transition=null,this.lastIngestTime=0,this.nodeTimestamps=new Map,this.edgeTimestamps=new Map,this._decaySortedNodes=null,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this._lastPositionSnapshot=null,this.config=e,this.tensionConfig=Object.assign(Object.assign({},mi),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&(this.particlePool=new bi(2e3))}updateConfig(e){const t=this.config;t.__orbitState&&(e.__orbitState=t.__orbitState),t.__hierarchyRoot&&(e.__hierarchyRoot=t.__hierarchyRoot),this.config=e,this.tensionConfig=Object.assign(Object.assign({},mi),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&!this.particlePool&&(this.particlePool=new bi(2e3))}ingestHierarchy(e,t){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this.config.__hierarchyRoot=e,this.runLayout(t)}ingestBounded(e,t,n){const{nodeIDAccessor:o="id",sourceAccessor:r="source",targetAccessor:i="target",valueAccessor:a="value"}=this.config,s="function"==typeof o?o:e=>e[o],l="function"==typeof r?r:e=>e[r],c="function"==typeof i?i:e=>e[i],u="function"==typeof a?a:e=>{var t;return null!==(t=e[a])&&void 0!==t?t:1};this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const t of e){const e=s(t)+"";this.nodes.set(e,Object.assign(Object.assign({},Na(e)),{data:t}))}for(let e=0;t.length>e;e++){const n=t[e],o=l(n)+"",r=c(n)+"",i=Number(u(n))||1;this.nodes.has(o)||this.nodes.set(o,Object.assign(Object.assign({},Na(o)),{data:n})),this.nodes.has(r)||this.nodes.set(r,Object.assign(Object.assign({},Na(r)),{data:n}));const a=`${o}\0${r}\0${e}`;this.edges.set(a,{source:o,target:r,value:i,y0:0,y1:0,sankeyWidth:0,data:n,_edgeKey:a})}this.runLayout(n)}edgeKey(e,t){return`${e}\0${t}`}ingestEdge(e){const{source:t,target:n,value:o}=e,r=0===this.nodes.size;let i=!1;const a="undefined"!=typeof performance?performance.now():Date.now();this.lastIngestTime=a,this._decaySortedNodes=null,this.nodes.has(t)||(this.nodes.set(t,Na(t)),this.nodeTimestamps.set(t,a),this.tension+=this.tensionConfig.newNode,i=!0),this.nodes.has(n)||(this.nodes.set(n,Na(n)),this.nodeTimestamps.set(n,a),this.tension+=this.tensionConfig.newNode,i=!0);const s=this.edgeKey(t,n),l=this.edges.get(s);let c=!1;return l?(l.value+=o,this.edgeTimestamps.set(s,a),this.tension+=this.tensionConfig.weightChange,c=!0):(this.edges.set(s,{source:t,target:n,value:o,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(s,a),this.tension+=this.tensionConfig.newEdge,i=!0),r||i||c||this.tension>=this.tensionConfig.threshold}runLayout(e){var t,n,o,r,i,a;const s=Ba(this.config.chartType);if(!s)return;let l=Array.from(this.nodes.values()),c=Array.from(this.edges.values());if(0===l.length&&!s.hierarchical)return;if(this.prepareForRelayout(),s.supportsStreaming&&!s.hierarchical){const e=new Map;for(const s of l)if(void 0!==s._prevX0){const l=(null!==(t=s._prevX1)&&void 0!==t?t:0)-(null!==(n=s._prevX0)&&void 0!==n?n:0),c=(null!==(o=s._prevY1)&&void 0!==o?o:0)-(null!==(r=s._prevY0)&&void 0!==r?r:0);e.set(s.id,{x:(null!==(i=s._prevX0)&&void 0!==i?i:0)+l/2,y:(null!==(a=s._prevY0)&&void 0!==a?a:0)+c/2})}else 0===s.x&&0===s.y||e.set(s.id,{x:s.x,y:s.y});if(this._lastPositionSnapshot)for(const[t,n]of this._lastPositionSnapshot)e.has(t)||e.set(t,n);this.config.__previousPositions=e.size>0?e:void 0}if(s.computeLayout(l,c,this.config,e),this.config.__previousPositions=void 0,s.hierarchical&&l.length>0){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const e of l)this.nodes.set(e.id,e);for(let e=0;c.length>e;e++){const t=c[e],n=t._edgeKey||`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}\0${e}`;t._edgeKey=n,this.edges.set(n,t)}}this.finalizeLayout();const u=new Map;for(const e of this.nodes.values())0===e.x&&0===e.y||u.set(e.id,{x:e.x,y:e.y});this._lastPositionSnapshot=u,this.saveTargetPositions(),l.some(e=>void 0!==e._prevX0&&(0!==e._prevX0||0!==e._prevX1||0!==e._prevY0||0!==e._prevY1))&&this.tensionConfig.transitionDuration>0&&(this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:this.tensionConfig.transitionDuration});const d=new Set(this.nodes.keys()),h=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const e of d)this.previousNodeIds.has(e)||this.addedNodes.add(e);for(const e of this.previousNodeIds)d.has(e)||this.removedNodes.add(e);for(const e of h)this.previousEdgeKeys.has(e)||this.addedEdges.add(e);for(const e of this.previousEdgeKeys)h.has(e)||this.removedEdges.add(e);(this.addedNodes.size>0||this.removedNodes.size>0||this.addedEdges.size>0||this.removedEdges.size>0)&&(this.lastTopologyChangeTime="undefined"!=typeof performance?performance.now():Date.now()),this.previousNodeIds=d,this.previousEdgeKeys=h,this.layoutVersion++}buildScene(e){const t=Ba(this.config.chartType);if(!t)return;const n=Array.from(this.nodes.values()),o=Array.from(this.edges.values()),{sceneNodes:r,sceneEdges:i,labels:a}=t.buildScene(n,o,this.config,e);this.sceneNodes=r,this.sceneEdges=i,this.labels=a}get isAnimating(){const e=Ba(this.config.chartType);return!!(null==e?void 0:e.supportsAnimation)&&!1!==this.config.orbitAnimated}tickAnimation(e,t){const n=Ba(this.config.chartType);if(!(null==n?void 0:n.tick))return!1;const o=Array.from(this.nodes.values()),r=Array.from(this.edges.values());return n.tick(o,r,this.config,e,t)}advanceTransition(e){if(!this.transition)return!1;const t=R(e,this.transition),n=H(t);for(const e of this.nodes.values())void 0===e._targetX0||void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=W(e._prevX0,e._targetX0,n),e.x1=W(e._prevX1,e._targetX1,n),e.y0=W(e._prevY0,e._targetY0,n),e.y1=W(e._prevY1,e._targetY1,n));for(const e of this.edges.values())void 0!==e._targetY0&&void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=W(e._prevY0,e._targetY0,n),e.y1=W(e._prevY1,e._targetY1,n),e.sankeyWidth=W(e._prevSankeyWidth,e._targetSankeyWidth,n));return this.rebuildAllBeziers(),1>t||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){for(const e of this.nodes.values())e._prevX0=e.x0,e._prevX1=e.x1,e._prevY0=e.y0,e._prevY1=e.y1;for(const e of this.edges.values())e._prevY0=e.y0,e._prevY1=e.y1,e._prevSankeyWidth=e.sankeyWidth}finalizeLayout(){const e="vertical"===this.config.orientation?"down":"right";for(const e of this.nodes.values())if(0!==e.x0||0!==e.x1||0!==e.y0||0!==e.y1)e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;else{const t=5;e.x0=e.x-t,e.x1=e.x+t,e.y0=e.y-t,e.y1=e.y+t,e.width=2*t,e.height=2*t}for(const t of this.edges.values())t.direction=e,this.updateEdgeBezier(t);this.tension=0}saveTargetPositions(){for(const e of this.nodes.values())e._targetX0=e.x0,e._targetX1=e.x1,e._targetY0=e.y0,e._targetY1=e.y1;for(const e of this.edges.values())e._targetY0=e.y0,e._targetY1=e.y1,e._targetSankeyWidth=e.sankeyWidth}restorePreviousPositions(){for(const e of this.nodes.values())void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=e._prevX0,e.x1=e._prevX1,e.y0=e._prevY0,e.y1=e._prevY1);for(const e of this.edges.values())void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=e._prevY0,e.y1=e._prevY1,e.sankeyWidth=e._prevSankeyWidth);this.rebuildAllBeziers()}snapToTargets(){for(const e of this.nodes.values())void 0!==e._targetX0&&(e.x0=e._targetX0,e.x1=e._targetX1,e.y0=e._targetY0,e.y1=e._targetY1);for(const e of this.edges.values())void 0!==e._targetY0&&(e.y0=e._targetY0,e.y1=e._targetY1,e.sankeyWidth=e._targetSankeyWidth);this.rebuildAllBeziers()}updateEdgeBezier(e){const t="string"==typeof e.source?this.nodes.get(e.source):e.source,n="string"==typeof e.target?this.nodes.get(e.target):e.target;t&&n&&(e.bezier=e.circular&&e.circularPathData?this.buildCircularBezier(e):this.buildStandardBezier(e,t,n))}buildStandardBezier(e,t,n){const o=(e.sankeyWidth||1)/2;if("down"===e.direction){const r=t.x1,i=n.x0,a=u.interpolateNumber(r,i);return{circular:!1,points:[{x:e.y0,y:r},{x:e.y0,y:a(.5)},{x:e.y1,y:a(.5)},{x:e.y1,y:i}],halfWidth:o}}const r=t.x1,i=n.x0,a=u.interpolateNumber(r,i);return{circular:!1,points:[{x:r,y:e.y0},{x:a(.5),y:e.y0},{x:a(.5),y:e.y1},{x:i,y:e.y1}],halfWidth:o}}buildCircularBezier(e){const t=(e._circularWidth||e.sankeyWidth||1)/2,n=e.circularPathData;if(e._circularStub){const e=Math.max(15,Math.min(40,.33*(n.rightFullExtent-n.sourceX))),o=Math.max(15,Math.min(40,.33*(n.targetX-n.leftFullExtent)));return{circular:!0,segments:[[{x:n.sourceX,y:n.sourceY},{x:n.sourceX+.33*e,y:n.sourceY},{x:n.sourceX+.66*e,y:n.sourceY},{x:n.sourceX+e,y:n.sourceY}],[{x:n.targetX-o,y:n.targetY},{x:n.targetX-.66*o,y:n.targetY},{x:n.targetX-.33*o,y:n.targetY},{x:n.targetX,y:n.targetY}]],halfWidth:t}}let o;o="down"===e.direction?[{x:n.sourceY,y:n.sourceX},{x:n.sourceY,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.leftFullExtent},{x:n.targetY,y:n.leftFullExtent},{x:n.targetY,y:n.targetX}]:[{x:n.sourceX,y:n.sourceY},{x:n.rightFullExtent,y:n.sourceY},{x:n.rightFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.targetY},{x:n.targetX,y:n.targetY}];const r=[];for(let e=0;o.length-1>e;e++){const t=o[e],n=o[e+1],i=n.x-t.x,a=n.y-t.y;r.push([t,{x:t.x+i/3,y:t.y+a/3},{x:t.x+2*i/3,y:t.y+2*a/3},n])}return{circular:!0,segments:r,halfWidth:t}}rebuildAllBeziers(){for(const e of this.nodes.values())e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;for(const e of this.edges.values())this.updateEdgeBezier(e)}applyPulse(e){var t,n,o,r,i;const a=this.config.pulse;if(!a)return;const s=null!==(t=a.duration)&&void 0!==t?t:500,l=null!==(n=a.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",c=null!==(o=a.glowRadius)&&void 0!==o?o:4;for(const t of this.sceneNodes){const n=t.id;if(!n)continue;const o=this.nodeTimestamps.get(n);if(!o)continue;const r=e-o;s>r&&(t._pulseIntensity=1-r/s,t._pulseColor=l,t._pulseGlowRadius=c)}for(const t of this.sceneEdges){const n=t.datum;if(!n)continue;const o="object"==typeof n.source?null===(r=n.source)||void 0===r?void 0:r.id:n.source,a="object"==typeof n.target?null===(i=n.target)||void 0===i?void 0:i.id:n.target;if(!o||!a)continue;const c=this.edgeTimestamps.get(`${o}\0${a}`);if(!c)continue;const u=e-c;s>u&&(t._pulseIntensity=1-u/s,t._pulseColor=l)}}applyDecay(){var e,t,n,o,r;const i=this.config.decay;if(!i)return;const a=null!==(e=i.minOpacity)&&void 0!==e?e:.1,s=this.nodeTimestamps.size;if(1>=s)return;this._decaySortedNodes||(this._decaySortedNodes=Array.from(this.nodeTimestamps.entries()).sort((e,t)=>e[1]-t[1]));const l=this._decaySortedNodes,c=new Map;for(let e=0;l.length>e;e++)c.set(l[e][0],e);for(const e of this.sceneNodes){const l=e.id;if(!l)continue;const u=c.get(l);if(void 0===u)continue;const d=s-1-u;let h;switch(i.type){case"linear":h=a+(1-d/(s-1))*(1-a);break;case"exponential":{const e=null!==(t=i.halfLife)&&void 0!==t?t:s/2;h=a+Math.pow(.5,d/e)*(1-a);break}case"step":h=(null!==(n=i.stepThreshold)&&void 0!==n?n:.5*s)>d?1:a;break;default:h=1}const g=null!==(r=null===(o=e.style)||void 0===o?void 0:o.opacity)&&void 0!==r?r:1;e.style=Object.assign(Object.assign({},e.style),{opacity:g*h})}}applyTopologyDiff(e){var t;if(0===this.addedNodes.size)return;const n=e-this.lastTopologyChangeTime;if(n>=2e3)return;const o=1-n/2e3;for(const e of this.sceneNodes){const n=e.id;n&&this.addedNodes.has(n)&&(e._pulseIntensity=Math.max(null!==(t=e._pulseIntensity)&&void 0!==t?t:0,o),e._pulseColor="rgba(34, 197, 94, 0.7)",e._pulseGlowRadius=8)}}get hasActiveTopologyDiff(){return 0!==this.addedNodes.size&&2e3>("undefined"!=typeof performance?performance.now():Date.now())-this.lastTopologyChangeTime}applyThresholds(e){var t,n;const o=this.config.thresholds;if(!o)return;const r=null!==(t=o.warningColor)&&void 0!==t?t:"#f59e0b",i=null!==(n=o.criticalColor)&&void 0!==n?n:"#ef4444",a=!1!==o.pulse;for(const t of this.sceneNodes){const n=t.id;if(!n)continue;const s=this.nodes.get(n);if(!s)continue;const l=o.metric(s);let c=null;void 0===o.critical||o.critical>l?void 0===o.warning||o.warning>l||(c=r):c=i,c&&(t.style=Object.assign(Object.assign({},t.style),{fill:c}),a&&(t._pulseIntensity=.6+.4*Math.sin(e/300),t._pulseColor=c,t._pulseGlowRadius=6))}}get hasActiveThresholds(){const e=this.config.thresholds;if(!e)return!1;for(const t of this.nodes.values()){const n=e.metric(t);if(void 0!==e.warning&&n>=e.warning||void 0!==e.critical&&n>=e.critical)return!0}return!1}get hasActivePulses(){var e;const t=this.config.pulse;if(!t||0===this.lastIngestTime)return!1;const n="undefined"!=typeof performance?performance.now():Date.now();return(null!==(e=t.duration)&&void 0!==e?e:500)>n-this.lastIngestTime}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}updateNode(e,t){var n;const o=this.nodes.get(e);if(!o)return null;const r=o.data?Object.assign({},o.data):{};return o.data=t(null!==(n=o.data)&&void 0!==n?n:{}),this.layoutVersion++,r}updateEdge(e,t,n){var o;const r=this.config.valueAccessor,i="function"==typeof r?r:r?e=>e[r]:e=>e.value,a=[];for(const[,r]of this.edges)if(("string"==typeof r.source?r.source:r.source.id)===e&&("string"==typeof r.target?r.target:r.target.id)===t){a.push(r.data?Object.assign({},r.data):{}),r.data=n(null!==(o=r.data)&&void 0!==o?o:{});const e=i(r.data);null!=e&&(r.value=Number(e))}return a.length>0&&this.layoutVersion++,a}removeNode(e){if(!this.nodes.has(e))return!1;this.nodes.delete(e),this.nodeTimestamps.delete(e);for(const[t,n]of this.edges)("string"==typeof n.source?n.source:n.source.id)!==e&&("string"==typeof n.target?n.target:n.target.id)!==e||(this.edges.delete(t),this.edgeTimestamps.delete(t));return this.layoutVersion++,!0}removeEdge(e,t){const n=[];for(const[o,r]of this.edges)("string"==typeof r.source?r.source:r.source.id)===e&&("string"==typeof r.target?r.target:r.target.id)===t&&n.push(o);for(const e of n)this.edges.delete(e),this.edgeTimestamps.delete(e);return n.length>0&&this.layoutVersion++,n.length>0}clear(){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.transition=null,this.lastIngestTime=0,this._lastPositionSnapshot=null,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.particlePool&&this.particlePool.clear()}}function Na(e){return{id:e,x0:0,x1:0,y0:0,y1:0,x:0,y:0,width:0,height:0,value:0,createdByFrame:!0}}function Da(e,t,n,o,r=30){let i=null,a=r,s=1/0;for(const t of e){const e=Ia(t,n,o,r);if(e)if("rect"===t.type){const n=t.w*t.h;s>n&&(i=e,s=n)}else a>e.distance&&(i=e,a=e.distance)}if(i)return i;for(const e of t){const t=Fa(e,n,o);t&&a>t.distance&&(i=t,a=t.distance)}return i}function Ia(e,t,n,o=30){switch(e.type){case"circle":return function(e,t,n,o=30){const r=t-e.cx,i=n-e.cy,a=Math.sqrt(r*r+i*i);return a>ee(e.r,o)?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:a}}(e,t,n,o);case"rect":return function(e,t,n){const o=J(t,n,e);return o.hit?{type:"node",datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}(e,t,n);case"arc":return function(e,t,n){const o=t-e.cx,r=n-e.cy,i=Math.sqrt(o*o+r*r);if(e.innerR-2>i||i>e.outerR+2)return null;const a=oe(Math.atan2(r,o)),s=oe(e.startAngle),l=oe(e.endAngle);if(s>l?a>=s||l>=a:a>=s&&l>=a){const t=(e.startAngle+e.endAngle)/2,n=(e.innerR+e.outerR)/2;return{type:"node",datum:e.datum,x:e.cx+n*Math.cos(t),y:e.cy+n*Math.sin(t),distance:0}}return null}(e,t,n);default:return null}}let Ha=null,Ra=null;function Wa(){return Ra||(Ha=document.createElement("canvas"),Ha.width=1,Ha.height=1,Ra=Ha.getContext("2d")),Ra}function Fa(e,t,n){switch(e.type){case"bezier":return function(e,t,n){var o,r;if(!e.pathD)return null;try{const i=new Path2D(e.pathD),a=Wa();if(!a)return null;if(a.isPointInPath(i,t,n)){const i="object"==typeof(null===(o=e.datum)||void 0===o?void 0:o.source)?e.datum.source:null,a="object"==typeof(null===(r=e.datum)||void 0===r?void 0:r.target)?e.datum.target:null;return{type:"edge",datum:e.datum,x:i&&a?(i.x1+a.x0)/2:t,y:e.datum?(e.datum.y0+e.datum.y1)/2:n,distance:0}}const s=a.lineWidth;a.lineWidth=10;const l=a.isPointInStroke(i,t,n);if(a.lineWidth=s,l)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}catch(e){}return null}(e,t,n);case"line":return function(e,t,n){const o=e.x2-e.x1,r=e.y2-e.y1,i=o*o+r*r;if(0===i)return null;let a=((t-e.x1)*o+(n-e.y1)*r)/i;a=Math.max(0,Math.min(1,a));const s=e.x1+a*o,l=e.y1+a*r,c=Math.sqrt(Math.pow(t-s,2)+Math.pow(n-l,2));return c>5?null:{type:"edge",datum:e.datum,x:s,y:l,distance:c}}(e,t,n);case"ribbon":case"curved":return function(e,t,n){if(!e.pathD)return null;try{const o=new Path2D(e.pathD),r=Wa();if(!r)return null;if(r.isPointInPath(o,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0};const i=r.lineWidth;r.lineWidth=10;const a=r.isPointInStroke(o,t,n);if(r.lineWidth=i,a)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}catch(e){}return null}(e,t,n);default:return null}}function za(e){const{width:t,height:n,totalWidth:o,totalHeight:r,margin:i,labels:a,title:s,legend:l,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:d,legendIsolatedCategories:h,legendPosition:g="right",foregroundGraphics:f,sceneNodes:y,annotations:m,svgAnnotationRules:v}=e;return p.createElement(p.Fragment,null,p.createElement("svg",{role:"img",width:o,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},p.createElement("title",null,"string"==typeof s?s:"Network Chart"),p.createElement("desc",null,"string"==typeof s?s+" — network data visualization":"Network data visualization"),p.createElement("g",{transform:`translate(${i.left},${i.top})`},a.map((e,t)=>p.createElement("text",{key:"label-"+t,x:e.x,y:e.y,textAnchor:e.anchor||"start",dominantBaseline:e.baseline||"middle",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"currentColor",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,style:{pointerEvents:"none"}},e.text)),m&&m.filter(e=>"widget"!==e.type).map((e,o)=>{if(v){const r=v(e,o,{width:t,height:n,sceneNodes:y});if(r)return p.createElement(p.Fragment,{key:"annotation-"+o},r)}return null}),f),s&&"string"==typeof s?p.createElement("text",{x:o/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor"},s):s?p.createElement("foreignObject",{x:0,y:0,width:o,height:i.top},s):null,Me({legend:l,totalWidth:o,totalHeight:r,margin:i,legendPosition:g,title:s,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:d,legendIsolatedCategories:h})),null==m?void 0:m.filter(e=>"widget"===e.type&&e.nodeId&&y).map((e,t)=>{var n,o,r,a,s,l,c,u,d;const h=y.find(t=>{var n,o,r,i,a;return t.id===e.nodeId||(null===(n=t.datum)||void 0===n?void 0:n.id)===e.nodeId||(null===(r=null===(o=t.datum)||void 0===o?void 0:o.data)||void 0===r?void 0:r.id)===e.nodeId||(null===(a=null===(i=t.datum)||void 0===i?void 0:i.data)||void 0===a?void 0:a.name)===e.nodeId});if(!h)return null;const g=i.left+(null!==(n=h.cx)&&void 0!==n?n:null!=h.x&&null!=h.w?h.x+h.w/2:null!==(o=h.x)&&void 0!==o?o:0),f=i.top+(null!==(r=h.cy)&&void 0!==r?r:null!=h.y&&null!=h.h?h.y+h.h/2:null!==(a=h.y)&&void 0!==a?a:0),m=null!==(s=e.dx)&&void 0!==s?s:0,v=null!==(l=e.dy)&&void 0!==l?l:-16,b=null!==(c=e.width)&&void 0!==c?c:32,x=null!==(u=e.height)&&void 0!==u?u:32,k=null!==(d=e.content)&&void 0!==d?d:p.createElement("span",{style:{fontSize:18,cursor:"default"}},"ℹ️");return p.createElement("div",{key:"widget-"+t,style:{position:"absolute",left:g+m-b/2,top:f+v-x/2,width:b,height:x,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:5}},k)}))}function $a(e,t){var n,o,r,i,a,s;if(!t.pathD)return;e.save();const l=new Path2D(t.pathD);if(t.style.fill&&"none"!==t.style.fill){const a=t._gradient;if(a){const r=e.createLinearGradient(a.x0,0,a.x1,0),i=null!==(o=null!==(n=t.style.fillOpacity)&&void 0!==n?n:t.style.opacity)&&void 0!==o?o:.5,s="string"==typeof t.style.fill?t.style.fill:"#999";r.addColorStop(0,1===a.from?s:"transparent"),r.addColorStop(1,1===a.to?s:"transparent"),e.fillStyle=r,e.globalAlpha=i}else e.fillStyle=t.style.fill,e.globalAlpha=null!==(i=null!==(r=t.style.fillOpacity)&&void 0!==r?r:t.style.opacity)&&void 0!==i?i:.5;e.fill(l)}t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(a=t.style.strokeWidth)&&void 0!==a?a:.5,e.globalAlpha=.5*(null!==(s=t.style.opacity)&&void 0!==s?s:1),e.stroke(l)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.2*t._pulseIntensity,e.fill(l)),e.restore()}function Ga(e,t){var n,o;e.save(),e.strokeStyle=t.style.stroke||"#999",e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.strokeDasharray&&e.setLineDash(t.style.strokeDasharray.split(/[\s,]+/).map(Number)),e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke(),t._pulseIntensity&&t._pulseIntensity>0&&(e.setLineDash([]),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=(null!==(o=t.style.strokeWidth)&&void 0!==o?o:1)+3*t._pulseIntensity,e.globalAlpha=.4*t._pulseIntensity,e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke()),e.restore()}function Ya(e,t){var n,o,r,i;if(!t.pathD)return;e.save();const a=new Path2D(t.pathD);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=t.style.fill,e.globalAlpha=null!==(o=null!==(n=t.style.fillOpacity)&&void 0!==n?n:t.style.opacity)&&void 0!==o?o:.5,e.fill(a)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(r=t.style.strokeWidth)&&void 0!==r?r:.5,e.globalAlpha=.3*(null!==(i=t.style.opacity)&&void 0!==i?i:1),e.stroke(a)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.25*t._pulseIntensity,e.fill(a)),e.restore()}function qa(e,t){var n,o;if(!t.pathD)return;e.save();const r=new Path2D(t.pathD);e.strokeStyle=t.style.stroke||"#999",e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.stroke(r),t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=t.style.fill,e.globalAlpha=null!==(o=t.style.fillOpacity)&&void 0!==o?o:.1,e.fill(r)),e.restore()}za.displayName="NetworkSVGOverlay";const Xa={top:20,right:80,bottom:20,left:80},Va={top:40,right:40,bottom:40,left:40},Ua=new Set(["chord","force","circlepack","orbit"]),Ka=[800,600],Qa={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,lineHeight:1.5,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function Za({data:e}){var t,n,o,r,i,a;if("edge"===e.type){const t=e.data;return p.createElement("div",{className:"semiotic-tooltip",style:Qa},p.createElement("div",{style:{fontWeight:600}},"object"==typeof t.source?t.source.id:t.source," → ","object"==typeof t.target?t.target.id:t.target),null!=t.value&&p.createElement("div",{style:{marginTop:4,opacity:.8}},"Value:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""))}const s=e.data,l=null==s?void 0:s.__hierarchyNode;if(l){const e=[];let i=l;for(;i;){const a=null!==(r=null!==(n=null===(t=i.data)||void 0===t?void 0:t.name)&&void 0!==n?n:null===(o=i.data)||void 0===o?void 0:o.id)&&void 0!==r?r:s.id;null!=a&&e.unshift(a+""),i=i.parent}e.length>1&&e.shift();const a=e.length-1;return p.createElement("div",{className:"semiotic-tooltip",style:Qa},p.createElement("div",null,e.map((e,t)=>p.createElement("span",{key:t},t>0&&p.createElement("span",{style:{margin:"0 3px",opacity:.5}}," → "),t===a?p.createElement("strong",null,e):p.createElement("span",{style:{opacity:.7}},e)))),null!=s.value&&s.value>0&&p.createElement("div",{style:{marginTop:4,opacity:.8}},"number"==typeof s.value?s.value.toLocaleString():s.value+""))}const c=((null===(i=s.sourceLinks)||void 0===i?void 0:i.length)||0)+((null===(a=s.targetLinks)||void 0===a?void 0:a.length)||0),u=(s.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(s.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0);return p.createElement("div",{className:"semiotic-tooltip",style:Qa},p.createElement("div",{style:{fontWeight:600}},s.id),null!=s.value&&s.value>0&&p.createElement("div",{style:{marginTop:4,opacity:.8}},"Total:"," ","number"==typeof s.value?s.value.toLocaleString():s.value+""),c>0&&p.createElement("div",{style:{marginTop:4,opacity:.8}},"Connections: ",c,u!==c&&` (weighted: ${u.toLocaleString()})`))}const Ja=e.forwardRef(function(t,n){var o,r,i,a,s,c,u,d,h,g,f,y,m,v;const{chartType:b,nodes:x,edges:k,data:w,initialEdges:A,nodeIDAccessor:S="id",sourceAccessor:O="source",targetAccessor:E="target",valueAccessor:M="value",childrenAccessor:j,hierarchySum:P,orientation:L="horizontal",nodeAlign:_="justify",nodePaddingRatio:B=.05,nodeWidth:T=15,iterations:N=300,forceStrength:D=.1,padAngle:I=.01,groupWidth:H=20,sortGroups:R,edgeSort:W,treeOrientation:F="vertical",edgeType:z="curve",padding:$,paddingTop:G,tensionConfig:Y,showParticles:q=!1,particleStyle:X,nodeStyle:V,edgeStyle:U,colorBy:K,colorScheme:Q="category10",edgeColorBy:Z="source",edgeOpacity:J=.5,colorByDepth:ee=!1,nodeSize:te=8,nodeSizeRange:ne=[5,20],nodeLabel:oe,showLabels:re=!0,labelMode:ie,size:ae=Ka,responsiveWidth:se,responsiveHeight:le,margin:ce,className:ue,background:de,enableHover:he=!0,tooltipContent:ge,customHoverBehavior:me,customClickBehavior:ve,onObservation:ke,chartId:we,onTopologyChange:Ae,annotations:Se,svgAnnotationRules:Oe,legend:Ee,legendPosition:Me,legendHoverBehavior:je,legendClickBehavior:Ce,legendHighlightedCategory:Pe,legendIsolatedCategories:Le,title:_e,foregroundGraphics:Be,backgroundGraphics:Te,decay:Ne,pulse:De,staleness:Ie,thresholds:He,accessibleTable:Re=!0,description:We,summary:Fe,orbitMode:ze,orbitSize:$e,orbitSpeed:Ge,orbitRevolution:Ye,orbitRevolutionStyle:qe,orbitEccentricity:Xe,orbitShowRings:Ve,orbitAnimated:Ue}=t,Ke=Mt(),Qe=e.useRef(Ke);Qe.current=Ke;const Ze="semiotic-table-"+p.useId(),Je=Ua.has(b)?Va:Xa,[et,tt]=be(ae,se,le),rt=Object.assign(Object.assign({},Je),ce),it=tt[0]-rt.left-rt.right,at=tt[1]-rt.top-rt.bottom,st="function"==typeof Be?Be({size:tt,margin:rt}):Be,lt=e.useMemo(()=>Object.assign(Object.assign({},mi),Y),[Y]),ut=e.useMemo(()=>Object.assign(Object.assign({},vi),X),[X]),dt=e.useMemo(()=>({chartType:b,nodeIDAccessor:S,sourceAccessor:O,targetAccessor:E,valueAccessor:M,childrenAccessor:j,hierarchySum:P,orientation:L,nodeAlign:_,nodePaddingRatio:B,nodeWidth:T,iterations:N,forceStrength:D,padAngle:I,groupWidth:H,sortGroups:R,edgeSort:W,treeOrientation:F,edgeType:z,padding:$,paddingTop:G,tensionConfig:lt,showParticles:q,particleStyle:ut,nodeStyle:V,edgeStyle:U,nodeLabel:oe,showLabels:re,labelMode:ie,colorBy:K,colorScheme:Q,edgeColorBy:Z,edgeOpacity:J,colorByDepth:ee,nodeSize:te,nodeSizeRange:ne,decay:Ne,pulse:De,staleness:Ie,thresholds:He,orbitMode:ze,orbitSize:$e,orbitSpeed:Ge,orbitRevolution:Ye,orbitRevolutionStyle:qe,orbitEccentricity:Xe,orbitShowRings:Ve,orbitAnimated:Ue}),[b,S,O,E,M,j,P,L,_,B,T,N,D,I,H,R,W,F,z,$,G,lt,q,ut,V,U,oe,re,ie,K,Q,Z,J,ee,te,ne,Ne,De,Ie,He,ze,$e,Ge,Ye,qe,Xe,Ve,Ue]),ht=e.useRef(null),gt=e.useRef(0),ft=e.useRef(0),pt=e.useRef(!0),yt=Tt(e=>e.theme),mt=e.useRef(()=>{}),vt=e.useRef(null);vt.current||(vt.current=new Ta(dt));const[At,Et]=e.useState(null),[jt,Ct]=e.useState(0),[Pt,Lt]=e.useState(0),[_t,Bt]=e.useState(!1),It=e.useRef(null),Ht=e.useRef(new Map),Rt=e.useRef(0),Wt=e.useCallback(e=>{if("function"==typeof K)return K(e)+"";if("string"==typeof K&&e.data){const t=e.data[K];if(void 0!==t){if(!Ht.current.has(t+"")){const e=Array.isArray(Q)?Q:C;Ht.current.set(t+"",e[Rt.current++%e.length])}return Ht.current.get(t+"")}}if(Ht.current.has(e.id))return Ht.current.get(e.id);const t=Array.isArray(Q)?Q:C,n=K?t[Rt.current++%t.length]:t[0];return Ht.current.set(e.id,n),n},[K,Q]),Ft=e.useCallback(e=>{if("function"==typeof Z)return Z(e);const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;return"target"===Z&&n?Wt(n):t?Wt(t):"#999"},[Z,Wt]),zt=e.useCallback(e=>{if(!(null==X?void 0:X.colorBy))return Ft(e);const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;return"target"===ut.colorBy&&n?Wt(n):t?Wt(t):"#999"},[null==X?void 0:X.colorBy,ut.colorBy,Wt,Ft]),$t="sankey"===b&&q||!!De||null!==(r=null===(o=vt.current)||void 0===o?void 0:o.isAnimating)&&void 0!==r&&r,Gt=e.useCallback(()=>{gt.current&&!$t||gt.current||(gt.current=requestAnimationFrame(()=>mt.current()))},[$t]);e.useEffect(()=>{var e;null===(e=vt.current)||void 0===e||e.updateConfig(dt),pt.current=!0,Gt()},[dt,Gt]),e.useEffect(()=>{pt.current=!0,Gt()},[yt,Gt]);const Yt=e.useCallback(()=>{var e;const t=vt.current;if(!t)return;t.runLayout([it,at]),t.buildScene([it,at]),pt.current=!0;for(const n of t.sceneNodes)n.id&&"string"==typeof(null===(e=n.style)||void 0===e?void 0:e.fill)&&Ht.current.set(n.id,n.style.fill);const n=Array.isArray(Q)?Q:C,o=Array.from(t.nodes.values());for(let e=0;o.length>e;e++){const t=o[e];Ht.current.has(t.id)||Ht.current.set(t.id,n[e%n.length])}if(Rt.current=o.length,Ct(t.layoutVersion),Ae){const{nodes:e,edges:n}=t.getLayoutData();Ae(e,n)}},[it,at,Ae,Q]),Vt=e.useCallback(e=>{const t=vt.current;t&&(t.ingestEdge(e)&&Yt(),Gt())},[Yt,Gt]),Ut=e.useCallback(e=>{const t=vt.current;if(!t)return;let n=!1;for(const o of e)t.ingestEdge(o)&&(n=!0);n&&Yt(),Gt()},[Yt,Gt]),Kt=e.useCallback(()=>{var e;null===(e=vt.current)||void 0===e||e.clear(),Ht.current.clear(),Rt.current=0,Ct(0),Et(null),It.current=null,pt.current=!0,Gt()},[Gt]),Qt=e.useCallback(()=>{const e=vt.current;e&&(e.tension+=999,Yt(),Gt())},[Yt,Gt]);e.useImperativeHandle(n,()=>({push:Vt,pushMany:Ut,removeNode:e=>{var t,n;const o=null!==(n=null===(t=vt.current)||void 0===t?void 0:t.removeNode(e))&&void 0!==n&&n;return o&&(Ht.current.delete(e),Yt(),pt.current=!0,Gt()),o},removeEdge:(e,t)=>{var n,o;const r=null!==(o=null===(n=vt.current)||void 0===n?void 0:n.removeEdge(e,t))&&void 0!==o&&o;return r&&(Yt(),pt.current=!0,Gt()),r},updateNode:(e,t)=>{var n,o;const r=null!==(o=null===(n=vt.current)||void 0===n?void 0:n.updateNode(e,t))&&void 0!==o?o:null;return r&&(pt.current=!0,Gt()),r},updateEdge:(e,t,n)=>{var o,r;const i=null!==(r=null===(o=vt.current)||void 0===o?void 0:o.updateEdge(e,t,n))&&void 0!==r?r:[];return i.length>0&&(Yt(),pt.current=!0,Gt()),i},clear:Kt,getTopology:()=>{var e,t;return null!==(t=null===(e=vt.current)||void 0===e?void 0:e.getLayoutData())&&void 0!==t?t:{nodes:[],edges:[]}},getTopologyDiff:()=>{const e=vt.current;return e?{addedNodes:Array.from(e.addedNodes),removedNodes:Array.from(e.removedNodes),addedEdges:Array.from(e.addedEdges),removedEdges:Array.from(e.removedEdges)}:{addedNodes:[],removedNodes:[],addedEdges:[],removedEdges:[]}},relayout:Qt,getTension:()=>{var e,t;return null!==(t=null===(e=vt.current)||void 0===e?void 0:e.tension)&&void 0!==t?t:0}}),[Vt,Ut,Kt,Qt,Yt,Gt]);const Zt=["tree","cluster","treemap","circlepack","partition","orbit"].includes(b),Jt=Zt?w||(Array.isArray(k)?void 0:k):void 0;e.useEffect(()=>{var e;const t=vt.current;if(t)if(Zt&&Jt)t.ingestHierarchy(Jt,[it,at]),t.buildScene([it,at]),pt.current=!0,Gt();else{const n=x||[],o=Array.isArray(k)?k:[];if(0===n.length&&0===o.length)return;t.ingestBounded(n,o,[it,at]),t.buildScene([it,at]);for(const n of t.sceneNodes)n.id&&(null===(e=n.style)||void 0===e?void 0:e.fill)&&Ht.current.set(n.id,n.style.fill+"");const r=Array.isArray(Q)?Q:C,i=Array.from(t.nodes.values());for(let e=0;i.length>e;e++){const t=i[e];Ht.current.has(t.id)||Ht.current.set(t.id,r[e%r.length])}Rt.current=i.length,pt.current=!0,Gt()}},[x,k,w,Jt,Zt,it,at,dt,Gt,Q]),e.useEffect(()=>{A&&A.length>0&&Ut(A)},[]);const en=e.useCallback(e=>{if(me&&me(e),ke){const t=Date.now();ke(e?{type:"hover",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:we}:{type:"hover-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:we})}},[me,ke,we]),tn=e.useCallback(e=>{if(ve&&ve(e),ke){const t=Date.now();ke(e?{type:"click",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:we}:{type:"click-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:we})}},[ve,ke,we]),nn=e.useRef(()=>{}),on=e.useRef(()=>{});nn.current=e=>{if(!he)return;const t=ht.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-rt.left,r=e.clientY-n.top-rt.top;if(0>o||o>it||0>r||r>at)return void(It.current&&(It.current=null,Et(null),en&&(en(null),pt.current=!0),Gt()));const i=vt.current;if(!i)return;const a=Da(i.sceneNodes,i.sceneEdges,o,r);if(!a)return void(It.current&&(It.current=null,Et(null),en&&(en(null),pt.current=!0),Gt()));const s=a.datum||{},l=Object.assign(Object.assign({},"object"!=typeof s||null===s||Array.isArray(s)?{}:s),{type:a.type,data:s,x:a.x,y:a.y});It.current=l,Et(l),en&&(en(l),pt.current=!0),Gt()},on.current=()=>{It.current&&(It.current=null,Et(null),en&&(en(null),pt.current=!0),Gt())};const rn=e.useRef(()=>{});rn.current=e=>{if(!ve&&!ke)return;const t=ht.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-rt.left,r=e.clientY-n.top-rt.top;if(0>o||o>it||0>r||r>at)return;const i=vt.current;if(!i)return;const a=Da(i.sceneNodes,i.sceneEdges,o,r);if(a){const e=a.datum||{};tn(Object.assign(Object.assign({},"object"!=typeof e||null===e||Array.isArray(e)?{}:e),{type:a.type,data:e,x:a.x,y:a.y}))}else tn(null)},e.useCallback(e=>nn.current(e),[]);const an=e.useCallback(()=>on.current(),[]),sn=e.useCallback(e=>rn.current(e),[]),ln=e.useRef(-1),cn=e.useRef(null),un=e.useRef(-1),dn=e.useCallback(e=>{var t;const n=vt.current;if(!n)return;const o=function(e){var t,n,o,r,i,a;const s=[];for(const l of e)"circle"===l.type&&null!=l.cx?s.push({x:l.cx,y:l.cy,datum:l.datum,shape:"circle",group:null!==(n=null===(t=l.datum)||void 0===t?void 0:t.id)&&void 0!==n?n:"_default"}):"rect"===l.type&&null!=l.x?s.push({x:l.x+l.w/2,y:l.y+l.h/2,datum:l.datum,shape:"rect",w:l.w,h:l.h,group:null!==(r=null===(o=l.datum)||void 0===o?void 0:o.id)&&void 0!==r?r:"_default"}):"arc"===l.type&&null!=l.cx&&s.push({x:l.cx,y:l.cy,datum:l.datum,shape:"circle",group:null!==(a=null===(i=l.datum)||void 0===i?void 0:i.id)&&void 0!==a?a:"_default"});return s.sort((e,t)=>e.x-t.x||e.y-t.y),s}(n.sceneNodes);if(0===o.length)return;const r=fe(o),i=ln.current;if(0>i){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Enter"].includes(e.key))return;e.preventDefault(),ln.current=0,un.current=-1;const t=r.flat[0];cn.current={shape:t.shape,w:t.w,h:t.h};const n=t.datum||{},o=Object.assign(Object.assign({},"object"!=typeof n||null===n||Array.isArray(n)?{}:n),{type:"node",data:n,x:t.x,y:t.y});return It.current=o,Et(o),en&&(en(o),pt.current=!0),void Gt()}const a=pe(r,i),s=function(e,t,n,o,r){var i,a,s;const l=n.flat[t.flatIndex];if(!l)return ye(e,t,n);const c=null===(i=l.datum)||void 0===i?void 0:i.id;switch(e){case"ArrowRight":case"ArrowLeft":case"ArrowDown":case"ArrowUp":{const o=null!==(a=function(e,t,n){let o=null,r=1/0;for(let i=0;e.flat.length>i;i++){const a=e.flat[i];if(a===t)continue;const s=a.x-t.x,l=a.y-t.y;let c=!1;switch(n){case"right":c=s>0&&Math.abs(s)>=Math.abs(l);break;case"left":c=0>s&&Math.abs(s)>=Math.abs(l);break;case"down":c=l>0&&Math.abs(l)>=Math.abs(s);break;case"up":c=0>l&&Math.abs(l)>=Math.abs(s)}if(!c)continue;const u=s*s+l*l;r>u&&(r=u,o=i)}return o}(n,l,"ArrowRight"===e?"right":"ArrowLeft"===e?"left":"ArrowDown"===e?"down":"up"))&&void 0!==a?a:t.flatIndex;return o!==t.flatIndex&&(r.current=-1),o}case"Enter":{if(null==c)return t.flatIndex;const e=function(e,t){var n,o,r;const i=e+"",a=[];for(const e of t){const t=null!==(n=e.datum)&&void 0!==n?n:e,s="object"==typeof t.source?null===(o=t.source)||void 0===o?void 0:o.id:t.source,l="object"==typeof t.target?null===(r=t.target)||void 0===r?void 0:r.id:t.target,c=null!=s,u=null!=l;c&&s+""===i&&u?a.push(l+""):u&&l+""===i&&c&&a.push(s+"")}return a}(c,o);if(0===e.length)return t.flatIndex;const i=null!==(s=n.idToIdx.get(e[(r.current+1)%e.length]))&&void 0!==s?s:-1;return 0>i?t.flatIndex:(r.current=-1,i)}default:{const o=ye(e,t,n);return null!==o&&o!==t.flatIndex&&(r.current=-1),o}}}(e.key,a,r,null!==(t=n.sceneEdges)&&void 0!==t?t:[],un);if(null===s)return;if(e.preventDefault(),0>s)return ln.current=-1,cn.current=null,un.current=-1,It.current=null,Et(null),en&&(en(null),pt.current=!0),void Gt();ln.current=s;const l=r.flat[s];cn.current={shape:l.shape,w:l.w,h:l.h};const c=l.datum||{},u=Object.assign(Object.assign({},"object"!=typeof c||null===c||Array.isArray(c)?{}:c),{type:"node",data:c,x:l.x,y:l.y});It.current=u,Et(u),en&&(en(u),pt.current=!0),Gt()},[en,Gt]),hn=e.useCallback(e=>{ln.current=-1,cn.current=null,nn.current(e)},[]);mt.current=()=>{var e,t,n,o,r,i,a;gt.current=0;const s=ht.current;if(!s)return;const l=s.getContext("2d");if(!l)return;const c=vt.current;if(!c)return;const u=performance.now(),d=ft.current?Math.min((u-ft.current)/1e3,.1):.016;ft.current=u;const h=c.advanceTransition(Qe.current?u+1e6:u),g=!Qe.current&&h,f=!Qe.current&&c.tickAnimation([it,at],d);(h||pt.current||f)&&c.buildScene([it,at]);const p=Dt();if(!Nt(s,tt,rt,p))return;l.clearRect(-rt.left,-rt.top,tt[0],tt[1]),de&&(l.fillStyle=de,l.fillRect(0,0,it,at)),Ne&&c.applyDecay(),De&&c.applyPulse(u),He&&c.applyThresholds(u),c.applyTopologyDiff(u);const y=null!==(e=null==Ie?void 0:Ie.threshold)&&void 0!==e?e:5e3,m=Ie&&c.lastIngestTime>0&&u-c.lastIngestTime>y;if(m&&(l.globalAlpha=null!==(t=null==Ie?void 0:Ie.dimOpacity)&&void 0!==t?t:.5),function(e,t){for(const n of t)switch(n.type){case"bezier":$a(e,n);break;case"line":Ga(e,n);break;case"ribbon":Ya(e,n);break;case"curved":qa(e,n)}}(l,c.sceneEdges),function(e,t){var n,o,r;for(const i of t){if("rect"!==i.type)continue;const t=i;t.w>0&&t.h>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(n=t.style.opacity)&&void 0!==n?n:1)*t.style.fillOpacity),e.fillRect(t.x,t.y,t.w,t.h)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(o=t.style.strokeWidth)&&void 0!==o?o:1,e.globalAlpha=null!==(r=t.style.opacity)&&void 0!==r?r:1,e.strokeRect(t.x,t.y,t.w,t.h)),qt(e,t),e.restore())}}(l,c.sceneNodes),function(e,t){var n,o,r;for(const i of t){if("circle"!==i.type)continue;const t=i;t.r>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.r,0,2*Math.PI),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(n=t.style.opacity)&&void 0!==n?n:1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(o=t.style.strokeWidth)&&void 0!==o?o:1,e.globalAlpha=null!==(r=t.style.opacity)&&void 0!==r?r:1,e.stroke()),Xt(e,t),e.restore())}}(l,c.sceneNodes),function(e,t){var n,o,r;for(const i of t){if("arc"!==i.type)continue;const t=i;e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.outerR,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerR,t.endAngle,t.startAngle,!0),e.closePath(),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(n=t.style.opacity)&&void 0!==n?n:1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(o=t.style.strokeWidth)&&void 0!==o?o:1,e.globalAlpha=null!==(r=t.style.opacity)&&void 0!==r?r:1,e.stroke()),e.restore()}}(l,c.sceneNodes),q&&c.particlePool&&!m){const e=Array.from(c.edges.values());if(e.length>0){!function(e,t,n,o){var r,i;const a=null!==(r=o.spawnRate)&&void 0!==r?r:vi.spawnRate,s=null!==(i=o.maxPerEdge)&&void 0!==i?i:vi.maxPerEdge;for(let o=0;t.length>o;o++){const r=t[o];if(!r.bezier)continue;if(e.countForEdge(o)>=s)continue;const i=r.value*a*n*(r.bezier.circular?.3:1),l=Math.floor(i),c=i-l;let u=l;Math.random()<c&&u++;for(let t=0;u>t&&e.countForEdge(o)<s;t++)e.spawn(o)}}(c.particlePool,e,d,ut);const t=.5*(null!==(n=ut.speedMultiplier)&&void 0!==n?n:1);let o;if(ut.proportionalSpeed){const t=e.reduce((e,t)=>Math.max(e,t.value||1),1);o=e.map(e=>.3+(e.value||1)/t*1.7)}c.particlePool.step(d,t,e,o),function(e,t,n,o,r){var i,a;const s=null!==(i=o.radius)&&void 0!==i?i:vi.radius,l=null!==(a=o.opacity)&&void 0!==a?a:vi.opacity;e.globalAlpha=l;for(let i=0;t.particles.length>i;i++){const a=t.particles[i];if(!a.active)continue;const l=n[a.edgeIndex];if(l){if("function"==typeof o.color){const t="object"==typeof l.source?l.source:null;e.fillStyle=t?o.color(l,t):"#666"}else e.fillStyle=o.color&&"inherit"!==o.color?o.color:r(l);e.beginPath(),e.arc(a.x,a.y,s,0,2*Math.PI),e.fill()}}e.globalAlpha=1}(l,c.particlePool,e,ut,zt)}}m&&(l.globalAlpha=1);const v=pt.current;if(pt.current=!1,v||g||f){const e=ht.current;e&&e.setAttribute("aria-label",ct(null!==(r=null===(o=c.sceneNodes)||void 0===o?void 0:o.length)&&void 0!==r?r:0,null!==(a=null===(i=c.sceneEdges)||void 0===i?void 0:i.length)&&void 0!==a?a:0,"Network chart"))}(v||g||f)&&Lt(e=>e+1),($t||g||f||c.hasActivePulses||c.hasActiveThresholds||c.hasActiveTopologyDiff)&&(gt.current=requestAnimationFrame(()=>mt.current()))},e.useEffect(()=>(Gt(),()=>{gt.current&&(cancelAnimationFrame(gt.current),gt.current=0)}),[Gt]),e.useEffect(()=>{pt.current=!0,Gt()},[b,it,at,de,Gt]),xe(Ie,vt,pt,Gt,_t,Bt);const gn=he&&At?p.createElement(Ot,{x:At.x,y:At.y,containerWidth:it,containerHeight:at,margin:rt,className:"stream-network-tooltip",zIndex:2},ge?ge(At):p.createElement(Za,{data:At})):null;if(ot){const e=vt.current;if(e){const t=["tree","cluster","treemap","circlepack","partition","orbit"].includes(b),n=t?w||(Array.isArray(k)?void 0:k):void 0;if(t&&n)e.ingestHierarchy(n,[it,at]),e.buildScene([it,at]);else{const t=x||[],n=Array.isArray(k)?k:[];(t.length>0||n.length>0)&&(e.ingestBounded(t,n,[it,at]),e.buildScene([it,at]))}}const t=null!==(i=null==e?void 0:e.sceneNodes)&&void 0!==i?i:[],n=null!==(a=null==e?void 0:e.sceneEdges)&&void 0!==a?a:[],o=null!==(s=null==e?void 0:e.labels)&&void 0!==s?s:[];return p.createElement("div",{className:"stream-network-frame"+(ue?" "+ue:""),role:"img","aria-label":We||("string"==typeof _e?_e:"Network chart"),style:{position:"relative",width:tt[0],height:tt[1]}},p.createElement(xt,{summary:Fe}),p.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:tt[0],height:tt[1],style:{position:"absolute",left:0,top:0}},Te&&p.createElement("g",{transform:`translate(${rt.left},${rt.top})`},Te),p.createElement("g",{transform:`translate(${rt.left},${rt.top})`},de&&p.createElement("rect",{x:0,y:0,width:it,height:at,fill:de}),n.map((e,t)=>function(e,t){switch(e.type){case"line":return p.createElement("line",{key:"net-edge-"+t,x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity});case"bezier":{const n=e;return p.createElement("path",{key:"net-edge-"+t,d:n.pathD,fill:nt(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})}case"ribbon":{const n=e;return p.createElement("path",{key:"net-edge-"+t,d:n.pathD,fill:nt(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})}case"curved":{const n=e;return p.createElement("path",{key:"net-edge-"+t,d:n.pathD,fill:nt(n.style.fill,"none"),stroke:n.style.stroke||"#999",strokeWidth:n.style.strokeWidth||1,opacity:n.style.opacity})}default:return null}}(e,t)).filter(Boolean),t.map((e,t)=>function(e,t){switch(e.type){case"circle":{const n=e;return p.createElement("circle",{key:"net-circle-"+t,cx:n.cx,cy:n.cy,r:n.r,fill:nt(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})}case"rect":{const n=e;return p.createElement("rect",{key:"net-rect-"+t,x:n.x,y:n.y,width:n.w,height:n.h,fill:nt(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})}case"arc":{const n=e,o=l.arc().innerRadius(n.innerR).outerRadius(n.outerR).startAngle(n.startAngle).endAngle(n.endAngle)({})||"";return p.createElement("path",{key:"net-arc-"+t,d:o,transform:`translate(${n.cx},${n.cy})`,fill:nt(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})}default:return null}}(e,t)).filter(Boolean),o.map((e,t)=>function(e,t){return p.createElement("text",{key:"net-label-"+t,x:e.x,y:e.y,textAnchor:e.anchor||"middle",dominantBaseline:e.baseline||"auto",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"#333",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder},e.text)}(e,t)).filter(Boolean))),p.createElement(za,{width:it,height:at,totalWidth:tt[0],totalHeight:tt[1],margin:rt,labels:o,sceneNodes:t,title:_e,legend:Ee,legendPosition:Me,legendHoverBehavior:je,legendClickBehavior:Ce,legendHighlightedCategory:Pe,legendIsolatedCategories:Le,foregroundGraphics:st,annotations:Se,svgAnnotationRules:Oe,annotationFrame:0}))}const fn=vt.current;return p.createElement("div",{ref:et,className:"stream-network-frame"+(ue?" "+ue:""),role:"group","aria-label":We||("string"==typeof _e?_e:"Network chart"),tabIndex:0,style:{position:"relative",width:se?"100%":tt[0],height:le?"100%":tt[1],overflow:"visible"},onKeyDown:dn},Re&&p.createElement(kt,{tableId:Ze}),Re&&p.createElement(bt,{nodes:null!==(c=null==fn?void 0:fn.sceneNodes)&&void 0!==c?c:[],edges:null!==(u=null==fn?void 0:fn.sceneEdges)&&void 0!==u?u:[],chartType:"Network chart",tableId:Ze,chartTitle:"string"==typeof _e?_e:void 0}),p.createElement(xt,{summary:Fe}),p.createElement("div",{role:"img","aria-label":We||("string"==typeof _e?_e:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:he?hn:void 0,onMouseLeave:he?an:void 0,onClick:ve||ke?sn:void 0},Te&&p.createElement("svg",{overflow:"visible",style:{position:"absolute",top:0,left:0,width:tt[0],height:tt[1],pointerEvents:"none",overflow:"visible"}},p.createElement("g",{transform:`translate(${rt.left},${rt.top})`},Te)),p.createElement("canvas",{ref:ht,"aria-label":ct(null!==(h=null===(d=null==fn?void 0:fn.sceneNodes)||void 0===d?void 0:d.length)&&void 0!==h?h:0,null!==(f=null===(g=null==fn?void 0:fn.sceneEdges)||void 0===g?void 0:g.length)&&void 0!==f?f:0,"Network chart"),style:{position:"absolute",top:0,left:0}}),p.createElement(wt,{hoverPoint:At}),p.createElement(za,{width:it,height:at,totalWidth:tt[0],totalHeight:tt[1],margin:rt,labels:(null==fn?void 0:fn.labels)||[],sceneNodes:null==fn?void 0:fn.sceneNodes,title:_e,legend:Ee,legendPosition:Me,legendHoverBehavior:je,legendClickBehavior:Ce,legendHighlightedCategory:Pe,legendIsolatedCategories:Le,foregroundGraphics:st,annotations:Se,svgAnnotationRules:Oe,annotationFrame:Pt}),p.createElement(St,{active:ln.current>=0,hoverPoint:At,margin:rt,size:tt,shape:null===(y=cn.current)||void 0===y?void 0:y.shape,width:null===(m=cn.current)||void 0===m?void 0:m.w,height:null===(v=cn.current)||void 0===v?void 0:v.h}),gn,(null==Ie?void 0:Ie.showBadge)&&p.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===Ie.badgePosition?{top:4,left:4}:"bottom-left"===Ie.badgePosition?{bottom:4,left:4}:"bottom-right"===Ie.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{background:_t?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"})},_t?"STALE":"LIVE")))});Ja.displayName="StreamNetworkFrame";const es=e.forwardRef(function(t,n){var o;const r=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n,o,i,a;const s=Array.isArray(e)?e:[e],l=null!==(o=null===(n=null===(t=r.current)||void 0===t?void 0:t.getTopology())||void 0===n?void 0:n.nodes)&&void 0!==o?o:[],c=[];for(const e of s){const t=l.find(t=>t.id===e);t&&c.push(Object.assign(Object.assign({},null!==(i=t.data)&&void 0!==i?i:{}),{id:e})),null===(a=r.current)||void 0===a||a.removeNode(e)}return c},update:(e,t)=>(Array.isArray(e)?e:[e]).flatMap(e=>{var n;const o=null===(n=r.current)||void 0===n?void 0:n.updateNode(e,t);return o?[Object.assign(Object.assign({},o),{id:e})]:[]}),clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t,n,o;return null!==(o=null===(n=null===(t=null===(e=r.current)||void 0===e?void 0:e.getTopology())||void 0===t?void 0:t.nodes)||void 0===n?void 0:n.map(e=>e.data))&&void 0!==o?o:[]}}));const i=Qn(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLegend:t.showLegend,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary},{width:600,height:600}),{nodes:a,edges:s,margin:l,className:c,nodeIDAccessor:u="id",sourceAccessor:d="source",targetAccessor:h="target",nodeLabel:g,colorBy:f,colorScheme:y,nodeSize:m=8,nodeSizeRange:v=[5,20],edgeWidth:b=1,edgeColor:x="#999",edgeOpacity:k=.6,iterations:w=300,forceStrength:A=.1,tooltip:S,frameProps:O={},onObservation:E,onClick:M,chartId:P,selection:L,linkedHover:_,loading:T,emptyContent:N,legendInteraction:D,legendPosition:I}=t,H=i.width,R=i.height,W=i.enableHover,F=i.showLegend,z=null!==(o=i.showLabels)&&void 0!==o&&o,$=i.title,G=i.description,Y=i.summary,q=i.accessibleTable,X=zo(T,H,R),V=X?null:Fo(a,H,R,N),U=a||[],K=s||[],Q=Gn(U,f,y),Z=e.useMemo(()=>{if(!f)return[];const e=new Set;for(const t of U){const n="function"==typeof f?f(t):t[f];null!=n&&e.add(n+"")}return Array.from(e)},[U,f]),J=Un(D,f,Z),ee=Fn(),te=e.useMemo(()=>new Map,[]),ne=e.useMemo(()=>{if(Array.isArray(y))return y;if(ee&&ee.length>0)return ee;const e=j[y];return Array.isArray(e)?e:C},[y,ee]),oe=e.useMemo(()=>e=>{const t={};return t.fill=f?B(e.data||e,f,Q):zn(void 0,ee,y,void 0,te),"number"==typeof m&&(t.r=m),t},[f,Q,m,ee,y,te]),re=e.useMemo(()=>e=>({stroke:x,strokeWidth:"number"==typeof b?b:"function"==typeof b?b(e):e[b]||1,opacity:k}),[b,x,k]),ie=e.useMemo(()=>{if(z&&g)return"function"==typeof g?g:e=>{var t,n,o;return null!==(o=null!==(n=null===(t=e.data)||void 0===t?void 0:t[g])&&void 0!==n?n:e[g])&&void 0!==o?o:e.id}},[z,g]),{legend:ae,margin:se,legendPosition:le}=Vn({data:U,colorBy:f,colorScale:Q,showLegend:F,legendPosition:I,userMargin:l,defaults:i.marginDefaults}),{customHoverBehavior:ce,customClickBehavior:ue}=qn({selection:L,linkedHover:_,fallbackFields:f?["string"==typeof f?f:""]:[],unwrapData:!0,onObservation:E,onClick:M,chartType:"ForceDirectedGraph",chartId:P}),de=vo({componentName:"ForceDirectedGraph",nodes:a,edges:s,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:u}});return de?p.createElement(co,{componentName:"ForceDirectedGraph",message:de,width:H,height:R}):X||V||p.createElement(Ho,{componentName:"ForceDirectedGraph",width:H,height:R},p.createElement(Ja,Object.assign({ref:r,chartType:"force"},null!=a&&{nodes:U},null!=s&&{edges:K},{size:[H,R],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:se,nodeIDAccessor:u,sourceAccessor:d,targetAccessor:h,iterations:w,forceStrength:A,nodeStyle:oe,edgeStyle:re,colorBy:f,colorScheme:ne,nodeSize:m,nodeSizeRange:v,nodeLabel:ie,showLabels:z,enableHover:W,tooltipContent:!1===S?()=>null:oo(S)||void 0,customHoverBehavior:_||E||M?ce:void 0,customClickBehavior:E||M?ue:void 0,legend:ae,legendPosition:le},D&&"none"!==D&&{legendHoverBehavior:J.onLegendHover,legendClickBehavior:J.onLegendClick,legendHighlightedCategory:J.highlightedCategory,legendIsolatedCategories:J.isolatedCategories},{className:c,title:$,description:G,summary:Y,accessibleTable:q},O)))});function ts(e,t){if(!e)return[];const n=[],o=e=>{n.push(e);const r="function"==typeof t?t(e):e[t];r&&Array.isArray(r)&&r.forEach(o)};return o(e),n}function ns(e,t,n,o){if(e&&e.length>0)return e;const r=new Set;return t.forEach(e=>{const t="function"==typeof n?n(e):e[n],i="function"==typeof o?o(e):e[o];r.add(t),r.add(i)}),Array.from(r).map(e=>({id:e}))}function os(e){return"function"==typeof e?e:t=>t[e]||1}function rs({edgeColorBy:e,colorBy:t,colorScale:n,nodeStyleFn:o,edgeOpacity:r,baseStyle:i={}}){return a=>{const s=Object.assign({fillOpacity:r},i);if("function"==typeof e)s.fill=e(a);else if("source"===e){const e="object"==typeof a.source?a.source:null;t&&e?s.fill=B(e.data||e,t,n):e&&(s.fill=o(e,e.index).fill)}else if("target"===e){const e="object"==typeof a.target?a.target:null;t&&e?s.fill=B(e.data||e,t,n):e&&(s.fill=o(e,e.index).fill)}else"gradient"===e&&(s.fill="#999",s.fillOpacity=.7*r);return s}}es.displayName="ForceDirectedGraph";const is=e.forwardRef(function(t,n){var o;const r=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n,o,i,a;const s=Array.isArray(e)?e:[e],l=null!==(o=null===(n=null===(t=r.current)||void 0===t?void 0:t.getTopology())||void 0===n?void 0:n.nodes)&&void 0!==o?o:[],c=[];for(const e of s){const t=l.find(t=>t.id===e);t&&c.push(Object.assign(Object.assign({},null!==(i=t.data)&&void 0!==i?i:{}),{id:e})),null===(a=r.current)||void 0===a||a.removeNode(e)}return c},update:(e,t)=>(Array.isArray(e)?e:[e]).flatMap(e=>{var n;const o=null===(n=r.current)||void 0===n?void 0:n.updateNode(e,t);return o?[Object.assign(Object.assign({},o),{id:e})]:[]}),clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t,n,o;return null!==(o=null===(n=null===(t=null===(e=r.current)||void 0===e?void 0:e.getTopology())||void 0===t?void 0:t.edges)||void 0===n?void 0:n.map(e=>e.data))&&void 0!==o?o:[]}}));const i=Qn(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary},{width:600,height:600}),{nodes:a,edges:s,margin:l,className:c,sourceAccessor:u="source",targetAccessor:d="target",valueAccessor:h="value",nodeIdAccessor:g="id",colorBy:f,colorScheme:y,edgeColorBy:m="source",padAngle:v=.01,groupWidth:b=20,sortGroups:x,nodeLabel:k,edgeOpacity:w=.5,tooltip:A,frameProps:S={},onObservation:O,onClick:E,chartId:M,selection:P,linkedHover:L,loading:_,emptyContent:T,legendInteraction:N}=t,D=i.width,I=i.height,H=i.enableHover,R=null===(o=i.showLabels)||void 0===o||o,W=i.title,F=i.description,z=i.summary,$=i.accessibleTable,G=zo(_,D,I),Y=G?null:Fo(s,D,I,T),q=s||[],X=e.useMemo(()=>ns(a,q,u,d),[a,q,u,d]),V=Gn(X,f,y),U=e.useMemo(()=>{if(!f)return[];const e=new Set;for(const t of X){const n="function"==typeof f?f(t):t[f];null!=n&&e.add(n+"")}return Array.from(e)},[X,f]),K=Un(N,f,U),Q=Fn(),Z=e.useMemo(()=>new Map,[]),J=e.useMemo(()=>{if(Array.isArray(y))return y;if(Q&&Q.length>0)return Q;const e=j[y];return Array.isArray(e)?e:C},[y,Q]),ee=X.length>0,te=e.useMemo(()=>{if(ee)return(e,t)=>{var n,o;const r={stroke:"black",strokeWidth:1};if(f)r.fill=B(e.data||e,f,V);else{const i=Array.isArray(y)?y:j[y]||C,a=Array.isArray(i)?i:C,s=null!==(o=null!==(n=e.index)&&void 0!==n?n:t)&&void 0!==o?o:0;r.fill=a[s%a.length]}return r}},[ee,f,V,y]),ne=e.useMemo(()=>{if(ee)return rs({edgeColorBy:m,colorBy:f,colorScale:V,nodeStyleFn:te||(e=>({fill:zn(void 0,Q,y,void 0,Z)})),edgeOpacity:w,baseStyle:{stroke:"black",strokeWidth:.5,strokeOpacity:w}})},[ee,m,f,V,te,w,Q,y,Z]),oe=e.useMemo(()=>{if(!R)return;const e=k||g;return"function"==typeof e?e:t=>{var n,o,r;return null!==(r=null!==(o=null===(n=t.data)||void 0===n?void 0:n[e])&&void 0!==o?o:t[e])&&void 0!==r?r:t.id}},[R,k,g]),re=Object.assign(Object.assign({},i.marginDefaults),l),{customHoverBehavior:ie,customClickBehavior:ae}=qn({selection:P,linkedHover:L,fallbackFields:f?["string"==typeof f?f:""]:[],unwrapData:!0,onObservation:O,onClick:E,chartType:"ChordDiagram",chartId:M}),se=vo({componentName:"ChordDiagram",edges:s,edgesRequired:!0});return se?p.createElement(co,{componentName:"ChordDiagram",message:se,width:D,height:I}):G||Y||p.createElement(Ho,{componentName:"ChordDiagram",width:D,height:I},p.createElement(Ja,Object.assign({ref:r,chartType:"chord"},X.length>0&&{nodes:X},null!=s&&{edges:q},{size:[D,I],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:re,nodeIDAccessor:g,sourceAccessor:u,targetAccessor:d,valueAccessor:h,padAngle:v,groupWidth:b,sortGroups:x,nodeStyle:te,edgeStyle:ne,colorBy:f,colorScheme:J,edgeColorBy:m,edgeOpacity:w,nodeLabel:oe,showLabels:R,enableHover:H,tooltipContent:!1===A?()=>null:oo(A)||void 0,customHoverBehavior:L||O||E?ie:void 0,customClickBehavior:O||E?ae:void 0},N&&"none"!==N&&{legendHoverBehavior:K.onLegendHover,legendClickBehavior:K.onLegendClick,legendHighlightedCategory:K.highlightedCategory,legendIsolatedCategories:K.isolatedCategories},{className:c,title:W,description:F,summary:z,accessibleTable:$},S)))});is.displayName="ChordDiagram";const as=e.forwardRef(function(t,n){var o;const r=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n,o,i,a;const s=Array.isArray(e)?e:[e],l=null!==(o=null===(n=null===(t=r.current)||void 0===t?void 0:t.getTopology())||void 0===n?void 0:n.nodes)&&void 0!==o?o:[],c=[];for(const e of s){const t=l.find(t=>t.id===e);t&&c.push(Object.assign(Object.assign({},null!==(i=t.data)&&void 0!==i?i:{}),{id:e})),null===(a=r.current)||void 0===a||a.removeNode(e)}return c},update:(e,t)=>(Array.isArray(e)?e:[e]).flatMap(e=>{var n;const o=null===(n=r.current)||void 0===n?void 0:n.updateNode(e,t);return o?[Object.assign(Object.assign({},o),{id:e})]:[]}),clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t,n,o;return null!==(o=null===(n=null===(t=null===(e=r.current)||void 0===e?void 0:e.getTopology())||void 0===t?void 0:t.edges)||void 0===n?void 0:n.map(e=>e.data))&&void 0!==o?o:[]}}));const i=Qn(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary},{width:800,height:600}),{nodes:a,edges:s,margin:l,className:c,sourceAccessor:u="source",targetAccessor:d="target",valueAccessor:h="value",nodeIdAccessor:g="id",colorBy:f,colorScheme:y,edgeColorBy:m="source",orientation:v="horizontal",nodeAlign:b="justify",nodePaddingRatio:x=.05,nodeWidth:k=15,nodeLabel:w,edgeOpacity:A=.5,edgeSort:S,tooltip:O,frameProps:E={},onObservation:M,onClick:P,chartId:L,selection:_,linkedHover:T,loading:N,emptyContent:D,legendInteraction:I}=t,H=i.width,R=i.height,W=i.enableHover,F=null===(o=i.showLabels)||void 0===o||o,z=i.title,$=i.description,G=i.summary,Y=i.accessibleTable,q=zo(N,H,R),X=q?null:Fo(s,H,R,D),V=s||[],U=e.useMemo(()=>ns(a,V,u,d),[a,V,u,d]),K=Gn(U,f,y),Q=e.useMemo(()=>{if(!f)return[];const e=new Set;for(const t of U){const n="function"==typeof f?f(t):t[f];null!=n&&e.add(n+"")}return Array.from(e)},[U,f]),Z=Un(I,f,Q),J=Fn(),ee=e.useMemo(()=>new Map,[]),te=e.useMemo(()=>{if(Array.isArray(y))return y;if(J&&J.length>0)return J;const e=j[y];return Array.isArray(e)?e:C},[y,J]),ne=e.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=f?B(e.data||e,f,K):zn(void 0,J,y,void 0,ee),t},[f,K,J,y,ee]),oe=e.useMemo(()=>rs({edgeColorBy:m,colorBy:f,colorScale:K,nodeStyleFn:ne,edgeOpacity:A,baseStyle:{stroke:"none",strokeWidth:0}}),[m,f,K,ne,A]),re=e.useMemo(()=>{if(!F)return;const e=w||g;return"function"==typeof e?e:t=>{var n,o,r;return null!==(r=null!==(o=null===(n=t.data)||void 0===n?void 0:n[e])&&void 0!==o?o:t[e])&&void 0!==r?r:t.id}},[F,w,g]),ie=Object.assign(Object.assign({},i.marginDefaults),l),{customHoverBehavior:ae,customClickBehavior:se}=qn({selection:_,linkedHover:T,fallbackFields:f?["string"==typeof f?f:""]:[],unwrapData:!0,onObservation:M,onClick:P,chartType:"SankeyDiagram",chartId:L}),le=vo({componentName:"SankeyDiagram",edges:s,edgesRequired:!0});return le?p.createElement(co,{componentName:"SankeyDiagram",message:le,width:H,height:R}):q||X||p.createElement(Ho,{componentName:"SankeyDiagram",width:H,height:R},p.createElement(Ja,Object.assign({ref:r,chartType:"sankey"},U.length>0&&{nodes:U},null!=s&&{edges:V},{size:[H,R],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:ie,nodeIDAccessor:g,sourceAccessor:u,targetAccessor:d,valueAccessor:h,orientation:v,nodeAlign:b,nodePaddingRatio:x,nodeWidth:k,nodeStyle:ne,edgeStyle:oe,colorBy:f,colorScheme:te,edgeColorBy:m,edgeOpacity:A,edgeSort:S,nodeLabel:re,showLabels:F,enableHover:W,tooltipContent:!1===O?()=>null:oo(O)||void 0,customHoverBehavior:T||M||P?ae:void 0,customClickBehavior:M||P?se:void 0},I&&"none"!==I&&{legendHoverBehavior:Z.onLegendHover,legendClickBehavior:Z.onLegendClick,legendHighlightedCategory:Z.highlightedCategory,legendIsolatedCategories:Z.isolatedCategories},{className:c,title:z,description:$,summary:G,accessibleTable:Y},E)))});function ss(t){var n;const o=Qn(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary},{width:600,height:600}),{data:r,margin:i,className:a,layout:s="tree",orientation:l="vertical",childrenAccessor:c="children",valueAccessor:u="value",nodeIdAccessor:d="name",colorBy:h,colorScheme:g,colorByDepth:f=!1,edgeStyle:y="curve",nodeLabel:m,nodeSize:v=5,tooltip:b,frameProps:x={},onObservation:k,onClick:w,chartId:A,selection:S,linkedHover:O,loading:E,legendInteraction:M}=t,P=o.width,_=o.height,T=o.enableHover,N=null===(n=o.showLabels)||void 0===n||n,D=o.title,I=o.description,H=o.summary,R=o.accessibleTable,W=zo(E,P,_),F=e.useMemo(()=>ts(null!=r?r:null,c),[r,c]),z=Gn(F,f?void 0:h,g),$=e.useMemo(()=>{if(!h||f)return[];const e=new Set;for(const t of F){const n="function"==typeof h?h(t):t[h];null!=n&&e.add(n+"")}return Array.from(e)},[F,h,f]),G=Un(M,f?void 0:h,$),Y=Fn(),q=e.useMemo(()=>new Map,[]),X=e.useMemo(()=>{if(Array.isArray(g))return g;if(Y&&Y.length>0)return Y;const e=j[g];return Array.isArray(e)?e:C},[g,Y]),V=e.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=f?L[(e.depth||0)%L.length]:h?B(e.data||e,h,z):zn(void 0,Y,g,void 0,q),t},[h,f,z,Y,g,q]),U=e.useMemo(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),K=e.useMemo(()=>{if("treemap"===s||"circlepack"===s||"partition"===s)return os(u)},[s,u]),Q=Object.assign(Object.assign({},o.marginDefaults),i),{customHoverBehavior:Z,customClickBehavior:J}=qn({selection:S,linkedHover:O,fallbackFields:h?["string"==typeof h?h:""]:[],unwrapData:!0,onObservation:k,onClick:w,chartType:"TreeDiagram",chartId:A}),ee=mo({componentName:"TreeDiagram",data:r});return ee?p.createElement(co,{componentName:"TreeDiagram",message:ee,width:P,height:_}):W||p.createElement(Ho,{componentName:"TreeDiagram",width:P,height:_},p.createElement(Ja,Object.assign({chartType:s},null!=r&&{data:r},{size:[P,_],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Q,nodeIDAccessor:d,childrenAccessor:c,hierarchySum:K,treeOrientation:l,edgeType:y,nodeStyle:V,edgeStyle:U,colorBy:h,colorScheme:X,colorByDepth:f,nodeSize:v,nodeLabel:N?m||d:void 0,showLabels:N,enableHover:T,tooltipContent:!1===b?()=>null:oo(b)||void 0,customHoverBehavior:O||k||w?Z:void 0,customClickBehavior:k||w?J:void 0},M&&"none"!==M&&{legendHoverBehavior:G.onLegendHover,legendClickBehavior:G.onLegendClick,legendHighlightedCategory:G.highlightedCategory,legendIsolatedCategories:G.isolatedCategories},{className:a,title:D,description:I,summary:H,accessibleTable:R},x)))}function ls(t){var n;const o=Qn(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary,linkedHover:t.linkedHover},{width:600,height:600}),{data:r,margin:i,className:a,childrenAccessor:s="children",valueAccessor:l="value",nodeIdAccessor:c="name",colorBy:u,colorScheme:d,colorByDepth:h=!1,labelMode:g="leaf",nodeLabel:f,padding:y=4,paddingTop:m,tooltip:v,frameProps:b={},selection:x,linkedHover:k,onObservation:w,onClick:A,chartId:S,loading:O,legendInteraction:E}=t,M=o.width,P=o.height,_=o.enableHover,T=null===(n=o.showLabels)||void 0===n||n,N=o.title,D=o.description,I=o.summary,H=o.accessibleTable,R=zo(O,M,P),{activeSelectionHook:W,customHoverBehavior:F,customClickBehavior:z}=qn({selection:x,linkedHover:k,fallbackFields:u?["string"==typeof u?u:""]:[],onObservation:w,onClick:A,chartType:"Treemap",chartId:S}),$=e.useCallback(e=>{if(!e)return F(null);const t=e.data||e;F({data:(null==t?void 0:t.data)||t})},[F]),G=e.useMemo(()=>ts(null!=r?r:null,s),[r,s]),Y=Gn(G,h?void 0:u,d),q=e.useMemo(()=>{if(!u||h)return[];const e=new Set;for(const t of G){const n="function"==typeof u?u(t):t[u];null!=n&&e.add(n+"")}return Array.from(e)},[G,u,h]),X=Un(E,h?void 0:u,q),V=Fn(),U=e.useMemo(()=>new Map,[]),K=e.useMemo(()=>{if(Array.isArray(d))return d;if(V&&V.length>0)return V;const e=j[d];return Array.isArray(e)?e:C},[d,V]),Q=e.useMemo(()=>e=>{const t={stroke:"#fff",strokeWidth:1,strokeOpacity:.8};return t.fill=h?L[(e.depth||0)%L.length]:u?B(e.data||e,u,Y):zn(void 0,V,d,void 0,U),t},[u,h,Y,V,d,U]),Z=e.useMemo(()=>W?e=>{var t;const n=Object.assign({},Q(e));if(W.isActive)if(W.predicate(e.data||e))(null==x?void 0:x.selectedStyle)&&Object.assign(n,x.selectedStyle);else{const e=null!==(t=null==x?void 0:x.unselectedOpacity)&&void 0!==t?t:.2;n.opacity=e,n.fillOpacity=e,n.strokeOpacity=e,(null==x?void 0:x.unselectedStyle)&&Object.assign(n,x.unselectedStyle)}return n}:Q,[Q,W,x]),J=e.useMemo(()=>os(l),[l]),ee=void 0!==m?m:!T||"parent"!==g&&"all"!==g?void 0:18,te=Object.assign(Object.assign({},o.marginDefaults),i),ne=mo({componentName:"Treemap",data:r});return ne?p.createElement(co,{componentName:"Treemap",message:ne,width:M,height:P}):R||p.createElement(Ho,{componentName:"Treemap",width:M,height:P},p.createElement(Ja,Object.assign({chartType:"treemap"},null!=r&&{data:r},{size:[M,P],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:te,nodeIDAccessor:c,childrenAccessor:s,hierarchySum:J,padding:y,paddingTop:ee,nodeStyle:Z,colorBy:u,colorScheme:K,colorByDepth:h,nodeLabel:T?f||c:void 0,showLabels:T,labelMode:g,enableHover:_,tooltipContent:!1===v?()=>null:oo(v)||void 0},(k||w||A)&&{customHoverBehavior:$},(w||A)&&{customClickBehavior:z},E&&"none"!==E&&{legendHoverBehavior:X.onLegendHover,legendClickBehavior:X.onLegendClick,legendHighlightedCategory:X.highlightedCategory,legendIsolatedCategories:X.isolatedCategories},{className:a,title:N,description:D,summary:I,accessibleTable:H},b)))}function cs(t){var n;const o=Qn(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary},{width:600,height:600}),{data:r,margin:i,className:a,childrenAccessor:s="children",valueAccessor:l="value",nodeIdAccessor:c="name",colorBy:u,colorScheme:d,colorByDepth:h=!1,nodeLabel:g,circleOpacity:f=.7,padding:y=4,tooltip:m,frameProps:v={},onObservation:b,onClick:x,chartId:k,selection:w,linkedHover:A,loading:S,legendInteraction:O}=t,E=o.width,M=o.height,P=o.enableHover,_=null===(n=o.showLabels)||void 0===n||n,T=o.title,N=o.description,D=o.summary,I=o.accessibleTable,H=zo(S,E,M),R=e.useMemo(()=>ts(null!=r?r:null,s),[r,s]),W=Gn(R,h?void 0:u,d),F=e.useMemo(()=>{if(!u||h)return[];const e=new Set;for(const t of R){const n="function"==typeof u?u(t):t[u];null!=n&&e.add(n+"")}return Array.from(e)},[R,u,h]),z=Un(O,h?void 0:u,F),$=Fn(),G=e.useMemo(()=>new Map,[]),Y=e.useMemo(()=>{if(Array.isArray(d))return d;if($&&$.length>0)return $;const e=j[d];return Array.isArray(e)?e:C},[d,$]),q=e.useMemo(()=>e=>{const t={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:f};return t.fill=h?L[(e.depth||0)%L.length]:u?B(e.data||e,u,W):zn(void 0,$,d,void 0,G),t},[u,h,W,f,$,d,G]),X=e.useMemo(()=>os(l),[l]),V=Object.assign(Object.assign({},o.marginDefaults),i),{customHoverBehavior:U,customClickBehavior:K}=qn({selection:w,linkedHover:A,fallbackFields:u?["string"==typeof u?u:""]:[],unwrapData:!0,onObservation:b,onClick:x,chartType:"CirclePack",chartId:k}),Q=mo({componentName:"CirclePack",data:r});return Q?p.createElement(co,{componentName:"CirclePack",message:Q,width:E,height:M}):H||p.createElement(Ho,{componentName:"CirclePack",width:E,height:M},p.createElement(Ja,Object.assign({chartType:"circlepack"},null!=r&&{data:r},{size:[E,M],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:V,nodeIDAccessor:c,childrenAccessor:s,hierarchySum:X,padding:y,nodeStyle:q,colorBy:u,colorScheme:Y,colorByDepth:h,nodeLabel:_?g||c:void 0,showLabels:_,enableHover:P,tooltipContent:!1===m?()=>null:oo(m)||void 0,customHoverBehavior:A||b||x?U:void 0,customClickBehavior:b||x?K:void 0},O&&"none"!==O&&{legendHoverBehavior:z.onLegendHover,legendClickBehavior:z.onLegendClick,legendHighlightedCategory:z.highlightedCategory,legendIsolatedCategories:z.isolatedCategories},{className:a,title:T,description:N,summary:D,accessibleTable:I},v)))}as.displayName="SankeyDiagram",ss.displayName="TreeDiagram",ls.displayName="Treemap",cs.displayName="CirclePack";const us=L;function ds(t){const n=Qn(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary},{width:600,height:600}),{data:o,margin:r,className:i,childrenAccessor:a="children",nodeIdAccessor:s="name",colorBy:l,colorScheme:c,colorByDepth:u=!1,orbitMode:d="flat",orbitSize:h=2.95,speed:g=.25,revolution:f,revolutionStyle:y,eccentricity:m=1,showRings:v=!0,nodeRadius:b=6,showLabels:x=!1,animated:k=!0,tooltip:w,foregroundGraphics:A,annotations:S,frameProps:O={},onObservation:E,onClick:M,chartId:P,selection:L,linkedHover:_,loading:T}=t,N=n.width,D=n.height,I=n.enableHover,H=n.title,R=n.description,W=n.summary,F=n.accessibleTable,z=zo(T,N,D),$=Gn(e.useMemo(()=>ts(o,a),[o,a]),u?void 0:l,c),G=Fn(),Y=e.useMemo(()=>new Map,[]),q=e.useMemo(()=>{if(Array.isArray(c))return c;if(G&&G.length>0)return G;const e=j[c];return Array.isArray(e)?e:C},[c,G]),X=e.useMemo(()=>{if(Array.isArray(c))return c;const e=j[c];return Array.isArray(e)?e:C},[c]),V=e.useMemo(()=>e=>{var t;const n={stroke:"#fff",strokeWidth:1},o=0===(null!==(t=e.depth)&&void 0!==t?t:0);return n.fill=u?o?X[0]:us[(e.depth||0)%us.length]:l?B(e.data||e,l,$):zn(void 0,G,c,void 0,Y),n.opacity=o?1:.85,n},[l,u,$,X,G,c,Y]),U=e.useMemo(()=>()=>({stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1}),[]),K=Object.assign({top:10,right:10,bottom:10,left:10},r),{customHoverBehavior:Q,customClickBehavior:Z}=qn({selection:L,linkedHover:_,fallbackFields:l?["string"==typeof l?l:""]:[],unwrapData:!0,onObservation:E,onClick:M,chartType:"OrbitDiagram",chartId:P}),J=e.useMemo(()=>{if(Q)return e=>{Q(e&&e.data&&void 0!==e.data.data?Object.assign(Object.assign({},e),{data:e.data.data}):e)}},[Q]),ee=e.useMemo(()=>{if(Z)return e=>{Z(e&&e.data&&void 0!==e.data.data?Object.assign(Object.assign({},e),{data:e.data.data}):e)}},[Z]),te=mo({componentName:"OrbitDiagram",data:o});return te?p.createElement(co,{componentName:"OrbitDiagram",message:te,width:N,height:D}):z||p.createElement(Ho,{componentName:"OrbitDiagram",width:N,height:D},p.createElement(Ja,Object.assign({chartType:"orbit"},null!=o&&{data:o},{size:[N,D],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:K,nodeIDAccessor:s,childrenAccessor:a,nodeStyle:V,edgeStyle:U,colorBy:l,colorScheme:q,colorByDepth:u,nodeSize:b,nodeLabel:x?s:void 0,showLabels:x,enableHover:!k&&I,tooltipContent:k?void 0:!1===w?()=>null:oo(w)||void 0,customHoverBehavior:_||E||M?J:void 0,customClickBehavior:E||M?ee:void 0,foregroundGraphics:A,annotations:S,className:i,title:H,description:R,summary:W,orbitMode:d,orbitSize:h,orbitSpeed:g,orbitRevolution:f,orbitRevolutionStyle:y,orbitEccentricity:m,orbitShowRings:v,orbitAnimated:k,accessibleTable:F},O)))}ds.displayName="OrbitDiagram";const hs=e.forwardRef(function(t,n){var o,r,i,a;const s=Qn(t.mode,{width:null!==(r=null===(o=t.size)||void 0===o?void 0:o[0])&&void 0!==r?r:t.width,height:null!==(a=null===(i=t.size)||void 0===i?void 0:i[1])&&void 0!==a?a:t.height,enableHover:null!=t.enableHover?!!t.enableHover:void 0}),{size:l,margin:c,className:u,arrowOfTime:d="right",windowMode:h="sliding",windowSize:g=200,data:f,timeAccessor:y,valueAccessor:m,timeExtent:v,valueExtent:b,extentPadding:x,stroke:k="#007bff",strokeWidth:w=2,strokeDasharray:A,background:S,tooltipContent:O,tooltip:E,onHover:M,annotations:j,svgAnnotationRules:C,tickFormatTime:P,tickFormatValue:L,decay:_,pulse:B,staleness:T,transition:N,linkedHover:D,selection:I,onObservation:H,chartId:R,loading:W,emptyContent:F,emphasis:z,legendPosition:$}=t,G=s.showAxes,Y=s.enableHover,q=null!=c?c:s.marginDefaults,X=null!=l?l:[s.width,s.height],V=null!=O?O:E,U=e.useRef(null),{customHoverBehavior:K}=qn({selection:I,linkedHover:D,unwrapData:!0,onObservation:H,chartType:"RealtimeLineChart",chartId:R}),Q=e.useCallback(e=>{M&&M(e),K(e)},[M,K]);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=U.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=U.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;return null===(e=U.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=U.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const Z=zo(W,X[0],X[1]),J=Z?null:Fo(f,X[0],X[1],F),ee={stroke:k,strokeWidth:w,strokeDasharray:A};return Z||J||p.createElement(hn,{ref:U,chartType:"line",runtimeMode:"streaming",size:X,margin:q,className:z?`${u||""} semiotic-emphasis-${z}`.trim():u,arrowOfTime:d,windowMode:h,windowSize:g,data:f,timeAccessor:y,valueAccessor:m,xExtent:v,yExtent:b,extentPadding:x,lineStyle:ee,showAxes:G,background:S,hoverAnnotation:Y,tooltipContent:V,customHoverBehavior:Q,annotations:j,svgAnnotationRules:C,tickFormatTime:P,tickFormatValue:L,decay:_,pulse:B,staleness:T,transition:N,pointIdAccessor:t.pointIdAccessor,legendPosition:$})});hs.displayName="RealtimeLineChart";const gs=e.forwardRef(function(t,n){var o,r,i,a;const s=Qn(t.mode,{width:null!==(r=null===(o=t.size)||void 0===o?void 0:o[0])&&void 0!==r?r:t.width,height:null!==(a=null===(i=t.size)||void 0===i?void 0:i[1])&&void 0!==a?a:t.height,enableHover:null!=t.enableHover?!!t.enableHover:void 0}),{binSize:l,size:c,margin:u,className:d,arrowOfTime:h="right",windowMode:g="sliding",windowSize:f=200,data:y,timeAccessor:m,valueAccessor:v,timeExtent:b,valueExtent:x,extentPadding:k,categoryAccessor:w,colors:A,fill:S,stroke:O,strokeWidth:E,gap:M,background:j,tooltipContent:C,tooltip:P,onHover:L,annotations:_,svgAnnotationRules:B,tickFormatTime:T,tickFormatValue:N,linkedHover:D,selection:I,decay:H,pulse:R,staleness:W,transition:F,onObservation:z,chartId:$,loading:G,emptyContent:Y,emphasis:q,legendPosition:X,brush:V,onBrush:U,linkedBrush:K}=t,Q=s.showAxes,Z=s.enableHover,J=null!=u?u:s.marginDefaults,ee=null!=c?c:[s.width,s.height],te=null!=C?C:P,ne=e.useRef(null),{customHoverBehavior:oe}=qn({selection:I,linkedHover:D,unwrapData:!0,onObservation:z,chartType:"RealtimeTemporalHistogram",chartId:$}),re=e.useCallback(e=>{L&&L(e),oe(e)},[L,oe]),ie=!0===V?{dimension:"x",snap:"bin"}:"x"===V?{dimension:"x"}:"object"==typeof V?V:void 0,ae=_n(K),se=On(Object.assign({name:(null==ae?void 0:ae.name)||"__unused_hist_brush__",xField:(null==ae?void 0:ae.xField)||("string"==typeof m?m:"time")},(null==ae?void 0:ae.yField)?{yField:ae.yField}:{})),le=e.useRef(se.brushInteraction);le.current=se.brushInteraction;const ce=e.useCallback(e=>{if(U&&U(e),z&&z(e?{type:"brush",extent:e,timestamp:Date.now(),chartType:"RealtimeTemporalHistogram",chartId:$}:{type:"brush-end",timestamp:Date.now(),chartType:"RealtimeTemporalHistogram",chartId:$}),ae){const t=le.current;t.end(e?"xBrush"===t.brush?e.x:"yBrush"===t.brush?e.y:[[e.x[0],e.y[0]],[e.x[1],e.y[1]]]:null)}},[U,z,$,ae]);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=ne.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=ne.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=ne.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=ne.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;return null===(e=ne.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=ne.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const ue=zo(G,ee[0],ee[1]),de=ue?null:Fo(y,ee[0],ee[1],Y),he={};return null!=S&&(he.fill=S),null!=O&&(he.stroke=O),null!=E&&(he.strokeWidth=E),null!=M&&(he.gap=M),ue||de||p.createElement(hn,{ref:ne,chartType:"bar",runtimeMode:"streaming",size:ee,margin:J,className:q?`${d||""} semiotic-emphasis-${q}`.trim():d,arrowOfTime:h,windowMode:g,windowSize:f,data:y,timeAccessor:m,valueAccessor:v,xExtent:b,yExtent:x,extentPadding:k,binSize:l,categoryAccessor:w,barColors:A,barStyle:he,showAxes:Q,background:j,hoverAnnotation:Z,tooltipContent:te,customHoverBehavior:re,annotations:_,svgAnnotationRules:B,tickFormatTime:T,tickFormatValue:N,decay:H,pulse:R,staleness:W,transition:F,pointIdAccessor:t.pointIdAccessor,legendPosition:X,brush:ie||(K?{dimension:"x"}:void 0),onBrush:ie||K?ce:void 0})});gs.displayName="RealtimeTemporalHistogram";const fs=gs,ps=e.forwardRef(function(t,n){var o,r,i,a;const s=Qn(t.mode,{width:null!==(r=null===(o=t.size)||void 0===o?void 0:o[0])&&void 0!==r?r:t.width,height:null!==(a=null===(i=t.size)||void 0===i?void 0:i[1])&&void 0!==a?a:t.height,enableHover:null!=t.enableHover?!!t.enableHover:void 0}),{size:l,margin:c,className:u,arrowOfTime:d="right",windowMode:h="sliding",windowSize:g=200,data:f,timeAccessor:y,valueAccessor:m,timeExtent:v,valueExtent:b,extentPadding:x,categoryAccessor:k,colors:w,radius:A,fill:S,opacity:O,stroke:E,strokeWidth:M,background:j,tooltipContent:C,tooltip:P,onHover:L,annotations:_,svgAnnotationRules:B,tickFormatTime:T,tickFormatValue:N,linkedHover:D,selection:I,onObservation:H,chartId:R,loading:W,emptyContent:F,emphasis:z,legendPosition:$}=t,G=s.showAxes,Y=s.enableHover,q=null!=c?c:s.marginDefaults,X=null!=l?l:[s.width,s.height],V=null!=C?C:P,U=e.useRef(null),{customHoverBehavior:K}=qn({selection:I,linkedHover:D,unwrapData:!0,onObservation:H,chartType:"RealtimeSwarmChart",chartId:R}),Q=e.useCallback(e=>{L&&L(e),K(e)},[L,K]);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=U.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=U.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;return null===(e=U.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=U.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const Z=zo(W,X[0],X[1]),J=Z?null:Fo(f,X[0],X[1],F),ee={};return null!=A&&(ee.radius=A),null!=S&&(ee.fill=S),null!=O&&(ee.opacity=O),null!=E&&(ee.stroke=E),null!=M&&(ee.strokeWidth=M),Z||J||p.createElement(hn,{ref:U,chartType:"swarm",runtimeMode:"streaming",size:X,margin:q,className:z?`${u||""} semiotic-emphasis-${z}`.trim():u,arrowOfTime:d,windowMode:h,windowSize:g,data:f,timeAccessor:y,valueAccessor:m,xExtent:v,yExtent:b,extentPadding:x,categoryAccessor:k,barColors:w,swarmStyle:ee,showAxes:G,background:j,hoverAnnotation:Y,tooltipContent:V,customHoverBehavior:Q,annotations:_,svgAnnotationRules:B,tickFormatTime:T,tickFormatValue:N,legendPosition:$,pointIdAccessor:t.pointIdAccessor})});ps.displayName="RealtimeSwarmChart";const ys=e.forwardRef(function(t,n){var o,r,i,a;const s=Qn(t.mode,{width:null!==(r=null===(o=t.size)||void 0===o?void 0:o[0])&&void 0!==r?r:t.width,height:null!==(a=null===(i=t.size)||void 0===i?void 0:i[1])&&void 0!==a?a:t.height,enableHover:null!=t.enableHover?!!t.enableHover:void 0}),{size:l,margin:c,className:u,arrowOfTime:d="right",windowMode:h="sliding",windowSize:g=200,data:f,timeAccessor:y,valueAccessor:m,timeExtent:v,valueExtent:b,extentPadding:x,positiveColor:k,negativeColor:w,connectorStroke:A,connectorWidth:S,gap:O,stroke:E,strokeWidth:M,background:j,tooltipContent:C,tooltip:P,onHover:L,annotations:_,svgAnnotationRules:B,tickFormatTime:T,tickFormatValue:N,linkedHover:D,selection:I,onObservation:H,chartId:R,loading:W,emptyContent:F,emphasis:z,legendPosition:$}=t,G=s.showAxes,Y=s.enableHover,q=null!=c?c:s.marginDefaults,X=null!=l?l:[s.width,s.height],V=null!=C?C:P,U=e.useRef(null),{customHoverBehavior:K}=qn({selection:I,linkedHover:D,unwrapData:!0,onObservation:H,chartType:"RealtimeWaterfallChart",chartId:R}),Q=e.useCallback(e=>{L&&L(e),K(e)},[L,K]);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=U.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=U.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;return null===(e=U.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=U.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const Z=zo(W,X[0],X[1]),J=Z?null:Fo(f,X[0],X[1],F),ee={};return null!=k&&(ee.positiveColor=k),null!=w&&(ee.negativeColor=w),null!=A&&(ee.connectorStroke=A),null!=S&&(ee.connectorWidth=S),null!=O&&(ee.gap=O),null!=E&&(ee.stroke=E),null!=M&&(ee.strokeWidth=M),Z||J||p.createElement(hn,{ref:U,chartType:"waterfall",runtimeMode:"streaming",size:X,margin:q,className:z?`${u||""} semiotic-emphasis-${z}`.trim():u,arrowOfTime:d,windowMode:h,windowSize:g,data:f,timeAccessor:y,valueAccessor:m,xExtent:v,yExtent:b,extentPadding:x,waterfallStyle:ee,showAxes:G,background:j,hoverAnnotation:Y,tooltipContent:V,customHoverBehavior:Q,annotations:_,svgAnnotationRules:B,tickFormatTime:T,tickFormatValue:N,legendPosition:$,pointIdAccessor:t.pointIdAccessor})});ys.displayName="RealtimeWaterfallChart";const ms=e.forwardRef(function(t,n){var o,r,i,a;const s=Qn(t.mode,{width:null!==(r=null===(o=t.size)||void 0===o?void 0:o[0])&&void 0!==r?r:t.width,height:null!==(a=null===(i=t.size)||void 0===i?void 0:i[1])&&void 0!==a?a:t.height,enableHover:null!=t.enableHover?!!t.enableHover:void 0}),{size:l,margin:c,className:u,arrowOfTime:d="right",windowMode:h="sliding",windowSize:g=200,data:f,timeAccessor:y,valueAccessor:m,categoryAccessor:v,timeExtent:b,valueExtent:x,extentPadding:k,heatmapXBins:w=20,heatmapYBins:A=20,aggregation:S="count",background:O,tooltipContent:E,tooltip:M,onHover:j,annotations:C,svgAnnotationRules:P,tickFormatTime:L,tickFormatValue:_,decay:B,pulse:T,staleness:N,linkedHover:D,selection:I,onObservation:H,chartId:R,loading:W,emptyContent:F,emphasis:z,legendPosition:$}=t,G=s.showAxes,Y=s.enableHover,q=null!=c?c:s.marginDefaults,X=null!=l?l:[s.width,s.height],V=null!=E?E:M,U=e.useRef(null),{customHoverBehavior:K}=qn({selection:I,linkedHover:D,unwrapData:!0,onObservation:H,chartType:"RealtimeHeatmap",chartId:R}),Q=e.useCallback(e=>{j&&j(e),K(e)},[j,K]);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=U.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=U.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;return null===(e=U.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=U.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const Z=zo(W,X[0],X[1]),J=Z?null:Fo(f,X[0],X[1],F);return Z||J||p.createElement(hn,{ref:U,chartType:"heatmap",runtimeMode:"streaming",size:X,margin:q,className:z?`${u||""} semiotic-emphasis-${z}`.trim():u,arrowOfTime:d,windowMode:h,windowSize:g,data:f,timeAccessor:y,valueAccessor:m,categoryAccessor:v,xExtent:b,yExtent:x,extentPadding:k,heatmapXBins:w,heatmapYBins:A,heatmapAggregation:S,showAxes:G,background:O,hoverAnnotation:Y,tooltipContent:V,customHoverBehavior:Q,annotations:C,svgAnnotationRules:P,tickFormatTime:L,tickFormatValue:_,decay:B,pulse:T,staleness:N,legendPosition:$,pointIdAccessor:t.pointIdAccessor})});ms.displayName="RealtimeHeatmap";let[vs]=jt(e=>({tooltip:null,changeTooltip(t){e(()=>({tooltip:t}))}}));function bs(e,t){return Go(this,void 0,void 0,function*(){const{format:n="png",filename:o="chart",scale:r=2,background:i="white"}=t||{},a=e.querySelector("svg");if(!a)throw Error("No SVG element found in the container");const s=a.cloneNode(!0),l=a.getBoundingClientRect();if(s.getAttribute("width")||s.setAttribute("width",l.width+""),s.getAttribute("height")||s.setAttribute("height",l.height+""),s.getAttribute("xmlns")||s.setAttribute("xmlns","http://www.w3.org/2000/svg"),xs(a,s),"svg"===n){const e=(new XMLSerializer).serializeToString(s);ks(new Blob([e],{type:"image/svg+xml;charset=utf-8"}),o+".svg")}else{const t=l.width*r,n=l.height*r,a=document.createElement("canvas");a.width=t,a.height=n;const c=a.getContext("2d");c.fillStyle=i,c.fillRect(0,0,t,n),c.scale(r,r);const u=e.querySelector("canvas");u&&c.drawImage(u,0,0,l.width,l.height);const d=(new XMLSerializer).serializeToString(s),h=new Blob([d],{type:"image/svg+xml;charset=utf-8"}),g=URL.createObjectURL(h),f=new Image;f.width=l.width,f.height=l.height,yield new Promise((e,t)=>{f.onload=()=>{c.drawImage(f,0,0),a.toBlob(n=>{n?(ks(n,o+".png"),e()):t(Error("Failed to create PNG blob"))},"image/png"),URL.revokeObjectURL(g)},f.onerror=()=>{URL.revokeObjectURL(g),t(Error("Failed to load SVG image"))},f.src=g})}})}function xs(e,t){var n;const o=e.children,r=t.children,i=window.getComputedStyle(e),a=["fill","stroke","stroke-width","stroke-dasharray","opacity","fill-opacity","stroke-opacity","font-family","font-size","font-weight","text-anchor","dominant-baseline"];for(const e of a){const o=i.getPropertyValue(e);o&&"none"!==o&&""!==o&&(null===(n=t.style)||void 0===n||n.setProperty(e,o))}for(let e=0;Math.min(o.length,r.length)>e;e++)xs(o[e],r[e])}function ks(e,t){const n=URL.createObjectURL(e),o=document.createElement("a");o.href=n,o.download=t,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(n)}const ws=new Set(["tooltip","onObservation","xFormat","yFormat","valueFormat","svgAnnotationRules","tooltipContent","onHover","tickFormatTime","tickFormatValue","edgeSort","sortGroups","centerContent","frameProps","controls","oFormat","rFormat","oSort","pieceStyle","summaryStyle","nodeStyle","edgeStyle","customHoverBehavior","customClickBehavior","customDoubleClickBehavior","onBrush","onTopologyChange","backgroundGraphics","foregroundGraphics","legend"]),As=new Set(["data","nodes","edges"]),Ss="function"==typeof structuredClone?structuredClone:e=>JSON.parse(JSON.stringify(e));function Os(e){return Go(this,arguments,void 0,function*(e,t="json"){const n="jsx"===t?Es(e):JSON.stringify(e,null,2);if("undefined"==typeof navigator||!navigator.clipboard)throw Error("Clipboard API not available. copyConfig requires a browser environment.");yield navigator.clipboard.writeText(n)})}function Es(e){const{component:t,props:n}=e,o=["<"+t];for(const[e,t]of Object.entries(n))if("string"==typeof t)o.push(` ${e}="${t}"`);else if("boolean"==typeof t&&!0===t)o.push(" "+e);else if("boolean"==typeof t&&!1===t)o.push(` ${e}={false}`);else if("number"==typeof t)o.push(` ${e}={${t}}`);else{const n=JSON.stringify(t);o.push(80>n.length?` ${e}={${n}}`:` ${e}={${JSON.stringify(t,null,2)}}`)}return o.push("/>"),o.join("\n")}function Ms(){const e=function(){const e=p.useContext(rt);return e?()=>e.setVisible(e=>!e):null}();return e?p.createElement("button",{className:"semiotic-chart-action",onClick:e,title:"Data summary","aria-label":"Toggle data summary",style:_s},p.createElement("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},p.createElement("rect",{x:"1",y:"1",width:"12",height:"3",rx:"0.5"}),p.createElement("rect",{x:"1",y:"6",width:"8",height:"3",rx:"0.5"}),p.createElement("rect",{x:"1",y:"11",width:"5",height:"2",rx:"0.5"}))):null}const js={live:{bg:"#22c55e",color:"#fff"},stale:{bg:"#ef4444",color:"#fff"},paused:{bg:"#eab308",color:"#000"},error:{bg:"#ef4444",color:"#fff"},static:{bg:"#6b7280",color:"#fff"}};function Cs({height:e}){return p.createElement("div",{role:"status","aria-busy":"true","aria-label":"Loading chart",style:{width:"100%",height:e,background:"linear-gradient(90deg, var(--semiotic-border, #e0e0e0) 25%, var(--semiotic-bg, #f5f5f5) 50%, var(--semiotic-border, #e0e0e0) 75%)",backgroundSize:"200% 100%",animation:"semiotic-skeleton-pulse 1.5s ease-in-out infinite",borderRadius:4}})}function Ps({error:e}){return p.createElement("div",{role:"alert",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",minHeight:120,padding:24,boxSizing:"border-box"}},p.createElement("div",{style:{textAlign:"center",maxWidth:400,fontSize:14,color:"var(--semiotic-text-secondary, #666)",lineHeight:1.5}},e))}const Ls=p.forwardRef(function({title:e,subtitle:t,children:n,width:o="100%",height:r=400,actions:i,chartConfig:a,controls:s,loading:l=!1,error:c,errorBoundary:u=!1,status:d,detailsPanel:h,className:g,style:f},y){const m=p.useRef(null),v=p.useRef(null),[b,x]=p.useState(!1),k=!1!==(null==i?void 0:i.export)&&void 0!==(null==i?void 0:i.export),w=!1!==(null==i?void 0:i.fullscreen)&&void 0!==(null==i?void 0:i.fullscreen),A=!1!==(null==i?void 0:i.copyConfig)&&void 0!==(null==i?void 0:i.copyConfig)&&a,S=!0===(null==i?void 0:i.dataSummary),O="object"==typeof(null==i?void 0:i.export)?i.export:{},E="object"==typeof(null==i?void 0:i.copyConfig)?i.copyConfig.format:"json",M=p.useCallback(e=>Go(this,void 0,void 0,function*(){v.current&&(yield bs(v.current,Object.assign(Object.assign({},O),e)))}),[O]),j=p.useCallback(()=>{m.current&&(document.fullscreenElement?document.exitFullscreen().catch(()=>{}):m.current.requestFullscreen().catch(()=>{}))},[]),C=p.useCallback(e=>Go(this,void 0,void 0,function*(){a&&(yield Os(a,e||E||"json"))}),[a,E]);p.useEffect(()=>{const e=()=>{x(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",e),()=>document.removeEventListener("fullscreenchange",e)},[]),p.useImperativeHandle(y,()=>({export:M,toggleFullscreen:j,copyConfig:C,element:m.current}),[M,j,C]);const P=e||t||s||k||w||A||S||d,L=l?p.createElement(Cs,{height:r}):c?p.createElement(Ps,{error:c}):u?p.createElement(uo,null,n):n;return _=p.createElement(p.Fragment,null,p.createElement("style",{dangerouslySetInnerHTML:{__html:"@keyframes semiotic-skeleton-pulse {\n 0% { background-position: 200% 0; }\n 100% { background-position: -200% 0; }\n}"}}),p.createElement("div",{ref:m,className:"semiotic-chart-container"+(g?" "+g:""),style:Object.assign(Object.assign({width:o,border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:"var(--semiotic-border-radius, 8px)",overflow:"hidden",background:"var(--semiotic-bg, #fff)",fontFamily:"var(--semiotic-font-family, sans-serif)",position:"relative"},b?{display:"flex",flexDirection:"column",width:"100%",height:"100%"}:{}),f)},P&&p.createElement("div",{className:"semiotic-chart-header",style:{padding:"12px 16px",display:"flex",justifyContent:"space-between",alignItems:"flex-start",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"}},p.createElement("div",{className:"semiotic-chart-title-area"},e&&p.createElement("div",{className:"semiotic-chart-title",style:{fontSize:14,fontWeight:600,color:"var(--semiotic-text, #333)"}},e),t&&p.createElement("div",{className:"semiotic-chart-subtitle",style:{fontSize:12,color:"var(--semiotic-text-secondary, #666)",marginTop:e?2:0}},t)),p.createElement("div",{className:"semiotic-chart-toolbar",style:{display:"flex",alignItems:"center",gap:4}},s,k&&p.createElement("button",{className:"semiotic-chart-action",onClick:()=>M(),title:"Export chart","aria-label":"Export chart",style:_s},p.createElement("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},p.createElement("path",{d:"M7 2v8M3.5 7L7 10.5 10.5 7"}),p.createElement("path",{d:"M2 12h10"}))),S&&p.createElement(Ms,null),w&&p.createElement("button",{className:"semiotic-chart-action",onClick:j,title:b?"Exit fullscreen":"Fullscreen","aria-label":b?"Exit fullscreen":"Enter fullscreen",style:_s},p.createElement("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},b?p.createElement(p.Fragment,null,p.createElement("path",{d:"M9 1v4h4"}),p.createElement("path",{d:"M5 13V9H1"}),p.createElement("path",{d:"M13 5H9V1"}),p.createElement("path",{d:"M1 9h4v4"})):p.createElement(p.Fragment,null,p.createElement("path",{d:"M1 5V1h4"}),p.createElement("path",{d:"M13 9v4H9"}),p.createElement("path",{d:"M9 1h4v4"}),p.createElement("path",{d:"M5 13H1V9"})))),A&&p.createElement("button",{className:"semiotic-chart-action",onClick:()=>C(),title:"Copy config","aria-label":"Copy chart configuration",style:_s},p.createElement("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},p.createElement("rect",{x:"5",y:"5",width:"8",height:"8",rx:"1"}),p.createElement("path",{d:"M9 5V2a1 1 0 00-1-1H2a1 1 0 00-1 1v6a1 1 0 001 1h3"}))),d&&p.createElement("div",{className:"semiotic-chart-status","aria-live":"polite","aria-atomic":"true",style:{padding:"2px 8px",borderRadius:4,fontSize:10,fontWeight:700,letterSpacing:"0.05em",textTransform:"uppercase",background:js[d].bg,color:js[d].color,lineHeight:"18px"}},d))),p.createElement("div",{className:"semiotic-chart-body",ref:v,style:Object.assign({position:"relative",overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center"},b?{flex:1}:{height:r})},L,h))),S?p.createElement(it,null,_):_;var _}),_s={width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",border:"none",background:"transparent",cursor:"pointer",borderRadius:4,color:"var(--semiotic-text-secondary, #666)",padding:0};function Bs({children:e,columns:t="auto",minCellWidth:n=300,gap:o=16,className:r,style:i}){const a="number"==typeof t?t:void 0;return p.createElement("div",{className:"semiotic-chart-grid"+(r?" "+r:""),style:Object.assign({display:"grid",gridTemplateColumns:"auto"===t?`repeat(auto-fill, minmax(${n}px, 1fr))`:`repeat(${t}, 1fr)`,gap:o,width:"100%"},i)},p.Children.map(e,e=>p.isValidElement(e)?"primary"!==e.props.emphasis||void 0!==a&&2>a?e:p.createElement("div",{style:{gridColumn:"span 2"}},e):e))}function Ts({children:e,context:t,position:n="right",contextSize:o=250,gap:r=12,className:i,style:a}){const s="left"===n||"right"===n,l="left"===n||"top"===n,c=Object.assign({display:"flex",flexDirection:s?l?"row-reverse":"row":l?"column-reverse":"column",gap:r,width:"100%"},a),u=s?{flex:`0 0 ${o}px`,width:o,minHeight:0}:{flex:`0 0 ${o}px`,height:o,minWidth:0};return p.createElement("div",{className:"semiotic-context-layout"+(i?" "+i:""),style:c},p.createElement("div",{style:{flex:"1 1 0%",minWidth:0,minHeight:0}},e),p.createElement("div",{style:u},t))}Bs.displayName="ChartGrid",Ts.displayName="ContextLayout";function Ns({children:t,position:n="right",size:o=300,trigger:r="click",chartId:i,observation:a,dismissOnEmpty:s=!0,showClose:l=!0,onToggle:c,className:u,style:d}){const[h,g]=e.useState(null),[f,y]=e.useState(null),[m,v]=e.useState(!1),[b,x]=e.useState(!1),k=e.useRef(null),w=e.useRef(),A="click"===r?["click","click-end"]:["hover","hover-end"],{latest:S}=En({types:A,chartId:i,limit:1}),O=void 0!==a?a:S;e.useEffect(()=>{if(O)if("click"===O.type||"hover"===O.type){const e=O;g(e.datum),y(e),m||(v(!0),x(!0),clearTimeout(w.current),w.current=setTimeout(()=>x(!1),200))}else!s||"click-end"!==O.type&&"hover-end"!==O.type||E()},[O]),e.useEffect(()=>{null==c||c(m)},[m,c]);const E=e.useCallback(()=>{x(!0),v(!1),clearTimeout(w.current),w.current=setTimeout(()=>{x(!1),g(null),y(null)},200)},[]);if(e.useEffect(()=>()=>clearTimeout(w.current),[]),!h&&!b)return null;const M=h&&f?t(h,f):null;if(null===M&&!b)return null;const j=function(e,t,n,o){const r={position:"absolute",background:"var(--semiotic-bg, #fff)",borderColor:"var(--semiotic-border, #e0e0e0)",borderStyle:"solid",borderWidth:0,boxSizing:"border-box",zIndex:10,display:"flex",flexDirection:"column",transition:o?"transform 200ms ease-out, opacity 200ms ease-out":void 0};return Object.assign(Object.assign({},r),"right"===e?{top:0,right:0,width:t,height:"100%",borderLeftWidth:1,padding:"12px 16px",transform:n?"translateX(0)":`translateX(${t}px)`,opacity:n?1:0}:"bottom"===e?{bottom:0,left:0,width:"100%",height:t,borderTopWidth:1,padding:"12px 16px",transform:n?"translateY(0)":`translateY(${t}px)`,opacity:n?1:0}:{top:"50%",left:"50%",transform:n?"translate(-50%, -50%) scale(1)":"translate(-50%, -50%) scale(0.95)",opacity:n?1:0,width:Math.min(t,400),maxHeight:"80%",borderWidth:1,borderRadius:8,padding:"16px 20px",boxShadow:"0 8px 32px rgba(0,0,0,0.12)"})}(n,o,m,b);return p.createElement("div",{ref:k,className:`semiotic-details-panel semiotic-details-${n}${u?" "+u:""}`,style:Object.assign(Object.assign({},j),d)},l&&p.createElement("button",{className:"semiotic-details-close",onClick:E,"aria-label":"Close details",style:Ds},p.createElement("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"},p.createElement("path",{d:"M2 2l8 8M10 2l-8 8"}))),p.createElement("div",{className:"semiotic-details-content",style:{overflow:"auto",flex:1}},M))}const Ds={position:"absolute",top:8,right:8,width:20,height:20,display:"flex",alignItems:"center",justifyContent:"center",border:"none",background:"transparent",cursor:"pointer",borderRadius:4,color:"var(--semiotic-text-secondary, #666)",padding:0,zIndex:1};function Is(e){return"nominal"===e||"ordinal"===e}function Hs(e){return"quantitative"===e||"temporal"===e}Ns.displayName="DetailsPanel";const Rs={category10:"category10",category20:"category20",category20b:"category20",category20c:"category20",accent:"accent",dark2:"dark2",paired:"paired",pastel1:"pastel1",pastel2:"pastel2",set1:"set1",set2:"set2",set3:"set3",tableau10:"category10",tableau20:"category20"},Ws={linear:"linear","monotone-x":"monotoneX","monotone-y":"monotoneY",monotone:"monotoneX",step:"step","step-after":"stepAfter","step-before":"stepBefore",basis:"basis",cardinal:"cardinal","catmull-rom":"catmullRom"},Fs={sum:"sum",mean:"mean",average:"mean",count:"count",min:"min",max:"max",median:"mean"};function zs(e,t,n,o,r){var i,a;(null==e?void 0:e.field)&&(n.xAccessor=o?"value":e.field),(null==t?void 0:t.field)&&(n.yAccessor=r?"value":t.field),(null===(i=null==e?void 0:e.axis)||void 0===i?void 0:i.title)&&(n.xLabel=e.axis.title),(null===(a=null==t?void 0:t.axis)||void 0===a?void 0:a.title)&&(n.yLabel=t.axis.title)}function $s(e,t,n){const o={component:e,props:t,version:"1",createdAt:(new Date).toISOString()};if(n.length>0){o.warnings=n;for(const e of n)console.warn("[semiotic/fromVegaLite] "+e)}return o}function Gs(e,t=.5){const n=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!n)return e;const o=Math.round(parseInt(n[1],16)*(1-t)),r=Math.round(parseInt(n[2],16)*(1-t)),i=Math.round(parseInt(n[3],16)*(1-t));return`#${o.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}`}function Ys(e,t=.5){const n=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!n)return e;const o=Math.round(parseInt(n[1],16)+(255-parseInt(n[1],16))*t),r=Math.round(parseInt(n[2],16)+(255-parseInt(n[2],16))*t),i=Math.round(parseInt(n[3],16)+(255-parseInt(n[3],16))*t);return`#${o.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}`}const qs="__forecastSegment";function Xs(e,t){return"function"==typeof t?t(e):!!e[t]}const Vs=Object.freeze({__proto__:null,SEGMENT_FIELD:qs,buildAnomalyAnnotations:function(e){var t,n,o;return[{type:"anomaly-band",threshold:null!==(t=e.threshold)&&void 0!==t?t:2,showBand:!1!==e.showBand,fill:e.bandColor||"#6366f1",fillOpacity:null!==(n=e.bandOpacity)&&void 0!==n?n:.1,anomalyColor:e.anomalyColor||"#ef4444",anomalyRadius:null!==(o=e.anomalyRadius)&&void 0!==o?o:6,label:e.label}]},buildForecast:function(e,t,n,o,r){return(i=o).isTraining||i.isForecast||i.isAnomaly||i.upperBounds||i.lowerBounds?function(e,t,n,o,r){var i,a,s,l;const{isTraining:c,isForecast:u,isAnomaly:d,upperBounds:h,lowerBounds:g,color:f="#6366f1",bandOpacity:p=.15,anomalyColor:y="#ef4444",anomalyRadius:m=6,label:v}=o,b=e.map(e=>{let t="observed";return u&&Xs(e,u)?t="forecast":c&&Xs(e,c)&&(t="training"),Object.assign(Object.assign({},e),{[qs]:t})}),x=o._groupBy,k=[];if(x){const e=new Map;for(const t of b){const n=null!==(i=t[x])&&void 0!==i?i:"__default";e.has(n)||e.set(n,[]),e.get(n).push(t)}const t=[];for(const[,n]of e)for(let e=0;n.length-1>e;e++)n[e][qs]!==n[e+1][qs]&&(t.push(Object.assign(Object.assign({},n[e+1]),{[qs]:n[e][qs]})),t.push(Object.assign(Object.assign({},n[e]),{[qs]:n[e+1][qs]})));k.push(...b,...t)}else for(let e=0;b.length>e;e++)k.push(b[e]),b.length-1>e&&b[e][qs]!==b[e+1][qs]&&(k.push(Object.assign(Object.assign({},b[e+1]),{[qs]:b[e][qs]})),k.push(Object.assign(Object.assign({},b[e]),{[qs]:b[e+1][qs]})));if(o.trainUnderline){const e=[];for(const t of k)"training"===t[qs]&&e.push(Object.assign(Object.assign({},t),{[qs]:"training-base"}));k.unshift(...e)}const w=[];if(h&&g){const e="string"==typeof h?h:"__envUpper",t="string"==typeof g?g:"__envLower";if("function"==typeof h||"function"==typeof g)for(const n of k)"function"==typeof h&&(n[e]=h(n)),"function"==typeof g&&(n[t]=g(n));w.push({type:"envelope",upperAccessor:e,lowerAccessor:t,fill:f,fillOpacity:p,label:v})}if(d){const e=o.anomalyStyle,t={type:"highlight",filter:e=>Xs(e,d)};e?(t.style=e,t.r=m):"function"==typeof y?(t.style=e=>{const t=y(e);return{stroke:t,strokeWidth:1.5,fill:t,fillOpacity:.7}},t.r=m):(t.color=y,t.r=m,t.style={stroke:y,strokeWidth:1.5,fill:y,fillOpacity:.7}),w.push(t)}return r&&w.push({type:"anomaly-band",threshold:null!==(a=r.threshold)&&void 0!==a?a:2,showBand:!1!==r.showBand,fill:r.bandColor||"#6366f1",fillOpacity:null!==(s=r.bandOpacity)&&void 0!==s?s:.1,anomalyColor:r.anomalyColor||"#ef4444",anomalyRadius:null!==(l=r.anomalyRadius)&&void 0!==l?l:6,label:r.label}),{processedData:k,annotations:w}}(e,0,0,o,r):function(e,t,n,o,r){var i,a,s;const{trainEnd:l,steps:c=10,confidence:u=.95,color:d="#6366f1",bandOpacity:h=.15,label:g}=o;if(null==l)return{processedData:e,annotations:[]};const f=[],p=[];for(const n of e)n[t]>l?p.push(Object.assign(Object.assign({},n),{[qs]:"observed"})):f.push(Object.assign(Object.assign({},n),{[qs]:"training"}));const y=f.map(e=>[e[t],e[n]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]),m=[],v=[];if(y.length>=3){const o=y.length;let r=0,i=0,a=0,s=0;for(const[e,t]of y)r+=e,i+=t,a+=e*e,s+=e*t;const l=o*a-r*r;if(Math.abs(l)>1e-12){const a=(o*s-r*i)/l,f=(i-a*r)/o,p=e=>f+a*e,b=y.map(([e,t])=>t-p(e)).reduce((e,t)=>e+t*t,0),x=Math.sqrt(b/Math.max(o-2,1)),k=y.reduce((e,t)=>e+t[0],0)/o,w=y.reduce((e,t)=>e+Math.pow(t[0]-k,2),0),A=.99>u?.95>u?.9>u?1:1.645:1.96:2.576,S=e.map(e=>e[t]).filter(e=>null!=e&&isFinite(e)),O=Math.max(...S),E=y.length>1?(y[o-1][0]-y[0][0])/(o-1):1;for(let e=1;c>=e;e++){const r=O+e*E,i=p(r),a=x*Math.sqrt(1+1/o+(w>0?Math.pow(r-k,2)/w:0))*A;v.push({[t]:r,[n]:i,[qs]:"forecast",__forecastUpper:i+a,__forecastLower:i-a})}m.push({type:"envelope",upperAccessor:"__forecastUpper",lowerAccessor:"__forecastLower",fill:d,fillOpacity:h,label:g})}}m.push({type:"x-threshold",x:l,color:"#94a3b8",strokeWidth:1,strokeDasharray:"4,2",label:"Train / Forecast"}),r&&m.push({type:"anomaly-band",threshold:null!==(i=r.threshold)&&void 0!==i?i:2,showBand:!1!==r.showBand,fill:r.bandColor||"#6366f1",fillOpacity:null!==(a=r.bandOpacity)&&void 0!==a?a:.1,anomalyColor:r.anomalyColor||"#ef4444",anomalyRadius:null!==(s=r.anomalyRadius)&&void 0!==s?s:6,label:r.label});const b=[];if(b.push(...f),f.length>0&&p.length>0&&b.push(Object.assign(Object.assign({},f[f.length-1]),{[qs]:"observed"})),b.push(...p),v.length>0){const e=p.length>0?p[p.length-1]:f[f.length-1];e&&b.push(Object.assign(Object.assign({},e),{[qs]:"forecast"})),b.push(...v)}return{processedData:b,annotations:m}}(e,t,n,o,r);var i},createSegmentLineStyle:function(e,t){var n,o;const r=null!==(n=t.trainDasharray)&&void 0!==n?n:"8,4",i=null!==(o=t.forecastDasharray)&&void 0!==o?o:"4,4",a=t.color||"#6366f1",s=t.trainOpacity,l=t.forecastOpacity,c=t.trainStroke,u=t.trainLinecap,d=t.trainUnderline;return t=>{const n=e(t),o=t[qs];if("training"===o){let e=n.stroke;return"darken"===c?e=Gs(n.stroke||"#666",.5):c&&(e=c),Object.assign(Object.assign(Object.assign(Object.assign({},n),{stroke:e,strokeDasharray:r}),u&&{strokeLinecap:u}),null!=s&&{strokeOpacity:s})}if("training-base"===o){let e=n.stroke||"#666";return"lighten"===d&&(e=Ys(e,.4)),Object.assign(Object.assign({},n),{stroke:e,strokeDasharray:void 0})}return"forecast"===o?Object.assign(Object.assign(Object.assign({},n),{stroke:a,strokeDasharray:i}),null!=l&&{strokeOpacity:l}):n}},darkenColor:Gs,lightenColor:Ys});exports.AreaChart=Uo,exports.BarChart=Ur,exports.BoxPlot=ni,exports.BubbleChart=nr,exports.CategoryColorProvider=fn,exports.ChartContainer=Ls,exports.ChartGrid=Bs,exports.ChordDiagram=is,exports.CirclePack=cs,exports.ConnectedScatterplot=tr,exports.ContextLayout=Ts,exports.DetailsPanel=Ns,exports.DonutChart=li,exports.DotPlot=ii,exports.ForceDirectedGraph=es,exports.FunnelChart=ci,exports.GroupedBarChart=Zr,exports.Heatmap=or,exports.Histogram=oi,exports.LikertChart=yi,exports.LineChart=Vo,exports.LinkedCharts=Pn,exports.MultiAxisLineChart=mr,exports.MultiLineTooltip=function(e={}){const{fields:t=[],title:n,format:o,style:r={},className:i="",showLabels:a=!0,separator:s=": "}=e;return e=>{if(!e||"object"!=typeof e)return null;const l=[];if(n){const t=eo(e,n);l.push({value:to(t,o)})}t&&Array.isArray(t)&&t.length>0?t.forEach(t=>{let n,r,i;"string"==typeof t?(n=t,r=t,i=o):(n=t.label,r=t.accessor||t.key||"",i=t.format||o);const s=to(eo(e,r),i);l.push({label:a?n:void 0,value:s})}):Object.keys(e).filter(e=>!e.startsWith("_")&&"data"!==e).forEach(t=>{l.push({label:a?t:void 0,value:to(e[t],o)})});const c=Object.assign(Object.assign({},Jn),r);return Array.isArray(l)&&0!==l.length?p.createElement("div",{className:("semiotic-tooltip semiotic-tooltip-multiline "+i).trim(),style:c},l.map((e,t)=>p.createElement("div",{key:t,style:{marginBottom:l.length-1>t?"4px":0}},e.label&&p.createElement("strong",null,e.label,s),e.value))):null}},exports.OrbitDiagram=ds,exports.PieChart=si,exports.QuadrantChart=hr,exports.RealtimeHeatmap=ms,exports.RealtimeHistogram=fs,exports.RealtimeLineChart=hs,exports.RealtimeSwarmChart=ps,exports.RealtimeWaterfallChart=ys,exports.RidgelinePlot=ai,exports.SankeyDiagram=as,exports.Scatterplot=Jo,exports.ScatterplotMatrix=dr,exports.StackedAreaChart=Qo,exports.StackedBarChart=Qr,exports.SwarmPlot=ei,exports.ThemeProvider=function({theme:e,children:t}){const n="string"==typeof e&&Nn(e)?e:void 0;return p.createElement(Bt,null,p.createElement(Dn.Provider,{value:n},p.createElement(In,{theme:e}),p.createElement(Hn,null,t)))},exports.TooltipProvider=vs,exports.TreeDiagram=ss,exports.Treemap=ls,exports.ViolinPlot=ri,exports.configToJSX=Es,exports.copyConfig=Os,exports.deserializeSelections=function(e){const t=new Map;for(const[n,o]of Object.entries(e)){const e=new Map;for(const t of o.clauses){const n={};for(const[e,o]of Object.entries(t.fields))n[e]="point"===o.type?{type:"point",values:new Set(o.values)}:{type:"interval",range:o.range};e.set(t.clientId,{clientId:t.clientId,type:t.type,fields:n})}t.set(n,{name:o.name,resolution:o.resolution,clauses:e})}return t},exports.diagnoseConfig=No,exports.exportChart=bs,exports.fromConfig=function(e){if(!e.component||!e.props)throw Error("Invalid chart config: missing component or props");if(!So[e.component])throw Error(`Unknown component "${e.component}". This config may require a newer version of semiotic.`);return{componentName:e.component,props:Ss(e.props)}},exports.fromURL=function(e){const t=new URLSearchParams(e.includes("?")?e.split("?")[1]:e).get("sc");if(!t)throw Error("No chart config found in URL (missing 'sc' parameter)");const n=t.replace(/-/g,"+").replace(/_/g,"/"),o=decodeURIComponent(escape(atob(n)));return JSON.parse(o)},exports.fromVegaLite=function(e){var t,n,o,r,i,a,s,l,c,u,d,h,g,f;const p=[],{type:y,markProps:m}=function(e){if("string"==typeof e)return{type:e,markProps:{}};const{type:t}=e;return{type:t,markProps:function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&0>t.indexOf(o)&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);o.length>r;r++)0>t.indexOf(o[r])&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n}(e,["type"])}}(e.mark),v=e.encoding||{},b=v.x,x=v.y,k=v.color,w=v.size,A=v.theta,S=v.opacity;let O;(null===(t=e.data)||void 0===t?void 0:t.values)?O=e.data.values:(null===(n=e.data)||void 0===n?void 0:n.url)&&p.push("data.url is not supported — only inline data.values can be translated. Provide data manually."),e.transform&&e.transform.length>0&&p.push("Vega-Lite transforms are not supported. Pre-transform your data before passing to fromVegaLite()."),e.layer&&p.push('Layered specs ("layer") are not supported. Only single-mark specs can be translated.'),(e.hconcat||e.vconcat||e.concat)&&p.push('Concatenated views ("hconcat"/"vconcat"/"concat") are not supported. Translate each sub-spec individually.'),(e.facet||e.encoding&&e.encoding.facet||e.encoding&&(e.encoding.row||e.encoding.column))&&p.push("Faceted views are not supported. Use Semiotic's LinkedCharts or render multiple charts manually."),e.repeat&&p.push('Repeated views ("repeat") are not supported. Translate each field combination individually.'),(e.params||e.selection)&&p.push("Selections/params are not supported. Use Semiotic's LinkedCharts and selection props for interactivity.");const E={};e.width&&(E.width=e.width),e.height&&(E.height=e.height);const M=function(e){if(e)return"string"==typeof e?e:e.text}(e.title);if(M&&(E.title=M),(null==k?void 0:k.field)&&(E.colorBy=k.field,null===(o=k.scale)||void 0===o?void 0:o.scheme)){const e=Rs[k.scale.scheme];e&&(E.colorScheme=e)}void 0!==(null==S?void 0:S.value)&&(E.pointOpacity=S.value);const j=null==b?void 0:b.aggregate,C=null==x?void 0:x.aggregate;if(O&&(j||C)){const e=C?x:b,t=C?b:x,n=Fs[e.aggregate];if(n&&(null==t?void 0:t.field)&&e.field)O=function(e,t){const{groupBy:n,value:o,agg:r="sum"}=t,i=new Map;for(const t of e){const e=t[n]+"";i.has(e)||i.set(e,[]),i.get(e).push(Number(t[o]))}const a=[];for(const[e,t]of i){let o;switch(r){case"count":o=t.length;break;case"mean":o=t.reduce((e,t)=>e+t,0)/t.length;break;case"min":o=Math.min(...t);break;case"max":o=Math.max(...t);break;default:o=t.reduce((e,t)=>e+t,0)}a.push({[n]:e,value:o})}return a}(O,{groupBy:t.field,value:e.field,agg:n});else if(("count"===n||"count"===e.aggregate)&&(null==t?void 0:t.field)&&O){const e=new Map;for(const n of O){const o=n[t.field]+"";e.set(o,(e.get(o)||0)+1)}O=Array.from(e,([e,n])=>({[t.field]:e,value:n}))}}if((null==b?void 0:b.bin)||(null==x?void 0:x.bin)){const e="Histogram";O&&(E.data=O),(null==b?void 0:b.bin)?(E.valueAccessor=b.field,(null==x?void 0:x.field)&&(E.categoryAccessor=x.field),(null===(r=b.axis)||void 0===r?void 0:r.title)&&(E.valueLabel=b.axis.title)):(null==x?void 0:x.bin)&&(E.valueAccessor=x.field,(null==b?void 0:b.field)&&(E.categoryAccessor=b.field),(null===(i=x.axis)||void 0===i?void 0:i.title)&&(E.valueLabel=x.axis.title));const t="object"==typeof((null==b?void 0:b.bin)||(null==x?void 0:x.bin))?(null===(a=null==b?void 0:b.bin)||void 0===a?void 0:a.maxbins)||(null===(s=null==x?void 0:x.bin)||void 0===s?void 0:s.maxbins):void 0;return t&&(E.bins=t),$s(e,E,p)}let P;switch(y){case"bar":P=function(e,t,n,o,r,i,a){var s,l,c,u,d,h;let g;return(null==n?void 0:n.field)&&!1!==(null==e?void 0:e.stack)&&!1!==(null==t?void 0:t.stack)&&null!==(null==e?void 0:e.stack)&&null!==(null==t?void 0:t.stack)?(g="StackedBarChart",o.stackBy=n.field):g="BarChart",Is(null==e?void 0:e.type)&&Hs(null==t?void 0:t.type)?(o.categoryAccessor=e.field,o.valueAccessor=a?"value":t.field,(null===(s=null==e?void 0:e.axis)||void 0===s?void 0:s.title)&&(o.categoryLabel=e.axis.title),(null===(l=null==t?void 0:t.axis)||void 0===l?void 0:l.title)&&(o.valueLabel=t.axis.title)):Hs(null==e?void 0:e.type)&&Is(null==t?void 0:t.type)?(o.categoryAccessor=t.field,o.valueAccessor=i?"value":e.field,o.orientation="horizontal",(null===(c=null==t?void 0:t.axis)||void 0===c?void 0:c.title)&&(o.categoryLabel=t.axis.title),(null===(u=null==e?void 0:e.axis)||void 0===u?void 0:u.title)&&(o.valueLabel=e.axis.title)):((null==e?void 0:e.field)&&(o.categoryAccessor=e.field),(null==t?void 0:t.field)&&(o.valueAccessor=a?"value":t.field),(null===(d=null==e?void 0:e.axis)||void 0===d?void 0:d.title)&&(o.categoryLabel=e.axis.title),(null===(h=null==t?void 0:t.axis)||void 0===h?void 0:h.title)&&(o.valueLabel=t.axis.title)),r&&(o.data=r),g}(b,x,k,E,O,j,C);break;case"line":if(P="LineChart",zs(b,x,E,j,C),(null==k?void 0:k.field)&&(E.lineBy=k.field),m.interpolate){const e=Ws[m.interpolate];e&&(E.curve=e)}!0===m.point&&(E.showPoints=!0),O&&(E.data=O);break;case"area":if((null==k?void 0:k.field)?(P="StackedAreaChart",E.areaBy=k.field):P="AreaChart",zs(b,x,E,j,C),m.interpolate){const e=Ws[m.interpolate];e&&(E.curve=e)}void 0!==m.opacity&&(E.areaOpacity=m.opacity),O&&(E.data=O);break;case"point":case"circle":case"square":(null==w?void 0:w.field)?(P="BubbleChart",E.sizeBy=w.field,(null===(l=w.scale)||void 0===l?void 0:l.range)&&(E.sizeRange=w.scale.range)):P="Scatterplot",zs(b,x,E,j,C),O&&(E.data=O);break;case"rect":P="Heatmap",(null==b?void 0:b.field)&&(E.xAccessor=b.field),(null==x?void 0:x.field)&&(E.yAccessor=x.field),(null==k?void 0:k.field)&&(E.valueAccessor=k.field,delete E.colorBy),(null===(c=null==b?void 0:b.axis)||void 0===c?void 0:c.title)&&(E.xLabel=b.axis.title),(null===(u=null==x?void 0:x.axis)||void 0===u?void 0:u.title)&&(E.yLabel=x.axis.title),O&&(E.data=O);break;case"arc":m.innerRadius&&m.innerRadius>0?(P="DonutChart",E.innerRadius=m.innerRadius):P="PieChart",(null==A?void 0:A.field)?E.valueAccessor=A.field:(null==x?void 0:x.field)&&(E.valueAccessor=C?"value":x.field),(null==k?void 0:k.field)&&(E.categoryAccessor=k.field),(null==b?void 0:b.field)&&!(null==A?void 0:A.field)&&(E.categoryAccessor=b.field),O&&(E.data=O);break;case"tick":P="DotPlot",Is(null==b?void 0:b.type)?(E.categoryAccessor=b.field,(null==x?void 0:x.field)&&(E.valueAccessor=C?"value":x.field),(null===(d=null==b?void 0:b.axis)||void 0===d?void 0:d.title)&&(E.categoryLabel=b.axis.title),(null===(h=null==x?void 0:x.axis)||void 0===h?void 0:h.title)&&(E.valueLabel=x.axis.title)):Is(null==x?void 0:x.type)?(E.categoryAccessor=x.field,(null==b?void 0:b.field)&&(E.valueAccessor=j?"value":b.field),E.orientation="horizontal",(null===(g=null==x?void 0:x.axis)||void 0===g?void 0:g.title)&&(E.categoryLabel=x.axis.title),(null===(f=null==b?void 0:b.axis)||void 0===f?void 0:f.title)&&(E.valueLabel=b.axis.title)):((null==b?void 0:b.field)&&(E.categoryAccessor=b.field),(null==x?void 0:x.field)&&(E.valueAccessor=C?"value":x.field)),O&&(E.data=O);break;default:p.push(`Unsupported mark type "${y}". Defaulting to Scatterplot.`),P="Scatterplot",zs(b,x,E,j,C),O&&(E.data=O)}return $s(P,E,p)},exports.serializeSelections=function(e){const t={};for(const[n,o]of e){const e=[];for(const[,t]of o.clauses){const n={};for(const[e,o]of Object.entries(t.fields))n[e]="point"===o.type?{type:"point",values:Array.from(o.values)}:{type:"interval",range:o.range};e.push({clientId:t.clientId,type:t.type,fields:n})}t[n]={name:o.name,resolution:o.resolution,clauses:e}}return t},exports.toConfig=function(e,t,n){if(!So[e])throw Error(`Unknown component "${e}". Known components: ${Object.keys(So).join(", ")}`);const o=!1!==(null==n?void 0:n.includeData),r={};for(const[e,n]of Object.entries(t))null!=n&&(ws.has(e)||!o&&As.has(e)||"function"!=typeof n&&((null==n?void 0:n.$$typeof)||(r[e]=Ss(n))));return Object.assign({component:e,props:r,version:"1",createdAt:(new Date).toISOString()},(null==n?void 0:n.selections)?{selections:n.selections}:{})},exports.toURL=function(e){const t=JSON.stringify(e);return"sc="+btoa(unescape(encodeURIComponent(t))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")},exports.useBrushSelection=On,exports.useCategoryColors=pn,exports.useChartObserver=En,exports.useFilteredData=function(t,n,o){const r=xn(e=>e.selections.get(n));return e.useMemo(()=>{if(!r||0===r.clauses.size)return t;const e=mn(r,o);return t.filter(e)},[t,r,o])},exports.useLinkedHover=Sn,exports.useSelection=An,exports.useTheme=Rn,exports.validateProps=Eo;
|
|
1
|
+
"use strict";const e=require("react"),t=require("d3-selection"),n=require("d3-brush"),o=require("d3-scale"),r=require("d3-quadtree"),i=require("d3-scale-chromatic"),a=require("d3-array"),s=require("d3-hierarchy"),l=require("d3-shape"),c=require("regression"),u=require("d3-interpolate"),d=require("d3-force"),h=require("d3-chord");function g(e){return e&&e.__esModule?e:{default:e}}function f(e){if(e&&e.__esModule)return e;const t=Object.create(null);if(e)for(const n in e)if("default"!==n){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:function(){return e[n]}})}return t.default=e,Object.freeze(t)}const p=f(e),y=g(c);function m(e,t){let n=0,o=t.length-1;for(;o>n;){const r=n+o+1>>1;t[r]>e?o=r-1:n=r}return t[n]}function v(e,t){let n=0,o=t.length-1;for(;o>n;){const r=n+o>>1;e>t[r]?n=r+1:o=r}return t[n]}function b({width:o,height:r,totalWidth:i,totalHeight:a,margin:s,dimension:l,scales:c,onBrush:u,binSize:d,snap:h,binBoundaries:g,snapDuring:f,streaming:y}){const b=e.useRef(null),x=e.useRef(null),k=e.useRef(u);k.current=u;const w=e.useRef(c);w.current=c;const A=e.useMemo(()=>g?[...g].sort((e,t)=>e-t):void 0,[g]),S=e.useRef(A);S.current=A;const O=e.useRef(!1),E=e.useRef(null);return e.useEffect(()=>{if(!b.current)return;const e=t.select(b.current).select(".brush-g"),i="x"===l?n.brushX():"y"===l?n.brushY():n.brush();return i.extent([[0,0],[o,r]]),i.on("brush end",t=>{if(O.current)return;const n=w.current;if(!n)return;if(!t.selection)return E.current=null,void k.current(null);let a,s;if("x"===l){const[e,o]=t.selection;a=[n.x.invert(e),n.x.invert(o)],s=[n.y.invert(r),n.y.invert(0)]}else if("y"===l){const[e,r]=t.selection;a=[n.x.invert(0),n.x.invert(o)],s=[n.y.invert(r),n.y.invert(e)]}else{const[[e,o],[r,i]]=t.selection;a=[n.x.invert(e),n.x.invert(r)],s=[n.y.invert(i),n.y.invert(o)]}if("bin"===h&&"y"!==l&&("end"===t.type||"brush"===t.type&&f)){const o=S.current;o&&o.length>0?a=function(e,t){return 0===t.length?e:[m(e[0],t),v(e[1],t)]}(a,o):d&&d>0&&(a=[Math.floor(a[0]/d)*d,Math.ceil(a[1]/d)*d]);const r=n.x(a[0]),s=n.x(a[1]);if(O.current=!0,"x"===l)e.call(i.move,[r,s]);else if("xy"===l){const n=t.selection;e.call(i.move,[[r,n[0][1]],[s,n[1][1]]])}O.current=!1}const c={x:a,y:s};E.current=c,k.current(c)}),e.call(i),x.current=i,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{i.on("brush end",null),x.current=null}},[o,r,l,h,d,f]),e.useEffect(()=>{if(!(y&&c&&x.current&&E.current))return;if(!b.current)return;if("y"===l)return;const e=E.current,n=c.x.domain()[0],o=t.select(b.current).select(".brush-g");if(n>=e.x[1])return O.current=!0,o.call(x.current.move,null),O.current=!1,E.current=null,void k.current(null);let r=e.x[0],i=!1;if(n>e.x[0]){if(r=n,"bin"===h){const e=S.current;e&&e.length>0?r=v(n,e):d&&d>0&&(r=Math.ceil(n/d)*d)}if(r>=e.x[1])return O.current=!0,o.call(x.current.move,null),O.current=!1,E.current=null,void k.current(null);i=!0}const a=c.x(r),s=c.x(e.x[1]);if(O.current=!0,"x"===l)o.call(x.current.move,[a,s]);else{const t=c.y(e.y[1]),n=c.y(e.y[0]);o.call(x.current.move,[[a,t],[s,n]])}if(O.current=!1,i){const t={x:[r,e.x[1]],y:e.y};E.current=t,k.current(t)}},[c,y,l,h,d]),p.createElement("svg",{ref:b,width:i,height:a,style:{position:"absolute",top:0,left:0,pointerEvents:"all"}},p.createElement("g",{className:"brush-g",transform:`translate(${s.left},${s.top})`}))}class x{constructor(e,t){var n,o;this.lastBoundedData=null,this.chunkTimer=0,this.pushBuffer=[],this.flushScheduled=!1,this.callback=e,this.chunkThreshold=null!==(n=null==t?void 0:t.chunkThreshold)&&void 0!==n?n:5e3,this.chunkSize=null!==(o=null==t?void 0:t.chunkSize)&&void 0!==o?o:5e3}updateChunkOptions(e){null!=e.chunkThreshold&&(this.chunkThreshold=e.chunkThreshold),null!=e.chunkSize&&(this.chunkSize=e.chunkSize)}clearLastData(){this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(e){if(this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.chunkThreshold>=e.length)return void this.callback({inserts:e,bounded:!0});this.callback({inserts:e.slice(0,this.chunkSize),bounded:!0,totalSize:e.length});let t=this.chunkSize;const n=()=>{if(t>=e.length)return;if(e!==this.lastBoundedData)return;const o=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,o),bounded:!1}),t=o,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}flushPushBuffer(){if(this.flushScheduled=!1,0===this.pushBuffer.length)return;const e=this.pushBuffer;this.pushBuffer=[],this.callback({inserts:e,bounded:!1})}scheduleFlush(){this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flushPushBuffer()))}push(e){this.pushBuffer.push(e),this.scheduleFlush()}pushMany(e){if(0!==e.length){for(let t=0;e.length>t;t++)this.pushBuffer.push(e[t]);this.scheduleFlush()}}flush(){this.flushPushBuffer()}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1}}class k{constructor(e){if(this._capacity=e,this.head=0,this._size=0,1>e)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(e)}push(e){let t;return this._size===this._capacity?t=this.buffer[this.head]:this._size++,this.buffer[this.head]=e,this.head=(this.head+1)%this._capacity,t}pushMany(e){const t=[];for(const n of e){const e=this.push(n);void 0!==e&&t.push(e)}return t}get(e){if(e>=0&&this._size>e)return this.buffer[(this.head-this._size+e+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let e=0;const t=this;return{next:()=>t._size>e?{done:!1,value:t.get(e++)}:{done:!0,value:void 0}}}forEach(e){const t=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)e(this.buffer[(t+n)%this._capacity],n)}toArray(){const e=Array(this._size),t=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)e[n]=this.buffer[(t+n)%this._capacity];return e}resize(e){if(1>e)throw Error("RingBuffer capacity must be at least 1");const t=this.toArray(),n=[];for(;t.length>e;)n.push(t.shift());this._capacity=e,this.buffer=Array(e),this.head=0,this._size=0;for(const e of t)this.push(e);return n}update(e,t){const n=[],o=(this.head-this._size+this._capacity)%this._capacity;for(let r=0;this._size>r;r++){const i=(o+r)%this._capacity,a=this.buffer[i];if(e(a)){let e;e="object"!=typeof a||null===a?a:Array.isArray(a)?[...a]:Object.assign({},a),n.push(e),this.buffer[i]=t(a)}}return n}remove(e){const t=[],n=[];if(this.forEach(o=>{e(o)?n.push(o):t.push(o)}),0===n.length)return n;this.buffer=Array(this._capacity),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 w{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 A(e,t,n,o,r){const i=new Map;for(const a of e){const e=t(a),s=n(a);if(null==e||null==s||Number.isNaN(e)||Number.isNaN(s))continue;const l=Math.floor(e/o)*o;let c=i.get(l);if(c||(c={start:l,end:l+o,total:0,categories:new Map},i.set(l,c)),c.total+=s,r){const e=r(a);c.categories.set(e,(c.categories.get(e)||0)+s)}}return i}function S(e,t){return e===t||typeof e==typeof t&&"function"==typeof e&&"function"==typeof t&&""+e==""+t}function O(e,t){if("function"==typeof e)return t=>+e(t);const n=e||t;return e=>+e[n]}function E(e,t){if("function"==typeof e)return e;const n=e||t;return e=>e[n]}function M(e,t){return"function"==typeof e?e:e?t=>t[e]+"":t?e=>e[t]+"":void 0}const j={category10:i.schemeCategory10,tableau10:i.schemeTableau10,set3:i.schemeSet3,blues:i.interpolateBlues,reds:i.interpolateReds,greens:i.interpolateGreens,oranges:i.interpolateOranges,purples:i.interpolatePurples,viridis:i.interpolateViridis,plasma:i.interpolatePlasma},C=i.schemeCategory10,P=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],L=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"],_=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);function T(e,t,n){if("function"==typeof t){const o=t(e);return n&&o&&"string"==typeof o&&!function(e){const t=e.toLowerCase();return t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||_.has(t)}(o)?n(o):o}const o=null==e?void 0:e[t];return n?n(o):C[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+""))%C.length]}function B(e,t,n="category10"){const r=Array.from(new Set(e.map(e=>null==e?void 0:e[t]).filter(e=>null!=e))),i=r.every(e=>"number"==typeof e||!isNaN(Number(e)));if(Array.isArray(n))return o.scaleOrdinal().domain(r).range(n).unknown("#999");const a=j[n]||j.category10;if(i&&"function"==typeof a){let e=-1/0;for(const t of r){const n=Number(t);n>e&&(e=n)}return t=>a(Number(t)/e)}{const e=Array.isArray(a)?a:C;return o.scaleOrdinal().domain(r).range(e).unknown("#999")}}function N(e,t,n=[3,20],o){let r;if(r="function"==typeof t?t(e):null==e?void 0:e[t],!o)return r;const[i,a]=o,[s,l]=n;return a===i?(s+l)/2:s+(r-i)/(a-i)*(l-s)}function D(e,t,n){var o,r,i;if(1>=n)return 1;const a=null!==(o=e.minOpacity)&&void 0!==o?o:.1,s=n-1-t;switch(e.type){case"linear":return a+(1-s/(n-1))*(1-a);case"exponential":{const t=null!==(r=e.halfLife)&&void 0!==r?r:n/2;return a+Math.pow(.5,s/t)*(1-a)}case"step":return(null!==(i=e.stepThreshold)&&void 0!==i?i:.5*n)>s?1:a;default:return 1}}function I(e,t,n){var o;const r=null!==(o=e.duration)&&void 0!==o?o:500,i=n-t;return r>i?1-i/r:0}function R(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}function H(e,t){return Math.min((e-t.startTime)/t.duration,1)}function W(e,t,n){return e+(t-e)*n}function F(){return"undefined"!=typeof performance?performance.now():Date.now()}function $(e,t,n){var o,r,i,a;switch(t.type){case"point":if(t.pointId)return"p:"+t.pointId;if("streaming"===e.runtimeMode&&t.datum){const n=e.getX(t.datum),o=e.getY(t.datum);if(e.getCategory)return`p:${e.getCategory(t.datum)}:${n}:${o}`;if(null!=n&&null!=o)return`p:${n}:${o}`}return"p:"+n;case"rect":return`r:${t.group||""}:${null!==(a=null!==(r=null===(o=t.datum)||void 0===o?void 0:o.binStart)&&void 0!==r?r:null===(i=t.datum)||void 0===i?void 0:i.category)&&void 0!==a?a:n}`;case"heatcell":return`h:${t.x}_${t.y}`;case"candlestick":return null==t.datum?"c:"+n:"c:"+e.getX(t.datum);case"line":return"l:"+(t.group||"_default");case"area":return"a:"+(t.group||"_default");default:return null}}function z(e,t,n,o,r,i){const a=[];for(const r of e){const e=n(r),i=o(r);null==e||null==i||Number.isNaN(e)||Number.isNaN(i)||a.push({px:t.x(e),py:t.y(i),rawY:i,d:r})}a.sort((e,t)=>e.px-t.px);const s=Array(a.length),l=Array(a.length),c=Array(a.length);for(let e=0;a.length>e;e++){const t=a[e];s[e]=[t.px,t.py],l[e]=t.rawY,c[e]=t.d}return{type:"line",path:s,rawValues:l,style:r,datum:c,group:i}}function G(e,t,n,o,r,i,a,s){const l=[];for(const i of e){const e=n(i),a=o(i);if(null==e||null==a||Number.isNaN(e)||Number.isNaN(a))continue;const c=t.x(e),u=s?s(i):r;l.push({px:c,topY:t.y(a),botY:t.y(u)})}l.sort((e,t)=>e.px-t.px);const c=Array(l.length),u=Array(l.length);for(let e=0;l.length>e;e++){const t=l[e];c[e]=[t.px,t.topY],u[e]=[t.px,t.botY]}return{type:"area",topPath:c,bottomPath:u,style:i,datum:e,group:a}}function q(e,t,n,o,r,i,a){const s=n(e),l=o(e);if(null==s||null==l||Number.isNaN(s)||Number.isNaN(l))return null;const c={type:"point",x:t.x(s),y:t.y(l),r:r,style:i,datum:e};return void 0!==a&&(c.pointId=a),c}function Y(e,t,n,o,r,i,a){return{type:"rect",x:e,y:t,w:n,h:o,style:r,datum:i,group:a}}function X(e,t,n,o,r,i,a){const s={type:"heatcell",x:e,y:t,w:n,h:o,fill:r,datum:i};return(null==a?void 0:a.showValues)&&(s.showValues=!0,s.value=a.value,a.valueFormat&&(s.valueFormat=a.valueFormat)),s}function V(e,t,n){if(!e.getBounds||!e.scales)return null;const o=[],r=[];for(const n of t){const t=e.getX(n),i=e.getY(n);if(null==t||null==i||Number.isNaN(t)||Number.isNaN(i))continue;const a=e.getBounds(n),s=e.scales.x(t);if(a&&0!==a)o.push([s,e.scales.y(i+a)]),r.push([s,e.scales.y(i-a)]);else{const t=e.scales.y(i);o.push([s,t]),r.push([s,t])}}return 2>o.length?null:{type:"area",topPath:o,bottomPath:r,style:e.resolveBoundsStyle(n,t[0]),datum:t,group:n,interactive:!1}}function U(e,t,n,o){var r;if(!e.config.pointStyle)return;const i=null!=o?o:e.getY;for(const o of t){const t=e.resolveGroupColor(o.key);for(const a of o.data){let o=e.config.pointStyle(a);!o.fill&&t&&(o=Object.assign(Object.assign({},o),{fill:t}));const s=null!==(r=o.r)&&void 0!==r?r:3,l=e.getPointId?e.getPointId(a)+"":void 0,c=q(a,e.scales,e.getX,i,s,o,l);c&&n.push(c)}}}const K={blues:i.interpolateBlues,reds:i.interpolateReds,greens:i.interpolateGreens,viridis:i.interpolateViridis},Q=new Map;class Z{constructor(e){if(this.xExtent=new w,this.yExtent=new w,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.prevPathMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupColorMap=new Map,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this._ingestVersion=0,this._bufferArrayCache=null,this._bufferDirty=!0,this.needsFullRebuild=!0,this.lastLayout=null,this.scales=null,this.scene=[],this.version=0,this.xIsDate=!1,this._quadtree=null,this.config=e,this.buffer=new k(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=O(e.timeAccessor||e.xAccessor,"time"),this.getY=O(e.valueAccessor||e.yAccessor,"value")):(this.getX=O(e.xAccessor,"x"),this.getY=O(e.yAccessor,"y")),this.getGroup=M(e.groupAccessor),this.getCategory=M(e.categoryAccessor),this.getSize=e.sizeAccessor?O(e.sizeAccessor,"size"):void 0,this.getColor=M(e.colorAccessor),this.getBounds=e.boundsAccessor?O(e.boundsAccessor,"bounds"):void 0,this.getY0=e.y0Accessor?O(e.y0Accessor,"y0"):void 0,this.getPointId=M(e.pointIdAccessor),"candlestick"===e.chartType){const t=null!=e.openAccessor,n=null!=e.closeAccessor;this.getOpen=t?O(e.openAccessor,"open"):void 0,this.getHigh=O(e.highAccessor,"high"),this.getLow=O(e.lowAccessor,"low"),this.getClose=n?O(e.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!n}e.pulse&&(this.timestampBuffer=new k(e.windowSize))}ingest(e){const t="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=t,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,e.bounded){if(this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.getX=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?O(this.config.timeAccessor||this.config.xAccessor,"time"):O(this.config.xAccessor,"x"),this.xIsDate=!1,e.inserts.length>0){const t=e.inserts[0],n=this.config.xAccessor,o="function"==typeof n?n(t):t[n||"x"],r=o instanceof Date,i="string"==typeof o&&o.length>=10&&!isNaN(new Date(o).getTime())&&isNaN(Number(o));if(this.xIsDate=r||i,i){const e="string"==typeof n?n:void 0;this.getX=e?t=>+new Date(t[e]):e=>+(n(e)instanceof Date?n(e):new Date(n(e)))}}const n=e.totalSize||e.inserts.length;n>this.buffer.capacity&&(this.buffer.resize(n),this.timestampBuffer&&n>this.timestampBuffer.capacity&&this.timestampBuffer.resize(n));for(const n of e.inserts)this.buffer.push(n),this.timestampBuffer&&this.timestampBuffer.push(t),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):(this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n)))}else for(const n of e.inserts){if("growing"===this.config.windowMode&&this.buffer.full){const e=this.config.maxCapacity||1e6;e>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,e),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap))}const e=this.buffer.push(n);this.timestampBuffer&&this.timestampBuffer.push(t),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n))):(this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n))),null!=e&&(this.xExtent.evict(this.getX(e)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(e)),this.yExtent.evict(this.getLow(e))):this.yExtent.evict(this.getY(e)))}return!0}computeScene(e){var t,n,r,i,a,s,l;const{config:c,buffer:u}=this;if(!this.needsFullRebuild&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(null!==(t=this.config.scalePadding)&&void 0!==t?t:0)&&(this.lastLayout.width!==e.width||this.lastLayout.height!==e.height))return void this.remapScene(e);if(this.xExtent.dirty&&this.xExtent.recalculate(u,this.getX),this.yExtent.dirty)if("candlestick"===c.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const e of u)this.yExtent.push(this.getHigh(e)),this.yExtent.push(this.getLow(e))}else this.yExtent.recalculate(u,this.getY);const d=this.getBufferArray(),h=this.xExtent.extent,g=this.yExtent.extent;let f=c.xExtent?[null!==(n=c.xExtent[0])&&void 0!==n?n:h[0],null!==(r=c.xExtent[1])&&void 0!==r?r:h[1]]:h,p=c.yExtent?[null!==(i=c.yExtent[0])&&void 0!==i?i:g[0],null!==(a=c.yExtent[1])&&void 0!==a?a:g[1]]:g;const y=c.yExtent&&null!=c.yExtent[0]&&null!=c.yExtent[1];if("stackedarea"===c.chartType&&!y&&u.size>0)if(c.normalize)p=[0,1+c.extentPadding];else{const e=`${u.size}:${this._ingestVersion}`;if(this._stackExtentCache&&this._stackExtentCache.key===e)p=this._stackExtentCache.yDomain;else{const t=this.groupData(d),n=new Map;for(const e of t)for(const t of e.data){const e=this.getX(t),o=this.getY(t);null==e||null==o||Number.isNaN(e)||Number.isNaN(o)||n.set(e,(n.get(e)||0)+o)}let o=0;for(const e of n.values())e>o&&(o=e);p=[0,o+(o>0?o*c.extentPadding:1)],this._stackExtentCache={key:e,yDomain:p}}}else if("bar"===c.chartType&&c.binSize&&!y&&u.size>0){const[,e]=function(e,t,n,o,r){const i=A(e,t,n,o,r);if(0===i.size)return[0,0];let a=0;for(const e of i.values())e.total>a&&(a=e.total);return[0,a]}(u,this.getX,this.getY,c.binSize,this.getCategory);p=[0,e+e*c.extentPadding]}else if("waterfall"===c.chartType&&!y&&u.size>0){const[e,t]=function(e,t){let n=0,o=0,r=0;for(const i of e){const e=t(i);null==e||Number.isNaN(e)||(r+=e,n>r&&(n=r),r>o&&(o=r))}return[n,o]}(u,this.getY),n=t-e,o=n>0?n*c.extentPadding:1;p=[Math.min(0,e-Math.abs(o)),Math.max(0,t+Math.abs(o))]}else if(!y&&p[0]!==1/0){if(this.getBounds)for(const e of d){const t=this.getY(e),n=this.getBounds(e);null!=t&&!Number.isNaN(t)&&n&&(t+n>p[1]&&(p[1]=t+n),p[0]>t-n&&(p[0]=t-n))}const e=p[1]-p[0],t=e>0?e*c.extentPadding:1,n=null===(s=c.yExtent)||void 0===s?void 0:s[0],o=null===(l=c.yExtent)||void 0===l?void 0:l[1];p=[null!=n?p[0]:p[0]-t,null!=o?p[1]:p[1]+t],"log"===c.yScaleType&&0>=p[0]&&g[0]>0&&(p[0]=null!=n?p[0]:g[0]/(1+c.extentPadding))}if(f[0]===1/0||f[1]===-1/0)if("time"===c.xScaleType){const e=Date.now();f=[e-864e5,e]}else f=[0,1];p[0]!==1/0&&p[1]!==-1/0||(p=[0,1]);const m="streaming"===c.runtimeMode,v=Math.max(0,Math.min(c.scalePadding||0,Math.min(e.width,e.height)/2-1));if(m)if("x"==("up"===(b=c.arrowOfTime)||"down"===b?"y":"x")){const t="right"===c.arrowOfTime?[v,e.width-v]:[e.width-v,v];this.scales={x:o.scaleLinear().domain(f).range(t),y:o.scaleLinear().domain(p).range([e.height-v,v])}}else{const t="down"===c.arrowOfTime?[v,e.height-v]:[e.height-v,v];this.scales={x:o.scaleLinear().domain(p).range([v,e.width-v]),y:o.scaleLinear().domain(f).range(t)}}else{const t=(e,t,n)=>{if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return o.scaleLog().domain(e).range(n).clamp(!0)}return"time"===e?o.scaleTime().domain([new Date(t[0]),new Date(t[1])]).range(n):o.scaleLinear().domain(t).range(n)};this.scales={x:t(c.xScaleType,f,[v,e.width-v]),y:t(c.yScaleType,p,[e.height-v,v])}}var b;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(e,d),this.config.decay&&this.applyDecay(this.scene,d),this.config.pulse&&this.applyPulse(this.scene,d),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.rebuildQuadtree(),this.needsFullRebuild=!1,this.lastLayout={width:e.width,height:e.height},this.version++}rebuildQuadtree(){const e=this.config.chartType;if("scatter"!==e&&"bubble"!==e)return void(this._quadtree=null);const t=this.scene.filter(e=>"point"===e.type);this._quadtree=t.length>Z.QUADTREE_THRESHOLD?r.quadtree().x(e=>e.x).y(e=>e.y).addAll(t):null}get quadtree(){return this._quadtree}remapScene(e){const t=e.width/this.lastLayout.width,n=e.height/this.lastLayout.height;for(const e of this.scene)switch(e.type){case"line":for(const o of e.path)o[0]*=t,o[1]*=n;break;case"area":for(const o of e.topPath)o[0]*=t,o[1]*=n;for(const o of e.bottomPath)o[0]*=t,o[1]*=n;break;case"point":e.x*=t,e.y*=n;break;case"rect":case"heatcell":e.x*=t,e.y*=n,e.w*=t,e.h*=n;break;case"candlestick":e.x*=t,e.openY*=n,e.closeY*=n,e.highY*=n,e.lowY*=n}const r=this.scales.x.domain(),i=this.scales.y.domain(),a=this.scales.x.range(),s=this.scales.y.range(),l=(e,t,n)=>{if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return o.scaleLog().domain(e).range(n).clamp(!0)}return"time"===e?o.scaleTime().domain([new Date(t[0]),new Date(t[1])]).range(n):o.scaleLinear().domain(t).range(n)},c=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(e.width,e.height)/2-1)),u=s[1]>s[0];this.scales={x:l(this.config.xScaleType,r,a[0]>a[1]?[e.width-c,c]:[c,e.width-c]),y:l(this.config.yScaleType,i,u?[c,e.height-c]:[e.height-c,c])},this.lastLayout={width:e.width,height:e.height},this.rebuildQuadtree(),this.version++}buildSceneNodes(e,t){var n;const{config:o,scales:r}=this;if(!r||0===t.length)return[];const a={scales:r,config:o,getX:this.getX,getY:this.getY,getY0:this.getY0,getSize:this.getSize,getColor:this.getColor,getGroup:this.getGroup,getCategory:this.getCategory,getPointId:this.getPointId,getBounds:this.getBounds,getOpen:this.getOpen,getHigh:this.getHigh,getLow:this.getLow,getClose:this.getClose,resolveLineStyle:(e,t)=>this.resolveLineStyle(e,t),resolveAreaStyle:(e,t)=>this.resolveAreaStyle(e,t),resolveBoundsStyle:(e,t)=>this.resolveBoundsStyle(e,t),resolveColorMap:e=>this.resolveColorMap(e),resolveGroupColor:e=>this.resolveGroupColor(e),groupData:e=>this.groupData(e),barCategoryCache:this._barCategoryCache};switch(o.chartType){case"line":return function(e,t){var n;const o=e.groupData(t),r=[],i=null===(n=e.config.annotations)||void 0===n?void 0:n.filter(e=>"threshold"===e.type&&e.color).map(e=>({value:e.value,color:e.color,thresholdType:e.thresholdType||"greater"}));if(e.getBounds)for(const t of o){const n=V(e,t.data,t.key);n&&r.push(n)}for(const t of o){const n=e.resolveLineStyle(t.key,t.data[0]),o=z(t.data,e.scales,e.getX,e.getY,n,t.key);i&&i.length>0&&(o.colorThresholds=i),e.config.curve&&"linear"!==e.config.curve&&(o.curve=e.config.curve),e.config.lineGradient&&(o.strokeGradient=e.config.lineGradient),r.push(o)}return U(e,o,r),r}(a,t);case"area":return function(e,t){const n=e.groupData(t),o=[],r=e.scales.y.domain()[0],i=e.getY0?t=>{const n=e.getY0(t);return null==n?r:n}:void 0;for(const t of n){const n=e.resolveAreaStyle(t.key,t.data[0]),a=G(t.data,e.scales,e.getX,e.getY,r,n,t.key,i);e.config.gradientFill&&(a.fillGradient=e.config.gradientFill),e.config.curve&&"linear"!==e.config.curve&&(a.curve=e.config.curve),e.config.lineGradient&&(a.strokeGradient=e.config.lineGradient),o.push(a)}return U(e,n,o),o}(a,t);case"mixed":return function(e,t){const n=e.groupData(t),o=[],r=e.config.areaGroups||new Set,i=e.scales.y.domain()[0],a=e.getY0?t=>{const n=e.getY0(t);return null==n?i:n}:void 0;for(const t of n)if(r.has(t.key)){const n=e.resolveAreaStyle(t.key,t.data[0]),r=G(t.data,e.scales,e.getX,e.getY,i,n,t.key,a);e.config.gradientFill&&(r.fillGradient=e.config.gradientFill),e.config.curve&&"linear"!==e.config.curve&&(r.curve=e.config.curve),e.config.lineGradient&&(r.strokeGradient=e.config.lineGradient),o.push(r)}else{const n=e.resolveLineStyle(t.key,t.data[0]),r=z(t.data,e.scales,e.getX,e.getY,n,t.key);e.config.curve&&"linear"!==e.config.curve&&(r.curve=e.config.curve),e.config.lineGradient&&(r.strokeGradient=e.config.lineGradient),o.push(r)}return U(e,n,o),o}(a,t);case"stackedarea":return function(e,t){const n=e.groupData(t);n.sort((e,t)=>t.key>e.key?-1:e.key>t.key?1:0);const o=e.config.curve&&"linear"!==e.config.curve?e.config.curve:void 0,{nodes:r,stackedTops:i}=function(e,t,n,o,r,i,a){var s;const l=new Set;for(const t of e)for(const e of t.data){const t=n(e);null==t||Number.isNaN(t)||l.add(t)}const c=Array.from(l).sort((e,t)=>e-t),u=new Map;for(const t of e){const e=new Map;for(const r of t.data){const t=n(r),i=o(r);null==t||null==i||Number.isNaN(t)||Number.isNaN(i)||e.set(t,(e.get(t)||0)+i)}u.set(t.key,e)}let d;if(i){d=new Map;for(const t of c){let n=0;for(const o of e)n+=(null===(s=u.get(o.key))||void 0===s?void 0:s.get(t))||0;d.set(t,n||1)}}const h=[],g=new Map,f=new Map;for(const e of c)f.set(e,0);for(const n of e){const e=u.get(n.key),o=[],s=[],l=new Map;for(const n of c){let r=e.get(n)||0;const a=f.get(n);i&&(r/=d.get(n));const c=a+r,u=t.x(n);s.push([u,t.y(a)]),o.push([u,t.y(c)]),f.set(n,c),l.set(n,c)}g.set(n.key,l);const p={type:"area",topPath:o,bottomPath:s,style:r(n.key,n.data[0]),datum:n.data,group:n.key};a&&(p.curve=a),h.push(p)}return{nodes:h,stackedTops:g}}(n,e.scales,e.getX,e.getY,(t,n)=>e.resolveAreaStyle(t,n),e.config.normalize,o),a=r;if(e.config.pointStyle){const t=new WeakMap;for(const o of n){const n=i.get(o.key);if(n)for(const r of o.data){const o=e.getX(r),i=e.getY(r);null==o||Number.isNaN(o)||null==i||Number.isNaN(i)||!n.has(o)||t.set(r,n.get(o))}}const o=n=>{var o;return null!==(o=t.get(n))&&void 0!==o?o:e.getY(n)};U(e,n,a,o)}return a}(a,t);case"scatter":case"bubble":return function(e,t){const n=[],o="bubble"===e.config.chartType?10:5,r=e.config.sizeRange||[3,15];let i=null;if(e.getSize&&!e.config.pointStyle){const n=t.map(t=>e.getSize(t)).filter(e=>null!=e&&!Number.isNaN(e));if(n.length>0){let e=1/0,t=-1/0;for(const o of n)e>o&&(e=o),o>t&&(t=o);i=n=>e===t?(r[0]+r[1])/2:r[0]+(n-e)/(t-e)*(r[1]-r[0])}}const a=e.getColor?e.resolveColorMap(t):null;for(const r of t){let t=e.config.pointStyle?e.config.pointStyle(r):{fill:"#4e79a7",opacity:.8},s=t.r||o;if(i&&e.getSize){const t=e.getSize(r);null==t||Number.isNaN(t)||(s=i(t))}if(a&&e.getColor&&!t.fill){const n=e.getColor(r);n&&a.has(n)&&(t=Object.assign(Object.assign({},t),{fill:a.get(n)}))}const l=e.getPointId?e.getPointId(r)+"":void 0,c=q(r,e.scales,e.getX,e.getY,s,t,l);c&&n.push(c)}return n}(a,t);case"heatmap":return function(e,t,n){if(e.config.heatmapAggregation)return function(e,t,n){var o,r,i;const a=Math.max(1,Math.floor(null!==(o=e.config.heatmapXBins)&&void 0!==o?o:20)),s=Math.max(1,Math.floor(null!==(r=e.config.heatmapYBins)&&void 0!==r?r:20)),l=null!==(i=e.config.heatmapAggregation)&&void 0!==i?i:"count",c=O(e.config.valueAccessor,"value");if(!e.scales||0===t.length)return[];const[u,d]=e.scales.x.domain(),[h,g]=e.scales.y.domain(),f=(d-u||1)/a,p=(g-h||1)/s,y=a*s;if(y>1e6)return[];const m=new Int32Array(y),v=new Float64Array(y);for(let n=0;t.length>n;n++){const o=t[n],r=e.getX(o),i=e.getY(o);if(!isFinite(r)||!isFinite(i))continue;const l=Math.min(Math.floor((r-u)/f),a-1),d=Math.min(Math.floor((i-h)/p),s-1);if(0>l||0>d)continue;const g=d*a+l;m[g]++;const y=c(o);v[g]+=isFinite(y)?y:0}let b=1/0,x=-1/0;for(let e=0;y>e;e++){if(0===m[e])continue;let t;switch(l){case"sum":t=v[e];break;case"mean":t=v[e]/m[e];break;default:t=m[e]}b>t&&(b=t),t>x&&(x=t)}if(!isFinite(b))return[];const k=x-b||1,w=n.width/a,A=n.height/s,S=e.config.showValues,E=e.config.heatmapValueFormat,M=[];for(let e=0;s>e;e++){const t=e*a;for(let n=0;a>n;n++){const o=t+n;if(0===m[o])continue;let r;switch(l){case"sum":r=v[o];break;case"mean":r=v[o]/m[o];break;default:r=m[o]}const i=(r-b)/k;M.push(X(n*w,(s-1-e)*A,w,A,`rgb(${220-(180*i+.5)|0},${220-(100*i+.5)|0},${255-(50*i+.5)|0})`,{xi:n,yi:e,value:r,count:m[o],sum:v[o]},S?{value:r,showValues:!0,valueFormat:E}:void 0))}}return M}(e,t,n);if(0===t.length)return[];const o=O(e.config.valueAccessor,"value"),r=E(e.config.xAccessor,"x"),a=E(e.config.yAccessor,"y"),s=new Map,l=new Map,c=Array(t.length),u=Array(t.length);for(let e=0;t.length>e;e++){const n=t[e],o=r(n),i=a(n);c[e]=o,u[e]=i,s.has(o)||s.set(o,s.size),l.has(i)||l.set(i,l.size)}const d=s.size,h=l.size;if(0===d||0===h)return[];const g=Array.from(s.keys()),f=Array.from(l.keys()),p=g.every(e=>"number"==typeof e&&!isNaN(e)),y=f.every(e=>"number"==typeof e&&!isNaN(e));if(p){g.sort((e,t)=>e-t),s.clear();for(let e=0;g.length>e;e++)s.set(g[e],e)}if(y){f.sort((e,t)=>e-t),l.clear();for(let e=0;f.length>e;e++)l.set(f[e],e)}const m=new Float64Array(t.length),v=new Float64Array(t.length),b=Array(t.length),x=new Map;let k=0;for(let e=0;t.length>e;e++){const n=t[e],r=s.get(c[e]),i=l.get(u[e]);if(void 0===r||void 0===i)continue;const a=o(n),h=i*d+r,g=x.get(h);let f;void 0!==g?f=g:(f=k++,x.set(h,f)),m[f]=h,v[f]=a,b[f]=n}let w=1/0,A=-1/0;for(let e=0;k>e;e++){const t=v[e];isFinite(t)&&(w>t&&(w=t),t>A&&(A=t))}if(!isFinite(w)||!isFinite(A))return[];const S=function(e){const t=e in K?e:"blues";let n=Q.get(t);if(n)return n;n=Array(256);const o=K[t]||i.interpolateBlues;for(let e=0;256>e;e++)n[e]=o(e/255);return Q.set(t,n),n}("string"==typeof e.config.colorScheme?e.config.colorScheme:"blues"),M=255/(A-w||1),j=n.width/d,C=n.height/h,P=e.config.showValues,L=e.config.heatmapValueFormat,_=[];for(let e=0;k>e;e++){const t=v[e];if(!isFinite(t))continue;const n=m[e],o=n%d;_.push(X(o*j,(h-1-(n-o)/d)*C,j,C,S[Math.min((t-w)*M+.5|0,255)],b[e],P?{value:t,showValues:!0,valueFormat:L}:void 0))}return _}(a,t,e);case"bar":{const e=function(e,t){var n;if(!e.config.binSize)return{nodes:[],binBoundaries:[]};const o=A(t,e.getX,e.getY,e.config.binSize,e.getCategory);if(0===o.size)return{nodes:[],binBoundaries:[]};let r=null;if(e.getCategory){const t=new Set;for(const e of o.values())for(const n of e.categories.keys())t.add(n);const n=e.config.barColors?Object.keys(e.config.barColors):[],i=new Set(n),a=Array.from(t).filter(e=>!i.has(e)).sort(),s=n.filter(e=>t.has(e)),l=s.join("\0")+""+a.join("\0");e.barCategoryCache&&e.barCategoryCache.key===l?r=e.barCategoryCache.order:(r=[...s,...a],e.barCategoryCache={key:l,order:r})}const i=[],a=e.scales,[s,l]=a.x.domain();for(const t of o.values()){const o=Math.max(t.start,s),c=Math.min(t.end,l);if(o>=c)continue;const u=a.x(o),d=a.x(c),h=Math.abs(d-u),g=h>2?1:0,f=Math.min(u,d)+g/2,p=Math.max(h-g,1);if(p>0)if(r&&t.categories.size>0){let o=0;for(const s of r){const r=t.categories.get(s)||0;if(0===r)continue;const l=a.y(o),c=a.y(o+r);i.push(Y(f,Math.min(l,c),p,Math.abs(l-c),{fill:(null===(n=e.config.barColors)||void 0===n?void 0:n[s])||"#4e79a7"},{binStart:t.start,binEnd:t.end,total:t.total,category:s,categoryValue:r},s)),o+=r}}else{const e=a.y(0),n=a.y(t.total);i.push(Y(f,Math.min(e,n),p,Math.abs(e-n),{fill:"#007bff"},{binStart:t.start,binEnd:t.end,total:t.total}))}}const c=new Set;for(const e of o.values())c.add(e.start),c.add(e.end);return{nodes:i,binBoundaries:Array.from(c).sort((e,t)=>e-t)}}(a,t);return this._barCategoryCache=null!==(n=a.barCategoryCache)&&void 0!==n?n:null,this._binBoundaries=e.binBoundaries,e.nodes}case"swarm":return function(e,t){var n,o,r,i;const a=[],s=e.config.swarmStyle||{},l=null!==(n=s.radius)&&void 0!==n?n:3,c=null!==(o=s.fill)&&void 0!==o?o:"#007bff",u=null!==(r=s.opacity)&&void 0!==r?r:.7,d=s.stroke,h=s.strokeWidth;for(const n of t){const t=e.getX(n),o=e.getY(n);if(null==o||Number.isNaN(o))continue;const r=e.scales.x(t),s=e.scales.y(o);let g=c;if(e.getCategory){const t=e.getCategory(n);g=(null===(i=e.config.barColors)||void 0===i?void 0:i[t])||g}const f={type:"point",x:r,y:s,r:l,style:{fill:g,opacity:u,stroke:d,strokeWidth:h},datum:n};e.getPointId&&(f.pointId=e.getPointId(n)+""),a.push(f)}return a}(a,t);case"waterfall":return function(e,t,n){var o,r,i;const a=[],s=e.scales,l=e.config.waterfallStyle,c=t.filter(t=>{const n=e.getY(t),o=e.getX(t);return null!=n&&!Number.isNaN(n)&&null!=o&&isFinite(o)});if(0===c.length)return a;const u=null!==(o=null==l?void 0:l.positiveColor)&&void 0!==o?o:"#28a745",d=null!==(r=null==l?void 0:l.negativeColor)&&void 0!==r?r:"#dc3545",h=null!==(i=null==l?void 0:l.gap)&&void 0!==i?i:1,g=null==l?void 0:l.stroke,f=null==l?void 0:l.strokeWidth;let p=0;for(let t=0;c.length>t;t++){const o=c[t],r=e.getX(o),i=e.getY(o),y=p+i;let m;m=c.length-1>t?e.getX(c[t+1])-r:t>0?r-e.getX(c[t-1]):0;const v=s.x(r),b=0!==m?s.x(r+m):v+n.width/10,x=Math.min(v,b)+h/2,k=Math.max(v,b)-h/2-x;if(0>=k){p=y;continue}const w=s.y(p),A=s.y(y);a.push(Y(x,Math.min(w,A),k,Math.abs(w-A),{fill:0>i?d:u,stroke:g,strokeWidth:f},Object.assign(Object.assign({},o),{baseline:p,cumEnd:y,delta:i,_connectorStroke:null==l?void 0:l.connectorStroke,_connectorWidth:null==l?void 0:l.connectorWidth}))),p=y}return a}(a,t,e);case"candlestick":return function(e,t){var n,o;if(!e.getHigh||!e.getLow||!e.scales)return[];const r=null!==(n=e.config.candlestickRangeMode)&&void 0!==n&&n;if(!(r||e.getOpen&&e.getClose))return[];const i=[],a=e.config.candlestickStyle||{},s=a.rangeColor||"#6366f1",l=r?s:a.upColor||"#28a745",c=r?s:a.downColor||"#dc3545",u=r?s:a.wickColor||"#333",d=a.wickWidth||(r?2:1),h=t.map(t=>e.getX(t)).filter(e=>null!=e&&!Number.isNaN(e)).sort((e,t)=>e-t);let g=r?0:null!==(o=a.bodyWidth)&&void 0!==o?o:0;if(!r&&null==a.bodyWidth&&h.length>1){let t=1/0;for(let n=1;h.length>n;n++){const o=Math.abs(e.scales.x(h[n])-e.scales.x(h[n-1]));o>0&&t>o&&(t=o)}g=t!==1/0?Math.max(2,Math.min(.6*t,20)):6}else r||null!=a.bodyWidth||(g=6);for(const n of t){const t=e.getX(n);if(null==t||Number.isNaN(t))continue;const o=e.getHigh(n),a=e.getLow(n);if(null==o||Number.isNaN(o)||null==a||Number.isNaN(a))continue;const s=r?o:e.getOpen(n),h=r?a:e.getClose(n);if(!r&&[s,h].some(e=>null==e||Number.isNaN(e)))continue;const f=h>=s,p={type:"candlestick",x:e.scales.x(t),openY:e.scales.y(s),closeY:e.scales.y(h),highY:e.scales.y(o),lowY:e.scales.y(a),bodyWidth:g,upColor:l,downColor:c,wickColor:u,wickWidth:d,isUp:f,datum:n};r&&(p.isRange=!0),i.push(p)}return i}(a,t);default:return[]}}resolveBoundsStyle(e,t){const n=this.config.boundsStyle;return"function"==typeof n?n(t||{},e):n&&"object"==typeof n?n:{fill:this.resolveLineStyle(e,t).stroke||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(e,t){const n=this.config.decay;return n&&t>1?D(n,e,t):1}applyDecay(e,t){this.config.decay&&function(e,t,n){var o,r;const i=n.length;if(1>=i)return;const a=new Map;for(let e=0;n.length>e;e++)a.set(n[e],e);for(const n of t){if("line"===n.type){const t=Array.isArray(n.datum)?n.datum:[];if(2>t.length)continue;const o=Array(t.length);let r=!1;for(let n=0;t.length>n;n++){const s=a.get(t[n]);null!=s?(o[n]=D(e,s,i),1>o[n]&&(r=!0)):o[n]=1}r&&(n._decayOpacities=o);continue}if("area"===n.type){const t=Array.isArray(n.datum)?n.datum:[],o=n.topPath?n.topPath.length:t.length;if(2>o)continue;if(t.length===o){const r=Array(o);let s=!1;for(let n=0;t.length>n;n++){const o=a.get(t[n]);null!=o?(r[n]=D(e,o,i),1>r[n]&&(s=!0)):r[n]=1}s&&(n._decayOpacities=r)}else{let r=1;for(const n of t){const t=a.get(n);if(null!=t){const n=D(e,t,i);r>n&&(r=n)}}if(1>r){const e=Array(o);e.fill(r),n._decayOpacities=e}}continue}const t=a.get(n.datum);if(null==t)continue;const s=D(e,t,i);if("heatcell"===n.type)n.style={opacity:s};else if("candlestick"===n.type)n._decayOpacity=s;else{const e=null!==(r=null===(o=n.style)||void 0===o?void 0:o.opacity)&&void 0!==r?r:1;n.style=Object.assign(Object.assign({},n.style),{opacity:e*s})}}}(this.config.decay,e,t)}applyPulse(e,t){this.config.pulse&&this.timestampBuffer&&function(e,t,n,o){var r,i;const a="undefined"!=typeof performance?performance.now():Date.now(),s=null!==(r=e.color)&&void 0!==r?r:"rgba(255,255,255,0.6)",l=null!==(i=e.glowRadius)&&void 0!==i?i:4,c=new Map;for(let e=0;n.length>e;e++)c.set(n[e],e);for(const n of t){if("line"===n.type)continue;if("area"===n.type){const t=Array.isArray(n.datum)?n.datum:[n.datum];let r=0;for(const n of t){const t=c.get(n);if(null==t)continue;const i=o.get(t);if(null==i)continue;const s=I(e,i,a);s>r&&(r=s)}r>0&&(n._pulseIntensity=r,n._pulseColor=s);continue}const t=c.get(n.datum);if(null==t)continue;const r=o.get(t);if(null==r)continue;const i=I(e,r,a);i>0&&(n._pulseIntensity=i,n._pulseColor=s,n._pulseGlowRadius=l)}}(this.config.pulse,e,t,this.timestampBuffer)}get hasActivePulses(){return!!this.config.pulse&&function(e,t){var n;if(!t||0===t.size)return!1;const o="undefined"!=typeof performance?performance.now():Date.now(),r=null!==(n=e.duration)&&void 0!==n?n:500,i=t.peek();return null!=i&&r>o-i}(this.config.pulse,this.timestampBuffer)}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(e,t,n,o){var r,i,a;n.clear(),o.clear();for(let s=0;t.length>s;s++){const l=t[s],c=$(e,l,s);c&&("point"===l.type?n.set(c,{x:l.x,y:l.y,r:l.r,opacity:l.style.opacity}):"rect"===l.type?n.set(c,{x:l.x,y:l.y,w:l.w,h:l.h,opacity:l.style.opacity}):"heatcell"===l.type?n.set(c,{x:l.x,y:l.y,w:l.w,h:l.h,opacity:null===(r=l.style)||void 0===r?void 0:r.opacity}):"candlestick"===l.type?n.set(c,{x:l.x,y:l.openY}):"line"===l.type?o.set(c,{path:l.path.map(e=>[e[0],e[1]]),opacity:null===(i=l.style)||void 0===i?void 0:i.opacity}):"area"===l.type&&o.set(c,{topPath:l.topPath.map(e=>[e[0],e[1]]),bottomPath:l.bottomPath.map(e=>[e[0],e[1]]),opacity:null===(a=l.style)||void 0===a?void 0:a.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}startTransition(){if(!this.config.transition)return;const e=function(e,t,n,o,r){var i,a,s,l,c,u,d,h,g,f,p,y,m,v,b,x,k,w,A,S,O,E,M,j,C,P,L,_;if(0===o.size&&0===r.size)return n;const T=null!==(i=t.duration)&&void 0!==i?i:300;if(n.exitNodes.length>0){const e=new Set(n.exitNodes);n.scene=n.scene.filter(t=>!e.has(t)),n.exitNodes=[]}let B=!1;const N=new Set,D=new Set;for(let t=0;n.scene.length>t;t++){const i=n.scene[t],A=$(e,i,t);if(!A)continue;if(i._transitionKey=A,"line"===i.type||"area"===i.type){const e=r.get(A);if(e){if(D.add(A),"line"===i.type&&e.path&&e.path.length===i.path.length){i._targetPath=i.path.map(e=>[e[0],e[1]]),i._prevPath=e.path;for(let t=0;i.path.length>t;t++)i.path[t]=[e.path[t][0],e.path[t][1]];B=!0}else if("area"===i.type&&e.topPath&&e.bottomPath&&e.topPath.length===i.topPath.length&&e.bottomPath.length===i.bottomPath.length){i._targetTopPath=i.topPath.map(e=>[e[0],e[1]]),i._targetBottomPath=i.bottomPath.map(e=>[e[0],e[1]]),i._prevTopPath=e.topPath,i._prevBottomPath=e.bottomPath;for(let t=0;i.topPath.length>t;t++)i.topPath[t]=[e.topPath[t][0],e.topPath[t][1]];for(let t=0;i.bottomPath.length>t;t++)i.bottomPath[t]=[e.bottomPath[t][0],e.bottomPath[t][1]];B=!0}i._targetOpacity=null!==(a=i.style.opacity)&&void 0!==a?a:1,i._startOpacity=null!==(l=null!==(s=e.opacity)&&void 0!==s?s:i.style.opacity)&&void 0!==l?l:1}else i._targetOpacity=null!==(c=i.style.opacity)&&void 0!==c?c:1,i._startOpacity=0,i.style=Object.assign(Object.assign({},i.style),{opacity:0}),B=!0;continue}const S=o.get(A);if("point"===i.type)if(S){N.add(A);const e={x:i.x,y:i.y,r:i.r};i._targetOpacity=null!==(u=i.style.opacity)&&void 0!==u?u:1,S.x===e.x&&S.y===e.y&&S.r===e.r||(i._targetX=e.x,i._targetY=e.y,i._targetR=e.r,i.x=S.x,i.y=S.y,i.r=null!==(d=S.r)&&void 0!==d?d:i.r,B=!0)}else i._targetOpacity=null!==(h=i.style.opacity)&&void 0!==h?h:1,i.style=Object.assign(Object.assign({},i.style),{opacity:0}),B=!0;else if("rect"===i.type)if(S){N.add(A);const e={x:i.x,y:i.y,w:i.w,h:i.h};i._targetOpacity=null!==(g=i.style.opacity)&&void 0!==g?g:1,S.x===e.x&&S.y===e.y&&S.w===e.w&&S.h===e.h||(i._targetX=e.x,i._targetY=e.y,i._targetW=e.w,i._targetH=e.h,i.x=S.x,i.y=S.y,i.w=null!==(f=S.w)&&void 0!==f?f:i.w,i.h=null!==(p=S.h)&&void 0!==p?p:i.h,B=!0)}else i._targetOpacity=null!==(y=i.style.opacity)&&void 0!==y?y:1,i.style=Object.assign(Object.assign({},i.style),{opacity:0}),B=!0;else if("heatcell"===i.type)if(S){N.add(A);const e={x:i.x,y:i.y,w:i.w,h:i.h};i._targetOpacity=null!==(v=null===(m=i.style)||void 0===m?void 0:m.opacity)&&void 0!==v?v:1,S.x===e.x&&S.y===e.y&&S.w===e.w&&S.h===e.h||(i._targetX=e.x,i._targetY=e.y,i._targetW=e.w,i._targetH=e.h,i.x=S.x,i.y=S.y,i.w=null!==(b=S.w)&&void 0!==b?b:i.w,i.h=null!==(x=S.h)&&void 0!==x?x:i.h,B=!0)}else i._targetOpacity=null!==(w=null===(k=i.style)||void 0===k?void 0:k.opacity)&&void 0!==w?w:1,i.style=Object.assign(Object.assign({},i.style||{}),{opacity:0}),B=!0}for(const[e,t]of r)if(!D.has(e))if(e.startsWith("l:")&&t.path){const o={type:"line",path:t.path.map(e=>[e[0],e[1]]),group:e.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:null!==(A=t.opacity)&&void 0!==A?A:1},_targetOpacity:0,_transitionKey:e,datum:null};n.exitNodes.push(o),B=!0}else if(e.startsWith("a:")&&t.topPath&&t.bottomPath){const o={type:"area",topPath:t.topPath.map(e=>[e[0],e[1]]),bottomPath:t.bottomPath.map(e=>[e[0],e[1]]),group:e.slice(2),style:{fill:"#999",opacity:null!==(S=t.opacity)&&void 0!==S?S:1},_targetOpacity:0,_transitionKey:e,datum:null};n.exitNodes.push(o),B=!0}for(const[e,t]of o)if(!N.has(e)){if(e.startsWith("p:")){const o={type:"point",x:t.x,y:t.y,r:null!==(O=t.r)&&void 0!==O?O:3,style:{opacity:null!==(E=t.opacity)&&void 0!==E?E:1},datum:null,_targetOpacity:0,_transitionKey:e};n.exitNodes.push(o)}else if(e.startsWith("r:")){const o={type:"rect",x:t.x,y:t.y,w:null!==(M=t.w)&&void 0!==M?M:0,h:null!==(j=t.h)&&void 0!==j?j:0,style:{opacity:null!==(C=t.opacity)&&void 0!==C?C:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e};n.exitNodes.push(o)}else if(e.startsWith("h:")){const o={type:"heatcell",x:t.x,y:t.y,w:null!==(P=t.w)&&void 0!==P?P:0,h:null!==(L=t.h)&&void 0!==L?L:0,fill:"#999",datum:null,style:{opacity:null!==(_=t.opacity)&&void 0!==_?_:1},_targetOpacity:0,_transitionKey:e};n.exitNodes.push(o)}B=!0}return n.exitNodes.length>0&&(n.scene=[...n.scene,...n.exitNodes]),B&&(n.activeTransition={startTime:F(),duration:T}),n}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap);this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition}advanceTransition(e){if(!this.activeTransition||!this.config.transition)return!1;const t={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},n=function(e,t,n,o){var r,i,a,s,l;if(!n.activeTransition)return!1;const c=H(e,n.activeTransition),u=R(c,"linear"===t.easing?"linear":"ease-out-cubic");for(const e of n.scene){const t=e._transitionKey;if("point"===e.type){if(void 0!==e._targetOpacity){const n=t?o.get(t):void 0,i=n?null!==(r=n.opacity)&&void 0!==r?r:1:0;e.style.opacity=W(i,e._targetOpacity,u)}if(void 0===e._targetX)continue;if(!t)continue;const n=o.get(t);if(!n)continue;e.x=W(n.x,e._targetX,u),e.y=W(n.y,e._targetY,u),void 0!==e._targetR&&void 0!==n.r&&(e.r=W(n.r,e._targetR,u))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const n=t?o.get(t):void 0,r=n?null!==(i=n.opacity)&&void 0!==i?i:1:0;e.style.opacity=W(r,e._targetOpacity,u)}if(void 0===e._targetX)continue;if(!t)continue;const n=o.get(t);if(!n)continue;e.x=W(n.x,e._targetX,u),e.y=W(n.y,e._targetY,u),void 0!==n.w&&(e.w=W(n.w,e._targetW,u)),void 0!==n.h&&(e.h=W(n.h,e._targetH,u))}else if("heatcell"===e.type){if(void 0!==e._targetOpacity){const n=t?o.get(t):void 0,r=n?null!==(a=n.opacity)&&void 0!==a?a:1:0;e.style=Object.assign(Object.assign({},e.style||{}),{opacity:W(r,e._targetOpacity,u)})}if(void 0===e._targetX)continue;if(!t)continue;const n=o.get(t);if(!n)continue;e.x=W(n.x,e._targetX,u),e.y=W(n.y,e._targetY,u),void 0!==n.w&&(e.w=W(n.w,e._targetW,u)),void 0!==n.h&&(e.h=W(n.h,e._targetH,u))}else if("line"===e.type){if(void 0!==e._targetOpacity){const t=null!==(s=e._startOpacity)&&void 0!==s?s:0;e.style=Object.assign(Object.assign({},e.style),{opacity:W(t,e._targetOpacity,u)})}const t=e._prevPath,n=e._targetPath;if(t&&n&&t.length===e.path.length)for(let o=0;e.path.length>o;o++)e.path[o][0]=W(t[o][0],n[o][0],u),e.path[o][1]=W(t[o][1],n[o][1],u)}else if("area"===e.type){if(void 0!==e._targetOpacity){const t=null!==(l=e._startOpacity)&&void 0!==l?l:0;e.style=Object.assign(Object.assign({},e.style),{opacity:W(t,e._targetOpacity,u)})}const t=e._prevTopPath,n=e._prevBottomPath,o=e._targetTopPath,r=e._targetBottomPath;if(t&&o&&t.length===e.topPath.length)for(let n=0;e.topPath.length>n;n++)e.topPath[n][0]=W(t[n][0],o[n][0],u),e.topPath[n][1]=W(t[n][1],o[n][1],u);if(n&&r&&n.length===e.bottomPath.length)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t][0]=W(n[t][0],r[t][0],u),e.bottomPath[t][1]=W(n[t][1],r[t][1],u)}}if(c>=1){for(const e of n.scene){if(void 0!==e._targetOpacity){const t=e._targetOpacity;e.style=Object.assign(Object.assign({},"line"===e.type||"area"===e.type?e.style:e.style||{}),{opacity:0===t?0:t}),e._targetOpacity=void 0}if("point"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,void 0!==e._targetR&&(e.r=e._targetR),e._targetX=void 0,e._targetY=void 0,e._targetR=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("heatcell"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("line"===e.type){const t=e._targetPath;if(t)for(let n=0;e.path.length>n;n++)e.path[n]=t[n];e._prevPath=void 0,e._targetPath=void 0}else if("area"===e.type){const t=e._targetTopPath,n=e._targetBottomPath;if(t)for(let n=0;e.topPath.length>n;n++)e.topPath[n]=t[n];if(n)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t]=n[t];e._prevTopPath=void 0,e._prevBottomPath=void 0,e._targetTopPath=void 0,e._targetBottomPath=void 0}}if(n.exitNodes.length>0){const e=new Set(n.exitNodes);n.scene=n.scene.filter(t=>!e.has(t)),n.exitNodes=[]}return n.activeTransition=null,!1}return!0}(e,this.config.transition,t,this.prevPositionMap);return this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition,n}groupData(e){if(!this.getGroup)return[{key:"_default",data:e}];const t=new Map;for(const n of e){const e=this.getGroup(n);t.has(e)||t.set(e,[]),t.get(e).push(n)}return Array.from(t.entries()).map(([e,t])=>({key:e,data:t}))}resolveColorMap(e){const t=new Set;for(const n of e){const e=this.getColor(n);e&&t.add(e)}const n=Array.from(t).sort(),o=n.join("\0");if(this._colorMapCache&&this._colorMapCache.key===o)return this._colorMapCache.map;const r=Array.isArray(this.config.colorScheme)?this.config.colorScheme:P,i=new Map;for(let e=0;n.length>e;e++)i.set(n[e],r[e%r.length]);return this._colorMapCache={key:o,map:i},i}resolveLineStyle(e,t){const n=this.config.lineStyle;if("function"==typeof n){const o=n(t||{},e);if(o&&!o.stroke&&e){const t=this.resolveGroupColor(e);if(t)return Object.assign(Object.assign({},o),{stroke:t})}return o}return n&&"object"==typeof n?{stroke:n.stroke||"#007bff",strokeWidth:n.strokeWidth||2,strokeDasharray:n.strokeDasharray,fill:n.fill,fillOpacity:n.fillOpacity,opacity:n.opacity}:{stroke:this.resolveGroupColor(e)||"#007bff",strokeWidth:2}}resolveAreaStyle(e,t){var n;if(this.config.areaStyle){const n=this.config.areaStyle(t||{});if(n&&!n.fill&&e){const t=this.resolveGroupColor(e);if(t)return Object.assign(Object.assign({},n),{fill:t,stroke:n.stroke||t})}return n}const o=this.config.lineStyle;if("function"==typeof o){const n=o(t||{},e);if(n&&!n.fill&&e){const t=this.resolveGroupColor(e);if(t)return Object.assign(Object.assign({},n),{fill:t,stroke:n.stroke||t})}return n}if(o&&"object"==typeof o)return{fill:o.fill||o.stroke||"#4e79a7",fillOpacity:null!==(n=o.fillOpacity)&&void 0!==n?n:.7,stroke:o.stroke||"#4e79a7",strokeWidth:o.strokeWidth||2};const r=this.resolveGroupColor(e)||"#4e79a7";return{fill:r,fillOpacity:.7,stroke:r,strokeWidth:2}}resolveGroupColor(e){if(this._colorMapCache){const t=this._colorMapCache.map.get(e);if(t)return t}const t=this._groupColorMap.get(e);if(t)return t;const n=Array.isArray(this.config.colorScheme)?this.config.colorScheme:P,o=n[this._groupColorMap.size%n.length];return this._groupColorMap.set(e,o),o}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}remove(e){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const t=new Set(Array.isArray(e)?e:[e]),n=this.getPointId,o=e=>t.has(n(e));if(this.timestampBuffer&&this.timestampBuffer.size>0){const e=this.timestampBuffer.toArray(),t=new Set;this.buffer.forEach((e,n)=>{o(e)&&t.add(n)}),this.timestampBuffer.clear();for(let n=0;e.length>n;n++)t.has(n)||this.timestampBuffer.push(e[n])}const r=this.buffer.remove(o);if(0===r.length)return r;for(const e of r)this.xExtent.evict(this.getX(e)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(e)),this.yExtent.evict(this.getLow(e))):(this.yExtent.evict(this.getY(e)),this.getY0&&this.yExtent.evict(this.getY0(e)));return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,r}update(e,t){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const n=new Set(Array.isArray(e)?e:[e]),o=this.getPointId,r=new Set;this.buffer.forEach((e,t)=>{n.has(o(e))&&r.add(t)});const i=this.buffer.update(e=>n.has(o(e)),t);if(0===i.length)return i;for(const e of i)this.xExtent.evict(this.getX(e)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(e)),this.yExtent.evict(this.getLow(e))):(this.yExtent.evict(this.getY(e)),this.getY0&&this.yExtent.evict(this.getY0(e)));return this.buffer.forEach((e,t)=>{r.has(t)&&(this.xExtent.push(this.getX(e)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(e)),this.yExtent.push(this.getLow(e))):(this.yExtent.push(this.getY(e)),this.getY0&&this.yExtent.push(this.getY0(e))))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,i}getBinBoundaries(){return this._binBoundaries}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.prevPathMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this.needsFullRebuild=!0,this._bufferDirty=!0,this._bufferArrayCache=null,this.lastLayout=null,this.scales=null,this.scene=[],this._quadtree=null,this._colorMapCache=null,this._groupColorMap=new Map,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this.version++}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}updateConfig(e){var t,n,o,r;const i=Object.assign({},this.config);void 0!==e.colorScheme&&(this._colorMapCache=null,this._groupColorMap=new Map),void 0===e.barColors&&void 0===e.colorScheme||(this._barCategoryCache=null),void 0===e.normalize&&void 0===e.extentPadding&&void 0===e.xAccessor&&void 0===e.yAccessor&&void 0===e.groupAccessor&&void 0===e.categoryAccessor&&void 0===e.chartType||(this._stackExtentCache=null);let a=!1;Object.assign(this.config,e);const s="chartType"in e&&e.chartType!==i.chartType||"runtimeMode"in e&&e.runtimeMode!==i.runtimeMode;if(s||void 0!==e.xAccessor||void 0!==e.yAccessor||void 0!==e.timeAccessor||void 0!==e.valueAccessor){const l=s||!S(null!==(t=e.xAccessor)&&void 0!==t?t:e.timeAccessor,null!==(n=i.xAccessor)&&void 0!==n?n:i.timeAccessor),c=s||!S(null!==(o=e.yAccessor)&&void 0!==o?o:e.valueAccessor,null!==(r=i.yAccessor)&&void 0!==r?r:i.valueAccessor);(l||c)&&(["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?(this.getX=O(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=O(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=O(this.config.xAccessor,"x"),this.getY=O(this.config.yAccessor,"y")),a=!0)}if("groupAccessor"in e&&!S(e.groupAccessor,i.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?M(this.config.groupAccessor):void 0,a=!0),"categoryAccessor"in e&&!S(e.categoryAccessor,i.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?M(this.config.categoryAccessor):void 0,a=!0),"sizeAccessor"in e&&!S(e.sizeAccessor,i.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?O(this.config.sizeAccessor,"size"):void 0,a=!0),"colorAccessor"in e&&!S(e.colorAccessor,i.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?M(this.config.colorAccessor):void 0,a=!0),"y0Accessor"in e&&!S(e.y0Accessor,i.y0Accessor)&&(this.getY0=this.config.y0Accessor?O(this.config.y0Accessor,"y0"):void 0,a=!0),"pointIdAccessor"in e&&!S(e.pointIdAccessor,i.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?M(this.config.pointIdAccessor):void 0,a=!0),"candlestick"===this.config.chartType&&("openAccessor"in e&&!S(e.openAccessor,i.openAccessor)||"closeAccessor"in e&&!S(e.closeAccessor,i.closeAccessor)||"highAccessor"in e&&!S(e.highAccessor,i.highAccessor)||"lowAccessor"in e&&!S(e.lowAccessor,i.lowAccessor))){const e=null!=this.config.openAccessor,t=null!=this.config.closeAccessor;this.getOpen=e?O(this.config.openAccessor,"open"):void 0,this.getHigh=O(this.config.highAccessor,"high"),this.getLow=O(this.config.lowAccessor,"low"),this.getClose=t?O(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!t,a=!0}if(!a){const t=Object.keys(e).filter(e=>!e.endsWith("Accessor")&&"timeAccessor"!==e&&"valueAccessor"!==e);for(const n of t)if(e[n]!==i[n]){a=!0;break}}a&&(this.needsFullRebuild=!0)}}function J(e,t,n){return n.x>e||e>n.x+n.w||n.y>t||t>n.y+n.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:n.x+n.w/2,cy:n.y+n.h/2}}function ee(e,t=30){return Math.max((null!=e?e:4)+5,12,t)}function te(e){return e instanceof Date?e:"number"==typeof e&&e>1e9?new Date(e):null}function ne(e,t){const n=te(e);if(!n)return!1;const o=te(t);return!o||n.getFullYear()!==o.getFullYear()||n.getMonth()!==o.getMonth()}function oe(e){let t=e%(2*Math.PI);return 0>t&&(t+=2*Math.PI),t}function re(e,t,n,o=30,r){let i=null,a=!1;if(r){const e=r.find(t,n,o);if(e){const r=ae(e,t,n,o);r&&o>r.distance&&(i=r,a=!0)}}for(const s of e){let e=null;switch(s.type){case"point":if(r&&a)break;e=ae(s,t,n,o);break;case"line":e=se(s,t,n,o);break;case"rect":e=ce(s,t,n);break;case"heatcell":e=ue(s,t,n);break;case"area":if(!1===s.interactive)break;e=he(s,t,n);break;case"candlestick":e=de(s,t,n)}e&&o>e.distance&&(i&&e.distance>=i.distance||(i=e))}return i}function ie(e,t,n){if(0===e.length)return null;const o=ge(e,t);if(0>o)return null;if(Math.abs(e[o][0]-t)>n)return null;let r=o,i=o;o>0&&e[o][0]>=t?(r=o-1,i=o):e.length-1>o&&(r=o,i=o+1);const[a,s]=e[r],[l,c]=e[i];return l===a?s:s+Math.max(0,Math.min(1,(t-a)/(l-a)))*(c-s)}function ae(e,t,n,o=30){const r=t-e.x,i=n-e.y,a=Math.sqrt(r*r+i*i);return a>ee(e.r,o)?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:a}}function se(e,t,n,o=30){var r,i,a,s;if(0===e.path.length)return null;const l=ge(e.path,t);if(0>l)return null;const[c,u]=e.path[l];let d;if(e.path.length>1){let o=1/0;const r=Math.max(0,l-1),i=Math.min(e.path.length-2,l);for(let a=r;i>=a;a++){const[r,i]=e.path[a],[s,l]=e.path[a+1],c=le(t,n,r,i,s,l);o>c&&(o=c)}d=o}else{const e=t-c,o=n-u;d=Math.sqrt(e*e+o*o)}const h=null!==(s=null!==(i=null===(r=e.style)||void 0===r?void 0:r.strokeWidth)&&void 0!==i?i:null===(a=e.style)||void 0===a?void 0:a.lineWidth)&&void 0!==s?s:1;return d>Math.max(5,h/2+2,o)?null:{node:e,datum:Array.isArray(e.datum)&&e.datum[l]?e.datum[l]:e.datum,x:c,y:u,distance:d}}function le(e,t,n,o,r,i){const a=r-n,s=i-o,l=a*a+s*s;if(0===l)return Math.sqrt(Math.pow(e-n,2)+Math.pow(t-o,2));let c=((e-n)*a+(t-o)*s)/l;c=Math.max(0,Math.min(1,c));const u=o+c*s;return Math.sqrt(Math.pow(e-(n+c*a),2)+Math.pow(t-u,2))}function ce(e,t,n){const o=J(t,n,e);return o.hit?{node:e,datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}function ue(e,t,n){const o=J(t,n,e);return o.hit?{node:e,datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}function de(e,t,n){const o=e.bodyWidth/2,r=Math.min(e.openY,e.closeY);if(!(e.x-o-3>t||t>e.x+o+3||e.highY-3>n||n>e.lowY+3)){const o=r+Math.max(Math.max(e.openY,e.closeY)-r,1)/2,i=t-e.x,a=n-o;return{node:e,datum:e.datum,x:e.x,y:o,distance:Math.sqrt(i*i+a*a)}}return null}function he(e,t,n){if(0===e.topPath.length)return null;const o=ge(e.topPath,t);if(0>o)return null;const[r,i]=e.topPath[o],a=t-r,s=n-i,l=Math.sqrt(a*a+s*s);return{node:e,datum:Array.isArray(e.datum)&&e.datum[o]?e.datum[o]:e.datum,x:r,y:i,distance:l}}function ge(e,t){if(0===e.length)return-1;let n=0,o=e.length-1;for(;o>n;){const r=n+o>>1;t>e[r][0]?n=r+1:o=r}return n>0&&Math.abs(e[n][0]-t)>=Math.abs(e[n-1][0]-t)?n-1:n}function fe(e){var t,n;const o=new Map;for(const n of e){const e=null!==(t=n.group)&&void 0!==t?t:"_default";let r=o.get(e);r||(r=[],o.set(e,r)),r.push(n)}for(const e of o.values()){e.sort((e,t)=>e.x-t.x||e.y-t.y);for(let t=0;e.length>t;t++)e[t]._groupIndex=t}const r=Array.from(o.keys()).sort((e,t)=>{const n=o.get(e),r=o.get(t);return(n.length>0?n[0].y:0)-(r.length>0?r[0].y:0)}),i=Array.from(o.values()).flat();i.sort((e,t)=>e.x-t.x||e.y-t.y);const a=new Map;for(let e=0;i.length>e;e++){i[e]._flatIndex=e;const t=null===(n=i[e].datum)||void 0===n?void 0:n.id;null!=t&&a.set(t+"",e)}return{flat:i,groups:r,byGroup:o,idToIdx:a}}function pe(e,t){var n,o;if(0===e.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const r=Math.max(0,Math.min(t,e.flat.length-1)),i=e.flat[r];return{flatIndex:r,group:null!==(n=i.group)&&void 0!==n?n:"_default",indexInGroup:null!==(o=i._groupIndex)&&void 0!==o?o:0}}function ye(e,t,n){const{group:o,indexInGroup:r}=t,i=n.byGroup.get(o);switch(e){case"ArrowRight":return i.length-1>r?i[r+1]._flatIndex:t.flatIndex;case"ArrowLeft":return r>0?i[r-1]._flatIndex:t.flatIndex;case"ArrowDown":{const e=n.groups.indexOf(o);return n.groups.length-1>e?me(n,n.groups[e+1],i[r]):t.flatIndex}case"ArrowUp":{const e=n.groups.indexOf(o);return e>0?me(n,n.groups[e-1],i[r]):t.flatIndex}case"PageDown":return Math.min(t.flatIndex+Math.max(1,Math.floor(.1*n.flat.length)),n.flat.length-1);case"PageUp":return Math.max(t.flatIndex-Math.max(1,Math.floor(.1*n.flat.length)),0);case"Home":return 0;case"End":return n.flat.length-1;case"Escape":return-1;default:return null}}function me(e,t,n){const o=e.byGroup.get(t);let r=0,i=Math.abs(o[0].x-n.x);for(let e=1;o.length>e;e++){const t=Math.abs(o[e].x-n.x);i>t&&(i=t,r=e)}return o[r]._flatIndex}function ve(e){const t=e.datum||{};return Object.assign(Object.assign({},"object"!=typeof t||null===t||Array.isArray(t)?{}:t),{data:t,x:e.x,y:e.y,time:e.x,value:e.y})}function be(t,n,o){const r=e.useRef(null),[i,a]=e.useState(null);return e.useEffect(()=>{if(!n&&!o)return;const e=r.current;if(!e)return;const t=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;a(t=>t&&t.w===e&&t.h===n?t:{w:e,h:n})}});return t.observe(e),()=>t.disconnect()},[n,o]),[r,[n&&i?i.w:t[0],o&&i?i.h:t[1]]]}function xe(t,n,o,r,i,a){e.useEffect(()=>{if(!t)return;const e=setInterval(()=>{var e;const s=n.current;if(!s||0===s.lastIngestTime)return;const l="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(e=t.threshold)&&void 0!==e?e:5e3,u=l-s.lastIngestTime>c;u!==i&&(a(u),o.current=!0,r())},1e3);return()=>clearInterval(e)},[t,i,r])}Z.QUADTREE_THRESHOLD=500;const ke={fill:e=>p.createElement("rect",{style:e,width:16,height:16}),line:e=>p.createElement("line",{style:e,x1:0,y1:0,x2:16,y2:16})};function we(e,t,n,o){let r;return r="function"==typeof n?n(e):(0,ke[n])(o(e,t)),r}function Ae(){return p.createElement("path",{d:"M4,8.8 L7.2,12 L12.8,4.8",fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function Se(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}function Oe({config:e,orientation:t="vertical",width:n=100}){const{colorFn:o,domain:r,label:i,format:a}=e,s=a||(e=>Math.round(100*e)/100+""),l="grad-legend-"+p.useId();if("horizontal"===t){const e=12,t=Math.min(n,200),a=Math.max(0,(n-t)/2),c=[];for(let e=0;64>=e;e++){const t=e/64;c.push(p.createElement("stop",{key:e,offset:100*t+"%",stopColor:o(r[0]+t*(r[1]-r[0]))}))}return p.createElement("g",{"aria-label":i||"Gradient legend"},p.createElement("defs",null,p.createElement("linearGradient",{id:l,x1:"0%",y1:"0%",x2:"100%",y2:"0%"},c)),i&&p.createElement("text",{x:a+t/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},i),p.createElement("rect",{x:a,y:0,width:t,height:e,fill:`url(#${l})`,rx:2}),p.createElement("text",{x:a,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(r[0])),p.createElement("text",{x:a+t,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(r[1])))}const c=[];for(let e=0;64>=e;e++){const t=e/64;c.push(p.createElement("stop",{key:e,offset:100*t+"%",stopColor:o(r[1]-t*(r[1]-r[0]))}))}return p.createElement("g",{"aria-label":i||"Gradient legend"},i&&p.createElement("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},i),p.createElement("defs",null,p.createElement("linearGradient",{id:l,x1:"0%",y1:"0%",x2:"0%",y2:"100%"},c)),p.createElement("rect",{x:0,y:0,width:14,height:100,fill:`url(#${l})`,rx:2}),p.createElement("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(r[1])),p.createElement("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(r[0])))}function Ee(e){const{legendGroups:t,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,legendInteraction:a,title:s="Legend",width:l=100,height:c=20,orientation:u="vertical"}=e,[d,h]=p.useState(0),[g,f]=p.useState(0),y=p.useCallback((e,t)=>{h(e),f(t)},[]),m="vertical"===u?(({legendGroups:e,width:t,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,focusedGroupIndex:a,focusedItemIndex:s,onFocusedIndexChange:l,legendInteraction:c})=>{let u=24;const d=[];return e.forEach((e,h)=>{u+=5,d.push(p.createElement("line",{key:"legend-top-line legend-symbol-"+h,stroke:"gray",x1:0,y1:u,x2:t,y2:u})),u+=8,e.label&&(u+=16,d.push(p.createElement("text",{key:"legend-text-"+h,y:u,className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},e.label)),u+=8),d.push(p.createElement("g",{key:"legend-group-"+h,className:"legend-item",transform:`translate(0,${u})`},((e,t,n,o,r,i,a,s,l,c)=>{const{type:u="fill",styleFn:d,items:h}=e,g=[];let f=0;const y=!(!t&&!n),m="isolate"===c||void 0===c&&null!=r;return h.forEach((e,c)=>{const v=we(e,c,u,d),b=Se(e,o,r),x=r&&r.size>0&&r.has(e.label);g.push(p.createElement("g",{key:"legend-item-"+c,transform:`translate(0,${f})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:y?s===i&&c===a?0:-1:void 0,role:y?"option":void 0,"aria-selected":y&&m?x||!1:void 0,"aria-current":y&&!m&&null!=o&&e.label===o||void 0,"aria-label":e.label,onKeyDown:y?n=>{var o;if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowDown"===n.key||"ArrowUp"===n.key){n.preventDefault();const e=(c+("ArrowDown"===n.key?1:-1)+h.length)%h.length;l(s,e);const t=null===(o=n.currentTarget.parentElement)||void 0===o?void 0:o.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:y?t=>{l(s,c),n&&n(e);const o=t.currentTarget.querySelector(".semiotic-legend-focus-ring");o&&o.setAttribute("visibility","visible")}:void 0,onBlur:y?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:y?"pointer":"default",opacity:b,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},y&&p.createElement("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*e.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),v,x&&p.createElement(Ae,null),p.createElement("text",{y:8,x:22,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)"},e.label))),f+=22}),g})(e,n,o,r,i,a,s,h,l,c))),u+=22*e.items.length+8}),d})({legendGroups:t||[],width:l,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,focusedGroupIndex:d,focusedItemIndex:g,onFocusedIndexChange:y,legendInteraction:a}):(({legendGroups:e,height:t,width:n,customClickBehavior:o,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:a,focusedGroupIndex:s,focusedItemIndex:l,onFocusedIndexChange:c,legendInteraction:u})=>{let d=0;const h=[];e.forEach((e,t)=>{let g=0;e.label&&(g+=16);const f=((e,t,n,o,r,i,a,s,l,c,u)=>{const{type:d="fill",styleFn:h,items:g}=e,f=[];let y=0,m=0;const v=!(!t&&!n),b="isolate"===c||void 0===c&&null!=r;g.forEach((e,c)=>{const x=we(e,c,d,h),k=Se(e,o,r),w=r&&r.size>0&&r.has(e.label),A=26+7*e.label.length;u&&u>0&&y>0&&y+A>u&&(m++,y=0),f.push(p.createElement("g",{key:"legend-item-"+c,transform:`translate(${y},${22*m})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:v?s===i&&c===a?0:-1:void 0,role:v?"option":void 0,"aria-selected":v&&b?w||!1:void 0,"aria-current":v&&!b&&null!=o&&e.label===o||void 0,"aria-label":e.label,onKeyDown:v?n=>{var o;if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowRight"===n.key||"ArrowLeft"===n.key){n.preventDefault();const e=(c+("ArrowRight"===n.key?1:-1)+g.length)%g.length;l(s,e);const t=null===(o=n.currentTarget.parentElement)||void 0===o?void 0:o.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:v?t=>{l(s,c),n&&n(e);const o=t.currentTarget.querySelector(".semiotic-legend-focus-ring");o&&o.setAttribute("visibility","visible")}:void 0,onBlur:v?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:v?"pointer":"default",opacity:k,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},v&&p.createElement("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*e.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),x,w&&p.createElement(Ae,null),p.createElement("text",{y:8,x:22,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)"},e.label))),y+=A});let x=0,k=0;for(const e of g){const t=26+7*e.label.length;u&&u>0&&k>0&&k+t>u?(x=Math.max(x,k),k=t):k+=t}x=Math.max(x,k);const w=m+1;return{items:f,offset:x,totalRows:w,totalHeight:22*w}})(e,o,r,i,a,s,l,t,c,u,n);g+=f.offset+5,h.push(Object.assign(Object.assign({label:e.label},f),{offset:g,totalRows:f.totalRows,totalHeight:f.totalHeight})),d+=g+12});let g=d>n?0:Math.max(0,(n-d)/2);const f=[];return h.forEach((n,o)=>{const r=e[o];r.label&&(f.push(p.createElement("text",{key:"legend-text-"+o,transform:`translate(${g},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},r.label)),g+=16),f.push(p.createElement("g",{key:"legend-group-"+o,className:"legend-item",transform:`translate(${g},0)`},n.items)),g+=n.offset+5,e[o+1]&&f.push(p.createElement("line",{key:"legend-top-line legend-symbol-"+o,stroke:"gray",x1:g,y1:-8,x2:g,y2:(n.totalHeight||t)+0+8})),g+=12}),p.createElement("g",null,f)})({legendGroups:t||[],title:s,height:c,width:l,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,focusedGroupIndex:d,focusedItemIndex:g,onFocusedIndexChange:y,legendInteraction:a}),v=!(!n&&!o);return p.createElement("g",{role:v?"listbox":void 0,"aria-multiselectable":!(!v||"isolate"!==a&&(void 0!==a||null==i))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"}},void 0!==s&&""!==s&&"vertical"===u&&p.createElement("text",{className:"legend-title",y:16,x:l/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)"},s),m)}function Me(e){const{legend:t,totalWidth:n,totalHeight:o,margin:r,legendPosition:i="right",title:a,legendHoverBehavior:s,legendClickBehavior:l,legendHighlightedCategory:c,legendIsolatedCategories:u,legendInteraction:d}=e;if(!t)return null;const h="top"===i||"bottom"===i;let g,f;return"left"===i?(g=4,f=r.top):"top"===i?(g=0,f=a?32:8):"bottom"===i?(g=0,f=o-r.bottom+50):(g=n-r.right+10,f=r.top),p.createElement("g",{transform:`translate(${g}, ${f})`},function(e){return"object"==typeof e&&null!==e&&"gradient"in e}(t)?p.createElement(Oe,{config:t.gradient,orientation:h?"horizontal":"vertical",width:h?n:100}):function(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}(t)?p.createElement(Ee,{legendGroups:t.legendGroups,title:"",width:h?n:100,orientation:h?"horizontal":"vertical",customHoverBehavior:s,customClickBehavior:l,highlightedCategory:c,isolatedCategories:u,legendInteraction:d}):t)}function je(e){return"string"==typeof e?{type:e}:e}function Ce({orient:t,config:n,values:o,scale:r,size:i,length:s}){const l=function(e){var t,n,o,r,i;return{type:e.type,bins:null!==(t=e.bins)&&void 0!==t?t:20,fill:null!==(n=e.fill)&&void 0!==n?n:"#4e79a7",fillOpacity:null!==(o=e.fillOpacity)&&void 0!==o?o:.5,stroke:null!==(r=e.stroke)&&void 0!==r?r:"none",strokeWidth:null!==(i=e.strokeWidth)&&void 0!==i?i:1}}(n),c="top"===t||"bottom"===t,u=e.useMemo(()=>{if(0===o.length)return null;const e=r.domain(),n=i-8;if("boxplot"===l.type){const e=function(e){const t=[...e].sort((e,t)=>e-t),n=t.length;if(0===n)return null;const o=t[Math.floor(.25*n)],r=t[Math.floor(.5*n)],i=t[Math.floor(.75*n)],a=i-o;return{q1:o,median:r,q3:i,whiskerLow:Math.max(t[0],o-1.5*a),whiskerHigh:Math.min(t[n-1],i+1.5*a)}}(o);if(!e)return null;const{q1:i,median:a,q3:s,whiskerLow:u,whiskerHigh:d}=e,h=Math.min(.5*n,20),g=(n-h)/2+4;if(c){const e=r(i),n=r(s),o=r(a),c=r(u),f=r(d),y="top"===t?-1:1,m=0;return p.createElement("g",{"data-testid":"marginal-boxplot-"+t},p.createElement("line",{x1:c,y1:m+y*(g+h/2),x2:f,y2:m+y*(g+h/2),stroke:l.fill,strokeWidth:l.strokeWidth}),p.createElement("line",{x1:c,y1:m+y*g,x2:c,y2:m+y*(g+h),stroke:l.fill,strokeWidth:l.strokeWidth}),p.createElement("line",{x1:f,y1:m+y*g,x2:f,y2:m+y*(g+h),stroke:l.fill,strokeWidth:l.strokeWidth}),p.createElement("rect",{x:Math.min(e,n),y:"top"===t?m-g-h:m+g,width:Math.abs(n-e),height:h,fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}),p.createElement("line",{x1:o,y1:"top"===t?m-g-h:m+g,x2:o,y2:"top"===t?m-g:m+g+h,stroke:l.fill,strokeWidth:2}))}{const e=r(i),n=r(s),o=r(a),c=r(u),f=r(d),y="left"===t?-1:1,m=0;return p.createElement("g",{"data-testid":"marginal-boxplot-"+t},p.createElement("line",{x1:m+y*(g+h/2),y1:c,x2:m+y*(g+h/2),y2:f,stroke:l.fill,strokeWidth:l.strokeWidth}),p.createElement("line",{x1:m+y*g,y1:c,x2:m+y*(g+h),y2:c,stroke:l.fill,strokeWidth:l.strokeWidth}),p.createElement("line",{x1:m+y*g,y1:f,x2:m+y*(g+h),y2:f,stroke:l.fill,strokeWidth:l.strokeWidth}),p.createElement("rect",{x:"left"===t?m-g-h:m+g,y:Math.min(e,n),width:h,height:Math.abs(n-e),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}),p.createElement("line",{x1:"left"===t?m-g-h:m+g,y1:o,x2:"left"===t?m-g:m+g+h,y2:o,stroke:l.fill,strokeWidth:2}))}}const u=a.bin().domain(e).thresholds(l.bins)(o);if(0===u.length)return null;const d=Math.max(...u.map(e=>e.length));if(0===d)return null;if("histogram"===l.type)return p.createElement("g",{"data-testid":"marginal-histogram-"+t},u.map((e,o)=>{if(null==e.x0||null==e.x1)return null;const i=e.length/d*n;if(c){const n=r(e.x0),a=r(e.x1)-r(e.x0);return p.createElement("rect",{key:o,x:n,y:"top"===t?-4-i:4,width:Math.max(a,.5),height:i,fill:l.fill,fillOpacity:l.fillOpacity,stroke:l.stroke,strokeWidth:l.strokeWidth})}{const n=r(e.x0),a=r(e.x1)-r(e.x0);return p.createElement("rect",{key:o,x:"left"===t?-4-i:4,y:Math.min(n,n+a),width:i,height:Math.abs(a),fill:l.fill,fillOpacity:l.fillOpacity,stroke:l.stroke,strokeWidth:l.strokeWidth})}}));if("violin"===l.type){const e=n/2+4,o=[];for(const i of u){if(null==i.x0||null==i.x1)continue;const a=i.length/d*(n/2),s=r((i.x0+i.x1)/2);o.push(c?`${s},${"top"===t?-(e-a):e-a}`:`${"left"===t?-(e-a):e-a},${s}`)}for(let i=u.length-1;i>=0;i--){const a=u[i];if(null==a.x0||null==a.x1)continue;const s=a.length/d*(n/2),l=r((a.x0+a.x1)/2);o.push(c?`${l},${"top"===t?-(e+s):e+s}`:`${"left"===t?-(e+s):e+s},${l}`)}return p.createElement("g",{"data-testid":"marginal-violin-"+t},p.createElement("polygon",{points:o.join(" "),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}))}if("ridgeline"===l.type){const e=[];if(c){const o=0,i=null!=u[0].x0?r(u[0].x0):0;e.push(`M${i},${o}`);for(const o of u){if(null==o.x0||null==o.x1)continue;const i=o.length/d*n,a=r((o.x0+o.x1)/2);e.push(`L${a},${"top"===t?-i-4:i+4}`)}const a=null!=u[u.length-1].x1?r(u[u.length-1].x1):s;e.push(`L${a},${o}`),e.push("Z")}else{const o=0,i=null!=u[0].x0?r(u[0].x0):0;e.push(`M${o},${i}`);for(const o of u){if(null==o.x0||null==o.x1)continue;const i=o.length/d*n,a=r((o.x0+o.x1)/2);e.push(`L${"left"===t?-i-4:i+4},${a}`)}const a=null!=u[u.length-1].x1?r(u[u.length-1].x1):s;e.push(`L${o},${a}`),e.push("Z")}return p.createElement("g",{"data-testid":"marginal-ridgeline-"+t},p.createElement("path",{d:e.join(" "),fill:l.fill,fillOpacity:l.fillOpacity,stroke:"none"===l.stroke?l.fill:l.stroke,strokeWidth:l.strokeWidth}))}return null},[o,r,l,i,s,t,c,4]);return u?p.createElement("g",{className:"marginal-"+t,"data-testid":"marginal-"+t},u):null}function Pe(e,t=120,n=8){if(!e)return[];const o=Math.max(1,Math.floor(t/n)),r=e.split(/\s+/),i=[];let a="";for(const e of r)a&&a.length+1+e.length>o?(i.push(a),a=e):a=a?`${a} ${e}`:e;return a&&i.push(a),i}function Le(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 _e(e){const{x:t=0,y:n=0,dx:o,dy:r,nx:i,ny:a,note:s,connector:l,subject:c,type:u,color:d,className:h,disable:g,events:f={},"data-testid":y}=e,m=new Set(Array.isArray(g)?g:[]);let v=o||0,b=r||0;null!=i&&(v=i-t),null!=a&&(b=a-n);const x="string"==typeof u?u:"label";if("bracket"===x&&c&&0===v&&0===b)if(void 0!==c.width){v=c.width/2;const e=c.depth||30;b=e+(0>e?-5:5)}else if(void 0!==c.height){const e=c.depth||30;v=e+(0>e?-5:5),b=c.height/2}return p.createElement("g",Object.assign({className:("annotation "+(h||"")).trim(),transform:`translate(${t},${n})`,"data-testid":y},f),!m.has("connector")&&function(e,t,n,o,r,i){const a=[];let s=0,l=0;if("callout-circle"!==r&&"label"!==r||!(null==i?void 0:i.radius)){if("callout-rect"===r&&i){const n=i.width||0,o=i.height||0;if(n>0||o>0){const r=n/2,i=o/2,a=e-r,c=t-i;if(0!==a||0!==c){const e=Math.abs(a),t=Math.abs(c),u=n/2,d=o/2,h=e*d>t*u?u/e:d/t;s=r+a*h,l=i+c*h}}}else if("bracket"===r&&i){const e=i.width,t=i.height,n=i.depth||30;void 0!==e?(s=e/2,l=n):void 0!==t&&(s=n,l=t/2)}}else{const n=(i.radius||0)+(i.radiusPadding||0);if(n>0&&(0!==e||0!==t)){const o=Math.atan2(t,e);s=Math.cos(o)*n,l=Math.sin(o)*n}}if(Math.sqrt(Math.pow(e-s,2)+Math.pow(t-l,2))>.5&&(a.push(p.createElement("line",{key:"connector-line",x1:s,y1:l,x2:e,y2:t,stroke:o||"var(--semiotic-text-secondary, currentColor)"})),"arrow"===(null==n?void 0:n.end))){const n=10,r=16/180*Math.PI,i=Math.atan2(t-l,e-s);a.push(p.createElement("path",{key:"connector-arrow",d:`M${s},${l}L${s+n*Math.cos(i+r)},${l+n*Math.sin(i+r)}L${s+n*Math.cos(i-r)},${l+n*Math.sin(i-r)}Z`,fill:o||"var(--semiotic-text-secondary, currentColor)",stroke:"none"}))}return p.createElement("g",{className:"annotation-connector"},a)}(v,b,l,d,x,c),!m.has("subject")&&function(e,t,n,o,r){var i;const a=[];switch(e){case"callout-circle":{const e=((null==t?void 0:t.radius)||0)+((null==t?void 0:t.radiusPadding)||0);e>0&&a.push(p.createElement("circle",{key:"subject-circle",r:e,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"}));break}case"callout-rect":{const e=(null==t?void 0:t.width)||0,o=(null==t?void 0:t.height)||0;(e>0||o>0)&&a.push(p.createElement("rect",{key:"subject-rect",width:e,height:o,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"}));break}case"callout-custom":(null==t?void 0:t.custom)&&a.push(...Array.isArray(t.custom)?t.custom:[t.custom]);break;case"xy-threshold":{const e=o||0,i=r||0;if(void 0!==(null==t?void 0:t.x)){const o=(t.x||0)-e;a.push(p.createElement("line",{key:"threshold-line",x1:o,y1:(t.y1||0)-i,x2:o,y2:(t.y2||0)-i,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"}))}else if(void 0!==(null==t?void 0:t.y)){const o=(t.y||0)-i;a.push(p.createElement("line",{key:"threshold-line",x1:(t.x1||0)-e,y1:o,x2:(t.x2||0)-e,y2:o,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"}))}else void 0!==(null==t?void 0:t.x1)||void 0!==(null==t?void 0:t.x2)?a.push(p.createElement("line",{key:"threshold-line",x1:(t.x1||0)-e,y1:0,x2:(t.x2||0)-e,y2:0,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"})):void 0===(null==t?void 0:t.y1)&&void 0===(null==t?void 0:t.y2)||a.push(p.createElement("line",{key:"threshold-line",x1:0,y1:(t.y1||0)-i,x2:0,y2:(t.y2||0)-i,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"}));break}case"bracket":{const e=null!==(i=null==t?void 0:t.width)&&void 0!==i?i:null==t?void 0:t.height;void 0!==e&&a.push(p.createElement("path",{key:"bracket-path",d:Le((null==t?void 0:t.type)||"curly",e,(null==t?void 0:t.depth)||30,void 0===(null==t?void 0:t.width)),fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"}));break}}return p.createElement("g",{className:"annotation-subject"},a)}(x,c,d,t,n),!m.has("note")&&function(e,t,n,o){if(!e)return p.createElement("g",{className:"annotation-note"});const{label:r,title:i,orientation:a,align:s,wrap:l=120,noWrap:c}=e;if(!r&&!i)return p.createElement("g",{className:"annotation-note"});let u=a;u||(u=Math.abs(t)>Math.abs(n)?"leftRight":"topBottom");let d=s;d&&"dynamic"!==d||(d="topBottom"===u?0>t?"right":"left":0>n?"bottom":"top");let h="start";"topBottom"===u?"right"===d?h="end":"middle"===d&&(h="middle"):h=0>t?"end":"start";const g=16,f=i?c?[i]:Pe(i,l):[],y=r?c?[r]:Pe(r,l):[],m="leftRight"===u?"end"===h?-4:4:0;let v=0;const b=[],x=o||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";f.length>0&&(b.push(p.createElement("text",{key:"annotation-note-title",className:"annotation-note-title",fill:x,textAnchor:h,fontWeight:"bold"},f.map((e,t)=>p.createElement("tspan",{key:t,x:m,dy:0===t?0:g},e)))),v=f.length*g),y.length>0&&b.push(p.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:x,textAnchor:h,y:v},y.map((e,t)=>p.createElement("tspan",{key:t,x:m,dy:0===t?0:g},e))));let k=null;if((i||r)&&(0!==t||0!==n))if("topBottom"===u){const e=Math.min(l,120);let t=0,n=e;"end"===h?(t=-e,n=0):"middle"===h&&(t=-e/2,n=e/2),k=p.createElement("line",{className:"note-line",x1:t,x2:n,y1:0,y2:0,stroke:o||"var(--semiotic-text-secondary, currentColor)"})}else{const e=(f.length+y.length)*g+(y.length>0?g:0);let t=0,n=e;"bottom"===d?(t=-e,n=0):"middle"===d&&(t=-e/2,n=e/2),k=p.createElement("line",{className:"note-line",x1:0,x2:0,y1:t,y2:n,stroke:o||"var(--semiotic-text-secondary, currentColor)"})}const w=Math.max(0,f.length+y.length-1)*g;let A=0;return"topBottom"===u?A=0>n?-(w+2):18:"leftRight"===u&&(A="middle"===d?-(w+g+(y.length>0&&f.length>0?2:0))/2+8:"bottom"===d||0>n?-(w+2):18),p.createElement("g",{className:"annotation-note",transform:`translate(${t},${n})`},p.createElement("g",{className:"annotation-note-content",transform:0!==A?`translate(0,${A})`:void 0},b),k)}(s,v,b,d))}function Te(e){var t,n;const{noteData:o}=e,{screenCoordinates:r}=o,i="string"==typeof o.type?o.type:"label",a=o.eventListeners||o.events||{};if(o.coordinates&&r){const e=o.nx||r[0][0]+(null!==(t=o.dx)&&void 0!==t?t:0),a=o.ny||r[0][1]+(null!==(n=o.dy)&&void 0!==n?n:0),s=r.map((t,n)=>{const r=Object.assign({},o,{note:0===n?o.note:{label:""},x:t[0],y:t[1],nx:e,ny:a});return p.createElement(_e,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+n},r,{type:i}))});return p.createElement("g",null,s)}const s=o.note||{title:"none",label:o.label};return p.createElement(_e,Object.assign({"data-testid":"semiotic-annotation",key:`${s.label}-${s.title}-${o.i}`,events:a},o,{type:i}))}function Be(e,t){var n,o,r;const i=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.x)&&void 0!==o?o:null===(r=t.scales)||void 0===r?void 0:r.time;return i?null!=e.x?i(e.x):t.xAccessor&&null!=e[t.xAccessor]?i(e[t.xAccessor]):null:null}function Ne(e,t){var n,o,r;const i=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.y)&&void 0!==o?o:null===(r=t.scales)||void 0===r?void 0:r.value;return i?null!=e.y?i(e.y):t.yAccessor&&null!=e[t.yAccessor]?i(e[t.yAccessor]):null:null}function De(e,t,n){var o,r,i,a;const s=e.anchor||"fixed";if("latest"===s){if(null!=e.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let r=n.pointNodes.length-1;r>=0;r--){const i=n.pointNodes[r];if(i.pointId===e.pointId){const e={x:i.x,y:i.y};return null===(o=n.stickyPositionCache)||void 0===o||o.set(t,e),e}}const i=function(e){var t,n,o,r,i,a;const s=e.data;if(!s||0===s.length)return null;const l=s[s.length-1],c=null!==(n=null===(t=e.scales)||void 0===t?void 0:t.x)&&void 0!==n?n:null===(o=e.scales)||void 0===o?void 0:o.time,u=null!==(i=null===(r=e.scales)||void 0===r?void 0:r.y)&&void 0!==i?i:null===(a=e.scales)||void 0===a?void 0:a.value;if(!c||!u)return null;const d=l[e.xAccessor||"x"],h=l[e.yAccessor||"y"];return null==d||null==h?null:{x:c(d),y:u(h)}}(n);return i&&(null===(r=n.stickyPositionCache)||void 0===r||r.set(t,i)),i}let l=null,c=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(l=t.x,c=t.y)}if(null!=l&&null!=c||(l=Be(e,n),c=Ne(e,n)),null!=l&&null!=c)return null===(i=n.stickyPositionCache)||void 0===i||i.set(t,{x:l,y:c}),{x:l,y:c};if("sticky"===s){const e=null===(a=n.stickyPositionCache)||void 0===a?void 0:a.get(t);if(e)return e}return null}function Ie(e,t,n,o=50){return!(-o>e||e>(n.width||0)+o||-o>t||t>(n.height||0)+o)}const Re={linear:l.curveLinear,monotoneX:l.curveMonotoneX,monotoneY:l.curveMonotoneY,step:l.curveStep,stepAfter:l.curveStepAfter,stepBefore:l.curveStepBefore,basis:l.curveBasis,cardinal:l.curveCardinal,catmullRom:l.curveCatmullRom};function He(e){return function(e,t,n){var o,r,i,a,c,u,d,h,g,f,m,v,b,x,k,w,A,S,O,E,M,j,C,P,L,_,T,B,N,D,I,R,H,W,F,$,z,G,q,Y,X,V,U,K,Q,Z,J,ee;switch(e.type){case"label":{const o=De(e,t,n);if(!o)return null;const{x:r,y:i}=o;return Ie(r,i,n)?p.createElement(Te,{key:"ann-"+t,noteData:{x:r,y:i,dx:e.dx||30,dy:e.dy||-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"label",connector:e.connector||{end:"arrow"},color:e.color}}):null}case"callout":{const o=De(e,t,n);if(!o)return null;const{x:r,y:i}=o;return Ie(r,i,n)?p.createElement(Te,{key:"ann-"+t,noteData:{x:r,y:i,dx:e.dx||30,dy:e.dy||-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"callout-circle",subject:{radius:e.radius||12},connector:e.connector||{end:"arrow"},color:e.color}}):null}case"x-threshold":{const o=Be(e,n);if(null==o)return null;const r=e.color||"#f97316",i=e.labelPosition||"top";let a;return a="bottom"===i?(n.height||0)-4:"center"===i?(n.height||0)/2:12,p.createElement("g",{key:"ann-"+t},p.createElement("line",{x1:o,y1:0,x2:o,y2:n.height||0,stroke:r,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&p.createElement("text",{x:o+4,y:a,fill:r,fontSize:12,fontWeight:"bold"},e.label))}case"y-threshold":{const o=Ne(e,n);if(null==o)return null;const r=e.color||"#f97316",i=e.labelPosition||"right";let a,s;return"left"===i?(a=4,s="start"):"center"===i?(a=(n.width||0)/2,s="middle"):(a=(n.width||0)-4,s="end"),p.createElement("g",{key:"ann-"+t},p.createElement("line",{x1:0,y1:o,x2:n.width||0,y2:o,stroke:r,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&p.createElement("text",{x:a,y:o-4,textAnchor:s,fill:r,fontSize:12,fontWeight:"bold"},e.label))}case"enclose":{const o=(e.coordinates||[]).map(e=>({x:Be(Object.assign(Object.assign({},e),{type:"point"}),n),y:Ne(Object.assign(Object.assign({},e),{type:"point"}),n),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>o.length)return null;const r=s.packEnclose(o),i=e.padding||10;return p.createElement("g",{key:"ann-"+t},p.createElement("circle",{cx:r.x,cy:r.y,r:r.r+i,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&p.createElement("text",{x:r.x,y:r.y-r.r-i-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12},e.label))}case"rect-enclose":{const o=(e.coordinates||[]).map(e=>({x:Be(Object.assign(Object.assign({},e),{type:"point"}),n),y:Ne(Object.assign(Object.assign({},e),{type:"point"}),n)})).filter(e=>null!=e.x&&null!=e.y);if(2>o.length)return null;const r=e.padding||10,i=o.map(e=>e.x),a=o.map(e=>e.y),s=Math.min(...i)-r,l=Math.max(...i)+r,c=Math.min(...a)-r,u=Math.max(...a)+r;return p.createElement("g",{key:"ann-"+t},p.createElement("rect",{x:s,y:c,width:l-s,height:u-c,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&p.createElement("text",{x:(s+l)/2,y:c-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12},e.label))}case"highlight":{const o=n.data||[],r="function"==typeof e.filter?o.filter(e.filter):e.field&&null!=e.value?o.filter(t=>t[e.field]===e.value):[],i={stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return p.createElement("g",{key:"ann-"+t},r.map((t,o)=>{const r=Be(t,n),a=Ne(t,n);if(null==r||null==a)return null;const s="function"==typeof e.r?e.r(t):e.r||6,l="function"==typeof e.style?e.style(t):e.style||i;return p.createElement("circle",Object.assign({key:"hl-"+o,cx:r,cy:a,r:s},l))}))}case"bracket":{const o=Be(e,n),r=Ne(e,n);return p.createElement(Te,{key:"ann-"+t,noteData:{x:null!=o?o:0,y:null!=r?r:0,dx:e.dx||0,dy:e.dy||0,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"bracket",subject:{type:e.bracketType||"curly",width:e.width,height:e.height,depth:e.depth||30},color:e.color}})}case"trend":{const s=n.data||[];if(2>s.length)return null;const l=n.xAccessor||"x",h=n.yAccessor||"y",g=s.map(e=>[e[l],e[h]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>g.length)return null;const f=null!==(r=null===(o=n.scales)||void 0===o?void 0:o.x)&&void 0!==r?r:null===(i=n.scales)||void 0===i?void 0:i.time,m=null!==(c=null===(a=n.scales)||void 0===a?void 0:a.y)&&void 0!==c?c:null===(u=n.scales)||void 0===u?void 0:u.value;if(!f||!m)return null;const v=e.method||"linear";let b;b="loess"===v?function(e,t=.3){const n=e.length;if(2>n)return e.slice();const o=e.slice().sort((e,t)=>e[0]-t[0]),r=o.map(e=>e[0]),i=o.map(e=>e[1]),a=Math.max(2,Math.ceil(t*n)),s=[];for(let e=0;n>e;e++){const t=r[e],o=r.map(e=>Math.abs(e-t)),l=o.slice().sort((e,t)=>e-t)[Math.min(a-1,n-1)]||1,c=[];for(let e=0;n>e;e++){const t=0===l?0:o[e]/l;c[e]=1>t?Math.pow(1-Math.pow(t,3),3):0}let u=0,d=0,h=0,g=0,f=0;for(let e=0;n>e;e++){const t=c[e];0!==t&&(u+=t,d+=t*r[e],h+=t*i[e],g+=t*r[e]*r[e],f+=t*r[e]*i[e])}if(0===u){s.push([t,i[e]]);continue}const p=u*g-d*d;if(1e-12>Math.abs(p))s.push([t,h/u]);else{const e=(u*f-d*h)/p;s.push([t,(h-e*d)/u+e*t])}}return s}(g,null!==(d=e.bandwidth)&&void 0!==d?d:.3):("polynomial"===v?y.default.polynomial(g,{order:e.order||2}):y.default.linear(g)).points;const x=b.map(([e,t])=>`${f(e)},${m(t)}`).join(" "),k=e.color||"#6366f1";return p.createElement("g",{key:"ann-"+t},p.createElement("polyline",{points:x,fill:"none",stroke:k,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&p.createElement("text",{x:f(b[b.length-1][0])+4,y:m(b[b.length-1][1])-4,fill:k,fontSize:11},e.label))}case"band":{const o=null!==(g=null===(h=n.scales)||void 0===h?void 0:h.y)&&void 0!==g?g:null===(f=n.scales)||void 0===f?void 0:f.value,r=null!==(m=null==o?void 0:o(e.y0))&&void 0!==m?m:0,i=null!==(v=null==o?void 0:o(e.y1))&&void 0!==v?v:n.height||0;return p.createElement("g",{key:"ann-"+t},p.createElement("rect",{x:0,y:Math.min(r,i),width:n.width||0,height:Math.abs(i-r),fill:e.fill||"var(--semiotic-primary, #6366f1)",fillOpacity:e.fillOpacity||.1}),e.label&&p.createElement("text",{x:(n.width||0)-4,y:Math.min(r,i)-4,textAnchor:"end",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11},e.label))}case"envelope":{const o=n.data||[];if(2>o.length)return null;const r=n.xAccessor||"x",i=null!==(x=null===(b=n.scales)||void 0===b?void 0:b.x)&&void 0!==x?x:null===(k=n.scales)||void 0===k?void 0:k.time,a=null!==(A=null===(w=n.scales)||void 0===w?void 0:w.y)&&void 0!==A?A:null===(S=n.scales)||void 0===S?void 0:S.value;if(!i||!a)return null;const s=e.upperAccessor||"upperBounds",c=e.lowerAccessor||"lowerBounds",u=e.filter,d=o.filter(e=>null!=e[s]&&null!=e[c]&&!(u&&!u(e))).sort((e,t)=>e[r]-t[r]);if(2>d.length)return null;const h=Re[n.curve||"linear"]||l.curveLinear,g=l.area().x(e=>i(e[r])).y0(e=>a(e[c])).y1(e=>a(e[s])).curve(h)(d);if(!g)return null;const f=e.fill||"#6366f1";return p.createElement("g",{key:"ann-"+t},p.createElement("path",{d:g,fill:f,fillOpacity:null!==(O=e.fillOpacity)&&void 0!==O?O:.15,stroke:"none"}),e.label&&d.length>0&&p.createElement("text",{x:i(d[d.length-1][r])+4,y:a(d[d.length-1][s])-4,fill:f,fontSize:11},e.label))}case"anomaly-band":{const o=n.data||[];if(2>o.length)return null;const r=n.yAccessor||"y",i=null!==(M=null===(E=n.scales)||void 0===E?void 0:E.x)&&void 0!==M?M:null===(j=n.scales)||void 0===j?void 0:j.time,a=null!==(P=null===(C=n.scales)||void 0===C?void 0:C.y)&&void 0!==P?P:null===(L=n.scales)||void 0===L?void 0:L.value;if(!i||!a)return null;const s=o.map(e=>e[r]).filter(e=>null!=e&&isFinite(e));if(2>s.length)return null;const l=s.reduce((e,t)=>e+t,0)/s.length,c=s.reduce((e,t)=>e+Math.pow(t-l,2),0)/s.length,u=Math.sqrt(c),d=null!==(_=e.threshold)&&void 0!==_?_:2,h=l-d*u,g=!1!==e.showBand,f=e.fill||"#6366f1",y=null!==(T=e.fillOpacity)&&void 0!==T?T:.1,m=e.anomalyColor||"#ef4444",v=null!==(B=e.anomalyRadius)&&void 0!==B?B:6,b=a(l+d*u),x=a(h),k=o.filter(e=>{const t=e[r];return null!=t&&Math.abs(t-l)>d*u});return p.createElement("g",{key:"ann-"+t},g&&p.createElement("rect",{x:0,y:Math.min(b,x),width:n.width||0,height:Math.abs(x-b),fill:f,fillOpacity:y}),k.map((e,t)=>{const o=Be(e,n),r=Ne(e,n);return null==o||null==r?null:p.createElement("circle",{key:"anomaly-"+t,cx:o,cy:r,r:v,fill:m,fillOpacity:.7,stroke:m,strokeWidth:1.5})}),e.label&&p.createElement("text",{x:(n.width||0)-4,y:Math.min(b,x)-4,textAnchor:"end",fill:f,fontSize:11},e.label))}case"forecast":{const o=n.data||[];if(3>o.length)return null;const r=n.xAccessor||"x",i=n.yAccessor||"y",a=null!==(D=null===(N=n.scales)||void 0===N?void 0:N.x)&&void 0!==D?D:null===(I=n.scales)||void 0===I?void 0:I.time,s=null!==(H=null===(R=n.scales)||void 0===R?void 0:R.y)&&void 0!==H?H:null===(W=n.scales)||void 0===W?void 0:W.value;if(!a||!s)return null;const l=o.map(e=>[e[r],e[i]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]);if(3>l.length)return null;let c;if("polynomial"===(e.method||"linear")){const t=y.default.polynomial(l,{order:e.order||2}).equation;c=e=>t.reduce((t,n,o)=>t+n*Math.pow(e,o),0)}else{const e=l.length;let t=0,n=0,o=0,r=0;for(const[e,i]of l)t+=e,n+=i,o+=e*e,r+=e*i;const i=e*o-t*t;if(1e-12>Math.abs(i))return null;const a=(e*r-t*n)/i,s=(n-a*t)/e;c=e=>s+a*e}const u=l.length,d=l.map(([e,t])=>t-c(e)).reduce((e,t)=>e+t*t,0),h=Math.sqrt(d/Math.max(u-2,1)),g=l.reduce((e,t)=>e+t[0],0)/u,f=l.reduce((e,t)=>e+Math.pow(t[0]-g,2),0),m=null!==(F=e.confidence)&&void 0!==F?F:.95,v=.99>m?.95>m?.9>m?1:1.645:1.96:2.576,b=null!==($=e.steps)&&void 0!==$?$:5,x=l[u-1][0],k=(x-l[0][0])/Math.max(u-1,1),w=[];for(let e=1;b>=e;e++)w.push(x+e*k);const A=[];for(const e of w){const t=c(e),n=h*Math.sqrt(1+1/u+(f>0?Math.pow(e-g,2)/f:0))*v;A.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const S=`M${A.map(e=>`${a(e.x)},${s(e.yUpper)}`).join(" L")} L${A.slice().reverse().map(e=>`${a(e.x)},${s(e.yLower)}`).join(" L")} Z`,O=A.map(e=>`${a(e.x)},${s(e.yCenter)}`).join(" "),E=`${a(x)},${s(c(x))}`,M=e.strokeColor||"#6366f1";return p.createElement("g",{key:"ann-"+t},p.createElement("path",{d:S,fill:e.fill||"#6366f1",fillOpacity:null!==(z=e.fillOpacity)&&void 0!==z?z:.15,stroke:"none"}),p.createElement("polyline",{points:`${E} ${O}`,fill:"none",stroke:M,strokeWidth:null!==(G=e.strokeWidth)&&void 0!==G?G:2,strokeDasharray:null!==(q=e.strokeDasharray)&&void 0!==q?q:"6,3"}),e.label&&A.length>0&&p.createElement("text",{x:a(A[A.length-1].x)+4,y:s(A[A.length-1].yCenter)-4,fill:M,fontSize:11},e.label))}case"widget":{let o=null,r=null;if(null!=e.px&&null!=e.py)o=e.px,r=e.py;else{const i=De(e,t,n);if(!i)return null;o=i.x,r=i.y}if(null==o||null==r)return null;if(!Ie(o,r,n))return null;const i=null!==(Y=e.dx)&&void 0!==Y?Y:0,a=null!==(X=e.dy)&&void 0!==X?X:0,s=null!==(V=e.width)&&void 0!==V?V:32,l=null!==(U=e.height)&&void 0!==U?U:32,c=null!==(K=e.content)&&void 0!==K?K:p.createElement("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info"},"ℹ️");return p.createElement("foreignObject",{key:"ann-"+t,x:o+i-s/2,y:r+a-l/2,width:s,height:l,style:{overflow:"visible",pointerEvents:"auto"}},p.createElement("div",{style:{width:s,height:l,display:"flex",alignItems:"center",justifyContent:"center"}},c))}case"text":{const o=De(e,t,n);if(!o)return null;const{x:r,y:i}=o;return p.createElement("text",{key:"ann-text-"+t,x:r+(e.dx||0),y:i+(e.dy||0),fill:e.color||"var(--semiotic-text, #333)",fontSize:e.fontSize||11,dominantBaseline:"middle",style:{fontFamily:"inherit"}},e.label)}case"category-highlight":{const o=e.category;if(null==o)return null;const r=null===(Q=n.scales)||void 0===Q?void 0:Q.o,i=null===(Z=n.scales)||void 0===Z?void 0:Z.x,a=null===(J=n.scales)||void 0===J?void 0:J.y,s=(null==r?void 0:r.bandwidth)?r:(null==i?void 0:i.bandwidth)?i:(null==a?void 0:a.bandwidth)?a:null;if(!s)return null;const l=s(o);if(null==l)return null;const c=s.bandwidth(),u=e.color||"var(--semiotic-primary, #4589ff)",d=null!==(ee=e.opacity)&&void 0!==ee?ee:.15,h=e.label;return(n.projection?"vertical"===n.projection:s===i)?p.createElement("g",{key:"ann-"+t},p.createElement("rect",{x:l,y:0,width:c,height:n.height||0,fill:u,fillOpacity:d}),h&&p.createElement("text",{x:l+c/2,y:12,textAnchor:"middle",fill:u,fontSize:12,fontWeight:"bold"},h)):p.createElement("g",{key:"ann-"+t},p.createElement("rect",{x:0,y:l,width:n.width||0,height:c,fill:u,fillOpacity:d}),h&&p.createElement("text",{x:12,y:l+c/2,dominantBaseline:"middle",fill:u,fontSize:12,fontWeight:"bold"},h))}default:return null}}}let We={positions:new Map};const Fe=new Set;function $e(){for(const e of Fe)e()}function ze(e,t){const n=We.positions.get(e);if(null==n?void 0:n.locked)return;if(!n||n.sourceId!==t)return;const o=new Map(We.positions);o.delete(e),We={positions:o},$e()}function Ge(e,t){const n=We.positions.get(e);if(!(null==n?void 0:n.locked))return;if(t&&n.sourceId!==t)return;const o=new Map(We.positions);o.delete(e),We={positions:o},$e()}function qe(){return We}function Ye(e){return Fe.add(e),()=>Fe.delete(e)}const Xe={positions:new Map};function Ve(){return()=>{}}function Ue(){return Xe}function Ke(e){if(e)return"dashed"===e?"6,4":"dotted"===e?"2,4":e}function Qe(e,t,n){if("left"===e||"right"===e){const o="left"===e?n:0,r="left"===e?-1:1,i=Math.ceil(t/8);let a="M0,"+o;for(let e=0;i>e;e++){const n=8*(e+1);a+=`L${Math.min(8*e+4,t)},${o+4*r}`,a+=`L${Math.min(n,t)},${o}`}return a}{const o="bottom"===e?0:t,r="bottom"===e?1:-1,i=Math.ceil(n/8);let a=`M${o},0`;for(let e=0;i>e;e++){const t=8*(e+1);a+=`L${o+4*r},${Math.min(8*e+4,n)}`,a+=`L${o},${Math.min(t,n)}`}return a}}function Ze(t){const{width:n,height:o,totalWidth:r,totalHeight:i,margin:a,scales:s,showAxes:l,axes:c,showGrid:u,xFormat:d,yFormat:h}=t,g=e.useMemo(()=>{var e;if(!s)return[];const t=null==c?void 0:c.find(e=>"bottom"===e.orient),o=(null==t?void 0:t.tickFormat)||d||Je,r=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5,i=s.x.ticks(Math.min(r,Math.max(2,Math.floor(n/70)))),a=i.map(e=>e.valueOf()),l=i.map((e,t)=>({value:e,pixel:s.x(e),label:o(e,t,a)})),u=l.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:"number"==typeof t.label?6.5*(t.label+"").length:60),0);return et(l,Math.max(55,u+8))},[s,c,d,n]),f=e.useMemo(()=>{var e;if(!s)return[];const t=null==c?void 0:c.find(e=>"left"===e.orient),n=(null==t?void 0:t.tickFormat)||h||Je,r=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;return et(s.y.ticks(Math.min(r,Math.max(2,Math.floor(o/30)))).map(e=>({value:e,pixel:s.y(e),label:n(e)})),22)},[s,c,h,o]),y=u&&s,m=l&&s;if(!y&&!m)return null;const v=null==c?void 0:c.find(e=>"bottom"===e.orient),b=null==c?void 0:c.find(e=>"left"===e.orient),x=m&&(!v||!1!==v.baseline),k=m&&(!b||!1!==b.baseline),w=(null==v?void 0:v.jaggedBase)||!1,A=(null==b?void 0:b.jaggedBase)||!1,S="var(--semiotic-border, #ccc)";return p.createElement("svg",{width:r,height:i,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},p.createElement("g",{transform:`translate(${a.left},${a.top})`},y&&(()=>{var e,t;const r=Ke(null===(e=null==c?void 0:c.find(e=>"bottom"===e.orient))||void 0===e?void 0:e.gridStyle),i=Ke(null===(t=null==c?void 0:c.find(e=>"left"===e.orient))||void 0===t?void 0:t.gridStyle);return p.createElement("g",{className:"stream-grid"},g.map((e,t)=>p.createElement("line",{key:"xgrid-"+t,x1:e.pixel,y1:0,x2:e.pixel,y2:o,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r})),f.map((e,t)=>p.createElement("line",{key:"ygrid-"+t,x1:0,y1:e.pixel,x2:n,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:i})))})(),x&&!w&&p.createElement("line",{x1:0,y1:o,x2:n,y2:o,stroke:S,strokeWidth:1}),w&&p.createElement("path",{d:Qe("bottom",n,o),fill:"none",stroke:S,strokeWidth:1}),k&&!A&&p.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:S,strokeWidth:1}),A&&p.createElement("path",{d:Qe("left",n,o),fill:"none",stroke:S,strokeWidth:1})))}function Je(e,t,n){return e instanceof Date?`${e.toLocaleString("en",{month:"short"})} ${e.getDate()}`:"number"==typeof e?Math.round(100*e)/100+"":e+""}function et(e,t){if(2>=e.length)return e;const n=[e[0]];for(let o=1;e.length-1>o;o++)t>Math.abs(e[o].pixel-n[n.length-1].pixel)||n.push(e[o]);const o=e[e.length-1];return t>Math.abs(o.pixel-n[n.length-1].pixel)?n[n.length-1]=o:n.push(o),n}function tt(t){var n,o;const{width:r,height:i,totalWidth:a,totalHeight:s,margin:l,scales:c,showAxes:u,axes:d,xLabel:h,yLabel:g,yLabelRight:f,xFormat:y,yFormat:m,showGrid:v,title:b,legend:x,legendHoverBehavior:k,legendClickBehavior:w,legendHighlightedCategory:A,legendIsolatedCategories:S,legendPosition:O="right",foregroundGraphics:E,marginalGraphics:M,xValues:j,yValues:C,annotations:P,svgAnnotationRules:L,xAccessor:_,yAccessor:T,annotationData:B,pointNodes:N,curve:D,underlayRendered:I,linkedCrosshairName:R,linkedCrosshairSourceId:H,children:W}=t,F=e.useMemo(()=>{var e;if(!u||!c)return[];const t=null==d?void 0:d.find(e=>"bottom"===e.orient),n=(null==t?void 0:t.tickFormat)||y||Je,o=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5,i=c.x.ticks(Math.min(o,Math.max(2,Math.floor(r/70)))),a=i.map(e=>e.valueOf()),s=i.map((e,t)=>({value:e,pixel:c.x(e),label:n(e,t,a)})),l=s.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:"number"==typeof t.label?6.5*(t.label+"").length:60),0),h=(null==t?void 0:t.autoRotate)?Math.max(20,Math.min(l+8,55)):Math.max(55,l+8);let g=et(s,h);if(g.length>1&&(g=g.filter((e,t)=>0===t||e.label+""!=g[t-1].label+"")),(null==t?void 0:t.includeMax)&&g.length>0){const e=c.x.domain()[1],t=c.x(e),o=g[g.length-1].pixel;if(Math.abs(t-o)>1){const r=n(e,g.length,a);h>t-o&&g.length>1&&(g=g.slice(0,-1)),g.push({value:e,pixel:t,label:r})}}return g},[u,c,d,y,r]),$=e.useMemo(()=>{var e;if(!u||!c)return[];const t=null==d?void 0:d.find(e=>"left"===e.orient),n=(null==t?void 0:t.tickFormat)||m||Je,o=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;let r=et(c.y.ticks(Math.min(o,Math.max(2,Math.floor(i/30)))).map(e=>({value:e,pixel:c.y(e),label:n(e)})),22);if(r.length>1&&(r=r.filter((e,t)=>0===t||e.label+""!=r[t-1].label+"")),(null==t?void 0:t.includeMax)&&r.length>0){const e=c.y.domain()[1],t=c.y(e),o=r[r.length-1].pixel;if(Math.abs(t-o)>1){const i=n(e);22>Math.abs(t-o)&&r.length>1&&(r=r.slice(0,-1)),r.push({value:e,pixel:t,label:i})}}return r},[u,c,d,m,i]),z=e.useMemo(()=>{var e;if(!u||!c)return[];const t=null==d?void 0:d.find(e=>"right"===e.orient);if(!t)return[];const n=t.tickFormat||m||Je,o=null!==(e=t.ticks)&&void 0!==e?e:5;return et(c.y.ticks(Math.min(o,Math.max(2,Math.floor(i/30)))).map(e=>({value:e,pixel:c.y(e),label:n(e)})),22)},[u,c,d,m,i]),G=e.useRef(new Map),q=e.useRef(null!==(n=null==P?void 0:P.length)&&void 0!==n?n:0),Y=null!==(o=null==P?void 0:P.length)&&void 0!==o?o:0;q.current!==Y&&(q.current=Y,G.current=new Map);const X=e.useMemo(()=>{if(!P||0===P.length)return null;const e=He(),t={scales:c?{x:c.x,y:c.y,time:c.x,value:c.y}:null,timeAxis:"x",xAccessor:_,yAccessor:T,width:r,height:i,data:B,frameType:"xy",pointNodes:N,curve:D,stickyPositionCache:G.current};return P.map((n,o)=>{if(L){const r=L(n,o,t);return null!=r?r:e(n,o,t)}return e(n,o,t)}).filter(Boolean)},[P,L,r,i,_,T,B,c,N,D]),V=function(t){var n;const o=e.useSyncExternalStore(t?Ye:Ve,t?qe:Ue,t?qe:Ue);return t&&null!==(n=o.positions.get(t))&&void 0!==n?n:null}(R);return e.useEffect(()=>{if(!(null==V?void 0:V.locked)||!R)return;const e=e=>{"Escape"===e.key&&Ge(R)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[null==V?void 0:V.locked,R]),u||b||x||E||M||X&&X.length>0||v||W||V?p.createElement("svg",{role:"img",width:a,height:s,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"}},p.createElement("title",null,"string"==typeof b?b:"XY Chart"),p.createElement("desc",null,"string"==typeof b?b+" — XY data visualization":"XY data visualization"),p.createElement("g",{transform:`translate(${l.left},${l.top})`},v&&c&&!I&&(()=>{var e,t;const n=Ke(null===(e=null==d?void 0:d.find(e=>"bottom"===e.orient))||void 0===e?void 0:e.gridStyle),o=Ke(null===(t=null==d?void 0:d.find(e=>"left"===e.orient))||void 0===t?void 0:t.gridStyle);return p.createElement("g",{className:"stream-grid"},F.map((e,t)=>p.createElement("line",{key:"xgrid-"+t,x1:e.pixel,y1:0,x2:e.pixel,y2:i,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:n})),$.map((e,t)=>p.createElement("line",{key:"ygrid-"+t,x1:0,y1:e.pixel,x2:r,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:o})))})(),u&&c&&(()=>{const e=null==d?void 0:d.find(e=>"left"===e.orient),t=null==d?void 0:d.find(e=>"bottom"===e.orient),n=!e||!1!==e.baseline,o=!t||!1!==t.baseline,a=(null==e?void 0:e.jaggedBase)||!1,s=(null==t?void 0:t.jaggedBase)||!1,c=null==t?void 0:t.landmarkTicks,u=null==e?void 0:e.landmarkTicks,y="var(--semiotic-border, #ccc)",m="var(--semiotic-text-secondary, var(--semiotic-text, #666))",v="var(--semiotic-text, #333)",b=!!(null==t?void 0:t.autoRotate)&&F.length>1&&(()=>{const e=r/Math.max(F.length-1,1);return F.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:60),0)+8>e})();return p.createElement("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"}},!I&&o&&!s&&p.createElement("line",{x1:0,y1:i,x2:r,y2:i,stroke:y,strokeWidth:1}),!I&&s&&p.createElement("path",{d:Qe("bottom",r,i),fill:"none",stroke:y,strokeWidth:1}),F.map((e,t)=>{const n=!!c&&("function"==typeof c?c(e.value,t):ne(e.value,t>0?F[t-1].value:void 0));return p.createElement("g",{key:"xtick-"+t,transform:`translate(${e.pixel},${i})`},p.createElement("line",{y2:5,stroke:y,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?p.createElement("text",{y:b?10:18,textAnchor:b?"end":"middle",fontSize:n?11:10,fontWeight:n?600:400,fill:m,style:{userSelect:"none"},transform:b?"rotate(-45)":void 0},e.label):p.createElement("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"}},p.createElement("div",{style:{textAlign:"center",fontSize:10,userSelect:"none"}},e.label)))}),h&&p.createElement("text",{x:r/2,y:i+40,textAnchor:"middle",fontSize:12,fill:v,style:{userSelect:"none"}},h),!I&&n&&!a&&p.createElement("line",{x1:0,y1:0,x2:0,y2:i,stroke:y,strokeWidth:1}),!I&&a&&p.createElement("path",{d:Qe("left",r,i),fill:"none",stroke:y,strokeWidth:1}),$.map((e,t)=>{const n=!!u&&("function"==typeof u?u(e.value,t):ne(e.value,t>0?$[t-1].value:void 0));return p.createElement("g",{key:"ytick-"+t,transform:`translate(0,${e.pixel})`},p.createElement("line",{x2:-5,stroke:y,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?p.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:n?11:10,fontWeight:n?600:400,fill:m,style:{userSelect:"none"}},e.label):p.createElement("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"}},p.createElement("div",{style:{textAlign:"right",fontSize:10,userSelect:"none"}},e.label)))}),(()=>{const t=(null==e?void 0:e.label)||g;return t?p.createElement("text",{x:15-l.left,y:i/2,textAnchor:"middle",fontSize:12,fill:v,transform:`rotate(-90, ${15-l.left}, ${i/2})`,style:{userSelect:"none"}},t):null})(),(()=>{const e=null==d?void 0:d.find(e=>"right"===e.orient);if(!e||0===z.length)return null;const t=e.landmarkTicks,n=e.label||f;return p.createElement(p.Fragment,null,!1!==e.baseline&&p.createElement("line",{x1:r,y1:0,x2:r,y2:i,stroke:y,strokeWidth:1}),z.map((e,n)=>{const o=!!t&&("function"==typeof t?t(e.value,n):ne(e.value,n>0?z[n-1].value:void 0));return p.createElement("g",{key:"ytick-r-"+n,transform:`translate(${r},${e.pixel})`},p.createElement("line",{x2:5,stroke:y,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?p.createElement("text",{x:8,textAnchor:"start",dominantBaseline:"middle",fontSize:o?11:10,fontWeight:o?600:400,fill:m,style:{userSelect:"none"}},e.label):p.createElement("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"}},p.createElement("div",{style:{textAlign:"left",fontSize:10,userSelect:"none"}},e.label)))}),n&&p.createElement("text",{x:r+l.right-15,y:i/2,textAnchor:"middle",fontSize:12,fill:v,transform:`rotate(90, ${r+l.right-15}, ${i/2})`,style:{userSelect:"none"}},n))})())})(),X,M&&c&&j&&C&&p.createElement(p.Fragment,null,M.top&&p.createElement("g",{transform:"translate(0, 0)"},p.createElement(Ce,{orient:"top",config:je(M.top),values:j,scale:c.x,size:l.top,length:r})),M.bottom&&p.createElement("g",{transform:`translate(0, ${i})`},p.createElement(Ce,{orient:"bottom",config:je(M.bottom),values:j,scale:c.x,size:l.bottom,length:r})),M.left&&p.createElement("g",{transform:"translate(0, 0)"},p.createElement(Ce,{orient:"left",config:je(M.left),values:C,scale:c.y,size:l.left,length:i})),M.right&&p.createElement("g",{transform:`translate(${r}, 0)`},p.createElement(Ce,{orient:"right",config:je(M.right),values:C,scale:c.y,size:l.right,length:i}))),E,V&&V.sourceId!==H&&(null==c?void 0:c.x)&&(()=>{const e=c.x(V.xValue);if(null==e||0>e||e>r)return null;const t=V.locked;return p.createElement("line",{x1:e,y1:0,x2:e,y2:i,stroke:t?"white":"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:t?1.5:1,strokeDasharray:t?"6,3":"4,4",pointerEvents:"none"})})(),W),b&&p.createElement("text",{x:a/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof b?b:null),Me({legend:x,totalWidth:a,totalHeight:s,margin:l,legendPosition:O,title:b,legendHoverBehavior:k,legendClickBehavior:w,legendHighlightedCategory:A,legendIsolatedCategories:S})):null}function nt(e,t="#4e79a7"){return e&&"string"==typeof e?e:t}const ot="undefined"==typeof window||"undefined"==typeof document,rt=p.createContext(null);function it({children:e}){const[t,n]=p.useState(!1),o=p.useMemo(()=>({visible:t,setVisible:n}),[t]);return p.createElement(rt.Provider,{value:o},e)}function at(){return p.useContext(rt)}const st={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function lt(e,t){if(!e||0===e.length)return t+", empty";const n={};for(const t of e)n[t.type]=(n[t.type]||0)+1;const o=[],r={point:"points",line:"lines",area:"areas",rect:"bars",heatcell:"cells",circle:"nodes",candlestick:"candlesticks",wedge:"wedges",arc:"arcs",geoarea:"regions"},i=["point","line","area","rect","heatcell","circle","candlestick","wedge","arc","geoarea"],a=Object.keys(n).sort((e,t)=>{const n=i.indexOf(e),o=i.indexOf(t);return(-1===n?999:n)-(-1===o?999:o)});for(const e of a)o.push(`${n[e]} ${r[e]||e}`);return`${t}, ${o.join(", ")}`}function ct(e,t,n){const o=[];return e>0&&o.push(e+" nodes"),t>0&&o.push(t+" edges"),0===o.length?n+", empty":`${n}, ${o.join(", ")}`}const ut=e=>{if(null==e)return"";const t=Math.round(100*e)/100;return Number.isNaN(t)?"":t+""},dt={position:"absolute",top:0,left:0,right:0,zIndex:5,padding:"14px 16px 12px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)",fontFamily:"var(--semiotic-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif)",fontSize:13,lineHeight:1.5,color:"var(--semiotic-text, #333)",background:"var(--semiotic-bg, #fff)",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},ht={marginBottom:8,paddingRight:28,color:"var(--semiotic-text-secondary, #666)",fontSize:12,letterSpacing:"0.01em"},gt={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-border, #e0e0e0)",background:"var(--semiotic-bg, #fff)",cursor:"pointer",color:"var(--semiotic-text-secondary, #666)",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},ft={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},pt={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-border, #e0e0e0)",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-text-secondary, #666)"},yt={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"},mt={textAlign:"left",fontSize:11,color:"var(--semiotic-text-secondary, #999)",marginBottom:4,fontStyle:"italic"};function vt({scene:e,chartType:t,tableId:n,chartTitle:o}){var r;const[i,a]=p.useState(!1),s=at(),l=null!==(r=null==s?void 0:s.visible)&&void 0!==r&&r,c=i||l,u=p.useRef(null),d=o?"Data summary for "+o:n?`Data summary for ${t} ${n}`:"Data summary for "+t,h=p.useCallback(()=>{i||l||a(!0)},[i,l]),g=p.useCallback(e=>{var t;l||(null===(t=u.current)||void 0===t?void 0:t.contains(e.relatedTarget))||a(!1)},[l]);if(!e||0===e.length)return n?p.createElement("span",{id:n,tabIndex:-1,style:st}):null;if(!c)return p.createElement("div",{id:n,tabIndex:-1,onFocus:h,style:st,role:"region","aria-label":d},p.createElement("button",{type:"button",onClick:()=>a(!0)},"View data summary (",e.length," elements)"));const f=function(e){var t,n,o,r,i,a,s,l,c,u,d,h,g,f,p,y,m,v,b,x,k,w,A,S,O;const E=[];if(!Array.isArray(e))return E;for(const M of e)if(M&&"object"==typeof M)try{switch(M.type){case"point":E.push({label:"Point",values:{x:M.x,y:M.y}});break;case"line":{const e=M.path,t=Array.isArray(M.datum)?M.datum:[];if(!Array.isArray(e))break;for(let n=0;e.length>n&&t.length>n;n++){const t=e[n];Array.isArray(t)&&E.push({label:"Line point",values:{x:t[0],y:t[1]}})}break}case"area":{const e=M.topPath,t=Array.isArray(M.datum)?M.datum:[];if(!Array.isArray(e))break;for(let n=0;e.length>n&&t.length>n;n++){const t=e[n];Array.isArray(t)&&E.push({label:"Area point",values:{x:t[0],y:t[1]}})}break}case"rect":{const e=null!=M.datum&&"object"==typeof M.datum?M.datum:{},i=null!==(n=null!==(t=e.category)&&void 0!==t?t:M.group)&&void 0!==n?n:"",a=null!==(r=null!==(o=e.value)&&void 0!==o?o:e.__aggregateValue)&&void 0!==r?r:e.total;E.push({label:"Bar",values:{category:i,value:null!=a?a:""}});break}case"heatcell":E.push({label:"Cell",values:{x:M.x,y:M.y,value:M.value}});break;case"wedge":E.push({label:"Wedge",values:{category:null!==(l=null!==(a=null===(i=M.datum)||void 0===i?void 0:i.category)&&void 0!==a?a:null===(s=M.datum)||void 0===s?void 0:s.label)&&void 0!==l?l:"",value:null!==(u=null===(c=M.datum)||void 0===c?void 0:c.value)&&void 0!==u?u:""}});break;case"circle":E.push({label:"Node",values:{id:null!==(h=null===(d=M.datum)||void 0===d?void 0:d.id)&&void 0!==h?h:"",x:null!==(g=M.cx)&&void 0!==g?g:M.x,y:null!==(f=M.cy)&&void 0!==f?f:M.y}});break;case"arc":E.push({label:"Arc",values:{id:null!==(y=null===(p=M.datum)||void 0===p?void 0:p.id)&&void 0!==y?y:"",x:null!==(m=M.cx)&&void 0!==m?m:M.x,y:null!==(v=M.cy)&&void 0!==v?v:M.y}});break;case"candlestick":E.push({label:"Candlestick",values:{x:M.x,open:M.open,high:M.high,low:M.low,close:M.close}});break;case"geoarea":E.push({label:"Region",values:{name:null!==(A=null!==(k=null===(x=null===(b=M.datum)||void 0===b?void 0:b.properties)||void 0===x?void 0:x.name)&&void 0!==k?k:null===(w=M.datum)||void 0===w?void 0:w.name)&&void 0!==A?A:"",value:null!==(O=null===(S=M.datum)||void 0===S?void 0:S.value)&&void 0!==O?O:""}})}}catch(e){}return E}(e),y=function(e){if(!e||0===e.length)return[];const t=new Set;for(const n of e)if(n&&n.values)for(const e of Object.keys(n.values))t.add(e);const n=[];for(const o of t){const t=[],r=new Set;for(const n of e){if(!n||!n.values)continue;const e=n.values[o];null!=e&&""!==e&&("number"==typeof e&&!Number.isNaN(e)&&Number.isFinite(e)?t.push(e):"number"==typeof e||"object"!=typeof e&&"function"!=typeof e&&r.add(e+""))}if(t.length>0){let e=t[0],r=t[0],i=0;for(const n of t)e>n&&(e=n),n>r&&(r=n),i+=n;n.push({name:o,count:t.length,numeric:!0,min:e,max:r,mean:i/t.length})}else if(r.size>0){const e=Array.from(r);n.push({name:o,count:e.length,numeric:!1,uniqueValues:e.slice(0,5)})}}return n}(f),m=function(e,t){const n=[e+" data points."];for(const e of t)if(e.numeric)n.push(`${e.name}: ${ut(e.min)} to ${ut(e.max)}, mean ${ut(e.mean)}.`);else{const t=e.uniqueValues,o=t.length>3?`${t.slice(0,3).join(", ")}… (${e.count} unique)`:t.join(", ");n.push(`${e.name}: ${o}.`)}return n.join(" ")}(f.length,y),v=f.slice(0,5),b=new Set;for(const e of v)for(const t of Object.keys(e.values))b.add(t);const x=Array.from(b);return p.createElement("div",{ref:u,id:n,tabIndex:-1,onBlur:g,style:dt,role:"region","aria-label":d},p.createElement("button",{type:"button",onClick:()=>{l&&s&&s.setVisible(!1),a(!1)},"aria-label":"Close data summary",style:gt},"×"),p.createElement("div",{role:"note",style:ht},m),p.createElement("table",{role:"table","aria-label":"Sample data for "+t,style:ft},p.createElement("caption",{style:mt},"First ",v.length," of ",f.length," data points"),p.createElement("thead",null,p.createElement("tr",null,p.createElement("th",{style:pt},"type"),x.map(e=>p.createElement("th",{key:e,style:pt},e)))),p.createElement("tbody",null,v.map((e,t)=>p.createElement("tr",{key:t},p.createElement("td",{style:yt},e.label),x.map(t=>{return p.createElement("td",{key:t,style:yt},null==(n=e.values[t])||""===n?"—":"number"==typeof n?Number.isNaN(n)?"—":ut(n):"boolean"==typeof n?n?"true":"false":"object"==typeof n?"—":n+"");var n}))))))}function bt({nodes:e,edges:t,chartType:n,tableId:o,chartTitle:r}){var i,a,s,l,c,u,d,h,g,f,y,m,v,b;const[x,k]=p.useState(!1),w=at(),A=null!==(i=null==w?void 0:w.visible)&&void 0!==i&&i,S=x||A,O=r?"Data summary for "+r:o?`Data summary for ${n} ${o}`:"Data summary for "+n,E=p.useRef(null),M=p.useCallback(()=>{x||A||k(!0)},[x,A]),j=p.useCallback(e=>{var t;A||(null===(t=E.current)||void 0===t?void 0:t.contains(e.relatedTarget))||k(!1)},[A]);if(!e||0===e.length)return o?p.createElement("span",{id:o,tabIndex:-1,style:st}):null;if(!S)return p.createElement("div",{id:o,tabIndex:-1,onFocus:M,style:st,role:"region","aria-label":O},p.createElement("button",{type:"button",onClick:()=>k(!0)},"View data summary (",e.length," nodes, ",t.length," edges)"));const C=Array.isArray(e)?e:[],P=Array.isArray(t)?t:[],L=new Map,_=new Map,T=new Map,B=new Map;for(const e of P){if(!e||"object"!=typeof e)continue;const t=null!==(a=e.datum)&&void 0!==a?a:e,n="object"==typeof t.source?null===(s=t.source)||void 0===s?void 0:s.id:t.source,o="object"==typeof t.target?null===(l=t.target)||void 0===l?void 0:l.id:t.target,r="number"==typeof t.value&&Number.isFinite(t.value)?t.value:0;if(null!=n&&""!==n){const e=n+"";_.set(e,(null!==(c=_.get(e))&&void 0!==c?c:0)+1),B.set(e,(null!==(u=B.get(e))&&void 0!==u?u:0)+r)}if(null!=o&&""!==o){const e=o+"";L.set(e,(null!==(d=L.get(e))&&void 0!==d?d:0)+1),T.set(e,(null!==(h=T.get(e))&&void 0!==h?h:0)+r)}}const N=[];for(let e=0;C.length>e;e++){const t=C[e];if(!t||"object"!=typeof t)continue;const n=null!==(f=null===(g=t.datum)||void 0===g?void 0:g.id)&&void 0!==f?f:t.id,o=null!=n?n+"":"node-"+e,r=null!==(y=L.get(o))&&void 0!==y?y:0,i=null!==(m=_.get(o))&&void 0!==m?m:0,a=null!==(v=T.get(o))&&void 0!==v?v:0,s=null!==(b=B.get(o))&&void 0!==b?b:0;N.push({id:o,degree:r+i,inDeg:r,outDeg:i,wDegree:a+s,wInDeg:a,wOutDeg:s})}N.sort((e,t)=>t.degree-e.degree);let D=0,I=0;if(N.length>0){let e=0;for(const t of N)e+=t.degree,t.degree>I&&(I=t.degree);D=e/N.length}const R=P.some(e=>{var t;const n=null!==(t=null==e?void 0:e.datum)&&void 0!==t?t:e;return"number"==typeof(null==n?void 0:n.value)&&Number.isFinite(n.value)}),H=[`${N.length} nodes, ${P.length} edges.`];N.length>0&&H.push(`Mean degree: ${ut(D)}, max degree: ${I}.`);const W=N.slice(0,5);return p.createElement("div",{ref:E,id:o,tabIndex:-1,onBlur:j,style:dt,role:"region","aria-label":O},p.createElement("button",{type:"button",onClick:()=>{A&&w&&w.setVisible(!1),k(!1)},"aria-label":"Close data summary",style:gt},"×"),p.createElement("div",{role:"note",style:ht},H.join(" ")),p.createElement("table",{role:"table","aria-label":"Node degree summary for "+n,style:ft},p.createElement("caption",{style:mt},"Top ",W.length," of ",N.length," nodes by degree"),p.createElement("thead",null,p.createElement("tr",null,p.createElement("th",{style:pt},"id"),p.createElement("th",{style:pt},"degree"),p.createElement("th",{style:pt},"in"),p.createElement("th",{style:pt},"out"),R&&p.createElement("th",{style:pt},"w. degree"),R&&p.createElement("th",{style:pt},"w. in"),R&&p.createElement("th",{style:pt},"w. out"))),p.createElement("tbody",null,W.map((e,t)=>p.createElement("tr",{key:t},p.createElement("td",{style:yt},e.id),p.createElement("td",{style:yt},e.degree),p.createElement("td",{style:yt},e.inDeg),p.createElement("td",{style:yt},e.outDeg),R&&p.createElement("td",{style:yt},ut(e.wDegree)),R&&p.createElement("td",{style:yt},ut(e.wInDeg)),R&&p.createElement("td",{style:yt},ut(e.wOutDeg)))))))}function xt({summary:e}){return e?p.createElement("div",{role:"note",style:st},e):null}function kt({tableId:e}){return p.createElement("a",{href:"#"+e,style:st,onClick:t=>{t.preventDefault();const n=document.getElementById(e);n&&requestAnimationFrame(()=>n.focus())},onFocus:e=>{Object.assign(e.currentTarget.style,{position:"absolute",width:"auto",height:"auto",overflow:"visible",clip:"auto",whiteSpace:"normal",padding:"4px 8px",background:"var(--semiotic-bg, #fff)",color:"var(--semiotic-text, #000)",border:"2px solid var(--semiotic-focus, #005fcc)",borderRadius:"4px",zIndex:"10",fontSize:"12px",top:"4px",left:"4px"})},onBlur:e=>{const t=e.currentTarget;t.removeAttribute("style"),Object.assign(t.style,st)}},"Skip to data table")}function wt({hoverPoint:e}){let t="";if(e){const n=e.data||e;t="object"==typeof n?"Focused on data point: "+Object.entries(n).filter(([,e])=>"object"!=typeof e&&"function"!=typeof e).map(([e,t])=>`${e}: ${t}`).join(", "):"Focused on data point: "+n}return p.createElement("div",{"aria-live":"polite","aria-atomic":"true",style:st},t)}const At="var(--semiotic-focus, #005fcc)";function St({active:e,hoverPoint:t,margin:n,size:o,shape:r="circle",width:i,height:a}){if(!e||!t)return null;const s=t.x+n.left,l=t.y+n.top;let c;if("rect"===r&&null!=i&&null!=a){const e=Math.max(i,4),t=Math.max(a,4);c=p.createElement("rect",{x:s-e/2-3,y:l-t/2-3,width:e+6,height:t+6,rx:3,fill:"none",stroke:At,strokeWidth:2,strokeDasharray:"4,2"})}else c=p.createElement("circle","wedge"===r?{cx:s,cy:l,r:12,fill:"none",stroke:At,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:s,cy:l,r:8,fill:"none",stroke:At,strokeWidth:2,strokeDasharray:"4,2"});return p.createElement("svg",{style:{position:"absolute",left:0,top:0,width:o[0],height:o[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true"},c)}function Ot({x:e,y:t,containerWidth:n,containerHeight:o,margin:r,children:i,className:a="stream-frame-tooltip",zIndex:s=1}){const l=p.useRef(null),[c,u]=p.useState(null);p.useLayoutEffect(()=>{const e=l.current;if(!e)return;const t=e.getBoundingClientRect();u(e=>e&&e.width===t.width&&e.height===t.height?e:{width:t.width,height:t.height})},[i,a,n,o]);let d;return d=c?`translate(${c.width+12>n-e?"calc(-100% - 12px)":"12px"}, ${c.height+12>o-t?"calc(-100% - 4px)":"4px"})`:`translate(${e>.7*n?"calc(-100% - 12px)":"12px"}, ${.3*o>t?"4px":"calc(-100% - 4px)"})`,p.createElement("div",{ref:l,className:a,style:{position:"absolute",left:r.left+e,top:r.top+t,transform:d,pointerEvents:"none",zIndex:s,width:"max-content"}},i)}function Et(e,t){return"function"==typeof e.addEventListener?(e.addEventListener("change",t),()=>e.removeEventListener("change",t)):(e.addListener(t),()=>e.removeListener(t))}function Mt(){const[t,n]=e.useState(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return e.useEffect(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)");return n(e.matches),Et(e,e=>n(e.matches))},[]),t}function jt(t){const n=e.createContext(null),o=Ct(t);return[function({children:o}){const r=e.useMemo(()=>Ct(t),[]);return p.createElement(n.Provider,{value:r,children:o})},t=>{var r;const i=null!==(r=e.useContext(n))&&void 0!==r?r:o,a=e.useRef(t);a.current=t;const s=e.useCallback(()=>a.current(i.getState()),[i]),l=e.useCallback(()=>a.current(i.getState()),[i]);return e.useSyncExternalStore(i.subscribe,s,l)}]}function Ct(e){const t=new EventTarget;let n=e(function(e){n=Object.assign(Object.assign({},n),e(n)),t.dispatchEvent(new CustomEvent("update"))});return{getState:()=>n,subscribe:function(e){return t.addEventListener("update",e),()=>t.removeEventListener("update",e)}}}const Pt={mode:"light",colors:{primary:"#00a2ce",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",diverging:"RdBu",background:"transparent",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc",selection:"#00a2ce",selectionOpacity:.15},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},Lt={mode:"dark",colors:{primary:"#4fc3f7",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",diverging:"RdBu",background:"#1a1a2e",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555",selection:"#4fc3f7",selectionOpacity:.15},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},_t={mode:"light",colors:{primary:"#0000cc",categorical:["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],sequential:"blues",diverging:"RdBu",background:"#ffffff",text:"#000000",textSecondary:"#333333",grid:"#999999",border:"#000000",focus:"#0000cc",selection:"#0000cc",selectionOpacity:.1},typography:{fontFamily:"system-ui, sans-serif",titleSize:18,labelSize:14,tickSize:12},tooltip:{background:"#000000",text:"#ffffff",borderRadius:"4px",fontSize:"14px",shadow:"0 2px 8px rgba(0, 0, 0, 0.3)"},borderRadius:"4px"},[Tt,Bt]=jt(e=>({theme:Pt,setTheme(t){e(e=>{if("light"===t)return{theme:Pt};if("dark"===t)return{theme:Lt};if("high-contrast"===t)return{theme:_t};if(t.mode&&"auto"!==t.mode){const e="dark"===t.mode?Lt:Pt;return{theme:Object.assign(Object.assign(Object.assign({},e),t),{colors:Object.assign(Object.assign({},e.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.typography),t.typography||{})})}}return{theme:Object.assign(Object.assign(Object.assign({},e.theme),t),{colors:Object.assign(Object.assign({},e.theme.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.theme.typography),t.typography||{})})}})}}));function Nt(e,t,n,o){const r=e.getContext("2d");if(!r)return null;const i=t[0]*o,a=t[1]*o,s=t[0]+"px",l=t[1]+"px";return e.style.width!==s&&(e.style.width=s),e.style.height!==l&&(e.style.height=l),e.width===i&&e.height===a||(e.width=i,e.height=a),r.setTransform(o,0,0,o,0,0),r.translate(n.left,n.top),r}function Dt(){return"undefined"!=typeof window&&window.devicePixelRatio||1}const It=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,Rt=new WeakMap;function Ht(e,t){var n,o;if(!t)return t;const r=It.exec(t);if(!r)return t;const i=e.canvas;if(!i)return(null===(n=r[2])||void 0===n?void 0:n.trim())||t;let a=Rt.get(i);if(a||(a=new Map,Rt.set(i,a)),a.has(t))return a.get(t);const s=getComputedStyle(i).getPropertyValue(r[1]).trim()||(null===(o=r[2])||void 0===o?void 0:o.trim())||t;return a.set(t,s),s}function Wt(e){Rt.delete(e)}function Ft(e){switch(e){case"monotoneX":return l.curveMonotoneX;case"monotoneY":return l.curveMonotoneY;case"cardinal":return l.curveCardinal;case"catmullRom":return l.curveCatmullRom;case"step":return l.curveStep;case"stepBefore":return l.curveStepBefore;case"stepAfter":return l.curveStepAfter;case"basis":return l.curveBasis;case"natural":return l.curveNatural;default:return null}}function $t(e,t,n){let o=n;for(const n of t)"lesser"===n.thresholdType?n.value>e&&(o=n.color):e>n.value&&(o=n.color);return o}function zt(e,t,n,o,r,i){if(2>t.length)return;const a=[0];for(let e=1;t.length>e;e++){const n=t[e][0]-t[e-1][0],o=t[e][1]-t[e-1][1];a.push(a[e-1]+Math.sqrt(n*n+o*o))}const s=a[a.length-1];if(0===s)return;const l=Math.min(.2*s,40);e.strokeStyle=n,e.lineWidth=o,e.lineCap=i;for(let n=0;t.length-1>n;n++){const o=(a[n]+a[n+1])/2;let i=r;l>o&&(i*=o/l),l>s-o&&(i*=(s-o)/l),e.globalAlpha=Math.max(0,i),e.beginPath(),e.moveTo(t[n][0],t[n][1]),e.lineTo(t[n+1][0],t[n+1][1]),e.stroke()}}const Gt=(e,t,n,o)=>{var r,i;const a=t.filter(e=>"line"===e.type);for(const s of a){if(2>s.path.length)continue;const c=s.style.stroke||"#007bff",u=s.style.strokeWidth||2,d=s.colorThresholds,h=s.rawValues;if(e.setLineDash(s.style.strokeDasharray?s.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=s.style.opacity&&(e.globalAlpha=s.style.opacity),e.lineWidth=u,e.lineCap=s.style.strokeLinecap||"butt",s.style._edgeFade){const y=null!==(r=s.style.opacity)&&void 0!==r?r:1;zt(e,s.path,c,u,y,s.style.strokeLinecap||"butt"),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt";continue}const g=Ft(s.curve),f=d&&d.length>0&&h&&h.length===s.path.length,p=s._decayOpacities;if(p&&p.length===s.path.length&&!f){e.strokeStyle=c;const m=null!==(i=s.style.opacity)&&void 0!==i?i:1;for(let v=0;s.path.length-1>v;v++)e.globalAlpha=.5*(p[v]+p[v+1])*m,e.beginPath(),e.moveTo(s.path[v][0],s.path[v][1]),e.lineTo(s.path[v+1][0],s.path[v+1][1]),e.stroke()}else if(f){let b=null,x=null,k=null,w=null,A=!1;function S(t,n,o){e.beginPath(),e.strokeStyle=t,e.moveTo(n,o),A=!0}function O(){A&&(e.stroke(),A=!1)}for(let E=0;s.path.length>E;E++){const[M,j]=s.path[E],C=h[E],P=$t(C,d,c);if(null!==b&&null!==w&&null!==k){if(P===w)e.lineTo(M,j);else{const L=[];for(const _ of d){const T=_.value;(k>T||T>C)&&(T>k||C>T)||k===T||C===T||L.push({t:(T-k)/(C-k)})}L.sort((e,t)=>e.t-t.t);for(const B of L){const N=b+(M-b)*B.t,D=x+(j-x)*B.t,I=$t(k+(C-k)*Math.min(B.t+1e-4,1),d,c);e.lineTo(N,D),O(),S(I,N,D)}e.lineTo(M,j)}b=M,x=j,k=C,w=P}else S(P,M,j),b=M,x=j,k=C,w=P}O()}else{if(e.beginPath(),!s.strokeGradient||2>s.strokeGradient.colorStops.length||2>s.path.length)e.strokeStyle=c;else{const R=e.createLinearGradient(s.path[0][0],0,s.path[s.path.length-1][0],0);for(const H of s.strokeGradient.colorStops)R.addColorStop(Math.max(0,Math.min(1,H.offset)),H.color);e.strokeStyle=R}if(g)l.line().x(e=>e[0]).y(e=>e[1]).curve(g).context(e)(s.path);else{const[W,F]=s.path[0];e.moveTo(W,F);for(let $=1;s.path.length>$;$++)e.lineTo(s.path[$][0],s.path[$][1])}e.stroke()}if(s.style.fill&&s.style.fillOpacity&&s.style.fillOpacity>0){if(e.beginPath(),e.globalAlpha=s.style.fillOpacity,e.fillStyle=("string"==typeof s.style.fill?Ht(e,s.style.fill):s.style.fill)||s.style.fill,g&&!f)l.line().x(e=>e[0]).y(e=>e[1]).curve(g).context(e)(s.path);else{const[G,q]=s.path[0];e.moveTo(G,q);for(let Y=1;s.path.length>Y;Y++)e.lineTo(s.path[Y][0],s.path[Y][1])}const z=s.path[0][0];e.lineTo(s.path[s.path.length-1][0],o.height),e.lineTo(z,o.height),e.closePath(),e.fill()}e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt"}};function qt(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function Yt(e,t,n=.3){qt(t)&&(e.globalAlpha=t._pulseIntensity*n,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h))}function Xt(e,t,n=.6){var o,r,i,a,s;if(!qt(t))return;const l=null!==(o=t._pulseGlowRadius)&&void 0!==o?o:4,c=t.r+l*t._pulseIntensity,u=null!==(i=null!==(r=t.cx)&&void 0!==r?r:t.x)&&void 0!==i?i:0,d=null!==(s=null!==(a=t.cy)&&void 0!==a?a:t.y)&&void 0!==s?s:0;e.beginPath(),e.arc(u,d,c,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=t._pulseIntensity*n,e.stroke()}function Vt(e,t,n,o=.35){qt(t)&&(e.globalAlpha=t._pulseIntensity*o,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fill())}function Ut(e){switch(e){case"monotoneX":return l.curveMonotoneX;case"monotoneY":return l.curveMonotoneY;case"cardinal":return l.curveCardinal;case"catmullRom":return l.curveCatmullRom;case"step":return l.curveStep;case"stepBefore":return l.curveStepBefore;case"stepAfter":return l.curveStepAfter;case"basis":return l.curveBasis;case"natural":return l.curveNatural;default:return null}}function Kt(e){if(e.startsWith("#")){const t=4===e.length?e[1]+e[1]+e[2]+e[2]+e[3]+e[3]:e.slice(1,7);return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[78,121,167]}function Qt(e,t){const n=Ut(t.curve);if(!n||2>t.topPath.length||2>t.bottomPath.length){e.beginPath(),e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1]);for(let n=t.bottomPath.length-1;n>=0;n--)e.lineTo(t.bottomPath[n][0],t.bottomPath[n][1]);e.closePath()}else{const o=l.area().x(e=>e[0]).y0((e,n)=>t.bottomPath[n][1]).y1(e=>e[1]).curve(n).context(e);e.beginPath(),o(t.topPath)}}const Zt=(e,t,n,o)=>{var r,i,a;const s=t.filter(e=>"area"===e.type);for(const t of s){if(2>t.topPath.length)continue;const n=t.style.fill||"#4e79a7",o=t._decayOpacities;if(o&&o.length===t.topPath.length){const i=null!==(r=t.style.fillOpacity)&&void 0!==r?r:.7;e.fillStyle=n;for(let n=0;t.topPath.length-1>n;n++)e.globalAlpha=.5*(o[n]+o[n+1])*i,e.beginPath(),e.moveTo(t.topPath[n][0],t.topPath[n][1]),e.lineTo(t.topPath[n+1][0],t.topPath[n+1][1]),e.lineTo(t.bottomPath[n+1][0],t.bottomPath[n+1][1]),e.lineTo(t.bottomPath[n][0],t.bottomPath[n][1]),e.closePath(),e.fill();if(t.style.stroke&&"none"!==t.style.stroke){e.strokeStyle=Ht(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);for(let n=0;t.topPath.length-1>n;n++)e.globalAlpha=.5*(o[n]+o[n+1]),e.beginPath(),e.moveTo(t.topPath[n][0],t.topPath[n][1]),e.lineTo(t.topPath[n+1][0],t.topPath[n+1][1]),e.stroke()}e.globalAlpha=1;continue}const s=null!==(i=t.style.opacity)&&void 0!==i?i:1;if(Qt(e,t),t.fillGradient&&("colorStops"in t.fillGradient&&t.fillGradient.colorStops.length>=2||"topOpacity"in t.fillGradient)&&t.fillGradient){let o=1/0;for(const e of t.topPath)o>e[1]&&(o=e[1]);let r=-1/0;for(const e of t.bottomPath)e[1]>r&&(r=e[1]);const i=e.createLinearGradient(0,o,0,r);if("colorStops"in t.fillGradient)for(const e of t.fillGradient.colorStops){const t=Math.max(0,Math.min(1,e.offset));isNaN(t)||i.addColorStop(t,e.color)}else if("topOpacity"in t.fillGradient){const e=Kt("string"==typeof n?n:"#4e79a7");i.addColorStop(0,`rgba(${e[0]},${e[1]},${e[2]},${t.fillGradient.topOpacity})`),i.addColorStop(1,`rgba(${e[0]},${e[1]},${e[2]},${t.fillGradient.bottomOpacity})`)}e.fillStyle=i,e.globalAlpha=s}else{const o=null!==(a=t.style.fillOpacity)&&void 0!==a?a:.7;e.globalAlpha=o*s,e.fillStyle=n}if(e.fill(),t._pulseIntensity&&t._pulseIntensity>0&&(Qt(e,t),Vt(e,t)),t.style.stroke&&"none"!==t.style.stroke){if(e.globalAlpha=s,!t.strokeGradient||2>t.strokeGradient.colorStops.length||2>t.topPath.length)e.strokeStyle=Ht(e,t.style.stroke)||t.style.stroke;else{const n=e.createLinearGradient(t.topPath[0][0],0,t.topPath[t.topPath.length-1][0],0);for(const e of t.strokeGradient.colorStops)n.addColorStop(Math.max(0,Math.min(1,e.offset)),e.color);e.strokeStyle=n}e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);const n=Ut(t.curve);if(e.beginPath(),n)l.line().x(e=>e[0]).y(e=>e[1]).curve(n).context(e)(t.topPath);else{e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1])}e.stroke()}e.globalAlpha=1}},Jt=(e,t,n,o)=>{var r;const i=t.filter(e=>"point"===e.type);if(0!==i.length){e.save();try{for(const t of i){e.beginPath(),e.arc(t.x,t.y,t.r,0,2*Math.PI);const n=null!==(r=t.style.opacity)&&void 0!==r?r:t.style.fillOpacity;null!=n&&(e.globalAlpha=n),e.fillStyle=("string"==typeof t.style.fill?Ht(e,t.style.fill):t.style.fill)||"#4e79a7",e.fill(),t.style.stroke&&(e.strokeStyle=("string"==typeof t.style.stroke?Ht(e,t.style.stroke):t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()),Xt(e,t),e.globalAlpha=1}}finally{e.restore()}}},en=(e,t,n,o)=>{const r=t.filter(e=>"rect"===e.type);for(const t of r){if(null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.icon)tn(e,t);else if(t.roundedTop&&t.roundedTop>0){e.fillStyle=("string"==typeof t.style.fill?Ht(e,t.style.fill):t.style.fill)||"#007bff";const n=Math.min(t.roundedTop,t.w/2,t.h/2);e.beginPath();const{x:o,y:r,w:i,h:a}=t;switch(t.roundedEdge){case"right":e.moveTo(o,r),e.lineTo(o+i-n,r),e.arcTo(o+i,r,o+i,r+n,n),e.lineTo(o+i,r+a-n),e.arcTo(o+i,r+a,o+i-n,r+a,n),e.lineTo(o,r+a);break;case"left":e.moveTo(o+i,r),e.lineTo(o+n,r),e.arcTo(o,r,o,r+n,n),e.lineTo(o,r+a-n),e.arcTo(o,r+a,o+n,r+a,n),e.lineTo(o+i,r+a);break;case"bottom":e.moveTo(o,r),e.lineTo(o+i,r),e.lineTo(o+i,r+a-n),e.arcTo(o+i,r+a,o+i-n,r+a,n),e.lineTo(o+n,r+a),e.arcTo(o,r+a,o,r+a-n,n);break;default:e.moveTo(o,r+a),e.lineTo(o,r+n),e.arcTo(o,r,o+n,r,n),e.lineTo(o+i-n,r),e.arcTo(o+i,r,o+i,r+n,n),e.lineTo(o+i,r+a)}e.closePath(),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Ht(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke())}else e.fillStyle=("string"==typeof t.style.fill?Ht(e,t.style.fill):t.style.fill)||"#007bff",e.fillRect(t.x,t.y,t.w,t.h),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Ht(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.strokeRect(t.x,t.y,t.w,t.h));Yt(e,t),e.globalAlpha=1}};function tn(e,t){const n=t.style.icon,o=t.style.iconPadding||2,r=Math.min(t.w,t.h)-o;if(0>=r)return;const i=t.h>t.w;if(e.save(),e.beginPath(),e.rect(t.x,t.y,t.w,t.h),e.clip(),i){const i=r+o,a=t.x+(t.w-r)/2;for(let o=t.y+t.h-r;o>=t.y-r;o-=i)e.drawImage(n,a,o,r,r)}else{const i=r+o,a=t.y+(t.h-r)/2;for(let o=t.x;t.x+t.w>o;o+=i)e.drawImage(n,o,a,r,r)}e.restore()}function nn(e,t,n,o){return Object.assign(Object.assign(Object.assign({},function(e){return"object"!=typeof e||null===e||Array.isArray(e)?{}:e}(e)),{data:e,x:t,y:n,time:t,value:n}),o)}function on(e){const[t,n,o]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*n+.114*o>128?"#000":"#fff"}function rn(e){return Number.isInteger(e)?e+"":100>Math.abs(e)?1>Math.abs(e)?e.toPrecision(3):e.toFixed(1):e.toFixed(0)}const an=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function sn(e){const t=e[1]-e[0],n=3156e7;return 864e5>t?e=>{const t=new Date(e);return`${(t.getUTCHours()+"").padStart(2,"0")}:${(t.getUTCMinutes()+"").padStart(2,"0")}`}:n>t?e=>{const t=new Date(e);return`${an[t.getUTCMonth()]} ${t.getUTCDate()}`}:5*n>t?e=>{const t=new Date(e);return`${an[t.getUTCMonth()]} ${t.getUTCFullYear()}`}:e=>new Date(e).getUTCFullYear()+""}const ln={line:[Zt,Gt,Jt],area:[Zt,Jt],stackedarea:[Zt,Jt],scatter:[Jt],bubble:[Jt],heatmap:[(e,t,n,o)=>{const r=t.filter(e=>"heatcell"===e.type);e.save();try{for(const t of r){const n=t.style;if(null!=(null==n?void 0:n.opacity)&&(e.globalAlpha=n.opacity),e.fillStyle=t.fill,e.fillRect(t.x,t.y,t.w,t.h),e.strokeStyle="#fff",e.lineWidth=1,e.strokeRect(t.x,t.y,t.w,t.h),Yt(e,t),e.globalAlpha=1,t.showValues&&null!=t.value){if(20>t.w||20>t.h)continue;const n=t.valueFormat?t.valueFormat(t.value):rn(t.value),o=Math.max(10,Math.min(16,.3*Math.min(t.w,t.h))),r=t.x+t.w/2,i=t.y+t.h/2;e.fillStyle=on(t.fill),e.font=o+"px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(n,r,i)}}}finally{e.restore()}}],bar:[en],swarm:[Jt],waterfall:[(e,t,n,o)=>{var r,i,a;en(e,t);const s=t.filter(e=>"rect"===e.type);if(2>s.length)return;const l=s[0].datum,c=null==l?void 0:l._connectorStroke;if(c){e.save(),e.strokeStyle=c,e.lineWidth=null!==(r=null==l?void 0:l._connectorWidth)&&void 0!==r?r:1,e.setLineDash([]);for(let t=0;s.length-1>t;t++){const o=s[t],r=s[t+1];if(!(null===(i=o.datum)||void 0===i?void 0:i.cumEnd)||!(null===(a=r.datum)||void 0===a?void 0:a.baseline))continue;const l=n.y(o.datum.cumEnd),c=o.x+o.w,u=r.x;e.beginPath(),e.moveTo(c,l),e.lineTo(u,l),e.stroke()}e.restore()}}],candlestick:[(e,t,n,o)=>{for(const n of t){if("candlestick"!==n.type)continue;const t=n;e.save();const o=t._decayOpacity;if(null!=o&&1!==o&&(e.globalAlpha=o),e.beginPath(),e.moveTo(t.x,t.highY),e.lineTo(t.x,t.lowY),e.strokeStyle=t.wickColor,e.lineWidth=t.wickWidth,e.stroke(),t.isRange){const n=Math.max(2*t.wickWidth,4);e.fillStyle=t.wickColor,e.beginPath(),e.arc(t.x,t.highY,n,0,2*Math.PI),e.fill(),e.beginPath(),e.arc(t.x,t.lowY,n,0,2*Math.PI),e.fill()}else if(t.bodyWidth>0){const n=Math.min(t.openY,t.closeY),o=Math.abs(t.openY-t.closeY),r=t.isUp?t.upColor:t.downColor;e.fillStyle=r,e.fillRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(o,1)),e.strokeStyle=r,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(o,1))}e.restore()}}],mixed:[Zt,Gt,Jt]},cn={top:20,right:20,bottom:30,left:40},un={axisStroke:"#ccc",tickText:"#666",crosshair:"rgba(0, 0, 0, 0.25)",hoverFill:"rgba(255, 255, 255, 0.3)",hoverStroke:"rgba(0, 0, 0, 0.4)",pointRing:"white"},dn={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,lineHeight:1.5,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function hn({hover:e}){const t=e=>Number.isInteger(e)?e+"":e.toFixed(2);return p.createElement("div",{className:"semiotic-tooltip",style:dn},p.createElement("div",{style:{fontWeight:600,marginBottom:2}},t(e.value)),p.createElement("div",{style:{opacity:.7,fontSize:11}},t(e.time)))}const gn=e.forwardRef(function(t,n){var o,r,i,a,s,l,c,u,d,h,g;const{chartType:f,runtimeMode:y,data:m,chunkThreshold:v,chunkSize:k,xAccessor:w,yAccessor:A,colorAccessor:S,sizeAccessor:O,groupAccessor:E,lineDataAccessor:M,curve:j,normalize:C,binSize:P,valueAccessor:L,arrowOfTime:_="right",windowMode:T="sliding",windowSize:B=200,timeAccessor:N,xExtent:D,yExtent:I,extentPadding:R=.1,scalePadding:H,sizeRange:W,size:F=[500,300],responsiveWidth:$,responsiveHeight:z,margin:G,className:q,background:Y,lineStyle:X,pointStyle:V,areaStyle:U,waterfallStyle:K,swarmStyle:Q,barColors:J,colorScheme:ee,boundsAccessor:te,boundsStyle:ne,y0Accessor:oe,gradientFill:ae,lineGradient:se,areaGroups:le,openAccessor:ce,highAccessor:ue,lowAccessor:de,closeAccessor:he,candlestickStyle:me,showAxes:ke=!0,axes:we,xLabel:Ae,yLabel:Se,yLabelRight:Oe,xFormat:Ee,yFormat:Me,tickFormatTime:je,tickFormatValue:Ce,hoverAnnotation:Pe,tooltipContent:Le,customHoverBehavior:_e,customClickBehavior:Te,enableHover:Be,hoverRadius:Ne=30,tooltipMode:De,annotations:Ie,svgAnnotationRules:Re,showGrid:He,legend:We,legendHoverBehavior:Fe,legendClickBehavior:$e,legendHighlightedCategory:ze,legendIsolatedCategories:Ge,legendPosition:qe,backgroundGraphics:Ye,foregroundGraphics:Xe,canvasPreRenderers:Ve,svgPreRenderers:Ue,title:Ke,categoryAccessor:Qe,brush:Je,onBrush:et,decay:rt,pulse:it,transition:at,staleness:st,heatmapAggregation:ct,heatmapXBins:ut,heatmapYBins:dt,showValues:ht,heatmapValueFormat:gt,marginalGraphics:ft,pointIdAccessor:pt,xScaleType:yt,yScaleType:mt,accessibleTable:bt=!0,description:At,summary:Et,linkedCrosshairName:jt,linkedCrosshairSourceId:Ct}=t,Pt=Mt(),Lt=e.useRef(Pt);Lt.current=Pt;const[_t,Tt]=be(F,$,z),It=Object.assign(Object.assign({},cn),G);if(ft){const e=60;ft.top&&e>It.top&&(It.top=e),ft.bottom&&e>It.bottom&&(It.bottom=e),ft.left&&e>It.left&&(It.left=e),ft.right&&e>It.right&&(It.right=e)}const Rt=Tt[0]-It.left-It.right,Ht=Tt[1]-It.top-It.bottom,Ft="function"==typeof Xe?Xe({size:Tt,margin:It}):Xe,$t="function"==typeof Ye?Ye({size:Tt,margin:It}):Ye,zt=null!=Pe?Pe:Be,Gt=e.useRef(null),qt=e.useRef(null),Yt=e.useRef(0),Xt=e.useRef(!1),Vt=Bt(e=>e.theme),[Ut,Kt]=e.useState(0),[Qt,Zt]=e.useState(null),Jt=e.useRef(null),en=e.useRef(null),[tn,on]=e.useState(null),[rn,an]=e.useState(!1),[dn,gn]=e.useState([]),[fn,pn]=e.useState([]),yn=e.useRef(()=>{}),mn="streaming"===y||["bar","swarm","waterfall"].includes(f),vn=e.useMemo(()=>({chartType:f,runtimeMode:mn?"streaming":"bounded",windowSize:B,windowMode:T,arrowOfTime:mn?_:"right",extentPadding:R,scalePadding:H,xAccessor:mn?void 0:w,yAccessor:mn?void 0:A,timeAccessor:mn?N:void 0,valueAccessor:L,colorAccessor:S,sizeAccessor:O,groupAccessor:E||(M?"_lineGroup":void 0),categoryAccessor:Qe,lineDataAccessor:M,xScaleType:yt,yScaleType:mt,xExtent:D,yExtent:I,sizeRange:W,binSize:P,normalize:C,boundsAccessor:te,boundsStyle:ne,y0Accessor:oe,gradientFill:!0===ae?{topOpacity:.8,bottomOpacity:.05}:!1===ae?void 0:ae,areaGroups:le?new Set(le):void 0,lineGradient:se,openAccessor:ce,highAccessor:ue,lowAccessor:de,closeAccessor:he,candlestickStyle:me,lineStyle:X,pointStyle:V,areaStyle:U,swarmStyle:Q,waterfallStyle:K,colorScheme:ee,barColors:J,annotations:Ie,decay:rt,pulse:it,transition:at,staleness:st,heatmapAggregation:ct,heatmapXBins:ut,heatmapYBins:dt,showValues:ht,heatmapValueFormat:gt,pointIdAccessor:pt,curve:j}),[f,B,T,_,R,H,w,A,N,L,yt,mt,S,O,E,Qe,M,D,I,W,P,C,te,ne,oe,ae,se,le,ce,ue,de,he,me,X,V,U,Q,K,ee,J,Ie,rt,it,at,st,ct,ut,dt,ht,gt,mn,pt,j]),bn=e.useRef(null);bn.current||(bn.current=new Z(vn));const xn=e.useCallback(()=>{Yt.current||(Yt.current=requestAnimationFrame(()=>yn.current()))},[]);e.useEffect(()=>{var e;null===(e=bn.current)||void 0===e||e.updateConfig(vn),Xt.current=!0,xn()},[vn,xn]),e.useEffect(()=>{Gt.current&&Wt(Gt.current),Xt.current=!0,xn()},[Vt,xn]);const kn=e.useRef(null);kn.current||(kn.current=new x(e=>{const t=bn.current;t&&t.ingest(e)&&(Xt.current=!0,xn())},{chunkThreshold:v,chunkSize:k})),e.useEffect(()=>{var e;null===(e=kn.current)||void 0===e||e.updateChunkOptions({chunkThreshold:v,chunkSize:k})},[v,k]);const wn=e.useCallback(e=>{var t;null===(t=kn.current)||void 0===t||t.push(e)},[]),An=e.useCallback(e=>{var t;null===(t=kn.current)||void 0===t||t.pushMany(e)},[]),Sn=e.useCallback(()=>{var e,t;null===(e=kn.current)||void 0===e||e.clear(),null===(t=bn.current)||void 0===t||t.clear(),Xt.current=!0,xn()},[xn]);e.useImperativeHandle(n,()=>({push:wn,pushMany:An,remove:e=>{var t,n,o;null===(t=kn.current)||void 0===t||t.flush();const r=null!==(o=null===(n=bn.current)||void 0===n?void 0:n.remove(e))&&void 0!==o?o:[];return r.length>0&&(Jt.current&&r.some(e=>{var t;return e===(null===(t=Jt.current)||void 0===t?void 0:t.data)})&&(Jt.current=null,on(null)),Xt.current=!0,xn()),r},update:(e,t)=>{var n,o,r;null===(n=kn.current)||void 0===n||n.flush();const i=null!==(r=null===(o=bn.current)||void 0===o?void 0:o.update(e,t))&&void 0!==r?r:[];return i.length>0&&(Xt.current=!0,xn()),i},clear:Sn,getData:()=>{var e,t,n;return null===(e=kn.current)||void 0===e||e.flush(),null!==(n=null===(t=bn.current)||void 0===t?void 0:t.getData())&&void 0!==n?n:[]},getScales:()=>{var e,t;return null!==(t=null===(e=bn.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null},getExtents:()=>{var e,t;return null!==(t=null===(e=bn.current)||void 0===e?void 0:e.getExtents())&&void 0!==t?t:null}}),[wn,An,Sn,xn]),e.useEffect(()=>{var e,t;if(m){if(M&&m.length>0&&"object"==typeof m[0]&&null!==m[0]){const t="string"==typeof M?M:"coordinates";if(Array.isArray(m[0][t])){const n=[];for(const e of m){const o=e[t];if(Array.isArray(o)){const t=e.label||e.id||e.key;if(null!=t)for(const e of o)n.push(Object.assign(Object.assign({},e),{_lineGroup:t}));else for(const e of o)n.push(e)}}return void(null===(e=kn.current)||void 0===e||e.setBoundedData(n))}}null===(t=kn.current)||void 0===t||t.setBoundedData(m)}},[m,M]);const On=e.useRef(()=>{}),En=e.useRef(()=>{});On.current=e=>{if(!zt)return;const t=Gt.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-It.left,r=e.clientY-n.top-It.top;if(0>o||o>Rt||0>r||r>Ht)return void(Jt.current&&(Jt.current=null,en.current=null,on(null),_e&&(_e(null),Xt.current=!0),xn()));const i=bn.current;if(!i||0===i.scene.length)return;const a=re(i.scene,o,r,Ne,i.quadtree);if(!a)return void(Jt.current&&(Jt.current=null,en.current=null,on(null),_e&&_e(null),xn()));const s=nn(a.datum||{},a.x,a.y);if("multi"===De&&i.scene.length>0&&i.scales){const e=function(e,t,n=30){const o=[];for(const r of e)if("line"===r.type){const e=r;if(2>e.path.length)continue;const i=ie(e.path,t,n);if(null===i)continue;const a=ge(e.path,t);o.push({node:r,datum:Array.isArray(e.datum)&&e.datum[a]?e.datum[a]:e.datum,x:e.path[a][0],y:i,group:e.group,color:e.style.stroke})}else if("area"===r.type){const e=r;if(!1===e.interactive)continue;if(2>e.topPath.length)continue;const i=ie(e.topPath,t,n);if(null===i)continue;const a=ge(e.topPath,t);o.push({node:r,datum:Array.isArray(e.datum)&&e.datum[a]?e.datum[a]:e.datum,x:e.topPath[a][0],y:i,group:e.group,color:"string"==typeof e.style.stroke?e.style.stroke:"string"==typeof e.style.fill?e.style.fill:void 0})}return o}(i.scene,a.x,Ne),t=i.scales.y.invert,n=i.scales.x.invert;if(e.length>0){const o=n?n(a.x):a.x;s.xValue=o,s.xPx=a.x,s.allSeries=e.map(e=>({group:e.group||"",value:t?t(e.y):e.y,valuePx:e.y,color:e.color||"#007bff",datum:e.datum}))}}Jt.current=s,en.current=a.node,on(s),_e&&(_e(s),Xt.current=!0),xn()},En.current=()=>{Jt.current&&(Jt.current=null,en.current=null,on(null),_e&&(_e(null),Xt.current=!0),xn())},e.useCallback(e=>On.current(e),[]);const Mn=e.useCallback(()=>En.current(),[]),jn=e.useRef(()=>{});jn.current=e=>{if(!Te)return;const t=Gt.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-It.left,r=e.clientY-n.top-It.top;if(0>o||o>Rt||0>r||r>Ht)return void Te(null);const i=bn.current;if(!i||0===i.scene.length)return void Te(null);const a=re(i.scene,o,r,Ne,i.quadtree);Te(a?nn(a.datum||{},a.x,a.y):null)};const Cn=e.useCallback(e=>jn.current(e),[]),Pn=e.useRef(-1),Ln=e.useRef(null),_n=e.useRef(null),Tn=e.useCallback(e=>{const t=bn.current;if(!t||0===t.scene.length)return;const n=t.version;let o;if(_n.current&&_n.current.version===n)o=_n.current.graph;else{const e=function(e){var t,n,o,r;const i=[];for(const a of e)switch(a.type){case"point":i.push({x:a.x,y:a.y,datum:a.datum,shape:"circle",group:null!==(t=a.group)&&void 0!==t?t:"_default"});break;case"line":{const e=a,t=Array.isArray(e.datum)?e.datum:[],o=null!==(n=e.group)&&void 0!==n?n:"_default";for(let n=0;e.path.length>n&&t.length>n;n++)i.push({x:e.path[n][0],y:e.path[n][1],datum:t[n],shape:"circle",group:o});break}case"area":{const e=a,t=Array.isArray(e.datum)?e.datum:[],n=null!==(o=e.group)&&void 0!==o?o:"_default";for(let o=0;e.topPath.length>o&&t.length>o;o++)i.push({x:e.topPath[o][0],y:e.topPath[o][1],datum:t[o],shape:"circle",group:n});break}case"rect":i.push({x:a.x+a.w/2,y:a.y+a.h/2,datum:a.datum,shape:"rect",w:a.w,h:a.h,group:null!==(r=a.group)&&void 0!==r?r:"_default"});break;case"heatcell":i.push({x:a.x+a.w/2,y:a.y+a.h/2,datum:a.datum,shape:"rect",w:a.w,h:a.h,group:"_default"})}return i.sort((e,t)=>e.x-t.x||e.y-t.y),i}(t.scene);if(0===e.length)return;o=fe(e),_n.current={version:n,graph:o}}const r=Pn.current;if(0>r){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(e.key))return;e.preventDefault(),Pn.current=0;const t=o.flat[0];Ln.current={shape:t.shape,w:t.w,h:t.h};const n=ve(t);return Jt.current=n,on(n),_e&&_e(n),void xn()}const i=pe(o,r),a=ye(e.key,i,o);if(null===a)return;if(e.preventDefault(),0>a)return Pn.current=-1,Ln.current=null,Jt.current=null,en.current=null,on(null),_e&&_e(null),void xn();Pn.current=a;const s=o.flat[a];Ln.current={shape:s.shape,w:s.w,h:s.h};const l=ve(s);Jt.current=l,on(l),_e&&_e(l),xn()},[_e,xn]),Bn=e.useCallback(e=>{Pn.current=-1,Ln.current=null,On.current(e)},[]);yn.current=()=>{var e,t;Yt.current=0;const n=Gt.current,o=qt.current;if(!n||!o)return;const r=bn.current;if(!r)return;const i="undefined"!=typeof performance?performance.now():Date.now(),a=r.advanceTransition(Lt.current?i+1e6:i),s=!Lt.current&&a,l=Xt.current||a;l&&!s&&r.computeScene({width:Rt,height:Ht});const c=Dt(),u=function(e){if(!e)return un;const t=getComputedStyle(e),n=t.getPropertyValue("--semiotic-border").trim(),o=t.getPropertyValue("--semiotic-text-secondary").trim(),r=t.getPropertyValue("--semiotic-bg").trim(),i=o||t.getPropertyValue("--text-secondary").trim(),a=t.getPropertyValue("--text-primary").trim(),s=n||t.getPropertyValue("--surface-3").trim(),l=r||t.getPropertyValue("--surface-0").trim();return i||a||n?{axisStroke:s||un.axisStroke,tickText:i||un.tickText,crosshair:i?i+"66":un.crosshair,hoverFill:l?l+"4D":un.hoverFill,hoverStroke:i?i+"99":un.hoverStroke,pointRing:l||un.pointRing}:un}(n),d=null!==(e=null==st?void 0:st.threshold)&&void 0!==e?e:5e3,h=st&&r.lastIngestTime>0&&i-r.lastIngestTime>d;if(l){const e=Nt(n,Tt,It,c);if(e){e.clearRect(-It.left,-It.top,Tt[0],Tt[1]),h&&(e.globalAlpha=null!==(t=null==st?void 0:st.dimOpacity)&&void 0!==t?t:.5);const o=getComputedStyle(n).getPropertyValue("--semiotic-bg").trim(),i=Y||(o&&"transparent"!==o?o:null);if(i&&(e.fillStyle=i,e.fillRect(-It.left,-It.top,Tt[0],Tt[1])),e.save(),"function"==typeof e.rect&&(e.beginPath(),e.rect(0,0,Rt,Ht),e.clip()),Ve&&r.scales)for(const t of Ve)e.save(),t(e,r.scene,r.scales,{width:Rt,height:Ht}),e.restore();const a=ln[f];if(a&&r.scales)for(const t of a)t(e,r.scene,r.scales,{width:Rt,height:Ht});e.restore(),h&&(e.globalAlpha=1)}}{const e=Nt(o,Tt,It,c);if(e&&(e.clearRect(-It.left,-It.top,Tt[0],Tt[1]),zt&&Jt.current&&r.scales&&function(e,t,n,o,r,i,a){var s,l;if(!1===r.crosshair)return;const c=t.allSeries,u=c&&c.length>0,d=null!==(s=t.xPx)&&void 0!==s?s:t.x;e.save();const h="object"==typeof r.crosshair?r.crosshair:{};if(e.strokeStyle=h.stroke||a.crosshair,e.lineWidth=h.strokeWidth||1,e.setLineDash(h.strokeDasharray?h.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),e.beginPath(),e.moveTo(u?d:t.x,0),e.lineTo(u?d:t.x,o),e.stroke(),u||(e.beginPath(),e.moveTo(0,t.y),e.lineTo(n,t.y),e.stroke()),e.restore(),u){e.lineWidth=2,e.strokeStyle=a.pointRing;for(const t of c)null!=t.valuePx&&(e.beginPath(),e.arc(d,t.valuePx,4,0,2*Math.PI),e.fillStyle=t.color||"#007bff",e.fill(),e.stroke())}else{let n="";try{(null===(l=e.canvas)||void 0===l?void 0:l.parentElement)&&(n=getComputedStyle(e.canvas).getPropertyValue("--semiotic-primary").trim())}catch(e){}const o=r.pointColor||function(e){if(!e)return null;if("heatcell"===e.type)return e.fill||null;if("candlestick"===e.type)return e.isUp?e.upColor:e.downColor;const{style:t}=e;if(!t)return null;const n="string"==typeof t.fill?t.fill:null;return"line"===e.type||"area"===e.type?t.stroke||n||null:n||t.stroke||null}(i)||n||"#007bff";e.beginPath(),e.arc(t.x,t.y,4,0,2*Math.PI),e.fillStyle=o,e.fill(),e.strokeStyle=a.pointRing,e.lineWidth=2,e.stroke()}}(e,Jt.current,Rt,Ht,"object"==typeof zt?zt:{},en.current,u),en.current&&Array.isArray(Pe))){const t=Pe.find(e=>e&&"object"==typeof e&&"highlight"===e.type);t&&function(e,t,n,o){var r;if(!n)return;const i=n.group;if(void 0!==i)for(const n of t){if("line"!==n.type)continue;if(n.group!==i)continue;if(2>n.path.length)continue;const t="function"==typeof o.style?o.style(n.datum):o.style||{};e.save(),e.beginPath(),e.moveTo(n.path[0][0],n.path[0][1]);for(let t=1;n.path.length>t;t++)e.lineTo(n.path[t][0],n.path[t][1]);e.strokeStyle=t.stroke||n.style.stroke||"#007bff",e.lineWidth=t.strokeWidth||(n.style.strokeWidth||2)+2,e.globalAlpha=null!==(r=t.opacity)&&void 0!==r?r:1,e.stroke(),e.restore()}}(e,r.scene,en.current,t)}}l&&n&&n.setAttribute("aria-label",lt(r.scene,f+" chart"));const g=Xt.current;if(Xt.current=!1,g&&r.scales){const e=e=>"object"==typeof e&&null!==e&&"function"==typeof e.valueOf?e.valueOf():e;if((!Qt||e(Qt.x.domain()[0])!==e(r.scales.x.domain()[0])||e(Qt.x.domain()[1])!==e(r.scales.x.domain()[1])||e(Qt.y.domain()[0])!==e(r.scales.y.domain()[0])||e(Qt.y.domain()[1])!==e(r.scales.y.domain()[1])||Qt.x.range()[0]!==r.scales.x.range()[0]||Qt.x.range()[1]!==r.scales.x.range()[1]||Qt.y.range()[0]!==r.scales.y.range()[0]||Qt.y.range()[1]!==r.scales.y.range()[1])&&Zt(r.scales),ft){const e=r.getData(),t="function"==typeof w?w:e=>e[w||"x"],n="function"==typeof A?A:e=>e[A||"y"];gn(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),pn(e.map(e=>n(e)).filter(e=>"number"==typeof e&&isFinite(e)))}}g&&Ie&&Ie.length>0&&Kt(e=>e+1),(null==st?void 0:st.showBadge)&&an(!!h),(s||r.hasActivePulses)&&(Yt.current=requestAnimationFrame(()=>yn.current()))},e.useEffect(()=>(xn(),()=>{Yt.current&&(cancelAnimationFrame(Yt.current),Yt.current=0)}),[xn]),e.useEffect(()=>{Xt.current=!0,xn()},[f,Rt,Ht,ke,Y,X,Ve,xn]),xe(st,bn,Xt,xn,rn,an);const Nn=e.useMemo(()=>{if(Ee||je)return;const e=bn.current;return(null==e?void 0:e.xIsDate)&&Qt?sn(Qt.x.domain()):void 0},[Ee,je,Qt]),Dn=Ee||je||Nn,In=zt&&tn?Le?Le(tn):p.createElement(hn,{hover:tn}):null,Rn=In?p.createElement(Ot,{x:tn.x,y:tn.y,containerWidth:Rt,containerHeight:Ht,margin:It,className:"stream-frame-tooltip"},In):null,Hn=Ln.current,Wn=p.createElement(St,{active:Pn.current>=0,hoverPoint:tn,margin:It,size:Tt,shape:null==Hn?void 0:Hn.shape,width:null==Hn?void 0:Hn.w,height:null==Hn?void 0:Hn.h}),Fn=(e,t,n,o)=>"string"==typeof e?{key:e,fn:null}:"function"==typeof e?{key:n,fn:e}:"string"==typeof t?{key:t,fn:null}:"function"==typeof t?{key:o,fn:t}:{key:void 0,fn:null},$n=Fn(w,N,"__semiotic_resolvedX","__semiotic_resolvedTime"),zn=Fn(A,L,"__semiotic_resolvedY","__semiotic_resolvedValue"),Gn=$n.key,qn=zn.key,Yn=Ie&&Ie.length>0,Xn=e=>{if(!e||!Yn||!$n.fn&&!zn.fn)return e;let t=!1;const n=e.map(e=>{const n=$n.fn&&$n.key&&!($n.key in e),o=zn.fn&&zn.key&&!(zn.key in e);if(!n&&!o)return e;t=!0;const r=Object.assign({},e);return n&&(r[$n.key]=$n.fn(e)),o&&(r[zn.key]=zn.fn(e)),r});return t?n:e};if(ot){const e=bn.current;e&&m&&(e.ingest({inserts:m,bounded:!0}),e.computeScene({width:Rt,height:Ht}));const t=null!==(o=null==e?void 0:e.scene)&&void 0!==o?o:[],n=null!==(r=null==e?void 0:e.scales)&&void 0!==r?r:null,i=Dn||(()=>{if((null==e?void 0:e.xIsDate)&&n)return sn(n.x.domain())})();return p.createElement("div",{className:"stream-xy-frame"+(q?" "+q:""),role:"img","aria-label":At||("string"==typeof Ke?Ke:"XY chart"),style:{position:"relative",width:Tt[0],height:Tt[1]}},p.createElement(xt,{summary:Et}),p.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:Tt[0],height:Tt[1],style:{position:"absolute",left:0,top:0}},p.createElement("g",{transform:`translate(${It.left},${It.top})`},$t),p.createElement("g",{transform:`translate(${It.left},${It.top})`},Y&&p.createElement("rect",{x:0,y:0,width:Rt,height:Ht,fill:Y}),Ue&&n&&Ue.map((e,o)=>p.createElement(p.Fragment,{key:"svgpre-"+o},e(t,n,{width:Rt,height:Ht}))),t.map((e,t)=>function(e,t){var n,o,r;switch(e.type){case"line":{const n=e;if(0===n.path.length)return null;const o="M"+n.path.map(([e,t])=>`${e},${t}`).join("L");return p.createElement("path",{key:"line-"+t,d:o,fill:"none",stroke:n.style.stroke||"#4e79a7",strokeWidth:n.style.strokeWidth||2,strokeDasharray:n.style.strokeDasharray,opacity:n.style.opacity})}case"area":{const r=e;if(0===r.topPath.length)return null;const i=r.topPath.map(([e,t])=>`${e},${t}`).join("L"),a=[...r.bottomPath].reverse().map(([e,t])=>`${e},${t}`).join("L");return p.createElement("path",{key:"area-"+t,d:`M${i}L${a}Z`,fill:nt(r.style.fill),fillOpacity:null!==(o=null!==(n=r.style.fillOpacity)&&void 0!==n?n:r.style.opacity)&&void 0!==o?o:.7,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})}case"point":{const n=e;return p.createElement("circle",{key:"point-"+t,cx:n.x,cy:n.y,r:n.r,fill:nt(n.style.fill),opacity:null!==(r=n.style.opacity)&&void 0!==r?r:.8,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth})}case"rect":{const n=e;return p.createElement("rect",{key:"rect-"+t,x:n.x,y:n.y,width:n.w,height:n.h,fill:nt(n.style.fill),opacity:n.style.opacity,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth})}case"heatcell":{const n=e;if(n.showValues&&null!=n.value&&n.w>=20&&n.h>=20){const e=n.valueFormat?n.valueFormat(n.value):Number.isInteger(n.value)?n.value+"":100>Math.abs(n.value)?1>Math.abs(n.value)?n.value.toPrecision(3):n.value.toFixed(1):n.value.toFixed(0),[o,r,i]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(n.fill),a=.299*o+.587*r+.114*i>128?"#000":"#fff",s=Math.max(10,Math.min(16,.3*Math.min(n.w,n.h)));return p.createElement("g",{key:"heatcell-"+t},p.createElement("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill}),p.createElement("text",{x:n.x+n.w/2,y:n.y+n.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:a,fontSize:s+"px"},e))}return p.createElement("rect",{key:"heatcell-"+t,x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill})}case"candlestick":{const n=e,o=Math.min(n.openY,n.closeY),r=Math.max(Math.abs(n.openY-n.closeY),1),i=n.isUp?n.upColor:n.downColor;return p.createElement("g",{key:"candle-"+t},p.createElement("line",{x1:n.x,y1:n.highY,x2:n.x,y2:n.lowY,stroke:n.wickColor,strokeWidth:n.wickWidth}),p.createElement("rect",{x:n.x-n.bodyWidth/2,y:o,width:n.bodyWidth,height:r,fill:i,stroke:i,strokeWidth:1}))}default:return null}}(e,t)).filter(Boolean))),p.createElement(tt,{width:Rt,height:Ht,totalWidth:Tt[0],totalHeight:Tt[1],margin:It,scales:n,showAxes:ke,axes:we,xLabel:Ae,yLabel:Se,yLabelRight:Oe,xFormat:i,yFormat:Me||Ce,showGrid:He,title:Ke,legend:We,legendHoverBehavior:Fe,legendClickBehavior:$e,legendHighlightedCategory:ze,legendIsolatedCategories:Ge,legendPosition:qe,foregroundGraphics:Ft,marginalGraphics:ft,xValues:[],yValues:[],annotations:Ie,svgAnnotationRules:Re,annotationFrame:0,xAccessor:Gn,yAccessor:qn,annotationData:Xn(null==e?void 0:e.getData()),pointNodes:null==e?void 0:e.scene.filter(e=>"point"===e.type),curve:"string"==typeof j?j:void 0,linkedCrosshairName:jt,linkedCrosshairSourceId:Ct}))}const Vn="semiotic-table-"+p.useId();return p.createElement("div",{ref:_t,className:"stream-xy-frame"+(q?" "+q:""),role:"group","aria-label":At||("string"==typeof Ke?Ke:"XY chart"),tabIndex:0,style:{position:"relative",width:$?"100%":Tt[0],height:z?"100%":Tt[1],overflow:"visible"},onKeyDown:Tn},bt&&p.createElement(kt,{tableId:Vn}),bt&&p.createElement(vt,{scene:null!==(a=null===(i=bn.current)||void 0===i?void 0:i.scene)&&void 0!==a?a:[],chartType:f+" chart",tableId:Vn,chartTitle:"string"==typeof Ke?Ke:void 0}),p.createElement(xt,{summary:Et}),p.createElement("div",{role:"img","aria-label":At||("string"==typeof Ke?Ke:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:zt?Bn:void 0,onMouseLeave:zt?Mn:void 0,onClick:Te?Cn:void 0},$t&&p.createElement("svg",{style:{position:"absolute",left:0,top:0,width:Tt[0],height:Tt[1],pointerEvents:"none"}},p.createElement("g",{transform:`translate(${It.left},${It.top})`},$t)),p.createElement(Ze,{width:Rt,height:Ht,totalWidth:Tt[0],totalHeight:Tt[1],margin:It,scales:Qt,showAxes:ke,axes:we,showGrid:He,xFormat:Dn,yFormat:Me||Ce}),p.createElement("canvas",{ref:Gt,"aria-label":lt(null!==(l=null===(s=bn.current)||void 0===s?void 0:s.scene)&&void 0!==l?l:[],f+" chart"),style:{position:"absolute",left:0,top:0}}),p.createElement("canvas",{ref:qt,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),p.createElement(wt,{hoverPoint:tn}),p.createElement(tt,{width:Rt,height:Ht,totalWidth:Tt[0],totalHeight:Tt[1],margin:It,scales:Qt,showAxes:ke,axes:we,xLabel:Ae,yLabel:Se,yLabelRight:Oe,xFormat:Dn,yFormat:Me||Ce,showGrid:He,title:Ke,legend:We,legendHoverBehavior:Fe,legendClickBehavior:$e,legendHighlightedCategory:ze,legendIsolatedCategories:Ge,legendPosition:qe,foregroundGraphics:Ft,marginalGraphics:ft,xValues:dn,yValues:fn,annotations:Ie,svgAnnotationRules:Re,annotationFrame:Ut,xAccessor:Gn,yAccessor:qn,annotationData:Xn(null===(c=bn.current)||void 0===c?void 0:c.getData()),pointNodes:null===(u=bn.current)||void 0===u?void 0:u.scene.filter(e=>"point"===e.type),curve:"string"==typeof j?j:void 0,underlayRendered:!0,linkedCrosshairName:jt,linkedCrosshairSourceId:Ct}),(Je||et)&&p.createElement(b,{width:Rt,height:Ht,totalWidth:Tt[0],totalHeight:Tt[1],margin:It,dimension:null!==(d=null==Je?void 0:Je.dimension)&&void 0!==d?d:"xy",scales:Qt,onBrush:null!=et?et:()=>{},binSize:P,snap:null==Je?void 0:Je.snap,binBoundaries:null!==(h=null==Je?void 0:Je.binBoundaries)&&void 0!==h?h:"bar"===f?null===(g=bn.current)||void 0===g?void 0:g.getBinBoundaries():void 0,snapDuring:null==Je?void 0:Je.snapDuring,streaming:"streaming"===y}),(null==st?void 0:st.showBadge)&&p.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===st.badgePosition?{top:4,left:4}:"bottom-left"===st.badgePosition?{bottom:4,left:4}:"bottom-right"===st.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:rn?"#dc3545":"#28a745",color:"white"})},rn?"STALE":"LIVE"),Wn,Rn))});gn.displayName="StreamXYFrame";const fn=e.createContext(null);function pn({colors:t,categories:n,colorScheme:o="category10",children:r}){const i=e.useMemo(()=>{if(t)return t;if(n){const e=Array.isArray(o)?o:j[o]||C,t={};for(let o=0;n.length>o;o++)t[n[o]]=e[o%e.length];return t}return{}},[t,n,o]);return p.createElement(fn.Provider,{value:i},r)}function yn(){return e.useContext(fn)}function mn(e){const t=[];for(const[n,o]of Object.entries(e.fields))if("point"===o.type)t.push(e=>o.values.has(e[n]));else{const[e,r]=o.range;t.push(t=>{const o=t[n];return o>=e&&r>=o})}return e=>t.every(t=>t(e))}function vn(e,t){const n=[];for(const[o,r]of e.clauses)"crossfilter"===e.resolution&&o===t||n.push(mn(r));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}function bn(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}pn.displayName="CategoryColorProvider";const[xn,kn]=jt(e=>({selections:new Map,setClause(t,n){e(e=>{const o=new Map(e.selections),r=bn(o,t),i=new Map(r.clauses);return i.set(n.clientId,n),o.set(t,Object.assign(Object.assign({},r),{clauses:i})),{selections:o}})},clearClause(t,n){e(e=>{const o=e.selections.get(t);if(!o)return{};const r=new Map(e.selections),i=new Map(o.clauses);return i.delete(n),r.set(t,Object.assign(Object.assign({},o),{clauses:i})),{selections:r}})},setResolution(t,n){e(e=>{const o=new Map(e.selections),r=bn(o,t);return o.set(t,Object.assign(Object.assign({},r),{resolution:n})),{selections:o}})},clearSelection(t){e(e=>{const n=new Map(e.selections),o=n.get(t);return o&&n.set(t,Object.assign(Object.assign({},o),{clauses:new Map})),{selections:n}})}})),[wn,An]=jt(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const n=e.observations;return n.push(t),n.length>e.maxObservations&&n.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}}));function Sn(t){const n=e.useId(),o=t.clientId||n,{name:r}=t,i=kn(e=>e.selections.get(r)),a=kn(e=>e.setClause),s=kn(e=>e.clearClause),l=e.useMemo(()=>!!i&&i.clauses.size>0,[i]);return{predicate:e.useMemo(()=>i&&0!==i.clauses.size?vn(i,o):()=>!0,[i,o]),isActive:l,selectPoints:e.useCallback(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"point",values:new Set(o)};a(r,{clientId:o,type:"point",fields:t})},[o,r,a]),selectInterval:e.useCallback(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"interval",range:o};a(r,{clientId:o,type:"interval",fields:t})},[o,r,a]),clear:e.useCallback(()=>{s(r,o)},[s,r,o]),clientId:o}}function On(t){const n=t.name||"hover",{fields:o}=t,{predicate:r,isActive:i,selectPoints:a,clear:s}=Sn({name:n});return{onHover:e.useCallback(e=>{if(!e)return void s();const t={};for(const n of o){const o=e[n];void 0!==o&&(t[n]=[o])}Object.keys(t).length>0&&a(t)},[o,a,s,n]),predicate:r,isActive:i}}function En(t){const{name:n,xField:o,yField:r}=t,{predicate:i,isActive:a,selectInterval:s,clear:l}=Sn({name:n}),c=o&&r?"xyBrush":o?"xBrush":"yBrush",u=e.useCallback(e=>{if(!e)return void l();const t={};"xyBrush"===c&&Array.isArray(e)&&2===e.length?(o&&(t[o]=[Math.min(e[0][0],e[1][0]),Math.max(e[0][0],e[1][0])]),r&&(t[r]=[Math.min(e[0][1],e[1][1]),Math.max(e[0][1],e[1][1])])):"xBrush"===c&&Array.isArray(e)?o&&(t[o]=[Math.min(...e),Math.max(...e)]):"yBrush"===c&&Array.isArray(e)&&r&&(t[r]=[Math.min(...e),Math.max(...e)]),Object.keys(t).length>0&&s(t)},[c,o,r,s,l]);return{brushInteraction:e.useMemo(()=>({brush:c,during:u,end:u}),[c,u]),predicate:i,isActive:a,clear:l}}function Mn(t={}){const{limit:n=50,types:o,chartId:r}=t,i=An(e=>e.version),a=An(e=>e.observations),s=An(e=>e.clearObservations),l=e.useMemo(()=>{let e=a;if(o&&o.length>0){const t=new Set(o);e=e.filter(e=>t.has(e.type))}return r&&(e=e.filter(e=>e.chartId===r)),e.length>n&&(e=e.slice(e.length-n)),e},[a,o,r,n,i]);return{observations:l,latest:l.length>0?l[l.length-1]:null,clear:s}}const jn=e.createContext(!1);function Cn({selections:t}){const n=kn(e=>e.setResolution);return e.useEffect(()=>{for(const[e,o]of Object.entries(t))o.resolution&&n(e,o.resolution)},[t,n]),null}function Pn({categoryColors:t,interaction:n,selectionName:o,field:r}){const i=Object.entries(t);if(0===i.length)return null;const a=i.map(([e])=>e),s=[{styleFn:e=>({fill:e.color||"#333",stroke:e.color||"#333"}),type:"fill",items:i.map(([e,t])=>({label:e,color:t})),label:""}],l=On({name:o,fields:[r]}),c=Sn({name:o,clientId:"__linked-legend-isolate__"}),[u,d]=e.useState(new Set),[h,g]=e.useState(null),f=e.useRef(c.selectPoints);f.current=c.selectPoints;const y=e.useRef(c.clear);y.current=c.clear,e.useEffect(()=>{"isolate"===n&&(u.size>0?f.current({[r]:Array.from(u)}):y.current())},[n,u,r]);const m=e.useCallback(e=>{"highlight"===n&&(e?(g(e.label),l.onHover({[r]:e.label})):(g(null),l.onHover(null)))},[n,r,l]),v=e.useCallback(e=>{"isolate"===n&&d(t=>{const n=new Set(t);return n.has(e.label)?n.delete(e.label):n.add(e.label),n.size===a.length?new Set:n})},[n,a.length]);return p.createElement("svg",{width:"100%",height:30,style:{display:"block",overflow:"visible"}},p.createElement(Ee,{legendGroups:s,title:!1,orientation:"horizontal",height:20,customHoverBehavior:"highlight"===n?m:void 0,customClickBehavior:"isolate"===n?v:void 0,highlightedCategory:h,isolatedCategories:u}))}function Ln({children:e,selections:t,showLegend:n,legendPosition:o="top",legendInteraction:r="none",legendSelectionName:i="legend",legendField:a="category"}){const s=yn(),l=void 0!==n?n:!(!s||0>=Object.keys(s).length);return p.createElement(xn,null,p.createElement(wn,null,t&&p.createElement(Cn,{selections:t}),p.createElement(jn.Provider,{value:l},l&&"top"===o&&s&&p.createElement(Pn,{categoryColors:s,interaction:r,selectionName:i,field:a}),e,l&&"bottom"===o&&s&&p.createElement(Pn,{categoryColors:s,interaction:r,selectionName:i,field:a}))))}function _n({data:e,colorBy:t,colorScale:n,getColor:o,strokeColor:r,strokeWidth:i,categories:a}){const s=(a&&a.length>0?a:Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t])))).map((r,i)=>{const a=e.find("function"==typeof t?e=>t(e)===r:e=>e[t]===r),s=a?o(a,t,n):n?n(r):P[i%P.length];return{label:r+"",color:s}});return{legendGroups:[{styleFn:e=>{const t=e.color||"#333",n={fill:t,stroke:t};return void 0!==r&&(n.stroke=r),void 0!==i&&(n.strokeWidth=i),n},type:"fill",items:s,label:""}]}}function Tn(e){return e?"string"==typeof e?{name:e}:e:null}function Bn(e,t,n){return t?o=>{var r;const i=Object.assign({},e(o));if(t.isActive)if(t.predicate(o))(null==n?void 0:n.selectedStyle)&&Object.assign(i,n.selectedStyle);else{const e=null!==(r=null==n?void 0:n.unselectedOpacity)&&void 0!==r?r:.2;i.opacity=e,i.fillOpacity=e,i.strokeOpacity=e,(null==n?void 0:n.unselectedStyle)&&Object.assign(i,n.unselectedStyle)}return i}:e}const Nn={light:Pt,dark:Lt,"high-contrast":_t,pastels:{mode:"light",colors:{primary:"#c9a0dc",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#fdf6f0",text:"#4a3728",textSecondary:"#8b7355",grid:"#e8d5c4",border:"#e8d5c4",focus:"#c9a0dc"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#fff5ee",text:"#4a3728",borderRadius:"8px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"10px"},"pastels-dark":{mode:"dark",colors:{primary:"#c9a0dc",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#1a1525",text:"#e8ddf0",textSecondary:"#a899c0",grid:"#3d3455",border:"#3d3455",focus:"#c9a0dc"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#251e35",text:"#e8ddf0",borderRadius:"8px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"10px"},"bi-tool":{mode:"light",colors:{primary:"#2563eb",categorical:["#2563eb","#0d9488","#ea580c","#6b7280"],sequential:"blues",background:"#f5f6f8",text:"#2c3e50",textSecondary:"#7f8c9b",grid:"#d8dce3",border:"#d8dce3",focus:"#2563eb"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#2c3e50",borderRadius:"6px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"8px"},"bi-tool-dark":{mode:"dark",colors:{primary:"#3b82f6",categorical:["#3b82f6","#14b8a6","#f97316","#9ca3af"],sequential:"blues",background:"#111827",text:"#f3f4f6",textSecondary:"#9ca3af",grid:"#374151",border:"#374151",focus:"#3b82f6"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1f2937",text:"#f3f4f6",borderRadius:"6px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"8px"},italian:{mode:"light",colors:{primary:"#cc0000",categorical:["#cc0000","#333333","#c8a415","#4682b4"],sequential:"reds",background:"#fafafa",text:"#1a1a1a",textSecondary:"#666666",grid:"#e0e0e0",border:"#e0e0e0",focus:"#cc0000"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#1a1a1a",borderRadius:"2px",shadow:"0 2px 4px rgba(0, 0, 0, 0.15)"},borderRadius:"2px"},"italian-dark":{mode:"dark",colors:{primary:"#ff3333",categorical:["#ff3333","#aaaaaa","#d4a843","#6aa4d4"],sequential:"reds",background:"#0a0a0a",text:"#f5f5f5",textSecondary:"#aaaaaa",grid:"#333333",border:"#333333",focus:"#ff3333"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1a1a1a",text:"#f5f5f5",borderRadius:"2px",shadow:"0 2px 8px rgba(0, 0, 0, 0.5)"},borderRadius:"2px"},tufte:{mode:"light",colors:{primary:"#8b0000",categorical:["#8b4513","#556b2f","#4a5568","#800020"],sequential:"oranges",background:"#fffff8",text:"#111111",textSecondary:"#555555",grid:"#e0ddd0",border:"#e0ddd0",focus:"#8b0000",annotation:"#8b0000"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:10,tickFontFamily:"'Courier New', Courier, monospace",legendSize:11},tooltip:{background:"#fffff8",text:"#111111",borderRadius:"2px",shadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},borderRadius:"0px"},"tufte-dark":{mode:"dark",colors:{primary:"#c05050",categorical:["#c08050","#7a8b5a","#8090a0","#a05060"],sequential:"oranges",background:"#1c1b18",text:"#e8e4d8",textSecondary:"#a09880",grid:"#3d3c35",border:"#3d3c35",focus:"#c05050"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#262520",text:"#e8e4d8",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.4)"},borderRadius:"0px"},journalist:{mode:"light",colors:{primary:"#e45050",categorical:["#3a86c8","#e45050","#d4a843","#888888"],sequential:"blues",background:"#ffffff",text:"#222222",textSecondary:"#666666",grid:"#d4d4d4",border:"#d4d4d4",focus:"#e45050",annotation:"#e45050"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:18,labelSize:12,tickSize:10,tickFontFamily:"'Courier New', Courier, monospace",legendSize:11},tooltip:{background:"#f8f8f8",text:"#222222",borderRadius:"4px",shadow:"0 2px 6px rgba(0, 0, 0, 0.12)"},borderRadius:"4px"},"journalist-dark":{mode:"dark",colors:{primary:"#ff6b6b",categorical:["#5a9fd8","#ff6b6b","#e0c060","#aaaaaa"],sequential:"blues",background:"#141414",text:"#ededed",textSecondary:"#a0a0a0",grid:"#383838",border:"#383838",focus:"#ff6b6b"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1e1e1e",text:"#ededed",borderRadius:"4px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"4px"},playful:{mode:"light",colors:{primary:"#8b5cf6",categorical:["#8b5cf6","#ec4899","#06b6d4","#84cc16"],sequential:"viridis",background:"#fdf8ff",text:"#2d1b4e",textSecondary:"#7c5a9e",grid:"#e8d0f8",border:"#e8d0f8",focus:"#8b5cf6"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#2d1b4e",borderRadius:"12px",shadow:"0 4px 12px rgba(139, 92, 246, 0.15)"},borderRadius:"12px"},"playful-dark":{mode:"dark",colors:{primary:"#a78bfa",categorical:["#a78bfa","#f472b6","#22d3ee","#a3e635"],sequential:"viridis",background:"#150a28",text:"#f0e8ff",textSecondary:"#b8a0d8",grid:"#3a2560",border:"#3a2560",focus:"#a78bfa"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1f1138",text:"#f0e8ff",borderRadius:"12px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"12px"},carbon:{mode:"light",colors:{primary:"#0f62fe",categorical:["#6929c4","#1192e8","#005d5d","#9f1853"],sequential:"blues",diverging:"RdBu",background:"#ffffff",text:"#161616",textSecondary:"#525252",grid:"#e0e0e0",border:"#e0e0e0",focus:"#0f62fe"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#161616",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.2)"},borderRadius:"0px"},"carbon-dark":{mode:"dark",colors:{primary:"#4589ff",categorical:["#a56eff","#33b1ff","#08bdba","#ff7eb6"],sequential:"blues",diverging:"RdBu",background:"#161616",text:"#f4f4f4",textSecondary:"#a8a8a8",grid:"#393939",border:"#393939",focus:"#4589ff"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#262626",text:"#f4f4f4",borderRadius:"2px",shadow:"0 4px 12px rgba(0, 0, 0, 0.5)"},borderRadius:"0px"}};function Dn(e){return Nn[e]}const In=p.createContext(void 0);function Rn({theme:e}){const t=Bt(e=>e.setTheme),n=Bt(e=>e.theme),o=p.useRef(n);o.current=n;const r=p.useRef(null);return p.useEffect(()=>{if(void 0!==e)return;if("undefined"==typeof window||!window.matchMedia)return;const n=window.matchMedia("(forced-colors: active)");return n.matches&&(r.current=o.current,t(_t)),Et(n,e=>{var n;e.matches?(r.current=o.current,t(_t)):(t(null!==(n=r.current)&&void 0!==n?n:Pt),r.current=null)})},[e,t]),p.useEffect(()=>{if(void 0!==e)if("string"==typeof e){const n=Dn(e);t(n||e)}else t(e)},[e,t]),null}function Hn({children:e}){var t,n,o,r,i;const a=Bt(e=>e.theme),s=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({position:"relative","--semiotic-bg":a.colors.background,"--semiotic-text":a.colors.text,"--semiotic-text-secondary":a.colors.textSecondary,"--semiotic-grid":a.colors.grid,"--semiotic-border":a.colors.border,"--semiotic-primary":a.colors.primary,"--semiotic-font-family":a.typography.fontFamily},a.colors.focus?{"--semiotic-focus":a.colors.focus}:{}),(null===(t=a.tooltip)||void 0===t?void 0:t.background)?{"--semiotic-tooltip-bg":a.tooltip.background}:{}),(null===(n=a.tooltip)||void 0===n?void 0:n.text)?{"--semiotic-tooltip-text":a.tooltip.text}:{}),(null===(o=a.tooltip)||void 0===o?void 0:o.borderRadius)?{"--semiotic-tooltip-radius":a.tooltip.borderRadius}:{}),(null===(r=a.tooltip)||void 0===r?void 0:r.fontSize)?{"--semiotic-tooltip-font-size":a.tooltip.fontSize}:{}),(null===(i=a.tooltip)||void 0===i?void 0:i.shadow)?{"--semiotic-tooltip-shadow":a.tooltip.shadow}:{}),a.borderRadius?{"--semiotic-border-radius":a.borderRadius}:{}),a.colors.selection?{"--semiotic-selection-color":a.colors.selection}:{}),null!=a.colors.selectionOpacity?{"--semiotic-selection-opacity":a.colors.selectionOpacity+""}:{}),a.colors.diverging?{"--semiotic-diverging":a.colors.diverging}:{}),a.colors.annotation?{"--semiotic-annotation-color":a.colors.annotation}:{}),null!=a.typography.legendSize?{"--semiotic-legend-font-size":a.typography.legendSize+"px"}:{}),null!=a.typography.titleFontSize?{"--semiotic-title-font-size":a.typography.titleFontSize+"px"}:{}),null!=a.typography.tickFontFamily?{"--semiotic-tick-font-family":a.typography.tickFontFamily}:{}),l=p.useContext(In),c={};return l&&(c["data-semiotic-theme"]=l),p.createElement("div",Object.assign({style:s},c),e)}function Wn(){return Bt(e=>e.theme)}const Fn="#007bff";function $n(){var e;const t=Wn(),n=null===(e=null==t?void 0:t.colors)||void 0===e?void 0:e.categorical;return n&&n.length>0?n:void 0}function zn(e,t,n,o,r){if(e)return e;let i;if(Array.isArray(n))i=n;else if(t&&t.length>0)i=t;else if("string"==typeof n){const e=j[n];Array.isArray(e)&&(i=e)}return i&&0!==i.length?null!=o?(r.has(o)||r.set(o,r.size),i[r.get(o)%i.length]):i[0]:Fn}function Gn(e){return"function"==typeof e?e:t=>t[e]}function qn(t,n,o){const r=yn(),i=$n();return e.useMemo(()=>{var e;if(!n)return;const a=null!==(e=null!=o?o:i&&i.length>0?i:void 0)&&void 0!==e?e:"category10";if(0!==t.length){if("function"==typeof n){const e=Array.from(new Set(t.map(e=>n(e)+"")));if(r&&Object.keys(r).length>0){const t=B(e.map(e=>({_cat:e})),"_cat",a);return e=>r[e]||t(e)}return B(e.map(e=>({_cat:e})),"_cat",a)}if(r&&Object.keys(r).length>0){const e=B(t,n,a);return t=>r[t]||e(t)}return B(t,n,a)}if(r&&Object.keys(r).length>0){const e=B([{_:"a"}],"_",a);return t=>r[t]||e(t)}},[t,n,o,r,i])}function Yn(t,n,o){return e.useMemo(()=>{if(!n)return t;const e=[...t];if("function"==typeof n)return e.sort(n);const r=Gn(o);return e.sort("asc"===n?(e,t)=>r(e)-r(t):(e,t)=>r(t)-r(e))},[t,n,o])}function Xn({selection:t,linkedHover:n,fallbackFields:o=[],unwrapData:r=!1,onObservation:i,chartType:a,chartId:s,onClick:l,hoverHighlight:c,colorByField:u}){const d=e.useId(),h=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||t||[],mode:e.mode,xField:e.xField}:null}(n,o),g=Sn({name:(null==t?void 0:t.name)||"__unused__"}),f=On({name:(null==h?void 0:h.name)||"hover",fields:(null==h?void 0:h.fields)||o||[]}),p=An(e=>e.pushObservation),y=t?{isActive:g.isActive,predicate:g.predicate}:null,[m,v]=e.useState(null),b=u||o[0],x=e.useMemo(()=>{if(!c||null==m||!b)return null;const e=m,t=b;return{isActive:!0,predicate:n=>{var o;return("string"==typeof n[t]?n[t]:(null!==(o=n[t])&&void 0!==o?o:"")+"")===e}}},[c,m,b]),k=e.useCallback(e=>{var t,o;if(n)if(e){let t=e.data||e.datum||e;if(Array.isArray(t)&&(t=t[0]),"x-position"===(null==h?void 0:h.mode)&&h.xField){const e=null==t?void 0:t[h.xField];null!=e&&Number.isFinite(Number(e))&&function(e,t,n){const o=We.positions.get(e);(null==o?void 0:o.locked)||o&&o.xValue===t&&o.sourceId===n||(We={positions:new Map(We.positions).set(e,{xValue:t,sourceId:n})},$e())}(h.name||"hover",Number(e),d)}"x-position"!==(null==h?void 0:h.mode)&&f.onHover(t)}else"x-position"===(null==h?void 0:h.mode)&&ze(h.name||"hover",d),"x-position"!==(null==h?void 0:h.mode)&&f.onHover(null);if(c&&b)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=null==t?void 0:t[b];v(null!=n?n+"":null)}else v(null);if(i||p){const n={timestamp:Date.now(),chartType:a||"unknown",chartId:s};if(e){let r=e.data||e.datum||e;Array.isArray(r)&&(r=r[0]);const a=Object.assign(Object.assign({},n),{type:"hover",datum:r||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(o=e.y)&&void 0!==o?o:0});i&&i(a),p&&p(a)}else{const e=Object.assign(Object.assign({},n),{type:"hover-end"});i&&i(e),p&&p(e)}}},[n,f,h,d,i,a,s,p,c,b]),w=e.useCallback(e=>{var t,n,o,r;if("x-position"===(null==h?void 0:h.mode)&&h.xField&&e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=null==t?void 0:t[h.xField];null!=n&&Number.isFinite(Number(n))&&function(e,t,n){const o=We.positions.get(e);if(null==o?void 0:o.locked){const t=new Map(We.positions);return t.delete(e),We={positions:t},$e(),!1}We={positions:new Map(We.positions).set(e,{xValue:t,sourceId:n,locked:!0})},$e()}(h.name||"hover",Number(n),d)}if(e&&l){let o=e.data||e.datum||e;Array.isArray(o)&&(o=o[0]),l(o,{x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0})}if(i||p){const t={timestamp:Date.now(),chartType:a||"unknown",chartId:s};if(e){let n=e.data||e.datum||e;Array.isArray(n)&&(n=n[0]);const a=Object.assign(Object.assign({},t),{type:"click",datum:n||{},x:null!==(o=e.x)&&void 0!==o?o:0,y:null!==(r=e.y)&&void 0!==r?r:0});i&&i(a),p&&p(a)}else{const e=Object.assign(Object.assign({},t),{type:"click-end"});i&&i(e),p&&p(e)}}},[l,i,p,a,s,h,d]);return e.useEffect(()=>{if("x-position"!==(null==h?void 0:h.mode))return;const e=h.name||"hover";return()=>{Ge(e,d),ze(e,d)}},[null==h?void 0:h.mode,null==h?void 0:h.name,d]),{activeSelectionHook:y,hoverSelectionHook:x,customHoverBehavior:k,customClickBehavior:w,crosshairSourceId:d}}function Vn(e,t){const n="object"==typeof e&&null!==e?e:void 0;if("x-position"===(null==n?void 0:n.mode))return{linkedCrosshairName:n.name||"hover",linkedCrosshairSourceId:t}}function Un({data:t,colorBy:n,colorScale:o,showLegend:r,legendPosition:i="right",userMargin:a,defaults:s={top:50,bottom:60,left:70,right:40},categories:l}){const c=e.useContext(jn),u=void 0!==r?r:!c&&!!n,d=e.useMemo(()=>{if(u&&n)return _n({data:t,colorBy:n,colorScale:o,getColor:T,categories:l})},[u,n,t,o,l]),h=e.useMemo(()=>{const e=Object.assign(Object.assign({},s),a);return d&&("right"===i&&110>e.right?e.right=110:"left"===i&&110>e.left?e.left=110:"top"===i&&50>e.top?e.top=50:"bottom"===i&&80>e.bottom&&(e.bottom=80)),e},[s,a,d,i]);return{legend:d,margin:h,legendPosition:i}}function Kn(t,n,o){const[r,i]=e.useState(null),[a,s]=e.useState(new Set),l=e.useCallback(e=>{"highlight"===t&&i(e?e.label:null)},[t]),c=e.useCallback(e=>{"isolate"===t&&s(t=>{const n=new Set(t);return n.has(e.label)?n.delete(e.label):n.add(e.label),n.size===o.length?new Set:n})},[t,o.length]),u=e.useMemo(()=>{if(!t||"none"===t||!n)return null;const e="string"==typeof n?n:null;return"highlight"===t&&null!=r?{isActive:!0,predicate:t=>(e?t[e]:"function"==typeof n?n(t):null)===r}:"isolate"===t&&a.size>0?{isActive:!0,predicate:t=>{const o=e?t[e]:"function"==typeof n?n(t):null;return a.has(o)}}:null},[t,n,r,a]);return{highlightedCategory:"highlight"===t?r:null,isolatedCategories:"isolate"===t?a:new Set,onLegendHover:l,onLegendClick:c,legendSelectionHook:u}}const Qn={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 Zn(e,t,n){var o,r,i,a,s,l,c;const u=Qn[e||"primary"],d="context"===e||"sparkline"===e;return{width:null!==(o=t.width)&&void 0!==o?o:e&&"primary"!==e||!(null==n?void 0:n.width)?u.width:n.width,height:null!==(r=t.height)&&void 0!==r?r:e&&"primary"!==e||!(null==n?void 0:n.height)?u.height:n.height,showAxes:null!==(i=t.showAxes)&&void 0!==i?i:u.showAxes,showGrid:null!==(a=t.showGrid)&&void 0!==a?a:u.showGrid,enableHover:null!==(s=t.enableHover)&&void 0!==s?s:!!t.linkedHover||u.enableHover,showLegend:null!==(l=t.showLegend)&&void 0!==l?l:u.showLegend,showLabels:null!==(c=t.showLabels)&&void 0!==c?c:u.showLabels,title:d?void 0:t.title,description:t.description,summary:t.summary,accessibleTable:t.accessibleTable,xLabel:d?void 0:t.xLabel,yLabel:d?void 0:t.yLabel,categoryLabel:d?void 0:t.categoryLabel,valueLabel:d?void 0:t.valueLabel,marginDefaults:Jn(u.marginDefaults,t.showCategoryTicks,t.orientation)}}function Jn(e,t,n){if(!1!==t)return e;const o=Object.assign({},e);return"horizontal"===n?o.left=Math.min(o.left,15):o.bottom=Math.min(o.bottom,15),o}const eo={background:"var(--semiotic-tooltip-bg, rgba(0, 0, 0, 0.85))",color:"var(--semiotic-tooltip-text, white)",padding:"8px 12px",borderRadius:"var(--semiotic-tooltip-radius, 6px)",fontSize:"var(--semiotic-tooltip-font-size, 14px)",fontFamily:"var(--semiotic-font-family, inherit)",lineHeight:"1.5",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, 0.15))",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"};function to(e,t){return"function"==typeof t?t(e):e[t]}function no(e,t){if(t)return t(e);if(null==e)return"";if("number"==typeof e){if(!Number.isFinite(e))return e+"";const t=Number.isInteger(e)?e:parseFloat(e.toPrecision(6));return Math.abs(t)>9999?t.toLocaleString():t+""}return 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 oo(e={}){const{fields:t,title:n,format:o,style:r={},className:i=""}=e;return e=>{if(!e||"object"!=typeof e)return null;let a;const s=[];if(n){const t=to(e,n);a=no(t,o)}if(t&&t.length>0)t.forEach(t=>{let n,r,i;"string"==typeof t?(n=t,r=t,i=o):(n=t.label,r=t.accessor||t.key||"",i=t.format||o);const a=to(e,r);s.push({label:n,value:no(a,i)})});else if(!n){const t=["value","y","name","id","label"];for(const n of t)if(void 0!==e[n]){a=no(e[n],o);break}if(!a){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(a=no(e[t[0]],o))}}const l=Object.assign(Object.assign({},eo),r);return p.createElement("div",{className:("semiotic-tooltip "+i).trim(),style:l},a&&p.createElement("div",{style:{fontWeight:s.length>0?"bold":"normal"}},a),s.map((e,t)=>p.createElement("div",{key:t,style:{marginTop:0===t&&a?"4px":0}},e.label&&p.createElement("span",null,e.label,": "),e.value)))}}function ro(e){if(!0===e)return oo();if("function"==typeof e){const t=e;return e=>{const n=t(!e||"object"!=typeof e.data||null===e.data||"node"!==e.type&&"edge"!==e.type?e:e.data);return null==n?null:p.createElement("div",{className:"semiotic-tooltip",style:eo},n)}}return!1!==e&&void 0!==e&&("object"==typeof e&&null!==e&&("fields"in e||"title"in e)?oo(e):oo())}function io(e){return"string"==typeof e?e:"value"}function ao(e){return null==e?"–":"number"==typeof e?Math.abs(e)>9999?e.toLocaleString():e+"":e instanceof Date?e.toLocaleDateString():e+""}function so(e,t){return"function"==typeof t?t(e):e[t]}function lo(e){const t=e.find(e=>"title"===e.role),n=e.filter(e=>"title"!==e.role);return e=>{const o=e.data;if(!o)return null;const r=t?ao(so(o,t.accessor)):null;return p.createElement("div",{className:"semiotic-tooltip",style:eo},r&&p.createElement("div",{style:{fontWeight:"bold",marginBottom:n.length>0?4:0}},r),n.map((e,t)=>{const n=ao(so(o,e.accessor));return p.createElement("div",{key:t,style:t>0?{marginTop:2}:void 0},p.createElement("span",{style:{opacity:.7}},e.label,": "),p.createElement("span",null,n))}))}}function co({categoryAccessor:e,valueAccessor:t,groupAccessor:n,groupLabel:o,pieData:r=!1}){return i=>{var a;const s=r?(null===(a=i.data)||void 0===a?void 0:a[0])||i.data||i:i.data||i,l=so(s,e),c=so(s,t),u=n?so(s,n):void 0;return p.createElement("div",{className:"semiotic-tooltip",style:eo},p.createElement("div",{style:{fontWeight:"bold"}},ao(l)),p.createElement("div",{style:{marginTop:4}},ao(c)),null!=u&&p.createElement("div",{style:{marginTop:2,opacity:.8}},o||io(n),": ",ao(u)))}}function uo({componentName:e,message:t,diagnosticHint:n,width:o,height:r}){return p.createElement("div",{role:"alert",style:{width:o,height:Math.max(r,120),display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed rgba(128, 128, 128, 0.4)",borderRadius:8,background:"rgba(128, 128, 128, 0.04)",padding:24,boxSizing:"border-box"}},p.createElement("div",{style:{textAlign:"center",maxWidth:400}},p.createElement("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"}},e),p.createElement("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5}},t),n&&p.createElement("div",{"data-testid":"semiotic-diagnostic-hint",style:{marginTop:10,padding:"8px 12px",background:"rgba(128, 128, 128, 0.06)",borderRadius:4,fontSize:12,color:"rgba(128, 128, 128, 0.8)",fontFamily:"monospace",textAlign:"left",whiteSpace:"pre-wrap",lineHeight:1.6}},n)))}class ho extends p.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){var n,o;null===(o=(n=this.props).onError)||void 0===o||o.call(n,e,t)}render(){if(this.state.error){const{fallback:e}=this.props,t=this.state.error;return"function"==typeof e?e(t):void 0!==e?e:p.createElement(uo,{componentName:"ChartErrorBoundary",message:t.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}function go(e,t){const n=e.length,o=t.length,r=Array(o+1);for(let e=0;o>=e;e++)r[e]=e;for(let i=1;n>=i;i++){let n=r[0];r[0]=i;for(let a=1;o>=a;a++){const o=r[a];r[a]=e[i-1]===t[a-1]?n:1+Math.min(n,r[a],r[a-1]),n=o}}return r[o]}function fo(e,t,n=3){let o,r=n+1;for(const n of t){const t=go(e.toLowerCase(),n.toLowerCase());r>t&&(r=t,o=n)}return r>n?void 0:o}function po(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:e}function yo(e,t){var n;if(0===t.length)return null;const o=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(o)||o.includes(e.toLowerCase()))||(null!==(n=fo(e,t,3))&&void 0!==n?n:null)}function mo({componentName:e,data:t,accessors:n,requiredProps:o}){if(o)for(const[t,n]of Object.entries(o))if(null==n)return`${e}: ${t} is required. Provide a field name or function.`;if(null==t)return null;if(!Array.isArray(t)||0===t.length)return e+": No data provided. Pass a non-empty array to the data prop.";if(!Array.isArray(t)&&"object"==typeof t)return e+": data should be an array, but received an object. If this is hierarchical data, use TreeDiagram, Treemap, or CirclePack instead.";if(n){const o=po(t).find(e=>e&&"object"==typeof e);if(o){const t=Object.keys(o);for(const[r,i]of Object.entries(n))if(i&&"string"==typeof i&&!(i in o)){const n=yo(i,t),o=n?` Try ${r}="${n}".`:"";return`${e}: ${r} "${i}" not found in data. Available fields: ${t.join(", ")}.${o}`}}}return null}function vo({componentName:e,data:t,dataLabel:n="data"}){return null==t?`${e}: No ${n} provided. Pass a hierarchical object with children: { name: "root", children: [...] }.`:Array.isArray(t)?`${e}: ${n} should be a single root object, not an array. Expected: { name: "root", children: [...] }. If you have flat data, use LineChart, BarChart, or Scatterplot instead.`:null}function bo({componentName:e,nodes:t,edges:n,nodesRequired:o=!1,edgesRequired:r=!0,accessors:i}){if(null==t&&null==n)return null;if(r&&(!n||!Array.isArray(n)||0===n.length))return e+': No edges provided. Pass a non-empty array: edges={[{ source: "A", target: "B", value: 10 }, ...]}.';if(o&&(!t||!Array.isArray(t)||0===t.length))return e+': No nodes provided. Pass a non-empty array: nodes={[{ id: "A" }, { id: "B" }, ...]}.';if(i&&t&&t.length>0){const n=po(t).find(e=>e&&"object"==typeof e);if(n){const t=Object.keys(n);for(const[o,r]of Object.entries(i))if(r&&"string"==typeof r&&!(r in n)){const n=yo(r,t),i=n?` Try ${o}="${n}".`:"";return`${e}: ${o} "${r}" not found in node data. Available fields: ${t.join(", ")}.${i}`}}}return null}const xo={width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},frameProps:{type:"object"},onClick:{type:"function"}},ko={xLabel:{type:"string"},yLabel:{type:"string"},xFormat:{type:"function"},yFormat:{type:"function"}},wo={categoryLabel:{type:"string"},valueLabel:{type:"string"},valueFormat:{type:"function"},categoryFormat:{type:"function"}},Ao=["linear","monotoneX","monotoneY","step","stepAfter","stepBefore","basis","cardinal","catmullRom"],So=["vertical","horizontal"],Oo={LineChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},xo),ko),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},lineBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:Ao},lineWidth:{type:"number"},showPoints:{type:"boolean"},pointRadius:{type:"number"},fillArea:{type:"boolean"},areaOpacity:{type:"number"}})},AreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},xo),ko),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:Ao},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"}})},StackedAreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},xo),ko),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:Ao},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"},normalize:{type:"boolean"}})},Scatterplot:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},xo),ko),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"}})},BubbleChart:{required:["data","sizeBy"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},xo),ko),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},bubbleOpacity:{type:"number"},bubbleStrokeWidth:{type:"number"},bubbleStrokeColor:{type:"string"}})},Heatmap:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},xo),ko),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},colorScheme:{type:"string",enum:["blues","reds","greens","viridis","custom"]},customColorScale:{type:["object","function"]},showValues:{type:"boolean"},valueFormat:{type:"function"},cellBorderColor:{type:"string"},cellBorderWidth:{type:"number"},showLegend:{type:"boolean"},legendPosition:{type:"string",enum:["right","left","top","bottom"]}})},QuadrantChart:{required:["quadrants"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},xo),ko),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},quadrants:{type:"object"},xCenter:{type:"number"},yCenter:{type:"number"},centerlineStyle:{type:"object"},showQuadrantLabels:{type:"boolean"},quadrantLabelSize:{type:"number"},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"}})},MultiAxisLineChart:{required:["series"],dataShape:"array",dataAccessors:["xAccessor"],props:Object.assign(Object.assign(Object.assign({},xo),ko),{data:{type:"array"},xAccessor:{type:["string","function"]},series:{type:"array"},colorScheme:{type:["string","array"]},curve:{type:"string"},lineWidth:{type:"number"},annotations:{type:"array"}})},ConnectedScatterplot:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},xo),ko),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},orderAccessor:{type:["string","function"]},orderLabel:{type:"string"},pointRadius:{type:"number"},pointIdAccessor:{type:["string","function"]},annotations:{type:"array"}})},BarChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},xo),wo),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:So},sort:{type:["boolean","string","function"]},barPadding:{type:"number"},roundedTop:{type:"number"}})},StackedBarChart:{required:["data","stackBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},xo),wo),{data:{type:"array"},categoryAccessor:{type:["string","function"]},stackBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:So},normalize:{type:"boolean"},sort:{type:["boolean","string","function"]},barPadding:{type:"number"},roundedTop:{type:"number"}})},LikertChart:{required:["levels"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor","levelAccessor","countAccessor"],props:Object.assign(Object.assign(Object.assign({},xo),wo),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},levelAccessor:{type:["string","function"]},countAccessor:{type:["string","function"]},levels:{type:"array"},orientation:{type:"string",enum:So},barPadding:{type:"number"}})},GroupedBarChart:{required:["data","groupBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},xo),wo),{data:{type:"array"},categoryAccessor:{type:["string","function"]},groupBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:So},sort:{type:["boolean","string","function"]},barPadding:{type:"number"},roundedTop:{type:"number"}})},SwarmPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},xo),wo),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:So},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"},categoryPadding:{type:"number"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}})},BoxPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},xo),wo),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:So},showOutliers:{type:"boolean"},outlierRadius:{type:"number"},categoryPadding:{type:"number"}})},Histogram:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},xo),wo),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},bins:{type:"number"},relative:{type:"boolean"},categoryPadding:{type:"number"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}})},ViolinPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},xo),wo),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:So},bins:{type:"number"},curve:{type:"string"},showIQR:{type:"boolean"},categoryPadding:{type:"number"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}})},RidgelinePlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},xo),wo),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},bins:{type:"number"},amplitude:{type:"number"},categoryPadding:{type:"number"}})},DotPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},xo),wo),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:So},sort:{type:["boolean","string","function"]},dotRadius:{type:"number"},categoryPadding:{type:"number"}})},PieChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},xo),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},startAngle:{type:"number"},cornerRadius:{type:"number"}})},DonutChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},xo),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},innerRadius:{type:"number"},centerContent:{type:["object","string","number"]},startAngle:{type:"number"},cornerRadius:{type:"number"}})},GaugeChart:{required:["value"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},xo),{value:{type:"number"},min:{type:"number"},max:{type:"number"},thresholds:{type:"array"},arcWidth:{type:"number"},sweep:{type:"number"},showNeedle:{type:"boolean"},needleColor:{type:"string"},centerContent:{type:["object","string","number","function"]},valueFormat:{type:"function"},showScaleLabels:{type:"boolean"},backgroundColor:{type:"string"}})},FunnelChart:{required:["data"],dataShape:"array",dataAccessors:["stepAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},xo),wo),{data:{type:"array"},stepAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},orientation:{type:"string",enum:["horizontal","vertical"]},connectorOpacity:{type:"number"},showCategoryTicks:{type:"boolean"},responsiveWidth:{type:"boolean"},legendPosition:{type:"string",enum:["right","left","top","bottom"]}})},SwimlaneChart:{required:["subcategoryAccessor"],dataShape:"array",dataAccessors:["categoryAccessor","subcategoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},xo),wo),{data:{type:"array"},categoryAccessor:{type:["string","function"]},subcategoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:["horizontal","vertical"]},barPadding:{type:"number"},showCategoryTicks:{type:"boolean"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]},responsiveWidth:{type:"boolean"},legendPosition:{type:"string",enum:["right","left","top","bottom"]}})},ForceDirectedGraph:{required:["nodes","edges"],dataShape:"network",dataAccessors:["nodeIDAccessor","sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},xo),{nodes:{type:"array"},edges:{type:"array"},nodeIDAccessor:{type:["string","function"]},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},nodeLabel:{type:["string","function"]},nodeSize:{type:["number","string","function"]},nodeSizeRange:{type:"array"},edgeWidth:{type:["number","string","function"]},edgeColor:{type:"string"},edgeOpacity:{type:"number"},iterations:{type:"number"},forceStrength:{type:"number"},showLabels:{type:"boolean"}})},SankeyDiagram:{required:["edges"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},xo),{nodes:{type:"array"},edges:{type:"array"},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},edgeColorBy:{type:["string","function"],enum:["source","target","gradient"]},orientation:{type:"string",enum:So},nodeAlign:{type:"string",enum:["justify","left","right","center"]},nodePaddingRatio:{type:"number"},nodeWidth:{type:"number"},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},edgeOpacity:{type:"number"},edgeSort:{type:"function"}})},ChordDiagram:{required:["edges"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},xo),{nodes:{type:"array"},edges:{type:"array"},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},edgeColorBy:{type:["string","function"],enum:["source","target"]},padAngle:{type:"number"},groupWidth:{type:"number"},sortGroups:{type:"function"},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},edgeOpacity:{type:"number"}})},TreeDiagram:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},xo),{data:{type:"object"},layout:{type:"string",enum:["tree","cluster","partition","treemap","circlepack"]},orientation:{type:"string",enum:["vertical","horizontal","radial"]},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},edgeStyle:{type:"string",enum:["line","curve"]},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},nodeSize:{type:"number"}})},Treemap:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},xo),{data:{type:"object"},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},showLabels:{type:"boolean"},nodeLabel:{type:["string","function"]}})},CirclePack:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},xo),{data:{type:"object"},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},showLabels:{type:"boolean"},nodeLabel:{type:["string","function"]},circleOpacity:{type:"number"}})},OrbitDiagram:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},xo),{data:{type:"object"},childrenAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},orbitMode:{type:["string","array"]},speed:{type:"number"},revolution:{type:"function"},eccentricity:{type:["number","function"]},orbitSize:{type:["number","function"]},nodeRadius:{type:["number","function"]},showRings:{type:"boolean"},showLabels:{type:"boolean"},animated:{type:"boolean"},colorByDepth:{type:"boolean"},annotations:{type:"array"},foregroundGraphics:{type:"object"}})},RealtimeLineChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},stroke:{type:"string"},strokeWidth:{type:"number"},strokeDasharray:{type:"string"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeHistogram:{required:["binSize"],dataShape:"realtime",dataAccessors:[],props:{binSize:{type:"number"},size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},colors:{type:"object"},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},fill:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},gap:{type:"number"},brush:{type:["boolean","string","object"]},onBrush:{type:"function"},linkedBrush:{type:["string","object"]},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeSwarmChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},colors:{type:"object"},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},radius:{type:"number"},fill:{type:"string"},opacity:{type:"number"},stroke:{type:"string"},strokeWidth:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeWaterfallChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},positiveColor:{type:"string"},negativeColor:{type:"string"},connectorStroke:{type:"string"},connectorWidth:{type:"number"},gap:{type:"number"},stroke:{type:"string"},strokeWidth:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeHeatmap:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},heatmapXBins:{type:"number"},heatmapYBins:{type:"number"},aggregation:{type:"string",enum:["count","sum","mean"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"}}},ScatterplotMatrix:{required:["data","fields"],dataShape:"array",dataAccessors:[],props:Object.assign(Object.assign({},xo),{data:{type:"array"},fields:{type:"array"}})},MinimapChart:{required:["data"],dataShape:"array",dataAccessors:[],props:Object.assign(Object.assign({},xo),{data:{type:"array"}})},ChoroplethMap:{required:["areas"],dataShape:"array",dataAccessors:["valueAccessor"],props:Object.assign(Object.assign({},xo),{areas:{type:["array","string"]},valueAccessor:{type:["string","function"]},colorScheme:{type:["string","array"]},projection:{type:"string"}})},ProportionalSymbolMap:{required:["points"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign({},xo),{points:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},areas:{type:["array","string"]}})},FlowMap:{required:["flows"],dataShape:"array",dataAccessors:[],props:Object.assign(Object.assign({},xo),{flows:{type:"array"},nodes:{type:"array"},valueAccessor:{type:["string","function"]}})},DistanceCartogram:{required:["points"],dataShape:"array",dataAccessors:[],props:Object.assign(Object.assign({},xo),{points:{type:"array"},center:{type:"array"},costAccessor:{type:["string","function"]}})}};function Eo(e,t){return(Array.isArray(t)?t:[t]).includes(Array.isArray(e)?"array":typeof e)}function Mo(e,t){const n=[],o=Oo[e];if(!o)return{valid:!1,errors:[`Unknown component "${e}". Valid components: ${Object.keys(Oo).join(", ")}`]};for(const r of o.required)null==t[r]&&n.push(`"${r}" is required for ${e}.`);for(const[e,r]of Object.entries(t)){if(null==r)continue;const t=o.props[e];if(t){if(!Eo(r,t.type)){const o=Array.isArray(t.type)?t.type.join(" | "):t.type;n.push(`"${e}" should be ${o}, got ${Array.isArray(r)?"array":typeof r}.`);continue}t.enum&&"string"==typeof r&&!t.enum.includes(r)&&n.push(`"${e}" value "${r}" is not valid. Expected one of: ${t.enum.join(", ")}.`)}}const r=Object.keys(o.props),i=new Set(r);for(const o of Object.keys(t))if(void 0!==t[o]&&!i.has(o)){const t=fo(o,r),i=t?`Unknown prop "${o}" for ${e}. Did you mean "${t}"?`:`Unknown prop "${o}" for ${e}. Valid props: ${r.join(", ")}.`;n.push(i)}if("array"===o.dataShape){const r=t.data,i={};for(const e of o.dataAccessors){const n=t[e];"string"==typeof n&&(i[e]=n)}const a=mo({componentName:e,data:r,accessors:Object.keys(i).length>0?i:void 0});a&&n.push(a)}else if("object"===o.dataShape){const o=vo({componentName:e,data:t.data});o&&n.push(o)}else if("network"===o.dataShape){const r=bo({componentName:e,nodes:t.nodes,edges:t.edges,nodesRequired:o.required.includes("nodes"),edgesRequired:o.required.includes("edges")});r&&n.push(r)}return{valid:0===n.length,errors:n}}const jo=new Set(["TreeDiagram","Treemap","CirclePack","OrbitDiagram"]),Co=new Set(["ForceDirectedGraph","SankeyDiagram","ChordDiagram"]),Po=new Set(["BarChart","StackedBarChart","GroupedBarChart","AreaChart","StackedAreaChart"]),Lo=new Set(["LineChart","AreaChart","StackedAreaChart"]),_o=new Set(["BarChart","StackedBarChart","GroupedBarChart","FunnelChart"]);function To(e){const t=e.match(/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i);if(!t)return null;const[n,o,r]=[parseInt(t[1],16)/255,parseInt(t[2],16)/255,parseInt(t[3],16)/255],i=e=>e>.03928?Math.pow((e+.055)/1.055,2.4):e/12.92;return.2126*i(n)+.7152*i(o)+.0722*i(r)}function Bo(e,t){const n=To(e),o=To(t);return null===n||null===o?null:(Math.max(n,o)+.05)/(Math.min(n,o)+.05)}const No=["xAccessor","yAccessor","timeAccessor","valueAccessor","categoryAccessor","colorBy","sizeBy","lineBy","areaBy","stackBy","groupBy","orderAccessor","y0Accessor","sourceAccessor","targetAccessor","nodeIDAccessor","childrenAccessor","costAccessor"];function Do(e,t){const n=[],o=Mo(e,t);for(const e of o.errors)n.push({severity:"error",code:"VALIDATION",message:e,fix:""});return Oo[e]?(function(e,t,n){const o=Oo[e];if(o){if("array"===o.dataShape){const e=t.data;e&&Array.isArray(e)&&0===e.length&&n.push({severity:"error",code:"EMPTY_DATA",message:"data is an empty array — chart will render blank.",fix:"Provide at least one data point: data={[{ x: 1, y: 2 }]}."})}"network"===o.dataShape&&t.edges&&Array.isArray(t.edges)&&0===t.edges.length&&n.push({severity:"error",code:"EMPTY_EDGES",message:"edges is an empty array — network chart will render blank.",fix:'Provide at least one edge: edges={[{ source: "A", target: "B" }]}.'})}}(e,t,n),function(e,t,n){const o=t.width,r=t.height;if(void 0===o||"number"==typeof o&&o>0||n.push({severity:"error",code:"BAD_WIDTH",message:`width=${JSON.stringify(o)} — chart needs a positive number.`,fix:"Set width={600} or use responsiveWidth={true}."}),void 0===r||"number"==typeof r&&r>0||n.push({severity:"error",code:"BAD_HEIGHT",message:`height=${JSON.stringify(r)} — chart needs a positive number.`,fix:"Set height={400} or use responsiveHeight={true}."}),t.size&&Array.isArray(t.size)){const[e,o]=t.size;(null!=e&&0>=e||null!=o&&0>=o)&&n.push({severity:"error",code:"BAD_SIZE",message:`size=[${e}, ${o}] — both dimensions must be positive.`,fix:"Set size={[600, 400]}."})}}(0,t,n),function(e,t,n){const o=Oo[e];if(!o||"array"!==o.dataShape)return;const r=t.data;if(!r||!Array.isArray(r)||0===r.length)return;const i=r[0];if(!i||"object"!=typeof i)return;const a=Object.keys(i);for(const e of o.dataAccessors){const o=t[e];"string"==typeof o&&(o in i||n.push({severity:"error",code:"ACCESSOR_MISSING",message:`${e}="${o}" not found in data. Available fields: ${a.join(", ")}.`,fix:`Change ${e} to one of: ${a.map(e=>`"${e}"`).join(", ")}.`}))}}(e,t,n),function(e,t,n){jo.has(e)&&Array.isArray(t.data)&&n.push({severity:"error",code:"HIERARCHY_FLAT_ARRAY",message:e+" expects hierarchical data but received a flat array.",fix:'Pass a root object: data={{ name: "root", children: [...] }}. For flat data, use BarChart or LineChart.'})}(e,t,n),function(e,t,n){Co.has(e)&&(t.edges||t.data||n.push({severity:"error",code:"NETWORK_NO_EDGES",message:e+" requires an edges prop.",fix:'Provide edges={[{ source: "A", target: "B", value: 10 }]}.'}))}(e,t,n),function(e,t,n){const o=Oo[e];if(!o||"array"!==o.dataShape)return;const r=t.data;if(!r||!Array.isArray(r)||0===r.length)return;const i=r[0];if(!i||"object"!=typeof i)return;const a=t.xAccessor;"string"==typeof a&&i[a]instanceof Date&&!t.xFormat&&n.push({severity:"warning",code:"DATE_NO_FORMAT",message:`xAccessor "${a}" contains Date objects but no xFormat is provided. Axis ticks may display "[object Object]".`,fix:"Add xFormat={d => d.toLocaleDateString()} or use timestamps (d.getTime()) instead of Date objects."})}(e,t,n),function(e,t,n){t.linkedHover&&!t.selection&&n.push({severity:"warning",code:"LINKED_HOVER_NO_SELECTION",message:"linkedHover is set but selection is not — this chart emits hover events but won't highlight from others.",fix:`Add selection={{ name: "${"object"==typeof t.linkedHover&&t.linkedHover.name||"hl"}" }} to receive cross-highlights.`})}(0,t,n),function(e,t,n){var o;if(!Po.has(e))return;const r=t.rExtent||t.yExtent;r&&Array.isArray(r)&&r.length>=1&&null!=r[0]&&0!==r[0]&&n.push({severity:"warning",code:"NON_ZERO_BASELINE",message:`${e} has a non-zero baseline (${r[0]}). Bar and area charts should start at zero to avoid exaggerating differences.`,fix:`Remove the custom extent minimum or set it to 0: rExtent={[0, ${null!==(o=r[1])&&void 0!==o?o:"auto"}]}. For trend-focused charts, use LineChart instead.`})}(e,t,n),function(e,t,n){if(!Lo.has(e))return;if(t.gapStrategy)return;const o=t.data;if(!o||!Array.isArray(o)||0===o.length)return;const r=t.yAccessor||"y";"string"==typeof r&&o.some(e=>{const t=e[r];return null==t||Number.isNaN(t)})&&n.push({severity:"warning",code:"DATA_GAPS",message:`Data contains null/undefined/NaN values in "${r}". Default behavior breaks the line at gaps.`,fix:'Set gapStrategy="break" (default), "interpolate", or "zero" to control gap handling.'})}(e,t,n),function(e,t,n){var o,r;const i=null!==(o=t.width)&&void 0!==o?o:600,a=null!==(r=t.height)&&void 0!==r?r:400,s=t.margin;if(!s||"object"!=typeof s)return;const l=(s.left||0)+(s.right||0),c=(s.top||0)+(s.bottom||0);i>l||n.push({severity:"error",code:"MARGIN_OVERFLOW_H",message:`Horizontal margins (${l}px) >= width (${i}px) — no drawing area left.`,fix:"Reduce margin.left/right or increase width."}),a>c||n.push({severity:"error",code:"MARGIN_OVERFLOW_V",message:`Vertical margins (${c}px) >= height (${a}px) — no drawing area left.`,fix:"Reduce margin.top/bottom or increase height."})}(0,t,n),function(e,t,n){var o;const r=Oo[e];if(!r||"array"!==r.dataShape)return;const i=t.data;if(!i||!Array.isArray(i)||0===i.length)return;const a=[];t.xAccessor&&"string"==typeof t.xAccessor&&a.push({prop:"xAccessor",name:t.xAccessor}),t.yAccessor&&"string"==typeof t.yAccessor&&a.push({prop:"yAccessor",name:t.yAccessor}),t.valueAccessor&&"string"==typeof t.valueAccessor&&a.push({prop:"valueAccessor",name:t.valueAccessor});const s=Math.min(i.length,5);for(const e of a){let t=!0;for(let n=0;s>n;n++){const r=null===(o=i[n])||void 0===o?void 0:o[e.name];if("number"==typeof r&&Number.isFinite(r)){t=!1;break}}t&&n.push({severity:"error",code:"DEGENERATE_EXTENT",message:`${e.prop}="${e.name}" produces NaN or non-finite values for all sampled data points — chart extents will be invalid.`,fix:`Ensure data[].${e.name} contains finite numbers, or use a function accessor to transform values.`})}}(e,t,n),function(e,t,n){if(!_o.has(e))return;const o=t.barPadding;"number"==typeof o&&10>o&&n.push({severity:"warning",code:"BAR_PADDING_INVISIBLE",message:`barPadding=${o} is very small — bars may appear to have no spacing between them.`,fix:"Increase barPadding to at least 10 for visible gaps, e.g. barPadding={12}."})}(e,t,n),function(e,t,n){if("bottom"!==t.legendPosition)return;const o=t.margin;if(!o||"object"!=typeof o)return;const r=o.bottom;"number"==typeof r&&70>r&&n.push({severity:"warning",code:"BOTTOM_MARGIN_WITH_LEGEND",message:`legendPosition="bottom" with margin.bottom=${r}px — legend may overlap axis labels.`,fix:"Increase margin.bottom to at least 70, e.g. margin={{ ...margin, bottom: 80 }}."})}(0,t,n),function(e,t,n){var o;if(!t.showLegend)return;if("right"!==(null!==(o=t.legendPosition)&&void 0!==o?o:"right"))return;const r=t.margin;if(!r||"object"!=typeof r)return;const i=r.right;"number"==typeof i&&100>i&&n.push({severity:"warning",code:"LEGEND_MARGIN_TIGHT",message:`showLegend is true with legendPosition="right" but margin.right=${i}px — legend may be clipped or overlap the chart.`,fix:"Increase margin.right to at least 100, e.g. margin={{ ...margin, right: 120 }}."})}(0,t,n),function(e,t,n){if("Heatmap"!==e)return;const o=t.data;if(!o||!Array.isArray(o)||0===o.length)return;const r=o[0];if(r&&"object"==typeof r)for(const e of["xAccessor","yAccessor"]){const o=t[e];if("string"!=typeof o)continue;const i=r[o];"string"==typeof i&&n.push({severity:"warning",code:"HEATMAP_STRING_ACCESSOR",message:`${e}="${o}" resolves to string values (e.g. "${i}"). Heatmap will use categorical axis handling which may produce unexpected cell layout.`,fix:"If you intend categorical axes this is fine. Otherwise, convert values to numbers before passing data."})}}(e,t,n),function(e,t,n){const o=t.colorScheme;if(!o||!Array.isArray(o))return;const r="string"==typeof t.background?t.background:"#ffffff";if(!r.startsWith("#"))return;const i=[];for(const e of o){if("string"!=typeof e||!e.startsWith("#"))continue;const t=Bo(e,r);null!==t&&3>t&&i.push(`${e} (${t.toFixed(1)}:1)`)}i.length>0&&n.push({severity:"warning",code:"LOW_COLOR_CONTRAST",message:`${i.length} color(s) in colorScheme have < 3:1 contrast against background "${r}": ${i.join(", ")}. Data marks may be hard to see.`,fix:'Use darker colors on light backgrounds or lighter colors on dark backgrounds. Import COLOR_BLIND_SAFE_CATEGORICAL from "semiotic" for an accessible preset.'})}(0,t,n),function(e,t,n){const o=t.colorScheme;if(!o||!Array.isArray(o)||2>o.length)return;const r=o.filter(e=>"string"==typeof e&&e.startsWith("#"));if(2>r.length)return;const i=[];for(let e=0;r.length-1>e;e++){const t=Bo(r[e],r[e+1]);null!==t&&1.5>t&&i.push(`${r[e]} / ${r[e+1]} (${t.toFixed(1)}:1)`)}i.length>0&&n.push({severity:"warning",code:"LOW_ADJACENT_CONTRAST",message:`${i.length} adjacent color pair(s) in colorScheme have very similar luminance: ${i.join("; ")}. Categories may be hard to distinguish.`,fix:'Alternate light and dark colors in the scheme, or use COLOR_BLIND_SAFE_CATEGORICAL from "semiotic" for a pre-tested palette.'})}(0,t,n),function(e,t,n){const o="string"==typeof t.title&&t.title.trim().length>0,r="string"==typeof t.description&&t.description.trim().length>0,i="string"==typeof t.summary&&t.summary.trim().length>0;o||r||i||n.push({severity:"warning",code:"MISSING_DESCRIPTION",message:'No title, description, or summary provided. Screen readers will use a generic label like "XY chart".',fix:'Add a title="..." prop for a brief label, or description="..." for a detailed aria-label, or summary="..." for a screen-reader-only note describing the chart\'s purpose.'})}(0,t,n),function(e,t,n){const o=[];for(const e of No)"function"==typeof t[e]&&o.push(e);o.length>0&&n.push({severity:"warning",code:"FUNCTION_ACCESSOR",message:`Function accessor${o.length>1?"s":""} detected: ${o.join(", ")}. If defined inline (e.g. \`xAccessor={d => d.value}\`), every parent re-render creates a new reference which may trigger unnecessary scene rebuilds.`,fix:'Use string accessors when possible (e.g. xAccessor="value"), or memoize with useCallback / define outside the component.'})}(0,t,n),{ok:n.every(e=>"warning"===e.severity),diagnoses:n}):{ok:0===n.length,diagnoses:n}}var Io;const Ro="undefined"!=typeof process&&"production"!==(null===(Io=process.env)||void 0===Io?void 0:Io.NODE_ENV);function Ho({componentName:e,width:t,height:n,chartProps:o,children:r}){return p.createElement(ho,{fallback:r=>{let i="";if(Ro&&o)try{const t=Do(e,o);t.ok||(i=t.diagnoses.map(e=>`${"error"===e.severity?"✗":"⚠"} ${e.message}${e.fix?" — Fix: "+e.fix:""}`).join("\n"))}catch(e){}return p.createElement(uo,{componentName:e,message:r.message,diagnosticHint:i,width:t,height:n})}},r)}const Wo={display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #999)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"},Fo={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function $o(e,t,n,o){return!1===o||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?p.createElement("div",{style:Object.assign(Object.assign({},Wo),{width:t,height:n})},o||"No data available"):null}function zo(e,t,n){if(!e)return null;const o=Math.min(5,Math.floor(n/40)),r=Math.max(8,Math.floor(n/(3*o))),i=Math.max(6,Math.floor(n/(2.5*o))),a=Math.floor((n-(o*(r+i)-i))/2);return p.createElement("div",{style:{width:t,height:n,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"}},Array.from({length:o},(e,n)=>p.createElement("div",{key:n,className:"semiotic-loading-bar",style:Object.assign(Object.assign({},Fo),{position:"absolute",top:a+n*(r+i),left:Math.floor(.1*t),width:30+(37*n+13)%50+"%",height:r,opacity:.5+n%2*.2})})))}function Go(e,t,n,o){if(!Ro)return;if(!t||0===t.length)return;if("string"!=typeof o)return;const r=t[0];if(!r||"object"!=typeof r)return;if(o in r)return;const i=Object.keys(r).join(", ");console.warn(`[semiotic] ${e}: ${n} "${o}" not found in data. Available keys: ${i}`)}function qo(e,t,n,o){return new(n||(n=Promise))(function(r,i){function a(e){try{l(o.next(e))}catch(e){i(e)}}function s(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){e.done?r(e.value):function(e){return e instanceof n?e:new n(function(t){t(e)})}(e.value).then(a,s)}l((o=o.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const Yo="__forecastSegment";let Xo=null;function Vo(){return qo(this,void 0,void 0,function*(){return Xo||(Xo=yield Promise.resolve().then(function(){return Zs})),Xo})}const Uo=e.forwardRef(function(t,n){var o,r;const i=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=i.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=i.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;return null===(e=i.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=i.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const a=Zn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,description:t.description,summary:t.summary,accessibleTable:t.accessibleTable,xLabel:t.xLabel,yLabel:t.yLabel}),{data:s,margin:l,className:c,xFormat:u,yFormat:d,xAccessor:h="x",yAccessor:g="y",lineBy:f,lineDataAccessor:y="coordinates",colorBy:m,colorScheme:v,curve:b="linear",showPoints:x=!1,pointRadius:k=3,fillArea:w=!1,areaOpacity:A=.3,lineWidth:S=2,lineGradient:O,tooltip:E,pointIdAccessor:M,annotations:j,directLabel:C,gapStrategy:P="break",anomaly:L,forecast:_,frameProps:B={},selection:N,linkedHover:D,onObservation:I,onClick:R,hoverHighlight:H,hoverRadius:W,chartId:F,loading:$,emptyContent:z,legendInteraction:G,legendPosition:q,xScaleType:Y,yScaleType:X,color:V}=t,U=a.width,K=a.height,Q=a.enableHover,Z=a.showGrid,J=a.showLegend,ee=a.title,te=a.description,ne=a.summary,oe=a.accessibleTable,re=a.xLabel,ie=a.yLabel,ae=zo($,U,K),se=ae?null:$o(s,U,K,z),le=s||[];Go("LineChart",le,"xAccessor",h),Go("LineChart",le,"yAccessor",g);const ce="string"==typeof h?h:"__semiotic_resolvedX",ue="string"==typeof g?g:"__semiotic_resolvedY",[de,he]=e.useState(null),[ge,fe]=e.useState([]),pe=e.useMemo(()=>{if(!_&&!L)return le;const e="function"==typeof h,t="function"==typeof g;return e||t?le.map(n=>{const o=Object.assign({},n);return e&&(o.__semiotic_resolvedX=h(n)),t&&(o.__semiotic_resolvedY=g(n)),o}):le},[le,_,L,h,g]),ye=e.useRef(_),me=e.useRef(L);e.useEffect(()=>{if(!_&&!L)return void((ye.current||me.current)&&(he(null),fe([]),ye.current=_,me.current=L));let e=!1;const t=_!==ye.current||L!==me.current;if(ye.current=_,me.current=L,t&&(he(null),fe([])),_){const t=f&&"string"==typeof f&&"object"==typeof _?Object.assign(Object.assign({},_),{_groupBy:f}):_;(function(...e){return qo(this,void 0,void 0,function*(){return(yield Vo()).buildForecast(...e)})})(pe,ce,ue,t,L).then(t=>{e||(he(t),fe(t.annotations))}).catch(()=>{e||(he(null),fe([]))})}else L&&function(...e){return qo(this,void 0,void 0,function*(){return(yield Vo()).buildAnomalyAnnotations(...e)})}(L).then(t=>{e||(he(null),fe(t))}).catch(()=>{e||fe([])});return()=>{e=!0}},[pe,_,L,ce,ue]);const ve=de?de.processedData:le,be="__compoundGroup",xe=!(!_||!f),ke=xe?be:_?Yo:f,we=e.useMemo(()=>{if(!xe)return ve;const e="function"==typeof f?f:e=>e[f];return ve.map(t=>{const n=Object.assign({},t);return n[be]=`${e(t)}__${t[Yo]||"observed"}`,n})},[ve,xe,f]),Ae=xe?we:ve,Se=e.useMemo(()=>{if(!_)return;const e=_.upperBounds,t=_.lowerBounds;if(!e&&!t)return;const n="function"==typeof e?e:"string"==typeof e?t=>t[e]:null,o="function"==typeof t?t:"string"==typeof t?e=>e[t]:null;let r=1/0,i=-1/0;const a=de?de.processedData:le;for(const e of a){const t="function"==typeof g?g(e):+e[g];if(isFinite(t)&&(r>t&&(r=t),t>i&&(i=t)),n){const t=n(e);null!=t&&isFinite(t)&&(t>i&&(i=t),r>t&&(r=t))}if(o){const t=o(e);null!=t&&isFinite(t)&&(r>t&&(r=t),t>i&&(i=t))}}return isFinite(r)&&isFinite(i)?[r,i]:void 0},[_,de,le,g]),{activeSelectionHook:Oe,hoverSelectionHook:Ee,customHoverBehavior:Me,customClickBehavior:je,crosshairSourceId:Ce}=Xn({selection:N,linkedHover:D,fallbackFields:m?["string"==typeof m?m:""]:[],onObservation:I,onClick:R,chartType:"LineChart",chartId:F,hoverHighlight:H,colorByField:"string"==typeof m?m:void 0}),Pe=Vn(D,Ce),Le=e.useCallback(e=>{const t="function"==typeof h?h(e):e[h],n="function"==typeof g?g(e):e[g];return null==t||null==n||Number.isNaN(t)||Number.isNaN(n)},[h,g]),_e=void 0!==(null===(o=Ae[0])||void 0===o?void 0:o[y]),Te=e.useMemo(()=>{if(_e)return Ae;if(ke){const e=Ae.reduce((e,t)=>{const n="function"==typeof ke?ke(t):t[ke];if(!e[n]){const o={[y]:[]};"string"==typeof ke&&(o[ke]=n),xe&&(o[Yo]=t[Yo],"string"==typeof f&&(o[f]=t[f])),e[n]=o}return e[n][y].push(t),e},{});return Object.values(e)}return[{[y]:Ae}]},[Ae,ke,y,_e]),{gapProcessedLineData:Be,hasGaps:Ne}=e.useMemo(()=>{if("interpolate"===P){let e=!1;const t=[];for(const n of Te){const o=(n[y]||[]).filter(t=>!Le(t)||(e=!0,!1));o.length>0&&t.push(Object.assign(Object.assign({},n),{[y]:o}))}return{gapProcessedLineData:t,hasGaps:e}}if("break"===P){let e=!1;const t=[];for(const n of Te){const o=n[y]||[];let r=[],i=0;const a=ke&&"string"==typeof ke?n[ke]:void 0;for(const s of o)if(Le(s))e=!0,r.length>0&&(t.push(Object.assign(Object.assign({},n),{[y]:r})),r=[],i++);else{const e=null!=a?`${a}__seg${i}`:"__seg"+i;r.push(Object.assign(Object.assign({},s),{_gapSegment:e}))}r.length>0&&t.push(Object.assign(Object.assign({},n),{[y]:r}))}return{gapProcessedLineData:t,hasGaps:e}}if("zero"===P){let e=!1;const t="string"==typeof g?g:"y",n=[];for(const o of Te){const r=o[y]||[],i=[];for(const n of r)Le(n)?(e=!0,i.push(Object.assign(Object.assign({},n),{[t]:0}))):i.push(n);n.push(Object.assign(Object.assign({},o),{[y]:i}))}return{gapProcessedLineData:n,hasGaps:e}}return{gapProcessedLineData:Te,hasGaps:!1}},[Te,P,y,Le,ke,g]),De=qn(ve,m,v),Ie=e.useMemo(()=>{if(!m)return[];const e=new Set;for(const t of ve){const n="function"==typeof m?m(t):t[m];null!=n&&e.add(n+"")}return Array.from(e)},[ve,m]),Re=Kn(G,m,Ie),He=e.useMemo(()=>Ee||(Re.legendSelectionHook?Re.legendSelectionHook:Oe),[Ee,Re.legendSelectionHook,Oe]),We=e.useMemo(()=>(e,t)=>{const n={strokeWidth:S},o=!0===w||Array.isArray(w)&&null!=t&&w.includes(t);return m?De&&(n.stroke=T(e,m,De),o&&(n.fill=n.stroke,n.fillOpacity=A)):(n.stroke=V||Fn,o&&(n.fill=V||Fn,n.fillOpacity=A)),n},[m,De,S,w,A,V]),[Fe,$e]=e.useState(null);e.useEffect(()=>{if(!_)return void $e(null);let e=!1;return function(...e){return qo(this,void 0,void 0,function*(){return(yield Vo()).createSegmentLineStyle(...e)})}(We,_).then(t=>{e||$e(()=>t)}).catch(()=>{e||$e(null)}),()=>{e=!0}},[We,_]);const ze=Fe||We,Ge=e.useMemo(()=>Bn(ze,He,N),[ze,He,N]),qe=e.useMemo(()=>{if(x)return e=>{const t={r:k,fillOpacity:1};return m?De&&(t.fill=T(e.parentLine||e,m,De)):t.fill=V||Fn,t}},[x,k,m,De,V]),Ye=Array.isArray(w)?"mixed":w?"area":"line",Xe="object"==typeof C?C:{},Ve=Xe.position||"end",Ue=Xe.fontSize||11,Ke=e.useMemo(()=>{var e,t;if(!C||!m)return[];const n="function"==typeof h?h:e=>e[h],o="function"==typeof g?g:e=>e[g],r="function"==typeof m?m:e=>e[m],i=new Map;for(const n of Be){const o=n[y]||[];if(0===o.length)continue;const a="end"===Ve?o[o.length-1]:o[0],s=null!==(t=null!==(e=r(a))&&void 0!==e?e:r(n))&&void 0!==t?t:"";s&&!i.has(s+"")&&i.set(s+"",a)}const a=Array.from(i.entries()).map(([e,t])=>({type:"text",label:e,["string"==typeof h?h:"x"]:n(t),["string"==typeof g?g:"y"]:o(t),dx:"end"===Ve?6:-6,dy:0,color:De?De(e):Fn,fontSize:Ue}));a.sort((e,t)=>{const n="string"==typeof g?g:"y";return e[n]-t[n]});for(let e=1;a.length>e;e++){const t="string"==typeof g?g:"y",n=a[e-1],o=a[e];Ue+2>Math.abs(o[t]+o.dy-(n[t]+n.dy))&&(o.dy+=Ue+2)}return a},[C,m,De,Be,y,h,g,Ve,Ue]),Qe=(!C||void 0!==J)&&J,Ze=e.useMemo(()=>{if(!C)return a.marginDefaults;const e=Ke.reduce((e,t)=>{var n;const o=((null===(n=t.label)||void 0===n?void 0:n.length)||0)*(.6*Ue);return Math.max(e,o)},0),t=e+10,n="end"===Ve?"right":"left";return Object.assign(Object.assign({},a.marginDefaults),{[n]:Math.max(a.marginDefaults[n]||0,t)})},[C,Ke,Ue,Ve,a.marginDefaults]),{legend:Je,margin:et,legendPosition:tt}=Un({data:Be,colorBy:m,colorScale:De,showLegend:Qe,legendPosition:q,userMargin:l,defaults:Ze}),nt=f||m,ot=e.useMemo(()=>lo([{label:re||io(h),accessor:h,role:"x"},{label:ie||io(g),accessor:g,role:"y"},...nt?[{label:io(nt),accessor:nt,role:"group"}]:[]]),[h,g,re,ie,nt]),rt=mo({componentName:"LineChart",data:_e?(null===(r=ve[0])||void 0===r?void 0:r[y])||[]:s,accessors:{xAccessor:h,yAccessor:g}}),it=e.useMemo(()=>_e||ke||Ne?Be.flatMap(e=>{const t=e[y]||[];return ke&&"string"==typeof ke?t.map(t=>Object.assign(Object.assign({},t),{[ke]:e[ke]})):t}):Ae,[Be,y,_e,ke,Ae,Ne]),at=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:Ye},Array.isArray(w)&&{areaGroups:w}),O&&{lineGradient:O}),null!=W&&{hoverRadius:W}),null!=s&&{data:it}),{xAccessor:h,yAccessor:g,xScaleType:Y,yScaleType:X}),Se&&{yExtent:Se}),{groupAccessor:"break"===P&&Ne?"_gapSegment":ke||void 0,curve:b,lineStyle:Ge}),x&&{pointStyle:qe}),{size:[U,K],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:et,showAxes:a.showAxes,xLabel:re,yLabel:ie,xFormat:u,yFormat:d,enableHover:Q,showGrid:Z}),Je&&{legend:Je,legendPosition:tt}),G&&"none"!==G&&{legendHoverBehavior:Re.onLegendHover,legendClickBehavior:Re.onLegendClick,legendHighlightedCategory:Re.highlightedCategory,legendIsolatedCategories:Re.isolatedCategories}),ee&&{title:ee}),te&&{description:te}),ne&&{summary:ne}),void 0!==oe&&{accessibleTable:oe}),c&&{className:c}),{tooltipContent:!1===E?()=>null:"multi"===E?e=>{var t,n,o,r,i,a,s,l,c,u;const d=e.allSeries;if(!d||0===d.length){const a=null!==(i=null!==(r=null!==(n=null===(t=e.data)||void 0===t?void 0:t.value)&&void 0!==n?n:null===(o=e.data)||void 0===o?void 0:o.y)&&void 0!==r?r:e.value)&&void 0!==i?i:e.y;return p.createElement("div",{className:"semiotic-tooltip",style:eo},p.createElement("div",null,no(a)))}const h=null!==(u=null!==(l=null!==(a=e.xValue)&&void 0!==a?a:null===(s=e.data)||void 0===s?void 0:s.time)&&void 0!==l?l:null===(c=e.data)||void 0===c?void 0:c.x)&&void 0!==u?u:e.time;return p.createElement("div",{className:"semiotic-tooltip",style:eo},null!=h&&p.createElement("div",{style:{fontWeight:600,marginBottom:4,fontSize:"0.9em",borderBottom:"1px solid var(--semiotic-border, #eee)",paddingBottom:4}},no(h)),d.map((e,t)=>p.createElement("div",{key:t,style:{display:"flex",alignItems:"center",gap:6,padding:"1px 0"}},p.createElement("span",{style:{width:8,height:8,borderRadius:"50%",backgroundColor:e.color,flexShrink:0}}),p.createElement("span",{style:{flex:1,fontSize:"0.85em"}},e.group),p.createElement("span",{style:{fontWeight:500,fontSize:"0.85em"}},no(e.value)))))}:ro(E)||ot}),"multi"===E&&{tooltipMode:"multi"}),(D||I||R||H)&&{customHoverBehavior:Me}),(I||R||D)&&{customClickBehavior:je}),M&&{pointIdAccessor:M}),((null==j?void 0:j.length)||ge.length||Ke.length)&&{annotations:[...j||[],...ge,...Ke]}),Pe),B);return ae||se||(rt?p.createElement(uo,{componentName:"LineChart",message:rt,width:U,height:K}):p.createElement(Ho,{componentName:"LineChart",width:U,height:K},p.createElement(gn,Object.assign({ref:i},at))))});Uo.displayName="LineChart";const Ko=e.forwardRef(function(t,n){var o;const r=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=r.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const i=Zn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:a,margin:s,className:l,xFormat:c,yFormat:u,xAccessor:d="x",yAccessor:h="y",areaBy:g,y0Accessor:f,gradientFill:y=!1,lineDataAccessor:m="coordinates",colorBy:v,colorScheme:b,curve:x="monotoneX",areaOpacity:k=.7,lineGradient:w,showLine:A=!0,lineWidth:S=2,showPoints:O=!1,pointRadius:E=3,tooltip:M,annotations:j,frameProps:C={},selection:P,linkedHover:L,onObservation:_,onClick:B,hoverHighlight:N,chartId:D,loading:I,emptyContent:R,legendInteraction:H,legendPosition:W,color:F}=t,$=i.width,z=i.height,G=i.enableHover,q=i.showGrid,Y=i.showLegend,X=i.title,V=i.description,U=i.summary,K=i.accessibleTable,Q=i.xLabel,Z=i.yLabel,J=zo(I,$,z),ee=J?null:$o(a,$,z,R),te=a||[];Go("AreaChart",te,"xAccessor",d),Go("AreaChart",te,"yAccessor",h);const{activeSelectionHook:ne,hoverSelectionHook:oe,customHoverBehavior:re,customClickBehavior:ie,crosshairSourceId:ae}=Xn({selection:P,linkedHover:L,fallbackFields:v?["string"==typeof v?v:""]:[],onObservation:_,onClick:B,chartType:"AreaChart",chartId:D,hoverHighlight:N,colorByField:"string"==typeof v?v:void 0}),se=Vn(L,ae),le=void 0!==(null===(o=te[0])||void 0===o?void 0:o[m]),ce=e.useMemo(()=>{if(le)return te;if(g){const e=te.reduce((e,t)=>{const n="function"==typeof g?g(t):t[g];if(!e[n]){const t={[m]:[]};"string"==typeof g&&(t[g]=n),e[n]=t}return e[n][m].push(t),e},{});return Object.values(e)}return[{[m]:te}]},[te,g,m,le]),ue=qn(te,v,b),de=e.useMemo(()=>{if(!v)return[];const e=new Set;for(const t of te){const n="function"==typeof v?v(t):t[v];null!=n&&e.add(n+"")}return Array.from(e)},[te,v]),he=Kn(H,v,de),ge=e.useMemo(()=>oe||(he.legendSelectionHook?he.legendSelectionHook:ne),[oe,he.legendSelectionHook,ne]),fe=e.useMemo(()=>e=>{const t={};if(v){if(ue){const n=T(e,v,ue);t.fill=n,A?(t.stroke=n,t.strokeWidth=S):t.stroke="none"}}else{const e=F||Fn;t.fill=e,A?(t.stroke=e,t.strokeWidth=S):t.stroke="none"}return t.fillOpacity=k,t},[v,ue,F,k,A,S]),pe=e.useMemo(()=>Bn(fe,ge,P),[fe,ge,P]),ye=e.useMemo(()=>{if(O)return e=>{const t={r:E,fillOpacity:1};return v?ue&&(t.fill=T(e.parentLine||e,v,ue)):t.fill=Fn,t}},[O,E,v,ue]),{legend:me,margin:ve,legendPosition:be}=Un({data:ce,colorBy:v,colorScale:ue,showLegend:Y,legendPosition:W,userMargin:s,defaults:i.marginDefaults}),xe=g||v,ke=e.useMemo(()=>lo([{label:Q||io(d),accessor:d,role:"x"},{label:Z||io(h),accessor:h,role:"y"},...xe?[{label:io(xe),accessor:xe,role:"group"}]:[]]),[d,h,Q,Z,xe]),we=mo({componentName:"AreaChart",data:a,accessors:{xAccessor:d,yAccessor:h}}),Ae=e.useMemo(()=>le||g?ce.flatMap(e=>{const t=e[m]||[];return g&&"string"==typeof g?t.map(t=>Object.assign(Object.assign({},t),{[g]:e[g]})):t}):te,[ce,m,le,g,te]),Se=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"area"},null!=a&&{data:Ae}),{xAccessor:d,yAccessor:h,groupAccessor:g||void 0}),f&&{y0Accessor:f}),y&&{gradientFill:y}),w&&{lineGradient:w}),{curve:x,lineStyle:pe}),O&&ye&&{pointStyle:ye}),{size:[$,z],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:ve,showAxes:i.showAxes,xLabel:Q,yLabel:Z,xFormat:c,yFormat:u,enableHover:G}),t.pointIdAccessor&&{pointIdAccessor:t.pointIdAccessor}),{showGrid:q}),me&&{legend:me,legendPosition:be}),H&&"none"!==H&&{legendHoverBehavior:he.onLegendHover,legendClickBehavior:he.onLegendClick,legendHighlightedCategory:he.highlightedCategory,legendIsolatedCategories:he.isolatedCategories}),X&&{title:X}),V&&{description:V}),U&&{summary:U}),void 0!==K&&{accessibleTable:K}),l&&{className:l}),{tooltipContent:!1===M?()=>null:ro(M)||ke}),(L||_||B||N)&&{customHoverBehavior:re}),(_||B||L)&&{customClickBehavior:ie}),j&&j.length>0&&{annotations:j}),se),C);return J||ee||(we?p.createElement(uo,{componentName:"AreaChart",message:we,width:$,height:z}):p.createElement(Ho,{componentName:"AreaChart",width:$,height:z},p.createElement(gn,Object.assign({ref:r},Se))))});function Qo({isPushMode:t,colorBy:n,colorScheme:o,showLegend:r,legendPosition:i="right"}){const a=e.useRef(new Set),s=e.useRef([]),[l,c]=e.useState(0),u=e.useCallback(e=>{if(!n)return null;const t="function"==typeof n?n(e):e[n];return null!=t?t+"":null},[n]),d=e.useCallback(e=>{if(!t||!n)return;let o=!1;for(const t of e){if(!t||"object"!=typeof t)continue;const e=u(t);null==e||a.current.has(e)||(a.current.add(e),s.current.push(e),o=!0)}o&&c(e=>e+1)},[t,n,u]),h=e.useCallback(e=>t=>{d([t]),e(t)},[d]),g=e.useCallback(e=>t=>{d(t),e(t)},[d]),f=e.useCallback(()=>{a.current=new Set,s.current=[],c(e=>e+1)},[]),p=e.useMemo(()=>{if(!t||!n||!1===r)return;const e=s.current;if(0===e.length)return;const i=Array.isArray(o)?o:P,a=new Map;for(let t=0;e.length>t;t++)a.set(e[t],i[t%i.length]);const l="string"==typeof n?n:"__streamCat";return _n({data:e.map(e=>({[l]:e})),colorBy:l,colorScale:e=>a.get(e)||"#999",getColor:T})},[t,n,r,o,l]),y=e.useMemo(()=>{if(p)return"right"===i?{right:110}:"left"===i?{left:110}:"top"===i?{top:50}:"bottom"===i?{bottom:80}:{right:110}},[p,i]);return{wrapPush:h,wrapPushMany:g,resetCategories:f,streamingLegend:p,streamingMarginAdjust:y}}Ko.displayName="AreaChart";const Zo=e.forwardRef(function(t,n){var o;const r=e.useRef(null),i=Zn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:a,margin:s,className:l,xFormat:c,yFormat:u,xAccessor:d="x",yAccessor:h="y",areaBy:g,lineDataAccessor:f="coordinates",colorBy:y,colorScheme:m,curve:v="monotoneX",areaOpacity:b=.7,showLine:x=!0,lineWidth:k=2,showPoints:w=!1,pointRadius:A=3,normalize:S=!1,tooltip:O,annotations:E,frameProps:M={},selection:j,linkedHover:C,onObservation:P,onClick:L,hoverHighlight:_,chartId:B,loading:N,emptyContent:D,legendInteraction:I,legendPosition:R,color:H}=t,W=i.width,F=i.height,$=i.enableHover,z=i.showGrid,G=i.showLegend,q=i.title,Y=i.description,X=i.summary,V=i.accessibleTable,U=i.xLabel,K=i.yLabel,Q=zo(N,W,F),Z=Q?null:$o(a,W,F,D),J=a||[],ee=Qo({isPushMode:void 0===a,colorBy:y||g,colorScheme:m,showLegend:G,legendPosition:R}),te=e.useCallback(ee.wrapPush(e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)}),[ee.wrapPush]),ne=e.useCallback(ee.wrapPushMany(e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)}),[ee.wrapPushMany]);e.useImperativeHandle(n,()=>({push:te,pushMany:ne,remove:e=>{var t,n;return null!==(n=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=r.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;ee.resetCategories(),null===(e=r.current)||void 0===e||e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}),[te,ne,ee.resetCategories]);const{activeSelectionHook:oe,hoverSelectionHook:re,customHoverBehavior:ie,customClickBehavior:ae,crosshairSourceId:se}=Xn({selection:j,linkedHover:C,fallbackFields:y?["string"==typeof y?y:""]:[],onObservation:P,onClick:L,chartType:"StackedAreaChart",chartId:B,hoverHighlight:_,colorByField:"string"==typeof y?y:void 0}),le=Vn(C,se),ce=void 0!==(null===(o=J[0])||void 0===o?void 0:o[f]),ue=e.useMemo(()=>{if(ce)return J;if(g){const e=J.reduce((e,t)=>{const n="function"==typeof g?g(t):t[g];if(!e[n]){const t={[f]:[]};"string"==typeof g&&(t[g]=n),e[n]=t}return e[n][f].push(t),e},{});return Object.values(e)}return[{[f]:J}]},[J,g,f,ce]),de=qn(J,y,m),he=e.useMemo(()=>{if(!y)return[];const e=new Set;for(const t of J){const n="function"==typeof y?y(t):t[y];null!=n&&e.add(n+"")}return Array.from(e)},[J,y]),ge=Kn(I,y,he),fe=e.useMemo(()=>re||(ge.legendSelectionHook?ge.legendSelectionHook:oe),[re,ge.legendSelectionHook,oe]),pe=e.useMemo(()=>e=>{const t={};if(y&&de){const n=T(e,y,de);t.fill=n,x?(t.stroke=n,t.strokeWidth=k):t.stroke="none"}else if(!y){const e=H||Fn;t.fill=e,t.stroke=x?e:"none",x&&(t.strokeWidth=k)}return t.fillOpacity=b,t},[y,de,b,x,k,H]),ye=e.useMemo(()=>Bn(pe,fe,j),[pe,fe,j]),me=e.useMemo(()=>{if(w)return e=>{const t={r:A,fillOpacity:1};return y?de&&(t.fill=T(e.parentLine||e,y,de)):t.fill=H||Fn,t}},[w,A,y,de,H]),{legend:ve,margin:be,legendPosition:xe}=Un({data:ue,colorBy:y,colorScale:de,showLegend:G,legendPosition:R,userMargin:s,defaults:i.marginDefaults}),ke=ee.streamingLegend||ve,we=R||xe,Ae=e.useMemo(()=>{if(ee.streamingMarginAdjust){const e=Object.assign({},be);for(const[t,n]of Object.entries(ee.streamingMarginAdjust))n>e[t]&&(e[t]=n);return e}return be},[be,ee.streamingMarginAdjust]),Se=g||y,Oe=e.useMemo(()=>lo([{label:U||io(d),accessor:d,role:"x"},{label:K||io(h),accessor:h,role:"y"},...Se?[{label:io(Se),accessor:Se,role:"group"}]:[]]),[d,h,U,K,Se]),Ee=mo({componentName:"StackedAreaChart",data:a,accessors:{xAccessor:d,yAccessor:h}}),Me=e.useMemo(()=>ce||g?ue.flatMap(e=>{const t=e[f]||[];return g&&"string"==typeof g?t.map(t=>Object.assign(Object.assign({},t),{[g]:e[g]})):t}):J,[ue,f,ce,g,J]),je=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"stackedarea"},null!=a&&{data:Me}),{xAccessor:d,yAccessor:h,groupAccessor:g||void 0,curve:v,normalize:S,lineStyle:ye}),w&&me&&{pointStyle:me}),{size:[W,F],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Ae,showAxes:i.showAxes,xLabel:U,yLabel:K,xFormat:c,yFormat:u,enableHover:$}),t.pointIdAccessor&&{pointIdAccessor:t.pointIdAccessor}),{showGrid:z}),ke&&{legend:ke,legendPosition:we}),I&&"none"!==I&&{legendHoverBehavior:ge.onLegendHover,legendClickBehavior:ge.onLegendClick,legendHighlightedCategory:ge.highlightedCategory,legendIsolatedCategories:ge.isolatedCategories}),q&&{title:q}),Y&&{description:Y}),X&&{summary:X}),void 0!==V&&{accessibleTable:V}),l&&{className:l}),{tooltipContent:!1===O?()=>null:ro(O)||Oe}),(C||P||L||_)&&{customHoverBehavior:ie}),(P||L||C)&&{customClickBehavior:ae}),E&&E.length>0&&{annotations:E}),le),M);return Q||Z||(Ee?p.createElement(uo,{componentName:"StackedAreaChart",message:Ee,width:W,height:F}):p.createElement(Ho,{componentName:"StackedAreaChart",width:W,height:F},p.createElement(gn,Object.assign({ref:r},je))))});function Jo(t){const{data:n,rawData:o,colorBy:r,colorScheme:i,legendInteraction:a,legendPosition:s,selection:l,linkedHover:c,fallbackFields:u,unwrapData:d=!1,onObservation:h,chartType:g,chartId:f,showLegend:p,userMargin:y,marginDefaults:m,onClick:v,hoverHighlight:b,loading:x,emptyContent:k,width:w,height:A}=t,S="string"==typeof t.colorBy?t.colorBy:void 0,{activeSelectionHook:O,hoverSelectionHook:E,customHoverBehavior:M,customClickBehavior:j,crosshairSourceId:C}=Xn({selection:l,linkedHover:c,fallbackFields:u,unwrapData:d,onObservation:h,chartType:g,chartId:f,onClick:v,hoverHighlight:b,colorByField:S}),P=Vn(c,C),L=qn(n,r,i),_=e.useMemo(()=>{if(!r)return[];const e=new Set;for(const t of n){const n="function"==typeof r?r(t):t[r];null!=n&&e.add(n+"")}return Array.from(e)},[n,r]),T=Kn(a,r,_),B=e.useMemo(()=>E||(T.legendSelectionHook?T.legendSelectionHook:O),[E,T.legendSelectionHook,O]),{legend:N,margin:D,legendPosition:I}=Un({data:n,colorBy:r,colorScale:L,showLegend:p,legendPosition:s,userMargin:y,defaults:m}),R=e.useMemo(()=>{const e={};return N&&(e.legend=N,e.legendPosition=I),a&&"none"!==a&&(e.legendHoverBehavior=T.onLegendHover,e.legendClickBehavior=T.onLegendClick,e.legendHighlightedCategory=T.highlightedCategory,e.legendIsolatedCategories=T.isolatedCategories),e},[N,I,a,T.onLegendHover,T.onLegendClick,T.highlightedCategory,T.isolatedCategories]),H=zo(x,w,A),W=H?null:$o(o,w,A,k);return{colorScale:L,allCategories:_,legendState:T,effectiveSelectionHook:B,activeSelectionHook:O,customHoverBehavior:M,customClickBehavior:j,legend:N,margin:D,legendPosition:I,earlyReturn:H||W||null,legendBehaviorProps:R,crosshairProps:P}}Zo.displayName="StackedAreaChart";const er=e.forwardRef(function(t,n){const o=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=o.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,r;return null!==(r=null===(n=o.current)||void 0===n?void 0:n.update(e,t))&&void 0!==r?r:[]},clear:()=>{var e;return null===(e=o.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=o.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const r=Zn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:i,margin:a,className:s,xFormat:l,yFormat:c,xAccessor:u="x",yAccessor:d="y",colorBy:h,colorScheme:g,sizeBy:f,sizeRange:y=[3,15],pointRadius:m=5,pointOpacity:v=.8,tooltip:b,marginalGraphics:x,pointIdAccessor:k,annotations:w,frameProps:A={},selection:S,linkedHover:O,linkedBrush:E,onObservation:M,onClick:j,hoverHighlight:C,chartId:P,loading:L,emptyContent:_,legendInteraction:B,legendPosition:D,color:I}=t,R=r.width,H=r.height,W=r.enableHover,F=r.showGrid,$=r.title,z=r.description,G=r.summary,q=r.accessibleTable,Y=r.xLabel,X=r.yLabel,V=i||[],U=Jo({data:V,rawData:i,colorBy:h,colorScheme:g,legendInteraction:B,legendPosition:D,selection:S,linkedHover:O,fallbackFields:h?["string"==typeof h?h:""]:[],unwrapData:!1,onObservation:M,onClick:j,hoverHighlight:C,chartType:"Scatterplot",chartId:P,showLegend:r.showLegend,userMargin:a,marginDefaults:r.marginDefaults,loading:L,emptyContent:_,width:R,height:H}),K=Tn(E),Q=En({name:(null==K?void 0:K.name)||"__unused_brush__",xField:(null==K?void 0:K.xField)||("string"==typeof u?u:void 0),yField:(null==K?void 0:K.yField)||("string"==typeof d?d:void 0)}),Z=K?"xyBrush"===Q.brushInteraction.brush?"xy":"xBrush"===Q.brushInteraction.brush?"x":"y":void 0,J=p.useRef(Q.brushInteraction);J.current=Q.brushInteraction;const ee=e.useCallback(e=>{const t=J.current;t.end(e?"xyBrush"===t.brush?[[e.x[0],e.y[0]],[e.x[1],e.y[1]]]:"xBrush"===t.brush?e.x:e.y:null)},[]);if(U.earlyReturn)return U.earlyReturn;Go("Scatterplot",V,"xAccessor",u),Go("Scatterplot",V,"yAccessor",d);const te=e.useMemo(()=>{if(!f||0===V.length)return;const e=V.map(e=>"function"==typeof f?f(e):e[f]);return[Math.min(...e),Math.max(...e)]},[V,f]),ne=e.useMemo(()=>e=>{const t={fillOpacity:v};return h?U.colorScale&&(t.fill=T(e,h,U.colorScale)):t.fill=I||Fn,t.r=f?N(e,f,y,te):m,t},[h,U.colorScale,f,y,te,m,v,I]),oe=e.useMemo(()=>Bn(ne,U.effectiveSelectionHook,S),[ne,U.effectiveSelectionHook,S]),re=e.useMemo(()=>lo([{label:Y||io(u),accessor:u,role:"x"},{label:X||io(d),accessor:d,role:"y"},...h?[{label:io(h),accessor:h,role:"color"}]:[],...f?[{label:io(f),accessor:f,role:"size"}]:[]]),[u,d,Y,X,h,f]),ie=mo({componentName:"Scatterplot",data:i,accessors:{xAccessor:u,yAccessor:d}});if(ie)return p.createElement(uo,{componentName:"Scatterplot",message:ie,width:R,height:H});const ae=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter"},null!=i&&{data:V}),{xAccessor:u,yAccessor:d,colorAccessor:h||void 0,sizeAccessor:f||void 0,sizeRange:y,pointStyle:oe,colorScheme:g,size:[R,H],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:U.margin,showAxes:r.showAxes,xLabel:Y,yLabel:X,xFormat:l,yFormat:c,enableHover:W,showGrid:F}),U.legendBehaviorProps),$&&{title:$}),z&&{description:z}),G&&{summary:G}),void 0!==q&&{accessibleTable:q}),s&&{className:s}),{tooltipContent:!1===b?()=>null:ro(b)||re}),(O||M||j||C)&&{customHoverBehavior:U.customHoverBehavior}),(M||j||O)&&{customClickBehavior:U.customClickBehavior}),x&&{marginalGraphics:x}),k&&{pointIdAccessor:k}),w&&w.length>0&&{annotations:w}),K&&{brush:{dimension:Z},onBrush:ee}),U.crosshairProps),A);return p.createElement(Ho,{componentName:"Scatterplot",width:R,height:H},p.createElement(gn,Object.assign({ref:o},ae)))});function tr(e,t){return i.interpolateViridis(1===t?.5:e/(t-1))}er.displayName="Scatterplot";const nr=e.forwardRef(function(t,n){const o=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=o.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,r;return null!==(r=null===(n=o.current)||void 0===n?void 0:n.update(e,t))&&void 0!==r?r:[]},clear:()=>{var e;return null===(e=o.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=o.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const r=Zn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:i,className:a,xFormat:s,yFormat:l,xAccessor:c="x",yAccessor:u="y",orderAccessor:d,orderLabel:h,pointRadius:g=4,tooltip:f,pointIdAccessor:y,annotations:m,frameProps:v={},selection:b,linkedHover:x,onObservation:k,onClick:w,hoverHighlight:A,chartId:S,loading:O,emptyContent:E,legendInteraction:M}=t,j=r.width,C=r.height,P=r.enableHover,L=r.showGrid,_=r.title,T=r.description,B=r.summary,N=r.accessibleTable,D=r.xLabel,I=r.yLabel,R=i||[],{safeData:H,orderMap:W}=e.useMemo(()=>{const e="function"==typeof c?c:e=>e[c],t="function"==typeof u?u:e=>e[u];let n=R;if(d&&R.length>0){const e="function"==typeof d?d:e=>e[d];n=[...R].sort((t,n)=>{const o=e(t),r=e(n);return(o instanceof Date?o.getTime():+o)-(r instanceof Date?r.getTime():+r)})}const o=new WeakMap;let r=0;for(const o of n){const n=e(o),i=t(o);null!=n&&null!=i&&isFinite(n)&&isFinite(i)&&r++}let i=0;for(const a of n){const n=e(a),s=t(a);null!=n&&null!=s&&isFinite(n)&&isFinite(s)&&o.set(a,{idx:i++,total:r})}return{safeData:n,orderMap:o}},[R,d,c,u]);Go("ConnectedScatterplot",H,"xAccessor",c),Go("ConnectedScatterplot",H,"yAccessor",u);const{activeSelectionHook:F,hoverSelectionHook:$,customHoverBehavior:z,customClickBehavior:G,crosshairSourceId:q}=Xn({selection:b,linkedHover:x,fallbackFields:[],onObservation:k,onClick:w,chartType:"ConnectedScatterplot",chartId:S,hoverHighlight:A,colorByField:void 0}),Y=Vn(x,q),X=Kn(M,void 0,[]),V=e.useMemo(()=>$||(X.legendSelectionHook?X.legendSelectionHook:F),[$,X.legendSelectionHook,F]),U=e.useMemo(()=>(e,t)=>{var n,o;const r=t.filter(e=>"point"===e.type);if(2>r.length)return;const i=null==V?void 0:V.isActive,a=null==V?void 0:V.predicate,s=100>r.length,l=r.length;e.lineCap="round";for(let t=0;l-1>t;t++){const c=r[t],u=r[t+1],d=tr(t,l),h=!i||!a||a(null!==(n=c.datum)&&void 0!==n?n:c)||a(null!==(o=u.datum)&&void 0!==o?o:u),f=i?h?1:.2:1;s&&(e.beginPath(),e.moveTo(c.x,c.y),e.lineTo(u.x,u.y),e.strokeStyle="white",e.lineWidth=g+2,e.globalAlpha=.5*f,e.stroke()),e.beginPath(),e.moveTo(c.x,c.y),e.lineTo(u.x,u.y),e.strokeStyle=d,e.lineWidth=g,e.globalAlpha=f,e.stroke()}e.globalAlpha=1},[g,V]),K=e.useMemo(()=>[U],[U]),Q=e.useMemo(()=>(e,t,n)=>{var o,r;const i=e.filter(e=>"point"===e.type);if(2>i.length)return null;const a=i.length,s=100>a,l=[];for(let e=0;a-1>e;e++){const t=i[e],n=i[e+1],c=tr(e,a),u="number"==typeof(null===(o=t.style)||void 0===o?void 0:o.opacity)?t.style.opacity:1,d="number"==typeof(null===(r=n.style)||void 0===r?void 0:r.opacity)?n.style.opacity:1,h=Math.min(u,d);s&&l.push(p.createElement("line",{key:"halo-"+e,x1:t.x,y1:t.y,x2:n.x,y2:n.y,stroke:"white",strokeWidth:g+2,strokeLinecap:"round",opacity:.5*h})),l.push(p.createElement("line",{key:"seg-"+e,x1:t.x,y1:t.y,x2:n.x,y2:n.y,stroke:c,strokeWidth:g,strokeLinecap:"round",opacity:h}))}return p.createElement(p.Fragment,null,l)},[g]),Z=e.useMemo(()=>[Q],[Q]),J=e.useMemo(()=>e=>{var t,n;const o=W.get(e),r=null!==(t=null==o?void 0:o.idx)&&void 0!==t?t:0,i=null!==(n=null==o?void 0:o.total)&&void 0!==n?n:1;return{fill:i>0?tr(r,i):"#6366f1",stroke:"white",strokeWidth:1,r:g,fillOpacity:1}},[g,W]),ee=e.useMemo(()=>Bn(J,V,b),[J,V,b]),te=Object.assign({top:50,right:40,bottom:60,left:70},t.margin),ne=h||("string"==typeof d?d:"Order"),oe=e.useMemo(()=>lo([{label:D||io(c),accessor:c,role:"x"},{label:I||io(u),accessor:u,role:"y"},...d?[{label:ne,accessor:d,role:"group"}]:[]]),[c,u,D,I,d,ne]),re=mo({componentName:"ConnectedScatterplot",data:i,accessors:{xAccessor:c,yAccessor:u}}),ie=zo(O,j,C),ae=ie?null:$o(i,j,C,E),se=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter"},null!=i&&{data:H}),{xAccessor:c,yAccessor:u,pointStyle:ee,size:[j,C],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:te,showAxes:r.showAxes,xLabel:D,yLabel:I,xFormat:s,yFormat:l,enableHover:P,showGrid:L}),_&&{title:_}),T&&{description:T}),B&&{summary:B}),void 0!==N&&{accessibleTable:N}),a&&{className:a}),{tooltipContent:!1===f?()=>null:ro(f)||oe}),(x||k||w||A)&&{customHoverBehavior:z}),(k||w||x)&&{customClickBehavior:G}),y&&{pointIdAccessor:y}),{canvasPreRenderers:K,svgPreRenderers:Z}),m&&m.length>0&&{annotations:m}),Y),v);return ie||ae||(re?p.createElement(uo,{componentName:"ConnectedScatterplot",message:re,width:j,height:C}):p.createElement(Ho,{componentName:"ConnectedScatterplot",width:j,height:C},p.createElement(gn,Object.assign({ref:o},se))))});nr.displayName="ConnectedScatterplot";const or=e.forwardRef(function(t,n){const o=e.useRef(null),r=Zn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:i,margin:a,className:s,xFormat:l,yFormat:c,xAccessor:u="x",yAccessor:d="y",sizeBy:h,sizeRange:g=[5,40],colorBy:f,colorScheme:y,bubbleOpacity:m=.6,bubbleStrokeWidth:v=1,bubbleStrokeColor:b="white",tooltip:x,marginalGraphics:k,pointIdAccessor:w,annotations:A,frameProps:S={},selection:O,linkedHover:E,linkedBrush:M,onObservation:j,onClick:C,hoverHighlight:P,chartId:L,loading:_,emptyContent:B,legendInteraction:D,legendPosition:I,color:R}=t,H=r.width,W=r.height,F=r.enableHover,$=r.showGrid,z=r.showLegend,G=r.title,q=r.description,Y=r.summary,X=r.accessibleTable,V=r.xLabel,U=r.yLabel,K=zo(_,H,W),Q=K?null:$o(i,H,W,B),Z=i||[],J=void 0===i,ee=e.useRef(null),[te,ne]=e.useState(0),oe=e.useCallback(e=>{if(!J)return;let t=!1;for(const n of e){const e="function"==typeof h?h(n):n[h];null!=e&&isFinite(e)&&(ee.current?(ee.current[0]>e&&(ee.current[0]=e,t=!0),e>ee.current[1]&&(ee.current[1]=e,t=!0)):(ee.current=[e,e],t=!0))}t&&ne(e=>e+1)},[J,h]),re=Qo({isPushMode:J,colorBy:f,colorScheme:y,showLegend:z,legendPosition:I}),ie=e.useCallback(re.wrapPush(e=>{var t;oe([e]),null===(t=o.current)||void 0===t||t.push(e)}),[re.wrapPush,oe]),ae=e.useCallback(re.wrapPushMany(e=>{var t;oe(e),null===(t=o.current)||void 0===t||t.pushMany(e)}),[re.wrapPushMany,oe]);e.useImperativeHandle(n,()=>({push:ie,pushMany:ae,remove:e=>{var t,n;return null!==(n=null===(t=o.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,r;return null!==(r=null===(n=o.current)||void 0===n?void 0:n.update(e,t))&&void 0!==r?r:[]},clear:()=>{var e;re.resetCategories(),ee.current=null,ne(e=>e+1),null===(e=o.current)||void 0===e||e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=o.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}),[ie,ae,re.resetCategories]);const{activeSelectionHook:se,hoverSelectionHook:le,customHoverBehavior:ce,customClickBehavior:ue,crosshairSourceId:de}=Xn({selection:O,linkedHover:E,fallbackFields:f?["string"==typeof f?f:""]:[],onObservation:j,onClick:C,chartType:"BubbleChart",chartId:L,hoverHighlight:P,colorByField:"string"==typeof f?f:void 0}),he=Vn(E,de),ge=Tn(M);En({name:(null==ge?void 0:ge.name)||"__unused_brush__",xField:(null==ge?void 0:ge.xField)||("string"==typeof u?u:void 0),yField:(null==ge?void 0:ge.yField)||("string"==typeof d?d:void 0)});const fe=qn(Z,f,y),pe=e.useMemo(()=>{if(!f)return[];const e=new Set;for(const t of Z){const n="function"==typeof f?f(t):t[f];null!=n&&e.add(n+"")}return Array.from(e)},[Z,f]),ye=Kn(D,f,pe),me=e.useMemo(()=>le||(ye.legendSelectionHook?ye.legendSelectionHook:se),[le,ye.legendSelectionHook,se]),ve=e.useMemo(()=>{if(J)return ee.current||[0,1];const e=Z.map(e=>"function"==typeof h?h(e):e[h]);return[Math.min(...e),Math.max(...e)]},[Z,h,J,te]),be=e.useMemo(()=>e=>{const t={fillOpacity:m,strokeWidth:v,stroke:b};return f?fe&&(t.fill=T(e,f,fe)):t.fill=R||Fn,t.r=N(e,h,g,ve),t},[f,fe,h,g,ve,m,v,b,R]),xe=e.useMemo(()=>Bn(be,me,O),[be,me,O]),{legend:ke,margin:we,legendPosition:Ae}=Un({data:Z,colorBy:f,colorScale:fe,showLegend:z,legendPosition:I,userMargin:a,defaults:r.marginDefaults}),Se=re.streamingLegend||ke,Oe=I||Ae,Ee=e.useMemo(()=>{if(re.streamingMarginAdjust){const e=Object.assign({},we);for(const[t,n]of Object.entries(re.streamingMarginAdjust))n>e[t]&&(e[t]=n);return e}return we},[we,re.streamingMarginAdjust]),Me=e.useMemo(()=>lo([{label:V||io(u),accessor:u,role:"x"},{label:U||io(d),accessor:d,role:"y"},{label:io(h),accessor:h,role:"size"},...f?[{label:io(f),accessor:f,role:"color"}]:[]]),[u,d,V,U,h,f]),je=mo({componentName:"BubbleChart",data:i,accessors:{xAccessor:u,yAccessor:d},requiredProps:{sizeBy:h}});if(je)return p.createElement(uo,{componentName:"BubbleChart",message:je,width:H,height:W});const Ce=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bubble"},null!=i&&{data:Z}),{xAccessor:u,yAccessor:d,colorAccessor:f||void 0,sizeAccessor:h,sizeRange:g,pointStyle:xe,colorScheme:y,size:[H,W],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Ee,showAxes:r.showAxes,xLabel:V,yLabel:U,xFormat:l,yFormat:c,enableHover:F,showGrid:$}),Se&&{legend:Se,legendPosition:Oe}),D&&"none"!==D&&{legendHoverBehavior:ye.onLegendHover,legendClickBehavior:ye.onLegendClick,legendHighlightedCategory:ye.highlightedCategory,legendIsolatedCategories:ye.isolatedCategories}),G&&{title:G}),q&&{description:q}),Y&&{summary:Y}),void 0!==X&&{accessibleTable:X}),s&&{className:s}),{tooltipContent:!1===x?()=>null:ro(x)||Me}),(E||j||C||P)&&{customHoverBehavior:ce}),(j||C||E)&&{customClickBehavior:ue}),k&&{marginalGraphics:k}),w&&{pointIdAccessor:w}),A&&A.length>0&&{annotations:A}),he),S);return K||Q||p.createElement(Ho,{componentName:"BubbleChart",width:H,height:W},p.createElement(gn,Object.assign({ref:o},Ce)))});or.displayName="BubbleChart";const rr=e.forwardRef(function(t,n){const r=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=r.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const a=Zn(t.mode,{width:t.width,height:t.height,showGrid:void 0,enableHover:t.enableHover,showLegend:void 0,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:s,margin:l,className:c,xAccessor:u="x",yAccessor:d="y",valueAccessor:h="value",xFormat:g,yFormat:f,colorScheme:y="blues",customColorScale:m,showValues:v=!1,valueFormat:b,cellBorderColor:x="#fff",cellBorderWidth:k=1,tooltip:w,annotations:A,frameProps:S={},selection:O,linkedHover:E,onObservation:M,onClick:j,hoverHighlight:C,chartId:P,loading:L,emptyContent:_,showLegend:T,legendPosition:B,legendInteraction:N}=t,D=a.width,I=a.height,R=a.enableHover,H=a.title,W=a.description,F=a.summary,$=a.accessibleTable,z=a.xLabel,G=a.yLabel,q=zo(L,D,I),Y=q?null:$o(s,D,I,_),X=s||[],V=null!=T&&T,U=null!=B?B:"right",{margin:K}=Un({data:X,colorBy:V?"value":void 0,colorScale:void 0,showLegend:V,legendPosition:U,userMargin:l,defaults:a.marginDefaults}),{activeSelectionHook:Q,hoverSelectionHook:Z,customHoverBehavior:J,customClickBehavior:ee,crosshairSourceId:te}=Xn({selection:O,linkedHover:E,fallbackFields:[],onObservation:M,onClick:j,chartType:"Heatmap",chartId:P,hoverHighlight:C,colorByField:void 0}),ne=Vn(E,te),oe=Kn(N,void 0,[]),re=e.useMemo(()=>Z||(oe.legendSelectionHook?oe.legendSelectionHook:Q),[Z,oe.legendSelectionHook,Q]),ie=e.useMemo(()=>"function"==typeof h?e=>h(e):e=>e[h],[h]),ae=e.useMemo(()=>{const e=X.map(ie);return[Math.min(...e),Math.max(...e)]},[X,ie]),se=e.useMemo(()=>"custom"===y&&m?m:o.scaleSequential({blues:i.interpolateBlues,reds:i.interpolateReds,greens:i.interpolateGreens,viridis:i.interpolateViridis}[y]||i.interpolateBlues).domain(ae),[y,m,ae]);e.useMemo(()=>{const e=Gn(u),t=Gn(d);return{xBinCount:new Set(X.map(e)).size,yBinCount:new Set(X.map(t)).size}},[X,u,d]),e.useMemo(()=>({coordinates:X}),[X]);const le=e.useMemo(()=>e=>{const t=ie(e);return{fill:se(t),stroke:x,strokeWidth:k}},[ie,se,x,k]);e.useMemo(()=>Bn(le,re,O),[le,re,O]);const ce=e.useMemo(()=>lo([{label:z||io(u),accessor:u,role:"x"},{label:G||io(d),accessor:d,role:"y"},{label:io(h),accessor:h,role:"value"}]),[u,d,z,G,h]),ue=mo({componentName:"Heatmap",data:s,accessors:{xAccessor:u,yAccessor:d,valueAccessor:h}}),de=e.useMemo(()=>{if(V)return{gradient:{colorFn:e=>se(e),domain:ae,label:"string"==typeof h?h:"value",format:b}}},[V,se,ae,h,b]),he=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"heatmap"},null!=s&&{data:X}),{xAccessor:u,yAccessor:d,valueAccessor:h,colorScheme:"custom"!==y?y:void 0,showValues:v,heatmapValueFormat:b,size:[D,I],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:K,showAxes:a.showAxes,xLabel:z,yLabel:G,xFormat:g,yFormat:f,enableHover:R}),t.pointIdAccessor&&{pointIdAccessor:t.pointIdAccessor}),de&&{legend:de,legendPosition:U}),H&&{title:H}),W&&{description:W}),F&&{summary:F}),void 0!==$&&{accessibleTable:$}),c&&{className:c}),{tooltipContent:!1===w?()=>null:ro(w)||ce}),(E||M||j||C)&&{customHoverBehavior:J}),(M||j||E)&&{customClickBehavior:ee}),A&&A.length>0&&{annotations:A}),ne),S);return q||Y||(ue?p.createElement(uo,{componentName:"Heatmap",message:ue,width:D,height:I}):p.createElement(Ho,{componentName:"Heatmap",width:D,height:I},p.createElement(gn,Object.assign({ref:r},he))))});rr.displayName="Heatmap";const ir="__splomIdx",ar={top:4,bottom:4,left:4,right:4};function sr({frameRef:o,cellSize:r,onBrush:i}){const a=e.useRef(null),s=r-ar.left-ar.right,l=r-ar.top-ar.bottom;return e.useEffect(()=>{if(!a.current)return;const e=t.select(a.current).select(".brush-g"),r=n.brush().extent([[0,0],[s,l]]).on("brush end",e=>{var t;const n=null===(t=o.current)||void 0===t?void 0:t.getScales();if(!n)return;if(!e.selection)return void i(null);const[[r,a],[s,l]]=e.selection,c=[[n.x.invert(r),n.y.invert(a)],[n.x.invert(s),n.y.invert(l)]];i(c)});return e.call(r),e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{r.on("brush end",null)}},[s,l,o,i]),p.createElement("svg",{ref:a,width:r,height:r,style:{position:"absolute",top:0,left:0}},p.createElement("g",{className:"brush-g",transform:`translate(${ar.left},${ar.top})`}))}function lr({data:t,xField:n,yField:o,cellSize:r,pointRadius:i,pointOpacity:a,colorBy:s,colorScale:l,brushSelectionName:c,hoverSelectionName:u,unselectedOpacity:d,mode:h,onPointHover:g}){const f=e.useRef(null),y=Sn({name:c,clientId:`splom-${n}-${o}`}),m=En({name:c,xField:n,yField:o}),v=Sn({name:u,clientId:"splom-hover-source"}),b=v.selectPoints,x=e.useCallback(e=>{e?m.brushInteraction.during(e):m.brushInteraction.end(null)},[m.brushInteraction]),k=e.useCallback(e=>{if(!e)return void(null==g||g(null));const t=e.data,n=null==t?void 0:t[ir];void 0!==n&&(b({[ir]:[n]}),null==g||g(t,e.x+ar.left,e.y+ar.top))},[b,g]),w=e.useCallback(e=>{const t={opacity:a,r:i};return t.fill=s?T(e,s,l):Fn,"hover"===h?v.isActive&&v.predicate(e)?(t.opacity=1,t.r=2.5*i,t.stroke="#333",t.strokeWidth=1.5):v.isActive&&(t.opacity=.6*a):y.isActive&&!y.predicate(e)&&(t.opacity=d),t},[s,l,a,i,h,y.isActive,y.predicate,v.isActive,v.predicate,d]);return p.createElement("div",{style:{position:"relative",width:r,height:r}},p.createElement(gn,{ref:f,chartType:"scatter",data:t,size:[r,r],xAccessor:n,yAccessor:o,pointStyle:w,margin:ar,showAxes:!1,enableHover:"hover"===h,customHoverBehavior:"hover"===h?k:void 0,tooltipContent:"hover"===h?()=>null:void 0}),"brush"===h&&p.createElement(sr,{frameRef:f,cellSize:r,xField:n,yField:o,onBrush:x}))}function cr({data:t,field:n,label:o,cellSize:r,bins:i,colorBy:a,colorScale:s,brushSelectionName:l,hoverSelectionName:c,mode:u}){const d=Sn({name:l,clientId:"splom-diag-"+n}),h=Sn({name:c,clientId:`splom-diag-${n}-hover`}),g="hover"===u?h:d,f=g.isActive,y=g.predicate,m=e.useMemo(()=>{const e=t.map(e=>e[n]).filter(e=>null!=e&&!isNaN(e));if(0===e.length)return{bars:[],selectedBars:[],categoryBars:[],selectedCategoryBars:[],max:0,categories:[]};const o=Math.min(...e),s=(Math.max(...e)-o)/i||1,l="string"==typeof a?a:null,c=l?[...new Set(t.map(e=>e[l]).filter(e=>null!=e).map(String))]:[],u=new Map(c.map((e,t)=>[e,t])),d=Array(i).fill(0),h=Array(i).fill(0),g=Array.from({length:i},()=>Array(c.length).fill(0)),p=Array.from({length:i},()=>Array(c.length).fill(0));for(const e of t){const t=e[n];if(null==t||isNaN(t))continue;const r=Math.min(Math.floor((t-o)/s),i-1);if(d[r]++,f&&!y(e)||h[r]++,l){const t=u.get(e[l]+"");void 0!==t&&(g[r][t]++,f&&!y(e)||p[r][t]++)}}const m=Math.max(...d,1),v=g.map((e,t)=>{let n=0;return e.map((e,o)=>{const a=e/m*(r-24),s={x:t/i*r,w:r/i-1,h:a,y0:n,category:c[o]};return n+=a,s})}),b=p.map((e,t)=>{let n=0;return e.map((e,o)=>{const a=e/m*(r-24),s={x:t/i*r,w:r/i-1,h:a,y0:n,category:c[o]};return n+=a,s})});return{bars:d.map((e,t)=>({x:t/i*r,w:r/i-1,h:e/m*(r-24),count:e})),selectedBars:h.map((e,t)=>({x:t/i*r,w:r/i-1,h:e/m*(r-24),count:e})),categoryBars:v,selectedCategoryBars:b,max:m,categories:c}},[t,n,i,r,f,y,a]);return p.createElement("svg",{width:r,height:r,style:{overflow:"hidden"}},p.createElement("text",{x:r/2,y:14,textAnchor:"middle",fontSize:11,fontWeight:"bold",fill:"#333"},o),m.categories.length>0?m.categoryBars.map((e,t)=>e.map((e,n)=>p.createElement("rect",{key:`bg-${t}-${n}`,x:e.x,y:r-e.y0-e.h,width:Math.max(e.w,1),height:e.h,fill:s?s(e.category):Fn,opacity:f?.3:.6}))):m.bars.map((e,t)=>p.createElement("rect",{key:"bg-"+t,x:e.x,y:r-e.h,width:Math.max(e.w,1),height:e.h,fill:Fn,opacity:f?.3:.6})),f&&(m.categories.length>0?m.selectedCategoryBars.map((e,t)=>e.map((e,n)=>p.createElement("rect",{key:`sel-${t}-${n}`,x:e.x,y:r-e.y0-e.h,width:Math.max(e.w,1),height:e.h,fill:s?s(e.category):Fn,opacity:.7}))):m.selectedBars.map((e,t)=>p.createElement("rect",{key:"sel-"+t,x:e.x,y:r-e.h,width:Math.max(e.w,1),height:e.h,fill:Fn,opacity:.7}))))}function ur({label:e,cellSize:t}){return p.createElement("svg",{width:t,height:t},p.createElement("text",{x:t/2,y:t/2,textAnchor:"middle",dominantBaseline:"middle",fontSize:12,fontWeight:"bold",fill:"#333"},e))}function dr(t){const{data:n,fields:o,fieldLabels:r={},colorBy:i,colorScheme:a,cellSize:s=150,cellGap:l=4,pointRadius:c=2,pointOpacity:u=.5,diagonal:d="histogram",histogramBins:h=20,brushMode:g="crossfilter",hoverMode:f=!0,unselectedOpacity:y=.1,showGrid:m=!1,tooltip:v,showLegend:b,idAccessor:x,className:k,onObservation:w,chartId:A}=t,S="splom",O="splom-hover",E=f?"hover":g?"brush":"hover",M=kn(e=>e.clearSelection),[j,C]=e.useState(null),P=e.useCallback(()=>{M(O),C(null)},[M,O]),L=e.useMemo(()=>(n||[]).map((e,t)=>void 0!==e[ir]?e:Object.assign(Object.assign({},e),{[ir]:t})),[n]),_=qn(L,i,a),T=void 0!==b?b:!!i,B=e.useMemo(()=>{if(!T||!i)return null;const e="string"==typeof i?i:null;return e?[...new Set(L.map(t=>t[e]))].map(e=>({label:e+"",color:_?_(e+""):Fn})):null},[T,i,L,_]),N=e.useMemo(()=>({display:"grid",gridTemplateColumns:"40px "+o.map(()=>s+"px").join(" "),gridTemplateRows:o.map(()=>s+"px").join(" ")+" 40px",gap:l+"px",width:"fit-content"}),[o,s,l,40]);return p.createElement("div",{className:k,style:{position:"relative"}},B&&p.createElement("div",{style:{display:"flex",gap:12,marginBottom:8,flexWrap:"wrap"}},B.map(e=>p.createElement("div",{key:e.label,style:{display:"flex",alignItems:"center",gap:4}},p.createElement("span",{style:{display:"inline-block",width:10,height:10,borderRadius:"50%",backgroundColor:e.color}}),p.createElement("span",{style:{fontSize:11}},e.label)))),p.createElement("div",{style:N,onMouseLeave:"hover"===E?P:void 0},o.map((e,t)=>p.createElement(p.Fragment,{key:"row-"+e},p.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",writingMode:"vertical-rl",transform:"rotate(180deg)",fontSize:11,fontWeight:"bold",color:"#333"}},r[e]||e),o.map((n,o)=>t===o?"label"===d?p.createElement(ur,{key:"diag-"+e,label:r[e]||e,cellSize:s}):p.createElement(cr,{key:"diag-"+e,data:L,field:e,label:r[e]||e,cellSize:s,bins:h,colorBy:i,colorScale:_,brushSelectionName:S,hoverSelectionName:O,unselectedOpacity:y,mode:E}):p.createElement(lr,{key:`cell-${e}-${n}`,data:L,xField:n,yField:e,fieldLabels:r,cellSize:s,pointRadius:c,pointOpacity:u,colorBy:i,colorScale:_,brushSelectionName:S,hoverSelectionName:O,unselectedOpacity:y,showGrid:m,tooltip:v,mode:E,onPointHover:"hover"===E?(r,i,a)=>{r?(C({datum:r,xField:n,yField:e,colIndex:o,rowIndex:t,px:null!=i?i:0,py:null!=a?a:0}),w&&w({type:"hover",datum:r,x:null!=i?i:0,y:null!=a?a:0,timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:A})):(C(null),w&&w({type:"hover-end",timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:A}))}:void 0})))),p.createElement("div",null)," ",o.map(e=>p.createElement("div",{key:"col-label-"+e,style:{display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:"bold",color:"#333"}},r[e]||e))),j&&"hover"===E&&(()=>{const e=j.datum,t=r[j.xField]||j.xField,n=r[j.yField]||j.yField,o=i?"function"==typeof i?i(e):e[i]:null,a=x?"function"==typeof x?x(e):e[x]:"Row "+e[ir];return p.createElement("div",{style:{position:"absolute",left:40+j.colIndex*(s+l)+j.px,top:j.rowIndex*(s+l)+j.py-8,transform:"translate(-50%, -100%)",color:"#333",background:"rgba(255,255,255,0.95)",border:"1px solid #ddd",borderRadius:3,padding:"4px 8px",fontSize:11,lineHeight:1.4,whiteSpace:"nowrap",pointerEvents:"none",zIndex:10}},p.createElement("div",{style:{fontWeight:"bold",marginBottom:2}},a+""),p.createElement("div",null,t,": ",null!=e[j.xField]?Number(e[j.xField]).toFixed(1):"–"),p.createElement("div",null,n,": ",null!=e[j.yField]?Number(e[j.yField]).toFixed(1):"–"),null!=o&&p.createElement("div",{style:{opacity:.8}},"string"==typeof i?i:"group",": ",o+""))})())}function hr(e){const{brushMode:t="crossfilter",hoverMode:n=!0}=e,o={};return!n&&t&&(o.splom={resolution:t}),n&&(o["splom-hover"]={resolution:"union"}),p.createElement(Ln,{selections:o},p.createElement(dr,Object.assign({},e)))}hr.displayName="ScatterplotMatrix";const gr=e.forwardRef(function(t,n){const o=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=o.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,r;return null!==(r=null===(n=o.current)||void 0===n?void 0:n.update(e,t))&&void 0!==r?r:[]},clear:()=>{var e;return null===(e=o.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=o.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const r=Zn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,yLabel:t.yLabel}),{data:i,margin:a,className:s,xFormat:l,yFormat:c,xAccessor:u="x",yAccessor:d="y",xCenter:h,yCenter:g,quadrants:f,centerlineStyle:y={},showQuadrantLabels:m=!0,quadrantLabelSize:v=12,colorBy:b,colorScheme:x,sizeBy:k,sizeRange:w=[3,15],pointRadius:A=5,pointOpacity:S=.8,tooltip:O,pointIdAccessor:E,annotations:M,frameProps:j={},selection:C,linkedHover:P,onObservation:L,onClick:_,hoverHighlight:B,chartId:D,loading:I,emptyContent:R,legendInteraction:H,legendPosition:W,color:F}=t,$=r.width,z=r.height,G=r.enableHover,q=r.showGrid,Y=r.showLegend,X=r.title,V=r.description,U=r.summary,K=r.accessibleTable,Q=r.xLabel,Z=r.yLabel,J=zo(I,$,z),ee=J?null:$o(i,$,z,R),te=i||[];Go("QuadrantChart",te,"xAccessor",u),Go("QuadrantChart",te,"yAccessor",d);const{activeSelectionHook:ne,hoverSelectionHook:oe,customHoverBehavior:re,customClickBehavior:ie,crosshairSourceId:ae}=Xn({selection:C,linkedHover:P,fallbackFields:"string"==typeof b?[b]:[],onObservation:L,onClick:_,chartType:"QuadrantChart",chartId:D,hoverHighlight:B,colorByField:"string"==typeof b?b:void 0}),se=Vn(P,ae),le=qn(te,b,x),ce=e.useMemo(()=>{if(!b)return[];const e=new Set;for(const t of te){const n="function"==typeof b?b(t):t[b];null!=n&&e.add(n+"")}return Array.from(e)},[te,b]),ue=Kn(H,b,ce),de=e.useMemo(()=>oe||(ue.legendSelectionHook?ue.legendSelectionHook:ne),[oe,ue.legendSelectionHook,ne]),he=e.useMemo(()=>{if(!te.length)return;const e="function"==typeof u?u:e=>+e[u],t="function"==typeof d?d:e=>+e[d];let n=1/0,o=-1/0,r=1/0,i=-1/0;for(const a of te){const s=e(a),l=t(a);isFinite(s)&&(n>s&&(n=s),s>o&&(o=s)),isFinite(l)&&(r>l&&(r=l),l>i&&(i=l))}if(null!=h&&isFinite(h)&&(n>h&&(n=h),h>o&&(o=h)),null!=g&&isFinite(g)&&(r>g&&(r=g),g>i&&(i=g)),n===1/0)return;const a=.1*(o-n)||1,s=.1*(i-r)||1;return{xExtent:[n-a,o+a],yExtent:[r-s,i+s]}},[te,u,d,h,g]),ge=e.useMemo(()=>{if(!k||0===te.length)return;const e=te.map(e=>"function"==typeof k?k(e):e[k]).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0!==e.length?[Math.min(...e),Math.max(...e)]:void 0},[te,k]),fe=e.useMemo(()=>"function"==typeof u?u:e=>+e[u],[u]),pe=e.useMemo(()=>"function"==typeof d?d:e=>+e[d],[d]),ye=e.useMemo(()=>e=>{const t={fillOpacity:S};if(b)le&&(t.fill=T(e,b,le));else{const n=fe(e),o=pe(e),r=null!=h?n>=h:void 0,i=null!=g?o>=g:void 0;t.fill=void 0===i||void 0===r?F||Fn:i&&r?f.topRight.color:i&&!r?f.topLeft.color:!i&&r?f.bottomRight.color:f.bottomLeft.color}return t.r=k?N(e,k,w,ge):A,t},[b,le,k,w,ge,A,S,fe,pe,h,g,f,F]),me=e.useMemo(()=>Bn(ye,de,C),[ye,de,C]),{legend:ve,margin:be,legendPosition:xe}=Un({data:te,colorBy:b,colorScale:le,showLegend:Y,legendPosition:W,userMargin:a,defaults:r.marginDefaults}),ke=e.useMemo(()=>{if(!te.length)return;const e=new Set;"string"==typeof u&&e.add(u),"string"==typeof d&&e.add(d),"string"==typeof b&&e.add(b),"string"==typeof k&&e.add(k);const t=te[0];for(const n of Object.keys(t))if(!n.startsWith("_")&&!e.has(n)&&"string"==typeof t[n])return n},[te,u,d,b,k]),we=e.useMemo(()=>lo([...ke?[{label:ke,accessor:ke,role:"title"}]:[],{label:Q||io(u),accessor:u,role:"x"},{label:Z||io(d),accessor:d,role:"y"},...b?[{label:io(b),accessor:b,role:"color"}]:[],...k?[{label:io(k),accessor:k,role:"size"}]:[]]),[ke,u,d,Q,Z,b,k]),Ae=mo({componentName:"QuadrantChart",data:i,accessors:{xAccessor:u,yAccessor:d}}),Se=e.useMemo(()=>{var e;const t={stroke:y.stroke||"#999",strokeWidth:null!==(e=y.strokeWidth)&&void 0!==e?e:1,dashArray:y.strokeDasharray||[]};return[(e,n,o,r)=>{var i;if(!(null==o?void 0:o.x)||!(null==o?void 0:o.y))return;const a=r.width,s=r.height,l=null!=h?o.x(h):a/2,c=null!=g?o.y(g):s/2;if(null!=h&&!isFinite(l))return;if(null!=g&&!isFinite(c))return;const u=Math.max(0,Math.min(a,l)),d=Math.max(0,Math.min(s,c)),p=[{config:f.topLeft,x:0,y:0,w:u,h:d},{config:f.topRight,x:u,y:0,w:a-u,h:d},{config:f.bottomLeft,x:0,y:d,w:u,h:s-d},{config:f.bottomRight,x:u,y:d,w:a-u,h:s-d}];for(const t of p)t.w>0&&t.h>0&&(e.fillStyle=t.config.color,e.globalAlpha=null!==(i=t.config.opacity)&&void 0!==i?i:.08,e.fillRect(t.x,t.y,t.w,t.h));e.globalAlpha=1,e.strokeStyle=t.stroke,e.lineWidth=t.strokeWidth,t.dashArray.length>0&&e.setLineDash(t.dashArray),e.beginPath(),e.moveTo(u,0),e.lineTo(u,s),e.stroke(),e.beginPath(),e.moveTo(0,d),e.lineTo(a,d),e.stroke(),e.setLineDash([])}]},[h,g,f,y]),Oe=e.useMemo(()=>m?[...Se,(e,t,n,o)=>{if(!(null==n?void 0:n.x)||!(null==n?void 0:n.y))return;const r=o.width,i=o.height,a=null!=h?n.x(h):r/2,s=null!=g?n.y(g):i/2;(null==h||isFinite(a))&&(null==g||isFinite(s))&&(e.font=`600 ${v}px sans-serif`,e.globalAlpha=.5,e.fillStyle=f.topLeft.color,e.textAlign="left",e.textBaseline="top",e.fillText(f.topLeft.label,8,8),e.fillStyle=f.topRight.color,e.textAlign="right",e.textBaseline="top",e.fillText(f.topRight.label,r-8,8),e.fillStyle=f.bottomLeft.color,e.textAlign="left",e.textBaseline="bottom",e.fillText(f.bottomLeft.label,8,i-8),e.fillStyle=f.bottomRight.color,e.textAlign="right",e.textBaseline="bottom",e.fillText(f.bottomRight.label,r-8,i-8),e.globalAlpha=1)}]:Se,[Se,m,v,f,h,g]),Ee=e.useMemo(()=>{const e=j.canvasPreRenderers||[];return[...Oe,...e]},[Oe,j.canvasPreRenderers]),Me=e.useMemo(()=>{var e;const t={stroke:y.stroke||"#999",strokeWidth:null!==(e=y.strokeWidth)&&void 0!==e?e:1,dashArray:y.strokeDasharray?Array.isArray(y.strokeDasharray)?y.strokeDasharray.join(","):y.strokeDasharray:void 0};return[(e,n,o)=>{if(!(null==n?void 0:n.x)||!(null==n?void 0:n.y))return null;const r=o.width,i=o.height,a=null!=h?n.x(h):r/2,s=null!=g?n.y(g):i/2;if(null!=h&&!isFinite(a))return null;if(null!=g&&!isFinite(s))return null;const l=Math.max(0,Math.min(r,a)),c=Math.max(0,Math.min(i,s));return p.createElement(p.Fragment,null,[{config:f.topLeft,x:0,y:0,w:l,h:c},{config:f.topRight,x:l,y:0,w:r-l,h:c},{config:f.bottomLeft,x:0,y:c,w:l,h:i-c},{config:f.bottomRight,x:l,y:c,w:r-l,h:i-c}].map((e,t)=>{var n;return e.w>0&&e.h>0?p.createElement("rect",{key:"qf-"+t,x:e.x,y:e.y,width:e.w,height:e.h,fill:e.config.color,opacity:null!==(n=e.config.opacity)&&void 0!==n?n:.08}):null}),p.createElement("line",{x1:l,y1:0,x2:l,y2:i,stroke:t.stroke,strokeWidth:t.strokeWidth,strokeDasharray:t.dashArray}),p.createElement("line",{x1:0,y1:c,x2:r,y2:c,stroke:t.stroke,strokeWidth:t.strokeWidth,strokeDasharray:t.dashArray}),m&&p.createElement(p.Fragment,null,p.createElement("text",{x:8,y:8+v,fill:f.topLeft.color,fontWeight:600,fontSize:v,opacity:.5},f.topLeft.label),p.createElement("text",{x:r-8,y:8+v,fill:f.topRight.color,fontWeight:600,fontSize:v,opacity:.5,textAnchor:"end"},f.topRight.label),p.createElement("text",{x:8,y:i-8,fill:f.bottomLeft.color,fontWeight:600,fontSize:v,opacity:.5},f.bottomLeft.label),p.createElement("text",{x:r-8,y:i-8,fill:f.bottomRight.color,fontWeight:600,fontSize:v,opacity:.5,textAnchor:"end"},f.bottomRight.label)))}]},[h,g,f,y,m,v]),je=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter"},null!=i&&{data:te}),{xAccessor:u,yAccessor:d,colorAccessor:b||void 0,sizeAccessor:k||void 0,sizeRange:w,pointStyle:me,colorScheme:x,size:[$,z],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:be,showAxes:r.showAxes,xLabel:Q,yLabel:Z,xFormat:l,yFormat:c,enableHover:G,showGrid:q}),he&&{xExtent:he.xExtent,yExtent:he.yExtent}),ve&&{legend:ve,legendPosition:xe}),H&&"none"!==H&&{legendHoverBehavior:ue.onLegendHover,legendClickBehavior:ue.onLegendClick,legendHighlightedCategory:ue.highlightedCategory,legendIsolatedCategories:ue.isolatedCategories}),X&&{title:X}),V&&{description:V}),U&&{summary:U}),void 0!==K&&{accessibleTable:K}),s&&{className:s}),{tooltipContent:!1===O?()=>null:!0===O||void 0===O?we:ro(O)||we}),(P||L||_||B)&&{customHoverBehavior:re}),(L||_||P)&&{customClickBehavior:ie}),E&&{pointIdAccessor:E}),M&&M.length>0&&{annotations:M}),{canvasPreRenderers:Ee}),se),j),Ee.length>0&&{canvasPreRenderers:Ee}),{svgPreRenderers:Me});return J||ee||(Ae?p.createElement(uo,{componentName:"QuadrantChart",message:Ae,width:$,height:z}):p.createElement(Ho,{componentName:"QuadrantChart",width:$,height:z},p.createElement(gn,Object.assign({ref:o},je))))});gr.displayName="QuadrantChart";const fr="__ma_unitized",pr="__ma_series";function yr(e,t){const n=t[1]-t[0];return 0===n?.5:(e-t[0])/n}function mr(e,t){return t[0]+e*(t[1]-t[0])}const vr=e.forwardRef(function(t,n){var o,r;const i=e.useRef(null),a=e.useRef([]);e.useImperativeHandle(n,()=>({push:e=>{if(!i.current)return;const n=e;for(let e=0;t.series.length>e&&2>e;e++){const o=t.series[e],r=o.extent||a.current[e];if(!r)continue;const s=("function"==typeof o.yAccessor?o.yAccessor:e=>e[o.yAccessor])(n);null!=s&&isFinite(s)&&i.current.push(Object.assign(Object.assign({},n),{[fr]:yr(s,r),[pr]:o.label||"Series "+(e+1)}))}},pushMany:e=>{if(!i.current)return;const n=[];for(const o of e)for(let e=0;t.series.length>e&&2>e;e++){const r=t.series[e],i=r.extent||a.current[e];if(!i)continue;const s=("function"==typeof r.yAccessor?r.yAccessor:e=>e[r.yAccessor])(o);null!=s&&isFinite(s)&&n.push(Object.assign(Object.assign({},o),{[fr]:yr(s,i),[pr]:r.label||"Series "+(e+1)}))}i.current.pushMany(n)},remove:e=>{var t,n;return null!==(n=null===(t=i.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=i.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;return null===(e=i.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=i.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const s=Zn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,xLabel:t.xLabel,accessibleTable:t.accessibleTable},{width:800,height:400}),{data:l,margin:c,className:u,xFormat:d,xAccessor:h="x",series:g,colorScheme:f,curve:y="monotoneX",lineWidth:m=2,tooltip:v,annotations:b,frameProps:x={},selection:k,linkedHover:w,onObservation:A,onClick:S,hoverHighlight:O,chartId:E,loading:M,emptyContent:P,legendInteraction:L,legendPosition:_}=t,T=s.width,B=s.height,N=s.enableHover,D=s.showGrid,I=null===(o=s.showLegend)||void 0===o||o,R=s.title,H=s.description,W=s.summary,F=s.accessibleTable,$=s.xLabel,z=2===g.length;"undefined"==typeof process||"production"===(null===(r=process.env)||void 0===r?void 0:r.NODE_ENV)||z||console.warn(`[MultiAxisLineChart] Expected exactly 2 series for dual-axis mode, got ${g.length}. Rendering as a standard multi-line chart.`);const G=zo(M,T,B),q=G?null:$o(l,T,B,P),Y=l||[],X=$n(),V=e.useMemo(()=>{let e;if(Array.isArray(f))e=f;else if(X&&X.length>0)e=X;else{const t=j[f];e=Array.isArray(t)?t:C}return g.map((t,n)=>t.color||e[n%e.length])},[g,f,X]),U=e.useMemo(()=>g.map((e,t)=>e.label||"Series "+(t+1)),[g]),{unitizedData:K,extents:Q}=e.useMemo(()=>{if(0===Y.length){const e=g.map(e=>e.extent||null).filter(Boolean);return e.length===g.length&&(a.current=e),{unitizedData:[],extents:e.length===g.length?e:[]}}const e=g.map(e=>e.extent||function(e,t){let n=1/0,o=-1/0;const r="function"==typeof t?t:e=>e[t];for(const t of e){const e=r(t);null!=e&&isFinite(e)&&(n>e&&(n=e),e>o&&(o=e))}if(!isFinite(n)||!isFinite(o))return[0,1];if(n===o){const e=0===n?1:.1*Math.abs(n);return[n-e,o+e]}return[n,o]}(Y,e.yAccessor));if(a.current=e,!z){const t=[];for(const e of Y)for(let n=0;g.length>n;n++){const o=g[n],r=("function"==typeof o.yAccessor?o.yAccessor:e=>e[o.yAccessor])(e);null!=r&&t.push(Object.assign(Object.assign({},e),{[fr]:r,[pr]:U[n]}))}return{unitizedData:t,extents:e}}const t=[];for(const n of Y)for(let o=0;2>o;o++){const r=g[o],i=("function"==typeof r.yAccessor?r.yAccessor:e=>e[r.yAccessor])(n);null!=i&&t.push(Object.assign(Object.assign({},n),{[fr]:yr(i,e[o]),[pr]:U[o]}))}return{unitizedData:t,extents:e}},[Y,g,z,U]),Z=e.useMemo(()=>{if(z&&Q.length>=2)return[{orient:"left",label:U[0],tickFormat:g[0].format||(e=>{const t=mr(e,Q[0]);return Number.isInteger(t)?t+"":t.toFixed(1)})},{orient:"right",label:U[1],tickFormat:g[1].format||(e=>{const t=mr(e,Q[1]);return Number.isInteger(t)?t+"":t.toFixed(1)})},{orient:"bottom"}]},[z,Q,g,U]),J=Jo({data:e.useMemo(()=>K.length>0?K:U.map(e=>({[pr]:e})),[K,U]),rawData:l,colorBy:pr,colorScheme:V,legendInteraction:L,legendPosition:_,selection:k,linkedHover:w,fallbackFields:[pr],unwrapData:!1,onObservation:A,onClick:S,hoverHighlight:O,chartType:"MultiAxisLineChart",chartId:E,showLegend:I,userMargin:c,marginDefaults:z?Object.assign(Object.assign({},s.marginDefaults),{left:70,right:70}):s.marginDefaults,loading:M,emptyContent:P,width:T,height:B});if(J.earlyReturn)return J.earlyReturn;const ee=e.useMemo(()=>{const e=new Map;return U.forEach((t,n)=>e.set(t,V[n])),t=>({stroke:e.get(t[pr])||V[0],strokeWidth:m,fill:"none"})},[U,V,m]),te=e.useMemo(()=>Bn(ee,J.effectiveSelectionHook,k),[ee,J.effectiveSelectionHook,k]),ne=e.useMemo(()=>{if(!1===v)return()=>null;return ro(v)||(e=>{var t;const n=e.data||e,o=n[pr],r=U.indexOf(o),i=n[fr],a=z&&r>=0&&Q[r]?mr(i,Q[r]):i,s=r>=0&&(null===(t=g[r])||void 0===t?void 0:t.format)?g[r].format:e=>Number.isInteger(e)?e+"":e.toFixed(2),l="function"==typeof h?h(n):n[h];return p.createElement("div",{style:{padding:"6px 10px",fontFamily:"var(--semiotic-font-family, sans-serif)",fontSize:"var(--semiotic-tooltip-font-size, 13px)"}},p.createElement("div",{style:{fontWeight:600,marginBottom:4,color:V[r]||"inherit"}},o),p.createElement("div",null,`${"string"==typeof h?h:"x"}: ${l}`),p.createElement("div",null,`${o}: ${s(a)}`))})},[v,U,V,Q,z,g,h]),oe=mo({componentName:"MultiAxisLineChart",data:l,accessors:{xAccessor:h}}),re=z?[0,1]:void 0,ie=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"line"},null!=l&&{data:K}),{xAccessor:h,yAccessor:fr,groupAccessor:pr,lineStyle:te,colorScheme:V,size:[T,B],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:J.margin,showAxes:s.showAxes}),Z&&{axes:Z}),{xLabel:$}),z?{}:{yLabel:U[0]}),{xFormat:d}),z&&re&&{yExtent:re}),{enableHover:N}),t.pointIdAccessor&&{pointIdAccessor:t.pointIdAccessor}),{showGrid:D,curve:y}),J.legendBehaviorProps),R&&{title:R}),H&&{description:H}),W&&{summary:W}),void 0!==F&&{accessibleTable:F}),u&&{className:u}),{tooltipContent:ne}),b&&{annotations:b}),(w||A||S||O)&&{customHoverBehavior:J.customHoverBehavior}),(A||S||w)&&{customClickBehavior:J.customClickBehavior}),J.crosshairProps),x);return G||q||(oe?p.createElement(uo,{componentName:"MultiAxisLineChart",message:oe,width:T,height:B}):p.createElement(Ho,{componentName:"MultiAxisLineChart",width:T,height:B},p.createElement(gn,Object.assign({ref:i},ie))))});function br(e,t){const{columns:n,config:o,resolvePieceStyle:r}=e,i=[],a=Math.min(t.width,t.height)/2-4,s="donut"===o.chartType?o.innerRadius||60:0,l=-Math.PI/2+(o.startAngle||0)*Math.PI/180,c=null!=o.sweepAngle?o.sweepAngle*Math.PI/180:2*Math.PI;for(const e of Object.values(n)){const t=l+e.pctStart*c,n=l+(e.pctStart+e.pct)*c,u=r(e.pieceData[0],e.name);i.push(Object.assign(Object.assign({type:"wedge",cx:0,cy:0,innerRadius:s,outerRadius:a,startAngle:t,endAngle:n},o.cornerRadius&&{cornerRadius:o.cornerRadius}),{style:u,datum:e.pieceData,category:e.name}))}return i}function xr(e){var t,n,o;const r=e.length,i=e[0],s=e[r-1];return{n:r,min:i,q1:null!==(t=a.quantile(e,.25))&&void 0!==t?t:i,median:null!==(n=a.quantile(e,.5))&&void 0!==n?n:(i+s)/2,q3:null!==(o=a.quantile(e,.75))&&void 0!==o?o:s,max:s,mean:e.reduce((e,t)=>e+t,0)/r}}vr.displayName="MultiAxisLineChart";const kr={bar:function(e,t){var n;const{scales:o,columns:r,config:i,getR:a,getStack:s,resolvePieceStyle:l}=e,{r:c,projection:u}=o,d=[],h="vertical"===u,g="horizontal"===u,f=i.normalize,p=[];if(s){const e=new Set;for(const t of Object.values(r))for(const n of t.pieceData){const t=s(n);e.has(t)||(e.add(t),p.push(t))}}else p.push("_default");for(const e of Object.values(r)){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+=a(n),o.pieces.push(n)}let n=0;if(f)for(const e of t.values())n+=Math.abs(e.total);let o=0,r=0;for(const i of p){const a=t.get(i);if(!a)continue;let u=a.total;f&&n>0&&(u/=n);const p=l(a.pieces[0],s?i:e.name),y=Object.assign(Object.assign({},a.pieces[0]),{__aggregateValue:a.total,__pieceCount:a.pieces.length,category:e.name});if(h){const t=c(0>u?r:o+u),n=0>u?c(r+u)-c(r):c(o)-c(o+u);d.push(Y(e.x,t,e.width,Math.abs(n),p,y,i)),0>u?r+=u:o+=u}else if(g){const t=c(0>u?r+u:o),n=0>u?c(r)-c(r+u):c(o+u)-c(o);d.push(Y(t,e.x,Math.abs(n),e.width,p,y,i)),0>u?r+=u:o+=u}}}if(i.roundedTop&&i.roundedTop>0){const e=Math.max(0,i.roundedTop),t=new Map;for(const e of d){if("rect"!==e.type)continue;const o=(null===(n=e.datum)||void 0===n?void 0:n.category)||"";t.has(o)||t.set(o,[]),t.get(o).push(e)}const o="vertical"===u;for(const n of t.values()){if(0===n.length)continue;const t=n.filter(e=>{var t,n;return(null!==(n=null===(t=e.datum)||void 0===t?void 0:t.__aggregateValue)&&void 0!==n?n:0)>=0}),r=n.filter(e=>{var t,n;return 0>(null!==(n=null===(t=e.datum)||void 0===t?void 0:t.__aggregateValue)&&void 0!==n?n:0)});if(t.length>0){const n=t.reduce(o?(e,t)=>t.y>e.y?e:t:(e,t)=>e.x+e.w>t.x+t.w?e:t);n.roundedTop=e,n.roundedEdge=o?"top":"right"}if(r.length>0){const t=r.reduce(o?(e,t)=>e.y+e.h>t.y+t.h?e:t:(e,t)=>t.x>e.x?e:t);t.roundedTop=e,t.roundedEdge=o?"bottom":"left"}}}return d},clusterbar:function(e,t){const{scales:n,columns:o,config:r,getR:i,getGroup:a,resolvePieceStyle:s}=e,{r:l,projection:c}=n,u=[],d="vertical"===c,h=[],g=new Set;for(const e of Object.values(o))for(const t of e.pieceData){const e=a?a(t):"_default";g.has(e)||(g.add(e),h.push(e))}const f=h.length||1;for(const e of Object.values(o)){const t=e.width/f,n=.2*t,o=t-n,r=new Map;for(const t of e.pieceData){const e=a?a(t):"_default";r.has(e)||r.set(e,[]),r.get(e).push(t)}for(let a=0;h.length>a;a++){const c=r.get(h[a])||[];for(const r of c){const c=i(r),g=s(r,h[a]);if(d){const i=e.x+a*t+n/2,s=l(0),d=l(c);u.push(Y(i,Math.min(s,d),o,Math.abs(s-d),g,r,h[a]))}else{const i=e.x+a*t+n/2,s=l(0),d=l(c);u.push(Y(Math.min(s,d),i,Math.abs(d-s),o,g,r,h[a]))}}}}if(r.roundedTop&&r.roundedTop>0){const e=Math.max(0,r.roundedTop);for(const t of u){if("rect"!==t.type)continue;const n=i(t.datum);t.roundedTop=e,t.roundedEdge=d?0>n?"bottom":"top":0>n?"left":"right"}}return u},point:function(e,t){var n,o;const{scales:r,columns:i,getR:a,multiScales:s,resolvePieceStyle:l}=e,{r:c,projection:u}=r,d=[],h="vertical"===u,g="radial"===u,f=s.length>0,p=2*Math.PI,y=-Math.PI/2;for(const e of Object.values(i))for(const t of e.pieceData){const r=null!==(n=t.__rIndex)&&void 0!==n?n:0,i=null!==(o=t.__rValue)&&void 0!==o?o:a(t),u=f&&s[r]||c,m=l(t,e.name),v=m.r||5;let b,x;if(g){const t=y+(e.pctStart+e.pct/2)*p,n=u(i);b=Math.cos(t)*n,x=Math.sin(t)*n}else h?(b=e.middle,x=u(i)):(b=u(i),x=e.middle);d.push({type:"point",x:b,y:x,r:v,style:m,datum:t})}return d},swarm:function(e,t){const{scales:n,columns:o,getR:r,resolvePieceStyle:i}=e,{r:a,projection:s}=n,l=[],c="vertical"===s;for(const e of Object.values(o)){const t=e.width/2;for(let n=0;e.pieceData.length>n;n++){const o=e.pieceData[n],s=r(o),u=i(o,e.name),d=u.r||4,h=(7919*n%100/100-.5)*t*.8,g=c?e.middle+h:a(s),f=c?a(s):e.middle+h;l.push({type:"point",x:g,y:f,r:d,style:u,datum:o})}}return l},pie:br,donut:br,boxplot:function(e,t){var n,o,r,i,s;const{scales:l,columns:c,config:u,getR:d,resolveSummaryStyle:h}=e,{r:g,projection:f}=l,p=[],y="vertical"===f,m=!1!==u.showOutliers;for(const e of Object.values(c)){const t=e.pieceData.map(e=>d(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(0===t.length)continue;const l=t[0],c=t[t.length-1],u=null!==(n=a.quantile(t,.25))&&void 0!==n?n:l,f=null!==(o=a.quantile(t,.5))&&void 0!==o?o:(l+c)/2,v=null!==(r=a.quantile(t,.75))&&void 0!==r?r:c,b=v-u,x=u-1.5*b,k=v+1.5*b,w=null!==(i=t.find(e=>e>=x))&&void 0!==i?i:l,A=null!==(s=[...t].reverse().find(e=>k>=e))&&void 0!==s?s:c,S=h(e.pieceData[0],e.name),O=[];if(m)for(const t of e.pieceData){const n=d(t);if(x>n||n>k){const o=y?e.middle:g(n),r=y?g(n):e.middle;O.push({px:o,py:r,value:n,datum:t})}}if(p.push({type:"boxplot",x:y?e.middle:0,y:y?0:e.middle,projection:y?"vertical":"horizontal",columnWidth:.6*e.width,minPos:g(w),q1Pos:g(u),medianPos:g(f),q3Pos:g(v),maxPos:g(A),stats:{n:t.length,min:w,q1:u,median:f,q3:v,max:A,mean:t.reduce((e,t)=>e+t,0)/t.length},style:S,datum:e.pieceData,category:e.name,outliers:O}),m)for(const e of O)p.push({type:"point",x:e.px,y:e.py,r:3,style:{fill:S.fill||"#999",opacity:.6},datum:e.datum})}return p},violin:function(e,t){var n,o,r;const{scales:i,columns:s,config:l,getR:c,resolveSummaryStyle:u}=e,{r:d,projection:h}=i,g=[],f="vertical"===h,p=l.bins||20,y=!1!==l.showIQR;for(const e of Object.values(s)){const t=e.pieceData.map(e=>c(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const i=t[0],s=t[t.length-1],l=(s-i)/p||1,h=Array(p).fill(0);for(const e of t)h[Math.min(Math.floor((e-i)/l),p-1)]++;const m=Math.max(...h,1),v=e.width/2*.9;let b="";if(f){b=`M ${e.middle} ${d(i)}`;for(let t=0;p>t;t++){const n=d(i+(t+.5)*l);b+=` L ${e.middle+h[t]/m*v} ${n}`}b+=` L ${e.middle} ${d(s)}`;for(let t=p-1;t>=0;t--){const n=d(i+(t+.5)*l);b+=` L ${e.middle-h[t]/m*v} ${n}`}b+=" Z"}else{b=`M ${d(i)} ${e.middle}`;for(let t=0;p>t;t++)b+=` L ${d(i+(t+.5)*l)} ${e.middle-h[t]/m*v}`;b+=` L ${d(s)} ${e.middle}`;for(let t=p-1;t>=0;t--)b+=` L ${d(i+(t+.5)*l)} ${e.middle+h[t]/m*v}`;b+=" Z"}const x=u(e.pieceData[0],e.name);let k;if(y&&t.length>=4){const l=null!==(n=a.quantile(t,.25))&&void 0!==n?n:i,c=null!==(o=a.quantile(t,.5))&&void 0!==o?o:(i+s)/2,u=null!==(r=a.quantile(t,.75))&&void 0!==r?r:s;k={q1Pos:d(l),medianPos:d(c),q3Pos:d(u),centerPos:e.middle,isVertical:f}}const w=f?{x:e.x,y:Math.min(d(s),d(i)),width:e.width,height:Math.abs(d(s)-d(i))}:{x:Math.min(d(i),d(s)),y:e.x,width:Math.abs(d(s)-d(i)),height:e.width};g.push({type:"violin",pathString:b,translateX:0,translateY:0,bounds:w,iqrLine:k,stats:xr(t),style:x,datum:e.pieceData,category:e.name})}return g},histogram:function(e,t){var n;const{scales:o,columns:r,config:i,getR:a,resolveSummaryStyle:s}=e,{r:l}=o,c=[],u=i.bins||25,d=i.normalize,h=null===(n=l.domain)||void 0===n?void 0:n.call(l),g=h?+h[0]:void 0,f=h?+h[1]:void 0;for(const e of Object.values(r)){const t=e.pieceData.map(e=>a(e)).filter(e=>null!=e&&!isNaN(e));if(0===t.length)continue;const n=null!=g&&isFinite(g)?g:Math.min(...t),o=null!=f&&isFinite(f)?f:Math.max(...t),r=(o-n)/u||1,i=Array(u).fill(0);for(const e of t)n>e||e>o||i[Math.min(Math.floor((e-n)/r),u-1)]++;const h=t.length,p=Math.max(...i,1),y=s(e.pieceData[0],e.name);for(let t=0;u>t;t++){if(0===i[t])continue;const o=(d?i[t]/h:i[t]/p)*e.width*.9,a=l(n+t*r),s=l(n+(t+1)*r);c.push(Y(Math.min(a,s),e.x+e.width-o,Math.abs(s-a),o,y,{bin:t,count:i[t],range:[n+t*r,n+(t+1)*r],category:e.name},e.name))}}return c},ridgeline:function(e,t){var n;const{scales:o,columns:r,config:i,getR:a,resolveSummaryStyle:s}=e,{r:l,projection:c}=o,u=[],d=i.bins||20,h="horizontal"===c,g=i.amplitude||1.5;for(const e of Object.values(r)){const t=e.pieceData.map(e=>a(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const o=t[0],r=t[t.length-1],i=(r-o)/d||1,c=Array(d).fill(0);for(const e of t)o>e||e>r||c[Math.min(Math.floor((e-o)/i),d-1)]++;const f=Math.max(...c,1),p=s(e.pieceData[0],e.name),y=e.width*g;let m="";if(h){const t=e.x+e.width;m=`M ${l(o)} ${t}`;for(let e=0;d>e;e++)m+=` L ${l(o+(e+.5)*i)} ${t-c[e]/f*y}`;m+=` L ${l(r)} ${t} Z`}else{const t=e.x;m=`M ${t} ${l(o)}`;for(let e=0;d>e;e++){const n=l(o+(e+.5)*i);m+=` L ${t+c[e]/f*y} ${n}`}m+=` L ${t} ${l(r)} Z`}const v=h?{x:Math.min(l(o),l(r)),y:e.x,width:Math.abs(l(r)-l(o)),height:e.width}:{x:e.x,y:Math.min(l(r),l(o)),width:e.width,height:Math.abs(l(r)-l(o))};u.push({type:"violin",pathString:m,translateX:0,translateY:0,bounds:v,stats:xr(t),style:Object.assign(Object.assign({},p),{fillOpacity:null!==(n=p.fillOpacity)&&void 0!==n?n:.5}),datum:e.pieceData,category:e.name})}return u},timeline:function(e,t){const{scales:n,columns:o,getRawRange:r,resolvePieceStyle:i}=e,{r:a,projection:s}=n,l=[],c="horizontal"===s;for(const e of Object.values(o))for(const t of e.pieceData){const n=r(t);if(!n)continue;const[o,s]=n,u=i(t,e.name);if(c){const n=a(Math.min(o,s)),r=a(Math.max(o,s));l.push(Y(n,e.x,r-n,e.width,u,t,e.name))}else{const n=a(Math.max(o,s)),r=a(Math.min(o,s));l.push(Y(e.x,n,e.width,r-n,u,t,e.name))}}return l},funnel:function(e,t){var n,r,i,a,s,l,c;const{columns:u,getR:d,getStack:h,resolvePieceStyle:g}=e,f=[],p=t.width/2,y=!1!==e.config.showLabels,m=e.scales.o.domain().map(e=>u[e]).filter(Boolean);if(0===m.length)return f;const v=[],b=new Set;for(const e of m)for(const t of e.pieceData){const e=h?h(t):"_default";b.has(e)||(b.add(e),v.push(e))}const x=v.length>1&&"_default"!==v[0],k=[];let w=0;for(const e of m){const t=new Map;let n=0;for(const o of e.pieceData){const e=h?h(o):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const r=t.get(e),i=d(o);r.total+=i,r.pieces.push(o),n+=i}k.push({col:e,groups:t,stepTotal:n}),x||n>w&&(w=n)}if(x)for(const e of k){let t=0,n=0;for(let o=0;v.length>o;o++){const r=e.groups.get(v[o]);r&&(o%2==0?t+=r.total:n+=r.total)}const o=Math.max(t,n);o>w&&(w=o)}if(0===w)return f;const A=new Map;for(const e of v){const t=k[0].groups.get(e);A.set(e,null!==(n=null==t?void 0:t.total)&&void 0!==n?n:0)}const S=k[0].stepTotal,O=x?.95*p:.9*t.width,E=o.scaleLinear().domain([0,w]).range([0,O]),M=null!==(r=e.config.connectorOpacity)&&void 0!==r?r:.3;let j=new Map;for(let e=0;k.length>e;e++){const t=k[e],n=t.col,o=0===e,r=n.width,u=.55*r,d=n.x+(r-u)/2,h=new Map;if(x){let e=0;for(const n of v){const o=t.groups.get(n);o&&(e+=E(o.total))}let r=p,i=p;for(let a=0;v.length>a;a++){const l=v[a],c=t.groups.get(l);if(!c)continue;const m=E(c.total),b=a%2==0,x=b?r:i-m;b?r+=m:i-=m;const k=g(c.pieces[0],l),w=null!==(s=A.get(l))&&void 0!==s?s:c.total,S=w>0?c.total/w*100:0,O=Object.assign(Object.assign({},c.pieces[0]),{__funnelValue:c.total,__funnelPercent:S,__funnelStep:n.name,__funnelIsFirstStep:o,__aggregateValue:c.total,__pieceCount:c.pieces.length,category:l});y&&(0===a&&(O.__funnelStepLabel=n.name,O.__funnelStepLabelX=p,O.__funnelStepLabelY=d,O.__funnelRowWidth=e),O.__funnelValueLabelX=x+m/2,O.__funnelValueLabelY=d,O.__funnelBarW=m),f.push(Y(x,d,m,u,k,O,l)),h.set(l,{x:x,y:d,w:m,h:u})}}else{const e=t.stepTotal,r=E(e),s=p-r/2,l=v[0],c="_default"!==l,m=null!==(a=null===(i=t.groups.get(l))||void 0===i?void 0:i.pieces[0])&&void 0!==a?a:n.pieceData[0],b=c?l:n.name,x=g(m,b),k=S>0?e/S*100:0,w=Object.assign(Object.assign({},m),{__funnelValue:e,__funnelPercent:k,__funnelStep:n.name,__funnelIsFirstStep:o,category:c?l:n.name});y&&(w.__funnelStepLabel=n.name,w.__funnelStepLabelX=p,w.__funnelStepLabelY=d,w.__funnelRowWidth=r,w.__funnelValueLabelX=p,w.__funnelValueLabelY=d,w.__funnelBarW=r),f.push(Y(s,d,r,u,x,w,b)),h.set(l,{x:s,y:d,w:r,h:u})}if(e>0&&j.size>0){const e=x?v:[v[0]];for(const o of e){const e=j.get(o),r=h.get(o);if(!e||!r)continue;const i=(()=>{const e=t.groups.get(o);return g(e?e.pieces[0]:n.pieceData[0],"_default"===o?n.name:o)})(),a={type:"trapezoid",points:[[e.x,e.y+e.h],[e.x+e.w,e.y+e.h],[r.x+r.w,r.y],[r.x,r.y]],style:{fill:i.fill||"#999",opacity:M},datum:null!==(c=null===(l=t.groups.get(o))||void 0===l?void 0:l.pieces[0])&&void 0!==c?c:n.pieceData[0],category:"_default"===o?n.name:o};f.push(a)}}j=h}return f},"bar-funnel":function(e,t){var n,o,r,i;const{columns:a,getR:s,getStack:l,resolvePieceStyle:c,scales:u}=e,d=[],h=u.o.domain().map(e=>a[e]).filter(Boolean);if(0===h.length)return d;const g=[],f=new Set;for(const e of h)for(const t of e.pieceData){const e=l?l(t):"_default";f.has(e)||(f.add(e),g.push(e))}const p=g.length>1&&"_default"!==g[0],y=[];for(const e of h){const t=new Map;let n=0;for(const o of e.pieceData){const e=l?l(o):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const r=t.get(e),i=s(o);r.total+=i,r.pieces.push(o),n+=i}y.push({col:e,groups:t,stepTotal:n})}const m=new Map;for(const e of g){const t=null===(n=y[0])||void 0===n?void 0:n.groups.get(e);m.set(e,null!==(o=null==t?void 0:t.total)&&void 0!==o?o:0)}const v=u.r,b=p?g.length:1,x=p?.15:0;for(let e=0;y.length>e;e++){const t=y[e],n=t.col,o=0===e,a=e>0?y[e-1]:null,s=n.width/b,l=s*x,u=s-l;for(let e=0;g.length>e;e++){const h=g[e],f=t.groups.get(h);if(!f)continue;const y=f.total,b=null!==(r=m.get(h))&&void 0!==r?r:y,x=b>0?y/b*100:0,k=null==a?void 0:a.groups.get(h),w=null!==(i=null==k?void 0:k.total)&&void 0!==i?i:y,A=o?0:Math.max(0,w-y),S=n.x+e*s+l/2,O=v(y),E=v(0)-O,M=c(f.pieces[0],p?h:n.name),j=Object.assign(Object.assign({},f.pieces[0]),{__barFunnelValue:y,__barFunnelPercent:x,__barFunnelIsFirstStep:o,__barFunnelIsDropoff:!1,__barFunnelStep:n.name,__barFunnelDropoffValue:A,__barFunnelCategory:"_default"===h?void 0:h,category:p?h:n.name,__barFunnelLabelX:S+u/2,__barFunnelLabelY:v(y+A)});if(d.push(Y(S,O,u,E,M,j,p?h:n.name)),A>0){const e=v(y+A),t=O-e,o=Object.assign({},M),r=Object.assign(Object.assign({},f.pieces[0]),{__barFunnelValue:A,__barFunnelPercent:b>0?A/b*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:n.name,__barFunnelCategory:"_default"===h?void 0:h,category:p?h:n.name});d.push(Y(S,e,u,t,o,r,p?h:n.name))}}}return d},swimlane:function(e,t){const{scales:n,columns:o,getR:r,getStack:i,resolvePieceStyle:a}=e,{r:s,projection:l}=n,c=[],u="horizontal"===l;for(const e of Object.values(o)){let t=0;for(const n of e.pieceData){const o=Math.abs(r(n));if(0===o)continue;const l=i?i(n):e.name,d=a(n,l);if(u){const r=s(t),i=s(t+o);c.push(Y(r,e.x,i-r,e.width,d,n,l))}else{const r=s(t+o),i=s(t);c.push(Y(e.x,r,e.width,i-r,d,n,l))}t+=o}}return c}};class wr{constructor(e){this.rExtent=new w,this.rExtents=[],this.rAccessors=[],this.categories=new Set,this._hasStreamingData=!1,this._colorSchemeMap=null,this._colorSchemeIndex=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.version=0,this.config=e,this.buffer=new k(e.windowSize),this.getO=M(e.oAccessor||e.categoryAccessor,"category");const t="streaming"===e.runtimeMode,n=e.rAccessor;Array.isArray(n)?(this.rAccessors=n.map(e=>O(e,"value")),this.getR=this.rAccessors[0],this.rExtents=n.map(()=>new w)):(this.getR=O(t&&(e.timeAccessor||e.valueAccessor)&&e.valueAccessor||n,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=M(e.stackBy),this.getGroup=M(e.groupBy),this.getColor=M(e.colorAccessor),this.getConnector=M(e.connectorAccessor),this.getDataId=M(e.dataIdAccessor),e.pulse&&(this.timestampBuffer=new k(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{this._hasStreamingData=!0;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 r=n.toArray(),i=t.projection||"vertical",a=t.oExtent||this.resolveCategories(r),s=this.computeValueDomain(r,a),l="horizontal"===i,c=null!=t.barPadding?t.barPadding/("vertical"===i?e.width:e.height):.1;let u,d;if("radial"===i){u=o.scaleBand().domain(a).range([0,1]).padding(0);const n=Math.min(e.width,e.height)/2,r=t.innerRadius||0;d=o.scaleLinear().domain(s).range([r,n])}else l?(u=o.scaleBand().domain(a).range([0,e.height]).padding(c),d=o.scaleLinear().domain(s).range([0,e.width])):(u=o.scaleBand().domain(a).range([0,e.width]).padding(c),d=o.scaleLinear().domain(s).range([e.height,0]));this.scales={o:u,r:d,projection:i},this.multiScales=this.rAccessors.length>1&&t.multiAxis?this.rAccessors.map((r,i)=>{var a;const s=this.rExtents[i];s.dirty&&s.recalculate(n,r);let[c,u]=s.extent;c===1/0&&(c=0,u=1);const d=null!==(a=t.extentPadding)&&void 0!==a?a:.05,h=u-c,g=h>0?h*d:1;return c-=g,u+=g,c>0&&(c=0),l?o.scaleLinear().domain([c,u]).range([0,e.width]):o.scaleLinear().domain([c,u]).range([e.height,0])}):[];let h=r;this.rAccessors.length>1&&(h=r.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(h,a,u,i,e),this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(h,e),this.config.decay&&this.applyDecay(this.scene,r),this.config.pulse&&this.applyPulse(this.scene,r),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||this._hasStreamingData)&&void 0===n){const n=new Set;for(const t of e)n.add(this.getO(t));const o=Math.max(50,3*n.size);if(this.categories.size>o){let e=this.categories.size-o;for(const t of this.categories){if(0>=e)break;n.has(t)||(this.categories.delete(t),e--)}}return t.filter(e=>n.has(e))}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,r,i,a;const s=this.config.chartType,l=null!==(n=this.config.extentPadding)&&void 0!==n?n:.05;if("radial"===this.config.projection&&("pie"===s||"donut"===s))return[0,1];let c=0,u=0;if("bar"===s&&this.getStack&&this.config.normalize)c=0,u=1;else if("bar"===s&&this.getStack){const t=new Map,n=new Map;for(const o of e){const e=this.getO(o),r=this.getR(o);0>r?n.set(e,(n.get(e)||0)+r):t.set(e,(t.get(e)||0)+r)}for(const e of t.values())e>u&&(u=e);for(const e of n.values())c>e&&(c=e)}else if("bar"===s){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>u&&(u=e),c>e&&(c=e)}else if("swimlane"===s){const t=new Map;for(const n of e){const e=this.getO(n),o=Math.abs(this.getR(n));t.set(e,(t.get(e)||0)+o)}for(const e of t.values())e>u&&(u=e)}else if("clusterbar"===s||"bar-funnel"===s)for(const t of e){const e=this.getR(t);e>u&&(u=e),c>e&&(c=e)}else{const e=this.rExtent.extent[0],t=this.rExtent.extent[1];e!==1/0&&(c=e),t!==-1/0&&(u=t)}this.config.rExtent&&(null!=this.config.rExtent[0]&&(c=this.config.rExtent[0]),null!=this.config.rExtent[1]&&(u=this.config.rExtent[1]));const d="bar"===s||"clusterbar"===s||"bar-funnel"===s||"swimlane"===s;if(d&&null==(null===(o=this.config.rExtent)||void 0===o?void 0:o[0])&&null==(null===(r=this.config.rExtent)||void 0===r?void 0:r[1])&&(c>0&&(c=0),0>u&&(u=0)),"bar-funnel"!==s){const e=u-c,t=e>0?e*l:1;null!=(null===(i=this.config.rExtent)||void 0===i?void 0:i[0])||d&&!this.config.baselinePadding&&0===c||(c-=t),null!=(null===(a=this.config.rExtent)||void 0===a?void 0:a[1])||d&&!this.config.baselinePadding&&0===u||"swimlane"===s||(u+=t)}return[c,u]}buildColumns(e,t,n,o,r){var i;const a={},s=new Map;for(const t of e){const e=this.getO(t);s.has(e)||s.set(e,[]),s.get(e).push(t)}let l=0;if("radial"===o)for(const t of e)l+=Math.abs(this.getR(t));const c=this.config.dynamicColumnWidth;let u=null;if(c&&"radial"!==o){u=new Map;let e=0;for(const n of t){const t=s.get(n)||[];let o;o="string"==typeof c?t.reduce((e,t)=>e+(Number(t[c])||0),0):c(t),u.set(n,o),e+=o}const i=("horizontal"===o?r.height:r.width)-n.padding()*n.step()*t.length;if(e>0)for(const[t,n]of u)u.set(t,n/e*i)}let d=0,h=0;for(const e of t){const t=s.get(e)||[],o=t.reduce((e,t)=>e+Math.abs(this.getR(t)),0),r=l>0?o/l:0;let c,g;u?(c=h,g=u.get(e)||n.bandwidth(),h+=g+n.padding()*n.step()):(c=null!==(i=n(e))&&void 0!==i?i:0,g=n.bandwidth()),a[e]={name:e,x:c,y:0,width:g,middle:c+g/2,padding:n.padding()*n.step(),pieceData:t,pct:r,pctStart:d},d+=r}return a}getSceneContext(){return{scales:this.scales,columns:this.columns,config:this.config,getR:this.getR,getStack:this.getStack,getGroup:this.getGroup,getColor:this.getColor,getConnector:this.getConnector,getO:this.getO,multiScales:this.multiScales,rAccessors:this.rAccessors,resolvePieceStyle:(e,t)=>this.resolvePieceStyle(e,t),resolveSummaryStyle:(e,t)=>this.resolveSummaryStyle(e,t),getRawRange:e=>this.getRawRange(e)}}buildSceneNodes(e,t){if(!this.scales)return[];const n=this.getSceneContext(),o=kr[this.config.chartType];let r=o?o(n,t):[];if(this.getConnector&&this.scales){const e=function(e,t){const{scales:n,config:o,getConnector:r,getO:i}=e;if(!r||!n)return[];const a=[],{projection:s}=n,l=new Map;for(const e of t){if("point"!==e.type&&"rect"!==e.type)continue;const t=e.datum;if(!t)continue;const n=r(t);if(!n)continue;let o,a;"point"===e.type?(o=e.x,a=e.y):(o=e.x+e.w/2,a=e.y+("vertical"===s?0:e.h/2)),l.has(n)||l.set(n,[]),l.get(n).push({x:o,y:a,datum:t,category:i(t)})}const c=n.o.domain(),u=o.connectorStyle;for(const[e,t]of l)if(t.length>=2){t.sort((e,t)=>c.indexOf(e.category)-c.indexOf(t.category));for(let n=0;t.length-1>n;n++){const o=t[n],r=t[n+1],i="function"==typeof u?u(o.datum):u||{stroke:"#999",strokeWidth:1,opacity:.5};a.push({type:"connector",x1:o.x,y1:o.y,x2:r.x,y2:r.y,style:i,datum:o.datum,group:e})}}return a}(n,r);r=[...e,...r]}return r}resolvePieceStyle(e,t){if("function"==typeof this.config.pieceStyle){const n=this.config.pieceStyle(e,t);return n&&!n.fill&&t?Object.assign(Object.assign({},n),{fill:this.getColorFromScheme(t)}):n}return 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:P,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){const n=this.config.decay;return n&&t>1?D(n,e,t):1}applyDecay(e,t){var n,o;if(!this.config.decay)return;const r=t.length;if(1>=r)return;const i=new Map;for(let e=0;t.length>e;e++)i.set(t[e],e);for(const t of e){if("connector"===t.type||"violin"===t.type||"boxplot"===t.type||"wedge"===t.type)continue;const e=i.get(t.datum);if(null==e)continue;const a=this.computeDecayOpacity(e,r),s=null!==(o=null===(n=t.style)||void 0===n?void 0:n.opacity)&&void 0!==o?o:1;t.style=Object.assign(Object.assign({},t.style),{opacity:s*a})}}applyPulse(e,t){var n,o,r;if(!this.config.pulse||!this.timestampBuffer)return;const i="undefined"!=typeof performance?performance.now():Date.now(),a=null!==(n=this.config.pulse.duration)&&void 0!==n?n:500,s=null!==(o=this.config.pulse.color)&&void 0!==o?o:"rgba(255,255,255,0.6)",l=null!==(r=this.config.pulse.glowRadius)&&void 0!==r?r:4,c=new Map;for(let e=0;t.length>e;e++)c.set(t[e],e);for(const n of e){if("connector"===n.type||"violin"===n.type||"boxplot"===n.type)continue;if("wedge"===n.type){const e=n.category;if(!e)continue;let o=0;for(let n=0;t.length>n;n++){const r=t[n],s=this.config.oAccessor;if(("function"==typeof s?s(r):r[s||"category"])!==e)continue;const l=this.timestampBuffer.get(n);if(null==l)continue;const c=i-l;if(a>c){const e=1-c/a;e>o&&(o=e)}}o>0&&(n._pulseIntensity=o,n._pulseColor=s);continue}const e=c.get(n.datum);if(null==e)continue;const o=this.timestampBuffer.get(e);if(null==o)continue;const r=i-o;a>r&&(n._pulseIntensity=1-r/a,n._pulseColor=s,n._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}getNodeKey(e,t){var n,o;if("point"===e.type){const n=`p:${e.datum?this.getO(e.datum):""}:${e.datum?this.getR(e.datum):0}`,o=t.get(n)||0;return t.set(n,o+1),`${n}:${o}`}return"rect"===e.type?`r:${e.group||""}:${null!==(o=null===(n=e.datum)||void 0===n?void 0:n.category)&&void 0!==o?o:""}`:null}snapshotPositions(){this.prevPositionMap.clear();const e=new Map;for(let t=0;this.scene.length>t;t++){const n=this.scene[t],o=this.getNodeKey(n,e);o&&("point"===n.type?this.prevPositionMap.set(o,{x:n.x,y:n.y,r:n.r,opacity:n.style.opacity}):"rect"===n.type&&this.prevPositionMap.set(o,{x:n.x,y:n.y,w:n.w,h:n.h,opacity:n.style.opacity}))}}startTransition(){var e,t,n,o,r,i,a,s,l,c,u,d;if(!this.config.transition||0===this.prevPositionMap.size)return;const h=null!==(e=this.config.transition.duration)&&void 0!==e?e:300;if(this.exitNodes.length>0){const e=new Set(this.exitNodes);this.scene=this.scene.filter(t=>!e.has(t)),this.exitNodes=[]}let g=!1;const f=new Set,p=new Map;for(let e=0;this.scene.length>e;e++){const s=this.scene[e],l=this.getNodeKey(s,p);if(!l)continue;s._transitionKey=l;const c=this.prevPositionMap.get(l);"point"===s.type?c?(f.add(l),s._targetOpacity=null!==(t=s.style.opacity)&&void 0!==t?t:1,c.x===s.x&&c.y===s.y||(s._targetX=s.x,s._targetY=s.y,s.x=c.x,s.y=c.y,g=!0)):(s._targetOpacity=null!==(n=s.style.opacity)&&void 0!==n?n:1,s.style=Object.assign(Object.assign({},s.style),{opacity:0}),g=!0):"rect"===s.type&&(c?(f.add(l),s._targetOpacity=null!==(o=s.style.opacity)&&void 0!==o?o:1,c.x===s.x&&c.y===s.y&&c.w===s.w&&c.h===s.h||(s._targetX=s.x,s._targetY=s.y,s._targetW=s.w,s._targetH=s.h,s.x=c.x,s.y=c.y,s.w=null!==(r=c.w)&&void 0!==r?r:s.w,s.h=null!==(i=c.h)&&void 0!==i?i:s.h,g=!0)):(s._targetOpacity=null!==(a=s.style.opacity)&&void 0!==a?a:1,s.style=Object.assign(Object.assign({},s.style),{opacity:0}),g=!0))}this.exitNodes=[];for(const[e,t]of this.prevPositionMap)f.has(e)||(e.startsWith("p:")?this.exitNodes.push({type:"point",x:t.x,y:t.y,r:null!==(s=t.r)&&void 0!==s?s:3,style:{opacity:null!==(l=t.opacity)&&void 0!==l?l:1},datum:null,_targetOpacity:0,_transitionKey:e}):e.startsWith("r:")&&this.exitNodes.push({type:"rect",x:t.x,y:t.y,w:null!==(c=t.w)&&void 0!==c?c:0,h:null!==(u=t.h)&&void 0!==u?u:0,style:{opacity:null!==(d=t.opacity)&&void 0!==d?d:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e}),g=!0);this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),g&&(this.activeTransition={startTime:F(),duration:h})}advanceTransition(e){var t,n,o;if(!this.activeTransition)return!1;const r=H(e,this.activeTransition),i=R(r,"linear"===(null===(t=this.config.transition)||void 0===t?void 0:t.easing)?"linear":"ease-out-cubic");for(const e of this.scene){const t=e._transitionKey;if(t)if("point"===e.type){if(void 0!==e._targetOpacity){const o=this.prevPositionMap.get(t),r=o?null!==(n=o.opacity)&&void 0!==n?n:1:0;e.style.opacity=W(r,e._targetOpacity,i)}if(void 0===e._targetX)continue;const o=this.prevPositionMap.get(t);if(!o)continue;e.x=W(o.x,e._targetX,i),e.y=W(o.y,e._targetY,i)}else if("rect"===e.type){if(void 0!==e._targetOpacity){const n=this.prevPositionMap.get(t),r=n?null!==(o=n.opacity)&&void 0!==o?o:1:0;e.style.opacity=W(r,e._targetOpacity,i)}if(void 0===e._targetX)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=W(n.x,e._targetX,i),e.y=W(n.y,e._targetY,i),void 0!==n.w&&(e.w=W(n.w,e._targetW,i),e.h=W(n.h,e._targetH,i))}}if(r>=1){for(const e of this.scene)if(void 0!==e._targetOpacity&&(e.style=Object.assign(Object.assign({},e.style||{}),{opacity:0===e._targetOpacity?0:e._targetOpacity}),e._targetOpacity=void 0),"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}if(this.exitNodes.length>0){const e=new Set(this.exitNodes);this.scene=this.scene.filter(t=>!e.has(t)),this.exitNodes=[]}return this.activeTransition=null,!1}return!0}getData(){return this.buffer.toArray()}remove(e){if(!this.getDataId)throw Error("remove() requires dataIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const t=new Set(Array.isArray(e)?e:[e]),n=this.getDataId,o=e=>t.has(n(e));if(this.timestampBuffer&&this.timestampBuffer.size>0){const e=this.timestampBuffer.toArray(),t=new Set;this.buffer.forEach((e,n)=>{o(e)&&t.add(n)}),this.timestampBuffer.clear();for(let n=0;e.length>n;n++)t.has(n)||this.timestampBuffer.push(e[n])}const r=this.buffer.remove(o);if(0===r.length)return r;for(const e of r)this.evictValueExtent(e);return this.categories.clear(),this.buffer.forEach(e=>this.categories.add(this.getO(e))),this.version++,r}update(e,t){if(!this.getDataId)throw Error("update() requires dataIdAccessor to be configured");const n=new Set(Array.isArray(e)?e:[e]),o=this.getDataId,r=new Set;this.buffer.forEach((e,t)=>{n.has(o(e))&&r.add(t)});const i=this.buffer.update(e=>n.has(o(e)),t);if(0===i.length)return i;for(const e of i)this.evictValueExtent(e);return this.categories.clear(),this.buffer.forEach((e,t)=>{this.categories.add(this.getO(e)),r.has(t)&&this.pushValueExtent(e)}),this.version++,i}clear(){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this._hasStreamingData=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.exitNodes=[],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){const t=Object.assign({},this.config);if(e.colorScheme!==this.config.colorScheme&&(this._colorSchemeMap=null,this._colorSchemeIndex=0),Object.assign(this.config,e),(void 0!==e.oAccessor||void 0!==e.categoryAccessor)&&(S(e.oAccessor||e.categoryAccessor,t.oAccessor||t.categoryAccessor)||(this.getO=M(this.config.oAccessor||this.config.categoryAccessor,"category"),this.categories.clear())),void 0!==e.rAccessor){const n=Array.isArray(e.rAccessor)?e.rAccessor:[e.rAccessor],o=Array.isArray(t.rAccessor)?t.rAccessor:[t.rAccessor];if(n.length!==o.length||n.some((e,t)=>!S(e,o[t]))){const e=this.config.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(e=>O(e,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new w)):(this.getR=O(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in e&&!S(e.stackBy,t.stackBy)&&(this.getStack=null!=this.config.stackBy?M(this.config.stackBy):void 0),"groupBy"in e&&!S(e.groupBy,t.groupBy)&&(this.getGroup=null!=this.config.groupBy?M(this.config.groupBy):void 0),"colorAccessor"in e&&!S(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?M(this.config.colorAccessor):void 0),"connectorAccessor"in e&&!S(e.connectorAccessor,t.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?M(this.config.connectorAccessor):void 0)}}function Ar(e,t,n){const o=J(t,n,e);return o.hit?{datum:e.datum,x:o.cx,y:e.y,distance:0,category:e.group}:null}function Sr(e,t,n,o=30){const r=t-e.x,i=n-e.y,a=Math.sqrt(r*r+i*i);return a>ee(e.r,o)?null:{datum:e.datum,x:e.x,y:e.y,distance:a}}function Or(e,t,n){const o=t-e.cx,r=n-e.cy,i=Math.sqrt(o*o+r*r);if(e.innerRadius>i||i>e.outerRadius)return null;const a=oe(Math.atan2(r,o)),s=oe(e.startAngle),l=oe(e.endAngle);if(!(s>l?a>=s||l>=a:a>=s&&l>=a))return null;const c=(e.startAngle+e.endAngle)/2,u=(e.innerRadius+e.outerRadius)/2;return{datum:e.datum,x:e.cx+Math.cos(c)*u,y:e.cy+Math.sin(c)*u,distance:0,category:e.category}}function Er(e,t,n){const o=e.columnWidth/2;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:e.stats}}else{const r=e.y-o,i=e.y+o;if(!(Math.min(e.minPos,e.maxPos)>t||t>Math.max(e.minPos,e.maxPos)||r>n||n>i))return{datum:e.datum,x:e.medianPos,y:e.y,distance:0,category:e.category,stats:e.stats}}return null}function Mr(e,t,n){if(!e.bounds)return null;const{x:o,y:r,width:i,height:a}=e.bounds;return o>t||t>o+i||r>n||n>r+a?null:{datum:e.datum,x:o+i/2,y:r+a/2,distance:0,category:e.category,stats:e.stats}}function jr(t){const{width:n,height:o,totalWidth:r,totalHeight:i,margin:a,scales:s,showAxes:l,showGrid:c,rFormat:u}=t,{rTickValues:d}=t,h="radial"===(null==s?void 0:s.projection),g="horizontal"===(null==s?void 0:s.projection),f=e.useMemo(()=>!s||h?[]:(d||s.r.ticks(5)).map(e=>({value:e,pixel:s.r(e),label:(u||Cr)(e)})),[s,u,h,d]),y=c&&s&&!h,m=l&&s&&!h;return y||m?p.createElement("svg",{width:r,height:i,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"}},p.createElement("g",{transform:`translate(${a.left},${a.top})`},y&&p.createElement("g",{className:"ordinal-grid"},f.map((e,t)=>p.createElement("line",{key:"grid-"+t,x1:g?e.pixel:0,y1:g?0:e.pixel,x2:g?e.pixel:n,y2:g?o:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),m&&p.createElement(p.Fragment,null,g?p.createElement(p.Fragment,null,p.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),p.createElement("line",{x1:0,y1:o,x2:n,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1})):p.createElement(p.Fragment,null,p.createElement("line",{x1:0,y1:o,x2:n,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),p.createElement("line",{x1:0,y1:0,x2:0,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}))))):null}function Cr(e){return Math.round(100*e)/100+""}function Pr(t){var n,o;const{width:r,height:i,totalWidth:a,totalHeight:s,margin:l,scales:c,showAxes:u,showCategoryTicks:d,oLabel:h,rLabel:g,oFormat:f,rFormat:y,showGrid:m,title:v,legend:b,legendHoverBehavior:x,legendClickBehavior:k,legendHighlightedCategory:w,legendIsolatedCategories:A,legendPosition:S="right",foregroundGraphics:O,annotations:E,svgAnnotationRules:M,xAccessor:j,yAccessor:C,annotationData:P,underlayRendered:L,children:_}=t,T="radial"===(null==c?void 0:c.projection),B="horizontal"===(null==c?void 0:c.projection),N=!1!==d,D=e.useMemo(()=>u&&N&&c&&!T?c.o.domain().map((e,t)=>{var n;return{value:e,pixel:(null!==(n=c.o(e))&&void 0!==n?n:0)+c.o.bandwidth()/2,label:f?f(e,t):e}}):[],[u,N,c,f,T]),I=t.rTickValues,R=t.tickLabelEdgeAlign,H=e.useMemo(()=>u&&c&&!T?(I||c.r.ticks(5)).map(e=>({value:e,pixel:c.r(e),label:(y||Cr)(e)})):[],[u,c,y,T,I]),W=e.useRef(new Map),F=e.useRef(null!==(n=null==E?void 0:E.length)&&void 0!==n?n:0),$=null!==(o=null==E?void 0:E.length)&&void 0!==o?o:0;F.current!==$&&(F.current=$,W.current=new Map);const z=e.useMemo(()=>{if(!E||0===E.length)return null;const e=He(),t="horizontal"===(null==c?void 0:c.projection),n=(null==c?void 0:c.o)?e=>{var t;return(null!==(t=c.o(e))&&void 0!==t?t:0)+c.o.bandwidth()/2}:null,o={scales:c?{x:t?c.r:n||c.r,y:t&&n||c.r,time:c.r,value:c.r,o:c.o}:null,timeAxis:"x",xAccessor:j,yAccessor:C,width:r,height:i,data:P,frameType:"ordinal",projection:t?"horizontal":"vertical",stickyPositionCache:W.current};return E.map((t,n)=>{if(M){const r=M(t,n,o);return null!=r?r:e(t,n,o)}return e(t,n,o)}).filter(Boolean)},[E,M,r,i,c,j,C,P]);return u||v||b||O||z&&z.length>0||m||_?p.createElement("svg",{role:"img",width:a,height:s,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"}},p.createElement("title",null,"string"==typeof v?v:"Ordinal Chart"),p.createElement("desc",null,"string"==typeof v?v+" — ordinal data visualization":"Ordinal data visualization"),p.createElement("g",{transform:`translate(${l.left},${l.top})`},m&&c&&!T&&!L&&p.createElement("g",{className:"ordinal-grid"},H.map((e,t)=>p.createElement("line",{key:"grid-"+t,x1:B?e.pixel:0,y1:B?0:e.pixel,x2:B?e.pixel:r,y2:B?i:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),u&&c&&!T&&p.createElement("g",{className:"ordinal-axes"},B?p.createElement(p.Fragment,null,!L&&p.createElement("line",{x1:0,y1:0,x2:0,y2:i,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),D.map((e,t)=>p.createElement("g",{key:"cat-"+t,transform:`translate(0,${e.pixel})`},p.createElement("line",{x2:-5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?p.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"}},e.label):p.createElement("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"}},p.createElement("div",{style:{textAlign:"right",fontSize:10,userSelect:"none"}},e.label)))),h&&p.createElement("text",{x:15-l.left,y:i/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",transform:`rotate(-90, ${15-l.left}, ${i/2})`,style:{userSelect:"none"}},h),!L&&p.createElement("line",{x1:0,y1:i,x2:r,y2:i,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),!L&&(null==c?void 0:c.r)&&(()=>{const e=c.r(0);return e>1&&r-1>e?p.createElement("line",{x1:e,y1:0,x2:e,y2:i,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1,strokeDasharray:"4,4"}):null})(),H.map((e,t)=>{const n=R?0===t?"start":t===H.length-1?"end":"middle":"middle";return p.createElement("g",{key:"val-"+t,transform:`translate(${e.pixel},${i})`},p.createElement("line",{y2:5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),p.createElement("text",{y:18,textAnchor:n,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"}},e.label))}),g&&p.createElement("text",{x:r/2,y:i+40,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},g)):p.createElement(p.Fragment,null,!L&&(()=>{const e=(null==c?void 0:c.r)?c.r(0):i,t=0>e||e>i?i:e;return p.createElement("line",{x1:0,y1:t,x2:r,y2:t,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1})})(),D.map((e,t)=>p.createElement("g",{key:"cat-"+t,transform:`translate(${e.pixel},${i})`},p.createElement("line",{y2:5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?p.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"}},e.label):p.createElement("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"}},p.createElement("div",{style:{textAlign:"center",fontSize:10,userSelect:"none"}},e.label)))),h&&p.createElement("text",{x:r/2,y:i+40,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},h),!L&&p.createElement("line",{x1:0,y1:0,x2:0,y2:i,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),H.map((e,t)=>p.createElement("g",{key:"val-"+t,transform:`translate(0,${e.pixel})`},p.createElement("line",{x2:-5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),p.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"}},e.label))),g&&p.createElement("text",{x:15-l.left,y:i/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",transform:`rotate(-90, ${15-l.left}, ${i/2})`,style:{userSelect:"none"}},g))),z,O,_),v&&p.createElement("text",{x:a/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof v?v:null),Me({legend:b,totalWidth:a,totalHeight:s,margin:l,legendPosition:S,title:v,legendHoverBehavior:x,legendClickBehavior:k,legendHighlightedCategory:w,legendIsolatedCategories:A})):null}function Lr({width:o,height:r,totalWidth:i,totalHeight:a,margin:s,scales:l,onBrush:c}){const u=e.useRef(null),d=e.useRef(null),h=e.useRef(c);h.current=c;const g=e.useRef(l);g.current=l;const f=e.useRef(!1),y=e.useRef(null),m="horizontal"===(null==l?void 0:l.projection),v=e.useRef(m);return v.current=m,e.useEffect(()=>{if(!u.current)return;const e=t.select(u.current).select(".brush-g"),i=m?n.brushX():n.brushY();return i.extent([[0,0],[o,r]]),i.on("brush end",e=>{if(f.current)return;const t=g.current;if(!t)return;if(!e.selection)return y.current=null,void h.current(null);const[n,o]=e.selection;let r;r=v.current?[t.r.invert(n),t.r.invert(o)]:[t.r.invert(o),t.r.invert(n)];const i={r:r};y.current=i,h.current(i)}),e.call(i),d.current=i,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{i.on("brush end",null),d.current=null}},[o,r,m]),e.useEffect(()=>{if(!l||!d.current||!y.current)return;if(!u.current)return;const e=y.current,n=t.select(u.current).select(".brush-g"),o=l.r(e.r[0]),r=l.r(e.r[1]);m?(f.current=!0,n.call(d.current.move,[o,r]),f.current=!1):(f.current=!0,n.call(d.current.move,[r,o]),f.current=!1)},[l,m]),p.createElement("svg",{ref:u,width:i,height:a,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},p.createElement("g",{className:"brush-g",transform:`translate(${s.left},${s.top})`,style:{pointerEvents:"all"}}))}function _r(e,t){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()}function Tr(e,t){const n=l.arc().innerRadius(t.innerRadius).outerRadius(t.outerRadius).startAngle(t.startAngle+Math.PI/2).endAngle(t.endAngle+Math.PI/2).cornerRadius(t.cornerRadius)({});if(!n)return;e.save(),e.translate(t.cx,t.cy);const o=new Path2D(n);e.fill(o),t.style.stroke&&"none"!==t.style.stroke&&e.stroke(o),e.restore()}const Br=(e,t,n,o)=>{var r,i;const a=t.filter(e=>"wedge"===e.type);for(const t of a)e.globalAlpha=null!==(i=null!==(r=t.style.fillOpacity)&&void 0!==r?r:t.style.opacity)&&void 0!==i?i:1,e.fillStyle=("string"==typeof t.style.fill?Ht(e,t.style.fill):t.style.fill)||"#007bff",t.cornerRadius?(t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Ht(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1),Tr(e,t)):(_r(e,t),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Ht(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke())),t._pulseIntensity&&t._pulseIntensity>0&&(_r(e,t),Vt(e,t)),e.globalAlpha=1},Nr=(e,t,n,o)=>{var r,i;const a=t.filter(e=>"violin"===e.type);for(const t of a){e.save(),(t.translateX||t.translateY)&&e.translate(t.translateX,t.translateY);const n=new Path2D(t.pathString);if(e.globalAlpha=null!==(i=null!==(r=t.style.fillOpacity)&&void 0!==r?r:t.style.opacity)&&void 0!==i?i:.6,e.fillStyle=("string"==typeof t.style.fill?Ht(e,t.style.fill):t.style.fill)||"#007bff",e.fill(n),e.globalAlpha=1,t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Ht(e,t.style.stroke)||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()}},Dr=(e,t,n,o)=>{var r,i,a;const s=t.filter(e=>"connector"===e.type);if(0===s.length)return;const l=new Map;for(const e of s){const t=e.group||"_default";l.has(t)||l.set(t,[]),l.get(t).push(e)}for(const[,t]of l){if(0===t.length)continue;const n=t[0].style;if(n.fill&&"none"!==n.fill){e.beginPath(),e.moveTo(t[0].x1,t[0].y1);for(const n of t)e.lineTo(n.x2,n.y2);e.closePath(),e.globalAlpha=null!==(i=null!==(r=n.fillOpacity)&&void 0!==r?r:n.opacity)&&void 0!==i?i:.3,e.fillStyle=n.fill,e.fill(),e.globalAlpha=1}for(const n of t)e.beginPath(),e.moveTo(n.x1,n.y1),e.lineTo(n.x2,n.y2),e.strokeStyle=Ht(e,n.style.stroke)||("string"==typeof n.style.fill?Ht(e,n.style.fill):n.style.fill)||"#999",e.lineWidth=n.style.strokeWidth||1,e.globalAlpha=null!==(a=n.style.opacity)&&void 0!==a?a:.5,e.stroke(),e.globalAlpha=1}};function Ir(e){return 1e6>e?1e4>e?1e3>e?e+"":(e/1e3).toFixed(1)+"K":(e/1e3).toFixed(0)+"K":(e/1e6).toFixed(1)+"M"}function Rr(e){return.05>Math.abs(e-Math.round(e))?Math.round(e)+"%":e.toFixed(1)+"%"}let Hr=null;const Wr=new Map;function Fr(e,t){const n=`${e}@${"undefined"!=typeof window&&window.devicePixelRatio||1}`,o=Wr.get(n);if(void 0!==o)return o;const r=function(e={},t){const{background:n="transparent",stroke:o="#000",lineWidth:r=1.5,spacing:i=6,angle:a=45}=e,s=Math.max(8,Math.ceil(2*i));let l;try{l=function(e){return"undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(e,e):(Hr||(Hr=document.createElement("canvas")),Hr.width=e,Hr.height=e,Hr)}(s)}catch(e){return null}const c=l.getContext("2d");if(!c)return null;n&&"transparent"!==n?(c.fillStyle=n,c.fillRect(0,0,s,s)):c.clearRect(0,0,s,s),c.strokeStyle=o,c.lineWidth=r,c.lineCap="square";const u=a*Math.PI/180;if(45===a||-45===a){const e=a>0?1:-1;for(let t=-s;2*s>=t;t+=i)c.beginPath(),c.moveTo(t,0),c.lineTo(t+e*s,s),c.stroke()}else{c.save(),c.translate(s/2,s/2),c.rotate(u);const e=2*s;for(let t=-e;e>=t;t+=i)c.beginPath(),c.moveTo(-e,t),c.lineTo(e,t),c.stroke();c.restore()}return(t||c).createPattern(l,"repeat")}({background:e,stroke:"rgba(255,255,255,0.5)",lineWidth:1.5,spacing:6,angle:45},t);return Wr.set(n,r),r}function $r(e,t,n,o,r,i){e.moveTo(t+i,n),e.lineTo(t+o-i,n),e.quadraticCurveTo(t+o,n,t+o,n+i),e.lineTo(t+o,n+r-i),e.quadraticCurveTo(t+o,n+r,t+o-i,n+r),e.lineTo(t+i,n+r),e.quadraticCurveTo(t,n+r,t,n+r-i),e.lineTo(t,n+i),e.quadraticCurveTo(t,n,t+i,n),e.closePath()}function zr(e){return 1e6>e?1e4>e?1e3>e?Math.round(e)+"":(e/1e3).toFixed(1)+"K":(e/1e3).toFixed(0)+"K":(e/1e6).toFixed(1)+"M"}function Gr(e){return.05>Math.abs(e-Math.round(e))?Math.round(e)+"%":e.toFixed(1)+"%"}const qr=e=>[Dr,...e],Yr={bar:qr([en]),clusterbar:qr([en]),point:qr([Jt]),swarm:qr([Jt]),pie:[Br],donut:[Br],boxplot:qr([(e,t,n,o)=>{var r,i;const a=t.filter(e=>"boxplot"===e.type);for(const t of a){const n=t.columnWidth/2,o="vertical"===t.projection,a=t.style.fill||"#007bff",s=t.style.stroke||"#333",l=t.style.strokeWidth||1,c=null!==(i=null!==(r=t.style.fillOpacity)&&void 0!==r?r:t.style.opacity)&&void 0!==i?i:.6;if(e.save(),e.strokeStyle=s,e.lineWidth=l,e.beginPath(),o?(e.moveTo(t.x,t.minPos),e.lineTo(t.x,t.maxPos)):(e.moveTo(t.minPos,t.y),e.lineTo(t.maxPos,t.y)),e.stroke(),e.beginPath(),o?(e.moveTo(t.x-.4*n,t.minPos),e.lineTo(t.x+.4*n,t.minPos),e.moveTo(t.x-.4*n,t.maxPos),e.lineTo(t.x+.4*n,t.maxPos)):(e.moveTo(t.minPos,t.y-.4*n),e.lineTo(t.minPos,t.y+.4*n),e.moveTo(t.maxPos,t.y-.4*n),e.lineTo(t.maxPos,t.y+.4*n)),e.stroke(),e.globalAlpha=c,e.fillStyle=a,o){const o=Math.min(t.q1Pos,t.q3Pos),r=Math.abs(t.q3Pos-t.q1Pos);e.fillRect(t.x-n,o,t.columnWidth,r),e.globalAlpha=1,e.strokeRect(t.x-n,o,t.columnWidth,r)}else{const o=Math.min(t.q1Pos,t.q3Pos),r=Math.abs(t.q3Pos-t.q1Pos);e.fillRect(o,t.y-n,r,t.columnWidth),e.globalAlpha=1,e.strokeRect(o,t.y-n,r,t.columnWidth)}e.strokeStyle="#fff",e.lineWidth=2,e.beginPath(),o?(e.moveTo(t.x-n,t.medianPos),e.lineTo(t.x+n,t.medianPos)):(e.moveTo(t.medianPos,t.y-n),e.lineTo(t.medianPos,t.y+n)),e.stroke(),e.restore()}},Jt]),violin:qr([Nr]),histogram:qr([en]),ridgeline:qr([Nr]),timeline:qr([en]),funnel:[en,(e,t,n,o)=>{var r,i,a,s;const l=t.filter(e=>"trapezoid"===e.type);for(const t of l){const n=t.points;if(n.length>=4){e.globalAlpha=null!==(i=null===(r=t.style)||void 0===r?void 0:r.opacity)&&void 0!==i?i:1,e.beginPath(),e.moveTo(n[0][0],n[0][1]);for(let t=1;n.length>t;t++)e.lineTo(n[t][0],n[t][1]);e.closePath(),e.fillStyle=(null===(a=t.style)||void 0===a?void 0:a.fill)||"#999",e.fill(),(null===(s=t.style)||void 0===s?void 0:s.stroke)&&(e.strokeStyle=Ht(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()),e.globalAlpha=1}}},(e,t,n,o)=>{var r,i,a,s;const l=t.filter(e=>"rect"===e.type&&null!=e.datum);if(0!==l.length&&l.some(e=>null!=e.datum.__funnelStepLabel||null!=e.datum.__funnelValueLabelX)){e.textBaseline="top",e.lineJoin="round",e.textAlign="center",e.font="bold 14px sans-serif";for(const t of l){const n=t.datum;if(!n.__funnelStepLabel)continue;const o=n.__funnelStepLabel;if(e.measureText(o).width+16>(null!==(i=null!==(r=n.__funnelRowWidth)&&void 0!==r?r:n.__funnelBarW)&&void 0!==i?i:0))continue;const a=n.__funnelStepLabelX,s=n.__funnelStepLabelY+3;e.strokeStyle="rgba(0,0,0,0.6)",e.lineWidth=3,e.strokeText(o,a,s),e.fillStyle="#fff",e.fillText(o,a,s)}e.font="bold 13px sans-serif";for(const t of l){const n=t.datum;if(null==n.__funnelValueLabelX)continue;const o=null!==(a=n.__funnelBarW)&&void 0!==a?a:0;if(60>o)continue;const r=n.__funnelValue;if(null==r||0===r)continue;const i=n.__funnelPercent,l=!0===n.__funnelIsFirstStep;let c;if(c=l?Ir(r):null!=i?`${Ir(r)} (${Rr(i)})`:Ir(r),e.measureText(c).width+16>o){if(l||null==i)continue;if(c=Ir(r),e.measureText(c).width+16>o)continue}const u=n.__funnelValueLabelX,d=(null!==(s=n.__funnelValueLabelY)&&void 0!==s?s:t.y)+14+5;e.textAlign="center",e.strokeStyle="rgba(0,0,0,0.5)",e.lineWidth=3,e.strokeText(c,u,d),e.fillStyle="#fff",e.fillText(c,u,d)}e.lineWidth=1,e.lineJoin="miter"}}],"bar-funnel":[en,(e,t,n,o)=>{var r,i;const a=t.filter(e=>{var t;return"rect"===e.type&&!0===(null===(t=e.datum)||void 0===t?void 0:t.__barFunnelIsDropoff)});for(const t of a){const n="string"==typeof t.style.fill?t.style.fill:"#999",o=Fr(n,e);e.globalAlpha=null!==(r=t.style.opacity)&&void 0!==r?r:1,e.beginPath(),e.rect(t.x,t.y,t.w,t.h),o?e.fillStyle=o:(e.fillStyle=n,e.globalAlpha=.4*(null!==(i=t.style.opacity)&&void 0!==i?i:1)),e.fill(),e.globalAlpha=1}},(e,t,n,o)=>{const r=t.filter(e=>{var t,n;return"rect"===e.type&&!0!==(null===(t=e.datum)||void 0===t?void 0:t.__barFunnelIsDropoff)&&null!=(null===(n=e.datum)||void 0===n?void 0:n.__barFunnelLabelX)});if(0!==r.length){for(const t of r){const n=t.datum,o=n.__barFunnelValue;if(null==o)continue;if(25>t.w)continue;const r=n.__barFunnelPercent,i=!(!0===n.__barFunnelIsFirstStep)&&null!=r,a=i?Gr(r):"",s=zr(o);e.font="bold 13px sans-serif";const l=i?e.measureText(a).width:0;e.font="11px sans-serif";const c=e.measureText(s).width,u=Math.max(l,c)+12,d=i?32:17,h=n.__barFunnelLabelX,g=h-u/2,f=n.__barFunnelLabelY-d-4;e.save(),e.shadowColor="rgba(0,0,0,0.15)",e.shadowBlur=4,e.shadowOffsetY=1,e.fillStyle="rgba(255,255,255,0.95)",e.beginPath(),$r(e,g,f,u,d,4),e.fill(),e.restore(),e.strokeStyle="rgba(0,0,0,0.12)",e.lineWidth=.5,e.beginPath(),$r(e,g,f,u,d,4),e.stroke(),e.textAlign="center",e.textBaseline="top",i?(e.font="bold 13px sans-serif",e.fillStyle="#333",e.fillText(a,h,f+3),e.font="11px sans-serif",e.fillStyle="#666",e.fillText(s,h,f+3+13+2)):(e.font="bold 11px sans-serif",e.fillStyle="#333",e.fillText(s,h,f+3))}e.lineWidth=1}}],swimlane:qr([en])},Xr={top:50,right:40,bottom:60,left:70},Vr={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 Ur({hover:e}){var t,n,o,r,i,a;const s=e.data||{},l=e.stats,c=e.category;if(Array.isArray(s)){const e=c||(null===(t=s[0])||void 0===t?void 0:t.category)||"";if(l)return p.createElement("div",{className:"semiotic-tooltip",style:Vr},e&&p.createElement("div",{style:{fontWeight:"bold"}},e+""),p.createElement("div",null,"n = ",l.n),p.createElement("div",null,"Min: ",l.min.toLocaleString()),p.createElement("div",null,"Q1: ",l.q1.toLocaleString()),p.createElement("div",null,"Median: ",l.median.toLocaleString()),p.createElement("div",null,"Q3: ",l.q3.toLocaleString()),p.createElement("div",null,"Max: ",l.max.toLocaleString()),p.createElement("div",{style:{opacity:.8}},"Mean: ",l.mean.toLocaleString(void 0,{maximumFractionDigits:2})));const n=s.length;return p.createElement("div",{className:"semiotic-tooltip",style:Vr},e&&p.createElement("div",{style:{fontWeight:"bold"}},e+""),p.createElement("div",null,n," items"))}if(null!=s.bin&&null!=s.count){const e=s.range||[];return p.createElement("div",{className:"semiotic-tooltip",style:Vr},s.category&&p.createElement("div",{style:{fontWeight:"bold"}},s.category+""),p.createElement("div",null,"Count: ",s.count),2===e.length&&p.createElement("div",{style:{opacity:.8}},Number(e[0]).toFixed(1)," – ",Number(e[1]).toFixed(1)))}const u=e.__oAccessor,d=e.__rAccessor,h=e.__chartType;if("swarm"===h||"point"===h){const e=Object.entries(s).filter(([e])=>!e.startsWith("_")&&"data"!==e);return p.createElement("div",{className:"semiotic-tooltip",style:Vr},e.map(([e,t])=>p.createElement("div",{key:e},p.createElement("span",{style:{opacity:.7}},e,":")," ","number"==typeof t?t.toLocaleString():t+"")))}const g=(u&&null!=s[u]?s[u]:null)||s.category||s.name||s.group||s.__rName||"",f=null!==(a=null!==(i=null!==(r=null!==(o=null!==(n=s.__aggregateValue)&&void 0!==n?n:d&&null!=s[d]?s[d]:null)&&void 0!==o?o:s.value)&&void 0!==r?r:s.__rValue)&&void 0!==i?i:s.pct)&&void 0!==a?a:"";if(!g&&""===f){const e=Object.entries(s).filter(([e])=>!e.startsWith("_")&&"data"!==e);return p.createElement("div",{className:"semiotic-tooltip",style:Vr},e.map(([e,t])=>p.createElement("div",{key:e},p.createElement("span",{style:{opacity:.7}},e,":")," ","number"==typeof t?t.toLocaleString():t+"")))}return p.createElement("div",{className:"semiotic-tooltip",style:Vr},g&&p.createElement("div",{style:{fontWeight:"bold"}},g+""),""!==f&&p.createElement("div",null,"number"==typeof f?f.toLocaleString():f+""))}const Kr=e.forwardRef(function(t,n){var o,r,i,a,s,c,u,d,h,g;const{chartType:f,runtimeMode:y,data:m,oAccessor:v="category",rAccessor:b="value",colorAccessor:k,stackBy:w,groupBy:A,multiAxis:S,timeAccessor:O,valueAccessor:E,categoryAccessor:M,projection:j="vertical",size:C=[600,400],responsiveWidth:P,responsiveHeight:L,margin:_,barPadding:T,roundedTop:B,baselinePadding:N,innerRadius:D,cornerRadius:I,normalize:R,startAngle:H,sweepAngle:W,dynamicColumnWidth:F,bins:$,showOutliers:z,showIQR:G,amplitude:q,connectorOpacity:Y,showLabels:X,connectorAccessor:V,connectorStyle:U,dataIdAccessor:K,rExtent:Q,oExtent:Z,extentPadding:J=.05,oSort:ee,windowMode:te="sliding",windowSize:ne=200,pieceStyle:oe,summaryStyle:re,colorScheme:ie,barColors:ae,showAxes:se=!0,showCategoryTicks:le,oLabel:ce,rLabel:ue,oFormat:de,rFormat:he,rTickValues:ge,tickLabelEdgeAlign:me,enableHover:ke=!0,hoverAnnotation:we,tooltipContent:Ae,customHoverBehavior:Se,annotations:Oe,svgAnnotationRules:Ee,showGrid:Me=!1,legend:je,legendHoverBehavior:Ce,legendClickBehavior:Pe,legendHighlightedCategory:Le,legendIsolatedCategories:_e,legendPosition:Te,backgroundGraphics:Be,foregroundGraphics:Ne,title:De,className:Ie,background:Re,centerContent:He,decay:We,pulse:Fe,transition:$e,staleness:ze,brush:Ge,onBrush:qe,accessibleTable:Ye=!0,description:Xe,summary:Ve}=t,Ue=Mt(),Ke=e.useRef(Ue);Ke.current=Ue;const[Qe,Ze]=be(C,P,L),Je=e.useMemo(()=>Object.assign(Object.assign({},Xr),_),[_]),et=Ze[0]-Je.left-Je.right,tt=Ze[1]-Je.top-Je.bottom,rt="function"==typeof Ne?Ne({size:Ze,margin:Je}):Ne,it=e.useRef(null),at=e.useRef(!0),st=Bt(e=>e.theme),ct=e.useRef(0),ut=e.useRef(null),dt=e.useRef(()=>{}),[ht,gt]=e.useState(null),[ft,pt]=e.useState(null),[yt,mt]=e.useState(0),[bt,At]=e.useState(!1),Et=ke||we,jt="streaming"===y,Ct=e.useMemo(()=>({chartType:f,runtimeMode:jt?"streaming":"bounded",windowSize:ne,windowMode:te,extentPadding:J,projection:j,oAccessor:jt?void 0:v,rAccessor:jt?void 0:b,colorAccessor:k,stackBy:w,groupBy:A,multiAxis:S,timeAccessor:jt?O:void 0,valueAccessor:jt?E||("string"==typeof b||"function"==typeof b?b:void 0):void 0,categoryAccessor:jt?M||v:void 0,rExtent:Q,oExtent:Z,barPadding:T,roundedTop:B,baselinePadding:N,innerRadius:D,cornerRadius:I,normalize:R,startAngle:H,sweepAngle:W,dynamicColumnWidth:F,bins:$,showOutliers:z,showIQR:G,amplitude:q,connectorOpacity:Y,showLabels:X,connectorAccessor:V,connectorStyle:U,dataIdAccessor:K,oSort:ee,pieceStyle:oe,summaryStyle:re,colorScheme:ie,barColors:ae,decay:We,pulse:Fe,transition:$e,staleness:ze}),[f,ne,te,J,j,v,b,k,w,A,S,O,E,M,Q,Z,T,B,N,D,I,R,H,W,F,$,z,G,q,Y,X,V,U,K,ee,oe,re,ie,ae,We,Fe,$e,ze,jt]),Pt=e.useRef(null);Pt.current||(Pt.current=new wr(Ct));const Lt=e.useCallback(()=>{ct.current||(ct.current=requestAnimationFrame(()=>dt.current()))},[]);e.useEffect(()=>{var e;null===(e=Pt.current)||void 0===e||e.updateConfig(Ct),at.current=!0,Lt()},[Ct,Lt]),e.useEffect(()=>{it.current&&Wt(it.current),at.current=!0,Lt()},[st,Lt]);const _t=e.useRef(null);_t.current||(_t.current=new x(e=>{const t=Pt.current;t&&t.ingest(e)&&(at.current=!0,Lt())}));const Tt=e.useCallback(e=>{var t;null===(t=_t.current)||void 0===t||t.push(e)},[]),Nt=e.useCallback(e=>{var t;null===(t=_t.current)||void 0===t||t.pushMany(e)},[]),It=e.useCallback(()=>{var e,t;null===(e=_t.current)||void 0===e||e.clear(),null===(t=Pt.current)||void 0===t||t.clear(),at.current=!0,Lt()},[Lt]);e.useImperativeHandle(n,()=>({push:Tt,pushMany:Nt,remove:e=>{var t,n,o,r;null===(t=_t.current)||void 0===t||t.flush();const i=null!==(o=null===(n=Pt.current)||void 0===n?void 0:n.remove(e))&&void 0!==o?o:[];if(i.length>0){const e=null===(r=ut.current)||void 0===r?void 0:r.data;!!ut.current&&i.some(Array.isArray(e)?t=>e.includes(t):t=>t===e)&&(ut.current=null,gt(null)),at.current=!0,Lt()}return i},update:(e,t)=>{var n,o,r;null===(n=_t.current)||void 0===n||n.flush();const i=null!==(r=null===(o=Pt.current)||void 0===o?void 0:o.update(e,t))&&void 0!==r?r:[];return i.length>0&&(at.current=!0,Lt()),i},clear:It,getData:()=>{var e,t,n;return null===(e=_t.current)||void 0===e||e.flush(),null!==(n=null===(t=Pt.current)||void 0===t?void 0:t.getData())&&void 0!==n?n:[]},getScales:()=>{var e,t;return null!==(t=null===(e=Pt.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null}}),[Tt,Nt,It,Lt]),e.useEffect(()=>{var e;m&&(null===(e=_t.current)||void 0===e||e.setBoundedData(m))},[m]);const Rt=e.useRef(()=>{}),Ht=e.useRef(()=>{});Rt.current=e=>{if(!Et)return;const t=it.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-Je.left,r=e.clientY-n.top-Je.top;if(0>o||o>et||0>r||r>tt)return void(ut.current&&(ut.current=null,gt(null),Se&&Se(null),Lt()));const i=Pt.current;if(!i||0===i.scene.length)return;const a="radial"===j,s=function(e,t,n,o=30){let r=null;for(const i of e){let e=null;switch(i.type){case"rect":e=Ar(i,t,n);break;case"point":e=Sr(i,t,n,o);break;case"wedge":e=Or(i,t,n);break;case"boxplot":e=Er(i,t,n);break;case"violin":e=Mr(i,t,n)}e&&o>e.distance&&(r&&e.distance>=r.distance||(r=e))}return r}(i.scene,a?o-et/2:o,a?r-tt/2:r);if(!s)return void(ut.current&&(ut.current=null,gt(null),Se&&Se(null),Lt()));const l=nn(s.datum||{},s.x,s.y,Object.assign(Object.assign(Object.assign({},s.stats&&{stats:s.stats}),s.category&&{category:s.category}),{__oAccessor:"string"==typeof v?v:void 0,__rAccessor:"string"==typeof b?b:void 0,__chartType:f}));ut.current=l,gt(l),Se&&(Se(l),at.current=!0),Lt()},Ht.current=()=>{ut.current&&(ut.current=null,gt(null),Se&&(Se(null),at.current=!0),Lt())},e.useCallback(e=>Rt.current(e),[]);const Ft=e.useCallback(()=>Ht.current(),[]),$t=e.useRef(-1),zt=e.useRef(null),Gt=e.useRef(null),qt=e.useCallback(e=>{const t=Pt.current;if(!t||0===t.scene.length)return;const n=t.version;let o;if(Gt.current&&Gt.current.version===n)o=Gt.current.graph;else{const e=function(e){var t,n,o,r;const i=[];for(const a of e)if("rect"===a.type&&null!=a.x){const e=null!==(n=null===(t=a.datum)||void 0===t?void 0:t.category)&&void 0!==n?n:"";i.push({x:a.x+a.w/2,y:a.y+a.h/2,datum:a.datum,shape:"rect",w:a.w,h:a.h,group:null!==(o=a.group)&&void 0!==o?o:e})}else if("point"===a.type)i.push({x:a.x,y:a.y,datum:a.datum,shape:"circle",group:null!==(r=a.group)&&void 0!==r?r:"_default"});else if("wedge"===a.type&&null!=a.cx){const e=((a.startAngle||0)+(a.endAngle||0))/2,t=((a.innerRadius||0)+(a.outerRadius||50))/2;i.push({x:a.cx+Math.cos(e)*t,y:a.cy+Math.sin(e)*t,datum:a.datum,shape:"wedge",group:"_default"})}return i.sort((e,t)=>e.x-t.x||e.y-t.y),i}(t.scene);if(0===e.length)return;o=fe(e),Gt.current={version:n,graph:o}}const r=$t.current;if(0>r){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(e.key))return;e.preventDefault(),$t.current=0;const t=o.flat[0];zt.current={shape:t.shape,w:t.w,h:t.h};const n=Object.assign(Object.assign({},ve(t)),{__oAccessor:"string"==typeof v?v:void 0,__rAccessor:"string"==typeof b?b:void 0,__chartType:f});return ut.current=n,gt(n),Se&&Se(n),void Lt()}const i=pe(o,r),a=ye(e.key,i,o);if(null===a)return;if(e.preventDefault(),0>a)return $t.current=-1,zt.current=null,ut.current=null,gt(null),Se&&Se(null),void Lt();$t.current=a;const s=o.flat[a];zt.current={shape:s.shape,w:s.w,h:s.h};const l=Object.assign(Object.assign({},ve(s)),{__oAccessor:"string"==typeof v?v:void 0,__rAccessor:"string"==typeof b?b:void 0,__chartType:f});ut.current=l,gt(l),Se&&Se(l),Lt()},[Se,Lt]),Yt=e.useCallback(e=>{$t.current=-1,zt.current=null,Rt.current(e)},[]);dt.current=()=>{var e,t;ct.current=0;const n=it.current;if(!n)return;const o=n.getContext("2d");if(!o)return;const r=Pt.current;if(!r)return;const i="undefined"!=typeof performance?performance.now():Date.now(),a=r.advanceTransition(Ke.current?i+1e6:i),s=!Ke.current&&a,l=at.current;l&&!a&&(r.computeScene({width:et,height:tt}),at.current=!1),(l||s)&&n.setAttribute("aria-label",lt(r.scene,f+" chart"));const c=Dt(),u=Ze[0]*c,d=Ze[1]*c;n.width===u&&n.height===d||(n.width=u,n.height=d,n.style.width=Ze[0]+"px",n.style.height=Ze[1]+"px"),o.setTransform(c,0,0,c,0,0),o.clearRect(0,0,Ze[0],Ze[1]);const h=null!==(e=null==ze?void 0:ze.threshold)&&void 0!==e?e:5e3,g=ze&&r.lastIngestTime>0&&i-r.lastIngestTime>h;g&&(o.globalAlpha=null!==(t=null==ze?void 0:ze.dimOpacity)&&void 0!==t?t:.5);const p=n?getComputedStyle(n).getPropertyValue("--semiotic-bg").trim():"",y=Re||(p&&"transparent"!==p?p:null);y&&(o.fillStyle=y,o.fillRect(0,0,Ze[0],Ze[1]));const m="radial"===j;o.save(),o.beginPath(),o.rect(Je.left,Je.top,et,tt),o.clip(),m?(o.save(),o.translate(Je.left+et/2,Je.top+tt/2)):o.translate(Je.left,Je.top);const v=Yr[f]||[],b={width:et,height:tt};for(const e of v)e(o,r.scene,r.scales,b);m&&o.restore(),o.restore(),g&&(o.globalAlpha=1),l&&r.scales&&(pt(r.scales),mt(e=>e+1)),(null==ze?void 0:ze.showBadge)&&At(!!g),(s||r.hasActivePulses)&&(ct.current=requestAnimationFrame(()=>dt.current()))},e.useEffect(()=>(Lt(),()=>{ct.current&&(cancelAnimationFrame(ct.current),ct.current=0)}),[Lt]),e.useEffect(()=>{at.current=!0,Lt()},[f,et,tt,se,Re,Lt]),xe(ze,Pt,at,Lt,bt,At);const Xt=Et&&ht?Ae?Ae(ht):p.createElement(Ur,{hover:ht}):null,Vt="radial"===j,Ut=Xt?p.createElement(Ot,{x:ht?Vt?ht.x+et/2:ht.x:0,y:ht?Vt?ht.y+tt/2:ht.y:0,containerWidth:et,containerHeight:tt,margin:Je,className:"stream-ordinal-tooltip"},Xt):null;if(ot){const e=Pt.current;e&&m&&(e.ingest({inserts:m,bounded:!0}),e.computeScene({width:et,height:tt}));const t=null!==(o=null==e?void 0:e.scene)&&void 0!==o?o:[],n=null!==(r=null==e?void 0:e.scales)&&void 0!==r?r:null,i="radial"===j,a=i?Je.left+et/2:Je.left,s=i?Je.top+tt/2:Je.top;return p.createElement("div",{className:"stream-ordinal-frame"+(Ie?" "+Ie:""),role:"img","aria-label":Xe||("string"==typeof De?De:"Ordinal chart"),style:{position:"relative",width:Ze[0],height:Ze[1]}},p.createElement(xt,{summary:Ve}),p.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:Ze[0],height:Ze[1],style:{position:"absolute",left:0,top:0}},Be&&p.createElement("g",{transform:`translate(${Je.left},${Je.top})`},Be),p.createElement("g",{transform:`translate(${a},${s})`},Re&&p.createElement("rect",{x:0,y:0,width:et,height:tt,fill:Re}),t.map((e,t)=>function(e,t){var n,o,r,i,a;const s=("category"in e?e.category:void 0)||("group"in e?e.group:void 0)||"",c=n=>`ord-${e.type}-${s}-${t}-${n}`,u=`ord-${e.type}-${s}-${t}`;switch(e.type){case"rect":{const t=e;if(t.roundedTop&&t.roundedTop>0){const e=Math.min(t.roundedTop,t.w/2,t.h/2),{x:n,y:o,w:r,h:i}=t;let a;switch(t.roundedEdge){case"right":a=`M${n},${o} L${n+r-e},${o} A${e},${e} 0 0 1 ${n+r},${o+e} L${n+r},${o+i-e} A${e},${e} 0 0 1 ${n+r-e},${o+i} L${n},${o+i} Z`;break;case"left":a=`M${n+r},${o} L${n+e},${o} A${e},${e} 0 0 0 ${n},${o+e} L${n},${o+i-e} A${e},${e} 0 0 0 ${n+e},${o+i} L${n+r},${o+i} Z`;break;case"bottom":a=`M${n},${o} L${n+r},${o} L${n+r},${o+i-e} A${e},${e} 0 0 1 ${n+r-e},${o+i} L${n+e},${o+i} A${e},${e} 0 0 1 ${n},${o+i-e} Z`;break;default:a=`M${n},${o+i} L${n},${o+e} A${e},${e} 0 0 1 ${n+e},${o} L${n+r-e},${o} A${e},${e} 0 0 1 ${n+r},${o+e} L${n+r},${o+i} Z`}return p.createElement("path",{key:u,d:a,fill:nt(t.style.fill),opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth})}return p.createElement("rect",{key:u,x:t.x,y:t.y,width:t.w,height:t.h,fill:nt(t.style.fill),opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth})}case"point":{const t=e;return p.createElement("circle",{key:u,cx:t.x,cy:t.y,r:t.r,fill:nt(t.style.fill),opacity:null!==(n=t.style.opacity)&&void 0!==n?n:.8,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth})}case"wedge":{const t=e,n=l.arc().innerRadius(t.innerRadius).outerRadius(t.outerRadius).startAngle(t.startAngle+Math.PI/2).endAngle(t.endAngle+Math.PI/2);t.cornerRadius&&n.cornerRadius(t.cornerRadius);const o=n({})||"";return p.createElement("path",{key:u,d:o,transform:`translate(${t.cx},${t.cy})`,fill:nt(t.style.fill),stroke:t.style.stroke,strokeWidth:t.style.strokeWidth,opacity:t.style.opacity})}case"boxplot":{const t=e,n=t.columnWidth/2;return"vertical"===t.projection?p.createElement("g",{key:u},p.createElement("line",{x1:t.x,y1:t.minPos,x2:t.x,y2:t.maxPos,stroke:t.style.stroke||"#333",strokeWidth:1}),p.createElement("rect",{x:t.x-n,y:Math.min(t.q1Pos,t.q3Pos),width:t.columnWidth,height:Math.abs(t.q3Pos-t.q1Pos),fill:nt(t.style.fill),fillOpacity:null!==(o=t.style.fillOpacity)&&void 0!==o?o:.6,stroke:t.style.stroke||"#333",strokeWidth:1}),p.createElement("line",{x1:t.x-n,y1:t.medianPos,x2:t.x+n,y2:t.medianPos,stroke:t.style.stroke||"#333",strokeWidth:2}),p.createElement("line",{x1:t.x-.5*n,y1:t.minPos,x2:t.x+.5*n,y2:t.minPos,stroke:t.style.stroke||"#333",strokeWidth:1}),p.createElement("line",{x1:t.x-.5*n,y1:t.maxPos,x2:t.x+.5*n,y2:t.maxPos,stroke:t.style.stroke||"#333",strokeWidth:1})):p.createElement("g",{key:u},p.createElement("line",{x1:t.minPos,y1:t.y,x2:t.maxPos,y2:t.y,stroke:t.style.stroke||"#333",strokeWidth:1}),p.createElement("rect",{x:Math.min(t.q1Pos,t.q3Pos),y:t.y-n,width:Math.abs(t.q3Pos-t.q1Pos),height:t.columnWidth,fill:nt(t.style.fill),fillOpacity:null!==(r=t.style.fillOpacity)&&void 0!==r?r:.6,stroke:t.style.stroke||"#333",strokeWidth:1}),p.createElement("line",{x1:t.medianPos,y1:t.y-n,x2:t.medianPos,y2:t.y+n,stroke:t.style.stroke||"#333",strokeWidth:2}),p.createElement("line",{x1:t.minPos,y1:t.y-.5*n,x2:t.minPos,y2:t.y+.5*n,stroke:t.style.stroke||"#333",strokeWidth:1}),p.createElement("line",{x1:t.maxPos,y1:t.y-.5*n,x2:t.maxPos,y2:t.y+.5*n,stroke:t.style.stroke||"#333",strokeWidth:1}))}case"violin":{const t=e,n=[p.createElement("path",{key:c("path"),d:t.pathString,transform:t.translateX||t.translateY?`translate(${t.translateX},${t.translateY})`:void 0,fill:nt(t.style.fill),fillOpacity:null!==(i=t.style.fillOpacity)&&void 0!==i?i:.6,stroke:t.style.stroke||"#333",strokeWidth:t.style.strokeWidth||1})];if(t.iqrLine&&t.bounds){const e=t.bounds,o=e.x+e.width/2,r=e.y+e.height/2;e.height>e.width?n.push(p.createElement("line",{key:c("iqr"),x1:o,y1:t.iqrLine.q1Pos,x2:o,y2:t.iqrLine.q3Pos,stroke:t.style.stroke||"#333",strokeWidth:2}),p.createElement("circle",{key:c("med"),cx:o,cy:t.iqrLine.medianPos,r:3,fill:"white",stroke:t.style.stroke||"#333",strokeWidth:1})):n.push(p.createElement("line",{key:c("iqr"),x1:t.iqrLine.q1Pos,y1:r,x2:t.iqrLine.q3Pos,y2:r,stroke:t.style.stroke||"#333",strokeWidth:2}),p.createElement("circle",{key:c("med"),cx:t.iqrLine.medianPos,cy:r,r:3,fill:"white",stroke:t.style.stroke||"#333",strokeWidth:1}))}return p.createElement("g",{key:u},n)}case"connector":return p.createElement("line",{key:u,x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:null!==(a=e.style.opacity)&&void 0!==a?a:.5});case"trapezoid":{const t=e,n=t.points.map(e=>`${e[0]},${e[1]}`).join(" ");return p.createElement("polygon",{key:u,points:n,fill:nt(t.style.fill,"#999"),opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth})}default:return null}}(e,t)).filter(Boolean))),p.createElement(Pr,{width:et,height:tt,totalWidth:Ze[0],totalHeight:Ze[1],margin:Je,scales:n,showAxes:se,showCategoryTicks:le,oLabel:ce,rLabel:ue,oFormat:de,rFormat:he,rTickValues:ge,tickLabelEdgeAlign:me,showGrid:Me,title:De,legend:je,legendHoverBehavior:Ce,legendClickBehavior:Pe,legendHighlightedCategory:Le,legendIsolatedCategories:_e,legendPosition:Te,foregroundGraphics:rt,annotations:Oe,svgAnnotationRules:Ee,annotationFrame:0,xAccessor:"string"==typeof v?v:void 0,yAccessor:"string"==typeof b?b:void 0,annotationData:null==e?void 0:e.getData()}),He&&"radial"===j&&p.createElement("div",{style:{position:"absolute",left:Je.left+et/2,top:Je.top+tt/2,transform:"translate(-50%, -50%)",pointerEvents:"none",textAlign:"center"}},He))}const Kt="semiotic-table-"+p.useId();return p.createElement("div",{ref:Qe,className:"stream-ordinal-frame"+(Ie?" "+Ie:""),role:"group","aria-label":Xe||("string"==typeof De?De:"Ordinal chart"),tabIndex:0,style:{position:"relative",width:P?"100%":Ze[0],height:L?"100%":Ze[1],overflow:"visible"},onKeyDown:qt},Ye&&p.createElement(kt,{tableId:Kt}),Ye&&p.createElement(vt,{scene:null!==(a=null===(i=Pt.current)||void 0===i?void 0:i.scene)&&void 0!==a?a:[],chartType:f+" chart",tableId:Kt,chartTitle:"string"==typeof De?De:void 0}),p.createElement(xt,{summary:Ve}),p.createElement("div",{role:"img","aria-label":Xe||("string"==typeof De?De:"Ordinal chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:Et?Yt:void 0,onMouseLeave:Et?Ft:void 0},Be&&p.createElement("svg",{style:{position:"absolute",top:0,left:0,width:Ze[0],height:Ze[1],pointerEvents:"none"}},p.createElement("g",{transform:`translate(${Je.left},${Je.top})`},Be)),p.createElement(jr,{width:et,height:tt,totalWidth:Ze[0],totalHeight:Ze[1],margin:Je,scales:ft,showAxes:se,showGrid:Me,rFormat:he,rTickValues:ge}),p.createElement("canvas",{ref:it,"aria-label":lt(null!==(c=null===(s=Pt.current)||void 0===s?void 0:s.scene)&&void 0!==c?c:[],f+" chart"),style:{position:"absolute",top:0,left:0,width:Ze[0],height:Ze[1]}}),p.createElement(wt,{hoverPoint:ht}),p.createElement(Pr,{width:et,height:tt,totalWidth:Ze[0],totalHeight:Ze[1],margin:Je,scales:ft,showAxes:se,showCategoryTicks:le,oLabel:ce,rLabel:ue,oFormat:de,rFormat:he,showGrid:Me,title:De,legend:je,legendHoverBehavior:Ce,legendClickBehavior:Pe,legendHighlightedCategory:Le,legendIsolatedCategories:_e,legendPosition:Te,foregroundGraphics:rt,annotations:Oe,svgAnnotationRules:Ee,annotationFrame:yt,xAccessor:"string"==typeof v?v:void 0,yAccessor:"string"==typeof b?b:void 0,annotationData:null===(u=Pt.current)||void 0===u?void 0:u.getData(),underlayRendered:!0}),(Ge||qe)&&"radial"!==j&&p.createElement(Lr,{width:et,height:tt,totalWidth:Ze[0],totalHeight:Ze[1],margin:Je,scales:ft,onBrush:qe||(()=>{})}),He&&"radial"===j&&p.createElement("div",{style:{position:"absolute",left:Je.left+et/2,top:Je.top+tt/2,transform:"translate(-50%, -50%)",pointerEvents:"none",textAlign:"center"}},He),(null==ze?void 0:ze.showBadge)&&p.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===ze.badgePosition?{top:4,left:4}:"bottom-left"===ze.badgePosition?{bottom:4,left:4}:"bottom-right"===ze.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:bt?"#dc3545":"#28a745",color:"white"})},bt?"STALE":"LIVE"),p.createElement(St,{active:$t.current>=0,hoverPoint:ht,margin:Je,size:Ze,shape:null===(d=zt.current)||void 0===d?void 0:d.shape,width:null===(h=zt.current)||void 0===h?void 0:h.w,height:null===(g=zt.current)||void 0===g?void 0:g.h}),Ut))});Kr.displayName="StreamOrdinalFrame";const Qr=e.forwardRef(function(t,n){const o=Zn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel,showCategoryTicks:t.showCategoryTicks,orientation:t.orientation}),r=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=r.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const{data:i,margin:a,className:s,categoryAccessor:l="category",valueAccessor:c="value",orientation:u="vertical",valueFormat:d,colorBy:h,colorScheme:g,sort:f=!1,barPadding:y=40,roundedTop:m,baselinePadding:v=!1,tooltip:b,annotations:x,frameProps:k={},selection:w,linkedHover:A,onObservation:S,onClick:O,hoverHighlight:E,chartId:M,loading:j,emptyContent:C,legendInteraction:P,legendPosition:L,color:_,showCategoryTicks:B,categoryFormat:N,dataIdAccessor:D}=t,I=o.width,R=o.height,H=o.enableHover,W=o.showGrid,F=o.title,$=o.description,z=o.summary,G=o.accessibleTable,q=o.categoryLabel,Y=o.valueLabel,X=i||[],V=Jo({data:X,rawData:i,colorBy:h,colorScheme:g,legendInteraction:P,legendPosition:L,selection:w,linkedHover:A,fallbackFields:h?["string"==typeof h?h:""]:[],unwrapData:!0,onObservation:S,onClick:O,hoverHighlight:E,chartType:"BarChart",chartId:M,showLegend:o.showLegend,userMargin:a,marginDefaults:o.marginDefaults,loading:j,emptyContent:C,width:I,height:R});if(V.earlyReturn)return V.earlyReturn;Go("BarChart",X,"categoryAccessor",l),Go("BarChart",X,"valueAccessor",c);const U=Yn(X,f,c),K=$n(),Q=e.useMemo(()=>new Map,[X]),Z=e.useMemo(()=>(e,t)=>{const n={};return n.fill=h?T(e,h,V.colorScale):zn(_,K,g,void 0,Q),n},[h,V.colorScale,_,K,g,Q]),J=e.useMemo(()=>{const e=null==k?void 0:k.pieceStyle;return e&&"function"==typeof e?(t,n)=>Object.assign(Object.assign({},Z(t,n)),e(t,n)||{}):Z},[Z,k]),ee=e.useMemo(()=>Bn(J,V.effectiveSelectionHook,w),[J,V.effectiveSelectionHook,w]),te=e.useMemo(()=>co({categoryAccessor:l,valueAccessor:c,groupAccessor:h&&h!==l?h:void 0,groupLabel:"string"==typeof h?h:"group"}),[l,c,h]),ne=mo({componentName:"BarChart",data:i,accessors:{categoryAccessor:l,valueAccessor:c}});if(ne)return p.createElement(uo,{componentName:"BarChart",message:ne,width:I,height:R});const oe=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bar"},null!=i&&{data:U}),{oAccessor:l,rAccessor:c,projection:"horizontal"===u?"horizontal":"vertical",pieceStyle:ee,size:[I,R],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:V.margin,barPadding:y}),null!=m&&{roundedTop:m}),D&&{dataIdAccessor:D}),{baselinePadding:v,enableHover:H,showAxes:o.showAxes,oLabel:q,rLabel:Y,rFormat:d}),N&&{oFormat:N}),{showGrid:W,showCategoryTicks:B,oSort:f}),V.legendBehaviorProps),F&&{title:F}),$&&{description:$}),z&&{summary:z}),void 0!==G&&{accessibleTable:G}),s&&{className:s}),{tooltipContent:!1===b?()=>null:ro(b)||te}),(A||S||O||E)&&{customHoverBehavior:V.customHoverBehavior}),(S||O||A)&&{customClickBehavior:V.customClickBehavior}),x&&x.length>0&&{annotations:x}),Object.fromEntries(Object.entries(k).filter(([e])=>"pieceStyle"!==e)));return p.createElement(Ho,{componentName:"BarChart",width:I,height:R},p.createElement(Kr,Object.assign({ref:r},oe)))});function Zr({ref:t,frameRef:n,isPushMode:o,colorBy:r,colorScheme:i,showLegend:a,legendPosition:s,setup:l}){const c=Qo({isPushMode:o,colorBy:r,colorScheme:i,showLegend:a,legendPosition:s}),u=e.useCallback(c.wrapPush(e=>{var t;return null===(t=n.current)||void 0===t?void 0:t.push(e)}),[c.wrapPush]),d=e.useCallback(c.wrapPushMany(e=>{var t;return null===(t=n.current)||void 0===t?void 0:t.pushMany(e)}),[c.wrapPushMany]);return e.useImperativeHandle(t,()=>({push:u,pushMany:d,remove:e=>{var t,o;return null!==(o=null===(t=n.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,r;return null!==(r=null===(o=n.current)||void 0===o?void 0:o.update(e,t))&&void 0!==r?r:[]},clear:()=>{var e;c.resetCategories(),null===(e=n.current)||void 0===e||e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=n.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}),[u,d,c.resetCategories]),{effectiveLegendProps:e.useMemo(()=>c.streamingLegend?Object.assign(Object.assign({},l.legendBehaviorProps),{legend:c.streamingLegend,legendPosition:s||l.legendPosition}):l.legendBehaviorProps,[l.legendBehaviorProps,l.legendPosition,c.streamingLegend,s]),effectiveMargin:e.useMemo(()=>{if(c.streamingMarginAdjust){const e=Object.assign({},l.margin);for(const[t,n]of Object.entries(c.streamingMarginAdjust))n>e[t]&&(e[t]=n);return e}return l.margin},[l.margin,c.streamingMarginAdjust])}}Qr.displayName="BarChart";const Jr=e.forwardRef(function(t,n){const o=Zn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel,showCategoryTicks:t.showCategoryTicks,orientation:t.orientation}),r=e.useRef(null),{data:i,margin:a,className:s,categoryAccessor:l="category",stackBy:c,valueAccessor:u="value",orientation:d="vertical",valueFormat:h,colorBy:g,colorScheme:f,normalize:y=!1,sort:m=!1,barPadding:v=40,roundedTop:b,baselinePadding:x=!1,tooltip:k,annotations:w,frameProps:A={},selection:S,linkedHover:O,onObservation:E,onClick:M,hoverHighlight:j,chartId:C,loading:P,emptyContent:L,legendInteraction:_,legendPosition:B,color:N,categoryFormat:D}=t,I=o.width,R=o.height,H=o.enableHover,W=o.showGrid,F=o.showLegend,$=o.title,z=o.description,G=o.summary,q=o.accessibleTable,Y=o.categoryLabel,X=o.valueLabel,V=i||[],U=g||c,K=void 0===i,Q=Jo({data:V,rawData:i,colorBy:U,colorScheme:f,legendInteraction:_,legendPosition:B,selection:S,linkedHover:O,fallbackFields:U?["string"==typeof U?U:""]:[],unwrapData:!0,onObservation:E,onClick:M,hoverHighlight:j,chartType:"StackedBarChart",chartId:C,showLegend:F,userMargin:a,marginDefaults:o.marginDefaults,loading:P,emptyContent:L,width:I,height:R});if(Q.earlyReturn)return Q.earlyReturn;const Z=$n(),J=e.useMemo(()=>new Map,[V]),ee=e.useMemo(()=>(e,t)=>U?Q.colorScale?{fill:T(e,U,Q.colorScale)}:{}:{fill:zn(N,Z,f,t,J)},[U,Q.colorScale,N,Z,f,J]),te=e.useMemo(()=>{const e=null==A?void 0:A.pieceStyle;return e&&"function"==typeof e?(t,n)=>{const o=ee(t,n),r=e(t,n)||{};return Object.assign(Object.assign({},o),r)}:ee},[ee,A]),ne=e.useMemo(()=>Bn(te,Q.effectiveSelectionHook,S),[te,Q.effectiveSelectionHook,S]),oe=e.useMemo(()=>co({categoryAccessor:c,valueAccessor:u,groupAccessor:l}),[c,l,u]),re=mo({componentName:"StackedBarChart",data:i,accessors:{categoryAccessor:l,valueAccessor:u},requiredProps:{stackBy:c}}),{effectiveLegendProps:ie,effectiveMargin:ae}=Zr({ref:n,frameRef:r,isPushMode:K,colorBy:U,colorScheme:f,showLegend:F,legendPosition:B,setup:Q}),se=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bar"},null!=i&&{data:V}),{oAccessor:l,rAccessor:u,stackBy:c,normalize:y,oSort:m,projection:"horizontal"===d?"horizontal":"vertical",pieceStyle:ne,size:[I,R],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:ae,barPadding:v}),null!=b&&{roundedTop:b}),{baselinePadding:x,enableHover:H}),t.dataIdAccessor&&{dataIdAccessor:t.dataIdAccessor}),{showAxes:o.showAxes,oLabel:Y,rLabel:X,rFormat:h}),D&&{oFormat:D}),{showGrid:W}),ie),$&&{title:$}),z&&{description:z}),G&&{summary:G}),void 0!==q&&{accessibleTable:q}),s&&{className:s}),{tooltipContent:!1===k?()=>null:ro(k)||oe}),(O||E||M||j)&&{customHoverBehavior:Q.customHoverBehavior}),(E||M||O)&&{customClickBehavior:Q.customClickBehavior}),w&&w.length>0&&{annotations:w}),Object.fromEntries(Object.entries(A).filter(([e])=>"pieceStyle"!==e)));return re?p.createElement(uo,{componentName:"StackedBarChart",message:re,width:I,height:R}):p.createElement(Ho,{componentName:"StackedBarChart",width:I,height:R},p.createElement(Kr,Object.assign({ref:r},se)))});Jr.displayName="StackedBarChart";const ei=e.forwardRef(function(t,n){const o=Zn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel,showCategoryTicks:t.showCategoryTicks,orientation:t.orientation}),r=e.useRef(null),{data:i,margin:a,className:s,categoryAccessor:l="category",groupBy:c,valueAccessor:u="value",orientation:d="vertical",valueFormat:h,colorBy:g,colorScheme:f,sort:y=!1,barPadding:m=60,roundedTop:v,baselinePadding:b=!1,tooltip:x,annotations:k,frameProps:w={},selection:A,linkedHover:S,onObservation:O,onClick:E,hoverHighlight:M,chartId:j,loading:C,emptyContent:P,legendInteraction:L,legendPosition:_,color:B,categoryFormat:N}=t,D=o.width,I=o.height,R=o.enableHover,H=o.showGrid,W=o.showLegend,F=o.title,$=o.description,z=o.summary,G=o.accessibleTable,q=o.categoryLabel,Y=o.valueLabel,X=i||[],V=g||c,U=void 0===i,K=Jo({data:X,rawData:i,colorBy:V,colorScheme:f,legendInteraction:L,legendPosition:_,selection:A,linkedHover:S,fallbackFields:V?["string"==typeof V?V:""]:[],unwrapData:!0,onObservation:O,onClick:E,hoverHighlight:M,chartType:"GroupedBarChart",chartId:j,showLegend:W,userMargin:a,marginDefaults:o.marginDefaults,loading:C,emptyContent:P,width:D,height:I});if(K.earlyReturn)return K.earlyReturn;const Q=$n(),Z=e.useMemo(()=>new Map,[X]),J=e.useMemo(()=>(e,t)=>V?K.colorScale?{fill:T(e,V,K.colorScale)}:{}:{fill:zn(B,Q,f,t,Z)},[V,K.colorScale,B,Q,f,Z]),ee=e.useMemo(()=>Bn(J,K.effectiveSelectionHook,A),[J,K.effectiveSelectionHook,A]),te=e.useMemo(()=>co({categoryAccessor:c,valueAccessor:u,groupAccessor:l}),[c,l,u]),ne=mo({componentName:"GroupedBarChart",data:i,accessors:{categoryAccessor:l,valueAccessor:u},requiredProps:{groupBy:c}}),{effectiveLegendProps:oe,effectiveMargin:re}=Zr({ref:n,frameRef:r,isPushMode:U,colorBy:V,colorScheme:f,showLegend:W,legendPosition:_,setup:K}),ie=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"clusterbar"},null!=i&&{data:X}),{oAccessor:l,rAccessor:u,groupBy:c,oSort:y,projection:"horizontal"===d?"horizontal":"vertical",pieceStyle:ee,size:[D,I],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:re,barPadding:m}),null!=v&&{roundedTop:v}),{baselinePadding:b,enableHover:R}),t.dataIdAccessor&&{dataIdAccessor:t.dataIdAccessor}),{showAxes:o.showAxes,oLabel:q,rLabel:Y,rFormat:h}),N&&{oFormat:N}),{showGrid:H}),oe),F&&{title:F}),$&&{description:$}),z&&{summary:z}),void 0!==G&&{accessibleTable:G}),s&&{className:s}),{tooltipContent:!1===x?()=>null:ro(x)||te}),(S||O||E||M)&&{customHoverBehavior:K.customHoverBehavior}),(O||E||S)&&{customClickBehavior:K.customClickBehavior}),k&&k.length>0&&{annotations:k}),Object.fromEntries(Object.entries(w).filter(([e])=>"pieceStyle"!==e)));return ne?p.createElement(uo,{componentName:"GroupedBarChart",message:ne,width:D,height:I}):p.createElement(Ho,{componentName:"GroupedBarChart",width:D,height:I},p.createElement(Kr,Object.assign({ref:r},ie)))});function ti({brushProp:t,onBrushProp:n,linkedBrush:o,valueAccessor:r}){const i=Tn("string"==typeof o?o:o?{name:o.name,xField:o.rField}:void 0),a=En({name:(null==i?void 0:i.name)||"__unused_ordinal_brush__",xField:(null==i?void 0:i.xField)||("string"==typeof r?r:"value")}),s=e.useRef(a.brushInteraction);s.current=a.brushInteraction;const l=e.useCallback(e=>{if(i){s.current.end(e?e.r:null)}null==n||n(e)},[n,i]),c=!!(t||o||n);return{hasBrush:c,handleBrush:l,brushStreamProps:c?{brush:{dimension:"r"},onBrush:l}:{}}}ei.displayName="GroupedBarChart";const ni=e.forwardRef(function(t,n){const o=Zn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel,showCategoryTicks:t.showCategoryTicks,orientation:t.orientation}),r=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=r.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const{data:i,margin:a,className:s,categoryAccessor:l="category",valueAccessor:c="value",orientation:u="vertical",valueFormat:d,colorBy:h,colorScheme:g,sizeBy:f,sizeRange:y=[3,8],pointRadius:m=4,pointOpacity:v=.7,categoryPadding:b=20,tooltip:x,annotations:k,brush:w,onBrush:A,linkedBrush:S,frameProps:O={},selection:E,linkedHover:M,onObservation:j,onClick:C,hoverHighlight:P,chartId:L,loading:_,emptyContent:B,legendInteraction:D,legendPosition:I,color:R,showCategoryTicks:H,categoryFormat:W}=t,F=o.width,$=o.height,z=o.enableHover,G=o.showGrid,q=o.title,Y=o.description,X=o.summary,V=o.accessibleTable,U=o.categoryLabel,K=o.valueLabel,Q=i||[],Z=Jo({data:Q,rawData:i,colorBy:h,colorScheme:g,legendInteraction:D,legendPosition:I,selection:E,linkedHover:M,fallbackFields:h?["string"==typeof h?h:""]:["string"==typeof l?l:""],unwrapData:!0,onObservation:j,onClick:C,hoverHighlight:P,chartType:"SwarmPlot",chartId:L,showLegend:o.showLegend,userMargin:a,marginDefaults:o.marginDefaults,loading:_,emptyContent:B,width:F,height:$}),J=ti({brushProp:w,onBrushProp:A,linkedBrush:S,valueAccessor:c});if(Z.earlyReturn)return Z.earlyReturn;const ee=e.useMemo(()=>{if(!f)return;const e=Q.map(e=>"function"==typeof f?f(e):e[f]);return[Math.min(...e),Math.max(...e)]},[Q,f]),te=$n(),ne=e.useMemo(()=>new Map,[Q]),oe=e.useMemo(()=>(e,t)=>{const n={fillOpacity:v};return n.fill=h?T(e,h,Z.colorScale):zn(R,te,g,void 0,ne),n.r=f?N(e,f,y,ee):m,n},[h,Z.colorScale,f,y,ee,m,v,R,te,g,ne]),re=e.useMemo(()=>Bn(oe,Z.effectiveSelectionHook,E),[oe,Z.effectiveSelectionHook,E]),ie=e.useMemo(()=>co({categoryAccessor:l,valueAccessor:c,groupAccessor:h||void 0}),[l,c,h]),ae=mo({componentName:"SwarmPlot",data:i,accessors:{categoryAccessor:l,valueAccessor:c}});if(ae)return p.createElement(uo,{componentName:"SwarmPlot",message:ae,width:F,height:$});const se=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"swarm"},null!=i&&{data:Q}),{oAccessor:l,rAccessor:c,projection:"horizontal"===u?"horizontal":"vertical",pieceStyle:re,size:[F,$],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Z.margin,barPadding:b,enableHover:z}),t.dataIdAccessor&&{dataIdAccessor:t.dataIdAccessor}),{showAxes:o.showAxes,oLabel:U,rLabel:K,rFormat:d}),W&&{oFormat:W}),{showGrid:G,showCategoryTicks:H}),Z.legendBehaviorProps),q&&{title:q}),Y&&{description:Y}),X&&{summary:X}),void 0!==V&&{accessibleTable:V}),s&&{className:s}),{tooltipContent:!1===x?()=>null:ro(x)||ie}),(M||j||C||P)&&{customHoverBehavior:Z.customHoverBehavior}),(j||C||M)&&{customClickBehavior:Z.customClickBehavior}),k&&k.length>0&&{annotations:k}),J.brushStreamProps),Object.fromEntries(Object.entries(O).filter(([e])=>"pieceStyle"!==e)));return p.createElement(Ho,{componentName:"SwarmPlot",width:F,height:$},p.createElement(Kr,Object.assign({ref:r},se)))});function oi(e){return t=>{var n;const o=t.category||t.data&&(null===(n=t.data[0])||void 0===n?void 0:n.category)||"",r=t.stats||(t.data||t).stats;if(r&&null!=r.median)return p.createElement("div",{className:"semiotic-tooltip",style:eo},o&&p.createElement("div",{style:{fontWeight:"bold"}},o+""),null!=r.n&&p.createElement("div",null,"n = ",r.n),null!=r.min&&p.createElement("div",null,"Min: ",r.min.toLocaleString()),null!=r.q1&&p.createElement("div",null,"Q1: ",r.q1.toLocaleString()),p.createElement("div",null,"Median: ",r.median.toLocaleString()),null!=r.q3&&p.createElement("div",null,"Q3: ",r.q3.toLocaleString()),null!=r.max&&p.createElement("div",null,"Max: ",r.max.toLocaleString()),null!=r.mean&&p.createElement("div",{style:{opacity:.8}},"Mean: ",r.mean.toLocaleString(void 0,{maximumFractionDigits:2})));if(null==e?void 0:e.valueAccessor){const n=e.valueAccessor,r=(Array.isArray(t.data)?t.data:[]).map(e=>Number("function"==typeof n?n(e):e[n])).filter(e=>Number.isFinite(e)).sort((e,t)=>e-t),i=r.length,a=i>0?i%2!=0?r[Math.floor(i/2)]:(r[i/2-1]+r[i/2])/2:null;return p.createElement("div",{className:"semiotic-tooltip",style:eo},o&&p.createElement("div",{style:{fontWeight:"bold"}},o+""),i>0&&p.createElement("div",null,"n = ",i),null!=a&&p.createElement("div",null,"Median: ",a.toLocaleString()))}return p.createElement("div",{className:"semiotic-tooltip",style:eo},p.createElement("div",{style:{fontWeight:"bold"}},o+""))}}ni.displayName="SwarmPlot";const ri=e.forwardRef(function(t,n){const o=Zn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel,showCategoryTicks:t.showCategoryTicks,orientation:t.orientation}),r=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=r.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const{data:i,margin:a,className:s,categoryAccessor:l="category",valueAccessor:c="value",orientation:u="vertical",valueFormat:d,colorBy:h,colorScheme:g,showOutliers:f=!0,categoryPadding:y=20,tooltip:m,annotations:v,frameProps:b={},selection:x,linkedHover:k,onObservation:w,onClick:A,hoverHighlight:S,chartId:O,loading:E,emptyContent:M,legendInteraction:j,legendPosition:C,color:P,showCategoryTicks:L,categoryFormat:_}=t,B=o.width,N=o.height,D=o.enableHover,I=o.showGrid,R=o.title,H=o.description,W=o.summary,F=o.accessibleTable,$=o.categoryLabel,z=o.valueLabel,G=i||[],q=Jo({data:G,rawData:i,colorBy:h,colorScheme:g,legendInteraction:j,legendPosition:C,selection:x,linkedHover:k,fallbackFields:h?["string"==typeof h?h:""]:["string"==typeof l?l:""],unwrapData:!0,onObservation:w,onClick:A,hoverHighlight:S,chartType:"BoxPlot",chartId:O,showLegend:o.showLegend,userMargin:a,marginDefaults:o.marginDefaults,loading:E,emptyContent:M,width:B,height:N});if(q.earlyReturn)return q.earlyReturn;const Y=$n(),X=e.useMemo(()=>new Map,[G]),V=e.useMemo(()=>e=>{const t=h?T(e,h,q.colorScale):zn(P,Y,g,void 0,X);return{fill:t,stroke:t,fillOpacity:.8}},[h,q.colorScale,P,Y,g,X]),U=e.useMemo(()=>Bn(V,q.effectiveSelectionHook,x),[V,q.effectiveSelectionHook,x]),K=e.useMemo(()=>oi(),[]),Q=mo({componentName:"BoxPlot",data:i,accessors:{categoryAccessor:l,valueAccessor:c}});if(Q)return p.createElement(uo,{componentName:"BoxPlot",message:Q,width:B,height:N});const Z=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"boxplot"},null!=i&&{data:G}),{oAccessor:l,rAccessor:c,projection:"horizontal"===u?"horizontal":"vertical",summaryStyle:U,showOutliers:f,size:[B,N],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:q.margin,barPadding:y,enableHover:D}),t.dataIdAccessor&&{dataIdAccessor:t.dataIdAccessor}),{showAxes:o.showAxes,oLabel:$,rLabel:z,rFormat:d}),_&&{oFormat:_}),{showGrid:I,showCategoryTicks:L}),q.legendBehaviorProps),R&&{title:R}),H&&{description:H}),W&&{summary:W}),void 0!==F&&{accessibleTable:F}),s&&{className:s}),{tooltipContent:!1===m?()=>null:ro(m)||K}),(k||w||A||S)&&{customHoverBehavior:q.customHoverBehavior}),(w||A||k)&&{customClickBehavior:q.customClickBehavior}),v&&v.length>0&&{annotations:v}),Object.fromEntries(Object.entries(b).filter(([e])=>"pieceStyle"!==e)));return p.createElement(Ho,{componentName:"BoxPlot",width:B,height:N},p.createElement(Kr,Object.assign({ref:r},Z)))});ri.displayName="BoxPlot";const ii=e.forwardRef(function(t,n){const o=Zn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel,showCategoryTicks:t.showCategoryTicks,orientation:"horizontal"}),r=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=r.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const{data:i,margin:a,className:s,categoryAccessor:l="category",valueAccessor:c="value",bins:u=25,relative:d=!1,valueFormat:h,colorBy:g,colorScheme:f,categoryPadding:y=20,tooltip:m,annotations:v,brush:b,onBrush:x,linkedBrush:k,frameProps:w={},selection:A,linkedHover:S,onObservation:O,onClick:E,hoverHighlight:M,chartId:j,loading:C,emptyContent:P,legendInteraction:L,legendPosition:_,color:B,showCategoryTicks:N,categoryFormat:D}=t,I=o.width,R=o.height,H=o.enableHover,W=o.showGrid,F=o.title,$=o.description,z=o.summary,G=o.accessibleTable,q=o.categoryLabel,Y=o.valueLabel,X=i||[],V=Jo({data:X,rawData:i,colorBy:g,colorScheme:f,legendInteraction:L,legendPosition:_,selection:A,linkedHover:S,fallbackFields:g?["string"==typeof g?g:""]:["string"==typeof l?l:""],unwrapData:!0,onObservation:O,onClick:E,hoverHighlight:M,chartType:"Histogram",chartId:j,showLegend:o.showLegend,userMargin:a,marginDefaults:o.marginDefaults,loading:C,emptyContent:P,width:I,height:R}),U=ti({brushProp:b,onBrushProp:x,linkedBrush:k,valueAccessor:c});if(V.earlyReturn)return V.earlyReturn;const K=e.useMemo(()=>{if(0===X.length)return;const e="function"==typeof c?c:e=>e[c];let t=1/0,n=-1/0;for(const o of X){const r=e(o);null!=r&&isFinite(r)&&(t>r&&(t=r),r>n&&(n=r))}return t>n?void 0:[t,n]},[X,c]),Q=$n(),Z=e.useMemo(()=>new Map,[X]),J=e.useMemo(()=>e=>{const t=g?T(e,g,V.colorScale):zn(B,Q,f,void 0,Z);return{fill:t,stroke:t,fillOpacity:.8}},[g,V.colorScale,B,Q,f,Z]),ee=e.useMemo(()=>Bn(J,V.effectiveSelectionHook,A),[J,V.effectiveSelectionHook,A]),te=e.useMemo(()=>e=>{const t=e.data||e,n=t.category||e.category||"",o=t.count,r=t.range;return p.createElement("div",{className:"semiotic-tooltip",style:eo},n&&p.createElement("div",{style:{fontWeight:"bold"}},n+""),null!=o&&p.createElement("div",null,"Count: ",o),r&&2===r.length&&p.createElement("div",{style:{opacity:.8}},Number(r[0]).toFixed(1)," – ",Number(r[1]).toFixed(1)))},[]),ne=mo({componentName:"Histogram",data:i,accessors:{categoryAccessor:l,valueAccessor:c}});if(ne)return p.createElement(uo,{componentName:"Histogram",message:ne,width:I,height:R});const oe=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"histogram"},null!=i&&{data:X}),{oAccessor:l,rAccessor:c,projection:"horizontal",summaryStyle:ee,bins:u,normalize:d}),K&&{rExtent:K}),{size:[I,R],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:V.margin,barPadding:y,enableHover:H}),t.dataIdAccessor&&{dataIdAccessor:t.dataIdAccessor}),{showAxes:o.showAxes,oLabel:q,rLabel:Y,rFormat:h}),D&&{oFormat:D}),{showGrid:W,showCategoryTicks:N}),V.legendBehaviorProps),F&&{title:F}),$&&{description:$}),z&&{summary:z}),void 0!==G&&{accessibleTable:G}),s&&{className:s}),{tooltipContent:!1===m?()=>null:ro(m)||te}),(S||O||E||M)&&{customHoverBehavior:V.customHoverBehavior}),(O||E||S)&&{customClickBehavior:V.customClickBehavior}),v&&v.length>0&&{annotations:v}),U.brushStreamProps),Object.fromEntries(Object.entries(w).filter(([e])=>"pieceStyle"!==e)));return p.createElement(Ho,{componentName:"Histogram",width:I,height:R},p.createElement(Kr,Object.assign({ref:r},oe)))});ii.displayName="Histogram";const ai=e.forwardRef(function(t,n){const o=Zn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel,showCategoryTicks:t.showCategoryTicks,orientation:t.orientation}),r=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=r.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const{data:i,margin:a,className:s,categoryAccessor:l="category",valueAccessor:c="value",orientation:u="vertical",bins:d=25,showIQR:h=!0,valueFormat:g,colorBy:f,colorScheme:y,categoryPadding:m=20,tooltip:v,annotations:b,brush:x,onBrush:k,linkedBrush:w,frameProps:A={},selection:S,linkedHover:O,onObservation:E,onClick:M,hoverHighlight:j,chartId:C,loading:P,emptyContent:L,legendInteraction:_,legendPosition:B,color:N,showCategoryTicks:D,categoryFormat:I}=t,R=o.width,H=o.height,W=o.enableHover,F=o.showGrid,$=o.title,z=o.description,G=o.summary,q=o.accessibleTable,Y=o.categoryLabel,X=o.valueLabel,V=i||[],U=Jo({data:V,rawData:i,colorBy:f,colorScheme:y,legendInteraction:_,legendPosition:B,selection:S,linkedHover:O,fallbackFields:f?["string"==typeof f?f:""]:["string"==typeof l?l:""],unwrapData:!0,onObservation:E,onClick:M,hoverHighlight:j,chartType:"ViolinPlot",chartId:C,showLegend:o.showLegend,userMargin:a,marginDefaults:o.marginDefaults,loading:P,emptyContent:L,width:R,height:H}),K=ti({brushProp:x,onBrushProp:k,linkedBrush:w,valueAccessor:c});if(U.earlyReturn)return U.earlyReturn;const Q=$n(),Z=e.useMemo(()=>new Map,[V]),J=e.useMemo(()=>e=>{const t=f?T(e,f,U.colorScale):zn(N,Q,y,void 0,Z);return{fill:t,stroke:t,fillOpacity:.6}},[f,U.colorScale,N,Q,y,Z]),ee=e.useMemo(()=>Bn(J,U.effectiveSelectionHook,S),[J,U.effectiveSelectionHook,S]),te=e.useMemo(()=>oi({valueAccessor:c}),[c]),ne=mo({componentName:"ViolinPlot",data:i,accessors:{categoryAccessor:l,valueAccessor:c}});if(ne)return p.createElement(uo,{componentName:"ViolinPlot",message:ne,width:R,height:H});const oe=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"violin"},null!=i&&{data:V}),{oAccessor:l,rAccessor:c,projection:"horizontal"===u?"horizontal":"vertical",summaryStyle:ee,bins:d,showIQR:h,size:[R,H],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:U.margin,barPadding:m,enableHover:W}),t.dataIdAccessor&&{dataIdAccessor:t.dataIdAccessor}),{showAxes:o.showAxes,oLabel:Y,rLabel:X,rFormat:g}),I&&{oFormat:I}),{showGrid:F,showCategoryTicks:D}),U.legendBehaviorProps),$&&{title:$}),z&&{description:z}),G&&{summary:G}),void 0!==q&&{accessibleTable:q}),s&&{className:s}),{tooltipContent:!1===v?()=>null:ro(v)||te}),(O||E||M||j)&&{customHoverBehavior:U.customHoverBehavior}),(E||M||O)&&{customClickBehavior:U.customClickBehavior}),b&&b.length>0&&{annotations:b}),K.brushStreamProps),Object.fromEntries(Object.entries(A).filter(([e])=>"pieceStyle"!==e)));return p.createElement(Ho,{componentName:"ViolinPlot",width:R,height:H},p.createElement(Kr,Object.assign({ref:r},oe)))});ai.displayName="ViolinPlot";const si=e.forwardRef(function(t,n){var o;const r=Zn(t.mode,{width:t.width,height:t.height,showGrid:null===(o=t.showGrid)||void 0===o||o,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel,showCategoryTicks:t.showCategoryTicks,orientation:t.orientation}),i=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=i.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=i.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;return null===(e=i.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=i.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const{data:a,margin:s,className:l,categoryAccessor:c="category",valueAccessor:u="value",orientation:d="horizontal",valueFormat:h,colorBy:g,colorScheme:f,sort:y=!0,dotRadius:m=5,categoryPadding:v=10,tooltip:b,annotations:x,frameProps:k={},selection:w,linkedHover:A,onObservation:S,onClick:O,hoverHighlight:E,chartId:M,loading:j,emptyContent:C,legendInteraction:P,legendPosition:L,color:_,categoryFormat:B}=t,N=r.width,D=r.height,I=r.enableHover,R=r.showGrid,H=r.title,W=r.description,F=r.summary,$=r.accessibleTable,z=r.categoryLabel,G=r.valueLabel,q=a||[],Y=Jo({data:q,rawData:a,colorBy:g,colorScheme:f,legendInteraction:P,legendPosition:L,selection:w,linkedHover:A,fallbackFields:g?["string"==typeof g?g:""]:["string"==typeof c?c:""],unwrapData:!0,onObservation:S,onClick:O,hoverHighlight:E,chartType:"DotPlot",chartId:M,showLegend:r.showLegend,userMargin:s,marginDefaults:r.marginDefaults,loading:j,emptyContent:C,width:N,height:D});if(Y.earlyReturn)return Y.earlyReturn;const X=Yn(q,y,u),V=$n(),U=e.useMemo(()=>new Map,[q]),K=e.useMemo(()=>(e,t)=>{const n={r:m,fillOpacity:.8};return n.fill=g?T(e,g,Y.colorScale):zn(_,V,f,void 0,U),n},[g,Y.colorScale,m,_,V,f,U]),Q=e.useMemo(()=>Bn(K,Y.effectiveSelectionHook,w),[K,Y.effectiveSelectionHook,w]),Z=e.useMemo(()=>co({categoryAccessor:c,valueAccessor:u}),[c,u]),J=mo({componentName:"DotPlot",data:a,accessors:{categoryAccessor:c,valueAccessor:u}});if(J)return p.createElement(uo,{componentName:"DotPlot",message:J,width:N,height:D});const ee=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"point"},null!=a&&{data:X}),{oAccessor:c,rAccessor:u,projection:"horizontal"===d?"horizontal":"vertical",pieceStyle:Q,size:[N,D],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Y.margin,barPadding:v,enableHover:I}),t.dataIdAccessor&&{dataIdAccessor:t.dataIdAccessor}),{showAxes:r.showAxes,oLabel:z,rLabel:G,rFormat:h}),B&&{oFormat:B}),{showGrid:R,oSort:y}),Y.legendBehaviorProps),H&&{title:H}),W&&{description:W}),F&&{summary:F}),void 0!==$&&{accessibleTable:$}),l&&{className:l}),{tooltipContent:!1===b?()=>null:ro(b)||Z}),(A||S||O||E)&&{customHoverBehavior:Y.customHoverBehavior}),(S||O||A)&&{customClickBehavior:Y.customClickBehavior}),x&&x.length>0&&{annotations:x}),Object.fromEntries(Object.entries(k).filter(([e])=>"pieceStyle"!==e)));return p.createElement(Ho,{componentName:"DotPlot",width:N,height:D},p.createElement(Kr,Object.assign({ref:i},ee)))});si.displayName="DotPlot";const li=e.forwardRef(function(t,n){const o=Zn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel,showCategoryTicks:t.showCategoryTicks,orientation:t.orientation}),r=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=r.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const{data:i,margin:a,className:s,categoryAccessor:l="category",valueAccessor:c="value",orientation:u="horizontal",bins:d=20,amplitude:h=1.5,valueFormat:g,colorBy:f,colorScheme:y,categoryPadding:m=5,tooltip:v,annotations:b,frameProps:x={},selection:k,linkedHover:w,onObservation:A,onClick:S,hoverHighlight:O,chartId:E,loading:M,emptyContent:j,legendInteraction:C,legendPosition:P,color:L,showCategoryTicks:_,categoryFormat:B}=t,N=o.width,D=o.height,I=o.enableHover,R=o.showGrid,H=o.title,W=o.description,F=o.summary,$=o.accessibleTable,z=o.categoryLabel,G=o.valueLabel,q=i||[],Y=Jo({data:q,rawData:i,colorBy:f,colorScheme:y,legendInteraction:C,legendPosition:P,selection:k,linkedHover:w,fallbackFields:f?["string"==typeof f?f:""]:["string"==typeof l?l:""],unwrapData:!0,onObservation:A,onClick:S,hoverHighlight:O,chartType:"RidgelinePlot",chartId:E,showLegend:o.showLegend,userMargin:a,marginDefaults:o.marginDefaults,loading:M,emptyContent:j,width:N,height:D});if(Y.earlyReturn)return Y.earlyReturn;const X=$n(),V=e.useMemo(()=>new Map,[q]),U=e.useMemo(()=>e=>{const t=f?T(e,f,Y.colorScale):zn(L,X,y,void 0,V);return{fill:t,stroke:t,fillOpacity:.5}},[f,Y.colorScale,L,X,y,V]),K=e.useMemo(()=>Bn(U,Y.effectiveSelectionHook,k),[U,Y.effectiveSelectionHook,k]),Q=e.useMemo(()=>oi(),[]),Z=mo({componentName:"RidgelinePlot",data:i,accessors:{categoryAccessor:l,valueAccessor:c}});if(Z)return p.createElement(uo,{componentName:"RidgelinePlot",message:Z,width:N,height:D});const J=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"ridgeline"},null!=i&&{data:q}),{oAccessor:l,rAccessor:c,projection:"horizontal"===u?"horizontal":"vertical",summaryStyle:K,bins:d,size:[N,D],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Y.margin,barPadding:m,enableHover:I}),t.dataIdAccessor&&{dataIdAccessor:t.dataIdAccessor}),{showAxes:o.showAxes,oLabel:z,rLabel:G,rFormat:g}),B&&{oFormat:B}),{showGrid:R,showCategoryTicks:_,oSort:!1,amplitude:h}),Y.legendBehaviorProps),H&&{title:H}),W&&{description:W}),F&&{summary:F}),void 0!==$&&{accessibleTable:$}),s&&{className:s}),{tooltipContent:!1===v?()=>null:ro(v)||Q}),(w||A||S||O)&&{customHoverBehavior:Y.customHoverBehavior}),(A||S||w)&&{customClickBehavior:Y.customClickBehavior}),b&&b.length>0&&{annotations:b}),Object.fromEntries(Object.entries(x).filter(([e])=>"pieceStyle"!==e)));return p.createElement(Ho,{componentName:"RidgelinePlot",width:N,height:D},p.createElement(Kr,Object.assign({ref:r},J)))});li.displayName="RidgelinePlot";const ci=e.forwardRef(function(t,n){var o,r;const i=Zn(t.mode,{width:null!==(o=t.width)&&void 0!==o?o:400,height:null!==(r=t.height)&&void 0!==r?r:400,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary,showCategoryTicks:t.showCategoryTicks}),a=e.useRef(null),{data:s,margin:l,className:c,categoryAccessor:u="category",valueAccessor:d="value",colorBy:h,colorScheme:g,startAngle:f=0,cornerRadius:y,tooltip:m,annotations:v,frameProps:b={},selection:x,linkedHover:k,onObservation:w,onClick:A,hoverHighlight:S,chartId:O,loading:E,emptyContent:M,legendInteraction:j,legendPosition:C,color:P}=t,L=i.width,_=i.height,B=i.enableHover,N=i.showLegend,D=i.title,I=i.description,R=i.summary,H=i.accessibleTable,W=s||[],F=h||u,$=void 0===s,z=Jo({data:W,rawData:s,colorBy:F,colorScheme:g,legendInteraction:j,legendPosition:C,selection:x,linkedHover:k,fallbackFields:F?["string"==typeof F?F:""]:[],unwrapData:!0,onObservation:w,onClick:A,hoverHighlight:S,chartType:"PieChart",chartId:O,showLegend:N,userMargin:l,marginDefaults:i.marginDefaults,loading:E,emptyContent:M,width:L,height:_});if(z.earlyReturn)return z.earlyReturn;const G=$n(),q=e.useMemo(()=>new Map,[W]),Y=e.useMemo(()=>(e,t)=>F?z.colorScale?{fill:T(e,F,z.colorScale)}:{}:{fill:zn(P,G,g,t,q)},[F,z.colorScale,P,G,g,q]),X=e.useMemo(()=>{const e=null==b?void 0:b.pieceStyle;return e&&"function"==typeof e?(t,n)=>Object.assign(Object.assign({},Y(t,n)),e(t,n)||{}):Y},[Y,b]),V=e.useMemo(()=>Bn(X,z.effectiveSelectionHook,x),[X,z.effectiveSelectionHook,x]),U=e.useMemo(()=>co({categoryAccessor:u,valueAccessor:d,groupAccessor:h&&h!==u?h:void 0,groupLabel:"string"==typeof h?h:"group",pieData:!0}),[u,d,h]),K=mo({componentName:"PieChart",data:s,accessors:{categoryAccessor:u,valueAccessor:d}}),{effectiveLegendProps:Q,effectiveMargin:Z}=Zr({ref:n,frameRef:a,isPushMode:$,colorBy:F,colorScheme:g,showLegend:N,legendPosition:C,setup:z}),J=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"pie"},null!=s&&{data:W}),{oAccessor:u,rAccessor:d,projection:"radial",pieceStyle:V,startAngle:f}),null!=y&&{cornerRadius:y}),{size:[L,_],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Z,enableHover:B}),t.dataIdAccessor&&{dataIdAccessor:t.dataIdAccessor}),{showAxes:!1}),Q),D&&{title:D}),I&&{description:I}),R&&{summary:R}),void 0!==H&&{accessibleTable:H}),c&&{className:c}),{tooltipContent:!1===m?()=>null:ro(m)||U}),(k||w||A||S)&&{customHoverBehavior:z.customHoverBehavior}),(w||A||k)&&{customClickBehavior:z.customClickBehavior}),v&&v.length>0&&{annotations:v}),Object.fromEntries(Object.entries(b).filter(([e])=>"pieceStyle"!==e)));return K?p.createElement(uo,{componentName:"PieChart",message:K,width:L,height:_}):p.createElement(Ho,{componentName:"PieChart",width:L,height:_},p.createElement(Kr,Object.assign({ref:a},J)))});ci.displayName="PieChart";const ui=e.forwardRef(function(t,n){var o,r;const i=Zn(t.mode,{width:null!==(o=t.width)&&void 0!==o?o:400,height:null!==(r=t.height)&&void 0!==r?r:400,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary,linkedHover:t.linkedHover,showCategoryTicks:t.showCategoryTicks}),a=e.useRef(null),{data:s,margin:l,className:c,categoryAccessor:u="category",valueAccessor:d="value",innerRadius:h=60,centerContent:g,colorBy:f,colorScheme:y,startAngle:m=0,cornerRadius:v,tooltip:b,annotations:x,frameProps:k={},selection:w,linkedHover:A,onObservation:S,onClick:O,hoverHighlight:E,chartId:M,loading:j,emptyContent:C,legendInteraction:P,legendPosition:L,color:_}=t,B=i.width,N=i.height,D=i.enableHover,I=i.showLegend,R=i.title,H=i.description,W=i.summary,F=i.accessibleTable,$=s||[],z=f||u,G=void 0===s,q=Jo({data:$,rawData:s,colorBy:z,colorScheme:y,legendInteraction:P,legendPosition:L,selection:w,linkedHover:A,fallbackFields:z?["string"==typeof z?z:""]:[],unwrapData:!0,onObservation:S,onClick:O,hoverHighlight:E,chartType:"DonutChart",chartId:M,showLegend:I,userMargin:l,marginDefaults:i.marginDefaults,loading:j,emptyContent:C,width:B,height:N});if(q.earlyReturn)return q.earlyReturn;const Y=$n(),X=e.useMemo(()=>new Map,[$]),V=e.useMemo(()=>(e,t)=>z?q.colorScale?{fill:T(e,z,q.colorScale)}:{}:{fill:zn(_,Y,y,t,X)},[z,q.colorScale,_,Y,y,X]),U=e.useMemo(()=>Bn(V,q.effectiveSelectionHook,w),[V,q.effectiveSelectionHook,w]),K=e.useMemo(()=>co({categoryAccessor:u,valueAccessor:d,groupAccessor:f&&f!==u?f:void 0,groupLabel:"string"==typeof f?f:"group",pieData:!0}),[u,d,f]),Q=mo({componentName:"DonutChart",data:s,accessors:{categoryAccessor:u,valueAccessor:d}}),{effectiveLegendProps:Z,effectiveMargin:J}=Zr({ref:n,frameRef:a,isPushMode:G,colorBy:z,colorScheme:y,showLegend:I,legendPosition:L,setup:q}),ee=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"donut"},null!=s&&{data:$}),{oAccessor:u,rAccessor:d,projection:"radial",pieceStyle:U,innerRadius:h,startAngle:m}),null!=v&&{cornerRadius:v}),{centerContent:g,size:[B,N],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:J,enableHover:D}),t.dataIdAccessor&&{dataIdAccessor:t.dataIdAccessor}),{showAxes:!1}),Z),R&&{title:R}),H&&{description:H}),W&&{summary:W}),void 0!==F&&{accessibleTable:F}),c&&{className:c}),{tooltipContent:!1===b?()=>null:ro(b)||K}),(A||S||O||E)&&{customHoverBehavior:q.customHoverBehavior}),(S||O||A)&&{customClickBehavior:q.customClickBehavior}),x&&x.length>0&&{annotations:x}),Object.fromEntries(Object.entries(k).filter(([e])=>"pieceStyle"!==e)));return Q?p.createElement(uo,{componentName:"DonutChart",message:Q,width:B,height:N}):p.createElement(Ho,{componentName:"DonutChart",width:B,height:N},p.createElement(Kr,Object.assign({ref:a},ee)))});ui.displayName="DonutChart";const di=e.forwardRef(function(t,n){const o=Zn(t.mode,{width:t.width,height:t.height,showGrid:!1,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary,showCategoryTicks:!1}),r=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=r.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const{data:i,margin:a,className:s,stepAccessor:l="step",valueAccessor:c="value",categoryAccessor:u,colorBy:d,colorScheme:h,orientation:g="horizontal",connectorOpacity:f=.3,showLabels:y=!0,tooltip:m,annotations:v,frameProps:b={},selection:x,linkedHover:k,onObservation:w,onClick:A,hoverHighlight:S,chartId:O,loading:E,emptyContent:M,legendInteraction:j,legendPosition:C,color:P,categoryFormat:L}=t,_="vertical"===g,B=o.width,N=o.height,D=o.enableHover,I=o.title,R=o.description,H=o.summary,W=o.accessibleTable,F=i||[],$=d||u,z=!$,G=Jo({data:F,rawData:i,colorBy:$,colorScheme:h,legendInteraction:j,legendPosition:C,selection:x,linkedHover:k,fallbackFields:$?["string"==typeof $?$:""]:[],unwrapData:!0,onObservation:w,onClick:A,hoverHighlight:S,chartType:"FunnelChart",chartId:O,showLegend:o.showLegend,userMargin:a,marginDefaults:_?{top:I?60:40,right:20,bottom:60,left:60}:{top:I?40:10,right:10,bottom:10,left:10},loading:E,emptyContent:M,width:B,height:N});if(G.earlyReturn)return G.earlyReturn;Go("FunnelChart",F,"stepAccessor",l),Go("FunnelChart",F,"valueAccessor",c);const q=$n(),Y=e.useMemo(()=>new Map,[F]),X=e.useMemo(()=>{if(z)return P||((null==q?void 0:q[0])?q[0]:Array.isArray(h)&&h[0]?h[0]:"#4e79a7")},[z,P,q,h]),V=e.useMemo(()=>(e,t)=>{const n={};return n.fill=X||($?T(e,$,G.colorScale):zn(P,q,h,t,Y)),n},[X,$,G.colorScale,P,q,h,Y]),U=e.useMemo(()=>Bn(V,G.effectiveSelectionHook,x),[V,G.effectiveSelectionHook,x]),K=e.useMemo(()=>e=>{var t,n,o,r,i,a;const s=(null==e?void 0:e.data)||e,l=(null==s?void 0:s.__funnelStep)||(null==s?void 0:s.__barFunnelStep)||(null==s?void 0:s.step)||"",c=null!==(o=null!==(n=null!==(t=null==s?void 0:s.__funnelValue)&&void 0!==t?t:null==s?void 0:s.__barFunnelValue)&&void 0!==n?n:null==s?void 0:s.value)&&void 0!==o?o:"",u=null!==(r=null==s?void 0:s.__funnelPercent)&&void 0!==r?r:null==s?void 0:s.__barFunnelPercent,d=null!==(i=null==s?void 0:s.__funnelIsFirstStep)&&void 0!==i?i:null==s?void 0:s.__barFunnelIsFirstStep,h=null==s?void 0:s.__barFunnelIsDropoff,g=null!==(a=null==s?void 0:s.__barFunnelCategory)&&void 0!==a?a:null==s?void 0:s.category,f=null==u||d?"":` (${.05>Math.abs(u-Math.round(u))?Math.round(u)+"%":u.toFixed(1)+"%"})`;return p.createElement("div",{className:"semiotic-tooltip",style:eo},l&&p.createElement("div",{style:{fontWeight:"bold"}},l+""),g&&g!==l&&p.createElement("div",{style:{marginTop:2,opacity:.8}},g+""),h&&p.createElement("div",{style:{marginTop:2,fontStyle:"italic",opacity:.7}},"Dropoff"),p.createElement("div",{style:{marginTop:4}},c+"",f))},[]),Q=mo({componentName:"FunnelChart",data:i,accessors:{stepAccessor:l,valueAccessor:c}});if(Q)return p.createElement(uo,{componentName:"FunnelChart",message:Q,width:B,height:N});const Z=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:_?"bar-funnel":"funnel"},null!=i&&{data:F}),{oAccessor:l,rAccessor:c}),u&&{stackBy:u}),{projection:_?"vertical":"horizontal",barPadding:_?40:0,pieceStyle:U,size:[B,N],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:G.margin,enableHover:D}),t.dataIdAccessor&&{dataIdAccessor:t.dataIdAccessor}),{showAxes:_,showCategoryTicks:_}),L&&{oFormat:L}),{showGrid:_}),!_&&{connectorOpacity:f}),{showLabels:y}),G.legendBehaviorProps),I&&{title:I}),R&&{description:R}),H&&{summary:H}),void 0!==W&&{accessibleTable:W}),s&&{className:s}),{tooltipContent:!1===m?()=>null:!0===m||null==m?K:ro(m)||K}),(k||w||A||S)&&{customHoverBehavior:G.customHoverBehavior}),(w||A||k)&&{customClickBehavior:G.customClickBehavior}),v&&v.length>0&&{annotations:v}),Object.fromEntries(Object.entries(b).filter(([e])=>"pieceStyle"!==e)));return p.createElement(Ho,{componentName:"FunnelChart",width:B,height:N},p.createElement(Kr,Object.assign({ref:r},Z)))});di.displayName="FunnelChart";const hi="__likert_neutral_neg",gi="__likert_neutral_pos";function fi(e,t){if("function"==typeof e)return e;const n=e||t;return e=>e[n]}function pi(e,t,n,o,r,i){const a=new Map,s=new Set(t);for(const l of e){const e=n(l);a.has(e)||a.set(e,new Map);const c=a.get(e);if(o){const e=o(l);if(null==e||!Number.isFinite(e))continue;if(!Number.isInteger(e)){"production"!==process.env.NODE_ENV&&console.warn("[LikertChart] Ignoring non-integer Likert score:",e);continue}const n=e-1;if(0>n||n>=t.length)continue;const r=t[n];c.set(r,(c.get(r)||0)+1)}else if(r&&i){const e=r(l),t=i(l);if(!s.has(e))continue;c.set(e,(c.get(e)||0)+(Number.isFinite(t)?t:0))}}const l=[];for(const[e,n]of a){let o=0;for(const e of t)o+=n.get(e)||0;if(0!==o)for(let r=0;t.length>r;r++){const i=t[r],a=n.get(i)||0;l.push({__likertCategory:e,__likertLevel:i,__likertLevelLabel:i,__likertCount:a,__likertPct:a/o*100,__likertLevelIndex:r})}}return l}function yi(e,t){const n=t.length,o=n%2!=0,r=Math.floor(n/2),i=[];for(const t of e){const e=t.__likertLevelIndex;if(o&&e===r){const e=t.__likertPct/2;i.push(Object.assign(Object.assign({},t),{__likertLevel:hi,__likertPct:-e})),i.push(Object.assign(Object.assign({},t),{__likertLevel:gi,__likertPct:e}))}else i.push(r>e?Object.assign(Object.assign({},t),{__likertPct:-t.__likertPct}):t)}return i}function mi(e,t){const n=t.length,o=n%2!=0,r=Math.floor(n/2),i=new Map;for(const t of e){const e=i.get(t.__likertCategory)||[];e.push(t),i.set(t.__likertCategory,e)}const a=[];for(const[,e]of i){const t=new Map;let i,s;for(const n of e)n.__likertLevel===hi?i=n:n.__likertLevel===gi?s=n:t.set(n.__likertLevelIndex,n);o&&i&&a.push(i);for(let e=r-1;e>=0;e--){const n=t.get(e);n&&a.push(n)}o&&s&&a.push(s);for(let e=o?r+1:r;n>e;e++){const n=t.get(e);n&&a.push(n)}}return a}const vi=e.forwardRef(function(t,n){const o=Zn(t.mode,{width:t.width,height:t.height,showGrid:t.showGrid,enableHover:t.enableHover,showLegend:t.showLegend,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary,categoryLabel:t.categoryLabel,valueLabel:t.valueLabel,showCategoryTicks:t.showCategoryTicks,orientation:t.orientation}),r=e.useRef(null),{data:i,margin:a,className:s,categoryAccessor:l="question",valueAccessor:c,levelAccessor:u,countAccessor:d="count",levels:h,orientation:g="horizontal",colorScheme:f,barPadding:y=20,tooltip:m,annotations:v,frameProps:b={},selection:x,linkedHover:k,onObservation:w,onClick:A,hoverHighlight:S,chartId:O,valueFormat:E,loading:M,emptyContent:j,legendInteraction:C,legendPosition:P,categoryFormat:L}=t,_=o.width,T=o.height,B=o.enableHover,N=o.showGrid,D=o.showLegend,I=o.title,R=o.description,H=o.summary,W=o.accessibleTable,F=o.categoryLabel,$=o.valueLabel,z="horizontal"===g,G=void 0===i,q=!u,Y=e.useMemo(()=>f&&Array.isArray(f)&&f.length>=h.length?f:function(e){const t=["#da1e28","#ff8389","#ffb3b8"],n=["#a6c8ff","#4589ff","#0043ce"],o="#a8a8a8";if(0>=e)return[];if(1===e)return[o];const r=e%2!=0,i=Math.floor(e/2),a=[];for(let e=0;i>e;e++)a.push(t[Math.min(Math.floor(e*t.length/i),t.length-1)]);r&&a.push(o);for(let e=0;i>e;e++)a.push(n[Math.min(Math.floor(e*n.length/i),n.length-1)]);return a}(h.length),[f,h.length]),X=e.useMemo(()=>{const e=new Map;for(let t=0;h.length>t;t++)e.set(h[t],Y[t]||"#888");return e},[h,Y]),{processedData:V,reAggregate:U,accumulatorRef:K}=function({data:t,levels:n,categoryAccessor:o,valueAccessor:r,levelAccessor:i,countAccessor:a,isDiverging:s,frameRef:l}){const c=!i,u=e.useMemo(()=>fi(o,"question"),[o]),d=e.useMemo(()=>c?fi(r,"score"):null,[c,r]),h=e.useMemo(()=>c?null:fi(i,"level"),[c,i]),g=e.useMemo(()=>c?null:fi(a,"count"),[c,a]),f=t||[],p=e.useRef([]),y=e.useMemo(()=>{if(0===f.length)return[];let e=pi(f,n,u,d,h,g);return s&&(e=yi(e,n),e=mi(e,n)),e},[f,n,u,d,h,g,s]),m=e.useCallback(e=>{var t,o;let r=pi(e,n,u,d,h,g);s&&(r=yi(r,n),r=mi(r,n)),null===(t=l.current)||void 0===t||t.clear(),r.length>0&&(null===(o=l.current)||void 0===o||o.pushMany(r))},[n,u,d,h,g,s,l]);return{processedData:y,reAggregate:m,accumulatorRef:p}}({data:i,levels:h,categoryAccessor:l,valueAccessor:c,levelAccessor:u,countAccessor:d,isDiverging:z,frameRef:r}),Q="__likertLevelLabel",Z=Qo({isPushMode:G,colorBy:Q,colorScheme:Y,showLegend:D,legendPosition:P}),J=e.useCallback(Z.wrapPush(e=>{K.current.push(e),U(K.current)}),[Z.wrapPush,U,K]),ee=e.useCallback(Z.wrapPushMany(e=>{K.current.push(...e),U(K.current)}),[Z.wrapPushMany,U,K]);e.useImperativeHandle(n,()=>({push:J,pushMany:ee,remove:e=>{var t,n;return null!==(n=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=r.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;K.current=[],Z.resetCategories(),null===(e=r.current)||void 0===e||e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}),[J,ee,Z.resetCategories,K]);const te=Jo({data:V,rawData:i,colorBy:Q,colorScheme:Y,legendInteraction:C,legendPosition:P,selection:x,linkedHover:k,fallbackFields:["__likertLevelLabel"],unwrapData:!0,onObservation:w,onClick:A,hoverHighlight:S,chartType:"LikertChart",chartId:O,showLegend:D,userMargin:a,marginDefaults:o.marginDefaults,loading:M,emptyContent:j,width:_,height:T});if(te.earlyReturn)return te.earlyReturn;const ne=e.useMemo(()=>{const e=h.length;return e%2!=0&&X.get(h[Math.floor(e/2)])||"#888"},[h,X]),oe=e.useMemo(()=>e=>{var t,n;const o=e.__likertLevelLabel||(null===(t=e.data)||void 0===t?void 0:t.__likertLevelLabel),r=e.__likertLevel||(null===(n=e.data)||void 0===n?void 0:n.__likertLevel);if(r===hi||r===gi)return{fill:ne};const i=o||r;return i&&X.has(i)?{fill:X.get(i)}:{fill:"#888"}},[X,ne]),re=e.useMemo(()=>Bn(oe,te.effectiveSelectionHook,x),[oe,te.effectiveSelectionHook,x]),ie=e.useMemo(()=>{const e=h.length;return e%2!=0?h[Math.floor(e/2)]:""},[h]),ae=e.useMemo(()=>e=>{const t=e.data||e,n=t.__likertLevel||"Unknown",o=n===hi||n===gi?ie:n,r=t.__likertCategory||"",i=Math.abs(t.__likertPct||0),a=n===hi||n===gi?2*i:i,s=t.__likertCount||0;return p.createElement("div",{className:"semiotic-tooltip",style:eo},p.createElement("div",{style:{fontWeight:"bold"}},r),p.createElement("div",{style:{marginTop:4}},`${o}: ${a.toFixed(1)}% (n=${s})`))},[ie]),se=e.useMemo(()=>{if(!h||2>h.length)return"LikertChart requires `levels` with at least 2 entries.";if(c&&u)return"LikertChart: provide either `valueAccessor` (raw responses) or `levelAccessor` + `countAccessor` (pre-aggregated), not both.";if(u&&!d)return"LikertChart: pre-aggregated mode requires both `levelAccessor` and `countAccessor`.";if(void 0!==i&&0===i.length)return null;const e={categoryAccessor:l};return q?c&&(e.valueAccessor=c):(u&&(e.levelAccessor=u),d&&(e.countAccessor=d)),mo({componentName:"LikertChart",data:i,accessors:e,requiredProps:{levels:h}})},[i,l,c,u,d,h,q]),le=e.useMemo(()=>[{styleFn:e=>({fill:X.get(e.label)||"#888"}),items:h.map(e=>({label:e})),label:""}],[h,X]),ce=e.useMemo(()=>!1!==D?Object.assign(Object.assign({},te.legendBehaviorProps),{legend:{legendGroups:le},legendPosition:P||te.legendPosition||"bottom"}):te.legendBehaviorProps,[te.legendBehaviorProps,te.legendPosition,P,D,le]),ue=e.useMemo(()=>{const e=Object.assign({},te.margin);if(G&&!1!==D){const t=P||"bottom";"bottom"===t&&80>e.bottom?e.bottom=80:"top"===t&&50>e.top?e.top=50:"right"===t&&110>e.right?e.right=110:"left"===t&&110>e.left&&(e.left=110)}else if(Z.streamingMarginAdjust)for(const[t,n]of Object.entries(Z.streamingMarginAdjust))n>e[t]&&(e[t]=n);return z&&100>e.left&&(e.left=100),e},[te.margin,Z.streamingMarginAdjust,z,G,D,P]),de=e.useMemo(()=>E||(z?e=>Math.abs(Number(e)).toFixed(0)+"%":e=>Number(e).toFixed(0)+"%"),[z,E]),he=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bar"},null!=i&&{data:V}),{oAccessor:"__likertCategory",rAccessor:"__likertPct",stackBy:"__likertLevel",normalize:!1,projection:z?"horizontal":"vertical",pieceStyle:re,size:[_,T],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:ue,barPadding:y,enableHover:B}),t.dataIdAccessor&&{dataIdAccessor:t.dataIdAccessor}),{showAxes:o.showAxes,oLabel:F,rLabel:$||(z?void 0:"Percentage"),rFormat:de}),L&&{oFormat:L}),{showGrid:N}),ce),I&&{title:I}),R&&{description:R}),H&&{summary:H}),void 0!==W&&{accessibleTable:W}),s&&{className:s}),{tooltipContent:!1===m?()=>null:!0===m?ae:ro(m)||ae}),(k||w||A||S)&&{customHoverBehavior:te.customHoverBehavior}),(w||A||k)&&{customClickBehavior:te.customClickBehavior}),v&&v.length>0&&{annotations:v}),Object.fromEntries(Object.entries(b).filter(([e])=>"pieceStyle"!==e)));return se?p.createElement(uo,{componentName:"LikertChart",message:se,width:_,height:T}):p.createElement(Ho,{componentName:"LikertChart",width:_,height:T},p.createElement(Kr,Object.assign({ref:r},he)))});vi.displayName="LikertChart";const bi={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},xi={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class ki{constructor(e){this.capacity=e,this.particles=Array(e);for(let t=0;e>t;t++)this.particles[t]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0}}spawn(e){for(let t=0;this.capacity>t;t++){const n=this.particles[t];if(!n.active)return n.active=!0,n.t=0,n.offset=Math.random()-.5,n.edgeIndex=e,n.x=0,n.y=0,n}return null}step(e,t,n,o){var r;for(let i=0;this.capacity>i;i++){const a=this.particles[i];if(!a.active)continue;const s=n[a.edgeIndex];if(!s||!s.bezier){a.active=!1;continue}const l=o&&null!==(r=o[a.edgeIndex])&&void 0!==r?r:1;if(a.t+=e*t*l*(s.bezier.circular?.3:1),a.t>=1){a.active=!1;continue}const c=wi(s.bezier,a.t,a.offset);a.x=c.x,a.y=c.y}}countForEdge(e){let t=0;for(let n=0;this.capacity>n;n++)this.particles[n].active&&this.particles[n].edgeIndex===e&&t++;return t}clear(){for(let e=0;this.capacity>e;e++)this.particles[e].active=!1}resize(e){if(this.capacity>=e)return;const t=this.particles;this.particles=Array(e);for(let n=0;e>n;n++)this.particles[n]=t.length>n?t[n]:{t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0};this.capacity=e}}function wi(e,t,n){if(e.circular&&e.segments)return function(e,t,n,o){const r=e.length,i=t*r,a=Math.min(Math.floor(i),r-1),s=i-a,[l,c,u,d]=e[a],h=Ai(l,c,u,d,s),g=d.x-l.x,f=d.y-l.y,p=Math.sqrt(g*g+f*f);if(p>.001){const e=g/p;h.x+=-f/p*n*o*2,h.y+=e*n*o*2}return h}(e.segments,t,n,e.halfWidth);if(!e.points)return{x:0,y:0};const[o,r,i,a]=e.points,s=Ai(o,r,i,a,t),l=a.x-o.x,c=a.y-o.y,u=Math.sqrt(l*l+c*c);if(u>.001){const t=l/u;s.x+=-c/u*n*e.halfWidth*2,s.y+=t*n*e.halfWidth*2}return s}function Ai(e,t,n,o,r){const i=1-r,a=i*i,s=a*i,l=r*r,c=l*r;return{x:s*e.x+3*a*r*t.x+3*i*l*n.x+c*o.x,y:s*e.y+3*a*r*t.y+3*i*l*n.y+c*o.y}}function Si(e,t){var n=e.get(t);if(!n)throw Error("missing: "+t);return n}function Oi(e,t){var n,o=[],r=[],i=[],a={},s=[];function l(e){i[e]=!1,a.hasOwnProperty(e)&&Object.keys(a[e]).forEach(function(t){delete a[e][t],i[t]&&l(t)})}function c(e){var t,o,d=!1;for(r.push(e),i[e]=!0,t=0;s[e].length>t;t++)(o=s[e][t])===n?(u(n,r),d=!0):i[o]||(d=c(o));if(d)l(e);else for(t=0;s[e].length>t;t++){var h=a[o=s[e][t]];h||(a[o]=h={}),h[o]=!0}return r.pop(),d}function u(e,t){var n=[].concat(t).concat(e);o.push(n)}function d(t){!function(t){for(var n=0;e.length>n;n++)n>=t&&e[n]||(e[n]=[]),e[n]=e[n].filter(function(e){return e>=t})}(t);for(var n,o=function(e){for(var t=e.length,n=Array(t),o=Array(t),r=Array(t),i=Array(t),a=Array(t),s=Array(t),l=0;t>l;++l)n[l]=-1,o[l]=0,r[l]=!1,i[l]=0,a[l]=-1,s[l]=[];var c,u=0,d=[],h=[];function g(t){var l=[t],c=[t];for(n[t]=o[t]=u,r[t]=!0,u+=1;c.length>0;){var g=e[t=c[c.length-1]];if(g.length>i[t]){for(var f=i[t];g.length>f;++f){var p=g[f];if(0>n[p]){n[p]=o[p]=u,r[p]=!0,u+=1,l.push(p),c.push(p);break}r[p]&&(o[t]=0|Math.min(o[t],o[p])),0>a[p]||s[t].push(a[p])}i[t]=f}else{if(o[t]===n[t]){var y=[],m=[],v=0;for(f=l.length-1;f>=0;--f){var b=l[f];if(r[b]=!1,y.push(b),m.push(s[b]),v+=s[b].length,a[b]=d.length,b===t){l.length=f;break}}d.push(y);var x=Array(v);for(f=0;m.length>f;f++)for(var k=0;m[f].length>k;k++)x[--v]=m[f][k];h.push(x)}c.pop()}}}for(l=0;t>l;++l)0>n[l]&&g(l);for(l=0;h.length>l;l++){var f=h[l];if(0!==f.length){f.sort(function(e,t){return e-t}),c=[f[0]];for(var p=1;f.length>p;p++)f[p]!==f[p-1]&&c.push(f[p]);h[l]=c}}return{components:d,adjacencyList:h}}(e),r=o.components.filter(function(e){return e.length>1}),i=1/0,a=0;r.length>a;a++)for(var s=0;r[a].length>s;s++)i>r[a][s]&&(i=r[a][s],n=a);var l=r[n];if(!l)return!1;var c=e.map(function(e,t){return-1===l.indexOf(t)?[]:e.filter(function(e){return-1!==l.indexOf(e)})});return{leastVertex:i,adjList:c}}n=0;for(var h=e.length;h>n;){var g=d(n);if(n=g.leastVertex,s=g.adjList){for(var f=0;s.length>f;f++)for(var p=0;s[f].length>p;p++){var y=s[f][p];i[+y]=!1,a[y]={}}c(n),n+=1}else n=h}return o}function Ei(e){return e.y0-e.y1>0?"up":"down"}function Mi(e,t){return t(e.source)==t(e.target)}function ji(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var n=0;return e.target.targetLinks.forEach(function(e){n=e.circular?n+1:n}),1>=t&&1>=n}function Ci(e){return e.target.x0-e.source.x1}function Pi(e,t){var n=_i(e),o=Ci(t)/Math.tan(n);return"up"==Ei(e)?e.y1-o:e.y1+o}function Li(e,t){var n=_i(e),o=Ci(t)/Math.tan(n);return"up"==Ei(e)?e.y1+o:e.y1-o}function _i(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function Ti(e,t){return t(e)}function Bi(e){return Di(e.source)}function Ni(e){return Di(e.target)}function Di(e){return(e.y0+e.y1)/2}function Ii(e){return e.virtual?0:e.value}function Ri(e,t){var n=0;e.sourceLinks.forEach(function(e){n=e.circular&&!Mi(e,t)?n+1:n});var o=0;return e.targetLinks.forEach(function(e){o=e.circular&&!Mi(e,t)?o+1:o}),n+o}function Hi(e){return e.target.depth}function Wi(e,t){return e.sourceLinks.length?e.depth:t-1}function Fi(e,t){return e.y0-t.y0}function $i(e,t){return t.y0-e.y0}function zi(e,t){return e.y1-t.y1}function Gi(e,t){return t.y1-e.y1}function qi(e,t){return Xi(e.source,t.source)||e.index-t.index}function Yi(e,t){return Xi(e.target,t.target)||e.index-t.index}function Xi(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function Vi(e,t){return Ui(e)==Ui(t)?"bottom"==e.circularLinkType?$i(e,t):Fi(e,t):Ui(t)-Ui(e)}function Ui(e){return e.target.column-e.source.column}function Ki(e,t){return Qi(e)==Qi(t)}function Qi(e){return e.y0-e.y1>0?"up":"down"}function Zi(e,t,n,o,r){let i=e;var s=Math.max(8,.15*(i.y1-i.y0));i.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,s))});var l=a.min(i.links,function(e){return e.source.y0});i.links.forEach(function(e){e.circular&&(e.circularPathData={})});var c=i.links.filter(function(e){return e.circular});return c.sort(function(e,t){return t.value-e.value}),c.forEach(function(e,t){e._circularStub=t>=4}),Ji(i.links.filter(function(e){return"top"==e.circularLinkType}),t,n),Ji(i.links.filter(function(e){return"bottom"==e.circularLinkType}),t,n),i.links.forEach(function(e){if(e.circular){if(e.circularPathData.arcRadius=e._circularWidth+o,e.circularPathData.rightNodeBuffer=5,e.circularPathData.leftNodeBuffer=5,e.circularPathData.sourceWidth=e.source.x1-e.source.x0,e.circularPathData.sourceX=e.source.x0+e.circularPathData.sourceWidth,e.circularPathData.targetX=e.target.x0,e.circularPathData.sourceY=e.y0,e.circularPathData.targetY=e.y1,Mi(e,t)&&ji(e))e.circularPathData.rightSmallArcRadius=o+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=o+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=o+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=o+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+r+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=e.source.y0-r-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius);else{var a=e.source.column,s=e.circularLinkType,c=i.links.filter(function(e){return e.source.column==a&&e.circularLinkType==s});c.sort("bottom"==e.circularLinkType?$i:Fi);var u=0;c.forEach(function(t,r){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=o+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=o+e._circularWidth/2+r*n+u),u+=t._circularWidth||t.width}),a=e.target.column,(c=i.links.filter(function(e){return e.target.column==a&&e.circularLinkType==s})).sort("bottom"==e.circularLinkType?Gi:zi),u=0,c.forEach(function(t,r){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=o+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=o+e._circularWidth/2+r*n+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(i.y1,e.source.y1,e.target.y1)+r+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=l-r-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius)}e.circularPathData.rightInnerExtent=e.circularPathData.sourceX+e.circularPathData.rightNodeBuffer,e.circularPathData.leftInnerExtent=e.circularPathData.targetX-e.circularPathData.leftNodeBuffer,e.circularPathData.rightFullExtent=e.circularPathData.sourceX+e.circularPathData.rightLargeArcRadius+e.circularPathData.rightNodeBuffer,e.circularPathData.leftFullExtent=e.circularPathData.targetX-e.circularPathData.leftLargeArcRadius-e.circularPathData.leftNodeBuffer}e.path=e.circular?function(e){return"top"==e.circularLinkType?"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 0 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY-e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 0 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 0 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY-e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 0 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY:"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 1 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY+e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 1 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 1 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY+e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 1 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY}(e):function(e){var t=e.source.x1,n=e.y0,o=e.target.x0,r=e.y1,i=(t+o)/2;return"M"+t+","+n+"C"+i+","+n+" "+i+","+r+" "+o+","+r}(e)}),i}function Ji(e,t,n){e.sort(Vi);var o=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,r){var i=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(Mi(e,t)&&ji(e))e.circularPathData.verticalBuffer=i+e._circularWidth/2;else{for(var a=0;o.length>a;a++){var s=o[a];if(s!==e&&s.circularPathData&&void 0!==s.circularPathData.verticalBuffer&&ea(e,s)){var l=s.circularPathData.verticalBuffer+(s._circularWidth||s.width)/2+n;i=l>i?l:i}}e.circularPathData.verticalBuffer=i+e._circularWidth/2}}),e}function ea(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}function ta(e){return function(){return e}}function na(e){return e.index}function oa(e){return e.nodes}function ra(e){return e.links}function ia(e,t,n){var o=a.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});o.forEach(function(r,i){var a=r.length;if(t)r.sort(t);else if(i>0){var s=new Map;r.forEach(function(e,t){var n,o,r,i=(o=0,r=0,(n=e).targetLinks.forEach(function(e){if(!e.circular){var t=e.value||1;r+=Di(e.source)*t,o+=t}}),n.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;r+=Di(e.target)*t,o+=t}}),o>0?r/o:NaN);s.set(e,{bc:i,idx:t})}),r.sort(function(e,t){var n=s.get(e),o=s.get(t),r=n.bc,i=o.bc;if(e.circularLinkType!==t.circularLinkType){if("top"==e.circularLinkType&&"bottom"==t.circularLinkType)return-1;if("bottom"==e.circularLinkType&&"top"==t.circularLinkType)return 1;if("top"==e.circularLinkType)return-1;if("top"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return-1}return isNaN(r)||isNaN(i)?isNaN(r)?isNaN(i)?n.idx-o.idx:1:-1:r-i})}else r.sort(function(e,t){return e.circularLinkType==t.circularLinkType?Ri(t,n)-Ri(e,n):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0});r.forEach(function(t,r){t.depth==o.length-1&&1==a||0==t.depth&&1==a?(t.y0=e.y1/2-t.value*e.ky,t.y1=t.y0+t.value*e.ky):t.partOfCycle?0==Ri(t,n)?(t.y0=e.y1/2+r,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+r,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-r,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/a*r,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-a/2+r,t.y1=t.y0+t.value*e.ky)})})}function aa(e,t,n,o,r,i){var s=a.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});d();for(var l=1,c=i;c>0;--c)u(l*=.99,n),d();function u(t,n){var o=s.length;s.forEach(function(r){var i=r.length,s=r[0].depth;r.forEach(function(r){var l;if(r.sourceLinks.length||r.targetLinks.length)if(r.partOfCycle&&Ri(r,n)>0){var c=a.mean(r.sourceLinks,Ni),u=a.mean(r.targetLinks,Bi),d=c&&u?(c+u)/2:c||u;if(d){var h=(d-Di(r))*t*.3;r.y0+=h,r.y1+=h}}else if(0==s&&1==i)r.y0=e.y1/2-(l=r.y1-r.y0)/2,r.y1=e.y1/2+l/2;else if(s==o-1&&1==i)r.y0=e.y1/2-(l=r.y1-r.y0)/2,r.y1=e.y1/2+l/2;else if(1==r.targetLinks.length&&1==r.targetLinks[0].source.sourceLinks.length)l=r.y1-r.y0,r.y0=r.targetLinks[0].source.y0,r.y1=r.y0+l;else{var g=a.mean(r.sourceLinks,Ni),f=a.mean(r.targetLinks,Bi),p=((g&&f?(g+f)/2:g||f)-Di(r))*t;r.y0+=p,r.y1+=p}})})}function d(){s.forEach(function(n){var i,a,s,l=e.y0,c=n.length;for(n.sort(t||Xi),s=0;c>s;++s)(a=l-(i=n[s]).y0)>0&&(i.y0+=a,i.y1+=a),l=i.y1+o;if((a=l-o-e.y1)>0)for(l=i.y0-=a,i.y1-=a,s=c-2;s>=0;--s)(a=(i=n[s]).y1+r-l)>0&&(i.y0-=a,i.y1-=a),l=i.y0})}}function sa(e){e.nodes.forEach(function(e){e.sourceLinks.sort(Yi),e.targetLinks.sort(qi)}),e.nodes.forEach(function(e){var t=e.y0,n=t,o=e.y1,r=o;e.sourceLinks.forEach(function(e){e.circular?(e.y0=o-e.width/2,o-=e.width):(e.y0=t+e.width/2,t+=e.width)}),e.targetLinks.forEach(function(e){e.circular?(e.y1=r-e.width/2,r-=e.width):(e.y1=n+e.width/2,n+=e.width)})})}function la(){var e=0,t=0,n=1,o=1,r=24,i=8,s=null,l=na,c=Wi,u=void 0,d=32,h=2,g=oa,f=ra;function p(){var p={nodes:g.apply(null,arguments),links:f.apply(null,arguments)};return function(g){g.x0=e,g.y0=t,g.x1=n,g.y1=o,g.py=0,function(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var n=function(e,t){var n=new Map;return a.group(e,t).forEach(function(e,t){n.set(t,e[0])}),n}(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var o=e.source,r=e.target;"object"!=typeof o&&(o=e.source=Si(n,o)),"object"!=typeof r&&(r=e.target=Si(n,r)),o.sourceLinks.push(e),r.targetLinks.push(e)})}(g,l),function(e,t){var n=0;if(null==t){for(var o=[],r=0;e.links.length>r;r++){var i=e.links[r],a=i.source.index,s=i.target.index;o[a]||(o[a]=[]),o[s]||(o[s]=[]),-1===o[a].indexOf(s)&&o[a].push(s)}var l=Oi(o);l.sort(function(e,t){return e.length-t.length});var c={};for(r=0;l.length>r;r++){var u=l[r].slice(-2);c[u[0]]||(c[u[0]]={}),c[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,o=e.source.index;t===o||c[o]&&c[o][t]?(e.circular=!0,e.circularLinkID=n++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=n++)})}(g,u),function(e,t){var n=0,o=0;e.links.forEach(function(r){r.circular&&(r.circularLinkType=r.source.circularLinkType||r.target.circularLinkType?r.source.circularLinkType?r.source.circularLinkType:r.target.circularLinkType:o>n?"top":"bottom","top"==r.circularLinkType?n++:o++,e.nodes.forEach(function(e){Ti(e,t)!=Ti(r.source,t)&&Ti(e,t)!=Ti(r.target,t)||(e.circularLinkType=r.circularLinkType)}))}),e.links.forEach(function(e){e.circular&&(e.source.circularLinkType==e.target.circularLinkType&&(e.circularLinkType=e.source.circularLinkType),Mi(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(g,l),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(a.sum(e.sourceLinks,Ii),a.sum(e.targetLinks,Ii)),e.sourceLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)}),e.targetLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)})})}(g),function(e,t,n){var o,r,i;if(null!=t){e.nodes.sort(function(e,n){return t(e)<t(n)?-1:1});var a=0,s=t(e.nodes[0]);e.nodes.forEach(function(e){a=t(e)==s?a:a+1,s=t(e)==s?s:t(e),e.column=a})}for(o=e.nodes,r=[],i=0;o.length;++i,o=r,r=[])o.forEach(function(e){e.depth=i,e.sourceLinks.forEach(function(e){0>r.indexOf(e.target)&&!e.circular&&r.push(e.target)})});for(o=e.nodes,r=[],i=0;o.length;++i,o=r,r=[])o.forEach(function(e){e.height=i,e.targetLinks.forEach(function(e){0>r.indexOf(e.source)&&!e.circular&&r.push(e.source)})});e.nodes.forEach(function(e){e.column=null==t?n(e,i):e.column})}(g,u,c);var f=i;if(null!==s){var p=a.groups(g.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),y=a.max(p,function(e){return e.length});y>1&&(f=Math.max(1,(o-t)*s/(y-1)))}(function(e,t,n){var o=a.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});e.py=t;var r=a.min(o,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/a.sum(t,function(e){return e.value})});e.ky=r,e.links.forEach(function(t){t.width=t.value*e.ky});var i=a.max(e.nodes,function(e){return e.column});e.nodes.forEach(i>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-n)/i),t.x1=t.x0+n}:function(t){t.x0=e.x0,t.x1=t.x0+n})})(g,f,r),ia(g,u,l),aa(g,u,l,f,f,d),sa(g),Zi(g,l,h,10,8),ia(g,u,l),aa(g,u,l,f,f,d),sa(g),Zi(g,l,h,10,8),function(e,t){let n=e;n.nodes.forEach(function(e){e.y+(e.y1-e.y0)>n.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-n.y1));var o=n.links.filter(function(n){return Ti(n.source,t)==Ti(e,t)}),r=o.length;r>1&&o.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!Ki(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var n=Pi(t,e);return e.y1-n}if(t.target.column>e.target.column)return Pi(e,t)-t.y1}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.target.column===t.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.target.column===t.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;o.forEach(function(e){e.y0=i+e.width/2,i+=e.width}),o.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,a=0;r>i;i++)a+=o[i].width;t.y0=e.y1-a-t.width/2}})})}(g,l),function(e,t){let n=e;n.nodes.forEach(function(e){var o=n.links.filter(function(n){return Ti(n.target,t)==Ti(e,t)}),r=o.length;r>1&&o.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!Ki(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var n=Li(t,e);return e.y0-n}if(t.source.column>e.source.column)return Li(e,t)-t.y0}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:e.source.column-t.source.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:t.source.column-e.source.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;o.forEach(function(e){e.y1=i+e.width/2,i+=e.width}),o.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,a=0;r>i;i++)a+=o[i].width;t.y1=e.y1-a-t.width/2}})})}(g,l),function(e){var t=e.nodes,n=e.links,o=!1,r=!1;if(n.forEach(function(e){"top"==e.circularLinkType?o=!0:"bottom"==e.circularLinkType&&(r=!0)}),0==o||0==r){var i=a.min(t,function(e){return e.y0}),s=a.max(t,function(e){return e.y1}),l=(e.y1-e.y0)/(s-i);function c(t){return(t-i)/(s-i)*(e.y1-e.y0)+e.y0}1>l?(t.forEach(function(e){e.y0=c(e.y0),e.y1=c(e.y1)}),n.forEach(function(e){e.y0=c(e.y0),e.y1=c(e.y1),e.width=e.width*l})):t.forEach(function(e){var t=e.y1-e.y0,n=c(e.y0)-e.y0;e.y0=c(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+n}),e.targetLinks.forEach(function(e){e.y1=e.y1+n})})}}(g),Zi(g,l,h,10,8)}(p),p}return p.update=function(e){return sa(e),Zi(e,l,h,10,8),e},p.nodeWidth=function(e){return arguments.length?(r=+e,p):r},p.nodePadding=function(e){return arguments.length?(i=+e,p):i},p.nodePaddingRatio=function(e){return arguments.length?(s=+e,p):s},p.nodes=function(e){return arguments.length?(g="function"==typeof e?e:ta(e),p):g},p.links=function(e){return arguments.length?(f="function"==typeof e?e:ta(e),p):f},p.nodeId=function(e){return arguments.length?(l="function"==typeof e?e:ta(e),p):l},p.nodeAlign=function(e){return arguments.length?(c="function"==typeof e?e:ta(e),p):c},p.nodeSort=function(e){return arguments.length?(u=e,p):u},p.iterations=function(e){return arguments.length?(d=+e,p):d},p.circularLinkGap=function(e){return arguments.length?(h=+e,p):h},p.extent=function(r){return arguments.length?(e=+r[0][0],t=+r[0][1],n=+r[1][0],o=+r[1][1],p):[[e,t],[n,o]]},p.size=function(r){return arguments.length?(e=t=0,n=+r[0],o=+r[1],p):[n-e,o-t]},p}const ca=e=>{let t,n,o,r,i,a,s,l,c;return"down"===e.direction?(t=e.y0-e.sankeyWidth/2,n=e.y1-e.sankeyWidth/2,o=e.y1+e.sankeyWidth/2,r=e.y0+e.sankeyWidth/2,i=e.source.x1,a=e.target.x0,s=u.interpolateNumber(i,a),l=s(.5),c=s(.5),`M${t},${i}C${t},${l} ${n},${c} ${n},${a}L${o},${a}C${o},${c} ${r},${l} ${r},${i}Z`):(t=e.source.x1,n=e.target.x0,s=u.interpolateNumber(t,n),o=s(.5),r=s(.5),i=e.y0-e.sankeyWidth/2,a=e.y1-e.sankeyWidth/2,l=e.y1+e.sankeyWidth/2,c=e.y0+e.sankeyWidth/2,`M${t},${i}C${o},${i} ${r},${a} ${n},${a}L${n},${l}C${r},${l} ${o},${c} ${t},${c}Z`)};function ua(e){var t;const n=e.sankeyWidth/2,o=(null!==(t=e._circularWidth)&&void 0!==t?t:e.sankeyWidth)/2,r=e.circularPathData;if(!r)return null;if("down"===e.direction)return null;if(e._circularStub){const t=r.sourceX,o=r.sourceY,i=r.targetX,a=r.targetY;if("object"!=typeof e.source||!e.source||"object"!=typeof e.target||!e.target)return null;const s=Math.max(15,Math.min(40,.33*(r.rightFullExtent-t))),l=Math.max(15,Math.min(40,.33*(i-r.leftFullExtent)));return`M${t},${o-n}L${t+s},${o-n}L${t+s},${o+n}L${t},${o+n}ZM${i},${a-n}L${i-l},${a-n}L${i-l},${a+n}L${i},${a+n}Z`}const i=r.sourceX,a=r.sourceY,s=r.targetX,l=r.targetY,c=r.rightFullExtent,u=r.leftFullExtent,d=r.verticalFullExtent,h="bottom"===e.circularLinkType?1:-1,g=Math.max(4,Math.min(o,15));return`M${i},${a-h*n}L${c},${a-h*n}L${c+o},${a-h*n+h*g}L${c+o},${d+h*o-h*g}L${c+o-g},${d+h*o}L${u-o+g},${d+h*o}L${u-o},${d+h*o-h*g}L${u-o},${l-h*n+h*g}L${u-o+g},${l-h*n}L${s},${l-h*n}L${s},${l+h*n}L${u+o},${l+h*n}L${u+o},${d-h*o}L${c-o},${d-h*o}L${c-o},${a+h*n}L${i},${a+h*n}Z`}const da=new Set,ha=new WeakMap;function ga(e,t){if("production"===process.env.NODE_ENV)return e;if(!e||!e.data||"object"!=typeof e.data)return e;let n=ha.get(e);if(n){const e=n.get(t);if(e)return e}else n=new Map,ha.set(e,n);const o=new Proxy(e,{get(e,n,o){if("string"==typeof n&&!(n in e)&&e.data&&n in e.data){const e=`${t}:${n}`;da.has(e)||(da.add(e),console.warn(`[Semiotic] "${t}" callback accessed "${n}" on the wrapper object, but it only exists on ".data". Use d.data.${n} (or d.data?.${n}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(e,n,o)}});return n.set(t,o),o}const fa={left:function(e){return e.depth},right:function(e,t){return t-1-e.height},center:function(e){return e.targetLinks.length?e.depth:e.sourceLinks.length?Math.min.apply(Math,e.sourceLinks.map(Hi))-1:0},justify:Wi},pa={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,o){var r,i,a,s,l,c,u;if(0===e.length)return;const d="vertical"===n.orientation?"down":"right",h=n.nodeAlign||"justify",g=null!==(r=n.nodeWidth)&&void 0!==r?r:15,f=null!==(i=n.nodePaddingRatio)&&void 0!==i?i:.05,p=null!==(a=n.iterations)&&void 0!==a?a:100,y=e.map(e=>Object.assign({},e)),m=t.map(e=>Object.assign(Object.assign({},e),{source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id,value:Math.sqrt(Math.max(1,e.value||1))}));let v;v="down"===d?[[0,0],[o[1],o[0]]]:[[0,0],[o[0],o[1]]];const b=la().extent(v).links(m).nodes(y).nodeAlign(fa[h]||Wi).nodeId(e=>e.id).nodeWidth(g).iterations(p);b.nodePaddingRatio&&b.nodePaddingRatio(f),b();{let e=1/0,t=-1/0,n=1/0,r=-1/0;for(const o of y)e>o.x0&&(e=o.x0),o.x1>t&&(t=o.x1),n>o.y0&&(n=o.y0),o.y1>r&&(r=o.y1);for(const o of m){if(!o.circular||!o.circularPathData)continue;const i=o.circularPathData,a=(null!==(l=null!==(s=o._circularWidth)&&void 0!==s?s:o.width)&&void 0!==l?l:0)/2;e>i.leftFullExtent-a&&(e=i.leftFullExtent-a),i.rightFullExtent+a>t&&(t=i.rightFullExtent+a),n>i.verticalFullExtent-a&&(n=i.verticalFullExtent-a),i.verticalFullExtent+a>r&&(r=i.verticalFullExtent+a)}const i=t-e,a=r-n,u=o[0],d=o[1];if(i>0&&a>0&&(0>e||0>n||t>u||r>d)){const t=Math.min(u/i,d/a),o=-e*t+(u-i*t)/2,r=-n*t+(d-a*t)/2;for(const e of y)e.x0=e.x0*t+o,e.x1=e.x1*t+o,e.y0=e.y0*t+r,e.y1=e.y1*t+r;for(const e of m)if(e.y0=e.y0*t+r,e.y1=e.y1*t+r,e.width=(null!==(c=e.width)&&void 0!==c?c:0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){const n=e.circularPathData;n.sourceX=n.sourceX*t+o,n.targetX=n.targetX*t+o,n.sourceY=n.sourceY*t+r,n.targetY=n.targetY*t+r,n.rightFullExtent=n.rightFullExtent*t+o,n.leftFullExtent=n.leftFullExtent*t+o,n.verticalFullExtent=n.verticalFullExtent*t+r,n.rightInnerExtent=n.rightInnerExtent*t+o,n.leftInnerExtent=n.leftInnerExtent*t+o,n.verticalRightInnerExtent=n.verticalRightInnerExtent*t+r,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*t+r,n.rightSmallArcRadius*=t,n.rightLargeArcRadius*=t,n.leftSmallArcRadius*=t,n.leftLargeArcRadius*=t,n.sourceWidth*=t,n.rightNodeBuffer*=t,n.leftNodeBuffer*=t,n.arcRadius*=t}}}const x=new Map;for(const t of e)x.set(t.id,t);for(const e of y){const t=x.get(e.id);t&&(t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.value=e.value,t.depth=e.depth,t.sourceLinks=e.sourceLinks,t.targetLinks=e.targetLinks,t.width=e.x1-e.x0,t.height=e.y1-e.y0,t.x=e.x0+(e.x1-e.x0)/2,t.y=e.y0+(e.y1-e.y0)/2)}const k=new Map;for(const e of t)k.set(e._edgeKey?e._edgeKey:`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const e of m){const t=e.source,n=e.target,o="object"==typeof t&&null!==t?t.id:t+"",r="object"==typeof n&&null!==n?n.id:n+"",i=k.get(e._edgeKey?e._edgeKey:`${o}\0${r}`);if(i){i.y0=e.y0,i.y1=e.y1,i.sankeyWidth=null!==(u=e.width)&&void 0!==u?u:0,i.circular=!!e.circular,i.circularPathData=e.circularPathData,i._circularWidth=e._circularWidth,i._circularStub=e._circularStub,i.path=e.path,i.circularLinkType=e.circularLinkType,i.direction=d;const t=x.get(o),n=x.get(r);t&&(i.source=t),n&&(i.target=n)}}},buildScene(e,t,n,o){var r,a,s,l;const c="vertical"===n.orientation?"down":"right",u=n.nodeStyle,d=n.edgeStyle,h=null!==(r=n.edgeOpacity)&&void 0!==r?r:.5,g=n.edgeColorBy||"source",f=Array.isArray(n.colorScheme)?n.colorScheme:i.schemeCategory10,p=new Map;e.forEach((e,t)=>{p.set(e.id,f[t%f.length])});const y=[],m=[],v=[],b=new Map;for(const t of e){const e=t.x1-t.x0,n=t.y1-t.y0;if(0>=e||0>=n)continue;const o=u?u(ga(t,"nodeStyle")):{},r={fill:o.fill||p.get(t.id)||"#4d430c",stroke:o.stroke,strokeWidth:o.strokeWidth,opacity:o.opacity};b.set(t.id,("string"==typeof r.fill?r.fill:null)||p.get(t.id)||"#4d430c"),y.push("down"===c?{type:"rect",x:t.y0,y:t.x0,w:n,h:e,style:r,datum:t,id:t.id,label:t.id}:{type:"rect",x:t.x0,y:t.y0,w:e,h:n,style:r,datum:t,id:t.id,label:t.id})}const x=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of x){if(!e.sankeyWidth||0>=e.sankeyWidth)continue;const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;if(!t||!n)continue;let o="#999";o="function"==typeof g?g(e)||o:"target"===g?b.get(n.id)||p.get(n.id)||o:b.get(t.id)||p.get(t.id)||o;const r=d?d(ga(e,"edgeStyle")):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,n=e.sankeyWidth/2,i=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),l=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),c=r.fill||o;m.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-n}L${t.sourceX+i},${t.sourceY-n}L${t.sourceX+i},${t.sourceY+n}L${t.sourceX},${t.sourceY+n}Z`,style:{fill:c,fillOpacity:null!==(a=r.fillOpacity)&&void 0!==a?a:h,stroke:"none",opacity:r.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+i}}),m.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-n}L${t.targetX-l},${t.targetY-n}L${t.targetX-l},${t.targetY+n}L${t.targetX},${t.targetY+n}Z`,style:{fill:c,fillOpacity:null!==(s=r.fillOpacity)&&void 0!==s?s:h,stroke:"none",opacity:r.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-l,x1:t.targetX}});continue}let i;if(i=e.circular&&e.circularPathData?ua(e):ca(e),!i)continue;const c={fill:r.fill||o,fillOpacity:null!==(l=r.fillOpacity)&&void 0!==l?l:h,stroke:r.stroke||"none",strokeWidth:r.strokeWidth,opacity:r.opacity};m.push({type:"bezier",pathD:i,bezierCache:e.bezier,style:c,datum:e})}if(!1!==n.showLabels){const t=(k=n.nodeLabel)?"function"==typeof k?k:e=>e[k]||e.id:null;for(const n of e){const e=n.x1-n.x0,r=n.y1-n.y0;if(0>=e||0>=r)continue;const i=t?t(n):n.id;if(!i)continue;let a,s,l;"down"===c?(a=n.y0+(n.y1-n.y0)/2,s=n.x1+14,l="middle"):(o[0]/2>n.x0+e/2?(a=n.x0-6,l="end"):(a=n.x1+6,l="start"),s=n.y0+r/2),v.push({x:a,y:s,text:i+"",anchor:l,baseline:"middle",fontSize:11})}}var k;return{sceneNodes:y,sceneEdges:m,labels:v}}},ya={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,o){var r,i;if(0===e.length)return;const a=null!==(r=n.forceStrength)&&void 0!==r?r:.1,s=o[0]/2,l=o[1]/2,c=n.__previousPositions;let u=0;const h=[];for(const t of e){const e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),n=null==c?void 0:c.get(t.id);e?u++:n?(t.x=n.x,t.y=n.y,u++):h.push(t)}const g=u>0&&.3>=(e.length>0?h.length/e.length:1);if(g){const n=new Map;for(const t of e)n.set(t.id,t);for(const e of h){const o=ma(e.id,t,n);if(o.length>0){let t=0,n=0;for(const e of o)t+=e.x,n+=e.y;const r=va(e.id),i=r%360*(Math.PI/180),a=10+r%20;e.x=t/o.length+a*Math.cos(i),e.y=n/o.length+a*Math.sin(i)}else{const t=va(e.id),n=t%360*(Math.PI/180),o=15+t%30;e.x=s+o*Math.cos(n),e.y=l+o*Math.sin(n)}}}else{const t=2.399963229728653;for(let n=0;e.length>n;n++){const o=e[n];if(null==o.x||null==o.y||0===o.x&&0===o.y){const e=10*Math.sqrt(n+.5),r=n*t;o.x=s+e*Math.cos(r),o.y=l+e*Math.sin(r)}}}const f=null!==(i=n.iterations)&&void 0!==i?i:Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),p=0===n.iterations?0:g?40:f,y=ba(n.nodeSize,n.nodeSizeRange,e),m=e=>y(e);if(p>0){const n=d.forceLink().strength(e=>Math.min(2.5,e.weight?e.weight*a:a)).id(e=>e.id),o=d.forceSimulation().force("charge",d.forceManyBody().strength(e=>-25*m(e))).force("center",d.forceCenter(s,l).strength(.8)).force("x",d.forceX(s).strength(.15)).force("y",d.forceY(l).strength(.15));if(o.nodes(e),t.length>0){const e=t.map(e=>Object.assign(Object.assign({},e),{source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id}));o.force("link",n),o.force("link").links(e)}g?o.alpha(.3):.1>o.alpha()&&o.alpha(1),o.stop();for(let e=0;p>e;++e)o.tick()}for(const t of e){if(null==t.x||null==t.y)continue;const e=m(t);t.x=Math.max(e,Math.min(o[0]-e,t.x)),t.y=Math.max(e,Math.min(o[1]-e,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}const v=new Map;for(const t of e)v.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=v.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=v.get(e.target);t&&(e.target=t)}}},buildScene(e,t,n,o){var r,a,s;const l=n.nodeStyle,c=n.edgeStyle,u=ba(n.nodeSize,n.nodeSizeRange,e),d=Array.isArray(n.colorScheme)?n.colorScheme:i.schemeCategory10,h=new Map;e.forEach((e,t)=>{h.set(e.id,d[t%d.length])});const g=[],f=[],p=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=u(ga(t,"nodeSize")),n=l?l(ga(t,"nodeStyle")):{},o={fill:n.fill||h.get(t.id)||"#007bff",stroke:n.stroke||"#fff",strokeWidth:null!==(r=n.strokeWidth)&&void 0!==r?r:2,opacity:n.opacity};g.push({type:"circle",cx:t.x,cy:t.y,r:e,style:o,datum:t,id:t.id,label:t.id})}const y=new Map;for(const t of e)y.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:y.get(e.source),n="object"==typeof e.target?e.target:y.get(e.target);if(!t||!n)continue;if(null==t.x||null==t.y)continue;if(null==n.x||null==n.y)continue;const o=c?c(ga(e,"edgeStyle")):{},r={stroke:o.stroke||"#999",strokeWidth:null!==(a=o.strokeWidth)&&void 0!==a?a:1,opacity:null!==(s=o.opacity)&&void 0!==s?s:.6};f.push({type:"line",x1:t.x,y1:t.y,x2:n.x,y2:n.y,style:r,datum:e})}if(!1!==n.showLabels){const t=(m=n.nodeLabel)?"function"==typeof m?m:e=>e[m]||e.id:null;for(const n of e){if(null==n.x||null==n.y)continue;const e=t?t(n):n.id;if(!e)continue;const o=u(ga(n,"nodeSize"));p.push({x:n.x,y:n.y-o-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var m;return{sceneNodes:g,sceneEdges:f,labels:p}}};function ma(e,t,n){const o=[];for(const r of t){const t="string"==typeof r.source?r.source:r.source.id,i="string"==typeof r.target?r.target:r.target.id;let a=null;if(t===e?a=i:i===e&&(a=t),a){const e=n.get(a);!e||0===e.x&&0===e.y||o.push({x:e.x,y:e.y})}}return o}function va(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return Math.abs(t)}function ba(e,t,n){var r,i;if(null==e)return()=>8;if("number"==typeof e)return()=>e;if("function"==typeof e)return t=>e(t)||8;const s=t||[5,20],l=n.map(t=>{var n;return null===(n=t.data)||void 0===n?void 0:n[e]}).filter(e=>null!=e&&"number"==typeof e);if(0===l.length)return()=>s[0];const c=null!==(r=a.min(l))&&void 0!==r?r:0,u=null!==(i=a.max(l))&&void 0!==i?i:1;if(c===u)return()=>(s[0]+s[1])/2;const d=o.scaleLinear().domain([c,u]).range(s).clamp(!0);return t=>{var n;const o=null===(n=t.data)||void 0===n?void 0:n[e];return null==o||"number"!=typeof o?s[0]:d(o)}}const xa=i.schemeCategory10,ka={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,n,o){if(0===e.length)return;const{padAngle:r=.01,groupWidth:i=20,sortGroups:a}=n,s=Math.min(o[0],o[1])/2,c=s-i,u=o[0]/2,d=o[1]/2,g=(f=n.valueAccessor)?"function"==typeof f?f:e=>{var t;return null!==(t=e[f])&&void 0!==t?t:1}:e=>{var t;return null!==(t=e.value)&&void 0!==t?t:1};var f;const p=new Map;for(let t=0;e.length>t;t++)p.set(e[t].id,t);const y=e.length,m=Array.from({length:y},()=>Array.from({length:y},()=>0));for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,n=p.get("string"==typeof e.source?e.source:e.source.id),o=p.get(t);if(void 0===n||void 0===o)continue;const r=g(e);m[n][o]=r}const v=h.chord().padAngle(r);a&&v.sortGroups(a);const b=v(m),x=b.groups,k=l.arc().innerRadius(c).outerRadius(s);for(const t of x){const n=e[t.index],o=k.centroid(t);n.x=o[0]+u,n.y=o[1]+d,n.arcData={startAngle:t.startAngle,endAngle:t.endAngle}}const w=new Map;for(const t of e)w.set(t.id,t);for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,n=w.get("string"==typeof e.source?e.source:e.source.id),o=w.get(t);n&&(e.source=n),o&&(e.target=o)}const A=new Map;for(const e of t)A.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const t of b){const n=e[t.source.index].id,o=e[t.target.index].id,r=A.get(`${n}\0${o}`)||A.get(`${o}\0${n}`);r&&(r.chordData=t)}},buildScene(e,t,n,o){var r,i;const{groupWidth:a=20,edgeOpacity:s=.5}=n,l=Math.min(o[0],o[1])/2,c=l-a,u=o[0]/2,d=o[1]/2,g=n.nodeStyle,f=n.edgeStyle,p=n.edgeColorBy||"source",y=Array.isArray(n.colorScheme)?n.colorScheme:xa,m=new Map;e.forEach((e,t)=>{m.set(e.id,y[t%y.length])});const v=h.ribbon().radius(c),b=[],x=[],k=[];for(let t=0;e.length>t;t++){const n=e[t],o=n.arcData;if(!o)continue;let i;i=g?g(ga(n,"nodeStyle")).fill||m.get(n.id)||y[t%y.length]:m.get(n.id)||y[t%y.length];const a=g?g(ga(n,"nodeStyle")):{},s={fill:i,stroke:a.stroke||"black",strokeWidth:null!==(r=a.strokeWidth)&&void 0!==r?r:1,opacity:a.opacity};b.push({type:"arc",cx:u,cy:d,innerR:c,outerR:l,startAngle:o.startAngle-Math.PI/2,endAngle:o.endAngle-Math.PI/2,style:s,datum:n,id:n.id,label:n.id})}for(const e of t){const t=e.chordData;if(!t)continue;const n=v(t);if(!n)continue;const o=wa(n,u,d);let r="#999";if(f)r=f(ga(e,"edgeStyle")).fill||r;else{const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;"target"===p&&n?r=m.get(n.id)||r:t&&(r=m.get(t.id)||r)}const a=f?f(ga(e,"edgeStyle")):{},l={fill:r,fillOpacity:null!==(i=a.fillOpacity)&&void 0!==i?i:s,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity};x.push({type:"ribbon",pathD:o,style:l,datum:e})}if(!1!==n.showLabels){const t=(w=n.nodeLabel)?"function"==typeof w?w:e=>e[w]||e.id:null,o=l+12;for(const n of e){const e=n.arcData;if(!e)continue;const r=t?t(n):n.id;if(!r)continue;const i=(e.startAngle+e.endAngle)/2,a=i-Math.PI/2;k.push({x:u+Math.cos(a)*o,y:d+Math.sin(a)*o,text:r+"",anchor:i>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var w;return{sceneNodes:b,sceneEdges:x,labels:k}}};function wa(e,t,n){const o=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!o)return e;const r=[];let i=0;for(;o.length>i;){const e=o[i];if("M"===e||"L"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)r.push(Number(o[i])+t+""),i++,o.length>i&&!isNaN(Number(o[i]))&&(r.push(Number(o[i])+n+""),i++);else if("C"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)for(let e=0;3>e&&o.length>i&&!isNaN(Number(o[i]));e++)r.push(Number(o[i])+t+""),i++,o.length>i&&!isNaN(Number(o[i]))&&(r.push(Number(o[i])+n+""),i++);else if("Q"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)for(let e=0;2>e&&o.length>i&&!isNaN(Number(o[i]));e++)r.push(Number(o[i])+t+""),i++,o.length>i&&!isNaN(Number(o[i]))&&(r.push(Number(o[i])+n+""),i++);else if("A"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&(r.push(Number(o[i])+t+""),i++),o.length>i&&(r.push(Number(o[i])+n+""),i++);else"Z"===e||"z"===e?(r.push(e),i++):(r.push(o[i]),i++)}return r.join(" ")}const Aa=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Sa(e){const[t,n,o]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*n+.114*o>150?"#222":"#fff"}function Oa(e,t,n){const o=t.nodeIDAccessor;return"function"==typeof o?o(e.data)+"":"string"==typeof o&&void 0!==e.data[o]?e.data[o]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+n}function Ea(e){return e?"function"==typeof e?e:t=>{var n;return(null===(n=t.data)||void 0===n?void 0:n[e])||t[e]||t.id}:null}function Ma(e){return Array.isArray(e.colorScheme)?e.colorScheme:Aa}function ja(e){return Array.isArray(e.colorScheme)&&e.colorScheme.length>0?e.colorScheme[0]:"#4d430c"}function Ca(e,t,n,o,r){if("horizontal"===r){const r=(e+n)/2;return`M ${e},${t} C ${r},${t} ${r},${o} ${n},${o}`}if("radial"===r){const r=(e+n)/2;return`M ${e},${t} Q ${r},${t} ${r},${(t+o)/2} T ${n},${o}`}{const r=(t+o)/2;return`M ${e},${t} C ${e},${r} ${n},${r} ${n},${o}`}}const Pa={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,n,o){var r;const i=n.__hierarchyRoot;if(!i)return;const a=n.chartType,l=function(e){if(e)return"function"==typeof e?e:t=>t[e]}(n.childrenAccessor),c=n.hierarchySum,u="function"==typeof c?c:"string"==typeof c?e=>{var t;return null!==(t=e[c])&&void 0!==t?t:0}:e=>{var t;return null!==(t=e.value)&&void 0!==t?t:0},d=s.hierarchy(i,l);d.sum(u),d.sort((e,t)=>{var n,o;return(null!==(n=t.value)&&void 0!==n?n:0)-(null!==(o=e.value)&&void 0!==o?o:0)});const[h,g]=o;switch(a){case"tree":!function(e,t,n,o){const r=t.treeOrientation||"vertical",i=s.tree();i.size("horizontal"===r?[o,n]:"radial"===r?[2*Math.PI,Math.min(n,o)/2*.8]:[n,o]),i(e)}(d,n,h,g);break;case"cluster":!function(e,t,n,o){const r=t.treeOrientation||"vertical",i=s.cluster();i.size("horizontal"===r?[o,n]:"radial"===r?[2*Math.PI,Math.min(n,o)/2*.8]:[n,o]),i(e)}(d,n,h,g);break;case"treemap":!function(e,t,n,o){var r,i;const a=null!==(r=t.padding)&&void 0!==r?r:4,l=null!==(i=t.paddingTop)&&void 0!==i?i:0,c=s.treemap().size([n,o]).tile(s.treemapBinary).padding(a);l>0&&c.paddingTop(l),c(e)}(d,n,h,g);break;case"circlepack":!function(e,t,n,o){var r;const i=null!==(r=t.padding)&&void 0!==r?r:4;s.pack().size([n,o]).padding(i)(e)}(d,n,h,g);break;case"partition":!function(e,t,n,o){var r;s.partition().size([n,o]).padding(null!==(r=t.padding)&&void 0!==r?r:1)(e)}(d,n,h,g)}const f=d.descendants();e.length=0,t.length=0;const p=new Map;for(let t=0;f.length>t;t++){const o=f[t],i={id:Oa(o,n,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(r=o.value)&&void 0!==r?r:0,depth:o.depth,data:o.data,createdByFrame:!0};"tree"===a||"cluster"===a?La(i,o,n):"treemap"===a||"partition"===a?_a(i,o):"circlepack"===a&&Ta(i,o),i.__hierarchyNode=o,e.push(i),p.set(o,i)}if("tree"===a||"cluster"===a)for(const e of f)if(e.parent){const n=p.get(e.parent),o=p.get(e);n&&o&&t.push({source:n,target:o,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,n,o){const r=n.nodeStyle||(()=>({})),i=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(e,t,n,o,r,i){var a,s,l,c,u;const d=[],h=[],g=[],f=n.treeOrientation||"vertical",p="radial"===f,y=o[0]/2,m=o[1]/2,v="number"==typeof(b=n.nodeSize)?b:5;var b;for(const t of e){let e=t.x,o=t.y;p&&(e+=y,o+=m);const i=r(ga(t,"nodeStyle"));let s=i.fill||ja(n);if(n.colorByDepth&&void 0!==t.depth){const e=Ma(n);s=e[t.depth%e.length]}const l={fill:s,stroke:i.stroke||"#fff",strokeWidth:null!==(a=i.strokeWidth)&&void 0!==a?a:1,opacity:i.opacity};d.push({type:"circle",cx:e,cy:o,r:v,style:l,datum:t,id:t.id,label:t.id,depth:t.depth})}const x=null!==(s=n.edgeOpacity)&&void 0!==s?s:.5;for(const e of t){const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;if(!t||!n)continue;let o=t.x,r=t.y,a=n.x,s=n.y;p&&(o+=y,r+=m,a+=y,s+=m);const u=Ca(o,r,a,s,f),d=i(ga(e,"edgeStyle")),g={fill:"none",stroke:d.stroke||"#999",strokeWidth:null!==(l=d.strokeWidth)&&void 0!==l?l:1.5,opacity:null!==(c=d.opacity)&&void 0!==c?c:x};h.push({type:"curved",pathD:u,style:g,datum:e})}if(!1!==n.showLabels){const t=Ea(n.nodeLabel);for(const n of e){const e=t?t(n):n.id;if(!e)continue;let o,r,i,a=n.x,s=n.y;if(p&&(a+=y,s+=m),p){const e=a-y,t=s-m,n=Math.sqrt(e*e+t*t);n>0?(o=a+e/n*10,r=s+t/n*10,i=0>e?"end":"start"):(o=a,r=s-12,i="middle")}else"horizontal"===f?((null===(u=n.data)||void 0===u?void 0:u.children)&&0!==n.data.children.length?(o=a-v-6,i="end"):(o=a+v+6,i="start"),r=s):(o=a,r=s+v+14,i="middle");g.push({x:o,y:r,text:e+"",anchor:i,baseline:"middle",fontSize:11})}}return{sceneNodes:d,sceneEdges:h,labels:g}}(e,t,n,o,r,i);case"treemap":case"partition":return function(e,t,n,o){var r,i;const a=[],s=[];for(const n of e){const e=n.x1-n.x0,i=n.y1-n.y0;if(0>=e||0>=i)continue;const s=o(ga(n,"nodeStyle"));let l=s.fill||ja(t);if(t.colorByDepth&&void 0!==n.depth){const e=Ma(t);l=e[n.depth%e.length]}const c={fill:l,stroke:s.stroke||"#fff",strokeWidth:null!==(r=s.strokeWidth)&&void 0!==r?r:1,opacity:s.opacity};a.push({type:"rect",x:n.x0,y:n.y0,w:e,h:i,style:c,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=Ea(t.nodeLabel),r=t.labelMode||"leaf",a="partition"===t.chartType;for(const l of e){const e=l.x1-l.x0,c=l.y1-l.y0;if(0>=e||0>=c)continue;const u=!((null===(i=l.data)||void 0===i?void 0:i.children)&&l.data.children.length>0);if(!a){if("leaf"===r&&!u)continue;if("parent"===r&&u)continue}const d=n?n(l):l.id;if(!d)continue;if((u?30:40)>e||(u?16:14)>c)continue;let h=o(ga(l,"nodeStyle")).fill||ja(t);if(t.colorByDepth&&void 0!==l.depth){const e=Ma(t);h=e[l.depth%e.length]}const g=Sa(h);s.push(u?{x:l.x0+e/2,y:l.y0+c/2,text:d+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,c)/6)),fill:g}:{x:l.x0+4,y:l.y0+12,text:d+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:g})}}return{sceneNodes:a,sceneEdges:[],labels:s}}(e,n,0,r);case"circlepack":return function(e,t,n,o){var r,i,a,s,l;const c=[],u=[];for(const n of e){const e=null!==(r=n.__radius)&&void 0!==r?r:5;if(0>=e)continue;const s=o(ga(n,"nodeStyle"));let l=s.fill||ja(t);if(t.colorByDepth&&void 0!==n.depth){const e=Ma(t);l=e[n.depth%e.length]}const u={fill:l,stroke:s.stroke||"#fff",strokeWidth:null!==(i=s.strokeWidth)&&void 0!==i?i:1,opacity:null!==(a=s.opacity)&&void 0!==a?a:.7};c.push({type:"circle",cx:n.x,cy:n.y,r:e,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=Ea(t.nodeLabel);for(const r of e){const e=null!==(s=r.__radius)&&void 0!==s?s:5,i=n?n(r):r.id;if(!i)continue;if(15>e)continue;const a=!((null===(l=r.data)||void 0===l?void 0:l.children)&&r.data.children.length>0);let c=o(ga(r,"nodeStyle")).fill||ja(t);if(t.colorByDepth&&void 0!==r.depth){const e=Ma(t);c=e[r.depth%e.length]}if(a){const t=Sa(c);u.push({x:r.x,y:r.y,text:i+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,e/3)),fill:t})}else u.push({x:r.x,y:r.y-e+14,text:i+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:"#000",stroke:"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:c,sceneEdges:[],labels:u}}(e,n,0,r);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function La(e,t,n){const o=n.treeOrientation||"vertical";if("radial"===o){const n=t.x,o=t.y;e.x=o*Math.cos(n-Math.PI/2),e.y=o*Math.sin(n-Math.PI/2)}else"horizontal"===o?(e.x=t.y,e.y=t.x):(e.x=t.x,e.y=t.y);e.x0=e.x-5,e.x1=e.x+5,e.y0=e.y-5,e.y1=e.y+5,e.width=10,e.height=10}function _a(e,t){e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.x=(t.x0+t.x1)/2,e.y=(t.y0+t.y1)/2,e.width=t.x1-t.x0,e.height=t.y1-t.y0}function Ta(e,t){var n;const o=null!==(n=t.r)&&void 0!==n?n:0;e.x=t.x,e.y=t.y,e.x0=t.x-o,e.x1=t.x+o,e.y0=t.y-o,e.y1=t.y+o,e.width=2*o,e.height=2*o,e.__radius=o}function Ba(e){const t=e;return t.__orbitState||(t.__orbitState={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()}),t.__orbitState}const Na={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,n,o){const r=n.__hierarchyRoot;r&&function(e,t,n,o,r){var i,a;const s=function(e){if("function"==typeof e)return e;const t=e||"children";return e=>e[t]||null}(n.childrenAccessor),c=function(e){if("function"==typeof e)return e;const t=e||"name";return e=>{var n;return(null!==(n=e[t])&&void 0!==n?n:"")+""}}(n.nodeIDAccessor),u=function(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(n.orbitMode),d=null!==(i=n.orbitSize)&&void 0!==i?i:2.95,h=null!==(a=n.orbitEccentricity)&&void 0!==a?a:1,g="number"==typeof d?()=>d:d,f="number"==typeof h?()=>h:h,p=Ba(n);p.metaMap.clear(),o.length=0,r.length=0;const y=new Map;function m(e){var t;const n=null!==(t=y.get(e))&&void 0!==t?t:0;return y.set(e,n+1),0===n?e:`${e}__${n}`}const v=t[0]/2,b=t[1]/2,x=Math.min(t[0],t[1])/2*.85,k=m(c(e));o.push({id:k,x:v,y:b,x0:v,x1:v,y0:b,y1:b,width:0,height:0,value:0,depth:0,data:e}),p.metaMap.set(k,{ring:x,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,n,i,a,d,h,y){const v=s(t);if(!(null==v?void 0:v.length))return;const b=v.length;let x=0,k=0,w=0;for(;b>k;)k+=u[Math.min(w,u.length-1)],w++,x++;let A=0;for(let b=0;x>b;b++){const k=u[Math.min(b,u.length-1)],w=v.slice(A,A+k);if(!w.length)break;const S=(b+1)/x,O={id:n,depth:h,data:t,parentId:n},E=y?d/g(O)*S:d*S,M=l.pie().value(e=>{var t;return(null===(t=s(e))||void 0===t?void 0:t.length)?4:1}).sort(null),j=M(w),C=f(O);for(let t=0;w.length>t;t++){const s=(j[t].startAngle+j[t].endAngle)/2,l=w[t],u=m(c(l)),d=i+E*Math.sin(s),g=a+E*Math.cos(s)*C;o.push({id:u,x:d,y:g,x0:d,x1:d,y0:g,y1:g,width:0,height:0,value:0,depth:h,data:l}),p.metaMap.set(u,{ring:E,angle:s,depth:h,parentId:n,eccentricity:C}),r.push({source:n,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:u}}),e(l,u,d,g,E,h+1,!0)}A+=k}}(e,k,v,b,x,1,!1)}(r,o,n,e,t)},buildScene(e,t,n,o){var r,i,a,s,l;const c=n.nodeStyle,u=n.nodeSize,d="number"==typeof u?()=>u:"function"==typeof u?u:()=>6,h=[],g=[],f=[];if(!1!==n.orbitShowRings){const t=Ba(n),o=new Map;for(const t of e)o.set(t.id,t);const r=new Map;for(const[,e]of t.metaMap){if(!e.parentId)continue;const t=o.get(e.parentId);if(!t)continue;const n=`${e.parentId}:${e.ring}`;r.has(n)||r.set(n,{parentX:t.x,parentY:t.y,ring:e.ring,ecc:e.eccentricity})}const i=48,a={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:e,parentY:t,ring:n,ecc:o}]of r)for(let r=0;i>r;r++){const s=r/i*Math.PI*2,l=(r+1)/i*Math.PI*2;g.push({type:"line",x1:e+n*Math.sin(s),y1:t+n*Math.cos(s)*o,x2:e+n*Math.sin(l),y2:t+n*Math.cos(l)*o,style:a,datum:null})}}for(const t of e){if(null==t.x||null==t.y)continue;const e=d(ga(t,"nodeSize")),n=c?c(ga(t,"nodeStyle")):{},o={fill:n.fill||"#6366f1",stroke:n.stroke||"#fff",strokeWidth:null!==(r=n.strokeWidth)&&void 0!==r?r:1,opacity:null!==(i=n.opacity)&&void 0!==i?i:0===(null!==(a=t.depth)&&void 0!==a?a:0)?1:.85};h.push({type:"circle",cx:t.x,cy:t.y,r:e,style:o,datum:t,id:t.id,label:t.id,depth:t.depth})}const p=new Map;for(const t of e)p.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:p.get(e.source),n="object"==typeof e.target?e.target:p.get(e.target);t&&n&&(null!=t.x&&null!=n.x&&g.push({type:"line",x1:t.x,y1:t.y,x2:n.x,y2:n.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:e}))}if(n.showLabels){const t=n.nodeLabel;for(const n of e){const e=d(ga(n,"nodeSize"));if(4>=e)continue;const o="function"==typeof t?t(n):t&&null!==(l=null===(s=n.data)||void 0===s?void 0:s[t])&&void 0!==l?l:n.id;f.push({x:n.x,y:n.y+e+12,text:o+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:h,sceneEdges:g,labels:f}},tick:(e,t,n,o,r)=>!1!==n.orbitAnimated&&(function(e,t){var n,o;const r=Ba(t),i=null!==(n=t.orbitSpeed)&&void 0!==n?n:.25,a=null!==(o=t.orbitRevolution)&&void 0!==o?o:function(e){switch(e){case"decay":return e=>{var t;return Math.pow(.6,null!==(t=e.depth)&&void 0!==t?t:0)};case"alternate":return e=>{var t;const n=null!==(t=e.depth)&&void 0!==t?t:0;return(n%2==0?1:-1)/(n+1)};default:return e=>{var t;return 1/((null!==(t=e.depth)&&void 0!==t?t:0)+1)}}}(t.orbitRevolutionStyle),s=(("undefined"!=typeof performance?performance.now():Date.now())-r.startTime)/1e3,l=i*(Math.PI/6),c=new Map;for(const t of e)c.set(t.id,t);for(const t of e){const e=r.metaMap.get(t.id);if(!e||!e.parentId)continue;const n=c.get(e.parentId);if(!n)continue;const o=e.angle+s*l*a({id:t.id,depth:e.depth,data:t.data,parentId:e.parentId});t.x=n.x+e.ring*Math.sin(o),t.y=n.y+e.ring*Math.cos(o)*e.eccentricity,t.x0=t.x,t.x1=t.x,t.y0=t.y,t.y1=t.y}}(e,n),!0)},Da={sankey:pa,force:ya,chord:ka,tree:Pa,cluster:Pa,treemap:Pa,circlepack:Pa,partition:Pa,orbit:Na};function Ia(e){return Da[e]}class Ra{constructor(e){this.nodes=new Map,this.edges=new Map,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.particlePool=null,this.transition=null,this.lastIngestTime=0,this.nodeTimestamps=new Map,this.edgeTimestamps=new Map,this._decaySortedNodes=null,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this._lastPositionSnapshot=null,this.config=e,this.tensionConfig=Object.assign(Object.assign({},bi),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&(this.particlePool=new ki(2e3))}updateConfig(e){const t=this.config;t.__orbitState&&(e.__orbitState=t.__orbitState),t.__hierarchyRoot&&(e.__hierarchyRoot=t.__hierarchyRoot),this.config=e,this.tensionConfig=Object.assign(Object.assign({},bi),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&!this.particlePool&&(this.particlePool=new ki(2e3))}ingestHierarchy(e,t){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this.config.__hierarchyRoot=e,this.runLayout(t)}ingestBounded(e,t,n){const{nodeIDAccessor:o="id",sourceAccessor:r="source",targetAccessor:i="target",valueAccessor:a="value"}=this.config,s="function"==typeof o?o:e=>e[o],l="function"==typeof r?r:e=>e[r],c="function"==typeof i?i:e=>e[i],u="function"==typeof a?a:e=>{var t;return null!==(t=e[a])&&void 0!==t?t:1};this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const t of e){const e=s(t)+"";this.nodes.set(e,Object.assign(Object.assign({},Ha(e)),{data:t}))}for(let e=0;t.length>e;e++){const n=t[e],o=l(n)+"",r=c(n)+"",i=Number(u(n))||1;this.nodes.has(o)||this.nodes.set(o,Object.assign(Object.assign({},Ha(o)),{data:n})),this.nodes.has(r)||this.nodes.set(r,Object.assign(Object.assign({},Ha(r)),{data:n}));const a=`${o}\0${r}\0${e}`;this.edges.set(a,{source:o,target:r,value:i,y0:0,y1:0,sankeyWidth:0,data:n,_edgeKey:a})}this.runLayout(n)}edgeKey(e,t){return`${e}\0${t}`}ingestEdge(e){const{source:t,target:n,value:o}=e,r=0===this.nodes.size;let i=!1;const a="undefined"!=typeof performance?performance.now():Date.now();this.lastIngestTime=a,this._decaySortedNodes=null,this.nodes.has(t)||(this.nodes.set(t,Ha(t)),this.nodeTimestamps.set(t,a),this.tension+=this.tensionConfig.newNode,i=!0),this.nodes.has(n)||(this.nodes.set(n,Ha(n)),this.nodeTimestamps.set(n,a),this.tension+=this.tensionConfig.newNode,i=!0);const s=this.edgeKey(t,n),l=this.edges.get(s);let c=!1;return l?(l.value+=o,this.edgeTimestamps.set(s,a),this.tension+=this.tensionConfig.weightChange,c=!0):(this.edges.set(s,{source:t,target:n,value:o,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(s,a),this.tension+=this.tensionConfig.newEdge,i=!0),r||i||c||this.tension>=this.tensionConfig.threshold}runLayout(e){var t,n,o,r,i,a;const s=Ia(this.config.chartType);if(!s)return;let l=Array.from(this.nodes.values()),c=Array.from(this.edges.values());if(0===l.length&&!s.hierarchical)return;if(this.prepareForRelayout(),s.supportsStreaming&&!s.hierarchical){const e=new Map;for(const s of l)if(void 0!==s._prevX0){const l=(null!==(t=s._prevX1)&&void 0!==t?t:0)-(null!==(n=s._prevX0)&&void 0!==n?n:0),c=(null!==(o=s._prevY1)&&void 0!==o?o:0)-(null!==(r=s._prevY0)&&void 0!==r?r:0);e.set(s.id,{x:(null!==(i=s._prevX0)&&void 0!==i?i:0)+l/2,y:(null!==(a=s._prevY0)&&void 0!==a?a:0)+c/2})}else 0===s.x&&0===s.y||e.set(s.id,{x:s.x,y:s.y});if(this._lastPositionSnapshot)for(const[t,n]of this._lastPositionSnapshot)e.has(t)||e.set(t,n);this.config.__previousPositions=e.size>0?e:void 0}if(s.computeLayout(l,c,this.config,e),this.config.__previousPositions=void 0,s.hierarchical&&l.length>0){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const e of l)this.nodes.set(e.id,e);for(let e=0;c.length>e;e++){const t=c[e],n=t._edgeKey||`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}\0${e}`;t._edgeKey=n,this.edges.set(n,t)}}this.finalizeLayout();const u=new Map;for(const e of this.nodes.values())0===e.x&&0===e.y||u.set(e.id,{x:e.x,y:e.y});this._lastPositionSnapshot=u,this.saveTargetPositions(),l.some(e=>void 0!==e._prevX0&&(0!==e._prevX0||0!==e._prevX1||0!==e._prevY0||0!==e._prevY1))&&this.tensionConfig.transitionDuration>0&&(this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:this.tensionConfig.transitionDuration});const d=new Set(this.nodes.keys()),h=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const e of d)this.previousNodeIds.has(e)||this.addedNodes.add(e);for(const e of this.previousNodeIds)d.has(e)||this.removedNodes.add(e);for(const e of h)this.previousEdgeKeys.has(e)||this.addedEdges.add(e);for(const e of this.previousEdgeKeys)h.has(e)||this.removedEdges.add(e);(this.addedNodes.size>0||this.removedNodes.size>0||this.addedEdges.size>0||this.removedEdges.size>0)&&(this.lastTopologyChangeTime="undefined"!=typeof performance?performance.now():Date.now()),this.previousNodeIds=d,this.previousEdgeKeys=h,this.layoutVersion++}buildScene(e){const t=Ia(this.config.chartType);if(!t)return;const n=Array.from(this.nodes.values()),o=Array.from(this.edges.values()),{sceneNodes:r,sceneEdges:i,labels:a}=t.buildScene(n,o,this.config,e);this.sceneNodes=r,this.sceneEdges=i,this.labels=a}get isAnimating(){const e=Ia(this.config.chartType);return!!(null==e?void 0:e.supportsAnimation)&&!1!==this.config.orbitAnimated}tickAnimation(e,t){const n=Ia(this.config.chartType);if(!(null==n?void 0:n.tick))return!1;const o=Array.from(this.nodes.values()),r=Array.from(this.edges.values());return n.tick(o,r,this.config,e,t)}advanceTransition(e){if(!this.transition)return!1;const t=H(e,this.transition),n=R(t);for(const e of this.nodes.values())void 0===e._targetX0||void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=W(e._prevX0,e._targetX0,n),e.x1=W(e._prevX1,e._targetX1,n),e.y0=W(e._prevY0,e._targetY0,n),e.y1=W(e._prevY1,e._targetY1,n));for(const e of this.edges.values())void 0!==e._targetY0&&void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=W(e._prevY0,e._targetY0,n),e.y1=W(e._prevY1,e._targetY1,n),e.sankeyWidth=W(e._prevSankeyWidth,e._targetSankeyWidth,n));return this.rebuildAllBeziers(),1>t||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){for(const e of this.nodes.values())e._prevX0=e.x0,e._prevX1=e.x1,e._prevY0=e.y0,e._prevY1=e.y1;for(const e of this.edges.values())e._prevY0=e.y0,e._prevY1=e.y1,e._prevSankeyWidth=e.sankeyWidth}finalizeLayout(){const e="vertical"===this.config.orientation?"down":"right";for(const e of this.nodes.values())if(0!==e.x0||0!==e.x1||0!==e.y0||0!==e.y1)e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;else{const t=5;e.x0=e.x-t,e.x1=e.x+t,e.y0=e.y-t,e.y1=e.y+t,e.width=2*t,e.height=2*t}for(const t of this.edges.values())t.direction=e,this.updateEdgeBezier(t);this.tension=0}saveTargetPositions(){for(const e of this.nodes.values())e._targetX0=e.x0,e._targetX1=e.x1,e._targetY0=e.y0,e._targetY1=e.y1;for(const e of this.edges.values())e._targetY0=e.y0,e._targetY1=e.y1,e._targetSankeyWidth=e.sankeyWidth}restorePreviousPositions(){for(const e of this.nodes.values())void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=e._prevX0,e.x1=e._prevX1,e.y0=e._prevY0,e.y1=e._prevY1);for(const e of this.edges.values())void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=e._prevY0,e.y1=e._prevY1,e.sankeyWidth=e._prevSankeyWidth);this.rebuildAllBeziers()}snapToTargets(){for(const e of this.nodes.values())void 0!==e._targetX0&&(e.x0=e._targetX0,e.x1=e._targetX1,e.y0=e._targetY0,e.y1=e._targetY1);for(const e of this.edges.values())void 0!==e._targetY0&&(e.y0=e._targetY0,e.y1=e._targetY1,e.sankeyWidth=e._targetSankeyWidth);this.rebuildAllBeziers()}updateEdgeBezier(e){const t="string"==typeof e.source?this.nodes.get(e.source):e.source,n="string"==typeof e.target?this.nodes.get(e.target):e.target;t&&n&&(e.bezier=e.circular&&e.circularPathData?this.buildCircularBezier(e):this.buildStandardBezier(e,t,n))}buildStandardBezier(e,t,n){const o=(e.sankeyWidth||1)/2;if("down"===e.direction){const r=t.x1,i=n.x0,a=u.interpolateNumber(r,i);return{circular:!1,points:[{x:e.y0,y:r},{x:e.y0,y:a(.5)},{x:e.y1,y:a(.5)},{x:e.y1,y:i}],halfWidth:o}}const r=t.x1,i=n.x0,a=u.interpolateNumber(r,i);return{circular:!1,points:[{x:r,y:e.y0},{x:a(.5),y:e.y0},{x:a(.5),y:e.y1},{x:i,y:e.y1}],halfWidth:o}}buildCircularBezier(e){const t=(e._circularWidth||e.sankeyWidth||1)/2,n=e.circularPathData;if(e._circularStub){const e=Math.max(15,Math.min(40,.33*(n.rightFullExtent-n.sourceX))),o=Math.max(15,Math.min(40,.33*(n.targetX-n.leftFullExtent)));return{circular:!0,segments:[[{x:n.sourceX,y:n.sourceY},{x:n.sourceX+.33*e,y:n.sourceY},{x:n.sourceX+.66*e,y:n.sourceY},{x:n.sourceX+e,y:n.sourceY}],[{x:n.targetX-o,y:n.targetY},{x:n.targetX-.66*o,y:n.targetY},{x:n.targetX-.33*o,y:n.targetY},{x:n.targetX,y:n.targetY}]],halfWidth:t}}let o;o="down"===e.direction?[{x:n.sourceY,y:n.sourceX},{x:n.sourceY,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.leftFullExtent},{x:n.targetY,y:n.leftFullExtent},{x:n.targetY,y:n.targetX}]:[{x:n.sourceX,y:n.sourceY},{x:n.rightFullExtent,y:n.sourceY},{x:n.rightFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.targetY},{x:n.targetX,y:n.targetY}];const r=[];for(let e=0;o.length-1>e;e++){const t=o[e],n=o[e+1],i=n.x-t.x,a=n.y-t.y;r.push([t,{x:t.x+i/3,y:t.y+a/3},{x:t.x+2*i/3,y:t.y+2*a/3},n])}return{circular:!0,segments:r,halfWidth:t}}rebuildAllBeziers(){for(const e of this.nodes.values())e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;for(const e of this.edges.values())this.updateEdgeBezier(e)}applyPulse(e){var t,n,o,r,i;const a=this.config.pulse;if(!a)return;const s=null!==(t=a.duration)&&void 0!==t?t:500,l=null!==(n=a.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",c=null!==(o=a.glowRadius)&&void 0!==o?o:4;for(const t of this.sceneNodes){const n=t.id;if(!n)continue;const o=this.nodeTimestamps.get(n);if(!o)continue;const r=e-o;s>r&&(t._pulseIntensity=1-r/s,t._pulseColor=l,t._pulseGlowRadius=c)}for(const t of this.sceneEdges){const n=t.datum;if(!n)continue;const o="object"==typeof n.source?null===(r=n.source)||void 0===r?void 0:r.id:n.source,a="object"==typeof n.target?null===(i=n.target)||void 0===i?void 0:i.id:n.target;if(!o||!a)continue;const c=this.edgeTimestamps.get(`${o}\0${a}`);if(!c)continue;const u=e-c;s>u&&(t._pulseIntensity=1-u/s,t._pulseColor=l)}}applyDecay(){var e,t;const n=this.config.decay;if(!n)return;const o=this.nodeTimestamps.size;if(1>=o)return;this._decaySortedNodes||(this._decaySortedNodes=Array.from(this.nodeTimestamps.entries()).sort((e,t)=>e[1]-t[1]));const r=this._decaySortedNodes,i=new Map;for(let e=0;r.length>e;e++)i.set(r[e][0],e);for(const r of this.sceneNodes){const a=r.id;if(!a)continue;const s=i.get(a);if(void 0===s)continue;const l=D(n,s,o),c=null!==(t=null===(e=r.style)||void 0===e?void 0:e.opacity)&&void 0!==t?t:1;r.style=Object.assign(Object.assign({},r.style),{opacity:c*l})}}applyTopologyDiff(e){var t;if(0===this.addedNodes.size)return;const n=e-this.lastTopologyChangeTime;if(n>=2e3)return;const o=1-n/2e3;for(const e of this.sceneNodes){const n=e.id;n&&this.addedNodes.has(n)&&(e._pulseIntensity=Math.max(null!==(t=e._pulseIntensity)&&void 0!==t?t:0,o),e._pulseColor="rgba(34, 197, 94, 0.7)",e._pulseGlowRadius=8)}}get hasActiveTopologyDiff(){return 0!==this.addedNodes.size&&2e3>("undefined"!=typeof performance?performance.now():Date.now())-this.lastTopologyChangeTime}applyThresholds(e){var t,n;const o=this.config.thresholds;if(!o)return;const r=null!==(t=o.warningColor)&&void 0!==t?t:"#f59e0b",i=null!==(n=o.criticalColor)&&void 0!==n?n:"#ef4444",a=!1!==o.pulse;for(const t of this.sceneNodes){const n=t.id;if(!n)continue;const s=this.nodes.get(n);if(!s)continue;const l=o.metric(s);let c=null;void 0===o.critical||o.critical>l?void 0===o.warning||o.warning>l||(c=r):c=i,c&&(t.style=Object.assign(Object.assign({},t.style),{fill:c}),a&&(t._pulseIntensity=.6+.4*Math.sin(e/300),t._pulseColor=c,t._pulseGlowRadius=6))}}get hasActiveThresholds(){const e=this.config.thresholds;if(!e)return!1;for(const t of this.nodes.values()){const n=e.metric(t);if(void 0!==e.warning&&n>=e.warning||void 0!==e.critical&&n>=e.critical)return!0}return!1}get hasActivePulses(){var e;const t=this.config.pulse;if(!t||0===this.lastIngestTime)return!1;const n="undefined"!=typeof performance?performance.now():Date.now();return(null!==(e=t.duration)&&void 0!==e?e:500)>n-this.lastIngestTime}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}updateNode(e,t){var n;const o=this.nodes.get(e);if(!o)return null;const r=o.data?Object.assign({},o.data):{};return o.data=t(null!==(n=o.data)&&void 0!==n?n:{}),this.layoutVersion++,r}updateEdge(e,t,n){var o;const r=this.config.valueAccessor,i="function"==typeof r?r:r?e=>e[r]:e=>e.value,a=[];for(const[,r]of this.edges)if(("string"==typeof r.source?r.source:r.source.id)===e&&("string"==typeof r.target?r.target:r.target.id)===t){a.push(r.data?Object.assign({},r.data):{}),r.data=n(null!==(o=r.data)&&void 0!==o?o:{});const e=i(r.data);null!=e&&(r.value=Number(e))}return a.length>0&&this.layoutVersion++,a}removeNode(e){if(!this.nodes.has(e))return!1;this.nodes.delete(e),this.nodeTimestamps.delete(e);for(const[t,n]of this.edges)("string"==typeof n.source?n.source:n.source.id)!==e&&("string"==typeof n.target?n.target:n.target.id)!==e||(this.edges.delete(t),this.edgeTimestamps.delete(t));return this.layoutVersion++,!0}removeEdge(e,t){const n=[];if(void 0===t){const t=this.config.edgeIdAccessor;if(!t)throw Error("removeEdge(edgeId) requires edgeIdAccessor to be configured. Use removeEdge(sourceId, targetId) instead.");const o="function"==typeof t?t:e=>null==e?void 0:e[t];for(const[t,r]of this.edges)o(r.data)===e&&n.push(t)}else for(const[o,r]of this.edges)("string"==typeof r.source?r.source:r.source.id)===e&&("string"==typeof r.target?r.target:r.target.id)===t&&n.push(o);for(const e of n)this.edges.delete(e),this.edgeTimestamps.delete(e);return n.length>0&&this.layoutVersion++,n.length>0}clear(){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.transition=null,this.lastIngestTime=0,this._lastPositionSnapshot=null,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.particlePool&&this.particlePool.clear()}}function Ha(e){return{id:e,x0:0,x1:0,y0:0,y1:0,x:0,y:0,width:0,height:0,value:0,createdByFrame:!0}}function Wa(e,t,n,o,r=30){let i=null,a=r,s=1/0;for(const t of e){const e=Fa(t,n,o,r);if(e)if("rect"===t.type){const n=t.w*t.h;s>n&&(i=e,s=n)}else a>e.distance&&(i=e,a=e.distance)}if(i)return i;for(const e of t){const t=qa(e,n,o);t&&a>t.distance&&(i=t,a=t.distance)}return i}function Fa(e,t,n,o=30){switch(e.type){case"circle":return function(e,t,n,o=30){const r=t-e.cx,i=n-e.cy,a=Math.sqrt(r*r+i*i);return a>ee(e.r,o)?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:a}}(e,t,n,o);case"rect":return function(e,t,n){const o=J(t,n,e);return o.hit?{type:"node",datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}(e,t,n);case"arc":return function(e,t,n){const o=t-e.cx,r=n-e.cy,i=Math.sqrt(o*o+r*r);if(e.innerR-2>i||i>e.outerR+2)return null;const a=oe(Math.atan2(r,o)),s=oe(e.startAngle),l=oe(e.endAngle);if(s>l?a>=s||l>=a:a>=s&&l>=a){const t=(e.startAngle+e.endAngle)/2,n=(e.innerR+e.outerR)/2;return{type:"node",datum:e.datum,x:e.cx+n*Math.cos(t),y:e.cy+n*Math.sin(t),distance:0}}return null}(e,t,n);default:return null}}let $a=null,za=null;function Ga(){return za||($a=document.createElement("canvas"),$a.width=1,$a.height=1,za=$a.getContext("2d")),za}function qa(e,t,n){switch(e.type){case"bezier":return function(e,t,n){var o,r;if(!e.pathD)return null;try{const i=new Path2D(e.pathD),a=Ga();if(!a)return null;if(a.isPointInPath(i,t,n)){const i="object"==typeof(null===(o=e.datum)||void 0===o?void 0:o.source)?e.datum.source:null,a="object"==typeof(null===(r=e.datum)||void 0===r?void 0:r.target)?e.datum.target:null;return{type:"edge",datum:e.datum,x:i&&a?(i.x1+a.x0)/2:t,y:e.datum?(e.datum.y0+e.datum.y1)/2:n,distance:0}}const s=a.lineWidth;a.lineWidth=10;const l=a.isPointInStroke(i,t,n);if(a.lineWidth=s,l)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}catch(e){}return null}(e,t,n);case"line":return function(e,t,n){const o=e.x2-e.x1,r=e.y2-e.y1,i=o*o+r*r;if(0===i)return null;let a=((t-e.x1)*o+(n-e.y1)*r)/i;a=Math.max(0,Math.min(1,a));const s=e.x1+a*o,l=e.y1+a*r,c=Math.sqrt(Math.pow(t-s,2)+Math.pow(n-l,2));return c>5?null:{type:"edge",datum:e.datum,x:s,y:l,distance:c}}(e,t,n);case"ribbon":case"curved":return function(e,t,n){if(!e.pathD)return null;try{const o=new Path2D(e.pathD),r=Ga();if(!r)return null;if(r.isPointInPath(o,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0};const i=r.lineWidth;r.lineWidth=10;const a=r.isPointInStroke(o,t,n);if(r.lineWidth=i,a)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}catch(e){}return null}(e,t,n);default:return null}}function Ya(e){const{width:t,height:n,totalWidth:o,totalHeight:r,margin:i,labels:a,title:s,legend:l,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:d,legendIsolatedCategories:h,legendPosition:g="right",foregroundGraphics:f,sceneNodes:y,annotations:m,svgAnnotationRules:v}=e;return p.createElement(p.Fragment,null,p.createElement("svg",{role:"img",width:o,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},p.createElement("title",null,"string"==typeof s?s:"Network Chart"),p.createElement("desc",null,"string"==typeof s?s+" — network data visualization":"Network data visualization"),p.createElement("g",{transform:`translate(${i.left},${i.top})`},a.map((e,t)=>p.createElement("text",{key:"label-"+t,x:e.x,y:e.y,textAnchor:e.anchor||"start",dominantBaseline:e.baseline||"middle",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"currentColor",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,style:{pointerEvents:"none"}},e.text)),m&&m.filter(e=>"widget"!==e.type).map((e,o)=>{if(v){const r=v(e,o,{width:t,height:n,sceneNodes:y});if(r)return p.createElement(p.Fragment,{key:"annotation-"+o},r)}return null}),f),s&&"string"==typeof s?p.createElement("text",{x:o/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor"},s):s?p.createElement("foreignObject",{x:0,y:0,width:o,height:i.top},s):null,Me({legend:l,totalWidth:o,totalHeight:r,margin:i,legendPosition:g,title:s,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:d,legendIsolatedCategories:h})),null==m?void 0:m.filter(e=>"widget"===e.type&&e.nodeId&&y).map((e,t)=>{var n,o,r,a,s,l,c,u,d;const h=y.find(t=>{var n,o,r,i,a;return t.id===e.nodeId||(null===(n=t.datum)||void 0===n?void 0:n.id)===e.nodeId||(null===(r=null===(o=t.datum)||void 0===o?void 0:o.data)||void 0===r?void 0:r.id)===e.nodeId||(null===(a=null===(i=t.datum)||void 0===i?void 0:i.data)||void 0===a?void 0:a.name)===e.nodeId});if(!h)return null;const g=i.left+(null!==(n=h.cx)&&void 0!==n?n:null!=h.x&&null!=h.w?h.x+h.w/2:null!==(o=h.x)&&void 0!==o?o:0),f=i.top+(null!==(r=h.cy)&&void 0!==r?r:null!=h.y&&null!=h.h?h.y+h.h/2:null!==(a=h.y)&&void 0!==a?a:0),m=null!==(s=e.dx)&&void 0!==s?s:0,v=null!==(l=e.dy)&&void 0!==l?l:-16,b=null!==(c=e.width)&&void 0!==c?c:32,x=null!==(u=e.height)&&void 0!==u?u:32,k=null!==(d=e.content)&&void 0!==d?d:p.createElement("span",{style:{fontSize:18,cursor:"default"}},"ℹ️");return p.createElement("div",{key:"widget-"+t,style:{position:"absolute",left:g+m-b/2,top:f+v-x/2,width:b,height:x,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:5}},k)}))}function Xa(e,t){var n,o,r,i,a,s;if(!t.pathD)return;e.save();const l=new Path2D(t.pathD);if(t.style.fill&&"none"!==t.style.fill){const a=t._gradient;if(a){const r=e.createLinearGradient(a.x0,0,a.x1,0),i=null!==(o=null!==(n=t.style.fillOpacity)&&void 0!==n?n:t.style.opacity)&&void 0!==o?o:.5,s="string"==typeof t.style.fill?t.style.fill:"#999";r.addColorStop(0,1===a.from?s:"transparent"),r.addColorStop(1,1===a.to?s:"transparent"),e.fillStyle=r,e.globalAlpha=i}else e.fillStyle=t.style.fill,e.globalAlpha=null!==(i=null!==(r=t.style.fillOpacity)&&void 0!==r?r:t.style.opacity)&&void 0!==i?i:.5;e.fill(l)}t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(a=t.style.strokeWidth)&&void 0!==a?a:.5,e.globalAlpha=.5*(null!==(s=t.style.opacity)&&void 0!==s?s:1),e.stroke(l)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.2*t._pulseIntensity,e.fill(l)),e.restore()}function Va(e,t){var n,o;e.save(),e.strokeStyle=t.style.stroke||"#999",e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.strokeDasharray&&e.setLineDash(t.style.strokeDasharray.split(/[\s,]+/).map(Number)),e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke(),t._pulseIntensity&&t._pulseIntensity>0&&(e.setLineDash([]),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=(null!==(o=t.style.strokeWidth)&&void 0!==o?o:1)+3*t._pulseIntensity,e.globalAlpha=.4*t._pulseIntensity,e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke()),e.restore()}function Ua(e,t){var n,o,r,i;if(!t.pathD)return;e.save();const a=new Path2D(t.pathD);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=t.style.fill,e.globalAlpha=null!==(o=null!==(n=t.style.fillOpacity)&&void 0!==n?n:t.style.opacity)&&void 0!==o?o:.5,e.fill(a)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(r=t.style.strokeWidth)&&void 0!==r?r:.5,e.globalAlpha=.3*(null!==(i=t.style.opacity)&&void 0!==i?i:1),e.stroke(a)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.25*t._pulseIntensity,e.fill(a)),e.restore()}function Ka(e,t){var n,o;if(!t.pathD)return;e.save();const r=new Path2D(t.pathD);e.strokeStyle=t.style.stroke||"#999",e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.stroke(r),t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=t.style.fill,e.globalAlpha=null!==(o=t.style.fillOpacity)&&void 0!==o?o:.1,e.fill(r)),e.restore()}Ya.displayName="NetworkSVGOverlay";const Qa={top:20,right:80,bottom:20,left:80},Za={top:40,right:40,bottom:40,left:40},Ja=new Set(["chord","force","circlepack","orbit"]),es=[800,600],ts={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,lineHeight:1.5,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function ns({data:e}){var t,n,o,r,i,a;if("edge"===e.nodeOrEdge){const t=e.data;return p.createElement("div",{className:"semiotic-tooltip",style:ts},p.createElement("div",{style:{fontWeight:600}},"object"==typeof t.source?t.source.id:t.source," → ","object"==typeof t.target?t.target.id:t.target),null!=t.value&&p.createElement("div",{style:{marginTop:4,opacity:.8}},"Value:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""))}const s=e.data,l=null==s?void 0:s.__hierarchyNode;if(l){const e=[];let i=l;for(;i;){const a=null!==(r=null!==(n=null===(t=i.data)||void 0===t?void 0:t.name)&&void 0!==n?n:null===(o=i.data)||void 0===o?void 0:o.id)&&void 0!==r?r:s.id;null!=a&&e.unshift(a+""),i=i.parent}e.length>1&&e.shift();const a=e.length-1;return p.createElement("div",{className:"semiotic-tooltip",style:ts},p.createElement("div",null,e.map((e,t)=>p.createElement("span",{key:t},t>0&&p.createElement("span",{style:{margin:"0 3px",opacity:.5}}," → "),t===a?p.createElement("strong",null,e):p.createElement("span",{style:{opacity:.7}},e)))),null!=s.value&&s.value>0&&p.createElement("div",{style:{marginTop:4,opacity:.8}},"number"==typeof s.value?s.value.toLocaleString():s.value+""))}const c=((null===(i=s.sourceLinks)||void 0===i?void 0:i.length)||0)+((null===(a=s.targetLinks)||void 0===a?void 0:a.length)||0),u=(s.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(s.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0);return p.createElement("div",{className:"semiotic-tooltip",style:ts},p.createElement("div",{style:{fontWeight:600}},s.id),null!=s.value&&s.value>0&&p.createElement("div",{style:{marginTop:4,opacity:.8}},"Total:"," ","number"==typeof s.value?s.value.toLocaleString():s.value+""),c>0&&p.createElement("div",{style:{marginTop:4,opacity:.8}},"Connections: ",c,u!==c&&` (weighted: ${u.toLocaleString()})`))}const os=e.forwardRef(function(t,n){var o,r,i,a,s,c,u,d,h,g,f,y,m,v;const{chartType:b,nodes:x,edges:k,data:w,initialEdges:A,nodeIDAccessor:S="id",sourceAccessor:O="source",targetAccessor:E="target",valueAccessor:M="value",edgeIdAccessor:j,childrenAccessor:P,hierarchySum:L,orientation:_="horizontal",nodeAlign:T="justify",nodePaddingRatio:B=.05,nodeWidth:N=15,iterations:D=300,forceStrength:I=.1,padAngle:R=.01,groupWidth:H=20,sortGroups:W,edgeSort:F,treeOrientation:$="vertical",edgeType:z="curve",padding:G,paddingTop:q,tensionConfig:Y,showParticles:X=!1,particleStyle:V,nodeStyle:U,edgeStyle:K,colorBy:Q,colorScheme:Z="category10",edgeColorBy:J="source",edgeOpacity:ee=.5,colorByDepth:te=!1,nodeSize:ne=8,nodeSizeRange:oe=[5,20],nodeLabel:re,showLabels:ie=!0,labelMode:ae,size:se=es,responsiveWidth:le,responsiveHeight:ce,margin:ue,className:de,background:he,enableHover:ge=!0,tooltipContent:me,customHoverBehavior:ve,customClickBehavior:ke,onObservation:we,chartId:Ae,onTopologyChange:Se,annotations:Oe,svgAnnotationRules:Ee,legend:Me,legendPosition:je,legendHoverBehavior:Ce,legendClickBehavior:Pe,legendHighlightedCategory:Le,legendIsolatedCategories:_e,title:Te,foregroundGraphics:Be,backgroundGraphics:Ne,decay:De,pulse:Ie,staleness:Re,thresholds:He,accessibleTable:We=!0,description:Fe,summary:$e,orbitMode:ze,orbitSize:Ge,orbitSpeed:qe,orbitRevolution:Ye,orbitRevolutionStyle:Xe,orbitEccentricity:Ve,orbitShowRings:Ue,orbitAnimated:Ke}=t,Qe=Mt(),Ze=e.useRef(Qe);Ze.current=Qe;const Je="semiotic-table-"+p.useId(),et=Ja.has(b)?Za:Qa,[tt,rt]=be(se,le,ce),it=Object.assign(Object.assign({},et),ue),at=rt[0]-it.left-it.right,st=rt[1]-it.top-it.bottom,lt="function"==typeof Be?Be({size:rt,margin:it}):Be,ut=e.useMemo(()=>Object.assign(Object.assign({},bi),Y),[Y]),dt=e.useMemo(()=>Object.assign(Object.assign({},xi),V),[V]),ht=e.useMemo(()=>({chartType:b,nodeIDAccessor:S,sourceAccessor:O,targetAccessor:E,valueAccessor:M,edgeIdAccessor:j,childrenAccessor:P,hierarchySum:L,orientation:_,nodeAlign:T,nodePaddingRatio:B,nodeWidth:N,iterations:D,forceStrength:I,padAngle:R,groupWidth:H,sortGroups:W,edgeSort:F,treeOrientation:$,edgeType:z,padding:G,paddingTop:q,tensionConfig:ut,showParticles:X,particleStyle:dt,nodeStyle:U,edgeStyle:K,nodeLabel:re,showLabels:ie,labelMode:ae,colorBy:Q,colorScheme:Z,edgeColorBy:J,edgeOpacity:ee,colorByDepth:te,nodeSize:ne,nodeSizeRange:oe,decay:De,pulse:Ie,staleness:Re,thresholds:He,orbitMode:ze,orbitSize:Ge,orbitSpeed:qe,orbitRevolution:Ye,orbitRevolutionStyle:Xe,orbitEccentricity:Ve,orbitShowRings:Ue,orbitAnimated:Ke}),[b,S,O,E,M,P,L,_,T,B,N,D,I,R,H,W,F,$,z,G,q,ut,X,dt,U,K,re,ie,ae,Q,Z,J,ee,te,ne,oe,De,Ie,Re,He,ze,Ge,qe,Ye,Xe,Ve,Ue,Ke]),gt=e.useRef(null),ft=e.useRef(0),pt=e.useRef(0),yt=e.useRef(!0),mt=Bt(e=>e.theme),vt=e.useRef(()=>{}),At=e.useRef(null);At.current||(At.current=new Ra(ht));const[Et,jt]=e.useState(null),[Ct,Pt]=e.useState(0),[Lt,_t]=e.useState(0),[Tt,It]=e.useState(!1),Rt=e.useRef(null),Ht=e.useRef(new Map),Wt=e.useRef(0),Ft=e.useCallback(e=>{if("function"==typeof Q)return Q(e)+"";if("string"==typeof Q&&e.data){const t=e.data[Q];if(void 0!==t){if(!Ht.current.has(t+"")){const e=Array.isArray(Z)?Z:C;Ht.current.set(t+"",e[Wt.current++%e.length])}return Ht.current.get(t+"")}}if(Ht.current.has(e.id))return Ht.current.get(e.id);const t=Array.isArray(Z)?Z:C,n=Q?t[Wt.current++%t.length]:t[0];return Ht.current.set(e.id,n),n},[Q,Z]),$t=e.useCallback(e=>{if("function"==typeof J)return J(e);const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;return"target"===J&&n?Ft(n):t?Ft(t):"#999"},[J,Ft]),zt=e.useCallback(e=>{if(!(null==V?void 0:V.colorBy))return $t(e);const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;return"target"===dt.colorBy&&n?Ft(n):t?Ft(t):"#999"},[null==V?void 0:V.colorBy,dt.colorBy,Ft,$t]),Gt="sankey"===b&&X||!!Ie||null!==(r=null===(o=At.current)||void 0===o?void 0:o.isAnimating)&&void 0!==r&&r,qt=e.useCallback(()=>{ft.current&&!Gt||ft.current||(ft.current=requestAnimationFrame(()=>vt.current()))},[Gt]);e.useEffect(()=>{var e;null===(e=At.current)||void 0===e||e.updateConfig(ht),yt.current=!0,qt()},[ht,qt]),e.useEffect(()=>{yt.current=!0,qt()},[mt,qt]);const Vt=e.useCallback(()=>{var e;const t=At.current;if(!t)return;t.runLayout([at,st]),t.buildScene([at,st]),yt.current=!0;for(const n of t.sceneNodes)n.id&&"string"==typeof(null===(e=n.style)||void 0===e?void 0:e.fill)&&Ht.current.set(n.id,n.style.fill);const n=Array.isArray(Z)?Z:C,o=Array.from(t.nodes.values());for(let e=0;o.length>e;e++){const t=o[e];Ht.current.has(t.id)||Ht.current.set(t.id,n[e%n.length])}if(Wt.current=o.length,Pt(t.layoutVersion),Se){const{nodes:e,edges:n}=t.getLayoutData();Se(e,n)}},[at,st,Se,Z]),Ut=e.useCallback(e=>{const t=At.current;t&&(t.ingestEdge(e)&&Vt(),qt())},[Vt,qt]),Kt=e.useCallback(e=>{const t=At.current;if(!t)return;let n=!1;for(const o of e)t.ingestEdge(o)&&(n=!0);n&&Vt(),qt()},[Vt,qt]),Qt=e.useCallback(()=>{var e;null===(e=At.current)||void 0===e||e.clear(),Ht.current.clear(),Wt.current=0,Pt(0),jt(null),Rt.current=null,yt.current=!0,qt()},[qt]),Zt=e.useCallback(()=>{const e=At.current;e&&(e.tension+=999,Vt(),qt())},[Vt,qt]);e.useImperativeHandle(n,()=>({push:Ut,pushMany:Kt,removeNode:e=>{var t,n,o;const r=null!==(n=null===(t=At.current)||void 0===t?void 0:t.removeNode(e))&&void 0!==n&&n;if(r){const t=(null===(o=Rt.current)||void 0===o?void 0:o.data)?"function"==typeof S?S(Rt.current.data):Rt.current.data[S]:void 0;Rt.current&&"node"===Rt.current.nodeOrEdge&&t===e&&(Rt.current=null,jt(null)),Ht.current.delete(e),Vt(),yt.current=!0,qt()}return r},removeEdge:(e,t)=>{var n,o;const r=null!==(o=null===(n=At.current)||void 0===n?void 0:n.removeEdge(e,t))&&void 0!==o&&o;if(r){if(Rt.current&&"edge"===Rt.current.nodeOrEdge){const n=Rt.current.data;let o;o=void 0!==t?("object"==typeof(null==n?void 0:n.source)?n.source.id:null==n?void 0:n.source)===e&&("object"==typeof(null==n?void 0:n.target)?n.target.id:null==n?void 0:n.target)===t:!j||!n||("function"==typeof j?j:e=>null==e?void 0:e[j])(n)===e,o&&(Rt.current=null,jt(null))}Vt(),yt.current=!0,qt()}return r},updateNode:(e,t)=>{var n,o;const r=null!==(o=null===(n=At.current)||void 0===n?void 0:n.updateNode(e,t))&&void 0!==o?o:null;return r&&(yt.current=!0,qt()),r},updateEdge:(e,t,n)=>{var o,r;const i=null!==(r=null===(o=At.current)||void 0===o?void 0:o.updateEdge(e,t,n))&&void 0!==r?r:[];return i.length>0&&(Vt(),yt.current=!0,qt()),i},clear:Qt,getTopology:()=>{var e,t;return null!==(t=null===(e=At.current)||void 0===e?void 0:e.getLayoutData())&&void 0!==t?t:{nodes:[],edges:[]}},getTopologyDiff:()=>{const e=At.current;return e?{addedNodes:Array.from(e.addedNodes),removedNodes:Array.from(e.removedNodes),addedEdges:Array.from(e.addedEdges),removedEdges:Array.from(e.removedEdges)}:{addedNodes:[],removedNodes:[],addedEdges:[],removedEdges:[]}},relayout:Zt,getTension:()=>{var e,t;return null!==(t=null===(e=At.current)||void 0===e?void 0:e.tension)&&void 0!==t?t:0}}),[Ut,Kt,Qt,Zt,Vt,qt]);const Jt=["tree","cluster","treemap","circlepack","partition","orbit"].includes(b),en=Jt?w||(Array.isArray(k)?void 0:k):void 0;e.useEffect(()=>{var e;const t=At.current;if(t)if(Jt&&en)t.ingestHierarchy(en,[at,st]),t.buildScene([at,st]),yt.current=!0,qt();else{const n=x||[],o=Array.isArray(k)?k:[];if(0===n.length&&0===o.length)return;t.ingestBounded(n,o,[at,st]),t.buildScene([at,st]);for(const n of t.sceneNodes)n.id&&(null===(e=n.style)||void 0===e?void 0:e.fill)&&Ht.current.set(n.id,n.style.fill+"");const r=Array.isArray(Z)?Z:C,i=Array.from(t.nodes.values());for(let e=0;i.length>e;e++){const t=i[e];Ht.current.has(t.id)||Ht.current.set(t.id,r[e%r.length])}Wt.current=i.length,yt.current=!0,qt()}},[x,k,w,en,Jt,at,st,ht,qt,Z]),e.useEffect(()=>{A&&A.length>0&&Kt(A)},[]);const tn=e.useCallback(e=>{if(ve&&ve(e),we){const t=Date.now();we(e?{type:"hover",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:Ae}:{type:"hover-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:Ae})}},[ve,we,Ae]),on=e.useCallback(e=>{if(ke&&ke(e),we){const t=Date.now();we(e?{type:"click",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:Ae}:{type:"click-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:Ae})}},[ke,we,Ae]),rn=e.useRef(()=>{}),an=e.useRef(()=>{});rn.current=e=>{if(!ge)return;const t=gt.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-it.left,r=e.clientY-n.top-it.top;if(0>o||o>at||0>r||r>st)return void(Rt.current&&(Rt.current=null,jt(null),tn&&(tn(null),yt.current=!0),qt()));const i=At.current;if(!i)return;const a=Wa(i.sceneNodes,i.sceneEdges,o,r);if(!a)return void(Rt.current&&(Rt.current=null,jt(null),tn&&(tn(null),yt.current=!0),qt()));const s=nn(a.datum||{},a.x,a.y,{nodeOrEdge:a.type});Rt.current=s,jt(s),tn&&(tn(s),yt.current=!0),qt()},an.current=()=>{Rt.current&&(Rt.current=null,jt(null),tn&&(tn(null),yt.current=!0),qt())};const sn=e.useRef(()=>{});sn.current=e=>{if(!ke&&!we)return;const t=gt.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-it.left,r=e.clientY-n.top-it.top;if(0>o||o>at||0>r||r>st)return;const i=At.current;if(!i)return;const a=Wa(i.sceneNodes,i.sceneEdges,o,r);on(a?nn(a.datum||{},a.x,a.y,{nodeOrEdge:a.type}):null)},e.useCallback(e=>rn.current(e),[]);const ln=e.useCallback(()=>an.current(),[]),cn=e.useCallback(e=>sn.current(e),[]),un=e.useRef(-1),dn=e.useRef(null),hn=e.useRef(-1),gn=e.useCallback(e=>{var t;const n=At.current;if(!n)return;const o=function(e){var t,n,o,r,i,a;const s=[];for(const l of e)"circle"===l.type&&null!=l.cx?s.push({x:l.cx,y:l.cy,datum:l.datum,shape:"circle",group:null!==(n=null===(t=l.datum)||void 0===t?void 0:t.id)&&void 0!==n?n:"_default"}):"rect"===l.type&&null!=l.x?s.push({x:l.x+l.w/2,y:l.y+l.h/2,datum:l.datum,shape:"rect",w:l.w,h:l.h,group:null!==(r=null===(o=l.datum)||void 0===o?void 0:o.id)&&void 0!==r?r:"_default"}):"arc"===l.type&&null!=l.cx&&s.push({x:l.cx,y:l.cy,datum:l.datum,shape:"circle",group:null!==(a=null===(i=l.datum)||void 0===i?void 0:i.id)&&void 0!==a?a:"_default"});return s.sort((e,t)=>e.x-t.x||e.y-t.y),s}(n.sceneNodes);if(0===o.length)return;const r=fe(o),i=un.current;if(0>i){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Enter"].includes(e.key))return;e.preventDefault(),un.current=0,hn.current=-1;const t=r.flat[0];dn.current={shape:t.shape,w:t.w,h:t.h};const n=nn(t.datum||{},t.x,t.y,{nodeOrEdge:"node"});return Rt.current=n,jt(n),tn&&(tn(n),yt.current=!0),void qt()}const a=pe(r,i),s=function(e,t,n,o,r){var i,a,s;const l=n.flat[t.flatIndex];if(!l)return ye(e,t,n);const c=null===(i=l.datum)||void 0===i?void 0:i.id;switch(e){case"ArrowRight":case"ArrowLeft":case"ArrowDown":case"ArrowUp":{const o=null!==(a=function(e,t,n){let o=null,r=1/0;for(let i=0;e.flat.length>i;i++){const a=e.flat[i];if(a===t)continue;const s=a.x-t.x,l=a.y-t.y;let c=!1;switch(n){case"right":c=s>0&&Math.abs(s)>=Math.abs(l);break;case"left":c=0>s&&Math.abs(s)>=Math.abs(l);break;case"down":c=l>0&&Math.abs(l)>=Math.abs(s);break;case"up":c=0>l&&Math.abs(l)>=Math.abs(s)}if(!c)continue;const u=s*s+l*l;r>u&&(r=u,o=i)}return o}(n,l,"ArrowRight"===e?"right":"ArrowLeft"===e?"left":"ArrowDown"===e?"down":"up"))&&void 0!==a?a:t.flatIndex;return o!==t.flatIndex&&(r.current=-1),o}case"Enter":{if(null==c)return t.flatIndex;const e=function(e,t){var n,o,r;const i=e+"",a=[];for(const e of t){const t=null!==(n=e.datum)&&void 0!==n?n:e,s="object"==typeof t.source?null===(o=t.source)||void 0===o?void 0:o.id:t.source,l="object"==typeof t.target?null===(r=t.target)||void 0===r?void 0:r.id:t.target,c=null!=s,u=null!=l;c&&s+""===i&&u?a.push(l+""):u&&l+""===i&&c&&a.push(s+"")}return a}(c,o);if(0===e.length)return t.flatIndex;const i=null!==(s=n.idToIdx.get(e[(r.current+1)%e.length]))&&void 0!==s?s:-1;return 0>i?t.flatIndex:(r.current=-1,i)}default:{const o=ye(e,t,n);return null!==o&&o!==t.flatIndex&&(r.current=-1),o}}}(e.key,a,r,null!==(t=n.sceneEdges)&&void 0!==t?t:[],hn);if(null===s)return;if(e.preventDefault(),0>s)return un.current=-1,dn.current=null,hn.current=-1,Rt.current=null,jt(null),tn&&(tn(null),yt.current=!0),void qt();un.current=s;const l=r.flat[s];dn.current={shape:l.shape,w:l.w,h:l.h};const c=l.datum||{},u=Object.assign(Object.assign({},"object"!=typeof c||null===c||Array.isArray(c)?{}:c),{data:c,x:l.x,y:l.y,time:l.x,value:l.y,nodeOrEdge:"node"});Rt.current=u,jt(u),tn&&(tn(u),yt.current=!0),qt()},[tn,qt]),fn=e.useCallback(e=>{un.current=-1,dn.current=null,rn.current(e)},[]);vt.current=()=>{var e,t,n,o,r,i,a;ft.current=0;const s=gt.current;if(!s)return;const l=s.getContext("2d");if(!l)return;const c=At.current;if(!c)return;const u=performance.now(),d=pt.current?Math.min((u-pt.current)/1e3,.1):.016;pt.current=u;const h=c.advanceTransition(Ze.current?u+1e6:u),g=!Ze.current&&h,f=!Ze.current&&c.tickAnimation([at,st],d);(h||yt.current||f)&&c.buildScene([at,st]);const p=Dt();if(!Nt(s,rt,it,p))return;l.clearRect(-it.left,-it.top,rt[0],rt[1]),he&&(l.fillStyle=he,l.fillRect(0,0,at,st)),De&&c.applyDecay(),Ie&&c.applyPulse(u),He&&c.applyThresholds(u),c.applyTopologyDiff(u);const y=null!==(e=null==Re?void 0:Re.threshold)&&void 0!==e?e:5e3,m=Re&&c.lastIngestTime>0&&u-c.lastIngestTime>y;if(m&&(l.globalAlpha=null!==(t=null==Re?void 0:Re.dimOpacity)&&void 0!==t?t:.5),function(e,t){for(const n of t)switch(n.type){case"bezier":Xa(e,n);break;case"line":Va(e,n);break;case"ribbon":Ua(e,n);break;case"curved":Ka(e,n)}}(l,c.sceneEdges),function(e,t){var n,o,r;for(const i of t){if("rect"!==i.type)continue;const t=i;t.w>0&&t.h>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(n=t.style.opacity)&&void 0!==n?n:1)*t.style.fillOpacity),e.fillRect(t.x,t.y,t.w,t.h)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(o=t.style.strokeWidth)&&void 0!==o?o:1,e.globalAlpha=null!==(r=t.style.opacity)&&void 0!==r?r:1,e.strokeRect(t.x,t.y,t.w,t.h)),Yt(e,t),e.restore())}}(l,c.sceneNodes),function(e,t){var n,o,r;for(const i of t){if("circle"!==i.type)continue;const t=i;t.r>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.r,0,2*Math.PI),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(n=t.style.opacity)&&void 0!==n?n:1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(o=t.style.strokeWidth)&&void 0!==o?o:1,e.globalAlpha=null!==(r=t.style.opacity)&&void 0!==r?r:1,e.stroke()),Xt(e,t),e.restore())}}(l,c.sceneNodes),function(e,t){var n,o,r;for(const i of t){if("arc"!==i.type)continue;const t=i;e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.outerR,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerR,t.endAngle,t.startAngle,!0),e.closePath(),t.style.fill&&(e.fillStyle=t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(n=t.style.opacity)&&void 0!==n?n:1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=null!==(o=t.style.strokeWidth)&&void 0!==o?o:1,e.globalAlpha=null!==(r=t.style.opacity)&&void 0!==r?r:1,e.stroke()),e.restore()}}(l,c.sceneNodes),X&&c.particlePool&&!m){const e=Array.from(c.edges.values());if(e.length>0){!function(e,t,n,o){var r,i;const a=null!==(r=o.spawnRate)&&void 0!==r?r:xi.spawnRate,s=null!==(i=o.maxPerEdge)&&void 0!==i?i:xi.maxPerEdge;for(let o=0;t.length>o;o++){const r=t[o];if(!r.bezier)continue;if(e.countForEdge(o)>=s)continue;const i=r.value*a*n*(r.bezier.circular?.3:1),l=Math.floor(i),c=i-l;let u=l;Math.random()<c&&u++;for(let t=0;u>t&&e.countForEdge(o)<s;t++)e.spawn(o)}}(c.particlePool,e,d,dt);const t=.5*(null!==(n=dt.speedMultiplier)&&void 0!==n?n:1);let o;if(dt.proportionalSpeed){const t=e.reduce((e,t)=>Math.max(e,t.value||1),1);o=e.map(e=>.3+(e.value||1)/t*1.7)}c.particlePool.step(d,t,e,o),function(e,t,n,o,r){var i,a;const s=null!==(i=o.radius)&&void 0!==i?i:xi.radius,l=null!==(a=o.opacity)&&void 0!==a?a:xi.opacity;e.globalAlpha=l;for(let i=0;t.particles.length>i;i++){const a=t.particles[i];if(!a.active)continue;const l=n[a.edgeIndex];if(l){if("function"==typeof o.color){const t="object"==typeof l.source?l.source:null;e.fillStyle=t?o.color(l,t):"#666"}else e.fillStyle=o.color&&"inherit"!==o.color?o.color:r(l);e.beginPath(),e.arc(a.x,a.y,s,0,2*Math.PI),e.fill()}}e.globalAlpha=1}(l,c.particlePool,e,dt,zt)}}m&&(l.globalAlpha=1);const v=yt.current;if(yt.current=!1,v||g||f){const e=gt.current;e&&e.setAttribute("aria-label",ct(null!==(r=null===(o=c.sceneNodes)||void 0===o?void 0:o.length)&&void 0!==r?r:0,null!==(a=null===(i=c.sceneEdges)||void 0===i?void 0:i.length)&&void 0!==a?a:0,"Network chart"))}(v||g||f)&&_t(e=>e+1),(Gt||g||f||c.hasActivePulses||c.hasActiveThresholds||c.hasActiveTopologyDiff)&&(ft.current=requestAnimationFrame(()=>vt.current()))},e.useEffect(()=>(qt(),()=>{ft.current&&(cancelAnimationFrame(ft.current),ft.current=0)}),[qt]),e.useEffect(()=>{yt.current=!0,qt()},[b,at,st,he,qt]),xe(Re,At,yt,qt,Tt,It);const pn=ge&&Et?p.createElement(Ot,{x:Et.x,y:Et.y,containerWidth:at,containerHeight:st,margin:it,className:"stream-network-tooltip",zIndex:2},me?me(Et):p.createElement(ns,{data:Et})):null;if(ot){const e=At.current;if(e){const t=["tree","cluster","treemap","circlepack","partition","orbit"].includes(b),n=t?w||(Array.isArray(k)?void 0:k):void 0;if(t&&n)e.ingestHierarchy(n,[at,st]),e.buildScene([at,st]);else{const t=x||[],n=Array.isArray(k)?k:[];(t.length>0||n.length>0)&&(e.ingestBounded(t,n,[at,st]),e.buildScene([at,st]))}}const t=null!==(i=null==e?void 0:e.sceneNodes)&&void 0!==i?i:[],n=null!==(a=null==e?void 0:e.sceneEdges)&&void 0!==a?a:[],o=null!==(s=null==e?void 0:e.labels)&&void 0!==s?s:[];return p.createElement("div",{className:"stream-network-frame"+(de?" "+de:""),role:"img","aria-label":Fe||("string"==typeof Te?Te:"Network chart"),style:{position:"relative",width:rt[0],height:rt[1]}},p.createElement(xt,{summary:$e}),p.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:rt[0],height:rt[1],style:{position:"absolute",left:0,top:0}},Ne&&p.createElement("g",{transform:`translate(${it.left},${it.top})`},Ne),p.createElement("g",{transform:`translate(${it.left},${it.top})`},he&&p.createElement("rect",{x:0,y:0,width:at,height:st,fill:he}),n.map((e,t)=>function(e,t){switch(e.type){case"line":return p.createElement("line",{key:"net-edge-"+t,x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity});case"bezier":{const n=e;return p.createElement("path",{key:"net-edge-"+t,d:n.pathD,fill:nt(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})}case"ribbon":{const n=e;return p.createElement("path",{key:"net-edge-"+t,d:n.pathD,fill:nt(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})}case"curved":{const n=e;return p.createElement("path",{key:"net-edge-"+t,d:n.pathD,fill:nt(n.style.fill,"none"),stroke:n.style.stroke||"#999",strokeWidth:n.style.strokeWidth||1,opacity:n.style.opacity})}default:return null}}(e,t)).filter(Boolean),t.map((e,t)=>function(e,t){switch(e.type){case"circle":{const n=e;return p.createElement("circle",{key:"net-circle-"+t,cx:n.cx,cy:n.cy,r:n.r,fill:nt(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})}case"rect":{const n=e;return p.createElement("rect",{key:"net-rect-"+t,x:n.x,y:n.y,width:n.w,height:n.h,fill:nt(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})}case"arc":{const n=e,o=l.arc().innerRadius(n.innerR).outerRadius(n.outerR).startAngle(n.startAngle+Math.PI/2).endAngle(n.endAngle+Math.PI/2)({})||"";return p.createElement("path",{key:"net-arc-"+t,d:o,transform:`translate(${n.cx},${n.cy})`,fill:nt(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})}default:return null}}(e,t)).filter(Boolean),o.map((e,t)=>function(e,t){return p.createElement("text",{key:"net-label-"+t,x:e.x,y:e.y,textAnchor:e.anchor||"middle",dominantBaseline:e.baseline||"auto",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"#333",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder},e.text)}(e,t)).filter(Boolean))),p.createElement(Ya,{width:at,height:st,totalWidth:rt[0],totalHeight:rt[1],margin:it,labels:o,sceneNodes:t,title:Te,legend:Me,legendPosition:je,legendHoverBehavior:Ce,legendClickBehavior:Pe,legendHighlightedCategory:Le,legendIsolatedCategories:_e,foregroundGraphics:lt,annotations:Oe,svgAnnotationRules:Ee,annotationFrame:0}))}const yn=At.current;return p.createElement("div",{ref:tt,className:"stream-network-frame"+(de?" "+de:""),role:"group","aria-label":Fe||("string"==typeof Te?Te:"Network chart"),tabIndex:0,style:{position:"relative",width:le?"100%":rt[0],height:ce?"100%":rt[1],overflow:"visible"},onKeyDown:gn},We&&p.createElement(kt,{tableId:Je}),We&&p.createElement(bt,{nodes:null!==(c=null==yn?void 0:yn.sceneNodes)&&void 0!==c?c:[],edges:null!==(u=null==yn?void 0:yn.sceneEdges)&&void 0!==u?u:[],chartType:"Network chart",tableId:Je,chartTitle:"string"==typeof Te?Te:void 0}),p.createElement(xt,{summary:$e}),p.createElement("div",{role:"img","aria-label":Fe||("string"==typeof Te?Te:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:ge?fn:void 0,onMouseLeave:ge?ln:void 0,onClick:ke||we?cn:void 0},Ne&&p.createElement("svg",{overflow:"visible",style:{position:"absolute",top:0,left:0,width:rt[0],height:rt[1],pointerEvents:"none",overflow:"visible"}},p.createElement("g",{transform:`translate(${it.left},${it.top})`},Ne)),p.createElement("canvas",{ref:gt,"aria-label":ct(null!==(h=null===(d=null==yn?void 0:yn.sceneNodes)||void 0===d?void 0:d.length)&&void 0!==h?h:0,null!==(f=null===(g=null==yn?void 0:yn.sceneEdges)||void 0===g?void 0:g.length)&&void 0!==f?f:0,"Network chart"),style:{position:"absolute",top:0,left:0}}),p.createElement(wt,{hoverPoint:Et}),p.createElement(Ya,{width:at,height:st,totalWidth:rt[0],totalHeight:rt[1],margin:it,labels:(null==yn?void 0:yn.labels)||[],sceneNodes:null==yn?void 0:yn.sceneNodes,title:Te,legend:Me,legendPosition:je,legendHoverBehavior:Ce,legendClickBehavior:Pe,legendHighlightedCategory:Le,legendIsolatedCategories:_e,foregroundGraphics:lt,annotations:Oe,svgAnnotationRules:Ee,annotationFrame:Lt}),p.createElement(St,{active:un.current>=0,hoverPoint:Et,margin:it,size:rt,shape:null===(y=dn.current)||void 0===y?void 0:y.shape,width:null===(m=dn.current)||void 0===m?void 0:m.w,height:null===(v=dn.current)||void 0===v?void 0:v.h}),pn,(null==Re?void 0:Re.showBadge)&&p.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===Re.badgePosition?{top:4,left:4}:"bottom-left"===Re.badgePosition?{bottom:4,left:4}:"bottom-right"===Re.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{background:Tt?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"})},Tt?"STALE":"LIVE")))});os.displayName="StreamNetworkFrame";const rs=e.forwardRef(function(t,n){var o;const r=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n,o,i,a;const s=Array.isArray(e)?e:[e],l=null!==(o=null===(n=null===(t=r.current)||void 0===t?void 0:t.getTopology())||void 0===n?void 0:n.nodes)&&void 0!==o?o:[],c=[];for(const e of s){const t=l.find(t=>t.id===e);t&&c.push(Object.assign(Object.assign({},null!==(i=t.data)&&void 0!==i?i:{}),{id:e})),null===(a=r.current)||void 0===a||a.removeNode(e)}return c},update:(e,t)=>(Array.isArray(e)?e:[e]).flatMap(e=>{var n;const o=null===(n=r.current)||void 0===n?void 0:n.updateNode(e,t);return o?[Object.assign(Object.assign({},o),{id:e})]:[]}),clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t,n,o;return null!==(o=null===(n=null===(t=null===(e=r.current)||void 0===e?void 0:e.getTopology())||void 0===t?void 0:t.nodes)||void 0===n?void 0:n.map(e=>e.data))&&void 0!==o?o:[]}}));const i=Zn(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLegend:t.showLegend,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary},{width:600,height:600}),{nodes:a,edges:s,margin:l,className:c,nodeIDAccessor:u="id",sourceAccessor:d="source",targetAccessor:h="target",nodeLabel:g,colorBy:f,colorScheme:y,nodeSize:m=8,nodeSizeRange:v=[5,20],edgeWidth:b=1,edgeColor:x="#999",edgeOpacity:k=.6,iterations:w=300,forceStrength:A=.1,tooltip:S,frameProps:O={},onObservation:E,onClick:M,chartId:P,selection:L,linkedHover:_,loading:B,emptyContent:N,legendInteraction:D,legendPosition:I}=t,R=i.width,H=i.height,W=i.enableHover,F=i.showLegend,$=null!==(o=i.showLabels)&&void 0!==o&&o,z=i.title,G=i.description,q=i.summary,Y=i.accessibleTable,X=zo(B,R,H),V=X?null:$o(a,R,H,N),U=a||[],K=s||[],Q=qn(U,f,y),Z=e.useMemo(()=>{if(!f)return[];const e=new Set;for(const t of U){const n="function"==typeof f?f(t):t[f];null!=n&&e.add(n+"")}return Array.from(e)},[U,f]),J=Kn(D,f,Z),ee=$n(),te=e.useMemo(()=>new Map,[]),ne=e.useMemo(()=>{if(Array.isArray(y))return y;if(ee&&ee.length>0)return ee;const e=j[y];return Array.isArray(e)?e:C},[y,ee]),oe=e.useMemo(()=>e=>{const t={};return t.fill=f?T(e.data||e,f,Q):zn(void 0,ee,y,void 0,te),"number"==typeof m&&(t.r=m),t},[f,Q,m,ee,y,te]),re=e.useMemo(()=>e=>({stroke:x,strokeWidth:"number"==typeof b?b:"function"==typeof b?b(e):e[b]||1,opacity:k}),[b,x,k]),ie=e.useMemo(()=>{if($&&g)return"function"==typeof g?g:e=>{var t,n,o;return null!==(o=null!==(n=null===(t=e.data)||void 0===t?void 0:t[g])&&void 0!==n?n:e[g])&&void 0!==o?o:e.id}},[$,g]),{legend:ae,margin:se,legendPosition:le}=Un({data:U,colorBy:f,colorScale:Q,showLegend:F,legendPosition:I,userMargin:l,defaults:i.marginDefaults}),{customHoverBehavior:ce,customClickBehavior:ue}=Xn({selection:L,linkedHover:_,fallbackFields:f?["string"==typeof f?f:""]:[],unwrapData:!0,onObservation:E,onClick:M,chartType:"ForceDirectedGraph",chartId:P}),de=bo({componentName:"ForceDirectedGraph",nodes:a,edges:s,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:u}});return de?p.createElement(uo,{componentName:"ForceDirectedGraph",message:de,width:R,height:H}):X||V||p.createElement(Ho,{componentName:"ForceDirectedGraph",width:R,height:H},p.createElement(os,Object.assign({ref:r,chartType:"force"},null!=a&&{nodes:U},null!=s&&{edges:K},{size:[R,H],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:se,nodeIDAccessor:u,sourceAccessor:d,targetAccessor:h,iterations:w,forceStrength:A,nodeStyle:oe,edgeStyle:re,colorBy:f,colorScheme:ne,nodeSize:m,nodeSizeRange:v,nodeLabel:ie,showLabels:$,enableHover:W,tooltipContent:!1===S?()=>null:ro(S)||void 0,customHoverBehavior:_||E||M?ce:void 0,customClickBehavior:E||M?ue:void 0,legend:ae,legendPosition:le},D&&"none"!==D&&{legendHoverBehavior:J.onLegendHover,legendClickBehavior:J.onLegendClick,legendHighlightedCategory:J.highlightedCategory,legendIsolatedCategories:J.isolatedCategories},{className:c,title:z,description:G,summary:q,accessibleTable:Y},O)))});function is(e,t){if(!e)return[];const n=[],o=e=>{n.push(e);const r="function"==typeof t?t(e):e[t];r&&Array.isArray(r)&&r.forEach(o)};return o(e),n}function as(e,t,n,o){if(e&&e.length>0)return e;const r=new Set;return t.forEach(e=>{const t="function"==typeof n?n(e):e[n],i="function"==typeof o?o(e):e[o];r.add(t),r.add(i)}),Array.from(r).map(e=>({id:e}))}function ss(e){return"function"==typeof e?e:t=>t[e]||1}function ls({edgeColorBy:e,colorBy:t,colorScale:n,nodeStyleFn:o,edgeOpacity:r,baseStyle:i={}}){return a=>{const s=Object.assign({fillOpacity:r},i);if("function"==typeof e)s.fill=e(a);else if("source"===e){const e="object"==typeof a.source?a.source:null;t&&e?s.fill=T(e.data||e,t,n):e&&(s.fill=o(e,e.index).fill)}else if("target"===e){const e="object"==typeof a.target?a.target:null;t&&e?s.fill=T(e.data||e,t,n):e&&(s.fill=o(e,e.index).fill)}else"gradient"===e&&(s.fill="#999",s.fillOpacity=.7*r);return s}}rs.displayName="ForceDirectedGraph";const cs=e.forwardRef(function(t,n){var o;const r=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n,o,i,a;const s=Array.isArray(e)?e:[e],l=null!==(o=null===(n=null===(t=r.current)||void 0===t?void 0:t.getTopology())||void 0===n?void 0:n.nodes)&&void 0!==o?o:[],c=[];for(const e of s){const t=l.find(t=>t.id===e);t&&c.push(Object.assign(Object.assign({},null!==(i=t.data)&&void 0!==i?i:{}),{id:e})),null===(a=r.current)||void 0===a||a.removeNode(e)}return c},update:(e,t)=>(Array.isArray(e)?e:[e]).flatMap(e=>{var n;const o=null===(n=r.current)||void 0===n?void 0:n.updateNode(e,t);return o?[Object.assign(Object.assign({},o),{id:e})]:[]}),clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t,n,o;return null!==(o=null===(n=null===(t=null===(e=r.current)||void 0===e?void 0:e.getTopology())||void 0===t?void 0:t.edges)||void 0===n?void 0:n.map(e=>e.data))&&void 0!==o?o:[]}}));const i=Zn(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary},{width:600,height:600}),{nodes:a,edges:s,margin:l,className:c,sourceAccessor:u="source",targetAccessor:d="target",valueAccessor:h="value",nodeIdAccessor:g="id",colorBy:f,colorScheme:y,edgeColorBy:m="source",padAngle:v=.01,groupWidth:b=20,sortGroups:x,nodeLabel:k,edgeOpacity:w=.5,tooltip:A,frameProps:S={},onObservation:O,onClick:E,chartId:M,selection:P,linkedHover:L,loading:_,emptyContent:B,legendInteraction:N}=t,D=i.width,I=i.height,R=i.enableHover,H=null===(o=i.showLabels)||void 0===o||o,W=i.title,F=i.description,$=i.summary,z=i.accessibleTable,G=zo(_,D,I),q=G?null:$o(s,D,I,B),Y=s||[],X=e.useMemo(()=>as(a,Y,u,d),[a,Y,u,d]),V=qn(X,f,y),U=e.useMemo(()=>{if(!f)return[];const e=new Set;for(const t of X){const n="function"==typeof f?f(t):t[f];null!=n&&e.add(n+"")}return Array.from(e)},[X,f]),K=Kn(N,f,U),Q=$n(),Z=e.useMemo(()=>new Map,[]),J=e.useMemo(()=>{if(Array.isArray(y))return y;if(Q&&Q.length>0)return Q;const e=j[y];return Array.isArray(e)?e:C},[y,Q]),ee=X.length>0,te=e.useMemo(()=>{if(ee)return(e,t)=>{var n,o;const r={stroke:"black",strokeWidth:1};if(f)r.fill=T(e.data||e,f,V);else{const i=Array.isArray(y)?y:j[y]||C,a=Array.isArray(i)?i:C,s=null!==(o=null!==(n=e.index)&&void 0!==n?n:t)&&void 0!==o?o:0;r.fill=a[s%a.length]}return r}},[ee,f,V,y]),ne=e.useMemo(()=>{if(ee)return ls({edgeColorBy:m,colorBy:f,colorScale:V,nodeStyleFn:te||(e=>({fill:zn(void 0,Q,y,void 0,Z)})),edgeOpacity:w,baseStyle:{stroke:"black",strokeWidth:.5,strokeOpacity:w}})},[ee,m,f,V,te,w,Q,y,Z]),oe=e.useMemo(()=>{if(!H)return;const e=k||g;return"function"==typeof e?e:t=>{var n,o,r;return null!==(r=null!==(o=null===(n=t.data)||void 0===n?void 0:n[e])&&void 0!==o?o:t[e])&&void 0!==r?r:t.id}},[H,k,g]),re=Object.assign(Object.assign({},i.marginDefaults),l),{customHoverBehavior:ie,customClickBehavior:ae}=Xn({selection:P,linkedHover:L,fallbackFields:f?["string"==typeof f?f:""]:[],unwrapData:!0,onObservation:O,onClick:E,chartType:"ChordDiagram",chartId:M}),se=bo({componentName:"ChordDiagram",edges:s,edgesRequired:!0});return se?p.createElement(uo,{componentName:"ChordDiagram",message:se,width:D,height:I}):G||q||p.createElement(Ho,{componentName:"ChordDiagram",width:D,height:I},p.createElement(os,Object.assign({ref:r,chartType:"chord"},X.length>0&&{nodes:X},null!=s&&{edges:Y},{size:[D,I],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:re,nodeIDAccessor:g,sourceAccessor:u,targetAccessor:d,valueAccessor:h,padAngle:v,groupWidth:b,sortGroups:x,nodeStyle:te,edgeStyle:ne,colorBy:f,colorScheme:J,edgeColorBy:m,edgeOpacity:w,nodeLabel:oe,showLabels:H,enableHover:R,tooltipContent:!1===A?()=>null:ro(A)||void 0,customHoverBehavior:L||O||E?ie:void 0,customClickBehavior:O||E?ae:void 0},N&&"none"!==N&&{legendHoverBehavior:K.onLegendHover,legendClickBehavior:K.onLegendClick,legendHighlightedCategory:K.highlightedCategory,legendIsolatedCategories:K.isolatedCategories},{className:c,title:W,description:F,summary:$,accessibleTable:z},S)))});cs.displayName="ChordDiagram";const us=e.forwardRef(function(t,n){var o;const r=e.useRef(null);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n,o,i,a;const s=Array.isArray(e)?e:[e],l=null!==(o=null===(n=null===(t=r.current)||void 0===t?void 0:t.getTopology())||void 0===n?void 0:n.nodes)&&void 0!==o?o:[],c=[];for(const e of s){const t=l.find(t=>t.id===e);t&&c.push(Object.assign(Object.assign({},null!==(i=t.data)&&void 0!==i?i:{}),{id:e})),null===(a=r.current)||void 0===a||a.removeNode(e)}return c},update:(e,t)=>(Array.isArray(e)?e:[e]).flatMap(e=>{var n;const o=null===(n=r.current)||void 0===n?void 0:n.updateNode(e,t);return o?[Object.assign(Object.assign({},o),{id:e})]:[]}),clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t,n,o;return null!==(o=null===(n=null===(t=null===(e=r.current)||void 0===e?void 0:e.getTopology())||void 0===t?void 0:t.edges)||void 0===n?void 0:n.map(e=>e.data))&&void 0!==o?o:[]}}));const i=Zn(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary},{width:800,height:600}),{nodes:a,edges:s,margin:l,className:c,sourceAccessor:u="source",targetAccessor:d="target",valueAccessor:h="value",nodeIdAccessor:g="id",colorBy:f,colorScheme:y,edgeColorBy:m="source",orientation:v="horizontal",nodeAlign:b="justify",nodePaddingRatio:x=.05,nodeWidth:k=15,nodeLabel:w,edgeOpacity:A=.5,edgeSort:S,tooltip:O,frameProps:E={},onObservation:M,onClick:P,chartId:L,selection:_,linkedHover:B,loading:N,emptyContent:D,legendInteraction:I}=t,R=i.width,H=i.height,W=i.enableHover,F=null===(o=i.showLabels)||void 0===o||o,$=i.title,z=i.description,G=i.summary,q=i.accessibleTable,Y=zo(N,R,H),X=Y?null:$o(s,R,H,D),V=s||[],U=e.useMemo(()=>as(a,V,u,d),[a,V,u,d]),K=qn(U,f,y),Q=e.useMemo(()=>{if(!f)return[];const e=new Set;for(const t of U){const n="function"==typeof f?f(t):t[f];null!=n&&e.add(n+"")}return Array.from(e)},[U,f]),Z=Kn(I,f,Q),J=$n(),ee=e.useMemo(()=>new Map,[]),te=e.useMemo(()=>{if(Array.isArray(y))return y;if(J&&J.length>0)return J;const e=j[y];return Array.isArray(e)?e:C},[y,J]),ne=e.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=f?T(e.data||e,f,K):zn(void 0,J,y,void 0,ee),t},[f,K,J,y,ee]),oe=e.useMemo(()=>ls({edgeColorBy:m,colorBy:f,colorScale:K,nodeStyleFn:ne,edgeOpacity:A,baseStyle:{stroke:"none",strokeWidth:0}}),[m,f,K,ne,A]),re=e.useMemo(()=>{if(!F)return;const e=w||g;return"function"==typeof e?e:t=>{var n,o,r;return null!==(r=null!==(o=null===(n=t.data)||void 0===n?void 0:n[e])&&void 0!==o?o:t[e])&&void 0!==r?r:t.id}},[F,w,g]),ie=Object.assign(Object.assign({},i.marginDefaults),l),{customHoverBehavior:ae,customClickBehavior:se}=Xn({selection:_,linkedHover:B,fallbackFields:f?["string"==typeof f?f:""]:[],unwrapData:!0,onObservation:M,onClick:P,chartType:"SankeyDiagram",chartId:L}),le=bo({componentName:"SankeyDiagram",edges:s,edgesRequired:!0});return le?p.createElement(uo,{componentName:"SankeyDiagram",message:le,width:R,height:H}):Y||X||p.createElement(Ho,{componentName:"SankeyDiagram",width:R,height:H},p.createElement(os,Object.assign({ref:r,chartType:"sankey"},U.length>0&&{nodes:U},null!=s&&{edges:V},{size:[R,H],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:ie,nodeIDAccessor:g,sourceAccessor:u,targetAccessor:d,valueAccessor:h,orientation:v,nodeAlign:b,nodePaddingRatio:x,nodeWidth:k,nodeStyle:ne,edgeStyle:oe,colorBy:f,colorScheme:te,edgeColorBy:m,edgeOpacity:A,edgeSort:S,nodeLabel:re,showLabels:F,enableHover:W,tooltipContent:!1===O?()=>null:ro(O)||void 0,customHoverBehavior:B||M||P?ae:void 0,customClickBehavior:M||P?se:void 0},I&&"none"!==I&&{legendHoverBehavior:Z.onLegendHover,legendClickBehavior:Z.onLegendClick,legendHighlightedCategory:Z.highlightedCategory,legendIsolatedCategories:Z.isolatedCategories},{className:c,title:$,description:z,summary:G,accessibleTable:q},E)))});function ds(t){var n;const o=Zn(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary},{width:600,height:600}),{data:r,margin:i,className:a,layout:s="tree",orientation:l="vertical",childrenAccessor:c="children",valueAccessor:u="value",nodeIdAccessor:d="name",colorBy:h,colorScheme:g,colorByDepth:f=!1,edgeStyle:y="curve",nodeLabel:m,nodeSize:v=5,tooltip:b,frameProps:x={},onObservation:k,onClick:w,chartId:A,selection:S,linkedHover:O,loading:E,legendInteraction:M}=t,P=o.width,_=o.height,B=o.enableHover,N=null===(n=o.showLabels)||void 0===n||n,D=o.title,I=o.description,R=o.summary,H=o.accessibleTable,W=zo(E,P,_),F=e.useMemo(()=>is(null!=r?r:null,c),[r,c]),$=qn(F,f?void 0:h,g),z=e.useMemo(()=>{if(!h||f)return[];const e=new Set;for(const t of F){const n="function"==typeof h?h(t):t[h];null!=n&&e.add(n+"")}return Array.from(e)},[F,h,f]),G=Kn(M,f?void 0:h,z),q=$n(),Y=e.useMemo(()=>new Map,[]),X=e.useMemo(()=>{if(Array.isArray(g))return g;if(q&&q.length>0)return q;const e=j[g];return Array.isArray(e)?e:C},[g,q]),V=e.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=f?L[(e.depth||0)%L.length]:h?T(e.data||e,h,$):zn(void 0,q,g,void 0,Y),t},[h,f,$,q,g,Y]),U=e.useMemo(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),K=e.useMemo(()=>{if("treemap"===s||"circlepack"===s||"partition"===s)return ss(u)},[s,u]),Q=Object.assign(Object.assign({},o.marginDefaults),i),{customHoverBehavior:Z,customClickBehavior:J}=Xn({selection:S,linkedHover:O,fallbackFields:h?["string"==typeof h?h:""]:[],unwrapData:!0,onObservation:k,onClick:w,chartType:"TreeDiagram",chartId:A}),ee=vo({componentName:"TreeDiagram",data:r});return ee?p.createElement(uo,{componentName:"TreeDiagram",message:ee,width:P,height:_}):W||p.createElement(Ho,{componentName:"TreeDiagram",width:P,height:_},p.createElement(os,Object.assign({chartType:s},null!=r&&{data:r},{size:[P,_],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:Q,nodeIDAccessor:d,childrenAccessor:c,hierarchySum:K,treeOrientation:l,edgeType:y,nodeStyle:V,edgeStyle:U,colorBy:h,colorScheme:X,colorByDepth:f,nodeSize:v,nodeLabel:N?m||d:void 0,showLabels:N,enableHover:B,tooltipContent:!1===b?()=>null:ro(b)||void 0,customHoverBehavior:O||k||w?Z:void 0,customClickBehavior:k||w?J:void 0},M&&"none"!==M&&{legendHoverBehavior:G.onLegendHover,legendClickBehavior:G.onLegendClick,legendHighlightedCategory:G.highlightedCategory,legendIsolatedCategories:G.isolatedCategories},{className:a,title:D,description:I,summary:R,accessibleTable:H},x)))}function hs(t){var n;const o=Zn(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary,linkedHover:t.linkedHover},{width:600,height:600}),{data:r,margin:i,className:a,childrenAccessor:s="children",valueAccessor:l="value",nodeIdAccessor:c="name",colorBy:u,colorScheme:d,colorByDepth:h=!1,labelMode:g="leaf",nodeLabel:f,padding:y=4,paddingTop:m,tooltip:v,frameProps:b={},selection:x,linkedHover:k,onObservation:w,onClick:A,chartId:S,loading:O,legendInteraction:E}=t,M=o.width,P=o.height,_=o.enableHover,B=null===(n=o.showLabels)||void 0===n||n,N=o.title,D=o.description,I=o.summary,R=o.accessibleTable,H=zo(O,M,P),{activeSelectionHook:W,customHoverBehavior:F,customClickBehavior:$}=Xn({selection:x,linkedHover:k,fallbackFields:u?["string"==typeof u?u:""]:[],onObservation:w,onClick:A,chartType:"Treemap",chartId:S}),z=e.useCallback(e=>{if(!e)return F(null);const t=e.data||e;F({data:(null==t?void 0:t.data)||t})},[F]),G=e.useMemo(()=>is(null!=r?r:null,s),[r,s]),q=qn(G,h?void 0:u,d),Y=e.useMemo(()=>{if(!u||h)return[];const e=new Set;for(const t of G){const n="function"==typeof u?u(t):t[u];null!=n&&e.add(n+"")}return Array.from(e)},[G,u,h]),X=Kn(E,h?void 0:u,Y),V=$n(),U=e.useMemo(()=>new Map,[]),K=e.useMemo(()=>{if(Array.isArray(d))return d;if(V&&V.length>0)return V;const e=j[d];return Array.isArray(e)?e:C},[d,V]),Q=e.useMemo(()=>e=>{const t={stroke:"#fff",strokeWidth:1,strokeOpacity:.8};return t.fill=h?L[(e.depth||0)%L.length]:u?T(e.data||e,u,q):zn(void 0,V,d,void 0,U),t},[u,h,q,V,d,U]),Z=e.useMemo(()=>W?e=>{var t;const n=Object.assign({},Q(e));if(W.isActive)if(W.predicate(e.data||e))(null==x?void 0:x.selectedStyle)&&Object.assign(n,x.selectedStyle);else{const e=null!==(t=null==x?void 0:x.unselectedOpacity)&&void 0!==t?t:.2;n.opacity=e,n.fillOpacity=e,n.strokeOpacity=e,(null==x?void 0:x.unselectedStyle)&&Object.assign(n,x.unselectedStyle)}return n}:Q,[Q,W,x]),J=e.useMemo(()=>ss(l),[l]),ee=void 0!==m?m:!B||"parent"!==g&&"all"!==g?void 0:18,te=Object.assign(Object.assign({},o.marginDefaults),i),ne=vo({componentName:"Treemap",data:r});return ne?p.createElement(uo,{componentName:"Treemap",message:ne,width:M,height:P}):H||p.createElement(Ho,{componentName:"Treemap",width:M,height:P},p.createElement(os,Object.assign({chartType:"treemap"},null!=r&&{data:r},{size:[M,P],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:te,nodeIDAccessor:c,childrenAccessor:s,hierarchySum:J,padding:y,paddingTop:ee,nodeStyle:Z,colorBy:u,colorScheme:K,colorByDepth:h,nodeLabel:B?f||c:void 0,showLabels:B,labelMode:g,enableHover:_,tooltipContent:!1===v?()=>null:ro(v)||void 0},(k||w||A)&&{customHoverBehavior:z},(w||A)&&{customClickBehavior:$},E&&"none"!==E&&{legendHoverBehavior:X.onLegendHover,legendClickBehavior:X.onLegendClick,legendHighlightedCategory:X.highlightedCategory,legendIsolatedCategories:X.isolatedCategories},{className:a,title:N,description:D,summary:I,accessibleTable:R},b)))}function gs(t){var n;const o=Zn(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary},{width:600,height:600}),{data:r,margin:i,className:a,childrenAccessor:s="children",valueAccessor:l="value",nodeIdAccessor:c="name",colorBy:u,colorScheme:d,colorByDepth:h=!1,nodeLabel:g,circleOpacity:f=.7,padding:y=4,tooltip:m,frameProps:v={},onObservation:b,onClick:x,chartId:k,selection:w,linkedHover:A,loading:S,legendInteraction:O}=t,E=o.width,M=o.height,P=o.enableHover,_=null===(n=o.showLabels)||void 0===n||n,B=o.title,N=o.description,D=o.summary,I=o.accessibleTable,R=zo(S,E,M),H=e.useMemo(()=>is(null!=r?r:null,s),[r,s]),W=qn(H,h?void 0:u,d),F=e.useMemo(()=>{if(!u||h)return[];const e=new Set;for(const t of H){const n="function"==typeof u?u(t):t[u];null!=n&&e.add(n+"")}return Array.from(e)},[H,u,h]),$=Kn(O,h?void 0:u,F),z=$n(),G=e.useMemo(()=>new Map,[]),q=e.useMemo(()=>{if(Array.isArray(d))return d;if(z&&z.length>0)return z;const e=j[d];return Array.isArray(e)?e:C},[d,z]),Y=e.useMemo(()=>e=>{const t={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:f};return t.fill=h?L[(e.depth||0)%L.length]:u?T(e.data||e,u,W):zn(void 0,z,d,void 0,G),t},[u,h,W,f,z,d,G]),X=e.useMemo(()=>ss(l),[l]),V=Object.assign(Object.assign({},o.marginDefaults),i),{customHoverBehavior:U,customClickBehavior:K}=Xn({selection:w,linkedHover:A,fallbackFields:u?["string"==typeof u?u:""]:[],unwrapData:!0,onObservation:b,onClick:x,chartType:"CirclePack",chartId:k}),Q=vo({componentName:"CirclePack",data:r});return Q?p.createElement(uo,{componentName:"CirclePack",message:Q,width:E,height:M}):R||p.createElement(Ho,{componentName:"CirclePack",width:E,height:M},p.createElement(os,Object.assign({chartType:"circlepack"},null!=r&&{data:r},{size:[E,M],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:V,nodeIDAccessor:c,childrenAccessor:s,hierarchySum:X,padding:y,nodeStyle:Y,colorBy:u,colorScheme:q,colorByDepth:h,nodeLabel:_?g||c:void 0,showLabels:_,enableHover:P,tooltipContent:!1===m?()=>null:ro(m)||void 0,customHoverBehavior:A||b||x?U:void 0,customClickBehavior:b||x?K:void 0},O&&"none"!==O&&{legendHoverBehavior:$.onLegendHover,legendClickBehavior:$.onLegendClick,legendHighlightedCategory:$.highlightedCategory,legendIsolatedCategories:$.isolatedCategories},{className:a,title:B,description:N,summary:D,accessibleTable:I},v)))}us.displayName="SankeyDiagram",ds.displayName="TreeDiagram",hs.displayName="Treemap",gs.displayName="CirclePack";const fs=L;function ps(t){const n=Zn(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary},{width:600,height:600}),{data:o,margin:r,className:i,childrenAccessor:a="children",nodeIdAccessor:s="name",colorBy:l,colorScheme:c,colorByDepth:u=!1,orbitMode:d="flat",orbitSize:h=2.95,speed:g=.25,revolution:f,revolutionStyle:y,eccentricity:m=1,showRings:v=!0,nodeRadius:b=6,showLabels:x=!1,animated:k=!0,tooltip:w,foregroundGraphics:A,annotations:S,frameProps:O={},onObservation:E,onClick:M,chartId:P,selection:L,linkedHover:_,loading:B}=t,N=n.width,D=n.height,I=n.enableHover,R=n.title,H=n.description,W=n.summary,F=n.accessibleTable,$=zo(B,N,D),z=qn(e.useMemo(()=>is(o,a),[o,a]),u?void 0:l,c),G=$n(),q=e.useMemo(()=>new Map,[]),Y=e.useMemo(()=>{if(Array.isArray(c))return c;if(G&&G.length>0)return G;const e=j[c];return Array.isArray(e)?e:C},[c,G]),X=e.useMemo(()=>{if(Array.isArray(c))return c;const e=j[c];return Array.isArray(e)?e:C},[c]),V=e.useMemo(()=>e=>{var t;const n={stroke:"#fff",strokeWidth:1},o=0===(null!==(t=e.depth)&&void 0!==t?t:0);return n.fill=u?o?X[0]:fs[(e.depth||0)%fs.length]:l?T(e.data||e,l,z):zn(void 0,G,c,void 0,q),n.opacity=o?1:.85,n},[l,u,z,X,G,c,q]),U=e.useMemo(()=>()=>({stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1}),[]),K=Object.assign({top:10,right:10,bottom:10,left:10},r),{customHoverBehavior:Q,customClickBehavior:Z}=Xn({selection:L,linkedHover:_,fallbackFields:l?["string"==typeof l?l:""]:[],unwrapData:!0,onObservation:E,onClick:M,chartType:"OrbitDiagram",chartId:P}),J=e.useMemo(()=>{if(Q)return e=>{Q(e&&e.data&&void 0!==e.data.data?Object.assign(Object.assign({},e),{data:e.data.data}):e)}},[Q]),ee=e.useMemo(()=>{if(Z)return e=>{Z(e&&e.data&&void 0!==e.data.data?Object.assign(Object.assign({},e),{data:e.data.data}):e)}},[Z]),te=vo({componentName:"OrbitDiagram",data:o});return te?p.createElement(uo,{componentName:"OrbitDiagram",message:te,width:N,height:D}):$||p.createElement(Ho,{componentName:"OrbitDiagram",width:N,height:D},p.createElement(os,Object.assign({chartType:"orbit"},null!=o&&{data:o},{size:[N,D],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:K,nodeIDAccessor:s,childrenAccessor:a,nodeStyle:V,edgeStyle:U,colorBy:l,colorScheme:Y,colorByDepth:u,nodeSize:b,nodeLabel:x?s:void 0,showLabels:x,enableHover:!k&&I,tooltipContent:k?void 0:!1===w?()=>null:ro(w)||void 0,customHoverBehavior:_||E||M?J:void 0,customClickBehavior:E||M?ee:void 0,foregroundGraphics:A,annotations:S,className:i,title:R,description:H,summary:W,orbitMode:d,orbitSize:h,orbitSpeed:g,orbitRevolution:f,orbitRevolutionStyle:y,orbitEccentricity:m,orbitShowRings:v,orbitAnimated:k,accessibleTable:F},O)))}ps.displayName="OrbitDiagram";const ys=e.forwardRef(function(t,n){var o,r,i,a;const s=Zn(t.mode,{width:null!==(r=null===(o=t.size)||void 0===o?void 0:o[0])&&void 0!==r?r:t.width,height:null!==(a=null===(i=t.size)||void 0===i?void 0:i[1])&&void 0!==a?a:t.height,enableHover:null!=t.enableHover?!!t.enableHover:void 0}),{size:l,margin:c,className:u,arrowOfTime:d="right",windowMode:h="sliding",windowSize:g=200,data:f,timeAccessor:y,valueAccessor:m,timeExtent:v,valueExtent:b,extentPadding:x,stroke:k="#007bff",strokeWidth:w=2,strokeDasharray:A,background:S,tooltipContent:O,tooltip:E,onHover:M,annotations:j,svgAnnotationRules:C,tickFormatTime:P,tickFormatValue:L,decay:_,pulse:T,staleness:B,transition:N,linkedHover:D,selection:I,onObservation:R,chartId:H,loading:W,emptyContent:F,emphasis:$,legendPosition:z}=t,G=s.showAxes,q=s.enableHover,Y=null!=c?c:s.marginDefaults,X=null!=l?l:[s.width,s.height],V=null!=O?O:E,U=e.useRef(null),{customHoverBehavior:K}=Xn({selection:I,linkedHover:D,unwrapData:!0,onObservation:R,chartType:"RealtimeLineChart",chartId:H}),Q=e.useCallback(e=>{M&&M(e),K(e)},[M,K]);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=U.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=U.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;return null===(e=U.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=U.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const Z=zo(W,X[0],X[1]),J=Z?null:$o(f,X[0],X[1],F),ee={stroke:k,strokeWidth:w,strokeDasharray:A};return Z||J||p.createElement(gn,{ref:U,chartType:"line",runtimeMode:"streaming",size:X,margin:Y,className:$?`${u||""} semiotic-emphasis-${$}`.trim():u,arrowOfTime:d,windowMode:h,windowSize:g,data:f,timeAccessor:y,valueAccessor:m,xExtent:v,yExtent:b,extentPadding:x,lineStyle:ee,showAxes:G,background:S,hoverAnnotation:q,tooltipContent:V,customHoverBehavior:Q,annotations:j,svgAnnotationRules:C,tickFormatTime:P,tickFormatValue:L,decay:_,pulse:T,staleness:B,transition:N,pointIdAccessor:t.pointIdAccessor,legendPosition:z})});ys.displayName="RealtimeLineChart";const ms=e.forwardRef(function(t,n){var o,r,i,a;const s=Zn(t.mode,{width:null!==(r=null===(o=t.size)||void 0===o?void 0:o[0])&&void 0!==r?r:t.width,height:null!==(a=null===(i=t.size)||void 0===i?void 0:i[1])&&void 0!==a?a:t.height,enableHover:null!=t.enableHover?!!t.enableHover:void 0}),{binSize:l,size:c,margin:u,className:d,arrowOfTime:h="right",windowMode:g="sliding",windowSize:f=200,data:y,timeAccessor:m,valueAccessor:v,timeExtent:b,valueExtent:x,extentPadding:k,categoryAccessor:w,colors:A,fill:S,stroke:O,strokeWidth:E,gap:M,background:j,tooltipContent:C,tooltip:P,onHover:L,annotations:_,svgAnnotationRules:T,tickFormatTime:B,tickFormatValue:N,linkedHover:D,selection:I,decay:R,pulse:H,staleness:W,transition:F,onObservation:$,chartId:z,loading:G,emptyContent:q,emphasis:Y,legendPosition:X,brush:V,onBrush:U,linkedBrush:K}=t,Q=s.showAxes,Z=s.enableHover,J=null!=u?u:s.marginDefaults,ee=null!=c?c:[s.width,s.height],te=null!=C?C:P,ne=e.useRef(null),{customHoverBehavior:oe}=Xn({selection:I,linkedHover:D,unwrapData:!0,onObservation:$,chartType:"RealtimeTemporalHistogram",chartId:z}),re=e.useCallback(e=>{L&&L(e),oe(e)},[L,oe]),ie=!0===V?{dimension:"x",snap:"bin"}:"x"===V?{dimension:"x"}:"object"==typeof V?V:void 0,ae=Tn(K),se=En(Object.assign({name:(null==ae?void 0:ae.name)||"__unused_hist_brush__",xField:(null==ae?void 0:ae.xField)||("string"==typeof m?m:"time")},(null==ae?void 0:ae.yField)?{yField:ae.yField}:{})),le=e.useRef(se.brushInteraction);le.current=se.brushInteraction;const ce=e.useCallback(e=>{if(U&&U(e),$&&$(e?{type:"brush",extent:e,timestamp:Date.now(),chartType:"RealtimeTemporalHistogram",chartId:z}:{type:"brush-end",timestamp:Date.now(),chartType:"RealtimeTemporalHistogram",chartId:z}),ae){const t=le.current;t.end(e?"xBrush"===t.brush?e.x:"yBrush"===t.brush?e.y:[[e.x[0],e.y[0]],[e.x[1],e.y[1]]]:null)}},[U,$,z,ae]);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=ne.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=ne.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=ne.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=ne.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;return null===(e=ne.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=ne.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const ue=zo(G,ee[0],ee[1]),de=ue?null:$o(y,ee[0],ee[1],q),he={};return null!=S&&(he.fill=S),null!=O&&(he.stroke=O),null!=E&&(he.strokeWidth=E),null!=M&&(he.gap=M),ue||de||p.createElement(gn,{ref:ne,chartType:"bar",runtimeMode:"streaming",size:ee,margin:J,className:Y?`${d||""} semiotic-emphasis-${Y}`.trim():d,arrowOfTime:h,windowMode:g,windowSize:f,data:y,timeAccessor:m,valueAccessor:v,xExtent:b,yExtent:x,extentPadding:k,binSize:l,categoryAccessor:w,barColors:A,barStyle:he,showAxes:Q,background:j,hoverAnnotation:Z,tooltipContent:te,customHoverBehavior:re,annotations:_,svgAnnotationRules:T,tickFormatTime:B,tickFormatValue:N,decay:R,pulse:H,staleness:W,transition:F,pointIdAccessor:t.pointIdAccessor,legendPosition:X,brush:ie||(K?{dimension:"x"}:void 0),onBrush:ie||K?ce:void 0})});ms.displayName="RealtimeTemporalHistogram";const vs=ms,bs=e.forwardRef(function(t,n){var o,r,i,a;const s=Zn(t.mode,{width:null!==(r=null===(o=t.size)||void 0===o?void 0:o[0])&&void 0!==r?r:t.width,height:null!==(a=null===(i=t.size)||void 0===i?void 0:i[1])&&void 0!==a?a:t.height,enableHover:null!=t.enableHover?!!t.enableHover:void 0}),{size:l,margin:c,className:u,arrowOfTime:d="right",windowMode:h="sliding",windowSize:g=200,data:f,timeAccessor:y,valueAccessor:m,timeExtent:v,valueExtent:b,extentPadding:x,categoryAccessor:k,colors:w,radius:A,fill:S,opacity:O,stroke:E,strokeWidth:M,background:j,tooltipContent:C,tooltip:P,onHover:L,annotations:_,svgAnnotationRules:T,tickFormatTime:B,tickFormatValue:N,linkedHover:D,selection:I,onObservation:R,chartId:H,loading:W,emptyContent:F,emphasis:$,legendPosition:z}=t,G=s.showAxes,q=s.enableHover,Y=null!=c?c:s.marginDefaults,X=null!=l?l:[s.width,s.height],V=null!=C?C:P,U=e.useRef(null),{customHoverBehavior:K}=Xn({selection:I,linkedHover:D,unwrapData:!0,onObservation:R,chartType:"RealtimeSwarmChart",chartId:H}),Q=e.useCallback(e=>{L&&L(e),K(e)},[L,K]);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=U.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=U.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;return null===(e=U.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=U.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const Z=zo(W,X[0],X[1]),J=Z?null:$o(f,X[0],X[1],F),ee={};return null!=A&&(ee.radius=A),null!=S&&(ee.fill=S),null!=O&&(ee.opacity=O),null!=E&&(ee.stroke=E),null!=M&&(ee.strokeWidth=M),Z||J||p.createElement(gn,{ref:U,chartType:"swarm",runtimeMode:"streaming",size:X,margin:Y,className:$?`${u||""} semiotic-emphasis-${$}`.trim():u,arrowOfTime:d,windowMode:h,windowSize:g,data:f,timeAccessor:y,valueAccessor:m,xExtent:v,yExtent:b,extentPadding:x,categoryAccessor:k,barColors:w,swarmStyle:ee,showAxes:G,background:j,hoverAnnotation:q,tooltipContent:V,customHoverBehavior:Q,annotations:_,svgAnnotationRules:T,tickFormatTime:B,tickFormatValue:N,legendPosition:z,pointIdAccessor:t.pointIdAccessor})});bs.displayName="RealtimeSwarmChart";const xs=e.forwardRef(function(t,n){var o,r,i,a;const s=Zn(t.mode,{width:null!==(r=null===(o=t.size)||void 0===o?void 0:o[0])&&void 0!==r?r:t.width,height:null!==(a=null===(i=t.size)||void 0===i?void 0:i[1])&&void 0!==a?a:t.height,enableHover:null!=t.enableHover?!!t.enableHover:void 0}),{size:l,margin:c,className:u,arrowOfTime:d="right",windowMode:h="sliding",windowSize:g=200,data:f,timeAccessor:y,valueAccessor:m,timeExtent:v,valueExtent:b,extentPadding:x,positiveColor:k,negativeColor:w,connectorStroke:A,connectorWidth:S,gap:O,stroke:E,strokeWidth:M,background:j,tooltipContent:C,tooltip:P,onHover:L,annotations:_,svgAnnotationRules:T,tickFormatTime:B,tickFormatValue:N,linkedHover:D,selection:I,onObservation:R,chartId:H,loading:W,emptyContent:F,emphasis:$,legendPosition:z}=t,G=s.showAxes,q=s.enableHover,Y=null!=c?c:s.marginDefaults,X=null!=l?l:[s.width,s.height],V=null!=C?C:P,U=e.useRef(null),{customHoverBehavior:K}=Xn({selection:I,linkedHover:D,unwrapData:!0,onObservation:R,chartType:"RealtimeWaterfallChart",chartId:H}),Q=e.useCallback(e=>{L&&L(e),K(e)},[L,K]);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=U.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=U.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;return null===(e=U.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=U.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const Z=zo(W,X[0],X[1]),J=Z?null:$o(f,X[0],X[1],F),ee={};return null!=k&&(ee.positiveColor=k),null!=w&&(ee.negativeColor=w),null!=A&&(ee.connectorStroke=A),null!=S&&(ee.connectorWidth=S),null!=O&&(ee.gap=O),null!=E&&(ee.stroke=E),null!=M&&(ee.strokeWidth=M),Z||J||p.createElement(gn,{ref:U,chartType:"waterfall",runtimeMode:"streaming",size:X,margin:Y,className:$?`${u||""} semiotic-emphasis-${$}`.trim():u,arrowOfTime:d,windowMode:h,windowSize:g,data:f,timeAccessor:y,valueAccessor:m,xExtent:v,yExtent:b,extentPadding:x,waterfallStyle:ee,showAxes:G,background:j,hoverAnnotation:q,tooltipContent:V,customHoverBehavior:Q,annotations:_,svgAnnotationRules:T,tickFormatTime:B,tickFormatValue:N,legendPosition:z,pointIdAccessor:t.pointIdAccessor})});xs.displayName="RealtimeWaterfallChart";const ks=e.forwardRef(function(t,n){var o,r,i,a;const s=Zn(t.mode,{width:null!==(r=null===(o=t.size)||void 0===o?void 0:o[0])&&void 0!==r?r:t.width,height:null!==(a=null===(i=t.size)||void 0===i?void 0:i[1])&&void 0!==a?a:t.height,enableHover:null!=t.enableHover?!!t.enableHover:void 0}),{size:l,margin:c,className:u,arrowOfTime:d="right",windowMode:h="sliding",windowSize:g=200,data:f,timeAccessor:y,valueAccessor:m,categoryAccessor:v,timeExtent:b,valueExtent:x,extentPadding:k,heatmapXBins:w=20,heatmapYBins:A=20,aggregation:S="count",background:O,tooltipContent:E,tooltip:M,onHover:j,annotations:C,svgAnnotationRules:P,tickFormatTime:L,tickFormatValue:_,decay:T,pulse:B,staleness:N,linkedHover:D,selection:I,onObservation:R,chartId:H,loading:W,emptyContent:F,emphasis:$,legendPosition:z}=t,G=s.showAxes,q=s.enableHover,Y=null!=c?c:s.marginDefaults,X=null!=l?l:[s.width,s.height],V=null!=E?E:M,U=e.useRef(null),{customHoverBehavior:K}=Xn({selection:I,linkedHover:D,unwrapData:!0,onObservation:R,chartType:"RealtimeHeatmap",chartId:H}),Q=e.useCallback(e=>{j&&j(e),K(e)},[j,K]);e.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=U.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=U.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;return null===(e=U.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=U.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const Z=zo(W,X[0],X[1]),J=Z?null:$o(f,X[0],X[1],F);return Z||J||p.createElement(gn,{ref:U,chartType:"heatmap",runtimeMode:"streaming",size:X,margin:Y,className:$?`${u||""} semiotic-emphasis-${$}`.trim():u,arrowOfTime:d,windowMode:h,windowSize:g,data:f,timeAccessor:y,valueAccessor:m,categoryAccessor:v,xExtent:b,yExtent:x,extentPadding:k,heatmapXBins:w,heatmapYBins:A,heatmapAggregation:S,showAxes:G,background:O,hoverAnnotation:q,tooltipContent:V,customHoverBehavior:Q,annotations:C,svgAnnotationRules:P,tickFormatTime:L,tickFormatValue:_,decay:T,pulse:B,staleness:N,legendPosition:z,pointIdAccessor:t.pointIdAccessor})});ks.displayName="RealtimeHeatmap";let[ws]=jt(e=>({tooltip:null,changeTooltip(t){e(()=>({tooltip:t}))}}));function As(e,t){return qo(this,void 0,void 0,function*(){const{format:n="png",filename:o="chart",scale:r=2,background:i="white"}=t||{},a=e.querySelector("svg");if(!a)throw Error("No SVG element found in the container");const s=a.cloneNode(!0),l=a.getBoundingClientRect();if(s.getAttribute("width")||s.setAttribute("width",l.width+""),s.getAttribute("height")||s.setAttribute("height",l.height+""),s.getAttribute("xmlns")||s.setAttribute("xmlns","http://www.w3.org/2000/svg"),Ss(a,s),"svg"===n){const e=(new XMLSerializer).serializeToString(s);Os(new Blob([e],{type:"image/svg+xml;charset=utf-8"}),o+".svg")}else{const t=l.width*r,n=l.height*r,a=document.createElement("canvas");a.width=t,a.height=n;const c=a.getContext("2d");c.fillStyle=i,c.fillRect(0,0,t,n),c.scale(r,r);const u=e.querySelector("canvas");u&&c.drawImage(u,0,0,l.width,l.height);const d=(new XMLSerializer).serializeToString(s),h=new Blob([d],{type:"image/svg+xml;charset=utf-8"}),g=URL.createObjectURL(h),f=new Image;f.width=l.width,f.height=l.height,yield new Promise((e,t)=>{f.onload=()=>{c.drawImage(f,0,0),a.toBlob(n=>{n?(Os(n,o+".png"),e()):t(Error("Failed to create PNG blob"))},"image/png"),URL.revokeObjectURL(g)},f.onerror=()=>{URL.revokeObjectURL(g),t(Error("Failed to load SVG image"))},f.src=g})}})}function Ss(e,t){var n;const o=e.children,r=t.children,i=window.getComputedStyle(e),a=["fill","stroke","stroke-width","stroke-dasharray","opacity","fill-opacity","stroke-opacity","font-family","font-size","font-weight","text-anchor","dominant-baseline"];for(const e of a){const o=i.getPropertyValue(e);o&&"none"!==o&&""!==o&&(null===(n=t.style)||void 0===n||n.setProperty(e,o))}for(let e=0;Math.min(o.length,r.length)>e;e++)Ss(o[e],r[e])}function Os(e,t){const n=URL.createObjectURL(e),o=document.createElement("a");o.href=n,o.download=t,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(n)}const Es=new Set(["tooltip","onObservation","xFormat","yFormat","valueFormat","svgAnnotationRules","tooltipContent","onHover","tickFormatTime","tickFormatValue","edgeSort","sortGroups","centerContent","frameProps","controls","oFormat","rFormat","oSort","pieceStyle","summaryStyle","nodeStyle","edgeStyle","customHoverBehavior","customClickBehavior","customDoubleClickBehavior","onBrush","onTopologyChange","backgroundGraphics","foregroundGraphics","legend"]),Ms=new Set(["data","nodes","edges"]),js="function"==typeof structuredClone?structuredClone:e=>JSON.parse(JSON.stringify(e));function Cs(e){return qo(this,arguments,void 0,function*(e,t="json"){const n="jsx"===t?Ps(e):JSON.stringify(e,null,2);if("undefined"==typeof navigator||!navigator.clipboard)throw Error("Clipboard API not available. copyConfig requires a browser environment.");yield navigator.clipboard.writeText(n)})}function Ps(e){const{component:t,props:n}=e,o=["<"+t];for(const[e,t]of Object.entries(n))if("string"==typeof t)o.push(` ${e}="${t}"`);else if("boolean"==typeof t&&!0===t)o.push(" "+e);else if("boolean"==typeof t&&!1===t)o.push(` ${e}={false}`);else if("number"==typeof t)o.push(` ${e}={${t}}`);else{const n=JSON.stringify(t);o.push(80>n.length?` ${e}={${n}}`:` ${e}={${JSON.stringify(t,null,2)}}`)}return o.push("/>"),o.join("\n")}function Ls(){const e=function(){const e=p.useContext(rt);return e?()=>e.setVisible(e=>!e):null}();return e?p.createElement("button",{className:"semiotic-chart-action",onClick:e,title:"Data summary","aria-label":"Toggle data summary",style:Ds},p.createElement("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},p.createElement("rect",{x:"1",y:"1",width:"12",height:"3",rx:"0.5"}),p.createElement("rect",{x:"1",y:"6",width:"8",height:"3",rx:"0.5"}),p.createElement("rect",{x:"1",y:"11",width:"5",height:"2",rx:"0.5"}))):null}const _s={live:{bg:"#22c55e",color:"#fff"},stale:{bg:"#ef4444",color:"#fff"},paused:{bg:"#eab308",color:"#000"},error:{bg:"#ef4444",color:"#fff"},static:{bg:"#6b7280",color:"#fff"}};function Ts({height:e}){return p.createElement("div",{role:"status","aria-busy":"true","aria-label":"Loading chart",style:{width:"100%",height:e,background:"linear-gradient(90deg, var(--semiotic-border, #e0e0e0) 25%, var(--semiotic-bg, #f5f5f5) 50%, var(--semiotic-border, #e0e0e0) 75%)",backgroundSize:"200% 100%",animation:"semiotic-skeleton-pulse 1.5s ease-in-out infinite",borderRadius:4}})}function Bs({error:e}){return p.createElement("div",{role:"alert",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",minHeight:120,padding:24,boxSizing:"border-box"}},p.createElement("div",{style:{textAlign:"center",maxWidth:400,fontSize:14,color:"var(--semiotic-text-secondary, #666)",lineHeight:1.5}},e))}const Ns=p.forwardRef(function({title:e,subtitle:t,children:n,width:o="100%",height:r=400,actions:i,chartConfig:a,controls:s,loading:l=!1,error:c,errorBoundary:u=!1,status:d,detailsPanel:h,className:g,style:f},y){const m=p.useRef(null),v=p.useRef(null),[b,x]=p.useState(!1),k=!1!==(null==i?void 0:i.export)&&void 0!==(null==i?void 0:i.export),w=!1!==(null==i?void 0:i.fullscreen)&&void 0!==(null==i?void 0:i.fullscreen),A=!1!==(null==i?void 0:i.copyConfig)&&void 0!==(null==i?void 0:i.copyConfig)&&a,S=!0===(null==i?void 0:i.dataSummary),O="object"==typeof(null==i?void 0:i.export)?i.export:{},E="object"==typeof(null==i?void 0:i.copyConfig)?i.copyConfig.format:"json",M=p.useCallback(e=>qo(this,void 0,void 0,function*(){v.current&&(yield As(v.current,Object.assign(Object.assign({},O),e)))}),[O]),j=p.useCallback(()=>{m.current&&(document.fullscreenElement?document.exitFullscreen().catch(()=>{}):m.current.requestFullscreen().catch(()=>{}))},[]),C=p.useCallback(e=>qo(this,void 0,void 0,function*(){a&&(yield Cs(a,e||E||"json"))}),[a,E]);p.useEffect(()=>{const e=()=>{x(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",e),()=>document.removeEventListener("fullscreenchange",e)},[]),p.useImperativeHandle(y,()=>({export:M,toggleFullscreen:j,copyConfig:C,element:m.current}),[M,j,C]);const P=e||t||s||k||w||A||S||d,L=l?p.createElement(Ts,{height:r}):c?p.createElement(Bs,{error:c}):u?p.createElement(ho,null,n):n;return _=p.createElement(p.Fragment,null,p.createElement("style",{dangerouslySetInnerHTML:{__html:"@keyframes semiotic-skeleton-pulse {\n 0% { background-position: 200% 0; }\n 100% { background-position: -200% 0; }\n}"}}),p.createElement("div",{ref:m,className:"semiotic-chart-container"+(g?" "+g:""),style:Object.assign(Object.assign({width:o,border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:"var(--semiotic-border-radius, 8px)",overflow:"hidden",background:"var(--semiotic-bg, #fff)",fontFamily:"var(--semiotic-font-family, sans-serif)",position:"relative"},b?{display:"flex",flexDirection:"column",width:"100%",height:"100%"}:{}),f)},P&&p.createElement("div",{className:"semiotic-chart-header",style:{padding:"12px 16px",display:"flex",justifyContent:"space-between",alignItems:"flex-start",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"}},p.createElement("div",{className:"semiotic-chart-title-area"},e&&p.createElement("div",{className:"semiotic-chart-title",style:{fontSize:14,fontWeight:600,color:"var(--semiotic-text, #333)"}},e),t&&p.createElement("div",{className:"semiotic-chart-subtitle",style:{fontSize:12,color:"var(--semiotic-text-secondary, #666)",marginTop:e?2:0}},t)),p.createElement("div",{className:"semiotic-chart-toolbar",style:{display:"flex",alignItems:"center",gap:4}},s,k&&p.createElement("button",{className:"semiotic-chart-action",onClick:()=>M(),title:"Export chart","aria-label":"Export chart",style:Ds},p.createElement("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},p.createElement("path",{d:"M7 2v8M3.5 7L7 10.5 10.5 7"}),p.createElement("path",{d:"M2 12h10"}))),S&&p.createElement(Ls,null),w&&p.createElement("button",{className:"semiotic-chart-action",onClick:j,title:b?"Exit fullscreen":"Fullscreen","aria-label":b?"Exit fullscreen":"Enter fullscreen",style:Ds},p.createElement("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},b?p.createElement(p.Fragment,null,p.createElement("path",{d:"M9 1v4h4"}),p.createElement("path",{d:"M5 13V9H1"}),p.createElement("path",{d:"M13 5H9V1"}),p.createElement("path",{d:"M1 9h4v4"})):p.createElement(p.Fragment,null,p.createElement("path",{d:"M1 5V1h4"}),p.createElement("path",{d:"M13 9v4H9"}),p.createElement("path",{d:"M9 1h4v4"}),p.createElement("path",{d:"M5 13H1V9"})))),A&&p.createElement("button",{className:"semiotic-chart-action",onClick:()=>C(),title:"Copy config","aria-label":"Copy chart configuration",style:Ds},p.createElement("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},p.createElement("rect",{x:"5",y:"5",width:"8",height:"8",rx:"1"}),p.createElement("path",{d:"M9 5V2a1 1 0 00-1-1H2a1 1 0 00-1 1v6a1 1 0 001 1h3"}))),d&&p.createElement("div",{className:"semiotic-chart-status","aria-live":"polite","aria-atomic":"true",style:{padding:"2px 8px",borderRadius:4,fontSize:10,fontWeight:700,letterSpacing:"0.05em",textTransform:"uppercase",background:_s[d].bg,color:_s[d].color,lineHeight:"18px"}},d))),p.createElement("div",{className:"semiotic-chart-body",ref:v,style:Object.assign({position:"relative",overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center"},b?{flex:1}:{height:r})},L,h))),S?p.createElement(it,null,_):_;var _}),Ds={width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",border:"none",background:"transparent",cursor:"pointer",borderRadius:4,color:"var(--semiotic-text-secondary, #666)",padding:0};function Is({children:e,columns:t="auto",minCellWidth:n=300,gap:o=16,className:r,style:i}){const a="number"==typeof t?t:void 0;return p.createElement("div",{className:"semiotic-chart-grid"+(r?" "+r:""),style:Object.assign({display:"grid",gridTemplateColumns:"auto"===t?`repeat(auto-fill, minmax(${n}px, 1fr))`:`repeat(${t}, 1fr)`,gap:o,width:"100%"},i)},p.Children.map(e,e=>p.isValidElement(e)?"primary"!==e.props.emphasis||void 0!==a&&2>a?e:p.createElement("div",{style:{gridColumn:"span 2"}},e):e))}function Rs({children:e,context:t,position:n="right",contextSize:o=250,gap:r=12,className:i,style:a}){const s="left"===n||"right"===n,l="left"===n||"top"===n,c=Object.assign({display:"flex",flexDirection:s?l?"row-reverse":"row":l?"column-reverse":"column",gap:r,width:"100%"},a),u=s?{flex:`0 0 ${o}px`,width:o,minHeight:0}:{flex:`0 0 ${o}px`,height:o,minWidth:0};return p.createElement("div",{className:"semiotic-context-layout"+(i?" "+i:""),style:c},p.createElement("div",{style:{flex:"1 1 0%",minWidth:0,minHeight:0}},e),p.createElement("div",{style:u},t))}Is.displayName="ChartGrid",Rs.displayName="ContextLayout";function Hs({children:t,position:n="right",size:o=300,trigger:r="click",chartId:i,observation:a,dismissOnEmpty:s=!0,showClose:l=!0,onToggle:c,className:u,style:d}){const[h,g]=e.useState(null),[f,y]=e.useState(null),[m,v]=e.useState(!1),[b,x]=e.useState(!1),k=e.useRef(null),w=e.useRef(),A="click"===r?["click","click-end"]:["hover","hover-end"],{latest:S}=Mn({types:A,chartId:i,limit:1}),O=void 0!==a?a:S;e.useEffect(()=>{if(O)if("click"===O.type||"hover"===O.type){const e=O;g(e.datum),y(e),m||(v(!0),x(!0),clearTimeout(w.current),w.current=setTimeout(()=>x(!1),200))}else!s||"click-end"!==O.type&&"hover-end"!==O.type||E()},[O]),e.useEffect(()=>{null==c||c(m)},[m,c]);const E=e.useCallback(()=>{x(!0),v(!1),clearTimeout(w.current),w.current=setTimeout(()=>{x(!1),g(null),y(null)},200)},[]);if(e.useEffect(()=>()=>clearTimeout(w.current),[]),!h&&!b)return null;const M=h&&f?t(h,f):null;if(null===M&&!b)return null;const j=function(e,t,n,o){const r={position:"absolute",background:"var(--semiotic-bg, #fff)",borderColor:"var(--semiotic-border, #e0e0e0)",borderStyle:"solid",borderWidth:0,boxSizing:"border-box",zIndex:10,display:"flex",flexDirection:"column",transition:o?"transform 200ms ease-out, opacity 200ms ease-out":void 0};return Object.assign(Object.assign({},r),"right"===e?{top:0,right:0,width:t,height:"100%",borderLeftWidth:1,padding:"12px 16px",transform:n?"translateX(0)":`translateX(${t}px)`,opacity:n?1:0}:"bottom"===e?{bottom:0,left:0,width:"100%",height:t,borderTopWidth:1,padding:"12px 16px",transform:n?"translateY(0)":`translateY(${t}px)`,opacity:n?1:0}:{top:"50%",left:"50%",transform:n?"translate(-50%, -50%) scale(1)":"translate(-50%, -50%) scale(0.95)",opacity:n?1:0,width:Math.min(t,400),maxHeight:"80%",borderWidth:1,borderRadius:8,padding:"16px 20px",boxShadow:"0 8px 32px rgba(0,0,0,0.12)"})}(n,o,m,b);return p.createElement("div",{ref:k,className:`semiotic-details-panel semiotic-details-${n}${u?" "+u:""}`,style:Object.assign(Object.assign({},j),d)},l&&p.createElement("button",{className:"semiotic-details-close",onClick:E,"aria-label":"Close details",style:Ws},p.createElement("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"},p.createElement("path",{d:"M2 2l8 8M10 2l-8 8"}))),p.createElement("div",{className:"semiotic-details-content",style:{overflow:"auto",flex:1}},M))}const Ws={position:"absolute",top:8,right:8,width:20,height:20,display:"flex",alignItems:"center",justifyContent:"center",border:"none",background:"transparent",cursor:"pointer",borderRadius:4,color:"var(--semiotic-text-secondary, #666)",padding:0,zIndex:1};function Fs(e){return"nominal"===e||"ordinal"===e}function $s(e){return"quantitative"===e||"temporal"===e}Hs.displayName="DetailsPanel";const zs={category10:"category10",category20:"category20",category20b:"category20",category20c:"category20",accent:"accent",dark2:"dark2",paired:"paired",pastel1:"pastel1",pastel2:"pastel2",set1:"set1",set2:"set2",set3:"set3",tableau10:"category10",tableau20:"category20"},Gs={linear:"linear","monotone-x":"monotoneX","monotone-y":"monotoneY",monotone:"monotoneX",step:"step","step-after":"stepAfter","step-before":"stepBefore",basis:"basis",cardinal:"cardinal","catmull-rom":"catmullRom"},qs={sum:"sum",mean:"mean",average:"mean",count:"count",min:"min",max:"max",median:"mean"};function Ys(e,t,n,o,r){var i,a;(null==e?void 0:e.field)&&(n.xAccessor=o?"value":e.field),(null==t?void 0:t.field)&&(n.yAccessor=r?"value":t.field),(null===(i=null==e?void 0:e.axis)||void 0===i?void 0:i.title)&&(n.xLabel=e.axis.title),(null===(a=null==t?void 0:t.axis)||void 0===a?void 0:a.title)&&(n.yLabel=t.axis.title)}function Xs(e,t,n){const o={component:e,props:t,version:"1",createdAt:(new Date).toISOString()};if(n.length>0){o.warnings=n;for(const e of n)console.warn("[semiotic/fromVegaLite] "+e)}return o}function Vs(e,t=.5){const n=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!n)return e;const o=Math.round(parseInt(n[1],16)*(1-t)),r=Math.round(parseInt(n[2],16)*(1-t)),i=Math.round(parseInt(n[3],16)*(1-t));return`#${o.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}`}function Us(e,t=.5){const n=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!n)return e;const o=Math.round(parseInt(n[1],16)+(255-parseInt(n[1],16))*t),r=Math.round(parseInt(n[2],16)+(255-parseInt(n[2],16))*t),i=Math.round(parseInt(n[3],16)+(255-parseInt(n[3],16))*t);return`#${o.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}`}const Ks="__forecastSegment";function Qs(e,t){return"function"==typeof t?t(e):!!e[t]}const Zs=Object.freeze({__proto__:null,SEGMENT_FIELD:Ks,buildAnomalyAnnotations:function(e){var t,n,o;return[{type:"anomaly-band",threshold:null!==(t=e.threshold)&&void 0!==t?t:2,showBand:!1!==e.showBand,fill:e.bandColor||"#6366f1",fillOpacity:null!==(n=e.bandOpacity)&&void 0!==n?n:.1,anomalyColor:e.anomalyColor||"#ef4444",anomalyRadius:null!==(o=e.anomalyRadius)&&void 0!==o?o:6,label:e.label}]},buildForecast:function(e,t,n,o,r){return(i=o).isTraining||i.isForecast||i.isAnomaly||i.upperBounds||i.lowerBounds?function(e,t,n,o,r){var i,a,s,l;const{isTraining:c,isForecast:u,isAnomaly:d,upperBounds:h,lowerBounds:g,color:f="#6366f1",bandOpacity:p=.15,anomalyColor:y="#ef4444",anomalyRadius:m=6,label:v}=o,b=e.map(e=>{let t="observed";return u&&Qs(e,u)?t="forecast":c&&Qs(e,c)&&(t="training"),Object.assign(Object.assign({},e),{[Ks]:t})}),x=o._groupBy,k=[];if(x){const e=new Map;for(const t of b){const n=null!==(i=t[x])&&void 0!==i?i:"__default";e.has(n)||e.set(n,[]),e.get(n).push(t)}const t=[];for(const[,n]of e)for(let e=0;n.length-1>e;e++)n[e][Ks]!==n[e+1][Ks]&&(t.push(Object.assign(Object.assign({},n[e+1]),{[Ks]:n[e][Ks]})),t.push(Object.assign(Object.assign({},n[e]),{[Ks]:n[e+1][Ks]})));k.push(...b,...t)}else for(let e=0;b.length>e;e++)k.push(b[e]),b.length-1>e&&b[e][Ks]!==b[e+1][Ks]&&(k.push(Object.assign(Object.assign({},b[e+1]),{[Ks]:b[e][Ks]})),k.push(Object.assign(Object.assign({},b[e]),{[Ks]:b[e+1][Ks]})));if(o.trainUnderline){const e=[];for(const t of k)"training"===t[Ks]&&e.push(Object.assign(Object.assign({},t),{[Ks]:"training-base"}));k.unshift(...e)}const w=[];if(h&&g){const e="string"==typeof h?h:"__envUpper",t="string"==typeof g?g:"__envLower";if("function"==typeof h||"function"==typeof g)for(const n of k)"function"==typeof h&&(n[e]=h(n)),"function"==typeof g&&(n[t]=g(n));w.push({type:"envelope",upperAccessor:e,lowerAccessor:t,fill:f,fillOpacity:p,label:v})}if(d){const e=o.anomalyStyle,t={type:"highlight",filter:e=>Qs(e,d)};e?(t.style=e,t.r=m):"function"==typeof y?(t.style=e=>{const t=y(e);return{stroke:t,strokeWidth:1.5,fill:t,fillOpacity:.7}},t.r=m):(t.color=y,t.r=m,t.style={stroke:y,strokeWidth:1.5,fill:y,fillOpacity:.7}),w.push(t)}return r&&w.push({type:"anomaly-band",threshold:null!==(a=r.threshold)&&void 0!==a?a:2,showBand:!1!==r.showBand,fill:r.bandColor||"#6366f1",fillOpacity:null!==(s=r.bandOpacity)&&void 0!==s?s:.1,anomalyColor:r.anomalyColor||"#ef4444",anomalyRadius:null!==(l=r.anomalyRadius)&&void 0!==l?l:6,label:r.label}),{processedData:k,annotations:w}}(e,0,0,o,r):function(e,t,n,o,r){var i,a,s;const{trainEnd:l,steps:c=10,confidence:u=.95,color:d="#6366f1",bandOpacity:h=.15,label:g}=o;if(null==l)return{processedData:e,annotations:[]};const f=[],p=[];for(const n of e)n[t]>l?p.push(Object.assign(Object.assign({},n),{[Ks]:"observed"})):f.push(Object.assign(Object.assign({},n),{[Ks]:"training"}));const y=f.map(e=>[e[t],e[n]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]),m=[],v=[];if(y.length>=3){const o=y.length;let r=0,i=0,a=0,s=0;for(const[e,t]of y)r+=e,i+=t,a+=e*e,s+=e*t;const l=o*a-r*r;if(Math.abs(l)>1e-12){const a=(o*s-r*i)/l,f=(i-a*r)/o,p=e=>f+a*e,b=y.map(([e,t])=>t-p(e)).reduce((e,t)=>e+t*t,0),x=Math.sqrt(b/Math.max(o-2,1)),k=y.reduce((e,t)=>e+t[0],0)/o,w=y.reduce((e,t)=>e+Math.pow(t[0]-k,2),0),A=.99>u?.95>u?.9>u?1:1.645:1.96:2.576,S=e.map(e=>e[t]).filter(e=>null!=e&&isFinite(e)),O=Math.max(...S),E=y.length>1?(y[o-1][0]-y[0][0])/(o-1):1;for(let e=1;c>=e;e++){const r=O+e*E,i=p(r),a=x*Math.sqrt(1+1/o+(w>0?Math.pow(r-k,2)/w:0))*A;v.push({[t]:r,[n]:i,[Ks]:"forecast",__forecastUpper:i+a,__forecastLower:i-a})}m.push({type:"envelope",upperAccessor:"__forecastUpper",lowerAccessor:"__forecastLower",fill:d,fillOpacity:h,label:g})}}m.push({type:"x-threshold",x:l,color:"#94a3b8",strokeWidth:1,strokeDasharray:"4,2",label:"Train / Forecast"}),r&&m.push({type:"anomaly-band",threshold:null!==(i=r.threshold)&&void 0!==i?i:2,showBand:!1!==r.showBand,fill:r.bandColor||"#6366f1",fillOpacity:null!==(a=r.bandOpacity)&&void 0!==a?a:.1,anomalyColor:r.anomalyColor||"#ef4444",anomalyRadius:null!==(s=r.anomalyRadius)&&void 0!==s?s:6,label:r.label});const b=[];if(b.push(...f),f.length>0&&p.length>0&&b.push(Object.assign(Object.assign({},f[f.length-1]),{[Ks]:"observed"})),b.push(...p),v.length>0){const e=p.length>0?p[p.length-1]:f[f.length-1];e&&b.push(Object.assign(Object.assign({},e),{[Ks]:"forecast"})),b.push(...v)}return{processedData:b,annotations:m}}(e,t,n,o,r);var i},createSegmentLineStyle:function(e,t){var n,o;const r=null!==(n=t.trainDasharray)&&void 0!==n?n:"8,4",i=null!==(o=t.forecastDasharray)&&void 0!==o?o:"4,4",a=t.color||"#6366f1",s=t.trainOpacity,l=t.forecastOpacity,c=t.trainStroke,u=t.trainLinecap,d=t.trainUnderline;return t=>{const n=e(t),o=t[Ks];if("training"===o){let e=n.stroke;return"darken"===c?e=Vs(n.stroke||"#666",.5):c&&(e=c),Object.assign(Object.assign(Object.assign(Object.assign({},n),{stroke:e,strokeDasharray:r}),u&&{strokeLinecap:u}),null!=s&&{strokeOpacity:s})}if("training-base"===o){let e=n.stroke||"#666";return"lighten"===d&&(e=Us(e,.4)),Object.assign(Object.assign({},n),{stroke:e,strokeDasharray:void 0})}return"forecast"===o?Object.assign(Object.assign(Object.assign({},n),{stroke:a,strokeDasharray:i}),null!=l&&{strokeOpacity:l}):n}},darkenColor:Vs,lightenColor:Us});exports.AreaChart=Ko,exports.BarChart=Qr,exports.BoxPlot=ri,exports.BubbleChart=or,exports.CategoryColorProvider=pn,exports.ChartContainer=Ns,exports.ChartGrid=Is,exports.ChordDiagram=cs,exports.CirclePack=gs,exports.ConnectedScatterplot=nr,exports.ContextLayout=Rs,exports.DetailsPanel=Hs,exports.DonutChart=ui,exports.DotPlot=si,exports.ForceDirectedGraph=rs,exports.FunnelChart=di,exports.GroupedBarChart=ei,exports.Heatmap=rr,exports.Histogram=ii,exports.LikertChart=vi,exports.LineChart=Uo,exports.LinkedCharts=Ln,exports.MultiAxisLineChart=vr,exports.MultiLineTooltip=function(e={}){const{fields:t=[],title:n,format:o,style:r={},className:i="",showLabels:a=!0,separator:s=": "}=e;return e=>{if(!e||"object"!=typeof e)return null;const l=[];if(n){const t=to(e,n);l.push({value:no(t,o)})}t&&Array.isArray(t)&&t.length>0?t.forEach(t=>{let n,r,i;"string"==typeof t?(n=t,r=t,i=o):(n=t.label,r=t.accessor||t.key||"",i=t.format||o);const s=no(to(e,r),i);l.push({label:a?n:void 0,value:s})}):Object.keys(e).filter(e=>!e.startsWith("_")&&"data"!==e).forEach(t=>{l.push({label:a?t:void 0,value:no(e[t],o)})});const c=Object.assign(Object.assign({},eo),r);return Array.isArray(l)&&0!==l.length?p.createElement("div",{className:("semiotic-tooltip semiotic-tooltip-multiline "+i).trim(),style:c},l.map((e,t)=>p.createElement("div",{key:t,style:{marginBottom:l.length-1>t?"4px":0}},e.label&&p.createElement("strong",null,e.label,s),e.value))):null}},exports.OrbitDiagram=ps,exports.PieChart=ci,exports.QuadrantChart=gr,exports.RealtimeHeatmap=ks,exports.RealtimeHistogram=vs,exports.RealtimeLineChart=ys,exports.RealtimeSwarmChart=bs,exports.RealtimeWaterfallChart=xs,exports.RidgelinePlot=li,exports.SankeyDiagram=us,exports.Scatterplot=er,exports.ScatterplotMatrix=hr,exports.StackedAreaChart=Zo,exports.StackedBarChart=Jr,exports.SwarmPlot=ni,exports.ThemeProvider=function({theme:e,children:t}){const n="string"==typeof e&&Dn(e)?e:void 0;return p.createElement(Tt,null,p.createElement(In.Provider,{value:n},p.createElement(Rn,{theme:e}),p.createElement(Hn,null,t)))},exports.TooltipProvider=ws,exports.TreeDiagram=ds,exports.Treemap=hs,exports.ViolinPlot=ai,exports.configToJSX=Ps,exports.copyConfig=Cs,exports.deserializeSelections=function(e){const t=new Map;for(const[n,o]of Object.entries(e)){const e=new Map;for(const t of o.clauses){const n={};for(const[e,o]of Object.entries(t.fields))n[e]="point"===o.type?{type:"point",values:new Set(o.values)}:{type:"interval",range:o.range};e.set(t.clientId,{clientId:t.clientId,type:t.type,fields:n})}t.set(n,{name:o.name,resolution:o.resolution,clauses:e})}return t},exports.diagnoseConfig=Do,exports.exportChart=As,exports.fromConfig=function(e){if(!e.component||!e.props)throw Error("Invalid chart config: missing component or props");if(!Oo[e.component])throw Error(`Unknown component "${e.component}". This config may require a newer version of semiotic.`);return{componentName:e.component,props:js(e.props)}},exports.fromURL=function(e){const t=new URLSearchParams(e.includes("?")?e.split("?")[1]:e).get("sc");if(!t)throw Error("No chart config found in URL (missing 'sc' parameter)");const n=t.replace(/-/g,"+").replace(/_/g,"/"),o=decodeURIComponent(escape(atob(n)));return JSON.parse(o)},exports.fromVegaLite=function(e){var t,n,o,r,i,a,s,l,c,u,d,h,g,f;const p=[],{type:y,markProps:m}=function(e){if("string"==typeof e)return{type:e,markProps:{}};const{type:t}=e;return{type:t,markProps:function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&0>t.indexOf(o)&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);o.length>r;r++)0>t.indexOf(o[r])&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n}(e,["type"])}}(e.mark),v=e.encoding||{},b=v.x,x=v.y,k=v.color,w=v.size,A=v.theta,S=v.opacity;let O;(null===(t=e.data)||void 0===t?void 0:t.values)?O=e.data.values:(null===(n=e.data)||void 0===n?void 0:n.url)&&p.push("data.url is not supported — only inline data.values can be translated. Provide data manually."),e.transform&&e.transform.length>0&&p.push("Vega-Lite transforms are not supported. Pre-transform your data before passing to fromVegaLite()."),e.layer&&p.push('Layered specs ("layer") are not supported. Only single-mark specs can be translated.'),(e.hconcat||e.vconcat||e.concat)&&p.push('Concatenated views ("hconcat"/"vconcat"/"concat") are not supported. Translate each sub-spec individually.'),(e.facet||e.encoding&&e.encoding.facet||e.encoding&&(e.encoding.row||e.encoding.column))&&p.push("Faceted views are not supported. Use Semiotic's LinkedCharts or render multiple charts manually."),e.repeat&&p.push('Repeated views ("repeat") are not supported. Translate each field combination individually.'),(e.params||e.selection)&&p.push("Selections/params are not supported. Use Semiotic's LinkedCharts and selection props for interactivity.");const E={};e.width&&(E.width=e.width),e.height&&(E.height=e.height);const M=function(e){if(e)return"string"==typeof e?e:e.text}(e.title);if(M&&(E.title=M),(null==k?void 0:k.field)&&(E.colorBy=k.field,null===(o=k.scale)||void 0===o?void 0:o.scheme)){const e=zs[k.scale.scheme];e&&(E.colorScheme=e)}void 0!==(null==S?void 0:S.value)&&(E.pointOpacity=S.value);const j=null==b?void 0:b.aggregate,C=null==x?void 0:x.aggregate;if(O&&(j||C)){const e=C?x:b,t=C?b:x,n=qs[e.aggregate];if(n&&(null==t?void 0:t.field)&&e.field)O=function(e,t){const{groupBy:n,value:o,agg:r="sum"}=t,i=new Map;for(const t of e){const e=t[n]+"";i.has(e)||i.set(e,[]),i.get(e).push(Number(t[o]))}const a=[];for(const[e,t]of i){let o;switch(r){case"count":o=t.length;break;case"mean":o=t.reduce((e,t)=>e+t,0)/t.length;break;case"min":o=Math.min(...t);break;case"max":o=Math.max(...t);break;default:o=t.reduce((e,t)=>e+t,0)}a.push({[n]:e,value:o})}return a}(O,{groupBy:t.field,value:e.field,agg:n});else if(("count"===n||"count"===e.aggregate)&&(null==t?void 0:t.field)&&O){const e=new Map;for(const n of O){const o=n[t.field]+"";e.set(o,(e.get(o)||0)+1)}O=Array.from(e,([e,n])=>({[t.field]:e,value:n}))}}if((null==b?void 0:b.bin)||(null==x?void 0:x.bin)){const e="Histogram";O&&(E.data=O),(null==b?void 0:b.bin)?(E.valueAccessor=b.field,(null==x?void 0:x.field)&&(E.categoryAccessor=x.field),(null===(r=b.axis)||void 0===r?void 0:r.title)&&(E.valueLabel=b.axis.title)):(null==x?void 0:x.bin)&&(E.valueAccessor=x.field,(null==b?void 0:b.field)&&(E.categoryAccessor=b.field),(null===(i=x.axis)||void 0===i?void 0:i.title)&&(E.valueLabel=x.axis.title));const t="object"==typeof((null==b?void 0:b.bin)||(null==x?void 0:x.bin))?(null===(a=null==b?void 0:b.bin)||void 0===a?void 0:a.maxbins)||(null===(s=null==x?void 0:x.bin)||void 0===s?void 0:s.maxbins):void 0;return t&&(E.bins=t),Xs(e,E,p)}let P;switch(y){case"bar":P=function(e,t,n,o,r,i,a){var s,l,c,u,d,h;let g;return(null==n?void 0:n.field)&&!1!==(null==e?void 0:e.stack)&&!1!==(null==t?void 0:t.stack)&&null!==(null==e?void 0:e.stack)&&null!==(null==t?void 0:t.stack)?(g="StackedBarChart",o.stackBy=n.field):g="BarChart",Fs(null==e?void 0:e.type)&&$s(null==t?void 0:t.type)?(o.categoryAccessor=e.field,o.valueAccessor=a?"value":t.field,(null===(s=null==e?void 0:e.axis)||void 0===s?void 0:s.title)&&(o.categoryLabel=e.axis.title),(null===(l=null==t?void 0:t.axis)||void 0===l?void 0:l.title)&&(o.valueLabel=t.axis.title)):$s(null==e?void 0:e.type)&&Fs(null==t?void 0:t.type)?(o.categoryAccessor=t.field,o.valueAccessor=i?"value":e.field,o.orientation="horizontal",(null===(c=null==t?void 0:t.axis)||void 0===c?void 0:c.title)&&(o.categoryLabel=t.axis.title),(null===(u=null==e?void 0:e.axis)||void 0===u?void 0:u.title)&&(o.valueLabel=e.axis.title)):((null==e?void 0:e.field)&&(o.categoryAccessor=e.field),(null==t?void 0:t.field)&&(o.valueAccessor=a?"value":t.field),(null===(d=null==e?void 0:e.axis)||void 0===d?void 0:d.title)&&(o.categoryLabel=e.axis.title),(null===(h=null==t?void 0:t.axis)||void 0===h?void 0:h.title)&&(o.valueLabel=t.axis.title)),r&&(o.data=r),g}(b,x,k,E,O,j,C);break;case"line":if(P="LineChart",Ys(b,x,E,j,C),(null==k?void 0:k.field)&&(E.lineBy=k.field),m.interpolate){const e=Gs[m.interpolate];e&&(E.curve=e)}!0===m.point&&(E.showPoints=!0),O&&(E.data=O);break;case"area":if((null==k?void 0:k.field)?(P="StackedAreaChart",E.areaBy=k.field):P="AreaChart",Ys(b,x,E,j,C),m.interpolate){const e=Gs[m.interpolate];e&&(E.curve=e)}void 0!==m.opacity&&(E.areaOpacity=m.opacity),O&&(E.data=O);break;case"point":case"circle":case"square":(null==w?void 0:w.field)?(P="BubbleChart",E.sizeBy=w.field,(null===(l=w.scale)||void 0===l?void 0:l.range)&&(E.sizeRange=w.scale.range)):P="Scatterplot",Ys(b,x,E,j,C),O&&(E.data=O);break;case"rect":P="Heatmap",(null==b?void 0:b.field)&&(E.xAccessor=b.field),(null==x?void 0:x.field)&&(E.yAccessor=x.field),(null==k?void 0:k.field)&&(E.valueAccessor=k.field,delete E.colorBy),(null===(c=null==b?void 0:b.axis)||void 0===c?void 0:c.title)&&(E.xLabel=b.axis.title),(null===(u=null==x?void 0:x.axis)||void 0===u?void 0:u.title)&&(E.yLabel=x.axis.title),O&&(E.data=O);break;case"arc":m.innerRadius&&m.innerRadius>0?(P="DonutChart",E.innerRadius=m.innerRadius):P="PieChart",(null==A?void 0:A.field)?E.valueAccessor=A.field:(null==x?void 0:x.field)&&(E.valueAccessor=C?"value":x.field),(null==k?void 0:k.field)&&(E.categoryAccessor=k.field),(null==b?void 0:b.field)&&!(null==A?void 0:A.field)&&(E.categoryAccessor=b.field),O&&(E.data=O);break;case"tick":P="DotPlot",Fs(null==b?void 0:b.type)?(E.categoryAccessor=b.field,(null==x?void 0:x.field)&&(E.valueAccessor=C?"value":x.field),(null===(d=null==b?void 0:b.axis)||void 0===d?void 0:d.title)&&(E.categoryLabel=b.axis.title),(null===(h=null==x?void 0:x.axis)||void 0===h?void 0:h.title)&&(E.valueLabel=x.axis.title)):Fs(null==x?void 0:x.type)?(E.categoryAccessor=x.field,(null==b?void 0:b.field)&&(E.valueAccessor=j?"value":b.field),E.orientation="horizontal",(null===(g=null==x?void 0:x.axis)||void 0===g?void 0:g.title)&&(E.categoryLabel=x.axis.title),(null===(f=null==b?void 0:b.axis)||void 0===f?void 0:f.title)&&(E.valueLabel=b.axis.title)):((null==b?void 0:b.field)&&(E.categoryAccessor=b.field),(null==x?void 0:x.field)&&(E.valueAccessor=C?"value":x.field)),O&&(E.data=O);break;default:p.push(`Unsupported mark type "${y}". Defaulting to Scatterplot.`),P="Scatterplot",Ys(b,x,E,j,C),O&&(E.data=O)}return Xs(P,E,p)},exports.serializeSelections=function(e){const t={};for(const[n,o]of e){const e=[];for(const[,t]of o.clauses){const n={};for(const[e,o]of Object.entries(t.fields))n[e]="point"===o.type?{type:"point",values:Array.from(o.values)}:{type:"interval",range:o.range};e.push({clientId:t.clientId,type:t.type,fields:n})}t[n]={name:o.name,resolution:o.resolution,clauses:e}}return t},exports.toConfig=function(e,t,n){if(!Oo[e])throw Error(`Unknown component "${e}". Known components: ${Object.keys(Oo).join(", ")}`);const o=!1!==(null==n?void 0:n.includeData),r={};for(const[e,n]of Object.entries(t))null!=n&&(Es.has(e)||!o&&Ms.has(e)||"function"!=typeof n&&((null==n?void 0:n.$$typeof)||(r[e]=js(n))));return Object.assign({component:e,props:r,version:"1",createdAt:(new Date).toISOString()},(null==n?void 0:n.selections)?{selections:n.selections}:{})},exports.toURL=function(e){const t=JSON.stringify(e);return"sc="+btoa(unescape(encodeURIComponent(t))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")},exports.useBrushSelection=En,exports.useCategoryColors=yn,exports.useChartObserver=Mn,exports.useFilteredData=function(t,n,o){const r=kn(e=>e.selections.get(n));return e.useMemo(()=>{if(!r||0===r.clauses.size)return t;const e=vn(r,o);return t.filter(e)},[t,r,o])},exports.useLinkedHover=On,exports.useSelection=Sn,exports.useTheme=Wn,exports.validateProps=Mo;
|