n8n-nodes-pdf-api-hub 4.0.18 → 4.0.20

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.
@@ -1,22 +1,4 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64" fill="none" aria-label="PDF API Hub">
3
- <defs>
4
- <linearGradient id="bg" x1="8" y1="8" x2="56" y2="56" gradientUnits="userSpaceOnUse">
5
- <stop offset="0" stop-color="#0B1220"/>
6
- <stop offset="1" stop-color="#1F1B3A"/>
7
- </linearGradient>
8
- </defs>
9
-
10
- <!-- Slight inset so it doesn't look full-bleed in n8n -->
11
- <rect x="4" y="4" width="56" height="56" rx="12" fill="url(#bg)" stroke="#334155" stroke-width="1"/>
12
-
13
- <!-- Centered logo text: </pdf> -->
14
- <text x="32" y="33" text-anchor="middle" dominant-baseline="middle"
15
- font-family="ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace"
16
- font-size="18" font-weight="700" letter-spacing="-0.5">
17
- <tspan fill="#E2E8F0">&lt;/</tspan><tspan fill="#A78BFA">pdf</tspan><tspan fill="#E2E8F0">&gt;</tspan>
18
- </text>
19
-
20
- <!-- Small page corner mark -->
21
- <path d="M44 18h-6a2 2 0 0 0-2 2v6" stroke="#64748B" stroke-width="2" stroke-linecap="round"/>
2
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64">
3
+ <text x="32" y="40" text-anchor="middle" font-family="Arial, Helvetica, sans-serif" font-size="28" font-weight="bold" fill="#F77522">PDF</text>
22
4
  </svg>
@@ -1,22 +1,4 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64" fill="none" aria-label="PDF API Hub">
3
- <defs>
4
- <linearGradient id="bg" x1="8" y1="8" x2="56" y2="56" gradientUnits="userSpaceOnUse">
5
- <stop offset="0" stop-color="#EEF2FF"/>
6
- <stop offset="1" stop-color="#DDD6FE"/>
7
- </linearGradient>
8
- </defs>
9
-
10
- <!-- Slight inset so it doesn't look full-bleed in n8n -->
11
- <rect x="4" y="4" width="56" height="56" rx="12" fill="url(#bg)" stroke="#CBD5E1" stroke-width="1"/>
12
-
13
- <!-- Centered logo text: </pdf> -->
14
- <text x="32" y="33" text-anchor="middle" dominant-baseline="middle"
15
- font-family="ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace"
16
- font-size="18" font-weight="700" letter-spacing="-0.5">
17
- <tspan fill="#0F172A">&lt;/</tspan><tspan fill="#6D28D9">pdf</tspan><tspan fill="#0F172A">&gt;</tspan>
18
- </text>
19
-
20
- <!-- Small page corner mark (subtle, optional) -->
21
- <path d="M44 18h-6a2 2 0 0 0-2 2v6" stroke="#94A3B8" stroke-width="2" stroke-linecap="round"/>
2
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64">
3
+ <text x="32" y="40" text-anchor="middle" font-family="Arial, Helvetica, sans-serif" font-size="28" font-weight="bold" fill="#F77522">PDF</text>
22
4
  </svg>
@@ -1,5 +1,18 @@
1
- import type { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
1
+ import type { IExecuteFunctions, ILoadOptionsFunctions, INodeExecutionData, INodePropertyOptions, INodeType, INodeTypeDescription, ResourceMapperFields } from 'n8n-workflow';
2
2
  export declare class PdfSplitMerge implements INodeType {
3
3
  description: INodeTypeDescription;
4
+ methods: {
5
+ loadOptions: {
6
+ getTemplates(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
7
+ getStarterTemplates(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
8
+ };
9
+ resourceMapping: {
10
+ getTemplatePlaceholderFields(this: ILoadOptionsFunctions): Promise<ResourceMapperFields>;
11
+ getStarterTemplatePlaceholders(this: ILoadOptionsFunctions): Promise<ResourceMapperFields>;
12
+ getStarterTemplatePlaceholdersImage(this: ILoadOptionsFunctions): Promise<ResourceMapperFields>;
13
+ getStarterTemplateHtml(this: ILoadOptionsFunctions): Promise<ResourceMapperFields>;
14
+ getStarterTemplateHtmlImage(this: ILoadOptionsFunctions): Promise<ResourceMapperFields>;
15
+ };
16
+ };
4
17
  execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
5
18
  }
@@ -31,6 +31,220 @@ class PdfSplitMerge {
31
31
  ...actions_1.allActionDescriptions,
32
32
  ],
33
33
  };
34
+ this.methods = {
35
+ loadOptions: {
36
+ async getTemplates() {
37
+ var _a;
38
+ const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'pdfapihubApi', {
39
+ method: 'GET',
40
+ url: 'https://pdfapihub.com/api/v1/templates',
41
+ json: true,
42
+ });
43
+ const templates = (_a = responseData.templates) !== null && _a !== void 0 ? _a : [];
44
+ return templates.map((t) => ({
45
+ name: t.name || t.template_id,
46
+ value: t.template_id,
47
+ }));
48
+ },
49
+ async getStarterTemplates() {
50
+ try {
51
+ const responseData = await this.helpers.httpRequest({
52
+ method: 'GET',
53
+ url: 'https://pdfapihub.com/starter-templates.json',
54
+ json: true,
55
+ });
56
+ return [
57
+ { name: '— None —', value: '' },
58
+ ...responseData.map((t) => ({
59
+ name: t.category ? `${t.category}: ${t.title}` : t.title,
60
+ value: t.id,
61
+ })),
62
+ ];
63
+ }
64
+ catch {
65
+ return [{ name: '— None —', value: '' }];
66
+ }
67
+ },
68
+ },
69
+ resourceMapping: {
70
+ async getTemplatePlaceholderFields() {
71
+ var _a;
72
+ const templateId = this.getCurrentNodeParameter('gen_template_id');
73
+ if (!templateId)
74
+ return { fields: [] };
75
+ try {
76
+ const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'pdfapihubApi', {
77
+ method: 'GET',
78
+ url: `https://pdfapihub.com/api/v1/templates/${encodeURIComponent(templateId)}`,
79
+ json: true,
80
+ });
81
+ const keys = new Set();
82
+ if (responseData.default_params) {
83
+ for (const k of Object.keys(responseData.default_params)) {
84
+ keys.add(k);
85
+ }
86
+ }
87
+ if (responseData.html_content) {
88
+ const patterns = [
89
+ /\{\{@(\w+)\}\}/g,
90
+ /\{\{\$(\w+)\}\}/g,
91
+ /\$\{(\w+)\}/g,
92
+ /\{(\w+)\}/g,
93
+ /%(\w+)%/g,
94
+ ];
95
+ for (const pattern of patterns) {
96
+ let match;
97
+ while ((match = pattern.exec(responseData.html_content)) !== null) {
98
+ keys.add(match[1]);
99
+ }
100
+ }
101
+ }
102
+ const defaultParams = (_a = responseData.default_params) !== null && _a !== void 0 ? _a : {};
103
+ return {
104
+ fields: Array.from(keys).sort().map((k) => {
105
+ var _a;
106
+ return ({
107
+ id: k,
108
+ displayName: k,
109
+ type: 'string',
110
+ required: false,
111
+ defaultMatch: false,
112
+ display: true,
113
+ defaultValue: (_a = defaultParams[k]) !== null && _a !== void 0 ? _a : '',
114
+ });
115
+ }),
116
+ };
117
+ }
118
+ catch {
119
+ return { fields: [] };
120
+ }
121
+ },
122
+ async getStarterTemplatePlaceholders() {
123
+ const templateId = this.getCurrentNodeParameter('starter_template');
124
+ if (!templateId)
125
+ return { fields: [] };
126
+ try {
127
+ const allTemplates = await this.helpers.httpRequest({
128
+ method: 'GET',
129
+ url: 'https://pdfapihub.com/starter-templates.json',
130
+ json: true,
131
+ });
132
+ const template = allTemplates.find((t) => t.id === templateId);
133
+ if (!template)
134
+ return { fields: [] };
135
+ return {
136
+ fields: template.fields.map((f) => {
137
+ var _a;
138
+ return ({
139
+ id: f.key,
140
+ displayName: f.label || f.key,
141
+ type: 'string',
142
+ required: false,
143
+ defaultMatch: false,
144
+ display: true,
145
+ defaultValue: (_a = f.defaultValue) !== null && _a !== void 0 ? _a : '',
146
+ });
147
+ }),
148
+ };
149
+ }
150
+ catch {
151
+ return { fields: [] };
152
+ }
153
+ },
154
+ async getStarterTemplatePlaceholdersImage() {
155
+ const templateId = this.getCurrentNodeParameter('image_starter_template');
156
+ if (!templateId)
157
+ return { fields: [] };
158
+ try {
159
+ const allTemplates = await this.helpers.httpRequest({
160
+ method: 'GET',
161
+ url: 'https://pdfapihub.com/starter-templates.json',
162
+ json: true,
163
+ });
164
+ const template = allTemplates.find((t) => t.id === templateId);
165
+ if (!template)
166
+ return { fields: [] };
167
+ return {
168
+ fields: template.fields.map((f) => {
169
+ var _a;
170
+ return ({
171
+ id: f.key,
172
+ displayName: f.label || f.key,
173
+ type: 'string',
174
+ required: false,
175
+ defaultMatch: false,
176
+ display: true,
177
+ defaultValue: (_a = f.defaultValue) !== null && _a !== void 0 ? _a : '',
178
+ });
179
+ }),
180
+ };
181
+ }
182
+ catch {
183
+ return { fields: [] };
184
+ }
185
+ },
186
+ async getStarterTemplateHtml() {
187
+ var _a;
188
+ const templateId = this.getCurrentNodeParameter('starter_template');
189
+ if (!templateId)
190
+ return { fields: [] };
191
+ try {
192
+ const allTemplates = await this.helpers.httpRequest({
193
+ method: 'GET',
194
+ url: 'https://pdfapihub.com/starter-templates.json',
195
+ json: true,
196
+ });
197
+ const template = allTemplates.find((t) => t.id === templateId);
198
+ if (!template)
199
+ return { fields: [] };
200
+ return {
201
+ fields: [{
202
+ id: 'html_content',
203
+ displayName: 'HTML Content',
204
+ type: 'string',
205
+ required: false,
206
+ defaultMatch: false,
207
+ display: true,
208
+ defaultValue: (_a = template.html) !== null && _a !== void 0 ? _a : '',
209
+ }],
210
+ };
211
+ }
212
+ catch {
213
+ return { fields: [] };
214
+ }
215
+ },
216
+ async getStarterTemplateHtmlImage() {
217
+ var _a;
218
+ const templateId = this.getCurrentNodeParameter('image_starter_template');
219
+ if (!templateId)
220
+ return { fields: [] };
221
+ try {
222
+ const allTemplates = await this.helpers.httpRequest({
223
+ method: 'GET',
224
+ url: 'https://pdfapihub.com/starter-templates.json',
225
+ json: true,
226
+ });
227
+ const template = allTemplates.find((t) => t.id === templateId);
228
+ if (!template)
229
+ return { fields: [] };
230
+ return {
231
+ fields: [{
232
+ id: 'html_content',
233
+ displayName: 'HTML Content',
234
+ type: 'string',
235
+ required: false,
236
+ defaultMatch: false,
237
+ display: true,
238
+ defaultValue: (_a = template.html) !== null && _a !== void 0 ? _a : '',
239
+ }],
240
+ };
241
+ }
242
+ catch {
243
+ return { fields: [] };
244
+ }
245
+ },
246
+ },
247
+ };
34
248
  }
35
249
  async execute() {
36
250
  return actions_1.executePdfSplitMerge.call(this);
@@ -1 +1 @@
1
- {"version":3,"file":"PdfSplitMerge.node.js","sourceRoot":"","sources":["../../../nodes/PdfSplitMerge/PdfSplitMerge.node.ts"],"names":[],"mappings":";;;AAMA,+CAAmD;AACnD,uCAAwE;AACxE,iDAAuE;AAEvE,MAAa,aAAa;IAA1B;QACC,gBAAW,GAAyB;YACnC,WAAW,EAAE,aAAa;YAC1B,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,EAAE,KAAK,EAAE,mCAAmC,EAAE,IAAI,EAAE,kCAAkC,EAAE;YAC9F,KAAK,EAAE,CAAC,WAAW,CAAC;YACpB,OAAO,EAAE,CAAC;YACV,WAAW,EACV,iIAAiI;YAClI,QAAQ,EAAE;gBACT,IAAI,EAAE,aAAa;aACnB;YACD,MAAM,EAAE,CAAC,kCAAmB,CAAC,IAAI,CAAC;YAClC,OAAO,EAAE,CAAC,kCAAmB,CAAC,IAAI,CAAC;YACnC,WAAW,EAAE;gBACZ;oBACC,IAAI,EAAE,cAAc;oBACpB,QAAQ,EAAE,IAAI;iBACd;aACD;YACD,YAAY,EAAE,IAAI;YAClB,UAAU,EAAE;gBACX,+BAAgB;gBAChB,GAAG,kCAAmB;gBACtB,GAAG,+BAAqB;aACxB;SACD,CAAC;IAKH,CAAC;IAHA,KAAK,CAAC,OAAO;QACZ,OAAO,8BAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;CACD;AA/BD,sCA+BC"}
1
+ {"version":3,"file":"PdfSplitMerge.node.js","sourceRoot":"","sources":["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EAAE,cAAc;oCAClB,WAAW,EAAE,cAAc;oCAC3B,IAAI,EAAE,QAAiB;oCACvB,QAAQ,EAAE,KAAK;oCACf,YAAY,EAAE,KAAK;oCACnB,OAAO,EAAE,IAAI;oCACb,YAAY,EAAE,MAAA,QAAQ,CAAC,IAAI,mCAAI,EAAE;iCAE1B,CAAC;yBACT,CAAC;oBACH,CAAC;oBAAC,MAAM,CAAC;wBACR,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;oBACvB,CAAC;gBACF,CAAC;aACD;SACD,CAAC;IAKH,CAAC;IAHA,KAAK,CAAC,OAAO;QACZ,OAAO,8BAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;CACD;AAtQD,sCAsQC"}
@@ -0,0 +1,3 @@
1
+ import type { IExecuteFunctions, INodeExecutionData, INodeProperties } from 'n8n-workflow';
2
+ export declare const description: INodeProperties[];
3
+ export declare function execute(this: IExecuteFunctions, index: number, returnData: INodeExecutionData[], operation: string): Promise<void>;
@@ -0,0 +1,167 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.description = void 0;
4
+ exports.execute = execute;
5
+ const helpers_1 = require("../helpers");
6
+ const BASE_URL = 'https://pdfapihub.com/api';
7
+ exports.description = [
8
+ {
9
+ displayName: 'Template Name or ID',
10
+ name: 'gen_template_id',
11
+ type: 'options',
12
+ typeOptions: { loadOptionsMethod: 'getTemplates' },
13
+ default: '',
14
+ required: true,
15
+ description: 'Select a saved template. Create new templates at <a href="https://pdfapihub.com/template-studio" target="_blank">Template Studio</a>. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
16
+ displayOptions: { show: { operation: ['templateToPdf', 'templateToImage'] } },
17
+ },
18
+ {
19
+ displayName: 'Output Format',
20
+ name: 'gen_tpl_output_format',
21
+ type: 'options',
22
+ options: [
23
+ {
24
+ name: 'URL (Hosted Link)',
25
+ value: 'url',
26
+ description: 'Returns a downloadable URL — file hosted for 30 days',
27
+ },
28
+ {
29
+ name: 'Binary File (Download)',
30
+ value: 'file',
31
+ description: 'Returns raw binary — great for piping into other nodes',
32
+ },
33
+ ],
34
+ default: 'url',
35
+ description: 'How the generated file is returned',
36
+ displayOptions: { show: { operation: ['templateToPdf', 'templateToImage'] } },
37
+ },
38
+ {
39
+ displayName: 'Dynamic Params',
40
+ name: 'gen_tpl_dynamic_params',
41
+ type: 'resourceMapper',
42
+ noDataExpression: true,
43
+ default: {
44
+ mappingMode: 'defineBelow',
45
+ value: null,
46
+ },
47
+ description: "Key/value pairs that replace placeholders in the template. All template placeholders are loaded automatically — fill in values and remove any you don't need.",
48
+ displayOptions: { show: { operation: ['templateToPdf', 'templateToImage'] } },
49
+ typeOptions: {
50
+ loadOptionsDependsOn: ['gen_template_id'],
51
+ resourceMapper: {
52
+ resourceMapperMethod: 'getTemplatePlaceholderFields',
53
+ mode: 'add',
54
+ fieldWords: {
55
+ singular: 'placeholder',
56
+ plural: 'placeholders',
57
+ },
58
+ addAllFields: true,
59
+ multiKeyMatch: false,
60
+ supportAutoMap: false,
61
+ },
62
+ },
63
+ },
64
+ {
65
+ displayName: 'Custom Dynamic Params',
66
+ name: 'gen_tpl_dynamic_params_manual',
67
+ type: 'fixedCollection',
68
+ typeOptions: { multipleValues: true },
69
+ default: {},
70
+ description: 'Additional custom key/value pairs. These are merged with the template placeholders above (manual values win on conflict).',
71
+ displayOptions: { show: { operation: ['templateToPdf', 'templateToImage'] } },
72
+ options: [
73
+ {
74
+ name: 'params',
75
+ displayName: 'Parameter',
76
+ values: [
77
+ {
78
+ displayName: 'Key',
79
+ name: 'key',
80
+ type: 'string',
81
+ default: '',
82
+ placeholder: 'custom_field',
83
+ description: 'Placeholder key \u2014 without the {{ }} braces',
84
+ },
85
+ {
86
+ displayName: 'Value',
87
+ name: 'value',
88
+ type: 'string',
89
+ default: '',
90
+ placeholder: 'My Value',
91
+ description: 'Replacement value for this placeholder',
92
+ },
93
+ ],
94
+ },
95
+ ],
96
+ },
97
+ ];
98
+ async function execute(index, returnData, operation) {
99
+ var _a, _b;
100
+ const templateId = this.getNodeParameter('gen_template_id', index);
101
+ const outputFormat = this.getNodeParameter('gen_tpl_output_format', index);
102
+ const body = {
103
+ template_id: templateId,
104
+ output_format: outputFormat,
105
+ };
106
+ const allDynamic = {};
107
+ const dynamicParamsRaw = this.getNodeParameter('gen_tpl_dynamic_params', index, {});
108
+ if (dynamicParamsRaw.value && typeof dynamicParamsRaw.value === 'object') {
109
+ for (const [k, v] of Object.entries(dynamicParamsRaw.value)) {
110
+ if (k)
111
+ allDynamic[k] = v !== null && v !== void 0 ? v : '';
112
+ }
113
+ }
114
+ const manualParams = this.getNodeParameter('gen_tpl_dynamic_params_manual', index, {});
115
+ if ((_a = manualParams.params) === null || _a === void 0 ? void 0 : _a.length) {
116
+ for (const p of manualParams.params) {
117
+ if (p.key)
118
+ allDynamic[p.key] = (_b = p.value) !== null && _b !== void 0 ? _b : '';
119
+ }
120
+ }
121
+ if (Object.keys(allDynamic).length)
122
+ body.dynamic_params = allDynamic;
123
+ const isPdf = operation === 'templateToPdf';
124
+ const endpoint = isPdf
125
+ ? `${BASE_URL}/v1/generatePdf`
126
+ : `${BASE_URL}/v1/generateImage`;
127
+ const fallbackFileName = isPdf ? 'template-output.pdf' : 'template-output.png';
128
+ const fallbackMimeType = isPdf ? 'application/pdf' : 'image/png';
129
+ if (outputFormat === 'file') {
130
+ const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'pdfapihubApi', {
131
+ method: 'POST',
132
+ url: endpoint,
133
+ body,
134
+ json: true,
135
+ encoding: 'arraybuffer',
136
+ returnFullResponse: true,
137
+ ignoreHttpStatusErrors: true,
138
+ });
139
+ if (responseData.statusCode >= 400) {
140
+ let errorBody;
141
+ try {
142
+ errorBody = JSON.parse(Buffer.from(responseData.body).toString('utf8'));
143
+ }
144
+ catch {
145
+ errorBody = {};
146
+ }
147
+ (0, helpers_1.checkApiResponse)(this, responseData.statusCode, errorBody, index);
148
+ }
149
+ returnData.push(await helpers_1.prepareBinaryResponse.call(this, index, responseData, fallbackFileName, fallbackMimeType));
150
+ }
151
+ else {
152
+ const responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'pdfapihubApi', {
153
+ method: 'POST',
154
+ url: endpoint,
155
+ body,
156
+ json: true,
157
+ returnFullResponse: true,
158
+ ignoreHttpStatusErrors: true,
159
+ });
160
+ (0, helpers_1.checkApiResponse)(this, responseData.statusCode, responseData.body, index);
161
+ returnData.push({
162
+ json: responseData.body,
163
+ pairedItem: { item: index },
164
+ });
165
+ }
166
+ }
167
+ //# sourceMappingURL=generateFromTemplate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateFromTemplate.js","sourceRoot":"","sources":["../../../../nodes/PdfSplitMerge/actions/generateFromTemplate.ts"],"names":[],"mappings":";;;AAuHA,0BAmGC;AApND,wCAAqE;AAErE,MAAM,QAAQ,GAAG,2BAA2B,CAAC;AAMhC,QAAA,WAAW,GAAsB;IAE7C;QACC,WAAW,EAAE,qBAAqB;QAClC,IAAI,EAAE,iBAAiB;QACvB,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,EAAE,iBAAiB,EAAE,cAAc,EAAE;QAClD,OAAO,EAAE,EAAE;QACX,QAAQ,EAAE,IAAI;QACd,WAAW,EACV,uPAAuP;QACxP,cAAc,EAAE,EAAE,IAAI,EAAE,EAAE,SAAS,EAAE,CAAC,eAAe,EAAE,iBAAiB,CAAC,EAAE,EAAE;KAC7E;IAGD;QACC,WAAW,EAAE,eAAe;QAC5B,IAAI,EAAE,uBAAuB;QAC7B,IAAI,EAAE,SAAS;QACf,OAAO,EAAE;YACR;gBACC,IAAI,EAAE,mBAAmB;gBACzB,KAAK,EAAE,KAAK;gBACZ,WAAW,EAAE,sDAAsD;aACnE;YACD;gBACC,IAAI,EAAE,wBAAwB;gBAC9B,KAAK,EAAE,MAAM;gBACb,WAAW,EAAE,wDAAwD;aACrE;SACD;QACD,OAA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