@parca/profile 0.19.140 → 0.19.143

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 (182) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/dist/GraphTooltipArrow/Content.js +224 -30
  3. package/dist/GraphTooltipArrow/DockedGraphTooltip/index.js +192 -33
  4. package/dist/GraphTooltipArrow/ExpandOnHoverValue.js +53 -3
  5. package/dist/GraphTooltipArrow/index.d.ts.map +1 -1
  6. package/dist/GraphTooltipArrow/index.js +86 -56
  7. package/dist/GraphTooltipArrow/useGraphTooltip/index.js +37 -37
  8. package/dist/GraphTooltipArrow/useGraphTooltipMetaInfo/index.js +94 -68
  9. package/dist/MatchersInput/SuggestionItem.js +91 -12
  10. package/dist/MatchersInput/SuggestionsList.d.ts +2 -1
  11. package/dist/MatchersInput/SuggestionsList.d.ts.map +1 -1
  12. package/dist/MatchersInput/SuggestionsList.js +371 -157
  13. package/dist/MatchersInput/SuggestionsList.test.d.ts +2 -0
  14. package/dist/MatchersInput/SuggestionsList.test.d.ts.map +1 -0
  15. package/dist/MatchersInput/index.js +308 -115
  16. package/dist/MetricsCircle/index.js +39 -3
  17. package/dist/MetricsGraph/MetricsContextMenu/index.js +119 -19
  18. package/dist/MetricsGraph/MetricsInfoPanel/index.js +81 -20
  19. package/dist/MetricsGraph/MetricsTooltip/index.d.ts.map +1 -1
  20. package/dist/MetricsGraph/MetricsTooltip/index.js +107 -74
  21. package/dist/MetricsGraph/index.js +552 -203
  22. package/dist/MetricsGraph/useMetricsGraphDimensions.js +46 -25
  23. package/dist/MetricsGraph/utils/colorMapping.js +24 -17
  24. package/dist/MetricsSeries/index.js +70 -7
  25. package/dist/PreSelectedMatchers/index.d.ts.map +1 -1
  26. package/dist/PreSelectedMatchers/index.js +249 -102
  27. package/dist/ProfileExplorer/ProfileExplorerCompare.d.ts.map +1 -1
  28. package/dist/ProfileExplorer/ProfileExplorerCompare.js +240 -45
  29. package/dist/ProfileExplorer/ProfileExplorerSingle.js +98 -11
  30. package/dist/ProfileExplorer/index.js +183 -32
  31. package/dist/ProfileFlameChart/SamplesStrips/SamplesGraph/index.js +333 -148
  32. package/dist/ProfileFlameChart/SamplesStrips/SamplesStrips.stories.js +69 -35
  33. package/dist/ProfileFlameChart/SamplesStrips/index.js +645 -134
  34. package/dist/ProfileFlameChart/SamplesStrips/labelSetUtils.js +114 -55
  35. package/dist/ProfileFlameChart/index.js +260 -126
  36. package/dist/ProfileFlameGraph/FlameGraphArrow/ContextMenu.js +283 -85
  37. package/dist/ProfileFlameGraph/FlameGraphArrow/ContextMenuWrapper.js +56 -20
  38. package/dist/ProfileFlameGraph/FlameGraphArrow/FlameGraphNodes.js +211 -140
  39. package/dist/ProfileFlameGraph/FlameGraphArrow/MemoizedTooltip.js +133 -38
  40. package/dist/ProfileFlameGraph/FlameGraphArrow/MiniMap.js +261 -216
  41. package/dist/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.d.ts.map +1 -1
  42. package/dist/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.js +71 -45
  43. package/dist/ProfileFlameGraph/FlameGraphArrow/TooltipContext.d.ts.map +1 -1
  44. package/dist/ProfileFlameGraph/FlameGraphArrow/TooltipContext.js +58 -28
  45. package/dist/ProfileFlameGraph/FlameGraphArrow/ZoomControls.d.ts.map +1 -1
  46. package/dist/ProfileFlameGraph/FlameGraphArrow/ZoomControls.js +59 -8
  47. package/dist/ProfileFlameGraph/FlameGraphArrow/index.js +396 -179
  48. package/dist/ProfileFlameGraph/FlameGraphArrow/useBatchedRendering.d.ts.map +1 -1
  49. package/dist/ProfileFlameGraph/FlameGraphArrow/useBatchedRendering.js +68 -50
  50. package/dist/ProfileFlameGraph/FlameGraphArrow/useMappingList.js +62 -38
  51. package/dist/ProfileFlameGraph/FlameGraphArrow/useNodeColor.js +14 -6
  52. package/dist/ProfileFlameGraph/FlameGraphArrow/useScrollViewport.js +124 -82
  53. package/dist/ProfileFlameGraph/FlameGraphArrow/useVisibleNodes.js +160 -98
  54. package/dist/ProfileFlameGraph/FlameGraphArrow/useZoom.js +232 -112
  55. package/dist/ProfileFlameGraph/FlameGraphArrow/utils.js +137 -114
  56. package/dist/ProfileFlameGraph/benchmarks/benchdata/populateData.js +85 -0
  57. package/dist/ProfileFlameGraph/index.js +322 -147
  58. package/dist/ProfileMetricsGraph/hooks/useQueryRange.js +140 -32
  59. package/dist/ProfileMetricsGraph/index.js +515 -256
  60. package/dist/ProfileSelector/CompareButton.js +132 -12
  61. package/dist/ProfileSelector/MetricsGraphSection.js +228 -63
  62. package/dist/ProfileSelector/index.d.ts +1 -1
  63. package/dist/ProfileSelector/index.d.ts.map +1 -1
  64. package/dist/ProfileSelector/index.js +734 -142
  65. package/dist/ProfileSelector/useAutoQuerySelector.d.ts +1 -3
  66. package/dist/ProfileSelector/useAutoQuerySelector.d.ts.map +1 -1
  67. package/dist/ProfileSelector/useAutoQuerySelector.js +280 -132
  68. package/dist/ProfileSource.js +230 -163
  69. package/dist/ProfileTypeSelector/index.js +214 -125
  70. package/dist/ProfileView/components/ActionButtons/GroupByDropdown.js +50 -4
  71. package/dist/ProfileView/components/ActionButtons/SortByDropdown.js +137 -32
  72. package/dist/ProfileView/components/ColorStackLegend.js +182 -54
  73. package/dist/ProfileView/components/DashboardItems/index.js +87 -28
  74. package/dist/ProfileView/components/DashboardLayout/index.js +108 -16
  75. package/dist/ProfileView/components/DiffLegend.js +172 -29
  76. package/dist/ProfileView/components/GroupByLabelsDropdown/index.js +199 -55
  77. package/dist/ProfileView/components/InvertCallStack/index.js +97 -9
  78. package/dist/ProfileView/components/ProfileFilters/filterPresets.js +260 -315
  79. package/dist/ProfileView/components/ProfileFilters/index.js +518 -215
  80. package/dist/ProfileView/components/ProfileFilters/useProfileFilters.js +370 -306
  81. package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.js +191 -118
  82. package/dist/ProfileView/components/ProfileHeader/index.js +105 -11
  83. package/dist/ProfileView/components/ShareButton/ResultBox.js +119 -16
  84. package/dist/ProfileView/components/ShareButton/index.js +352 -62
  85. package/dist/ProfileView/components/Toolbars/MultiLevelDropdown.d.ts.map +1 -1
  86. package/dist/ProfileView/components/Toolbars/MultiLevelDropdown.js +664 -192
  87. package/dist/ProfileView/components/Toolbars/SwitchMenuItem.js +94 -7
  88. package/dist/ProfileView/components/Toolbars/TableColumnsDropdown.js +196 -155
  89. package/dist/ProfileView/components/Toolbars/index.js +441 -21
  90. package/dist/ProfileView/components/ViewSelector/Dropdown.js +233 -22
  91. package/dist/ProfileView/components/ViewSelector/index.js +186 -82
  92. package/dist/ProfileView/components/VisualizationContainer/index.d.ts.map +1 -1
  93. package/dist/ProfileView/components/VisualizationContainer/index.js +52 -7
  94. package/dist/ProfileView/components/VisualizationPanel.js +185 -8
  95. package/dist/ProfileView/context/DashboardContext.js +74 -26
  96. package/dist/ProfileView/context/ProfileViewContext.js +56 -15
  97. package/dist/ProfileView/hooks/useAutoSelectDimension.js +71 -41
  98. package/dist/ProfileView/hooks/useProfileMetadata.js +50 -18
  99. package/dist/ProfileView/hooks/useResetFlameGraphState.js +31 -10
  100. package/dist/ProfileView/hooks/useResetStateOnProfileTypeChange.js +71 -27
  101. package/dist/ProfileView/hooks/useResetStateOnSeriesChange.js +53 -17
  102. package/dist/ProfileView/hooks/useVisualizationState.js +229 -69
  103. package/dist/ProfileView/index.js +383 -45
  104. package/dist/ProfileView/types/visualization.js +1 -13
  105. package/dist/ProfileView/utils/colorUtils.js +8 -7
  106. package/dist/ProfileViewWithData.js +319 -225
  107. package/dist/QueryControls/index.js +418 -47
  108. package/dist/Sandwich/components/CalleesSection.js +54 -4
  109. package/dist/Sandwich/components/CallersSection.js +97 -27
  110. package/dist/Sandwich/components/TableSection.js +77 -4
  111. package/dist/Sandwich/index.js +125 -12
  112. package/dist/Sandwich/utils/processRowData.js +48 -39
  113. package/dist/SelectWithRefresh/index.js +102 -28
  114. package/dist/SimpleMatchers/Select.js +520 -187
  115. package/dist/SimpleMatchers/index.js +590 -288
  116. package/dist/SourceView/Highlighter.js +230 -70
  117. package/dist/SourceView/LineNo.js +72 -17
  118. package/dist/SourceView/index.js +177 -101
  119. package/dist/SourceView/lang-detector/ext-to-lang.json +798 -798
  120. package/dist/SourceView/lang-detector/index.js +28 -14
  121. package/dist/SourceView/useSelectedLineRange.js +72 -20
  122. package/dist/Table/ColorCell.js +42 -1
  123. package/dist/Table/ColumnsVisibility.js +114 -6
  124. package/dist/Table/MoreDropdown.js +107 -21
  125. package/dist/Table/TableContextMenu.js +144 -134
  126. package/dist/Table/TableContextMenuWrapper.js +59 -14
  127. package/dist/Table/hooks/useColorManagement.js +58 -16
  128. package/dist/Table/hooks/useTableConfiguration.d.ts.map +1 -1
  129. package/dist/Table/hooks/useTableConfiguration.js +323 -167
  130. package/dist/Table/index.js +217 -123
  131. package/dist/Table/utils/functions.js +169 -144
  132. package/dist/Table/utils/topAndBottomExpandedRowModel.js +69 -52
  133. package/dist/TimelineGuide/index.js +209 -16
  134. package/dist/TopTable/benchmarks/benchdata/populateData.js +91 -0
  135. package/dist/TopTable/index.js +325 -121
  136. package/dist/contexts/LabelsQueryProvider.js +94 -32
  137. package/dist/contexts/UnifiedLabelsContext.js +114 -49
  138. package/dist/contexts/utils.js +37 -15
  139. package/dist/hooks/urlParsers.js +27 -15
  140. package/dist/hooks/useColorBy.js +47 -10
  141. package/dist/hooks/useCompareModeMeta.js +112 -62
  142. package/dist/hooks/useDashboardItems.js +52 -11
  143. package/dist/hooks/useLabels.js +295 -52
  144. package/dist/hooks/useQueryState.d.ts +1 -1
  145. package/dist/hooks/useQueryState.d.ts.map +1 -1
  146. package/dist/hooks/useQueryState.js +375 -329
  147. package/dist/index.js +11 -6
  148. package/dist/testdata/fg-diff.json +3750 -0
  149. package/dist/testdata/fg-simple.json +1879 -0
  150. package/dist/testdata/link_data.json +56 -0
  151. package/dist/testdata/tabular.json +30 -0
  152. package/dist/testdata/test_flamegraph.json +26846 -0
  153. package/dist/testdata/test_graph.json +53 -0
  154. package/dist/useDelayedLoader.js +32 -18
  155. package/dist/useGrpcQuery/index.js +71 -11
  156. package/dist/useHasProfileData.js +90 -12
  157. package/dist/useQuery.js +205 -64
  158. package/dist/useSumBy.d.ts.map +1 -1
  159. package/dist/useSumBy.js +294 -138
  160. package/dist/utils.js +62 -30
  161. package/package.json +9 -9
  162. package/src/GraphTooltipArrow/index.tsx +3 -0
  163. package/src/MatchersInput/SuggestionsList.test.tsx +70 -0
  164. package/src/MatchersInput/SuggestionsList.tsx +11 -10
  165. package/src/MatchersInput/index.tsx +1 -1
  166. package/src/MetricsGraph/MetricsTooltip/index.tsx +22 -34
  167. package/src/PreSelectedMatchers/index.tsx +3 -0
  168. package/src/ProfileExplorer/ProfileExplorerCompare.tsx +9 -2
  169. package/src/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.tsx +3 -0
  170. package/src/ProfileFlameGraph/FlameGraphArrow/TooltipContext.tsx +3 -0
  171. package/src/ProfileFlameGraph/FlameGraphArrow/ZoomControls.tsx +3 -0
  172. package/src/ProfileFlameGraph/FlameGraphArrow/useBatchedRendering.ts +3 -0
  173. package/src/ProfileSelector/index.tsx +31 -9
  174. package/src/ProfileSelector/useAutoQuerySelector.ts +64 -42
  175. package/src/ProfileView/components/Toolbars/MultiLevelDropdown.tsx +3 -0
  176. package/src/ProfileView/components/VisualizationContainer/index.tsx +3 -0
  177. package/src/Table/hooks/useTableConfiguration.tsx +7 -13
  178. package/src/hooks/useQueryState.ts +18 -3
  179. package/src/useDelayedLoader.ts +10 -10
  180. package/src/useSumBy.ts +12 -18
  181. package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.test.js +0 -455
  182. package/dist/hooks/useQueryState.test.js +0 -868
@@ -1,3 +1,10 @@
1
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
2
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
4
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
5
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
6
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
7
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
1
8
  // Copyright 2022 The Parca Authors
2
9
  // Licensed under the Apache License, Version 2.0 (the "License");
3
10
  // you may not use this file except in compliance with the License.
@@ -10,70 +17,122 @@
10
17
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
18
  // See the License for the specific language governing permissions and
12
19
  // limitations under the License.
20
+
13
21
  // Determine which label keys have all-numeric values across every label set.
14
- const getNumericKeys = (labelSets) => {
15
- const numericKeys = new Set();
16
- if (labelSets.length === 0)
17
- return numericKeys;
18
- const keyCandidates = new Set(labelSets[0].labels.map(l => l.name));
19
- for (const key of keyCandidates) {
20
- const allNumeric = labelSets.every(ls => {
21
- const label = ls.labels.find(l => l.name === key);
22
- return label != null && label.value !== '' && !isNaN(Number(label.value));
22
+ var getNumericKeys = function getNumericKeys(labelSets) {
23
+ var numericKeys = new Set();
24
+ if (labelSets.length === 0) return numericKeys;
25
+ var keyCandidates = new Set(labelSets[0].labels.map(function (l) {
26
+ return l.name;
27
+ }));
28
+ var _iterator = _createForOfIteratorHelper(keyCandidates),
29
+ _step;
30
+ try {
31
+ var _loop = function _loop() {
32
+ var key = _step.value;
33
+ var allNumeric = labelSets.every(function (ls) {
34
+ var label = ls.labels.find(function (l) {
35
+ return l.name === key;
23
36
  });
24
- if (allNumeric)
25
- numericKeys.add(key);
37
+ return label != null && label.value !== '' && !isNaN(Number(label.value));
38
+ });
39
+ if (allNumeric) numericKeys.add(key);
40
+ };
41
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
42
+ _loop();
26
43
  }
27
- return numericKeys;
44
+ } catch (err) {
45
+ _iterator.e(err);
46
+ } finally {
47
+ _iterator.f();
48
+ }
49
+ return numericKeys;
28
50
  };
51
+
29
52
  // Get key order: text keys first (sorted), then numeric keys (sorted).
30
- const getSortedKeys = (labelSets, numericKeys) => {
31
- const allKeys = new Set();
32
- for (const ls of labelSets) {
33
- for (const l of ls.labels)
34
- allKeys.add(l.name);
53
+ var getSortedKeys = function getSortedKeys(labelSets, numericKeys) {
54
+ var allKeys = new Set();
55
+ var _iterator2 = _createForOfIteratorHelper(labelSets),
56
+ _step2;
57
+ try {
58
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
59
+ var ls = _step2.value;
60
+ var _iterator3 = _createForOfIteratorHelper(ls.labels),
61
+ _step3;
62
+ try {
63
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
64
+ var l = _step3.value;
65
+ allKeys.add(l.name);
66
+ }
67
+ } catch (err) {
68
+ _iterator3.e(err);
69
+ } finally {
70
+ _iterator3.f();
71
+ }
35
72
  }
36
- return [...allKeys]
37
- .filter(k => !numericKeys.has(k))
38
- .sort()
39
- .concat([...numericKeys].sort());
73
+ } catch (err) {
74
+ _iterator2.e(err);
75
+ } finally {
76
+ _iterator2.f();
77
+ }
78
+ return _toConsumableArray(allKeys).filter(function (k) {
79
+ return !numericKeys.has(k);
80
+ }).sort().concat(_toConsumableArray(numericKeys).sort());
40
81
  };
82
+
41
83
  // Format a LabelSet as a string with keys ordered: text first, then numeric.
42
- export const labelSetToString = (labelSet, keyOrder) => {
43
- if (labelSet === undefined)
44
- return '{}';
45
- const labels = keyOrder != null
46
- ? keyOrder
47
- .map(key => labelSet.labels.find(l => l.name === key))
48
- .filter((l) => l != null)
49
- : labelSet.labels;
50
- if (labels.length === 0)
51
- return '{}';
52
- return '{' + labels.map(l => `${l.name}: ${l.value}`).join(', ') + '}';
84
+ export var labelSetToString = function labelSetToString(labelSet, keyOrder) {
85
+ if (labelSet === undefined) return '{}';
86
+ var labels = keyOrder != null ? keyOrder.map(function (key) {
87
+ return labelSet.labels.find(function (l) {
88
+ return l.name === key;
89
+ });
90
+ }).filter(function (l) {
91
+ return l != null;
92
+ }) : labelSet.labels;
93
+ if (labels.length === 0) return '{}';
94
+ return '{' + labels.map(function (l) {
95
+ return "".concat(l.name, ": ").concat(l.value);
96
+ }).join(', ') + '}';
53
97
  };
98
+
54
99
  // Build a comparator for LabelSets: text keys first (for grouping), then numeric keys.
55
100
  // Also returns the key order so labelSetToString can use the same ordering.
56
- export const createLabelSetComparator = (labelSets) => {
57
- const numericKeys = getNumericKeys(labelSets);
58
- const keyOrder = getSortedKeys(labelSets, numericKeys);
59
- const compare = (a, b) => {
60
- const aMap = new Map(a.labels.map(l => [l.name, l.value]));
61
- const bMap = new Map(b.labels.map(l => [l.name, l.value]));
62
- for (const key of keyOrder) {
63
- const aVal = aMap.get(key) ?? '';
64
- const bVal = bMap.get(key) ?? '';
65
- if (numericKeys.has(key)) {
66
- const diff = Number(aVal) - Number(bVal);
67
- if (diff !== 0)
68
- return diff;
69
- }
70
- else {
71
- const cmp = aVal.localeCompare(bVal);
72
- if (cmp !== 0)
73
- return cmp;
74
- }
101
+ export var createLabelSetComparator = function createLabelSetComparator(labelSets) {
102
+ var numericKeys = getNumericKeys(labelSets);
103
+ var keyOrder = getSortedKeys(labelSets, numericKeys);
104
+ var compare = function compare(a, b) {
105
+ var aMap = new Map(a.labels.map(function (l) {
106
+ return [l.name, l.value];
107
+ }));
108
+ var bMap = new Map(b.labels.map(function (l) {
109
+ return [l.name, l.value];
110
+ }));
111
+ var _iterator4 = _createForOfIteratorHelper(keyOrder),
112
+ _step4;
113
+ try {
114
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
115
+ var _aMap$get, _bMap$get;
116
+ var key = _step4.value;
117
+ var aVal = (_aMap$get = aMap.get(key)) !== null && _aMap$get !== void 0 ? _aMap$get : '';
118
+ var bVal = (_bMap$get = bMap.get(key)) !== null && _bMap$get !== void 0 ? _bMap$get : '';
119
+ if (numericKeys.has(key)) {
120
+ var diff = Number(aVal) - Number(bVal);
121
+ if (diff !== 0) return diff;
122
+ } else {
123
+ var cmp = aVal.localeCompare(bVal);
124
+ if (cmp !== 0) return cmp;
75
125
  }
76
- return 0;
77
- };
78
- return { compare, keyOrder };
79
- };
126
+ }
127
+ } catch (err) {
128
+ _iterator4.e(err);
129
+ } finally {
130
+ _iterator4.f();
131
+ }
132
+ return 0;
133
+ };
134
+ return {
135
+ compare: compare,
136
+ keyOrder: keyOrder
137
+ };
138
+ };
@@ -1,4 +1,20 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
8
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
9
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
10
+ function _toArray(r) { return _arrayWithHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableRest(); }
11
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
12
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
13
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
14
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
15
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
16
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
17
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
2
18
  // Copyright 2022 The Parca Authors
3
19
  // Licensed under the Apache License, Version 2.0 (the "License");
4
20
  // you may not use this file except in compliance with the License.
@@ -11,6 +27,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
27
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
28
  // See the License for the specific language governing permissions and
13
29
  // limitations under the License.
30
+
14
31
  import { useEffect, useMemo, useRef } from 'react';
15
32
  import { createParser, useQueryState } from 'nuqs';
16
33
  import { QueryRequest_ReportType } from '@parca/client';
@@ -24,136 +41,253 @@ import { useProfileFilters } from '../ProfileView/components/ProfileFilters/useP
24
41
  import { flamechartDimensionParser } from '../hooks/urlParsers';
25
42
  import { useQuery } from '../useQuery';
26
43
  import { SamplesStrip } from './SamplesStrips';
27
- const timeframeParser = createParser({
28
- parse: (value) => {
29
- try {
30
- const [labelPart, boundsPart] = value.split('|');
31
- if (labelPart != null && boundsPart != null) {
32
- const labels = labelPart.split(',').map(labelStr => {
33
- const [name, ...rest] = labelStr.split(':');
34
- return { name, value: rest.join(':') };
35
- });
36
- const [startMs, endMs] = boundsPart.split(',').map(Number);
37
- if (labels.length > 0 && !isNaN(startMs) && !isNaN(endMs)) {
38
- return {
39
- labels: { labels },
40
- bounds: [startMs, endMs],
41
- };
42
- }
43
- }
44
- }
45
- catch {
46
- // Ignore parsing errors
44
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
45
+ var timeframeParser = createParser({
46
+ parse: function parse(value) {
47
+ try {
48
+ var _value$split = value.split('|'),
49
+ _value$split2 = _slicedToArray(_value$split, 2),
50
+ labelPart = _value$split2[0],
51
+ boundsPart = _value$split2[1];
52
+ if (labelPart != null && boundsPart != null) {
53
+ var labels = labelPart.split(',').map(function (labelStr) {
54
+ var _labelStr$split = labelStr.split(':'),
55
+ _labelStr$split2 = _toArray(_labelStr$split),
56
+ name = _labelStr$split2[0],
57
+ rest = _arrayLikeToArray(_labelStr$split2).slice(1);
58
+ return {
59
+ name: name,
60
+ value: rest.join(':')
61
+ };
62
+ });
63
+ var _boundsPart$split$map = boundsPart.split(',').map(Number),
64
+ _boundsPart$split$map2 = _slicedToArray(_boundsPart$split$map, 2),
65
+ startMs = _boundsPart$split$map2[0],
66
+ endMs = _boundsPart$split$map2[1];
67
+ if (labels.length > 0 && !isNaN(startMs) && !isNaN(endMs)) {
68
+ return {
69
+ labels: {
70
+ labels: labels
71
+ },
72
+ bounds: [startMs, endMs]
73
+ };
47
74
  }
48
- return null;
49
- },
50
- serialize: (value) => {
51
- const labelsStr = value.labels.labels.map(l => `${l.name}:${l.value}`).join(',');
52
- return `${labelsStr}|${value.bounds[0]},${value.bounds[1]}`;
53
- },
54
- }).withOptions({ history: 'replace' });
75
+ }
76
+ } catch (_unused) {
77
+ // Ignore parsing errors
78
+ }
79
+ return null;
80
+ },
81
+ serialize: function serialize(value) {
82
+ var labelsStr = value.labels.labels.map(function (l) {
83
+ return "".concat(l.name, ":").concat(l.value);
84
+ }).join(',');
85
+ return "".concat(labelsStr, "|").concat(value.bounds[0], ",").concat(value.bounds[1]);
86
+ }
87
+ }).withOptions({
88
+ history: 'replace'
89
+ });
55
90
  // Helper to create a filtered profile source with narrowed time bounds
56
91
  // and dimension label matchers from the selected strip.
57
- const createFilteredProfileSource = (profileSource, selectedTimeframe) => {
58
- if (!(profileSource instanceof MergedProfileSource)) {
59
- return null;
60
- }
61
- // The bounds are in milliseconds, convert to nanoseconds for the profile source
62
- // Round to integers since BigInt requires integer values
63
- const mergeFrom = BigInt(Math.round(selectedTimeframe.bounds[0])) * 1000000n;
64
- const mergeTo = BigInt(Math.round(selectedTimeframe.bounds[1])) * 1000000n;
65
- // Add dimension labels as additional matchers to the query
66
- const dimensionMatchers = selectedTimeframe.labels.labels.map(l => new Matcher(l.name, MatcherTypes.MatchEqual, l.value));
67
- const query = new Query(profileSource.query.profType, [...profileSource.query.matchers, ...dimensionMatchers], '');
68
- return new MergedProfileSource(mergeFrom, mergeTo, query);
92
+ var createFilteredProfileSource = function createFilteredProfileSource(profileSource, selectedTimeframe) {
93
+ if (!(profileSource instanceof MergedProfileSource)) {
94
+ return null;
95
+ }
96
+
97
+ // The bounds are in milliseconds, convert to nanoseconds for the profile source
98
+ // Round to integers since BigInt requires integer values
99
+ var mergeFrom = BigInt(Math.round(selectedTimeframe.bounds[0])) * 1000000n;
100
+ var mergeTo = BigInt(Math.round(selectedTimeframe.bounds[1])) * 1000000n;
101
+
102
+ // Add dimension labels as additional matchers to the query
103
+ var dimensionMatchers = selectedTimeframe.labels.labels.map(function (l) {
104
+ return new Matcher(l.name, MatcherTypes.MatchEqual, l.value);
105
+ });
106
+ var query = new Query(profileSource.query.profType, [].concat(_toConsumableArray(profileSource.query.matchers), _toConsumableArray(dimensionMatchers)), '');
107
+ return new MergedProfileSource(mergeFrom, mergeTo, query);
69
108
  };
70
- export const ProfileFlameChart = ({ samplesData, queryClient, profileSource, width, total, filtered, profileType, isHalfScreen, metadataMappingFiles, metadataLoading, onSwitchToFifteenMinutes, }) => {
71
- const { enableFlamechartFiltering } = useParcaContext();
72
- const { protoFilters } = useProfileFilters();
73
- const zoomControlsRef = useRef(null);
74
- const [selectedTimeframe, setSelectedTimeframe] = useQueryState('flamechart_timeframe', timeframeParser);
75
- // Read flamechart dimension from URL state to detect changes
76
- const [flamechartDimension] = useQueryState('flamechart_dimension', flamechartDimensionParser.withDefault([]));
77
- // Reset selection when the parent time range (profileSource) changes
78
- const timeBoundsKey = boundsFromProfileSource(profileSource).join(',');
79
- const prevTimeBoundsKey = useRef(timeBoundsKey);
80
- useEffect(() => {
81
- if (prevTimeBoundsKey.current !== timeBoundsKey) {
82
- prevTimeBoundsKey.current = timeBoundsKey;
83
- void setSelectedTimeframe(null);
84
- }
85
- }, [timeBoundsKey, setSelectedTimeframe]);
86
- // Reset selection when the dimension changes
87
- const dimensionKey = (flamechartDimension ?? []).join(',');
88
- const prevDimensionKey = useRef(dimensionKey);
89
- useEffect(() => {
90
- if (prevDimensionKey.current !== dimensionKey) {
91
- prevDimensionKey.current = dimensionKey;
92
- void setSelectedTimeframe(null);
93
- }
94
- }, [dimensionKey, setSelectedTimeframe]);
95
- // Handle timeframe selection from strips
96
- const handleSelectedTimeframe = (labels, bounds) => {
97
- if (bounds === undefined) {
98
- void setSelectedTimeframe(null);
99
- }
100
- else {
101
- void setSelectedTimeframe({ labels, bounds });
102
- }
109
+ export var ProfileFlameChart = function ProfileFlameChart(_ref) {
110
+ var samplesData = _ref.samplesData,
111
+ queryClient = _ref.queryClient,
112
+ profileSource = _ref.profileSource,
113
+ width = _ref.width,
114
+ total = _ref.total,
115
+ filtered = _ref.filtered,
116
+ profileType = _ref.profileType,
117
+ isHalfScreen = _ref.isHalfScreen,
118
+ metadataMappingFiles = _ref.metadataMappingFiles,
119
+ metadataLoading = _ref.metadataLoading,
120
+ onSwitchToFifteenMinutes = _ref.onSwitchToFifteenMinutes;
121
+ var _useParcaContext = useParcaContext(),
122
+ enableFlamechartFiltering = _useParcaContext.enableFlamechartFiltering;
123
+ var _useProfileFilters = useProfileFilters(),
124
+ protoFilters = _useProfileFilters.protoFilters;
125
+ var zoomControlsRef = useRef(null);
126
+ var _useQueryState = useQueryState('flamechart_timeframe', timeframeParser),
127
+ _useQueryState2 = _slicedToArray(_useQueryState, 2),
128
+ selectedTimeframe = _useQueryState2[0],
129
+ setSelectedTimeframe = _useQueryState2[1];
130
+
131
+ // Read flamechart dimension from URL state to detect changes
132
+ var _useQueryState3 = useQueryState('flamechart_dimension', flamechartDimensionParser.withDefault([])),
133
+ _useQueryState4 = _slicedToArray(_useQueryState3, 1),
134
+ flamechartDimension = _useQueryState4[0];
135
+
136
+ // Reset selection when the parent time range (profileSource) changes
137
+ var timeBoundsKey = boundsFromProfileSource(profileSource).join(',');
138
+ var prevTimeBoundsKey = useRef(timeBoundsKey);
139
+ useEffect(function () {
140
+ if (prevTimeBoundsKey.current !== timeBoundsKey) {
141
+ prevTimeBoundsKey.current = timeBoundsKey;
142
+ void setSelectedTimeframe(null);
143
+ }
144
+ }, [timeBoundsKey, setSelectedTimeframe]);
145
+
146
+ // Reset selection when the dimension changes
147
+ var dimensionKey = (flamechartDimension !== null && flamechartDimension !== void 0 ? flamechartDimension : []).join(',');
148
+ var prevDimensionKey = useRef(dimensionKey);
149
+ useEffect(function () {
150
+ if (prevDimensionKey.current !== dimensionKey) {
151
+ prevDimensionKey.current = dimensionKey;
152
+ void setSelectedTimeframe(null);
153
+ }
154
+ }, [dimensionKey, setSelectedTimeframe]);
155
+
156
+ // Handle timeframe selection from strips
157
+ var handleSelectedTimeframe = function handleSelectedTimeframe(labels, bounds) {
158
+ if (bounds === undefined) {
159
+ void setSelectedTimeframe(null);
160
+ } else {
161
+ void setSelectedTimeframe({
162
+ labels: labels,
163
+ bounds: bounds
164
+ });
165
+ }
166
+ };
167
+
168
+ // Create filtered profile source when selection exists
169
+ var filteredProfileSource = useMemo(function () {
170
+ if (selectedTimeframe == null) return null;
171
+ return createFilteredProfileSource(profileSource, selectedTimeframe);
172
+ }, [profileSource, selectedTimeframe]);
173
+
174
+ // Query flamechart data only when a strip selection exists
175
+ var _useQuery = useQuery(queryClient, filteredProfileSource !== null && filteredProfileSource !== void 0 ? filteredProfileSource : profileSource, QueryRequest_ReportType.FLAMECHART, _objectSpread({
176
+ skip: selectedTimeframe == null || filteredProfileSource == null
177
+ }, enableFlamechartFiltering === true ? {
178
+ protoFilters: protoFilters
179
+ } : {})),
180
+ flamechartLoading = _useQuery.isLoading,
181
+ flamechartResponse = _useQuery.response,
182
+ flamechartError = _useQuery.error;
183
+ var flamechartArrow = (flamechartResponse === null || flamechartResponse === void 0 ? void 0 : flamechartResponse.report.oneofKind) === 'flamegraphArrow' ? flamechartResponse.report.flamegraphArrow : undefined;
184
+ var flamechartTotal = flamechartResponse != null ? BigInt(flamechartResponse.total) : total;
185
+ var flamechartFiltered = flamechartResponse != null ? BigInt(flamechartResponse.filtered) : filtered;
186
+
187
+ // Get time bounds from profile source for the strips
188
+ var timeBounds = boundsFromProfileSource(profileSource);
189
+
190
+ // Transform samples data for SamplesStrip component
191
+ var stripsData = useMemo(function () {
192
+ var _samplesData$stepMs;
193
+ if ((samplesData === null || samplesData === void 0 ? void 0 : samplesData.series) == null) return {
194
+ cpus: [],
195
+ data: [],
196
+ stepMs: 0
103
197
  };
104
- // Create filtered profile source when selection exists
105
- const filteredProfileSource = useMemo(() => {
106
- if (selectedTimeframe == null)
107
- return null;
108
- return createFilteredProfileSource(profileSource, selectedTimeframe);
109
- }, [profileSource, selectedTimeframe]);
110
- // Query flamechart data only when a strip selection exists
111
- const { isLoading: flamechartLoading, response: flamechartResponse, error: flamechartError, } = useQuery(queryClient, filteredProfileSource ?? profileSource, QueryRequest_ReportType.FLAMECHART, {
112
- skip: selectedTimeframe == null || filteredProfileSource == null,
113
- ...(enableFlamechartFiltering === true ? { protoFilters } : {}),
198
+ var cpus = samplesData.series.map(function (s) {
199
+ return s.labelset;
114
200
  });
115
- const flamechartArrow = flamechartResponse?.report.oneofKind === 'flamegraphArrow'
116
- ? flamechartResponse.report.flamegraphArrow
117
- : undefined;
118
- const flamechartTotal = flamechartResponse != null ? BigInt(flamechartResponse.total) : total;
119
- const flamechartFiltered = flamechartResponse != null ? BigInt(flamechartResponse.filtered) : filtered;
120
- // Get time bounds from profile source for the strips
121
- const timeBounds = boundsFromProfileSource(profileSource);
122
- // Transform samples data for SamplesStrip component
123
- const stripsData = useMemo(() => {
124
- if (samplesData?.series == null)
125
- return { cpus: [], data: [], stepMs: 0 };
126
- const cpus = samplesData.series.map(s => s.labelset);
127
- const data = samplesData.series.map(s => s.data);
128
- const stepMs = samplesData.stepMs ?? 0;
129
- return { cpus, data, stepMs };
130
- }, [samplesData?.series, samplesData?.stepMs]);
131
- const { isValid, isNonDelta, isDurationTooLong } = validateFlameChartQuery(profileSource);
132
- if (!isValid) {
133
- if (isDurationTooLong) {
134
- return (_jsxs("div", { className: "flex flex-col justify-center items-center p-10 text-center gap-4 text-sm", children: [_jsx("span", { children: "Flame chart is unavailable for queries longer than 15 minutes. Try reducing the time range to 15 minutes or selecting a point in the metrics graph." }), onSwitchToFifteenMinutes != null && (_jsx(Button, { variant: "primary", onClick: onSwitchToFifteenMinutes, children: "Switch to last 15 minutes" }))] }));
135
- }
136
- const message = isNonDelta
137
- ? 'To use the Flame chart, please switch to a Delta profile.'
138
- : 'Flame chart is unavailable for this query.';
139
- return (_jsx("div", { className: "flex flex-col justify-center p-10 text-center gap-6 text-sm", children: message }));
140
- }
141
- const hasDimension = (flamechartDimension ?? []).length > 0;
142
- const isStripsLoading = metadataLoading === true || !hasDimension || samplesData?.loading === true;
143
- if (!hasDimension && metadataLoading !== true) {
144
- return (_jsx("div", { className: "flex justify-center items-center py-10 text-gray-500 dark:text-gray-400 text-sm", children: "Select a label in the \"Samples group by\" dropdown above to view the samples strips." }));
201
+ var data = samplesData.series.map(function (s_0) {
202
+ return s_0.data;
203
+ });
204
+ var stepMs = (_samplesData$stepMs = samplesData.stepMs) !== null && _samplesData$stepMs !== void 0 ? _samplesData$stepMs : 0;
205
+ return {
206
+ cpus: cpus,
207
+ data: data,
208
+ stepMs: stepMs
209
+ };
210
+ }, [samplesData === null || samplesData === void 0 ? void 0 : samplesData.series, samplesData === null || samplesData === void 0 ? void 0 : samplesData.stepMs]);
211
+ var _validateFlameChartQu = validateFlameChartQuery(profileSource),
212
+ isValid = _validateFlameChartQu.isValid,
213
+ isNonDelta = _validateFlameChartQu.isNonDelta,
214
+ isDurationTooLong = _validateFlameChartQu.isDurationTooLong;
215
+ if (!isValid) {
216
+ if (isDurationTooLong) {
217
+ return /*#__PURE__*/_jsxs("div", {
218
+ className: "flex flex-col justify-center items-center p-10 text-center gap-4 text-sm",
219
+ children: [/*#__PURE__*/_jsx("span", {
220
+ children: "Flame chart is unavailable for queries longer than 15 minutes. Try reducing the time range to 15 minutes or selecting a point in the metrics graph."
221
+ }), onSwitchToFifteenMinutes != null && /*#__PURE__*/_jsx(Button, {
222
+ variant: "primary",
223
+ onClick: onSwitchToFifteenMinutes,
224
+ children: "Switch to last 15 minutes"
225
+ })]
226
+ });
145
227
  }
146
- return (_jsxs("div", { children: [(isStripsLoading || (stripsData.cpus.length > 0 && stripsData.data.length > 0)) && (_jsx("div", { className: "mb-2", children: _jsx(SamplesStrip, { loading: isStripsLoading, cpus: stripsData.cpus, data: stripsData.data, selectedTimeframe: selectedTimeframe, onSelectedTimeframe: handleSelectedTimeframe, width: width, bounds: [Number(timeBounds[0] / 1000000n), Number(timeBounds[1] / 1000000n)], stepMs: stripsData.stepMs }) })), selectedTimeframe != null &&
147
- (() => {
148
- const labels = selectedTimeframe.labels.labels
149
- .map(l => `${l.name} = ${l.value}`)
150
- .join(', ');
151
- const durationMs = selectedTimeframe.bounds[1] - selectedTimeframe.bounds[0];
152
- const duration = durationMs < 5000
153
- ? `${(durationMs / 1000).toFixed(1)}s`
154
- : formatDuration({ [TimeUnits.Milliseconds]: durationMs });
155
- const fmt = durationMs < 5000 ? "yyyy-MM-dd HH:mm:ss.SSS '(UTC)'" : timeFormat();
156
- return (_jsxs("div", { className: "flex items-center justify-between px-2 py-1", children: [_jsxs("div", { className: "text-xs font-medium text-gray-500 dark:text-gray-400", children: ["Samples matching ", labels, " over ", duration, " from", ' ', formatDate(new Date(selectedTimeframe.bounds[0]), fmt), " to", ' ', formatDate(new Date(selectedTimeframe.bounds[1]), fmt)] }), _jsx("div", { ref: zoomControlsRef })] }));
157
- })(), selectedTimeframe != null && filteredProfileSource != null ? (_jsx(ProfileFlameGraph, { arrow: flamechartArrow, loading: flamechartLoading, error: flamechartError, profileSource: filteredProfileSource, width: width, total: flamechartTotal, filtered: flamechartFiltered, profileType: profileType, isHalfScreen: isHalfScreen, metadataMappingFiles: metadataMappingFiles, metadataLoading: metadataLoading, isFlameChart: true, curPathArrow: [], setNewCurPathArrow: () => { }, zoomControlsRef: zoomControlsRef })) : (_jsx("div", { className: "flex justify-center items-center py-10 text-gray-500 dark:text-gray-400 text-sm", children: "Select a time range in the samples strips above to view the flamechart." }))] }));
228
+ var message = isNonDelta ? 'To use the Flame chart, please switch to a Delta profile.' : 'Flame chart is unavailable for this query.';
229
+ return /*#__PURE__*/_jsx("div", {
230
+ className: "flex flex-col justify-center p-10 text-center gap-6 text-sm",
231
+ children: message
232
+ });
233
+ }
234
+ var hasDimension = (flamechartDimension !== null && flamechartDimension !== void 0 ? flamechartDimension : []).length > 0;
235
+ var isStripsLoading = metadataLoading === true || !hasDimension || (samplesData === null || samplesData === void 0 ? void 0 : samplesData.loading) === true;
236
+ if (!hasDimension && metadataLoading !== true) {
237
+ return /*#__PURE__*/_jsx("div", {
238
+ className: "flex justify-center items-center py-10 text-gray-500 dark:text-gray-400 text-sm",
239
+ children: "Select a label in the \"Samples group by\" dropdown above to view the samples strips."
240
+ });
241
+ }
242
+ return /*#__PURE__*/_jsxs("div", {
243
+ children: [(isStripsLoading || stripsData.cpus.length > 0 && stripsData.data.length > 0) && /*#__PURE__*/_jsx("div", {
244
+ className: "mb-2",
245
+ children: /*#__PURE__*/_jsx(SamplesStrip, {
246
+ loading: isStripsLoading,
247
+ cpus: stripsData.cpus,
248
+ data: stripsData.data,
249
+ selectedTimeframe: selectedTimeframe,
250
+ onSelectedTimeframe: handleSelectedTimeframe,
251
+ width: width,
252
+ bounds: [Number(timeBounds[0] / 1000000n), Number(timeBounds[1] / 1000000n)],
253
+ stepMs: stripsData.stepMs
254
+ })
255
+ }), selectedTimeframe != null && function () {
256
+ var labels_0 = selectedTimeframe.labels.labels.map(function (l) {
257
+ return "".concat(l.name, " = ").concat(l.value);
258
+ }).join(', ');
259
+ var durationMs = selectedTimeframe.bounds[1] - selectedTimeframe.bounds[0];
260
+ var duration = durationMs < 5000 ? "".concat((durationMs / 1000).toFixed(1), "s") : formatDuration(_defineProperty({}, TimeUnits.Milliseconds, durationMs));
261
+ var fmt = durationMs < 5000 ? "yyyy-MM-dd HH:mm:ss.SSS '(UTC)'" : timeFormat();
262
+ return /*#__PURE__*/_jsxs("div", {
263
+ className: "flex items-center justify-between px-2 py-1",
264
+ children: [/*#__PURE__*/_jsxs("div", {
265
+ className: "text-xs font-medium text-gray-500 dark:text-gray-400",
266
+ children: ["Samples matching ", labels_0, " over ", duration, " from", ' ', formatDate(new Date(selectedTimeframe.bounds[0]), fmt), " to", ' ', formatDate(new Date(selectedTimeframe.bounds[1]), fmt)]
267
+ }), /*#__PURE__*/_jsx("div", {
268
+ ref: zoomControlsRef
269
+ })]
270
+ });
271
+ }(), selectedTimeframe != null && filteredProfileSource != null ? /*#__PURE__*/_jsx(ProfileFlameGraph, {
272
+ arrow: flamechartArrow,
273
+ loading: flamechartLoading,
274
+ error: flamechartError,
275
+ profileSource: filteredProfileSource,
276
+ width: width,
277
+ total: flamechartTotal,
278
+ filtered: flamechartFiltered,
279
+ profileType: profileType,
280
+ isHalfScreen: isHalfScreen,
281
+ metadataMappingFiles: metadataMappingFiles,
282
+ metadataLoading: metadataLoading,
283
+ isFlameChart: true,
284
+ curPathArrow: [],
285
+ setNewCurPathArrow: function setNewCurPathArrow() {},
286
+ zoomControlsRef: zoomControlsRef
287
+ }) : /*#__PURE__*/_jsx("div", {
288
+ className: "flex justify-center items-center py-10 text-gray-500 dark:text-gray-400 text-sm",
289
+ children: "Select a time range in the samples strips above to view the flamechart."
290
+ })]
291
+ });
158
292
  };
159
- export default ProfileFlameChart;
293
+ export default ProfileFlameChart;