@ledgerhq/lumen-ui-react-visualization 0.1.15 → 0.1.17

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.
Files changed (91) hide show
  1. package/dist/lib/Components/Axis/Axis.constants.d.ts +9 -0
  2. package/dist/lib/Components/Axis/Axis.constants.d.ts.map +1 -0
  3. package/dist/lib/Components/Axis/Axis.constants.js +24 -0
  4. package/dist/lib/Components/Axis/Axis.types.d.ts +37 -0
  5. package/dist/lib/Components/Axis/Axis.types.d.ts.map +1 -1
  6. package/dist/lib/Components/Axis/XAxis/XAxis.d.ts +0 -1
  7. package/dist/lib/Components/Axis/XAxis/XAxis.d.ts.map +1 -1
  8. package/dist/lib/Components/Axis/XAxis/XAxis.js +21 -22
  9. package/dist/lib/Components/Axis/XAxis/index.d.ts +1 -1
  10. package/dist/lib/Components/Axis/XAxis/index.d.ts.map +1 -1
  11. package/dist/lib/Components/Axis/YAxis/YAxis.d.ts +0 -1
  12. package/dist/lib/Components/Axis/YAxis/YAxis.d.ts.map +1 -1
  13. package/dist/lib/Components/Axis/YAxis/YAxis.js +16 -17
  14. package/dist/lib/Components/Axis/YAxis/index.d.ts +1 -1
  15. package/dist/lib/Components/Axis/YAxis/index.d.ts.map +1 -1
  16. package/dist/lib/Components/Axis/index.d.ts +3 -0
  17. package/dist/lib/Components/Axis/index.d.ts.map +1 -0
  18. package/dist/lib/Components/CartesianChart/CartesianChart.d.ts +1 -1
  19. package/dist/lib/Components/CartesianChart/CartesianChart.d.ts.map +1 -1
  20. package/dist/lib/Components/CartesianChart/CartesianChart.js +62 -58
  21. package/dist/lib/Components/CartesianChart/context/useBuildChartContext.d.ts +7 -4
  22. package/dist/lib/Components/CartesianChart/context/useBuildChartContext.d.ts.map +1 -1
  23. package/dist/lib/Components/CartesianChart/context/useBuildChartContext.js +31 -31
  24. package/dist/lib/Components/CartesianChart/types.d.ts +11 -3
  25. package/dist/lib/Components/CartesianChart/types.d.ts.map +1 -1
  26. package/dist/lib/Components/CartesianChart/utils.d.ts +19 -8
  27. package/dist/lib/Components/CartesianChart/utils.d.ts.map +1 -1
  28. package/dist/lib/Components/CartesianChart/utils.js +14 -15
  29. package/dist/lib/Components/Line/utils.d.ts +4 -0
  30. package/dist/lib/Components/Line/utils.d.ts.map +1 -1
  31. package/dist/lib/Components/Line/utils.js +15 -15
  32. package/dist/lib/Components/LineChart/LineChart.d.ts +1 -1
  33. package/dist/lib/Components/LineChart/LineChart.d.ts.map +1 -1
  34. package/dist/lib/Components/LineChart/LineChart.js +64 -74
  35. package/dist/lib/Components/LineChart/__stories__/chartStoryFixtures.d.ts +46 -0
  36. package/dist/lib/Components/LineChart/__stories__/chartStoryFixtures.d.ts.map +1 -0
  37. package/dist/lib/Components/LineChart/__stories__/cryptoChartData.d.ts +85 -0
  38. package/dist/lib/Components/LineChart/__stories__/cryptoChartData.d.ts.map +1 -0
  39. package/dist/lib/Components/LineChart/types.d.ts +10 -3
  40. package/dist/lib/Components/LineChart/types.d.ts.map +1 -1
  41. package/dist/lib/Components/Point/Point.d.ts +1 -1
  42. package/dist/lib/Components/Point/Point.d.ts.map +1 -1
  43. package/dist/lib/Components/Point/Point.js +35 -30
  44. package/dist/lib/Components/Point/constants.d.ts +7 -0
  45. package/dist/lib/Components/Point/constants.d.ts.map +1 -0
  46. package/dist/lib/Components/Point/constants.js +9 -0
  47. package/dist/lib/Components/Point/pointContext/MagneticPointsProvider.d.ts +7 -0
  48. package/dist/lib/Components/Point/pointContext/MagneticPointsProvider.d.ts.map +1 -0
  49. package/dist/lib/Components/Point/pointContext/MagneticPointsProvider.js +19 -0
  50. package/dist/lib/Components/Point/pointContext/index.d.ts +3 -0
  51. package/dist/lib/Components/Point/pointContext/index.d.ts.map +1 -0
  52. package/dist/lib/Components/Point/pointContext/magneticPointsContext.d.ts +13 -0
  53. package/dist/lib/Components/Point/pointContext/magneticPointsContext.d.ts.map +1 -0
  54. package/dist/lib/Components/Point/pointContext/magneticPointsContext.js +9 -0
  55. package/dist/lib/Components/Point/types.d.ts +7 -0
  56. package/dist/lib/Components/Point/types.d.ts.map +1 -1
  57. package/dist/lib/Components/Point/utils.d.ts +8 -6
  58. package/dist/lib/Components/Point/utils.d.ts.map +1 -1
  59. package/dist/lib/Components/Point/utils.js +32 -20
  60. package/dist/lib/Components/ReferenceLine/constants.d.ts +1 -1
  61. package/dist/lib/Components/ReferenceLine/constants.d.ts.map +1 -1
  62. package/dist/lib/Components/ReferenceLine/utils.d.ts +3 -2
  63. package/dist/lib/Components/ReferenceLine/utils.d.ts.map +1 -1
  64. package/dist/lib/Components/Scrubber/DefaultScrubberTooltip/ChartTooltipItem.js +14 -14
  65. package/dist/lib/Components/Scrubber/DefaultScrubberTooltip/DefaultScrubberTooltip.d.ts.map +1 -1
  66. package/dist/lib/Components/Scrubber/DefaultScrubberTooltip/DefaultScrubberTooltip.js +38 -38
  67. package/dist/lib/Components/Scrubber/DefaultScrubberTooltip/constants.d.ts +1 -2
  68. package/dist/lib/Components/Scrubber/DefaultScrubberTooltip/constants.d.ts.map +1 -1
  69. package/dist/lib/Components/Scrubber/DefaultScrubberTooltip/constants.js +8 -9
  70. package/dist/lib/Components/Scrubber/ScrubberProvider.d.ts +1 -1
  71. package/dist/lib/Components/Scrubber/ScrubberProvider.d.ts.map +1 -1
  72. package/dist/lib/Components/Scrubber/ScrubberProvider.js +97 -72
  73. package/dist/lib/Components/Scrubber/types.d.ts +6 -0
  74. package/dist/lib/Components/Scrubber/types.d.ts.map +1 -1
  75. package/dist/lib/Components/Scrubber/utils.d.ts +33 -3
  76. package/dist/lib/Components/Scrubber/utils.d.ts.map +1 -1
  77. package/dist/lib/Components/Scrubber/utils.js +71 -37
  78. package/dist/lib/utils/domain/domain.d.ts +5 -4
  79. package/dist/lib/utils/domain/domain.d.ts.map +1 -1
  80. package/dist/lib/utils/index.d.ts +1 -1
  81. package/dist/lib/utils/index.d.ts.map +1 -1
  82. package/dist/lib/utils/scales/scales.d.ts +11 -5
  83. package/dist/lib/utils/scales/scales.d.ts.map +1 -1
  84. package/dist/lib/utils/scales/scales.js +19 -15
  85. package/dist/lib/utils/ticks/ticks.d.ts +13 -5
  86. package/dist/lib/utils/ticks/ticks.d.ts.map +1 -1
  87. package/dist/lib/utils/ticks/ticks.js +20 -20
  88. package/dist/lib/utils/types.d.ts +3 -28
  89. package/dist/lib/utils/types.d.ts.map +1 -1
  90. package/dist/package.json +4 -4
  91. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"file":"ScrubberProvider.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/Scrubber/ScrubberProvider.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAwB,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAG3E,wBAAgB,gBAAgB,CAAC,EAC/B,QAAQ,EACR,MAAM,EACN,eAAe,EACf,wBAAwB,GACzB,EAAE,QAAQ,CAAC,qBAAqB,CAAC,2CAiLjC"}
1
+ {"version":3,"file":"ScrubberProvider.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/Scrubber/ScrubberProvider.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAwB,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAQ3E,wBAAgB,gBAAgB,CAAC,EAC/B,QAAQ,EACR,MAAM,EACN,eAAe,EACf,wBAAwB,EACxB,YAAgB,GACjB,EAAE,QAAQ,CAAC,qBAAqB,CAAC,2CA+NjC"}
@@ -1,77 +1,102 @@
1
- import { jsx as D } from "react/jsx-runtime";
2
- import { useState as w, useRef as y, useCallback as a, useEffect as R, useMemo as T } from "react";
3
- import { getDataIndexFromPosition as X } from "./utils.js";
4
- import { useCartesianChartContext as A } from "../CartesianChart/context/cartesianChartContext.js";
5
- import { ScrubberContextProvider as B } from "./context/scrubberContext.js";
6
- function N({
7
- children: k,
8
- svgRef: L,
9
- enableScrubbing: o,
10
- onScrubberPositionChange: x
1
+ import { jsx as F } from "react/jsx-runtime";
2
+ import { useState as q, useRef as C, useMemo as I, useCallback as s, useEffect as K } from "react";
3
+ import { buildSortedMagnets as j, getDataIndexFromPosition as z, resolvePixelX as H, applyMagnetization as N } from "./utils.js";
4
+ import { useCartesianChartContext as U } from "../CartesianChart/context/cartesianChartContext.js";
5
+ import { useMagneticPointsContext as V } from "../Point/pointContext/magneticPointsContext.js";
6
+ import { ScrubberContextProvider as G } from "./context/scrubberContext.js";
7
+ function _({
8
+ children: X,
9
+ svgRef: k,
10
+ enableScrubbing: r,
11
+ onScrubberPositionChange: D,
12
+ magnetRadius: p = 8
11
13
  }) {
12
- const { getXScale: M, getXAxisConfig: g, dataLength: s } = A(), [m, C] = w(
14
+ const { getXScale: f, getXAxisConfig: m, dataLength: c } = U(), { getMagneticPoints: y, version: R } = V(), [v, T] = q(
13
15
  void 0
14
- ), v = y(m);
15
- v.current = m;
16
- const c = a(
16
+ ), h = C(v);
17
+ h.current = v;
18
+ const x = C(null), l = C(0), w = I(() => {
19
+ const t = y();
20
+ return j({
21
+ magneticIndices: t,
22
+ getPixelForIndex: (e) => H(e, f, m())
23
+ });
24
+ }, [R, y, f, m]), i = s(
17
25
  (t) => {
18
- const e = t === void 0 ? void 0 : Math.max(0, Math.min(t, s - 1));
19
- C(e), x?.(e);
26
+ const e = t === void 0 ? void 0 : Math.max(0, Math.min(t, c - 1));
27
+ T(e), D?.(e);
20
28
  },
21
- [s, x]
22
- ), i = a(
29
+ [c, D]
30
+ ), A = s(
23
31
  (t) => {
24
- const e = M();
25
- if (!e || !o || s <= 0) return;
26
- const n = X(
32
+ const e = f();
33
+ if (!e || !r || c <= 0) return;
34
+ const a = m();
35
+ let o = z(
27
36
  t,
28
37
  e,
29
- g(),
30
- s
38
+ a,
39
+ c
31
40
  );
32
- n !== v.current && c(n);
41
+ p > 0 && (o = N({
42
+ resolvedIndex: o,
43
+ pixelX: t,
44
+ sortedMagnets: w,
45
+ magnetRadius: p
46
+ })), o !== h.current && i(o);
33
47
  },
34
48
  [
35
- o,
36
- M,
37
- g,
38
- s,
39
- c
49
+ r,
50
+ f,
51
+ m,
52
+ c,
53
+ w,
54
+ p,
55
+ i
40
56
  ]
41
- ), r = a(() => {
42
- o && c(void 0);
43
- }, [o, c]), h = a(
57
+ ), u = s(
44
58
  (t) => {
45
- const n = t.currentTarget.getBoundingClientRect();
46
- i(t.clientX - n.left);
59
+ x.current = t, l.current || (l.current = requestAnimationFrame(() => {
60
+ l.current = 0;
61
+ const e = x.current;
62
+ e !== null && (x.current = null, A(e));
63
+ }));
47
64
  },
48
- [i]
49
- ), f = a(
65
+ [A]
66
+ ), n = s(() => {
67
+ r && i(void 0);
68
+ }, [r, i]), E = s(
50
69
  (t) => {
51
- if (!o || !t.touches.length) return;
52
- const e = t.touches[0], u = t.currentTarget.getBoundingClientRect();
53
- i(e.clientX - u.left);
70
+ const a = t.currentTarget.getBoundingClientRect();
71
+ u(t.clientX - a.left);
54
72
  },
55
- [o, i]
56
- ), l = a(
73
+ [u]
74
+ ), g = s(
75
+ (t) => {
76
+ if (!r || !t.touches.length) return;
77
+ const e = t.touches[0], o = t.currentTarget.getBoundingClientRect();
78
+ u(e.clientX - o.left);
79
+ },
80
+ [r, u]
81
+ ), L = s(
57
82
  (t) => {
58
83
  if (!t.touches.length) return;
59
84
  t.preventDefault();
60
- const e = t.touches[0], u = t.currentTarget.getBoundingClientRect();
61
- i(e.clientX - u.left);
85
+ const e = t.touches[0], o = t.currentTarget.getBoundingClientRect();
86
+ u(e.clientX - o.left);
62
87
  },
63
- [i]
64
- ), E = a(
88
+ [u]
89
+ ), M = s(
65
90
  (t) => {
66
- if (!o || s <= 0) return;
67
- const e = s - 1, n = v.current ?? e, u = t.shiftKey ? Math.min(10, Math.max(1, Math.floor(e * 0.1))) : 1;
91
+ if (!r || c <= 0) return;
92
+ const e = c - 1, a = h.current ?? e, o = t.shiftKey ? Math.min(10, Math.max(1, Math.floor(e * 0.1))) : 1;
68
93
  let d;
69
94
  switch (t.key) {
70
95
  case "ArrowLeft":
71
- t.preventDefault(), d = Math.max(0, n - u);
96
+ t.preventDefault(), d = Math.max(0, a - o);
72
97
  break;
73
98
  case "ArrowRight":
74
- t.preventDefault(), d = Math.min(e, n + u);
99
+ t.preventDefault(), d = Math.min(e, a + o);
75
100
  break;
76
101
  case "Home":
77
102
  t.preventDefault(), d = 0;
@@ -85,38 +110,38 @@ function N({
85
110
  default:
86
111
  return;
87
112
  }
88
- c(d);
113
+ i(d);
89
114
  },
90
- [o, s, c]
91
- ), p = a(() => {
92
- !o || v.current === void 0 || r();
93
- }, [o, r]);
94
- R(() => {
95
- const t = L.current;
96
- if (!(!t || !o))
97
- return t.addEventListener("mousemove", h), t.addEventListener("mouseleave", r), t.addEventListener("touchstart", f, { passive: !1 }), t.addEventListener("touchmove", l, { passive: !1 }), t.addEventListener("touchend", r), t.addEventListener("touchcancel", r), t.addEventListener("keydown", E), t.addEventListener("blur", p), () => {
98
- t.removeEventListener("mousemove", h), t.removeEventListener("mouseleave", r), t.removeEventListener("touchstart", f), t.removeEventListener("touchmove", l), t.removeEventListener("touchend", r), t.removeEventListener("touchcancel", r), t.removeEventListener("keydown", E), t.removeEventListener("blur", p);
115
+ [r, c, i]
116
+ ), P = s(() => {
117
+ !r || h.current === void 0 || n();
118
+ }, [r, n]);
119
+ K(() => {
120
+ const t = k.current;
121
+ if (!(!t || !r))
122
+ return t.addEventListener("mousemove", E), t.addEventListener("mouseleave", n), t.addEventListener("touchstart", g, { passive: !1 }), t.addEventListener("touchmove", L, { passive: !1 }), t.addEventListener("touchend", n), t.addEventListener("touchcancel", n), t.addEventListener("keydown", M), t.addEventListener("blur", P), () => {
123
+ t.removeEventListener("mousemove", E), t.removeEventListener("mouseleave", n), t.removeEventListener("touchstart", g), t.removeEventListener("touchmove", L), t.removeEventListener("touchend", n), t.removeEventListener("touchcancel", n), t.removeEventListener("keydown", M), t.removeEventListener("blur", P), cancelAnimationFrame(l.current), l.current = 0;
99
124
  };
100
125
  }, [
101
- L,
102
- o,
103
- h,
126
+ k,
104
127
  r,
105
- f,
106
- l,
107
128
  E,
108
- p
129
+ n,
130
+ g,
131
+ L,
132
+ M,
133
+ P
109
134
  ]);
110
- const P = T(
135
+ const B = I(
111
136
  () => ({
112
- enableScrubbing: o,
113
- scrubberPosition: m,
114
- onScrubberPositionChange: c
137
+ enableScrubbing: r,
138
+ scrubberPosition: v,
139
+ onScrubberPositionChange: i
115
140
  }),
116
- [o, m, c]
141
+ [r, v, i]
117
142
  );
118
- return /* @__PURE__ */ D(B, { value: P, children: k });
143
+ return /* @__PURE__ */ F(G, { value: B, children: X });
119
144
  }
120
145
  export {
121
- N as ScrubberProvider
146
+ _ as ScrubberProvider
122
147
  };
@@ -28,6 +28,12 @@ export type ScrubberProviderProps = {
28
28
  * Optional external callback fired whenever the scrubber position changes.
29
29
  */
30
30
  onScrubberPositionChange?: (index: number | undefined) => void;
31
+ /**
32
+ * Pixel radius within which the scrubber magnetically snaps to registered
33
+ * magnetic points. Set to `0` to disable magnetization.
34
+ * @default 8
35
+ */
36
+ magnetRadius?: number;
31
37
  };
32
38
  /**
33
39
  * Valid content for an SVG `<text>` element: a plain string,
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/Scrubber/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE/E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,MAAM,MAAM,oBAAoB,GAAG;IACjC;;OAEG;IACH,eAAe,EAAE,OAAO,CAAC;IACzB;;OAEG;IACH,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC;;OAEG;IACH,wBAAwB,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;CAC/D,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,EAAE,S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IACzE;;OAEG;IACH,KAAK,EAAE,oBAAoB,EAAE,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;OAIG;IACH,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,sBAAsB,CAAC;CACzD,CAAC"}
@@ -1,4 +1,5 @@
1
- import { AxisConfigProps, ChartScaleFunction } from '../../utils/types';
1
+ import { ChartScaleFunction } from '../../utils/types';
2
+ import { BaseAxisProps } from '../Axis';
2
3
  import { useCartesianChartContext } from '../CartesianChart/context';
3
4
  export declare const BEACON_RADIUS = 5;
4
5
  export declare const BEACON_STROKE_WIDTH = 2;
@@ -7,6 +8,19 @@ export declare const OVERLAY_OFFSET = 2;
7
8
  export declare const OVERLAY_LINE_INSET = 0.5;
8
9
  export declare const OVERLAY_OPACITY = 0.8;
9
10
  export declare const LINE_GRADIENT_EDGE_OPACITY = 0.1;
11
+ export type MagnetEntry = {
12
+ index: number;
13
+ pixelX: number;
14
+ };
15
+ /**
16
+ * Resolves each magnetic index to its pixel position and returns them sorted
17
+ * by `pixelX` ascending. Indices that cannot be projected are filtered out.
18
+ * The sorted output enables early-exit in {@link applyMagnetization}.
19
+ */
20
+ export declare const buildSortedMagnets: ({ magneticIndices, getPixelForIndex, }: {
21
+ magneticIndices: ReadonlySet<number>;
22
+ getPixelForIndex: (index: number) => number | undefined;
23
+ }) => MagnetEntry[];
10
24
  /**
11
25
  * Converts a pixel position along the x-axis into the nearest data index.
12
26
  *
@@ -14,7 +28,7 @@ export declare const LINE_GRADIENT_EDGE_OPACITY = 0.1;
14
28
  * `pixelX`. For numeric scales, uses `scale.invert()` and rounds to the
15
29
  * nearest integer, clamped to the valid index range.
16
30
  */
17
- export declare const getDataIndexFromPosition: (pixelX: number, scale: ChartScaleFunction, axisConfig: Partial<AxisConfigProps> | undefined, dataLength: number) => number;
31
+ export declare const getDataIndexFromPosition: (pixelX: number, scale: ChartScaleFunction, axisConfig: Partial<BaseAxisProps> | undefined, dataLength: number) => number;
18
32
  /**
19
33
  * Resolves the pixel y-coordinate for a given series data point at a data index.
20
34
  * Returns undefined when the value is null/missing or the scale is unavailable.
@@ -26,5 +40,21 @@ export declare const resolvePixelY: (dataIndex: number, seriesData: (number | nu
26
40
  * otherwise the data index is used as the x input.
27
41
  * Returns undefined when the scale is unavailable or the value cannot be mapped.
28
42
  */
29
- export declare const resolvePixelX: (dataIndex: number, getXScale: ReturnType<typeof useCartesianChartContext>["getXScale"], axisConfig?: AxisConfigProps) => number | undefined;
43
+ export declare const resolvePixelX: (dataIndex: number, getXScale: ReturnType<typeof useCartesianChartContext>["getXScale"], axisConfig?: BaseAxisProps) => number | undefined;
44
+ /**
45
+ * Binary search for the magnet whose `pixelX` is closest to `pixelX`.
46
+ * Returns -1 when the array is empty. Favors the left neighbor on ties.
47
+ */
48
+ export declare const nearestIndex: (sortedMagnets: readonly MagnetEntry[], pixelX: number) => number;
49
+ /**
50
+ * Given a resolved data index and the raw pixel position, checks whether any
51
+ * magnetic point is within `magnetRadius` pixels of `pixelX`. If so, returns
52
+ * the closest magnetic index; otherwise returns the original `resolvedIndex`.
53
+ */
54
+ export declare const applyMagnetization: ({ resolvedIndex, pixelX, sortedMagnets, magnetRadius, }: {
55
+ resolvedIndex: number;
56
+ pixelX: number;
57
+ sortedMagnets: readonly MagnetEntry[];
58
+ magnetRadius: number;
59
+ }) => number;
30
60
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/Scrubber/utils.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,KAAK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SAAS,WAAW,EAAE,CAAC;IACtC,YAAY,EAAE,MAAM,CAAC;CACtB,KAAG,MAWH,CAAC"}
@@ -1,56 +1,90 @@
1
- import { getPointOnScale as d, isNumericScale as u, isCategoricalScale as l } from "../../utils/scales/scales.js";
2
- const E = 5, m = 2, I = 2, A = 0.5, O = 0.8, _ = 0.1, f = (o) => typeof o[0] == "number", a = (o, n, r) => {
1
+ import { getPointOnScale as f, isNumericScale as l, isCategoricalScale as a } from "../../utils/scales/scales.js";
2
+ const v = 5, E = 2, m = 2, p = 0.5, A = 0.8, I = 0.1, O = ({
3
+ magneticIndices: o,
4
+ getPixelForIndex: i
5
+ }) => {
6
+ if (o.size === 0) return [];
7
+ const n = [];
8
+ for (const e of o) {
9
+ const t = i(e);
10
+ t !== void 0 && n.push({ index: e, pixelX: t });
11
+ }
12
+ return n.sort((e, t) => e.pixelX - t.pixelX), n;
13
+ }, d = (o) => typeof o[0] == "number", u = (o, i, n) => {
3
14
  let e = 0, t = 1 / 0;
4
- for (let i = 0; i < o; i++) {
5
- const s = r(i);
6
- if (s === void 0) continue;
7
- const c = Math.abs(n - s);
8
- c < t && (t = c, e = i);
15
+ for (let r = 0; r < o; r++) {
16
+ const c = n(r);
17
+ if (c === void 0) continue;
18
+ const s = Math.abs(i - c);
19
+ s < t && (t = s, e = r);
9
20
  }
10
21
  return e;
11
- }, h = (o, n, r, e) => {
12
- if (l(n)) {
13
- const t = n.domain(), i = n.bandwidth();
14
- return a(t.length, o, (s) => {
15
- const c = n(t[s]);
16
- return c === void 0 ? void 0 : c + i / 2;
22
+ }, _ = (o, i, n, e) => {
23
+ if (a(i)) {
24
+ const t = i.domain(), r = i.bandwidth();
25
+ return u(t.length, o, (c) => {
26
+ const s = i(t[c]);
27
+ return s === void 0 ? void 0 : s + r / 2;
17
28
  });
18
29
  }
19
- if (u(n)) {
20
- const t = r?.data;
21
- if (t && t.length > 0 && f(t))
22
- return a(
30
+ if (l(i)) {
31
+ const t = n?.data;
32
+ if (t && t.length > 0 && d(t))
33
+ return u(
23
34
  t.length,
24
35
  o,
25
- (s) => n(t[s])
36
+ (c) => i(t[c])
26
37
  );
27
- const i = n.invert(o);
38
+ const r = i.invert(o);
28
39
  return Math.max(
29
40
  0,
30
- Math.min(Math.round(i), e - 1)
41
+ Math.min(Math.round(r), e - 1)
31
42
  );
32
43
  }
33
44
  return 0;
34
- }, x = (o, n, r) => {
35
- const e = r();
36
- if (!e || !u(e) || !n) return;
37
- const t = n[o];
45
+ }, S = (o, i, n) => {
46
+ const e = n();
47
+ if (!e || !l(e) || !i) return;
48
+ const t = i[o];
38
49
  if (t != null)
39
50
  return e(t);
40
- }, N = (o, n, r) => {
41
- const e = n();
51
+ }, b = (o, i, n) => {
52
+ const e = i();
42
53
  if (!e) return;
43
- const t = r?.data?.[o];
44
- return d(typeof t == "number" ? t : o, e);
54
+ const t = n?.data?.[o];
55
+ return f(typeof t == "number" ? t : o, e);
56
+ }, h = (o, i) => {
57
+ if (o.length === 0) return -1;
58
+ let n = 0, e = o.length;
59
+ for (; n < e; ) {
60
+ const c = Math.floor((n + e) / 2);
61
+ o[c].pixelX < i ? n = c + 1 : e = c;
62
+ }
63
+ if (n === 0) return 0;
64
+ if (n === o.length) return n - 1;
65
+ const t = i - o[n - 1].pixelX, r = o[n].pixelX - i;
66
+ return t <= r ? n - 1 : n;
67
+ }, N = ({
68
+ resolvedIndex: o,
69
+ pixelX: i,
70
+ sortedMagnets: n,
71
+ magnetRadius: e
72
+ }) => {
73
+ if (e <= 0 || n.length === 0) return o;
74
+ const t = h(n, i);
75
+ return t >= 0 && Math.abs(n[t].pixelX - i) <= e ? n[t].index : o;
45
76
  };
46
77
  export {
47
- E as BEACON_RADIUS,
48
- m as BEACON_STROKE_WIDTH,
49
- _ as LINE_GRADIENT_EDGE_OPACITY,
50
- A as OVERLAY_LINE_INSET,
51
- I as OVERLAY_OFFSET,
52
- O as OVERLAY_OPACITY,
53
- h as getDataIndexFromPosition,
54
- N as resolvePixelX,
55
- x as resolvePixelY
78
+ v as BEACON_RADIUS,
79
+ E as BEACON_STROKE_WIDTH,
80
+ I as LINE_GRADIENT_EDGE_OPACITY,
81
+ p as OVERLAY_LINE_INSET,
82
+ m as OVERLAY_OFFSET,
83
+ A as OVERLAY_OPACITY,
84
+ N as applyMagnetization,
85
+ O as buildSortedMagnets,
86
+ _ as getDataIndexFromPosition,
87
+ h as nearestIndex,
88
+ b as resolvePixelX,
89
+ S as resolvePixelY
56
90
  };
@@ -1,17 +1,18 @@
1
- import { AxisBounds, AxisConfigProps, Series } from '../types';
1
+ import { AxisBounds, BaseAxisProps } from '../../Components/Axis';
2
+ import { Series } from '../types';
2
3
  /**
3
4
  * Compute the X domain (index-based) from series data and axis config.
4
5
  * For the X axis the domain is typically 0..N-1 where N = longest series length,
5
6
  * unless explicit `data` is provided on the axis config.
6
7
  */
7
- export declare const computeXDomain: (series: Series[], axisConfig?: Partial<AxisConfigProps>) => AxisBounds;
8
+ export declare const computeXDomain: (series: Series[], axisConfig?: Partial<BaseAxisProps>) => AxisBounds;
8
9
  /**
9
10
  * Compute the Y domain (value-based) from series data and axis config.
10
11
  * Scans all non-null values across all series to find min/max.
11
12
  */
12
- export declare const computeYDomain: (series: Series[], axisConfig?: Partial<AxisConfigProps>) => AxisBounds;
13
+ export declare const computeYDomain: (series: Series[], axisConfig?: Partial<BaseAxisProps>) => AxisBounds;
13
14
  /**
14
15
  * Compute the data length (number of discrete positions on the index axis).
15
16
  */
16
- export declare const computeDataLength: (series: Series[], axisConfig?: Partial<AxisConfigProps>) => number;
17
+ export declare const computeDataLength: (series: Series[], axisConfig?: Partial<BaseAxisProps>) => number;
17
18
  //# sourceMappingURL=domain.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"domain.d.ts","sourceRoot":"","sources":["../../../../src/lib/utils/domain/domain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEpE;;;;GAIG;AACH,eAAO,MAAM,cAAc,GACzB,QAAQ,MAAM,EAAE,EAChB,aAAa,OAAO,CAAC,eAAe,CAAC,KACpC,UA4BF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,cAAc,GACzB,QAAQ,MAAM,EAAE,EAChB,aAAa,OAAO,CAAC,eAAe,CAAC,KACpC,UAwBF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAC5B,QAAQ,MAAM,EAAE,EAChB,aAAa,OAAO,CAAC,eAAe,CAAC,KACpC,MAKF,CAAC"}
1
+ {"version":3,"file":"domain.d.ts","sourceRoot":"","sources":["../../../../src/lib/utils/domain/domain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC;;;;GAIG;AACH,eAAO,MAAM,cAAc,GACzB,QAAQ,MAAM,EAAE,EAChB,aAAa,OAAO,CAAC,aAAa,CAAC,KAClC,UA4BF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,cAAc,GACzB,QAAQ,MAAM,EAAE,EAChB,aAAa,OAAO,CAAC,aAAa,CAAC,KAClC,UAwBF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAC5B,QAAQ,MAAM,EAAE,EAChB,aAAa,OAAO,CAAC,aAAa,CAAC,KAClC,MAKF,CAAC"}
@@ -1,2 +1,2 @@
1
- export type { AxisBounds, AxisConfigProps, CartesianChartContextValue, CategoricalScale, ChartInset, ChartScaleFunction, DrawingArea, NumericScale, Series, } from './types';
1
+ export type { CartesianChartContextValue, CategoricalScale, ChartInset, ChartScaleFunction, DrawingArea, NumericScale, Series, } from './types';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,UAAU,EACV,eAAe,EACf,0BAA0B,EAC1B,gBAAgB,EAChB,UAAU,EACV,kBAAkB,EAClB,WAAW,EACX,YAAY,EACZ,MAAM,GACP,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,0BAA0B,EAC1B,gBAAgB,EAChB,UAAU,EACV,kBAAkB,EAClB,WAAW,EACX,YAAY,EACZ,MAAM,GACP,MAAM,SAAS,CAAC"}
@@ -1,12 +1,18 @@
1
- import { AxisBounds, AxisConfigProps, CategoricalScale, ChartScaleFunction, NumericScale } from '../types';
1
+ import { AxisBounds, BaseAxisProps } from '../../Components/Axis';
2
+ import { CategoricalScale, ChartScaleFunction, NumericScale } from '../types';
2
3
  /**
3
- * Creates a numeric scale with `.nice()` applied so the domain
4
- * extends to clean rounded boundaries (e.g. `[4, 98]` → `[0, 100]`).
4
+ * Creates a numeric scale.
5
+ *
6
+ * When `nice` is `true` (default), the domain is rounded outward to clean
7
+ * boundaries via d3's `.nice()` (e.g. `[4, 98]` → `[0, 100]`). Set `nice` to
8
+ * `false` to keep the domain exactly as provided so data fills the range
9
+ * boundary-to-boundary.
5
10
  */
6
- export declare const getNumericScale: ({ scaleType, domain, range, }: {
11
+ export declare const getNumericScale: ({ scaleType, domain, range, nice, }: {
7
12
  scaleType: "linear" | "log";
8
13
  domain: AxisBounds;
9
14
  range: AxisBounds;
15
+ nice?: boolean;
10
16
  }) => NumericScale;
11
17
  export declare const getCategoricalScale: ({ domain, range, padding, }: {
12
18
  domain: AxisBounds;
@@ -16,7 +22,7 @@ export declare const getCategoricalScale: ({ domain, range, padding, }: {
16
22
  /**
17
23
  * Checks if a scale type config value refers to a band (categorical) scale.
18
24
  */
19
- export declare const isBandScaleType: (scaleType: AxisConfigProps["scaleType"]) => scaleType is "band";
25
+ export declare const isBandScaleType: (scaleType: BaseAxisProps["scaleType"]) => scaleType is "band";
20
26
  /**
21
27
  * Checks if a scale is a categorical scale.
22
28
  */
@@ -1 +1 @@
1
- {"version":3,"file":"scales.d.ts","sourceRoot":"","sources":["../../../../src/lib/utils/scales/scales.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACb,MAAM,UAAU,CAAC;AAElB;;;GAGG;AACH,eAAO,MAAM,eAAe,GAAI,+BAI7B;IACD,SAAS,EAAE,QAAQ,GAAG,KAAK,CAAC;IAC5B,MAAM,EAAE,UAAU,CAAC;IACnB,KAAK,EAAE,UAAU,CAAC;CACnB,KAAG,YAMH,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,6BAIjC;IACD,MAAM,EAAE,UAAU,CAAC;IACnB,KAAK,EAAE,UAAU,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,KAAG,gBAUH,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,GAC1B,WAAW,eAAe,CAAC,WAAW,CAAC,KACtC,SAAS,IAAI,MAA8B,CAAC;AAE/C;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAC7B,OAAO,kBAAkB,KACxB,KAAK,IAAI,gBAEX,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,GACzB,OAAO,kBAAkB,KACxB,KAAK,IAAI,YAEX,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe,GAC1B,OAAO,MAAM,EACb,OAAO,kBAAkB,KACxB,MAKF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,YAAY,GACvB,OAAO,MAAM,EACb,OAAO,MAAM,EACb,QAAQ,kBAAkB,EAC1B,QAAQ,kBAAkB,KACzB;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAGvB,CAAC"}
1
+ {"version":3,"file":"scales.d.ts","sourceRoot":"","sources":["../../../../src/lib/utils/scales/scales.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,KAAK,EACV,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACb,MAAM,UAAU,CAAC;AAElB;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,GAAI,qCAK7B;IACD,SAAS,EAAE,QAAQ,GAAG,KAAK,CAAC;IAC5B,MAAM,EAAE,UAAU,CAAC;IACnB,KAAK,EAAE,UAAU,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,KAAG,YAOH,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,6BAIjC;IACD,MAAM,EAAE,UAAU,CAAC;IACnB,KAAK,EAAE,UAAU,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,KAAG,gBAUH,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,GAC1B,WAAW,aAAa,CAAC,WAAW,CAAC,KACpC,SAAS,IAAI,MAA8B,CAAC;AAE/C;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAC7B,OAAO,kBAAkB,KACxB,KAAK,IAAI,gBAEX,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,GACzB,OAAO,kBAAkB,KACxB,KAAK,IAAI,YAEX,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe,GAC1B,OAAO,MAAM,EACb,OAAO,kBAAkB,KACxB,MAKF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,YAAY,GACvB,OAAO,MAAM,EACb,OAAO,MAAM,EACb,QAAQ,kBAAkB,EAC1B,QAAQ,kBAAkB,KACzB;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAGvB,CAAC"}
@@ -1,30 +1,34 @@
1
- import c from "../../../node_modules/d3-scale/src/band.js";
2
- import m from "../../../node_modules/d3-scale/src/log.js";
3
- import d from "../../../node_modules/d3-scale/src/linear.js";
4
- const p = ({
1
+ import m from "../../../node_modules/d3-scale/src/band.js";
2
+ import d from "../../../node_modules/d3-scale/src/log.js";
3
+ import u from "../../../node_modules/d3-scale/src/linear.js";
4
+ const l = ({
5
5
  scaleType: n,
6
6
  domain: t,
7
- range: r
8
- }) => (n === "log" ? m() : d()).domain([t.min, t.max]).nice().range([r.min, r.max]), f = ({
7
+ range: r,
8
+ nice: i = !0
9
+ }) => {
10
+ const o = n === "log" ? d() : u();
11
+ return o.domain([t.min, t.max]), i && o.nice(), o.range([r.min, r.max]);
12
+ }, p = ({
9
13
  domain: n,
10
14
  range: t,
11
15
  padding: r = 0.1
12
16
  }) => {
13
17
  const i = Array.from(
14
18
  { length: n.max - n.min + 1 },
15
- (s, a) => n.min + a
19
+ (o, c) => n.min + c
16
20
  );
17
- return c().domain(i).range([t.min, t.max]).paddingInner(r).paddingOuter(r / 2);
18
- }, x = (n) => n === "band", e = (n) => "bandwidth" in n && typeof n.bandwidth == "function", S = (n) => !e(n), o = (n, t) => e(t) ? (t(n) ?? 0) + t.bandwidth() / 2 : t(n), b = (n, t, r, i) => ({
19
- x: o(n, r),
20
- y: o(t, i)
21
+ return m().domain(i).range([t.min, t.max]).paddingInner(r).paddingOuter(r / 2);
22
+ }, x = (n) => n === "band", a = (n) => "bandwidth" in n && typeof n.bandwidth == "function", S = (n) => !a(n), e = (n, t) => a(t) ? (t(n) ?? 0) + t.bandwidth() / 2 : t(n), b = (n, t, r, i) => ({
23
+ x: e(n, r),
24
+ y: e(t, i)
21
25
  });
22
26
  export {
23
- f as getCategoricalScale,
24
- p as getNumericScale,
25
- o as getPointOnScale,
27
+ p as getCategoricalScale,
28
+ l as getNumericScale,
29
+ e as getPointOnScale,
26
30
  x as isBandScaleType,
27
- e as isCategoricalScale,
31
+ a as isCategoricalScale,
28
32
  S as isNumericScale,
29
33
  b as projectPoint
30
34
  };
@@ -1,4 +1,5 @@
1
- import { AxisConfigProps, ChartScaleFunction, DrawingArea } from '../types';
1
+ import { BaseAxisProps } from '../../Components/Axis';
2
+ import { ChartScaleFunction, DrawingArea } from '../types';
2
3
  export declare const APPROXIMATE_TICK_COUNT = 5;
3
4
  export type TickData = {
4
5
  position: number;
@@ -7,9 +8,16 @@ export type TickData = {
7
8
  };
8
9
  /**
9
10
  * Resolves which numeric tick values should appear on the axis.
10
- * Explicit ticks take priority, then scale-specific defaults.
11
+ *
12
+ * Priority:
13
+ * 1. Explicit `ticks` provided by the consumer.
14
+ * 2. Axis `data` — when provided, ticks come from the data itself (numeric
15
+ * values for numeric data, indices for string data) so the rendered ticks
16
+ * mirror exactly what the consumer asked for, with no d3-invented
17
+ * intermediate values.
18
+ * 3. Scale-specific defaults (band domain, or `scale.ticks()` for numeric).
11
19
  */
12
- export declare const getTickValues: (scale: ChartScaleFunction, explicitTicks?: number[]) => number[];
20
+ export declare const getTickValues: (scale: ChartScaleFunction, explicitTicks?: number[], axisData?: BaseAxisProps["data"]) => number[];
13
21
  /**
14
22
  * Converts a tick value to its pixel position on the axis.
15
23
  * Band scales are centered within the band.
@@ -19,11 +27,11 @@ export declare const getTickPosition: (scale: ChartScaleFunction, tick: number)
19
27
  * Resolves the display label for a tick value.
20
28
  * Priority: formatter > string label lookup > raw value.
21
29
  */
22
- export declare const getTickLabel: (tick: number, axisData: AxisConfigProps["data"], formatter?: (value: number | string) => string) => string;
30
+ export declare const getTickLabel: (tick: number, axisData: BaseAxisProps["data"], formatter?: (value: number | string) => string) => string;
23
31
  /**
24
32
  * Builds the complete tick data array from a scale and axis configuration.
25
33
  */
26
- export declare const buildTicksData: (scale: ChartScaleFunction, axisConfig?: AxisConfigProps, explicitTicks?: number[], formatter?: (value: number | string) => string) => TickData[];
34
+ export declare const buildTicksData: (scale: ChartScaleFunction, axisConfig?: BaseAxisProps, explicitTicks?: number[], formatter?: (value: number | string) => string) => TickData[];
27
35
  /**
28
36
  * Excludes the X grid line at the Y-axis origin (left edge)
29
37
  * to prevent overlap with the Y-axis solid line.
@@ -1 +1 @@
1
- {"version":3,"file":"ticks.d.ts","sourceRoot":"","sources":["../../../../src/lib/utils/ticks/ticks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,eAAe,EACf,kBAAkB,EAClB,WAAW,EACZ,MAAM,UAAU,CAAC;AAElB,eAAO,MAAM,sBAAsB,IAAI,CAAC;AAExC,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,aAAa,GACxB,OAAO,kBAAkB,EACzB,gBAAgB,MAAM,EAAE,KACvB,MAAM,EAKR,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe,GAC1B,OAAO,kBAAkB,EACzB,MAAM,MAAM,KACX,MAKF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,YAAY,GACvB,MAAM,MAAM,EACZ,UAAU,eAAe,CAAC,MAAM,CAAC,EACjC,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,KAAK,MAAM,KAC7C,MAeF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,GACzB,OAAO,kBAAkB,EACzB,aAAa,eAAe,EAC5B,gBAAgB,MAAM,EAAE,EACxB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,KAAK,MAAM,KAC7C,QAAQ,EASV,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,uBAAuB,GAClC,MAAM,QAAQ,EACd,aAAa,WAAW,KACvB,OAEF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,uBAAuB,GAClC,MAAM,QAAQ,EACd,aAAa,WAAW,KACvB,OAEF,CAAC"}
1
+ {"version":3,"file":"ticks.d.ts","sourceRoot":"","sources":["../../../../src/lib/utils/ticks/ticks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OA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