@danielsimonjr/mathts-functions 0.42.0 → 0.43.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.
@@ -1,106 +1,33 @@
1
1
  /**
2
- * A map facade on a bare object.
3
- *
4
- * The small number of methods needed to implement a scope,
5
- * forwarding on to the SafeProperty functions. Over time, the codebase
6
- * will stop using this method, as all objects will be Maps, rather than
7
- * more security prone objects.
8
- */
9
- /**
10
- * The iterator type `Map` itself declares, derived from the installed TS lib
11
- * rather than hard-coded: older libs say `IterableIterator<[K, V]>`, TS >= 5.6
12
- * says `MapIterator<[K, V]>` (which additionally requires `[Symbol.dispose]`).
13
- * Deriving it keeps `implements Map<K, V>` honest on every TS version.
14
- */
15
- type MapEntryIterator<K, V> = ReturnType<Map<K, V>[typeof Symbol.iterator]>;
16
- export declare class ObjectWrappingMap<K = string, V = unknown> implements Map<K, V> {
17
- wrappedObject: Record<string, V>;
18
- readonly [Symbol.toStringTag]: string;
19
- constructor(object: Record<string, V>);
20
- /**
21
- * Declared as a real method rather than assigned in the constructor through a
22
- * cast. The old form satisfied the runtime but never appeared in the emitted
23
- * type, so `implements Map<K, V>` was a lie that only surfaced downstream:
24
- * consumers compiling with `skipLibCheck: false` got TS2420 ("incorrectly
25
- * implements interface 'Map'... '[Symbol.iterator]' is missing").
26
- */
27
- [Symbol.iterator](): MapEntryIterator<K, V>;
28
- keys(): IterableIterator<K>;
29
- get(key: K): V | undefined;
30
- set(key: K, value: V): this;
31
- has(key: K): boolean;
32
- entries(): IterableIterator<[K, V]>;
33
- values(): IterableIterator<V>;
34
- forEach(callback: (value: V, key: K, map: Map<K, V>) => void): void;
35
- delete(key: K): boolean;
36
- clear(): void;
37
- get size(): number;
38
- }
39
- /**
40
- * Create a map with two partitions: a and b.
41
- * The set with bKeys determines which keys/values are read/written to map b,
42
- * all other values are read/written to map a
43
- *
44
- * For example:
45
- *
46
- * const a = new Map()
47
- * const b = new Map()
48
- * const p = new PartitionedMap(a, b, new Set(['x', 'y']))
49
- *
50
- * In this case, values `x` and `y` are read/written to map `b`,
51
- * all other values are read/written to map `a`.
52
- */
53
- export declare class PartitionedMap<K = unknown, V = unknown> implements Map<K, V> {
54
- a: Map<K, V>;
55
- b: Map<K, V>;
56
- bKeys: Set<K>;
57
- readonly [Symbol.toStringTag]: string;
58
- /**
59
- * @param a - Primary map
60
- * @param b - Secondary map
61
- * @param bKeys - Set of keys that should be read/written to map b
62
- */
63
- constructor(a: Map<K, V>, b: Map<K, V>, bKeys: Set<K>);
64
- /** See the note on `ObjectWrappingMap[Symbol.iterator]` — same fix. */
65
- [Symbol.iterator](): MapEntryIterator<K, V>;
66
- get(key: K): V | undefined;
67
- set(key: K, value: V): this;
68
- has(key: K): boolean;
69
- keys(): IterableIterator<K>;
70
- values(): IterableIterator<V>;
71
- entries(): IterableIterator<[K, V]>;
72
- forEach(callback: (value: V, key: K, map: Map<K, V>) => void): void;
73
- delete(key: K): boolean;
74
- clear(): void;
75
- get size(): number;
76
- }
77
- /**
78
- * Creates an empty map, or whatever your platform's polyfill is.
79
- *
80
- * @returns an empty Map or Map like object.
81
- */
82
- export declare function createEmptyMap<K = unknown, V = unknown>(): Map<K, V>;
83
- /**
84
- * Creates a Map from the given object.
85
- *
86
- * @param mapOrObject - Map or object to convert
87
- * @returns Map instance
88
- */
89
- export declare function createMap<K = unknown, V = unknown>(mapOrObject?: Map<K, V> | Record<string, V> | null): Map<K, V>;
90
- /**
91
- * Copies the contents of key-value pairs from each `objects` in to `map`.
92
- *
93
- * Object is `objects` can be a `Map` or object.
94
- *
95
- * This is the `Map` analog to `Object.assign`.
96
- */
97
- export declare function assign<K = unknown, V = unknown>(map: Map<K, V>, ...objects: (Map<K, V> | Record<string, V> | null | undefined)[]): Map<K, V>;
98
- /**
99
- * Returns `true` if `object` is an {@link ObjectWrappingMap}.
100
- *
101
- * Defined here, next to the class it guards, so `is.ts` need not import
102
- * `map.ts` — that import was the sole edge closing the `is`/`map` cycle.
2
+ * A `Map`-facade over a bare object (`ObjectWrappingMap`), a two-partition
3
+ * `Map` (`PartitionedMap`), and small `Map`/object interop helpers
4
+ * (`createMap`/`createEmptyMap`/`assign`).
5
+ *
6
+ * Consolidated onto core: the implementation lives once in
7
+ * `@danielsimonjr/mathts-core/internal` (see `core/src/map.ts` and the
8
+ * `project-all-libraries-build-on-core` principle). Thin re-export so existing
9
+ * `../utils/map.js` imports keep working while the single source of truth lives
10
+ * in core. Proven equivalent to the prior local copy (and to `expression`'s copy)
11
+ * via a fast-check property harness before the redirect see
12
+ * `functions/tests/dedup-bucketB-equivalence.test.ts`.
13
+ *
14
+ * TWO divergences were found and reconciled onto core (see `core/src/map.ts`'s
15
+ * header for the full writeup):
16
+ * 1. `[Symbol.iterator]` THIS package's prior copy already declared it as a
17
+ * real, correctly-typed class method (the fix `expression`'s copy was
18
+ * missing); core's canonical adopts this package's version unchanged.
19
+ * 2. `createEmptyMap`/`createMap`'s generic default (`K = unknown` here vs.
20
+ * `K = string` in `expression`) — a compile-time-only inference default with
21
+ * no behavioral difference; reconciled to core's `K = string` (matching
22
+ * `ObjectWrappingMap`/`PartitionedMap`'s own `K = string` default already
23
+ * shared by both packages). No call site in this package relies on the
24
+ * `K = unknown` default (checked: `functions/src/algebra/simplify.ts`'s
25
+ * `createEmptyMap()` call is assigned to an explicitly `Map<string, unknown>`-
26
+ * typed parameter default, which `Map<string, unknown>` satisfies directly).
27
+ *
28
+ * This package never had `toObject` (unlike `expression`'s prior copy, consumed
29
+ * by its `Parser.ts`), so it is intentionally not re-exported here — this shim
30
+ * preserves exactly the original export surface.
103
31
  */
104
- export declare function isObjectWrappingMap(object: unknown): object is ObjectWrappingMap;
105
- export {};
32
+ export { ObjectWrappingMap, PartitionedMap, createEmptyMap, createMap, assignMap as assign, isObjectWrappingMap, } from '@danielsimonjr/mathts-core/internal';
106
33
  //# sourceMappingURL=map.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"map.d.ts","sourceRoot":"","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AAI,IAAI,IAAI,MAAM,CAEjB;CACF;AAmBD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,CAAC,GAAG,OAAO,EAAE,CAAC,GAAG,OAAO,KAAK,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAEpE;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,CAAC,GAAG,OAAO,EAAE,CAAC,GAAG,OAAO,EAChD,WAAW,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,IAAI,GACjD,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAYX;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,CAAC,GAAG,OAAO,EAAE,CAAC,GAAG,OAAO,EAC7C,GAAG,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EACd,GAAG,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,GAC/D,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAgBX;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,iBAAiB,CAIhF"}
1
+ {"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../../src/utils/map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,SAAS,EACT,SAAS,IAAI,MAAM,EACnB,mBAAmB,GACpB,MAAM,qCAAqC,CAAC"}
@@ -1,64 +1,20 @@
1
- import { type FormatOptions } from './number.js';
2
1
  /**
3
- * Formatting options accepted by the generic `format` helper. Extends the
4
- * numeric {@link FormatOptions} with the string-level `truncate` and the
5
- * fraction rendering mode, or is a precision number, or a custom formatter.
6
- */
7
- export type GeneralFormatOptions = number | ((value: unknown) => string) | (FormatOptions & {
8
- truncate?: number;
9
- fraction?: 'ratio' | 'decimal';
10
- });
11
- /**
12
- * Format a value of any type into a string.
13
- *
14
- * Usage:
15
- * math.format(value)
16
- * math.format(value, precision)
17
- * math.format(value, options)
18
- *
19
- * When value is a function:
20
- *
21
- * - When the function has a property `syntax`, it returns this
22
- * syntax description.
23
- * - In other cases, a string `'function'` is returned.
24
- *
25
- * When `value` is an Object:
2
+ * Generic-value string formatting (`format`, `stringify`, `compareText`).
26
3
  *
27
- * - When the object contains a property `format` being a function, this
28
- * function is invoked as `value.format(options)` and the result is returned.
29
- * - When the object has its own `toString` method, this method is invoked
30
- * and the result is returned.
31
- * - In other cases the function will loop over all object properties and
32
- * return JSON object notation like '{"a": 2, "b": 3}'.
4
+ * Consolidated onto core: the implementations live once in
5
+ * `@danielsimonjr/mathts-core/internal` (see `number.ts`/`object.ts` and the
6
+ * `project-all-libraries-build-on-core` principle). Thin re-export so existing
7
+ * `../utils/string.js` imports keep working while the single source of truth
8
+ * lives in core. Proven equivalent to the prior local copy (and to `expression`'s
9
+ * copy) via a fast-check property harness before the redirect — see
10
+ * `functions/tests/dedup-bucketB-equivalence.test.ts`.
33
11
  *
34
- * Example usage:
35
- * math.format(2/7) // '0.2857142857142857'
36
- * math.format(math.pi, 3) // '3.14'
37
- * math.format(new Complex(2, 3)) // '2 + 3i'
38
- * math.format('hello') // '"hello"'
39
- *
40
- * @param {*} value Value to be stringified
41
- * @param {Object | number | Function} [options]
42
- * Formatting options. See src/utils/number.js:format for a
43
- * description of the available options controlling number output.
44
- * This generic "format" also supports the option property `truncate: NN`
45
- * giving the maximum number NN of characters to return (if there would
46
- * have been more, they are deleted and replaced by an ellipsis).
47
- * @return {string} str
48
- */
49
- export declare function format(value: unknown, options?: unknown): string;
50
- /**
51
- * Stringify a value into a string enclosed in double quotes.
52
- * Unescaped double quotes and backslashes inside the value are escaped.
53
- * @param {*} value
54
- * @return {string}
55
- */
56
- export declare function stringify(value: unknown): string;
57
- /**
58
- * Compare two strings
59
- * @param {string} x
60
- * @param {string} y
61
- * @returns {number}
12
+ * NOTE: core exports the generic `format` here as `formatGeneric` (its `number.ts`
13
+ * already exports a `format` for plain numbers from the same `internal.ts` barrel,
14
+ * so an unaliased re-export would collide); re-exported here under the original
15
+ * local name `format`. This package never had `escape`/`endsWith` in this file
16
+ * (unlike `expression`'s prior copy), so they are intentionally not re-exported
17
+ * here — this shim preserves exactly the original export surface.
62
18
  */
63
- export declare function compareText(x: unknown, y: unknown): number;
19
+ export { formatGeneric as format, stringify, compareText, type GeneralFormatOptions, } from '@danielsimonjr/mathts-core/internal';
64
20
  //# sourceMappingURL=string.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../src/utils/string.ts"],"names":[],"mappings":"AACA,OAAO,EAA0B,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAGzE;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,GAC5B,MAAM,GACN,CAAC,CAAC,KAAK,EAAE,OAAO,KAAK,MAAM,CAAC,GAC5B,CAAC,aAAa,GAAG;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAChC,CAAC,CAAC;AASP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,CAShE;AA2DD;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAWhD;AAwDD;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,MAAM,CAoB1D"}
1
+ {"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../src/utils/string.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EACL,aAAa,IAAI,MAAM,EACvB,SAAS,EACT,WAAW,EACX,KAAK,oBAAoB,GAC1B,MAAM,qCAAqC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danielsimonjr/mathts-functions",
3
- "version": "0.42.0",
3
+ "version": "0.43.0",
4
4
  "description": "Mathematical functions for MathTS - arithmetic, algebra, trigonometry, statistics, and more",
5
5
  "author": "Daniel Simon Jr.",
6
6
  "license": "MIT",
@@ -34,11 +34,11 @@
34
34
  "build:prod": "tsup src/index.ts --format esm --clean --minify --treeshake"
35
35
  },
36
36
  "dependencies": {
37
- "@danielsimonjr/mathts-core": "^0.10.0",
38
- "@danielsimonjr/mathts-expression": "^0.6.4",
37
+ "@danielsimonjr/mathts-core": "^0.11.0",
38
+ "@danielsimonjr/mathts-expression": "^0.6.5",
39
39
  "@danielsimonjr/mathts-gpu": "^0.2.0",
40
- "@danielsimonjr/mathts-matrix": "^0.6.0",
41
- "@danielsimonjr/mathts-parallel": "^0.6.0",
40
+ "@danielsimonjr/mathts-matrix": "^0.6.1",
41
+ "@danielsimonjr/mathts-parallel": "^0.6.1",
42
42
  "bignumber.js": "^9.1.2",
43
43
  "complex.js": "^2.2.5",
44
44
  "decimal.js": "^10.4.3",
@@ -1,13 +0,0 @@
1
- /**
2
- * Custom error type for Mathjs errors
3
- * @extends Error
4
- */
5
- export declare class MathjsError extends Error {
6
- isMathjsError: true;
7
- /**
8
- * Create a MathjsError
9
- * @param message Error message
10
- */
11
- constructor(message: string);
12
- }
13
- //# sourceMappingURL=MathjsError.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MathjsError.d.ts","sourceRoot":"","sources":["../../src/error/MathjsError.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,qBAAa,WAAY,SAAQ,KAAK;IACpC,aAAa,EAAG,IAAI,CAAU;IAE9B;;;OAGG;gBACS,OAAO,EAAE,MAAM;CAY5B"}
@@ -1,136 +0,0 @@
1
- /**
2
- * Structural contract for the BigNumber values handled by this formatter.
3
- * Captures exactly the methods/properties used here. The configured BigNumber
4
- * implementation (e.g. decimal.js) provides these; the project's `BigNumber`
5
- * type alias points at a minimal local Decimal that does not declare them all,
6
- * so we model the runtime contract explicitly.
7
- */
8
- interface BigNumberValue {
9
- e: number;
10
- constructor: new (value: number | string) => BigNumberValue;
11
- isFinite(): boolean;
12
- isNaN(): boolean;
13
- isZero(): boolean;
14
- isInteger(): boolean;
15
- gt(other: number | BigNumberValue): boolean;
16
- greaterThan(other: number | BigNumberValue): boolean;
17
- lessThan(other: number | BigNumberValue): boolean;
18
- add(other: number | BigNumberValue): BigNumberValue;
19
- sub(other: number | BigNumberValue): BigNumberValue;
20
- mul(other: number | BigNumberValue): BigNumberValue;
21
- pow(exp: number | BigNumberValue): BigNumberValue;
22
- toNumber(): number;
23
- toFixed(places?: number): string;
24
- toExponential(places?: number): string;
25
- toPrecision(sd?: number): string;
26
- toSignificantDigits(sd?: number): BigNumberValue;
27
- toBinary(): string;
28
- toOctal(): string;
29
- toHexadecimal(): string;
30
- }
31
- /**
32
- * Convert a BigNumber to a formatted string representation.
33
- *
34
- * Syntax:
35
- *
36
- * format(value)
37
- * format(value, options)
38
- * format(value, precision)
39
- * format(value, fn)
40
- *
41
- * Where:
42
- *
43
- * {number} value The value to be formatted
44
- * {Object} options An object with formatting options. Available options:
45
- * {string} notation
46
- * Number notation. Choose from:
47
- * 'fixed' Always use regular number notation.
48
- * For example '123.40' and '14000000'
49
- * 'exponential' Always use exponential notation.
50
- * For example '1.234e+2' and '1.4e+7'
51
- * 'auto' (default) Regular number notation for numbers
52
- * having an absolute value between
53
- * `lower` and `upper` bounds, and uses
54
- * exponential notation elsewhere.
55
- * Lower bound is included, upper bound
56
- * is excluded.
57
- * For example '123.4' and '1.4e7'.
58
- * 'bin', 'oct, or
59
- * 'hex' Format the number using binary, octal,
60
- * or hexadecimal notation.
61
- * For example '0b1101' and '0x10fe'.
62
- * {number} wordSize The word size in bits to use for formatting
63
- * in binary, octal, or hexadecimal notation.
64
- * To be used only with 'bin', 'oct', or 'hex'
65
- * values for 'notation' option. When this option
66
- * is defined the value is formatted as a signed
67
- * twos complement integer of the given word size
68
- * and the size suffix is appended to the output.
69
- * For example
70
- * format(-1, {notation: 'hex', wordSize: 8}) === '0xffi8'.
71
- * Default value is undefined.
72
- * {number} precision A number between 0 and 16 to round
73
- * the digits of the number.
74
- * In case of notations 'exponential',
75
- * 'engineering', and 'auto',
76
- * `precision` defines the total
77
- * number of significant digits returned.
78
- * In case of notation 'fixed',
79
- * `precision` defines the number of
80
- * significant digits after the decimal
81
- * point.
82
- * `precision` is undefined by default.
83
- * {number} lowerExp Exponent determining the lower boundary
84
- * for formatting a value with an exponent
85
- * when `notation='auto`.
86
- * Default value is `-3`.
87
- * {number} upperExp Exponent determining the upper boundary
88
- * for formatting a value with an exponent
89
- * when `notation='auto`.
90
- * Default value is `5`.
91
- * {Function} fn A custom formatting function. Can be used to override the
92
- * built-in notations. Function `fn` is called with `value` as
93
- * parameter and must return a string. Is useful for example to
94
- * format all values inside a matrix in a particular way.
95
- *
96
- * Examples:
97
- *
98
- * format(6.4) // '6.4'
99
- * format(1240000) // '1.24e6'
100
- * format(1/3) // '0.3333333333333333'
101
- * format(1/3, 3) // '0.333'
102
- * format(21385, 2) // '21000'
103
- * format(12e8, {notation: 'fixed'}) // returns '1200000000'
104
- * format(2.3, {notation: 'fixed', precision: 4}) // returns '2.3000'
105
- * format(52.8, {notation: 'exponential'}) // returns '5.28e+1'
106
- * format(12400, {notation: 'engineering'}) // returns '12.400e+3'
107
- *
108
- * @param {BigNumber} value
109
- * @param {Object | Function | number | BigNumber} [options]
110
- * @return {string} str The formatted value
111
- */
112
- export declare function format(value: unknown, options?: unknown): string;
113
- /**
114
- * Format a BigNumber in engineering notation. Like '1.23e+6', '2.3e+0', '3.500e-3'
115
- * @param {BigNumber} value
116
- * @param {number} [precision] Optional number of significant figures to return.
117
- */
118
- export declare function toEngineering(value: BigNumberValue, precision?: number): string;
119
- /**
120
- * Format a number in exponential notation. Like '1.23e+5', '2.3e+0', '3.500e-3'
121
- * @param {BigNumber} value
122
- * @param {number} [precision] Number of digits in formatted output.
123
- * If not provided, the maximum available digits
124
- * is used.
125
- * @returns {string} str
126
- */
127
- export declare function toExponential(value: BigNumberValue, precision?: number): string;
128
- /**
129
- * Format a number with fixed notation.
130
- * @param {BigNumber} value
131
- * @param {number} [precision=undefined] Optional number of decimals after the
132
- * decimal point. Undefined by default.
133
- */
134
- export declare function toFixed(value: BigNumberValue, precision?: number): string;
135
- export {};
136
- //# sourceMappingURL=formatter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../../../src/utils/bignumber/formatter.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,UAAU,cAAc;IACtB,CAAC,EAAE,MAAM,CAAC;IACV,WAAW,EAAE,KAAK,KAAK,EAAE,MAAM,GAAG,MAAM,KAAK,cAAc,CAAC;IAC5D,QAAQ,IAAI,OAAO,CAAC;IACpB,KAAK,IAAI,OAAO,CAAC;IACjB,MAAM,IAAI,OAAO,CAAC;IAClB,SAAS,IAAI,OAAO,CAAC;IACrB,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,GAAG,OAAO,CAAC;IAC5C,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,GAAG,OAAO,CAAC;IACrD,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,GAAG,OAAO,CAAC;IAClD,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,GAAG,cAAc,CAAC;IACpD,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,GAAG,cAAc,CAAC;IACpD,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,GAAG,cAAc,CAAC;IACpD,GAAG,CAAC,GAAG,EA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