@overdoser/react-toolkit 0.19.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 (279) hide show
  1. package/AGENTS.md +2 -2
  2. package/CHANGELOG.md +47 -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 +41 -16
  123. package/components/Table/Table.js +383 -442
  124. package/components/Table/Table.module.js +42 -0
  125. package/components/Table/index.d.ts +1 -1
  126. package/components/Table/useTableSort.d.ts +1 -1
  127. package/components/Table/useTableSort.js +51 -42
  128. package/components/Tabs/Tabs.js +109 -161
  129. package/components/Tabs/Tabs.module.js +28 -0
  130. package/components/ThemeToggle/ThemeToggle.d.ts +2 -0
  131. package/components/ThemeToggle/ThemeToggle.js +122 -97
  132. package/components/ThemeToggle/ThemeToggle.module.js +13 -0
  133. package/components/Timeline/GanttTimeline.js +357 -318
  134. package/components/Timeline/GanttTimeline.module.js +29 -0
  135. package/components/Timeline/HistoryTimeline.js +486 -450
  136. package/components/Timeline/HistoryTimeline.module.js +31 -0
  137. package/components/Timeline/Timeline.module.js +76 -0
  138. package/components/Timeline/TimelineShared.d.ts +7 -7
  139. package/components/Timeline/TimelineShared.js +288 -279
  140. package/components/Timeline/TraceEventDetails.d.ts +3 -3
  141. package/components/Timeline/TraceEventDetails.js +245 -178
  142. package/components/Timeline/TraceTimeline.js +823 -783
  143. package/components/Timeline/TraceTimeline.module.js +98 -0
  144. package/components/Timeline/historyLayout.js +336 -263
  145. package/components/Timeline/timelineCore.js +208 -183
  146. package/components/Timeline/traceEvent.js +59 -61
  147. package/components/Timeline/traceLayout.js +101 -90
  148. package/components/Timeline/useTimeline.js +76 -79
  149. package/components/Timer/Timer.js +190 -156
  150. package/components/Timer/Timer.module.js +29 -0
  151. package/components/Toast/Toast.d.ts +1 -1
  152. package/components/Toast/Toast.js +128 -128
  153. package/components/Toast/Toast.module.js +37 -0
  154. package/components/Toast/toastStore.js +58 -62
  155. package/components/ToggleIconButton/ToggleIconButton.js +35 -57
  156. package/components/ToggleIconButton/ToggleIconButton.module.js +15 -0
  157. package/components/Tooltip/Tooltip.d.ts +1 -1
  158. package/components/Tooltip/Tooltip.js +76 -85
  159. package/components/Tooltip/Tooltip.module.js +17 -0
  160. package/components/Typography/Typography.js +11 -36
  161. package/components/Typography/Typography.module.js +30 -0
  162. package/components/inputs/Checkbox/Checkbox.js +27 -51
  163. package/components/inputs/Checkbox/Checkbox.module.js +10 -0
  164. package/components/inputs/Checkbox/CheckboxGroup.js +53 -111
  165. package/components/inputs/Checkbox/CheckboxGroup.module.js +17 -0
  166. package/components/inputs/DatePicker/CalendarPanel.d.ts +1 -1
  167. package/components/inputs/DatePicker/CalendarPanel.js +263 -286
  168. package/components/inputs/DatePicker/CalendarPanel.module.js +23 -0
  169. package/components/inputs/DatePicker/DatePicker.js +115 -142
  170. package/components/inputs/DatePicker/DatePicker.module.js +14 -0
  171. package/components/inputs/DatePicker/dateUtils.js +32 -41
  172. package/components/inputs/DateTimePicker/DateTimePicker.js +226 -232
  173. package/components/inputs/DateTimePicker/DateTimePicker.module.js +20 -0
  174. package/components/inputs/DateTimePicker/DateTimeSegments.js +273 -252
  175. package/components/inputs/DateTimePicker/TimeField.d.ts +1 -1
  176. package/components/inputs/DateTimePicker/TimeField.js +131 -132
  177. package/components/inputs/DateTimePicker/timeZoneUtils.js +95 -92
  178. package/components/inputs/Input/Input.js +98 -109
  179. package/components/inputs/Input/Input.module.js +15 -0
  180. package/components/inputs/NumberInput/NumberInput.js +112 -132
  181. package/components/inputs/NumberInput/NumberInput.module.js +14 -0
  182. package/components/inputs/Radio/Radio.js +50 -73
  183. package/components/inputs/Radio/Radio.module.js +9 -0
  184. package/components/inputs/SearchInput/SearchInput.js +98 -115
  185. package/components/inputs/SearchInput/SearchInput.module.js +8 -0
  186. package/components/inputs/Select/Select.js +555 -682
  187. package/components/inputs/Select/Select.module.js +38 -0
  188. package/components/inputs/Slider/Slider.js +97 -128
  189. package/components/inputs/Slider/Slider.module.js +9 -0
  190. package/components/inputs/Switch/Switch.js +11 -8
  191. package/components/inputs/Textarea/Textarea.js +42 -58
  192. package/components/inputs/Textarea/Textarea.module.js +14 -0
  193. package/hooks/useClickOutside.js +17 -14
  194. package/hooks/useDebouncedValue.js +13 -14
  195. package/hooks/useElementSize.js +27 -22
  196. package/hooks/useEscapeLayer.js +28 -29
  197. package/hooks/useFocusTrap.js +27 -38
  198. package/hooks/useKeyboard.js +76 -64
  199. package/hooks/useMediaQuery.js +10 -15
  200. package/hooks/useNow.js +28 -33
  201. package/hooks/usePersistedState.js +98 -91
  202. package/hooks/usePortalPosition.js +25 -19
  203. package/hooks/useResizable.js +106 -104
  204. package/hooks/useTheme.d.ts +2 -2
  205. package/hooks/useTheme.js +28 -25
  206. package/index.css +2 -1
  207. package/index.d.ts +1 -1
  208. package/index.js +97 -215
  209. package/index.layered.css +2 -3
  210. package/llms.txt +9 -6
  211. package/manifest.json +66 -10
  212. package/package.json +1 -1
  213. package/utils/formatBytes.js +29 -13
  214. package/utils/themeScript.d.ts +2 -0
  215. package/utils/themeScript.js +6 -8
  216. package/utils/timeAgo.js +59 -32
  217. package/components/Accordion/Accordion.module.scss.js +0 -36
  218. package/components/ActionButton/ActionButton.module.scss.js +0 -47
  219. package/components/Alert/Alert.module.scss.js +0 -33
  220. package/components/Avatar/Avatar.module.scss.js +0 -43
  221. package/components/Badge/Badge.module.scss.js +0 -31
  222. package/components/Breadcrumbs/Breadcrumbs.module.scss.js +0 -17
  223. package/components/Button/Button.module.scss.js +0 -47
  224. package/components/Card/Card.module.scss.js +0 -60
  225. package/components/Chart/Chart.module.scss.js +0 -61
  226. package/components/Chip/Chip.module.scss.js +0 -59
  227. package/components/CodeBlock/CodeBlock.module.scss.js +0 -43
  228. package/components/CommandPalette/CommandPalette.module.scss.js +0 -49
  229. package/components/ConfirmDialog/ConfirmDialog.module.scss.js +0 -21
  230. package/components/Divider/Divider.module.scss.js +0 -31
  231. package/components/Draggable/Draggable.module.scss.js +0 -17
  232. package/components/Drawer/Drawer.module.scss.js +0 -119
  233. package/components/Dropdown/Dropdown.module.scss.js +0 -53
  234. package/components/Dropzone/Dropzone.module.scss.js +0 -21
  235. package/components/EmptyState/EmptyState.module.scss.js +0 -25
  236. package/components/Form/Form.module.scss.js +0 -29
  237. package/components/ImageViewer/ImageViewer.module.scss.js +0 -47
  238. package/components/Kbd/Kbd.module.scss.js +0 -17
  239. package/components/KeyValueList/KeyValueList.module.scss.js +0 -43
  240. package/components/Link/Link.module.scss.js +0 -16
  241. package/components/List/List.module.scss.js +0 -21
  242. package/components/Loader/Loader.module.scss.js +0 -70
  243. package/components/Modal/Modal.module.scss.js +0 -33
  244. package/components/PageHeader/PageHeader.module.scss.js +0 -43
  245. package/components/Pagination/Pagination.module.scss.js +0 -23
  246. package/components/Popover/Popover.module.scss.js +0 -21
  247. package/components/ProgressBar/ProgressBar.module.scss.js +0 -51
  248. package/components/RelativeTime/RelativeTime.module.scss.js +0 -7
  249. package/components/SegmentedControl/SegmentedControl.module.scss.js +0 -39
  250. package/components/Skeleton/Skeleton.module.scss.js +0 -25
  251. package/components/Spinner/Spinner.module.scss.js +0 -20
  252. package/components/SplitButton/SplitButton.module.scss.js +0 -57
  253. package/components/SplitPane/SplitPane.module.scss.js +0 -25
  254. package/components/StatCard/StatCard.module.scss.js +0 -72
  255. package/components/StatusDot/StatusDot.module.scss.js +0 -32
  256. package/components/Table/Table.module.scss.js +0 -81
  257. package/components/Tabs/Tabs.module.scss.js +0 -53
  258. package/components/ThemeToggle/ThemeToggle.module.scss.js +0 -23
  259. package/components/Timeline/GanttTimeline.module.scss.js +0 -55
  260. package/components/Timeline/HistoryTimeline.module.scss.js +0 -59
  261. package/components/Timeline/Timeline.module.scss.js +0 -141
  262. package/components/Timeline/TraceTimeline.module.scss.js +0 -189
  263. package/components/Timer/Timer.module.scss.js +0 -55
  264. package/components/Toast/Toast.module.scss.js +0 -62
  265. package/components/ToggleIconButton/ToggleIconButton.module.scss.js +0 -27
  266. package/components/Tooltip/Tooltip.module.scss.js +0 -30
  267. package/components/Typography/Typography.module.scss.js +0 -53
  268. package/components/inputs/Checkbox/Checkbox.module.scss.js +0 -17
  269. package/components/inputs/Checkbox/CheckboxGroup.module.scss.js +0 -31
  270. package/components/inputs/DatePicker/CalendarPanel.module.scss.js +0 -41
  271. package/components/inputs/DatePicker/DatePicker.module.scss.js +0 -25
  272. package/components/inputs/DateTimePicker/DateTimePicker.module.scss.js +0 -37
  273. package/components/inputs/Input/Input.module.scss.js +0 -27
  274. package/components/inputs/NumberInput/NumberInput.module.scss.js +0 -25
  275. package/components/inputs/Radio/Radio.module.scss.js +0 -15
  276. package/components/inputs/SearchInput/SearchInput.module.scss.js +0 -13
  277. package/components/inputs/Select/Select.module.scss.js +0 -73
  278. package/components/inputs/Slider/Slider.module.scss.js +0 -15
  279. package/components/inputs/Textarea/Textarea.module.scss.js +0 -25
@@ -1,783 +1,823 @@
1
- import { jsx as n, jsxs as a, Fragment as D } from "react/jsx-runtime";
2
- import { forwardRef as xl, useRef as p, useState as f, useEffect as le, useCallback as ne, useLayoutEffect as Cl, useMemo as Et } from "react";
3
- import o from "clsx";
4
- import i from "./Timeline.module.scss.js";
5
- import t from "./TraceTimeline.module.scss.js";
6
- import { fmtDateISO as Ne, fmtClockUTC as A, fmtISO as be, ticks as Tl, tickSubdiv as Ml, TL_COLORS as C, fmtDur as Ke, eventMatches as Sl, tint as W, TIMELINE_PALETTE_VARS as Bt } from "./timelineCore.js";
7
- import { traceChipWidth as kl, layoutTraceBand as Ll } from "./traceLayout.js";
8
- import { TimelineSummary as Rl, TimelineZoomControls as Pl, TimelineLegend as El, HighlightText as je, TimelineResizer as Ye, TimelineTooltip as Bl } from "./TimelineShared.js";
9
- import { TraceEventDetails as Dl, EventBadge as Wl, FieldRow as Hl } from "./TraceEventDetails.js";
10
- import { ridOf as se, srcOf as Dt, isRequestEvent as Wt, routeOf as Ht, toText as q } from "./traceEvent.js";
11
- import { useNowTicker as zl, useContainerWidth as Il, useTimelinePan as Al, useWheelZoom as ql, animateScrollTo as zt, wheelZoomAllowed as Fl } from "./useTimeline.js";
12
- import { CopyButton as Je } from "../ActionButton/CopyButton.js";
13
- const N = 84, It = 24, F = 400, Ol = 51, we = 300, tn = xl(
14
- function(At, qt) {
15
- const {
16
- events: u,
17
- title: xe,
18
- meta: Ce,
19
- highlight: Te,
20
- defaultHighlight: Ft,
21
- onHighlightChange: Ot,
22
- showSearch: Ut = !0,
23
- renderSearch: Qe,
24
- services: et,
25
- serviceColors: Vt,
26
- compactRows: $t = !1,
27
- showGridlines: Xt = !0,
28
- showControls: tt = !0,
29
- wheelZoom: Me = "ctrl",
30
- showLegend: Zt = !0,
31
- showSummary: ae = !0,
32
- summaryPlacement: P = "bubble",
33
- summaryDefaultPosition: Gt,
34
- showDock: T = !0,
35
- defaultDock: _t = null,
36
- showExtraFields: Kt = !0,
37
- hiddenFields: lt,
38
- maxHeight: jt = "80vh",
39
- minHeight: Yt = 420,
40
- selectedEventId: O,
41
- defaultSelectedEventId: nt = null,
42
- onEventSelect: Jt,
43
- renderChip: st,
44
- renderTooltip: Se,
45
- renderDetails: ke,
46
- classes: m,
47
- className: Qt,
48
- style: el
49
- } = At, g = p(null), [at, it] = f(null), [ot, rt] = f(!0), [v, Le] = f(null), [tl, ct] = f(null), [E, Re] = f(null), [U, dt] = f(null), [ll, nl] = f(null), [sl, al] = f(null), ut = p(!1), [il, ol] = f(nt), y = O !== void 0 ? O : il, [w, V] = f(
50
- () => T ? _t ?? ((O !== void 0 ? O : nt) != null ? "details" : null) : null
51
- ), [ie, mt] = f(360), [ht, rl] = f(420), pt = p(y);
52
- le(() => {
53
- y != null && y !== pt.current && T && w == null && V("details"), pt.current = y;
54
- }, [y, T, w]);
55
- const [oe, cl] = f({ l: 0, w: 0 }), ft = p(ae);
56
- ft.current = ae;
57
- const Pe = ne(() => {
58
- const e = g.current;
59
- e && cl(
60
- (l) => l.l === e.scrollLeft && l.w === e.clientWidth ? l : { l: e.scrollLeft, w: e.clientWidth }
61
- );
62
- }, []);
63
- le(() => {
64
- ae && Pe();
65
- });
66
- const [$, dl] = f({ l: 0, w: 2e3 }), Ee = p($);
67
- Ee.current = $;
68
- const Be = ne(() => {
69
- const e = g.current;
70
- if (!e) return;
71
- const l = Math.floor(e.scrollLeft / F) * F, s = (Math.ceil((e.clientWidth || 1600) / F) + 1) * F;
72
- (l !== Ee.current.l || s !== Ee.current.w) && dl({ l, w: s });
73
- }, []), gt = u.some((e) => e.end == null), k = zl(gt, 400), re = Il(g), X = Al(g), Z = p(null), G = p(null), vt = p(null), [ul, yt] = f(null), _ = p(null);
74
- le(
75
- () => () => {
76
- _.current && clearTimeout(_.current);
77
- },
78
- []
79
- );
80
- const [ml, hl] = f(Ft ?? ""), De = Te !== void 0 ? Te : ml, M = De.trim(), Nt = (e) => {
81
- Te === void 0 && hl(e), Ot?.(e);
82
- }, bt = Qe ? Qe({ value: De, setValue: Nt }) : Ut ? /* @__PURE__ */ n(
83
- "input",
84
- {
85
- className: o(i.searchInput, m?.search),
86
- placeholder: "Highlight keyword in events…",
87
- "aria-label": "Highlight keyword",
88
- value: De,
89
- onChange: (e) => Nt(e.target.value)
90
- }
91
- ) : null;
92
- let d, K;
93
- u.length ? (d = Math.min(...u.map((e) => e.start)), K = Math.max(d + 1e3, ...u.map((e) => e.end ?? k))) : (d = k - 3e4, K = k + 5e3);
94
- const We = (K - d) * 0.03;
95
- d -= We, K += We;
96
- const He = K - d, wt = Math.max(240, re - N - It), ce = Math.max(wt * 0.45, wt - 210) / He, b = ot || !at ? ce : at, ze = p(ce), H = p(b), Ie = p(d), Ae = p(1e9);
97
- ze.current = ce, H.current = b, Ie.current = d;
98
- const de = p(null);
99
- Cl(() => {
100
- de.current != null && g.current && (g.current.scrollLeft = de.current, de.current = null), Be();
101
- });
102
- const qe = ne((e, l) => {
103
- const s = g.current;
104
- if (!s) return;
105
- const h = H.current || 1e-3, c = Math.max(ze.current ? ze.current * 0.2 : 1e-7, Math.min(10, h * e)), r = (s.scrollLeft + l - N) / h;
106
- de.current = r * c + N - l, rt(!1), it(c);
107
- }, []);
108
- ql(g, (e) => {
109
- if (!Fl(Me, e)) return;
110
- e.preventDefault();
111
- const l = g.current;
112
- l && qe(
113
- Math.exp(-(e.deltaY || e.deltaX) * 22e-4),
114
- e.clientX - l.getBoundingClientRect().left
115
- );
116
- });
117
- const Fe = p(null), pl = ne(() => {
118
- Fe.current == null && (Fe.current = requestAnimationFrame(() => {
119
- Fe.current = null;
120
- const e = g.current;
121
- if (!e || !H.current) return;
122
- const l = Ie.current + Math.max(0, e.scrollLeft + 117 - N) / H.current;
123
- nl(Ne(l)), al(ut.current ? A(l) : null), Be(), ft.current && Pe();
124
- }));
125
- }, [Pe, Be]), Oe = p(null), fl = ne((e) => {
126
- const l = e.clientX;
127
- Oe.current == null && (Oe.current = requestAnimationFrame(() => {
128
- Oe.current = null;
129
- const s = g.current;
130
- if (!s) return;
131
- const h = s.getBoundingClientRect(), c = l - h.left + s.scrollLeft;
132
- if (c < N + 5 || !H.current) {
133
- Re(null);
134
- return;
135
- }
136
- const r = Ie.current + (c - N) / H.current, x = Math.max(88, Math.min(Math.round(c), Ae.current - 88));
137
- Re({ left: Math.round(c), chipLeft: x, label: be(r, !0), t: r });
138
- }));
139
- }, []), ue = (e) => {
140
- O === void 0 && ol(e ? e.id : null), Jt?.(e);
141
- }, Ue = Et(() => {
142
- const e = [];
143
- return (et || []).forEach((l) => {
144
- u.some((s) => s.service === l) && e.push(l);
145
- }), u.forEach((l) => {
146
- e.includes(l.service) || e.push(l.service);
147
- }), e;
148
- }, [u, et]), L = {};
149
- Ue.forEach((e, l) => {
150
- L[e] = Bt[l % Bt.length];
151
- }), Object.assign(L, Vt);
152
- const xt = $t, Ct = xt ? 20 : 26, gl = xt ? 60 : 66, vl = u.map((e) => ({
153
- id: e.id,
154
- left: Math.round(N + (e.start - d) * b),
155
- width: Math.round(Math.max(12, ((e.end ?? k) - e.start) * b)),
156
- labelW: kl(Dt(e), e.service, String(se(e)))
157
- })), me = Ll(vl, {
158
- barH: Ct,
159
- rowH: gl,
160
- chipH: Ol,
161
- minH: Yt
162
- }), he = new Map(me.items.map((e) => [e.id, e])), Ve = Math.ceil(Math.max(N + He * b + It + 60, me.maxExt + 26));
163
- Ae.current = Ve;
164
- const yl = d + (Ve - N) / b, j = Math.max(d, d + ($.l - F - N) / b), pe = Math.min(yl, d + ($.l + $.w + F - N) / b), B = Tl(j, pe, Math.max(1, (pe - j) * b), 64), fe = B.step < 1e3;
165
- ut.current = fe;
166
- const $e = [], Tt = Math.max(d, (B.list.length ? B.list[0].t : j) - B.step);
167
- let Mt = Ne(Tt), St = A(Tt);
168
- B.list.forEach((e) => {
169
- const l = Ne(e.t), s = A(e.t);
170
- $e.push({
171
- left: Math.round(N + (e.t - d) * b),
172
- date: l !== Mt ? l : null,
173
- time: !fe || s !== St ? s : null,
174
- sub: fe ? "." + String(new Date(e.t).getUTCMilliseconds()).padStart(3, "0") : null
175
- }), Mt = l, St = s;
176
- });
177
- const kt = [], z = Ml(B.step);
178
- if (z.parts > 1) {
179
- const e = B.step / z.parts;
180
- if ((pe - j) / e < 2e3)
181
- for (let l = Math.ceil(j / e); l * e <= pe; l++)
182
- l % z.parts !== 0 && kt.push({
183
- left: Math.round(N + (l * e - d) * b),
184
- medium: z.medium > 0 && l % z.parts === z.medium
185
- });
186
- }
187
- const Xe = E ? E.t : null, R = y != null && u.find((e) => e.id === y) || null;
188
- le(() => {
189
- const e = Z.current;
190
- if (e == null) return;
191
- const l = g.current;
192
- if (!l) {
193
- Z.current = null;
194
- return;
195
- }
196
- if (l.clientWidth && l.clientWidth !== re) return;
197
- Z.current = null;
198
- const s = he.get(e);
199
- s && zt(l, { left: Math.max(0, s.left + s.width / 2 - l.clientWidth / 2) });
200
- }), le(() => {
201
- const e = G.current;
202
- if (e == null) return;
203
- const l = vt.current;
204
- if (!l) return;
205
- G.current = null;
206
- const s = typeof CSS < "u" && typeof CSS.escape == "function" ? CSS.escape(e) : e.replace(/"/g, '\\"'), h = l.querySelector(`[data-crk-log-id="${s}"]`);
207
- if (!h) return;
208
- const c = Math.max(
209
- 0,
210
- l.scrollTop + h.getBoundingClientRect().top - l.getBoundingClientRect().top - 8
211
- );
212
- zt(l, { top: c }, 600), yt(e), _.current && clearTimeout(_.current), _.current = setTimeout(() => yt(null), 1200);
213
- });
214
- const Nl = (e, l) => {
215
- const s = he.get(e.id);
216
- if (!s) return;
217
- const h = e.end == null, c = (e.end ?? k) - e.start;
218
- if (dt({
219
- left: s.left,
220
- chipLeft: Math.max(88, Math.min(s.left, Ae.current - 88)),
221
- label: be(e.start, !0)
222
- }), ct(e.id), y === e.id) return;
223
- const r = g.current, x = r ? r.getBoundingClientRect() : { left: 0 }, J = r ? r.scrollLeft : 0, ge = window.innerWidth || 1200, I = window.innerHeight || 800, ve = s.showLabel ? s.labelW : 0, Q = s.showLabel ? s.labelX : s.left, _e = x.left - J + Math.min(s.left, Q), ee = x.left - J + Math.max(s.left + s.width, Q + ve), te = l.currentTarget.getBoundingClientRect();
224
- let S = ee + 28, ye = Math.max(95, Math.min(l.clientY, I - 120));
225
- S + we > ge - 12 && (S = _e - we - 28), S < 12 && (S = Math.max(12, Math.min(ge - we - 12, l.clientX - we / 2)), ye = te.bottom + 108, ye > I - 95 && (ye = Math.max(95, te.top - 108)));
226
- const Pt = Wt(e);
227
- Le({
228
- id: e.id,
229
- x: S,
230
- y: ye,
231
- rid: String(se(e)),
232
- route: Ht(e),
233
- label: e.label || (Pt ? (e.method || "GET") + " " + (e.url ? e.url.replace(/^https?:\/\/[^/]+/, "") : e.id) : e.message || ""),
234
- time: be(e.start, !0),
235
- durLine: h ? (Pt ? "in flight · " : "ongoing · ") + Ke(c) + " so far" : Ke(c) + (typeof e.status == "number" ? " · status " + e.status : e.level ? " · " + e.level : ""),
236
- url: e.url || ""
237
- });
238
- }, bl = () => {
239
- Le(null), dt(null), ct(null);
240
- }, wl = R ? R.end == null : !1, Ze = T ? w === "details" : R != null, Lt = T && w === "log", Ge = () => {
241
- ue(null), T && V(null);
242
- }, Rt = Et(() => u.slice().sort((e, l) => e.start - l.start), [u]), Y = ae ? /* @__PURE__ */ n(
243
- Rl,
244
- {
245
- className: m?.summary,
246
- placement: P,
247
- floatingDefaultPosition: Gt,
248
- bubbleGlyphColors: Ue.slice(0, 3).map((e) => L[e]),
249
- items: Rt.map((e, l) => {
250
- const s = he.get(e.id);
251
- return {
252
- id: e.id,
253
- number: String(l + 1).padStart(2, "0"),
254
- label: String(se(e)),
255
- color: L[e.service] || C.body,
256
- time: A(e.start),
257
- inView: !s || !oe.w ? !0 : s.left < oe.l + oe.w && s.left + s.width > oe.l,
258
- selected: y === e.id
259
- };
260
- }),
261
- onPick: (e) => {
262
- const l = u.find((s) => s.id === e);
263
- l && (ue(l), w === "log" && (G.current = e)), Z.current = e;
264
- }
265
- }
266
- ) : null;
267
- return /* @__PURE__ */ a("div", { ref: qt, className: o(i.root, m?.root, Qt), style: el, children: [
268
- (tt || bt || xe != null || Ce != null) && /* @__PURE__ */ a("div", { className: o(i.toolbar, m?.toolbar), children: [
269
- /* @__PURE__ */ a("div", { className: i.toolbarText, children: [
270
- xe != null && /* @__PURE__ */ n("span", { className: i.toolbarTitle, children: xe }),
271
- /* @__PURE__ */ n("span", { className: i.toolbarMeta, children: Ce ?? (u.length ? `${u.length} events · span ${Ke(He - 2 * We)} · times in UTC` : "No events") })
272
- ] }),
273
- bt,
274
- tt && /* @__PURE__ */ n(
275
- Pl,
276
- {
277
- zoomPct: `${Math.round(b / ce * 100)}%`,
278
- fitActive: ot,
279
- onZoomIn: () => qe(1.5, re / 2),
280
- onZoomOut: () => qe(1 / 1.5, re / 2),
281
- onFit: () => {
282
- rt(!0), it(null);
283
- },
284
- hint: Me === "none" ? "drag pans" : (Me === "ctrl" ? "Ctrl+scroll zooms" : "scroll zooms") + " · drag pans"
285
- }
286
- )
287
- ] }),
288
- Zt && /* @__PURE__ */ n(
289
- El,
290
- {
291
- className: m?.legend,
292
- items: Ue.map((e) => ({ name: e, color: L[e] }))
293
- }
294
- ),
295
- P === "top" && Y,
296
- /* @__PURE__ */ a("div", { className: i.layout, children: [
297
- P === "left" && Y,
298
- /* @__PURE__ */ a("div", { className: i.main, children: [
299
- /* @__PURE__ */ a("div", { className: i.cardWrap, children: [
300
- /* @__PURE__ */ n(
301
- "div",
302
- {
303
- className: o(
304
- i.card,
305
- (Ze || Lt) && t.cardFlushRight,
306
- m?.card
307
- ),
308
- children: /* @__PURE__ */ n(
309
- "div",
310
- {
311
- ref: g,
312
- className: o(i.scroller, t.scroller, m?.scroller),
313
- style: { maxHeight: jt },
314
- onPointerDown: X.onPointerDown,
315
- onPointerMove: X.onPointerMove,
316
- onPointerUp: X.onPointerUp,
317
- onPointerLeave: () => {
318
- X.onPointerUp(), Re(null);
319
- },
320
- onMouseMove: fl,
321
- onScroll: pl,
322
- children: /* @__PURE__ */ a("div", { className: t.inner, style: { width: Ve }, children: [
323
- Xt && $e.map((e, l) => /* @__PURE__ */ n("div", { className: t.gridline, style: { left: e.left } }, l)),
324
- gt && /* @__PURE__ */ n(
325
- "div",
326
- {
327
- className: t.nowLine,
328
- style: { left: Math.round(N + (k - d) * b) }
329
- }
330
- ),
331
- E && !v && /* @__PURE__ */ n("div", { className: t.cursorLine, style: { left: E.left } }),
332
- U && /* @__PURE__ */ n("div", { className: t.eventLine, style: { left: U.left } }),
333
- /* @__PURE__ */ a("div", { className: o(t.axis, m?.axis), children: [
334
- /* @__PURE__ */ n("div", { className: t.axisDivider }),
335
- /* @__PURE__ */ a("div", { className: t.axisSticky, children: [
336
- /* @__PURE__ */ n("span", { className: t.axisUtc, children: "UTC" }),
337
- /* @__PURE__ */ n("span", { className: t.axisViewDate, children: ll || (u.length ? Ne(d) : "") }),
338
- fe && /* @__PURE__ */ n("span", { className: t.axisViewTime, children: sl || A(d) })
339
- ] }),
340
- $e.map((e, l) => /* @__PURE__ */ a("span", { children: [
341
- e.date && /* @__PURE__ */ n("span", { className: t.axisDateLabel, style: { left: e.left }, children: e.date }),
342
- e.time && /* @__PURE__ */ n("span", { className: t.axisTickLabel, style: { left: e.left }, children: e.time }),
343
- e.sub && /* @__PURE__ */ n("span", { className: t.axisSubLabel, style: { left: e.left }, children: e.sub }),
344
- /* @__PURE__ */ n("span", { className: t.axisTickMark, style: { left: e.left } })
345
- ] }, l)),
346
- kt.map((e, l) => /* @__PURE__ */ n(
347
- "span",
348
- {
349
- className: o(t.axisMinorMark, e.medium && t.axisMinorMedium),
350
- style: { left: e.left }
351
- },
352
- l
353
- )),
354
- E && !v && /* @__PURE__ */ n("div", { className: t.axisChip, style: { left: E.chipLeft }, children: E.label }),
355
- U && /* @__PURE__ */ a(
356
- "div",
357
- {
358
- className: o(t.axisChip, t.axisChipEvent),
359
- style: { left: U.chipLeft },
360
- children: [
361
- "▸ ",
362
- U.label
363
- ]
364
- }
365
- )
366
- ] }),
367
- /* @__PURE__ */ a("div", { className: t.lane, style: { height: me.h }, children: [
368
- /* @__PURE__ */ n("div", { className: t.axisLine, style: { top: me.axisY } }),
369
- u.map((e) => {
370
- const l = he.get(e.id);
371
- if (!l) return null;
372
- const s = L[e.service] || C.body, h = e.end == null, c = Sl(e, M, lt), r = Xe != null && Xe >= e.start && Xe <= (e.end ?? k), x = tl === e.id, J = M && !c ? 0.25 : 1, ge = String(se(e)), I = Dt(e), ve = L[I] || C.body, Q = L[e.service] || C.body, _e = x ? `0 0 0 3px ${W(s, 55)}, 0 4px 14px rgba(35,32,28,.22)` : M && c ? `0 0 0 3px ${C.hlRing}` : y === e.id ? `0 0 0 3px ${C.selectedRing}` : r ? `0 0 0 3px ${W(s, 30)}` : "none", ee = x ? s : r ? C.stemHot : C.stem, te = {
373
- onClick: () => {
374
- if (X.wasDragSuppressed()) return;
375
- Le(null);
376
- const S = y === e.id ? null : e;
377
- ue(S), S && w === "log" && (G.current = S.id);
378
- },
379
- onMouseEnter: (S) => Nl(e, S),
380
- onMouseLeave: bl
381
- };
382
- return /* @__PURE__ */ a("span", { children: [
383
- l.showLabel && /* @__PURE__ */ a(D, { children: [
384
- l.conn && !l.hconn && /* @__PURE__ */ n(
385
- "div",
386
- {
387
- className: t.stem,
388
- style: {
389
- left: l.left,
390
- top: l.connTop,
391
- height: l.connH,
392
- background: ee
393
- }
394
- }
395
- ),
396
- l.conn && l.hconn && /* @__PURE__ */ a(D, { children: [
397
- /* @__PURE__ */ n(
398
- "div",
399
- {
400
- className: t.stem,
401
- style: {
402
- left: l.left,
403
- top: l.connTop,
404
- height: l.connH,
405
- background: ee
406
- }
407
- }
408
- ),
409
- /* @__PURE__ */ n(
410
- "div",
411
- {
412
- className: t.elbow,
413
- style: {
414
- left: l.hconnLeft,
415
- top: l.hconnTop,
416
- width: l.hconnW,
417
- background: ee
418
- }
419
- }
420
- )
421
- ] }),
422
- /* @__PURE__ */ n(
423
- "div",
424
- {
425
- ...te,
426
- className: o(t.chip, m?.chip),
427
- style: {
428
- left: l.labelX,
429
- top: l.labelTop,
430
- opacity: J,
431
- background: x ? W(s, 7) : M && c ? C.hlWashSoft : void 0,
432
- borderColor: x ? s : M && c ? C.hlBorder : r ? s : void 0,
433
- boxShadow: x ? `0 0 0 2px ${W(s, 40)}, 0 4px 12px rgba(35,32,28,.16)` : "0 1px 2px rgba(35,32,28,.06)"
434
- },
435
- children: st ? st(e, {
436
- color: s,
437
- pending: h,
438
- durationMs: (e.end ?? k) - e.start
439
- }) : /* @__PURE__ */ a(D, { children: [
440
- /* @__PURE__ */ a("div", { children: [
441
- I && /* @__PURE__ */ a(D, { children: [
442
- /* @__PURE__ */ n(
443
- "span",
444
- {
445
- className: t.chipBadge,
446
- style: {
447
- background: W(ve, 14),
448
- color: ve
449
- },
450
- children: I
451
- }
452
- ),
453
- /* @__PURE__ */ n("span", { className: t.chipArrow, children: " → " })
454
- ] }),
455
- /* @__PURE__ */ n(
456
- "span",
457
- {
458
- className: t.chipBadge,
459
- style: { background: W(Q, 14), color: Q },
460
- children: e.service
461
- }
462
- )
463
- ] }),
464
- /* @__PURE__ */ n("div", { className: t.chipOp, children: /* @__PURE__ */ n(je, { text: ge, query: M }) }),
465
- /* @__PURE__ */ n("div", { className: t.chipTime, children: be(e.start, !0) })
466
- ] })
467
- }
468
- )
469
- ] }),
470
- /* @__PURE__ */ n(
471
- "div",
472
- {
473
- ...te,
474
- className: o(t.bar, h && t.barPending, m?.bar),
475
- style: {
476
- left: l.left,
477
- top: l.barTop,
478
- width: l.width,
479
- height: Ct,
480
- background: M && c ? C.hlBarBg : W(s, 22),
481
- borderColor: s,
482
- opacity: J,
483
- boxShadow: _e
484
- },
485
- children: h && /* @__PURE__ */ n(
486
- "span",
487
- {
488
- className: o(i.pulseDot, t.barDot),
489
- style: { background: s }
490
- }
491
- )
492
- }
493
- )
494
- ] }, e.id);
495
- })
496
- ] })
497
- ] })
498
- }
499
- )
500
- }
501
- ),
502
- Ze && R && ke && /* @__PURE__ */ a("div", { className: t.dockCol, style: { flexBasis: ie }, children: [
503
- /* @__PURE__ */ n(
504
- Ye,
505
- {
506
- panel: "right",
507
- width: ie,
508
- min: 280,
509
- max: 640,
510
- onResize: mt,
511
- label: "Resize details drawer",
512
- className: t.dockColResizer
513
- }
514
- ),
515
- /* @__PURE__ */ n("aside", { className: o(i.aside, t.drawerCustom, m?.drawer), children: ke(R, { close: Ge, pending: wl }) })
516
- ] }),
517
- Ze && !(R && ke) && /* @__PURE__ */ a("div", { className: t.dockCol, style: { flexBasis: ie }, children: [
518
- /* @__PURE__ */ n(
519
- Ye,
520
- {
521
- panel: "right",
522
- width: ie,
523
- min: 280,
524
- max: 640,
525
- onResize: mt,
526
- label: "Resize details drawer",
527
- className: t.dockColResizer
528
- }
529
- ),
530
- /* @__PURE__ */ a("aside", { className: o(i.aside, T && t.dockAside, m?.drawer), children: [
531
- T && /* @__PURE__ */ a("div", { className: t.dockHead, children: [
532
- /* @__PURE__ */ n("span", { className: t.dockTitle, children: "Event details" }),
533
- /* @__PURE__ */ n("div", { className: t.drawerSpacer }),
534
- /* @__PURE__ */ n(
535
- "button",
536
- {
537
- type: "button",
538
- className: i.asideClose,
539
- "aria-label": "Close details",
540
- onClick: Ge,
541
- children: "✕"
542
- }
543
- )
544
- ] }),
545
- R ? /* @__PURE__ */ n(
546
- Dl,
547
- {
548
- event: R,
549
- now: k,
550
- highlight: M,
551
- showExtraFields: Kt,
552
- hiddenFields: lt,
553
- onClose: T ? void 0 : Ge,
554
- className: T ? t.dockScroll : void 0
555
- }
556
- ) : /* @__PURE__ */ n("div", { className: t.dockEmpty, children: "Click an event on the timeline to inspect it." })
557
- ] })
558
- ] }),
559
- Lt && /* @__PURE__ */ a("div", { className: t.dockCol, style: { flexBasis: ht }, children: [
560
- /* @__PURE__ */ n(
561
- Ye,
562
- {
563
- panel: "right",
564
- width: ht,
565
- min: 320,
566
- max: 680,
567
- onResize: rl,
568
- label: "Resize log drawer",
569
- className: t.dockColResizer
570
- }
571
- ),
572
- /* @__PURE__ */ a("aside", { className: o(i.aside, t.dockAside, m?.log), children: [
573
- /* @__PURE__ */ a("div", { className: t.dockHead, children: [
574
- /* @__PURE__ */ n("span", { className: t.dockTitle, children: "Full log" }),
575
- /* @__PURE__ */ a("span", { className: t.dockCount, children: [
576
- u.length,
577
- " events"
578
- ] }),
579
- /* @__PURE__ */ n("div", { className: t.drawerSpacer }),
580
- /* @__PURE__ */ n(
581
- "button",
582
- {
583
- type: "button",
584
- className: i.asideClose,
585
- "aria-label": "Close full log",
586
- onClick: () => V(null),
587
- children: "✕"
588
- }
589
- )
590
- ] }),
591
- /* @__PURE__ */ n("div", { ref: vt, className: o(t.dockScroll, t.logBody), children: Rt.map((e, l) => {
592
- const s = e.end == null, h = e.url ? e.url.replace(/^https?:\/\/[^/]+/, "") : "", c = Wt(e);
593
- return /* @__PURE__ */ a(
594
- "div",
595
- {
596
- "data-crk-log-id": e.id,
597
- className: o(
598
- t.logEntry,
599
- y === e.id && t.logEntrySelected,
600
- ul === e.id && t.logEntryFlash
601
- ),
602
- onClick: () => {
603
- ue(e), Z.current = e.id;
604
- },
605
- children: [
606
- /* @__PURE__ */ a("div", { className: t.logTop, children: [
607
- /* @__PURE__ */ n("span", { className: t.logNum, children: String(l + 1).padStart(2, "0") }),
608
- e.method && /* @__PURE__ */ n("span", { className: o(t.methodBadge, t.badgeSm), children: e.method }),
609
- /* @__PURE__ */ n(Wl, { event: e, pending: s, small: !0 }),
610
- /* @__PURE__ */ n("span", { className: t.logPair, children: Ht(e) }),
611
- /* @__PURE__ */ n("div", { className: t.drawerSpacer }),
612
- /* @__PURE__ */ n("span", { className: t.logClock, children: A(e.start) })
613
- ] }),
614
- /* @__PURE__ */ n("div", { className: t.logOp, children: /* @__PURE__ */ n(je, { text: String(se(e)), query: M }) }),
615
- h && /* @__PURE__ */ n("div", { className: t.logPath, children: h }),
616
- e.message && /* @__PURE__ */ n("div", { className: t.logMessage, children: /* @__PURE__ */ n(je, { text: e.message, query: M }) }),
617
- !!e.details?.length && // the fields carry their own copy buttons, so the
618
- // block swallows clicks rather than selecting the row
619
- /* @__PURE__ */ n(
620
- "div",
621
- {
622
- className: o(t.fieldList, t.logFields),
623
- onClick: (r) => r.stopPropagation(),
624
- children: e.details.map((r, x) => /* @__PURE__ */ n(Hl, { field: r, query: M }, r.label + x))
625
- }
626
- ),
627
- e.payload != null && /* @__PURE__ */ a(D, { children: [
628
- /* @__PURE__ */ a("div", { className: t.logPayloadHead, children: [
629
- /* @__PURE__ */ n("span", { className: t.logPayloadLabel, children: "Payload" }),
630
- /* @__PURE__ */ n(
631
- "span",
632
- {
633
- className: t.copyStop,
634
- onClick: (r) => r.stopPropagation(),
635
- children: /* @__PURE__ */ n(
636
- Je,
637
- {
638
- size: "sm",
639
- className: t.payloadCopy,
640
- value: () => q(e.payload),
641
- "aria-label": "Copy payload"
642
- }
643
- )
644
- }
645
- )
646
- ] }),
647
- /* @__PURE__ */ n("pre", { className: o(i.asideRaw, t.logPre), children: q(e.payload) })
648
- ] }),
649
- c && /* @__PURE__ */ a(D, { children: [
650
- /* @__PURE__ */ a("div", { className: t.logPayloadHead, children: [
651
- /* @__PURE__ */ n("span", { className: t.logPayloadLabel, children: "Request" }),
652
- e.reqBody != null && /* @__PURE__ */ n(
653
- "span",
654
- {
655
- className: t.copyStop,
656
- onClick: (r) => r.stopPropagation(),
657
- children: /* @__PURE__ */ n(
658
- Je,
659
- {
660
- size: "sm",
661
- className: t.payloadCopy,
662
- value: () => q(e.reqBody),
663
- "aria-label": "Copy request payload"
664
- }
665
- )
666
- }
667
- )
668
- ] }),
669
- /* @__PURE__ */ n("pre", { className: o(i.asideRaw, t.logPre), children: e.reqBody != null ? q(e.reqBody) : "(empty)" }),
670
- /* @__PURE__ */ a("div", { className: t.logPayloadHead, children: [
671
- /* @__PURE__ */ n("span", { className: t.logPayloadLabel, children: "Response" }),
672
- !s && e.resBody != null && /* @__PURE__ */ n(
673
- "span",
674
- {
675
- className: t.copyStop,
676
- onClick: (r) => r.stopPropagation(),
677
- children: /* @__PURE__ */ n(
678
- Je,
679
- {
680
- size: "sm",
681
- className: t.payloadCopy,
682
- value: () => q(e.resBody),
683
- "aria-label": "Copy response payload"
684
- }
685
- )
686
- }
687
- )
688
- ] }),
689
- s ? /* @__PURE__ */ a("div", { className: t.awaiting, children: [
690
- /* @__PURE__ */ n("span", { className: o(i.pulseDot, t.awaitingDot) }),
691
- "Awaiting response…"
692
- ] }) : /* @__PURE__ */ n("pre", { className: o(i.asideRaw, t.logPre), children: e.resBody != null ? q(e.resBody) : "(empty)" })
693
- ] }),
694
- !c && s && /* @__PURE__ */ a("div", { className: t.awaiting, children: [
695
- /* @__PURE__ */ n("span", { className: o(i.pulseDot, t.awaitingDot) }),
696
- "Still ongoing…"
697
- ] })
698
- ]
699
- },
700
- e.id
701
- );
702
- }) })
703
- ] })
704
- ] }),
705
- P === "bubble" && Y
706
- ] }),
707
- /* @__PURE__ */ n("div", { className: o(i.footnote, m?.footnote), children: "Click an event to open its details in the side panel · dashed pills are still in flight" })
708
- ] }),
709
- (P === "right" || P === "floating") && Y,
710
- T && /* @__PURE__ */ a("div", { className: o(t.rail, m?.rail), children: [
711
- /* @__PURE__ */ n(
712
- "button",
713
- {
714
- type: "button",
715
- title: "Event details",
716
- "aria-label": "Toggle event details drawer",
717
- "aria-pressed": w === "details",
718
- className: o(t.railBtn, w === "details" && t.railBtnActive),
719
- onClick: () => V(w === "details" ? null : "details"),
720
- children: /* @__PURE__ */ a("span", { className: t.railGlyphDetails, "aria-hidden": !0, children: [
721
- /* @__PURE__ */ n("span", {}),
722
- /* @__PURE__ */ n("span", {}),
723
- /* @__PURE__ */ n("span", {})
724
- ] })
725
- }
726
- ),
727
- /* @__PURE__ */ n(
728
- "button",
729
- {
730
- type: "button",
731
- title: "Full log",
732
- "aria-label": "Toggle full log drawer",
733
- "aria-pressed": w === "log",
734
- className: o(t.railBtn, w === "log" && t.railBtnActive),
735
- onClick: () => {
736
- const e = w === "log" ? null : "log";
737
- e === "log" && y != null && (G.current = y), V(e);
738
- },
739
- children: /* @__PURE__ */ a("span", { className: t.railGlyphLog, "aria-hidden": !0, children: [
740
- /* @__PURE__ */ n("span", {}),
741
- /* @__PURE__ */ n("span", {}),
742
- /* @__PURE__ */ n("span", {})
743
- ] })
744
- }
745
- )
746
- ] })
747
- ] }),
748
- P === "bottom" && Y,
749
- v && (() => {
750
- const e = u.find((s) => s.id === v.id), l = e && Se ? Se(e, {
751
- color: L[e.service] || C.body,
752
- pending: e.end == null,
753
- durationMs: (e.end ?? k) - e.start
754
- }) : void 0;
755
- return Se && l == null ? null : /* @__PURE__ */ n(Bl, { x: v.x, y: v.y, className: m?.tooltip, children: l !== void 0 ? l : /* @__PURE__ */ a(D, { children: [
756
- /* @__PURE__ */ n("div", { className: o(i.tooltipTitle, i.tooltipMono), children: v.rid }),
757
- /* @__PURE__ */ n("div", { className: i.tooltipLine, style: { marginTop: 4 }, children: v.route }),
758
- v.label && /* @__PURE__ */ n(
759
- "div",
760
- {
761
- className: o(i.tooltipLine, i.tooltipMono),
762
- style: { marginTop: 2 },
763
- children: v.label
764
- }
765
- ),
766
- /* @__PURE__ */ n("div", { className: i.tooltipLine, style: { marginTop: 4 }, children: v.time }),
767
- /* @__PURE__ */ n("div", { className: i.tooltipLine, children: v.durLine }),
768
- v.url && /* @__PURE__ */ n(
769
- "div",
770
- {
771
- className: o(i.tooltipDim, i.tooltipMono),
772
- style: { marginTop: 4, wordBreak: "break-all", fontSize: "10.5px" },
773
- children: v.url
774
- }
775
- )
776
- ] }) });
777
- })()
778
- ] });
779
- }
780
- );
781
- export {
782
- tn as TraceTimeline
783
- };
1
+ import e from "./Timeline.module.js";
2
+ import t from "./TraceTimeline.module.js";
3
+ import { TIMELINE_PALETTE_VARS as n, TL_COLORS as r, eventMatches as i, fmtClockUTC as a, fmtDateISO as o, fmtDur as s, fmtISO as ee, tickSubdiv as c, ticks as l, tint as u } from "./timelineCore.js";
4
+ import { layoutTraceBand as d, traceChipWidth as f } from "./traceLayout.js";
5
+ import { HighlightText as te, TimelineLegend as ne, TimelineResizer as p, TimelineSummary as m, TimelineTooltip as h, TimelineZoomControls as re } from "./TimelineShared.js";
6
+ import { CopyButton as g } from "../ActionButton/CopyButton.js";
7
+ import { EventBadge as ie, FieldRow as ae, TraceEventDetails as oe } from "./TraceEventDetails.js";
8
+ import { isRequestEvent as se, ridOf as _, routeOf as ce, srcOf as le, toText as v } from "./traceEvent.js";
9
+ import { animateScrollTo as ue, useContainerWidth as de, useNowTicker as fe, useTimelinePan as pe, useWheelZoom as me, wheelZoomAllowed as he } from "./useTimeline.js";
10
+ import { forwardRef as ge, useCallback as y, useEffect as _e, useLayoutEffect as ve, useMemo as ye, useRef as b, useState as x } from "react";
11
+ import S from "clsx";
12
+ import { Fragment as C, jsx as w, jsxs as T } from "react/jsx-runtime";
13
+ // src/components/Timeline/TraceTimeline.tsx
14
+ var E = 84, be = 24, D = 400, xe = 51, Se = 300, Ce = ge(function(ge, Ce) {
15
+ let { events: O, title: we, meta: Te, highlight: Ee, defaultHighlight: De, onHighlightChange: Oe, showSearch: ke = !0, renderSearch: Ae, services: je, serviceColors: Me, compactRows: Ne = !1, showGridlines: Pe = !0, showControls: Fe = !0, wheelZoom: Ie = "ctrl", showLegend: Le = !0, showSummary: Re = !0, summaryPlacement: k = "bubble", summaryDefaultPosition: ze, showDock: A = !0, defaultDock: Be = null, showExtraFields: Ve = !0, hiddenFields: He, maxHeight: Ue = "80vh", minHeight: We = 420, selectedEventId: Ge, defaultSelectedEventId: Ke = null, onEventSelect: qe, renderChip: Je, renderTooltip: Ye, renderDetails: Xe, classes: j, className: Ze, style: Qe } = ge, M = b(null), [$e, et] = x(null), [tt, nt] = x(!0), [N, rt] = x(null), [it, at] = x(null), [P, ot] = x(null), [F, st] = x(null), [ct, lt] = x(null), [ut, dt] = x(null), ft = b(!1), [pt, mt] = x(Ke), I = Ge === void 0 ? pt : Ge, [L, ht] = x(() => A ? Be ?? ((Ge === void 0 ? Ke : Ge) == null ? null : "details") : null), [gt, _t] = x(360), [vt, yt] = x(420), bt = b(I);
16
+ _e(() => {
17
+ I != null && I !== bt.current && A && L == null && ht("details"), bt.current = I;
18
+ }, [
19
+ I,
20
+ A,
21
+ L
22
+ ]);
23
+ let [xt, St] = x({
24
+ l: 0,
25
+ w: 0
26
+ }), Ct = b(Re);
27
+ Ct.current = Re;
28
+ let wt = y(() => {
29
+ let e = M.current;
30
+ e && St((t) => t.l === e.scrollLeft && t.w === e.clientWidth ? t : {
31
+ l: e.scrollLeft,
32
+ w: e.clientWidth
33
+ });
34
+ }, []);
35
+ _e(() => {
36
+ Re && wt();
37
+ });
38
+ let [R, Tt] = x({
39
+ l: 0,
40
+ w: 2e3
41
+ }), Et = b(R);
42
+ Et.current = R;
43
+ let Dt = y(() => {
44
+ let e = M.current;
45
+ if (!e) return;
46
+ let t = Math.floor(e.scrollLeft / D) * D, n = (Math.ceil((e.clientWidth || 1600) / D) + 1) * D;
47
+ (t !== Et.current.l || n !== Et.current.w) && Tt({
48
+ l: t,
49
+ w: n
50
+ });
51
+ }, []), Ot = O.some((e) => e.end == null), z = fe(Ot, 400), kt = de(M), B = pe(M), V = b(null), H = b(null), At = b(null), [jt, Mt] = x(null), U = b(null);
52
+ _e(() => () => {
53
+ U.current && clearTimeout(U.current);
54
+ }, []);
55
+ let [Nt, Pt] = x(De ?? ""), Ft = Ee === void 0 ? Nt : Ee, W = Ft.trim(), It = (e) => {
56
+ Ee === void 0 && Pt(e), Oe?.(e);
57
+ }, Lt = Ae ? Ae({
58
+ value: Ft,
59
+ setValue: It
60
+ }) : ke ? /* @__PURE__ */ w("input", {
61
+ className: S(e.searchInput, j?.search),
62
+ placeholder: "Highlight keyword in events…",
63
+ "aria-label": "Highlight keyword",
64
+ value: Ft,
65
+ onChange: (e) => It(e.target.value)
66
+ }) : null, G, K;
67
+ O.length ? (G = Math.min(...O.map((e) => e.start)), K = Math.max(G + 1e3, ...O.map((e) => e.end ?? z))) : (G = z - 3e4, K = z + 5e3);
68
+ let Rt = (K - G) * .03;
69
+ G -= Rt, K += Rt;
70
+ let zt = K - G, Bt = Math.max(240, kt - E - be), Vt = Math.max(Bt * .45, Bt - 210) / zt, q = tt || !$e ? Vt : $e, Ht = b(Vt), J = b(q), Ut = b(G), Wt = b(1e9);
71
+ Ht.current = Vt, J.current = q, Ut.current = G;
72
+ let Gt = b(null);
73
+ ve(() => {
74
+ Gt.current != null && M.current && (M.current.scrollLeft = Gt.current, Gt.current = null), Dt();
75
+ });
76
+ let Kt = y((e, t) => {
77
+ let n = M.current;
78
+ if (!n) return;
79
+ let r = J.current || .001, i = Math.max(Ht.current ? Ht.current * .2 : 1e-7, Math.min(10, r * e)), a = (n.scrollLeft + t - E) / r;
80
+ Gt.current = a * i + E - t, nt(!1), et(i);
81
+ }, []);
82
+ me(M, (e) => {
83
+ if (!he(Ie, e)) return;
84
+ e.preventDefault();
85
+ let t = M.current;
86
+ t && Kt(Math.exp(-(e.deltaY || e.deltaX) * .0022), e.clientX - t.getBoundingClientRect().left);
87
+ });
88
+ let qt = b(null), Jt = y(() => {
89
+ qt.current ??= requestAnimationFrame(() => {
90
+ qt.current = null;
91
+ let e = M.current;
92
+ if (!e || !J.current) return;
93
+ let t = Ut.current + Math.max(0, e.scrollLeft + 117 - E) / J.current;
94
+ lt(o(t)), dt(ft.current ? a(t) : null), Dt(), Ct.current && wt();
95
+ });
96
+ }, [wt, Dt]), Yt = b(null), Xt = y((e) => {
97
+ let t = e.clientX;
98
+ Yt.current ??= requestAnimationFrame(() => {
99
+ Yt.current = null;
100
+ let e = M.current;
101
+ if (!e) return;
102
+ let n = e.getBoundingClientRect(), r = t - n.left + e.scrollLeft;
103
+ if (r < 89 || !J.current) {
104
+ ot(null);
105
+ return;
106
+ }
107
+ let i = Ut.current + (r - E) / J.current, a = Math.max(88, Math.min(Math.round(r), Wt.current - 88));
108
+ ot({
109
+ left: Math.round(r),
110
+ chipLeft: a,
111
+ label: ee(i, !0),
112
+ t: i
113
+ });
114
+ });
115
+ }, []), Zt = (e) => {
116
+ Ge === void 0 && mt(e ? e.id : null), qe?.(e);
117
+ }, Qt = ye(() => {
118
+ let e = [];
119
+ return (je || []).forEach((t) => {
120
+ O.some((e) => e.service === t) && e.push(t);
121
+ }), O.forEach((t) => {
122
+ e.includes(t.service) || e.push(t.service);
123
+ }), e;
124
+ }, [O, je]), Y = {};
125
+ Qt.forEach((e, t) => {
126
+ Y[e] = n[t % n.length];
127
+ }), Object.assign(Y, Me);
128
+ let $t = Ne, en = $t ? 20 : 26, tn = $t ? 60 : 66, nn = O.map((e) => ({
129
+ id: e.id,
130
+ left: Math.round(E + (e.start - G) * q),
131
+ width: Math.round(Math.max(12, ((e.end ?? z) - e.start) * q)),
132
+ labelW: f(le(e), e.service, String(_(e)))
133
+ })), rn = d(nn, {
134
+ barH: en,
135
+ rowH: tn,
136
+ chipH: xe,
137
+ minH: We
138
+ }), an = new Map(rn.items.map((e) => [e.id, e])), on = Math.ceil(Math.max(E + zt * q + be + 60, rn.maxExt + 26));
139
+ Wt.current = on;
140
+ let sn = G + (on - E) / q, X = Math.max(G, G + (R.l - D - E) / q), cn = Math.min(sn, G + (R.l + R.w + D - E) / q), Z = l(X, cn, Math.max(1, (cn - X) * q), 64), ln = Z.step < 1e3;
141
+ ft.current = ln;
142
+ let un = [], dn = Math.max(G, (Z.list.length ? Z.list[0].t : X) - Z.step), fn = o(dn), pn = a(dn);
143
+ Z.list.forEach((e) => {
144
+ let t = o(e.t), n = a(e.t);
145
+ un.push({
146
+ left: Math.round(E + (e.t - G) * q),
147
+ date: t === fn ? null : t,
148
+ time: !ln || n !== pn ? n : null,
149
+ sub: ln ? "." + String(new Date(e.t).getUTCMilliseconds()).padStart(3, "0") : null
150
+ }), fn = t, pn = n;
151
+ });
152
+ let mn = [], Q = c(Z.step);
153
+ if (Q.parts > 1) {
154
+ let e = Z.step / Q.parts;
155
+ if ((cn - X) / e < 2e3) for (let t = Math.ceil(X / e); t * e <= cn; t++) t % Q.parts !== 0 && mn.push({
156
+ left: Math.round(E + (t * e - G) * q),
157
+ medium: Q.medium > 0 && t % Q.parts === Q.medium
158
+ });
159
+ }
160
+ let hn = P ? P.t : null, $ = I == null ? null : O.find((e) => e.id === I) || null;
161
+ _e(() => {
162
+ let e = V.current;
163
+ if (e == null) return;
164
+ let t = M.current;
165
+ if (!t) {
166
+ V.current = null;
167
+ return;
168
+ }
169
+ if (t.clientWidth && t.clientWidth !== kt) return;
170
+ V.current = null;
171
+ let n = an.get(e);
172
+ n && ue(t, { left: Math.max(0, n.left + n.width / 2 - t.clientWidth / 2) });
173
+ }), _e(() => {
174
+ let e = H.current;
175
+ if (e == null) return;
176
+ let t = At.current;
177
+ if (!t) return;
178
+ H.current = null;
179
+ let n = typeof CSS < "u" && typeof CSS.escape == "function" ? CSS.escape(e) : e.replace(/"/g, "\\\""), r = t.querySelector(`[data-crk-log-id="${n}"]`);
180
+ if (!r) return;
181
+ let i = Math.max(0, t.scrollTop + r.getBoundingClientRect().top - t.getBoundingClientRect().top - 8);
182
+ ue(t, { top: i }, 600), Mt(e), U.current && clearTimeout(U.current), U.current = setTimeout(() => Mt(null), 1200);
183
+ });
184
+ let gn = (e, t) => {
185
+ let n = an.get(e.id);
186
+ if (!n) return;
187
+ let r = e.end == null, i = (e.end ?? z) - e.start;
188
+ if (st({
189
+ left: n.left,
190
+ chipLeft: Math.max(88, Math.min(n.left, Wt.current - 88)),
191
+ label: ee(e.start, !0)
192
+ }), at(e.id), I === e.id) return;
193
+ let a = M.current, o = a ? a.getBoundingClientRect() : { left: 0 }, c = a ? a.scrollLeft : 0, l = window.innerWidth || 1200, u = window.innerHeight || 800, d = n.showLabel ? n.labelW : 0, f = n.showLabel ? n.labelX : n.left, te = o.left - c + Math.min(n.left, f), ne = o.left - c + Math.max(n.left + n.width, f + d), p = t.currentTarget.getBoundingClientRect(), m = ne + 28, h = Math.max(95, Math.min(t.clientY, u - 120));
194
+ m + Se > l - 12 && (m = te - Se - 28), m < 12 && (m = Math.max(12, Math.min(l - Se - 12, t.clientX - Se / 2)), h = p.bottom + 108, h > u - 95 && (h = Math.max(95, p.top - 108)));
195
+ let re = se(e);
196
+ rt({
197
+ id: e.id,
198
+ x: m,
199
+ y: h,
200
+ rid: String(_(e)),
201
+ route: ce(e),
202
+ label: e.label || (re ? (e.method || "GET") + " " + (e.url ? e.url.replace(/^https?:\/\/[^/]+/, "") : e.id) : e.message || ""),
203
+ time: ee(e.start, !0),
204
+ durLine: r ? (re ? "in flight · " : "ongoing · ") + s(i) + " so far" : s(i) + (typeof e.status == "number" ? " · status " + e.status : e.level ? " · " + e.level : ""),
205
+ url: e.url || ""
206
+ });
207
+ }, _n = () => {
208
+ rt(null), st(null), at(null);
209
+ }, vn = $ ? $.end == null : !1, yn = A ? L === "details" : $ != null, bn = A && L === "log", xn = () => {
210
+ Zt(null), A && ht(null);
211
+ }, Sn = ye(() => O.slice().sort((e, t) => e.start - t.start), [O]), Cn = Re ? /* @__PURE__ */ w(m, {
212
+ className: j?.summary,
213
+ placement: k,
214
+ floatingDefaultPosition: ze,
215
+ bubbleGlyphColors: Qt.slice(0, 3).map((e) => Y[e]),
216
+ items: Sn.map((e, t) => {
217
+ let n = an.get(e.id);
218
+ return {
219
+ id: e.id,
220
+ number: String(t + 1).padStart(2, "0"),
221
+ label: String(_(e)),
222
+ color: Y[e.service] || r.body,
223
+ time: a(e.start),
224
+ inView: !n || !xt.w || n.left < xt.l + xt.w && n.left + n.width > xt.l,
225
+ selected: I === e.id
226
+ };
227
+ }),
228
+ onPick: (e) => {
229
+ let t = O.find((t) => t.id === e);
230
+ t && (Zt(t), L === "log" && (H.current = e)), V.current = e;
231
+ }
232
+ }) : null;
233
+ return /* @__PURE__ */ T("div", {
234
+ ref: Ce,
235
+ className: S(e.root, j?.root, Ze),
236
+ style: Qe,
237
+ children: [
238
+ (Fe || Lt || we != null || Te != null) && /* @__PURE__ */ T("div", {
239
+ className: S(e.toolbar, j?.toolbar),
240
+ children: [
241
+ /* @__PURE__ */ T("div", {
242
+ className: e.toolbarText,
243
+ children: [we != null && /* @__PURE__ */ w("span", {
244
+ className: e.toolbarTitle,
245
+ children: we
246
+ }), /* @__PURE__ */ w("span", {
247
+ className: e.toolbarMeta,
248
+ children: Te ?? (O.length ? `${O.length} events · span ${s(zt - 2 * Rt)} · times in UTC` : "No events")
249
+ })]
250
+ }),
251
+ Lt,
252
+ Fe && /* @__PURE__ */ w(re, {
253
+ zoomPct: `${Math.round(q / Vt * 100)}%`,
254
+ fitActive: tt,
255
+ onZoomIn: () => Kt(1.5, kt / 2),
256
+ onZoomOut: () => Kt(1 / 1.5, kt / 2),
257
+ onFit: () => {
258
+ nt(!0), et(null);
259
+ },
260
+ hint: Ie === "none" ? "drag pans" : (Ie === "ctrl" ? "Ctrl+scroll zooms" : "scroll zooms") + " · drag pans"
261
+ })
262
+ ]
263
+ }),
264
+ Le && /* @__PURE__ */ w(ne, {
265
+ className: j?.legend,
266
+ items: Qt.map((e) => ({
267
+ name: e,
268
+ color: Y[e]
269
+ }))
270
+ }),
271
+ k === "top" && Cn,
272
+ /* @__PURE__ */ T("div", {
273
+ className: e.layout,
274
+ children: [
275
+ k === "left" && Cn,
276
+ /* @__PURE__ */ T("div", {
277
+ className: e.main,
278
+ children: [/* @__PURE__ */ T("div", {
279
+ className: e.cardWrap,
280
+ children: [
281
+ /* @__PURE__ */ w("div", {
282
+ className: S(e.card, (yn || bn) && t.cardFlushRight, j?.card),
283
+ children: /* @__PURE__ */ w("div", {
284
+ ref: M,
285
+ className: S(e.scroller, t.scroller, j?.scroller),
286
+ style: { maxHeight: Ue },
287
+ onPointerDown: B.onPointerDown,
288
+ onPointerMove: B.onPointerMove,
289
+ onPointerUp: B.onPointerUp,
290
+ onPointerLeave: () => {
291
+ B.onPointerUp(), ot(null);
292
+ },
293
+ onMouseMove: Xt,
294
+ onScroll: Jt,
295
+ children: /* @__PURE__ */ T("div", {
296
+ className: t.inner,
297
+ style: { width: on },
298
+ children: [
299
+ Pe && un.map((e, n) => /* @__PURE__ */ w("div", {
300
+ className: t.gridline,
301
+ style: { left: e.left }
302
+ }, n)),
303
+ Ot && /* @__PURE__ */ w("div", {
304
+ className: t.nowLine,
305
+ style: { left: Math.round(E + (z - G) * q) }
306
+ }),
307
+ P && !N && /* @__PURE__ */ w("div", {
308
+ className: t.cursorLine,
309
+ style: { left: P.left }
310
+ }),
311
+ F && /* @__PURE__ */ w("div", {
312
+ className: t.eventLine,
313
+ style: { left: F.left }
314
+ }),
315
+ /* @__PURE__ */ T("div", {
316
+ className: S(t.axis, j?.axis),
317
+ children: [
318
+ /* @__PURE__ */ w("div", { className: t.axisDivider }),
319
+ /* @__PURE__ */ T("div", {
320
+ className: t.axisSticky,
321
+ children: [
322
+ /* @__PURE__ */ w("span", {
323
+ className: t.axisUtc,
324
+ children: "UTC"
325
+ }),
326
+ /* @__PURE__ */ w("span", {
327
+ className: t.axisViewDate,
328
+ children: ct || (O.length ? o(G) : "")
329
+ }),
330
+ ln && /* @__PURE__ */ w("span", {
331
+ className: t.axisViewTime,
332
+ children: ut || a(G)
333
+ })
334
+ ]
335
+ }),
336
+ un.map((e, n) => /* @__PURE__ */ T("span", { children: [
337
+ e.date && /* @__PURE__ */ w("span", {
338
+ className: t.axisDateLabel,
339
+ style: { left: e.left },
340
+ children: e.date
341
+ }),
342
+ e.time && /* @__PURE__ */ w("span", {
343
+ className: t.axisTickLabel,
344
+ style: { left: e.left },
345
+ children: e.time
346
+ }),
347
+ e.sub && /* @__PURE__ */ w("span", {
348
+ className: t.axisSubLabel,
349
+ style: { left: e.left },
350
+ children: e.sub
351
+ }),
352
+ /* @__PURE__ */ w("span", {
353
+ className: t.axisTickMark,
354
+ style: { left: e.left }
355
+ })
356
+ ] }, n)),
357
+ mn.map((e, n) => /* @__PURE__ */ w("span", {
358
+ className: S(t.axisMinorMark, e.medium && t.axisMinorMedium),
359
+ style: { left: e.left }
360
+ }, n)),
361
+ P && !N && /* @__PURE__ */ w("div", {
362
+ className: t.axisChip,
363
+ style: { left: P.chipLeft },
364
+ children: P.label
365
+ }),
366
+ F && /* @__PURE__ */ T("div", {
367
+ className: S(t.axisChip, t.axisChipEvent),
368
+ style: { left: F.chipLeft },
369
+ children: ["▸ ", F.label]
370
+ })
371
+ ]
372
+ }),
373
+ /* @__PURE__ */ T("div", {
374
+ className: t.lane,
375
+ style: { height: rn.h },
376
+ children: [/* @__PURE__ */ w("div", {
377
+ className: t.axisLine,
378
+ style: { top: rn.axisY }
379
+ }), O.map((n) => {
380
+ let a = an.get(n.id);
381
+ if (!a) return null;
382
+ let o = Y[n.service] || r.body, s = n.end == null, c = i(n, W, He), l = hn != null && hn >= n.start && hn <= (n.end ?? z), d = it === n.id, f = W && !c ? .25 : 1, ne = String(_(n)), p = le(n), m = Y[p] || r.body, h = Y[n.service] || r.body, re = d ? `0 0 0 3px ${u(o, 55)}, 0 4px 14px rgba(35,32,28,.22)` : W && c ? `0 0 0 3px ${r.hlRing}` : I === n.id ? `0 0 0 3px ${r.selectedRing}` : l ? `0 0 0 3px ${u(o, 30)}` : "none", g = d ? o : l ? r.stemHot : r.stem, ie = {
383
+ onClick: () => {
384
+ if (B.wasDragSuppressed()) return;
385
+ rt(null);
386
+ let e = I === n.id ? null : n;
387
+ Zt(e), e && L === "log" && (H.current = e.id);
388
+ },
389
+ onMouseEnter: (e) => gn(n, e),
390
+ onMouseLeave: _n
391
+ };
392
+ return /* @__PURE__ */ T("span", { children: [a.showLabel && /* @__PURE__ */ T(C, { children: [
393
+ a.conn && !a.hconn && /* @__PURE__ */ w("div", {
394
+ className: t.stem,
395
+ style: {
396
+ left: a.left,
397
+ top: a.connTop,
398
+ height: a.connH,
399
+ background: g
400
+ }
401
+ }),
402
+ a.conn && a.hconn && /* @__PURE__ */ T(C, { children: [/* @__PURE__ */ w("div", {
403
+ className: t.stem,
404
+ style: {
405
+ left: a.left,
406
+ top: a.connTop,
407
+ height: a.connH,
408
+ background: g
409
+ }
410
+ }), /* @__PURE__ */ w("div", {
411
+ className: t.elbow,
412
+ style: {
413
+ left: a.hconnLeft,
414
+ top: a.hconnTop,
415
+ width: a.hconnW,
416
+ background: g
417
+ }
418
+ })] }),
419
+ /* @__PURE__ */ w("div", {
420
+ ...ie,
421
+ className: S(t.chip, j?.chip),
422
+ style: {
423
+ left: a.labelX,
424
+ top: a.labelTop,
425
+ opacity: f,
426
+ background: d ? u(o, 7) : W && c ? r.hlWashSoft : void 0,
427
+ borderColor: d ? o : W && c ? r.hlBorder : l ? o : void 0,
428
+ boxShadow: d ? `0 0 0 2px ${u(o, 40)}, 0 4px 12px rgba(35,32,28,.16)` : "0 1px 2px rgba(35,32,28,.06)"
429
+ },
430
+ children: Je ? Je(n, {
431
+ color: o,
432
+ pending: s,
433
+ durationMs: (n.end ?? z) - n.start
434
+ }) : /* @__PURE__ */ T(C, { children: [
435
+ /* @__PURE__ */ T("div", { children: [p && /* @__PURE__ */ T(C, { children: [/* @__PURE__ */ w("span", {
436
+ className: t.chipBadge,
437
+ style: {
438
+ background: u(m, 14),
439
+ color: m
440
+ },
441
+ children: p
442
+ }), /* @__PURE__ */ w("span", {
443
+ className: t.chipArrow,
444
+ children: " → "
445
+ })] }), /* @__PURE__ */ w("span", {
446
+ className: t.chipBadge,
447
+ style: {
448
+ background: u(h, 14),
449
+ color: h
450
+ },
451
+ children: n.service
452
+ })] }),
453
+ /* @__PURE__ */ w("div", {
454
+ className: t.chipOp,
455
+ children: /* @__PURE__ */ w(te, {
456
+ text: ne,
457
+ query: W
458
+ })
459
+ }),
460
+ /* @__PURE__ */ w("div", {
461
+ className: t.chipTime,
462
+ children: ee(n.start, !0)
463
+ })
464
+ ] })
465
+ })
466
+ ] }), /* @__PURE__ */ w("div", {
467
+ ...ie,
468
+ className: S(t.bar, s && t.barPending, j?.bar),
469
+ style: {
470
+ left: a.left,
471
+ top: a.barTop,
472
+ width: a.width,
473
+ height: en,
474
+ background: W && c ? r.hlBarBg : u(o, 22),
475
+ borderColor: o,
476
+ opacity: f,
477
+ boxShadow: re
478
+ },
479
+ children: s && /* @__PURE__ */ w("span", {
480
+ className: S(e.pulseDot, t.barDot),
481
+ style: { background: o }
482
+ })
483
+ })] }, n.id);
484
+ })]
485
+ })
486
+ ]
487
+ })
488
+ })
489
+ }),
490
+ yn && $ && Xe && /* @__PURE__ */ T("div", {
491
+ className: t.dockCol,
492
+ style: { flexBasis: gt },
493
+ children: [/* @__PURE__ */ w(p, {
494
+ panel: "right",
495
+ width: gt,
496
+ min: 280,
497
+ max: 640,
498
+ onResize: _t,
499
+ label: "Resize details drawer",
500
+ className: t.dockColResizer
501
+ }), /* @__PURE__ */ w("aside", {
502
+ className: S(e.aside, t.drawerCustom, j?.drawer),
503
+ children: Xe($, {
504
+ close: xn,
505
+ pending: vn
506
+ })
507
+ })]
508
+ }),
509
+ yn && !($ && Xe) && /* @__PURE__ */ T("div", {
510
+ className: t.dockCol,
511
+ style: { flexBasis: gt },
512
+ children: [/* @__PURE__ */ w(p, {
513
+ panel: "right",
514
+ width: gt,
515
+ min: 280,
516
+ max: 640,
517
+ onResize: _t,
518
+ label: "Resize details drawer",
519
+ className: t.dockColResizer
520
+ }), /* @__PURE__ */ T("aside", {
521
+ className: S(e.aside, A && t.dockAside, j?.drawer),
522
+ children: [A && /* @__PURE__ */ T("div", {
523
+ className: t.dockHead,
524
+ children: [
525
+ /* @__PURE__ */ w("span", {
526
+ className: t.dockTitle,
527
+ children: "Event details"
528
+ }),
529
+ /* @__PURE__ */ w("div", { className: t.drawerSpacer }),
530
+ /* @__PURE__ */ w("button", {
531
+ type: "button",
532
+ className: e.asideClose,
533
+ "aria-label": "Close details",
534
+ onClick: xn,
535
+ children: "✕"
536
+ })
537
+ ]
538
+ }), $ ? /* @__PURE__ */ w(oe, {
539
+ event: $,
540
+ now: z,
541
+ highlight: W,
542
+ showExtraFields: Ve,
543
+ hiddenFields: He,
544
+ onClose: A ? void 0 : xn,
545
+ className: A ? t.dockScroll : void 0
546
+ }) : /* @__PURE__ */ w("div", {
547
+ className: t.dockEmpty,
548
+ children: "Click an event on the timeline to inspect it."
549
+ })]
550
+ })]
551
+ }),
552
+ bn && /* @__PURE__ */ T("div", {
553
+ className: t.dockCol,
554
+ style: { flexBasis: vt },
555
+ children: [/* @__PURE__ */ w(p, {
556
+ panel: "right",
557
+ width: vt,
558
+ min: 320,
559
+ max: 680,
560
+ onResize: yt,
561
+ label: "Resize log drawer",
562
+ className: t.dockColResizer
563
+ }), /* @__PURE__ */ T("aside", {
564
+ className: S(e.aside, t.dockAside, j?.log),
565
+ children: [/* @__PURE__ */ T("div", {
566
+ className: t.dockHead,
567
+ children: [
568
+ /* @__PURE__ */ w("span", {
569
+ className: t.dockTitle,
570
+ children: "Full log"
571
+ }),
572
+ /* @__PURE__ */ T("span", {
573
+ className: t.dockCount,
574
+ children: [O.length, " events"]
575
+ }),
576
+ /* @__PURE__ */ w("div", { className: t.drawerSpacer }),
577
+ /* @__PURE__ */ w("button", {
578
+ type: "button",
579
+ className: e.asideClose,
580
+ "aria-label": "Close full log",
581
+ onClick: () => ht(null),
582
+ children: "✕"
583
+ })
584
+ ]
585
+ }), /* @__PURE__ */ w("div", {
586
+ ref: At,
587
+ className: S(t.dockScroll, t.logBody),
588
+ children: Sn.map((n, r) => {
589
+ let i = n.end == null, o = n.url ? n.url.replace(/^https?:\/\/[^/]+/, "") : "", s = se(n);
590
+ return /* @__PURE__ */ T("div", {
591
+ "data-crk-log-id": n.id,
592
+ className: S(t.logEntry, I === n.id && t.logEntrySelected, jt === n.id && t.logEntryFlash),
593
+ onClick: () => {
594
+ Zt(n), V.current = n.id;
595
+ },
596
+ children: [
597
+ /* @__PURE__ */ T("div", {
598
+ className: t.logTop,
599
+ children: [
600
+ /* @__PURE__ */ w("span", {
601
+ className: t.logNum,
602
+ children: String(r + 1).padStart(2, "0")
603
+ }),
604
+ n.method && /* @__PURE__ */ w("span", {
605
+ className: S(t.methodBadge, t.badgeSm),
606
+ children: n.method
607
+ }),
608
+ /* @__PURE__ */ w(ie, {
609
+ event: n,
610
+ pending: i,
611
+ small: !0
612
+ }),
613
+ /* @__PURE__ */ w("span", {
614
+ className: t.logPair,
615
+ children: ce(n)
616
+ }),
617
+ /* @__PURE__ */ w("div", { className: t.drawerSpacer }),
618
+ /* @__PURE__ */ w("span", {
619
+ className: t.logClock,
620
+ children: a(n.start)
621
+ })
622
+ ]
623
+ }),
624
+ /* @__PURE__ */ w("div", {
625
+ className: t.logOp,
626
+ children: /* @__PURE__ */ w(te, {
627
+ text: String(_(n)),
628
+ query: W
629
+ })
630
+ }),
631
+ o && /* @__PURE__ */ w("div", {
632
+ className: t.logPath,
633
+ children: o
634
+ }),
635
+ n.message && /* @__PURE__ */ w("div", {
636
+ className: t.logMessage,
637
+ children: /* @__PURE__ */ w(te, {
638
+ text: n.message,
639
+ query: W
640
+ })
641
+ }),
642
+ !!n.details?.length && /* @__PURE__ */ w("div", {
643
+ className: S(t.fieldList, t.logFields),
644
+ onClick: (e) => e.stopPropagation(),
645
+ children: n.details.map((e, t) => /* @__PURE__ */ w(ae, {
646
+ field: e,
647
+ query: W
648
+ }, e.label + t))
649
+ }),
650
+ n.payload != null && /* @__PURE__ */ T(C, { children: [/* @__PURE__ */ T("div", {
651
+ className: t.logPayloadHead,
652
+ children: [/* @__PURE__ */ w("span", {
653
+ className: t.logPayloadLabel,
654
+ children: "Payload"
655
+ }), /* @__PURE__ */ w("span", {
656
+ className: t.copyStop,
657
+ onClick: (e) => e.stopPropagation(),
658
+ children: /* @__PURE__ */ w(g, {
659
+ size: "sm",
660
+ className: t.payloadCopy,
661
+ value: () => v(n.payload),
662
+ "aria-label": "Copy payload"
663
+ })
664
+ })]
665
+ }), /* @__PURE__ */ w("pre", {
666
+ className: S(e.asideRaw, t.logPre),
667
+ children: v(n.payload)
668
+ })] }),
669
+ s && /* @__PURE__ */ T(C, { children: [
670
+ /* @__PURE__ */ T("div", {
671
+ className: t.logPayloadHead,
672
+ children: [/* @__PURE__ */ w("span", {
673
+ className: t.logPayloadLabel,
674
+ children: "Request"
675
+ }), n.reqBody != null && /* @__PURE__ */ w("span", {
676
+ className: t.copyStop,
677
+ onClick: (e) => e.stopPropagation(),
678
+ children: /* @__PURE__ */ w(g, {
679
+ size: "sm",
680
+ className: t.payloadCopy,
681
+ value: () => v(n.reqBody),
682
+ "aria-label": "Copy request payload"
683
+ })
684
+ })]
685
+ }),
686
+ /* @__PURE__ */ w("pre", {
687
+ className: S(e.asideRaw, t.logPre),
688
+ children: n.reqBody == null ? "(empty)" : v(n.reqBody)
689
+ }),
690
+ /* @__PURE__ */ T("div", {
691
+ className: t.logPayloadHead,
692
+ children: [/* @__PURE__ */ w("span", {
693
+ className: t.logPayloadLabel,
694
+ children: "Response"
695
+ }), !i && n.resBody != null && /* @__PURE__ */ w("span", {
696
+ className: t.copyStop,
697
+ onClick: (e) => e.stopPropagation(),
698
+ children: /* @__PURE__ */ w(g, {
699
+ size: "sm",
700
+ className: t.payloadCopy,
701
+ value: () => v(n.resBody),
702
+ "aria-label": "Copy response payload"
703
+ })
704
+ })]
705
+ }),
706
+ i ? /* @__PURE__ */ T("div", {
707
+ className: t.awaiting,
708
+ children: [/* @__PURE__ */ w("span", { className: S(e.pulseDot, t.awaitingDot) }), "Awaiting response…"]
709
+ }) : /* @__PURE__ */ w("pre", {
710
+ className: S(e.asideRaw, t.logPre),
711
+ children: n.resBody == null ? "(empty)" : v(n.resBody)
712
+ })
713
+ ] }),
714
+ !s && i && /* @__PURE__ */ T("div", {
715
+ className: t.awaiting,
716
+ children: [/* @__PURE__ */ w("span", { className: S(e.pulseDot, t.awaitingDot) }), "Still ongoing…"]
717
+ })
718
+ ]
719
+ }, n.id);
720
+ })
721
+ })]
722
+ })]
723
+ }),
724
+ k === "bubble" && Cn
725
+ ]
726
+ }), /* @__PURE__ */ w("div", {
727
+ className: S(e.footnote, j?.footnote),
728
+ children: "Click an event to open its details in the side panel · dashed pills are still in flight"
729
+ })]
730
+ }),
731
+ (k === "right" || k === "floating") && Cn,
732
+ A && /* @__PURE__ */ T("div", {
733
+ className: S(t.rail, j?.rail),
734
+ children: [/* @__PURE__ */ w("button", {
735
+ type: "button",
736
+ title: "Event details",
737
+ "aria-label": "Toggle event details drawer",
738
+ "aria-pressed": L === "details",
739
+ className: S(t.railBtn, L === "details" && t.railBtnActive),
740
+ onClick: () => ht(L === "details" ? null : "details"),
741
+ children: /* @__PURE__ */ T("span", {
742
+ className: t.railGlyphDetails,
743
+ "aria-hidden": !0,
744
+ children: [
745
+ /* @__PURE__ */ w("span", {}),
746
+ /* @__PURE__ */ w("span", {}),
747
+ /* @__PURE__ */ w("span", {})
748
+ ]
749
+ })
750
+ }), /* @__PURE__ */ w("button", {
751
+ type: "button",
752
+ title: "Full log",
753
+ "aria-label": "Toggle full log drawer",
754
+ "aria-pressed": L === "log",
755
+ className: S(t.railBtn, L === "log" && t.railBtnActive),
756
+ onClick: () => {
757
+ let e = L === "log" ? null : "log";
758
+ e === "log" && I != null && (H.current = I), ht(e);
759
+ },
760
+ children: /* @__PURE__ */ T("span", {
761
+ className: t.railGlyphLog,
762
+ "aria-hidden": !0,
763
+ children: [
764
+ /* @__PURE__ */ w("span", {}),
765
+ /* @__PURE__ */ w("span", {}),
766
+ /* @__PURE__ */ w("span", {})
767
+ ]
768
+ })
769
+ })]
770
+ })
771
+ ]
772
+ }),
773
+ k === "bottom" && Cn,
774
+ N && (() => {
775
+ let t = O.find((e) => e.id === N.id), n = t && Ye ? Ye(t, {
776
+ color: Y[t.service] || r.body,
777
+ pending: t.end == null,
778
+ durationMs: (t.end ?? z) - t.start
779
+ }) : void 0;
780
+ return Ye && n == null ? null : /* @__PURE__ */ w(h, {
781
+ x: N.x,
782
+ y: N.y,
783
+ className: j?.tooltip,
784
+ children: n === void 0 ? /* @__PURE__ */ T(C, { children: [
785
+ /* @__PURE__ */ w("div", {
786
+ className: S(e.tooltipTitle, e.tooltipMono),
787
+ children: N.rid
788
+ }),
789
+ /* @__PURE__ */ w("div", {
790
+ className: e.tooltipLine,
791
+ style: { marginTop: 4 },
792
+ children: N.route
793
+ }),
794
+ N.label && /* @__PURE__ */ w("div", {
795
+ className: S(e.tooltipLine, e.tooltipMono),
796
+ style: { marginTop: 2 },
797
+ children: N.label
798
+ }),
799
+ /* @__PURE__ */ w("div", {
800
+ className: e.tooltipLine,
801
+ style: { marginTop: 4 },
802
+ children: N.time
803
+ }),
804
+ /* @__PURE__ */ w("div", {
805
+ className: e.tooltipLine,
806
+ children: N.durLine
807
+ }),
808
+ N.url && /* @__PURE__ */ w("div", {
809
+ className: S(e.tooltipDim, e.tooltipMono),
810
+ style: {
811
+ marginTop: 4,
812
+ wordBreak: "break-all",
813
+ fontSize: "10.5px"
814
+ },
815
+ children: N.url
816
+ })
817
+ ] }) : n
818
+ });
819
+ })()
820
+ ]
821
+ });
822
+ });
823
+ export { Ce as TraceTimeline };