@nahisaho/musubix-lean 1.8.5

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 (89) hide show
  1. package/dist/converters/EarsToLeanConverter.d.ts +61 -0
  2. package/dist/converters/EarsToLeanConverter.d.ts.map +1 -0
  3. package/dist/converters/EarsToLeanConverter.js +300 -0
  4. package/dist/converters/EarsToLeanConverter.js.map +1 -0
  5. package/dist/converters/TypeScriptSpecifier.d.ts +63 -0
  6. package/dist/converters/TypeScriptSpecifier.d.ts.map +1 -0
  7. package/dist/converters/TypeScriptSpecifier.js +307 -0
  8. package/dist/converters/TypeScriptSpecifier.js.map +1 -0
  9. package/dist/converters/index.d.ts +7 -0
  10. package/dist/converters/index.d.ts.map +1 -0
  11. package/dist/converters/index.js +7 -0
  12. package/dist/converters/index.js.map +1 -0
  13. package/dist/environment/LeanEnvironmentDetector.d.ts +57 -0
  14. package/dist/environment/LeanEnvironmentDetector.d.ts.map +1 -0
  15. package/dist/environment/LeanEnvironmentDetector.js +221 -0
  16. package/dist/environment/LeanEnvironmentDetector.js.map +1 -0
  17. package/dist/environment/LeanProjectInitializer.d.ts +49 -0
  18. package/dist/environment/LeanProjectInitializer.d.ts.map +1 -0
  19. package/dist/environment/LeanProjectInitializer.js +232 -0
  20. package/dist/environment/LeanProjectInitializer.js.map +1 -0
  21. package/dist/environment/index.d.ts +7 -0
  22. package/dist/environment/index.d.ts.map +1 -0
  23. package/dist/environment/index.js +7 -0
  24. package/dist/environment/index.js.map +1 -0
  25. package/dist/errors.d.ts +141 -0
  26. package/dist/errors.d.ts.map +1 -0
  27. package/dist/errors.js +254 -0
  28. package/dist/errors.js.map +1 -0
  29. package/dist/hybrid/HybridVerifier.d.ts +113 -0
  30. package/dist/hybrid/HybridVerifier.d.ts.map +1 -0
  31. package/dist/hybrid/HybridVerifier.js +247 -0
  32. package/dist/hybrid/HybridVerifier.js.map +1 -0
  33. package/dist/hybrid/index.d.ts +6 -0
  34. package/dist/hybrid/index.d.ts.map +1 -0
  35. package/dist/hybrid/index.js +6 -0
  36. package/dist/hybrid/index.js.map +1 -0
  37. package/dist/index.d.ts +21 -0
  38. package/dist/index.d.ts.map +1 -0
  39. package/dist/index.js +50 -0
  40. package/dist/index.js.map +1 -0
  41. package/dist/infrastructure/LeanFileGenerator.d.ts +70 -0
  42. package/dist/infrastructure/LeanFileGenerator.d.ts.map +1 -0
  43. package/dist/infrastructure/LeanFileGenerator.js +253 -0
  44. package/dist/infrastructure/LeanFileGenerator.js.map +1 -0
  45. package/dist/infrastructure/LeanRunner.d.ts +93 -0
  46. package/dist/infrastructure/LeanRunner.d.ts.map +1 -0
  47. package/dist/infrastructure/LeanRunner.js +296 -0
  48. package/dist/infrastructure/LeanRunner.js.map +1 -0
  49. package/dist/infrastructure/index.d.ts +7 -0
  50. package/dist/infrastructure/index.d.ts.map +1 -0
  51. package/dist/infrastructure/index.js +7 -0
  52. package/dist/infrastructure/index.js.map +1 -0
  53. package/dist/integration/LeanIntegration.d.ts +138 -0
  54. package/dist/integration/LeanIntegration.d.ts.map +1 -0
  55. package/dist/integration/LeanIntegration.js +352 -0
  56. package/dist/integration/LeanIntegration.js.map +1 -0
  57. package/dist/proof/ProofGenerator.d.ts +53 -0
  58. package/dist/proof/ProofGenerator.d.ts.map +1 -0
  59. package/dist/proof/ProofGenerator.js +324 -0
  60. package/dist/proof/ProofGenerator.js.map +1 -0
  61. package/dist/proof/ReProverClient.d.ts +58 -0
  62. package/dist/proof/ReProverClient.d.ts.map +1 -0
  63. package/dist/proof/ReProverClient.js +260 -0
  64. package/dist/proof/ReProverClient.js.map +1 -0
  65. package/dist/proof/index.d.ts +7 -0
  66. package/dist/proof/index.d.ts.map +1 -0
  67. package/dist/proof/index.js +7 -0
  68. package/dist/proof/index.js.map +1 -0
  69. package/dist/reporting/VerificationReporter.d.ts +89 -0
  70. package/dist/reporting/VerificationReporter.d.ts.map +1 -0
  71. package/dist/reporting/VerificationReporter.js +296 -0
  72. package/dist/reporting/VerificationReporter.js.map +1 -0
  73. package/dist/reporting/index.d.ts +6 -0
  74. package/dist/reporting/index.d.ts.map +1 -0
  75. package/dist/reporting/index.js +6 -0
  76. package/dist/reporting/index.js.map +1 -0
  77. package/dist/traceability/TraceabilityManager.d.ts +104 -0
  78. package/dist/traceability/TraceabilityManager.d.ts.map +1 -0
  79. package/dist/traceability/TraceabilityManager.js +299 -0
  80. package/dist/traceability/TraceabilityManager.js.map +1 -0
  81. package/dist/traceability/index.d.ts +6 -0
  82. package/dist/traceability/index.d.ts.map +1 -0
  83. package/dist/traceability/index.js +6 -0
  84. package/dist/traceability/index.js.map +1 -0
  85. package/dist/types.d.ts +466 -0
  86. package/dist/types.d.ts.map +1 -0
  87. package/dist/types.js +17 -0
  88. package/dist/types.js.map +1 -0
  89. package/package.json +78 -0
@@ -0,0 +1,352 @@
1
+ /**
2
+ * @fileoverview Main integration facade for Lean 4 formal verification
3
+ * @module @nahisaho/musubix-lean
4
+ * @traceability REQ-LEAN-001 to REQ-LEAN-006
5
+ */
6
+ import { ok, err } from 'neverthrow';
7
+ import { LeanEnvironmentDetector } from '../environment/LeanEnvironmentDetector.js';
8
+ import { LeanProjectInitializer } from '../environment/LeanProjectInitializer.js';
9
+ import { LeanRunner } from '../infrastructure/LeanRunner.js';
10
+ import { LeanFileGenerator } from '../infrastructure/LeanFileGenerator.js';
11
+ import { EarsToLeanConverter } from '../converters/EarsToLeanConverter.js';
12
+ import { TypeScriptSpecifier } from '../converters/TypeScriptSpecifier.js';
13
+ import { ProofGenerator } from '../proof/ProofGenerator.js';
14
+ import { ReProverClient } from '../proof/ReProverClient.js';
15
+ import { VerificationReporter } from '../reporting/VerificationReporter.js';
16
+ import { TraceabilityManager } from '../traceability/TraceabilityManager.js';
17
+ import { HybridVerifier } from '../hybrid/HybridVerifier.js';
18
+ import { LeanIntegrationError, LeanEnvironmentError, LeanVerificationError, } from '../errors.js';
19
+ /**
20
+ * Main integration class for Lean 4 formal verification
21
+ * Provides a unified API for all verification capabilities
22
+ *
23
+ * @traceability REQ-LEAN-001
24
+ */
25
+ export class LeanIntegration {
26
+ leanConfig;
27
+ detector;
28
+ initializer;
29
+ runner;
30
+ generator;
31
+ earsConverter;
32
+ tsSpecifier;
33
+ proofGenerator;
34
+ reprovarClient;
35
+ reporter;
36
+ traceability;
37
+ hybridVerifier;
38
+ status = {
39
+ initialized: false,
40
+ leanAvailable: false,
41
+ projectInitialized: false,
42
+ mathlibAvailable: false,
43
+ reprovarAvailable: false,
44
+ };
45
+ constructor(config = {}) {
46
+ this.leanConfig = {
47
+ leanPath: config.leanPath ?? 'lean',
48
+ projectPath: config.projectPath ?? process.cwd(),
49
+ timeout: config.timeout ?? 30000,
50
+ lakeEnabled: config.lakeEnabled ?? true,
51
+ mathlibEnabled: config.mathlibEnabled ?? false,
52
+ verbose: config.verbose ?? false,
53
+ };
54
+ // Initialize all components
55
+ this.detector = new LeanEnvironmentDetector();
56
+ this.initializer = new LeanProjectInitializer(config);
57
+ this.runner = new LeanRunner(config);
58
+ this.generator = new LeanFileGenerator(config);
59
+ this.earsConverter = new EarsToLeanConverter();
60
+ this.tsSpecifier = new TypeScriptSpecifier();
61
+ this.proofGenerator = new ProofGenerator();
62
+ this.reprovarClient = new ReProverClient(config);
63
+ this.reporter = new VerificationReporter();
64
+ this.traceability = new TraceabilityManager();
65
+ this.hybridVerifier = new HybridVerifier(config);
66
+ // Connect components
67
+ this.hybridVerifier.setReporter(this.reporter);
68
+ this.hybridVerifier.setTraceabilityManager(this.traceability);
69
+ }
70
+ /**
71
+ * Initialize the integration
72
+ * @traceability REQ-LEAN-ENV-001
73
+ */
74
+ async initialize() {
75
+ try {
76
+ // Detect Lean environment
77
+ const envInfo = await this.detector.detect();
78
+ this.status.leanAvailable = envInfo.installed;
79
+ this.status.leanVersion = envInfo.version ?? undefined;
80
+ this.status.mathlibAvailable = envInfo.mathlibAvailable;
81
+ if (!envInfo.installed) {
82
+ return err(new LeanIntegrationError('Lean 4 is not installed. Please install Lean 4 from https://leanprover.github.io/lean4/doc/setup.html'));
83
+ }
84
+ // Check ReProver availability
85
+ const reprovarAvailable = await this.reprovarClient.isAvailable();
86
+ this.status.reprovarAvailable = reprovarAvailable;
87
+ this.status.initialized = true;
88
+ return ok(this.status);
89
+ }
90
+ catch (error) {
91
+ return err(new LeanIntegrationError(`Initialization failed: ${error instanceof Error ? error.message : String(error)}`));
92
+ }
93
+ }
94
+ /**
95
+ * Initialize a new Lean project
96
+ * @traceability REQ-LEAN-ENV-002
97
+ */
98
+ async initProject(name, path) {
99
+ try {
100
+ await this.initializer.initialize({ name, directory: path ?? process.cwd() });
101
+ this.status.projectInitialized = true;
102
+ return ok(undefined);
103
+ }
104
+ catch (error) {
105
+ return err(new LeanIntegrationError(`Project initialization failed: ${error instanceof Error ? error.message : String(error)}`));
106
+ }
107
+ }
108
+ /**
109
+ * Convert EARS requirement to Lean theorem
110
+ * @traceability REQ-LEAN-CONV-001
111
+ */
112
+ convertRequirement(requirement) {
113
+ const result = this.earsConverter.convert(requirement);
114
+ return result.mapErr((e) => new LeanIntegrationError(`Conversion failed: ${e.message}`));
115
+ }
116
+ /**
117
+ * Convert TypeScript specification to Lean
118
+ * @traceability REQ-LEAN-CONV-002
119
+ */
120
+ convertTypeScript(spec) {
121
+ const functions = spec.functions ?? [];
122
+ const theorems = [];
123
+ for (const func of functions) {
124
+ const result = this.tsSpecifier.specify(func);
125
+ if (result.isErr()) {
126
+ return err(new LeanIntegrationError(`TypeScript conversion failed: ${result.error.message}`));
127
+ }
128
+ // Convert LeanFunctionSpec to LeanTheorem
129
+ const funcSpec = result.value;
130
+ theorems.push({
131
+ id: `theorem-${func.name}`,
132
+ name: funcSpec.functionName,
133
+ statement: funcSpec.typeSignature,
134
+ requirementId: `ts-func-${func.name}`,
135
+ hypotheses: funcSpec.preconditionHypotheses,
136
+ conclusion: funcSpec.postconditionGoal,
137
+ leanCode: funcSpec.leanCode,
138
+ });
139
+ }
140
+ return ok(theorems);
141
+ }
142
+ /**
143
+ * Generate proof for a theorem
144
+ * @traceability REQ-LEAN-PROOF-001
145
+ */
146
+ async generateProof(theorem, options = {}) {
147
+ try {
148
+ let proof;
149
+ if (options.useReProver && this.status.reprovarAvailable) {
150
+ // Create proof state from theorem for ReProver
151
+ const proofState = {
152
+ goals: [{ id: 0, type: theorem.conclusion?.type ?? '', leanCode: theorem.conclusion?.leanCode ?? '' }],
153
+ hypotheses: theorem.hypotheses,
154
+ currentGoal: 0,
155
+ };
156
+ const searchResult = await this.reprovarClient.search(proofState);
157
+ if (!searchResult.found || !searchResult.proof) {
158
+ return err(new LeanIntegrationError(`ReProver search failed: ${searchResult.suggestions.join(', ')}`));
159
+ }
160
+ // Convert ReProverSearchResult to LeanProof
161
+ proof = {
162
+ id: `proof-${theorem.id}`,
163
+ theoremId: theorem.id,
164
+ tactics: searchResult.searchPath.map(node => node.tactic),
165
+ leanCode: searchResult.proof,
166
+ isComplete: true,
167
+ generatedAt: new Date().toISOString(),
168
+ };
169
+ }
170
+ else {
171
+ const result = await this.proofGenerator.generate(theorem);
172
+ if (!result.success || !result.proof) {
173
+ return err(new LeanIntegrationError(`Proof generation failed: ${result.error ?? 'Unknown error'}`));
174
+ }
175
+ proof = result.proof;
176
+ }
177
+ return ok(proof);
178
+ }
179
+ catch (error) {
180
+ return err(new LeanIntegrationError(`Proof generation failed: ${error instanceof Error ? error.message : String(error)}`));
181
+ }
182
+ }
183
+ /**
184
+ * Verify a theorem
185
+ * @traceability REQ-LEAN-VERIFY-001
186
+ */
187
+ async verify(theorem, options = {}) {
188
+ const startTime = Date.now();
189
+ try {
190
+ // Register in traceability
191
+ if (options.traceability !== false) {
192
+ this.traceability.linkTheoremToRequirement(theorem);
193
+ }
194
+ // Generate proof if needed
195
+ let theoremWithProof = theorem;
196
+ if (options.generateProofs && !theorem.proof) {
197
+ const proofResult = await this.generateProof(theorem, {
198
+ useReProver: options.useReProver,
199
+ });
200
+ if (proofResult.isOk()) {
201
+ theoremWithProof = { ...theorem, proof: proofResult.value };
202
+ // Link proof in traceability
203
+ if (options.traceability !== false) {
204
+ this.traceability.linkProofToTheorem(proofResult.value, theorem);
205
+ }
206
+ }
207
+ }
208
+ // Generate Lean file
209
+ const outputDir = this.leanConfig.projectPath ?? process.cwd();
210
+ const genResult = await this.generator.generate([theoremWithProof], {
211
+ outputDir,
212
+ includeImports: true,
213
+ includeProofs: true,
214
+ });
215
+ // Type check
216
+ const checkResult = await this.runner.typeCheck(genResult.path);
217
+ const result = {
218
+ theoremId: theorem.id,
219
+ status: checkResult.valid ? 'proved' : 'incomplete',
220
+ proof: theoremWithProof.proof,
221
+ errors: checkResult.errors,
222
+ warnings: [],
223
+ duration: Date.now() - startTime,
224
+ };
225
+ // Add to reporter
226
+ this.reporter.addResult({
227
+ theorem: theoremWithProof,
228
+ status: result.status === 'proved' ? 'proved' : 'incomplete',
229
+ proof: result.proof,
230
+ error: result.errors[0],
231
+ duration: result.duration,
232
+ });
233
+ return ok(result);
234
+ }
235
+ catch (error) {
236
+ return err(new LeanVerificationError(`Verification failed: ${error instanceof Error ? error.message : String(error)}`));
237
+ }
238
+ }
239
+ /**
240
+ * Perform hybrid verification
241
+ * @traceability REQ-LEAN-HYBRID-001
242
+ */
243
+ async verifyHybrid(functionId, runtimeTests, theorem) {
244
+ return this.hybridVerifier.verify(functionId, runtimeTests, theorem);
245
+ }
246
+ /**
247
+ * Batch verify multiple theorems
248
+ */
249
+ async verifyBatch(theorems, options = {}) {
250
+ const results = new Map();
251
+ for (const theorem of theorems) {
252
+ const result = await this.verify(theorem, options);
253
+ if (result.isOk()) {
254
+ results.set(theorem.id, result.value);
255
+ }
256
+ else {
257
+ results.set(theorem.id, {
258
+ theoremId: theorem.id,
259
+ status: 'error',
260
+ errors: [result.error.message],
261
+ warnings: [],
262
+ duration: 0,
263
+ });
264
+ }
265
+ }
266
+ return results;
267
+ }
268
+ /**
269
+ * Generate verification report
270
+ * @traceability REQ-LEAN-FEEDBACK-001
271
+ */
272
+ generateReport() {
273
+ return this.reporter.generate();
274
+ }
275
+ /**
276
+ * Export report in specified format
277
+ */
278
+ exportReport(format) {
279
+ return this.reporter.export(format);
280
+ }
281
+ /**
282
+ * Get traceability coverage
283
+ * @traceability REQ-LEAN-TRACE-003
284
+ */
285
+ getTraceabilityCoverage(requirementIds) {
286
+ const coverage = this.traceability.calculateCoverage(requirementIds);
287
+ return {
288
+ totalRequirements: coverage.totalRequirements,
289
+ coveredRequirements: coverage.coveredRequirements,
290
+ coveragePercentage: coverage.coveragePercentage,
291
+ untraced: coverage.untraced,
292
+ fullyTraced: coverage.fullyTraced,
293
+ };
294
+ }
295
+ /**
296
+ * Get traceability matrix as Markdown
297
+ */
298
+ getTraceabilityMatrix() {
299
+ return this.traceability.exportMarkdown();
300
+ }
301
+ /**
302
+ * Get current status
303
+ */
304
+ getStatus() {
305
+ return { ...this.status };
306
+ }
307
+ /**
308
+ * Get Lean version
309
+ */
310
+ async getLeanVersion() {
311
+ try {
312
+ const version = await this.runner.getVersion();
313
+ return ok(version);
314
+ }
315
+ catch (error) {
316
+ return err(new LeanEnvironmentError(`Failed to get version: ${error instanceof Error ? error.message : String(error)}`));
317
+ }
318
+ }
319
+ /**
320
+ * Check if a file has valid Lean syntax
321
+ */
322
+ async validateSyntax(filePath) {
323
+ try {
324
+ const result = await this.runner.typeCheck(filePath);
325
+ return ok(result.valid);
326
+ }
327
+ catch (error) {
328
+ return err(new LeanVerificationError(`Syntax validation failed: ${error instanceof Error ? error.message : String(error)}`));
329
+ }
330
+ }
331
+ /**
332
+ * Clear all state
333
+ */
334
+ reset() {
335
+ this.reporter.clear();
336
+ this.traceability.clear();
337
+ this.status = {
338
+ initialized: false,
339
+ leanAvailable: false,
340
+ projectInitialized: false,
341
+ mathlibAvailable: false,
342
+ reprovarAvailable: false,
343
+ };
344
+ }
345
+ }
346
+ /**
347
+ * Factory function for creating LeanIntegration instance
348
+ */
349
+ export function createLeanIntegration(config) {
350
+ return new LeanIntegration(config);
351
+ }
352
+ //# sourceMappingURL=LeanIntegration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LeanIntegration.js","sourceRoot":"","sources":["../../src/integration/LeanIntegration.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAU,EAAE,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAY7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,2CAA2C,CAAC;AACpF,OAAO,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAClF,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,EAAE,cAAc,EAA0B,MAAM,6BAA6B,CAAC;AACrF,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,cAAc,CAAC;AAyBtB;;;;;GAKG;AACH,MAAM,OAAO,eAAe;IAClB,UAAU,CAAa;IACvB,QAAQ,CAA0B;IAClC,WAAW,CAAyB;IACpC,MAAM,CAAa;IACnB,SAAS,CAAoB;IAC7B,aAAa,CAAsB;IACnC,WAAW,CAAsB;IACjC,cAAc,CAAiB;IAC/B,cAAc,CAAiB;IAC/B,QAAQ,CAAuB;IAC/B,YAAY,CAAsB;IAClC,cAAc,CAAiB;IAE/B,MAAM,GAAsB;QAClC,WAAW,EAAE,KAAK;QAClB,aAAa,EAAE,KAAK;QACpB,kB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PROOF-003
5
+ */
6
+ import type { LeanTheorem, LeanProofSketch, ProofResult, ProofState, ProofStrategy, ProofOptions, TacticResult } from '../types.js';
7
+ /**
8
+ * Generate proof for a Lean theorem
9
+ * @traceability REQ-LEAN-PROOF-001
10
+ */
11
+ export declare function generateProof(theorem: LeanTheorem, options?: ProofOptions): Promise<ProofResult>;
12
+ /**
13
+ * Apply a single tactic to proof state
14
+ */
15
+ export declare function applyTactic(state: ProofState, tactic: string): Promise<TacticResult>;
16
+ /**
17
+ * Generate proof sketch with sorry markers
18
+ * @traceability REQ-LEAN-PROOF-003
19
+ */
20
+ export declare function generateProofSketch(theorem: LeanTheorem, partialTactics?: string[]): LeanProofSketch;
21
+ /**
22
+ * Select best strategy for theorem
23
+ */
24
+ export declare function selectStrategy(theorem: LeanTheorem, strategies?: ProofStrategy[]): ProofStrategy;
25
+ /**
26
+ * ProofGenerator class implementation
27
+ * @traceability REQ-LEAN-PROOF-001
28
+ */
29
+ export declare class ProofGenerator {
30
+ private strategies;
31
+ constructor(strategies?: ProofStrategy[]);
32
+ /**
33
+ * Generate proof for theorem
34
+ */
35
+ generate(theorem: LeanTheorem, options?: ProofOptions): Promise<ProofResult>;
36
+ /**
37
+ * Apply single tactic
38
+ */
39
+ applyTactic(state: ProofState, tactic: string): Promise<TacticResult>;
40
+ /**
41
+ * Generate proof sketch
42
+ */
43
+ generateSketch(theorem: LeanTheorem, partialTactics?: string[]): LeanProofSketch;
44
+ /**
45
+ * Select best strategy
46
+ */
47
+ selectStrategy(theorem: LeanTheorem): ProofStrategy;
48
+ /**
49
+ * Add custom strategy
50
+ */
51
+ addStrategy(strategy: ProofStrategy): void;
52
+ }
53
+ //# sourceMappingURL=ProofGenerator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProofGenerator.d.ts","sourceRoot":"","sources":["../../src/proof/ProofGenerator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,WAAW,EAEX,eAAe,EACf,W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