@analogjs/vite-plugin-angular 0.2.0-alpha.0 → 0.2.0-alpha.3
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/package.json +1 -1
- package/src/lib/angular-vite-plugin.d.ts +3 -4
- package/src/lib/angular-vite-plugin.js +206 -103
- package/src/lib/angular-vite-plugin.js.map +1 -1
- package/src/lib/component-resolvers.d.ts +4 -0
- package/src/lib/component-resolvers.js +35 -0
- package/src/lib/component-resolvers.js.map +1 -0
package/package.json
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { BundleStylesheetOptions } from '@angular-devkit/build-angular/src/builders/browser-esbuild/stylesheets';
|
|
2
1
|
import * as ts from 'typescript';
|
|
3
2
|
import { Plugin } from 'vite';
|
|
4
3
|
interface PluginOptions {
|
|
5
4
|
tsconfig: string;
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
mode: string;
|
|
6
|
+
workspaceRoot: string;
|
|
8
7
|
}
|
|
9
8
|
interface EmitFileResult {
|
|
10
9
|
content?: string;
|
|
@@ -13,6 +12,6 @@ interface EmitFileResult {
|
|
|
13
12
|
hash?: Uint8Array;
|
|
14
13
|
}
|
|
15
14
|
declare type FileEmitter = (file: string) => Promise<EmitFileResult | undefined>;
|
|
16
|
-
export declare function angular(pluginOptions?: PluginOptions
|
|
15
|
+
export declare function angular(pluginOptions?: PluginOptions): Plugin[];
|
|
17
16
|
export declare function createFileEmitter(program: ts.BuilderProgram, transformers?: ts.CustomTransformers, onAfterEmit?: (sourceFile: ts.SourceFile) => void): FileEmitter;
|
|
18
17
|
export {};
|
|
@@ -4,16 +4,15 @@ exports.createFileEmitter = exports.angular = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const core_1 = require("@babel/core");
|
|
6
6
|
const application_1 = require("@angular-devkit/build-angular/src/babel/presets/application");
|
|
7
|
+
const webpack_loader_1 = require("@angular-devkit/build-angular/src/babel/webpack-loader");
|
|
7
8
|
const ts = require("typescript");
|
|
8
9
|
const compiler_plugin_1 = require("@angular-devkit/build-angular/src/builders/browser-esbuild/compiler-plugin");
|
|
9
10
|
const load_esm_1 = require("@angular-devkit/build-angular/src/utils/load-esm");
|
|
11
|
+
const component_resolvers_1 = require("./component-resolvers");
|
|
10
12
|
function angular(pluginOptions = {
|
|
11
13
|
tsconfig: './tsconfig.app.json',
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}, styleOptions = {
|
|
15
|
-
optimization: false,
|
|
16
|
-
sourcemap: true,
|
|
14
|
+
mode: 'development',
|
|
15
|
+
workspaceRoot: process.cwd()
|
|
17
16
|
}) {
|
|
18
17
|
// The file emitter created during `onStart` that will be used during the build in `onLoad` callbacks for TS files
|
|
19
18
|
let fileEmitter;
|
|
@@ -29,109 +28,213 @@ function angular(pluginOptions = {
|
|
|
29
28
|
let builderProgram;
|
|
30
29
|
let watchMode = false;
|
|
31
30
|
let sourceFileCache = new SourceFileCache();
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
inlineSources: pluginOptions.sourcemap,
|
|
63
|
-
inlineSourceMap: pluginOptions.sourcemap,
|
|
64
|
-
sourceMap: false,
|
|
65
|
-
mapRoot: undefined,
|
|
66
|
-
sourceRoot: undefined,
|
|
67
|
-
declaration: false,
|
|
68
|
-
declarationMap: false,
|
|
69
|
-
allowEmptyCodegenFiles: false,
|
|
70
|
-
annotationsAs: 'decorators',
|
|
71
|
-
enableResourceInlining: false,
|
|
31
|
+
let isProd = pluginOptions.mode === 'production';
|
|
32
|
+
return [
|
|
33
|
+
{
|
|
34
|
+
name: '@analogjs/vite-plugin-angular',
|
|
35
|
+
config(config, { command }) {
|
|
36
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
watchMode = command === 'serve';
|
|
38
|
+
compilerCli = yield (0, load_esm_1.loadEsmModule)('@angular/compiler-cli');
|
|
39
|
+
return {
|
|
40
|
+
optimizeDeps: {
|
|
41
|
+
esbuildOptions: {
|
|
42
|
+
plugins: [
|
|
43
|
+
(0, compiler_plugin_1.createCompilerPlugin)({
|
|
44
|
+
tsconfig: pluginOptions.tsconfig,
|
|
45
|
+
sourcemap: !isProd,
|
|
46
|
+
advancedOptimizations: isProd,
|
|
47
|
+
}, {
|
|
48
|
+
workspaceRoot: pluginOptions.workspaceRoot,
|
|
49
|
+
sourcemap: !isProd,
|
|
50
|
+
optimization: isProd,
|
|
51
|
+
}),
|
|
52
|
+
],
|
|
53
|
+
define: {
|
|
54
|
+
ngDevMode: watchMode ? JSON.stringify({}) : 'false',
|
|
55
|
+
ngJitMode: 'false',
|
|
56
|
+
ngI18nClosureMode: 'false',
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
};
|
|
72
61
|
});
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
62
|
+
},
|
|
63
|
+
buildStart() {
|
|
64
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
65
|
+
const { options: tsCompilerOptions, rootNames: rn } = compilerCli.readConfiguration(pluginOptions.tsconfig, {
|
|
66
|
+
enableIvy: true,
|
|
67
|
+
noEmitOnError: false,
|
|
68
|
+
suppressOutputPathCheck: true,
|
|
69
|
+
outDir: undefined,
|
|
70
|
+
inlineSources: !isProd,
|
|
71
|
+
inlineSourceMap: !isProd,
|
|
72
|
+
sourceMap: false,
|
|
73
|
+
mapRoot: undefined,
|
|
74
|
+
sourceRoot: undefined,
|
|
75
|
+
declaration: false,
|
|
76
|
+
declarationMap: false,
|
|
77
|
+
allowEmptyCodegenFiles: false,
|
|
78
|
+
annotationsAs: 'decorators',
|
|
79
|
+
enableResourceInlining: false,
|
|
80
|
+
});
|
|
81
|
+
rootNames = rn;
|
|
82
|
+
compilerOptions = tsCompilerOptions;
|
|
83
|
+
host = ts.createIncrementalCompilerHost(compilerOptions);
|
|
84
|
+
// Setup source file caching and reuse cache from previous compilation if present
|
|
85
|
+
let cache = new SourceFileCache();
|
|
86
|
+
// Only store cache if in watch mode
|
|
87
|
+
if (watchMode) {
|
|
88
|
+
sourceFileCache = cache;
|
|
89
|
+
}
|
|
90
|
+
augmentHostWithCaching(host, cache);
|
|
90
91
|
yield buildAndAnalyze();
|
|
91
|
-
}
|
|
92
|
-
}
|
|
92
|
+
});
|
|
93
|
+
},
|
|
94
|
+
handleHotUpdate(ctx) {
|
|
95
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
96
|
+
if (/\.[cm]?tsx?$/.test(ctx.file)) {
|
|
97
|
+
sourceFileCache.invalidate(ctx.file);
|
|
98
|
+
yield buildAndAnalyze();
|
|
99
|
+
}
|
|
100
|
+
if (/\.(html|htm|css|less|sass|scss)$/.test(ctx.file)) {
|
|
101
|
+
/**
|
|
102
|
+
* Check to see if this was a direct request
|
|
103
|
+
* for an external resource (styles, html).
|
|
104
|
+
*/
|
|
105
|
+
const isDirect = ctx.modules.find((mod) => { var _a; return ctx.file === mod.file && ((_a = mod.id) === null || _a === void 0 ? void 0 : _a.includes('?direct')); });
|
|
106
|
+
if (isDirect) {
|
|
107
|
+
return ctx.modules;
|
|
108
|
+
}
|
|
109
|
+
let mods = [];
|
|
110
|
+
ctx.modules.forEach((mod) => {
|
|
111
|
+
mod.importers.forEach((imp) => {
|
|
112
|
+
sourceFileCache.invalidate(imp.id);
|
|
113
|
+
ctx.server.moduleGraph.invalidateModule(imp);
|
|
114
|
+
mods.push(imp);
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
yield buildAndAnalyze();
|
|
118
|
+
return mods;
|
|
119
|
+
}
|
|
120
|
+
return ctx.modules;
|
|
121
|
+
});
|
|
122
|
+
},
|
|
123
|
+
transform(code, id) {
|
|
124
|
+
var _a, _b;
|
|
125
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
126
|
+
// Skip transforming node_modules
|
|
127
|
+
if (id.includes('node_modules')) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
if (/\.[cm]?tsx?$/.test(id)) {
|
|
131
|
+
if ((0, component_resolvers_1.hasTemplateUrl)(code)) {
|
|
132
|
+
const templateUrl = (0, component_resolvers_1.resolveTemplateUrl)(code, id);
|
|
133
|
+
if (templateUrl) {
|
|
134
|
+
this.addWatchFile(templateUrl);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if ((0, component_resolvers_1.hasStyleUrls)(code)) {
|
|
138
|
+
const styleUrls = (0, component_resolvers_1.resolveStyleUrls)(code, id);
|
|
139
|
+
styleUrls.forEach((styleUrl) => {
|
|
140
|
+
this.addWatchFile(styleUrl);
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
const typescriptResult = yield fileEmitter(id);
|
|
144
|
+
// return fileEmitter
|
|
145
|
+
const data = (_a = typescriptResult === null || typescriptResult === void 0 ? void 0 : typescriptResult.content) !== null && _a !== void 0 ? _a : '';
|
|
146
|
+
const babelResult = yield (0, core_1.transformAsync)(data, {
|
|
147
|
+
filename: id,
|
|
148
|
+
inputSourceMap: (!isProd ? undefined : false),
|
|
149
|
+
sourceMaps: !isProd ? 'inline' : false,
|
|
150
|
+
compact: false,
|
|
151
|
+
configFile: false,
|
|
152
|
+
babelrc: false,
|
|
153
|
+
browserslistConfigFile: false,
|
|
154
|
+
plugins: [],
|
|
155
|
+
presets: [
|
|
156
|
+
[
|
|
157
|
+
application_1.default,
|
|
158
|
+
{
|
|
159
|
+
forceAsyncTransformation: data.includes('async'),
|
|
160
|
+
optimize: isProd && {},
|
|
161
|
+
},
|
|
162
|
+
],
|
|
163
|
+
],
|
|
164
|
+
});
|
|
165
|
+
return {
|
|
166
|
+
code: (_b = babelResult === null || babelResult === void 0 ? void 0 : babelResult.code) !== null && _b !== void 0 ? _b : '',
|
|
167
|
+
map: babelResult === null || babelResult === void 0 ? void 0 : babelResult.map,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
return undefined;
|
|
171
|
+
});
|
|
172
|
+
},
|
|
93
173
|
},
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
174
|
+
{
|
|
175
|
+
name: '@analogjs/vite-plugin-angular-optimizer',
|
|
176
|
+
apply: 'build',
|
|
177
|
+
config() {
|
|
178
|
+
return {
|
|
179
|
+
esbuild: {
|
|
180
|
+
legalComments: isProd ? 'none' : 'external',
|
|
181
|
+
keepNames: false,
|
|
182
|
+
define: isProd
|
|
183
|
+
? {
|
|
184
|
+
ngDevMode: 'false',
|
|
185
|
+
ngJitMode: 'false',
|
|
186
|
+
ngI18nClosureMode: 'false',
|
|
187
|
+
}
|
|
188
|
+
: undefined,
|
|
189
|
+
},
|
|
190
|
+
};
|
|
191
|
+
},
|
|
192
|
+
transform(code, id) {
|
|
193
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
194
|
+
if (/\.[cm]?js$/.test(id)) {
|
|
195
|
+
const angularPackage = /[\\/]node_modules[\\/]@angular[\\/]/.test(id);
|
|
196
|
+
const linkerPluginCreator = (yield (0, load_esm_1.loadEsmModule)('@angular/compiler-cli/linker/babel')).createEs2015LinkerPlugin;
|
|
197
|
+
const useInputSourcemap = !isProd;
|
|
198
|
+
const result = yield (0, core_1.transformAsync)(code, {
|
|
199
|
+
filename: id,
|
|
200
|
+
inputSourceMap: (useInputSourcemap
|
|
201
|
+
? undefined
|
|
202
|
+
: false),
|
|
203
|
+
sourceMaps: !isProd ? 'inline' : false,
|
|
204
|
+
compact: false,
|
|
205
|
+
configFile: false,
|
|
206
|
+
babelrc: false,
|
|
207
|
+
browserslistConfigFile: false,
|
|
208
|
+
plugins: [],
|
|
209
|
+
presets: [
|
|
210
|
+
[
|
|
211
|
+
application_1.default,
|
|
212
|
+
{
|
|
213
|
+
angularLinker: {
|
|
214
|
+
shouldLink: yield (0, webpack_loader_1.requiresLinking)(id, code),
|
|
215
|
+
jitMode: false,
|
|
216
|
+
linkerPluginCreator,
|
|
217
|
+
},
|
|
218
|
+
forceAsyncTransformation: !/[\\/][_f]?esm2015[\\/]/.test(id) &&
|
|
219
|
+
code.includes('async'),
|
|
220
|
+
optimize: isProd && {
|
|
221
|
+
looseEnums: angularPackage,
|
|
222
|
+
pureTopLevel: angularPackage,
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
],
|
|
123
226
|
],
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
227
|
+
});
|
|
228
|
+
return {
|
|
229
|
+
code: (result === null || result === void 0 ? void 0 : result.code) || '',
|
|
230
|
+
map: result === null || result === void 0 ? void 0 : result.map,
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
return;
|
|
234
|
+
});
|
|
235
|
+
},
|
|
133
236
|
},
|
|
134
|
-
|
|
237
|
+
];
|
|
135
238
|
/**
|
|
136
239
|
* Creates a new NgtscProgram to analyze/re-analyze
|
|
137
240
|
* the source files and create a file emitter.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"angular-vite-plugin.js","sourceRoot":"","sources":["../../../../../packages/vite-plugin-angular/src/lib/angular-vite-plugin.ts"],"names":[],"mappings":";;;;AACA,sCAA6C;AAC7C,6FAAmG;
|
|
1
|
+
{"version":3,"file":"angular-vite-plugin.js","sourceRoot":"","sources":["../../../../../packages/vite-plugin-angular/src/lib/angular-vite-plugin.ts"],"names":[],"mappings":";;;;AACA,sCAA6C;AAC7C,6FAAmG;AACnG,2FAAyF;AACzF,iCAAiC;AAGjC,gHAAkH;AAClH,+EAAiF;AACjF,+DAK+B;AAgB/B,SAAgB,OAAO,CACrB,gBAA+B;IAC7B,QAAQ,EAAE,qBAAqB;IAC/B,IAAI,EAAE,aAAa;IACnB,aAAa,EAAE,OAAO,CAAC,GAAG,EAAE;CAC7B;IAED,kHAAkH;IAClH,IAAI,WAAoC,CAAC;IACzC,IAAI,eAAe,GAAG,EAAE,CAAC;IACzB,gDAAgD;IAChD,MAAM,EACJ,iBAAiB,EACjB,gBAAgB,GACjB,GAAG,OAAO,CAAC,yCAAyC,CAAC,CAAC;IACvD,MAAM,EACJ,4BAA4B,EAC5B,sBAAsB,GACvB,GAAG,OAAO,CAAC,+BAA+B,CAAC,CAAC;IAC7C,MAAM,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,gCAAgC,CAAC,CAAC;IACtE,IAAI,WAAmD,CAAC;IACxD,IAAI,SAAmB,CAAC;IACxB,IAAI,IAAqB,CAAC;IAC1B,IAAI,WAAyB,CAAC;IAC9B,IAAI,cAA2D,CAAC;IAChE,IAAI,SAAS,GAAY,KAAK,CAAC;IAC/B,IAAI,eAAe,GAAG,IAAI,e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SAAS,CAAC;SAClB;QAED,IAAI,OAA2B,CAAC;QAChC,OAAO,CAAC,IAAI,CACV,UAAU,EACV,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE;YACjB,IAAI,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;gBAC/B,OAAO,GAAG,IAAI,CAAC;aAChB;QACH,CAAC,EACD,SAAS,CAAC,uBAAuB,EACjC,SAAS,CAAC,sBAAsB,EAChC,YAAY,CACb,CAAC;QAEF,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAG,UAAU,CAAC,CAAC;QAE1B,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC;IACvC,CAAC,CAAA,CAAC;AACJ,CAAC;AA5BD,8CA4BC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function hasStyleUrls(code: string): boolean;
|
|
2
|
+
export declare function resolveStyleUrls(code: string, id: string): string[];
|
|
3
|
+
export declare function hasTemplateUrl(code: string): boolean;
|
|
4
|
+
export declare function resolveTemplateUrl(code: string, id: string): string;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveTemplateUrl = exports.hasTemplateUrl = exports.resolveStyleUrls = exports.hasStyleUrls = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const styleUrlsRE = /styleUrls\s*:\s*\[([^\[]*?)\]/;
|
|
6
|
+
const templateUrlRE = /\s*templateUrl\s*:\s*["|']*?["|'].*/;
|
|
7
|
+
function hasStyleUrls(code) {
|
|
8
|
+
return styleUrlsRE.test(code);
|
|
9
|
+
}
|
|
10
|
+
exports.hasStyleUrls = hasStyleUrls;
|
|
11
|
+
function resolveStyleUrls(code, id) {
|
|
12
|
+
const styleUrlsGroup = styleUrlsRE.exec(code);
|
|
13
|
+
if (Array.isArray(styleUrlsGroup) && styleUrlsGroup[0]) {
|
|
14
|
+
const styleUrls = styleUrlsGroup[0].replace(/(styleUrls|\:|\s|\[|\]|"|')/g, '');
|
|
15
|
+
const styleUrlPaths = (styleUrls === null || styleUrls === void 0 ? void 0 : styleUrls.split(',')) || [];
|
|
16
|
+
return styleUrlPaths.map(styleUrlPath => (0, path_1.resolve)((0, path_1.dirname)(id), styleUrlPath));
|
|
17
|
+
}
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
20
|
+
exports.resolveStyleUrls = resolveStyleUrls;
|
|
21
|
+
function hasTemplateUrl(code) {
|
|
22
|
+
return templateUrlRE.test(code);
|
|
23
|
+
}
|
|
24
|
+
exports.hasTemplateUrl = hasTemplateUrl;
|
|
25
|
+
function resolveTemplateUrl(code, id) {
|
|
26
|
+
const templateUrlGroup = templateUrlRE.exec(code);
|
|
27
|
+
let templateUrlPath = '';
|
|
28
|
+
if (Array.isArray(templateUrlGroup) && templateUrlGroup[0]) {
|
|
29
|
+
const resolvedTemplatePath = templateUrlGroup[0].replace(/templateUrl|\s|'|"|\:|,/g, '');
|
|
30
|
+
templateUrlPath = (0, path_1.resolve)((0, path_1.dirname)(id), resolvedTemplatePath);
|
|
31
|
+
}
|
|
32
|
+
return templateUrlPath;
|
|
33
|
+
}
|
|
34
|
+
exports.resolveTemplateUrl = resolveTemplateUrl;
|
|
35
|
+
//# sourceMappingURL=component-resolvers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-resolvers.js","sourceRoot":"","sources":["../../../../../packages/vite-plugin-angular/src/lib/component-resolvers.ts"],"names":[],"mappings":";;;AAAA,+BAAwC;AAExC,MAAM,WAAW,GAAG,+BAA+B,CAAC;AACpD,MAAM,aAAa,GAAG,qCAAqC,CAAC;AAE5D,SAAgB,YAAY,CAAC,IAAY;IACvC,OAAO,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAChC,CAAC;AAFD,oCAEC;AAED,SAAgB,gBAAgB,CAAC,IAAY,EAAE,EAAU;IACvD,MAAM,cAAc,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