@openweave/weave-graph 0.2.0 → 0.2.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.
- package/dist/cjs/compression.d.ts +94 -0
- package/dist/cjs/compression.d.ts.map +1 -0
- package/dist/cjs/compression.js +215 -0
- package/dist/cjs/compression.js.map +1 -0
- package/dist/cjs/edge.d.ts +43 -0
- package/dist/cjs/edge.d.ts.map +1 -0
- package/dist/cjs/edge.js +83 -0
- package/dist/cjs/edge.js.map +1 -0
- package/dist/cjs/hebbian-weights.d.ts +100 -0
- package/dist/cjs/hebbian-weights.d.ts.map +1 -0
- package/dist/cjs/hebbian-weights.js +152 -0
- package/dist/cjs/hebbian-weights.js.map +1 -0
- package/dist/cjs/index.d.ts +193 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +417 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/node.d.ts +43 -0
- package/dist/cjs/node.d.ts.map +1 -0
- package/dist/cjs/node.js +83 -0
- package/dist/cjs/node.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/persistence.d.ts +86 -0
- package/dist/cjs/persistence.d.ts.map +1 -0
- package/dist/cjs/persistence.js +215 -0
- package/dist/cjs/persistence.js.map +1 -0
- package/dist/cjs/synaptic-engine.d.ts +126 -0
- package/dist/cjs/synaptic-engine.d.ts.map +1 -0
- package/dist/cjs/synaptic-engine.js +243 -0
- package/dist/cjs/synaptic-engine.js.map +1 -0
- package/dist/cjs/types.d.ts +74 -0
- package/dist/cjs/types.d.ts.map +1 -0
- package/dist/cjs/types.js +30 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/hebbian-weights.d.ts +100 -0
- package/dist/hebbian-weights.d.ts.map +1 -0
- package/dist/hebbian-weights.js +148 -0
- package/dist/hebbian-weights.js.map +1 -0
- package/dist/index.d.ts +36 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +65 -3
- package/dist/index.js.map +1 -1
- package/dist/persistence.d.ts +43 -15
- package/dist/persistence.d.ts.map +1 -1
- package/dist/persistence.js +109 -119
- package/dist/persistence.js.map +1 -1
- package/dist/synaptic-engine.d.ts +126 -0
- package/dist/synaptic-engine.d.ts.map +1 -0
- package/dist/synaptic-engine.js +236 -0
- package/dist/synaptic-engine.js.map +1 -0
- package/package.json +6 -4
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HebbianWeights = void 0;
|
|
4
|
+
const DEFAULT_HEBBIAN_STRENGTH = 0.1;
|
|
5
|
+
const DEFAULT_DECAY_RATE = 0.99;
|
|
6
|
+
const DEFAULT_PRUNE_THRESHOLD = 0.05;
|
|
7
|
+
const DEFAULT_MAX_WEIGHT = 5.0;
|
|
8
|
+
// ---------------------------------------------------------------------------
|
|
9
|
+
// HebbianWeights
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
/**
|
|
12
|
+
* HebbianWeights — Hebbian learning + temporal decay for graph edges.
|
|
13
|
+
*
|
|
14
|
+
* Models three neuronal behaviours:
|
|
15
|
+
*
|
|
16
|
+
* 1. **Strengthen** (`strengthen`): When two nodes are co-activated (both
|
|
17
|
+
* appear in the same query result), every edge connecting them gains
|
|
18
|
+
* `hebbianStrength` weight — "neurons that fire together, wire together."
|
|
19
|
+
*
|
|
20
|
+
* 2. **Decay** (`decay`): Every edge weight is multiplied by `decayRate`
|
|
21
|
+
* each cycle. Edges not reinforced by co-activation gradually weaken.
|
|
22
|
+
*
|
|
23
|
+
* 3. **Prune** (`prune`): Edges whose weight drops below `pruneThreshold`
|
|
24
|
+
* are deleted, keeping the graph clean and preventing stale connections
|
|
25
|
+
* from accumulating indefinitely.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* const hebb = new HebbianWeights({ hebbianStrength: 0.1, decayRate: 0.99 });
|
|
30
|
+
* graph.setHebbianWeights(hebb);
|
|
31
|
+
*
|
|
32
|
+
* // queryNodesByLabel() auto-strengthens edges between co-activated nodes
|
|
33
|
+
* graph.queryNodesByLabel("TypeScript");
|
|
34
|
+
*
|
|
35
|
+
* // Run decay once per session cycle
|
|
36
|
+
* hebb.decay(graph);
|
|
37
|
+
*
|
|
38
|
+
* // Prune weak edges
|
|
39
|
+
* hebb.prune(graph);
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
class HebbianWeights {
|
|
43
|
+
hebbianStrength;
|
|
44
|
+
decayRate;
|
|
45
|
+
pruneThreshold;
|
|
46
|
+
maxWeight;
|
|
47
|
+
constructor(options = {}) {
|
|
48
|
+
this.hebbianStrength = options.hebbianStrength ?? DEFAULT_HEBBIAN_STRENGTH;
|
|
49
|
+
this.decayRate = options.decayRate ?? DEFAULT_DECAY_RATE;
|
|
50
|
+
this.pruneThreshold = options.pruneThreshold ?? DEFAULT_PRUNE_THRESHOLD;
|
|
51
|
+
this.maxWeight = options.maxWeight ?? DEFAULT_MAX_WEIGHT;
|
|
52
|
+
}
|
|
53
|
+
/** Read-only view of the resolved configuration. */
|
|
54
|
+
get config() {
|
|
55
|
+
return {
|
|
56
|
+
hebbianStrength: this.hebbianStrength,
|
|
57
|
+
decayRate: this.decayRate,
|
|
58
|
+
pruneThreshold: this.pruneThreshold,
|
|
59
|
+
maxWeight: this.maxWeight,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
// ------------------------------------------------------------------
|
|
63
|
+
// strengthen()
|
|
64
|
+
// ------------------------------------------------------------------
|
|
65
|
+
/**
|
|
66
|
+
* Strengthen a single edge by `hebbianStrength`, capped at `maxWeight`.
|
|
67
|
+
*
|
|
68
|
+
* Intended to be called for every edge that connects two nodes that were
|
|
69
|
+
* co-activated (both appeared in the same query result).
|
|
70
|
+
*
|
|
71
|
+
* @returns The updated edge, or `undefined` if the edge was not found.
|
|
72
|
+
*/
|
|
73
|
+
strengthen(edgeId, graph) {
|
|
74
|
+
const edge = graph.getEdge(edgeId);
|
|
75
|
+
if (!edge)
|
|
76
|
+
return undefined;
|
|
77
|
+
const currentWeight = edge.weight ?? 1.0;
|
|
78
|
+
const newWeight = Math.min(currentWeight + this.hebbianStrength, this.maxWeight);
|
|
79
|
+
return graph.updateEdge(edgeId, { weight: newWeight });
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Strengthen all edges that connect pairs of nodes within `nodeIds`.
|
|
83
|
+
*
|
|
84
|
+
* This is the batch form used by `ContextGraphManager` after a query:
|
|
85
|
+
* every edge whose `sourceId` AND `targetId` both appear in the result
|
|
86
|
+
* set gets strengthened once.
|
|
87
|
+
*
|
|
88
|
+
* @returns The list of edge ids that were strengthened.
|
|
89
|
+
*/
|
|
90
|
+
strengthenCoActivated(nodeIds, graph) {
|
|
91
|
+
if (nodeIds.length < 2)
|
|
92
|
+
return [];
|
|
93
|
+
const nodeSet = new Set(nodeIds);
|
|
94
|
+
const strengthened = [];
|
|
95
|
+
for (const edge of graph.getAllEdges()) {
|
|
96
|
+
if (nodeSet.has(edge.sourceId) && nodeSet.has(edge.targetId)) {
|
|
97
|
+
this.strengthen(edge.id, graph);
|
|
98
|
+
strengthened.push(edge.id);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return strengthened;
|
|
102
|
+
}
|
|
103
|
+
// ------------------------------------------------------------------
|
|
104
|
+
// decay()
|
|
105
|
+
// ------------------------------------------------------------------
|
|
106
|
+
/**
|
|
107
|
+
* Apply temporal decay to every edge in the graph.
|
|
108
|
+
*
|
|
109
|
+
* Each edge weight is multiplied by `decayRate` (< 1.0).
|
|
110
|
+
* Edges reinforced by recent co-activation decay slower relative
|
|
111
|
+
* to their higher baseline weight.
|
|
112
|
+
*
|
|
113
|
+
* @returns The number of edges decayed.
|
|
114
|
+
*/
|
|
115
|
+
decay(graph) {
|
|
116
|
+
const allEdges = graph.getAllEdges();
|
|
117
|
+
let count = 0;
|
|
118
|
+
for (const edge of allEdges) {
|
|
119
|
+
const current = edge.weight ?? 1.0;
|
|
120
|
+
const decayed = current * this.decayRate;
|
|
121
|
+
graph.updateEdge(edge.id, { weight: decayed });
|
|
122
|
+
count++;
|
|
123
|
+
}
|
|
124
|
+
return count;
|
|
125
|
+
}
|
|
126
|
+
// ------------------------------------------------------------------
|
|
127
|
+
// prune()
|
|
128
|
+
// ------------------------------------------------------------------
|
|
129
|
+
/**
|
|
130
|
+
* Delete all edges whose weight has fallen below `pruneThreshold`.
|
|
131
|
+
*
|
|
132
|
+
* Can be called after `decay()` to clean up stale connections.
|
|
133
|
+
*
|
|
134
|
+
* @param minWeight Override the instance's `pruneThreshold` for this call.
|
|
135
|
+
* @returns The number of edges deleted.
|
|
136
|
+
*/
|
|
137
|
+
prune(graph, minWeight) {
|
|
138
|
+
const threshold = minWeight ?? this.pruneThreshold;
|
|
139
|
+
const toDelete = [];
|
|
140
|
+
for (const edge of graph.getAllEdges()) {
|
|
141
|
+
if ((edge.weight ?? 1.0) < threshold) {
|
|
142
|
+
toDelete.push(edge.id);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
for (const id of toDelete) {
|
|
146
|
+
graph.deleteEdge(id);
|
|
147
|
+
}
|
|
148
|
+
return toDelete.length;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
exports.HebbianWeights = HebbianWeights;
|
|
152
|
+
//# sourceMappingURL=hebbian-weights.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hebbian-weights.js","sourceRoot":"","sources":["../../src/hebbian-weights.ts"],"names":[],"mappings":";;;AAiBA,MAAM,wBAAwB,GAAG,GAAG,CAAC;AACrC,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAChC,MAAM,uBAAuB,GAAG,IAAI,CAAC;AACrC,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAiB/B,8EAA8E;AAC9E,iBAAiB;AACjB,8EAA8E;AAE9E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8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C,WAAW,EAAE,EAAE,CAAC;YACvC,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,GAAG,CAAC,GAAG,SAAS,EAAE,CAAC;gBACrC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACzB,CAAC;QACH,CAAC;QAED,KAAK,MAAM,EAAE,IAAI,QAAQ,EAAE,CAAC;YAC1B,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;QACvB,CAAC;QAED,OAAO,QAAQ,CAAC,MAAM,CAAC;IACzB,CAAC;CACF;AA7HD,wCA6HC"}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { Node, Edge, NodeType, EdgeType, GraphSnapshot } from "./types";
|
|
2
|
+
import { SynapticEngine } from "./synaptic-engine";
|
|
3
|
+
import { HebbianWeights } from "./hebbian-weights";
|
|
4
|
+
/**
|
|
5
|
+
* ContextGraphManager
|
|
6
|
+
* Main interface for managing the WeaveGraph
|
|
7
|
+
* Handles node/edge operations, queries, and persistence metadata
|
|
8
|
+
*/
|
|
9
|
+
export declare class ContextGraphManager {
|
|
10
|
+
private nodes;
|
|
11
|
+
private edges;
|
|
12
|
+
private edgesBySource;
|
|
13
|
+
private edgesByTarget;
|
|
14
|
+
private nodesByLabel;
|
|
15
|
+
private chatId;
|
|
16
|
+
private compressionThreshold;
|
|
17
|
+
private version;
|
|
18
|
+
private createdAt;
|
|
19
|
+
private updatedAt;
|
|
20
|
+
private synapticEngine?;
|
|
21
|
+
private hebbianWeights?;
|
|
22
|
+
constructor(chatId: string, compressionThreshold?: number);
|
|
23
|
+
/**
|
|
24
|
+
* Attach a SynapticEngine to this graph. Once set, every subsequent
|
|
25
|
+
* `addNode()` call will automatically trigger retroactive linking.
|
|
26
|
+
*/
|
|
27
|
+
setSynapticEngine(engine: SynapticEngine): void;
|
|
28
|
+
/**
|
|
29
|
+
* Attach a HebbianWeights instance to this graph. Once set,
|
|
30
|
+
* `queryNodesByLabel()` and `queryNodesByType()` will automatically
|
|
31
|
+
* strengthen edges between co-activated result nodes.
|
|
32
|
+
*/
|
|
33
|
+
setHebbianWeights(hw: HebbianWeights): void;
|
|
34
|
+
/**
|
|
35
|
+
* Add a node to the graph.
|
|
36
|
+
* If a SynapticEngine is attached, retroactive linking is performed
|
|
37
|
+
* immediately after the node is indexed.
|
|
38
|
+
*/
|
|
39
|
+
addNode(node: Node): Node;
|
|
40
|
+
/**
|
|
41
|
+
* Add a node to the graph and run embedding-based retroactive linking
|
|
42
|
+
* (async). If the attached SynapticEngine has an `embeddingService`,
|
|
43
|
+
* cosine similarity is used instead of Jaccard keyword overlap.
|
|
44
|
+
*
|
|
45
|
+
* If no SynapticEngine is attached, behaves identically to `addNode()`.
|
|
46
|
+
* If a SynapticEngine is attached but has no embedding service, the
|
|
47
|
+
* keyword-based path runs (same as `addNode()`).
|
|
48
|
+
*
|
|
49
|
+
* @returns The added node.
|
|
50
|
+
*/
|
|
51
|
+
addNodeAsync(node: Node): Promise<Node>;
|
|
52
|
+
/**
|
|
53
|
+
* Get a node by ID
|
|
54
|
+
*/
|
|
55
|
+
getNode(nodeId: string): Node | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Update an existing node
|
|
58
|
+
*/
|
|
59
|
+
updateNode(nodeId: string, updates: Partial<Node>): Node | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* Delete a node (and all related edges)
|
|
62
|
+
*/
|
|
63
|
+
deleteNode(nodeId: string): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Add an edge to the graph
|
|
66
|
+
*/
|
|
67
|
+
addEdge(edge: Edge): Edge;
|
|
68
|
+
/**
|
|
69
|
+
* Get an edge by ID
|
|
70
|
+
*/
|
|
71
|
+
getEdge(edgeId: string): Edge | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* Update an existing edge
|
|
74
|
+
*/
|
|
75
|
+
updateEdge(edgeId: string, updates: Partial<Edge>): Edge | undefined;
|
|
76
|
+
/**
|
|
77
|
+
* Delete an edge
|
|
78
|
+
*/
|
|
79
|
+
deleteEdge(edgeId: string): boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Get all edges from a source node
|
|
82
|
+
*/
|
|
83
|
+
getEdgesFromNode(nodeId: string): Edge[];
|
|
84
|
+
/**
|
|
85
|
+
* Get all edges to a target node
|
|
86
|
+
*/
|
|
87
|
+
getEdgesToNode(nodeId: string): Edge[];
|
|
88
|
+
/**
|
|
89
|
+
* Query nodes by label (keyword search)
|
|
90
|
+
* Returns nodes where the label contains the query string
|
|
91
|
+
*/
|
|
92
|
+
queryNodesByLabel(query: string): Node[];
|
|
93
|
+
/**
|
|
94
|
+
* Query nodes by type
|
|
95
|
+
*/
|
|
96
|
+
queryNodesByType(type: NodeType): Node[];
|
|
97
|
+
/**
|
|
98
|
+
* Query edges by type
|
|
99
|
+
*/
|
|
100
|
+
queryEdgesByType(type: EdgeType): Edge[];
|
|
101
|
+
/**
|
|
102
|
+
* Get graph statistics
|
|
103
|
+
*/
|
|
104
|
+
getStats(): {
|
|
105
|
+
totalNodes: number;
|
|
106
|
+
totalEdges: number;
|
|
107
|
+
nodesByType: {
|
|
108
|
+
[k: string]: number;
|
|
109
|
+
};
|
|
110
|
+
edgesByType: {
|
|
111
|
+
[k: string]: number;
|
|
112
|
+
};
|
|
113
|
+
chatId: string;
|
|
114
|
+
createdAt: Date;
|
|
115
|
+
updatedAt: Date;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Snapshot the graph for serialization
|
|
119
|
+
*/
|
|
120
|
+
snapshot(): GraphSnapshot;
|
|
121
|
+
/**
|
|
122
|
+
* Restore graph from snapshot
|
|
123
|
+
*/
|
|
124
|
+
static fromSnapshot(snapshot: GraphSnapshot): ContextGraphManager;
|
|
125
|
+
/**
|
|
126
|
+
* Get the current window size percentage
|
|
127
|
+
* Calculates actual context window usage based on node and edge sizes
|
|
128
|
+
*/
|
|
129
|
+
getContextWindowUsage(): number;
|
|
130
|
+
/**
|
|
131
|
+
* Get estimated context size in bytes
|
|
132
|
+
*/
|
|
133
|
+
getContextSize(): number;
|
|
134
|
+
/**
|
|
135
|
+
* Check if compression threshold has been reached
|
|
136
|
+
*/
|
|
137
|
+
shouldCompress(): boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Compress the graph by archiving low-frequency nodes
|
|
140
|
+
* Returns compression statistics
|
|
141
|
+
*/
|
|
142
|
+
compress(targetReductionPercentage?: number): {
|
|
143
|
+
archivedNodeCount: number;
|
|
144
|
+
archiveStats: {
|
|
145
|
+
archivedNodeCount: number;
|
|
146
|
+
archivedEdgeCount: number;
|
|
147
|
+
};
|
|
148
|
+
newContextSize: number;
|
|
149
|
+
contextUsagePercentage: number;
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* Suppress an error node and create a correction
|
|
153
|
+
*/
|
|
154
|
+
suppressError(errorNodeId: string, correctionLabel: string, correctionDescription?: string): {
|
|
155
|
+
correctionNode: Node;
|
|
156
|
+
correctionEdge: Edge;
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* Get all error nodes that have been corrected
|
|
160
|
+
*/
|
|
161
|
+
getCorrectedErrors(): Map<string, {
|
|
162
|
+
error: Node;
|
|
163
|
+
corrections: Node[];
|
|
164
|
+
}>;
|
|
165
|
+
/**
|
|
166
|
+
* Get all error nodes that haven't been corrected yet
|
|
167
|
+
*/
|
|
168
|
+
getUncorrectedErrors(): Node[];
|
|
169
|
+
/**
|
|
170
|
+
* Get all nodes
|
|
171
|
+
*/
|
|
172
|
+
getAllNodes(): Node[];
|
|
173
|
+
/**
|
|
174
|
+
* Get all edges
|
|
175
|
+
*/
|
|
176
|
+
getAllEdges(): Edge[];
|
|
177
|
+
/**
|
|
178
|
+
* Clear the entire graph
|
|
179
|
+
*/
|
|
180
|
+
clear(): void;
|
|
181
|
+
}
|
|
182
|
+
export type { Node, Edge, GraphSnapshot, QueryResult } from "./types";
|
|
183
|
+
export { NodeType, EdgeType } from "./types";
|
|
184
|
+
export { PersistenceManager } from "./persistence";
|
|
185
|
+
export { NodeBuilder } from "./node";
|
|
186
|
+
export { EdgeBuilder } from "./edge";
|
|
187
|
+
export { CompressionManager, ErrorSuppression } from "./compression";
|
|
188
|
+
export type { CompressionStats } from "./compression";
|
|
189
|
+
export { SynapticEngine, tokenize, jaccardSimilarity, cosineSimilarity } from "./synaptic-engine";
|
|
190
|
+
export type { SynapticOptions, SynapticGraph, SynapticEmbeddingService } from "./synaptic-engine";
|
|
191
|
+
export { HebbianWeights } from "./hebbian-weights";
|
|
192
|
+
export type { HebbianOptions, HebbianGraph } from "./hebbian-weights";
|
|
193
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAIxE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD;;;;GAIG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,KAAK,CAAoB;IACjC,OAAO,CAAC,KAAK,CAAoB;IACjC,OAAO,CAAC,aAAa,CAA2B;IAChD,OAAO,CAAC,aAAa,CAA2B;IAChD,OAAO,CAAC,YAAY,CAA2B;IAC/C,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,oBAAoB,CAAgB;IAC5C,OAAO,CAAC,OAAO,CAAmB;IAClC,OAAO,CAAC,SAAS,CAAO;IACxB,OAAO,CAAC,SAAS,CAAO;IACxB,OAAO,CAAC,cAAc,CAAC,CAAiB;IACxC,OAAO,CAAC,cAAc,CAAC,CAAiB;gBAE5B,MAAM,EAAE,MAAM,EAAE,oBAAoB,CAAC,EAAE,MAAM;IAczD;;;OAGG;IACH,iBAAiB,CAAC,MAAM,EAAE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