@carlonicora/nestjs-neo4jsonapi 1.4.1 → 1.5.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.
Files changed (137) hide show
  1. package/dist/agents/agents.modules.d.ts.map +1 -1
  2. package/dist/agents/agents.modules.js +21 -2
  3. package/dist/agents/agents.modules.js.map +1 -1
  4. package/dist/agents/community.detector/community.detector.module.d.ts +3 -0
  5. package/dist/agents/community.detector/community.detector.module.d.ts.map +1 -0
  6. package/dist/agents/community.detector/community.detector.module.js +25 -0
  7. package/dist/agents/community.detector/community.detector.module.js.map +1 -0
  8. package/dist/agents/community.detector/services/community.detector.service.d.ts +63 -0
  9. package/dist/agents/community.detector/services/community.detector.service.d.ts.map +1 -0
  10. package/dist/agents/community.detector/services/community.detector.service.js +343 -0
  11. package/dist/agents/community.detector/services/community.detector.service.js.map +1 -0
  12. package/dist/agents/community.summariser/community.summariser.module.d.ts +3 -0
  13. package/dist/agents/community.summariser/community.summariser.module.d.ts.map +1 -0
  14. package/dist/agents/community.summariser/community.summariser.module.js +33 -0
  15. package/dist/agents/community.summariser/community.summariser.module.js.map +1 -0
  16. package/dist/agents/community.summariser/processors/community.summariser.processor.d.ts +21 -0
  17. package/dist/agents/community.summariser/processors/community.summariser.processor.d.ts.map +1 -0
  18. package/dist/agents/community.summariser/processors/community.summariser.processor.js +70 -0
  19. package/dist/agents/community.summariser/processors/community.summariser.processor.js.map +1 -0
  20. package/dist/agents/community.summariser/services/community.summariser.service.d.ts +26 -0
  21. package/dist/agents/community.summariser/services/community.summariser.service.d.ts.map +1 -0
  22. package/dist/agents/community.summariser/services/community.summariser.service.js +155 -0
  23. package/dist/agents/community.summariser/services/community.summariser.service.js.map +1 -0
  24. package/dist/agents/drift/contexts/drift.context.d.ts +56 -0
  25. package/dist/agents/drift/contexts/drift.context.d.ts.map +1 -0
  26. package/dist/agents/drift/contexts/drift.context.js +91 -0
  27. package/dist/agents/drift/contexts/drift.context.js.map +1 -0
  28. package/dist/agents/drift/drift.module.d.ts +3 -0
  29. package/dist/agents/drift/drift.module.d.ts.map +1 -0
  30. package/dist/agents/drift/drift.module.js +44 -0
  31. package/dist/agents/drift/drift.module.js.map +1 -0
  32. package/dist/agents/drift/nodes/community.search.node.service.d.ts +12 -0
  33. package/dist/agents/drift/nodes/community.search.node.service.d.ts.map +1 -0
  34. package/dist/agents/drift/nodes/community.search.node.service.js +57 -0
  35. package/dist/agents/drift/nodes/community.search.node.service.js.map +1 -0
  36. package/dist/agents/drift/nodes/followup.node.service.d.ts +28 -0
  37. package/dist/agents/drift/nodes/followup.node.service.d.ts.map +1 -0
  38. package/dist/agents/drift/nodes/followup.node.service.js +174 -0
  39. package/dist/agents/drift/nodes/followup.node.service.js.map +1 -0
  40. package/dist/agents/drift/nodes/hyde.node.service.d.ts +21 -0
  41. package/dist/agents/drift/nodes/hyde.node.service.d.ts.map +1 -0
  42. package/dist/agents/drift/nodes/hyde.node.service.js +114 -0
  43. package/dist/agents/drift/nodes/hyde.node.service.js.map +1 -0
  44. package/dist/agents/drift/nodes/primer.answer.node.service.d.ts +17 -0
  45. package/dist/agents/drift/nodes/primer.answer.node.service.d.ts.map +1 -0
  46. package/dist/agents/drift/nodes/primer.answer.node.service.js +108 -0
  47. package/dist/agents/drift/nodes/primer.answer.node.service.js.map +1 -0
  48. package/dist/agents/drift/nodes/synthesis.node.service.d.ts +17 -0
  49. package/dist/agents/drift/nodes/synthesis.node.service.d.ts.map +1 -0
  50. package/dist/agents/drift/nodes/synthesis.node.service.js +105 -0
  51. package/dist/agents/drift/nodes/synthesis.node.service.js.map +1 -0
  52. package/dist/agents/drift/services/drift.migration.service.d.ts +47 -0
  53. package/dist/agents/drift/services/drift.migration.service.d.ts.map +1 -0
  54. package/dist/agents/drift/services/drift.migration.service.js +114 -0
  55. package/dist/agents/drift/services/drift.migration.service.js.map +1 -0
  56. package/dist/agents/drift/services/drift.search.service.d.ts +52 -0
  57. package/dist/agents/drift/services/drift.search.service.d.ts.map +1 -0
  58. package/dist/agents/drift/services/drift.search.service.js +185 -0
  59. package/dist/agents/drift/services/drift.search.service.js.map +1 -0
  60. package/dist/agents/graph.creator/interfaces/chunk.analysis.interface.d.ts +4 -0
  61. package/dist/agents/graph.creator/interfaces/chunk.analysis.interface.d.ts.map +1 -1
  62. package/dist/agents/graph.creator/services/graph.creator.service.d.ts +1 -1
  63. package/dist/agents/graph.creator/services/graph.creator.service.d.ts.map +1 -1
  64. package/dist/agents/graph.creator/services/graph.creator.service.js +43 -0
  65. package/dist/agents/graph.creator/services/graph.creator.service.js.map +1 -1
  66. package/dist/agents/index.d.ts +8 -0
  67. package/dist/agents/index.d.ts.map +1 -1
  68. package/dist/agents/index.js +18 -1
  69. package/dist/agents/index.js.map +1 -1
  70. package/dist/agents/responder/contexts/responder.context.d.ts +3 -0
  71. package/dist/agents/responder/contexts/responder.context.d.ts.map +1 -1
  72. package/dist/agents/responder/contexts/responder.context.js +8 -0
  73. package/dist/agents/responder/contexts/responder.context.js.map +1 -1
  74. package/dist/agents/responder/factories/responder.context.factory.d.ts +1 -0
  75. package/dist/agents/responder/factories/responder.context.factory.d.ts.map +1 -1
  76. package/dist/agents/responder/factories/responder.context.factory.js +2 -0
  77. package/dist/agents/responder/factories/responder.context.factory.js.map +1 -1
  78. package/dist/agents/responder/nodes/responder.answer.node.service.d.ts +22 -0
  79. package/dist/agents/responder/nodes/responder.answer.node.service.d.ts.map +1 -1
  80. package/dist/agents/responder/nodes/responder.answer.node.service.js +155 -0
  81. package/dist/agents/responder/nodes/responder.answer.node.service.js.map +1 -1
  82. package/dist/agents/responder/responder.module.d.ts.map +1 -1
  83. package/dist/agents/responder/responder.module.js +2 -1
  84. package/dist/agents/responder/responder.module.js.map +1 -1
  85. package/dist/agents/responder/services/responder.service.d.ts +17 -1
  86. package/dist/agents/responder/services/responder.service.d.ts.map +1 -1
  87. package/dist/agents/responder/services/responder.service.js +49 -5
  88. package/dist/agents/responder/services/responder.service.js.map +1 -1
  89. package/dist/common/interfaces/agents/graph.creator.interface.d.ts +4 -0
  90. package/dist/common/interfaces/agents/graph.creator.interface.d.ts.map +1 -1
  91. package/dist/config/enums/queue.id.d.ts +2 -1
  92. package/dist/config/enums/queue.id.d.ts.map +1 -1
  93. package/dist/config/enums/queue.id.js +1 -0
  94. package/dist/config/enums/queue.id.js.map +1 -1
  95. package/dist/config/interfaces/config.prompts.interface.d.ts +5 -0
  96. package/dist/config/interfaces/config.prompts.interface.d.ts.map +1 -1
  97. package/dist/foundations/chunk/services/chunk.service.d.ts.map +1 -1
  98. package/dist/foundations/chunk/services/chunk.service.js +8 -0
  99. package/dist/foundations/chunk/services/chunk.service.js.map +1 -1
  100. package/dist/foundations/community/community.module.d.ts +5 -0
  101. package/dist/foundations/community/community.module.d.ts.map +1 -0
  102. package/dist/foundations/community/community.module.js +29 -0
  103. package/dist/foundations/community/community.module.js.map +1 -0
  104. package/dist/foundations/community/entities/community.entity.d.ts +18 -0
  105. package/dist/foundations/community/entities/community.entity.d.ts.map +1 -0
  106. package/dist/foundations/community/entities/community.entity.js +3 -0
  107. package/dist/foundations/community/entities/community.entity.js.map +1 -0
  108. package/dist/foundations/community/entities/community.map.d.ts +8 -0
  109. package/dist/foundations/community/entities/community.map.d.ts.map +1 -0
  110. package/dist/foundations/community/entities/community.map.js +23 -0
  111. package/dist/foundations/community/entities/community.map.js.map +1 -0
  112. package/dist/foundations/community/entities/community.meta.d.ts +3 -0
  113. package/dist/foundations/community/entities/community.meta.d.ts.map +1 -0
  114. package/dist/foundations/community/entities/community.meta.js +10 -0
  115. package/dist/foundations/community/entities/community.meta.js.map +1 -0
  116. package/dist/foundations/community/entities/community.model.d.ts +4 -0
  117. package/dist/foundations/community/entities/community.model.d.ts.map +1 -0
  118. package/dist/foundations/community/entities/community.model.js +15 -0
  119. package/dist/foundations/community/entities/community.model.js.map +1 -0
  120. package/dist/foundations/community/repositories/community.repository.d.ts +138 -0
  121. package/dist/foundations/community/repositories/community.repository.d.ts.map +1 -0
  122. package/dist/foundations/community/repositories/community.repository.js +446 -0
  123. package/dist/foundations/community/repositories/community.repository.js.map +1 -0
  124. package/dist/foundations/community/services/community.service.d.ts +8 -0
  125. package/dist/foundations/community/services/community.service.d.ts.map +1 -0
  126. package/dist/foundations/community/services/community.service.js +28 -0
  127. package/dist/foundations/community/services/community.service.js.map +1 -0
  128. package/dist/foundations/keyconcept/entities/key.concept.entity.d.ts +1 -0
  129. package/dist/foundations/keyconcept/entities/key.concept.entity.d.ts.map +1 -1
  130. package/dist/foundations/keyconcept/entities/key.concept.map.d.ts.map +1 -1
  131. package/dist/foundations/keyconcept/entities/key.concept.map.js +1 -0
  132. package/dist/foundations/keyconcept/entities/key.concept.map.js.map +1 -1
  133. package/dist/foundations/keyconcept/repositories/keyconcept.repository.d.ts +13 -2
  134. package/dist/foundations/keyconcept/repositories/keyconcept.repository.d.ts.map +1 -1
  135. package/dist/foundations/keyconcept/repositories/keyconcept.repository.js +22 -2
  136. package/dist/foundations/keyconcept/repositories/keyconcept.repository.js.map +1 -1
  137. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"agents.modules.d.ts","sourceRoot":"","sources":["../../src/agents/agents.modules.ts"],"names":[],"mappings":"AAMA;;;;GAIG;AACH,qBAIa,YAAY;CAAG"}
1
+ {"version":3,"file":"agents.modules.d.ts","sourceRoot":"","sources":["../../src/agents/agents.modules.ts"],"names":[],"mappings":"AASA;;;;GAIG;AACH,qBAoBa,YAAY;CAAG"}
@@ -8,7 +8,10 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.AgentsModule = void 0;
10
10
  const common_1 = require("@nestjs/common");
11
+ const community_detector_module_1 = require("./community.detector/community.detector.module");
12
+ const community_summariser_module_1 = require("./community.summariser/community.summariser.module");
11
13
  const contextualiser_module_1 = require("./contextualiser/contextualiser.module");
14
+ const drift_module_1 = require("./drift/drift.module");
12
15
  const graph_creator_module_1 = require("./graph.creator/graph.creator.module");
13
16
  const responder_module_1 = require("./responder/responder.module");
14
17
  const summariser_module_1 = require("./summariser/summariser.module");
@@ -22,8 +25,24 @@ let AgentsModule = class AgentsModule {
22
25
  exports.AgentsModule = AgentsModule;
23
26
  exports.AgentsModule = AgentsModule = __decorate([
24
27
  (0, common_1.Module)({
25
- imports: [contextualiser_module_1.ContextualiserModule, graph_creator_module_1.GraphCreatorModule, responder_module_1.ResponderModule, summariser_module_1.SummariserModule],
26
- exports: [contextualiser_module_1.ContextualiserModule, graph_creator_module_1.GraphCreatorModule, responder_module_1.ResponderModule, summariser_module_1.SummariserModule],
28
+ imports: [
29
+ community_detector_module_1.CommunityDetectorModule,
30
+ community_summariser_module_1.CommunitySummariserModule,
31
+ contextualiser_module_1.ContextualiserModule,
32
+ drift_module_1.DriftModule,
33
+ graph_creator_module_1.GraphCreatorModule,
34
+ responder_module_1.ResponderModule,
35
+ summariser_module_1.SummariserModule,
36
+ ],
37
+ exports: [
38
+ community_detector_module_1.CommunityDetectorModule,
39
+ community_summariser_module_1.CommunitySummariserModule,
40
+ contextualiser_module_1.ContextualiserModule,
41
+ drift_module_1.DriftModule,
42
+ graph_creator_module_1.GraphCreatorModule,
43
+ responder_module_1.ResponderModule,
44
+ summariser_module_1.SummariserModule,
45
+ ],
27
46
  })
28
47
  ], AgentsModule);
29
48
  //# sourceMappingURL=agents.modules.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"agents.modules.js","sourceRoot":"","sources":["../../src/agents/agents.modules.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,kFAA8E;AAC9E,+EAA0E;AAC1E,mEAA+D;AAC/D,sEAAkE;AAElE;;;;GAIG;AAKI,IAAM,YAAY,GAAlB,MAAM,YAAY;CAAG,CAAA;AAAf,oCAAY;uBAAZ,YAAY;IAJxB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,4CAAoB,EAAE,yCAAkB,EAAE,kCAAe,EAAE,oCAAgB,CAAC;QACtF,OAAO,EAAE,CAAC,4CAAoB,EAAE,yCAAkB,EAAE,kCAAe,EAAE,oCAAgB,CAAC;KACvF,CAAC;GACW,YAAY,CAAG"}
1
+ {"version":3,"file":"agents.modules.js","sourceRoot":"","sources":["../../src/agents/agents.modules.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,8FAAyF;AACzF,oGAA+F;AAC/F,kFAA8E;AAC9E,uDAAmD;AACnD,+EAA0E;AAC1E,mEAA+D;AAC/D,sEAAkE;AAElE;;;;GAIG;AAqBI,IAAM,YAAY,GAAlB,MAAM,YAAY;CAAG,CAAA;AAAf,oCAAY;uBAAZ,YAAY;IApBxB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,mDAAuB;YACvB,uDAAyB;YACzB,4CAAoB;YACpB,0BAAW;YACX,yCAAkB;YAClB,kCAAe;YACf,oCAAgB;SACjB;QACD,OAAO,EAAE;YACP,mDAAuB;YACvB,uDAAyB;YACzB,4CAAoB;YACpB,0BAAW;YACX,yCAAkB;YAClB,kCAAe;YACf,oCAAgB;SACjB;KACF,CAAC;GACW,YAAY,CAAG"}
@@ -0,0 +1,3 @@
1
+ export declare class CommunityDetectorModule {
2
+ }
3
+ //# sourceMappingURL=community.detector.module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"community.detector.module.d.ts","sourceRoot":"","sources":["../../../src/agents/community.detector/community.detector.module.ts"],"names":[],"mappings":"AAMA,qBAKa,uBAAuB;CAAG"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.CommunityDetectorModule = void 0;
10
+ const common_1 = require("@nestjs/common");
11
+ const community_detector_service_1 = require("./services/community.detector.service");
12
+ const logging_module_1 = require("../../core/logging/logging.module");
13
+ const community_module_1 = require("../../foundations/community/community.module");
14
+ const community_summariser_module_1 = require("../community.summariser/community.summariser.module");
15
+ let CommunityDetectorModule = class CommunityDetectorModule {
16
+ };
17
+ exports.CommunityDetectorModule = CommunityDetectorModule;
18
+ exports.CommunityDetectorModule = CommunityDetectorModule = __decorate([
19
+ (0, common_1.Module)({
20
+ imports: [logging_module_1.LoggingModule, community_module_1.CommunityModule, community_summariser_module_1.CommunitySummariserModule],
21
+ providers: [community_detector_service_1.CommunityDetectorService],
22
+ exports: [community_detector_service_1.CommunityDetectorService],
23
+ })
24
+ ], CommunityDetectorModule);
25
+ //# sourceMappingURL=community.detector.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"community.detector.module.js","sourceRoot":"","sources":["../../../src/agents/community.detector/community.detector.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,sFAAiF;AACjF,sEAAkE;AAClE,mFAA+E;AAC/E,qGAAgG;AAOzF,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;CAAG,CAAA;AAA1B,0DAAuB;kCAAvB,uBAAuB;IALnC,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,8BAAa,EAAE,kCAAe,EAAE,uDAAyB,CAAC;QACpE,SAAS,EAAE,CAAC,qDAAwB,CAAC;QACrC,OAAO,EAAE,CAAC,qDAAwB,CAAC;KACpC,CAAC;GACW,uBAAuB,CAAG"}
@@ -0,0 +1,63 @@
1
+ import { AppLoggingService } from "../../../core/logging/services/logging.service";
2
+ import { Neo4jService } from "../../../core/neo4j/services/neo4j.service";
3
+ import { CommunityRepository } from "../../../foundations/community/repositories/community.repository";
4
+ import { CommunitySummariserService } from "../../community.summariser/services/community.summariser.service";
5
+ export declare class CommunityDetectorService {
6
+ private readonly neo4j;
7
+ private readonly logger;
8
+ private readonly communityRepository;
9
+ private readonly summariserService;
10
+ private readonly louvainResolutions;
11
+ private readonly minCommunitySize;
12
+ constructor(neo4j: Neo4jService, logger: AppLoggingService, communityRepository: CommunityRepository, summariserService: CommunitySummariserService);
13
+ /**
14
+ * Detect communities for all KeyConcepts belonging to the current company
15
+ * Creates hierarchical communities at multiple resolution levels
16
+ */
17
+ detectCommunities(): Promise<void>;
18
+ /**
19
+ * Count KeyConcepts for the current company
20
+ */
21
+ private countKeyConceptsForCompany;
22
+ /**
23
+ * Check if Neo4j GDS is available
24
+ */
25
+ private checkGdsAvailability;
26
+ /**
27
+ * Detect communities at a specific resolution level using Louvain algorithm
28
+ */
29
+ private detectCommunitiesAtLevel;
30
+ /**
31
+ * Project KeyConcept graph into Neo4j GDS
32
+ * Uses KeyConceptRelationship weights as relationship weights
33
+ */
34
+ private projectGraph;
35
+ /**
36
+ * Run Louvain community detection algorithm
37
+ */
38
+ private runLouvain;
39
+ /**
40
+ * Create Community nodes from Louvain results
41
+ */
42
+ private createCommunityNodes;
43
+ /**
44
+ * Build PARENT_OF hierarchy between communities at different levels
45
+ * A parent community at level N+1 contains child communities at level N
46
+ * if the child's members are a subset of the parent's members
47
+ */
48
+ private buildHierarchy;
49
+ /**
50
+ * Drop a projected graph from GDS
51
+ */
52
+ private dropGraph;
53
+ /**
54
+ * Mark communities affected by a KeyConcept change as stale
55
+ */
56
+ markAffectedCommunitiesStale(keyConceptId: string): Promise<void>;
57
+ /**
58
+ * Incrementally assign KeyConcepts from a content to existing communities
59
+ * Called after document processing completes
60
+ */
61
+ assignKeyConceptsToCommunities(contentId: string, label: string): Promise<void>;
62
+ }
63
+ //# sourceMappingURL=community.detector.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"community.detector.service.d.ts","sourceRoot":"","sources":["../../../../src/agents/community.detector/services/community.detector.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gDAAgD,CAAC;AACnF,OAAO,EAAE,YAAY,EAAE,MAAM,4CAA4C,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,kEAAkE,CAAC;AACvG,OAAO,EAAE,0BAA0B,EAAE,MAAM,kEAAkE,CAAC;AAc9G,qBACa,wBAAwB;IAOjC,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,mBAAmB;IACpC,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAPpC,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAS;IAC5C,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAK;gBAGnB,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,iBAAiB,EACzB,mBAAmB,EAAE,mBAAmB,EACxC,iBAAiB,EAAE,0BAA0B;IAGhE;;;OAGG;IACG,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;IAyDxC;;OAEG;YACW,0BAA0B;IAgBxC;;OAEG;YACW,oBAAoB;IAgBlC;;OAEG;YACW,wBAAwB;IAoBtC;;;OAGG;YACW,YAAY;IAiC1B;;OAEG;YACW,UAAU;IA4BxB;;OAEG;YACW,oBAAoB;IA8ClC;;;;OAIG;YACW,cAAc;IA0D5B;;OAEG;YACW,SAAS;IAWvB;;OAEG;IACG,4BAA4B,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAavE;;;OAGG;IACG,8BAA8B,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CA8CtF"}
@@ -0,0 +1,343 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.CommunityDetectorService = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ const logging_service_1 = require("../../../core/logging/services/logging.service");
15
+ const neo4j_service_1 = require("../../../core/neo4j/services/neo4j.service");
16
+ const community_repository_1 = require("../../../foundations/community/repositories/community.repository");
17
+ const community_summariser_service_1 = require("../../community.summariser/services/community.summariser.service");
18
+ let CommunityDetectorService = class CommunityDetectorService {
19
+ constructor(neo4j, logger, communityRepository, summariserService) {
20
+ this.neo4j = neo4j;
21
+ this.logger = logger;
22
+ this.communityRepository = communityRepository;
23
+ this.summariserService = summariserService;
24
+ // Note: OpenGDS doesn't support resolution parameter, so we only run single level
25
+ // Future: could use Leiden with gamma, or post-process for hierarchy
26
+ this.louvainResolutions = [1.0];
27
+ this.minCommunitySize = 3;
28
+ }
29
+ /**
30
+ * Detect communities for all KeyConcepts belonging to the current company
31
+ * Creates hierarchical communities at multiple resolution levels
32
+ */
33
+ async detectCommunities() {
34
+ this.logger.log("Starting community detection", "CommunityDetectorService");
35
+ try {
36
+ // Delete existing communities for this company before regenerating
37
+ await this.communityRepository.deleteAllCommunities();
38
+ this.logger.debug("Deleted existing communities", "CommunityDetectorService");
39
+ // Check if GDS is available
40
+ const gdsAvailable = await this.checkGdsAvailability();
41
+ if (!gdsAvailable) {
42
+ this.logger.warn("Neo4j GDS not available, skipping community detection", "CommunityDetectorService");
43
+ return;
44
+ }
45
+ // Check if there are any KeyConcepts for this company
46
+ const keyConceptCount = await this.countKeyConceptsForCompany();
47
+ if (keyConceptCount === 0) {
48
+ this.logger.warn("No KeyConcepts found for company, skipping community detection", "CommunityDetectorService");
49
+ return;
50
+ }
51
+ this.logger.debug(`Found ${keyConceptCount} KeyConcepts for community detection`, "CommunityDetectorService");
52
+ // Detect communities at each resolution level
53
+ const allDetectedCommunities = [];
54
+ for (let levelIndex = 0; levelIndex < this.louvainResolutions.length; levelIndex++) {
55
+ const resolution = this.louvainResolutions[levelIndex];
56
+ const level = levelIndex;
57
+ this.logger.debug(`Detecting communities at level ${level} (resolution: ${resolution})`, "CommunityDetectorService");
58
+ const levelCommunities = await this.detectCommunitiesAtLevel(resolution, level);
59
+ allDetectedCommunities.push(...levelCommunities);
60
+ this.logger.debug(`Detected ${levelCommunities.length} communities at level ${level}`, "CommunityDetectorService");
61
+ }
62
+ // Build hierarchy relationships between levels
63
+ await this.buildHierarchy(allDetectedCommunities);
64
+ this.logger.log(`Community detection completed: ${allDetectedCommunities.length} total communities`, "CommunityDetectorService");
65
+ }
66
+ catch (error) {
67
+ this.logger.error(`Community detection failed: ${error.message}`, "CommunityDetectorService");
68
+ throw error;
69
+ }
70
+ }
71
+ /**
72
+ * Count KeyConcepts for the current company
73
+ */
74
+ async countKeyConceptsForCompany() {
75
+ const query = this.neo4j.initQuery();
76
+ query.query += `
77
+ MATCH (company)<-[:BELONGS_TO]-()-[:HAS_CHUNK]->()-[:HAS_ATOMIC_FACT]->()-[:HAS_KEY_CONCEPT]->(kc:KeyConcept)
78
+ RETURN count(DISTINCT kc) AS count
79
+ `;
80
+ // Use raw read() to avoid entity serialization - we just need a count
81
+ const result = await this.neo4j.read(query.query, query.queryParams);
82
+ if (result.records.length > 0) {
83
+ const count = result.records[0].get("count");
84
+ return count?.toNumber?.() ?? count ?? 0;
85
+ }
86
+ return 0;
87
+ }
88
+ /**
89
+ * Check if Neo4j GDS is available
90
+ */
91
+ async checkGdsAvailability() {
92
+ try {
93
+ // Use raw read() to avoid initQuery() company/user context requirement
94
+ const result = await this.neo4j.read(`RETURN gds.version() AS version`, {});
95
+ if (result.records.length > 0) {
96
+ const version = result.records[0].get("version");
97
+ this.logger.log(`Neo4j GDS version ${version} detected`, "CommunityDetectorService");
98
+ return true;
99
+ }
100
+ return false;
101
+ }
102
+ catch (error) {
103
+ this.logger.warn(`Neo4j GDS check failed: ${error.message}`, "CommunityDetectorService");
104
+ return false;
105
+ }
106
+ }
107
+ /**
108
+ * Detect communities at a specific resolution level using Louvain algorithm
109
+ */
110
+ async detectCommunitiesAtLevel(resolution, level) {
111
+ const graphName = `keyconcept_graph_${Date.now()}`;
112
+ try {
113
+ // Step 1: Project the KeyConcept graph into GDS
114
+ await this.projectGraph(graphName);
115
+ // Step 2: Run Louvain community detection
116
+ const communityAssignments = await this.runLouvain(graphName, resolution);
117
+ // Step 3: Create Community nodes from the results
118
+ const detectedCommunities = await this.createCommunityNodes(communityAssignments, level);
119
+ return detectedCommunities;
120
+ }
121
+ finally {
122
+ // Clean up: drop the projected graph
123
+ await this.dropGraph(graphName);
124
+ }
125
+ }
126
+ /**
127
+ * Project KeyConcept graph into Neo4j GDS
128
+ * Uses KeyConceptRelationship weights as relationship weights
129
+ */
130
+ async projectGraph(graphName) {
131
+ const query = this.neo4j.initQuery();
132
+ // GDS cypher projection needs parameters passed via configuration
133
+ // Path: Company <- BELONGS_TO - Content -> HAS_CHUNK -> Chunk -> HAS_ATOMIC_FACT -> AtomicFact -> HAS_KEY_CONCEPT -> KeyConcept
134
+ query.query += `
135
+ CALL gds.graph.project.cypher(
136
+ $graphName,
137
+ 'MATCH (company:Company {id: $companyId})<-[:BELONGS_TO]-()-[:HAS_CHUNK]->()-[:HAS_ATOMIC_FACT]->()-[:HAS_KEY_CONCEPT]->(kc:KeyConcept)
138
+ RETURN DISTINCT id(kc) AS id',
139
+ 'MATCH (kc1:KeyConcept)<-[:RELATES_TO]-(rel:KeyConceptRelationship)-[:RELATES_TO]->(kc2:KeyConcept)
140
+ MATCH (rel)-[:BELONGS_TO]->(company:Company {id: $companyId})
141
+ RETURN id(kc1) AS source, id(kc2) AS target, coalesce(rel.weight, 1.0) AS weight',
142
+ { parameters: { companyId: $companyId }, validateRelationships: false }
143
+ )
144
+ YIELD graphName, nodeCount, relationshipCount
145
+ RETURN graphName, nodeCount, relationshipCount
146
+ `;
147
+ query.queryParams = { ...query.queryParams, graphName };
148
+ // Use raw read() to avoid entity serialization
149
+ const result = await this.neo4j.read(query.query, query.queryParams);
150
+ const record = result.records[0];
151
+ const nodeCount = record?.get("nodeCount")?.toNumber?.() ?? record?.get("nodeCount") ?? 0;
152
+ const relationshipCount = record?.get("relationshipCount")?.toNumber?.() ?? record?.get("relationshipCount") ?? 0;
153
+ this.logger.debug(`Graph projected: ${nodeCount} nodes, ${relationshipCount} relationships`, "CommunityDetectorService");
154
+ }
155
+ /**
156
+ * Run Louvain community detection algorithm
157
+ */
158
+ async runLouvain(graphName, _resolution) {
159
+ const query = this.neo4j.initQuery();
160
+ // Note: OpenGDS doesn't support 'resolution' parameter, using basic Louvain
161
+ query.query += `
162
+ CALL gds.louvain.stream($graphName, {
163
+ relationshipWeightProperty: 'weight'
164
+ })
165
+ YIELD nodeId, communityId
166
+ WITH gds.util.asNode(nodeId) AS node, communityId
167
+ RETURN node.id AS keyConceptId, communityId
168
+ `;
169
+ query.queryParams = { ...query.queryParams, graphName };
170
+ // Use raw read() to avoid entity serialization
171
+ const result = await this.neo4j.read(query.query, query.queryParams);
172
+ const communityAssignments = new Map();
173
+ for (const record of result.records) {
174
+ const keyConceptId = record.get("keyConceptId");
175
+ const communityId = record.get("communityId")?.toNumber?.() ?? record.get("communityId");
176
+ communityAssignments.set(keyConceptId, communityId);
177
+ }
178
+ return communityAssignments;
179
+ }
180
+ /**
181
+ * Create Community nodes from Louvain results
182
+ */
183
+ async createCommunityNodes(communityAssignments, level) {
184
+ // Group KeyConcepts by community
185
+ const communitiesMap = new Map();
186
+ for (const [keyConceptId, communityId] of communityAssignments) {
187
+ if (!communitiesMap.has(communityId)) {
188
+ communitiesMap.set(communityId, []);
189
+ }
190
+ communitiesMap.get(communityId).push(keyConceptId);
191
+ }
192
+ const detectedCommunities = [];
193
+ // Create Community nodes for each cluster
194
+ for (const [, keyConceptIds] of communitiesMap) {
195
+ // Skip communities smaller than minimum size
196
+ if (keyConceptIds.length < this.minCommunitySize) {
197
+ continue;
198
+ }
199
+ // Create the community node
200
+ const community = await this.communityRepository.createCommunity({
201
+ name: `Community L${level}`, // Temporary name, will be updated by summariser
202
+ level,
203
+ memberCount: keyConceptIds.length,
204
+ rating: 0, // Will be updated by summariser
205
+ });
206
+ // Add HAS_MEMBER relationships
207
+ await this.communityRepository.updateCommunityMembers({
208
+ communityId: community.id,
209
+ keyConceptIds,
210
+ });
211
+ detectedCommunities.push({
212
+ id: community.id,
213
+ level,
214
+ memberKeyConceptIds: keyConceptIds,
215
+ });
216
+ }
217
+ return detectedCommunities;
218
+ }
219
+ /**
220
+ * Build PARENT_OF hierarchy between communities at different levels
221
+ * A parent community at level N+1 contains child communities at level N
222
+ * if the child's members are a subset of the parent's members
223
+ */
224
+ async buildHierarchy(allCommunities) {
225
+ // Group communities by level
226
+ const communitiesByLevel = new Map();
227
+ for (const community of allCommunities) {
228
+ if (!communitiesByLevel.has(community.level)) {
229
+ communitiesByLevel.set(community.level, []);
230
+ }
231
+ communitiesByLevel.get(community.level).push(community);
232
+ }
233
+ // For each level, find parent communities in the next level
234
+ const levels = Array.from(communitiesByLevel.keys()).sort((a, b) => a - b);
235
+ for (let i = 0; i < levels.length - 1; i++) {
236
+ const childLevel = levels[i];
237
+ const parentLevel = levels[i + 1];
238
+ const childCommunities = communitiesByLevel.get(childLevel) || [];
239
+ const parentCommunities = communitiesByLevel.get(parentLevel) || [];
240
+ for (const child of childCommunities) {
241
+ // Find the best parent (highest overlap)
242
+ let bestParent = null;
243
+ let bestOverlap = 0;
244
+ const childMembers = new Set(child.memberKeyConceptIds);
245
+ for (const parent of parentCommunities) {
246
+ const parentMembers = new Set(parent.memberKeyConceptIds);
247
+ // Count overlap
248
+ let overlap = 0;
249
+ for (const member of childMembers) {
250
+ if (parentMembers.has(member)) {
251
+ overlap++;
252
+ }
253
+ }
254
+ // Parent must contain majority of child's members
255
+ const overlapRatio = overlap / childMembers.size;
256
+ if (overlapRatio > 0.5 && overlap > bestOverlap) {
257
+ bestParent = parent;
258
+ bestOverlap = overlap;
259
+ }
260
+ }
261
+ if (bestParent) {
262
+ await this.communityRepository.setParentCommunity({
263
+ childCommunityId: child.id,
264
+ parentCommunityId: bestParent.id,
265
+ });
266
+ }
267
+ }
268
+ }
269
+ this.logger.debug("Community hierarchy built", "CommunityDetectorService");
270
+ }
271
+ /**
272
+ * Drop a projected graph from GDS
273
+ */
274
+ async dropGraph(graphName) {
275
+ try {
276
+ await this.neo4j.writeOne({
277
+ query: `CALL gds.graph.drop($graphName, false) YIELD graphName RETURN graphName`,
278
+ queryParams: { graphName },
279
+ });
280
+ }
281
+ catch {
282
+ // Graph might not exist, ignore error
283
+ }
284
+ }
285
+ /**
286
+ * Mark communities affected by a KeyConcept change as stale
287
+ */
288
+ async markAffectedCommunitiesStale(keyConceptId) {
289
+ const communities = await this.communityRepository.findCommunitiesByKeyConcept(keyConceptId);
290
+ const communityIds = communities.map((c) => c.id);
291
+ if (communityIds.length > 0) {
292
+ await this.communityRepository.markAsStale(communityIds);
293
+ this.logger.debug(`Marked ${communityIds.length} communities as stale for KeyConcept ${keyConceptId}`, "CommunityDetectorService");
294
+ }
295
+ }
296
+ /**
297
+ * Incrementally assign KeyConcepts from a content to existing communities
298
+ * Called after document processing completes
299
+ */
300
+ async assignKeyConceptsToCommunities(contentId, label) {
301
+ this.logger.debug(`Assigning KeyConcepts from ${label}:${contentId} to communities`, "CommunityDetectorService");
302
+ // Find KeyConcepts from this content that aren't in any community yet
303
+ const orphanKeyConceptIds = await this.communityRepository.findOrphanKeyConceptsForContent(contentId, label);
304
+ if (orphanKeyConceptIds.length === 0) {
305
+ this.logger.debug("No orphan KeyConcepts to assign", "CommunityDetectorService");
306
+ return;
307
+ }
308
+ this.logger.debug(`Found ${orphanKeyConceptIds.length} orphan KeyConcepts to assign`, "CommunityDetectorService");
309
+ const affectedCommunityIds = new Set();
310
+ for (const keyConceptId of orphanKeyConceptIds) {
311
+ // Find communities with related KeyConcepts
312
+ const relatedCommunities = await this.communityRepository.findCommunitiesByRelatedKeyConcepts(keyConceptId);
313
+ if (relatedCommunities.length > 0) {
314
+ // Assign to community with highest affinity (totalWeight)
315
+ const bestCommunity = relatedCommunities[0];
316
+ await this.communityRepository.addMemberToCommunity(bestCommunity.communityId, keyConceptId);
317
+ affectedCommunityIds.add(bestCommunity.communityId);
318
+ const msg = `Assigned KeyConcept ${keyConceptId} to community ${bestCommunity.communityId} (weight: ${bestCommunity.totalWeight})`;
319
+ this.logger.debug(msg, "CommunityDetectorService");
320
+ }
321
+ // If no related communities, leave as orphan for next full detection
322
+ }
323
+ // Generate summaries for affected communities
324
+ if (affectedCommunityIds.size > 0) {
325
+ this.logger.log(`Assigned KeyConcepts to ${affectedCommunityIds.size} communities, generating summaries`, "CommunityDetectorService");
326
+ for (const communityId of affectedCommunityIds) {
327
+ const community = await this.communityRepository.findById(communityId);
328
+ if (community) {
329
+ await this.summariserService.generateSummary(community);
330
+ }
331
+ }
332
+ }
333
+ }
334
+ };
335
+ exports.CommunityDetectorService = CommunityDetectorService;
336
+ exports.CommunityDetectorService = CommunityDetectorService = __decorate([
337
+ (0, common_1.Injectable)(),
338
+ __metadata("design:paramtypes", [neo4j_service_1.Neo4jService,
339
+ logging_service_1.AppLoggingService,
340
+ community_repository_1.CommunityRepository,
341
+ community_summariser_service_1.CommunitySummariserService])
342
+ ], CommunityDetectorService);
343
+ //# sourceMappingURL=community.detector.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"community.detector.service.js","sourceRoot":"","sources":["../../../../src/agents/community.detector/services/community.detector.service.ts"],"names":[],"mapp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CAAC,WAAW,aAAa,aAAa,CAAC,WAAW,GAAG,CAAC;gBACnI,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,0BAA0B,CAAC,CAAC;YACrD,CAAC;YACD,qEAAqE;QACvE,CAAC;QAED,8CAA8C;QAC9C,IAAI,oBAAoB,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;YAClC,IAAI,CAAC,MAAM,CAAC,GAAG,CACb,2BAA2B,oBAAoB,CAAC,IAAI,oCAAoC,EACxF,0BAA0B,CAC3B,CAAC;YAEF,KAAK,MAAM,WAAW,IAAI,oBAAoB,EAAE,CAAC;gBAC/C,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;gBACvE,IAAI,SAAS,EAAE,CAAC;oBACd,MAAM,IAAI,CAAC,iBAAiB,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;gBAC1D,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAA;AA3YY,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,mBAAU,GAAE;qCAQe,4BAAY;QACX,mCAAiB;QACJ,0CAAmB;QACrB,yDAA0B;GAVrD,wBAAwB,CA2YpC"}
@@ -0,0 +1,3 @@
1
+ export declare class CommunitySummariserModule {
2
+ }
3
+ //# sourceMappingURL=community.summariser.module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"community.summariser.module.d.ts","sourceRoot":"","sources":["../../../src/agents/community.summariser/community.summariser.module.ts"],"names":[],"mappings":"AASA,qBAUa,yBAAyB;CAAG"}
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.CommunitySummariserModule = void 0;
10
+ const bullmq_1 = require("@nestjs/bullmq");
11
+ const common_1 = require("@nestjs/common");
12
+ const config_1 = require("../../config");
13
+ const llm_module_1 = require("../../core/llm/llm.module");
14
+ const logging_module_1 = require("../../core/logging/logging.module");
15
+ const community_module_1 = require("../../foundations/community/community.module");
16
+ const community_summariser_processor_1 = require("./processors/community.summariser.processor");
17
+ const community_summariser_service_1 = require("./services/community.summariser.service");
18
+ let CommunitySummariserModule = class CommunitySummariserModule {
19
+ };
20
+ exports.CommunitySummariserModule = CommunitySummariserModule;
21
+ exports.CommunitySummariserModule = CommunitySummariserModule = __decorate([
22
+ (0, common_1.Module)({
23
+ imports: [
24
+ llm_module_1.LLMModule,
25
+ logging_module_1.LoggingModule,
26
+ community_module_1.CommunityModule,
27
+ bullmq_1.BullModule.registerQueue({ name: config_1.QueueId.COMMUNITY_SUMMARISER }),
28
+ ],
29
+ providers: [community_summariser_service_1.CommunitySummariserService, community_summariser_processor_1.CommunitySummariserProcessor],
30
+ exports: [community_summariser_service_1.CommunitySummariserService],
31
+ })
32
+ ], CommunitySummariserModule);
33
+ //# sourceMappingURL=community.summariser.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"community.summariser.module.js","sourceRoot":"","sources":["../../../src/agents/community.summariser/community.summariser.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAC5C,2CAAwC;AACxC,yCAAuC;AACvC,0DAAsD;AACtD,sEAAkE;AAClE,mFAA+E;AAC/E,gGAA2F;AAC3F,0FAAqF;AAY9E,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB;CAAG,CAAA;AAA5B,8DAAyB;oCAAzB,yBAAyB;IAVrC,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,sBAAS;YACT,8BAAa;YACb,kCAAe;YACf,mBAAU,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,gBAAO,CAAC,oBAAoB,EAAE,CAAC;SACjE;QACD,SAAS,EAAE,CAAC,yDAA0B,EAAE,6DAA4B,CAAC;QACrE,OAAO,EAAE,CAAC,yDAA0B,CAAC;KACtC,CAAC;GACW,yBAAyB,CAAG"}
@@ -0,0 +1,21 @@
1
+ import { WorkerHost } from "@nestjs/bullmq";
2
+ import { Job } from "bullmq";
3
+ import { ClsService } from "nestjs-cls";
4
+ import { AppLoggingService } from "../../../core/logging/services/logging.service";
5
+ import { CommunitySummariserService } from "../services/community.summariser.service";
6
+ interface CommunitySummariserJobData {
7
+ companyId: string;
8
+ batchSize?: number;
9
+ }
10
+ export declare class CommunitySummariserProcessor extends WorkerHost {
11
+ private readonly summariserService;
12
+ private readonly cls;
13
+ private readonly logger;
14
+ constructor(summariserService: CommunitySummariserService, cls: ClsService, logger: AppLoggingService);
15
+ onActive(job: Job): void;
16
+ onError(job: Job): void;
17
+ onCompleted(job: Job): void;
18
+ process(job: Job<CommunitySummariserJobData>): Promise<void>;
19
+ }
20
+ export {};
21
+ //# sourceMappingURL=community.summariser.processor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"community.summariser.processor.d.ts","sourceRoot":"","sources":["../../../../src/agents/community.summariser/processors/community.summariser.processor.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,OAAO,EAAE,iBAAiB,EAAE,MAAM,gDAAgD,CAAC;AACnF,OAAO,EAAE,0BAA0B,EAAE,MAAM,0CAA0C,CAAC;AAEtF,UAAU,0BAA0B;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,qBACa,4BAA6B,SAAQ,UAAU;IAExD,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAClC,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAFN,iBAAiB,EAAE,0BAA0B,EAC7C,GAAG,EAAE,UAAU,EACf,MAAM,EAAE,iBAAiB;IAM5C,QAAQ,CAAC,GAAG,EAAE,GAAG;IAKjB,OAAO,CAAC,GAAG,EAAE,GAAG;IAOhB,WAAW,CAAC,GAAG,EAAE,GAAG;IAId,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,0BAA0B,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAmBnE"}