semiotic 3.2.3 → 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 +122 -265
- package/README.md +37 -17
- package/ai/schema.json +97 -1
- package/ai/system-prompt.md +3 -3
- 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/charts/ordinal/SwimlaneChart.d.ts +4 -0
- package/dist/components/charts/realtime/RealtimeHeatmap.d.ts +2 -0
- package/dist/components/charts/realtime/RealtimeHistogram.d.ts +2 -0
- package/dist/components/charts/realtime/RealtimeLineChart.d.ts +2 -0
- package/dist/components/charts/realtime/RealtimeSwarmChart.d.ts +2 -0
- package/dist/components/charts/realtime/RealtimeWaterfallChart.d.ts +2 -0
- package/dist/components/charts/shared/hooks.d.ts +2 -1
- package/dist/components/charts/shared/types.d.ts +6 -2
- package/dist/components/charts/shared/useChartSetup.d.ts +1 -1
- package/dist/components/realtime/RingBuffer.d.ts +11 -0
- package/dist/components/realtime/types.d.ts +46 -3
- package/dist/components/semiotic-server.d.ts +6 -1
- package/dist/components/server/animatedGif.d.ts +78 -0
- package/dist/components/server/renderToStaticSVG.d.ts +86 -5
- package/dist/components/server/serverChartConfigs.d.ts +17 -0
- package/dist/components/server/staticAnnotations.d.ts +40 -0
- package/dist/components/server/staticLegend.d.ts +39 -0
- package/dist/components/server/svgHatchPattern.d.ts +26 -0
- package/dist/components/server/themeResolver.d.ts +39 -0
- package/dist/components/store/ThemeStore.d.ts +14 -0
- package/dist/components/stream/GeoPipelineStore.d.ts +6 -1
- package/dist/components/stream/NetworkPipelineStore.d.ts +26 -0
- package/dist/components/stream/OrdinalPipelineStore.d.ts +11 -0
- package/dist/components/stream/OrdinalSVGOverlay.d.ts +5 -0
- package/dist/components/stream/PipelineStore.d.ts +11 -0
- package/dist/components/stream/accessorUtils.d.ts +3 -3
- package/dist/components/stream/geoTypes.d.ts +6 -4
- package/dist/components/stream/hoverUtils.d.ts +22 -0
- package/dist/components/stream/networkTypes.d.ts +45 -20
- package/dist/components/stream/ordinalTypes.d.ts +40 -3
- package/dist/components/stream/pipelineDecay.d.ts +6 -5
- package/dist/components/stream/renderers/resolveCSSColor.d.ts +17 -0
- package/dist/components/stream/types.d.ts +8 -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-server.d.ts +6 -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 +14 -3
package/dist/server.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const t=require("react"),e=require("d3-scale"),i=require("d3-quadtree"),n=require("d3-scale-chromatic"),r=require("d3-array"),o=require("d3-interpolate"),s=require("d3-force"),a=require("d3-chord"),c=require("d3-shape"),l=require("d3-hierarchy"),u=require("d3-geo");function h(t){if(t&&t.__esModule)return t;const e=Object.create(null);if(t)for(const i in t)if("default"!==i){const n=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,n.get?n:{enumerable:!0,get:function(){return t[i]}})}return e.default=t,Object.freeze(e)}const f=h(t);class d{constructor(t){if(this._capacity=t,this.head=0,this._size=0,1>t)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(t)}push(t){let e;return this._size===this._capacity?e=this.buffer[this.head]:this._size++,this.buffer[this.head]=t,this.head=(this.head+1)%this._capacity,e}pushMany(t){const e=[];for(const i of t){const t=this.push(i);void 0!==t&&e.push(t)}return e}get(t){if(t>=0&&this._size>t)return this.buffer[(this.head-this._size+t+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 t=0;const e=this;return{next:()=>e._size>t?{done:!1,value:e.get(t++)}:{done:!0,value:void 0}}}forEach(t){const e=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;this._size>i;i++)t(this.buffer[(e+i)%this._capacity],i)}toArray(){const t=Array(this._size),e=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;this._size>i;i++)t[i]=this.buffer[(e+i)%this._capacity];return t}resize(t){if(1>t)throw Error("RingBuffer capacity must be at least 1");const e=this.toArray(),i=[];for(;e.length>t;)i.push(e.shift());this._capacity=t,this.buffer=Array(t),this.head=0,this._size=0;for(const t of e)this.push(t);return i}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 g{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(t){Number.isNaN(t)||(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}evict(t){t!==this._min&&t!==this._max||(this._dirty=!0)}recalculate(t,e){this._min=1/0,this._max=-1/0;for(const i of t){const t=e?e(i):i;Number.isNaN(t)||(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}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 y(t,e,i,n,r){const o=new Map;for(const s of t){const t=e(s),a=i(s);if(null==t||null==a||Number.isNaN(t)||Number.isNaN(a))continue;const c=Math.floor(t/n)*n;let l=o.get(c);if(l||(l={start:c,end:c+n,total:0,categories:new Map},o.set(c,l)),l.total+=a,r){const t=r(s);l.categories.set(t,(l.categories.get(t)||0)+a)}}return o}function p(t,e){return t===e||typeof t==typeof e&&"function"==typeof t&&"function"==typeof e&&""+t==""+e}function m(t,e){if("function"==typeof t)return e=>+t(e);const i=t||e;return t=>+t[i]}function v(t,e){if("function"==typeof t)return t;const i=t||e;return t=>t[i]}function x(t,e){return"function"==typeof t?t:t?e=>e[t]+"":e?t=>t[e]+"":void 0}const b=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];function k(t,e,i){var n,r,o;if(1>=i)return 1;const s=null!==(n=t.minOpacity)&&void 0!==n?n:.1,a=i-1-e;switch(t.type){case"linear":return s+(1-a/(i-1))*(1-s);case"exponential":{const e=null!==(r=t.halfLife)&&void 0!==r?r:i/2;return s+Math.pow(.5,a/e)*(1-s)}case"step":return(null!==(o=t.stepThreshold)&&void 0!==o?o:.5*i)>a?1:s;default:return 1}}function w(t,e,i){var n;const r=null!==(n=t.duration)&&void 0!==n?n:500,o=i-e;return r>o?1-o/r:0}function _(t,e="ease-out-cubic"){return"linear"===e?t:1-Math.pow(1-t,3)}function A(t,e){return Math.min((t-e.startTime)/e.duration,1)}function P(t,e,i){return t+(e-t)*i}function S(){return"undefined"!=typeof performance?performance.now():Date.now()}function M(t,e,i){var n,r,o,s;switch(e.type){case"point":if(e.pointId)return"p:"+e.pointId;if("streaming"===t.runtimeMode&&e.datum){const i=t.getX(e.datum),n=t.getY(e.datum);if(t.getCategory)return`p:${t.getCategory(e.datum)}:${i}:${n}`;if(null!=i&&null!=n)return`p:${i}:${n}`}return"p:"+i;case"rect":return`r:${e.group||""}:${null!==(s=null!==(r=null===(n=e.datum)||void 0===n?void 0:n.binStart)&&void 0!==r?r:null===(o=e.datum)||void 0===o?void 0:o.category)&&void 0!==s?s:i}`;case"heatcell":return`h:${e.x}_${e.y}`;case"candlestick":return null==e.datum?"c:"+i:"c:"+t.getX(e.datum);case"line":return"l:"+(e.group||"_default");case"area":return"a:"+(e.group||"_default");default:return null}}function E(t,e,i,n,r,o){const s=[];for(const r of t){const t=i(r),o=n(r);null==t||null==o||Number.isNaN(t)||Number.isNaN(o)||s.push({px:e.x(t),py:e.y(o),rawY:o,d:r})}s.sort((t,e)=>t.px-e.px);const a=Array(s.length),c=Array(s.length),l=Array(s.length);for(let t=0;s.length>t;t++){const e=s[t];a[t]=[e.px,e.py],c[t]=e.rawY,l[t]=e.d}return{type:"line",path:a,rawValues:c,style:r,datum:l,group:o}}function L(t,e,i,n,r,o,s,a){const c=[];for(const o of t){const t=i(o),s=n(o);if(null==t||null==s||Number.isNaN(t)||Number.isNaN(s))continue;const l=e.x(t),u=a?a(o):r;c.push({px:l,topY:e.y(s),botY:e.y(u)})}c.sort((t,e)=>t.px-e.px);const l=Array(c.length),u=Array(c.length);for(let t=0;c.length>t;t++){const e=c[t];l[t]=[e.px,e.topY],u[t]=[e.px,e.botY]}return{type:"area",topPath:l,bottomPath:u,style:o,datum:t,group:s}}function D(t,e,i,n,r,o,s){const a=i(t),c=n(t);if(null==a||null==c||Number.isNaN(a)||Number.isNaN(c))return null;const l={type:"point",x:e.x(a),y:e.y(c),r:r,style:o,datum:t};return void 0!==s&&(l.pointId=s),l}function O(t,e,i,n,r,o,s){return{type:"rect",x:t,y:e,w:i,h:n,style:r,datum:o,group:s}}function N(t,e,i,n,r,o,s){const a={type:"heatcell",x:t,y:e,w:i,h:n,fill:r,datum:o};return(null==s?void 0:s.showValues)&&(a.showValues=!0,a.value=s.value,s.valueFormat&&(a.valueFormat=s.valueFormat)),a}function T(t,e,i){if(!t.getBounds||!t.scales)return null;const n=[],r=[];for(const i of e){const e=t.getX(i),o=t.getY(i);if(null==e||null==o||Number.isNaN(e)||Number.isNaN(o))continue;const s=t.getBounds(i),a=t.scales.x(e);if(s&&0!==s)n.push([a,t.scales.y(o+s)]),r.push([a,t.scales.y(o-s)]);else{const e=t.scales.y(o);n.push([a,e]),r.push([a,e])}}return 2>n.length?null:{type:"area",topPath:n,bottomPath:r,style:t.resolveBoundsStyle(i,e[0]),datum:e,group:i,interactive:!1}}function $(t,e,i,n){var r;if(!t.config.pointStyle)return;const o=null!=n?n:t.getY;for(const n of e){const e=t.resolveGroupColor(n.key);for(const s of n.data){let n=t.config.pointStyle(s);!n.fill&&e&&(n=Object.assign(Object.assign({},n),{fill:e}));const a=null!==(r=n.r)&&void 0!==r?r:3,c=t.getPointId?t.getPointId(s)+"":void 0,l=D(s,t.scales,t.getX,o,a,n,c);l&&i.push(l)}}}const W={blues:n.interpolateBlues,reds:n.interpolateReds,greens:n.interpolateGreens,viridis:n.interpolateViridis},j=new Map;class C{constructor(t){if(this.xExtent=new g,this.yExtent=new g,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=t,this.buffer=new d(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=m(t.timeAccessor||t.xAccessor,"time"),this.getY=m(t.valueAccessor||t.yAccessor,"value")):(this.getX=m(t.xAccessor,"x"),this.getY=m(t.yAccessor,"y")),this.getGroup=x(t.groupAccessor),this.getCategory=x(t.categoryAccessor),this.getSize=t.sizeAccessor?m(t.sizeAccessor,"size"):void 0,this.getColor=x(t.colorAccessor),this.getBounds=t.boundsAccessor?m(t.boundsAccessor,"bounds"):void 0,this.getY0=t.y0Accessor?m(t.y0Accessor,"y0"):void 0,this.getPointId=x(t.pointIdAccessor),"candlestick"===t.chartType){const e=null!=t.openAccessor,i=null!=t.closeAccessor;this.getOpen=e?m(t.openAccessor,"open"):void 0,this.getHigh=m(t.highAccessor,"high"),this.getLow=m(t.lowAccessor,"low"),this.getClose=i?m(t.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!i}t.pulse&&(this.timestampBuffer=new d(t.windowSize))}ingest(t){const e="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=e,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,t.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?m(this.config.timeAccessor||this.config.xAccessor,"time"):m(this.config.xAccessor,"x"),this.xIsDate=!1,t.inserts.length>0){const e=t.inserts[0],i=this.config.xAccessor,n="function"==typeof i?i(e):e[i||"x"],r=n instanceof Date,o="string"==typeof n&&n.length>=10&&!isNaN(new Date(n).getTime())&&isNaN(Number(n));if(this.xIsDate=r||o,o){const t="string"==typeof i?i:void 0;this.getX=t?e=>+new Date(e[t]):t=>+(i(t)instanceof Date?i(t):new Date(i(t)))}}const i=t.totalSize||t.inserts.length;i>this.buffer.capacity&&(this.buffer.resize(i),this.timestampBuffer&&i>this.timestampBuffer.capacity&&this.timestampBuffer.resize(i));for(const i of t.inserts)this.buffer.push(i),this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(i)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(i)),this.yExtent.push(this.getLow(i))):(this.yExtent.push(this.getY(i)),this.getY0&&this.yExtent.push(this.getY0(i)))}else for(const i of t.inserts){if("growing"===this.config.windowMode&&this.buffer.full){const t=this.config.maxCapacity||1e6;t>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,t),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap))}const t=this.buffer.push(i);this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(i)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(i)),this.yExtent.push(this.getLow(i))):(this.yExtent.push(this.getY(i)),this.getY0&&this.yExtent.push(this.getY0(i))),null!=t&&(this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):this.yExtent.evict(this.getY(t)))}return!0}computeScene(t){var i,n,r,o,s,a,c;const{config:l,buffer:u}=this;if(!this.needsFullRebuild&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(null!==(i=this.config.scalePadding)&&void 0!==i?i:0)&&(this.lastLayout.width!==t.width||this.lastLayout.height!==t.height))return void this.remapScene(t);if(this.xExtent.dirty&&this.xExtent.recalculate(u,this.getX),this.yExtent.dirty)if("candlestick"===l.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const t of u)this.yExtent.push(this.getHigh(t)),this.yExtent.push(this.getLow(t))}else this.yExtent.recalculate(u,this.getY);const h=this.getBufferArray(),f=this.xExtent.extent,d=this.yExtent.extent;let g=l.xExtent?[null!==(n=l.xExtent[0])&&void 0!==n?n:f[0],null!==(r=l.xExtent[1])&&void 0!==r?r:f[1]]:f,p=l.yExtent?[null!==(o=l.yExtent[0])&&void 0!==o?o:d[0],null!==(s=l.yExtent[1])&&void 0!==s?s:d[1]]:d;const m=l.yExtent&&null!=l.yExtent[0]&&null!=l.yExtent[1];if("stackedarea"===l.chartType&&!m&&u.size>0)if(l.normalize)p=[0,1+l.extentPadding];else{const t=`${u.size}:${this._ingestVersion}`;if(this._stackExtentCache&&this._stackExtentCache.key===t)p=this._stackExtentCache.yDomain;else{const e=this.groupData(h),i=new Map;for(const t of e)for(const e of t.data){const t=this.getX(e),n=this.getY(e);null==t||null==n||Number.isNaN(t)||Number.isNaN(n)||i.set(t,(i.get(t)||0)+n)}let n=0;for(const t of i.values())t>n&&(n=t);p=[0,n+(n>0?n*l.extentPadding:1)],this._stackExtentCache={key:t,yDomain:p}}}else if("bar"===l.chartType&&l.binSize&&!m&&u.size>0){const[,t]=function(t,e,i,n,r){const o=y(t,e,i,n,r);if(0===o.size)return[0,0];let s=0;for(const t of o.values())t.total>s&&(s=t.total);return[0,s]}(u,this.getX,this.getY,l.binSize,this.getCategory);p=[0,t+t*l.extentPadding]}else if("waterfall"===l.chartType&&!m&&u.size>0){const[t,e]=function(t,e){let i=0,n=0,r=0;for(const o of t){const t=e(o);null==t||Number.isNaN(t)||(r+=t,i>r&&(i=r),r>n&&(n=r))}return[i,n]}(u,this.getY),i=e-t,n=i>0?i*l.extentPadding:1;p=[Math.min(0,t-Math.abs(n)),Math.max(0,e+Math.abs(n))]}else if(!m&&p[0]!==1/0){if(this.getBounds)for(const t of h){const e=this.getY(t),i=this.getBounds(t);null!=e&&!Number.isNaN(e)&&i&&(e+i>p[1]&&(p[1]=e+i),p[0]>e-i&&(p[0]=e-i))}const t=p[1]-p[0],e=t>0?t*l.extentPadding:1,i=null===(a=l.yExtent)||void 0===a?void 0:a[0],n=null===(c=l.yExtent)||void 0===c?void 0:c[1];p=[null!=i?p[0]:p[0]-e,null!=n?p[1]:p[1]+e],"log"===l.yScaleType&&0>=p[0]&&d[0]>0&&(p[0]=null!=i?p[0]:d[0]/(1+l.extentPadding))}if(g[0]===1/0||g[1]===-1/0)if("time"===l.xScaleType){const t=Date.now();g=[t-864e5,t]}else g=[0,1];p[0]!==1/0&&p[1]!==-1/0||(p=[0,1]);const v="streaming"===l.runtimeMode,x=Math.max(0,Math.min(l.scalePadding||0,Math.min(t.width,t.height)/2-1));if(v)if("x"==("up"===(b=l.arrowOfTime)||"down"===b?"y":"x")){const i="right"===l.arrowOfTime?[x,t.width-x]:[t.width-x,x];this.scales={x:e.scaleLinear().domain(g).range(i),y:e.scaleLinear().domain(p).range([t.height-x,x])}}else{const i="down"===l.arrowOfTime?[x,t.height-x]:[t.height-x,x];this.scales={x:e.scaleLinear().domain(p).range([x,t.width-x]),y:e.scaleLinear().domain(g).range(i)}}else{const i=(t,i,n)=>{if("log"===t){const t=[Math.max(i[0],1e-6),Math.max(i[1],1e-6)];return e.scaleLog().domain(t).range(n).clamp(!0)}return"time"===t?e.scaleTime().domain([new Date(i[0]),new Date(i[1])]).range(n):e.scaleLinear().domain(i).range(n)};this.scales={x:i(l.xScaleType,g,[x,t.width-x]),y:i(l.yScaleType,p,[t.height-x,x])}}var b;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(t,h),this.config.decay&&this.applyDecay(this.scene,h),this.config.pulse&&this.applyPulse(this.scene,h),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.rebuildQuadtree(),this.needsFullRebuild=!1,this.lastLayout={width:t.width,height:t.height},this.version++}rebuildQuadtree(){const t=this.config.chartType;if("scatter"!==t&&"bubble"!==t)return void(this._quadtree=null);const e=this.scene.filter(t=>"point"===t.type);this._quadtree=e.length>C.QUADTREE_THRESHOLD?i.quadtree().x(t=>t.x).y(t=>t.y).addAll(e):null}get quadtree(){return this._quadtree}remapScene(t){const i=t.width/this.lastLayout.width,n=t.height/this.lastLayout.height;for(const t of this.scene)switch(t.type){case"line":for(const e of t.path)e[0]*=i,e[1]*=n;break;case"area":for(const e of t.topPath)e[0]*=i,e[1]*=n;for(const e of t.bottomPath)e[0]*=i,e[1]*=n;break;case"point":t.x*=i,t.y*=n;break;case"rect":case"heatcell":t.x*=i,t.y*=n,t.w*=i,t.h*=n;break;case"candlestick":t.x*=i,t.openY*=n,t.closeY*=n,t.highY*=n,t.lowY*=n}const r=this.scales.x.domain(),o=this.scales.y.domain(),s=this.scales.x.range(),a=this.scales.y.range(),c=(t,i,n)=>{if("log"===t){const t=[Math.max(i[0],1e-6),Math.max(i[1],1e-6)];return e.scaleLog().domain(t).range(n).clamp(!0)}return"time"===t?e.scaleTime().domain([new Date(i[0]),new Date(i[1])]).range(n):e.scaleLinear().domain(i).range(n)},l=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(t.width,t.height)/2-1)),u=a[1]>a[0];this.scales={x:c(this.config.xScaleType,r,s[0]>s[1]?[t.width-l,l]:[l,t.width-l]),y:c(this.config.yScaleType,o,u?[l,t.height-l]:[t.height-l,l])},this.lastLayout={width:t.width,height:t.height},this.rebuildQuadtree(),this.version++}buildSceneNodes(t,e){var i;const{config:r,scales:o}=this;if(!o||0===e.length)return[];const s={scales:o,config:r,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:(t,e)=>this.resolveLineStyle(t,e),resolveAreaStyle:(t,e)=>this.resolveAreaStyle(t,e),resolveBoundsStyle:(t,e)=>this.resolveBoundsStyle(t,e),resolveColorMap:t=>this.resolveColorMap(t),resolveGroupColor:t=>this.resolveGroupColor(t),groupData:t=>this.groupData(t),barCategoryCache:this._barCategoryCache};switch(r.chartType){case"line":return function(t,e){var i;const n=t.groupData(e),r=[],o=null===(i=t.config.annotations)||void 0===i?void 0:i.filter(t=>"threshold"===t.type&&t.color).map(t=>({value:t.value,color:t.color,thresholdType:t.thresholdType||"greater"}));if(t.getBounds)for(const e of n){const i=T(t,e.data,e.key);i&&r.push(i)}for(const e of n){const i=t.resolveLineStyle(e.key,e.data[0]),n=E(e.data,t.scales,t.getX,t.getY,i,e.key);o&&o.length>0&&(n.colorThresholds=o),t.config.curve&&"linear"!==t.config.curve&&(n.curve=t.config.curve),t.config.lineGradient&&(n.strokeGradient=t.config.lineGradient),r.push(n)}return $(t,n,r),r}(s,e);case"area":return function(t,e){const i=t.groupData(e),n=[],r=t.scales.y.domain()[0],o=t.getY0?e=>{const i=t.getY0(e);return null==i?r:i}:void 0;for(const e of i){const i=t.resolveAreaStyle(e.key,e.data[0]),s=L(e.data,t.scales,t.getX,t.getY,r,i,e.key,o);t.config.gradientFill&&(s.fillGradient=t.config.gradientFill),t.config.curve&&"linear"!==t.config.curve&&(s.curve=t.config.curve),t.config.lineGradient&&(s.strokeGradient=t.config.lineGradient),n.push(s)}return $(t,i,n),n}(s,e);case"mixed":return function(t,e){const i=t.groupData(e),n=[],r=t.config.areaGroups||new Set,o=t.scales.y.domain()[0],s=t.getY0?e=>{const i=t.getY0(e);return null==i?o:i}:void 0;for(const e of i)if(r.has(e.key)){const i=t.resolveAreaStyle(e.key,e.data[0]),r=L(e.data,t.scales,t.getX,t.getY,o,i,e.key,s);t.config.gradientFill&&(r.fillGradient=t.config.gradientFill),t.config.curve&&"linear"!==t.config.curve&&(r.curve=t.config.curve),t.config.lineGradient&&(r.strokeGradient=t.config.lineGradient),n.push(r)}else{const i=t.resolveLineStyle(e.key,e.data[0]),r=E(e.data,t.scales,t.getX,t.getY,i,e.key);t.config.curve&&"linear"!==t.config.curve&&(r.curve=t.config.curve),t.config.lineGradient&&(r.strokeGradient=t.config.lineGradient),n.push(r)}return $(t,i,n),n}(s,e);case"stackedarea":return function(t,e){const i=t.groupData(e);i.sort((t,e)=>e.key>t.key?-1:t.key>e.key?1:0);const n=t.config.curve&&"linear"!==t.config.curve?t.config.curve:void 0,{nodes:r,stackedTops:o}=function(t,e,i,n,r,o,s){var a;const c=new Set;for(const e of t)for(const t of e.data){const e=i(t);null==e||Number.isNaN(e)||c.add(e)}const l=Array.from(c).sort((t,e)=>t-e),u=new Map;for(const e of t){const t=new Map;for(const r of e.data){const e=i(r),o=n(r);null==e||null==o||Number.isNaN(e)||Number.isNaN(o)||t.set(e,(t.get(e)||0)+o)}u.set(e.key,t)}let h;if(o){h=new Map;for(const e of l){let i=0;for(const n of t)i+=(null===(a=u.get(n.key))||void 0===a?void 0:a.get(e))||0;h.set(e,i||1)}}const f=[],d=new Map,g=new Map;for(const t of l)g.set(t,0);for(const i of t){const t=u.get(i.key),n=[],a=[],c=new Map;for(const i of l){let r=t.get(i)||0;const s=g.get(i);o&&(r/=h.get(i));const l=s+r,u=e.x(i);a.push([u,e.y(s)]),n.push([u,e.y(l)]),g.set(i,l),c.set(i,l)}d.set(i.key,c);const y={type:"area",topPath:n,bottomPath:a,style:r(i.key,i.data[0]),datum:i.data,group:i.key};s&&(y.curve=s),f.push(y)}return{nodes:f,stackedTops:d}}(i,t.scales,t.getX,t.getY,(e,i)=>t.resolveAreaStyle(e,i),t.config.normalize,n),s=r;if(t.config.pointStyle){const e=new WeakMap;for(const n of i){const i=o.get(n.key);if(i)for(const r of n.data){const n=t.getX(r),o=t.getY(r);null==n||Number.isNaN(n)||null==o||Number.isNaN(o)||!i.has(n)||e.set(r,i.get(n))}}const n=i=>{var n;return null!==(n=e.get(i))&&void 0!==n?n:t.getY(i)};$(t,i,s,n)}return s}(s,e);case"scatter":case"bubble":return function(t,e){const i=[],n="bubble"===t.config.chartType?10:5,r=t.config.sizeRange||[3,15];let o=null;if(t.getSize&&!t.config.pointStyle){const i=e.map(e=>t.getSize(e)).filter(t=>null!=t&&!Number.isNaN(t));if(i.length>0){let t=1/0,e=-1/0;for(const n of i)t>n&&(t=n),n>e&&(e=n);o=i=>t===e?(r[0]+r[1])/2:r[0]+(i-t)/(e-t)*(r[1]-r[0])}}const s=t.getColor?t.resolveColorMap(e):null;for(const r of e){let e=t.config.pointStyle?t.config.pointStyle(r):{fill:"#4e79a7",opacity:.8},a=e.r||n;if(o&&t.getSize){const e=t.getSize(r);null==e||Number.isNaN(e)||(a=o(e))}if(s&&t.getColor&&!e.fill){const i=t.getColor(r);i&&s.has(i)&&(e=Object.assign(Object.assign({},e),{fill:s.get(i)}))}const c=t.getPointId?t.getPointId(r)+"":void 0,l=D(r,t.scales,t.getX,t.getY,a,e,c);l&&i.push(l)}return i}(s,e);case"heatmap":return function(t,e,i){if(t.config.heatmapAggregation)return function(t,e,i){var n,r,o;const s=Math.max(1,Math.floor(null!==(n=t.config.heatmapXBins)&&void 0!==n?n:20)),a=Math.max(1,Math.floor(null!==(r=t.config.heatmapYBins)&&void 0!==r?r:20)),c=null!==(o=t.config.heatmapAggregation)&&void 0!==o?o:"count",l=m(t.config.valueAccessor,"value");if(!t.scales||0===e.length)return[];const[u,h]=t.scales.x.domain(),[f,d]=t.scales.y.domain(),g=(h-u||1)/s,y=(d-f||1)/a,p=s*a;if(p>1e6)return[];const v=new Int32Array(p),x=new Float64Array(p);for(let i=0;e.length>i;i++){const n=e[i],r=t.getX(n),o=t.getY(n);if(!isFinite(r)||!isFinite(o))continue;const c=Math.min(Math.floor((r-u)/g),s-1),h=Math.min(Math.floor((o-f)/y),a-1);if(0>c||0>h)continue;const d=h*s+c;v[d]++;const p=l(n);x[d]+=isFinite(p)?p:0}let b=1/0,k=-1/0;for(let t=0;p>t;t++){if(0===v[t])continue;let e;switch(c){case"sum":e=x[t];break;case"mean":e=x[t]/v[t];break;default:e=v[t]}b>e&&(b=e),e>k&&(k=e)}if(!isFinite(b))return[];const w=k-b||1,_=i.width/s,A=i.height/a,P=t.config.showValues,S=t.config.heatmapValueFormat,M=[];for(let t=0;a>t;t++){const e=t*s;for(let i=0;s>i;i++){const n=e+i;if(0===v[n])continue;let r;switch(c){case"sum":r=x[n];break;case"mean":r=x[n]/v[n];break;default:r=v[n]}const o=(r-b)/w;M.push(N(i*_,(a-1-t)*A,_,A,`rgb(${220-(180*o+.5)|0},${220-(100*o+.5)|0},${255-(50*o+.5)|0})`,{xi:i,yi:t,value:r,count:v[n],sum:x[n]},P?{value:r,showValues:!0,valueFormat:S}:void 0))}}return M}(t,e,i);if(0===e.length)return[];const r=m(t.config.valueAccessor,"value"),o=v(t.config.xAccessor,"x"),s=v(t.config.yAccessor,"y"),a=new Map,c=new Map,l=Array(e.length),u=Array(e.length);for(let t=0;e.length>t;t++){const i=e[t],n=o(i),r=s(i);l[t]=n,u[t]=r,a.has(n)||a.set(n,a.size),c.has(r)||c.set(r,c.size)}const h=a.size,f=c.size;if(0===h||0===f)return[];const d=Array.from(a.keys()),g=Array.from(c.keys()),y=d.every(t=>"number"==typeof t&&!isNaN(t)),p=g.every(t=>"number"==typeof t&&!isNaN(t));if(y){d.sort((t,e)=>t-e),a.clear();for(let t=0;d.length>t;t++)a.set(d[t],t)}if(p){g.sort((t,e)=>t-e),c.clear();for(let t=0;g.length>t;t++)c.set(g[t],t)}const x=new Float64Array(e.length),b=new Float64Array(e.length),k=Array(e.length),w=new Map;let _=0;for(let t=0;e.length>t;t++){const i=e[t],n=a.get(l[t]),o=c.get(u[t]);if(void 0===n||void 0===o)continue;const s=r(i),f=o*h+n,d=w.get(f);let g;void 0!==d?g=d:(g=_++,w.set(f,g)),x[g]=f,b[g]=s,k[g]=i}let A=1/0,P=-1/0;for(let t=0;_>t;t++){const e=b[t];isFinite(e)&&(A>e&&(A=e),e>P&&(P=e))}if(!isFinite(A)||!isFinite(P))return[];const S=function(t){const e=t in W?t:"blues";let i=j.get(e);if(i)return i;i=Array(256);const r=W[e]||n.interpolateBlues;for(let t=0;256>t;t++)i[t]=r(t/255);return j.set(e,i),i}("string"==typeof t.config.colorScheme?t.config.colorScheme:"blues"),M=255/(P-A||1),E=i.width/h,L=i.height/f,D=t.config.showValues,O=t.config.heatmapValueFormat,T=[];for(let t=0;_>t;t++){const e=b[t];if(!isFinite(e))continue;const i=x[t],n=i%h;T.push(N(n*E,(f-1-(i-n)/h)*L,E,L,S[Math.min((e-A)*M+.5|0,255)],k[t],D?{value:e,showValues:!0,valueFormat:O}:void 0))}return T}(s,e,t);case"bar":{const t=function(t,e){var i;if(!t.config.binSize)return{nodes:[],binBoundaries:[]};const n=y(e,t.getX,t.getY,t.config.binSize,t.getCategory);if(0===n.size)return{nodes:[],binBoundaries:[]};let r=null;if(t.getCategory){const e=new Set;for(const t of n.values())for(const i of t.categories.keys())e.add(i);const i=t.config.barColors?Object.keys(t.config.barColors):[],o=new Set(i),s=Array.from(e).filter(t=>!o.has(t)).sort(),a=i.filter(t=>e.has(t)),c=a.join("\0")+""+s.join("\0");t.barCategoryCache&&t.barCategoryCache.key===c?r=t.barCategoryCache.order:(r=[...a,...s],t.barCategoryCache={key:c,order:r})}const o=[],s=t.scales,[a,c]=s.x.domain();for(const e of n.values()){const n=Math.max(e.start,a),l=Math.min(e.end,c);if(n>=l)continue;const u=s.x(n),h=s.x(l),f=Math.abs(h-u),d=f>2?1:0,g=Math.min(u,h)+d/2,y=Math.max(f-d,1);if(y>0)if(r&&e.categories.size>0){let n=0;for(const a of r){const r=e.categories.get(a)||0;if(0===r)continue;const c=s.y(n),l=s.y(n+r);o.push(O(g,Math.min(c,l),y,Math.abs(c-l),{fill:(null===(i=t.config.barColors)||void 0===i?void 0:i[a])||"#4e79a7"},{binStart:e.start,binEnd:e.end,total:e.total,category:a,categoryValue:r},a)),n+=r}}else{const t=s.y(0),i=s.y(e.total);o.push(O(g,Math.min(t,i),y,Math.abs(t-i),{fill:"#007bff"},{binStart:e.start,binEnd:e.end,total:e.total}))}}const l=new Set;for(const t of n.values())l.add(t.start),l.add(t.end);return{nodes:o,binBoundaries:Array.from(l).sort((t,e)=>t-e)}}(s,e);return this._barCategoryCache=null!==(i=s.barCategoryCache)&&void 0!==i?i:null,this._binBoundaries=t.binBoundaries,t.nodes}case"swarm":return function(t,e){var i,n,r,o;const s=[],a=t.config.swarmStyle||{},c=null!==(i=a.radius)&&void 0!==i?i:3,l=null!==(n=a.fill)&&void 0!==n?n:"#007bff",u=null!==(r=a.opacity)&&void 0!==r?r:.7,h=a.stroke,f=a.strokeWidth;for(const i of e){const e=t.getX(i),n=t.getY(i);if(null==n||Number.isNaN(n))continue;const r=t.scales.x(e),a=t.scales.y(n);let d=l;if(t.getCategory){const e=t.getCategory(i);d=(null===(o=t.config.barColors)||void 0===o?void 0:o[e])||d}const g={type:"point",x:r,y:a,r:c,style:{fill:d,opacity:u,stroke:h,strokeWidth:f},datum:i};t.getPointId&&(g.pointId=t.getPointId(i)+""),s.push(g)}return s}(s,e);case"waterfall":return function(t,e,i){var n,r,o;const s=[],a=t.scales,c=t.config.waterfallStyle,l=e.filter(e=>{const i=t.getY(e),n=t.getX(e);return null!=i&&!Number.isNaN(i)&&null!=n&&isFinite(n)});if(0===l.length)return s;const u=null!==(n=null==c?void 0:c.positiveColor)&&void 0!==n?n:"#28a745",h=null!==(r=null==c?void 0:c.negativeColor)&&void 0!==r?r:"#dc3545",f=null!==(o=null==c?void 0:c.gap)&&void 0!==o?o:1,d=null==c?void 0:c.stroke,g=null==c?void 0:c.strokeWidth;let y=0;for(let e=0;l.length>e;e++){const n=l[e],r=t.getX(n),o=t.getY(n),p=y+o;let m;m=l.length-1>e?t.getX(l[e+1])-r:e>0?r-t.getX(l[e-1]):0;const v=a.x(r),x=0!==m?a.x(r+m):v+i.width/10,b=Math.min(v,x)+f/2,k=Math.max(v,x)-f/2-b;if(0>=k){y=p;continue}const w=a.y(y),_=a.y(p);s.push(O(b,Math.min(w,_),k,Math.abs(w-_),{fill:0>o?h:u,stroke:d,strokeWidth:g},Object.assign(Object.assign({},n),{baseline:y,cumEnd:p,delta:o,_connectorStroke:null==c?void 0:c.connectorStroke,_connectorWidth:null==c?void 0:c.connectorWidth}))),y=p}return s}(s,e,t);case"candlestick":return function(t,e){var i,n;if(!t.getHigh||!t.getLow||!t.scales)return[];const r=null!==(i=t.config.candlestickRangeMode)&&void 0!==i&&i;if(!(r||t.getOpen&&t.getClose))return[];const o=[],s=t.config.candlestickStyle||{},a=s.rangeColor||"#6366f1",c=r?a:s.upColor||"#28a745",l=r?a:s.downColor||"#dc3545",u=r?a:s.wickColor||"#333",h=s.wickWidth||(r?2:1),f=e.map(e=>t.getX(e)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let d=r?0:null!==(n=s.bodyWidth)&&void 0!==n?n:0;if(!r&&null==s.bodyWidth&&f.length>1){let e=1/0;for(let i=1;f.length>i;i++){const n=Math.abs(t.scales.x(f[i])-t.scales.x(f[i-1]));n>0&&e>n&&(e=n)}d=e!==1/0?Math.max(2,Math.min(.6*e,20)):6}else r||null!=s.bodyWidth||(d=6);for(const i of e){const e=t.getX(i);if(null==e||Number.isNaN(e))continue;const n=t.getHigh(i),s=t.getLow(i);if(null==n||Number.isNaN(n)||null==s||Number.isNaN(s))continue;const a=r?n:t.getOpen(i),f=r?s:t.getClose(i);if(!r&&[a,f].some(t=>null==t||Number.isNaN(t)))continue;const g=f>=a,y={type:"candlestick",x:t.scales.x(e),openY:t.scales.y(a),closeY:t.scales.y(f),highY:t.scales.y(n),lowY:t.scales.y(s),bodyWidth:d,upColor:c,downColor:l,wickColor:u,wickWidth:h,isUp:g,datum:i};r&&(y.isRange=!0),o.push(y)}return o}(s,e);default:return[]}}resolveBoundsStyle(t,e){const i=this.config.boundsStyle;return"function"==typeof i?i(e||{},t):i&&"object"==typeof i?i:{fill:this.resolveLineStyle(t,e).stroke||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(t,e){const i=this.config.decay;return i&&e>1?k(i,t,e):1}applyDecay(t,e){this.config.decay&&function(t,e,i){var n,r;const o=i.length;if(1>=o)return;const s=new Map;for(let t=0;i.length>t;t++)s.set(i[t],t);for(const i of e){if("line"===i.type){const e=Array.isArray(i.datum)?i.datum:[];if(2>e.length)continue;const n=Array(e.length);let r=!1;for(let i=0;e.length>i;i++){const a=s.get(e[i]);null!=a?(n[i]=k(t,a,o),1>n[i]&&(r=!0)):n[i]=1}r&&(i._decayOpacities=n);continue}if("area"===i.type){const e=Array.isArray(i.datum)?i.datum:[],n=i.topPath?i.topPath.length:e.length;if(2>n)continue;if(e.length===n){const r=Array(n);let a=!1;for(let i=0;e.length>i;i++){const n=s.get(e[i]);null!=n?(r[i]=k(t,n,o),1>r[i]&&(a=!0)):r[i]=1}a&&(i._decayOpacities=r)}else{let r=1;for(const i of e){const e=s.get(i);if(null!=e){const i=k(t,e,o);r>i&&(r=i)}}if(1>r){const t=Array(n);t.fill(r),i._decayOpacities=t}}continue}const e=s.get(i.datum);if(null==e)continue;const a=k(t,e,o);if("heatcell"===i.type)i.style={opacity:a};else if("candlestick"===i.type)i._decayOpacity=a;else{const t=null!==(r=null===(n=i.style)||void 0===n?void 0:n.opacity)&&void 0!==r?r:1;i.style=Object.assign(Object.assign({},i.style),{opacity:t*a})}}}(this.config.decay,t,e)}applyPulse(t,e){this.config.pulse&&this.timestampBuffer&&function(t,e,i,n){var r,o;const s="undefined"!=typeof performance?performance.now():Date.now(),a=null!==(r=t.color)&&void 0!==r?r:"rgba(255,255,255,0.6)",c=null!==(o=t.glowRadius)&&void 0!==o?o:4,l=new Map;for(let t=0;i.length>t;t++)l.set(i[t],t);for(const i of e){if("line"===i.type)continue;if("area"===i.type){const e=Array.isArray(i.datum)?i.datum:[i.datum];let r=0;for(const i of e){const e=l.get(i);if(null==e)continue;const o=n.get(e);if(null==o)continue;const a=w(t,o,s);a>r&&(r=a)}r>0&&(i._pulseIntensity=r,i._pulseColor=a);continue}const e=l.get(i.datum);if(null==e)continue;const r=n.get(e);if(null==r)continue;const o=w(t,r,s);o>0&&(i._pulseIntensity=o,i._pulseColor=a,i._pulseGlowRadius=c)}}(this.config.pulse,t,e,this.timestampBuffer)}get hasActivePulses(){return!!this.config.pulse&&function(t,e){var i;if(!e||0===e.size)return!1;const n="undefined"!=typeof performance?performance.now():Date.now(),r=null!==(i=t.duration)&&void 0!==i?i:500,o=e.peek();return null!=o&&r>n-o}(this.config.pulse,this.timestampBuffer)}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(t,e,i,n){var r,o,s;i.clear(),n.clear();for(let a=0;e.length>a;a++){const c=e[a],l=M(t,c,a);l&&("point"===c.type?i.set(l,{x:c.x,y:c.y,r:c.r,opacity:c.style.opacity}):"rect"===c.type?i.set(l,{x:c.x,y:c.y,w:c.w,h:c.h,opacity:c.style.opacity}):"heatcell"===c.type?i.set(l,{x:c.x,y:c.y,w:c.w,h:c.h,opacity:null===(r=c.style)||void 0===r?void 0:r.opacity}):"candlestick"===c.type?i.set(l,{x:c.x,y:c.openY}):"line"===c.type?n.set(l,{path:c.path.map(t=>[t[0],t[1]]),opacity:null===(o=c.style)||void 0===o?void 0:o.opacity}):"area"===c.type&&n.set(l,{topPath:c.topPath.map(t=>[t[0],t[1]]),bottomPath:c.bottomPath.map(t=>[t[0],t[1]]),opacity:null===(s=c.style)||void 0===s?void 0:s.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}startTransition(){if(!this.config.transition)return;const t=function(t,e,i,n,r){var o,s,a,c,l,u,h,f,d,g,y,p,m,v,x,b,k,w,_,A,P,E,L,D,O,N,T,$;if(0===n.size&&0===r.size)return i;const W=null!==(o=e.duration)&&void 0!==o?o:300;if(i.exitNodes.length>0){const t=new Set(i.exitNodes);i.scene=i.scene.filter(e=>!t.has(e)),i.exitNodes=[]}let j=!1;const C=new Set,R=new Set;for(let e=0;i.scene.length>e;e++){const o=i.scene[e],_=M(t,o,e);if(!_)continue;if(o._transitionKey=_,"line"===o.type||"area"===o.type){const t=r.get(_);if(t){if(R.add(_),"line"===o.type&&t.path&&t.path.length===o.path.length){o._targetPath=o.path.map(t=>[t[0],t[1]]),o._prevPath=t.path;for(let e=0;o.path.length>e;e++)o.path[e]=[t.path[e][0],t.path[e][1]];j=!0}else if("area"===o.type&&t.topPath&&t.bottomPath&&t.topPath.length===o.topPath.length&&t.bottomPath.length===o.bottomPath.length){o._targetTopPath=o.topPath.map(t=>[t[0],t[1]]),o._targetBottomPath=o.bottomPath.map(t=>[t[0],t[1]]),o._prevTopPath=t.topPath,o._prevBottomPath=t.bottomPath;for(let e=0;o.topPath.length>e;e++)o.topPath[e]=[t.topPath[e][0],t.topPath[e][1]];for(let e=0;o.bottomPath.length>e;e++)o.bottomPath[e]=[t.bottomPath[e][0],t.bottomPath[e][1]];j=!0}o._targetOpacity=null!==(s=o.style.opacity)&&void 0!==s?s:1,o._startOpacity=null!==(c=null!==(a=t.opacity)&&void 0!==a?a:o.style.opacity)&&void 0!==c?c:1}else o._targetOpacity=null!==(l=o.style.opacity)&&void 0!==l?l:1,o._startOpacity=0,o.style=Object.assign(Object.assign({},o.style),{opacity:0}),j=!0;continue}const A=n.get(_);if("point"===o.type)if(A){C.add(_);const t={x:o.x,y:o.y,r:o.r};o._targetOpacity=null!==(u=o.style.opacity)&&void 0!==u?u:1,A.x===t.x&&A.y===t.y&&A.r===t.r||(o._targetX=t.x,o._targetY=t.y,o._targetR=t.r,o.x=A.x,o.y=A.y,o.r=null!==(h=A.r)&&void 0!==h?h:o.r,j=!0)}else o._targetOpacity=null!==(f=o.style.opacity)&&void 0!==f?f:1,o.style=Object.assign(Object.assign({},o.style),{opacity:0}),j=!0;else if("rect"===o.type)if(A){C.add(_);const t={x:o.x,y:o.y,w:o.w,h:o.h};o._targetOpacity=null!==(d=o.style.opacity)&&void 0!==d?d:1,A.x===t.x&&A.y===t.y&&A.w===t.w&&A.h===t.h||(o._targetX=t.x,o._targetY=t.y,o._targetW=t.w,o._targetH=t.h,o.x=A.x,o.y=A.y,o.w=null!==(g=A.w)&&void 0!==g?g:o.w,o.h=null!==(y=A.h)&&void 0!==y?y:o.h,j=!0)}else o._targetOpacity=null!==(p=o.style.opacity)&&void 0!==p?p:1,o.style=Object.assign(Object.assign({},o.style),{opacity:0}),j=!0;else if("heatcell"===o.type)if(A){C.add(_);const t={x:o.x,y:o.y,w:o.w,h:o.h};o._targetOpacity=null!==(v=null===(m=o.style)||void 0===m?void 0:m.opacity)&&void 0!==v?v:1,A.x===t.x&&A.y===t.y&&A.w===t.w&&A.h===t.h||(o._targetX=t.x,o._targetY=t.y,o._targetW=t.w,o._targetH=t.h,o.x=A.x,o.y=A.y,o.w=null!==(x=A.w)&&void 0!==x?x:o.w,o.h=null!==(b=A.h)&&void 0!==b?b:o.h,j=!0)}else o._targetOpacity=null!==(w=null===(k=o.style)||void 0===k?void 0:k.opacity)&&void 0!==w?w:1,o.style=Object.assign(Object.assign({},o.style||{}),{opacity:0}),j=!0}for(const[t,e]of r)if(!R.has(t))if(t.startsWith("l:")&&e.path){const n={type:"line",path:e.path.map(t=>[t[0],t[1]]),group:t.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:null!==(_=e.opacity)&&void 0!==_?_:1},_targetOpacity:0,_transitionKey:t,datum:null};i.exitNodes.push(n),j=!0}else if(t.startsWith("a:")&&e.topPath&&e.bottomPath){const n={type:"area",topPath:e.topPath.map(t=>[t[0],t[1]]),bottomPath:e.bottomPath.map(t=>[t[0],t[1]]),group:t.slice(2),style:{fill:"#999",opacity:null!==(A=e.opacity)&&void 0!==A?A:1},_targetOpacity:0,_transitionKey:t,datum:null};i.exitNodes.push(n),j=!0}for(const[t,e]of n)if(!C.has(t)){if(t.startsWith("p:")){const n={type:"point",x:e.x,y:e.y,r:null!==(P=e.r)&&void 0!==P?P:3,style:{opacity:null!==(E=e.opacity)&&void 0!==E?E:1},datum:null,_targetOpacity:0,_transitionKey:t};i.exitNodes.push(n)}else if(t.startsWith("r:")){const n={type:"rect",x:e.x,y:e.y,w:null!==(L=e.w)&&void 0!==L?L:0,h:null!==(D=e.h)&&void 0!==D?D:0,style:{opacity:null!==(O=e.opacity)&&void 0!==O?O:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t};i.exitNodes.push(n)}else if(t.startsWith("h:")){const n={type:"heatcell",x:e.x,y:e.y,w:null!==(N=e.w)&&void 0!==N?N:0,h:null!==(T=e.h)&&void 0!==T?T:0,fill:"#999",datum:null,style:{opacity:null!==($=e.opacity)&&void 0!==$?$:1},_targetOpacity:0,_transitionKey:t};i.exitNodes.push(n)}j=!0}return i.exitNodes.length>0&&(i.scene=[...i.scene,...i.exitNodes]),j&&(i.activeTransition={startTime:S(),duration:W}),i}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap);this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition}advanceTransition(t){if(!this.activeTransition||!this.config.transition)return!1;const e={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},i=function(t,e,i,n){var r,o,s,a,c;if(!i.activeTransition)return!1;const l=A(t,i.activeTransition),u=_(l,"linear"===e.easing?"linear":"ease-out-cubic");for(const t of i.scene){const e=t._transitionKey;if("point"===t.type){if(void 0!==t._targetOpacity){const i=e?n.get(e):void 0,o=i?null!==(r=i.opacity)&&void 0!==r?r:1:0;t.style.opacity=P(o,t._targetOpacity,u)}if(void 0===t._targetX)continue;if(!e)continue;const i=n.get(e);if(!i)continue;t.x=P(i.x,t._targetX,u),t.y=P(i.y,t._targetY,u),void 0!==t._targetR&&void 0!==i.r&&(t.r=P(i.r,t._targetR,u))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const i=e?n.get(e):void 0,r=i?null!==(o=i.opacity)&&void 0!==o?o:1:0;t.style.opacity=P(r,t._targetOpacity,u)}if(void 0===t._targetX)continue;if(!e)continue;const i=n.get(e);if(!i)continue;t.x=P(i.x,t._targetX,u),t.y=P(i.y,t._targetY,u),void 0!==i.w&&(t.w=P(i.w,t._targetW,u)),void 0!==i.h&&(t.h=P(i.h,t._targetH,u))}else if("heatcell"===t.type){if(void 0!==t._targetOpacity){const i=e?n.get(e):void 0,r=i?null!==(s=i.opacity)&&void 0!==s?s:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:P(r,t._targetOpacity,u)})}if(void 0===t._targetX)continue;if(!e)continue;const i=n.get(e);if(!i)continue;t.x=P(i.x,t._targetX,u),t.y=P(i.y,t._targetY,u),void 0!==i.w&&(t.w=P(i.w,t._targetW,u)),void 0!==i.h&&(t.h=P(i.h,t._targetH,u))}else if("line"===t.type){if(void 0!==t._targetOpacity){const e=null!==(a=t._startOpacity)&&void 0!==a?a:0;t.style=Object.assign(Object.assign({},t.style),{opacity:P(e,t._targetOpacity,u)})}const e=t._prevPath,i=t._targetPath;if(e&&i&&e.length===t.path.length)for(let n=0;t.path.length>n;n++)t.path[n][0]=P(e[n][0],i[n][0],u),t.path[n][1]=P(e[n][1],i[n][1],u)}else if("area"===t.type){if(void 0!==t._targetOpacity){const e=null!==(c=t._startOpacity)&&void 0!==c?c:0;t.style=Object.assign(Object.assign({},t.style),{opacity:P(e,t._targetOpacity,u)})}const e=t._prevTopPath,i=t._prevBottomPath,n=t._targetTopPath,r=t._targetBottomPath;if(e&&n&&e.length===t.topPath.length)for(let i=0;t.topPath.length>i;i++)t.topPath[i][0]=P(e[i][0],n[i][0],u),t.topPath[i][1]=P(e[i][1],n[i][1],u);if(i&&r&&i.length===t.bottomPath.length)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e][0]=P(i[e][0],r[e][0],u),t.bottomPath[e][1]=P(i[e][1],r[e][1],u)}}if(l>=1){for(const t of i.scene){if(void 0!==t._targetOpacity){const e=t._targetOpacity;t.style=Object.assign(Object.assign({},"line"===t.type||"area"===t.type?t.style:t.style||{}),{opacity:0===e?0:e}),t._targetOpacity=void 0}if("point"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("rect"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("heatcell"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("line"===t.type){const e=t._targetPath;if(e)for(let i=0;t.path.length>i;i++)t.path[i]=e[i];t._prevPath=void 0,t._targetPath=void 0}else if("area"===t.type){const e=t._targetTopPath,i=t._targetBottomPath;if(e)for(let i=0;t.topPath.length>i;i++)t.topPath[i]=e[i];if(i)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e]=i[e];t._prevTopPath=void 0,t._prevBottomPath=void 0,t._targetTopPath=void 0,t._targetBottomPath=void 0}}if(i.exitNodes.length>0){const t=new Set(i.exitNodes);i.scene=i.scene.filter(e=>!t.has(e)),i.exitNodes=[]}return i.activeTransition=null,!1}return!0}(t,this.config.transition,e,this.prevPositionMap);return this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition,i}groupData(t){if(!this.getGroup)return[{key:"_default",data:t}];const e=new Map;for(const i of t){const t=this.getGroup(i);e.has(t)||e.set(t,[]),e.get(t).push(i)}return Array.from(e.entries()).map(([t,e])=>({key:t,data:e}))}resolveColorMap(t){const e=new Set;for(const i of t){const t=this.getColor(i);t&&e.add(t)}const i=Array.from(e).sort(),n=i.join("\0");if(this._colorMapCache&&this._colorMapCache.key===n)return this._colorMapCache.map;const r=Array.isArray(this.config.colorScheme)?this.config.colorScheme:b,o=new Map;for(let t=0;i.length>t;t++)o.set(i[t],r[t%r.length]);return this._colorMapCache={key:n,map:o},o}resolveLineStyle(t,e){const i=this.config.lineStyle;if("function"==typeof i){const n=i(e||{},t);if(n&&!n.stroke&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},n),{stroke:e})}return n}return i&&"object"==typeof i?{stroke:i.stroke||"#007bff",strokeWidth:i.strokeWidth||2,strokeDasharray:i.strokeDasharray,fill:i.fill,fillOpacity:i.fillOpacity,opacity:i.opacity}:{stroke:"#007bff",strokeWidth:2}}resolveAreaStyle(t,e){var i;if(this.config.areaStyle){const i=this.config.areaStyle(e||{});if(i&&!i.fill&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},i),{fill:e,stroke:i.stroke||e})}return i}const n=this.config.lineStyle;if("function"==typeof n){const i=n(e||{},t);if(i&&!i.fill&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},i),{fill:e,stroke:i.stroke||e})}return i}return n&&"object"==typeof n?{fill:n.fill||n.stroke||"#4e79a7",fillOpacity:null!==(i=n.fillOpacity)&&void 0!==i?i:.7,stroke:n.stroke||"#4e79a7",strokeWidth:n.strokeWidth||2}:{fill:"#4e79a7",fillOpacity:.7,stroke:"#4e79a7",strokeWidth:2}}resolveGroupColor(t){if(this._colorMapCache){const e=this._colorMapCache.map.get(t);if(e)return e}const e=this._groupColorMap.get(t);if(e)return e;const i=Array.isArray(this.config.colorScheme)?this.config.colorScheme:b,n=i[this._groupColorMap.size%i.length];return this._groupColorMap.set(t,n),n}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}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(t){var e,i,n,r;const o=Object.assign({},this.config);void 0!==t.colorScheme&&(this._colorMapCache=null,this._groupColorMap=new Map),void 0===t.barColors&&void 0===t.colorScheme||(this._barCategoryCache=null),void 0===t.normalize&&void 0===t.extentPadding&&void 0===t.xAccessor&&void 0===t.yAccessor&&void 0===t.groupAccessor&&void 0===t.categoryAccessor&&void 0===t.chartType||(this._stackExtentCache=null);let s=!1;Object.assign(this.config,t);const a="chartType"in t&&t.chartType!==o.chartType||"runtimeMode"in t&&t.runtimeMode!==o.runtimeMode;if(a||void 0!==t.xAccessor||void 0!==t.yAccessor||void 0!==t.timeAccessor||void 0!==t.valueAccessor){const c=a||!p(null!==(e=t.xAccessor)&&void 0!==e?e:t.timeAccessor,null!==(i=o.xAccessor)&&void 0!==i?i:o.timeAccessor),l=a||!p(null!==(n=t.yAccessor)&&void 0!==n?n:t.valueAccessor,null!==(r=o.yAccessor)&&void 0!==r?r:o.valueAccessor);(c||l)&&(["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?(this.getX=m(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=m(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=m(this.config.xAccessor,"x"),this.getY=m(this.config.yAccessor,"y")),s=!0)}if("groupAccessor"in t&&!p(t.groupAccessor,o.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?x(this.config.groupAccessor):void 0,s=!0),"categoryAccessor"in t&&!p(t.categoryAccessor,o.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?x(this.config.categoryAccessor):void 0,s=!0),"sizeAccessor"in t&&!p(t.sizeAccessor,o.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?m(this.config.sizeAccessor,"size"):void 0,s=!0),"colorAccessor"in t&&!p(t.colorAccessor,o.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?x(this.config.colorAccessor):void 0,s=!0),"y0Accessor"in t&&!p(t.y0Accessor,o.y0Accessor)&&(this.getY0=this.config.y0Accessor?m(this.config.y0Accessor,"y0"):void 0,s=!0),"pointIdAccessor"in t&&!p(t.pointIdAccessor,o.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?x(this.config.pointIdAccessor):void 0,s=!0),"candlestick"===this.config.chartType&&("openAccessor"in t&&!p(t.openAccessor,o.openAccessor)||"closeAccessor"in t&&!p(t.closeAccessor,o.closeAccessor)||"highAccessor"in t&&!p(t.highAccessor,o.highAccessor)||"lowAccessor"in t&&!p(t.lowAccessor,o.lowAccessor))){const t=null!=this.config.openAccessor,e=null!=this.config.closeAccessor;this.getOpen=t?m(this.config.openAccessor,"open"):void 0,this.getHigh=m(this.config.highAccessor,"high"),this.getLow=m(this.config.lowAccessor,"low"),this.getClose=e?m(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!e,s=!0}if(!s){const e=Object.keys(t).filter(t=>!t.endsWith("Accessor")&&"timeAccessor"!==t&&"valueAccessor"!==t);for(const i of e)if(t[i]!==o[i]){s=!0;break}}s&&(this.needsFullRebuild=!0)}}function R(t,e){var i=t.get(e);if(!i)throw Error("missing: "+e);return i}function z(t,e){var i,n=[],r=[],o=[],s={},a=[];function c(t){o[t]=!1,s.hasOwnProperty(t)&&Object.keys(s[t]).forEach(function(e){delete s[t][e],o[e]&&c(e)})}function l(t){var e,n,h=!1;for(r.push(t),o[t]=!0,e=0;a[t].length>e;e++)(n=a[t][e])===i?(u(i,r),h=!0):o[n]||(h=l(n));if(h)c(t);else for(e=0;a[t].length>e;e++){var f=s[n=a[t][e]];f||(s[n]=f={}),f[n]=!0}return r.pop(),h}function u(t,e){var i=[].concat(e).concat(t);n.push(i)}function h(e){!function(e){for(var i=0;t.length>i;i++)i>=e&&t[i]||(t[i]=[]),t[i]=t[i].filter(function(t){return t>=e})}(e);for(var i,n=function(t){for(var e=t.length,i=Array(e),n=Array(e),r=Array(e),o=Array(e),s=Array(e),a=Array(e),c=0;e>c;++c)i[c]=-1,n[c]=0,r[c]=!1,o[c]=0,s[c]=-1,a[c]=[];var l,u=0,h=[],f=[];function d(e){var c=[e],l=[e];for(i[e]=n[e]=u,r[e]=!0,u+=1;l.length>0;){var d=t[e=l[l.length-1]];if(d.length>o[e]){for(var g=o[e];d.length>g;++g){var y=d[g];if(0>i[y]){i[y]=n[y]=u,r[y]=!0,u+=1,c.push(y),l.push(y);break}r[y]&&(n[e]=0|Math.min(n[e],n[y])),0>s[y]||a[e].push(s[y])}o[e]=g}else{if(n[e]===i[e]){var p=[],m=[],v=0;for(g=c.length-1;g>=0;--g){var x=c[g];if(r[x]=!1,p.push(x),m.push(a[x]),v+=a[x].length,s[x]=h.length,x===e){c.length=g;break}}h.push(p);var b=Array(v);for(g=0;m.length>g;g++)for(var k=0;m[g].length>k;k++)b[--v]=m[g][k];f.push(b)}l.pop()}}}for(c=0;e>c;++c)0>i[c]&&d(c);for(c=0;f.length>c;c++){var g=f[c];if(0!==g.length){g.sort(function(t,e){return t-e}),l=[g[0]];for(var y=1;g.length>y;y++)g[y]!==g[y-1]&&l.push(g[y]);f[c]=l}}return{components:h,adjacencyList:f}}(t),r=n.components.filter(function(t){return t.length>1}),o=1/0,s=0;r.length>s;s++)for(var a=0;r[s].length>a;a++)o>r[s][a]&&(o=r[s][a],i=s);var c=r[i];if(!c)return!1;var l=t.map(function(t,e){return-1===c.indexOf(e)?[]:t.filter(function(t){return-1!==c.indexOf(t)})});return{leastVertex:o,adjList:l}}i=0;for(var f=t.length;f>i;){var d=h(i);if(i=d.leastVertex,a=d.adjList){for(var g=0;a.length>g;g++)for(var y=0;a[g].length>y;y++){var p=a[g][y];o[+p]=!1,s[p]={}}l(i),i+=1}else i=f}return n}function B(t){return t.y0-t.y1>0?"up":"down"}function I(t,e){return e(t.source)==e(t.target)}function Y(t){var e=0;t.source.sourceLinks.forEach(function(t){e=t.circular?e+1:e});var i=0;return t.target.targetLinks.forEach(function(t){i=t.circular?i+1:i}),1>=e&&1>=i}function F(t){return t.target.x0-t.source.x1}function X(t,e){var i=G(t),n=F(e)/Math.tan(i);return"up"==B(t)?t.y1-n:t.y1+n}function q(t,e){var i=G(t),n=F(e)/Math.tan(i);return"up"==B(t)?t.y1+n:t.y1-n}function G(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function V(t,e){return e(t)}function H(t){return K(t.source)}function Z(t){return K(t.target)}function K(t){return(t.y0+t.y1)/2}function Q(t){return t.virtual?0:t.value}function U(t,e){var i=0;t.sourceLinks.forEach(function(t){i=t.circular&&!I(t,e)?i+1:i});var n=0;return t.targetLinks.forEach(function(t){n=t.circular&&!I(t,e)?n+1:n}),i+n}function J(t){return t.target.depth}function tt(t,e){return t.sourceLinks.length?t.depth:e-1}function et(t,e){return t.y0-e.y0}function it(t,e){return e.y0-t.y0}function nt(t,e){return t.y1-e.y1}function rt(t,e){return e.y1-t.y1}function ot(t,e){return at(t.source,e.source)||t.index-e.index}function st(t,e){return at(t.target,e.target)||t.index-e.index}function at(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function ct(t,e){return lt(t)==lt(e)?"bottom"==t.circularLinkType?it(t,e):et(t,e):lt(e)-lt(t)}function lt(t){return t.target.column-t.source.column}function ut(t,e){return ht(t)==ht(e)}function ht(t){return t.y0-t.y1>0?"up":"down"}function ft(t,e,i,n,o){let s=t;var a=Math.max(8,.15*(s.y1-s.y0));s.links.forEach(function(t){t.circular&&(t._circularWidth=Math.min(t.width,a))});var c=r.min(s.links,function(t){return t.source.y0});s.links.forEach(function(t){t.circular&&(t.circularPathData={})});var l=s.links.filter(function(t){return t.circular});return l.sort(function(t,e){return e.value-t.value}),l.forEach(function(t,e){t._circularStub=e>=4}),dt(s.links.filter(function(t){return"top"==t.circularLinkType}),e,i),dt(s.links.filter(function(t){return"bottom"==t.circularLinkType}),e,i),s.links.forEach(function(t){if(t.circular){if(t.circularPathData.arcRadius=t._circularWidth+n,t.circularPathData.rightNodeBuffer=5,t.circularPathData.leftNodeBuffer=5,t.circularPathData.sourceWidth=t.source.x1-t.source.x0,t.circularPathData.sourceX=t.source.x0+t.circularPathData.sourceWidth,t.circularPathData.targetX=t.target.x0,t.circularPathData.sourceY=t.y0,t.circularPathData.targetY=t.y1,I(t,e)&&Y(t))t.circularPathData.rightSmallArcRadius=n+t._circularWidth/2,t.circularPathData.rightLargeArcRadius=n+t._circularWidth/2,t.circularPathData.leftSmallArcRadius=n+t._circularWidth/2,t.circularPathData.leftLargeArcRadius=n+t._circularWidth/2,"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=t.source.y1+o+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=t.source.y0-o-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius);else{var r=t.source.column,a=t.circularLinkType,l=s.links.filter(function(t){return t.source.column==r&&t.circularLinkType==a});l.sort("bottom"==t.circularLinkType?it:et);var u=0;l.forEach(function(e,r){e.circularLinkID==t.circularLinkID&&(t.circularPathData.rightSmallArcRadius=n+t._circularWidth/2+u,t.circularPathData.rightLargeArcRadius=n+t._circularWidth/2+r*i+u),u+=e._circularWidth||e.width}),r=t.target.column,(l=s.links.filter(function(t){return t.target.column==r&&t.circularLinkType==a})).sort("bottom"==t.circularLinkType?rt:nt),u=0,l.forEach(function(e,r){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=n+t._circularWidth/2+u,t.circularPathData.leftLargeArcRadius=n+t._circularWidth/2+r*i+u),u+=e._circularWidth||e.width}),"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=Math.max(s.y1,t.source.y1,t.target.y1)+o+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=c-o-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius)}t.circularPathData.rightInnerExtent=t.circularPathData.sourceX+t.circularPathData.rightNodeBuffer,t.circularPathData.leftInnerExtent=t.circularPathData.targetX-t.circularPathData.leftNodeBuffer,t.circularPathData.rightFullExtent=t.circularPathData.sourceX+t.circularPathData.rightLargeArcRadius+t.circularPathData.rightNodeBuffer,t.circularPathData.leftFullExtent=t.circularPathData.targetX-t.circularPathData.leftLargeArcRadius-t.circularPathData.leftNodeBuffer}t.path=t.circular?function(t){return"top"==t.circularLinkType?"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 0 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY-t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 0 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 0 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY-t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 0 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY:"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 1 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY+t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 1 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 1 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY+t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 1 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY}(t):function(t){var e=t.source.x1,i=t.y0,n=t.target.x0,r=t.y1,o=(e+n)/2;return"M"+e+","+i+"C"+o+","+i+" "+o+","+r+" "+n+","+r}(t)}),s}function dt(t,e,i){t.sort(ct);var n=t.filter(function(t){return!t._circularStub});return t.forEach(function(t,r){var o=0;if(t._circularStub)t.circularPathData.verticalBuffer=0;else if(I(t,e)&&Y(t))t.circularPathData.verticalBuffer=o+t._circularWidth/2;else{for(var s=0;n.length>s;s++){var a=n[s];if(a!==t&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&>(t,a)){var c=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+i;o=c>o?c:o}}t.circularPathData.verticalBuffer=o+t._circularWidth/2}}),t}function gt(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}function yt(t){return function(){return t}}function pt(t){return t.index}function mt(t){return t.nodes}function vt(t){return t.links}function xt(t,e,i){var n=r.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});n.forEach(function(r,o){var s=r.length;if(e)r.sort(e);else if(o>0){var a=new Map;r.forEach(function(t,e){var i,n,r,o=(n=0,r=0,(i=t).targetLinks.forEach(function(t){if(!t.circular){var e=t.value||1;r+=K(t.source)*e,n+=e}}),i.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;r+=K(t.target)*e,n+=e}}),n>0?r/n:NaN);a.set(t,{bc:o,idx:e})}),r.sort(function(t,e){var i=a.get(t),n=a.get(e),r=i.bc,o=n.bc;if(t.circularLinkType!==e.circularLinkType){if("top"==t.circularLinkType&&"bottom"==e.circularLinkType)return-1;if("bottom"==t.circularLinkType&&"top"==e.circularLinkType)return 1;if("top"==t.circularLinkType)return-1;if("top"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return-1}return isNaN(r)||isNaN(o)?isNaN(r)?isNaN(o)?i.idx-n.idx:1:-1:r-o})}else r.sort(function(t,e){return t.circularLinkType==e.circularLinkType?U(e,i)-U(t,i):"top"==t.circularLinkType&&"bottom"==e.circularLinkType||"top"==t.circularLinkType&&0==e.partOfCycle||0==t.partOfCycle&&"bottom"==e.circularLinkType?-1:0});r.forEach(function(e,r){e.depth==n.length-1&&1==s||0==e.depth&&1==s?(e.y0=t.y1/2-e.value*t.ky,e.y1=e.y0+e.value*t.ky):e.partOfCycle?0==U(e,i)?(e.y0=t.y1/2+r,e.y1=e.y0+e.value*t.ky):"top"==e.circularLinkType?(e.y0=t.y0+r,e.y1=e.y0+e.value*t.ky):(e.y0=t.y1-e.value*t.ky-r,e.y1=e.y0+e.value*t.ky):0==t.y0||0==t.y1?(e.y0=(t.y1-t.y0)/s*r,e.y1=e.y0+e.value*t.ky):(e.y0=(t.y1-t.y0)/2-s/2+r,e.y1=e.y0+e.value*t.ky)})})}function bt(t,e,i,n,o,s){var a=r.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});h();for(var c=1,l=s;l>0;--l)u(c*=.99,i),h();function u(e,i){var n=a.length;a.forEach(function(o){var s=o.length,a=o[0].depth;o.forEach(function(o){var c;if(o.sourceLinks.length||o.targetLinks.length)if(o.partOfCycle&&U(o,i)>0){var l=r.mean(o.sourceLinks,Z),u=r.mean(o.targetLinks,H),h=l&&u?(l+u)/2:l||u;if(h){var f=(h-K(o))*e*.3;o.y0+=f,o.y1+=f}}else if(0==a&&1==s)o.y0=t.y1/2-(c=o.y1-o.y0)/2,o.y1=t.y1/2+c/2;else if(a==n-1&&1==s)o.y0=t.y1/2-(c=o.y1-o.y0)/2,o.y1=t.y1/2+c/2;else if(1==o.targetLinks.length&&1==o.targetLinks[0].source.sourceLinks.length)c=o.y1-o.y0,o.y0=o.targetLinks[0].source.y0,o.y1=o.y0+c;else{var d=r.mean(o.sourceLinks,Z),g=r.mean(o.targetLinks,H),y=((d&&g?(d+g)/2:d||g)-K(o))*e;o.y0+=y,o.y1+=y}})})}function h(){a.forEach(function(i){var r,s,a,c=t.y0,l=i.length;for(i.sort(e||at),a=0;l>a;++a)(s=c-(r=i[a]).y0)>0&&(r.y0+=s,r.y1+=s),c=r.y1+n;if((s=c-n-t.y1)>0)for(c=r.y0-=s,r.y1-=s,a=l-2;a>=0;--a)(s=(r=i[a]).y1+o-c)>0&&(r.y0-=s,r.y1-=s),c=r.y0})}}function kt(t){t.nodes.forEach(function(t){t.sourceLinks.sort(st),t.targetLinks.sort(ot)}),t.nodes.forEach(function(t){var e=t.y0,i=e,n=t.y1,r=n;t.sourceLinks.forEach(function(t){t.circular?(t.y0=n-t.width/2,n-=t.width):(t.y0=e+t.width/2,e+=t.width)}),t.targetLinks.forEach(function(t){t.circular?(t.y1=r-t.width/2,r-=t.width):(t.y1=i+t.width/2,i+=t.width)})})}function wt(){var t=0,e=0,i=1,n=1,o=24,s=8,a=null,c=pt,l=tt,u=void 0,h=32,f=2,d=mt,g=vt;function y(){var y={nodes:d.apply(null,arguments),links:g.apply(null,arguments)};return function(d){d.x0=t,d.y0=e,d.x1=i,d.y1=n,d.py=0,function(t,e){t.nodes.forEach(function(t,e){t.index=e,t.sourceLinks=[],t.targetLinks=[]});var i=function(t,e){var i=new Map;return r.group(t,e).forEach(function(t,e){i.set(e,t[0])}),i}(t.nodes,e);t.links.forEach(function(t,e){t.index=e;var n=t.source,r=t.target;"object"!=typeof n&&(n=t.source=R(i,n)),"object"!=typeof r&&(r=t.target=R(i,r)),n.sourceLinks.push(t),r.targetLinks.push(t)})}(d,c),function(t,e){var i=0;if(null==e){for(var n=[],r=0;t.links.length>r;r++){var o=t.links[r],s=o.source.index,a=o.target.index;n[s]||(n[s]=[]),n[a]||(n[a]=[]),-1===n[s].indexOf(a)&&n[s].push(a)}var c=z(n);c.sort(function(t,e){return t.length-e.length});var l={};for(r=0;c.length>r;r++){var u=c[r].slice(-2);l[u[0]]||(l[u[0]]={}),l[u[0]][u[1]]=!0}t.links.forEach(function(t){var e=t.target.index,n=t.source.index;e===n||l[n]&&l[n][e]?(t.circular=!0,t.circularLinkID=i++):t.circular=!1})}else t.links.forEach(function(t){e(t.source)<e(t.target)?t.circular=!1:(t.circular=!0,t.circularLinkID=i++)})}(d,u),function(t,e){var i=0,n=0;t.links.forEach(function(r){r.circular&&(r.circularLinkType=r.source.circularLinkType||r.target.circularLinkType?r.source.circularLinkType?r.source.circularLinkType:r.target.circularLinkType:n>i?"top":"bottom","top"==r.circularLinkType?i++:n++,t.nodes.forEach(function(t){V(t,e)!=V(r.source,e)&&V(t,e)!=V(r.target,e)||(t.circularLinkType=r.circularLinkType)}))}),t.links.forEach(function(t){t.circular&&(t.source.circularLinkType==t.target.circularLinkType&&(t.circularLinkType=t.source.circularLinkType),I(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(d,c),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max(r.sum(t.sourceLinks,Q),r.sum(t.targetLinks,Q)),t.sourceLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)}),t.targetLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)})})}(d),function(t,e,i){var n,r,o;if(null!=e){t.nodes.sort(function(t,i){return e(t)<e(i)?-1:1});var s=0,a=e(t.nodes[0]);t.nodes.forEach(function(t){s=e(t)==a?s:s+1,a=e(t)==a?a:e(t),t.column=s})}for(n=t.nodes,r=[],o=0;n.length;++o,n=r,r=[])n.forEach(function(t){t.depth=o,t.sourceLinks.forEach(function(t){0>r.indexOf(t.target)&&!t.circular&&r.push(t.target)})});for(n=t.nodes,r=[],o=0;n.length;++o,n=r,r=[])n.forEach(function(t){t.height=o,t.targetLinks.forEach(function(t){0>r.indexOf(t.source)&&!t.circular&&r.push(t.source)})});t.nodes.forEach(function(t){t.column=null==e?i(t,o):t.column})}(d,u,l);var g=s;if(null!==a){var y=r.groups(d.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),p=r.max(y,function(t){return t.length});p>1&&(g=Math.max(1,(n-e)*a/(p-1)))}(function(t,e,i){var n=r.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});t.py=e;var o=r.min(n,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/r.sum(e,function(t){return t.value})});t.ky=o,t.links.forEach(function(e){e.width=e.value*t.ky});var s=r.max(t.nodes,function(t){return t.column});t.nodes.forEach(s>0?function(e){e.x0=t.x0+e.column*((t.x1-t.x0-i)/s),e.x1=e.x0+i}:function(e){e.x0=t.x0,e.x1=e.x0+i})})(d,g,o),xt(d,u,c),bt(d,u,c,g,g,h),kt(d),ft(d,c,f,10,8),xt(d,u,c),bt(d,u,c,g,g,h),kt(d),ft(d,c,f,10,8),function(t,e){let i=t;i.nodes.forEach(function(t){t.y+(t.y1-t.y0)>i.y1&&(t.y=t.y-(t.y+(t.y1-t.y0)-i.y1));var n=i.links.filter(function(i){return V(i.source,e)==V(t,e)}),r=n.length;r>1&&n.sort(function(t,e){if(!t.circular&&!e.circular){if(t.target.column==e.target.column)return t.y1-e.y1;if(!ut(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var i=X(e,t);return t.y1-i}if(e.target.column>t.target.column)return X(t,e)-e.y1}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.target.column===e.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.target.column===e.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:"top"==t.circularLinkType?-1:1:void 0});var o=t.y0;n.forEach(function(t){t.y0=o+t.width/2,o+=t.width}),n.forEach(function(e,i){if("bottom"==e.circularLinkType){for(var o=i+1,s=0;r>o;o++)s+=n[o].width;e.y0=t.y1-s-e.width/2}})})}(d,c),function(t,e){let i=t;i.nodes.forEach(function(t){var n=i.links.filter(function(i){return V(i.target,e)==V(t,e)}),r=n.length;r>1&&n.sort(function(t,e){if(!t.circular&&!e.circular){if(t.source.column==e.source.column)return t.y0-e.y0;if(!ut(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var i=q(e,t);return t.y0-i}if(e.source.column>t.source.column)return q(t,e)-e.y0}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:t.source.column-e.source.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:e.source.column-t.source.column:"top"==t.circularLinkType?-1:1:void 0});var o=t.y0;n.forEach(function(t){t.y1=o+t.width/2,o+=t.width}),n.forEach(function(e,i){if("bottom"==e.circularLinkType){for(var o=i+1,s=0;r>o;o++)s+=n[o].width;e.y1=t.y1-s-e.width/2}})})}(d,c),function(t){var e=t.nodes,i=t.links,n=!1,o=!1;if(i.forEach(function(t){"top"==t.circularLinkType?n=!0:"bottom"==t.circularLinkType&&(o=!0)}),0==n||0==o){var s=r.min(e,function(t){return t.y0}),a=r.max(e,function(t){return t.y1}),c=(t.y1-t.y0)/(a-s);function l(e){return(e-s)/(a-s)*(t.y1-t.y0)+t.y0}1>c?(e.forEach(function(t){t.y0=l(t.y0),t.y1=l(t.y1)}),i.forEach(function(t){t.y0=l(t.y0),t.y1=l(t.y1),t.width=t.width*c})):e.forEach(function(t){var e=t.y1-t.y0,i=l(t.y0)-t.y0;t.y0=l(t.y0),t.y1=t.y0+e,t.sourceLinks.forEach(function(t){t.y0=t.y0+i}),t.targetLinks.forEach(function(t){t.y1=t.y1+i})})}}(d),ft(d,c,f,10,8)}(y),y}return y.update=function(t){return kt(t),ft(t,c,f,10,8),t},y.nodeWidth=function(t){return arguments.length?(o=+t,y):o},y.nodePadding=function(t){return arguments.length?(s=+t,y):s},y.nodePaddingRatio=function(t){return arguments.length?(a=+t,y):a},y.nodes=function(t){return arguments.length?(d="function"==typeof t?t:yt(t),y):d},y.links=function(t){return arguments.length?(g="function"==typeof t?t:yt(t),y):g},y.nodeId=function(t){return arguments.length?(c="function"==typeof t?t:yt(t),y):c},y.nodeAlign=function(t){return arguments.length?(l="function"==typeof t?t:yt(t),y):l},y.nodeSort=function(t){return arguments.length?(u=t,y):u},y.iterations=function(t){return arguments.length?(h=+t,y):h},y.circularLinkGap=function(t){return arguments.length?(f=+t,y):f},y.extent=function(r){return arguments.length?(t=+r[0][0],e=+r[0][1],i=+r[1][0],n=+r[1][1],y):[[t,e],[i,n]]},y.size=function(r){return arguments.length?(t=e=0,i=+r[0],n=+r[1],y):[i-t,n-e]},y}C.QUADTREE_THRESHOLD=500;const _t=t=>{let e,i,n,r,s,a,c,l,u;return"down"===t.direction?(e=t.y0-t.sankeyWidth/2,i=t.y1-t.sankeyWidth/2,n=t.y1+t.sankeyWidth/2,r=t.y0+t.sankeyWidth/2,s=t.source.x1,a=t.target.x0,c=o.interpolateNumber(s,a),l=c(.5),u=c(.5),`M${e},${s}C${e},${l} ${i},${u} ${i},${a}L${n},${a}C${n},${u} ${r},${l} ${r},${s}Z`):(e=t.source.x1,i=t.target.x0,c=o.interpolateNumber(e,i),n=c(.5),r=c(.5),s=t.y0-t.sankeyWidth/2,a=t.y1-t.sankeyWidth/2,l=t.y1+t.sankeyWidth/2,u=t.y0+t.sankeyWidth/2,`M${e},${s}C${n},${s} ${r},${a} ${i},${a}L${i},${l}C${r},${l} ${n},${u} ${e},${u}Z`)};function At(t){var e;const i=t.sankeyWidth/2,n=(null!==(e=t._circularWidth)&&void 0!==e?e:t.sankeyWidth)/2,r=t.circularPathData;if(!r)return null;if("down"===t.direction)return null;if(t._circularStub){const e=r.sourceX,n=r.sourceY,o=r.targetX,s=r.targetY;if("object"!=typeof t.source||!t.source||"object"!=typeof t.target||!t.target)return null;const a=Math.max(15,Math.min(40,.33*(r.rightFullExtent-e))),c=Math.max(15,Math.min(40,.33*(o-r.leftFullExtent)));return`M${e},${n-i}L${e+a},${n-i}L${e+a},${n+i}L${e},${n+i}ZM${o},${s-i}L${o-c},${s-i}L${o-c},${s+i}L${o},${s+i}Z`}const o=r.sourceX,s=r.sourceY,a=r.targetX,c=r.targetY,l=r.rightFullExtent,u=r.leftFullExtent,h=r.verticalFullExtent,f="bottom"===t.circularLinkType?1:-1,d=Math.max(4,Math.min(n,15));return`M${o},${s-f*i}L${l},${s-f*i}L${l+n},${s-f*i+f*d}L${l+n},${h+f*n-f*d}L${l+n-d},${h+f*n}L${u-n+d},${h+f*n}L${u-n},${h+f*n-f*d}L${u-n},${c-f*i+f*d}L${u-n+d},${c-f*i}L${a},${c-f*i}L${a},${c+f*i}L${u+n},${c+f*i}L${u+n},${h-f*n}L${l-n},${h-f*n}L${l-n},${s+f*i}L${o},${s+f*i}Z`}const Pt=new Set,St=new WeakMap;function Mt(t,e){if("production"===process.env.NODE_ENV)return t;if(!t||!t.data||"object"!=typeof t.data)return t;let i=St.get(t);if(i){const t=i.get(e);if(t)return t}else i=new Map,St.set(t,i);const n=new Proxy(t,{get(t,i,n){if("string"==typeof i&&!(i in t)&&t.data&&i in t.data){const t=`${e}:${i}`;Pt.has(t)||(Pt.add(t),console.warn(`[Semiotic] "${e}" callback accessed "${i}" on the wrapper object, but it only exists on ".data". Use d.data.${i} (or d.data?.${i}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(t,i,n)}});return i.set(e,n),n}const Et={left:function(t){return t.depth},right:function(t,e){return e-1-t.height},center:function(t){return t.targetLinks.length?t.depth:t.sourceLinks.length?Math.min.apply(Math,t.sourceLinks.map(J))-1:0},justify:tt},Lt={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,i,n){var r,o,s,a,c,l,u;if(0===t.length)return;const h="vertical"===i.orientation?"down":"right",f=i.nodeAlign||"justify",d=null!==(r=i.nodeWidth)&&void 0!==r?r:15,g=null!==(o=i.nodePaddingRatio)&&void 0!==o?o:.05,y=null!==(s=i.iterations)&&void 0!==s?s:100,p=t.map(t=>Object.assign({},t)),m=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id,value:Math.sqrt(Math.max(1,t.value||1))}));let v;v="down"===h?[[0,0],[n[1],n[0]]]:[[0,0],[n[0],n[1]]];const x=wt().extent(v).links(m).nodes(p).nodeAlign(Et[f]||tt).nodeId(t=>t.id).nodeWidth(d).iterations(y);x.nodePaddingRatio&&x.nodePaddingRatio(g),x();{let t=1/0,e=-1/0,i=1/0,r=-1/0;for(const n of p)t>n.x0&&(t=n.x0),n.x1>e&&(e=n.x1),i>n.y0&&(i=n.y0),n.y1>r&&(r=n.y1);for(const n of m){if(!n.circular||!n.circularPathData)continue;const o=n.circularPathData,s=(null!==(c=null!==(a=n._circularWidth)&&void 0!==a?a:n.width)&&void 0!==c?c:0)/2;t>o.leftFullExtent-s&&(t=o.leftFullExtent-s),o.rightFullExtent+s>e&&(e=o.rightFullExtent+s),i>o.verticalFullExtent-s&&(i=o.verticalFullExtent-s),o.verticalFullExtent+s>r&&(r=o.verticalFullExtent+s)}const o=e-t,s=r-i,u=n[0],h=n[1];if(o>0&&s>0&&(0>t||0>i||e>u||r>h)){const e=Math.min(u/o,h/s),n=-t*e+(u-o*e)/2,r=-i*e+(h-s*e)/2;for(const t of p)t.x0=t.x0*e+n,t.x1=t.x1*e+n,t.y0=t.y0*e+r,t.y1=t.y1*e+r;for(const t of m)if(t.y0=t.y0*e+r,t.y1=t.y1*e+r,t.width=(null!==(l=t.width)&&void 0!==l?l:0)*e,t._circularWidth&&(t._circularWidth*=e),t.circular&&t.circularPathData){const i=t.circularPathData;i.sourceX=i.sourceX*e+n,i.targetX=i.targetX*e+n,i.sourceY=i.sourceY*e+r,i.targetY=i.targetY*e+r,i.rightFullExtent=i.rightFullExtent*e+n,i.leftFullExtent=i.leftFullExtent*e+n,i.verticalFullExtent=i.verticalFullExtent*e+r,i.rightInnerExtent=i.rightInnerExtent*e+n,i.leftInnerExtent=i.leftInnerExtent*e+n,i.verticalRightInnerExtent=i.verticalRightInnerExtent*e+r,i.verticalLeftInnerExtent=i.verticalLeftInnerExtent*e+r,i.rightSmallArcRadius*=e,i.rightLargeArcRadius*=e,i.leftSmallArcRadius*=e,i.leftLargeArcRadius*=e,i.sourceWidth*=e,i.rightNodeBuffer*=e,i.leftNodeBuffer*=e,i.arcRadius*=e}}}const b=new Map;for(const e of t)b.set(e.id,e);for(const t of p){const e=b.get(t.id);e&&(e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.value=t.value,e.depth=t.depth,e.sourceLinks=t.sourceLinks,e.targetLinks=t.targetLinks,e.width=t.x1-t.x0,e.height=t.y1-t.y0,e.x=t.x0+(t.x1-t.x0)/2,e.y=t.y0+(t.y1-t.y0)/2)}const k=new Map;for(const t of e)k.set(t._edgeKey?t._edgeKey:`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const t of m){const e=t.source,i=t.target,n="object"==typeof e&&null!==e?e.id:e+"",r="object"==typeof i&&null!==i?i.id:i+"",o=k.get(t._edgeKey?t._edgeKey:`${n}\0${r}`);if(o){o.y0=t.y0,o.y1=t.y1,o.sankeyWidth=null!==(u=t.width)&&void 0!==u?u:0,o.circular=!!t.circular,o.circularPathData=t.circularPathData,o._circularWidth=t._circularWidth,o._circularStub=t._circularStub,o.path=t.path,o.circularLinkType=t.circularLinkType,o.direction=h;const e=b.get(n),i=b.get(r);e&&(o.source=e),i&&(o.target=i)}}},buildScene(t,e,i,r){var o,s,a,c;const l="vertical"===i.orientation?"down":"right",u=i.nodeStyle,h=i.edgeStyle,f=null!==(o=i.edgeOpacity)&&void 0!==o?o:.5,d=i.edgeColorBy||"source",g=Array.isArray(i.colorScheme)?i.colorScheme:n.schemeCategory10,y=new Map;t.forEach((t,e)=>{y.set(t.id,g[e%g.length])});const p=[],m=[],v=[],x=new Map;for(const e of t){const t=e.x1-e.x0,i=e.y1-e.y0;if(0>=t||0>=i)continue;const n=u?u(Mt(e,"nodeStyle")):{},r={fill:n.fill||y.get(e.id)||"#4d430c",stroke:n.stroke,strokeWidth:n.strokeWidth,opacity:n.opacity};x.set(e.id,("string"==typeof r.fill?r.fill:null)||y.get(e.id)||"#4d430c"),p.push("down"===l?{type:"rect",x:e.y0,y:e.x0,w:i,h:t,style:r,datum:e,id:e.id,label:e.id}:{type:"rect",x:e.x0,y:e.y0,w:t,h:i,style:r,datum:e,id:e.id,label:e.id})}const b=[...e].sort((t,e)=>(e.sankeyWidth||0)-(t.sankeyWidth||0));for(const t of b){if(!t.sankeyWidth||0>=t.sankeyWidth)continue;const e="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;if(!e||!i)continue;let n="#999";n="function"==typeof d?d(t)||n:"target"===d?x.get(i.id)||y.get(i.id)||n:x.get(e.id)||y.get(e.id)||n;const r=h?h(Mt(t,"edgeStyle")):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,i=t.sankeyWidth/2,o=Math.max(15,Math.min(40,.33*(e.rightFullExtent-e.sourceX))),c=Math.max(15,Math.min(40,.33*(e.targetX-e.leftFullExtent))),l=r.fill||n;m.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-i}L${e.sourceX+o},${e.sourceY-i}L${e.sourceX+o},${e.sourceY+i}L${e.sourceX},${e.sourceY+i}Z`,style:{fill:l,fillOpacity:null!==(s=r.fillOpacity)&&void 0!==s?s:f,stroke:"none",opacity:r.opacity},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+o}}),m.push({type:"bezier",pathD:`M${e.targetX},${e.targetY-i}L${e.targetX-c},${e.targetY-i}L${e.targetX-c},${e.targetY+i}L${e.targetX},${e.targetY+i}Z`,style:{fill:l,fillOpacity:null!==(a=r.fillOpacity)&&void 0!==a?a:f,stroke:"none",opacity:r.opacity},datum:t,_gradient:{direction:"left",from:0,to:1,x0:e.targetX-c,x1:e.targetX}});continue}let o;if(o=t.circular&&t.circularPathData?At(t):_t(t),!o)continue;const l={fill:r.fill||n,fillOpacity:null!==(c=r.fillOpacity)&&void 0!==c?c:f,stroke:r.stroke||"none",strokeWidth:r.strokeWidth,opacity:r.opacity};m.push({type:"bezier",pathD:o,bezierCache:t.bezier,style:l,datum:t})}if(!1!==i.showLabels){const e=(k=i.nodeLabel)?"function"==typeof k?k:t=>t[k]||t.id:null;for(const i of t){const t=i.x1-i.x0,n=i.y1-i.y0;if(0>=t||0>=n)continue;const o=e?e(i):i.id;if(!o)continue;let s,a,c;"down"===l?(s=i.y0+(i.y1-i.y0)/2,a=i.x1+14,c="middle"):(r[0]/2>i.x0+t/2?(s=i.x0-6,c="end"):(s=i.x1+6,c="start"),a=i.y0+n/2),v.push({x:s,y:a,text:o+"",anchor:c,baseline:"middle",fontSize:11})}}var k;return{sceneNodes:p,sceneEdges:m,labels:v}}},Dt={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,i,n){var r,o;if(0===t.length)return;const a=null!==(r=i.forceStrength)&&void 0!==r?r:.1,c=n[0]/2,l=n[1]/2,u=i.__previousPositions;let h=0;const f=[];for(const e of t){const t=null!=e.x&&null!=e.y&&(0!==e.x||0!==e.y),i=null==u?void 0:u.get(e.id);t?h++:i?(e.x=i.x,e.y=i.y,h++):f.push(e)}const d=h>0&&.3>=(t.length>0?f.length/t.length:1);if(d){const i=new Map;for(const e of t)i.set(e.id,e);for(const t of f){const n=Ot(t.id,e,i);if(n.length>0){let e=0,i=0;for(const t of n)e+=t.x,i+=t.y;const r=Nt(t.id),o=r%360*(Math.PI/180),s=10+r%20;t.x=e/n.length+s*Math.cos(o),t.y=i/n.length+s*Math.sin(o)}else{const e=Nt(t.id),i=e%360*(Math.PI/180),n=15+e%30;t.x=c+n*Math.cos(i),t.y=l+n*Math.sin(i)}}}else{const e=2.399963229728653;for(let i=0;t.length>i;i++){const n=t[i];if(null==n.x||null==n.y||0===n.x&&0===n.y){const t=10*Math.sqrt(i+.5),r=i*e;n.x=c+t*Math.cos(r),n.y=l+t*Math.sin(r)}}}const g=null!==(o=i.iterations)&&void 0!==o?o:Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),y=d?40:g,p=Tt(i.nodeSize,i.nodeSizeRange,t),m=t=>p(t),v=s.forceLink().strength(t=>Math.min(2.5,t.weight?t.weight*a:a)).id(t=>t.id),x=s.forceSimulation().force("charge",s.forceManyBody().strength(t=>-25*m(t))).force("center",s.forceCenter(c,l).strength(.8)).force("x",s.forceX(c).strength(.15)).force("y",s.forceY(l).strength(.15));if(x.nodes(t),e.length>0){const t=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id}));x.force("link",v),x.force("link").links(t)}d?x.alpha(.3):.1>x.alpha()&&x.alpha(1),x.stop();for(let t=0;y>t;++t)x.tick();for(const e of t){if(null==e.x||null==e.y)continue;const t=m(e);e.x=Math.max(t,Math.min(n[0]-t,e.x)),e.y=Math.max(t,Math.min(n[1]-t,e.y)),e.x0=0,e.x1=0,e.y0=0,e.y1=0}const b=new Map;for(const e of t)b.set(e.id,e);for(const t of e){if("string"==typeof t.source){const e=b.get(t.source);e&&(t.source=e)}if("string"==typeof t.target){const e=b.get(t.target);e&&(t.target=e)}}},buildScene(t,e,i,r){var o,s,a;const c=i.nodeStyle,l=i.edgeStyle,u=Tt(i.nodeSize,i.nodeSizeRange,t),h=Array.isArray(i.colorScheme)?i.colorScheme:n.schemeCategory10,f=new Map;t.forEach((t,e)=>{f.set(t.id,h[e%h.length])});const d=[],g=[],y=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=u(Mt(e,"nodeSize")),i=c?c(Mt(e,"nodeStyle")):{},n={fill:i.fill||f.get(e.id)||"#007bff",stroke:i.stroke||"#fff",strokeWidth:null!==(o=i.strokeWidth)&&void 0!==o?o:2,opacity:i.opacity};d.push({type:"circle",cx:e.x,cy:e.y,r:t,style:n,datum:e,id:e.id,label:e.id})}const p=new Map;for(const e of t)p.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:p.get(t.source),i="object"==typeof t.target?t.target:p.get(t.target);if(!e||!i)continue;if(null==e.x||null==e.y)continue;if(null==i.x||null==i.y)continue;const n=l?l(Mt(t,"edgeStyle")):{},r={stroke:n.stroke||"#999",strokeWidth:null!==(s=n.strokeWidth)&&void 0!==s?s:1,opacity:null!==(a=n.opacity)&&void 0!==a?a:.6};g.push({type:"line",x1:e.x,y1:e.y,x2:i.x,y2:i.y,style:r,datum:t})}if(!1!==i.showLabels){const e=(m=i.nodeLabel)?"function"==typeof m?m:t=>t[m]||t.id:null;for(const i of t){if(null==i.x||null==i.y)continue;const t=e?e(i):i.id;if(!t)continue;const n=u(Mt(i,"nodeSize"));y.push({x:i.x,y:i.y-n-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var m;return{sceneNodes:d,sceneEdges:g,labels:y}}};function Ot(t,e,i){const n=[];for(const r of e){const e="string"==typeof r.source?r.source:r.source.id,o="string"==typeof r.target?r.target:r.target.id;let s=null;if(e===t?s=o:o===t&&(s=e),s){const t=i.get(s);!t||0===t.x&&0===t.y||n.push({x:t.x,y:t.y})}}return n}function Nt(t){let e=0;for(let i=0;t.length>i;i++)e=(e<<5)-e+t.charCodeAt(i)|0;return Math.abs(e)}function Tt(t,i,n){var o,s;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const a=i||[5,20],c=n.map(e=>{var i;return null===(i=e.data)||void 0===i?void 0:i[t]}).filter(t=>null!=t&&"number"==typeof t);if(0===c.length)return()=>a[0];const l=null!==(o=r.min(c))&&void 0!==o?o:0,u=null!==(s=r.max(c))&&void 0!==s?s:1;if(l===u)return()=>(a[0]+a[1])/2;const h=e.scaleLinear().domain([l,u]).range(a).clamp(!0);return e=>{var i;const n=null===(i=e.data)||void 0===i?void 0:i[t];return null==n||"number"!=typeof n?a[0]:h(n)}}const $t=n.schemeCategory10,Wt={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,i,n){if(0===t.length)return;const{padAngle:r=.01,groupWidth:o=20,sortGroups:s}=i,l=Math.min(n[0],n[1])/2,u=l-o,h=n[0]/2,f=n[1]/2,d=(g=i.valueAccessor)?"function"==typeof g?g:t=>{var e;return null!==(e=t[g])&&void 0!==e?e:1}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:1};var g;const y=new Map;for(let e=0;t.length>e;e++)y.set(t[e].id,e);const p=t.length,m=Array.from({length:p},()=>Array.from({length:p},()=>0));for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,i=y.get("string"==typeof t.source?t.source:t.source.id),n=y.get(e);if(void 0===i||void 0===n)continue;const r=d(t);m[i][n]=r}const v=a.chord().padAngle(r);s&&v.sortGroups(s);const x=v(m),b=x.groups,k=c.arc().innerRadius(u).outerRadius(l);for(const e of b){const i=t[e.index],n=k.centroid(e);i.x=n[0]+h,i.y=n[1]+f,i.arcData={startAngle:e.startAngle,endAngle:e.endAngle}}const w=new Map;for(const e of t)w.set(e.id,e);for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,i=w.get("string"==typeof t.source?t.source:t.source.id),n=w.get(e);i&&(t.source=i),n&&(t.target=n)}const _=new Map;for(const t of e)_.set(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const e of x){const i=t[e.source.index].id,n=t[e.target.index].id,r=_.get(`${i}\0${n}`)||_.get(`${n}\0${i}`);r&&(r.chordData=e)}},buildScene(t,e,i,n){var r,o;const{groupWidth:s=20,edgeOpacity:c=.5}=i,l=Math.min(n[0],n[1])/2,u=l-s,h=n[0]/2,f=n[1]/2,d=i.nodeStyle,g=i.edgeStyle,y=i.edgeColorBy||"source",p=Array.isArray(i.colorScheme)?i.colorScheme:$t,m=new Map;t.forEach((t,e)=>{m.set(t.id,p[e%p.length])});const v=a.ribbon().radius(u),x=[],b=[],k=[];for(let e=0;t.length>e;e++){const i=t[e],n=i.arcData;if(!n)continue;let o;o=d?d(Mt(i,"nodeStyle")).fill||m.get(i.id)||p[e%p.length]:m.get(i.id)||p[e%p.length];const s=d?d(Mt(i,"nodeStyle")):{},a={fill:o,stroke:s.stroke||"black",strokeWidth:null!==(r=s.strokeWidth)&&void 0!==r?r:1,opacity:s.opacity};x.push({type:"arc",cx:h,cy:f,innerR:u,outerR:l,startAngle:n.startAngle-Math.PI/2,endAngle:n.endAngle-Math.PI/2,style:a,datum:i,id:i.id,label:i.id})}for(const t of e){const e=t.chordData;if(!e)continue;const i=v(e);if(!i)continue;const n=jt(i,h,f);let r="#999";if(g)r=g(Mt(t,"edgeStyle")).fill||r;else{const e="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;"target"===y&&i?r=m.get(i.id)||r:e&&(r=m.get(e.id)||r)}const s=g?g(Mt(t,"edgeStyle")):{},a={fill:r,fillOpacity:null!==(o=s.fillOpacity)&&void 0!==o?o:c,stroke:s.stroke||"none",strokeWidth:s.strokeWidth,opacity:s.opacity};b.push({type:"ribbon",pathD:n,style:a,datum:t})}if(!1!==i.showLabels){const e=(w=i.nodeLabel)?"function"==typeof w?w:t=>t[w]||t.id:null,n=l+12;for(const i of t){const t=i.arcData;if(!t)continue;const r=e?e(i):i.id;if(!r)continue;const o=(t.startAngle+t.endAngle)/2,s=o-Math.PI/2;k.push({x:h+Math.cos(s)*n,y:f+Math.sin(s)*n,text:r+"",anchor:o>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var w;return{sceneNodes:x,sceneEdges:b,labels:k}}};function jt(t,e,i){const n=t.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!n)return t;const r=[];let o=0;for(;n.length>o;){const t=n[o];if("M"===t||"L"===t)for(r.push(t),o++;n.length>o&&!isNaN(Number(n[o]));)r.push(Number(n[o])+e+""),o++,n.length>o&&!isNaN(Number(n[o]))&&(r.push(Number(n[o])+i+""),o++);else if("C"===t)for(r.push(t),o++;n.length>o&&!isNaN(Number(n[o]));)for(let t=0;3>t&&n.length>o&&!isNaN(Number(n[o]));t++)r.push(Number(n[o])+e+""),o++,n.length>o&&!isNaN(Number(n[o]))&&(r.push(Number(n[o])+i+""),o++);else if("Q"===t)for(r.push(t),o++;n.length>o&&!isNaN(Number(n[o]));)for(let t=0;2>t&&n.length>o&&!isNaN(Number(n[o]));t++)r.push(Number(n[o])+e+""),o++,n.length>o&&!isNaN(Number(n[o]))&&(r.push(Number(n[o])+i+""),o++);else if("A"===t)for(r.push(t),o++;n.length>o&&!isNaN(Number(n[o]));)r.push(n[o++]),n.length>o&&r.push(n[o++]),n.length>o&&r.push(n[o++]),n.length>o&&r.push(n[o++]),n.length>o&&r.push(n[o++]),n.length>o&&(r.push(Number(n[o])+e+""),o++),n.length>o&&(r.push(Number(n[o])+i+""),o++);else"Z"===t||"z"===t?(r.push(t),o++):(r.push(n[o]),o++)}return r.join(" ")}const Ct=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Rt(t){const[e,i,n]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(t);return.299*e+.587*i+.114*n>150?"#222":"#fff"}function zt(t,e,i){const n=e.nodeIDAccessor;return"function"==typeof n?n(t.data)+"":"string"==typeof n&&void 0!==t.data[n]?t.data[n]+"":void 0!==t.data.name?t.data.name+"":void 0!==t.data.id?t.data.id+"":"node-"+i}function Bt(t){return t?"function"==typeof t?t:e=>{var i;return(null===(i=e.data)||void 0===i?void 0:i[t])||e[t]||e.id}:null}function It(t,e,i,n,r){if("horizontal"===r){const r=(t+i)/2;return`M ${t},${e} C ${r},${e} ${r},${n} ${i},${n}`}if("radial"===r){const r=(t+i)/2;return`M ${t},${e} Q ${r},${e} ${r},${(e+n)/2} T ${i},${n}`}{const r=(e+n)/2;return`M ${t},${e} C ${t},${r} ${i},${r} ${i},${n}`}}const Yt={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,i,n){var r;const o=i.__hierarchyRoot;if(!o)return;const s=i.chartType,a=function(t){if(t)return"function"==typeof t?t:e=>e[t]}(i.childrenAccessor),c=i.hierarchySum||(t=>{var e;return null!==(e=t.value)&&void 0!==e?e:0}),u=l.hierarchy(o,a);u.sum(c),u.sort((t,e)=>{var i,n;return(null!==(i=e.value)&&void 0!==i?i:0)-(null!==(n=t.value)&&void 0!==n?n:0)});const[h,f]=n;switch(s){case"tree":!function(t,e,i,n){const r=e.treeOrientation||"vertical",o=l.tree();o.size("horizontal"===r?[n,i]:"radial"===r?[2*Math.PI,Math.min(i,n)/2*.8]:[i,n]),o(t)}(u,i,h,f);break;case"cluster":!function(t,e,i,n){const r=e.treeOrientation||"vertical",o=l.cluster();o.size("horizontal"===r?[n,i]:"radial"===r?[2*Math.PI,Math.min(i,n)/2*.8]:[i,n]),o(t)}(u,i,h,f);break;case"treemap":!function(t,e,i,n){var r,o;const s=null!==(r=e.padding)&&void 0!==r?r:4,a=null!==(o=e.paddingTop)&&void 0!==o?o:0,c=l.treemap().size([i,n]).tile(l.treemapBinary).padding(s);a>0&&c.paddingTop(a),c(t)}(u,i,h,f);break;case"circlepack":!function(t,e,i,n){var r;const o=null!==(r=e.padding)&&void 0!==r?r:4;l.pack().size([i,n]).padding(o)(t)}(u,i,h,f);break;case"partition":!function(t,e,i,n){var r;l.partition().size([i,n]).padding(null!==(r=e.padding)&&void 0!==r?r:1)(t)}(u,i,h,f)}const d=u.descendants();t.length=0,e.length=0;const g=new Map;for(let e=0;d.length>e;e++){const n=d[e],o={id:zt(n,i,e),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(r=n.value)&&void 0!==r?r:0,depth:n.depth,data:n.data,createdByFrame:!0};"tree"===s||"cluster"===s?Ft(o,n,i):"treemap"===s||"partition"===s?Xt(o,n):"circlepack"===s&&qt(o,n),o.__hierarchyNode=n,t.push(o),g.set(n,o)}if("tree"===s||"cluster"===s)for(const t of d)if(t.parent){const i=g.get(t.parent),n=g.get(t);i&&n&&e.push({source:i,target:n,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,i,n){const r=i.nodeStyle||(()=>({})),o=i.edgeStyle||(()=>({}));switch(i.chartType){case"tree":case"cluster":return function(t,e,i,n,r,o){var s,a,c,l,u;const h=[],f=[],d=[],g=i.treeOrientation||"vertical",y="radial"===g,p=n[0]/2,m=n[1]/2,v="number"==typeof(x=i.nodeSize)?x:5;var x;for(const e of t){let t=e.x,n=e.y;y&&(t+=p,n+=m);const o=r(Mt(e,"nodeStyle"));let a=o.fill||"#4d430c";i.colorByDepth&&void 0!==e.depth&&(a=Ct[e.depth%Ct.length]);const c={fill:a,stroke:o.stroke||"#fff",strokeWidth:null!==(s=o.strokeWidth)&&void 0!==s?s:1,opacity:o.opacity};h.push({type:"circle",cx:t,cy:n,r:v,style:c,datum:e,id:e.id,label:e.id,depth:e.depth})}const b=null!==(a=i.edgeOpacity)&&void 0!==a?a:.5;for(const t of e){const e="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;if(!e||!i)continue;let n=e.x,r=e.y,s=i.x,a=i.y;y&&(n+=p,r+=m,s+=p,a+=m);const u=It(n,r,s,a,g),h=o(Mt(t,"edgeStyle")),d={fill:"none",stroke:h.stroke||"#999",strokeWidth:null!==(c=h.strokeWidth)&&void 0!==c?c:1.5,opacity:null!==(l=h.opacity)&&void 0!==l?l:b};f.push({type:"curved",pathD:u,style:d,datum:t})}if(!1!==i.showLabels){const e=Bt(i.nodeLabel);for(const i of t){const t=e?e(i):i.id;if(!t)continue;let n,r,o,s=i.x,a=i.y;if(y&&(s+=p,a+=m),y){const t=s-p,e=a-m,i=Math.sqrt(t*t+e*e);i>0?(n=s+t/i*10,r=a+e/i*10,o=0>t?"end":"start"):(n=s,r=a-12,o="middle")}else"horizontal"===g?((null===(u=i.data)||void 0===u?void 0:u.children)&&0!==i.data.children.length?(n=s-v-6,o="end"):(n=s+v+6,o="start"),r=a):(n=s,r=a+v+14,o="middle");d.push({x:n,y:r,text:t+"",anchor:o,baseline:"middle",fontSize:11})}}return{sceneNodes:h,sceneEdges:f,labels:d}}(t,e,i,n,r,o);case"treemap":case"partition":return function(t,e,i,n){var r,o;const s=[],a=[];for(const i of t){const t=i.x1-i.x0,o=i.y1-i.y0;if(0>=t||0>=o)continue;const a=n(Mt(i,"nodeStyle"));let c=a.fill||"#4d430c";e.colorByDepth&&void 0!==i.depth&&(c=Ct[i.depth%Ct.length]);const l={fill:c,stroke:a.stroke||"#fff",strokeWidth:null!==(r=a.strokeWidth)&&void 0!==r?r:1,opacity:a.opacity};s.push({type:"rect",x:i.x0,y:i.y0,w:t,h:o,style:l,datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==e.showLabels){const i=Bt(e.nodeLabel),r=e.labelMode||"leaf",s="partition"===e.chartType;for(const c of t){const t=c.x1-c.x0,l=c.y1-c.y0;if(0>=t||0>=l)continue;const u=!((null===(o=c.data)||void 0===o?void 0:o.children)&&c.data.children.length>0);if(!s){if("leaf"===r&&!u)continue;if("parent"===r&&u)continue}const h=i?i(c):c.id;if(!h)continue;if((u?30:40)>t||(u?16:14)>l)continue;let f=n(Mt(c,"nodeStyle")).fill||"#4d430c";e.colorByDepth&&void 0!==c.depth&&(f=Ct[c.depth%Ct.length]);const d=Rt(f);a.push(u?{x:c.x0+t/2,y:c.y0+l/2,text:h+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,l)/6)),fill:d}:{x:c.x0+4,y:c.y0+12,text:h+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:d})}}return{sceneNodes:s,sceneEdges:[],labels:a}}(t,i,0,r);case"circlepack":return function(t,e,i,n){var r,o,s,a,c;const l=[],u=[];for(const i of t){const t=null!==(r=i.__radius)&&void 0!==r?r:5;if(0>=t)continue;const a=n(Mt(i,"nodeStyle"));let c=a.fill||"#4d430c";e.colorByDepth&&void 0!==i.depth&&(c=Ct[i.depth%Ct.length]);const u={fill:c,stroke:a.stroke||"#fff",strokeWidth:null!==(o=a.strokeWidth)&&void 0!==o?o:1,opacity:null!==(s=a.opacity)&&void 0!==s?s:.7};l.push({type:"circle",cx:i.x,cy:i.y,r:t,style:u,datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==e.showLabels){const i=Bt(e.nodeLabel);for(const r of t){const t=null!==(a=r.__radius)&&void 0!==a?a:5,o=i?i(r):r.id;if(!o)continue;if(15>t)continue;const s=!((null===(c=r.data)||void 0===c?void 0:c.children)&&r.data.children.length>0);let l=n(Mt(r,"nodeStyle")).fill||"#4d430c";if(e.colorByDepth&&void 0!==r.depth&&(l=Ct[r.depth%Ct.length]),s){const e=Rt(l);u.push({x:r.x,y:r.y,text:o+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,t/3)),fill:e})}else u.push({x:r.x,y:r.y-t+14,text:o+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,t/3)),fill:"#000",stroke:"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:l,sceneEdges:[],labels:u}}(t,i,0,r);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Ft(t,e,i){const n=i.treeOrientation||"vertical";if("radial"===n){const i=e.x,n=e.y;t.x=n*Math.cos(i-Math.PI/2),t.y=n*Math.sin(i-Math.PI/2)}else"horizontal"===n?(t.x=e.y,t.y=e.x):(t.x=e.x,t.y=e.y);t.x0=t.x-5,t.x1=t.x+5,t.y0=t.y-5,t.y1=t.y+5,t.width=10,t.height=10}function Xt(t,e){t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.x=(e.x0+e.x1)/2,t.y=(e.y0+e.y1)/2,t.width=e.x1-e.x0,t.height=e.y1-e.y0}function qt(t,e){var i;const n=null!==(i=e.r)&&void 0!==i?i:0;t.x=e.x,t.y=e.y,t.x0=e.x-n,t.x1=e.x+n,t.y0=e.y-n,t.y1=e.y+n,t.width=2*n,t.height=2*n,t.__radius=n}function Gt(t){const e=t;return e.__orbitState||(e.__orbitState={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()}),e.__orbitState}const Vt={sankey:Lt,force:Dt,chord:Wt,tree:Yt,cluster:Yt,treemap:Yt,circlepack:Yt,partition:Yt,orbit:{supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(t,e,i,n){const r=i.__hierarchyRoot;r&&function(t,e,i,n,r){var o,s;const a=function(t){if("function"==typeof t)return t;const e=t||"children";return t=>t[e]||null}(i.childrenAccessor),l=function(t){if("function"==typeof t)return t;const e=t||"name";return t=>{var i;return(null!==(i=t[e])&&void 0!==i?i:"")+""}}(i.nodeIDAccessor),u=function(t){if(Array.isArray(t))return t;switch(t){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(i.orbitMode),h=null!==(o=i.orbitSize)&&void 0!==o?o:2.95,f=null!==(s=i.orbitEccentricity)&&void 0!==s?s:1,d="number"==typeof h?()=>h:h,g="number"==typeof f?()=>f:f,y=Gt(i);y.metaMap.clear(),n.length=0,r.length=0;const p=new Map;function m(t){var e;const i=null!==(e=p.get(t))&&void 0!==e?e:0;return p.set(t,i+1),0===i?t:`${t}__${i}`}const v=e[0]/2,x=e[1]/2,b=Math.min(e[0],e[1])/2*.85,k=m(l(t));n.push({id:k,x:v,y:x,x0:v,x1:v,y0:x,y1:x,width:0,height:0,value:0,depth:0,data:t}),y.metaMap.set(k,{ring:b,angle:0,depth:0,parentId:null,eccentricity:1}),function t(e,i,o,s,h,f,p){const v=a(e);if(!(null==v?void 0:v.length))return;const x=v.length;let b=0,k=0,w=0;for(;x>k;)k+=u[Math.min(w,u.length-1)],w++,b++;let _=0;for(let x=0;b>x;x++){const k=u[Math.min(x,u.length-1)],w=v.slice(_,_+k);if(!w.length)break;const A=(x+1)/b,P={id:i,depth:f,data:e,parentId:i},S=p?h/d(P)*A:h*A,M=c.pie().value(t=>{var e;return(null===(e=a(t))||void 0===e?void 0:e.length)?4:1}).sort(null),E=M(w),L=g(P);for(let e=0;w.length>e;e++){const a=(E[e].startAngle+E[e].endAngle)/2,c=w[e],u=m(l(c)),h=o+S*Math.sin(a),d=s+S*Math.cos(a)*L;n.push({id:u,x:h,y:d,x0:h,x1:h,y0:d,y1:d,width:0,height:0,value:0,depth:f,data:c}),y.metaMap.set(u,{ring:S,angle:a,depth:f,parentId:i,eccentricity:L}),r.push({source:i,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:i,target:u}}),t(c,u,h,d,S,f+1,!0)}_+=k}}(t,k,v,x,b,1,!1)}(r,n,i,t,e)},buildScene(t,e,i,n){var r,o,s,a,c;const l=i.nodeStyle,u=i.nodeSize,h="number"==typeof u?()=>u:"function"==typeof u?u:()=>6,f=[],d=[],g=[];if(!1!==i.orbitShowRings){const e=Gt(i),n=new Map;for(const e of t)n.set(e.id,e);const r=new Map;for(const[,t]of e.metaMap){if(!t.parentId)continue;const e=n.get(t.parentId);if(!e)continue;const i=`${t.parentId}:${t.ring}`;r.has(i)||r.set(i,{parentX:e.x,parentY:e.y,ring:t.ring,ecc:t.eccentricity})}const o=48,s={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:t,parentY:e,ring:i,ecc:n}]of r)for(let r=0;o>r;r++){const a=r/o*Math.PI*2,c=(r+1)/o*Math.PI*2;d.push({type:"line",x1:t+i*Math.sin(a),y1:e+i*Math.cos(a)*n,x2:t+i*Math.sin(c),y2:e+i*Math.cos(c)*n,style:s,datum:null})}}for(const e of t){if(null==e.x||null==e.y)continue;const t=h(Mt(e,"nodeSize")),i=l?l(Mt(e,"nodeStyle")):{},n={fill:i.fill||"#6366f1",stroke:i.stroke||"#fff",strokeWidth:null!==(r=i.strokeWidth)&&void 0!==r?r:1,opacity:null!==(o=i.opacity)&&void 0!==o?o:0===(null!==(s=e.depth)&&void 0!==s?s:0)?1:.85};f.push({type:"circle",cx:e.x,cy:e.y,r:t,style:n,datum:e,id:e.id,label:e.id,depth:e.depth})}const y=new Map;for(const e of t)y.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:y.get(t.source),i="object"==typeof t.target?t.target:y.get(t.target);e&&i&&(null!=e.x&&null!=i.x&&d.push({type:"line",x1:e.x,y1:e.y,x2:i.x,y2:i.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:t}))}if(i.showLabels){const e=i.nodeLabel;for(const i of t){const t=h(Mt(i,"nodeSize"));if(4>=t)continue;const n="function"==typeof e?e(i):e&&null!==(c=null===(a=i.data)||void 0===a?void 0:a[e])&&void 0!==c?c:i.id;g.push({x:i.x,y:i.y+t+12,text:n+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:f,sceneEdges:d,labels:g}},tick:(t,e,i,n,r)=>!1!==i.orbitAnimated&&(function(t,e){var i,n;const r=Gt(e),o=null!==(i=e.orbitSpeed)&&void 0!==i?i:.25,s=null!==(n=e.orbitRevolution)&&void 0!==n?n:function(t){switch(t){case"decay":return t=>{var e;return Math.pow(.6,null!==(e=t.depth)&&void 0!==e?e:0)};case"alternate":return t=>{var e;const i=null!==(e=t.depth)&&void 0!==e?e:0;return(i%2==0?1:-1)/(i+1)};default:return t=>{var e;return 1/((null!==(e=t.depth)&&void 0!==e?e:0)+1)}}}(e.orbitRevolutionStyle),a=(("undefined"!=typeof performance?performance.now():Date.now())-r.startTime)/1e3,c=o*(Math.PI/6),l=new Map;for(const e of t)l.set(e.id,e);for(const e of t){const t=r.metaMap.get(e.id);if(!t||!t.parentId)continue;const i=l.get(t.parentId);if(!i)continue;const n=t.angle+a*c*s({id:e.id,depth:t.depth,data:e.data,parentId:t.parentId});e.x=i.x+t.ring*Math.sin(n),e.y=i.y+t.ring*Math.cos(n)*t.eccentricity,e.x0=e.x,e.x1=e.x,e.y0=e.y,e.y1=e.y}}(t,i),!0)}};function Ht(t,e){const{columns:i,config:n,resolvePieceStyle:r}=t,o=[],s=Math.min(e.width,e.height)/2-4,a="donut"===n.chartType?n.innerRadius||60:0,c=-Math.PI/2+(n.startAngle||0)*Math.PI/180,l=null!=n.sweepAngle?n.sweepAngle*Math.PI/180:2*Math.PI;for(const t of Object.values(i)){const e=c+t.pctStart*l,i=c+(t.pctStart+t.pct)*l,n=r(t.pieceData[0],t.name);o.push({type:"wedge",cx:0,cy:0,innerRadius:a,outerRadius:s,startAngle:e,endAngle:i,style:n,datum:t.pieceData,category:t.name})}return o}function Zt(t){var e,i,n;const o=t.length,s=t[0],a=t[o-1];return{n:o,min:s,q1:null!==(e=r.quantile(t,.25))&&void 0!==e?e:s,median:null!==(i=r.quantile(t,.5))&&void 0!==i?i:(s+a)/2,q3:null!==(n=r.quantile(t,.75))&&void 0!==n?n:a,max:a,mean:t.reduce((t,e)=>t+e,0)/o}}const Kt={bar:function(t,e){const{scales:i,columns:n,config:r,getR:o,getStack:s,resolvePieceStyle:a}=t,{r:c,projection:l}=i,u=[],h="vertical"===l,f="horizontal"===l,d=r.normalize,g=[];if(s){const t=new Set;for(const e of Object.values(n))for(const i of e.pieceData){const e=s(i);t.has(e)||(t.add(e),g.push(e))}}else g.push("_default");for(const t of Object.values(n)){const e=new Map;for(const i of t.pieceData){const t=s?s(i):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const n=e.get(t);n.total+=o(i),n.pieces.push(i)}let i=0;if(d)for(const t of e.values())i+=Math.abs(t.total);let n=0,r=0;for(const o of g){const l=e.get(o);if(!l)continue;let g=l.total;d&&i>0&&(g/=i);const y=a(l.pieces[0],s?o:t.name),p=Object.assign(Object.assign({},l.pieces[0]),{__aggregateValue:l.total,__pieceCount:l.pieces.length,category:t.name});if(h){const e=c(0>g?r:n+g),i=0>g?c(r+g)-c(r):c(n)-c(n+g);u.push(O(t.x,e,t.width,Math.abs(i),y,p,o)),0>g?r+=g:n+=g}else if(f){const e=c(0>g?r+g:n),i=0>g?c(r)-c(r+g):c(n+g)-c(n);u.push(O(e,t.x,Math.abs(i),t.width,y,p,o)),0>g?r+=g:n+=g}}}return u},clusterbar:function(t,e){const{scales:i,columns:n,getR:r,getGroup:o,resolvePieceStyle:s}=t,{r:a,projection:c}=i,l=[],u="vertical"===c,h=[],f=new Set;for(const t of Object.values(n))for(const e of t.pieceData){const t=o?o(e):"_default";f.has(t)||(f.add(t),h.push(t))}const d=h.length||1;for(const t of Object.values(n)){const e=t.width/d,i=.2*e,n=e-i,c=new Map;for(const e of t.pieceData){const t=o?o(e):"_default";c.has(t)||c.set(t,[]),c.get(t).push(e)}for(let o=0;h.length>o;o++){const f=c.get(h[o])||[];for(const c of f){const f=r(c),d=s(c,h[o]);if(u){const r=t.x+o*e+i/2,s=a(0),u=a(f);l.push(O(r,Math.min(s,u),n,Math.abs(s-u),d,c,h[o]))}else{const r=t.x+o*e+i/2,s=a(0),u=a(f);l.push(O(Math.min(s,u),r,Math.abs(u-s),n,d,c,h[o]))}}}}return l},point:function(t,e){var i,n;const{scales:r,columns:o,getR:s,multiScales:a,resolvePieceStyle:c}=t,{r:l,projection:u}=r,h=[],f="vertical"===u,d="radial"===u,g=a.length>0,y=2*Math.PI,p=-Math.PI/2;for(const t of Object.values(o))for(const e of t.pieceData){const r=null!==(i=e.__rIndex)&&void 0!==i?i:0,o=null!==(n=e.__rValue)&&void 0!==n?n:s(e),u=g&&a[r]||l,m=c(e,t.name),v=m.r||5;let x,b;if(d){const e=p+(t.pctStart+t.pct/2)*y,i=u(o);x=Math.cos(e)*i,b=Math.sin(e)*i}else f?(x=t.middle,b=u(o)):(x=u(o),b=t.middle);h.push({type:"point",x:x,y:b,r:v,style:m,datum:e})}return h},swarm:function(t,e){const{scales:i,columns:n,getR:r,resolvePieceStyle:o}=t,{r:s,projection:a}=i,c=[],l="vertical"===a;for(const t of Object.values(n)){const e=t.width/2;for(let i=0;t.pieceData.length>i;i++){const n=t.pieceData[i],a=r(n),u=o(n,t.name),h=u.r||4,f=(7919*i%100/100-.5)*e*.8,d=l?t.middle+f:s(a),g=l?s(a):t.middle+f;c.push({type:"point",x:d,y:g,r:h,style:u,datum:n})}}return c},pie:Ht,donut:Ht,boxplot:function(t,e){var i,n,o,s,a;const{scales:c,columns:l,config:u,getR:h,resolveSummaryStyle:f}=t,{r:d,projection:g}=c,y=[],p="vertical"===g,m=!1!==u.showOutliers;for(const t of Object.values(l)){const e=t.pieceData.map(t=>h(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(0===e.length)continue;const c=e[0],l=e[e.length-1],u=null!==(i=r.quantile(e,.25))&&void 0!==i?i:c,g=null!==(n=r.quantile(e,.5))&&void 0!==n?n:(c+l)/2,v=null!==(o=r.quantile(e,.75))&&void 0!==o?o:l,x=v-u,b=u-1.5*x,k=v+1.5*x,w=null!==(s=e.find(t=>t>=b))&&void 0!==s?s:c,_=null!==(a=[...e].reverse().find(t=>k>=t))&&void 0!==a?a:l,A=f(t.pieceData[0],t.name),P=[];if(m)for(const e of t.pieceData){const i=h(e);if(b>i||i>k){const n=p?t.middle:d(i),r=p?d(i):t.middle;P.push({px:n,py:r,value:i,datum:e})}}if(y.push({type:"boxplot",x:p?t.middle:0,y:p?0:t.middle,projection:p?"vertical":"horizontal",columnWidth:.6*t.width,minPos:d(w),q1Pos:d(u),medianPos:d(g),q3Pos:d(v),maxPos:d(_),stats:{n:e.length,min:w,q1:u,median:g,q3:v,max:_,mean:e.reduce((t,e)=>t+e,0)/e.length},style:A,datum:t.pieceData,category:t.name,outliers:P}),m)for(const t of P)y.push({type:"point",x:t.px,y:t.py,r:3,style:{fill:A.fill||"#999",opacity:.6},datum:t.datum})}return y},violin:function(t,e){var i,n,o;const{scales:s,columns:a,config:c,getR:l,resolveSummaryStyle:u}=t,{r:h,projection:f}=s,d=[],g="vertical"===f,y=c.bins||20,p=!1!==c.showIQR;for(const t of Object.values(a)){const e=t.pieceData.map(t=>l(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const s=e[0],a=e[e.length-1],c=(a-s)/y||1,f=Array(y).fill(0);for(const t of e)f[Math.min(Math.floor((t-s)/c),y-1)]++;const m=Math.max(...f,1),v=t.width/2*.9;let x="";if(g){x=`M ${t.middle} ${h(s)}`;for(let e=0;y>e;e++){const i=h(s+(e+.5)*c);x+=` L ${t.middle+f[e]/m*v} ${i}`}x+=` L ${t.middle} ${h(a)}`;for(let e=y-1;e>=0;e--){const i=h(s+(e+.5)*c);x+=` L ${t.middle-f[e]/m*v} ${i}`}x+=" Z"}else{x=`M ${h(s)} ${t.middle}`;for(let e=0;y>e;e++)x+=` L ${h(s+(e+.5)*c)} ${t.middle-f[e]/m*v}`;x+=` L ${h(a)} ${t.middle}`;for(let e=y-1;e>=0;e--)x+=` L ${h(s+(e+.5)*c)} ${t.middle+f[e]/m*v}`;x+=" Z"}const b=u(t.pieceData[0],t.name);let k;if(p&&e.length>=4){const c=null!==(i=r.quantile(e,.25))&&void 0!==i?i:s,l=null!==(n=r.quantile(e,.5))&&void 0!==n?n:(s+a)/2,u=null!==(o=r.quantile(e,.75))&&void 0!==o?o:a;k={q1Pos:h(c),medianPos:h(l),q3Pos:h(u),centerPos:t.middle,isVertical:g}}const w=g?{x:t.x,y:Math.min(h(a),h(s)),width:t.width,height:Math.abs(h(a)-h(s))}:{x:Math.min(h(s),h(a)),y:t.x,width:Math.abs(h(a)-h(s)),height:t.width};d.push({type:"violin",pathString:x,translateX:0,translateY:0,bounds:w,iqrLine:k,stats:Zt(e),style:b,datum:t.pieceData,category:t.name})}return d},histogram:function(t,e){var i;const{scales:n,columns:r,config:o,getR:s,resolveSummaryStyle:a}=t,{r:c}=n,l=[],u=o.bins||25,h=o.normalize,f=null===(i=c.domain)||void 0===i?void 0:i.call(c),d=f?+f[0]:void 0,g=f?+f[1]:void 0;for(const t of Object.values(r)){const e=t.pieceData.map(t=>s(t)).filter(t=>null!=t&&!isNaN(t));if(0===e.length)continue;const i=null!=d&&isFinite(d)?d:Math.min(...e),n=null!=g&&isFinite(g)?g:Math.max(...e),r=(n-i)/u||1,o=Array(u).fill(0);for(const t of e)i>t||t>n||o[Math.min(Math.floor((t-i)/r),u-1)]++;const f=e.length,y=Math.max(...o,1),p=a(t.pieceData[0],t.name);for(let e=0;u>e;e++){if(0===o[e])continue;const n=(h?o[e]/f:o[e]/y)*t.width*.9,s=c(i+e*r),a=c(i+(e+1)*r);l.push(O(Math.min(s,a),t.x+t.width-n,Math.abs(a-s),n,p,{bin:e,count:o[e],range:[i+e*r,i+(e+1)*r],category:t.name},t.name))}}return l},ridgeline:function(t,e){var i;const{scales:n,columns:r,config:o,getR:s,resolveSummaryStyle:a}=t,{r:c,projection:l}=n,u=[],h=o.bins||20,f="horizontal"===l,d=o.amplitude||1.5;for(const t of Object.values(r)){const e=t.pieceData.map(t=>s(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const n=e[0],r=e[e.length-1],o=(r-n)/h||1,l=Array(h).fill(0);for(const t of e)n>t||t>r||l[Math.min(Math.floor((t-n)/o),h-1)]++;const g=Math.max(...l,1),y=a(t.pieceData[0],t.name),p=t.width*d;let m="";if(f){const e=t.x+t.width;m=`M ${c(n)} ${e}`;for(let t=0;h>t;t++)m+=` L ${c(n+(t+.5)*o)} ${e-l[t]/g*p}`;m+=` L ${c(r)} ${e} Z`}else{const e=t.x;m=`M ${e} ${c(n)}`;for(let t=0;h>t;t++){const i=c(n+(t+.5)*o);m+=` L ${e+l[t]/g*p} ${i}`}m+=` L ${e} ${c(r)} Z`}const v=f?{x:Math.min(c(n),c(r)),y:t.x,width:Math.abs(c(r)-c(n)),height:t.width}:{x:t.x,y:Math.min(c(r),c(n)),width:t.width,height:Math.abs(c(r)-c(n))};u.push({type:"violin",pathString:m,translateX:0,translateY:0,bounds:v,stats:Zt(e),style:Object.assign(Object.assign({},y),{fillOpacity:null!==(i=y.fillOpacity)&&void 0!==i?i:.5}),datum:t.pieceData,category:t.name})}return u},timeline:function(t,e){const{scales:i,columns:n,getRawRange:r,resolvePieceStyle:o}=t,{r:s,projection:a}=i,c=[],l="horizontal"===a;for(const t of Object.values(n))for(const e of t.pieceData){const i=r(e);if(!i)continue;const[n,a]=i,u=o(e,t.name);if(l){const i=s(Math.min(n,a)),r=s(Math.max(n,a));c.push(O(i,t.x,r-i,t.width,u,e,t.name))}else{const i=s(Math.max(n,a)),r=s(Math.min(n,a));c.push(O(t.x,i,t.width,r-i,u,e,t.name))}}return c},funnel:function(t,i){var n,r,o,s,a,c,l;const{columns:u,getR:h,getStack:f,resolvePieceStyle:d}=t,g=[],y=i.width/2,p=!1!==t.config.showLabels,m=t.scales.o.domain().map(t=>u[t]).filter(Boolean);if(0===m.length)return g;const v=[],x=new Set;for(const t of m)for(const e of t.pieceData){const t=f?f(e):"_default";x.has(t)||(x.add(t),v.push(t))}const b=v.length>1&&"_default"!==v[0],k=[];let w=0;for(const t of m){const e=new Map;let i=0;for(const n of t.pieceData){const t=f?f(n):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const r=e.get(t),o=h(n);r.total+=o,r.pieces.push(n),i+=o}k.push({col:t,groups:e,stepTotal:i}),b||i>w&&(w=i)}if(b)for(const t of k){let e=0,i=0;for(let n=0;v.length>n;n++){const r=t.groups.get(v[n]);r&&(n%2==0?e+=r.total:i+=r.total)}const n=Math.max(e,i);n>w&&(w=n)}if(0===w)return g;const _=new Map;for(const t of v){const e=k[0].groups.get(t);_.set(t,null!==(n=null==e?void 0:e.total)&&void 0!==n?n:0)}const A=k[0].stepTotal,P=b?.95*y:.9*i.width,S=e.scaleLinear().domain([0,w]).range([0,P]),M=null!==(r=t.config.connectorOpacity)&&void 0!==r?r:.3;let E=new Map;for(let t=0;k.length>t;t++){const e=k[t],i=e.col,n=0===t,r=i.width,u=.55*r,h=i.x+(r-u)/2,f=new Map;if(b){let t=0;for(const i of v){const n=e.groups.get(i);n&&(t+=S(n.total))}let r=y,o=y;for(let s=0;v.length>s;s++){const c=v[s],l=e.groups.get(c);if(!l)continue;const m=S(l.total),x=s%2==0,b=x?r:o-m;x?r+=m:o-=m;const k=d(l.pieces[0],c),w=null!==(a=_.get(c))&&void 0!==a?a:l.total,A=w>0?l.total/w*100:0,P=Object.assign(Object.assign({},l.pieces[0]),{__funnelValue:l.total,__funnelPercent:A,__funnelStep:i.name,__funnelIsFirstStep:n,__aggregateValue:l.total,__pieceCount:l.pieces.length,category:c});p&&(0===s&&(P.__funnelStepLabel=i.name,P.__funnelStepLabelX=y,P.__funnelStepLabelY=h,P.__funnelRowWidth=t),P.__funnelValueLabelX=b+m/2,P.__funnelValueLabelY=h,P.__funnelBarW=m),g.push(O(b,h,m,u,k,P,c)),f.set(c,{x:b,y:h,w:m,h:u})}}else{const t=e.stepTotal,r=S(t),a=y-r/2,c=v[0],l="_default"!==c,m=null!==(s=null===(o=e.groups.get(c))||void 0===o?void 0:o.pieces[0])&&void 0!==s?s:i.pieceData[0],x=l?c:i.name,b=d(m,x),k=A>0?t/A*100:0,w=Object.assign(Object.assign({},m),{__funnelValue:t,__funnelPercent:k,__funnelStep:i.name,__funnelIsFirstStep:n,category:l?c:i.name});p&&(w.__funnelStepLabel=i.name,w.__funnelStepLabelX=y,w.__funnelStepLabelY=h,w.__funnelRowWidth=r,w.__funnelValueLabelX=y,w.__funnelValueLabelY=h,w.__funnelBarW=r),g.push(O(a,h,r,u,b,w,x)),f.set(c,{x:a,y:h,w:r,h:u})}if(t>0&&E.size>0){const t=b?v:[v[0]];for(const n of t){const t=E.get(n),r=f.get(n);if(!t||!r)continue;const o=(()=>{const t=e.groups.get(n);return d(t?t.pieces[0]:i.pieceData[0],"_default"===n?i.name:n)})(),s={type:"trapezoid",points:[[t.x,t.y+t.h],[t.x+t.w,t.y+t.h],[r.x+r.w,r.y],[r.x,r.y]],style:{fill:o.fill||"#999",opacity:M},datum:null!==(l=null===(c=e.groups.get(n))||void 0===c?void 0:c.pieces[0])&&void 0!==l?l:i.pieceData[0],category:"_default"===n?i.name:n};g.push(s)}}E=f}return g},"bar-funnel":function(t,e){var i,n,r,o;const{columns:s,getR:a,getStack:c,resolvePieceStyle:l,scales:u}=t,h=[],f=u.o.domain().map(t=>s[t]).filter(Boolean);if(0===f.length)return h;const d=[],g=new Set;for(const t of f)for(const e of t.pieceData){const t=c?c(e):"_default";g.has(t)||(g.add(t),d.push(t))}const y=d.length>1&&"_default"!==d[0],p=[];for(const t of f){const e=new Map;let i=0;for(const n of t.pieceData){const t=c?c(n):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const r=e.get(t),o=a(n);r.total+=o,r.pieces.push(n),i+=o}p.push({col:t,groups:e,stepTotal:i})}const m=new Map;for(const t of d){const e=null===(i=p[0])||void 0===i?void 0:i.groups.get(t);m.set(t,null!==(n=null==e?void 0:e.total)&&void 0!==n?n:0)}const v=u.r,x=y?d.length:1,b=y?.15:0;for(let t=0;p.length>t;t++){const e=p[t],i=e.col,n=0===t,s=t>0?p[t-1]:null,a=i.width/x,c=a*b,u=a-c;for(let t=0;d.length>t;t++){const f=d[t],g=e.groups.get(f);if(!g)continue;const p=g.total,x=null!==(r=m.get(f))&&void 0!==r?r:p,b=x>0?p/x*100:0,k=null==s?void 0:s.groups.get(f),w=null!==(o=null==k?void 0:k.total)&&void 0!==o?o:p,_=n?0:Math.max(0,w-p),A=i.x+t*a+c/2,P=v(p),S=v(0)-P,M=l(g.pieces[0],y?f:i.name),E=Object.assign(Object.assign({},g.pieces[0]),{__barFunnelValue:p,__barFunnelPercent:b,__barFunnelIsFirstStep:n,__barFunnelIsDropoff:!1,__barFunnelStep:i.name,__barFunnelDropoffValue:_,__barFunnelCategory:"_default"===f?void 0:f,category:y?f:i.name,__barFunnelLabelX:A+u/2,__barFunnelLabelY:v(p+_)});if(h.push(O(A,P,u,S,M,E,y?f:i.name)),_>0){const t=v(p+_),e=P-t,n=Object.assign({},M),r=Object.assign(Object.assign({},g.pieces[0]),{__barFunnelValue:_,__barFunnelPercent:x>0?_/x*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:i.name,__barFunnelCategory:"_default"===f?void 0:f,category:y?f:i.name});h.push(O(A,t,u,e,n,r,y?f:i.name))}}}return h},swimlane:function(t,e){const{scales:i,columns:n,getR:r,getStack:o,resolvePieceStyle:s}=t,{r:a,projection:c}=i,l=[],u="horizontal"===c;for(const t of Object.values(n)){let e=0;for(const i of t.pieceData){const n=Math.abs(r(i));if(0===n)continue;const c=o?o(i):t.name,h=s(i,c);if(u){const r=a(e),o=a(e+n);l.push(O(r,t.x,o-r,t.width,h,i,c))}else{const r=a(e+n),o=a(e);l.push(O(t.x,r,t.width,o-r,h,i,c))}e+=n}}return l}};class Qt{constructor(t){this.rExtent=new g,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=t,this.buffer=new d(t.windowSize),this.getO=x(t.oAccessor||t.categoryAccessor,"category");const e="streaming"===t.runtimeMode,i=t.rAccessor;Array.isArray(i)?(this.rAccessors=i.map(t=>m(t,"value")),this.getR=this.rAccessors[0],this.rExtents=i.map(()=>new g)):(this.getR=m(e&&(t.timeAccessor||t.valueAccessor)&&t.valueAccessor||i,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=x(t.stackBy),this.getGroup=x(t.groupBy),this.getColor=x(t.colorAccessor),this.getConnector=x(t.connectorAccessor),t.pulse&&(this.timestampBuffer=new d(t.windowSize))}ingest(t){const e="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=e,t.bounded){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const i=t.totalSize||t.inserts.length;i>this.buffer.capacity&&(this.buffer.resize(i),this.timestampBuffer&&i>this.timestampBuffer.capacity&&this.timestampBuffer.resize(i));for(const i of t.inserts)this.buffer.push(i),this.timestampBuffer&&this.timestampBuffer.push(e),this.categories.add(this.getO(i)),this.pushValueExtent(i)}else{this._hasStreamingData=!0;for(const i of t.inserts){const t=this.buffer.push(i);this.timestampBuffer&&this.timestampBuffer.push(e),this.categories.add(this.getO(i)),this.pushValueExtent(i),null!=t&&this.evictValueExtent(t)}}return!0}pushValueExtent(t){if("timeline"===this.config.chartType){const e=this.getRawRange(t);e&&(this.rExtent.push(e[0]),this.rExtent.push(e[1]))}else if(this.rAccessors.length>1){for(let e=0;this.rAccessors.length>e;e++)this.rExtents[e].push(this.rAccessors[e](t));this.rExtent.push(this.getR(t))}else this.rExtent.push(this.getR(t))}evictValueExtent(t){if("timeline"===this.config.chartType){const e=this.getRawRange(t);e&&(this.rExtent.evict(e[0]),this.rExtent.evict(e[1]))}else if(this.rAccessors.length>1){for(let e=0;this.rAccessors.length>e;e++)this.rExtents[e].evict(this.rAccessors[e](t));this.rExtent.evict(this.getR(t))}else this.rExtent.evict(this.getR(t))}getRawRange(t){const e=this.config.rAccessor;if(!e)return null;const i="function"==typeof e?e(t):t[e];return Array.isArray(i)&&i.length>=2?[+i[0],+i[1]]:null}computeScene(t){const{config:i,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(),o=i.projection||"vertical",s=i.oExtent||this.resolveCategories(r),a=this.computeValueDomain(r,s),c="horizontal"===o,l=null!=i.barPadding?i.barPadding/("vertical"===o?t.width:t.height):.1;let u,h;if("radial"===o){u=e.scaleBand().domain(s).range([0,1]).padding(0);const n=Math.min(t.width,t.height)/2,r=i.innerRadius||0;h=e.scaleLinear().domain(a).range([r,n])}else c?(u=e.scaleBand().domain(s).range([0,t.height]).padding(l),h=e.scaleLinear().domain(a).range([0,t.width])):(u=e.scaleBand().domain(s).range([0,t.width]).padding(l),h=e.scaleLinear().domain(a).range([t.height,0]));this.scales={o:u,r:h,projection:o},this.multiScales=this.rAccessors.length>1&&i.multiAxis?this.rAccessors.map((r,o)=>{const s=this.rExtents[o];s.dirty&&s.recalculate(n,r);let[a,l]=s.extent;a===1/0&&(a=0,l=1);const u=l-a,h=u>0?u*(i.extentPadding||.05):1;return a-=h,l+=h,a>0&&(a=0),c?e.scaleLinear().domain([a,l]).range([0,t.width]):e.scaleLinear().domain([a,l]).range([t.height,0])}):[];let f=r;this.rAccessors.length>1&&(f=r.flatMap(t=>this.rAccessors.map((e,i)=>Object.assign(Object.assign({},t),{__rIndex:i,__rValue:e(t),__rName:this.resolveRAccessorName(i)})))),this.columns=this.buildColumns(f,s,u,o,t),this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(f,t),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(t){const e=Array.isArray(this.config.rAccessor)?this.config.rAccessor[t]:this.config.rAccessor;return"string"==typeof e?e:"value"+t}resolveCategories(t){const e=Array.from(this.categories),i=this.config.oSort;if(("streaming"===this.config.runtimeMode||this._hasStreamingData)&&void 0===i){const i=new Set;for(const e of t)i.add(this.getO(e));const n=Math.max(50,3*i.size);if(this.categories.size>n){let t=this.categories.size-n;for(const e of this.categories){if(0>=t)break;i.has(e)||(this.categories.delete(e),t--)}}return e.filter(t=>i.has(t))}if(!1===i)return e;if("function"==typeof i)return e.sort(i);const n=new Map;for(const e of t){const t=this.getO(e);n.set(t,(n.get(t)||0)+Math.abs(this.getR(e)))}return e.sort("asc"===i?(t,e)=>(n.get(t)||0)-(n.get(e)||0):(t,e)=>(n.get(e)||0)-(n.get(t)||0))}computeValueDomain(t,e){var i,n,r,o;const s=this.config.chartType,a=this.config.extentPadding||.05;if("radial"===this.config.projection&&("pie"===s||"donut"===s))return[0,1];let c=0,l=0;if("bar"===s&&this.getStack&&this.config.normalize)c=0,l=1;else if("bar"===s&&this.getStack){const e=new Map,i=new Map;for(const n of t){const t=this.getO(n),r=this.getR(n);0>r?i.set(t,(i.get(t)||0)+r):e.set(t,(e.get(t)||0)+r)}for(const t of e.values())t>l&&(l=t);for(const t of i.values())c>t&&(c=t)}else if("bar"===s){const e=new Map;for(const i of t){const t=this.getO(i),n=this.getR(i);e.set(t,(e.get(t)||0)+n)}for(const t of e.values())t>l&&(l=t),c>t&&(c=t)}else if("swimlane"===s){const e=new Map;for(const i of t){const t=this.getO(i),n=Math.abs(this.getR(i));e.set(t,(e.get(t)||0)+n)}for(const t of e.values())t>l&&(l=t)}else if("clusterbar"===s||"bar-funnel"===s)for(const e of t){const t=this.getR(e);t>l&&(l=t),c>t&&(c=t)}else{const t=this.rExtent.extent[0],e=this.rExtent.extent[1];t!==1/0&&(c=t),e!==-1/0&&(l=e)}this.config.rExtent&&(null!=this.config.rExtent[0]&&(c=this.config.rExtent[0]),null!=this.config.rExtent[1]&&(l=this.config.rExtent[1]));const u="bar"===s||"clusterbar"===s||"bar-funnel"===s||"swimlane"===s;if(u&&null==(null===(i=this.config.rExtent)||void 0===i?void 0:i[0])&&null==(null===(n=this.config.rExtent)||void 0===n?void 0:n[1])&&(c>0&&(c=0),0>l&&(l=0)),"bar-funnel"!==s){const t=l-c,e=t>0?t*a:1;null!=(null===(r=this.config.rExtent)||void 0===r?void 0:r[0])||u&&!this.config.baselinePadding&&0===c||(c-=e),null!=(null===(o=this.config.rExtent)||void 0===o?void 0:o[1])||u&&!this.config.baselinePadding&&0===l||(l+=e)}return[c,l]}buildColumns(t,e,i,n,r){var o;const s={},a=new Map;for(const e of t){const t=this.getO(e);a.has(t)||a.set(t,[]),a.get(t).push(e)}let c=0;if("radial"===n)for(const e of t)c+=Math.abs(this.getR(e));const l=this.config.dynamicColumnWidth;let u=null;if(l&&"radial"!==n){u=new Map;let t=0;for(const i of e){const e=a.get(i)||[];let n;n="string"==typeof l?e.reduce((t,e)=>t+(Number(e[l])||0),0):l(e),u.set(i,n),t+=n}const o=("horizontal"===n?r.height:r.width)-i.padding()*i.step()*e.length;if(t>0)for(const[e,i]of u)u.set(e,i/t*o)}let h=0,f=0;for(const t of e){const e=a.get(t)||[],n=e.reduce((t,e)=>t+Math.abs(this.getR(e)),0),r=c>0?n/c:0;let l,d;u?(l=f,d=u.get(t)||i.bandwidth(),f+=d+i.padding()*i.step()):(l=null!==(o=i(t))&&void 0!==o?o:0,d=i.bandwidth()),s[t]={name:t,x:l,y:0,width:d,middle:l+d/2,padding:i.padding()*i.step(),pieceData:e,pct:r,pctStart:h},h+=r}return s}getSceneContext(){return{scales:this.scales,columns:this.columns,config:this.config,getR:this.getR,getStack:this.getStack,getGroup:this.getGroup,getColor:this.getColor,getConnector:this.getConnector,getO:this.getO,multiScales:this.multiScales,rAccessors:this.rAccessors,resolvePieceStyle:(t,e)=>this.resolvePieceStyle(t,e),resolveSummaryStyle:(t,e)=>this.resolveSummaryStyle(t,e),getRawRange:t=>this.getRawRange(t)}}buildSceneNodes(t,e){if(!this.scales)return[];const i=this.getSceneContext(),n=Kt[this.config.chartType];let r=n?n(i,e):[];if(this.getConnector&&this.scales){const t=function(t,e){const{scales:i,config:n,getConnector:r,getO:o}=t;if(!r||!i)return[];const s=[],{projection:a}=i,c=new Map;for(const t of e){if("point"!==t.type&&"rect"!==t.type)continue;const e=t.datum;if(!e)continue;const i=r(e);if(!i)continue;let n,s;"point"===t.type?(n=t.x,s=t.y):(n=t.x+t.w/2,s=t.y+("vertical"===a?0:t.h/2)),c.has(i)||c.set(i,[]),c.get(i).push({x:n,y:s,datum:e,category:o(e)})}const l=i.o.domain(),u=n.connectorStyle;for(const[t,e]of c)if(e.length>=2){e.sort((t,e)=>l.indexOf(t.category)-l.indexOf(e.category));for(let i=0;e.length-1>i;i++){const n=e[i],r=e[i+1],o="function"==typeof u?u(n.datum):u||{stroke:"#999",strokeWidth:1,opacity:.5};s.push({type:"connector",x1:n.x,y1:n.y,x2:r.x,y2:r.y,style:o,datum:n.datum,group:t})}}return s}(i,r);r=[...t,...r]}return r}resolvePieceStyle(t,e){if("function"==typeof this.config.pieceStyle){const i=this.config.pieceStyle(t,e);return i&&!i.fill&&e?Object.assign(Object.assign({},i),{fill:this.getColorFromScheme(e)}):i}return this.config.pieceStyle&&"object"==typeof this.config.pieceStyle?this.config.pieceStyle:this.config.barColors&&e?{fill:this.config.barColors[e]||"#007bff"}:e?{fill:this.getColorFromScheme(e)}:{fill:"#007bff"}}getColorFromScheme(t){this._colorSchemeMap||(this._colorSchemeMap=new Map);const e=this._colorSchemeMap.get(t);if(e)return e;const i=Array.isArray(this.config.colorScheme)?this.config.colorScheme:b,n=i[this._colorSchemeIndex%i.length];return this._colorSchemeIndex++,this._colorSchemeMap.set(t,n),n}resolveSummaryStyle(t,e){return"function"==typeof this.config.summaryStyle?this.config.summaryStyle(t,e):this.config.summaryStyle&&"object"==typeof this.config.summaryStyle?this.config.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}computeDecayOpacity(t,e){var i,n,r;const o=this.config.decay;if(!o||1>=e)return 1;const s=null!==(i=o.minOpacity)&&void 0!==i?i:.1,a=e-1-t;switch(o.type){case"linear":return s+(1-a/(e-1))*(1-s);case"exponential":{const t=null!==(n=o.halfLife)&&void 0!==n?n:e/2;return s+Math.pow(.5,a/t)*(1-s)}case"step":return(null!==(r=o.stepThreshold)&&void 0!==r?r:.5*e)>a?1:s;default:return 1}}applyDecay(t,e){var i,n;if(!this.config.decay)return;const r=e.length;if(1>=r)return;const o=new Map;for(let t=0;e.length>t;t++)o.set(e[t],t);for(const e of t){if("connector"===e.type||"violin"===e.type||"boxplot"===e.type||"wedge"===e.type)continue;const t=o.get(e.datum);if(null==t)continue;const s=this.computeDecayOpacity(t,r),a=null!==(n=null===(i=e.style)||void 0===i?void 0:i.opacity)&&void 0!==n?n:1;e.style=Object.assign(Object.assign({},e.style),{opacity:a*s})}}applyPulse(t,e){var i,n,r;if(!this.config.pulse||!this.timestampBuffer)return;const o="undefined"!=typeof performance?performance.now():Date.now(),s=null!==(i=this.config.pulse.duration)&&void 0!==i?i:500,a=null!==(n=this.config.pulse.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",c=null!==(r=this.config.pulse.glowRadius)&&void 0!==r?r:4,l=new Map;for(let t=0;e.length>t;t++)l.set(e[t],t);for(const i of t){if("connector"===i.type||"violin"===i.type||"boxplot"===i.type)continue;if("wedge"===i.type){const t=i.category;if(!t)continue;let n=0;for(let i=0;e.length>i;i++){const r=e[i],a=this.config.oAccessor;if(("function"==typeof a?a(r):r[a||"category"])!==t)continue;const c=this.timestampBuffer.get(i);if(null==c)continue;const l=o-c;if(s>l){const t=1-l/s;t>n&&(n=t)}}n>0&&(i._pulseIntensity=n,i._pulseColor=a);continue}const t=l.get(i.datum);if(null==t)continue;const n=this.timestampBuffer.get(t);if(null==n)continue;const r=o-n;s>r&&(i._pulseIntensity=1-r/s,i._pulseColor=a,i._pulseGlowRadius=c)}}get hasActivePulses(){var t;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const e="undefined"!=typeof performance?performance.now():Date.now(),i=null!==(t=this.config.pulse.duration)&&void 0!==t?t:500,n=this.timestampBuffer.peek();return null!=n&&i>e-n}getNodeKey(t,e){var i,n;if("point"===t.type){const i=`p:${t.datum?this.getO(t.datum):""}:${t.datum?this.getR(t.datum):0}`,n=e.get(i)||0;return e.set(i,n+1),`${i}:${n}`}return"rect"===t.type?`r:${t.group||""}:${null!==(n=null===(i=t.datum)||void 0===i?void 0:i.category)&&void 0!==n?n:""}`:null}snapshotPositions(){this.prevPositionMap.clear();const t=new Map;for(let e=0;this.scene.length>e;e++){const i=this.scene[e],n=this.getNodeKey(i,t);n&&("point"===i.type?this.prevPositionMap.set(n,{x:i.x,y:i.y,r:i.r,opacity:i.style.opacity}):"rect"===i.type&&this.prevPositionMap.set(n,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:i.style.opacity}))}}startTransition(){var t,e,i,n,r,o,s,a,c,l,u,h;if(!this.config.transition||0===this.prevPositionMap.size)return;const f=null!==(t=this.config.transition.duration)&&void 0!==t?t:300;if(this.exitNodes.length>0){const t=new Set(this.exitNodes);this.scene=this.scene.filter(e=>!t.has(e)),this.exitNodes=[]}let d=!1;const g=new Set,y=new Map;for(let t=0;this.scene.length>t;t++){const a=this.scene[t],c=this.getNodeKey(a,y);if(!c)continue;a._transitionKey=c;const l=this.prevPositionMap.get(c);"point"===a.type?l?(g.add(c),a._targetOpacity=null!==(e=a.style.opacity)&&void 0!==e?e:1,l.x===a.x&&l.y===a.y||(a._targetX=a.x,a._targetY=a.y,a.x=l.x,a.y=l.y,d=!0)):(a._targetOpacity=null!==(i=a.style.opacity)&&void 0!==i?i:1,a.style=Object.assign(Object.assign({},a.style),{opacity:0}),d=!0):"rect"===a.type&&(l?(g.add(c),a._targetOpacity=null!==(n=a.style.opacity)&&void 0!==n?n:1,l.x===a.x&&l.y===a.y&&l.w===a.w&&l.h===a.h||(a._targetX=a.x,a._targetY=a.y,a._targetW=a.w,a._targetH=a.h,a.x=l.x,a.y=l.y,a.w=null!==(r=l.w)&&void 0!==r?r:a.w,a.h=null!==(o=l.h)&&void 0!==o?o:a.h,d=!0)):(a._targetOpacity=null!==(s=a.style.opacity)&&void 0!==s?s:1,a.style=Object.assign(Object.assign({},a.style),{opacity:0}),d=!0))}this.exitNodes=[];for(const[t,e]of this.prevPositionMap)g.has(t)||(t.startsWith("p:")?this.exitNodes.push({type:"point",x:e.x,y:e.y,r:null!==(a=e.r)&&void 0!==a?a:3,style:{opacity:null!==(c=e.opacity)&&void 0!==c?c:1},datum:null,_targetOpacity:0,_transitionKey:t}):t.startsWith("r:")&&this.exitNodes.push({type:"rect",x:e.x,y:e.y,w:null!==(l=e.w)&&void 0!==l?l:0,h:null!==(u=e.h)&&void 0!==u?u:0,style:{opacity:null!==(h=e.opacity)&&void 0!==h?h:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t}),d=!0);this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),d&&(this.activeTransition={startTime:S(),duration:f})}advanceTransition(t){var e,i,n;if(!this.activeTransition)return!1;const r=A(t,this.activeTransition),o=_(r,"linear"===(null===(e=this.config.transition)||void 0===e?void 0:e.easing)?"linear":"ease-out-cubic");for(const t of this.scene){const e=t._transitionKey;if(e)if("point"===t.type){if(void 0!==t._targetOpacity){const n=this.prevPositionMap.get(e),r=n?null!==(i=n.opacity)&&void 0!==i?i:1:0;t.style.opacity=P(r,t._targetOpacity,o)}if(void 0===t._targetX)continue;const n=this.prevPositionMap.get(e);if(!n)continue;t.x=P(n.x,t._targetX,o),t.y=P(n.y,t._targetY,o)}else if("rect"===t.type){if(void 0!==t._targetOpacity){const i=this.prevPositionMap.get(e),r=i?null!==(n=i.opacity)&&void 0!==n?n:1:0;t.style.opacity=P(r,t._targetOpacity,o)}if(void 0===t._targetX)continue;const i=this.prevPositionMap.get(e);if(!i)continue;t.x=P(i.x,t._targetX,o),t.y=P(i.y,t._targetY,o),void 0!==i.w&&(t.w=P(i.w,t._targetW,o),t.h=P(i.h,t._targetH,o))}}if(r>=1){for(const t of this.scene)if(void 0!==t._targetOpacity&&(t.style=Object.assign(Object.assign({},t.style||{}),{opacity:0===t._targetOpacity?0:t._targetOpacity}),t._targetOpacity=void 0),"point"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t._targetX=void 0,t._targetY=void 0}else if("rect"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}if(this.exitNodes.length>0){const t=new Set(this.exitNodes);this.scene=this.scene.filter(e=>!t.has(e)),this.exitNodes=[]}return this.activeTransition=null,!1}return!0}getData(){return this.buffer.toArray()}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(t){const e=Object.assign({},this.config);if(t.colorScheme!==this.config.colorScheme&&(this._colorSchemeMap=null,this._colorSchemeIndex=0),Object.assign(this.config,t),(void 0!==t.oAccessor||void 0!==t.categoryAccessor)&&(p(t.oAccessor||t.categoryAccessor,e.oAccessor||e.categoryAccessor)||(this.getO=x(this.config.oAccessor||this.config.categoryAccessor,"category"),this.categories.clear())),void 0!==t.rAccessor){const i=Array.isArray(t.rAccessor)?t.rAccessor:[t.rAccessor],n=Array.isArray(e.rAccessor)?e.rAccessor:[e.rAccessor];if(i.length!==n.length||i.some((t,e)=>!p(t,n[e]))){const t=this.config.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(t=>m(t,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new g)):(this.getR=m(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in t&&!p(t.stackBy,e.stackBy)&&(this.getStack=null!=this.config.stackBy?x(this.config.stackBy):void 0),"groupBy"in t&&!p(t.groupBy,e.groupBy)&&(this.getGroup=null!=this.config.groupBy?x(this.config.groupBy):void 0),"colorAccessor"in t&&!p(t.colorAccessor,e.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?x(this.config.colorAccessor):void 0),"connectorAccessor"in t&&!p(t.connectorAccessor,e.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?x(this.config.connectorAccessor):void 0)}}const Ut={mercator:u.geoMercator,equalEarth:u.geoEqualEarth,albersUsa:u.geoAlbersUsa,orthographic:u.geoOrthographic,naturalEarth:u.geoNaturalEarth1,equirectangular:u.geoEquirectangular};function Jt(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}function te(t){return t?"function"==typeof t?t:e=>e[t]:t=>t.coordinates||t.data||[]}function ee(t,e,i){return t?Object.assign(Object.assign({},i),"function"==typeof t?t(e):t):i}const ie={fill:"#e0e0e0",stroke:"#999",strokeWidth:.5,fillOpacity:1},ne={fill:"#4e79a7",r:4,fillOpacity:.8},re={stroke:"#4e79a7",strokeWidth:1.5,fill:"none"};function oe(t,e){if(2>t.length)return[t];const i=.4*e,n=[];let r=[t[0]];for(let e=1;t.length>e;e++){const o=t[e];Math.abs(o[0]-t[e-1][0])>i?(2>r.length||n.push(r),r=[o]):r.push(o)}return 2>r.length||n.push(r),n}function se(t,e,i=24){const n=e[0]-t[0],r=e[1]-t[1],o=Math.sqrt(n*n+r*r);if(0===o)return[t,e];const s=-r/o,a=n/o,c=Math.min(.3*o,80),l=(t[0]+e[0])/2+s*c,u=(t[1]+e[1])/2+a*c,h=[];for(let n=0;i>=n;n++){const r=n/i,o=1-r;h.push([o*o*t[0]+2*o*r*l+r*r*e[0],o*o*t[1]+2*o*r*u+r*r*e[1]])}return h}function ae(t,e){if(2>t.length)return t;const i=e/2+1,n=[];for(let e=0;t.length>e;e++){const r=t[e];let o,s;0===e?(o=t[1][0]-r[0],s=t[1][1]-r[1]):e===t.length-1?(o=r[0]-t[e-1][0],s=r[1]-t[e-1][1]):(o=t[e+1][0]-t[e-1][0],s=t[e+1][1]-t[e-1][1]);const a=Math.sqrt(o*o+s*s)||1;n.push([r[0]+s/a*i,r[1]+-o/a*i])}return n}function ce(t,e,i,n,r){const o=e[0]-t[0],s=e[1]-t[1],a=Math.sqrt(o*o+s*s);if(0===a)return[t,e];const c=s/a,l=-o/a,u=r/2+1;return[[t[0]+c*u,t[1]+l*u],[e[0]+c*u,e[1]+l*u]]}class le{constructor(t){this.scene=[],this.scales=null,this.version=0,this.projection=null,this.geoPath=null,this.baseScale=0,this.baseTranslate=[0,0],this.baseRotation=[0,0,0],this.currentZoom=1,this.cartogramLayout=null,this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.streaming=!1,this.lastIngestTime=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositions=null,this.config=t}updateConfig(t){this.config=Object.assign(Object.assign({},this.config),t)}setAreas(t){this.areas=t}setPoints(t){this.pointData=t,this.streaming=!1}setLines(t){this.lineData=t}initStreaming(t=500){this.pointBuffer=new d(t),this.timestampBuffer=new d(t),this.streaming=!0}pushPoint(t){this.pointBuffer||this.initStreaming(),this.pointBuffer.push(t),this.timestampBuffer.push(performance.now()),this.lastIngestTime=performance.now()}pushMany(t){this.pointBuffer||this.initStreaming();const e=performance.now();for(const i of t)this.pointBuffer.push(i),this.timestampBuffer.push(e);this.lastIngestTime=e}clear(){this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.timestampBuffer=null,this.scene=[],this.scales=null,this.version++}computeScene(t){const{config:e}=this;this.projection=function(t){if(!t)return u.geoEqualEarth();if("string"==typeof t){const e=Ut[t];return e?e():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${t}", falling back to equalEarth`),u.geoEqualEarth())}if("object"==typeof t&&"type"in t){const e=Ut[t.type],i=e?e():u.geoEqualEarth();return t.rotate&&"rotate"in i&&i.rotate(t.rotate),t.center&&"center"in i&&i.center(t.center),i}return t}(e.projection),this.geoPath=u.geoPath(this.projection),this.fitProjection(t),this.geoPath=u.geoPath(this.projection);const i=this.projection;this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(t,e)=>i([t,e]),invertedPoint:(t,e)=>i.invert?i.invert([t,e]):null};const n=this.scene;this.scene=this.buildSceneNodes(t),e.projectionTransform&&this.applyCartogramTransform(e.projectionTransform,t),e.decay&&this.streaming&&this.applyDecay(),e.pulse&&this.streaming&&this.applyPulse(),e.transition&&n.length>0&&this.startTransition(n),this.version++}fitProjection(t){var e,i,n,r,o;const s=this.projection,a=this.config,c=[...this.areas],l=Jt(a.xAccessor,"lon"),u=Jt(a.yAccessor,"lat"),h=this.getPoints();if(h.length>0){const t=h.map(t=>[l(t),u(t)]);c.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:t}})}const f=te(a.lineDataAccessor);for(const t of this.lineData){const e=f(t);if(e&&e.length>0){const t=e.map(t=>[l(t),u(t)]);c.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:t}})}}if(0!==c.length){if(a.projectionExtent){const[[e,i],[n,r]]=a.projectionExtent;s.fitExtent([[0,0],[t.width,t.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[e,i],[n,i],[n,r],[e,r],[e,i]]]}})}else if(s.clipAngle&&(null!==(e=s.clipAngle())&&void 0!==e?e:0)>0){const e=null!==(i=a.fitPadding)&&void 0!==i?i:0,n=Math.min(t.width,t.height);s.scale(n/2-n*e),s.translate([t.width/2,t.height/2])}else{const e=null!==(n=a.fitPadding)&&void 0!==n?n:0,i=t.width*e,r=t.height*e;s.fitExtent([[i,r],[t.width-i,t.height-r]],{type:"FeatureCollection",features:c})}this.baseScale=s.scale(),this.baseTranslate=s.translate(),this.baseRotation=null!==(o=null===(r=s.rotate)||void 0===r?void 0:r.call(s))&&void 0!==o?o:[0,0,0]}}applyZoomTransform(t,e){const i=this.projection;i&&(i.scale(this.baseScale*t.k),i.translate([this.baseTranslate[0]*t.k+t.x,this.baseTranslate[1]*t.k+t.y]),this.currentZoom=t.k,this.geoPath=u.geoPath(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(t,e)=>i([t,e]),invertedPoint:(t,e)=>i.invert?i.invert([t,e]):null},this.scene=this.buildSceneNodes(e),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}applyZoomScale(t,e){const i=this.projection;i&&(i.scale(this.baseScale*t),i.translate(this.baseTranslate),this.currentZoom=t,this.geoPath=u.geoPath(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(t,e)=>i([t,e]),invertedPoint:(t,e)=>i.invert?i.invert([t,e]):null},this.scene=this.buildSceneNodes(e),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}applyRotation(t,e){const i=this.projection;i&&i.rotate&&(i.rotate(t),this.geoPath=u.geoPath(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(t,e)=>i([t,e]),invertedPoint:(t,e)=>i.invert?i.invert([t,e]):null},this.scene=this.buildSceneNodes(e),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}setRotation(t){const e=this.projection;e&&e.rotate&&e.rotate(t)}getRotation(){var t,e,i;return null!==(i=null===(e=null===(t=this.projection)||void 0===t?void 0:t.rotate)||void 0===e?void 0:e.call(t))&&void 0!==i?i:this.baseRotation}getBaseProjectionState(){return{scale:this.baseScale,translate:[...this.baseTranslate]}}getPoints(){return this.streaming&&this.pointBuffer?this.pointBuffer.toArray():this.pointData}buildSceneNodes(t){var e,i,n;const r=[],{config:o}=this,s=this.projection,a=this.geoPath,c=Jt(o.xAccessor,"lon"),l=Jt(o.yAccessor,"lat");if(o.graticule){const e=!0===o.graticule?{}:o.graticule,i=u.geoGraticule();e.step&&i.step(e.step);const n=a(i())||"";n&&r.push({type:"geoarea",pathData:n,centroid:[t.width/2,t.height/2],bounds:[[0,0],[t.width,t.height]],screenArea:0,style:{fill:"none",stroke:e.stroke||"#e0e0e0",strokeWidth:e.strokeWidth||.5,strokeDasharray:e.strokeDasharray||"2,2"},datum:null,interactive:!1})}for(const t of this.areas){const e=a(t);if(!e)continue;const i=a.centroid(t),n=a.bounds(t),s=a.area(t),c=ee(o.areaStyle,t,ie);r.push({type:"geoarea",pathData:e,centroid:i,bounds:n,screenArea:s,style:c,datum:t,interactive:!0})}const h=te(o.lineDataAccessor);for(const e of this.lineData){const i=h(e);if(!i||2>i.length)continue;const n=i.map(t=>[c(t),l(t)]);let a;if("geo"===o.lineType){const t=[];for(let e=0;n.length-1>e;e++){const i=n[e],r=n[e+1],o=u.geoDistance(i,r)||0,s=Math.max(2,Math.ceil(o/(Math.PI/180))),a=u.geoInterpolate(i,r);for(let i=0;s>=i;i++)e>0&&0===i||t.push(a(i/s))}a=t.map(([t,e])=>s([t,e])).filter(t=>null!=t)}else a=n.map(([t,e])=>s([t,e])).filter(t=>null!=t);if(2>a.length)continue;const f=ee(o.lineStyle,e,re),d="number"==typeof f.strokeWidth?f.strokeWidth:1;2!==n.length||2>a.length||"arc"!==o.flowStyle?2!==n.length||2>a.length||"offset"!==o.flowStyle||(a="geo"===o.lineType?ae(a,d):ce(a[0],a[a.length-1],0,0,d)):a=se(a[0],a[a.length-1]);const g=oe(a,t.width);if(g.length>1)for(const t of g){if(2>t.length)continue;const i={type:"line",path:t,style:Object.assign(Object.assign({},f),{_edgeFade:!0}),datum:e};r.push(i)}else r.push({type:"line",path:2>a.length&&g[0]||a,style:f,datum:e})}const f=this.getPoints(),d=o.pointIdAccessor?"function"==typeof o.pointIdAccessor?o.pointIdAccessor:t=>t[o.pointIdAccessor]:null,g=s.clipAngle&&null!==(e=s.clipAngle())&&void 0!==e?e:0,y=g>0?g*Math.PI/180:null,p=s.rotate?s.rotate():[0,0,0],m="function"==typeof s.center?s.center():[0,0],v=[(null!==(i=m[0])&&void 0!==i?i:0)-p[0],(null!==(n=m[1])&&void 0!==n?n:0)-p[1]];for(let t=0;f.length>t;t++){const e=f[t],i=c(e),n=l(e);if(null!=y&&u.geoDistance([i,n],v)>y)continue;const a=s([i,n]);if(!a)continue;const h=o.pointStyle?o.pointStyle(e):Object.assign({},ne),g={type:"point",x:a[0],y:a[1],r:h.r||4,style:h,datum:e,pointId:d?d(e)+"":void 0};r.push(g)}return r}applyCartogramTransform(t,i){var n,r,o;const s=this.scene.filter(t=>"point"===t.type);if(2>s.length)return;const a=null!==(n=t.strength)&&void 0!==n?n:1;if(0===a)return;const c=t.centerAccessor?"function"==typeof t.centerAccessor?t.centerAccessor:e=>e[t.centerAccessor]:t=>t.id,l="function"==typeof t.costAccessor?t.costAccessor:e=>e[t.costAccessor],u=s.find(e=>c(e.datum)+""==t.center+"");if(!u)return void("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${t.center}" not found in point data`));const h=u.x,f=u.y,d=s.map(t=>l(t.datum)).filter(t=>isFinite(t)&&t>=0),g=Math.max(...d,1),y=Math.min(i.width,i.height)/2,p=e.scaleLinear().domain([0,g]).range([0,y]);this.cartogramLayout={cx:h,cy:f,maxCost:g,availableRadius:y},this.areas.length>0&&"production"!==process.env.NODE_ENV&&console.warn("GeoFrame: Distance cartogram does not support area rendering. Areas will be ignored. Remove areas or set projectionTransform to null to render them."),this.scene=this.scene.filter(t=>"geoarea"!==t.type||!t.interactive);for(const t of s){if(t===u)continue;const e=Math.atan2(t.y-f,t.x-h),i=Math.sqrt(Math.pow(t.x-h,2)+Math.pow(t.y-f,2)),n=l(t.datum),r=i+((isFinite(n)?p(n):i)-i)*a;t.x=h+Math.cos(e)*r,t.y=f+Math.sin(e)*r}const m=i.width/2,v=i.height/2,x=m-u.x,b=v-u.y;if(Math.abs(x)>.5||Math.abs(b)>.5)for(const t of s)t.x+=x,t.y+=b;this.cartogramLayout={cx:m,cy:v,maxCost:g,availableRadius:y};const k=this.scene.filter(t=>"line"===t.type);if(k.length>0&&"fractional"!==t.lineMode){const t=new Map;for(const e of s)e.pointId&&t.set(e.pointId,[e.x,e.y]);for(const e of k){const i=null===(r=e.datum)||void 0===r?void 0:r.source,n=null===(o=e.datum)||void 0===o?void 0:o.target;if(i&&n){const r=t.get(i+""),o=t.get(n+"");r&&o&&(e.path=[r,o])}}}}applyDecay(){var t,e,i;const n=this.config.decay;if(!n||!this.pointBuffer)return;const r=this.pointBuffer.size;if(0===r)return;const o=null!==(t=n.minOpacity)&&void 0!==t?t:.1,s=null!==(e=n.halfLife)&&void 0!==e?e:r/2,a=null!==(i=n.stepThreshold)&&void 0!==i?i:.5*r,c=this.scene.filter(t=>"point"===t.type);for(let t=0;c.length>t;t++){const e=r-1-t;let i;switch(n.type){case"exponential":i=o+Math.pow(.5,e/s)*(1-o);break;case"step":i=a>e?1:o;break;default:i=o+(r>1?1-e/(r-1):1)*(1-o)}c[t]._decayOpacity=i,c[t].style=Object.assign(Object.assign({},c[t].style),{opacity:i})}}applyPulse(){var t,e;const i=this.config.pulse;if(!i||!this.timestampBuffer)return;const n=null!==(t=i.duration)&&void 0!==t?t:500,r=performance.now(),o=this.scene.filter(t=>"point"===t.type),s=this.timestampBuffer.toArray();for(let t=0;o.length>t&&s.length>t;t++){const a=r-s[t];n>a&&(o[t]._pulseIntensity=1-a/n,o[t]._pulseColor=i.color||"rgba(255,255,255,0.6)",o[t]._pulseGlowRadius=null!==(e=i.glowRadius)&&void 0!==e?e:4)}}get hasActivePulses(){var t,e;if(!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const i=null!==(e=null===(t=this.config.pulse)||void 0===t?void 0:t.duration)&&void 0!==e?e:500,n=this.timestampBuffer.toArray()[this.timestampBuffer.size-1];return performance.now()-n<i}startTransition(t){var e,i;const n=null!==(i=null===(e=this.config.transition)||void 0===e?void 0:e.duration)&&void 0!==i?i:300;if(0>=n)return;const r=new Map;for(const e of t)"point"===e.type&&e.pointId&&r.set(e.pointId,[e.x,e.y]);const o=this.scene.filter(t=>"point"===t.type);let s=!1;for(const t of o)if(t.pointId){const e=r.get(t.pointId);e&&(t._targetX=t.x,t._targetY=t.y,t.x=e[0],t.y=e[1],(Math.abs(e[0]-t._targetX)>.5||Math.abs(e[1]-t._targetY)>.5)&&(s=!0))}s&&(this.activeTransition={startTime:performance.now(),duration:n})}advanceTransition(t){if(!this.activeTransition)return!1;const e=A(t,this.activeTransition),i=_(e),n=this.scene.filter(t=>"point"===t.type);for(const t of n)if(null!=t._targetX&&null!=t._targetY){const e=t.y;t.x=P(t.x,t._targetX,i),t.y=P(e,t._targetY,i)}if(e>=1){for(const t of n)null!=t._targetX&&(t.x=t._targetX,t.y=t._targetY,t._targetX=void 0,t._targetY=void 0);return this.activeTransition=null,!1}return!0}}function ue(t,e="#4e79a7"){return t&&"string"==typeof t?t:e}const he=require("react-dom/server");function fe(t){return Math.round(100*t)/100+""}function de(t){var e,i,n,r;const o=t.size||[500,300],s=Object.assign(Object.assign({},{top:20,right:20,bottom:30,left:40}),t.margin),a=o[0]-s.left-s.right,c=o[1]-s.top-s.bottom,l="streaming"===t.runtimeMode||["bar","swarm","waterfall"].includes(t.chartType),u={chartType:t.chartType,windowSize:null!==(e=t.windowSize)&&void 0!==e?e:200,windowMode:null!==(i=t.windowMode)&&void 0!==i?i:"sliding",arrowOfTime:l&&null!==(n=t.arrowOfTime)&&void 0!==n?n:"right",extentPadding:null!==(r=t.extentPadding)&&void 0!==r?r:.1,xAccessor:l?void 0:t.xAccessor,yAccessor:l?void 0:t.yAccessor,timeAccessor:l?t.timeAccessor:void 0,valueAccessor:t.valueAccessor,colorAccessor:t.colorAccessor,sizeAccessor:t.sizeAccessor,groupAccessor:t.groupAccessor,categoryAccessor:t.categoryAccessor,lineDataAccessor:t.lineDataAccessor,xExtent:t.xExtent,yExtent:t.yExtent,sizeRange:t.sizeRange,binSize:t.binSize,normalize:t.normalize,boundsAccessor:t.boundsAccessor,boundsStyle:t.boundsStyle,openAccessor:t.openAccessor,highAccessor:t.highAccessor,lowAccessor:t.lowAccessor,closeAccessor:t.closeAccessor,candlestickStyle:t.candlestickStyle,lineStyle:t.lineStyle,pointStyle:t.pointStyle,areaStyle:t.areaStyle,colorScheme:t.colorScheme,barColors:t.barColors},h=new C(u);if(t.data&&h.ingest({inserts:t.data,bounded:!0}),h.computeScene({width:a,height:c}),!h.scales||0===h.scene.length)return he.renderToStaticMarkup(f.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"stream-xy-frame",width:o[0],height:o[1]}));const d=h.scene.map((t,e)=>function(t,e){var i,n,r;switch(t.type){case"line":{const i=t;if(0===i.path.length)return null;const n="M"+i.path.map(([t,e])=>`${t},${e}`).join("L");return f.createElement("path",{key:"line-"+e,d:n,fill:"none",stroke:i.style.stroke||"#4e79a7",strokeWidth:i.style.strokeWidth||2,strokeDasharray:i.style.strokeDasharray,opacity:i.style.opacity})}case"area":{const r=t;if(0===r.topPath.length)return null;const o=r.topPath.map(([t,e])=>`${t},${e}`).join("L"),s=[...r.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L");return f.createElement("path",{key:"area-"+e,d:`M${o}L${s}Z`,fill:ue(r.style.fill),fillOpacity:null!==(n=null!==(i=r.style.fillOpacity)&&void 0!==i?i:r.style.opacity)&&void 0!==n?n:.7,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})}case"point":{const i=t;return f.createElement("circle",{key:"point-"+e,cx:i.x,cy:i.y,r:i.r,fill:ue(i.style.fill),opacity:null!==(r=i.style.opacity)&&void 0!==r?r:.8,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})}case"rect":{const i=t;return f.createElement("rect",{key:"rect-"+e,x:i.x,y:i.y,width:i.w,height:i.h,fill:ue(i.style.fill),opacity:i.style.opacity,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})}case"heatcell":{const i=t;if(i.showValues&&null!=i.value&&i.w>=20&&i.h>=20){const t=i.valueFormat?i.valueFormat(i.value):Number.isInteger(i.value)?i.value+"":100>Math.abs(i.value)?1>Math.abs(i.value)?i.value.toPrecision(3):i.value.toFixed(1):i.value.toFixed(0),[n,r,o]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(i.fill),s=.299*n+.587*r+.114*o>128?"#000":"#fff",a=Math.max(10,Math.min(16,.3*Math.min(i.w,i.h)));return f.createElement("g",{key:"heatcell-"+e},f.createElement("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:i.fill}),f.createElement("text",{x:i.x+i.w/2,y:i.y+i.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:s,fontSize:a+"px"},t))}return f.createElement("rect",{key:"heatcell-"+e,x:i.x,y:i.y,width:i.w,height:i.h,fill:i.fill})}case"candlestick":{const i=t,n=Math.min(i.openY,i.closeY),r=Math.max(Math.abs(i.openY-i.closeY),1),o=i.isUp?i.upColor:i.downColor;return f.createElement("g",{key:"candle-"+e},f.createElement("line",{x1:i.x,y1:i.highY,x2:i.x,y2:i.lowY,stroke:i.wickColor,strokeWidth:i.wickWidth}),f.createElement("rect",{x:i.x-i.bodyWidth/2,y:n,width:i.bodyWidth,height:r,fill:o,stroke:o,strokeWidth:1}))}default:return null}}(t,e)).filter(Boolean),g=!1!==t.showAxes?function(t,e,i){var n,r,o,s;const a=t.x.ticks(5).map(e=>({pixel:t.x(e),label:(i.xFormat||i.tickFormatTime||fe)(e)})),c=t.y.ticks(5).map(e=>({pixel:t.y(e),label:(i.yFormat||i.tickFormatValue||fe)(e)}));return f.createElement("g",{className:"stream-axes"},f.createElement("line",{x1:0,y1:e.height,x2:e.width,y2:e.height,stroke:"#ccc",strokeWidth:1}),a.map((t,i)=>f.createElement("g",{key:"xtick-"+i,transform:`translate(${t.pixel},${e.height})`},f.createElement("line",{y2:5,stroke:"#ccc",strokeWidth:1}),f.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:"#666"},t.label))),i.xLabel&&f.createElement("text",{x:e.width/2,y:e.height+40,textAnchor:"middle",fontSize:12,fill:"#333"},i.xLabel),f.createElement("line",{x1:0,y1:0,x2:0,y2:e.height,stroke:"#ccc",strokeWidth:1}),c.map((t,e)=>f.createElement("g",{key:"ytick-"+e,transform:`translate(0,${t.pixel})`},f.createElement("line",{x2:-5,stroke:"#ccc",strokeWidth:1}),f.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"#666"},t.label))),i.yLabel&&f.createElement("text",{x:15-(null!==(r=null===(n=i.margin)||void 0===n?void 0:n.left)&&void 0!==r?r:40),y:e.height/2,textAnchor:"middle",fontSize:12,fill:"#333",transform:`rotate(-90, ${15-(null!==(s=null===(o=i.margin)||void 0===o?void 0:o.left)&&void 0!==s?s:40)}, ${e.height/2})`},i.yLabel))}(h.scales,{width:a,height:c},t):null,y=t.title&&"string"==typeof t.title?f.createElement("text",{x:o[0]/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"#333"},t.title):null,p=t.background?f.createElement("rect",{x:0,y:0,width:a,height:c,fill:t.background}):null,m=f.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"stream-xy-frame"+(t.className?" "+t.className:""),width:o[0],height:o[1]},f.createElement("g",{transform:`translate(${s.left},${s.top})`},p,d,g),y);return he.renderToStaticMarkup(m)}function ge(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}const ye=new Set(["tree","cluster","treemap","circlepack","partition"]);function pe(t){const e=t.chartType||"force",i=t.size||[500,500],n=Object.assign(Object.assign({},{top:20,right:20,bottom:20,left:20}),t.margin),r=i[0]-n.left-n.right,o=i[1]-n.top-n.bottom,s=function(t){return Vt[t]}(e);if(!s)throw Error(`No layout plugin found for chart type: "${e}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition.`);const a={chartType:e,nodeIDAccessor:t.nodeIDAccessor,sourceAccessor:t.sourceAccessor,targetAccessor:t.targetAccessor,valueAccessor:t.valueAccessor,childrenAccessor:t.childrenAccessor,hierarchySum:t.hierarchySum,orientation:t.orientation,nodeAlign:t.nodeAlign,nodePaddingRatio:t.nodePaddingRatio,nodeWidth:t.nodeWidth,iterations:t.iterations,forceStrength:t.forceStrength,padAngle:t.padAngle,groupWidth:t.groupWidth,sortGroups:t.sortGroups,edgeSort:t.edgeSort,treeOrientation:t.treeOrientation,edgeType:t.edgeType,padding:t.padding,paddingTop:t.paddingTop,nodeStyle:t.nodeStyle,edgeStyle:t.edgeStyle,nodeLabel:t.nodeLabel,showLabels:t.showLabels,colorBy:t.colorBy,colorScheme:t.colorScheme,edgeColorBy:t.edgeColorBy,edgeOpacity:t.edgeOpacity,colorByDepth:t.colorByDepth,nodeSize:t.nodeSize,nodeSizeRange:t.nodeSizeRange};let l,u;if(ye.has(e)){const e=t.data||t.edges;if(!e||Array.isArray(e))return he.renderToStaticMarkup(f.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"stream-network-frame",width:i[0],height:i[1]}));a.__hierarchyRoot=e,l=[],u=[]}else{const e=t.nodes||[],n=Array.isArray(t.edges)?t.edges:[];if(0===e.length&&0===n.length)return he.renderToStaticMarkup(f.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"stream-network-frame",width:i[0],height:i[1]}));if(u=function(t,e){const i=ge(e.sourceAccessor,"source"),n=ge(e.targetAccessor,"target"),r=ge(e.valueAccessor,"value");return t.map(t=>({source:i(t)+"",target:n(t)+"",value:Number(r(t))||1,y0:0,y1:0,sankeyWidth:0,data:t}))}(n,a),0===e.length&&u.length>0){const t=new Set;for(const e of u){const i="string"==typeof e.target?e.target:e.target.id;t.add("string"==typeof e.source?e.source:e.source.id),t.add(i)}l=Array.from(t).map(t=>({id:t,x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:{id:t}}))}else l=function(t,e){const i=ge(e.nodeIDAccessor,"id");return t.map(t=>({id:i(t)+"",x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:t}))}(e,a)}s.computeLayout(l,u,a,[r,o]);const{sceneNodes:h,sceneEdges:d,labels:g}=s.buildScene(l,u,a,[r,o]),y=d.map((t,e)=>function(t,e){switch(t.type){case"line":return f.createElement("line",{key:"net-edge-"+e,x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.stroke||"#999",strokeWidth:t.style.strokeWidth||1,opacity:t.style.opacity});case"bezier":{const i=t;return f.createElement("path",{key:"net-edge-"+e,d:i.pathD,fill:ue(i.style.fill,"#999"),fillOpacity:i.style.fillOpacity,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})}case"ribbon":{const i=t;return f.createElement("path",{key:"net-edge-"+e,d:i.pathD,fill:ue(i.style.fill,"#999"),fillOpacity:i.style.fillOpacity,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})}case"curved":{const i=t;return f.createElement("path",{key:"net-edge-"+e,d:i.pathD,fill:ue(i.style.fill,"none"),stroke:i.style.stroke||"#999",strokeWidth:i.style.strokeWidth||1,opacity:i.style.opacity})}default:return null}}(t,e)).filter(Boolean),p=h.map((t,e)=>function(t,e){switch(t.type){case"circle":{const i=t;return f.createElement("circle",{key:"net-circle-"+e,cx:i.cx,cy:i.cy,r:i.r,fill:ue(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})}case"rect":{const i=t;return f.createElement("rect",{key:"net-rect-"+e,x:i.x,y:i.y,width:i.w,height:i.h,fill:ue(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})}case"arc":{const i=t,n=c.arc().innerRadius(i.innerR).outerRadius(i.outerR).startAngle(i.startAngle).endAngle(i.endAngle)({})||"";return f.createElement("path",{key:"net-arc-"+e,d:n,transform:`translate(${i.cx},${i.cy})`,fill:ue(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})}default:return null}}(t,e)).filter(Boolean),m=g.map((t,e)=>function(t,e){return f.createElement("text",{key:"net-label-"+e,x:t.x,y:t.y,textAnchor:t.anchor||"middle",dominantBaseline:t.baseline||"auto",fontSize:t.fontSize||11,fontWeight:t.fontWeight,fill:t.fill||"#333",stroke:t.stroke,strokeWidth:t.strokeWidth,paintOrder:t.paintOrder},t.text)}(t,e)).filter(Boolean),v=t.title&&"string"==typeof t.title?f.createElement("text",{x:i[0]/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"#333"},t.title):null,x=t.background?f.createElement("rect",{x:0,y:0,width:r,height:o,fill:t.background}):null,b=f.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"stream-network-frame"+(t.className?" "+t.className:""),width:i[0],height:i[1]},f.createElement("g",{transform:`translate(${n.left},${n.top})`},x,y,p,m),v);return he.renderToStaticMarkup(b)}function me(t){var e,i,n;const r=t.size||[500,400],o=Object.assign(Object.assign({},{top:20,right:20,bottom:30,left:40}),t.margin),s=r[0]-o.left-o.right,a=r[1]-o.top-o.bottom,l=t.projection||"vertical",u="radial"===l,h={chartType:t.chartType,windowSize:null!==(e=t.windowSize)&&void 0!==e?e:1e4,windowMode:null!==(i=t.windowMode)&&void 0!==i?i:"sliding",extentPadding:null!==(n=t.extentPadding)&&void 0!==n?n:.05,projection:l,oAccessor:t.oAccessor,rAccessor:t.rAccessor,colorAccessor:t.colorAccessor,stackBy:t.stackBy,groupBy:t.groupBy,categoryAccessor:t.categoryAccessor,valueAccessor:t.valueAccessor,timeAccessor:t.timeAccessor,rExtent:t.rExtent,oExtent:t.oExtent,barPadding:t.barPadding,innerRadius:t.innerRadius,normalize:t.normalize,startAngle:t.startAngle,bins:t.bins,showOutliers:t.showOutliers,showIQR:t.showIQR,amplitude:t.amplitude,oSort:t.oSort,connectorAccessor:t.connectorAccessor,connectorStyle:t.connectorStyle,dynamicColumnWidth:t.dynamicColumnWidth,pieceStyle:t.pieceStyle,summaryStyle:t.summaryStyle,colorScheme:t.colorScheme,barColors:t.barColors},d=new Qt(h);if(t.data&&d.ingest({inserts:t.data,bounded:!0}),d.computeScene({width:s,height:a}),!d.scales||0===d.scene.length)return he.renderToStaticMarkup(f.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"stream-ordinal-frame",width:r[0],height:r[1]}));const g=d.scene.map((t,e)=>function(t,e){var i,n,r,o,s;const a=t.category||t.group||"",l=i=>`ord-${t.type}-${a}-${e}-${i}`,u=`ord-${t.type}-${a}-${e}`;switch(t.type){case"rect":{const e=t;return f.createElement("rect",{key:u,x:e.x,y:e.y,width:e.w,height:e.h,fill:ue(e.style.fill),opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth})}case"point":{const e=t;return f.createElement("circle",{key:u,cx:e.x,cy:e.y,r:e.r,fill:ue(e.style.fill),opacity:null!==(i=e.style.opacity)&&void 0!==i?i:.8,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth})}case"wedge":{const e=t,i=c.arc().innerRadius(e.innerRadius).outerRadius(e.outerRadius).startAngle(e.startAngle).endAngle(e.endAngle)({})||"";return f.createElement("path",{key:u,d:i,transform:`translate(${e.cx},${e.cy})`,fill:ue(e.style.fill),stroke:e.style.stroke,strokeWidth:e.style.strokeWidth,opacity:e.style.opacity})}case"boxplot":{const e=t,i=e.columnWidth/2;return"vertical"===e.projection?f.createElement("g",{key:u},f.createElement("line",{x1:e.x,y1:e.minPos,x2:e.x,y2:e.maxPos,stroke:e.style.stroke||"#333",strokeWidth:1}),f.createElement("rect",{x:e.x-i,y:Math.min(e.q1Pos,e.q3Pos),width:e.columnWidth,height:Math.abs(e.q3Pos-e.q1Pos),fill:ue(e.style.fill),fillOpacity:null!==(n=e.style.fillOpacity)&&void 0!==n?n:.6,stroke:e.style.stroke||"#333",strokeWidth:1}),f.createElement("line",{x1:e.x-i,y1:e.medianPos,x2:e.x+i,y2:e.medianPos,stroke:e.style.stroke||"#333",strokeWidth:2}),f.createElement("line",{x1:e.x-.5*i,y1:e.minPos,x2:e.x+.5*i,y2:e.minPos,stroke:e.style.stroke||"#333",strokeWidth:1}),f.createElement("line",{x1:e.x-.5*i,y1:e.maxPos,x2:e.x+.5*i,y2:e.maxPos,stroke:e.style.stroke||"#333",strokeWidth:1})):f.createElement("g",{key:u},f.createElement("line",{x1:e.minPos,y1:e.y,x2:e.maxPos,y2:e.y,stroke:e.style.stroke||"#333",strokeWidth:1}),f.createElement("rect",{x:Math.min(e.q1Pos,e.q3Pos),y:e.y-i,width:Math.abs(e.q3Pos-e.q1Pos),height:e.columnWidth,fill:ue(e.style.fill),fillOpacity:null!==(r=e.style.fillOpacity)&&void 0!==r?r:.6,stroke:e.style.stroke||"#333",strokeWidth:1}),f.createElement("line",{x1:e.medianPos,y1:e.y-i,x2:e.medianPos,y2:e.y+i,stroke:e.style.stroke||"#333",strokeWidth:2}),f.createElement("line",{x1:e.minPos,y1:e.y-.5*i,x2:e.minPos,y2:e.y+.5*i,stroke:e.style.stroke||"#333",strokeWidth:1}),f.createElement("line",{x1:e.maxPos,y1:e.y-.5*i,x2:e.maxPos,y2:e.y+.5*i,stroke:e.style.stroke||"#333",strokeWidth:1}))}case"violin":{const e=t,i=[f.createElement("path",{key:l("path"),d:e.pathString,transform:e.translateX||e.translateY?`translate(${e.translateX},${e.translateY})`:void 0,fill:ue(e.style.fill),fillOpacity:null!==(o=e.style.fillOpacity)&&void 0!==o?o:.6,stroke:e.style.stroke||"#333",strokeWidth:e.style.strokeWidth||1})];if(e.iqrLine&&e.bounds){const t=e.bounds,n=t.x+t.width/2,r=t.y+t.height/2;t.height>t.width?i.push(f.createElement("line",{key:l("iqr"),x1:n,y1:e.iqrLine.q1Pos,x2:n,y2:e.iqrLine.q3Pos,stroke:e.style.stroke||"#333",strokeWidth:2}),f.createElement("circle",{key:l("med"),cx:n,cy:e.iqrLine.medianPos,r:3,fill:"white",stroke:e.style.stroke||"#333",strokeWidth:1})):i.push(f.createElement("line",{key:l("iqr"),x1:e.iqrLine.q1Pos,y1:r,x2:e.iqrLine.q3Pos,y2:r,stroke:e.style.stroke||"#333",strokeWidth:2}),f.createElement("circle",{key:l("med"),cx:e.iqrLine.medianPos,cy:r,r:3,fill:"white",stroke:e.style.stroke||"#333",strokeWidth:1}))}return f.createElement("g",{key:u},i)}case"connector":return f.createElement("line",{key:u,x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.stroke||"#999",strokeWidth:t.style.strokeWidth||1,opacity:null!==(s=t.style.opacity)&&void 0!==s?s:.5});case"trapezoid":{const e=t,i=e.points.map(t=>`${t[0]},${t[1]}`).join(" ");return f.createElement("polygon",{key:u,points:i,fill:ue(e.style.fill,"#999"),opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth})}default:return null}}(t,e)).filter(Boolean),y=!1!==t.showAxes?function(t,e,i){var n,r,o,s,a,c,l,u;const h=t.scales;if(!h)return null;if("radial"===h.projection)return null;const d="vertical"===h.projection,g=Object.values(t.columns).map(t=>({pixel:t.middle,label:(i.oFormat||String)(t.name)})),y=h.r.ticks(5).map(t=>({pixel:h.r(t),label:(i.rFormat||fe)(t)}));return d?f.createElement("g",{className:"ordinal-axes"},f.createElement("line",{x1:0,y1:e.height,x2:e.width,y2:e.height,stroke:"#ccc",strokeWidth:1}),g.map((t,i)=>f.createElement("g",{key:"oxtick-"+i,transform:`translate(${t.pixel},${e.height})`},f.createElement("line",{y2:5,stroke:"#ccc",strokeWidth:1}),f.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:"#666"},t.label))),i.oLabel&&f.createElement("text",{x:e.width/2,y:e.height+40,textAnchor:"middle",fontSize:12,fill:"#333"},i.oLabel),f.createElement("line",{x1:0,y1:0,x2:0,y2:e.height,stroke:"#ccc",strokeWidth:1}),y.map((t,e)=>f.createElement("g",{key:"oytick-"+e,transform:`translate(0,${t.pixel})`},f.createElement("line",{x2:-5,stroke:"#ccc",strokeWidth:1}),f.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"#666"},t.label))),i.rLabel&&f.createElement("text",{x:15-(null!==(r=null===(n=i.margin)||void 0===n?void 0:n.left)&&void 0!==r?r:40),y:e.height/2,textAnchor:"middle",fontSize:12,fill:"#333",transform:`rotate(-90, ${15-(null!==(s=null===(o=i.margin)||void 0===o?void 0:o.left)&&void 0!==s?s:40)}, ${e.height/2})`},i.rLabel)):f.createElement("g",{className:"ordinal-axes"},f.createElement("line",{x1:0,y1:e.height,x2:e.width,y2:e.height,stroke:"#ccc",strokeWidth:1}),y.map((t,i)=>f.createElement("g",{key:"oxtick-"+i,transform:`translate(${t.pixel},${e.height})`},f.createElement("line",{y2:5,stroke:"#ccc",strokeWidth:1}),f.createElement("text",{y:18,textAnchor:"middle",fontSize:10,fill:"#666"},t.label))),i.rLabel&&f.createElement("text",{x:e.width/2,y:e.height+40,textAnchor:"middle",fontSize:12,fill:"#333"},i.rLabel),f.createElement("line",{x1:0,y1:0,x2:0,y2:e.height,stroke:"#ccc",strokeWidth:1}),g.map((t,e)=>f.createElement("g",{key:"oytick-"+e,transform:`translate(0,${t.pixel})`},f.createElement("line",{x2:-5,stroke:"#ccc",strokeWidth:1}),f.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"#666"},t.label))),i.oLabel&&f.createElement("text",{x:15-(null!==(c=null===(a=i.margin)||void 0===a?void 0:a.left)&&void 0!==c?c:40),y:e.height/2,textAnchor:"middle",fontSize:12,fill:"#333",transform:`rotate(-90, ${15-(null!==(u=null===(l=i.margin)||void 0===l?void 0:l.left)&&void 0!==u?u:40)}, ${e.height/2})`},i.oLabel))}(d,{width:s,height:a},t):null,p=t.title&&"string"==typeof t.title?f.createElement("text",{x:r[0]/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"#333"},t.title):null,m=t.background?f.createElement("rect",{x:0,y:0,width:s,height:a,fill:t.background}):null,v=f.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"stream-ordinal-frame"+(t.className?" "+t.className:""),width:r[0],height:r[1]},f.createElement("g",{transform:`translate(${u?o.left+s/2:o.left},${u?o.top+a/2:o.top})`},m,g,y),p);return he.renderToStaticMarkup(v)}function ve(t){var e,i,n,r,o,s;const a=t.size||[t.width||600,t.height||400],c=Object.assign(Object.assign({},{top:10,right:10,bottom:10,left:10}),t.margin),l=a[0]-(null!==(e=c.left)&&void 0!==e?e:0)-(null!==(i=c.right)&&void 0!==i?i:0),u=a[1]-(null!==(n=c.top)&&void 0!==n?n:0)-(null!==(r=c.bottom)&&void 0!==r?r:0),h=new le({projection:t.projection||"equalEarth",xAccessor:t.xAccessor,yAccessor:t.yAccessor,lineDataAccessor:t.lineDataAccessor,pointIdAccessor:t.pointIdAccessor,lineType:t.lineType,areaStyle:t.areaStyle,pointStyle:t.pointStyle,lineStyle:t.lineStyle,graticule:t.graticule,fitPadding:t.fitPadding,projectionTransform:t.projectionTransform});if(t.areas){if("string"==typeof t.areas)throw Error(`Geo SSR requires pre-resolved GeoJSON features. Reference string "${t.areas}" cannot be resolved synchronously. Use \`const features = await resolveReferenceGeography('${t.areas}')\` before calling renderGeoToStaticSVG.`);h.setAreas(t.areas)}if(t.points&&h.setPoints(t.points),t.lines&&h.setLines(t.lines),h.computeScene({width:l,height:u}),0===h.scene.length)return he.renderToStaticMarkup(f.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"stream-geo-frame",width:a[0],height:a[1]}));const d=h.scene.map((t,e)=>function(t,e){var i,n,r,o,s,a;switch(t.type){case"geoarea":{const r=t;return r.pathData?f.createElement("path",{key:"geoarea-"+e,d:r.pathData,fill:ue(r.style.fill,"#e0e0e0"),fillOpacity:null!==(i=r.style.fillOpacity)&&void 0!==i?i:1,stroke:r.style.stroke||"none",strokeWidth:r.style.strokeWidth||.5,strokeDasharray:r.style.strokeDasharray,opacity:null!==(n=r._decayOpacity)&&void 0!==n?n:1}):null}case"point":{const i=t;return f.createElement("circle",{key:"point-"+e,cx:i.x,cy:i.y,r:i.r,fill:ue(i.style.fill),fillOpacity:null!==(r=i.style.fillOpacity)&&void 0!==r?r:.8,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:null!==(o=i._decayOpacity)&&void 0!==o?o:null!==(s=i.style.opacity)&&void 0!==s?s:1})}case"line":{const i=t;if(2>i.path.length)return null;const n="M"+i.path.map(t=>`${t[0]},${t[1]}`).join("L");return f.createElement("path",{key:"line-"+e,d:n,fill:"none",stroke:i.style.stroke||"#4e79a7",strokeWidth:i.style.strokeWidth||1.5,strokeDasharray:i.style.strokeDasharray,opacity:null!==(a=i.style.opacity)&&void 0!==a?a:1})}default:return null}}(t,e)).filter(Boolean),g=t.title&&"string"==typeof t.title?f.createElement("text",{x:a[0]/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"#333"},t.title):null,y=t.background?f.createElement("rect",{x:0,y:0,width:l,height:u,fill:t.background}):null,p=f.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"stream-geo-frame"+(t.className?" "+t.className:""),width:a[0],height:a[1]},f.createElement("g",{transform:`translate(${null!==(o=c.left)&&void 0!==o?o:0},${null!==(s=c.top)&&void 0!==s?s:0})`},y,d),g);return he.renderToStaticMarkup(p)}exports.renderGeoToStaticSVG=function(t){return ve(t)},exports.renderNetworkToStaticSVG=function(t){return pe(t)},exports.renderOrdinalToStaticSVG=function(t){return me(t)},exports.renderToStaticSVG=function(t,e){switch(t){case"xy":return de(e);case"ordinal":return me(e);case"network":return pe(e);case"geo":return ve(e);default:throw Error(`Unknown frame type: ${t}. Must be "xy", "ordinal", "network", or "geo".`)}},exports.renderXYToStaticSVG=function(t){return de(t)};
|
|
1
|
+
"use strict";const t=require("react"),e=require("d3-scale"),r=require("d3-quadtree"),i=require("d3-scale-chromatic"),o=require("d3-array"),n=require("d3-interpolate"),s=require("d3-force"),a=require("d3-chord"),c=require("d3-shape"),l=require("d3-hierarchy"),u=require("d3-geo");function h(t){if(t&&t.__esModule)return t;const e=Object.create(null);if(t)for(const r in t)if("default"!==r){const i=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,i.get?i:{enumerable:!0,get:function(){return t[r]}})}return e.default=t,Object.freeze(e)}const f=h(t);function d(t,e,r,i){return new(r||(r=Promise))(function(o,n){function s(t){try{c(i.next(t))}catch(t){n(t)}}function a(t){try{c(i.throw(t))}catch(t){n(t)}}function c(t){t.done?o(t.value):function(t){return t instanceof r?t:new r(function(e){e(t)})}(t.value).then(s,a)}c((i=i.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class g{constructor(t){if(this._capacity=t,this.head=0,this._size=0,1>t)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(t)}push(t){let e;return this._size===this._capacity?e=this.buffer[this.head]:this._size++,this.buffer[this.head]=t,this.head=(this.head+1)%this._capacity,e}pushMany(t){const e=[];for(const r of t){const t=this.push(r);void 0!==t&&e.push(t)}return e}get(t){if(t>=0&&this._size>t)return this.buffer[(this.head-this._size+t+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 t=0;const e=this;return{next:()=>e._size>t?{done:!1,value:e.get(t++)}:{done:!0,value:void 0}}}forEach(t){const e=(this.head-this._size+this._capacity)%this._capacity;for(let r=0;this._size>r;r++)t(this.buffer[(e+r)%this._capacity],r)}toArray(){const t=Array(this._size),e=(this.head-this._size+this._capacity)%this._capacity;for(let r=0;this._size>r;r++)t[r]=this.buffer[(e+r)%this._capacity];return t}resize(t){if(1>t)throw Error("RingBuffer capacity must be at least 1");const e=this.toArray(),r=[];for(;e.length>t;)r.push(e.shift());this._capacity=t,this.buffer=Array(t),this.head=0,this._size=0;for(const t of e)this.push(t);return r}update(t,e){const r=[],i=(this.head-this._size+this._capacity)%this._capacity;for(let o=0;this._size>o;o++){const n=(i+o)%this._capacity,s=this.buffer[n];if(t(s)){let t;t="object"!=typeof s||null===s?s:Array.isArray(s)?[...s]:Object.assign({},s),r.push(t),this.buffer[n]=e(s)}}return r}remove(t){const e=[],r=[];if(this.forEach(i=>{t(i)?r.push(i):e.push(i)}),0===r.length)return r;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const t of e)this.push(t);return r}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}}class y{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(t){Number.isNaN(t)||(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}evict(t){t!==this._min&&t!==this._max||(this._dirty=!0)}recalculate(t,e){this._min=1/0,this._max=-1/0;for(const r of t){const t=e?e(r):r;Number.isNaN(t)||(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}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 p(t,e,r,i,o){const n=new Map;for(const s of t){const t=e(s),a=r(s);if(null==t||null==a||Number.isNaN(t)||Number.isNaN(a))continue;const c=Math.floor(t/i)*i;let l=n.get(c);if(l||(l={start:c,end:c+i,total:0,categories:new Map},n.set(c,l)),l.total+=a,o){const t=o(s);l.categories.set(t,(l.categories.get(t)||0)+a)}}return n}function m(t,e){return t===e||typeof t==typeof e&&"function"==typeof t&&"function"==typeof e&&""+t==""+e}function x(t,e){if("function"==typeof t)return e=>+t(e);const r=t||e;return t=>+t[r]}function v(t,e){if("function"==typeof t)return t;const r=t||e;return t=>t[r]}function b(t,e){return"function"==typeof t?t:t?e=>e[t]+"":e?t=>t[e]+"":void 0}const k=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];function A(t,e,r){var i,o,n;if(1>=r)return 1;const s=null!==(i=t.minOpacity)&&void 0!==i?i:.1,a=r-1-e;switch(t.type){case"linear":return s+(1-a/(r-1))*(1-s);case"exponential":{const e=null!==(o=t.halfLife)&&void 0!==o?o:r/2;return s+Math.pow(.5,a/e)*(1-s)}case"step":return(null!==(n=t.stepThreshold)&&void 0!==n?n:.5*r)>a?1:s;default:return 1}}function w(t,e,r){var i;const o=null!==(i=t.duration)&&void 0!==i?i:500,n=r-e;return o>n?1-n/o:0}function S(t,e="ease-out-cubic"){return"linear"===e?t:1-Math.pow(1-t,3)}function _(t,e){return Math.min((t-e.startTime)/e.duration,1)}function P(t,e,r){return t+(e-t)*r}function E(){return"undefined"!=typeof performance?performance.now():Date.now()}function M(t,e,r){var i,o,n,s;switch(e.type){case"point":if(e.pointId)return"p:"+e.pointId;if("streaming"===t.runtimeMode&&e.datum){const r=t.getX(e.datum),i=t.getY(e.datum);if(t.getCategory)return`p:${t.getCategory(e.datum)}:${r}:${i}`;if(null!=r&&null!=i)return`p:${r}:${i}`}return"p:"+r;case"rect":return`r:${e.group||""}:${null!==(s=null!==(o=null===(i=e.datum)||void 0===i?void 0:i.binStart)&&void 0!==o?o:null===(n=e.datum)||void 0===n?void 0:n.category)&&void 0!==s?s:r}`;case"heatcell":return`h:${e.x}_${e.y}`;case"candlestick":return null==e.datum?"c:"+r:"c:"+t.getX(e.datum);case"line":return"l:"+(e.group||"_default");case"area":return"a:"+(e.group||"_default");default:return null}}function O(t,e,r,i,o,n){const s=[];for(const o of t){const t=r(o),n=i(o);null==t||null==n||Number.isNaN(t)||Number.isNaN(n)||s.push({px:e.x(t),py:e.y(n),rawY:n,d:o})}s.sort((t,e)=>t.px-e.px);const a=Array(s.length),c=Array(s.length),l=Array(s.length);for(let t=0;s.length>t;t++){const e=s[t];a[t]=[e.px,e.py],c[t]=e.rawY,l[t]=e.d}return{type:"line",path:a,rawValues:c,style:o,datum:l,group:n}}function L(t,e,r,i,o,n,s,a){const c=[];for(const n of t){const t=r(n),s=i(n);if(null==t||null==s||Number.isNaN(t)||Number.isNaN(s))continue;const l=e.x(t),u=a?a(n):o;c.push({px:l,topY:e.y(s),botY:e.y(u)})}c.sort((t,e)=>t.px-e.px);const l=Array(c.length),u=Array(c.length);for(let t=0;c.length>t;t++){const e=c[t];l[t]=[e.px,e.topY],u[t]=[e.px,e.botY]}return{type:"area",topPath:l,bottomPath:u,style:n,datum:t,group:s}}function T(t,e,r,i,o,n,s){const a=r(t),c=i(t);if(null==a||null==c||Number.isNaN(a)||Number.isNaN(c))return null;const l={type:"point",x:e.x(a),y:e.y(c),r:o,style:n,datum:t};return void 0!==s&&(l.pointId=s),l}function D(t,e,r,i,o,n,s){return{type:"rect",x:t,y:e,w:r,h:i,style:o,datum:n,group:s}}function $(t,e,r,i,o,n,s){const a={type:"heatcell",x:t,y:e,w:r,h:i,fill:o,datum:n};return(null==s?void 0:s.showValues)&&(a.showValues=!0,a.value=s.value,s.valueFormat&&(a.valueFormat=s.valueFormat)),a}function z(t,e,r){if(!t.getBounds||!t.scales)return null;const i=[],o=[];for(const r of e){const e=t.getX(r),n=t.getY(r);if(null==e||null==n||Number.isNaN(e)||Number.isNaN(n))continue;const s=t.getBounds(r),a=t.scales.x(e);if(s&&0!==s)i.push([a,t.scales.y(n+s)]),o.push([a,t.scales.y(n-s)]);else{const e=t.scales.y(n);i.push([a,e]),o.push([a,e])}}return 2>i.length?null:{type:"area",topPath:i,bottomPath:o,style:t.resolveBoundsStyle(r,e[0]),datum:e,group:r,interactive:!1}}function j(t,e,r,i){var o;if(!t.config.pointStyle)return;const n=null!=i?i:t.getY;for(const i of e){const e=t.resolveGroupColor(i.key);for(const s of i.data){let i=t.config.pointStyle(s);!i.fill&&e&&(i=Object.assign(Object.assign({},i),{fill:e}));const a=null!==(o=i.r)&&void 0!==o?o:3,c=t.getPointId?t.getPointId(s)+"":void 0,l=T(s,t.scales,t.getX,n,a,i,c);l&&r.push(l)}}}const N={blues:i.interpolateBlues,reds:i.interpolateReds,greens:i.interpolateGreens,viridis:i.interpolateViridis},B=new Map;class R{constructor(t){if(this.xExtent=new y,this.yExtent=new y,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.prevPathMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupColorMap=new Map,this._barCategoryCache=null,this._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=t,this.buffer=new g(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=x(t.timeAccessor||t.xAccessor,"time"),this.getY=x(t.valueAccessor||t.yAccessor,"value")):(this.getX=x(t.xAccessor,"x"),this.getY=x(t.yAccessor,"y")),this.getGroup=b(t.groupAccessor),this.getCategory=b(t.categoryAccessor),this.getSize=t.sizeAccessor?x(t.sizeAccessor,"size"):void 0,this.getColor=b(t.colorAccessor),this.getBounds=t.boundsAccessor?x(t.boundsAccessor,"bounds"):void 0,this.getY0=t.y0Accessor?x(t.y0Accessor,"y0"):void 0,this.getPointId=b(t.pointIdAccessor),"candlestick"===t.chartType){const e=null!=t.openAccessor,r=null!=t.closeAccessor;this.getOpen=e?x(t.openAccessor,"open"):void 0,this.getHigh=x(t.highAccessor,"high"),this.getLow=x(t.lowAccessor,"low"),this.getClose=r?x(t.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!r}t.pulse&&(this.timestampBuffer=new g(t.windowSize))}ingest(t){const e="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=e,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,t.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?x(this.config.timeAccessor||this.config.xAccessor,"time"):x(this.config.xAccessor,"x"),this.xIsDate=!1,t.inserts.length>0){const e=t.inserts[0],r=this.config.xAccessor,i="function"==typeof r?r(e):e[r||"x"],o=i instanceof Date,n="string"==typeof i&&i.length>=10&&!isNaN(new Date(i).getTime())&&isNaN(Number(i));if(this.xIsDate=o||n,n){const t="string"==typeof r?r:void 0;this.getX=t?e=>+new Date(e[t]):t=>+(r(t)instanceof Date?r(t):new Date(r(t)))}}const r=t.totalSize||t.inserts.length;r>this.buffer.capacity&&(this.buffer.resize(r),this.timestampBuffer&&r>this.timestampBuffer.capacity&&this.timestampBuffer.resize(r));for(const r of t.inserts)this.buffer.push(r),this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(r)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(r)),this.yExtent.push(this.getLow(r))):(this.yExtent.push(this.getY(r)),this.getY0&&this.yExtent.push(this.getY0(r)))}else for(const r of t.inserts){if("growing"===this.config.windowMode&&this.buffer.full){const t=this.config.maxCapacity||1e6;t>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,t),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap))}const t=this.buffer.push(r);this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(r)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(r)),this.yExtent.push(this.getLow(r))):(this.yExtent.push(this.getY(r)),this.getY0&&this.yExtent.push(this.getY0(r))),null!=t&&(this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):this.yExtent.evict(this.getY(t)))}return!0}computeScene(t){var r,i,o,n,s,a,c;const{config:l,buffer:u}=this;if(!this.needsFullRebuild&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(null!==(r=this.config.scalePadding)&&void 0!==r?r:0)&&(this.lastLayout.width!==t.width||this.lastLayout.height!==t.height))return void this.remapScene(t);if(this.xExtent.dirty&&this.xExtent.recalculate(u,this.getX),this.yExtent.dirty)if("candlestick"===l.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const t of u)this.yExtent.push(this.getHigh(t)),this.yExtent.push(this.getLow(t))}else this.yExtent.recalculate(u,this.getY);const h=this.getBufferArray(),f=this.xExtent.extent,d=this.yExtent.extent;let g=l.xExtent?[null!==(i=l.xExtent[0])&&void 0!==i?i:f[0],null!==(o=l.xExtent[1])&&void 0!==o?o:f[1]]:f,y=l.yExtent?[null!==(n=l.yExtent[0])&&void 0!==n?n:d[0],null!==(s=l.yExtent[1])&&void 0!==s?s:d[1]]:d;const m=l.yExtent&&null!=l.yExtent[0]&&null!=l.yExtent[1];if("stackedarea"===l.chartType&&!m&&u.size>0)if(l.normalize)y=[0,1+l.extentPadding];else{const t=`${u.size}:${this._ingestVersion}`;if(this._stackExtentCache&&this._stackExtentCache.key===t)y=this._stackExtentCache.yDomain;else{const e=this.groupData(h),r=new Map;for(const t of e)for(const e of t.data){const t=this.getX(e),i=this.getY(e);null==t||null==i||Number.isNaN(t)||Number.isNaN(i)||r.set(t,(r.get(t)||0)+i)}let i=0;for(const t of r.values())t>i&&(i=t);y=[0,i+(i>0?i*l.extentPadding:1)],this._stackExtentCache={key:t,yDomain:y}}}else if("bar"===l.chartType&&l.binSize&&!m&&u.size>0){const[,t]=function(t,e,r,i,o){const n=p(t,e,r,i,o);if(0===n.size)return[0,0];let s=0;for(const t of n.values())t.total>s&&(s=t.total);return[0,s]}(u,this.getX,this.getY,l.binSize,this.getCategory);y=[0,t+t*l.extentPadding]}else if("waterfall"===l.chartType&&!m&&u.size>0){const[t,e]=function(t,e){let r=0,i=0,o=0;for(const n of t){const t=e(n);null==t||Number.isNaN(t)||(o+=t,r>o&&(r=o),o>i&&(i=o))}return[r,i]}(u,this.getY),r=e-t,i=r>0?r*l.extentPadding:1;y=[Math.min(0,t-Math.abs(i)),Math.max(0,e+Math.abs(i))]}else if(!m&&y[0]!==1/0){if(this.getBounds)for(const t of h){const e=this.getY(t),r=this.getBounds(t);null!=e&&!Number.isNaN(e)&&r&&(e+r>y[1]&&(y[1]=e+r),y[0]>e-r&&(y[0]=e-r))}const t=y[1]-y[0],e=t>0?t*l.extentPadding:1,r=null===(a=l.yExtent)||void 0===a?void 0:a[0],i=null===(c=l.yExtent)||void 0===c?void 0:c[1];y=[null!=r?y[0]:y[0]-e,null!=i?y[1]:y[1]+e],"log"===l.yScaleType&&0>=y[0]&&d[0]>0&&(y[0]=null!=r?y[0]:d[0]/(1+l.extentPadding))}if(g[0]===1/0||g[1]===-1/0)if("time"===l.xScaleType){const t=Date.now();g=[t-864e5,t]}else g=[0,1];y[0]!==1/0&&y[1]!==-1/0||(y=[0,1]);const x="streaming"===l.runtimeMode,v=Math.max(0,Math.min(l.scalePadding||0,Math.min(t.width,t.height)/2-1));if(x)if("x"==("up"===(b=l.arrowOfTime)||"down"===b?"y":"x")){const r="right"===l.arrowOfTime?[v,t.width-v]:[t.width-v,v];this.scales={x:e.scaleLinear().domain(g).range(r),y:e.scaleLinear().domain(y).range([t.height-v,v])}}else{const r="down"===l.arrowOfTime?[v,t.height-v]:[t.height-v,v];this.scales={x:e.scaleLinear().domain(y).range([v,t.width-v]),y:e.scaleLinear().domain(g).range(r)}}else{const r=(t,r,i)=>{if("log"===t){const t=[Math.max(r[0],1e-6),Math.max(r[1],1e-6)];return e.scaleLog().domain(t).range(i).clamp(!0)}return"time"===t?e.scaleTime().domain([new Date(r[0]),new Date(r[1])]).range(i):e.scaleLinear().domain(r).range(i)};this.scales={x:r(l.xScaleType,g,[v,t.width-v]),y:r(l.yScaleType,y,[t.height-v,v])}}var b;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(t,h),this.config.decay&&this.applyDecay(this.scene,h),this.config.pulse&&this.applyPulse(this.scene,h),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.rebuildQuadtree(),this.needsFullRebuild=!1,this.lastLayout={width:t.width,height:t.height},this.version++}rebuildQuadtree(){const t=this.config.chartType;if("scatter"!==t&&"bubble"!==t)return void(this._quadtree=null);const e=this.scene.filter(t=>"point"===t.type);this._quadtree=e.length>R.QUADTREE_THRESHOLD?r.quadtree().x(t=>t.x).y(t=>t.y).addAll(e):null}get quadtree(){return this._quadtree}remapScene(t){const r=t.width/this.lastLayout.width,i=t.height/this.lastLayout.height;for(const t of this.scene)switch(t.type){case"line":for(const e of t.path)e[0]*=r,e[1]*=i;break;case"area":for(const e of t.topPath)e[0]*=r,e[1]*=i;for(const e of t.bottomPath)e[0]*=r,e[1]*=i;break;case"point":t.x*=r,t.y*=i;break;case"rect":case"heatcell":t.x*=r,t.y*=i,t.w*=r,t.h*=i;break;case"candlestick":t.x*=r,t.openY*=i,t.closeY*=i,t.highY*=i,t.lowY*=i}const o=this.scales.x.domain(),n=this.scales.y.domain(),s=this.scales.x.range(),a=this.scales.y.range(),c=(t,r,i)=>{if("log"===t){const t=[Math.max(r[0],1e-6),Math.max(r[1],1e-6)];return e.scaleLog().domain(t).range(i).clamp(!0)}return"time"===t?e.scaleTime().domain([new Date(r[0]),new Date(r[1])]).range(i):e.scaleLinear().domain(r).range(i)},l=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(t.width,t.height)/2-1)),u=a[1]>a[0];this.scales={x:c(this.config.xScaleType,o,s[0]>s[1]?[t.width-l,l]:[l,t.width-l]),y:c(this.config.yScaleType,n,u?[l,t.height-l]:[t.height-l,l])},this.lastLayout={width:t.width,height:t.height},this.rebuildQuadtree(),this.version++}buildSceneNodes(t,e){var r;const{config:o,scales:n}=this;if(!n||0===e.length)return[];const s={scales:n,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:(t,e)=>this.resolveLineStyle(t,e),resolveAreaStyle:(t,e)=>this.resolveAreaStyle(t,e),resolveBoundsStyle:(t,e)=>this.resolveBoundsStyle(t,e),resolveColorMap:t=>this.resolveColorMap(t),resolveGroupColor:t=>this.resolveGroupColor(t),groupData:t=>this.groupData(t),barCategoryCache:this._barCategoryCache};switch(o.chartType){case"line":return function(t,e){var r;const i=t.groupData(e),o=[],n=null===(r=t.config.annotations)||void 0===r?void 0:r.filter(t=>"threshold"===t.type&&t.color).map(t=>({value:t.value,color:t.color,thresholdType:t.thresholdType||"greater"}));if(t.getBounds)for(const e of i){const r=z(t,e.data,e.key);r&&o.push(r)}for(const e of i){const r=t.resolveLineStyle(e.key,e.data[0]),i=O(e.data,t.scales,t.getX,t.getY,r,e.key);n&&n.length>0&&(i.colorThresholds=n),t.config.curve&&"linear"!==t.config.curve&&(i.curve=t.config.curve),t.config.lineGradient&&(i.strokeGradient=t.config.lineGradient),o.push(i)}return j(t,i,o),o}(s,e);case"area":return function(t,e){const r=t.groupData(e),i=[],o=t.scales.y.domain()[0],n=t.getY0?e=>{const r=t.getY0(e);return null==r?o:r}:void 0;for(const e of r){const r=t.resolveAreaStyle(e.key,e.data[0]),s=L(e.data,t.scales,t.getX,t.getY,o,r,e.key,n);t.config.gradientFill&&(s.fillGradient=t.config.gradientFill),t.config.curve&&"linear"!==t.config.curve&&(s.curve=t.config.curve),t.config.lineGradient&&(s.strokeGradient=t.config.lineGradient),i.push(s)}return j(t,r,i),i}(s,e);case"mixed":return function(t,e){const r=t.groupData(e),i=[],o=t.config.areaGroups||new Set,n=t.scales.y.domain()[0],s=t.getY0?e=>{const r=t.getY0(e);return null==r?n:r}:void 0;for(const e of r)if(o.has(e.key)){const r=t.resolveAreaStyle(e.key,e.data[0]),o=L(e.data,t.scales,t.getX,t.getY,n,r,e.key,s);t.config.gradientFill&&(o.fillGradient=t.config.gradientFill),t.config.curve&&"linear"!==t.config.curve&&(o.curve=t.config.curve),t.config.lineGradient&&(o.strokeGradient=t.config.lineGradient),i.push(o)}else{const r=t.resolveLineStyle(e.key,e.data[0]),o=O(e.data,t.scales,t.getX,t.getY,r,e.key);t.config.curve&&"linear"!==t.config.curve&&(o.curve=t.config.curve),t.config.lineGradient&&(o.strokeGradient=t.config.lineGradient),i.push(o)}return j(t,r,i),i}(s,e);case"stackedarea":return function(t,e){const r=t.groupData(e);r.sort((t,e)=>e.key>t.key?-1:t.key>e.key?1:0);const i=t.config.curve&&"linear"!==t.config.curve?t.config.curve:void 0,{nodes:o,stackedTops:n}=function(t,e,r,i,o,n,s){var a;const c=new Set;for(const e of t)for(const t of e.data){const e=r(t);null==e||Number.isNaN(e)||c.add(e)}const l=Array.from(c).sort((t,e)=>t-e),u=new Map;for(const e of t){const t=new Map;for(const o of e.data){const e=r(o),n=i(o);null==e||null==n||Number.isNaN(e)||Number.isNaN(n)||t.set(e,(t.get(e)||0)+n)}u.set(e.key,t)}let h;if(n){h=new Map;for(const e of l){let r=0;for(const i of t)r+=(null===(a=u.get(i.key))||void 0===a?void 0:a.get(e))||0;h.set(e,r||1)}}const f=[],d=new Map,g=new Map;for(const t of l)g.set(t,0);for(const r of t){const t=u.get(r.key),i=[],a=[],c=new Map;for(const r of l){let o=t.get(r)||0;const s=g.get(r);n&&(o/=h.get(r));const l=s+o,u=e.x(r);a.push([u,e.y(s)]),i.push([u,e.y(l)]),g.set(r,l),c.set(r,l)}d.set(r.key,c);const y={type:"area",topPath:i,bottomPath:a,style:o(r.key,r.data[0]),datum:r.data,group:r.key};s&&(y.curve=s),f.push(y)}return{nodes:f,stackedTops:d}}(r,t.scales,t.getX,t.getY,(e,r)=>t.resolveAreaStyle(e,r),t.config.normalize,i),s=o;if(t.config.pointStyle){const e=new WeakMap;for(const i of r){const r=n.get(i.key);if(r)for(const o of i.data){const i=t.getX(o),n=t.getY(o);null==i||Number.isNaN(i)||null==n||Number.isNaN(n)||!r.has(i)||e.set(o,r.get(i))}}const i=r=>{var i;return null!==(i=e.get(r))&&void 0!==i?i:t.getY(r)};j(t,r,s,i)}return s}(s,e);case"scatter":case"bubble":return function(t,e){const r=[],i="bubble"===t.config.chartType?10:5,o=t.config.sizeRange||[3,15];let n=null;if(t.getSize&&!t.config.pointStyle){const r=e.map(e=>t.getSize(e)).filter(t=>null!=t&&!Number.isNaN(t));if(r.length>0){let t=1/0,e=-1/0;for(const i of r)t>i&&(t=i),i>e&&(e=i);n=r=>t===e?(o[0]+o[1])/2:o[0]+(r-t)/(e-t)*(o[1]-o[0])}}const s=t.getColor?t.resolveColorMap(e):null;for(const o of e){let e=t.config.pointStyle?t.config.pointStyle(o):{fill:"#4e79a7",opacity:.8},a=e.r||i;if(n&&t.getSize){const e=t.getSize(o);null==e||Number.isNaN(e)||(a=n(e))}if(s&&t.getColor&&!e.fill){const r=t.getColor(o);r&&s.has(r)&&(e=Object.assign(Object.assign({},e),{fill:s.get(r)}))}const c=t.getPointId?t.getPointId(o)+"":void 0,l=T(o,t.scales,t.getX,t.getY,a,e,c);l&&r.push(l)}return r}(s,e);case"heatmap":return function(t,e,r){if(t.config.heatmapAggregation)return function(t,e,r){var i,o,n;const s=Math.max(1,Math.floor(null!==(i=t.config.heatmapXBins)&&void 0!==i?i:20)),a=Math.max(1,Math.floor(null!==(o=t.config.heatmapYBins)&&void 0!==o?o:20)),c=null!==(n=t.config.heatmapAggregation)&&void 0!==n?n:"count",l=x(t.config.valueAccessor,"value");if(!t.scales||0===e.length)return[];const[u,h]=t.scales.x.domain(),[f,d]=t.scales.y.domain(),g=(h-u||1)/s,y=(d-f||1)/a,p=s*a;if(p>1e6)return[];const m=new Int32Array(p),v=new Float64Array(p);for(let r=0;e.length>r;r++){const i=e[r],o=t.getX(i),n=t.getY(i);if(!isFinite(o)||!isFinite(n))continue;const c=Math.min(Math.floor((o-u)/g),s-1),h=Math.min(Math.floor((n-f)/y),a-1);if(0>c||0>h)continue;const d=h*s+c;m[d]++;const p=l(i);v[d]+=isFinite(p)?p:0}let b=1/0,k=-1/0;for(let t=0;p>t;t++){if(0===m[t])continue;let e;switch(c){case"sum":e=v[t];break;case"mean":e=v[t]/m[t];break;default:e=m[t]}b>e&&(b=e),e>k&&(k=e)}if(!isFinite(b))return[];const A=k-b||1,w=r.width/s,S=r.height/a,_=t.config.showValues,P=t.config.heatmapValueFormat,E=[];for(let t=0;a>t;t++){const e=t*s;for(let r=0;s>r;r++){const i=e+r;if(0===m[i])continue;let o;switch(c){case"sum":o=v[i];break;case"mean":o=v[i]/m[i];break;default:o=m[i]}const n=(o-b)/A;E.push($(r*w,(a-1-t)*S,w,S,`rgb(${220-(180*n+.5)|0},${220-(100*n+.5)|0},${255-(50*n+.5)|0})`,{xi:r,yi:t,value:o,count:m[i],sum:v[i]},_?{value:o,showValues:!0,valueFormat:P}:void 0))}}return E}(t,e,r);if(0===e.length)return[];const o=x(t.config.valueAccessor,"value"),n=v(t.config.xAccessor,"x"),s=v(t.config.yAccessor,"y"),a=new Map,c=new Map,l=Array(e.length),u=Array(e.length);for(let t=0;e.length>t;t++){const r=e[t],i=n(r),o=s(r);l[t]=i,u[t]=o,a.has(i)||a.set(i,a.size),c.has(o)||c.set(o,c.size)}const h=a.size,f=c.size;if(0===h||0===f)return[];const d=Array.from(a.keys()),g=Array.from(c.keys()),y=d.every(t=>"number"==typeof t&&!isNaN(t)),p=g.every(t=>"number"==typeof t&&!isNaN(t));if(y){d.sort((t,e)=>t-e),a.clear();for(let t=0;d.length>t;t++)a.set(d[t],t)}if(p){g.sort((t,e)=>t-e),c.clear();for(let t=0;g.length>t;t++)c.set(g[t],t)}const m=new Float64Array(e.length),b=new Float64Array(e.length),k=Array(e.length),A=new Map;let w=0;for(let t=0;e.length>t;t++){const r=e[t],i=a.get(l[t]),n=c.get(u[t]);if(void 0===i||void 0===n)continue;const s=o(r),f=n*h+i,d=A.get(f);let g;void 0!==d?g=d:(g=w++,A.set(f,g)),m[g]=f,b[g]=s,k[g]=r}let S=1/0,_=-1/0;for(let t=0;w>t;t++){const e=b[t];isFinite(e)&&(S>e&&(S=e),e>_&&(_=e))}if(!isFinite(S)||!isFinite(_))return[];const P=function(t){const e=t in N?t:"blues";let r=B.get(e);if(r)return r;r=Array(256);const o=N[e]||i.interpolateBlues;for(let t=0;256>t;t++)r[t]=o(t/255);return B.set(e,r),r}("string"==typeof t.config.colorScheme?t.config.colorScheme:"blues"),E=255/(_-S||1),M=r.width/h,O=r.height/f,L=t.config.showValues,T=t.config.heatmapValueFormat,D=[];for(let t=0;w>t;t++){const e=b[t];if(!isFinite(e))continue;const r=m[t],i=r%h;D.push($(i*M,(f-1-(r-i)/h)*O,M,O,P[Math.min((e-S)*E+.5|0,255)],k[t],L?{value:e,showValues:!0,valueFormat:T}:void 0))}return D}(s,e,t);case"bar":{const t=function(t,e){var r;if(!t.config.binSize)return{nodes:[],binBoundaries:[]};const i=p(e,t.getX,t.getY,t.config.binSize,t.getCategory);if(0===i.size)return{nodes:[],binBoundaries:[]};let o=null;if(t.getCategory){const e=new Set;for(const t of i.values())for(const r of t.categories.keys())e.add(r);const r=t.config.barColors?Object.keys(t.config.barColors):[],n=new Set(r),s=Array.from(e).filter(t=>!n.has(t)).sort(),a=r.filter(t=>e.has(t)),c=a.join("\0")+""+s.join("\0");t.barCategoryCache&&t.barCategoryCache.key===c?o=t.barCategoryCache.order:(o=[...a,...s],t.barCategoryCache={key:c,order:o})}const n=[],s=t.scales,[a,c]=s.x.domain();for(const e of i.values()){const i=Math.max(e.start,a),l=Math.min(e.end,c);if(i>=l)continue;const u=s.x(i),h=s.x(l),f=Math.abs(h-u),d=f>2?1:0,g=Math.min(u,h)+d/2,y=Math.max(f-d,1);if(y>0)if(o&&e.categories.size>0){let i=0;for(const a of o){const o=e.categories.get(a)||0;if(0===o)continue;const c=s.y(i),l=s.y(i+o);n.push(D(g,Math.min(c,l),y,Math.abs(c-l),{fill:(null===(r=t.config.barColors)||void 0===r?void 0:r[a])||"#4e79a7"},{binStart:e.start,binEnd:e.end,total:e.total,category:a,categoryValue:o},a)),i+=o}}else{const t=s.y(0),r=s.y(e.total);n.push(D(g,Math.min(t,r),y,Math.abs(t-r),{fill:"#007bff"},{binStart:e.start,binEnd:e.end,total:e.total}))}}const l=new Set;for(const t of i.values())l.add(t.start),l.add(t.end);return{nodes:n,binBoundaries:Array.from(l).sort((t,e)=>t-e)}}(s,e);return this._barCategoryCache=null!==(r=s.barCategoryCache)&&void 0!==r?r:null,this._binBoundaries=t.binBoundaries,t.nodes}case"swarm":return function(t,e){var r,i,o,n;const s=[],a=t.config.swarmStyle||{},c=null!==(r=a.radius)&&void 0!==r?r:3,l=null!==(i=a.fill)&&void 0!==i?i:"#007bff",u=null!==(o=a.opacity)&&void 0!==o?o:.7,h=a.stroke,f=a.strokeWidth;for(const r of e){const e=t.getX(r),i=t.getY(r);if(null==i||Number.isNaN(i))continue;const o=t.scales.x(e),a=t.scales.y(i);let d=l;if(t.getCategory){const e=t.getCategory(r);d=(null===(n=t.config.barColors)||void 0===n?void 0:n[e])||d}const g={type:"point",x:o,y:a,r:c,style:{fill:d,opacity:u,stroke:h,strokeWidth:f},datum:r};t.getPointId&&(g.pointId=t.getPointId(r)+""),s.push(g)}return s}(s,e);case"waterfall":return function(t,e,r){var i,o,n;const s=[],a=t.scales,c=t.config.waterfallStyle,l=e.filter(e=>{const r=t.getY(e),i=t.getX(e);return null!=r&&!Number.isNaN(r)&&null!=i&&isFinite(i)});if(0===l.length)return s;const u=null!==(i=null==c?void 0:c.positiveColor)&&void 0!==i?i:"#28a745",h=null!==(o=null==c?void 0:c.negativeColor)&&void 0!==o?o:"#dc3545",f=null!==(n=null==c?void 0:c.gap)&&void 0!==n?n:1,d=null==c?void 0:c.stroke,g=null==c?void 0:c.strokeWidth;let y=0;for(let e=0;l.length>e;e++){const i=l[e],o=t.getX(i),n=t.getY(i),p=y+n;let m;m=l.length-1>e?t.getX(l[e+1])-o:e>0?o-t.getX(l[e-1]):0;const x=a.x(o),v=0!==m?a.x(o+m):x+r.width/10,b=Math.min(x,v)+f/2,k=Math.max(x,v)-f/2-b;if(0>=k){y=p;continue}const A=a.y(y),w=a.y(p);s.push(D(b,Math.min(A,w),k,Math.abs(A-w),{fill:0>n?h:u,stroke:d,strokeWidth:g},Object.assign(Object.assign({},i),{baseline:y,cumEnd:p,delta:n,_connectorStroke:null==c?void 0:c.connectorStroke,_connectorWidth:null==c?void 0:c.connectorWidth}))),y=p}return s}(s,e,t);case"candlestick":return function(t,e){var r,i;if(!t.getHigh||!t.getLow||!t.scales)return[];const o=null!==(r=t.config.candlestickRangeMode)&&void 0!==r&&r;if(!(o||t.getOpen&&t.getClose))return[];const n=[],s=t.config.candlestickStyle||{},a=s.rangeColor||"#6366f1",c=o?a:s.upColor||"#28a745",l=o?a:s.downColor||"#dc3545",u=o?a:s.wickColor||"#333",h=s.wickWidth||(o?2:1),f=e.map(e=>t.getX(e)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let d=o?0:null!==(i=s.bodyWidth)&&void 0!==i?i:0;if(!o&&null==s.bodyWidth&&f.length>1){let e=1/0;for(let r=1;f.length>r;r++){const i=Math.abs(t.scales.x(f[r])-t.scales.x(f[r-1]));i>0&&e>i&&(e=i)}d=e!==1/0?Math.max(2,Math.min(.6*e,20)):6}else o||null!=s.bodyWidth||(d=6);for(const r of e){const e=t.getX(r);if(null==e||Number.isNaN(e))continue;const i=t.getHigh(r),s=t.getLow(r);if(null==i||Number.isNaN(i)||null==s||Number.isNaN(s))continue;const a=o?i:t.getOpen(r),f=o?s:t.getClose(r);if(!o&&[a,f].some(t=>null==t||Number.isNaN(t)))continue;const g=f>=a,y={type:"candlestick",x:t.scales.x(e),openY:t.scales.y(a),closeY:t.scales.y(f),highY:t.scales.y(i),lowY:t.scales.y(s),bodyWidth:d,upColor:c,downColor:l,wickColor:u,wickWidth:h,isUp:g,datum:r};o&&(y.isRange=!0),n.push(y)}return n}(s,e);default:return[]}}resolveBoundsStyle(t,e){const r=this.config.boundsStyle;return"function"==typeof r?r(e||{},t):r&&"object"==typeof r?r:{fill:this.resolveLineStyle(t,e).stroke||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(t,e){const r=this.config.decay;return r&&e>1?A(r,t,e):1}applyDecay(t,e){this.config.decay&&function(t,e,r){var i,o;const n=r.length;if(1>=n)return;const s=new Map;for(let t=0;r.length>t;t++)s.set(r[t],t);for(const r of e){if("line"===r.type){const e=Array.isArray(r.datum)?r.datum:[];if(2>e.length)continue;const i=Array(e.length);let o=!1;for(let r=0;e.length>r;r++){const a=s.get(e[r]);null!=a?(i[r]=A(t,a,n),1>i[r]&&(o=!0)):i[r]=1}o&&(r._decayOpacities=i);continue}if("area"===r.type){const e=Array.isArray(r.datum)?r.datum:[],i=r.topPath?r.topPath.length:e.length;if(2>i)continue;if(e.length===i){const o=Array(i);let a=!1;for(let r=0;e.length>r;r++){const i=s.get(e[r]);null!=i?(o[r]=A(t,i,n),1>o[r]&&(a=!0)):o[r]=1}a&&(r._decayOpacities=o)}else{let o=1;for(const r of e){const e=s.get(r);if(null!=e){const r=A(t,e,n);o>r&&(o=r)}}if(1>o){const t=Array(i);t.fill(o),r._decayOpacities=t}}continue}const e=s.get(r.datum);if(null==e)continue;const a=A(t,e,n);if("heatcell"===r.type)r.style={opacity:a};else if("candlestick"===r.type)r._decayOpacity=a;else{const t=null!==(o=null===(i=r.style)||void 0===i?void 0:i.opacity)&&void 0!==o?o:1;r.style=Object.assign(Object.assign({},r.style),{opacity:t*a})}}}(this.config.decay,t,e)}applyPulse(t,e){this.config.pulse&&this.timestampBuffer&&function(t,e,r,i){var o,n;const s="undefined"!=typeof performance?performance.now():Date.now(),a=null!==(o=t.color)&&void 0!==o?o:"rgba(255,255,255,0.6)",c=null!==(n=t.glowRadius)&&void 0!==n?n:4,l=new Map;for(let t=0;r.length>t;t++)l.set(r[t],t);for(const r of e){if("line"===r.type)continue;if("area"===r.type){const e=Array.isArray(r.datum)?r.datum:[r.datum];let o=0;for(const r of e){const e=l.get(r);if(null==e)continue;const n=i.get(e);if(null==n)continue;const a=w(t,n,s);a>o&&(o=a)}o>0&&(r._pulseIntensity=o,r._pulseColor=a);continue}const e=l.get(r.datum);if(null==e)continue;const o=i.get(e);if(null==o)continue;const n=w(t,o,s);n>0&&(r._pulseIntensity=n,r._pulseColor=a,r._pulseGlowRadius=c)}}(this.config.pulse,t,e,this.timestampBuffer)}get hasActivePulses(){return!!this.config.pulse&&function(t,e){var r;if(!e||0===e.size)return!1;const i="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(r=t.duration)&&void 0!==r?r:500,n=e.peek();return null!=n&&o>i-n}(this.config.pulse,this.timestampBuffer)}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(t,e,r,i){var o,n,s;r.clear(),i.clear();for(let a=0;e.length>a;a++){const c=e[a],l=M(t,c,a);l&&("point"===c.type?r.set(l,{x:c.x,y:c.y,r:c.r,opacity:c.style.opacity}):"rect"===c.type?r.set(l,{x:c.x,y:c.y,w:c.w,h:c.h,opacity:c.style.opacity}):"heatcell"===c.type?r.set(l,{x:c.x,y:c.y,w:c.w,h:c.h,opacity:null===(o=c.style)||void 0===o?void 0:o.opacity}):"candlestick"===c.type?r.set(l,{x:c.x,y:c.openY}):"line"===c.type?i.set(l,{path:c.path.map(t=>[t[0],t[1]]),opacity:null===(n=c.style)||void 0===n?void 0:n.opacity}):"area"===c.type&&i.set(l,{topPath:c.topPath.map(t=>[t[0],t[1]]),bottomPath:c.bottomPath.map(t=>[t[0],t[1]]),opacity:null===(s=c.style)||void 0===s?void 0:s.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}startTransition(){if(!this.config.transition)return;const t=function(t,e,r,i,o){var n,s,a,c,l,u,h,f,d,g,y,p,m,x,v,b,k,A,w,S,_,P,O,L,T,D,$,z;if(0===i.size&&0===o.size)return r;const j=null!==(n=e.duration)&&void 0!==n?n:300;if(r.exitNodes.length>0){const t=new Set(r.exitNodes);r.scene=r.scene.filter(e=>!t.has(e)),r.exitNodes=[]}let N=!1;const B=new Set,R=new Set;for(let e=0;r.scene.length>e;e++){const n=r.scene[e],w=M(t,n,e);if(!w)continue;if(n._transitionKey=w,"line"===n.type||"area"===n.type){const t=o.get(w);if(t){if(R.add(w),"line"===n.type&&t.path&&t.path.length===n.path.length){n._targetPath=n.path.map(t=>[t[0],t[1]]),n._prevPath=t.path;for(let e=0;n.path.length>e;e++)n.path[e]=[t.path[e][0],t.path[e][1]];N=!0}else if("area"===n.type&&t.topPath&&t.bottomPath&&t.topPath.length===n.topPath.length&&t.bottomPath.length===n.bottomPath.length){n._targetTopPath=n.topPath.map(t=>[t[0],t[1]]),n._targetBottomPath=n.bottomPath.map(t=>[t[0],t[1]]),n._prevTopPath=t.topPath,n._prevBottomPath=t.bottomPath;for(let e=0;n.topPath.length>e;e++)n.topPath[e]=[t.topPath[e][0],t.topPath[e][1]];for(let e=0;n.bottomPath.length>e;e++)n.bottomPath[e]=[t.bottomPath[e][0],t.bottomPath[e][1]];N=!0}n._targetOpacity=null!==(s=n.style.opacity)&&void 0!==s?s:1,n._startOpacity=null!==(c=null!==(a=t.opacity)&&void 0!==a?a:n.style.opacity)&&void 0!==c?c:1}else n._targetOpacity=null!==(l=n.style.opacity)&&void 0!==l?l:1,n._startOpacity=0,n.style=Object.assign(Object.assign({},n.style),{opacity:0}),N=!0;continue}const S=i.get(w);if("point"===n.type)if(S){B.add(w);const t={x:n.x,y:n.y,r:n.r};n._targetOpacity=null!==(u=n.style.opacity)&&void 0!==u?u:1,S.x===t.x&&S.y===t.y&&S.r===t.r||(n._targetX=t.x,n._targetY=t.y,n._targetR=t.r,n.x=S.x,n.y=S.y,n.r=null!==(h=S.r)&&void 0!==h?h:n.r,N=!0)}else n._targetOpacity=null!==(f=n.style.opacity)&&void 0!==f?f:1,n.style=Object.assign(Object.assign({},n.style),{opacity:0}),N=!0;else if("rect"===n.type)if(S){B.add(w);const t={x:n.x,y:n.y,w:n.w,h:n.h};n._targetOpacity=null!==(d=n.style.opacity)&&void 0!==d?d:1,S.x===t.x&&S.y===t.y&&S.w===t.w&&S.h===t.h||(n._targetX=t.x,n._targetY=t.y,n._targetW=t.w,n._targetH=t.h,n.x=S.x,n.y=S.y,n.w=null!==(g=S.w)&&void 0!==g?g:n.w,n.h=null!==(y=S.h)&&void 0!==y?y:n.h,N=!0)}else n._targetOpacity=null!==(p=n.style.opacity)&&void 0!==p?p:1,n.style=Object.assign(Object.assign({},n.style),{opacity:0}),N=!0;else if("heatcell"===n.type)if(S){B.add(w);const t={x:n.x,y:n.y,w:n.w,h:n.h};n._targetOpacity=null!==(x=null===(m=n.style)||void 0===m?void 0:m.opacity)&&void 0!==x?x:1,S.x===t.x&&S.y===t.y&&S.w===t.w&&S.h===t.h||(n._targetX=t.x,n._targetY=t.y,n._targetW=t.w,n._targetH=t.h,n.x=S.x,n.y=S.y,n.w=null!==(v=S.w)&&void 0!==v?v:n.w,n.h=null!==(b=S.h)&&void 0!==b?b:n.h,N=!0)}else n._targetOpacity=null!==(A=null===(k=n.style)||void 0===k?void 0:k.opacity)&&void 0!==A?A:1,n.style=Object.assign(Object.assign({},n.style||{}),{opacity:0}),N=!0}for(const[t,e]of o)if(!R.has(t))if(t.startsWith("l:")&&e.path){const i={type:"line",path:e.path.map(t=>[t[0],t[1]]),group:t.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:null!==(w=e.opacity)&&void 0!==w?w:1},_targetOpacity:0,_transitionKey:t,datum:null};r.exitNodes.push(i),N=!0}else if(t.startsWith("a:")&&e.topPath&&e.bottomPath){const i={type:"area",topPath:e.topPath.map(t=>[t[0],t[1]]),bottomPath:e.bottomPath.map(t=>[t[0],t[1]]),group:t.slice(2),style:{fill:"#999",opacity:null!==(S=e.opacity)&&void 0!==S?S:1},_targetOpacity:0,_transitionKey:t,datum:null};r.exitNodes.push(i),N=!0}for(const[t,e]of i)if(!B.has(t)){if(t.startsWith("p:")){const i={type:"point",x:e.x,y:e.y,r:null!==(_=e.r)&&void 0!==_?_:3,style:{opacity:null!==(P=e.opacity)&&void 0!==P?P:1},datum:null,_targetOpacity:0,_transitionKey:t};r.exitNodes.push(i)}else if(t.startsWith("r:")){const i={type:"rect",x:e.x,y:e.y,w:null!==(O=e.w)&&void 0!==O?O:0,h:null!==(L=e.h)&&void 0!==L?L:0,style:{opacity:null!==(T=e.opacity)&&void 0!==T?T:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t};r.exitNodes.push(i)}else if(t.startsWith("h:")){const i={type:"heatcell",x:e.x,y:e.y,w:null!==(D=e.w)&&void 0!==D?D:0,h:null!==($=e.h)&&void 0!==$?$:0,fill:"#999",datum:null,style:{opacity:null!==(z=e.opacity)&&void 0!==z?z:1},_targetOpacity:0,_transitionKey:t};r.exitNodes.push(i)}N=!0}return r.exitNodes.length>0&&(r.scene=[...r.scene,...r.exitNodes]),N&&(r.activeTransition={startTime:E(),duration:j}),r}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap);this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition}advanceTransition(t){if(!this.activeTransition||!this.config.transition)return!1;const e={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},r=function(t,e,r,i){var o,n,s,a,c;if(!r.activeTransition)return!1;const l=_(t,r.activeTransition),u=S(l,"linear"===e.easing?"linear":"ease-out-cubic");for(const t of r.scene){const e=t._transitionKey;if("point"===t.type){if(void 0!==t._targetOpacity){const r=e?i.get(e):void 0,n=r?null!==(o=r.opacity)&&void 0!==o?o:1:0;t.style.opacity=P(n,t._targetOpacity,u)}if(void 0===t._targetX)continue;if(!e)continue;const r=i.get(e);if(!r)continue;t.x=P(r.x,t._targetX,u),t.y=P(r.y,t._targetY,u),void 0!==t._targetR&&void 0!==r.r&&(t.r=P(r.r,t._targetR,u))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const r=e?i.get(e):void 0,o=r?null!==(n=r.opacity)&&void 0!==n?n:1:0;t.style.opacity=P(o,t._targetOpacity,u)}if(void 0===t._targetX)continue;if(!e)continue;const r=i.get(e);if(!r)continue;t.x=P(r.x,t._targetX,u),t.y=P(r.y,t._targetY,u),void 0!==r.w&&(t.w=P(r.w,t._targetW,u)),void 0!==r.h&&(t.h=P(r.h,t._targetH,u))}else if("heatcell"===t.type){if(void 0!==t._targetOpacity){const r=e?i.get(e):void 0,o=r?null!==(s=r.opacity)&&void 0!==s?s:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:P(o,t._targetOpacity,u)})}if(void 0===t._targetX)continue;if(!e)continue;const r=i.get(e);if(!r)continue;t.x=P(r.x,t._targetX,u),t.y=P(r.y,t._targetY,u),void 0!==r.w&&(t.w=P(r.w,t._targetW,u)),void 0!==r.h&&(t.h=P(r.h,t._targetH,u))}else if("line"===t.type){if(void 0!==t._targetOpacity){const e=null!==(a=t._startOpacity)&&void 0!==a?a:0;t.style=Object.assign(Object.assign({},t.style),{opacity:P(e,t._targetOpacity,u)})}const e=t._prevPath,r=t._targetPath;if(e&&r&&e.length===t.path.length)for(let i=0;t.path.length>i;i++)t.path[i][0]=P(e[i][0],r[i][0],u),t.path[i][1]=P(e[i][1],r[i][1],u)}else if("area"===t.type){if(void 0!==t._targetOpacity){const e=null!==(c=t._startOpacity)&&void 0!==c?c:0;t.style=Object.assign(Object.assign({},t.style),{opacity:P(e,t._targetOpacity,u)})}const e=t._prevTopPath,r=t._prevBottomPath,i=t._targetTopPath,o=t._targetBottomPath;if(e&&i&&e.length===t.topPath.length)for(let r=0;t.topPath.length>r;r++)t.topPath[r][0]=P(e[r][0],i[r][0],u),t.topPath[r][1]=P(e[r][1],i[r][1],u);if(r&&o&&r.length===t.bottomPath.length)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e][0]=P(r[e][0],o[e][0],u),t.bottomPath[e][1]=P(r[e][1],o[e][1],u)}}if(l>=1){for(const t of r.scene){if(void 0!==t._targetOpacity){const e=t._targetOpacity;t.style=Object.assign(Object.assign({},"line"===t.type||"area"===t.type?t.style:t.style||{}),{opacity:0===e?0:e}),t._targetOpacity=void 0}if("point"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("rect"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("heatcell"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("line"===t.type){const e=t._targetPath;if(e)for(let r=0;t.path.length>r;r++)t.path[r]=e[r];t._prevPath=void 0,t._targetPath=void 0}else if("area"===t.type){const e=t._targetTopPath,r=t._targetBottomPath;if(e)for(let r=0;t.topPath.length>r;r++)t.topPath[r]=e[r];if(r)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e]=r[e];t._prevTopPath=void 0,t._prevBottomPath=void 0,t._targetTopPath=void 0,t._targetBottomPath=void 0}}if(r.exitNodes.length>0){const t=new Set(r.exitNodes);r.scene=r.scene.filter(e=>!t.has(e)),r.exitNodes=[]}return r.activeTransition=null,!1}return!0}(t,this.config.transition,e,this.prevPositionMap);return this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition,r}groupData(t){if(!this.getGroup)return[{key:"_default",data:t}];const e=new Map;for(const r of t){const t=this.getGroup(r);e.has(t)||e.set(t,[]),e.get(t).push(r)}return Array.from(e.entries()).map(([t,e])=>({key:t,data:e}))}resolveColorMap(t){const e=new Set;for(const r of t){const t=this.getColor(r);t&&e.add(t)}const r=Array.from(e).sort(),i=r.join("\0");if(this._colorMapCache&&this._colorMapCache.key===i)return this._colorMapCache.map;const o=Array.isArray(this.config.colorScheme)?this.config.colorScheme:k,n=new Map;for(let t=0;r.length>t;t++)n.set(r[t],o[t%o.length]);return this._colorMapCache={key:i,map:n},n}resolveLineStyle(t,e){const r=this.config.lineStyle;if("function"==typeof r){const i=r(e||{},t);if(i&&!i.stroke&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},i),{stroke:e})}return i}return r&&"object"==typeof r?{stroke:r.stroke||"#007bff",strokeWidth:r.strokeWidth||2,strokeDasharray:r.strokeDasharray,fill:r.fill,fillOpacity:r.fillOpacity,opacity:r.opacity}:{stroke:this.resolveGroupColor(t)||"#007bff",strokeWidth:2}}resolveAreaStyle(t,e){var r;if(this.config.areaStyle){const r=this.config.areaStyle(e||{});if(r&&!r.fill&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},r),{fill:e,stroke:r.stroke||e})}return r}const i=this.config.lineStyle;if("function"==typeof i){const r=i(e||{},t);if(r&&!r.fill&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},r),{fill:e,stroke:r.stroke||e})}return r}if(i&&"object"==typeof i)return{fill:i.fill||i.stroke||"#4e79a7",fillOpacity:null!==(r=i.fillOpacity)&&void 0!==r?r:.7,stroke:i.stroke||"#4e79a7",strokeWidth:i.strokeWidth||2};const o=this.resolveGroupColor(t)||"#4e79a7";return{fill:o,fillOpacity:.7,stroke:o,strokeWidth:2}}resolveGroupColor(t){if(this._colorMapCache){const e=this._colorMapCache.map.get(t);if(e)return e}const e=this._groupColorMap.get(t);if(e)return e;const r=Array.isArray(this.config.colorScheme)?this.config.colorScheme:k,i=r[this._groupColorMap.size%r.length];return this._groupColorMap.set(t,i),i}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}remove(t){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const e=new Set(Array.isArray(t)?t:[t]),r=this.getPointId,i=t=>e.has(r(t));if(this.timestampBuffer&&this.timestampBuffer.size>0){const t=this.timestampBuffer.toArray(),e=new Set;this.buffer.forEach((t,r)=>{i(t)&&e.add(r)}),this.timestampBuffer.clear();for(let r=0;t.length>r;r++)e.has(r)||this.timestampBuffer.push(t[r])}const o=this.buffer.remove(i);if(0===o.length)return o;for(const t of o)this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):(this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t)));return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,o}update(t,e){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const r=new Set(Array.isArray(t)?t:[t]),i=this.getPointId,o=new Set;this.buffer.forEach((t,e)=>{r.has(i(t))&&o.add(e)});const n=this.buffer.update(t=>r.has(i(t)),e);if(0===n.length)return n;for(const t of n)this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):(this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t)));return this.buffer.forEach((t,e)=>{o.has(e)&&(this.xExtent.push(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(t)),this.yExtent.push(this.getLow(t))):(this.yExtent.push(this.getY(t)),this.getY0&&this.yExtent.push(this.getY0(t))))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,n}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(t){var e,r,i,o;const n=Object.assign({},this.config);void 0!==t.colorScheme&&(this._colorMapCache=null,this._groupColorMap=new Map),void 0===t.barColors&&void 0===t.colorScheme||(this._barCategoryCache=null),void 0===t.normalize&&void 0===t.extentPadding&&void 0===t.xAccessor&&void 0===t.yAccessor&&void 0===t.groupAccessor&&void 0===t.categoryAccessor&&void 0===t.chartType||(this._stackExtentCache=null);let s=!1;Object.assign(this.config,t);const a="chartType"in t&&t.chartType!==n.chartType||"runtimeMode"in t&&t.runtimeMode!==n.runtimeMode;if(a||void 0!==t.xAccessor||void 0!==t.yAccessor||void 0!==t.timeAccessor||void 0!==t.valueAccessor){const c=a||!m(null!==(e=t.xAccessor)&&void 0!==e?e:t.timeAccessor,null!==(r=n.xAccessor)&&void 0!==r?r:n.timeAccessor),l=a||!m(null!==(i=t.yAccessor)&&void 0!==i?i:t.valueAccessor,null!==(o=n.yAccessor)&&void 0!==o?o:n.valueAccessor);(c||l)&&(["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?(this.getX=x(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=x(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=x(this.config.xAccessor,"x"),this.getY=x(this.config.yAccessor,"y")),s=!0)}if("groupAccessor"in t&&!m(t.groupAccessor,n.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?b(this.config.groupAccessor):void 0,s=!0),"categoryAccessor"in t&&!m(t.categoryAccessor,n.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?b(this.config.categoryAccessor):void 0,s=!0),"sizeAccessor"in t&&!m(t.sizeAccessor,n.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?x(this.config.sizeAccessor,"size"):void 0,s=!0),"colorAccessor"in t&&!m(t.colorAccessor,n.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?b(this.config.colorAccessor):void 0,s=!0),"y0Accessor"in t&&!m(t.y0Accessor,n.y0Accessor)&&(this.getY0=this.config.y0Accessor?x(this.config.y0Accessor,"y0"):void 0,s=!0),"pointIdAccessor"in t&&!m(t.pointIdAccessor,n.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?b(this.config.pointIdAccessor):void 0,s=!0),"candlestick"===this.config.chartType&&("openAccessor"in t&&!m(t.openAccessor,n.openAccessor)||"closeAccessor"in t&&!m(t.closeAccessor,n.closeAccessor)||"highAccessor"in t&&!m(t.highAccessor,n.highAccessor)||"lowAccessor"in t&&!m(t.lowAccessor,n.lowAccessor))){const t=null!=this.config.openAccessor,e=null!=this.config.closeAccessor;this.getOpen=t?x(this.config.openAccessor,"open"):void 0,this.getHigh=x(this.config.highAccessor,"high"),this.getLow=x(this.config.lowAccessor,"low"),this.getClose=e?x(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!e,s=!0}if(!s){const e=Object.keys(t).filter(t=>!t.endsWith("Accessor")&&"timeAccessor"!==t&&"valueAccessor"!==t);for(const r of e)if(t[r]!==n[r]){s=!0;break}}s&&(this.needsFullRebuild=!0)}}function W(t,e){var r=t.get(e);if(!r)throw Error("missing: "+e);return r}function F(t,e){var r,i=[],o=[],n=[],s={},a=[];function c(t){n[t]=!1,s.hasOwnProperty(t)&&Object.keys(s[t]).forEach(function(e){delete s[t][e],n[e]&&c(e)})}function l(t){var e,i,h=!1;for(o.push(t),n[t]=!0,e=0;a[t].length>e;e++)(i=a[t][e])===r?(u(r,o),h=!0):n[i]||(h=l(i));if(h)c(t);else for(e=0;a[t].length>e;e++){var f=s[i=a[t][e]];f||(s[i]=f={}),f[i]=!0}return o.pop(),h}function u(t,e){var r=[].concat(e).concat(t);i.push(r)}function h(e){!function(e){for(var r=0;t.length>r;r++)r>=e&&t[r]||(t[r]=[]),t[r]=t[r].filter(function(t){return t>=e})}(e);for(var r,i=function(t){for(var e=t.length,r=Array(e),i=Array(e),o=Array(e),n=Array(e),s=Array(e),a=Array(e),c=0;e>c;++c)r[c]=-1,i[c]=0,o[c]=!1,n[c]=0,s[c]=-1,a[c]=[];var l,u=0,h=[],f=[];function d(e){var c=[e],l=[e];for(r[e]=i[e]=u,o[e]=!0,u+=1;l.length>0;){var d=t[e=l[l.length-1]];if(d.length>n[e]){for(var g=n[e];d.length>g;++g){var y=d[g];if(0>r[y]){r[y]=i[y]=u,o[y]=!0,u+=1,c.push(y),l.push(y);break}o[y]&&(i[e]=0|Math.min(i[e],i[y])),0>s[y]||a[e].push(s[y])}n[e]=g}else{if(i[e]===r[e]){var p=[],m=[],x=0;for(g=c.length-1;g>=0;--g){var v=c[g];if(o[v]=!1,p.push(v),m.push(a[v]),x+=a[v].length,s[v]=h.length,v===e){c.length=g;break}}h.push(p);var b=Array(x);for(g=0;m.length>g;g++)for(var k=0;m[g].length>k;k++)b[--x]=m[g][k];f.push(b)}l.pop()}}}for(c=0;e>c;++c)0>r[c]&&d(c);for(c=0;f.length>c;c++){var g=f[c];if(0!==g.length){g.sort(function(t,e){return t-e}),l=[g[0]];for(var y=1;g.length>y;y++)g[y]!==g[y-1]&&l.push(g[y]);f[c]=l}}return{components:h,adjacencyList:f}}(t),o=i.components.filter(function(t){return t.length>1}),n=1/0,s=0;o.length>s;s++)for(var a=0;o[s].length>a;a++)n>o[s][a]&&(n=o[s][a],r=s);var c=o[r];if(!c)return!1;var l=t.map(function(t,e){return-1===c.indexOf(e)?[]:t.filter(function(t){return-1!==c.indexOf(t)})});return{leastVertex:n,adjList:l}}r=0;for(var f=t.length;f>r;){var d=h(r);if(r=d.leastVertex,a=d.adjList){for(var g=0;a.length>g;g++)for(var y=0;a[g].length>y;y++){var p=a[g][y];n[+p]=!1,s[p]={}}l(r),r+=1}else r=f}return i}function C(t){return t.y0-t.y1>0?"up":"down"}function I(t,e){return e(t.source)==e(t.target)}function Y(t){var e=0;t.source.sourceLinks.forEach(function(t){e=t.circular?e+1:e});var r=0;return t.target.targetLinks.forEach(function(t){r=t.circular?r+1:r}),1>=e&&1>=r}function X(t){return t.target.x0-t.source.x1}function q(t,e){var r=V(t),i=X(e)/Math.tan(r);return"up"==C(t)?t.y1-i:t.y1+i}function G(t,e){var r=V(t),i=X(e)/Math.tan(r);return"up"==C(t)?t.y1+i:t.y1-i}function V(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function H(t,e){return e(t)}function Z(t){return U(t.source)}function K(t){return U(t.target)}function U(t){return(t.y0+t.y1)/2}function Q(t){return t.virtual?0:t.value}function J(t,e){var r=0;t.sourceLinks.forEach(function(t){r=t.circular&&!I(t,e)?r+1:r});var i=0;return t.targetLinks.forEach(function(t){i=t.circular&&!I(t,e)?i+1:i}),r+i}function tt(t){return t.target.depth}function et(t,e){return t.sourceLinks.length?t.depth:e-1}function rt(t,e){return t.y0-e.y0}function it(t,e){return e.y0-t.y0}function ot(t,e){return t.y1-e.y1}function nt(t,e){return e.y1-t.y1}function st(t,e){return ct(t.source,e.source)||t.index-e.index}function at(t,e){return ct(t.target,e.target)||t.index-e.index}function ct(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function lt(t,e){return ut(t)==ut(e)?"bottom"==t.circularLinkType?it(t,e):rt(t,e):ut(e)-ut(t)}function ut(t){return t.target.column-t.source.column}function ht(t,e){return ft(t)==ft(e)}function ft(t){return t.y0-t.y1>0?"up":"down"}function dt(t,e,r,i,n){let s=t;var a=Math.max(8,.15*(s.y1-s.y0));s.links.forEach(function(t){t.circular&&(t._circularWidth=Math.min(t.width,a))});var c=o.min(s.links,function(t){return t.source.y0});s.links.forEach(function(t){t.circular&&(t.circularPathData={})});var l=s.links.filter(function(t){return t.circular});return l.sort(function(t,e){return e.value-t.value}),l.forEach(function(t,e){t._circularStub=e>=4}),gt(s.links.filter(function(t){return"top"==t.circularLinkType}),e,r),gt(s.links.filter(function(t){return"bottom"==t.circularLinkType}),e,r),s.links.forEach(function(t){if(t.circular){if(t.circularPathData.arcRadius=t._circularWidth+i,t.circularPathData.rightNodeBuffer=5,t.circularPathData.leftNodeBuffer=5,t.circularPathData.sourceWidth=t.source.x1-t.source.x0,t.circularPathData.sourceX=t.source.x0+t.circularPathData.sourceWidth,t.circularPathData.targetX=t.target.x0,t.circularPathData.sourceY=t.y0,t.circularPathData.targetY=t.y1,I(t,e)&&Y(t))t.circularPathData.rightSmallArcRadius=i+t._circularWidth/2,t.circularPathData.rightLargeArcRadius=i+t._circularWidth/2,t.circularPathData.leftSmallArcRadius=i+t._circularWidth/2,t.circularPathData.leftLargeArcRadius=i+t._circularWidth/2,"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=t.source.y1+n+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=t.source.y0-n-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius);else{var o=t.source.column,a=t.circularLinkType,l=s.links.filter(function(t){return t.source.column==o&&t.circularLinkType==a});l.sort("bottom"==t.circularLinkType?it:rt);var u=0;l.forEach(function(e,o){e.circularLinkID==t.circularLinkID&&(t.circularPathData.rightSmallArcRadius=i+t._circularWidth/2+u,t.circularPathData.rightLargeArcRadius=i+t._circularWidth/2+o*r+u),u+=e._circularWidth||e.width}),o=t.target.column,(l=s.links.filter(function(t){return t.target.column==o&&t.circularLinkType==a})).sort("bottom"==t.circularLinkType?nt:ot),u=0,l.forEach(function(e,o){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=i+t._circularWidth/2+u,t.circularPathData.leftLargeArcRadius=i+t._circularWidth/2+o*r+u),u+=e._circularWidth||e.width}),"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=Math.max(s.y1,t.source.y1,t.target.y1)+n+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=c-n-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius)}t.circularPathData.rightInnerExtent=t.circularPathData.sourceX+t.circularPathData.rightNodeBuffer,t.circularPathData.leftInnerExtent=t.circularPathData.targetX-t.circularPathData.leftNodeBuffer,t.circularPathData.rightFullExtent=t.circularPathData.sourceX+t.circularPathData.rightLargeArcRadius+t.circularPathData.rightNodeBuffer,t.circularPathData.leftFullExtent=t.circularPathData.targetX-t.circularPathData.leftLargeArcRadius-t.circularPathData.leftNodeBuffer}t.path=t.circular?function(t){return"top"==t.circularLinkType?"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 0 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY-t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 0 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 0 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY-t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 0 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY:"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 1 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY+t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 1 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 1 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY+t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 1 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY}(t):function(t){var e=t.source.x1,r=t.y0,i=t.target.x0,o=t.y1,n=(e+i)/2;return"M"+e+","+r+"C"+n+","+r+" "+n+","+o+" "+i+","+o}(t)}),s}function gt(t,e,r){t.sort(lt);var i=t.filter(function(t){return!t._circularStub});return t.forEach(function(t,o){var n=0;if(t._circularStub)t.circularPathData.verticalBuffer=0;else if(I(t,e)&&Y(t))t.circularPathData.verticalBuffer=n+t._circularWidth/2;else{for(var s=0;i.length>s;s++){var a=i[s];if(a!==t&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&yt(t,a)){var c=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+r;n=c>n?c:n}}t.circularPathData.verticalBuffer=n+t._circularWidth/2}}),t}function yt(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}function pt(t){return function(){return t}}function mt(t){return t.index}function xt(t){return t.nodes}function vt(t){return t.links}function bt(t,e,r){var i=o.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});i.forEach(function(o,n){var s=o.length;if(e)o.sort(e);else if(n>0){var a=new Map;o.forEach(function(t,e){var r,i,o,n=(i=0,o=0,(r=t).targetLinks.forEach(function(t){if(!t.circular){var e=t.value||1;o+=U(t.source)*e,i+=e}}),r.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;o+=U(t.target)*e,i+=e}}),i>0?o/i:NaN);a.set(t,{bc:n,idx:e})}),o.sort(function(t,e){var r=a.get(t),i=a.get(e),o=r.bc,n=i.bc;if(t.circularLinkType!==e.circularLinkType){if("top"==t.circularLinkType&&"bottom"==e.circularLinkType)return-1;if("bottom"==t.circularLinkType&&"top"==e.circularLinkType)return 1;if("top"==t.circularLinkType)return-1;if("top"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return-1}return isNaN(o)||isNaN(n)?isNaN(o)?isNaN(n)?r.idx-i.idx:1:-1:o-n})}else o.sort(function(t,e){return t.circularLinkType==e.circularLinkType?J(e,r)-J(t,r):"top"==t.circularLinkType&&"bottom"==e.circularLinkType||"top"==t.circularLinkType&&0==e.partOfCycle||0==t.partOfCycle&&"bottom"==e.circularLinkType?-1:0});o.forEach(function(e,o){e.depth==i.length-1&&1==s||0==e.depth&&1==s?(e.y0=t.y1/2-e.value*t.ky,e.y1=e.y0+e.value*t.ky):e.partOfCycle?0==J(e,r)?(e.y0=t.y1/2+o,e.y1=e.y0+e.value*t.ky):"top"==e.circularLinkType?(e.y0=t.y0+o,e.y1=e.y0+e.value*t.ky):(e.y0=t.y1-e.value*t.ky-o,e.y1=e.y0+e.value*t.ky):0==t.y0||0==t.y1?(e.y0=(t.y1-t.y0)/s*o,e.y1=e.y0+e.value*t.ky):(e.y0=(t.y1-t.y0)/2-s/2+o,e.y1=e.y0+e.value*t.ky)})})}function kt(t,e,r,i,n,s){var a=o.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});h();for(var c=1,l=s;l>0;--l)u(c*=.99,r),h();function u(e,r){var i=a.length;a.forEach(function(n){var s=n.length,a=n[0].depth;n.forEach(function(n){var c;if(n.sourceLinks.length||n.targetLinks.length)if(n.partOfCycle&&J(n,r)>0){var l=o.mean(n.sourceLinks,K),u=o.mean(n.targetLinks,Z),h=l&&u?(l+u)/2:l||u;if(h){var f=(h-U(n))*e*.3;n.y0+=f,n.y1+=f}}else if(0==a&&1==s)n.y0=t.y1/2-(c=n.y1-n.y0)/2,n.y1=t.y1/2+c/2;else if(a==i-1&&1==s)n.y0=t.y1/2-(c=n.y1-n.y0)/2,n.y1=t.y1/2+c/2;else if(1==n.targetLinks.length&&1==n.targetLinks[0].source.sourceLinks.length)c=n.y1-n.y0,n.y0=n.targetLinks[0].source.y0,n.y1=n.y0+c;else{var d=o.mean(n.sourceLinks,K),g=o.mean(n.targetLinks,Z),y=((d&&g?(d+g)/2:d||g)-U(n))*e;n.y0+=y,n.y1+=y}})})}function h(){a.forEach(function(r){var o,s,a,c=t.y0,l=r.length;for(r.sort(e||ct),a=0;l>a;++a)(s=c-(o=r[a]).y0)>0&&(o.y0+=s,o.y1+=s),c=o.y1+i;if((s=c-i-t.y1)>0)for(c=o.y0-=s,o.y1-=s,a=l-2;a>=0;--a)(s=(o=r[a]).y1+n-c)>0&&(o.y0-=s,o.y1-=s),c=o.y0})}}function At(t){t.nodes.forEach(function(t){t.sourceLinks.sort(at),t.targetLinks.sort(st)}),t.nodes.forEach(function(t){var e=t.y0,r=e,i=t.y1,o=i;t.sourceLinks.forEach(function(t){t.circular?(t.y0=i-t.width/2,i-=t.width):(t.y0=e+t.width/2,e+=t.width)}),t.targetLinks.forEach(function(t){t.circular?(t.y1=o-t.width/2,o-=t.width):(t.y1=r+t.width/2,r+=t.width)})})}function wt(){var t=0,e=0,r=1,i=1,n=24,s=8,a=null,c=mt,l=et,u=void 0,h=32,f=2,d=xt,g=vt;function y(){var y={nodes:d.apply(null,arguments),links:g.apply(null,arguments)};return function(d){d.x0=t,d.y0=e,d.x1=r,d.y1=i,d.py=0,function(t,e){t.nodes.forEach(function(t,e){t.index=e,t.sourceLinks=[],t.targetLinks=[]});var r=function(t,e){var r=new Map;return o.group(t,e).forEach(function(t,e){r.set(e,t[0])}),r}(t.nodes,e);t.links.forEach(function(t,e){t.index=e;var i=t.source,o=t.target;"object"!=typeof i&&(i=t.source=W(r,i)),"object"!=typeof o&&(o=t.target=W(r,o)),i.sourceLinks.push(t),o.targetLinks.push(t)})}(d,c),function(t,e){var r=0;if(null==e){for(var i=[],o=0;t.links.length>o;o++){var n=t.links[o],s=n.source.index,a=n.target.index;i[s]||(i[s]=[]),i[a]||(i[a]=[]),-1===i[s].indexOf(a)&&i[s].push(a)}var c=F(i);c.sort(function(t,e){return t.length-e.length});var l={};for(o=0;c.length>o;o++){var u=c[o].slice(-2);l[u[0]]||(l[u[0]]={}),l[u[0]][u[1]]=!0}t.links.forEach(function(t){var e=t.target.index,i=t.source.index;e===i||l[i]&&l[i][e]?(t.circular=!0,t.circularLinkID=r++):t.circular=!1})}else t.links.forEach(function(t){e(t.source)<e(t.target)?t.circular=!1:(t.circular=!0,t.circularLinkID=r++)})}(d,u),function(t,e){var r=0,i=0;t.links.forEach(function(o){o.circular&&(o.circularLinkType=o.source.circularLinkType||o.target.circularLinkType?o.source.circularLinkType?o.source.circularLinkType:o.target.circularLinkType:i>r?"top":"bottom","top"==o.circularLinkType?r++:i++,t.nodes.forEach(function(t){H(t,e)!=H(o.source,e)&&H(t,e)!=H(o.target,e)||(t.circularLinkType=o.circularLinkType)}))}),t.links.forEach(function(t){t.circular&&(t.source.circularLinkType==t.target.circularLinkType&&(t.circularLinkType=t.source.circularLinkType),I(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(d,c),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max(o.sum(t.sourceLinks,Q),o.sum(t.targetLinks,Q)),t.sourceLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)}),t.targetLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)})})}(d),function(t,e,r){var i,o,n;if(null!=e){t.nodes.sort(function(t,r){return e(t)<e(r)?-1:1});var s=0,a=e(t.nodes[0]);t.nodes.forEach(function(t){s=e(t)==a?s:s+1,a=e(t)==a?a:e(t),t.column=s})}for(i=t.nodes,o=[],n=0;i.length;++n,i=o,o=[])i.forEach(function(t){t.depth=n,t.sourceLinks.forEach(function(t){0>o.indexOf(t.target)&&!t.circular&&o.push(t.target)})});for(i=t.nodes,o=[],n=0;i.length;++n,i=o,o=[])i.forEach(function(t){t.height=n,t.targetLinks.forEach(function(t){0>o.indexOf(t.source)&&!t.circular&&o.push(t.source)})});t.nodes.forEach(function(t){t.column=null==e?r(t,n):t.column})}(d,u,l);var g=s;if(null!==a){var y=o.groups(d.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),p=o.max(y,function(t){return t.length});p>1&&(g=Math.max(1,(i-e)*a/(p-1)))}(function(t,e,r){var i=o.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});t.py=e;var n=o.min(i,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/o.sum(e,function(t){return t.value})});t.ky=n,t.links.forEach(function(e){e.width=e.value*t.ky});var s=o.max(t.nodes,function(t){return t.column});t.nodes.forEach(s>0?function(e){e.x0=t.x0+e.column*((t.x1-t.x0-r)/s),e.x1=e.x0+r}:function(e){e.x0=t.x0,e.x1=e.x0+r})})(d,g,n),bt(d,u,c),kt(d,u,c,g,g,h),At(d),dt(d,c,f,10,8),bt(d,u,c),kt(d,u,c,g,g,h),At(d),dt(d,c,f,10,8),function(t,e){let r=t;r.nodes.forEach(function(t){t.y+(t.y1-t.y0)>r.y1&&(t.y=t.y-(t.y+(t.y1-t.y0)-r.y1));var i=r.links.filter(function(r){return H(r.source,e)==H(t,e)}),o=i.length;o>1&&i.sort(function(t,e){if(!t.circular&&!e.circular){if(t.target.column==e.target.column)return t.y1-e.y1;if(!ht(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var r=q(e,t);return t.y1-r}if(e.target.column>t.target.column)return q(t,e)-e.y1}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.target.column===e.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.target.column===e.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:"top"==t.circularLinkType?-1:1:void 0});var n=t.y0;i.forEach(function(t){t.y0=n+t.width/2,n+=t.width}),i.forEach(function(e,r){if("bottom"==e.circularLinkType){for(var n=r+1,s=0;o>n;n++)s+=i[n].width;e.y0=t.y1-s-e.width/2}})})}(d,c),function(t,e){let r=t;r.nodes.forEach(function(t){var i=r.links.filter(function(r){return H(r.target,e)==H(t,e)}),o=i.length;o>1&&i.sort(function(t,e){if(!t.circular&&!e.circular){if(t.source.column==e.source.column)return t.y0-e.y0;if(!ht(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var r=G(e,t);return t.y0-r}if(e.source.column>t.source.column)return G(t,e)-e.y0}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:t.source.column-e.source.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:e.source.column-t.source.column:"top"==t.circularLinkType?-1:1:void 0});var n=t.y0;i.forEach(function(t){t.y1=n+t.width/2,n+=t.width}),i.forEach(function(e,r){if("bottom"==e.circularLinkType){for(var n=r+1,s=0;o>n;n++)s+=i[n].width;e.y1=t.y1-s-e.width/2}})})}(d,c),function(t){var e=t.nodes,r=t.links,i=!1,n=!1;if(r.forEach(function(t){"top"==t.circularLinkType?i=!0:"bottom"==t.circularLinkType&&(n=!0)}),0==i||0==n){var s=o.min(e,function(t){return t.y0}),a=o.max(e,function(t){return t.y1}),c=(t.y1-t.y0)/(a-s);function l(e){return(e-s)/(a-s)*(t.y1-t.y0)+t.y0}1>c?(e.forEach(function(t){t.y0=l(t.y0),t.y1=l(t.y1)}),r.forEach(function(t){t.y0=l(t.y0),t.y1=l(t.y1),t.width=t.width*c})):e.forEach(function(t){var e=t.y1-t.y0,r=l(t.y0)-t.y0;t.y0=l(t.y0),t.y1=t.y0+e,t.sourceLinks.forEach(function(t){t.y0=t.y0+r}),t.targetLinks.forEach(function(t){t.y1=t.y1+r})})}}(d),dt(d,c,f,10,8)}(y),y}return y.update=function(t){return At(t),dt(t,c,f,10,8),t},y.nodeWidth=function(t){return arguments.length?(n=+t,y):n},y.nodePadding=function(t){return arguments.length?(s=+t,y):s},y.nodePaddingRatio=function(t){return arguments.length?(a=+t,y):a},y.nodes=function(t){return arguments.length?(d="function"==typeof t?t:pt(t),y):d},y.links=function(t){return arguments.length?(g="function"==typeof t?t:pt(t),y):g},y.nodeId=function(t){return arguments.length?(c="function"==typeof t?t:pt(t),y):c},y.nodeAlign=function(t){return arguments.length?(l="function"==typeof t?t:pt(t),y):l},y.nodeSort=function(t){return arguments.length?(u=t,y):u},y.iterations=function(t){return arguments.length?(h=+t,y):h},y.circularLinkGap=function(t){return arguments.length?(f=+t,y):f},y.extent=function(o){return arguments.length?(t=+o[0][0],e=+o[0][1],r=+o[1][0],i=+o[1][1],y):[[t,e],[r,i]]},y.size=function(o){return arguments.length?(t=e=0,r=+o[0],i=+o[1],y):[r-t,i-e]},y}R.QUADTREE_THRESHOLD=500;const St=t=>{let e,r,i,o,s,a,c,l,u;return"down"===t.direction?(e=t.y0-t.sankeyWidth/2,r=t.y1-t.sankeyWidth/2,i=t.y1+t.sankeyWidth/2,o=t.y0+t.sankeyWidth/2,s=t.source.x1,a=t.target.x0,c=n.interpolateNumber(s,a),l=c(.5),u=c(.5),`M${e},${s}C${e},${l} ${r},${u} ${r},${a}L${i},${a}C${i},${u} ${o},${l} ${o},${s}Z`):(e=t.source.x1,r=t.target.x0,c=n.interpolateNumber(e,r),i=c(.5),o=c(.5),s=t.y0-t.sankeyWidth/2,a=t.y1-t.sankeyWidth/2,l=t.y1+t.sankeyWidth/2,u=t.y0+t.sankeyWidth/2,`M${e},${s}C${i},${s} ${o},${a} ${r},${a}L${r},${l}C${o},${l} ${i},${u} ${e},${u}Z`)};function _t(t){var e;const r=t.sankeyWidth/2,i=(null!==(e=t._circularWidth)&&void 0!==e?e:t.sankeyWidth)/2,o=t.circularPathData;if(!o)return null;if("down"===t.direction)return null;if(t._circularStub){const e=o.sourceX,i=o.sourceY,n=o.targetX,s=o.targetY;if("object"!=typeof t.source||!t.source||"object"!=typeof t.target||!t.target)return null;const a=Math.max(15,Math.min(40,.33*(o.rightFullExtent-e))),c=Math.max(15,Math.min(40,.33*(n-o.leftFullExtent)));return`M${e},${i-r}L${e+a},${i-r}L${e+a},${i+r}L${e},${i+r}ZM${n},${s-r}L${n-c},${s-r}L${n-c},${s+r}L${n},${s+r}Z`}const n=o.sourceX,s=o.sourceY,a=o.targetX,c=o.targetY,l=o.rightFullExtent,u=o.leftFullExtent,h=o.verticalFullExtent,f="bottom"===t.circularLinkType?1:-1,d=Math.max(4,Math.min(i,15));return`M${n},${s-f*r}L${l},${s-f*r}L${l+i},${s-f*r+f*d}L${l+i},${h+f*i-f*d}L${l+i-d},${h+f*i}L${u-i+d},${h+f*i}L${u-i},${h+f*i-f*d}L${u-i},${c-f*r+f*d}L${u-i+d},${c-f*r}L${a},${c-f*r}L${a},${c+f*r}L${u+i},${c+f*r}L${u+i},${h-f*i}L${l-i},${h-f*i}L${l-i},${s+f*r}L${n},${s+f*r}Z`}const Pt=new Set,Et=new WeakMap;function Mt(t,e){if("production"===process.env.NODE_ENV)return t;if(!t||!t.data||"object"!=typeof t.data)return t;let r=Et.get(t);if(r){const t=r.get(e);if(t)return t}else r=new Map,Et.set(t,r);const i=new Proxy(t,{get(t,r,i){if("string"==typeof r&&!(r in t)&&t.data&&r in t.data){const t=`${e}:${r}`;Pt.has(t)||(Pt.add(t),console.warn(`[Semiotic] "${e}" callback accessed "${r}" on the wrapper object, but it only exists on ".data". Use d.data.${r} (or d.data?.${r}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(t,r,i)}});return r.set(e,i),i}const Ot={left:function(t){return t.depth},right:function(t,e){return e-1-t.height},center:function(t){return t.targetLinks.length?t.depth:t.sourceLinks.length?Math.min.apply(Math,t.sourceLinks.map(tt))-1:0},justify:et},Lt={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,r,i){var o,n,s,a,c,l,u;if(0===t.length)return;const h="vertical"===r.orientation?"down":"right",f=r.nodeAlign||"justify",d=null!==(o=r.nodeWidth)&&void 0!==o?o:15,g=null!==(n=r.nodePaddingRatio)&&void 0!==n?n:.05,y=null!==(s=r.iterations)&&void 0!==s?s:100,p=t.map(t=>Object.assign({},t)),m=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id,value:Math.sqrt(Math.max(1,t.value||1))}));let x;x="down"===h?[[0,0],[i[1],i[0]]]:[[0,0],[i[0],i[1]]];const v=wt().extent(x).links(m).nodes(p).nodeAlign(Ot[f]||et).nodeId(t=>t.id).nodeWidth(d).iterations(y);v.nodePaddingRatio&&v.nodePaddingRatio(g),v();{let t=1/0,e=-1/0,r=1/0,o=-1/0;for(const i of p)t>i.x0&&(t=i.x0),i.x1>e&&(e=i.x1),r>i.y0&&(r=i.y0),i.y1>o&&(o=i.y1);for(const i of m){if(!i.circular||!i.circularPathData)continue;const n=i.circularPathData,s=(null!==(c=null!==(a=i._circularWidth)&&void 0!==a?a:i.width)&&void 0!==c?c:0)/2;t>n.leftFullExtent-s&&(t=n.leftFullExtent-s),n.rightFullExtent+s>e&&(e=n.rightFullExtent+s),r>n.verticalFullExtent-s&&(r=n.verticalFullExtent-s),n.verticalFullExtent+s>o&&(o=n.verticalFullExtent+s)}const n=e-t,s=o-r,u=i[0],h=i[1];if(n>0&&s>0&&(0>t||0>r||e>u||o>h)){const e=Math.min(u/n,h/s),i=-t*e+(u-n*e)/2,o=-r*e+(h-s*e)/2;for(const t of p)t.x0=t.x0*e+i,t.x1=t.x1*e+i,t.y0=t.y0*e+o,t.y1=t.y1*e+o;for(const t of m)if(t.y0=t.y0*e+o,t.y1=t.y1*e+o,t.width=(null!==(l=t.width)&&void 0!==l?l:0)*e,t._circularWidth&&(t._circularWidth*=e),t.circular&&t.circularPathData){const r=t.circularPathData;r.sourceX=r.sourceX*e+i,r.targetX=r.targetX*e+i,r.sourceY=r.sourceY*e+o,r.targetY=r.targetY*e+o,r.rightFullExtent=r.rightFullExtent*e+i,r.leftFullExtent=r.leftFullExtent*e+i,r.verticalFullExtent=r.verticalFullExtent*e+o,r.rightInnerExtent=r.rightInnerExtent*e+i,r.leftInnerExtent=r.leftInnerExtent*e+i,r.verticalRightInnerExtent=r.verticalRightInnerExtent*e+o,r.verticalLeftInnerExtent=r.verticalLeftInnerExtent*e+o,r.rightSmallArcRadius*=e,r.rightLargeArcRadius*=e,r.leftSmallArcRadius*=e,r.leftLargeArcRadius*=e,r.sourceWidth*=e,r.rightNodeBuffer*=e,r.leftNodeBuffer*=e,r.arcRadius*=e}}}const b=new Map;for(const e of t)b.set(e.id,e);for(const t of p){const e=b.get(t.id);e&&(e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.value=t.value,e.depth=t.depth,e.sourceLinks=t.sourceLinks,e.targetLinks=t.targetLinks,e.width=t.x1-t.x0,e.height=t.y1-t.y0,e.x=t.x0+(t.x1-t.x0)/2,e.y=t.y0+(t.y1-t.y0)/2)}const k=new Map;for(const t of e)k.set(t._edgeKey?t._edgeKey:`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const t of m){const e=t.source,r=t.target,i="object"==typeof e&&null!==e?e.id:e+"",o="object"==typeof r&&null!==r?r.id:r+"",n=k.get(t._edgeKey?t._edgeKey:`${i}\0${o}`);if(n){n.y0=t.y0,n.y1=t.y1,n.sankeyWidth=null!==(u=t.width)&&void 0!==u?u:0,n.circular=!!t.circular,n.circularPathData=t.circularPathData,n._circularWidth=t._circularWidth,n._circularStub=t._circularStub,n.path=t.path,n.circularLinkType=t.circularLinkType,n.direction=h;const e=b.get(i),r=b.get(o);e&&(n.source=e),r&&(n.target=r)}}},buildScene(t,e,r,o){var n,s,a,c;const l="vertical"===r.orientation?"down":"right",u=r.nodeStyle,h=r.edgeStyle,f=null!==(n=r.edgeOpacity)&&void 0!==n?n:.5,d=r.edgeColorBy||"source",g=Array.isArray(r.colorScheme)?r.colorScheme:i.schemeCategory10,y=new Map;t.forEach((t,e)=>{y.set(t.id,g[e%g.length])});const p=[],m=[],x=[],v=new Map;for(const e of t){const t=e.x1-e.x0,r=e.y1-e.y0;if(0>=t||0>=r)continue;const i=u?u(Mt(e,"nodeStyle")):{},o={fill:i.fill||y.get(e.id)||"#4d430c",stroke:i.stroke,strokeWidth:i.strokeWidth,opacity:i.opacity};v.set(e.id,("string"==typeof o.fill?o.fill:null)||y.get(e.id)||"#4d430c"),p.push("down"===l?{type:"rect",x:e.y0,y:e.x0,w:r,h:t,style:o,datum:e,id:e.id,label:e.id}:{type:"rect",x:e.x0,y:e.y0,w:t,h:r,style:o,datum:e,id:e.id,label:e.id})}const b=[...e].sort((t,e)=>(e.sankeyWidth||0)-(t.sankeyWidth||0));for(const t of b){if(!t.sankeyWidth||0>=t.sankeyWidth)continue;const e="object"==typeof t.source?t.source:null,r="object"==typeof t.target?t.target:null;if(!e||!r)continue;let i="#999";i="function"==typeof d?d(t)||i:"target"===d?v.get(r.id)||y.get(r.id)||i:v.get(e.id)||y.get(e.id)||i;const o=h?h(Mt(t,"edgeStyle")):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,r=t.sankeyWidth/2,n=Math.max(15,Math.min(40,.33*(e.rightFullExtent-e.sourceX))),c=Math.max(15,Math.min(40,.33*(e.targetX-e.leftFullExtent))),l=o.fill||i;m.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-r}L${e.sourceX+n},${e.sourceY-r}L${e.sourceX+n},${e.sourceY+r}L${e.sourceX},${e.sourceY+r}Z`,style:{fill:l,fillOpacity:null!==(s=o.fillOpacity)&&void 0!==s?s:f,stroke:"none",opacity:o.opacity},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+n}}),m.push({type:"bezier",pathD:`M${e.targetX},${e.targetY-r}L${e.targetX-c},${e.targetY-r}L${e.targetX-c},${e.targetY+r}L${e.targetX},${e.targetY+r}Z`,style:{fill:l,fillOpacity:null!==(a=o.fillOpacity)&&void 0!==a?a:f,stroke:"none",opacity:o.opacity},datum:t,_gradient:{direction:"left",from:0,to:1,x0:e.targetX-c,x1:e.targetX}});continue}let n;if(n=t.circular&&t.circularPathData?_t(t):St(t),!n)continue;const l={fill:o.fill||i,fillOpacity:null!==(c=o.fillOpacity)&&void 0!==c?c:f,stroke:o.stroke||"none",strokeWidth:o.strokeWidth,opacity:o.opacity};m.push({type:"bezier",pathD:n,bezierCache:t.bezier,style:l,datum:t})}if(!1!==r.showLabels){const e=(k=r.nodeLabel)?"function"==typeof k?k:t=>t[k]||t.id:null;for(const r of t){const t=r.x1-r.x0,i=r.y1-r.y0;if(0>=t||0>=i)continue;const n=e?e(r):r.id;if(!n)continue;let s,a,c;"down"===l?(s=r.y0+(r.y1-r.y0)/2,a=r.x1+14,c="middle"):(o[0]/2>r.x0+t/2?(s=r.x0-6,c="end"):(s=r.x1+6,c="start"),a=r.y0+i/2),x.push({x:s,y:a,text:n+"",anchor:c,baseline:"middle",fontSize:11})}}var k;return{sceneNodes:p,sceneEdges:m,labels:x}}},Tt={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,r,i){var o,n;if(0===t.length)return;const a=null!==(o=r.forceStrength)&&void 0!==o?o:.1,c=i[0]/2,l=i[1]/2,u=r.__previousPositions;let h=0;const f=[];for(const e of t){const t=null!=e.x&&null!=e.y&&(0!==e.x||0!==e.y),r=null==u?void 0:u.get(e.id);t?h++:r?(e.x=r.x,e.y=r.y,h++):f.push(e)}const d=h>0&&.3>=(t.length>0?f.length/t.length:1);if(d){const r=new Map;for(const e of t)r.set(e.id,e);for(const t of f){const i=Dt(t.id,e,r);if(i.length>0){let e=0,r=0;for(const t of i)e+=t.x,r+=t.y;const o=$t(t.id),n=o%360*(Math.PI/180),s=10+o%20;t.x=e/i.length+s*Math.cos(n),t.y=r/i.length+s*Math.sin(n)}else{const e=$t(t.id),r=e%360*(Math.PI/180),i=15+e%30;t.x=c+i*Math.cos(r),t.y=l+i*Math.sin(r)}}}else{const e=2.399963229728653;for(let r=0;t.length>r;r++){const i=t[r];if(null==i.x||null==i.y||0===i.x&&0===i.y){const t=10*Math.sqrt(r+.5),o=r*e;i.x=c+t*Math.cos(o),i.y=l+t*Math.sin(o)}}}const g=null!==(n=r.iterations)&&void 0!==n?n:Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),y=0===r.iterations?0:d?40:g,p=zt(r.nodeSize,r.nodeSizeRange,t),m=t=>p(t);if(y>0){const r=s.forceLink().strength(t=>Math.min(2.5,t.weight?t.weight*a:a)).id(t=>t.id),i=s.forceSimulation().force("charge",s.forceManyBody().strength(t=>-25*m(t))).force("center",s.forceCenter(c,l).strength(.8)).force("x",s.forceX(c).strength(.15)).force("y",s.forceY(l).strength(.15));if(i.nodes(t),e.length>0){const t=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id}));i.force("link",r),i.force("link").links(t)}d?i.alpha(.3):.1>i.alpha()&&i.alpha(1),i.stop();for(let t=0;y>t;++t)i.tick()}for(const e of t){if(null==e.x||null==e.y)continue;const t=m(e);e.x=Math.max(t,Math.min(i[0]-t,e.x)),e.y=Math.max(t,Math.min(i[1]-t,e.y)),e.x0=0,e.x1=0,e.y0=0,e.y1=0}const x=new Map;for(const e of t)x.set(e.id,e);for(const t of e){if("string"==typeof t.source){const e=x.get(t.source);e&&(t.source=e)}if("string"==typeof t.target){const e=x.get(t.target);e&&(t.target=e)}}},buildScene(t,e,r,o){var n,s,a;const c=r.nodeStyle,l=r.edgeStyle,u=zt(r.nodeSize,r.nodeSizeRange,t),h=Array.isArray(r.colorScheme)?r.colorScheme:i.schemeCategory10,f=new Map;t.forEach((t,e)=>{f.set(t.id,h[e%h.length])});const d=[],g=[],y=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=u(Mt(e,"nodeSize")),r=c?c(Mt(e,"nodeStyle")):{},i={fill:r.fill||f.get(e.id)||"#007bff",stroke:r.stroke||"#fff",strokeWidth:null!==(n=r.strokeWidth)&&void 0!==n?n:2,opacity:r.opacity};d.push({type:"circle",cx:e.x,cy:e.y,r:t,style:i,datum:e,id:e.id,label:e.id})}const p=new Map;for(const e of t)p.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:p.get(t.source),r="object"==typeof t.target?t.target:p.get(t.target);if(!e||!r)continue;if(null==e.x||null==e.y)continue;if(null==r.x||null==r.y)continue;const i=l?l(Mt(t,"edgeStyle")):{},o={stroke:i.stroke||"#999",strokeWidth:null!==(s=i.strokeWidth)&&void 0!==s?s:1,opacity:null!==(a=i.opacity)&&void 0!==a?a:.6};g.push({type:"line",x1:e.x,y1:e.y,x2:r.x,y2:r.y,style:o,datum:t})}if(!1!==r.showLabels){const e=(m=r.nodeLabel)?"function"==typeof m?m:t=>t[m]||t.id:null;for(const r of t){if(null==r.x||null==r.y)continue;const t=e?e(r):r.id;if(!t)continue;const i=u(Mt(r,"nodeSize"));y.push({x:r.x,y:r.y-i-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var m;return{sceneNodes:d,sceneEdges:g,labels:y}}};function Dt(t,e,r){const i=[];for(const o of e){const e="string"==typeof o.source?o.source:o.source.id,n="string"==typeof o.target?o.target:o.target.id;let s=null;if(e===t?s=n:n===t&&(s=e),s){const t=r.get(s);!t||0===t.x&&0===t.y||i.push({x:t.x,y:t.y})}}return i}function $t(t){let e=0;for(let r=0;t.length>r;r++)e=(e<<5)-e+t.charCodeAt(r)|0;return Math.abs(e)}function zt(t,r,i){var n,s;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const a=r||[5,20],c=i.map(e=>{var r;return null===(r=e.data)||void 0===r?void 0:r[t]}).filter(t=>null!=t&&"number"==typeof t);if(0===c.length)return()=>a[0];const l=null!==(n=o.min(c))&&void 0!==n?n:0,u=null!==(s=o.max(c))&&void 0!==s?s:1;if(l===u)return()=>(a[0]+a[1])/2;const h=e.scaleLinear().domain([l,u]).range(a).clamp(!0);return e=>{var r;const i=null===(r=e.data)||void 0===r?void 0:r[t];return null==i||"number"!=typeof i?a[0]:h(i)}}const jt=i.schemeCategory10,Nt={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,r,i){if(0===t.length)return;const{padAngle:o=.01,groupWidth:n=20,sortGroups:s}=r,l=Math.min(i[0],i[1])/2,u=l-n,h=i[0]/2,f=i[1]/2,d=(g=r.valueAccessor)?"function"==typeof g?g:t=>{var e;return null!==(e=t[g])&&void 0!==e?e:1}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:1};var g;const y=new Map;for(let e=0;t.length>e;e++)y.set(t[e].id,e);const p=t.length,m=Array.from({length:p},()=>Array.from({length:p},()=>0));for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,r=y.get("string"==typeof t.source?t.source:t.source.id),i=y.get(e);if(void 0===r||void 0===i)continue;const o=d(t);m[r][i]=o}const x=a.chord().padAngle(o);s&&x.sortGroups(s);const v=x(m),b=v.groups,k=c.arc().innerRadius(u).outerRadius(l);for(const e of b){const r=t[e.index],i=k.centroid(e);r.x=i[0]+h,r.y=i[1]+f,r.arcData={startAngle:e.startAngle,endAngle:e.endAngle}}const A=new Map;for(const e of t)A.set(e.id,e);for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,r=A.get("string"==typeof t.source?t.source:t.source.id),i=A.get(e);r&&(t.source=r),i&&(t.target=i)}const w=new Map;for(const t of e)w.set(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const e of v){const r=t[e.source.index].id,i=t[e.target.index].id,o=w.get(`${r}\0${i}`)||w.get(`${i}\0${r}`);o&&(o.chordData=e)}},buildScene(t,e,r,i){var o,n;const{groupWidth:s=20,edgeOpacity:c=.5}=r,l=Math.min(i[0],i[1])/2,u=l-s,h=i[0]/2,f=i[1]/2,d=r.nodeStyle,g=r.edgeStyle,y=r.edgeColorBy||"source",p=Array.isArray(r.colorScheme)?r.colorScheme:jt,m=new Map;t.forEach((t,e)=>{m.set(t.id,p[e%p.length])});const x=a.ribbon().radius(u),v=[],b=[],k=[];for(let e=0;t.length>e;e++){const r=t[e],i=r.arcData;if(!i)continue;let n;n=d?d(Mt(r,"nodeStyle")).fill||m.get(r.id)||p[e%p.length]:m.get(r.id)||p[e%p.length];const s=d?d(Mt(r,"nodeStyle")):{},a={fill:n,stroke:s.stroke||"black",strokeWidth:null!==(o=s.strokeWidth)&&void 0!==o?o:1,opacity:s.opacity};v.push({type:"arc",cx:h,cy:f,innerR:u,outerR:l,startAngle:i.startAngle-Math.PI/2,endAngle:i.endAngle-Math.PI/2,style:a,datum:r,id:r.id,label:r.id})}for(const t of e){const e=t.chordData;if(!e)continue;const r=x(e);if(!r)continue;const i=Bt(r,h,f);let o="#999";if(g)o=g(Mt(t,"edgeStyle")).fill||o;else{const e="object"==typeof t.source?t.source:null,r="object"==typeof t.target?t.target:null;"target"===y&&r?o=m.get(r.id)||o:e&&(o=m.get(e.id)||o)}const s=g?g(Mt(t,"edgeStyle")):{},a={fill:o,fillOpacity:null!==(n=s.fillOpacity)&&void 0!==n?n:c,stroke:s.stroke||"none",strokeWidth:s.strokeWidth,opacity:s.opacity};b.push({type:"ribbon",pathD:i,style:a,datum:t})}if(!1!==r.showLabels){const e=(A=r.nodeLabel)?"function"==typeof A?A:t=>t[A]||t.id:null,i=l+12;for(const r of t){const t=r.arcData;if(!t)continue;const o=e?e(r):r.id;if(!o)continue;const n=(t.startAngle+t.endAngle)/2,s=n-Math.PI/2;k.push({x:h+Math.cos(s)*i,y:f+Math.sin(s)*i,text:o+"",anchor:n>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var A;return{sceneNodes:v,sceneEdges:b,labels:k}}};function Bt(t,e,r){const i=t.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!i)return t;const o=[];let n=0;for(;i.length>n;){const t=i[n];if("M"===t||"L"===t)for(o.push(t),n++;i.length>n&&!isNaN(Number(i[n]));)o.push(Number(i[n])+e+""),n++,i.length>n&&!isNaN(Number(i[n]))&&(o.push(Number(i[n])+r+""),n++);else if("C"===t)for(o.push(t),n++;i.length>n&&!isNaN(Number(i[n]));)for(let t=0;3>t&&i.length>n&&!isNaN(Number(i[n]));t++)o.push(Number(i[n])+e+""),n++,i.length>n&&!isNaN(Number(i[n]))&&(o.push(Number(i[n])+r+""),n++);else if("Q"===t)for(o.push(t),n++;i.length>n&&!isNaN(Number(i[n]));)for(let t=0;2>t&&i.length>n&&!isNaN(Number(i[n]));t++)o.push(Number(i[n])+e+""),n++,i.length>n&&!isNaN(Number(i[n]))&&(o.push(Number(i[n])+r+""),n++);else if("A"===t)for(o.push(t),n++;i.length>n&&!isNaN(Number(i[n]));)o.push(i[n++]),i.length>n&&o.push(i[n++]),i.length>n&&o.push(i[n++]),i.length>n&&o.push(i[n++]),i.length>n&&o.push(i[n++]),i.length>n&&(o.push(Number(i[n])+e+""),n++),i.length>n&&(o.push(Number(i[n])+r+""),n++);else"Z"===t||"z"===t?(o.push(t),n++):(o.push(i[n]),n++)}return o.join(" ")}const Rt=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Wt(t){const[e,r,i]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(t);return.299*e+.587*r+.114*i>150?"#222":"#fff"}function Ft(t,e,r){const i=e.nodeIDAccessor;return"function"==typeof i?i(t.data)+"":"string"==typeof i&&void 0!==t.data[i]?t.data[i]+"":void 0!==t.data.name?t.data.name+"":void 0!==t.data.id?t.data.id+"":"node-"+r}function Ct(t){return t?"function"==typeof t?t:e=>{var r;return(null===(r=e.data)||void 0===r?void 0:r[t])||e[t]||e.id}:null}function It(t){return Array.isArray(t.colorScheme)?t.colorScheme:Rt}function Yt(t){return Array.isArray(t.colorScheme)&&t.colorScheme.length>0?t.colorScheme[0]:"#4d430c"}function Xt(t,e,r,i,o){if("horizontal"===o){const o=(t+r)/2;return`M ${t},${e} C ${o},${e} ${o},${i} ${r},${i}`}if("radial"===o){const o=(t+r)/2;return`M ${t},${e} Q ${o},${e} ${o},${(e+i)/2} T ${r},${i}`}{const o=(e+i)/2;return`M ${t},${e} C ${t},${o} ${r},${o} ${r},${i}`}}const qt={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,r,i){var o;const n=r.__hierarchyRoot;if(!n)return;const s=r.chartType,a=function(t){if(t)return"function"==typeof t?t:e=>e[t]}(r.childrenAccessor),c=r.hierarchySum,u="function"==typeof c?c:"string"==typeof c?t=>{var e;return null!==(e=t[c])&&void 0!==e?e:0}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:0},h=l.hierarchy(n,a);h.sum(u),h.sort((t,e)=>{var r,i;return(null!==(r=e.value)&&void 0!==r?r:0)-(null!==(i=t.value)&&void 0!==i?i:0)});const[f,d]=i;switch(s){case"tree":!function(t,e,r,i){const o=e.treeOrientation||"vertical",n=l.tree();n.size("horizontal"===o?[i,r]:"radial"===o?[2*Math.PI,Math.min(r,i)/2*.8]:[r,i]),n(t)}(h,r,f,d);break;case"cluster":!function(t,e,r,i){const o=e.treeOrientation||"vertical",n=l.cluster();n.size("horizontal"===o?[i,r]:"radial"===o?[2*Math.PI,Math.min(r,i)/2*.8]:[r,i]),n(t)}(h,r,f,d);break;case"treemap":!function(t,e,r,i){var o,n;const s=null!==(o=e.padding)&&void 0!==o?o:4,a=null!==(n=e.paddingTop)&&void 0!==n?n:0,c=l.treemap().size([r,i]).tile(l.treemapBinary).padding(s);a>0&&c.paddingTop(a),c(t)}(h,r,f,d);break;case"circlepack":!function(t,e,r,i){var o;const n=null!==(o=e.padding)&&void 0!==o?o:4;l.pack().size([r,i]).padding(n)(t)}(h,r,f,d);break;case"partition":!function(t,e,r,i){var o;l.partition().size([r,i]).padding(null!==(o=e.padding)&&void 0!==o?o:1)(t)}(h,r,f,d)}const g=h.descendants();t.length=0,e.length=0;const y=new Map;for(let e=0;g.length>e;e++){const i=g[e],n={id:Ft(i,r,e),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(o=i.value)&&void 0!==o?o:0,depth:i.depth,data:i.data,createdByFrame:!0};"tree"===s||"cluster"===s?Gt(n,i,r):"treemap"===s||"partition"===s?Vt(n,i):"circlepack"===s&&Ht(n,i),n.__hierarchyNode=i,t.push(n),y.set(i,n)}if("tree"===s||"cluster"===s)for(const t of g)if(t.parent){const r=y.get(t.parent),i=y.get(t);r&&i&&e.push({source:r,target:i,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,r,i){const o=r.nodeStyle||(()=>({})),n=r.edgeStyle||(()=>({}));switch(r.chartType){case"tree":case"cluster":return function(t,e,r,i,o,n){var s,a,c,l,u;const h=[],f=[],d=[],g=r.treeOrientation||"vertical",y="radial"===g,p=i[0]/2,m=i[1]/2,x="number"==typeof(v=r.nodeSize)?v:5;var v;for(const e of t){let t=e.x,i=e.y;y&&(t+=p,i+=m);const n=o(Mt(e,"nodeStyle"));let a=n.fill||Yt(r);if(r.colorByDepth&&void 0!==e.depth){const t=It(r);a=t[e.depth%t.length]}const c={fill:a,stroke:n.stroke||"#fff",strokeWidth:null!==(s=n.strokeWidth)&&void 0!==s?s:1,opacity:n.opacity};h.push({type:"circle",cx:t,cy:i,r:x,style:c,datum:e,id:e.id,label:e.id,depth:e.depth})}const b=null!==(a=r.edgeOpacity)&&void 0!==a?a:.5;for(const t of e){const e="object"==typeof t.source?t.source:null,r="object"==typeof t.target?t.target:null;if(!e||!r)continue;let i=e.x,o=e.y,s=r.x,a=r.y;y&&(i+=p,o+=m,s+=p,a+=m);const u=Xt(i,o,s,a,g),h=n(Mt(t,"edgeStyle")),d={fill:"none",stroke:h.stroke||"#999",strokeWidth:null!==(c=h.strokeWidth)&&void 0!==c?c:1.5,opacity:null!==(l=h.opacity)&&void 0!==l?l:b};f.push({type:"curved",pathD:u,style:d,datum:t})}if(!1!==r.showLabels){const e=Ct(r.nodeLabel);for(const r of t){const t=e?e(r):r.id;if(!t)continue;let i,o,n,s=r.x,a=r.y;if(y&&(s+=p,a+=m),y){const t=s-p,e=a-m,r=Math.sqrt(t*t+e*e);r>0?(i=s+t/r*10,o=a+e/r*10,n=0>t?"end":"start"):(i=s,o=a-12,n="middle")}else"horizontal"===g?((null===(u=r.data)||void 0===u?void 0:u.children)&&0!==r.data.children.length?(i=s-x-6,n="end"):(i=s+x+6,n="start"),o=a):(i=s,o=a+x+14,n="middle");d.push({x:i,y:o,text:t+"",anchor:n,baseline:"middle",fontSize:11})}}return{sceneNodes:h,sceneEdges:f,labels:d}}(t,e,r,i,o,n);case"treemap":case"partition":return function(t,e,r,i){var o,n;const s=[],a=[];for(const r of t){const t=r.x1-r.x0,n=r.y1-r.y0;if(0>=t||0>=n)continue;const a=i(Mt(r,"nodeStyle"));let c=a.fill||Yt(e);if(e.colorByDepth&&void 0!==r.depth){const t=It(e);c=t[r.depth%t.length]}const l={fill:c,stroke:a.stroke||"#fff",strokeWidth:null!==(o=a.strokeWidth)&&void 0!==o?o:1,opacity:a.opacity};s.push({type:"rect",x:r.x0,y:r.y0,w:t,h:n,style:l,datum:r,id:r.id,label:r.id,depth:r.depth})}if(!1!==e.showLabels){const r=Ct(e.nodeLabel),o=e.labelMode||"leaf",s="partition"===e.chartType;for(const c of t){const t=c.x1-c.x0,l=c.y1-c.y0;if(0>=t||0>=l)continue;const u=!((null===(n=c.data)||void 0===n?void 0:n.children)&&c.data.children.length>0);if(!s){if("leaf"===o&&!u)continue;if("parent"===o&&u)continue}const h=r?r(c):c.id;if(!h)continue;if((u?30:40)>t||(u?16:14)>l)continue;let f=i(Mt(c,"nodeStyle")).fill||Yt(e);if(e.colorByDepth&&void 0!==c.depth){const t=It(e);f=t[c.depth%t.length]}const d=Wt(f);a.push(u?{x:c.x0+t/2,y:c.y0+l/2,text:h+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,l)/6)),fill:d}:{x:c.x0+4,y:c.y0+12,text:h+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:d})}}return{sceneNodes:s,sceneEdges:[],labels:a}}(t,r,0,o);case"circlepack":return function(t,e,r,i){var o,n,s,a,c;const l=[],u=[];for(const r of t){const t=null!==(o=r.__radius)&&void 0!==o?o:5;if(0>=t)continue;const a=i(Mt(r,"nodeStyle"));let c=a.fill||Yt(e);if(e.colorByDepth&&void 0!==r.depth){const t=It(e);c=t[r.depth%t.length]}const u={fill:c,stroke:a.stroke||"#fff",strokeWidth:null!==(n=a.strokeWidth)&&void 0!==n?n:1,opacity:null!==(s=a.opacity)&&void 0!==s?s:.7};l.push({type:"circle",cx:r.x,cy:r.y,r:t,style:u,datum:r,id:r.id,label:r.id,depth:r.depth})}if(!1!==e.showLabels){const r=Ct(e.nodeLabel);for(const o of t){const t=null!==(a=o.__radius)&&void 0!==a?a:5,n=r?r(o):o.id;if(!n)continue;if(15>t)continue;const s=!((null===(c=o.data)||void 0===c?void 0:c.children)&&o.data.children.length>0);let l=i(Mt(o,"nodeStyle")).fill||Yt(e);if(e.colorByDepth&&void 0!==o.depth){const t=It(e);l=t[o.depth%t.length]}if(s){const e=Wt(l);u.push({x:o.x,y:o.y,text:n+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,t/3)),fill:e})}else u.push({x:o.x,y:o.y-t+14,text:n+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,t/3)),fill:"#000",stroke:"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:l,sceneEdges:[],labels:u}}(t,r,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Gt(t,e,r){const i=r.treeOrientation||"vertical";if("radial"===i){const r=e.x,i=e.y;t.x=i*Math.cos(r-Math.PI/2),t.y=i*Math.sin(r-Math.PI/2)}else"horizontal"===i?(t.x=e.y,t.y=e.x):(t.x=e.x,t.y=e.y);t.x0=t.x-5,t.x1=t.x+5,t.y0=t.y-5,t.y1=t.y+5,t.width=10,t.height=10}function Vt(t,e){t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.x=(e.x0+e.x1)/2,t.y=(e.y0+e.y1)/2,t.width=e.x1-e.x0,t.height=e.y1-e.y0}function Ht(t,e){var r;const i=null!==(r=e.r)&&void 0!==r?r:0;t.x=e.x,t.y=e.y,t.x0=e.x-i,t.x1=e.x+i,t.y0=e.y-i,t.y1=e.y+i,t.width=2*i,t.height=2*i,t.__radius=i}function Zt(t){const e=t;return e.__orbitState||(e.__orbitState={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()}),e.__orbitState}const Kt={sankey:Lt,force:Tt,chord:Nt,tree:qt,cluster:qt,treemap:qt,circlepack:qt,partition:qt,orbit:{supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(t,e,r,i){const o=r.__hierarchyRoot;o&&function(t,e,r,i,o){var n,s;const a=function(t){if("function"==typeof t)return t;const e=t||"children";return t=>t[e]||null}(r.childrenAccessor),l=function(t){if("function"==typeof t)return t;const e=t||"name";return t=>{var r;return(null!==(r=t[e])&&void 0!==r?r:"")+""}}(r.nodeIDAccessor),u=function(t){if(Array.isArray(t))return t;switch(t){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(r.orbitMode),h=null!==(n=r.orbitSize)&&void 0!==n?n:2.95,f=null!==(s=r.orbitEccentricity)&&void 0!==s?s:1,d="number"==typeof h?()=>h:h,g="number"==typeof f?()=>f:f,y=Zt(r);y.metaMap.clear(),i.length=0,o.length=0;const p=new Map;function m(t){var e;const r=null!==(e=p.get(t))&&void 0!==e?e:0;return p.set(t,r+1),0===r?t:`${t}__${r}`}const x=e[0]/2,v=e[1]/2,b=Math.min(e[0],e[1])/2*.85,k=m(l(t));i.push({id:k,x:x,y:v,x0:x,x1:x,y0:v,y1:v,width:0,height:0,value:0,depth:0,data:t}),y.metaMap.set(k,{ring:b,angle:0,depth:0,parentId:null,eccentricity:1}),function t(e,r,n,s,h,f,p){const x=a(e);if(!(null==x?void 0:x.length))return;const v=x.length;let b=0,k=0,A=0;for(;v>k;)k+=u[Math.min(A,u.length-1)],A++,b++;let w=0;for(let v=0;b>v;v++){const k=u[Math.min(v,u.length-1)],A=x.slice(w,w+k);if(!A.length)break;const S=(v+1)/b,_={id:r,depth:f,data:e,parentId:r},P=p?h/d(_)*S:h*S,E=c.pie().value(t=>{var e;return(null===(e=a(t))||void 0===e?void 0:e.length)?4:1}).sort(null),M=E(A),O=g(_);for(let e=0;A.length>e;e++){const a=(M[e].startAngle+M[e].endAngle)/2,c=A[e],u=m(l(c)),h=n+P*Math.sin(a),d=s+P*Math.cos(a)*O;i.push({id:u,x:h,y:d,x0:h,x1:h,y0:d,y1:d,width:0,height:0,value:0,depth:f,data:c}),y.metaMap.set(u,{ring:P,angle:a,depth:f,parentId:r,eccentricity:O}),o.push({source:r,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:r,target:u}}),t(c,u,h,d,P,f+1,!0)}w+=k}}(t,k,x,v,b,1,!1)}(o,i,r,t,e)},buildScene(t,e,r,i){var o,n,s,a,c;const l=r.nodeStyle,u=r.nodeSize,h="number"==typeof u?()=>u:"function"==typeof u?u:()=>6,f=[],d=[],g=[];if(!1!==r.orbitShowRings){const e=Zt(r),i=new Map;for(const e of t)i.set(e.id,e);const o=new Map;for(const[,t]of e.metaMap){if(!t.parentId)continue;const e=i.get(t.parentId);if(!e)continue;const r=`${t.parentId}:${t.ring}`;o.has(r)||o.set(r,{parentX:e.x,parentY:e.y,ring:t.ring,ecc:t.eccentricity})}const n=48,s={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:t,parentY:e,ring:r,ecc:i}]of o)for(let o=0;n>o;o++){const a=o/n*Math.PI*2,c=(o+1)/n*Math.PI*2;d.push({type:"line",x1:t+r*Math.sin(a),y1:e+r*Math.cos(a)*i,x2:t+r*Math.sin(c),y2:e+r*Math.cos(c)*i,style:s,datum:null})}}for(const e of t){if(null==e.x||null==e.y)continue;const t=h(Mt(e,"nodeSize")),r=l?l(Mt(e,"nodeStyle")):{},i={fill:r.fill||"#6366f1",stroke:r.stroke||"#fff",strokeWidth:null!==(o=r.strokeWidth)&&void 0!==o?o:1,opacity:null!==(n=r.opacity)&&void 0!==n?n:0===(null!==(s=e.depth)&&void 0!==s?s:0)?1:.85};f.push({type:"circle",cx:e.x,cy:e.y,r:t,style:i,datum:e,id:e.id,label:e.id,depth:e.depth})}const y=new Map;for(const e of t)y.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:y.get(t.source),r="object"==typeof t.target?t.target:y.get(t.target);e&&r&&(null!=e.x&&null!=r.x&&d.push({type:"line",x1:e.x,y1:e.y,x2:r.x,y2:r.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:t}))}if(r.showLabels){const e=r.nodeLabel;for(const r of t){const t=h(Mt(r,"nodeSize"));if(4>=t)continue;const i="function"==typeof e?e(r):e&&null!==(c=null===(a=r.data)||void 0===a?void 0:a[e])&&void 0!==c?c:r.id;g.push({x:r.x,y:r.y+t+12,text:i+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:f,sceneEdges:d,labels:g}},tick:(t,e,r,i,o)=>!1!==r.orbitAnimated&&(function(t,e){var r,i;const o=Zt(e),n=null!==(r=e.orbitSpeed)&&void 0!==r?r:.25,s=null!==(i=e.orbitRevolution)&&void 0!==i?i:function(t){switch(t){case"decay":return t=>{var e;return Math.pow(.6,null!==(e=t.depth)&&void 0!==e?e:0)};case"alternate":return t=>{var e;const r=null!==(e=t.depth)&&void 0!==e?e:0;return(r%2==0?1:-1)/(r+1)};default:return t=>{var e;return 1/((null!==(e=t.depth)&&void 0!==e?e:0)+1)}}}(e.orbitRevolutionStyle),a=(("undefined"!=typeof performance?performance.now():Date.now())-o.startTime)/1e3,c=n*(Math.PI/6),l=new Map;for(const e of t)l.set(e.id,e);for(const e of t){const t=o.metaMap.get(e.id);if(!t||!t.parentId)continue;const r=l.get(t.parentId);if(!r)continue;const i=t.angle+a*c*s({id:e.id,depth:t.depth,data:e.data,parentId:t.parentId});e.x=r.x+t.ring*Math.sin(i),e.y=r.y+t.ring*Math.cos(i)*t.eccentricity,e.x0=e.x,e.x1=e.x,e.y0=e.y,e.y1=e.y}}(t,r),!0)}};function Ut(t,e){const{columns:r,config:i,resolvePieceStyle:o}=t,n=[],s=Math.min(e.width,e.height)/2-4,a="donut"===i.chartType?i.innerRadius||60:0,c=-Math.PI/2+(i.startAngle||0)*Math.PI/180,l=null!=i.sweepAngle?i.sweepAngle*Math.PI/180:2*Math.PI;for(const t of Object.values(r)){const e=c+t.pctStart*l,r=c+(t.pctStart+t.pct)*l,u=o(t.pieceData[0],t.name);n.push(Object.assign(Object.assign({type:"wedge",cx:0,cy:0,innerRadius:a,outerRadius:s,startAngle:e,endAngle:r},i.cornerRadius&&{cornerRadius:i.cornerRadius}),{style:u,datum:t.pieceData,category:t.name}))}return n}function Qt(t){var e,r,i;const n=t.length,s=t[0],a=t[n-1];return{n:n,min:s,q1:null!==(e=o.quantile(t,.25))&&void 0!==e?e:s,median:null!==(r=o.quantile(t,.5))&&void 0!==r?r:(s+a)/2,q3:null!==(i=o.quantile(t,.75))&&void 0!==i?i:a,max:a,mean:t.reduce((t,e)=>t+e,0)/n}}const Jt={bar:function(t,e){var r;const{scales:i,columns:o,config:n,getR:s,getStack:a,resolvePieceStyle:c}=t,{r:l,projection:u}=i,h=[],f="vertical"===u,d="horizontal"===u,g=n.normalize,y=[];if(a){const t=new Set;for(const e of Object.values(o))for(const r of e.pieceData){const e=a(r);t.has(e)||(t.add(e),y.push(e))}}else y.push("_default");for(const t of Object.values(o)){const e=new Map;for(const r of t.pieceData){const t=a?a(r):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const i=e.get(t);i.total+=s(r),i.pieces.push(r)}let r=0;if(g)for(const t of e.values())r+=Math.abs(t.total);let i=0,o=0;for(const n of y){const s=e.get(n);if(!s)continue;let u=s.total;g&&r>0&&(u/=r);const y=c(s.pieces[0],a?n:t.name),p=Object.assign(Object.assign({},s.pieces[0]),{__aggregateValue:s.total,__pieceCount:s.pieces.length,category:t.name});if(f){const e=l(0>u?o:i+u),r=0>u?l(o+u)-l(o):l(i)-l(i+u);h.push(D(t.x,e,t.width,Math.abs(r),y,p,n)),0>u?o+=u:i+=u}else if(d){const e=l(0>u?o+u:i),r=0>u?l(o)-l(o+u):l(i+u)-l(i);h.push(D(e,t.x,Math.abs(r),t.width,y,p,n)),0>u?o+=u:i+=u}}}if(n.roundedTop&&n.roundedTop>0){const t=Math.max(0,n.roundedTop),e=new Map;for(const t of h){if("rect"!==t.type)continue;const i=(null===(r=t.datum)||void 0===r?void 0:r.category)||"";e.has(i)||e.set(i,[]),e.get(i).push(t)}const i="vertical"===u;for(const r of e.values()){if(0===r.length)continue;const e=r.filter(t=>{var e,r;return(null!==(r=null===(e=t.datum)||void 0===e?void 0:e.__aggregateValue)&&void 0!==r?r:0)>=0}),o=r.filter(t=>{var e,r;return 0>(null!==(r=null===(e=t.datum)||void 0===e?void 0:e.__aggregateValue)&&void 0!==r?r:0)});if(e.length>0){const r=e.reduce(i?(t,e)=>e.y>t.y?t:e:(t,e)=>t.x+t.w>e.x+e.w?t:e);r.roundedTop=t,r.roundedEdge=i?"top":"right"}if(o.length>0){const e=o.reduce(i?(t,e)=>t.y+t.h>e.y+e.h?t:e:(t,e)=>e.x>t.x?t:e);e.roundedTop=t,e.roundedEdge=i?"bottom":"left"}}}return h},clusterbar:function(t,e){const{scales:r,columns:i,config:o,getR:n,getGroup:s,resolvePieceStyle:a}=t,{r:c,projection:l}=r,u=[],h="vertical"===l,f=[],d=new Set;for(const t of Object.values(i))for(const e of t.pieceData){const t=s?s(e):"_default";d.has(t)||(d.add(t),f.push(t))}const g=f.length||1;for(const t of Object.values(i)){const e=t.width/g,r=.2*e,i=e-r,o=new Map;for(const e of t.pieceData){const t=s?s(e):"_default";o.has(t)||o.set(t,[]),o.get(t).push(e)}for(let s=0;f.length>s;s++){const l=o.get(f[s])||[];for(const o of l){const l=n(o),d=a(o,f[s]);if(h){const n=t.x+s*e+r/2,a=c(0),h=c(l);u.push(D(n,Math.min(a,h),i,Math.abs(a-h),d,o,f[s]))}else{const n=t.x+s*e+r/2,a=c(0),h=c(l);u.push(D(Math.min(a,h),n,Math.abs(h-a),i,d,o,f[s]))}}}}if(o.roundedTop&&o.roundedTop>0){const t=Math.max(0,o.roundedTop);for(const e of u){if("rect"!==e.type)continue;const r=n(e.datum);e.roundedTop=t,e.roundedEdge=h?0>r?"bottom":"top":0>r?"left":"right"}}return u},point:function(t,e){var r,i;const{scales:o,columns:n,getR:s,multiScales:a,resolvePieceStyle:c}=t,{r:l,projection:u}=o,h=[],f="vertical"===u,d="radial"===u,g=a.length>0,y=2*Math.PI,p=-Math.PI/2;for(const t of Object.values(n))for(const e of t.pieceData){const o=null!==(r=e.__rIndex)&&void 0!==r?r:0,n=null!==(i=e.__rValue)&&void 0!==i?i:s(e),u=g&&a[o]||l,m=c(e,t.name),x=m.r||5;let v,b;if(d){const e=p+(t.pctStart+t.pct/2)*y,r=u(n);v=Math.cos(e)*r,b=Math.sin(e)*r}else f?(v=t.middle,b=u(n)):(v=u(n),b=t.middle);h.push({type:"point",x:v,y:b,r:x,style:m,datum:e})}return h},swarm:function(t,e){const{scales:r,columns:i,getR:o,resolvePieceStyle:n}=t,{r:s,projection:a}=r,c=[],l="vertical"===a;for(const t of Object.values(i)){const e=t.width/2;for(let r=0;t.pieceData.length>r;r++){const i=t.pieceData[r],a=o(i),u=n(i,t.name),h=u.r||4,f=(7919*r%100/100-.5)*e*.8,d=l?t.middle+f:s(a),g=l?s(a):t.middle+f;c.push({type:"point",x:d,y:g,r:h,style:u,datum:i})}}return c},pie:Ut,donut:Ut,boxplot:function(t,e){var r,i,n,s,a;const{scales:c,columns:l,config:u,getR:h,resolveSummaryStyle:f}=t,{r:d,projection:g}=c,y=[],p="vertical"===g,m=!1!==u.showOutliers;for(const t of Object.values(l)){const e=t.pieceData.map(t=>h(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(0===e.length)continue;const c=e[0],l=e[e.length-1],u=null!==(r=o.quantile(e,.25))&&void 0!==r?r:c,g=null!==(i=o.quantile(e,.5))&&void 0!==i?i:(c+l)/2,x=null!==(n=o.quantile(e,.75))&&void 0!==n?n:l,v=x-u,b=u-1.5*v,k=x+1.5*v,A=null!==(s=e.find(t=>t>=b))&&void 0!==s?s:c,w=null!==(a=[...e].reverse().find(t=>k>=t))&&void 0!==a?a:l,S=f(t.pieceData[0],t.name),_=[];if(m)for(const e of t.pieceData){const r=h(e);if(b>r||r>k){const i=p?t.middle:d(r),o=p?d(r):t.middle;_.push({px:i,py:o,value:r,datum:e})}}if(y.push({type:"boxplot",x:p?t.middle:0,y:p?0:t.middle,projection:p?"vertical":"horizontal",columnWidth:.6*t.width,minPos:d(A),q1Pos:d(u),medianPos:d(g),q3Pos:d(x),maxPos:d(w),stats:{n:e.length,min:A,q1:u,median:g,q3:x,max:w,mean:e.reduce((t,e)=>t+e,0)/e.length},style:S,datum:t.pieceData,category:t.name,outliers:_}),m)for(const t of _)y.push({type:"point",x:t.px,y:t.py,r:3,style:{fill:S.fill||"#999",opacity:.6},datum:t.datum})}return y},violin:function(t,e){var r,i,n;const{scales:s,columns:a,config:c,getR:l,resolveSummaryStyle:u}=t,{r:h,projection:f}=s,d=[],g="vertical"===f,y=c.bins||20,p=!1!==c.showIQR;for(const t of Object.values(a)){const e=t.pieceData.map(t=>l(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const s=e[0],a=e[e.length-1],c=(a-s)/y||1,f=Array(y).fill(0);for(const t of e)f[Math.min(Math.floor((t-s)/c),y-1)]++;const m=Math.max(...f,1),x=t.width/2*.9;let v="";if(g){v=`M ${t.middle} ${h(s)}`;for(let e=0;y>e;e++){const r=h(s+(e+.5)*c);v+=` L ${t.middle+f[e]/m*x} ${r}`}v+=` L ${t.middle} ${h(a)}`;for(let e=y-1;e>=0;e--){const r=h(s+(e+.5)*c);v+=` L ${t.middle-f[e]/m*x} ${r}`}v+=" Z"}else{v=`M ${h(s)} ${t.middle}`;for(let e=0;y>e;e++)v+=` L ${h(s+(e+.5)*c)} ${t.middle-f[e]/m*x}`;v+=` L ${h(a)} ${t.middle}`;for(let e=y-1;e>=0;e--)v+=` L ${h(s+(e+.5)*c)} ${t.middle+f[e]/m*x}`;v+=" Z"}const b=u(t.pieceData[0],t.name);let k;if(p&&e.length>=4){const c=null!==(r=o.quantile(e,.25))&&void 0!==r?r:s,l=null!==(i=o.quantile(e,.5))&&void 0!==i?i:(s+a)/2,u=null!==(n=o.quantile(e,.75))&&void 0!==n?n:a;k={q1Pos:h(c),medianPos:h(l),q3Pos:h(u),centerPos:t.middle,isVertical:g}}const A=g?{x:t.x,y:Math.min(h(a),h(s)),width:t.width,height:Math.abs(h(a)-h(s))}:{x:Math.min(h(s),h(a)),y:t.x,width:Math.abs(h(a)-h(s)),height:t.width};d.push({type:"violin",pathString:v,translateX:0,translateY:0,bounds:A,iqrLine:k,stats:Qt(e),style:b,datum:t.pieceData,category:t.name})}return d},histogram:function(t,e){var r;const{scales:i,columns:o,config:n,getR:s,resolveSummaryStyle:a}=t,{r:c}=i,l=[],u=n.bins||25,h=n.normalize,f=null===(r=c.domain)||void 0===r?void 0:r.call(c),d=f?+f[0]:void 0,g=f?+f[1]:void 0;for(const t of Object.values(o)){const e=t.pieceData.map(t=>s(t)).filter(t=>null!=t&&!isNaN(t));if(0===e.length)continue;const r=null!=d&&isFinite(d)?d:Math.min(...e),i=null!=g&&isFinite(g)?g:Math.max(...e),o=(i-r)/u||1,n=Array(u).fill(0);for(const t of e)r>t||t>i||n[Math.min(Math.floor((t-r)/o),u-1)]++;const f=e.length,y=Math.max(...n,1),p=a(t.pieceData[0],t.name);for(let e=0;u>e;e++){if(0===n[e])continue;const i=(h?n[e]/f:n[e]/y)*t.width*.9,s=c(r+e*o),a=c(r+(e+1)*o);l.push(D(Math.min(s,a),t.x+t.width-i,Math.abs(a-s),i,p,{bin:e,count:n[e],range:[r+e*o,r+(e+1)*o],category:t.name},t.name))}}return l},ridgeline:function(t,e){var r;const{scales:i,columns:o,config:n,getR:s,resolveSummaryStyle:a}=t,{r:c,projection:l}=i,u=[],h=n.bins||20,f="horizontal"===l,d=n.amplitude||1.5;for(const t of Object.values(o)){const e=t.pieceData.map(t=>s(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const i=e[0],o=e[e.length-1],n=(o-i)/h||1,l=Array(h).fill(0);for(const t of e)i>t||t>o||l[Math.min(Math.floor((t-i)/n),h-1)]++;const g=Math.max(...l,1),y=a(t.pieceData[0],t.name),p=t.width*d;let m="";if(f){const e=t.x+t.width;m=`M ${c(i)} ${e}`;for(let t=0;h>t;t++)m+=` L ${c(i+(t+.5)*n)} ${e-l[t]/g*p}`;m+=` L ${c(o)} ${e} Z`}else{const e=t.x;m=`M ${e} ${c(i)}`;for(let t=0;h>t;t++){const r=c(i+(t+.5)*n);m+=` L ${e+l[t]/g*p} ${r}`}m+=` L ${e} ${c(o)} Z`}const x=f?{x:Math.min(c(i),c(o)),y:t.x,width:Math.abs(c(o)-c(i)),height:t.width}:{x:t.x,y:Math.min(c(o),c(i)),width:t.width,height:Math.abs(c(o)-c(i))};u.push({type:"violin",pathString:m,translateX:0,translateY:0,bounds:x,stats:Qt(e),style:Object.assign(Object.assign({},y),{fillOpacity:null!==(r=y.fillOpacity)&&void 0!==r?r:.5}),datum:t.pieceData,category:t.name})}return u},timeline:function(t,e){const{scales:r,columns:i,getRawRange:o,resolvePieceStyle:n}=t,{r:s,projection:a}=r,c=[],l="horizontal"===a;for(const t of Object.values(i))for(const e of t.pieceData){const r=o(e);if(!r)continue;const[i,a]=r,u=n(e,t.name);if(l){const r=s(Math.min(i,a)),o=s(Math.max(i,a));c.push(D(r,t.x,o-r,t.width,u,e,t.name))}else{const r=s(Math.max(i,a)),o=s(Math.min(i,a));c.push(D(t.x,r,t.width,o-r,u,e,t.name))}}return c},funnel:function(t,r){var i,o,n,s,a,c,l;const{columns:u,getR:h,getStack:f,resolvePieceStyle:d}=t,g=[],y=r.width/2,p=!1!==t.config.showLabels,m=t.scales.o.domain().map(t=>u[t]).filter(Boolean);if(0===m.length)return g;const x=[],v=new Set;for(const t of m)for(const e of t.pieceData){const t=f?f(e):"_default";v.has(t)||(v.add(t),x.push(t))}const b=x.length>1&&"_default"!==x[0],k=[];let A=0;for(const t of m){const e=new Map;let r=0;for(const i of t.pieceData){const t=f?f(i):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const o=e.get(t),n=h(i);o.total+=n,o.pieces.push(i),r+=n}k.push({col:t,groups:e,stepTotal:r}),b||r>A&&(A=r)}if(b)for(const t of k){let e=0,r=0;for(let i=0;x.length>i;i++){const o=t.groups.get(x[i]);o&&(i%2==0?e+=o.total:r+=o.total)}const i=Math.max(e,r);i>A&&(A=i)}if(0===A)return g;const w=new Map;for(const t of x){const e=k[0].groups.get(t);w.set(t,null!==(i=null==e?void 0:e.total)&&void 0!==i?i:0)}const S=k[0].stepTotal,_=b?.95*y:.9*r.width,P=e.scaleLinear().domain([0,A]).range([0,_]),E=null!==(o=t.config.connectorOpacity)&&void 0!==o?o:.3;let M=new Map;for(let t=0;k.length>t;t++){const e=k[t],r=e.col,i=0===t,o=r.width,u=.55*o,h=r.x+(o-u)/2,f=new Map;if(b){let t=0;for(const r of x){const i=e.groups.get(r);i&&(t+=P(i.total))}let o=y,n=y;for(let s=0;x.length>s;s++){const c=x[s],l=e.groups.get(c);if(!l)continue;const m=P(l.total),v=s%2==0,b=v?o:n-m;v?o+=m:n-=m;const k=d(l.pieces[0],c),A=null!==(a=w.get(c))&&void 0!==a?a:l.total,S=A>0?l.total/A*100:0,_=Object.assign(Object.assign({},l.pieces[0]),{__funnelValue:l.total,__funnelPercent:S,__funnelStep:r.name,__funnelIsFirstStep:i,__aggregateValue:l.total,__pieceCount:l.pieces.length,category:c});p&&(0===s&&(_.__funnelStepLabel=r.name,_.__funnelStepLabelX=y,_.__funnelStepLabelY=h,_.__funnelRowWidth=t),_.__funnelValueLabelX=b+m/2,_.__funnelValueLabelY=h,_.__funnelBarW=m),g.push(D(b,h,m,u,k,_,c)),f.set(c,{x:b,y:h,w:m,h:u})}}else{const t=e.stepTotal,o=P(t),a=y-o/2,c=x[0],l="_default"!==c,m=null!==(s=null===(n=e.groups.get(c))||void 0===n?void 0:n.pieces[0])&&void 0!==s?s:r.pieceData[0],v=l?c:r.name,b=d(m,v),k=S>0?t/S*100:0,A=Object.assign(Object.assign({},m),{__funnelValue:t,__funnelPercent:k,__funnelStep:r.name,__funnelIsFirstStep:i,category:l?c:r.name});p&&(A.__funnelStepLabel=r.name,A.__funnelStepLabelX=y,A.__funnelStepLabelY=h,A.__funnelRowWidth=o,A.__funnelValueLabelX=y,A.__funnelValueLabelY=h,A.__funnelBarW=o),g.push(D(a,h,o,u,b,A,v)),f.set(c,{x:a,y:h,w:o,h:u})}if(t>0&&M.size>0){const t=b?x:[x[0]];for(const i of t){const t=M.get(i),o=f.get(i);if(!t||!o)continue;const n=(()=>{const t=e.groups.get(i);return d(t?t.pieces[0]:r.pieceData[0],"_default"===i?r.name:i)})(),s={type:"trapezoid",points:[[t.x,t.y+t.h],[t.x+t.w,t.y+t.h],[o.x+o.w,o.y],[o.x,o.y]],style:{fill:n.fill||"#999",opacity:E},datum:null!==(l=null===(c=e.groups.get(i))||void 0===c?void 0:c.pieces[0])&&void 0!==l?l:r.pieceData[0],category:"_default"===i?r.name:i};g.push(s)}}M=f}return g},"bar-funnel":function(t,e){var r,i,o,n;const{columns:s,getR:a,getStack:c,resolvePieceStyle:l,scales:u}=t,h=[],f=u.o.domain().map(t=>s[t]).filter(Boolean);if(0===f.length)return h;const d=[],g=new Set;for(const t of f)for(const e of t.pieceData){const t=c?c(e):"_default";g.has(t)||(g.add(t),d.push(t))}const y=d.length>1&&"_default"!==d[0],p=[];for(const t of f){const e=new Map;let r=0;for(const i of t.pieceData){const t=c?c(i):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const o=e.get(t),n=a(i);o.total+=n,o.pieces.push(i),r+=n}p.push({col:t,groups:e,stepTotal:r})}const m=new Map;for(const t of d){const e=null===(r=p[0])||void 0===r?void 0:r.groups.get(t);m.set(t,null!==(i=null==e?void 0:e.total)&&void 0!==i?i:0)}const x=u.r,v=y?d.length:1,b=y?.15:0;for(let t=0;p.length>t;t++){const e=p[t],r=e.col,i=0===t,s=t>0?p[t-1]:null,a=r.width/v,c=a*b,u=a-c;for(let t=0;d.length>t;t++){const f=d[t],g=e.groups.get(f);if(!g)continue;const p=g.total,v=null!==(o=m.get(f))&&void 0!==o?o:p,b=v>0?p/v*100:0,k=null==s?void 0:s.groups.get(f),A=null!==(n=null==k?void 0:k.total)&&void 0!==n?n:p,w=i?0:Math.max(0,A-p),S=r.x+t*a+c/2,_=x(p),P=x(0)-_,E=l(g.pieces[0],y?f:r.name),M=Object.assign(Object.assign({},g.pieces[0]),{__barFunnelValue:p,__barFunnelPercent:b,__barFunnelIsFirstStep:i,__barFunnelIsDropoff:!1,__barFunnelStep:r.name,__barFunnelDropoffValue:w,__barFunnelCategory:"_default"===f?void 0:f,category:y?f:r.name,__barFunnelLabelX:S+u/2,__barFunnelLabelY:x(p+w)});if(h.push(D(S,_,u,P,E,M,y?f:r.name)),w>0){const t=x(p+w),e=_-t,i=Object.assign({},E),o=Object.assign(Object.assign({},g.pieces[0]),{__barFunnelValue:w,__barFunnelPercent:v>0?w/v*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:r.name,__barFunnelCategory:"_default"===f?void 0:f,category:y?f:r.name});h.push(D(S,t,u,e,i,o,y?f:r.name))}}}return h},swimlane:function(t,e){const{scales:r,columns:i,getR:o,getStack:n,resolvePieceStyle:s}=t,{r:a,projection:c}=r,l=[],u="horizontal"===c;for(const t of Object.values(i)){let e=0;for(const r of t.pieceData){const i=Math.abs(o(r));if(0===i)continue;const c=n?n(r):t.name,h=s(r,c);if(u){const o=a(e),n=a(e+i);l.push(D(o,t.x,n-o,t.width,h,r,c))}else{const o=a(e+i),n=a(e);l.push(D(t.x,o,t.width,n-o,h,r,c))}e+=i}}return l}};class te{constructor(t){this.rExtent=new y,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=t,this.buffer=new g(t.windowSize),this.getO=b(t.oAccessor||t.categoryAccessor,"category");const e="streaming"===t.runtimeMode,r=t.rAccessor;Array.isArray(r)?(this.rAccessors=r.map(t=>x(t,"value")),this.getR=this.rAccessors[0],this.rExtents=r.map(()=>new y)):(this.getR=x(e&&(t.timeAccessor||t.valueAccessor)&&t.valueAccessor||r,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=b(t.stackBy),this.getGroup=b(t.groupBy),this.getColor=b(t.colorAccessor),this.getConnector=b(t.connectorAccessor),this.getDataId=b(t.dataIdAccessor),t.pulse&&(this.timestampBuffer=new g(t.windowSize))}ingest(t){const e="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=e,t.bounded){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const r=t.totalSize||t.inserts.length;r>this.buffer.capacity&&(this.buffer.resize(r),this.timestampBuffer&&r>this.timestampBuffer.capacity&&this.timestampBuffer.resize(r));for(const r of t.inserts)this.buffer.push(r),this.timestampBuffer&&this.timestampBuffer.push(e),this.categories.add(this.getO(r)),this.pushValueExtent(r)}else{this._hasStreamingData=!0;for(const r of t.inserts){const t=this.buffer.push(r);this.timestampBuffer&&this.timestampBuffer.push(e),this.categories.add(this.getO(r)),this.pushValueExtent(r),null!=t&&this.evictValueExtent(t)}}return!0}pushValueExtent(t){if("timeline"===this.config.chartType){const e=this.getRawRange(t);e&&(this.rExtent.push(e[0]),this.rExtent.push(e[1]))}else if(this.rAccessors.length>1){for(let e=0;this.rAccessors.length>e;e++)this.rExtents[e].push(this.rAccessors[e](t));this.rExtent.push(this.getR(t))}else this.rExtent.push(this.getR(t))}evictValueExtent(t){if("timeline"===this.config.chartType){const e=this.getRawRange(t);e&&(this.rExtent.evict(e[0]),this.rExtent.evict(e[1]))}else if(this.rAccessors.length>1){for(let e=0;this.rAccessors.length>e;e++)this.rExtents[e].evict(this.rAccessors[e](t));this.rExtent.evict(this.getR(t))}else this.rExtent.evict(this.getR(t))}getRawRange(t){const e=this.config.rAccessor;if(!e)return null;const r="function"==typeof e?e(t):t[e];return Array.isArray(r)&&r.length>=2?[+r[0],+r[1]]:null}computeScene(t){const{config:r,buffer:i}=this;if(0===i.size)return this.scales=null,this.scene=[],this.columns={},void this.version++;this.rExtent.dirty&&this.rExtent.recalculate(i,this.getR);const o=i.toArray(),n=r.projection||"vertical",s=r.oExtent||this.resolveCategories(o),a=this.computeValueDomain(o,s),c="horizontal"===n,l=null!=r.barPadding?r.barPadding/("vertical"===n?t.width:t.height):.1;let u,h;if("radial"===n){u=e.scaleBand().domain(s).range([0,1]).padding(0);const i=Math.min(t.width,t.height)/2,o=r.innerRadius||0;h=e.scaleLinear().domain(a).range([o,i])}else c?(u=e.scaleBand().domain(s).range([0,t.height]).padding(l),h=e.scaleLinear().domain(a).range([0,t.width])):(u=e.scaleBand().domain(s).range([0,t.width]).padding(l),h=e.scaleLinear().domain(a).range([t.height,0]));this.scales={o:u,r:h,projection:n},this.multiScales=this.rAccessors.length>1&&r.multiAxis?this.rAccessors.map((o,n)=>{var s;const a=this.rExtents[n];a.dirty&&a.recalculate(i,o);let[l,u]=a.extent;l===1/0&&(l=0,u=1);const h=null!==(s=r.extentPadding)&&void 0!==s?s:.05,f=u-l,d=f>0?f*h:1;return l-=d,u+=d,l>0&&(l=0),c?e.scaleLinear().domain([l,u]).range([0,t.width]):e.scaleLinear().domain([l,u]).range([t.height,0])}):[];let f=o;this.rAccessors.length>1&&(f=o.flatMap(t=>this.rAccessors.map((e,r)=>Object.assign(Object.assign({},t),{__rIndex:r,__rValue:e(t),__rName:this.resolveRAccessorName(r)})))),this.columns=this.buildColumns(f,s,u,n,t),this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(f,t),this.config.decay&&this.applyDecay(this.scene,o),this.config.pulse&&this.applyPulse(this.scene,o),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++}resolveRAccessorName(t){const e=Array.isArray(this.config.rAccessor)?this.config.rAccessor[t]:this.config.rAccessor;return"string"==typeof e?e:"value"+t}resolveCategories(t){const e=Array.from(this.categories),r=this.config.oSort;if(("streaming"===this.config.runtimeMode||this._hasStreamingData)&&void 0===r){const r=new Set;for(const e of t)r.add(this.getO(e));const i=Math.max(50,3*r.size);if(this.categories.size>i){let t=this.categories.size-i;for(const e of this.categories){if(0>=t)break;r.has(e)||(this.categories.delete(e),t--)}}return e.filter(t=>r.has(t))}if(!1===r)return e;if("function"==typeof r)return e.sort(r);const i=new Map;for(const e of t){const t=this.getO(e);i.set(t,(i.get(t)||0)+Math.abs(this.getR(e)))}return e.sort("asc"===r?(t,e)=>(i.get(t)||0)-(i.get(e)||0):(t,e)=>(i.get(e)||0)-(i.get(t)||0))}computeValueDomain(t,e){var r,i,o,n,s;const a=this.config.chartType,c=null!==(r=this.config.extentPadding)&&void 0!==r?r:.05;if("radial"===this.config.projection&&("pie"===a||"donut"===a))return[0,1];let l=0,u=0;if("bar"===a&&this.getStack&&this.config.normalize)l=0,u=1;else if("bar"===a&&this.getStack){const e=new Map,r=new Map;for(const i of t){const t=this.getO(i),o=this.getR(i);0>o?r.set(t,(r.get(t)||0)+o):e.set(t,(e.get(t)||0)+o)}for(const t of e.values())t>u&&(u=t);for(const t of r.values())l>t&&(l=t)}else if("bar"===a){const e=new Map;for(const r of t){const t=this.getO(r),i=this.getR(r);e.set(t,(e.get(t)||0)+i)}for(const t of e.values())t>u&&(u=t),l>t&&(l=t)}else if("swimlane"===a){const e=new Map;for(const r of t){const t=this.getO(r),i=Math.abs(this.getR(r));e.set(t,(e.get(t)||0)+i)}for(const t of e.values())t>u&&(u=t)}else if("clusterbar"===a||"bar-funnel"===a)for(const e of t){const t=this.getR(e);t>u&&(u=t),l>t&&(l=t)}else{const t=this.rExtent.extent[0],e=this.rExtent.extent[1];t!==1/0&&(l=t),e!==-1/0&&(u=e)}this.config.rExtent&&(null!=this.config.rExtent[0]&&(l=this.config.rExtent[0]),null!=this.config.rExtent[1]&&(u=this.config.rExtent[1]));const h="bar"===a||"clusterbar"===a||"bar-funnel"===a||"swimlane"===a;if(h&&null==(null===(i=this.config.rExtent)||void 0===i?void 0:i[0])&&null==(null===(o=this.config.rExtent)||void 0===o?void 0:o[1])&&(l>0&&(l=0),0>u&&(u=0)),"bar-funnel"!==a){const t=u-l,e=t>0?t*c:1;null!=(null===(n=this.config.rExtent)||void 0===n?void 0:n[0])||h&&!this.config.baselinePadding&&0===l||(l-=e),null!=(null===(s=this.config.rExtent)||void 0===s?void 0:s[1])||h&&!this.config.baselinePadding&&0===u||"swimlane"===a||(u+=e)}return[l,u]}buildColumns(t,e,r,i,o){var n;const s={},a=new Map;for(const e of t){const t=this.getO(e);a.has(t)||a.set(t,[]),a.get(t).push(e)}let c=0;if("radial"===i)for(const e of t)c+=Math.abs(this.getR(e));const l=this.config.dynamicColumnWidth;let u=null;if(l&&"radial"!==i){u=new Map;let t=0;for(const r of e){const e=a.get(r)||[];let i;i="string"==typeof l?e.reduce((t,e)=>t+(Number(e[l])||0),0):l(e),u.set(r,i),t+=i}const n=("horizontal"===i?o.height:o.width)-r.padding()*r.step()*e.length;if(t>0)for(const[e,r]of u)u.set(e,r/t*n)}let h=0,f=0;for(const t of e){const e=a.get(t)||[],i=e.reduce((t,e)=>t+Math.abs(this.getR(e)),0),o=c>0?i/c:0;let l,d;u?(l=f,d=u.get(t)||r.bandwidth(),f+=d+r.padding()*r.step()):(l=null!==(n=r(t))&&void 0!==n?n:0,d=r.bandwidth()),s[t]={name:t,x:l,y:0,width:d,middle:l+d/2,padding:r.padding()*r.step(),pieceData:e,pct:o,pctStart:h},h+=o}return s}getSceneContext(){return{scales:this.scales,columns:this.columns,config:this.config,getR:this.getR,getStack:this.getStack,getGroup:this.getGroup,getColor:this.getColor,getConnector:this.getConnector,getO:this.getO,multiScales:this.multiScales,rAccessors:this.rAccessors,resolvePieceStyle:(t,e)=>this.resolvePieceStyle(t,e),resolveSummaryStyle:(t,e)=>this.resolveSummaryStyle(t,e),getRawRange:t=>this.getRawRange(t)}}buildSceneNodes(t,e){if(!this.scales)return[];const r=this.getSceneContext(),i=Jt[this.config.chartType];let o=i?i(r,e):[];if(this.getConnector&&this.scales){const t=function(t,e){const{scales:r,config:i,getConnector:o,getO:n}=t;if(!o||!r)return[];const s=[],{projection:a}=r,c=new Map;for(const t of e){if("point"!==t.type&&"rect"!==t.type)continue;const e=t.datum;if(!e)continue;const r=o(e);if(!r)continue;let i,s;"point"===t.type?(i=t.x,s=t.y):(i=t.x+t.w/2,s=t.y+("vertical"===a?0:t.h/2)),c.has(r)||c.set(r,[]),c.get(r).push({x:i,y:s,datum:e,category:n(e)})}const l=r.o.domain(),u=i.connectorStyle;for(const[t,e]of c)if(e.length>=2){e.sort((t,e)=>l.indexOf(t.category)-l.indexOf(e.category));for(let r=0;e.length-1>r;r++){const i=e[r],o=e[r+1],n="function"==typeof u?u(i.datum):u||{stroke:"#999",strokeWidth:1,opacity:.5};s.push({type:"connector",x1:i.x,y1:i.y,x2:o.x,y2:o.y,style:n,datum:i.datum,group:t})}}return s}(r,o);o=[...t,...o]}return o}resolvePieceStyle(t,e){if("function"==typeof this.config.pieceStyle){const r=this.config.pieceStyle(t,e);return r&&!r.fill&&e?Object.assign(Object.assign({},r),{fill:this.getColorFromScheme(e)}):r}return this.config.pieceStyle&&"object"==typeof this.config.pieceStyle?this.config.pieceStyle:this.config.barColors&&e?{fill:this.config.barColors[e]||"#007bff"}:e?{fill:this.getColorFromScheme(e)}:{fill:"#007bff"}}getColorFromScheme(t){this._colorSchemeMap||(this._colorSchemeMap=new Map);const e=this._colorSchemeMap.get(t);if(e)return e;const r=Array.isArray(this.config.colorScheme)?this.config.colorScheme:k,i=r[this._colorSchemeIndex%r.length];return this._colorSchemeIndex++,this._colorSchemeMap.set(t,i),i}resolveSummaryStyle(t,e){return"function"==typeof this.config.summaryStyle?this.config.summaryStyle(t,e):this.config.summaryStyle&&"object"==typeof this.config.summaryStyle?this.config.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}computeDecayOpacity(t,e){const r=this.config.decay;return r&&e>1?A(r,t,e):1}applyDecay(t,e){var r,i;if(!this.config.decay)return;const o=e.length;if(1>=o)return;const n=new Map;for(let t=0;e.length>t;t++)n.set(e[t],t);for(const e of t){if("connector"===e.type||"violin"===e.type||"boxplot"===e.type||"wedge"===e.type)continue;const t=n.get(e.datum);if(null==t)continue;const s=this.computeDecayOpacity(t,o),a=null!==(i=null===(r=e.style)||void 0===r?void 0:r.opacity)&&void 0!==i?i:1;e.style=Object.assign(Object.assign({},e.style),{opacity:a*s})}}applyPulse(t,e){var r,i,o;if(!this.config.pulse||!this.timestampBuffer)return;const n="undefined"!=typeof performance?performance.now():Date.now(),s=null!==(r=this.config.pulse.duration)&&void 0!==r?r:500,a=null!==(i=this.config.pulse.color)&&void 0!==i?i:"rgba(255,255,255,0.6)",c=null!==(o=this.config.pulse.glowRadius)&&void 0!==o?o:4,l=new Map;for(let t=0;e.length>t;t++)l.set(e[t],t);for(const r of t){if("connector"===r.type||"violin"===r.type||"boxplot"===r.type)continue;if("wedge"===r.type){const t=r.category;if(!t)continue;let i=0;for(let r=0;e.length>r;r++){const o=e[r],a=this.config.oAccessor;if(("function"==typeof a?a(o):o[a||"category"])!==t)continue;const c=this.timestampBuffer.get(r);if(null==c)continue;const l=n-c;if(s>l){const t=1-l/s;t>i&&(i=t)}}i>0&&(r._pulseIntensity=i,r._pulseColor=a);continue}const t=l.get(r.datum);if(null==t)continue;const i=this.timestampBuffer.get(t);if(null==i)continue;const o=n-i;s>o&&(r._pulseIntensity=1-o/s,r._pulseColor=a,r._pulseGlowRadius=c)}}get hasActivePulses(){var t;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const e="undefined"!=typeof performance?performance.now():Date.now(),r=null!==(t=this.config.pulse.duration)&&void 0!==t?t:500,i=this.timestampBuffer.peek();return null!=i&&r>e-i}getNodeKey(t,e){var r,i;if("point"===t.type){const r=`p:${t.datum?this.getO(t.datum):""}:${t.datum?this.getR(t.datum):0}`,i=e.get(r)||0;return e.set(r,i+1),`${r}:${i}`}return"rect"===t.type?`r:${t.group||""}:${null!==(i=null===(r=t.datum)||void 0===r?void 0:r.category)&&void 0!==i?i:""}`:null}snapshotPositions(){this.prevPositionMap.clear();const t=new Map;for(let e=0;this.scene.length>e;e++){const r=this.scene[e],i=this.getNodeKey(r,t);i&&("point"===r.type?this.prevPositionMap.set(i,{x:r.x,y:r.y,r:r.r,opacity:r.style.opacity}):"rect"===r.type&&this.prevPositionMap.set(i,{x:r.x,y:r.y,w:r.w,h:r.h,opacity:r.style.opacity}))}}startTransition(){var t,e,r,i,o,n,s,a,c,l,u,h;if(!this.config.transition||0===this.prevPositionMap.size)return;const f=null!==(t=this.config.transition.duration)&&void 0!==t?t:300;if(this.exitNodes.length>0){const t=new Set(this.exitNodes);this.scene=this.scene.filter(e=>!t.has(e)),this.exitNodes=[]}let d=!1;const g=new Set,y=new Map;for(let t=0;this.scene.length>t;t++){const a=this.scene[t],c=this.getNodeKey(a,y);if(!c)continue;a._transitionKey=c;const l=this.prevPositionMap.get(c);"point"===a.type?l?(g.add(c),a._targetOpacity=null!==(e=a.style.opacity)&&void 0!==e?e:1,l.x===a.x&&l.y===a.y||(a._targetX=a.x,a._targetY=a.y,a.x=l.x,a.y=l.y,d=!0)):(a._targetOpacity=null!==(r=a.style.opacity)&&void 0!==r?r:1,a.style=Object.assign(Object.assign({},a.style),{opacity:0}),d=!0):"rect"===a.type&&(l?(g.add(c),a._targetOpacity=null!==(i=a.style.opacity)&&void 0!==i?i:1,l.x===a.x&&l.y===a.y&&l.w===a.w&&l.h===a.h||(a._targetX=a.x,a._targetY=a.y,a._targetW=a.w,a._targetH=a.h,a.x=l.x,a.y=l.y,a.w=null!==(o=l.w)&&void 0!==o?o:a.w,a.h=null!==(n=l.h)&&void 0!==n?n:a.h,d=!0)):(a._targetOpacity=null!==(s=a.style.opacity)&&void 0!==s?s:1,a.style=Object.assign(Object.assign({},a.style),{opacity:0}),d=!0))}this.exitNodes=[];for(const[t,e]of this.prevPositionMap)g.has(t)||(t.startsWith("p:")?this.exitNodes.push({type:"point",x:e.x,y:e.y,r:null!==(a=e.r)&&void 0!==a?a:3,style:{opacity:null!==(c=e.opacity)&&void 0!==c?c:1},datum:null,_targetOpacity:0,_transitionKey:t}):t.startsWith("r:")&&this.exitNodes.push({type:"rect",x:e.x,y:e.y,w:null!==(l=e.w)&&void 0!==l?l:0,h:null!==(u=e.h)&&void 0!==u?u:0,style:{opacity:null!==(h=e.opacity)&&void 0!==h?h:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t}),d=!0);this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),d&&(this.activeTransition={startTime:E(),duration:f})}advanceTransition(t){var e,r,i;if(!this.activeTransition)return!1;const o=_(t,this.activeTransition),n=S(o,"linear"===(null===(e=this.config.transition)||void 0===e?void 0:e.easing)?"linear":"ease-out-cubic");for(const t of this.scene){const e=t._transitionKey;if(e)if("point"===t.type){if(void 0!==t._targetOpacity){const i=this.prevPositionMap.get(e),o=i?null!==(r=i.opacity)&&void 0!==r?r:1:0;t.style.opacity=P(o,t._targetOpacity,n)}if(void 0===t._targetX)continue;const i=this.prevPositionMap.get(e);if(!i)continue;t.x=P(i.x,t._targetX,n),t.y=P(i.y,t._targetY,n)}else if("rect"===t.type){if(void 0!==t._targetOpacity){const r=this.prevPositionMap.get(e),o=r?null!==(i=r.opacity)&&void 0!==i?i:1:0;t.style.opacity=P(o,t._targetOpacity,n)}if(void 0===t._targetX)continue;const r=this.prevPositionMap.get(e);if(!r)continue;t.x=P(r.x,t._targetX,n),t.y=P(r.y,t._targetY,n),void 0!==r.w&&(t.w=P(r.w,t._targetW,n),t.h=P(r.h,t._targetH,n))}}if(o>=1){for(const t of this.scene)if(void 0!==t._targetOpacity&&(t.style=Object.assign(Object.assign({},t.style||{}),{opacity:0===t._targetOpacity?0:t._targetOpacity}),t._targetOpacity=void 0),"point"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t._targetX=void 0,t._targetY=void 0}else if("rect"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}if(this.exitNodes.length>0){const t=new Set(this.exitNodes);this.scene=this.scene.filter(e=>!t.has(e)),this.exitNodes=[]}return this.activeTransition=null,!1}return!0}getData(){return this.buffer.toArray()}remove(t){if(!this.getDataId)throw Error("remove() requires dataIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const e=new Set(Array.isArray(t)?t:[t]),r=this.getDataId,i=t=>e.has(r(t));if(this.timestampBuffer&&this.timestampBuffer.size>0){const t=this.timestampBuffer.toArray(),e=new Set;this.buffer.forEach((t,r)=>{i(t)&&e.add(r)}),this.timestampBuffer.clear();for(let r=0;t.length>r;r++)e.has(r)||this.timestampBuffer.push(t[r])}const o=this.buffer.remove(i);if(0===o.length)return o;for(const t of o)this.evictValueExtent(t);return this.categories.clear(),this.buffer.forEach(t=>this.categories.add(this.getO(t))),this.version++,o}update(t,e){if(!this.getDataId)throw Error("update() requires dataIdAccessor to be configured");const r=new Set(Array.isArray(t)?t:[t]),i=this.getDataId,o=new Set;this.buffer.forEach((t,e)=>{r.has(i(t))&&o.add(e)});const n=this.buffer.update(t=>r.has(i(t)),e);if(0===n.length)return n;for(const t of n)this.evictValueExtent(t);return this.categories.clear(),this.buffer.forEach((t,e)=>{this.categories.add(this.getO(t)),o.has(e)&&this.pushValueExtent(t)}),this.version++,n}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(t){const e=Object.assign({},this.config);if(t.colorScheme!==this.config.colorScheme&&(this._colorSchemeMap=null,this._colorSchemeIndex=0),Object.assign(this.config,t),(void 0!==t.oAccessor||void 0!==t.categoryAccessor)&&(m(t.oAccessor||t.categoryAccessor,e.oAccessor||e.categoryAccessor)||(this.getO=b(this.config.oAccessor||this.config.categoryAccessor,"category"),this.categories.clear())),void 0!==t.rAccessor){const r=Array.isArray(t.rAccessor)?t.rAccessor:[t.rAccessor],i=Array.isArray(e.rAccessor)?e.rAccessor:[e.rAccessor];if(r.length!==i.length||r.some((t,e)=>!m(t,i[e]))){const t=this.config.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(t=>x(t,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new y)):(this.getR=x(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in t&&!m(t.stackBy,e.stackBy)&&(this.getStack=null!=this.config.stackBy?b(this.config.stackBy):void 0),"groupBy"in t&&!m(t.groupBy,e.groupBy)&&(this.getGroup=null!=this.config.groupBy?b(this.config.groupBy):void 0),"colorAccessor"in t&&!m(t.colorAccessor,e.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?b(this.config.colorAccessor):void 0),"connectorAccessor"in t&&!m(t.connectorAccessor,e.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?b(this.config.connectorAccessor):void 0)}}const ee={mercator:u.geoMercator,equalEarth:u.geoEqualEarth,albersUsa:u.geoAlbersUsa,orthographic:u.geoOrthographic,naturalEarth:u.geoNaturalEarth1,equirectangular:u.geoEquirectangular};function re(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}function ie(t){return t?"function"==typeof t?t:e=>e[t]:t=>t.coordinates||t.data||[]}function oe(t,e,r){return t?Object.assign(Object.assign({},r),"function"==typeof t?t(e):t):r}const ne={fill:"#e0e0e0",stroke:"#999",strokeWidth:.5,fillOpacity:1},se={fill:"#4e79a7",r:4,fillOpacity:.8},ae={stroke:"#4e79a7",strokeWidth:1.5,fill:"none"};function ce(t,e){if(2>t.length)return[t];const r=.4*e,i=[];let o=[t[0]];for(let e=1;t.length>e;e++){const n=t[e];Math.abs(n[0]-t[e-1][0])>r?(2>o.length||i.push(o),o=[n]):o.push(n)}return 2>o.length||i.push(o),i}function le(t,e,r=24){const i=e[0]-t[0],o=e[1]-t[1],n=Math.sqrt(i*i+o*o);if(0===n)return[t,e];const s=-o/n,a=i/n,c=Math.min(.3*n,80),l=(t[0]+e[0])/2+s*c,u=(t[1]+e[1])/2+a*c,h=[];for(let i=0;r>=i;i++){const o=i/r,n=1-o;h.push([n*n*t[0]+2*n*o*l+o*o*e[0],n*n*t[1]+2*n*o*u+o*o*e[1]])}return h}function ue(t,e){if(2>t.length)return t;const r=e/2+1,i=[];for(let e=0;t.length>e;e++){const o=t[e];let n,s;0===e?(n=t[1][0]-o[0],s=t[1][1]-o[1]):e===t.length-1?(n=o[0]-t[e-1][0],s=o[1]-t[e-1][1]):(n=t[e+1][0]-t[e-1][0],s=t[e+1][1]-t[e-1][1]);const a=Math.sqrt(n*n+s*s)||1;i.push([o[0]+s/a*r,o[1]+-n/a*r])}return i}function he(t,e,r,i,o){const n=e[0]-t[0],s=e[1]-t[1],a=Math.sqrt(n*n+s*s);if(0===a)return[t,e];const c=s/a,l=-n/a,u=o/2+1;return[[t[0]+c*u,t[1]+l*u],[e[0]+c*u,e[1]+l*u]]}class fe{constructor(t){this.scene=[],this.scales=null,this.version=0,this.projection=null,this.geoPath=null,this.baseScale=0,this.baseTranslate=[0,0],this.baseRotation=[0,0,0],this.currentZoom=1,this.cartogramLayout=null,this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.streaming=!1,this.lastIngestTime=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositions=null,this.config=t}updateConfig(t){this.config=Object.assign(Object.assign({},this.config),t)}setAreas(t){this.areas=t}setPoints(t){this.pointData=t,this.streaming=!1}setLines(t){this.lineData=t}initStreaming(t=500){this.pointBuffer=new g(t),this.timestampBuffer=new g(t),this.streaming=!0}pushPoint(t){this.pointBuffer||this.initStreaming(),this.pointBuffer.push(t),this.timestampBuffer.push(performance.now()),this.lastIngestTime=performance.now()}pushMany(t){this.pointBuffer||this.initStreaming();const e=performance.now();for(const r of t)this.pointBuffer.push(r),this.timestampBuffer.push(e);this.lastIngestTime=e}removePoint(t){const{pointIdAccessor:e}=this.config;if(!e)throw Error("removePoint() requires pointIdAccessor to be configured");const r="function"==typeof e?e:t=>t[e],i=new Set(Array.isArray(t)?t:[t]);if(this.streaming&&this.pointBuffer){const t=t=>i.has(r(t)+"");if(this.timestampBuffer&&this.timestampBuffer.size>0){const e=this.timestampBuffer.toArray(),r=new Set;this.pointBuffer.forEach((e,i)=>{t(e)&&r.add(i)}),this.timestampBuffer.clear();for(let t=0;e.length>t;t++)r.has(t)||this.timestampBuffer.push(e[t])}const e=this.pointBuffer.remove(t);return e.length>0&&this.version++,e}{const t=[];return this.pointData=this.pointData.filter(e=>!i.has(r(e)+"")||(t.push(e),!1)),t.length>0&&this.version++,t}}clear(){this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.timestampBuffer=null,this.scene=[],this.scales=null,this.version++}computeScene(t){const{config:e}=this;this.projection=function(t){if(!t)return u.geoEqualEarth();if("string"==typeof t){const e=ee[t];return e?e():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${t}", falling back to equalEarth`),u.geoEqualEarth())}if("object"==typeof t&&"type"in t){const e=ee[t.type],r=e?e():u.geoEqualEarth();return t.rotate&&"rotate"in r&&r.rotate(t.rotate),t.center&&"center"in r&&r.center(t.center),r}return t}(e.projection),this.geoPath=u.geoPath(this.projection),this.fitProjection(t),this.geoPath=u.geoPath(this.projection);const r=this.projection;this.scales={projection:r,geoPath:this.geoPath,projectedPoint:(t,e)=>r([t,e]),invertedPoint:(t,e)=>r.invert?r.invert([t,e]):null};const i=this.scene;this.scene=this.buildSceneNodes(t),e.projectionTransform&&this.applyCartogramTransform(e.projectionTransform,t),e.decay&&this.streaming&&this.applyDecay(),e.pulse&&this.streaming&&this.applyPulse(),e.transition&&i.length>0&&this.startTransition(i),this.version++}fitProjection(t){var e,r,i,o,n;const s=this.projection,a=this.config,c=[...this.areas],l=re(a.xAccessor,"lon"),u=re(a.yAccessor,"lat"),h=this.getPoints();if(h.length>0){const t=h.map(t=>[l(t),u(t)]);c.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:t}})}const f=ie(a.lineDataAccessor);for(const t of this.lineData){const e=f(t);if(e&&e.length>0){const t=e.map(t=>[l(t),u(t)]);c.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:t}})}}if(0!==c.length){if(a.projectionExtent){const[[e,r],[i,o]]=a.projectionExtent;s.fitExtent([[0,0],[t.width,t.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[e,r],[i,r],[i,o],[e,o],[e,r]]]}})}else if(s.clipAngle&&(null!==(e=s.clipAngle())&&void 0!==e?e:0)>0){const e=null!==(r=a.fitPadding)&&void 0!==r?r:0,i=Math.min(t.width,t.height);s.scale(i/2-i*e),s.translate([t.width/2,t.height/2])}else{const e=null!==(i=a.fitPadding)&&void 0!==i?i:0,r=t.width*e,o=t.height*e;s.fitExtent([[r,o],[t.width-r,t.height-o]],{type:"FeatureCollection",features:c})}this.baseScale=s.scale(),this.baseTranslate=s.translate(),this.baseRotation=null!==(n=null===(o=s.rotate)||void 0===o?void 0:o.call(s))&&void 0!==n?n:[0,0,0]}}applyZoomTransform(t,e){const r=this.projection;r&&(r.scale(this.baseScale*t.k),r.translate([this.baseTranslate[0]*t.k+t.x,this.baseTranslate[1]*t.k+t.y]),this.currentZoom=t.k,this.geoPath=u.geoPath(r),this.scales={projection:r,geoPath:this.geoPath,projectedPoint:(t,e)=>r([t,e]),invertedPoint:(t,e)=>r.invert?r.invert([t,e]):null},this.scene=this.buildSceneNodes(e),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}applyZoomScale(t,e){const r=this.projection;r&&(r.scale(this.baseScale*t),r.translate(this.baseTranslate),this.currentZoom=t,this.geoPath=u.geoPath(r),this.scales={projection:r,geoPath:this.geoPath,projectedPoint:(t,e)=>r([t,e]),invertedPoint:(t,e)=>r.invert?r.invert([t,e]):null},this.scene=this.buildSceneNodes(e),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}applyRotation(t,e){const r=this.projection;r&&r.rotate&&(r.rotate(t),this.geoPath=u.geoPath(r),this.scales={projection:r,geoPath:this.geoPath,projectedPoint:(t,e)=>r([t,e]),invertedPoint:(t,e)=>r.invert?r.invert([t,e]):null},this.scene=this.buildSceneNodes(e),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}setRotation(t){const e=this.projection;e&&e.rotate&&e.rotate(t)}getRotation(){var t,e,r;return null!==(r=null===(e=null===(t=this.projection)||void 0===t?void 0:t.rotate)||void 0===e?void 0:e.call(t))&&void 0!==r?r:this.baseRotation}getBaseProjectionState(){return{scale:this.baseScale,translate:[...this.baseTranslate]}}getPoints(){return this.streaming&&this.pointBuffer?this.pointBuffer.toArray():this.pointData}buildSceneNodes(t){var e,r,i;const o=[],{config:n}=this,s=this.projection,a=this.geoPath,c=re(n.xAccessor,"lon"),l=re(n.yAccessor,"lat");if(n.graticule){const e=!0===n.graticule?{}:n.graticule,r=u.geoGraticule();e.step&&r.step(e.step);const i=a(r())||"";i&&o.push({type:"geoarea",pathData:i,centroid:[t.width/2,t.height/2],bounds:[[0,0],[t.width,t.height]],screenArea:0,style:{fill:"none",stroke:e.stroke||"#e0e0e0",strokeWidth:e.strokeWidth||.5,strokeDasharray:e.strokeDasharray||"2,2"},datum:null,interactive:!1})}for(const t of this.areas){const e=a(t);if(!e)continue;const r=a.centroid(t),i=a.bounds(t),s=a.area(t),c=oe(n.areaStyle,t,ne);o.push({type:"geoarea",pathData:e,centroid:r,bounds:i,screenArea:s,style:c,datum:t,interactive:!0})}const h=ie(n.lineDataAccessor);for(const e of this.lineData){const r=h(e);if(!r||2>r.length)continue;const i=r.map(t=>[c(t),l(t)]);let a;if("geo"===n.lineType){const t=[];for(let e=0;i.length-1>e;e++){const r=i[e],o=i[e+1],n=u.geoDistance(r,o)||0,s=Math.max(2,Math.ceil(n/(Math.PI/180))),a=u.geoInterpolate(r,o);for(let r=0;s>=r;r++)e>0&&0===r||t.push(a(r/s))}a=t.map(([t,e])=>s([t,e])).filter(t=>null!=t)}else a=i.map(([t,e])=>s([t,e])).filter(t=>null!=t);if(2>a.length)continue;const f=oe(n.lineStyle,e,ae),d="number"==typeof f.strokeWidth?f.strokeWidth:1;2!==i.length||2>a.length||"arc"!==n.flowStyle?2!==i.length||2>a.length||"offset"!==n.flowStyle||(a="geo"===n.lineType?ue(a,d):he(a[0],a[a.length-1],0,0,d)):a=le(a[0],a[a.length-1]);const g=ce(a,t.width);if(g.length>1)for(const t of g){if(2>t.length)continue;const r={type:"line",path:t,style:Object.assign(Object.assign({},f),{_edgeFade:!0}),datum:e};o.push(r)}else o.push({type:"line",path:2>a.length&&g[0]||a,style:f,datum:e})}const f=this.getPoints(),d=n.pointIdAccessor?"function"==typeof n.pointIdAccessor?n.pointIdAccessor:t=>t[n.pointIdAccessor]:null,g=s.clipAngle&&null!==(e=s.clipAngle())&&void 0!==e?e:0,y=g>0?g*Math.PI/180:null,p=s.rotate?s.rotate():[0,0,0],m="function"==typeof s.center?s.center():[0,0],x=[(null!==(r=m[0])&&void 0!==r?r:0)-p[0],(null!==(i=m[1])&&void 0!==i?i:0)-p[1]];for(let t=0;f.length>t;t++){const e=f[t],r=c(e),i=l(e);if(null!=y&&u.geoDistance([r,i],x)>y)continue;const a=s([r,i]);if(!a)continue;const h=n.pointStyle?n.pointStyle(e):Object.assign({},se),g={type:"point",x:a[0],y:a[1],r:h.r||4,style:h,datum:e,pointId:d?d(e)+"":void 0};o.push(g)}return o}applyCartogramTransform(t,r){var i,o,n;const s=this.scene.filter(t=>"point"===t.type);if(2>s.length)return;const a=null!==(i=t.strength)&&void 0!==i?i:1;if(0===a)return;const c=t.centerAccessor?"function"==typeof t.centerAccessor?t.centerAccessor:e=>e[t.centerAccessor]:t=>t.id,l="function"==typeof t.costAccessor?t.costAccessor:e=>e[t.costAccessor],u=s.find(e=>c(e.datum)+""==t.center+"");if(!u)return void("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${t.center}" not found in point data`));const h=u.x,f=u.y,d=s.map(t=>l(t.datum)).filter(t=>isFinite(t)&&t>=0),g=Math.max(...d,1),y=Math.min(r.width,r.height)/2,p=e.scaleLinear().domain([0,g]).range([0,y]);this.cartogramLayout={cx:h,cy:f,maxCost:g,availableRadius:y},this.areas.length>0&&"production"!==process.env.NODE_ENV&&console.warn("GeoFrame: Distance cartogram does not support area rendering. Areas will be ignored. Remove areas or set projectionTransform to null to render them."),this.scene=this.scene.filter(t=>"geoarea"!==t.type||!t.interactive);for(const t of s){if(t===u)continue;const e=Math.atan2(t.y-f,t.x-h),r=Math.sqrt(Math.pow(t.x-h,2)+Math.pow(t.y-f,2)),i=l(t.datum),o=r+((isFinite(i)?p(i):r)-r)*a;t.x=h+Math.cos(e)*o,t.y=f+Math.sin(e)*o}const m=r.width/2,x=r.height/2,v=m-u.x,b=x-u.y;if(Math.abs(v)>.5||Math.abs(b)>.5)for(const t of s)t.x+=v,t.y+=b;this.cartogramLayout={cx:m,cy:x,maxCost:g,availableRadius:y};const k=this.scene.filter(t=>"line"===t.type);if(k.length>0&&"fractional"!==t.lineMode){const t=new Map;for(const e of s)e.pointId&&t.set(e.pointId,[e.x,e.y]);for(const e of k){const r=null===(o=e.datum)||void 0===o?void 0:o.source,i=null===(n=e.datum)||void 0===n?void 0:n.target;if(r&&i){const o=t.get(r+""),n=t.get(i+"");o&&n&&(e.path=[o,n])}}}}applyDecay(){const t=this.config.decay;if(!t||!this.pointBuffer)return;const e=this.pointBuffer.size;if(0===e)return;const r=this.scene.filter(t=>"point"===t.type);for(let i=0;r.length>i;i++){const o=A(t,i,e);r[i]._decayOpacity=o,r[i].style=Object.assign(Object.assign({},r[i].style),{opacity:o})}}applyPulse(){var t,e;const r=this.config.pulse;if(!r||!this.timestampBuffer)return;const i=null!==(t=r.duration)&&void 0!==t?t:500,o=performance.now(),n=this.scene.filter(t=>"point"===t.type),s=this.timestampBuffer.toArray();for(let t=0;n.length>t&&s.length>t;t++){const a=o-s[t];i>a&&(n[t]._pulseIntensity=1-a/i,n[t]._pulseColor=r.color||"rgba(255,255,255,0.6)",n[t]._pulseGlowRadius=null!==(e=r.glowRadius)&&void 0!==e?e:4)}}get hasActivePulses(){var t,e;if(!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const r=null!==(e=null===(t=this.config.pulse)||void 0===t?void 0:t.duration)&&void 0!==e?e:500,i=this.timestampBuffer.toArray()[this.timestampBuffer.size-1];return performance.now()-i<r}startTransition(t){var e,r;const i=null!==(r=null===(e=this.config.transition)||void 0===e?void 0:e.duration)&&void 0!==r?r:300;if(0>=i)return;const o=new Map;for(const e of t)"point"===e.type&&e.pointId&&o.set(e.pointId,[e.x,e.y]);const n=this.scene.filter(t=>"point"===t.type);let s=!1;for(const t of n)if(t.pointId){const e=o.get(t.pointId);e&&(t._targetX=t.x,t._targetY=t.y,t.x=e[0],t.y=e[1],(Math.abs(e[0]-t._targetX)>.5||Math.abs(e[1]-t._targetY)>.5)&&(s=!0))}s&&(this.activeTransition={startTime:performance.now(),duration:i})}advanceTransition(t){if(!this.activeTransition)return!1;const e=_(t,this.activeTransition),r=S(e),i=this.scene.filter(t=>"point"===t.type);for(const t of i)if(null!=t._targetX&&null!=t._targetY){const e=t.y;t.x=P(t.x,t._targetX,r),t.y=P(e,t._targetY,r)}if(e>=1){for(const t of i)null!=t._targetX&&(t.x=t._targetX,t.y=t._targetY,t._targetX=void 0,t._targetY=void 0);return this.activeTransition=null,!1}return!0}}function de(t,e="#4e79a7"){return t&&"string"==typeof t?t:e}function ge(t,e){var r,i,o;switch(t.type){case"line":{const r=t;if(0===r.path.length)return null;const i="M"+r.path.map(([t,e])=>`${t},${e}`).join("L");return f.createElement("path",{key:"line-"+e,d:i,fill:"none",stroke:r.style.stroke||"#4e79a7",strokeWidth:r.style.strokeWidth||2,strokeDasharray:r.style.strokeDasharray,opacity:r.style.opacity})}case"area":{const o=t;if(0===o.topPath.length)return null;const n=o.topPath.map(([t,e])=>`${t},${e}`).join("L"),s=[...o.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L");return f.createElement("path",{key:"area-"+e,d:`M${n}L${s}Z`,fill:de(o.style.fill),fillOpacity:null!==(i=null!==(r=o.style.fillOpacity)&&void 0!==r?r:o.style.opacity)&&void 0!==i?i:.7,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})}case"point":{const r=t;return f.createElement("circle",{key:"point-"+e,cx:r.x,cy:r.y,r:r.r,fill:de(r.style.fill),opacity:null!==(o=r.style.opacity)&&void 0!==o?o:.8,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})}case"rect":{const r=t;return f.createElement("rect",{key:"rect-"+e,x:r.x,y:r.y,width:r.w,height:r.h,fill:de(r.style.fill),opacity:r.style.opacity,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})}case"heatcell":{const r=t;if(r.showValues&&null!=r.value&&r.w>=20&&r.h>=20){const t=r.valueFormat?r.valueFormat(r.value):Number.isInteger(r.value)?r.value+"":100>Math.abs(r.value)?1>Math.abs(r.value)?r.value.toPrecision(3):r.value.toFixed(1):r.value.toFixed(0),[i,o,n]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(r.fill),s=.299*i+.587*o+.114*n>128?"#000":"#fff",a=Math.max(10,Math.min(16,.3*Math.min(r.w,r.h)));return f.createElement("g",{key:"heatcell-"+e},f.createElement("rect",{x:r.x,y:r.y,width:r.w,height:r.h,fill:r.fill}),f.createElement("text",{x:r.x+r.w/2,y:r.y+r.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:s,fontSize:a+"px"},t))}return f.createElement("rect",{key:"heatcell-"+e,x:r.x,y:r.y,width:r.w,height:r.h,fill:r.fill})}case"candlestick":{const r=t,i=Math.min(r.openY,r.closeY),o=Math.max(Math.abs(r.openY-r.closeY),1),n=r.isUp?r.upColor:r.downColor;return f.createElement("g",{key:"candle-"+e},f.createElement("line",{x1:r.x,y1:r.highY,x2:r.x,y2:r.lowY,stroke:r.wickColor,strokeWidth:r.wickWidth}),f.createElement("rect",{x:r.x-r.bodyWidth/2,y:i,width:r.bodyWidth,height:o,fill:n,stroke:n,strokeWidth:1}))}default:return null}}function ye(t,e){var r,i,o,n,s;const a=("category"in t?t.category:void 0)||("group"in t?t.group:void 0)||"",l=r=>`ord-${t.type}-${a}-${e}-${r}`,u=`ord-${t.type}-${a}-${e}`;switch(t.type){case"rect":{const e=t;if(e.roundedTop&&e.roundedTop>0){const t=Math.min(e.roundedTop,e.w/2,e.h/2),{x:r,y:i,w:o,h:n}=e;let s;switch(e.roundedEdge){case"right":s=`M${r},${i} L${r+o-t},${i} A${t},${t} 0 0 1 ${r+o},${i+t} L${r+o},${i+n-t} A${t},${t} 0 0 1 ${r+o-t},${i+n} L${r},${i+n} Z`;break;case"left":s=`M${r+o},${i} L${r+t},${i} A${t},${t} 0 0 0 ${r},${i+t} L${r},${i+n-t} A${t},${t} 0 0 0 ${r+t},${i+n} L${r+o},${i+n} Z`;break;case"bottom":s=`M${r},${i} L${r+o},${i} L${r+o},${i+n-t} A${t},${t} 0 0 1 ${r+o-t},${i+n} L${r+t},${i+n} A${t},${t} 0 0 1 ${r},${i+n-t} Z`;break;default:s=`M${r},${i+n} L${r},${i+t} A${t},${t} 0 0 1 ${r+t},${i} L${r+o-t},${i} A${t},${t} 0 0 1 ${r+o},${i+t} L${r+o},${i+n} Z`}return f.createElement("path",{key:u,d:s,fill:de(e.style.fill),opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth})}return f.createElement("rect",{key:u,x:e.x,y:e.y,width:e.w,height:e.h,fill:de(e.style.fill),opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth})}case"point":{const e=t;return f.createElement("circle",{key:u,cx:e.x,cy:e.y,r:e.r,fill:de(e.style.fill),opacity:null!==(r=e.style.opacity)&&void 0!==r?r:.8,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth})}case"wedge":{const e=t,r=c.arc().innerRadius(e.innerRadius).outerRadius(e.outerRadius).startAngle(e.startAngle+Math.PI/2).endAngle(e.endAngle+Math.PI/2);e.cornerRadius&&r.cornerRadius(e.cornerRadius);const i=r({})||"";return f.createElement("path",{key:u,d:i,transform:`translate(${e.cx},${e.cy})`,fill:de(e.style.fill),stroke:e.style.stroke,strokeWidth:e.style.strokeWidth,opacity:e.style.opacity})}case"boxplot":{const e=t,r=e.columnWidth/2;return"vertical"===e.projection?f.createElement("g",{key:u},f.createElement("line",{x1:e.x,y1:e.minPos,x2:e.x,y2:e.maxPos,stroke:e.style.stroke||"#333",strokeWidth:1}),f.createElement("rect",{x:e.x-r,y:Math.min(e.q1Pos,e.q3Pos),width:e.columnWidth,height:Math.abs(e.q3Pos-e.q1Pos),fill:de(e.style.fill),fillOpacity:null!==(i=e.style.fillOpacity)&&void 0!==i?i:.6,stroke:e.style.stroke||"#333",strokeWidth:1}),f.createElement("line",{x1:e.x-r,y1:e.medianPos,x2:e.x+r,y2:e.medianPos,stroke:e.style.stroke||"#333",strokeWidth:2}),f.createElement("line",{x1:e.x-.5*r,y1:e.minPos,x2:e.x+.5*r,y2:e.minPos,stroke:e.style.stroke||"#333",strokeWidth:1}),f.createElement("line",{x1:e.x-.5*r,y1:e.maxPos,x2:e.x+.5*r,y2:e.maxPos,stroke:e.style.stroke||"#333",strokeWidth:1})):f.createElement("g",{key:u},f.createElement("line",{x1:e.minPos,y1:e.y,x2:e.maxPos,y2:e.y,stroke:e.style.stroke||"#333",strokeWidth:1}),f.createElement("rect",{x:Math.min(e.q1Pos,e.q3Pos),y:e.y-r,width:Math.abs(e.q3Pos-e.q1Pos),height:e.columnWidth,fill:de(e.style.fill),fillOpacity:null!==(o=e.style.fillOpacity)&&void 0!==o?o:.6,stroke:e.style.stroke||"#333",strokeWidth:1}),f.createElement("line",{x1:e.medianPos,y1:e.y-r,x2:e.medianPos,y2:e.y+r,stroke:e.style.stroke||"#333",strokeWidth:2}),f.createElement("line",{x1:e.minPos,y1:e.y-.5*r,x2:e.minPos,y2:e.y+.5*r,stroke:e.style.stroke||"#333",strokeWidth:1}),f.createElement("line",{x1:e.maxPos,y1:e.y-.5*r,x2:e.maxPos,y2:e.y+.5*r,stroke:e.style.stroke||"#333",strokeWidth:1}))}case"violin":{const e=t,r=[f.createElement("path",{key:l("path"),d:e.pathString,transform:e.translateX||e.translateY?`translate(${e.translateX},${e.translateY})`:void 0,fill:de(e.style.fill),fillOpacity:null!==(n=e.style.fillOpacity)&&void 0!==n?n:.6,stroke:e.style.stroke||"#333",strokeWidth:e.style.strokeWidth||1})];if(e.iqrLine&&e.bounds){const t=e.bounds,i=t.x+t.width/2,o=t.y+t.height/2;t.height>t.width?r.push(f.createElement("line",{key:l("iqr"),x1:i,y1:e.iqrLine.q1Pos,x2:i,y2:e.iqrLine.q3Pos,stroke:e.style.stroke||"#333",strokeWidth:2}),f.createElement("circle",{key:l("med"),cx:i,cy:e.iqrLine.medianPos,r:3,fill:"white",stroke:e.style.stroke||"#333",strokeWidth:1})):r.push(f.createElement("line",{key:l("iqr"),x1:e.iqrLine.q1Pos,y1:o,x2:e.iqrLine.q3Pos,y2:o,stroke:e.style.stroke||"#333",strokeWidth:2}),f.createElement("circle",{key:l("med"),cx:e.iqrLine.medianPos,cy:o,r:3,fill:"white",stroke:e.style.stroke||"#333",strokeWidth:1}))}return f.createElement("g",{key:u},r)}case"connector":return f.createElement("line",{key:u,x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.stroke||"#999",strokeWidth:t.style.strokeWidth||1,opacity:null!==(s=t.style.opacity)&&void 0!==s?s:.5});case"trapezoid":{const e=t,r=e.points.map(t=>`${t[0]},${t[1]}`).join(" ");return f.createElement("polygon",{key:u,points:r,fill:de(e.style.fill,"#999"),opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth})}default:return null}}const pe={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}},me={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}},xe={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"};t.createContext(null),function(t){const e=new EventTarget;let r=t(function(t){r=Object.assign(Object.assign({},r),t(r)),e.dispatchEvent(new CustomEvent("update"))})}(t=>({theme:pe,setTheme(e){t(t=>{if("light"===e)return{theme:pe};if("dark"===e)return{theme:me};if("high-contrast"===e)return{theme:xe};if(e.mode&&"auto"!==e.mode){const t="dark"===e.mode?me:pe;return{theme:Object.assign(Object.assign(Object.assign({},t),e),{colors:Object.assign(Object.assign({},t.colors),e.colors||{}),typography:Object.assign(Object.assign({},t.typography),e.typography||{})})}}return{theme:Object.assign(Object.assign(Object.assign({},t.theme),e),{colors:Object.assign(Object.assign({},t.theme.colors),e.colors||{}),typography:Object.assign(Object.assign({},t.theme.typography),e.typography||{})})}})}}));const ve={light:pe,dark:me,"high-contrast":xe,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 be(t){if(!t)return pe;if("string"==typeof t){if("light"===t)return pe;if("dark"===t)return me;if("high-contrast"===t)return xe;return ve[t]||pe}const e="dark"===t.mode?me:pe;return 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||{}),tooltip:Object.assign(Object.assign({},e.tooltip),t.tooltip||{})})}function ke(t){var e,r,i,o;return{background:t.colors.background,text:t.colors.text,textSecondary:t.colors.textSecondary,grid:t.colors.grid,border:t.colors.border,primary:t.colors.primary,fontFamily:t.typography.fontFamily,titleSize:t.typography.titleSize,labelSize:t.typography.labelSize,tickSize:t.typography.tickSize,categorical:t.colors.categorical,annotation:null!==(e=t.colors.annotation)&&void 0!==e?e:t.colors.text,legendSize:null!==(r=t.typography.legendSize)&&void 0!==r?r:t.typography.labelSize,titleFontSize:null!==(i=t.typography.titleFontSize)&&void 0!==i?i:t.typography.titleSize,tickFontFamily:null!==(o=t.typography.tickFontFamily)&&void 0!==o?o:t.typography.fontFamily}}function Ae(t){const{categories:r,colorScheme:o,theme:n,position:s="right",totalWidth:a,totalHeight:c,margin:l,hasTitle:u=!1}=t;if(!r||0===r.length)return null;const h=function(t,r,o){const n=Array.isArray(r)?r:o.colors.categorical.length>0?o.colors.categorical:i.schemeCategory10;return e.scaleOrdinal().domain(t).range(n)}(r,o,n),d="top"===s||"bottom"===s;let g,y;if("left"===s?(g=4,y=l.top):"top"===s?(g=l.left,y=u?32:8):"bottom"===s?(g=l.left,y=Math.min(c-l.bottom+38,c-16)):(g=a-l.right+10,y=l.top),d){let t=0;const e=r.map((e,r)=>{const i=t;return t+=22+6.5*e.length+8,f.createElement("g",{key:"legend-"+r,transform:`translate(${i},0)`},f.createElement("rect",{width:14,height:14,fill:h(e),rx:2}),f.createElement("text",{x:20,y:7,dominantBaseline:"central",fontSize:n.typography.tickSize,fill:n.colors.text,fontFamily:n.typography.fontFamily},e))});return f.createElement("g",{className:"semiotic-legend",transform:`translate(${g},${y})`},e)}const p=r.map((t,e)=>f.createElement("g",{key:"legend-"+e,transform:`translate(0,${20*e})`},f.createElement("rect",{width:14,height:14,fill:h(t),rx:2}),f.createElement("text",{x:20,y:7,dominantBaseline:"central",fontSize:n.typography.tickSize,fill:n.colors.text,fontFamily:n.typography.fontFamily},t)));return f.createElement("g",{className:"semiotic-legend",transform:`translate(${g},${y})`},p)}function we(t,e){if(!e||!t||0===t.length)return[];const r="function"==typeof e?e:t=>t[e],i=new Set;for(const e of t){const t=r(e);null!=t&&i.add(t+"")}return Array.from(i)}function Se(t,e){return t.color||e.colors.annotation||e.colors.text}function _e(t){const{annotations:e}=t;if(!e||0===e.length)return null;const r=[];for(let i=0;e.length>i;i++){const o=Pe(e[i],i,t);o&&r.push(o)}return r.length>0?f.createElement("g",{id:(t.idPrefix?t.idPrefix+"-":"")+"annotations",className:"semiotic-annotations"},r):null}function Pe(t,e,r){var i,o,n,s;const{scales:a,layout:c,theme:l,xAccessor:u,yAccessor:h}=r;switch(t.type){case"y-threshold":{const o=t.value;if(null==o)return null;const n=Se(t,l),s=t.label,u=t.labelPosition||"right",h=t.strokeDasharray||"6,4",d=null!==(i=t.strokeWidth)&&void 0!==i?i:1.5;if("horizontal"===r.projection&&a.r){const t=a.r(o);return null==t?null:f.createElement("g",{key:"ann-ythresh-"+e},f.createElement("line",{x1:t,y1:0,x2:t,y2:c.height,stroke:n,strokeWidth:d,strokeDasharray:h}),s&&f.createElement("text",{x:t+4,y:12,textAnchor:"start",fontSize:l.typography.tickSize,fill:n,fontFamily:l.typography.fontFamily},s))}const g=a.y?a.y(o):a.r?a.r(o):null;return null==g?null:f.createElement("g",{key:"ann-ythresh-"+e},f.createElement("line",{x1:0,y1:g,x2:c.width,y2:g,stroke:n,strokeWidth:d,strokeDasharray:h}),s&&f.createElement("text",{x:"left"===u?4:"center"===u?c.width/2:c.width-4,y:g-6,textAnchor:"left"===u?"start":"center"===u?"middle":"end",fontSize:l.typography.tickSize,fill:n,fontFamily:l.typography.fontFamily},s))}case"x-threshold":{const r=t.value;if(null==r||!a.x)return null;const i=a.x(r);if(null==i)return null;const n=Se(t,l),s=t.label,u=t.labelPosition||"top",h=null!==(o=t.strokeWidth)&&void 0!==o?o:1.5;return f.createElement("g",{key:"ann-xthresh-"+e},f.createElement("line",{x1:i,y1:0,x2:i,y2:c.height,stroke:n,strokeWidth:h,strokeDasharray:t.strokeDasharray||"6,4"}),s&&f.createElement("text",{x:i+4,y:"bottom"===u?c.height-4:"center"===u?c.height/2:12,textAnchor:"start",fontSize:l.typography.tickSize,fill:n,fontFamily:l.typography.fontFamily},s))}case"band":{const r=null!=t.y0&&a.y?a.y(t.y0):null,i=null!=t.y1&&a.y?a.y(t.y1):null;if(null==r||null==i)return null;const o=Math.min(r,i),s=Math.abs(i-r),u=t.fill||Se(t,l),h=null!==(n=t.opacity)&&void 0!==n?n:.1;return f.createElement("g",{key:"ann-band-"+e},f.createElement("rect",{x:0,y:o,width:c.width,height:s,fill:u,opacity:h}),t.label&&f.createElement("text",{x:c.width-4,y:o+12,textAnchor:"end",fontSize:l.typography.tickSize,fill:u,fontFamily:l.typography.fontFamily},t.label))}case"category-highlight":{if(!t.category||!a.o)return null;const i=a.o(t.category);if(null==i)return null;const o=a.o.bandwidth?a.o.bandwidth():40,n=Se(t,l),u=null!==(s=t.opacity)&&void 0!==s?s:.1;return f.createElement("rect","horizontal"===r.projection?{key:"ann-cathighlight-"+e,x:0,y:i,width:c.width,height:o,fill:n,opacity:u}:{key:"ann-cathighlight-"+e,x:i,y:0,width:o,height:c.height,fill:n,opacity:u})}case"label":case"text":{const r=function(t,e,r){return null!=t.x&&e.x?e.x(t.x):r&&null!=t[r]&&e.x?e.x(t[r]):null}(t,a,u),i=function(t,e,r){return null!=t.y&&e.y?e.y(t.y):r&&null!=t[r]&&e.y?e.y(t[r]):null}(t,a,h);if(null==r||null==i)return null;const o=t.dx||0,n=t.dy||0,s=t.color||l.colors.text;return f.createElement("g",{key:"ann-label-"+e},"label"===t.type&&f.createElement("line",{x1:r,y1:i,x2:r+o,y2:i+n,stroke:l.colors.textSecondary,strokeWidth:1}),f.createElement("text",{x:r+o,y:i+n,textAnchor:t.textAnchor||"start",fontSize:t.fontSize||l.typography.labelSize,fill:s,fontFamily:l.typography.fontFamily,fontWeight:t.fontWeight},t.label||t.title))}default:return null}}const Ee={Sparkline:{frameType:"xy",buildProps:(t,e,r,i,o)=>Object.assign(Object.assign({chartType:"line",data:t,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",groupAccessor:o.lineBy||e,colorAccessor:e},i),{showAxes:!1,margin:i.margin||{top:2,right:2,bottom:2,left:2},showLegend:!1,showGrid:!1,title:void 0})},LineChart:{frameType:"xy",buildProps:(t,e,r,i,o)=>Object.assign({chartType:"line",data:t,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",groupAccessor:o.lineBy||e,colorAccessor:e,colorScheme:r,lineStyle:o.lineStyle},i)},AreaChart:{frameType:"xy",buildProps:(t,e,r,i,o)=>Object.assign({chartType:"area",data:t,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",y0Accessor:o.y0Accessor,groupAccessor:o.areaBy||e,colorAccessor:e,colorScheme:r},i)},StackedAreaChart:{frameType:"xy",buildProps:(t,e,r,i,o)=>Object.assign({chartType:"stackedarea",data:t,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",groupAccessor:o.areaBy,colorAccessor:e||o.areaBy,colorScheme:r,normalize:o.normalize},i)},Scatterplot:{frameType:"xy",buildProps:(t,e,r,i,o)=>Object.assign({chartType:"scatter",data:t,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",colorAccessor:e,sizeAccessor:o.sizeBy,colorScheme:r},i)},BubbleChart:{frameType:"xy",buildProps:(t,e,r,i,o)=>Object.assign({chartType:"scatter",data:t,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",colorAccessor:e,sizeAccessor:o.sizeBy,sizeRange:o.sizeRange||[5,40],colorScheme:r},i)},ConnectedScatterplot:{frameType:"xy",buildProps:(t,e,r,i,o)=>Object.assign({chartType:"line",data:t,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",colorAccessor:e,colorScheme:r,showPoints:!0},i)},Heatmap:{frameType:"xy",buildProps:(t,e,r,i,o)=>Object.assign({chartType:"heatmap",data:t,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",valueAccessor:o.valueAccessor,colorScheme:r||o.colorScheme||"blues",showValues:o.showValues,cellBorderColor:o.cellBorderColor},i)},BarChart:{frameType:"ordinal",buildProps:(t,e,r,i,o)=>{var n;return Object.assign(Object.assign({chartType:"bar",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"horizontal"===o.orientation?"horizontal":"vertical",oSort:null!==(n=o.sort)&&void 0!==n&&n,colorAccessor:e,colorScheme:r,barPadding:o.barPadding},null!=o.roundedTop&&{roundedTop:o.roundedTop}),i)}},StackedBarChart:{frameType:"ordinal",buildProps:(t,e,r,i,o)=>{var n;return Object.assign(Object.assign({chartType:"bar",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",stackBy:o.stackBy,colorAccessor:e||o.stackBy,colorScheme:r,projection:"horizontal"===o.orientation?"horizontal":"vertical",normalize:o.normalize,oSort:null!==(n=o.sort)&&void 0!==n&&n},null!=o.roundedTop&&{roundedTop:o.roundedTop}),i)}},GroupedBarChart:{frameType:"ordinal",buildProps:(t,e,r,i,o)=>{var n;return Object.assign(Object.assign({chartType:"clusterbar",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",groupBy:o.groupBy,colorAccessor:e||o.groupBy,colorScheme:r,projection:"horizontal"===o.orientation?"horizontal":"vertical",oSort:null!==(n=o.sort)&&void 0!==n&&n,barPadding:o.barPadding},null!=o.roundedTop&&{roundedTop:o.roundedTop}),i)}},PieChart:{frameType:"ordinal",buildProps:(t,e,r,i,o)=>Object.assign(Object.assign({chartType:"pie",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"radial",colorAccessor:e||o.categoryAccessor,colorScheme:r},null!=o.cornerRadius&&{cornerRadius:o.cornerRadius}),i)},DonutChart:{frameType:"ordinal",buildProps:(t,e,r,i,o)=>Object.assign(Object.assign({chartType:"donut",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"radial",innerRadius:o.innerRadius||60,colorAccessor:e||o.categoryAccessor,colorScheme:r},null!=o.cornerRadius&&{cornerRadius:o.cornerRadius}),i)},Histogram:{frameType:"ordinal",buildProps:(t,e,r,i,o)=>Object.assign({chartType:"histogram",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"horizontal",bins:o.bins,colorAccessor:e,colorScheme:r},i)},BoxPlot:{frameType:"ordinal",buildProps:(t,e,r,i,o)=>Object.assign({chartType:"boxplot",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",colorScheme:r},i)},ViolinPlot:{frameType:"ordinal",buildProps:(t,e,r,i,o)=>Object.assign({chartType:"violin",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",bins:o.bins,colorScheme:r},i)},SwarmPlot:{frameType:"ordinal",buildProps:(t,e,r,i,o)=>Object.assign({chartType:"swarm",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",colorAccessor:e,colorScheme:r},i)},DotPlot:{frameType:"ordinal",buildProps:(t,e,r,i,o)=>{var n;return Object.assign(Object.assign({chartType:"point",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",colorAccessor:e,colorScheme:r},i),{showGrid:null===(n=i.showGrid)||void 0===n||n})}},SwimlaneChart:{frameType:"ordinal",buildProps:(t,e,r,i,o)=>Object.assign({chartType:"swimlane",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",stackBy:o.subcategoryAccessor,colorAccessor:e||o.subcategoryAccessor,categoryAccessor:o.categoryAccessor,subcategoryAccessor:o.subcategoryAccessor,colorScheme:r,projection:"horizontal"===o.orientation?"horizontal":"vertical"},i)},RidgelinePlot:{frameType:"ordinal",buildProps:(t,e,r,i,o)=>Object.assign({chartType:"ridgeline",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",bins:o.bins,amplitude:o.amplitude},i)},LikertChart:{frameType:"ordinal",buildProps:(t,e,r,i,o)=>Object.assign({chartType:"bar",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",stackBy:o.levelAccessor||"level",colorAccessor:e||o.levelAccessor||"level",colorScheme:r,normalize:!0,projection:"vertical"===o.orientation?"vertical":"horizontal"},i)},FunnelChart:{frameType:"ordinal",buildProps:(t,e,r,i,o)=>{const n="vertical"===o.orientation;return Object.assign({chartType:n?"bar-funnel":"funnel",data:t,oAccessor:o.stepAccessor||"step",rAccessor:o.valueAccessor||"value",colorAccessor:e||o.categoryAccessor,categoryAccessor:o.categoryAccessor,projection:n?"vertical":"horizontal",connectorAccessor:o.connectorAccessor,connectorStyle:o.connectorStyle,colorScheme:r},i)}},GaugeChart:{frameType:"ordinal",buildProps:(t,e,r,i,o)=>{var n,s,a,c;const l=null!==(n=o.min)&&void 0!==n?n:0,u=null!==(s=o.max)&&void 0!==s?s:100,h=null!==(a=o.sweep)&&void 0!==a?a:240,f=null!==(c=o.arcWidth)&&void 0!==c?c:.3,d=180+(360-h)/2,g=o.thresholds||[{value:u,color:"#4e79a7"}],y=g.map((t,e)=>({category:t.label||"zone-"+e,value:t.value-(e>0?g[e-1].value:l)})),p={};g.forEach((t,e)=>{p[t.label||"zone-"+e]=t.color||"#4e79a7"});const m=i.margin||{top:20,right:20,bottom:30,left:40},[x,v]=i.size||[300,300];return Object.assign(Object.assign({chartType:"donut",data:y,oAccessor:"category",rAccessor:"value",projection:"radial",innerRadius:Math.max(10,Math.min(x-(m.left||0)-(m.right||0),v-(m.top||0)-(m.bottom||0))/2*(1-f)),sweepAngle:h,startAngle:d,oSort:!1,pieceStyle:(t,e)=>({fill:p[e||""]||"#4e79a7"})},i),{showAxes:!1,__gauge:{gMin:l,gMax:u,sweep:h,arcWidth:f,value:o.value,startAngleDeg:d,thresholds:g}})}},ForceDirectedGraph:{frameType:"network",buildProps:(t,e,r,i,o)=>Object.assign({chartType:"force",nodes:o.nodes,edges:o.edges,nodeIDAccessor:o.nodeIDAccessor,sourceAccessor:o.sourceAccessor,targetAccessor:o.targetAccessor,colorBy:e,colorScheme:r,iterations:o.iterations,forceStrength:o.forceStrength,showLabels:o.showLabels,nodeLabel:o.nodeLabel,nodeSize:o.nodeSize,nodeSizeRange:o.nodeSizeRange,nodeStyle:o.nodeStyle,edgeStyle:o.edgeStyle},i)},SankeyDiagram:{frameType:"network",buildProps:(t,e,r,i,o)=>Object.assign({chartType:"sankey",nodes:o.nodes,edges:o.edges,nodeIDAccessor:o.nodeIdAccessor||o.nodeIDAccessor,sourceAccessor:o.sourceAccessor,targetAccessor:o.targetAccessor,valueAccessor:o.valueAccessor,orientation:o.orientation,nodeAlign:o.nodeAlign,nodeWidth:o.nodeWidth,nodePaddingRatio:o.nodePaddingRatio,showLabels:o.showLabels,nodeLabel:o.nodeLabel,colorBy:e,edgeColorBy:o.edgeColorBy,edgeOpacity:o.edgeOpacity,nodeStyle:o.nodeStyle,edgeStyle:o.edgeStyle,colorScheme:r},i)},ChordDiagram:{frameType:"network",buildProps:(t,e,r,i,o)=>Object.assign({chartType:"chord",nodes:o.nodes,edges:o.edges,valueAccessor:o.valueAccessor,padAngle:o.padAngle,groupWidth:o.groupWidth,showLabels:o.showLabels,colorBy:e,edgeColorBy:o.edgeColorBy,colorScheme:r},i)},TreeDiagram:{frameType:"network",buildProps:(t,e,r,i,o)=>Object.assign({chartType:"cluster"===o.layout?"cluster":"tree",data:t,childrenAccessor:o.childrenAccessor,colorBy:e,colorByDepth:o.colorByDepth,orientation:o.orientation,showLabels:o.showLabels,colorScheme:r},i)},Treemap:{frameType:"network",buildProps:(t,e,r,i,o)=>Object.assign({chartType:"treemap",data:t,childrenAccessor:o.childrenAccessor,hierarchySum:o.valueAccessor,colorBy:e,colorByDepth:o.colorByDepth,showLabels:o.showLabels,colorScheme:r},i)},CirclePack:{frameType:"network",buildProps:(t,e,r,i,o)=>Object.assign({chartType:"circlepack",data:t,childrenAccessor:o.childrenAccessor,hierarchySum:o.valueAccessor,colorBy:e,colorByDepth:o.colorByDepth,colorScheme:r},i)},ChoroplethMap:{frameType:"geo",buildProps:(t,e,r,i,o)=>Object.assign({areas:o.areas,projection:o.projection||"equalEarth",areaStyle:o.areaStyle,valueAccessor:o.valueAccessor,colorScheme:r||"blues",graticule:o.graticule,fitPadding:o.fitPadding},i)},ProportionalSymbolMap:{frameType:"geo",buildProps:(t,e,r,i,o)=>Object.assign({points:t||o.points,xAccessor:o.xAccessor||"lon",yAccessor:o.yAccessor||"lat",areas:o.areas,areaStyle:o.areaStyle,sizeBy:o.sizeBy,colorBy:e,colorScheme:r,projection:o.projection||"equalEarth",graticule:o.graticule,fitPadding:o.fitPadding},i)}},Me=require("react-dom/server");function Oe(t){return Math.round(100*t)/100+""}function Le(t,e){const r=ke(e.theme),i=e.idPrefix?e.idPrefix+"-":"",o="string"==typeof e.title?e.title:void 0,n=o?i+"semiotic-title":void 0,s=e.description?i+"semiotic-desc":void 0,a=[n,s].filter(Boolean).join(" ")||void 0;return f.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:e.className,width:e.width,height:e.height,role:"img","aria-labelledby":a,style:{fontFamily:r.fontFamily}},o&&f.createElement("title",{id:n},o),e.description&&f.createElement("desc",{id:s},e.description),e.defs&&f.createElement("defs",null,e.defs),e.background&&"transparent"!==e.background&&f.createElement("rect",{x:0,y:0,width:e.width,height:e.height,fill:e.background}),f.createElement("g",{id:i+"data-area",transform:e.innerTransform},t),o&&f.createElement("text",{id:i+"chart-title",x:e.width/2,y:16,textAnchor:"middle",fontSize:r.titleSize,fontWeight:"bold",fill:r.text,fontFamily:r.fontFamily},o),e.legend&&f.createElement("g",{id:i+"legend"},e.legend),e.outerElements)}function Te(t){var e,r,i,o;const n=be(t.theme),s=t.size||[500,300],a=Object.assign(Object.assign({},{top:20,right:20,bottom:30,left:40}),t.margin),c=t.legendPosition;t.showLegend&&(c&&"right"!==c?"left"===c?a.left=Math.max(a.left,100):"bottom"===c?a.bottom=Math.max(a.bottom,70):"top"===c&&(a.top=Math.max(a.top,40)):a.right=Math.max(a.right,100));const l=s[0]-a.left-a.right,u=s[1]-a.top-a.bottom,h="streaming"===t.runtimeMode||["bar","swarm","waterfall"].includes(t.chartType),d={chartType:t.chartType,windowSize:null!==(e=t.windowSize)&&void 0!==e?e:200,windowMode:null!==(r=t.windowMode)&&void 0!==r?r:"sliding",arrowOfTime:h&&null!==(i=t.arrowOfTime)&&void 0!==i?i:"right",extentPadding:null!==(o=t.extentPadding)&&void 0!==o?o:.1,xAccessor:h?void 0:t.xAccessor,yAccessor:h?void 0:t.yAccessor,timeAccessor:h?t.timeAccessor:void 0,valueAccessor:t.valueAccessor,colorAccessor:t.colorAccessor,sizeAccessor:t.sizeAccessor,groupAccessor:t.groupAccessor,categoryAccessor:t.categoryAccessor,lineDataAccessor:t.lineDataAccessor,xExtent:t.xExtent,yExtent:t.yExtent,sizeRange:t.sizeRange,binSize:t.binSize,normalize:t.normalize,boundsAccessor:t.boundsAccessor,boundsStyle:t.boundsStyle,openAccessor:t.openAccessor,highAccessor:t.highAccessor,lowAccessor:t.lowAccessor,closeAccessor:t.closeAccessor,candlestickStyle:t.candlestickStyle,lineStyle:t.lineStyle,pointStyle:t.pointStyle,areaStyle:t.areaStyle,colorScheme:t.colorScheme||n.colors.categorical,barColors:t.barColors},g=new R(d);if(t.data&&g.ingest({inserts:t.data,bounded:!0}),g.computeScene({width:l,height:u}),!g.scales||0===g.scene.length)return Me.renderToStaticMarkup(Le(null,{width:s[0],height:s[1],className:"stream-xy-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:n,innerTransform:`translate(${a.left},${a.top})`,idPrefix:t._idPrefix}));const y=t._idPrefix,p=t.showGrid?function(t,e,r,i){const{grid:o}=ke(r),n=i?i+"-":"",s=t.x.ticks(5),a=t.y.ticks(5);return f.createElement("g",{id:n+"grid",className:"semiotic-grid",opacity:.8},s.map((r,i)=>{const n=t.x(r);return f.createElement("line",{key:"gx-"+i,x1:n,y1:0,x2:n,y2:e.height,stroke:o,strokeWidth:.5})}),a.map((r,i)=>{const n=t.y(r);return f.createElement("line",{key:"gy-"+i,x1:0,y1:n,x2:e.width,y2:n,stroke:o,strokeWidth:.5})}))}(g.scales,{width:l,height:u},n,y):null,m=g.scene.map((t,e)=>ge(t,e)).filter(Boolean),x=!1!==t.showAxes?function(t,e,r,i,o){var n,s,a,c;const l=ke(i),u=t.x.ticks(5).map(e=>({pixel:t.x(e),label:(r.xFormat||r.tickFormatTime||Oe)(e)})),h=t.y.ticks(5).map(e=>({pixel:t.y(e),label:(r.yFormat||r.tickFormatValue||Oe)(e)}));return f.createElement("g",{id:(o?o+"-":"")+"axes",className:"stream-axes"},f.createElement("line",{x1:0,y1:e.height,x2:e.width,y2:e.height,stroke:l.border,strokeWidth:1}),u.map((t,r)=>f.createElement("g",{key:"xtick-"+r,transform:`translate(${t.pixel},${e.height})`},f.createElement("line",{y2:5,stroke:l.border,strokeWidth:1}),f.createElement("text",{y:18,textAnchor:"middle",fontSize:l.tickSize,fill:l.textSecondary,fontFamily:l.fontFamily},t.label))),r.xLabel&&f.createElement("text",{x:e.width/2,y:e.height+40,textAnchor:"middle",fontSize:l.labelSize,fill:l.text,fontFamily:l.fontFamily},r.xLabel),f.createElement("line",{x1:0,y1:0,x2:0,y2:e.height,stroke:l.border,strokeWidth:1}),h.map((t,e)=>f.createElement("g",{key:"ytick-"+e,transform:`translate(0,${t.pixel})`},f.createElement("line",{x2:-5,stroke:l.border,strokeWidth:1}),f.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:l.tickSize,fill:l.textSecondary,fontFamily:l.fontFamily},t.label))),r.yLabel&&f.createElement("text",{x:15-(null!==(s=null===(n=r.margin)||void 0===n?void 0:n.left)&&void 0!==s?s:40),y:e.height/2,textAnchor:"middle",fontSize:l.labelSize,fill:l.text,fontFamily:l.fontFamily,transform:`rotate(-90, ${15-(null!==(c=null===(a=r.margin)||void 0===a?void 0:a.left)&&void 0!==c?c:40)}, ${e.height/2})`},r.yLabel))}(g.scales,{width:l,height:u},t,n,y):null,v=t.annotations?_e({annotations:t.annotations,scales:{x:g.scales.x,y:g.scales.y},layout:{width:l,height:u},theme:n,xAccessor:"string"==typeof t.xAccessor?t.xAccessor:void 0,yAccessor:"string"==typeof t.yAccessor?t.yAccessor:void 0,idPrefix:y}):null,b=t.showLegend?(()=>{const e=we(t.data||[],t.colorAccessor||t.groupAccessor);return 0===e.length?null:Ae({categories:e,colorScheme:t.colorScheme,theme:n,position:t.legendPosition||"right",totalWidth:s[0],totalHeight:s[1],margin:a,hasTitle:!!t.title})})():null,k=f.createElement(f.Fragment,null,p,v,m,x);return Me.renderToStaticMarkup(Le(k,{width:s[0],height:s[1],className:"stream-xy-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:n,innerTransform:`translate(${a.left},${a.top})`,legend:b,idPrefix:t._idPrefix}))}function De(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}const $e=new Set(["tree","cluster","treemap","circlepack","partition"]);function ze(t){const e=be(t.theme),r=t.chartType||"force",i=t.size||[500,500],o=Object.assign(Object.assign({},{top:20,right:20,bottom:20,left:20}),t.margin),n=i[0]-o.left-o.right,s=i[1]-o.top-o.bottom,a=function(t){return Kt[t]}(r);if(!a)throw Error(`No layout plugin found for chart type: "${r}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition.`);const l={chartType:r,nodeIDAccessor:t.nodeIDAccessor,sourceAccessor:t.sourceAccessor,targetAccessor:t.targetAccessor,valueAccessor:t.valueAccessor,childrenAccessor:t.childrenAccessor,hierarchySum:t.hierarchySum,orientation:t.orientation,nodeAlign:t.nodeAlign,nodePaddingRatio:t.nodePaddingRatio,nodeWidth:t.nodeWidth,iterations:t.iterations,forceStrength:t.forceStrength,padAngle:t.padAngle,groupWidth:t.groupWidth,sortGroups:t.sortGroups,edgeSort:t.edgeSort,treeOrientation:t.treeOrientation,edgeType:t.edgeType,padding:t.padding,paddingTop:t.paddingTop,nodeStyle:t.nodeStyle,edgeStyle:t.edgeStyle,nodeLabel:t.nodeLabel,showLabels:t.showLabels,colorBy:t.colorBy,colorScheme:t.colorScheme||e.colors.categorical,edgeColorBy:t.edgeColorBy,edgeOpacity:t.edgeOpacity,colorByDepth:t.colorByDepth,nodeSize:t.nodeSize,nodeSizeRange:t.nodeSizeRange};let u,h;if($e.has(r)){const r=t.data||t.edges;if(!r||Array.isArray(r))return Me.renderToStaticMarkup(Le(null,{width:i[0],height:i[1],className:"stream-network-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:e,innerTransform:`translate(${o.left},${o.top})`,idPrefix:t._idPrefix}));l.__hierarchyRoot=r,u=[],h=[]}else{const r=t.nodes||[],n=Array.isArray(t.edges)?t.edges:[];if(0===r.length&&0===n.length)return Me.renderToStaticMarkup(Le(null,{width:i[0],height:i[1],className:"stream-network-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:e,innerTransform:`translate(${o.left},${o.top})`,idPrefix:t._idPrefix}));if(h=function(t,e){const r=De(e.sourceAccessor,"source"),i=De(e.targetAccessor,"target"),o=De(e.valueAccessor,"value");return t.map(t=>({source:r(t)+"",target:i(t)+"",value:Number(o(t))||1,y0:0,y1:0,sankeyWidth:0,data:t}))}(n,l),0===r.length&&h.length>0){const t=new Set;for(const e of h){const r="string"==typeof e.target?e.target:e.target.id;t.add("string"==typeof e.source?e.source:e.source.id),t.add(r)}u=Array.from(t).map(t=>({id:t,x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:{id:t}}))}else u=function(t,e){const r=De(e.nodeIDAccessor,"id");return t.map(t=>{var e,i;return{id:r(t)+"",x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(i=t.y)&&void 0!==i?i:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:t}})}(r,l)}a.computeLayout(u,h,l,[n,s]);const{sceneNodes:d,sceneEdges:g,labels:y}=a.buildScene(u,h,l,[n,s]),p=ke(e);for(const t of y)t.fill||(t.fill=p.text);const m=g.map((t,e)=>function(t,e){switch(t.type){case"line":return f.createElement("line",{key:"net-edge-"+e,x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.stroke||"#999",strokeWidth:t.style.strokeWidth||1,opacity:t.style.opacity});case"bezier":{const r=t;return f.createElement("path",{key:"net-edge-"+e,d:r.pathD,fill:de(r.style.fill,"#999"),fillOpacity:r.style.fillOpacity,stroke:r.style.stroke||"none",strokeWidth:r.style.strokeWidth,opacity:r.style.opacity})}case"ribbon":{const r=t;return f.createElement("path",{key:"net-edge-"+e,d:r.pathD,fill:de(r.style.fill,"#999"),fillOpacity:r.style.fillOpacity,stroke:r.style.stroke||"none",strokeWidth:r.style.strokeWidth,opacity:r.style.opacity})}case"curved":{const r=t;return f.createElement("path",{key:"net-edge-"+e,d:r.pathD,fill:de(r.style.fill,"none"),stroke:r.style.stroke||"#999",strokeWidth:r.style.strokeWidth||1,opacity:r.style.opacity})}default:return null}}(t,e)).filter(Boolean),x=d.map((t,e)=>function(t,e){switch(t.type){case"circle":{const r=t;return f.createElement("circle",{key:"net-circle-"+e,cx:r.cx,cy:r.cy,r:r.r,fill:de(r.style.fill),stroke:r.style.stroke,strokeWidth:r.style.strokeWidth,opacity:r.style.opacity})}case"rect":{const r=t;return f.createElement("rect",{key:"net-rect-"+e,x:r.x,y:r.y,width:r.w,height:r.h,fill:de(r.style.fill),stroke:r.style.stroke,strokeWidth:r.style.strokeWidth,opacity:r.style.opacity})}case"arc":{const r=t,i=c.arc().innerRadius(r.innerR).outerRadius(r.outerR).startAngle(r.startAngle+Math.PI/2).endAngle(r.endAngle+Math.PI/2)({})||"";return f.createElement("path",{key:"net-arc-"+e,d:i,transform:`translate(${r.cx},${r.cy})`,fill:de(r.style.fill),stroke:r.style.stroke,strokeWidth:r.style.strokeWidth,opacity:r.style.opacity})}default:return null}}(t,e)).filter(Boolean),v=y.map((t,e)=>function(t,e){return f.createElement("text",{key:"net-label-"+e,x:t.x,y:t.y,textAnchor:t.anchor||"middle",dominantBaseline:t.baseline||"auto",fontSize:t.fontSize||11,fontWeight:t.fontWeight,fill:t.fill||"#333",stroke:t.stroke,strokeWidth:t.strokeWidth,paintOrder:t.paintOrder},t.text)}(t,e)).filter(Boolean),b=f.createElement(f.Fragment,null,m,x,v);return Me.renderToStaticMarkup(Le(b,{width:i[0],height:i[1],className:"stream-network-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:e,innerTransform:`translate(${o.left},${o.top})`,idPrefix:t._idPrefix}))}function je(t){var e,r,i,o,n;const s=be(t.theme),a=t.size||[500,400],c=Object.assign(Object.assign({},{top:20,right:20,bottom:30,left:40}),t.margin),l=t.legendPosition;t.showLegend&&(l&&"right"!==l?"left"===l?c.left=Math.max(c.left,100):"bottom"===l?c.bottom=Math.max(c.bottom,70):"top"===l&&(c.top=Math.max(c.top,40)):c.right=Math.max(c.right,100));const u=a[0]-c.left-c.right,h=a[1]-c.top-c.bottom,d=t.projection||"vertical",g="radial"===d,y={chartType:t.chartType,windowSize:null!==(e=t.windowSize)&&void 0!==e?e:1e4,windowMode:null!==(r=t.windowMode)&&void 0!==r?r:"sliding",extentPadding:null!==(i=t.extentPadding)&&void 0!==i?i:.05,projection:d,oAccessor:t.oAccessor,rAccessor:t.rAccessor,colorAccessor:t.colorAccessor,stackBy:t.stackBy,groupBy:t.groupBy,categoryAccessor:t.categoryAccessor,valueAccessor:t.valueAccessor,timeAccessor:t.timeAccessor,rExtent:t.rExtent,oExtent:t.oExtent,barPadding:t.barPadding,roundedTop:t.roundedTop,innerRadius:t.innerRadius,cornerRadius:t.cornerRadius,normalize:t.normalize,startAngle:t.startAngle,sweepAngle:t.sweepAngle,bins:t.bins,showOutliers:t.showOutliers,showIQR:t.showIQR,amplitude:t.amplitude,oSort:t.oSort,connectorAccessor:t.connectorAccessor,connectorStyle:t.connectorStyle,dynamicColumnWidth:t.dynamicColumnWidth,pieceStyle:t.pieceStyle,summaryStyle:t.summaryStyle,colorScheme:t.colorScheme||s.colors.categorical,barColors:t.barColors},p=new te(y);if(t.data&&p.ingest({inserts:t.data,bounded:!0}),p.computeScene({width:u,height:h}),!p.scales||0===p.scene.length)return Me.renderToStaticMarkup(Le(null,{width:a[0],height:a[1],className:"stream-ordinal-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:s,innerTransform:`translate(${c.left},${c.top})`,idPrefix:t._idPrefix}));const m=t._idPrefix,x=t.showGrid?function(t,e,r,i){const o=t.scales;if(!o||"radial"===o.projection)return null;const{grid:n}=ke(r),s=i?i+"-":"",a="vertical"===o.projection,c=o.r.ticks(5);return f.createElement("g",{id:s+"grid",className:"semiotic-grid",opacity:.8},c.map(a?(t,r)=>{const i=o.r(t);return f.createElement("line",{key:"gr-"+r,x1:0,y1:i,x2:e.width,y2:i,stroke:n,strokeWidth:.5})}:(t,r)=>{const i=o.r(t);return f.createElement("line",{key:"gr-"+r,x1:i,y1:0,x2:i,y2:e.height,stroke:n,strokeWidth:.5})}))}(p,{width:u,height:h},s,m):null,v=p.scene.some(t=>{var e;return"rect"===t.type&&(null===(e=t.datum)||void 0===e?void 0:e.__barFunnelIsDropoff)});let b=null;if(v){const e=function(t){const e=t._idPrefix||t.chartId;if(e){const t=(e+"").replace(/[^a-zA-Z0-9_-]/g,"_");return/^[A-Za-z_]/.test(t)?t:"c"+t}const r=`${t.chartType||""}:${t.title||""}:${Array.isArray(t.data)?t.data.length:0}`;let i=0;for(let t=0;r.length>t;t++)i=31*i+r.charCodeAt(t)|0;return"c"+(i>>>0).toString(36)}(t),r=new Set;for(const t of p.scene)"rect"===t.type&&(null===(o=t.datum)||void 0===o?void 0:o.__barFunnelIsDropoff)&&r.add("string"==typeof t.style.fill?t.style.fill:"#666");b=Array.from(r).map((t,r)=>function(t){const{id:e,background:r="transparent",stroke:i="#000",lineWidth:o=1.5,spacing:n=6,angle:s=45}=t,a=Math.max(8,Math.ceil(2*n));return f.createElement("pattern",{key:e,id:e,width:a,height:a,patternUnits:"userSpaceOnUse",patternTransform:0!==s?`rotate(${s})`:void 0},r&&"transparent"!==r&&f.createElement("rect",{width:a,height:a,fill:r}),f.createElement("line",{x1:0,y1:0,x2:0,y2:a,stroke:i,strokeWidth:o}),f.createElement("line",{x1:n,y1:0,x2:n,y2:a,stroke:i,strokeWidth:o}))}({id:`funnel-hatch-${e}-${r}`,background:t,stroke:"transparent"===s.colors.background?"#fff":s.colors.background,lineWidth:1.5,spacing:5,angle:45}));const i=new Map;Array.from(r).forEach((t,r)=>i.set(t,`funnel-hatch-${e}-${r}`));for(const t of p.scene)if("rect"===t.type&&(null===(n=t.datum)||void 0===n?void 0:n.__barFunnelIsDropoff)){const e="string"==typeof t.style.fill?t.style.fill:"#666";t.style=Object.assign(Object.assign({},t.style),{fill:`url(#${i.get(e)})`})}}const k=p.scene.map((t,e)=>ye(t,e)).filter(Boolean),A=!1!==t.showAxes?function(t,e,r,i,o){var n,s,a,c,l,u,h,d;const g=t.scales;if(!g)return null;if("radial"===g.projection)return null;const y=ke(i),p="vertical"===g.projection,m=Object.values(t.columns).map(t=>({pixel:t.middle,label:(r.oFormat||String)(t.name)})),x=g.r.ticks(5).map(t=>({pixel:g.r(t),label:(r.rFormat||Oe)(t)}));return p?f.createElement("g",{id:(o?o+"-":"")+"axes",className:"ordinal-axes"},f.createElement("line",{x1:0,y1:e.height,x2:e.width,y2:e.height,stroke:y.border,strokeWidth:1}),m.map((t,r)=>f.createElement("g",{key:"oxtick-"+r,transform:`translate(${t.pixel},${e.height})`},f.createElement("line",{y2:5,stroke:y.border,strokeWidth:1}),f.createElement("text",{y:18,textAnchor:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily},t.label))),r.oLabel&&f.createElement("text",{x:e.width/2,y:e.height+40,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily},r.oLabel),f.createElement("line",{x1:0,y1:0,x2:0,y2:e.height,stroke:y.border,strokeWidth:1}),x.map((t,e)=>f.createElement("g",{key:"oytick-"+e,transform:`translate(0,${t.pixel})`},f.createElement("line",{x2:-5,stroke:y.border,strokeWidth:1}),f.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily},t.label))),r.rLabel&&f.createElement("text",{x:15-(null!==(s=null===(n=r.margin)||void 0===n?void 0:n.left)&&void 0!==s?s:40),y:e.height/2,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily,transform:`rotate(-90, ${15-(null!==(c=null===(a=r.margin)||void 0===a?void 0:a.left)&&void 0!==c?c:40)}, ${e.height/2})`},r.rLabel)):f.createElement("g",{id:(o?o+"-":"")+"axes",className:"ordinal-axes"},f.createElement("line",{x1:0,y1:e.height,x2:e.width,y2:e.height,stroke:y.border,strokeWidth:1}),x.map((t,r)=>f.createElement("g",{key:"oxtick-"+r,transform:`translate(${t.pixel},${e.height})`},f.createElement("line",{y2:5,stroke:y.border,strokeWidth:1}),f.createElement("text",{y:18,textAnchor:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily},t.label))),r.rLabel&&f.createElement("text",{x:e.width/2,y:e.height+40,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily},r.rLabel),f.createElement("line",{x1:0,y1:0,x2:0,y2:e.height,stroke:y.border,strokeWidth:1}),m.map((t,e)=>f.createElement("g",{key:"oytick-"+e,transform:`translate(0,${t.pixel})`},f.createElement("line",{x2:-5,stroke:y.border,strokeWidth:1}),f.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily},t.label))),r.oLabel&&f.createElement("text",{x:15-(null!==(u=null===(l=r.margin)||void 0===l?void 0:l.left)&&void 0!==u?u:40),y:e.height/2,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily,transform:`rotate(-90, ${15-(null!==(d=null===(h=r.margin)||void 0===h?void 0:h.left)&&void 0!==d?d:40)}, ${e.height/2})`},r.oLabel))}(p,{width:u,height:h},t,s,m):null,w=t.annotations?_e({annotations:t.annotations,scales:{r:p.scales.r,y:"vertical"===p.scales.projection?p.scales.r:void 0},layout:{width:u,height:h},theme:s,projection:d,idPrefix:m}):null,S=t.showLegend?(()=>{const e=we(t.data||[],t.colorAccessor||t.stackBy||t.groupBy);return 0===e.length?null:Ae({categories:e,colorScheme:t.colorScheme,theme:s,position:t.legendPosition||"right",totalWidth:a[0],totalHeight:a[1],margin:c,hasTitle:!!t.title})})():null,_=g?c.left+u/2:c.left,P=g?c.top+h/2:c.top,E=f.createElement(f.Fragment,null,x,w,k,A);return Me.renderToStaticMarkup(Le(E,{width:a[0],height:a[1],className:"stream-ordinal-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:s,innerTransform:`translate(${_},${P})`,legend:S,defs:b,idPrefix:t._idPrefix}))}function Ne(t){var e,r,i,o,n,s,a,c;const l=be(t.theme),u=t.size||[t.width||600,t.height||400],h=Object.assign(Object.assign({},{top:10,right:10,bottom:10,left:10}),t.margin),d=u[0]-(null!==(e=h.left)&&void 0!==e?e:0)-(null!==(r=h.right)&&void 0!==r?r:0),g=u[1]-(null!==(i=h.top)&&void 0!==i?i:0)-(null!==(o=h.bottom)&&void 0!==o?o:0),y=new fe({projection:t.projection||"equalEarth",xAccessor:t.xAccessor,yAccessor:t.yAccessor,lineDataAccessor:t.lineDataAccessor,pointIdAccessor:t.pointIdAccessor,lineType:t.lineType,areaStyle:t.areaStyle,pointStyle:t.pointStyle,lineStyle:t.lineStyle,graticule:t.graticule,fitPadding:t.fitPadding,projectionTransform:t.projectionTransform});if(t.areas){if("string"==typeof t.areas)throw Error(`Geo SSR requires pre-resolved GeoJSON features. Reference string "${t.areas}" cannot be resolved synchronously. Use \`const features = await resolveReferenceGeography('${t.areas}')\` before calling renderGeoToStaticSVG.`);y.setAreas(t.areas)}if(t.points&&y.setPoints(t.points),t.lines&&y.setLines(t.lines),y.computeScene({width:d,height:g}),0===y.scene.length)return Me.renderToStaticMarkup(Le(null,{width:u[0],height:u[1],className:"stream-geo-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:l,innerTransform:`translate(${null!==(n=h.left)&&void 0!==n?n:0},${null!==(s=h.top)&&void 0!==s?s:0})`,idPrefix:t._idPrefix}));const p=y.scene.map((t,e)=>function(t,e){var r,i,o,n,s,a;switch(t.type){case"geoarea":{const o=t;return o.pathData?f.createElement("path",{key:"geoarea-"+e,d:o.pathData,fill:de(o.style.fill,"#e0e0e0"),fillOpacity:null!==(r=o.style.fillOpacity)&&void 0!==r?r:1,stroke:o.style.stroke||"none",strokeWidth:o.style.strokeWidth||.5,strokeDasharray:o.style.strokeDasharray,opacity:null!==(i=o._decayOpacity)&&void 0!==i?i:1}):null}case"point":{const r=t;return f.createElement("circle",{key:"point-"+e,cx:r.x,cy:r.y,r:r.r,fill:de(r.style.fill),fillOpacity:null!==(o=r.style.fillOpacity)&&void 0!==o?o:.8,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth,opacity:null!==(n=r._decayOpacity)&&void 0!==n?n:null!==(s=r.style.opacity)&&void 0!==s?s:1})}case"line":{const r=t;if(2>r.path.length)return null;const i="M"+r.path.map(t=>`${t[0]},${t[1]}`).join("L");return f.createElement("path",{key:"line-"+e,d:i,fill:"none",stroke:r.style.stroke||"#4e79a7",strokeWidth:r.style.strokeWidth||1.5,strokeDasharray:r.style.strokeDasharray,opacity:null!==(a=r.style.opacity)&&void 0!==a?a:1})}default:return null}}(t,e)).filter(Boolean),m=f.createElement(f.Fragment,null,p);return Me.renderToStaticMarkup(Le(m,{width:u[0],height:u[1],className:"stream-geo-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:l,innerTransform:`translate(${null!==(a=h.left)&&void 0!==a?a:0},${null!==(c=h.top)&&void 0!==c?c:0})`,idPrefix:t._idPrefix}))}function Be(t,e){switch(t){case"xy":return Te(e);case"ordinal":return je(e);case"network":return ze(e);case"geo":return Ne(e);default:throw Error(`Unknown frame type: ${t}. Must be "xy", "ordinal", "network", or "geo".`)}}function Re(t,e,r){var i;const{data:o,width:n=600,height:s=400,theme:a,title:c,description:l,showLegend:u,showGrid:h,background:d,className:g,annotations:y,margin:p,colorScheme:m,colorBy:x,legendPosition:v}=e,b=function(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&0>e.indexOf(i)&&(r[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(i=Object.getOwnPropertySymbols(t);i.length>o;o++)0>e.indexOf(i[o])&&Object.prototype.propertyIsEnumerable.call(t,i[o])&&(r[i[o]]=t[i[o]])}return r}(e,["data","width","height","theme","title","description","showLegend","showGrid","background","className","annotations","margin","colorScheme","colorBy","legendPosition"]),k=[n,s],A=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},b.frameProps||{}),{theme:a,title:c,description:l,showLegend:u,showGrid:h,background:d,className:g,annotations:y,size:k}),void 0!==p&&{margin:p}),void 0!==m&&{colorScheme:m}),void 0!==v&&{legendPosition:v}),{_idPrefix:b._idPrefix}),w=Ee[t];if(!w)throw Error(`Unknown chart component: "${t}". See CLAUDE.md for supported chart types.`);const S=w.buildProps(o,x,m,A,b);let _=(0,{xy:Te,ordinal:je,network:ze,geo:Ne}[w.frameType])(S);if("GaugeChart"===t&&S.__gauge){const t=S.__gauge,e=A.margin||{top:20,right:20,bottom:30,left:40},r=(n||300)-e.left-e.right,o=(s||300)-e.top-e.bottom,c=Math.min(r,o)/2*.85,l=e.left+r/2,u=e.top+o/2,h=Math.max(t.gMin,Math.min(t.gMax,null!==(i=t.value)&&void 0!==i?i:t.gMin)),d=(t.startAngleDeg+(t.gMax===t.gMin?0:(h-t.gMin)/(t.gMax-t.gMin))*t.sweep-90)*Math.PI/180,g=be(a).colors.text,y=Me.renderToStaticMarkup(f.createElement(f.Fragment,null,f.createElement("line",{x1:l,y1:u,x2:l+c*Math.cos(d),y2:u+c*Math.sin(d),stroke:g,strokeWidth:2.5,strokeLinecap:"round"}),f.createElement("circle",{cx:l,cy:u,r:4,fill:g})));_=_.replace("</svg>",y+"</svg>")}return _}const We=require("react-dom/server");function Fe(t,e,r,i={}){const{stepSize:o,windowSize:n,frameCount:s,xExtent:a,yExtent:c,transitionFrames:l=4,fps:u=12,easing:h="ease-out",decay:f}=i,d=r.width||600,g=r.height||400,y=be(r.theme),p=Object.assign(Object.assign(Object.assign({},r),a&&{xExtent:a}),c&&{yExtent:c});if(!e||0===e.length)return[];const m=o||Math.max(1,Math.ceil(e.length/(s||Math.min(60,Math.max(10,e.length))))),x=[];for(let t=m;e.length>=t;t+=m)x.push(t);x[x.length-1]!==e.length&&x.push(e.length);const v=new Set(["bar","pie","donut","clusterbar","swarm","point","boxplot","violin","histogram","timeline","swimlane","ridgeline","funnel","bar-funnel"]).has(t),b=Object.assign({top:20,right:20,bottom:30,left:40},r.margin),k=d-b.left-b.right,A=g-b.top-b.bottom,w=[];if(v)for(let i=0;x.length>i;i++){const o=x[i],s=e.slice(n?Math.max(0,o-n):0,o),a=Object.assign({chartType:t,windowSize:1e4,windowMode:"sliding",extentPadding:.05,projection:r.projection||"vertical",oAccessor:r.oAccessor||r.categoryAccessor||"category",rAccessor:r.rAccessor||r.valueAccessor||"value",colorAccessor:r.colorAccessor||r.colorBy,stackBy:r.stackBy,groupBy:r.groupBy,barPadding:r.barPadding,innerRadius:r.innerRadius,normalize:r.normalize,bins:r.bins,colorScheme:r.colorScheme||y.colors.categorical},f&&{decay:f}),c=new te(a);c.ingest({inserts:s,bounded:!0}),c.computeScene({width:k,height:A}),c.scene.length>0&&w.push(Ye(c.scene,d,g,y,p))}else for(let i=0;x.length>i;i++){const o=x[i],s=e.slice(n?Math.max(0,o-n):0,o),m=Object.assign(Object.assign({chartType:t,windowSize:s.length+10,windowMode:"sliding",arrowOfTime:"right",extentPadding:.1,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:r.colorAccessor||r.colorBy,groupAccessor:r.groupAccessor||r.lineBy,lineDataAccessor:r.lineDataAccessor,xExtent:a,yExtent:c,colorScheme:r.colorScheme||y.colors.categorical,lineStyle:r.lineStyle,pointStyle:r.pointStyle,areaStyle:r.areaStyle,sizeAccessor:r.sizeAccessor||r.sizeBy,sizeRange:r.sizeRange},f&&{decay:f}),l>0&&{transition:{duration:l*(1e3/u),easing:h}}),v=new R(m);if(v.ingest({inserts:s,bounded:!0}),v.computeScene({width:k,height:A}),0===v.scene.length)continue;const b=v.scales?{y:v.scales.y}:void 0;if(w.push(Ie(v.scene,d,g,y,p,b)),l>0&&i>0&&v.activeTransition){const t=l*(1e3/u);for(let e=1;l>=e;e++)v.advanceTransition(v.activeTransition.startTime+e/l*t),w.push(Ie(v.scene,d,g,y,p,b))}}return w}function Ce(t,e){const r=t.background||e.colors.background;return r&&"transparent"!==r?r:null}function Ie(t,e,r,i,o,n){const s=ke(i),a=Object.assign({top:20,right:20,bottom:30,left:40},o.margin),c=e-a.left-a.right,l=r-a.top-a.bottom,u=Ce(o,i),h=t.map((t,e)=>ge(t,e)).filter(Boolean),d=function(t,e,r,i,o,n){var s;if(!t||0===t.length)return null;const a=ke(i),c=[];for(let i=0;t.length>i;i++){const l=t[i];if("y-threshold"===l.type&&null!=l.value){let t=null;if(n)t=n(l.value);else if(o){const[e,i]=o,n=i-e;if(0===n)continue;t=r-(l.value-e)/n*r}if(null==t)continue;const u=l.color||a.primary,h=null!==(s=l.strokeWidth)&&void 0!==s?s:1.5,d=l.labelPosition||"right";c.push(f.createElement("g",{key:"ann-"+i},f.createElement("line",{x1:0,y1:t,x2:e,y2:t,stroke:u,strokeWidth:h,strokeDasharray:l.strokeDasharray||"6,4"}),l.label&&f.createElement("text",{x:"left"===d?4:"center"===d?e/2:e-4,y:t-5,textAnchor:"left"===d?"start":"center"===d?"middle":"end",fontSize:a.tickSize,fill:u,fontFamily:a.fontFamily},l.label)))}}return c.length>0?f.createElement(f.Fragment,null,c):null}(o.annotations,c,l,i,o.yExtent,null==n?void 0:n.y),g="string"==typeof o.title?o.title:void 0,y="string"==typeof o.description?o.description:void 0,p=g?"semiotic-title":void 0,m=y?"semiotic-desc":void 0,x=[p,m].filter(Boolean).join(" ")||void 0,v=f.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:r,role:"img","aria-labelledby":x,style:{fontFamily:s.fontFamily}},g&&f.createElement("title",{id:p},g),y&&f.createElement("desc",{id:m},y),u&&f.createElement("rect",{x:0,y:0,width:e,height:r,fill:u}),f.createElement("g",{transform:`translate(${a.left},${a.top})`},d,h),g&&f.createElement("text",{x:e/2,y:16,textAnchor:"middle",fontSize:s.titleSize,fontWeight:"bold",fill:s.text,fontFamily:s.fontFamily},g));return We.renderToStaticMarkup(v)}function Ye(t,e,r,i,o){const n=ke(i),s=Object.assign({top:20,right:20,bottom:30,left:40},o.margin),a="radial"===o.projection,c=a?s.left+(e-s.left-s.right)/2:s.left,l=a?s.top+(r-s.top-s.bottom)/2:s.top,u=Ce(o,i),h=t.map((t,e)=>ye(t,e)).filter(Boolean),d="string"==typeof o.title?o.title:void 0,g="string"==typeof o.description?o.description:void 0,y=d?"semiotic-title":void 0,p=g?"semiotic-desc":void 0,m=[y,p].filter(Boolean).join(" ")||void 0,x=f.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:r,role:"img","aria-labelledby":m,style:{fontFamily:n.fontFamily}},d&&f.createElement("title",{id:y},d),g&&f.createElement("desc",{id:p},g),u&&f.createElement("rect",{x:0,y:0,width:e,height:r,fill:u}),f.createElement("g",{transform:`translate(${c},${l})`},h),d&&f.createElement("text",{x:e/2,y:16,textAnchor:"middle",fontSize:n.titleSize,fontWeight:"bold",fill:n.text,fontFamily:n.fontFamily},d));return We.renderToStaticMarkup(x)}exports.generateFrameSVGs=Fe,exports.generateFrameSequence=function(t,e,r={}){return e.map(e=>{try{return Re(t,Object.assign(Object.assign({},r),e))}catch(t){return`<svg xmlns="http://www.w3.org/2000/svg" width="${r.width||e.width||600}" height="${r.height||e.height||400}"></svg>`}})},exports.renderChart=Re,exports.renderDashboard=function(t,e={}){var r;const{title:i,subtitle:o,theme:n,width:s=1200,height:a,layout:c={},background:l}=e,u=ke(be(n)),h=c.columns||2,d=null!==(r=c.gap)&&void 0!==r?r:16;let g=0;i&&(g+=30),o&&(g+=20),g>0&&(g+=10);const y=Math.floor((s-d-d*(h-1))/h),p=[];let m=0,x=g+d,v=0;for(const e of t){const t=Math.min(e.colSpan||1,h),r=e.props.height||300;m+t>h&&(x+=v+d,m=0,v=0),p.push({chart:e,x:d/2+m*(y+d),y:x,w:y*t+d*(t-1),h:r}),v=Math.max(v,r),m+=t}const b=a||x+v+d,k=p.map((t,e)=>{const{chart:r,x:i,y:o,w:s,h:a}=t,c=Object.assign(Object.assign({},r.props),{width:s,height:a,theme:n,_idPrefix:"chart-"+e});let l;return l=r.component?Re(r.component,c):r.frameType?Be(r.frameType,c):`<svg xmlns="http://www.w3.org/2000/svg" width="${s}" height="${a}"></svg>`,f.createElement("g",{key:"dashboard-chart-"+e,transform:`translate(${i},${o})`},f.createElement("foreignObject",{width:s,height:a},f.createElement("div",{xmlns:"http://www.w3.org/1999/xhtml",dangerouslySetInnerHTML:{__html:l}})))}),A=f.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:s,height:b,role:"img","aria-label":i||"Dashboard",style:{fontFamily:u.fontFamily}},i&&f.createElement("title",null,i),l&&f.createElement("rect",{x:0,y:0,width:s,height:b,fill:l}),i&&f.createElement("text",{x:s/2,y:24,textAnchor:"middle",fontSize:u.titleSize+4,fontWeight:"bold",fill:u.text,fontFamily:u.fontFamily},i),o&&f.createElement("text",{x:s/2,y:i?46:20,textAnchor:"middle",fontSize:u.labelSize,fill:u.textSecondary,fontFamily:u.fontFamily},o),k);return Me.renderToStaticMarkup(A)},exports.renderGeoToStaticSVG=function(t){return Ne(t)},exports.renderNetworkToStaticSVG=function(t){return ze(t)},exports.renderOrdinalToStaticSVG=function(t){return je(t)},exports.renderToAnimatedGif=function(t,e,r){return d(this,arguments,void 0,function*(t,e,r,i={}){const{fps:o=12,loop:n=!0,scale:s=1,background:a}=i,c=r.height||400,l=Math.round((r.width||600)*s),u=Math.round(c*s),h=Fe(t,e,a?Object.assign(Object.assign({},r),{background:a}):r,i);if(0===h.length)throw Error("No frames generated — check that data is not empty");let f,d,g,y;try{f=require("sharp")}catch(t){throw Error('Animated GIF export requires "sharp". Install it:\n npm install sharp')}try{const t=require("gifenc");d=t.GIFEncoder,g=t.quantize,y=t.applyPalette}catch(t){throw Error('Animated GIF export requires "gifenc". Install it:\n npm install gifenc')}const p=Math.round(1e3/o),m=d();for(let t=0;h.length>t;t++){const e=h[t],r=yield f(Buffer.from(e),{density:72*s}).resize(l,u).ensureAlpha().raw().toBuffer(),i=new Uint8Array(r),o=g(i,256),a=y(i,o);m.writeFrame(a,l,u,{palette:o,delay:p,repeat:n?0:-1})}return m.finish(),Buffer.from(m.bytes())})},exports.renderToImage=function(t,e){return d(this,arguments,void 0,function*(t,e,r={}){var i,o;const{format:n="png",scale:s=1,background:a}=r;let c,l;c=["xy","ordinal","network","geo"].includes(t)?Be(t,e):Re(t,e),a&&(c=c.replace(/<svg /,`<svg style="background:${a}" `));try{l=require("sharp")}catch(t){throw Error('Image export requires the "sharp" package and a Node.js runtime. Install it:\n npm install sharp\nsharp is listed as an optional dependency of semiotic.')}const u=e.width||(null===(i=e.size)||void 0===i?void 0:i[0])||600,h=e.height||(null===(o=e.size)||void 0===o?void 0:o[1])||400,f=l(void 0!==globalThis.Buffer?globalThis.Buffer.from(c):(new TextEncoder).encode(c),{density:72*s}).resize(Math.round(u*s),Math.round(h*s));return"jpeg"===n?f.jpeg({quality:90}).toBuffer():f.png().toBuffer()})},exports.renderToStaticSVG=Be,exports.renderXYToStaticSVG=function(t){return Te(t)},exports.resolveTheme=be,exports.themeStyles=ke;
|