@digitaldefiance/i18n-lib 3.6.1 → 3.6.2
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/README.md +5 -0
- package/package.json +1 -1
- package/src/active-context.d.ts +12 -6
- package/src/active-context.d.ts.map +1 -1
- package/src/component-registry.d.ts +44 -12
- package/src/component-registry.d.ts.map +1 -1
- package/src/component-registry.js +44 -12
- package/src/component-registry.js.map +1 -1
- package/src/context-error-type.d.ts +4 -0
- package/src/context-error-type.d.ts.map +1 -1
- package/src/context-error-type.js +4 -0
- package/src/context-error-type.js.map +1 -1
- package/src/core/component-store.d.ts +69 -1
- package/src/core/component-store.d.ts.map +1 -1
- package/src/core/component-store.js +69 -1
- package/src/core/component-store.js.map +1 -1
- package/src/core/context-manager.d.ts +53 -1
- package/src/core/context-manager.d.ts.map +1 -1
- package/src/core/context-manager.js +52 -4
- package/src/core/context-manager.js.map +1 -1
- package/src/core/enum-registry.d.ts +34 -0
- package/src/core/enum-registry.d.ts.map +1 -1
- package/src/core/enum-registry.js +34 -0
- package/src/core/enum-registry.js.map +1 -1
- package/src/core/i18n-engine.d.ts +186 -0
- package/src/core/i18n-engine.d.ts.map +1 -1
- package/src/core/i18n-engine.js +189 -17
- package/src/core/i18n-engine.js.map +1 -1
- package/src/core/language-registry.d.ts +139 -0
- package/src/core/language-registry.d.ts.map +1 -1
- package/src/core/language-registry.js +138 -0
- package/src/core/language-registry.js.map +1 -1
- package/src/core-i18n.d.ts.map +1 -1
- package/src/core-i18n.js +16 -416
- package/src/core-i18n.js.map +1 -1
- package/src/enum-registry.d.ts +41 -21
- package/src/enum-registry.d.ts.map +1 -1
- package/src/enum-registry.js +44 -24
- package/src/enum-registry.js.map +1 -1
- package/src/errors/context-error.d.ts +11 -0
- package/src/errors/context-error.d.ts.map +1 -1
- package/src/errors/context-error.js +11 -0
- package/src/errors/context-error.js.map +1 -1
- package/src/errors/handleable.d.ts +33 -0
- package/src/errors/handleable.d.ts.map +1 -1
- package/src/errors/handleable.js +33 -0
- package/src/errors/handleable.js.map +1 -1
- package/src/errors/i18n-error.d.ts +107 -0
- package/src/errors/i18n-error.d.ts.map +1 -1
- package/src/errors/i18n-error.js +104 -0
- package/src/errors/i18n-error.js.map +1 -1
- package/src/gender/gender-categories.d.ts +11 -0
- package/src/gender/gender-categories.d.ts.map +1 -1
- package/src/gender/gender-categories.js +5 -0
- package/src/gender/gender-categories.js.map +1 -1
- package/src/gender/gender-resolver.d.ts +6 -1
- package/src/gender/gender-resolver.d.ts.map +1 -1
- package/src/gender/gender-resolver.js +6 -1
- package/src/gender/gender-resolver.js.map +1 -1
- package/src/interfaces/component-config.interface.d.ts +6 -0
- package/src/interfaces/component-config.interface.d.ts.map +1 -1
- package/src/interfaces/engine-config.interface.d.ts +9 -0
- package/src/interfaces/engine-config.interface.d.ts.map +1 -1
- package/src/interfaces/handleable-error-options.d.ts +7 -0
- package/src/interfaces/handleable-error-options.d.ts.map +1 -1
- package/src/interfaces/handleable.d.ts +15 -0
- package/src/interfaces/handleable.d.ts.map +1 -1
- package/src/interfaces/i18n-engine.interface.d.ts +20 -0
- package/src/interfaces/i18n-engine.interface.d.ts.map +1 -1
- package/src/interfaces/language-definition.interface.d.ts +7 -0
- package/src/interfaces/language-definition.interface.d.ts.map +1 -1
- package/src/interfaces/translation-options.interface.d.ts +6 -0
- package/src/interfaces/translation-options.interface.d.ts.map +1 -1
- package/src/interfaces/validation-result.interface.d.ts +10 -0
- package/src/interfaces/validation-result.interface.d.ts.map +1 -1
- package/src/registry-error-type.d.ts +7 -0
- package/src/registry-error-type.d.ts.map +1 -1
- package/src/registry-error-type.js +7 -0
- package/src/registry-error-type.js.map +1 -1
- package/src/strings/de.d.ts +3 -0
- package/src/strings/de.d.ts.map +1 -0
- package/src/strings/de.js +57 -0
- package/src/strings/de.js.map +1 -0
- package/src/strings/en-GB.d.ts +3 -0
- package/src/strings/en-GB.d.ts.map +1 -0
- package/src/strings/en-GB.js +57 -0
- package/src/strings/en-GB.js.map +1 -0
- package/src/strings/en-US.d.ts +3 -0
- package/src/strings/en-US.d.ts.map +1 -0
- package/src/strings/en-US.js +57 -0
- package/src/strings/en-US.js.map +1 -0
- package/src/strings/es.d.ts +3 -0
- package/src/strings/es.d.ts.map +1 -0
- package/src/strings/es.js +57 -0
- package/src/strings/es.js.map +1 -0
- package/src/strings/fr.d.ts +3 -0
- package/src/strings/fr.d.ts.map +1 -0
- package/src/strings/fr.js +57 -0
- package/src/strings/fr.js.map +1 -0
- package/src/strings/ja.d.ts +3 -0
- package/src/strings/ja.d.ts.map +1 -0
- package/src/strings/ja.js +57 -0
- package/src/strings/ja.js.map +1 -0
- package/src/strings/uk.d.ts +3 -0
- package/src/strings/uk.d.ts.map +1 -0
- package/src/strings/uk.js +57 -0
- package/src/strings/uk.js.map +1 -0
- package/src/strings/zh-CN.d.ts +3 -0
- package/src/strings/zh-CN.d.ts.map +1 -0
- package/src/strings/zh-CN.js +57 -0
- package/src/strings/zh-CN.js.map +1 -0
- package/src/types/plural-types.d.ts +10 -3
- package/src/types/plural-types.d.ts.map +1 -1
- package/src/types/plural-types.js +8 -2
- package/src/types/plural-types.js.map +1 -1
- package/src/utils/currency.d.ts +53 -0
- package/src/utils/currency.d.ts.map +1 -1
- package/src/utils/currency.js +35 -0
- package/src/utils/currency.js.map +1 -1
- package/src/utils/html-escape.d.ts +14 -0
- package/src/utils/html-escape.d.ts.map +1 -1
- package/src/utils/html-escape.js +20 -0
- package/src/utils/html-escape.js.map +1 -1
- package/src/utils/lru-cache.d.ts +29 -0
- package/src/utils/lru-cache.d.ts.map +1 -1
- package/src/utils/lru-cache.js +29 -0
- package/src/utils/lru-cache.js.map +1 -1
- package/src/utils/plural-helpers.d.ts +16 -0
- package/src/utils/plural-helpers.d.ts.map +1 -1
- package/src/utils/plural-helpers.js +16 -0
- package/src/utils/plural-helpers.js.map +1 -1
- package/src/utils/safe-object.d.ts +30 -0
- package/src/utils/safe-object.d.ts.map +1 -1
- package/src/utils/safe-object.js +33 -0
- package/src/utils/safe-object.js.map +1 -1
- package/src/utils/string-utils.d.ts +19 -0
- package/src/utils/string-utils.d.ts.map +1 -1
- package/src/utils/string-utils.js +18 -1
- package/src/utils/string-utils.js.map +1 -1
- package/src/utils/timezone.d.ts +36 -0
- package/src/utils/timezone.d.ts.map +1 -1
- package/src/utils/timezone.js +36 -0
- package/src/utils/timezone.js.map +1 -1
- package/src/utils/validation.d.ts +25 -0
- package/src/utils/validation.d.ts.map +1 -1
- package/src/utils/validation.js +25 -0
- package/src/utils/validation.js.map +1 -1
- package/src/validation/plural-validator.d.ts +25 -2
- package/src/validation/plural-validator.d.ts.map +1 -1
- package/src/validation/plural-validator.js +22 -4
- package/src/validation/plural-validator.js.map +1 -1
|
@@ -1,20 +1,72 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Interface representing the translation context for an I18nEngine instance.
|
|
3
3
|
*/
|
|
4
4
|
export interface Context {
|
|
5
|
+
/** Current user-facing language code. */
|
|
5
6
|
language: string;
|
|
7
|
+
/** Current administrative language code. */
|
|
6
8
|
adminLanguage: string;
|
|
9
|
+
/** Active context space: 'admin' or 'user'. */
|
|
7
10
|
currentSpace: 'admin' | 'user';
|
|
8
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* ContextManager handles creation and management of per-instance translation contexts,
|
|
14
|
+
* including separate user and admin languages and context switching.
|
|
15
|
+
*/
|
|
9
16
|
export declare class ContextManager {
|
|
10
17
|
private contexts;
|
|
18
|
+
/**
|
|
19
|
+
* Creates a new context for a given instance key with a default language.
|
|
20
|
+
*
|
|
21
|
+
* @param instanceKey Unique identifier for the context instance.
|
|
22
|
+
* @param defaultLanguage Language code to initialize both user and admin contexts.
|
|
23
|
+
* @returns The newly created Context object.
|
|
24
|
+
*/
|
|
11
25
|
create(instanceKey: string, defaultLanguage: string): Context;
|
|
26
|
+
/**
|
|
27
|
+
* Retrieves the context for a given instance key.
|
|
28
|
+
*
|
|
29
|
+
* @param instanceKey Unique identifier for the context instance.
|
|
30
|
+
* @returns The Context object associated with the key.
|
|
31
|
+
* @throws {Error} If no context exists for the provided key.
|
|
32
|
+
*/
|
|
12
33
|
get(instanceKey: string): Context;
|
|
34
|
+
/**
|
|
35
|
+
* Sets the user-facing language for the specified context.
|
|
36
|
+
*
|
|
37
|
+
* @param instanceKey Unique identifier for the context instance.
|
|
38
|
+
* @param language New language code for user-facing translations.
|
|
39
|
+
*/
|
|
13
40
|
setLanguage(instanceKey: string, language: string): void;
|
|
41
|
+
/**
|
|
42
|
+
* Sets the administrative language for the specified context.
|
|
43
|
+
*
|
|
44
|
+
* @param instanceKey Unique identifier for the context instance.
|
|
45
|
+
* @param language New language code for administrative translations.
|
|
46
|
+
*/
|
|
14
47
|
setAdminLanguage(instanceKey: string, language: string): void;
|
|
48
|
+
/**
|
|
49
|
+
* Switches the active context space to 'admin'.
|
|
50
|
+
*
|
|
51
|
+
* @param instanceKey Unique identifier for the context instance.
|
|
52
|
+
*/
|
|
15
53
|
switchToAdmin(instanceKey: string): void;
|
|
54
|
+
/**
|
|
55
|
+
* Switches the active context space to 'user'.
|
|
56
|
+
*
|
|
57
|
+
* @param instanceKey Unique identifier for the context instance.
|
|
58
|
+
*/
|
|
16
59
|
switchToUser(instanceKey: string): void;
|
|
60
|
+
/**
|
|
61
|
+
* Retrieves the currently active language based on the context space.
|
|
62
|
+
*
|
|
63
|
+
* @param instanceKey Unique identifier for the context instance.
|
|
64
|
+
* @returns The active language code ('adminLanguage' or 'language').
|
|
65
|
+
*/
|
|
17
66
|
getCurrentLanguage(instanceKey: string): string;
|
|
67
|
+
/**
|
|
68
|
+
* Clears all stored contexts, removing all instance data.
|
|
69
|
+
*/
|
|
18
70
|
clear(): void;
|
|
19
71
|
}
|
|
20
72
|
//# sourceMappingURL=context-manager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-manager.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/core/context-manager.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"context-manager.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/core/context-manager.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,yCAAyC;IACzC,QAAQ,EAAE,MAAM,CAAC;IACjB,4CAA4C;IAC5C,aAAa,EAAE,MAAM,CAAC;IACtB,+CAA+C;IAC/C,YAAY,EAAE,OAAO,GAAG,MAAM,CAAC;CAChC;AAED;;;GAGG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAA8B;IAE9C;;;;;;OAMG;IACH,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO;IAU7D;;;;;;OAMG;IACH,GAAG,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO;IAQjC;;;;;OAKG;IACH,WAAW,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IAKxD;;;;;OAKG;IACH,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IAK7D;;;;OAIG;IACH,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAKxC;;;;OAIG;IACH,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAKvC;;;;;OAKG;IACH,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM;IAO/C;;OAEG;IACH,KAAK,IAAI,IAAI;CAGd"}
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Simplified context management
|
|
4
|
-
*/
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.ContextManager = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* ContextManager handles creation and management of per-instance translation contexts,
|
|
6
|
+
* including separate user and admin languages and context switching.
|
|
7
|
+
*/
|
|
7
8
|
class ContextManager {
|
|
8
9
|
contexts = new Map();
|
|
10
|
+
/**
|
|
11
|
+
* Creates a new context for a given instance key with a default language.
|
|
12
|
+
*
|
|
13
|
+
* @param instanceKey Unique identifier for the context instance.
|
|
14
|
+
* @param defaultLanguage Language code to initialize both user and admin contexts.
|
|
15
|
+
* @returns The newly created Context object.
|
|
16
|
+
*/
|
|
9
17
|
create(instanceKey, defaultLanguage) {
|
|
10
18
|
const context = {
|
|
11
19
|
language: defaultLanguage,
|
|
@@ -15,6 +23,13 @@ class ContextManager {
|
|
|
15
23
|
this.contexts.set(instanceKey, context);
|
|
16
24
|
return context;
|
|
17
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Retrieves the context for a given instance key.
|
|
28
|
+
*
|
|
29
|
+
* @param instanceKey Unique identifier for the context instance.
|
|
30
|
+
* @returns The Context object associated with the key.
|
|
31
|
+
* @throws {Error} If no context exists for the provided key.
|
|
32
|
+
*/
|
|
18
33
|
get(instanceKey) {
|
|
19
34
|
const context = this.contexts.get(instanceKey);
|
|
20
35
|
if (!context) {
|
|
@@ -22,26 +37,59 @@ class ContextManager {
|
|
|
22
37
|
}
|
|
23
38
|
return context;
|
|
24
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Sets the user-facing language for the specified context.
|
|
42
|
+
*
|
|
43
|
+
* @param instanceKey Unique identifier for the context instance.
|
|
44
|
+
* @param language New language code for user-facing translations.
|
|
45
|
+
*/
|
|
25
46
|
setLanguage(instanceKey, language) {
|
|
26
47
|
const context = this.get(instanceKey);
|
|
27
48
|
context.language = language;
|
|
28
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Sets the administrative language for the specified context.
|
|
52
|
+
*
|
|
53
|
+
* @param instanceKey Unique identifier for the context instance.
|
|
54
|
+
* @param language New language code for administrative translations.
|
|
55
|
+
*/
|
|
29
56
|
setAdminLanguage(instanceKey, language) {
|
|
30
57
|
const context = this.get(instanceKey);
|
|
31
58
|
context.adminLanguage = language;
|
|
32
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Switches the active context space to 'admin'.
|
|
62
|
+
*
|
|
63
|
+
* @param instanceKey Unique identifier for the context instance.
|
|
64
|
+
*/
|
|
33
65
|
switchToAdmin(instanceKey) {
|
|
34
66
|
const context = this.get(instanceKey);
|
|
35
67
|
context.currentSpace = 'admin';
|
|
36
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* Switches the active context space to 'user'.
|
|
71
|
+
*
|
|
72
|
+
* @param instanceKey Unique identifier for the context instance.
|
|
73
|
+
*/
|
|
37
74
|
switchToUser(instanceKey) {
|
|
38
75
|
const context = this.get(instanceKey);
|
|
39
76
|
context.currentSpace = 'user';
|
|
40
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Retrieves the currently active language based on the context space.
|
|
80
|
+
*
|
|
81
|
+
* @param instanceKey Unique identifier for the context instance.
|
|
82
|
+
* @returns The active language code ('adminLanguage' or 'language').
|
|
83
|
+
*/
|
|
41
84
|
getCurrentLanguage(instanceKey) {
|
|
42
85
|
const context = this.get(instanceKey);
|
|
43
|
-
return context.currentSpace === 'admin'
|
|
86
|
+
return context.currentSpace === 'admin'
|
|
87
|
+
? context.adminLanguage
|
|
88
|
+
: context.language;
|
|
44
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* Clears all stored contexts, removing all instance data.
|
|
92
|
+
*/
|
|
45
93
|
clear() {
|
|
46
94
|
this.contexts.clear();
|
|
47
95
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-manager.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/core/context-manager.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"context-manager.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/core/context-manager.ts"],"names":[],"mappings":";;;AAYA;;;GAGG;AACH,MAAa,cAAc;IACjB,QAAQ,GAAG,IAAI,GA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AED;;;;;OAKG;IACH,kBAAkB,CAAC,WAAmB;QACpC,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QACtC,OAAO,OAAO,CAAC,YAAY,KAAK,OAAO;YACrC,CAAC,CAAC,OAAO,CAAC,aAAa;YACvB,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC;CACF;AAhGD,wCAgGC"}
|
|
@@ -1,14 +1,48 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Enum translation registry (v2 - no generics)
|
|
3
3
|
*/
|
|
4
|
+
/**
|
|
5
|
+
* Registry for managing translations of enum values across multiple languages.
|
|
6
|
+
* Provides a centralized way to register and translate enum values.
|
|
7
|
+
*/
|
|
4
8
|
export declare class EnumRegistry {
|
|
5
9
|
private translations;
|
|
6
10
|
private enumNames;
|
|
7
11
|
private translateFn?;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a new EnumRegistry instance.
|
|
14
|
+
* @param translateFn - Optional translation function for error messages
|
|
15
|
+
*/
|
|
8
16
|
constructor(translateFn?: (key: string, vars?: Record<string, any>) => string);
|
|
17
|
+
/**
|
|
18
|
+
* Registers an enum with its translations for all languages.
|
|
19
|
+
* @template TEnum - The enum value type (string or number)
|
|
20
|
+
* @param enumObj - The enum object to register
|
|
21
|
+
* @param translations - Mapping of language codes to enum value translations
|
|
22
|
+
* @param enumName - Human-readable name for the enum (used in error messages)
|
|
23
|
+
*/
|
|
9
24
|
register<TEnum extends string | number>(enumObj: Record<string, TEnum>, translations: Record<string, Record<TEnum, string>>, enumName: string): void;
|
|
25
|
+
/**
|
|
26
|
+
* Translates an enum value to a specific language.
|
|
27
|
+
* @template TEnum - The enum value type
|
|
28
|
+
* @param enumObj - The registered enum object
|
|
29
|
+
* @param value - The enum value to translate
|
|
30
|
+
* @param language - The target language code
|
|
31
|
+
* @returns The translated string
|
|
32
|
+
* @throws {I18nError} If the enum, language, or value is not found
|
|
33
|
+
*/
|
|
10
34
|
translate<TEnum extends string | number>(enumObj: Record<string, TEnum>, value: TEnum, language: string): string;
|
|
35
|
+
/**
|
|
36
|
+
* Checks if an enum has been registered.
|
|
37
|
+
* @param enumObj - The enum object to check
|
|
38
|
+
* @returns True if the enum is registered, false otherwise
|
|
39
|
+
*/
|
|
11
40
|
has(enumObj: any): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Gets the human-readable name of an enum.
|
|
43
|
+
* @param enumObj - The enum object
|
|
44
|
+
* @returns The enum name or 'UnknownEnum' if not set
|
|
45
|
+
*/
|
|
12
46
|
private getEnumName;
|
|
13
47
|
}
|
|
14
48
|
//# sourceMappingURL=enum-registry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enum-registry.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/core/enum-registry.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,qBAAa,YAAY;IACvB,OAAO,CAAC,YAAY,CAA0D;IAC9E,OAAO,CAAC,SAAS,CAA8B;IAC/C,OAAO,CAAC,WAAW,CAAC,CAAsD;
|
|
1
|
+
{"version":3,"file":"enum-registry.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/core/enum-registry.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;;GAGG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,YAAY,CAA0D;IAC9E,OAAO,CAAC,SAAS,CAA8B;IAC/C,OAAO,CAAC,WAAW,CAAC,CAAsD;IAE1E;;;OAGG;gBACS,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,MAAM;IAI7E;;;;;;OAMG;IACH,QAAQ,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM,EACpC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAC9B,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,EACnD,QAAQ,EAAE,MAAM,GACf,IAAI;IAKP;;;;;;;;OAQG;IACH,SAAS,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM,EACrC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAC9B,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,MAAM,GACf,MAAM;IA4BT;;;;OAIG;IACH,GAAG,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO;IAI1B;;;;OAIG;IACH,OAAO,CAAC,WAAW;CAGpB"}
|
|
@@ -5,17 +5,41 @@
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.EnumRegistry = void 0;
|
|
7
7
|
const errors_1 = require("../errors");
|
|
8
|
+
/**
|
|
9
|
+
* Registry for managing translations of enum values across multiple languages.
|
|
10
|
+
* Provides a centralized way to register and translate enum values.
|
|
11
|
+
*/
|
|
8
12
|
class EnumRegistry {
|
|
9
13
|
translations = new Map();
|
|
10
14
|
enumNames = new WeakMap();
|
|
11
15
|
translateFn;
|
|
16
|
+
/**
|
|
17
|
+
* Creates a new EnumRegistry instance.
|
|
18
|
+
* @param translateFn - Optional translation function for error messages
|
|
19
|
+
*/
|
|
12
20
|
constructor(translateFn) {
|
|
13
21
|
this.translateFn = translateFn;
|
|
14
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Registers an enum with its translations for all languages.
|
|
25
|
+
* @template TEnum - The enum value type (string or number)
|
|
26
|
+
* @param enumObj - The enum object to register
|
|
27
|
+
* @param translations - Mapping of language codes to enum value translations
|
|
28
|
+
* @param enumName - Human-readable name for the enum (used in error messages)
|
|
29
|
+
*/
|
|
15
30
|
register(enumObj, translations, enumName) {
|
|
16
31
|
this.translations.set(enumObj, translations);
|
|
17
32
|
this.enumNames.set(enumObj, enumName);
|
|
18
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Translates an enum value to a specific language.
|
|
36
|
+
* @template TEnum - The enum value type
|
|
37
|
+
* @param enumObj - The registered enum object
|
|
38
|
+
* @param value - The enum value to translate
|
|
39
|
+
* @param language - The target language code
|
|
40
|
+
* @returns The translated string
|
|
41
|
+
* @throws {I18nError} If the enum, language, or value is not found
|
|
42
|
+
*/
|
|
19
43
|
translate(enumObj, value, language) {
|
|
20
44
|
const translations = this.translations.get(enumObj);
|
|
21
45
|
if (!translations) {
|
|
@@ -37,9 +61,19 @@ class EnumRegistry {
|
|
|
37
61
|
}
|
|
38
62
|
return result;
|
|
39
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Checks if an enum has been registered.
|
|
66
|
+
* @param enumObj - The enum object to check
|
|
67
|
+
* @returns True if the enum is registered, false otherwise
|
|
68
|
+
*/
|
|
40
69
|
has(enumObj) {
|
|
41
70
|
return this.translations.has(enumObj);
|
|
42
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* Gets the human-readable name of an enum.
|
|
74
|
+
* @param enumObj - The enum object
|
|
75
|
+
* @returns The enum name or 'UnknownEnum' if not set
|
|
76
|
+
*/
|
|
43
77
|
getEnumName(enumObj) {
|
|
44
78
|
return this.enumNames.get(enumObj) || 'UnknownEnum';
|
|
45
79
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enum-registry.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/core/enum-registry.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,sCAAsC;AAEtC,MAAa,YAAY;IACf,YAAY,GAAG,IAAI,GAAG,EAA+C,CAAC;IACtE,SAAS,GAAG,IAAI,OAAO,EAAe,CAAC;IACvC,WAAW,CAAuD;IAE1E,YAAY,WAAiE;QAC3E,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAED,QAAQ,CACN,OAA8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d,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACxC,CAAC;
|
|
1
|
+
{"version":3,"file":"enum-registry.js","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/core/enum-registry.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,sCAAsC;AAEtC;;;GAGG;AACH,MAAa,YAAY;IACf,YAAY,GAAG,IAAI,GAAG,EAA+C,CAAC;IACtE,SAAS,GAAG,IAAI,OAAO,EAAe,CAAC;IACvC,WAAW,CAAuD;IAE1E;;;OAGG;IACH,YAAY,WAAiE;QAC3E,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAED;;;;;;OAMG;IACH,QAAQ,CACN,OAA8B,EAC9B,YAAmD,EACnD,QAAgB;QAEhB,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,EAAE,YAAmB,CAAC,CAAC;QACpD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACxC,CAAC;IAED;;;;;;;;OAQG;IACH,SAAS,CACP,OAA8B,EAC9B,KAAY,EACZ,QAAgB;QAEhB,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACpD,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,MAAM,kBAAS,CAAC,aAAa,CAC3B,mCAAmC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,CAC/D,CAAC;QACJ,CAAC;QAED,MAAM,gBAAgB,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC;QAChD,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACtB,MAAM,kBAAS,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QAC7C,CAAC;QAED,IAAI,MAAM,GAAG,gBAAgB,CAAC,KAAY,CAAC,CAAC;QAC5C,IAAI,CAAC,MAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YACzC,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC,CAAC;YAC7E,IAAI,SAAS,EAAE,CAAC;gBACd,MAAM,GAAG,gBAAgB,CAAC,SAAgB,CAAC,CAAC;YAC9C,CAAC;QACH,CAAC;QAED,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,kBAAS,CAAC,kBAAkB,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,CAAC;QACtE,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;;;OAIG;IACH,GAAG,CAAC,OAAY;QACd,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACxC,CAAC;IAED;;;;OAIG;IACK,WAAW,CAAC,OAAY;QAC9B,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,aAAa,CAAC;IACtD,CAAC;CACF;AAvFD,oCAuFC"}
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
* Main I18n Engine (no generics)
|
|
3
3
|
*/
|
|
4
4
|
import { ComponentConfig, EngineConfig, II18nEngine, LanguageDefinition, ValidationResult } from '../interfaces';
|
|
5
|
+
/**
|
|
6
|
+
* I18nEngine implements the II18nEngine interface, providing translation,
|
|
7
|
+
* component registration, enum translation, and context management.
|
|
8
|
+
*/
|
|
5
9
|
export declare class I18nEngine implements II18nEngine {
|
|
6
10
|
private static instances;
|
|
7
11
|
private static defaultKey;
|
|
@@ -13,43 +17,225 @@ export declare class I18nEngine implements II18nEngine {
|
|
|
13
17
|
private readonly config;
|
|
14
18
|
private readonly aliasToComponent;
|
|
15
19
|
private readonly componentKeyLookup;
|
|
20
|
+
/**
|
|
21
|
+
* Constructs an I18nEngine instance, registering languages, setting defaults,
|
|
22
|
+
* and optionally registering and setting this instance as default.
|
|
23
|
+
*
|
|
24
|
+
* @param languages - Array of language definitions to register.
|
|
25
|
+
* @param config - Engine configuration options.
|
|
26
|
+
* @param options - Optional creation options.
|
|
27
|
+
* @param options.instanceKey - Key to identify this instance.
|
|
28
|
+
* @param options.registerInstance - Whether to add this instance to the registry.
|
|
29
|
+
* @param options.setAsDefault - Whether to set this instance as the default.
|
|
30
|
+
* @throws {I18nError} If an instance with the same key already exists.
|
|
31
|
+
*/
|
|
16
32
|
constructor(languages: readonly LanguageDefinition[], config?: EngineConfig, options?: {
|
|
17
33
|
instanceKey?: string;
|
|
18
34
|
registerInstance?: boolean;
|
|
19
35
|
setAsDefault?: boolean;
|
|
20
36
|
});
|
|
37
|
+
/**
|
|
38
|
+
* Registers a translation component configuration.
|
|
39
|
+
* @param config - Component configuration object.
|
|
40
|
+
* @returns ValidationResult containing any warnings or errors.
|
|
41
|
+
*/
|
|
21
42
|
register(config: ComponentConfig): ValidationResult;
|
|
43
|
+
/**
|
|
44
|
+
* Registers a component if not already registered.
|
|
45
|
+
* @param config - Component configuration object.
|
|
46
|
+
* @returns ValidationResult containing any warnings or errors.
|
|
47
|
+
*/
|
|
22
48
|
registerIfNotExists(config: ComponentConfig): ValidationResult;
|
|
49
|
+
/**
|
|
50
|
+
* Internal: Builds metadata lookup maps from component config.
|
|
51
|
+
* @param config - Component configuration object.
|
|
52
|
+
*/
|
|
23
53
|
private registerComponentMetadata;
|
|
54
|
+
/**
|
|
55
|
+
* Internal: Normalizes legacy keys into snake_case lowercased.
|
|
56
|
+
* @param rawKey - The raw key string to normalize.
|
|
57
|
+
* @returns Normalized key or null if empty.
|
|
58
|
+
*/
|
|
24
59
|
private normalizeLegacyKey;
|
|
60
|
+
/**
|
|
61
|
+
* Internal: Resolves the component prefix and key to actual IDs.
|
|
62
|
+
* @param prefix - Component or enum alias.
|
|
63
|
+
* @param rawKey - Raw translation key.
|
|
64
|
+
* @returns Object containing resolved componentId and stringKey.
|
|
65
|
+
*/
|
|
25
66
|
private resolveComponentAndKey;
|
|
67
|
+
/**
|
|
68
|
+
* Updates translation strings for a component.
|
|
69
|
+
* @param componentId - ID of the component to update.
|
|
70
|
+
* @param strings - Language-keyed string records.
|
|
71
|
+
* @returns ValidationResult containing any warnings or errors.
|
|
72
|
+
*/
|
|
26
73
|
updateStrings(componentId: string, strings: Record<string, Record<string, string>>): ValidationResult;
|
|
74
|
+
/**
|
|
75
|
+
* Checks if a component is registered.
|
|
76
|
+
* @param componentId - ID of the component.
|
|
77
|
+
* @returns True if the component exists.
|
|
78
|
+
*/
|
|
27
79
|
hasComponent(componentId: string): boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Retrieves all registered component configs.
|
|
82
|
+
* @returns Array of ComponentConfig.
|
|
83
|
+
*/
|
|
28
84
|
getComponents(): readonly ComponentConfig[];
|
|
85
|
+
/**
|
|
86
|
+
* Translates a key for a component in a given or current language.
|
|
87
|
+
* @param componentId - ID of the component.
|
|
88
|
+
* @param key - Translation key.
|
|
89
|
+
* @param variables - Optional variables for template.
|
|
90
|
+
* @param language - Language code to translate into.
|
|
91
|
+
* @returns Translated string.
|
|
92
|
+
*/
|
|
29
93
|
translate(componentId: string, key: string, variables?: Record<string, any>, language?: string): string;
|
|
94
|
+
/**
|
|
95
|
+
* Safely translates a key, returning a placeholder for missing translations.
|
|
96
|
+
* @param componentId - ID of the component.
|
|
97
|
+
* @param key - Translation key.
|
|
98
|
+
* @param variables - Optional variables for template.
|
|
99
|
+
* @param language - Language code to translate into.
|
|
100
|
+
* @returns Safe translated string.
|
|
101
|
+
*/
|
|
30
102
|
safeTranslate(componentId: string, key: string, variables?: Record<string, any>, language?: string): string;
|
|
103
|
+
/**
|
|
104
|
+
* Processes a translation template, replacing component and variable placeholders.
|
|
105
|
+
* @param template - Template string containing {{component.key}} and {variable}.
|
|
106
|
+
* @param variables - Optional variables for substitution.
|
|
107
|
+
* @param language - Language code to translate into.
|
|
108
|
+
* @returns Processed template string.
|
|
109
|
+
* @throws {I18nError} If template length exceeds limits.
|
|
110
|
+
*/
|
|
31
111
|
t(template: string, variables?: Record<string, any>, language?: string): string;
|
|
112
|
+
/**
|
|
113
|
+
* Internal: Combines constants, context, and provided variables for translation.
|
|
114
|
+
* @param variables - Optional overrides for context and constants.
|
|
115
|
+
* @returns Combined variables record.
|
|
116
|
+
*/
|
|
32
117
|
private buildCombinedVariables;
|
|
118
|
+
/**
|
|
119
|
+
* Internal: Extracts primitive or object 'value' fields, handling CurrencyCode and Timezone.
|
|
120
|
+
* @param value - Value or wrapper object.
|
|
121
|
+
* @returns Extracted primitive value.
|
|
122
|
+
*/
|
|
33
123
|
private extractValue;
|
|
124
|
+
/**
|
|
125
|
+
* Registers a language in the global LanguageRegistry.
|
|
126
|
+
* @param language - LanguageDefinition to register.
|
|
127
|
+
*/
|
|
34
128
|
registerLanguage(language: LanguageDefinition): void;
|
|
129
|
+
/**
|
|
130
|
+
* Sets the current translation language for this instance.
|
|
131
|
+
* @param language - Language code to set.
|
|
132
|
+
* @throws {I18nError} If the language is not registered.
|
|
133
|
+
*/
|
|
35
134
|
setLanguage(language: string): void;
|
|
135
|
+
/**
|
|
136
|
+
* Sets the current admin translation language for this instance.
|
|
137
|
+
* @param language - Language code to set.
|
|
138
|
+
* @throws {I18nError} If the language is not registered.
|
|
139
|
+
*/
|
|
36
140
|
setAdminLanguage(language: string): void;
|
|
141
|
+
/**
|
|
142
|
+
* Retrieves all registered languages.
|
|
143
|
+
* @returns Array of LanguageDefinition.
|
|
144
|
+
*/
|
|
37
145
|
getLanguages(): readonly LanguageDefinition[];
|
|
146
|
+
/**
|
|
147
|
+
* Checks if a language is registered in the global registry.
|
|
148
|
+
* @param language - Language code to check.
|
|
149
|
+
* @returns True if the language exists.
|
|
150
|
+
*/
|
|
38
151
|
hasLanguage(language: string): boolean;
|
|
152
|
+
/**
|
|
153
|
+
* Merges new constants into existing config constants.
|
|
154
|
+
* @param constants - Key-value constants to merge.
|
|
155
|
+
*/
|
|
39
156
|
mergeConstants(constants: Record<string, any>): void;
|
|
157
|
+
/**
|
|
158
|
+
* Updates config constants and componentStore constants to new values.
|
|
159
|
+
* @param constants - New constants record.
|
|
160
|
+
*/
|
|
40
161
|
updateConstants(constants: Record<string, any>): void;
|
|
162
|
+
/**
|
|
163
|
+
* Switches translation context to admin.
|
|
164
|
+
*/
|
|
41
165
|
switchToAdmin(): void;
|
|
166
|
+
/**
|
|
167
|
+
* Switches translation context to user.
|
|
168
|
+
*/
|
|
42
169
|
switchToUser(): void;
|
|
170
|
+
/**
|
|
171
|
+
* Retrieves the current language for this instance.
|
|
172
|
+
* @returns Current language code.
|
|
173
|
+
*/
|
|
43
174
|
getCurrentLanguage(): string;
|
|
175
|
+
/**
|
|
176
|
+
* Registers an enum for translation.
|
|
177
|
+
* @param enumObj - Enum object to register.
|
|
178
|
+
* @param translations - Language keyed translations for enum values.
|
|
179
|
+
* @param enumName - Name to identify the enum in templates.
|
|
180
|
+
*/
|
|
44
181
|
registerEnum<TEnum extends string | number>(enumObj: Record<string, TEnum>, translations: Record<string, Record<TEnum, string>>, enumName: string): void;
|
|
182
|
+
/**
|
|
183
|
+
* Translates an enum value for the current or specified language.
|
|
184
|
+
* @param enumObj - Enum object.
|
|
185
|
+
* @param value - Enum value to translate.
|
|
186
|
+
* @param language - Optional language code.
|
|
187
|
+
* @returns Translated enum string.
|
|
188
|
+
*/
|
|
45
189
|
translateEnum<TEnum extends string | number>(enumObj: Record<string, TEnum>, value: TEnum, language?: string): string;
|
|
190
|
+
/**
|
|
191
|
+
* Checks if an enum is registered.
|
|
192
|
+
* @param enumObj - Enum object to check.
|
|
193
|
+
* @returns True if the enum is registered.
|
|
194
|
+
*/
|
|
46
195
|
hasEnum(enumObj: any): boolean;
|
|
196
|
+
/**
|
|
197
|
+
* Validates all registered components for missing translations or warnings.
|
|
198
|
+
* @returns ValidationResult containing errors and warnings.
|
|
199
|
+
*/
|
|
47
200
|
validate(): ValidationResult;
|
|
201
|
+
/**
|
|
202
|
+
* Creates a new engine instance with the given key, languages, and config.
|
|
203
|
+
* @param key - Unique key for the new instance.
|
|
204
|
+
* @param languages - Array of language definitions to register.
|
|
205
|
+
* @param config - Optional engine configuration.
|
|
206
|
+
* @returns Newly created I18nEngine instance.
|
|
207
|
+
*/
|
|
48
208
|
static createInstance(key: string, languages: readonly LanguageDefinition[], config?: EngineConfig): I18nEngine;
|
|
209
|
+
/**
|
|
210
|
+
* Registers or retrieves an existing engine instance by key.
|
|
211
|
+
* @param key - Unique key for the instance.
|
|
212
|
+
* @param languages - Array of language definitions.
|
|
213
|
+
* @param config - Optional engine configuration.
|
|
214
|
+
* @returns Existing or newly created I18nEngine instance.
|
|
215
|
+
*/
|
|
49
216
|
static registerIfNotExists(key: string, languages: readonly LanguageDefinition[], config?: EngineConfig): I18nEngine;
|
|
217
|
+
/**
|
|
218
|
+
* Retrieves an engine instance by key or default if none provided.
|
|
219
|
+
* @param key - Optional instance key.
|
|
220
|
+
* @returns I18nEngine instance.
|
|
221
|
+
* @throws {I18nError} If instance not found.
|
|
222
|
+
*/
|
|
50
223
|
static getInstance(key?: string): I18nEngine;
|
|
224
|
+
/**
|
|
225
|
+
* Checks if an engine instance exists.
|
|
226
|
+
* @param key - Optional instance key.
|
|
227
|
+
* @returns True if instance exists.
|
|
228
|
+
*/
|
|
51
229
|
static hasInstance(key?: string): boolean;
|
|
230
|
+
/**
|
|
231
|
+
* Removes an engine instance by key.
|
|
232
|
+
* @param key - Optional instance key.
|
|
233
|
+
* @returns True if the instance was removed.
|
|
234
|
+
*/
|
|
52
235
|
static removeInstance(key?: string): boolean;
|
|
236
|
+
/**
|
|
237
|
+
* Resets all engine instances and clears global registries.
|
|
238
|
+
*/
|
|
53
239
|
static resetAll(): void;
|
|
54
240
|
}
|
|
55
241
|
//# sourceMappingURL=i18n-engine.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n-engine.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/core/i18n-engine.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EACL,eAAe,EACf,YAAY,EACZ,WAAW,EACX,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,eAAe,CAAC;AAUvB,qBAAa,UAAW,YAAW,WAAW;IAC5C,OAAO,CAAC,MAAM,CAAC,SAAS,CAAiC;IACzD,OAAO,CAAC,MAAM,CAAC,UAAU,CAAuB;IAChD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAa;IAChD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAwB;IAE9D,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAiB;IAChD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAe;IAC5C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAyB;IAChD,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAA6B;IAC9D,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAA0C;
|
|
1
|
+
{"version":3,"file":"i18n-engine.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-i18n-lib/src/core/i18n-engine.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EACL,eAAe,EACf,YAAY,EACZ,WAAW,EACX,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,eAAe,CAAC;AAUvB;;;GAGG;AACH,qBAAa,UAAW,YAAW,WAAW;IAC5C,OAAO,CAAC,MAAM,CAAC,SAAS,CAAiC;IACzD,OAAO,CAAC,MAAM,CAAC,UAAU,CAAuB;IAChD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAa;IAChD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAwB;IAE9D,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAiB;IAChD,OAAO,CAAC,QAAQ,CAA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