@mckit/schematics 0.0.5 → 0.0.7
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/add-login-page/files/login-page.component.ts.template +90 -0
- package/src/add-login-page/index.d.ts +2 -0
- package/src/add-login-page/index.js +92 -0
- package/src/add-login-page/index.js.map +1 -0
- package/src/collection.json +4 -0
- package/src/core/add-route.d.ts +2 -0
- package/src/core/add-route.js +18 -0
- package/src/core/add-route.js.map +1 -0
- package/src/core/get-content-by-file.d.ts +1 -0
- package/src/core/get-content-by-file.js +12 -0
- package/src/core/get-content-by-file.js.map +1 -0
- package/src/core/run-command.d.ts +2 -0
- package/src/core/run-command.js +14 -0
- package/src/core/run-command.js.map +1 -0
- package/src/init/index.js +12 -2
- package/src/init/index.js.map +1 -1
package/package.json
CHANGED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { Component, DestroyRef, inject, viewChild } from '@angular/core';
|
|
2
|
+
import { ActivatedRoute, Router } from '@angular/router';
|
|
3
|
+
import { MCAuthSakaiComponent, MCAuthSakaiConfig, MCAuthenticationService, MCAuthModel, MCUser } from '@mckit/auth';
|
|
4
|
+
import { catchError, switchMap, take, takeUntil, tap } from 'rxjs';
|
|
5
|
+
|
|
6
|
+
@Component({
|
|
7
|
+
selector: 'app-login-page',
|
|
8
|
+
imports: [MCAuthSakaiComponent],
|
|
9
|
+
templateUrl: './login-page.component.html',
|
|
10
|
+
styleUrl: './login-page.component.scss'
|
|
11
|
+
})
|
|
12
|
+
export class LoginPageComponent {
|
|
13
|
+
|
|
14
|
+
authComp = viewChild.required(MCAuthSakaiComponent);
|
|
15
|
+
|
|
16
|
+
mcAuthService = inject(MCAuthenticationService);
|
|
17
|
+
router = inject(Router);
|
|
18
|
+
route = inject(ActivatedRoute);
|
|
19
|
+
|
|
20
|
+
onDestroy = inject(DestroyRef);
|
|
21
|
+
|
|
22
|
+
config!: MCAuthSakaiConfig;
|
|
23
|
+
|
|
24
|
+
routeToMain = '/dashboard';
|
|
25
|
+
|
|
26
|
+
ngOnInit(): void {
|
|
27
|
+
this.configLoader();
|
|
28
|
+
this.loadConfig();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
onAction(type: string) {
|
|
32
|
+
if(type === 'forgot-password') {
|
|
33
|
+
//this.dialogService.open(ForgotPasswordDialogComponent, { header: 'Recover Pass' });
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
onLogin(data: MCAuthModel) {
|
|
38
|
+
/*this.authService.signIn(data.email!, data.password!)
|
|
39
|
+
.pipe(
|
|
40
|
+
catchError(err => {
|
|
41
|
+
this.authComp().hideLoading();
|
|
42
|
+
this.authComp().showErrorMessage(err.error?.message || 'Error desconocido');
|
|
43
|
+
throw err;
|
|
44
|
+
}),
|
|
45
|
+
)
|
|
46
|
+
.subscribe(user => this.router.navigateByUrl(this.routeToMain));*/
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
loadConfig() {
|
|
50
|
+
this.config = new MCAuthSakaiConfig();
|
|
51
|
+
this.config.title = 'Life Purse - Inicio de sesión';
|
|
52
|
+
this.config.subtitle = 'Por favor, inicie sesión para continuar';
|
|
53
|
+
this.config.emailPlaceholder = 'Correo electrónico';
|
|
54
|
+
this.config.passwordPlaceholder = 'Contraseña';
|
|
55
|
+
this.config.submitButton = 'Iniciar sesión';
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
configLoader() {
|
|
59
|
+
this.route.queryParams
|
|
60
|
+
.pipe(
|
|
61
|
+
take(1),
|
|
62
|
+
tap(params => this.processRedirectUrl(params['redirect'])),
|
|
63
|
+
switchMap(() => this.mcAuthService.getUser()),
|
|
64
|
+
tap(user => this.processIfLogged(user))
|
|
65
|
+
)
|
|
66
|
+
.subscribe();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
processIfLogged(user?: MCUser) {
|
|
70
|
+
if(user != undefined){
|
|
71
|
+
this.router.navigateByUrl(this.routeToMain);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
processRedirectUrl(redirect?: string) {
|
|
76
|
+
if(redirect == undefined) {
|
|
77
|
+
// this.loaderService.hide();
|
|
78
|
+
} else if (
|
|
79
|
+
redirect !== '/login' &&
|
|
80
|
+
redirect !== '/' &&
|
|
81
|
+
redirect !== '' &&
|
|
82
|
+
redirect !== null &&
|
|
83
|
+
redirect !== undefined &&
|
|
84
|
+
redirect !== '%2F' &&
|
|
85
|
+
redirect !== '/login;redirect=%2F'
|
|
86
|
+
) {
|
|
87
|
+
this.routeToMain = redirect;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addLoginPage = addLoginPage;
|
|
4
|
+
const run_command_1 = require("../core/run-command");
|
|
5
|
+
const add_route_1 = require("../core/add-route");
|
|
6
|
+
const get_content_by_file_1 = require("../core/get-content-by-file");
|
|
7
|
+
function insertStringAt(originalString, stringToInsert, position) {
|
|
8
|
+
if (position > originalString.length) {
|
|
9
|
+
// Si la posición está fuera del rango, simplemente agrega el string al final
|
|
10
|
+
return originalString + stringToInsert;
|
|
11
|
+
}
|
|
12
|
+
// Dividir el original en dos partes: antes y después de la posición
|
|
13
|
+
const before = originalString.slice(0, position);
|
|
14
|
+
const after = originalString.slice(position);
|
|
15
|
+
// Insertar el string en la posición deseada
|
|
16
|
+
return before + stringToInsert + after;
|
|
17
|
+
}
|
|
18
|
+
function processStyles(tree, _context) {
|
|
19
|
+
const filePath = 'src/styles.scss';
|
|
20
|
+
if (!tree.exists(filePath)) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const fileBuffer = tree.read(filePath);
|
|
24
|
+
const content = fileBuffer ? fileBuffer.toString() : '';
|
|
25
|
+
if (!content.includes('@use "tailwindcss";')) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
// Search last @source
|
|
29
|
+
const sourcePosition = content.lastIndexOf('@source');
|
|
30
|
+
// Search last ;
|
|
31
|
+
const sourceEndPosition = content.indexOf(';', sourcePosition);
|
|
32
|
+
// Add the new @source after the last @source
|
|
33
|
+
const updatedContent = insertStringAt(content, `
|
|
34
|
+
@source "../node_modules/@mckit/auth";
|
|
35
|
+
`, sourceEndPosition + 1);
|
|
36
|
+
tree.overwrite(filePath, updatedContent);
|
|
37
|
+
}
|
|
38
|
+
function processAppConfig(tree, _context) {
|
|
39
|
+
const filePath = 'src/app/app.config.ts';
|
|
40
|
+
if (!tree.exists(filePath)) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const fileBuffer = tree.read(filePath);
|
|
44
|
+
let content = fileBuffer ? fileBuffer.toString() : '';
|
|
45
|
+
// Search position of the last import
|
|
46
|
+
const importPosition = content.lastIndexOf('import');
|
|
47
|
+
// Search position of the last ; after import position
|
|
48
|
+
const importEndPosition = content.indexOf(';', importPosition);
|
|
49
|
+
// Add the new import after the last import
|
|
50
|
+
content = insertStringAt(content, `
|
|
51
|
+
|
|
52
|
+
import { provideMCAuth, authInterceptor} from '@mckit/auth';
|
|
53
|
+
|
|
54
|
+
import { environment } from '../environments/environment';`, importEndPosition + 1);
|
|
55
|
+
// Replace the zoneChangeDetectionStrategy
|
|
56
|
+
content = content.replace('provideZoneChangeDetection({ eventCoalescing: true }),', `provideZoneChangeDetection({ eventCoalescing: true }),
|
|
57
|
+
provideHttpClient(
|
|
58
|
+
withInterceptors([authInterceptor])
|
|
59
|
+
),
|
|
60
|
+
provideMCAuth({
|
|
61
|
+
baseUrl: environment.baseUrl
|
|
62
|
+
}),`);
|
|
63
|
+
tree.overwrite(filePath, content);
|
|
64
|
+
}
|
|
65
|
+
// You don't have to export the function as default. You can also have more than one rule factory
|
|
66
|
+
// per file.
|
|
67
|
+
function addLoginPage(_options) {
|
|
68
|
+
return (tree, _context) => {
|
|
69
|
+
// Install the required dependencies
|
|
70
|
+
(0, run_command_1.runCommand)('npm install --save @ngx-pwa/local-storage@19 @mckit/auth', _context);
|
|
71
|
+
// Generate environments
|
|
72
|
+
(0, run_command_1.runCommand)('ng g environments', _context);
|
|
73
|
+
// Config SCSS
|
|
74
|
+
processStyles(tree, _context);
|
|
75
|
+
// Add Route
|
|
76
|
+
(0, add_route_1.addRoute)(`{
|
|
77
|
+
path: 'login',
|
|
78
|
+
loadComponent: () => import('./features/auth/pages/login-page/login-page.component').then(m => m.LoginPageComponent)
|
|
79
|
+
},`, tree, _context);
|
|
80
|
+
// Config app.config.ts
|
|
81
|
+
processAppConfig(tree, _context);
|
|
82
|
+
// Generate component
|
|
83
|
+
(0, run_command_1.runCommand)('ng g c features/auth/pages/login-page', _context);
|
|
84
|
+
// Add html
|
|
85
|
+
tree.overwrite('src/app/features/auth/pages/login-page/login-page.component.html', `<mc-auth-sakai #authComp [config]="config" (submit)="onLogin($event)" (action)="onAction($event)" />`);
|
|
86
|
+
// Add Component
|
|
87
|
+
const component = (0, get_content_by_file_1.getContentByFile)(__dirname, 'login-page.component.ts.template');
|
|
88
|
+
tree.overwrite('src/app/features/auth/pages/login-page/login-page.component.ts', component !== null && component !== void 0 ? component : '');
|
|
89
|
+
return tree;
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;AAiFA,oCAiCC;AAjHD,qDAAiD;AACjD,iDAA6C;AAC7C,qEAA+D;AAG/D,SAAS,cAAc,CAAC,cAAsB,EAAE,cAAsB,EAAE,QAAgB;IACtF,IAAI,QAAQ,GAAG,cAAc,CAAC,MAAM,EAAE,CAAC;QACrC,6EAA6E;QAC7E,OAAO,cAAc,GAAG,cAAc,CAAC;IACzC,CAAC;IAED,oEAAoE;IACpE,MAAM,MAAM,GAAG,cAAc,CAAC,KAAK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AC,SAAS,EAAE,kCAAkC,CAAC,CAAC;QAClF,IAAI,CAAC,SAAS,CAAC,gEAAgE,EAAE,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,EAAE,CAAC,CAAC;QAElG,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;AACJ,CAAC"}
|
package/src/collection.json
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addRoute = addRoute;
|
|
4
|
+
function addRoute(routeText, tree, context) {
|
|
5
|
+
var _a;
|
|
6
|
+
const filePath = 'src/app/app.routes.ts';
|
|
7
|
+
if (!tree.exists(filePath)) {
|
|
8
|
+
context.logger.error(`❌ No se encontró ${filePath}`);
|
|
9
|
+
return tree;
|
|
10
|
+
}
|
|
11
|
+
const content = ((_a = tree.read(filePath)) === null || _a === void 0 ? void 0 : _a.toString('utf-8')) || '';
|
|
12
|
+
const updatedContent = content.replace(/\[\s*([\s\S]*?)\s*\]/, (_, routes) => {
|
|
13
|
+
return `[${routes.trim() ? routes.trim() + ', ' : ''}${routeText}]`;
|
|
14
|
+
});
|
|
15
|
+
tree.overwrite(filePath, updatedContent);
|
|
16
|
+
context.logger.info(`✅ Ruta añadida correctamente`);
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=add-route.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-route.js","sourceRoot":"","sources":["add-route.ts"],"names":[],"mappings":";;AAEA,4BAiBC;AAjBD,SAAgB,QAAQ,CAAC,SAAiB,EAAE,IAAU,EAAE,OAAyB;;IAC7E,MAAM,QAAQ,GAAG,uBAAuB,CAAC;IAEzC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;QACzB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,oBAAoB,QAAQ,EAAE,CAAC,CAAC;QACrD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,MAAM,OAAO,GAAG,CAAA,MAAA,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,0CAAE,QAAQ,CAAC,OAAO,CAAC,KAAI,EAAE,CAAC;IAE7D,MAAM,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,sBAAsB,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE;QACzE,OAAO,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,SAAS,GAAG,CAAC;IACxE,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;IAEzC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getContentByFile(dirname: string, file: string): string | undefined;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getContentByFile = getContentByFile;
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
function getContentByFile(dirname, file) {
|
|
7
|
+
const filePath = path.join(dirname, 'files/' + file);
|
|
8
|
+
if (fs.existsSync(filePath)) {
|
|
9
|
+
return fs.readFileSync(filePath, 'utf8');
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=get-content-by-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-content-by-file.js","sourceRoot":"","sources":["get-content-by-file.ts"],"names":[],"mappings":";;AAGA,4CAKC;AARD,yBAAyB;AACzB,6BAA6B;AAE7B,SAAgB,gBAAgB,CAAC,OAAe,EAAE,IAAY;IAC1D,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,GAAG,IAAI,CAAC,CAAC;IACrD,IAAI,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5B,OAAO,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC3C,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runCommand = runCommand;
|
|
4
|
+
const child_process_1 = require("child_process");
|
|
5
|
+
function runCommand(command, _context) {
|
|
6
|
+
try {
|
|
7
|
+
const stdout = (0, child_process_1.execSync)(command, { encoding: 'utf-8' });
|
|
8
|
+
_context.logger.info(`✅ Result: ${stdout}`);
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
_context.logger.error(`Error: ${error.message}`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=run-command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-command.js","sourceRoot":"","sources":["run-command.ts"],"names":[],"mappings":";;AAGA,gCASC;AAXD,iDAAyC;AAEzC,SAAgB,UAAU,CAAC,OAAe,EAAE,QAA0B;IAEpE,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAA,wBAAQ,EAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;QACxD,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,MAAM,EAAE,CAAC,CAAC;IAC9C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IACnD,CAAC;AAEH,CAAC"}
|
package/src/init/index.js
CHANGED
|
@@ -17,6 +17,10 @@ function runCommand(command, _context) {
|
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
function createFileWithTemplate(tree, fileName, template) {
|
|
20
|
+
// Verify if exist the file
|
|
21
|
+
if (tree.exists(fileName)) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
20
24
|
const filePath = path.join(__dirname, 'files/' + template);
|
|
21
25
|
if (fs.existsSync(filePath)) {
|
|
22
26
|
let content = fs.readFileSync(filePath, 'utf8');
|
|
@@ -48,6 +52,10 @@ function processStyles(tree, _context) {
|
|
|
48
52
|
const newContent = `@use "tailwindcss";
|
|
49
53
|
@use "primeicons/primeicons.css";
|
|
50
54
|
|
|
55
|
+
@source "../node_modules/@mckit/core";
|
|
56
|
+
|
|
57
|
+
@custom-variant dark (&:where(.dark, .dark *));
|
|
58
|
+
|
|
51
59
|
body, html {
|
|
52
60
|
height: 100%;
|
|
53
61
|
margin: 0;
|
|
@@ -70,13 +78,15 @@ function processAppConfig(tree, _context) {
|
|
|
70
78
|
const importEndPosition = content.indexOf(';', importPosition);
|
|
71
79
|
// Add the new import after the last import
|
|
72
80
|
content = insertStringAt(content, `
|
|
81
|
+
|
|
73
82
|
import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';
|
|
74
83
|
import { providePrimeNG } from 'primeng/config';
|
|
75
84
|
import Aura from '@primeng/themes/aura';`, importEndPosition + 1);
|
|
76
85
|
// Search position of the last ]
|
|
77
86
|
const providerPosition = content.lastIndexOf(']');
|
|
78
87
|
// Add the new provider after the last provider
|
|
79
|
-
content = insertStringAt(content,
|
|
88
|
+
content = insertStringAt(content, `,
|
|
89
|
+
provideAnimationsAsync(),
|
|
80
90
|
providePrimeNG({
|
|
81
91
|
theme: {
|
|
82
92
|
preset: Aura,
|
|
@@ -86,7 +96,7 @@ import Aura from '@primeng/themes/aura';`, importEndPosition + 1);
|
|
|
86
96
|
cssLayer: false
|
|
87
97
|
}
|
|
88
98
|
}
|
|
89
|
-
})`, providerPosition
|
|
99
|
+
})`, providerPosition);
|
|
90
100
|
tree.overwrite(filePath, content);
|
|
91
101
|
}
|
|
92
102
|
// You don't have to export the function as default. You can also have more than one rule factory
|
package/src/init/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;AAwHA,oBAsBC;AA7ID,iDAAqC;AACrC,yBAAyB;AACzB,6BAA6B;AAE7B,SAAS,UAAU,CAAC,OAAe,EAAE,QAA0B;IAC7D,IAAA,oBAAI,EAAC,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;QACtC,IAAI,KAAK,EAAE,CAAC;YACV,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YACnD,OAAO;QACT,CAAC;QACD,IAAI,MAAM,EAAE,CAAC;YACX,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,eAAe,MAAM,EAAE,CAAC,CAAC;QAChD,CAAC;QACD,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,MAAM,EAAE,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,sBAAsB,CAAC,IAAU,EAAE,QAAgB,EAAE,QAAgB;IAC5E,2BAA2B;IAC3B,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1B,OAAO;IACT,CAAC;IAED,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,GAAG,QAAQ,CAAC,CAAC;IAC3D,IAAI,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5B,IAAI,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAChD,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACjC,CAAC;AACH,CAAC;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