@cccsaurora/clue-ui 1.3.0 → 1.4.0-dev.424
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.
- package/ActionForm-CqKcnDWC.js +6099 -0
- package/AnnotationDetails-BlPd3T8k.js +176 -0
- package/AnnotationPreview-Bl447SKT.js +188 -0
- package/ClueEnrichContext-B3YrTCaJ.js +567 -0
- package/FlexOne-BSYAhhtG.js +9 -0
- package/_MapCache-kuEY_iOH.js +220 -0
- package/_Set-BrSMTlHn.js +6 -0
- package/_Uint8Array-OPpgYQj7.js +123 -0
- package/_arrayIncludes-BNqL-9ZP.js +31 -0
- package/_arrayPush-CBkQqaE_.js +10 -0
- package/_baseAssignValue-CNUVPOBW.js +16 -0
- package/_baseClone-9FaRd1R2.js +287 -0
- package/_baseExtremum-wOGT4Dgw.js +18 -0
- package/_baseFlatten-Co6QHDlG.js +92 -0
- package/_baseGet-Cmp6FztG.js +109 -0
- package/_baseGetTag-Hj-0NTYF.js +44 -0
- package/_baseIsEqual-1CpU47TZ.js +211 -0
- package/_baseIteratee-BN7Vbe5g.js +126 -0
- package/_baseRest-BZ_hQ9PC.js +8 -0
- package/_baseSlice-GAv_YFTT.js +20 -0
- package/_baseSum-D0WC1dN0.js +13 -0
- package/_baseUniq-BnvS3JHL.js +63 -0
- package/_cacheHas-_aF2y2Xv.js +25 -0
- package/_commonjsHelpers-CUmg6egw.js +6 -0
- package/_createAggregator-BUZrP_is.js +63 -0
- package/_defineProperty-DolZLKmv.js +12 -0
- package/_getPrototype-Bb4gm-5m.js +5 -0
- package/_getTag-CML_cXiN.js +105 -0
- package/_isIterateeCall-B1IFEqVv.js +17 -0
- package/_setToArray-CqyqC8ib.js +10 -0
- package/cloneDeep-l3UkXG5M.js +8 -0
- package/components/AnnotationBody.js +49 -35
- package/components/AnnotationDetailPopover.js +36 -30
- package/components/AnnotationDetails.js +7 -7
- package/components/AnnotationEntry.js +35 -35
- package/components/AnnotationPreview.js +5 -5
- package/components/ClassificationChip.js +44 -23
- package/components/CountBadge.js +31 -26
- package/components/EnrichedCard.js +110 -97
- package/components/EnrichedChip.js +130 -105
- package/components/EnrichedTypography.js +133 -107
- package/components/ErrorBoundary.js +28 -24
- package/components/RetryFailedEnrichments.js +10 -9
- package/components/SourcePicker.js +57 -49
- package/components/actions/ActionForm.js +4 -4
- package/components/actions/ExecutePopover.js +75 -59
- package/components/actions/ResultModal.js +4 -4
- package/components/actions/form/schemaAdapter.js +39 -23
- package/components/actions/formats/FileResult.js +86 -59
- package/components/actions/formats/index.js +29 -25
- package/components/display/graph/ExpandMoreButton.js +10 -10
- package/components/display/graph/elements/NodeCard.js +111 -91
- package/components/display/graph/elements/NodeTag.js +15 -13
- package/components/display/graph/index.js +261 -202
- package/components/display/graph/visualizations/Leaf.js +89 -70
- package/components/display/graph/visualizations/cloud/index.js +98 -81
- package/components/display/graph/visualizations/icons/BaseIcon.js +26 -21
- package/components/display/graph/visualizations/icons/BugIcon.js +12 -12
- package/components/display/graph/visualizations/icons/HostIcon.js +12 -12
- package/components/display/graph/visualizations/icons/NetworkIcon.js +12 -12
- package/components/display/graph/visualizations/icons/ProcessIcon.js +12 -12
- package/components/display/graph/visualizations/icons/TargetIcon.js +13 -13
- package/components/display/graph/visualizations/icons/index.js +14 -13
- package/components/display/graph/visualizations/panels/NodePanel.js +10 -8
- package/components/display/graph/visualizations/tree/BundleLine.js +108 -81
- package/components/display/graph/visualizations/tree/Triangle.js +13 -13
- package/components/display/graph/visualizations/tree/index.js +408 -306
- package/components/display/icons/Iconified.js +27 -12
- package/components/display/json/index.js +4 -4
- package/components/display/markdown/index.js +8678 -5770
- package/components/enrichment/EnrichPopover.js +54 -46
- package/components/fetchers/Fetcher.js +166 -123
- package/components/fetchers/FetcherResultView.js +31 -27
- package/components/fetchers/PreviewModal.js +17 -16
- package/components/fetchers/StatusChip.js +21 -17
- package/components/group/Entry.js +13 -11
- package/components/group/Group.js +13 -10
- package/components/group/GroupControl.js +76 -65
- package/components/stats/QueryStatus.js +45 -32
- package/countBy-Bqcp3VCs.js +14 -0
- package/data/event.js +6 -4
- package/database/globals.js +2 -2
- package/database/index.js +3 -3
- package/database/replication.js +4 -4
- package/get-CdMThM8x.js +8 -0
- package/groupBy-BVV07EGQ.js +14 -0
- package/hooks/ClueActionContext.js +6 -6
- package/hooks/ClueComponentContext.js +29 -23
- package/hooks/ClueConfigProvider.js +14 -12
- package/hooks/ClueDatabaseContext.js +35 -23
- package/hooks/ClueEnrichContext.js +11 -11
- package/hooks/ClueFetcherContext.js +83 -56
- package/hooks/ClueGroupContext.js +17 -14
- package/hooks/CluePopupContext.js +5 -5
- package/hooks/ClueProvider.js +13 -11
- package/hooks/ClueUIPluginContext.js +49 -35
- package/hooks/selectors.js +7 -7
- package/hooks/useActionResult.js +3 -3
- package/hooks/useAnnotations.js +48 -32
- package/hooks/useClue.js +6 -4
- package/hooks/useClueActions.js +3 -3
- package/hooks/useClueConfig.js +6 -4
- package/hooks/useClueTypeConfig.js +49 -24
- package/hooks/useClueUIPlugins.js +8 -7
- package/hooks/useComparator.js +722 -435
- package/hooks/useErrors.js +22 -18
- package/hooks/useFetcherResult.js +33 -24
- package/hooks/useMyHighlights.js +66 -36
- package/hooks/useMyLocalStorage.js +66 -37
- package/iconify-DJxl6dC-.js +1789 -0
- package/icons/Action.js +66 -49
- package/icons/Assessment.js +85 -69
- package/icons/Context.js +77 -63
- package/icons/Opinion.js +76 -60
- package/icons/iconMap.js +2 -2
- package/identity-CPGTqrE4.js +6 -0
- package/index-CAvu7vwt.js +1172 -0
- package/index-CVUD9o3t.js +15768 -0
- package/index-DUEubgWN.js +464 -0
- package/index-Dj1N4IQP.js +9314 -0
- package/index-DpJxD74E.js +3272 -0
- package/index-_gpzM2Px.js +702 -0
- package/isArguments-CuYlEuhP.js +27 -0
- package/isArray-RJPfgWqI.js +4 -0
- package/isEmpty-BE656RUK.js +30 -0
- package/isNil-CIubwp4T.js +6 -0
- package/isObject-FTY-5JQX.js +7 -0
- package/isObjectLike-CeENW9FN.js +6 -0
- package/isSymbol-D_H4HPZQ.js +9 -0
- package/last-CUCl67Im.js +7 -0
- package/main.js +62 -62
- package/maxBy-BjjQmX5t.js +8 -0
- package/package.json +1 -1
- package/plugins/ClueUIPlugin.js +163 -96
- package/plugins/file/index.js +15 -15
- package/plugins/graph/index.js +29 -26
- package/plugins/image/index.js +28 -24
- package/plugins/json/index.js +21 -21
- package/plugins/markdown/index.js +18 -18
- package/plugins/registry.js +6 -6
- package/plugins/store.js +4 -4
- package/plugins/test/index.js +17 -17
- package/plugins/utils.js +13 -12
- package/replication--gLEZw8a.js +11777 -0
- package/sessionStorage-B68y-wnE.js +140 -0
- package/sortBy-B8JVsLQY.js +95 -0
- package/store-B9sjQbcS.js +2163 -0
- package/sumBy-D-HCzM2i.js +8 -0
- package/text/Frequency.js +42 -23
- package/toFinite-meZTg4Su.js +16 -0
- package/toNumber-B5JaA1vX.js +39 -0
- package/uniq-CahZPAwp.js +7 -0
- package/utils/chain.js +92 -65
- package/utils/classificationParser.js +519 -256
- package/utils/constants.js +37 -11
- package/utils/graph.js +72 -45
- package/utils/hashUtil.js +7 -7
- package/utils/line.js +131 -81
- package/utils/loggerUtil.js +5 -3
- package/utils/sessionStorage.js +7 -7
- package/utils/time.js +447 -427
- package/utils/utils.js +10 -10
- package/utils/window.js +21 -10
- package/utils-CEySTPtg.js +224 -0
- package/ActionForm-CHOSKfvu.js +0 -4403
- package/AnnotationDetails-Bqq6Ymmg.js +0 -160
- package/AnnotationPreview-CqXmC-j8.js +0 -140
- package/ClueEnrichContext-DL6aGe1k.js +0 -432
- package/FlexOne-BXWFOd1T.js +0 -6
- package/_MapCache-DRK-s2eK.js +0 -179
- package/_Set-DrS_bbSV.js +0 -6
- package/_Uint8Array-D9R2N9Lp.js +0 -98
- package/_arrayIncludes-Dcl_29E6.js +0 -25
- package/_arrayPush-DBJIuK2V.js +0 -8
- package/_baseAssignValue-Bx1cxHj5.js +0 -12
- package/_baseClone-DRhywkxm.js +0 -211
- package/_baseExtremum-DodEaEyF.js +0 -16
- package/_baseFlatten-CD9NgrYE.js +0 -72
- package/_baseGet-bVwDaGrA.js +0 -80
- package/_baseGetTag-CxDaTem-.js +0 -25
- package/_baseIsEqual-C-FKsm1J.js +0 -150
- package/_baseIteratee-D0FhC5bC.js +0 -95
- package/_baseRest-D_eW2E0d.js +0 -8
- package/_baseSlice-M5RKzt1A.js +0 -10
- package/_baseSum-wEbgNeUs.js +0 -10
- package/_baseUniq-D3N8igOm.js +0 -41
- package/_cacheHas-Wgl-hw34.js +0 -22
- package/_commonjsHelpers-C6fGbg64.js +0 -6
- package/_createAggregator-BVj8IAuF.js +0 -53
- package/_defineProperty-BZU4WKA3.js +0 -11
- package/_getPrototype-BGBCg-aX.js +0 -5
- package/_getTag-B7R9qBo7.js +0 -73
- package/_isIterateeCall-Dm0VTAYy.js +0 -13
- package/_setToArray-Ck4YZu0Z.js +0 -9
- package/cloneDeep-fV59zwUf.js +0 -8
- package/countBy-B3rNuG4T.js +0 -8
- package/get-Bil3mzRD.js +0 -8
- package/groupBy-CrJC7sGa.js +0 -8
- package/iconify-Ptb5dTKy.js +0 -1270
- package/identity-ByMq8VxU.js +0 -6
- package/index-BH-gBhtO.js +0 -2282
- package/index-BM9Sve5T.js +0 -571
- package/index-Cj4d5cGz.js +0 -357
- package/index-Dh2PP9h8.js +0 -11747
- package/index-DoFpWPHo.js +0 -975
- package/index-DzVIklWY.js +0 -6464
- package/isArguments-BWcXOE6a.js +0 -24
- package/isArray-WzO_os3q.js +0 -4
- package/isEmpty-DKxrY-_M.js +0 -22
- package/isNil-CjWwlQS3.js +0 -6
- package/isObject-B53jY8Qg.js +0 -7
- package/isObjectLike-CYbdrIBr.js +0 -6
- package/isSymbol-DE1Kcy2M.js +0 -9
- package/last-7CdUxN0r.js +0 -7
- package/maxBy-BOWDkL_D.js +0 -8
- package/replication-WkKbPdwG.js +0 -8453
- package/sessionStorage-DFMae61b.js +0 -90
- package/sortBy-BHe812lF.js +0 -74
- package/store-DClHBq7r.js +0 -1169
- package/sumBy-B7f_bP_k.js +0 -8
- package/toFinite-CBrE65MP.js +0 -14
- package/toNumber-CxmWey0f.js +0 -31
- package/uniq-B4UZ671_.js +0 -7
- package/utils-SpTOhPYl.js +0 -147
|
@@ -1,290 +1,553 @@
|
|
|
1
|
-
const
|
|
1
|
+
const defaultParts = {
|
|
2
2
|
lvlIdx: 0,
|
|
3
3
|
lvl: "",
|
|
4
4
|
req: [],
|
|
5
5
|
groups: [],
|
|
6
6
|
subgroups: []
|
|
7
|
-
}
|
|
7
|
+
};
|
|
8
|
+
const defaultDisabled = {
|
|
8
9
|
groups: [],
|
|
9
10
|
levels: []
|
|
10
11
|
};
|
|
11
|
-
class
|
|
12
|
+
class InvalidClassification extends Error {
|
|
12
13
|
}
|
|
13
|
-
const
|
|
14
|
-
let
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
14
|
+
const getLevelText = (lvl, c12nDef, format, isMobile) => {
|
|
15
|
+
let text = null;
|
|
16
|
+
if (c12nDef != null && lvl != null) {
|
|
17
|
+
text = c12nDef.levels_map[lvl.toString()];
|
|
18
|
+
}
|
|
19
|
+
if (text === void 0 || text == null) {
|
|
20
|
+
console.error(
|
|
21
|
+
`[classificationParser] Classification level number '${lvl}' was not found in your classification definition.`
|
|
22
|
+
);
|
|
23
|
+
return "INVALID";
|
|
24
|
+
}
|
|
25
|
+
if (format === "long" && !isMobile) {
|
|
26
|
+
return c12nDef.levels_map_stl[text];
|
|
27
|
+
}
|
|
28
|
+
return text;
|
|
29
|
+
};
|
|
30
|
+
const getLevelIndex = (c12n, c12nDef) => {
|
|
31
|
+
let retIndex = null;
|
|
32
|
+
const [level, unused, _x] = (c12n == null ? void 0 : c12n.split(/\/\/(.*)/)) ?? [null, null, null];
|
|
33
|
+
const c12nLvl = level == null ? void 0 : level.toUpperCase();
|
|
34
|
+
if (c12nDef.levels_map[c12nLvl] !== void 0) {
|
|
35
|
+
retIndex = c12nDef.levels_map[c12nLvl];
|
|
36
|
+
} else if (c12nDef.levels_map_lts[c12nLvl] !== void 0) {
|
|
37
|
+
retIndex = c12nDef.levels_map[c12nDef.levels_map_lts[c12nLvl]];
|
|
38
|
+
} else if (c12nDef.levels_aliases[c12nLvl] !== void 0) {
|
|
39
|
+
retIndex = c12nDef.levels_map[c12nDef.levels_aliases[c12nLvl]];
|
|
40
|
+
} else {
|
|
41
|
+
retIndex = -1;
|
|
42
|
+
console.error(
|
|
43
|
+
`[classificationParser] Classification level '${level}' was not found in your classification definition.`
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
if (typeof retIndex !== "number") {
|
|
47
|
+
retIndex = parseInt(retIndex);
|
|
48
|
+
}
|
|
49
|
+
return [retIndex, unused];
|
|
50
|
+
};
|
|
51
|
+
const getRequired = (c12n, c12nDef, format, isMobile) => {
|
|
52
|
+
const returnSet = [];
|
|
53
|
+
const unused = [];
|
|
54
|
+
if (!c12n) {
|
|
55
|
+
return [returnSet.sort(), unused];
|
|
56
|
+
}
|
|
57
|
+
const partSet = c12n.toUpperCase().split("/");
|
|
58
|
+
for (const p of partSet) {
|
|
59
|
+
if (p in c12nDef.access_req_map_lts) {
|
|
60
|
+
returnSet.push(c12nDef.access_req_map_lts[p]);
|
|
61
|
+
} else if (p in c12nDef.access_req_map_stl) {
|
|
62
|
+
returnSet.push(p);
|
|
63
|
+
} else if (p in c12nDef.access_req_aliases) {
|
|
64
|
+
for (const a of c12nDef.access_req_aliases[p]) {
|
|
65
|
+
returnSet.push(a);
|
|
66
|
+
}
|
|
67
|
+
} else {
|
|
68
|
+
unused.push(p);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (format === "long" && !isMobile) {
|
|
72
|
+
const out = [];
|
|
73
|
+
for (const r of returnSet) {
|
|
74
|
+
out.push(c12nDef.access_req_map_stl[r]);
|
|
75
|
+
}
|
|
76
|
+
return [out.sort(), unused];
|
|
77
|
+
}
|
|
78
|
+
return [returnSet.sort(), unused];
|
|
79
|
+
};
|
|
80
|
+
const getGroups = (groupParts, c12nDef, format, isMobile, autoSelect = false) => {
|
|
81
|
+
var _a, _b, _c, _d;
|
|
82
|
+
let g1Set = /* @__PURE__ */ new Set();
|
|
83
|
+
let g2Set = /* @__PURE__ */ new Set();
|
|
84
|
+
let others = /* @__PURE__ */ new Set();
|
|
85
|
+
const groups = [];
|
|
86
|
+
const subgroups = [];
|
|
87
|
+
for (const grpPart of groupParts) {
|
|
88
|
+
if (!grpPart) {
|
|
52
89
|
continue;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
90
|
+
}
|
|
91
|
+
const gp = grpPart.toUpperCase();
|
|
92
|
+
if (gp.startsWith("REL ")) {
|
|
93
|
+
const tempGroups = new Set(gp.replace("REL TO ", "").replace("REL ", "").split(","));
|
|
94
|
+
for (let tg of tempGroups) {
|
|
95
|
+
tg = tg.trim();
|
|
96
|
+
for (let tsg of tg.split("/")) {
|
|
97
|
+
tsg = tsg.trim();
|
|
98
|
+
groups.push(tsg);
|
|
99
|
+
}
|
|
60
100
|
}
|
|
61
|
-
} else
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
);
|
|
101
|
+
} else {
|
|
102
|
+
subgroups.push(gp);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
for (const g of groups) {
|
|
106
|
+
if (g in c12nDef.groups_map_lts) {
|
|
107
|
+
g1Set.add(c12nDef.groups_map_lts[g]);
|
|
108
|
+
} else if (g in c12nDef.groups_map_stl) {
|
|
109
|
+
g1Set.add(g);
|
|
110
|
+
} else if (g in c12nDef.groups_aliases) {
|
|
111
|
+
for (const a of c12nDef.groups_aliases[g]) {
|
|
112
|
+
g1Set.add(a);
|
|
113
|
+
}
|
|
114
|
+
} else {
|
|
115
|
+
others.add(g);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
for (const g of subgroups) {
|
|
119
|
+
if (g in c12nDef.subgroups_map_lts) {
|
|
120
|
+
g2Set.add(c12nDef.subgroups_map_lts[g]);
|
|
121
|
+
} else if (g in c12nDef.subgroups_map_stl) {
|
|
122
|
+
g2Set.add(g);
|
|
123
|
+
} else if (g in c12nDef.subgroups_aliases) {
|
|
124
|
+
for (const sa of c12nDef.subgroups_aliases[g]) {
|
|
125
|
+
g2Set.add(sa);
|
|
126
|
+
}
|
|
127
|
+
} else if (g in c12nDef.groups_aliases) {
|
|
128
|
+
const grps = c12nDef.groups_aliases[g];
|
|
129
|
+
if (grps.length > 1) {
|
|
130
|
+
console.error(`[classificationParser] Unclear use of alias ${g}`);
|
|
131
|
+
}
|
|
132
|
+
g1Set.add(grps[0]);
|
|
133
|
+
} else {
|
|
134
|
+
g1Set.add(g);
|
|
135
|
+
console.error(`[classificationParser] Unknown component ${g}`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (c12nDef.dynamic_groups) {
|
|
139
|
+
for (const o of others) {
|
|
140
|
+
g1Set.add(o);
|
|
141
|
+
}
|
|
142
|
+
others = /* @__PURE__ */ new Set();
|
|
143
|
+
}
|
|
144
|
+
for (const subgroup of g2Set) {
|
|
145
|
+
const required = (_b = (_a = c12nDef.params_map) == null ? void 0 : _a[subgroup]) == null ? void 0 : _b.require_group;
|
|
146
|
+
if (!!required) {
|
|
147
|
+
g1Set.add(required);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
for (const subgroup of g2Set) {
|
|
151
|
+
const limitedToGroup = (_d = (_c = c12nDef.params_map) == null ? void 0 : _c[subgroup]) == null ? void 0 : _d.limited_to_group;
|
|
152
|
+
if (limitedToGroup !== null && limitedToGroup !== void 0) {
|
|
153
|
+
if (g1Set.size > 1 || g1Set.size === 1 && !g1Set.has(limitedToGroup)) {
|
|
154
|
+
console.error(
|
|
155
|
+
`[classificationParser] Subgroup ${subgroup} is limited to group ${limitedToGroup} (found: ${Array.from(
|
|
156
|
+
g1Set
|
|
157
|
+
).toString()})`
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
if (!!autoSelect && !!g1Set) {
|
|
163
|
+
g1Set = /* @__PURE__ */ new Set([...g1Set, ...c12nDef.groups_auto_select_short]);
|
|
164
|
+
}
|
|
165
|
+
if (!!autoSelect && !!g2Set) {
|
|
166
|
+
g2Set = /* @__PURE__ */ new Set([...g2Set, ...c12nDef.subgroups_auto_select_short]);
|
|
167
|
+
}
|
|
168
|
+
if (format === "long" && !isMobile) {
|
|
169
|
+
const g1Out = [];
|
|
170
|
+
for (const gr of g1Set) {
|
|
171
|
+
g1Out.push(gr in c12nDef.groups_map_stl ? c12nDef.groups_map_stl[gr] : gr);
|
|
172
|
+
}
|
|
173
|
+
const g2Out = [];
|
|
174
|
+
for (const sgr of g2Set) {
|
|
175
|
+
g2Out.push(c12nDef.subgroups_map_stl[sgr]);
|
|
176
|
+
}
|
|
177
|
+
return { groups: g1Out.sort(), subgroups: g2Out.sort(), others: Array.from(others).sort() };
|
|
178
|
+
}
|
|
179
|
+
return { groups: Array.from(g1Set).sort(), subgroups: Array.from(g2Set).sort(), others: Array.from(others).sort() };
|
|
180
|
+
};
|
|
181
|
+
const getParts = (c12n, c12nDef, format, isMobile) => {
|
|
182
|
+
const [lvlIdx, unused] = getLevelIndex(c12n, c12nDef);
|
|
183
|
+
const [req, unusedParts] = getRequired(unused, c12nDef, format, isMobile);
|
|
184
|
+
const { groups, subgroups, others } = getGroups(unusedParts, c12nDef, format, isMobile);
|
|
185
|
+
if (others.length > 0) {
|
|
186
|
+
console.error(`[classificationParser] Unparsable classification parts: ${others.join(",")}`);
|
|
103
187
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
f.push(s.subgroups_map_stl[g]);
|
|
111
|
-
return { groups: t.sort(), subgroups: f.sort(), others: Array.from(m).sort() };
|
|
112
|
-
}
|
|
113
|
-
return { groups: Array.from(r).sort(), subgroups: Array.from(a).sort(), others: Array.from(m).sort() };
|
|
114
|
-
}, b = (i, s, o, p) => {
|
|
115
|
-
const [u, r] = T(i, s), [a, m] = $(r, s, o, p), { groups: d, subgroups: _, others: l } = U(m, s, o, p);
|
|
116
|
-
return l.length > 0 && console.error(`[classificationParser] Unparsable classification parts: ${l.join(",")}`), {
|
|
117
|
-
lvlIdx: u,
|
|
118
|
-
lvl: I(u, s, o, p),
|
|
119
|
-
req: a,
|
|
120
|
-
groups: d,
|
|
121
|
-
subgroups: _
|
|
188
|
+
return {
|
|
189
|
+
lvlIdx,
|
|
190
|
+
lvl: getLevelText(lvlIdx, c12nDef, format, isMobile),
|
|
191
|
+
req,
|
|
192
|
+
groups,
|
|
193
|
+
subgroups
|
|
122
194
|
};
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
return
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
if (
|
|
167
|
-
|
|
168
|
-
|
|
195
|
+
};
|
|
196
|
+
const canSeeRequired = (user_req, req) => {
|
|
197
|
+
if (req.length <= 0) return true;
|
|
198
|
+
const userSet = new Set(user_req);
|
|
199
|
+
const reqSet = new Set(req);
|
|
200
|
+
for (const elem of reqSet) {
|
|
201
|
+
if (!userSet.has(elem)) {
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return true;
|
|
206
|
+
};
|
|
207
|
+
const canSeeGroups = (user_groups, groups) => {
|
|
208
|
+
if (groups.length === 0) return true;
|
|
209
|
+
const groupSet = new Set(groups);
|
|
210
|
+
const userSet = new Set(user_groups);
|
|
211
|
+
for (const elem of groupSet) {
|
|
212
|
+
if (userSet.has(elem)) {
|
|
213
|
+
return true;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return false;
|
|
217
|
+
};
|
|
218
|
+
const normalizedClassification = (parts, c12nDef, format, isMobile, skipAutoSelect = false) => {
|
|
219
|
+
var _a, _b, _c, _d, _e, _f;
|
|
220
|
+
if (!c12nDef.enforce || !!c12nDef.invalid_mode) return c12nDef.UNRESTRICTED;
|
|
221
|
+
const longFormat = format === "short" || !!isMobile ? false : true;
|
|
222
|
+
const groupDelim = !!longFormat ? "REL TO " : "REL ";
|
|
223
|
+
const { lvlIdx, lvl } = parts;
|
|
224
|
+
let { groups, subgroups, req } = parts;
|
|
225
|
+
req = req.map((r) => {
|
|
226
|
+
if (!!longFormat) {
|
|
227
|
+
return c12nDef.access_req_map_stl[r] || r;
|
|
228
|
+
}
|
|
229
|
+
return c12nDef.access_req_map_lts[r] || r;
|
|
230
|
+
});
|
|
231
|
+
groups = groups.map((g) => {
|
|
232
|
+
if (!!longFormat) {
|
|
233
|
+
return c12nDef.groups_map_stl[g] || g;
|
|
234
|
+
}
|
|
235
|
+
return c12nDef.groups_map_lts[g] || g;
|
|
236
|
+
});
|
|
237
|
+
subgroups = subgroups.map((g) => {
|
|
238
|
+
if (!!longFormat) {
|
|
239
|
+
return c12nDef.subgroups_map_stl[g] || g;
|
|
240
|
+
}
|
|
241
|
+
return c12nDef.subgroups_map_lts[g] || g;
|
|
242
|
+
});
|
|
243
|
+
let out = lvl;
|
|
244
|
+
let requiredLvlIdx = 0;
|
|
245
|
+
for (const r of req) {
|
|
246
|
+
const rl = !!((_b = (_a = c12nDef.params_map) == null ? void 0 : _a[r]) == null ? void 0 : _b.require_lvl) ? c12nDef.params_map[r].require_lvl : 0;
|
|
247
|
+
requiredLvlIdx = Math.max(requiredLvlIdx, rl);
|
|
248
|
+
}
|
|
249
|
+
out = getLevelText(Math.max(lvlIdx, requiredLvlIdx), c12nDef, format, isMobile);
|
|
250
|
+
const reqGrp = /* @__PURE__ */ new Set();
|
|
251
|
+
for (const r of req) {
|
|
252
|
+
if (!!((_c = c12nDef.params_map[r]) == null ? void 0 : _c.is_required_group)) {
|
|
253
|
+
reqGrp.add(r);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
const tempReq = Array.from(new Set([...req].filter((x) => !reqGrp.has(x))));
|
|
257
|
+
if (tempReq.length > 0) {
|
|
258
|
+
out += "//" + tempReq.sort().join("/");
|
|
259
|
+
}
|
|
260
|
+
if (reqGrp.size > 0) {
|
|
261
|
+
out += "//" + Array.from(reqGrp).sort().join("/");
|
|
262
|
+
}
|
|
263
|
+
let tempSubGroups = [...subgroups];
|
|
264
|
+
if (!!longFormat) {
|
|
265
|
+
if (subgroups.length > 0 && c12nDef.subgroups_auto_select.length > 0 && !skipAutoSelect) {
|
|
266
|
+
tempSubGroups = Array.from(/* @__PURE__ */ new Set([...subgroups, ...c12nDef.subgroups_auto_select])).sort();
|
|
267
|
+
}
|
|
268
|
+
} else {
|
|
269
|
+
if (subgroups.length > 0 && c12nDef.subgroups_auto_select_short.length > 0 && !skipAutoSelect) {
|
|
270
|
+
tempSubGroups = Array.from(/* @__PURE__ */ new Set([...subgroups, ...c12nDef.subgroups_auto_select_short])).sort();
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
let tempGroups = [];
|
|
274
|
+
for (const sg of tempSubGroups) {
|
|
275
|
+
const rGrp = (_d = c12nDef.params_map[sg]) == null ? void 0 : _d.require_group;
|
|
276
|
+
if (!!rGrp) {
|
|
277
|
+
tempGroups.push(rGrp);
|
|
278
|
+
}
|
|
279
|
+
const limToGrp = (_e = c12nDef.params_map[sg]) == null ? void 0 : _e.limited_to_group;
|
|
280
|
+
if (!!limToGrp) {
|
|
281
|
+
if (limToGrp in tempGroups) {
|
|
282
|
+
tempGroups = [limToGrp];
|
|
283
|
+
} else {
|
|
284
|
+
tempGroups = [];
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
for (const g of tempGroups) {
|
|
289
|
+
if (!!longFormat) {
|
|
290
|
+
groups.push(c12nDef.groups_map_stl[g] || g);
|
|
291
|
+
} else {
|
|
292
|
+
groups.push(c12nDef.groups_map_lts[g] || g);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
groups = Array.from(new Set(groups));
|
|
296
|
+
if (!!longFormat) {
|
|
297
|
+
if (groups.length > 0 && c12nDef.groups_auto_select.length > 0 && !skipAutoSelect) {
|
|
298
|
+
groups = Array.from(/* @__PURE__ */ new Set([...groups, ...c12nDef.groups_auto_select])).sort();
|
|
299
|
+
}
|
|
300
|
+
} else {
|
|
301
|
+
if (groups.length > 0 && c12nDef.groups_auto_select_short.length > 0 && !skipAutoSelect) {
|
|
302
|
+
groups = Array.from(/* @__PURE__ */ new Set([...groups, ...c12nDef.groups_auto_select_short])).sort();
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
if (groups.length > 0) {
|
|
306
|
+
groups = groups.sort();
|
|
307
|
+
out += reqGrp.size > 0 ? "/" : "//";
|
|
308
|
+
if (groups.length === 1) {
|
|
309
|
+
const grp = groups[0];
|
|
310
|
+
const displayName = ((_f = c12nDef.params_map[grp]) == null ? void 0 : _f.solitary_display_name) || grp;
|
|
311
|
+
out += displayName !== grp ? displayName : groupDelim + grp;
|
|
312
|
+
} else {
|
|
313
|
+
if (!longFormat) {
|
|
314
|
+
for (const [alias, values] of Object.entries(c12nDef.groups_aliases)) {
|
|
315
|
+
if (values.length > 1) {
|
|
316
|
+
if (JSON.stringify(values.sort()) === JSON.stringify(groups)) {
|
|
317
|
+
groups = [alias];
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
out += groupDelim + groups.sort().join(", ");
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
if (tempSubGroups.length > 0) {
|
|
326
|
+
if (groups.length > 0 || reqGrp.size > 0) {
|
|
327
|
+
out += "/";
|
|
169
328
|
} else {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
const
|
|
178
|
-
for (const
|
|
179
|
-
isNaN(parseInt(
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
}
|
|
185
|
-
|
|
329
|
+
out += "//";
|
|
330
|
+
}
|
|
331
|
+
out += tempSubGroups.sort().join("/");
|
|
332
|
+
}
|
|
333
|
+
return out;
|
|
334
|
+
};
|
|
335
|
+
const levelList = (c12nDef) => {
|
|
336
|
+
const out = [];
|
|
337
|
+
for (const i in c12nDef.levels_map) {
|
|
338
|
+
if (!isNaN(parseInt(i))) {
|
|
339
|
+
out.push(c12nDef.levels_map[i]);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
return out;
|
|
343
|
+
};
|
|
344
|
+
const defaultClassificationValidator = {
|
|
345
|
+
disabled: defaultDisabled,
|
|
346
|
+
parts: defaultParts
|
|
347
|
+
};
|
|
348
|
+
const applyClassificationRules = (parts, c12nDef, format, isMobile, userClassification = false) => {
|
|
349
|
+
const longFormat = format === "short" || !!isMobile ? false : true;
|
|
350
|
+
const requireLvl = {};
|
|
351
|
+
const limitedToGroup = {};
|
|
352
|
+
const requireGroup = {};
|
|
353
|
+
const partsToCheck = ["req", "groups", "subgroups"];
|
|
354
|
+
const retParts = { ...parts };
|
|
355
|
+
const disabledList = {
|
|
186
356
|
levels: [],
|
|
187
357
|
groups: []
|
|
188
358
|
};
|
|
189
|
-
for (const
|
|
190
|
-
if ({}.hasOwnProperty.call(
|
|
191
|
-
const
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
359
|
+
for (const item in c12nDef.params_map) {
|
|
360
|
+
if ({}.hasOwnProperty.call(c12nDef.params_map, item)) {
|
|
361
|
+
const data = c12nDef.params_map[item];
|
|
362
|
+
if ("require_lvl" in data) {
|
|
363
|
+
requireLvl[item] = data.require_lvl;
|
|
364
|
+
}
|
|
365
|
+
if ("limited_to_group" in data) {
|
|
366
|
+
limitedToGroup[item] = data.limited_to_group;
|
|
367
|
+
}
|
|
368
|
+
if ("require_group" in data) {
|
|
369
|
+
requireGroup[item] = data.require_group;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
for (const partName in partsToCheck) {
|
|
374
|
+
if ({}.hasOwnProperty.call(partsToCheck, partName)) {
|
|
375
|
+
const part = retParts[partsToCheck[partName]];
|
|
376
|
+
for (const value of part) {
|
|
377
|
+
let triggerAutoSelect = false;
|
|
378
|
+
if (value) {
|
|
379
|
+
if (value in requireLvl) {
|
|
380
|
+
if (retParts.lvlIdx < requireLvl[value]) {
|
|
381
|
+
retParts.lvlIdx = requireLvl[value];
|
|
382
|
+
retParts.lvl = getLevelText(requireLvl[value], c12nDef, format, isMobile);
|
|
383
|
+
}
|
|
384
|
+
const levels = levelList(c12nDef);
|
|
385
|
+
for (const l of levels) {
|
|
386
|
+
if (c12nDef.levels_map[l] < requireLvl[value]) {
|
|
387
|
+
disabledList.levels.push(l);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
205
390
|
}
|
|
206
|
-
if (
|
|
207
|
-
const
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
391
|
+
if (value in requireGroup) {
|
|
392
|
+
const valueLong = c12nDef.groups_map_stl[requireGroup[value]] || requireGroup[value];
|
|
393
|
+
const valueShort = c12nDef.groups_map_lts[requireGroup[value]] || requireGroup[value];
|
|
394
|
+
if (!retParts.groups.includes(valueLong) && !retParts.groups.includes(valueShort)) {
|
|
395
|
+
retParts.groups.push(valueShort);
|
|
396
|
+
for (const group of c12nDef.groups_auto_select) {
|
|
397
|
+
const gLong = c12nDef.groups_map_stl[group] || group;
|
|
398
|
+
const gShort = c12nDef.groups_map_lts[group] || group;
|
|
399
|
+
if (!retParts.groups.includes(gShort) && !retParts.groups.includes(gLong)) {
|
|
400
|
+
retParts.groups.push(group);
|
|
401
|
+
}
|
|
213
402
|
}
|
|
214
403
|
}
|
|
215
404
|
}
|
|
216
|
-
if (
|
|
217
|
-
for (const
|
|
218
|
-
const
|
|
219
|
-
if (
|
|
220
|
-
const
|
|
221
|
-
|
|
405
|
+
if (value in limitedToGroup) {
|
|
406
|
+
for (const gShort in c12nDef.groups_map_stl) {
|
|
407
|
+
const lgShort = c12nDef.groups_map_lts[limitedToGroup[value]] || limitedToGroup[value];
|
|
408
|
+
if (gShort !== lgShort) {
|
|
409
|
+
const gLong = c12nDef.groups_map_stl[gShort];
|
|
410
|
+
disabledList.groups.push(gShort);
|
|
411
|
+
if (retParts.groups.includes(gShort)) {
|
|
412
|
+
retParts.groups.splice(retParts.groups.indexOf(gShort), 1);
|
|
413
|
+
} else if (retParts.groups.includes(gLong)) {
|
|
414
|
+
retParts.groups.splice(retParts.groups.indexOf(gLong), 1);
|
|
415
|
+
}
|
|
222
416
|
}
|
|
223
417
|
}
|
|
224
|
-
|
|
418
|
+
}
|
|
419
|
+
if (!userClassification && partsToCheck[partName] === "groups") {
|
|
420
|
+
triggerAutoSelect = true;
|
|
421
|
+
}
|
|
225
422
|
}
|
|
226
|
-
if (
|
|
227
|
-
for (const
|
|
228
|
-
const
|
|
229
|
-
|
|
423
|
+
if (triggerAutoSelect) {
|
|
424
|
+
for (const group of c12nDef.groups_auto_select) {
|
|
425
|
+
const gLong = c12nDef.groups_map_stl[group] || group;
|
|
426
|
+
const gShort = c12nDef.groups_map_lts[group] || group;
|
|
427
|
+
if (!retParts.groups.includes(gLong) && !retParts.groups.includes(gShort)) {
|
|
428
|
+
retParts.groups.push(group);
|
|
429
|
+
}
|
|
230
430
|
}
|
|
431
|
+
}
|
|
231
432
|
}
|
|
232
433
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
434
|
+
}
|
|
435
|
+
retParts.req = retParts.req.sort().map((r) => {
|
|
436
|
+
if (!!longFormat) {
|
|
437
|
+
return c12nDef.access_req_map_stl[r] || r;
|
|
438
|
+
}
|
|
439
|
+
return c12nDef.access_req_map_lts[r] || r;
|
|
440
|
+
});
|
|
441
|
+
retParts.groups = retParts.groups.sort().map((g) => {
|
|
442
|
+
if (!!longFormat) {
|
|
443
|
+
return c12nDef.groups_map_stl[g] || g;
|
|
444
|
+
}
|
|
445
|
+
return c12nDef.groups_map_lts[g] || g;
|
|
446
|
+
});
|
|
447
|
+
retParts.subgroups = retParts.subgroups.sort().map((sg) => {
|
|
448
|
+
if (!!longFormat) {
|
|
449
|
+
return c12nDef.subgroups_map_stl[sg] || sg;
|
|
450
|
+
}
|
|
451
|
+
return c12nDef.subgroups_map_lts[sg] || sg;
|
|
452
|
+
});
|
|
453
|
+
disabledList.groups = disabledList.groups.sort().map((g) => {
|
|
454
|
+
if (!!longFormat) {
|
|
455
|
+
return c12nDef.groups_map_stl[g] || g;
|
|
456
|
+
}
|
|
457
|
+
return c12nDef.groups_map_lts[g] || g;
|
|
458
|
+
});
|
|
459
|
+
disabledList.levels = disabledList.levels.sort().map((l) => {
|
|
460
|
+
if (!!longFormat) {
|
|
461
|
+
return c12nDef.levels_map_stl[l] || l;
|
|
462
|
+
}
|
|
463
|
+
return c12nDef.levels_map_lts[l] || l;
|
|
464
|
+
});
|
|
465
|
+
if (!!longFormat) {
|
|
466
|
+
retParts.lvl = c12nDef.levels_map_stl[retParts.lvl] || retParts.lvl;
|
|
467
|
+
} else {
|
|
468
|
+
retParts.lvl = c12nDef.levels_map_lts[retParts.lvl] || retParts.lvl;
|
|
469
|
+
}
|
|
470
|
+
return {
|
|
471
|
+
disabled: disabledList,
|
|
472
|
+
parts: retParts
|
|
236
473
|
};
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
if (!
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
474
|
+
};
|
|
475
|
+
const getMaxGroups = (grps1, grps2) => {
|
|
476
|
+
let groups = /* @__PURE__ */ new Set();
|
|
477
|
+
if (grps1.length > 0 && grps2.length > 0) {
|
|
478
|
+
const g2 = new Set(grps2);
|
|
479
|
+
groups = new Set([...grps1].filter((x) => g2.has(x)));
|
|
480
|
+
} else {
|
|
481
|
+
groups = /* @__PURE__ */ new Set([...grps1, ...grps2]);
|
|
482
|
+
}
|
|
483
|
+
if (grps1.length > 0 && grps2.length > 0 && groups.size <= 0) {
|
|
484
|
+
groups = /* @__PURE__ */ new Set([...grps1, ...grps2]);
|
|
485
|
+
console.error(
|
|
486
|
+
`[classificationParser] Could not find any intersection between the groups. ${grps1.toString()} & ${grps2.toString()}`
|
|
487
|
+
);
|
|
488
|
+
}
|
|
489
|
+
return Array.from(groups);
|
|
490
|
+
};
|
|
491
|
+
const getMaxClassification = (c12n_1, c12n_2, c12nDef, format, isMobile) => {
|
|
492
|
+
if (!c12nDef.enforce || !!c12nDef.invalid_mode) {
|
|
493
|
+
const noEnforceParts = getParts(c12nDef.UNRESTRICTED, c12nDef, format, isMobile);
|
|
494
|
+
return normalizedClassification(noEnforceParts, c12nDef, format, isMobile);
|
|
495
|
+
}
|
|
496
|
+
const c12n1Parts = getParts(c12n_1, c12nDef, format, isMobile);
|
|
497
|
+
const c12n2Parts = getParts(c12n_2, c12nDef, format, isMobile);
|
|
498
|
+
if (!c12n_1) {
|
|
499
|
+
return normalizedClassification(c12n2Parts, c12nDef, format, isMobile);
|
|
500
|
+
}
|
|
501
|
+
if (!c12n_2) {
|
|
502
|
+
return normalizedClassification(c12n1Parts, c12nDef, format, isMobile);
|
|
503
|
+
}
|
|
504
|
+
const req = Array.from(/* @__PURE__ */ new Set([...c12n1Parts.req, ...c12n2Parts.req]));
|
|
505
|
+
const groups = getMaxGroups(c12n1Parts.groups, c12n2Parts.groups);
|
|
506
|
+
const subgroups = getMaxGroups(c12n1Parts.subgroups, c12n2Parts.subgroups);
|
|
507
|
+
const lvlIdx = Math.max(c12n1Parts.lvlIdx, c12n2Parts.lvlIdx);
|
|
508
|
+
const out = {
|
|
509
|
+
lvlIdx,
|
|
510
|
+
lvl: getLevelText(lvlIdx, c12nDef, format, isMobile),
|
|
511
|
+
req,
|
|
512
|
+
groups,
|
|
513
|
+
subgroups
|
|
263
514
|
};
|
|
264
|
-
return
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
if (
|
|
515
|
+
return normalizedClassification(out, c12nDef, format, isMobile);
|
|
516
|
+
};
|
|
517
|
+
const isAccessible = (user_c12n, c12n, c12nDef, enforce = false, ignoreInvalid = true) => {
|
|
518
|
+
if (!!c12nDef.invalid_mode) return false;
|
|
519
|
+
if (!enforce) return true;
|
|
520
|
+
if (!c12n) return true;
|
|
268
521
|
try {
|
|
269
|
-
const
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
return
|
|
274
|
-
|
|
522
|
+
const userParts = getParts(user_c12n, c12nDef, "long", false);
|
|
523
|
+
const parts = getParts(c12n, c12nDef, "long", false);
|
|
524
|
+
if (Number(userParts.lvlIdx) >= Number(parts.lvlIdx)) {
|
|
525
|
+
if (!canSeeRequired(userParts.req, parts.req)) return false;
|
|
526
|
+
if (!canSeeGroups(userParts.groups, parts.groups)) return false;
|
|
527
|
+
if (!canSeeGroups(userParts.subgroups, parts.subgroups)) return false;
|
|
528
|
+
return true;
|
|
529
|
+
}
|
|
530
|
+
return false;
|
|
531
|
+
} catch (e) {
|
|
532
|
+
if (e instanceof InvalidClassification) {
|
|
533
|
+
if (!!ignoreInvalid) {
|
|
534
|
+
return false;
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
throw e;
|
|
275
538
|
}
|
|
276
539
|
};
|
|
277
540
|
export {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
541
|
+
InvalidClassification,
|
|
542
|
+
applyClassificationRules,
|
|
543
|
+
canSeeGroups,
|
|
544
|
+
canSeeRequired,
|
|
545
|
+
defaultClassificationValidator,
|
|
546
|
+
defaultDisabled,
|
|
547
|
+
defaultParts,
|
|
548
|
+
getLevelText,
|
|
549
|
+
getMaxClassification,
|
|
550
|
+
getParts,
|
|
551
|
+
isAccessible,
|
|
552
|
+
normalizedClassification
|
|
290
553
|
};
|