@redsift/charts 7.8.1 → 8.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -1,44 +1,106 @@
1
- import { scaleOrdinal, select, axisBottom, scaleLinear, sum, pie, arc } from 'd3';
2
- import { RedsiftDataVizColorBlueDefault, RedsiftDataVizColorPurpleDefault, RedsiftDataVizColorGreenDefault, RedsiftDataVizColorRedDefault, RedsiftDataVizColorPinkDefault, RedsiftDataVizColorCyanDefault, RedsiftDataVizColorOrangeDefault, RedsiftDataVizColorYellowDefault, RedsiftDataVizColorBrownDefault, RedsiftDataVizColorGreyDefault, RedsiftDataVizColorPurpleDark, RedsiftDataVizColorBlueDark, RedsiftDataVizColorGreenDark, RedsiftDataVizColorRedDark, RedsiftDataVizColorPinkDark, RedsiftDataVizColorCyanDark, RedsiftDataVizColorOrangeDark, RedsiftDataVizColorYellowDark, RedsiftDataVizColorBrownDark, RedsiftDataVizColorGreyDark, RedsiftDataVizColorPurpleDarker, RedsiftDataVizColorBlueDarker, RedsiftDataVizColorGreenDarker, RedsiftDataVizColorRedDarker, RedsiftDataVizColorPinkDarker, RedsiftDataVizColorCyanDarker, RedsiftDataVizColorOrangeDarker, RedsiftDataVizColorYellowDarker, RedsiftDataVizColorBrownDarker, RedsiftDataVizColorGreyDarker, RedsiftDataVizColorPurpleLight, RedsiftDataVizColorBlueLight, RedsiftDataVizColorGreenLight, RedsiftDataVizColorRedLight, RedsiftDataVizColorPinkLight, RedsiftDataVizColorCyanLight, RedsiftDataVizColorOrangeLight, RedsiftDataVizColorYellowLight, RedsiftDataVizColorBrownLight, RedsiftDataVizColorGreyLight, RedsiftDataVizColorPurpleLighter, RedsiftDataVizColorBlueLighter, RedsiftDataVizColorGreenLighter, RedsiftDataVizColorRedLighter, RedsiftDataVizColorPinkLighter, RedsiftDataVizColorCyanLighter, RedsiftDataVizColorOrangeLighter, RedsiftDataVizColorYellowLighter, RedsiftDataVizColorBrownLighter, RedsiftDataVizColorGreyLighter, Flexbox, Text, Number as Number$1 } from '@redsift/design-system';
3
- import React, { forwardRef, useRef, useEffect, useId } from 'react';
1
+ import { brush, select, scaleOrdinal, zoom, interpolateRound, interpolate, sum, scaleLinear, arc, pie, min, extent, descending, scaleSqrt, max } from 'd3';
2
+ import { RedsiftDataVizColorBlueDefault, RedsiftDataVizColorGreyDark, RedsiftDataVizColorGreenDefault, RedsiftDataVizColorPinkDefault, RedsiftDataVizColorAquaDefault, RedsiftDataVizColorBrownDefault, RedsiftDataVizColorRedDefault, RedsiftDataVizColorYellowDefault, RedsiftDataVizColorPurpleDefault, RedsiftDataVizColorOrangeDefault, RedsiftDataVizColorGreyDefault, RedsiftDataVizColorGreenDark, RedsiftDataVizColorPinkDark, RedsiftDataVizColorAquaDark, RedsiftDataVizColorBrownDark, RedsiftDataVizColorRedDark, RedsiftDataVizColorYellowDark, RedsiftDataVizColorPurpleDark, RedsiftDataVizColorOrangeDark, RedsiftDataVizColorBlueDark, RedsiftDataVizColorGreenDarker, RedsiftDataVizColorPinkDarker, RedsiftDataVizColorAquaDarker, RedsiftDataVizColorBrownDarker, RedsiftDataVizColorRedDarker, RedsiftDataVizColorYellowDarker, RedsiftDataVizColorPurpleDarker, RedsiftDataVizColorOrangeDarker, RedsiftDataVizColorBlueDarker, RedsiftDataVizColorGreyDarker, RedsiftDataVizColorGreenDarkerer, RedsiftDataVizColorPinkDarkerer, RedsiftDataVizColorAquaDarkerer, RedsiftDataVizColorBrownDarkerer, RedsiftDataVizColorRedDarkerer, RedsiftDataVizColorYellowDarkerer, RedsiftDataVizColorPurpleDarkerer, RedsiftDataVizColorOrangeDarkerer, RedsiftDataVizColorBlueDarkerer, RedsiftDataVizColorGreyDarkerer, RedsiftDataVizColorGreenLight, RedsiftDataVizColorPinkLight, RedsiftDataVizColorAquaLight, RedsiftDataVizColorBrownLight, RedsiftDataVizColorRedLight, RedsiftDataVizColorYellowLight, RedsiftDataVizColorPurpleLight, RedsiftDataVizColorOrangeLight, RedsiftDataVizColorBlueLight, RedsiftDataVizColorGreyLight, RedsiftDataVizColorGreenLighter, RedsiftDataVizColorPinkLighter, RedsiftDataVizColorAquaLighter, RedsiftDataVizColorBrownLighter, RedsiftDataVizColorRedLighter, RedsiftDataVizColorYellowLighter, RedsiftDataVizColorPurpleLighter, RedsiftDataVizColorOrangeLighter, RedsiftDataVizColorBlueLighter, RedsiftDataVizColorGreyLighter, RedsiftDataVizColorGreenLighterer, RedsiftDataVizColorPinkLighterer, RedsiftDataVizColorAquaLighterer, RedsiftDataVizColorBrownLighterer, RedsiftDataVizColorRedLighterer, RedsiftDataVizColorYellowLighterer, RedsiftDataVizColorPurpleLighterer, RedsiftDataVizColorOrangeLighterer, RedsiftDataVizColorBlueLighterer, RedsiftDataVizColorGreyLighterer, Text, Number as Number$1, baseStyling, Flexbox, warnIfNoAccessibleLabelFound, Heading, Button } from '@redsift/design-system';
3
+ import * as React from 'react';
4
+ import React__default, { useRef, useEffect, useMemo, useState, useLayoutEffect, forwardRef, useCallback, useContext, useId } from 'react';
5
+ import classNames from 'classnames';
6
+ import { unstable_batchedUpdates } from 'react-dom';
4
7
  import styled, { css } from 'styled-components';
5
8
  import { Tooltip } from '@redsift/popovers';
9
+ import { useLocalizedStringFormatter } from 'react-aria';
6
10
 
7
- const ColorTheme = {
8
- default: 'default',
9
- dark: 'dark',
10
- darker: 'darker',
11
- monochrome: 'monochrome'
11
+ const getRoundedIntermediaryPoint = (selection, scaleX, scaleY) => {
12
+ if (!selection) {
13
+ return null;
14
+ }
15
+ const xTicks = scaleX.ticks(20);
16
+ const xDelta = xTicks[1] - xTicks[0];
17
+ const yTicks = scaleY.ticks(20);
18
+ const yDelta = yTicks[1] - yTicks[0];
19
+ return [[scaleX(Math.round(scaleX.invert(selection[0][0]) / xDelta) * xDelta - xDelta / 2), scaleY(Math.round(scaleY.invert(selection[0][1]) / yDelta) * yDelta - yDelta / 2)], [scaleX(Math.round(scaleX.invert(selection[1][0]) / xDelta) * xDelta - xDelta / 2), scaleY(Math.round(scaleY.invert(selection[1][1]) / yDelta) * yDelta - yDelta / 2)]];
20
+ };
21
+ const useBrush = _ref => {
22
+ let {
23
+ svgRef,
24
+ extent,
25
+ scaleX,
26
+ scaleY,
27
+ isBrushable,
28
+ isGridded,
29
+ onBrush,
30
+ onBrushEnd
31
+ } = _ref;
32
+ const brush$1 = useRef();
33
+ useEffect(() => {
34
+ if (svgRef.current && isBrushable) {
35
+ brush$1.current = brush().extent(extent).keyModifiers(false).filter(event => event.shiftKey).on('brush', event => {
36
+ if (!event.sourceEvent || !brush$1.current || !svgRef.current) return;
37
+ if (isGridded) {
38
+ const selection = getRoundedIntermediaryPoint(event.selection, scaleX, scaleY);
39
+ select(svgRef.current).call(brush$1.current.move, selection);
40
+ onBrush === null || onBrush === void 0 ? void 0 : onBrush(selection, scaleX, scaleY);
41
+ } else {
42
+ onBrush === null || onBrush === void 0 ? void 0 : onBrush(event.selection, scaleX, scaleY);
43
+ }
44
+ }).on('end', event => {
45
+ if (!event.sourceEvent || !brush$1.current || !svgRef.current) return;
46
+ onBrushEnd === null || onBrushEnd === void 0 ? void 0 : onBrushEnd(event.selection, scaleX, scaleY);
47
+ });
48
+ select(svgRef.current).call(brush$1.current);
49
+ }
50
+ });
51
+ return {
52
+ brush: brush$1
53
+ };
12
54
  };
13
55
 
14
56
  const monochrome = RedsiftDataVizColorBlueDefault;
57
+ const empty = RedsiftDataVizColorGreyDark;
15
58
  const scheme = {
16
- default: [RedsiftDataVizColorPurpleDefault, RedsiftDataVizColorBlueDefault, RedsiftDataVizColorGreenDefault, RedsiftDataVizColorRedDefault, RedsiftDataVizColorPinkDefault, RedsiftDataVizColorCyanDefault, RedsiftDataVizColorOrangeDefault, RedsiftDataVizColorYellowDefault, RedsiftDataVizColorBrownDefault, RedsiftDataVizColorGreyDefault],
17
- dark: [RedsiftDataVizColorPurpleDark, RedsiftDataVizColorBlueDark, RedsiftDataVizColorGreenDark, RedsiftDataVizColorRedDark, RedsiftDataVizColorPinkDark, RedsiftDataVizColorCyanDark, RedsiftDataVizColorOrangeDark, RedsiftDataVizColorYellowDark, RedsiftDataVizColorBrownDark, RedsiftDataVizColorGreyDark],
18
- darker: [RedsiftDataVizColorPurpleDarker, RedsiftDataVizColorBlueDarker, RedsiftDataVizColorGreenDarker, RedsiftDataVizColorRedDarker, RedsiftDataVizColorPinkDarker, RedsiftDataVizColorCyanDarker, RedsiftDataVizColorOrangeDarker, RedsiftDataVizColorYellowDarker, RedsiftDataVizColorBrownDarker, RedsiftDataVizColorGreyDarker],
19
- light: [RedsiftDataVizColorPurpleLight, RedsiftDataVizColorBlueLight, RedsiftDataVizColorGreenLight, RedsiftDataVizColorRedLight, RedsiftDataVizColorPinkLight, RedsiftDataVizColorCyanLight, RedsiftDataVizColorOrangeLight, RedsiftDataVizColorYellowLight, RedsiftDataVizColorBrownLight, RedsiftDataVizColorGreyLight],
20
- lighter: [RedsiftDataVizColorPurpleLighter, RedsiftDataVizColorBlueLighter, RedsiftDataVizColorGreenLighter, RedsiftDataVizColorRedLighter, RedsiftDataVizColorPinkLighter, RedsiftDataVizColorCyanLighter, RedsiftDataVizColorOrangeLighter, RedsiftDataVizColorYellowLighter, RedsiftDataVizColorBrownLighter, RedsiftDataVizColorGreyLighter],
59
+ default: [RedsiftDataVizColorGreenDefault, RedsiftDataVizColorPinkDefault, RedsiftDataVizColorAquaDefault, RedsiftDataVizColorBrownDefault, RedsiftDataVizColorRedDefault, RedsiftDataVizColorYellowDefault, RedsiftDataVizColorPurpleDefault, RedsiftDataVizColorOrangeDefault, RedsiftDataVizColorBlueDefault, RedsiftDataVizColorGreyDefault],
60
+ dark: [RedsiftDataVizColorGreenDark, RedsiftDataVizColorPinkDark, RedsiftDataVizColorAquaDark, RedsiftDataVizColorBrownDark, RedsiftDataVizColorRedDark, RedsiftDataVizColorYellowDark, RedsiftDataVizColorPurpleDark, RedsiftDataVizColorOrangeDark, RedsiftDataVizColorBlueDark, RedsiftDataVizColorGreyDark],
61
+ darker: [RedsiftDataVizColorGreenDarker, RedsiftDataVizColorPinkDarker, RedsiftDataVizColorAquaDarker, RedsiftDataVizColorBrownDarker, RedsiftDataVizColorRedDarker, RedsiftDataVizColorYellowDarker, RedsiftDataVizColorPurpleDarker, RedsiftDataVizColorOrangeDarker, RedsiftDataVizColorBlueDarker, RedsiftDataVizColorGreyDarker],
62
+ darkerer: [RedsiftDataVizColorGreenDarkerer, RedsiftDataVizColorPinkDarkerer, RedsiftDataVizColorAquaDarkerer, RedsiftDataVizColorBrownDarkerer, RedsiftDataVizColorRedDarkerer, RedsiftDataVizColorYellowDarkerer, RedsiftDataVizColorPurpleDarkerer, RedsiftDataVizColorOrangeDarkerer, RedsiftDataVizColorBlueDarkerer, RedsiftDataVizColorGreyDarkerer],
63
+ light: [RedsiftDataVizColorGreenLight, RedsiftDataVizColorPinkLight, RedsiftDataVizColorAquaLight, RedsiftDataVizColorBrownLight, RedsiftDataVizColorRedLight, RedsiftDataVizColorYellowLight, RedsiftDataVizColorPurpleLight, RedsiftDataVizColorOrangeLight, RedsiftDataVizColorBlueLight, RedsiftDataVizColorGreyLight],
64
+ lighter: [RedsiftDataVizColorGreenLighter, RedsiftDataVizColorPinkLighter, RedsiftDataVizColorAquaLighter, RedsiftDataVizColorBrownLighter, RedsiftDataVizColorRedLighter, RedsiftDataVizColorYellowLighter, RedsiftDataVizColorPurpleLighter, RedsiftDataVizColorOrangeLighter, RedsiftDataVizColorBlueLighter, RedsiftDataVizColorGreyLighter],
65
+ lighterer: [RedsiftDataVizColorGreenLighterer, RedsiftDataVizColorPinkLighterer, RedsiftDataVizColorAquaLighterer, RedsiftDataVizColorBrownLighterer, RedsiftDataVizColorRedLighterer, RedsiftDataVizColorYellowLighterer, RedsiftDataVizColorPurpleLighterer, RedsiftDataVizColorOrangeLighterer, RedsiftDataVizColorBlueLighterer, RedsiftDataVizColorGreyLighterer],
21
66
  monochrome: [monochrome],
22
- empty: [RedsiftDataVizColorGreyDark]
67
+ empty: [empty]
23
68
  };
24
69
  const successDangerScheme = {
25
- success: RedsiftDataVizColorGreenDark,
26
- warning: RedsiftDataVizColorOrangeDark,
27
- danger: RedsiftDataVizColorRedDark,
28
- neutral: RedsiftDataVizColorGreyDark
70
+ success: RedsiftDataVizColorGreenDefault,
71
+ warning: RedsiftDataVizColorOrangeDefault,
72
+ danger: RedsiftDataVizColorRedDefault,
73
+ neutral: RedsiftDataVizColorGreyDefault
29
74
  };
30
- const getColorScale = (theme, isEmpty) => {
75
+ const getColorScale = (theme, domain, isEmpty) => {
31
76
  let d3colors = scaleOrdinal(scheme.default);
32
77
  if (isEmpty) {
33
78
  d3colors = scaleOrdinal(scheme.empty);
34
79
  } else if (typeof theme === 'string') {
35
- d3colors = scaleOrdinal(scheme[theme]);
80
+ d3colors = scaleOrdinal().domain(domain).range(scheme[theme]).unknown(monochrome);
36
81
  } else if (typeof theme === 'object') {
37
- d3colors = scaleOrdinal().domain([theme.success, theme.warning, theme.danger, ...(theme.neutral ? [theme.neutral] : [])]).range([successDangerScheme.success, successDangerScheme.warning, successDangerScheme.danger, ...(theme.neutral ? [successDangerScheme.neutral] : [])]).unknown(monochrome);
82
+ if (Object.keys(theme).includes('success') && Object.keys(theme).includes('danger') && Object.keys(theme).includes('warning')) {
83
+ d3colors = scaleOrdinal().domain([theme.success, theme.warning, theme.danger, ...(theme.neutral ? [theme.neutral] : [])]).range([successDangerScheme.success, successDangerScheme.warning, successDangerScheme.danger, ...(theme.neutral ? [successDangerScheme.neutral] : [])]).unknown(monochrome);
84
+ } else {
85
+ d3colors = scaleOrdinal().domain(Object.keys(theme)).range(Object.values(theme)).unknown(monochrome);
86
+ }
38
87
  }
39
88
  return d3colors;
40
89
  };
41
90
 
91
+ const useColor = _ref => {
92
+ let {
93
+ data,
94
+ theme,
95
+ category
96
+ } = _ref;
97
+ const colorScaleRef = useRef();
98
+ if (!colorScaleRef.current && data !== undefined) {
99
+ colorScaleRef.current = getColorScale(theme, data.map(d => d[category]));
100
+ }
101
+ return colorScaleRef.current;
102
+ };
103
+
42
104
  function ownKeys(object, enumerableOnly) {
43
105
  var keys = Object.keys(object);
44
106
  if (Object.getOwnPropertySymbols) {
@@ -130,130 +192,231 @@ function _toPropertyKey(arg) {
130
192
  return typeof key === "symbol" ? key : String(key);
131
193
  }
132
194
 
133
- /**
134
- * Component size.
135
- */
136
- const HorizontalBarChartSize = {
137
- small: 'small',
138
- medium: 'medium',
139
- large: 'large'
195
+ const useFormatCategoricalData = _ref => {
196
+ let {
197
+ data,
198
+ caping,
199
+ others,
200
+ theme
201
+ } = _ref;
202
+ const computedData = useMemo(() => {
203
+ let computedData;
204
+ if (data === undefined || data === null) {
205
+ return undefined;
206
+ }
207
+ computedData = [...data].sort((a, b) => a.value === b.value ? a.key > b.key ? 1 : -1 : a.value < b.value ? 1 : -1);
208
+ if (caping) {
209
+ if (typeof others === 'boolean' && !others) {
210
+ computedData = computedData.slice(0, caping);
211
+ } else {
212
+ computedData = computedData.reduce((acc, curr, index) => {
213
+ if (index < caping) {
214
+ acc[index] = curr;
215
+ } else if (index === caping) {
216
+ acc[index] = {
217
+ key: typeof others === 'string' ? others : 'Others',
218
+ value: curr.value
219
+ };
220
+ } else {
221
+ acc[caping] = _objectSpread2(_objectSpread2({}, acc[caping]), {}, {
222
+ value: acc[caping].value + curr.value
223
+ });
224
+ }
225
+ return acc;
226
+ }, []);
227
+ }
228
+ }
229
+ return computedData;
230
+ }, [data]);
231
+ const colorScale = useColor({
232
+ data: computedData,
233
+ theme,
234
+ category: 'key'
235
+ });
236
+ return {
237
+ data: computedData,
238
+ colorScale
239
+ };
140
240
  };
141
- /**
142
- * Component theme.
143
- */
144
- const HorizontalBarChartTheme = ColorTheme;
145
- /**
146
- * Tooltip label variant.
147
- */
148
- const HorizontalBarChartTooltipVariant = {
241
+
242
+ const useZoom = _ref => {
243
+ let {
244
+ svgRef,
245
+ scaleX,
246
+ scaleY,
247
+ defaultTransform = {
248
+ k: 1,
249
+ x: 0,
250
+ y: 0
251
+ },
252
+ onZoom
253
+ } = _ref;
254
+ const zx = useRef(scaleX);
255
+ const zy = useRef(scaleY);
256
+ const [transform, setTransform] = useState(defaultTransform);
257
+ useEffect(() => {
258
+ if (svgRef.current) {
259
+ const zoom$1 = zoom().filter(event => !event.shiftKey).scaleExtent([1 / 2 ** 3, 2 ** 3]).on('zoom', event => {
260
+ onZoom === null || onZoom === void 0 ? void 0 : onZoom();
261
+ zx.current = event.transform.rescaleX(scaleX).interpolate(interpolateRound);
262
+ zy.current = event.transform.rescaleY(scaleY).interpolate(interpolateRound);
263
+ setTransform(event.transform);
264
+ });
265
+ select(svgRef.current).call(zoom$1);
266
+ }
267
+ }, [svgRef.current]);
268
+ return {
269
+ transform,
270
+ scaleX: zx.current,
271
+ scaleY: zy.current
272
+ };
273
+ };
274
+
275
+ /** TOOLTIP */
276
+
277
+ const TooltipVariant = {
149
278
  none: 'none',
150
279
  label: 'label',
151
280
  value: 'value',
152
281
  percent: 'percent'
153
282
  };
283
+ /** LEGEND */
284
+ const LabelVariant = {
285
+ label: 'label',
286
+ value: 'value',
287
+ percent: 'percent'
288
+ };
154
289
 
155
- /**
156
- * Component style.
157
- */
158
- const StyledHorizontalBarChart = styled.div`
159
- margin: 8px;
160
- padding: 8px;
161
- color: var(--redsift-color-neutral-black);
290
+ const ChartSize = {
291
+ small: 'small',
292
+ medium: 'medium',
293
+ large: 'large'
294
+ };
162
295
 
163
- .redsift-horizontal-barchart__container {
164
- display: flex;
165
- align-items: center;
166
- gap: 16px;
167
- font-family: var(--redsift-typography-font-family-source-code-pro);
168
- font-size: 11px;
169
- justify-content: center;
170
- margin: 8px 0;
296
+ const ColorTheme = {
297
+ default: 'default',
298
+ dark: 'dark',
299
+ darker: 'darker',
300
+ darkerer: 'darkerer',
301
+ light: 'light',
302
+ lighter: 'lighter',
303
+ lighterer: 'lighterer',
304
+ monochrome: 'monochrome'
305
+ };
171
306
 
172
- .redsift-horizontal-barchart-container__chart {
173
- position: relative;
174
- }
175
- }
307
+ var f$1=r(),n=e=>c$3(e,f$1),m$1=r();n.write=e=>c$3(e,m$1);var d$2=r();n.onStart=e=>c$3(e,d$2);var h$3=r();n.onFrame=e=>c$3(e,h$3);var p$1=r();n.onFinish=e=>c$3(e,p$1);var i=[];n.setTimeout=(e,t)=>{let a=n.now()+t,o=()=>{let F=i.findIndex(z=>z.cancel==o);~F&&i.splice(F,1),u$2-=~F?1:0;},s={time:a,handler:e,cancel:o};return i.splice(w(a),0,s),u$2+=1,v$2(),s};var w=e=>~(~i.findIndex(t=>t.time>e)||~i.length);n.cancel=e=>{d$2.delete(e),h$3.delete(e),p$1.delete(e),f$1.delete(e),m$1.delete(e);};n.sync=e=>{T=!0,n.batchedUpdates(e),T=!1;};n.throttle=e=>{let t;function a(){try{e(...t);}finally{t=null;}}function o(...s){t=s,n.onStart(a);}return o.handler=e,o.cancel=()=>{d$2.delete(a),t=null;},o};var y$3=typeof window<"u"?window.requestAnimationFrame:()=>{};n.use=e=>y$3=e;n.now=typeof performance<"u"?()=>performance.now():Date.now;n.batchedUpdates=e=>e();n.catch=console.error;n.frameLoop="always";n.advance=()=>{n.frameLoop!=="demand"?console.warn("Cannot call the manual advancement of rafz whilst frameLoop is not set as demand"):x$2();};var l$2=-1,u$2=0,T=!1;function c$3(e,t){T?(t.delete(e),e(0)):(t.add(e),v$2());}function v$2(){l$2<0&&(l$2=0,n.frameLoop!=="demand"&&y$3(b$2));}function R(){l$2=-1;}function b$2(){~l$2&&(y$3(b$2),n.batchedUpdates(x$2));}function x$2(){let e=l$2;l$2=n.now();let t=w(l$2);if(t&&(Q$2(i.splice(0,t),a=>a.handler()),u$2-=t),!u$2){R();return}d$2.flush(),f$1.flush(e?Math.min(64,l$2-e):16.667),h$3.flush(),m$1.flush(),p$1.flush();}function r(){let e=new Set,t=e;return {add(a){u$2+=t==e&&!e.has(a)?1:0,e.add(a);},delete(a){return u$2-=t==e&&e.has(a)?1:0,e.delete(a)},flush(a){t.size&&(e=new Set,u$2-=t.size,Q$2(t,o=>o(a)&&e.add(o)),u$2+=e.size,t=e);}}}function Q$2(e,t){e.forEach(a=>{try{t(a);}catch(o){n.catch(o);}});}
176
308
 
177
- svg {
178
- display: block;
309
+ var ze$1=Object.defineProperty;var Le$2=(e,t)=>{for(var r in t)ze$1(e,r,{get:t[r],enumerable:!0});};var p={};Le$2(p,{assign:()=>U,colors:()=>c$2,createStringInterpolator:()=>k$2,skipAnimation:()=>ee,to:()=>J$1,willAdvance:()=>S});function Y(){}var mt$1=(e,t,r)=>Object.defineProperty(e,t,{value:r,writable:!0,configurable:!0}),l$1={arr:Array.isArray,obj:e=>!!e&&e.constructor.name==="Object",fun:e=>typeof e=="function",str:e=>typeof e=="string",num:e=>typeof e=="number",und:e=>e===void 0};function bt$1(e,t){if(l$1.arr(e)){if(!l$1.arr(t)||e.length!==t.length)return !1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return !1;return !0}return e===t}var Ve=(e,t)=>e.forEach(t);function xt(e,t,r){if(l$1.arr(e)){for(let n=0;n<e.length;n++)t.call(r,e[n],`${n}`);return}for(let n in e)e.hasOwnProperty(n)&&t.call(r,e[n],n);}var ht$1=e=>l$1.und(e)?[]:l$1.arr(e)?e:[e];function Pe$1(e,t){if(e.size){let r=Array.from(e);e.clear(),Ve(r,t);}}var yt$1=(e,...t)=>Pe$1(e,r=>r(...t)),h$2=()=>typeof window>"u"||!window.navigator||/ServerSideRendering|^Deno\//.test(window.navigator.userAgent);var k$2,J$1,c$2=null,ee=!1,S=Y,U=e=>{e.to&&(J$1=e.to),e.now&&(n.now=e.now),e.colors!==void 0&&(c$2=e.colors),e.skipAnimation!=null&&(ee=e.skipAnimation),e.createStringInterpolator&&(k$2=e.createStringInterpolator),e.requestAnimationFrame&&n.use(e.requestAnimationFrame),e.batchedUpdates&&(n.batchedUpdates=e.batchedUpdates),e.willAdvance&&(S=e.willAdvance),e.frameLoop&&(n.frameLoop=e.frameLoop);};var E$1=new Set,u$1=[],H$1=[],A=0,qe$1={get idle(){return !E$1.size&&!u$1.length},start(e){A>e.priority?(E$1.add(e),n.onStart($e)):(te$1(e),n(B));},advance:B,sort(e){if(A)n.onFrame(()=>qe$1.sort(e));else {let t=u$1.indexOf(e);~t&&(u$1.splice(t,1),re(e));}},clear(){u$1=[],E$1.clear();}};function $e(){E$1.forEach(te$1),E$1.clear(),n(B);}function te$1(e){u$1.includes(e)||re(e);}function re(e){u$1.splice(Ge$1(u$1,t=>t.priority>e.priority),0,e);}function B(e){let t=H$1;for(let r=0;r<u$1.length;r++){let n=u$1[r];A=n.priority,n.idle||(S(n),n.advance(e),n.idle||t.push(n));}return A=0,H$1=u$1,H$1.length=0,u$1=t,u$1.length>0}function Ge$1(e,t){let r=e.findIndex(t);return r<0?e.length:r}var ne$2=(e,t,r)=>Math.min(Math.max(r,e),t);var It={transparent:0,aliceblue:4042850303,antiquewhite:4209760255,aqua:16777215,aquamarine:2147472639,azure:4043309055,beige:4126530815,bisque:4293182719,black:255,blanchedalmond:4293643775,blue:65535,blueviolet:2318131967,brown:2771004159,burlywood:3736635391,burntsienna:3934150143,cadetblue:1604231423,chartreuse:2147418367,chocolate:3530104575,coral:4286533887,cornflowerblue:1687547391,cornsilk:4294499583,crimson:3692313855,cyan:16777215,darkblue:35839,darkcyan:9145343,darkgoldenrod:3095792639,darkgray:2846468607,darkgreen:6553855,darkgrey:2846468607,darkkhaki:3182914559,darkmagenta:2332068863,darkolivegreen:1433087999,darkorange:4287365375,darkorchid:2570243327,darkred:2332033279,darksalmon:3918953215,darkseagreen:2411499519,darkslateblue:1211993087,darkslategray:793726975,darkslategrey:793726975,darkturquoise:13554175,darkviolet:2483082239,deeppink:4279538687,deepskyblue:12582911,dimgray:1768516095,dimgrey:1768516095,dodgerblue:512819199,firebrick:2988581631,floralwhite:4294635775,forestgreen:579543807,fuchsia:4278255615,gainsboro:3705462015,ghostwhite:4177068031,gold:4292280575,goldenrod:3668254975,gray:2155905279,green:8388863,greenyellow:2919182335,grey:2155905279,honeydew:4043305215,hotpink:4285117695,indianred:3445382399,indigo:1258324735,ivory:4294963455,khaki:4041641215,lavender:3873897215,lavenderblush:4293981695,lawngreen:2096890111,lemonchiffon:4294626815,lightblue:2916673279,lightcoral:4034953471,lightcyan:3774873599,lightgoldenrodyellow:4210742015,lightgray:3553874943,lightgreen:2431553791,lightgrey:3553874943,lightpink:4290167295,lightsalmon:4288707327,lightseagreen:548580095,lightskyblue:2278488831,lightslategray:2005441023,lightslategrey:2005441023,lightsteelblue:2965692159,lightyellow:4294959359,lime:16711935,limegreen:852308735,linen:4210091775,magenta:4278255615,maroon:2147483903,mediumaquamarine:1724754687,mediumblue:52735,mediumorchid:3126187007,mediumpurple:2473647103,mediumseagreen:1018393087,mediumslateblue:2070474495,mediumspringgreen:16423679,mediumturquoise:1221709055,mediumvioletred:3340076543,midnightblue:421097727,mintcream:4127193855,mistyrose:4293190143,moccasin:4293178879,navajowhite:4292783615,navy:33023,oldlace:4260751103,olive:2155872511,olivedrab:1804477439,orange:4289003775,orangered:4282712319,orchid:3664828159,palegoldenrod:4008225535,palegreen:2566625535,paleturquoise:2951671551,palevioletred:3681588223,papayawhip:4293907967,peachpuff:4292524543,peru:3448061951,pink:4290825215,plum:3718307327,powderblue:2967529215,purple:2147516671,rebeccapurple:1714657791,red:4278190335,rosybrown:3163525119,royalblue:1097458175,saddlebrown:2336560127,salmon:4202722047,sandybrown:4104413439,seagreen:780883967,seashell:4294307583,sienna:2689740287,silver:3233857791,skyblue:2278484991,slateblue:1784335871,slategray:1887473919,slategrey:1887473919,snow:4294638335,springgreen:16744447,steelblue:1182971135,tan:3535047935,teal:8421631,thistle:3636451583,tomato:4284696575,turquoise:1088475391,violet:4001558271,wheat:4125012991,white:4294967295,whitesmoke:4126537215,yellow:4294902015,yellowgreen:2597139199};var d$1="[-+]?\\d*\\.?\\d+",M=d$1+"%";function C$1(...e){return "\\(\\s*("+e.join(")\\s*,\\s*(")+")\\s*\\)"}var oe$1=new RegExp("rgb"+C$1(d$1,d$1,d$1)),fe$1=new RegExp("rgba"+C$1(d$1,d$1,d$1,d$1)),ae$1=new RegExp("hsl"+C$1(d$1,M,M)),ie=new RegExp("hsla"+C$1(d$1,M,M,d$1)),se$1=/^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,ue$1=/^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,le$1=/^#([0-9a-fA-F]{6})$/,ce=/^#([0-9a-fA-F]{8})$/;function be$1(e){let t;return typeof e=="number"?e>>>0===e&&e>=0&&e<=4294967295?e:null:(t=le$1.exec(e))?parseInt(t[1]+"ff",16)>>>0:c$2&&c$2[e]!==void 0?c$2[e]:(t=oe$1.exec(e))?(y$2(t[1])<<24|y$2(t[2])<<16|y$2(t[3])<<8|255)>>>0:(t=fe$1.exec(e))?(y$2(t[1])<<24|y$2(t[2])<<16|y$2(t[3])<<8|me$1(t[4]))>>>0:(t=se$1.exec(e))?parseInt(t[1]+t[1]+t[2]+t[2]+t[3]+t[3]+"ff",16)>>>0:(t=ce.exec(e))?parseInt(t[1],16)>>>0:(t=ue$1.exec(e))?parseInt(t[1]+t[1]+t[2]+t[2]+t[3]+t[3]+t[4]+t[4],16)>>>0:(t=ae$1.exec(e))?(de$1(pe(t[1]),z$1(t[2]),z$1(t[3]))|255)>>>0:(t=ie.exec(e))?(de$1(pe(t[1]),z$1(t[2]),z$1(t[3]))|me$1(t[4]))>>>0:null}function j$1(e,t,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?e+(t-e)*6*r:r<1/2?t:r<2/3?e+(t-e)*(2/3-r)*6:e}function de$1(e,t,r){let n=r<.5?r*(1+t):r+t-r*t,f=2*r-n,o=j$1(f,n,e+1/3),i=j$1(f,n,e),s=j$1(f,n,e-1/3);return Math.round(o*255)<<24|Math.round(i*255)<<16|Math.round(s*255)<<8}function y$2(e){let t=parseInt(e,10);return t<0?0:t>255?255:t}function pe(e){return (parseFloat(e)%360+360)%360/360}function me$1(e){let t=parseFloat(e);return t<0?0:t>1?255:Math.round(t*255)}function z$1(e){let t=parseFloat(e);return t<0?0:t>100?1:t/100}function D$1(e){let t=be$1(e);if(t===null)return e;t=t||0;let r=(t&4278190080)>>>24,n=(t&16711680)>>>16,f=(t&65280)>>>8,o=(t&255)/255;return `rgba(${r}, ${n}, ${f}, ${o})`}var W$1=(e,t,r)=>{if(l$1.fun(e))return e;if(l$1.arr(e))return W$1({range:e,output:t,extrapolate:r});if(l$1.str(e.output[0]))return k$2(e);let n=e,f=n.output,o=n.range||[0,1],i=n.extrapolateLeft||n.extrapolate||"extend",s=n.extrapolateRight||n.extrapolate||"extend",x=n.easing||(a=>a);return a=>{let F=He$1(a,o);return Ue$1(a,o[F],o[F+1],f[F],f[F+1],x,i,s,n.map)}};function Ue$1(e,t,r,n,f,o,i,s,x){let a=x?x(e):e;if(a<t){if(i==="identity")return a;i==="clamp"&&(a=t);}if(a>r){if(s==="identity")return a;s==="clamp"&&(a=r);}return n===f?n:t===r?e<=t?n:f:(t===-1/0?a=-a:r===1/0?a=a-t:a=(a-t)/(r-t),a=o(a),n===-1/0?a=-a:f===1/0?a=a+n:a=a*(f-n)+n,a)}function He$1(e,t){for(var r=1;r<t.length-1&&!(t[r]>=e);++r);return r-1}var Be=(e,t="end")=>r=>{r=t==="end"?Math.min(r,.999):Math.max(r,.001);let n=r*e,f=t==="end"?Math.floor(n):Math.ceil(n);return ne$2(0,1,f/e)},P=1.70158,L$1=P*1.525,xe$1=P+1,he$1=2*Math.PI/3,ye$1=2*Math.PI/4.5,V$1=e=>e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375,Lt$1={linear:e=>e,easeInQuad:e=>e*e,easeOutQuad:e=>1-(1-e)*(1-e),easeInOutQuad:e=>e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2,easeInCubic:e=>e*e*e,easeOutCubic:e=>1-Math.pow(1-e,3),easeInOutCubic:e=>e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2,easeInQuart:e=>e*e*e*e,easeOutQuart:e=>1-Math.pow(1-e,4),easeInOutQuart:e=>e<.5?8*e*e*e*e:1-Math.pow(-2*e+2,4)/2,easeInQuint:e=>e*e*e*e*e,easeOutQuint:e=>1-Math.pow(1-e,5),easeInOutQuint:e=>e<.5?16*e*e*e*e*e:1-Math.pow(-2*e+2,5)/2,easeInSine:e=>1-Math.cos(e*Math.PI/2),easeOutSine:e=>Math.sin(e*Math.PI/2),easeInOutSine:e=>-(Math.cos(Math.PI*e)-1)/2,easeInExpo:e=>e===0?0:Math.pow(2,10*e-10),easeOutExpo:e=>e===1?1:1-Math.pow(2,-10*e),easeInOutExpo:e=>e===0?0:e===1?1:e<.5?Math.pow(2,20*e-10)/2:(2-Math.pow(2,-20*e+10))/2,easeInCirc:e=>1-Math.sqrt(1-Math.pow(e,2)),easeOutCirc:e=>Math.sqrt(1-Math.pow(e-1,2)),easeInOutCirc:e=>e<.5?(1-Math.sqrt(1-Math.pow(2*e,2)))/2:(Math.sqrt(1-Math.pow(-2*e+2,2))+1)/2,easeInBack:e=>xe$1*e*e*e-P*e*e,easeOutBack:e=>1+xe$1*Math.pow(e-1,3)+P*Math.pow(e-1,2),easeInOutBack:e=>e<.5?Math.pow(2*e,2)*((L$1+1)*2*e-L$1)/2:(Math.pow(2*e-2,2)*((L$1+1)*(e*2-2)+L$1)+2)/2,easeInElastic:e=>e===0?0:e===1?1:-Math.pow(2,10*e-10)*Math.sin((e*10-10.75)*he$1),easeOutElastic:e=>e===0?0:e===1?1:Math.pow(2,-10*e)*Math.sin((e*10-.75)*he$1)+1,easeInOutElastic:e=>e===0?0:e===1?1:e<.5?-(Math.pow(2,20*e-10)*Math.sin((20*e-11.125)*ye$1))/2:Math.pow(2,-20*e+10)*Math.sin((20*e-11.125)*ye$1)/2+1,easeInBounce:e=>1-V$1(1-e),easeOutBounce:V$1,easeInOutBounce:e=>e<.5?(1-V$1(1-2*e))/2:(1+V$1(2*e-1))/2,steps:Be};var g$1=Symbol.for("FluidValue.get"),m=Symbol.for("FluidValue.observers");var Pt=e=>!!(e&&e[g$1]),ve=e=>e&&e[g$1]?e[g$1]():e,qt=e=>e[m]||null;function je(e,t){e.eventObserved?e.eventObserved(t):e(t);}function $t(e,t){let r=e[m];r&&r.forEach(n=>{je(n,t);});}var ge=class{[g$1];[m];constructor(t){if(!t&&!(t=this.get))throw Error("Unknown getter");De$1(this,t);}},De$1=(e,t)=>Ee$1(e,g$1,t);function Gt$1(e,t){if(e[g$1]){let r=e[m];r||Ee$1(e,m,r=new Set),r.has(t)||(r.add(t),e.observerAdded&&e.observerAdded(r.size,t));}return t}function Qt(e,t){let r=e[m];if(r&&r.has(t)){let n=r.size-1;n?r.delete(t):e[m]=null,e.observerRemoved&&e.observerRemoved(n,t);}}var Ee$1=(e,t,r)=>Object.defineProperty(e,t,{value:r,writable:!0,configurable:!0});var O=/[+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,Oe=/(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d\.]+%?\))/gi,K=new RegExp(`(${O.source})(%|[a-z]+)`,"i"),we$1=/rgba\(([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+)\)/gi,b$1=/var\((--[a-zA-Z0-9-_]+),? ?([a-zA-Z0-9 ()%#.,-]+)?\)/;var N=e=>{let[t,r]=We(e);if(!t||h$2())return e;let n=window.getComputedStyle(document.documentElement).getPropertyValue(t);if(n)return n.trim();if(r&&r.startsWith("--")){let f=window.getComputedStyle(document.documentElement).getPropertyValue(r);return f||e}else {if(r&&b$1.test(r))return N(r);if(r)return r}return e},We=e=>{let t=b$1.exec(e);if(!t)return [,];let[,r,n]=t;return [r,n]};var _$1,Ke$1=(e,t,r,n,f)=>`rgba(${Math.round(t)}, ${Math.round(r)}, ${Math.round(n)}, ${f})`,Xt=e=>{_$1||(_$1=c$2?new RegExp(`(${Object.keys(c$2).join("|")})(?!\\w)`,"g"):/^\b$/);let t=e.output.map(o=>ve(o).replace(b$1,N).replace(Oe,D$1).replace(_$1,D$1)),r=t.map(o=>o.match(O).map(Number)),f=r[0].map((o,i)=>r.map(s=>{if(!(i in s))throw Error('The arity of each "output" value must be equal');return s[i]})).map(o=>W$1({...e,output:o}));return o=>{let i=!K.test(t[0])&&t.find(x=>K.test(x))?.replace(O,""),s=0;return t[0].replace(O,()=>`${f[s++](o)}${i||""}`).replace(we$1,Ke$1)}};var Z="react-spring: ",Te=e=>{let t=e,r=!1;if(typeof t!="function")throw new TypeError(`${Z}once requires a function parameter`);return (...n)=>{r||(t(...n),r=!0);}},Ne$1=Te(console.warn);function Jt(){Ne$1(`${Z}The "interpolate" function is deprecated in v9 (use "to" instead)`);}var _e$1=Te(console.warn);function er$1(){_e$1(`${Z}Directly calling start instead of using the api object is deprecated in v9 (use ".start" instead), this will be removed in later 0.X.0 versions`);}function or(e){return l$1.str(e)&&(e[0]=="#"||/\d/.test(e)||!h$2()&&b$1.test(e)||e in(c$2||{}))}var Q$1=h$2()?useEffect:useLayoutEffect;var Ce$1=()=>{let e=useRef(!1);return Q$1(()=>(e.current=!0,()=>{e.current=!1;}),[]),e};function Mr(){let e=useState()[1],t=Ce$1();return ()=>{t.current&&e(Math.random());}}function Lr(e,t){let[r]=useState(()=>({inputs:t,result:e()})),n=useRef(),f=n.current,o=f;return o?t&&o.inputs&&it$2(t,o.inputs)||(o={inputs:t,result:e()}):o=r,useEffect(()=>{n.current=o,f==r&&(r.inputs=r.result=void 0);},[o]),o.result}function it$2(e,t){if(e.length!==t.length)return !1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return !1;return !0}var $r=e=>useEffect(e,ut),ut=[];function Ur(e){let t=useRef();return useEffect(()=>{t.current=e;}),t.current}
310
+
311
+ var h$1=Symbol.for("Animated:node"),v$1=e=>!!e&&e[h$1]===e,k$1=e=>e&&e[h$1],D=(e,t)=>mt$1(e,h$1,t),F$1=e=>e&&e[h$1]&&e[h$1].getPayload(),c$1=class{payload;constructor(){D(this,this);}getPayload(){return this.payload||[]}};var l=class extends c$1{constructor(r){super();this._value=r;l$1.num(this._value)&&(this.lastPosition=this._value);}done=!0;elapsedTime;lastPosition;lastVelocity;v0;durationProgress=0;static create(r){return new l(r)}getPayload(){return [this]}getValue(){return this._value}setValue(r,n){return l$1.num(r)&&(this.lastPosition=r,n&&(r=Math.round(r/n)*n,this.done&&(this.lastPosition=r))),this._value===r?!1:(this._value=r,!0)}reset(){let{done:r}=this;this.done=!1,l$1.num(this._value)&&(this.elapsedTime=0,this.durationProgress=0,this.lastPosition=this._value,r&&(this.lastVelocity=null),this.v0=null);}};var d=class extends l{_string=null;_toString;constructor(t){super(0),this._toString=W$1({output:[t,t]});}static create(t){return new d(t)}getValue(){let t=this._string;return t??(this._string=this._toString(this._value))}setValue(t){if(l$1.str(t)){if(t==this._string)return !1;this._string=t,this._value=1;}else if(super.setValue(t))this._string=null;else return !1;return !0}reset(t){t&&(this._toString=W$1({output:[this.getValue(),t]})),this._value=0,super.reset();}};var f={dependencies:null};var u=class extends c$1{constructor(r){super();this.source=r;this.setValue(r);}getValue(r){let n={};return xt(this.source,(a,i)=>{v$1(a)?n[i]=a.getValue(r):Pt(a)?n[i]=ve(a):r||(n[i]=a);}),n}setValue(r){this.source=r,this.payload=this._makePayload(r);}reset(){this.payload&&Ve(this.payload,r=>r.reset());}_makePayload(r){if(r){let n=new Set;return xt(r,this._addToPayload,n),Array.from(n)}}_addToPayload(r){f.dependencies&&Pt(r)&&f.dependencies.add(r);let n=F$1(r);n&&Ve(n,a=>this.add(a));}};var y$1=class extends u{constructor(t){super(t);}static create(t){return new y$1(t)}getValue(){return this.source.map(t=>t.getValue())}setValue(t){let r=this.getPayload();return t.length==r.length?r.map((n,a)=>n.setValue(t[a])).some(Boolean):(super.setValue(t.map(z)),!0)}};function z(e){return (or(e)?d:l).create(e)}function Le$1(e){let t=k$1(e);return t?t.constructor:l$1.arr(e)?y$1:or(e)?d:l}var x$1=(e,t)=>{let r=!l$1.fun(e)||e.prototype&&e.prototype.isReactComponent;return forwardRef((n$1,a)=>{let i=useRef(null),o=r&&useCallback(s=>{i.current=ae(a,s);},[a]),[m,T]=ne$1(n$1,t),W=Mr(),P=()=>{let s=i.current;if(r&&!s)return;(s?t.applyAnimatedValues(s,m.getValue(!0)):!1)===!1&&W();},_=new b(P,T),p=useRef();Q$1(()=>(p.current=_,Ve(T,s=>Gt$1(s,_)),()=>{p.current&&(Ve(p.current.deps,s=>Qt(s,p.current)),n.cancel(p.current.update));})),useEffect(P,[]),$r(()=>()=>{let s=p.current;Ve(s.deps,S=>Qt(S,s));});let $=t.getComponentProps(m.getValue());return React.createElement(e,{...$,ref:o})})},b=class{constructor(t,r){this.update=t;this.deps=r;}eventObserved(t){t.type=="change"&&n.write(this.update);}};function ne$1(e,t){let r=new Set;return f.dependencies=r,e.style&&(e={...e,style:t.createAnimatedStyle(e.style)}),e=new u(e),f.dependencies=null,[e,r]}function ae(e,t){return e&&(l$1.fun(e)?e(t):e.current=t),t}var j=Symbol.for("AnimatedComponent"),Ke=(e,{applyAnimatedValues:t=()=>!1,createAnimatedStyle:r=a=>new u(a),getComponentProps:n=a=>a}={})=>{let a={applyAnimatedValues:t,createAnimatedStyle:r,getComponentProps:n},i=o=>{let m=I$2(o)||"Anonymous";return l$1.str(o)?o=i[o]||(i[o]=x$1(o,a)):o=o[j]||(o[j]=x$1(o,a)),o.displayName=`Animated(${m})`,o};return xt(e,(o,m)=>{l$1.arr(e)&&(m=I$2(o)),i[m]=i(o);}),{animated:i}},I$2=e=>l$1.str(e)?e:e&&l$1.str(e.displayName)?e.displayName:l$1.fun(e)&&e.name||null;
312
+
313
+ function I$1(t,...e){return l$1.fun(t)?t(...e):t}var te=(t,e)=>t===!0||!!(e&&t&&(l$1.fun(t)?t(e):ht$1(t).includes(e))),et=(t,e)=>l$1.obj(t)?e&&t[e]:t;var ke=(t,e)=>t.default===!0?t[e]:t.default?t.default[e]:void 0,nn=t=>t,ne=(t,e=nn)=>{let n=rn;t.default&&t.default!==!0&&(t=t.default,n=Object.keys(t));let r={};for(let o of n){let s=e(t[o],o);l$1.und(s)||(r[o]=s);}return r},rn=["config","onProps","onStart","onChange","onPause","onResume","onRest"],on={config:1,from:1,to:1,ref:1,loop:1,reset:1,pause:1,cancel:1,reverse:1,immediate:1,default:1,delay:1,onProps:1,onStart:1,onChange:1,onPause:1,onResume:1,onRest:1,onResolve:1,items:1,trail:1,sort:1,expires:1,initial:1,enter:1,update:1,leave:1,children:1,onDestroyed:1,keys:1,callId:1,parentId:1};function sn(t){let e={},n=0;if(xt(t,(r,o)=>{on[o]||(e[o]=r,n++);}),n)return e}function de(t){let e=sn(t);if(e){let n={to:e};return xt(t,(r,o)=>o in e||(n[o]=r)),n}return {...t}}function me(t){return t=ve(t),l$1.arr(t)?t.map(me):or(t)?p.createStringInterpolator({range:[0,1],output:[t,t]})(1):t}function Ue(t){for(let e in t)return !0;return !1}function Ee(t){return l$1.fun(t)||l$1.arr(t)&&l$1.obj(t[0])}function xe(t,e){t.ref?.delete(t),e?.delete(t);}function he(t,e){e&&t.ref!==e&&(t.ref?.delete(t),e.add(t),t.ref=e);}var mt={default:{tension:170,friction:26},gentle:{tension:120,friction:14},wobbly:{tension:180,friction:12},stiff:{tension:210,friction:20},slow:{tension:280,friction:60},molasses:{tension:280,friction:120}};var tt={...mt.default,mass:1,damping:1,easing:Lt$1.linear,clamp:!1},we=class{tension;friction;frequency;damping;mass;velocity=0;restVelocity;precision;progress;duration;easing;clamp;bounce;decay;round;constructor(){Object.assign(this,tt);}};function gt(t,e,n){n&&(n={...n},ht(n,e),e={...n,...e}),ht(t,e),Object.assign(t,e);for(let i in tt)t[i]==null&&(t[i]=tt[i]);let{frequency:r,damping:o}=t,{mass:s}=t;return l$1.und(r)||(r<.01&&(r=.01),o<0&&(o=0),t.tension=Math.pow(2*Math.PI/r,2)*s,t.friction=4*Math.PI*o*s/r),t}function ht(t,e){if(!l$1.und(e.decay))t.duration=void 0;else {let n=!l$1.und(e.tension)||!l$1.und(e.friction);(n||!l$1.und(e.frequency)||!l$1.und(e.damping)||!l$1.und(e.mass))&&(t.duration=void 0,t.decay=void 0),n&&(t.frequency=void 0);}}var yt=[],Le=class{changed=!1;values=yt;toValues=null;fromValues=yt;to;from;config=new we;immediate=!1};function Me(t,{key:e,props:n$1,defaultProps:r,state:o,actions:s}){return new Promise((i,a)=>{let u,p$1,f=te(n$1.cancel??r?.cancel,e);if(f)b();else {l$1.und(n$1.pause)||(o.paused=te(n$1.pause,e));let c=r?.pause;c!==!0&&(c=o.paused||te(c,e)),u=I$1(n$1.delay||0,e),c?(o.resumeQueue.add(m),s.pause()):(s.resume(),m());}function d(){o.resumeQueue.add(m),o.timeouts.delete(p$1),p$1.cancel(),u=p$1.time-n.now();}function m(){u>0&&!p.skipAnimation?(o.delayed=!0,p$1=n.setTimeout(b,u),o.pauseQueue.add(d),o.timeouts.add(p$1)):b();}function b(){o.delayed&&(o.delayed=!1),o.pauseQueue.delete(d),o.timeouts.delete(p$1),t<=(o.cancelId||0)&&(f=!0);try{s.start({...n$1,callId:t,cancel:f},i);}catch(c){a(c);}}})}var be=(t,e)=>e.length==1?e[0]:e.some(n=>n.cancelled)?q$1(t.get()):e.every(n=>n.noop)?nt(t.get()):E(t.get(),e.every(n=>n.finished)),nt=t=>({value:t,noop:!0,finished:!0,cancelled:!1}),E=(t,e,n=!1)=>({value:t,finished:e,cancelled:n}),q$1=t=>({value:t,cancelled:!0,finished:!1});function De(t,e,n$1,r){let{callId:o,parentId:s,onRest:i}=e,{asyncTo:a,promise:u}=n$1;return !s&&t===a&&!e.reset?u:n$1.promise=(async()=>{n$1.asyncId=o,n$1.asyncTo=t;let p$1=ne(e,(l,h)=>h==="onRest"?void 0:l),f,d,m=new Promise((l,h)=>(f=l,d=h)),b=l=>{let h=o<=(n$1.cancelId||0)&&q$1(r)||o!==n$1.asyncId&&E(r,!1);if(h)throw l.result=h,d(l),l},c=(l,h)=>{let g=new Ae,x=new Ne;return (async()=>{if(p.skipAnimation)throw oe(n$1),x.result=E(r,!1),d(x),x;b(g);let S=l$1.obj(l)?{...l}:{...h,to:l};S.parentId=o,xt(p$1,(V,_)=>{l$1.und(S[_])&&(S[_]=V);});let A=await r.start(S);return b(g),n$1.paused&&await new Promise(V=>{n$1.resumeQueue.add(V);}),A})()},P;if(p.skipAnimation)return oe(n$1),E(r,!1);try{let l;l$1.arr(t)?l=(async h=>{for(let g of h)await c(g);})(t):l=Promise.resolve(t(c,r.stop.bind(r))),await Promise.all([l.then(f),m]),P=E(r.get(),!0,!1);}catch(l){if(l instanceof Ae)P=l.result;else if(l instanceof Ne)P=l.result;else throw l}finally{o==n$1.asyncId&&(n$1.asyncId=s,n$1.asyncTo=s?a:void 0,n$1.promise=s?u:void 0);}return l$1.fun(i)&&n.batchedUpdates(()=>{i(P,r,r.item);}),P})()}function oe(t,e){Pe$1(t.timeouts,n=>n.cancel()),t.pauseQueue.clear(),t.resumeQueue.clear(),t.asyncId=t.asyncTo=t.promise=void 0,e&&(t.cancelId=e);}var Ae=class extends Error{result;constructor(){super("An async animation has been interrupted. You see this error because you forgot to use `await` or `.catch(...)` on its returned promise.");}},Ne=class extends Error{result;constructor(){super("SkipAnimationSignal");}};var Re=t=>t instanceof X,Sn=1,X=class extends ge{id=Sn++;_priority=0;get priority(){return this._priority}set priority(e){this._priority!=e&&(this._priority=e,this._onPriorityChange(e));}get(){let e=k$1(this);return e&&e.getValue()}to(...e){return p.to(this,e)}interpolate(...e){return Jt(),p.to(this,e)}toJSON(){return this.get()}observerAdded(e){e==1&&this._attach();}observerRemoved(e){e==0&&this._detach();}_attach(){}_detach(){}_onChange(e,n=!1){$t(this,{type:"change",parent:this,value:e,idle:n});}_onPriorityChange(e){this.idle||qe$1.sort(this),$t(this,{type:"priority",parent:this,priority:e});}};var se=Symbol.for("SpringPhase"),bt=1,rt=2,ot=4,qe=t=>(t[se]&bt)>0,Q=t=>(t[se]&rt)>0,ye=t=>(t[se]&ot)>0,st=(t,e)=>e?t[se]|=rt|bt:t[se]&=~rt,it$1=(t,e)=>e?t[se]|=ot:t[se]&=~ot;var ue=class extends X{key;animation=new Le;queue;defaultProps={};_state={paused:!1,delayed:!1,pauseQueue:new Set,resumeQueue:new Set,timeouts:new Set};_pendingCalls=new Set;_lastCallId=0;_lastToId=0;_memoizedDuration=0;constructor(e,n){if(super(),!l$1.und(e)||!l$1.und(n)){let r=l$1.obj(e)?{...e}:{...n,from:e};l$1.und(r.default)&&(r.default=!0),this.start(r);}}get idle(){return !(Q(this)||this._state.asyncTo)||ye(this)}get goal(){return ve(this.animation.to)}get velocity(){let e=k$1(this);return e instanceof l?e.lastVelocity||0:e.getPayload().map(n=>n.lastVelocity||0)}get hasAnimated(){return qe(this)}get isAnimating(){return Q(this)}get isPaused(){return ye(this)}get isDelayed(){return this._state.delayed}advance(e){let n=!0,r=!1,o=this.animation,{toValues:s}=o,{config:i}=o,a=F$1(o.to);!a&&Pt(o.to)&&(s=ht$1(ve(o.to))),o.values.forEach((f,d$1)=>{if(f.done)return;let m=f.constructor==d?1:a?a[d$1].lastPosition:s[d$1],b=o.immediate,c=m;if(!b){if(c=f.lastPosition,i.tension<=0){f.done=!0;return}let P=f.elapsedTime+=e,l=o.fromValues[d$1],h=f.v0!=null?f.v0:f.v0=l$1.arr(i.velocity)?i.velocity[d$1]:i.velocity,g,x=i.precision||(l==m?.005:Math.min(1,Math.abs(m-l)*.001));if(l$1.und(i.duration))if(i.decay){let S=i.decay===!0?.998:i.decay,A=Math.exp(-(1-S)*P);c=l+h/(1-S)*(1-A),b=Math.abs(f.lastPosition-c)<=x,g=h*A;}else {g=f.lastVelocity==null?h:f.lastVelocity;let S=i.restVelocity||x/10,A=i.clamp?0:i.bounce,V=!l$1.und(A),_=l==m?f.v0>0:l<m,v,w=!1,C=1,$=Math.ceil(e/C);for(let L=0;L<$&&(v=Math.abs(g)>S,!(!v&&(b=Math.abs(m-c)<=x,b)));++L){V&&(w=c==m||c>m==_,w&&(g=-g*A,c=m));let N=-i.tension*1e-6*(c-m),y=-i.friction*.001*g,T=(N+y)/i.mass;g=g+T*C,c=c+g*C;}}else {let S=1;i.duration>0&&(this._memoizedDuration!==i.duration&&(this._memoizedDuration=i.duration,f.durationProgress>0&&(f.elapsedTime=i.duration*f.durationProgress,P=f.elapsedTime+=e)),S=(i.progress||0)+P/this._memoizedDuration,S=S>1?1:S<0?0:S,f.durationProgress=S),c=l+i.easing(S)*(m-l),g=(c-f.lastPosition)/e,b=S==1;}f.lastVelocity=g,Number.isNaN(c)&&(console.warn("Got NaN while animating:",this),b=!0);}a&&!a[d$1].done&&(b=!1),b?f.done=!0:n=!1,f.setValue(c,i.round)&&(r=!0);});let u=k$1(this),p=u.getValue();if(n){let f=ve(o.to);(p!==f||r)&&!i.decay?(u.setValue(f),this._onChange(f)):r&&i.decay&&this._onChange(p),this._stop();}else r&&this._onChange(p);}set(e){return n.batchedUpdates(()=>{this._stop(),this._focus(e),this._set(e);}),this}pause(){this._update({pause:!0});}resume(){this._update({pause:!1});}finish(){if(Q(this)){let{to:e,config:n$1}=this.animation;n.batchedUpdates(()=>{this._onStart(),n$1.decay||this._set(e,!1),this._stop();});}return this}update(e){return (this.queue||(this.queue=[])).push(e),this}start(e,n){let r;return l$1.und(e)?(r=this.queue||[],this.queue=[]):r=[l$1.obj(e)?e:{...n,to:e}],Promise.all(r.map(o=>this._update(o))).then(o=>be(this,o))}stop(e){let{to:n$1}=this.animation;return this._focus(this.get()),oe(this._state,e&&this._lastCallId),n.batchedUpdates(()=>this._stop(n$1,e)),this}reset(){this._update({reset:!0});}eventObserved(e){e.type=="change"?this._start():e.type=="priority"&&(this.priority=e.priority+1);}_prepareNode(e){let n=this.key||"",{to:r,from:o}=e;r=l$1.obj(r)?r[n]:r,(r==null||Ee(r))&&(r=void 0),o=l$1.obj(o)?o[n]:o,o==null&&(o=void 0);let s={to:r,from:o};return qe(this)||(e.reverse&&([r,o]=[o,r]),o=ve(o),l$1.und(o)?k$1(this)||this._set(r):this._set(o)),s}_update({...e},n){let{key:r,defaultProps:o}=this;e.default&&Object.assign(o,ne(e,(a,u)=>/^on/.test(u)?et(a,r):a)),_t(this,e,"onProps"),Ie(this,"onProps",e,this);let s=this._prepareNode(e);if(Object.isFrozen(this))throw Error("Cannot animate a `SpringValue` object that is frozen. Did you forget to pass your component to `animated(...)` before animating its props?");let i=this._state;return Me(++this._lastCallId,{key:r,props:e,defaultProps:o,state:i,actions:{pause:()=>{ye(this)||(it$1(this,!0),yt$1(i.pauseQueue),Ie(this,"onPause",E(this,Ce(this,this.animation.to)),this));},resume:()=>{ye(this)&&(it$1(this,!1),Q(this)&&this._resume(),yt$1(i.resumeQueue),Ie(this,"onResume",E(this,Ce(this,this.animation.to)),this));},start:this._merge.bind(this,s)}}).then(a=>{if(e.loop&&a.finished&&!(n&&a.noop)){let u=at(e);if(u)return this._update(u,!0)}return a})}_merge(e,n$1,r){if(n$1.cancel)return this.stop(!0),r(q$1(this));let o=!l$1.und(e.to),s=!l$1.und(e.from);if(o||s)if(n$1.callId>this._lastToId)this._lastToId=n$1.callId;else return r(q$1(this));let{key:i,defaultProps:a,animation:u}=this,{to:p,from:f}=u,{to:d$1=p,from:m=f}=e;s&&!o&&(!n$1.default||l$1.und(d$1))&&(d$1=m),n$1.reverse&&([d$1,m]=[m,d$1]);let b=!bt$1(m,f);b&&(u.from=m),m=ve(m);let c=!bt$1(d$1,p);c&&this._focus(d$1);let P=Ee(n$1.to),{config:l}=u,{decay:h,velocity:g}=l;(o||s)&&(l.velocity=0),n$1.config&&!P&&gt(l,I$1(n$1.config,i),n$1.config!==a.config?I$1(a.config,i):void 0);let x=k$1(this);if(!x||l$1.und(d$1))return r(E(this,!0));let S=l$1.und(n$1.reset)?s&&!n$1.default:!l$1.und(m)&&te(n$1.reset,i),A=S?m:this.get(),V=me(d$1),_=l$1.num(V)||l$1.arr(V)||or(V),v=!P&&(!_||te(a.immediate||n$1.immediate,i));if(c){let L=Le$1(d$1);if(L!==x.constructor)if(v)x=this._set(V);else throw Error(`Cannot animate between ${x.constructor.name} and ${L.name}, as the "to" prop suggests`)}let w=x.constructor,C=Pt(d$1),$=!1;if(!C){let L=S||!qe(this)&&b;(c||L)&&($=bt$1(me(A),V),C=!$),(!bt$1(u.immediate,v)&&!v||!bt$1(l.decay,h)||!bt$1(l.velocity,g))&&(C=!0);}if($&&Q(this)&&(u.changed&&!S?C=!0:C||this._stop(p)),!P&&((C||Pt(p))&&(u.values=x.getPayload(),u.toValues=Pt(d$1)?null:w==d?[1]:ht$1(V)),u.immediate!=v&&(u.immediate=v,!v&&!S&&this._set(p)),C)){let{onRest:L}=u;Ve(_n,y=>_t(this,n$1,y));let N=E(this,Ce(this,p));yt$1(this._pendingCalls,N),this._pendingCalls.add(r),u.changed&&n.batchedUpdates(()=>{u.changed=!S,L?.(N,this),S?I$1(a.onRest,N):u.onStart?.(N,this);});}S&&this._set(A),P?r(De(n$1.to,n$1,this._state,this)):C?this._start():Q(this)&&!c?this._pendingCalls.add(r):r(nt(A));}_focus(e){let n=this.animation;e!==n.to&&(qt(this)&&this._detach(),n.to=e,qt(this)&&this._attach());}_attach(){let e=0,{to:n}=this.animation;Pt(n)&&(Gt$1(n,this),Re(n)&&(e=n.priority+1)),this.priority=e;}_detach(){let{to:e}=this.animation;Pt(e)&&Qt(e,this);}_set(e,n$1=!0){let r=ve(e);if(!l$1.und(r)){let o=k$1(this);if(!o||!bt$1(r,o.getValue())){let s=Le$1(r);!o||o.constructor!=s?D(this,s.create(r)):o.setValue(r),o&&n.batchedUpdates(()=>{this._onChange(r,n$1);});}}return k$1(this)}_onStart(){let e=this.animation;e.changed||(e.changed=!0,Ie(this,"onStart",E(this,Ce(this,e.to)),this));}_onChange(e,n){n||(this._onStart(),I$1(this.animation.onChange,e,this)),I$1(this.defaultProps.onChange,e,this),super._onChange(e,n);}_start(){let e=this.animation;k$1(this).reset(ve(e.to)),e.immediate||(e.fromValues=e.values.map(n=>n.lastPosition)),Q(this)||(st(this,!0),ye(this)||this._resume());}_resume(){p.skipAnimation?this.finish():qe$1.start(this);}_stop(e,n){if(Q(this)){st(this,!1);let r=this.animation;Ve(r.values,s=>{s.done=!0;}),r.toValues&&(r.onChange=r.onPause=r.onResume=void 0),$t(this,{type:"idle",parent:this});let o=n?q$1(this.get()):E(this.get(),Ce(this,e??r.to));yt$1(this._pendingCalls,o),r.changed&&(r.changed=!1,Ie(this,"onRest",o,this));}}};function Ce(t,e){let n=me(e),r=me(t.get());return bt$1(r,n)}function at(t,e=t.loop,n=t.to){let r=I$1(e);if(r){let o=r!==!0&&de(r),s=(o||t).reverse,i=!o||o.reset;return Pe({...t,loop:e,default:!1,pause:void 0,to:!s||Ee(n)?n:void 0,from:i?t.from:void 0,reset:i,...o})}}function Pe(t){let{to:e,from:n}=t=de(t),r=new Set;return l$1.obj(e)&&Vt(e,r),l$1.obj(n)&&Vt(n,r),t.keys=r.size?Array.from(r):null,t}function Ot(t){let e=Pe(t);return l$1.und(e.default)&&(e.default=ne(e)),e}function Vt(t,e){xt(t,(n,r)=>n!=null&&e.add(r));}var _n=["onStart","onRest","onChange","onPause","onResume"];function _t(t,e,n){t.animation[n]=e[n]!==ke(e,n)?et(e[n],t.key):void 0;}function Ie(t,e,...n){t.animation[e]?.(...n),t.defaultProps[e]?.(...n);}var Fn=["onStart","onChange","onRest"],kn=1,le=class{id=kn++;springs={};queue=[];ref;_flush;_initialProps;_lastAsyncId=0;_active=new Set;_changed=new Set;_started=!1;_item;_state={paused:!1,pauseQueue:new Set,resumeQueue:new Set,timeouts:new Set};_events={onStart:new Map,onChange:new Map,onRest:new Map};constructor(e,n){this._onFrame=this._onFrame.bind(this),n&&(this._flush=n),e&&this.start({default:!0,...e});}get idle(){return !this._state.asyncTo&&Object.values(this.springs).every(e=>e.idle&&!e.isDelayed&&!e.isPaused)}get item(){return this._item}set item(e){this._item=e;}get(){let e={};return this.each((n,r)=>e[r]=n.get()),e}set(e){for(let n in e){let r=e[n];l$1.und(r)||this.springs[n].set(r);}}update(e){return e&&this.queue.push(Pe(e)),this}start(e){let{queue:n}=this;return e?n=ht$1(e).map(Pe):this.queue=[],this._flush?this._flush(this,n):(jt(this,n),ze(this,n))}stop(e,n){if(e!==!!e&&(n=e),n){let r=this.springs;Ve(ht$1(n),o=>r[o].stop(!!e));}else oe(this._state,this._lastAsyncId),this.each(r=>r.stop(!!e));return this}pause(e){if(l$1.und(e))this.start({pause:!0});else {let n=this.springs;Ve(ht$1(e),r=>n[r].pause());}return this}resume(e){if(l$1.und(e))this.start({pause:!1});else {let n=this.springs;Ve(ht$1(e),r=>n[r].resume());}return this}each(e){xt(this.springs,e);}_onFrame(){let{onStart:e,onChange:n,onRest:r}=this._events,o=this._active.size>0,s=this._changed.size>0;(o&&!this._started||s&&!this._started)&&(this._started=!0,Pe$1(e,([u,p])=>{p.value=this.get(),u(p,this,this._item);}));let i=!o&&this._started,a=s||i&&r.size?this.get():null;s&&n.size&&Pe$1(n,([u,p])=>{p.value=a,u(p,this,this._item);}),i&&(this._started=!1,Pe$1(r,([u,p])=>{p.value=a,u(p,this,this._item);}));}eventObserved(e){if(e.type=="change")this._changed.add(e.parent),e.idle||this._active.add(e.parent);else if(e.type=="idle")this._active.delete(e.parent);else return;n.onFrame(this._onFrame);}};function ze(t,e){return Promise.all(e.map(n=>wt(t,n))).then(n=>be(t,n))}async function wt(t,e,n$1){let{keys:r,to:o,from:s,loop:i,onRest:a,onResolve:u}=e,p=l$1.obj(e.default)&&e.default;i&&(e.loop=!1),o===!1&&(e.to=null),s===!1&&(e.from=null);let f=l$1.arr(o)||l$1.fun(o)?o:void 0;f?(e.to=void 0,e.onRest=void 0,p&&(p.onRest=void 0)):Ve(Fn,P=>{let l=e[P];if(l$1.fun(l)){let h=t._events[P];e[P]=({finished:g,cancelled:x})=>{let S=h.get(l);S?(g||(S.finished=!1),x&&(S.cancelled=!0)):h.set(l,{value:null,finished:g||!1,cancelled:x||!1});},p&&(p[P]=e[P]);}});let d=t._state;e.pause===!d.paused?(d.paused=e.pause,yt$1(e.pause?d.pauseQueue:d.resumeQueue)):d.paused&&(e.pause=!0);let m=(r||Object.keys(t.springs)).map(P=>t.springs[P].start(e)),b=e.cancel===!0||ke(e,"cancel")===!0;(f||b&&d.asyncId)&&m.push(Me(++t._lastAsyncId,{props:e,state:d,actions:{pause:Y,resume:Y,start(P,l){b?(oe(d,t._lastAsyncId),l(q$1(t))):(P.onRest=a,l(De(f,P,d,t)));}}})),d.paused&&await new Promise(P=>{d.resumeQueue.add(P);});let c=be(t,await Promise.all(m));if(i&&c.finished&&!(n$1&&c.noop)){let P=at(e,i,o);if(P)return jt(t,[P]),wt(t,P,!0)}return u&&n.batchedUpdates(()=>u(c,t,t.item)),c}function _e(t,e){let n={...t.springs};return e&&Ve(ht$1(e),r=>{l$1.und(r.keys)&&(r=Pe(r)),l$1.obj(r.to)||(r={...r,to:void 0}),Mt(n,r,o=>Lt(o));}),pt(t,n),n}function pt(t,e){xt(e,(n,r)=>{t.springs[r]||(t.springs[r]=n,Gt$1(n,t));});}function Lt(t,e){let n=new ue;return n.key=t,e&&Gt$1(n,e),n}function Mt(t,e,n){e.keys&&Ve(e.keys,r=>{(t[r]||(t[r]=n(r)))._prepareNode(e);});}function jt(t,e){Ve(e,n=>{Mt(t.springs,n,r=>Lt(r,t));});}var H=({children:t,...e})=>{let n=useContext(Ge),r=e.pause||!!n.pause,o=e.immediate||!!n.immediate;e=Lr(()=>({pause:r,immediate:o}),[r,o]);let{Provider:s}=Ge;return React.createElement(s,{value:e},t)},Ge=wn(H,{});H.Provider=Ge.Provider;H.Consumer=Ge.Consumer;function wn(t,e){return Object.assign(t,React.createContext(e)),t.Provider._context=t,t.Consumer._context=t,t}var fe=()=>{let t=[],e=function(r){er$1();let o=[];return Ve(t,(s,i)=>{if(l$1.und(r))o.push(s.start());else {let a=n(r,s,i);a&&o.push(s.start(a));}}),o};e.current=t,e.add=function(r){t.includes(r)||t.push(r);},e.delete=function(r){let o=t.indexOf(r);~o&&t.splice(o,1);},e.pause=function(){return Ve(t,r=>r.pause(...arguments)),this},e.resume=function(){return Ve(t,r=>r.resume(...arguments)),this},e.set=function(r){Ve(t,(o,s)=>{let i=l$1.fun(r)?r(s,o):r;i&&o.set(i);});},e.start=function(r){let o=[];return Ve(t,(s,i)=>{if(l$1.und(r))o.push(s.start());else {let a=this._getProps(r,s,i);a&&o.push(s.start(a));}}),o},e.stop=function(){return Ve(t,r=>r.stop(...arguments)),this},e.update=function(r){return Ve(t,(o,s)=>o.update(this._getProps(r,o,s))),this};let n=function(r,o,s){return l$1.fun(r)?r(s,o):r};return e._getProps=n,e};function He(t,e,n){let r=l$1.fun(e)&&e;r&&!n&&(n=[]);let o=useMemo(()=>r||arguments.length==3?fe():void 0,[]),s=useRef(0),i=Mr(),a=useMemo(()=>({ctrls:[],queue:[],flush(h,g){let x=_e(h,g);return s.current>0&&!a.queue.length&&!Object.keys(x).some(A=>!h.springs[A])?ze(h,g):new Promise(A=>{pt(h,x),a.queue.push(()=>{A(ze(h,g));}),i();})}}),[]),u=useRef([...a.ctrls]),p=[],f=Ur(t)||0;useMemo(()=>{Ve(u.current.slice(t,f),h=>{xe(h,o),h.stop(!0);}),u.current.length=t,d(f,t);},[t]),useMemo(()=>{d(0,Math.min(f,t));},n);function d(h,g){for(let x=h;x<g;x++){let S=u.current[x]||(u.current[x]=new le(null,a.flush)),A=r?r(x,S):e[x];A&&(p[x]=Ot(A));}}let m=u.current.map((h,g)=>_e(h,p[g])),b=useContext(H),c=Ur(b),P=b!==c&&Ue(b);Q$1(()=>{s.current++,a.ctrls=u.current;let{queue:h}=a;h.length&&(a.queue=[],Ve(h,g=>g())),Ve(u.current,(g,x)=>{o?.add(g),P&&g.start({default:b});let S=p[x];S&&(he(g,S.ref),g.ref?g.queue.push(S):g.start(S));});}),$r(()=>()=>{Ve(a.ctrls,h=>h.stop(!0));});let l=m.map(h=>({...h}));return o?[l,o]:l}function J(t,e){let n=l$1.fun(t),[[r],o]=He(1,n?t:[t],n?e||[]:e);return n||arguments.length==2?[r,o]:r}function Gt(t,e,n){let r=l$1.fun(e)&&e,{reset:o,sort:s,trail:i=0,expires:a=!0,exitBeforeEnter:u=!1,onDestroyed:p,ref:f,config:d}=r?r():e,m=useMemo(()=>r||arguments.length==3?fe():void 0,[]),b=ht$1(t),c=[],P=useRef(null),l=o?null:P.current;Q$1(()=>{P.current=c;}),$r(()=>(Ve(c,y=>{m?.add(y.ctrl),y.ctrl.ref=m;}),()=>{Ve(P.current,y=>{y.expired&&clearTimeout(y.expirationId),xe(y.ctrl,m),y.ctrl.stop(!0);});}));let h=tr(b,r?r():e,l),g=o&&P.current||[];Q$1(()=>Ve(g,({ctrl:y,item:T,key:F})=>{xe(y,m),I$1(p,T,F);}));let x=[];if(l&&Ve(l,(y,T)=>{y.expired?(clearTimeout(y.expirationId),g.push(y)):(T=x[T]=h.indexOf(y.key),~T&&(c[T]=y));}),Ve(b,(y,T)=>{c[T]||(c[T]={key:h[T],item:y,phase:"mount",ctrl:new le},c[T].ctrl.item=y);}),x.length){let y=-1,{leave:T}=r?r():e;Ve(x,(F,k)=>{let O=l[k];~F?(y=c.indexOf(O),c[y]={...O,item:b[F]}):T&&c.splice(++y,0,O);});}l$1.fun(s)&&c.sort((y,T)=>s(y.item,T.item));let S=-i,A=Mr(),V=ne(e),_=new Map,v=useRef(new Map),w=useRef(!1);Ve(c,(y,T)=>{let F=y.key,k=y.phase,O=r?r():e,U,D,Jt=I$1(O.delay||0,F);if(k=="mount")U=O.enter,D="enter";else {let M=h.indexOf(F)<0;if(k!="leave")if(M)U=O.leave,D="leave";else if(U=O.update)D="update";else return;else if(!M)U=O.enter,D="enter";else return}if(U=I$1(U,y.item,T),U=l$1.obj(U)?de(U):{to:U},!U.config){let M=d||V.config;U.config=I$1(M,y.item,T,D);}S+=i;let Z={...V,delay:Jt+S,ref:f,immediate:O.immediate,reset:!1,...U};if(D=="enter"&&l$1.und(Z.from)){let M=r?r():e,Te=l$1.und(M.initial)||l?M.from:M.initial;Z.from=I$1(Te,y.item,T);}let{onResolve:Wt}=Z;Z.onResolve=M=>{I$1(Wt,M);let Te=P.current,B=Te.find(Fe=>Fe.key===F);if(B&&!(M.cancelled&&B.phase!="update")&&B.ctrl.idle){let Fe=Te.every(ee=>ee.ctrl.idle);if(B.phase=="leave"){let ee=I$1(a,B.item);if(ee!==!1){let Ze=ee===!0?0:ee;if(B.expired=!0,!Fe&&Ze>0){Ze<=2147483647&&(B.expirationId=setTimeout(A,Ze));return}}}Fe&&Te.some(ee=>ee.expired)&&(v.current.delete(B),u&&(w.current=!0),A());}};let ft=_e(y.ctrl,Z);D==="leave"&&u?v.current.set(y,{phase:D,springs:ft,payload:Z}):_.set(y,{phase:D,springs:ft,payload:Z});});let C=useContext(H),$=Ur(C),L=C!==$&&Ue(C);Q$1(()=>{L&&Ve(c,y=>{y.ctrl.start({default:C});});},[C]),Ve(_,(y,T)=>{if(v.current.size){let F=c.findIndex(k=>k.key===T.key);c.splice(F,1);}}),Q$1(()=>{Ve(v.current.size?v.current:_,({phase:y,payload:T},F)=>{let{ctrl:k}=F;F.phase=y,m?.add(k),L&&y=="enter"&&k.start({default:C}),T&&(he(k,T.ref),(k.ref||m)&&!w.current?k.update(T):(k.start(T),w.current&&(w.current=!1)));});},o?void 0:n);let N=y=>React.createElement(React.Fragment,null,c.map((T,F)=>{let{springs:k}=_.get(T)||T.ctrl,O=y({...k},T.item,T,F);return O&&O.type?React.createElement(O.type,{...O.props,key:l$1.str(T.key)||l$1.num(T.key)?T.key:T.ctrl.id,ref:O.ref}):O}));return m?[N,m]:N}var er=1;function tr(t,{key:e,keys:n=e},r){if(n===null){let o=new Set;return t.map(s=>{let i=r&&r.find(a=>a.item===s&&a.phase!=="leave"&&!o.has(a));return i?(o.add(i),i.key):er++})}return l$1.und(n)?t:l$1.fun(n)?t.map(n):ht$1(n)}var W=class extends X{constructor(n,r){super();this.source=n;this.calc=W$1(...r);let o=this._get(),s=Le$1(o);D(this,s.create(o));}key;idle=!0;calc;_active=new Set;advance(n){let r=this._get(),o=this.get();bt$1(r,o)||(k$1(this).setValue(r),this._onChange(r,this.idle)),!this.idle&&Yt(this._active)&&ct(this);}_get(){let n=l$1.arr(this.source)?this.source.map(ve):ht$1(ve(this.source));return this.calc(...n)}_start(){this.idle&&!Yt(this._active)&&(this.idle=!1,Ve(F$1(this),n=>{n.done=!1;}),p.skipAnimation?(n.batchedUpdates(()=>this.advance()),ct(this)):qe$1.start(this));}_attach(){let n=1;Ve(ht$1(this.source),r=>{Pt(r)&&Gt$1(r,this),Re(r)&&(r.idle||this._active.add(r),n=Math.max(n,r.priority+1));}),this.priority=n,this._start();}_detach(){Ve(ht$1(this.source),n=>{Pt(n)&&Qt(n,this);}),this._active.clear(),ct(this);}eventObserved(n){n.type=="change"?n.idle?this.advance():(this._active.add(n.parent),this._start()):n.type=="idle"?this._active.delete(n.parent):n.type=="priority"&&(this.priority=ht$1(this.source).reduce((r,o)=>Math.max(r,(Re(o)?o.priority:0)+1),0));}};function vr(t){return t.idle!==!1}function Yt(t){return !t.size||Array.from(t).every(vr)}function ct(t){t.idle||(t.idle=!0,Ve(F$1(t),e=>{e.done=!0;}),$t(t,{type:"idle",parent:t}));}p.assign({createStringInterpolator:Xt,to:(t,e)=>new W(t,e)});
314
+
315
+ var k=/^--/;function I(t,e){return e==null||typeof e=="boolean"||e===""?"":typeof e=="number"&&e!==0&&!k.test(t)&&!(c.hasOwnProperty(t)&&c[t])?e+"px":(""+e).trim()}var v={};function V(t,e){if(!t.nodeType||!t.setAttribute)return !1;let r=t.nodeName==="filter"||t.parentNode&&t.parentNode.nodeName==="filter",{style:i,children:s,scrollTop:u,scrollLeft:l,viewBox:a,...n}=e,d=Object.values(n),m=Object.keys(n).map(o=>r||t.hasAttribute(o)?o:v[o]||(v[o]=o.replace(/([A-Z])/g,p=>"-"+p.toLowerCase())));s!==void 0&&(t.textContent=s);for(let o in i)if(i.hasOwnProperty(o)){let p=I(o,i[o]);k.test(o)?t.style.setProperty(o,p):t.style[o]=p;}m.forEach((o,p)=>{t.setAttribute(o,d[p]);}),u!==void 0&&(t.scrollTop=u),l!==void 0&&(t.scrollLeft=l),a!==void 0&&t.setAttribute("viewBox",a);}var c={animationIterationCount:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},F=(t,e)=>t+e.charAt(0).toUpperCase()+e.substring(1),L=["Webkit","Ms","Moz","O"];c=Object.keys(c).reduce((t,e)=>(L.forEach(r=>t[F(r,e)]=t[e]),t),c);var _=/^(matrix|translate|scale|rotate|skew)/,$=/^(translate)/,G=/^(rotate|skew)/,y=(t,e)=>l$1.num(t)&&t!==0?t+e:t,h=(t,e)=>l$1.arr(t)?t.every(r=>h(r,e)):l$1.num(t)?t===e:parseFloat(t)===e,g=class extends u{constructor({x:e,y:r,z:i,...s}){let u=[],l=[];(e||r||i)&&(u.push([e||0,r||0,i||0]),l.push(a=>[`translate3d(${a.map(n=>y(n,"px")).join(",")})`,h(a,0)])),xt(s,(a,n)=>{if(n==="transform")u.push([a||""]),l.push(d=>[d,d===""]);else if(_.test(n)){if(delete s[n],l$1.und(a))return;let d=$.test(n)?"px":G.test(n)?"deg":"";u.push(ht$1(a)),l.push(n==="rotate3d"?([m,o,p,O])=>[`rotate3d(${m},${o},${p},${y(O,d)})`,h(O,0)]:m=>[`${n}(${m.map(o=>y(o,d)).join(",")})`,h(m,n.startsWith("scale")?1:0)]);}}),u.length&&(s.transform=new x(u,l)),super(s);}},x=class extends ge{constructor(r,i){super();this.inputs=r;this.transforms=i;}_value=null;get(){return this._value||(this._value=this._get())}_get(){let r="",i=!0;return Ve(this.inputs,(s,u)=>{let l=ve(s[0]),[a,n]=this.transforms[u](l$1.arr(l)?l:s.map(ve));r+=" "+a,i=i&&n;}),i?"none":r}observerAdded(r){r==1&&Ve(this.inputs,i=>Ve(i,s=>Pt(s)&&Gt$1(s,this)));}observerRemoved(r){r==0&&Ve(this.inputs,i=>Ve(i,s=>Pt(s)&&Qt(s,this)));}eventObserved(r){r.type=="change"&&(this._value=null),$t(this,r);}};var C=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"];p.assign({batchedUpdates:unstable_batchedUpdates,createStringInterpolator:Xt,colors:It});var q=Ke(C,{applyAnimatedValues:V,createAnimatedStyle:t=>new g(t),getComponentProps:({scrollTop:t,scrollLeft:e,...r})=>r}),it=q.animated;
179
316
 
180
- g {
181
- margin: 8px;
317
+ /**
318
+ * Component style.
319
+ */
320
+ const StyledDataPoint = styled.g``;
321
+
322
+ const _excluded$j = ["children", "className", "data", "id", "index", "isSelected", "labelDecorator", "onClick", "role", "tooltipVariant"];
323
+ const DataPoint = /*#__PURE__*/forwardRef((props, ref) => {
324
+ const {
325
+ children,
326
+ className,
327
+ data,
328
+ id: propsId,
329
+ index,
330
+ isSelected: propsIsSelected,
331
+ labelDecorator,
332
+ onClick,
333
+ role,
334
+ tooltipVariant
335
+ } = props,
336
+ forwardedProps = _objectWithoutProperties(props, _excluded$j);
337
+ const id = propsId !== null && propsId !== void 0 ? propsId : useId();
338
+ const text = labelDecorator ? labelDecorator(data) : data.data.key;
339
+ const hasText = text && tooltipVariant !== TooltipVariant.none;
340
+ const tooltipValue = tooltipVariant === TooltipVariant.value ? data.data.value : tooltipVariant === TooltipVariant.percent && data.data.percent ? data.data.percent : undefined;
341
+ const hasValue = tooltipValue && [TooltipVariant.value, TooltipVariant.percent].includes(tooltipVariant);
342
+ const showTooltip = tooltipVariant !== TooltipVariant.none && (hasText || hasValue);
343
+ const isEmpty = data.data.value === 0;
344
+ const isSelectable = role === 'option';
345
+ const isSelected = isSelectable && propsIsSelected === true;
346
+ const isDeselected = isSelectable && propsIsSelected === false;
347
+ const onKeyDown = event => {
348
+ if (onClick) {
349
+ event.stopPropagation();
350
+ if (event.code === 'Enter' || event.code === 'Space') {
351
+ event.preventDefault();
352
+ onClick(data);
353
+ }
182
354
  }
355
+ };
356
+ const DataPointComponent = /*#__PURE__*/React__default.createElement(StyledDataPoint, _extends({}, forwardedProps, {
357
+ className: classNames(className, `_${index}`, {
358
+ selected: isSelected,
359
+ deselected: isDeselected
360
+ }),
361
+ ref: ref,
362
+ "aria-label": showTooltip && !isEmpty ? `${text}: ${data.data.value}` : undefined,
363
+ "aria-labelledby": !showTooltip && !isEmpty ? `${id}-title` : undefined,
364
+ "aria-selected": isSelected ? true : isDeselected ? false : undefined,
365
+ id: id,
366
+ onClick: onClick ? () => onClick(data) : undefined,
367
+ onKeyDown: onClick ? e => onKeyDown(e) : undefined,
368
+ role: role ? role : onClick ? 'button' : undefined,
369
+ tabIndex: onClick ? 0 : undefined,
370
+ $clickable: Boolean(onClick)
371
+ }), children, !showTooltip && !isEmpty ? /*#__PURE__*/React__default.createElement("title", {
372
+ id: `${id}-title`
373
+ }, `${text}: ${data.data.value}`) : null);
374
+ if (showTooltip) {
375
+ return /*#__PURE__*/React__default.createElement(Tooltip, {
376
+ placement: "right"
377
+ }, /*#__PURE__*/React__default.createElement(Tooltip.Trigger, null, DataPointComponent), /*#__PURE__*/React__default.createElement(Tooltip.Content, null, /*#__PURE__*/React__default.createElement(Text, {
378
+ variant: "caption"
379
+ }, text, hasText && hasValue ? ' - ' : null, hasValue ? /*#__PURE__*/React__default.createElement(Number$1, {
380
+ value: tooltipValue,
381
+ type: tooltipVariant === TooltipVariant.percent ? 'percent' : 'decimal',
382
+ variant: "caption",
383
+ maximumFractionDigits: 2
384
+ }) : null)));
183
385
  }
184
- `;
185
- const StyledHorizontalBarChartTitle = styled(Flexbox)`
186
- font-family: var(--redsift-typography-h4-font-family);
187
- font-size: var(--redsift-typography-h4-font-size);
188
- font-weight: var(--redsift-typography-h4-font-weight);
189
- line-height: var(--redsift-typography-h4-line-height);
190
- `;
191
- const StyledHorizontalBarChartCaption = styled.p`
192
- font-family: var(--redsift-typography-caption-font-family);
193
- font-size: var(--redsift-typography-caption-font-size);
194
- font-weight: var(--redsift-typography-caption-font-weight);
195
- line-height: var(--redsift-typography-caption-line-height);
196
- `;
197
- const StyledHorizontalBarChartEmptyText = styled.div`
198
- position: absolute;
199
- top: 0;
200
- left: 0;
201
- height: 100%;
202
- width: 100%;
203
- display: flex;
204
- flex-direction: column;
205
- justify-content: center;
206
- align-items: center;
207
- pointer-events: none;
386
+ return DataPointComponent;
387
+ });
208
388
 
209
- > * {
210
- max-width: ${_ref => {
389
+ /**
390
+ * Component style.
391
+ */
392
+ const StyledArc = styled(DataPoint)`
393
+ ${_ref => {
211
394
  let {
212
- $maxWidth
395
+ $hasStroke
213
396
  } = _ref;
214
- return $maxWidth;
215
- }}px;
216
- }
217
-
218
- > span {
219
- font-family: var(--redsift-typography-font-family-raleway);
220
- color: var(--redsift-color-neutral-black);
221
- font-size: ${_ref2 => {
222
- let {
223
- $textSize
224
- } = _ref2;
225
- return $textSize;
226
- }}px;
227
- line-height: ${_ref3 => {
228
- let {
229
- $textSize
230
- } = _ref3;
231
- return $textSize;
232
- }}px;
233
- }
234
- `;
235
- const StyledHorizontalBarChartBar = styled.g`
236
- rect {
237
- fill-opacity: 0.9;
238
- }
397
+ return $hasStroke ? css`
398
+ path {
399
+ stroke-width: 2px;
400
+ stroke: #fff;
401
+ }
402
+ ` : '';
403
+ }}
239
404
 
240
- ${_ref4 => {
405
+ ${_ref2 => {
241
406
  let {
242
407
  $clickable
243
- } = _ref4;
408
+ } = _ref2;
244
409
  return $clickable ? css`
245
410
  cursor: pointer;
246
411
 
247
412
  &:hover,
248
413
  &:focus {
414
+ opacity: 0.8;
249
415
  outline: none;
250
- rect {
251
- fill-opacity: 0.7;
252
- }
253
416
  }
254
417
 
255
418
  &:focus-visible {
256
- rect {
419
+ path {
257
420
  stroke: var(--redsift-color-default-primary);
258
421
  stroke-width: 4px;
259
422
  paint-order: stroke;
@@ -262,315 +425,1052 @@ const StyledHorizontalBarChartBar = styled.g`
262
425
  ` : '';
263
426
  }}}
264
427
  `;
265
- const StyledHorizontalBarChartAxisBottom = styled.g`
266
- line.grid-line {
267
- fill: none;
268
- stroke: #ccc;
269
- shape-rendering: crispEdges;
270
- }
271
428
 
272
- text {
273
- font-family: var(--redsift-typography-font-family-source-code-pro);
274
- font-size: 10px;
275
- }
276
- `;
429
+ const config = (() => ({
430
+ config: {
431
+ duration: 700,
432
+ easing: Lt$1.easeInOutQuad
433
+ },
434
+ reset: true,
435
+ immediate: false
436
+ }))();
277
437
 
278
- const _excluded$4 = ["chartId", "color", "data", "gap", "height", "index", "isEmpty", "onClick", "role", "showTooltip", "tooltipLabelOnly", "tooltipPercent", "width"];
279
- const COMPONENT_NAME$4 = 'HorizontalBarChartBar';
280
- const CLASSNAME$4 = 'redsift-horizontal-barchart-bar';
281
- const DEFAULT_PROPS$4 = {};
282
- const HorizontalBarChartBar = /*#__PURE__*/forwardRef((props, ref) => {
438
+ const _excluded$i = ["className", "createArc", "hasStroke"];
439
+ const COMPONENT_NAME$9 = 'Arc';
440
+ const CLASSNAME$9 = 'redsift-arc';
441
+ const DEFAULT_PROPS$9 = {
442
+ color: monochrome,
443
+ index: 0,
444
+ previousData: {
445
+ data: {
446
+ key: '',
447
+ value: 0
448
+ },
449
+ startAngle: 0,
450
+ endAngle: 0,
451
+ padAngle: 0,
452
+ value: 0,
453
+ index: 0
454
+ }
455
+ };
456
+ const Arc = /*#__PURE__*/forwardRef((props, ref) => {
283
457
  const {
284
- chartId,
285
- color,
286
- data,
287
- gap,
288
- height,
289
- index,
290
- isEmpty,
291
- onClick,
292
- role,
293
- showTooltip,
294
- tooltipLabelOnly,
295
- tooltipPercent,
296
- width
458
+ color,
459
+ data,
460
+ isSelected: propsIsSelected,
461
+ onClick,
462
+ previousData,
463
+ role
464
+ } = props;
465
+ const {
466
+ className,
467
+ createArc,
468
+ hasStroke
297
469
  } = props,
298
- forwardedProps = _objectWithoutProperties(props, _excluded$4);
299
- const onKeyDown = event => {
300
- if (onClick) {
301
- event.stopPropagation();
302
- if (event.code === 'Enter' || event.code === 'Space') {
303
- event.preventDefault();
304
- onClick();
305
- }
470
+ forwardedProps = _objectWithoutProperties(props, _excluded$i);
471
+ const interpolator = interpolate(previousData, data);
472
+ const isSelectable = role === 'option';
473
+ const isDeselected = isSelectable && propsIsSelected === false;
474
+ const animatedProps = J(_objectSpread2(_objectSpread2({}, config), {}, {
475
+ to: async next => {
476
+ await next({
477
+ t: 1
478
+ });
479
+ },
480
+ from: {
481
+ t: 0
306
482
  }
307
- };
308
- const Bar = /*#__PURE__*/React.createElement(StyledHorizontalBarChartBar, _extends({}, forwardedProps, {
483
+ }));
484
+ return /*#__PURE__*/React__default.createElement(StyledArc, _extends({}, forwardedProps, {
309
485
  ref: ref,
310
- "aria-label": showTooltip && !isEmpty ? `${data.name}: ${data.value}` : undefined,
311
- "aria-labelledby": !showTooltip && !isEmpty ? `id${chartId}__slice-${index}-title` : undefined,
312
- id: `id${chartId}__slice-${index}`,
313
- className: `row _${index}`,
314
- onClick: onClick,
315
- onKeyDown: onKeyDown,
316
- role: role ? role : onClick ? 'button' : undefined,
317
- tabIndex: onClick ? 0 : undefined,
318
- transform: `translate(0,${gap * (index + 1) + height * index})`,
319
- $clickable: Boolean(onClick)
320
- }), /*#__PURE__*/React.createElement("rect", {
321
- height: height,
322
- width: width,
323
- fill: color
324
- }), /*#__PURE__*/React.createElement("text", {
325
- x: "10",
326
- y: height / 2,
327
- dy: "0.35em",
328
- "aria-hidden": true
329
- }, data.name), !showTooltip && !isEmpty && /*#__PURE__*/React.createElement("title", null, `${data.name}: ${data.value}`));
330
- if (showTooltip) {
331
- return /*#__PURE__*/React.createElement(Tooltip, {
332
- placement: "right"
333
- }, /*#__PURE__*/React.createElement(Tooltip.Trigger, null, Bar), /*#__PURE__*/React.createElement(Tooltip.Content, null, tooltipLabelOnly ? /*#__PURE__*/React.createElement(Text, {
334
- variant: "caption"
335
- }, data.name) : tooltipPercent !== null ? /*#__PURE__*/React.createElement(Text, {
336
- variant: "caption"
337
- }, data.name, " -", ' ', /*#__PURE__*/React.createElement(Number$1, {
338
- value: tooltipPercent,
339
- type: "percent",
340
- variant: "caption",
341
- maximumFractionDigits: 2
342
- })) : /*#__PURE__*/React.createElement(Text, {
343
- variant: "caption"
344
- }, data.name, " -", ' ', /*#__PURE__*/React.createElement(Number$1, {
345
- value: data.value,
346
- variant: "caption",
347
- maximumFractionDigits: 2
348
- }))));
349
- }
350
- return Bar;
486
+ className: classNames(Arc.className, className),
487
+ $clickable: Boolean(onClick),
488
+ $hasStroke: Boolean(hasStroke)
489
+ }), /*#__PURE__*/React__default.createElement(it.path, {
490
+ d: config.immediate ? createArc(data) : animatedProps.t.to(t => createArc(interpolator(t))),
491
+ fill: isDeselected ? 'var(--redsift-color-neutral-lightgrey)' : color
492
+ }));
351
493
  });
352
- HorizontalBarChartBar.className = CLASSNAME$4;
353
- HorizontalBarChartBar.defaultProps = DEFAULT_PROPS$4;
354
- HorizontalBarChartBar.displayName = COMPONENT_NAME$4;
355
-
356
- const _excluded$3 = ["areXLabelsRotated", "chartHeight", "d3scale"];
357
- const COMPONENT_NAME$3 = 'HorizontalBarChartAxisBottom';
358
- const CLASSNAME$3 = 'redsift-horizontal-barchart-axis-bottom';
359
- const DEFAULT_PROPS$3 = {};
360
- const HorizontalBarChartAxisBottom = /*#__PURE__*/forwardRef((props, ref) => {
494
+ Arc.className = CLASSNAME$9;
495
+ Arc.defaultProps = DEFAULT_PROPS$9;
496
+ Arc.displayName = COMPONENT_NAME$9;
497
+
498
+ /**
499
+ * Component style.
500
+ */
501
+ const StyledArcs = styled.g``;
502
+
503
+ const _excluded$h = ["arcs", "className", "color", "hasLabels", "hasStroke", "id", "labelDecorator", "onClick", "role", "tooltipVariant"];
504
+ const COMPONENT_NAME$8 = 'Arcs';
505
+ const CLASSNAME$8 = 'redsift-arcs';
506
+ const DEFAULT_PROPS$8 = {};
507
+ const Arcs = /*#__PURE__*/forwardRef((props, ref) => {
361
508
  const {
362
- areXLabelsRotated,
363
- chartHeight,
364
- d3scale
509
+ arcs,
510
+ className,
511
+ color,
512
+ hasLabels,
513
+ hasStroke,
514
+ id: propsId,
515
+ labelDecorator,
516
+ onClick,
517
+ role,
518
+ tooltipVariant
365
519
  } = props,
366
- forwardedProps = _objectWithoutProperties(props, _excluded$3);
367
- const axisRef = ref || useRef();
368
- useEffect(() => {
369
- if (axisRef.current) {
370
- select(axisRef.current).call(axisBottom(d3scale).ticks(5));
371
- select(axisRef.current).selectAll('g.tick').select('line.grid-line').remove();
372
- select(axisRef.current).selectAll('g.tick').append('line').attr('class', 'grid-line').attr('x1', 0).attr('y1', 0).attr('x2', 0).attr('y2', () => -chartHeight);
373
- if (areXLabelsRotated) {
374
- select(axisRef.current).attr('text-anchor', 'end').selectAll('text').attr('transform', 'translate(-6,5) rotate(-45)');
375
- }
520
+ forwardedProps = _objectWithoutProperties(props, _excluded$h);
521
+ const id = propsId !== null && propsId !== void 0 ? propsId : useId();
522
+ const animatedProps = J(_objectSpread2(_objectSpread2({}, config), {}, {
523
+ to: async next => {
524
+ await next({
525
+ t: 1
526
+ });
527
+ },
528
+ from: {
529
+ t: 0
376
530
  }
377
- }, [d3scale]);
378
- return /*#__PURE__*/React.createElement(StyledHorizontalBarChartAxisBottom, _extends({
379
- className: "axis"
380
- }, forwardedProps, {
381
- ref: axisRef
382
531
  }));
532
+ return /*#__PURE__*/React__default.createElement(StyledArcs, _extends({}, forwardedProps, {
533
+ className: classNames(Arcs.className, className),
534
+ ref: ref
535
+ }), /*#__PURE__*/React__default.createElement("g", {
536
+ className: "arc-group"
537
+ }, arcs.map((arc, index) => {
538
+ var _arc$index, _arc$id;
539
+ const arcIndex = (_arc$index = arc.index) !== null && _arc$index !== void 0 ? _arc$index : index;
540
+ const arcId = (_arc$id = arc.id) !== null && _arc$id !== void 0 ? _arc$id : `id${id}__arc-${arcIndex}`;
541
+ return /*#__PURE__*/React__default.createElement(Arc, _extends({
542
+ color: color,
543
+ hasStroke: hasStroke,
544
+ labelDecorator: labelDecorator,
545
+ onClick: onClick,
546
+ role: role,
547
+ tooltipVariant: tooltipVariant
548
+ }, arc, {
549
+ key: arcId,
550
+ id: arcId,
551
+ index: arcIndex
552
+ }));
553
+ })), hasLabels ? /*#__PURE__*/React__default.createElement("g", {
554
+ className: "arc-label-group"
555
+ }, arcs.filter(arc => {
556
+ const value = arc.data.data.value;
557
+ const percent = arc.data.data.percent;
558
+ return percent ? value > 0 && percent >= 0.1 : value > 0;
559
+ }).map((arc, index) => {
560
+ var _arc$index2, _arc$id2, _arc$labelDecorator;
561
+ const arcIndex = (_arc$index2 = arc.index) !== null && _arc$index2 !== void 0 ? _arc$index2 : index;
562
+ const arcId = (_arc$id2 = arc.id) !== null && _arc$id2 !== void 0 ? _arc$id2 : `id${id}__arc-${arcIndex}`;
563
+ const arcLabelDecorator = (_arc$labelDecorator = arc.labelDecorator) !== null && _arc$labelDecorator !== void 0 ? _arc$labelDecorator : labelDecorator;
564
+ const interpolator = interpolate(arc.from, arc.data);
565
+ return /*#__PURE__*/React__default.createElement(it.text, {
566
+ alignmentBaseline: "middle",
567
+ className: `arc-label _${index}`,
568
+ key: `${arcId}-label`,
569
+ textAnchor: "middle",
570
+ transform: config.immediate ? `translate(${arc.createArc.centroid(arc.data)})` : animatedProps.t.to(t => `translate(${arc.createArc.centroid(interpolator(t))})`)
571
+ }, arcLabelDecorator ? arcLabelDecorator(arc.data) : arc.data.data.key);
572
+ })) : null);
383
573
  });
384
- HorizontalBarChartAxisBottom.className = CLASSNAME$3;
385
- HorizontalBarChartAxisBottom.defaultProps = DEFAULT_PROPS$3;
386
- HorizontalBarChartAxisBottom.displayName = COMPONENT_NAME$3;
574
+ Arcs.className = CLASSNAME$8;
575
+ Arcs.defaultProps = DEFAULT_PROPS$8;
576
+ Arcs.displayName = COMPONENT_NAME$8;
387
577
 
388
- const _excluded$2 = ["aria-label", "aria-labelledby", "areXLabelsRotated", "caping", "caption", "className", "data", "onBarClick", "others", "size", "barRole", "theme", "title", "tooltipVariant", "localeText"];
389
- const COMPONENT_NAME$2 = 'HorizontalBarChart';
390
- const CLASSNAME$2 = 'redsift-horizontal-barchart';
391
- const DEFAULT_PROPS$2 = {
392
- others: true,
393
- size: HorizontalBarChartSize.medium,
394
- theme: HorizontalBarChartTheme.default,
395
- tooltipVariant: HorizontalBarChartTooltipVariant.value,
396
- localeText: {
397
- emptyChartText: 'No Data'
398
- }
578
+ /**
579
+ * Component variant.
580
+ */
581
+ const AxisPosition = {
582
+ top: 'top',
583
+ right: 'right',
584
+ bottom: 'bottom',
585
+ left: 'left'
399
586
  };
400
- const sizeToDimension$1 = size => {
401
- switch (size) {
402
- case HorizontalBarChartSize.small:
403
- return {
404
- width: 300,
405
- height: 200
406
- };
407
- case HorizontalBarChartSize.large:
408
- return {
409
- width: 500,
410
- height: 400
411
- };
412
- case HorizontalBarChartSize.medium:
413
- default:
414
- return {
415
- width: 400,
416
- height: 300
417
- };
587
+
588
+ /**
589
+ * Component style.
590
+ */
591
+ const StyledAxis = styled(it.g)`
592
+ .redsift-axis__line,
593
+ .redsift-axis-tick__line {
594
+ fill: none;
595
+ stroke: var(--redsift-color-neutral-black);
596
+ shape-rendering: crispEdges;
597
+ }
598
+
599
+ text {
600
+ font-family: var(--redsift-typography-font-family-source-code-pro);
601
+ font-size: 10px;
602
+ }
603
+ `;
604
+
605
+ const getScaleTicks = (scale, spec) => {
606
+ // specific values
607
+ if (Array.isArray(spec)) {
608
+ return spec;
609
+ }
610
+
611
+ // continuous scales
612
+ if ('ticks' in scale) {
613
+ // default behaviour
614
+ if (spec === undefined) {
615
+ return scale.ticks();
616
+ }
617
+
618
+ // specific tick count
619
+ if (typeof spec === 'number' && isFinite(spec) && Math.floor(spec) === spec) {
620
+ return scale.ticks(spec);
621
+ }
622
+ }
623
+
624
+ // non linear scale default
625
+ return scale.domain();
626
+ };
627
+ const centerScale = scale => {
628
+ const bandwidth = scale.bandwidth();
629
+ if (bandwidth === 0) return scale;
630
+ let offset = bandwidth / 2;
631
+ if (scale.round()) {
632
+ offset = Math.round(offset);
633
+ }
634
+ return d => {
635
+ var _scale;
636
+ return ((_scale = scale(d)) !== null && _scale !== void 0 ? _scale : 0) + offset;
637
+ };
638
+ };
639
+ const computeTicks = _ref => {
640
+ let {
641
+ axis,
642
+ scale,
643
+ ticksPosition,
644
+ tickValues,
645
+ tickSize,
646
+ tickPadding,
647
+ tickRotation
648
+ } = _ref;
649
+ const values = getScaleTicks(scale, tickValues);
650
+ const position = 'bandwidth' in scale ? centerScale(scale) : scale;
651
+ const line = {
652
+ lineX: 0,
653
+ lineY: 0
654
+ };
655
+ const text = {
656
+ textX: 0,
657
+ textY: 0
658
+ };
659
+ const isRTL = typeof document === 'object' ? document.dir === 'rtl' : false;
660
+ let translate;
661
+ let textAlign = 'middle';
662
+ let textBaseline = 'central';
663
+ if (axis === 'x') {
664
+ translate = d => {
665
+ var _position;
666
+ return {
667
+ x: (_position = position(d)) !== null && _position !== void 0 ? _position : 0,
668
+ y: 0
669
+ };
670
+ };
671
+ line.lineY = tickSize * (ticksPosition === 'after' ? 1 : -1);
672
+ text.textY = (tickSize + tickPadding) * (ticksPosition === 'after' ? 1 : -1);
673
+ if (ticksPosition === 'after') {
674
+ textBaseline = 'text-before-edge';
675
+ } else {
676
+ textBaseline = 'alphabetic';
677
+ }
678
+ if (tickRotation === 0) {
679
+ textAlign = 'middle';
680
+ } else if (ticksPosition === 'after' && tickRotation < 0 || ticksPosition === 'before' && tickRotation > 0) {
681
+ textAlign = isRTL ? 'start' : 'end';
682
+ textBaseline = 'middle';
683
+ } else if (ticksPosition === 'after' && tickRotation > 0 || ticksPosition === 'before' && tickRotation < 0) {
684
+ textAlign = isRTL ? 'end' : 'start';
685
+ textBaseline = 'middle';
686
+ }
687
+ } else {
688
+ translate = d => {
689
+ var _position2;
690
+ return {
691
+ x: 0,
692
+ y: (_position2 = position(d)) !== null && _position2 !== void 0 ? _position2 : 0
693
+ };
694
+ };
695
+ line.lineX = tickSize * (ticksPosition === 'after' ? 1 : -1);
696
+ text.textX = (tickSize + tickPadding) * (ticksPosition === 'after' ? 1 : -1);
697
+ if (ticksPosition === 'after') {
698
+ textAlign = 'start';
699
+ } else {
700
+ textAlign = 'end';
701
+ }
702
+ }
703
+ const ticks = values.map(value => _objectSpread2(_objectSpread2(_objectSpread2({
704
+ key: value instanceof Date ? `${value.valueOf()}` : `${value}`,
705
+ value
706
+ }, translate(value)), line), text));
707
+ return {
708
+ ticks,
709
+ textAlign,
710
+ textBaseline
711
+ };
712
+ };
713
+
714
+ const _excluded$g = ["className", "length", "legend", "legendOffset", "legendPosition", "position", "scale", "tickPadding", "tickRotation", "tickSize", "tickValues", "x", "y"];
715
+ const COMPONENT_NAME$7 = 'Axis';
716
+ const CLASSNAME$7 = 'redsift-axis';
717
+ const DEFAULT_PROPS$7 = {
718
+ position: AxisPosition.bottom,
719
+ legendOffset: -32,
720
+ legendPosition: 'end',
721
+ tickPadding: 5,
722
+ tickRotation: 0,
723
+ tickSize: 5,
724
+ x: 0,
725
+ y: 0
726
+ };
727
+ const getAxisType = position => [AxisPosition.top, AxisPosition.bottom].includes(position) ? 'x' : 'y';
728
+ const Axis = /*#__PURE__*/forwardRef((props, ref) => {
729
+ const {
730
+ className,
731
+ length,
732
+ legend,
733
+ legendOffset,
734
+ legendPosition,
735
+ position,
736
+ scale,
737
+ tickPadding,
738
+ tickRotation,
739
+ tickSize,
740
+ tickValues,
741
+ x,
742
+ y
743
+ } = props,
744
+ forwardedProps = _objectWithoutProperties(props, _excluded$g);
745
+ const axis = getAxisType(position);
746
+ const axisRef = ref || useRef();
747
+ const animatedProps = J(_objectSpread2(_objectSpread2({}, config), {}, {
748
+ to: async next => {
749
+ await next({
750
+ lineX2: axis === 'x' ? length : 0,
751
+ lineY2: axis === 'x' ? 0 : length
752
+ });
753
+ },
754
+ from: {
755
+ lineX2: 0,
756
+ lineY2: 0
757
+ },
758
+ reset: false
759
+ }));
760
+ let legendNode = null;
761
+ if (legend !== undefined) {
762
+ let legendX = 0;
763
+ let legendY = 0;
764
+ let legendRotation = 0;
765
+ let textAnchor;
766
+ if (axis === 'y') {
767
+ legendRotation = -90;
768
+ legendX = legendOffset;
769
+ if (legendPosition === 'start') {
770
+ textAnchor = 'start';
771
+ legendY = length;
772
+ } else if (legendPosition === 'middle') {
773
+ textAnchor = 'middle';
774
+ legendY = length / 2;
775
+ } else if (legendPosition === 'end') {
776
+ textAnchor = 'end';
777
+ }
778
+ } else {
779
+ legendY = legendOffset;
780
+ if (legendPosition === 'start') {
781
+ textAnchor = 'start';
782
+ } else if (legendPosition === 'middle') {
783
+ textAnchor = 'middle';
784
+ legendX = length / 2;
785
+ } else if (legendPosition === 'end') {
786
+ textAnchor = 'end';
787
+ legendX = length;
788
+ }
789
+ }
790
+ legendNode = /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("text", {
791
+ transform: `translate(${legendX}, ${legendY}) rotate(${legendRotation})`,
792
+ textAnchor: textAnchor,
793
+ style: {
794
+ dominantBaseline: 'central'
795
+ }
796
+ }, legend));
797
+ }
798
+ const {
799
+ ticks,
800
+ textAlign,
801
+ textBaseline
802
+ } = computeTicks({
803
+ axis,
804
+ scale,
805
+ ticksPosition: [AxisPosition.top, AxisPosition.left].includes(position) ? 'before' : 'after',
806
+ tickValues,
807
+ tickSize: tickSize,
808
+ tickPadding: tickPadding,
809
+ tickRotation: tickRotation
810
+ });
811
+ const transition = Gt(ticks, _objectSpread2(_objectSpread2({}, config), {}, {
812
+ keys: tick => tick.key,
813
+ initial: tick => ({
814
+ opacity: 1,
815
+ transform: `translate(${tick.x},${tick.y})`,
816
+ textTransform: `translate(${tick.textX},${tick.textY}) rotate(${tickRotation})`
817
+ }),
818
+ from: tick => ({
819
+ opacity: 0,
820
+ transform: `translate(${tick.x},${tick.y})`,
821
+ textTransform: `translate(${tick.textX},${tick.textY}) rotate(${tickRotation})`
822
+ }),
823
+ enter: tick => ({
824
+ opacity: 1,
825
+ transform: `translate(${tick.x},${tick.y})`,
826
+ textTransform: `translate(${tick.textX},${tick.textY}) rotate(${tickRotation})`
827
+ }),
828
+ update: tick => ({
829
+ opacity: 1,
830
+ transform: `translate(${tick.x},${tick.y})`,
831
+ textTransform: `translate(${tick.textX},${tick.textY}) rotate(${tickRotation})`
832
+ }),
833
+ leave: {
834
+ opacity: 0
835
+ }
836
+ }));
837
+ return /*#__PURE__*/React__default.createElement(StyledAxis, _extends({
838
+ className: classNames(Axis.className, className)
839
+ }, forwardedProps, {
840
+ transform: `translate(${x},${y})`,
841
+ ref: axisRef
842
+ }), transition((transitionProps, tick, _state, tickIndex) => {
843
+ return /*#__PURE__*/React__default.createElement(it.g, {
844
+ className: `${Axis.className}__tick`,
845
+ key: tickIndex,
846
+ transform: transitionProps.transform,
847
+ style: {
848
+ opacity: transitionProps.opacity
849
+ }
850
+ }, /*#__PURE__*/React__default.createElement("line", {
851
+ className: `${Axis.className}-tick__line`,
852
+ x1: 0,
853
+ x2: tick.lineX,
854
+ y1: 0,
855
+ y2: tick.lineY
856
+ }), /*#__PURE__*/React__default.createElement(it.text, {
857
+ dominantBaseline: textBaseline,
858
+ textAnchor: textAlign,
859
+ transform: transitionProps.textTransform
860
+ }, `${tick.value}`));
861
+ }), /*#__PURE__*/React__default.createElement(it.line, {
862
+ className: `${Axis.className}__line`,
863
+ x1: 0,
864
+ x2: config.immediate ? axis === 'x' ? length : 0 : animatedProps.lineX2,
865
+ y1: 0,
866
+ y2: config.immediate ? axis === 'x' ? 0 : length : animatedProps.lineY2
867
+ }), legendNode);
868
+ });
869
+ Axis.className = CLASSNAME$7;
870
+ Axis.defaultProps = DEFAULT_PROPS$7;
871
+ Axis.displayName = COMPONENT_NAME$7;
872
+
873
+ /**
874
+ * Component variant.
875
+ */
876
+ const BarOrientation = {
877
+ horizontal: 'horizontal',
878
+ vertical: 'vertical'
879
+ };
880
+
881
+ /**
882
+ * Component style.
883
+ */
884
+ const StyledBar = styled(DataPoint)`
885
+ rect {
886
+ fill-opacity: 0.9;
418
887
  }
888
+
889
+ ${_ref => {
890
+ let {
891
+ $clickable
892
+ } = _ref;
893
+ return $clickable ? css`
894
+ cursor: pointer;
895
+
896
+ &:hover,
897
+ &:focus {
898
+ outline: none;
899
+ rect {
900
+ fill-opacity: 0.7;
901
+ }
902
+ }
903
+
904
+ &:focus-visible {
905
+ rect {
906
+ stroke: var(--redsift-color-default-primary);
907
+ stroke-width: 4px;
908
+ paint-order: stroke;
909
+ }
910
+ }
911
+ ` : '';
912
+ }}}
913
+ `;
914
+
915
+ const _excluded$f = ["className", "gap", "height", "orientation", "scale", "width"];
916
+ const COMPONENT_NAME$6 = 'Bar';
917
+ const CLASSNAME$6 = 'redsift-bar';
918
+ const DEFAULT_PROPS$6 = {
919
+ color: monochrome,
920
+ index: 0,
921
+ gap: 5,
922
+ height: 40,
923
+ orientation: BarOrientation.horizontal,
924
+ previousData: {
925
+ data: {
926
+ key: '',
927
+ value: 0
928
+ }
929
+ },
930
+ width: 40
931
+ };
932
+ const Bar = /*#__PURE__*/forwardRef((props, ref) => {
933
+ var _data;
934
+ const {
935
+ color,
936
+ data,
937
+ index,
938
+ isSelected: propsIsSelected,
939
+ labelDecorator,
940
+ onClick,
941
+ previousData,
942
+ role
943
+ } = props;
944
+ const {
945
+ className,
946
+ gap,
947
+ height,
948
+ orientation,
949
+ scale,
950
+ width
951
+ } = props,
952
+ forwardedProps = _objectWithoutProperties(props, _excluded$f);
953
+ const interpolator = interpolate(((_data = previousData.data) === null || _data === void 0 ? void 0 : _data.value) || 0, data.data.value);
954
+ const text = labelDecorator ? labelDecorator(data) : data.data.key;
955
+ const isSelectable = role === 'option';
956
+ const isDeselected = isSelectable && propsIsSelected === false;
957
+ const animatedProps = J(_objectSpread2(_objectSpread2({}, config), {}, {
958
+ to: async next => {
959
+ await next({
960
+ t: 1
961
+ });
962
+ },
963
+ from: {
964
+ t: 0
965
+ }
966
+ }));
967
+ return /*#__PURE__*/React__default.createElement(StyledBar, _extends({}, forwardedProps, {
968
+ ref: ref,
969
+ className: classNames(Bar.className, className),
970
+ transform: orientation === BarOrientation.horizontal ? `translate(0, ${gap * (index + 1) + height * index})` : `translate(${gap * (index + 1) + width * index}, 0)`,
971
+ $clickable: Boolean(onClick)
972
+ }), orientation === BarOrientation.horizontal ? /*#__PURE__*/React__default.createElement(it.rect, {
973
+ height: height,
974
+ fill: isDeselected ? 'var(--redsift-color-neutral-lightgrey)' : color,
975
+ width: config.immediate ? scale(data.data.value) : animatedProps.t.to(t => scale(interpolator(t)))
976
+ }) : /*#__PURE__*/React__default.createElement(it.rect, {
977
+ height: config.immediate ? scale(data.data.value) : animatedProps.t.to(t => scale(interpolator(t))),
978
+ fill: isDeselected ? 'var(--redsift-color-neutral-lightgrey)' : color,
979
+ width: width
980
+ }), orientation === BarOrientation.horizontal ? /*#__PURE__*/React__default.createElement("text", {
981
+ x: "10",
982
+ y: height / 2,
983
+ dy: "0.35em",
984
+ "aria-hidden": true
985
+ }, text) : null);
986
+ });
987
+ Bar.className = CLASSNAME$6;
988
+ Bar.defaultProps = DEFAULT_PROPS$6;
989
+ Bar.displayName = COMPONENT_NAME$6;
990
+
991
+ var reset$1 = "Reset";
992
+ var enUS = {
993
+ reset: reset$1
994
+ };
995
+
996
+ var reset = "Réinitialiser";
997
+ var frFR = {
998
+ reset: reset
999
+ };
1000
+
1001
+ var intlMessages = {
1002
+ 'en-US': enUS,
1003
+ 'fr-FR': frFR
419
1004
  };
420
- const sizeToFontSize$1 = size => {
1005
+
1006
+ /**
1007
+ * Component style.
1008
+ */
1009
+ const StyledChartContainer = styled.div`
1010
+ ${baseStyling}
1011
+
1012
+ margin: 8px;
1013
+ padding: 8px;
1014
+ color: var(--redsift-color-neutral-black);
1015
+
1016
+ .redsift-chart-container__content {
1017
+ display: flex;
1018
+ align-items: center;
1019
+ gap: 16px;
1020
+ font-family: var(--redsift-typography-font-family-source-code-pro);
1021
+ font-size: 11px;
1022
+ justify-content: center;
1023
+ margin: 8px 0;
1024
+ position: relative;
1025
+ }
1026
+
1027
+ svg {
1028
+ display: block;
1029
+ }
1030
+ `;
1031
+ const StyledChartContainerTitle = styled(Flexbox)``;
1032
+ const StyledChartContainerCaption = styled.p`
1033
+ font-family: var(--redsift-typography-caption-font-family);
1034
+ font-size: var(--redsift-typography-caption-font-size);
1035
+ font-weight: var(--redsift-typography-caption-font-weight);
1036
+ line-height: var(--redsift-typography-caption-line-height);
1037
+ `;
1038
+
1039
+ const _excluded$e = ["aria-label", "aria-labelledby", "caption", "children", "className", "id", "title", "onReset"];
1040
+ const COMPONENT_NAME$5 = 'ChartContainer';
1041
+ const CLASSNAME$5 = 'redsift-chart-container';
1042
+ const DEFAULT_PROPS$5 = {};
1043
+ const ChartContainer = /*#__PURE__*/forwardRef((props, ref) => {
1044
+ const {
1045
+ 'aria-label': propsAriaLabel,
1046
+ 'aria-labelledby': propsAriaLabelledby,
1047
+ caption,
1048
+ children,
1049
+ className,
1050
+ id: propsId,
1051
+ title,
1052
+ onReset
1053
+ } = props,
1054
+ forwardedProps = _objectWithoutProperties(props, _excluded$e);
1055
+ const id = propsId !== null && propsId !== void 0 ? propsId : useId();
1056
+ warnIfNoAccessibleLabelFound(props, [title]);
1057
+ const stringFormatter = useLocalizedStringFormatter(intlMessages);
1058
+ const ariaLabel = propsAriaLabel ? propsAriaLabel : propsAriaLabelledby || title ? undefined : undefined;
1059
+ const ariaLabelledby = propsAriaLabelledby ? propsAriaLabelledby : title ? `id${id}__title` : undefined;
1060
+ return /*#__PURE__*/React__default.createElement(StyledChartContainer, _extends({}, forwardedProps, {
1061
+ ref: ref,
1062
+ className: classNames(ChartContainer.className, className),
1063
+ id: id
1064
+ }), title || onReset ? /*#__PURE__*/React__default.createElement(StyledChartContainerTitle, {
1065
+ alignItems: "center",
1066
+ justifyContent: "space-between",
1067
+ className: `${ChartContainer.className}__title`,
1068
+ id: `id${id}__title`
1069
+ }, typeof title === 'string' ? /*#__PURE__*/React__default.createElement(Heading, {
1070
+ as: "h3"
1071
+ }, title) : title ? title : null, onReset ? /*#__PURE__*/React__default.createElement(Button, {
1072
+ className: `${ChartContainer.className}-title__reset-button`,
1073
+ color: "question",
1074
+ variant: "unstyled",
1075
+ onPress: onReset
1076
+ }, stringFormatter.format('reset')) : null) : null, children ? /*#__PURE__*/React__default.createElement("div", {
1077
+ className: `${ChartContainer.className}__content`,
1078
+ "aria-label": ariaLabel,
1079
+ "aria-labelledby": ariaLabelledby
1080
+ }, children) : null, caption ? /*#__PURE__*/React__default.createElement(StyledChartContainerCaption, {
1081
+ className: `${ChartContainer.className}__caption`
1082
+ }, caption) : null);
1083
+ });
1084
+ ChartContainer.className = CLASSNAME$5;
1085
+ ChartContainer.defaultProps = DEFAULT_PROPS$5;
1086
+ ChartContainer.displayName = COMPONENT_NAME$5;
1087
+
1088
+ /**
1089
+ * Component style.
1090
+ */
1091
+ const StyledLegend = styled.ul`
1092
+ max-width: 262px;
1093
+ ${_ref => {
1094
+ let {
1095
+ $width
1096
+ } = _ref;
1097
+ return $width !== undefined ? css`
1098
+ width: ${$width};
1099
+ ` : null;
1100
+ }}
1101
+ `;
1102
+ const StyledLabel = styled.li`
1103
+ display: flex;
1104
+ align-items: center;
1105
+ gap: 8px;
1106
+ font-size: var(--redsift-typography-caption-font-size);
1107
+
1108
+ > div {
1109
+ height: 16px;
1110
+ width: 16px;
1111
+ min-width: 16px;
1112
+ background-color: ${_ref2 => {
1113
+ let {
1114
+ $color
1115
+ } = _ref2;
1116
+ return $color;
1117
+ }};
1118
+ }
1119
+ `;
1120
+
1121
+ const _excluded$d = ["className", "data", "variant", "width"];
1122
+ const COMPONENT_NAME$4 = 'Legend';
1123
+ const CLASSNAME$4 = 'redsift-chart-legend';
1124
+ const DEFAULT_PROPS$4 = {
1125
+ variant: LabelVariant.label
1126
+ };
1127
+ const Legend = /*#__PURE__*/forwardRef((props, ref) => {
1128
+ const {
1129
+ className,
1130
+ data,
1131
+ variant,
1132
+ width
1133
+ } = props,
1134
+ forwardedProps = _objectWithoutProperties(props, _excluded$d);
1135
+ const total = sum(data, d => d.value);
1136
+ return /*#__PURE__*/React__default.createElement(StyledLegend, _extends({}, forwardedProps, {
1137
+ className: classNames(Legend.className, className),
1138
+ ref: ref,
1139
+ $width: width
1140
+ }), data.map((_ref, index) => {
1141
+ let {
1142
+ key,
1143
+ value,
1144
+ color
1145
+ } = _ref;
1146
+ return /*#__PURE__*/React__default.createElement(StyledLabel, {
1147
+ key: `pie-external-label _${index}`,
1148
+ $color: color
1149
+ }, /*#__PURE__*/React__default.createElement("div", null), variant === LabelVariant.value ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Number$1, {
1150
+ as: "b",
1151
+ maximumFractionDigits: 2,
1152
+ value: value,
1153
+ variant: "inherit"
1154
+ }), /*#__PURE__*/React__default.createElement(Text, {
1155
+ variant: "caption"
1156
+ }, key)) : variant === LabelVariant.percent ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Number$1, {
1157
+ as: "b",
1158
+ maximumFractionDigits: 2,
1159
+ type: "percent",
1160
+ value: value / total,
1161
+ variant: "inherit"
1162
+ }), /*#__PURE__*/React__default.createElement(Text, {
1163
+ variant: "caption"
1164
+ }, key)) : /*#__PURE__*/React__default.createElement(Text, {
1165
+ variant: "caption"
1166
+ }, key));
1167
+ }));
1168
+ });
1169
+ Legend.className = CLASSNAME$4;
1170
+ Legend.defaultProps = DEFAULT_PROPS$4;
1171
+ Legend.displayName = COMPONENT_NAME$4;
1172
+
1173
+ /**
1174
+ * Component style.
1175
+ */
1176
+ const StyledBarChart = styled(ChartContainer)``;
1177
+ const StyledBarChartEmptyText = styled.div`
1178
+ position: absolute;
1179
+ top: 0;
1180
+ left: 0;
1181
+ height: 100%;
1182
+ width: 100%;
1183
+ display: flex;
1184
+ flex-direction: column;
1185
+ justify-content: center;
1186
+ align-items: center;
1187
+ pointer-events: none;
1188
+
1189
+ > * {
1190
+ max-width: ${_ref => {
1191
+ let {
1192
+ $maxWidth
1193
+ } = _ref;
1194
+ return $maxWidth;
1195
+ }}px;
1196
+ }
1197
+
1198
+ > span {
1199
+ font-family: var(--redsift-typography-font-family-raleway);
1200
+ color: var(--redsift-color-neutral-black);
1201
+ font-size: ${_ref2 => {
1202
+ let {
1203
+ $textSize
1204
+ } = _ref2;
1205
+ return $textSize;
1206
+ }}px;
1207
+ line-height: ${_ref3 => {
1208
+ let {
1209
+ $textSize
1210
+ } = _ref3;
1211
+ return $textSize;
1212
+ }}px;
1213
+ }
1214
+ `;
1215
+
1216
+ const sizeToDimension$2 = size => {
1217
+ if (typeof size !== 'string') {
1218
+ return size;
1219
+ }
421
1220
  switch (size) {
422
- case HorizontalBarChartSize.small:
423
- return 30;
424
- case HorizontalBarChartSize.large:
425
- return 38;
426
- case HorizontalBarChartSize.medium:
1221
+ case ChartSize.small:
1222
+ return {
1223
+ width: 300,
1224
+ height: 200,
1225
+ fontSize: 30
1226
+ };
1227
+ case ChartSize.large:
1228
+ return {
1229
+ width: 500,
1230
+ height: 400,
1231
+ fontSize: 38
1232
+ };
1233
+ case ChartSize.medium:
427
1234
  default:
428
- return 34;
1235
+ return {
1236
+ width: 400,
1237
+ height: 300,
1238
+ fontSize: 34
1239
+ };
429
1240
  }
430
1241
  };
431
- const HorizontalBarChart = /*#__PURE__*/forwardRef((props, ref) => {
432
- const id = useId();
1242
+
1243
+ const _excluded$c = ["className", "emptyComponent", "size", "localeText"];
1244
+ const EmptyBarChart = /*#__PURE__*/forwardRef((props, ref) => {
1245
+ const {
1246
+ className,
1247
+ emptyComponent,
1248
+ size,
1249
+ localeText
1250
+ } = props,
1251
+ forwardedProps = _objectWithoutProperties(props, _excluded$c);
1252
+ const chartDimensions = sizeToDimension$2(size);
1253
+ const width = chartDimensions.width;
1254
+ const height = chartDimensions.height;
1255
+ const margins = {
1256
+ top: 16,
1257
+ left: 16,
1258
+ right: 16,
1259
+ bottom: 32
1260
+ };
1261
+ const chartHeight = height - margins.top - margins.bottom;
1262
+ const chartWidth = width - margins.left - margins.right;
1263
+ const scaleRef = useRef();
1264
+ if (!scaleRef.current) {
1265
+ scaleRef.current = scaleLinear().domain([]).range([0, chartWidth]);
1266
+ }
1267
+ return /*#__PURE__*/React__default.createElement(StyledBarChart, _extends({}, forwardedProps, {
1268
+ className: className,
1269
+ ref: ref
1270
+ }), emptyComponent !== null && emptyComponent !== void 0 ? emptyComponent : /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(StyledBarChartEmptyText, {
1271
+ $maxWidth: width,
1272
+ $textSize: chartDimensions.fontSize / 2
1273
+ }, /*#__PURE__*/React__default.createElement("span", null, localeText === null || localeText === void 0 ? void 0 : localeText.emptyChartText)), /*#__PURE__*/React__default.createElement("svg", {
1274
+ width: width,
1275
+ height: height
1276
+ }, /*#__PURE__*/React__default.createElement("g", {
1277
+ transform: `translate(${margins.left},${margins.top})`
1278
+ }, /*#__PURE__*/React__default.createElement(Axis, {
1279
+ position: "bottom",
1280
+ length: chartWidth,
1281
+ scale: scaleRef.current,
1282
+ x: 0,
1283
+ y: chartHeight,
1284
+ tickValues: 4
1285
+ })))));
1286
+ });
1287
+
1288
+ const _excluded$b = ["className"];
1289
+ const LoadingBarChart = /*#__PURE__*/forwardRef((props, ref) => {
1290
+ const {
1291
+ className
1292
+ } = props,
1293
+ forwardedProps = _objectWithoutProperties(props, _excluded$b);
1294
+ return /*#__PURE__*/React__default.createElement(StyledBarChart, _extends({}, forwardedProps, {
1295
+ className: className,
1296
+ ref: ref
1297
+ }), "Loading...");
1298
+ });
1299
+
1300
+ const _excluded$a = ["areXLabelsRotated", "caping", "className", "data", "id", "isBarSelected", "labelDecorator", "onBarClick", "others", "size", "barRole", "theme", "tooltipVariant"];
1301
+ const RenderedBarChart = /*#__PURE__*/forwardRef((props, ref) => {
433
1302
  const {
434
- 'aria-label': ariaLabel,
435
- 'aria-labelledby': ariaLabelledby,
436
1303
  areXLabelsRotated,
437
1304
  caping,
438
- caption,
439
1305
  className,
440
- data: propData,
1306
+ data: propsData,
1307
+ id,
1308
+ isBarSelected,
1309
+ labelDecorator,
441
1310
  onBarClick,
442
1311
  others,
443
1312
  size,
444
1313
  barRole,
445
1314
  theme,
446
- title,
447
- tooltipVariant,
448
- localeText
1315
+ tooltipVariant
449
1316
  } = props,
450
- forwardedProps = _objectWithoutProperties(props, _excluded$2);
1317
+ forwardedProps = _objectWithoutProperties(props, _excluded$a);
1318
+ const cache = useRef();
451
1319
  const {
452
- emptyChartText
453
- } = _objectSpread2(_objectSpread2({}, DEFAULT_PROPS$2.localeText), localeText);
454
- const isEmpty = propData.every(d => d.value === 0);
455
- let data = propData.sort((a, b) => a.value < b.value ? 1 : -1);
456
- if (caping) {
457
- if (typeof others === 'boolean' && !others) {
458
- data = data.slice(0, caping);
459
- } else {
460
- data = data.reduce((acc, curr, index) => {
461
- if (index < caping) {
462
- acc[index] = curr;
463
- } else if (index === caping) {
464
- acc[index] = {
465
- name: typeof others === 'string' ? others : 'Others',
466
- value: curr.value
467
- };
468
- } else {
469
- acc[caping] = _objectSpread2(_objectSpread2({}, acc[caping]), {}, {
470
- value: acc[caping].value + curr.value
471
- });
472
- }
473
- return acc;
474
- }, []);
475
- }
476
- }
477
- if (isEmpty) {
478
- data = [];
479
- }
480
-
481
- // Get charts dimensions based on the selected size.
482
- const chartDimensions = sizeToDimension$1(size);
483
- const width = chartDimensions.width - 16;
1320
+ data,
1321
+ colorScale
1322
+ } = useFormatCategoricalData({
1323
+ data: propsData,
1324
+ theme: theme,
1325
+ caping,
1326
+ others
1327
+ });
1328
+ useEffect(() => {
1329
+ cache.current = data;
1330
+ });
1331
+ const chartDimensions = sizeToDimension$2(size);
1332
+ const width = chartDimensions.width;
484
1333
  const height = chartDimensions.height;
485
- const chartHeight = height - 48 - (areXLabelsRotated ? 30 : 0);
486
1334
  const margins = {
487
1335
  top: 16,
488
1336
  left: 16,
489
1337
  right: 16,
490
1338
  bottom: 32
491
1339
  };
1340
+ const chartHeight = height - margins.top - margins.bottom;
1341
+ const chartWidth = width - margins.left - margins.right;
492
1342
  const numberOfRows = data.length;
493
1343
  const gap = 5;
494
-
495
- // Set color scheme.
496
- const d3colors = getColorScale(theme, isEmpty);
497
-
498
- // Initialize the chart.
499
- const scaleX = scaleLinear().domain([0, Math.max(...data.map(_ref => {
500
- let {
501
- value
502
- } = _ref;
503
- return value;
504
- }))]).range([0, width - 32]);
1344
+ const scaleRef = useRef();
1345
+ if (!scaleRef.current) {
1346
+ scaleRef.current = scaleLinear().domain([0, Math.max(...data.map(_ref => {
1347
+ let {
1348
+ value
1349
+ } = _ref;
1350
+ return value;
1351
+ }))]).range([0, chartWidth]);
1352
+ }
505
1353
  const barHeight = (chartHeight - (numberOfRows + 1) * gap) / numberOfRows;
506
1354
  const total = sum(data, d => d.value);
507
- return /*#__PURE__*/React.createElement(StyledHorizontalBarChart, _extends({}, forwardedProps, {
508
- ref: ref,
509
- className: className
510
- }), title ? /*#__PURE__*/React.createElement(StyledHorizontalBarChartTitle, {
511
- className: `${HorizontalBarChart.className}__title`,
512
- alignItems: "center",
513
- id: `id${id}__title`
514
- }, title) : null, /*#__PURE__*/React.createElement("div", {
515
- className: `${HorizontalBarChart.className}__container`
516
- }, /*#__PURE__*/React.createElement("div", {
517
- className: `${HorizontalBarChart.className}-container__chart`,
518
- "aria-label": ariaLabel ? ariaLabel : ariaLabelledby || title ? undefined : 'Horizontal Bar Chart',
519
- "aria-labelledby": ariaLabelledby ? ariaLabelledby : title ? `id${id}__title` : undefined
520
- }, isEmpty ? /*#__PURE__*/React.createElement(StyledHorizontalBarChartEmptyText, {
521
- $maxWidth: width,
522
- $textSize: sizeToFontSize$1(size) / 2
523
- }, /*#__PURE__*/React.createElement("span", null, emptyChartText)) : null, /*#__PURE__*/React.createElement("svg", {
1355
+ return /*#__PURE__*/React__default.createElement(StyledBarChart, _extends({}, forwardedProps, {
1356
+ id: id,
1357
+ className: className,
1358
+ ref: ref
1359
+ }), /*#__PURE__*/React__default.createElement("svg", {
524
1360
  width: width,
525
1361
  height: height
526
- }, /*#__PURE__*/React.createElement("g", {
1362
+ }, /*#__PURE__*/React__default.createElement("g", {
527
1363
  transform: `translate(${margins.left},${margins.top})`
528
- }, /*#__PURE__*/React.createElement(HorizontalBarChartAxisBottom, {
529
- areXLabelsRotated: !!areXLabelsRotated,
530
- chartHeight: chartHeight,
531
- d3scale: scaleX,
532
- transform: `translate(0,${chartHeight})`
533
- }), data.map((_ref2, index) => {
534
- let {
535
- value,
536
- name
537
- } = _ref2;
538
- const percent = value / total;
539
- return /*#__PURE__*/React.createElement(HorizontalBarChartBar, {
540
- chartId: id,
541
- color: d3colors(name),
542
- data: {
543
- value,
544
- name
545
- },
1364
+ }, /*#__PURE__*/React__default.createElement(Axis, {
1365
+ position: "bottom",
1366
+ length: chartWidth,
1367
+ scale: scaleRef.current,
1368
+ x: 0,
1369
+ y: chartHeight,
1370
+ tickValues: 4,
1371
+ tickRotation: areXLabelsRotated ? -45 : 0
1372
+ }), data.map((datum, index) => {
1373
+ const percent = datum.value / total;
1374
+ const to = {
1375
+ data: _objectSpread2(_objectSpread2({}, datum), {}, {
1376
+ percent
1377
+ })
1378
+ };
1379
+ const from = cache.current ? {
1380
+ data: cache.current[index]
1381
+ } : undefined;
1382
+ return /*#__PURE__*/React__default.createElement(Bar, {
1383
+ color: colorScale === null || colorScale === void 0 ? void 0 : colorScale(to.data.key),
1384
+ data: to,
546
1385
  gap: gap,
547
1386
  height: barHeight,
1387
+ id: `id${id}__bar-${index}`,
548
1388
  index: index,
549
- isEmpty: isEmpty,
550
- key: `row _${index}`,
551
- onClick: onBarClick ? () => onBarClick(data[index]) : undefined,
1389
+ isSelected: Boolean(isBarSelected(to)),
1390
+ key: `bar _${index}`,
1391
+ labelDecorator: labelDecorator,
1392
+ onClick: onBarClick,
1393
+ previousData: from,
552
1394
  role: barRole,
553
- showTooltip: tooltipVariant !== HorizontalBarChartTooltipVariant.none && !isEmpty,
554
- tooltipLabelOnly: tooltipVariant == HorizontalBarChartTooltipVariant.label,
555
- tooltipPercent: tooltipVariant === HorizontalBarChartTooltipVariant.percent ? percent : null,
556
- width: Math.abs(scaleX(value))
1395
+ scale: scaleRef.current,
1396
+ tooltipVariant: tooltipVariant
557
1397
  });
558
- }))))), caption ? /*#__PURE__*/React.createElement(StyledHorizontalBarChartCaption, {
559
- className: `${HorizontalBarChart.className}__caption`
560
- }, caption) : null);
1398
+ }))));
561
1399
  });
562
- HorizontalBarChart.className = CLASSNAME$2;
563
- HorizontalBarChart.defaultProps = DEFAULT_PROPS$2;
564
- HorizontalBarChart.displayName = COMPONENT_NAME$2;
565
1400
 
566
- /**
567
- * Component size.
568
- */
569
- const PieChartSize = {
570
- small: 'small',
571
- medium: 'medium',
572
- large: 'large'
1401
+ const _excluded$9 = ["areXLabelsRotated", "caping", "className", "data", "emptyComponent", "id", "isBarSelected", "labelDecorator", "localeText", "onBarClick", "others", "size", "barRole", "theme", "tooltipVariant"];
1402
+ const COMPONENT_NAME$3 = 'BarChart';
1403
+ const CLASSNAME$3 = 'redsift-barchart';
1404
+ const DEFAULT_PROPS$3 = {
1405
+ isBarSelected: () => true,
1406
+ others: true,
1407
+ size: ChartSize.medium,
1408
+ theme: ColorTheme.default,
1409
+ tooltipVariant: TooltipVariant.value,
1410
+ localeText: {
1411
+ emptyChartText: 'No Data'
1412
+ }
573
1413
  };
1414
+ const BarChart = /*#__PURE__*/forwardRef((props, ref) => {
1415
+ const {
1416
+ areXLabelsRotated,
1417
+ caping,
1418
+ className,
1419
+ data: propsData,
1420
+ emptyComponent,
1421
+ id: propsId,
1422
+ isBarSelected,
1423
+ labelDecorator,
1424
+ localeText,
1425
+ onBarClick,
1426
+ others,
1427
+ size,
1428
+ barRole,
1429
+ theme,
1430
+ tooltipVariant
1431
+ } = props,
1432
+ forwardedProps = _objectWithoutProperties(props, _excluded$9);
1433
+ const id = propsId !== null && propsId !== void 0 ? propsId : useId();
1434
+ if (propsData === undefined || propsData === null) {
1435
+ return /*#__PURE__*/React__default.createElement(LoadingBarChart, _extends({
1436
+ id: id
1437
+ }, forwardedProps, {
1438
+ ref: ref
1439
+ }));
1440
+ }
1441
+ if (propsData.length === 0) {
1442
+ return /*#__PURE__*/React__default.createElement(EmptyBarChart, _extends({
1443
+ data: propsData,
1444
+ emptyComponent: emptyComponent,
1445
+ id: id,
1446
+ localeText: localeText,
1447
+ size: size
1448
+ }, forwardedProps, {
1449
+ ref: ref
1450
+ }));
1451
+ }
1452
+ return /*#__PURE__*/React__default.createElement(RenderedBarChart, _extends({
1453
+ areXLabelsRotated: areXLabelsRotated,
1454
+ barRole: barRole,
1455
+ caping: caping,
1456
+ className: classNames(BarChart.className, className),
1457
+ data: propsData,
1458
+ id: id,
1459
+ isBarSelected: isBarSelected,
1460
+ labelDecorator: labelDecorator,
1461
+ onBarClick: onBarClick,
1462
+ others: others,
1463
+ size: size,
1464
+ theme: theme,
1465
+ tooltipVariant: tooltipVariant
1466
+ }, forwardedProps, {
1467
+ ref: ref
1468
+ }));
1469
+ });
1470
+ BarChart.className = CLASSNAME$3;
1471
+ BarChart.defaultProps = DEFAULT_PROPS$3;
1472
+ BarChart.displayName = COMPONENT_NAME$3;
1473
+
574
1474
  /**
575
1475
  * Component variant.
576
1476
  */
@@ -590,57 +1490,11 @@ const PieChartLabelVariant = {
590
1490
  externalLabelValue: 'externalLabelValue',
591
1491
  externalLabelPercent: 'externalLabelPercent'
592
1492
  };
593
- /**
594
- * Component theme.
595
- */
596
- const PieChartTheme = ColorTheme;
597
- /**
598
- * Tooltip label variant.
599
- */
600
- const PieChartTooltipVariant = {
601
- none: 'none',
602
- label: 'label',
603
- value: 'value',
604
- percent: 'percent'
605
- };
606
1493
 
607
1494
  /**
608
1495
  * Component style.
609
1496
  */
610
- const StyledPieChart = styled.div`
611
- margin: 8px;
612
- padding: 8px;
613
- color: var(--redsift-color-neutral-black);
614
-
615
- .redsift-piechart__container {
616
- display: flex;
617
- align-items: center;
618
- gap: 16px;
619
- font-family: var(--redsift-typography-font-family-source-code-pro);
620
- font-size: 11px;
621
- justify-content: center;
622
- margin: 8px 0;
623
-
624
- .redsift-piechart-container__chart {
625
- position: relative;
626
- }
627
- }
628
- svg {
629
- display: block;
630
- }
631
- `;
632
- const StyledPieChartTitle = styled(Flexbox)`
633
- font-family: var(--redsift-typography-h4-font-family);
634
- font-size: var(--redsift-typography-h4-font-size);
635
- font-weight: var(--redsift-typography-h4-font-weight);
636
- line-height: var(--redsift-typography-h4-line-height);
637
- `;
638
- const StyledPieChartCaption = styled.p`
639
- font-family: var(--redsift-typography-caption-font-family);
640
- font-size: var(--redsift-typography-caption-font-size);
641
- font-weight: var(--redsift-typography-caption-font-weight);
642
- line-height: var(--redsift-typography-caption-line-height);
643
- `;
1497
+ const StyledPieChart = styled(ChartContainer)``;
644
1498
  const StyledPieChartCenterText = styled.div`
645
1499
  position: absolute;
646
1500
  top: 0;
@@ -734,8 +1588,367 @@ const StyledPieChartCenterText = styled.div`
734
1588
  color: rgba(0, 0, 0, 0.6);
735
1589
  text-align: center;
736
1590
  }
737
- `;
738
- const StyledPieChartEmptyText = styled.div`
1591
+ `;
1592
+ const StyledPieChartEmptyText = styled.div`
1593
+ position: absolute;
1594
+ top: 0;
1595
+ left: 0;
1596
+ height: 100%;
1597
+ width: 100%;
1598
+ display: flex;
1599
+ flex-direction: column;
1600
+ justify-content: center;
1601
+ align-items: center;
1602
+ pointer-events: none;
1603
+
1604
+ > * {
1605
+ max-width: ${_ref10 => {
1606
+ let {
1607
+ $maxWidth
1608
+ } = _ref10;
1609
+ return $maxWidth;
1610
+ }}px;
1611
+ }
1612
+
1613
+ > span {
1614
+ font-family: var(--redsift-typography-font-family-raleway);
1615
+ color: ${_ref11 => {
1616
+ let {
1617
+ $isDonut
1618
+ } = _ref11;
1619
+ return $isDonut ? css`var(--redsift-color-neutral-midgrey)` : css`var(--redsift-color-neutral-black)`;
1620
+ }};
1621
+ font-size: ${_ref12 => {
1622
+ let {
1623
+ $textSize
1624
+ } = _ref12;
1625
+ return $textSize;
1626
+ }}px;
1627
+ line-height: ${_ref13 => {
1628
+ let {
1629
+ $textSize
1630
+ } = _ref13;
1631
+ return $textSize;
1632
+ }}px;
1633
+ }
1634
+ `;
1635
+
1636
+ const _excluded$8 = ["className"];
1637
+ const LoadingPieChart = /*#__PURE__*/forwardRef((props, ref) => {
1638
+ const {
1639
+ className
1640
+ } = props,
1641
+ forwardedProps = _objectWithoutProperties(props, _excluded$8);
1642
+ return /*#__PURE__*/React__default.createElement(StyledPieChart, _extends({}, forwardedProps, {
1643
+ className: className,
1644
+ ref: ref
1645
+ }), "Loading...");
1646
+ });
1647
+
1648
+ const sizeToDimension$1 = size => {
1649
+ if (typeof size !== 'string') {
1650
+ return size;
1651
+ }
1652
+ switch (size) {
1653
+ case ChartSize.small:
1654
+ return {
1655
+ width: 200,
1656
+ height: 200,
1657
+ smallFontSize: 13,
1658
+ fontSize: 30,
1659
+ innerRadius: 55
1660
+ };
1661
+ case ChartSize.large:
1662
+ return {
1663
+ width: 300,
1664
+ height: 300,
1665
+ smallFontSize: 18,
1666
+ fontSize: 38,
1667
+ innerRadius: 80
1668
+ };
1669
+ case ChartSize.medium:
1670
+ default:
1671
+ return {
1672
+ width: 240,
1673
+ height: 240,
1674
+ smallFontSize: 14,
1675
+ fontSize: 34,
1676
+ innerRadius: 65
1677
+ };
1678
+ }
1679
+ };
1680
+
1681
+ const _excluded$7 = ["className", "emptyComponent", "localeText", "size", "variant"];
1682
+ const EmptyPieChart = /*#__PURE__*/forwardRef((props, ref) => {
1683
+ const {
1684
+ className,
1685
+ emptyComponent,
1686
+ localeText,
1687
+ size,
1688
+ variant
1689
+ } = props,
1690
+ forwardedProps = _objectWithoutProperties(props, _excluded$7);
1691
+ const isDonut = variant === PieChartVariant.donut || variant === PieChartVariant.spacedDonut;
1692
+ const {
1693
+ width,
1694
+ height,
1695
+ fontSize,
1696
+ innerRadius
1697
+ } = sizeToDimension$1(size);
1698
+ const externalRadiusPadding = 8;
1699
+ const createArc = arc().innerRadius(isDonut ? innerRadius : 0).outerRadius(width / 2 - externalRadiusPadding);
1700
+ return /*#__PURE__*/React__default.createElement(StyledPieChart, _extends({}, forwardedProps, {
1701
+ className: className,
1702
+ ref: ref
1703
+ }), emptyComponent !== null && emptyComponent !== void 0 ? emptyComponent : /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(StyledPieChartEmptyText, {
1704
+ $maxWidth: innerRadius * 2,
1705
+ $textSize: fontSize / 2,
1706
+ $isDonut: isDonut
1707
+ }, /*#__PURE__*/React__default.createElement("span", null, localeText === null || localeText === void 0 ? void 0 : localeText.emptyChartText)), /*#__PURE__*/React__default.createElement("svg", {
1708
+ width: width,
1709
+ height: height
1710
+ }, /*#__PURE__*/React__default.createElement(Arcs, {
1711
+ arcs: [{
1712
+ createArc,
1713
+ previousData: {
1714
+ data: {
1715
+ key: '',
1716
+ value: 0
1717
+ },
1718
+ startAngle: 0,
1719
+ endAngle: 0,
1720
+ padAngle: 0,
1721
+ value: 0,
1722
+ index: 0
1723
+ },
1724
+ data: {
1725
+ data: {
1726
+ key: 'No Data',
1727
+ value: 0
1728
+ },
1729
+ index: 0,
1730
+ value: 0,
1731
+ startAngle: 0,
1732
+ endAngle: 2 * Math.PI,
1733
+ padAngle: 0
1734
+ },
1735
+ color: empty
1736
+ }],
1737
+ transform: `translate(${width / 2} ${height / 2})`
1738
+ }))));
1739
+ });
1740
+
1741
+ const _excluded$6 = ["caping", "className", "data", "id", "isSliceSelected", "labelDecorator", "labelVariant", "middleText", "onSliceClick", "others", "size", "sliceRole", "subtext", "text", "theme", "tooltipVariant", "variant"];
1742
+ const RenderedPieChart = /*#__PURE__*/forwardRef((props, ref) => {
1743
+ const {
1744
+ caping,
1745
+ className,
1746
+ data: propsData,
1747
+ id,
1748
+ isSliceSelected,
1749
+ labelDecorator,
1750
+ labelVariant,
1751
+ middleText,
1752
+ onSliceClick,
1753
+ others,
1754
+ size,
1755
+ sliceRole,
1756
+ subtext,
1757
+ text,
1758
+ theme,
1759
+ tooltipVariant,
1760
+ variant
1761
+ } = props,
1762
+ forwardedProps = _objectWithoutProperties(props, _excluded$6);
1763
+ const cache = useRef();
1764
+ const isDonut = variant === PieChartVariant.donut || variant === PieChartVariant.spacedDonut;
1765
+ const {
1766
+ data,
1767
+ colorScale
1768
+ } = useFormatCategoricalData({
1769
+ data: propsData,
1770
+ theme: theme,
1771
+ caping,
1772
+ others
1773
+ });
1774
+ useEffect(() => {
1775
+ cache.current = data;
1776
+ });
1777
+ const {
1778
+ width,
1779
+ height,
1780
+ smallFontSize,
1781
+ fontSize,
1782
+ innerRadius
1783
+ } = sizeToDimension$1(size);
1784
+ const externalRadiusPadding = 8;
1785
+ const createPie = pie().value(d => d.value).sort(null);
1786
+ const createArc = arc().innerRadius(isDonut ? innerRadius : 0).outerRadius(width / 2 - externalRadiusPadding);
1787
+ const pieData = createPie(data);
1788
+ const previousPieData = cache.current ? createPie(cache.current) : undefined;
1789
+ const total = sum(data, d => d.value);
1790
+ return /*#__PURE__*/React__default.createElement(StyledPieChart, _extends({}, forwardedProps, {
1791
+ className: className,
1792
+ id: id,
1793
+ ref: ref
1794
+ }), text ? /*#__PURE__*/React__default.createElement(StyledPieChartCenterText, {
1795
+ $maxWidth: innerRadius * 2,
1796
+ $textSize: fontSize,
1797
+ $smallTextSize: smallFontSize
1798
+ }, subtext ? /*#__PURE__*/React__default.createElement("b", null, text) : /*#__PURE__*/React__default.createElement("span", null, text), middleText ? /*#__PURE__*/React__default.createElement("b", null, middleText) : null, /*#__PURE__*/React__default.createElement("span", null, subtext)) : null, /*#__PURE__*/React__default.createElement("svg", {
1799
+ width: width,
1800
+ height: height
1801
+ }, /*#__PURE__*/React__default.createElement(Arcs, {
1802
+ arcs: pieData.map((datum, index) => {
1803
+ const percent = datum.data.value / total;
1804
+ const from = previousPieData ? previousPieData[index] : {
1805
+ data: {
1806
+ key: '',
1807
+ value: 0
1808
+ },
1809
+ startAngle: 0,
1810
+ endAngle: 0,
1811
+ padAngle: 0,
1812
+ value: 0,
1813
+ index: index
1814
+ };
1815
+ const to = _objectSpread2(_objectSpread2({}, datum), {}, {
1816
+ data: _objectSpread2(_objectSpread2({}, datum.data), {}, {
1817
+ percent
1818
+ })
1819
+ });
1820
+ return {
1821
+ color: colorScale === null || colorScale === void 0 ? void 0 : colorScale(to.data.key),
1822
+ createArc,
1823
+ previousData: from,
1824
+ id: `id${id}__bar-${index}`,
1825
+ index,
1826
+ isSelected: isSliceSelected(to),
1827
+ key: `id${id}__bar-${index}`,
1828
+ data: to
1829
+ };
1830
+ }),
1831
+ hasLabels: labelVariant === PieChartLabelVariant.internal,
1832
+ hasStroke: variant === PieChartVariant.spaced || variant === PieChartVariant.spacedDonut,
1833
+ labelDecorator: labelDecorator,
1834
+ onClick: onSliceClick,
1835
+ tooltipVariant: tooltipVariant,
1836
+ transform: `translate(${width / 2} ${height / 2})`,
1837
+ role: sliceRole
1838
+ })), labelVariant !== PieChartLabelVariant.none && labelVariant !== PieChartLabelVariant.internal ? /*#__PURE__*/React__default.createElement(Legend, {
1839
+ data: data.map(d => _objectSpread2(_objectSpread2({}, d), {}, {
1840
+ color: colorScale === null || colorScale === void 0 ? void 0 : colorScale(d.key)
1841
+ })),
1842
+ variant: labelVariant === PieChartLabelVariant.externalLabelValue ? LabelVariant.value : labelVariant === PieChartLabelVariant.externalLabelPercent ? LabelVariant.percent : LabelVariant.label
1843
+ }) : null);
1844
+ });
1845
+
1846
+ const _excluded$5 = ["caping", "className", "data", "emptyComponent", "id", "isSliceSelected", "labelDecorator", "labelVariant", "localeText", "middleText", "onSliceClick", "others", "size", "sliceRole", "subtext", "text", "theme", "tooltipVariant", "variant"];
1847
+ const COMPONENT_NAME$2 = 'PieChart';
1848
+ const CLASSNAME$2 = 'redsift-piechart';
1849
+ const DEFAULT_PROPS$2 = {
1850
+ isSliceSelected: () => true,
1851
+ labelVariant: PieChartLabelVariant.none,
1852
+ others: true,
1853
+ size: ChartSize.medium,
1854
+ theme: ColorTheme.default,
1855
+ variant: PieChartVariant.plain,
1856
+ tooltipVariant: TooltipVariant.value,
1857
+ localeText: {
1858
+ emptyChartText: 'No Data'
1859
+ }
1860
+ };
1861
+ const PieChart = /*#__PURE__*/forwardRef((props, ref) => {
1862
+ const {
1863
+ caping,
1864
+ className,
1865
+ data: propsData,
1866
+ emptyComponent,
1867
+ id: propsId,
1868
+ isSliceSelected,
1869
+ labelDecorator,
1870
+ labelVariant,
1871
+ localeText,
1872
+ middleText,
1873
+ onSliceClick,
1874
+ others,
1875
+ size,
1876
+ sliceRole,
1877
+ subtext,
1878
+ text,
1879
+ theme,
1880
+ tooltipVariant,
1881
+ variant
1882
+ } = props,
1883
+ forwardedProps = _objectWithoutProperties(props, _excluded$5);
1884
+ const id = propsId !== null && propsId !== void 0 ? propsId : useId();
1885
+ if (propsData === undefined || propsData === null) {
1886
+ return /*#__PURE__*/React__default.createElement(LoadingPieChart, _extends({
1887
+ id: id
1888
+ }, forwardedProps, {
1889
+ ref: ref
1890
+ }));
1891
+ }
1892
+ if (propsData.length === 0) {
1893
+ return /*#__PURE__*/React__default.createElement(EmptyPieChart, _extends({
1894
+ data: propsData,
1895
+ emptyComponent: emptyComponent,
1896
+ id: id,
1897
+ localeText: localeText,
1898
+ size: size,
1899
+ variant: variant
1900
+ }, forwardedProps, {
1901
+ ref: ref
1902
+ }));
1903
+ }
1904
+ return /*#__PURE__*/React__default.createElement(RenderedPieChart, _extends({
1905
+ caping: caping,
1906
+ className: classNames(PieChart.className, className),
1907
+ data: propsData,
1908
+ id: id,
1909
+ isSliceSelected: isSliceSelected,
1910
+ labelDecorator: labelDecorator,
1911
+ labelVariant: labelVariant,
1912
+ middleText: middleText,
1913
+ onSliceClick: onSliceClick,
1914
+ others: others,
1915
+ size: size,
1916
+ sliceRole: sliceRole,
1917
+ subtext: subtext,
1918
+ text: text,
1919
+ theme: theme,
1920
+ tooltipVariant: tooltipVariant,
1921
+ variant: variant
1922
+ }, forwardedProps, {
1923
+ ref: ref
1924
+ }));
1925
+ });
1926
+ PieChart.className = CLASSNAME$2;
1927
+ PieChart.defaultProps = DEFAULT_PROPS$2;
1928
+ PieChart.displayName = COMPONENT_NAME$2;
1929
+
1930
+ /**
1931
+ * Component variant.
1932
+ */
1933
+ const ScatterPlotVariant = {
1934
+ default: 'default',
1935
+ gridded: 'gridded'
1936
+ };
1937
+ /**
1938
+ * Component's labels variant.
1939
+ */
1940
+ const ScatterPlotLabelVariant = {
1941
+ none: 'none',
1942
+ externalLabel: 'externalLabel',
1943
+ externalLabelValue: 'externalLabelValue',
1944
+ externalLabelPercent: 'externalLabelPercent'
1945
+ };
1946
+
1947
+ /**
1948
+ * Component style.
1949
+ */
1950
+ const StyledScatterPlot = styled(ChartContainer)``;
1951
+ const StyledScatterPlotEmptyText = styled.div`
739
1952
  position: absolute;
740
1953
  top: 0;
741
1954
  left: 0;
@@ -748,84 +1961,178 @@ const StyledPieChartEmptyText = styled.div`
748
1961
  pointer-events: none;
749
1962
 
750
1963
  > * {
751
- max-width: ${_ref10 => {
1964
+ max-width: ${_ref => {
752
1965
  let {
753
1966
  $maxWidth
754
- } = _ref10;
1967
+ } = _ref;
755
1968
  return $maxWidth;
756
1969
  }}px;
757
1970
  }
758
1971
 
759
1972
  > span {
760
1973
  font-family: var(--redsift-typography-font-family-raleway);
761
- color: ${_ref11 => {
762
- let {
763
- $isDonut
764
- } = _ref11;
765
- return $isDonut ? css`var(--redsift-color-neutral-midgrey)` : css`var(--redsift-color-neutral-black)`;
766
- }};
767
- font-size: ${_ref12 => {
1974
+ color: var(--redsift-color-neutral-black);
1975
+ font-size: ${_ref2 => {
768
1976
  let {
769
1977
  $textSize
770
- } = _ref12;
1978
+ } = _ref2;
771
1979
  return $textSize;
772
1980
  }}px;
773
- line-height: ${_ref13 => {
1981
+ line-height: ${_ref3 => {
774
1982
  let {
775
1983
  $textSize
776
- } = _ref13;
1984
+ } = _ref3;
777
1985
  return $textSize;
778
1986
  }}px;
779
1987
  }
780
1988
  `;
781
- const StyledPieChartLabel = styled.li`
782
- display: flex;
783
- align-items: center;
784
- gap: 8px;
785
- width: 100%;
786
- max-width: 262px;
787
- font-size: var(--redsift-typography-caption-font-size);
788
1989
 
789
- > div {
790
- height: 16px;
791
- width: 16px;
792
- min-width: 16px;
793
- background-color: ${_ref14 => {
794
- let {
795
- $color
796
- } = _ref14;
797
- return $color;
798
- }};
1990
+ const _excluded$4 = ["className"];
1991
+ const LoadingScatterPlot = /*#__PURE__*/forwardRef((props, ref) => {
1992
+ const {
1993
+ className
1994
+ } = props,
1995
+ forwardedProps = _objectWithoutProperties(props, _excluded$4);
1996
+ return /*#__PURE__*/React__default.createElement(StyledScatterPlot, _extends({}, forwardedProps, {
1997
+ className: className,
1998
+ ref: ref
1999
+ }), "Loading...");
2000
+ });
2001
+
2002
+ const sizeToDimension = size => {
2003
+ if (typeof size !== 'string') {
2004
+ return size;
2005
+ }
2006
+ switch (size) {
2007
+ case ChartSize.small:
2008
+ return {
2009
+ width: 600,
2010
+ height: 300,
2011
+ fontSize: 30
2012
+ };
2013
+ case ChartSize.medium:
2014
+ default:
2015
+ return {
2016
+ width: 750,
2017
+ height: 375,
2018
+ fontSize: 34
2019
+ };
2020
+ case ChartSize.large:
2021
+ return {
2022
+ width: 900,
2023
+ height: 450,
2024
+ fontSize: 38
2025
+ };
2026
+ }
2027
+ };
2028
+ const BASE_NUMBER_OF_TICKS = 20;
2029
+ const getClosestLineIndex = (value, scale) => {
2030
+ const ticks = scale.ticks(BASE_NUMBER_OF_TICKS);
2031
+ const delta = ticks[1] - ticks[0];
2032
+ const index = Math.round(value / delta);
2033
+ const roundValue = index * delta;
2034
+ return [index, roundValue];
2035
+ };
2036
+ const group = (data, x, y) => {
2037
+ const groupDict = {};
2038
+ data.forEach(d => {
2039
+ const [i, rx] = getClosestLineIndex(d.key[0], x);
2040
+ const [j, ry] = getClosestLineIndex(d.key[1], y);
2041
+ const key = `${i}_${j}_${d.key[2]}`;
2042
+ if (!(key in groupDict)) {
2043
+ groupDict[key] = {
2044
+ category: d.key[2],
2045
+ x: rx,
2046
+ y: ry,
2047
+ data: {
2048
+ key: d.key,
2049
+ value: 0
2050
+ },
2051
+ points: []
2052
+ };
2053
+ }
2054
+ groupDict[key].points.push(d);
2055
+ groupDict[key].data.value += 1;
2056
+ });
2057
+ return Object.values(groupDict);
2058
+ };
2059
+ const countBy = arr => {
2060
+ const counts = arr.reduce((prev, curr) => (prev[curr.key[2]] = ++prev[curr.key[2]] || 1, prev), {});
2061
+ return Object.keys(counts).map(key => ({
2062
+ key: key,
2063
+ value: counts[key]
2064
+ })).sort((a, b) => a.value === b.value ? a.key > b.key ? 1 : -1 : a.value < b.value ? 1 : -1);
2065
+ };
2066
+
2067
+ const _excluded$3 = ["className", "data", "emptyComponent", "localeText", "size"];
2068
+ const EmptyScatterPlot = /*#__PURE__*/forwardRef((props, ref) => {
2069
+ const {
2070
+ className,
2071
+ data: propsData,
2072
+ emptyComponent,
2073
+ localeText,
2074
+ size
2075
+ } = props,
2076
+ forwardedProps = _objectWithoutProperties(props, _excluded$3);
2077
+ const cache = useRef();
2078
+ const data = propsData;
2079
+ useEffect(() => {
2080
+ cache.current = data;
2081
+ });
2082
+ const chartDimensions = sizeToDimension(size);
2083
+ const width = chartDimensions.width;
2084
+ const height = chartDimensions.height;
2085
+ const margins = {
2086
+ top: 16,
2087
+ left: 48,
2088
+ right: 16,
2089
+ bottom: 48
2090
+ };
2091
+ const chartWidth = width - margins.left - margins.right;
2092
+ return /*#__PURE__*/React__default.createElement(StyledScatterPlot, _extends({}, forwardedProps, {
2093
+ className: className,
2094
+ ref: ref
2095
+ }), emptyComponent !== null && emptyComponent !== void 0 ? emptyComponent : /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(StyledScatterPlotEmptyText, {
2096
+ $maxWidth: width,
2097
+ $textSize: chartDimensions.fontSize / 2
2098
+ }, /*#__PURE__*/React__default.createElement("span", null, localeText === null || localeText === void 0 ? void 0 : localeText.emptyChartText)), /*#__PURE__*/React__default.createElement("svg", {
2099
+ width: width,
2100
+ height: height
2101
+ }, /*#__PURE__*/React__default.createElement("g", {
2102
+ transform: `translate(${margins.left},${margins.top})`
2103
+ }, /*#__PURE__*/React__default.createElement(Axis, {
2104
+ position: "bottom",
2105
+ length: width - 32,
2106
+ scale: scaleLinear().domain([]).range([0, chartWidth]),
2107
+ x: 0,
2108
+ y: height,
2109
+ tickValues: 4
2110
+ })))));
2111
+ });
2112
+
2113
+ /**
2114
+ * Component style.
2115
+ */
2116
+ const StyledDot = styled(DataPoint)`
2117
+ circle {
2118
+ fill-opacity: 0.7;
799
2119
  }
800
- `;
801
- const StyledPieChartArc = styled.g`
802
- ${_ref15 => {
803
- let {
804
- $spaced
805
- } = _ref15;
806
- return $spaced ? css`
807
- path {
808
- stroke-width: 2px;
809
- stroke: #fff;
810
- }
811
- ` : '';
812
- }}
813
2120
 
814
- ${_ref16 => {
2121
+ ${_ref => {
815
2122
  let {
816
2123
  $clickable
817
- } = _ref16;
2124
+ } = _ref;
818
2125
  return $clickable ? css`
819
2126
  cursor: pointer;
820
2127
 
821
2128
  &:hover,
822
2129
  &:focus {
823
- opacity: 0.8;
2130
+ opacity: 0.5;
824
2131
  outline: none;
825
2132
  }
826
2133
 
827
2134
  &:focus-visible {
828
- path {
2135
+ circle {
829
2136
  stroke: var(--redsift-color-default-primary);
830
2137
  stroke-width: 4px;
831
2138
  paint-order: stroke;
@@ -835,305 +2142,288 @@ const StyledPieChartArc = styled.g`
835
2142
  }}}
836
2143
  `;
837
2144
 
838
- const _excluded$1 = ["chartId", "color", "data", "index", "onClick", "path", "role", "spaced", "showTooltip", "tooltipPercent", "tooltipLabelOnly", "isEmpty"];
839
- const COMPONENT_NAME$1 = 'PieChartArc';
840
- const CLASSNAME$1 = 'redsift-piechart-arc';
841
- const DEFAULT_PROPS$1 = {};
842
- const PieChartArc = /*#__PURE__*/forwardRef((props, ref) => {
2145
+ const _excluded$2 = ["className", "scaleX", "scaleY"];
2146
+ const COMPONENT_NAME$1 = 'Dot';
2147
+ const CLASSNAME$1 = 'redsift-dot';
2148
+ const DEFAULT_PROPS$1 = {
2149
+ color: monochrome,
2150
+ index: 0,
2151
+ labelDecorator: datum => {
2152
+ return datum.data.key[2] !== undefined && datum.data.key[2] !== null ? datum.data.key[2] : `${datum.data.key[0]},${datum.data.key[1]}`;
2153
+ }
2154
+ };
2155
+ const Dot = /*#__PURE__*/forwardRef((props, ref) => {
843
2156
  const {
844
- chartId,
845
- color,
846
- data,
847
- index,
848
- onClick,
849
- path,
850
- role,
851
- spaced,
852
- showTooltip,
853
- tooltipPercent,
854
- tooltipLabelOnly,
855
- isEmpty
2157
+ color,
2158
+ data,
2159
+ isSelected: propsIsSelected,
2160
+ onClick,
2161
+ role
2162
+ } = props;
2163
+ const {
2164
+ className,
2165
+ scaleX,
2166
+ scaleY
2167
+ } = props,
2168
+ forwardedProps = _objectWithoutProperties(props, _excluded$2);
2169
+ const isSelectable = role === 'option';
2170
+ const isDeselected = isSelectable && propsIsSelected === false;
2171
+ return /*#__PURE__*/React__default.createElement(StyledDot, _extends({}, forwardedProps, {
2172
+ ref: ref,
2173
+ className: classNames(Dot.className, className),
2174
+ $clickable: Boolean(onClick)
2175
+ }), /*#__PURE__*/React__default.createElement("circle", {
2176
+ cx: scaleX(data.x),
2177
+ cy: scaleY(data.y),
2178
+ r: data.r,
2179
+ fill: isDeselected ? 'var(--redsift-color-neutral-lightgrey)' : color
2180
+ }));
2181
+ });
2182
+ Dot.className = CLASSNAME$1;
2183
+ Dot.defaultProps = DEFAULT_PROPS$1;
2184
+ Dot.displayName = COMPONENT_NAME$1;
2185
+
2186
+ const _excluded$1 = ["isBrushable", "className", "data", "dotRole", "id", "isDotSelected", "labelDecorator", "labelVariant", "onBrush", "onBrushEnd", "onDotClick", "size", "theme", "tooltipVariant", "variant"];
2187
+ const RenderedScatterPlot = /*#__PURE__*/forwardRef((props, ref) => {
2188
+ const {
2189
+ isBrushable,
2190
+ className,
2191
+ data: propsData,
2192
+ dotRole,
2193
+ id,
2194
+ isDotSelected,
2195
+ labelDecorator,
2196
+ labelVariant,
2197
+ onBrush,
2198
+ onBrushEnd,
2199
+ onDotClick,
2200
+ size,
2201
+ theme,
2202
+ tooltipVariant,
2203
+ variant
856
2204
  } = props,
857
2205
  forwardedProps = _objectWithoutProperties(props, _excluded$1);
858
- const onKeyDown = event => {
859
- if (onClick) {
860
- event.stopPropagation();
861
- if (event.code === 'Enter' || event.code === 'Space') {
862
- event.preventDefault();
863
- onClick();
864
- }
865
- }
2206
+ const cache = useRef();
2207
+ const data = propsData;
2208
+ useEffect(() => {
2209
+ cache.current = data;
2210
+ });
2211
+ const chartDimensions = sizeToDimension(size);
2212
+ const width = chartDimensions.width;
2213
+ const height = chartDimensions.height;
2214
+ const margins = {
2215
+ top: 16,
2216
+ left: 48,
2217
+ right: 16,
2218
+ bottom: 48
866
2219
  };
867
- const Arc = /*#__PURE__*/React.createElement(StyledPieChartArc, _extends({}, forwardedProps, {
868
- ref: ref,
869
- "aria-label": showTooltip && !isEmpty ? `${data.name}: ${data.value}` : undefined,
870
- "aria-labelledby": !showTooltip && !isEmpty ? `id${chartId}__slice-${index}-title` : undefined,
871
- className: `pie-slice _${index}`,
872
- id: `id${chartId}__slice-${index}`,
873
- onClick: onClick,
874
- onKeyDown: onKeyDown,
875
- role: role ? role : onClick ? 'button' : undefined,
876
- tabIndex: onClick ? 0 : undefined,
877
- $clickable: Boolean(onClick),
878
- $spaced: Boolean(spaced)
879
- }), /*#__PURE__*/React.createElement("path", {
880
- d: path,
881
- fill: color
882
- }), !showTooltip && !isEmpty ? /*#__PURE__*/React.createElement("title", {
883
- id: `id${chartId}__slice-${index}-title`
884
- }, `${data.name}: ${data.value}`) : null);
885
- if (showTooltip) {
886
- return /*#__PURE__*/React.createElement(Tooltip, {
887
- placement: "right"
888
- }, /*#__PURE__*/React.createElement(Tooltip.Trigger, null, Arc), /*#__PURE__*/React.createElement(Tooltip.Content, null, tooltipLabelOnly ? /*#__PURE__*/React.createElement(Text, {
889
- variant: "caption"
890
- }, data.name) : tooltipPercent !== null ? /*#__PURE__*/React.createElement(Text, {
891
- variant: "caption"
892
- }, data.name, " -", ' ', /*#__PURE__*/React.createElement(Number$1, {
893
- maximumFractionDigits: 2,
894
- type: "percent",
895
- value: tooltipPercent,
896
- variant: "caption"
897
- })) : /*#__PURE__*/React.createElement(Text, {
898
- variant: "caption"
899
- }, data.name, " -", ' ', /*#__PURE__*/React.createElement(Number$1, {
900
- maximumFractionDigits: 2,
901
- value: data.value,
902
- variant: "caption"
903
- }))));
2220
+ const chartHeight = height - margins.top - margins.bottom;
2221
+ const chartWidth = width - margins.left - margins.right;
2222
+ const minSize = min([chartWidth, chartHeight]);
2223
+ const extendedScaleX = (() => {
2224
+ const domain = extent(data, d => d.key[0]);
2225
+ const gap = domain[1] - domain[0];
2226
+ domain[0] -= gap * 0.1;
2227
+ domain[1] += gap * 0.1;
2228
+ return scaleLinear().domain(domain).range([0, chartWidth]).nice();
2229
+ })();
2230
+ const extendedScaleY = (() => {
2231
+ const domain = extent(data, d => d.key[1]);
2232
+ const gap = domain[1] - domain[0];
2233
+ domain[0] -= gap * 0.1;
2234
+ domain[1] += gap * 0.1;
2235
+ return scaleLinear().domain(domain).range([chartHeight, 0]).nice();
2236
+ })();
2237
+ const hasCategory = data[0].key.length === 3 && data[0].key[2] !== null && data[0].key[2] !== undefined;
2238
+ const countsByCategory = hasCategory ? countBy(data) : undefined;
2239
+ const colorScale = useColor({
2240
+ data: countsByCategory || data,
2241
+ theme: theme,
2242
+ category: 'key'
2243
+ });
2244
+ const svgRef = useRef();
2245
+ const {
2246
+ scaleX,
2247
+ scaleY,
2248
+ transform
2249
+ } = useZoom({
2250
+ svgRef,
2251
+ scaleX: extendedScaleX,
2252
+ scaleY: extendedScaleY
2253
+ });
2254
+ const svgBrushRef = useRef();
2255
+ useBrush({
2256
+ svgRef: svgBrushRef,
2257
+ extent: [[0, 0], [chartWidth, chartHeight]],
2258
+ scaleX,
2259
+ scaleY,
2260
+ isBrushable,
2261
+ isGridded: variant === ScatterPlotVariant.gridded,
2262
+ onBrush,
2263
+ onBrushEnd
2264
+ });
2265
+ const circles = variant === ScatterPlotVariant.gridded ? group(data, scaleX, scaleY).sort((a, b) => descending(a.points.length, b.points.length)) : data.map(d => ({
2266
+ category: d.key[2],
2267
+ x: d.key[0],
2268
+ y: d.key[1],
2269
+ data: {
2270
+ key: d.key,
2271
+ value: 1
2272
+ },
2273
+ points: [d]
2274
+ }));
2275
+ const globalSize = variant === ScatterPlotVariant.gridded ? scaleSqrt().domain([1, Math.max(max(circles, d => d.points.length), 1)]).range([3, minSize / BASE_NUMBER_OF_TICKS / 2]) : undefined;
2276
+ const legendWidth = useRef();
2277
+ if (countsByCategory && !legendWidth.current) {
2278
+ legendWidth.current = `${Math.max(...countsByCategory.map(d => d.key.length + String(d.value).length)) * 8 + 32}px`;
904
2279
  }
905
- return Arc;
2280
+ return /*#__PURE__*/React__default.createElement(StyledScatterPlot, _extends({}, forwardedProps, {
2281
+ id: id,
2282
+ className: className,
2283
+ ref: ref
2284
+ }), /*#__PURE__*/React__default.createElement("svg", {
2285
+ ref: svgRef,
2286
+ width: width,
2287
+ height: height
2288
+ }, /*#__PURE__*/React__default.createElement("g", {
2289
+ ref: svgBrushRef,
2290
+ transform: `translate(${margins.left},${margins.top})`
2291
+ }, /*#__PURE__*/React__default.createElement("defs", null, /*#__PURE__*/React__default.createElement("clipPath", {
2292
+ id: `${id}-clip`
2293
+ }, /*#__PURE__*/React__default.createElement("rect", {
2294
+ width: chartWidth,
2295
+ height: chartHeight,
2296
+ x: "0",
2297
+ y: "0"
2298
+ })))), /*#__PURE__*/React__default.createElement("g", {
2299
+ transform: `translate(${margins.left},${margins.top})`
2300
+ }, /*#__PURE__*/React__default.createElement("g", {
2301
+ clipPath: `url(#${id}-clip)`
2302
+ }, circles.map((group, index) => {
2303
+ var _countsByCategory$fin;
2304
+ const to = _objectSpread2(_objectSpread2({}, group), {}, {
2305
+ data: _objectSpread2(_objectSpread2({}, group.data), {}, {
2306
+ percent: group.category ? group.data.value / (countsByCategory === null || countsByCategory === void 0 ? void 0 : (_countsByCategory$fin = countsByCategory.find(_ref => {
2307
+ let {
2308
+ key
2309
+ } = _ref;
2310
+ return key === group.category;
2311
+ })) === null || _countsByCategory$fin === void 0 ? void 0 : _countsByCategory$fin.value) : undefined
2312
+ }),
2313
+ r: variant === ScatterPlotVariant.gridded ? globalSize(group.points.length) / transform.k : 4
2314
+ });
2315
+ return /*#__PURE__*/React__default.createElement(Dot, {
2316
+ color: colorScale === null || colorScale === void 0 ? void 0 : colorScale(group.category),
2317
+ data: to,
2318
+ isSelected: Boolean(isDotSelected === null || isDotSelected === void 0 ? void 0 : isDotSelected(to)),
2319
+ key: `circle _${index}`,
2320
+ labelDecorator: labelDecorator,
2321
+ onClick: onDotClick,
2322
+ role: dotRole,
2323
+ scaleX: scaleX,
2324
+ scaleY: scaleY,
2325
+ tooltipVariant: tooltipVariant
2326
+ });
2327
+ }))), /*#__PURE__*/React__default.createElement("g", {
2328
+ transform: `translate(${margins.left},${margins.top})`
2329
+ }, /*#__PURE__*/React__default.createElement(Axis, {
2330
+ position: "left",
2331
+ length: chartHeight,
2332
+ scale: scaleY,
2333
+ x: 0,
2334
+ y: 0,
2335
+ tickValues: 8
2336
+ }), /*#__PURE__*/React__default.createElement(Axis, {
2337
+ position: "bottom",
2338
+ length: chartWidth,
2339
+ scale: scaleX,
2340
+ x: 0,
2341
+ y: chartHeight,
2342
+ tickValues: 8
2343
+ }))), hasCategory && labelVariant !== ScatterPlotLabelVariant.none ? /*#__PURE__*/React__default.createElement(Legend, {
2344
+ data: countsByCategory.map(d => _objectSpread2(_objectSpread2({}, d), {}, {
2345
+ color: colorScale === null || colorScale === void 0 ? void 0 : colorScale(d.key)
2346
+ })),
2347
+ variant: labelVariant === ScatterPlotLabelVariant.externalLabelValue ? LabelVariant.value : labelVariant === ScatterPlotLabelVariant.externalLabelPercent ? LabelVariant.percent : LabelVariant.label,
2348
+ width: legendWidth.current
2349
+ }) : null);
906
2350
  });
907
- PieChartArc.className = CLASSNAME$1;
908
- PieChartArc.defaultProps = DEFAULT_PROPS$1;
909
- PieChartArc.displayName = COMPONENT_NAME$1;
910
2351
 
911
- const _excluded = ["aria-label", "aria-labelledby", "caping", "caption", "className", "data", "labelVariant", "onSliceClick", "others", "size", "sliceRole", "text", "middleText", "subtext", "theme", "title", "variant", "tooltipVariant", "localeText"];
912
- const COMPONENT_NAME = 'PieChart';
913
- const CLASSNAME = 'redsift-piechart';
2352
+ const _excluded = ["className", "data", "dotRole", "emptyComponent", "id", "isDotSelected", "labelVariant", "localeText", "onBrush", "onBrushEnd", "onDotClick", "size", "theme", "tooltipVariant", "variant"];
2353
+ const COMPONENT_NAME = 'ScatterPlot';
2354
+ const CLASSNAME = 'redsift-scatterplot';
914
2355
  const DEFAULT_PROPS = {
915
- labelVariant: PieChartLabelVariant.none,
916
- others: true,
917
- size: PieChartSize.medium,
918
- theme: PieChartTheme.default,
919
- variant: PieChartVariant.plain,
920
- tooltipVariant: PieChartTooltipVariant.value,
2356
+ labelVariant: ScatterPlotLabelVariant.externalLabel,
921
2357
  localeText: {
922
2358
  emptyChartText: 'No Data'
923
- }
924
- };
925
- const sizeToDimension = size => {
926
- switch (size) {
927
- case PieChartSize.small:
928
- return {
929
- width: 200,
930
- height: 200
931
- };
932
- case PieChartSize.large:
933
- return {
934
- width: 300,
935
- height: 300
936
- };
937
- case PieChartSize.medium:
938
- default:
939
- return {
940
- width: 240,
941
- height: 240
942
- };
943
- }
944
- };
945
- const sizeToSmallFontSize = size => {
946
- switch (size) {
947
- case PieChartSize.small:
948
- return 13;
949
- case PieChartSize.large:
950
- return 18;
951
- case PieChartSize.medium:
952
- default:
953
- return 14;
954
- }
955
- };
956
- const sizeToFontSize = size => {
957
- switch (size) {
958
- case PieChartSize.small:
959
- return 30;
960
- case PieChartSize.large:
961
- return 38;
962
- case PieChartSize.medium:
963
- default:
964
- return 34;
965
- }
966
- };
967
- const sizeToInnerRadius = size => {
968
- switch (size) {
969
- case PieChartSize.small:
970
- return 55;
971
- case PieChartSize.large:
972
- return 80;
973
- case PieChartSize.medium:
974
- default:
975
- return 65;
976
- }
2359
+ },
2360
+ size: ChartSize.medium,
2361
+ theme: ColorTheme.default,
2362
+ tooltipVariant: TooltipVariant.none,
2363
+ variant: ScatterPlotVariant.default
977
2364
  };
978
- const PieChart = /*#__PURE__*/forwardRef((props, ref) => {
979
- const id = useId();
2365
+ const ScatterPlot = /*#__PURE__*/forwardRef((props, ref) => {
980
2366
  const {
981
- 'aria-label': ariaLabel,
982
- 'aria-labelledby': ariaLabelledby,
983
- caping,
984
- caption,
985
2367
  className,
986
- data: propData,
2368
+ data: propsData,
2369
+ dotRole,
2370
+ emptyComponent,
2371
+ id: propsId,
2372
+ isDotSelected,
987
2373
  labelVariant,
988
- onSliceClick,
989
- others,
2374
+ localeText,
2375
+ onBrush,
2376
+ onBrushEnd,
2377
+ onDotClick,
990
2378
  size,
991
- sliceRole,
992
- text,
993
- middleText,
994
- subtext,
995
2379
  theme,
996
- title,
997
- variant,
998
2380
  tooltipVariant,
999
- localeText
2381
+ variant
1000
2382
  } = props,
1001
2383
  forwardedProps = _objectWithoutProperties(props, _excluded);
1002
- const {
1003
- emptyChartText
1004
- } = _objectSpread2(_objectSpread2({}, DEFAULT_PROPS.localeText), localeText);
1005
- const isEmpty = propData.every(d => d.value === 0);
1006
- const isDonut = variant === PieChartVariant.donut || variant === PieChartVariant.spacedDonut;
1007
- let data = propData.sort((a, b) => a.value < b.value ? 1 : -1);
1008
- if (caping) {
1009
- if (typeof others === 'boolean' && !others) {
1010
- data = data.slice(0, caping);
1011
- } else {
1012
- data = data.reduce((acc, curr, index) => {
1013
- if (index < caping) {
1014
- acc[index] = curr;
1015
- } else if (index === caping) {
1016
- acc[index] = {
1017
- name: typeof others === 'string' ? others : 'Others',
1018
- value: curr.value
1019
- };
1020
- } else {
1021
- acc[caping] = _objectSpread2(_objectSpread2({}, acc[caping]), {}, {
1022
- value: acc[caping].value + curr.value
1023
- });
1024
- }
1025
- return acc;
1026
- }, []);
1027
- }
1028
- }
1029
- if (isEmpty) {
1030
- data = [{
1031
- name: emptyChartText,
1032
- value: 100
1033
- }];
1034
- }
1035
-
1036
- // Get charts dimensions based on the selected size.
1037
- const chartDimensions = sizeToDimension(size);
1038
- const externalRadiusPadding = 8;
1039
- const innerRadius = sizeToInnerRadius(size);
2384
+ const id = propsId !== null && propsId !== void 0 ? propsId : useId();
1040
2385
 
1041
- // Set color scheme.
1042
- const d3colors = getColorScale(theme, isEmpty);
2386
+ // console.log(propsData);
1043
2387
 
1044
- // Initialize the chart.
1045
- const createPie = pie().value(d => d.value).sort(null);
1046
- const createArc = arc().innerRadius(isDonut ? innerRadius : 0).outerRadius(chartDimensions.width / 2 - externalRadiusPadding);
1047
- const pieData = createPie(data);
1048
- const total = sum(data, d => d.value);
1049
- return /*#__PURE__*/React.createElement(StyledPieChart, _extends({}, forwardedProps, {
1050
- ref: ref,
1051
- className: className
1052
- }), title ? /*#__PURE__*/React.createElement(StyledPieChartTitle, {
1053
- className: `${PieChart.className}__title`,
1054
- alignItems: "center",
1055
- id: `id${id}__title`
1056
- }, title) : null, /*#__PURE__*/React.createElement("div", {
1057
- className: `${PieChart.className}__container`
1058
- }, /*#__PURE__*/React.createElement("div", {
1059
- className: `${PieChart.className}-container__chart`,
1060
- "aria-label": ariaLabel ? ariaLabel : ariaLabelledby || title ? undefined : 'Pie Chart',
1061
- "aria-labelledby": ariaLabelledby ? ariaLabelledby : title ? `id${id}__title` : undefined
1062
- }, text && !isEmpty ? /*#__PURE__*/React.createElement(StyledPieChartCenterText, {
1063
- $maxWidth: innerRadius * 2,
1064
- $textSize: sizeToFontSize(size),
1065
- $smallTextSize: sizeToSmallFontSize(size)
1066
- }, subtext ? /*#__PURE__*/React.createElement("b", null, text) : /*#__PURE__*/React.createElement("span", null, text), middleText ? /*#__PURE__*/React.createElement("b", null, middleText) : null, /*#__PURE__*/React.createElement("span", null, subtext)) : null, isEmpty ? /*#__PURE__*/React.createElement(StyledPieChartEmptyText, {
1067
- $maxWidth: innerRadius * 2,
1068
- $textSize: sizeToFontSize(size) / 2,
1069
- $isDonut: isDonut
1070
- }, /*#__PURE__*/React.createElement("span", null, emptyChartText)) : null, /*#__PURE__*/React.createElement("svg", {
1071
- width: chartDimensions.width,
1072
- height: chartDimensions.height
1073
- }, /*#__PURE__*/React.createElement("g", {
1074
- transform: `translate(${chartDimensions.width / 2} ${chartDimensions.height / 2})`
1075
- }, /*#__PURE__*/React.createElement("g", {
1076
- className: "pie-slice-group"
1077
- }, pieData.map((datum, index) => {
1078
- const percent = datum.data.value / total;
1079
- return /*#__PURE__*/React.createElement(PieChartArc, {
1080
- chartId: id,
1081
- color: d3colors(datum.data.name),
1082
- data: datum.data,
1083
- isEmpty: isEmpty,
1084
- index: index,
1085
- key: `pie-slice _${index}`,
1086
- onClick: onSliceClick ? () => onSliceClick(data[index]) : undefined,
1087
- showTooltip: tooltipVariant !== PieChartTooltipVariant.none && !isEmpty,
1088
- role: sliceRole,
1089
- tooltipLabelOnly: tooltipVariant == PieChartTooltipVariant.label,
1090
- tooltipPercent: tooltipVariant === PieChartTooltipVariant.percent ? percent : null,
1091
- path: createArc(datum),
1092
- spaced: variant === PieChartVariant.spaced || variant === PieChartVariant.spacedDonut
1093
- });
1094
- })), labelVariant === PieChartLabelVariant.internal && !isEmpty ? /*#__PURE__*/React.createElement("g", {
1095
- className: "pie-label-group"
1096
- }, pieData.filter(datum => {
1097
- const value = datum.data.value;
1098
- return value > 0 && value / total >= 0.1;
1099
- }).map((datum, index) => /*#__PURE__*/React.createElement("text", {
1100
- className: `pie-slice pie-label _${index}`,
1101
- key: `pie-slice pie-label _${index}`,
1102
- textAnchor: "middle",
1103
- transform: `translate(${createArc.centroid(datum)})`
1104
- }, datum.data.name))) : null))), labelVariant !== PieChartLabelVariant.none && labelVariant !== PieChartLabelVariant.internal ? /*#__PURE__*/React.createElement("ul", null, data.map((_ref, index) => {
1105
- let {
1106
- name,
1107
- value
1108
- } = _ref;
1109
- return /*#__PURE__*/React.createElement(StyledPieChartLabel, {
1110
- key: `pie-external-label _${index}`,
1111
- $color: d3colors(name)
1112
- }, /*#__PURE__*/React.createElement("div", null), labelVariant === PieChartLabelVariant.externalLabelValue ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Number$1, {
1113
- as: "b",
1114
- maximumFractionDigits: 2,
1115
- value: value,
1116
- variant: "inherit"
1117
- }), /*#__PURE__*/React.createElement(Text, {
1118
- variant: "caption"
1119
- }, name)) : labelVariant === PieChartLabelVariant.externalLabelPercent ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Number$1, {
1120
- as: "b",
1121
- maximumFractionDigits: 2,
1122
- type: "percent",
1123
- value: value / total,
1124
- variant: "inherit"
1125
- }), /*#__PURE__*/React.createElement(Text, {
1126
- variant: "caption"
1127
- }, name)) : /*#__PURE__*/React.createElement(Text, {
1128
- variant: "caption"
1129
- }, name));
1130
- })) : null), caption ? /*#__PURE__*/React.createElement(StyledPieChartCaption, {
1131
- className: `${PieChart.className}__caption`
1132
- }, caption) : null);
2388
+ if (propsData === undefined || propsData === null) {
2389
+ return /*#__PURE__*/React__default.createElement(LoadingScatterPlot, _extends({
2390
+ id: id
2391
+ }, forwardedProps, {
2392
+ ref: ref
2393
+ }));
2394
+ }
2395
+ if (propsData.length === 0) {
2396
+ return /*#__PURE__*/React__default.createElement(EmptyScatterPlot, _extends({
2397
+ data: propsData,
2398
+ emptyComponent: emptyComponent,
2399
+ localeText: localeText,
2400
+ size: size
2401
+ }, forwardedProps, {
2402
+ ref: ref
2403
+ }));
2404
+ }
2405
+ return /*#__PURE__*/React__default.createElement(RenderedScatterPlot, _extends({
2406
+ className: classNames(ScatterPlot.className, className),
2407
+ data: propsData,
2408
+ dotRole: dotRole,
2409
+ id: id,
2410
+ isDotSelected: isDotSelected,
2411
+ labelVariant: labelVariant,
2412
+ localeText: localeText,
2413
+ onBrush: onBrush,
2414
+ onBrushEnd: onBrushEnd,
2415
+ onDotClick: onDotClick,
2416
+ size: size,
2417
+ theme: theme,
2418
+ tooltipVariant: tooltipVariant,
2419
+ variant: variant
2420
+ }, forwardedProps, {
2421
+ ref: ref
2422
+ }));
1133
2423
  });
1134
- PieChart.className = CLASSNAME;
1135
- PieChart.defaultProps = DEFAULT_PROPS;
1136
- PieChart.displayName = COMPONENT_NAME;
2424
+ ScatterPlot.className = CLASSNAME;
2425
+ ScatterPlot.defaultProps = DEFAULT_PROPS;
2426
+ ScatterPlot.displayName = COMPONENT_NAME;
1137
2427
 
1138
- export { ColorTheme, HorizontalBarChart, HorizontalBarChartSize, HorizontalBarChartTheme, HorizontalBarChartTooltipVariant, PieChart, PieChartLabelVariant, PieChartSize, PieChartTheme, PieChartTooltipVariant, PieChartVariant, StyledHorizontalBarChart, StyledHorizontalBarChartAxisBottom, StyledHorizontalBarChartBar, StyledHorizontalBarChartCaption, StyledHorizontalBarChartEmptyText, StyledHorizontalBarChartTitle, StyledPieChart, StyledPieChartArc, StyledPieChartCaption, StyledPieChartCenterText, StyledPieChartEmptyText, StyledPieChartLabel, StyledPieChartTitle, getColorScale, monochrome, scheme, successDangerScheme };
2428
+ export { Arc, Arcs, Axis, AxisPosition, Bar, BarChart, BarOrientation, ChartContainer, ChartSize, ColorTheme, LabelVariant, Legend, PieChart, PieChartLabelVariant, PieChartVariant, ScatterPlot, ScatterPlotLabelVariant, ScatterPlotVariant, StyledArc, StyledArcs, StyledAxis, StyledBar, StyledBarChart, StyledBarChartEmptyText, StyledChartContainer, StyledChartContainerCaption, StyledChartContainerTitle, StyledLabel, StyledLegend, StyledPieChart, StyledPieChartCenterText, StyledPieChartEmptyText, StyledScatterPlot, StyledScatterPlotEmptyText, TooltipVariant, empty, getColorScale, monochrome, scheme, successDangerScheme, useBrush, useColor, useFormatCategoricalData, useZoom };
1139
2429
  //# sourceMappingURL=index.js.map