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