@memberjunction/ai 3.3.0 → 4.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 (65) hide show
  1. package/dist/generic/apiKeyDictionary.d.ts +22 -0
  2. package/dist/generic/apiKeyDictionary.d.ts.map +1 -1
  3. package/dist/generic/apiKeyDictionary.js +20 -13
  4. package/dist/generic/apiKeyDictionary.js.map +1 -1
  5. package/dist/generic/baseAudio.d.ts +107 -2
  6. package/dist/generic/baseAudio.d.ts.map +1 -1
  7. package/dist/generic/baseAudio.js +26 -20
  8. package/dist/generic/baseAudio.js.map +1 -1
  9. package/dist/generic/baseDiffusion.d.ts +5 -1
  10. package/dist/generic/baseDiffusion.d.ts.map +1 -1
  11. package/dist/generic/baseDiffusion.js +5 -17
  12. package/dist/generic/baseDiffusion.js.map +1 -1
  13. package/dist/generic/baseEmbeddings.d.ts +25 -2
  14. package/dist/generic/baseEmbeddings.d.ts.map +1 -1
  15. package/dist/generic/baseEmbeddings.js +26 -8
  16. package/dist/generic/baseEmbeddings.js.map +1 -1
  17. package/dist/generic/baseImage.d.ts +262 -2
  18. package/dist/generic/baseImage.d.ts.map +1 -1
  19. package/dist/generic/baseImage.js +83 -20
  20. package/dist/generic/baseImage.js.map +1 -1
  21. package/dist/generic/baseLLM.d.ts +100 -4
  22. package/dist/generic/baseLLM.d.ts.map +1 -1
  23. package/dist/generic/baseLLM.js +122 -14
  24. package/dist/generic/baseLLM.js.map +1 -1
  25. package/dist/generic/baseModel.d.ts +91 -0
  26. package/dist/generic/baseModel.d.ts.map +1 -1
  27. package/dist/generic/baseModel.js +37 -11
  28. package/dist/generic/baseModel.js.map +1 -1
  29. package/dist/generic/baseReranker.d.ts +81 -2
  30. package/dist/generic/baseReranker.d.ts.map +1 -1
  31. package/dist/generic/baseReranker.js +73 -6
  32. package/dist/generic/baseReranker.js.map +1 -1
  33. package/dist/generic/baseVideo.d.ts +24 -1
  34. package/dist/generic/baseVideo.d.ts.map +1 -1
  35. package/dist/generic/baseVideo.js +11 -14
  36. package/dist/generic/baseVideo.js.map +1 -1
  37. package/dist/generic/chat.types.d.ts +291 -2
  38. package/dist/generic/chat.types.d.ts.map +1 -1
  39. package/dist/generic/chat.types.js +105 -32
  40. package/dist/generic/chat.types.js.map +1 -1
  41. package/dist/generic/classify.types.d.ts +5 -2
  42. package/dist/generic/classify.types.d.ts.map +1 -1
  43. package/dist/generic/classify.types.js +8 -11
  44. package/dist/generic/classify.types.js.map +1 -1
  45. package/dist/generic/embed.types.d.ts +1 -1
  46. package/dist/generic/embed.types.js +1 -2
  47. package/dist/generic/errorAnalyzer.d.ts +94 -0
  48. package/dist/generic/errorAnalyzer.d.ts.map +1 -1
  49. package/dist/generic/errorAnalyzer.js +160 -28
  50. package/dist/generic/errorAnalyzer.js.map +1 -1
  51. package/dist/generic/errorTypes.d.ts +116 -0
  52. package/dist/generic/errorTypes.d.ts.map +1 -1
  53. package/dist/generic/errorTypes.js +1 -2
  54. package/dist/generic/reranker.types.d.ts +74 -0
  55. package/dist/generic/reranker.types.d.ts.map +1 -1
  56. package/dist/generic/reranker.types.js +10 -2
  57. package/dist/generic/reranker.types.js.map +1 -1
  58. package/dist/generic/summarize.types.d.ts +5 -2
  59. package/dist/generic/summarize.types.d.ts.map +1 -1
  60. package/dist/generic/summarize.types.js +8 -9
  61. package/dist/generic/summarize.types.js.map +1 -1
  62. package/dist/index.d.ts +15 -15
  63. package/dist/index.js +15 -31
  64. package/dist/index.js.map +1 -1
  65. package/package.json +8 -7
@@ -1,89 +1,349 @@
1
- /// <reference types="node" />
2
- import { BaseModel, BaseResult, ModelUsage } from "./baseModel";
1
+ import { BaseModel, BaseResult, ModelUsage } from "./baseModel.js";
2
+ /**
3
+ * Represents a single generated image from an image generation request.
4
+ * Supports multiple formats for maximum flexibility with different providers.
5
+ */
3
6
  export declare class GeneratedImage {
7
+ /**
8
+ * Raw binary image data. Either data or url will be populated, not both.
9
+ */
4
10
  data?: Buffer;
11
+ /**
12
+ * Base64-encoded image data. Convenience representation of the data field.
13
+ * If data is populated, base64 will also be populated with the encoded value.
14
+ */
5
15
  base64?: string;
16
+ /**
17
+ * URL to the generated image. Some providers return URLs instead of direct data.
18
+ * Either url or data will be populated, not both.
19
+ * URLs may be temporary and expire after a period of time.
20
+ */
6
21
  url?: string;
22
+ /**
23
+ * The image format/encoding
24
+ */
7
25
  format: 'png' | 'jpg' | 'jpeg' | 'webp' | 'gif';
26
+ /**
27
+ * Width of the generated image in pixels
28
+ */
8
29
  width?: number;
30
+ /**
31
+ * Height of the generated image in pixels
32
+ */
9
33
  height?: number;
34
+ /**
35
+ * Provider-specific index when multiple images are generated
36
+ */
10
37
  index?: number;
38
+ /**
39
+ * Optional content filter results from the provider
40
+ */
11
41
  contentFilterResults?: ContentFilterResult;
12
42
  }
43
+ /**
44
+ * Content filter/safety results from image generation
45
+ */
13
46
  export interface ContentFilterResult {
47
+ /**
48
+ * Whether the image was filtered/blocked
49
+ */
14
50
  filtered: boolean;
51
+ /**
52
+ * Reason for filtering if applicable
53
+ */
15
54
  reason?: string;
55
+ /**
56
+ * Provider-specific category information
57
+ */
16
58
  categories?: Record<string, boolean>;
17
59
  }
60
+ /**
61
+ * Result of an image generation request
62
+ */
18
63
  export declare class ImageGenerationResult extends BaseResult {
64
+ /**
65
+ * Array of generated images. May contain multiple images if n > 1 was requested.
66
+ */
19
67
  images: GeneratedImage[];
68
+ /**
69
+ * Some providers (like OpenAI DALL-E 3) may revise the prompt for safety or quality.
70
+ * The revised prompt used for generation is returned here.
71
+ */
20
72
  revisedPrompt?: string;
73
+ /**
74
+ * Usage information if provided by the model
75
+ */
21
76
  usage?: ModelUsage;
77
+ /**
78
+ * Provider-specific metadata
79
+ */
22
80
  metadata?: Record<string, unknown>;
23
81
  }
82
+ /**
83
+ * Size specification for image generation.
84
+ * Common sizes supported by most providers.
85
+ */
24
86
  export type ImageSize = '256x256' | '512x512' | '1024x1024' | '1024x1792' | '1792x1024' | '1536x1024' | '1024x1536' | string;
87
+ /**
88
+ * Quality level for image generation
89
+ */
25
90
  export type ImageQuality = 'standard' | 'hd' | 'low' | 'medium' | 'high';
91
+ /**
92
+ * Style preset for image generation
93
+ */
26
94
  export type ImageStyle = 'vivid' | 'natural' | 'photorealistic' | 'artistic' | 'anime' | string;
95
+ /**
96
+ * Response format - how the generated image should be returned
97
+ */
27
98
  export type ImageResponseFormat = 'url' | 'b64_json' | 'buffer';
99
+ /**
100
+ * Parameters for text-to-image generation
101
+ */
28
102
  export declare class ImageGenerationParams {
103
+ /**
104
+ * Model name/ID to use for generation
105
+ */
29
106
  model?: string;
107
+ /**
108
+ * Text prompt describing the image to generate. Required.
109
+ */
30
110
  prompt: string;
111
+ /**
112
+ * Negative prompt - things to avoid in the generated image.
113
+ * Not all providers support this.
114
+ */
31
115
  negativePrompt?: string;
116
+ /**
117
+ * Number of images to generate. Default is 1.
118
+ * Some providers have limits on the maximum number.
119
+ */
32
120
  n?: number;
121
+ /**
122
+ * Size of the generated image(s)
123
+ */
33
124
  size?: ImageSize;
125
+ /**
126
+ * Quality level for the generated image
127
+ */
34
128
  quality?: ImageQuality;
129
+ /**
130
+ * Style preset for the generated image
131
+ */
35
132
  style?: ImageStyle;
133
+ /**
134
+ * How the generated image should be returned
135
+ */
36
136
  outputFormat?: ImageResponseFormat;
137
+ /**
138
+ * Optional seed for reproducible generation.
139
+ * Not all providers support seeding.
140
+ */
37
141
  seed?: number;
142
+ /**
143
+ * Aspect ratio as an alternative to explicit size.
144
+ * Format: "width:height" e.g., "16:9", "1:1", "9:16"
145
+ */
38
146
  aspectRatio?: string;
147
+ /**
148
+ * User identifier for tracking/abuse prevention
149
+ */
39
150
  user?: string;
151
+ /**
152
+ * Provider-specific additional parameters
153
+ */
40
154
  providerOptions?: Record<string, unknown>;
41
155
  }
156
+ /**
157
+ * Parameters for image editing/inpainting
158
+ */
42
159
  export declare class ImageEditParams {
160
+ /**
161
+ * Model name/ID to use for editing
162
+ */
43
163
  model?: string;
164
+ /**
165
+ * The original image to edit. Can be a Buffer, base64 string, or URL.
166
+ */
44
167
  image: Buffer | string;
168
+ /**
169
+ * Text prompt describing the edit to make
170
+ */
45
171
  prompt: string;
172
+ /**
173
+ * Mask image indicating which areas to edit.
174
+ * Transparent/white areas will be regenerated.
175
+ * Can be a Buffer, base64 string, or URL.
176
+ */
46
177
  mask?: Buffer | string;
178
+ /**
179
+ * Negative prompt - things to avoid
180
+ */
47
181
  negativePrompt?: string;
182
+ /**
183
+ * Number of edited images to generate
184
+ */
48
185
  n?: number;
186
+ /**
187
+ * Size of the output image(s)
188
+ */
49
189
  size?: ImageSize;
190
+ /**
191
+ * How the result should be returned
192
+ */
50
193
  outputFormat?: ImageResponseFormat;
194
+ /**
195
+ * Provider-specific additional parameters
196
+ */
51
197
  providerOptions?: Record<string, unknown>;
52
198
  }
199
+ /**
200
+ * Parameters for creating image variations
201
+ */
53
202
  export declare class ImageVariationParams {
203
+ /**
204
+ * Model name/ID to use for variations
205
+ */
54
206
  model?: string;
207
+ /**
208
+ * The original image to create variations of.
209
+ * Can be a Buffer, base64 string, or URL.
210
+ */
55
211
  image: Buffer | string;
212
+ /**
213
+ * Optional prompt to guide the variation
214
+ */
56
215
  prompt?: string;
216
+ /**
217
+ * Number of variations to generate
218
+ */
57
219
  n?: number;
220
+ /**
221
+ * Size of the output image(s)
222
+ */
58
223
  size?: ImageSize;
224
+ /**
225
+ * How the result should be returned
226
+ */
59
227
  outputFormat?: ImageResponseFormat;
228
+ /**
229
+ * Strength of variation (0-1). Higher values create more different images.
230
+ */
60
231
  strength?: number;
232
+ /**
233
+ * Provider-specific additional parameters
234
+ */
61
235
  providerOptions?: Record<string, unknown>;
62
236
  }
237
+ /**
238
+ * Information about an available image generation model
239
+ */
63
240
  export declare class ImageModelInfo {
241
+ /**
242
+ * Model identifier
243
+ */
64
244
  id: string;
245
+ /**
246
+ * Human-readable model name
247
+ */
65
248
  name: string;
249
+ /**
250
+ * Model description
251
+ */
66
252
  description?: string;
253
+ /**
254
+ * Supported image sizes
255
+ */
67
256
  supportedSizes?: ImageSize[];
257
+ /**
258
+ * Maximum number of images per request
259
+ */
68
260
  maxImages?: number;
261
+ /**
262
+ * Whether the model supports image editing/inpainting
263
+ */
69
264
  supportsEditing?: boolean;
265
+ /**
266
+ * Whether the model supports image variations
267
+ */
70
268
  supportsVariations?: boolean;
269
+ /**
270
+ * Whether the model supports negative prompts
271
+ */
71
272
  supportsNegativePrompt?: boolean;
273
+ /**
274
+ * Whether the model supports seeded generation
275
+ */
72
276
  supportsSeed?: boolean;
73
277
  }
278
+ /**
279
+ * Base class for all image generation models.
280
+ * Each AI provider will have a sub-class implementing the abstract methods.
281
+ * Not all sub-classes will support all methods - use GetSupportedMethods()
282
+ * to determine what methods are available for a specific provider.
283
+ */
74
284
  export declare abstract class BaseImageGenerator extends BaseModel {
285
+ /**
286
+ * Generate image(s) from a text prompt.
287
+ * This is the primary method for text-to-image generation.
288
+ *
289
+ * @param params Parameters controlling the image generation
290
+ * @returns Result containing generated image(s)
291
+ */
75
292
  abstract GenerateImage(params: ImageGenerationParams): Promise<ImageGenerationResult>;
293
+ /**
294
+ * Edit an existing image using a text prompt and optional mask.
295
+ * Also known as inpainting. The mask specifies which areas to regenerate.
296
+ *
297
+ * @param params Parameters for the edit operation
298
+ * @returns Result containing edited image(s)
299
+ * @throws Error if not supported by this provider
300
+ */
76
301
  abstract EditImage(params: ImageEditParams): Promise<ImageGenerationResult>;
302
+ /**
303
+ * Create variations of an existing image.
304
+ * Generates new images that are similar to the input but with variations.
305
+ *
306
+ * @param params Parameters for the variation operation
307
+ * @returns Result containing image variations
308
+ * @throws Error if not supported by this provider
309
+ */
77
310
  abstract CreateVariation(params: ImageVariationParams): Promise<ImageGenerationResult>;
311
+ /**
312
+ * Get information about available image generation models from this provider.
313
+ *
314
+ * @returns Array of available model information
315
+ */
78
316
  abstract GetModels(): Promise<ImageModelInfo[]>;
317
+ /**
318
+ * Get the list of methods supported by this provider.
319
+ * Use this to check capabilities before calling methods that may not be implemented.
320
+ *
321
+ * @returns Array of supported method names
322
+ */
79
323
  abstract GetSupportedMethods(): Promise<string[]>;
324
+ /**
325
+ * Helper method to convert image input (Buffer, base64, or URL) to the format
326
+ * required by the specific provider. Subclasses can override as needed.
327
+ *
328
+ * @param input Image as Buffer, base64 string, or URL
329
+ * @returns Normalized image data
330
+ */
80
331
  protected normalizeImageInput(input: Buffer | string): Promise<{
81
332
  buffer: Buffer;
82
333
  base64: string;
83
334
  }>;
335
+ /**
336
+ * Helper method to create a successful result with proper timing
337
+ */
84
338
  protected createSuccessResult(startTime: Date, images: GeneratedImage[]): ImageGenerationResult;
339
+ /**
340
+ * Helper method to create an error result with proper timing
341
+ */
85
342
  protected createErrorResult(startTime: Date, errorMessage: string): ImageGenerationResult;
86
343
  }
344
+ /**
345
+ * @deprecated Use BaseImageGenerator instead. This class is kept for backward compatibility.
346
+ */
87
347
  export declare abstract class BaseDiffusion extends BaseImageGenerator {
88
348
  }
89
349
  //# sourceMappingURL=baseImage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"baseImage.d.ts","sourceRoot":"","sources":["../../src/generic/baseImage.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAMhE,qBAAa,cAAc;IAIvB,IAAI,CAAC,EAAE,MAAM,CAAC;IAMd,MAAM,CAAC,EAAE,MAAM,CAAC;IAOhB,GAAG,CAAC,EAAE,MAAM,CAAC;IAKb,MAAM,EAAE,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,CAAS;IAKxD,KAAK,CAAC,EAAE,MAAM,CAAC;IAKf,MAAM,CAAC,EAAE,MAAM,CAAC;IAKhB,KAAK,CAAC,EAAE,MAAM,CAAC;IAKf,oBAAoB,CAAC,EAAE,mBAAmB,CAAC;CAC9C;AAKD,MAAM,WAAW,mBAAmB;IAIhC,QAAQ,EAAE,O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AAS,CAAC,mBAAmB,CAAC,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,GAAG,qBAAqB;IAM/F;;OAEG;IACH,SAAS,CAAC,iBAAiB,CAAC,SAAS,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,GAAG,qBAAqB;CAK5F;AAED;;GAEG;AACH,8BAAsB,aAAc,SAAQ,kBAAkB;CAC7D"}
@@ -1,47 +1,101 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseDiffusion = exports.BaseImageGenerator = exports.ImageModelInfo = exports.ImageVariationParams = exports.ImageEditParams = exports.ImageGenerationParams = exports.ImageGenerationResult = exports.GeneratedImage = void 0;
4
- const baseModel_1 = require("./baseModel");
5
- class GeneratedImage {
1
+ import { BaseModel, BaseResult } from "./baseModel.js";
2
+ /**
3
+ * Represents a single generated image from an image generation request.
4
+ * Supports multiple formats for maximum flexibility with different providers.
5
+ */
6
+ export class GeneratedImage {
6
7
  constructor() {
8
+ /**
9
+ * The image format/encoding
10
+ */
7
11
  this.format = 'png';
8
12
  }
9
13
  }
10
- exports.GeneratedImage = GeneratedImage;
11
- class ImageGenerationResult extends baseModel_1.BaseResult {
14
+ /**
15
+ * Result of an image generation request
16
+ */
17
+ export class ImageGenerationResult extends BaseResult {
12
18
  constructor() {
13
19
  super(...arguments);
20
+ /**
21
+ * Array of generated images. May contain multiple images if n > 1 was requested.
22
+ */
14
23
  this.images = [];
15
24
  }
16
25
  }
17
- exports.ImageGenerationResult = ImageGenerationResult;
18
- class ImageGenerationParams {
26
+ /**
27
+ * Parameters for text-to-image generation
28
+ */
29
+ export class ImageGenerationParams {
19
30
  constructor() {
31
+ /**
32
+ * Number of images to generate. Default is 1.
33
+ * Some providers have limits on the maximum number.
34
+ */
20
35
  this.n = 1;
36
+ /**
37
+ * Size of the generated image(s)
38
+ */
21
39
  this.size = '1024x1024';
40
+ /**
41
+ * Quality level for the generated image
42
+ */
22
43
  this.quality = 'standard';
44
+ /**
45
+ * How the generated image should be returned
46
+ */
23
47
  this.outputFormat = 'b64_json';
24
48
  }
25
49
  }
26
- exports.ImageGenerationParams = ImageGenerationParams;
27
- class ImageEditParams {
50
+ /**
51
+ * Parameters for image editing/inpainting
52
+ */
53
+ export class ImageEditParams {
28
54
  constructor() {
55
+ /**
56
+ * Number of edited images to generate
57
+ */
29
58
  this.n = 1;
59
+ /**
60
+ * How the result should be returned
61
+ */
30
62
  this.outputFormat = 'b64_json';
31
63
  }
32
64
  }
33
- exports.ImageEditParams = ImageEditParams;
34
- class ImageVariationParams {
65
+ /**
66
+ * Parameters for creating image variations
67
+ */
68
+ export class ImageVariationParams {
35
69
  constructor() {
70
+ /**
71
+ * Number of variations to generate
72
+ */
36
73
  this.n = 1;
74
+ /**
75
+ * How the result should be returned
76
+ */
37
77
  this.outputFormat = 'b64_json';
38
78
  }
39
79
  }
40
- exports.ImageVariationParams = ImageVariationParams;
41
- class ImageModelInfo {
80
+ /**
81
+ * Information about an available image generation model
82
+ */
83
+ export class ImageModelInfo {
42
84
  }
43
- exports.ImageModelInfo = ImageModelInfo;
44
- class BaseImageGenerator extends baseModel_1.BaseModel {
85
+ /**
86
+ * Base class for all image generation models.
87
+ * Each AI provider will have a sub-class implementing the abstract methods.
88
+ * Not all sub-classes will support all methods - use GetSupportedMethods()
89
+ * to determine what methods are available for a specific provider.
90
+ */
91
+ export class BaseImageGenerator extends BaseModel {
92
+ /**
93
+ * Helper method to convert image input (Buffer, base64, or URL) to the format
94
+ * required by the specific provider. Subclasses can override as needed.
95
+ *
96
+ * @param input Image as Buffer, base64 string, or URL
97
+ * @returns Normalized image data
98
+ */
45
99
  async normalizeImageInput(input) {
46
100
  let buffer;
47
101
  if (Buffer.isBuffer(input)) {
@@ -49,6 +103,7 @@ class BaseImageGenerator extends baseModel_1.BaseModel {
49
103
  }
50
104
  else if (typeof input === 'string') {
51
105
  if (input.startsWith('http://') || input.startsWith('https://')) {
106
+ // Fetch image from URL
52
107
  const response = await fetch(input);
53
108
  if (!response.ok) {
54
109
  throw new Error(`Failed to fetch image from URL: ${response.statusText}`);
@@ -57,6 +112,7 @@ class BaseImageGenerator extends baseModel_1.BaseModel {
57
112
  buffer = Buffer.from(arrayBuffer);
58
113
  }
59
114
  else {
115
+ // Assume base64
60
116
  buffer = Buffer.from(input, 'base64');
61
117
  }
62
118
  }
@@ -68,19 +124,26 @@ class BaseImageGenerator extends baseModel_1.BaseModel {
68
124
  base64: buffer.toString('base64')
69
125
  };
70
126
  }
127
+ /**
128
+ * Helper method to create a successful result with proper timing
129
+ */
71
130
  createSuccessResult(startTime, images) {
72
131
  const result = new ImageGenerationResult(true, startTime, new Date());
73
132
  result.images = images;
74
133
  return result;
75
134
  }
135
+ /**
136
+ * Helper method to create an error result with proper timing
137
+ */
76
138
  createErrorResult(startTime, errorMessage) {
77
139
  const result = new ImageGenerationResult(false, startTime, new Date());
78
140
  result.errorMessage = errorMessage;
79
141
  return result;
80
142
  }
81
143
  }
82
- exports.BaseImageGenerator = BaseImageGenerator;
83
- class BaseDiffusion extends BaseImageGenerator {
144
+ /**
145
+ * @deprecated Use BaseImageGenerator instead. This class is kept for backward compatibility.
146
+ */
147
+ export class BaseDiffusion extends BaseImageGenerator {
84
148
  }
85
- exports.BaseDiffusion = BaseDiffusion;
86
149
  //# sourceMappingURL=baseImage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"baseImage.js","sourceRoot":"","sources":["../../src/generic/baseImage.ts"],"names":[],"mappings":";;;AAAA,2CAAgE;AAMhE,MAAa,cAAc;IAA3B;QAsBI,WAAM,GAA4C,KAAK,CAAC;IAqB5D,CAAC;CAAA;AA3CD,wCA2CC;AAyBD,MAAa,qBAAsB,SAAQ,sBAAU;IAArD;;QAII,WAAM,GAAqB,EAAE,CAAC;IAiBlC,CAAC;CAAA;AArBD,sDAqBC;AAkCD,MAAa,qBAAqB;IAAlC;QAqBI,MAAC,GAAY,CAAC,CAAC;QAKf,SAAI,GAAe,WAAW,CAAC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