n8n-nodes-comfyui-all 2.2.23 → 2.3.1

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 (32) hide show
  1. package/dist/index.d.ts +2 -1
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +2 -0
  4. package/dist/index.js.map +1 -1
  5. package/dist/nodes/ComfyUi/ComfyUi.node.d.ts +63 -30
  6. package/dist/nodes/ComfyUi/ComfyUi.node.d.ts.map +1 -1
  7. package/dist/nodes/ComfyUi/ComfyUi.node.js +142 -55
  8. package/dist/nodes/ComfyUi/ComfyUi.node.js.map +1 -1
  9. package/dist/nodes/ComfyUiTool/ComfyUiTool.node.d.ts +157 -0
  10. package/dist/nodes/ComfyUiTool/ComfyUiTool.node.d.ts.map +1 -0
  11. package/dist/nodes/ComfyUiTool/ComfyUiTool.node.js +435 -0
  12. package/dist/nodes/ComfyUiTool/ComfyUiTool.node.js.map +1 -0
  13. package/dist/nodes/ComfyUiTool.node.d.ts +125 -0
  14. package/dist/nodes/ComfyUiTool.node.d.ts.map +1 -0
  15. package/dist/nodes/ComfyUiTool.node.js +265 -0
  16. package/dist/nodes/ComfyUiTool.node.js.map +1 -0
  17. package/dist/nodes/agentToolHelpers.d.ts +93 -0
  18. package/dist/nodes/agentToolHelpers.d.ts.map +1 -0
  19. package/dist/nodes/agentToolHelpers.js +337 -0
  20. package/dist/nodes/agentToolHelpers.js.map +1 -0
  21. package/dist/nodes/parameterProcessor.d.ts.map +1 -1
  22. package/dist/nodes/parameterProcessor.js +19 -9
  23. package/dist/nodes/parameterProcessor.js.map +1 -1
  24. package/dist/nodes/validation.d.ts +10 -0
  25. package/dist/nodes/validation.d.ts.map +1 -1
  26. package/dist/nodes/validation.js +81 -0
  27. package/dist/nodes/validation.js.map +1 -1
  28. package/dist/nodes/workflowConfig.d.ts +8 -1
  29. package/dist/nodes/workflowConfig.d.ts.map +1 -1
  30. package/dist/nodes/workflowConfig.js +75 -1
  31. package/dist/nodes/workflowConfig.js.map +1 -1
  32. package/package.json +1 -1
@@ -0,0 +1,125 @@
1
+ /**
2
+ * ComfyUI Tool - AI Agent-friendly image generation node
3
+ *
4
+ * This node is designed to be used as an AI Agent tool with minimal configuration.
5
+ * It accepts a simple text query and automatically generates images using ComfyUI.
6
+ */
7
+ import { IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
8
+ export declare class ComfyUiTool {
9
+ /**
10
+ * Node description for n8n
11
+ */
12
+ description: {
13
+ displayName: string;
14
+ name: string;
15
+ icon: string;
16
+ iconColor: string;
17
+ group: string[];
18
+ version: number[];
19
+ defaultVersion: number;
20
+ description: string;
21
+ defaults: {
22
+ name: string;
23
+ };
24
+ usableAsTool: boolean;
25
+ inputs: string[];
26
+ outputs: string[];
27
+ subtitle: string;
28
+ notes: string[];
29
+ inputSample: {
30
+ query: string;
31
+ };
32
+ outputSample: {
33
+ json: {
34
+ success: boolean;
35
+ imageCount: number;
36
+ imageUrls: string[];
37
+ prompt: string;
38
+ parameters: {
39
+ width: number;
40
+ height: number;
41
+ steps: number;
42
+ cfg: number;
43
+ seed: number;
44
+ };
45
+ };
46
+ binary: {
47
+ data: {
48
+ data: string;
49
+ mimeType: string;
50
+ fileName: string;
51
+ };
52
+ };
53
+ };
54
+ properties: ({
55
+ displayName: string;
56
+ name: string;
57
+ type: string;
58
+ required: boolean;
59
+ default: string;
60
+ description: string;
61
+ minValue?: undefined;
62
+ maxValue?: undefined;
63
+ placeholder?: undefined;
64
+ options?: undefined;
65
+ } | {
66
+ displayName: string;
67
+ name: string;
68
+ type: string;
69
+ default: number;
70
+ description: string;
71
+ minValue: number;
72
+ maxValue: number;
73
+ required?: undefined;
74
+ placeholder?: undefined;
75
+ options?: undefined;
76
+ } | {
77
+ displayName: string;
78
+ name: string;
79
+ type: string;
80
+ default: string;
81
+ description: string;
82
+ placeholder: string;
83
+ required?: undefined;
84
+ minValue?: undefined;
85
+ maxValue?: undefined;
86
+ options?: undefined;
87
+ } | {
88
+ displayName: string;
89
+ name: string;
90
+ type: string;
91
+ placeholder: string;
92
+ default: {};
93
+ options: ({
94
+ displayName: string;
95
+ name: string;
96
+ type: string;
97
+ typeOptions: {
98
+ rows: number;
99
+ };
100
+ default: string;
101
+ description: string;
102
+ minValue?: undefined;
103
+ maxValue?: undefined;
104
+ } | {
105
+ displayName: string;
106
+ name: string;
107
+ type: string;
108
+ default: number;
109
+ description: string;
110
+ minValue: number;
111
+ maxValue: number;
112
+ typeOptions?: undefined;
113
+ })[];
114
+ required?: undefined;
115
+ description?: undefined;
116
+ minValue?: undefined;
117
+ maxValue?: undefined;
118
+ })[];
119
+ };
120
+ /**
121
+ * Execute function - called when the node runs
122
+ */
123
+ execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
124
+ }
125
+ //# sourceMappingURL=ComfyUiTool.node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ComfyUiTool.node.d.ts","sourceRoot":"","sources":["../../nodes/ComfyUiTool.node.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAEnB,MAAM,cAAc,CAAC;AAStB,qBAAa,WAAW;IACtB;;OAEG;IACH,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAyIT;IAEF;;OAEG;IACG,OAAO,CAAC,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC;CAyIxE"}
@@ -0,0 +1,265 @@
1
+ "use strict";
2
+ /**
3
+ * ComfyUI Tool - AI Agent-friendly image generation node
4
+ *
5
+ * This node is designed to be used as an AI Agent tool with minimal configuration.
6
+ * It accepts a simple text query and automatically generates images using ComfyUI.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.ComfyUiTool = void 0;
10
+ const n8n_workflow_1 = require("n8n-workflow");
11
+ const ComfyUiClient_1 = require("./ComfyUiClient");
12
+ const validation_1 = require("./validation");
13
+ const logger_1 = require("./logger");
14
+ const agentToolHelpers_1 = require("./agentToolHelpers");
15
+ const workflowConfig_1 = require("./workflowConfig");
16
+ class ComfyUiTool {
17
+ constructor() {
18
+ /**
19
+ * Node description for n8n
20
+ */
21
+ this.description = {
22
+ displayName: 'ComfyUI Tool',
23
+ name: 'comfyUiTool',
24
+ icon: 'file:comfyui.svg',
25
+ iconColor: '#77C157',
26
+ group: ['transform'],
27
+ version: [1],
28
+ defaultVersion: 1,
29
+ description: 'AI-friendly image generation tool. Simply describe what you want to create.',
30
+ defaults: {
31
+ name: 'ComfyUI Tool',
32
+ },
33
+ usableAsTool: true,
34
+ inputs: ['main'],
35
+ outputs: ['main'],
36
+ subtitle: 'AI Image Generator',
37
+ notes: [
38
+ 'Optimized for AI Agent usage',
39
+ 'Automatically parses natural language queries',
40
+ 'Supports size, steps, cfg, seed, and negative prompt parameters',
41
+ 'Example: "A beautiful sunset, size:1024x768, steps:30"',
42
+ ],
43
+ inputSample: {
44
+ query: 'A beautiful landscape painting',
45
+ },
46
+ outputSample: {
47
+ json: {
48
+ success: true,
49
+ imageCount: 1,
50
+ imageUrls: ['http://127.0.0.1:8188/view?filename=ComfyUI_00001.png'],
51
+ prompt: 'A beautiful landscape painting',
52
+ parameters: {
53
+ width: 512,
54
+ height: 512,
55
+ steps: 20,
56
+ cfg: 8,
57
+ seed: 123456789,
58
+ },
59
+ },
60
+ binary: {
61
+ data: {
62
+ data: 'base64_encoded_image_data',
63
+ mimeType: 'image/png',
64
+ fileName: 'ComfyUI_00001.png',
65
+ },
66
+ },
67
+ },
68
+ properties: [
69
+ {
70
+ displayName: 'ComfyUI URL',
71
+ name: 'comfyUiUrl',
72
+ type: 'string',
73
+ required: true,
74
+ default: 'http://127.0.0.1:8188',
75
+ description: 'URL of ComfyUI server',
76
+ },
77
+ {
78
+ displayName: 'Timeout (Seconds)',
79
+ name: 'timeout',
80
+ type: 'number',
81
+ default: 120,
82
+ description: 'Maximum time to wait for image generation (in seconds). Default: 120 (2 minutes).',
83
+ minValue: 10,
84
+ maxValue: 600,
85
+ },
86
+ {
87
+ displayName: 'Output Binary Key',
88
+ name: 'outputBinaryKey',
89
+ type: 'string',
90
+ default: 'data',
91
+ description: 'Property name for the output binary data (e.g., "data", "image", "output")',
92
+ placeholder: 'data',
93
+ },
94
+ {
95
+ displayName: 'Default Negative Prompt',
96
+ name: 'defaultNegativePrompt',
97
+ type: 'string',
98
+ default: 'ugly, blurry, low quality, distorted',
99
+ description: 'Default negative prompt to use when not specified in query',
100
+ placeholder: 'ugly, blurry, low quality',
101
+ },
102
+ {
103
+ displayName: 'Advanced Options',
104
+ name: 'advancedOptions',
105
+ type: 'collection',
106
+ placeholder: 'Add Option',
107
+ default: {},
108
+ options: [
109
+ {
110
+ displayName: 'Custom Workflow JSON',
111
+ name: 'customWorkflow',
112
+ type: 'string',
113
+ typeOptions: {
114
+ rows: 20,
115
+ },
116
+ default: '',
117
+ description: 'Optional: Custom ComfyUI workflow JSON (API Format). If empty, uses default workflow. Only use this if you want to override the default template.',
118
+ },
119
+ {
120
+ displayName: 'Default Width',
121
+ name: 'defaultWidth',
122
+ type: 'number',
123
+ default: 512,
124
+ description: 'Default image width when not specified in query',
125
+ minValue: 64,
126
+ maxValue: 4096,
127
+ },
128
+ {
129
+ displayName: 'Default Height',
130
+ name: 'defaultHeight',
131
+ type: 'number',
132
+ default: 512,
133
+ description: 'Default image height when not specified in query',
134
+ minValue: 64,
135
+ maxValue: 4096,
136
+ },
137
+ {
138
+ displayName: 'Default Steps',
139
+ name: 'defaultSteps',
140
+ type: 'number',
141
+ default: 20,
142
+ description: 'Default sampling steps when not specified in query',
143
+ minValue: 1,
144
+ maxValue: 150,
145
+ },
146
+ {
147
+ displayName: 'Default CFG',
148
+ name: 'defaultCfg',
149
+ type: 'number',
150
+ default: 8,
151
+ description: 'Default CFG scale when not specified in query',
152
+ minValue: 1,
153
+ maxValue: 30,
154
+ },
155
+ ],
156
+ },
157
+ ],
158
+ };
159
+ }
160
+ /**
161
+ * Execute function - called when the node runs
162
+ */
163
+ async execute() {
164
+ const logger = (0, logger_1.createLogger)(this.logger);
165
+ // Get node parameters
166
+ const comfyUiUrl = this.getNodeParameter('comfyUiUrl', 0);
167
+ const timeout = this.getNodeParameter('timeout', 0);
168
+ const outputBinaryKey = this.getNodeParameter('outputBinaryKey', 0);
169
+ const defaultNegativePrompt = this.getNodeParameter('defaultNegativePrompt', 0);
170
+ const advancedOptions = this.getNodeParameter('advancedOptions', 0);
171
+ const { customWorkflow = '', defaultWidth = 512, defaultHeight = 512, defaultSteps = 20, defaultCfg = 8, } = advancedOptions || {};
172
+ // Validate URL
173
+ if (!(0, validation_1.validateUrl)(comfyUiUrl)) {
174
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Invalid ComfyUI URL. Must be a valid HTTP/HTTPS URL.');
175
+ }
176
+ // Validate output binary key
177
+ (0, validation_1.validateOutputBinaryKey)(outputBinaryKey);
178
+ // Get input data
179
+ const inputData = this.getInputData();
180
+ if (!inputData || inputData.length === 0) {
181
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'No input data provided. Please provide a query text.');
182
+ }
183
+ // Get query from input
184
+ const firstItem = inputData[0];
185
+ const query = firstItem.json.query ||
186
+ firstItem.json.text ||
187
+ firstItem.json.prompt ||
188
+ '';
189
+ if (!query || query.trim().length === 0) {
190
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'No query found in input. Please provide a "query", "text", or "prompt" field with a description of the image you want to generate.');
191
+ }
192
+ logger.info('Processing image generation request', { query, comfyUiUrl, timeout });
193
+ // Parse the query to extract parameters
194
+ const params = (0, agentToolHelpers_1.parseInput)(query, {
195
+ negativePrompt: defaultNegativePrompt,
196
+ width: defaultWidth,
197
+ height: defaultHeight,
198
+ steps: defaultSteps,
199
+ cfg: defaultCfg,
200
+ });
201
+ logger.debug('Parsed parameters', {
202
+ prompt: params.prompt,
203
+ width: params.width,
204
+ height: params.height,
205
+ steps: params.steps,
206
+ cfg: params.cfg,
207
+ seed: params.seed,
208
+ });
209
+ // Get workflow template
210
+ let workflowTemplate;
211
+ if (customWorkflow && customWorkflow.trim().length > 0) {
212
+ workflowTemplate = (0, validation_1.safeJsonParse)(customWorkflow, 'Custom workflow JSON');
213
+ }
214
+ else {
215
+ workflowTemplate = (0, workflowConfig_1.getWorkflowTemplate)();
216
+ }
217
+ // Update workflow with parsed parameters
218
+ const workflow = (0, agentToolHelpers_1.updateWorkflow)(workflowTemplate, params);
219
+ // Create ComfyUI client
220
+ const client = new ComfyUiClient_1.ComfyUIClient({
221
+ baseUrl: comfyUiUrl,
222
+ timeout: timeout * 1000,
223
+ helpers: this.helpers,
224
+ logger,
225
+ });
226
+ try {
227
+ logger.info('Starting ComfyUI workflow execution');
228
+ // Execute workflow
229
+ const result = await client.executeWorkflow(workflow);
230
+ if (!result.success) {
231
+ logger.error('Workflow execution failed', result.error);
232
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Failed to generate image: ${result.error}`);
233
+ }
234
+ // Process results
235
+ const { json, binary } = await client.processResults(result, outputBinaryKey);
236
+ // Add metadata to JSON output
237
+ const enhancedJson = {
238
+ ...json,
239
+ prompt: params.prompt,
240
+ parameters: {
241
+ width: params.width,
242
+ height: params.height,
243
+ steps: params.steps,
244
+ cfg: params.cfg,
245
+ seed: params.seed,
246
+ negative_prompt: params.negative_prompt,
247
+ },
248
+ };
249
+ logger.info('Image generation completed successfully', {
250
+ imageCount: json.imageCount,
251
+ });
252
+ return [this.helpers.constructExecutionMetaData([{ json: enhancedJson, binary }], { itemData: { item: 0 } })];
253
+ }
254
+ catch (error) {
255
+ logger.error('Error during workflow execution', error);
256
+ throw error;
257
+ }
258
+ finally {
259
+ client.destroy();
260
+ logger.debug('Client destroyed');
261
+ }
262
+ }
263
+ }
264
+ exports.ComfyUiTool = ComfyUiTool;
265
+ //# sourceMappingURL=ComfyUiTool.node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ComfyUiTool.node.js","sourceRoot":"","sources":["../../nodes/ComfyUiTool.node.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,+CAIsB;AAEtB,mDAAgD;AAChD,6CAAmF;AAEnF,qCAAwC;AACxC,yDAAgE;AAChE,qDAAuD;AAEvD,MAAa,WAAW;IAAxB;QACE;;WAEG;QACH,gBAAW,GAAG;YACZ,WAAW,EAAE,cAAc;YAC3B,IAAI,EAAE,aAAa;YACnB,IAAI,EAAE,kBAAkB;YACxB,SAAS,EAAE,SAAS;YACpB,KAAK,EAAE,CAAC,WAAW,CAAC;YACpB,OAAO,EAAE,CAAC,CAAC,CAAC;YACZ,cAAc,EAAE,CAAC;YACjB,WAAW,EAAE,6EAA6E;YAC1F,QAAQ,EAAE;gBACR,IAAI,EAAE,cAAc;aACrB;YACD,YAAY,EAAE,IAAI;YAClB,MAAM,EAAE,CAAC,MAAM,CAAC;YAChB,OAAO,EAAE,CAAC,MAAM,CAAC;YACjB,QAAQ,EAAE,oBAAoB;YAC9B,KAAK,EAAE;gBACL,8BAA8B;gBAC9B,+CAA+C;gBAC/C,iEAAiE;gBACjE,wDAAwD;aACzD;YACD,WAAW,EAAE;gBACX,KAAK,EAAE,gCAAgC;aACxC;YACD,YAAY,EAAE;gBACZ,IAAI,EAAE;oBACJ,OAAO,EAAE,IAAI;oBACb,UAAU,EAAE,CAAC;oBACb,SAAS,EAAE,CAAC,uDAAuD,CAAC;oBACpE,MAAM,EAAE,gCAAgC;oBACxC,UAAU,EAAE;wBACV,KAAK,EAAE,GAAG;wBACV,MAAM,EAAE,GAAG;wBACX,KAAK,EAAE,EAAE;wBACT,GAAG,EAAE,CAAC;wBACN,IAAI,EAAE,SAAS;qBAChB;iBACF;gBACD,MAAM,EAAE;oBACN,IAAI,EAAE;wBACJ,IAAI,EAAE,2BAA2B;wBACjC,QAAQ,EAAE,WAA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* Agent Tool Helpers - Utility functions for AI Agent-friendly ComfyUI nodes
3
+ *
4
+ * This file contains helper functions for parsing natural language queries
5
+ * and updating ComfyUI workflows, designed to be used by agent-friendly nodes.
6
+ */
7
+ import type { INodeExecutionData } from 'n8n-workflow';
8
+ import { Workflow, ParsedParameters, ParameterPattern, ParameterExtractionResult, BinaryData } from './types';
9
+ export declare const DEFAULT_NEGATIVE_PROMPT = "ugly, blurry, low quality, distorted";
10
+ export declare const DEFAULT_WIDTH = 512;
11
+ export declare const DEFAULT_HEIGHT = 512;
12
+ export declare const DEFAULT_STEPS = 20;
13
+ export declare const DEFAULT_CFG = 8;
14
+ export declare const MAX_SEED_VALUE = 2147483647;
15
+ export declare const PARAM_PATTERNS: Record<string, ParameterPattern>;
16
+ /**
17
+ * Extract parameter from query
18
+ * @param query - User query text
19
+ * @param pattern - Parameter pattern configuration
20
+ * @returns Extracted parameter and cleaned query
21
+ */
22
+ export declare function extractParameter(query: string, pattern: ParameterPattern): ParameterExtractionResult;
23
+ /**
24
+ * Parse user input to extract image generation parameters
25
+ * @param query - User query text
26
+ * @param defaults - Default parameter values
27
+ * @returns Parsed parameters object
28
+ */
29
+ export declare function parseInput(query: string, defaults?: {
30
+ negativePrompt?: string;
31
+ width?: number;
32
+ height?: number;
33
+ steps?: number;
34
+ cfg?: number;
35
+ }): ParsedParameters;
36
+ /**
37
+ * Find node ID by node type
38
+ * @param workflow - Workflow object
39
+ * @param classType - Node type
40
+ * @returns Node ID or null
41
+ */
42
+ export declare function findNodeByClassType(workflow: Workflow, classType: string): string | null;
43
+ /**
44
+ * Update workflow parameters
45
+ * @param workflow - ComfyUI workflow object
46
+ * @param params - Parameters object
47
+ * @returns Updated workflow
48
+ */
49
+ export declare function updateWorkflow(workflow: Workflow, params: ParsedParameters): Workflow;
50
+ /**
51
+ * Update workflow with uploaded image filename
52
+ * @param workflow - ComfyUI workflow object
53
+ * @param imageFilename - Uploaded image filename
54
+ * @returns Updated workflow
55
+ */
56
+ export declare function updateWorkflowWithImage(workflow: Workflow, imageFilename: string): Workflow;
57
+ /**
58
+ * Extract binary data from input data
59
+ * @param inputData - Input data from n8n
60
+ * @param binaryKey - Binary property key (default: 'data')
61
+ * @returns Binary data or null
62
+ */
63
+ export declare function extractBinaryData(inputData: INodeExecutionData[], binaryKey?: string): BinaryData | null;
64
+ /**
65
+ * Check if input contains binary image data
66
+ * @param inputData - Input data from n8n
67
+ * @returns True if binary data is present
68
+ */
69
+ export declare function hasBinaryData(inputData: INodeExecutionData[]): boolean;
70
+ /**
71
+ * Get first binary key from input data
72
+ * @param inputData - Input data from n8n
73
+ * @returns First binary key or null
74
+ */
75
+ export declare function getFirstBinaryKey(inputData: INodeExecutionData[]): string | null;
76
+ /**
77
+ * Apply structured parameters to workflow
78
+ * Intelligently maps parameters to the correct nodes in the workflow
79
+ * @param workflow - ComfyUI workflow object
80
+ * @param params - Parameters object with parameter names and values
81
+ * @returns Updated workflow
82
+ */
83
+ export declare function applyStructuredParameters(workflow: Workflow, params: Record<string, unknown>): Workflow;
84
+ /**
85
+ * Apply parameters to a specific node in the workflow
86
+ * Used by ComfyUiTool when user has configured which node/parameters AI can modify
87
+ * @param workflow - ComfyUI workflow object
88
+ * @param nodeId - Target node ID
89
+ * @param params - Parameters to apply
90
+ * @returns Updated workflow
91
+ */
92
+ export declare function applyParametersToNode(workflow: Workflow, nodeId: string, params: Record<string, unknown>): Workflow;
93
+ //# sourceMappingURL=agentToolHelpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agentToolHelpers.d.ts","sourceRoot":"","sources":["../../nodes/agentToolHelpers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EACL,QAAQ,EACR,gBAAgB,EAChB,gBAAgB,EAChB,yBAAyB,EACzB,UAAU,EACX,MAAM,SAAS,CAAC;AAGjB,eAAO,MAAM,uBAAuB,yCAAyC,CAAC;AA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