@highcharts/grid-pro 2.2.0 → 2.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (274) hide show
  1. package/LICENSE.txt +6 -0
  2. package/README.md +15 -9
  3. package/css/grid-pro.css +1262 -1122
  4. package/css/modules/grid-base-variables.css +131 -0
  5. package/css/modules/grid-button-variables.css +140 -0
  6. package/css/modules/grid-caption-variables.css +11 -0
  7. package/css/modules/grid-description-variables.css +11 -0
  8. package/css/modules/grid-input-variables.css +114 -0
  9. package/css/modules/grid-link-variables.css +18 -0
  10. package/css/modules/grid-menu-variables.css +50 -0
  11. package/css/modules/grid-pagination-variables.css +12 -0
  12. package/css/modules/grid-popup-variables.css +24 -0
  13. package/css/modules/grid-pro.css +234 -0
  14. package/css/modules/grid-table-variables.css +385 -0
  15. package/css/modules/grid-theme-default.css +55 -0
  16. package/es-modules/Accessibility/A11yI18n.js +1 -2
  17. package/es-modules/Accessibility/Accessibility.js +1 -2
  18. package/es-modules/Accessibility/AccessibilityComponent.d.ts +2 -2
  19. package/es-modules/Accessibility/Components/ContainerComponent.js +0 -1
  20. package/es-modules/Accessibility/Components/InfoRegionsComponent.js +6 -8
  21. package/es-modules/Accessibility/Components/LegendComponent.js +1 -2
  22. package/es-modules/Accessibility/Components/MenuComponent.js +1 -3
  23. package/es-modules/Accessibility/Components/NavigatorComponent.js +3 -4
  24. package/es-modules/Accessibility/Components/RangeSelectorComponent.js +1 -3
  25. package/es-modules/Accessibility/Components/SeriesComponent/ForcedMarkers.js +22 -11
  26. package/es-modules/Accessibility/Components/SeriesComponent/NewDataAnnouncer.js +3 -7
  27. package/es-modules/Accessibility/Components/SeriesComponent/SeriesComponent.js +0 -1
  28. package/es-modules/Accessibility/Components/SeriesComponent/SeriesDescriber.js +3 -5
  29. package/es-modules/Accessibility/Components/SeriesComponent/SeriesKeyboardNavigation.js +1 -4
  30. package/es-modules/Accessibility/Components/ZoomComponent.js +1 -2
  31. package/es-modules/Accessibility/FocusBorder.js +6 -7
  32. package/es-modules/Accessibility/KeyboardNavigation.js +1 -2
  33. package/es-modules/Accessibility/KeyboardNavigationHandler.js +1 -2
  34. package/es-modules/Accessibility/Options/A11yDefaults.d.ts +11 -0
  35. package/es-modules/Accessibility/Options/A11yDefaults.js +11 -0
  36. package/es-modules/Accessibility/Options/DeprecatedOptions.d.ts +58 -0
  37. package/es-modules/Accessibility/Options/DeprecatedOptions.js +8 -4
  38. package/es-modules/Accessibility/Options/LangDefaults.js +9 -0
  39. package/es-modules/Accessibility/ProxyElement.d.ts +2 -2
  40. package/es-modules/Accessibility/ProxyElement.js +4 -7
  41. package/es-modules/Accessibility/ProxyProvider.js +1 -2
  42. package/es-modules/Accessibility/Utils/Announcer.js +2 -3
  43. package/es-modules/Accessibility/Utils/ChartUtilities.js +1 -3
  44. package/es-modules/Accessibility/Utils/EventProvider.d.ts +2 -2
  45. package/es-modules/Accessibility/Utils/EventProvider.js +6 -2
  46. package/es-modules/Accessibility/Utils/HTMLUtilities.js +1 -3
  47. package/es-modules/Core/Animation/AnimationUtilities.js +1 -2
  48. package/es-modules/Core/Animation/Fx.js +1 -2
  49. package/es-modules/Core/Callback.d.ts +9 -2
  50. package/es-modules/Core/Chart/Chart.js +56 -42
  51. package/es-modules/Core/Chart/Chart3D.js +1 -2
  52. package/es-modules/Core/Chart/ChartDefaults.js +11 -0
  53. package/es-modules/Core/Chart/ChartNavigationComposition.js +0 -1
  54. package/es-modules/Core/Chart/ChartOptions.d.ts +8 -0
  55. package/es-modules/Core/Chart/GanttChart.js +1 -2
  56. package/es-modules/Core/Chart/MapChart.js +3 -2
  57. package/es-modules/Core/Chart/StockChart.js +2 -3
  58. package/es-modules/Core/Color/Color.js +1 -3
  59. package/es-modules/Core/Defaults.js +36 -10
  60. package/es-modules/Core/Delaunay.d.ts +1 -0
  61. package/es-modules/Core/Delaunay.js +312 -0
  62. package/es-modules/Core/Foundation.js +1 -3
  63. package/es-modules/Core/Geometry/CircleUtilities.js +1 -2
  64. package/es-modules/Core/Globals.js +1 -1
  65. package/es-modules/Core/HttpUtilities.js +1 -2
  66. package/es-modules/Core/MSPointer.js +1 -3
  67. package/es-modules/Core/Math3D.js +1 -2
  68. package/es-modules/Core/Options.d.ts +6 -2
  69. package/es-modules/Core/Pointer.js +23 -4
  70. package/es-modules/Core/PointerEvent.d.ts +2 -0
  71. package/es-modules/Core/Renderer/HTML/AST.js +2 -2
  72. package/es-modules/Core/Renderer/HTML/HTMLAttributes.d.ts +3 -0
  73. package/es-modules/Core/Renderer/HTML/HTMLElement.js +1 -2
  74. package/es-modules/Core/Renderer/RendererUtilities.js +34 -20
  75. package/es-modules/Core/Renderer/SVG/SVGRenderer.d.ts +1 -1
  76. package/es-modules/Core/Renderer/SVG/Symbols.d.ts +2 -2
  77. package/es-modules/Core/Responsive.d.ts +4 -2
  78. package/es-modules/Core/Responsive.js +10 -4
  79. package/es-modules/Core/Templating.d.ts +1 -1
  80. package/es-modules/Core/Templating.js +3 -4
  81. package/es-modules/Core/Time.d.ts +8 -0
  82. package/es-modules/Core/Time.js +2 -2
  83. package/es-modules/Core/Tooltip.d.ts +4 -8
  84. package/es-modules/Core/Tooltip.js +100 -81
  85. package/es-modules/Core/TooltipOptions.d.ts +44 -1
  86. package/es-modules/Core/Utilities.d.ts +25 -665
  87. package/es-modules/Core/Utilities.js +21 -1400
  88. package/es-modules/Data/ColumnUtils.d.ts +83 -80
  89. package/es-modules/Data/ColumnUtils.js +103 -113
  90. package/es-modules/Data/Connectors/CSVConnector.d.ts +9 -14
  91. package/es-modules/Data/Connectors/CSVConnector.js +3 -4
  92. package/es-modules/Data/Connectors/DataConnector.d.ts +56 -58
  93. package/es-modules/Data/Connectors/DataConnector.js +37 -56
  94. package/es-modules/Data/Connectors/GoogleSheetsConnector.d.ts +40 -42
  95. package/es-modules/Data/Connectors/GoogleSheetsConnector.js +73 -88
  96. package/es-modules/Data/Connectors/GoogleSheetsConnectorOptions.d.ts +4 -2
  97. package/es-modules/Data/Connectors/HTMLTableConnector.d.ts +23 -28
  98. package/es-modules/Data/Connectors/HTMLTableConnector.js +3 -4
  99. package/es-modules/Data/Connectors/JSONConnector.d.ts +9 -14
  100. package/es-modules/Data/Connectors/JSONConnector.js +3 -4
  101. package/es-modules/Data/Converters/CSVConverter.d.ts +5 -5
  102. package/es-modules/Data/Converters/CSVConverter.js +3 -4
  103. package/es-modules/Data/Converters/CSVConverterOptions.d.ts +2 -2
  104. package/es-modules/Data/Converters/DataConverter.d.ts +76 -78
  105. package/es-modules/Data/Converters/DataConverter.js +26 -53
  106. package/es-modules/Data/Converters/DataConverterUtils.d.ts +88 -81
  107. package/es-modules/Data/Converters/DataConverterUtils.js +169 -181
  108. package/es-modules/Data/Converters/GoogleSheetsConverter.d.ts +4 -4
  109. package/es-modules/Data/Converters/GoogleSheetsConverter.js +3 -3
  110. package/es-modules/Data/Converters/GoogleSheetsConverterOptions.d.ts +2 -2
  111. package/es-modules/Data/Converters/HTMLTableConverter.d.ts +4 -4
  112. package/es-modules/Data/Converters/HTMLTableConverter.js +2 -3
  113. package/es-modules/Data/Converters/HTMLTableConverterOptions.d.ts +2 -2
  114. package/es-modules/Data/Converters/JSONConverter.d.ts +7 -7
  115. package/es-modules/Data/Converters/JSONConverter.js +6 -6
  116. package/es-modules/Data/Converters/JSONConverterOptions.d.ts +2 -2
  117. package/es-modules/Data/DataCursor.d.ts +65 -70
  118. package/es-modules/Data/DataCursor.js +119 -139
  119. package/es-modules/Data/DataEvent.d.ts +55 -57
  120. package/es-modules/Data/DataPool.d.ts +10 -17
  121. package/es-modules/Data/DataPool.js +21 -10
  122. package/es-modules/Data/DataTable.d.ts +111 -113
  123. package/es-modules/Data/DataTable.js +3 -3
  124. package/es-modules/Data/DataTableCore.d.ts +9 -9
  125. package/es-modules/Data/DataTableCore.js +2 -2
  126. package/es-modules/Data/Formula/FormulaParser.js +1 -2
  127. package/es-modules/Data/Formula/FormulaProcessor.js +1 -2
  128. package/es-modules/Data/Modifiers/ChainModifier.d.ts +29 -34
  129. package/es-modules/Data/Modifiers/ChainModifier.js +7 -8
  130. package/es-modules/Data/Modifiers/DataModifier.d.ts +36 -41
  131. package/es-modules/Data/Modifiers/DataModifier.js +31 -53
  132. package/es-modules/Data/Modifiers/FilterModifier.d.ts +4 -4
  133. package/es-modules/Data/Modifiers/FilterModifier.js +3 -4
  134. package/es-modules/Data/Modifiers/FilterModifierOptions.d.ts +3 -2
  135. package/es-modules/Data/Modifiers/InvertModifier.d.ts +4 -4
  136. package/es-modules/Data/Modifiers/InvertModifier.js +3 -4
  137. package/es-modules/Data/Modifiers/MathModifier.d.ts +5 -4
  138. package/es-modules/Data/Modifiers/RangeModifier.d.ts +4 -4
  139. package/es-modules/Data/Modifiers/RangeModifier.js +3 -4
  140. package/es-modules/Data/Modifiers/SortModifier.d.ts +6 -11
  141. package/es-modules/Data/Modifiers/SortModifier.js +3 -4
  142. package/es-modules/Data/Modifiers/SortModifierOptions.d.ts +3 -3
  143. package/es-modules/Grid/Core/Accessibility/Accessibility.d.ts +1 -1
  144. package/es-modules/Grid/Core/Accessibility/Accessibility.js +5 -6
  145. package/es-modules/Grid/Core/Data/DataProvider.d.ts +97 -0
  146. package/es-modules/Grid/Core/Data/DataProvider.js +89 -0
  147. package/es-modules/Grid/Core/Data/DataProviderRegistry.d.ts +20 -0
  148. package/es-modules/Grid/Core/Data/DataProviderRegistry.js +52 -0
  149. package/es-modules/Grid/Core/Data/DataProviderType.d.ts +19 -0
  150. package/es-modules/Grid/Core/Data/DataProviderType.js +15 -0
  151. package/es-modules/Grid/Core/Data/LocalDataProvider.d.ts +165 -0
  152. package/es-modules/Grid/Core/Data/LocalDataProvider.js +341 -0
  153. package/es-modules/Grid/Core/Defaults.js +4 -2
  154. package/es-modules/Grid/Core/Globals.d.ts +20 -16
  155. package/es-modules/Grid/Core/Globals.js +10 -8
  156. package/es-modules/Grid/Core/Grid.d.ts +31 -22
  157. package/es-modules/Grid/Core/Grid.js +217 -139
  158. package/es-modules/Grid/Core/GridUtils.d.ts +33 -0
  159. package/es-modules/Grid/Core/GridUtils.js +50 -3
  160. package/es-modules/Grid/Core/Options.d.ts +145 -4
  161. package/es-modules/Grid/Core/Pagination/Pagination.d.ts +3 -0
  162. package/es-modules/Grid/Core/Pagination/Pagination.js +68 -28
  163. package/es-modules/Grid/Core/Pagination/PaginationOptions.d.ts +4 -0
  164. package/es-modules/Grid/Core/Querying/FilteringController.js +1 -2
  165. package/es-modules/Grid/Core/Querying/PaginationController.d.ts +3 -3
  166. package/es-modules/Grid/Core/Querying/PaginationController.js +7 -6
  167. package/es-modules/Grid/Core/Querying/QueryingController.d.ts +1 -1
  168. package/es-modules/Grid/Core/Querying/QueryingController.js +2 -26
  169. package/es-modules/Grid/Core/Responsive/ResponsiveComposition.d.ts +53 -0
  170. package/es-modules/Grid/Core/Responsive/ResponsiveComposition.js +272 -0
  171. package/es-modules/Grid/Core/Responsive/ResponsiveOptions.d.ts +58 -0
  172. package/es-modules/Grid/Core/Responsive/ResponsiveOptions.js +15 -0
  173. package/es-modules/Grid/Core/Table/Actions/ColumnFiltering/ColumnFiltering.js +2 -3
  174. package/es-modules/Grid/Core/Table/Actions/ColumnFiltering/FilterCell.d.ts +1 -1
  175. package/es-modules/Grid/Core/Table/Actions/ColumnFiltering/FilterCell.js +3 -4
  176. package/es-modules/Grid/Core/Table/Actions/ColumnFiltering/FilterRow.d.ts +1 -1
  177. package/es-modules/Grid/Core/Table/Actions/ColumnFiltering/FilterRow.js +2 -2
  178. package/es-modules/Grid/Core/Table/Actions/ColumnSorting.d.ts +17 -1
  179. package/es-modules/Grid/Core/Table/Actions/ColumnSorting.js +58 -15
  180. package/es-modules/Grid/Core/Table/Actions/ColumnsResizer.js +1 -3
  181. package/es-modules/Grid/Core/Table/Actions/RowsVirtualizer.d.ts +57 -3
  182. package/es-modules/Grid/Core/Table/Actions/RowsVirtualizer.js +411 -118
  183. package/es-modules/Grid/Core/Table/Body/CellContextMenu.d.ts +11 -0
  184. package/es-modules/Grid/Core/Table/Body/CellContextMenu.js +84 -0
  185. package/es-modules/Grid/Core/Table/Body/TableCell.d.ts +27 -13
  186. package/es-modules/Grid/Core/Table/Body/TableCell.js +74 -25
  187. package/es-modules/Grid/Core/Table/Body/TableRow.d.ts +7 -15
  188. package/es-modules/Grid/Core/Table/Body/TableRow.js +24 -19
  189. package/es-modules/Grid/Core/Table/Cell.d.ts +16 -3
  190. package/es-modules/Grid/Core/Table/Cell.js +36 -3
  191. package/es-modules/Grid/Core/Table/CellContent/TextContent.js +3 -8
  192. package/es-modules/Grid/Core/Table/Column.d.ts +10 -4
  193. package/es-modules/Grid/Core/Table/Column.js +23 -34
  194. package/es-modules/Grid/Core/Table/ColumnResizing/IndependentResizingMode.js +9 -8
  195. package/es-modules/Grid/Core/Table/ColumnResizing/ResizingMode.js +4 -3
  196. package/es-modules/Grid/Core/Table/Header/ColumnToolbar/ColumnToolbar.d.ts +5 -0
  197. package/es-modules/Grid/Core/Table/Header/ColumnToolbar/ColumnToolbar.js +7 -2
  198. package/es-modules/Grid/Core/Table/Header/ColumnToolbar/FilterPopup.js +1 -2
  199. package/es-modules/Grid/Core/Table/Header/ColumnToolbar/MenuButtons/FilterMenuButton.js +1 -2
  200. package/es-modules/Grid/Core/Table/Header/ColumnToolbar/MenuButtons/SortMenuButton.js +2 -3
  201. package/es-modules/Grid/Core/Table/Header/ColumnToolbar/ToolbarButtons/FilterToolbarButton.js +1 -2
  202. package/es-modules/Grid/Core/Table/Header/ColumnToolbar/ToolbarButtons/MenuToolbarButton.js +1 -2
  203. package/es-modules/Grid/Core/Table/Header/ColumnToolbar/ToolbarButtons/SortToolbarButton.d.ts +0 -1
  204. package/es-modules/Grid/Core/Table/Header/ColumnToolbar/ToolbarButtons/SortToolbarButton.js +4 -14
  205. package/es-modules/Grid/Core/Table/Header/HeaderCell.d.ts +6 -1
  206. package/es-modules/Grid/Core/Table/Header/HeaderCell.js +33 -13
  207. package/es-modules/Grid/Core/Table/Header/HeaderRow.js +4 -5
  208. package/es-modules/Grid/Core/Table/Header/TableHeader.d.ts +1 -1
  209. package/es-modules/Grid/Core/Table/Header/TableHeader.js +3 -3
  210. package/es-modules/Grid/Core/Table/Row.d.ts +1 -1
  211. package/es-modules/Grid/Core/Table/Row.js +2 -2
  212. package/es-modules/Grid/Core/Table/Table.d.ts +38 -12
  213. package/es-modules/Grid/Core/Table/Table.js +184 -91
  214. package/es-modules/Grid/Core/UI/ContextMenuButton.d.ts +6 -7
  215. package/es-modules/Grid/Core/UI/ContextMenuButton.js +5 -3
  216. package/es-modules/Grid/Core/UI/Popup.js +7 -9
  217. package/es-modules/Grid/Core/UI/SvgIcons.d.ts +42 -7
  218. package/es-modules/Grid/Core/UI/SvgIcons.js +206 -33
  219. package/es-modules/Grid/Core/UI/Toolbar.d.ts +5 -0
  220. package/es-modules/Grid/Core/UI/ToolbarButton.d.ts +4 -12
  221. package/es-modules/Grid/Core/UI/ToolbarButton.js +8 -26
  222. package/es-modules/Grid/Pro/CellEditing/CellEditMode.d.ts +2 -2
  223. package/es-modules/Grid/Pro/CellEditing/CellEditing.js +10 -10
  224. package/es-modules/Grid/Pro/CellEditing/CellEditingComposition.js +1 -2
  225. package/es-modules/Grid/Pro/CellRendering/CellRenderersComposition.d.ts +1 -1
  226. package/es-modules/Grid/Pro/CellRendering/CellRenderersComposition.js +4 -2
  227. package/es-modules/Grid/Pro/CellRendering/ContentTypes/CheckboxContent.d.ts +2 -2
  228. package/es-modules/Grid/Pro/CellRendering/ContentTypes/NumberInputContent.js +1 -2
  229. package/es-modules/Grid/Pro/CellRendering/ContentTypes/SelectContent.d.ts +2 -2
  230. package/es-modules/Grid/Pro/CellRendering/ContentTypes/SparklineContent.js +1 -2
  231. package/es-modules/Grid/Pro/CellRendering/ContentTypes/TextInputContent.d.ts +2 -2
  232. package/es-modules/Grid/Pro/CellRendering/ContentTypes/TextInputContent.js +1 -2
  233. package/es-modules/Grid/Pro/CellRendering/Renderers/CheckboxRenderer.js +1 -2
  234. package/es-modules/Grid/Pro/CellRendering/Renderers/DateInputRenderer.js +1 -2
  235. package/es-modules/Grid/Pro/CellRendering/Renderers/DateTimeInputRenderer.js +1 -2
  236. package/es-modules/Grid/Pro/CellRendering/Renderers/NumberInputRenderer.js +1 -2
  237. package/es-modules/Grid/Pro/CellRendering/Renderers/SelectRenderer.js +1 -2
  238. package/es-modules/Grid/Pro/CellRendering/Renderers/SparklineRenderer.d.ts +2 -2
  239. package/es-modules/Grid/Pro/CellRendering/Renderers/SparklineRenderer.js +1 -2
  240. package/es-modules/Grid/Pro/CellRendering/Renderers/TextInputRenderer.js +1 -2
  241. package/es-modules/Grid/Pro/CellRendering/Renderers/TextRenderer.js +1 -2
  242. package/es-modules/Grid/Pro/CellRendering/Renderers/TimeInputRenderer.js +1 -2
  243. package/es-modules/Grid/Pro/ColumnTypes/Validator.js +34 -32
  244. package/es-modules/Grid/Pro/ColumnTypes/ValidatorComposition.d.ts +1 -1
  245. package/es-modules/Grid/Pro/ColumnTypes/ValidatorComposition.js +3 -4
  246. package/es-modules/Grid/Pro/Credits/CreditsProComposition.d.ts +1 -1
  247. package/es-modules/Grid/Pro/Credits/CreditsProComposition.js +1 -3
  248. package/es-modules/Grid/Pro/Data/DataSourceHelper.d.ts +74 -0
  249. package/es-modules/Grid/Pro/Data/DataSourceHelper.js +256 -0
  250. package/es-modules/Grid/Pro/Data/QuerySerializer.d.ts +46 -0
  251. package/es-modules/Grid/Pro/Data/QuerySerializer.js +169 -0
  252. package/es-modules/Grid/Pro/Data/RemoteDataProvider.d.ts +187 -0
  253. package/es-modules/Grid/Pro/Data/RemoteDataProvider.js +500 -0
  254. package/es-modules/Grid/Pro/Export/Exporting.js +1 -2
  255. package/es-modules/Grid/Pro/Export/ExportingComposition.js +1 -2
  256. package/es-modules/Grid/Pro/GridEvents.js +1 -2
  257. package/es-modules/Grid/Pro/Pagination/PaginationComposition.d.ts +0 -1
  258. package/es-modules/Grid/Pro/Pagination/PaginationComposition.js +1 -2
  259. package/es-modules/Shared/BaseForm.js +1 -2
  260. package/es-modules/Shared/DownloadURL.js +1 -2
  261. package/es-modules/Shared/TimeBase.js +3 -3
  262. package/es-modules/Shared/Types.d.ts +7 -0
  263. package/es-modules/Shared/Utilities.d.ts +576 -0
  264. package/es-modules/Shared/Utilities.js +1360 -0
  265. package/es-modules/masters/grid-pro.src.d.ts +15 -11
  266. package/es-modules/masters/grid-pro.src.js +12 -5
  267. package/grid-pro.d.ts +15 -11
  268. package/grid-pro.js +3 -3
  269. package/grid-pro.js.map +1 -1
  270. package/grid-pro.src.d.ts +15 -11
  271. package/grid-pro.src.js +13854 -11395
  272. package/package.json +1 -1
  273. package/es-modules/Grid/Core/Pagination/Icons.d.ts +0 -7
  274. package/es-modules/Grid/Core/Pagination/Icons.js +0 -7
@@ -0,0 +1,1360 @@
1
+ /* *
2
+ *
3
+ * (c) 2009-2026 Highsoft AS
4
+ *
5
+ * A commercial license may be required depending on use.
6
+ * See www.highcharts.com/license
7
+ *
8
+ *
9
+ * */
10
+ import H from '../Core/Globals.js';
11
+ const { doc, win } = H;
12
+ /**
13
+ * Add an event listener.
14
+ *
15
+ * @function Highcharts.addEvent<T>
16
+ *
17
+ * @param {Highcharts.Class<T>|T} el
18
+ * The element or object to add a listener to. It can be a
19
+ * {@link HTMLDOMElement}, an {@link SVGElement} or any other object.
20
+ *
21
+ * @param {string} type
22
+ * The event type.
23
+ *
24
+ * @param {Highcharts.EventCallbackFunction<T>|Function} fn
25
+ * The function callback to execute when the event is fired.
26
+ *
27
+ * @param {Highcharts.EventOptionsObject} [options]
28
+ * Options for adding the event.
29
+ *
30
+ * @sample highcharts/members/addevent
31
+ * Use a general `render` event to draw shapes on a chart
32
+ *
33
+ * @return {Function}
34
+ * A callback function to remove the added event.
35
+ */
36
+ export function addEvent(el, type, fn, options = {}) {
37
+ // Add hcEvents to either the prototype (in case we're running addEvent on a
38
+ // class) or the instance. If hasOwnProperty('hcEvents') is false, it is
39
+ // inherited down the prototype chain, in which case we need to set the
40
+ // property on this instance (which may itself be a prototype).
41
+ const owner = typeof el === 'function' && el.prototype || el;
42
+ if (!Object.hasOwnProperty.call(owner, 'hcEvents')) {
43
+ owner.hcEvents = {};
44
+ }
45
+ const events = owner.hcEvents;
46
+ // Allow click events added to points, otherwise they will be prevented by
47
+ // the TouchPointer.pinch function after a pinch zoom operation (#7091).
48
+ if (H.Point && // Without H a dependency loop occurs
49
+ el instanceof H.Point &&
50
+ el.series &&
51
+ el.series.chart) {
52
+ el.series.chart.runTrackerClick = true;
53
+ }
54
+ // Handle DOM events
55
+ // If the browser supports passive events, add it to improve performance
56
+ // on touch events (#11353).
57
+ const addEventListener = el.addEventListener;
58
+ if (addEventListener) {
59
+ addEventListener.call(el, type, fn, H.supportsPassiveEvents ? {
60
+ passive: options.passive === void 0 ?
61
+ type.indexOf('touch') !== -1 : options.passive,
62
+ capture: false
63
+ } : false);
64
+ }
65
+ if (!events[type]) {
66
+ events[type] = [];
67
+ }
68
+ const eventObject = {
69
+ fn,
70
+ order: typeof options.order === 'number' ? options.order : Infinity
71
+ };
72
+ events[type].push(eventObject);
73
+ // Order the calls
74
+ events[type].sort((a, b) => a.order - b.order);
75
+ // Return a function that can be called to remove this event.
76
+ return function () {
77
+ removeEvent(el, type, fn);
78
+ };
79
+ }
80
+ /**
81
+ * Non-recursive method to find the lowest member of an array. `Math.min` raises
82
+ * a maximum call stack size exceeded error in Chrome when trying to apply more
83
+ * than 150.000 points. This method is slightly slower, but safe.
84
+ *
85
+ * @function Highcharts.arrayMin
86
+ *
87
+ * @param {Array<*>} data
88
+ * An array of numbers.
89
+ *
90
+ * @return {number}
91
+ * The lowest number.
92
+ */
93
+ export function arrayMin(data) {
94
+ let i = data.length, min = data[0];
95
+ while (i--) {
96
+ if (data[i] < min) {
97
+ min = data[i];
98
+ }
99
+ }
100
+ return min;
101
+ }
102
+ /**
103
+ * Non-recursive method to find the lowest member of an array. `Math.max` raises
104
+ * a maximum call stack size exceeded error in Chrome when trying to apply more
105
+ * than 150.000 points. This method is slightly slower, but safe.
106
+ *
107
+ * @function Highcharts.arrayMax
108
+ *
109
+ * @param {Array<*>} data
110
+ * An array of numbers.
111
+ *
112
+ * @return {number}
113
+ * The highest number.
114
+ */
115
+ export function arrayMax(data) {
116
+ let i = data.length, max = data[0];
117
+ while (i--) {
118
+ if (data[i] > max) {
119
+ max = data[i];
120
+ }
121
+ }
122
+ return max;
123
+ }
124
+ /**
125
+ * Set or get an attribute or an object of attributes.
126
+ *
127
+ * To use as a setter, pass a key and a value, or let the second argument be a
128
+ * collection of keys and values. When using a collection, passing a value of
129
+ * `null` or `undefined` will remove the attribute.
130
+ *
131
+ * To use as a getter, pass only a string as the second argument.
132
+ *
133
+ * @function Highcharts.attr
134
+ *
135
+ * @param {Highcharts.HTMLDOMElement|Highcharts.SVGDOMElement} elem
136
+ * The DOM element to receive the attribute(s).
137
+ *
138
+ * @param {string|Highcharts.HTMLAttributes|Highcharts.SVGAttributes} [keyOrAttribs]
139
+ * The property or an object of key-value pairs.
140
+ *
141
+ * @param {number|string} [value]
142
+ * The value if a single property is set.
143
+ *
144
+ * @return {string|null|undefined}
145
+ * When used as a getter, return the value.
146
+ */
147
+ export function attr(elem, keyOrAttribs, value) {
148
+ const isGetter = isString(keyOrAttribs) && !defined(value);
149
+ let ret;
150
+ const attrSingle = (value, key) => {
151
+ // Set the value
152
+ if (defined(value)) {
153
+ elem.setAttribute(key, value);
154
+ // Get the value
155
+ }
156
+ else if (isGetter) {
157
+ ret = elem.getAttribute(key);
158
+ // IE7 and below cannot get class through getAttribute (#7850)
159
+ if (!ret && key === 'class') {
160
+ ret = elem.getAttribute(key + 'Name');
161
+ }
162
+ // Remove the value
163
+ }
164
+ else {
165
+ elem.removeAttribute(key);
166
+ }
167
+ };
168
+ // If keyOrAttribs is a string
169
+ if (isString(keyOrAttribs)) {
170
+ attrSingle(value, keyOrAttribs);
171
+ // Else if keyOrAttribs is defined, it is a hash of key/value pairs
172
+ }
173
+ else {
174
+ objectEach(keyOrAttribs, attrSingle);
175
+ }
176
+ return ret;
177
+ }
178
+ /**
179
+ * Constrain a value to within a lower and upper threshold.
180
+ *
181
+ * @internal
182
+ * @param {number} value The initial value
183
+ * @param {number} min The lower threshold
184
+ * @param {number} max The upper threshold
185
+ * @return {number} Returns a number value within min and max.
186
+ */
187
+ export function clamp(value, min, max) {
188
+ return value > min ? value < max ? value : max : min;
189
+ }
190
+ /**
191
+ * Fix JS round off float errors.
192
+ *
193
+ * @function Highcharts.correctFloat
194
+ *
195
+ * @param {number} num
196
+ * A float number to fix.
197
+ *
198
+ * @param {number} [prec=14]
199
+ * The precision.
200
+ *
201
+ * @return {number}
202
+ * The corrected float number.
203
+ */
204
+ export function correctFloat(num, prec) {
205
+ // When the number is higher than 1e14 use the number (#16275)
206
+ return num > 1e14 ? num : parseFloat(num.toPrecision(prec || 14));
207
+ }
208
+ /**
209
+ * Utility function to create an HTML element with attributes and styles.
210
+ *
211
+ * @function Highcharts.createElement
212
+ *
213
+ * @param {string} tag
214
+ * The HTML tag.
215
+ *
216
+ * @param {Highcharts.HTMLAttributes} [attribs]
217
+ * Attributes as an object of key-value pairs.
218
+ *
219
+ * @param {Highcharts.CSSObject} [styles]
220
+ * Styles as an object of key-value pairs.
221
+ *
222
+ * @param {Highcharts.HTMLDOMElement} [parent]
223
+ * The parent HTML object.
224
+ *
225
+ * @param {boolean} [nopad=false]
226
+ * If true, remove all padding, border and margin.
227
+ *
228
+ * @return {Highcharts.HTMLDOMElement}
229
+ * The created DOM element.
230
+ */
231
+ export function createElement(tag, attribs, styles, parent, nopad) {
232
+ const el = doc.createElement(tag);
233
+ if (attribs) {
234
+ extend(el, attribs);
235
+ }
236
+ if (nopad) {
237
+ css(el, { padding: '0', border: 'none', margin: '0' });
238
+ }
239
+ if (styles) {
240
+ css(el, styles);
241
+ }
242
+ if (parent) {
243
+ parent.appendChild(el);
244
+ }
245
+ return el;
246
+ }
247
+ /**
248
+ * Utility for crisping a line position to the nearest full pixel depening on
249
+ * the line width
250
+ *
251
+ * @internal
252
+ * @param {number} value The raw pixel position
253
+ * @param {number} lineWidth The line width
254
+ * @param {boolean} [inverted] Whether the containing group is inverted.
255
+ * Crisping round numbers on the y-scale need to go
256
+ * to the other side because the coordinate system
257
+ * is flipped (scaleY is -1)
258
+ * @return {number} The pixel position to use for a crisp display
259
+ */
260
+ export function crisp(value, lineWidth = 0, inverted) {
261
+ const mod = lineWidth % 2 / 2, inverter = inverted ? -1 : 1;
262
+ return (Math.round(value * inverter - mod) + mod) * inverter;
263
+ }
264
+ /**
265
+ * Set CSS on a given element.
266
+ *
267
+ * @function Highcharts.css
268
+ *
269
+ * @param {Highcharts.HTMLDOMElement|Highcharts.SVGDOMElement} el
270
+ * An HTML DOM element.
271
+ *
272
+ * @param {Highcharts.CSSObject} styles
273
+ * Style object with camel case property names.
274
+ *
275
+ * @return {void}
276
+ */
277
+ export function css(el, styles) {
278
+ extend(el.style, styles);
279
+ }
280
+ /**
281
+ * Check if an object is null or undefined.
282
+ *
283
+ * @function Highcharts.defined
284
+ *
285
+ * @param {*} obj
286
+ * The object to check.
287
+ *
288
+ * @return {boolean}
289
+ * False if the object is null or undefined, otherwise true.
290
+ */
291
+ export function defined(obj) {
292
+ return typeof obj !== 'undefined' && obj !== null;
293
+ }
294
+ /**
295
+ * Utility method that destroys any SVGElement instances that are properties on
296
+ * the given object. It loops all properties and invokes destroy if there is a
297
+ * destroy method. The property is then delete.
298
+ *
299
+ * @function Highcharts.destroyObjectProperties
300
+ *
301
+ * @param {*} obj
302
+ * The object to destroy properties on.
303
+ *
304
+ * @param {*} [except]
305
+ * Exception, do not destroy this property, only delete it.
306
+ */
307
+ export function destroyObjectProperties(obj, except, destructablesOnly) {
308
+ objectEach(obj, function (val, n) {
309
+ // If the object is non-null and destroy is defined
310
+ if (val !== except && val?.destroy) {
311
+ // Invoke the destroy
312
+ val.destroy();
313
+ }
314
+ // Delete the property from the object
315
+ if (val?.destroy || !destructablesOnly) {
316
+ delete obj[n];
317
+ }
318
+ });
319
+ }
320
+ /**
321
+ * Discard a HTML element
322
+ *
323
+ * @function Highcharts.discardElement
324
+ *
325
+ * @param {Highcharts.HTMLDOMElement} element
326
+ * The HTML node to discard.
327
+ */
328
+ export function discardElement(element) {
329
+ element?.parentElement?.removeChild(element);
330
+ }
331
+ // eslint-disable-next-line valid-jsdoc
332
+ /**
333
+ * Return the deep difference between two objects. It can either return the new
334
+ * properties, or optionally return the old values of new properties.
335
+ * @internal
336
+ */
337
+ export function diffObjects(newer, older, keepOlder, collectionsWithUpdate) {
338
+ const ret = {};
339
+ /**
340
+ * Recurse over a set of options and its current values, and store the
341
+ * current values in the ret object.
342
+ */
343
+ function diff(newer, older, ret, depth) {
344
+ const keeper = keepOlder ? older : newer;
345
+ objectEach(newer, function (newerVal, key) {
346
+ if (!depth &&
347
+ collectionsWithUpdate &&
348
+ collectionsWithUpdate.indexOf(key) > -1 &&
349
+ older[key]) {
350
+ newerVal = splat(newerVal);
351
+ ret[key] = [];
352
+ // Iterate over collections like series, xAxis or yAxis and map
353
+ // the items by index.
354
+ for (let i = 0; i < Math.max(newerVal.length, older[key].length); i++) {
355
+ // Item exists in current data (#6347)
356
+ if (older[key][i]) {
357
+ // If the item is missing from the new data, we need to
358
+ // save the whole config structure. Like when
359
+ // responsively updating from a dual axis layout to a
360
+ // single axis and back (#13544).
361
+ if (newerVal[i] === void 0) {
362
+ ret[key][i] = older[key][i];
363
+ // Otherwise, proceed
364
+ }
365
+ else {
366
+ ret[key][i] = {};
367
+ diff(newerVal[i], older[key][i], ret[key][i], depth + 1);
368
+ }
369
+ }
370
+ }
371
+ }
372
+ else if (isObject(newerVal, true) &&
373
+ !newerVal.nodeType // #10044
374
+ ) {
375
+ ret[key] = isArray(newerVal) ? [] : {};
376
+ diff(newerVal, older[key] || {}, ret[key], depth + 1);
377
+ // Delete empty nested objects
378
+ if (Object.keys(ret[key]).length === 0 &&
379
+ // Except colorAxis which is a special case where the empty
380
+ // object means it is enabled. Which is unfortunate and we
381
+ // should try to find a better way.
382
+ !(key === 'colorAxis' && depth === 0)) {
383
+ delete ret[key];
384
+ }
385
+ }
386
+ else if (newer[key] !== older[key] ||
387
+ // If the newer key is explicitly undefined, keep it (#10525)
388
+ (key in newer && !(key in older))) {
389
+ if (key !== '__proto__' && key !== 'constructor') {
390
+ ret[key] = keeper[key];
391
+ }
392
+ }
393
+ });
394
+ }
395
+ diff(newer, older, ret, 0);
396
+ return ret;
397
+ }
398
+ /**
399
+ * Remove the last occurence of an item from an array.
400
+ *
401
+ * @function Highcharts.erase
402
+ *
403
+ * @param {Array<*>} arr
404
+ * The array.
405
+ *
406
+ * @param {*} item
407
+ * The item to remove.
408
+ *
409
+ * @return {void}
410
+ */
411
+ export function erase(arr, item) {
412
+ let i = arr.length;
413
+ while (i--) {
414
+ if (arr[i] === item) {
415
+ arr.splice(i, 1);
416
+ break;
417
+ }
418
+ }
419
+ }
420
+ /**
421
+ * Utility function to extend an object with the members of another.
422
+ *
423
+ * @function Highcharts.extend<T>
424
+ *
425
+ * @param {T|undefined} a
426
+ * The object to be extended.
427
+ *
428
+ * @param {Partial<T>} b
429
+ * The object to add to the first one.
430
+ *
431
+ * @return {T}
432
+ * Object a, the original object.
433
+ */
434
+ export function extend(a, b) {
435
+ let n;
436
+ if (!a) {
437
+ a = {};
438
+ }
439
+ for (n in b) { // eslint-disable-line guard-for-in
440
+ a[n] = b[n];
441
+ }
442
+ return a;
443
+ }
444
+ // eslint-disable-next-line valid-jsdoc
445
+ /**
446
+ * Extend a prototyped class by new members.
447
+ *
448
+ * @deprecated
449
+ * @function Highcharts.extendClass<T>
450
+ *
451
+ * @param {Highcharts.Class<T>} parent
452
+ * The parent prototype to inherit.
453
+ *
454
+ * @param {Highcharts.Dictionary<*>} members
455
+ * A collection of prototype members to add or override compared to the
456
+ * parent prototype.
457
+ *
458
+ * @return {Highcharts.Class<T>}
459
+ * A new prototype.
460
+ */
461
+ export function extendClass(parent, members) {
462
+ const obj = (function () { });
463
+ obj.prototype = new parent(); // eslint-disable-line new-cap
464
+ extend(obj.prototype, members);
465
+ return obj;
466
+ }
467
+ /**
468
+ * Fire an event that was registered with {@link Highcharts#addEvent}.
469
+ *
470
+ * @function Highcharts.fireEvent<T>
471
+ *
472
+ * @param {T} el
473
+ * The object to fire the event on. It can be a {@link HTMLDOMElement},
474
+ * an {@link SVGElement} or any other object.
475
+ *
476
+ * @param {string} type
477
+ * The type of event.
478
+ *
479
+ * @param {Highcharts.Dictionary<*>|Event} [eventArguments]
480
+ * Custom event arguments that are passed on as an argument to the event
481
+ * handler.
482
+ *
483
+ * @param {Highcharts.EventCallbackFunction<T>|Function} [defaultFunction]
484
+ * The default function to execute if the other listeners haven't
485
+ * returned false.
486
+ *
487
+ * @return {void}
488
+ */
489
+ export function fireEvent(el, type, eventArguments, defaultFunction) {
490
+ eventArguments = eventArguments || {};
491
+ if (doc?.createEvent &&
492
+ (el.dispatchEvent ||
493
+ (el.fireEvent &&
494
+ // Enable firing events on Highcharts instance.
495
+ el !== H))) {
496
+ const e = doc.createEvent('Events');
497
+ e.initEvent(type, true, true);
498
+ eventArguments = extend(e, eventArguments);
499
+ if (el.dispatchEvent) {
500
+ el.dispatchEvent(eventArguments);
501
+ }
502
+ else {
503
+ el.fireEvent(type, eventArguments);
504
+ }
505
+ }
506
+ else if (el.hcEvents) {
507
+ if (!eventArguments.target) {
508
+ // We're running a custom event
509
+ extend(eventArguments, {
510
+ // Attach a simple preventDefault function to skip
511
+ // default handler if called. The built-in
512
+ // defaultPrevented property is not overwritable (#5112)
513
+ preventDefault: function () {
514
+ eventArguments.defaultPrevented = true;
515
+ },
516
+ // Setting target to native events fails with clicking
517
+ // the zoom-out button in Chrome.
518
+ target: el,
519
+ // If the type is not set, we're running a custom event
520
+ // (#2297). If it is set, we're running a browser event.
521
+ type: type
522
+ });
523
+ }
524
+ const events = [];
525
+ let object = el;
526
+ let multilevel = false;
527
+ // Recurse up the inheritance chain and collect hcEvents set as own
528
+ // objects on the prototypes.
529
+ while (object.hcEvents) {
530
+ if (Object.hasOwnProperty.call(object, 'hcEvents') &&
531
+ object.hcEvents[type]) {
532
+ if (events.length) {
533
+ multilevel = true;
534
+ }
535
+ events.unshift.apply(events, object.hcEvents[type]);
536
+ }
537
+ object = Object.getPrototypeOf(object);
538
+ }
539
+ // For performance reasons, only sort the event handlers in case we are
540
+ // dealing with multiple levels in the prototype chain. Otherwise, the
541
+ // events are already sorted in the addEvent function.
542
+ if (multilevel) {
543
+ // Order the calls
544
+ events.sort((a, b) => a.order - b.order);
545
+ }
546
+ // Call the collected event handlers
547
+ events.forEach((obj) => {
548
+ // If the event handler returns false, prevent the default handler
549
+ // from executing
550
+ if (obj.fn.call(el, eventArguments, el) === false) {
551
+ eventArguments.preventDefault();
552
+ }
553
+ });
554
+ }
555
+ // Run the default if not prevented
556
+ if (defaultFunction && !eventArguments.defaultPrevented) {
557
+ defaultFunction.call(el, eventArguments);
558
+ }
559
+ }
560
+ /**
561
+ * Convenience function to get the align factor, used several places for
562
+ * computing positions
563
+ * @internal
564
+ */
565
+ export const getAlignFactor = (align = '') => ({
566
+ center: 0.5,
567
+ right: 1,
568
+ middle: 0.5,
569
+ bottom: 1
570
+ }[align] || 0);
571
+ /**
572
+ * Find the closest distance between two values of a two-dimensional array
573
+ * @internal
574
+ * @function Highcharts.getClosestDistance
575
+ *
576
+ * @param {Array<Array<number>>} arrays
577
+ * An array of arrays of numbers
578
+ *
579
+ * @return {number | undefined}
580
+ * The closest distance between values
581
+ */
582
+ export function getClosestDistance(arrays, onError) {
583
+ const allowNegative = !onError;
584
+ let closest, loopLength, distance, i;
585
+ arrays.forEach((xData) => {
586
+ if (xData.length > 1) {
587
+ loopLength = xData.length - 1;
588
+ for (i = loopLength; i > 0; i--) {
589
+ distance = xData[i] - xData[i - 1];
590
+ if (distance < 0 && !allowNegative) {
591
+ onError?.();
592
+ // Only one call
593
+ onError = void 0;
594
+ }
595
+ else if (distance && (typeof closest === 'undefined' || distance < closest)) {
596
+ closest = distance;
597
+ }
598
+ }
599
+ }
600
+ });
601
+ return closest;
602
+ }
603
+ /**
604
+ * Get the magnitude of a number.
605
+ *
606
+ * @function Highcharts.getMagnitude
607
+ *
608
+ * @param {number} num
609
+ * The number.
610
+ *
611
+ * @return {number}
612
+ * The magnitude, where 1-9 are magnitude 1, 10-99 magnitude 2 etc.
613
+ */
614
+ export function getMagnitude(num) {
615
+ return Math.pow(10, Math.floor(Math.log(num) / Math.LN10));
616
+ }
617
+ /**
618
+ * Returns the value of a property path on a given object.
619
+ *
620
+ * @internal
621
+ * @function getNestedProperty
622
+ *
623
+ * @param {string} path
624
+ * Path to the property, for example `custom.myValue`.
625
+ *
626
+ * @param {unknown} parent
627
+ * Instance containing the property on the specific path.
628
+ *
629
+ * @return {unknown}
630
+ * The unknown property value.
631
+ */
632
+ export function getNestedProperty(path, parent) {
633
+ const pathElements = path.split('.');
634
+ while (pathElements.length && defined(parent)) {
635
+ const pathElement = pathElements.shift();
636
+ // Filter on the key
637
+ if (typeof pathElement === 'undefined' ||
638
+ pathElement === '__proto__') {
639
+ return; // Undefined
640
+ }
641
+ if (pathElement === 'this') {
642
+ let thisProp;
643
+ if (isObject(parent)) {
644
+ thisProp = parent['@this'];
645
+ }
646
+ return thisProp ?? parent;
647
+ }
648
+ const child = parent[pathElement.replace(/[\\'"]/g, '')];
649
+ // Filter on the child
650
+ if (!defined(child) ||
651
+ typeof child === 'function' ||
652
+ typeof child.nodeType === 'number' ||
653
+ child === win) {
654
+ return; // Undefined
655
+ }
656
+ // Else, proceed
657
+ parent = child;
658
+ }
659
+ return parent;
660
+ }
661
+ /**
662
+ * Get the computed CSS value for given element and property, only for numerical
663
+ * properties. For width and height, the dimension of the inner box (excluding
664
+ * padding) is returned. Used for fitting the chart within the container.
665
+ *
666
+ * @function Highcharts.getStyle
667
+ *
668
+ * @param {Highcharts.HTMLDOMElement} el
669
+ * An HTML element.
670
+ *
671
+ * @param {string} prop
672
+ * The property name.
673
+ *
674
+ * @param {boolean} [toInt=true]
675
+ * Parse to integer.
676
+ *
677
+ * @return {number|string|undefined}
678
+ * The style value.
679
+ */
680
+ export function getStyle(el, prop, toInt) {
681
+ let style;
682
+ // For width and height, return the actual inner pixel size (#4913)
683
+ if (prop === 'width') {
684
+ let offsetWidth = Math.min(el.offsetWidth, el.scrollWidth);
685
+ // In flex boxes, we need to use getBoundingClientRect and floor it,
686
+ // because scrollWidth doesn't support subpixel precision (#6427) ...
687
+ const boundingClientRectWidth = el.getBoundingClientRect?.().width;
688
+ // ...unless if the containing div or its parents are transform-scaled
689
+ // down, in which case the boundingClientRect can't be used as it is
690
+ // also scaled down (#9871, #10498).
691
+ if (boundingClientRectWidth < offsetWidth &&
692
+ boundingClientRectWidth >= offsetWidth - 1) {
693
+ offsetWidth = Math.floor(boundingClientRectWidth);
694
+ }
695
+ return Math.max(0, // #8377
696
+ (offsetWidth -
697
+ (getStyle(el, 'padding-left', true) || 0) -
698
+ (getStyle(el, 'padding-right', true) || 0)));
699
+ }
700
+ if (prop === 'height') {
701
+ return Math.max(0, // #8377
702
+ (Math.min(el.offsetHeight, el.scrollHeight) -
703
+ (getStyle(el, 'padding-top', true) || 0) -
704
+ (getStyle(el, 'padding-bottom', true) || 0)));
705
+ }
706
+ // Otherwise, get the computed style
707
+ const css = win.getComputedStyle(el, void 0); // eslint-disable-line no-undefined
708
+ if (css) {
709
+ style = css.getPropertyValue(prop);
710
+ if (pick(toInt, prop !== 'opacity')) {
711
+ style = pInt(style);
712
+ }
713
+ }
714
+ return style;
715
+ }
716
+ /**
717
+ * Return the value of the first element in the array that satisfies the
718
+ * provided testing function.
719
+ *
720
+ * @function Highcharts.find<T>
721
+ *
722
+ * @param {Array<T>} arr
723
+ * The array to test.
724
+ *
725
+ * @param {Function} callback
726
+ * The callback function. The function receives the item as the first
727
+ * argument. Return `true` if this item satisfies the condition.
728
+ *
729
+ * @return {T|undefined}
730
+ * The value of the element.
731
+ */
732
+ export const find = Array.prototype.find ?
733
+ function (arr, callback) {
734
+ return arr.find(callback);
735
+ } :
736
+ // Legacy implementation. PhantomJS, IE <= 11 etc. #7223.
737
+ function (arr, callback) {
738
+ let i;
739
+ const length = arr.length;
740
+ for (i = 0; i < length; i++) {
741
+ if (callback(arr[i], i)) { // eslint-disable-line node/callback-return
742
+ return arr[i];
743
+ }
744
+ }
745
+ };
746
+ /**
747
+ * Internal clear timeout. The function checks that the `id` was not removed
748
+ * (e.g. by `chart.destroy()`). For the details see
749
+ * [issue #7901](https://github.com/highcharts/highcharts/issues/7901).
750
+ *
751
+ * @internal
752
+ *
753
+ * @function Highcharts.clearTimeout
754
+ *
755
+ * @param {number|undefined} id
756
+ * Id of a timeout.
757
+ */
758
+ export function internalClearTimeout(id) {
759
+ if (defined(id)) {
760
+ clearTimeout(id);
761
+ }
762
+ }
763
+ /**
764
+ * Utility function to check if an Object is a HTML Element.
765
+ *
766
+ * @function Highcharts.isDOMElement
767
+ *
768
+ * @param {*} obj
769
+ * The item to check.
770
+ *
771
+ * @return {boolean}
772
+ * True if the argument is a HTML Element.
773
+ */
774
+ export function isDOMElement(obj) {
775
+ return isObject(obj) && typeof obj.nodeType === 'number';
776
+ }
777
+ /**
778
+ * Utility function to check if an Object is a class.
779
+ *
780
+ * @function Highcharts.isClass
781
+ *
782
+ * @param {object|undefined} obj
783
+ * The item to check.
784
+ *
785
+ * @return {boolean}
786
+ * True if the argument is a class.
787
+ */
788
+ export function isClass(obj) {
789
+ const c = obj?.constructor;
790
+ return !!(isObject(obj, true) &&
791
+ !isDOMElement(obj) &&
792
+ (c?.name && c.name !== 'Object'));
793
+ }
794
+ /**
795
+ * Utility function to check if an item is a number and it is finite (not NaN,
796
+ * Infinity or -Infinity).
797
+ *
798
+ * @function Highcharts.isNumber
799
+ *
800
+ * @param {*} n
801
+ * The item to check.
802
+ *
803
+ * @return {boolean}
804
+ * True if the item is a finite number
805
+ */
806
+ export function isNumber(n) {
807
+ return typeof n === 'number' && !isNaN(n) && n < Infinity && n > -Infinity;
808
+ }
809
+ /**
810
+ * Utility function to check for string type.
811
+ *
812
+ * @function Highcharts.isString
813
+ *
814
+ * @param {*} s
815
+ * The item to check.
816
+ *
817
+ * @return {boolean}
818
+ * True if the argument is a string.
819
+ */
820
+ export function isString(s) {
821
+ return typeof s === 'string';
822
+ }
823
+ /**
824
+ * Utility function to check if an item is an array.
825
+ *
826
+ * @function Highcharts.isArray
827
+ *
828
+ * @param {*} obj
829
+ * The item to check.
830
+ *
831
+ * @return {boolean}
832
+ * True if the argument is an array.
833
+ */
834
+ export function isArray(obj) {
835
+ const str = Object.prototype.toString.call(obj);
836
+ return str === '[object Array]' || str === '[object Array Iterator]';
837
+ }
838
+ /**
839
+ * Utility function to check if object is a function.
840
+ *
841
+ * @function Highcharts.isFunction
842
+ *
843
+ * @param {*} obj
844
+ * The item to check.
845
+ *
846
+ * @return {boolean}
847
+ * True if the argument is a function.
848
+ */
849
+ export function isFunction(obj) {
850
+ return typeof obj === 'function';
851
+ }
852
+ /**
853
+ * Utility function to check if an item is of type object.
854
+ *
855
+ * @function Highcharts.isObject
856
+ *
857
+ * @param {*} obj
858
+ * The item to check.
859
+ *
860
+ * @param {boolean} [strict=false]
861
+ * Also checks that the object is not an array.
862
+ *
863
+ * @return {boolean}
864
+ * True if the argument is an object.
865
+ */
866
+ export function isObject(obj, strict) {
867
+ return (!!obj &&
868
+ typeof obj === 'object' &&
869
+ (!strict || !isArray(obj))); // eslint-disable-line @typescript-eslint/no-explicit-any
870
+ }
871
+ /**
872
+ * Utility function to deep merge two or more objects and return a third object.
873
+ * If the first argument is true, the contents of the second object is copied
874
+ * into the first object. The merge function can also be used with a single
875
+ * object argument to create a deep copy of an object.
876
+ *
877
+ * @function Highcharts.merge<T>
878
+ *
879
+ * @param {true | T} extendOrSource
880
+ * Whether to extend the left-side object,
881
+ * or the first object to merge as a deep copy.
882
+ *
883
+ * @param {...Array<object|undefined>} [sources]
884
+ * Object(s) to merge into the previous one.
885
+ *
886
+ * @return {T}
887
+ * The merged object. If the first argument is true, the return is the
888
+ * same as the second argument.
889
+ */
890
+ export function merge(extendOrSource, ...sources) {
891
+ let i, args = [extendOrSource, ...sources], ret = {};
892
+ const doCopy = function (copy, original) {
893
+ // An object is replacing a primitive
894
+ if (typeof copy !== 'object') {
895
+ copy = {};
896
+ }
897
+ objectEach(original, function (value, key) {
898
+ // Prototype pollution (#14883)
899
+ if (key === '__proto__' || key === 'constructor') {
900
+ return;
901
+ }
902
+ // Copy the contents of objects, but not arrays or DOM nodes
903
+ if (isObject(value, true) &&
904
+ !isClass(value) &&
905
+ !isDOMElement(value)) {
906
+ copy[key] = doCopy(copy[key] || {}, value);
907
+ // Primitives and arrays are copied over directly
908
+ }
909
+ else {
910
+ copy[key] = original[key];
911
+ }
912
+ });
913
+ return copy;
914
+ };
915
+ // If first argument is true, copy into the existing object. Used in
916
+ // setOptions.
917
+ if (extendOrSource === true) {
918
+ ret = args[1];
919
+ args = Array.prototype.slice.call(args, 2);
920
+ }
921
+ // For each argument, extend the return
922
+ const len = args.length;
923
+ for (i = 0; i < len; i++) {
924
+ ret = doCopy(ret, args[i]);
925
+ }
926
+ return ret;
927
+ }
928
+ /**
929
+ * Take an interval and normalize it to multiples of round numbers.
930
+ *
931
+ * @deprecated
932
+ * @function Highcharts.normalizeTickInterval
933
+ *
934
+ * @param {number} interval
935
+ * The raw, un-rounded interval.
936
+ *
937
+ * @param {Array<*>} [multiples]
938
+ * Allowed multiples.
939
+ *
940
+ * @param {number} [magnitude]
941
+ * The magnitude of the number.
942
+ *
943
+ * @param {boolean} [allowDecimals]
944
+ * Whether to allow decimals.
945
+ *
946
+ * @param {boolean} [hasTickAmount]
947
+ * If it has tickAmount, avoid landing on tick intervals lower than
948
+ * original.
949
+ *
950
+ * @return {number}
951
+ * The normalized interval.
952
+ *
953
+ * @todo
954
+ * Move this function to the Axis prototype. It is here only for historical
955
+ * reasons.
956
+ */
957
+ export function normalizeTickInterval(interval, multiples, magnitude, allowDecimals, hasTickAmount) {
958
+ let i, retInterval = interval;
959
+ // Round to a tenfold of 1, 2, 2.5 or 5
960
+ magnitude = pick(magnitude, getMagnitude(interval));
961
+ const normalized = interval / magnitude;
962
+ // Multiples for a linear scale
963
+ if (!multiples) {
964
+ multiples = hasTickAmount ?
965
+ // Finer grained ticks when the tick amount is hard set, including
966
+ // when alignTicks is true on multiple axes (#4580).
967
+ [1, 1.2, 1.5, 2, 2.5, 3, 4, 5, 6, 8, 10] :
968
+ // Else, let ticks fall on rounder numbers
969
+ [1, 2, 2.5, 5, 10];
970
+ // The allowDecimals option
971
+ if (allowDecimals === false) {
972
+ if (magnitude === 1) {
973
+ multiples = multiples.filter(function (num) {
974
+ return num % 1 === 0;
975
+ });
976
+ }
977
+ else if (magnitude <= 0.1) {
978
+ multiples = [1 / magnitude];
979
+ }
980
+ }
981
+ }
982
+ // Normalize the interval to the nearest multiple
983
+ for (i = 0; i < multiples.length; i++) {
984
+ retInterval = multiples[i];
985
+ // Only allow tick amounts smaller than natural
986
+ if ((hasTickAmount &&
987
+ retInterval * magnitude >= interval) ||
988
+ (!hasTickAmount &&
989
+ (normalized <=
990
+ (multiples[i] +
991
+ (multiples[i + 1] || multiples[i])) / 2))) {
992
+ break;
993
+ }
994
+ }
995
+ // Multiply back to the correct magnitude. Correct floats to appropriate
996
+ // precision (#6085).
997
+ retInterval = correctFloat(retInterval * magnitude, -Math.round(Math.log(0.001) / Math.LN10));
998
+ return retInterval;
999
+ }
1000
+ /**
1001
+ * Iterate over object key pairs in an object.
1002
+ *
1003
+ * @function Highcharts.objectEach<T>
1004
+ *
1005
+ * @param {*} obj
1006
+ * The object to iterate over.
1007
+ *
1008
+ * @param {Highcharts.ObjectEachCallbackFunction<T>} fn
1009
+ * The iterator callback. It passes three arguments:
1010
+ * * value - The property value.
1011
+ * * key - The property key.
1012
+ * * obj - The object that objectEach is being applied to.
1013
+ *
1014
+ * @param {T} [ctx]
1015
+ * The context.
1016
+ */
1017
+ export function objectEach(obj, fn, ctx) {
1018
+ for (const key in obj) {
1019
+ if (Object.hasOwnProperty.call(obj, key)) {
1020
+ fn.call(ctx || obj[key], obj[key], key, obj);
1021
+ }
1022
+ }
1023
+ }
1024
+ /**
1025
+ * Get the element's offset position, corrected for `overflow: auto`.
1026
+ *
1027
+ * @function Highcharts.offset
1028
+ *
1029
+ * @param {global.Element} el
1030
+ * The DOM element.
1031
+ *
1032
+ * @return {Highcharts.OffsetObject}
1033
+ * An object containing `left` and `top` properties for the position in
1034
+ * the page.
1035
+ */
1036
+ export function offset(el) {
1037
+ const docElem = doc.documentElement, box = (el.parentElement || el.parentNode) ?
1038
+ el.getBoundingClientRect() :
1039
+ { top: 0, left: 0, width: 0, height: 0 };
1040
+ return {
1041
+ top: box.top + (win.pageYOffset || docElem.scrollTop) -
1042
+ (docElem.clientTop || 0),
1043
+ left: box.left + (win.pageXOffset || docElem.scrollLeft) -
1044
+ (docElem.clientLeft || 0),
1045
+ width: box.width,
1046
+ height: box.height
1047
+ };
1048
+ }
1049
+ /**
1050
+ * Left-pad a string to a given length by adding a character repetitively.
1051
+ *
1052
+ * @function Highcharts.pad
1053
+ *
1054
+ * @param {number} number
1055
+ * The input string or number.
1056
+ *
1057
+ * @param {number} [length]
1058
+ * The desired string length.
1059
+ *
1060
+ * @param {string} [padder=0]
1061
+ * The character to pad with.
1062
+ *
1063
+ * @return {string}
1064
+ * The padded string.
1065
+ */
1066
+ export function pad(number, length, padder) {
1067
+ return new Array((length || 2) +
1068
+ 1 -
1069
+ String(number)
1070
+ .replace('-', '')
1071
+ .length).join(padder || '0') + number;
1072
+ }
1073
+ /* eslint-disable jsdoc/check-param-names */
1074
+ /**
1075
+ * Return the first value that is not null or undefined.
1076
+ *
1077
+ * @function Highcharts.pick<T>
1078
+ *
1079
+ * @param {...Array<T|null|undefined>} items
1080
+ * Variable number of arguments to inspect.
1081
+ *
1082
+ * @return {T}
1083
+ * The value of the first argument that is not null or undefined.
1084
+ */
1085
+ export function pick() {
1086
+ const args = arguments;
1087
+ const length = args.length;
1088
+ for (let i = 0; i < length; i++) {
1089
+ const arg = args[i];
1090
+ if (typeof arg !== 'undefined' && arg !== null) {
1091
+ return arg;
1092
+ }
1093
+ }
1094
+ }
1095
+ /* eslint-enable jsdoc/check-param-names */
1096
+ /**
1097
+ * Shortcut for parseInt
1098
+ *
1099
+ * @internal
1100
+ * @function Highcharts.pInt
1101
+ *
1102
+ * @param {*} s
1103
+ * any
1104
+ *
1105
+ * @param {number} [mag]
1106
+ * Magnitude
1107
+ *
1108
+ * @return {number}
1109
+ * number
1110
+ */
1111
+ export function pInt(s, mag) {
1112
+ return parseInt(s, mag || 10);
1113
+ }
1114
+ /**
1115
+ * Adds an item to an array, if it is not present in the array.
1116
+ *
1117
+ * @internal
1118
+ *
1119
+ * @function Highcharts.pushUnique
1120
+ *
1121
+ * @param {Array<unknown>} array
1122
+ * The array to add the item to.
1123
+ *
1124
+ * @param {unknown} item
1125
+ * The item to add.
1126
+ *
1127
+ * @return {boolean}
1128
+ * Returns true, if the item was not present and has been added.
1129
+ */
1130
+ export function pushUnique(array, item) {
1131
+ return array.indexOf(item) < 0 && !!array.push(item);
1132
+ }
1133
+ /**
1134
+ * Return a length based on either the integer value, or a percentage of a base.
1135
+ *
1136
+ * @function Highcharts.relativeLength
1137
+ *
1138
+ * @param {Highcharts.RelativeSize} value
1139
+ * A percentage string or a number.
1140
+ *
1141
+ * @param {number} base
1142
+ * The full length that represents 100%.
1143
+ *
1144
+ * @param {number} [offset=0]
1145
+ * A pixel offset to apply for percentage values. Used internally in
1146
+ * axis positioning.
1147
+ *
1148
+ * @return {number}
1149
+ * The computed length.
1150
+ */
1151
+ export function relativeLength(value, base, offset) {
1152
+ return (/%$/).test(value) ?
1153
+ (base * parseFloat(value) / 100) + (offset || 0) :
1154
+ parseFloat(value);
1155
+ }
1156
+ /**
1157
+ * Replaces text in a string with a given replacement in a loop to catch nested
1158
+ * matches after previous replacements.
1159
+ *
1160
+ * @internal
1161
+ *
1162
+ * @function Highcharts.replaceNested
1163
+ *
1164
+ * @param {string} text
1165
+ * Text to search and modify.
1166
+ *
1167
+ * @param {...Array<(RegExp|string)>} replacements
1168
+ * One or multiple tuples with search pattern (`[0]: (string|RegExp)`) and
1169
+ * replacement (`[1]: string`) for matching text.
1170
+ *
1171
+ * @return {string}
1172
+ * Text with replacements.
1173
+ */
1174
+ export function replaceNested(text, ...replacements) {
1175
+ let previous, replacement;
1176
+ do {
1177
+ previous = text;
1178
+ for (replacement of replacements) {
1179
+ text = text.replace(replacement[0], replacement[1]);
1180
+ }
1181
+ } while (text !== previous);
1182
+ return text;
1183
+ }
1184
+ /**
1185
+ * Remove an event that was added with {@link Highcharts#addEvent}.
1186
+ *
1187
+ * @function Highcharts.removeEvent<T>
1188
+ *
1189
+ * @param {Highcharts.Class<T>|T} el
1190
+ * The element to remove events on.
1191
+ *
1192
+ * @param {string} [type]
1193
+ * The type of events to remove. If undefined, all events are removed
1194
+ * from the element.
1195
+ *
1196
+ * @param {Highcharts.EventCallbackFunction<T>} [fn]
1197
+ * The specific callback to remove. If undefined, all events that match
1198
+ * the element and optionally the type are removed.
1199
+ *
1200
+ * @return {void}
1201
+ */
1202
+ export function removeEvent(el, type, fn) {
1203
+ /** @internal */
1204
+ function removeOneEvent(type, fn) {
1205
+ const removeEventListener = el.removeEventListener;
1206
+ if (removeEventListener) {
1207
+ removeEventListener.call(el, type, fn, false);
1208
+ }
1209
+ }
1210
+ /** @internal */
1211
+ function removeAllEvents(eventCollection) {
1212
+ let types, len;
1213
+ if (!el.nodeName) {
1214
+ return; // Break on non-DOM events
1215
+ }
1216
+ if (type) {
1217
+ types = {};
1218
+ types[type] = true;
1219
+ }
1220
+ else {
1221
+ types = eventCollection;
1222
+ }
1223
+ objectEach(types, function (_val, n) {
1224
+ if (eventCollection[n]) {
1225
+ len = eventCollection[n].length;
1226
+ while (len--) {
1227
+ removeOneEvent(n, eventCollection[n][len].fn);
1228
+ }
1229
+ }
1230
+ });
1231
+ }
1232
+ const owner = typeof el === 'function' && el.prototype || el;
1233
+ if (Object.hasOwnProperty.call(owner, 'hcEvents')) {
1234
+ const events = owner.hcEvents;
1235
+ if (type) {
1236
+ const typeEvents = (events[type] || []);
1237
+ if (fn) {
1238
+ events[type] = typeEvents.filter(function (obj) {
1239
+ return fn !== obj.fn;
1240
+ });
1241
+ removeOneEvent(type, fn);
1242
+ }
1243
+ else {
1244
+ removeAllEvents(events);
1245
+ events[type] = [];
1246
+ }
1247
+ }
1248
+ else {
1249
+ removeAllEvents(events);
1250
+ delete owner.hcEvents;
1251
+ }
1252
+ }
1253
+ }
1254
+ /**
1255
+ * Check if an element is an array, and if not, make it into an array.
1256
+ *
1257
+ * @function Highcharts.splat
1258
+ *
1259
+ * @param {*} obj
1260
+ * The object to splat.
1261
+ *
1262
+ * @return {Array}
1263
+ * The produced or original array.
1264
+ */
1265
+ export function splat(obj) {
1266
+ return isArray(obj) ? obj : [obj];
1267
+ }
1268
+ /**
1269
+ * Sort an object array and keep the order of equal items. The ECMAScript
1270
+ * standard does not specify the behaviour when items are equal.
1271
+ *
1272
+ * @function Highcharts.stableSort
1273
+ *
1274
+ * @param {Array<*>} arr
1275
+ * The array to sort.
1276
+ *
1277
+ * @param {Function} sortFunction
1278
+ * The function to sort it with, like with regular Array.prototype.sort.
1279
+ */
1280
+ export function stableSort(arr, sortFunction) {
1281
+ // @todo It seems like Chrome since v70 sorts in a stable way internally,
1282
+ // plus all other browsers do it, so over time we may be able to remove this
1283
+ // function
1284
+ const length = arr.length;
1285
+ let sortValue, i;
1286
+ // Add index to each item
1287
+ for (i = 0; i < length; i++) {
1288
+ arr[i].safeI = i; // Stable sort index
1289
+ }
1290
+ arr.sort(function (a, b) {
1291
+ sortValue = sortFunction(a, b);
1292
+ return sortValue === 0 ? a.safeI - b.safeI : sortValue;
1293
+ });
1294
+ // Remove index from items
1295
+ for (i = 0; i < length; i++) {
1296
+ delete arr[i].safeI; // Stable sort index
1297
+ }
1298
+ }
1299
+ /**
1300
+ * Set a timeout if the delay is given, otherwise perform the function
1301
+ * synchronously.
1302
+ *
1303
+ * @function Highcharts.syncTimeout
1304
+ *
1305
+ * @param {Function} fn
1306
+ * The function callback.
1307
+ *
1308
+ * @param {number} delay
1309
+ * Delay in milliseconds.
1310
+ *
1311
+ * @param {*} [context]
1312
+ * An optional context to send to the function callback.
1313
+ *
1314
+ * @return {number}
1315
+ * An identifier for the timeout that can later be cleared with
1316
+ * Highcharts.clearTimeout. Returns -1 if there is no timeout.
1317
+ */
1318
+ export function syncTimeout(fn, delay, context) {
1319
+ if (delay > 0) {
1320
+ return setTimeout(fn, delay, context);
1321
+ }
1322
+ fn.call(0, context);
1323
+ return -1;
1324
+ }
1325
+ /**
1326
+ * @internal
1327
+ */
1328
+ export function ucfirst(s) {
1329
+ return ((isString(s) ?
1330
+ s.substring(0, 1).toUpperCase() + s.substring(1) :
1331
+ String(s)));
1332
+ }
1333
+ /**
1334
+ * Wrap a method with extended functionality, preserving the original function.
1335
+ *
1336
+ * @function Highcharts.wrap
1337
+ *
1338
+ * @param {*} obj
1339
+ * The context object that the method belongs to. In real cases, this is
1340
+ * often a prototype.
1341
+ *
1342
+ * @param {string} method
1343
+ * The name of the method to extend.
1344
+ *
1345
+ * @param {Highcharts.WrapProceedFunction} func
1346
+ * A wrapper function callback. This function is called with the same
1347
+ * arguments as the original function, except that the original function
1348
+ * is unshifted and passed as the first argument.
1349
+ */
1350
+ export function wrap(obj, method, func) {
1351
+ const proceed = obj[method];
1352
+ obj[method] = function () {
1353
+ const outerArgs = arguments, scope = this;
1354
+ return func.apply(this, [
1355
+ function () {
1356
+ return proceed.apply(scope, arguments.length ? arguments : outerArgs);
1357
+ }
1358
+ ].concat([].slice.call(arguments)));
1359
+ };
1360
+ }