@cccsaurora/clue-ui 1.0.1-dev.55 → 1.0.1

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 (180) hide show
  1. package/ActionForm-WIj7BfD5.js +340 -0
  2. package/AnnotationPreview-DWRDhxUB.js +140 -0
  3. package/ClueEnrichContext-CbJVBm4w.js +397 -0
  4. package/FlexOne-BXWFOd1T.js +6 -0
  5. package/_Map-DXNg_Z-q.js +54 -0
  6. package/_MapCache-Cu25RRDU.js +129 -0
  7. package/_Uint8Array-DlJCtTvG.js +102 -0
  8. package/_baseAssignValue-CUmzp727.js +20 -0
  9. package/_baseClone-BlMmRXeX.js +208 -0
  10. package/_baseExtremum-P_0akmCi.js +27 -0
  11. package/_baseFlatten-CN7vDNEQ.js +72 -0
  12. package/_baseGet-Dgf6_xCm.js +80 -0
  13. package/_baseIsEqual-Cpjtfb3Q.js +173 -0
  14. package/_baseIteratee-CP1bocOX.js +95 -0
  15. package/_baseSlice-M5RKzt1A.js +10 -0
  16. package/_baseSum-wEbgNeUs.js +10 -0
  17. package/_baseUniq-tMFmk80M.js +61 -0
  18. package/_commonjsHelpers-C6fGbg64.js +6 -0
  19. package/_createAggregator-B4Cav8ZM.js +53 -0
  20. package/_getPrototype-CHAFQYL_.js +5 -0
  21. package/_getTag-BV_UoLYG.js +90 -0
  22. package/cloneDeep-BPVpFBzJ.js +8 -0
  23. package/components/AnnotationBody.js +34 -49
  24. package/components/AnnotationDetailPopover.js +30 -36
  25. package/components/AnnotationDetails.js +94 -109
  26. package/components/AnnotationEntry.js +52 -55
  27. package/components/AnnotationPreview.js +5 -5
  28. package/components/ClassificationChip.js +23 -44
  29. package/components/CountBadge.js +26 -31
  30. package/components/EnrichedCard.js +92 -104
  31. package/components/EnrichedChip.js +109 -134
  32. package/components/EnrichedTypography.js +110 -136
  33. package/components/ErrorBoundary.js +24 -28
  34. package/components/RetryFailedEnrichments.js +9 -10
  35. package/components/SourcePicker.js +49 -57
  36. package/components/actions/ActionForm.js +4 -4
  37. package/components/actions/ExecutePopover.js +50 -64
  38. package/components/actions/ResultModal.js +34 -37
  39. package/components/actions/form/schemaAdapter.js +20 -39
  40. package/components/display/graph/ExpandMoreButton.js +10 -10
  41. package/components/display/graph/elements/NodeCard.js +76 -92
  42. package/components/display/graph/elements/NodeTag.js +13 -15
  43. package/components/display/graph/index.js +200 -258
  44. package/components/display/graph/visualizations/Leaf.js +69 -88
  45. package/components/display/graph/visualizations/cloud/index.js +81 -98
  46. package/components/display/graph/visualizations/icons/BaseIcon.js +21 -26
  47. package/components/display/graph/visualizations/icons/BugIcon.js +12 -12
  48. package/components/display/graph/visualizations/icons/HostIcon.js +12 -12
  49. package/components/display/graph/visualizations/icons/NetworkIcon.js +12 -12
  50. package/components/display/graph/visualizations/icons/ProcessIcon.js +12 -12
  51. package/components/display/graph/visualizations/icons/TargetIcon.js +13 -13
  52. package/components/display/graph/visualizations/icons/index.js +13 -14
  53. package/components/display/graph/visualizations/panels/NodePanel.js +8 -10
  54. package/components/display/graph/visualizations/tree/BundleLine.js +81 -108
  55. package/components/display/graph/visualizations/tree/Triangle.js +13 -13
  56. package/components/display/graph/visualizations/tree/index.js +305 -407
  57. package/components/display/icons/Iconified.js +12 -27
  58. package/components/display/json/index.js +4 -4
  59. package/components/display/markdown/DynamicTabs.js +17 -22
  60. package/components/display/markdown/index.js +5674 -8531
  61. package/components/display/markdown/markdownPlugins/tabs.js +1 -1
  62. package/components/enrichment/EnrichPopover.js +47 -55
  63. package/components/fetchers/Fetcher.js +95 -123
  64. package/components/fetchers/PreviewModal.js +17 -20
  65. package/components/fetchers/StatusChip.js +18 -22
  66. package/components/group/Entry.js +11 -13
  67. package/components/group/Group.js +10 -13
  68. package/components/group/GroupControl.js +65 -76
  69. package/components/stats/QueryStatus.js +28 -37
  70. package/countBy-DOutsa_w.js +8 -0
  71. package/data/event.js +4 -6
  72. package/database/index.js +2 -2
  73. package/debounce-DryYcbJ4.js +56 -0
  74. package/get-Bow1vKwx.js +8 -0
  75. package/groupBy-BheQYl6f.js +8 -0
  76. package/hooks/ClueActionContext.js +6 -6
  77. package/hooks/ClueComponentContext.js +23 -29
  78. package/hooks/ClueConfigProvider.js +12 -14
  79. package/hooks/ClueDatabaseContext.js +13 -19
  80. package/hooks/ClueEnrichContext.js +8 -8
  81. package/hooks/ClueFetcherContext.js +46 -74
  82. package/hooks/ClueGroupContext.js +14 -17
  83. package/hooks/CluePopupContext.js +5 -5
  84. package/hooks/ClueProvider.js +10 -12
  85. package/hooks/selectors.js +11 -22
  86. package/hooks/useAnnotations.js +32 -48
  87. package/hooks/useClue.js +4 -6
  88. package/hooks/useClueActions.js +3 -3
  89. package/hooks/useClueConfig.js +5 -5
  90. package/hooks/useClueTypeConfig.js +3 -3
  91. package/hooks/useComparator.js +435 -722
  92. package/hooks/useErrors.js +18 -22
  93. package/hooks/useMyHighlights.js +36 -66
  94. package/hooks/useMyLocalStorage.js +43 -63
  95. package/iconify-BBckr5AQ.js +1263 -0
  96. package/icons/Action.js +49 -66
  97. package/icons/Assessment.js +68 -84
  98. package/icons/Context.js +61 -75
  99. package/icons/Opinion.js +65 -77
  100. package/icons/iconMap.js +2 -2
  101. package/identity-ByMq8VxU.js +6 -0
  102. package/index-4YFAh_sa.js +358 -0
  103. package/index-E7g8cRyW.js +568 -0
  104. package/index-HuYhutsd.js +975 -0
  105. package/index-WvFmjbxF.js +12734 -0
  106. package/index-p5_wX7q1.js +11729 -0
  107. package/isEmpty-g47Qir2A.js +21 -0
  108. package/isNil-CjWwlQS3.js +6 -0
  109. package/isObject-B53jY8Qg.js +7 -0
  110. package/isObjectLike-BatpeCIi.js +29 -0
  111. package/isSymbol-C3_SC0Qp.js +8 -0
  112. package/isUndefined-DiNCDKoz.js +10 -0
  113. package/last-7CdUxN0r.js +7 -0
  114. package/main.js +68 -68
  115. package/package.json +1 -1
  116. package/sortBy-ITdmD17L.js +79 -0
  117. package/sumBy-DxJUU2E8.js +8 -0
  118. package/tabs-CgADNA57.js +195 -0
  119. package/text/Frequency.js +23 -42
  120. package/toFinite-BMy6GObD.js +14 -0
  121. package/toNumber-YVhnnJv4.js +31 -0
  122. package/useClueTypeConfig-BQ33EiyB.js +2273 -0
  123. package/utils/chain.js +64 -91
  124. package/utils/classificationParser.js +254 -504
  125. package/utils/constants.js +10 -35
  126. package/utils/graph.js +45 -72
  127. package/utils/hashUtil.js +7 -7
  128. package/utils/line.js +81 -131
  129. package/utils/loggerUtil.js +3 -5
  130. package/utils/sessionStorage.js +29 -41
  131. package/utils/utils.js +9 -9
  132. package/utils/window.js +10 -21
  133. package/utils-C_RX5uMP.js +2704 -0
  134. package/ActionForm-c5hLIfQ-.js +0 -436
  135. package/AnnotationPreview-BvNpZOP0.js +0 -188
  136. package/ClueEnrichContext-m-4vn9rz.js +0 -518
  137. package/FlexOne-BSYAhhtG.js +0 -9
  138. package/_Map-kgDsDYxq.js +0 -64
  139. package/_MapCache-DabaaWfq.js +0 -161
  140. package/_Uint8Array-BlVVH1tp.js +0 -129
  141. package/_baseAssignValue-CNbcU6Nb.js +0 -25
  142. package/_baseClone-D3a8Pa4T.js +0 -284
  143. package/_baseExtremum-B1o1zHjR.js +0 -33
  144. package/_baseFlatten-D4huXoEI.js +0 -92
  145. package/_baseGet-BSK_nnoz.js +0 -109
  146. package/_baseIsEqual-B5xLoweL.js +0 -238
  147. package/_baseIteratee-p6Nj07-n.js +0 -126
  148. package/_baseSlice-GAv_YFTT.js +0 -20
  149. package/_baseSum-D0WC1dN0.js +0 -13
  150. package/_baseUniq-CpupKWcL.js +0 -89
  151. package/_commonjsHelpers-CUmg6egw.js +0 -6
  152. package/_createAggregator-BpVy5xMi.js +0 -63
  153. package/_getPrototype-D1LAdQKO.js +0 -5
  154. package/_getTag-D3ToyefI.js +0 -126
  155. package/cloneDeep-CjP5k9zW.js +0 -8
  156. package/countBy-C69WslUA.js +0 -14
  157. package/debounce-bV0h5FC5.js +0 -92
  158. package/get-D3C3lEU3.js +0 -8
  159. package/groupBy-DC2oOuBN.js +0 -14
  160. package/iconify-CXMreGTg.js +0 -1782
  161. package/identity-CPGTqrE4.js +0 -6
  162. package/index-BDVjGvMI.js +0 -696
  163. package/index-BDrtH5ec.js +0 -465
  164. package/index-BbPn6-Mw.js +0 -15750
  165. package/index-C9lySIVX.js +0 -1172
  166. package/index-Dn2NHyXg.js +0 -17654
  167. package/isEmpty-BQkZubqU.js +0 -29
  168. package/isNil-CIubwp4T.js +0 -6
  169. package/isObject-FTY-5JQX.js +0 -7
  170. package/isObjectLike-OAgjjZye.js +0 -48
  171. package/isSymbol-Xd2FsJyp.js +0 -8
  172. package/isUndefined-CE8h73dH.js +0 -10
  173. package/last-CUCl67Im.js +0 -7
  174. package/sortBy-B-UKp4GT.js +0 -100
  175. package/sumBy-MYkDPHZL.js +0 -8
  176. package/tabs-xGuUGsJd.js +0 -254
  177. package/toFinite-Bc55msYj.js +0 -16
  178. package/toNumber-DPxy1FBy.js +0 -39
  179. package/useClueTypeConfig-D4zcy8Gr.js +0 -3184
  180. package/utils-CxIhC2xH.js +0 -4182
@@ -1,162 +1,150 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
2
- import { I as Icon } from "../iconify-CXMreGTg.js";
3
- import { useTheme, Card, CardHeader, Stack, CircularProgress, Divider, CardContent, Grid, Chip, Typography, Tooltip, Box } from "@mui/material";
4
- import { ClueComponentContext } from "../hooks/ClueComponentContext.js";
5
- import { useClueEnrichSelector } from "../hooks/selectors.js";
6
- import useAnnotations from "../hooks/useAnnotations.js";
7
- import useErrors from "../hooks/useErrors.js";
8
- import AssessmentIcon from "../icons/Assessment.js";
9
- import ContextIcon from "../icons/Context.js";
10
- import OpinionIcon from "../icons/Opinion.js";
11
- import { ICON_MAP } from "../icons/iconMap.js";
12
- import FrequencyText from "../text/Frequency.js";
13
- import { memo, useState, useMemo, useCallback } from "react";
14
- import { u as useContextSelector } from "../index-BDVjGvMI.js";
15
- import AnnotationEntry from "./AnnotationEntry.js";
16
- import { u as uniq } from "../ClueEnrichContext-m-4vn9rz.js";
17
- const EnrichedCard = ({
18
- type,
19
- value,
20
- classification: _classification,
21
- contextIcon = false,
22
- counters = false,
23
- hideLoading = false,
24
- ...otherProps
1
+ import { jsxs as a, jsx as t } from "react/jsx-runtime";
2
+ import { I as h } from "../iconify-BBckr5AQ.js";
3
+ import { useTheme as q, Card as F, CardHeader as M, Stack as O, CircularProgress as W, Divider as $, CardContent as B, Grid as s, Chip as C, Typography as g, Tooltip as D, Box as G } from "@mui/material";
4
+ import { ClueComponentContext as H } from "../hooks/ClueComponentContext.js";
5
+ import { useClueEnrichSelector as b } from "../hooks/selectors.js";
6
+ import N from "../hooks/useAnnotations.js";
7
+ import J from "../hooks/useErrors.js";
8
+ import K from "../icons/Assessment.js";
9
+ import L from "../icons/Context.js";
10
+ import Q from "../icons/Opinion.js";
11
+ import { ICON_MAP as T } from "../icons/iconMap.js";
12
+ import R from "../text/Frequency.js";
13
+ import { memo as U, useState as V, useMemo as z, useCallback as X } from "react";
14
+ import { u as Y } from "../index-E7g8cRyW.js";
15
+ import Z from "./AnnotationEntry.js";
16
+ import { u as _ } from "../ClueEnrichContext-CbJVBm4w.js";
17
+ const P = ({
18
+ type: o,
19
+ value: r,
20
+ classification: f,
21
+ contextIcon: I = !1,
22
+ counters: m = !1,
23
+ hideLoading: y = !1,
24
+ ...e
25
25
  }) => {
26
- const theme = useTheme();
27
- const { t } = useContextSelector(ClueComponentContext, (ctx) => ctx.i18next);
28
- const defaultClassification = useClueEnrichSelector((ctx) => ctx.defaultClassification);
29
- const enrich = useClueEnrichSelector((state) => state.enrich);
30
- const [filter, setFilter] = useState("all");
31
- const classification = useMemo(
32
- () => _classification ?? defaultClassification,
33
- [_classification, defaultClassification]
34
- );
35
- const [annotations, loading] = useAnnotations(type, value, classification);
36
- const errors = useErrors(value);
37
- const options = useMemo(() => ["all", ...uniq(annotations.map((annotation) => annotation.type))], [annotations]);
38
- const forceEnrich = useCallback(() => {
39
- return enrich(type, value, {
40
- classification,
41
- timeout: 15,
42
- force: true
43
- });
44
- }, [classification, enrich, type, value]);
45
- return /* @__PURE__ */ jsxs(
46
- Card,
26
+ const p = q(), { t: E } = Y(H, (i) => i.i18next), u = b((i) => i.defaultClassification), x = b((i) => i.enrich), [S, A] = V("all"), l = z(
27
+ () => f ?? u,
28
+ [f, u]
29
+ ), [n, k] = N(o, r, l), c = J(r), v = z(() => ["all", ..._(n.map((i) => i.type))], [n]), w = X(() => x(o, r, {
30
+ classification: l,
31
+ timeout: 15,
32
+ force: !0
33
+ }), [l, x, o, r]);
34
+ return /* @__PURE__ */ a(
35
+ F,
47
36
  {
48
37
  sx: [
49
38
  {
50
39
  maxWidth: "900px"
51
40
  },
52
- ...Array.isArray(otherProps == null ? void 0 : otherProps.sx) ? otherProps == null ? void 0 : otherProps.sx : [otherProps == null ? void 0 : otherProps.sx]
41
+ ...Array.isArray(e == null ? void 0 : e.sx) ? e == null ? void 0 : e.sx : [e == null ? void 0 : e.sx]
53
42
  ],
54
- ...otherProps,
43
+ ...e,
55
44
  children: [
56
- /* @__PURE__ */ jsx(
57
- CardHeader,
45
+ /* @__PURE__ */ t(
46
+ M,
58
47
  {
59
- title: /* @__PURE__ */ jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [
60
- /* @__PURE__ */ jsx(FrequencyText, { annotations, value, variant: "h6" }),
61
- /* @__PURE__ */ jsx(
62
- AssessmentIcon,
48
+ title: /* @__PURE__ */ a(O, { direction: "row", spacing: 1, alignItems: "center", children: [
49
+ /* @__PURE__ */ t(R, { annotations: n, value: r, variant: "h6" }),
50
+ /* @__PURE__ */ t(
51
+ K,
63
52
  {
64
- value: { type, value, classification },
65
- annotations,
66
- counters,
53
+ value: { type: o, value: r, classification: l },
54
+ annotations: n,
55
+ counters: m,
67
56
  fontSize: "1em",
68
- disableTooltip: true
57
+ disableTooltip: !0
69
58
  }
70
59
  ),
71
- /* @__PURE__ */ jsx(
72
- OpinionIcon,
60
+ /* @__PURE__ */ t(
61
+ Q,
73
62
  {
74
- value: { type, value, classification },
75
- annotations,
76
- counters,
63
+ value: { type: o, value: r, classification: l },
64
+ annotations: n,
65
+ counters: m,
77
66
  fontSize: "1em",
78
- disableTooltip: true
67
+ disableTooltip: !0
79
68
  }
80
69
  ),
81
- /* @__PURE__ */ jsx(
82
- ContextIcon,
70
+ /* @__PURE__ */ t(
71
+ L,
83
72
  {
84
- value: { type, value, classification },
85
- annotations,
86
- counters,
87
- showExtraIcon: contextIcon,
73
+ value: { type: o, value: r, classification: l },
74
+ annotations: n,
75
+ counters: m,
76
+ showExtraIcon: I,
88
77
  fontSize: "inherit",
89
- disableTooltip: true
78
+ disableTooltip: !0
90
79
  }
91
80
  ),
92
- loading && !hideLoading && /* @__PURE__ */ jsx(CircularProgress, { color: "primary", size: 18 })
81
+ k && !y && /* @__PURE__ */ t(W, { color: "primary", size: 18 })
93
82
  ] })
94
83
  }
95
84
  ),
96
- /* @__PURE__ */ jsx(Divider, { sx: { mx: 1 } }),
97
- /* @__PURE__ */ jsxs(CardContent, { sx: { p: 1 }, children: [
98
- /* @__PURE__ */ jsxs(Grid, { container: true, spacing: 0.5, sx: { mb: 1 }, children: [
99
- options.map((opt, id) => (
85
+ /* @__PURE__ */ t($, { sx: { mx: 1 } }),
86
+ /* @__PURE__ */ a(B, { sx: { p: 1 }, children: [
87
+ /* @__PURE__ */ a(s, { container: !0, spacing: 0.5, sx: { mb: 1 }, children: [
88
+ v.map((i, d) => (
100
89
  // eslint-disable-next-line react/no-array-index-key
101
- /* @__PURE__ */ jsx(Grid, { item: true, children: /* @__PURE__ */ jsx(
102
- Chip,
90
+ /* @__PURE__ */ t(s, { item: !0, children: /* @__PURE__ */ t(
91
+ C,
103
92
  {
104
93
  size: "small",
105
- variant: opt === filter ? "filled" : "outlined",
106
- icon: ICON_MAP[opt] && /* @__PURE__ */ jsx(Icon, { icon: ICON_MAP[opt] }),
107
- label: /* @__PURE__ */ jsxs(Typography, { variant: "caption", textTransform: "capitalize", children: [
108
- opt,
94
+ variant: i === S ? "filled" : "outlined",
95
+ icon: T[i] && /* @__PURE__ */ t(h, { icon: T[i] }),
96
+ label: /* @__PURE__ */ a(g, { variant: "caption", textTransform: "capitalize", children: [
97
+ i,
109
98
  ":",
110
99
  " ",
111
- opt === "all" ? annotations.length : annotations.filter((annotation) => annotation.type === opt).length
100
+ i === "all" ? n.length : n.filter((j) => j.type === i).length
112
101
  ] }),
113
- onClick: () => setFilter(opt)
102
+ onClick: () => A(i)
114
103
  }
115
- ) }, id)
104
+ ) }, d)
116
105
  )),
117
- (errors == null ? void 0 : errors.length) > 0 && /* @__PURE__ */ jsx(Grid, { item: true, children: /* @__PURE__ */ jsx(
118
- Tooltip,
106
+ (c == null ? void 0 : c.length) > 0 && /* @__PURE__ */ t(s, { item: !0, children: /* @__PURE__ */ t(
107
+ D,
119
108
  {
120
- title: /* @__PURE__ */ jsx("div", { onClick: (e) => e.stopPropagation(), children: errors.map((err) => /* @__PURE__ */ jsxs("div", { children: [
121
- /* @__PURE__ */ jsx("span", { style: { textTransform: "capitalize" }, children: err.source.replace(/-/g, " ") }),
109
+ title: /* @__PURE__ */ t("div", { onClick: (i) => i.stopPropagation(), children: c.map((i) => /* @__PURE__ */ a("div", { children: [
110
+ /* @__PURE__ */ t("span", { style: { textTransform: "capitalize" }, children: i.source.replace(/-/g, " ") }),
122
111
  ":",
123
112
  " ",
124
- err.message
125
- ] }, err.source)) }),
126
- children: /* @__PURE__ */ jsx(
127
- Chip,
113
+ i.message
114
+ ] }, i.source)) }),
115
+ children: /* @__PURE__ */ t(
116
+ C,
128
117
  {
129
118
  size: "small",
130
119
  variant: "outlined",
131
- icon: /* @__PURE__ */ jsx(
132
- Icon,
120
+ icon: /* @__PURE__ */ t(
121
+ h,
133
122
  {
134
123
  icon: "material-symbols:timer-outline",
135
- color: theme.palette.error.main,
124
+ color: p.palette.error.main,
136
125
  style: { filter: "drop-shadow(0px 0px 1px rgb(0 0 0 / 0.4))" }
137
126
  }
138
127
  ),
139
- label: /* @__PURE__ */ jsxs(Typography, { variant: "caption", textTransform: "capitalize", children: [
140
- t("annotation.failed"),
128
+ label: /* @__PURE__ */ a(g, { variant: "caption", textTransform: "capitalize", children: [
129
+ E("annotation.failed"),
141
130
  ": ",
142
- errors.length
131
+ c.length
143
132
  ] }),
144
- onClick: forceEnrich
133
+ onClick: w
145
134
  }
146
135
  )
147
136
  }
148
137
  ) })
149
138
  ] }),
150
- /* @__PURE__ */ jsx(Grid, { container: true, spacing: 1, alignItems: "stretch", children: annotations.map((annotation, id) => (
139
+ /* @__PURE__ */ t(s, { container: !0, spacing: 1, alignItems: "stretch", children: n.map((i, d) => (
151
140
  // eslint-disable-next-line react/no-array-index-key
152
- /* @__PURE__ */ jsx(Grid, { item: true, xs: 6, minWidth: "300px", children: /* @__PURE__ */ jsx(Box, { sx: { border: `thin solid ${theme.palette.divider}`, p: 1, height: "100%" }, children: /* @__PURE__ */ jsx(AnnotationEntry, { annotation }) }) }, id)
141
+ /* @__PURE__ */ t(s, { item: !0, xs: 6, minWidth: "300px", children: /* @__PURE__ */ t(G, { sx: { border: `thin solid ${p.palette.divider}`, p: 1, height: "100%" }, children: /* @__PURE__ */ t(Z, { annotation: i }) }) }, d)
153
142
  )) })
154
143
  ] })
155
144
  ]
156
145
  }
157
146
  );
158
- };
159
- const EnrichedCard$1 = memo(EnrichedCard);
147
+ }, hi = U(P);
160
148
  export {
161
- EnrichedCard$1 as default
149
+ hi as default
162
150
  };
@@ -1,176 +1,151 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { Chip, Tooltip, Box, Stack, CircularProgress } from "@mui/material";
3
- import Iconified from "./display/icons/Iconified.js";
4
- import { ClueComponentContext } from "../hooks/ClueComponentContext.js";
5
- import { ClueGroupContext } from "../hooks/ClueGroupContext.js";
6
- import { C as CluePopupContext } from "../AnnotationPreview-BvNpZOP0.js";
7
- import { useClueEnrichSelector } from "../hooks/selectors.js";
8
- import useAnnotations from "../hooks/useAnnotations.js";
9
- import ActionIcon from "../icons/Action.js";
10
- import AssessmentIcon from "../icons/Assessment.js";
11
- import ContextIcon from "../icons/Context.js";
12
- import OpinionIcon from "../icons/Opinion.js";
13
- import FrequencyText from "../text/Frequency.js";
14
- import React__default, { useRef, useMemo, useCallback, useEffect, memo } from "react";
15
- import { u as useContextSelector } from "../index-BDVjGvMI.js";
16
- const EnrichedChip = React__default.memo(
1
+ import { jsx as l, jsxs as O } from "react/jsx-runtime";
2
+ import { Chip as B, Tooltip as G, Box as $, Stack as H, CircularProgress as J } from "@mui/material";
3
+ import K from "./display/icons/Iconified.js";
4
+ import { ClueComponentContext as L } from "../hooks/ClueComponentContext.js";
5
+ import { ClueGroupContext as N } from "../hooks/ClueGroupContext.js";
6
+ import { C as E } from "../AnnotationPreview-DWRDhxUB.js";
7
+ import { useClueEnrichSelector as Q } from "../hooks/selectors.js";
8
+ import U from "../hooks/useAnnotations.js";
9
+ import V from "../icons/Action.js";
10
+ import v from "../icons/Assessment.js";
11
+ import q from "../icons/Context.js";
12
+ import z from "../icons/Opinion.js";
13
+ import W from "../text/Frequency.js";
14
+ import X, { useRef as Y, useMemo as x, useCallback as Z, useEffect as _, memo as F } from "react";
15
+ import { u as d } from "../index-E7g8cRyW.js";
16
+ const D = X.memo(
17
17
  ({
18
- type: _type,
19
- value,
20
- classification: _classification,
21
- contextIcon = false,
22
- counters = false,
23
- hideDetails = false,
24
- hideLoading = false,
25
- forceDetails = false,
26
- setForceDetails = null,
27
- useDetailsIcon = false,
28
- skipEnrichment = false,
29
- slotProps = {},
30
- ...otherProps
18
+ type: b,
19
+ value: o,
20
+ classification: k,
21
+ contextIcon: y = !1,
22
+ counters: a = !1,
23
+ hideDetails: T = !1,
24
+ hideLoading: A = !1,
25
+ forceDetails: f = !1,
26
+ setForceDetails: u = null,
27
+ useDetailsIcon: p = !1,
28
+ skipEnrichment: R = !1,
29
+ slotProps: s = {},
30
+ ...t
31
31
  }) => {
32
- const { t } = useContextSelector(ClueComponentContext, (ctx) => ctx.i18next);
33
- const anchorRef = useRef();
34
- const groupType = useContextSelector(ClueGroupContext, (ctx) => ctx == null ? void 0 : ctx.type);
35
- const defaultClassification = useClueEnrichSelector((ctx) => ctx.defaultClassification);
36
- const type = useMemo(() => _type ?? groupType, [_type, groupType]);
37
- const classification = useMemo(
38
- () => _classification ?? defaultClassification,
39
- [_classification, defaultClassification]
32
+ const { t: j } = d(L, (i) => i.i18next), C = Y(), S = d(N, (i) => i == null ? void 0 : i.type), w = Q((i) => i.defaultClassification), n = x(() => b ?? S, [b, S]), e = x(
33
+ () => k ?? w,
34
+ [k, w]
40
35
  );
41
- if (!type) {
36
+ if (!n)
42
37
  throw new Error("Type was not provided as a prop, and component is not used in a group context.");
43
- }
44
- const [annotations, loading] = useAnnotations(type, value, classification, { skipEnrichment });
45
- const showInfo = useContextSelector(CluePopupContext, (ctx) => ctx.showInfo);
46
- const closeInfo = useContextSelector(CluePopupContext, (ctx) => ctx.closeInfo);
47
- const buildOptions = useCallback(() => {
48
- const options = {};
49
- if (setForceDetails) {
50
- options.onClose = () => setForceDetails(false);
51
- }
52
- if (slotProps == null ? void 0 : slotProps.popover) {
53
- options.popoverProps = slotProps.popover;
54
- }
55
- return options;
56
- }, [setForceDetails, slotProps.popover]);
57
- const clicker = useMemo(
58
- () => !loading ? !hideDetails || useDetailsIcon ? (e) => {
59
- var _a;
60
- showInfo("details", anchorRef.current, { type, value, classification }, buildOptions());
61
- (_a = otherProps.onClick) == null ? void 0 : _a.call(otherProps, e);
62
- e.stopPropagation();
63
- e.preventDefault();
64
- } : otherProps.onClick : (
38
+ const [m, c] = U(n, o, e, { skipEnrichment: R }), g = d(E, (i) => i.showInfo), M = d(E, (i) => i.closeInfo), h = Z(() => {
39
+ const i = {};
40
+ return u && (i.onClose = () => u(!1)), s != null && s.popover && (i.popoverProps = s.popover), i;
41
+ }, [u, s.popover]), I = x(
42
+ () => c ? (
65
43
  // We need to give a dummy callback when loading so the popover doesn't get confused
66
- (e) => {
67
- var _a;
68
- (_a = otherProps.onClick) == null ? void 0 : _a.call(otherProps, e);
44
+ (i) => {
45
+ var r;
46
+ (r = t.onClick) == null || r.call(t, i);
69
47
  }
70
- ),
48
+ ) : !T || p ? (i) => {
49
+ var r;
50
+ g("details", C.current, { type: n, value: o, classification: e }, h()), (r = t.onClick) == null || r.call(t, i), i.stopPropagation(), i.preventDefault();
51
+ } : t.onClick,
71
52
  // eslint-disable-next-line react-hooks/exhaustive-deps
72
- [loading, hideDetails, useDetailsIcon, otherProps, type, value, classification]
53
+ [c, T, p, t, n, o, e]
73
54
  );
74
- useEffect(() => {
75
- if (forceDetails) {
76
- showInfo("details", anchorRef.current, { type, value, classification }, buildOptions());
77
- } else {
78
- closeInfo("details", {
79
- type,
80
- value,
81
- classification
82
- });
83
- }
84
- }, [classification, forceDetails, type, value]);
85
- return /* @__PURE__ */ jsx(
86
- Chip,
55
+ return _(() => {
56
+ f ? g("details", C.current, { type: n, value: o, classification: e }, h()) : M("details", {
57
+ type: n,
58
+ value: o,
59
+ classification: e
60
+ });
61
+ }, [e, f, n, o]), /* @__PURE__ */ l(
62
+ B,
87
63
  {
88
- ...otherProps,
89
- ref: anchorRef,
90
- variant: otherProps.variant || "outlined",
64
+ ...t,
65
+ ref: C,
66
+ variant: t.variant || "outlined",
91
67
  sx: {
92
- height: otherProps.size !== "small" ? "40px" : "unset",
68
+ height: t.size !== "small" ? "40px" : "unset",
93
69
  "& .MuiChip-label": { overflow: "visible" },
94
- ...otherProps.sx ?? {}
70
+ ...t.sx ?? {}
95
71
  },
96
- label: /* @__PURE__ */ jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [
97
- /* @__PURE__ */ jsx(
98
- AssessmentIcon,
72
+ label: /* @__PURE__ */ O(H, { direction: "row", spacing: 1, alignItems: "center", children: [
73
+ /* @__PURE__ */ l(
74
+ v,
99
75
  {
100
- ubiquitous: true,
101
- value: { type, value, classification },
102
- annotations,
103
- counters,
104
- disableTooltip: forceDetails,
76
+ ubiquitous: !0,
77
+ value: { type: n, value: o, classification: e },
78
+ annotations: m,
79
+ counters: a,
80
+ disableTooltip: f,
105
81
  style: { flexShrink: 0 }
106
82
  }
107
83
  ),
108
- /* @__PURE__ */ jsx(
109
- OpinionIcon,
84
+ /* @__PURE__ */ l(
85
+ z,
110
86
  {
111
- ubiquitous: true,
112
- value: { type, value, classification },
113
- annotations,
114
- counters,
115
- disableTooltip: forceDetails,
87
+ ubiquitous: !0,
88
+ value: { type: n, value: o, classification: e },
89
+ annotations: m,
90
+ counters: a,
91
+ disableTooltip: f,
116
92
  style: { flexShrink: 0 }
117
93
  }
118
94
  ),
119
- /* @__PURE__ */ jsx(
120
- ContextIcon,
95
+ /* @__PURE__ */ l(
96
+ q,
121
97
  {
122
- ubiquitous: true,
123
- value: { type, value, classification },
124
- annotations,
125
- counters,
126
- showExtraIcon: contextIcon,
127
- disableTooltip: forceDetails,
98
+ ubiquitous: !0,
99
+ value: { type: n, value: o, classification: e },
100
+ annotations: m,
101
+ counters: a,
102
+ showExtraIcon: y,
103
+ disableTooltip: f,
128
104
  style: { flexShrink: 0 }
129
105
  }
130
106
  ),
131
- otherProps.label ?? /* @__PURE__ */ jsx(FrequencyText, { fontSize: "inherit", annotations, value }),
132
- /* @__PURE__ */ jsx(
133
- AssessmentIcon,
107
+ t.label ?? /* @__PURE__ */ l(W, { fontSize: "inherit", annotations: m, value: o }),
108
+ /* @__PURE__ */ l(
109
+ v,
134
110
  {
135
- value: { type, value, classification },
136
- annotations,
137
- counters,
138
- disableTooltip: forceDetails,
111
+ value: { type: n, value: o, classification: e },
112
+ annotations: m,
113
+ counters: a,
114
+ disableTooltip: f,
139
115
  style: { flexShrink: 0 }
140
116
  }
141
117
  ),
142
- /* @__PURE__ */ jsx(
143
- OpinionIcon,
118
+ /* @__PURE__ */ l(
119
+ z,
144
120
  {
145
- value: { type, value, classification },
146
- annotations,
147
- counters,
148
- disableTooltip: forceDetails,
121
+ value: { type: n, value: o, classification: e },
122
+ annotations: m,
123
+ counters: a,
124
+ disableTooltip: f,
149
125
  style: { flexShrink: 0 }
150
126
  }
151
127
  ),
152
- /* @__PURE__ */ jsx(
153
- ContextIcon,
128
+ /* @__PURE__ */ l(
129
+ q,
154
130
  {
155
- value: { type, value, classification },
156
- annotations,
157
- counters,
158
- showExtraIcon: contextIcon,
159
- disableTooltip: forceDetails,
131
+ value: { type: n, value: o, classification: e },
132
+ annotations: m,
133
+ counters: a,
134
+ showExtraIcon: y,
135
+ disableTooltip: f,
160
136
  style: { flexShrink: 0 }
161
137
  }
162
138
  ),
163
- /* @__PURE__ */ jsx(ActionIcon, { counters, value: { type, value, classification }, disableTooltip: forceDetails }),
164
- loading && !hideLoading && /* @__PURE__ */ jsx(CircularProgress, { color: "primary", size: 16 })
139
+ /* @__PURE__ */ l(V, { counters: a, value: { type: n, value: o, classification: e }, disableTooltip: f }),
140
+ c && !A && /* @__PURE__ */ l(J, { color: "primary", size: 16 })
165
141
  ] }),
166
- onClick: !useDetailsIcon ? clicker : void 0,
167
- onDelete: !loading && useDetailsIcon ? clicker : void 0,
168
- deleteIcon: useDetailsIcon ? /* @__PURE__ */ jsx(Tooltip, { title: t("details.open"), children: /* @__PURE__ */ jsx(Box, { component: "span", sx: { pr: 1 }, children: /* @__PURE__ */ jsx(Iconified, { icon: "ic:outline-info" }) }) }) : null
142
+ onClick: p ? void 0 : I,
143
+ onDelete: !c && p ? I : void 0,
144
+ deleteIcon: p ? /* @__PURE__ */ l(G, { title: j("details.open"), children: /* @__PURE__ */ l($, { component: "span", sx: { pr: 1 }, children: /* @__PURE__ */ l(K, { icon: "ic:outline-info" }) }) }) : null
169
145
  }
170
146
  );
171
147
  }
172
- );
173
- const EnrichedChip$1 = memo(EnrichedChip);
148
+ ), ui = F(D);
174
149
  export {
175
- EnrichedChip$1 as default
150
+ ui as default
176
151
  };