file2md 1.1.8 → 1.1.10
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/parsers/pptx-parser.d.ts +3 -0
- package/dist/parsers/pptx-parser.d.ts.map +1 -1
- package/dist/parsers/pptx-parser.js +82 -2
- package/dist/parsers/pptx-parser.js.map +1 -1
- package/dist/utils/libreoffice-converter.d.ts +33 -0
- package/dist/utils/libreoffice-converter.d.ts.map +1 -0
- package/dist/utils/libreoffice-converter.js +169 -0
- package/dist/utils/libreoffice-converter.js.map +1 -0
- package/dist/utils/libreoffice-detector.d.ts +57 -0
- package/dist/utils/libreoffice-detector.d.ts.map +1 -0
- package/dist/utils/libreoffice-detector.js +295 -0
- package/dist/utils/libreoffice-detector.js.map +1 -0
- package/dist/utils/pptx-visual-parser.d.ts +190 -0
- package/dist/utils/pptx-visual-parser.d.ts.map +1 -0
- package/dist/utils/pptx-visual-parser.js +648 -0
- package/dist/utils/pptx-visual-parser.js.map +1 -0
- package/dist/utils/puppeteer-renderer.d.ts +65 -0
- package/dist/utils/puppeteer-renderer.d.ts.map +1 -0
- package/dist/utils/puppeteer-renderer.js +393 -0
- package/dist/utils/puppeteer-renderer.js.map +1 -0
- package/dist/utils/slide-renderer.d.ts +55 -3
- package/dist/utils/slide-renderer.d.ts.map +1 -1
- package/dist/utils/slide-renderer.js +478 -52
- package/dist/utils/slide-renderer.js.map +1 -1
- package/package.json +6 -1
@@ -0,0 +1,295 @@
|
|
1
|
+
import { exec } from 'child_process';
|
2
|
+
import { promisify } from 'util';
|
3
|
+
import { platform } from 'os';
|
4
|
+
import fs from 'fs/promises';
|
5
|
+
const execAsync = promisify(exec);
|
6
|
+
export class LibreOfficeDetector {
|
7
|
+
static instance;
|
8
|
+
cachedInfo;
|
9
|
+
constructor() { }
|
10
|
+
static getInstance() {
|
11
|
+
if (!LibreOfficeDetector.instance) {
|
12
|
+
LibreOfficeDetector.instance = new LibreOfficeDetector();
|
13
|
+
}
|
14
|
+
return LibreOfficeDetector.instance;
|
15
|
+
}
|
16
|
+
/**
|
17
|
+
* Check if LibreOffice is installed and get its information
|
18
|
+
*/
|
19
|
+
async checkLibreOfficeInstallation() {
|
20
|
+
// Return cached result if available
|
21
|
+
if (this.cachedInfo) {
|
22
|
+
return this.cachedInfo;
|
23
|
+
}
|
24
|
+
try {
|
25
|
+
const info = await this.detectLibreOffice();
|
26
|
+
this.cachedInfo = info;
|
27
|
+
return info;
|
28
|
+
}
|
29
|
+
catch (error) {
|
30
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
31
|
+
return {
|
32
|
+
installed: false,
|
33
|
+
error: errorMessage
|
34
|
+
};
|
35
|
+
}
|
36
|
+
}
|
37
|
+
/**
|
38
|
+
* Detect LibreOffice based on platform
|
39
|
+
*/
|
40
|
+
async detectLibreOffice() {
|
41
|
+
const platformName = platform();
|
42
|
+
switch (platformName) {
|
43
|
+
case 'win32':
|
44
|
+
return await this.detectWindows();
|
45
|
+
case 'darwin':
|
46
|
+
return await this.detectMacOS();
|
47
|
+
case 'linux':
|
48
|
+
return await this.detectLinux();
|
49
|
+
default:
|
50
|
+
return {
|
51
|
+
installed: false,
|
52
|
+
error: `Unsupported platform: ${platformName}`
|
53
|
+
};
|
54
|
+
}
|
55
|
+
}
|
56
|
+
/**
|
57
|
+
* Detect LibreOffice on Windows
|
58
|
+
*/
|
59
|
+
async detectWindows() {
|
60
|
+
const possiblePaths = [
|
61
|
+
'C:\\Program Files\\LibreOffice\\program\\soffice.exe',
|
62
|
+
'C:\\Program Files (x86)\\LibreOffice\\program\\soffice.exe',
|
63
|
+
process.env['PROGRAMFILES'] + '\\LibreOffice\\program\\soffice.exe',
|
64
|
+
process.env['PROGRAMFILES(X86)'] + '\\LibreOffice\\program\\soffice.exe'
|
65
|
+
];
|
66
|
+
// Try common installation paths
|
67
|
+
for (const checkPath of possiblePaths) {
|
68
|
+
if (checkPath && await this.fileExists(checkPath)) {
|
69
|
+
const version = await this.getVersion(checkPath);
|
70
|
+
return {
|
71
|
+
installed: true,
|
72
|
+
path: checkPath,
|
73
|
+
version
|
74
|
+
};
|
75
|
+
}
|
76
|
+
}
|
77
|
+
// Try to find via registry or command
|
78
|
+
try {
|
79
|
+
const { stdout } = await execAsync('where soffice.exe');
|
80
|
+
const path = stdout.trim().split('\n')[0];
|
81
|
+
if (path && await this.fileExists(path)) {
|
82
|
+
const version = await this.getVersion(path);
|
83
|
+
return {
|
84
|
+
installed: true,
|
85
|
+
path,
|
86
|
+
version
|
87
|
+
};
|
88
|
+
}
|
89
|
+
}
|
90
|
+
catch {
|
91
|
+
// Command failed, LibreOffice not in PATH
|
92
|
+
}
|
93
|
+
return {
|
94
|
+
installed: false,
|
95
|
+
error: 'LibreOffice not found in common Windows locations'
|
96
|
+
};
|
97
|
+
}
|
98
|
+
/**
|
99
|
+
* Detect LibreOffice on macOS
|
100
|
+
*/
|
101
|
+
async detectMacOS() {
|
102
|
+
const possiblePaths = [
|
103
|
+
'/Applications/LibreOffice.app/Contents/MacOS/soffice',
|
104
|
+
'/usr/local/bin/soffice',
|
105
|
+
'/opt/homebrew/bin/soffice'
|
106
|
+
];
|
107
|
+
// Try common installation paths
|
108
|
+
for (const checkPath of possiblePaths) {
|
109
|
+
if (await this.fileExists(checkPath)) {
|
110
|
+
const version = await this.getVersion(checkPath);
|
111
|
+
return {
|
112
|
+
installed: true,
|
113
|
+
path: checkPath,
|
114
|
+
version
|
115
|
+
};
|
116
|
+
}
|
117
|
+
}
|
118
|
+
// Try to find via which command
|
119
|
+
try {
|
120
|
+
const { stdout } = await execAsync('which soffice');
|
121
|
+
const path = stdout.trim();
|
122
|
+
if (path && await this.fileExists(path)) {
|
123
|
+
const version = await this.getVersion(path);
|
124
|
+
return {
|
125
|
+
installed: true,
|
126
|
+
path,
|
127
|
+
version
|
128
|
+
};
|
129
|
+
}
|
130
|
+
}
|
131
|
+
catch {
|
132
|
+
// Command failed
|
133
|
+
}
|
134
|
+
return {
|
135
|
+
installed: false,
|
136
|
+
error: 'LibreOffice not found in common macOS locations'
|
137
|
+
};
|
138
|
+
}
|
139
|
+
/**
|
140
|
+
* Detect LibreOffice on Linux
|
141
|
+
*/
|
142
|
+
async detectLinux() {
|
143
|
+
const possiblePaths = [
|
144
|
+
'/usr/bin/soffice',
|
145
|
+
'/usr/local/bin/soffice',
|
146
|
+
'/opt/libreoffice/program/soffice',
|
147
|
+
'/snap/bin/libreoffice'
|
148
|
+
];
|
149
|
+
// Try common installation paths
|
150
|
+
for (const checkPath of possiblePaths) {
|
151
|
+
if (await this.fileExists(checkPath)) {
|
152
|
+
const version = await this.getVersion(checkPath);
|
153
|
+
return {
|
154
|
+
installed: true,
|
155
|
+
path: checkPath,
|
156
|
+
version
|
157
|
+
};
|
158
|
+
}
|
159
|
+
}
|
160
|
+
// Try to find via which command
|
161
|
+
try {
|
162
|
+
const { stdout } = await execAsync('which soffice');
|
163
|
+
const path = stdout.trim();
|
164
|
+
if (path && await this.fileExists(path)) {
|
165
|
+
const version = await this.getVersion(path);
|
166
|
+
return {
|
167
|
+
installed: true,
|
168
|
+
path,
|
169
|
+
version
|
170
|
+
};
|
171
|
+
}
|
172
|
+
}
|
173
|
+
catch {
|
174
|
+
// Command failed
|
175
|
+
}
|
176
|
+
return {
|
177
|
+
installed: false,
|
178
|
+
error: 'LibreOffice not found in common Linux locations'
|
179
|
+
};
|
180
|
+
}
|
181
|
+
/**
|
182
|
+
* Get LibreOffice version
|
183
|
+
*/
|
184
|
+
async getVersion(execPath) {
|
185
|
+
try {
|
186
|
+
const { stdout } = await execAsync(`"${execPath}" --version`);
|
187
|
+
const versionMatch = stdout.match(/LibreOffice ([\d.]+)/);
|
188
|
+
return versionMatch ? versionMatch[1] : undefined;
|
189
|
+
}
|
190
|
+
catch {
|
191
|
+
return undefined;
|
192
|
+
}
|
193
|
+
}
|
194
|
+
/**
|
195
|
+
* Check if file exists
|
196
|
+
*/
|
197
|
+
async fileExists(filePath) {
|
198
|
+
try {
|
199
|
+
await fs.access(filePath);
|
200
|
+
return true;
|
201
|
+
}
|
202
|
+
catch {
|
203
|
+
return false;
|
204
|
+
}
|
205
|
+
}
|
206
|
+
/**
|
207
|
+
* Check if LibreOffice version meets minimum requirement
|
208
|
+
*/
|
209
|
+
isVersionSupported(version) {
|
210
|
+
if (!version)
|
211
|
+
return false;
|
212
|
+
const parts = version.split('.');
|
213
|
+
const major = parseInt(parts[0], 10);
|
214
|
+
const minor = parseInt(parts[1] || '0', 10);
|
215
|
+
// Require LibreOffice 7.0 or higher
|
216
|
+
return major > 7 || (major === 7 && minor >= 0);
|
217
|
+
}
|
218
|
+
/**
|
219
|
+
* Get installation instructions for current platform
|
220
|
+
*/
|
221
|
+
getInstallationInstructions() {
|
222
|
+
const platformName = platform();
|
223
|
+
switch (platformName) {
|
224
|
+
case 'win32':
|
225
|
+
return `
|
226
|
+
LibreOffice Installation Instructions for Windows:
|
227
|
+
|
228
|
+
1. Download LibreOffice from: https://www.libreoffice.org/download/download/
|
229
|
+
2. Run the installer and follow the installation wizard
|
230
|
+
3. Default installation path: C:\\Program Files\\LibreOffice
|
231
|
+
|
232
|
+
Alternative: Use Chocolatey package manager:
|
233
|
+
choco install libreoffice-fresh
|
234
|
+
`;
|
235
|
+
case 'darwin':
|
236
|
+
return `
|
237
|
+
LibreOffice Installation Instructions for macOS:
|
238
|
+
|
239
|
+
1. Download LibreOffice from: https://www.libreoffice.org/download/download/
|
240
|
+
2. Open the .dmg file and drag LibreOffice to Applications
|
241
|
+
3. Default installation path: /Applications/LibreOffice.app
|
242
|
+
|
243
|
+
Alternative: Use Homebrew:
|
244
|
+
brew install --cask libreoffice
|
245
|
+
`;
|
246
|
+
case 'linux':
|
247
|
+
return `
|
248
|
+
LibreOffice Installation Instructions for Linux:
|
249
|
+
|
250
|
+
Ubuntu/Debian:
|
251
|
+
sudo apt update
|
252
|
+
sudo apt install libreoffice
|
253
|
+
|
254
|
+
Fedora:
|
255
|
+
sudo dnf install libreoffice
|
256
|
+
|
257
|
+
Arch Linux:
|
258
|
+
sudo pacman -S libreoffice-fresh
|
259
|
+
|
260
|
+
Alternative: Download from https://www.libreoffice.org/download/download/
|
261
|
+
`;
|
262
|
+
default:
|
263
|
+
return `
|
264
|
+
Please visit https://www.libreoffice.org/download/download/ to download LibreOffice for your platform.
|
265
|
+
`;
|
266
|
+
}
|
267
|
+
}
|
268
|
+
/**
|
269
|
+
* Get download URL for current platform
|
270
|
+
*/
|
271
|
+
getDownloadUrl() {
|
272
|
+
const platformName = platform();
|
273
|
+
const arch = process.arch;
|
274
|
+
const baseUrl = 'https://www.libreoffice.org/donate/dl/';
|
275
|
+
switch (platformName) {
|
276
|
+
case 'win32':
|
277
|
+
return arch === 'x64'
|
278
|
+
? `${baseUrl}win-x86_64/7.6.4/en-US/LibreOffice_7.6.4_Win_x86-64.msi`
|
279
|
+
: `${baseUrl}win-x86/7.6.4/en-US/LibreOffice_7.6.4_Win_x86.msi`;
|
280
|
+
case 'darwin':
|
281
|
+
return `${baseUrl}mac-x86_64/7.6.4/en-US/LibreOffice_7.6.4_MacOS_x86-64.dmg`;
|
282
|
+
case 'linux':
|
283
|
+
return `${baseUrl}deb-x86_64/7.6.4/en-US/LibreOffice_7.6.4_Linux_x86-64_deb.tar.gz`;
|
284
|
+
default:
|
285
|
+
return 'https://www.libreoffice.org/download/download/';
|
286
|
+
}
|
287
|
+
}
|
288
|
+
/**
|
289
|
+
* Clear cached LibreOffice info
|
290
|
+
*/
|
291
|
+
clearCache() {
|
292
|
+
this.cachedInfo = undefined;
|
293
|
+
}
|
294
|
+
}
|
295
|
+
//# sourceMappingURL=libreoffice-detector.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"libreoffice-detector.js","sourceRoot":"","sources":["../../src/utils/libreoffice-detector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAC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,CAAC;YAEpE,KAAK,QAAQ;gBACX,OAAO,GAAG,OAAO,2DAA2D,CAAC;YAE/E,KAAK,OAAO;gBACV,OAAO,GAAG,OAAO,kEAAkE,CAAC;YAEtF;gBACE,OAAO,gDAAgD,CAAC;QAC5D,CAAC;IACH,CAAC;IAED;;OAEG;IACH,UAAU;QACR,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAC9B,CAAC;CACF"}
|
@@ -0,0 +1,190 @@
|
|
1
|
+
export interface SlideLayout {
|
2
|
+
slideId: string;
|
3
|
+
slideNumber: number;
|
4
|
+
title?: string;
|
5
|
+
background?: BackgroundInfo;
|
6
|
+
elements: VisualElement[];
|
7
|
+
dimensions: SlideDimensions;
|
8
|
+
}
|
9
|
+
export interface SlideDimensions {
|
10
|
+
width: number;
|
11
|
+
height: number;
|
12
|
+
units: 'EMU' | 'points' | 'pixels';
|
13
|
+
}
|
14
|
+
export interface BackgroundInfo {
|
15
|
+
type: 'solid' | 'gradient' | 'image' | 'pattern';
|
16
|
+
color?: string;
|
17
|
+
colors?: string[];
|
18
|
+
imagePath?: string;
|
19
|
+
}
|
20
|
+
export interface VisualElement {
|
21
|
+
id: string;
|
22
|
+
type: 'text' | 'shape' | 'image' | 'chart' | 'table' | 'group';
|
23
|
+
position: ElementPosition;
|
24
|
+
size: ElementSize;
|
25
|
+
content?: any;
|
26
|
+
style?: ElementStyle;
|
27
|
+
children?: VisualElement[];
|
28
|
+
}
|
29
|
+
export interface ElementPosition {
|
30
|
+
x: number;
|
31
|
+
y: number;
|
32
|
+
z: number;
|
33
|
+
}
|
34
|
+
export interface ElementSize {
|
35
|
+
width: number;
|
36
|
+
height: number;
|
37
|
+
}
|
38
|
+
export interface ElementStyle {
|
39
|
+
fill?: string;
|
40
|
+
stroke?: string;
|
41
|
+
strokeWidth?: number;
|
42
|
+
opacity?: number;
|
43
|
+
rotation?: number;
|
44
|
+
font?: FontInfo;
|
45
|
+
}
|
46
|
+
export interface FontInfo {
|
47
|
+
family: string;
|
48
|
+
size: number;
|
49
|
+
color: string;
|
50
|
+
bold: boolean;
|
51
|
+
italic: boolean;
|
52
|
+
underline: boolean;
|
53
|
+
}
|
54
|
+
export interface TextElement extends VisualElement {
|
55
|
+
type: 'text';
|
56
|
+
content: {
|
57
|
+
text: string;
|
58
|
+
paragraphs: TextParagraph[];
|
59
|
+
};
|
60
|
+
}
|
61
|
+
export interface TextParagraph {
|
62
|
+
text: string;
|
63
|
+
runs: TextRun[];
|
64
|
+
alignment: 'left' | 'center' | 'right' | 'justify';
|
65
|
+
level: number;
|
66
|
+
}
|
67
|
+
export interface TextRun {
|
68
|
+
text: string;
|
69
|
+
font?: FontInfo;
|
70
|
+
}
|
71
|
+
export interface ShapeElement extends VisualElement {
|
72
|
+
type: 'shape';
|
73
|
+
content: {
|
74
|
+
shapeType: string;
|
75
|
+
geometry?: any;
|
76
|
+
};
|
77
|
+
}
|
78
|
+
export interface ImageElement extends VisualElement {
|
79
|
+
type: 'image';
|
80
|
+
content: {
|
81
|
+
imagePath: string;
|
82
|
+
originalSize: ElementSize;
|
83
|
+
aspectRatio: number;
|
84
|
+
};
|
85
|
+
}
|
86
|
+
export interface ChartElement extends VisualElement {
|
87
|
+
type: 'chart';
|
88
|
+
content: {
|
89
|
+
chartType: string;
|
90
|
+
data?: any;
|
91
|
+
series?: any[];
|
92
|
+
};
|
93
|
+
}
|
94
|
+
export interface TableElement extends VisualElement {
|
95
|
+
type: 'table';
|
96
|
+
content: {
|
97
|
+
rows: TableRow[];
|
98
|
+
columnWidths: number[];
|
99
|
+
style?: TableStyle;
|
100
|
+
};
|
101
|
+
}
|
102
|
+
export interface TableRow {
|
103
|
+
cells: TableCell[];
|
104
|
+
height?: number;
|
105
|
+
}
|
106
|
+
export interface TableCell {
|
107
|
+
text: string;
|
108
|
+
colspan?: number;
|
109
|
+
rowspan?: number;
|
110
|
+
style?: ElementStyle;
|
111
|
+
}
|
112
|
+
export interface TableStyle {
|
113
|
+
borderStyle?: string;
|
114
|
+
borderColor?: string;
|
115
|
+
borderWidth?: number;
|
116
|
+
headerStyle?: ElementStyle;
|
117
|
+
}
|
118
|
+
export declare class PptxVisualParser {
|
119
|
+
private zip;
|
120
|
+
private slideCount;
|
121
|
+
private relationships;
|
122
|
+
private themes;
|
123
|
+
/**
|
124
|
+
* Parse PPTX buffer to extract comprehensive visual information
|
125
|
+
*/
|
126
|
+
parseVisualElements(pptxBuffer: Buffer): Promise<SlideLayout[]>;
|
127
|
+
/**
|
128
|
+
* Extract slide references from presentation.xml
|
129
|
+
*/
|
130
|
+
private extractSlideReferences;
|
131
|
+
/**
|
132
|
+
* Load relationships from _rels files
|
133
|
+
*/
|
134
|
+
private loadRelationships;
|
135
|
+
/**
|
136
|
+
* Load theme information
|
137
|
+
*/
|
138
|
+
private loadThemes;
|
139
|
+
/**
|
140
|
+
* Parse individual slide
|
141
|
+
*/
|
142
|
+
private parseSlide;
|
143
|
+
/**
|
144
|
+
* Extract slide dimensions
|
145
|
+
*/
|
146
|
+
private extractSlideDimensions;
|
147
|
+
/**
|
148
|
+
* Extract slide background information
|
149
|
+
*/
|
150
|
+
private extractSlideBackground;
|
151
|
+
/**
|
152
|
+
* Extract slide title
|
153
|
+
*/
|
154
|
+
private extractSlideTitle;
|
155
|
+
/**
|
156
|
+
* Parse all visual elements in a slide
|
157
|
+
*/
|
158
|
+
private parseSlideElements;
|
159
|
+
/**
|
160
|
+
* Parse a shape element
|
161
|
+
*/
|
162
|
+
private parseShape;
|
163
|
+
/**
|
164
|
+
* Parse a group element
|
165
|
+
*/
|
166
|
+
private parseGroup;
|
167
|
+
/**
|
168
|
+
* Parse a picture element
|
169
|
+
*/
|
170
|
+
private parsePicture;
|
171
|
+
/**
|
172
|
+
* Parse a chart element
|
173
|
+
*/
|
174
|
+
private parseChart;
|
175
|
+
private extractPosition;
|
176
|
+
private extractSize;
|
177
|
+
private extractElementStyle;
|
178
|
+
private extractFontInfo;
|
179
|
+
private extractTextFromBody;
|
180
|
+
private extractParagraphsFromBody;
|
181
|
+
private extractTextFromParagraph;
|
182
|
+
private extractTextRuns;
|
183
|
+
private extractAlignment;
|
184
|
+
private extractShapeType;
|
185
|
+
private extractShapeGeometry;
|
186
|
+
private findRelationshipTarget;
|
187
|
+
private createPlaceholderSlide;
|
188
|
+
private getXmlContent;
|
189
|
+
}
|
190
|
+
//# sourceMappingURL=pptx-visual-parser.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"pptx-visual-parser.d.ts","sourceRoot":"","sources":["../../src/utils/pptx-visual-parser.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,cAAc,CAAC;IAC5B,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,UAAU,EAAE,eAAe,CAAC;CAC7B;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,KAAK,GAAG,QAAQ,GAAG,QAAQ,CAAC;CACpC;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,OAAO,GAAG,UAAU,GAAG,OAAO,GAAG,SAAS,CAAC;IACjD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;IAC/D,QAAQ,EAAE,eAAe,CAAC;IAC1B,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB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