@mediaproc/image 1.4.7 → 1.4.8

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 (44) hide show
  1. package/dist/commands/watermark.d.ts.map +1 -1
  2. package/dist/commands/watermark.js +23 -20
  3. package/dist/commands/watermark.js.map +1 -1
  4. package/package.json +6 -6
  5. package/dist/commands/auto-enhance.d.ts +0 -3
  6. package/dist/commands/auto-enhance.d.ts.map +0 -1
  7. package/dist/commands/auto-enhance.js +0 -172
  8. package/dist/commands/auto-enhance.js.map +0 -1
  9. package/dist/commands/auto-orient.d.ts +0 -3
  10. package/dist/commands/auto-orient.d.ts.map +0 -1
  11. package/dist/commands/auto-orient.js +0 -131
  12. package/dist/commands/auto-orient.js.map +0 -1
  13. package/dist/commands/grid.d.ts +0 -3
  14. package/dist/commands/grid.d.ts.map +0 -1
  15. package/dist/commands/grid.js +0 -230
  16. package/dist/commands/grid.js.map +0 -1
  17. package/dist/commands/smart-crop.d.ts +0 -3
  18. package/dist/commands/smart-crop.d.ts.map +0 -1
  19. package/dist/commands/smart-crop.js +0 -158
  20. package/dist/commands/smart-crop.js.map +0 -1
  21. package/dist/commands/stack.d.ts +0 -3
  22. package/dist/commands/stack.d.ts.map +0 -1
  23. package/dist/commands/stack.js +0 -242
  24. package/dist/commands/stack.js.map +0 -1
  25. package/dist/utils/branding.d.ts +0 -6
  26. package/dist/utils/branding.d.ts.map +0 -1
  27. package/dist/utils/branding.js +0 -45
  28. package/dist/utils/branding.js.map +0 -1
  29. package/dist/utils/colorUtils.d.ts +0 -7
  30. package/dist/utils/colorUtils.d.ts.map +0 -1
  31. package/dist/utils/colorUtils.js +0 -82
  32. package/dist/utils/colorUtils.js.map +0 -1
  33. package/dist/utils/explainFormatter.d.ts +0 -2
  34. package/dist/utils/explainFormatter.d.ts.map +0 -1
  35. package/dist/utils/explainFormatter.js +0 -4
  36. package/dist/utils/explainFormatter.js.map +0 -1
  37. package/dist/utils/helpFormatter.d.ts +0 -63
  38. package/dist/utils/helpFormatter.d.ts.map +0 -1
  39. package/dist/utils/helpFormatter.js +0 -171
  40. package/dist/utils/helpFormatter.js.map +0 -1
  41. package/dist/utils/pathValidator.d.ts +0 -48
  42. package/dist/utils/pathValidator.d.ts.map +0 -1
  43. package/dist/utils/pathValidator.js +0 -183
  44. package/dist/utils/pathValidator.js.map +0 -1
@@ -1,171 +0,0 @@
1
- /**
2
- * Standardized Help Formatter for MediaProc Image CLI
3
- * Creates consistent, beautiful help displays for all image commands
4
- */
5
- import chalk from 'chalk';
6
- /**
7
- * Create a gradient-like effect using chalk
8
- */
9
- function createGradientText(text, startColor) {
10
- // Simple gradient simulation using chalk colors
11
- return chalk.hex(startColor)(text);
12
- }
13
- /**
14
- * Create a box around content
15
- */
16
- function createBox(content, borderColor = 'cyan') {
17
- const lines = content.split('\n');
18
- const maxLength = Math.max(...lines.map(line => stripAnsi(line).length));
19
- const width = Math.min(maxLength + 4, 100);
20
- const colorFn = chalk[borderColor];
21
- const topBorder = colorFn('╭' + '─'.repeat(width - 2) + '╮');
22
- const bottomBorder = colorFn('╰' + '─'.repeat(width - 2) + '╯');
23
- const boxedLines = lines.map(line => {
24
- const stripped = stripAnsi(line);
25
- const padding = ' '.repeat(Math.max(0, width - stripped.length - 4));
26
- return colorFn('│ ') + line + padding + colorFn(' │');
27
- });
28
- return '\n' + topBorder + '\n' + boxedLines.join('\n') + '\n' + bottomBorder + '\n';
29
- }
30
- /**
31
- * Strip ANSI codes from string for length calculation
32
- */
33
- function stripAnsi(str) {
34
- return str.replace(/\x1b\[[0-9;]*m/g, '');
35
- }
36
- /**
37
- * Create standardized help display for commands
38
- */
39
- export function createStandardHelp(config) {
40
- let helpContent = '';
41
- // Header
42
- helpContent += createGradientText(`${config.emoji} MediaProc Image - ${config.commandName} Command`, '#4facfe') + '\n\n';
43
- // Description
44
- helpContent += chalk.white(config.description) + '\n\n';
45
- // Usage
46
- helpContent += chalk.cyan.bold('Usage:') + '\n';
47
- config.usage.forEach(usage => {
48
- helpContent += chalk.white(` ${chalk.magenta('mediaproc')} ${chalk.cyan('image')} ${usage}`) + '\n';
49
- });
50
- helpContent += '\n';
51
- // Options
52
- helpContent += chalk.cyan.bold('Options:') + '\n';
53
- // Check if help flag already exists
54
- const hasHelpFlag = config.options && config.options.some(option => option.flag.includes('-h') || option.flag.includes('--help'));
55
- // Add custom options first
56
- if (config.options && config.options.length > 0) {
57
- config.options.forEach(option => {
58
- const flagPart = chalk.yellow(option.flag.padEnd(30));
59
- const descPart = chalk.gray(option.description);
60
- helpContent += ` ${flagPart} ${descPart}\n`;
61
- });
62
- }
63
- // Add the global help flag only if it doesn't already exist
64
- if (!hasHelpFlag) {
65
- helpContent += ` ${chalk.yellow('-h, --help'.padEnd(30))} ${chalk.gray('Show this help message')}\n`;
66
- }
67
- helpContent += '\n';
68
- // Examples
69
- if (config.examples && config.examples.length > 0) {
70
- helpContent += chalk.cyan.bold('Examples:') + '\n';
71
- config.examples.forEach(example => {
72
- // Check if command already starts with 'mediaproc image', if not add it
73
- const command = example.command.startsWith('mediaproc image ')
74
- ? example.command
75
- : `mediaproc image ${example.command}`;
76
- const formattedCommand = command
77
- .replace(/^mediaproc /, `${chalk.magenta('mediaproc')} `)
78
- .replace(/image /, `${chalk.cyan('image')} `);
79
- helpContent += chalk.white(` ${formattedCommand}`) + '\n';
80
- helpContent += chalk.dim(` → ${example.description}`) + '\n\n';
81
- });
82
- }
83
- // Additional sections
84
- if (config.additionalSections && config.additionalSections.length > 0) {
85
- config.additionalSections.forEach(section => {
86
- helpContent += chalk.hex('#00d2d3').bold(`💡 ${section.title}:`) + '\n';
87
- section.items.forEach(item => {
88
- helpContent += chalk.hex('#95afc0')(` • ${item}`) + '\n';
89
- });
90
- helpContent += '\n';
91
- });
92
- }
93
- // Tips
94
- if (config.tips && config.tips.length > 0) {
95
- config.tips.forEach(tip => {
96
- helpContent += chalk.yellow(`💡 Tip: ${tip}`) + '\n';
97
- });
98
- helpContent += '\n';
99
- }
100
- // Footer
101
- helpContent += chalk.dim(`━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━`) + '\n';
102
- helpContent += chalk.hex('#636e72')(`🖼️ MediaProc Image Plugin • Powered by Sharp • High Performance`);
103
- console.log(createBox(helpContent, 'cyan'));
104
- }
105
- /**
106
- * Quick help display for commands with minimal options
107
- */
108
- export function createQuickHelp(commandName, emoji, description, usage, options) {
109
- let helpContent = '';
110
- helpContent += createGradientText(`${emoji} ${commandName.toUpperCase()} COMMAND`, '#4facfe') + '\n\n';
111
- helpContent += chalk.white(description) + '\n\n';
112
- helpContent += chalk.cyan.bold('Usage:') + '\n';
113
- helpContent += chalk.white(` ${chalk.magenta('mediaproc')} ${chalk.cyan('image')} ${usage}`) + '\n\n';
114
- if (options.length > 0) {
115
- helpContent += chalk.cyan.bold('Options:') + '\n';
116
- options.forEach(option => {
117
- helpContent += chalk.gray(` ${option}`) + '\n';
118
- });
119
- }
120
- console.log(createBox(helpContent, 'cyan'));
121
- }
122
- /**
123
- * Create error help display
124
- */
125
- export function createErrorHelp(commandName, error, suggestion) {
126
- let helpContent = '';
127
- helpContent += chalk.red.bold(`❌ ${commandName.toUpperCase()} ERROR`) + '\n\n';
128
- helpContent += chalk.white(error) + '\n';
129
- if (suggestion) {
130
- helpContent += '\n' + chalk.yellow(`💡 Suggestion: ${suggestion}`) + '\n';
131
- }
132
- helpContent += '\n' + chalk.gray(`Run: `) + chalk.cyan(`mediaproc image ${commandName} --help`) + chalk.gray(` for more information`);
133
- console.log(createBox(helpContent, 'red'));
134
- }
135
- /**
136
- * Create success message display
137
- */
138
- export function createSuccessMessage(message, details) {
139
- let content = chalk.green.bold('✓ ' + message) + '\n';
140
- if (details && details.length > 0) {
141
- content += '\n';
142
- details.forEach(detail => {
143
- content += chalk.dim(` ${detail}`) + '\n';
144
- });
145
- }
146
- console.log(content);
147
- }
148
- /**
149
- * Create info message display
150
- */
151
- export function createInfoMessage(title, items) {
152
- let content = chalk.blue.bold('ℹ ' + title) + '\n';
153
- items.forEach(item => {
154
- content += chalk.gray(` • ${item}`) + '\n';
155
- });
156
- console.log(content);
157
- }
158
- /**
159
- * Create warning message display
160
- */
161
- export function createWarningMessage(message, details) {
162
- let content = chalk.yellow.bold('⚠ ' + message) + '\n';
163
- if (details && details.length > 0) {
164
- content += '\n';
165
- details.forEach(detail => {
166
- content += chalk.dim(` ${detail}`) + '\n';
167
- });
168
- }
169
- console.log(content);
170
- }
171
- //# sourceMappingURL=helpFormatter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"helpFormatter.js","sourceRoot":"","sources":["../../src/utils/helpFormatter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAwC1B;;GAEG;AACH,SAAS,kBAAkB,CAAC,IAAY,EAAE,UAAkB;IAC1D,gDAAgD;IAChD,OAAO,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC;AACrC,CAAC;AAED;;GAEG;AACH,SAAS,SAAS,CAAC,OAAe,EAAE,cAAmD,MAAM;IAC3F,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAClC,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;IACzE,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;IAE3C,MAAM,OAAO,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC;IACnC,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC;IAC7D,MAAM,YAAY,GAAG,OAA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IAAI,CAAC;QAC7C,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AACvB,CAAC"}
@@ -1,48 +0,0 @@
1
- /**
2
- * Supported image file extensions
3
- */
4
- export declare const IMAGE_EXTENSIONS: string[];
5
- /**
6
- * Parse input path and return array of files
7
- * Supports:
8
- * - Single file: "image.jpg"
9
- * - Multiple files with commas: "image1.jpg,image2.jpg,image3.jpg"
10
- * - Directory: "input-images/" (finds all matching files)
11
- */
12
- export declare function parseInputPaths(inputPath: string, allowedExtensions?: string[]): string[];
13
- /**
14
- * Resolve output paths for input files
15
- *
16
- * Logic:
17
- * 1. Single file + output has extension (e.g., output.jpg) = Use exact file path
18
- * 2. Multiple files + output has extension = Invalid (error)
19
- * 3. No output provided = Use current directory
20
- * 4. Output directory provided = Use that directory
21
- *
22
- * @param inputFiles - Array of input file paths
23
- * @param outputPath - Output path (file or directory, or undefined for current dir)
24
- * @param suffix - Suffix to add to filenames (default: empty)
25
- * @param newExtension - New extension for output files (default: same as input)
26
- */
27
- export declare function resolveOutputPaths(inputFiles: string[], outputPath: string | undefined, options?: {
28
- suffix?: string;
29
- newExtension?: string;
30
- }): Map<string, string>;
31
- /**
32
- * Validate input and output paths
33
- * Returns validated input files, output directory, and any errors
34
- */
35
- export declare function validatePaths(inputPath: string, outputPath: string | undefined, options?: {
36
- allowedExtensions?: string[];
37
- suffix?: string;
38
- newExtension?: string;
39
- }): {
40
- inputFiles: string[];
41
- outputPath: string | undefined;
42
- errors: string[];
43
- };
44
- /**
45
- * Get file name from path
46
- */
47
- export declare function getFileName(filePath: string): string;
48
- //# sourceMappingURL=pathValidator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pathValidator.d.ts","sourceRoot":"","sources":["../../src/utils/pathValidator.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,eAAO,MAAM,gBAAgB,UAc5B,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,SAAS,EAAE,MAAM,EACjB,iBAAiB,GAAE,MAAM,EAAqB,GAC7C,MAAM,EAAE,CA8BV;AAkCD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,MAAM,EAAE,EACpB,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,OAAO,GAAE;IACP,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;CAClB,GACL,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CA6DrB;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,OAAO,GAAE;IACP,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;CAClB,GACL;IACD,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CA2BA;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEpD"}
@@ -1,183 +0,0 @@
1
- import * as fs from 'fs';
2
- import * as path from 'path';
3
- /**
4
- * Supported image file extensions
5
- */
6
- export const IMAGE_EXTENSIONS = [
7
- '.jpg',
8
- '.jpeg',
9
- '.png',
10
- '.gif',
11
- '.bmp',
12
- '.webp',
13
- '.tiff',
14
- '.tif',
15
- '.svg',
16
- '.ico',
17
- '.heic',
18
- '.heif',
19
- '.avif',
20
- ];
21
- /**
22
- * Parse input path and return array of files
23
- * Supports:
24
- * - Single file: "image.jpg"
25
- * - Multiple files with commas: "image1.jpg,image2.jpg,image3.jpg"
26
- * - Directory: "input-images/" (finds all matching files)
27
- */
28
- export function parseInputPaths(inputPath, allowedExtensions = IMAGE_EXTENSIONS) {
29
- const files = [];
30
- // Split by comma for multiple files
31
- const paths = inputPath.split(',').map(p => p.trim());
32
- for (const p of paths) {
33
- const resolvedPath = path.resolve(p);
34
- // Check if path exists
35
- if (!fs.existsSync(resolvedPath)) {
36
- continue; // Skip non-existent paths
37
- }
38
- const stats = fs.statSync(resolvedPath);
39
- if (stats.isFile()) {
40
- // Check if file has allowed extension
41
- const ext = path.extname(resolvedPath).toLowerCase();
42
- if (allowedExtensions.includes(ext)) {
43
- files.push(resolvedPath);
44
- }
45
- }
46
- else if (stats.isDirectory()) {
47
- // Recursively find all files in directory
48
- const dirFiles = findFilesInDirectory(resolvedPath, allowedExtensions);
49
- files.push(...dirFiles);
50
- }
51
- }
52
- return files;
53
- }
54
- /**
55
- * Recursively find all files with allowed extensions in a directory
56
- */
57
- function findFilesInDirectory(dir, allowedExtensions) {
58
- const files = [];
59
- try {
60
- const entries = fs.readdirSync(dir, { withFileTypes: true });
61
- for (const entry of entries) {
62
- const fullPath = path.join(dir, entry.name);
63
- if (entry.isDirectory()) {
64
- // Recursively search subdirectories
65
- files.push(...findFilesInDirectory(fullPath, allowedExtensions));
66
- }
67
- else if (entry.isFile()) {
68
- const ext = path.extname(fullPath).toLowerCase();
69
- if (allowedExtensions.includes(ext)) {
70
- files.push(fullPath);
71
- }
72
- }
73
- }
74
- }
75
- catch (error) {
76
- // Ignore directories that can't be read
77
- }
78
- return files;
79
- }
80
- /**
81
- * Resolve output paths for input files
82
- *
83
- * Logic:
84
- * 1. Single file + output has extension (e.g., output.jpg) = Use exact file path
85
- * 2. Multiple files + output has extension = Invalid (error)
86
- * 3. No output provided = Use current directory
87
- * 4. Output directory provided = Use that directory
88
- *
89
- * @param inputFiles - Array of input file paths
90
- * @param outputPath - Output path (file or directory, or undefined for current dir)
91
- * @param suffix - Suffix to add to filenames (default: empty)
92
- * @param newExtension - New extension for output files (default: same as input)
93
- */
94
- export function resolveOutputPaths(inputFiles, outputPath, options = {}) {
95
- const { suffix = '', newExtension } = options;
96
- const outputMap = new Map();
97
- // No input files - return empty map
98
- if (inputFiles.length === 0) {
99
- return outputMap;
100
- }
101
- // Determine output directory or file
102
- let outputDir;
103
- let isExplicitFile = false;
104
- if (!outputPath) {
105
- // No output provided - use current directory
106
- outputDir = process.cwd();
107
- }
108
- else {
109
- const resolvedOutput = path.resolve(outputPath);
110
- const outputExt = path.extname(resolvedOutput).toLowerCase();
111
- if (outputExt) {
112
- // Output has extension - it's a file path
113
- if (inputFiles.length > 1) {
114
- throw new Error('Cannot specify a file output path for multiple input files. Use a directory instead.');
115
- }
116
- // Single file with explicit output file
117
- isExplicitFile = true;
118
- outputDir = resolvedOutput;
119
- }
120
- else {
121
- // No extension - it's a directory path
122
- outputDir = resolvedOutput;
123
- }
124
- }
125
- // Case 1: Single file with explicit output file path
126
- if (isExplicitFile && inputFiles.length === 1) {
127
- // Create parent directory if needed
128
- const parentDir = path.dirname(outputDir);
129
- if (!fs.existsSync(parentDir)) {
130
- fs.mkdirSync(parentDir, { recursive: true });
131
- }
132
- outputMap.set(inputFiles[0], outputDir);
133
- return outputMap;
134
- }
135
- // Case 2: Multiple files or directory output
136
- // Create output directory if it doesn't exist
137
- if (!fs.existsSync(outputDir)) {
138
- fs.mkdirSync(outputDir, { recursive: true });
139
- }
140
- // Map each input file to output path
141
- for (const inputFile of inputFiles) {
142
- const inputParsed = path.parse(inputFile);
143
- const ext = newExtension || inputParsed.ext;
144
- const outputFilename = `${inputParsed.name}${suffix}${ext}`;
145
- const outputFilePath = path.join(outputDir, outputFilename);
146
- outputMap.set(inputFile, outputFilePath);
147
- }
148
- return outputMap;
149
- }
150
- /**
151
- * Validate input and output paths
152
- * Returns validated input files, output directory, and any errors
153
- */
154
- export function validatePaths(inputPath, outputPath, options = {}) {
155
- const { allowedExtensions = IMAGE_EXTENSIONS } = options;
156
- const errors = [];
157
- // Parse input files
158
- const inputFiles = parseInputPaths(inputPath, allowedExtensions);
159
- if (inputFiles.length === 0) {
160
- errors.push(`No valid files found. Supported extensions: ${allowedExtensions.join(', ')}`);
161
- }
162
- // Validate output path if provided
163
- if (outputPath) {
164
- const resolvedOutput = path.resolve(outputPath);
165
- const outputExt = path.extname(resolvedOutput).toLowerCase();
166
- // If output has extension but multiple input files
167
- if (outputExt && inputFiles.length > 1) {
168
- errors.push('Cannot specify a file output path for multiple input files. Use a directory instead.');
169
- }
170
- }
171
- return {
172
- inputFiles,
173
- outputPath,
174
- errors,
175
- };
176
- }
177
- /**
178
- * Get file name from path
179
- */
180
- export function getFileName(filePath) {
181
- return path.basename(filePath);
182
- }
183
- //# sourceMappingURL=pathValidator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pathValidator.js","sourceRoot":"","sources":["../../src/utils/pathValidator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,MAAM;IACN,OAAO;IACP,MAAM;IACN,MAAM;IACN,MAAM;IACN,OAAO;IACP,OAAO;IACP,MAAM;IACN,MAAM;IACN,MAAM;IACN,OAAO;IACP,OAAO;IACP,OAAO;CACR,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAC7B,SAAiB,EACjB,oBAA8B,gBAAgB;IAE9C,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,oCAAoC;IACpC,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAEtD,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QACtB,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAErC,uBAAuB;QACvB,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;Y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