@overdoser/react-toolkit 0.20.0 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (273) hide show
  1. package/AGENTS.md +1 -1
  2. package/CHANGELOG.md +14 -0
  3. package/components/Accordion/Accordion.js +160 -177
  4. package/components/Accordion/Accordion.module.js +20 -0
  5. package/components/ActionButton/ActionButton.js +155 -209
  6. package/components/ActionButton/ActionButton.module.js +25 -0
  7. package/components/ActionButton/CopyButton.js +52 -64
  8. package/components/Alert/Alert.js +92 -95
  9. package/components/Alert/Alert.module.js +18 -0
  10. package/components/Avatar/Avatar.js +44 -55
  11. package/components/Avatar/Avatar.module.js +23 -0
  12. package/components/Badge/Badge.js +16 -38
  13. package/components/Badge/Badge.module.js +17 -0
  14. package/components/Breadcrumbs/Breadcrumbs.d.ts +1 -1
  15. package/components/Breadcrumbs/Breadcrumbs.js +52 -48
  16. package/components/Breadcrumbs/Breadcrumbs.module.js +10 -0
  17. package/components/Button/Button.js +35 -57
  18. package/components/Button/Button.module.js +25 -0
  19. package/components/Card/Card.js +94 -131
  20. package/components/Card/Card.module.js +35 -0
  21. package/components/Chart/AreaChart.d.ts +1 -1
  22. package/components/Chart/AreaChart.js +248 -249
  23. package/components/Chart/Axis.d.ts +2 -2
  24. package/components/Chart/Axis.js +34 -43
  25. package/components/Chart/BarChart.d.ts +1 -1
  26. package/components/Chart/BarChart.js +307 -348
  27. package/components/Chart/Chart.module.js +32 -0
  28. package/components/Chart/ChartContainer.js +33 -41
  29. package/components/Chart/ChartLegend.d.ts +1 -1
  30. package/components/Chart/ChartLegend.js +31 -30
  31. package/components/Chart/ChartTooltip.d.ts +1 -1
  32. package/components/Chart/ChartTooltip.js +46 -41
  33. package/components/Chart/LineChart.d.ts +1 -1
  34. package/components/Chart/LineChart.js +220 -232
  35. package/components/Chart/PieChart.d.ts +1 -1
  36. package/components/Chart/PieChart.js +224 -240
  37. package/components/Chart/RadarChart.d.ts +1 -1
  38. package/components/Chart/RadarChart.js +166 -215
  39. package/components/Chart/Sparkline.js +73 -68
  40. package/components/Chart/TradingChart.d.ts +1 -1
  41. package/components/Chart/TradingChart.js +804 -701
  42. package/components/Chart/scales.js +28 -35
  43. package/components/Chart/trading/indicators.js +61 -62
  44. package/components/Chart/trading/period.js +46 -68
  45. package/components/Chart/useChartDimensions.js +30 -22
  46. package/components/Chip/Chip.js +98 -141
  47. package/components/Chip/Chip.module.js +32 -0
  48. package/components/CodeBlock/CodeBlock.js +111 -119
  49. package/components/CodeBlock/CodeBlock.module.js +23 -0
  50. package/components/CommandPalette/CommandPalette.js +387 -392
  51. package/components/CommandPalette/CommandPalette.module.js +28 -0
  52. package/components/ConfirmDialog/ConfirmDialog.d.ts +1 -1
  53. package/components/ConfirmDialog/ConfirmDialog.js +184 -199
  54. package/components/ConfirmDialog/ConfirmDialog.module.js +12 -0
  55. package/components/Divider/Divider.js +25 -36
  56. package/components/Divider/Divider.module.js +17 -0
  57. package/components/Draggable/Draggable.d.ts +1 -1
  58. package/components/Draggable/Draggable.js +157 -164
  59. package/components/Draggable/Draggable.module.js +10 -0
  60. package/components/Drawer/Drawer.js +104 -126
  61. package/components/Drawer/Drawer.module.js +66 -0
  62. package/components/Dropdown/Dropdown.js +175 -234
  63. package/components/Dropdown/Dropdown.module.js +29 -0
  64. package/components/Dropdown/DropdownItem.js +55 -58
  65. package/components/Dropdown/DropdownLabel.js +14 -11
  66. package/components/Dropdown/DropdownSeparator.js +12 -10
  67. package/components/Dropdown/dropdownContext.js +4 -5
  68. package/components/Dropdown/useContextMenu.js +27 -17
  69. package/components/Dropzone/Dropzone.js +99 -105
  70. package/components/Dropzone/Dropzone.module.js +12 -0
  71. package/components/EmptyState/EmptyState.js +58 -55
  72. package/components/EmptyState/EmptyState.module.js +14 -0
  73. package/components/Form/Form.d.ts +1 -1
  74. package/components/Form/Form.js +32 -35
  75. package/components/Form/Form.module.js +16 -0
  76. package/components/Form/FormField.d.ts +1 -1
  77. package/components/Form/FormField.js +71 -75
  78. package/components/Form/FormRow.d.ts +1 -1
  79. package/components/Form/FormRow.js +11 -8
  80. package/components/Form/formFieldDefaults.js +4 -5
  81. package/components/ImageViewer/ImageViewer.js +312 -201
  82. package/components/ImageViewer/ImageViewer.module.js +26 -0
  83. package/components/ImageViewer/useZoomPan.js +206 -137
  84. package/components/Kbd/Kbd.js +25 -22
  85. package/components/Kbd/Kbd.module.js +10 -0
  86. package/components/KeyValueList/KeyValueList.js +119 -123
  87. package/components/KeyValueList/KeyValueList.module.js +23 -0
  88. package/components/Link/Link.js +45 -59
  89. package/components/Link/Link.module.js +10 -0
  90. package/components/List/List.js +22 -46
  91. package/components/List/List.module.js +12 -0
  92. package/components/Loader/Loader.js +152 -182
  93. package/components/Loader/Loader.module.js +40 -0
  94. package/components/Modal/Modal.js +93 -105
  95. package/components/Modal/Modal.module.js +18 -0
  96. package/components/PageHeader/PageHeader.js +78 -72
  97. package/components/PageHeader/PageHeader.module.js +23 -0
  98. package/components/Pagination/Pagination.js +63 -84
  99. package/components/Pagination/Pagination.module.js +13 -0
  100. package/components/Pagination/paginationRange.js +15 -22
  101. package/components/Popover/Popover.js +110 -134
  102. package/components/Popover/Popover.module.js +12 -0
  103. package/components/ProgressBar/ProgressBar.d.ts +15 -1
  104. package/components/ProgressBar/ProgressBar.js +57 -90
  105. package/components/ProgressBar/ProgressBar.module.js +29 -0
  106. package/components/RelativeTime/RelativeTime.js +36 -43
  107. package/components/RelativeTime/RelativeTime.module.js +3 -0
  108. package/components/SegmentedControl/SegmentedControl.js +94 -130
  109. package/components/SegmentedControl/SegmentedControl.module.js +21 -0
  110. package/components/Skeleton/Skeleton.js +36 -50
  111. package/components/Skeleton/Skeleton.module.js +15 -0
  112. package/components/Spinner/Spinner.js +25 -25
  113. package/components/Spinner/Spinner.module.js +12 -0
  114. package/components/SplitButton/SplitButton.js +149 -196
  115. package/components/SplitButton/SplitButton.module.js +31 -0
  116. package/components/SplitPane/SplitPane.js +134 -170
  117. package/components/SplitPane/SplitPane.module.js +14 -0
  118. package/components/StatCard/StatCard.js +132 -125
  119. package/components/StatCard/StatCard.module.js +42 -0
  120. package/components/StatusDot/StatusDot.js +28 -39
  121. package/components/StatusDot/StatusDot.module.js +18 -0
  122. package/components/Table/Table.d.ts +1 -1
  123. package/components/Table/Table.js +381 -451
  124. package/components/Table/Table.module.js +42 -0
  125. package/components/Table/useTableSort.js +51 -42
  126. package/components/Tabs/Tabs.js +109 -161
  127. package/components/Tabs/Tabs.module.js +28 -0
  128. package/components/ThemeToggle/ThemeToggle.js +122 -98
  129. package/components/ThemeToggle/ThemeToggle.module.js +13 -0
  130. package/components/Timeline/GanttTimeline.js +357 -318
  131. package/components/Timeline/GanttTimeline.module.js +29 -0
  132. package/components/Timeline/HistoryTimeline.js +486 -450
  133. package/components/Timeline/HistoryTimeline.module.js +31 -0
  134. package/components/Timeline/Timeline.module.js +76 -0
  135. package/components/Timeline/TimelineShared.d.ts +7 -7
  136. package/components/Timeline/TimelineShared.js +288 -279
  137. package/components/Timeline/TraceEventDetails.d.ts +3 -3
  138. package/components/Timeline/TraceEventDetails.js +245 -178
  139. package/components/Timeline/TraceTimeline.js +823 -783
  140. package/components/Timeline/TraceTimeline.module.js +98 -0
  141. package/components/Timeline/historyLayout.js +336 -263
  142. package/components/Timeline/timelineCore.js +208 -183
  143. package/components/Timeline/traceEvent.js +59 -61
  144. package/components/Timeline/traceLayout.js +101 -90
  145. package/components/Timeline/useTimeline.js +76 -79
  146. package/components/Timer/Timer.js +190 -156
  147. package/components/Timer/Timer.module.js +29 -0
  148. package/components/Toast/Toast.d.ts +1 -1
  149. package/components/Toast/Toast.js +128 -128
  150. package/components/Toast/Toast.module.js +37 -0
  151. package/components/Toast/toastStore.js +58 -62
  152. package/components/ToggleIconButton/ToggleIconButton.js +35 -57
  153. package/components/ToggleIconButton/ToggleIconButton.module.js +15 -0
  154. package/components/Tooltip/Tooltip.d.ts +1 -1
  155. package/components/Tooltip/Tooltip.js +76 -85
  156. package/components/Tooltip/Tooltip.module.js +17 -0
  157. package/components/Typography/Typography.js +11 -36
  158. package/components/Typography/Typography.module.js +30 -0
  159. package/components/inputs/Checkbox/Checkbox.js +27 -51
  160. package/components/inputs/Checkbox/Checkbox.module.js +10 -0
  161. package/components/inputs/Checkbox/CheckboxGroup.js +53 -111
  162. package/components/inputs/Checkbox/CheckboxGroup.module.js +17 -0
  163. package/components/inputs/DatePicker/CalendarPanel.d.ts +1 -1
  164. package/components/inputs/DatePicker/CalendarPanel.js +263 -286
  165. package/components/inputs/DatePicker/CalendarPanel.module.js +23 -0
  166. package/components/inputs/DatePicker/DatePicker.js +115 -142
  167. package/components/inputs/DatePicker/DatePicker.module.js +14 -0
  168. package/components/inputs/DatePicker/dateUtils.js +32 -41
  169. package/components/inputs/DateTimePicker/DateTimePicker.js +226 -232
  170. package/components/inputs/DateTimePicker/DateTimePicker.module.js +20 -0
  171. package/components/inputs/DateTimePicker/DateTimeSegments.js +273 -252
  172. package/components/inputs/DateTimePicker/TimeField.d.ts +1 -1
  173. package/components/inputs/DateTimePicker/TimeField.js +131 -132
  174. package/components/inputs/DateTimePicker/timeZoneUtils.js +95 -92
  175. package/components/inputs/Input/Input.js +98 -109
  176. package/components/inputs/Input/Input.module.js +15 -0
  177. package/components/inputs/NumberInput/NumberInput.js +112 -132
  178. package/components/inputs/NumberInput/NumberInput.module.js +14 -0
  179. package/components/inputs/Radio/Radio.js +50 -73
  180. package/components/inputs/Radio/Radio.module.js +9 -0
  181. package/components/inputs/SearchInput/SearchInput.js +98 -115
  182. package/components/inputs/SearchInput/SearchInput.module.js +8 -0
  183. package/components/inputs/Select/Select.js +555 -682
  184. package/components/inputs/Select/Select.module.js +38 -0
  185. package/components/inputs/Slider/Slider.js +97 -128
  186. package/components/inputs/Slider/Slider.module.js +9 -0
  187. package/components/inputs/Switch/Switch.js +11 -8
  188. package/components/inputs/Textarea/Textarea.js +42 -58
  189. package/components/inputs/Textarea/Textarea.module.js +14 -0
  190. package/hooks/useClickOutside.js +17 -14
  191. package/hooks/useDebouncedValue.js +13 -14
  192. package/hooks/useElementSize.js +27 -22
  193. package/hooks/useEscapeLayer.js +28 -29
  194. package/hooks/useFocusTrap.js +27 -38
  195. package/hooks/useKeyboard.js +76 -64
  196. package/hooks/useMediaQuery.js +10 -15
  197. package/hooks/useNow.js +28 -33
  198. package/hooks/usePersistedState.js +98 -94
  199. package/hooks/usePortalPosition.js +25 -19
  200. package/hooks/useResizable.js +106 -104
  201. package/hooks/useTheme.js +28 -23
  202. package/index.css +2 -1
  203. package/index.js +97 -215
  204. package/index.layered.css +2 -3
  205. package/llms.txt +3 -0
  206. package/manifest.json +8 -0
  207. package/package.json +1 -1
  208. package/utils/formatBytes.js +29 -13
  209. package/utils/themeScript.js +6 -8
  210. package/utils/timeAgo.js +59 -32
  211. package/components/Accordion/Accordion.module.scss.js +0 -36
  212. package/components/ActionButton/ActionButton.module.scss.js +0 -47
  213. package/components/Alert/Alert.module.scss.js +0 -33
  214. package/components/Avatar/Avatar.module.scss.js +0 -43
  215. package/components/Badge/Badge.module.scss.js +0 -31
  216. package/components/Breadcrumbs/Breadcrumbs.module.scss.js +0 -17
  217. package/components/Button/Button.module.scss.js +0 -47
  218. package/components/Card/Card.module.scss.js +0 -60
  219. package/components/Chart/Chart.module.scss.js +0 -61
  220. package/components/Chip/Chip.module.scss.js +0 -59
  221. package/components/CodeBlock/CodeBlock.module.scss.js +0 -43
  222. package/components/CommandPalette/CommandPalette.module.scss.js +0 -49
  223. package/components/ConfirmDialog/ConfirmDialog.module.scss.js +0 -21
  224. package/components/Divider/Divider.module.scss.js +0 -31
  225. package/components/Draggable/Draggable.module.scss.js +0 -17
  226. package/components/Drawer/Drawer.module.scss.js +0 -119
  227. package/components/Dropdown/Dropdown.module.scss.js +0 -53
  228. package/components/Dropzone/Dropzone.module.scss.js +0 -21
  229. package/components/EmptyState/EmptyState.module.scss.js +0 -25
  230. package/components/Form/Form.module.scss.js +0 -29
  231. package/components/ImageViewer/ImageViewer.module.scss.js +0 -47
  232. package/components/Kbd/Kbd.module.scss.js +0 -17
  233. package/components/KeyValueList/KeyValueList.module.scss.js +0 -43
  234. package/components/Link/Link.module.scss.js +0 -16
  235. package/components/List/List.module.scss.js +0 -21
  236. package/components/Loader/Loader.module.scss.js +0 -70
  237. package/components/Modal/Modal.module.scss.js +0 -33
  238. package/components/PageHeader/PageHeader.module.scss.js +0 -43
  239. package/components/Pagination/Pagination.module.scss.js +0 -23
  240. package/components/Popover/Popover.module.scss.js +0 -21
  241. package/components/ProgressBar/ProgressBar.module.scss.js +0 -51
  242. package/components/RelativeTime/RelativeTime.module.scss.js +0 -7
  243. package/components/SegmentedControl/SegmentedControl.module.scss.js +0 -39
  244. package/components/Skeleton/Skeleton.module.scss.js +0 -25
  245. package/components/Spinner/Spinner.module.scss.js +0 -20
  246. package/components/SplitButton/SplitButton.module.scss.js +0 -57
  247. package/components/SplitPane/SplitPane.module.scss.js +0 -25
  248. package/components/StatCard/StatCard.module.scss.js +0 -72
  249. package/components/StatusDot/StatusDot.module.scss.js +0 -32
  250. package/components/Table/Table.module.scss.js +0 -81
  251. package/components/Tabs/Tabs.module.scss.js +0 -53
  252. package/components/ThemeToggle/ThemeToggle.module.scss.js +0 -23
  253. package/components/Timeline/GanttTimeline.module.scss.js +0 -55
  254. package/components/Timeline/HistoryTimeline.module.scss.js +0 -59
  255. package/components/Timeline/Timeline.module.scss.js +0 -141
  256. package/components/Timeline/TraceTimeline.module.scss.js +0 -189
  257. package/components/Timer/Timer.module.scss.js +0 -55
  258. package/components/Toast/Toast.module.scss.js +0 -62
  259. package/components/ToggleIconButton/ToggleIconButton.module.scss.js +0 -27
  260. package/components/Tooltip/Tooltip.module.scss.js +0 -30
  261. package/components/Typography/Typography.module.scss.js +0 -53
  262. package/components/inputs/Checkbox/Checkbox.module.scss.js +0 -17
  263. package/components/inputs/Checkbox/CheckboxGroup.module.scss.js +0 -31
  264. package/components/inputs/DatePicker/CalendarPanel.module.scss.js +0 -41
  265. package/components/inputs/DatePicker/DatePicker.module.scss.js +0 -25
  266. package/components/inputs/DateTimePicker/DateTimePicker.module.scss.js +0 -37
  267. package/components/inputs/Input/Input.module.scss.js +0 -27
  268. package/components/inputs/NumberInput/NumberInput.module.scss.js +0 -25
  269. package/components/inputs/Radio/Radio.module.scss.js +0 -15
  270. package/components/inputs/SearchInput/SearchInput.module.scss.js +0 -13
  271. package/components/inputs/Select/Select.module.scss.js +0 -73
  272. package/components/inputs/Slider/Slider.module.scss.js +0 -15
  273. package/components/inputs/Textarea/Textarea.module.scss.js +0 -25
@@ -1,733 +1,836 @@
1
- import { jsxs as et, jsx as x } from "react/jsx-runtime";
2
- import { useRef as U, useState as kt, useCallback as X, useMemo as Qt, useLayoutEffect as te, useEffect as ee } from "react";
3
- import ne from "clsx";
4
- import { niceTicks as Dt } from "./scales.js";
5
- import { rsi as oe, sma as re, ema as ie, bollinger as le } from "./trading/indicators.js";
6
- import { periodToSeconds as se } from "./trading/period.js";
7
- import gt from "./Chart.module.scss.js";
8
- import { Popover as ae } from "../Popover/Popover.js";
9
- import { Button as ce } from "../Button/Button.js";
10
- import { Dropdown as fe } from "../Dropdown/Dropdown.js";
11
- const he = 420, vt = 64, wt = 28, ue = 40, pe = 4, Ct = { rsi: 0.18, volume: 0.14 }, de = 1, me = 40, Lt = 0.1, ge = 500, Me = [];
12
- function Ge({
13
- datafeed: t,
14
- symbol: n,
15
- resolution: e,
16
- period: o,
17
- seriesType: r = "candle",
18
- indicators: l = Me,
19
- precision: i = 2,
20
- initialLookback: s = ge,
21
- height: c = he,
22
- upColor: g = "var(--crk-color-success)",
23
- downColor: u = "var(--crk-color-danger)",
24
- lineColor: f = "var(--crk-chart-1)",
25
- timezone: d,
26
- defaultTimezone: M = "local",
27
- onTimezoneChange: k,
28
- showConfigPanel: L = !0,
29
- priceBadgeColorByDirection: W = !1,
30
- priceBadgeShowTime: P = !1,
31
- priceBadgeTimeFormat: j,
32
- onCrosshair: N,
33
- onVisibleRangeChange: Y,
34
- className: _,
35
- style: J
36
- }) {
37
- const Z = U(null), G = U(null), I = U([]), y = U({ from: 0, to: 0 }), F = U(null), V = U(null), z = U(!1), K = U(0), ht = U(null), ut = U(null), yt = U(1), pt = U({ width: 0, height: 0 }), dt = U(() => {
38
- }), bt = U(N), lt = U(Y);
39
- bt.current = N, lt.current = Y;
40
- const [st, Ut] = kt(null), [_t, xt] = kt(M), mt = d ?? _t, Ft = X(
41
- (p) => {
42
- d === void 0 && xt(p), k?.(p);
43
- },
44
- [d, k]
45
- ), Rt = Qt(
46
- () => ({ up: g, down: u, line: f }),
47
- [g, u, f]
48
- ), q = l, nt = q.some((p) => p.type === "rsi"), ot = q.some((p) => p.type === "volume"), Nt = X(() => {
49
- const p = G.current;
50
- if (!p) return;
51
- const a = p.getContext("2d");
52
- if (!a) return;
53
- const { width: S, height: b } = pt.current;
54
- if (S === 0 || b === 0) return;
55
- const R = yt.current;
56
- a.save(), a.setTransform(1, 0, 0, 1, 0, 0), a.clearRect(0, 0, p.width, p.height), a.scale(R, R);
57
- const m = Se(Z.current, Rt), $ = It(Z.current), A = I.current;
58
- if (A.length === 0) {
59
- Ae(a, S, b, m), a.restore();
60
- return;
61
- }
62
- const h = Mt(S, b, nt, ot), { from: T, to: v } = ye(y.current, A.length);
63
- y.current = { from: T, to: v };
64
- const C = A.slice(Math.max(0, Math.floor(T)), Math.min(A.length, Math.ceil(v) + 1)), H = (w) => {
65
- const it = v - T + 1, tt = h.plotWidth / it;
66
- return h.plotLeft + (w - T + 0.5) * tt;
67
- }, rt = h.plotWidth / (v - T + 1), Q = q.map((w) => be(w, A)).filter((w) => w !== null).map((w) => ({ ...w, color: $(w.color) })), E = Pt(h.main, C, Q, T, v);
68
- Tt(a, h.plotLeft, h.plotRight, E, m), ke(a, h, E, i, m), a.save(), a.beginPath(), a.rect(h.plotLeft, E.paneTop, h.plotWidth, E.paneHeight), a.clip();
69
- for (let w = 0; w < q.length; w++) {
70
- const it = q[w], tt = Q[w];
71
- tt && $e(a, tt, it, A, T, v, H, E);
72
- }
73
- if (r === "candle" ? Ce(a, A, T, v, H, rt, E, { up: m.up, down: m.down }) : r === "bar" ? Le(a, A, T, v, H, rt, E, { up: m.up, down: m.down }) : We(a, A, T, v, H, E, m.line, r === "area"), a.restore(), h.volume) {
74
- const w = Re(h.volume, A, T, v);
75
- Tt(a, h.plotLeft, h.plotRight, w, m, !0), Wt(a, h, h.volume, "Volume", m), a.save(), a.beginPath(), a.rect(h.plotLeft, w.paneTop, h.plotWidth, w.paneHeight), a.clip(), He(a, A, T, v, H, rt, w, { up: m.up, down: m.down }), a.restore();
76
- }
77
- if (h.rsi) {
78
- const w = q.find((qt) => qt.type === "rsi"), it = w && w.type === "rsi" ? w.period ?? 14 : 14, tt = w && w.type === "rsi" ? w.overbought ?? 70 : 70, At = w && w.type === "rsi" ? w.oversold ?? 30 : 30, Kt = (w && w.type === "rsi" ? w.color : void 0) ?? "var(--crk-chart-5)", jt = $(Kt), Jt = oe(A, it), ct = {
79
- paneTop: h.rsi.top,
80
- paneBottom: h.rsi.bottom,
81
- paneHeight: h.rsi.height,
82
- priceMin: 0,
83
- priceMax: 100,
84
- ticks: [At, 50, tt]
85
- };
86
- Tt(a, h.plotLeft, h.plotRight, ct, m, !0), Wt(a, h, h.rsi, `RSI ${it}`, m), a.save(), a.beginPath(), a.rect(h.plotLeft, ct.paneTop, h.plotWidth, ct.paneHeight), a.clip(), ft(a, Jt, T, v, H, ct, jt), a.restore(), Be(a, h, ct, tt, At, m);
87
- }
88
- De(a, h, A, T, v, e, m), F.current && Pe(
89
- a,
90
- h,
91
- F.current,
92
- A,
93
- T,
94
- v,
95
- H,
96
- i,
97
- E,
98
- mt,
99
- m,
100
- e,
101
- W,
102
- P,
103
- j
104
- ), a.restore();
105
- }, [r, q, nt, ot, i, Rt, e, mt, W, P, j]);
106
- dt.current = Nt;
107
- const O = X(() => {
108
- if (ut.current === null) {
109
- if (typeof requestAnimationFrame > "u") {
110
- dt.current();
111
- return;
112
- }
113
- ut.current = requestAnimationFrame(() => {
114
- ut.current = null, dt.current();
115
- });
116
- }
117
- }, []);
118
- te(() => {
119
- const p = Z.current;
120
- if (!p) return;
121
- const a = () => {
122
- const b = p.getBoundingClientRect(), R = typeof window < "u" && window.devicePixelRatio || 1;
123
- yt.current = R, pt.current = { width: b.width, height: b.height };
124
- const m = G.current;
125
- m && (m.width = Math.round(b.width * R), m.height = Math.round(b.height * R), m.style.width = `${b.width}px`, m.style.height = `${b.height}px`), O();
126
- };
127
- if (a(), typeof ResizeObserver > "u") return;
128
- const S = new ResizeObserver(a);
129
- return S.observe(p), () => S.disconnect();
130
- }, [O]), ee(() => {
131
- let p = !1;
132
- const a = Math.floor(Date.now() / 1e3), S = Bt(e), b = o === "MAX", R = o !== void 0 ? se(o) : S * s, m = o !== void 0 ? Math.max(10, Math.ceil(R / S)) : s, $ = b ? 0 : a - R;
133
- I.current = [], y.current = { from: 0, to: 0 }, K.current += 1, z.current = !1, O(), t.getBars({ symbol: n, resolution: e, from: $, to: a, countBack: m }).then((h) => {
134
- if (p) return;
135
- const T = [...h].sort((C, H) => C.time - H.time);
136
- I.current = T;
137
- const v = T.length - 1;
138
- if (o !== void 0)
139
- y.current = { from: 0, to: v };
140
- else {
141
- const C = Math.min(T.length, Math.min(200, s));
142
- y.current = {
143
- from: Math.max(0, v - C + 1),
144
- to: v
145
- };
146
- }
147
- lt.current?.(y.current, T), O();
148
- }).catch(() => {
149
- });
150
- const A = t.subscribeBars({
151
- symbol: n,
152
- resolution: e,
153
- onTick: (h) => {
154
- if (p) return;
155
- const T = I.current, v = T[T.length - 1];
156
- if (v && v.time === h.time)
157
- T[T.length - 1] = h;
158
- else if (!v || h.time > v.time) {
159
- T.push(h);
160
- const C = y.current;
161
- C.to >= T.length - 2 && (y.current = { from: C.from + 1, to: C.to + 1 });
162
- }
163
- O();
164
- }
165
- });
166
- return ht.current = A, () => {
167
- p = !0, ht.current !== null && (t.unsubscribeBars(ht.current), ht.current = null);
168
- };
169
- }, [t, n, e, o, s]);
170
- const at = X((p) => {
171
- Ut(p), bt.current?.(p);
172
- }, []), Xt = X((p) => {
173
- p.currentTarget.setPointerCapture(p.pointerId);
174
- const a = y.current;
175
- V.current = { startX: p.clientX, from: a.from, to: a.to };
176
- }, []), St = X(() => {
177
- if (z.current) return;
178
- const p = I.current;
179
- if (p.length === 0) return;
180
- z.current = !0;
181
- const a = K.current, S = Bt(e), b = p[0].time, R = b - S * s, m = b - S;
182
- t.getBars({ symbol: n, resolution: e, from: R, to: m, countBack: s }).then(($) => {
183
- if (a !== K.current) return;
184
- if ($.length === 0) {
185
- z.current = !1;
186
- return;
187
- }
188
- const h = [...$].sort((v, C) => v.time - C.time).filter((v) => v.time < b), T = y.current;
189
- I.current = [...h, ...I.current], y.current = { from: T.from + h.length, to: T.to + h.length }, z.current = !1, O();
190
- }).catch(() => {
191
- a === K.current && (z.current = !1);
192
- });
193
- }, [t, n, e, s, O]), Yt = X(
194
- (p) => {
195
- const a = p.currentTarget.getBoundingClientRect(), S = p.clientX - a.left, b = p.clientY - a.top;
196
- if (F.current = { x: S, y: b }, V.current) {
197
- const { startX: $, from: A, to: h } = V.current, { width: T } = pt.current, v = Math.max(1, T - vt), C = h - A + 1, H = v / C, rt = -(p.clientX - $) / H;
198
- let Q = A + rt, E = h + rt;
199
- const w = I.current.length;
200
- Q < 0 && (St(), Q = 0, E = C - 1), E > w - 1 && (E = w - 1, Q = E - C + 1), y.current = { from: Q, to: E }, lt.current?.(y.current, I.current);
201
- }
202
- const R = Mt(a.width, a.height, nt, ot), m = y.current;
203
- if (S >= R.plotLeft && S <= R.plotRight) {
204
- const $ = m.to - m.from + 1, A = R.plotWidth / $, h = Math.round(m.from + (S - R.plotLeft) / A - 0.5), T = I.current, v = Math.max(0, Math.min(T.length - 1, h)), C = T[v] ?? null, H = Ie(b, R, T, m.from, m.to);
205
- at({ barIndex: v, bar: C, priceAtCursor: H });
206
- } else
207
- at(null);
208
- O();
209
- },
210
- [nt, ot, St, O, at]
211
- ), Vt = X((p) => {
212
- p.currentTarget.releasePointerCapture(p.pointerId), V.current = null;
213
- }, []), zt = X(() => {
214
- F.current = null, V.current = null, at(null), O();
215
- }, [O, at]), Zt = X(
216
- (p) => {
217
- p.preventDefault();
218
- const a = p.currentTarget.getBoundingClientRect(), S = p.clientX - a.left, b = Mt(a.width, a.height, nt, ot), R = y.current, m = I.current;
219
- if (m.length === 0) return;
220
- const $ = R.to - R.from + 1, A = p.deltaY > 0 ? 1 + Lt : 1 / (1 + Lt), h = Math.max(
221
- b.plotWidth / me,
222
- Math.min(m.length, b.plotWidth / de, $ * A)
223
- ), T = R.from + (S - b.plotLeft) / (b.plotWidth / $), v = (T - R.from) / $;
224
- let C = T - v * h, H = C + h - 1;
225
- C < 0 && (C = 0, H = h - 1), H > m.length - 1 && (H = m.length - 1, C = H - h + 1), y.current = { from: C, to: H }, lt.current?.(y.current, m), O();
226
- },
227
- [nt, ot, O]
228
- ), Gt = X(
229
- (p) => {
230
- const a = y.current, S = a.to - a.from + 1, b = I.current;
231
- if (b.length === 0) return;
232
- let R = 0;
233
- if (p.key === "ArrowLeft") R = -Math.max(1, Math.floor(S * 0.1));
234
- else if (p.key === "ArrowRight") R = Math.max(1, Math.floor(S * 0.1));
235
- else return;
236
- p.preventDefault();
237
- let m = a.from + R, $ = a.to + R;
238
- m < 0 && (m = 0, $ = S - 1), $ > b.length - 1 && ($ = b.length - 1, m = $ - S + 1), y.current = { from: m, to: $ }, lt.current?.(y.current, b), O();
239
- },
240
- [O]
241
- );
242
- return /* @__PURE__ */ et(
243
- "div",
244
- {
245
- ref: Z,
246
- className: ne(gt.root, _),
247
- style: { ...J, height: c, position: "relative" },
248
- tabIndex: 0,
249
- role: "figure",
250
- "aria-label": `${n} ${e} chart`,
251
- onKeyDown: Gt,
252
- children: [
253
- /* @__PURE__ */ x(
254
- "canvas",
255
- {
256
- ref: G,
257
- className: gt.svg,
258
- onPointerDown: Xt,
259
- onPointerMove: Yt,
260
- onPointerUp: Vt,
261
- onPointerLeave: zt,
262
- onWheel: Zt,
263
- style: { cursor: V.current ? "grabbing" : "crosshair", touchAction: "none" }
264
- }
265
- ),
266
- /* @__PURE__ */ et(
267
- "div",
268
- {
269
- className: gt.tradingHeader,
270
- style: {
271
- position: "absolute",
272
- top: pe,
273
- left: 8,
274
- right: 8,
275
- pointerEvents: "none",
276
- display: "flex",
277
- alignItems: "center",
278
- justifyContent: "space-between",
279
- gap: 8
280
- },
281
- children: [
282
- /* @__PURE__ */ et("div", { style: { display: "flex", alignItems: "center", gap: 8, minWidth: 0 }, children: [
283
- /* @__PURE__ */ x("strong", { children: n }),
284
- /* @__PURE__ */ x("span", { style: { color: "var(--crk-color-text-muted)" }, children: e }),
285
- st?.bar && /* @__PURE__ */ et("span", { style: { color: "var(--crk-color-text-muted)", whiteSpace: "nowrap" }, children: [
286
- "O ",
287
- st.bar.open.toFixed(i),
288
- " · H ",
289
- st.bar.high.toFixed(i),
290
- " · L",
291
- " ",
292
- st.bar.low.toFixed(i),
293
- " · C ",
294
- st.bar.close.toFixed(i)
295
- ] })
296
- ] }),
297
- L && /* @__PURE__ */ x("div", { style: { pointerEvents: "auto" }, children: /* @__PURE__ */ x(
298
- ae,
299
- {
300
- position: "bottom",
301
- asChild: !0,
302
- trigger: /* @__PURE__ */ x(
303
- ce,
304
- {
305
- variant: "ghost",
306
- size: "sm",
307
- iconOnly: !0,
308
- "aria-label": "Chart settings",
309
- children: /* @__PURE__ */ x(we, {})
310
- }
311
- ),
312
- content: /* @__PURE__ */ x(
313
- ve,
314
- {
315
- timezone: mt,
316
- onTimezoneChange: Ft
317
- }
318
- )
319
- }
320
- ) })
321
- ]
322
- }
323
- )
324
- ]
325
- }
326
- );
1
+ import { Button as e } from "../Button/Button.js";
2
+ import { Dropdown as t } from "../Dropdown/Dropdown.js";
3
+ import { Popover as n } from "../Popover/Popover.js";
4
+ import { niceTicks as r } from "./scales.js";
5
+ import { bollinger as i, ema as a, rsi as o, sma as s } from "./trading/indicators.js";
6
+ import { periodToSeconds as c } from "./trading/period.js";
7
+ import l from "./Chart.module.js";
8
+ import { useCallback as u, useEffect as d, useLayoutEffect as f, useMemo as p, useRef as m, useState as h } from "react";
9
+ import g from "clsx";
10
+ import { jsx as _, jsxs as v } from "react/jsx-runtime";
11
+ // src/components/Chart/TradingChart.tsx
12
+ var y = 420, b = 64, x = 28, S = 40, ee = 4, C = {
13
+ rsi: .18,
14
+ volume: .14
15
+ }, te = 1, ne = 40, re = 500, ie = [];
16
+ function ae({ datafeed: t, symbol: r, resolution: i, period: a, seriesType: s = "candle", indicators: x = ie, precision: S = 2, initialLookback: C = re, height: ae = y, upColor: w = "var(--crk-color-success)", downColor: E = "var(--crk-color-danger)", lineColor: O = "var(--crk-chart-1)", timezone: k, defaultTimezone: A = "local", onTimezoneChange: j, showConfigPanel: M = !0, priceBadgeColorByDirection: N = !1, priceBadgeShowTime: P = !1, priceBadgeTimeFormat: De, onCrosshair: Oe, onVisibleRangeChange: ke, className: Ae, style: je }) {
17
+ let I = m(null), L = m(null), R = m([]), z = m({
18
+ from: 0,
19
+ to: 0
20
+ }), B = m(null), V = m(null), H = m(!1), U = m(0), W = m(null), G = m(null), Me = m(1), K = m({
21
+ width: 0,
22
+ height: 0
23
+ }), Ne = m(() => {}), Pe = m(Oe), q = m(ke);
24
+ Pe.current = Oe, q.current = ke;
25
+ let [J, Fe] = h(null), [Ie, Le] = h(A), Re = k ?? Ie, ze = u((e) => {
26
+ k === void 0 && Le(e), j?.(e);
27
+ }, [k, j]), Be = p(() => ({
28
+ up: w,
29
+ down: E,
30
+ line: O
31
+ }), [
32
+ w,
33
+ E,
34
+ O
35
+ ]), Y = x, X = Y.some((e) => e.type === "rsi"), Z = Y.some((e) => e.type === "volume");
36
+ Ne.current = u(() => {
37
+ let e = L.current;
38
+ if (!e) return;
39
+ let t = e.getContext("2d");
40
+ if (!t) return;
41
+ let { width: n, height: r } = K.current;
42
+ if (n === 0 || r === 0) return;
43
+ let a = Me.current;
44
+ t.save(), t.setTransform(1, 0, 0, 1, 0, 0), t.clearRect(0, 0, e.width, e.height), t.scale(a, a);
45
+ let c = pe(I.current, Be), l = fe(I.current), u = R.current;
46
+ if (u.length === 0) {
47
+ me(t, n, r, c), t.restore();
48
+ return;
49
+ }
50
+ let d = T(n, r, X, Z), { from: f, to: p } = ce(z.current, u.length);
51
+ z.current = {
52
+ from: f,
53
+ to: p
54
+ };
55
+ let m = u.slice(Math.max(0, Math.floor(f)), Math.min(u.length, Math.ceil(p) + 1)), h = (e) => {
56
+ let t = p - f + 1, n = d.plotWidth / t;
57
+ return d.plotLeft + (e - f + .5) * n;
58
+ }, g = d.plotWidth / (p - f + 1), _ = Y.map((e) => le(e, u)).filter((e) => e !== null).map((e) => ({
59
+ ...e,
60
+ color: l(e.color)
61
+ })), v = ue(d.main, m, _, f, p);
62
+ he(t, d.plotLeft, d.plotRight, v, c), ge(t, d, v, S, c), t.save(), t.beginPath(), t.rect(d.plotLeft, v.paneTop, d.plotWidth, v.paneHeight), t.clip();
63
+ for (let e = 0; e < Y.length; e++) {
64
+ let n = Y[e], r = _[e];
65
+ r && be(t, r, n, u, f, p, h, v);
66
+ }
67
+ if (s === "candle" ? _e(t, u, f, p, h, g, v, {
68
+ up: c.up,
69
+ down: c.down
70
+ }) : s === "bar" ? ve(t, u, f, p, h, g, v, {
71
+ up: c.up,
72
+ down: c.down
73
+ }) : ye(t, u, f, p, h, v, c.line, s === "area"), t.restore(), d.volume) {
74
+ let e = de(d.volume, u, f, p);
75
+ he(t, d.plotLeft, d.plotRight, e, c, !0), Ce(t, d, d.volume, "Volume", c), t.save(), t.beginPath(), t.rect(d.plotLeft, e.paneTop, d.plotWidth, e.paneHeight), t.clip(), xe(t, u, f, p, h, g, e, {
76
+ up: c.up,
77
+ down: c.down
78
+ }), t.restore();
79
+ }
80
+ if (d.rsi) {
81
+ let e = Y.find((e) => e.type === "rsi"), n = e && e.type === "rsi" ? e.period ?? 14 : 14, r = e && e.type === "rsi" ? e.overbought ?? 70 : 70, i = e && e.type === "rsi" ? e.oversold ?? 30 : 30, a = l((e && e.type === "rsi" ? e.color : void 0) ?? "var(--crk-chart-5)"), s = o(u, n), m = {
82
+ paneTop: d.rsi.top,
83
+ paneBottom: d.rsi.bottom,
84
+ paneHeight: d.rsi.height,
85
+ priceMin: 0,
86
+ priceMax: 100,
87
+ ticks: [
88
+ i,
89
+ 50,
90
+ r
91
+ ]
92
+ };
93
+ he(t, d.plotLeft, d.plotRight, m, c, !0), Ce(t, d, d.rsi, `RSI ${n}`, c), t.save(), t.beginPath(), t.rect(d.plotLeft, m.paneTop, d.plotWidth, m.paneHeight), t.clip(), D(t, s, f, p, h, m, a), t.restore(), Se(t, d, m, r, i, c);
94
+ }
95
+ we(t, d, u, f, p, i, c), B.current && Te(t, d, B.current, u, f, p, h, S, v, Re, c, i, N, P, De), t.restore();
96
+ }, [
97
+ s,
98
+ Y,
99
+ X,
100
+ Z,
101
+ S,
102
+ Be,
103
+ i,
104
+ Re,
105
+ N,
106
+ P,
107
+ De
108
+ ]);
109
+ let Q = u(() => {
110
+ G.current === null && (typeof requestAnimationFrame > "u" ? Ne.current() : G.current = requestAnimationFrame(() => {
111
+ G.current = null, Ne.current();
112
+ }));
113
+ }, []);
114
+ f(() => {
115
+ let e = I.current;
116
+ if (!e) return;
117
+ let t = () => {
118
+ let t = e.getBoundingClientRect(), n = typeof window < "u" && window.devicePixelRatio || 1;
119
+ Me.current = n, K.current = {
120
+ width: t.width,
121
+ height: t.height
122
+ };
123
+ let r = L.current;
124
+ r && (r.width = Math.round(t.width * n), r.height = Math.round(t.height * n), r.style.width = `${t.width}px`, r.style.height = `${t.height}px`), Q();
125
+ };
126
+ if (t(), typeof ResizeObserver > "u") return;
127
+ let n = new ResizeObserver(t);
128
+ return n.observe(e), () => n.disconnect();
129
+ }, [Q]), d(() => {
130
+ let e = !1, n = Math.floor(Date.now() / 1e3), o = F(i), s = a === "MAX", l = a === void 0 ? o * C : c(a), u = a === void 0 ? C : Math.max(10, Math.ceil(l / o)), d = s ? 0 : n - l;
131
+ R.current = [], z.current = {
132
+ from: 0,
133
+ to: 0
134
+ }, U.current += 1, H.current = !1, Q(), t.getBars({
135
+ symbol: r,
136
+ resolution: i,
137
+ from: d,
138
+ to: n,
139
+ countBack: u
140
+ }).then((t) => {
141
+ if (e) return;
142
+ let n = [...t].sort((e, t) => e.time - t.time);
143
+ R.current = n;
144
+ let r = n.length - 1;
145
+ if (a !== void 0) z.current = {
146
+ from: 0,
147
+ to: r
148
+ };
149
+ else {
150
+ let e = Math.min(n.length, Math.min(200, C));
151
+ z.current = {
152
+ from: Math.max(0, r - e + 1),
153
+ to: r
154
+ };
155
+ }
156
+ q.current?.(z.current, n), Q();
157
+ }).catch(() => {});
158
+ let f = t.subscribeBars({
159
+ symbol: r,
160
+ resolution: i,
161
+ onTick: (t) => {
162
+ if (e) return;
163
+ let n = R.current, r = n[n.length - 1];
164
+ if (r && r.time === t.time) n[n.length - 1] = t;
165
+ else if (!r || t.time > r.time) {
166
+ n.push(t);
167
+ let e = z.current;
168
+ e.to >= n.length - 2 && (z.current = {
169
+ from: e.from + 1,
170
+ to: e.to + 1
171
+ });
172
+ }
173
+ Q();
174
+ }
175
+ });
176
+ return W.current = f, () => {
177
+ e = !0, W.current !== null && (t.unsubscribeBars(W.current), W.current = null);
178
+ };
179
+ }, [
180
+ t,
181
+ r,
182
+ i,
183
+ a,
184
+ C
185
+ ]);
186
+ let $ = u((e) => {
187
+ Fe(e), Pe.current?.(e);
188
+ }, []), Ve = u((e) => {
189
+ e.currentTarget.setPointerCapture(e.pointerId);
190
+ let t = z.current;
191
+ V.current = {
192
+ startX: e.clientX,
193
+ from: t.from,
194
+ to: t.to
195
+ };
196
+ }, []), He = u(() => {
197
+ if (H.current) return;
198
+ let e = R.current;
199
+ if (e.length === 0) return;
200
+ H.current = !0;
201
+ let n = U.current, a = F(i), o = e[0].time, s = o - a * C, c = o - a;
202
+ t.getBars({
203
+ symbol: r,
204
+ resolution: i,
205
+ from: s,
206
+ to: c,
207
+ countBack: C
208
+ }).then((e) => {
209
+ if (n !== U.current) return;
210
+ if (e.length === 0) {
211
+ H.current = !1;
212
+ return;
213
+ }
214
+ let t = [...e].sort((e, t) => e.time - t.time).filter((e) => e.time < o), r = z.current;
215
+ R.current = [...t, ...R.current], z.current = {
216
+ from: r.from + t.length,
217
+ to: r.to + t.length
218
+ }, H.current = !1, Q();
219
+ }).catch(() => {
220
+ n === U.current && (H.current = !1);
221
+ });
222
+ }, [
223
+ t,
224
+ r,
225
+ i,
226
+ C,
227
+ Q
228
+ ]), Ue = u((e) => {
229
+ let t = e.currentTarget.getBoundingClientRect(), n = e.clientX - t.left, r = e.clientY - t.top;
230
+ if (B.current = {
231
+ x: n,
232
+ y: r
233
+ }, V.current) {
234
+ let { startX: t, from: n, to: r } = V.current, { width: i } = K.current, a = Math.max(1, i - b), o = r - n + 1, s = a / o, c = -(e.clientX - t) / s, l = n + c, u = r + c, d = R.current.length;
235
+ l < 0 && (He(), l = 0, u = o - 1), u > d - 1 && (u = d - 1, l = u - o + 1), z.current = {
236
+ from: l,
237
+ to: u
238
+ }, q.current?.(z.current, R.current);
239
+ }
240
+ let i = T(t.width, t.height, X, Z), a = z.current;
241
+ if (n >= i.plotLeft && n <= i.plotRight) {
242
+ let e = a.to - a.from + 1, t = i.plotWidth / e, o = Math.round(a.from + (n - i.plotLeft) / t - .5), s = R.current, c = Math.max(0, Math.min(s.length - 1, o)), l = s[c] ?? null, u = Ee(r, i, s, a.from, a.to, X, Z);
243
+ $({
244
+ barIndex: c,
245
+ bar: l,
246
+ priceAtCursor: u
247
+ });
248
+ } else $(null);
249
+ Q();
250
+ }, [
251
+ X,
252
+ Z,
253
+ He,
254
+ Q,
255
+ $
256
+ ]), We = u((e) => {
257
+ e.currentTarget.releasePointerCapture(e.pointerId), V.current = null;
258
+ }, []), Ge = u(() => {
259
+ B.current = null, V.current = null, $(null), Q();
260
+ }, [Q, $]), Ke = u((e) => {
261
+ e.preventDefault();
262
+ let t = e.currentTarget.getBoundingClientRect(), n = e.clientX - t.left, r = T(t.width, t.height, X, Z), i = z.current, a = R.current;
263
+ if (a.length === 0) return;
264
+ let o = i.to - i.from + 1, s = e.deltaY > 0 ? 1.1 : 1 / 1.1, c = Math.max(r.plotWidth / ne, Math.min(a.length, r.plotWidth / te, o * s)), l = i.from + (n - r.plotLeft) / (r.plotWidth / o), u = l - (l - i.from) / o * c, d = u + c - 1;
265
+ u < 0 && (u = 0, d = c - 1), d > a.length - 1 && (d = a.length - 1, u = d - c + 1), z.current = {
266
+ from: u,
267
+ to: d
268
+ }, q.current?.(z.current, a), Q();
269
+ }, [
270
+ X,
271
+ Z,
272
+ Q
273
+ ]), qe = u((e) => {
274
+ let t = z.current, n = t.to - t.from + 1, r = R.current;
275
+ if (r.length === 0) return;
276
+ let i = 0;
277
+ if (e.key === "ArrowLeft") i = -Math.max(1, Math.floor(n * .1));
278
+ else if (e.key === "ArrowRight") i = Math.max(1, Math.floor(n * .1));
279
+ else return;
280
+ e.preventDefault();
281
+ let a = t.from + i, o = t.to + i;
282
+ a < 0 && (a = 0, o = n - 1), o > r.length - 1 && (o = r.length - 1, a = o - n + 1), z.current = {
283
+ from: a,
284
+ to: o
285
+ }, q.current?.(z.current, r), Q();
286
+ }, [Q]);
287
+ return /* @__PURE__ */ v("div", {
288
+ ref: I,
289
+ className: g(l.root, Ae),
290
+ style: {
291
+ ...je,
292
+ height: ae,
293
+ position: "relative"
294
+ },
295
+ tabIndex: 0,
296
+ role: "figure",
297
+ "aria-label": `${r} ${i} chart`,
298
+ onKeyDown: qe,
299
+ children: [/* @__PURE__ */ _("canvas", {
300
+ ref: L,
301
+ className: l.svg,
302
+ onPointerDown: Ve,
303
+ onPointerMove: Ue,
304
+ onPointerUp: We,
305
+ onPointerLeave: Ge,
306
+ onWheel: Ke,
307
+ style: {
308
+ cursor: V.current ? "grabbing" : "crosshair",
309
+ touchAction: "none"
310
+ }
311
+ }), /* @__PURE__ */ v("div", {
312
+ className: l.tradingHeader,
313
+ style: {
314
+ position: "absolute",
315
+ top: ee,
316
+ left: 8,
317
+ right: 8,
318
+ pointerEvents: "none",
319
+ display: "flex",
320
+ alignItems: "center",
321
+ justifyContent: "space-between",
322
+ gap: 8
323
+ },
324
+ children: [/* @__PURE__ */ v("div", {
325
+ style: {
326
+ display: "flex",
327
+ alignItems: "center",
328
+ gap: 8,
329
+ minWidth: 0
330
+ },
331
+ children: [
332
+ /* @__PURE__ */ _("strong", { children: r }),
333
+ /* @__PURE__ */ _("span", {
334
+ style: { color: "var(--crk-color-text-muted)" },
335
+ children: i
336
+ }),
337
+ J?.bar && /* @__PURE__ */ v("span", {
338
+ style: {
339
+ color: "var(--crk-color-text-muted)",
340
+ whiteSpace: "nowrap"
341
+ },
342
+ children: [
343
+ "O ",
344
+ J.bar.open.toFixed(S),
345
+ " · H ",
346
+ J.bar.high.toFixed(S),
347
+ " · L",
348
+ " ",
349
+ J.bar.low.toFixed(S),
350
+ " · C ",
351
+ J.bar.close.toFixed(S)
352
+ ]
353
+ })
354
+ ]
355
+ }), M && /* @__PURE__ */ _("div", {
356
+ style: { pointerEvents: "auto" },
357
+ children: /* @__PURE__ */ _(n, {
358
+ position: "bottom",
359
+ asChild: !0,
360
+ trigger: /* @__PURE__ */ _(e, {
361
+ variant: "ghost",
362
+ size: "sm",
363
+ iconOnly: !0,
364
+ "aria-label": "Chart settings",
365
+ children: /* @__PURE__ */ _(se, {})
366
+ }),
367
+ content: /* @__PURE__ */ _(oe, {
368
+ timezone: Re,
369
+ onTimezoneChange: ze
370
+ })
371
+ })
372
+ })]
373
+ })]
374
+ });
327
375
  }
328
- const Te = [
329
- { value: "local", label: "Local time" },
330
- { value: "utc", label: "UTC" },
331
- { value: "America/New_York", label: "America / New York" },
332
- { value: "America/Los_Angeles", label: "America / Los Angeles" },
333
- { value: "Europe/London", label: "Europe / London" },
334
- { value: "Europe/Berlin", label: "Europe / Berlin" },
335
- { value: "Asia/Tokyo", label: "Asia / Tokyo" },
336
- { value: "Asia/Singapore", label: "Asia / Singapore" }
376
+ var w = [
377
+ {
378
+ value: "local",
379
+ label: "Local time"
380
+ },
381
+ {
382
+ value: "utc",
383
+ label: "UTC"
384
+ },
385
+ {
386
+ value: "America/New_York",
387
+ label: "America / New York"
388
+ },
389
+ {
390
+ value: "America/Los_Angeles",
391
+ label: "America / Los Angeles"
392
+ },
393
+ {
394
+ value: "Europe/London",
395
+ label: "Europe / London"
396
+ },
397
+ {
398
+ value: "Europe/Berlin",
399
+ label: "Europe / Berlin"
400
+ },
401
+ {
402
+ value: "Asia/Tokyo",
403
+ label: "Asia / Tokyo"
404
+ },
405
+ {
406
+ value: "Asia/Singapore",
407
+ label: "Asia / Singapore"
408
+ }
337
409
  ];
338
- function ve({
339
- timezone: t,
340
- onTimezoneChange: n
341
- }) {
342
- return /* @__PURE__ */ et("div", { style: { minWidth: 220, padding: 4 }, children: [
343
- /* @__PURE__ */ x(
344
- "div",
345
- {
346
- style: {
347
- fontWeight: 600,
348
- fontSize: "var(--crk-font-size-sm)",
349
- padding: "4px 4px 8px"
350
- },
351
- children: "Settings"
352
- }
353
- ),
354
- /* @__PURE__ */ et("label", { style: { display: "flex", flexDirection: "column", gap: 4, padding: "4px" }, children: [
355
- /* @__PURE__ */ x("span", { style: { fontSize: "var(--crk-font-size-xs)", color: "var(--crk-color-text-muted)" }, children: "Timezone" }),
356
- /* @__PURE__ */ x(
357
- fe,
358
- {
359
- options: Te.map((e) => ({ value: e.value, label: e.label })),
360
- value: t,
361
- onChange: (e) => n(e)
362
- }
363
- )
364
- ] })
365
- ] });
410
+ function oe({ timezone: e, onTimezoneChange: n }) {
411
+ return /* @__PURE__ */ v("div", {
412
+ style: {
413
+ minWidth: 220,
414
+ padding: 4
415
+ },
416
+ children: [/* @__PURE__ */ _("div", {
417
+ style: {
418
+ fontWeight: 600,
419
+ fontSize: "var(--crk-font-size-sm)",
420
+ padding: "4px 4px 8px"
421
+ },
422
+ children: "Settings"
423
+ }), /* @__PURE__ */ v("label", {
424
+ style: {
425
+ display: "flex",
426
+ flexDirection: "column",
427
+ gap: 4,
428
+ padding: "4px"
429
+ },
430
+ children: [/* @__PURE__ */ _("span", {
431
+ style: {
432
+ fontSize: "var(--crk-font-size-xs)",
433
+ color: "var(--crk-color-text-muted)"
434
+ },
435
+ children: "Timezone"
436
+ }), /* @__PURE__ */ _(t, {
437
+ options: w.map((e) => ({
438
+ value: e.value,
439
+ label: e.label
440
+ })),
441
+ value: e,
442
+ onChange: (e) => n(e)
443
+ })]
444
+ })]
445
+ });
366
446
  }
367
- function we() {
368
- return /* @__PURE__ */ et(
369
- "svg",
370
- {
371
- viewBox: "0 0 24 24",
372
- fill: "none",
373
- stroke: "currentColor",
374
- strokeWidth: 2,
375
- strokeLinecap: "round",
376
- strokeLinejoin: "round",
377
- "aria-hidden": "true",
378
- children: [
379
- /* @__PURE__ */ x("circle", { cx: "12", cy: "12", r: "3" }),
380
- /* @__PURE__ */ x("path", { d: "M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z" })
381
- ]
382
- }
383
- );
447
+ function se() {
448
+ return /* @__PURE__ */ v("svg", {
449
+ viewBox: "0 0 24 24",
450
+ fill: "none",
451
+ stroke: "currentColor",
452
+ strokeWidth: 2,
453
+ strokeLinecap: "round",
454
+ strokeLinejoin: "round",
455
+ "aria-hidden": "true",
456
+ children: [/* @__PURE__ */ _("circle", {
457
+ cx: "12",
458
+ cy: "12",
459
+ r: "3"
460
+ }), /* @__PURE__ */ _("path", { d: "M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z" })]
461
+ });
384
462
  }
385
- function Mt(t, n, e, o) {
386
- const l = Math.max(0, t - vt), i = ue, s = Math.max(i, n - wt), c = Math.max(0, l - 0), g = Math.max(0, s - i);
387
- let u = g, f = i;
388
- const d = { top: i, bottom: s, height: g };
389
- let M = null, k = null;
390
- const L = e ? Ct.rsi : 0, W = o ? Ct.volume : 0;
391
- return u = g * (1 - L - W), d.top = f, d.height = u, d.bottom = d.top + u, f = d.bottom, e && (M = { top: f, height: g * L, bottom: f + g * L }, f = M.bottom), o && (k = { top: f, height: g * W, bottom: f + g * W }), { width: t, height: n, plotLeft: 0, plotRight: l, plotTop: i, plotBottom: s, plotWidth: c, plotHeight: g, main: d, rsi: M, volume: k };
463
+ function T(e, t, n, r) {
464
+ let i = Math.max(0, e - b), a = S, o = Math.max(a, t - x), s = Math.max(0, i - 0), c = Math.max(0, o - a), l = c, u = a, d = {
465
+ top: a,
466
+ bottom: o,
467
+ height: c
468
+ }, f = null, p = null, m = n ? C.rsi : 0, h = r ? C.volume : 0;
469
+ return l = c * (1 - m - h), d.top = u, d.height = l, d.bottom = d.top + l, u = d.bottom, n && (f = {
470
+ top: u,
471
+ height: c * m,
472
+ bottom: u + c * m
473
+ }, u = f.bottom), r && (p = {
474
+ top: u,
475
+ height: c * h,
476
+ bottom: u + c * h
477
+ }), {
478
+ width: e,
479
+ height: t,
480
+ plotLeft: 0,
481
+ plotRight: i,
482
+ plotTop: a,
483
+ plotBottom: o,
484
+ plotWidth: s,
485
+ plotHeight: c,
486
+ main: d,
487
+ rsi: f,
488
+ volume: p
489
+ };
392
490
  }
393
- function ye(t, n) {
394
- if (n === 0) return { from: 0, to: 0 };
395
- let { from: e, to: o } = t;
396
- if (o >= n) {
397
- const r = o - e;
398
- o = n - 1, e = Math.max(0, o - r);
399
- }
400
- return e < 0 && (e = 0), o < e && (o = e), { from: e, to: o };
491
+ function ce(e, t) {
492
+ if (t === 0) return {
493
+ from: 0,
494
+ to: 0
495
+ };
496
+ let { from: n, to: r } = e;
497
+ if (r >= t) {
498
+ let e = r - n;
499
+ r = t - 1, n = Math.max(0, r - e);
500
+ }
501
+ return n < 0 && (n = 0), r < n && (r = n), {
502
+ from: n,
503
+ to: r
504
+ };
401
505
  }
402
- function be(t, n) {
403
- if (t.type === "sma")
404
- return { kind: "line", values: re(n, t.period), color: t.color ?? "var(--crk-chart-2)" };
405
- if (t.type === "ema")
406
- return { kind: "line", values: ie(n, t.period), color: t.color ?? "var(--crk-chart-3)" };
407
- if (t.type === "bollinger") {
408
- const e = le(n, t.period, t.stdDev ?? 2);
409
- return {
410
- kind: "bollinger",
411
- middle: e.middle,
412
- upper: e.upper,
413
- lower: e.lower,
414
- color: t.color ?? "var(--crk-chart-4)",
415
- fillOpacity: t.fillOpacity ?? 0.1
416
- };
417
- }
418
- return null;
506
+ function le(e, t) {
507
+ if (e.type === "sma") return {
508
+ kind: "line",
509
+ values: s(t, e.period),
510
+ color: e.color ?? "var(--crk-chart-2)"
511
+ };
512
+ if (e.type === "ema") return {
513
+ kind: "line",
514
+ values: a(t, e.period),
515
+ color: e.color ?? "var(--crk-chart-3)"
516
+ };
517
+ if (e.type === "bollinger") {
518
+ let n = i(t, e.period, e.stdDev ?? 2);
519
+ return {
520
+ kind: "bollinger",
521
+ middle: n.middle,
522
+ upper: n.upper,
523
+ lower: n.lower,
524
+ color: e.color ?? "var(--crk-chart-4)",
525
+ fillOpacity: e.fillOpacity ?? .1
526
+ };
527
+ }
528
+ return null;
419
529
  }
420
- function Pt(t, n, e, o, r) {
421
- let l = 1 / 0, i = -1 / 0;
422
- for (const f of n)
423
- f.low < l && (l = f.low), f.high > i && (i = f.high);
424
- for (const f of e) {
425
- const d = f.kind === "line" ? [f.values] : [f.upper, f.lower];
426
- for (const M of d) {
427
- const k = Math.max(0, Math.floor(o)), L = Math.min(M.length - 1, Math.ceil(r));
428
- for (let W = k; W <= L; W++) {
429
- const P = M[W];
430
- P != null && (P < l && (l = P), P > i && (i = P));
431
- }
432
- }
433
- }
434
- (!isFinite(l) || !isFinite(i)) && (l = 0, i = 1);
435
- const s = (i - l) * 0.08 || 1, c = Dt(l - s, i + s, 5), g = Math.min(c[0], l), u = Math.max(c[c.length - 1], i);
436
- return { paneTop: t.top, paneBottom: t.bottom, paneHeight: t.height, priceMin: g, priceMax: u, ticks: c };
530
+ function ue(e, t, n, i, a) {
531
+ let o = Infinity, s = -Infinity;
532
+ for (let e of t) e.low < o && (o = e.low), e.high > s && (s = e.high);
533
+ for (let e of n) {
534
+ let t = e.kind === "line" ? [e.values] : [e.upper, e.lower];
535
+ for (let e of t) {
536
+ let t = Math.max(0, Math.floor(i)), n = Math.min(e.length - 1, Math.ceil(a));
537
+ for (let r = t; r <= n; r++) {
538
+ let t = e[r];
539
+ t != null && (t < o && (o = t), t > s && (s = t));
540
+ }
541
+ }
542
+ }
543
+ isFinite(o) && isFinite(s) || (o = 0, s = 1);
544
+ let c = (s - o) * .08 || 1, l = r(o - c, s + c, 5), u = Math.min(l[0], o), d = Math.max(l[l.length - 1], s);
545
+ return {
546
+ paneTop: e.top,
547
+ paneBottom: e.bottom,
548
+ paneHeight: e.height,
549
+ priceMin: u,
550
+ priceMax: d,
551
+ ticks: l
552
+ };
437
553
  }
438
- function Re(t, n, e, o) {
439
- let r = 0;
440
- const l = Math.max(0, Math.floor(e)), i = Math.min(n.length - 1, Math.ceil(o));
441
- for (let g = l; g <= i; g++) {
442
- const u = n[g].volume ?? 0;
443
- u > r && (r = u);
444
- }
445
- const s = Dt(0, r || 1, 3), c = Math.max(s[s.length - 1], r);
446
- return { paneTop: t.top, paneBottom: t.bottom, paneHeight: t.height, priceMin: 0, priceMax: c, ticks: s };
554
+ function de(e, t, n, i) {
555
+ let a = 0, o = Math.max(0, Math.floor(n)), s = Math.min(t.length - 1, Math.ceil(i));
556
+ for (let e = o; e <= s; e++) {
557
+ let n = t[e].volume ?? 0;
558
+ n > a && (a = n);
559
+ }
560
+ let c = r(0, a || 1, 3), l = Math.max(c[c.length - 1], a);
561
+ return {
562
+ paneTop: e.top,
563
+ paneBottom: e.bottom,
564
+ paneHeight: e.height,
565
+ priceMin: 0,
566
+ priceMax: l,
567
+ ticks: c
568
+ };
447
569
  }
448
- function B(t, n) {
449
- const e = (t - n.priceMin) / (n.priceMax - n.priceMin || 1);
450
- return n.paneBottom - e * n.paneHeight;
570
+ function E(e, t) {
571
+ let n = (e - t.priceMin) / (t.priceMax - t.priceMin || 1);
572
+ return t.paneBottom - n * t.paneHeight;
451
573
  }
452
- function It(t) {
453
- if (!t || typeof getComputedStyle > "u") return (r) => r;
454
- const n = getComputedStyle(t), e = /* @__PURE__ */ new Map(), o = (r) => {
455
- if (!r || !r.includes("var(")) return r;
456
- const l = e.get(r);
457
- if (l !== void 0) return l;
458
- const i = /var\(\s*(--[a-zA-Z0-9_-]+)/.exec(r);
459
- if (!i)
460
- return e.set(r, r), r;
461
- const s = n.getPropertyValue(i[1]).trim();
462
- if (!s)
463
- return e.set(r, r), r;
464
- const c = s.includes("var(") ? o(s) : s;
465
- return e.set(r, c), c;
466
- };
467
- return o;
574
+ function fe(e) {
575
+ if (!e || typeof getComputedStyle > "u") return (e) => e;
576
+ let t = getComputedStyle(e), n = /* @__PURE__ */ new Map(), r = (e) => {
577
+ if (!e || !e.includes("var(")) return e;
578
+ let i = n.get(e);
579
+ if (i !== void 0) return i;
580
+ let a = /var\(\s*(--[a-zA-Z0-9_-]+)/.exec(e);
581
+ if (!a) return n.set(e, e), e;
582
+ let o = t.getPropertyValue(a[1]).trim();
583
+ if (!o) return n.set(e, e), e;
584
+ let s = o.includes("var(") ? r(o) : o;
585
+ return n.set(e, s), s;
586
+ };
587
+ return r;
468
588
  }
469
- function Se(t, n) {
470
- const e = It(t);
471
- return {
472
- up: e(n.up),
473
- down: e(n.down),
474
- line: e(n.line),
475
- text: e("var(--crk-color-text)") || "#0f172a",
476
- textMuted: e("var(--crk-color-text-muted)") || "#94a3b8",
477
- axis: e("var(--crk-chart-axis)") || "#94a3b8",
478
- grid: e("var(--crk-chart-grid)") || "#e2e8f0",
479
- bg: e("var(--crk-color-bg)") || "#ffffff"
480
- };
589
+ function pe(e, t) {
590
+ let n = fe(e);
591
+ return {
592
+ up: n(t.up),
593
+ down: n(t.down),
594
+ line: n(t.line),
595
+ text: n("var(--crk-color-text)") || "#0f172a",
596
+ textMuted: n("var(--crk-color-text-muted)") || "#94a3b8",
597
+ axis: n("var(--crk-chart-axis)") || "#94a3b8",
598
+ grid: n("var(--crk-chart-grid)") || "#e2e8f0",
599
+ bg: n("var(--crk-color-bg)") || "#ffffff"
600
+ };
481
601
  }
482
- function Ae(t, n, e, o) {
483
- t.fillStyle = o.textMuted, t.font = "13px system-ui, sans-serif", t.textAlign = "center", t.textBaseline = "middle", t.fillText("Loading…", n / 2, e / 2);
602
+ function me(e, t, n, r) {
603
+ e.fillStyle = r.textMuted, e.font = "13px system-ui, sans-serif", e.textAlign = "center", e.textBaseline = "middle", e.fillText("Loading…", t / 2, n / 2);
484
604
  }
485
- function Tt(t, n, e, o, r, l = !1) {
486
- t.strokeStyle = r.grid, t.lineWidth = 1, t.beginPath();
487
- for (const i of o.ticks) {
488
- const s = Math.round(B(i, o)) + 0.5;
489
- t.moveTo(n, s), t.lineTo(e, s);
490
- }
491
- t.stroke();
605
+ function he(e, t, n, r, i, a = !1) {
606
+ e.strokeStyle = i.grid, e.lineWidth = 1, e.beginPath();
607
+ for (let i of r.ticks) {
608
+ let a = Math.round(E(i, r)) + .5;
609
+ e.moveTo(t, a), e.lineTo(n, a);
610
+ }
611
+ e.stroke();
492
612
  }
493
- function ke(t, n, e, o, r) {
494
- t.fillStyle = r.axis, t.font = "11px system-ui, sans-serif", t.textAlign = "left", t.textBaseline = "middle";
495
- for (const l of e.ticks) {
496
- const i = B(l, e);
497
- t.fillText(l.toFixed(o), n.plotRight + 6, i);
498
- }
613
+ function ge(e, t, n, r, i) {
614
+ e.fillStyle = i.axis, e.font = "11px system-ui, sans-serif", e.textAlign = "left", e.textBaseline = "middle";
615
+ for (let i of n.ticks) {
616
+ let a = E(i, n);
617
+ e.fillText(i.toFixed(r), t.plotRight + 6, a);
618
+ }
499
619
  }
500
- function Ce(t, n, e, o, r, l, i, s) {
501
- const c = Math.max(0, Math.floor(e)), g = Math.min(n.length - 1, Math.ceil(o)), u = Math.max(1, l * 0.7);
502
- for (let f = c; f <= g; f++) {
503
- const d = n[f], M = r(f), k = B(d.open, i), L = B(d.close, i), W = B(d.high, i), P = B(d.low, i), N = d.close >= d.open ? s.up : s.down;
504
- t.strokeStyle = N, t.fillStyle = N, t.beginPath();
505
- const Y = Math.round(M) + 0.5;
506
- t.moveTo(Y, W), t.lineTo(Y, P), t.stroke();
507
- const _ = Math.min(k, L), J = Math.max(1, Math.abs(L - k));
508
- t.fillRect(Math.round(M - u / 2), Math.round(_), Math.round(u), Math.round(J));
509
- }
620
+ function _e(e, t, n, r, i, a, o, s) {
621
+ let c = Math.max(0, Math.floor(n)), l = Math.min(t.length - 1, Math.ceil(r)), u = Math.max(1, a * .7);
622
+ for (let n = c; n <= l; n++) {
623
+ let r = t[n], a = i(n), c = E(r.open, o), l = E(r.close, o), d = E(r.high, o), f = E(r.low, o), p = r.close >= r.open ? s.up : s.down;
624
+ e.strokeStyle = p, e.fillStyle = p, e.beginPath();
625
+ let m = Math.round(a) + .5;
626
+ e.moveTo(m, d), e.lineTo(m, f), e.stroke();
627
+ let h = Math.min(c, l), g = Math.max(1, Math.abs(l - c));
628
+ e.fillRect(Math.round(a - u / 2), Math.round(h), Math.round(u), Math.round(g));
629
+ }
510
630
  }
511
- function Le(t, n, e, o, r, l, i, s) {
512
- const c = Math.max(0, Math.floor(e)), g = Math.min(n.length - 1, Math.ceil(o)), u = Math.max(2, Math.min(l * 0.4, 8));
513
- t.lineWidth = Math.max(1, Math.min(2, l * 0.18)), t.lineCap = "butt";
514
- for (let f = c; f <= g; f++) {
515
- const d = n[f], M = Math.round(r(f)) + 0.5, k = B(d.high, i), L = B(d.low, i), W = B(d.open, i), P = B(d.close, i), j = d.close >= d.open;
516
- t.strokeStyle = j ? s.up : s.down, t.beginPath(), t.moveTo(M, k), t.lineTo(M, L), t.moveTo(M - u, W), t.lineTo(M, W), t.moveTo(M, P), t.lineTo(M + u, P), t.stroke();
517
- }
631
+ function ve(e, t, n, r, i, a, o, s) {
632
+ let c = Math.max(0, Math.floor(n)), l = Math.min(t.length - 1, Math.ceil(r)), u = Math.max(2, Math.min(a * .4, 8));
633
+ e.lineWidth = Math.max(1, Math.min(2, a * .18)), e.lineCap = "butt";
634
+ for (let n = c; n <= l; n++) {
635
+ let r = t[n], a = Math.round(i(n)) + .5, c = E(r.high, o), l = E(r.low, o), d = E(r.open, o), f = E(r.close, o);
636
+ e.strokeStyle = r.close >= r.open ? s.up : s.down, e.beginPath(), e.moveTo(a, c), e.lineTo(a, l), e.moveTo(a - u, d), e.lineTo(a, d), e.moveTo(a, f), e.lineTo(a + u, f), e.stroke();
637
+ }
518
638
  }
519
- function We(t, n, e, o, r, l, i, s) {
520
- const c = Math.max(0, Math.floor(e)), g = Math.min(n.length - 1, Math.ceil(o));
521
- if (!(g <= c)) {
522
- t.strokeStyle = i, t.lineWidth = 1.5, t.beginPath(), t.moveTo(r(c), B(n[c].close, l));
523
- for (let u = c + 1; u <= g; u++)
524
- t.lineTo(r(u), B(n[u].close, l));
525
- t.stroke(), s && (t.globalAlpha = 0.18, t.fillStyle = i, t.lineTo(r(g), l.paneBottom), t.lineTo(r(c), l.paneBottom), t.closePath(), t.fill(), t.globalAlpha = 1);
526
- }
639
+ function ye(e, t, n, r, i, a, o, s) {
640
+ let c = Math.max(0, Math.floor(n)), l = Math.min(t.length - 1, Math.ceil(r));
641
+ if (!(l <= c)) {
642
+ e.strokeStyle = o, e.lineWidth = 1.5, e.beginPath(), e.moveTo(i(c), E(t[c].close, a));
643
+ for (let n = c + 1; n <= l; n++) e.lineTo(i(n), E(t[n].close, a));
644
+ e.stroke(), s && (e.globalAlpha = .18, e.fillStyle = o, e.lineTo(i(l), a.paneBottom), e.lineTo(i(c), a.paneBottom), e.closePath(), e.fill(), e.globalAlpha = 1);
645
+ }
527
646
  }
528
- function $e(t, n, e, o, r, l, i, s) {
529
- if (n.kind === "line") {
530
- ft(t, n.values, r, l, i, s, n.color);
531
- return;
532
- }
533
- const c = Math.max(0, Math.floor(r)), g = Math.min(o.length - 1, Math.ceil(l));
534
- t.globalAlpha = n.fillOpacity, t.fillStyle = n.color, t.beginPath();
535
- let u = !1;
536
- for (let f = c; f <= g; f++) {
537
- const d = n.upper[f];
538
- if (d == null) continue;
539
- const M = i(f), k = B(d, s);
540
- u ? t.lineTo(M, k) : (t.moveTo(M, k), u = !0);
541
- }
542
- for (let f = g; f >= c; f--) {
543
- const d = n.lower[f];
544
- d != null && t.lineTo(i(f), B(d, s));
545
- }
546
- t.closePath(), t.fill(), t.globalAlpha = 1, ft(t, n.upper, r, l, i, s, n.color), ft(t, n.lower, r, l, i, s, n.color), ft(t, n.middle, r, l, i, s, n.color);
647
+ function be(e, t, n, r, i, a, o, s) {
648
+ if (t.kind === "line") {
649
+ D(e, t.values, i, a, o, s, t.color);
650
+ return;
651
+ }
652
+ let c = Math.max(0, Math.floor(i)), l = Math.min(r.length - 1, Math.ceil(a));
653
+ e.globalAlpha = t.fillOpacity, e.fillStyle = t.color, e.beginPath();
654
+ let u = !1;
655
+ for (let n = c; n <= l; n++) {
656
+ let r = t.upper[n];
657
+ if (r == null) continue;
658
+ let i = o(n), a = E(r, s);
659
+ u ? e.lineTo(i, a) : (e.moveTo(i, a), u = !0);
660
+ }
661
+ for (let n = l; n >= c; n--) {
662
+ let r = t.lower[n];
663
+ r != null && e.lineTo(o(n), E(r, s));
664
+ }
665
+ e.closePath(), e.fill(), e.globalAlpha = 1, D(e, t.upper, i, a, o, s, t.color), D(e, t.lower, i, a, o, s, t.color), D(e, t.middle, i, a, o, s, t.color);
547
666
  }
548
- function ft(t, n, e, o, r, l, i) {
549
- t.strokeStyle = i, t.lineWidth = 1.25, t.beginPath();
550
- let s = !1;
551
- const c = Math.max(0, Math.floor(e)), g = Math.min(n.length - 1, Math.ceil(o));
552
- for (let u = c; u <= g; u++) {
553
- const f = n[u];
554
- if (f == null) {
555
- s = !1;
556
- continue;
557
- }
558
- const d = r(u), M = B(f, l);
559
- s ? t.lineTo(d, M) : (t.moveTo(d, M), s = !0);
560
- }
561
- t.stroke();
667
+ function D(e, t, n, r, i, a, o) {
668
+ e.strokeStyle = o, e.lineWidth = 1.25, e.beginPath();
669
+ let s = !1, c = Math.max(0, Math.floor(n)), l = Math.min(t.length - 1, Math.ceil(r));
670
+ for (let n = c; n <= l; n++) {
671
+ let r = t[n];
672
+ if (r == null) {
673
+ s = !1;
674
+ continue;
675
+ }
676
+ let o = i(n), c = E(r, a);
677
+ s ? e.lineTo(o, c) : (e.moveTo(o, c), s = !0);
678
+ }
679
+ e.stroke();
562
680
  }
563
- function He(t, n, e, o, r, l, i, s) {
564
- const c = Math.max(0, Math.floor(e)), g = Math.min(n.length - 1, Math.ceil(o)), u = Math.max(1, l * 0.7);
565
- for (let f = c; f <= g; f++) {
566
- const d = n[f], M = d.volume ?? 0;
567
- if (M === 0) continue;
568
- const k = d.close >= d.open;
569
- t.fillStyle = k ? s.up : s.down, t.globalAlpha = 0.55;
570
- const L = B(M, i), W = i.paneBottom - L;
571
- t.fillRect(Math.round(r(f) - u / 2), Math.round(L), Math.round(u), Math.round(W));
572
- }
573
- t.globalAlpha = 1;
681
+ function xe(e, t, n, r, i, a, o, s) {
682
+ let c = Math.max(0, Math.floor(n)), l = Math.min(t.length - 1, Math.ceil(r)), u = Math.max(1, a * .7);
683
+ for (let n = c; n <= l; n++) {
684
+ let r = t[n], a = r.volume ?? 0;
685
+ if (a === 0) continue;
686
+ e.fillStyle = r.close >= r.open ? s.up : s.down, e.globalAlpha = .55;
687
+ let c = E(a, o), l = o.paneBottom - c;
688
+ e.fillRect(Math.round(i(n) - u / 2), Math.round(c), Math.round(u), Math.round(l));
689
+ }
690
+ e.globalAlpha = 1;
574
691
  }
575
- function Be(t, n, e, o, r, l) {
576
- t.strokeStyle = l.grid, t.setLineDash([3, 3]), t.beginPath();
577
- for (const i of [o, r]) {
578
- const s = Math.round(B(i, e)) + 0.5;
579
- t.moveTo(n.plotLeft, s), t.lineTo(n.plotRight, s);
580
- }
581
- t.stroke(), t.setLineDash([]), t.fillStyle = l.axis, t.font = "10px system-ui, sans-serif", t.textAlign = "left", t.textBaseline = "middle", t.fillText(String(o), n.plotRight + 6, B(o, e)), t.fillText(String(r), n.plotRight + 6, B(r, e));
692
+ function Se(e, t, n, r, i, a) {
693
+ e.strokeStyle = a.grid, e.setLineDash([3, 3]), e.beginPath();
694
+ for (let a of [r, i]) {
695
+ let r = Math.round(E(a, n)) + .5;
696
+ e.moveTo(t.plotLeft, r), e.lineTo(t.plotRight, r);
697
+ }
698
+ e.stroke(), e.setLineDash([]), e.fillStyle = a.axis, e.font = "10px system-ui, sans-serif", e.textAlign = "left", e.textBaseline = "middle", e.fillText(String(r), t.plotRight + 6, E(r, n)), e.fillText(String(i), t.plotRight + 6, E(i, n));
582
699
  }
583
- function Wt(t, n, e, o, r) {
584
- t.fillStyle = r.textMuted, t.font = "11px system-ui, sans-serif", t.textAlign = "left", t.textBaseline = "top", t.fillText(o, n.plotLeft + 6, e.top + 4);
700
+ function Ce(e, t, n, r, i) {
701
+ e.fillStyle = i.textMuted, e.font = "11px system-ui, sans-serif", e.textAlign = "left", e.textBaseline = "top", e.fillText(r, t.plotLeft + 6, n.top + 4);
585
702
  }
586
- function De(t, n, e, o, r, l, i) {
587
- const s = r - o + 1, c = n.plotWidth / s, g = Math.max(1, Math.round(80 / c));
588
- t.fillStyle = i.axis, t.font = "11px system-ui, sans-serif", t.textAlign = "center", t.textBaseline = "middle";
589
- const u = Math.max(0, Math.floor(o)), f = Math.min(e.length - 1, Math.ceil(r)), d = n.plotBottom + wt / 2;
590
- for (let M = u; M <= f; M += g) {
591
- const k = e[M], L = n.plotLeft + (M - o + 0.5) * c;
592
- t.fillText(Oe(k.time, l), L, d);
593
- }
703
+ function we(e, t, n, r, i, a, o) {
704
+ let s = i - r + 1, c = t.plotWidth / s, l = Math.max(1, Math.round(80 / c));
705
+ e.fillStyle = o.axis, e.font = "11px system-ui, sans-serif", e.textAlign = "center", e.textBaseline = "middle";
706
+ let u = Math.max(0, Math.floor(r)), d = Math.min(n.length - 1, Math.ceil(i)), f = t.plotBottom + x / 2;
707
+ for (let i = u; i <= d; i += l) {
708
+ let o = n[i], s = t.plotLeft + (i - r + .5) * c;
709
+ e.fillText(O(o.time, a), s, f);
710
+ }
594
711
  }
595
- function Pe(t, n, e, o, r, l, i, s, c, g, u, f, d, M, k) {
596
- if (e.x < n.plotLeft || e.x > n.plotRight) return;
597
- const L = l - r + 1, W = n.plotWidth / L, P = r + (e.x - n.plotLeft) / W - 0.5, j = Math.round(P), N = Math.max(0, Math.min(o.length - 1, j)), Y = i(N);
598
- if (t.save(), t.strokeStyle = u.textMuted, t.setLineDash([3, 3]), t.lineWidth = 1, t.beginPath(), t.moveTo(Y + 0.5, n.plotTop), t.lineTo(Y + 0.5, n.plotBottom), t.moveTo(n.plotLeft, e.y + 0.5), t.lineTo(n.plotRight, e.y + 0.5), t.stroke(), t.setLineDash([]), e.y >= c.paneTop && e.y <= c.paneBottom) {
599
- const _ = c.priceMax - (e.y - c.paneTop) / c.paneHeight * (c.priceMax - c.priceMin);
600
- t.fillStyle = u.text, t.fillRect(n.plotRight, e.y - 9, vt, 18), t.fillStyle = u.bg, t.font = "11px system-ui, sans-serif", t.textAlign = "left", t.textBaseline = "middle", t.fillText(_.toFixed(s), n.plotRight + 6, e.y);
601
- }
602
- if (o[N]) {
603
- const _ = Et(o[N].time, g);
604
- t.font = "11px system-ui, sans-serif", t.textBaseline = "middle";
605
- const G = t.measureText(_).width + 8 * 2, I = wt, y = Math.max(
606
- n.plotLeft,
607
- Math.min(n.plotRight - G, Y - G / 2)
608
- ), F = n.plotBottom;
609
- t.fillStyle = u.text, t.fillRect(y, F, G, I), t.fillStyle = u.bg, t.textAlign = "center", t.fillText(_, y + G / 2, F + I / 2);
610
- }
611
- if (o[N]) {
612
- const _ = o[N], J = _.close.toFixed(s);
613
- let Z = J;
614
- if (M) {
615
- const K = (k ?? Ot)(_.time, f, g);
616
- K && (Z = `${J} · ${K}`);
617
- }
618
- t.font = "11px system-ui, sans-serif", t.textBaseline = "middle";
619
- const y = t.measureText(Z).width + 8 * 2, F = 18, V = Math.max(
620
- n.plotLeft,
621
- Math.min(n.plotRight - y, Y - y / 2)
622
- ), z = Math.max(0, n.plotTop - F - 2);
623
- if (d) {
624
- const K = _.close >= _.open;
625
- t.fillStyle = K ? u.up : u.down, t.fillRect(V, z, y, F), t.fillStyle = "#ffffff";
626
- } else
627
- t.fillStyle = u.text, t.fillRect(V, z, y, F), t.fillStyle = u.bg;
628
- t.textAlign = "center", t.fillText(Z, V + y / 2, z + F / 2);
629
- }
630
- t.restore();
712
+ function Te(e, t, n, r, i, a, o, s, c, l, u, d, f, p, m) {
713
+ if (n.x < t.plotLeft || n.x > t.plotRight) return;
714
+ let h = a - i + 1, g = t.plotWidth / h, _ = i + (n.x - t.plotLeft) / g - .5, v = Math.round(_), y = Math.max(0, Math.min(r.length - 1, v)), S = o(y);
715
+ if (e.save(), e.strokeStyle = u.textMuted, e.setLineDash([3, 3]), e.lineWidth = 1, e.beginPath(), e.moveTo(S + .5, t.plotTop), e.lineTo(S + .5, t.plotBottom), e.moveTo(t.plotLeft, n.y + .5), e.lineTo(t.plotRight, n.y + .5), e.stroke(), e.setLineDash([]), n.y >= c.paneTop && n.y <= c.paneBottom) {
716
+ let r = c.priceMax - (n.y - c.paneTop) / c.paneHeight * (c.priceMax - c.priceMin);
717
+ e.fillStyle = u.text, e.fillRect(t.plotRight, n.y - 9, b, 18), e.fillStyle = u.bg, e.font = "11px system-ui, sans-serif", e.textAlign = "left", e.textBaseline = "middle", e.fillText(r.toFixed(s), t.plotRight + 6, n.y);
718
+ }
719
+ if (r[y]) {
720
+ let n = M(r[y].time, l);
721
+ e.font = "11px system-ui, sans-serif", e.textBaseline = "middle";
722
+ let i = e.measureText(n).width + 16, a = x, o = Math.max(t.plotLeft, Math.min(t.plotRight - i, S - i / 2)), s = t.plotBottom;
723
+ e.fillStyle = u.text, e.fillRect(o, s, i, a), e.fillStyle = u.bg, e.textAlign = "center", e.fillText(n, o + i / 2, s + a / 2);
724
+ }
725
+ if (r[y]) {
726
+ let n = r[y], i = n.close.toFixed(s), a = i;
727
+ if (p) {
728
+ let e = (m ?? j)(n.time, d, l);
729
+ e && (a = `${i} · ${e}`);
730
+ }
731
+ e.font = "11px system-ui, sans-serif", e.textBaseline = "middle";
732
+ let o = e.measureText(a).width + 16, c = Math.max(t.plotLeft, Math.min(t.plotRight - o, S - o / 2)), h = Math.max(0, t.plotTop - 18 - 2);
733
+ f ? (e.fillStyle = n.close >= n.open ? u.up : u.down, e.fillRect(c, h, o, 18), e.fillStyle = "#ffffff") : (e.fillStyle = u.text, e.fillRect(c, h, o, 18), e.fillStyle = u.bg), e.textAlign = "center", e.fillText(a, c + o / 2, h + 9);
734
+ }
735
+ e.restore();
631
736
  }
632
- function Ie(t, n, e, o, r, l, i) {
633
- const s = e.slice(Math.max(0, Math.floor(o)), Math.min(e.length, Math.ceil(r) + 1)), c = Pt(n.main, s, [], o, r);
634
- return t < c.paneTop || t > c.paneBottom ? null : c.priceMax - (t - c.paneTop) / c.paneHeight * (c.priceMax - c.priceMin);
737
+ function Ee(e, t, n, r, i, a, o) {
738
+ let s = n.slice(Math.max(0, Math.floor(r)), Math.min(n.length, Math.ceil(i) + 1)), c = ue(t.main, s, [], r, i);
739
+ return e < c.paneTop || e > c.paneBottom ? null : c.priceMax - (e - c.paneTop) / c.paneHeight * (c.priceMax - c.priceMin);
635
740
  }
636
- function Oe(t, n) {
637
- const e = new Date(t * 1e3);
638
- return n === "D" || n === "W" || n === "M" ? `${e.getUTCFullYear()}-${D(e.getUTCMonth() + 1)}-${D(e.getUTCDate())}` : `${D(e.getUTCHours())}:${D(e.getUTCMinutes())}`;
741
+ function O(e, t) {
742
+ let n = /* @__PURE__ */ new Date(e * 1e3);
743
+ return t === "D" || t === "W" || t === "M" ? `${n.getUTCFullYear()}-${P(n.getUTCMonth() + 1)}-${P(n.getUTCDate())}` : `${P(n.getUTCHours())}:${P(n.getUTCMinutes())}`;
639
744
  }
640
- const $t = [
641
- "Jan",
642
- "Feb",
643
- "Mar",
644
- "Apr",
645
- "May",
646
- "Jun",
647
- "Jul",
648
- "Aug",
649
- "Sep",
650
- "Oct",
651
- "Nov",
652
- "Dec"
653
- ], Ht = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
654
- function Ot(t, n, e) {
655
- const o = new Date(t * 1e3), r = n === "D" || n === "W" || n === "M";
656
- let l, i, s, c, g, u;
657
- if (e === "local")
658
- l = o.getDate(), i = o.getMonth(), s = o.getFullYear(), c = o.getHours(), g = o.getMinutes(), u = o.getDay();
659
- else if (e === "utc")
660
- l = o.getUTCDate(), i = o.getUTCMonth(), s = o.getUTCFullYear(), c = o.getUTCHours(), g = o.getUTCMinutes(), u = o.getUTCDay();
661
- else
662
- try {
663
- const d = new Intl.DateTimeFormat("en-US", {
664
- timeZone: e,
665
- year: "numeric",
666
- month: "2-digit",
667
- day: "2-digit",
668
- hour: "2-digit",
669
- minute: "2-digit",
670
- weekday: "short",
671
- hour12: !1,
672
- hourCycle: "h23"
673
- }).formatToParts(o), M = (W) => d.find((P) => P.type === W)?.value ?? "";
674
- l = Number(M("day")), i = Number(M("month")) - 1, s = Number(M("year")), c = Number(M("hour")), g = Number(M("minute"));
675
- const k = M("weekday"), L = Ht.indexOf(k);
676
- u = L >= 0 ? L : 0;
677
- } catch {
678
- return Ot(t, n, "utc");
679
- }
680
- return r ? `${l} ${$t[i]} ${s}` : `${Ht[u]} ${l} ${$t[i]} ${D(c)}:${D(g)}`;
745
+ var k = [
746
+ "Jan",
747
+ "Feb",
748
+ "Mar",
749
+ "Apr",
750
+ "May",
751
+ "Jun",
752
+ "Jul",
753
+ "Aug",
754
+ "Sep",
755
+ "Oct",
756
+ "Nov",
757
+ "Dec"
758
+ ], A = [
759
+ "Sun",
760
+ "Mon",
761
+ "Tue",
762
+ "Wed",
763
+ "Thu",
764
+ "Fri",
765
+ "Sat"
766
+ ];
767
+ function j(e, t, n) {
768
+ let r = /* @__PURE__ */ new Date(e * 1e3), i = t === "D" || t === "W" || t === "M", a, o, s, c, l, u;
769
+ if (n === "local") a = r.getDate(), o = r.getMonth(), s = r.getFullYear(), c = r.getHours(), l = r.getMinutes(), u = r.getDay();
770
+ else if (n === "utc") a = r.getUTCDate(), o = r.getUTCMonth(), s = r.getUTCFullYear(), c = r.getUTCHours(), l = r.getUTCMinutes(), u = r.getUTCDay();
771
+ else try {
772
+ let e = new Intl.DateTimeFormat("en-US", {
773
+ timeZone: n,
774
+ year: "numeric",
775
+ month: "2-digit",
776
+ day: "2-digit",
777
+ hour: "2-digit",
778
+ minute: "2-digit",
779
+ weekday: "short",
780
+ hour12: !1,
781
+ hourCycle: "h23"
782
+ }).formatToParts(r), t = (t) => e.find((e) => e.type === t)?.value ?? "";
783
+ a = Number(t("day")), o = Number(t("month")) - 1, s = Number(t("year")), c = Number(t("hour")), l = Number(t("minute"));
784
+ let i = t("weekday"), d = A.indexOf(i);
785
+ u = d >= 0 ? d : 0;
786
+ } catch {
787
+ return j(e, t, "utc");
788
+ }
789
+ return i ? `${a} ${k[o]} ${s}` : `${A[u]} ${a} ${k[o]} ${P(c)}:${P(l)}`;
681
790
  }
682
- function Et(t, n) {
683
- const e = new Date(t * 1e3);
684
- if (n === "local")
685
- return `${e.getFullYear()}-${D(e.getMonth() + 1)}-${D(e.getDate())} ${D(e.getHours())}:${D(e.getMinutes())}:${D(e.getSeconds())} ${Ee(e)}`;
686
- if (n === "utc")
687
- return `${e.getUTCFullYear()}-${D(e.getUTCMonth() + 1)}-${D(e.getUTCDate())} ${D(e.getUTCHours())}:${D(e.getUTCMinutes())}:${D(e.getUTCSeconds())} UTC`;
688
- try {
689
- const r = new Intl.DateTimeFormat("en-CA", {
690
- timeZone: n,
691
- year: "numeric",
692
- month: "2-digit",
693
- day: "2-digit",
694
- hour: "2-digit",
695
- minute: "2-digit",
696
- second: "2-digit",
697
- hour12: !1,
698
- hourCycle: "h23",
699
- timeZoneName: "short"
700
- }).formatToParts(e), l = (s) => r.find((c) => c.type === s)?.value ?? "", i = l("timeZoneName") || n;
701
- return `${l("year")}-${l("month")}-${l("day")} ${l("hour")}:${l("minute")}:${l("second")} ${i}`;
702
- } catch {
703
- return Et(t, "utc");
704
- }
791
+ function M(e, t) {
792
+ let n = /* @__PURE__ */ new Date(e * 1e3);
793
+ if (t === "local") return `${n.getFullYear()}-${P(n.getMonth() + 1)}-${P(n.getDate())} ${P(n.getHours())}:${P(n.getMinutes())}:${P(n.getSeconds())} ${N(n)}`;
794
+ if (t === "utc") return `${n.getUTCFullYear()}-${P(n.getUTCMonth() + 1)}-${P(n.getUTCDate())} ${P(n.getUTCHours())}:${P(n.getUTCMinutes())}:${P(n.getUTCSeconds())} UTC`;
795
+ try {
796
+ let e = new Intl.DateTimeFormat("en-CA", {
797
+ timeZone: t,
798
+ year: "numeric",
799
+ month: "2-digit",
800
+ day: "2-digit",
801
+ hour: "2-digit",
802
+ minute: "2-digit",
803
+ second: "2-digit",
804
+ hour12: !1,
805
+ hourCycle: "h23",
806
+ timeZoneName: "short"
807
+ }).formatToParts(n), r = (t) => e.find((e) => e.type === t)?.value ?? "", i = r("timeZoneName") || t;
808
+ return `${r("year")}-${r("month")}-${r("day")} ${r("hour")}:${r("minute")}:${r("second")} ${i}`;
809
+ } catch {
810
+ return M(e, "utc");
811
+ }
705
812
  }
706
- function Ee(t) {
707
- const n = -t.getTimezoneOffset(), e = n >= 0 ? "+" : "-", o = Math.abs(n);
708
- return `${e}${D(Math.floor(o / 60))}:${D(o % 60)}`;
813
+ function N(e) {
814
+ let t = -e.getTimezoneOffset(), n = t >= 0 ? "+" : "-", r = Math.abs(t);
815
+ return `${n}${P(Math.floor(r / 60))}:${P(r % 60)}`;
709
816
  }
710
- function D(t) {
711
- return t < 10 ? `0${t}` : String(t);
817
+ function P(e) {
818
+ return e < 10 ? `0${e}` : String(e);
712
819
  }
713
- function Bt(t) {
714
- if (t === "D") return 86400;
715
- if (t === "W") return 86400 * 7;
716
- if (t === "M") return 86400 * 30;
717
- const n = Number(t);
718
- if (Number.isFinite(n)) return n * 60;
719
- const e = /^(\d+)([HhDdWwMm])$/.exec(t);
720
- if (e) {
721
- const o = Number(e[1]), r = e[2].toUpperCase();
722
- if (r === "H") return o * 3600;
723
- if (r === "D") return o * 86400;
724
- if (r === "W") return o * 86400 * 7;
725
- if (r === "M") return o * 60;
726
- }
727
- return 60;
820
+ function F(e) {
821
+ if (e === "D") return 86400;
822
+ if (e === "W") return 604800;
823
+ if (e === "M") return 2592e3;
824
+ let t = Number(e);
825
+ if (Number.isFinite(t)) return t * 60;
826
+ let n = /^(\d+)([HhDdWwMm])$/.exec(e);
827
+ if (n) {
828
+ let e = Number(n[1]), t = n[2].toUpperCase();
829
+ if (t === "H") return e * 3600;
830
+ if (t === "D") return e * 86400;
831
+ if (t === "W") return e * 86400 * 7;
832
+ if (t === "M") return e * 60;
833
+ }
834
+ return 60;
728
835
  }
729
- export {
730
- Ge as TradingChart,
731
- Bt as approxIntervalSeconds,
732
- Et as formatCrosshairTime
733
- };
836
+ export { ae as TradingChart, F as approxIntervalSeconds, M as formatCrosshairTime };