@fluentui/react-charts 0.0.0-nightly-20251107-0407.1 → 0.0.0-nightly-20251110-0407.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/CHANGELOG.md +13 -13
  2. package/dist/index.d.ts +211 -0
  3. package/lib/AnnotationOnlyChart.js +1 -0
  4. package/lib/AnnotationOnlyChart.js.map +1 -0
  5. package/lib/components/AnnotationOnlyChart/AnnotationOnlyChart.js +208 -0
  6. package/lib/components/AnnotationOnlyChart/AnnotationOnlyChart.js.map +1 -0
  7. package/lib/components/AnnotationOnlyChart/AnnotationOnlyChart.types.js +1 -0
  8. package/lib/components/AnnotationOnlyChart/AnnotationOnlyChart.types.js.map +1 -0
  9. package/lib/components/AnnotationOnlyChart/index.js +2 -0
  10. package/lib/components/AnnotationOnlyChart/index.js.map +1 -0
  11. package/lib/components/AnnotationOnlyChart/useAnnotationOnlyChartStyles.styles.js +31 -0
  12. package/lib/components/AnnotationOnlyChart/useAnnotationOnlyChartStyles.styles.js.map +1 -0
  13. package/lib/components/AnnotationOnlyChart/useAnnotationOnlyChartStyles.styles.raw.js +23 -0
  14. package/lib/components/AnnotationOnlyChart/useAnnotationOnlyChartStyles.styles.raw.js.map +1 -0
  15. package/lib/components/AreaChart/useAreaChartStyles.styles.js +3 -1
  16. package/lib/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
  17. package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js +3 -1
  18. package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
  19. package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.js +617 -0
  20. package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.js.map +1 -0
  21. package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.types.js +1 -0
  22. package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.types.js.map +1 -0
  23. package/lib/components/CommonComponents/Annotations/index.js +2 -0
  24. package/lib/components/CommonComponents/Annotations/index.js.map +1 -0
  25. package/lib/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.js +173 -0
  26. package/lib/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.js.map +1 -0
  27. package/lib/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.raw.js +126 -0
  28. package/lib/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.raw.js.map +1 -0
  29. package/lib/components/CommonComponents/CartesianChart.js +31 -6
  30. package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
  31. package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
  32. package/lib/components/CommonComponents/index.js +2 -0
  33. package/lib/components/CommonComponents/index.js.map +1 -1
  34. package/lib/components/CommonComponents/useCartesianChartStyles.styles.js +17 -4
  35. package/lib/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
  36. package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js +14 -1
  37. package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
  38. package/lib/components/DeclarativeChart/DeclarativeChart.js +39 -19
  39. package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  40. package/lib/components/DeclarativeChart/PlotlyColorAdapter.js +4 -8
  41. package/lib/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
  42. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +588 -40
  43. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  44. package/lib/components/GanttChart/useGanttChartStyles.styles.js +3 -1
  45. package/lib/components/GanttChart/useGanttChartStyles.styles.js.map +1 -1
  46. package/lib/components/GanttChart/useGanttChartStyles.styles.raw.js +3 -1
  47. package/lib/components/GanttChart/useGanttChartStyles.styles.raw.js.map +1 -1
  48. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +3 -1
  49. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
  50. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +3 -1
  51. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +1 -1
  52. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js +3 -1
  53. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -1
  54. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js +3 -1
  55. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js.map +1 -1
  56. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +3 -1
  57. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -1
  58. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js +3 -1
  59. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js.map +1 -1
  60. package/lib/components/LineChart/useLineChartStyles.styles.js +3 -1
  61. package/lib/components/LineChart/useLineChartStyles.styles.js.map +1 -1
  62. package/lib/components/LineChart/useLineChartStyles.styles.raw.js +3 -1
  63. package/lib/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
  64. package/lib/components/ScatterChart/useScatterChartStyles.styles.js +3 -1
  65. package/lib/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
  66. package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js +3 -1
  67. package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
  68. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +3 -1
  69. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
  70. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +3 -1
  71. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
  72. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +3 -1
  73. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
  74. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +3 -1
  75. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
  76. package/lib/index.js +1 -0
  77. package/lib/index.js.map +1 -1
  78. package/lib/types/ChartAnnotation.js +1 -0
  79. package/lib/types/ChartAnnotation.js.map +1 -0
  80. package/lib/types/index.js +1 -0
  81. package/lib/types/index.js.map +1 -1
  82. package/lib/utilities/image-export-utils.js +108 -0
  83. package/lib/utilities/image-export-utils.js.map +1 -1
  84. package/lib-commonjs/AnnotationOnlyChart.js +6 -0
  85. package/lib-commonjs/AnnotationOnlyChart.js.map +1 -0
  86. package/lib-commonjs/components/AnnotationOnlyChart/AnnotationOnlyChart.js +219 -0
  87. package/lib-commonjs/components/AnnotationOnlyChart/AnnotationOnlyChart.js.map +1 -0
  88. package/lib-commonjs/components/AnnotationOnlyChart/AnnotationOnlyChart.types.js +6 -0
  89. package/lib-commonjs/components/AnnotationOnlyChart/AnnotationOnlyChart.types.js.map +1 -0
  90. package/lib-commonjs/components/AnnotationOnlyChart/index.js +7 -0
  91. package/lib-commonjs/components/AnnotationOnlyChart/index.js.map +1 -0
  92. package/lib-commonjs/components/AnnotationOnlyChart/useAnnotationOnlyChartStyles.styles.js +56 -0
  93. package/lib-commonjs/components/AnnotationOnlyChart/useAnnotationOnlyChartStyles.styles.js.map +1 -0
  94. package/lib-commonjs/components/AnnotationOnlyChart/useAnnotationOnlyChartStyles.styles.raw.js +33 -0
  95. package/lib-commonjs/components/AnnotationOnlyChart/useAnnotationOnlyChartStyles.styles.raw.js.map +1 -0
  96. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js +3 -1
  97. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
  98. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js +3 -1
  99. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
  100. package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.js +628 -0
  101. package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.js.map +1 -0
  102. package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.types.js +4 -0
  103. package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.types.js.map +1 -0
  104. package/lib-commonjs/components/CommonComponents/Annotations/index.js +7 -0
  105. package/lib-commonjs/components/CommonComponents/Annotations/index.js.map +1 -0
  106. package/lib-commonjs/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.js +265 -0
  107. package/lib-commonjs/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.js.map +1 -0
  108. package/lib-commonjs/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.raw.js +161 -0
  109. package/lib-commonjs/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.raw.js.map +1 -0
  110. package/lib-commonjs/components/CommonComponents/CartesianChart.js +31 -6
  111. package/lib-commonjs/components/CommonComponents/CartesianChart.js.map +1 -1
  112. package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
  113. package/lib-commonjs/components/CommonComponents/index.js +2 -0
  114. package/lib-commonjs/components/CommonComponents/index.js.map +1 -1
  115. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js +16 -2
  116. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
  117. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js +14 -1
  118. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
  119. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +38 -18
  120. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  121. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
  122. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +574 -6
  123. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  124. package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.js +3 -1
  125. package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.js.map +1 -1
  126. package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.raw.js +3 -1
  127. package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.raw.js.map +1 -1
  128. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +3 -1
  129. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
  130. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +3 -1
  131. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +1 -1
  132. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js +3 -1
  133. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -1
  134. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js +3 -1
  135. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js.map +1 -1
  136. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +3 -1
  137. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -1
  138. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js +3 -1
  139. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js.map +1 -1
  140. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js +3 -1
  141. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js.map +1 -1
  142. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js +3 -1
  143. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
  144. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js +3 -1
  145. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
  146. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js +3 -1
  147. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
  148. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +3 -1
  149. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
  150. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +3 -1
  151. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
  152. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +3 -1
  153. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
  154. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +3 -1
  155. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
  156. package/lib-commonjs/index.js +1 -0
  157. package/lib-commonjs/index.js.map +1 -1
  158. package/lib-commonjs/types/ChartAnnotation.js +6 -0
  159. package/lib-commonjs/types/ChartAnnotation.js.map +1 -0
  160. package/lib-commonjs/types/index.js +1 -0
  161. package/lib-commonjs/types/index.js.map +1 -1
  162. package/lib-commonjs/utilities/image-export-utils.js +108 -0
  163. package/lib-commonjs/utilities/image-export-utils.js.map +1 -1
  164. package/package.json +12 -12
@@ -0,0 +1,628 @@
1
+ 'use client';
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "ChartAnnotationLayer", {
7
+ enumerable: true,
8
+ get: function() {
9
+ return ChartAnnotationLayer;
10
+ }
11
+ });
12
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
13
+ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
14
+ const _react1 = require("@griffel/react");
15
+ const _useChartAnnotationLayerstyles = require("./useChartAnnotationLayer.styles");
16
+ const _reactutilities = require("@fluentui/react-utilities");
17
+ const _reacttheme = require("@fluentui/react-theme");
18
+ const DEFAULT_HORIZONTAL_ALIGN = 'center';
19
+ const DEFAULT_VERTICAL_ALIGN = 'middle';
20
+ const DEFAULT_FOREIGN_OBJECT_WIDTH = 180;
21
+ const DEFAULT_FOREIGN_OBJECT_HEIGHT = 60;
22
+ const MIN_ARROW_SIZE = 6;
23
+ const MAX_ARROW_SIZE = 24;
24
+ const ARROW_SIZE_SCALE = 0.35;
25
+ const MAX_SIMPLE_MARKUP_DEPTH = 5;
26
+ const CHAR_CODE_LESS_THAN = '<'.codePointAt(0);
27
+ const CHAR_CODE_GREATER_THAN = '>'.codePointAt(0);
28
+ const getAnnotationKey = (annotation, index)=>{
29
+ var _annotation_id, _ref;
30
+ return (_ref = (_annotation_id = annotation.id) !== null && _annotation_id !== void 0 ? _annotation_id : typeof annotation.text === 'string' || typeof annotation.text === 'number' ? String(annotation.text) : undefined) !== null && _ref !== void 0 ? _ref : `annotation-${index}`;
31
+ };
32
+ const decodeSimpleMarkupInput = (input)=>{
33
+ const namedEntities = {
34
+ amp: '&',
35
+ quot: '"',
36
+ apos: "'",
37
+ nbsp: '\u00a0'
38
+ };
39
+ const withBasicEntitiesDecoded = input.replace(/&(#x?[0-9a-f]+|#\d+|[a-z][\w-]*);/gi, (match, entity)=>{
40
+ const lower = entity.toLowerCase();
41
+ if (lower === 'lt' || lower === 'gt') {
42
+ return `&${lower};`;
43
+ }
44
+ if (lower.startsWith('#')) {
45
+ const isHex = lower[1] === 'x';
46
+ const digits = lower.slice(isHex ? 2 : 1);
47
+ const codePoint = Number.parseInt(digits, isHex ? 16 : 10);
48
+ if (Number.isNaN(codePoint)) {
49
+ return match;
50
+ }
51
+ if (codePoint === CHAR_CODE_LESS_THAN) {
52
+ return '&lt;';
53
+ }
54
+ if (codePoint === CHAR_CODE_GREATER_THAN) {
55
+ return '&gt;';
56
+ }
57
+ return String.fromCodePoint(codePoint);
58
+ }
59
+ var _namedEntities_lower;
60
+ return (_namedEntities_lower = namedEntities[lower]) !== null && _namedEntities_lower !== void 0 ? _namedEntities_lower : match;
61
+ });
62
+ return withBasicEntitiesDecoded.replace(/&lt;([^;]+)&gt;/gi, (match, inner)=>{
63
+ const normalized = inner.trim().replace(/\s+/g, ' ');
64
+ const lower = normalized.toLowerCase();
65
+ switch(lower){
66
+ case 'b':
67
+ return '<b>';
68
+ case '/b':
69
+ return '</b>';
70
+ case 'i':
71
+ return '<i>';
72
+ case '/i':
73
+ return '</i>';
74
+ case 'br':
75
+ case 'br/':
76
+ case 'br /':
77
+ return '<br />';
78
+ default:
79
+ return match;
80
+ }
81
+ });
82
+ };
83
+ const appendTextNode = (nodes, text)=>{
84
+ if (text.length === 0) {
85
+ return;
86
+ }
87
+ const last = nodes[nodes.length - 1];
88
+ if (last && last.type === 'text') {
89
+ last.content += text;
90
+ } else {
91
+ nodes.push({
92
+ type: 'text',
93
+ content: text
94
+ });
95
+ }
96
+ };
97
+ const serializeSimpleMarkup = (nodes)=>nodes.map((node)=>{
98
+ if (node.type === 'text') {
99
+ return node.content;
100
+ }
101
+ if (node.type === 'br') {
102
+ return '<br />';
103
+ }
104
+ return `<${node.tag}>${serializeSimpleMarkup(node.children)}</${node.tag}>`;
105
+ }).join('');
106
+ const parseSimpleMarkup = (input)=>{
107
+ if (!input) {
108
+ return [];
109
+ }
110
+ const decodedInput = decodeSimpleMarkupInput(input);
111
+ const rootChildren = [];
112
+ const stack = [
113
+ {
114
+ node: null
115
+ }
116
+ ];
117
+ const currentChildren = ()=>{
118
+ var _stack__node;
119
+ var _stack__node_children;
120
+ return (_stack__node_children = (_stack__node = stack[stack.length - 1].node) === null || _stack__node === void 0 ? void 0 : _stack__node.children) !== null && _stack__node_children !== void 0 ? _stack__node_children : rootChildren;
121
+ };
122
+ const tagRegex = /<\/?([a-z]+)\s*\/?\s*>/gi;
123
+ let lastIndex = 0;
124
+ let match;
125
+ while((match = tagRegex.exec(decodedInput)) !== null){
126
+ const [fullMatch, rawTagName] = match;
127
+ const tagName = rawTagName.toLowerCase();
128
+ const isClosing = fullMatch.startsWith('</');
129
+ const isSelfClosing = /\/\s*>$/.test(fullMatch);
130
+ appendTextNode(currentChildren(), decodedInput.slice(lastIndex, match.index));
131
+ lastIndex = match.index + fullMatch.length;
132
+ if (tagName === 'br' && !isClosing) {
133
+ currentChildren().push({
134
+ type: 'br'
135
+ });
136
+ continue;
137
+ }
138
+ if ((tagName === 'b' || tagName === 'i') && !isSelfClosing) {
139
+ if (isClosing) {
140
+ const top = stack[stack.length - 1].node;
141
+ if (stack.length > 1 && (top === null || top === void 0 ? void 0 : top.tag) === tagName) {
142
+ stack.pop();
143
+ } else {
144
+ appendTextNode(currentChildren(), fullMatch);
145
+ }
146
+ } else {
147
+ if (stack.length - 1 >= MAX_SIMPLE_MARKUP_DEPTH) {
148
+ appendTextNode(currentChildren(), fullMatch);
149
+ continue;
150
+ }
151
+ const elementNode = {
152
+ type: 'element',
153
+ tag: tagName,
154
+ children: []
155
+ };
156
+ currentChildren().push(elementNode);
157
+ stack.push({
158
+ node: elementNode
159
+ });
160
+ }
161
+ continue;
162
+ }
163
+ appendTextNode(currentChildren(), fullMatch);
164
+ }
165
+ appendTextNode(currentChildren(), decodedInput.slice(lastIndex));
166
+ while(stack.length > 1){
167
+ var _stack__node;
168
+ const unclosed = stack.pop();
169
+ const elementNode = unclosed.node;
170
+ if (!elementNode) {
171
+ continue;
172
+ }
173
+ var _stack__node_children;
174
+ const parentChildren = (_stack__node_children = (_stack__node = stack[stack.length - 1].node) === null || _stack__node === void 0 ? void 0 : _stack__node.children) !== null && _stack__node_children !== void 0 ? _stack__node_children : rootChildren;
175
+ const lastChild = parentChildren[parentChildren.length - 1];
176
+ if (lastChild === elementNode) {
177
+ parentChildren.pop();
178
+ } else {
179
+ const nodeIndex = parentChildren.indexOf(elementNode);
180
+ if (nodeIndex !== -1) {
181
+ parentChildren.splice(nodeIndex, 1);
182
+ }
183
+ }
184
+ appendTextNode(parentChildren, `<${elementNode.tag}>${serializeSimpleMarkup(elementNode.children)}</${elementNode.tag}>`);
185
+ }
186
+ return rootChildren;
187
+ };
188
+ const simpleMarkupNodesToPlainText = (nodes)=>nodes.map((node)=>{
189
+ if (node.type === 'text') {
190
+ return node.content;
191
+ }
192
+ if (node.type === 'br') {
193
+ return '\n';
194
+ }
195
+ return simpleMarkupNodesToPlainText(node.children);
196
+ }).join('');
197
+ const renderSimpleMarkupNodeList = (nodes, keyPrefix)=>nodes.map((node, index)=>{
198
+ const key = `${keyPrefix}-${index}`;
199
+ if (node.type === 'text') {
200
+ return /*#__PURE__*/ _react.createElement(_react.Fragment, {
201
+ key: key
202
+ }, node.content);
203
+ }
204
+ if (node.type === 'br') {
205
+ return /*#__PURE__*/ _react.createElement("br", {
206
+ key: key
207
+ });
208
+ }
209
+ const Tag = node.tag === 'b' ? 'strong' : 'em';
210
+ return /*#__PURE__*/ _react.createElement(Tag, {
211
+ key
212
+ }, ...renderSimpleMarkupNodeList(node.children, key));
213
+ });
214
+ const renderSimpleMarkup = (nodes, keyPrefix)=>{
215
+ const rendered = renderSimpleMarkupNodeList(nodes, keyPrefix);
216
+ var _rendered_;
217
+ return rendered.length <= 1 ? (_rendered_ = rendered[0]) !== null && _rendered_ !== void 0 ? _rendered_ : null : rendered;
218
+ };
219
+ const normalizeBandOffset = (scale, value)=>{
220
+ const position = scale === null || scale === void 0 ? void 0 : scale(value);
221
+ if (typeof position !== 'number' || Number.isNaN(position)) {
222
+ return undefined;
223
+ }
224
+ if (scale && typeof scale.bandwidth === 'function') {
225
+ return position + scale.bandwidth() / 2;
226
+ }
227
+ return position;
228
+ };
229
+ const clamp = (value, min, max)=>Math.max(min, Math.min(max, value));
230
+ const createMeasurementSignature = (annotationContentSignature, containerStyle, contentStyle, layoutClassName, styleClassName)=>JSON.stringify({
231
+ annotationContentSignature,
232
+ containerStyle,
233
+ contentStyle,
234
+ layoutClassName: layoutClassName !== null && layoutClassName !== void 0 ? layoutClassName : '',
235
+ styleClassName: styleClassName !== null && styleClassName !== void 0 ? styleClassName : ''
236
+ });
237
+ const resolveCoordinates = (annotation, context)=>{
238
+ const { coordinates, layout } = annotation;
239
+ if (!coordinates) {
240
+ return undefined;
241
+ }
242
+ var _layout_offsetX;
243
+ const offsetX = (_layout_offsetX = layout === null || layout === void 0 ? void 0 : layout.offsetX) !== null && _layout_offsetX !== void 0 ? _layout_offsetX : 0;
244
+ var _layout_offsetY;
245
+ const offsetY = (_layout_offsetY = layout === null || layout === void 0 ? void 0 : layout.offsetY) !== null && _layout_offsetY !== void 0 ? _layout_offsetY : 0;
246
+ const anchor = {
247
+ x: 0,
248
+ y: 0
249
+ };
250
+ switch(coordinates.type){
251
+ case 'data':
252
+ {
253
+ const { x, y, yAxis = 'primary' } = coordinates;
254
+ const xScale = context.xScale;
255
+ const yScale = yAxis === 'secondary' ? context.yScaleSecondary : context.yScalePrimary;
256
+ if (!xScale || !yScale) {
257
+ return undefined;
258
+ }
259
+ const xValue = normalizeBandOffset(xScale, x instanceof Date ? x.getTime() : x);
260
+ const yValue = normalizeBandOffset(yScale, y instanceof Date ? y.getTime() : y);
261
+ if (typeof xValue !== 'number' || typeof yValue !== 'number') {
262
+ return undefined;
263
+ }
264
+ anchor.x = xValue;
265
+ anchor.y = yValue;
266
+ break;
267
+ }
268
+ case 'relative':
269
+ {
270
+ if (typeof coordinates.x !== 'number' || typeof coordinates.y !== 'number') {
271
+ return undefined;
272
+ }
273
+ anchor.x = context.plotRect.x + context.plotRect.width * coordinates.x;
274
+ anchor.y = context.plotRect.y + context.plotRect.height * coordinates.y;
275
+ break;
276
+ }
277
+ case 'pixel':
278
+ {
279
+ if (typeof coordinates.x !== 'number' || typeof coordinates.y !== 'number') {
280
+ return undefined;
281
+ }
282
+ anchor.x = context.plotRect.x + coordinates.x;
283
+ anchor.y = context.plotRect.y + coordinates.y;
284
+ break;
285
+ }
286
+ default:
287
+ return undefined;
288
+ }
289
+ let left = anchor.x + offsetX;
290
+ let top = anchor.y + offsetY;
291
+ if (layout === null || layout === void 0 ? void 0 : layout.clipToBounds) {
292
+ left = clamp(left, context.plotRect.x, context.plotRect.x + context.plotRect.width);
293
+ top = clamp(top, context.plotRect.y, context.plotRect.y + context.plotRect.height);
294
+ }
295
+ return {
296
+ anchor,
297
+ point: {
298
+ x: left,
299
+ y: top
300
+ }
301
+ };
302
+ };
303
+ const ChartAnnotationLayer = /*#__PURE__*/ _react.memo((props)=>{
304
+ const { annotations: annotationsProp, context } = props;
305
+ const classes = (0, _useChartAnnotationLayerstyles.useChartAnnotationLayerStyles)(props);
306
+ const idPrefix = (0, _reactutilities.useId)('chart-annotation');
307
+ const [measurements, setMeasurements] = _react.useState({});
308
+ const resolvedAnnotations = _react.useMemo(()=>(annotationsProp !== null && annotationsProp !== void 0 ? annotationsProp : []).map((annotation, index)=>({
309
+ annotation,
310
+ key: getAnnotationKey(annotation, index)
311
+ })), [
312
+ annotationsProp
313
+ ]);
314
+ _react.useEffect(()=>{
315
+ setMeasurements((prev)=>{
316
+ if (resolvedAnnotations.length === 0) {
317
+ if (Object.keys(prev).length === 0) {
318
+ return prev;
319
+ }
320
+ return {};
321
+ }
322
+ const next = {};
323
+ resolvedAnnotations.forEach(({ key })=>{
324
+ if (prev[key]) {
325
+ next[key] = prev[key];
326
+ }
327
+ });
328
+ if (Object.keys(next).length === Object.keys(prev).length) {
329
+ let identical = true;
330
+ for (const key of Object.keys(next)){
331
+ if (next[key] !== prev[key]) {
332
+ identical = false;
333
+ break;
334
+ }
335
+ }
336
+ if (identical) {
337
+ return prev;
338
+ }
339
+ }
340
+ return next;
341
+ });
342
+ }, [
343
+ resolvedAnnotations
344
+ ]);
345
+ const updateMeasurement = _react.useCallback((key, width, height, signature)=>{
346
+ setMeasurements((prev)=>{
347
+ const prevEntry = prev[key];
348
+ if (prevEntry && prevEntry.signature === signature && Math.abs(prevEntry.width - width) < 0.5 && Math.abs(prevEntry.height - height) < 0.5) {
349
+ return prev;
350
+ }
351
+ if (width === 0 && height === 0) {
352
+ return prev;
353
+ }
354
+ return {
355
+ ...prev,
356
+ [key]: {
357
+ width,
358
+ height,
359
+ signature
360
+ }
361
+ };
362
+ });
363
+ }, []);
364
+ const annotationForeignObjects = [];
365
+ const measurementElements = [];
366
+ const connectors = [];
367
+ resolvedAnnotations.forEach(({ annotation, key })=>{
368
+ var _annotation_style, _annotation_style1, _annotation_style2, _annotation_style3, _annotation_style4, _annotation_style5, _annotation_style6, _annotation_style7, _annotation_style8, _annotation_style9, _annotation_style10, _annotation_style11, _annotation_style12, _annotation_style13, _annotation_style14, _annotation_style15, _annotation_style16, _annotation_style17, _annotation_accessibility, _annotation_accessibility1, _annotation_accessibility2;
369
+ const resolved = resolveCoordinates(annotation, context);
370
+ if (!resolved) {
371
+ return;
372
+ }
373
+ const rawAnnotationText = annotation.text === undefined || annotation.text === null ? '' : String(annotation.text);
374
+ const annotationMarkupNodes = parseSimpleMarkup(rawAnnotationText);
375
+ const annotationMarkupSignature = JSON.stringify(annotationMarkupNodes);
376
+ const annotationPlainText = simpleMarkupNodesToPlainText(annotationMarkupNodes);
377
+ const layout = annotation.layout;
378
+ var _layout_align;
379
+ const horizontalAlign = (_layout_align = layout === null || layout === void 0 ? void 0 : layout.align) !== null && _layout_align !== void 0 ? _layout_align : DEFAULT_HORIZONTAL_ALIGN;
380
+ var _layout_verticalAlign;
381
+ const verticalAlign = (_layout_verticalAlign = layout === null || layout === void 0 ? void 0 : layout.verticalAlign) !== null && _layout_verticalAlign !== void 0 ? _layout_verticalAlign : DEFAULT_VERTICAL_ALIGN;
382
+ var _annotation_style_opacity;
383
+ const backgroundOpacity = (_annotation_style_opacity = (_annotation_style = annotation.style) === null || _annotation_style === void 0 ? void 0 : _annotation_style.opacity) !== null && _annotation_style_opacity !== void 0 ? _annotation_style_opacity : _useChartAnnotationLayerstyles.DEFAULT_ANNOTATION_BACKGROUND_OPACITY;
384
+ const baseBackgroundColor = (_annotation_style1 = annotation.style) === null || _annotation_style1 === void 0 ? void 0 : _annotation_style1.backgroundColor;
385
+ const hasCustomBackground = ((_annotation_style2 = annotation.style) === null || _annotation_style2 === void 0 ? void 0 : _annotation_style2.backgroundColor) !== undefined || ((_annotation_style3 = annotation.style) === null || _annotation_style3 === void 0 ? void 0 : _annotation_style3.opacity) !== undefined;
386
+ var _annotation_style_borderStyle;
387
+ const containerStyle = {
388
+ maxWidth: layout === null || layout === void 0 ? void 0 : layout.maxWidth,
389
+ ...hasCustomBackground ? {
390
+ backgroundColor: (0, _useChartAnnotationLayerstyles.applyOpacityToColor)(baseBackgroundColor, backgroundOpacity)
391
+ } : {
392
+ backgroundColor: (0, _useChartAnnotationLayerstyles.applyOpacityToColor)(_reacttheme.tokens.colorNeutralBackground1, _useChartAnnotationLayerstyles.DEFAULT_ANNOTATION_BACKGROUND_OPACITY)
393
+ },
394
+ borderColor: (_annotation_style4 = annotation.style) === null || _annotation_style4 === void 0 ? void 0 : _annotation_style4.borderColor,
395
+ borderWidth: (_annotation_style5 = annotation.style) === null || _annotation_style5 === void 0 ? void 0 : _annotation_style5.borderWidth,
396
+ borderStyle: (_annotation_style_borderStyle = (_annotation_style6 = annotation.style) === null || _annotation_style6 === void 0 ? void 0 : _annotation_style6.borderStyle) !== null && _annotation_style_borderStyle !== void 0 ? _annotation_style_borderStyle : ((_annotation_style7 = annotation.style) === null || _annotation_style7 === void 0 ? void 0 : _annotation_style7.borderColor) ? 'solid' : undefined,
397
+ borderRadius: (_annotation_style8 = annotation.style) === null || _annotation_style8 === void 0 ? void 0 : _annotation_style8.borderRadius,
398
+ padding: (_annotation_style9 = annotation.style) === null || _annotation_style9 === void 0 ? void 0 : _annotation_style9.padding,
399
+ boxShadow: (_annotation_style10 = annotation.style) === null || _annotation_style10 === void 0 ? void 0 : _annotation_style10.boxShadow
400
+ };
401
+ const contentStyle = {
402
+ color: (_annotation_style11 = annotation.style) === null || _annotation_style11 === void 0 ? void 0 : _annotation_style11.textColor,
403
+ fontSize: (_annotation_style12 = annotation.style) === null || _annotation_style12 === void 0 ? void 0 : _annotation_style12.fontSize,
404
+ fontWeight: (_annotation_style13 = annotation.style) === null || _annotation_style13 === void 0 ? void 0 : _annotation_style13.fontWeight,
405
+ opacity: 1
406
+ };
407
+ if (typeof ((_annotation_style14 = annotation.style) === null || _annotation_style14 === void 0 ? void 0 : _annotation_style14.rotation) === 'number' && !Number.isNaN(annotation.style.rotation)) {
408
+ containerStyle.transform = `rotate(${annotation.style.rotation}deg)`;
409
+ containerStyle.transformOrigin = '50% 50%';
410
+ }
411
+ const measurementSignature = createMeasurementSignature(annotationMarkupSignature, containerStyle, contentStyle, layout === null || layout === void 0 ? void 0 : layout.className, (_annotation_style15 = annotation.style) === null || _annotation_style15 === void 0 ? void 0 : _annotation_style15.className);
412
+ const measurementEntry = measurements[key];
413
+ const isMeasurementValid = (measurementEntry === null || measurementEntry === void 0 ? void 0 : measurementEntry.signature) === measurementSignature;
414
+ const measuredSize = isMeasurementValid ? measurementEntry : undefined;
415
+ var _measuredSize_width, _ref;
416
+ const width = Math.max((_ref = (_measuredSize_width = measuredSize === null || measuredSize === void 0 ? void 0 : measuredSize.width) !== null && _measuredSize_width !== void 0 ? _measuredSize_width : layout === null || layout === void 0 ? void 0 : layout.maxWidth) !== null && _ref !== void 0 ? _ref : DEFAULT_FOREIGN_OBJECT_WIDTH, 1);
417
+ var _measuredSize_height;
418
+ const height = Math.max((_measuredSize_height = measuredSize === null || measuredSize === void 0 ? void 0 : measuredSize.height) !== null && _measuredSize_height !== void 0 ? _measuredSize_height : DEFAULT_FOREIGN_OBJECT_HEIGHT, 1);
419
+ const offsetX = horizontalAlign === 'center' ? -width / 2 : horizontalAlign === 'end' ? -width : 0;
420
+ const offsetY = verticalAlign === 'middle' ? -height / 2 : verticalAlign === 'bottom' ? -height : 0;
421
+ const baseTopLeftX = resolved.point.x + offsetX;
422
+ const baseTopLeftY = resolved.point.y + offsetY;
423
+ const usePlotBounds = (layout === null || layout === void 0 ? void 0 : layout.clipToBounds) !== false;
424
+ const viewportX = usePlotBounds ? context.plotRect.x : 0;
425
+ const viewportY = usePlotBounds ? context.plotRect.y : 0;
426
+ var _context_svgRect_width;
427
+ const viewportWidth = usePlotBounds ? context.plotRect.width : (_context_svgRect_width = context.svgRect.width) !== null && _context_svgRect_width !== void 0 ? _context_svgRect_width : 0;
428
+ var _context_svgRect_height;
429
+ const viewportHeight = usePlotBounds ? context.plotRect.height : (_context_svgRect_height = context.svgRect.height) !== null && _context_svgRect_height !== void 0 ? _context_svgRect_height : 0;
430
+ const maxTopLeftX = viewportWidth > 0 ? viewportX + viewportWidth - width : baseTopLeftX;
431
+ const maxTopLeftY = viewportHeight > 0 ? viewportY + viewportHeight - height : baseTopLeftY;
432
+ let topLeftX = viewportWidth > 0 ? clamp(baseTopLeftX, viewportX, Math.max(viewportX, maxTopLeftX)) : baseTopLeftX;
433
+ let topLeftY = viewportHeight > 0 ? clamp(baseTopLeftY, viewportY, Math.max(viewportY, maxTopLeftY)) : baseTopLeftY;
434
+ let displayPoint = {
435
+ x: topLeftX - offsetX,
436
+ y: topLeftY - offsetY
437
+ };
438
+ if (annotation.connector) {
439
+ var _annotation_connector_startPadding;
440
+ const startPadding = (_annotation_connector_startPadding = annotation.connector.startPadding) !== null && _annotation_connector_startPadding !== void 0 ? _annotation_connector_startPadding : 12;
441
+ var _annotation_connector_endPadding;
442
+ const endPadding = (_annotation_connector_endPadding = annotation.connector.endPadding) !== null && _annotation_connector_endPadding !== void 0 ? _annotation_connector_endPadding : 0;
443
+ const minArrowClearance = 6;
444
+ const minDistance = Math.max(startPadding + endPadding + minArrowClearance, startPadding);
445
+ const dx = displayPoint.x - resolved.anchor.x;
446
+ const dy = displayPoint.y - resolved.anchor.y;
447
+ const distance = Math.sqrt(dx * dx + dy * dy);
448
+ if (distance < minDistance) {
449
+ const fallbackDirection = {
450
+ x: 0,
451
+ y: -1
452
+ };
453
+ const ux = distance === 0 ? fallbackDirection.x : dx / distance;
454
+ const uy = distance === 0 ? fallbackDirection.y : dy / distance;
455
+ const desiredDisplayX = resolved.anchor.x + ux * minDistance;
456
+ const desiredDisplayY = resolved.anchor.y + uy * minDistance;
457
+ let desiredTopLeftX = desiredDisplayX + offsetX;
458
+ let desiredTopLeftY = desiredDisplayY + offsetY;
459
+ desiredTopLeftX = viewportWidth > 0 ? clamp(desiredTopLeftX, viewportX, Math.max(viewportX, maxTopLeftX)) : desiredTopLeftX;
460
+ desiredTopLeftY = viewportHeight > 0 ? clamp(desiredTopLeftY, viewportY, Math.max(viewportY, maxTopLeftY)) : desiredTopLeftY;
461
+ topLeftX = desiredTopLeftX;
462
+ topLeftY = desiredTopLeftY;
463
+ displayPoint = {
464
+ x: topLeftX - offsetX,
465
+ y: topLeftY - offsetY
466
+ };
467
+ }
468
+ }
469
+ const measurementStyle = {
470
+ position: 'absolute',
471
+ left: topLeftX,
472
+ top: topLeftY,
473
+ pointerEvents: 'none',
474
+ visibility: 'hidden',
475
+ ...containerStyle
476
+ };
477
+ if (!isMeasurementValid) {
478
+ var _annotation_style18, _annotation_style19;
479
+ measurementElements.push(/*#__PURE__*/ _react.createElement("div", {
480
+ key: `${key}-measurement`,
481
+ ref: (node)=>{
482
+ if (node) {
483
+ const rect = node.getBoundingClientRect();
484
+ if (rect.width !== 0 || rect.height !== 0) {
485
+ updateMeasurement(key, rect.width, rect.height, measurementSignature);
486
+ }
487
+ }
488
+ },
489
+ className: (0, _react1.mergeClasses)(classes.annotation, classes.measurement, layout === null || layout === void 0 ? void 0 : layout.className, (_annotation_style18 = annotation.style) === null || _annotation_style18 === void 0 ? void 0 : _annotation_style18.className),
490
+ style: measurementStyle,
491
+ "aria-hidden": true,
492
+ "data-annotation-key": key,
493
+ "data-chart-annotation-measurement": "true"
494
+ }, /*#__PURE__*/ _react.createElement("div", {
495
+ className: (0, _react1.mergeClasses)(classes.annotationContent, layout === null || layout === void 0 ? void 0 : layout.className, (_annotation_style19 = annotation.style) === null || _annotation_style19 === void 0 ? void 0 : _annotation_style19.className),
496
+ style: contentStyle
497
+ }, renderSimpleMarkup(annotationMarkupNodes, `${key}-measurement`))));
498
+ }
499
+ var _annotation_accessibility_role, _annotation_accessibility_ariaLabel;
500
+ annotationForeignObjects.push(/*#__PURE__*/ _react.createElement("foreignObject", {
501
+ key: `${key}-annotation`,
502
+ x: topLeftX,
503
+ y: topLeftY,
504
+ width: width,
505
+ height: height,
506
+ className: (0, _react1.mergeClasses)(classes.annotationForeignObject),
507
+ "data-annotation-key": key
508
+ }, /*#__PURE__*/ _react.createElement("div", {
509
+ className: (0, _react1.mergeClasses)(classes.annotation, layout === null || layout === void 0 ? void 0 : layout.className, (_annotation_style16 = annotation.style) === null || _annotation_style16 === void 0 ? void 0 : _annotation_style16.className),
510
+ style: containerStyle,
511
+ "data-annotation-key": key
512
+ }, /*#__PURE__*/ _react.createElement("div", {
513
+ className: (0, _react1.mergeClasses)(classes.annotationContent, (_annotation_style17 = annotation.style) === null || _annotation_style17 === void 0 ? void 0 : _annotation_style17.className),
514
+ style: contentStyle,
515
+ role: (_annotation_accessibility_role = (_annotation_accessibility = annotation.accessibility) === null || _annotation_accessibility === void 0 ? void 0 : _annotation_accessibility.role) !== null && _annotation_accessibility_role !== void 0 ? _annotation_accessibility_role : 'note',
516
+ "aria-label": (_annotation_accessibility_ariaLabel = (_annotation_accessibility1 = annotation.accessibility) === null || _annotation_accessibility1 === void 0 ? void 0 : _annotation_accessibility1.ariaLabel) !== null && _annotation_accessibility_ariaLabel !== void 0 ? _annotation_accessibility_ariaLabel : annotationPlainText ? annotationPlainText : undefined,
517
+ "aria-describedby": (_annotation_accessibility2 = annotation.accessibility) === null || _annotation_accessibility2 === void 0 ? void 0 : _annotation_accessibility2.ariaDescribedBy,
518
+ "data-chart-annotation": "true",
519
+ "data-annotation-key": key
520
+ }, renderSimpleMarkup(annotationMarkupNodes, `${key}-content`)))));
521
+ if (annotation.connector) {
522
+ const { startPadding = _useChartAnnotationLayerstyles.DEFAULT_CONNECTOR_START_PADDING, endPadding = _useChartAnnotationLayerstyles.DEFAULT_CONNECTOR_END_PADDING, strokeColor = (0, _useChartAnnotationLayerstyles.getDefaultConnectorStrokeColor)(), strokeWidth = _useChartAnnotationLayerstyles.DEFAULT_CONNECTOR_STROKE_WIDTH, dashArray, arrow = _useChartAnnotationLayerstyles.DEFAULT_CONNECTOR_ARROW } = annotation.connector;
523
+ const dx = resolved.anchor.x - displayPoint.x;
524
+ const dy = resolved.anchor.y - displayPoint.y;
525
+ const distance = Math.sqrt(dx * dx + dy * dy) || 1;
526
+ const ux = dx / distance;
527
+ const uy = dy / distance;
528
+ const sizeBasis = Math.max(1, Math.min(width, height));
529
+ const proportionalSize = sizeBasis * ARROW_SIZE_SCALE;
530
+ const maxByPadding = startPadding > 0 ? startPadding * 1.25 : MAX_ARROW_SIZE;
531
+ const maxByDistance = distance * 0.6;
532
+ const markerSize = clamp(proportionalSize, MIN_ARROW_SIZE, Math.min(MAX_ARROW_SIZE, maxByPadding, maxByDistance));
533
+ const markerStrokeWidth = clamp(strokeWidth, 1, markerSize / 2);
534
+ const start = {
535
+ x: displayPoint.x + ux * startPadding,
536
+ y: displayPoint.y + uy * startPadding
537
+ };
538
+ const end = {
539
+ x: resolved.anchor.x - ux * endPadding,
540
+ y: resolved.anchor.y - uy * endPadding
541
+ };
542
+ connectors.push({
543
+ key: `${key}-connector`,
544
+ start,
545
+ end,
546
+ strokeColor,
547
+ strokeWidth,
548
+ dashArray,
549
+ arrow,
550
+ markerSize,
551
+ markerStrokeWidth
552
+ });
553
+ }
554
+ });
555
+ if (annotationForeignObjects.length === 0 && connectors.length === 0) {
556
+ return null;
557
+ }
558
+ const viewBoxWidth = context.svgRect.width || 1;
559
+ const viewBoxHeight = context.svgRect.height || 1;
560
+ const markerDefs = [];
561
+ const createMarkerId = (color, position, size, markerStrokeWidth)=>{
562
+ const id = `${idPrefix}-${position}-${markerDefs.length}`;
563
+ const refY = size / 2;
564
+ const refX = position === 'end' ? size : 0;
565
+ const pathEnd = `M0 0 L ${size} ${refY} L0 ${size} Z`;
566
+ const pathStart = `M ${size} 0 L0 ${refY} L ${size} ${size} Z`;
567
+ const path = position === 'end' ? pathEnd : pathStart;
568
+ markerDefs.push(/*#__PURE__*/ _react.createElement("marker", {
569
+ key: id,
570
+ id: id,
571
+ markerWidth: size,
572
+ markerHeight: size,
573
+ viewBox: `0 0 ${size} ${size}`,
574
+ refX: refX,
575
+ refY: refY,
576
+ orient: "auto",
577
+ markerUnits: "userSpaceOnUse"
578
+ }, /*#__PURE__*/ _react.createElement("path", {
579
+ d: path,
580
+ fill: color,
581
+ stroke: color,
582
+ strokeWidth: markerStrokeWidth,
583
+ strokeLinecap: "round",
584
+ strokeLinejoin: "round"
585
+ })));
586
+ return id;
587
+ };
588
+ const connectorElements = connectors.map((connector)=>{
589
+ let markerStart;
590
+ let markerEnd;
591
+ if (connector.arrow === 'start' || connector.arrow === 'both') {
592
+ markerStart = createMarkerId(connector.strokeColor, 'start', connector.markerSize, connector.markerStrokeWidth);
593
+ }
594
+ if (connector.arrow === 'end' || connector.arrow === 'both') {
595
+ markerEnd = createMarkerId(connector.strokeColor, 'end', connector.markerSize, connector.markerStrokeWidth);
596
+ }
597
+ return /*#__PURE__*/ _react.createElement("line", {
598
+ key: connector.key,
599
+ x1: connector.start.x,
600
+ y1: connector.start.y,
601
+ x2: connector.end.x,
602
+ y2: connector.end.y,
603
+ stroke: connector.strokeColor,
604
+ strokeWidth: connector.strokeWidth,
605
+ strokeDasharray: connector.dashArray,
606
+ strokeLinecap: "round",
607
+ markerStart: markerStart ? `url(#${markerStart})` : undefined,
608
+ markerEnd: markerEnd ? `url(#${markerEnd})` : undefined
609
+ });
610
+ });
611
+ const shouldRenderSvg = connectors.length > 0 || annotationForeignObjects.length > 0;
612
+ return /*#__PURE__*/ _react.createElement("div", {
613
+ className: classes.root,
614
+ role: "presentation",
615
+ "data-chart-annotation-layer": "true"
616
+ }, shouldRenderSvg && /*#__PURE__*/ _react.createElement("svg", {
617
+ className: classes.connectorLayer,
618
+ width: "100%",
619
+ height: "100%",
620
+ viewBox: `0 0 ${viewBoxWidth} ${viewBoxHeight}`,
621
+ preserveAspectRatio: "none",
622
+ "data-chart-annotation-svg": "true"
623
+ }, markerDefs.length > 0 && /*#__PURE__*/ _react.createElement("defs", null, markerDefs), connectorElements.length > 0 && /*#__PURE__*/ _react.createElement("g", {
624
+ "aria-hidden": "true",
625
+ className: classes.connectorGroup
626
+ }, connectorElements), annotationForeignObjects), measurementElements);
627
+ });
628
+ ChartAnnotationLayer.displayName = 'ChartAnnotationLayer';