mapra 0.1.0
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/LICENSE +21 -0
- package/README.md +144 -0
- package/dist/analyzer/blast-radius.d.ts +27 -0
- package/dist/analyzer/blast-radius.d.ts.map +1 -0
- package/dist/analyzer/blast-radius.js +58 -0
- package/dist/analyzer/blast-radius.js.map +1 -0
- package/dist/analyzer/churn.d.ts +26 -0
- package/dist/analyzer/churn.d.ts.map +1 -0
- package/dist/analyzer/churn.js +96 -0
- package/dist/analyzer/churn.js.map +1 -0
- package/dist/analyzer/co-change.d.ts +60 -0
- package/dist/analyzer/co-change.d.ts.map +1 -0
- package/dist/analyzer/co-change.js +153 -0
- package/dist/analyzer/co-change.js.map +1 -0
- package/dist/analyzer/conventions.d.ts +22 -0
- package/dist/analyzer/conventions.d.ts.map +1 -0
- package/dist/analyzer/conventions.js +81 -0
- package/dist/analyzer/conventions.js.map +1 -0
- package/dist/analyzer/git-hash.d.ts +11 -0
- package/dist/analyzer/git-hash.d.ts.map +1 -0
- package/dist/analyzer/git-hash.js +25 -0
- package/dist/analyzer/git-hash.js.map +1 -0
- package/dist/analyzer/graph-utils.d.ts +46 -0
- package/dist/analyzer/graph-utils.d.ts.map +1 -0
- package/dist/analyzer/graph-utils.js +145 -0
- package/dist/analyzer/graph-utils.js.map +1 -0
- package/dist/analyzer/index.d.ts +34 -0
- package/dist/analyzer/index.d.ts.map +1 -0
- package/dist/analyzer/index.js +63 -0
- package/dist/analyzer/index.js.map +1 -0
- package/dist/cli/hooks.d.ts +24 -0
- package/dist/cli/hooks.d.ts.map +1 -0
- package/dist/cli/hooks.js +126 -0
- package/dist/cli/hooks.js.map +1 -0
- package/dist/cli/index.d.ts +18 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +818 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/plan-parser.d.ts +20 -0
- package/dist/cli/plan-parser.d.ts.map +1 -0
- package/dist/cli/plan-parser.js +104 -0
- package/dist/cli/plan-parser.js.map +1 -0
- package/dist/cli/shim.d.ts +3 -0
- package/dist/cli/shim.d.ts.map +1 -0
- package/dist/cli/shim.js +33 -0
- package/dist/cli/shim.js.map +1 -0
- package/dist/cli/templates.d.ts +28 -0
- package/dist/cli/templates.d.ts.map +1 -0
- package/dist/cli/templates.js +91 -0
- package/dist/cli/templates.js.map +1 -0
- package/dist/encoder/encode.d.ts +17 -0
- package/dist/encoder/encode.d.ts.map +1 -0
- package/dist/encoder/encode.js +270 -0
- package/dist/encoder/encode.js.map +1 -0
- package/dist/encoder/layer-infrastructure.d.ts +17 -0
- package/dist/encoder/layer-infrastructure.d.ts.map +1 -0
- package/dist/encoder/layer-infrastructure.js +232 -0
- package/dist/encoder/layer-infrastructure.js.map +1 -0
- package/dist/encoder/layer-labels.d.ts +18 -0
- package/dist/encoder/layer-labels.d.ts.map +1 -0
- package/dist/encoder/layer-labels.js +172 -0
- package/dist/encoder/layer-labels.js.map +1 -0
- package/dist/encoder/layer-terrain.d.ts +18 -0
- package/dist/encoder/layer-terrain.d.ts.map +1 -0
- package/dist/encoder/layer-terrain.js +135 -0
- package/dist/encoder/layer-terrain.js.map +1 -0
- package/dist/encoder/layout.d.ts +53 -0
- package/dist/encoder/layout.d.ts.map +1 -0
- package/dist/encoder/layout.js +178 -0
- package/dist/encoder/layout.js.map +1 -0
- package/dist/encoder/parse-strand-header.d.ts +29 -0
- package/dist/encoder/parse-strand-header.d.ts.map +1 -0
- package/dist/encoder/parse-strand-header.js +59 -0
- package/dist/encoder/parse-strand-header.js.map +1 -0
- package/dist/encoder/spatial-text-encode.d.ts +22 -0
- package/dist/encoder/spatial-text-encode.d.ts.map +1 -0
- package/dist/encoder/spatial-text-encode.js +199 -0
- package/dist/encoder/spatial-text-encode.js.map +1 -0
- package/dist/encoder/strand-format-encode-v1.d.ts +16 -0
- package/dist/encoder/strand-format-encode-v1.d.ts.map +1 -0
- package/dist/encoder/strand-format-encode-v1.js +296 -0
- package/dist/encoder/strand-format-encode-v1.js.map +1 -0
- package/dist/encoder/strand-format-encode.d.ts +21 -0
- package/dist/encoder/strand-format-encode.d.ts.map +1 -0
- package/dist/encoder/strand-format-encode.js +562 -0
- package/dist/encoder/strand-format-encode.js.map +1 -0
- package/dist/encoder/text-encode.d.ts +13 -0
- package/dist/encoder/text-encode.d.ts.map +1 -0
- package/dist/encoder/text-encode.js +123 -0
- package/dist/encoder/text-encode.js.map +1 -0
- package/dist/query/blast-radius.d.ts +14 -0
- package/dist/query/blast-radius.d.ts.map +1 -0
- package/dist/query/blast-radius.js +81 -0
- package/dist/query/blast-radius.js.map +1 -0
- package/dist/query/cache.d.ts +29 -0
- package/dist/query/cache.d.ts.map +1 -0
- package/dist/query/cache.js +138 -0
- package/dist/query/cache.js.map +1 -0
- package/dist/query/index.d.ts +2 -0
- package/dist/query/index.d.ts.map +1 -0
- package/dist/query/index.js +46 -0
- package/dist/query/index.js.map +1 -0
- package/dist/query/resolve.d.ts +7 -0
- package/dist/query/resolve.d.ts.map +1 -0
- package/dist/query/resolve.js +24 -0
- package/dist/query/resolve.js.map +1 -0
- package/dist/query/risk-profile.d.ts +30 -0
- package/dist/query/risk-profile.d.ts.map +1 -0
- package/dist/query/risk-profile.js +94 -0
- package/dist/query/risk-profile.js.map +1 -0
- package/dist/query/test-map.d.ts +13 -0
- package/dist/query/test-map.d.ts.map +1 -0
- package/dist/query/test-map.js +43 -0
- package/dist/query/test-map.js.map +1 -0
- package/dist/scanner/index.d.ts +51 -0
- package/dist/scanner/index.d.ts.map +1 -0
- package/dist/scanner/index.js +480 -0
- package/dist/scanner/index.js.map +1 -0
- package/dist/scanner/workspace.d.ts +11 -0
- package/dist/scanner/workspace.d.ts.map +1 -0
- package/dist/scanner/workspace.js +243 -0
- package/dist/scanner/workspace.js.map +1 -0
- package/package.json +52 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { queryTestMap } from "./test-map.js";
|
|
2
|
+
export function queryRiskProfile(fileId, cache) {
|
|
3
|
+
// Blast radius
|
|
4
|
+
const blastResult = cache.analysis.risk.find(r => r.nodeId === fileId);
|
|
5
|
+
const risk = blastResult
|
|
6
|
+
? {
|
|
7
|
+
directImporters: blastResult.directImporters,
|
|
8
|
+
affectedCount: blastResult.affectedCount,
|
|
9
|
+
cascadeDepth: blastResult.maxDepth,
|
|
10
|
+
amplificationRatio: blastResult.amplificationRatio,
|
|
11
|
+
modulesAffected: blastResult.modulesAffected,
|
|
12
|
+
affectedModules: blastResult.affectedModuleNames,
|
|
13
|
+
}
|
|
14
|
+
: null;
|
|
15
|
+
// Churn
|
|
16
|
+
const churnResult = cache.analysis.churn.get(fileId);
|
|
17
|
+
const churn = churnResult
|
|
18
|
+
? {
|
|
19
|
+
commits30d: churnResult.commits30d,
|
|
20
|
+
linesAdded: churnResult.linesAdded30d,
|
|
21
|
+
linesRemoved: churnResult.linesRemoved30d,
|
|
22
|
+
lastCommitMsg: churnResult.lastCommitMsg,
|
|
23
|
+
}
|
|
24
|
+
: null;
|
|
25
|
+
// Co-change partners
|
|
26
|
+
const coChangePartners = cache.analysis.coChanges
|
|
27
|
+
.filter(cc => cc.fileA === fileId || cc.fileB === fileId)
|
|
28
|
+
.map(cc => ({
|
|
29
|
+
file: cc.fileA === fileId ? cc.fileB : cc.fileA,
|
|
30
|
+
count: cc.coChangeCount,
|
|
31
|
+
confidence: cc.confidence,
|
|
32
|
+
linked: cc.importConnected,
|
|
33
|
+
}));
|
|
34
|
+
// Tests (reuses test_map algorithm)
|
|
35
|
+
const tests = queryTestMap(fileId, cache);
|
|
36
|
+
// Convention violations
|
|
37
|
+
const conventionViolations = [];
|
|
38
|
+
for (const conv of cache.analysis.conventions) {
|
|
39
|
+
if (conv.violators.includes(fileId)) {
|
|
40
|
+
conventionViolations.push(`${conv.anchorFile}:${conv.anchorExports.join(",")} \u2014 ${conv.consumerType} (${Math.round(conv.coverage * 100)}% adoption)`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return { file: fileId, risk, churn, coChangePartners, tests, conventionViolations };
|
|
44
|
+
}
|
|
45
|
+
export function formatRiskProfile(result, json) {
|
|
46
|
+
if (json)
|
|
47
|
+
return JSON.stringify(result, null, 2);
|
|
48
|
+
const lines = [result.file];
|
|
49
|
+
// Risk
|
|
50
|
+
if (result.risk) {
|
|
51
|
+
lines.push(`risk: \u00D7${result.risk.directImporters}\u2192${result.risk.affectedCount} d${result.risk.cascadeDepth} amp${result.risk.amplificationRatio} ${result.risk.modulesAffected}mod`);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
lines.push("risk: (none)");
|
|
55
|
+
}
|
|
56
|
+
// Churn
|
|
57
|
+
if (result.churn) {
|
|
58
|
+
lines.push(`churn: ${result.churn.commits30d} commits/30d +${result.churn.linesAdded} -${result.churn.linesRemoved} last: "${result.churn.lastCommitMsg}"`);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
lines.push("churn: (none)");
|
|
62
|
+
}
|
|
63
|
+
// Co-change
|
|
64
|
+
if (result.coChangePartners.length > 0) {
|
|
65
|
+
const parts = result.coChangePartners.map(p => `${p.file} (${p.count}\u00D7, ${Math.round(p.confidence * 100)}% confidence${p.linked ? ", linked" : ""})`);
|
|
66
|
+
lines.push(`co-change: ${parts.join("; ")}`);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
lines.push("co-change: (none)");
|
|
70
|
+
}
|
|
71
|
+
// Tests
|
|
72
|
+
if (result.tests.testCount > 0) {
|
|
73
|
+
const testParts = [];
|
|
74
|
+
for (const t of result.tests.directTests) {
|
|
75
|
+
testParts.push(`${t} (direct)`);
|
|
76
|
+
}
|
|
77
|
+
for (const t of result.tests.transitiveTests) {
|
|
78
|
+
testParts.push(`${t.test} (transitive)`);
|
|
79
|
+
}
|
|
80
|
+
lines.push(`tests: ${testParts.join(", ")}`);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
lines.push("tests: (none)");
|
|
84
|
+
}
|
|
85
|
+
// Convention violations
|
|
86
|
+
if (result.conventionViolations.length > 0) {
|
|
87
|
+
lines.push(`conventions: ${result.conventionViolations.join("; ")}`);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
lines.push("conventions: no violations");
|
|
91
|
+
}
|
|
92
|
+
return lines.join("\n");
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=risk-profile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"risk-profile.js","sourceRoot":"","sources":["../../src/query/risk-profile.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAsB,MAAM,eAAe,CAAC;AA4BjE,MAAM,UAAU,gBAAgB,CAAC,MAAc,EAAE,KAAiB;IAChE,eAAe;IACf,MAAM,WAAW,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC;IACvE,MAAM,IAAI,GAAG,WAAW;QACtB,CAAC,CAAC;YACE,eAAe,EAAE,WAAW,CAAC,eAAe;YAC5C,aAAa,EAAE,WAAW,CAAC,aAAa;YACxC,YAAY,EAAE,WAAW,CAAC,QAAQ;YAClC,kBAAkB,EAAE,WAAW,CAAC,kBAAkB;YAClD,eAAe,EAAE,WAAW,CAAC,eAAe;YAC5C,eAAe,EAAE,WAAW,CAAC,mBAAmB;SACjD;QACH,CAAC,CAAC,IAAI,CAAC;IAET,QAAQ;IACR,MAAM,WAAW,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACrD,MAAM,KAAK,GAAG,WAAW;QACvB,CAAC,CAAC;YACE,UAAU,EAAE,WAAW,CAAC,UAAU;YAClC,UAAU,EAAE,WAAW,CAAC,aAAa;YACrC,YAAY,EAAE,WAAW,CAAC,eAAe;YACzC,aAAa,EAAE,WAAW,CAAC,aAAa;SACzC;QAC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Tests: string[];
|
|
6
|
+
transitiveTests: Array<{
|
|
7
|
+
test: string;
|
|
8
|
+
via: string;
|
|
9
|
+
}>;
|
|
10
|
+
}
|
|
11
|
+
export declare function queryTestMap(fileId: string, cache: MapraCache): TestMapResult;
|
|
12
|
+
export declare function formatTestMap(result: TestMapResult, json: boolean): string;
|
|
13
|
+
//# sourceMappingURL=test-map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-map.d.ts","sourceRoot":"","sources":["../../src/query/test-map.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,eAAe,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACvD;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,aAAa,CA+B7E;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,OAAO,GAAG,MAAM,CAiB1E"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// src/query/test-map.ts
|
|
2
|
+
import { buildReverseAdjacency, bfsWithParents } from "../analyzer/graph-utils.js";
|
|
3
|
+
export function queryTestMap(fileId, cache) {
|
|
4
|
+
// Build reverse adjacency WITHOUT excluding test edges —
|
|
5
|
+
// the goal is specifically to find test files in the import chain
|
|
6
|
+
const reverseAdj = buildReverseAdjacency(cache.graph.edges, false);
|
|
7
|
+
const { depths, parents } = bfsWithParents(fileId, reverseAdj);
|
|
8
|
+
const testNodeIds = new Set(cache.graph.nodes.filter(n => n.type === "test").map(n => n.id));
|
|
9
|
+
const directTests = [];
|
|
10
|
+
const transitiveTests = [];
|
|
11
|
+
for (const [nodeId, depth] of depths) {
|
|
12
|
+
if (!testNodeIds.has(nodeId))
|
|
13
|
+
continue;
|
|
14
|
+
if (depth === 1) {
|
|
15
|
+
directTests.push(nodeId);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
// Trace one step back from test node to find the "via" intermediate
|
|
19
|
+
const via = parents.get(nodeId) ?? "";
|
|
20
|
+
transitiveTests.push({ test: nodeId, via });
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
file: fileId,
|
|
25
|
+
testCount: directTests.length + transitiveTests.length,
|
|
26
|
+
directTests: directTests.sort(),
|
|
27
|
+
transitiveTests: transitiveTests.sort((a, b) => a.test.localeCompare(b.test)),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export function formatTestMap(result, json) {
|
|
31
|
+
if (json)
|
|
32
|
+
return JSON.stringify(result, null, 2);
|
|
33
|
+
const lines = [];
|
|
34
|
+
lines.push(`${result.file} \u2014 ${result.testCount} test files connected (structural, not runtime coverage)`);
|
|
35
|
+
if (result.directTests.length > 0) {
|
|
36
|
+
lines.push(`direct: ${result.directTests.join(", ")}`);
|
|
37
|
+
}
|
|
38
|
+
for (const t of result.transitiveTests) {
|
|
39
|
+
lines.push(`transitive: ${t.test} (via ${t.via})`);
|
|
40
|
+
}
|
|
41
|
+
return lines.join("\n");
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=test-map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-map.js","sourceRoot":"","sources":["../../src/query/test-map.ts"],"names":[],"mappings":"AAAA,wBAAwB;AACxB,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAUnF,MAAM,UAAU,YAAY,CAAC,MAAc,EAAE,KAAiB;IAC5D,yDAAyD;IACzD,kEAAkE;IAClE,MAAM,UAAU,GAAG,qBAAqB,CAAC,KAAK,CAAC,KAAK,CA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EAAE,IAAa;IAChE,IAAI,IAAI;QAAE,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAEjD,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,CAAC,IAAI,CACR,GAAG,MAAM,CAAC,IAAI,WAAW,MAAM,CAAC,SAAS,0DAA0D,CACpG,CAAC;IAEF,IAAI,MAAM,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAClC,KAAK,CAAC,IAAI,CAAC,WAAW,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACzD,CAAC;IAED,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,eAAe,EAAE,CAAC;QACvC,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,IAAI,SAAS,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC;IACrD,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Strand Scanner — reads a codebase and builds a structural graph
|
|
3
|
+
*
|
|
4
|
+
* Extracts: modules, files, imports, exports, routes, components,
|
|
5
|
+
* framework conventions, and complexity metrics.
|
|
6
|
+
*/
|
|
7
|
+
export interface StrandNode {
|
|
8
|
+
id: string;
|
|
9
|
+
path: string;
|
|
10
|
+
type: "module" | "file" | "route" | "api-route" | "component" | "layout" | "middleware" | "schema" | "test" | "config" | "utility";
|
|
11
|
+
name: string;
|
|
12
|
+
lines: number;
|
|
13
|
+
imports: string[];
|
|
14
|
+
exports: string[];
|
|
15
|
+
framework?: {
|
|
16
|
+
type: string;
|
|
17
|
+
metadata: Record<string, unknown>;
|
|
18
|
+
};
|
|
19
|
+
complexity: number;
|
|
20
|
+
domain?: string;
|
|
21
|
+
children?: string[];
|
|
22
|
+
}
|
|
23
|
+
export interface StrandEdge {
|
|
24
|
+
from: string;
|
|
25
|
+
to: string;
|
|
26
|
+
type: "imports" | "renders" | "calls" | "tests" | "extends";
|
|
27
|
+
weight: number;
|
|
28
|
+
}
|
|
29
|
+
export interface StrandGraph {
|
|
30
|
+
projectName: string;
|
|
31
|
+
projectType: string;
|
|
32
|
+
framework: string;
|
|
33
|
+
totalFiles: number;
|
|
34
|
+
totalLines: number;
|
|
35
|
+
nodes: StrandNode[];
|
|
36
|
+
edges: StrandEdge[];
|
|
37
|
+
modules: ModuleBoundary[];
|
|
38
|
+
}
|
|
39
|
+
export interface ModuleBoundary {
|
|
40
|
+
id: string;
|
|
41
|
+
name: string;
|
|
42
|
+
path: string;
|
|
43
|
+
nodeCount: number;
|
|
44
|
+
totalLines: number;
|
|
45
|
+
entryPoints: string[];
|
|
46
|
+
}
|
|
47
|
+
export declare function scanCodebase(rootDir: string): StrandGraph;
|
|
48
|
+
export declare function detectPathAliases(rootDir: string): Map<string, string>;
|
|
49
|
+
export declare function resolveImportPath(importPath: string, fromPath: string, aliases: Map<string, string>): string | null;
|
|
50
|
+
export declare function findNodeByImport(resolvedPath: string, nodeMap: Map<string, StrandNode>): StrandNode | null;
|
|
51
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/scanner/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EACA,QAAQ,GACR,MAAM,GACN,OAAO,GACP,WAAW,GACX,WAAW,GACX,QAAQ,GACR,YAAY,GACZ,QAAQ,GACR,MAAM,GACN,QAAQ,GACR,SAAS,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM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