@cccsaurora/clue-ui 0.15.0 → 1.0.0-dev.49

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 (257) hide show
  1. package/ActionForm-c5hLIfQ-.js +436 -0
  2. package/AnnotationPreview-BvNpZOP0.js +188 -0
  3. package/ClueEnrichContext-m-4vn9rz.js +518 -0
  4. package/FlexOne-BSYAhhtG.js +9 -0
  5. package/_Map-kgDsDYxq.js +64 -0
  6. package/_MapCache-DabaaWfq.js +161 -0
  7. package/_Uint8Array-BlVVH1tp.js +129 -0
  8. package/_baseAssignValue-CNbcU6Nb.js +25 -0
  9. package/_baseClone-D3a8Pa4T.js +284 -0
  10. package/_baseExtremum-B1o1zHjR.js +33 -0
  11. package/_baseFlatten-D4huXoEI.js +92 -0
  12. package/_baseGet-BSK_nnoz.js +109 -0
  13. package/_baseIsEqual-B5xLoweL.js +238 -0
  14. package/_baseIteratee-p6Nj07-n.js +126 -0
  15. package/_baseSlice-GAv_YFTT.js +20 -0
  16. package/_baseSum-D0WC1dN0.js +13 -0
  17. package/_baseUniq-CpupKWcL.js +89 -0
  18. package/_commonjsHelpers-CUmg6egw.js +6 -0
  19. package/_createAggregator-BpVy5xMi.js +63 -0
  20. package/_getPrototype-D1LAdQKO.js +5 -0
  21. package/_getTag-D3ToyefI.js +126 -0
  22. package/api/lookup/enrich.d.ts +10 -0
  23. package/api/lookup/index.d.ts +5 -0
  24. package/api/lookup/types.d.ts +5 -0
  25. package/api/lookup/types_detection.d.ts +5 -0
  26. package/cloneDeep-CjP5k9zW.js +8 -0
  27. package/components/AnnotationBody.d.ts +6 -0
  28. package/components/AnnotationBody.js +56 -0
  29. package/components/AnnotationDetailPopover.d.ts +14 -0
  30. package/components/AnnotationDetailPopover.js +61 -0
  31. package/components/AnnotationDetails.d.ts +8 -0
  32. package/components/AnnotationDetails.js +172 -0
  33. package/components/AnnotationEntry.d.ts +6 -0
  34. package/components/AnnotationEntry.js +59 -0
  35. package/components/AnnotationPreview.d.ts +14 -0
  36. package/components/AnnotationPreview.js +11 -0
  37. package/components/ClassificationChip.d.ts +11 -0
  38. package/components/ClassificationChip.js +52 -0
  39. package/components/CountBadge.d.ts +8 -0
  40. package/components/CountBadge.js +34 -0
  41. package/components/EnrichedCard.d.ts +14 -0
  42. package/components/EnrichedCard.js +162 -0
  43. package/components/EnrichedChip.d.ts +9 -0
  44. package/components/EnrichedChip.js +176 -0
  45. package/components/EnrichedTypography.d.ts +16 -0
  46. package/components/EnrichedTypography.js +178 -0
  47. package/components/ErrorBoundary.d.ts +15 -0
  48. package/components/ErrorBoundary.js +36 -0
  49. package/components/RetryFailedEnrichments.d.ts +2 -0
  50. package/components/RetryFailedEnrichments.js +13 -0
  51. package/components/SourcePicker.d.ts +2 -0
  52. package/components/SourcePicker.js +98 -0
  53. package/components/actions/ActionForm.d.ts +6 -0
  54. package/components/actions/ActionForm.js +16 -0
  55. package/components/actions/ExecutePopover.d.ts +10 -0
  56. package/components/actions/ExecutePopover.js +93 -0
  57. package/components/actions/ResultModal.d.ts +9 -0
  58. package/components/actions/ResultModal.js +46 -0
  59. package/components/actions/form/schemaAdapter.d.ts +3 -0
  60. package/components/actions/form/schemaAdapter.js +47 -0
  61. package/components/display/graph/ExpandMoreButton.d.ts +7 -0
  62. package/components/display/graph/ExpandMoreButton.js +18 -0
  63. package/components/display/graph/elements/NodeCard.d.ts +10 -0
  64. package/components/display/graph/elements/NodeCard.js +146 -0
  65. package/components/display/graph/elements/NodeTag.d.ts +9 -0
  66. package/components/display/graph/elements/NodeTag.js +17 -0
  67. package/components/display/graph/index.d.ts +9 -0
  68. package/components/display/graph/index.js +438 -0
  69. package/components/display/graph/visualizations/Leaf.d.ts +25 -0
  70. package/components/display/graph/visualizations/Leaf.js +125 -0
  71. package/components/display/graph/visualizations/cloud/index.d.ts +24 -0
  72. package/components/display/graph/visualizations/cloud/index.js +141 -0
  73. package/components/display/graph/visualizations/icons/BaseIcon.d.ts +12 -0
  74. package/components/display/graph/visualizations/icons/BaseIcon.js +37 -0
  75. package/components/display/graph/visualizations/icons/BugIcon.d.ts +5 -0
  76. package/components/display/graph/visualizations/icons/BugIcon.js +18 -0
  77. package/components/display/graph/visualizations/icons/HostIcon.d.ts +5 -0
  78. package/components/display/graph/visualizations/icons/HostIcon.js +24 -0
  79. package/components/display/graph/visualizations/icons/NetworkIcon.d.ts +5 -0
  80. package/components/display/graph/visualizations/icons/NetworkIcon.js +24 -0
  81. package/components/display/graph/visualizations/icons/ProcessIcon.d.ts +5 -0
  82. package/components/display/graph/visualizations/icons/ProcessIcon.js +18 -0
  83. package/components/display/graph/visualizations/icons/TargetIcon.d.ts +5 -0
  84. package/components/display/graph/visualizations/icons/TargetIcon.js +19 -0
  85. package/components/display/graph/visualizations/icons/index.d.ts +2 -0
  86. package/components/display/graph/visualizations/icons/index.js +16 -0
  87. package/components/display/graph/visualizations/panels/NodePanel.d.ts +8 -0
  88. package/components/display/graph/visualizations/panels/NodePanel.js +12 -0
  89. package/components/display/graph/visualizations/tree/BundleLine.d.ts +29 -0
  90. package/components/display/graph/visualizations/tree/BundleLine.js +121 -0
  91. package/components/display/graph/visualizations/tree/Triangle.d.ts +9 -0
  92. package/components/display/graph/visualizations/tree/Triangle.js +26 -0
  93. package/components/display/graph/visualizations/tree/index.d.ts +36 -0
  94. package/components/display/graph/visualizations/tree/index.js +485 -0
  95. package/components/display/graph/visualizations/tree/types.d.ts +11 -0
  96. package/components/display/graph/visualizations/tree/types.js +1 -0
  97. package/components/display/icons/Iconified.d.ts +9 -0
  98. package/components/display/icons/Iconified.js +29 -0
  99. package/components/display/json/index.d.ts +14 -0
  100. package/components/display/json/index.js +12 -0
  101. package/components/display/markdown/DynamicTabs.d.ts +8 -0
  102. package/components/display/markdown/DynamicTabs.js +26 -0
  103. package/components/display/markdown/index.d.ts +9 -0
  104. package/components/display/markdown/index.js +13389 -0
  105. package/components/display/markdown/markdownPlugins/tabs.d.ts +3 -0
  106. package/components/display/markdown/markdownPlugins/tabs.js +4 -0
  107. package/components/enrichment/EnrichPopover.d.ts +10 -0
  108. package/components/enrichment/EnrichPopover.js +88 -0
  109. package/components/fetchers/Fetcher.d.ts +17 -0
  110. package/components/fetchers/Fetcher.js +188 -0
  111. package/components/fetchers/PreviewModal.d.ts +8 -0
  112. package/components/fetchers/PreviewModal.js +22 -0
  113. package/components/fetchers/StatusChip.d.ts +8 -0
  114. package/components/fetchers/StatusChip.js +30 -0
  115. package/components/group/Entry.d.ts +8 -0
  116. package/components/group/Entry.js +15 -0
  117. package/components/group/Group.d.ts +12 -0
  118. package/components/group/Group.js +15 -0
  119. package/components/group/GroupControl.d.ts +4 -0
  120. package/components/group/GroupControl.js +103 -0
  121. package/components/stats/QueryStatus.d.ts +4 -0
  122. package/components/stats/QueryStatus.js +61 -0
  123. package/countBy-C69WslUA.js +14 -0
  124. package/data/event.d.ts +12 -0
  125. package/data/event.js +8 -0
  126. package/database/index.d.ts +4 -0
  127. package/database/index.js +4 -0
  128. package/database/selector.schema.json.d.ts +119 -0
  129. package/database/status.schema.json.d.ts +38 -0
  130. package/database/types.d.ts +64 -0
  131. package/debounce-bV0h5FC5.js +92 -0
  132. package/en/translation.json +135 -0
  133. package/fr/translation.json +134 -0
  134. package/get-D3C3lEU3.js +8 -0
  135. package/groupBy-DC2oOuBN.js +14 -0
  136. package/hooks/ClueActionContext.d.ts +86 -0
  137. package/hooks/ClueActionContext.js +18 -0
  138. package/hooks/ClueComponentContext.d.ts +10 -0
  139. package/hooks/ClueComponentContext.js +40 -0
  140. package/hooks/ClueConfigProvider.d.ts +12 -0
  141. package/hooks/ClueConfigProvider.js +23 -0
  142. package/hooks/ClueDatabaseContext.d.ts +10 -0
  143. package/hooks/ClueDatabaseContext.js +23 -0
  144. package/hooks/ClueEnrichContext.d.ts +6 -0
  145. package/hooks/ClueEnrichContext.js +15 -0
  146. package/hooks/ClueEnrichContextType.d.ts +113 -0
  147. package/hooks/ClueEnrichProps.d.ts +81 -0
  148. package/hooks/ClueFetcherContext.d.ts +35 -0
  149. package/hooks/ClueFetcherContext.js +88 -0
  150. package/hooks/ClueGroupContext.d.ts +14 -0
  151. package/hooks/ClueGroupContext.js +23 -0
  152. package/hooks/CluePopupContext.d.ts +24 -0
  153. package/hooks/CluePopupContext.js +12 -0
  154. package/hooks/ClueProvider.d.ts +9 -0
  155. package/hooks/ClueProvider.js +14 -0
  156. package/hooks/selectors.d.ts +10 -0
  157. package/hooks/selectors.js +24 -0
  158. package/hooks/useAnnotations.d.ts +24 -0
  159. package/hooks/useAnnotations.js +69 -0
  160. package/hooks/useClue.d.ts +4 -0
  161. package/hooks/useClue.js +8 -0
  162. package/hooks/useClueActions.d.ts +4 -0
  163. package/hooks/useClueActions.js +5 -0
  164. package/hooks/useClueConfig.d.ts +1 -0
  165. package/hooks/useClueConfig.js +8 -0
  166. package/hooks/useClueTypeConfig.d.ts +17 -0
  167. package/hooks/useClueTypeConfig.js +7 -0
  168. package/hooks/useComparator.d.ts +16 -0
  169. package/hooks/useComparator.js +1060 -0
  170. package/hooks/useErrors.d.ts +17 -0
  171. package/hooks/useErrors.js +35 -0
  172. package/hooks/useMyHighlights.d.ts +11 -0
  173. package/hooks/useMyHighlights.js +74 -0
  174. package/hooks/useMyLocalStorage.d.ts +16 -0
  175. package/hooks/useMyLocalStorage.js +80 -0
  176. package/iconify-CXMreGTg.js +1782 -0
  177. package/icons/Action.d.ts +9 -0
  178. package/icons/Action.js +90 -0
  179. package/icons/Assessment.d.ts +11 -0
  180. package/icons/Assessment.js +123 -0
  181. package/icons/Context.d.ts +12 -0
  182. package/icons/Context.js +83 -0
  183. package/icons/Opinion.d.ts +11 -0
  184. package/icons/Opinion.js +125 -0
  185. package/icons/iconMap.d.ts +7 -0
  186. package/icons/iconMap.js +10 -0
  187. package/identity-CPGTqrE4.js +6 -0
  188. package/index-BDVjGvMI.js +696 -0
  189. package/index-BDrtH5ec.js +465 -0
  190. package/index-BbPn6-Mw.js +15750 -0
  191. package/index-C9lySIVX.js +1172 -0
  192. package/index-Dn2NHyXg.js +17654 -0
  193. package/index.css +21 -0
  194. package/isEmpty-BQkZubqU.js +29 -0
  195. package/isNil-CIubwp4T.js +6 -0
  196. package/isObject-FTY-5JQX.js +7 -0
  197. package/isObjectLike-OAgjjZye.js +48 -0
  198. package/isSymbol-Xd2FsJyp.js +8 -0
  199. package/isUndefined-CE8h73dH.js +10 -0
  200. package/last-CUCl67Im.js +7 -0
  201. package/main.d.ts +42 -0
  202. package/main.js +70 -0
  203. package/package.json +39 -143
  204. package/public/manifest.json +16 -0
  205. package/public/robots.txt +3 -0
  206. package/public/svg/dark/clue-h.svg +52 -0
  207. package/public/svg/dark/clue-icon1-simple.svg +33 -0
  208. package/public/svg/dark/clue-icon1.svg +44 -0
  209. package/public/svg/dark/clue-icon2-simple.svg +26 -0
  210. package/public/svg/dark/clue-icon2.svg +37 -0
  211. package/public/svg/dark/clue-name.svg +14 -0
  212. package/public/svg/dark/clue-v.svg +52 -0
  213. package/public/svg/light/clue-h.svg +60 -0
  214. package/public/svg/light/clue-icon1-simple.svg +37 -0
  215. package/public/svg/light/clue-icon1.svg +48 -0
  216. package/public/svg/light/clue-icon2-simple.svg +30 -0
  217. package/public/svg/light/clue-icon2.svg +41 -0
  218. package/public/svg/light/clue-name.svg +14 -0
  219. package/public/svg/light/clue-v.svg +60 -0
  220. package/sortBy-B-UKp4GT.js +100 -0
  221. package/sumBy-MYkDPHZL.js +8 -0
  222. package/tabs-xGuUGsJd.js +254 -0
  223. package/text/Frequency.d.ts +9 -0
  224. package/text/Frequency.js +49 -0
  225. package/toFinite-Bc55msYj.js +16 -0
  226. package/toNumber-DPxy1FBy.js +39 -0
  227. package/types/EnrichmentProps.d.ts +73 -0
  228. package/types/RunningActionData.d.ts +15 -0
  229. package/types/WithActionData.d.ts +9 -0
  230. package/types/action.d.ts +25 -0
  231. package/types/config.d.ts +16 -0
  232. package/types/fetcher.d.ts +60 -0
  233. package/types/graph.d.ts +101 -0
  234. package/types/lookup.d.ts +62 -0
  235. package/types/network.d.ts +9 -0
  236. package/useClueTypeConfig-D4zcy8Gr.js +3184 -0
  237. package/utils/chain.d.ts +14 -0
  238. package/utils/chain.js +106 -0
  239. package/utils/classificationParser.d.ts +195 -0
  240. package/utils/classificationParser.js +553 -0
  241. package/utils/constants.d.ts +27 -0
  242. package/utils/constants.js +37 -0
  243. package/utils/graph.d.ts +13 -0
  244. package/utils/graph.js +79 -0
  245. package/utils/hashUtil.d.ts +6 -0
  246. package/utils/hashUtil.js +11 -0
  247. package/utils/line.d.ts +28 -0
  248. package/utils/line.js +136 -0
  249. package/utils/loggerUtil.d.ts +6 -0
  250. package/utils/loggerUtil.js +8 -0
  251. package/utils/sessionStorage.d.ts +9 -0
  252. package/utils/sessionStorage.js +51 -0
  253. package/utils/utils.d.ts +13 -0
  254. package/utils/utils.js +11 -0
  255. package/utils/window.d.ts +3 -0
  256. package/utils/window.js +24 -0
  257. package/utils-CxIhC2xH.js +4182 -0
@@ -0,0 +1,518 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { a as addAPIProvider } from "./iconify-CXMreGTg.js";
3
+ import { u as useClueTypeConfig, a as api, p as post } from "./useClueTypeConfig-D4zcy8Gr.js";
4
+ import { clueDebugLogger } from "./utils/loggerUtil.js";
5
+ import { useContext, useMemo, useState, useRef, useEffect, useCallback } from "react";
6
+ import { c as createContext } from "./index-BDVjGvMI.js";
7
+ import { ClueDatabaseContext } from "./hooks/ClueDatabaseContext.js";
8
+ import useClueConfig from "./hooks/useClueConfig.js";
9
+ import { g as groupBy } from "./groupBy-DC2oOuBN.js";
10
+ import { b as baseUniq } from "./_baseUniq-CpupKWcL.js";
11
+ import { d as debounce } from "./debounce-bV0h5FC5.js";
12
+ import { b as baseSlice } from "./_baseSlice-GAv_YFTT.js";
13
+ import { t as toFinite } from "./toFinite-Bc55msYj.js";
14
+ function toInteger(value) {
15
+ var result = toFinite(value), remainder = result % 1;
16
+ return result === result ? remainder ? result - remainder : result : 0;
17
+ }
18
+ var nativeCeil = Math.ceil, nativeMax = Math.max;
19
+ function chunk(array, size, guard) {
20
+ if (size === void 0) {
21
+ size = 1;
22
+ } else {
23
+ size = nativeMax(toInteger(size), 0);
24
+ }
25
+ var length = array == null ? 0 : array.length;
26
+ if (!length || size < 1) {
27
+ return [];
28
+ }
29
+ var index = 0, resIndex = 0, result = Array(nativeCeil(length / size));
30
+ while (index < length) {
31
+ result[resIndex++] = baseSlice(array, index, index += size);
32
+ }
33
+ return result;
34
+ }
35
+ function uniq(array) {
36
+ return array && array.length ? baseUniq(array) : [];
37
+ }
38
+ let getRandomValues;
39
+ const rnds8 = new Uint8Array(16);
40
+ function rng() {
41
+ if (!getRandomValues) {
42
+ getRandomValues = typeof crypto !== "undefined" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
43
+ if (!getRandomValues) {
44
+ throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
45
+ }
46
+ }
47
+ return getRandomValues(rnds8);
48
+ }
49
+ const byteToHex = [];
50
+ for (let i = 0; i < 256; ++i) {
51
+ byteToHex.push((i + 256).toString(16).slice(1));
52
+ }
53
+ function unsafeStringify(arr, offset = 0) {
54
+ return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];
55
+ }
56
+ const randomUUID = typeof crypto !== "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
57
+ const native = {
58
+ randomUUID
59
+ };
60
+ function v4(options, buf, offset) {
61
+ if (native.randomUUID && true && !options) {
62
+ return native.randomUUID();
63
+ }
64
+ options = options || {};
65
+ const rnds = options.random || (options.rng || rng)();
66
+ rnds[6] = rnds[6] & 15 | 64;
67
+ rnds[8] = rnds[8] & 63 | 128;
68
+ return unsafeStringify(rnds);
69
+ }
70
+ const ClueEnrichContext = createContext(null);
71
+ const ClueEnrichProvider = ({
72
+ children,
73
+ classification: _defaultClassification,
74
+ baseURL,
75
+ getToken,
76
+ onNetworkCall,
77
+ pickSources,
78
+ chunkSize = 15,
79
+ maxRequestCount = 4,
80
+ defaultTimeout = 5,
81
+ enabled = true,
82
+ ready = false,
83
+ publicIconify = true,
84
+ skipConfigCall = false,
85
+ customIconify: _customIconify,
86
+ debugLogging = true
87
+ }) => {
88
+ var _a;
89
+ const clueConfig = useClueConfig();
90
+ const database = useContext(ClueDatabaseContext);
91
+ const defaultClassification = useMemo(() => {
92
+ var _a2, _b;
93
+ return (_b = (_a2 = clueConfig.config) == null ? void 0 : _a2.c12nDef) == null ? void 0 : _b.UNRESTRICTED;
94
+ }, [clueConfig.config]);
95
+ const [isReady, setIsReady] = useState(ready);
96
+ const runningRequestCount = useRef(0);
97
+ const [sources, setSources] = useState([]);
98
+ const { availableSources, typesDetection } = useClueTypeConfig(
99
+ enabled && isReady,
100
+ baseURL,
101
+ debugLogging,
102
+ getToken,
103
+ onNetworkCall
104
+ );
105
+ useEffect(() => {
106
+ if (skipConfigCall || !enabled || !isReady) {
107
+ return;
108
+ }
109
+ const headers = {};
110
+ const token = getToken == null ? void 0 : getToken();
111
+ if (token) {
112
+ headers.Authorization = `Bearer ${token}`;
113
+ }
114
+ let requestConfig = { baseURL, headers };
115
+ if (onNetworkCall) {
116
+ requestConfig = onNetworkCall(requestConfig);
117
+ }
118
+ api.configs.get(requestConfig).then(clueConfig.setConfig);
119
+ }, [baseURL, onNetworkCall, skipConfigCall, isReady]);
120
+ const [customIconify, setCustomIconify] = useState(_customIconify);
121
+ useEffect(() => {
122
+ if (_customIconify) {
123
+ setCustomIconify(_customIconify);
124
+ }
125
+ }, [_customIconify]);
126
+ useEffect(() => {
127
+ if (publicIconify) {
128
+ return;
129
+ }
130
+ let iconURL = customIconify ?? void 0 ?? (baseURL == null ? void 0 : baseURL.replace(/^[^.]+/, "icons"));
131
+ if (!iconURL && typeof window !== "undefined" && !!window && !window.location.origin.includes("localhost")) {
132
+ iconURL = window.location.protocol + "//" + window.location.origin.replace(/^[^.]+/, "icons");
133
+ }
134
+ if (iconURL) {
135
+ clueDebugLogger(`Using ${iconURL} for iconify`, debugLogging);
136
+ addAPIProvider("", {
137
+ resources: [iconURL]
138
+ });
139
+ }
140
+ }, [baseURL, customIconify, debugLogging, publicIconify]);
141
+ const _addEntries = useCallback(
142
+ async (entries) => {
143
+ const newRecords = [];
144
+ for (const entry of entries) {
145
+ const { latency, source, type, value: value2, items, error } = entry;
146
+ if (error) {
147
+ newRecords.push({
148
+ id: v4(),
149
+ source,
150
+ type,
151
+ value: value2,
152
+ annotations: [],
153
+ classification: defaultClassification,
154
+ latency,
155
+ count: 0,
156
+ error
157
+ });
158
+ }
159
+ for (const item of items) {
160
+ const { classification, count, link, annotations } = item;
161
+ await database.selectors.find({ selector: { type, value: value2, source, classification } }).incrementalRemove();
162
+ const record = {
163
+ id: v4(),
164
+ source,
165
+ type,
166
+ value: value2,
167
+ annotations,
168
+ classification,
169
+ latency,
170
+ count,
171
+ link,
172
+ error
173
+ };
174
+ if (newRecords.some((_entry) => _entry.id === record.id)) {
175
+ record.id = v4();
176
+ }
177
+ newRecords.push(record);
178
+ }
179
+ }
180
+ const result = await database.selectors.bulkInsert(newRecords);
181
+ if (result.error.length > 0) {
182
+ console.warn("Errors on upsert:");
183
+ result.error.forEach((err) => console.warn(err.documentId, err.validationErrors ?? err.status));
184
+ }
185
+ },
186
+ [database, defaultClassification]
187
+ );
188
+ const enrich = useCallback(
189
+ async (type, value2, _options = {}) => {
190
+ var _a2, _b;
191
+ if (!type || !value2) {
192
+ console.error(`Type (${type}) or value (${value2}) is empty, returning empty response`);
193
+ return {};
194
+ }
195
+ const _sources = (pickSources == null ? void 0 : pickSources(sources, availableSources, [{ type, value: value2, classification: _options.classification }])) ?? sources;
196
+ const options = {
197
+ timeout: defaultTimeout,
198
+ force: false,
199
+ includeRaw: false,
200
+ noCache: false,
201
+ classification: defaultClassification,
202
+ sources: _sources,
203
+ ..._options
204
+ };
205
+ const headers = {};
206
+ const token = getToken == null ? void 0 : getToken();
207
+ if (token) {
208
+ headers.Authorization = `Bearer ${token}`;
209
+ }
210
+ let requestConfig = { baseURL, headers };
211
+ if (onNetworkCall) {
212
+ requestConfig = onNetworkCall(requestConfig);
213
+ }
214
+ const selector = {
215
+ type,
216
+ value: value2,
217
+ classification: options.classification
218
+ };
219
+ let statusRecord = await ((_a2 = database.status) == null ? void 0 : _a2.findOne({ selector: { ...selector } }).exec());
220
+ if (!statusRecord) {
221
+ statusRecord = await ((_b = database.status) == null ? void 0 : _b.insert({
222
+ id: v4(),
223
+ type: selector.type,
224
+ value: selector.value,
225
+ classification: selector.classification ?? defaultClassification,
226
+ status: "in-progress"
227
+ }));
228
+ } else {
229
+ await statusRecord.incrementalPatch({ status: "in-progress" });
230
+ }
231
+ try {
232
+ const enrichmentResult = await post([selector], options.sources, options, requestConfig);
233
+ const enrichData = Object.values(Object.values(enrichmentResult)[0])[0];
234
+ await (statusRecord == null ? void 0 : statusRecord.incrementalPatch({ status: "complete" }));
235
+ await _addEntries(Object.values(enrichData));
236
+ return enrichData;
237
+ } catch (e) {
238
+ console.error(e);
239
+ return {};
240
+ }
241
+ },
242
+ [
243
+ _addEntries,
244
+ availableSources,
245
+ baseURL,
246
+ database,
247
+ defaultClassification,
248
+ defaultTimeout,
249
+ getToken,
250
+ onNetworkCall,
251
+ pickSources,
252
+ sources
253
+ ]
254
+ );
255
+ const bulkEnrich = useCallback(
256
+ async (bulkRequest, _options) => {
257
+ const _sources = (pickSources == null ? void 0 : pickSources(sources, availableSources, bulkRequest)) ?? sources;
258
+ const options = {
259
+ timeout: defaultTimeout,
260
+ includeRaw: false,
261
+ noCache: false,
262
+ classification: defaultClassification,
263
+ sources: _sources,
264
+ ..._options
265
+ };
266
+ const headers = {};
267
+ const token = getToken == null ? void 0 : getToken();
268
+ if (token) {
269
+ headers.Authorization = `Bearer ${token}`;
270
+ }
271
+ let requestConfig = { baseURL, headers };
272
+ if (onNetworkCall) {
273
+ requestConfig = onNetworkCall(requestConfig);
274
+ }
275
+ const statuses = [];
276
+ for (const selector of bulkRequest) {
277
+ const query = { type: selector.type, value: selector.value, classification: options.classification };
278
+ let statusRecord = await database.status.findOne({
279
+ selector: query
280
+ }).incrementalPatch({
281
+ status: "in-progress"
282
+ });
283
+ if (!statusRecord) {
284
+ statusRecord = await database.status.insert({
285
+ id: v4(),
286
+ ...query,
287
+ status: "in-progress",
288
+ sources: options.sources
289
+ });
290
+ }
291
+ statuses.push(statusRecord.toMutableJSON());
292
+ }
293
+ try {
294
+ const result = await post(bulkRequest, options.sources, options, requestConfig);
295
+ const entries = Object.values(result).flatMap(Object.values).flatMap(Object.values);
296
+ await _addEntries(entries);
297
+ return result;
298
+ } catch (e) {
299
+ console.error(e);
300
+ return {};
301
+ } finally {
302
+ const records = await Promise.all(statuses);
303
+ database.status.bulkUpsert(
304
+ records.map((record) => {
305
+ record.status = "complete";
306
+ return record;
307
+ })
308
+ );
309
+ }
310
+ },
311
+ [
312
+ pickSources,
313
+ sources,
314
+ availableSources,
315
+ defaultTimeout,
316
+ defaultClassification,
317
+ getToken,
318
+ baseURL,
319
+ onNetworkCall,
320
+ database,
321
+ _addEntries
322
+ ]
323
+ );
324
+ const enrichFailedEnrichments = useCallback(async () => {
325
+ const failedEnrichments = await database.selectors.find({ selector: { error: { $exists: true } } }).exec();
326
+ const byClassification = groupBy(failedEnrichments, "classification");
327
+ const newRequests = [];
328
+ for (const [classification, selectors] of Object.entries(byClassification)) {
329
+ const bySelector = groupBy(selectors, (_selector) => `${_selector.type}:${_selector.value}`);
330
+ Object.values(bySelector).forEach((records) => {
331
+ newRequests.push({
332
+ id: v4(),
333
+ type: records[0].type,
334
+ value: records[0].value,
335
+ classification,
336
+ sources: uniq(records.map((_record) => _record.source)).sort(),
337
+ status: "pending"
338
+ });
339
+ });
340
+ }
341
+ await database.status.bulkInsert(newRequests);
342
+ await database.selectors.bulkRemove(failedEnrichments);
343
+ }, [database]);
344
+ const enrichQueued = useMemo(
345
+ () => debounce(
346
+ async () => {
347
+ if (!(database == null ? void 0 : database.status)) {
348
+ return;
349
+ } else if (database.status.closed) {
350
+ console.warn("Status database is closed, will not enrich");
351
+ return;
352
+ }
353
+ const selectors = await database.status.find({ selector: { status: "pending" } }).update({ $set: { status: "in-progress" } });
354
+ if (selectors.length < 1) {
355
+ return;
356
+ }
357
+ const chunks = chunk(selectors, chunkSize);
358
+ clueDebugLogger(
359
+ `Enriching ${selectors.length} selectors in ${chunks.length} chunks of ${chunkSize}.`,
360
+ debugLogging
361
+ );
362
+ await Promise.all(
363
+ // For performance reasons, we chunk the requests. This will allow us to take advantage of parellelization in the
364
+ // backend, both on the pod level and kubernetes level
365
+ chunks.map(async (reqsChunk) => {
366
+ let _interval = null;
367
+ if (runningRequestCount.current <= maxRequestCount) {
368
+ runningRequestCount.current += 1;
369
+ } else {
370
+ let startOfWait = Date.now();
371
+ await new Promise((res) => {
372
+ _interval = setInterval(() => {
373
+ clueDebugLogger(
374
+ `Waiting on ${runningRequestCount.current} existing requests to complete (total delay: ${Date.now() - startOfWait}ms)`,
375
+ debugLogging
376
+ );
377
+ if (runningRequestCount.current < maxRequestCount) {
378
+ res();
379
+ }
380
+ }, 400);
381
+ }).finally(() => {
382
+ runningRequestCount.current += 1;
383
+ clearInterval(_interval);
384
+ });
385
+ }
386
+ try {
387
+ const options = {};
388
+ const _sources = uniq(reqsChunk.flatMap((record) => record.sources ?? []));
389
+ if (_sources.length > 0) {
390
+ options.sources = _sources;
391
+ }
392
+ await bulkEnrich(
393
+ reqsChunk.map((record) => record.toSelector()),
394
+ options
395
+ );
396
+ await database.status.findByIds(reqsChunk.map((selector) => selector.id)).update({ $set: { status: "complete" } });
397
+ } catch (e) {
398
+ console.error(e);
399
+ } finally {
400
+ runningRequestCount.current -= 1;
401
+ if (_interval) {
402
+ clearInterval(_interval);
403
+ }
404
+ }
405
+ })
406
+ );
407
+ },
408
+ 200,
409
+ { maxWait: 500, leading: false }
410
+ ),
411
+ [bulkEnrich, chunkSize, database, debugLogging, maxRequestCount]
412
+ );
413
+ useEffect(() => {
414
+ {
415
+ return;
416
+ }
417
+ }, [database, debugLogging]);
418
+ useEffect(() => {
419
+ if (!enabled || !isReady || !(database == null ? void 0 : database.status)) {
420
+ return;
421
+ }
422
+ const observer = database.status.find({
423
+ selector: {
424
+ status: "pending"
425
+ }
426
+ }).$.subscribe(() => enrichQueued());
427
+ return () => {
428
+ try {
429
+ observer == null ? void 0 : observer.unsubscribe();
430
+ } catch (e) {
431
+ console.warn(e);
432
+ }
433
+ };
434
+ }, [enabled, isReady, database, debugLogging, enrichQueued]);
435
+ const queueEnrich = useCallback(
436
+ async (type, value2, classification) => {
437
+ if (!type) {
438
+ throw new Error("Type cannot be null");
439
+ }
440
+ if (!value2) {
441
+ throw new Error("Value cannot be null");
442
+ }
443
+ const query = { type, value: value2, classification: classification ?? defaultClassification };
444
+ let statusRecord = await database.status.findOne({
445
+ selector: query
446
+ }).exec();
447
+ if (!statusRecord) {
448
+ statusRecord = await database.status.queueInsert({
449
+ id: v4(),
450
+ ...query,
451
+ status: "pending"
452
+ });
453
+ }
454
+ return statusRecord;
455
+ },
456
+ [defaultClassification, database]
457
+ );
458
+ const guessType = useCallback(
459
+ (value2) => {
460
+ var _a2, _b;
461
+ if (!value2) {
462
+ return null;
463
+ }
464
+ const types = Object.entries(typesDetection);
465
+ const regularCheck = (_a2 = types.find(([_type, _regexp]) => _regexp.exec(value2))) == null ? void 0 : _a2[0];
466
+ if (regularCheck) {
467
+ return regularCheck;
468
+ }
469
+ const lowercased = value2.toLowerCase();
470
+ const lowercaseCheck = (_b = types.find(([_type, _regexp]) => _regexp.exec(lowercased))) == null ? void 0 : _b[0];
471
+ if (lowercaseCheck) {
472
+ return lowercaseCheck;
473
+ }
474
+ return null;
475
+ },
476
+ [typesDetection]
477
+ );
478
+ const value = useMemo(
479
+ () => {
480
+ var _a2;
481
+ return {
482
+ bulkEnrich,
483
+ enrich,
484
+ enrichFailedEnrichments,
485
+ sources,
486
+ setSources,
487
+ typesDetection,
488
+ availableSources,
489
+ guessType,
490
+ queueEnrich,
491
+ setCustomIconify,
492
+ setReady: setIsReady,
493
+ defaultClassification,
494
+ ready: isReady && !!database && !!((_a2 = clueConfig.config) == null ? void 0 : _a2.c12nDef)
495
+ };
496
+ },
497
+ [
498
+ bulkEnrich,
499
+ enrich,
500
+ enrichFailedEnrichments,
501
+ sources,
502
+ typesDetection,
503
+ availableSources,
504
+ guessType,
505
+ queueEnrich,
506
+ defaultClassification,
507
+ isReady,
508
+ database,
509
+ (_a = clueConfig.config) == null ? void 0 : _a.c12nDef
510
+ ]
511
+ );
512
+ return /* @__PURE__ */ jsx(ClueEnrichContext.Provider, { value, children });
513
+ };
514
+ export {
515
+ ClueEnrichContext as C,
516
+ ClueEnrichProvider as a,
517
+ uniq as u
518
+ };
@@ -0,0 +1,9 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { memo } from "react";
3
+ const FlexOne = ({ children = null }) => {
4
+ return /* @__PURE__ */ jsx("div", { style: { flex: 1 }, children });
5
+ };
6
+ const FlexOne$1 = memo(FlexOne);
7
+ export {
8
+ FlexOne$1 as F
9
+ };
@@ -0,0 +1,64 @@
1
+ import { b as baseGetTag, r as root } from "./isObjectLike-OAgjjZye.js";
2
+ import { i as isObject } from "./isObject-FTY-5JQX.js";
3
+ var isArray = Array.isArray;
4
+ var asyncTag = "[object AsyncFunction]", funcTag = "[object Function]", genTag = "[object GeneratorFunction]", proxyTag = "[object Proxy]";
5
+ function isFunction(value) {
6
+ if (!isObject(value)) {
7
+ return false;
8
+ }
9
+ var tag = baseGetTag(value);
10
+ return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
11
+ }
12
+ var coreJsData = root["__core-js_shared__"];
13
+ var maskSrcKey = function() {
14
+ var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || "");
15
+ return uid ? "Symbol(src)_1." + uid : "";
16
+ }();
17
+ function isMasked(func) {
18
+ return !!maskSrcKey && maskSrcKey in func;
19
+ }
20
+ var funcProto$1 = Function.prototype;
21
+ var funcToString$1 = funcProto$1.toString;
22
+ function toSource(func) {
23
+ if (func != null) {
24
+ try {
25
+ return funcToString$1.call(func);
26
+ } catch (e) {
27
+ }
28
+ try {
29
+ return func + "";
30
+ } catch (e) {
31
+ }
32
+ }
33
+ return "";
34
+ }
35
+ var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
36
+ var reIsHostCtor = /^\[object .+?Constructor\]$/;
37
+ var funcProto = Function.prototype, objectProto = Object.prototype;
38
+ var funcToString = funcProto.toString;
39
+ var hasOwnProperty = objectProto.hasOwnProperty;
40
+ var reIsNative = RegExp(
41
+ "^" + funcToString.call(hasOwnProperty).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
42
+ );
43
+ function baseIsNative(value) {
44
+ if (!isObject(value) || isMasked(value)) {
45
+ return false;
46
+ }
47
+ var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
48
+ return pattern.test(toSource(value));
49
+ }
50
+ function getValue(object, key) {
51
+ return object == null ? void 0 : object[key];
52
+ }
53
+ function getNative(object, key) {
54
+ var value = getValue(object, key);
55
+ return baseIsNative(value) ? value : void 0;
56
+ }
57
+ var Map = getNative(root, "Map");
58
+ export {
59
+ Map as M,
60
+ isFunction as a,
61
+ getNative as g,
62
+ isArray as i,
63
+ toSource as t
64
+ };