semiotic 3.3.0 → 3.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +7 -4
- package/ai/schema.json +97 -1
- package/dist/components/charts/ordinal/BarChart.d.ts +2 -0
- package/dist/components/charts/ordinal/DonutChart.d.ts +2 -0
- package/dist/components/charts/ordinal/GroupedBarChart.d.ts +4 -0
- package/dist/components/charts/ordinal/PieChart.d.ts +2 -0
- package/dist/components/charts/ordinal/StackedBarChart.d.ts +4 -0
- package/dist/components/realtime/types.d.ts +42 -3
- package/dist/components/server/renderToStaticSVG.d.ts +1 -0
- package/dist/components/server/serverChartConfigs.d.ts +17 -0
- package/dist/components/server/themeResolver.d.ts +4 -0
- package/dist/components/store/ThemeStore.d.ts +14 -0
- package/dist/components/stream/NetworkPipelineStore.d.ts +7 -1
- package/dist/components/stream/geoTypes.d.ts +4 -4
- package/dist/components/stream/hoverUtils.d.ts +22 -0
- package/dist/components/stream/networkTypes.d.ts +14 -22
- package/dist/components/stream/ordinalTypes.d.ts +10 -0
- package/dist/components/stream/pipelineDecay.d.ts +6 -5
- package/dist/components/stream/types.d.ts +4 -0
- package/dist/geo.min.js +1 -1
- package/dist/geo.module.min.js +1 -1
- package/dist/network.min.js +1 -1
- package/dist/network.module.min.js +1 -1
- package/dist/ordinal.min.js +1 -1
- package/dist/ordinal.module.min.js +1 -1
- package/dist/realtime.min.js +1 -1
- package/dist/realtime.module.min.js +1 -1
- package/dist/semiotic-ai.min.js +1 -1
- package/dist/semiotic-ai.module.min.js +1 -1
- package/dist/semiotic-themes.min.js +1 -1
- package/dist/semiotic-themes.module.min.js +1 -1
- package/dist/semiotic-utils.min.js +1 -1
- package/dist/semiotic-utils.module.min.js +1 -1
- package/dist/semiotic.min.js +1 -1
- package/dist/semiotic.module.min.js +1 -1
- package/dist/server.min.js +1 -1
- package/dist/server.module.min.js +1 -1
- package/dist/xy.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +1 -1
package/dist/server.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const t=require("react"),e=require("d3-scale"),i=require("d3-quadtree"),r=require("d3-scale-chromatic"),o=require("d3-array"),n=require("d3-interpolate"),a=require("d3-force"),s=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 r=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,r.get?r:{enumerable:!0,get:function(){return t[i]}})}return e.default=t,Object.freeze(e)}const f=h(t);function d(t,e,i,r){return new(i||(i=Promise))(function(o,n){function a(t){try{c(r.next(t))}catch(t){n(t)}}function s(t){try{c(r.throw(t))}catch(t){n(t)}}function c(t){t.done?o(t.value):function(t){return t instanceof i?t:new i(function(e){e(t)})}(t.value).then(a,s)}c((r=r.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 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}update(t,e){const i=[],r=(this.head-this._size+this._capacity)%this._capacity;for(let o=0;this._size>o;o++){const n=(r+o)%this._capacity,a=this.buffer[n];if(t(a)){let t;t="object"!=typeof a||null===a?a:Array.isArray(a)?[...a]:Object.assign({},a),i.push(t),this.buffer[n]=e(a)}}return i}remove(t){const e=[],i=[];if(this.forEach(r=>{t(r)?i.push(r):e.push(r)}),0===i.length)return i;this.buffer=Array(this._capacity),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 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 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 p(t,e,i,r,o){const n=new Map;for(const a of t){const t=e(a),s=i(a);if(null==t||null==s||Number.isNaN(t)||Number.isNaN(s))continue;const c=Math.floor(t/r)*r;let l=n.get(c);if(l||(l={start:c,end:c+r,total:0,categories:new Map},n.set(c,l)),l.total+=s,o){const t=o(a);l.categories.set(t,(l.categories.get(t)||0)+s)}}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 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 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 w(t,e,i){var r,o,n;if(1>=i)return 1;const a=null!==(r=t.minOpacity)&&void 0!==r?r:.1,s=i-1-e;switch(t.type){case"linear":return a+(1-s/(i-1))*(1-a);case"exponential":{const e=null!==(o=t.halfLife)&&void 0!==o?o:i/2;return a+Math.pow(.5,s/e)*(1-a)}case"step":return(null!==(n=t.stepThreshold)&&void 0!==n?n:.5*i)>s?1:a;default:return 1}}function A(t,e,i){var r;const o=null!==(r=t.duration)&&void 0!==r?r:500,n=i-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 E(t,e,i){return t+(e-t)*i}function P(){return"undefined"!=typeof performance?performance.now():Date.now()}function M(t,e,i){var r,o,n,a;switch(e.type){case"point":if(e.pointId)return"p:"+e.pointId;if("streaming"===t.runtimeMode&&e.datum){const i=t.getX(e.datum),r=t.getY(e.datum);if(t.getCategory)return`p:${t.getCategory(e.datum)}:${i}:${r}`;if(null!=i&&null!=r)return`p:${i}:${r}`}return"p:"+i;case"rect":return`r:${e.group||""}:${null!==(a=null!==(o=null===(r=e.datum)||void 0===r?void 0:r.binStart)&&void 0!==o?o:null===(n=e.datum)||void 0===n?void 0:n.category)&&void 0!==a?a: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 O(t,e,i,r,o,n){const a=[];for(const o of t){const t=i(o),n=r(o);null==t||null==n||Number.isNaN(t)||Number.isNaN(n)||a.push({px:e.x(t),py:e.y(n),rawY:n,d:o})}a.sort((t,e)=>t.px-e.px);const s=Array(a.length),c=Array(a.length),l=Array(a.length);for(let t=0;a.length>t;t++){const e=a[t];s[t]=[e.px,e.py],c[t]=e.rawY,l[t]=e.d}return{type:"line",path:s,rawValues:c,style:o,datum:l,group:n}}function L(t,e,i,r,o,n,a,s){const c=[];for(const n of t){const t=i(n),a=r(n);if(null==t||null==a||Number.isNaN(t)||Number.isNaN(a))continue;const l=e.x(t),u=s?s(n):o;c.push({px:l,topY:e.y(a),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:a}}function D(t,e,i,r,o,n,a){const s=i(t),c=r(t);if(null==s||null==c||Number.isNaN(s)||Number.isNaN(c))return null;const l={type:"point",x:e.x(s),y:e.y(c),r:o,style:n,datum:t};return void 0!==a&&(l.pointId=a),l}function z(t,e,i,r,o,n,a){return{type:"rect",x:t,y:e,w:i,h:r,style:o,datum:n,group:a}}function j(t,e,i,r,o,n,a){const s={type:"heatcell",x:t,y:e,w:i,h:r,fill:o,datum:n};return(null==a?void 0:a.showValues)&&(s.showValues=!0,s.value=a.value,a.valueFormat&&(s.valueFormat=a.valueFormat)),s}function T(t,e,i){if(!t.getBounds||!t.scales)return null;const r=[],o=[];for(const i of e){const e=t.getX(i),n=t.getY(i);if(null==e||null==n||Number.isNaN(e)||Number.isNaN(n))continue;const a=t.getBounds(i),s=t.scales.x(e);if(a&&0!==a)r.push([s,t.scales.y(n+a)]),o.push([s,t.scales.y(n-a)]);else{const e=t.scales.y(n);r.push([s,e]),o.push([s,e])}}return 2>r.length?null:{type:"area",topPath:r,bottomPath:o,style:t.resolveBoundsStyle(i,e[0]),datum:e,group:i,interactive:!1}}function N(t,e,i,r){var o;if(!t.config.pointStyle)return;const n=null!=r?r:t.getY;for(const r of e){const e=t.resolveGroupColor(r.key);for(const a of r.data){let r=t.config.pointStyle(a);!r.fill&&e&&(r=Object.assign(Object.assign({},r),{fill:e}));const s=null!==(o=r.r)&&void 0!==o?o:3,c=t.getPointId?t.getPointId(a)+"":void 0,l=D(a,t.scales,t.getX,n,s,r,c);l&&i.push(l)}}}const $={blues:r.interpolateBlues,reds:r.interpolateReds,greens:r.interpolateGreens,viridis:r.interpolateViridis},B=new Map;class W{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,i=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=i?x(t.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!i}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],i=this.config.xAccessor,r="function"==typeof i?i(e):e[i||"x"],o=r instanceof Date,n="string"==typeof r&&r.length>=10&&!isNaN(new Date(r).getTime())&&isNaN(Number(r));if(this.xIsDate=o||n,n){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,r,o,n,a,s,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!==(r=l.xExtent[0])&&void 0!==r?r: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!==(a=l.yExtent[1])&&void 0!==a?a: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),i=new Map;for(const t of e)for(const e of t.data){const t=this.getX(e),r=this.getY(e);null==t||null==r||Number.isNaN(t)||Number.isNaN(r)||i.set(t,(i.get(t)||0)+r)}let r=0;for(const t of i.values())t>r&&(r=t);y=[0,r+(r>0?r*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,i,r,o){const n=p(t,e,i,r,o);if(0===n.size)return[0,0];let a=0;for(const t of n.values())t.total>a&&(a=t.total);return[0,a]}(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 i=0,r=0,o=0;for(const n of t){const t=e(n);null==t||Number.isNaN(t)||(o+=t,i>o&&(i=o),o>r&&(r=o))}return[i,r]}(u,this.getY),i=e-t,r=i>0?i*l.extentPadding:1;y=[Math.min(0,t-Math.abs(r)),Math.max(0,e+Math.abs(r))]}else if(!m&&y[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>y[1]&&(y[1]=e+i),y[0]>e-i&&(y[0]=e-i))}const t=y[1]-y[0],e=t>0?t*l.extentPadding:1,i=null===(s=l.yExtent)||void 0===s?void 0:s[0],r=null===(c=l.yExtent)||void 0===c?void 0:c[1];y=[null!=i?y[0]:y[0]-e,null!=r?y[1]:y[1]+e],"log"===l.yScaleType&&0>=y[0]&&d[0]>0&&(y[0]=null!=i?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 i="right"===l.arrowOfTime?[v,t.width-v]:[t.width-v,v];this.scales={x:e.scaleLinear().domain(g).range(i),y:e.scaleLinear().domain(y).range([t.height-v,v])}}else{const i="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(i)}}else{const i=(t,i,r)=>{if("log"===t){const t=[Math.max(i[0],1e-6),Math.max(i[1],1e-6)];return e.scaleLog().domain(t).range(r).clamp(!0)}return"time"===t?e.scaleTime().domain([new Date(i[0]),new Date(i[1])]).range(r):e.scaleLinear().domain(i).range(r)};this.scales={x:i(l.xScaleType,g,[v,t.width-v]),y:i(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>W.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,r=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]*=r;break;case"area":for(const e of t.topPath)e[0]*=i,e[1]*=r;for(const e of t.bottomPath)e[0]*=i,e[1]*=r;break;case"point":t.x*=i,t.y*=r;break;case"rect":case"heatcell":t.x*=i,t.y*=r,t.w*=i,t.h*=r;break;case"candlestick":t.x*=i,t.openY*=r,t.closeY*=r,t.highY*=r,t.lowY*=r}const o=this.scales.x.domain(),n=this.scales.y.domain(),a=this.scales.x.range(),s=this.scales.y.range(),c=(t,i,r)=>{if("log"===t){const t=[Math.max(i[0],1e-6),Math.max(i[1],1e-6)];return e.scaleLog().domain(t).range(r).clamp(!0)}return"time"===t?e.scaleTime().domain([new Date(i[0]),new Date(i[1])]).range(r):e.scaleLinear().domain(i).range(r)},l=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(t.width,t.height)/2-1)),u=s[1]>s[0];this.scales={x:c(this.config.xScaleType,o,a[0]>a[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 i;const{config:o,scales:n}=this;if(!n||0===e.length)return[];const a={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 i;const r=t.groupData(e),o=[],n=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 r){const i=T(t,e.data,e.key);i&&o.push(i)}for(const e of r){const i=t.resolveLineStyle(e.key,e.data[0]),r=O(e.data,t.scales,t.getX,t.getY,i,e.key);n&&n.length>0&&(r.colorThresholds=n),t.config.curve&&"linear"!==t.config.curve&&(r.curve=t.config.curve),t.config.lineGradient&&(r.strokeGradient=t.config.lineGradient),o.push(r)}return N(t,r,o),o}(a,e);case"area":return function(t,e){const i=t.groupData(e),r=[],o=t.scales.y.domain()[0],n=t.getY0?e=>{const i=t.getY0(e);return null==i?o:i}:void 0;for(const e of i){const i=t.resolveAreaStyle(e.key,e.data[0]),a=L(e.data,t.scales,t.getX,t.getY,o,i,e.key,n);t.config.gradientFill&&(a.fillGradient=t.config.gradientFill),t.config.curve&&"linear"!==t.config.curve&&(a.curve=t.config.curve),t.config.lineGradient&&(a.strokeGradient=t.config.lineGradient),r.push(a)}return N(t,i,r),r}(a,e);case"mixed":return function(t,e){const i=t.groupData(e),r=[],o=t.config.areaGroups||new Set,n=t.scales.y.domain()[0],a=t.getY0?e=>{const i=t.getY0(e);return null==i?n:i}:void 0;for(const e of i)if(o.has(e.key)){const i=t.resolveAreaStyle(e.key,e.data[0]),o=L(e.data,t.scales,t.getX,t.getY,n,i,e.key,a);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),r.push(o)}else{const i=t.resolveLineStyle(e.key,e.data[0]),o=O(e.data,t.scales,t.getX,t.getY,i,e.key);t.config.curve&&"linear"!==t.config.curve&&(o.curve=t.config.curve),t.config.lineGradient&&(o.strokeGradient=t.config.lineGradient),r.push(o)}return N(t,i,r),r}(a,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 r=t.config.curve&&"linear"!==t.config.curve?t.config.curve:void 0,{nodes:o,stackedTops:n}=function(t,e,i,r,o,n,a){var s;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 o of e.data){const e=i(o),n=r(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 i=0;for(const r of t)i+=(null===(s=u.get(r.key))||void 0===s?void 0:s.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),r=[],s=[],c=new Map;for(const i of l){let o=t.get(i)||0;const a=g.get(i);n&&(o/=h.get(i));const l=a+o,u=e.x(i);s.push([u,e.y(a)]),r.push([u,e.y(l)]),g.set(i,l),c.set(i,l)}d.set(i.key,c);const y={type:"area",topPath:r,bottomPath:s,style:o(i.key,i.data[0]),datum:i.data,group:i.key};a&&(y.curve=a),f.push(y)}return{nodes:f,stackedTops:d}}(i,t.scales,t.getX,t.getY,(e,i)=>t.resolveAreaStyle(e,i),t.config.normalize,r),a=o;if(t.config.pointStyle){const e=new WeakMap;for(const r of i){const i=n.get(r.key);if(i)for(const o of r.data){const r=t.getX(o),n=t.getY(o);null==r||Number.isNaN(r)||null==n||Number.isNaN(n)||!i.has(r)||e.set(o,i.get(r))}}const r=i=>{var r;return null!==(r=e.get(i))&&void 0!==r?r:t.getY(i)};N(t,i,a,r)}return a}(a,e);case"scatter":case"bubble":return function(t,e){const i=[],r="bubble"===t.config.chartType?10:5,o=t.config.sizeRange||[3,15];let n=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 r of i)t>r&&(t=r),r>e&&(e=r);n=i=>t===e?(o[0]+o[1])/2:o[0]+(i-t)/(e-t)*(o[1]-o[0])}}const a=t.getColor?t.resolveColorMap(e):null;for(const o of e){let e=t.config.pointStyle?t.config.pointStyle(o):{fill:"#4e79a7",opacity:.8},s=e.r||r;if(n&&t.getSize){const e=t.getSize(o);null==e||Number.isNaN(e)||(s=n(e))}if(a&&t.getColor&&!e.fill){const i=t.getColor(o);i&&a.has(i)&&(e=Object.assign(Object.assign({},e),{fill:a.get(i)}))}const c=t.getPointId?t.getPointId(o)+"":void 0,l=D(o,t.scales,t.getX,t.getY,s,e,c);l&&i.push(l)}return i}(a,e);case"heatmap":return function(t,e,i){if(t.config.heatmapAggregation)return function(t,e,i){var r,o,n;const a=Math.max(1,Math.floor(null!==(r=t.config.heatmapXBins)&&void 0!==r?r:20)),s=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)/a,y=(d-f||1)/s,p=a*s;if(p>1e6)return[];const m=new Int32Array(p),v=new Float64Array(p);for(let i=0;e.length>i;i++){const r=e[i],o=t.getX(r),n=t.getY(r);if(!isFinite(o)||!isFinite(n))continue;const c=Math.min(Math.floor((o-u)/g),a-1),h=Math.min(Math.floor((n-f)/y),s-1);if(0>c||0>h)continue;const d=h*a+c;m[d]++;const p=l(r);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 w=k-b||1,A=i.width/a,S=i.height/s,_=t.config.showValues,E=t.config.heatmapValueFormat,P=[];for(let t=0;s>t;t++){const e=t*a;for(let i=0;a>i;i++){const r=e+i;if(0===m[r])continue;let o;switch(c){case"sum":o=v[r];break;case"mean":o=v[r]/m[r];break;default:o=m[r]}const n=(o-b)/w;P.push(j(i*A,(s-1-t)*S,A,S,`rgb(${220-(180*n+.5)|0},${220-(100*n+.5)|0},${255-(50*n+.5)|0})`,{xi:i,yi:t,value:o,count:m[r],sum:v[r]},_?{value:o,showValues:!0,valueFormat:E}:void 0))}}return P}(t,e,i);if(0===e.length)return[];const o=x(t.config.valueAccessor,"value"),n=v(t.config.xAccessor,"x"),a=v(t.config.yAccessor,"y"),s=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],r=n(i),o=a(i);l[t]=r,u[t]=o,s.has(r)||s.set(r,s.size),c.has(o)||c.set(o,c.size)}const h=s.size,f=c.size;if(0===h||0===f)return[];const d=Array.from(s.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),s.clear();for(let t=0;d.length>t;t++)s.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),w=new Map;let A=0;for(let t=0;e.length>t;t++){const i=e[t],r=s.get(l[t]),n=c.get(u[t]);if(void 0===r||void 0===n)continue;const a=o(i),f=n*h+r,d=w.get(f);let g;void 0!==d?g=d:(g=A++,w.set(f,g)),m[g]=f,b[g]=a,k[g]=i}let S=1/0,_=-1/0;for(let t=0;A>t;t++){const e=b[t];isFinite(e)&&(S>e&&(S=e),e>_&&(_=e))}if(!isFinite(S)||!isFinite(_))return[];const E=function(t){const e=t in $?t:"blues";let i=B.get(e);if(i)return i;i=Array(256);const o=$[e]||r.interpolateBlues;for(let t=0;256>t;t++)i[t]=o(t/255);return B.set(e,i),i}("string"==typeof t.config.colorScheme?t.config.colorScheme:"blues"),P=255/(_-S||1),M=i.width/h,O=i.height/f,L=t.config.showValues,D=t.config.heatmapValueFormat,z=[];for(let t=0;A>t;t++){const e=b[t];if(!isFinite(e))continue;const i=m[t],r=i%h;z.push(j(r*M,(f-1-(i-r)/h)*O,M,O,E[Math.min((e-S)*P+.5|0,255)],k[t],L?{value:e,showValues:!0,valueFormat:D}:void 0))}return z}(a,e,t);case"bar":{const t=function(t,e){var i;if(!t.config.binSize)return{nodes:[],binBoundaries:[]};const r=p(e,t.getX,t.getY,t.config.binSize,t.getCategory);if(0===r.size)return{nodes:[],binBoundaries:[]};let o=null;if(t.getCategory){const e=new Set;for(const t of r.values())for(const i of t.categories.keys())e.add(i);const i=t.config.barColors?Object.keys(t.config.barColors):[],n=new Set(i),a=Array.from(e).filter(t=>!n.has(t)).sort(),s=i.filter(t=>e.has(t)),c=s.join("\0")+""+a.join("\0");t.barCategoryCache&&t.barCategoryCache.key===c?o=t.barCategoryCache.order:(o=[...s,...a],t.barCategoryCache={key:c,order:o})}const n=[],a=t.scales,[s,c]=a.x.domain();for(const e of r.values()){const r=Math.max(e.start,s),l=Math.min(e.end,c);if(r>=l)continue;const u=a.x(r),h=a.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 r=0;for(const s of o){const o=e.categories.get(s)||0;if(0===o)continue;const c=a.y(r),l=a.y(r+o);n.push(z(g,Math.min(c,l),y,Math.abs(c-l),{fill:(null===(i=t.config.barColors)||void 0===i?void 0:i[s])||"#4e79a7"},{binStart:e.start,binEnd:e.end,total:e.total,category:s,categoryValue:o},s)),r+=o}}else{const t=a.y(0),i=a.y(e.total);n.push(z(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 r.values())l.add(t.start),l.add(t.end);return{nodes:n,binBoundaries:Array.from(l).sort((t,e)=>t-e)}}(a,e);return this._barCategoryCache=null!==(i=a.barCategoryCache)&&void 0!==i?i:null,this._binBoundaries=t.binBoundaries,t.nodes}case"swarm":return function(t,e){var i,r,o,n;const a=[],s=t.config.swarmStyle||{},c=null!==(i=s.radius)&&void 0!==i?i:3,l=null!==(r=s.fill)&&void 0!==r?r:"#007bff",u=null!==(o=s.opacity)&&void 0!==o?o:.7,h=s.stroke,f=s.strokeWidth;for(const i of e){const e=t.getX(i),r=t.getY(i);if(null==r||Number.isNaN(r))continue;const o=t.scales.x(e),s=t.scales.y(r);let d=l;if(t.getCategory){const e=t.getCategory(i);d=(null===(n=t.config.barColors)||void 0===n?void 0:n[e])||d}const g={type:"point",x:o,y:s,r:c,style:{fill:d,opacity:u,stroke:h,strokeWidth:f},datum:i};t.getPointId&&(g.pointId=t.getPointId(i)+""),a.push(g)}return a}(a,e);case"waterfall":return function(t,e,i){var r,o,n;const a=[],s=t.scales,c=t.config.waterfallStyle,l=e.filter(e=>{const i=t.getY(e),r=t.getX(e);return null!=i&&!Number.isNaN(i)&&null!=r&&isFinite(r)});if(0===l.length)return a;const u=null!==(r=null==c?void 0:c.positiveColor)&&void 0!==r?r:"#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 r=l[e],o=t.getX(r),n=t.getY(r),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=s.x(o),v=0!==m?s.x(o+m):x+i.width/10,b=Math.min(x,v)+f/2,k=Math.max(x,v)-f/2-b;if(0>=k){y=p;continue}const w=s.y(y),A=s.y(p);a.push(z(b,Math.min(w,A),k,Math.abs(w-A),{fill:0>n?h:u,stroke:d,strokeWidth:g},Object.assign(Object.assign({},r),{baseline:y,cumEnd:p,delta:n,_connectorStroke:null==c?void 0:c.connectorStroke,_connectorWidth:null==c?void 0:c.connectorWidth}))),y=p}return a}(a,e,t);case"candlestick":return function(t,e){var i,r;if(!t.getHigh||!t.getLow||!t.scales)return[];const o=null!==(i=t.config.candlestickRangeMode)&&void 0!==i&&i;if(!(o||t.getOpen&&t.getClose))return[];const n=[],a=t.config.candlestickStyle||{},s=a.rangeColor||"#6366f1",c=o?s:a.upColor||"#28a745",l=o?s:a.downColor||"#dc3545",u=o?s:a.wickColor||"#333",h=a.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!==(r=a.bodyWidth)&&void 0!==r?r:0;if(!o&&null==a.bodyWidth&&f.length>1){let e=1/0;for(let i=1;f.length>i;i++){const r=Math.abs(t.scales.x(f[i])-t.scales.x(f[i-1]));r>0&&e>r&&(e=r)}d=e!==1/0?Math.max(2,Math.min(.6*e,20)):6}else o||null!=a.bodyWidth||(d=6);for(const i of e){const e=t.getX(i);if(null==e||Number.isNaN(e))continue;const r=t.getHigh(i),a=t.getLow(i);if(null==r||Number.isNaN(r)||null==a||Number.isNaN(a))continue;const s=o?r:t.getOpen(i),f=o?a:t.getClose(i);if(!o&&[s,f].some(t=>null==t||Number.isNaN(t)))continue;const g=f>=s,y={type:"candlestick",x:t.scales.x(e),openY:t.scales.y(s),closeY:t.scales.y(f),highY:t.scales.y(r),lowY:t.scales.y(a),bodyWidth:d,upColor:c,downColor:l,wickColor:u,wickWidth:h,isUp:g,datum:i};o&&(y.isRange=!0),n.push(y)}return n}(a,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?w(i,t,e):1}applyDecay(t,e){this.config.decay&&function(t,e,i){var r,o;const n=i.length;if(1>=n)return;const a=new Map;for(let t=0;i.length>t;t++)a.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 r=Array(e.length);let o=!1;for(let i=0;e.length>i;i++){const s=a.get(e[i]);null!=s?(r[i]=w(t,s,n),1>r[i]&&(o=!0)):r[i]=1}o&&(i._decayOpacities=r);continue}if("area"===i.type){const e=Array.isArray(i.datum)?i.datum:[],r=i.topPath?i.topPath.length:e.length;if(2>r)continue;if(e.length===r){const o=Array(r);let s=!1;for(let i=0;e.length>i;i++){const r=a.get(e[i]);null!=r?(o[i]=w(t,r,n),1>o[i]&&(s=!0)):o[i]=1}s&&(i._decayOpacities=o)}else{let o=1;for(const i of e){const e=a.get(i);if(null!=e){const i=w(t,e,n);o>i&&(o=i)}}if(1>o){const t=Array(r);t.fill(o),i._decayOpacities=t}}continue}const e=a.get(i.datum);if(null==e)continue;const s=w(t,e,n);if("heatcell"===i.type)i.style={opacity:s};else if("candlestick"===i.type)i._decayOpacity=s;else{const t=null!==(o=null===(r=i.style)||void 0===r?void 0:r.opacity)&&void 0!==o?o:1;i.style=Object.assign(Object.assign({},i.style),{opacity:t*s})}}}(this.config.decay,t,e)}applyPulse(t,e){this.config.pulse&&this.timestampBuffer&&function(t,e,i,r){var o,n;const a="undefined"!=typeof performance?performance.now():Date.now(),s=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;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 o=0;for(const i of e){const e=l.get(i);if(null==e)continue;const n=r.get(e);if(null==n)continue;const s=A(t,n,a);s>o&&(o=s)}o>0&&(i._pulseIntensity=o,i._pulseColor=s);continue}const e=l.get(i.datum);if(null==e)continue;const o=r.get(e);if(null==o)continue;const n=A(t,o,a);n>0&&(i._pulseIntensity=n,i._pulseColor=s,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 r="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(i=t.duration)&&void 0!==i?i:500,n=e.peek();return null!=n&&o>r-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,i,r){var o,n,a;i.clear(),r.clear();for(let s=0;e.length>s;s++){const c=e[s],l=M(t,c,s);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===(o=c.style)||void 0===o?void 0:o.opacity}):"candlestick"===c.type?i.set(l,{x:c.x,y:c.openY}):"line"===c.type?r.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&&r.set(l,{topPath:c.topPath.map(t=>[t[0],t[1]]),bottomPath:c.bottomPath.map(t=>[t[0],t[1]]),opacity:null===(a=c.style)||void 0===a?void 0:a.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}startTransition(){if(!this.config.transition)return;const t=function(t,e,i,r,o){var n,a,s,c,l,u,h,f,d,g,y,p,m,x,v,b,k,w,A,S,_,E,O,L,D,z,j,T;if(0===r.size&&0===o.size)return i;const N=null!==(n=e.duration)&&void 0!==n?n:300;if(i.exitNodes.length>0){const t=new Set(i.exitNodes);i.scene=i.scene.filter(e=>!t.has(e)),i.exitNodes=[]}let $=!1;const B=new Set,W=new Set;for(let e=0;i.scene.length>e;e++){const n=i.scene[e],A=M(t,n,e);if(!A)continue;if(n._transitionKey=A,"line"===n.type||"area"===n.type){const t=o.get(A);if(t){if(W.add(A),"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]];$=!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]];$=!0}n._targetOpacity=null!==(a=n.style.opacity)&&void 0!==a?a:1,n._startOpacity=null!==(c=null!==(s=t.opacity)&&void 0!==s?s: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}),$=!0;continue}const S=r.get(A);if("point"===n.type)if(S){B.add(A);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,$=!0)}else n._targetOpacity=null!==(f=n.style.opacity)&&void 0!==f?f:1,n.style=Object.assign(Object.assign({},n.style),{opacity:0}),$=!0;else if("rect"===n.type)if(S){B.add(A);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,$=!0)}else n._targetOpacity=null!==(p=n.style.opacity)&&void 0!==p?p:1,n.style=Object.assign(Object.assign({},n.style),{opacity:0}),$=!0;else if("heatcell"===n.type)if(S){B.add(A);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,$=!0)}else n._targetOpacity=null!==(w=null===(k=n.style)||void 0===k?void 0:k.opacity)&&void 0!==w?w:1,n.style=Object.assign(Object.assign({},n.style||{}),{opacity:0}),$=!0}for(const[t,e]of o)if(!W.has(t))if(t.startsWith("l:")&&e.path){const r={type:"line",path:e.path.map(t=>[t[0],t[1]]),group:t.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:null!==(A=e.opacity)&&void 0!==A?A:1},_targetOpacity:0,_transitionKey:t,datum:null};i.exitNodes.push(r),$=!0}else if(t.startsWith("a:")&&e.topPath&&e.bottomPath){const r={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};i.exitNodes.push(r),$=!0}for(const[t,e]of r)if(!B.has(t)){if(t.startsWith("p:")){const r={type:"point",x:e.x,y:e.y,r:null!==(_=e.r)&&void 0!==_?_:3,style:{opacity:null!==(E=e.opacity)&&void 0!==E?E:1},datum:null,_targetOpacity:0,_transitionKey:t};i.exitNodes.push(r)}else if(t.startsWith("r:")){const r={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!==(D=e.opacity)&&void 0!==D?D:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t};i.exitNodes.push(r)}else if(t.startsWith("h:")){const r={type:"heatcell",x:e.x,y:e.y,w:null!==(z=e.w)&&void 0!==z?z:0,h:null!==(j=e.h)&&void 0!==j?j:0,fill:"#999",datum:null,style:{opacity:null!==(T=e.opacity)&&void 0!==T?T:1},_targetOpacity:0,_transitionKey:t};i.exitNodes.push(r)}$=!0}return i.exitNodes.length>0&&(i.scene=[...i.scene,...i.exitNodes]),$&&(i.activeTransition={startTime:P(),duration:N}),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,r){var o,n,a,s,c;if(!i.activeTransition)return!1;const l=_(t,i.activeTransition),u=S(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?r.get(e):void 0,n=i?null!==(o=i.opacity)&&void 0!==o?o:1:0;t.style.opacity=E(n,t._targetOpacity,u)}if(void 0===t._targetX)continue;if(!e)continue;const i=r.get(e);if(!i)continue;t.x=E(i.x,t._targetX,u),t.y=E(i.y,t._targetY,u),void 0!==t._targetR&&void 0!==i.r&&(t.r=E(i.r,t._targetR,u))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const i=e?r.get(e):void 0,o=i?null!==(n=i.opacity)&&void 0!==n?n:1:0;t.style.opacity=E(o,t._targetOpacity,u)}if(void 0===t._targetX)continue;if(!e)continue;const i=r.get(e);if(!i)continue;t.x=E(i.x,t._targetX,u),t.y=E(i.y,t._targetY,u),void 0!==i.w&&(t.w=E(i.w,t._targetW,u)),void 0!==i.h&&(t.h=E(i.h,t._targetH,u))}else if("heatcell"===t.type){if(void 0!==t._targetOpacity){const i=e?r.get(e):void 0,o=i?null!==(a=i.opacity)&&void 0!==a?a:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:E(o,t._targetOpacity,u)})}if(void 0===t._targetX)continue;if(!e)continue;const i=r.get(e);if(!i)continue;t.x=E(i.x,t._targetX,u),t.y=E(i.y,t._targetY,u),void 0!==i.w&&(t.w=E(i.w,t._targetW,u)),void 0!==i.h&&(t.h=E(i.h,t._targetH,u))}else if("line"===t.type){if(void 0!==t._targetOpacity){const e=null!==(s=t._startOpacity)&&void 0!==s?s:0;t.style=Object.assign(Object.assign({},t.style),{opacity:E(e,t._targetOpacity,u)})}const e=t._prevPath,i=t._targetPath;if(e&&i&&e.length===t.path.length)for(let r=0;t.path.length>r;r++)t.path[r][0]=E(e[r][0],i[r][0],u),t.path[r][1]=E(e[r][1],i[r][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:E(e,t._targetOpacity,u)})}const e=t._prevTopPath,i=t._prevBottomPath,r=t._targetTopPath,o=t._targetBottomPath;if(e&&r&&e.length===t.topPath.length)for(let i=0;t.topPath.length>i;i++)t.topPath[i][0]=E(e[i][0],r[i][0],u),t.topPath[i][1]=E(e[i][1],r[i][1],u);if(i&&o&&i.length===t.bottomPath.length)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e][0]=E(i[e][0],o[e][0],u),t.bottomPath[e][1]=E(i[e][1],o[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(),r=i.join("\0");if(this._colorMapCache&&this._colorMapCache.key===r)return this._colorMapCache.map;const o=Array.isArray(this.config.colorScheme)?this.config.colorScheme:k,n=new Map;for(let t=0;i.length>t;t++)n.set(i[t],o[t%o.length]);return this._colorMapCache={key:r,map:n},n}resolveLineStyle(t,e){const i=this.config.lineStyle;if("function"==typeof i){const r=i(e||{},t);if(r&&!r.stroke&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},r),{stroke:e})}return r}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:this.resolveGroupColor(t)||"#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 r=this.config.lineStyle;if("function"==typeof r){const i=r(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}if(r&&"object"==typeof r)return{fill:r.fill||r.stroke||"#4e79a7",fillOpacity:null!==(i=r.fillOpacity)&&void 0!==i?i:.7,stroke:r.stroke||"#4e79a7",strokeWidth:r.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 i=Array.isArray(this.config.colorScheme)?this.config.colorScheme:k,r=i[this._groupColorMap.size%i.length];return this._groupColorMap.set(t,r),r}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");const e=new Set(Array.isArray(t)?t:[t]),i=this.getPointId,r=t=>e.has(i(t));if(this.timestampBuffer&&this.timestampBuffer.size>0){const t=this.timestampBuffer.toArray(),e=new Set;this.buffer.forEach((t,i)=>{r(t)&&e.add(i)}),this.timestampBuffer.clear();for(let i=0;t.length>i;i++)e.has(i)||this.timestampBuffer.push(t[i])}const o=this.buffer.remove(r);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 i=new Set(Array.isArray(t)?t:[t]),r=this.getPointId,o=new Set;this.buffer.forEach((t,e)=>{i.has(r(t))&&o.add(e)});const n=this.buffer.update(t=>i.has(r(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,i,r,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 a=!1;Object.assign(this.config,t);const s="chartType"in t&&t.chartType!==n.chartType||"runtimeMode"in t&&t.runtimeMode!==n.runtimeMode;if(s||void 0!==t.xAccessor||void 0!==t.yAccessor||void 0!==t.timeAccessor||void 0!==t.valueAccessor){const c=s||!m(null!==(e=t.xAccessor)&&void 0!==e?e:t.timeAccessor,null!==(i=n.xAccessor)&&void 0!==i?i:n.timeAccessor),l=s||!m(null!==(r=t.yAccessor)&&void 0!==r?r: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")),a=!0)}if("groupAccessor"in t&&!m(t.groupAccessor,n.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?b(this.config.groupAccessor):void 0,a=!0),"categoryAccessor"in t&&!m(t.categoryAccessor,n.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?b(this.config.categoryAccessor):void 0,a=!0),"sizeAccessor"in t&&!m(t.sizeAccessor,n.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?x(this.config.sizeAccessor,"size"):void 0,a=!0),"colorAccessor"in t&&!m(t.colorAccessor,n.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?b(this.config.colorAccessor):void 0,a=!0),"y0Accessor"in t&&!m(t.y0Accessor,n.y0Accessor)&&(this.getY0=this.config.y0Accessor?x(this.config.y0Accessor,"y0"):void 0,a=!0),"pointIdAccessor"in t&&!m(t.pointIdAccessor,n.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?b(this.config.pointIdAccessor):void 0,a=!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,a=!0}if(!a){const e=Object.keys(t).filter(t=>!t.endsWith("Accessor")&&"timeAccessor"!==t&&"valueAccessor"!==t);for(const i of e)if(t[i]!==n[i]){a=!0;break}}a&&(this.needsFullRebuild=!0)}}function R(t,e){var i=t.get(e);if(!i)throw Error("missing: "+e);return i}function F(t,e){var i,r=[],o=[],n=[],a={},s=[];function c(t){n[t]=!1,a.hasOwnProperty(t)&&Object.keys(a[t]).forEach(function(e){delete a[t][e],n[e]&&c(e)})}function l(t){var e,r,h=!1;for(o.push(t),n[t]=!0,e=0;s[t].length>e;e++)(r=s[t][e])===i?(u(i,o),h=!0):n[r]||(h=l(r));if(h)c(t);else for(e=0;s[t].length>e;e++){var f=a[r=s[t][e]];f||(a[r]=f={}),f[r]=!0}return o.pop(),h}function u(t,e){var i=[].concat(e).concat(t);r.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,r=function(t){for(var e=t.length,i=Array(e),r=Array(e),o=Array(e),n=Array(e),a=Array(e),s=Array(e),c=0;e>c;++c)i[c]=-1,r[c]=0,o[c]=!1,n[c]=0,a[c]=-1,s[c]=[];var l,u=0,h=[],f=[];function d(e){var c=[e],l=[e];for(i[e]=r[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>i[y]){i[y]=r[y]=u,o[y]=!0,u+=1,c.push(y),l.push(y);break}o[y]&&(r[e]=0|Math.min(r[e],r[y])),0>a[y]||s[e].push(a[y])}n[e]=g}else{if(r[e]===i[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(s[v]),x+=s[v].length,a[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>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),o=r.components.filter(function(t){return t.length>1}),n=1/0,a=0;o.length>a;a++)for(var s=0;o[a].length>s;s++)n>o[a][s]&&(n=o[a][s],i=a);var c=o[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:n,adjList:l}}i=0;for(var f=t.length;f>i;){var d=h(i);if(i=d.leastVertex,s=d.adjList){for(var g=0;s.length>g;g++)for(var y=0;s[g].length>y;y++){var p=s[g][y];n[+p]=!1,a[p]={}}l(i),i+=1}else i=f}return r}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 i=0;return t.target.targetLinks.forEach(function(t){i=t.circular?i+1:i}),1>=e&&1>=i}function X(t){return t.target.x0-t.source.x1}function q(t,e){var i=V(t),r=X(e)/Math.tan(i);return"up"==C(t)?t.y1-r:t.y1+r}function G(t,e){var i=V(t),r=X(e)/Math.tan(i);return"up"==C(t)?t.y1+r:t.y1-r}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 i=0;t.sourceLinks.forEach(function(t){i=t.circular&&!I(t,e)?i+1:i});var r=0;return t.targetLinks.forEach(function(t){r=t.circular&&!I(t,e)?r+1:r}),i+r}function tt(t){return t.target.depth}function et(t,e){return t.sourceLinks.length?t.depth:e-1}function it(t,e){return t.y0-e.y0}function rt(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 at(t,e){return ct(t.source,e.source)||t.index-e.index}function st(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?rt(t,e):it(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,i,r,n){let a=t;var s=Math.max(8,.15*(a.y1-a.y0));a.links.forEach(function(t){t.circular&&(t._circularWidth=Math.min(t.width,s))});var c=o.min(a.links,function(t){return t.source.y0});a.links.forEach(function(t){t.circular&&(t.circularPathData={})});var l=a.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(a.links.filter(function(t){return"top"==t.circularLinkType}),e,i),gt(a.links.filter(function(t){return"bottom"==t.circularLinkType}),e,i),a.links.forEach(function(t){if(t.circular){if(t.circularPathData.arcRadius=t._circularWidth+r,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=r+t._circularWidth/2,t.circularPathData.rightLargeArcRadius=r+t._circularWidth/2,t.circularPathData.leftSmallArcRadius=r+t._circularWidth/2,t.circularPathData.leftLargeArcRadius=r+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,s=t.circularLinkType,l=a.links.filter(function(t){return t.source.column==o&&t.circularLinkType==s});l.sort("bottom"==t.circularLinkType?rt:it);var u=0;l.forEach(function(e,o){e.circularLinkID==t.circularLinkID&&(t.circularPathData.rightSmallArcRadius=r+t._circularWidth/2+u,t.circularPathData.rightLargeArcRadius=r+t._circularWidth/2+o*i+u),u+=e._circularWidth||e.width}),o=t.target.column,(l=a.links.filter(function(t){return t.target.column==o&&t.circularLinkType==s})).sort("bottom"==t.circularLinkType?nt:ot),u=0,l.forEach(function(e,o){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=r+t._circularWidth/2+u,t.circularPathData.leftLargeArcRadius=r+t._circularWidth/2+o*i+u),u+=e._circularWidth||e.width}),"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=Math.max(a.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,i=t.y0,r=t.target.x0,o=t.y1,n=(e+r)/2;return"M"+e+","+i+"C"+n+","+i+" "+n+","+o+" "+r+","+o}(t)}),a}function gt(t,e,i){t.sort(lt);var r=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 a=0;r.length>a;a++){var s=r[a];if(s!==t&&s.circularPathData&&void 0!==s.circularPathData.verticalBuffer&&yt(t,s)){var c=s.circularPathData.verticalBuffer+(s._circularWidth||s.width)/2+i;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,i){var r=o.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});r.forEach(function(o,n){var a=o.length;if(e)o.sort(e);else if(n>0){var s=new Map;o.forEach(function(t,e){var i,r,o,n=(r=0,o=0,(i=t).targetLinks.forEach(function(t){if(!t.circular){var e=t.value||1;o+=U(t.source)*e,r+=e}}),i.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;o+=U(t.target)*e,r+=e}}),r>0?o/r:NaN);s.set(t,{bc:n,idx:e})}),o.sort(function(t,e){var i=s.get(t),r=s.get(e),o=i.bc,n=r.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)?i.idx-r.idx:1:-1:o-n})}else o.sort(function(t,e){return t.circularLinkType==e.circularLinkType?J(e,i)-J(t,i):"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==r.length-1&&1==a||0==e.depth&&1==a?(e.y0=t.y1/2-e.value*t.ky,e.y1=e.y0+e.value*t.ky):e.partOfCycle?0==J(e,i)?(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)/a*o,e.y1=e.y0+e.value*t.ky):(e.y0=(t.y1-t.y0)/2-a/2+o,e.y1=e.y0+e.value*t.ky)})})}function kt(t,e,i,r,n,a){var s=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=a;l>0;--l)u(c*=.99,i),h();function u(e,i){var r=s.length;s.forEach(function(n){var a=n.length,s=n[0].depth;n.forEach(function(n){var c;if(n.sourceLinks.length||n.targetLinks.length)if(n.partOfCycle&&J(n,i)>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==s&&1==a)n.y0=t.y1/2-(c=n.y1-n.y0)/2,n.y1=t.y1/2+c/2;else if(s==r-1&&1==a)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(){s.forEach(function(i){var o,a,s,c=t.y0,l=i.length;for(i.sort(e||ct),s=0;l>s;++s)(a=c-(o=i[s]).y0)>0&&(o.y0+=a,o.y1+=a),c=o.y1+r;if((a=c-r-t.y1)>0)for(c=o.y0-=a,o.y1-=a,s=l-2;s>=0;--s)(a=(o=i[s]).y1+n-c)>0&&(o.y0-=a,o.y1-=a),c=o.y0})}}function wt(t){t.nodes.forEach(function(t){t.sourceLinks.sort(st),t.targetLinks.sort(at)}),t.nodes.forEach(function(t){var e=t.y0,i=e,r=t.y1,o=r;t.sourceLinks.forEach(function(t){t.circular?(t.y0=r-t.width/2,r-=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=i+t.width/2,i+=t.width)})})}function At(){var t=0,e=0,i=1,r=1,n=24,a=8,s=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=i,d.y1=r,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 o.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 r=t.source,o=t.target;"object"!=typeof r&&(r=t.source=R(i,r)),"object"!=typeof o&&(o=t.target=R(i,o)),r.sourceLinks.push(t),o.targetLinks.push(t)})}(d,c),function(t,e){var i=0;if(null==e){for(var r=[],o=0;t.links.length>o;o++){var n=t.links[o],a=n.source.index,s=n.target.index;r[a]||(r[a]=[]),r[s]||(r[s]=[]),-1===r[a].indexOf(s)&&r[a].push(s)}var c=F(r);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,r=t.source.index;e===r||l[r]&&l[r][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,r=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:r>i?"top":"bottom","top"==o.circularLinkType?i++:r++,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,i){var r,o,n;if(null!=e){t.nodes.sort(function(t,i){return e(t)<e(i)?-1:1});var a=0,s=e(t.nodes[0]);t.nodes.forEach(function(t){a=e(t)==s?a:a+1,s=e(t)==s?s:e(t),t.column=a})}for(r=t.nodes,o=[],n=0;r.length;++n,r=o,o=[])r.forEach(function(t){t.depth=n,t.sourceLinks.forEach(function(t){0>o.indexOf(t.target)&&!t.circular&&o.push(t.target)})});for(r=t.nodes,o=[],n=0;r.length;++n,r=o,o=[])r.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?i(t,n):t.column})}(d,u,l);var g=a;if(null!==s){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,(r-e)*s/(p-1)))}(function(t,e,i){var r=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(r,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 a=o.max(t.nodes,function(t){return t.column});t.nodes.forEach(a>0?function(e){e.x0=t.x0+e.column*((t.x1-t.x0-i)/a),e.x1=e.x0+i}:function(e){e.x0=t.x0,e.x1=e.x0+i})})(d,g,n),bt(d,u,c),kt(d,u,c,g,g,h),wt(d),dt(d,c,f,10,8),bt(d,u,c),kt(d,u,c,g,g,h),wt(d),dt(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 r=i.links.filter(function(i){return H(i.source,e)==H(t,e)}),o=r.length;o>1&&r.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 i=q(e,t);return t.y1-i}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;r.forEach(function(t){t.y0=n+t.width/2,n+=t.width}),r.forEach(function(e,i){if("bottom"==e.circularLinkType){for(var n=i+1,a=0;o>n;n++)a+=r[n].width;e.y0=t.y1-a-e.width/2}})})}(d,c),function(t,e){let i=t;i.nodes.forEach(function(t){var r=i.links.filter(function(i){return H(i.target,e)==H(t,e)}),o=r.length;o>1&&r.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 i=G(e,t);return t.y0-i}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;r.forEach(function(t){t.y1=n+t.width/2,n+=t.width}),r.forEach(function(e,i){if("bottom"==e.circularLinkType){for(var n=i+1,a=0;o>n;n++)a+=r[n].width;e.y1=t.y1-a-e.width/2}})})}(d,c),function(t){var e=t.nodes,i=t.links,r=!1,n=!1;if(i.forEach(function(t){"top"==t.circularLinkType?r=!0:"bottom"==t.circularLinkType&&(n=!0)}),0==r||0==n){var a=o.min(e,function(t){return t.y0}),s=o.max(e,function(t){return t.y1}),c=(t.y1-t.y0)/(s-a);function l(e){return(e-a)/(s-a)*(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),dt(d,c,f,10,8)}(y),y}return y.update=function(t){return wt(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?(a=+t,y):a},y.nodePaddingRatio=function(t){return arguments.length?(s=+t,y):s},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],i=+o[1][0],r=+o[1][1],y):[[t,e],[i,r]]},y.size=function(o){return arguments.length?(t=e=0,i=+o[0],r=+o[1],y):[i-t,r-e]},y}W.QUADTREE_THRESHOLD=500;const St=t=>{let e,i,r,o,a,s,c,l,u;return"down"===t.direction?(e=t.y0-t.sankeyWidth/2,i=t.y1-t.sankeyWidth/2,r=t.y1+t.sankeyWidth/2,o=t.y0+t.sankeyWidth/2,a=t.source.x1,s=t.target.x0,c=n.interpolateNumber(a,s),l=c(.5),u=c(.5),`M${e},${a}C${e},${l} ${i},${u} ${i},${s}L${r},${s}C${r},${u} ${o},${l} ${o},${a}Z`):(e=t.source.x1,i=t.target.x0,c=n.interpolateNumber(e,i),r=c(.5),o=c(.5),a=t.y0-t.sankeyWidth/2,s=t.y1-t.sankeyWidth/2,l=t.y1+t.sankeyWidth/2,u=t.y0+t.sankeyWidth/2,`M${e},${a}C${r},${a} ${o},${s} ${i},${s}L${i},${l}C${o},${l} ${r},${u} ${e},${u}Z`)};function _t(t){var e;const i=t.sankeyWidth/2,r=(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,r=o.sourceY,n=o.targetX,a=o.targetY;if("object"!=typeof t.source||!t.source||"object"!=typeof t.target||!t.target)return null;const s=Math.max(15,Math.min(40,.33*(o.rightFullExtent-e))),c=Math.max(15,Math.min(40,.33*(n-o.leftFullExtent)));return`M${e},${r-i}L${e+s},${r-i}L${e+s},${r+i}L${e},${r+i}ZM${n},${a-i}L${n-c},${a-i}L${n-c},${a+i}L${n},${a+i}Z`}const n=o.sourceX,a=o.sourceY,s=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(r,15));return`M${n},${a-f*i}L${l},${a-f*i}L${l+r},${a-f*i+f*d}L${l+r},${h+f*r-f*d}L${l+r-d},${h+f*r}L${u-r+d},${h+f*r}L${u-r},${h+f*r-f*d}L${u-r},${c-f*i+f*d}L${u-r+d},${c-f*i}L${s},${c-f*i}L${s},${c+f*i}L${u+r},${c+f*i}L${u+r},${h-f*r}L${l-r},${h-f*r}L${l-r},${a+f*i}L${n},${a+f*i}Z`}const Et=new Set,Pt=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=Pt.get(t);if(i){const t=i.get(e);if(t)return t}else i=new Map,Pt.set(t,i);const r=new Proxy(t,{get(t,i,r){if("string"==typeof i&&!(i in t)&&t.data&&i in t.data){const t=`${e}:${i}`;Et.has(t)||(Et.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,r)}});return i.set(e,r),r}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,i,r){var o,n,a,s,c,l,u;if(0===t.length)return;const h="vertical"===i.orientation?"down":"right",f=i.nodeAlign||"justify",d=null!==(o=i.nodeWidth)&&void 0!==o?o:15,g=null!==(n=i.nodePaddingRatio)&&void 0!==n?n:.05,y=null!==(a=i.iterations)&&void 0!==a?a: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],[r[1],r[0]]]:[[0,0],[r[0],r[1]]];const v=At().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,i=1/0,o=-1/0;for(const r of p)t>r.x0&&(t=r.x0),r.x1>e&&(e=r.x1),i>r.y0&&(i=r.y0),r.y1>o&&(o=r.y1);for(const r of m){if(!r.circular||!r.circularPathData)continue;const n=r.circularPathData,a=(null!==(c=null!==(s=r._circularWidth)&&void 0!==s?s:r.width)&&void 0!==c?c:0)/2;t>n.leftFullExtent-a&&(t=n.leftFullExtent-a),n.rightFullExtent+a>e&&(e=n.rightFullExtent+a),i>n.verticalFullExtent-a&&(i=n.verticalFullExtent-a),n.verticalFullExtent+a>o&&(o=n.verticalFullExtent+a)}const n=e-t,a=o-i,u=r[0],h=r[1];if(n>0&&a>0&&(0>t||0>i||e>u||o>h)){const e=Math.min(u/n,h/a),r=-t*e+(u-n*e)/2,o=-i*e+(h-a*e)/2;for(const t of p)t.x0=t.x0*e+r,t.x1=t.x1*e+r,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 i=t.circularPathData;i.sourceX=i.sourceX*e+r,i.targetX=i.targetX*e+r,i.sourceY=i.sourceY*e+o,i.targetY=i.targetY*e+o,i.rightFullExtent=i.rightFullExtent*e+r,i.leftFullExtent=i.leftFullExtent*e+r,i.verticalFullExtent=i.verticalFullExtent*e+o,i.rightInnerExtent=i.rightInnerExtent*e+r,i.leftInnerExtent=i.leftInnerExtent*e+r,i.verticalRightInnerExtent=i.verticalRightInnerExtent*e+o,i.verticalLeftInnerExtent=i.verticalLeftInnerExtent*e+o,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,r="object"==typeof e&&null!==e?e.id:e+"",o="object"==typeof i&&null!==i?i.id:i+"",n=k.get(t._edgeKey?t._edgeKey:`${r}\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(r),i=b.get(o);e&&(n.source=e),i&&(n.target=i)}}},buildScene(t,e,i,o){var n,a,s,c;const l="vertical"===i.orientation?"down":"right",u=i.nodeStyle,h=i.edgeStyle,f=null!==(n=i.edgeOpacity)&&void 0!==n?n:.5,d=i.edgeColorBy||"source",g=Array.isArray(i.colorScheme)?i.colorScheme:r.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,i=e.y1-e.y0;if(0>=t||0>=i)continue;const r=u?u(Mt(e,"nodeStyle")):{},o={fill:r.fill||y.get(e.id)||"#4d430c",stroke:r.stroke,strokeWidth:r.strokeWidth,opacity:r.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:i,h:t,style:o,datum:e,id:e.id,label:e.id}:{type:"rect",x:e.x0,y:e.y0,w:t,h:i,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,i="object"==typeof t.target?t.target:null;if(!e||!i)continue;let r="#999";r="function"==typeof d?d(t)||r:"target"===d?v.get(i.id)||y.get(i.id)||r:v.get(e.id)||y.get(e.id)||r;const o=h?h(Mt(t,"edgeStyle")):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,i=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||r;m.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-i}L${e.sourceX+n},${e.sourceY-i}L${e.sourceX+n},${e.sourceY+i}L${e.sourceX},${e.sourceY+i}Z`,style:{fill:l,fillOpacity:null!==(a=o.fillOpacity)&&void 0!==a?a: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-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!==(s=o.fillOpacity)&&void 0!==s?s: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||r,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!==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,r=i.y1-i.y0;if(0>=t||0>=r)continue;const n=e?e(i):i.id;if(!n)continue;let a,s,c;"down"===l?(a=i.y0+(i.y1-i.y0)/2,s=i.x1+14,c="middle"):(o[0]/2>i.x0+t/2?(a=i.x0-6,c="end"):(a=i.x1+6,c="start"),s=i.y0+r/2),x.push({x:a,y:s,text:n+"",anchor:c,baseline:"middle",fontSize:11})}}var k;return{sceneNodes:p,sceneEdges:m,labels:x}}},Dt={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,i,r){var o,n;if(0===t.length)return;const s=null!==(o=i.forceStrength)&&void 0!==o?o:.1,c=r[0]/2,l=r[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 r=zt(t.id,e,i);if(r.length>0){let e=0,i=0;for(const t of r)e+=t.x,i+=t.y;const o=jt(t.id),n=o%360*(Math.PI/180),a=10+o%20;t.x=e/r.length+a*Math.cos(n),t.y=i/r.length+a*Math.sin(n)}else{const e=jt(t.id),i=e%360*(Math.PI/180),r=15+e%30;t.x=c+r*Math.cos(i),t.y=l+r*Math.sin(i)}}}else{const e=2.399963229728653;for(let i=0;t.length>i;i++){const r=t[i];if(null==r.x||null==r.y||0===r.x&&0===r.y){const t=10*Math.sqrt(i+.5),o=i*e;r.x=c+t*Math.cos(o),r.y=l+t*Math.sin(o)}}}const g=null!==(n=i.iterations)&&void 0!==n?n:Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),y=0===i.iterations?0:d?40:g,p=Tt(i.nodeSize,i.nodeSizeRange,t),m=t=>p(t);if(y>0){const i=a.forceLink().strength(t=>Math.min(2.5,t.weight?t.weight*s:s)).id(t=>t.id),r=a.forceSimulation().force("charge",a.forceManyBody().strength(t=>-25*m(t))).force("center",a.forceCenter(c,l).strength(.8)).force("x",a.forceX(c).strength(.15)).force("y",a.forceY(l).strength(.15));if(r.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}));r.force("link",i),r.force("link").links(t)}d?r.alpha(.3):.1>r.alpha()&&r.alpha(1),r.stop();for(let t=0;y>t;++t)r.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(r[0]-t,e.x)),e.y=Math.max(t,Math.min(r[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,i,o){var n,a,s;const c=i.nodeStyle,l=i.edgeStyle,u=Tt(i.nodeSize,i.nodeSizeRange,t),h=Array.isArray(i.colorScheme)?i.colorScheme:r.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")):{},r={fill:i.fill||f.get(e.id)||"#007bff",stroke:i.stroke||"#fff",strokeWidth:null!==(n=i.strokeWidth)&&void 0!==n?n:2,opacity:i.opacity};d.push({type:"circle",cx:e.x,cy:e.y,r:t,style:r,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 r=l?l(Mt(t,"edgeStyle")):{},o={stroke:r.stroke||"#999",strokeWidth:null!==(a=r.strokeWidth)&&void 0!==a?a:1,opacity:null!==(s=r.opacity)&&void 0!==s?s:.6};g.push({type:"line",x1:e.x,y1:e.y,x2:i.x,y2:i.y,style:o,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 r=u(Mt(i,"nodeSize"));y.push({x:i.x,y:i.y-r-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var m;return{sceneNodes:d,sceneEdges:g,labels:y}}};function zt(t,e,i){const r=[];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 a=null;if(e===t?a=n:n===t&&(a=e),a){const t=i.get(a);!t||0===t.x&&0===t.y||r.push({x:t.x,y:t.y})}}return r}function jt(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,r){var n,a;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const s=i||[5,20],c=r.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()=>s[0];const l=null!==(n=o.min(c))&&void 0!==n?n:0,u=null!==(a=o.max(c))&&void 0!==a?a:1;if(l===u)return()=>(s[0]+s[1])/2;const h=e.scaleLinear().domain([l,u]).range(s).clamp(!0);return e=>{var i;const r=null===(i=e.data)||void 0===i?void 0:i[t];return null==r||"number"!=typeof r?s[0]:h(r)}}const Nt=r.schemeCategory10,$t={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,i,r){if(0===t.length)return;const{padAngle:o=.01,groupWidth:n=20,sortGroups:a}=i,l=Math.min(r[0],r[1])/2,u=l-n,h=r[0]/2,f=r[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),r=y.get(e);if(void 0===i||void 0===r)continue;const o=d(t);m[i][r]=o}const x=s.chord().padAngle(o);a&&x.sortGroups(a);const v=x(m),b=v.groups,k=c.arc().innerRadius(u).outerRadius(l);for(const e of b){const i=t[e.index],r=k.centroid(e);i.x=r[0]+h,i.y=r[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),r=w.get(e);i&&(t.source=i),r&&(t.target=r)}const A=new Map;for(const t of e)A.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 i=t[e.source.index].id,r=t[e.target.index].id,o=A.get(`${i}\0${r}`)||A.get(`${r}\0${i}`);o&&(o.chordData=e)}},buildScene(t,e,i,r){var o,n;const{groupWidth:a=20,edgeOpacity:c=.5}=i,l=Math.min(r[0],r[1])/2,u=l-a,h=r[0]/2,f=r[1]/2,d=i.nodeStyle,g=i.edgeStyle,y=i.edgeColorBy||"source",p=Array.isArray(i.colorScheme)?i.colorScheme:Nt,m=new Map;t.forEach((t,e)=>{m.set(t.id,p[e%p.length])});const x=s.ribbon().radius(u),v=[],b=[],k=[];for(let e=0;t.length>e;e++){const i=t[e],r=i.arcData;if(!r)continue;let n;n=d?d(Mt(i,"nodeStyle")).fill||m.get(i.id)||p[e%p.length]:m.get(i.id)||p[e%p.length];const a=d?d(Mt(i,"nodeStyle")):{},s={fill:n,stroke:a.stroke||"black",strokeWidth:null!==(o=a.strokeWidth)&&void 0!==o?o:1,opacity:a.opacity};v.push({type:"arc",cx:h,cy:f,innerR:u,outerR:l,startAngle:r.startAngle-Math.PI/2,endAngle:r.endAngle-Math.PI/2,style:s,datum:i,id:i.id,label:i.id})}for(const t of e){const e=t.chordData;if(!e)continue;const i=x(e);if(!i)continue;const r=Bt(i,h,f);let o="#999";if(g)o=g(Mt(t,"edgeStyle")).fill||o;else{const e="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;"target"===y&&i?o=m.get(i.id)||o:e&&(o=m.get(e.id)||o)}const a=g?g(Mt(t,"edgeStyle")):{},s={fill:o,fillOpacity:null!==(n=a.fillOpacity)&&void 0!==n?n:c,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity};b.push({type:"ribbon",pathD:r,style:s,datum:t})}if(!1!==i.showLabels){const e=(w=i.nodeLabel)?"function"==typeof w?w:t=>t[w]||t.id:null,r=l+12;for(const i of t){const t=i.arcData;if(!t)continue;const o=e?e(i):i.id;if(!o)continue;const n=(t.startAngle+t.endAngle)/2,a=n-Math.PI/2;k.push({x:h+Math.cos(a)*r,y:f+Math.sin(a)*r,text:o+"",anchor:n>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var w;return{sceneNodes:v,sceneEdges:b,labels:k}}};function Bt(t,e,i){const r=t.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!r)return t;const o=[];let n=0;for(;r.length>n;){const t=r[n];if("M"===t||"L"===t)for(o.push(t),n++;r.length>n&&!isNaN(Number(r[n]));)o.push(Number(r[n])+e+""),n++,r.length>n&&!isNaN(Number(r[n]))&&(o.push(Number(r[n])+i+""),n++);else if("C"===t)for(o.push(t),n++;r.length>n&&!isNaN(Number(r[n]));)for(let t=0;3>t&&r.length>n&&!isNaN(Number(r[n]));t++)o.push(Number(r[n])+e+""),n++,r.length>n&&!isNaN(Number(r[n]))&&(o.push(Number(r[n])+i+""),n++);else if("Q"===t)for(o.push(t),n++;r.length>n&&!isNaN(Number(r[n]));)for(let t=0;2>t&&r.length>n&&!isNaN(Number(r[n]));t++)o.push(Number(r[n])+e+""),n++,r.length>n&&!isNaN(Number(r[n]))&&(o.push(Number(r[n])+i+""),n++);else if("A"===t)for(o.push(t),n++;r.length>n&&!isNaN(Number(r[n]));)o.push(r[n++]),r.length>n&&o.push(r[n++]),r.length>n&&o.push(r[n++]),r.length>n&&o.push(r[n++]),r.length>n&&o.push(r[n++]),r.length>n&&(o.push(Number(r[n])+e+""),n++),r.length>n&&(o.push(Number(r[n])+i+""),n++);else"Z"===t||"z"===t?(o.push(t),n++):(o.push(r[n]),n++)}return o.join(" ")}const Wt=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Rt(t){const[e,i,r]=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*r>150?"#222":"#fff"}function Ft(t,e,i){const r=e.nodeIDAccessor;return"function"==typeof r?r(t.data)+"":"string"==typeof r&&void 0!==t.data[r]?t.data[r]+"":void 0!==t.data.name?t.data.name+"":void 0!==t.data.id?t.data.id+"":"node-"+i}function Ct(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,r,o){if("horizontal"===o){const o=(t+i)/2;return`M ${t},${e} C ${o},${e} ${o},${r} ${i},${r}`}if("radial"===o){const o=(t+i)/2;return`M ${t},${e} Q ${o},${e} ${o},${(e+r)/2} T ${i},${r}`}{const o=(e+r)/2;return`M ${t},${e} C ${t},${o} ${i},${o} ${i},${r}`}}const Yt={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,i,r){var o;const n=i.__hierarchyRoot;if(!n)return;const a=i.chartType,s=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(n,s);u.sum(c),u.sort((t,e)=>{var i,r;return(null!==(i=e.value)&&void 0!==i?i:0)-(null!==(r=t.value)&&void 0!==r?r:0)});const[h,f]=r;switch(a){case"tree":!function(t,e,i,r){const o=e.treeOrientation||"vertical",n=l.tree();n.size("horizontal"===o?[r,i]:"radial"===o?[2*Math.PI,Math.min(i,r)/2*.8]:[i,r]),n(t)}(u,i,h,f);break;case"cluster":!function(t,e,i,r){const o=e.treeOrientation||"vertical",n=l.cluster();n.size("horizontal"===o?[r,i]:"radial"===o?[2*Math.PI,Math.min(i,r)/2*.8]:[i,r]),n(t)}(u,i,h,f);break;case"treemap":!function(t,e,i,r){var o,n;const a=null!==(o=e.padding)&&void 0!==o?o:4,s=null!==(n=e.paddingTop)&&void 0!==n?n:0,c=l.treemap().size([i,r]).tile(l.treemapBinary).padding(a);s>0&&c.paddingTop(s),c(t)}(u,i,h,f);break;case"circlepack":!function(t,e,i,r){var o;const n=null!==(o=e.padding)&&void 0!==o?o:4;l.pack().size([i,r]).padding(n)(t)}(u,i,h,f);break;case"partition":!function(t,e,i,r){var o;l.partition().size([i,r]).padding(null!==(o=e.padding)&&void 0!==o?o: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 r=d[e],n={id:Ft(r,i,e),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(o=r.value)&&void 0!==o?o:0,depth:r.depth,data:r.data,createdByFrame:!0};"tree"===a||"cluster"===a?Xt(n,r,i):"treemap"===a||"partition"===a?qt(n,r):"circlepack"===a&&Gt(n,r),n.__hierarchyNode=r,t.push(n),g.set(r,n)}if("tree"===a||"cluster"===a)for(const t of d)if(t.parent){const i=g.get(t.parent),r=g.get(t);i&&r&&e.push({source:i,target:r,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,i,r){const o=i.nodeStyle||(()=>({})),n=i.edgeStyle||(()=>({}));switch(i.chartType){case"tree":case"cluster":return function(t,e,i,r,o,n){var a,s,c,l,u;const h=[],f=[],d=[],g=i.treeOrientation||"vertical",y="radial"===g,p=r[0]/2,m=r[1]/2,x="number"==typeof(v=i.nodeSize)?v:5;var v;for(const e of t){let t=e.x,r=e.y;y&&(t+=p,r+=m);const n=o(Mt(e,"nodeStyle"));let s=n.fill||"#4d430c";i.colorByDepth&&void 0!==e.depth&&(s=Wt[e.depth%Wt.length]);const c={fill:s,stroke:n.stroke||"#fff",strokeWidth:null!==(a=n.strokeWidth)&&void 0!==a?a:1,opacity:n.opacity};h.push({type:"circle",cx:t,cy:r,r:x,style:c,datum:e,id:e.id,label:e.id,depth:e.depth})}const b=null!==(s=i.edgeOpacity)&&void 0!==s?s:.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 r=e.x,o=e.y,a=i.x,s=i.y;y&&(r+=p,o+=m,a+=p,s+=m);const u=It(r,o,a,s,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!==i.showLabels){const e=Ct(i.nodeLabel);for(const i of t){const t=e?e(i):i.id;if(!t)continue;let r,o,n,a=i.x,s=i.y;if(y&&(a+=p,s+=m),y){const t=a-p,e=s-m,i=Math.sqrt(t*t+e*e);i>0?(r=a+t/i*10,o=s+e/i*10,n=0>t?"end":"start"):(r=a,o=s-12,n="middle")}else"horizontal"===g?((null===(u=i.data)||void 0===u?void 0:u.children)&&0!==i.data.children.length?(r=a-x-6,n="end"):(r=a+x+6,n="start"),o=s):(r=a,o=s+x+14,n="middle");d.push({x:r,y:o,text:t+"",anchor:n,baseline:"middle",fontSize:11})}}return{sceneNodes:h,sceneEdges:f,labels:d}}(t,e,i,r,o,n);case"treemap":case"partition":return function(t,e,i,r){var o,n;const a=[],s=[];for(const i of t){const t=i.x1-i.x0,n=i.y1-i.y0;if(0>=t||0>=n)continue;const s=r(Mt(i,"nodeStyle"));let c=s.fill||"#4d430c";e.colorByDepth&&void 0!==i.depth&&(c=Wt[i.depth%Wt.length]);const l={fill:c,stroke:s.stroke||"#fff",strokeWidth:null!==(o=s.strokeWidth)&&void 0!==o?o:1,opacity:s.opacity};a.push({type:"rect",x:i.x0,y:i.y0,w:t,h:n,style:l,datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==e.showLabels){const i=Ct(e.nodeLabel),o=e.labelMode||"leaf",a="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(!a){if("leaf"===o&&!u)continue;if("parent"===o&&u)continue}const h=i?i(c):c.id;if(!h)continue;if((u?30:40)>t||(u?16:14)>l)continue;let f=r(Mt(c,"nodeStyle")).fill||"#4d430c";e.colorByDepth&&void 0!==c.depth&&(f=Wt[c.depth%Wt.length]);const d=Rt(f);s.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:a,sceneEdges:[],labels:s}}(t,i,0,o);case"circlepack":return function(t,e,i,r){var o,n,a,s,c;const l=[],u=[];for(const i of t){const t=null!==(o=i.__radius)&&void 0!==o?o:5;if(0>=t)continue;const s=r(Mt(i,"nodeStyle"));let c=s.fill||"#4d430c";e.colorByDepth&&void 0!==i.depth&&(c=Wt[i.depth%Wt.length]);const u={fill:c,stroke:s.stroke||"#fff",strokeWidth:null!==(n=s.strokeWidth)&&void 0!==n?n:1,opacity:null!==(a=s.opacity)&&void 0!==a?a:.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=Ct(e.nodeLabel);for(const o of t){const t=null!==(s=o.__radius)&&void 0!==s?s:5,n=i?i(o):o.id;if(!n)continue;if(15>t)continue;const a=!((null===(c=o.data)||void 0===c?void 0:c.children)&&o.data.children.length>0);let l=r(Mt(o,"nodeStyle")).fill||"#4d430c";if(e.colorByDepth&&void 0!==o.depth&&(l=Wt[o.depth%Wt.length]),a){const e=Rt(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,i,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Xt(t,e,i){const r=i.treeOrientation||"vertical";if("radial"===r){const i=e.x,r=e.y;t.x=r*Math.cos(i-Math.PI/2),t.y=r*Math.sin(i-Math.PI/2)}else"horizontal"===r?(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 qt(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 Gt(t,e){var i;const r=null!==(i=e.r)&&void 0!==i?i:0;t.x=e.x,t.y=e.y,t.x0=e.x-r,t.x1=e.x+r,t.y0=e.y-r,t.y1=e.y+r,t.width=2*r,t.height=2*r,t.__radius=r}function Vt(t){const e=t;return e.__orbitState||(e.__orbitState={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()}),e.__orbitState}const Ht={sankey:Lt,force:Dt,chord:$t,tree:Yt,cluster:Yt,treemap:Yt,circlepack:Yt,partition:Yt,orbit:{supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(t,e,i,r){const o=i.__hierarchyRoot;o&&function(t,e,i,r,o){var n,a;const s=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!==(n=i.orbitSize)&&void 0!==n?n:2.95,f=null!==(a=i.orbitEccentricity)&&void 0!==a?a:1,d="number"==typeof h?()=>h:h,g="number"==typeof f?()=>f:f,y=Vt(i);y.metaMap.clear(),r.length=0,o.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 x=e[0]/2,v=e[1]/2,b=Math.min(e[0],e[1])/2*.85,k=m(l(t));r.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,i,n,a,h,f,p){const x=s(e);if(!(null==x?void 0:x.length))return;const v=x.length;let b=0,k=0,w=0;for(;v>k;)k+=u[Math.min(w,u.length-1)],w++,b++;let A=0;for(let v=0;b>v;v++){const k=u[Math.min(v,u.length-1)],w=x.slice(A,A+k);if(!w.length)break;const S=(v+1)/b,_={id:i,depth:f,data:e,parentId:i},E=p?h/d(_)*S:h*S,P=c.pie().value(t=>{var e;return(null===(e=s(t))||void 0===e?void 0:e.length)?4:1}).sort(null),M=P(w),O=g(_);for(let e=0;w.length>e;e++){const s=(M[e].startAngle+M[e].endAngle)/2,c=w[e],u=m(l(c)),h=n+E*Math.sin(s),d=a+E*Math.cos(s)*O;r.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:E,angle:s,depth:f,parentId:i,eccentricity:O}),o.push({source:i,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:i,target:u}}),t(c,u,h,d,E,f+1,!0)}A+=k}}(t,k,x,v,b,1,!1)}(o,r,i,t,e)},buildScene(t,e,i,r){var o,n,a,s,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=Vt(i),r=new Map;for(const e of t)r.set(e.id,e);const o=new Map;for(const[,t]of e.metaMap){if(!t.parentId)continue;const e=r.get(t.parentId);if(!e)continue;const i=`${t.parentId}:${t.ring}`;o.has(i)||o.set(i,{parentX:e.x,parentY:e.y,ring:t.ring,ecc:t.eccentricity})}const n=48,a={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:t,parentY:e,ring:i,ecc:r}]of o)for(let o=0;n>o;o++){const s=o/n*Math.PI*2,c=(o+1)/n*Math.PI*2;d.push({type:"line",x1:t+i*Math.sin(s),y1:e+i*Math.cos(s)*r,x2:t+i*Math.sin(c),y2:e+i*Math.cos(c)*r,style:a,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")):{},r={fill:i.fill||"#6366f1",stroke:i.stroke||"#fff",strokeWidth:null!==(o=i.strokeWidth)&&void 0!==o?o:1,opacity:null!==(n=i.opacity)&&void 0!==n?n:0===(null!==(a=e.depth)&&void 0!==a?a:0)?1:.85};f.push({type:"circle",cx:e.x,cy:e.y,r:t,style:r,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 r="function"==typeof e?e(i):e&&null!==(c=null===(s=i.data)||void 0===s?void 0:s[e])&&void 0!==c?c:i.id;g.push({x:i.x,y:i.y+t+12,text:r+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:f,sceneEdges:d,labels:g}},tick:(t,e,i,r,o)=>!1!==i.orbitAnimated&&(function(t,e){var i,r;const o=Vt(e),n=null!==(i=e.orbitSpeed)&&void 0!==i?i:.25,a=null!==(r=e.orbitRevolution)&&void 0!==r?r: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),s=(("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 i=l.get(t.parentId);if(!i)continue;const r=t.angle+s*c*a({id:e.id,depth:t.depth,data:e.data,parentId:t.parentId});e.x=i.x+t.ring*Math.sin(r),e.y=i.y+t.ring*Math.cos(r)*t.eccentricity,e.x0=e.x,e.x1=e.x,e.y0=e.y,e.y1=e.y}}(t,i),!0)}};function Zt(t,e){const{columns:i,config:r,resolvePieceStyle:o}=t,n=[],a=Math.min(e.width,e.height)/2-4,s="donut"===r.chartType?r.innerRadius||60:0,c=-Math.PI/2+(r.startAngle||0)*Math.PI/180,l=null!=r.sweepAngle?r.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,r=o(t.pieceData[0],t.name);n.push({type:"wedge",cx:0,cy:0,innerRadius:s,outerRadius:a,startAngle:e,endAngle:i,style:r,datum:t.pieceData,category:t.name})}return n}function Kt(t){var e,i,r;const n=t.length,a=t[0],s=t[n-1];return{n:n,min:a,q1:null!==(e=o.quantile(t,.25))&&void 0!==e?e:a,median:null!==(i=o.quantile(t,.5))&&void 0!==i?i:(a+s)/2,q3:null!==(r=o.quantile(t,.75))&&void 0!==r?r:s,max:s,mean:t.reduce((t,e)=>t+e,0)/n}}const Ut={bar:function(t,e){const{scales:i,columns:r,config:o,getR:n,getStack:a,resolvePieceStyle:s}=t,{r:c,projection:l}=i,u=[],h="vertical"===l,f="horizontal"===l,d=o.normalize,g=[];if(a){const t=new Set;for(const e of Object.values(r))for(const i of e.pieceData){const e=a(i);t.has(e)||(t.add(e),g.push(e))}}else g.push("_default");for(const t of Object.values(r)){const e=new Map;for(const i of t.pieceData){const t=a?a(i):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const r=e.get(t);r.total+=n(i),r.pieces.push(i)}let i=0;if(d)for(const t of e.values())i+=Math.abs(t.total);let r=0,o=0;for(const n of g){const l=e.get(n);if(!l)continue;let g=l.total;d&&i>0&&(g/=i);const y=s(l.pieces[0],a?n: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?o:r+g),i=0>g?c(o+g)-c(o):c(r)-c(r+g);u.push(z(t.x,e,t.width,Math.abs(i),y,p,n)),0>g?o+=g:r+=g}else if(f){const e=c(0>g?o+g:r),i=0>g?c(o)-c(o+g):c(r+g)-c(r);u.push(z(e,t.x,Math.abs(i),t.width,y,p,n)),0>g?o+=g:r+=g}}}return u},clusterbar:function(t,e){const{scales:i,columns:r,getR:o,getGroup:n,resolvePieceStyle:a}=t,{r:s,projection:c}=i,l=[],u="vertical"===c,h=[],f=new Set;for(const t of Object.values(r))for(const e of t.pieceData){const t=n?n(e):"_default";f.has(t)||(f.add(t),h.push(t))}const d=h.length||1;for(const t of Object.values(r)){const e=t.width/d,i=.2*e,r=e-i,c=new Map;for(const e of t.pieceData){const t=n?n(e):"_default";c.has(t)||c.set(t,[]),c.get(t).push(e)}for(let n=0;h.length>n;n++){const f=c.get(h[n])||[];for(const c of f){const f=o(c),d=a(c,h[n]);if(u){const o=t.x+n*e+i/2,a=s(0),u=s(f);l.push(z(o,Math.min(a,u),r,Math.abs(a-u),d,c,h[n]))}else{const o=t.x+n*e+i/2,a=s(0),u=s(f);l.push(z(Math.min(a,u),o,Math.abs(u-a),r,d,c,h[n]))}}}}return l},point:function(t,e){var i,r;const{scales:o,columns:n,getR:a,multiScales:s,resolvePieceStyle:c}=t,{r:l,projection:u}=o,h=[],f="vertical"===u,d="radial"===u,g=s.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!==(i=e.__rIndex)&&void 0!==i?i:0,n=null!==(r=e.__rValue)&&void 0!==r?r:a(e),u=g&&s[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,i=u(n);v=Math.cos(e)*i,b=Math.sin(e)*i}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:i,columns:r,getR:o,resolvePieceStyle:n}=t,{r:a,projection:s}=i,c=[],l="vertical"===s;for(const t of Object.values(r)){const e=t.width/2;for(let i=0;t.pieceData.length>i;i++){const r=t.pieceData[i],s=o(r),u=n(r,t.name),h=u.r||4,f=(7919*i%100/100-.5)*e*.8,d=l?t.middle+f:a(s),g=l?a(s):t.middle+f;c.push({type:"point",x:d,y:g,r:h,style:u,datum:r})}}return c},pie:Zt,donut:Zt,boxplot:function(t,e){var i,r,n,a,s;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=o.quantile(e,.25))&&void 0!==i?i:c,g=null!==(r=o.quantile(e,.5))&&void 0!==r?r:(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,w=null!==(a=e.find(t=>t>=b))&&void 0!==a?a:c,A=null!==(s=[...e].reverse().find(t=>k>=t))&&void 0!==s?s:l,S=f(t.pieceData[0],t.name),_=[];if(m)for(const e of t.pieceData){const i=h(e);if(b>i||i>k){const r=p?t.middle:d(i),o=p?d(i):t.middle;_.push({px:r,py:o,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(x),maxPos:d(A),stats:{n:e.length,min:w,q1:u,median:g,q3:x,max:A,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 i,r,n;const{scales:a,columns:s,config:c,getR:l,resolveSummaryStyle:u}=t,{r:h,projection:f}=a,d=[],g="vertical"===f,y=c.bins||20,p=!1!==c.showIQR;for(const t of Object.values(s)){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 a=e[0],s=e[e.length-1],c=(s-a)/y||1,f=Array(y).fill(0);for(const t of e)f[Math.min(Math.floor((t-a)/c),y-1)]++;const m=Math.max(...f,1),x=t.width/2*.9;let v="";if(g){v=`M ${t.middle} ${h(a)}`;for(let e=0;y>e;e++){const i=h(a+(e+.5)*c);v+=` L ${t.middle+f[e]/m*x} ${i}`}v+=` L ${t.middle} ${h(s)}`;for(let e=y-1;e>=0;e--){const i=h(a+(e+.5)*c);v+=` L ${t.middle-f[e]/m*x} ${i}`}v+=" Z"}else{v=`M ${h(a)} ${t.middle}`;for(let e=0;y>e;e++)v+=` L ${h(a+(e+.5)*c)} ${t.middle-f[e]/m*x}`;v+=` L ${h(s)} ${t.middle}`;for(let e=y-1;e>=0;e--)v+=` L ${h(a+(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!==(i=o.quantile(e,.25))&&void 0!==i?i:a,l=null!==(r=o.quantile(e,.5))&&void 0!==r?r:(a+s)/2,u=null!==(n=o.quantile(e,.75))&&void 0!==n?n:s;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(s),h(a)),width:t.width,height:Math.abs(h(s)-h(a))}:{x:Math.min(h(a),h(s)),y:t.x,width:Math.abs(h(s)-h(a)),height:t.width};d.push({type:"violin",pathString:v,translateX:0,translateY:0,bounds:w,iqrLine:k,stats:Kt(e),style:b,datum:t.pieceData,category:t.name})}return d},histogram:function(t,e){var i;const{scales:r,columns:o,config:n,getR:a,resolveSummaryStyle:s}=t,{r:c}=r,l=[],u=n.bins||25,h=n.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(o)){const e=t.pieceData.map(t=>a(t)).filter(t=>null!=t&&!isNaN(t));if(0===e.length)continue;const i=null!=d&&isFinite(d)?d:Math.min(...e),r=null!=g&&isFinite(g)?g:Math.max(...e),o=(r-i)/u||1,n=Array(u).fill(0);for(const t of e)i>t||t>r||n[Math.min(Math.floor((t-i)/o),u-1)]++;const f=e.length,y=Math.max(...n,1),p=s(t.pieceData[0],t.name);for(let e=0;u>e;e++){if(0===n[e])continue;const r=(h?n[e]/f:n[e]/y)*t.width*.9,a=c(i+e*o),s=c(i+(e+1)*o);l.push(z(Math.min(a,s),t.x+t.width-r,Math.abs(s-a),r,p,{bin:e,count:n[e],range:[i+e*o,i+(e+1)*o],category:t.name},t.name))}}return l},ridgeline:function(t,e){var i;const{scales:r,columns:o,config:n,getR:a,resolveSummaryStyle:s}=t,{r:c,projection:l}=r,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=>a(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const r=e[0],o=e[e.length-1],n=(o-r)/h||1,l=Array(h).fill(0);for(const t of e)r>t||t>o||l[Math.min(Math.floor((t-r)/n),h-1)]++;const g=Math.max(...l,1),y=s(t.pieceData[0],t.name),p=t.width*d;let m="";if(f){const e=t.x+t.width;m=`M ${c(r)} ${e}`;for(let t=0;h>t;t++)m+=` L ${c(r+(t+.5)*n)} ${e-l[t]/g*p}`;m+=` L ${c(o)} ${e} Z`}else{const e=t.x;m=`M ${e} ${c(r)}`;for(let t=0;h>t;t++){const i=c(r+(t+.5)*n);m+=` L ${e+l[t]/g*p} ${i}`}m+=` L ${e} ${c(o)} Z`}const x=f?{x:Math.min(c(r),c(o)),y:t.x,width:Math.abs(c(o)-c(r)),height:t.width}:{x:t.x,y:Math.min(c(o),c(r)),width:t.width,height:Math.abs(c(o)-c(r))};u.push({type:"violin",pathString:m,translateX:0,translateY:0,bounds:x,stats:Kt(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:r,getRawRange:o,resolvePieceStyle:n}=t,{r:a,projection:s}=i,c=[],l="horizontal"===s;for(const t of Object.values(r))for(const e of t.pieceData){const i=o(e);if(!i)continue;const[r,s]=i,u=n(e,t.name);if(l){const i=a(Math.min(r,s)),o=a(Math.max(r,s));c.push(z(i,t.x,o-i,t.width,u,e,t.name))}else{const i=a(Math.max(r,s)),o=a(Math.min(r,s));c.push(z(t.x,i,t.width,o-i,u,e,t.name))}}return c},funnel:function(t,i){var r,o,n,a,s,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 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 w=0;for(const t of m){const e=new Map;let i=0;for(const r of t.pieceData){const t=f?f(r):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const o=e.get(t),n=h(r);o.total+=n,o.pieces.push(r),i+=n}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 r=0;x.length>r;r++){const o=t.groups.get(x[r]);o&&(r%2==0?e+=o.total:i+=o.total)}const r=Math.max(e,i);r>w&&(w=r)}if(0===w)return g;const A=new Map;for(const t of x){const e=k[0].groups.get(t);A.set(t,null!==(r=null==e?void 0:e.total)&&void 0!==r?r:0)}const S=k[0].stepTotal,_=b?.95*y:.9*i.width,E=e.scaleLinear().domain([0,w]).range([0,_]),P=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],i=e.col,r=0===t,o=i.width,u=.55*o,h=i.x+(o-u)/2,f=new Map;if(b){let t=0;for(const i of x){const r=e.groups.get(i);r&&(t+=E(r.total))}let o=y,n=y;for(let a=0;x.length>a;a++){const c=x[a],l=e.groups.get(c);if(!l)continue;const m=E(l.total),v=a%2==0,b=v?o:n-m;v?o+=m:n-=m;const k=d(l.pieces[0],c),w=null!==(s=A.get(c))&&void 0!==s?s:l.total,S=w>0?l.total/w*100:0,_=Object.assign(Object.assign({},l.pieces[0]),{__funnelValue:l.total,__funnelPercent:S,__funnelStep:i.name,__funnelIsFirstStep:r,__aggregateValue:l.total,__pieceCount:l.pieces.length,category:c});p&&(0===a&&(_.__funnelStepLabel=i.name,_.__funnelStepLabelX=y,_.__funnelStepLabelY=h,_.__funnelRowWidth=t),_.__funnelValueLabelX=b+m/2,_.__funnelValueLabelY=h,_.__funnelBarW=m),g.push(z(b,h,m,u,k,_,c)),f.set(c,{x:b,y:h,w:m,h:u})}}else{const t=e.stepTotal,o=E(t),s=y-o/2,c=x[0],l="_default"!==c,m=null!==(a=null===(n=e.groups.get(c))||void 0===n?void 0:n.pieces[0])&&void 0!==a?a:i.pieceData[0],v=l?c:i.name,b=d(m,v),k=S>0?t/S*100:0,w=Object.assign(Object.assign({},m),{__funnelValue:t,__funnelPercent:k,__funnelStep:i.name,__funnelIsFirstStep:r,category:l?c:i.name});p&&(w.__funnelStepLabel=i.name,w.__funnelStepLabelX=y,w.__funnelStepLabelY=h,w.__funnelRowWidth=o,w.__funnelValueLabelX=y,w.__funnelValueLabelY=h,w.__funnelBarW=o),g.push(z(s,h,o,u,b,w,v)),f.set(c,{x:s,y:h,w:o,h:u})}if(t>0&&M.size>0){const t=b?x:[x[0]];for(const r of t){const t=M.get(r),o=f.get(r);if(!t||!o)continue;const n=(()=>{const t=e.groups.get(r);return d(t?t.pieces[0]:i.pieceData[0],"_default"===r?i.name:r)})(),a={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:P},datum:null!==(l=null===(c=e.groups.get(r))||void 0===c?void 0:c.pieces[0])&&void 0!==l?l:i.pieceData[0],category:"_default"===r?i.name:r};g.push(a)}}M=f}return g},"bar-funnel":function(t,e){var i,r,o,n;const{columns:a,getR:s,getStack:c,resolvePieceStyle:l,scales:u}=t,h=[],f=u.o.domain().map(t=>a[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 r of t.pieceData){const t=c?c(r):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const o=e.get(t),n=s(r);o.total+=n,o.pieces.push(r),i+=n}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!==(r=null==e?void 0:e.total)&&void 0!==r?r: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],i=e.col,r=0===t,a=t>0?p[t-1]:null,s=i.width/v,c=s*b,u=s-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==a?void 0:a.groups.get(f),w=null!==(n=null==k?void 0:k.total)&&void 0!==n?n:p,A=r?0:Math.max(0,w-p),S=i.x+t*s+c/2,_=x(p),E=x(0)-_,P=l(g.pieces[0],y?f:i.name),M=Object.assign(Object.assign({},g.pieces[0]),{__barFunnelValue:p,__barFunnelPercent:b,__barFunnelIsFirstStep:r,__barFunnelIsDropoff:!1,__barFunnelStep:i.name,__barFunnelDropoffValue:A,__barFunnelCategory:"_default"===f?void 0:f,category:y?f:i.name,__barFunnelLabelX:S+u/2,__barFunnelLabelY:x(p+A)});if(h.push(z(S,_,u,E,P,M,y?f:i.name)),A>0){const t=x(p+A),e=_-t,r=Object.assign({},P),o=Object.assign(Object.assign({},g.pieces[0]),{__barFunnelValue:A,__barFunnelPercent:v>0?A/v*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:i.name,__barFunnelCategory:"_default"===f?void 0:f,category:y?f:i.name});h.push(z(S,t,u,e,r,o,y?f:i.name))}}}return h},swimlane:function(t,e){const{scales:i,columns:r,getR:o,getStack:n,resolvePieceStyle:a}=t,{r:s,projection:c}=i,l=[],u="horizontal"===c;for(const t of Object.values(r)){let e=0;for(const i of t.pieceData){const r=Math.abs(o(i));if(0===r)continue;const c=n?n(i):t.name,h=a(i,c);if(u){const o=s(e),n=s(e+r);l.push(z(o,t.x,n-o,t.width,h,i,c))}else{const o=s(e+r),n=s(e);l.push(z(t.x,o,t.width,n-o,h,i,c))}e+=r}}return l}};class Qt{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,i=t.rAccessor;Array.isArray(i)?(this.rAccessors=i.map(t=>x(t,"value")),this.getR=this.rAccessors[0],this.rExtents=i.map(()=>new y)):(this.getR=x(e&&(t.timeAccessor||t.valueAccessor)&&t.valueAccessor||i,"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 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:r}=this;if(0===r.size)return this.scales=null,this.scene=[],this.columns={},void this.version++;this.rExtent.dirty&&this.rExtent.recalculate(r,this.getR);const o=r.toArray(),n=i.projection||"vertical",a=i.oExtent||this.resolveCategories(o),s=this.computeValueDomain(o,a),c="horizontal"===n,l=null!=i.barPadding?i.barPadding/("vertical"===n?t.width:t.height):.1;let u,h;if("radial"===n){u=e.scaleBand().domain(a).range([0,1]).padding(0);const r=Math.min(t.width,t.height)/2,o=i.innerRadius||0;h=e.scaleLinear().domain(s).range([o,r])}else c?(u=e.scaleBand().domain(a).range([0,t.height]).padding(l),h=e.scaleLinear().domain(s).range([0,t.width])):(u=e.scaleBand().domain(a).range([0,t.width]).padding(l),h=e.scaleLinear().domain(s).range([t.height,0]));this.scales={o:u,r:h,projection:n},this.multiScales=this.rAccessors.length>1&&i.multiAxis?this.rAccessors.map((o,n)=>{var a;const s=this.rExtents[n];s.dirty&&s.recalculate(r,o);let[l,u]=s.extent;l===1/0&&(l=0,u=1);const h=null!==(a=i.extentPadding)&&void 0!==a?a:.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,i)=>Object.assign(Object.assign({},t),{__rIndex:i,__rValue:e(t),__rName:this.resolveRAccessorName(i)})))),this.columns=this.buildColumns(f,a,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),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 r=Math.max(50,3*i.size);if(this.categories.size>r){let t=this.categories.size-r;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 r=new Map;for(const e of t){const t=this.getO(e);r.set(t,(r.get(t)||0)+Math.abs(this.getR(e)))}return e.sort("asc"===i?(t,e)=>(r.get(t)||0)-(r.get(e)||0):(t,e)=>(r.get(e)||0)-(r.get(t)||0))}computeValueDomain(t,e){var i,r,o,n,a;const s=this.config.chartType,c=null!==(i=this.config.extentPadding)&&void 0!==i?i:.05;if("radial"===this.config.projection&&("pie"===s||"donut"===s))return[0,1];let l=0,u=0;if("bar"===s&&this.getStack&&this.config.normalize)l=0,u=1;else if("bar"===s&&this.getStack){const e=new Map,i=new Map;for(const r of t){const t=this.getO(r),o=this.getR(r);0>o?i.set(t,(i.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 i.values())l>t&&(l=t)}else if("bar"===s){const e=new Map;for(const i of t){const t=this.getO(i),r=this.getR(i);e.set(t,(e.get(t)||0)+r)}for(const t of e.values())t>u&&(u=t),l>t&&(l=t)}else if("swimlane"===s){const e=new Map;for(const i of t){const t=this.getO(i),r=Math.abs(this.getR(i));e.set(t,(e.get(t)||0)+r)}for(const t of e.values())t>u&&(u=t)}else if("clusterbar"===s||"bar-funnel"===s)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"===s||"clusterbar"===s||"bar-funnel"===s||"swimlane"===s;if(h&&null==(null===(r=this.config.rExtent)||void 0===r?void 0:r[0])&&null==(null===(o=this.config.rExtent)||void 0===o?void 0:o[1])&&(l>0&&(l=0),0>u&&(u=0)),"bar-funnel"!==s){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===(a=this.config.rExtent)||void 0===a?void 0:a[1])||h&&!this.config.baselinePadding&&0===u||"swimlane"===s||(u+=e)}return[l,u]}buildColumns(t,e,i,r,o){var n;const a={},s=new Map;for(const e of t){const t=this.getO(e);s.has(t)||s.set(t,[]),s.get(t).push(e)}let c=0;if("radial"===r)for(const e of t)c+=Math.abs(this.getR(e));const l=this.config.dynamicColumnWidth;let u=null;if(l&&"radial"!==r){u=new Map;let t=0;for(const i of e){const e=s.get(i)||[];let r;r="string"==typeof l?e.reduce((t,e)=>t+(Number(e[l])||0),0):l(e),u.set(i,r),t+=r}const n=("horizontal"===r?o.height:o.width)-i.padding()*i.step()*e.length;if(t>0)for(const[e,i]of u)u.set(e,i/t*n)}let h=0,f=0;for(const t of e){const e=s.get(t)||[],r=e.reduce((t,e)=>t+Math.abs(this.getR(e)),0),o=c>0?r/c:0;let l,d;u?(l=f,d=u.get(t)||i.bandwidth(),f+=d+i.padding()*i.step()):(l=null!==(n=i(t))&&void 0!==n?n:0,d=i.bandwidth()),a[t]={name:t,x:l,y:0,width:d,middle:l+d/2,padding:i.padding()*i.step(),pieceData:e,pct:o,pctStart:h},h+=o}return a}getSceneContext(){return{scales:this.scales,columns:this.columns,config:this.config,getR:this.getR,getStack:this.getStack,getGroup:this.getGroup,getColor:this.getColor,getConnector:this.getConnector,getO:this.getO,multiScales:this.multiScales,rAccessors:this.rAccessors,resolvePieceStyle:(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(),r=Ut[this.config.chartType];let o=r?r(i,e):[];if(this.getConnector&&this.scales){const t=function(t,e){const{scales:i,config:r,getConnector:o,getO:n}=t;if(!o||!i)return[];const a=[],{projection:s}=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=o(e);if(!i)continue;let r,a;"point"===t.type?(r=t.x,a=t.y):(r=t.x+t.w/2,a=t.y+("vertical"===s?0:t.h/2)),c.has(i)||c.set(i,[]),c.get(i).push({x:r,y:a,datum:e,category:n(e)})}const l=i.o.domain(),u=r.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 r=e[i],o=e[i+1],n="function"==typeof u?u(r.datum):u||{stroke:"#999",strokeWidth:1,opacity:.5};a.push({type:"connector",x1:r.x,y1:r.y,x2:o.x,y2:o.y,style:n,datum:r.datum,group:t})}}return a}(i,o);o=[...t,...o]}return o}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:k,r=i[this._colorSchemeIndex%i.length];return this._colorSchemeIndex++,this._colorSchemeMap.set(t,r),r}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,r,o;const n=this.config.decay;if(!n||1>=e)return 1;const a=null!==(i=n.minOpacity)&&void 0!==i?i:.1,s=e-1-t;switch(n.type){case"linear":return a+(1-s/(e-1))*(1-a);case"exponential":{const t=null!==(r=n.halfLife)&&void 0!==r?r:e/2;return a+Math.pow(.5,s/t)*(1-a)}case"step":return(null!==(o=n.stepThreshold)&&void 0!==o?o:.5*e)>s?1:a;default:return 1}}applyDecay(t,e){var i,r;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 a=this.computeDecayOpacity(t,o),s=null!==(r=null===(i=e.style)||void 0===i?void 0:i.opacity)&&void 0!==r?r:1;e.style=Object.assign(Object.assign({},e.style),{opacity:s*a})}}applyPulse(t,e){var i,r,o;if(!this.config.pulse||!this.timestampBuffer)return;const n="undefined"!=typeof performance?performance.now():Date.now(),a=null!==(i=this.config.pulse.duration)&&void 0!==i?i:500,s=null!==(r=this.config.pulse.color)&&void 0!==r?r:"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 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 r=0;for(let i=0;e.length>i;i++){const o=e[i],s=this.config.oAccessor;if(("function"==typeof s?s(o):o[s||"category"])!==t)continue;const c=this.timestampBuffer.get(i);if(null==c)continue;const l=n-c;if(a>l){const t=1-l/a;t>r&&(r=t)}}r>0&&(i._pulseIntensity=r,i._pulseColor=s);continue}const t=l.get(i.datum);if(null==t)continue;const r=this.timestampBuffer.get(t);if(null==r)continue;const o=n-r;a>o&&(i._pulseIntensity=1-o/a,i._pulseColor=s,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,r=this.timestampBuffer.peek();return null!=r&&i>e-r}getNodeKey(t,e){var i,r;if("point"===t.type){const i=`p:${t.datum?this.getO(t.datum):""}:${t.datum?this.getR(t.datum):0}`,r=e.get(i)||0;return e.set(i,r+1),`${i}:${r}`}return"rect"===t.type?`r:${t.group||""}:${null!==(r=null===(i=t.datum)||void 0===i?void 0:i.category)&&void 0!==r?r:""}`:null}snapshotPositions(){this.prevPositionMap.clear();const t=new Map;for(let e=0;this.scene.length>e;e++){const i=this.scene[e],r=this.getNodeKey(i,t);r&&("point"===i.type?this.prevPositionMap.set(r,{x:i.x,y:i.y,r:i.r,opacity:i.style.opacity}):"rect"===i.type&&this.prevPositionMap.set(r,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:i.style.opacity}))}}startTransition(){var t,e,i,r,o,n,a,s,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 s=this.scene[t],c=this.getNodeKey(s,y);if(!c)continue;s._transitionKey=c;const l=this.prevPositionMap.get(c);"point"===s.type?l?(g.add(c),s._targetOpacity=null!==(e=s.style.opacity)&&void 0!==e?e:1,l.x===s.x&&l.y===s.y||(s._targetX=s.x,s._targetY=s.y,s.x=l.x,s.y=l.y,d=!0)):(s._targetOpacity=null!==(i=s.style.opacity)&&void 0!==i?i:1,s.style=Object.assign(Object.assign({},s.style),{opacity:0}),d=!0):"rect"===s.type&&(l?(g.add(c),s._targetOpacity=null!==(r=s.style.opacity)&&void 0!==r?r:1,l.x===s.x&&l.y===s.y&&l.w===s.w&&l.h===s.h||(s._targetX=s.x,s._targetY=s.y,s._targetW=s.w,s._targetH=s.h,s.x=l.x,s.y=l.y,s.w=null!==(o=l.w)&&void 0!==o?o:s.w,s.h=null!==(n=l.h)&&void 0!==n?n:s.h,d=!0)):(s._targetOpacity=null!==(a=s.style.opacity)&&void 0!==a?a:1,s.style=Object.assign(Object.assign({},s.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!==(s=e.r)&&void 0!==s?s: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:P(),duration:f})}advanceTransition(t){var e,i,r;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 r=this.prevPositionMap.get(e),o=r?null!==(i=r.opacity)&&void 0!==i?i:1:0;t.style.opacity=E(o,t._targetOpacity,n)}if(void 0===t._targetX)continue;const r=this.prevPositionMap.get(e);if(!r)continue;t.x=E(r.x,t._targetX,n),t.y=E(r.y,t._targetY,n)}else if("rect"===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=E(o,t._targetOpacity,n)}if(void 0===t._targetX)continue;const i=this.prevPositionMap.get(e);if(!i)continue;t.x=E(i.x,t._targetX,n),t.y=E(i.y,t._targetY,n),void 0!==i.w&&(t.w=E(i.w,t._targetW,n),t.h=E(i.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");const e=new Set(Array.isArray(t)?t:[t]),i=this.getDataId,r=t=>e.has(i(t));if(this.timestampBuffer&&this.timestampBuffer.size>0){const t=this.timestampBuffer.toArray(),e=new Set;this.buffer.forEach((t,i)=>{r(t)&&e.add(i)}),this.timestampBuffer.clear();for(let i=0;t.length>i;i++)e.has(i)||this.timestampBuffer.push(t[i])}const o=this.buffer.remove(r);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 i=new Set(Array.isArray(t)?t:[t]),r=this.getDataId,o=new Set;this.buffer.forEach((t,e)=>{i.has(r(t))&&o.add(e)});const n=this.buffer.update(t=>i.has(r(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 i=Array.isArray(t.rAccessor)?t.rAccessor:[t.rAccessor],r=Array.isArray(e.rAccessor)?e.rAccessor:[e.rAccessor];if(i.length!==r.length||i.some((t,e)=>!m(t,r[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 Jt={mercator:u.geoMercator,equalEarth:u.geoEqualEarth,albersUsa:u.geoAlbersUsa,orthographic:u.geoOrthographic,naturalEarth:u.geoNaturalEarth1,equirectangular:u.geoEquirectangular};function te(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}function ee(t){return t?"function"==typeof t?t:e=>e[t]:t=>t.coordinates||t.data||[]}function ie(t,e,i){return t?Object.assign(Object.assign({},i),"function"==typeof t?t(e):t):i}const re={fill:"#e0e0e0",stroke:"#999",strokeWidth:.5,fillOpacity:1},oe={fill:"#4e79a7",r:4,fillOpacity:.8},ne={stroke:"#4e79a7",strokeWidth:1.5,fill:"none"};function ae(t,e){if(2>t.length)return[t];const i=.4*e,r=[];let o=[t[0]];for(let e=1;t.length>e;e++){const n=t[e];Math.abs(n[0]-t[e-1][0])>i?(2>o.length||r.push(o),o=[n]):o.push(n)}return 2>o.length||r.push(o),r}function se(t,e,i=24){const r=e[0]-t[0],o=e[1]-t[1],n=Math.sqrt(r*r+o*o);if(0===n)return[t,e];const a=-o/n,s=r/n,c=Math.min(.3*n,80),l=(t[0]+e[0])/2+a*c,u=(t[1]+e[1])/2+s*c,h=[];for(let r=0;i>=r;r++){const o=r/i,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 ce(t,e){if(2>t.length)return t;const i=e/2+1,r=[];for(let e=0;t.length>e;e++){const o=t[e];let n,a;0===e?(n=t[1][0]-o[0],a=t[1][1]-o[1]):e===t.length-1?(n=o[0]-t[e-1][0],a=o[1]-t[e-1][1]):(n=t[e+1][0]-t[e-1][0],a=t[e+1][1]-t[e-1][1]);const s=Math.sqrt(n*n+a*a)||1;r.push([o[0]+a/s*i,o[1]+-n/s*i])}return r}function le(t,e,i,r,o){const n=e[0]-t[0],a=e[1]-t[1],s=Math.sqrt(n*n+a*a);if(0===s)return[t,e];const c=a/s,l=-n/s,u=o/2+1;return[[t[0]+c*u,t[1]+l*u],[e[0]+c*u,e[1]+l*u]]}class ue{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 i of t)this.pointBuffer.push(i),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 i="function"==typeof e?e:t=>t[e],r=new Set(Array.isArray(t)?t:[t]);if(this.streaming&&this.pointBuffer){const t=t=>r.has(i(t)+"");if(this.timestampBuffer&&this.timestampBuffer.size>0){const e=this.timestampBuffer.toArray(),i=new Set;this.pointBuffer.forEach((e,r)=>{t(e)&&i.add(r)}),this.timestampBuffer.clear();for(let t=0;e.length>t;t++)i.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=>!r.has(i(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=Jt[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=Jt[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 r=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&&r.length>0&&this.startTransition(r),this.version++}fitProjection(t){var e,i,r,o,n;const a=this.projection,s=this.config,c=[...this.areas],l=te(s.xAccessor,"lon"),u=te(s.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=ee(s.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(s.projectionExtent){const[[e,i],[r,o]]=s.projectionExtent;a.fitExtent([[0,0],[t.width,t.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[e,i],[r,i],[r,o],[e,o],[e,i]]]}})}else if(a.clipAngle&&(null!==(e=a.clipAngle())&&void 0!==e?e:0)>0){const e=null!==(i=s.fitPadding)&&void 0!==i?i:0,r=Math.min(t.width,t.height);a.scale(r/2-r*e),a.translate([t.width/2,t.height/2])}else{const e=null!==(r=s.fitPadding)&&void 0!==r?r:0,i=t.width*e,o=t.height*e;a.fitExtent([[i,o],[t.width-i,t.height-o]],{type:"FeatureCollection",features:c})}this.baseScale=a.scale(),this.baseTranslate=a.translate(),this.baseRotation=null!==(n=null===(o=a.rotate)||void 0===o?void 0:o.call(a))&&void 0!==n?n:[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,r;const o=[],{config:n}=this,a=this.projection,s=this.geoPath,c=te(n.xAccessor,"lon"),l=te(n.yAccessor,"lat");if(n.graticule){const e=!0===n.graticule?{}:n.graticule,i=u.geoGraticule();e.step&&i.step(e.step);const r=s(i())||"";r&&o.push({type:"geoarea",pathData:r,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=s(t);if(!e)continue;const i=s.centroid(t),r=s.bounds(t),a=s.area(t),c=ie(n.areaStyle,t,re);o.push({type:"geoarea",pathData:e,centroid:i,bounds:r,screenArea:a,style:c,datum:t,interactive:!0})}const h=ee(n.lineDataAccessor);for(const e of this.lineData){const i=h(e);if(!i||2>i.length)continue;const r=i.map(t=>[c(t),l(t)]);let s;if("geo"===n.lineType){const t=[];for(let e=0;r.length-1>e;e++){const i=r[e],o=r[e+1],n=u.geoDistance(i,o)||0,a=Math.max(2,Math.ceil(n/(Math.PI/180))),s=u.geoInterpolate(i,o);for(let i=0;a>=i;i++)e>0&&0===i||t.push(s(i/a))}s=t.map(([t,e])=>a([t,e])).filter(t=>null!=t)}else s=r.map(([t,e])=>a([t,e])).filter(t=>null!=t);if(2>s.length)continue;const f=ie(n.lineStyle,e,ne),d="number"==typeof f.strokeWidth?f.strokeWidth:1;2!==r.length||2>s.length||"arc"!==n.flowStyle?2!==r.length||2>s.length||"offset"!==n.flowStyle||(s="geo"===n.lineType?ce(s,d):le(s[0],s[s.length-1],0,0,d)):s=se(s[0],s[s.length-1]);const g=ae(s,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};o.push(i)}else o.push({type:"line",path:2>s.length&&g[0]||s,style:f,datum:e})}const f=this.getPoints(),d=n.pointIdAccessor?"function"==typeof n.pointIdAccessor?n.pointIdAccessor:t=>t[n.pointIdAccessor]:null,g=a.clipAngle&&null!==(e=a.clipAngle())&&void 0!==e?e:0,y=g>0?g*Math.PI/180:null,p=a.rotate?a.rotate():[0,0,0],m="function"==typeof a.center?a.center():[0,0],x=[(null!==(i=m[0])&&void 0!==i?i:0)-p[0],(null!==(r=m[1])&&void 0!==r?r:0)-p[1]];for(let t=0;f.length>t;t++){const e=f[t],i=c(e),r=l(e);if(null!=y&&u.geoDistance([i,r],x)>y)continue;const s=a([i,r]);if(!s)continue;const h=n.pointStyle?n.pointStyle(e):Object.assign({},oe),g={type:"point",x:s[0],y:s[1],r:h.r||4,style:h,datum:e,pointId:d?d(e)+"":void 0};o.push(g)}return o}applyCartogramTransform(t,i){var r,o,n;const a=this.scene.filter(t=>"point"===t.type);if(2>a.length)return;const s=null!==(r=t.strength)&&void 0!==r?r:1;if(0===s)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=a.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=a.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 a){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)),r=l(t.datum),o=i+((isFinite(r)?p(r):i)-i)*s;t.x=h+Math.cos(e)*o,t.y=f+Math.sin(e)*o}const m=i.width/2,x=i.height/2,v=m-u.x,b=x-u.y;if(Math.abs(v)>.5||Math.abs(b)>.5)for(const t of a)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 a)e.pointId&&t.set(e.pointId,[e.x,e.y]);for(const e of k){const i=null===(o=e.datum)||void 0===o?void 0:o.source,r=null===(n=e.datum)||void 0===n?void 0:n.target;if(i&&r){const o=t.get(i+""),n=t.get(r+"");o&&n&&(e.path=[o,n])}}}}applyDecay(){var t,e,i;const r=this.config.decay;if(!r||!this.pointBuffer)return;const o=this.pointBuffer.size;if(0===o)return;const n=null!==(t=r.minOpacity)&&void 0!==t?t:.1,a=null!==(e=r.halfLife)&&void 0!==e?e:o/2,s=null!==(i=r.stepThreshold)&&void 0!==i?i:.5*o,c=this.scene.filter(t=>"point"===t.type);for(let t=0;c.length>t;t++){const e=o-1-t;let i;switch(r.type){case"exponential":i=n+Math.pow(.5,e/a)*(1-n);break;case"step":i=s>e?1:n;break;default:i=n+(o>1?1-e/(o-1):1)*(1-n)}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 r=null!==(t=i.duration)&&void 0!==t?t:500,o=performance.now(),n=this.scene.filter(t=>"point"===t.type),a=this.timestampBuffer.toArray();for(let t=0;n.length>t&&a.length>t;t++){const s=o-a[t];r>s&&(n[t]._pulseIntensity=1-s/r,n[t]._pulseColor=i.color||"rgba(255,255,255,0.6)",n[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,r=this.timestampBuffer.toArray()[this.timestampBuffer.size-1];return performance.now()-r<i}startTransition(t){var e,i;const r=null!==(i=null===(e=this.config.transition)||void 0===e?void 0:e.duration)&&void 0!==i?i:300;if(0>=r)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 a=!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)&&(a=!0))}a&&(this.activeTransition={startTime:performance.now(),duration:r})}advanceTransition(t){if(!this.activeTransition)return!1;const e=_(t,this.activeTransition),i=S(e),r=this.scene.filter(t=>"point"===t.type);for(const t of r)if(null!=t._targetX&&null!=t._targetY){const e=t.y;t.x=E(t.x,t._targetX,i),t.y=E(e,t._targetY,i)}if(e>=1){for(const t of r)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 he(t,e="#4e79a7"){return t&&"string"==typeof t?t:e}function fe(t,e){var i,r,o;switch(t.type){case"line":{const i=t;if(0===i.path.length)return null;const r="M"+i.path.map(([t,e])=>`${t},${e}`).join("L");return f.createElement("path",{key:"line-"+e,d:r,fill:"none",stroke:i.style.stroke||"#4e79a7",strokeWidth:i.style.strokeWidth||2,strokeDasharray:i.style.strokeDasharray,opacity:i.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"),a=[...o.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L");return f.createElement("path",{key:"area-"+e,d:`M${n}L${a}Z`,fill:he(o.style.fill),fillOpacity:null!==(r=null!==(i=o.style.fillOpacity)&&void 0!==i?i:o.style.opacity)&&void 0!==r?r:.7,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})}case"point":{const i=t;return f.createElement("circle",{key:"point-"+e,cx:i.x,cy:i.y,r:i.r,fill:he(i.style.fill),opacity:null!==(o=i.style.opacity)&&void 0!==o?o:.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:he(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),[r,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]}(i.fill),a=.299*r+.587*o+.114*n>128?"#000":"#fff",s=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:a,fontSize:s+"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,r=Math.min(i.openY,i.closeY),o=Math.max(Math.abs(i.openY-i.closeY),1),n=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:r,width:i.bodyWidth,height:o,fill:n,stroke:n,strokeWidth:1}))}default:return null}}function de(t,e){var i,r,o,n,a;const s=t.category||t.group||"",l=i=>`ord-${t.type}-${s}-${e}-${i}`,u=`ord-${t.type}-${s}-${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:he(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:he(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:he(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:he(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.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:he(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-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:he(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,r=t.x+t.width/2,o=t.y+t.height/2;t.height>t.width?i.push(f.createElement("line",{key:l("iqr"),x1:r,y1:e.iqrLine.q1Pos,x2:r,y2:e.iqrLine.q3Pos,stroke:e.style.stroke||"#333",strokeWidth:2}),f.createElement("circle",{key:l("med"),cx:r,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: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},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!==(a=t.style.opacity)&&void 0!==a?a:.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:he(e.style.fill,"#999"),opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth})}default:return null}}const ge={mode:"light",colors:{primary:"#00a2ce",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",background:"transparent",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},ye={mode:"dark",colors:{primary:"#4fc3f7",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",background:"#1a1a2e",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},pe={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 i=t(function(t){i=Object.assign(Object.assign({},i),t(i)),e.dispatchEvent(new CustomEvent("update"))})}(t=>({theme:ge,setTheme(e){t(t=>{if("light"===e)return{theme:ge};if("dark"===e)return{theme:ye};if("high-contrast"===e)return{theme:pe};if(e.mode&&"auto"!==e.mode){const t="dark"===e.mode?ye:ge;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 me={light:ge,dark:ye,"high-contrast":pe,pastels:{mode:"light",colors:{primary:"#c9a0dc",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#fdf6f0",text:"#4a3728",textSecondary:"#8b7355",grid:"#e8d5c4",border:"#e8d5c4",focus:"#c9a0dc"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#fff5ee",text:"#4a3728",borderRadius:"8px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"10px"},"pastels-dark":{mode:"dark",colors:{primary:"#c9a0dc",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#1a1525",text:"#e8ddf0",textSecondary:"#a899c0",grid:"#3d3455",border:"#3d3455",focus:"#c9a0dc"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#251e35",text:"#e8ddf0",borderRadius:"8px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"10px"},"bi-tool":{mode:"light",colors:{primary:"#2563eb",categorical:["#2563eb","#0d9488","#ea580c","#6b7280"],sequential:"blues",background:"#f5f6f8",text:"#2c3e50",textSecondary:"#7f8c9b",grid:"#d8dce3",border:"#d8dce3",focus:"#2563eb"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#2c3e50",borderRadius:"6px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"8px"},"bi-tool-dark":{mode:"dark",colors:{primary:"#3b82f6",categorical:["#3b82f6","#14b8a6","#f97316","#9ca3af"],sequential:"blues",background:"#111827",text:"#f3f4f6",textSecondary:"#9ca3af",grid:"#374151",border:"#374151",focus:"#3b82f6"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1f2937",text:"#f3f4f6",borderRadius:"6px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"8px"},italian:{mode:"light",colors:{primary:"#cc0000",categorical:["#cc0000","#333333","#c8a415","#4682b4"],sequential:"reds",background:"#fafafa",text:"#1a1a1a",textSecondary:"#666666",grid:"#e0e0e0",border:"#e0e0e0",focus:"#cc0000"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#1a1a1a",borderRadius:"2px",shadow:"0 2px 4px rgba(0, 0, 0, 0.15)"},borderRadius:"2px"},"italian-dark":{mode:"dark",colors:{primary:"#ff3333",categorical:["#ff3333","#aaaaaa","#d4a843","#6aa4d4"],sequential:"reds",background:"#0a0a0a",text:"#f5f5f5",textSecondary:"#aaaaaa",grid:"#333333",border:"#333333",focus:"#ff3333"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1a1a1a",text:"#f5f5f5",borderRadius:"2px",shadow:"0 2px 8px rgba(0, 0, 0, 0.5)"},borderRadius:"2px"},tufte:{mode:"light",colors:{primary:"#8b0000",categorical:["#8b4513","#556b2f","#4a5568","#800020"],sequential:"oranges",background:"#fffff8",text:"#111111",textSecondary:"#555555",grid:"#e0ddd0",border:"#e0ddd0",focus:"#8b0000"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#fffff8",text:"#111111",borderRadius:"2px",shadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},borderRadius:"0px"},"tufte-dark":{mode:"dark",colors:{primary:"#c05050",categorical:["#c08050","#7a8b5a","#8090a0","#a05060"],sequential:"oranges",background:"#1c1b18",text:"#e8e4d8",textSecondary:"#a09880",grid:"#3d3c35",border:"#3d3c35",focus:"#c05050"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#262520",text:"#e8e4d8",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.4)"},borderRadius:"0px"},journalist:{mode:"light",colors:{primary:"#e45050",categorical:["#3a86c8","#e45050","#d4a843","#888888"],sequential:"blues",background:"#ffffff",text:"#222222",textSecondary:"#666666",grid:"#d4d4d4",border:"#d4d4d4",focus:"#e45050"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#f8f8f8",text:"#222222",borderRadius:"4px",shadow:"0 2px 6px rgba(0, 0, 0, 0.12)"},borderRadius:"4px"},"journalist-dark":{mode:"dark",colors:{primary:"#ff6b6b",categorical:["#5a9fd8","#ff6b6b","#e0c060","#aaaaaa"],sequential:"blues",background:"#141414",text:"#ededed",textSecondary:"#a0a0a0",grid:"#383838",border:"#383838",focus:"#ff6b6b"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1e1e1e",text:"#ededed",borderRadius:"4px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"4px"},playful:{mode:"light",colors:{primary:"#8b5cf6",categorical:["#8b5cf6","#ec4899","#06b6d4","#84cc16"],sequential:"viridis",background:"#fdf8ff",text:"#2d1b4e",textSecondary:"#7c5a9e",grid:"#e8d0f8",border:"#e8d0f8",focus:"#8b5cf6"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#2d1b4e",borderRadius:"12px",shadow:"0 4px 12px rgba(139, 92, 246, 0.15)"},borderRadius:"12px"},"playful-dark":{mode:"dark",colors:{primary:"#a78bfa",categorical:["#a78bfa","#f472b6","#22d3ee","#a3e635"],sequential:"viridis",background:"#150a28",text:"#f0e8ff",textSecondary:"#b8a0d8",grid:"#3a2560",border:"#3a2560",focus:"#a78bfa"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1f1138",text:"#f0e8ff",borderRadius:"12px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"12px"},carbon:{mode:"light",colors:{primary:"#0f62fe",categorical:["#6929c4","#1192e8","#005d5d","#9f1853"],sequential:"blues",diverging:"RdBu",background:"#ffffff",text:"#161616",textSecondary:"#525252",grid:"#e0e0e0",border:"#e0e0e0",focus:"#0f62fe"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#161616",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.2)"},borderRadius:"0px"},"carbon-dark":{mode:"dark",colors:{primary:"#4589ff",categorical:["#a56eff","#33b1ff","#08bdba","#ff7eb6"],sequential:"blues",diverging:"RdBu",background:"#161616",text:"#f4f4f4",textSecondary:"#a8a8a8",grid:"#393939",border:"#393939",focus:"#4589ff"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#262626",text:"#f4f4f4",borderRadius:"2px",shadow:"0 4px 12px rgba(0, 0, 0, 0.5)"},borderRadius:"0px"}};function xe(t){if(!t)return ge;if("string"==typeof t){if("light"===t)return ge;if("dark"===t)return ye;if("high-contrast"===t)return pe;return me[t]||ge}const e="dark"===t.mode?ye:ge;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 ve(t){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}}function be(t){const{categories:i,colorScheme:o,theme:n,position:a="right",totalWidth:s,totalHeight:c,margin:l,hasTitle:u=!1}=t;if(!i||0===i.length)return null;const h=function(t,i,o){const n=Array.isArray(i)?i:o.colors.categorical.length>0?o.colors.categorical:r.schemeCategory10;return e.scaleOrdinal().domain(t).range(n)}(i,o,n);let d,g;if("left"===a?(d=4,g=l.top):"top"===a?(d=l.left,g=u?32:8):"bottom"===a?(d=l.left,g=c-l.bottom+8):(d=s-l.right+10,g=l.top),"top"===a||"bottom"===a){let t=0;const e=i.map((e,i)=>{const r=t;return t+=22+6.5*e.length+8,f.createElement("g",{key:"legend-"+i,transform:`translate(${r},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(${d},${g})`},e)}const y=i.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(${d},${g})`},y)}function ke(t,e){if(!e||!t||0===t.length)return[];const i="function"==typeof e?e:t=>t[e],r=new Set;for(const e of t){const t=i(e);null!=t&&r.add(t+"")}return Array.from(r)}function we(t){const{annotations:e}=t;if(!e||0===e.length)return null;const i=[];for(let r=0;e.length>r;r++){const o=Ae(e[r],r,t);o&&i.push(o)}return i.length>0?f.createElement("g",{id:(t.idPrefix?t.idPrefix+"-":"")+"annotations",className:"semiotic-annotations"},i):null}function Ae(t,e,i){var r,o,n,a;const{scales:s,layout:c,theme:l,xAccessor:u,yAccessor:h}=i;switch(t.type){case"y-threshold":{const o=t.value;if(null==o)return null;const n=t.color||l.colors.primary,a=t.label,u=t.labelPosition||"right",h=t.strokeDasharray||"6,4",d=null!==(r=t.strokeWidth)&&void 0!==r?r:1.5;if("horizontal"===i.projection&&s.r){const t=s.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}),a&&f.createElement("text",{x:t+4,y:12,textAnchor:"start",fontSize:l.typography.tickSize,fill:n,fontFamily:l.typography.fontFamily},a))}const g=s.y?s.y(o):s.r?s.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}),a&&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},a))}case"x-threshold":{const i=t.value;if(null==i||!s.x)return null;const r=s.x(i);if(null==r)return null;const n=t.color||l.colors.primary,a=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:r,y1:0,x2:r,y2:c.height,stroke:n,strokeWidth:h,strokeDasharray:t.strokeDasharray||"6,4"}),a&&f.createElement("text",{x:r+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},a))}case"band":{const i=null!=t.y0&&s.y?s.y(t.y0):null,r=null!=t.y1&&s.y?s.y(t.y1):null;if(null==i||null==r)return null;const o=Math.min(i,r),a=t.fill||t.color||l.colors.primary,u=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:Math.abs(r-i),fill:a,opacity:u}),t.label&&f.createElement("text",{x:c.width-4,y:o+12,textAnchor:"end",fontSize:l.typography.tickSize,fill:a,fontFamily:l.typography.fontFamily},t.label))}case"category-highlight":{if(!t.category||!s.o)return null;const r=s.o(t.category);if(null==r)return null;const o=s.o.bandwidth?s.o.bandwidth():40,n=t.color||l.colors.primary,u=null!==(a=t.opacity)&&void 0!==a?a:.1;return f.createElement("rect","horizontal"===i.projection?{key:"ann-cathighlight-"+e,x:0,y:r,width:c.width,height:o,fill:n,opacity:u}:{key:"ann-cathighlight-"+e,x:r,y:0,width:o,height:c.height,fill:n,opacity:u})}case"label":case"text":{const i=function(t,e,i){return null!=t.x&&e.x?e.x(t.x):i&&null!=t[i]&&e.x?e.x(t[i]):null}(t,s,u),r=function(t,e,i){return null!=t.y&&e.y?e.y(t.y):i&&null!=t[i]&&e.y?e.y(t[i]):null}(t,s,h);if(null==i||null==r)return null;const o=t.dx||0,n=t.dy||0,a=t.color||l.colors.text;return f.createElement("g",{key:"ann-label-"+e},"label"===t.type&&f.createElement("line",{x1:i,y1:r,x2:i+o,y2:r+n,stroke:l.colors.textSecondary,strokeWidth:1}),f.createElement("text",{x:i+o,y:r+n,textAnchor:t.textAnchor||"start",fontSize:t.fontSize||l.typography.labelSize,fill:a,fontFamily:l.typography.fontFamily,fontWeight:t.fontWeight},t.label||t.title))}default:return null}}const Se=require("react-dom/server");function _e(t){return Math.round(100*t)/100+""}function Ee(t,e){const i=ve(e.theme),r=e.idPrefix?e.idPrefix+"-":"",o="string"==typeof e.title?e.title:void 0,n=o?r+"semiotic-title":void 0,a=e.description?r+"semiotic-desc":void 0,s=[n,a].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":s,style:{fontFamily:i.fontFamily}},o&&f.createElement("title",{id:n},o),e.description&&f.createElement("desc",{id:a},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:r+"data-area",transform:e.innerTransform},t),o&&f.createElement("text",{id:r+"chart-title",x:e.width/2,y:16,textAnchor:"middle",fontSize:i.titleSize,fontWeight:"bold",fill:i.text,fontFamily:i.fontFamily},o),e.legend&&f.createElement("g",{id:r+"legend"},e.legend),e.outerElements)}function Pe(t){var e,i,r,o;const n=xe(t.theme),a=t.size||[500,300],s=Object.assign(Object.assign({},{top:20,right:20,bottom:30,left:40}),t.margin),c=t.legendPosition;t.showLegend&&(c&&"right"!==c?"left"===c?s.left=Math.max(s.left,100):"bottom"===c?s.bottom=Math.max(s.bottom,70):"top"===c&&(s.top=Math.max(s.top,40)):s.right=Math.max(s.right,100));const l=a[0]-s.left-s.right,u=a[1]-s.top-s.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!==(i=t.windowMode)&&void 0!==i?i:"sliding",arrowOfTime:h&&null!==(r=t.arrowOfTime)&&void 0!==r?r:"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 W(d);if(t.data&&g.ingest({inserts:t.data,bounded:!0}),g.computeScene({width:l,height:u}),!g.scales||0===g.scene.length)return Se.renderToStaticMarkup(Ee(null,{width:a[0],height:a[1],className:"stream-xy-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:n,innerTransform:`translate(${s.left},${s.top})`,idPrefix:t._idPrefix}));const y=t._idPrefix,p=t.showGrid?function(t,e,i,r){const{grid:o}=ve(i),n=r?r+"-":"",a=t.x.ticks(5),s=t.y.ticks(5);return f.createElement("g",{id:n+"grid",className:"semiotic-grid",opacity:.8},a.map((i,r)=>{const n=t.x(i);return f.createElement("line",{key:"gx-"+r,x1:n,y1:0,x2:n,y2:e.height,stroke:o,strokeWidth:.5})}),s.map((i,r)=>{const n=t.y(i);return f.createElement("line",{key:"gy-"+r,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)=>fe(t,e)).filter(Boolean),x=!1!==t.showAxes?function(t,e,i,r,o){var n,a,s,c;const l=ve(r),u=t.x.ticks(5).map(e=>({pixel:t.x(e),label:(i.xFormat||i.tickFormatTime||_e)(e)})),h=t.y.ticks(5).map(e=>({pixel:t.y(e),label:(i.yFormat||i.tickFormatValue||_e)(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,i)=>f.createElement("g",{key:"xtick-"+i,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))),i.xLabel&&f.createElement("text",{x:e.width/2,y:e.height+40,textAnchor:"middle",fontSize:l.labelSize,fill:l.text,fontFamily:l.fontFamily},i.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))),i.yLabel&&f.createElement("text",{x:15-(null!==(a=null===(n=i.margin)||void 0===n?void 0:n.left)&&void 0!==a?a:40),y:e.height/2,textAnchor:"middle",fontSize:l.labelSize,fill:l.text,fontFamily:l.fontFamily,transform:`rotate(-90, ${15-(null!==(c=null===(s=i.margin)||void 0===s?void 0:s.left)&&void 0!==c?c:40)}, ${e.height/2})`},i.yLabel))}(g.scales,{width:l,height:u},t,n,y):null,v=t.annotations?we({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=ke(t.data||[],t.colorAccessor||t.groupAccessor);return 0===e.length?null:be({categories:e,colorScheme:t.colorScheme,theme:n,position:t.legendPosition||"right",totalWidth:a[0],totalHeight:a[1],margin:s,hasTitle:!!t.title})})():null,k=f.createElement(f.Fragment,null,p,v,m,x);return Se.renderToStaticMarkup(Ee(k,{width:a[0],height:a[1],className:"stream-xy-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:n,innerTransform:`translate(${s.left},${s.top})`,legend:b,idPrefix:t._idPrefix}))}function Me(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}const Oe=new Set(["tree","cluster","treemap","circlepack","partition"]);function Le(t){const e=xe(t.theme),i=t.chartType||"force",r=t.size||[500,500],o=Object.assign(Object.assign({},{top:20,right:20,bottom:20,left:20}),t.margin),n=r[0]-o.left-o.right,a=r[1]-o.top-o.bottom,s=function(t){return Ht[t]}(i);if(!s)throw Error(`No layout plugin found for chart type: "${i}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition.`);const l={chartType:i,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(Oe.has(i)){const i=t.data||t.edges;if(!i||Array.isArray(i))return Se.renderToStaticMarkup(Ee(null,{width:r[0],height:r[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=i,u=[],h=[]}else{const i=t.nodes||[],n=Array.isArray(t.edges)?t.edges:[];if(0===i.length&&0===n.length)return Se.renderToStaticMarkup(Ee(null,{width:r[0],height:r[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 i=Me(e.sourceAccessor,"source"),r=Me(e.targetAccessor,"target"),o=Me(e.valueAccessor,"value");return t.map(t=>({source:i(t)+"",target:r(t)+"",value:Number(o(t))||1,y0:0,y1:0,sankeyWidth:0,data:t}))}(n,l),0===i.length&&h.length>0){const t=new Set;for(const e of h){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)}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 i=Me(e.nodeIDAccessor,"id");return t.map(t=>{var e,r;return{id:i(t)+"",x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(r=t.y)&&void 0!==r?r:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:t}})}(i,l)}s.computeLayout(u,h,l,[n,a]);const{sceneNodes:d,sceneEdges:g,labels:y}=s.buildScene(u,h,l,[n,a]),p=ve(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 i=t;return f.createElement("path",{key:"net-edge-"+e,d:i.pathD,fill:he(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:he(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:he(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),x=d.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:he(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:he(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})}case"arc":{const i=t,r=c.arc().innerRadius(i.innerR).outerRadius(i.outerR).startAngle(i.startAngle).endAngle(i.endAngle)({})||"";return f.createElement("path",{key:"net-arc-"+e,d:r,transform:`translate(${i.cx},${i.cy})`,fill:he(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.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 Se.renderToStaticMarkup(Ee(b,{width:r[0],height:r[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 De(t){var e,i,r,o,n;const a=xe(t.theme),s=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=s[0]-c.left-c.right,h=s[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!==(i=t.windowMode)&&void 0!==i?i:"sliding",extentPadding:null!==(r=t.extentPadding)&&void 0!==r?r:.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,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||a.colors.categorical,barColors:t.barColors},p=new Qt(y);if(t.data&&p.ingest({inserts:t.data,bounded:!0}),p.computeScene({width:u,height:h}),!p.scales||0===p.scene.length)return Se.renderToStaticMarkup(Ee(null,{width:s[0],height:s[1],className:"stream-ordinal-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:a,innerTransform:`translate(${c.left},${c.top})`,idPrefix:t._idPrefix}));const m=t._idPrefix,x=t.showGrid?function(t,e,i,r){const o=t.scales;if(!o||"radial"===o.projection)return null;const{grid:n}=ve(i),a=r?r+"-":"",s="vertical"===o.projection,c=o.r.ticks(5);return f.createElement("g",{id:a+"grid",className:"semiotic-grid",opacity:.8},c.map(s?(t,i)=>{const r=o.r(t);return f.createElement("line",{key:"gr-"+i,x1:0,y1:r,x2:e.width,y2:r,stroke:n,strokeWidth:.5})}:(t,i)=>{const r=o.r(t);return f.createElement("line",{key:"gr-"+i,x1:r,y1:0,x2:r,y2:e.height,stroke:n,strokeWidth:.5})}))}(p,{width:u,height:h},a,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 i=`${t.chartType||""}:${t.title||""}:${Array.isArray(t.data)?t.data.length:0}`;let r=0;for(let t=0;i.length>t;t++)r=31*r+i.charCodeAt(t)|0;return"c"+(r>>>0).toString(36)}(t),i=new Set;for(const t of p.scene)"rect"===t.type&&(null===(o=t.datum)||void 0===o?void 0:o.__barFunnelIsDropoff)&&i.add("string"==typeof t.style.fill?t.style.fill:"#666");b=Array.from(i).map((t,i)=>function(t){const{id:e,background:i="transparent",stroke:r="#000",lineWidth:o=1.5,spacing:n=6,angle:a=45}=t,s=Math.max(8,Math.ceil(2*n));return f.createElement("pattern",{key:e,id:e,width:s,height:s,patternUnits:"userSpaceOnUse",patternTransform:0!==a?`rotate(${a})`:void 0},i&&"transparent"!==i&&f.createElement("rect",{width:s,height:s,fill:i}),f.createElement("line",{x1:0,y1:0,x2:0,y2:s,stroke:r,strokeWidth:o}),f.createElement("line",{x1:n,y1:0,x2:n,y2:s,stroke:r,strokeWidth:o}))}({id:`funnel-hatch-${e}-${i}`,background:t,stroke:"transparent"===a.colors.background?"#fff":a.colors.background,lineWidth:1.5,spacing:5,angle:45}));const r=new Map;Array.from(i).forEach((t,i)=>r.set(t,`funnel-hatch-${e}-${i}`));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(#${r.get(e)})`})}}const k=p.scene.map((t,e)=>de(t,e)).filter(Boolean),w=!1!==t.showAxes?function(t,e,i,r,o){var n,a,s,c,l,u,h,d;const g=t.scales;if(!g)return null;if("radial"===g.projection)return null;const y=ve(r),p="vertical"===g.projection,m=Object.values(t.columns).map(t=>({pixel:t.middle,label:(i.oFormat||String)(t.name)})),x=g.r.ticks(5).map(t=>({pixel:g.r(t),label:(i.rFormat||_e)(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,i)=>f.createElement("g",{key:"oxtick-"+i,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))),i.oLabel&&f.createElement("text",{x:e.width/2,y:e.height+40,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily},i.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))),i.rLabel&&f.createElement("text",{x:15-(null!==(a=null===(n=i.margin)||void 0===n?void 0:n.left)&&void 0!==a?a:40),y:e.height/2,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily,transform:`rotate(-90, ${15-(null!==(c=null===(s=i.margin)||void 0===s?void 0:s.left)&&void 0!==c?c:40)}, ${e.height/2})`},i.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,i)=>f.createElement("g",{key:"oxtick-"+i,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))),i.rLabel&&f.createElement("text",{x:e.width/2,y:e.height+40,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily},i.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))),i.oLabel&&f.createElement("text",{x:15-(null!==(u=null===(l=i.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=i.margin)||void 0===h?void 0:h.left)&&void 0!==d?d:40)}, ${e.height/2})`},i.oLabel))}(p,{width:u,height:h},t,a,m):null,A=t.annotations?we({annotations:t.annotations,scales:{r:p.scales.r,y:"vertical"===p.scales.projection?p.scales.r:void 0},layout:{width:u,height:h},theme:a,projection:d,idPrefix:m}):null,S=t.showLegend?(()=>{const e=ke(t.data||[],t.colorAccessor||t.stackBy||t.groupBy);return 0===e.length?null:be({categories:e,colorScheme:t.colorScheme,theme:a,position:t.legendPosition||"right",totalWidth:s[0],totalHeight:s[1],margin:c,hasTitle:!!t.title})})():null,_=g?c.left+u/2:c.left,E=g?c.top+h/2:c.top,P=f.createElement(f.Fragment,null,x,A,k,w);return Se.renderToStaticMarkup(Ee(P,{width:s[0],height:s[1],className:"stream-ordinal-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:a,innerTransform:`translate(${_},${E})`,legend:S,defs:b,idPrefix:t._idPrefix}))}function ze(t){var e,i,r,o,n,a,s,c;const l=xe(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!==(i=h.right)&&void 0!==i?i:0),g=u[1]-(null!==(r=h.top)&&void 0!==r?r:0)-(null!==(o=h.bottom)&&void 0!==o?o:0),y=new ue({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 Se.renderToStaticMarkup(Ee(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!==(a=h.top)&&void 0!==a?a:0})`,idPrefix:t._idPrefix}));const p=y.scene.map((t,e)=>function(t,e){var i,r,o,n,a,s;switch(t.type){case"geoarea":{const o=t;return o.pathData?f.createElement("path",{key:"geoarea-"+e,d:o.pathData,fill:he(o.style.fill,"#e0e0e0"),fillOpacity:null!==(i=o.style.fillOpacity)&&void 0!==i?i:1,stroke:o.style.stroke||"none",strokeWidth:o.style.strokeWidth||.5,strokeDasharray:o.style.strokeDasharray,opacity:null!==(r=o._decayOpacity)&&void 0!==r?r:1}):null}case"point":{const i=t;return f.createElement("circle",{key:"point-"+e,cx:i.x,cy:i.y,r:i.r,fill:he(i.style.fill),fillOpacity:null!==(o=i.style.fillOpacity)&&void 0!==o?o:.8,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:null!==(n=i._decayOpacity)&&void 0!==n?n:null!==(a=i.style.opacity)&&void 0!==a?a:1})}case"line":{const i=t;if(2>i.path.length)return null;const r="M"+i.path.map(t=>`${t[0]},${t[1]}`).join("L");return f.createElement("path",{key:"line-"+e,d:r,fill:"none",stroke:i.style.stroke||"#4e79a7",strokeWidth:i.style.strokeWidth||1.5,strokeDasharray:i.style.strokeDasharray,opacity:null!==(s=i.style.opacity)&&void 0!==s?s:1})}default:return null}}(t,e)).filter(Boolean),m=f.createElement(f.Fragment,null,p);return Se.renderToStaticMarkup(Ee(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!==(s=h.left)&&void 0!==s?s:0},${null!==(c=h.top)&&void 0!==c?c:0})`,idPrefix:t._idPrefix}))}function je(t,e){switch(t){case"xy":return Pe(e);case"ordinal":return De(e);case"network":return Le(e);case"geo":return ze(e);default:throw Error(`Unknown frame type: ${t}. Must be "xy", "ordinal", "network", or "geo".`)}}function Te(t,e,i){var r,o,n,a,s,c,l,u;const{data:h,width:d=600,height:g=400,theme:y,title:p,description:m,showLegend:x,showGrid:v,background:b,className:k,annotations:w,margin:A,colorScheme:S,colorBy:_,legendPosition:E}=e,P=function(t,e){var i={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&0>e.indexOf(r)&&(i[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);r.length>o;o++)0>e.indexOf(r[o])&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(i[r[o]]=t[r[o]])}return i}(e,["data","width","height","theme","title","description","showLegend","showGrid","background","className","annotations","margin","colorScheme","colorBy","legendPosition"]),M=[d,g],O=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},P.frameProps||{}),{theme:y,title:p,description:m,showLegend:x,showGrid:v,background:b,className:k,annotations:w,size:M}),void 0!==A&&{margin:A}),void 0!==S&&{colorScheme:S}),void 0!==E&&{legendPosition:E}),{_idPrefix:P._idPrefix});switch(t){case"Sparkline":return Pe(Object.assign(Object.assign({chartType:"line",data:h,xAccessor:P.xAccessor||"x",yAccessor:P.yAccessor||"y",groupAccessor:P.lineBy||_,colorAccessor:_},O),{showAxes:!1,margin:O.margin||{top:2,right:2,bottom:2,left:2},showLegend:!1,showGrid:!1,title:void 0}));case"LineChart":return Pe(Object.assign({chartType:"line",data:h,xAccessor:P.xAccessor||"x",yAccessor:P.yAccessor||"y",groupAccessor:P.lineBy||_,lineDataAccessor:P.lineDataAccessor,colorAccessor:_},O));case"AreaChart":return Pe(Object.assign({chartType:"area",data:h,xAccessor:P.xAccessor||"x",yAccessor:P.yAccessor||"y",groupAccessor:P.areaBy||_,colorAccessor:_},O));case"StackedAreaChart":return Pe(Object.assign({chartType:"stackedarea",data:h,xAccessor:P.xAccessor||"x",yAccessor:P.yAccessor||"y",groupAccessor:P.areaBy,colorAccessor:_||P.areaBy,normalize:P.normalize},O));case"Scatterplot":case"BubbleChart":return Pe(Object.assign({chartType:"scatter",data:h,xAccessor:P.xAccessor||"x",yAccessor:P.yAccessor||"y",colorAccessor:_,sizeAccessor:P.sizeBy,sizeRange:P.sizeRange||("BubbleChart"===t?[5,40]:void 0)},O));case"ConnectedScatterplot":return Pe(Object.assign({chartType:"scatter",data:h,xAccessor:P.xAccessor||"x",yAccessor:P.yAccessor||"y",colorAccessor:_},O));case"Heatmap":return Pe(Object.assign({chartType:"heatmap",data:h,xAccessor:P.xAccessor||"x",yAccessor:P.yAccessor||"y",valueAccessor:P.valueAccessor||"value",colorScheme:S||"blues"},O));case"BarChart":return De(Object.assign({chartType:"bar",data:h,oAccessor:P.categoryAccessor||"category",rAccessor:P.valueAccessor||"value",projection:"horizontal"===P.orientation?"horizontal":"vertical",colorAccessor:_,barPadding:P.barPadding},O));case"StackedBarChart":return De(Object.assign({chartType:"bar",data:h,oAccessor:P.categoryAccessor||"category",rAccessor:P.valueAccessor||"value",stackBy:P.stackBy,projection:"horizontal"===P.orientation?"horizontal":"vertical",colorAccessor:_||P.stackBy,normalize:P.normalize,barPadding:P.barPadding},O));case"GroupedBarChart":return De(Object.assign({chartType:"clusterbar",data:h,oAccessor:P.categoryAccessor||"category",rAccessor:P.valueAccessor||"value",groupBy:P.groupBy,projection:"horizontal"===P.orientation?"horizontal":"vertical",colorAccessor:_||P.groupBy,barPadding:P.barPadding},O));case"PieChart":return De(Object.assign({chartType:"pie",data:h,oAccessor:P.categoryAccessor||"category",rAccessor:P.valueAccessor||"value",projection:"radial",colorAccessor:_||P.categoryAccessor||"category"},O));case"DonutChart":return De(Object.assign({chartType:"donut",data:h,oAccessor:P.categoryAccessor||"category",rAccessor:P.valueAccessor||"value",projection:"radial",innerRadius:P.innerRadius||60,colorAccessor:_||P.categoryAccessor||"category"},O));case"Histogram":return De(Object.assign({chartType:"histogram",data:h,oAccessor:P.categoryAccessor||"category",rAccessor:P.valueAccessor||"value",bins:P.bins||25,projection:"horizontal"},O));case"BoxPlot":return De(Object.assign({chartType:"boxplot",data:h,oAccessor:P.categoryAccessor||"category",rAccessor:P.valueAccessor||"value",colorAccessor:_},O));case"ViolinPlot":return De(Object.assign({chartType:"violin",data:h,oAccessor:P.categoryAccessor||"category",rAccessor:P.valueAccessor||"value",colorAccessor:_,bins:P.bins},O));case"SwarmPlot":return De(Object.assign({chartType:"swarm",data:h,oAccessor:P.categoryAccessor||"category",rAccessor:P.valueAccessor||"value",colorAccessor:_},O));case"DotPlot":return De(Object.assign(Object.assign({chartType:"point",data:h,oAccessor:P.categoryAccessor||"category",rAccessor:P.valueAccessor||"value",colorAccessor:_},O),{showGrid:null==v||v}));case"SwimlaneChart":return De(Object.assign({chartType:"swimlane",data:h,oAccessor:P.categoryAccessor||"category",rAccessor:P.valueAccessor||"value",stackBy:P.subcategoryAccessor,projection:"vertical"===P.orientation?"vertical":"horizontal",colorAccessor:_||P.subcategoryAccessor,barPadding:P.barPadding},O));case"FunnelChart":{const t="vertical"===P.orientation;return De(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:t?"bar-funnel":"funnel",data:h,oAccessor:P.stepAccessor||"step",rAccessor:P.valueAccessor||"value"},P.categoryAccessor&&{stackBy:P.categoryAccessor}),{projection:t?"vertical":"horizontal",colorAccessor:_||P.categoryAccessor,barPadding:t?null!==(r=P.barPadding)&&void 0!==r?r:40:null!==(o=P.barPadding)&&void 0!==o?o:0}),!t&&{connectorAccessor:()=>!0,connectorStyle:{opacity:null!==(n=P.connectorOpacity)&&void 0!==n?n:.3}}),{showAxes:t,showCategoryTicks:t,showGrid:t,showLabels:P.showLabels}),O))}case"RidgelinePlot":return De(Object.assign({chartType:"ridgeline",data:h,oAccessor:P.categoryAccessor||"category",rAccessor:P.valueAccessor||"value",bins:P.bins,amplitude:P.amplitude},O));case"GaugeChart":{const t=null!==(a=P.min)&&void 0!==a?a:0,e=null!==(s=P.max)&&void 0!==s?s:100,i=null!==(c=P.sweep)&&void 0!==c?c:240,r=null!==(l=P.arcWidth)&&void 0!==l?l:.3,o=180+(360-i)/2,n=P.thresholds||[{value:e,color:"#4e79a7"}],h=n.map((e,i)=>({category:e.label||"zone-"+i,value:e.value-(i>0?n[i-1].value:t)})),p={};n.forEach((t,e)=>{p[t.label||"zone-"+e]=t.color||"#4e79a7"});const m=O.margin||{top:20,right:20,bottom:30,left:40},x=(d||300)-m.left-m.right,v=(g||300)-m.top-m.bottom,b=Math.min(x,v),k=Math.max(10,b/2*(1-r)),w=Math.max(t,Math.min(e,null!==(u=P.value)&&void 0!==u?u:t)),A=(o+(e===t?0:(w-t)/(e-t))*i-90)*Math.PI/180,S=b/2*.85,_=m.left+x/2,E=m.top+v/2,M=xe(y).colors.text,L=De(Object.assign(Object.assign({chartType:"donut",data:h,oAccessor:"category",rAccessor:"value",projection:"radial",innerRadius:k,sweepAngle:i,startAngle:o,oSort:!1,pieceStyle:(t,e)=>({fill:p[e||""]||"#4e79a7"})},O),{showAxes:!1})),D=Se.renderToStaticMarkup(f.createElement(f.Fragment,null,f.createElement("line",{x1:_,y1:E,x2:_+S*Math.cos(A),y2:E+S*Math.sin(A),stroke:M,strokeWidth:2.5,strokeLinecap:"round"}),f.createElement("circle",{cx:_,cy:E,r:4,fill:M})));return L.replace("</svg>",D+"</svg>")}case"ForceDirectedGraph":return Le(Object.assign({chartType:"force",nodes:P.nodes,edges:P.edges,nodeIDAccessor:P.nodeIDAccessor,sourceAccessor:P.sourceAccessor,targetAccessor:P.targetAccessor,colorBy:_,colorScheme:S,iterations:P.iterations,forceStrength:P.forceStrength,showLabels:P.showLabels,nodeLabel:P.nodeLabel,nodeSize:P.nodeSize,nodeSizeRange:P.nodeSizeRange,nodeStyle:P.nodeStyle,edgeStyle:P.edgeStyle},O));case"SankeyDiagram":return Le(Object.assign({chartType:"sankey",nodes:P.nodes,edges:P.edges,nodeIDAccessor:P.nodeIdAccessor||P.nodeIDAccessor,sourceAccessor:P.sourceAccessor,targetAccessor:P.targetAccessor,valueAccessor:P.valueAccessor,orientation:P.orientation,nodeAlign:P.nodeAlign,nodeWidth:P.nodeWidth,nodePaddingRatio:P.nodePaddingRatio,showLabels:P.showLabels,nodeLabel:P.nodeLabel,colorBy:_,edgeColorBy:P.edgeColorBy,edgeOpacity:P.edgeOpacity,nodeStyle:P.nodeStyle,edgeStyle:P.edgeStyle,colorScheme:S},O));case"ChordDiagram":return Le(Object.assign({chartType:"chord",nodes:P.nodes,edges:P.edges,valueAccessor:P.valueAccessor,padAngle:P.padAngle,groupWidth:P.groupWidth,showLabels:P.showLabels,colorBy:_,edgeColorBy:P.edgeColorBy,colorScheme:S},O));case"TreeDiagram":return Le(Object.assign({chartType:"cluster"===P.layout?"cluster":"tree",data:h,childrenAccessor:P.childrenAccessor,colorBy:_,colorByDepth:P.colorByDepth,orientation:P.orientation,showLabels:P.showLabels,colorScheme:S},O));case"Treemap":return Le(Object.assign({chartType:"treemap",data:h,childrenAccessor:P.childrenAccessor,hierarchySum:P.valueAccessor,colorBy:_,colorByDepth:P.colorByDepth,showLabels:P.showLabels,colorScheme:S},O));case"CirclePack":return Le(Object.assign({chartType:"circlepack",data:h,childrenAccessor:P.childrenAccessor,hierarchySum:P.valueAccessor,colorBy:_,colorByDepth:P.colorByDepth,colorScheme:S},O));case"ChoroplethMap":return ze(Object.assign({areas:P.areas,projection:P.projection||"equalEarth",areaStyle:P.areaStyle,graticule:P.graticule,fitPadding:P.fitPadding},O));case"ProportionalSymbolMap":return ze(Object.assign({points:P.points,areas:P.areas,xAccessor:P.xAccessor||"lon",yAccessor:P.yAccessor||"lat",pointStyle:P.pointStyle,projection:P.projection||"equalEarth",graticule:P.graticule,fitPadding:P.fitPadding},O));default:throw Error(`Unknown chart component: "${t}". See CLAUDE.md for supported chart types.`)}}const Ne=require("react-dom/server");function $e(t,e,i,r={}){const{stepSize:o,windowSize:n,frameCount:a,xExtent:s,yExtent:c,transitionFrames:l=4,fps:u=12,easing:h="ease-out",decay:f}=r,d=i.width||600,g=i.height||400,y=xe(i.theme),p=Object.assign(Object.assign(Object.assign({},i),s&&{xExtent:s}),c&&{yExtent:c});if(!e||0===e.length)return[];const m=o||Math.max(1,Math.ceil(e.length/(a||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},i.margin),k=d-b.left-b.right,w=g-b.top-b.bottom,A=[];if(v)for(let r=0;x.length>r;r++){const o=x[r],a=e.slice(n?Math.max(0,o-n):0,o),s=Object.assign({chartType:t,windowSize:1e4,windowMode:"sliding",extentPadding:.05,projection:i.projection||"vertical",oAccessor:i.oAccessor||i.categoryAccessor||"category",rAccessor:i.rAccessor||i.valueAccessor||"value",colorAccessor:i.colorAccessor||i.colorBy,stackBy:i.stackBy,groupBy:i.groupBy,barPadding:i.barPadding,innerRadius:i.innerRadius,normalize:i.normalize,bins:i.bins,colorScheme:i.colorScheme||y.colors.categorical},f&&{decay:f}),c=new Qt(s);c.ingest({inserts:a,bounded:!0}),c.computeScene({width:k,height:w}),c.scene.length>0&&A.push(Re(c.scene,d,g,y,p))}else for(let r=0;x.length>r;r++){const o=x[r],a=e.slice(n?Math.max(0,o-n):0,o),m=Object.assign(Object.assign({chartType:t,windowSize:a.length+10,windowMode:"sliding",arrowOfTime:"right",extentPadding:.1,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",colorAccessor:i.colorAccessor||i.colorBy,groupAccessor:i.groupAccessor||i.lineBy,lineDataAccessor:i.lineDataAccessor,xExtent:s,yExtent:c,colorScheme:i.colorScheme||y.colors.categorical,lineStyle:i.lineStyle,pointStyle:i.pointStyle,areaStyle:i.areaStyle,sizeAccessor:i.sizeAccessor||i.sizeBy,sizeRange:i.sizeRange},f&&{decay:f}),l>0&&{transition:{duration:l*(1e3/u),easing:h}}),v=new W(m);if(v.ingest({inserts:a,bounded:!0}),v.computeScene({width:k,height:w}),0===v.scene.length)continue;const b=v.scales?{y:v.scales.y}:void 0;if(A.push(We(v.scene,d,g,y,p,b)),l>0&&r>0&&v.activeTransition){const t=l*(1e3/u);for(let e=1;l>=e;e++)v.advanceTransition(v.activeTransition.startTime+e/l*t),A.push(We(v.scene,d,g,y,p,b))}}return A}function Be(t,e){const i=t.background||e.colors.background;return i&&"transparent"!==i?i:null}function We(t,e,i,r,o,n){const a=ve(r),s=Object.assign({top:20,right:20,bottom:30,left:40},o.margin),c=e-s.left-s.right,l=i-s.top-s.bottom,u=Be(o,r),h=t.map((t,e)=>fe(t,e)).filter(Boolean),d=function(t,e,i,r,o,n){var a;if(!t||0===t.length)return null;const s=ve(r),c=[];for(let r=0;t.length>r;r++){const l=t[r];if("y-threshold"===l.type&&null!=l.value){let t=null;if(n)t=n(l.value);else if(o){const[e,r]=o,n=r-e;if(0===n)continue;t=i-(l.value-e)/n*i}if(null==t)continue;const u=l.color||s.primary,h=null!==(a=l.strokeWidth)&&void 0!==a?a:1.5,d=l.labelPosition||"right";c.push(f.createElement("g",{key:"ann-"+r},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:s.tickSize,fill:u,fontFamily:s.fontFamily},l.label)))}}return c.length>0?f.createElement(f.Fragment,null,c):null}(o.annotations,c,l,r,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:i,role:"img","aria-labelledby":x,style:{fontFamily:a.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:i,fill:u}),f.createElement("g",{transform:`translate(${s.left},${s.top})`},d,h),g&&f.createElement("text",{x:e/2,y:16,textAnchor:"middle",fontSize:a.titleSize,fontWeight:"bold",fill:a.text,fontFamily:a.fontFamily},g));return Ne.renderToStaticMarkup(v)}function Re(t,e,i,r,o){const n=ve(r),a=Object.assign({top:20,right:20,bottom:30,left:40},o.margin),s="radial"===o.projection,c=s?a.left+(e-a.left-a.right)/2:a.left,l=s?a.top+(i-a.top-a.bottom)/2:a.top,u=Be(o,r),h=t.map((t,e)=>de(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:i,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:i,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 Ne.renderToStaticMarkup(x)}exports.generateFrameSVGs=$e,exports.generateFrameSequence=function(t,e,i={}){return e.map(e=>{try{return Te(t,Object.assign(Object.assign({},i),e))}catch(t){return`<svg xmlns="http://www.w3.org/2000/svg" width="${i.width||e.width||600}" height="${i.height||e.height||400}"></svg>`}})},exports.renderChart=Te,exports.renderDashboard=function(t,e={}){var i;const{title:r,subtitle:o,theme:n,width:a=1200,height:s,layout:c={},background:l}=e,u=ve(xe(n)),h=c.columns||2,d=null!==(i=c.gap)&&void 0!==i?i:16;let g=0;r&&(g+=30),o&&(g+=20),g>0&&(g+=10);const y=Math.floor((a-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),i=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:i}),v=Math.max(v,i),m+=t}const b=s||x+v+d,k=p.map((t,e)=>{const{chart:i,x:r,y:o,w:a,h:s}=t,c=Object.assign(Object.assign({},i.props),{width:a,height:s,theme:n,_idPrefix:"chart-"+e});let l;return l=i.component?Te(i.component,c):i.frameType?je(i.frameType,c):`<svg xmlns="http://www.w3.org/2000/svg" width="${a}" height="${s}"></svg>`,f.createElement("g",{key:"dashboard-chart-"+e,transform:`translate(${r},${o})`},f.createElement("foreignObject",{width:a,height:s},f.createElement("div",{xmlns:"http://www.w3.org/1999/xhtml",dangerouslySetInnerHTML:{__html:l}})))}),w=f.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:a,height:b,role:"img","aria-label":r||"Dashboard",style:{fontFamily:u.fontFamily}},r&&f.createElement("title",null,r),l&&f.createElement("rect",{x:0,y:0,width:a,height:b,fill:l}),r&&f.createElement("text",{x:a/2,y:24,textAnchor:"middle",fontSize:u.titleSize+4,fontWeight:"bold",fill:u.text,fontFamily:u.fontFamily},r),o&&f.createElement("text",{x:a/2,y:r?46:20,textAnchor:"middle",fontSize:u.labelSize,fill:u.textSecondary,fontFamily:u.fontFamily},o),k);return Se.renderToStaticMarkup(w)},exports.renderGeoToStaticSVG=function(t){return ze(t)},exports.renderNetworkToStaticSVG=function(t){return Le(t)},exports.renderOrdinalToStaticSVG=function(t){return De(t)},exports.renderToAnimatedGif=function(t,e,i){return d(this,arguments,void 0,function*(t,e,i,r={}){const{fps:o=12,loop:n=!0,scale:a=1,background:s}=r,c=i.height||400,l=Math.round((i.width||600)*a),u=Math.round(c*a),h=$e(t,e,s?Object.assign(Object.assign({},i),{background:s}):i,r);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],i=yield f(Buffer.from(e),{density:72*a}).resize(l,u).ensureAlpha().raw().toBuffer(),r=new Uint8Array(i),o=g(r,256),s=y(r,o);m.writeFrame(s,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,i={}){var r,o;const{format:n="png",scale:a=1,background:s}=i;let c,l;c=["xy","ordinal","network","geo"].includes(t)?je(t,e):Te(t,e),s&&(c=c.replace(/<svg /,`<svg style="background:${s}" `));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===(r=e.size)||void 0===r?void 0:r[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*a}).resize(Math.round(u*a),Math.round(h*a));return"jpeg"===n?f.jpeg({quality:90}).toBuffer():f.png().toBuffer()})},exports.renderToStaticSVG=je,exports.renderXYToStaticSVG=function(t){return Pe(t)},exports.resolveTheme=xe,exports.themeStyles=ve;
|
|
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;
|