@cccsaurora/clue-ui 1.2.1-patch.256 → 1.3.0-dev.255

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 (181) hide show
  1. package/ActionForm-C0aE9HUv.js +5941 -0
  2. package/AnnotationDetails-CEou0vCc.js +175 -0
  3. package/AnnotationPreview-CLMVD6Ec.js +188 -0
  4. package/ClueEnrichContext-BkD9ZwM9.js +541 -0
  5. package/FlexOne-BSYAhhtG.js +9 -0
  6. package/_MapCache-WmuDdwuH.js +222 -0
  7. package/_Uint8Array-DdG4KLKn.js +128 -0
  8. package/_baseAssignValue-CGTuELqU.js +25 -0
  9. package/_baseClone-BpWiBnMp.js +283 -0
  10. package/_baseExtremum-BY663UjY.js +33 -0
  11. package/_baseFlatten-B69cDsaV.js +92 -0
  12. package/_baseGet-Bx3A4Qfp.js +108 -0
  13. package/_baseIsEqual-B4IufFlL.js +208 -0
  14. package/_baseIteratee-7AQvAy1o.js +126 -0
  15. package/_baseSlice-GAv_YFTT.js +20 -0
  16. package/_baseSum-D0WC1dN0.js +13 -0
  17. package/_baseUniq-B8fK6hI-.js +115 -0
  18. package/_commonjsHelpers-DWwsNxpa.js +8 -0
  19. package/_createAggregator-CwGPThny.js +63 -0
  20. package/_getPrototype-CblfEidB.js +5 -0
  21. package/_getTag-jwz4XLoZ.js +126 -0
  22. package/_setToArray-CaPKQhcz.js +33 -0
  23. package/cloneDeep-DmUylbkM.js +8 -0
  24. package/components/AnnotationBody.js +49 -35
  25. package/components/AnnotationDetailPopover.js +36 -30
  26. package/components/AnnotationDetails.js +7 -7
  27. package/components/AnnotationEntry.js +35 -35
  28. package/components/AnnotationPreview.js +5 -5
  29. package/components/ClassificationChip.js +44 -23
  30. package/components/CountBadge.js +31 -26
  31. package/components/EnrichedCard.js +110 -97
  32. package/components/EnrichedChip.js +130 -105
  33. package/components/EnrichedTypography.js +133 -107
  34. package/components/ErrorBoundary.js +28 -24
  35. package/components/RetryFailedEnrichments.js +10 -9
  36. package/components/SourcePicker.js +57 -49
  37. package/components/actions/ActionForm.js +4 -4
  38. package/components/actions/ExecutePopover.js +75 -59
  39. package/components/actions/ResultModal.js +4 -4
  40. package/components/actions/form/schemaAdapter.js +39 -23
  41. package/components/actions/formats/FileResult.js +86 -59
  42. package/components/actions/formats/index.js +21 -10
  43. package/components/display/graph/ExpandMoreButton.js +10 -10
  44. package/components/display/graph/elements/NodeCard.js +111 -91
  45. package/components/display/graph/elements/NodeTag.js +15 -13
  46. package/components/display/graph/index.js +261 -202
  47. package/components/display/graph/visualizations/Leaf.js +88 -69
  48. package/components/display/graph/visualizations/cloud/index.js +98 -81
  49. package/components/display/graph/visualizations/icons/BaseIcon.js +26 -21
  50. package/components/display/graph/visualizations/icons/BugIcon.js +12 -12
  51. package/components/display/graph/visualizations/icons/HostIcon.js +12 -12
  52. package/components/display/graph/visualizations/icons/NetworkIcon.js +12 -12
  53. package/components/display/graph/visualizations/icons/ProcessIcon.js +12 -12
  54. package/components/display/graph/visualizations/icons/TargetIcon.js +13 -13
  55. package/components/display/graph/visualizations/icons/index.js +14 -13
  56. package/components/display/graph/visualizations/panels/NodePanel.js +10 -8
  57. package/components/display/graph/visualizations/tree/BundleLine.js +108 -81
  58. package/components/display/graph/visualizations/tree/Triangle.js +13 -13
  59. package/components/display/graph/visualizations/tree/index.js +407 -306
  60. package/components/display/icons/Iconified.js +27 -12
  61. package/components/display/json/index.js +4 -4
  62. package/components/display/markdown/index.js +8678 -5770
  63. package/components/enrichment/EnrichPopover.js +54 -46
  64. package/components/fetchers/Fetcher.js +155 -117
  65. package/components/fetchers/PreviewModal.js +20 -17
  66. package/components/fetchers/StatusChip.js +21 -17
  67. package/components/group/Entry.js +13 -11
  68. package/components/group/Group.js +13 -10
  69. package/components/group/GroupControl.js +76 -65
  70. package/components/stats/QueryStatus.js +43 -33
  71. package/countBy-DqlU5OwT.js +14 -0
  72. package/data/event.js +6 -4
  73. package/database/index.js +2 -2
  74. package/debounce-bV0h5FC5.js +92 -0
  75. package/get-DSsNkRQs.js +8 -0
  76. package/groupBy-ChDRT7uy.js +14 -0
  77. package/hooks/ClueActionContext.js +6 -6
  78. package/hooks/ClueComponentContext.js +29 -23
  79. package/hooks/ClueConfigProvider.js +14 -12
  80. package/hooks/ClueDatabaseContext.js +19 -13
  81. package/hooks/ClueEnrichContext.js +8 -8
  82. package/hooks/ClueFetcherContext.js +83 -56
  83. package/hooks/ClueGroupContext.js +17 -14
  84. package/hooks/CluePopupContext.js +5 -5
  85. package/hooks/ClueProvider.js +12 -10
  86. package/hooks/selectors.js +7 -7
  87. package/hooks/useActionResult.js +2 -2
  88. package/hooks/useAnnotations.js +47 -31
  89. package/hooks/useClue.js +6 -4
  90. package/hooks/useClueActions.js +3 -3
  91. package/hooks/useClueConfig.js +6 -4
  92. package/hooks/useClueTypeConfig.js +3 -3
  93. package/hooks/useComparator.js +722 -435
  94. package/hooks/useErrors.js +22 -18
  95. package/hooks/useFetcherResult.js +33 -24
  96. package/hooks/useMyHighlights.js +66 -36
  97. package/hooks/useMyLocalStorage.js +66 -37
  98. package/iconify-CXMreGTg.js +1782 -0
  99. package/icons/Action.js +66 -49
  100. package/icons/Assessment.js +84 -69
  101. package/icons/Context.js +77 -63
  102. package/icons/Opinion.js +78 -60
  103. package/icons/iconMap.js +2 -2
  104. package/identity-CPGTqrE4.js +6 -0
  105. package/index-AMfoEg_6.js +696 -0
  106. package/index-B6C2a_Lg.js +1172 -0
  107. package/index-C12gPw2W.js +17698 -0
  108. package/index-DCKkHTvx.js +15750 -0
  109. package/index-UkW8Sur3.js +465 -0
  110. package/isNil-CIubwp4T.js +6 -0
  111. package/isObject-FTY-5JQX.js +7 -0
  112. package/isObjectLike-OAgjjZye.js +48 -0
  113. package/isSymbol-Xd2FsJyp.js +8 -0
  114. package/last-CUCl67Im.js +7 -0
  115. package/main.js +60 -60
  116. package/package.json +1 -1
  117. package/sortBy-C7mGPI_D.js +100 -0
  118. package/sumBy-CGALjmwQ.js +8 -0
  119. package/text/Frequency.js +42 -23
  120. package/toFinite-Bc55msYj.js +16 -0
  121. package/toNumber-DPxy1FBy.js +39 -0
  122. package/useClueTypeConfig-D2tf4-NM.js +3289 -0
  123. package/utils/chain.js +91 -65
  124. package/utils/classificationParser.js +519 -256
  125. package/utils/constants.js +35 -10
  126. package/utils/graph.js +72 -45
  127. package/utils/hashUtil.js +7 -7
  128. package/utils/line.js +131 -81
  129. package/utils/loggerUtil.js +5 -3
  130. package/utils/sessionStorage.js +41 -27
  131. package/utils/time.js +423 -423
  132. package/utils/utils.js +9 -9
  133. package/utils/window.js +21 -10
  134. package/utils-71DpzFrA.js +199 -0
  135. package/ActionForm-DlOXqMUx.js +0 -4460
  136. package/AnnotationDetails-Bk-p0F6h.js +0 -160
  137. package/AnnotationPreview-jzZvkCxJ.js +0 -140
  138. package/ClueEnrichContext-KqRuuWNS.js +0 -418
  139. package/FlexOne-BXWFOd1T.js +0 -6
  140. package/_MapCache-BiTi0iqu.js +0 -180
  141. package/_Uint8Array-BQNOM9Rr.js +0 -101
  142. package/_baseAssignValue-CNMLQZco.js +0 -20
  143. package/_baseClone-BnT-6pyM.js +0 -207
  144. package/_baseExtremum-Ca2EHgy2.js +0 -16
  145. package/_baseFlatten-Bfr_Molw.js +0 -72
  146. package/_baseGet-DSZygzyq.js +0 -79
  147. package/_baseIsEqual-VgvaAFZG.js +0 -147
  148. package/_baseIteratee-Dbfsw5z8.js +0 -95
  149. package/_baseSlice-M5RKzt1A.js +0 -10
  150. package/_baseSum-wEbgNeUs.js +0 -10
  151. package/_baseUniq-BJcj69PL.js +0 -79
  152. package/_commonjsHelpers-DaMA6jEr.js +0 -8
  153. package/_createAggregator-k3TuAnxT.js +0 -53
  154. package/_getPrototype-Cr1Mk7BC.js +0 -5
  155. package/_getTag-CK2Sffaq.js +0 -90
  156. package/_isIterateeCall-DkJP7Rbx.js +0 -13
  157. package/_setToArray-C7yMOeww.js +0 -29
  158. package/cloneDeep-CF8TtLHr.js +0 -8
  159. package/countBy-CdYegFSu.js +0 -8
  160. package/debounce-DryYcbJ4.js +0 -56
  161. package/get-CH7kz5Ix.js +0 -8
  162. package/groupBy-br8xmD2R.js +0 -8
  163. package/iconify-BBckr5AQ.js +0 -1263
  164. package/identity-ByMq8VxU.js +0 -6
  165. package/index-BHAe_V9n.js +0 -12768
  166. package/index-BK-zfYhR.js +0 -358
  167. package/index-CA5CUNZO.js +0 -975
  168. package/index-Dj5C04IX.js +0 -568
  169. package/index-p5_wX7q1.js +0 -11729
  170. package/isNil-CjWwlQS3.js +0 -6
  171. package/isObject-B53jY8Qg.js +0 -7
  172. package/isObjectLike-BatpeCIi.js +0 -29
  173. package/isSymbol-C3_SC0Qp.js +0 -8
  174. package/last-7CdUxN0r.js +0 -7
  175. package/maxBy-Bc0dYHcO.js +0 -8
  176. package/sortBy-DY2JBf9n.js +0 -75
  177. package/sumBy-DuMASLPd.js +0 -8
  178. package/toFinite-BMy6GObD.js +0 -14
  179. package/toNumber-YVhnnJv4.js +0 -31
  180. package/useClueTypeConfig-Ct9Ygter.js +0 -2292
  181. package/utils-DmwSUrum.js +0 -129
@@ -1,41 +1,54 @@
1
- import { jsxs as it, jsx as L, Fragment as At } from "react/jsx-runtime";
2
- import { useTheme as Bt, colors as wt, Box as Ft } from "@mui/material";
3
- import It from "../../../../../hooks/useComparator.js";
4
- import Wt from "../../../../../hooks/useMyHighlights.js";
5
- import { useMyLocalStorageItem as Ot } from "../../../../../hooks/useMyLocalStorage.js";
6
- import { StorageKey as Pt, BUNDLE_SEPARATOR as Ht } from "../../../../../utils/constants.js";
7
- import { c as Xt } from "../../../../../cloneDeep-CF8TtLHr.js";
8
- import { g as Tt } from "../../../../../get-CH7kz5Ix.js";
9
- import { i as Yt } from "../../../../../isNil-CjWwlQS3.js";
10
- import { b as $t, a as jt } from "../../../../../_baseExtremum-Ca2EHgy2.js";
11
- import { i as Nt } from "../../../../../identity-ByMq8VxU.js";
12
- import { i as Ut } from "../../../../../_isIterateeCall-DkJP7Rbx.js";
13
- import { t as et } from "../../../../../toFinite-BMy6GObD.js";
14
- import { b as Gt } from "../../../../../_baseSum-wEbgNeUs.js";
15
- import { memo as Vt, useMemo as S } from "react";
16
- import qt from "../../elements/NodeCard.js";
17
- import zt from "../icons/index.js";
18
- import Jt from "../Leaf.js";
19
- import Qt from "./BundleLine.js";
20
- function kt(c) {
21
- return c && c.length ? $t(c, Nt, jt) : void 0;
1
+ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
+ import { useTheme, colors, Box } from "@mui/material";
3
+ import useComparator from "../../../../../hooks/useComparator.js";
4
+ import useMyHighlights from "../../../../../hooks/useMyHighlights.js";
5
+ import { useMyLocalStorageItem } from "../../../../../hooks/useMyLocalStorage.js";
6
+ import { StorageKey, BUNDLE_SEPARATOR } from "../../../../../utils/constants.js";
7
+ import { c as cloneDeep } from "../../../../../cloneDeep-DmUylbkM.js";
8
+ import { g as get } from "../../../../../get-DSsNkRQs.js";
9
+ import { i as isNil } from "../../../../../isNil-CIubwp4T.js";
10
+ import { b as baseExtremum, a as baseGt, i as isIterateeCall } from "../../../../../_baseExtremum-BY663UjY.js";
11
+ import { i as identity } from "../../../../../identity-CPGTqrE4.js";
12
+ import { t as toFinite } from "../../../../../toFinite-Bc55msYj.js";
13
+ import { b as baseSum } from "../../../../../_baseSum-D0WC1dN0.js";
14
+ import { memo, useMemo } from "react";
15
+ import NodeCard from "../../elements/NodeCard.js";
16
+ import getIcon from "../icons/index.js";
17
+ import Leaf from "../Leaf.js";
18
+ import BundleLine from "./BundleLine.js";
19
+ function max(array) {
20
+ return array && array.length ? baseExtremum(array, identity, baseGt) : void 0;
22
21
  }
23
- var Zt = Math.ceil, Kt = Math.max;
24
- function ti(c, n, r, h) {
25
- for (var d = -1, _ = Kt(Zt((n - c) / (r || 1)), 0), v = Array(_); _--; )
26
- v[++d] = c, c += r;
27
- return v;
22
+ var nativeCeil = Math.ceil, nativeMax = Math.max;
23
+ function baseRange(start, end, step, fromRight) {
24
+ var index = -1, length = nativeMax(nativeCeil((end - start) / (step || 1)), 0), result = Array(length);
25
+ while (length--) {
26
+ result[++index] = start;
27
+ start += step;
28
+ }
29
+ return result;
28
30
  }
29
- function ii(c) {
30
- return function(n, r, h) {
31
- return h && typeof h != "number" && Ut(n, r, h) && (r = h = void 0), n = et(n), r === void 0 ? (r = n, n = 0) : r = et(r), h = h === void 0 ? n < r ? 1 : -1 : et(h), ti(n, r, h);
31
+ function createRange(fromRight) {
32
+ return function(start, end, step) {
33
+ if (step && typeof step != "number" && isIterateeCall(start, end, step)) {
34
+ end = step = void 0;
35
+ }
36
+ start = toFinite(start);
37
+ if (end === void 0) {
38
+ end = start;
39
+ start = 0;
40
+ } else {
41
+ end = toFinite(end);
42
+ }
43
+ step = step === void 0 ? start < end ? 1 : -1 : toFinite(step);
44
+ return baseRange(start, end, step);
32
45
  };
33
46
  }
34
- var ei = ii();
35
- function ni(c) {
36
- return c && c.length ? Gt(c, Nt) : 0;
47
+ var range = createRange();
48
+ function sum(array) {
49
+ return array && array.length ? baseSum(array, identity) : 0;
37
50
  }
38
- const nt = {
51
+ const DEFAULT_OPTIONS = {
39
52
  textColor: "white",
40
53
  nodeColor: {
41
54
  border: "grey",
@@ -50,335 +63,423 @@ const nt = {
50
63
  linePaddingX: 10,
51
64
  linePaddingY: 10,
52
65
  lineWidth: 3,
53
- enableEntryPadding: !0,
54
- truncateLabels: !0,
55
- enableTimestamps: !0,
66
+ enableEntryPadding: true,
67
+ truncateLabels: true,
68
+ enableTimestamps: true,
56
69
  iconOrientation: "vertical",
57
70
  lineDirection: "horizontal",
58
71
  rowStep: null,
59
72
  // We'll make this dynamic
60
- belowPrevious: !1
73
+ belowPrevious: false
61
74
  };
62
- nt.rowStep = nt.ySpacing * 2;
63
- const ai = ({ svgRef: c, graph: n, labelKeys: r, onNodeSelectionChanged: h, zoom: d, options: _ = {} }) => {
64
- var gt, xt, vt;
65
- const v = S(
75
+ DEFAULT_OPTIONS.rowStep = DEFAULT_OPTIONS.ySpacing * 2;
76
+ const Tree = ({ svgRef, graph, labelKeys, onNodeSelectionChanged, zoom, options = {} }) => {
77
+ var _a, _b, _c;
78
+ const combinedOptions = useMemo(
66
79
  () => {
67
- var i, o;
80
+ var _a2, _b2;
68
81
  return {
69
- ...nt,
70
- ..._,
71
- ...((o = (i = n == null ? void 0 : n.metadata.display) == null ? void 0 : i.visualization) == null ? void 0 : o.config) ?? {}
82
+ ...DEFAULT_OPTIONS,
83
+ ...options,
84
+ ...((_b2 = (_a2 = graph == null ? void 0 : graph.metadata.display) == null ? void 0 : _a2.visualization) == null ? void 0 : _b2.config) ?? {}
72
85
  };
73
86
  },
74
- [(xt = (gt = n == null ? void 0 : n.metadata.display) == null ? void 0 : gt.visualization) == null ? void 0 : xt.config, _]
75
- ), {
76
- xSpacing: at,
77
- ySpacing: ot,
78
- linePaddingX: rt,
79
- linePaddingY: st
80
- } = v, { runComparators: lt, runComparator: W } = It(), { onNodeHoveredChanged: A, onNodeClicked: ct, nodeOpacities: H, highlightedPath: dt, highlightedNodes: ft, hoveredNode: pt } = Wt(n, (i) => h(i)), u = Bt(), ut = S(() => u.palette.mode === "dark", [u]), [X] = Ot(Pt.SHOW_CARDS, !1), [mt] = Ot(Pt.CARD_CUTOFF, 2.5), Y = S(() => d.k > mt && X, [mt, X, d.k]), w = S(
81
- () => n.data.map(
82
- (i, o) => i.map((l) => ({
83
- ...l,
84
- parents: l == null ? void 0 : l.edges,
85
- level: o
87
+ [(_b = (_a = graph == null ? void 0 : graph.metadata.display) == null ? void 0 : _a.visualization) == null ? void 0 : _b.config, options]
88
+ );
89
+ const {
90
+ xSpacing: baseXSpacing,
91
+ ySpacing: baseYSpacing,
92
+ linePaddingX: baseLinePaddingX,
93
+ linePaddingY: baseLinePaddingY
94
+ } = combinedOptions;
95
+ const { runComparators, runComparator } = useComparator();
96
+ const { onNodeHoveredChanged, onNodeClicked, nodeOpacities, highlightedPath, highlightedNodes, hoveredNode } = useMyHighlights(graph, (nodeIds) => onNodeSelectionChanged(nodeIds));
97
+ const theme = useTheme();
98
+ const isDark = useMemo(() => theme.palette.mode === "dark", [theme]);
99
+ const [showCardsSettings] = useMyLocalStorageItem(StorageKey.SHOW_CARDS, false);
100
+ const [cardCutoff] = useMyLocalStorageItem(StorageKey.CARD_CUTOFF, 2.5);
101
+ const showCards = useMemo(() => zoom.k > cardCutoff && showCardsSettings, [cardCutoff, showCardsSettings, zoom.k]);
102
+ const levels = useMemo(
103
+ () => graph.data.map(
104
+ (level, levelIndex) => level.map((node) => ({
105
+ ...node,
106
+ parents: node == null ? void 0 : node.edges,
107
+ level: levelIndex
86
108
  }))
87
109
  ),
88
- [n.data]
89
- ), C = S(() => w.flat(), [w]), [$, j, ht, M] = S(() => {
90
- const i = [
91
- [at, rt],
92
- [ot, st]
110
+ [graph.data]
111
+ );
112
+ const flatNodes = useMemo(() => levels.flat(), [levels]);
113
+ const [xSpacing, linePaddingX, ySpacing, linePaddingY] = useMemo(() => {
114
+ const baseValues = [
115
+ [baseXSpacing, baseLinePaddingX],
116
+ [baseYSpacing, baseLinePaddingY]
93
117
  ];
94
- return d.k > 1 && X ? i.flatMap(
95
- (o, l) => o.map((s) => s * Math.pow(2.5 - l * 1.25, Math.min(d.k, 2.5) - 1))
96
- ) : i.flat();
97
- }, [rt, st, at, ot, X, d.k]);
98
- let B;
99
- if (!n || !c.current)
100
- B = [
118
+ if (zoom.k > 1 && showCardsSettings) {
119
+ return baseValues.flatMap(
120
+ (arr, index) => arr.map((_v) => _v * Math.pow(2.5 - index * 1.25, Math.min(zoom.k, 2.5) - 1))
121
+ );
122
+ } else {
123
+ return baseValues.flat();
124
+ }
125
+ }, [baseLinePaddingX, baseLinePaddingY, baseXSpacing, baseYSpacing, showCardsSettings, zoom.k]);
126
+ let portBounds;
127
+ if (!graph || !svgRef.current) {
128
+ portBounds = [
101
129
  [0, 0],
102
130
  [0, 0]
103
131
  ];
104
- else {
105
- const i = c.current.getBoundingClientRect();
106
- B = [d.invert([0, 0]), d.invert([i.width, i.height])];
132
+ } else {
133
+ const data = svgRef.current.getBoundingClientRect();
134
+ portBounds = [zoom.invert([0, 0]), zoom.invert([data.width, data.height])];
107
135
  }
108
- const U = S(() => {
109
- const i = {};
110
- return C.forEach((o) => {
111
- if (!o.parents)
136
+ const bundles = useMemo(() => {
137
+ const bundlesDict = {};
138
+ flatNodes.forEach((node) => {
139
+ if (!node.parents) {
112
140
  return;
113
- const l = o.parents.join(Ht);
114
- i[l] ? i[l].destinations.push(o) : i[l] = {
115
- id: l,
116
- sources: o.parents.map((s) => C.find((E) => E.id === s)),
117
- destinations: [o]
118
- };
119
- }), Object.values(i);
120
- }, [C]), G = S(() => {
141
+ }
142
+ const bundleId = node.parents.join(BUNDLE_SEPARATOR);
143
+ if (bundlesDict[bundleId]) {
144
+ bundlesDict[bundleId].destinations.push(node);
145
+ } else {
146
+ bundlesDict[bundleId] = {
147
+ id: bundleId,
148
+ sources: node.parents.map((parent) => flatNodes.find((_node) => _node.id === parent)),
149
+ destinations: [node]
150
+ };
151
+ }
152
+ });
153
+ return Object.values(bundlesDict);
154
+ }, [flatNodes]);
155
+ const layoutData = useMemo(() => {
121
156
  const {
122
- letterSize: i,
123
- letterWidth: o,
124
- enableEntryPadding: l,
125
- truncateLabels: s,
126
- rowStep: E,
127
- belowPrevious: F
128
- } = v;
129
- let V = 0, O = 0;
130
- const P = {}, T = {}, R = {}, k = {}, D = {};
131
- return w.forEach((e, a) => {
132
- let b = 0;
133
- e.forEach((f) => {
134
- var q;
135
- const g = r == null ? void 0 : r.filter((t) => W(t, f)), m = (q = g == null ? void 0 : g.pop()) == null ? void 0 : q.label, p = (m == null ? void 0 : m.split(",").map((t) => Tt(f, t)).filter((t) => !!t)) ?? [];
136
- p.length < 1 && f.id.split(`
137
- `).forEach((t) => p.push(t));
138
- const I = p.length * i;
139
- O += I, P[f.id] = [+V, +O, -M], O += ht, l && (b = Math.max(b, kt((p == null ? void 0 : p.map((t) => t.toString().length)) ?? [f.id.length])));
140
- }), V += $ + (s ? Math.min(b, 44) : b) * o, F ? O += E : O = (a + 1) * E;
141
- }), U.forEach((e) => {
142
- e.sources.forEach((a) => {
143
- D[a.id] || (D[a.id] = /* @__PURE__ */ new Set()), D[a.id].add(e.id);
144
- }), e.destinations.forEach((a) => {
145
- Yt(T[a.level]) && (T[a.level] = /* @__PURE__ */ new Set()), k[a.id] || (k[a.id] = /* @__PURE__ */ new Set()), T[a.level].add(e.id), k[a.id].add(e.id);
157
+ letterSize,
158
+ letterWidth,
159
+ enableEntryPadding,
160
+ truncateLabels,
161
+ rowStep,
162
+ belowPrevious
163
+ } = combinedOptions;
164
+ let currentX = 0;
165
+ let currentY = 0;
166
+ const nodeLocations = {};
167
+ const linesByLevel = {};
168
+ const paddingByLevel = {};
169
+ const inputs = {};
170
+ const outputs = {};
171
+ levels.forEach((level, levelIndex) => {
172
+ let longestLabel = 0;
173
+ level.forEach((node) => {
174
+ var _a2;
175
+ const validKeys = labelKeys == null ? void 0 : labelKeys.filter((_comparator) => runComparator(_comparator, node));
176
+ const labelKey = (_a2 = validKeys == null ? void 0 : validKeys.pop()) == null ? void 0 : _a2.label;
177
+ const labelRows = (labelKey == null ? void 0 : labelKey.split(",").map((key) => get(node, key)).filter((val) => !!val)) ?? [];
178
+ if (labelRows.length < 1) {
179
+ node.id.split("\n").forEach((line) => labelRows.push(line));
180
+ }
181
+ const labelHeight = labelRows.length * letterSize;
182
+ currentY += labelHeight;
183
+ nodeLocations[node.id] = [+currentX, +currentY, -linePaddingY];
184
+ currentY += ySpacing;
185
+ if (enableEntryPadding) {
186
+ longestLabel = Math.max(longestLabel, max((labelRows == null ? void 0 : labelRows.map((row) => row.toString().length)) ?? [node.id.length]));
187
+ }
146
188
  });
147
- }), Object.entries(T).forEach(([e, a]) => R[e] = a.size), w.forEach((e, a) => {
148
- const f = ei(a + 1).map((m) => R[m] ?? 0), g = ni(f) * j;
149
- e.forEach((m) => {
150
- P[m.id][0] += g;
189
+ currentX += xSpacing + (!truncateLabels ? longestLabel : Math.min(longestLabel, 44)) * letterWidth;
190
+ if (!belowPrevious) {
191
+ currentY = (levelIndex + 1) * rowStep;
192
+ } else {
193
+ currentY += rowStep;
194
+ }
195
+ });
196
+ bundles.forEach((bundle) => {
197
+ bundle.sources.forEach((source) => {
198
+ if (!outputs[source.id]) {
199
+ outputs[source.id] = /* @__PURE__ */ new Set();
200
+ }
201
+ outputs[source.id].add(bundle.id);
151
202
  });
152
- }), C.forEach((e) => {
153
- var f, g, m;
154
- let a = kt([((f = k[e.id]) == null ? void 0 : f.size) - 1, ((g = D[e.id]) == null ? void 0 : g.size) - 1, 0]) * M;
155
- (m = k[e.id]) != null && m.has(e.id) && (a += M), P[e.id][2] = a;
156
- const b = w[e.level].findIndex((p) => p.id === e.id);
157
- w[e.level].filter((p, I) => b < I).forEach((p) => {
158
- P[p.id][1] += a;
203
+ bundle.destinations.forEach((dest) => {
204
+ if (isNil(linesByLevel[dest.level])) {
205
+ linesByLevel[dest.level] = /* @__PURE__ */ new Set();
206
+ }
207
+ if (!inputs[dest.id]) {
208
+ inputs[dest.id] = /* @__PURE__ */ new Set();
209
+ }
210
+ linesByLevel[dest.level].add(bundle.id);
211
+ inputs[dest.id].add(bundle.id);
159
212
  });
160
- }), {
161
- nodeLocations: P,
162
- linesByLevel: T,
163
- paddingByLevel: R
213
+ });
214
+ Object.entries(linesByLevel).forEach(([level, lines]) => paddingByLevel[level] = lines.size);
215
+ levels.forEach((level, levelIndex) => {
216
+ const indexesSoFar = range(levelIndex + 1);
217
+ const paddingArray = indexesSoFar.map((_levelIndex) => paddingByLevel[_levelIndex] ?? 0);
218
+ const totalPadding = sum(paddingArray) * linePaddingX;
219
+ level.forEach((node) => {
220
+ nodeLocations[node.id][0] += totalPadding;
221
+ });
222
+ });
223
+ flatNodes.forEach((node) => {
224
+ var _a2, _b2, _c2;
225
+ let maxHeight = max([((_a2 = inputs[node.id]) == null ? void 0 : _a2.size) - 1, ((_b2 = outputs[node.id]) == null ? void 0 : _b2.size) - 1, 0]) * linePaddingY;
226
+ if ((_c2 = inputs[node.id]) == null ? void 0 : _c2.has(node.id)) {
227
+ maxHeight += linePaddingY;
228
+ }
229
+ nodeLocations[node.id][2] = maxHeight;
230
+ const levelIndex = levels[node.level].findIndex((_node) => _node.id === node.id);
231
+ levels[node.level].filter((__, index) => levelIndex < index).forEach((_node) => {
232
+ nodeLocations[_node.id][1] += maxHeight;
233
+ });
234
+ });
235
+ return {
236
+ nodeLocations,
237
+ linesByLevel,
238
+ paddingByLevel
164
239
  };
165
240
  }, [
166
- U,
167
- v,
168
- C,
169
- r,
170
- w,
171
- j,
172
- M,
173
- W,
174
- $,
175
- ht
176
- ]), [Mt, Rt, Dt] = S(() => {
241
+ bundles,
242
+ combinedOptions,
243
+ flatNodes,
244
+ labelKeys,
245
+ levels,
246
+ linePaddingX,
247
+ linePaddingY,
248
+ runComparator,
249
+ xSpacing,
250
+ ySpacing
251
+ ]);
252
+ const [timestamps, bundleElements, nodes] = useMemo(() => {
177
253
  const {
178
- textColor: i,
179
- letterSize: o,
180
- letterWidth: l,
181
- nodeRadius: s,
182
- nodeColor: E,
183
- maxArcRadius: F,
184
- lineWidth: V,
185
- truncateLabels: O,
186
- enableTimestamps: P,
187
- belowPrevious: T,
188
- iconOrientation: R,
189
- lineDirection: k,
190
- colorTheme: D
191
- } = v, { nodeLocations: e, linesByLevel: a, paddingByLevel: b } = G, f = [], g = [];
192
- C.forEach((t) => {
193
- var St, Ct, bt, Et;
194
- const [yt, z, Z] = e[t.id], K = ((St = r == null ? void 0 : r.filter((y) => W(y, t)).pop()) == null ? void 0 : St.label) ?? "id";
195
- let J = K == null ? void 0 : K.split(",").map((y) => {
196
- let x = Tt(t, y);
197
- return x && O && x.length > 44 && (x = x.replace(/^(.{32}).+$/, "$1 (TRUNCATED)")), x;
198
- }).filter((y) => !!y).join(`
199
- `);
200
- if (J || (t.id.length > 44 ? J = t.id.replace(/^(.{32}).+$/, "$1 (TRUNCATED)") : J = t.id), T && P && (t.timestamp || t.annotation) && g.push(
201
- /* @__PURE__ */ it(
202
- "g",
203
- {
204
- style: {
205
- cursor: "default",
206
- fontFamily: '"Lucida Console", monospace',
207
- fontSize: o * 0.75 + "px"
208
- },
209
- children: [
210
- /* @__PURE__ */ L(
211
- "text",
212
- {
213
- x: B[0][0] + $,
214
- y: z + (Z + s) / 2,
215
- fill: u.palette.getContrastText(u.palette.background.paper),
216
- style: {
217
- fillOpacity: H(t.id) / 2,
218
- transition: u.transitions.create(["fill-opacity"], {
219
- duration: u.transitions.duration.short
220
- })
221
- },
222
- children: t.timestamp
223
- }
224
- ),
225
- t.annotation && t.annotation.split(`
226
- `).map((y, x) => {
227
- var Q;
228
- return /* @__PURE__ */ L(
254
+ textColor,
255
+ letterSize,
256
+ letterWidth,
257
+ nodeRadius,
258
+ nodeColor,
259
+ maxArcRadius,
260
+ lineWidth,
261
+ truncateLabels,
262
+ enableTimestamps,
263
+ belowPrevious,
264
+ iconOrientation,
265
+ lineDirection,
266
+ colorTheme
267
+ } = combinedOptions;
268
+ const { nodeLocations, linesByLevel, paddingByLevel } = layoutData;
269
+ const _nodes = [];
270
+ const _timestamps = [];
271
+ flatNodes.forEach((node) => {
272
+ var _a2, _b2, _c2, _d;
273
+ const [x, y, _height] = nodeLocations[node.id];
274
+ const labelKey = ((_a2 = labelKeys == null ? void 0 : labelKeys.filter((_comparator) => runComparator(_comparator, node)).pop()) == null ? void 0 : _a2.label) ?? "id";
275
+ let label = labelKey == null ? void 0 : labelKey.split(",").map((key) => {
276
+ let labelSection = get(node, key);
277
+ if (labelSection && truncateLabels && labelSection.length > 44) {
278
+ labelSection = labelSection.replace(/^(.{32}).+$/, "$1 (TRUNCATED)");
279
+ }
280
+ return labelSection;
281
+ }).filter((section) => !!section).join("\n");
282
+ if (!label) {
283
+ if (node.id.length > 44) {
284
+ label = node.id.replace(/^(.{32}).+$/, "$1 (TRUNCATED)");
285
+ } else {
286
+ label = node.id;
287
+ }
288
+ }
289
+ if (belowPrevious && enableTimestamps && (node.timestamp || node.annotation)) {
290
+ _timestamps.push(
291
+ /* @__PURE__ */ jsxs(
292
+ "g",
293
+ {
294
+ style: {
295
+ cursor: "default",
296
+ fontFamily: '"Lucida Console", monospace',
297
+ fontSize: letterSize * 0.75 + "px"
298
+ },
299
+ children: [
300
+ /* @__PURE__ */ jsx(
229
301
  "text",
230
302
  {
231
- x: B[0][0] + (((Q = t.timestamp) == null ? void 0 : Q.length) ?? 0) * l,
232
- y: z + (Z + s) / 2 + x * o,
233
- fill: ut ? wt.orange[300] : wt.blue[900],
303
+ x: portBounds[0][0] + xSpacing,
304
+ y: y + (_height + nodeRadius) / 2,
305
+ fill: theme.palette.getContrastText(theme.palette.background.paper),
234
306
  style: {
235
- fillOpacity: H(t.id),
236
- transition: u.transitions.create(["fill-opacity"], {
237
- duration: u.transitions.duration.short
307
+ fillOpacity: nodeOpacities(node.id) / 2,
308
+ transition: theme.transitions.create(["fill-opacity"], {
309
+ duration: theme.transitions.duration.short
238
310
  })
239
311
  },
240
- children: y
241
- },
242
- y
243
- );
244
- })
245
- ]
246
- },
247
- t.id + "-timestamp"
248
- )
249
- ), !Y) {
250
- const y = lt(
251
- (bt = (Ct = n.metadata.display) == null ? void 0 : Ct.styles) == null ? void 0 : bt.filter((N) => N.type === "node"),
252
- t
253
- ), x = H(t.id), Q = (Et = t.icons) == null ? void 0 : Et.map((N) => [N, zt(N)]).filter(([N, tt]) => !!tt).map(([N, tt], Lt) => /* @__PURE__ */ L(
254
- tt,
312
+ children: node.timestamp
313
+ }
314
+ ),
315
+ node.annotation && node.annotation.split("\n").map((line, index) => {
316
+ var _a3;
317
+ return /* @__PURE__ */ jsx(
318
+ "text",
319
+ {
320
+ x: portBounds[0][0] + (((_a3 = node.timestamp) == null ? void 0 : _a3.length) ?? 0) * letterWidth,
321
+ y: y + (_height + nodeRadius) / 2 + index * letterSize,
322
+ fill: isDark ? colors.orange[300] : colors.blue[900],
323
+ style: {
324
+ fillOpacity: nodeOpacities(node.id),
325
+ transition: theme.transitions.create(["fill-opacity"], {
326
+ duration: theme.transitions.duration.short
327
+ })
328
+ },
329
+ children: line
330
+ },
331
+ line
332
+ );
333
+ })
334
+ ]
335
+ },
336
+ node.id + "-timestamp"
337
+ )
338
+ );
339
+ }
340
+ if (!showCards) {
341
+ const style = runComparators(
342
+ (_c2 = (_b2 = graph.metadata.display) == null ? void 0 : _b2.styles) == null ? void 0 : _c2.filter((comparator) => comparator.type === "node"),
343
+ node
344
+ );
345
+ const nodeOpacity = nodeOpacities(node.id);
346
+ const icons = (_d = node.icons) == null ? void 0 : _d.map((icon) => [icon, getIcon(icon)]).filter(([__, icon]) => !!icon).map(([icon, Icon], index) => /* @__PURE__ */ jsx(
347
+ Icon,
255
348
  {
256
- x: yt - s * 3 * (R === "horizontal" ? Lt + 1 : 0),
257
- y: z - s * 3 * (R === "vertical" ? Lt + 1 : 0),
258
- size: o * 1.5,
349
+ x: x - nodeRadius * 3 * (iconOrientation === "horizontal" ? index + 1 : 0),
350
+ y: y - nodeRadius * 3 * (iconOrientation === "vertical" ? index + 1 : 0),
351
+ size: letterSize * 1.5,
259
352
  style: {
260
- fillOpacity: x
353
+ fillOpacity: nodeOpacity
261
354
  },
262
355
  circleStyle: {
263
- fillOpacity: x
356
+ fillOpacity: nodeOpacity
264
357
  }
265
358
  },
266
- N
359
+ icon
267
360
  ));
268
- f.push(
269
- /* @__PURE__ */ L(
270
- Jt,
361
+ _nodes.push(
362
+ /* @__PURE__ */ jsx(
363
+ Leaf,
271
364
  {
272
- alwaysShowText: !0,
273
- nodeId: t.id,
274
- label: J,
275
- height: Z,
276
- x: yt,
277
- y: z,
278
- style: y,
279
- nodeRadius: s,
280
- nodeColor: E,
281
- nodeOpacity: x,
282
- letterSize: o,
283
- letterWidth: l,
284
- textColor: i,
285
- selected: ft.has(t.id),
286
- onHoverChanged: A,
287
- onClick: ct,
288
- children: Q
365
+ alwaysShowText: true,
366
+ nodeId: node.id,
367
+ label,
368
+ height: _height,
369
+ x,
370
+ y,
371
+ style,
372
+ nodeRadius,
373
+ nodeColor,
374
+ nodeOpacity,
375
+ letterSize,
376
+ letterWidth,
377
+ textColor,
378
+ selected: highlightedNodes.has(node.id),
379
+ onHoverChanged: onNodeHoveredChanged,
380
+ onClick: onNodeClicked,
381
+ children: icons
289
382
  },
290
- t.id
383
+ node.id
291
384
  )
292
385
  );
293
386
  }
294
387
  });
295
- const m = Xt(e), p = {}, I = {}, q = U.map((t) => /* @__PURE__ */ L(
296
- Qt,
297
- {
298
- lineDirection: k,
299
- linesByLevel: a,
300
- paddingByLevel: b,
301
- nodeLocations: m,
302
- outputsByNode: p,
303
- inputsByNode: I,
304
- bundle: t,
305
- maxArcRadius: F,
306
- lineWidth: V,
307
- linePaddingX: j,
308
- linePaddingY: M,
309
- highlightedPath: dt,
310
- colorTheme: D
311
- },
312
- t.id
313
- ));
314
- return [g, q, f];
388
+ const readonlyNodeLocations = cloneDeep(nodeLocations);
389
+ const outputsByNode = {};
390
+ const inputsByNode = {};
391
+ const _bundleElements = bundles.map((bundle) => {
392
+ return /* @__PURE__ */ jsx(
393
+ BundleLine,
394
+ {
395
+ lineDirection,
396
+ linesByLevel,
397
+ paddingByLevel,
398
+ nodeLocations: readonlyNodeLocations,
399
+ outputsByNode,
400
+ inputsByNode,
401
+ bundle,
402
+ maxArcRadius,
403
+ lineWidth,
404
+ linePaddingX,
405
+ linePaddingY,
406
+ highlightedPath,
407
+ colorTheme
408
+ },
409
+ bundle.id
410
+ );
411
+ });
412
+ return [_timestamps, _bundleElements, _nodes];
315
413
  }, [
316
- U,
317
- v,
318
- (vt = n.metadata.display) == null ? void 0 : vt.styles,
319
- C,
320
- ft,
321
- dt,
322
- ut,
323
- r,
324
- G,
325
- j,
326
- M,
327
- H,
328
- ct,
329
- A,
330
- B,
331
- W,
332
- lt,
333
- Y,
334
- u.palette,
335
- u.transitions,
336
- $
337
- ]), _t = S(() => {
338
- const { nodeRadius: i, lineWidth: o } = v, { nodeLocations: l } = G;
339
- return C.filter((s) => Y || pt === s.id).map((s) => {
340
- const [E, F] = l[s.id];
341
- return /* @__PURE__ */ L(
342
- Ft,
414
+ bundles,
415
+ combinedOptions,
416
+ (_c = graph.metadata.display) == null ? void 0 : _c.styles,
417
+ flatNodes,
418
+ highlightedNodes,
419
+ highlightedPath,
420
+ isDark,
421
+ labelKeys,
422
+ layoutData,
423
+ linePaddingX,
424
+ linePaddingY,
425
+ nodeOpacities,
426
+ onNodeClicked,
427
+ onNodeHoveredChanged,
428
+ portBounds,
429
+ runComparator,
430
+ runComparators,
431
+ showCards,
432
+ theme.palette,
433
+ theme.transitions,
434
+ xSpacing
435
+ ]);
436
+ const cards = useMemo(() => {
437
+ const { nodeRadius, lineWidth } = combinedOptions;
438
+ const { nodeLocations } = layoutData;
439
+ return flatNodes.filter((node) => showCards || hoveredNode === node.id).map((node) => {
440
+ const [x, y] = nodeLocations[node.id];
441
+ return /* @__PURE__ */ jsx(
442
+ Box,
343
443
  {
344
- onMouseOver: () => A(s.id, !0),
345
- onMouseLeave: () => setTimeout(() => A(s.id, !1), 100),
444
+ onMouseOver: () => onNodeHoveredChanged(node.id, true),
445
+ onMouseLeave: () => setTimeout(() => onNodeHoveredChanged(node.id, false), 100),
346
446
  sx: {
347
447
  position: "absolute",
348
- left: d.k * E + d.x,
349
- top: d.k * F + d.y,
350
- transform: `translateX(-${i * 2}px) translateY(${o}px)`,
351
- backgroundColor: u.palette.background.paper,
448
+ left: zoom.k * x + zoom.x,
449
+ top: zoom.k * y + zoom.y,
450
+ transform: `translateX(-${nodeRadius * 2}px) translateY(${lineWidth}px)`,
451
+ backgroundColor: theme.palette.background.paper,
352
452
  maxWidth: "450px",
353
453
  maxHeight: "500px",
354
454
  overflow: "auto"
355
455
  },
356
- children: /* @__PURE__ */ L(qt, { node: s })
456
+ children: /* @__PURE__ */ jsx(NodeCard, { node })
357
457
  },
358
- s.id
458
+ node.id
359
459
  );
360
460
  });
361
461
  }, [
362
- v,
363
- C,
364
- pt,
365
- G,
366
- A,
367
- Y,
368
- u.palette.background.paper,
369
- d.k,
370
- d.x,
371
- d.y
462
+ combinedOptions,
463
+ flatNodes,
464
+ hoveredNode,
465
+ layoutData,
466
+ onNodeHoveredChanged,
467
+ showCards,
468
+ theme.palette.background.paper,
469
+ zoom.k,
470
+ zoom.x,
471
+ zoom.y
372
472
  ]);
373
- return /* @__PURE__ */ it(At, { children: [
374
- /* @__PURE__ */ L("svg", { id: "viz", ref: c, children: /* @__PURE__ */ it("g", { id: "view", children: [
375
- Mt,
376
- Rt,
377
- Dt
473
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
474
+ /* @__PURE__ */ jsx("svg", { id: "viz", ref: svgRef, children: /* @__PURE__ */ jsxs("g", { id: "view", children: [
475
+ timestamps,
476
+ bundleElements,
477
+ nodes
378
478
  ] }) }),
379
- _t
479
+ cards
380
480
  ] });
381
- }, Li = Vt(ai);
481
+ };
482
+ const Tree$1 = memo(Tree);
382
483
  export {
383
- Li as default
484
+ Tree$1 as default
384
485
  };