@nahisaho/musubix-codegraph 2.3.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.
Files changed (66) hide show
  1. package/README.md +187 -0
  2. package/dist/codegraph.d.ts +218 -0
  3. package/dist/codegraph.d.ts.map +1 -0
  4. package/dist/codegraph.js +429 -0
  5. package/dist/codegraph.js.map +1 -0
  6. package/dist/events/event-emitter.d.ts +93 -0
  7. package/dist/events/event-emitter.d.ts.map +1 -0
  8. package/dist/events/event-emitter.js +152 -0
  9. package/dist/events/event-emitter.js.map +1 -0
  10. package/dist/events/index.d.ts +8 -0
  11. package/dist/events/index.d.ts.map +1 -0
  12. package/dist/events/index.js +8 -0
  13. package/dist/events/index.js.map +1 -0
  14. package/dist/graph/graph-engine.d.ts +97 -0
  15. package/dist/graph/graph-engine.d.ts.map +1 -0
  16. package/dist/graph/graph-engine.js +341 -0
  17. package/dist/graph/graph-engine.js.map +1 -0
  18. package/dist/graph/index.d.ts +8 -0
  19. package/dist/graph/index.d.ts.map +1 -0
  20. package/dist/graph/index.js +8 -0
  21. package/dist/graph/index.js.map +1 -0
  22. package/dist/graphrag/graphrag-search.d.ts +67 -0
  23. package/dist/graphrag/graphrag-search.d.ts.map +1 -0
  24. package/dist/graphrag/graphrag-search.js +297 -0
  25. package/dist/graphrag/graphrag-search.js.map +1 -0
  26. package/dist/graphrag/index.d.ts +8 -0
  27. package/dist/graphrag/index.d.ts.map +1 -0
  28. package/dist/graphrag/index.js +8 -0
  29. package/dist/graphrag/index.js.map +1 -0
  30. package/dist/index.d.ts +18 -0
  31. package/dist/index.d.ts.map +1 -0
  32. package/dist/index.js +20 -0
  33. package/dist/index.js.map +1 -0
  34. package/dist/indexer/index.d.ts +8 -0
  35. package/dist/indexer/index.d.ts.map +1 -0
  36. package/dist/indexer/index.js +8 -0
  37. package/dist/indexer/index.js.map +1 -0
  38. package/dist/indexer/indexer.d.ts +58 -0
  39. package/dist/indexer/indexer.d.ts.map +1 -0
  40. package/dist/indexer/indexer.js +206 -0
  41. package/dist/indexer/indexer.js.map +1 -0
  42. package/dist/parser/ast-parser.d.ts +79 -0
  43. package/dist/parser/ast-parser.d.ts.map +1 -0
  44. package/dist/parser/ast-parser.js +489 -0
  45. package/dist/parser/ast-parser.js.map +1 -0
  46. package/dist/parser/index.d.ts +8 -0
  47. package/dist/parser/index.d.ts.map +1 -0
  48. package/dist/parser/index.js +8 -0
  49. package/dist/parser/index.js.map +1 -0
  50. package/dist/storage/index.d.ts +9 -0
  51. package/dist/storage/index.d.ts.map +1 -0
  52. package/dist/storage/index.js +10 -0
  53. package/dist/storage/index.js.map +1 -0
  54. package/dist/storage/memory-storage.d.ts +102 -0
  55. package/dist/storage/memory-storage.d.ts.map +1 -0
  56. package/dist/storage/memory-storage.js +263 -0
  57. package/dist/storage/memory-storage.js.map +1 -0
  58. package/dist/storage/sqlite-storage.d.ts +90 -0
  59. package/dist/storage/sqlite-storage.d.ts.map +1 -0
  60. package/dist/storage/sqlite-storage.js +344 -0
  61. package/dist/storage/sqlite-storage.js.map +1 -0
  62. package/dist/types.d.ts +539 -0
  63. package/dist/types.d.ts.map +1 -0
  64. package/dist/types.js +99 -0
  65. package/dist/types.js.map +1 -0
  66. package/package.json +85 -0
@@ -0,0 +1,297 @@
1
+ /**
2
+ * @nahisaho/musubix-codegraph - GraphRAG Search
3
+ *
4
+ * Graph-based retrieval augmented generation search
5
+ *
6
+ * @see REQ-CG-RAG-001 - Community detection
7
+ * @see REQ-CG-RAG-002 - Global search
8
+ * @see REQ-CG-RAG-003 - Local search
9
+ * @see DES-CG-005
10
+ * @see TSK-CG-040
11
+ */
12
+ /**
13
+ * GraphRAG Search Engine
14
+ *
15
+ * Implements Microsoft's GraphRAG approach for code understanding:
16
+ * - Community detection via Leiden algorithm
17
+ * - Hierarchical summaries for global queries
18
+ * - Local context retrieval for specific queries
19
+ */
20
+ export class GraphRAGSearch {
21
+ graph;
22
+ _options;
23
+ communities = [];
24
+ entityCommunityMap = new Map();
25
+ constructor(graph, options = {}) {
26
+ this.graph = graph;
27
+ this._options = {
28
+ communityAlgorithm: options.communityAlgorithm ?? 'louvain',
29
+ minCommunitySize: options.minCommunitySize ?? 3,
30
+ };
31
+ }
32
+ /**
33
+ * Get current options
34
+ */
35
+ getOptions() {
36
+ return this._options;
37
+ }
38
+ // =========================================================================
39
+ // Community Detection
40
+ // =========================================================================
41
+ /**
42
+ * Detect communities in the code graph
43
+ *
44
+ * Uses a simplified Leiden-inspired algorithm for code communities
45
+ */
46
+ async detectCommunities() {
47
+ const result = await this.graph.query({});
48
+ const entities = result.entities;
49
+ const relations = result.relations;
50
+ // Build adjacency map
51
+ const adjacency = new Map();
52
+ for (const entity of entities) {
53
+ adjacency.set(entity.id, new Set());
54
+ }
55
+ for (const relation of relations) {
56
+ adjacency.get(relation.sourceId)?.add(relation.targetId);
57
+ adjacency.get(relation.targetId)?.add(relation.sourceId);
58
+ }
59
+ // Simple community detection: group by file/module
60
+ const fileGroups = new Map();
61
+ for (const entity of entities) {
62
+ if (entity.type === 'file')
63
+ continue;
64
+ const filePath = entity.filePath ?? 'unknown';
65
+ if (!fileGroups.has(filePath)) {
66
+ fileGroups.set(filePath, []);
67
+ }
68
+ fileGroups.get(filePath).push(entity);
69
+ }
70
+ // Create communities from file groups
71
+ this.communities = [];
72
+ let communityId = 0;
73
+ for (const [filePath, members] of fileGroups) {
74
+ if (members.length === 0)
75
+ continue;
76
+ const community = {
77
+ id: `community-${communityId++}`,
78
+ name: filePath.split('/').pop() ?? filePath,
79
+ memberCount: members.length,
80
+ keyEntities: members.slice(0, 5).map(e => e.id),
81
+ };
82
+ this.communities.push(community);
83
+ // Map entities to communities
84
+ for (const member of members) {
85
+ this.entityCommunityMap.set(member.id, community.id);
86
+ }
87
+ }
88
+ // Create hierarchical communities (level 2: by directory)
89
+ const dirGroups = new Map();
90
+ for (const community of this.communities) {
91
+ const parts = community.name.split('/');
92
+ const dir = parts.slice(0, -1).join('/') || 'root';
93
+ if (!dirGroups.has(dir)) {
94
+ dirGroups.set(dir, []);
95
+ }
96
+ dirGroups.get(dir).push(community);
97
+ }
98
+ // Create parent communities
99
+ for (const [dir, children] of dirGroups) {
100
+ if (children.length <= 1)
101
+ continue;
102
+ const parentCommunity = {
103
+ id: `community-${communityId++}`,
104
+ name: dir,
105
+ memberCount: children.reduce((sum, c) => sum + c.memberCount, 0),
106
+ keyEntities: children.flatMap(c => c.keyEntities).slice(0, 10),
107
+ };
108
+ this.communities.push(parentCommunity);
109
+ // Update children to reference parent
110
+ for (const child of children) {
111
+ child.parentId = parentCommunity.id;
112
+ }
113
+ }
114
+ return this.communities;
115
+ }
116
+ /**
117
+ * Generate community summary
118
+ */
119
+ async generateCommunitySummary(communityId) {
120
+ const community = this.communities.find(c => c.id === communityId);
121
+ if (!community) {
122
+ return 'Community not found';
123
+ }
124
+ // Get entities in this community
125
+ const entityIds = Array.from(this.entityCommunityMap.entries())
126
+ .filter(([_, cid]) => cid === communityId)
127
+ .map(([eid, _]) => eid);
128
+ // Build summary from entity names and types
129
+ const entityDetails = [];
130
+ for (const entityId of entityIds.slice(0, 20)) {
131
+ const entity = await this.graph.getEntity(entityId);
132
+ if (entity) {
133
+ entityDetails.push(`${entity.type}: ${entity.name}`);
134
+ }
135
+ }
136
+ const summary = `Community "${community.name}" contains ${community.memberCount} entities:\n${entityDetails.join('\n')}`;
137
+ // Cache summary
138
+ community.summary = summary;
139
+ return summary;
140
+ }
141
+ // =========================================================================
142
+ // Search Operations
143
+ // =========================================================================
144
+ /**
145
+ * Global search across all communities
146
+ *
147
+ * Searches community summaries for high-level understanding
148
+ */
149
+ async globalSearch(query, options) {
150
+ const limit = options?.limit ?? 10;
151
+ const minScore = options?.minScore ?? 0.1;
152
+ const results = [];
153
+ // Ensure communities are detected
154
+ if (this.communities.length === 0) {
155
+ await this.detectCommunities();
156
+ }
157
+ // Search in community summaries
158
+ const queryLower = query.toLowerCase();
159
+ const queryTerms = queryLower.split(/\s+/);
160
+ for (const community of this.communities) {
161
+ // Generate summary if not cached
162
+ if (!community.summary && options?.includeSummaries) {
163
+ await this.generateCommunitySummary(community.id);
164
+ }
165
+ // Calculate relevance score
166
+ let score = 0;
167
+ const searchText = `${community.name} ${community.summary ?? ''}`.toLowerCase();
168
+ for (const term of queryTerms) {
169
+ if (searchText.includes(term)) {
170
+ score += 0.3;
171
+ }
172
+ }
173
+ // Boost score based on community size
174
+ score += Math.min(community.memberCount / 100, 0.2);
175
+ if (score >= minScore) {
176
+ // Get representative entity from community
177
+ const entityId = community.keyEntities[0];
178
+ if (entityId) {
179
+ const entity = await this.graph.getEntity(entityId);
180
+ if (entity) {
181
+ results.push({
182
+ entity,
183
+ score: Math.min(score, 1),
184
+ context: community.summary ?? community.name,
185
+ community,
186
+ });
187
+ }
188
+ }
189
+ }
190
+ }
191
+ // Sort by score and limit
192
+ results.sort((a, b) => b.score - a.score);
193
+ return results.slice(0, limit);
194
+ }
195
+ /**
196
+ * Local search in entity neighborhood
197
+ *
198
+ * Searches within a specific entity's local context
199
+ */
200
+ async localSearch(entityName, options) {
201
+ const radius = options?.radius ?? 2;
202
+ const limit = options?.limit ?? 10;
203
+ const results = [];
204
+ // Find the starting entity
205
+ const startEntity = await this.graph.findByName(entityName);
206
+ if (!startEntity) {
207
+ return [];
208
+ }
209
+ // Get neighbors within radius
210
+ const visited = new Set();
211
+ const neighbors = [];
212
+ await this.collectNeighbors(startEntity.id, radius, visited, neighbors);
213
+ // Score neighbors based on proximity and relation type
214
+ const entityDepthMap = new Map();
215
+ entityDepthMap.set(startEntity.id, 0);
216
+ // BFS to determine depths
217
+ const queue = [[startEntity.id, 0]];
218
+ const bfsVisited = new Set();
219
+ while (queue.length > 0) {
220
+ const [entityId, depth] = queue.shift();
221
+ if (bfsVisited.has(entityId) || depth > radius)
222
+ continue;
223
+ bfsVisited.add(entityId);
224
+ const entity = neighbors.find(e => e.id === entityId);
225
+ if (entity) {
226
+ entityDepthMap.set(entityId, depth);
227
+ }
228
+ // Get connected entities
229
+ const deps = await this.graph.findDependencies(entityId, 1);
230
+ for (const dep of deps) {
231
+ if (!bfsVisited.has(dep.id)) {
232
+ queue.push([dep.id, depth + 1]);
233
+ }
234
+ }
235
+ }
236
+ // Build results
237
+ for (const entity of neighbors) {
238
+ if (entity.id === startEntity.id)
239
+ continue;
240
+ const depth = entityDepthMap.get(entity.id) ?? radius;
241
+ const score = 1 - (depth / (radius + 1));
242
+ // Get community context if requested
243
+ let community;
244
+ if (options?.includeCommunity) {
245
+ const communityId = this.entityCommunityMap.get(entity.id);
246
+ if (communityId) {
247
+ community = this.communities.find(c => c.id === communityId);
248
+ }
249
+ }
250
+ results.push({
251
+ entity,
252
+ score,
253
+ context: `${entity.type}: ${entity.name}`,
254
+ community,
255
+ });
256
+ }
257
+ // Sort by score and limit
258
+ results.sort((a, b) => b.score - a.score);
259
+ return results.slice(0, limit);
260
+ }
261
+ /**
262
+ * Collect neighbors within radius
263
+ */
264
+ async collectNeighbors(entityId, radius, visited, neighbors) {
265
+ if (radius < 0 || visited.has(entityId))
266
+ return;
267
+ visited.add(entityId);
268
+ const entity = await this.graph.getEntity(entityId);
269
+ if (entity) {
270
+ neighbors.push(entity);
271
+ }
272
+ // Get connected entities
273
+ const deps = await this.graph.findDependencies(entityId, 1);
274
+ for (const dep of deps) {
275
+ await this.collectNeighbors(dep.id, radius - 1, visited, neighbors);
276
+ }
277
+ }
278
+ // =========================================================================
279
+ // Getters
280
+ // =========================================================================
281
+ /**
282
+ * Get all communities
283
+ */
284
+ getCommunities() {
285
+ return [...this.communities];
286
+ }
287
+ /**
288
+ * Get community for entity
289
+ */
290
+ getCommunityForEntity(entityId) {
291
+ const communityId = this.entityCommunityMap.get(entityId);
292
+ if (!communityId)
293
+ return undefined;
294
+ return this.communities.find(c => c.id === communityId);
295
+ }
296
+ }
297
+ //# sourceMappingURL=graphrag-search.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graphrag-search.js","sourceRoot":"","sources":["../../src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export { GraphRAGSearch } from './graphrag-search.js';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/graphrag/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @nahisaho/musubix-codegraph - GraphRAG Module
3
+ *
4
+ * @see REQ-CG-RAG-001
5
+ * @see DES-CG-005
6
+ */
7
+ export { GraphRAGSearch } from './graphrag-search.js';
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/graphrag/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @nahisaho/musubix-codegraph
3
+ *
4
+ * Code graph analysis library for MUSUBIX
5
+ * Provides AST parsing, graph construction, and semantic search
6
+ *
7
+ * @packageDocumentation
8
+ * @module @nahisaho/musubix-codegraph
9
+ *
10
+ * @see REQ-CG-API-001 - Library as standalone
11
+ * @see REQ-CG-API-002 - Programmatic API
12
+ * @see REQ-CG-API-005 - Comprehensive exports
13
+ */
14
+ export { CodeGraph, createCodeGraph } from './codegraph.js';
15
+ export { TypedEventEmitter, CodeGraphEventEmitter, } from './events/index.js';
16
+ export type { Language, EntityType, Entity, EntityInput, RelationType, Relation, RelationInput, CodeGraphOptions, ParserOptions, GraphOptions, IndexerOptions, GraphRAGOptions, StorageAdapter, StorageStats, CodeGraphEvents, IndexProgress, QueryResult, IndexResult, CallPath, ModuleAnalysis, CodeSnippet, FileStructure, SearchResult, Community, GraphStatistics, ParseResult, GraphQuery, DependencyOptions, LocalSearchOptions, GlobalSearchOptions, } from './types.js';
17
+ export { LANGUAGE_EXTENSIONS, DEFAULT_CODEGRAPH_OPTIONS, generateEntityId, generateRelationId, isSupportedLanguage, getLanguageFromExtension, } from './types.js';
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAG5D,OAAO,EACL,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,mBAAmB,CAAC;AAG3B,YAAY,EAEV,QAAQ,EAGR,UAAU,EACV,MAAM,EACN,WAAW,EAGX,YAAY,EACZ,QAAQ,EACR,aAAa,EAGb,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,cAAc,EACd,eAAe,EAGf,cAAc,EACd,YAAY,EAGZ,eAAe,EACf,aAAa,EAGb,WAAW,EACX,WAAW,EACX,QAAQ,EACR,cAAc,EACd,WAAW,EACX,aAAa,EACb,YAAY,EACZ,SAAS,EACT,eAAe,EACf,WAAW,EAGX,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EACzB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,GACzB,MAAM,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @nahisaho/musubix-codegraph
3
+ *
4
+ * Code graph analysis library for MUSUBIX
5
+ * Provides AST parsing, graph construction, and semantic search
6
+ *
7
+ * @packageDocumentation
8
+ * @module @nahisaho/musubix-codegraph
9
+ *
10
+ * @see REQ-CG-API-001 - Library as standalone
11
+ * @see REQ-CG-API-002 - Programmatic API
12
+ * @see REQ-CG-API-005 - Comprehensive exports
13
+ */
14
+ // Main Facade
15
+ export { CodeGraph, createCodeGraph } from './codegraph.js';
16
+ // Event System
17
+ export { TypedEventEmitter, CodeGraphEventEmitter, } from './events/index.js';
18
+ // Constants
19
+ export { LANGUAGE_EXTENSIONS, DEFAULT_CODEGRAPH_OPTIONS, generateEntityId, generateRelationId, isSupportedLanguage, getLanguageFromExtension, } from './types.js';
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,cAAc;AACd,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAE5D,eAAe;AACf,OAAO,EACL,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,mBAAmB,CAAC;AAmD3B,YAAY;AACZ,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EACzB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,GACzB,MAAM,YAAY,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @nahisaho/musubix-codegraph - Indexer Module
3
+ *
4
+ * @see REQ-CG-IDX-001
5
+ * @see DES-CG-004
6
+ */
7
+ export { Indexer, type ProgressCallback } from './indexer.js';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/indexer/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @nahisaho/musubix-codegraph - Indexer Module
3
+ *
4
+ * @see REQ-CG-IDX-001
5
+ * @see DES-CG-004
6
+ */
7
+ export { Indexer } from './indexer.js';
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/indexer/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAyB,MAAM,cAAc,CAAC"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * @nahisaho/musubix-codegraph - Indexer
3
+ *
4
+ * Repository and directory indexing
5
+ *
6
+ * @see REQ-CG-IDX-001 - Repository indexing
7
+ * @see REQ-CG-IDX-002 - Incremental indexing
8
+ * @see DES-CG-004
9
+ * @see TSK-CG-030
10
+ */
11
+ import type { IndexResult, IndexerOptions, IndexProgress } from '../types.js';
12
+ import type { ASTParser } from '../parser/index.js';
13
+ import type { GraphEngine } from '../graph/index.js';
14
+ /**
15
+ * Progress callback type
16
+ */
17
+ export type ProgressCallback = (progress: IndexProgress) => void;
18
+ /**
19
+ * Indexer for code repositories
20
+ *
21
+ * Scans directories, parses files, and builds the code graph.
22
+ */
23
+ export declare class Indexer {
24
+ private parser;
25
+ private graph;
26
+ private options;
27
+ private progressCallback;
28
+ constructor(parser: ASTParser, graph: GraphEngine, options?: Partial<IndexerOptions>);
29
+ /**
30
+ * Set progress callback
31
+ */
32
+ onProgress(callback: ProgressCallback): void;
33
+ /**
34
+ * Index a repository or directory
35
+ */
36
+ indexRepository(repoPath: string): Promise<IndexResult>;
37
+ /**
38
+ * Index a single file
39
+ */
40
+ indexFile(filePath: string): Promise<IndexResult>;
41
+ /**
42
+ * Discover all parseable files in directory
43
+ */
44
+ private discoverFiles;
45
+ /**
46
+ * Recursively walk directory
47
+ */
48
+ private walkDirectory;
49
+ /**
50
+ * Check if path should be excluded
51
+ */
52
+ private shouldExclude;
53
+ /**
54
+ * Simple glob matching
55
+ */
56
+ private matchGlob;
57
+ }
58
+ //# sourceMappingURL=indexer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indexer.d.ts","sourceRoot":"","sources":["../../src/indexer/indexer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,KAAK,EACV,WAAW,EAEX,cAAc,EACd,aAAa,EACd,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,QAAQ,EAAE,aAAa,KAAK,IAAI,CAAC;AAEjE;;;;GAIG;AACH,qBAAa,OAAO;IAClB,OAAO,CAAC,MAAM,CAAY;IAC1B,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,OAAO,CAA2B;IAC1C,OAAO,CAAC,gBAAgB,CAAiC;gBAGvD,MAAM,EAAE,SAAS,EACjB,KAAK,EAAE,WAAW,EAClB,OAAO,GAAE,OAAO,CAAC,cAAc,CAAM;IAmBvC;;OAEG;IACH,UAAU,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI;IAI5C;;OAEG;IACG,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IA+D7D;;OAEG;IACG,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IA0CvD;;OAEG;YACW,aAAa;IAM3B;;OAEG;YACW,aAAa;IA0B3B;;OAEG;IACH,OAAO,CAAC,aAAa;IASrB;;OAEG;IACH,OAAO,CAAC,SAAS;CAWlB"}