@pawells/math-extended 2.0.0 → 3.0.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 (118) hide show
  1. package/README.md +15 -21
  2. package/build/clamp.d.ts +5 -5
  3. package/build/clamp.js +5 -5
  4. package/build/core.d.ts +23 -0
  5. package/build/core.d.ts.map +1 -0
  6. package/build/core.js +25 -0
  7. package/build/core.js.map +1 -0
  8. package/build/index.d.ts +1 -4
  9. package/build/index.d.ts.map +1 -1
  10. package/build/index.js +1 -6
  11. package/build/index.js.map +1 -1
  12. package/build/interpolation.d.ts +158 -171
  13. package/build/interpolation.d.ts.map +1 -1
  14. package/build/interpolation.js +162 -181
  15. package/build/interpolation.js.map +1 -1
  16. package/build/matrices/arithmetic.d.ts +132 -132
  17. package/build/matrices/arithmetic.d.ts.map +1 -1
  18. package/build/matrices/arithmetic.js +194 -226
  19. package/build/matrices/arithmetic.js.map +1 -1
  20. package/build/matrices/asserts.d.ts +30 -408
  21. package/build/matrices/asserts.d.ts.map +1 -1
  22. package/build/matrices/asserts.js +98 -542
  23. package/build/matrices/asserts.js.map +1 -1
  24. package/build/matrices/core.d.ts +117 -46
  25. package/build/matrices/core.d.ts.map +1 -1
  26. package/build/matrices/core.js +127 -103
  27. package/build/matrices/core.js.map +1 -1
  28. package/build/matrices/decompositions.d.ts +95 -96
  29. package/build/matrices/decompositions.d.ts.map +1 -1
  30. package/build/matrices/decompositions.js +119 -160
  31. package/build/matrices/decompositions.js.map +1 -1
  32. package/build/matrices/index.d.ts +0 -1
  33. package/build/matrices/index.d.ts.map +1 -1
  34. package/build/matrices/index.js +0 -3
  35. package/build/matrices/index.js.map +1 -1
  36. package/build/matrices/linear-algebra.d.ts +45 -8
  37. package/build/matrices/linear-algebra.d.ts.map +1 -1
  38. package/build/matrices/linear-algebra.js +76 -32
  39. package/build/matrices/linear-algebra.js.map +1 -1
  40. package/build/matrices/normalization.d.ts +29 -8
  41. package/build/matrices/normalization.d.ts.map +1 -1
  42. package/build/matrices/normalization.js +32 -23
  43. package/build/matrices/normalization.js.map +1 -1
  44. package/build/matrices/transformations.d.ts +116 -148
  45. package/build/matrices/transformations.d.ts.map +1 -1
  46. package/build/matrices/transformations.js +69 -91
  47. package/build/matrices/transformations.js.map +1 -1
  48. package/build/matrices/types.d.ts +32 -60
  49. package/build/matrices/types.d.ts.map +1 -1
  50. package/build/matrices/types.js +63 -1
  51. package/build/matrices/types.js.map +1 -1
  52. package/build/quaternions/asserts.d.ts +29 -38
  53. package/build/quaternions/asserts.d.ts.map +1 -1
  54. package/build/quaternions/asserts.js +61 -77
  55. package/build/quaternions/asserts.js.map +1 -1
  56. package/build/quaternions/conversions.d.ts +26 -26
  57. package/build/quaternions/conversions.d.ts.map +1 -1
  58. package/build/quaternions/conversions.js +24 -24
  59. package/build/quaternions/core.d.ts +70 -69
  60. package/build/quaternions/core.d.ts.map +1 -1
  61. package/build/quaternions/core.js +71 -71
  62. package/build/quaternions/core.js.map +1 -1
  63. package/build/quaternions/index.d.ts +0 -1
  64. package/build/quaternions/index.d.ts.map +1 -1
  65. package/build/quaternions/index.js +0 -2
  66. package/build/quaternions/index.js.map +1 -1
  67. package/build/quaternions/interpolation.d.ts +16 -16
  68. package/build/quaternions/interpolation.d.ts.map +1 -1
  69. package/build/quaternions/interpolation.js +21 -21
  70. package/build/quaternions/interpolation.js.map +1 -1
  71. package/build/quaternions/predefined.d.ts +10 -10
  72. package/build/quaternions/predefined.d.ts.map +1 -1
  73. package/build/quaternions/predefined.js +9 -9
  74. package/build/quaternions/types.d.ts +23 -12
  75. package/build/quaternions/types.d.ts.map +1 -1
  76. package/build/quaternions/types.js +51 -1
  77. package/build/quaternions/types.js.map +1 -1
  78. package/build/random.d.ts +66 -20
  79. package/build/random.d.ts.map +1 -1
  80. package/build/random.js +73 -20
  81. package/build/random.js.map +1 -1
  82. package/build/vectors/asserts.d.ts +50 -220
  83. package/build/vectors/asserts.d.ts.map +1 -1
  84. package/build/vectors/asserts.js +141 -327
  85. package/build/vectors/asserts.js.map +1 -1
  86. package/build/vectors/core.d.ts +182 -229
  87. package/build/vectors/core.d.ts.map +1 -1
  88. package/build/vectors/core.js +234 -288
  89. package/build/vectors/core.js.map +1 -1
  90. package/build/vectors/index.d.ts +0 -1
  91. package/build/vectors/index.d.ts.map +1 -1
  92. package/build/vectors/index.js +0 -2
  93. package/build/vectors/index.js.map +1 -1
  94. package/build/vectors/interpolation.d.ts +40 -40
  95. package/build/vectors/interpolation.d.ts.map +1 -1
  96. package/build/vectors/interpolation.js +75 -86
  97. package/build/vectors/interpolation.js.map +1 -1
  98. package/build/vectors/predefined.d.ts +31 -7
  99. package/build/vectors/predefined.d.ts.map +1 -1
  100. package/build/vectors/predefined.js +30 -6
  101. package/build/vectors/predefined.js.map +1 -1
  102. package/build/vectors/types.d.ts +26 -4
  103. package/build/vectors/types.d.ts.map +1 -1
  104. package/build/vectors/types.js +50 -1
  105. package/build/vectors/types.js.map +1 -1
  106. package/package.json +3 -2
  107. package/build/matrices/_exports.d.ts +0 -13
  108. package/build/matrices/_exports.d.ts.map +0 -1
  109. package/build/matrices/_exports.js +0 -13
  110. package/build/matrices/_exports.js.map +0 -1
  111. package/build/quaternions/_exports.d.ts +0 -11
  112. package/build/quaternions/_exports.d.ts.map +0 -1
  113. package/build/quaternions/_exports.js +0 -11
  114. package/build/quaternions/_exports.js.map +0 -1
  115. package/build/vectors/_exports.d.ts +0 -10
  116. package/build/vectors/_exports.d.ts.map +0 -1
  117. package/build/vectors/_exports.js +0 -10
  118. package/build/vectors/_exports.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"random.js","sourceRoot":"","sources":["../src/random.ts"],"names":[],"mappings":"AAAA,MAAM,sBAAsB,GAAG,CAAC,CAAC,CAAC;AAClC,MAAM,iBAAiB,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,mDAAmD;AAE7F;;;;;;;;;GASG;AACH,MAAM,UAAU,SAAS,CAAC,GAAW,E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1B,MAAM,IAAI,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;QAC5B,WAAW,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAM,CAAC;QACrC,WAAW,CAAC,CAAC,CAAC,GAAG,IAAS,CAAC;IAC5B,CAAC;IAED,OAAO,WAAW,CAAC;AACpB,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,UAAU,CAAC,cAAsB,GAAG;IACnD,IAAI,WAAW,GAAG,CAAC,IAAI,WAAW,GAAG,CAAC;QAAE,MAAM,IAAI,UAAU,CAAC,4CAA4C,WAAW,EAAE,CAAC,CAAC;IAExH,OAAO,IAAI,CAAC,MAAM,EAAE,GAAG,WAAW,CAAC;AACpC,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,YAAY,CAAC,OAAe,CAAC,EAAE,oBAA4B,CAAC;IAC3E,oEAAoE;IACpE,IAAI,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;IACvB;;;;;;OAMG;IACH,OAAO,EAAE,GAAG,iBAAiB,EAAE,CAAC;QAC/B,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;IACpB,CAAC;IACD,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;IAEzB,MAAM,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,sBAAsB,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;IACzF,OAAO,CAAC,EAAE,GAAG,iBAAiB,CAAC,GAAG,IAAI,CAAC;AACxC,CAAC"}
@@ -3,70 +3,19 @@
3
3
  * Provides comprehensive validation functions to ensure vector data integrity
4
4
  * and catch errors early in mathematical operations.
5
5
  */
6
- import { IAssertException, IAssertNumberArgs, IAssertArrayArgs } from '@pawells/typescript-common';
7
- import { TVector, TVector2, TVector3, TVector4 } from './types.js';
6
+ import { type TVector, type TVector2, type TVector3, type TVector4 } from './types.js';
7
+ import z from 'zod';
8
8
  /**
9
- * Configuration options for vector assertion functions.
10
- * Allows flexible validation of vector properties and constraints.
11
- */
12
- export type TAssertVectorArgs = IAssertNumberArgs & IAssertArrayArgs;
13
- /**
14
- * Extended configuration for validating multiple vectors.
15
- * Includes all single vector options plus multi-vector constraints.
16
- */
17
- export interface IAssertVectorsArgs extends TAssertVectorArgs {
18
- /**
19
- * Minimum vector size allowed.
20
- * If specified, vectors must have at least this many components.
21
- */
22
- minSize?: number;
23
- /**
24
- * Whether all vectors must have the same size.
25
- * Default: true when using individual arguments, configurable when using array syntax.
26
- */
27
- sameSize?: boolean;
28
- /**
29
- * Whether all vector elements must be finite numbers.
30
- * If true, validates that each element is not Infinity or -Infinity.
31
- */
32
- finite?: boolean;
33
- }
34
- /**
35
- * Extended exception interface for vector-specific error information.
36
- * Provides additional context about which vector component caused the error.
37
- */
38
- interface IAssertVectorException extends IAssertException {
39
- /**
40
- * Index of the vector component that caused the validation failure.
41
- * Useful for debugging which specific element is invalid.
42
- */
43
- index?: number;
44
- }
45
- type TAssertVectorValueArgs = IAssertNumberArgs;
46
- /**
47
- * Specialized error class for vector-related operations and validations.
48
- * Thrown when vector assertions fail or vector operations encounter invalid data.
9
+ * Vector error class for validation failures and vector operations.
10
+ * Extends Error to provide detailed error information with optional cause chain.
49
11
  *
50
12
  * @example
51
- * ```typescript
52
- * try {
53
- * AssertVector("not a vector");
54
- * } catch (error) {
55
- * if (error instanceof VectorError) {
56
- * console.log("Vector validation failed:", error.message);
57
- * }
58
- * }
59
- * ```
13
+ * ```typescript
14
+ * throw new VectorError('Invalid vector dimensions', { cause: originalError });
15
+ * ```
60
16
  */
61
17
  export declare class VectorError extends Error {
62
18
  readonly code: string;
63
- /**
64
- * Creates a new VectorError instance.
65
- *
66
- * @param message - Error message describing the validation failure
67
- * @param options - Optional error context
68
- * @param options.cause - Original error that caused this error
69
- */
70
19
  constructor(message: string, options?: {
71
20
  cause?: unknown;
72
21
  });
@@ -83,18 +32,17 @@ export declare class VectorError extends Error {
83
32
  * @throws {VectorError} If the value is not a valid vector meeting all constraints
84
33
  *
85
34
  * @example
86
- * ```typescript
87
- * ```typescript
88
- * // Basic validation — passes silently for a valid vector
89
- * AssertVector([1, 2, 3]);
90
- * // Validate with size constraint
91
- * AssertVector([1, 2], { size: 2 });
92
- * // Throws VectorError for non-array input
93
- * AssertVector("not a vector"); // throws VectorError
94
- * ```
95
- * ```
35
+ * ```typescript
36
+ * // Basic validation — passes silently for a valid vector
37
+ * AssertVector([1, 2, 3]);
38
+ * // Validate with size constraint
39
+ * AssertVector([1, 2], { size: 2 });
40
+ * // Throws VectorError for non-array input
41
+ * AssertVector("not a vector"); // throws VectorError
42
+ * ```
96
43
  */
97
- export declare function AssertVector(vector: unknown, args?: TAssertVectorArgs, exception?: IAssertVectorException): asserts vector is TVector;
44
+ export declare function AssertVector(vector: unknown): asserts vector is TVector;
45
+ export declare function ValidateVector(vector: unknown): boolean;
98
46
  /**
99
47
  * Validates that an unknown value is a valid 2D vector (exactly 2 numeric components).
100
48
  *
@@ -103,15 +51,14 @@ export declare function AssertVector(vector: unknown, args?: TAssertVectorArgs,
103
51
  * @throws {VectorError} If the value is not a 2-component vector
104
52
  *
105
53
  * @example
106
- * ```typescript
107
- * ```typescript
108
- * AssertVector2([1, 2]); // passes
109
- * AssertVector2([1, 2, 3]); // throws — too many components
110
- * AssertVector2("not a vec"); // throws
111
- * ```
112
- * ```
54
+ * ```typescript
55
+ * AssertVector2([1, 2]); // passes
56
+ * AssertVector2([1, 2, 3]); // throws — too many components
57
+ * AssertVector2("not a vec"); // throws
58
+ * ```
113
59
  */
114
- export declare function AssertVector2(vector: unknown, exception?: IAssertVectorException): asserts vector is TVector2;
60
+ export declare function AssertVector2(vector: unknown): asserts vector is TVector2;
61
+ export declare function ValidateVector2(vector: unknown): boolean;
115
62
  /**
116
63
  * Validates that an unknown value is a valid 3D vector (exactly 3 numeric components).
117
64
  *
@@ -120,15 +67,14 @@ export declare function AssertVector2(vector: unknown, exception?: IAssertVector
120
67
  * @throws {VectorError} If the value is not a 3-component vector
121
68
  *
122
69
  * @example
123
- * ```typescript
124
- * ```typescript
125
- * AssertVector3([1, 2, 3]); // passes
126
- * AssertVector3([1, 2]); // throws — too few components
127
- * AssertVector3(null); // throws
128
- * ```
129
- * ```
70
+ * ```typescript
71
+ * AssertVector3([1, 2, 3]); // passes
72
+ * AssertVector3([1, 2]); // throws — too few components
73
+ * AssertVector3(null); // throws
74
+ * ```
130
75
  */
131
- export declare function AssertVector3(vector: unknown, exception?: IAssertVectorException): asserts vector is TVector3;
76
+ export declare function AssertVector3(vector: unknown): asserts vector is TVector3;
77
+ export declare function ValidateVector3(vector: unknown): boolean;
132
78
  /**
133
79
  * Validates that an unknown value is a valid 4D vector (exactly 4 numeric components).
134
80
  *
@@ -136,151 +82,35 @@ export declare function AssertVector3(vector: unknown, exception?: IAssertVector
136
82
  * @param exception - Custom exception details if validation fails
137
83
  * @throws {VectorError} If the value is not a 4-component vector
138
84
  *
139
- * @example
140
- * ```typescript
141
- * ```typescript
142
- * AssertVector4([1, 2, 3, 4]); // passes
143
- * AssertVector4([1, 2, 3]); // throws — too few components
144
- * AssertVector4(undefined); // throws
145
- * ```
146
- * ```
147
- */
148
- export declare function AssertVector4(vector: unknown, exception?: IAssertVectorException): asserts vector is TVector4;
149
- /**
150
- * Validates that an unknown value is a valid vector element (a finite, non-NaN number).
151
- *
152
- * Supports optional numeric constraints such as range bounds, integer enforcement,
153
- * and finiteness checks. Throws `VectorError` with the component index when available.
154
- *
155
- * @param value - The value to validate as a vector element
156
- * @param args - Numeric constraints (finite, integer, gt, gte, lt, lte, eq)
157
- * @param exception - Custom exception details, optionally including a component `index`
158
- * @throws {VectorError} If the value is not a valid number or violates any constraint
159
- *
160
- * @example
161
- * ```typescript
162
- * ```typescript
163
- * AssertVectorValue(3.14); // passes
164
- * AssertVectorValue(3.14, { finite: true }); // passes
165
- * AssertVectorValue(Infinity, { finite: true }); // throws
166
- * AssertVectorValue(NaN); // throws
167
- * AssertVectorValue(5, { gte: 0, lte: 10 }); // passes
168
- * ```
169
- * ```
170
- */
171
- export declare function AssertVectorValue(value: unknown, args?: TAssertVectorValueArgs, exception?: IAssertVectorException): asserts value is number;
172
- /**
173
- * Validates an array of vectors, ensuring each vector is valid and optionally
174
- * enforcing that all vectors share the same size.
175
- *
176
- * @param vectors - The array of vectors to validate (must be non-empty)
177
- * @param args - Validation constraints applied to each vector; set `sameSize: true`
178
- * to require all vectors to have identical lengths
179
- * @param exception - Custom exception details if validation fails
180
- * @throws {VectorError} If the array is empty, any vector is invalid, or sizes
181
- * differ when `sameSize` is `true`
182
- *
183
- * @example
184
- * ```typescript
185
- * // Validate an array of 3D vectors
186
- * AssertVectors([[1, 2, 3], [4, 5, 6]]);
187
- * // Require all vectors to share the same length
188
- * AssertVectors([[1, 2], [3, 4]], { sameSize: true });
189
- * // Throws because vectors have different sizes
190
- * AssertVectors([[1, 2], [1, 2, 3]], { sameSize: true }); // throws
191
- * ```
192
- */
193
- export declare function AssertVectors(vectors: unknown[], args?: IAssertVectorsArgs, exception?: IAssertVectorException): void;
194
- /**
195
- * Validates that an unknown value is a valid vector without throwing an error.
196
- *
197
- * This function performs the same validation as AssertVector but returns
198
- * a boolean instead of throwing an exception, making it suitable for
199
- * conditional logic where exceptions are not desired.
200
- *
201
- * @param vector - The value to validate as a vector
202
- * @param args - Validation configuration options
203
- * @returns true if the vector is valid, false otherwise
204
- *
205
- * @example
206
- * ```typescript
207
- * if (ValidateVector([1, 2, 3])) {
208
- * // Process the valid vector
209
- * }
210
- * ```
211
- */
212
- export declare function ValidateVector(vector: unknown, args?: TAssertVectorArgs): vector is TVector;
213
- /**
214
- * Validates that an unknown value is a valid 2D vector without throwing an error.
215
- *
216
- * @param vector - The value to validate as a 2D vector
217
- * @returns true if the vector is valid, false otherwise
218
- *
219
- * @example
220
- * ```typescript
221
- * if (ValidateVector2([1, 2])) {
222
- * // Process the valid 2D vector
223
- * }
224
- * ```
225
- */
226
- export declare function ValidateVector2(vector: unknown): vector is TVector2;
227
- /**
228
- * Validates that an unknown value is a valid 3D vector without throwing an error.
229
- *
230
- * @param vector - The value to validate as a 3D vector
231
- * @returns true if the vector is valid, false otherwise
232
- *
233
- * @example
234
- * ```typescript
235
- * if (ValidateVector3([1, 2, 3])) {
236
- * // Process the valid 3D vector
237
- * }
238
- * ```
239
- */
240
- export declare function ValidateVector3(vector: unknown): vector is TVector3;
241
- /**
242
- * Validates that an unknown value is a valid 4D vector without throwing an error.
243
- *
244
- * @param vector - The value to validate as a 4D vector
245
- * @returns true if the vector is valid, false otherwise
246
- *
247
85
  * @example
248
86
  * ```typescript
249
- * if (ValidateVector4([1, 2, 3, 4])) {
250
- * // Process the valid 4D vector
251
- * }
87
+ * AssertVector4([1, 2, 3, 4]); // passes
88
+ * AssertVector4([1, 2, 3]); // throws too few components
89
+ * AssertVector4(undefined); // throws
252
90
  * ```
253
91
  */
254
- export declare function ValidateVector4(vector: unknown): vector is TVector4;
92
+ export declare function AssertVector4(vector: unknown): asserts vector is TVector4;
93
+ export declare function ValidateVector4(vector: unknown): boolean;
94
+ export declare const VECTOR_SAME_SIZE_SCHEMA: z.ZodArray<z.ZodArray<z.ZodNumber>>;
95
+ export type TVectorSameSize = z.infer<typeof VECTOR_SAME_SIZE_SCHEMA>;
96
+ export declare function AssertVectorSameSize(vectors: unknown[]): asserts vectors is TVectorSameSize;
97
+ export declare function ValidateVectorSameSize(vectors: unknown[]): boolean;
255
98
  /**
256
- * Validates that an unknown value is a valid vector element without throwing an error.
99
+ * Validates that the given vector is not a zero vector (all components are not zero).
100
+ * Throws a VectorError if the vector is zero.
257
101
  *
258
- * @param value - The value to validate as a vector element
259
- * @param args - Validation configuration options
260
- * @returns true if the value is valid, false otherwise
102
+ * @param vector - The vector to validate
103
+ * @param label - The label for the vector used in the error message (default: 'Vector')
104
+ * @throws {VectorError} If the vector is a zero vector
261
105
  *
262
106
  * @example
263
107
  * ```typescript
264
- * if (ValidateVectorValue(1.5)) {
265
- * // Process the valid element
266
- * }
267
- * ```
268
- */
269
- export declare function ValidateVectorValue(value: unknown, args?: TAssertVectorValueArgs): value is number;
270
- /**
271
- * Validates that an unknown value is an array of valid vectors without throwing an error.
272
- *
273
- * @param vectors - The value to validate as an array of vectors
274
- * @param args - Validation configuration options
275
- * @returns true if all vectors are valid, false otherwise
108
+ * const v = [1, 2, 3];
109
+ * AssertVectorNonZero(v); // Valid
276
110
  *
277
- * @example
278
- * ```typescript
279
- * if (ValidateVectors([v1, v2, v3])) {
280
- * // Process the valid vector array
281
- * }
111
+ * const zero = [0, 0, 0];
112
+ * AssertVectorNonZero(zero, 'Direction'); // Throws VectorError: Direction must not be zero
282
113
  * ```
283
114
  */
284
- export declare function ValidateVectors(vectors: unknown[], args?: IAssertVectorsArgs): boolean;
285
- export {};
115
+ export declare function AssertVectorNonZero(vector: TVector, label?: string): void;
286
116
  //# sourceMappingURL=asserts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"asserts.d.ts","sourceRoot":"","sources":["../../src/vectors/asserts.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,gBAAgB,EAAuC,MAAM,4BAA4B,CAAC;AACxI,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEnE;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,iBAAiB,GAAG,gBAAgB,CAAC;AAErE;;;GAGG;AACH,MAAM,WAAW,kBAAmB,SAAQ,iBAAiB;IAC5D;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB;AACD;;;GAG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