@basemaps/cli-vector 8.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.
@@ -0,0 +1,348 @@
1
+ import { z } from 'zod';
2
+ export declare const zStyling: z.ZodObject<{
3
+ minZoom: z.ZodNumber;
4
+ maxZoom: z.ZodNumber;
5
+ detail: z.ZodOptional<z.ZodNumber>;
6
+ }, "strip", z.ZodTypeAny, {
7
+ minZoom: number;
8
+ maxZoom: number;
9
+ detail?: number | undefined;
10
+ }, {
11
+ minZoom: number;
12
+ maxZoom: number;
13
+ detail?: number | undefined;
14
+ }>;
15
+ export declare const zTags: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodBoolean]>>;
16
+ export declare const zAttributes: z.ZodRecord<z.ZodString, z.ZodString>;
17
+ export declare const zSpecialTag: z.ZodObject<{
18
+ condition: z.ZodString;
19
+ tags: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodBoolean]>>;
20
+ }, "strip", z.ZodTypeAny, {
21
+ condition: string;
22
+ tags: Record<string, string | boolean>;
23
+ }, {
24
+ condition: string;
25
+ tags: Record<string, string | boolean>;
26
+ }>;
27
+ export declare const zSimplify: z.ZodObject<{
28
+ style: z.ZodObject<{
29
+ minZoom: z.ZodNumber;
30
+ maxZoom: z.ZodNumber;
31
+ detail: z.ZodOptional<z.ZodNumber>;
32
+ }, "strip", z.ZodTypeAny, {
33
+ minZoom: number;
34
+ maxZoom: number;
35
+ detail?: number | undefined;
36
+ }, {
37
+ minZoom: number;
38
+ maxZoom: number;
39
+ detail?: number | undefined;
40
+ }>;
41
+ tolerance: z.ZodOptional<z.ZodNumber>;
42
+ }, "strip", z.ZodTypeAny, {
43
+ style: {
44
+ minZoom: number;
45
+ maxZoom: number;
46
+ detail?: number | undefined;
47
+ };
48
+ tolerance?: number | undefined;
49
+ }, {
50
+ style: {
51
+ minZoom: number;
52
+ maxZoom: number;
53
+ detail?: number | undefined;
54
+ };
55
+ tolerance?: number | undefined;
56
+ }>;
57
+ export declare const zLayer: z.ZodObject<{
58
+ id: z.ZodString;
59
+ name: z.ZodString;
60
+ source: z.ZodString;
61
+ tags: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodBoolean]>>;
62
+ attributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
63
+ style: z.ZodObject<{
64
+ minZoom: z.ZodNumber;
65
+ maxZoom: z.ZodNumber;
66
+ detail: z.ZodOptional<z.ZodNumber>;
67
+ }, "strip", z.ZodTypeAny, {
68
+ minZoom: number;
69
+ maxZoom: number;
70
+ detail?: number | undefined;
71
+ }, {
72
+ minZoom: number;
73
+ maxZoom: number;
74
+ detail?: number | undefined;
75
+ }>;
76
+ simplify: z.ZodOptional<z.ZodArray<z.ZodObject<{
77
+ style: z.ZodObject<{
78
+ minZoom: z.ZodNumber;
79
+ maxZoom: z.ZodNumber;
80
+ detail: z.ZodOptional<z.ZodNumber>;
81
+ }, "strip", z.ZodTypeAny, {
82
+ minZoom: number;
83
+ maxZoom: number;
84
+ detail?: number | undefined;
85
+ }, {
86
+ minZoom: number;
87
+ maxZoom: number;
88
+ detail?: number | undefined;
89
+ }>;
90
+ tolerance: z.ZodOptional<z.ZodNumber>;
91
+ }, "strip", z.ZodTypeAny, {
92
+ style: {
93
+ minZoom: number;
94
+ maxZoom: number;
95
+ detail?: number | undefined;
96
+ };
97
+ tolerance?: number | undefined;
98
+ }, {
99
+ style: {
100
+ minZoom: number;
101
+ maxZoom: number;
102
+ detail?: number | undefined;
103
+ };
104
+ tolerance?: number | undefined;
105
+ }>, "many">>;
106
+ tippecanoe: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
107
+ }, "strip", z.ZodTypeAny, {
108
+ tags: Record<string, string | boolean>;
109
+ style: {
110
+ minZoom: number;
111
+ maxZoom: number;
112
+ detail?: number | undefined;
113
+ };
114
+ id: string;
115
+ name: string;
116
+ source: string;
117
+ attributes?: Record<string, string> | undefined;
118
+ simplify?: {
119
+ style: {
120
+ minZoom: number;
121
+ maxZoom: number;
122
+ detail?: number | undefined;
123
+ };
124
+ tolerance?: number | undefined;
125
+ }[] | undefined;
126
+ tippecanoe?: string[] | undefined;
127
+ }, {
128
+ tags: Record<string, string | boolean>;
129
+ style: {
130
+ minZoom: number;
131
+ maxZoom: number;
132
+ detail?: number | undefined;
133
+ };
134
+ id: string;
135
+ name: string;
136
+ source: string;
137
+ attributes?: Record<string, string> | undefined;
138
+ simplify?: {
139
+ style: {
140
+ minZoom: number;
141
+ maxZoom: number;
142
+ detail?: number | undefined;
143
+ };
144
+ tolerance?: number | undefined;
145
+ }[] | undefined;
146
+ tippecanoe?: string[] | undefined;
147
+ }>;
148
+ export declare const zSchema: z.ZodObject<{
149
+ name: z.ZodString;
150
+ metadata: z.ZodObject<{
151
+ attributes: z.ZodArray<z.ZodString, "many">;
152
+ }, "strip", z.ZodTypeAny, {
153
+ attributes: string[];
154
+ }, {
155
+ attributes: string[];
156
+ }>;
157
+ simplify: z.ZodOptional<z.ZodArray<z.ZodObject<{
158
+ style: z.ZodObject<{
159
+ minZoom: z.ZodNumber;
160
+ maxZoom: z.ZodNumber;
161
+ detail: z.ZodOptional<z.ZodNumber>;
162
+ }, "strip", z.ZodTypeAny, {
163
+ minZoom: number;
164
+ maxZoom: number;
165
+ detail?: number | undefined;
166
+ }, {
167
+ minZoom: number;
168
+ maxZoom: number;
169
+ detail?: number | undefined;
170
+ }>;
171
+ tolerance: z.ZodOptional<z.ZodNumber>;
172
+ }, "strip", z.ZodTypeAny, {
173
+ style: {
174
+ minZoom: number;
175
+ maxZoom: number;
176
+ detail?: number | undefined;
177
+ };
178
+ tolerance?: number | undefined;
179
+ }, {
180
+ style: {
181
+ minZoom: number;
182
+ maxZoom: number;
183
+ detail?: number | undefined;
184
+ };
185
+ tolerance?: number | undefined;
186
+ }>, "many">>;
187
+ layers: z.ZodArray<z.ZodObject<{
188
+ id: z.ZodString;
189
+ name: z.ZodString;
190
+ source: z.ZodString;
191
+ tags: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodBoolean]>>;
192
+ attributes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
193
+ style: z.ZodObject<{
194
+ minZoom: z.ZodNumber;
195
+ maxZoom: z.ZodNumber;
196
+ detail: z.ZodOptional<z.ZodNumber>;
197
+ }, "strip", z.ZodTypeAny, {
198
+ minZoom: number;
199
+ maxZoom: number;
200
+ detail?: number | undefined;
201
+ }, {
202
+ minZoom: number;
203
+ maxZoom: number;
204
+ detail?: number | undefined;
205
+ }>;
206
+ simplify: z.ZodOptional<z.ZodArray<z.ZodObject<{
207
+ style: z.ZodObject<{
208
+ minZoom: z.ZodNumber;
209
+ maxZoom: z.ZodNumber;
210
+ detail: z.ZodOptional<z.ZodNumber>;
211
+ }, "strip", z.ZodTypeAny, {
212
+ minZoom: number;
213
+ maxZoom: number;
214
+ detail?: number | undefined;
215
+ }, {
216
+ minZoom: number;
217
+ maxZoom: number;
218
+ detail?: number | undefined;
219
+ }>;
220
+ tolerance: z.ZodOptional<z.ZodNumber>;
221
+ }, "strip", z.ZodTypeAny, {
222
+ style: {
223
+ minZoom: number;
224
+ maxZoom: number;
225
+ detail?: number | undefined;
226
+ };
227
+ tolerance?: number | undefined;
228
+ }, {
229
+ style: {
230
+ minZoom: number;
231
+ maxZoom: number;
232
+ detail?: number | undefined;
233
+ };
234
+ tolerance?: number | undefined;
235
+ }>, "many">>;
236
+ tippecanoe: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
237
+ }, "strip", z.ZodTypeAny, {
238
+ tags: Record<string, string | boolean>;
239
+ style: {
240
+ minZoom: number;
241
+ maxZoom: number;
242
+ detail?: number | undefined;
243
+ };
244
+ id: string;
245
+ name: string;
246
+ source: string;
247
+ attributes?: Record<string, string> | undefined;
248
+ simplify?: {
249
+ style: {
250
+ minZoom: number;
251
+ maxZoom: number;
252
+ detail?: number | undefined;
253
+ };
254
+ tolerance?: number | undefined;
255
+ }[] | undefined;
256
+ tippecanoe?: string[] | undefined;
257
+ }, {
258
+ tags: Record<string, string | boolean>;
259
+ style: {
260
+ minZoom: number;
261
+ maxZoom: number;
262
+ detail?: number | undefined;
263
+ };
264
+ id: string;
265
+ name: string;
266
+ source: string;
267
+ attributes?: Record<string, string> | undefined;
268
+ simplify?: {
269
+ style: {
270
+ minZoom: number;
271
+ maxZoom: number;
272
+ detail?: number | undefined;
273
+ };
274
+ tolerance?: number | undefined;
275
+ }[] | undefined;
276
+ tippecanoe?: string[] | undefined;
277
+ }>, "many">;
278
+ }, "strip", z.ZodTypeAny, {
279
+ name: string;
280
+ metadata: {
281
+ attributes: string[];
282
+ };
283
+ layers: {
284
+ tags: Record<string, string | boolean>;
285
+ style: {
286
+ minZoom: number;
287
+ maxZoom: number;
288
+ detail?: number | undefined;
289
+ };
290
+ id: string;
291
+ name: string;
292
+ source: string;
293
+ attributes?: Record<string, string> | undefined;
294
+ simplify?: {
295
+ style: {
296
+ minZoom: number;
297
+ maxZoom: number;
298
+ detail?: number | undefined;
299
+ };
300
+ tolerance?: number | undefined;
301
+ }[] | undefined;
302
+ tippecanoe?: string[] | undefined;
303
+ }[];
304
+ simplify?: {
305
+ style: {
306
+ minZoom: number;
307
+ maxZoom: number;
308
+ detail?: number | undefined;
309
+ };
310
+ tolerance?: number | undefined;
311
+ }[] | undefined;
312
+ }, {
313
+ name: string;
314
+ metadata: {
315
+ attributes: string[];
316
+ };
317
+ layers: {
318
+ tags: Record<string, string | boolean>;
319
+ style: {
320
+ minZoom: number;
321
+ maxZoom: number;
322
+ detail?: number | undefined;
323
+ };
324
+ id: string;
325
+ name: string;
326
+ source: string;
327
+ attributes?: Record<string, string> | undefined;
328
+ simplify?: {
329
+ style: {
330
+ minZoom: number;
331
+ maxZoom: number;
332
+ detail?: number | undefined;
333
+ };
334
+ tolerance?: number | undefined;
335
+ }[] | undefined;
336
+ tippecanoe?: string[] | undefined;
337
+ }[];
338
+ simplify?: {
339
+ style: {
340
+ minZoom: number;
341
+ maxZoom: number;
342
+ detail?: number | undefined;
343
+ };
344
+ tolerance?: number | undefined;
345
+ }[] | undefined;
346
+ }>;
347
+ export type zTypeLayer = z.infer<typeof zLayer>;
348
+ export type zTypeSchema = z.infer<typeof zSchema>;
@@ -0,0 +1,35 @@
1
+ import { z } from 'zod';
2
+ export const zStyling = z.object({
3
+ minZoom: z.number(),
4
+ maxZoom: z.number(),
5
+ detail: z.number().optional(),
6
+ });
7
+ export const zTags = z.record(z.string().or(z.boolean()));
8
+ export const zAttributes = z.record(z.string());
9
+ export const zSpecialTag = z.object({
10
+ condition: z.string(),
11
+ tags: zTags,
12
+ });
13
+ export const zSimplify = z.object({
14
+ style: zStyling,
15
+ tolerance: z.number().optional(),
16
+ });
17
+ export const zLayer = z.object({
18
+ id: z.string(),
19
+ name: z.string(),
20
+ source: z.string(),
21
+ tags: zTags,
22
+ attributes: zAttributes.optional(),
23
+ style: zStyling,
24
+ simplify: z.array(zSimplify).optional(),
25
+ tippecanoe: z.array(z.string()).optional(),
26
+ });
27
+ export const zSchema = z.object({
28
+ name: z.string(),
29
+ metadata: z.object({
30
+ attributes: z.array(z.string()),
31
+ }),
32
+ simplify: z.array(zSimplify).optional(),
33
+ layers: z.array(zLayer),
34
+ });
35
+ //# sourceMappingURL=parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.js","sourceRoot":"","sources":["../../src/schema-loader/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/B,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC9B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,KAAK,GAAG,CAA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C,KAAK,CAAC,SAAS,CAAC,CAAC,QAAQ,EAAE;IACvC,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC;CACxB,CAAC,CAAC"}
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Vector layer zoom level and detail setting
3
+ */
4
+ export interface Styling {
5
+ minZoom: number;
6
+ maxZoom: number;
7
+ detail?: number;
8
+ }
9
+ /**
10
+ * Schema tags for vector layer
11
+ * @example Shortbread
12
+ * {
13
+ * "kind": "wood"
14
+ * }
15
+ */
16
+ export type Tags = Record<string, string | boolean>;
17
+ /**
18
+ * Attributes to keep in the layer, mapping the existing source attribute name to the new name in the output schema
19
+ * @example
20
+ * {
21
+ * "topo50_id": "id"
22
+ * }
23
+ */
24
+ export type Attributes = Record<string, string>;
25
+ /**
26
+ * Special tagging condition for vector layer
27
+ * @example
28
+ * {
29
+ * "condition": "hway_num != null",
30
+ * "tags": {
31
+ * "kind": "motorway"
32
+ * }
33
+ * }
34
+ */
35
+ export type SpecialTag = {
36
+ condition: string;
37
+ tags: Tags;
38
+ };
39
+ /**
40
+ * Generalization setting for multiple zoom levels tolerance, to set this will simplify the geometry greatly reducing the size of the vector tile
41
+ * @example
42
+ * {
43
+ * "style": {
44
+ * "minZoom": 0,
45
+ * "maxZoom": 1,
46
+ * },
47
+ * "tolerance": 0.5
48
+ * }
49
+ */
50
+ export type Simplify = {
51
+ style: Styling;
52
+ tolerance?: number;
53
+ };
54
+ /**
55
+ * Layer interface for source data layer config metadata
56
+ */
57
+ export interface Layer {
58
+ /** LDS layer id */
59
+ id: string;
60
+ /** LDS layer version */
61
+ version?: number;
62
+ /** layer name */
63
+ name: string;
64
+ /** Location of the layers paths, could be locate or s3.*/
65
+ source: string;
66
+ /** new tags added to layer, with key value pair, like Class:Wood */
67
+ tags: Tags;
68
+ /** existing attributes to keep, with key(existing attribute), value(renamed attribute), if key !== value, map the attribute name to value */
69
+ attributes?: Attributes;
70
+ /** layer zoom level and details */
71
+ style: Styling;
72
+ /** Generalization setting for multiple zoom levels tolerance */
73
+ simplify?: Simplify[];
74
+ /** Tippecanoe transform options */
75
+ tippecanoe?: string[];
76
+ /** Metrics data during the process, will capture into the stac once processed */
77
+ metrics?: {
78
+ input: number;
79
+ output: number;
80
+ };
81
+ /** cached mbtile location */
82
+ cache?: URL;
83
+ /** true for layer over 2GB, which will require separated node to process */
84
+ largeLayer?: boolean;
85
+ }
86
+ /**
87
+ * Schema metadata for vector layer
88
+ *
89
+ */
90
+ export interface SchemaMetadata {
91
+ /** All the attributes that is available for this layer, could be mapped from different attribute from source layer */
92
+ attributes: string[];
93
+ }
94
+ /**
95
+ * Schema interface for single vector layer that merged from multiple source layers like poi, street, building
96
+ *
97
+ */
98
+ export interface Schema {
99
+ /** Schema name */
100
+ name: string;
101
+ /** Schema metadata */
102
+ metadata: SchemaMetadata;
103
+ /** Generalization setting for multiple zoom levels tolerance, this will apply to all individual layers as default if no simplify defined. */
104
+ simplify?: Simplify[];
105
+ /** All individual layers that combined for the Schema */
106
+ layers: Layer[];
107
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/schema-loader/schema.ts"],"names":[],"mappings":""}
@@ -0,0 +1,21 @@
1
+ import { LogType } from '@basemaps/shared';
2
+ import { Schema } from './schema.js';
3
+ export declare class SchemaLoader {
4
+ path: URL;
5
+ logger: LogType;
6
+ schemas: Schema[];
7
+ cache?: URL;
8
+ constructor(path: URL, logger: LogType, cache?: URL);
9
+ /**
10
+ * Read the json schema from the path
11
+ *
12
+ */
13
+ private readJsonSchema;
14
+ /**
15
+ * Prepare the schema with additional information
16
+ * Add cache path, layer id, and version for lds-cache layer in path
17
+ *
18
+ */
19
+ private prepareSchema;
20
+ load(): Promise<Schema[]>;
21
+ }
@@ -0,0 +1,114 @@
1
+ import { sha256base58 } from '@basemaps/config';
2
+ import { fsa } from '@basemaps/shared';
3
+ import { CliInfo } from '@basemaps/shared/build/cli/info.js';
4
+ import { z } from 'zod';
5
+ import { lds, LDS_CACHE_BUCKET } from '../extract/extract.js';
6
+ import { zSchema } from './parser.js';
7
+ const LARGE_LAYER_SIZE = 1024 * 1024 * 1024; // processing for large layers that over 1GB
8
+ export class SchemaLoader {
9
+ constructor(path, logger, cache) {
10
+ Object.defineProperty(this, "path", {
11
+ enumerable: true,
12
+ configurable: true,
13
+ writable: true,
14
+ value: void 0
15
+ });
16
+ Object.defineProperty(this, "logger", {
17
+ enumerable: true,
18
+ configurable: true,
19
+ writable: true,
20
+ value: void 0
21
+ });
22
+ Object.defineProperty(this, "schemas", {
23
+ enumerable: true,
24
+ configurable: true,
25
+ writable: true,
26
+ value: []
27
+ });
28
+ Object.defineProperty(this, "cache", {
29
+ enumerable: true,
30
+ configurable: true,
31
+ writable: true,
32
+ value: void 0
33
+ });
34
+ this.path = path;
35
+ this.logger = logger;
36
+ this.cache = cache;
37
+ }
38
+ /**
39
+ * Read the json schema from the path
40
+ *
41
+ */
42
+ async readJsonSchema() {
43
+ this.logger.info({ path: this.path.href }, 'SchemaLoader: ReadJsonSchema');
44
+ const files = await fsa.toArray(fsa.list(this.path));
45
+ for (const file of files) {
46
+ if (file.href.endsWith('.json')) {
47
+ const schema = await fsa.readJson(file);
48
+ // Validate the json
49
+ try {
50
+ const parsed = zSchema.parse(schema);
51
+ this.schemas.push(parsed);
52
+ }
53
+ catch (e) {
54
+ if (e instanceof z.ZodError) {
55
+ // Thrown error
56
+ throw new Error(`Schema ${file.href} is invalid: ${e.message}`);
57
+ }
58
+ }
59
+ }
60
+ }
61
+ return this.schemas;
62
+ }
63
+ /**
64
+ * Prepare the schema with additional information
65
+ * Add cache path, layer id, and version for lds-cache layer in path
66
+ *
67
+ */
68
+ async prepareSchema() {
69
+ this.logger.info({ path: this.path.href }, 'SchemaLoader: PrepareSchema');
70
+ const files = await lds.getLdsCacheFiles();
71
+ for (const schema of this.schemas) {
72
+ this.logger.info({ layer: schema.name }, 'SchemaLoader: PrepareLayer');
73
+ if (schema.layers == null)
74
+ continue;
75
+ for (const layer of schema.layers) {
76
+ // Set layer simplify
77
+ if (schema.simplify != null && layer.simplify == null)
78
+ layer.simplify = schema.simplify;
79
+ // Set layer path to the latest layer in lds-cache
80
+ const isLdsFile = layer.source.startsWith(LDS_CACHE_BUCKET);
81
+ if (isLdsFile) {
82
+ const file = files.get(layer.id);
83
+ if (file == null)
84
+ throw new Error(`Layer ${layer.id} is not exist in lds cache.`);
85
+ // Set the layer path to the latest layer
86
+ layer.version = file.version;
87
+ layer.source = file.filePath.href;
88
+ }
89
+ // Check existence of the layer path and set file size for larger layers
90
+ const fileInfo = await fsa.head(new URL(layer.source));
91
+ if (fileInfo == null)
92
+ throw new Error(`Layer ${layer.id} path ${layer.source} does not exist`);
93
+ if (fileInfo.size != null && fileInfo.size > LARGE_LAYER_SIZE)
94
+ layer.largeLayer = true;
95
+ // Set the cache path for the layer
96
+ const configHash = sha256base58(JSON.stringify({ ...layer, version: CliInfo.version }));
97
+ if (this.cache != null) {
98
+ const fileName = isLdsFile
99
+ ? `${layer.id}_${layer.version}_${configHash}.mbtiles`
100
+ : `${layer.id}_${configHash}.mbtiles`;
101
+ layer.cache = new URL(fileName, this.cache);
102
+ }
103
+ }
104
+ }
105
+ return this.schemas;
106
+ }
107
+ async load() {
108
+ // Load the schema
109
+ await this.readJsonSchema();
110
+ // Prepare the schema with additional information
111
+ return this.prepareSchema();
112
+ }
113
+ }
114
+ //# sourceMappingURL=schema.loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.loader.js","sourceRoot":"","sources":["../../src/schema-loader/schema.loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,GAAG,EAAW,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAC7D,OAAO,EAAE,CAAC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