@racedayready/workouts 0.1.0 → 0.1.2
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.
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/workouts/swim-workout-types.d.ts.map +1 -1
- package/dist/workouts/swim-workout-types.js +0 -1
- package/dist/workouts/swim-workout-types.js.map +1 -1
- package/dist/workouts/workout-types.d.ts +1 -2
- package/dist/workouts/workout-types.d.ts.map +1 -1
- package/dist/workouts/workout-types.js.map +1 -1
- package/dist/workouts/workout-utils.d.ts +4 -0
- package/dist/workouts/workout-utils.d.ts.map +1 -1
- package/dist/workouts/workout-utils.js +30 -0
- package/dist/workouts/workout-utils.js.map +1 -1
- package/dist/workouts/workout-utils.test.d.ts +2 -0
- package/dist/workouts/workout-utils.test.d.ts.map +1 -0
- package/dist/workouts/workout-utils.test.js +61 -0
- package/dist/workouts/workout-utils.test.js.map +1 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
|
+
export * from './workouts/bike-workout-types';
|
|
2
|
+
export * from './workouts/run-workout-types';
|
|
3
|
+
export * from './workouts/swim-workout-types';
|
|
1
4
|
export * from './workouts/workout-types';
|
|
5
|
+
export { getTotalDistanceMeters, getTotalDurationSeconds, getTotalSegmentCount, } from './workouts/workout-utils';
|
|
2
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAC;AACzC,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,0BAA0B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
|
+
export * from './workouts/bike-workout-types';
|
|
2
|
+
export * from './workouts/run-workout-types';
|
|
3
|
+
export * from './workouts/swim-workout-types';
|
|
1
4
|
export * from './workouts/workout-types';
|
|
5
|
+
export { getTotalDistanceMeters, getTotalDurationSeconds, getTotalSegmentCount, } from './workouts/workout-utils';
|
|
2
6
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAC;AACzC,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,0BAA0B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swim-workout-types.d.ts","sourceRoot":"","sources":["../../src/workouts/swim-workout-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"swim-workout-types.d.ts","sourceRoot":"","sources":["../../src/workouts/swim-workout-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,gBAAgB;;;;;EAA8C,CAAC;AAC5E,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;iBAQ1C,CAAC;AACH,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { WorkoutIndividualItemBaseSchema } from './workout-base-types';
|
|
3
|
-
// TODO: More?
|
|
4
3
|
export const SwimStrokeSchema = z.enum(['free', 'kick', 'drill', 'choice']);
|
|
5
4
|
export const SwimWorkoutIndividualItemSchema = WorkoutIndividualItemBaseSchema.extend({
|
|
6
5
|
discipline: z.literal('swim'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swim-workout-types.js","sourceRoot":"","sources":["../../src/workouts/swim-workout-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,+BAA+B,EAAE,MAAM,sBAAsB,CAAC;AAEvE,
|
|
1
|
+
{"version":3,"file":"swim-workout-types.js","sourceRoot":"","sources":["../../src/workouts/swim-workout-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,+BAA+B,EAAE,MAAM,sBAAsB,CAAC;AAEvE,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC;AAG5E,MAAM,CAAC,MAAM,+BAA+B,GAAG,+BAA+B,CAAC,MAAM,CAAC;IACpF,UAAU,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;IAC7B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9B,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IAC3C,gBAAgB;IAChB,sBAAsB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACpD,MAAM,EAAE,gBAAgB,CAAC,QAAQ,EAAE;IACnC,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;CAC3C,CAAC,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
export type WorkoutCompletionStatus = 'over' | 'complete' | 'incomplete' | 'missed' | 'planned' | 'unplanned' | 'suggested';
|
|
3
2
|
export declare const WorkoutIndividualItemSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
4
3
|
type: z.ZodLiteral<"individual">;
|
|
5
4
|
id: z.ZodDefault<z.ZodString>;
|
|
@@ -163,9 +162,9 @@ export declare const WorkoutSegmentItemSchema: z.ZodUnion<readonly [z.ZodObject<
|
|
|
163
162
|
}, z.core.$strip>], "discipline">]>;
|
|
164
163
|
export type WorkoutSegmentItem = z.infer<typeof WorkoutSegmentItemSchema>;
|
|
165
164
|
export declare const WorkoutDisciplineSchema: z.ZodEnum<{
|
|
166
|
-
bike: "bike";
|
|
167
165
|
run: "run";
|
|
168
166
|
swim: "swim";
|
|
167
|
+
bike: "bike";
|
|
169
168
|
}>;
|
|
170
169
|
export type WorkoutDiscipline = z.infer<typeof WorkoutDisciplineSchema>;
|
|
171
170
|
//# sourceMappingURL=workout-types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workout-types.d.ts","sourceRoot":"","sources":["../../src/workouts/workout-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,
|
|
1
|
+
{"version":3,"file":"workout-types.d.ts","sourceRoot":"","sources":["../../src/workouts/workout-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iCAItC,CAAC;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAEhF,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAMjC,CAAC;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEtE,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mCAGnC,CAAC;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E,eAAO,MAAM,uBAAuB;;;;EAAkC,CAAC;AACvE,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workout-types.js","sourceRoot":"","sources":["../../src/workouts/workout-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,+BAA+B,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,8BAA8B,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAE,+BAA+B,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"workout-types.js","sourceRoot":"","sources":["../../src/workouts/workout-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,+BAA+B,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,8BAA8B,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAE,+BAA+B,EAAE,MAAM,sBAAsB,CAAC;AAEvE,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,kBAAkB,CAAC,YAAY,EAAE;IAC5E,+BAA+B;IAC/B,+BAA+B;IAC/B,8BAA8B;CAC/B,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7C,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;IACxB,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,qBAAqB,CAAC;IAC7C,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IACzC,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;CACtD,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC;IAC9C,sBAAsB;IACtB,2BAA2B;CAC5B,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC"}
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
+
import type { WorkoutSegmentItem } from './workout-types';
|
|
1
2
|
export declare const generateWorkoutItemId: () => string;
|
|
3
|
+
export declare function getTotalDistanceMeters(segments: WorkoutSegmentItem[]): number;
|
|
4
|
+
export declare function getTotalSegmentCount(segments: WorkoutSegmentItem[]): number;
|
|
5
|
+
export declare function getTotalDurationSeconds(segments: WorkoutSegmentItem[]): number;
|
|
2
6
|
//# sourceMappingURL=workout-utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workout-utils.d.ts","sourceRoot":"","sources":["../../src/workouts/workout-utils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,cAAmD,CAAC"}
|
|
1
|
+
{"version":3,"file":"workout-utils.d.ts","sourceRoot":"","sources":["../../src/workouts/workout-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAyB,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAEjF,eAAO,MAAM,qBAAqB,cAAmD,CAAC;AAEtF,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,kBAAkB,EAAE,GAAG,MAAM,CAY7E;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,kBAAkB,EAAE,GAAG,MAAM,CAO3E;AAED,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,kBAAkB,EAAE,GAAG,MAAM,CAU9E"}
|
|
@@ -1,2 +1,32 @@
|
|
|
1
1
|
export const generateWorkoutItemId = () => Math.random().toString(36).substring(2, 9);
|
|
2
|
+
export function getTotalDistanceMeters(segments) {
|
|
3
|
+
return segments.reduce((total, segment) => {
|
|
4
|
+
if (segment.type === 'group') {
|
|
5
|
+
const groupDistance = segment.segments.reduce((sum, item) => {
|
|
6
|
+
return sum + ('target_distance_meters' in item ? (item.target_distance_meters ?? 0) : 0);
|
|
7
|
+
}, 0);
|
|
8
|
+
return total + groupDistance * segment.repeatCount;
|
|
9
|
+
}
|
|
10
|
+
return (total + ('target_distance_meters' in segment ? (segment.target_distance_meters ?? 0) : 0));
|
|
11
|
+
}, 0);
|
|
12
|
+
}
|
|
13
|
+
export function getTotalSegmentCount(segments) {
|
|
14
|
+
return segments.reduce((total, segment) => {
|
|
15
|
+
if (segment.type === 'group') {
|
|
16
|
+
return total + segment.segments.length * segment.repeatCount;
|
|
17
|
+
}
|
|
18
|
+
return total + 1;
|
|
19
|
+
}, 0);
|
|
20
|
+
}
|
|
21
|
+
export function getTotalDurationSeconds(segments) {
|
|
22
|
+
return segments.reduce((total, segment) => {
|
|
23
|
+
if (segment.type === 'group') {
|
|
24
|
+
const groupDuration = segment.segments.reduce((sum, item) => {
|
|
25
|
+
return sum + (item.target_duration_seconds ?? 0);
|
|
26
|
+
}, 0);
|
|
27
|
+
return total + groupDuration * segment.repeatCount;
|
|
28
|
+
}
|
|
29
|
+
return total + (segment.target_duration_seconds ?? 0);
|
|
30
|
+
}, 0);
|
|
31
|
+
}
|
|
2
32
|
//# sourceMappingURL=workout-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workout-utils.js","sourceRoot":"","sources":["../../src/workouts/workout-utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"workout-utils.js","sourceRoot":"","sources":["../../src/workouts/workout-utils.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAEtF,MAAM,UAAU,sBAAsB,CAAC,QAA8B;IACnE,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;QACxC,IAAI,OAAO,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YAC7B,MAAM,aAAa,GAAG,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAW,EAAE,IAA2B,EAAE,EAAE;gBACzF,OAAO,GAAG,GAAG,CAAC,wBAAwB,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,sBAAsB,IAAI,CAAC,CAAC,CAAC,CAAC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C,CAAC,CAAC;AACR,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workout-utils.test.d.ts","sourceRoot":"","sources":["../../src/workouts/workout-utils.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { getTotalDistanceMeters, getTotalDurationSeconds, getTotalSegmentCount, } from './workout-utils';
|
|
3
|
+
const swim = (id, overrides) => ({
|
|
4
|
+
type: 'individual',
|
|
5
|
+
id,
|
|
6
|
+
name: id,
|
|
7
|
+
discipline: 'swim',
|
|
8
|
+
zone: 2,
|
|
9
|
+
...overrides,
|
|
10
|
+
});
|
|
11
|
+
const bike = (id, overrides) => ({
|
|
12
|
+
type: 'individual',
|
|
13
|
+
id,
|
|
14
|
+
name: id,
|
|
15
|
+
discipline: 'bike',
|
|
16
|
+
zone: 4,
|
|
17
|
+
...overrides,
|
|
18
|
+
});
|
|
19
|
+
const group = (repeatCount, segments) => ({
|
|
20
|
+
type: 'group',
|
|
21
|
+
id: 'group',
|
|
22
|
+
repeatCount,
|
|
23
|
+
segments: segments,
|
|
24
|
+
});
|
|
25
|
+
describe('getTotalDistanceMeters', () => {
|
|
26
|
+
it('sums individuals and groups, treating missing distance as 0', () => {
|
|
27
|
+
const segments = [
|
|
28
|
+
swim('warmup', { target_distance_meters: 400 }),
|
|
29
|
+
group(3, [
|
|
30
|
+
swim('fast', { target_distance_meters: 100 }),
|
|
31
|
+
swim('easy', { target_distance_meters: 50 }),
|
|
32
|
+
]),
|
|
33
|
+
bike('tempo'), // no distance field
|
|
34
|
+
];
|
|
35
|
+
expect(getTotalDistanceMeters(segments)).toBe(850);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
describe('getTotalDurationSeconds', () => {
|
|
39
|
+
it('sums individuals and groups, treating missing duration as 0', () => {
|
|
40
|
+
const segments = [
|
|
41
|
+
bike('warmup', { target_duration_seconds: 600 }),
|
|
42
|
+
group(3, [
|
|
43
|
+
bike('on', { target_duration_seconds: 300 }),
|
|
44
|
+
bike('off', { target_duration_seconds: 300 }),
|
|
45
|
+
]),
|
|
46
|
+
swim('cooldown'), // no duration
|
|
47
|
+
];
|
|
48
|
+
expect(getTotalDurationSeconds(segments)).toBe(2400);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
describe('getTotalSegmentCount', () => {
|
|
52
|
+
it('counts individuals as 1 and group segments multiplied by repeatCount', () => {
|
|
53
|
+
const segments = [
|
|
54
|
+
swim('warmup'),
|
|
55
|
+
group(3, [swim('on'), swim('off')]),
|
|
56
|
+
swim('cooldown'),
|
|
57
|
+
];
|
|
58
|
+
expect(getTotalSegmentCount(segments)).toBe(8);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
//# sourceMappingURL=workout-utils.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workout-utils.test.js","sourceRoot":"","sources":["../../src/workouts/workout-utils.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AAGzB,MAAM,IAAI,GAAG,CACX,EAAU,EACV,SAAwF,EACjE,EAAE,CAAC,CAAC;IAC3B,IAAI,EAAE,YAAY;IAClB,EAAE;IACF,IAAI,EAAE,EAAE;IACR,UAAU,EAAE,MAAM;IAClB,IAAI,EAAE,CAAC;IACP,GAAG,SAAS;CACb,CAAC,CAAC;AAEH,MAAM,IAAI,GAAG,CACX,EAAU,EACV,SAAwD,EACjC,EAAE,CAAC,CAAC;IAC3B,IAAI,EAAE,YAAY;IAClB,EAAE;IACF,IAAI,EAAE,EAAE;IACR,UAAU,EAAE,MAAM;IAClB,IAAI,EAAE,CAAC;IACP,GAAG,SAAS;CACb,CAAC,CAAC;AAEH,MA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