semiotic 3.4.0 → 3.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +16 -3
- package/ai/schema.json +42 -1
- package/ai/system-prompt.md +4 -0
- package/dist/components/Annotation.d.ts +42 -2
- package/dist/components/CategoryColors.d.ts +1 -1
- package/dist/components/ChartGrid.d.ts +1 -1
- package/dist/components/ContextLayout.d.ts +1 -1
- package/dist/components/DataSummaryContext.d.ts +1 -1
- package/dist/components/DetailsPanel.d.ts +3 -2
- package/dist/components/Legend.d.ts +2 -3
- package/dist/components/LinkedCharts.d.ts +1 -1
- package/dist/components/ThemeProvider.d.ts +1 -1
- package/dist/components/Tooltip/FlippingTooltip.d.ts +1 -1
- package/dist/components/Tooltip/Tooltip.d.ts +4 -3
- package/dist/components/charts/geo/ChoroplethMap.d.ts +4 -4
- package/dist/components/charts/geo/DistanceCartogram.d.ts +5 -4
- package/dist/components/charts/geo/FlowMap.d.ts +4 -4
- package/dist/components/charts/geo/ProportionalSymbolMap.d.ts +4 -3
- package/dist/components/charts/index.d.ts +2 -0
- package/dist/components/charts/network/ChordDiagram.d.ts +4 -3
- package/dist/components/charts/network/CirclePack.d.ts +3 -3
- package/dist/components/charts/network/ForceDirectedGraph.d.ts +3 -2
- package/dist/components/charts/network/OrbitDiagram.d.ts +6 -5
- package/dist/components/charts/network/SankeyDiagram.d.ts +4 -3
- package/dist/components/charts/network/TreeDiagram.d.ts +3 -3
- package/dist/components/charts/network/Treemap.d.ts +3 -3
- package/dist/components/charts/ordinal/BarChart.d.ts +24 -4
- package/dist/components/charts/ordinal/BoxPlot.d.ts +4 -3
- package/dist/components/charts/ordinal/DonutChart.d.ts +4 -3
- package/dist/components/charts/ordinal/DotPlot.d.ts +4 -3
- package/dist/components/charts/ordinal/FunnelChart.d.ts +4 -3
- package/dist/components/charts/ordinal/GaugeChart.d.ts +2 -1
- package/dist/components/charts/ordinal/GroupedBarChart.d.ts +4 -3
- package/dist/components/charts/ordinal/Histogram.d.ts +4 -3
- package/dist/components/charts/ordinal/LikertChart.d.ts +4 -3
- package/dist/components/charts/ordinal/PieChart.d.ts +4 -3
- package/dist/components/charts/ordinal/RidgelinePlot.d.ts +4 -3
- package/dist/components/charts/ordinal/StackedBarChart.d.ts +4 -3
- package/dist/components/charts/ordinal/SwarmPlot.d.ts +4 -3
- package/dist/components/charts/ordinal/SwimlaneChart.d.ts +4 -3
- package/dist/components/charts/ordinal/ViolinPlot.d.ts +4 -3
- package/dist/components/charts/realtime/RealtimeHeatmap.d.ts +7 -6
- package/dist/components/charts/realtime/RealtimeHistogram.d.ts +10 -7
- package/dist/components/charts/realtime/RealtimeLineChart.d.ts +9 -6
- package/dist/components/charts/realtime/RealtimeSwarmChart.d.ts +7 -6
- package/dist/components/charts/realtime/RealtimeWaterfallChart.d.ts +9 -6
- package/dist/components/charts/shared/ChartError.d.ts +1 -2
- package/dist/components/charts/shared/annotationResolvers.d.ts +4 -3
- package/dist/components/charts/shared/annotationRules.d.ts +2 -1
- package/dist/components/charts/shared/colorUtils.d.ts +4 -3
- package/dist/components/charts/shared/datumTypes.d.ts +20 -0
- package/dist/components/charts/shared/diagnoseConfig.d.ts +2 -7
- package/dist/components/charts/shared/formatUtils.d.ts +4 -2
- package/dist/components/charts/shared/hooks.d.ts +27 -23
- package/dist/components/charts/shared/legendUtils.d.ts +3 -2
- package/dist/components/charts/shared/mergeShapeStyle.d.ts +43 -0
- package/dist/components/charts/shared/networkUtils.d.ts +7 -6
- package/dist/components/charts/shared/selectionUtils.d.ts +5 -4
- package/dist/components/charts/shared/statisticalOverlays.d.ts +14 -26
- package/dist/components/charts/shared/statisticalOverlaysLazy.d.ts +2 -2
- package/dist/components/charts/shared/statsTooltip.d.ts +3 -2
- package/dist/components/charts/shared/tooltipUtils.d.ts +7 -6
- package/dist/components/charts/shared/types.d.ts +22 -13
- package/dist/components/charts/shared/useChartSetup.d.ts +7 -6
- package/dist/components/charts/shared/useLikertAggregation.d.ts +18 -7
- package/dist/components/charts/shared/useOrdinalStreaming.d.ts +3 -2
- package/dist/components/charts/shared/useStreamingLegend.d.ts +2 -1
- package/dist/components/charts/shared/validateChartData.d.ts +2 -1
- package/dist/components/charts/shared/validateProps.d.ts +2 -8
- package/dist/components/charts/shared/withChartWrapper.d.ts +1 -1
- package/dist/components/charts/xy/AreaChart.d.ts +4 -3
- package/dist/components/charts/xy/BubbleChart.d.ts +4 -3
- package/dist/components/charts/xy/CandlestickChart.d.ts +47 -0
- package/dist/components/charts/xy/ConnectedScatterplot.d.ts +4 -3
- package/dist/components/charts/xy/Heatmap.d.ts +12 -7
- package/dist/components/charts/xy/LineChart.d.ts +4 -3
- package/dist/components/charts/xy/MinimapChart.d.ts +4 -4
- package/dist/components/charts/xy/MultiAxisLineChart.d.ts +5 -4
- package/dist/components/charts/xy/QuadrantChart.d.ts +4 -3
- package/dist/components/charts/xy/Scatterplot.d.ts +4 -3
- package/dist/components/charts/xy/ScatterplotMatrix.d.ts +3 -3
- package/dist/components/charts/xy/StackedAreaChart.d.ts +4 -3
- package/dist/components/data/transforms.d.ts +8 -7
- package/dist/components/export/chartConfig.d.ts +4 -3
- package/dist/components/export/selectionSerializer.d.ts +1 -1
- package/dist/components/geo/mergeData.d.ts +2 -1
- package/dist/components/realtime/BinAccumulator.d.ts +3 -2
- package/dist/components/realtime/renderers/types.d.ts +2 -1
- package/dist/components/realtime/renderers/waterfallRenderer.d.ts +2 -1
- package/dist/components/realtime/types.d.ts +25 -21
- package/dist/components/semiotic-themes.d.ts +2 -1
- package/dist/components/semiotic-xy.d.ts +2 -0
- package/dist/components/semiotic.d.ts +3 -3
- package/dist/components/server/animatedGif.d.ts +4 -18
- package/dist/components/server/renderToStaticSVG.d.ts +5 -4
- package/dist/components/server/serverChartConfigs.d.ts +2 -10
- package/dist/components/server/staticAnnotations.d.ts +2 -1
- package/dist/components/server/staticLegend.d.ts +2 -1
- package/dist/components/store/ObservationStore.d.ts +4 -3
- package/dist/components/store/SelectionStore.d.ts +4 -9
- package/dist/components/store/ThemeStore.d.ts +32 -4
- package/dist/components/store/TooltipStore.d.ts +6 -2
- package/dist/components/store/useSelection.d.ts +13 -9
- package/dist/components/stream/AccessibleDataTable.d.ts +5 -5
- package/dist/components/stream/CanvasHitTester.d.ts +2 -1
- package/dist/components/stream/DataSourceAdapter.d.ts +2 -1
- package/dist/components/stream/FocusRing.d.ts +1 -2
- package/dist/components/stream/GeoParticlePool.d.ts +2 -1
- package/dist/components/stream/GeoPipelineStore.d.ts +7 -6
- package/dist/components/stream/MarginalGraphics.d.ts +1 -2
- package/dist/components/stream/NetworkPipelineStore.d.ts +3 -2
- package/dist/components/stream/NetworkSVGOverlay.d.ts +21 -15
- package/dist/components/stream/OrdinalBrushOverlay.d.ts +1 -19
- package/dist/components/stream/OrdinalPipelineStore.d.ts +6 -5
- package/dist/components/stream/OrdinalSVGOverlay.d.ts +6 -5
- package/dist/components/stream/PipelineStore.d.ts +63 -28
- package/dist/components/stream/SVGOverlay.d.ts +10 -10
- package/dist/components/stream/SceneGraph.d.ts +6 -5
- package/dist/components/stream/StreamGeoFrame.d.ts +2 -1
- package/dist/components/stream/StreamNetworkFrame.d.ts +2 -1
- package/dist/components/stream/StreamOrdinalFrame.d.ts +2 -1
- package/dist/components/stream/StreamXYFrame.d.ts +2 -1
- package/dist/components/stream/XYBrushOverlay.d.ts +1 -21
- package/dist/components/stream/devDataAccessWarning.d.ts +2 -11
- package/dist/components/stream/geoTypes.d.ts +43 -24
- package/dist/components/stream/hoverUtils.d.ts +2 -1
- package/dist/components/stream/keyboardNav.d.ts +18 -6
- package/dist/components/stream/layouts/hierarchySceneBuilders.d.ts +4 -3
- package/dist/components/stream/layouts/hierarchyUtils.d.ts +4 -3
- package/dist/components/stream/networkTypes.d.ts +73 -47
- package/dist/components/stream/ordinalSceneBuilders/barFunnelScene.d.ts +1 -1
- package/dist/components/stream/ordinalSceneBuilders/barScene.d.ts +2 -2
- package/dist/components/stream/ordinalSceneBuilders/connectorScene.d.ts +1 -1
- package/dist/components/stream/ordinalSceneBuilders/pointScene.d.ts +2 -2
- package/dist/components/stream/ordinalSceneBuilders/statisticalScene.d.ts +4 -4
- package/dist/components/stream/ordinalSceneBuilders/swimlaneScene.d.ts +1 -1
- package/dist/components/stream/ordinalSceneBuilders/timelineScene.d.ts +1 -1
- package/dist/components/stream/ordinalSceneBuilders/types.d.ts +9 -8
- package/dist/components/stream/ordinalTypes.d.ts +65 -33
- package/dist/components/stream/pipelineDecay.d.ts +2 -1
- package/dist/components/stream/pipelinePulse.d.ts +2 -1
- package/dist/components/stream/pipelineTransitions.d.ts +16 -4
- package/dist/components/stream/renderers/colorUtils.d.ts +20 -0
- package/dist/components/stream/types.d.ts +58 -17
- package/dist/components/stream/xySceneBuilders/areaScene.d.ts +3 -2
- package/dist/components/stream/xySceneBuilders/barScene.d.ts +2 -1
- package/dist/components/stream/xySceneBuilders/boundsScene.d.ts +2 -1
- package/dist/components/stream/xySceneBuilders/candlestickScene.d.ts +2 -1
- package/dist/components/stream/xySceneBuilders/emitPointNodes.d.ts +3 -2
- package/dist/components/stream/xySceneBuilders/heatmapScene.d.ts +2 -1
- package/dist/components/stream/xySceneBuilders/lineScene.d.ts +2 -1
- package/dist/components/stream/xySceneBuilders/mixedScene.d.ts +2 -1
- package/dist/components/stream/xySceneBuilders/pointScene.d.ts +2 -1
- package/dist/components/stream/xySceneBuilders/swarmScene.d.ts +2 -1
- package/dist/components/stream/xySceneBuilders/types.d.ts +35 -26
- package/dist/components/stream/xySceneBuilders/waterfallScene.d.ts +2 -1
- package/dist/components/types/marginType.d.ts +15 -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-statisticalOverlays-Ckd_jM8z.js +1 -0
- package/dist/semiotic-themes.d.ts +2 -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-xy.d.ts +2 -0
- package/dist/semiotic.d.ts +3 -3
- 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/test-utils/canvasMock.d.ts +10 -2
- package/dist/xy.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +38 -32
- package/dist/components/types/annotationTypes.d.ts +0 -145
- package/dist/components/types/generalTypes.d.ts +0 -241
- package/dist/components/types/interactionTypes.d.ts +0 -72
- package/dist/components/types/networkTypes.d.ts +0 -174
- package/dist/components/types/ordinalTypes.d.ts +0 -112
- package/dist/semiotic-statisticalOverlays-DGX_WWc5.js +0 -1
package/dist/server.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const t=require("react"),e=require("react-dom/server"),i=require("d3-scale"),r=require("d3-quadtree"),o=require("d3-scale-chromatic"),n=require("d3-array"),a=require("d3-interpolate"),s=require("d3-force"),c=require("d3-chord"),l=require("d3-shape"),u=require("d3-hierarchy"),h=require("d3-geo");function d(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=d(t),g=d(e);function y(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 p{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 m{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 x(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 v(t,e){return t===e||typeof t==typeof e&&"function"==typeof t&&"function"==typeof e&&""+t==""+e}function b(t,e){if("function"==typeof t)return e=>+t(e);const i=t||e;return t=>+t[i]}function k(t,e){if("function"==typeof t)return t;const i=t||e;return t=>t[i]}function A(t,e){return"function"==typeof t?t:t?e=>e[t]+"":e?t=>t[e]+"":void 0}const w={category10:o.schemeCategory10,tableau10:o.schemeTableau10,set3:o.schemeSet3,blues:o.interpolateBlues,reds:o.interpolateReds,greens:o.interpolateGreens,oranges:o.interpolateOranges,purples:o.interpolatePurples,viridis:o.interpolateViridis,plasma:o.interpolatePlasma},S=o.schemeCategory10,_=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],P=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);function E(t,e,r="category10"){const o=Array.from(new Set(t.map(t=>null==t?void 0:t[e]).filter(t=>null!=t))),n=o.every(t=>"number"==typeof t||!isNaN(Number(t)));if(Array.isArray(r))return i.scaleOrdinal().domain(o).range(r).unknown("#999");const a=w[r]||w.category10;if(n&&"function"==typeof a){let t=-1/0;for(const e of o){const i=Number(e);i>t&&(t=i)}return e=>a(Number(e)/t)}{const t=Array.isArray(a)?a:S;return i.scaleOrdinal().domain(o).range(t).unknown("#999")}}function M(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 O(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 T(t,e="ease-out-cubic"){return"linear"===e?t:1-Math.pow(1-t,3)}function L(t,e){return Math.min((t-e.startTime)/e.duration,1)}function D(t,e,i){return t+(e-t)*i}function j(){return"undefined"!=typeof performance?performance.now():Date.now()}function z(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 $(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 R(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 N(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 C(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 B(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 W(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 F(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=N(a,t.scales,t.getX,n,s,r,c);l&&i.push(l)}}}const I={blues:o.interpolateBlues,reds:o.interpolateReds,greens:o.interpolateGreens,viridis:o.interpolateViridis},Y=new Map;class q{constructor(t){if(this.xExtent=new m,this.yExtent=new m,this.timestampBuffer=null,this.activeTransition=null,this._hasRenderedOnce=!1,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._maxPointRadius=0,this.config=t,this.buffer=new p(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=b(t.timeAccessor||t.xAccessor,"time"),this.getY=b(t.valueAccessor||t.yAccessor,"value")):(this.getX=b(t.xAccessor,"x"),this.getY=b(t.yAccessor,"y")),this.getGroup=A(t.groupAccessor),this.getCategory=A(t.categoryAccessor),this.getSize=t.sizeAccessor?b(t.sizeAccessor,"size"):void 0,this.getColor=A(t.colorAccessor),this.getBounds=t.boundsAccessor?b(t.boundsAccessor,"bounds"):void 0,this.getY0=t.y0Accessor?b(t.y0Accessor,"y0"):void 0,this.getPointId=A(t.pointIdAccessor),"candlestick"===t.chartType){const e=null!=t.openAccessor,i=null!=t.closeAccessor;this.getOpen=e?b(t.openAccessor,"open"):void 0,this.getHigh=b(t.highAccessor,"high"),this.getLow=b(t.lowAccessor,"low"),this.getClose=i?b(t.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!i}t.pulse&&(this.timestampBuffer=new p(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?b(this.config.timeAccessor||this.config.xAccessor,"time"):b(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 e,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!==(e=this.config.scalePadding)&&void 0!==e?e: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(),d=this.xExtent.extent,f=this.yExtent.extent;let g=l.xExtent?[null!==(r=l.xExtent[0])&&void 0!==r?r:d[0],null!==(o=l.xExtent[1])&&void 0!==o?o:d[1]]:d,y=l.yExtent?[null!==(n=l.yExtent[0])&&void 0!==n?n:f[0],null!==(a=l.yExtent[1])&&void 0!==a?a:f[1]]:f;const p=l.yExtent&&null!=l.yExtent[0]&&null!=l.yExtent[1];if("stackedarea"===l.chartType&&!p&&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;let r=0;for(const t of e)for(const e of t.data){const t=this.getX(e),o=this.getY(e);if(null==t||null==o||Number.isNaN(t)||Number.isNaN(o))continue;const n=(i.get(t)||0)+o;i.set(t,n),n>r&&(r=n)}y=[0,r+(r>0?r*l.extentPadding:1)],this._stackExtentCache={key:t,yDomain:y}}}else if("bar"===l.chartType&&l.binSize&&!p&&u.size>0){const[,t]=function(t,e,i,r,o){const n=x(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&&!p&&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(!p&&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]&&f[0]>0&&(y[0]=null!=i?y[0]:f[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 m="streaming"===l.runtimeMode,v=Math.max(0,Math.min(l.scalePadding||0,Math.min(t.width,t.height)/2-1));if(m)if("x"==("up"===(b=l.arrowOfTime)||"down"===b?"y":"x")){const e="right"===l.arrowOfTime?[v,t.width-v]:[t.width-v,v];this.scales={x:i.scaleLinear().domain(g).range(e),y:i.scaleLinear().domain(y).range([t.height-v,v])}}else{const e="down"===l.arrowOfTime?[v,t.height-v]:[t.height-v,v];this.scales={x:i.scaleLinear().domain(y).range([v,t.width-v]),y:i.scaleLinear().domain(g).range(e)}}else{const e=(t,e,r)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return i.scaleLog().domain(t).range(r).clamp(!0)}return"time"===t?i.scaleTime().domain([new Date(e[0]),new Date(e[1])]).range(r):i.scaleLinear().domain(e).range(r)};this.scales={x:e(l.xScaleType,g,[v,t.width-v]),y:e(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._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),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 this._quadtree=null,void(this._maxPointRadius=0);let e=0,i=0;for(const t of this.scene)"point"===t.type&&(e++,t.r>i&&(i=t.r));if(this._maxPointRadius=i,q.QUADTREE_THRESHOLD>=e)return void(this._quadtree=null);const o=Array(e);let n=0;for(const t of this.scene)"point"===t.type&&(o[n++]=t);this._quadtree=r.quadtree().x(t=>t.x).y(t=>t.y).addAll(o)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}remapScene(t){const e=t.width/this.lastLayout.width,r=t.height/this.lastLayout.height;for(const t of this.scene)switch(t.type){case"line":for(const i of t.path)i[0]*=e,i[1]*=r;break;case"area":for(const i of t.topPath)i[0]*=e,i[1]*=r;for(const i of t.bottomPath)i[0]*=e,i[1]*=r;break;case"point":t.x*=e,t.y*=r;break;case"rect":case"heatcell":t.x*=e,t.y*=r,t.w*=e,t.h*=r;break;case"candlestick":t.x*=e,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,e,r)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return i.scaleLog().domain(t).range(r).clamp(!0)}return"time"===t?i.scaleTime().domain([new Date(e[0]),new Date(e[1])]).range(r):i.scaleLinear().domain(e).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:r,scales:n}=this;if(!n||0===e.length)return[];const a={scales:n,config:r,getX:this.getX,getY:this.getY,getY0:this.getY0,getSize:this.getSize,getColor:this.getColor,getGroup:this.getGroup,getCategory:this.getCategory,getPointId:this.getPointId,getBounds:this.getBounds,getOpen:this.getOpen,getHigh:this.getHigh,getLow:this.getLow,getClose:this.getClose,resolveLineStyle:(t,e)=>this.resolveLineStyle(t,e),resolveAreaStyle:(t,e)=>this.resolveAreaStyle(t,e),resolveBoundsStyle:(t,e)=>this.resolveBoundsStyle(t,e),resolveColorMap:t=>this.resolveColorMap(t),resolveGroupColor:t=>this.resolveGroupColor(t),groupData:t=>this.groupData(t),barCategoryCache:this._barCategoryCache};switch(r.chartType){case"line":return function(t,e){var i;const 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=W(t,e.data,e.key);i&&o.push(i)}for(const e of r){const i=t.resolveLineStyle(e.key,e.data[0]),r=$(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 F(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=R(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 F(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=R(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=$(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 F(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 d=[],f=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)}f.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),d.push(y)}return{nodes:d,stackedTops:f}}(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)};F(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=N(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=b(t.config.valueAccessor,"value");if(!t.scales||0===e.length)return[];const[u,h]=t.scales.x.domain(),[d,f]=t.scales.y.domain(),g=(h-u||1)/a,y=(f-d||1)/s,p=a*s;if(p>1e6)return[];const m=new Int32Array(p),x=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-d)/y),s-1);if(0>c||0>h)continue;const f=h*a+c;m[f]++;const p=l(r);x[f]+=isFinite(p)?p:0}let v=1/0,k=-1/0;for(let t=0;p>t;t++){if(0===m[t])continue;let e;switch(c){case"sum":e=x[t];break;case"mean":e=x[t]/m[t];break;default:e=m[t]}v>e&&(v=e),e>k&&(k=e)}if(!isFinite(v))return[];const A=k-v||1,w=i.width/a,S=i.height/s,_=t.config.showValues,P=t.config.heatmapValueFormat,E=[];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=x[r];break;case"mean":o=x[r]/m[r];break;default:o=m[r]}const n=(o-v)/A;E.push(B(i*w,(s-1-t)*S,w,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:x[r]},_?{value:o,showValues:!0,valueFormat:P}:void 0))}}return E}(t,e,i);if(0===e.length)return[];const r=b(t.config.valueAccessor,"value"),n=k(t.config.xAccessor,"x"),a=k(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,d=c.size;if(0===h||0===d)return[];const f=Array.from(s.keys()),g=Array.from(c.keys()),y=f.every(t=>"number"==typeof t&&!isNaN(t)),p=g.every(t=>"number"==typeof t&&!isNaN(t));if(y){f.sort((t,e)=>t-e),s.clear();for(let t=0;f.length>t;t++)s.set(f[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),x=new Float64Array(e.length),v=Array(e.length),A=new Map;let w=0;for(let t=0;e.length>t;t++){const i=e[t],o=s.get(l[t]),n=c.get(u[t]);if(void 0===o||void 0===n)continue;const a=r(i),d=n*h+o,f=A.get(d);let g;void 0!==f?g=f:(g=w++,A.set(d,g)),m[g]=d,x[g]=a,v[g]=i}let S=1/0,_=-1/0;for(let t=0;w>t;t++){const e=x[t];isFinite(e)&&(S>e&&(S=e),e>_&&(_=e))}if(!isFinite(S)||!isFinite(_))return[];const P=function(t){const e=t in I?t:"blues";let i=Y.get(e);if(i)return i;i=Array(256);const r=I[e]||o.interpolateBlues;for(let t=0;256>t;t++)i[t]=r(t/255);return Y.set(e,i),i}("string"==typeof t.config.colorScheme?t.config.colorScheme:"blues"),E=255/(_-S||1),M=i.width/h,O=i.height/d,T=t.config.showValues,L=t.config.heatmapValueFormat,D=[];for(let t=0;w>t;t++){const e=x[t];if(!isFinite(e))continue;const i=m[t],r=i%h;D.push(B(r*M,(d-1-(i-r)/h)*O,M,O,P[Math.min((e-S)*E+.5|0,255)],v[t],T?{value:e,showValues:!0,valueFormat:L}:void 0))}return D}(a,e,t);case"bar":{const t=function(t,e){var i;if(!t.config.binSize)return{nodes:[],binBoundaries:[]};const r=x(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),d=Math.abs(h-u),f=d>2?1:0,g=Math.min(u,h)+f/2,y=Math.max(d-f,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(C(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(C(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,d=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 f=l;if(t.getCategory){const e=t.getCategory(i);f=(null===(n=t.config.barColors)||void 0===n?void 0:n[e])||f}const g={type:"point",x:o,y:s,r:c,style:{fill:f,opacity:u,stroke:h,strokeWidth:d},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",d=null!==(n=null==c?void 0:c.gap)&&void 0!==n?n:1,f=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)+d/2,k=Math.max(x,v)-d/2-b;if(0>=k){y=p;continue}const A=s.y(y),w=s.y(p);a.push(C(b,Math.min(A,w),k,Math.abs(A-w),{fill:0>n?h:u,stroke:f,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),d=e.map(e=>t.getX(e)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let f=o?0:null!==(r=a.bodyWidth)&&void 0!==r?r:0;if(!o&&null==a.bodyWidth&&d.length>1){let e=1/0;for(let i=1;d.length>i;i++){const r=Math.abs(t.scales.x(d[i])-t.scales.x(d[i-1]));r>0&&e>r&&(e=r)}f=e!==1/0?Math.max(2,Math.min(.6*e,20)):6}else o||null!=a.bodyWidth||(f=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),d=o?a:t.getClose(i);if(!o&&[s,d].some(t=>null==t||Number.isNaN(t)))continue;const g=d>=s,y={type:"candlestick",x:t.scales.x(e),openY:t.scales.y(s),closeY:t.scales.y(d),highY:t.scales.y(r),lowY:t.scales.y(a),bodyWidth:f,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?M(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]=M(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]=M(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=M(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=M(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=O(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=O(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=z(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)}synthesizeIntroPositions(){var t,e,i;this.prevPositionMap.clear(),this.prevPathMap.clear();const r=null!==(e=null===(t=this.scales)||void 0===t?void 0:t.y(0))&&void 0!==e?e:0;for(let t=0;this.scene.length>t;t++){const e=this.scene[t],o=z(this.transitionContext,e,t);o&&("point"===e.type?this.prevPositionMap.set(o,{x:e.x,y:e.y,r:0,opacity:0}):"rect"===e.type?this.prevPositionMap.set(o,{x:e.x,y:r,w:e.w,h:0,opacity:null!==(i=e.style.opacity)&&void 0!==i?i:1}):"heatcell"===e.type?this.prevPositionMap.set(o,{x:e.x,y:e.y,w:e.w,h:e.h,opacity:0}):"line"===e.type?(e._introClipFraction=0,this.prevPathMap.set(o,{path:e.path.map(t=>[t[0],t[1]]),opacity:e.style.opacity})):"area"===e.type&&(e._introClipFraction=0,this.prevPathMap.set(o,{topPath:e.topPath.map(t=>[t[0],t[1]]),bottomPath:e.bottomPath.map(t=>[t[0],t[1]]),opacity:e.style.opacity})))}}startTransition(){if(!this.config.transition)return;const t=function(t,e,i,r,o){var n,a,s,c,l,u,h,d,f,g,y,p,m,x,v,b,k,A,w,S,_,P,E,M,O,T,L,D;if(0===r.size&&0===o.size)return i;const $=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 R=!1;const N=new Set,C=new Set;for(let e=0;i.scene.length>e;e++){const n=i.scene[e],w=z(t,n,e);if(!w)continue;if(n._transitionKey=w,"line"===n.type||"area"===n.type){const t=o.get(w);if(t){if(C.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]];R=!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]];R=!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}),R=!0;continue}const S=r.get(w);if("point"===n.type)if(S){N.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,R=!0)}else n._targetOpacity=null!==(d=n.style.opacity)&&void 0!==d?d:1,n.style=Object.assign(Object.assign({},n.style),{opacity:0}),R=!0;else if("rect"===n.type)if(S){N.add(w);const t={x:n.x,y:n.y,w:n.w,h:n.h};n._targetOpacity=null!==(f=n.style.opacity)&&void 0!==f?f: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,R=!0)}else n._targetOpacity=null!==(p=n.style.opacity)&&void 0!==p?p:1,n.style=Object.assign(Object.assign({},n.style),{opacity:0}),R=!0;else if("heatcell"===n.type)if(S){N.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,R=!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}),R=!0}for(const[t,e]of o)if(!C.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!==(w=e.opacity)&&void 0!==w?w:1},_targetOpacity:0,_transitionKey:t,datum:null};i.exitNodes.push(r),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),R=!0}for(const[t,e]of r)if(!N.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!==(P=e.opacity)&&void 0!==P?P: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!==(E=e.w)&&void 0!==E?E:0,h:null!==(M=e.h)&&void 0!==M?M:0,style:{opacity:null!==(O=e.opacity)&&void 0!==O?O: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!==(T=e.w)&&void 0!==T?T:0,h:null!==(L=e.h)&&void 0!==L?L:0,fill:"#999",datum:null,style:{opacity:null!==(D=e.opacity)&&void 0!==D?D:1},_targetOpacity:0,_transitionKey:t};i.exitNodes.push(r)}R=!0}return i.exitNodes.length>0&&(i.scene=[...i.scene,...i.exitNodes]),R&&(i.activeTransition={startTime:j(),duration:$}),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=L(t,i.activeTransition),u=T(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=D(n,t._targetOpacity,u)}if(void 0===t._targetX)continue;if(!e)continue;const i=r.get(e);if(!i)continue;t.x=D(i.x,t._targetX,u),t.y=D(i.y,t._targetY,u),void 0!==t._targetR&&void 0!==i.r&&(t.r=D(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=D(o,t._targetOpacity,u)}if(void 0===t._targetX)continue;if(!e)continue;const i=r.get(e);if(!i)continue;t.x=D(i.x,t._targetX,u),t.y=D(i.y,t._targetY,u),void 0!==i.w&&(t.w=D(i.w,t._targetW,u)),void 0!==i.h&&(t.h=D(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:D(o,t._targetOpacity,u)})}if(void 0===t._targetX)continue;if(!e)continue;const i=r.get(e);if(!i)continue;t.x=D(i.x,t._targetX,u),t.y=D(i.y,t._targetY,u),void 0!==i.w&&(t.w=D(i.w,t._targetW,u)),void 0!==i.h&&(t.h=D(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:D(e,t._targetOpacity,u)})}void 0!==t._introClipFraction&&(t._introClipFraction=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]=D(e[r][0],i[r][0],u),t.path[r][1]=D(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:D(e,t._targetOpacity,u)})}void 0!==t._introClipFraction&&(t._introClipFraction=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]=D(e[i][0],r[i][0],u),t.topPath[i][1]=D(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]=D(i[e][0],o[e][0],u),t.bottomPath[e][1]=D(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,t._introClipFraction=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,t._introClipFraction=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){if(this._colorMapCache&&this._colorMapCache.version===this._ingestVersion)return this._colorMapCache.map;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.version=this._ingestVersion,this._colorMapCache.map;const o=Array.isArray(this.config.colorScheme)?this.config.colorScheme:this.config.themeCategorical||_,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,version:this._ingestVersion},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:this.config.themeCategorical||_,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");this.config.transition&&this.scene.length>0&&this.snapshotPositions();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._hasRenderedOnce=!1,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._maxPointRadius=0,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);("colorScheme"in t||"themeCategorical"in t||"colorAccessor"in t)&&(this._colorMapCache=null,this._groupColorMap=new Map),("barColors"in t||"colorScheme"in t)&&(this._barCategoryCache=null),("normalize"in t||"extentPadding"in t||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t||"groupAccessor"in t||"categoryAccessor"in t||"chartType"in t||"runtimeMode"in t)&&(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||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t){const c=s||!v(null!==(e=t.xAccessor)&&void 0!==e?e:t.timeAccessor,null!==(i=n.xAccessor)&&void 0!==i?i:n.timeAccessor),l=s||!v(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=b(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=b(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=b(this.config.xAccessor,"x"),this.getY=b(this.config.yAccessor,"y")),a=!0)}if("groupAccessor"in t&&!v(t.groupAccessor,n.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?A(this.config.groupAccessor):void 0,a=!0),"categoryAccessor"in t&&!v(t.categoryAccessor,n.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?A(this.config.categoryAccessor):void 0,a=!0),"sizeAccessor"in t&&!v(t.sizeAccessor,n.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?b(this.config.sizeAccessor,"size"):void 0,a=!0),"colorAccessor"in t&&!v(t.colorAccessor,n.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?A(this.config.colorAccessor):void 0,a=!0),"y0Accessor"in t&&!v(t.y0Accessor,n.y0Accessor)&&(this.getY0=this.config.y0Accessor?b(this.config.y0Accessor,"y0"):void 0,a=!0),"pointIdAccessor"in t&&!v(t.pointIdAccessor,n.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?A(this.config.pointIdAccessor):void 0,a=!0),"candlestick"===this.config.chartType&&("openAccessor"in t&&!v(t.openAccessor,n.openAccessor)||"closeAccessor"in t&&!v(t.closeAccessor,n.closeAccessor)||"highAccessor"in t&&!v(t.highAccessor,n.highAccessor)||"lowAccessor"in t&&!v(t.lowAccessor,n.lowAccessor))){const t=null!=this.config.openAccessor,e=null!=this.config.closeAccessor;this.getOpen=t?b(this.config.openAccessor,"open"):void 0,this.getHigh=b(this.config.highAccessor,"high"),this.getLow=b(this.config.lowAccessor,"low"),this.getClose=e?b(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 X(t,e){var i=t.get(e);if(!i)throw Error("missing: "+e);return i}function G(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 d=a[r=s[t][e]];d||(a[r]=d={}),d[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=[],d=[];function f(e){var c=[e],l=[e];for(i[e]=r[e]=u,o[e]=!0,u+=1;l.length>0;){var f=t[e=l[l.length-1]];if(f.length>n[e]){for(var g=n[e];f.length>g;++g){var y=f[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];d.push(b)}l.pop()}}}for(c=0;e>c;++c)0>i[c]&&f(c);for(c=0;d.length>c;c++){var g=d[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]);d[c]=l}}return{components:h,adjacencyList:d}}(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 d=t.length;d>i;){var f=h(i);if(i=f.leastVertex,s=f.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=d}return r}function V(t){return t.y0-t.y1>0?"up":"down"}function H(t,e){return e(t.source)==e(t.target)}function Q(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 Z(t){return t.target.x0-t.source.x1}function U(t,e){var i=J(t),r=Z(e)/Math.tan(i);return"up"==V(t)?t.y1-r:t.y1+r}function K(t,e){var i=J(t),r=Z(e)/Math.tan(i);return"up"==V(t)?t.y1+r:t.y1-r}function J(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function tt(t,e){return e(t)}function et(t){return rt(t.source)}function it(t){return rt(t.target)}function rt(t){return(t.y0+t.y1)/2}function ot(t){return t.virtual?0:t.value}function nt(t,e){var i=0;t.sourceLinks.forEach(function(t){i=t.circular&&!H(t,e)?i+1:i});var r=0;return t.targetLinks.forEach(function(t){r=t.circular&&!H(t,e)?r+1:r}),i+r}function at(t){return t.target.depth}function st(t,e){return t.sourceLinks.length?t.depth:e-1}function ct(t,e){return t.y0-e.y0}function lt(t,e){return e.y0-t.y0}function ut(t,e){return t.y1-e.y1}function ht(t,e){return e.y1-t.y1}function dt(t,e){return gt(t.source,e.source)||t.index-e.index}function ft(t,e){return gt(t.target,e.target)||t.index-e.index}function gt(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function yt(t,e){return pt(t)==pt(e)?"bottom"==t.circularLinkType?lt(t,e):ct(t,e):pt(e)-pt(t)}function pt(t){return t.target.column-t.source.column}function mt(t,e){return xt(t)==xt(e)}function xt(t){return t.y0-t.y1>0?"up":"down"}function vt(t,e,i,r,o){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=n.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}),bt(a.links.filter(function(t){return"top"==t.circularLinkType}),e,i),bt(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,H(t,e)&&Q(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+o+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=t.source.y0-o-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius);else{var n=t.source.column,s=t.circularLinkType,l=a.links.filter(function(t){return t.source.column==n&&t.circularLinkType==s});l.sort("bottom"==t.circularLinkType?lt:ct);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}),n=t.target.column,(l=a.links.filter(function(t){return t.target.column==n&&t.circularLinkType==s})).sort("bottom"==t.circularLinkType?ht:ut),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)+o+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=c-o-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius)}t.circularPathData.rightInnerExtent=t.circularPathData.sourceX+t.circularPathData.rightNodeBuffer,t.circularPathData.leftInnerExtent=t.circularPathData.targetX-t.circularPathData.leftNodeBuffer,t.circularPathData.rightFullExtent=t.circularPathData.sourceX+t.circularPathData.rightLargeArcRadius+t.circularPathData.rightNodeBuffer,t.circularPathData.leftFullExtent=t.circularPathData.targetX-t.circularPathData.leftLargeArcRadius-t.circularPathData.leftNodeBuffer}t.path=t.circular?function(t){return"top"==t.circularLinkType?"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 0 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY-t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 0 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 0 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY-t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 0 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY:"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 1 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY+t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 1 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 1 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY+t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 1 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY}(t):function(t){var e=t.source.x1,i=t.y0,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 bt(t,e,i){t.sort(yt);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(H(t,e)&&Q(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&&kt(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 kt(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}function At(t){return function(){return t}}function wt(t){return t.index}function St(t){return t.nodes}function _t(t){return t.links}function Pt(t,e,i){var r=n.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+=rt(t.source)*e,r+=e}}),i.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;o+=rt(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?nt(e,i)-nt(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==nt(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 Et(t,e,i,r,o,a){var s=n.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(o){var a=o.length,s=o[0].depth;o.forEach(function(o){var c;if(o.sourceLinks.length||o.targetLinks.length)if(o.partOfCycle&&nt(o,i)>0){var l=n.mean(o.sourceLinks,it),u=n.mean(o.targetLinks,et),h=l&&u?(l+u)/2:l||u;if(h){var d=(h-rt(o))*e*.3;o.y0+=d,o.y1+=d}}else if(0==s&&1==a)o.y0=t.y1/2-(c=o.y1-o.y0)/2,o.y1=t.y1/2+c/2;else if(s==r-1&&1==a)o.y0=t.y1/2-(c=o.y1-o.y0)/2,o.y1=t.y1/2+c/2;else if(1==o.targetLinks.length&&1==o.targetLinks[0].source.sourceLinks.length)c=o.y1-o.y0,o.y0=o.targetLinks[0].source.y0,o.y1=o.y0+c;else{var f=n.mean(o.sourceLinks,it),g=n.mean(o.targetLinks,et),y=((f&&g?(f+g)/2:f||g)-rt(o))*e;o.y0+=y,o.y1+=y}})})}function h(){s.forEach(function(i){var n,a,s,c=t.y0,l=i.length;for(i.sort(e||gt),s=0;l>s;++s)(a=c-(n=i[s]).y0)>0&&(n.y0+=a,n.y1+=a),c=n.y1+r;if((a=c-r-t.y1)>0)for(c=n.y0-=a,n.y1-=a,s=l-2;s>=0;--s)(a=(n=i[s]).y1+o-c)>0&&(n.y0-=a,n.y1-=a),c=n.y0})}}function Mt(t){t.nodes.forEach(function(t){t.sourceLinks.sort(ft),t.targetLinks.sort(dt)}),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 Ot(){var t=0,e=0,i=1,r=1,o=24,a=8,s=null,c=wt,l=st,u=void 0,h=32,d=2,f=St,g=_t;function y(){var y={nodes:f.apply(null,arguments),links:g.apply(null,arguments)};return function(f){f.x0=t,f.y0=e,f.x1=i,f.y1=r,f.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 n.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=X(i,r)),"object"!=typeof o&&(o=t.target=X(i,o)),r.sourceLinks.push(t),o.targetLinks.push(t)})}(f,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=G(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++)})}(f,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){tt(t,e)!=tt(o.source,e)&&tt(t,e)!=tt(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),H(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(f,c),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max(n.sum(t.sourceLinks,ot),n.sum(t.targetLinks,ot)),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)})})}(f),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})}(f,u,l);var g=a;if(null!==s){var y=n.groups(f.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),p=n.max(y,function(t){return t.length});p>1&&(g=Math.max(1,(r-e)*s/(p-1)))}(function(t,e,i){var r=n.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});t.py=e;var o=n.min(r,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/n.sum(e,function(t){return t.value})});t.ky=o,t.links.forEach(function(e){e.width=e.value*t.ky});var a=n.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})})(f,g,o),Pt(f,u,c),Et(f,u,c,g,g,h),Mt(f),vt(f,c,d,10,8),Pt(f,u,c),Et(f,u,c,g,g,h),Mt(f),vt(f,c,d,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 tt(i.source,e)==tt(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(!mt(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var i=U(e,t);return t.y1-i}if(e.target.column>t.target.column)return U(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}})})}(f,c),function(t,e){let i=t;i.nodes.forEach(function(t){var r=i.links.filter(function(i){return tt(i.target,e)==tt(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(!mt(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var i=K(e,t);return t.y0-i}if(e.source.column>t.source.column)return K(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}})})}(f,c),function(t){var e=t.nodes,i=t.links,r=!1,o=!1;if(i.forEach(function(t){"top"==t.circularLinkType?r=!0:"bottom"==t.circularLinkType&&(o=!0)}),0==r||0==o){var a=n.min(e,function(t){return t.y0}),s=n.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})})}}(f),vt(f,c,d,10,8)}(y),y}return y.update=function(t){return Mt(t),vt(t,c,d,10,8),t},y.nodeWidth=function(t){return arguments.length?(o=+t,y):o},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?(f="function"==typeof t?t:At(t),y):f},y.links=function(t){return arguments.length?(g="function"==typeof t?t:At(t),y):g},y.nodeId=function(t){return arguments.length?(c="function"==typeof t?t:At(t),y):c},y.nodeAlign=function(t){return arguments.length?(l="function"==typeof t?t:At(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?(d=+t,y):d},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}q.QUADTREE_THRESHOLD=500;const Tt=t=>{let e,i,r,o,n,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,n=t.source.x1,s=t.target.x0,c=a.interpolateNumber(n,s),l=c(.5),u=c(.5),`M${e},${n}C${e},${l} ${i},${u} ${i},${s}L${r},${s}C${r},${u} ${o},${l} ${o},${n}Z`):(e=t.source.x1,i=t.target.x0,c=a.interpolateNumber(e,i),r=c(.5),o=c(.5),n=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},${n}C${r},${n} ${o},${s} ${i},${s}L${i},${l}C${o},${l} ${r},${u} ${e},${u}Z`)};function Lt(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,d="bottom"===t.circularLinkType?1:-1,f=Math.max(4,Math.min(r,15));return`M${n},${a-d*i}L${l},${a-d*i}L${l+r},${a-d*i+d*f}L${l+r},${h+d*r-d*f}L${l+r-f},${h+d*r}L${u-r+f},${h+d*r}L${u-r},${h+d*r-d*f}L${u-r},${c-d*i+d*f}L${u-r+f},${c-d*i}L${s},${c-d*i}L${s},${c+d*i}L${u+r},${c+d*i}L${u+r},${h-d*r}L${l-r},${h-d*r}L${l-r},${a+d*i}L${n},${a+d*i}Z`}const Dt=new Set,jt=new WeakMap;function zt(t,e){if("production"===process.env.NODE_ENV)return t;if(!t||!t.data||"object"!=typeof t.data)return t;let i=jt.get(t);if(i){const t=i.get(e);if(t)return t}else i=new Map,jt.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}`;Dt.has(t)||(Dt.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 $t={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(at))-1:0},justify:st},Rt={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",d=i.nodeAlign||"justify",f=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=Ot().extent(x).links(m).nodes(p).nodeAlign($t[d]||st).nodeId(t=>t.id).nodeWidth(f).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,r){var n,a,s,c;const l="vertical"===i.orientation?"down":"right",u=i.nodeStyle,h=i.edgeStyle,d=null!==(n=i.edgeOpacity)&&void 0!==n?n:.5,f=i.edgeColorBy||"source",g=Array.isArray(i.colorScheme)?i.colorScheme:o.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(zt(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 f?f(t)||r:"target"===f?v.get(i.id)||y.get(i.id)||r:v.get(e.id)||y.get(e.id)||r;const o=h?h(zt(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:d,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:d,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?Lt(t):Tt(t),!n)continue;const l={fill:o.fill||r,fillOpacity:null!==(c=o.fillOpacity)&&void 0!==c?c:d,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,o=i.y1-i.y0;if(0>=t||0>=o)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"):(r[0]/2>i.x0+t/2?(a=i.x0-6,c="end"):(a=i.x1+6,c="start"),s=i.y0+o/2),x.push({x:a,y:s,text:n+"",anchor:c,baseline:"middle",fontSize:11})}}var k;return{sceneNodes:p,sceneEdges:m,labels:x}}},Nt={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,i,r){var o,n;if(0===t.length)return;const a=null!==(o=i.forceStrength)&&void 0!==o?o:.1,c=r[0]/2,l=r[1]/2,u=i.__previousPositions;let h=0;const d=[];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++):d.push(e)}const f=h>0&&.3>=(t.length>0?d.length/t.length:1);if(f){const i=new Map;for(const e of t)i.set(e.id,e);for(const t of d){const r=Ct(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=Bt(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=Bt(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:f?40:g,p=Wt(i.nodeSize,i.nodeSizeRange,t),m=t=>p(t);if(y>0){const i=s.forceLink().strength(t=>Math.min(2.5,t.weight?t.weight*a:a)).id(t=>t.id),r=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(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)}f?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,r){var n,a,s;const c=i.nodeStyle,l=i.edgeStyle,u=Wt(i.nodeSize,i.nodeSizeRange,t),h=Array.isArray(i.colorScheme)?i.colorScheme:o.schemeCategory10,d=new Map;t.forEach((t,e)=>{d.set(t.id,h[e%h.length])});const f=[],g=[],y=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=u(zt(e,"nodeSize")),i=c?c(zt(e,"nodeStyle")):{},r={fill:i.fill||d.get(e.id)||"#007bff",stroke:i.stroke||"#fff",strokeWidth:null!==(n=i.strokeWidth)&&void 0!==n?n:2,opacity:i.opacity};f.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(zt(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(zt(i,"nodeSize"));y.push({x:i.x,y:i.y-r-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var m;return{sceneNodes:f,sceneEdges:g,labels:y}}};function Ct(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 Bt(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 Wt(t,e,r){var o,a;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const s=e||[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!==(o=n.min(c))&&void 0!==o?o:0,u=null!==(a=n.max(c))&&void 0!==a?a:1;if(l===u)return()=>(s[0]+s[1])/2;const h=i.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 Ft=o.schemeCategory10,It={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,i,r){if(0===t.length)return;const{padAngle:o=.01,groupWidth:n=20,sortGroups:a}=i,s=Math.min(r[0],r[1])/2,u=s-n,h=r[0]/2,d=r[1]/2,f=(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=f(t);m[i][r]=o}const x=c.chord().padAngle(o);a&&x.sortGroups(a);const v=x(m),b=v.groups,k=l.arc().innerRadius(u).outerRadius(s);for(const e of b){const i=t[e.index],r=k.centroid(e);i.x=r[0]+h,i.y=r[1]+d,i.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,i=A.get("string"==typeof t.source?t.source:t.source.id),r=A.get(e);i&&(t.source=i),r&&(t.target=r)}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 i=t[e.source.index].id,r=t[e.target.index].id,o=w.get(`${i}\0${r}`)||w.get(`${r}\0${i}`);o&&(o.chordData=e)}},buildScene(t,e,i,r){var o,n;const{groupWidth:a=20,edgeOpacity:s=.5}=i,l=Math.min(r[0],r[1])/2,u=l-a,h=r[0]/2,d=r[1]/2,f=i.nodeStyle,g=i.edgeStyle,y=i.edgeColorBy||"source",p=Array.isArray(i.colorScheme)?i.colorScheme:Ft,m=new Map;t.forEach((t,e)=>{m.set(t.id,p[e%p.length])});const x=c.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=f?f(zt(i,"nodeStyle")).fill||m.get(i.id)||p[e%p.length]:m.get(i.id)||p[e%p.length];const a=f?f(zt(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:d,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=Yt(i,h,d);let o="#999";if(g)o=g(zt(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(zt(t,"edgeStyle")):{},c={fill:o,fillOpacity:null!==(n=a.fillOpacity)&&void 0!==n?n:s,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity};b.push({type:"ribbon",pathD:r,style:c,datum:t})}if(!1!==i.showLabels){const e=(A=i.nodeLabel)?"function"==typeof A?A:t=>t[A]||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:d+Math.sin(a)*r,text:o+"",anchor:n>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var A;return{sceneNodes:v,sceneEdges:b,labels:k}}};function Yt(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 qt=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Xt(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 Gt(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 Vt(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 Ht(t){return Array.isArray(t.colorScheme)?t.colorScheme:qt}function Qt(t){return Array.isArray(t.colorScheme)&&t.colorScheme.length>0?t.colorScheme[0]:"#4d430c"}function Zt(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 Ut={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,l="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=u.hierarchy(n,s);h.sum(l),h.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[d,f]=r;switch(a){case"tree":!function(t,e,i,r){const o=e.treeOrientation||"vertical",n=u.tree();n.size("horizontal"===o?[r,i]:"radial"===o?[2*Math.PI,Math.min(i,r)/2*.8]:[i,r]),n(t)}(h,i,d,f);break;case"cluster":!function(t,e,i,r){const o=e.treeOrientation||"vertical",n=u.cluster();n.size("horizontal"===o?[r,i]:"radial"===o?[2*Math.PI,Math.min(i,r)/2*.8]:[i,r]),n(t)}(h,i,d,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=u.treemap().size([i,r]).tile(u.treemapBinary).padding(a);s>0&&c.paddingTop(s),c(t)}(h,i,d,f);break;case"circlepack":!function(t,e,i,r){var o;const n=null!==(o=e.padding)&&void 0!==o?o:4;u.pack().size([i,r]).padding(n)(t)}(h,i,d,f);break;case"partition":!function(t,e,i,r){var o;u.partition().size([i,r]).padding(null!==(o=e.padding)&&void 0!==o?o:1)(t)}(h,i,d,f)}const g=h.descendants();t.length=0,e.length=0;const y=new Map;for(let e=0;g.length>e;e++){const r=g[e],n={id:Gt(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?Kt(n,r,i):"treemap"===a||"partition"===a?Jt(n,r):"circlepack"===a&&te(n,r),n.__hierarchyNode=r,t.push(n),y.set(r,n)}if("tree"===a||"cluster"===a)for(const t of g)if(t.parent){const i=y.get(t.parent),r=y.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=[],d=[],f=[],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(zt(e,"nodeStyle"));let s=n.fill||Qt(i);if(i.colorByDepth&&void 0!==e.depth){const t=Ht(i);s=t[e.depth%t.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=Zt(r,o,a,s,g),h=n(zt(t,"edgeStyle")),f={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};d.push({type:"curved",pathD:u,style:f,datum:t})}if(!1!==i.showLabels){const e=Vt(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");f.push({x:r,y:o,text:t+"",anchor:n,baseline:"middle",fontSize:11})}}return{sceneNodes:h,sceneEdges:d,labels:f}}(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(zt(i,"nodeStyle"));let c=s.fill||Qt(e);if(e.colorByDepth&&void 0!==i.depth){const t=Ht(e);c=t[i.depth%t.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=Vt(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 d=r(zt(c,"nodeStyle")).fill||Qt(e);if(e.colorByDepth&&void 0!==c.depth){const t=Ht(e);d=t[c.depth%t.length]}const f=Xt(d);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:f}:{x:c.x0+4,y:c.y0+12,text:h+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:f})}}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(zt(i,"nodeStyle"));let c=s.fill||Qt(e);if(e.colorByDepth&&void 0!==i.depth){const t=Ht(e);c=t[i.depth%t.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=Vt(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(zt(o,"nodeStyle")).fill||Qt(e);if(e.colorByDepth&&void 0!==o.depth){const t=Ht(e);l=t[o.depth%t.length]}if(a){const e=Xt(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 Kt(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 Jt(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 te(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 ee(t){const e=t;return e.__orbitState||(e.__orbitState={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()}),e.__orbitState}const ie={sankey:Rt,force:Nt,chord:It,tree:Ut,cluster:Ut,treemap:Ut,circlepack:Ut,partition:Ut,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),c=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,d=null!==(a=i.orbitEccentricity)&&void 0!==a?a:1,f="number"==typeof h?()=>h:h,g="number"==typeof d?()=>d:d,y=ee(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(c(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,d,p){const x=s(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:i,depth:d,data:e,parentId:i},P=p?h/f(_)*S:h*S,E=l.pie().value(t=>{var e;return(null===(e=s(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 s=(M[e].startAngle+M[e].endAngle)/2,l=A[e],u=m(c(l)),h=n+P*Math.sin(s),f=a+P*Math.cos(s)*O;r.push({id:u,x:h,y:f,x0:h,x1:h,y0:f,y1:f,width:0,height:0,value:0,depth:d,data:l}),y.metaMap.set(u,{ring:P,angle:s,depth:d,parentId:i,eccentricity:O}),o.push({source:i,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:i,target:u}}),t(l,u,h,f,P,d+1,!0)}w+=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,d=[],f=[],g=[];if(!1!==i.orbitShowRings){const e=ee(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;f.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(zt(e,"nodeSize")),i=l?l(zt(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};d.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&&f.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(zt(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:d,sceneEdges:f,labels:g}},tick:(t,e,i,r,o)=>!1!==i.orbitAnimated&&(function(t,e){var i,r;const o=ee(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 re(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,u=o(t.pieceData[0],t.name);n.push(Object.assign(Object.assign({type:"wedge",cx:0,cy:0,innerRadius:s,outerRadius:a,startAngle:e,endAngle:i},r.cornerRadius&&{cornerRadius:r.cornerRadius}),{style:u,datum:t.pieceData,category:t.name}))}return n}function oe(t){var e,i,r;const o=t.length,a=t[0],s=t[o-1];return{n:o,min:a,q1:null!==(e=n.quantile(t,.25))&&void 0!==e?e:a,median:null!==(i=n.quantile(t,.5))&&void 0!==i?i:(a+s)/2,q3:null!==(r=n.quantile(t,.75))&&void 0!==r?r:s,max:s,mean:t.reduce((t,e)=>t+e,0)/o}}const ne={bar:function(t,e){var i;const{scales:r,columns:o,config:n,getR:a,getStack:s,resolvePieceStyle:c}=t,{r:l,projection:u}=r,h=[],d="vertical"===u,f="horizontal"===u,g=n.normalize,y=[];if(s){const t=new Set;for(const e of Object.values(o))for(const i of e.pieceData){const e=s(i);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 i of t.pieceData){const t=s?s(i):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const r=e.get(t);r.total+=a(i),r.pieces.push(i)}let i=0;if(g)for(const t of e.values())i+=Math.abs(t.total);let r=0,o=0;for(const n of y){const a=e.get(n);if(!a)continue;let u=a.total;g&&i>0&&(u/=i);const y=c(a.pieces[0],s?n:t.name),p=Object.assign(Object.assign({},a.pieces[0]),{__aggregateValue:a.total,__pieceCount:a.pieces.length,category:t.name});if(d){const e=l(0>u?o:r+u),i=0>u?l(o+u)-l(o):l(r)-l(r+u);h.push(C(t.x,e,t.width,Math.abs(i),y,p,n)),0>u?o+=u:r+=u}else if(f){const e=l(0>u?o+u:r),i=0>u?l(o)-l(o+u):l(r+u)-l(r);h.push(C(e,t.x,Math.abs(i),t.width,y,p,n)),0>u?o+=u:r+=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 r=(null===(i=t.datum)||void 0===i?void 0:i.category)||"";e.has(r)||e.set(r,[]),e.get(r).push(t)}const r="vertical"===u;for(const i of e.values()){if(0===i.length)continue;const e=i.filter(t=>{var e,i;return(null!==(i=null===(e=t.datum)||void 0===e?void 0:e.__aggregateValue)&&void 0!==i?i:0)>=0}),o=i.filter(t=>{var e,i;return 0>(null!==(i=null===(e=t.datum)||void 0===e?void 0:e.__aggregateValue)&&void 0!==i?i:0)});if(e.length>0){const i=e.reduce(r?(t,e)=>e.y>t.y?t:e:(t,e)=>t.x+t.w>e.x+e.w?t:e);i.roundedTop=t,i.roundedEdge=r?"top":"right"}if(o.length>0){const e=o.reduce(r?(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=r?"bottom":"left"}}}return h},clusterbar:function(t,e){const{scales:i,columns:r,config:o,getR:n,getGroup:a,resolvePieceStyle:s}=t,{r:c,projection:l}=i,u=[],h="vertical"===l,d=[],f=new Set;for(const t of Object.values(r))for(const e of t.pieceData){const t=a?a(e):"_default";f.has(t)||(f.add(t),d.push(t))}const g=d.length||1;for(const t of Object.values(r)){const e=t.width/g,i=.2*e,r=e-i,o=new Map;for(const e of t.pieceData){const t=a?a(e):"_default";o.has(t)||o.set(t,[]),o.get(t).push(e)}for(let a=0;d.length>a;a++){const l=o.get(d[a])||[];for(const o of l){const l=n(o),f=s(o,d[a]);if(h){const n=t.x+a*e+i/2,s=c(0),h=c(l);u.push(C(n,Math.min(s,h),r,Math.abs(s-h),f,o,d[a]))}else{const n=t.x+a*e+i/2,s=c(0),h=c(l);u.push(C(Math.min(s,h),n,Math.abs(h-s),r,f,o,d[a]))}}}}if(o.roundedTop&&o.roundedTop>0){const t=Math.max(0,o.roundedTop);for(const e of u){if("rect"!==e.type)continue;const i=n(e.datum);e.roundedTop=t,e.roundedEdge=h?0>i?"bottom":"top":0>i?"left":"right"}}return u},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=[],d="vertical"===u,f="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(f){const e=p+(t.pctStart+t.pct/2)*y,i=u(n);v=Math.cos(e)*i,b=Math.sin(e)*i}else d?(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,d=(7919*i%100/100-.5)*e*.8,f=l?t.middle+d:a(s),g=l?a(s):t.middle+d;c.push({type:"point",x:f,y:g,r:h,style:u,datum:r})}}return c},pie:re,donut:re,boxplot:function(t,e){var i,r,o,a,s;const{scales:c,columns:l,config:u,getR:h,resolveSummaryStyle:d}=t,{r:f,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=n.quantile(e,.25))&&void 0!==i?i:c,g=null!==(r=n.quantile(e,.5))&&void 0!==r?r:(c+l)/2,x=null!==(o=n.quantile(e,.75))&&void 0!==o?o:l,v=x-u,b=u-1.5*v,k=x+1.5*v,A=null!==(a=e.find(t=>t>=b))&&void 0!==a?a:c,w=null!==(s=[...e].reverse().find(t=>k>=t))&&void 0!==s?s:l,S=d(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:f(i),o=p?f(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:f(A),q1Pos:f(u),medianPos:f(g),q3Pos:f(x),maxPos:f(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 i,r,o;const{scales:a,columns:s,config:c,getR:l,resolveSummaryStyle:u}=t,{r:h,projection:d}=a,f=[],g="vertical"===d,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,d=Array(y).fill(0);for(const t of e)d[Math.min(Math.floor((t-a)/c),y-1)]++;const m=Math.max(...d,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+d[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-d[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-d[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+d[e]/m*x}`;v+=" Z"}const b=u(t.pieceData[0],t.name);let k;if(p&&e.length>=4){const c=null!==(i=n.quantile(e,.25))&&void 0!==i?i:a,l=null!==(r=n.quantile(e,.5))&&void 0!==r?r:(a+s)/2,u=null!==(o=n.quantile(e,.75))&&void 0!==o?o:s;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(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};f.push({type:"violin",pathString:v,translateX:0,translateY:0,bounds:A,iqrLine:k,stats:oe(e),style:b,datum:t.pieceData,category:t.name})}return f},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,d=null===(i=c.domain)||void 0===i?void 0:i.call(c),f=d?+d[0]:void 0,g=d?+d[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!=f&&isFinite(f)?f: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 d=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]/d:n[e]/y)*t.width*.9,a=c(i+e*o),s=c(i+(e+1)*o);l.push(C(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,d="horizontal"===l,f=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*f;let m="";if(d){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=d?{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:oe(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(C(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(C(t.x,i,t.width,o-i,u,e,t.name))}}return c},funnel:function(t,e){var r,o,n,a,s,c,l;const{columns:u,getR:h,getStack:d,resolvePieceStyle:f}=t,g=[],y=e.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=d?d(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 i=0;for(const r of t.pieceData){const t=d?d(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>A&&(A=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>A&&(A=r)}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!==(r=null==e?void 0:e.total)&&void 0!==r?r:0)}const S=k[0].stepTotal,_=b?.95*y:.9*e.width,P=i.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],i=e.col,r=0===t,o=i.width,u=.55*o,h=i.x+(o-u)/2,d=new Map;if(b){let t=0;for(const i of x){const r=e.groups.get(i);r&&(t+=P(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=P(l.total),v=a%2==0,b=v?o:n-m;v?o+=m:n-=m;const k=f(l.pieces[0],c),A=null!==(s=w.get(c))&&void 0!==s?s:l.total,S=A>0?l.total/A*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(C(b,h,m,u,k,_,c)),d.set(c,{x:b,y:h,w:m,h:u})}}else{const t=e.stepTotal,o=P(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=f(m,v),k=S>0?t/S*100:0,A=Object.assign(Object.assign({},m),{__funnelValue:t,__funnelPercent:k,__funnelStep:i.name,__funnelIsFirstStep:r,category:l?c:i.name});p&&(A.__funnelStepLabel=i.name,A.__funnelStepLabelX=y,A.__funnelStepLabelY=h,A.__funnelRowWidth=o,A.__funnelValueLabelX=y,A.__funnelValueLabelY=h,A.__funnelBarW=o),g.push(C(s,h,o,u,b,A,v)),d.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=d.get(r);if(!t||!o)continue;const n=(()=>{const t=e.groups.get(r);return f(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:E},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=d}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=[],d=u.o.domain().map(t=>a[t]).filter(Boolean);if(0===d.length)return h;const f=[],g=new Set;for(const t of d)for(const e of t.pieceData){const t=c?c(e):"_default";g.has(t)||(g.add(t),f.push(t))}const y=f.length>1&&"_default"!==f[0],p=[];for(const t of d){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 f){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?f.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;f.length>t;t++){const d=f[t],g=e.groups.get(d);if(!g)continue;const p=g.total,v=null!==(o=m.get(d))&&void 0!==o?o:p,b=v>0?p/v*100:0,k=null==a?void 0:a.groups.get(d),A=null!==(n=null==k?void 0:k.total)&&void 0!==n?n:p,w=r?0:Math.max(0,A-p),S=i.x+t*s+c/2,_=x(p),P=x(0)-_,E=l(g.pieces[0],y?d:i.name),M=Object.assign(Object.assign({},g.pieces[0]),{__barFunnelValue:p,__barFunnelPercent:b,__barFunnelIsFirstStep:r,__barFunnelIsDropoff:!1,__barFunnelStep:i.name,__barFunnelDropoffValue:w,__barFunnelCategory:"_default"===d?void 0:d,category:y?d:i.name,__barFunnelLabelX:S+u/2,__barFunnelLabelY:x(p+w)});if(h.push(C(S,_,u,P,E,M,y?d:i.name)),w>0){const t=x(p+w),e=_-t,r=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:i.name,__barFunnelCategory:"_default"===d?void 0:d,category:y?d:i.name});h.push(C(S,t,u,e,r,o,y?d: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(C(o,t.x,n-o,t.width,h,i,c))}else{const o=s(e+r),n=s(e);l.push(C(t.x,o,t.width,n-o,h,i,c))}e+=r}}return l}};class ae{constructor(t){this.rExtent=new m,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._dataVersion=0,this._pointQuadtree=null,this._maxPointRadius=0,this._datumIndexCache=null,this._categoryIndexCache=null,this._hasRenderedOnce=!1,this.config=t,this.buffer=new p(t.windowSize),this.getO=A(t.categoryAccessor||t.oAccessor,"category");const e=t.valueAccessor||t.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(t=>b(t,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new m)):(this.getR=b(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=A(t.stackBy),this.getGroup=A(t.groupBy),this.getColor=A(t.colorAccessor),this.getConnector=A(t.connectorAccessor),this.getDataId=A(t.dataIdAccessor),t.pulse&&(this.timestampBuffer=new p(t.windowSize))}ingest(t){const e="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=e,this._dataVersion++,t.bounded){this.buffer.clear(),this.rExtent.clear();for(const t of this.rExtents)t.clear();t.preserveCategoryOrder?this._hasStreamingData=!0: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.valueAccessor||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:e,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=e.projection||"vertical",a=e.oExtent||this.resolveCategories(o),s=this.computeValueDomain(o,a),c="horizontal"===n,l="radial"===n,u=Math.min(.9,Math.max(0,null!=e.barPadding?e.barPadding/("vertical"===n?t.width:t.height):.1));let h,d;if(l){h=i.scaleBand().domain(a).range([0,1]).padding(0);const r=Math.min(t.width,t.height)/2,o=e.innerRadius||0;d=i.scaleLinear().domain(s).range([o,r])}else c?(h=i.scaleBand().domain(a).range([0,t.height]).padding(u),d=i.scaleLinear().domain(s).range([0,t.width])):(h=i.scaleBand().domain(a).range([0,t.width]).padding(u),d=i.scaleLinear().domain(s).range([t.height,0]));this.scales={o:h,r:d,projection:n},this.multiScales=this.rAccessors.length>1&&e.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=e.extentPadding)&&void 0!==a?a:.05,d=u-l,f=d>0?d*h:1;return l-=f,u+=f,l>0&&(l=0),c?i.scaleLinear().domain([l,u]).range([0,t.width]):i.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,h,n,t),this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(f,t),this.rebuildPointQuadtree(),this.config.decay&&this.applyDecay(this.scene,o),this.config.pulse&&this.applyPulse(this.scene,o),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++}resolveRAccessorName(t){const e=this.config.valueAccessor||this.config.rAccessor,i=Array.isArray(e)?e[t]:e;return"string"==typeof i?i:"value"+t}resolveCategories(t){const e=this.config.oSort,i="streaming"===this.config.runtimeMode||this._hasStreamingData,r="auto"===e?void 0:e;let o=null;if(i){o=new Set;for(const e of t)o.add(this.getO(e))}const n=o?Array.from(this.categories).filter(t=>o.has(t)):Array.from(this.categories);if(i&&void 0===r){const t=Math.max(50,3*o.size);if(this.categories.size>t){let e=this.categories.size-t;for(const t of this.categories){if(0>=e)break;o.has(t)||(this.categories.delete(t),e--)}}return n}if(!1===r)return n;if("function"==typeof r)return n.sort(r);const a=new Map;for(const e of t){const t=this.getO(e);a.set(t,(a.get(t)||0)+Math.abs(this.getR(e)))}return n.sort("asc"===r?(t,e)=>(a.get(t)||0)-(a.get(e)||0):(t,e)=>(a.get(e)||0)-(a.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,d=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,f;u?(l=d,f=u.get(t)||i.bandwidth(),d+=f+i.padding()*i.step()):(l=null!==(n=i(t))&&void 0!==n?n:0,f=i.bandwidth()),a[t]={name:t,x:l,y:0,width:f,middle:l+f/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=ne[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:this.config.themeCategorical||_,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){const i=this.config.decay;return i&&e>1?M(i,t,e):1}getDatumIndexMap(t){if(this._datumIndexCache&&this._datumIndexCache.version===this._dataVersion)return this._datumIndexCache.map;const e=new Map;for(let i=0;t.length>i;i++)e.set(t[i],i);return this._datumIndexCache={version:this._dataVersion,map:e},e}getCategoryIndexMap(t){if(this._categoryIndexCache&&this._categoryIndexCache.version===this._dataVersion)return this._categoryIndexCache.map;const e=this.config.categoryAccessor||this.config.oAccessor,i="function"==typeof e,r=i?null:e||"category",o=new Map;for(let n=0;t.length>n;n++){const a=t[n],s=i?e(a):a[r];let c=o.get(s);c||(c=[],o.set(s,c)),c.push(n)}return this._categoryIndexCache={version:this._dataVersion,map:o},o}rebuildPointQuadtree(){let t=0,e=0;for(const i of this.scene)"point"===i.type&&(t++,i.r>e&&(e=i.r));if(this._maxPointRadius=e,ae.QUADTREE_THRESHOLD>=t)return void(this._pointQuadtree=null);const i=Array(t);let o=0;for(const t of this.scene)"point"===t.type&&(i[o++]=t);this._pointQuadtree=r.quadtree().x(t=>t.x).y(t=>t.y).addAll(i)}get pointQuadtree(){return this._pointQuadtree}get maxPointRadius(){return this._maxPointRadius}applyDecay(t,e){var i,r;if(!this.config.decay)return;const o=e.length;if(1>=o)return;const n=this.getDatumIndexMap(e);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=this.getDatumIndexMap(e);let u=null;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;u||(u=this.getCategoryIndexMap(e));const r=u.get(t);if(!r)continue;let o=0;for(let t=0;r.length>t;t++){const e=this.timestampBuffer.get(r[t]);if(null==e)continue;const i=n-e;if(a>i){const t=1-i/a;t>o&&(o=t)}}o>0&&(i._pulseIntensity=o,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}synthesizeIntroPositions(){var t,e,i,r,o;this.prevPositionMap.clear();const n=new Map,a=null!==(e=null===(t=this.scales)||void 0===t?void 0:t.r(0))&&void 0!==e?e:0,s="horizontal"!==(null===(i=this.scales)||void 0===i?void 0:i.projection);let c;for(let t=0;this.scene.length>t;t++){const e=this.scene[t],i=this.getNodeKey(e,n);i&&("rect"===e.type?this.prevPositionMap.set(i,s?{x:e.x,y:a,w:e.w,h:0,opacity:null!==(r=e.style.opacity)&&void 0!==r?r:1}:{x:a,y:e.y,w:0,h:e.h,opacity:null!==(o=e.style.opacity)&&void 0!==o?o:1}):"point"===e.type?this.prevPositionMap.set(i,{x:e.x,y:e.y,r:0,opacity:0}):"wedge"===e.type&&(void 0===c&&(c=e.startAngle),this.prevPositionMap.set(i,{x:e.cx,y:e.cy,startAngle:c,endAngle:c,innerRadius:e.innerRadius,outerRadius:e.outerRadius,opacity:0})))}}getNodeKey(t,e){var i,r,o;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:""}`:"wedge"===t.type?"w:"+(null!==(o=t.category)&&void 0!==o?o:""):null}snapshotPositions(){var t;this.prevPositionMap.clear();const e=new Map;for(let i=0;this.scene.length>i;i++){const r=this.scene[i],o=this.getNodeKey(r,e);o&&("point"===r.type?this.prevPositionMap.set(o,{x:r.x,y:r.y,r:r.r,opacity:r.style.opacity}):"rect"===r.type?this.prevPositionMap.set(o,{x:r.x,y:r.y,w:r.w,h:r.h,opacity:r.style.opacity}):"wedge"===r.type&&this.prevPositionMap.set(o,{x:r.cx,y:r.cy,startAngle:r.startAngle,endAngle:r.endAngle,innerRadius:r.innerRadius,outerRadius:r.outerRadius,opacity:null!==(t=r.style.opacity)&&void 0!==t?t:1}))}}startTransition(){var t,e,i,r,o,n,a,s,c,l,u,h,d,f,g,y,p,m,x,v,b;if(!this.config.transition||0===this.prevPositionMap.size)return;const k=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 A=!1;const w=new Set,S=new Map;for(let t=0;this.scene.length>t;t++){const l=this.scene[t],u=this.getNodeKey(l,S);if(!u)continue;l._transitionKey=u;const h=this.prevPositionMap.get(u);if("point"===l.type)h?(w.add(u),l._targetOpacity=null!==(e=l.style.opacity)&&void 0!==e?e:1,(h.x!==l.x||h.y!==l.y||void 0!==h.r&&h.r!==l.r)&&(l._targetX=l.x,l._targetY=l.y,l._targetR=l.r,l.x=h.x,l.y=h.y,void 0!==h.r&&(l.r=h.r),A=!0)):(l._targetOpacity=null!==(i=l.style.opacity)&&void 0!==i?i:1,l._targetR=l.r,l.r=0,l.style=Object.assign(Object.assign({},l.style),{opacity:0}),A=!0);else if("rect"===l.type)h?(w.add(u),l._targetOpacity=null!==(r=l.style.opacity)&&void 0!==r?r:1,h.x===l.x&&h.y===l.y&&h.w===l.w&&h.h===l.h||(l._targetX=l.x,l._targetY=l.y,l._targetW=l.w,l._targetH=l.h,l.x=h.x,l.y=h.y,l.w=null!==(o=h.w)&&void 0!==o?o:l.w,l.h=null!==(n=h.h)&&void 0!==n?n:l.h,A=!0)):(l._targetOpacity=null!==(a=l.style.opacity)&&void 0!==a?a:1,l.style=Object.assign(Object.assign({},l.style),{opacity:0}),A=!0);else if("wedge"===l.type)if(h)w.add(u),l._targetOpacity=null!==(s=l.style.opacity)&&void 0!==s?s:1,h.startAngle===l.startAngle&&h.endAngle===l.endAngle||(l._targetStartAngle=l.startAngle,l._targetEndAngle=l.endAngle,l.startAngle=h.startAngle,l.endAngle=h.endAngle,A=!0);else{l._targetOpacity=null!==(c=l.style.opacity)&&void 0!==c?c:1,l._targetStartAngle=l.startAngle,l._targetEndAngle=l.endAngle;const t=l.startAngle;l.startAngle=t,l.endAngle=t,l.style=Object.assign(Object.assign({},l.style),{opacity:0}),this.prevPositionMap.set(u,{x:l.cx,y:l.cy,startAngle:t,endAngle:t,innerRadius:l.innerRadius,outerRadius:l.outerRadius,opacity:0}),A=!0}}this.exitNodes=[];for(const[t,e]of this.prevPositionMap)if(!w.has(t)){if(t.startsWith("p:"))this.exitNodes.push({type:"point",x:e.x,y:e.y,r:null!==(l=e.r)&&void 0!==l?l:3,style:{opacity:null!==(u=e.opacity)&&void 0!==u?u:1},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("r:"))this.exitNodes.push({type:"rect",x:e.x,y:e.y,w:null!==(h=e.w)&&void 0!==h?h:0,h:null!==(d=e.h)&&void 0!==d?d:0,style:{opacity:null!==(f=e.opacity)&&void 0!==f?f:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("w:")){const i=((null!==(g=e.startAngle)&&void 0!==g?g:0)+(null!==(y=e.endAngle)&&void 0!==y?y:0))/2;this.exitNodes.push({type:"wedge",cx:e.x,cy:e.y,innerRadius:null!==(p=e.innerRadius)&&void 0!==p?p:0,outerRadius:null!==(m=e.outerRadius)&&void 0!==m?m:100,startAngle:null!==(x=e.startAngle)&&void 0!==x?x:0,endAngle:null!==(v=e.endAngle)&&void 0!==v?v:0,style:{opacity:null!==(b=e.opacity)&&void 0!==b?b:1},datum:null,category:t.slice(2),_targetStartAngle:i,_targetEndAngle:i,_targetOpacity:0,_transitionKey:t})}A=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),A&&(this.activeTransition={startTime:j(),duration:k})}advanceTransition(t){var e,i,r,o;if(!this.activeTransition)return!1;const n=L(t,this.activeTransition),a=T(n,"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=D(o,t._targetOpacity,a)}const r=this.prevPositionMap.get(e);void 0!==t._targetX&&r&&(t.x=D(r.x,t._targetX,a),t.y=D(r.y,t._targetY,a)),void 0!==t._targetR&&void 0!==(null==r?void 0:r.r)&&(t.r=D(r.r,t._targetR,a))}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=D(o,t._targetOpacity,a)}if(void 0===t._targetX)continue;const i=this.prevPositionMap.get(e);if(!i)continue;t.x=D(i.x,t._targetX,a),t.y=D(i.y,t._targetY,a),void 0!==i.w&&(t.w=D(i.w,t._targetW,a),t.h=D(i.h,t._targetH,a))}else if("wedge"===t.type){if(void 0!==t._targetOpacity){const i=this.prevPositionMap.get(e),r=i?null!==(o=i.opacity)&&void 0!==o?o:1:0;t.style=Object.assign(Object.assign({},t.style),{opacity:D(r,t._targetOpacity,a)})}if(void 0!==t._targetStartAngle&&void 0!==t._targetEndAngle){const i=this.prevPositionMap.get(e);i&&void 0!==i.startAngle&&(t.startAngle=D(i.startAngle,t._targetStartAngle,a),t.endAngle=D(i.endAngle,t._targetEndAngle,a))}}}if(n>=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&&void 0===t._targetR)continue;void 0!==t._targetX&&(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"wedge"===t.type&&void 0!==t._targetStartAngle&&(t.startAngle=t._targetStartAngle,t.endAngle=t._targetEndAngle,t._targetStartAngle=void 0,t._targetEndAngle=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]),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._dataVersion++,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._dataVersion++,this.version++,n}clear(){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this._hasStreamingData=!1,this._hasRenderedOnce=!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._pointQuadtree=null,this._maxPointRadius=0,this._dataVersion++,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(("colorScheme"in t&&t.colorScheme!==e.colorScheme||"themeCategorical"in t&&t.themeCategorical!==e.themeCategorical||"colorAccessor"in t&&!v(t.colorAccessor,e.colorAccessor))&&(this._colorSchemeMap=null,this._colorSchemeIndex=0),("categoryAccessor"in t&&!v(t.categoryAccessor,e.categoryAccessor)||"oAccessor"in t&&!v(t.oAccessor,e.oAccessor))&&(this._categoryIndexCache=null),Object.assign(this.config,t),("categoryAccessor"in t||"oAccessor"in t)&&(v(t.categoryAccessor||t.oAccessor,e.categoryAccessor||e.oAccessor)||(this.getO=A(this.config.categoryAccessor||this.config.oAccessor,"category"),this.categories.clear())),"valueAccessor"in t||"rAccessor"in t){const i=t.valueAccessor||t.rAccessor,r=e.valueAccessor||e.rAccessor,o=Array.isArray(i)?i:[i],n=Array.isArray(r)?r:[r];if(o.length!==n.length||o.some((t,e)=>!v(t,n[e]))){const t=this.config.valueAccessor||this.config.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(t=>b(t,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new m)):(this.getR=b(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in t&&!v(t.stackBy,e.stackBy)&&(this.getStack=null!=this.config.stackBy?A(this.config.stackBy):void 0),"groupBy"in t&&!v(t.groupBy,e.groupBy)&&(this.getGroup=null!=this.config.groupBy?A(this.config.groupBy):void 0),"colorAccessor"in t&&!v(t.colorAccessor,e.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?A(this.config.colorAccessor):void 0),"connectorAccessor"in t&&!v(t.connectorAccessor,e.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?A(this.config.connectorAccessor):void 0)}}ae.QUADTREE_THRESHOLD=500;const se={mercator:h.geoMercator,equalEarth:h.geoEqualEarth,albersUsa:h.geoAlbersUsa,orthographic:h.geoOrthographic,naturalEarth:h.geoNaturalEarth1,equirectangular:h.geoEquirectangular};function ce(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}function le(t){return t?"function"==typeof t?t:e=>e[t]:t=>t.coordinates||t.data||[]}function ue(t,e,i){return t?Object.assign(Object.assign({},i),"function"==typeof t?t(e):t):i}const he={fill:"#e0e0e0",stroke:"#999",strokeWidth:.5,fillOpacity:1},de={fill:"#4e79a7",r:4,fillOpacity:.8},fe={stroke:"#4e79a7",strokeWidth:1.5,fill:"none"};function ge(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 ye(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 pe(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 me(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 xe{constructor(t){this.scene=[],this.scales=null,this.version=0,this._quadtree=null,this._maxPointRadius=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._hasRenderedOnce=!1,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 p(t),this.timestampBuffer=new p(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._hasRenderedOnce=!1,this.activeTransition=null,this.prevPositions=null,this._quadtree=null,this._maxPointRadius=0,this.version++}computeScene(t){const{config:e}=this;this.projection=function(t){if(!t)return h.geoEqualEarth();if("string"==typeof t){const e=se[t];return e?e():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${t}", falling back to equalEarth`),h.geoEqualEarth())}if("object"==typeof t&&"type"in t){const e=se[t.type],i=e?e():h.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=h.geoPath(this.projection),this.fitProjection(t),this.geoPath=h.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;if(this.scene=this.buildSceneNodes(t),this.rebuildQuadtree(),e.projectionTransform&&this.applyCartogramTransform(e.projectionTransform,t),e.decay&&this.streaming&&this.applyDecay(),e.pulse&&this.streaming&&this.applyPulse(),e.transition&&!this._hasRenderedOnce&&this.scene.length>0&&e.introAnimation){const e=t.width/2,i=t.height/2,r=this.scene.filter(t=>"point"===t.type).map(t=>Object.assign(Object.assign({},t),{x:e,y:i}));r.length>0&&this.startTransition(r)}this._hasRenderedOnce=!0,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=ce(s.xAccessor,"lon"),u=ce(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 d=le(s.lineDataAccessor);for(const t of this.lineData){const e=d(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=h.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.rebuildQuadtree(),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=h.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.rebuildQuadtree(),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=h.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.rebuildQuadtree(),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}rebuildQuadtree(){let t=0,e=0;for(const i of this.scene)"point"===i.type&&(e++,i.r>t&&(t=i.r));if(this._maxPointRadius=t,xe.QUADTREE_THRESHOLD>=e)return void(this._quadtree=null);const i=Array(e);let o=0;for(const t of this.scene)"point"===t.type&&(i[o++]=t);this._quadtree=r.quadtree().x(t=>t.x).y(t=>t.y).addAll(i)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}buildSceneNodes(t){var e,i,r;const o=[],{config:n}=this,a=this.projection,s=this.geoPath,c=ce(n.xAccessor,"lon"),l=ce(n.yAccessor,"lat");if(n.graticule){const e=!0===n.graticule?{}:n.graticule,i=h.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=ue(n.areaStyle,t,he);o.push({type:"geoarea",pathData:e,centroid:i,bounds:r,screenArea:a,style:c,datum:t,interactive:!0})}const u=le(n.lineDataAccessor);for(const e of this.lineData){const i=u(e);if(!i||2>i.length)continue;let r=[];if("geo"===n.lineType){const t=Array(i.length);for(let e=0;i.length>e;e++)t[e]=[c(i[e]),l(i[e])];for(let e=0;t.length-1>e;e++){const i=t[e],o=t[e+1],n=h.geoDistance(i,o)||0,s=Math.max(2,Math.ceil(n/(Math.PI/180))),c=h.geoInterpolate(i,o);for(let t=0;s>=t;t++){if(e>0&&0===t)continue;const i=a(c(t/s));null!=i&&r.push(i)}}}else for(let t=0;i.length>t;t++){const e=i[t],o=a([c(e),l(e)]);null!=o&&r.push(o)}if(2>r.length)continue;const s=ue(n.lineStyle,e,fe),d="number"==typeof s.strokeWidth?s.strokeWidth:1;2!==i.length||2>r.length||"arc"!==n.flowStyle?2!==i.length||2>r.length||"offset"!==n.flowStyle||(r="geo"===n.lineType?pe(r,d):me(r[0],r[r.length-1],0,0,d)):r=ye(r[0],r[r.length-1]);const f=ge(r,t.width);if(f.length>1)for(const t of f){if(2>t.length)continue;const i={type:"line",path:t,style:Object.assign(Object.assign({},s),{_edgeFade:!0}),datum:e};o.push(i)}else o.push({type:"line",path:2>r.length&&f[0]||r,style:s,datum:e})}const d=this.getPoints(),f=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;d.length>t;t++){const e=d[t],i=c(e),r=l(e);if(null!=y&&h.geoDistance([i,r],x)>y)continue;const s=a([i,r]);if(!s)continue;const u=n.pointStyle?n.pointStyle(e):Object.assign({},de),g={type:"point",x:s[0],y:s[1],r:u.r||4,style:u,datum:e,pointId:f?f(e)+"":void 0};o.push(g)}return o}applyCartogramTransform(t,e){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,d=u.y,f=a.map(t=>l(t.datum)).filter(t=>isFinite(t)&&t>=0),g=Math.max(...f,1),y=Math.min(e.width,e.height)/2,p=i.scaleLinear().domain([0,g]).range([0,y]);this.cartogramLayout={cx:h,cy:d,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-d,t.x-h),i=Math.sqrt(Math.pow(t.x-h,2)+Math.pow(t.y-d,2)),r=l(t.datum),o=i+((isFinite(r)?p(r):i)-i)*s;t.x=h+Math.cos(e)*o,t.y=d+Math.sin(e)*o}const m=e.width/2,x=e.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(){const t=this.config.decay;if(!t||!this.pointBuffer)return;const e=this.pointBuffer.size;if(0===e)return;const i=this.scene.filter(t=>"point"===t.type);for(let r=0;i.length>r;r++){const o=M(t,r,e);i[r]._decayOpacity=o,i[r].style=Object.assign(Object.assign({},i[r].style),{opacity:o})}}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=L(t,this.activeTransition),i=T(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=D(t.x,t._targetX,i),t.y=D(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 ve(t,e="#4e79a7"){return t&&"string"==typeof t?t:e}function be(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:ve(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:ve(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:ve(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 ke(t,e){var i,r,o,n,a;const s=("category"in t?t.category:void 0)||("group"in t?t.group:void 0)||"",c=i=>`ord-${t.type}-${s}-${e}-${i}`,u=`ord-${t.type}-${s}-${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:i,y:r,w:o,h:n}=e;let a;switch(e.roundedEdge){case"right":a=`M${i},${r} L${i+o-t},${r} A${t},${t} 0 0 1 ${i+o},${r+t} L${i+o},${r+n-t} A${t},${t} 0 0 1 ${i+o-t},${r+n} L${i},${r+n} Z`;break;case"left":a=`M${i+o},${r} L${i+t},${r} A${t},${t} 0 0 0 ${i},${r+t} L${i},${r+n-t} A${t},${t} 0 0 0 ${i+t},${r+n} L${i+o},${r+n} Z`;break;case"bottom":a=`M${i},${r} L${i+o},${r} L${i+o},${r+n-t} A${t},${t} 0 0 1 ${i+o-t},${r+n} L${i+t},${r+n} A${t},${t} 0 0 1 ${i},${r+n-t} Z`;break;default:a=`M${i},${r+n} L${i},${r+t} A${t},${t} 0 0 1 ${i+t},${r} L${i+o-t},${r} A${t},${t} 0 0 1 ${i+o},${r+t} L${i+o},${r+n} Z`}return f.createElement("path",{key:u,d:a,fill:ve(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:ve(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:ve(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=l.arc().innerRadius(e.innerRadius).outerRadius(e.outerRadius).startAngle(e.startAngle+Math.PI/2).endAngle(e.endAngle+Math.PI/2);e.cornerRadius&&i.cornerRadius(e.cornerRadius);const r=i({})||"";return f.createElement("path",{key:u,d:r,transform:`translate(${e.cx},${e.cy})`,fill:ve(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:ve(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:ve(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:c("path"),d:e.pathString,transform:e.translateX||e.translateY?`translate(${e.translateX},${e.translateY})`:void 0,fill:ve(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:c("iqr"),x1:r,y1:e.iqrLine.q1Pos,x2:r,y2:e.iqrLine.q3Pos,stroke:e.style.stroke||"#333",strokeWidth:2}),f.createElement("circle",{key:c("med"),cx:r,cy:e.iqrLine.medianPos,r:3,fill:"white",stroke:e.style.stroke||"#333",strokeWidth:1})):i.push(f.createElement("line",{key:c("iqr"),x1:e.iqrLine.q1Pos,y1:o,x2:e.iqrLine.q3Pos,y2:o,stroke:e.style.stroke||"#333",strokeWidth:2}),f.createElement("circle",{key:c("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:ve(e.style.fill,"#999"),opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth})}default:return null}}function Ae(t){if(!t.accessibility)return t;let e=t;if(t.accessibility.colorBlindSafe&&(e=Object.assign(Object.assign({},e),{colors:Object.assign(Object.assign({},e.colors),{categorical:we})})),t.accessibility.highContrast){const t="dark"===e.mode;e=Object.assign(Object.assign({},e),{colors:Object.assign(Object.assign({},e.colors),{text:t?"#ffffff":"#000000",textSecondary:t?"#cccccc":"#333333",grid:t?"#666666":"#999999",border:t?"#888888":"#000000"})})}return e}xe.QUADTREE_THRESHOLD=500;const we=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],Se={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}},_e={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}},Pe={mode:"light",colors:{primary:"#0000cc",categorical:we,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:Se,setTheme(e){t(t=>{if("light"===e)return{theme:Se};if("dark"===e)return{theme:_e};if("high-contrast"===e)return{theme:Pe};if(e.mode&&"auto"!==e.mode){const t="dark"===e.mode?_e:Se;return{theme:Ae(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:Ae(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 Ee={light:Se,dark:_e,"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",annotation:"#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",annotation:"#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",annotation:"#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",annotation:"#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",annotation:"#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",annotation:"#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",annotation:"#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",annotation:"#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",annotation:"#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",annotation:"#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",annotation:"#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",annotation:"#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 Me(t){if(!t)return Se;if("string"==typeof t){if("light"===t)return Se;if("dark"===t)return _e;if("high-contrast"===t)return Pe;return Ee[t]||Se}const e="dark"===t.mode?_e:Se;return Ae(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 Oe(t){var e,i,r,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!==(i=t.typography.legendSize)&&void 0!==i?i:t.typography.labelSize,titleFontSize:null!==(r=t.typography.titleFontSize)&&void 0!==r?r:t.typography.titleSize,tickFontFamily:null!==(o=t.typography.tickFontFamily)&&void 0!==o?o:t.typography.fontFamily}}function Te(t){const{categories:e,colorScheme:r,theme:n,position:a="right",totalWidth:s,totalHeight:c,margin:l,hasTitle:u=!1}=t;if(!e||0===e.length)return null;const h=function(t,e,r){const n=Array.isArray(e)?e:r.colors.categorical.length>0?r.colors.categorical:o.schemeCategory10;return i.scaleOrdinal().domain(t).range(n)}(e,r,n),d="top"===a||"bottom"===a;let g,y;if("left"===a?(g=4,y=l.top):"top"===a?(g=l.left,y=u?32:8):"bottom"===a?(g=l.left,y=Math.min(c-l.bottom+38,c-16)):(g=s-l.right+10,y=l.top),d){let t=0;const i=e.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(${g},${y})`},i)}const p=e.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 Le(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 De(t,e){return t.color||e.colors.annotation||e.colors.text}function je(t){const{annotations:e}=t;if(!e||0===e.length)return null;const i=[];for(let r=0;e.length>r;r++){const o=ze(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 ze(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=De(t,l),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=De(t,l),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=Math.abs(r-i),u=t.fill||De(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:a,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||!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=De(t,l),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 $e={Sparkline:{frameType:"xy",buildProps:(t,e,i,r,o)=>Object.assign(Object.assign({chartType:"line",data:t,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",groupAccessor:o.lineBy||e,colorAccessor:e},r),{showAxes:!1,margin:r.margin||{top:2,right:2,bottom:2,left:2},showLegend:!1,showGrid:!1,title:void 0})},LineChart:{frameType:"xy",buildProps:(t,e,i,r,o)=>Object.assign({chartType:"line",data:t,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",groupAccessor:o.lineBy||e,colorAccessor:e,colorScheme:i,lineStyle:o.lineStyle},r)},AreaChart:{frameType:"xy",buildProps:(t,e,i,r,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:i},r)},StackedAreaChart:{frameType:"xy",buildProps:(t,e,i,r,o)=>Object.assign({chartType:"stackedarea",data:t,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",groupAccessor:o.areaBy,colorAccessor:e||o.areaBy,colorScheme:i,normalize:o.normalize},r)},Scatterplot:{frameType:"xy",buildProps:(t,e,i,r,o)=>Object.assign({chartType:"scatter",data:t,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",colorAccessor:e,sizeAccessor:o.sizeBy,colorScheme:i},r)},BubbleChart:{frameType:"xy",buildProps:(t,e,i,r,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:i},r)},ConnectedScatterplot:{frameType:"xy",buildProps:(t,e,i,r,o)=>Object.assign({chartType:"line",data:t,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",colorAccessor:e,colorScheme:i,showPoints:!0},r)},Heatmap:{frameType:"xy",buildProps:(t,e,i,r,o)=>Object.assign({chartType:"heatmap",data:t,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",valueAccessor:o.valueAccessor,colorScheme:i||o.colorScheme||"blues",showValues:o.showValues,cellBorderColor:o.cellBorderColor},r)},BarChart:{frameType:"ordinal",buildProps:(t,e,i,r,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:i,barPadding:o.barPadding},null!=o.roundedTop&&{roundedTop:o.roundedTop}),r)}},StackedBarChart:{frameType:"ordinal",buildProps:(t,e,i,r,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:i,projection:"horizontal"===o.orientation?"horizontal":"vertical",normalize:o.normalize,oSort:null!==(n=o.sort)&&void 0!==n&&n},null!=o.roundedTop&&{roundedTop:o.roundedTop}),r)}},GroupedBarChart:{frameType:"ordinal",buildProps:(t,e,i,r,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:i,projection:"horizontal"===o.orientation?"horizontal":"vertical",oSort:null!==(n=o.sort)&&void 0!==n&&n,barPadding:o.barPadding},null!=o.roundedTop&&{roundedTop:o.roundedTop}),r)}},PieChart:{frameType:"ordinal",buildProps:(t,e,i,r,o)=>Object.assign(Object.assign({chartType:"pie",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"radial",colorAccessor:e||o.categoryAccessor,colorScheme:i},null!=o.cornerRadius&&{cornerRadius:o.cornerRadius}),r)},DonutChart:{frameType:"ordinal",buildProps:(t,e,i,r,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:i},null!=o.cornerRadius&&{cornerRadius:o.cornerRadius}),r)},Histogram:{frameType:"ordinal",buildProps:(t,e,i,r,o)=>Object.assign({chartType:"histogram",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"horizontal",bins:o.bins,colorAccessor:e,colorScheme:i},r)},BoxPlot:{frameType:"ordinal",buildProps:(t,e,i,r,o)=>Object.assign({chartType:"boxplot",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",colorScheme:i},r)},ViolinPlot:{frameType:"ordinal",buildProps:(t,e,i,r,o)=>Object.assign({chartType:"violin",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",bins:o.bins,colorScheme:i},r)},SwarmPlot:{frameType:"ordinal",buildProps:(t,e,i,r,o)=>Object.assign({chartType:"swarm",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",colorAccessor:e,colorScheme:i},r)},DotPlot:{frameType:"ordinal",buildProps:(t,e,i,r,o)=>{var n;return Object.assign(Object.assign({chartType:"point",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",colorAccessor:e,colorScheme:i},r),{showGrid:null===(n=r.showGrid)||void 0===n||n})}},SwimlaneChart:{frameType:"ordinal",buildProps:(t,e,i,r,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:i,projection:"horizontal"===o.orientation?"horizontal":"vertical"},r)},RidgelinePlot:{frameType:"ordinal",buildProps:(t,e,i,r,o)=>Object.assign({chartType:"ridgeline",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",bins:o.bins,amplitude:o.amplitude},r)},LikertChart:{frameType:"ordinal",buildProps:(t,e,i,r,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:i,normalize:!0,projection:"vertical"===o.orientation?"vertical":"horizontal"},r)},FunnelChart:{frameType:"ordinal",buildProps:(t,e,i,r,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:i},r)}},GaugeChart:{frameType:"ordinal",buildProps:(t,e,i,r,o)=>{var n,a,s,c;const l=null!==(n=o.min)&&void 0!==n?n:0,u=null!==(a=o.max)&&void 0!==a?a:100,h=null!==(s=o.sweep)&&void 0!==s?s:240,d=null!==(c=o.arcWidth)&&void 0!==c?c:.3,f=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=r.margin||{top:20,right:20,bottom:30,left:40},[x,v]=r.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-d)),sweepAngle:h,startAngle:f,oSort:!1,pieceStyle:(t,e)=>({fill:p[e||""]||"#4e79a7"})},r),{showAxes:!1,__gauge:{gMin:l,gMax:u,sweep:h,arcWidth:d,value:o.value,startAngleDeg:f,thresholds:g}})}},ForceDirectedGraph:{frameType:"network",buildProps:(t,e,i,r,o)=>Object.assign({chartType:"force",nodes:o.nodes,edges:o.edges,nodeIDAccessor:o.nodeIDAccessor,sourceAccessor:o.sourceAccessor,targetAccessor:o.targetAccessor,colorBy:e,colorScheme:i,iterations:o.iterations,forceStrength:o.forceStrength,showLabels:o.showLabels,nodeLabel:o.nodeLabel,nodeSize:o.nodeSize,nodeSizeRange:o.nodeSizeRange,nodeStyle:o.nodeStyle,edgeStyle:o.edgeStyle},r)},SankeyDiagram:{frameType:"network",buildProps:(t,e,i,r,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:i},r)},ChordDiagram:{frameType:"network",buildProps:(t,e,i,r,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:i},r)},TreeDiagram:{frameType:"network",buildProps:(t,e,i,r,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:i},r)},Treemap:{frameType:"network",buildProps:(t,e,i,r,o)=>Object.assign({chartType:"treemap",data:t,childrenAccessor:o.childrenAccessor,hierarchySum:o.valueAccessor,colorBy:e,colorByDepth:o.colorByDepth,showLabels:o.showLabels,colorScheme:i},r)},CirclePack:{frameType:"network",buildProps:(t,e,i,r,o)=>Object.assign({chartType:"circlepack",data:t,childrenAccessor:o.childrenAccessor,hierarchySum:o.valueAccessor,colorBy:e,colorByDepth:o.colorByDepth,colorScheme:i},r)},ChoroplethMap:{frameType:"geo",buildProps:(t,e,i,r,o)=>Object.assign({areas:o.areas,projection:o.projection||"equalEarth",areaStyle:o.areaStyle,valueAccessor:o.valueAccessor,colorScheme:i||"blues",graticule:o.graticule,fitPadding:o.fitPadding},r)},ProportionalSymbolMap:{frameType:"geo",buildProps:(t,e,i,r,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:i,projection:o.projection||"equalEarth",graticule:o.graticule,fitPadding:o.fitPadding},r)},FlowMap:{frameType:"geo",buildProps:(t,e,i,r,o)=>{var n,a,s,c,l;const u=(Array.isArray(t)?t:null)||o.flows||[],h=o.nodeIdAccessor||"id",d=o.valueAccessor||"value",f=o.xAccessor||"lon",g=o.yAccessor||"lat",y="function"==typeof f?f:t=>t[f],p="function"==typeof g?g:t=>t[g],m=(o.nodes||[]).map(t=>Object.assign(Object.assign({},t),{x:y(t),y:p(t)})),x=new Map;for(const t of m)x.set(t[h]+"",t);const v=null!==(n=o.edgeColorBy)&&void 0!==n?n:e,b="function"==typeof v,k=u.map(t=>{if(!t||null==t.source||null==t.target)return null;const e=x.get(t.source+""),i=x.get(t.target+"");return e&&i?Object.assign(Object.assign({},t),{coordinates:[{x:e.x,y:e.y},{x:i.x,y:i.y}]}):null}).filter(Boolean),A="__flowMapEdgeColor",w=v?b?E(k.map(t=>({[A]:v(t)})),A,i||"category10"):E(k,v,i||"category10"):null,_=t=>v&&w?function(t,e,i){if("function"==typeof e){const r=e(t);return i&&r&&"string"==typeof r&&!function(t){const e=t.toLowerCase();return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")||P.has(e)}(r)?i(r):r}const r=null==t?void 0:t[e];return i?i(r):S[Math.abs(function(t){let e=0;for(let i=0;t.length>i;i++)e=(e<<5)-e+t.charCodeAt(i),e&=e;return Math.abs(e)}(r+""))%S.length]}(t,v,w):"#007bff";let M=1/0,O=-1/0;for(const t of k){const e=Number(null!==(a=t[d])&&void 0!==a?a:0);isFinite(e)&&(M>e&&(M=e),e>O&&(O=e))}const T=O>M?O-M:0,[L,D]=null!==(s=o.edgeWidthRange)&&void 0!==s?s:[1,8],j=D-L,z=null!==(c=o.edgeOpacity)&&void 0!==c?c:.6,$=null!==(l=o.edgeLinecap)&&void 0!==l?l:"round";return Object.assign({lines:k,points:m,xAccessor:"x",yAccessor:"y",lineDataAccessor:"coordinates",lineType:o.lineType||"geo",flowStyle:o.flowStyle||"basic",areas:o.areas,areaStyle:o.areaStyle,projection:o.projection||"equalEarth",graticule:o.graticule,fitPadding:o.fitPadding,colorScheme:i,lineStyle:t=>{const e=Number(null==t?void 0:t[d]),i=L+Math.max(0,Math.min(1,T>0?((Number.isFinite(e)?e:M)-M)/T:0))*j;return{stroke:_(t),strokeWidth:i,strokeLinecap:$,opacity:z,fillOpacity:0}},pointStyle:()=>({fill:"#333",r:4,fillOpacity:.8})},r)}}};function Re(t){return Math.round(100*t)/100+""}function Ne(t,e){const i=Oe(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 Ce(t){var e,i,r,o;const n=Me(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},y=new q(d);if(t.data&&y.ingest({inserts:t.data,bounded:!0}),y.computeScene({width:l,height:u}),!y.scales||0===y.scene.length)return g.renderToStaticMarkup(Ne(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 p=t._idPrefix,m=t.showGrid?function(t,e,i,r){const{grid:o}=Oe(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})}))}(y.scales,{width:l,height:u},n,p):null,x=y.scene.map((t,e)=>be(t,e)).filter(Boolean),v=!1!==t.showAxes?function(t,e,i,r,o){var n,a,s,c;const l=Oe(r),u=t.x.ticks(5).map(e=>({pixel:t.x(e),label:(i.xFormat||i.tickFormatTime||Re)(e)})),h=t.y.ticks(5).map(e=>({pixel:t.y(e),label:(i.yFormat||i.tickFormatValue||Re)(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))}(y.scales,{width:l,height:u},t,n,p):null,b=t.annotations?je({annotations:t.annotations,scales:{x:y.scales.x,y:y.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:p}):null,k=t.showLegend?(()=>{const e=Le(t.data||[],t.colorAccessor||t.groupAccessor);return 0===e.length?null:Te({categories:e,colorScheme:t.colorScheme,theme:n,position:t.legendPosition||"right",totalWidth:a[0],totalHeight:a[1],margin:s,hasTitle:!!t.title})})():null,A=f.createElement(f.Fragment,null,m,b,x,v);return g.renderToStaticMarkup(Ne(A,{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:k,idPrefix:t._idPrefix}))}function Be(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}const We=new Set(["tree","cluster","treemap","circlepack","partition"]);function Fe(t){const e=Me(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 ie[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 c={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(We.has(i)){const i=t.data||t.edges;if(!i||Array.isArray(i))return g.renderToStaticMarkup(Ne(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}));c.__hierarchyRoot=i,u=[],h=[]}else{const i=t.nodes||[],n=Array.isArray(t.edges)?t.edges:[];if(0===i.length&&0===n.length)return g.renderToStaticMarkup(Ne(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=Be(e.sourceAccessor,"source"),r=Be(e.targetAccessor,"target"),o=Be(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,c),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=Be(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,c)}s.computeLayout(u,h,c,[n,a]);const{sceneNodes:d,sceneEdges:y,labels:p}=s.buildScene(u,h,c,[n,a]),m=Oe(e);for(const t of p)t.fill||(t.fill=m.text);const x=y.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:ve(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:ve(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:ve(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),v=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:ve(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:ve(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})}case"arc":{const i=t,r=l.arc().innerRadius(i.innerR).outerRadius(i.outerR).startAngle(i.startAngle+Math.PI/2).endAngle(i.endAngle+Math.PI/2)({})||"";return f.createElement("path",{key:"net-arc-"+e,d:r,transform:`translate(${i.cx},${i.cy})`,fill:ve(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})}default:return null}}(t,e)).filter(Boolean),b=p.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),k=f.createElement(f.Fragment,null,x,v,b);return g.renderToStaticMarkup(Ne(k,{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 Ie(t){var e,i,r,o,n;const a=Me(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",y="radial"===d,p={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,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||a.colors.categorical,barColors:t.barColors},m=new ae(p);if(t.data&&m.ingest({inserts:t.data,bounded:!0}),m.computeScene({width:u,height:h}),!m.scales||0===m.scene.length)return g.renderToStaticMarkup(Ne(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 x=t._idPrefix,v=t.showGrid?function(t,e,i,r){const o=t.scales;if(!o||"radial"===o.projection)return null;const{grid:n}=Oe(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})}))}(m,{width:u,height:h},a,x):null,b=m.scene.some(t=>{var e;return"rect"===t.type&&(null===(e=t.datum)||void 0===e?void 0:e.__barFunnelIsDropoff)});let k=null;if(b){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 m.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");k=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 m.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 A=m.scene.map((t,e)=>ke(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=Oe(r),p="vertical"===g.projection,m=i.categoryFormat||i.oFormat,x=i.valueFormat||i.rFormat,v=i.categoryLabel||i.oLabel,b=i.valueLabel||i.rLabel,k=Object.values(t.columns).map(t=>({pixel:t.middle,label:(m||String)(t.name)})),A=g.r.ticks(5).map(t=>({pixel:g.r(t),label:(x||Re)(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}),k.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))),v&&f.createElement("text",{x:e.width/2,y:e.height+40,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily},v),f.createElement("line",{x1:0,y1:0,x2:0,y2:e.height,stroke:y.border,strokeWidth:1}),A.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))),b&&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})`},b)):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}),A.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))),b&&f.createElement("text",{x:e.width/2,y:e.height+40,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily},b),f.createElement("line",{x1:0,y1:0,x2:0,y2:e.height,stroke:y.border,strokeWidth:1}),k.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))),v&&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})`},v))}(m,{width:u,height:h},t,a,x):null,S=t.annotations?je({annotations:t.annotations,scales:{r:m.scales.r,y:"vertical"===m.scales.projection?m.scales.r:void 0},layout:{width:u,height:h},theme:a,projection:d,idPrefix:x}):null,_=t.showLegend?(()=>{const e=Le(t.data||[],t.colorAccessor||t.stackBy||t.groupBy);return 0===e.length?null:Te({categories:e,colorScheme:t.colorScheme,theme:a,position:t.legendPosition||"right",totalWidth:s[0],totalHeight:s[1],margin:c,hasTitle:!!t.title})})():null,P=y?c.left+u/2:c.left,E=y?c.top+h/2:c.top,M=f.createElement(f.Fragment,null,v,S,A,w);return g.renderToStaticMarkup(Ne(M,{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(${P},${E})`,legend:_,defs:k,idPrefix:t._idPrefix}))}function Ye(t){var e,i,r,o,n,a,s,c;const l=Me(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),y=u[1]-(null!==(r=h.top)&&void 0!==r?r:0)-(null!==(o=h.bottom)&&void 0!==o?o:0),p=new xe({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.`);p.setAreas(t.areas)}if(t.points&&p.setPoints(t.points),t.lines&&p.setLines(t.lines),p.computeScene({width:d,height:y}),0===p.scene.length)return g.renderToStaticMarkup(Ne(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 m=p.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:ve(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:ve(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),x=f.createElement(f.Fragment,null,m);return g.renderToStaticMarkup(Ne(x,{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 qe(t,e){switch(t){case"xy":return Ce(e);case"ordinal":return Ie(e);case"network":return Fe(e);case"geo":return Ye(e);default:throw Error(`Unknown frame type: ${t}. Must be "xy", "ordinal", "network", or "geo".`)}}function Xe(t,e,i){var r;const{data:o,width:n=600,height:a=400,theme:s,title:c,description:l,showLegend:u,showGrid:h,background:d,className:y,annotations:p,margin:m,colorScheme:x,colorBy:v,legendPosition:b}=e,k=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"]),A=[n,a],w=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},k.frameProps||{}),{theme:s,title:c,description:l,showLegend:u,showGrid:h,background:d,className:y,annotations:p,size:A}),void 0!==m&&{margin:m}),void 0!==x&&{colorScheme:x}),void 0!==b&&{legendPosition:b}),{_idPrefix:k._idPrefix}),S=$e[t];if(!S)throw Error(`Unknown chart component: "${t}". See CLAUDE.md for supported chart types.`);const _=S.buildProps(o,v,x,w,k);let P=(0,{xy:Ce,ordinal:Ie,network:Fe,geo:Ye}[S.frameType])(_);if("GaugeChart"===t&&_.__gauge){const t=_.__gauge,e=w.margin||{top:20,right:20,bottom:30,left:40},i=(n||300)-e.left-e.right,o=(a||300)-e.top-e.bottom,c=Math.min(i,o)/2*.85,l=e.left+i/2,u=e.top+o/2,h=Math.max(t.gMin,Math.min(t.gMax,null!==(r=t.value)&&void 0!==r?r:t.gMin)),d=(t.startAngleDeg+(t.gMax===t.gMin?0:(h-t.gMin)/(t.gMax-t.gMin))*t.sweep-90)*Math.PI/180,y=Me(s).colors.text,p=g.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:y,strokeWidth:2.5,strokeLinecap:"round"}),f.createElement("circle",{cx:l,cy:u,r:4,fill:y})));P=P.replace("</svg>",p+"</svg>")}return P}function Ge(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:d}=r,f=i.width||600,g=i.height||400,y=Me(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=f-b.left-b.right,A=g-b.top-b.bottom,w=[];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},d&&{decay:d}),c=new ae(s);c.ingest({inserts:a,bounded:!0}),c.computeScene({width:k,height:A}),c.scene.length>0&&w.push(Qe(c.scene,f,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},d&&{decay:d}),l>0&&{transition:{duration:l*(1e3/u),easing:h}}),v=new q(m);if(v.ingest({inserts:a,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(He(v.scene,f,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),w.push(He(v.scene,f,g,y,p,b))}}return w}function Ve(t,e){const i=t.background||e.colors.background;return i&&"transparent"!==i?i:null}function He(t,e,i,r,o,n){const a=Oe(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=Ve(o,r),h=t.map((t,e)=>be(t,e)).filter(Boolean),d=function(t,e,i,r,o,n){var a;if(!t||0===t.length)return null;const s=Oe(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),y="string"==typeof o.title?o.title:void 0,p="string"==typeof o.description?o.description:void 0,m=y?"semiotic-title":void 0,x=p?"semiotic-desc":void 0,v=[m,x].filter(Boolean).join(" ")||void 0,b=f.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:i,role:"img","aria-labelledby":v,style:{fontFamily:a.fontFamily}},y&&f.createElement("title",{id:m},y),p&&f.createElement("desc",{id:x},p),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),y&&f.createElement("text",{x:e/2,y:16,textAnchor:"middle",fontSize:a.titleSize,fontWeight:"bold",fill:a.text,fontFamily:a.fontFamily},y));return g.renderToStaticMarkup(b)}function Qe(t,e,i,r,o){const n=Oe(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=Ve(o,r),h=t.map((t,e)=>ke(t,e)).filter(Boolean),d="string"==typeof o.title?o.title:void 0,y="string"==typeof o.description?o.description:void 0,p=d?"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:n.fontFamily}},d&&f.createElement("title",{id:p},d),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(${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 g.renderToStaticMarkup(v)}exports.generateFrameSVGs=Ge,exports.generateFrameSequence=function(t,e,i={}){return e.map(e=>{try{return Xe(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=Xe,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=Oe(Me(n)),h=c.columns||2,d=null!==(i=c.gap)&&void 0!==i?i:16;let y=0;r&&(y+=30),o&&(y+=20),y>0&&(y+=10);const p=Math.floor((a-d-d*(h-1))/h),m=[];let x=0,v=y+d,b=0;for(const e of t){const t=Math.min(e.colSpan||1,h),i=e.props.height||300;x+t>h&&(v+=b+d,x=0,b=0),m.push({chart:e,x:d/2+x*(p+d),y:v,w:p*t+d*(t-1),h:i}),b=Math.max(b,i),x+=t}const k=s||v+b+d,A=m.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?Xe(i.component,c):i.frameType?qe(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:k,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:k,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),A);return g.renderToStaticMarkup(w)},exports.renderGeoToStaticSVG=function(t){return Ye(t)},exports.renderNetworkToStaticSVG=function(t){return Fe(t)},exports.renderOrdinalToStaticSVG=function(t){return Ie(t)},exports.renderToAnimatedGif=function(t,e,i){return y(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=Ge(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 d,f,g,y;try{d=require("sharp")}catch(t){throw Error('Animated GIF export requires "sharp". Install it:\n npm install sharp')}try{const t=require("gifenc");f=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=f();for(let t=0;h.length>t;t++){const e=h[t],i=yield d(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 y(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)?qe(t,e):Xe(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,d=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?d.jpeg({quality:90}).toBuffer():d.png().toBuffer()})},exports.renderToStaticSVG=qe,exports.renderXYToStaticSVG=function(t){return Ce(t)},exports.resolveTheme=Me,exports.themeStyles=Oe;
|
|
1
|
+
"use strict";const t=require("react/jsx-runtime"),e=require("react-dom/server"),i=require("d3-scale"),o=require("d3-quadtree"),r=require("d3-scale-chromatic"),n=require("d3-array"),s=require("d3-interpolate"),a=require("d3-force"),c=require("d3-chord"),l=require("d3-shape"),u=require("d3-hierarchy"),h=require("d3-geo"),d=require("react");function f(t){if(t&&t.__esModule)return t;const e=Object.create(null);if(t)for(const i in t)if("default"!==i){const o=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,o.get?o:{enumerable:!0,get:function(){return t[i]}})}return e.default=t,Object.freeze(e)}const g=f(e),y=f(d);function p(t,e,i,o){return new(i||(i=Promise))(function(r,n){function s(t){try{c(o.next(t))}catch(t){n(t)}}function a(t){try{c(o.throw(t))}catch(t){n(t)}}function c(t){t.done?r(t.value):function(t){return t instanceof i?t:new i(function(e){e(t)})}(t.value).then(s,a)}c((o=o.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class m{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;return{next:()=>this._size>t?{done:!1,value:this.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=[],o=(this.head-this._size+this._capacity)%this._capacity;for(let r=0;this._size>r;r++){const n=(o+r)%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),i.push(t),this.buffer[n]=e(s)}}return i}remove(t){const e=[],i=[];if(this.forEach(o=>{t(o)?i.push(o):e.push(o)}),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 x{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 v(t,e,i,o,r){const n=new Map;for(const s of t){const t=e(s),a=i(s);if(null==t||null==a||Number.isNaN(t)||Number.isNaN(a))continue;const c=Math.floor(t/o)*o;let l=n.get(c);if(l||(l={start:c,end:c+o,total:0,categories:new Map},n.set(c,l)),l.total+=a,r){const t=r(s);l.categories.set(t,(l.categories.get(t)||0)+a)}}return n}function b(t,e){return t===e||typeof t==typeof e&&"function"==typeof t&&"function"==typeof e&&""+t==""+e}function k(t,e){if("function"==typeof t)return e=>+t(e);const i=t||e;return t=>+t[i]}function A(t,e){if("function"==typeof t)return t;const i=t||e;return t=>t[i]}function w(t,e){return"function"==typeof t?t:t?e=>e[t]+"":e?t=>t[e]+"":void 0}const S={category10:r.schemeCategory10,tableau10:r.schemeTableau10,set3:r.schemeSet3,blues:r.interpolateBlues,reds:r.interpolateReds,greens:r.interpolateGreens,oranges:r.interpolateOranges,purples:r.interpolatePurples,viridis:r.interpolateViridis,plasma:r.interpolatePlasma},_=r.schemeCategory10,P=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],j=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);function M(t,e,o="category10"){const r=Array.from(new Set(t.map(t=>null==t?void 0:t[e]).filter(t=>null!=t))),n=r.every(t=>"number"==typeof t||!isNaN(Number(t)));if(Array.isArray(o))return i.scaleOrdinal().domain(r).range(o).unknown("#999");const s=S[o]||S.category10;if(n&&"function"==typeof s){let t=-1/0;for(const e of r){const i=Number(e);i>t&&(t=i)}return e=>s(Number(e)/t)}{const t=Array.isArray(s)?s:_;return i.scaleOrdinal().domain(r).range(t).unknown("#999")}}function O(t,e,i){var o,r,n;if(1>=i)return 1;const s=null!==(o=t.minOpacity)&&void 0!==o?o:.1,a=i-1-e;switch(t.type){case"linear":return s+(1-a/(i-1))*(1-s);case"exponential":{const e=null!==(r=t.halfLife)&&void 0!==r?r:i/2;return s+Math.pow(.5,a/e)*(1-s)}case"step":return(null!==(n=t.stepThreshold)&&void 0!==n?n:.5*i)>a?1:s;default:return 1}}function T(t,e,i){var o;const r=null!==(o=t.duration)&&void 0!==o?o:500,n=i-e;return r>n?1-n/r:0}function L(t,e="ease-out-cubic"){return"linear"===e?t:1-Math.pow(1-t,3)}function E(t,e){return Math.min((t-e.startTime)/e.duration,1)}function D(t,e,i){return t+(e-t)*i}function z(){return"undefined"!=typeof performance?performance.now():Date.now()}function $(t,e,i){var o,r,n,s;if(e._transitionKey)return e._transitionKey;switch(e.type){case"point":if(e.pointId)return"p:"+e.pointId;if("streaming"===t.runtimeMode&&e.datum){const i=t.getX(e.datum),o=t.getY(e.datum);if(t.getCategory)return`p:${t.getCategory(e.datum)}:${i}:${o}`;if(null!=i&&null!=o)return`p:${i}:${o}`}return"p:"+i;case"rect":return`r:${e.group||""}:${null!==(s=null!==(r=null===(o=e.datum)||void 0===o?void 0:o.binStart)&&void 0!==r?r:null===(n=e.datum)||void 0===n?void 0:n.category)&&void 0!==s?s:i}`;case"heatcell":return`h:${e.x}_${e.y}`;case"candlestick":return null==e.datum?"c:"+i:"c:"+t.getX(e.datum);case"line":return"l:"+(e.group||"_default");case"area":return"a:"+(e.group||"_default");default:return null}}function C(t,e,i,o,r,n){const s=[];for(const r of t){const t=i(r),n=o(r);null==t||null==n||Number.isNaN(t)||Number.isNaN(n)||s.push({px:e.x(t),py:e.y(n),rawY:n,d:r})}s.sort((t,e)=>t.px-e.px);const a=Array(s.length),c=Array(s.length),l=Array(s.length);for(let t=0;s.length>t;t++){const e=s[t];a[t]=[e.px,e.py],c[t]=e.rawY,l[t]=e.d}return{type:"line",path:a,rawValues:c,style:r,datum:l,group:n}}function R(t,e,i,o,r,n,s,a){const c=[];for(const n of t){const t=i(n),s=o(n);if(null==t||null==s||Number.isNaN(t)||Number.isNaN(s))continue;const l=e.x(t),u=a?a(n):r;c.push({px:l,topY:e.y(s),botY:e.y(u)})}c.sort((t,e)=>t.px-e.px);const l=Array(c.length),u=Array(c.length);for(let t=0;c.length>t;t++){const e=c[t];l[t]=[e.px,e.topY],u[t]=[e.px,e.botY]}return{type:"area",topPath:l,bottomPath:u,style:n,datum:t,group:s}}function N(t,e,i,o,r,n,s){const a=i(t),c=o(t);if(null==a||null==c||Number.isNaN(a)||Number.isNaN(c))return null;const l={type:"point",x:e.x(a),y:e.y(c),r:r,style:n,datum:t};return void 0!==s&&(l.pointId=s),l}function B(t,e,i,o,r,n,s){return{type:"rect",x:t,y:e,w:i,h:o,style:r,datum:n,group:s}}function W(t,e,i,o,r,n,s){const a={type:"heatcell",x:t,y:e,w:i,h:o,fill:r,datum:n};return(null==s?void 0:s.showValues)&&(a.showValues=!0,a.value=s.value,s.valueFormat&&(a.valueFormat=s.valueFormat)),a}function F(t,e,i){if(!t.getBounds||!t.scales)return null;const o=[],r=[];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 s=t.getBounds(i),a=t.scales.x(e);if(s&&0!==s)o.push([a,t.scales.y(n+s)]),r.push([a,t.scales.y(n-s)]);else{const e=t.scales.y(n);o.push([a,e]),r.push([a,e])}}return 2>o.length?null:{type:"area",topPath:o,bottomPath:r,style:t.resolveBoundsStyle(i,e[0]),datum:e,group:i,interactive:!1}}function Y(t,e,i,o){var r;if(!t.config.pointStyle)return;const n=null!=o?o:t.getY;for(const o of e){const e=t.resolveGroupColor(o.key);for(const s of o.data){let o=t.config.pointStyle(s);!o.fill&&e&&(o=Object.assign(Object.assign({},o),{fill:e}));const a=null!==(r=o.r)&&void 0!==r?r:3,c=t.getPointId?t.getPointId(s)+"":void 0,l=N(s,t.scales,t.getX,n,a,o,c);l&&i.push(l)}}}const I={blues:r.interpolateBlues,reds:r.interpolateReds,greens:r.interpolateGreens,viridis:r.interpolateViridis,oranges:r.interpolateOranges,purples:r.interpolatePurples,greys:r.interpolateGreys,plasma:r.interpolatePlasma,inferno:r.interpolateInferno,magma:r.interpolateMagma,cividis:r.interpolateCividis,turbo:r.interpolateTurbo},X=new Map;class q{constructor(t){if(this.xExtent=new x,this.yExtent=new x,this.timestampBuffer=null,this.activeTransition=null,this._hasRenderedOnce=!1,this.prevPositionMap=new Map,this.prevPathMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,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._maxPointRadius=0,this.config=t,this.buffer=new m(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=k(t.timeAccessor||t.xAccessor,"time"),this.getY=k(t.valueAccessor||t.yAccessor,"value")):(this.getX=k(t.xAccessor,"x"),this.getY=k(t.yAccessor,"y")),this.getGroup=w(t.groupAccessor),this.getCategory=w(t.categoryAccessor),this.getSize=t.sizeAccessor?k(t.sizeAccessor,"size"):void 0,this.getColor=w(t.colorAccessor),this.getBounds=t.boundsAccessor?k(t.boundsAccessor,"bounds"):void 0,this.getY0=t.y0Accessor?k(t.y0Accessor,"y0"):void 0,this.getPointId=w(t.pointIdAccessor),"candlestick"===t.chartType){const e=null!=t.openAccessor,i=null!=t.closeAccessor;this.getOpen=e?k(t.openAccessor,"open"):void 0,this.getHigh=k(t.highAccessor,"high"),this.getLow=k(t.lowAccessor,"low"),this.getClose=i?k(t.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!i}t.pulse&&(this.timestampBuffer=new m(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?k(this.config.timeAccessor||this.config.xAccessor,"time"):k(this.config.xAccessor,"x"),this.xIsDate=!1,t.inserts.length>0){const e=t.inserts[0],i=this.config.xAccessor,o="function"==typeof i?i(e):e[i||"x"],r=o instanceof Date,n="string"==typeof o&&o.length>=10&&!isNaN(new Date(o).getTime())&&isNaN(Number(o));if(this.xIsDate=r||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 e,o,r,n,s,a,c;const{config:l,buffer:u}=this;if(!this.needsFullRebuild&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(null!==(e=this.config.scalePadding)&&void 0!==e?e: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(),d=this.xExtent.extent,f=this.yExtent.extent;let g=l.xExtent?[null!==(o=l.xExtent[0])&&void 0!==o?o:d[0],null!==(r=l.xExtent[1])&&void 0!==r?r:d[1]]:d,y=l.yExtent?[null!==(n=l.yExtent[0])&&void 0!==n?n:f[0],null!==(s=l.yExtent[1])&&void 0!==s?s:f[1]]:f;const p=l.yExtent&&null!=l.yExtent[0]&&null!=l.yExtent[1];if("stackedarea"===l.chartType&&!p&&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;let o=0;for(const t of e)for(const e of t.data){const t=this.getX(e),r=this.getY(e);if(null==t||null==r||Number.isNaN(t)||Number.isNaN(r))continue;const n=(i.get(t)||0)+r;i.set(t,n),n>o&&(o=n)}y=[0,o+(o>0?o*l.extentPadding:1)],this._stackExtentCache={key:t,yDomain:y}}}else if("bar"===l.chartType&&l.binSize&&!p&&u.size>0){const[,t]=function(t,e,i,o,r){const n=v(t,e,i,o,r);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&&!p&&u.size>0){const[t,e]=function(t,e){let i=0,o=0,r=0;for(const n of t){const t=e(n);null==t||Number.isNaN(t)||(r+=t,i>r&&(i=r),r>o&&(o=r))}return[i,o]}(u,this.getY),i=e-t,o=i>0?i*l.extentPadding:1;y=[Math.min(0,t-Math.abs(o)),Math.max(0,e+Math.abs(o))]}else if(!p&&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===(a=l.yExtent)||void 0===a?void 0:a[0],o=null===(c=l.yExtent)||void 0===c?void 0:c[1];y=[null!=i?y[0]:y[0]-e,null!=o?y[1]:y[1]+e],"log"===l.yScaleType&&0>=y[0]&&f[0]>0&&(y[0]=null!=i?y[0]:f[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 m="streaming"===l.runtimeMode,x=Math.max(0,Math.min(l.scalePadding||0,Math.min(t.width,t.height)/2-1));if(m)if("x"==("up"===(b=l.arrowOfTime)||"down"===b?"y":"x")){const e="right"===l.arrowOfTime?[x,t.width-x]:[t.width-x,x];this.scales={x:i.scaleLinear().domain(g).range(e),y:i.scaleLinear().domain(y).range([t.height-x,x])}}else{const e="down"===l.arrowOfTime?[x,t.height-x]:[t.height-x,x];this.scales={x:i.scaleLinear().domain(y).range([x,t.width-x]),y:i.scaleLinear().domain(g).range(e)}}else{const e=(t,e,o)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return i.scaleLog().domain(t).range(o).clamp(!0)}return"time"===t?i.scaleTime().domain([new Date(e[0]),new Date(e[1])]).range(o):i.scaleLinear().domain(e).range(o)};this.scales={x:e(l.xScaleType,g,[x,t.width-x]),y:e(l.yScaleType,y,[t.height-x,x])}}var b;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(t,h),this.config.decay&&this.applyDecay(this.scene,h),this.config.pulse&&this.applyPulse(this.scene,h),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),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 this._quadtree=null,void(this._maxPointRadius=0);let e=0,i=0;for(const t of this.scene)"point"===t.type&&(e++,t.r>i&&(i=t.r));if(this._maxPointRadius=i,q.QUADTREE_THRESHOLD>=e)return void(this._quadtree=null);const r=Array(e);let n=0;for(const t of this.scene)"point"===t.type&&(r[n++]=t);this._quadtree=o.quadtree().x(t=>t.x).y(t=>t.y).addAll(r)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}remapScene(t){const e=t.width/this.lastLayout.width,o=t.height/this.lastLayout.height;for(const t of this.scene)switch(t.type){case"line":for(const i of t.path)i[0]*=e,i[1]*=o;break;case"area":for(const i of t.topPath)i[0]*=e,i[1]*=o;for(const i of t.bottomPath)i[0]*=e,i[1]*=o;break;case"point":t.x*=e,t.y*=o;break;case"rect":case"heatcell":t.x*=e,t.y*=o,t.w*=e,t.h*=o;break;case"candlestick":t.x*=e,t.openY*=o,t.closeY*=o,t.highY*=o,t.lowY*=o}const r=this.scales.x.domain(),n=this.scales.y.domain(),s=this.scales.x.range(),a=this.scales.y.range(),c=(t,e,o)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return i.scaleLog().domain(t).range(o).clamp(!0)}return"time"===t?i.scaleTime().domain([new Date(e[0]),new Date(e[1])]).range(o):i.scaleLinear().domain(e).range(o)},l=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(t.width,t.height)/2-1)),u=a[1]>a[0];this.scales={x:c(this.config.xScaleType,r,s[0]>s[1]?[t.width-l,l]:[l,t.width-l]),y:c(this.config.yScaleType,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 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 i;const o=t.groupData(e),r=[],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 o){const i=F(t,e.data,e.key);i&&r.push(i)}for(const e of o){const i=t.resolveLineStyle(e.key,e.data[0]),o=C(e.data,t.scales,t.getX,t.getY,i,e.key);n&&n.length>0&&(o.colorThresholds=n),t.config.curve&&"linear"!==t.config.curve&&(o.curve=t.config.curve),t.config.lineGradient&&(o.strokeGradient=t.config.lineGradient),r.push(o)}return Y(t,o,r),r}(s,e);case"area":return function(t,e){const i=t.groupData(e),o=[],r=t.scales.y.domain()[0],n=t.getY0?e=>{const i=t.getY0(e);return null==i?r:i}:void 0;for(const e of i){const i=t.resolveAreaStyle(e.key,e.data[0]),s=R(e.data,t.scales,t.getX,t.getY,r,i,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),o.push(s)}return Y(t,i,o),o}(s,e);case"mixed":return function(t,e){const i=t.groupData(e),o=[],r=t.config.areaGroups||new Set,n=t.scales.y.domain()[0],s=t.getY0?e=>{const i=t.getY0(e);return null==i?n:i}:void 0;for(const e of i)if(r.has(e.key)){const i=t.resolveAreaStyle(e.key,e.data[0]),r=R(e.data,t.scales,t.getX,t.getY,n,i,e.key,s);t.config.gradientFill&&(r.fillGradient=t.config.gradientFill),t.config.curve&&"linear"!==t.config.curve&&(r.curve=t.config.curve),t.config.lineGradient&&(r.strokeGradient=t.config.lineGradient),o.push(r)}else{const i=t.resolveLineStyle(e.key,e.data[0]),r=C(e.data,t.scales,t.getX,t.getY,i,e.key);t.config.curve&&"linear"!==t.config.curve&&(r.curve=t.config.curve),t.config.lineGradient&&(r.strokeGradient=t.config.lineGradient),o.push(r)}return Y(t,i,o),o}(s,e);case"stackedarea":return function(t,e){const i=t.groupData(e);i.sort((t,e)=>e.key>t.key?-1:t.key>e.key?1:0);const o=t.config.curve&&"linear"!==t.config.curve?t.config.curve:void 0,{nodes:r,stackedTops:n}=function(t,e,i,o,r,n,s){var a;const c=new Set;for(const e of t)for(const t of e.data){const e=i(t);null==e||Number.isNaN(e)||c.add(e)}const l=Array.from(c).sort((t,e)=>t-e),u=new Map;for(const e of t){const t=new Map;for(const r of e.data){const e=i(r),n=o(r);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 o of t)i+=(null===(a=u.get(o.key))||void 0===a?void 0:a.get(e))||0;h.set(e,i||1)}}const d=[],f=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),o=[],a=[],c=new Map;for(const i of l){let r=t.get(i)||0;const s=g.get(i);n&&(r/=h.get(i));const l=s+r,u=e.x(i);a.push([u,e.y(s)]),o.push([u,e.y(l)]),g.set(i,l),c.set(i,l)}f.set(i.key,c);const y={type:"area",topPath:o,bottomPath:a,style:r(i.key,i.data[0]),datum:i.data,group:i.key};s&&(y.curve=s),d.push(y)}return{nodes:d,stackedTops:f}}(i,t.scales,t.getX,t.getY,(e,i)=>t.resolveAreaStyle(e,i),t.config.normalize,o),s=r;if(t.config.pointStyle){const e=new WeakMap;for(const o of i){const i=n.get(o.key);if(i)for(const r of o.data){const o=t.getX(r),n=t.getY(r);null==o||Number.isNaN(o)||null==n||Number.isNaN(n)||!i.has(o)||e.set(r,i.get(o))}}const o=i=>{var o;return null!==(o=e.get(i))&&void 0!==o?o:t.getY(i)};Y(t,i,s,o)}return s}(s,e);case"scatter":case"bubble":return function(t,e){var i;const o=[],r="bubble"===t.config.chartType?10:5,n=t.config.sizeRange||[3,15];let s=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 o of i)t>o&&(t=o),o>e&&(e=o);s=i=>t===e?(n[0]+n[1])/2:n[0]+(i-t)/(e-t)*(n[1]-n[0])}}const a=t.getColor?t.resolveColorMap(e):null,c=(null===(i=t.config.themeSemantic)||void 0===i?void 0:i.primary)||"#4e79a7";for(const i of e){let e=t.config.pointStyle?t.config.pointStyle(i):{fill:c,opacity:.8},n=e.r||r;if(s&&t.getSize){const e=t.getSize(i);null==e||Number.isNaN(e)||(n=s(e))}if(a&&t.getColor&&!e.fill){const o=t.getColor(i);o&&a.has(o)&&(e=Object.assign(Object.assign({},e),{fill:a.get(o)}))}const l=t.getPointId?t.getPointId(i)+"":void 0,u=N(i,t.scales,t.getX,t.getY,n,e,l);u&&o.push(u)}return o}(s,e);case"heatmap":return function(t,e,i){if(t.config.heatmapAggregation)return function(t,e,i){var o,r,n;const s=Math.max(1,Math.floor(null!==(o=t.config.heatmapXBins)&&void 0!==o?o:20)),a=Math.max(1,Math.floor(null!==(r=t.config.heatmapYBins)&&void 0!==r?r:20)),c=null!==(n=t.config.heatmapAggregation)&&void 0!==n?n:"count",l=k(t.config.valueAccessor,"value");if(!t.scales||0===e.length)return[];const[u,h]=t.scales.x.domain(),[d,f]=t.scales.y.domain(),g=(h-u||1)/s,y=(f-d||1)/a,p=s*a;if(p>1e6)return[];const m=new Int32Array(p),x=new Float64Array(p);for(let i=0;e.length>i;i++){const o=e[i],r=t.getX(o),n=t.getY(o);if(!isFinite(r)||!isFinite(n))continue;const c=Math.min(Math.floor((r-u)/g),s-1),h=Math.min(Math.floor((n-d)/y),a-1);if(0>c||0>h)continue;const f=h*s+c;m[f]++;const p=l(o);x[f]+=isFinite(p)?p:0}let v=1/0,b=-1/0;for(let t=0;p>t;t++){if(0===m[t])continue;let e;switch(c){case"sum":e=x[t];break;case"mean":e=x[t]/m[t];break;default:e=m[t]}v>e&&(v=e),e>b&&(b=e)}if(!isFinite(v))return[];const A=b-v||1,w=i.width/s,S=i.height/a,_=t.config.showValues,P=t.config.heatmapValueFormat,j=[];for(let t=0;a>t;t++){const e=t*s;for(let i=0;s>i;i++){const o=e+i;if(0===m[o])continue;let r;switch(c){case"sum":r=x[o];break;case"mean":r=x[o]/m[o];break;default:r=m[o]}const n=(r-v)/A;j.push(W(i*w,(a-1-t)*S,w,S,`rgb(${220-(180*n+.5)|0},${220-(100*n+.5)|0},${255-(50*n+.5)|0})`,{xi:i,yi:t,value:r,count:m[o],sum:x[o]},_?{value:r,showValues:!0,valueFormat:P}:void 0))}}return j}(t,e,i);if(0===e.length)return[];const o=k(t.config.valueAccessor,"value"),n=A(t.config.xAccessor,"x"),s=A(t.config.yAccessor,"y"),a=new Map,c=new Map,l=Array(e.length),u=Array(e.length);for(let t=0;e.length>t;t++){const i=e[t],o=n(i),r=s(i);l[t]=o,u[t]=r,a.has(o)||a.set(o,a.size),c.has(r)||c.set(r,c.size)}const h=a.size,d=c.size;if(0===h||0===d)return[];const f=Array.from(a.keys()),g=Array.from(c.keys()),y=f.every(t=>"number"==typeof t&&!isNaN(t)),p=g.every(t=>"number"==typeof t&&!isNaN(t));if(y){f.sort((t,e)=>t-e),a.clear();for(let t=0;f.length>t;t++)a.set(f[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),x=new Float64Array(e.length),v=Array(e.length),b=new Map;let w=0;for(let t=0;e.length>t;t++){const i=e[t],r=a.get(l[t]),n=c.get(u[t]);if(void 0===r||void 0===n)continue;const s=o(i),d=n*h+r,f=b.get(d);let g;void 0!==f?g=f:(g=w++,b.set(d,g)),m[g]=d,x[g]=s,v[g]=i}let S=1/0,_=-1/0;for(let t=0;w>t;t++){const e=x[t];isFinite(e)&&(S>e&&(S=e),e>_&&(_=e))}if(!isFinite(S)||!isFinite(_))return[];const P=function(t){const e=t in I?t:"blues";let i=X.get(e);if(i)return i;i=Array(256);const o=I[e]||r.interpolateBlues;for(let t=0;256>t;t++)i[t]=o(t/255);return X.set(e,i),i}("string"==typeof t.config.colorScheme?t.config.colorScheme:t.config.themeSequential||"blues"),j=255/(_-S||1),M=i.width/h,O=i.height/d,T=t.config.showValues,L=t.config.heatmapValueFormat,E=[];for(let t=0;w>t;t++){const e=x[t];if(!isFinite(e))continue;const i=m[t],o=i%h;E.push(W(o*M,(d-1-(i-o)/h)*O,M,O,P[Math.min((e-S)*j+.5|0,255)],v[t],T?{value:e,showValues:!0,valueFormat:L}:void 0))}return E}(s,e,t);case"bar":{const t=function(t,e){var i,o;if(!t.config.binSize)return{nodes:[],binBoundaries:[]};const r=v(e,t.getX,t.getY,t.config.binSize,t.getCategory);if(0===r.size)return{nodes:[],binBoundaries:[]};let n=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):[],o=new Set(i),s=Array.from(e).filter(t=>!o.has(t)).sort(),a=i.filter(t=>e.has(t)),c=a.join("\0")+""+s.join("\0");t.barCategoryCache&&t.barCategoryCache.key===c?n=t.barCategoryCache.order:(n=[...a,...s],t.barCategoryCache={key:c,order:n})}const s=[],a=t.scales,[c,l]=a.x.domain(),u=t.config.barStyle,h=null===(i=t.config.themeSemantic)||void 0===i?void 0:i.primary,d=null==u?void 0:u.gap,f="number"!=typeof d||0>d?1:d,g={};(null==u?void 0:u.stroke)&&(g.stroke=u.stroke),"number"==typeof(null==u?void 0:u.strokeWidth)&&(g.strokeWidth=u.strokeWidth),"number"==typeof(null==u?void 0:u.opacity)&&(g.opacity=u.opacity);for(const e of r.values()){const i=Math.max(e.start,c),r=Math.min(e.end,l);if(i>=r)continue;const d=a.x(i),y=a.x(r),p=Math.abs(y-d),m=p>f+1?f:0,x=Math.min(d,y)+m/2,v=Math.max(p-m,1);if(v>0)if(n&&e.categories.size>0){let i=0;for(const r of n){const n=e.categories.get(r)||0;if(0===n)continue;const c=a.y(i),l=a.y(i+n),d=(null===(o=t.config.barColors)||void 0===o?void 0:o[r])||(null==u?void 0:u.fill)||h||"#4e79a7";s.push(B(x,Math.min(c,l),v,Math.abs(c-l),Object.assign({fill:d},g),{binStart:e.start,binEnd:e.end,total:e.total,category:r,categoryValue:n},r)),i+=n}}else{const t=a.y(0),i=a.y(e.total);s.push(B(x,Math.min(t,i),v,Math.abs(t-i),Object.assign({fill:(null==u?void 0:u.fill)||h||"#007bff"},g),{binStart:e.start,binEnd:e.end,total:e.total}))}}const y=new Set;for(const t of r.values())y.add(t.start),y.add(t.end);return{nodes:s,binBoundaries:Array.from(y).sort((t,e)=>t-e)}}(s,e);return this._barCategoryCache=null!==(i=s.barCategoryCache)&&void 0!==i?i:null,this._binBoundaries=t.binBoundaries,t.nodes}case"swarm":return function(t,e){var i,o,r,n,s,a;const c=[],l=t.config.swarmStyle||{},u=null!==(i=l.radius)&&void 0!==i?i:3,h=null!==(n=null!==(o=l.fill)&&void 0!==o?o:null===(r=t.config.themeSemantic)||void 0===r?void 0:r.primary)&&void 0!==n?n:"#007bff",d=null!==(s=l.opacity)&&void 0!==s?s:.7,f=l.stroke,g=l.strokeWidth;for(const i of e){const e=t.getX(i),o=t.getY(i);if(null==o||Number.isNaN(o))continue;const r=t.scales.x(e),n=t.scales.y(o);let s=h;if(t.getCategory){const e=t.getCategory(i);s=(null===(a=t.config.barColors)||void 0===a?void 0:a[e])||s}const l={type:"point",x:r,y:n,r:u,style:{fill:s,opacity:d,stroke:f,strokeWidth:g},datum:i};t.getPointId&&(l.pointId=t.getPointId(i)+""),c.push(l)}return c}(s,e);case"waterfall":return function(t,e,i){var o,r,n,s,a,c,l;const u=[],h=t.scales,d=t.config.waterfallStyle,f=e.filter(e=>{const i=t.getY(e),o=t.getX(e);return null!=i&&!Number.isNaN(i)&&null!=o&&isFinite(o)});if(0===f.length)return u;const g=null!==(n=null!==(o=null==d?void 0:d.positiveColor)&&void 0!==o?o:null===(r=t.config.themeSemantic)||void 0===r?void 0:r.success)&&void 0!==n?n:"#28a745",y=null!==(c=null!==(s=null==d?void 0:d.negativeColor)&&void 0!==s?s:null===(a=t.config.themeSemantic)||void 0===a?void 0:a.danger)&&void 0!==c?c:"#dc3545",p=null!==(l=null==d?void 0:d.gap)&&void 0!==l?l:1,m=null==d?void 0:d.stroke,x=null==d?void 0:d.strokeWidth,v=null==d?void 0:d.opacity;let b=0;for(let e=0;f.length>e;e++){const o=f[e],r=t.getX(o),n=t.getY(o),s=b+n;let a;a=f.length-1>e?t.getX(f[e+1])-r:e>0?r-t.getX(f[e-1]):0;const c=h.x(r),l=0!==a?h.x(r+a):c+i.width/10,k=Math.min(c,l)+p/2,A=Math.max(c,l)-p/2-k;if(0>=A){b=s;continue}const w=h.y(b),S=h.y(s),_=Math.min(w,S),P=Math.abs(w-S),j={fill:0>n?y:g,stroke:m,strokeWidth:x};null!=v&&(j.opacity=v),u.push(B(k,_,A,P,j,Object.assign(Object.assign({},o),{baseline:b,cumEnd:s,delta:n,_connectorStroke:null==d?void 0:d.connectorStroke,_connectorWidth:null==d?void 0:d.connectorWidth}))),b=s}return u}(s,e,t);case"candlestick":return function(t,e){var i,o;if(!t.getHigh||!t.getLow||!t.scales)return[];const r=null!==(i=t.config.candlestickRangeMode)&&void 0!==i&&i;if(!(r||t.getOpen&&t.getClose))return[];const n=[],s=t.config.candlestickStyle||{},a=s.rangeColor||"#6366f1",c=r?a:s.upColor||"#28a745",l=r?a:s.downColor||"#dc3545",u=r?a:s.wickColor||"#333",h=s.wickWidth||(r?2:1),d=e.map(e=>t.getX(e)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let f=null!==(o=s.bodyWidth)&&void 0!==o?o:0;if(null==s.bodyWidth)if(d.length>1){let e=1/0;for(let i=1;d.length>i;i++){const o=Math.abs(t.scales.x(d[i])-t.scales.x(d[i-1]));o>0&&e>o&&(e=o)}f=e!==1/0?Math.max(2,Math.min(.6*e,20)):6}else f=6;for(const i of e){const e=t.getX(i);if(null==e||Number.isNaN(e))continue;const o=t.getHigh(i),s=t.getLow(i);if(null==o||Number.isNaN(o)||null==s||Number.isNaN(s))continue;const a=r?o:t.getOpen(i),d=r?s:t.getClose(i);if(!r&&[a,d].some(t=>null==t||Number.isNaN(t)))continue;const g=d>=a,y={type:"candlestick",x:t.scales.x(e),openY:t.scales.y(a),closeY:t.scales.y(d),highY:t.scales.y(o),lowY:t.scales.y(s),bodyWidth:f,upColor:c,downColor:l,wickColor:u,wickWidth:h,isUp:g,datum:i};r&&(y.isRange=!0),n.push(y)}return n}(s,e);default:return[]}}resolveBoundsStyle(t,e){var i;const o=this.config.boundsStyle;return"function"==typeof o?o(e||{},t):o&&"object"==typeof o?o:{fill:this.resolveLineStyle(t,e).stroke||(null===(i=this.config.themeSemantic)||void 0===i?void 0:i.primary)||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(t,e){const i=this.config.decay;return i&&e>1?O(i,t,e):1}applyDecay(t,e){this.config.decay&&function(t,e,i){var o,r;const n=i.length;if(1>=n)return;const s=new Map;for(let t=0;i.length>t;t++)s.set(i[t],t);for(const i of e){if("line"===i.type){const e=Array.isArray(i.datum)?i.datum:[];if(2>e.length)continue;const o=Array(e.length);let r=!1;for(let i=0;e.length>i;i++){const a=s.get(e[i]);null!=a?(o[i]=O(t,a,n),1>o[i]&&(r=!0)):o[i]=1}r&&(i._decayOpacities=o);continue}if("area"===i.type){const e=Array.isArray(i.datum)?i.datum:[],o=i.topPath?i.topPath.length:e.length;if(2>o)continue;if(e.length===o){const r=Array(o);let a=!1;for(let i=0;e.length>i;i++){const o=s.get(e[i]);null!=o?(r[i]=O(t,o,n),1>r[i]&&(a=!0)):r[i]=1}a&&(i._decayOpacities=r)}else{let r=1;for(const i of e){const e=s.get(i);if(null!=e){const i=O(t,e,n);r>i&&(r=i)}}if(1>r){const t=Array(o);t.fill(r),i._decayOpacities=t}}continue}const e=s.get(i.datum);if(null==e)continue;const a=O(t,e,n);if("heatcell"===i.type)i.style={opacity:a};else if("candlestick"===i.type)i._decayOpacity=a;else{const t=null!==(r=null===(o=i.style)||void 0===o?void 0:o.opacity)&&void 0!==r?r:1;i.style=Object.assign(Object.assign({},i.style),{opacity:t*a})}}}(this.config.decay,t,e)}applyPulse(t,e){this.config.pulse&&this.timestampBuffer&&function(t,e,i,o){var r,n;const s="undefined"!=typeof performance?performance.now():Date.now(),a=null!==(r=t.color)&&void 0!==r?r:"rgba(255,255,255,0.6)",c=null!==(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 r=0;for(const i of e){const e=l.get(i);if(null==e)continue;const n=o.get(e);if(null==n)continue;const a=T(t,n,s);a>r&&(r=a)}r>0&&(i._pulseIntensity=r,i._pulseColor=a);continue}const e=l.get(i.datum);if(null==e)continue;const r=o.get(e);if(null==r)continue;const n=T(t,r,s);n>0&&(i._pulseIntensity=n,i._pulseColor=a,i._pulseGlowRadius=c)}}(this.config.pulse,t,e,this.timestampBuffer)}get hasActivePulses(){return!!this.config.pulse&&function(t,e){var i;if(!e||0===e.size)return!1;const o="undefined"!=typeof performance?performance.now():Date.now(),r=null!==(i=t.duration)&&void 0!==i?i:500,n=e.peek();return null!=n&&r>o-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,o){var r,n,s,a;i.clear(),o.clear();for(let c=0;e.length>c;c++){const l=e[c],u=$(t,l,c);u&&("point"===l.type?i.set(u,{x:l.x,y:l.y,r:l.r,opacity:l.style.opacity}):"rect"===l.type?i.set(u,{x:l.x,y:l.y,w:l.w,h:l.h,opacity:l.style.opacity}):"heatcell"===l.type?i.set(u,{x:l.x,y:l.y,w:l.w,h:l.h,opacity:null===(r=l.style)||void 0===r?void 0:r.opacity}):"candlestick"===l.type?i.set(u,{x:l.x,y:l.openY,w:l.bodyWidth,openY:l.openY,closeY:l.closeY,highY:l.highY,lowY:l.lowY,opacity:null===(n=l.style)||void 0===n?void 0:n.opacity}):"line"===l.type?o.set(u,{path:l.path.map(t=>[t[0],t[1]]),opacity:null===(s=l.style)||void 0===s?void 0:s.opacity}):"area"===l.type&&o.set(u,{topPath:l.topPath.map(t=>[t[0],t[1]]),bottomPath:l.bottomPath.map(t=>[t[0],t[1]]),opacity:null===(a=l.style)||void 0===a?void 0:a.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){var t,e,i;this.prevPositionMap.clear(),this.prevPathMap.clear();const o=null!==(e=null===(t=this.scales)||void 0===t?void 0:t.y(0))&&void 0!==e?e:0;for(let t=0;this.scene.length>t;t++){const e=this.scene[t],r=$(this.transitionContext,e,t);r&&("point"===e.type?this.prevPositionMap.set(r,{x:e.x,y:e.y,r:0,opacity:0}):"rect"===e.type?this.prevPositionMap.set(r,{x:e.x,y:o,w:e.w,h:0,opacity:null!==(i=e.style.opacity)&&void 0!==i?i:1}):"heatcell"===e.type?this.prevPositionMap.set(r,{x:e.x,y:e.y,w:e.w,h:e.h,opacity:0}):"line"===e.type?(e._introClipFraction=0,this.prevPathMap.set(r,{path:e.path.map(t=>[t[0],t[1]]),opacity:e.style.opacity})):"area"===e.type&&(e._introClipFraction=0,this.prevPathMap.set(r,{topPath:e.topPath.map(t=>[t[0],t[1]]),bottomPath:e.bottomPath.map(t=>[t[0],t[1]]),opacity:e.style.opacity})))}}startTransition(){if(!this.config.transition)return;const t=function(t,e,i,o,r){var n,s,a,c,l,u,h,d,f,g,y,p,m,x,v,b,k,A,w,S,_,P,j,M,O,T,L,E,D,C,R,N,B,W,F,Y,I,X,q,G,V;if(0===o.size&&0===r.size)return i;const H=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 Q=!1;const U=new Set,Z=new Set;for(let e=0;i.scene.length>e;e++){const n=i.scene[e],T=$(t,n,e);if(!T)continue;if(n._transitionKey=T,"line"===n.type||"area"===n.type){const t=r.get(T);if(t){if(Z.add(T),"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]];Q=!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]];Q=!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}),Q=!0;continue}const L=o.get(T);if("point"===n.type)if(L){U.add(T);const t={x:n.x,y:n.y,r:n.r};n._targetOpacity=null!==(u=n.style.opacity)&&void 0!==u?u:1,L.x===t.x&&L.y===t.y&&L.r===t.r||(n._targetX=t.x,n._targetY=t.y,n._targetR=t.r,n.x=L.x,n.y=L.y,n.r=null!==(h=L.r)&&void 0!==h?h:n.r,Q=!0)}else n._targetOpacity=null!==(d=n.style.opacity)&&void 0!==d?d:1,n.style=Object.assign(Object.assign({},n.style),{opacity:0}),Q=!0;else if("rect"===n.type)if(L){U.add(T);const t={x:n.x,y:n.y,w:n.w,h:n.h};n._targetOpacity=null!==(f=n.style.opacity)&&void 0!==f?f:1,L.x===t.x&&L.y===t.y&&L.w===t.w&&L.h===t.h||(n._targetX=t.x,n._targetY=t.y,n._targetW=t.w,n._targetH=t.h,n.x=L.x,n.y=L.y,n.w=null!==(g=L.w)&&void 0!==g?g:n.w,n.h=null!==(y=L.h)&&void 0!==y?y:n.h,Q=!0)}else n._targetOpacity=null!==(p=n.style.opacity)&&void 0!==p?p:1,n.style=Object.assign(Object.assign({},n.style),{opacity:0}),Q=!0;else if("heatcell"===n.type)if(L){U.add(T);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,L.x===t.x&&L.y===t.y&&L.w===t.w&&L.h===t.h||(n._targetX=t.x,n._targetY=t.y,n._targetW=t.w,n._targetH=t.h,n.x=L.x,n.y=L.y,n.w=null!==(v=L.w)&&void 0!==v?v:n.w,n.h=null!==(b=L.h)&&void 0!==b?b:n.h,Q=!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}),Q=!0;else if("candlestick"===n.type)if(L&&null!=L.openY){U.add(T);const t={x:n.x,openY:n.openY,closeY:n.closeY,highY:n.highY,lowY:n.lowY};n._targetOpacity=null!==(S=null===(w=n.style)||void 0===w?void 0:w.opacity)&&void 0!==S?S:1,(L.x!==t.x||L.openY!==t.openY||L.closeY!==t.closeY||L.highY!==t.highY||L.lowY!==t.lowY)&&(n._targetX=t.x,n._targetOpenY=t.openY,n._targetCloseY=t.closeY,n._targetHighY=t.highY,n._targetLowY=t.lowY,n.x=L.x,n.openY=L.openY,n.closeY=null!==(_=L.closeY)&&void 0!==_?_:n.closeY,n.highY=null!==(P=L.highY)&&void 0!==P?P:n.highY,n.lowY=null!==(j=L.lowY)&&void 0!==j?j:n.lowY,Q=!0)}else n._targetOpacity=null!==(O=null===(M=n.style)||void 0===M?void 0:M.opacity)&&void 0!==O?O:1,n.style=Object.assign(Object.assign({},n.style||{}),{opacity:0}),Q=!0}for(const[t,e]of r)if(!Z.has(t))if(t.startsWith("l:")&&e.path){const o={type:"line",path:e.path.map(t=>[t[0],t[1]]),group:t.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:null!==(T=e.opacity)&&void 0!==T?T:1},_targetOpacity:0,_transitionKey:t,datum:null};i.exitNodes.push(o),Q=!0}else if(t.startsWith("a:")&&e.topPath&&e.bottomPath){const o={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!==(L=e.opacity)&&void 0!==L?L:1},_targetOpacity:0,_transitionKey:t,datum:null};i.exitNodes.push(o),Q=!0}for(const[t,e]of o)if(!U.has(t)){if(t.startsWith("p:")){const o={type:"point",x:e.x,y:e.y,r:null!==(E=e.r)&&void 0!==E?E:3,style:{opacity:null!==(D=e.opacity)&&void 0!==D?D:1},datum:null,_targetOpacity:0,_transitionKey:t};i.exitNodes.push(o)}else if(t.startsWith("r:")){const o={type:"rect",x:e.x,y:e.y,w:null!==(C=e.w)&&void 0!==C?C:0,h:null!==(R=e.h)&&void 0!==R?R:0,style:{opacity:null!==(N=e.opacity)&&void 0!==N?N:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t};i.exitNodes.push(o)}else if(t.startsWith("h:")){const o={type:"heatcell",x:e.x,y:e.y,w:null!==(B=e.w)&&void 0!==B?B:0,h:null!==(W=e.h)&&void 0!==W?W:0,fill:"#999",datum:null,style:{opacity:null!==(F=e.opacity)&&void 0!==F?F:1},_targetOpacity:0,_transitionKey:t};i.exitNodes.push(o)}else if(t.startsWith("c:")){const o=null!==(Y=e.openY)&&void 0!==Y?Y:e.y,r={type:"candlestick",x:e.x,openY:o,closeY:null!==(I=e.closeY)&&void 0!==I?I:o,highY:null!==(X=e.highY)&&void 0!==X?X:o,lowY:null!==(q=e.lowY)&&void 0!==q?q:o,bodyWidth:null!==(G=e.w)&&void 0!==G?G:6,upColor:"#999",downColor:"#999",wickColor:"#999",wickWidth:1,isUp:!0,datum:null,style:{opacity:null!==(V=e.opacity)&&void 0!==V?V:1},_targetOpacity:0,_transitionKey:t};i.exitNodes.push(r)}Q=!0}return i.exitNodes.length>0&&(i.scene=[...i.scene,...i.exitNodes]),Q&&(i.activeTransition={startTime:z(),duration:H}),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,o){var r,n,s,a,c,l;if(!i.activeTransition)return!1;const u=E(t,i.activeTransition),h=L(u,"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?o.get(e):void 0,n=i?null!==(r=i.opacity)&&void 0!==r?r:1:0;t.style.opacity=D(n,t._targetOpacity,h)}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=D(i.x,t._targetX,h),t.y=D(i.y,t._targetY,h),void 0!==t._targetR&&void 0!==i.r&&(t.r=D(i.r,t._targetR,h))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0,r=i?null!==(n=i.opacity)&&void 0!==n?n:1:0;t.style.opacity=D(r,t._targetOpacity,h)}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=D(i.x,t._targetX,h),t.y=D(i.y,t._targetY,h),void 0!==i.w&&(t.w=D(i.w,t._targetW,h)),void 0!==i.h&&(t.h=D(i.h,t._targetH,h))}else if("heatcell"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0,r=i?null!==(s=i.opacity)&&void 0!==s?s:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:D(r,t._targetOpacity,h)})}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=D(i.x,t._targetX,h),t.y=D(i.y,t._targetY,h),void 0!==i.w&&(t.w=D(i.w,t._targetW,h)),void 0!==i.h&&(t.h=D(i.h,t._targetH,h))}else if("candlestick"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0,r=i?null!==(a=i.opacity)&&void 0!==a?a:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:D(r,t._targetOpacity,h)})}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=D(i.x,t._targetX,h),void 0!==i.openY&&(t.openY=D(i.openY,t._targetOpenY,h)),void 0!==i.closeY&&(t.closeY=D(i.closeY,t._targetCloseY,h)),void 0!==i.highY&&(t.highY=D(i.highY,t._targetHighY,h)),void 0!==i.lowY&&(t.lowY=D(i.lowY,t._targetLowY,h))}else if("line"===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:D(e,t._targetOpacity,h)})}void 0!==t._introClipFraction&&(t._introClipFraction=h);const e=t._prevPath,i=t._targetPath;if(e&&i&&e.length===t.path.length)for(let o=0;t.path.length>o;o++)t.path[o][0]=D(e[o][0],i[o][0],h),t.path[o][1]=D(e[o][1],i[o][1],h)}else if("area"===t.type){if(void 0!==t._targetOpacity){const e=null!==(l=t._startOpacity)&&void 0!==l?l:0;t.style=Object.assign(Object.assign({},t.style),{opacity:D(e,t._targetOpacity,h)})}void 0!==t._introClipFraction&&(t._introClipFraction=h);const e=t._prevTopPath,i=t._prevBottomPath,o=t._targetTopPath,r=t._targetBottomPath;if(e&&o&&e.length===t.topPath.length)for(let i=0;t.topPath.length>i;i++)t.topPath[i][0]=D(e[i][0],o[i][0],h),t.topPath[i][1]=D(e[i][1],o[i][1],h);if(i&&r&&i.length===t.bottomPath.length)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e][0]=D(i[e][0],r[e][0],h),t.bottomPath[e][1]=D(i[e][1],r[e][1],h)}}if(u>=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("candlestick"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,void 0!==t._targetOpenY&&(t.openY=t._targetOpenY),void 0!==t._targetCloseY&&(t.closeY=t._targetCloseY),void 0!==t._targetHighY&&(t.highY=t._targetHighY),void 0!==t._targetLowY&&(t.lowY=t._targetLowY),t._targetX=void 0,t._targetOpenY=void 0,t._targetCloseY=void 0,t._targetHighY=void 0,t._targetLowY=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,t._introClipFraction=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,t._introClipFraction=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){if(this._colorMapCache&&this._colorMapCache.version===this._ingestVersion)return this._colorMapCache.map;const e=new Set;for(const i of t){const t=this.getColor(i);t&&e.add(t)}const i=Array.from(e).sort(),o=i.join("\0");if(this._colorMapCache&&this._colorMapCache.key===o)return this._colorMapCache.version=this._ingestVersion,this._colorMapCache.map;const r=Array.isArray(this.config.colorScheme)?this.config.colorScheme:this.config.themeCategorical||P,n=new Map;for(let t=0;i.length>t;t++)n.set(i[t],r[t%r.length]);return this._colorMapCache={key:o,map:n,version:this._ingestVersion},n}resolveLineStyle(t,e){var i;const o=this.config.lineStyle;if("function"==typeof o){const i=o(e||{},t);if(i&&!i.stroke&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},i),{stroke:e})}return i}const r=null===(i=this.config.themeSemantic)||void 0===i?void 0:i.primary;return o&&"object"==typeof o?{stroke:o.stroke||r||"#007bff",strokeWidth:o.strokeWidth||2,strokeDasharray:o.strokeDasharray,fill:o.fill,fillOpacity:o.fillOpacity,opacity:o.opacity}:{stroke:this.resolveGroupColor(t)||r||"#007bff",strokeWidth:2}}resolveAreaStyle(t,e){var i,o;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}const n=null===(i=this.config.themeSemantic)||void 0===i?void 0:i.primary;if(r&&"object"==typeof r)return{fill:r.fill||r.stroke||n||"#4e79a7",fillOpacity:null!==(o=r.fillOpacity)&&void 0!==o?o:.7,stroke:r.stroke||n||"#4e79a7",strokeWidth:r.strokeWidth||2};const s=this.resolveGroupColor(t)||n||"#4e79a7";return{fill:s,fillOpacity:.7,stroke:s,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.length>0?this.config.colorScheme:null)||(Array.isArray(this.config.themeCategorical)&&this.config.themeCategorical.length>0?this.config.themeCategorical:null)||P;if(0===i.length)return null;const o=i[this._groupColorCounter%i.length];if(this._groupColorCounter++,this._groupColorMap.set(t,o),this._groupColorMap.size>q.GROUP_COLOR_MAP_CAP){const t=this._groupColorMap.keys().next().value;void 0!==t&&this._groupColorMap.delete(t)}return o}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]),i=this.getPointId,o=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)=>{o(t)&&e.add(i)}),this.timestampBuffer.clear();for(let i=0;t.length>i;i++)e.has(i)||this.timestampBuffer.push(t[i])}const r=this.buffer.remove(o);if(0===r.length)return r;for(const t of r)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++,r}update(t,e){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const i=new Set(Array.isArray(t)?t:[t]),o=this.getPointId,r=new Set;this.buffer.forEach((t,e)=>{i.has(o(t))&&r.add(e)});const n=this.buffer.update(t=>i.has(o(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)=>{r.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._hasRenderedOnce=!1,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._maxPointRadius=0,this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,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,o,r;const n=Object.assign({},this.config);("colorScheme"in t||"themeCategorical"in t||"colorAccessor"in t)&&(this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0),("barColors"in t||"colorScheme"in t)&&(this._barCategoryCache=null),("normalize"in t||"extentPadding"in t||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t||"groupAccessor"in t||"categoryAccessor"in t||"chartType"in t||"runtimeMode"in t)&&(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||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t){const c=a||!b(null!==(e=t.xAccessor)&&void 0!==e?e:t.timeAccessor,null!==(i=n.xAccessor)&&void 0!==i?i:n.timeAccessor),l=a||!b(null!==(o=t.yAccessor)&&void 0!==o?o:t.valueAccessor,null!==(r=n.yAccessor)&&void 0!==r?r:n.valueAccessor);(c||l)&&(["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?(this.getX=k(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=k(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=k(this.config.xAccessor,"x"),this.getY=k(this.config.yAccessor,"y")),s=!0)}if("groupAccessor"in t&&!b(t.groupAccessor,n.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?w(this.config.groupAccessor):void 0,s=!0),"categoryAccessor"in t&&!b(t.categoryAccessor,n.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?w(this.config.categoryAccessor):void 0,s=!0),"sizeAccessor"in t&&!b(t.sizeAccessor,n.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?k(this.config.sizeAccessor,"size"):void 0,s=!0),"colorAccessor"in t&&!b(t.colorAccessor,n.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?w(this.config.colorAccessor):void 0,s=!0),"y0Accessor"in t&&!b(t.y0Accessor,n.y0Accessor)&&(this.getY0=this.config.y0Accessor?k(this.config.y0Accessor,"y0"):void 0,s=!0),"pointIdAccessor"in t&&!b(t.pointIdAccessor,n.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?w(this.config.pointIdAccessor):void 0,s=!0),"candlestick"===this.config.chartType&&("openAccessor"in t&&!b(t.openAccessor,n.openAccessor)||"closeAccessor"in t&&!b(t.closeAccessor,n.closeAccessor)||"highAccessor"in t&&!b(t.highAccessor,n.highAccessor)||"lowAccessor"in t&&!b(t.lowAccessor,n.lowAccessor))){const t=null!=this.config.openAccessor,e=null!=this.config.closeAccessor;this.getOpen=t?k(this.config.openAccessor,"open"):void 0,this.getHigh=k(this.config.highAccessor,"high"),this.getLow=k(this.config.lowAccessor,"low"),this.getClose=e?k(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!e,s=!0}if(!s){const e=Object.keys(t).filter(t=>!t.endsWith("Accessor")&&"timeAccessor"!==t&&"valueAccessor"!==t);for(const i of e)if(t[i]!==n[i]){s=!0;break}}s&&(this.needsFullRebuild=!0)}}function G(t,e){var i=t.get(e);if(!i)throw Error("missing: "+e);return i}function V(t,e){var i,o=[],r=[],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,o,h=!1;for(r.push(t),n[t]=!0,e=0;a[t].length>e;e++)(o=a[t][e])===i?(u(i,r),h=!0):n[o]||(h=l(o));if(h)c(t);else for(e=0;a[t].length>e;e++){var d=s[o=a[t][e]];d||(s[o]=d={}),d[o]=!0}return r.pop(),h}function u(t,e){var i=[].concat(e).concat(t);o.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,o=function(t){for(var e=t.length,i=Array(e),o=Array(e),r=Array(e),n=Array(e),s=Array(e),a=Array(e),c=0;e>c;++c)i[c]=-1,o[c]=0,r[c]=!1,n[c]=0,s[c]=-1,a[c]=[];var l,u=0,h=[],d=[];function f(e){var c=[e],l=[e];for(i[e]=o[e]=u,r[e]=!0,u+=1;l.length>0;){var f=t[e=l[l.length-1]];if(f.length>n[e]){for(var g=n[e];f.length>g;++g){var y=f[g];if(0>i[y]){i[y]=o[y]=u,r[y]=!0,u+=1,c.push(y),l.push(y);break}r[y]&&(o[e]=0|Math.min(o[e],o[y])),0>s[y]||a[e].push(s[y])}n[e]=g}else{if(o[e]===i[e]){var p=[],m=[],x=0;for(g=c.length-1;g>=0;--g){var v=c[g];if(r[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];d.push(b)}l.pop()}}}for(c=0;e>c;++c)0>i[c]&&f(c);for(c=0;d.length>c;c++){var g=d[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]);d[c]=l}}return{components:h,adjacencyList:d}}(t),r=o.components.filter(function(t){return t.length>1}),n=1/0,s=0;r.length>s;s++)for(var a=0;r[s].length>a;a++)n>r[s][a]&&(n=r[s][a],i=s);var c=r[i];if(!c)return!1;var l=t.map(function(t,e){return-1===c.indexOf(e)?[]:t.filter(function(t){return-1!==c.indexOf(t)})});return{leastVertex:n,adjList:l}}i=0;for(var d=t.length;d>i;){var f=h(i);if(i=f.leastVertex,a=f.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(i),i+=1}else i=d}return o}function H(t){return t.y0-t.y1>0?"up":"down"}function Q(t,e){return e(t.source)==e(t.target)}function U(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 Z(t){return t.target.x0-t.source.x1}function K(t,e){var i=tt(t),o=Z(e)/Math.tan(i);return"up"==H(t)?t.y1-o:t.y1+o}function J(t,e){var i=tt(t),o=Z(e)/Math.tan(i);return"up"==H(t)?t.y1+o:t.y1-o}function tt(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function et(t,e){return e(t)}function it(t){return rt(t.source)}function ot(t){return rt(t.target)}function rt(t){return(t.y0+t.y1)/2}function nt(t){return t.virtual?0:t.value}function st(t,e){var i=0;t.sourceLinks.forEach(function(t){i=t.circular&&!Q(t,e)?i+1:i});var o=0;return t.targetLinks.forEach(function(t){o=t.circular&&!Q(t,e)?o+1:o}),i+o}function at(t){return t.target.depth}function ct(t,e){return t.sourceLinks.length?t.depth:e-1}function lt(t,e){return t.y0-e.y0}function ut(t,e){return e.y0-t.y0}function ht(t,e){return t.y1-e.y1}function dt(t,e){return e.y1-t.y1}function ft(t,e){return yt(t.source,e.source)||t.index-e.index}function gt(t,e){return yt(t.target,e.target)||t.index-e.index}function yt(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function pt(t,e){return mt(t)==mt(e)?"bottom"==t.circularLinkType?ut(t,e):lt(t,e):mt(e)-mt(t)}function mt(t){return t.target.column-t.source.column}function xt(t,e){return vt(t)==vt(e)}function vt(t){return t.y0-t.y1>0?"up":"down"}function bt(t,e,i,o,r){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=n.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}),kt(s.links.filter(function(t){return"top"==t.circularLinkType}),e,i),kt(s.links.filter(function(t){return"bottom"==t.circularLinkType}),e,i),s.links.forEach(function(t){if(t.circular){if(t.circularPathData.arcRadius=t._circularWidth+o,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,Q(t,e)&&U(t))t.circularPathData.rightSmallArcRadius=o+t._circularWidth/2,t.circularPathData.rightLargeArcRadius=o+t._circularWidth/2,t.circularPathData.leftSmallArcRadius=o+t._circularWidth/2,t.circularPathData.leftLargeArcRadius=o+t._circularWidth/2,"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=t.source.y1+r+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-r-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius);else{var n=t.source.column,a=t.circularLinkType,l=s.links.filter(function(t){return t.source.column==n&&t.circularLinkType==a});l.sort("bottom"==t.circularLinkType?ut:lt);var u=0;l.forEach(function(e,r){e.circularLinkID==t.circularLinkID&&(t.circularPathData.rightSmallArcRadius=o+t._circularWidth/2+u,t.circularPathData.rightLargeArcRadius=o+t._circularWidth/2+r*i+u),u+=e._circularWidth||e.width}),n=t.target.column,(l=s.links.filter(function(t){return t.target.column==n&&t.circularLinkType==a})).sort("bottom"==t.circularLinkType?dt:ht),u=0,l.forEach(function(e,r){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=o+t._circularWidth/2+u,t.circularPathData.leftLargeArcRadius=o+t._circularWidth/2+r*i+u),u+=e._circularWidth||e.width}),"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=Math.max(s.y1,t.source.y1,t.target.y1)+r+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-r-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,o=t.target.x0,r=t.y1,n=(e+o)/2;return"M"+e+","+i+"C"+n+","+i+" "+n+","+r+" "+o+","+r}(t)}),s}function kt(t,e,i){t.sort(pt);var o=t.filter(function(t){return!t._circularStub});return t.forEach(function(t,r){var n=0;if(t._circularStub)t.circularPathData.verticalBuffer=0;else if(Q(t,e)&&U(t))t.circularPathData.verticalBuffer=n+t._circularWidth/2;else{for(var s=0;o.length>s;s++){var a=o[s];if(a!==t&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&At(t,a)){var c=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+i;n=c>n?c:n}}t.circularPathData.verticalBuffer=n+t._circularWidth/2}}),t}function At(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}function wt(t){return function(){return t}}function St(t){return t.index}function _t(t){return t.nodes}function Pt(t){return t.links}function jt(t,e,i){var o=n.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});o.forEach(function(r,n){var s=r.length;if(e)r.sort(e);else if(n>0){var a=new Map;r.forEach(function(t,e){var i,o,r,n=(o=0,r=0,(i=t).targetLinks.forEach(function(t){if(!t.circular){var e=t.value||1;r+=rt(t.source)*e,o+=e}}),i.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;r+=rt(t.target)*e,o+=e}}),o>0?r/o:NaN);a.set(t,{bc:n,idx:e})}),r.sort(function(t,e){var i=a.get(t),o=a.get(e),r=i.bc,n=o.bc;if(t.circularLinkType!==e.circularLinkType){if("top"==t.circularLinkType&&"bottom"==e.circularLinkType)return-1;if("bottom"==t.circularLinkType&&"top"==e.circularLinkType)return 1;if("top"==t.circularLinkType)return-1;if("top"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return-1}return isNaN(r)||isNaN(n)?isNaN(r)?isNaN(n)?i.idx-o.idx:1:-1:r-n})}else r.sort(function(t,e){return t.circularLinkType==e.circularLinkType?st(e,i)-st(t,i):"top"==t.circularLinkType&&"bottom"==e.circularLinkType||"top"==t.circularLinkType&&0==e.partOfCycle||0==t.partOfCycle&&"bottom"==e.circularLinkType?-1:0});r.forEach(function(e,r){e.depth==o.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==st(e,i)?(e.y0=t.y1/2+r,e.y1=e.y0+e.value*t.ky):"top"==e.circularLinkType?(e.y0=t.y0+r,e.y1=e.y0+e.value*t.ky):(e.y0=t.y1-e.value*t.ky-r,e.y1=e.y0+e.value*t.ky):0==t.y0||0==t.y1?(e.y0=(t.y1-t.y0)/s*r,e.y1=e.y0+e.value*t.ky):(e.y0=(t.y1-t.y0)/2-s/2+r,e.y1=e.y0+e.value*t.ky)})})}function Mt(t,e,i,o,r,s){var a=n.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});h();for(var c=1,l=s;l>0;--l)u(c*=.99,i),h();function u(e,i){var o=a.length;a.forEach(function(r){var s=r.length,a=r[0].depth;r.forEach(function(r){var c;if(r.sourceLinks.length||r.targetLinks.length)if(r.partOfCycle&&st(r,i)>0){var l=n.mean(r.sourceLinks,ot),u=n.mean(r.targetLinks,it),h=l&&u?(l+u)/2:l||u;if(h){var d=(h-rt(r))*e*.3;r.y0+=d,r.y1+=d}}else if(0==a&&1==s)r.y0=t.y1/2-(c=r.y1-r.y0)/2,r.y1=t.y1/2+c/2;else if(a==o-1&&1==s)r.y0=t.y1/2-(c=r.y1-r.y0)/2,r.y1=t.y1/2+c/2;else if(1==r.targetLinks.length&&1==r.targetLinks[0].source.sourceLinks.length)c=r.y1-r.y0,r.y0=r.targetLinks[0].source.y0,r.y1=r.y0+c;else{var f=n.mean(r.sourceLinks,ot),g=n.mean(r.targetLinks,it),y=((f&&g?(f+g)/2:f||g)-rt(r))*e;r.y0+=y,r.y1+=y}})})}function h(){a.forEach(function(i){var n,s,a,c=t.y0,l=i.length;for(i.sort(e||yt),a=0;l>a;++a)(s=c-(n=i[a]).y0)>0&&(n.y0+=s,n.y1+=s),c=n.y1+o;if((s=c-o-t.y1)>0)for(c=n.y0-=s,n.y1-=s,a=l-2;a>=0;--a)(s=(n=i[a]).y1+r-c)>0&&(n.y0-=s,n.y1-=s),c=n.y0})}}function Ot(t){t.nodes.forEach(function(t){t.sourceLinks.sort(gt),t.targetLinks.sort(ft)}),t.nodes.forEach(function(t){var e=t.y0,i=e,o=t.y1,r=o;t.sourceLinks.forEach(function(t){t.circular?(t.y0=o-t.width/2,o-=t.width):(t.y0=e+t.width/2,e+=t.width)}),t.targetLinks.forEach(function(t){t.circular?(t.y1=r-t.width/2,r-=t.width):(t.y1=i+t.width/2,i+=t.width)})})}function Tt(){var t=0,e=0,i=1,o=1,r=24,s=8,a=null,c=St,l=ct,u=void 0,h=32,d=2,f=_t,g=Pt;function y(){var y={nodes:f.apply(null,arguments),links:g.apply(null,arguments)};return function(f){f.x0=t,f.y0=e,f.x1=i,f.y1=o,f.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 n.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 o=t.source,r=t.target;"object"!=typeof o&&(o=t.source=G(i,o)),"object"!=typeof r&&(r=t.target=G(i,r)),o.sourceLinks.push(t),r.targetLinks.push(t)})}(f,c),function(t,e){var i=0;if(null==e){for(var o=[],r=0;t.links.length>r;r++){var n=t.links[r],s=n.source.index,a=n.target.index;o[s]||(o[s]=[]),o[a]||(o[a]=[]),-1===o[s].indexOf(a)&&o[s].push(a)}var c=V(o);c.sort(function(t,e){return t.length-e.length});var l={};for(r=0;c.length>r;r++){var u=c[r].slice(-2);l[u[0]]||(l[u[0]]={}),l[u[0]][u[1]]=!0}t.links.forEach(function(t){var e=t.target.index,o=t.source.index;e===o||l[o]&&l[o][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++)})}(f,u),function(t,e){var i=0,o=0;t.links.forEach(function(r){r.circular&&(r.circularLinkType=r.source.circularLinkType||r.target.circularLinkType?r.source.circularLinkType?r.source.circularLinkType:r.target.circularLinkType:o>i?"top":"bottom","top"==r.circularLinkType?i++:o++,t.nodes.forEach(function(t){et(t,e)!=et(r.source,e)&&et(t,e)!=et(r.target,e)||(t.circularLinkType=r.circularLinkType)}))}),t.links.forEach(function(t){t.circular&&(t.source.circularLinkType==t.target.circularLinkType&&(t.circularLinkType=t.source.circularLinkType),Q(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(f,c),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max(n.sum(t.sourceLinks,nt),n.sum(t.targetLinks,nt)),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)})})}(f),function(t,e,i){var o,r,n;if(null!=e){t.nodes.sort(function(t,i){return e(t)<e(i)?-1:1});var s=0,a=e(t.nodes[0]);t.nodes.forEach(function(t){s=e(t)==a?s:s+1,a=e(t)==a?a:e(t),t.column=s})}for(o=t.nodes,r=[],n=0;o.length;++n,o=r,r=[])o.forEach(function(t){t.depth=n,t.sourceLinks.forEach(function(t){0>r.indexOf(t.target)&&!t.circular&&r.push(t.target)})});for(o=t.nodes,r=[],n=0;o.length;++n,o=r,r=[])o.forEach(function(t){t.height=n,t.targetLinks.forEach(function(t){0>r.indexOf(t.source)&&!t.circular&&r.push(t.source)})});t.nodes.forEach(function(t){t.column=null==e?i(t,n):t.column})}(f,u,l);var g=s;if(null!==a){var y=n.groups(f.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),p=n.max(y,function(t){return t.length});p>1&&(g=Math.max(1,(o-e)*a/(p-1)))}(function(t,e,i){var o=n.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 r=n.min(o,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/n.sum(e,function(t){return t.value})});t.ky=r,t.links.forEach(function(e){e.width=e.value*t.ky});var s=n.max(t.nodes,function(t){return t.column});t.nodes.forEach(s>0?function(e){e.x0=t.x0+e.column*((t.x1-t.x0-i)/s),e.x1=e.x0+i}:function(e){e.x0=t.x0,e.x1=e.x0+i})})(f,g,r),jt(f,u,c),Mt(f,u,c,g,g,h),Ot(f),bt(f,c,d,10,8),jt(f,u,c),Mt(f,u,c,g,g,h),Ot(f),bt(f,c,d,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 o=i.links.filter(function(i){return et(i.source,e)==et(t,e)}),r=o.length;r>1&&o.sort(function(t,e){if(!t.circular&&!e.circular){if(t.target.column==e.target.column)return t.y1-e.y1;if(!xt(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var i=K(e,t);return t.y1-i}if(e.target.column>t.target.column)return K(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;o.forEach(function(t){t.y0=n+t.width/2,n+=t.width}),o.forEach(function(e,i){if("bottom"==e.circularLinkType){for(var n=i+1,s=0;r>n;n++)s+=o[n].width;e.y0=t.y1-s-e.width/2}})})}(f,c),function(t,e){let i=t;i.nodes.forEach(function(t){var o=i.links.filter(function(i){return et(i.target,e)==et(t,e)}),r=o.length;r>1&&o.sort(function(t,e){if(!t.circular&&!e.circular){if(t.source.column==e.source.column)return t.y0-e.y0;if(!xt(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var i=J(e,t);return t.y0-i}if(e.source.column>t.source.column)return J(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;o.forEach(function(t){t.y1=n+t.width/2,n+=t.width}),o.forEach(function(e,i){if("bottom"==e.circularLinkType){for(var n=i+1,s=0;r>n;n++)s+=o[n].width;e.y1=t.y1-s-e.width/2}})})}(f,c),function(t){var e=t.nodes,i=t.links,o=!1,r=!1;if(i.forEach(function(t){"top"==t.circularLinkType?o=!0:"bottom"==t.circularLinkType&&(r=!0)}),0==o||0==r){var s=n.min(e,function(t){return t.y0}),a=n.max(e,function(t){return t.y1}),c=(t.y1-t.y0)/(a-s);function l(e){return(e-s)/(a-s)*(t.y1-t.y0)+t.y0}1>c?(e.forEach(function(t){t.y0=l(t.y0),t.y1=l(t.y1)}),i.forEach(function(t){t.y0=l(t.y0),t.y1=l(t.y1),t.width=t.width*c})):e.forEach(function(t){var e=t.y1-t.y0,i=l(t.y0)-t.y0;t.y0=l(t.y0),t.y1=t.y0+e,t.sourceLinks.forEach(function(t){t.y0=t.y0+i}),t.targetLinks.forEach(function(t){t.y1=t.y1+i})})}}(f),bt(f,c,d,10,8)}(y),y}return y.update=function(t){return Ot(t),bt(t,c,d,10,8),t},y.nodeWidth=function(t){return arguments.length?(r=+t,y):r},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?(f="function"==typeof t?t:wt(t),y):f},y.links=function(t){return arguments.length?(g="function"==typeof t?t:wt(t),y):g},y.nodeId=function(t){return arguments.length?(c="function"==typeof t?t:wt(t),y):c},y.nodeAlign=function(t){return arguments.length?(l="function"==typeof t?t:wt(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?(d=+t,y):d},y.extent=function(r){return arguments.length?(t=+r[0][0],e=+r[0][1],i=+r[1][0],o=+r[1][1],y):[[t,e],[i,o]]},y.size=function(r){return arguments.length?(t=e=0,i=+r[0],o=+r[1],y):[i-t,o-e]},y}q.GROUP_COLOR_MAP_CAP=1e3,q.QUADTREE_THRESHOLD=500;const Lt=t=>{let e,i,o,r,n,a,c,l,u;return"down"===t.direction?(e=t.y0-t.sankeyWidth/2,i=t.y1-t.sankeyWidth/2,o=t.y1+t.sankeyWidth/2,r=t.y0+t.sankeyWidth/2,n=t.source.x1,a=t.target.x0,c=s.interpolateNumber(n,a),l=c(.5),u=c(.5),`M${e},${n}C${e},${l} ${i},${u} ${i},${a}L${o},${a}C${o},${u} ${r},${l} ${r},${n}Z`):(e=t.source.x1,i=t.target.x0,c=s.interpolateNumber(e,i),o=c(.5),r=c(.5),n=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},${n}C${o},${n} ${r},${a} ${i},${a}L${i},${l}C${r},${l} ${o},${u} ${e},${u}Z`)};function Et(t){var e;const i=t.sankeyWidth/2,o=(null!==(e=t._circularWidth)&&void 0!==e?e:t.sankeyWidth)/2,r=t.circularPathData;if(!r)return null;if("down"===t.direction)return null;if(t._circularStub){const e=r.sourceX,o=r.sourceY,n=r.targetX,s=r.targetY;if("object"!=typeof t.source||!t.source||"object"!=typeof t.target||!t.target)return null;const a=Math.max(15,Math.min(40,.33*(r.rightFullExtent-e))),c=Math.max(15,Math.min(40,.33*(n-r.leftFullExtent)));return`M${e},${o-i}L${e+a},${o-i}L${e+a},${o+i}L${e},${o+i}ZM${n},${s-i}L${n-c},${s-i}L${n-c},${s+i}L${n},${s+i}Z`}const n=r.sourceX,s=r.sourceY,a=r.targetX,c=r.targetY,l=r.rightFullExtent,u=r.leftFullExtent,h=r.verticalFullExtent,d="bottom"===t.circularLinkType?1:-1,f=Math.max(4,Math.min(o,15));return`M${n},${s-d*i}L${l},${s-d*i}L${l+o},${s-d*i+d*f}L${l+o},${h+d*o-d*f}L${l+o-f},${h+d*o}L${u-o+f},${h+d*o}L${u-o},${h+d*o-d*f}L${u-o},${c-d*i+d*f}L${u-o+f},${c-d*i}L${a},${c-d*i}L${a},${c+d*i}L${u+o},${c+d*i}L${u+o},${h-d*o}L${l-o},${h-d*o}L${l-o},${s+d*i}L${n},${s+d*i}Z`}const Dt=new Set,zt=new WeakMap;function $t(t,e){if("production"===process.env.NODE_ENV)return t;if(!t||!t.data||"object"!=typeof t.data)return t;let i=zt.get(t);if(i){const t=i.get(e);if(t)return t}else i=new Map,zt.set(t,i);const o=new Proxy(t,{get(t,i,o){if("string"==typeof i&&!(i in t)&&t.data&&i in t.data){const t=`${e}:${i}`;Dt.has(t)||(Dt.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,o)}});return i.set(e,o),o}const Ct={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(at))-1:0},justify:ct};function Rt(t){return"string"==typeof t?t:t.id}const Nt={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,i,o){var r,n,s,a,c,l,u;if(0===t.length)return;const h="vertical"===i.orientation?"down":"right",d=i.nodeAlign||"justify",f=null!==(r=i.nodeWidth)&&void 0!==r?r:15,g=null!==(n=i.nodePaddingRatio)&&void 0!==n?n:.05,y=null!==(s=i.iterations)&&void 0!==s?s:100,p=t.map(t=>Object.assign({},t)),m=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id,value:Math.sqrt(Math.max(1,t.value||1))}));let x;x="down"===h?[[0,0],[o[1],o[0]]]:[[0,0],[o[0],o[1]]];const v=Tt().extent(x).links(m).nodes(p).nodeAlign(Ct[d]||ct).nodeId(t=>t.id).nodeWidth(f).iterations(y);v.nodePaddingRatio&&v.nodePaddingRatio(g),v();{let t=1/0,e=-1/0,i=1/0,r=-1/0;for(const o of p)t>o.x0&&(t=o.x0),o.x1>e&&(e=o.x1),i>o.y0&&(i=o.y0),o.y1>r&&(r=o.y1);for(const o of m){if(!o.circular||!o.circularPathData)continue;const n=o.circularPathData,s=(null!==(c=null!==(a=o._circularWidth)&&void 0!==a?a:o.width)&&void 0!==c?c:0)/2;t>n.leftFullExtent-s&&(t=n.leftFullExtent-s),n.rightFullExtent+s>e&&(e=n.rightFullExtent+s),i>n.verticalFullExtent-s&&(i=n.verticalFullExtent-s),n.verticalFullExtent+s>r&&(r=n.verticalFullExtent+s)}const n=e-t,s=r-i,u=o[0],h=o[1];if(n>0&&s>0&&(0>t||0>i||e>u||r>h)){const e=Math.min(u/n,h/s),o=-t*e+(u-n*e)/2,r=-i*e+(h-s*e)/2;for(const t of p)t.x0=t.x0*e+o,t.x1=t.x1*e+o,t.y0=t.y0*e+r,t.y1=t.y1*e+r;for(const t of m)if(t.y0=t.y0*e+r,t.y1=t.y1*e+r,t.width=(null!==(l=t.width)&&void 0!==l?l:0)*e,t._circularWidth&&(t._circularWidth*=e),t.circular&&t.circularPathData){const i=t.circularPathData;i.sourceX=i.sourceX*e+o,i.targetX=i.targetX*e+o,i.sourceY=i.sourceY*e+r,i.targetY=i.targetY*e+r,i.rightFullExtent=i.rightFullExtent*e+o,i.leftFullExtent=i.leftFullExtent*e+o,i.verticalFullExtent=i.verticalFullExtent*e+r,i.rightInnerExtent=i.rightInnerExtent*e+o,i.leftInnerExtent=i.leftInnerExtent*e+o,i.verticalRightInnerExtent=i.verticalRightInnerExtent*e+r,i.verticalLeftInnerExtent=i.verticalLeftInnerExtent*e+r,i.rightSmallArcRadius*=e,i.rightLargeArcRadius*=e,i.leftSmallArcRadius*=e,i.leftLargeArcRadius*=e,i.sourceWidth*=e,i.rightNodeBuffer*=e,i.leftNodeBuffer*=e,i.arcRadius*=e}}}const b=new Map;for(const e of t)b.set(e.id,e);for(const t of p){const e=b.get(t.id);e&&(e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.value=t.value,e.depth=t.depth,e.sourceLinks=t.sourceLinks,e.targetLinks=t.targetLinks,e.width=t.x1-t.x0,e.height=t.y1-t.y0,e.x=t.x0+(t.x1-t.x0)/2,e.y=t.y0+(t.y1-t.y0)/2)}const k=new Map;for(const t of e)k.set(t._edgeKey?t._edgeKey:`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const t of m){const e=Rt(t.source),i=Rt(t.target),o=k.get(t._edgeKey?t._edgeKey:`${e}\0${i}`);if(o){o.y0=t.y0,o.y1=t.y1,o.sankeyWidth=null!==(u=t.width)&&void 0!==u?u:0,o.circular=!!t.circular,o.circularPathData=t.circularPathData,o._circularWidth=t._circularWidth,o._circularStub=t._circularStub,o.path=t.path,o.circularLinkType=t.circularLinkType,o.direction=h;const r=b.get(e),n=b.get(i);r&&(o.source=r),n&&(o.target=n)}}},buildScene(t,e,i,o){var n,s,a,c,l,u;const h="vertical"===i.orientation?"down":"right",d=i.nodeStyle,f=i.edgeStyle,g=null!==(n=i.edgeOpacity)&&void 0!==n?n:.5,y=i.edgeColorBy||"source",p=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:r.schemeCategory10,m=new Map;t.forEach((t,e)=>{m.set(t.id,p[e%p.length])});const x=[],v=[],b=[],k=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 o=d?d($t(e,"nodeStyle")):{},r={fill:o.fill||m.get(e.id)||"#4d430c",stroke:o.stroke,strokeWidth:o.strokeWidth,opacity:o.opacity};k.set(e.id,("string"==typeof r.fill?r.fill:null)||m.get(e.id)||"#4d430c"),x.push("down"===h?{type:"rect",x:e.y0,y:e.x0,w:i,h:t,style:r,datum:e,id:e.id,label:e.id}:{type:"rect",x:e.x0,y:e.y0,w:t,h:i,style:r,datum:e,id:e.id,label:e.id})}const A=[...e].sort((t,e)=>(e.sankeyWidth||0)-(t.sankeyWidth||0));for(const t of A){if(!t.sankeyWidth||0>=t.sankeyWidth)continue;const e="object"==typeof t.source?t.source:null,o="object"==typeof t.target?t.target:null;if(!e||!o)continue;let r=(null===(s=i.themeSemantic)||void 0===s?void 0:s.border)||(null===(a=i.themeSemantic)||void 0===a?void 0:a.secondary)||"#999";r="function"==typeof y?y(t)||r:"target"===y?k.get(o.id)||m.get(o.id)||r:k.get(e.id)||m.get(e.id)||r;const n=f?f($t(t,"edgeStyle")):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,i=t.sankeyWidth/2,o=Math.max(15,Math.min(40,.33*(e.rightFullExtent-e.sourceX))),s=Math.max(15,Math.min(40,.33*(e.targetX-e.leftFullExtent))),a=n.fill||r;v.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-i}L${e.sourceX+o},${e.sourceY-i}L${e.sourceX+o},${e.sourceY+i}L${e.sourceX},${e.sourceY+i}Z`,style:{fill:a,fillOpacity:null!==(c=n.fillOpacity)&&void 0!==c?c:g,stroke:"none",opacity:n.opacity},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+o}}),v.push({type:"bezier",pathD:`M${e.targetX},${e.targetY-i}L${e.targetX-s},${e.targetY-i}L${e.targetX-s},${e.targetY+i}L${e.targetX},${e.targetY+i}Z`,style:{fill:a,fillOpacity:null!==(l=n.fillOpacity)&&void 0!==l?l:g,stroke:"none",opacity:n.opacity},datum:t,_gradient:{direction:"left",from:0,to:1,x0:e.targetX-s,x1:e.targetX}});continue}let h;if(h=t.circular&&t.circularPathData?Et(t):Lt(t),!h)continue;const d={fill:n.fill||r,fillOpacity:null!==(u=n.fillOpacity)&&void 0!==u?u:g,stroke:n.stroke||"none",strokeWidth:n.strokeWidth,opacity:n.opacity};v.push({type:"bezier",pathD:h,bezierCache:t.bezier,style:d,datum:t})}if(!1!==i.showLabels){const e=(w=i.nodeLabel)?"function"==typeof w?w:t=>t[w]||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 s,a,c;"down"===h?(s=i.y0+(i.y1-i.y0)/2,a=i.x1+14,c="start"):(o[0]/2>i.x0+t/2?(s=i.x0-6,c="end"):(s=i.x1+6,c="start"),a=i.y0+r/2),b.push({x:s,y:a,text:n+"",anchor:"down"===h?"middle":c,baseline:"middle",fontSize:11})}}var w;return{sceneNodes:x,sceneEdges:v,labels:b}}},Bt={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,i,o){var r,n;if(0===t.length)return;const s=null!==(r=i.forceStrength)&&void 0!==r?r:.1,c=o[0]/2,l=o[1]/2,u=i.__previousPositions;let h=0;const d=[];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++):d.push(e)}const f=h>0&&.3>=(t.length>0?d.length/t.length:1);if(f){const i=new Map;for(const e of t)i.set(e.id,e);for(const t of d){const o=Wt(t.id,e,i);if(o.length>0){let e=0,i=0;for(const t of o)e+=t.x,i+=t.y;const r=Ft(t.id),n=r%360*(Math.PI/180),s=10+r%20;t.x=e/o.length+s*Math.cos(n),t.y=i/o.length+s*Math.sin(n)}else{const e=Ft(t.id),i=e%360*(Math.PI/180),o=15+e%30;t.x=c+o*Math.cos(i),t.y=l+o*Math.sin(i)}}}else{const e=2.399963229728653;for(let i=0;t.length>i;i++){const o=t[i];if(null==o.x||null==o.y||0===o.x&&0===o.y){const t=10*Math.sqrt(i+.5),r=i*e;o.x=c+t*Math.cos(r),o.y=l+t*Math.sin(r)}}}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:f?40:g,p=Yt(i.nodeSize,i.nodeSizeRange,t),m=t=>p(t);if(y>0){const i=a.forceLink().strength(t=>{const e=t.weight;return Math.min(2.5,e?e*s:s)}).id(t=>t.id),o=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(o.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}));o.force("link",i),o.force("link").links(t)}f?o.alpha(.3):.1>o.alpha()&&o.alpha(1),o.stop();for(let t=0;y>t;++t)o.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(o[0]-t,e.x)),e.y=Math.max(t,Math.min(o[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,s,a,c,l,u,h;const d=i.nodeStyle,f=i.edgeStyle,g=Yt(i.nodeSize,i.nodeSizeRange,t),y=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:r.schemeCategory10,p=new Map;t.forEach((t,e)=>{p.set(t.id,y[e%y.length])});const m=[],x=[],v=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=g($t(e,"nodeSize")),o=d?d($t(e,"nodeStyle")):{},r={fill:o.fill||p.get(e.id)||(null===(n=i.themeSemantic)||void 0===n?void 0:n.primary)||"#007bff",stroke:o.stroke||(null===(s=i.themeSemantic)||void 0===s?void 0:s.surface)||"#fff",strokeWidth:null!==(a=o.strokeWidth)&&void 0!==a?a:2,opacity:o.opacity};m.push({type:"circle",cx:e.x,cy:e.y,r:t,style:r,datum:e,id:e.id,label:e.id})}const b=new Map;for(const e of t)b.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:b.get(t.source),o="object"==typeof t.target?t.target:b.get(t.target);if(!e||!o)continue;if(null==e.x||null==e.y)continue;if(null==o.x||null==o.y)continue;const r=f?f($t(t,"edgeStyle")):{},n={stroke:r.stroke||(null===(c=i.themeSemantic)||void 0===c?void 0:c.border)||(null===(l=i.themeSemantic)||void 0===l?void 0:l.secondary)||"#999",strokeWidth:null!==(u=r.strokeWidth)&&void 0!==u?u:1,opacity:null!==(h=r.opacity)&&void 0!==h?h:.6};x.push({type:"line",x1:e.x,y1:e.y,x2:o.x,y2:o.y,style:n,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){if(null==i.x||null==i.y)continue;const t=e?e(i):i.id;if(!t)continue;const o=g($t(i,"nodeSize"));v.push({x:i.x,y:i.y-o-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var k;return{sceneNodes:m,sceneEdges:x,labels:v}}};function Wt(t,e,i){const o=[];for(const r of e){const e="string"==typeof r.source?r.source:r.source.id,n="string"==typeof r.target?r.target:r.target.id;let s=null;if(e===t?s=n:n===t&&(s=e),s){const t=i.get(s);!t||0===t.x&&0===t.y||o.push({x:t.x,y:t.y})}}return o}function Ft(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 Yt(t,e,o){var r,s;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const a=e||[5,20],c=o.map(e=>{var i;return null===(i=e.data)||void 0===i?void 0:i[t]}).filter(t=>null!=t&&"number"==typeof t);if(0===c.length)return()=>a[0];const l=null!==(r=n.min(c))&&void 0!==r?r:0,u=null!==(s=n.max(c))&&void 0!==s?s:1;if(l===u)return()=>(a[0]+a[1])/2;const h=i.scaleLinear().domain([l,u]).range(a).clamp(!0);return e=>{var i;const o=null===(i=e.data)||void 0===i?void 0:i[t];return null==o||"number"!=typeof o?a[0]:h(o)}}const It=r.schemeCategory10,Xt={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,i,o){if(0===t.length)return;const{padAngle:r=.01,groupWidth:n=20,sortGroups:s}=i,a=Math.min(o[0],o[1])/2,u=a-n,h=o[0]/2,d=o[1]/2,f=(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),o=y.get(e);if(void 0===i||void 0===o)continue;const r=f(t);m[i][o]=r}const x=c.chord().padAngle(r);s&&x.sortGroups(s);const v=x(m),b=v.groups,k=l.arc().innerRadius(u).outerRadius(a);for(const e of b){const i=t[e.index],o=k.centroid(e);i.x=o[0]+h,i.y=o[1]+d,i.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,i=A.get("string"==typeof t.source?t.source:t.source.id),o=A.get(e);i&&(t.source=i),o&&(t.target=o)}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 i=t[e.source.index].id,o=t[e.target.index].id,r=w.get(`${i}\0${o}`)||w.get(`${o}\0${i}`);r&&(r.chordData=e)}},buildScene(t,e,i,o){var r,n,s,a;const{groupWidth:l=20,edgeOpacity:u=.5}=i,h=Math.min(o[0],o[1])/2,d=h-l,f=o[0]/2,g=o[1]/2,y=i.nodeStyle,p=i.edgeStyle,m=i.edgeColorBy||"source",x=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:It,v=new Map;t.forEach((t,e)=>{v.set(t.id,x[e%x.length])});const b=c.ribbon().radius(d),k=[],A=[],w=[];for(let e=0;t.length>e;e++){const i=t[e],o=i.arcData;if(!o)continue;let n;n=y?y($t(i,"nodeStyle")).fill||v.get(i.id)||x[e%x.length]:v.get(i.id)||x[e%x.length];const s=y?y($t(i,"nodeStyle")):{},a={fill:n,stroke:s.stroke||"black",strokeWidth:null!==(r=s.strokeWidth)&&void 0!==r?r:1,opacity:s.opacity};k.push({type:"arc",cx:f,cy:g,innerR:d,outerR:h,startAngle:o.startAngle-Math.PI/2,endAngle:o.endAngle-Math.PI/2,style:a,datum:i,id:i.id,label:i.id})}for(const t of e){const e=t.chordData;if(!e)continue;const o=b(e);if(!o)continue;const r=qt(o,f,g);let c=(null===(n=i.themeSemantic)||void 0===n?void 0:n.border)||(null===(s=i.themeSemantic)||void 0===s?void 0:s.secondary)||"#999";if(p)c=p($t(t,"edgeStyle")).fill||c;else{const e="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;"target"===m&&i?c=v.get(i.id)||c:e&&(c=v.get(e.id)||c)}const l=p?p($t(t,"edgeStyle")):{},h={fill:c,fillOpacity:null!==(a=l.fillOpacity)&&void 0!==a?a:u,stroke:l.stroke||"none",strokeWidth:l.strokeWidth,opacity:l.opacity};A.push({type:"ribbon",pathD:r,style:h,datum:t})}if(!1!==i.showLabels){const e=(S=i.nodeLabel)?"function"==typeof S?S:t=>t[S]||t.id:null,o=h+12;for(const i of t){const t=i.arcData;if(!t)continue;const r=e?e(i):i.id;if(!r)continue;const n=(t.startAngle+t.endAngle)/2,s=n-Math.PI/2;w.push({x:f+Math.cos(s)*o,y:g+Math.sin(s)*o,text:r+"",anchor:n>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var S;return{sceneNodes:k,sceneEdges:A,labels:w}}};function qt(t,e,i){const o=t.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!o)return t;const r=[];let n=0;for(;o.length>n;){const t=o[n];if("M"===t||"L"===t)for(r.push(t),n++;o.length>n&&!isNaN(Number(o[n]));)r.push(Number(o[n])+e+""),n++,o.length>n&&!isNaN(Number(o[n]))&&(r.push(Number(o[n])+i+""),n++);else if("C"===t)for(r.push(t),n++;o.length>n&&!isNaN(Number(o[n]));)for(let t=0;3>t&&o.length>n&&!isNaN(Number(o[n]));t++)r.push(Number(o[n])+e+""),n++,o.length>n&&!isNaN(Number(o[n]))&&(r.push(Number(o[n])+i+""),n++);else if("Q"===t)for(r.push(t),n++;o.length>n&&!isNaN(Number(o[n]));)for(let t=0;2>t&&o.length>n&&!isNaN(Number(o[n]));t++)r.push(Number(o[n])+e+""),n++,o.length>n&&!isNaN(Number(o[n]))&&(r.push(Number(o[n])+i+""),n++);else if("A"===t)for(r.push(t),n++;o.length>n&&!isNaN(Number(o[n]));)r.push(o[n++]),o.length>n&&r.push(o[n++]),o.length>n&&r.push(o[n++]),o.length>n&&r.push(o[n++]),o.length>n&&r.push(o[n++]),o.length>n&&(r.push(Number(o[n])+e+""),n++),o.length>n&&(r.push(Number(o[n])+i+""),n++);else"Z"===t||"z"===t?(r.push(t),n++):(r.push(o[n]),n++)}return r.join(" ")}const Gt=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Vt(t){const[e,i,o]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(t);return.299*e+.587*i+.114*o>150?"#222":"#fff"}function Ht(t,e,i){const o=e.nodeIDAccessor;return"function"==typeof o?o(t.data)+"":"string"==typeof o&&void 0!==t.data[o]?t.data[o]+"":void 0!==t.data.name?t.data.name+"":void 0!==t.data.id?t.data.id+"":"node-"+i}function Qt(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 Ut(t){return Array.isArray(t.colorScheme)?t.colorScheme:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical:Gt}function Zt(t){var e;return Array.isArray(t.colorScheme)&&t.colorScheme.length>0?t.colorScheme[0]:(null===(e=t.themeSemantic)||void 0===e?void 0:e.primary)?t.themeSemantic.primary:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical[0]:"#4d430c"}function Kt(t,e,i,o,r){if("horizontal"===r){const r=(t+i)/2;return`M ${t},${e} C ${r},${e} ${r},${o} ${i},${o}`}if("radial"===r){const r=(t+i)/2;return`M ${t},${e} Q ${r},${e} ${r},${(e+o)/2} T ${i},${o}`}{const r=(e+o)/2;return`M ${t},${e} C ${t},${r} ${i},${r} ${i},${o}`}}const Jt={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,i,o){var r;const n=i.__hierarchyRoot;if(!n)return;const s=i.chartType,a=function(t){if(t)return"function"==typeof t?t:e=>e[t]}(i.childrenAccessor),c=i.hierarchySum,l="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=u.hierarchy(n,a);h.sum(l),h.sort((t,e)=>{var i,o;return(null!==(i=e.value)&&void 0!==i?i:0)-(null!==(o=t.value)&&void 0!==o?o:0)});const[d,f]=o;switch(s){case"tree":!function(t,e,i,o){const r=e.treeOrientation||"vertical",n=u.tree();n.size("horizontal"===r?[o,i]:"radial"===r?[2*Math.PI,Math.min(i,o)/2*.8]:[i,o]),n(t)}(h,i,d,f);break;case"cluster":!function(t,e,i,o){const r=e.treeOrientation||"vertical",n=u.cluster();n.size("horizontal"===r?[o,i]:"radial"===r?[2*Math.PI,Math.min(i,o)/2*.8]:[i,o]),n(t)}(h,i,d,f);break;case"treemap":!function(t,e,i,o){var r,n;const s=null!==(r=e.padding)&&void 0!==r?r:4,a=null!==(n=e.paddingTop)&&void 0!==n?n:0,c=u.treemap().size([i,o]).tile(u.treemapBinary).padding(s);a>0&&c.paddingTop(a),c(t)}(h,i,d,f);break;case"circlepack":!function(t,e,i,o){var r;const n=null!==(r=e.padding)&&void 0!==r?r:4;u.pack().size([i,o]).padding(n)(t)}(h,i,d,f);break;case"partition":!function(t,e,i,o){var r;u.partition().size([i,o]).padding(null!==(r=e.padding)&&void 0!==r?r:1)(t)}(h,i,d,f)}const g=h.descendants();t.length=0,e.length=0;const y=new Map;for(let e=0;g.length>e;e++){const o=g[e],n={id:Ht(o,i,e),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(r=o.value)&&void 0!==r?r:0,depth:o.depth,data:o.data,createdByFrame:!0};"tree"===s||"cluster"===s?te(n,o,i):"treemap"===s||"partition"===s?ee(n,o):"circlepack"===s&&ie(n,o),n.__hierarchyNode=o,t.push(n),y.set(o,n)}if("tree"===s||"cluster"===s)for(const t of g)if(t.parent){const i=y.get(t.parent),o=y.get(t);i&&o&&e.push({source:i,target:o,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,i,o){const r=i.nodeStyle||(()=>({})),n=i.edgeStyle||(()=>({}));switch(i.chartType){case"tree":case"cluster":return function(t,e,i,o,r,n){var s,a,c,l,u,h,d,f;const g=[],y=[],p=[],m=i.treeOrientation||"vertical",x="radial"===m,v=o[0]/2,b=o[1]/2,k="number"==typeof(A=i.nodeSize)?A:5;var A;for(const e of t){let t=e.x,o=e.y;x&&(t+=v,o+=b);const n=r($t(e,"nodeStyle"));let c=n.fill||Zt(i);if(i.colorByDepth&&void 0!==e.depth){const t=Ut(i);c=t[e.depth%t.length]}const l={fill:c,stroke:n.stroke||(null===(s=i.themeSemantic)||void 0===s?void 0:s.surface)||"#fff",strokeWidth:null!==(a=n.strokeWidth)&&void 0!==a?a:1,opacity:n.opacity};g.push({type:"circle",cx:t,cy:o,r:k,style:l,datum:e,id:e.id,label:e.id,depth:e.depth})}const w=null!==(c=i.edgeOpacity)&&void 0!==c?c:.5;for(const t of e){const e="object"==typeof t.source?t.source:null,o="object"==typeof t.target?t.target:null;if(!e||!o)continue;let r=e.x,s=e.y,a=o.x,c=o.y;x&&(r+=v,s+=b,a+=v,c+=b);const f=Kt(r,s,a,c,m),g=n($t(t,"edgeStyle")),p={fill:"none",stroke:g.stroke||(null===(l=i.themeSemantic)||void 0===l?void 0:l.border)||(null===(u=i.themeSemantic)||void 0===u?void 0:u.secondary)||"#999",strokeWidth:null!==(h=g.strokeWidth)&&void 0!==h?h:1.5,opacity:null!==(d=g.opacity)&&void 0!==d?d:w};y.push({type:"curved",pathD:f,style:p,datum:t})}if(!1!==i.showLabels){const e=Qt(i.nodeLabel);for(const i of t){const t=e?e(i):i.id;if(!t)continue;let o,r,n,s=i.x,a=i.y;if(x&&(s+=v,a+=b),x){const t=s-v,e=a-b,i=Math.sqrt(t*t+e*e);i>0?(o=s+t/i*10,r=a+e/i*10,n=0>t?"end":"start"):(o=s,r=a-12,n="middle")}else"horizontal"===m?((null===(f=i.data)||void 0===f?void 0:f.children)&&0!==i.data.children.length?(o=s-k-6,n="end"):(o=s+k+6,n="start"),r=a):(o=s,r=a+k+14,n="middle");p.push({x:o,y:r,text:t+"",anchor:n,baseline:"middle",fontSize:11})}}return{sceneNodes:g,sceneEdges:y,labels:p}}(t,e,i,o,r,n);case"treemap":case"partition":return function(t,e,i,o){var r,n,s,a,c;const l=[],u=[];for(const i of t){const t=i.x1-i.x0,s=i.y1-i.y0;if(0>=t||0>=s)continue;const a=o($t(i,"nodeStyle"));let c=a.fill||Zt(e);if(e.colorByDepth&&void 0!==i.depth){const t=Ut(e);c=t[i.depth%t.length]}const u={fill:c,stroke:a.stroke||(null===(r=e.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(n=a.strokeWidth)&&void 0!==n?n:1,opacity:a.opacity};l.push({type:"rect",x:i.x0,y:i.y0,w:t,h:s,style:u,datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==e.showLabels){const i=Qt(e.nodeLabel),r=e.labelMode||"leaf",n="partition"===e.chartType;for(const l of t){const t=l.x1-l.x0,h=l.y1-l.y0;if(0>=t||0>=h)continue;const d=!((null===(s=l.data)||void 0===s?void 0:s.children)&&l.data.children.length>0);if(!n){if("leaf"===r&&!d)continue;if("parent"===r&&d)continue}const f=i?i(l):l.id;if(!f)continue;if((d?30:40)>t||(d?16:14)>h)continue;let g=o($t(l,"nodeStyle")).fill||Zt(e);if(e.colorByDepth&&void 0!==l.depth){const t=Ut(e);g=t[l.depth%t.length]}const y="string"==typeof g?Vt(g):null!==(c=null===(a=e.themeSemantic)||void 0===a?void 0:a.text)&&void 0!==c?c:"#000";u.push(d?{x:l.x0+t/2,y:l.y0+h/2,text:f+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,h)/6)),fill:y}:{x:l.x0+4,y:l.y0+12,text:f+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:y})}}return{sceneNodes:l,sceneEdges:[],labels:u}}(t,i,0,r);case"circlepack":return function(t,e,i,o){var r,n,s,a,c,l,u,h,d,f;const g=[],y=[];for(const i of t){const t=null!==(r=i.__radius)&&void 0!==r?r:5;if(0>=t)continue;const c=o($t(i,"nodeStyle"));let l=c.fill||Zt(e);if(e.colorByDepth&&void 0!==i.depth){const t=Ut(e);l=t[i.depth%t.length]}const u={fill:l,stroke:c.stroke||(null===(n=e.themeSemantic)||void 0===n?void 0:n.surface)||"#fff",strokeWidth:null!==(s=c.strokeWidth)&&void 0!==s?s:1,opacity:null!==(a=c.opacity)&&void 0!==a?a:.7};g.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=Qt(e.nodeLabel);for(const r of t){const t=null!==(c=r.__radius)&&void 0!==c?c:5,n=i?i(r):r.id;if(!n)continue;if(15>t)continue;const s=!((null===(l=r.data)||void 0===l?void 0:l.children)&&r.data.children.length>0);let a=o($t(r,"nodeStyle")).fill||Zt(e);if(e.colorByDepth&&void 0!==r.depth){const t=Ut(e);a=t[r.depth%t.length]}if(s){const i="string"==typeof a?Vt(a):null!==(h=null===(u=e.themeSemantic)||void 0===u?void 0:u.text)&&void 0!==h?h:"#000";y.push({x:r.x,y:r.y,text:n+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,t/3)),fill:i})}else y.push({x:r.x,y:r.y-t+14,text:n+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,t/3)),fill:(null===(d=e.themeSemantic)||void 0===d?void 0:d.text)||"#000",stroke:(null===(f=e.themeSemantic)||void 0===f?void 0:f.surface)||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:g,sceneEdges:[],labels:y}}(t,i,0,r);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function te(t,e,i){const o=i.treeOrientation||"vertical";if("radial"===o){const i=e.x,o=e.y;t.x=o*Math.cos(i-Math.PI/2),t.y=o*Math.sin(i-Math.PI/2)}else"horizontal"===o?(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 ee(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 ie(t,e){var i;const o=null!==(i=e.r)&&void 0!==i?i:0;t.x=e.x,t.y=e.y,t.x0=e.x-o,t.x1=e.x+o,t.y0=e.y-o,t.y1=e.y+o,t.width=2*o,t.height=2*o,t.__radius=o}function oe(t){const e=t;return e.__orbitState||(e.__orbitState={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()}),e.__orbitState}const re={sankey:Nt,force:Bt,chord:Xt,tree:Jt,cluster:Jt,treemap:Jt,circlepack:Jt,partition:Jt,orbit:{supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(t,e,i,o){const r=i.__hierarchyRoot;r&&function(t,e,i,o,r){var n,s;const a=function(t){if("function"==typeof t)return t;const e=t||"children";return t=>t[e]||null}(i.childrenAccessor),c=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,d=null!==(s=i.orbitEccentricity)&&void 0!==s?s:1,f="number"==typeof h?()=>h:h,g="number"==typeof d?()=>d:d,y=oe(i);y.metaMap.clear(),o.length=0,r.length=0;const p=new Map;function m(t){var e;const i=null!==(e=p.get(t))&&void 0!==e?e:0;return p.set(t,i+1),0===i?t:`${t}__${i}`}const x=e[0]/2,v=e[1]/2,b=Math.min(e[0],e[1])/2*.85,k=m(c(t));o.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,s,h,d,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:i,depth:d,data:e,parentId:i},P=p?h/f(_)*S:h*S,j=l.pie().value(t=>{var e;return(null===(e=a(t))||void 0===e?void 0:e.length)?4:1}).sort(null),M=j(A),O=g(_);for(let e=0;A.length>e;e++){const a=(M[e].startAngle+M[e].endAngle)/2,l=A[e],u=m(c(l)),h=n+P*Math.sin(a),f=s+P*Math.cos(a)*O;o.push({id:u,x:h,y:f,x0:h,x1:h,y0:f,y1:f,width:0,height:0,value:0,depth:d,data:l}),y.metaMap.set(u,{ring:P,angle:a,depth:d,parentId:i,eccentricity:O}),r.push({source:i,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:i,target:u}}),t(l,u,h,f,P,d+1,!0)}w+=k}}(t,k,x,v,b,1,!1)}(r,o,i,t,e)},buildScene(t,e,i,o){var r,n,s,a,c,l,u;const h=i.nodeStyle,d=i.nodeSize,f="number"==typeof d?()=>d:"function"==typeof d?d:()=>6,g=[],y=[],p=[];if(!1!==i.orbitShowRings){const e=oe(i),o=new Map;for(const e of t)o.set(e.id,e);const r=new Map;for(const[,t]of e.metaMap){if(!t.parentId)continue;const e=o.get(t.parentId);if(!e)continue;const i=`${t.parentId}:${t.ring}`;r.has(i)||r.set(i,{parentX:e.x,parentY:e.y,ring:t.ring,ecc:t.eccentricity})}const n=48,s={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:t,parentY:e,ring:i,ecc:o}]of r)for(let r=0;n>r;r++){const a=r/n*Math.PI*2,c=(r+1)/n*Math.PI*2;y.push({type:"line",x1:t+i*Math.sin(a),y1:e+i*Math.cos(a)*o,x2:t+i*Math.sin(c),y2:e+i*Math.cos(c)*o,style:s,datum:null})}}for(const e of t){if(null==e.x||null==e.y)continue;const t=f($t(e,"nodeSize")),o=h?h($t(e,"nodeStyle")):{},l={fill:o.fill||(null===(r=i.themeSemantic)||void 0===r?void 0:r.primary)||"#6366f1",stroke:o.stroke||(null===(n=i.themeSemantic)||void 0===n?void 0:n.surface)||"#fff",strokeWidth:null!==(s=o.strokeWidth)&&void 0!==s?s:1,opacity:null!==(a=o.opacity)&&void 0!==a?a:0===(null!==(c=e.depth)&&void 0!==c?c:0)?1:.85};g.push({type:"circle",cx:e.x,cy:e.y,r:t,style:l,datum:e,id:e.id,label:e.id,depth:e.depth})}const m=new Map;for(const e of t)m.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:m.get(t.source),i="object"==typeof t.target?t.target:m.get(t.target);e&&i&&(null!=e.x&&null!=i.x&&y.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=f($t(i,"nodeSize"));if(4>=t)continue;const o="function"==typeof e?e(i):e&&null!==(u=null===(l=i.data)||void 0===l?void 0:l[e])&&void 0!==u?u:i.id;p.push({x:i.x,y:i.y+t+12,text:o+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:g,sceneEdges:y,labels:p}},tick:(t,e,i,o,r)=>!1!==i.orbitAnimated&&(function(t,e){var i,o;const r=oe(e),n=null!==(i=e.orbitSpeed)&&void 0!==i?i:.25,s=null!==(o=e.orbitRevolution)&&void 0!==o?o:function(t){switch(t){case"decay":return t=>{var e;return Math.pow(.6,null!==(e=t.depth)&&void 0!==e?e:0)};case"alternate":return t=>{var e;const i=null!==(e=t.depth)&&void 0!==e?e:0;return(i%2==0?1:-1)/(i+1)};default:return t=>{var e;return 1/((null!==(e=t.depth)&&void 0!==e?e:0)+1)}}}(e.orbitRevolutionStyle),a=(("undefined"!=typeof performance?performance.now():Date.now())-r.startTime)/1e3,c=n*(Math.PI/6),l=new Map;for(const e of t)l.set(e.id,e);for(const e of t){const t=r.metaMap.get(e.id);if(!t||!t.parentId)continue;const i=l.get(t.parentId);if(!i)continue;const o=t.angle+a*c*s({id:e.id,depth:t.depth,data:e.data,parentId:t.parentId});e.x=i.x+t.ring*Math.sin(o),e.y=i.y+t.ring*Math.cos(o)*t.eccentricity,e.x0=e.x,e.x1=e.x,e.y0=e.y,e.y1=e.y}}(t,i),!0)}};function ne(t,e){const{columns:i,config:o,resolvePieceStyle:r}=t,n=[],s=Math.min(e.width,e.height)/2-4,a="donut"===o.chartType?o.innerRadius||60:0,c=-Math.PI/2+(o.startAngle||0)*Math.PI/180,l=null!=o.sweepAngle?o.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,u=r(t.pieceData[0],t.name);n.push(Object.assign(Object.assign({type:"wedge",cx:0,cy:0,innerRadius:a,outerRadius:s,startAngle:e,endAngle:i},o.cornerRadius&&{cornerRadius:o.cornerRadius}),{style:u,datum:t.pieceData,category:t.name}))}return n}function se(t){var e,i,o;const r=t.length,s=t[0],a=t[r-1];return{n:r,min:s,q1:null!==(e=n.quantile(t,.25))&&void 0!==e?e:s,median:null!==(i=n.quantile(t,.5))&&void 0!==i?i:(s+a)/2,q3:null!==(o=n.quantile(t,.75))&&void 0!==o?o:a,max:a,mean:t.reduce((t,e)=>t+e,0)/r}}const ae={bar:function(t,e){var i,o,r;const{scales:n,columns:s,config:a,getR:c,getStack:l,resolvePieceStyle:u}=t,{r:h,projection:d}=n,f=[],g="vertical"===d,y="horizontal"===d,p=a.normalize,m=[];if(l){const t=new Set;for(const e of Object.values(s))for(const i of e.pieceData){const e=l(i);t.has(e)||(t.add(e),m.push(e))}}else m.push("_default");for(const t of Object.values(s)){const e=new Map;for(const i of t.pieceData){const t=l?l(i):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const o=e.get(t);o.total+=c(i),o.pieces.push(i)}let i=0;if(p)for(const t of e.values())i+=Math.abs(t.total);let o=0,r=0;for(const n of m){const s=e.get(n);if(!s)continue;let a=s.total;p&&i>0&&(a/=i);const c=u(s.pieces[0],l?n:t.name),d=Object.assign(Object.assign({},s.pieces[0]),{__aggregateValue:s.total,__pieceCount:s.pieces.length,category:t.name});if(g){const e=h(0>a?r:o+a),i=0>a?h(r+a)-h(r):h(o)-h(o+a);f.push(B(t.x,e,t.width,Math.abs(i),c,d,n)),0>a?r+=a:o+=a}else if(y){const e=h(0>a?r+a:o),i=0>a?h(r)-h(r+a):h(o+a)-h(o);f.push(B(e,t.x,Math.abs(i),t.width,c,d,n)),0>a?r+=a:o+=a}}}const x="vertical"===d,v=a.roundedTop&&a.roundedTop>0?Math.max(0,a.roundedTop):0;for(const t of f){if("rect"!==t.type)continue;const e=null!==(o=null===(i=t.datum)||void 0===i?void 0:i.__aggregateValue)&&void 0!==o?o:0;t.roundedEdge=x?0>e?"bottom":"top":0>e?"left":"right",a.gradientFill&&(t.fillGradient=a.gradientFill)}if(v>0){const t=new Map;for(const e of f){if("rect"!==e.type)continue;const i=(null===(r=e.datum)||void 0===r?void 0:r.category)||"";t.has(i)||t.set(i,[]),t.get(i).push(e)}for(const e of t.values()){if(0===e.length)continue;const t=e.filter(t=>{var e,i;return(null!==(i=null===(e=t.datum)||void 0===e?void 0:e.__aggregateValue)&&void 0!==i?i:0)>=0}),i=e.filter(t=>{var e,i;return 0>(null!==(i=null===(e=t.datum)||void 0===e?void 0:e.__aggregateValue)&&void 0!==i?i:0)});t.length>0&&(t.reduce(x?(t,e)=>e.y>t.y?t:e:(t,e)=>t.x+t.w>e.x+e.w?t:e).roundedTop=v),i.length>0&&(i.reduce(x?(t,e)=>t.y+t.h>e.y+e.h?t:e:(t,e)=>e.x>t.x?t:e).roundedTop=v)}}return f},clusterbar:function(t,e){const{scales:i,columns:o,config:r,getR:n,getGroup:s,resolvePieceStyle:a}=t,{r:c,projection:l}=i,u=[],h="vertical"===l,d=[],f=new Set;for(const t of Object.values(o))for(const e of t.pieceData){const t=s?s(e):"_default";f.has(t)||(f.add(t),d.push(t))}const g=d.length||1;for(const t of Object.values(o)){const e=t.width/g,i=.2*e,o=e-i,r=new Map;for(const e of t.pieceData){const t=s?s(e):"_default";r.has(t)||r.set(t,[]),r.get(t).push(e)}for(let s=0;d.length>s;s++){const l=r.get(d[s])||[];for(const r of l){const l=n(r),f=a(r,d[s]);if(h){const n=t.x+s*e+i/2,a=c(0),h=c(l);u.push(B(n,Math.min(a,h),o,Math.abs(a-h),f,r,d[s]))}else{const n=t.x+s*e+i/2,a=c(0),h=c(l);u.push(B(Math.min(a,h),n,Math.abs(h-a),o,f,r,d[s]))}}}}const y=r.roundedTop&&r.roundedTop>0?Math.max(0,r.roundedTop):0;for(const t of u){if("rect"!==t.type)continue;if(null==t.datum)continue;const e=n(t.datum);y>0&&(t.roundedTop=y),t.roundedEdge=h?0>e?"bottom":"top":0>e?"left":"right",r.gradientFill&&(t.fillGradient=r.gradientFill)}return u},point:function(t,e){var i,o;const{scales:r,columns:n,getR:s,multiScales:a,resolvePieceStyle:c}=t,{r:l,projection:u}=r,h=[],d="vertical"===u,f="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 r=null!==(i=e.__rIndex)&&void 0!==i?i:0,n=null!==(o=e.__rValue)&&void 0!==o?o:s(e),u=g&&a[r]||l,m=c(e,t.name),x=m.r||5;let v,b;if(f){const e=p+(t.pctStart+t.pct/2)*y,i=u(n);v=Math.cos(e)*i,b=Math.sin(e)*i}else d?(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:o,getR:r,resolvePieceStyle:n}=t,{r:s,projection:a}=i,c=[],l="vertical"===a;for(const t of Object.values(o)){const e=t.width/2;for(let i=0;t.pieceData.length>i;i++){const o=t.pieceData[i],a=r(o),u=n(o,t.name),h=u.r||4,d=(7919*i%100/100-.5)*e*.8,f=l?t.middle+d:s(a),g=l?s(a):t.middle+d;c.push({type:"point",x:f,y:g,r:h,style:u,datum:o})}}return c},pie:ne,donut:ne,boxplot:function(t,e){var i,o,r,s,a,c;const{scales:l,columns:u,config:h,getR:d,resolveSummaryStyle:f}=t,{r:g,projection:y}=l,p=[],m="vertical"===y,x=!1!==h.showOutliers;for(const e of Object.values(u)){const l=e.pieceData.map(t=>d(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(0===l.length)continue;const u=l[0],h=l[l.length-1],y=null!==(i=n.quantile(l,.25))&&void 0!==i?i:u,v=null!==(o=n.quantile(l,.5))&&void 0!==o?o:(u+h)/2,b=null!==(r=n.quantile(l,.75))&&void 0!==r?r:h,k=b-y,A=y-1.5*k,w=b+1.5*k,S=null!==(s=l.find(t=>t>=A))&&void 0!==s?s:u,_=null!==(a=[...l].reverse().find(t=>w>=t))&&void 0!==a?a:h,P=f(e.pieceData[0],e.name),j=[];if(x)for(const t of e.pieceData){const i=d(t);if(A>i||i>w){const o=m?e.middle:g(i),r=m?g(i):e.middle;j.push({px:o,py:r,value:i,datum:t})}}if(p.push({type:"boxplot",x:m?e.middle:0,y:m?0:e.middle,projection:m?"vertical":"horizontal",columnWidth:.6*e.width,minPos:g(S),q1Pos:g(y),medianPos:g(v),q3Pos:g(b),maxPos:g(_),stats:{n:l.length,min:S,q1:y,median:v,q3:b,max:_,mean:l.reduce((t,e)=>t+e,0)/l.length},style:P,datum:e.pieceData,category:e.name,outliers:j}),x)for(const e of j)p.push({type:"point",x:e.px,y:e.py,r:3,style:{fill:P.fill||(null===(c=t.config.themeSemantic)||void 0===c?void 0:c.secondary)||"#999",opacity:.6},datum:e.datum})}return p},violin:function(t,e){var i,o,r;const{scales:s,columns:a,config:c,getR:l,resolveSummaryStyle:u}=t,{r:h,projection:d}=s,f=[],g="vertical"===d,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,d=Array(y).fill(0);for(const t of e)d[Math.min(Math.floor((t-s)/c),y-1)]++;const m=Math.max(...d,1),x=t.width/2*.9;let v="";if(g){v=`M ${t.middle} ${h(s)}`;for(let e=0;y>e;e++){const i=h(s+(e+.5)*c);v+=` L ${t.middle+d[e]/m*x} ${i}`}v+=` L ${t.middle} ${h(a)}`;for(let e=y-1;e>=0;e--){const i=h(s+(e+.5)*c);v+=` L ${t.middle-d[e]/m*x} ${i}`}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-d[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+d[e]/m*x}`;v+=" Z"}const b=u(t.pieceData[0],t.name);let k;if(p&&e.length>=4){const c=null!==(i=n.quantile(e,.25))&&void 0!==i?i:s,l=null!==(o=n.quantile(e,.5))&&void 0!==o?o:(s+a)/2,u=null!==(r=n.quantile(e,.75))&&void 0!==r?r: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};f.push({type:"violin",pathString:v,translateX:0,translateY:0,bounds:A,iqrLine:k,stats:se(e),style:b,datum:t.pieceData,category:t.name})}return f},histogram:function(t,e){var i;const{scales:o,columns:r,config:n,getR:s,resolveSummaryStyle:a}=t,{r:c}=o,l=[],u=n.bins||25,h=n.normalize,d=null===(i=c.domain)||void 0===i?void 0:i.call(c),f=d?+d[0]:void 0,g=d?+d[1]:void 0;for(const t of Object.values(r)){const e=t.pieceData.map(t=>s(t)).filter(t=>null!=t&&!isNaN(t));if(0===e.length)continue;const i=null!=f&&isFinite(f)?f:Math.min(...e),o=null!=g&&isFinite(g)?g:Math.max(...e),r=(o-i)/u||1,n=Array(u).fill(0);for(const t of e)i>t||t>o||n[Math.min(Math.floor((t-i)/r),u-1)]++;const d=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 o=(h?n[e]/d:n[e]/y)*t.width*.9,s=c(i+e*r),a=c(i+(e+1)*r);l.push(B(Math.min(s,a),t.x+t.width-o,Math.abs(a-s),o,p,{bin:e,count:n[e],range:[i+e*r,i+(e+1)*r],category:t.name},t.name))}}return l},ridgeline:function(t,e){var i;const{scales:o,columns:r,config:n,getR:s,resolveSummaryStyle:a}=t,{r:c,projection:l}=o,u=[],h=n.bins||20,d="horizontal"===l,f=n.amplitude||1.5;for(const t of Object.values(r)){const e=t.pieceData.map(t=>s(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const o=e[0],r=e[e.length-1],n=(r-o)/h||1,l=Array(h).fill(0);for(const t of e)o>t||t>r||l[Math.min(Math.floor((t-o)/n),h-1)]++;const g=Math.max(...l,1),y=a(t.pieceData[0],t.name),p=t.width*f;let m="";if(d){const e=t.x+t.width;m=`M ${c(o)} ${e}`;for(let t=0;h>t;t++)m+=` L ${c(o+(t+.5)*n)} ${e-l[t]/g*p}`;m+=` L ${c(r)} ${e} Z`}else{const e=t.x;m=`M ${e} ${c(o)}`;for(let t=0;h>t;t++){const i=c(o+(t+.5)*n);m+=` L ${e+l[t]/g*p} ${i}`}m+=` L ${e} ${c(r)} Z`}const x=d?{x:Math.min(c(o),c(r)),y:t.x,width:Math.abs(c(r)-c(o)),height:t.width}:{x:t.x,y:Math.min(c(r),c(o)),width:t.width,height:Math.abs(c(r)-c(o))};u.push({type:"violin",pathString:m,translateX:0,translateY:0,bounds:x,stats:se(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:o,getRawRange:r,resolvePieceStyle:n}=t,{r:s,projection:a}=i,c=[],l="horizontal"===a;for(const t of Object.values(o))for(const e of t.pieceData){const i=r(e);if(!i)continue;const[o,a]=i,u=n(e,t.name);if(l){const i=s(Math.min(o,a)),r=s(Math.max(o,a));c.push(B(i,t.x,r-i,t.width,u,e,t.name))}else{const i=s(Math.max(o,a)),r=s(Math.min(o,a));c.push(B(t.x,i,t.width,r-i,u,e,t.name))}}return c},funnel:function(t,e){var o,r,n,s,a,c,l,u;const{columns:h,getR:d,getStack:f,resolvePieceStyle:g}=t,y=[],p=e.width/2,m=!1!==t.config.showLabels,x=t.scales.o.domain().map(t=>h[t]).filter(Boolean);if(0===x.length)return y;const v=[],b=new Set;for(const t of x)for(const e of t.pieceData){const t=f?f(e):"_default";b.has(t)||(b.add(t),v.push(t))}const k=v.length>1&&"_default"!==v[0],A=[];let w=0;for(const t of x){const e=new Map;let i=0;for(const o of t.pieceData){const t=f?f(o):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const r=e.get(t),n=d(o);r.total+=n,r.pieces.push(o),i+=n}A.push({col:t,groups:e,stepTotal:i}),k||i>w&&(w=i)}if(k)for(const t of A){let e=0,i=0;for(let o=0;v.length>o;o++){const r=t.groups.get(v[o]);r&&(o%2==0?e+=r.total:i+=r.total)}const o=Math.max(e,i);o>w&&(w=o)}if(0===w)return y;const S=new Map;for(const t of v){const e=A[0].groups.get(t);S.set(t,null!==(o=null==e?void 0:e.total)&&void 0!==o?o:0)}const _=A[0].stepTotal,P=k?.95*p:.9*e.width,j=i.scaleLinear().domain([0,w]).range([0,P]),M=null!==(r=t.config.connectorOpacity)&&void 0!==r?r:.3;let O=new Map;for(let e=0;A.length>e;e++){const i=A[e],o=i.col,r=0===e,h=o.width,d=.55*h,f=o.x+(h-d)/2,x=new Map;if(k){let t=0;for(const e of v){const o=i.groups.get(e);o&&(t+=j(o.total))}let e=p,n=p;for(let s=0;v.length>s;s++){const c=v[s],l=i.groups.get(c);if(!l)continue;const u=j(l.total),h=s%2==0,b=h?e:n-u;h?e+=u:n-=u;const k=g(l.pieces[0],c),A=null!==(a=S.get(c))&&void 0!==a?a:l.total,w=A>0?l.total/A*100:0,_=Object.assign(Object.assign({},l.pieces[0]),{__funnelValue:l.total,__funnelPercent:w,__funnelStep:o.name,__funnelIsFirstStep:r,__aggregateValue:l.total,__pieceCount:l.pieces.length,category:c});m&&(0===s&&(_.__funnelStepLabel=o.name,_.__funnelStepLabelX=p,_.__funnelStepLabelY=f,_.__funnelRowWidth=t),_.__funnelValueLabelX=b+u/2,_.__funnelValueLabelY=f,_.__funnelBarW=u),y.push(B(b,f,u,d,k,_,c)),x.set(c,{x:b,y:f,w:u,h:d})}}else{const t=i.stepTotal,e=j(t),a=p-e/2,c=v[0],l="_default"!==c,u=null!==(s=null===(n=i.groups.get(c))||void 0===n?void 0:n.pieces[0])&&void 0!==s?s:o.pieceData[0],h=l?c:o.name,b=g(u,h),k=_>0?t/_*100:0,A=Object.assign(Object.assign({},u),{__funnelValue:t,__funnelPercent:k,__funnelStep:o.name,__funnelIsFirstStep:r,category:l?c:o.name});m&&(A.__funnelStepLabel=o.name,A.__funnelStepLabelX=p,A.__funnelStepLabelY=f,A.__funnelRowWidth=e,A.__funnelValueLabelX=p,A.__funnelValueLabelY=f,A.__funnelBarW=e),y.push(B(a,f,e,d,b,A,h)),x.set(c,{x:a,y:f,w:e,h:d})}if(e>0&&O.size>0){const e=k?v:[v[0]];for(const r of e){const e=O.get(r),n=x.get(r);if(!e||!n)continue;const s=(()=>{const t=i.groups.get(r);return g(t?t.pieces[0]:o.pieceData[0],"_default"===r?o.name:r)})(),a={type:"trapezoid",points:[[e.x,e.y+e.h],[e.x+e.w,e.y+e.h],[n.x+n.w,n.y],[n.x,n.y]],style:{fill:s.fill||(null===(c=t.config.themeSemantic)||void 0===c?void 0:c.secondary)||"#999",opacity:M},datum:null!==(u=null===(l=i.groups.get(r))||void 0===l?void 0:l.pieces[0])&&void 0!==u?u:o.pieceData[0],category:"_default"===r?o.name:r};y.push(a)}}O=x}return y},"bar-funnel":function(t,e){var i,o,r,n;const{columns:s,getR:a,getStack:c,resolvePieceStyle:l,scales:u}=t,h=[],d=u.o.domain().map(t=>s[t]).filter(Boolean);if(0===d.length)return h;const f=[],g=new Set;for(const t of d)for(const e of t.pieceData){const t=c?c(e):"_default";g.has(t)||(g.add(t),f.push(t))}const y=f.length>1&&"_default"!==f[0],p=[];for(const t of d){const e=new Map;let i=0;for(const o of t.pieceData){const t=c?c(o):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const r=e.get(t),n=a(o);r.total+=n,r.pieces.push(o),i+=n}p.push({col:t,groups:e,stepTotal:i})}const m=new Map;for(const t of f){const e=null===(i=p[0])||void 0===i?void 0:i.groups.get(t);m.set(t,null!==(o=null==e?void 0:e.total)&&void 0!==o?o:0)}const x=u.r,v=y?f.length:1,b=y?.15:0;for(let t=0;p.length>t;t++){const e=p[t],i=e.col,o=0===t,s=t>0?p[t-1]:null,a=i.width/v,c=a*b,u=a-c;for(let t=0;f.length>t;t++){const d=f[t],g=e.groups.get(d);if(!g)continue;const p=g.total,v=null!==(r=m.get(d))&&void 0!==r?r:p,b=v>0?p/v*100:0,k=null==s?void 0:s.groups.get(d),A=null!==(n=null==k?void 0:k.total)&&void 0!==n?n:p,w=o?0:Math.max(0,A-p),S=i.x+t*a+c/2,_=x(p),P=x(0)-_,j=l(g.pieces[0],y?d:i.name),M=Object.assign(Object.assign({},g.pieces[0]),{__barFunnelValue:p,__barFunnelPercent:b,__barFunnelIsFirstStep:o,__barFunnelIsDropoff:!1,__barFunnelStep:i.name,__barFunnelDropoffValue:w,__barFunnelCategory:"_default"===d?void 0:d,category:y?d:i.name,__barFunnelLabelX:S+u/2,__barFunnelLabelY:x(p+w)});if(h.push(B(S,_,u,P,j,M,y?d:i.name)),w>0){const t=x(p+w),e=_-t,o=Object.assign({},j),r=Object.assign(Object.assign({},g.pieces[0]),{__barFunnelValue:w,__barFunnelPercent:v>0?w/v*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:i.name,__barFunnelCategory:"_default"===d?void 0:d,category:y?d:i.name});h.push(B(S,t,u,e,o,r,y?d:i.name))}}}return h},swimlane:function(t,e){const{scales:i,columns:o,getR:r,getStack:n,resolvePieceStyle:s}=t,{r:a,projection:c}=i,l=[],u="horizontal"===c;for(const t of Object.values(o)){let e=0;for(const i of t.pieceData){const o=Math.abs(r(i));if(0===o)continue;const c=n?n(i):t.name,h=s(i,c);if(u){const r=a(e),n=a(e+o);l.push(B(r,t.x,n-r,t.width,h,i,c))}else{const r=a(e+o),n=a(e);l.push(B(t.x,r,t.width,n-r,h,i,c))}e+=o}}return l}};class ce{constructor(t){this.rExtent=new x,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._dataVersion=0,this._pointQuadtree=null,this._maxPointRadius=0,this._datumIndexCache=null,this._categoryIndexCache=null,this._hasRenderedOnce=!1,this.config=t,this.buffer=new m(t.windowSize),this.getO=w(t.categoryAccessor||t.oAccessor,"category");const e=t.valueAccessor||t.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(t=>k(t,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new x)):(this.getR=k(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=w(t.stackBy),this.getGroup=w(t.groupBy),this.getColor=w(t.colorAccessor),this.getConnector=w(t.connectorAccessor),this.getDataId=w(t.dataIdAccessor),t.pulse&&(this.timestampBuffer=new m(t.windowSize))}ingest(t){const e="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=e,this._dataVersion++,t.bounded){this.buffer.clear(),this.rExtent.clear();for(const t of this.rExtents)t.clear();t.preserveCategoryOrder?this._hasStreamingData=!0: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.valueAccessor||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:e,buffer:o}=this;if(0===o.size)return this.scales=null,this.scene=[],this.columns={},void this.version++;this.rExtent.dirty&&this.rExtent.recalculate(o,this.getR);const r=o.toArray(),n=e.projection||"vertical",s=e.oExtent||this.resolveCategories(r),a=this.computeValueDomain(r,s),c="horizontal"===n,l="radial"===n,u=Math.min(.9,Math.max(0,null!=e.barPadding?e.barPadding/("vertical"===n?t.width:t.height):.1));let h,d;if(l){h=i.scaleBand().domain(s).range([0,1]).padding(0);const o=Math.min(t.width,t.height)/2,r=e.innerRadius||0;d=i.scaleLinear().domain(a).range([r,o])}else c?(h=i.scaleBand().domain(s).range([0,t.height]).padding(u),d=i.scaleLinear().domain(a).range([0,t.width])):(h=i.scaleBand().domain(s).range([0,t.width]).padding(u),d=i.scaleLinear().domain(a).range([t.height,0]));this.scales={o:h,r:d,projection:n},this.multiScales=this.rAccessors.length>1&&e.multiAxis?this.rAccessors.map((r,n)=>{var s;const a=this.rExtents[n];a.dirty&&a.recalculate(o,r);let[l,u]=a.extent;l===1/0&&(l=0,u=1);const h=null!==(s=e.extentPadding)&&void 0!==s?s:.05,d=u-l,f=d>0?d*h:1;return l-=f,u+=f,l>0&&(l=0),c?i.scaleLinear().domain([l,u]).range([0,t.width]):i.scaleLinear().domain([l,u]).range([t.height,0])}):[];let f=r;this.rAccessors.length>1&&(f=r.flatMap(t=>this.rAccessors.map((e,i)=>Object.assign(Object.assign({},t),{__rIndex:i,__rValue:e(t),__rName:this.resolveRAccessorName(i)})))),this.columns=this.buildColumns(f,s,h,n,t),this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(f,t),this.rebuildPointQuadtree(),this.config.decay&&this.applyDecay(this.scene,r),this.config.pulse&&this.applyPulse(this.scene,r),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++}resolveRAccessorName(t){const e=this.config.valueAccessor||this.config.rAccessor,i=Array.isArray(e)?e[t]:e;return"string"==typeof i?i:"value"+t}resolveCategories(t){const e=this.config.oSort,i="streaming"===this.config.runtimeMode||this._hasStreamingData,o="auto"===e?void 0:e;let r=null;if(i){r=new Set;for(const e of t)r.add(this.getO(e))}const n=r?Array.from(this.categories).filter(t=>r.has(t)):Array.from(this.categories);if(i&&void 0===o){const t=Math.max(50,3*r.size);if(this.categories.size>t){let e=this.categories.size-t;for(const t of this.categories){if(0>=e)break;r.has(t)||(this.categories.delete(t),e--)}}return n}if(!1===o)return n;if("function"==typeof o)return n.sort(o);const s=new Map;for(const e of t){const t=this.getO(e);s.set(t,(s.get(t)||0)+Math.abs(this.getR(e)))}return n.sort("asc"===o?(t,e)=>(s.get(t)||0)-(s.get(e)||0):(t,e)=>(s.get(e)||0)-(s.get(t)||0))}computeValueDomain(t,e){var i,o,r,n,s;const a=this.config.chartType,c=null!==(i=this.config.extentPadding)&&void 0!==i?i:.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,i=new Map;for(const o of t){const t=this.getO(o),r=this.getR(o);0>r?i.set(t,(i.get(t)||0)+r):e.set(t,(e.get(t)||0)+r)}for(const t of e.values())t>u&&(u=t);for(const t of i.values())l>t&&(l=t)}else if("bar"===a){const e=new Map;for(const i of t){const t=this.getO(i),o=this.getR(i);e.set(t,(e.get(t)||0)+o)}for(const t of e.values())t>u&&(u=t),l>t&&(l=t)}else if("swimlane"===a){const e=new Map;for(const i of t){const t=this.getO(i),o=Math.abs(this.getR(i));e.set(t,(e.get(t)||0)+o)}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===(o=this.config.rExtent)||void 0===o?void 0:o[0])&&null==(null===(r=this.config.rExtent)||void 0===r?void 0:r[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,i,o,r){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"===o)for(const e of t)c+=Math.abs(this.getR(e));const l=this.config.dynamicColumnWidth;let u=null;if(l&&"radial"!==o){u=new Map;let t=0;for(const i of e){const e=a.get(i)||[];let o;o="string"==typeof l?e.reduce((t,e)=>t+(Number(e[l])||0),0):l(e),u.set(i,o),t+=o}const n=("horizontal"===o?r.height:r.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,d=0;for(const t of e){const e=a.get(t)||[],o=e.reduce((t,e)=>t+Math.abs(this.getR(e)),0),r=c>0?o/c:0;let l,f;u?(l=d,f=u.get(t)||i.bandwidth(),d+=f+i.padding()*i.step()):(l=null!==(n=i(t))&&void 0!==n?n:0,f=i.bandwidth()),s[t]={name:t,x:l,y:0,width:f,middle:l+f/2,padding:i.padding()*i.step(),pieceData:e,pct:r,pctStart:h},h+=r}return s}getSceneContext(){return{scales:this.scales,columns:this.columns,config:this.config,getR:this.getR,getStack:this.getStack,getGroup:this.getGroup,getColor:this.getColor,getConnector:this.getConnector,getO:this.getO,multiScales:this.multiScales,rAccessors:this.rAccessors,resolvePieceStyle:(t,e)=>this.resolvePieceStyle(t,e),resolveSummaryStyle:(t,e)=>this.resolveSummaryStyle(t,e),getRawRange:t=>this.getRawRange(t)}}buildSceneNodes(t,e){if(!this.scales)return[];const i=this.getSceneContext(),o=ae[this.config.chartType];let r=o?o(i,e):[];if(this.getConnector&&this.scales){const t=function(t,e){var i,o;const{scales:r,config:n,getConnector:s,getO:a}=t;if(!s||!r)return[];const c=[],{projection:l}=r,u=new Map;for(const t of e){if("point"!==t.type&&"rect"!==t.type)continue;const e=t.datum;if(!e)continue;const i=s(e);if(!i)continue;let o,r;"point"===t.type?(o=t.x,r=t.y):(o=t.x+t.w/2,r=t.y+("vertical"===l?0:t.h/2)),u.has(i)||u.set(i,[]),u.get(i).push({x:o,y:r,datum:e,category:a(e)})}const h=r.o.domain(),d=n.connectorStyle;for(const[e,r]of u)if(r.length>=2){r.sort((t,e)=>h.indexOf(t.category)-h.indexOf(e.category));for(let n=0;r.length-1>n;n++){const s=r[n],a=r[n+1],l="function"==typeof d?d(s.datum):d||{stroke:(null===(i=t.config.themeSemantic)||void 0===i?void 0:i.border)||(null===(o=t.config.themeSemantic)||void 0===o?void 0:o.secondary)||"#999",strokeWidth:1,opacity:.5};c.push({type:"connector",x1:s.x,y1:s.y,x2:a.x,y2:a.y,style:l,datum:s.datum,group:e})}}return c}(i,r);r=[...t,...r]}return r}resolvePieceStyle(t,e){if("function"==typeof this.config.pieceStyle){const i=this.config.pieceStyle(t,e);return i&&!i.fill&&e?Object.assign(Object.assign({},i),{fill:this.getColorFromScheme(e)}):i}return this.config.pieceStyle&&"object"==typeof this.config.pieceStyle?this.config.pieceStyle:this.config.barColors&&e?{fill:this.config.barColors[e]||"#007bff"}:e?{fill:this.getColorFromScheme(e)}:{fill:"#007bff"}}getColorFromScheme(t){this._colorSchemeMap||(this._colorSchemeMap=new Map);const e=this._colorSchemeMap.get(t);if(e)return e;const i=Array.isArray(this.config.colorScheme)?this.config.colorScheme:this.config.themeCategorical||P,o=i[this._colorSchemeIndex%i.length];return this._colorSchemeIndex++,this._colorSchemeMap.set(t,o),o}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 i=this.config.decay;return i&&e>1?O(i,t,e):1}getDatumIndexMap(t){if(this._datumIndexCache&&this._datumIndexCache.version===this._dataVersion)return this._datumIndexCache.map;const e=new Map;for(let i=0;t.length>i;i++)e.set(t[i],i);return this._datumIndexCache={version:this._dataVersion,map:e},e}getCategoryIndexMap(t){if(this._categoryIndexCache&&this._categoryIndexCache.version===this._dataVersion)return this._categoryIndexCache.map;const e=this.config.categoryAccessor||this.config.oAccessor,i="function"==typeof e,o=i?null:e||"category",r=new Map;for(let n=0;t.length>n;n++){const s=t[n],a=i?e(s):s[o];let c=r.get(a);c||(c=[],r.set(a,c)),c.push(n)}return this._categoryIndexCache={version:this._dataVersion,map:r},r}rebuildPointQuadtree(){let t=0,e=0;for(const i of this.scene)"point"===i.type&&(t++,i.r>e&&(e=i.r));if(this._maxPointRadius=e,ce.QUADTREE_THRESHOLD>=t)return void(this._pointQuadtree=null);const i=Array(t);let r=0;for(const t of this.scene)"point"===t.type&&(i[r++]=t);this._pointQuadtree=o.quadtree().x(t=>t.x).y(t=>t.y).addAll(i)}get pointQuadtree(){return this._pointQuadtree}get maxPointRadius(){return this._maxPointRadius}applyDecay(t,e){var i,o;if(!this.config.decay)return;const r=e.length;if(1>=r)return;const n=this.getDatumIndexMap(e);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,r),a=null!==(o=null===(i=e.style)||void 0===i?void 0:i.opacity)&&void 0!==o?o:1;e.style=Object.assign(Object.assign({},e.style),{opacity:a*s})}}applyPulse(t,e){var i,o,r;if(!this.config.pulse||!this.timestampBuffer)return;const n="undefined"!=typeof performance?performance.now():Date.now(),s=null!==(i=this.config.pulse.duration)&&void 0!==i?i:500,a=null!==(o=this.config.pulse.color)&&void 0!==o?o:"rgba(255,255,255,0.6)",c=null!==(r=this.config.pulse.glowRadius)&&void 0!==r?r:4,l=this.getDatumIndexMap(e);let u=null;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;u||(u=this.getCategoryIndexMap(e));const o=u.get(t);if(!o)continue;let r=0;for(let t=0;o.length>t;t++){const e=this.timestampBuffer.get(o[t]);if(null==e)continue;const i=n-e;if(s>i){const t=1-i/s;t>r&&(r=t)}}r>0&&(i._pulseIntensity=r,i._pulseColor=a);continue}const t=l.get(i.datum);if(null==t)continue;const o=this.timestampBuffer.get(t);if(null==o)continue;const r=n-o;s>r&&(i._pulseIntensity=1-r/s,i._pulseColor=a,i._pulseGlowRadius=c)}}get hasActivePulses(){var t;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const e="undefined"!=typeof performance?performance.now():Date.now(),i=null!==(t=this.config.pulse.duration)&&void 0!==t?t:500,o=this.timestampBuffer.peek();return null!=o&&i>e-o}synthesizeIntroPositions(){var t,e,i,o,r;this.prevPositionMap.clear();const n=new Map,s=null!==(e=null===(t=this.scales)||void 0===t?void 0:t.r(0))&&void 0!==e?e:0,a="horizontal"!==(null===(i=this.scales)||void 0===i?void 0:i.projection);let c;for(let t=0;this.scene.length>t;t++){const e=this.scene[t],i=this.getNodeKey(e,n);i&&("rect"===e.type?this.prevPositionMap.set(i,a?{x:e.x,y:s,w:e.w,h:0,opacity:null!==(o=e.style.opacity)&&void 0!==o?o:1}:{x:s,y:e.y,w:0,h:e.h,opacity:null!==(r=e.style.opacity)&&void 0!==r?r:1}):"point"===e.type?this.prevPositionMap.set(i,{x:e.x,y:e.y,r:0,opacity:0}):"wedge"===e.type&&(void 0===c&&(c=e.startAngle),this.prevPositionMap.set(i,{x:e.cx,y:e.cy,startAngle:c,endAngle:c,innerRadius:e.innerRadius,outerRadius:e.outerRadius,opacity:0})))}}getNodeKey(t,e){var i,o,r;if("point"===t.type){const i=`p:${t.datum?this.getO(t.datum):""}:${t.datum?this.getR(t.datum):0}`,o=e.get(i)||0;return e.set(i,o+1),`${i}:${o}`}return"rect"===t.type?`r:${t.group||""}:${null!==(o=null===(i=t.datum)||void 0===i?void 0:i.category)&&void 0!==o?o:""}`:"wedge"===t.type?"w:"+(null!==(r=t.category)&&void 0!==r?r:""):null}snapshotPositions(){var t;this.prevPositionMap.clear();const e=new Map;for(let i=0;this.scene.length>i;i++){const o=this.scene[i],r=this.getNodeKey(o,e);r&&("point"===o.type?this.prevPositionMap.set(r,{x:o.x,y:o.y,r:o.r,opacity:o.style.opacity}):"rect"===o.type?this.prevPositionMap.set(r,{x:o.x,y:o.y,w:o.w,h:o.h,opacity:o.style.opacity}):"wedge"===o.type&&this.prevPositionMap.set(r,{x:o.cx,y:o.cy,startAngle:o.startAngle,endAngle:o.endAngle,innerRadius:o.innerRadius,outerRadius:o.outerRadius,opacity:null!==(t=o.style.opacity)&&void 0!==t?t:1}))}}startTransition(){var t,e,i,o,r,n,s,a,c,l,u,h,d,f,g,y,p,m,x,v,b;if(!this.config.transition||0===this.prevPositionMap.size)return;const k=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 A=!1;const w=new Set,S=new Map;for(let t=0;this.scene.length>t;t++){const l=this.scene[t],u=this.getNodeKey(l,S);if(!u)continue;l._transitionKey=u;const h=this.prevPositionMap.get(u);if("point"===l.type)h?(w.add(u),l._targetOpacity=null!==(e=l.style.opacity)&&void 0!==e?e:1,(h.x!==l.x||h.y!==l.y||void 0!==h.r&&h.r!==l.r)&&(l._targetX=l.x,l._targetY=l.y,l._targetR=l.r,l.x=h.x,l.y=h.y,void 0!==h.r&&(l.r=h.r),A=!0)):(l._targetOpacity=null!==(i=l.style.opacity)&&void 0!==i?i:1,l._targetR=l.r,l.r=0,l.style=Object.assign(Object.assign({},l.style),{opacity:0}),A=!0);else if("rect"===l.type)h?(w.add(u),l._targetOpacity=null!==(o=l.style.opacity)&&void 0!==o?o:1,h.x===l.x&&h.y===l.y&&h.w===l.w&&h.h===l.h||(l._targetX=l.x,l._targetY=l.y,l._targetW=l.w,l._targetH=l.h,l.x=h.x,l.y=h.y,l.w=null!==(r=h.w)&&void 0!==r?r:l.w,l.h=null!==(n=h.h)&&void 0!==n?n:l.h,A=!0)):(l._targetOpacity=null!==(s=l.style.opacity)&&void 0!==s?s:1,l.style=Object.assign(Object.assign({},l.style),{opacity:0}),A=!0);else if("wedge"===l.type)if(h)w.add(u),l._targetOpacity=null!==(a=l.style.opacity)&&void 0!==a?a:1,h.startAngle===l.startAngle&&h.endAngle===l.endAngle||(l._targetStartAngle=l.startAngle,l._targetEndAngle=l.endAngle,l.startAngle=h.startAngle,l.endAngle=h.endAngle,A=!0);else{l._targetOpacity=null!==(c=l.style.opacity)&&void 0!==c?c:1,l._targetStartAngle=l.startAngle,l._targetEndAngle=l.endAngle;const t=l.startAngle;l.startAngle=t,l.endAngle=t,l.style=Object.assign(Object.assign({},l.style),{opacity:0}),this.prevPositionMap.set(u,{x:l.cx,y:l.cy,startAngle:t,endAngle:t,innerRadius:l.innerRadius,outerRadius:l.outerRadius,opacity:0}),A=!0}}this.exitNodes=[];for(const[t,e]of this.prevPositionMap)if(!w.has(t)){if(t.startsWith("p:"))this.exitNodes.push({type:"point",x:e.x,y:e.y,r:null!==(l=e.r)&&void 0!==l?l:3,style:{opacity:null!==(u=e.opacity)&&void 0!==u?u:1},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("r:"))this.exitNodes.push({type:"rect",x:e.x,y:e.y,w:null!==(h=e.w)&&void 0!==h?h:0,h:null!==(d=e.h)&&void 0!==d?d:0,style:{opacity:null!==(f=e.opacity)&&void 0!==f?f:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("w:")){const i=((null!==(g=e.startAngle)&&void 0!==g?g:0)+(null!==(y=e.endAngle)&&void 0!==y?y:0))/2,o={type:"wedge",cx:e.x,cy:e.y,innerRadius:null!==(p=e.innerRadius)&&void 0!==p?p:0,outerRadius:null!==(m=e.outerRadius)&&void 0!==m?m:100,startAngle:null!==(x=e.startAngle)&&void 0!==x?x:0,endAngle:null!==(v=e.endAngle)&&void 0!==v?v:0,style:{opacity:null!==(b=e.opacity)&&void 0!==b?b:1},datum:null,category:t.slice(2),_targetStartAngle:i,_targetEndAngle:i,_targetOpacity:0,_transitionKey:t};this.exitNodes.push(o)}A=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),A&&(this.activeTransition={startTime:z(),duration:k})}advanceTransition(t){var e,i,o,r;if(!this.activeTransition)return!1;const n=E(t,this.activeTransition),s=L(n,"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 o=this.prevPositionMap.get(e),r=o?null!==(i=o.opacity)&&void 0!==i?i:1:0;t.style.opacity=D(r,t._targetOpacity,s)}const o=this.prevPositionMap.get(e);void 0!==t._targetX&&o&&(t.x=D(o.x,t._targetX,s),t.y=D(o.y,t._targetY,s)),void 0!==t._targetR&&void 0!==(null==o?void 0:o.r)&&(t.r=D(o.r,t._targetR,s))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const i=this.prevPositionMap.get(e),r=i?null!==(o=i.opacity)&&void 0!==o?o:1:0;t.style.opacity=D(r,t._targetOpacity,s)}if(void 0===t._targetX)continue;const i=this.prevPositionMap.get(e);if(!i)continue;t.x=D(i.x,t._targetX,s),t.y=D(i.y,t._targetY,s),void 0!==i.w&&(t.w=D(i.w,t._targetW,s),t.h=D(i.h,t._targetH,s))}else if("wedge"===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=Object.assign(Object.assign({},t.style),{opacity:D(o,t._targetOpacity,s)})}if(void 0!==t._targetStartAngle&&void 0!==t._targetEndAngle){const i=this.prevPositionMap.get(e);i&&void 0!==i.startAngle&&(t.startAngle=D(i.startAngle,t._targetStartAngle,s),t.endAngle=D(i.endAngle,t._targetEndAngle,s))}}}if(n>=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&&void 0===t._targetR)continue;void 0!==t._targetX&&(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"wedge"===t.type&&void 0!==t._targetStartAngle&&(t.startAngle=t._targetStartAngle,t.endAngle=t._targetEndAngle,t._targetStartAngle=void 0,t._targetEndAngle=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]),i=this.getDataId,o=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)=>{o(t)&&e.add(i)}),this.timestampBuffer.clear();for(let i=0;t.length>i;i++)e.has(i)||this.timestampBuffer.push(t[i])}const r=this.buffer.remove(o);if(0===r.length)return r;for(const t of r)this.evictValueExtent(t);return this.categories.clear(),this.buffer.forEach(t=>this.categories.add(this.getO(t))),this._dataVersion++,this.version++,r}update(t,e){if(!this.getDataId)throw Error("update() requires dataIdAccessor to be configured");const i=new Set(Array.isArray(t)?t:[t]),o=this.getDataId,r=new Set;this.buffer.forEach((t,e)=>{i.has(o(t))&&r.add(e)});const n=this.buffer.update(t=>i.has(o(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)),r.has(e)&&this.pushValueExtent(t)}),this._dataVersion++,this.version++,n}clear(){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this._hasStreamingData=!1,this._hasRenderedOnce=!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._pointQuadtree=null,this._maxPointRadius=0,this._dataVersion++,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(("colorScheme"in t&&t.colorScheme!==e.colorScheme||"themeCategorical"in t&&t.themeCategorical!==e.themeCategorical||"colorAccessor"in t&&!b(t.colorAccessor,e.colorAccessor))&&(this._colorSchemeMap=null,this._colorSchemeIndex=0),("categoryAccessor"in t&&!b(t.categoryAccessor,e.categoryAccessor)||"oAccessor"in t&&!b(t.oAccessor,e.oAccessor))&&(this._categoryIndexCache=null),Object.assign(this.config,t),("categoryAccessor"in t||"oAccessor"in t)&&(b(t.categoryAccessor||t.oAccessor,e.categoryAccessor||e.oAccessor)||(this.getO=w(this.config.categoryAccessor||this.config.oAccessor,"category"),this.categories.clear())),"valueAccessor"in t||"rAccessor"in t){const i=t.valueAccessor||t.rAccessor,o=e.valueAccessor||e.rAccessor,r=Array.isArray(i)?i:[i],n=Array.isArray(o)?o:[o];if(r.length!==n.length||r.some((t,e)=>!b(t,n[e]))){const t=this.config.valueAccessor||this.config.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(t=>k(t,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new x)):(this.getR=k(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in t&&!b(t.stackBy,e.stackBy)&&(this.getStack=null!=this.config.stackBy?w(this.config.stackBy):void 0),"groupBy"in t&&!b(t.groupBy,e.groupBy)&&(this.getGroup=null!=this.config.groupBy?w(this.config.groupBy):void 0),"colorAccessor"in t&&!b(t.colorAccessor,e.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?w(this.config.colorAccessor):void 0),"connectorAccessor"in t&&!b(t.connectorAccessor,e.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?w(this.config.connectorAccessor):void 0)}}ce.QUADTREE_THRESHOLD=500;const le={mercator:h.geoMercator,equalEarth:h.geoEqualEarth,albersUsa:h.geoAlbersUsa,orthographic:h.geoOrthographic,naturalEarth:h.geoNaturalEarth1,equirectangular:h.geoEquirectangular};function ue(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}function he(t){return t?"function"==typeof t?t:e=>e[t]:t=>t.coordinates||t.data||[]}function de(t,e,i){return t?Object.assign(Object.assign({},i),"function"==typeof t?t(e):t):Object.assign({},i)}function fe(t,e){if(2>t.length)return[t];const i=.4*e,o=[];let r=[t[0]];for(let e=1;t.length>e;e++){const n=t[e];Math.abs(n[0]-t[e-1][0])>i?(2>r.length||o.push(r),r=[n]):r.push(n)}return 2>r.length||o.push(r),o}function ge(t,e,i=24){const o=e[0]-t[0],r=e[1]-t[1],n=Math.sqrt(o*o+r*r);if(0===n)return[t,e];const s=-r/n,a=o/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 o=0;i>=o;o++){const r=o/i,n=1-r;h.push([n*n*t[0]+2*n*r*l+r*r*e[0],n*n*t[1]+2*n*r*u+r*r*e[1]])}return h}function ye(t,e){if(2>t.length)return t;const i=e/2+1,o=[];for(let e=0;t.length>e;e++){const r=t[e];let n,s;0===e?(n=t[1][0]-r[0],s=t[1][1]-r[1]):e===t.length-1?(n=r[0]-t[e-1][0],s=r[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;o.push([r[0]+s/a*i,r[1]+-n/a*i])}return o}function pe(t,e,i,o,r){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=r/2+1;return[[t[0]+c*u,t[1]+l*u],[e[0]+c*u,e[1]+l*u]]}class me{constructor(t){this.scene=[],this.scales=null,this.version=0,this._quadtree=null,this._maxPointRadius=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._hasRenderedOnce=!1,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 m(t),this.timestampBuffer=new m(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],o=new Set(Array.isArray(t)?t:[t]);if(this.streaming&&this.pointBuffer){const t=t=>o.has(i(t)+"");if(this.timestampBuffer&&this.timestampBuffer.size>0){const e=this.timestampBuffer.toArray(),i=new Set;this.pointBuffer.forEach((e,o)=>{t(e)&&i.add(o)}),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=>!o.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._hasRenderedOnce=!1,this.activeTransition=null,this.prevPositions=null,this._quadtree=null,this._maxPointRadius=0,this.version++}computeScene(t){const{config:e}=this;this.projection=function(t){if(!t)return h.geoEqualEarth();if("string"==typeof t){const e=le[t];return e?e():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${t}", falling back to equalEarth`),h.geoEqualEarth())}if("object"==typeof t&&"type"in t){const e=le[t.type],i=e?e():h.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=h.geoPath(this.projection),this.fitProjection(t),this.geoPath=h.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 o=this.scene;if(this.scene=this.buildSceneNodes(t),this.rebuildQuadtree(),e.projectionTransform&&this.applyCartogramTransform(e.projectionTransform,t),e.decay&&this.streaming&&this.applyDecay(),e.pulse&&this.streaming&&this.applyPulse(),e.transition&&!this._hasRenderedOnce&&this.scene.length>0&&e.introAnimation){const e=t.width/2,i=t.height/2,o=this.scene.filter(t=>"point"===t.type).map(t=>Object.assign(Object.assign({},t),{x:e,y:i}));o.length>0&&this.startTransition(o)}this._hasRenderedOnce=!0,e.transition&&o.length>0&&this.startTransition(o),this.version++}fitProjection(t){var e,i,o,r,n;const s=this.projection,a=this.config,c=[...this.areas],l=ue(a.xAccessor,"lon"),u=ue(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 d=he(a.lineDataAccessor);for(const t of this.lineData){const e=d(t);if(e&&e.length>0){const t=e.map(t=>[l(t),u(t)]);c.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:t}})}}if(0!==c.length){if(a.projectionExtent){const[[e,i],[o,r]]=a.projectionExtent;s.fitExtent([[0,0],[t.width,t.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[e,i],[o,i],[o,r],[e,r],[e,i]]]}})}else if(s.clipAngle&&(null!==(e=s.clipAngle())&&void 0!==e?e:0)>0){const e=null!==(i=a.fitPadding)&&void 0!==i?i:0,o=Math.min(t.width,t.height);s.scale(o/2-o*e),s.translate([t.width/2,t.height/2])}else{const e=null!==(o=a.fitPadding)&&void 0!==o?o:0,i=t.width*e,r=t.height*e;s.fitExtent([[i,r],[t.width-i,t.height-r]],{type:"FeatureCollection",features:c})}this.baseScale=s.scale(),this.baseTranslate=s.translate(),this.baseRotation=null!==(n=null===(r=s.rotate)||void 0===r?void 0:r.call(s))&&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=h.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.rebuildQuadtree(),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=h.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.rebuildQuadtree(),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=h.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.rebuildQuadtree(),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}rebuildQuadtree(){let t=0,e=0;for(const i of this.scene)"point"===i.type&&(e++,i.r>t&&(t=i.r));if(this._maxPointRadius=t,me.QUADTREE_THRESHOLD>=e)return void(this._quadtree=null);const i=Array(e);let r=0;for(const t of this.scene)"point"===t.type&&(i[r++]=t);this._quadtree=o.quadtree().x(t=>t.x).y(t=>t.y).addAll(i)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}buildSceneNodes(t){var e,i,o;const r=[],{config:n}=this,s=this.projection,a=this.geoPath,c=ue(n.xAccessor,"lon"),l=ue(n.yAccessor,"lat"),u=function(t){var e,i;return{fill:(null===(e=t.themeSemantic)||void 0===e?void 0:e.surface)||"#e0e0e0",stroke:(null===(i=t.themeSemantic)||void 0===i?void 0:i.border)||"#999",strokeWidth:.5,fillOpacity:1}}(n),d=function(t){var e;return{stroke:(null===(e=t.themeSemantic)||void 0===e?void 0:e.primary)||"#4e79a7",strokeWidth:1.5,fill:"none"}}(n),f=function(t){var e;return{fill:(null===(e=t.themeSemantic)||void 0===e?void 0:e.primary)||"#4e79a7",r:4,fillOpacity:.8}}(n);if(n.graticule){const e=!0===n.graticule?{}:n.graticule,i=h.geoGraticule();e.step&&i.step(e.step);const o=a(i())||"";o&&r.push({type:"geoarea",pathData:o,centroid:[t.width/2,t.height/2],bounds:[[0,0],[t.width,t.height]],screenArea:0,style:{fill:"none",stroke:e.stroke||"#e0e0e0",strokeWidth:e.strokeWidth||.5,strokeDasharray:e.strokeDasharray||"2,2"},datum:null,interactive:!1})}for(const t of this.areas){const e=a(t);if(!e)continue;const i=a.centroid(t),o=a.bounds(t),s=a.area(t),c=de(n.areaStyle,t,u);r.push({type:"geoarea",pathData:e,centroid:i,bounds:o,screenArea:s,style:c,datum:t,interactive:!0})}const g=he(n.lineDataAccessor);for(const e of this.lineData){const i=g(e);if(!i||2>i.length)continue;let o=[];if("geo"===n.lineType){const t=Array(i.length);for(let e=0;i.length>e;e++)t[e]=[c(i[e]),l(i[e])];for(let e=0;t.length-1>e;e++){const i=t[e],r=t[e+1],n=h.geoDistance(i,r)||0,a=Math.max(2,Math.ceil(n/(Math.PI/180))),c=h.geoInterpolate(i,r);for(let t=0;a>=t;t++){if(e>0&&0===t)continue;const i=s(c(t/a));null!=i&&o.push(i)}}}else for(let t=0;i.length>t;t++){const e=i[t],r=s([c(e),l(e)]);null!=r&&o.push(r)}if(2>o.length)continue;const a=de(n.lineStyle,e,d),u="number"==typeof a.strokeWidth?a.strokeWidth:1;2!==i.length||2>o.length||"arc"!==n.flowStyle?2!==i.length||2>o.length||"offset"!==n.flowStyle||(o="geo"===n.lineType?ye(o,u):pe(o[0],o[o.length-1],0,0,u)):o=ge(o[0],o[o.length-1]);const f=fe(o,t.width);if(f.length>1)for(const t of f){if(2>t.length)continue;const i={type:"line",path:t,style:Object.assign(Object.assign({},a),{_edgeFade:!0}),datum:e};r.push(i)}else r.push({type:"line",path:2>o.length&&f[0]||o,style:a,datum:e})}const y=this.getPoints(),p=n.pointIdAccessor?"function"==typeof n.pointIdAccessor?n.pointIdAccessor:t=>t[n.pointIdAccessor]:null,m=s.clipAngle&&null!==(e=s.clipAngle())&&void 0!==e?e:0,x=m>0?m*Math.PI/180:null,v=s.rotate?s.rotate():[0,0,0],b="function"==typeof s.center?s.center():[0,0],k=[(null!==(i=b[0])&&void 0!==i?i:0)-v[0],(null!==(o=b[1])&&void 0!==o?o:0)-v[1]];for(let t=0;y.length>t;t++){const e=y[t],i=c(e),o=l(e);if(null!=x&&h.geoDistance([i,o],k)>x)continue;const a=s([i,o]);if(!a)continue;const u=n.pointStyle?n.pointStyle(e):Object.assign({},f),d={type:"point",x:a[0],y:a[1],r:u.r||4,style:u,datum:e,pointId:p?p(e)+"":void 0};r.push(d)}return r}applyCartogramTransform(t,e){var o,r,n;const s=this.scene.filter(t=>"point"===t.type);if(2>s.length)return;const a=null!==(o=t.strength)&&void 0!==o?o: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=>e.datum&&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,d=u.y,f=s.map(t=>t.datum?l(t.datum):NaN).filter(t=>isFinite(t)&&t>=0),g=Math.max(...f,1),y=Math.min(e.width,e.height)/2,p=i.scaleLinear().domain([0,g]).range([0,y]);this.cartogramLayout={cx:h,cy:d,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;if(!t.datum)continue;const e=Math.atan2(t.y-d,t.x-h),i=Math.sqrt(Math.pow(t.x-h,2)+Math.pow(t.y-d,2)),o=l(t.datum),r=i+((isFinite(o)?p(o):i)-i)*a;t.x=h+Math.cos(e)*r,t.y=d+Math.sin(e)*r}const m=e.width/2,x=e.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 i=null===(r=e.datum)||void 0===r?void 0:r.source,o=null===(n=e.datum)||void 0===n?void 0:n.target;if(i&&o){const r=t.get(i+""),n=t.get(o+"");r&&n&&(e.path=[r,n])}}}}applyDecay(){const t=this.config.decay;if(!t||!this.pointBuffer)return;const e=this.pointBuffer.size;if(0===e)return;const i=this.scene.filter(t=>"point"===t.type);for(let o=0;i.length>o;o++){const r=O(t,o,e);i[o]._decayOpacity=r,i[o].style=Object.assign(Object.assign({},i[o].style),{opacity:r})}}applyPulse(){var t,e;const i=this.config.pulse;if(!i||!this.timestampBuffer)return;const o=null!==(t=i.duration)&&void 0!==t?t:500,r=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=r-s[t];o>a&&(n[t]._pulseIntensity=1-a/o,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,o=this.timestampBuffer.toArray()[this.timestampBuffer.size-1];return performance.now()-o<i}startTransition(t){var e,i;const o=null!==(i=null===(e=this.config.transition)||void 0===e?void 0:e.duration)&&void 0!==i?i:300;if(0>=o)return;const r=new Map;for(const e of t)"point"===e.type&&e.pointId&&r.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=r.get(t.pointId);e&&(t._targetX=t.x,t._targetY=t.y,t.x=e[0],t.y=e[1],(Math.abs(e[0]-t._targetX)>.5||Math.abs(e[1]-t._targetY)>.5)&&(s=!0))}s&&(this.activeTransition={startTime:performance.now(),duration:o})}advanceTransition(t){if(!this.activeTransition)return!1;const e=E(t,this.activeTransition),i=L(e),o=this.scene.filter(t=>"point"===t.type);for(const t of o)if(null!=t._targetX&&null!=t._targetY){const e=t.y;t.x=D(t.x,t._targetX,i),t.y=D(e,t._targetY,i)}if(e>=1){for(const t of o)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 xe(t,e="#4e79a7"){return t&&"string"==typeof t?t:e}function ve(e,i){var o,r,n;switch(e.type){case"line":{const o=e;if(0===o.path.length)return null;const r="M"+o.path.map(([t,e])=>`${t},${e}`).join("L");return t.jsx("path",{d:r,fill:"none",stroke:o.style.stroke||"#4e79a7",strokeWidth:o.style.strokeWidth||2,strokeDasharray:o.style.strokeDasharray,opacity:o.style.opacity},"line-"+i)}case"area":{const n=e;if(0===n.topPath.length)return null;const s=n.topPath.map(([t,e])=>`${t},${e}`).join("L"),a=[...n.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L");return t.jsx("path",{d:`M${s}L${a}Z`,fill:xe(n.style.fill),fillOpacity:null!==(r=null!==(o=n.style.fillOpacity)&&void 0!==o?o:n.style.opacity)&&void 0!==r?r:.7,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth},"area-"+i)}case"point":{const o=e;return t.jsx("circle",{cx:o.x,cy:o.y,r:o.r,fill:xe(o.style.fill),opacity:null!==(n=o.style.opacity)&&void 0!==n?n:.8,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth},"point-"+i)}case"rect":{const o=e;return t.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:xe(o.style.fill),opacity:o.style.opacity,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth},"rect-"+i)}case"heatcell":{const o=e;if(o.showValues&&null!=o.value&&o.w>=20&&o.h>=20){const e=o.valueFormat?o.valueFormat(o.value):Number.isInteger(o.value)?o.value+"":100>Math.abs(o.value)?1>Math.abs(o.value)?o.value.toPrecision(3):o.value.toFixed(1):o.value.toFixed(0),[r,n,s]=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]}(o.fill),a=.299*r+.587*n+.114*s>128?"#000":"#fff",c=Math.max(10,Math.min(16,.3*Math.min(o.w,o.h)));return t.jsxs("g",{children:[t.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:o.fill}),t.jsx("text",{x:o.x+o.w/2,y:o.y+o.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:a,fontSize:c+"px",children:e})]},"heatcell-"+i)}return t.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:o.fill},"heatcell-"+i)}case"candlestick":{const o=e,r=Math.min(o.openY,o.closeY),n=Math.max(Math.abs(o.openY-o.closeY),1),s=o.isUp?o.upColor:o.downColor;return t.jsxs("g",{children:[t.jsx("line",{x1:o.x,y1:o.highY,x2:o.x,y2:o.lowY,stroke:o.wickColor,strokeWidth:o.wickWidth}),t.jsx("rect",{x:o.x-o.bodyWidth/2,y:r,width:o.bodyWidth,height:n,fill:s,stroke:s,strokeWidth:1})]},"candle-"+i)}default:return null}}function be(e,i){var o,r,n,s,a;const c=("category"in e?e.category:void 0)||("group"in e?e.group:void 0)||"",u=t=>`ord-${e.type}-${c}-${i}-${t}`,h=`ord-${e.type}-${c}-${i}`;switch(e.type){case"rect":{const i=e,o=function(t){const e=t.replace(/[^A-Za-z0-9_-]/g,"_");return!e||/^\d/.test(e)?"s_"+e:e}(h)+"-grad",r=function(e,i){const o=e.fillGradient;if(!o)return null;let r=e.x,n=e.y,s=e.x,a=e.y+e.h;"bottom"===e.roundedEdge?(n=e.y+e.h,a=e.y):"right"===e.roundedEdge?(r=e.x+e.w,n=e.y,s=e.x,a=e.y):"left"===e.roundedEdge&&(r=e.x,n=e.y,s=e.x+e.w,a=e.y);const c=[];if("colorStops"in o){const e=o.colorStops.filter(t=>Number.isFinite(t.offset)).map(t=>({offset:Math.max(0,Math.min(1,t.offset)),color:t.color}));if(2>e.length)return null;for(let i=0;e.length>i;i++)c.push(t.jsx("stop",{offset:e[i].offset,stopColor:e[i].color},i))}else{const i=xe(e.style.fill);c.push(t.jsx("stop",{offset:0,stopColor:i,stopOpacity:o.topOpacity},"0")),c.push(t.jsx("stop",{offset:1,stopColor:i,stopOpacity:o.bottomOpacity},"1"))}return t.jsx("linearGradient",{id:i,gradientUnits:"userSpaceOnUse",x1:r,y1:n,x2:s,y2:a,children:c})}(i,o),n=r?`url(#${o})`:xe(i.style.fill);if(i.roundedTop&&i.roundedTop>0){const e=Math.min(i.roundedTop,i.w/2,i.h/2),{x:o,y:s,w:a,h:c}=i;let l;switch(i.roundedEdge){case"right":l=`M${o},${s} L${o+a-e},${s} A${e},${e} 0 0 1 ${o+a},${s+e} L${o+a},${s+c-e} A${e},${e} 0 0 1 ${o+a-e},${s+c} L${o},${s+c} Z`;break;case"left":l=`M${o+a},${s} L${o+e},${s} A${e},${e} 0 0 0 ${o},${s+e} L${o},${s+c-e} A${e},${e} 0 0 0 ${o+e},${s+c} L${o+a},${s+c} Z`;break;case"bottom":l=`M${o},${s} L${o+a},${s} L${o+a},${s+c-e} A${e},${e} 0 0 1 ${o+a-e},${s+c} L${o+e},${s+c} A${e},${e} 0 0 1 ${o},${s+c-e} Z`;break;default:l=`M${o},${s+c} L${o},${s+e} A${e},${e} 0 0 1 ${o+e},${s} L${o+a-e},${s} A${e},${e} 0 0 1 ${o+a},${s+e} L${o+a},${s+c} Z`}return t.jsxs(y.Fragment,{children:[r&&t.jsx("defs",{children:r}),t.jsx("path",{d:l,fill:n,opacity:i.style.opacity,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})]},h)}return t.jsxs(y.Fragment,{children:[r&&t.jsx("defs",{children:r}),t.jsx("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:n,opacity:i.style.opacity,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})]},h)}case"point":{const i=e;return t.jsx("circle",{cx:i.x,cy:i.y,r:i.r,fill:xe(i.style.fill),opacity:null!==(o=i.style.opacity)&&void 0!==o?o:.8,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth},h)}case"wedge":{const i=e,o=l.arc().innerRadius(i.innerRadius).outerRadius(i.outerRadius).startAngle(i.startAngle+Math.PI/2).endAngle(i.endAngle+Math.PI/2);i.cornerRadius&&o.cornerRadius(i.cornerRadius);const r=o({})||"";return t.jsx("path",{d:r,transform:`translate(${i.cx},${i.cy})`,fill:xe(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},h)}case"boxplot":{const i=e,o=i.columnWidth/2;return t.jsxs("g","vertical"===i.projection?{children:[t.jsx("line",{x1:i.x,y1:i.minPos,x2:i.x,y2:i.maxPos,stroke:i.style.stroke||"#333",strokeWidth:1}),t.jsx("rect",{x:i.x-o,y:Math.min(i.q1Pos,i.q3Pos),width:i.columnWidth,height:Math.abs(i.q3Pos-i.q1Pos),fill:xe(i.style.fill),fillOpacity:null!==(r=i.style.fillOpacity)&&void 0!==r?r:.6,stroke:i.style.stroke||"#333",strokeWidth:1}),t.jsx("line",{x1:i.x-o,y1:i.medianPos,x2:i.x+o,y2:i.medianPos,stroke:i.style.stroke||"#333",strokeWidth:2}),t.jsx("line",{x1:i.x-.5*o,y1:i.minPos,x2:i.x+.5*o,y2:i.minPos,stroke:i.style.stroke||"#333",strokeWidth:1}),t.jsx("line",{x1:i.x-.5*o,y1:i.maxPos,x2:i.x+.5*o,y2:i.maxPos,stroke:i.style.stroke||"#333",strokeWidth:1})]}:{children:[t.jsx("line",{x1:i.minPos,y1:i.y,x2:i.maxPos,y2:i.y,stroke:i.style.stroke||"#333",strokeWidth:1}),t.jsx("rect",{x:Math.min(i.q1Pos,i.q3Pos),y:i.y-o,width:Math.abs(i.q3Pos-i.q1Pos),height:i.columnWidth,fill:xe(i.style.fill),fillOpacity:null!==(n=i.style.fillOpacity)&&void 0!==n?n:.6,stroke:i.style.stroke||"#333",strokeWidth:1}),t.jsx("line",{x1:i.medianPos,y1:i.y-o,x2:i.medianPos,y2:i.y+o,stroke:i.style.stroke||"#333",strokeWidth:2}),t.jsx("line",{x1:i.minPos,y1:i.y-.5*o,x2:i.minPos,y2:i.y+.5*o,stroke:i.style.stroke||"#333",strokeWidth:1}),t.jsx("line",{x1:i.maxPos,y1:i.y-.5*o,x2:i.maxPos,y2:i.y+.5*o,stroke:i.style.stroke||"#333",strokeWidth:1})]},h)}case"violin":{const i=e,o=[t.jsx("path",{d:i.pathString,transform:i.translateX||i.translateY?`translate(${i.translateX},${i.translateY})`:void 0,fill:xe(i.style.fill),fillOpacity:null!==(s=i.style.fillOpacity)&&void 0!==s?s:.6,stroke:i.style.stroke||"#333",strokeWidth:i.style.strokeWidth||1},u("path"))];if(i.iqrLine&&i.bounds){const e=i.bounds,r=e.x+e.width/2,n=e.y+e.height/2;e.height>e.width?o.push(t.jsx("line",{x1:r,y1:i.iqrLine.q1Pos,x2:r,y2:i.iqrLine.q3Pos,stroke:i.style.stroke||"#333",strokeWidth:2},u("iqr")),t.jsx("circle",{cx:r,cy:i.iqrLine.medianPos,r:3,fill:"white",stroke:i.style.stroke||"#333",strokeWidth:1},u("med"))):o.push(t.jsx("line",{x1:i.iqrLine.q1Pos,y1:n,x2:i.iqrLine.q3Pos,y2:n,stroke:i.style.stroke||"#333",strokeWidth:2},u("iqr")),t.jsx("circle",{cx:i.iqrLine.medianPos,cy:n,r:3,fill:"white",stroke:i.style.stroke||"#333",strokeWidth:1},u("med")))}return t.jsx("g",{children:o},h)}case"connector":return t.jsx("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:null!==(a=e.style.opacity)&&void 0!==a?a:.5},h);case"trapezoid":{const i=e,o=i.points.map(t=>`${t[0]},${t[1]}`).join(" ");return t.jsx("polygon",{points:o,fill:xe(i.style.fill,"#999"),opacity:i.style.opacity,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth},h)}default:return null}}function ke(t){if(!t.accessibility)return t;let e=t;if(t.accessibility.colorBlindSafe&&(e=Object.assign(Object.assign({},e),{colors:Object.assign(Object.assign({},e.colors),{categorical:Ae})})),t.accessibility.highContrast){const t="dark"===e.mode;e=Object.assign(Object.assign({},e),{colors:Object.assign(Object.assign({},e.colors),{text:t?"#ffffff":"#000000",textSecondary:t?"#cccccc":"#333333",grid:t?"#666666":"#999999",border:t?"#888888":"#000000"})})}return e}me.QUADTREE_THRESHOLD=500;const Ae=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],we={mode:"light",colors:{primary:"#00a2ce",secondary:"#6c757d",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",diverging:"RdBu",background:"transparent",surface:"#ffffff",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc",selection:"#00a2ce",selectionOpacity:.15,success:"#2ca02c",danger:"#d62728",warning:"#f0ad4e",error:"#b4181b",info:"#00a2ce"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},Se={mode:"dark",colors:{primary:"#4fc3f7",secondary:"#90a4ae",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",diverging:"RdBu",background:"#1a1a2e",surface:"#252540",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555",selection:"#4fc3f7",selectionOpacity:.15,success:"#81c784",danger:"#ef5350",warning:"#ffb74d",error:"#d84848",info:"#4fc3f7"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},_e={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:Ae,sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#000000",textSecondary:"#333333",grid:"#999999",border:"#000000",focus:"#0000cc",selection:"#0000cc",selectionOpacity:.1,success:"#006400",danger:"#cc0000",warning:"#b15a00",error:"#8b0000",info:"#0000cc"},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"};d.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:we,setTheme(e){t(t=>{if("light"===e)return{theme:we};if("dark"===e)return{theme:Se};if("high-contrast"===e)return{theme:_e};if(e.mode&&"auto"!==e.mode){const t="dark"===e.mode?Se:we;return{theme:ke(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:ke(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 Pe={light:we,dark:Se,"high-contrast":_e,pastels:{mode:"light",colors:{primary:"#c9a0dc",secondary:"#b8a8c8",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#fdf6f0",surface:"#fff5ee",text:"#4a3728",textSecondary:"#8b7355",grid:"#e8d5c4",border:"#e8d5c4",focus:"#c9a0dc",annotation:"#c9a0dc",success:"#9ad4a3",danger:"#e8869a",warning:"#f0c888",error:"#c86070",info:"#9cb8e0"},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",secondary:"#a899c0",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#1a1525",surface:"#251e35",text:"#e8ddf0",textSecondary:"#a899c0",grid:"#3d3455",border:"#3d3455",focus:"#c9a0dc",annotation:"#c9a0dc",success:"#88d4ab",danger:"#f0a0c0",warning:"#f0c888",error:"#e87690",info:"#9cb8e0"},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",secondary:"#6b7280",categorical:["#2563eb","#0d9488","#ea580c","#6b7280"],sequential:"blues",background:"#f5f6f8",surface:"#ffffff",text:"#2c3e50",textSecondary:"#7f8c9b",grid:"#d8dce3",border:"#d8dce3",focus:"#2563eb",annotation:"#2563eb",success:"#10b981",danger:"#ef4444",warning:"#f59e0b",error:"#dc2626",info:"#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",secondary:"#9ca3af",categorical:["#3b82f6","#14b8a6","#f97316","#9ca3af"],sequential:"blues",background:"#111827",surface:"#1f2937",text:"#f3f4f6",textSecondary:"#9ca3af",grid:"#374151",border:"#374151",focus:"#3b82f6",annotation:"#3b82f6",success:"#34d399",danger:"#f87171",warning:"#fbbf24",error:"#ef4444",info:"#60a5fa"},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",secondary:"#666666",categorical:["#cc0000","#333333","#c8a415","#4682b4"],sequential:"reds",background:"#fafafa",surface:"#ffffff",text:"#1a1a1a",textSecondary:"#666666",grid:"#e0e0e0",border:"#e0e0e0",focus:"#cc0000",annotation:"#cc0000",success:"#556b2f",danger:"#cc0000",warning:"#c8a415",error:"#8b0000",info:"#4682b4"},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",secondary:"#aaaaaa",categorical:["#ff3333","#aaaaaa","#d4a843","#6aa4d4"],sequential:"reds",background:"#0a0a0a",surface:"#1a1a1a",text:"#f5f5f5",textSecondary:"#aaaaaa",grid:"#333333",border:"#333333",focus:"#ff3333",annotation:"#ff3333",success:"#7a8b5a",danger:"#ff3333",warning:"#d4a843",error:"#cc0000",info:"#6aa4d4"},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",secondary:"#555555",categorical:["#8b4513","#556b2f","#4a5568","#800020"],sequential:"oranges",background:"#fffff8",surface:"#fffff8",text:"#111111",textSecondary:"#555555",grid:"#e0ddd0",border:"#e0ddd0",focus:"#8b0000",annotation:"#8b0000",success:"#556b2f",danger:"#8b0000",warning:"#b88700",error:"#6b0000",info:"#4a5568"},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",secondary:"#a09880",categorical:["#c08050","#7a8b5a","#8090a0","#a05060"],sequential:"oranges",background:"#1c1b18",surface:"#262520",text:"#e8e4d8",textSecondary:"#a09880",grid:"#3d3c35",border:"#3d3c35",focus:"#c05050",annotation:"#c05050",success:"#7a8b5a",danger:"#c05050",warning:"#c8a060",error:"#a04040",info:"#8090a0"},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",secondary:"#666666",categorical:["#3a86c8","#e45050","#d4a843","#888888"],sequential:"blues",background:"#ffffff",surface:"#f8f8f8",text:"#222222",textSecondary:"#666666",grid:"#d4d4d4",border:"#d4d4d4",focus:"#e45050",annotation:"#e45050",success:"#2d7a3d",danger:"#c8303a",warning:"#d4a843",error:"#a02028",info:"#3a86c8"},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",secondary:"#a0a0a0",categorical:["#5a9fd8","#ff6b6b","#e0c060","#aaaaaa"],sequential:"blues",background:"#141414",surface:"#1e1e1e",text:"#ededed",textSecondary:"#a0a0a0",grid:"#383838",border:"#383838",focus:"#ff6b6b",annotation:"#ff6b6b",success:"#6fba78",danger:"#ff6b6b",warning:"#e0c060",error:"#d04040",info:"#5a9fd8"},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",secondary:"#7c5a9e",categorical:["#8b5cf6","#ec4899","#06b6d4","#84cc16"],sequential:"viridis",background:"#fdf8ff",surface:"#ffffff",text:"#2d1b4e",textSecondary:"#7c5a9e",grid:"#e8d0f8",border:"#e8d0f8",focus:"#8b5cf6",annotation:"#8b5cf6",success:"#10d870",danger:"#ff4b6e",warning:"#ffaa33",error:"#e11d48",info:"#06b6d4"},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",secondary:"#b8a0d8",categorical:["#a78bfa","#f472b6","#22d3ee","#a3e635"],sequential:"viridis",background:"#150a28",surface:"#1f1138",text:"#f0e8ff",textSecondary:"#b8a0d8",grid:"#3a2560",border:"#3a2560",focus:"#a78bfa",annotation:"#a78bfa",success:"#4ade80",danger:"#fb7185",warning:"#fbbf24",error:"#f43f5e",info:"#22d3ee"},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",secondary:"#525252",categorical:["#6929c4","#1192e8","#005d5d","#9f1853"],sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#161616",textSecondary:"#525252",grid:"#e0e0e0",border:"#e0e0e0",focus:"#0f62fe",annotation:"#0f62fe",success:"#24a148",danger:"#da1e28",warning:"#f1c21b",error:"#a2191f",info:"#0043ce"},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",secondary:"#a8a8a8",categorical:["#a56eff","#33b1ff","#08bdba","#ff7eb6"],sequential:"blues",diverging:"RdBu",background:"#161616",surface:"#262626",text:"#f4f4f4",textSecondary:"#a8a8a8",grid:"#393939",border:"#393939",focus:"#4589ff",annotation:"#4589ff",success:"#42be65",danger:"#fa4d56",warning:"#f1c21b",error:"#da1e28",info:"#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 je(t){if(!t)return we;if("string"==typeof t){if("light"===t)return we;if("dark"===t)return Se;if("high-contrast"===t)return _e;return Pe[t]||we}const e="dark"===t.mode?Se:we;return ke(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 Me(t){var e,i,o,r;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!==(i=t.typography.legendSize)&&void 0!==i?i:t.typography.labelSize,titleFontSize:null!==(o=t.typography.titleFontSize)&&void 0!==o?o:t.typography.titleSize,tickFontFamily:null!==(r=t.typography.tickFontFamily)&&void 0!==r?r:t.typography.fontFamily}}function Oe(e){const{categories:o,colorScheme:n,theme:s,position:a="right",totalWidth:c,totalHeight:l,margin:u,hasTitle:h=!1}=e;if(!o||0===o.length)return null;const d=function(t,e,o){const n=Array.isArray(e)?e:o.colors.categorical.length>0?o.colors.categorical:r.schemeCategory10;return i.scaleOrdinal().domain(t).range(n)}(o,n,s),f="top"===a||"bottom"===a;let g,y;if("left"===a?(g=4,y=u.top):"top"===a?(g=u.left,y=h?32:8):"bottom"===a?(g=u.left,y=Math.min(l-u.bottom+38,l-16)):(g=c-u.right+10,y=u.top),f){let e=0;const i=o.map((i,o)=>{const r=e;return e+=22+6.5*i.length+8,t.jsxs("g",{transform:`translate(${r},0)`,children:[t.jsx("rect",{width:14,height:14,fill:d(i),rx:2}),t.jsx("text",{x:20,y:7,dominantBaseline:"central",fontSize:s.typography.tickSize,fill:s.colors.text,fontFamily:s.typography.fontFamily,children:i})]},"legend-"+o)});return t.jsx("g",{className:"semiotic-legend",transform:`translate(${g},${y})`,children:i})}const p=o.map((e,i)=>t.jsxs("g",{transform:`translate(0,${20*i})`,children:[t.jsx("rect",{width:14,height:14,fill:d(e),rx:2}),t.jsx("text",{x:20,y:7,dominantBaseline:"central",fontSize:s.typography.tickSize,fill:s.colors.text,fontFamily:s.typography.fontFamily,children:e})]},"legend-"+i));return t.jsx("g",{className:"semiotic-legend",transform:`translate(${g},${y})`,children:p})}function Te(t,e){if(!e||!t||0===t.length)return[];const i="function"==typeof e?e:t=>t[e],o=new Set;for(const e of t){const t=i(e);null!=t&&o.add(t+"")}return Array.from(o)}function Le(t,e){return t.color||e.colors.annotation||e.colors.text}function Ee(e){const{annotations:i}=e;if(!i||0===i.length)return null;const o=[];for(let t=0;i.length>t;t++){const r=De(i[t],t,e);r&&o.push(r)}return o.length>0?t.jsx("g",{id:(e.idPrefix?e.idPrefix+"-":"")+"annotations",className:"semiotic-annotations",children:o}):null}function De(e,i,o){var r,n,s,a;const{scales:c,layout:l,theme:u,xAccessor:h,yAccessor:d}=o;switch(e.type){case"y-threshold":{const n=e.value;if(null==n)return null;const s=Le(e,u),a=e.label,h=e.labelPosition||"right",d=e.strokeDasharray||"6,4",f=null!==(r=e.strokeWidth)&&void 0!==r?r:1.5;if("horizontal"===o.projection&&c.r){const e=c.r(n);return null==e?null:t.jsxs("g",{children:[t.jsx("line",{x1:e,y1:0,x2:e,y2:l.height,stroke:s,strokeWidth:f,strokeDasharray:d}),a&&t.jsx("text",{x:e+4,y:12,textAnchor:"start",fontSize:u.typography.tickSize,fill:s,fontFamily:u.typography.fontFamily,children:a})]},"ann-ythresh-"+i)}const g=c.y?c.y(n):c.r?c.r(n):null;return null==g?null:t.jsxs("g",{children:[t.jsx("line",{x1:0,y1:g,x2:l.width,y2:g,stroke:s,strokeWidth:f,strokeDasharray:d}),a&&t.jsx("text",{x:"left"===h?4:"center"===h?l.width/2:l.width-4,y:g-6,textAnchor:"left"===h?"start":"center"===h?"middle":"end",fontSize:u.typography.tickSize,fill:s,fontFamily:u.typography.fontFamily,children:a})]},"ann-ythresh-"+i)}case"x-threshold":{const o=e.value;if(null==o||!c.x)return null;const r=c.x(o);if(null==r)return null;const s=Le(e,u),a=e.label,h=e.labelPosition||"top",d=null!==(n=e.strokeWidth)&&void 0!==n?n:1.5;return t.jsxs("g",{children:[t.jsx("line",{x1:r,y1:0,x2:r,y2:l.height,stroke:s,strokeWidth:d,strokeDasharray:e.strokeDasharray||"6,4"}),a&&t.jsx("text",{x:r+4,y:"bottom"===h?l.height-4:"center"===h?l.height/2:12,textAnchor:"start",fontSize:u.typography.tickSize,fill:s,fontFamily:u.typography.fontFamily,children:a})]},"ann-xthresh-"+i)}case"band":{const o=null!=e.y0&&c.y?c.y(e.y0):null,r=null!=e.y1&&c.y?c.y(e.y1):null;if(null==o||null==r)return null;const n=Math.min(o,r),a=Math.abs(r-o),h=e.fill||Le(e,u),d=null!==(s=e.opacity)&&void 0!==s?s:.1;return t.jsxs("g",{children:[t.jsx("rect",{x:0,y:n,width:l.width,height:a,fill:h,opacity:d}),e.label&&t.jsx("text",{x:l.width-4,y:n+12,textAnchor:"end",fontSize:u.typography.tickSize,fill:h,fontFamily:u.typography.fontFamily,children:e.label})]},"ann-band-"+i)}case"category-highlight":{if(!e.category||!c.o)return null;const r=c.o(e.category);if(null==r)return null;const n=c.o.bandwidth?c.o.bandwidth():40,s=Le(e,u),h=null!==(a=e.opacity)&&void 0!==a?a:.1;return t.jsx("rect","horizontal"===o.projection?{x:0,y:r,width:l.width,height:n,fill:s,opacity:h}:{x:r,y:0,width:n,height:l.height,fill:s,opacity:h},"ann-cathighlight-"+i)}case"label":case"text":{const o=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}(e,c,h),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}(e,c,d);if(null==o||null==r)return null;const n=e.dx||0,s=e.dy||0,a=e.color||u.colors.text;return t.jsxs("g",{children:["label"===e.type&&t.jsx("line",{x1:o,y1:r,x2:o+n,y2:r+s,stroke:u.colors.textSecondary,strokeWidth:1}),t.jsx("text",{x:o+n,y:r+s,textAnchor:e.textAnchor||"start",fontSize:e.fontSize||u.typography.labelSize,fill:a,fontFamily:u.typography.fontFamily,fontWeight:e.fontWeight,children:e.label||e.title})]},"ann-label-"+i)}default:return null}}const ze={Sparkline:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign(Object.assign({chartType:"line",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",groupAccessor:r.lineBy||e,colorAccessor:e},o),{showAxes:!1,margin:o.margin||{top:2,right:2,bottom:2,left:2},showLegend:!1,showGrid:!1,title:void 0})},LineChart:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"line",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",groupAccessor:r.lineBy||e,colorAccessor:e,colorScheme:i,lineStyle:r.lineStyle},o)},AreaChart:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"area",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",y0Accessor:r.y0Accessor,groupAccessor:r.areaBy||e,colorAccessor:e,colorScheme:i},o)},StackedAreaChart:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"stackedarea",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",groupAccessor:r.areaBy,colorAccessor:e||r.areaBy,colorScheme:i,normalize:r.normalize},o)},Scatterplot:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"scatter",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:e,sizeAccessor:r.sizeBy,colorScheme:i},o)},CandlestickChart:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"candlestick",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.highAccessor||"high",highAccessor:r.highAccessor||"high",lowAccessor:r.lowAccessor||"low",openAccessor:r.openAccessor,closeAccessor:r.closeAccessor,candlestickStyle:r.candlestickStyle},o)},BubbleChart:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"scatter",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:e,sizeAccessor:r.sizeBy,sizeRange:r.sizeRange||[5,40],colorScheme:i},o)},ConnectedScatterplot:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"line",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:e,colorScheme:i,showPoints:!0},o)},Heatmap:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"heatmap",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",valueAccessor:r.valueAccessor,colorScheme:i||r.colorScheme||"blues",showValues:r.showValues,cellBorderColor:r.cellBorderColor},o)},BarChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>{var n;return Object.assign(Object.assign({chartType:"bar",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",projection:"horizontal"===r.orientation?"horizontal":"vertical",oSort:null!==(n=r.sort)&&void 0!==n&&n,colorAccessor:e,colorScheme:i,barPadding:r.barPadding},null!=r.roundedTop&&{roundedTop:r.roundedTop}),o)}},StackedBarChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>{var n;return Object.assign(Object.assign({chartType:"bar",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",stackBy:r.stackBy,colorAccessor:e||r.stackBy,colorScheme:i,projection:"horizontal"===r.orientation?"horizontal":"vertical",normalize:r.normalize,oSort:null!==(n=r.sort)&&void 0!==n&&n},null!=r.roundedTop&&{roundedTop:r.roundedTop}),o)}},GroupedBarChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>{var n;return Object.assign(Object.assign({chartType:"clusterbar",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",groupBy:r.groupBy,colorAccessor:e||r.groupBy,colorScheme:i,projection:"horizontal"===r.orientation?"horizontal":"vertical",oSort:null!==(n=r.sort)&&void 0!==n&&n,barPadding:r.barPadding},null!=r.roundedTop&&{roundedTop:r.roundedTop}),o)}},PieChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign(Object.assign({chartType:"pie",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",projection:"radial",colorAccessor:e||r.categoryAccessor,colorScheme:i},null!=r.cornerRadius&&{cornerRadius:r.cornerRadius}),o)},DonutChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign(Object.assign({chartType:"donut",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",projection:"radial",innerRadius:r.innerRadius||60,colorAccessor:e||r.categoryAccessor,colorScheme:i},null!=r.cornerRadius&&{cornerRadius:r.cornerRadius}),o)},Histogram:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"histogram",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",projection:"horizontal",bins:r.bins,colorAccessor:e,colorScheme:i},o)},BoxPlot:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"boxplot",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",colorScheme:i},o)},ViolinPlot:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"violin",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",bins:r.bins,colorScheme:i},o)},SwarmPlot:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"swarm",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",colorAccessor:e,colorScheme:i},o)},DotPlot:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>{var n;return Object.assign(Object.assign({chartType:"point",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",colorAccessor:e,colorScheme:i},o),{showGrid:null===(n=o.showGrid)||void 0===n||n})}},SwimlaneChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"swimlane",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",stackBy:r.subcategoryAccessor,colorAccessor:e||r.subcategoryAccessor,categoryAccessor:r.categoryAccessor,subcategoryAccessor:r.subcategoryAccessor,colorScheme:i,projection:"horizontal"===r.orientation?"horizontal":"vertical"},o)},RidgelinePlot:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"ridgeline",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",bins:r.bins,amplitude:r.amplitude},o)},LikertChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"bar",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",stackBy:r.levelAccessor||"level",colorAccessor:e||r.levelAccessor||"level",colorScheme:i,normalize:!0,projection:"vertical"===r.orientation?"vertical":"horizontal"},o)},FunnelChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>{const n="vertical"===r.orientation;return Object.assign({chartType:n?"bar-funnel":"funnel",data:t,oAccessor:r.stepAccessor||"step",rAccessor:r.valueAccessor||"value",colorAccessor:e||r.categoryAccessor,categoryAccessor:r.categoryAccessor,projection:n?"vertical":"horizontal",connectorAccessor:r.connectorAccessor,connectorStyle:r.connectorStyle,colorScheme:i},o)}},GaugeChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>{var n,s,a,c;const l=null!==(n=r.min)&&void 0!==n?n:0,u=null!==(s=r.max)&&void 0!==s?s:100,h=null!==(a=r.sweep)&&void 0!==a?a:240,d=null!==(c=r.arcWidth)&&void 0!==c?c:.3,f=180+(360-h)/2,g=r.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=o.margin||{top:20,right:20,bottom:30,left:40},[x,v]=o.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-d)),sweepAngle:h,startAngle:f,oSort:!1,pieceStyle:(t,e)=>({fill:p[e||""]||"#4e79a7"})},o),{showAxes:!1,__gauge:{gMin:l,gMax:u,sweep:h,arcWidth:d,value:r.value,startAngleDeg:f,thresholds:g}})}},ForceDirectedGraph:{frameType:"network",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"force",nodes:r.nodes,edges:r.edges,nodeIDAccessor:r.nodeIDAccessor,sourceAccessor:r.sourceAccessor,targetAccessor:r.targetAccessor,colorBy:e,colorScheme:i,iterations:r.iterations,forceStrength:r.forceStrength,showLabels:r.showLabels,nodeLabel:r.nodeLabel,nodeSize:r.nodeSize,nodeSizeRange:r.nodeSizeRange,nodeStyle:r.nodeStyle,edgeStyle:r.edgeStyle},o)},SankeyDiagram:{frameType:"network",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"sankey",nodes:r.nodes,edges:r.edges,nodeIDAccessor:r.nodeIdAccessor||r.nodeIDAccessor,sourceAccessor:r.sourceAccessor,targetAccessor:r.targetAccessor,valueAccessor:r.valueAccessor,orientation:r.orientation,nodeAlign:r.nodeAlign,nodeWidth:r.nodeWidth,nodePaddingRatio:r.nodePaddingRatio,showLabels:r.showLabels,nodeLabel:r.nodeLabel,colorBy:e,edgeColorBy:r.edgeColorBy,edgeOpacity:r.edgeOpacity,nodeStyle:r.nodeStyle,edgeStyle:r.edgeStyle,colorScheme:i},o)},ChordDiagram:{frameType:"network",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"chord",nodes:r.nodes,edges:r.edges,valueAccessor:r.valueAccessor,padAngle:r.padAngle,groupWidth:r.groupWidth,showLabels:r.showLabels,colorBy:e,edgeColorBy:r.edgeColorBy,colorScheme:i},o)},TreeDiagram:{frameType:"network",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"cluster"===r.layout?"cluster":"tree",data:t,childrenAccessor:r.childrenAccessor,colorBy:e,colorByDepth:r.colorByDepth,orientation:r.orientation,showLabels:r.showLabels,colorScheme:i},o)},Treemap:{frameType:"network",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"treemap",data:t,childrenAccessor:r.childrenAccessor,hierarchySum:r.valueAccessor,colorBy:e,colorByDepth:r.colorByDepth,showLabels:r.showLabels,colorScheme:i},o)},CirclePack:{frameType:"network",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"circlepack",data:t,childrenAccessor:r.childrenAccessor,hierarchySum:r.valueAccessor,colorBy:e,colorByDepth:r.colorByDepth,colorScheme:i},o)},ChoroplethMap:{frameType:"geo",buildProps:(t,e,i,o,r)=>Object.assign({areas:r.areas,projection:r.projection||"equalEarth",areaStyle:r.areaStyle,valueAccessor:r.valueAccessor,colorScheme:i||"blues",graticule:r.graticule,fitPadding:r.fitPadding},o)},ProportionalSymbolMap:{frameType:"geo",buildProps:(t,e,i,o,r)=>Object.assign({points:t||r.points,xAccessor:r.xAccessor||"lon",yAccessor:r.yAccessor||"lat",areas:r.areas,areaStyle:r.areaStyle,sizeBy:r.sizeBy,colorBy:e,colorScheme:i,projection:r.projection||"equalEarth",graticule:r.graticule,fitPadding:r.fitPadding},o)},FlowMap:{frameType:"geo",buildProps:(t,e,i,o,r)=>{var n,s,a,c,l;const u=(Array.isArray(t)?t:null)||r.flows||[],h=r.nodeIdAccessor||"id",d=r.valueAccessor||"value",f=r.xAccessor||"lon",g=r.yAccessor||"lat",y="function"==typeof f?f:t=>t[f],p="function"==typeof g?g:t=>t[g],m=(r.nodes||[]).map(t=>Object.assign(Object.assign({},t),{x:y(t),y:p(t)})),x=new Map;for(const t of m)x.set(t[h]+"",t);const v=null!==(n=r.edgeColorBy)&&void 0!==n?n:e,b="function"==typeof v,k=u.map(t=>{if(!t||null==t.source||null==t.target)return null;const e=x.get(t.source+""),i=x.get(t.target+"");return e&&i?Object.assign(Object.assign({},t),{coordinates:[{x:e.x,y:e.y},{x:i.x,y:i.y}]}):null}).filter(Boolean),A="__flowMapEdgeColor",w=v?b?M(k.map(t=>({[A]:v(t)})),A,i||"category10"):M(k,v,i||"category10"):null,S=t=>v&&w?function(t,e,i){if("function"==typeof e){const o=e(t);return i&&o&&"string"==typeof o&&!function(t){const e=t.toLowerCase();return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")||j.has(e)}(o)?i(o):o}const o=null==t?void 0:t[e];return i?i(o):_[Math.abs(function(t){let e=0;for(let i=0;t.length>i;i++)e=(e<<5)-e+t.charCodeAt(i),e&=e;return Math.abs(e)}(o+""))%_.length]}(t,v,w):"#007bff";let P=1/0,O=-1/0;for(const t of k){const e=Number(null!==(s=t[d])&&void 0!==s?s:0);isFinite(e)&&(P>e&&(P=e),e>O&&(O=e))}const T=O>P?O-P:0,[L,E]=null!==(a=r.edgeWidthRange)&&void 0!==a?a:[1,8],D=E-L,z=null!==(c=r.edgeOpacity)&&void 0!==c?c:.6,$=null!==(l=r.edgeLinecap)&&void 0!==l?l:"round";return Object.assign({lines:k,points:m,xAccessor:"x",yAccessor:"y",lineDataAccessor:"coordinates",lineType:r.lineType||"geo",flowStyle:r.flowStyle||"basic",areas:r.areas,areaStyle:r.areaStyle,projection:r.projection||"equalEarth",graticule:r.graticule,fitPadding:r.fitPadding,colorScheme:i,lineStyle:t=>{const e=Number(null==t?void 0:t[d]),i=L+Math.max(0,Math.min(1,T>0?((Number.isFinite(e)?e:P)-P)/T:0))*D;return{stroke:S(t),strokeWidth:i,strokeLinecap:$,opacity:z,fillOpacity:0}},pointStyle:()=>({fill:"#333",r:4,fillOpacity:.8})},o)}}};function $e(t){return Math.round(100*t)/100+""}function Ce(e,i){const o=Me(i.theme),r=i.idPrefix?i.idPrefix+"-":"",n="string"==typeof i.title?i.title:void 0,s=n?r+"semiotic-title":void 0,a=i.description?r+"semiotic-desc":void 0,c=[s,a].filter(Boolean).join(" ")||void 0;return t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:i.className,width:i.width,height:i.height,role:"img","aria-labelledby":c,style:{fontFamily:o.fontFamily},children:[n&&t.jsx("title",{id:s,children:n}),i.description&&t.jsx("desc",{id:a,children:i.description}),i.defs&&t.jsx("defs",{children:i.defs}),i.background&&"transparent"!==i.background&&t.jsx("rect",{x:0,y:0,width:i.width,height:i.height,fill:i.background}),t.jsx("g",{id:r+"data-area",transform:i.innerTransform,children:e}),n&&t.jsx("text",{id:r+"chart-title",x:i.width/2,y:16,textAnchor:"middle",fontSize:o.titleSize,fontWeight:"bold",fill:o.text,fontFamily:o.fontFamily,children:n}),i.legend&&t.jsx("g",{id:r+"legend",children:i.legend}),i.outerElements]})}function Re(e){var i,o,r,n;const s=je(e.theme),a=e.size||[500,300],c=Object.assign(Object.assign({},{top:20,right:20,bottom:30,left:40}),e.margin),l=e.legendPosition;e.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="streaming"===e.runtimeMode||["bar","swarm","waterfall"].includes(e.chartType),f={chartType:e.chartType,windowSize:null!==(i=e.windowSize)&&void 0!==i?i:200,windowMode:null!==(o=e.windowMode)&&void 0!==o?o:"sliding",arrowOfTime:d&&null!==(r=e.arrowOfTime)&&void 0!==r?r:"right",extentPadding:null!==(n=e.extentPadding)&&void 0!==n?n:.1,xAccessor:d?void 0:e.xAccessor,yAccessor:d?void 0:e.yAccessor,timeAccessor:d?e.timeAccessor:void 0,valueAccessor:e.valueAccessor,colorAccessor:e.colorAccessor,sizeAccessor:e.sizeAccessor,groupAccessor:e.groupAccessor,categoryAccessor:e.categoryAccessor,lineDataAccessor:e.lineDataAccessor,xExtent:e.xExtent,yExtent:e.yExtent,sizeRange:e.sizeRange,binSize:e.binSize,normalize:e.normalize,boundsAccessor:e.boundsAccessor,boundsStyle:e.boundsStyle,openAccessor:e.openAccessor,highAccessor:e.highAccessor,lowAccessor:e.lowAccessor,closeAccessor:e.closeAccessor,candlestickStyle:e.candlestickStyle,lineStyle:e.lineStyle,pointStyle:e.pointStyle,areaStyle:e.areaStyle,colorScheme:e.colorScheme||s.colors.categorical,barColors:e.barColors},y=new q(f);if(e.data&&y.ingest({inserts:e.data,bounded:!0}),y.computeScene({width:u,height:h}),!y.scales||0===y.scene.length)return g.renderToStaticMarkup(Ce(null,{width:a[0],height:a[1],className:"stream-xy-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:s,innerTransform:`translate(${c.left},${c.top})`,idPrefix:e._idPrefix}));const p=e._idPrefix,m=e.showGrid?function(e,i,o,r){const{grid:n}=Me(o),s=r?r+"-":"",a=e.x.ticks(5),c=e.y.ticks(5);return t.jsxs("g",{id:s+"grid",className:"semiotic-grid",opacity:.8,children:[a.map((o,r)=>{const s=e.x(o);return t.jsx("line",{x1:s,y1:0,x2:s,y2:i.height,stroke:n,strokeWidth:.5},"gx-"+r)}),c.map((o,r)=>{const s=e.y(o);return t.jsx("line",{x1:0,y1:s,x2:i.width,y2:s,stroke:n,strokeWidth:.5},"gy-"+r)})]})}(y.scales,{width:u,height:h},s,p):null,x=y.scene.map((t,e)=>ve(t,e)).filter(Boolean),v=!1!==e.showAxes?function(e,i,o,r,n){var s,a,c,l;const u=Me(r),h=e.x.ticks(5).map(t=>({pixel:e.x(t),label:(o.xFormat||o.tickFormatTime||$e)(t)})),d=e.y.ticks(5).map(t=>({pixel:e.y(t),label:(o.yFormat||o.tickFormatValue||$e)(t)}));return t.jsxs("g",{id:(n?n+"-":"")+"axes",className:"stream-axes",children:[t.jsx("line",{x1:0,y1:i.height,x2:i.width,y2:i.height,stroke:u.border,strokeWidth:1}),h.map((e,o)=>t.jsxs("g",{transform:`translate(${e.pixel},${i.height})`,children:[t.jsx("line",{y2:5,stroke:u.border,strokeWidth:1}),t.jsx("text",{y:18,textAnchor:"middle",fontSize:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:e.label})]},"xtick-"+o)),o.xLabel&&t.jsx("text",{x:i.width/2,y:i.height+40,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,children:o.xLabel}),t.jsx("line",{x1:0,y1:0,x2:0,y2:i.height,stroke:u.border,strokeWidth:1}),d.map((e,i)=>t.jsxs("g",{transform:`translate(0,${e.pixel})`,children:[t.jsx("line",{x2:-5,stroke:u.border,strokeWidth:1}),t.jsx("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:e.label})]},"ytick-"+i)),o.yLabel&&t.jsx("text",{x:15-(null!==(a=null===(s=o.margin)||void 0===s?void 0:s.left)&&void 0!==a?a:40),y:i.height/2,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,transform:`rotate(-90, ${15-(null!==(l=null===(c=o.margin)||void 0===c?void 0:c.left)&&void 0!==l?l:40)}, ${i.height/2})`,children:o.yLabel})]})}(y.scales,{width:u,height:h},e,s,p):null,b=e.annotations?Ee({annotations:e.annotations,scales:{x:y.scales.x,y:y.scales.y},layout:{width:u,height:h},theme:s,xAccessor:"string"==typeof e.xAccessor?e.xAccessor:void 0,yAccessor:"string"==typeof e.yAccessor?e.yAccessor:void 0,idPrefix:p}):null,k=e.showLegend?(()=>{const t=Te(e.data||[],e.colorAccessor||e.groupAccessor);return 0===t.length?null:Oe({categories:t,colorScheme:e.colorScheme,theme:s,position:e.legendPosition||"right",totalWidth:a[0],totalHeight:a[1],margin:c,hasTitle:!!e.title})})():null,A=t.jsxs(t.Fragment,{children:[m,b,x,v]});return g.renderToStaticMarkup(Ce(A,{width:a[0],height:a[1],className:"stream-xy-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:s,innerTransform:`translate(${c.left},${c.top})`,legend:k,idPrefix:e._idPrefix}))}function Ne(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}const Be=new Set(["tree","cluster","treemap","circlepack","partition"]);function We(e){const i=je(e.theme),o=e.chartType||"force",r=e.size||[500,500],n=Object.assign(Object.assign({},{top:20,right:20,bottom:20,left:20}),e.margin),s=r[0]-n.left-n.right,a=r[1]-n.top-n.bottom,c=function(t){return re[t]}(o);if(!c)throw Error(`No layout plugin found for chart type: "${o}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition.`);const u={chartType:o,nodeIDAccessor:e.nodeIDAccessor,sourceAccessor:e.sourceAccessor,targetAccessor:e.targetAccessor,valueAccessor:e.valueAccessor,childrenAccessor:e.childrenAccessor,hierarchySum:e.hierarchySum,orientation:e.orientation,nodeAlign:e.nodeAlign,nodePaddingRatio:e.nodePaddingRatio,nodeWidth:e.nodeWidth,iterations:e.iterations,forceStrength:e.forceStrength,padAngle:e.padAngle,groupWidth:e.groupWidth,sortGroups:e.sortGroups,edgeSort:e.edgeSort,treeOrientation:e.treeOrientation,edgeType:e.edgeType,padding:e.padding,paddingTop:e.paddingTop,nodeStyle:e.nodeStyle,edgeStyle:e.edgeStyle,nodeLabel:e.nodeLabel,showLabels:e.showLabels,colorBy:e.colorBy,colorScheme:e.colorScheme||i.colors.categorical,edgeColorBy:e.edgeColorBy,edgeOpacity:e.edgeOpacity,colorByDepth:e.colorByDepth,nodeSize:e.nodeSize,nodeSizeRange:e.nodeSizeRange};let h,d;if(Be.has(o)){const t=e.data||e.edges;if(!t||Array.isArray(t))return g.renderToStaticMarkup(Ce(null,{width:r[0],height:r[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${n.left},${n.top})`,idPrefix:e._idPrefix}));u.__hierarchyRoot=t,h=[],d=[]}else{const t=e.nodes||[],o=Array.isArray(e.edges)?e.edges:[];if(0===t.length&&0===o.length)return g.renderToStaticMarkup(Ce(null,{width:r[0],height:r[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${n.left},${n.top})`,idPrefix:e._idPrefix}));if(d=function(t,e){const i=Ne(e.sourceAccessor,"source"),o=Ne(e.targetAccessor,"target"),r=Ne(e.valueAccessor,"value");return t.map(t=>({source:i(t)+"",target:o(t)+"",value:Number(r(t))||1,y0:0,y1:0,sankeyWidth:0,data:t}))}(o,u),0===t.length&&d.length>0){const t=new Set;for(const e of d){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)}h=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 h=function(t,e){const i=Ne(e.nodeIDAccessor,"id");return t.map(t=>{var e,o;return{id:i(t)+"",x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(o=t.y)&&void 0!==o?o:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:t}})}(t,u)}c.computeLayout(h,d,u,[s,a]);const{sceneNodes:f,sceneEdges:y,labels:p}=c.buildScene(h,d,u,[s,a]),m=Me(i);for(const t of p)t.fill||(t.fill=m.text);const x=y.map((e,i)=>function(e,i){switch(e.type){case"line":return t.jsx("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity},"net-edge-"+i);case"bezier":{const o=e;return t.jsx("path",{d:o.pathD,fill:xe(o.style.fill,"#999"),fillOpacity:o.style.fillOpacity,stroke:o.style.stroke||"none",strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-edge-"+i)}case"ribbon":{const o=e;return t.jsx("path",{d:o.pathD,fill:xe(o.style.fill,"#999"),fillOpacity:o.style.fillOpacity,stroke:o.style.stroke||"none",strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-edge-"+i)}case"curved":{const o=e;return t.jsx("path",{d:o.pathD,fill:xe(o.style.fill,"none"),stroke:o.style.stroke||"#999",strokeWidth:o.style.strokeWidth||1,opacity:o.style.opacity},"net-edge-"+i)}default:return null}}(e,i)).filter(Boolean),v=f.map((e,i)=>function(e,i){switch(e.type){case"circle":{const o=e;return t.jsx("circle",{cx:o.cx,cy:o.cy,r:o.r,fill:xe(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-circle-"+i)}case"rect":{const o=e;return t.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:xe(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-rect-"+i)}case"arc":{const o=e,r=l.arc().innerRadius(o.innerR).outerRadius(o.outerR).startAngle(o.startAngle+Math.PI/2).endAngle(o.endAngle+Math.PI/2)({})||"";return t.jsx("path",{d:r,transform:`translate(${o.cx},${o.cy})`,fill:xe(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-arc-"+i)}default:return null}}(e,i)).filter(Boolean),b=p.map((e,i)=>function(e,i){return t.jsx("text",{x:e.x,y:e.y,textAnchor:e.anchor||"middle",dominantBaseline:e.baseline||"auto",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"#333",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,children:e.text},"net-label-"+i)}(e,i)).filter(Boolean),k=t.jsxs(t.Fragment,{children:[x,v,b]});return g.renderToStaticMarkup(Ce(k,{width:r[0],height:r[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${n.left},${n.top})`,idPrefix:e._idPrefix}))}function Fe(e){var i,o,r,n,s;const a=je(e.theme),c=e.size||[500,400],l=Object.assign(Object.assign({},{top:20,right:20,bottom:30,left:40}),e.margin),u=e.legendPosition;e.showLegend&&(u&&"right"!==u?"left"===u?l.left=Math.max(l.left,100):"bottom"===u?l.bottom=Math.max(l.bottom,70):"top"===u&&(l.top=Math.max(l.top,40)):l.right=Math.max(l.right,100));const h=c[0]-l.left-l.right,d=c[1]-l.top-l.bottom,f=e.projection||"vertical",y="radial"===f,p={chartType:e.chartType,windowSize:null!==(i=e.windowSize)&&void 0!==i?i:1e4,windowMode:null!==(o=e.windowMode)&&void 0!==o?o:"sliding",extentPadding:null!==(r=e.extentPadding)&&void 0!==r?r:.05,projection:f,oAccessor:e.oAccessor,rAccessor:e.rAccessor,colorAccessor:e.colorAccessor,stackBy:e.stackBy,groupBy:e.groupBy,categoryAccessor:e.categoryAccessor,valueAccessor:e.valueAccessor,timeAccessor:e.timeAccessor,rExtent:e.rExtent,oExtent:e.oExtent,barPadding:e.barPadding,roundedTop:e.roundedTop,innerRadius:e.innerRadius,cornerRadius:e.cornerRadius,normalize:e.normalize,startAngle:e.startAngle,sweepAngle:e.sweepAngle,bins:e.bins,showOutliers:e.showOutliers,showIQR:e.showIQR,amplitude:e.amplitude,oSort:e.oSort,connectorAccessor:e.connectorAccessor,connectorStyle:e.connectorStyle,dynamicColumnWidth:e.dynamicColumnWidth,pieceStyle:e.pieceStyle,summaryStyle:e.summaryStyle,colorScheme:e.colorScheme||a.colors.categorical,barColors:e.barColors},m=new ce(p);if(e.data&&m.ingest({inserts:e.data,bounded:!0}),m.computeScene({width:h,height:d}),!m.scales||0===m.scene.length)return g.renderToStaticMarkup(Ce(null,{width:c[0],height:c[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:a,innerTransform:`translate(${l.left},${l.top})`,idPrefix:e._idPrefix}));const x=e._idPrefix,v=e.showGrid?function(e,i,o,r){const n=e.scales;if(!n||"radial"===n.projection)return null;const{grid:s}=Me(o),a=r?r+"-":"",c="vertical"===n.projection,l=n.r.ticks(5);return t.jsx("g",c?{id:a+"grid",className:"semiotic-grid",opacity:.8,children:l.map((e,o)=>{const r=n.r(e);return t.jsx("line",{x1:0,y1:r,x2:i.width,y2:r,stroke:s,strokeWidth:.5},"gr-"+o)})}:{id:a+"grid",className:"semiotic-grid",opacity:.8,children:l.map((e,o)=>{const r=n.r(e);return t.jsx("line",{x1:r,y1:0,x2:r,y2:i.height,stroke:s,strokeWidth:.5},"gr-"+o)})})}(m,{width:h,height:d},a,x):null,b=m.scene.some(t=>{var e;return"rect"===t.type&&(null===(e=t.datum)||void 0===e?void 0:e.__barFunnelIsDropoff)});let k=null;if(b){const i=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 o=0;for(let t=0;i.length>t;t++)o=31*o+i.charCodeAt(t)|0;return"c"+(o>>>0).toString(36)}(e),o=new Set;for(const t of m.scene)"rect"===t.type&&(null===(n=t.datum)||void 0===n?void 0:n.__barFunnelIsDropoff)&&o.add("string"==typeof t.style.fill?t.style.fill:"#666");k=Array.from(o).map((e,o)=>function(e){const{id:i,background:o="transparent",stroke:r="#000",lineWidth:n=1.5,spacing:s=6,angle:a=45}=e,c=Math.max(8,Math.ceil(2*s));return t.jsxs("pattern",{id:i,width:c,height:c,patternUnits:"userSpaceOnUse",patternTransform:0!==a?`rotate(${a})`:void 0,children:[o&&"transparent"!==o&&t.jsx("rect",{width:c,height:c,fill:o}),t.jsx("line",{x1:0,y1:0,x2:0,y2:c,stroke:r,strokeWidth:n}),t.jsx("line",{x1:s,y1:0,x2:s,y2:c,stroke:r,strokeWidth:n})]},i)}({id:`funnel-hatch-${i}-${o}`,background:e,stroke:"transparent"===a.colors.background?"#fff":a.colors.background,lineWidth:1.5,spacing:5,angle:45}));const r=new Map;Array.from(o).forEach((t,e)=>r.set(t,`funnel-hatch-${i}-${e}`));for(const t of m.scene)if("rect"===t.type&&(null===(s=t.datum)||void 0===s?void 0:s.__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 A=m.scene.map((t,e)=>be(t,e)).filter(Boolean),w=!1!==e.showAxes?function(e,i,o,r,n){var s,a,c,l,u,h,d,f;const g=e.scales;if(!g)return null;if("radial"===g.projection)return null;const y=Me(r),p="vertical"===g.projection,m=o.categoryFormat||o.oFormat,x=o.valueFormat||o.rFormat,v=o.categoryLabel||o.oLabel,b=o.valueLabel||o.rLabel,k=Object.values(e.columns).map(t=>({pixel:t.middle,label:(m||String)(t.name)})),A=g.r.ticks(5).map(t=>({pixel:g.r(t),label:(x||$e)(t)}));return t.jsxs("g",p?{id:(n?n+"-":"")+"axes",className:"ordinal-axes",children:[t.jsx("line",{x1:0,y1:i.height,x2:i.width,y2:i.height,stroke:y.border,strokeWidth:1}),k.map((e,o)=>t.jsxs("g",{transform:`translate(${e.pixel},${i.height})`,children:[t.jsx("line",{y2:5,stroke:y.border,strokeWidth:1}),t.jsx("text",{y:18,textAnchor:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily,children:e.label})]},"oxtick-"+o)),v&&t.jsx("text",{x:i.width/2,y:i.height+40,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily,children:v}),t.jsx("line",{x1:0,y1:0,x2:0,y2:i.height,stroke:y.border,strokeWidth:1}),A.map((e,i)=>t.jsxs("g",{transform:`translate(0,${e.pixel})`,children:[t.jsx("line",{x2:-5,stroke:y.border,strokeWidth:1}),t.jsx("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily,children:e.label})]},"oytick-"+i)),b&&t.jsx("text",{x:15-(null!==(a=null===(s=o.margin)||void 0===s?void 0:s.left)&&void 0!==a?a:40),y:i.height/2,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily,transform:`rotate(-90, ${15-(null!==(l=null===(c=o.margin)||void 0===c?void 0:c.left)&&void 0!==l?l:40)}, ${i.height/2})`,children:b})]}:{id:(n?n+"-":"")+"axes",className:"ordinal-axes",children:[t.jsx("line",{x1:0,y1:i.height,x2:i.width,y2:i.height,stroke:y.border,strokeWidth:1}),A.map((e,o)=>t.jsxs("g",{transform:`translate(${e.pixel},${i.height})`,children:[t.jsx("line",{y2:5,stroke:y.border,strokeWidth:1}),t.jsx("text",{y:18,textAnchor:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily,children:e.label})]},"oxtick-"+o)),b&&t.jsx("text",{x:i.width/2,y:i.height+40,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily,children:b}),t.jsx("line",{x1:0,y1:0,x2:0,y2:i.height,stroke:y.border,strokeWidth:1}),k.map((e,i)=>t.jsxs("g",{transform:`translate(0,${e.pixel})`,children:[t.jsx("line",{x2:-5,stroke:y.border,strokeWidth:1}),t.jsx("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily,children:e.label})]},"oytick-"+i)),v&&t.jsx("text",{x:15-(null!==(h=null===(u=o.margin)||void 0===u?void 0:u.left)&&void 0!==h?h:40),y:i.height/2,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily,transform:`rotate(-90, ${15-(null!==(f=null===(d=o.margin)||void 0===d?void 0:d.left)&&void 0!==f?f:40)}, ${i.height/2})`,children:v})]})}(m,{width:h,height:d},e,a,x):null,S=e.annotations?Ee({annotations:e.annotations,scales:{r:m.scales.r,y:"vertical"===m.scales.projection?m.scales.r:void 0},layout:{width:h,height:d},theme:a,projection:f,idPrefix:x}):null,_=e.showLegend?(()=>{const t=Te(e.data||[],e.colorAccessor||e.stackBy||e.groupBy);return 0===t.length?null:Oe({categories:t,colorScheme:e.colorScheme,theme:a,position:e.legendPosition||"right",totalWidth:c[0],totalHeight:c[1],margin:l,hasTitle:!!e.title})})():null,P=y?l.left+h/2:l.left,j=y?l.top+d/2:l.top,M=t.jsxs(t.Fragment,{children:[v,S,A,w]});return g.renderToStaticMarkup(Ce(M,{width:c[0],height:c[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:a,innerTransform:`translate(${P},${j})`,legend:_,defs:k,idPrefix:e._idPrefix}))}function Ye(e){var i,o,r,n,s,a,c,l;const u=je(e.theme),h=e.size||[e.width||600,e.height||400],d=Object.assign(Object.assign({},{top:10,right:10,bottom:10,left:10}),e.margin),f=h[0]-(null!==(i=d.left)&&void 0!==i?i:0)-(null!==(o=d.right)&&void 0!==o?o:0),y=h[1]-(null!==(r=d.top)&&void 0!==r?r:0)-(null!==(n=d.bottom)&&void 0!==n?n:0),p=new me({projection:e.projection||"equalEarth",xAccessor:e.xAccessor,yAccessor:e.yAccessor,lineDataAccessor:e.lineDataAccessor,pointIdAccessor:e.pointIdAccessor,lineType:e.lineType,areaStyle:e.areaStyle,pointStyle:e.pointStyle,lineStyle:e.lineStyle,graticule:e.graticule,fitPadding:e.fitPadding,projectionTransform:e.projectionTransform});if(e.areas){if("string"==typeof e.areas)throw Error(`Geo SSR requires pre-resolved GeoJSON features. Reference string "${e.areas}" cannot be resolved synchronously. Use \`const features = await resolveReferenceGeography('${e.areas}')\` before calling renderGeoToStaticSVG.`);p.setAreas(e.areas)}if(e.points&&p.setPoints(e.points),e.lines&&p.setLines(e.lines),p.computeScene({width:f,height:y}),0===p.scene.length)return g.renderToStaticMarkup(Ce(null,{width:h[0],height:h[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:u,innerTransform:`translate(${null!==(s=d.left)&&void 0!==s?s:0},${null!==(a=d.top)&&void 0!==a?a:0})`,idPrefix:e._idPrefix}));const m=p.scene.map((e,i)=>function(e,i){var o,r,n,s,a,c;switch(e.type){case"geoarea":{const n=e;return n.pathData?t.jsx("path",{d:n.pathData,fill:xe(n.style.fill,"#e0e0e0"),fillOpacity:null!==(o=n.style.fillOpacity)&&void 0!==o?o:1,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth||.5,strokeDasharray:n.style.strokeDasharray,opacity:null!==(r=n._decayOpacity)&&void 0!==r?r:1},"geoarea-"+i):null}case"point":{const o=e;return t.jsx("circle",{cx:o.x,cy:o.y,r:o.r,fill:xe(o.style.fill),fillOpacity:null!==(n=o.style.fillOpacity)&&void 0!==n?n:.8,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:null!==(s=o._decayOpacity)&&void 0!==s?s:null!==(a=o.style.opacity)&&void 0!==a?a:1},"point-"+i)}case"line":{const o=e;if(2>o.path.length)return null;const r="M"+o.path.map(t=>`${t[0]},${t[1]}`).join("L");return t.jsx("path",{d:r,fill:"none",stroke:o.style.stroke||"#4e79a7",strokeWidth:o.style.strokeWidth||1.5,strokeDasharray:o.style.strokeDasharray,opacity:null!==(c=o.style.opacity)&&void 0!==c?c:1},"line-"+i)}default:return null}}(e,i)).filter(Boolean),x=t.jsx(t.Fragment,{children:m});return g.renderToStaticMarkup(Ce(x,{width:h[0],height:h[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:u,innerTransform:`translate(${null!==(c=d.left)&&void 0!==c?c:0},${null!==(l=d.top)&&void 0!==l?l:0})`,idPrefix:e._idPrefix}))}function Ie(t,e){switch(t){case"xy":return Re(e);case"ordinal":return Fe(e);case"network":return We(e);case"geo":return Ye(e);default:throw Error(`Unknown frame type: ${t}. Must be "xy", "ordinal", "network", or "geo".`)}}function Xe(e,i,o){var r;const{data:n,width:s=600,height:a=400,theme:c,title:l,description:u,showLegend:h,showGrid:d,background:f,className:y,annotations:p,margin:m,colorScheme:x,colorBy:v,legendPosition:b}=i,k=function(t,e){var i={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&0>e.indexOf(o)&&(i[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(t);o.length>r;r++)0>e.indexOf(o[r])&&Object.prototype.propertyIsEnumerable.call(t,o[r])&&(i[o[r]]=t[o[r]])}return i}(i,["data","width","height","theme","title","description","showLegend","showGrid","background","className","annotations","margin","colorScheme","colorBy","legendPosition"]),A=[s,a],w=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},k.frameProps||{}),{theme:c,title:l,description:u,showLegend:h,showGrid:d,background:f,className:y,annotations:p,size:A}),void 0!==m&&{margin:m}),void 0!==x&&{colorScheme:x}),void 0!==b&&{legendPosition:b}),{_idPrefix:k._idPrefix}),S=ze[e];if(!S)throw Error(`Unknown chart component: "${e}". See CLAUDE.md for supported chart types.`);const _=S.buildProps(n,v,x,w,k);let P=(0,{xy:Re,ordinal:Fe,network:We,geo:Ye}[S.frameType])(_);if("GaugeChart"===e&&_.__gauge){const e=_.__gauge,i=w.margin||{top:20,right:20,bottom:30,left:40},o=(s||300)-i.left-i.right,n=(a||300)-i.top-i.bottom,l=Math.min(o,n)/2*.85,u=i.left+o/2,h=i.top+n/2,d=Math.max(e.gMin,Math.min(e.gMax,null!==(r=e.value)&&void 0!==r?r:e.gMin)),f=(e.startAngleDeg+(e.gMax===e.gMin?0:(d-e.gMin)/(e.gMax-e.gMin))*e.sweep-90)*Math.PI/180,y=je(c).colors.text,p=g.renderToStaticMarkup(t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:u,y1:h,x2:u+l*Math.cos(f),y2:h+l*Math.sin(f),stroke:y,strokeWidth:2.5,strokeLinecap:"round"}),t.jsx("circle",{cx:u,cy:h,r:4,fill:y})]}));P=P.replace("</svg>",p+"</svg>")}return P}function qe(t,e,i,o={}){const{stepSize:r,windowSize:n,frameCount:s,xExtent:a,yExtent:c,transitionFrames:l=4,fps:u=12,easing:h="ease-out",decay:d}=o,f=i.width||600,g=i.height||400,y=je(i.theme),p=Object.assign(Object.assign(Object.assign({},i),a&&{xExtent:a}),c&&{yExtent:c});if(!e||0===e.length)return[];const m=r||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},i.margin),k=f-b.left-b.right,A=g-b.top-b.bottom,w=[];if(v)for(let o=0;x.length>o;o++){const r=x[o],s=e.slice(n?Math.max(0,r-n):0,r),a=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},d&&{decay:d}),c=new ce(a);c.ingest({inserts:s,bounded:!0}),c.computeScene({width:k,height:A}),c.scene.length>0&&w.push(He(c.scene,f,g,y,p))}else for(let o=0;x.length>o;o++){const r=x[o],s=e.slice(n?Math.max(0,r-n):0,r),m=Object.assign(Object.assign({chartType:t,windowSize:s.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:a,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},d&&{decay:d}),l>0&&{transition:{duration:l*(1e3/u),easing:h}}),v=new q(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(Ve(v.scene,f,g,y,p,b)),l>0&&o>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(Ve(v.scene,f,g,y,p,b))}}return w}function Ge(t,e){const i=t.background||e.colors.background;return i&&"transparent"!==i?i:null}function Ve(e,i,o,r,n,s){const a=Me(r),c=Object.assign({top:20,right:20,bottom:30,left:40},n.margin),l=i-c.left-c.right,u=o-c.top-c.bottom,h=Ge(n,r),d=e.map((t,e)=>ve(t,e)).filter(Boolean),f=function(e,i,o,r,n,s){var a;if(!e||0===e.length)return null;const c=Me(r),l=[];for(let r=0;e.length>r;r++){const u=e[r];if("y-threshold"===u.type&&null!=u.value){let e=null;if(s)e=s(u.value);else if(n){const[t,i]=n,r=i-t;if(0===r)continue;e=o-(u.value-t)/r*o}if(null==e)continue;const h=u.color||c.primary,d=null!==(a=u.strokeWidth)&&void 0!==a?a:1.5,f=u.labelPosition||"right";l.push(t.jsxs("g",{children:[t.jsx("line",{x1:0,y1:e,x2:i,y2:e,stroke:h,strokeWidth:d,strokeDasharray:u.strokeDasharray||"6,4"}),u.label&&t.jsx("text",{x:"left"===f?4:"center"===f?i/2:i-4,y:e-5,textAnchor:"left"===f?"start":"center"===f?"middle":"end",fontSize:c.tickSize,fill:h,fontFamily:c.fontFamily,children:u.label})]},"ann-"+r))}}return l.length>0?t.jsx(t.Fragment,{children:l}):null}(n.annotations,l,u,r,n.yExtent,null==s?void 0:s.y),y="string"==typeof n.title?n.title:void 0,p="string"==typeof n.description?n.description:void 0,m=y?"semiotic-title":void 0,x=p?"semiotic-desc":void 0,v=[m,x].filter(Boolean).join(" ")||void 0,b=t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:i,height:o,role:"img","aria-labelledby":v,style:{fontFamily:a.fontFamily},children:[y&&t.jsx("title",{id:m,children:y}),p&&t.jsx("desc",{id:x,children:p}),h&&t.jsx("rect",{x:0,y:0,width:i,height:o,fill:h}),t.jsxs("g",{transform:`translate(${c.left},${c.top})`,children:[f,d]}),y&&t.jsx("text",{x:i/2,y:16,textAnchor:"middle",fontSize:a.titleSize,fontWeight:"bold",fill:a.text,fontFamily:a.fontFamily,children:y})]});return g.renderToStaticMarkup(b)}function He(e,i,o,r,n){const s=Me(r),a=Object.assign({top:20,right:20,bottom:30,left:40},n.margin),c="radial"===n.projection,l=c?a.left+(i-a.left-a.right)/2:a.left,u=c?a.top+(o-a.top-a.bottom)/2:a.top,h=Ge(n,r),d=e.map((t,e)=>be(t,e)).filter(Boolean),f="string"==typeof n.title?n.title:void 0,y="string"==typeof n.description?n.description:void 0,p=f?"semiotic-title":void 0,m=y?"semiotic-desc":void 0,x=[p,m].filter(Boolean).join(" ")||void 0,v=t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:i,height:o,role:"img","aria-labelledby":x,style:{fontFamily:s.fontFamily},children:[f&&t.jsx("title",{id:p,children:f}),y&&t.jsx("desc",{id:m,children:y}),h&&t.jsx("rect",{x:0,y:0,width:i,height:o,fill:h}),t.jsx("g",{transform:`translate(${l},${u})`,children:d}),f&&t.jsx("text",{x:i/2,y:16,textAnchor:"middle",fontSize:s.titleSize,fontWeight:"bold",fill:s.text,fontFamily:s.fontFamily,children:f})]});return g.renderToStaticMarkup(v)}exports.generateFrameSVGs=qe,exports.generateFrameSequence=function(t,e,i={}){return e.map(e=>{try{return Xe(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=Xe,exports.renderDashboard=function(e,i={}){var o;const{title:r,subtitle:n,theme:s,width:a=1200,height:c,layout:l={},background:u}=i,h=Me(je(s)),d=l.columns||2,f=null!==(o=l.gap)&&void 0!==o?o:16;let y=0;r&&(y+=30),n&&(y+=20),y>0&&(y+=10);const p=Math.floor((a-f-f*(d-1))/d),m=[];let x=0,v=y+f,b=0;for(const t of e){const e=Math.min(t.colSpan||1,d),i=t.props.height||300;x+e>d&&(v+=b+f,x=0,b=0),m.push({chart:t,x:f/2+x*(p+f),y:v,w:p*e+f*(e-1),h:i}),b=Math.max(b,i),x+=e}const k=c||v+b+f,A=m.map((e,i)=>{const{chart:o,x:r,y:n,w:a,h:c}=e,l=Object.assign(Object.assign({},o.props),{width:a,height:c,theme:s,_idPrefix:"chart-"+i});let u;return u=o.component?Xe(o.component,l):o.frameType?Ie(o.frameType,l):`<svg xmlns="http://www.w3.org/2000/svg" width="${a}" height="${c}"></svg>`,t.jsx("g",{transform:`translate(${r},${n})`,children:t.jsx("foreignObject",{width:a,height:c,children:t.jsx("div",{xmlns:"http://www.w3.org/1999/xhtml",dangerouslySetInnerHTML:{__html:u}})})},"dashboard-chart-"+i)}),w=t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:a,height:k,role:"img","aria-label":r||"Dashboard",style:{fontFamily:h.fontFamily},children:[r&&t.jsx("title",{children:r}),u&&t.jsx("rect",{x:0,y:0,width:a,height:k,fill:u}),r&&t.jsx("text",{x:a/2,y:24,textAnchor:"middle",fontSize:h.titleSize+4,fontWeight:"bold",fill:h.text,fontFamily:h.fontFamily,children:r}),n&&t.jsx("text",{x:a/2,y:r?46:20,textAnchor:"middle",fontSize:h.labelSize,fill:h.textSecondary,fontFamily:h.fontFamily,children:n}),A]});return g.renderToStaticMarkup(w)},exports.renderGeoToStaticSVG=function(t){return Ye(t)},exports.renderNetworkToStaticSVG=function(t){return We(t)},exports.renderOrdinalToStaticSVG=function(t){return Fe(t)},exports.renderToAnimatedGif=function(t,e,i){return p(this,arguments,void 0,function*(t,e,i,o={}){const{fps:r=12,loop:n=!0,scale:s=1,background:a}=o,c=i.height||400,l=Math.round((i.width||600)*s),u=Math.round(c*s),h=qe(t,e,a?Object.assign(Object.assign({},i),{background:a}):i,o);if(0===h.length)throw Error("No frames generated — check that data is not empty");let d,f,g,y;try{d=require("sharp")}catch(t){throw Error('Animated GIF export requires "sharp". Install it:\n npm install sharp')}try{const t=require("gifenc");f=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/r),m=f();for(let t=0;h.length>t;t++){const e=h[t],i=yield d(Buffer.from(e),{density:72*s}).resize(l,u).ensureAlpha().raw().toBuffer(),o=new Uint8Array(i),r=g(o,256),a=y(o,r);m.writeFrame(a,l,u,{palette:r,delay:p,repeat:n?0:-1})}return m.finish(),Buffer.from(m.bytes())})},exports.renderToImage=function(t,e){return p(this,arguments,void 0,function*(t,e,i={}){var o,r;const{format:n="png",scale:s=1,background:a}=i;let c,l;c=["xy","ordinal","network","geo"].includes(t)?Ie(t,e):Xe(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===(o=e.size)||void 0===o?void 0:o[0])||600,h=e.height||(null===(r=e.size)||void 0===r?void 0:r[1])||400,d=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?d.jpeg({quality:90}).toBuffer():d.png().toBuffer()})},exports.renderToStaticSVG=Ie,exports.renderXYToStaticSVG=function(t){return Re(t)},exports.resolveTheme=je,exports.themeStyles=Me;
|