@intlayer/types 9.1.1 → 9.1.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.
|
@@ -96,6 +96,37 @@ type DictionaryQualifierType = "variant" | "item";
|
|
|
96
96
|
* values — an array registers the same content under every listed variant id.
|
|
97
97
|
*/
|
|
98
98
|
type DictionaryVariantValue = string | Record<string, string | number>;
|
|
99
|
+
/**
|
|
100
|
+
* A variant coordinate as pinned by a **selector** (or by a provider default):
|
|
101
|
+
* one value, or an **ordered preference chain**.
|
|
102
|
+
*
|
|
103
|
+
* A chain is tried left to right against the entries the key declares, and the
|
|
104
|
+
* first declared one wins; when none is declared the implicit `default` entry
|
|
105
|
+
* is used, exactly as for a single value. So `['black-friday', 'promo']` reads
|
|
106
|
+
* as "black-friday if this key has one, else promo, else default".
|
|
107
|
+
*
|
|
108
|
+
* Note this is the mirror image of the array accepted by the `variant` field of
|
|
109
|
+
* a {@link Dictionary}: there an array **declares** one entry per element
|
|
110
|
+
* (fan-out), here it **consumes** them in priority order.
|
|
111
|
+
*/
|
|
112
|
+
type DictionaryVariantChain = DictionaryVariantValue | readonly DictionaryVariantValue[];
|
|
113
|
+
/**
|
|
114
|
+
* Variant default carried by a framework provider (`<IntlayerProvider variant>`)
|
|
115
|
+
* and applied to every dictionary read below it, the way `locale` already is.
|
|
116
|
+
*
|
|
117
|
+
* Three forms:
|
|
118
|
+
* - `'school1'` — one named variant for every key
|
|
119
|
+
* - `['school1', 'default']` — an ordered {@link DictionaryVariantChain}
|
|
120
|
+
* - `{ key1: 'school1', default: 'base' }` — per dictionary key, with the
|
|
121
|
+
* reserved `default` entry covering every key not listed
|
|
122
|
+
*
|
|
123
|
+
* On a provider a plain object is **always** read as the per-key map, never as
|
|
124
|
+
* a structured variant value — the two are structurally identical. To pin a
|
|
125
|
+
* structured variant globally, nest it under an entry:
|
|
126
|
+
* `variant={{ default: { id: 'prod_abc' } }}`.
|
|
127
|
+
*/
|
|
128
|
+
type ProviderVariantMap<Key extends string = DictionaryKey> = Partial<Record<Key | "default", DictionaryVariantChain>>;
|
|
129
|
+
type ProviderVariant<Key extends string = DictionaryKey> = string | readonly DictionaryVariantValue[] | ProviderVariantMap<Key>;
|
|
99
130
|
/**
|
|
100
131
|
* Output of the merge step for a key whose dictionaries declare one or more
|
|
101
132
|
* qualifier dimensions (`variant`, `item`).
|
|
@@ -143,18 +174,21 @@ type QualifiedDictionaryGroup = {
|
|
|
143
174
|
*
|
|
144
175
|
* - `{ item: 2 }` selects a collection item (1-based index)
|
|
145
176
|
* - `{ variant: 'black-friday' }` selects a named variant
|
|
177
|
+
* - `{ variant: ['black-friday', 'promo'] }` selects the first of an ordered
|
|
178
|
+
* preference chain that the key actually declares
|
|
146
179
|
* - `{ variant: { id: 'prod_abc', userId: '123' } }` selects a structured
|
|
147
180
|
* variant; the object must equal the variant declared on the dictionary
|
|
148
181
|
* - `locale` composes with any of the above and overrides the context locale
|
|
149
182
|
*/
|
|
150
183
|
type DictionarySelector = {
|
|
151
184
|
/**
|
|
152
|
-
*
|
|
153
|
-
* a
|
|
185
|
+
* The declared locales are offered as suggestions, but any string is
|
|
186
|
+
* accepted: a locale usually reaches this API as a router param or a stored
|
|
187
|
+
* value, whose type is a plain `string`.
|
|
154
188
|
*/
|
|
155
|
-
locale?:
|
|
189
|
+
locale?: LocalesValues;
|
|
156
190
|
item?: number;
|
|
157
|
-
variant?:
|
|
191
|
+
variant?: DictionaryVariantChain;
|
|
158
192
|
};
|
|
159
193
|
type QualifiedEntryContent<Entry> = Entry extends {
|
|
160
194
|
content: infer Content;
|
|
@@ -198,8 +232,12 @@ type CoordinateEquals<Left, Right> = [StringifyCoordinate<Left>] extends [String
|
|
|
198
232
|
* precisely; an object variant broadens to `string` (it matches any declared
|
|
199
233
|
* variant entry, since the object identity is not reconstructable at the type
|
|
200
234
|
* level). An absent selector defaults to the `'default'` variant.
|
|
235
|
+
*
|
|
236
|
+
* A {@link DictionaryVariantChain} broadens to the **union** of its entries:
|
|
237
|
+
* which one wins depends on what the key declares, which is a runtime fact, so
|
|
238
|
+
* the content type is the union of every outcome the chain can produce.
|
|
201
239
|
*/
|
|
202
|
-
type SelectorVariant<Selector> = "variant" extends keyof Selector ? Selector["variant" & keyof Selector] extends (infer Variant) ? Variant extends string ? Variant : string : never : "default";
|
|
240
|
+
type SelectorVariant<Selector> = "variant" extends keyof Selector ? Selector["variant" & keyof Selector] extends (infer Variant) ? Variant extends readonly (infer ChainEntry)[] ? ChainEntry extends string ? ChainEntry : string : Variant extends string ? Variant : string : never : "default";
|
|
203
241
|
/** The item a selector pins, or `undefined` when it leaves the axis open. */
|
|
204
242
|
type SelectorItem<Selector> = "item" extends keyof Selector ? Selector["item" & keyof Selector] : undefined;
|
|
205
243
|
/**
|
|
@@ -334,10 +372,15 @@ type HasDefaultVariant<T> = "default" extends VariantIdsOfGroup<T> ? true : fals
|
|
|
334
372
|
* never accepted in their serialized string form (`'id=abc&userId=123'`) —
|
|
335
373
|
* that is a storage encoding, not part of the API.
|
|
336
374
|
*/
|
|
375
|
+
type SelectableVariantsOf<T, KnownVariants> = NamedVariantIds<EntryVariant<GroupEntryUnion<T>>> | (HasDefaultVariant<T> extends true ? KnownVariants : never) | DictionaryObjectVariantsOf<T>;
|
|
337
376
|
type DictionarySelectorForGroup<T, KnownVariants = DeclaredVariants> = [GroupEntryUnion<T>] extends [never] ? DictionarySelector : {
|
|
338
|
-
locale?:
|
|
377
|
+
locale?: LocalesValues;
|
|
339
378
|
} & ([EntryVariant<GroupEntryUnion<T>>] extends [never] ? unknown : {
|
|
340
|
-
|
|
379
|
+
/**
|
|
380
|
+
* One variant, or an ordered preference chain of them — every value
|
|
381
|
+
* accepted alone is also accepted as a chain entry.
|
|
382
|
+
*/
|
|
383
|
+
variant?: SelectableVariantsOf<T, KnownVariants> | readonly SelectableVariantsOf<T, KnownVariants>[];
|
|
341
384
|
}) & ([EntryItem<GroupEntryUnion<T>>] extends [never] ? unknown : {
|
|
342
385
|
item?: EntryItem<GroupEntryUnion<T>> | number | (string & {});
|
|
343
386
|
});
|
|
@@ -702,5 +745,5 @@ type DictionaryWithoutSchema<ContentType, FetchableNode> = {
|
|
|
702
745
|
type Dictionary<ContentType = undefined, SchemaKey extends SchemaKeys | undefined = undefined, FetchableNode = false> = DictionaryBase & (SchemaKey extends SchemaKeys ? DictionaryWithSchema<ContentType, FetchableNode, SchemaKey> : undefined extends SchemaKey ? DictionaryWithoutSchema<ContentType, FetchableNode> | DictionaryWithSchema<ContentType, FetchableNode> : never);
|
|
703
746
|
type GetSubPath<T, P> = P extends `${infer K}.${infer Rest}` ? K extends keyof T ? GetSubPath<T[K], Rest> : never : P extends keyof T ? T[P] : T;
|
|
704
747
|
//#endregion
|
|
705
|
-
export { ContentAutoTransformation, ContentNode, Dictionary, DictionaryFormat, DictionaryId, DictionaryKey, DictionaryLocation, DictionaryQualifierType, DictionarySelector, DictionarySelectorForGroup, DictionaryVariantIdsOf, DictionaryVariantValue, Fill, GetSubPath, ImportMode, LocalDictionaryId, QualifiedDictionaryGroup, ResolveQualifiedDictionaryContent, TypedNode };
|
|
748
|
+
export { ContentAutoTransformation, ContentNode, Dictionary, DictionaryFormat, DictionaryId, DictionaryKey, DictionaryLocation, DictionaryQualifierType, DictionarySelector, DictionarySelectorForGroup, DictionaryVariantChain, DictionaryVariantIdsOf, DictionaryVariantValue, Fill, GetSubPath, ImportMode, LocalDictionaryId, ProviderVariant, ProviderVariantMap, QualifiedDictionaryGroup, ResolveQualifiedDictionaryContent, TypedNode };
|
|
706
749
|
//# sourceMappingURL=dictionary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dictionary.d.ts","names":[],"sources":["../../src/dictionary.ts"],"mappings":";;;;KAUK;KAEA;EACH,UAAU;;UAGK,UAAU,+BAA+B;KAErD,qBAAqB,aACxB,eACG,YAAY,YAAY,QAAQ,YAAY;KAErC,YACV,eACA,uBACA,WAAW,sBAAsB,WAAW,KAE1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,WAAW,EAAE,IAAI,gBAEnB,gBAAgB,IACd,EAAE,KACF"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ import { ALL_LOCALES, Locale } from "./allLocales.js";
|
|
|
3
3
|
import { DeclaredLocales, DeclaredVariants, DictionaryKeys, DictionaryRegistry, DictionaryRegistryContent, DictionaryRegistryElement, DictionaryRegistryResult, DictionarySelectorForKey, ExtractSelectorLocale, GetLocaleLang, LocalesValues, LocalizedUrl, PathWithoutLocale, RequiredLocales, ResolvedDefaultLocale, ResolvedEditor, ResolvedRoutingMode, Schema, SchemaKeys, StrictModeLocaleMap } from "./module_augmentation.js";
|
|
4
4
|
import { FilePathPattern, FilePathPatternContext, FilePathPatternFunction } from "./filePathPattern.js";
|
|
5
5
|
import { ARRAY, BOOLEAN, CONDITION, ENUMERATION, FILE, GENDER, HTML, INSERTION, MARKDOWN, NESTED, NULL, NUMBER, NodeType, OBJECT, PLUGIN_NODE_TYPES, PLURAL, PREACT_NODE, REACT_NODE, SELECT, SOLID_NODE, TEXT, TRANSLATION, TypedNodeModel, UNKNOWN, formatNodeType } from "./nodeType.js";
|
|
6
|
-
import { ContentAutoTransformation, ContentNode, Dictionary, DictionaryFormat, DictionaryId, DictionaryKey, DictionaryLocation, DictionaryQualifierType, DictionarySelector, DictionarySelectorForGroup, DictionaryVariantIdsOf, DictionaryVariantValue, Fill, GetSubPath, ImportMode, LocalDictionaryId, QualifiedDictionaryGroup, ResolveQualifiedDictionaryContent, TypedNode } from "./dictionary.js";
|
|
6
|
+
import { ContentAutoTransformation, ContentNode, Dictionary, DictionaryFormat, DictionaryId, DictionaryKey, DictionaryLocation, DictionaryQualifierType, DictionarySelector, DictionarySelectorForGroup, DictionaryVariantChain, DictionaryVariantIdsOf, DictionaryVariantValue, Fill, GetSubPath, ImportMode, LocalDictionaryId, ProviderVariant, ProviderVariantMap, QualifiedDictionaryGroup, ResolveQualifiedDictionaryContent, TypedNode } from "./dictionary.js";
|
|
7
7
|
import { MergedDictionaryOutput, MergedDictionaryResult, Plugin, UnmergedDictionaryOutput, UnmergedDictionaryResult } from "./plugin.js";
|
|
8
8
|
import { AiConfig, AiProviderConfigMap, AiProviders, AnalyticsConfig, BuildConfig, CommonAiConfig, CompilerConfig, ConfigSchema, ContentConfig, CookiesAttributes, CustomIntlayerConfig, CustomRoutingConfig, DictionaryConfig, EditorConfig, InternationalizationConfig, IntlayerConfig, LogConfig, LogFunctions, ProcessedCookieAttributes, ProcessedStorageAttributes, RewriteObject, RewriteRule, RewriteRules, RoutingConfig, RoutingStorageInput, StorageAttributes, StrictMode, SystemConfig, URLType } from "./config.js";
|
|
9
9
|
import { ArrayNode, ConditionNode, EnumerationNode, FileNode, GenderNode, HTMLNode, InsertionNode, KeyPath, MarkdownNode, NestedNode, ObjectNode, PluralNode, ReactNode, SelectNode, TranslationNode } from "./keyPath.js";
|
|
10
|
-
export { ALL_LOCALES, ARRAY, AiConfig, AiProviderConfigMap, AiProviders, AnalyticsConfig, ArrayNode, BOOLEAN, BuildConfig, CONDITION, CommonAiConfig, CompilerConfig, ConditionNode, ConfigSchema, ContentAutoTransformation, ContentConfig, ContentNode, CookiesAttributes, CustomIntlayerConfig, CustomRoutingConfig, DeclaredLocales, DeclaredVariants, Dictionary, DictionaryConfig, DictionaryFormat, DictionaryId, DictionaryKey, DictionaryKeys, DictionaryLocation, DictionaryQualifierType, DictionaryRegistry, DictionaryRegistryContent, DictionaryRegistryElement, DictionaryRegistryResult, DictionarySelector, DictionarySelectorForGroup, DictionarySelectorForKey, DictionaryVariantIdsOf, DictionaryVariantValue, ENUMERATION, EditorConfig, EnumerationNode, ExtractSelectorLocale, FILE, FileNode, FilePathPattern, FilePathPatternContext, FilePathPatternFunction, Fill, GENDER, GenderNode, GetLocaleLang, GetSubPath, HTML, HTMLNode, INSERTION, ImportMode, InsertionNode, InternationalizationConfig, IntlayerConfig, KeyPath, LocalDictionaryId, Locale, locales_d_exports as Locales, LocalesValues, LocalizedUrl, LogConfig, LogFunctions, MARKDOWN, MarkdownNode, MergedDictionaryOutput, MergedDictionaryResult, NESTED, NULL, NUMBER, NestedNode, NodeType, OBJECT, ObjectNode, PLUGIN_NODE_TYPES, PLURAL, PREACT_NODE, PathWithoutLocale, Plugin, PluralNode, ProcessedCookieAttributes, ProcessedStorageAttributes, QualifiedDictionaryGroup, REACT_NODE, ReactNode, RequiredLocales, ResolveQualifiedDictionaryContent, ResolvedDefaultLocale, ResolvedEditor, ResolvedRoutingMode, RewriteObject, RewriteRule, RewriteRules, RoutingConfig, RoutingStorageInput, SELECT, SOLID_NODE, Schema, SchemaKeys, SelectNode, StorageAttributes, StrictMode, StrictModeLocaleMap, SystemConfig, TEXT, TRANSLATION, TranslationNode, TypedNode, TypedNodeModel, UNKNOWN, URLType, UnmergedDictionaryOutput, UnmergedDictionaryResult, formatNodeType };
|
|
10
|
+
export { ALL_LOCALES, ARRAY, AiConfig, AiProviderConfigMap, AiProviders, AnalyticsConfig, ArrayNode, BOOLEAN, BuildConfig, CONDITION, CommonAiConfig, CompilerConfig, ConditionNode, ConfigSchema, ContentAutoTransformation, ContentConfig, ContentNode, CookiesAttributes, CustomIntlayerConfig, CustomRoutingConfig, DeclaredLocales, DeclaredVariants, Dictionary, DictionaryConfig, DictionaryFormat, DictionaryId, DictionaryKey, DictionaryKeys, DictionaryLocation, DictionaryQualifierType, DictionaryRegistry, DictionaryRegistryContent, DictionaryRegistryElement, DictionaryRegistryResult, DictionarySelector, DictionarySelectorForGroup, DictionarySelectorForKey, DictionaryVariantChain, DictionaryVariantIdsOf, DictionaryVariantValue, ENUMERATION, EditorConfig, EnumerationNode, ExtractSelectorLocale, FILE, FileNode, FilePathPattern, FilePathPatternContext, FilePathPatternFunction, Fill, GENDER, GenderNode, GetLocaleLang, GetSubPath, HTML, HTMLNode, INSERTION, ImportMode, InsertionNode, InternationalizationConfig, IntlayerConfig, KeyPath, LocalDictionaryId, Locale, locales_d_exports as Locales, LocalesValues, LocalizedUrl, LogConfig, LogFunctions, MARKDOWN, MarkdownNode, MergedDictionaryOutput, MergedDictionaryResult, NESTED, NULL, NUMBER, NestedNode, NodeType, OBJECT, ObjectNode, PLUGIN_NODE_TYPES, PLURAL, PREACT_NODE, PathWithoutLocale, Plugin, PluralNode, ProcessedCookieAttributes, ProcessedStorageAttributes, ProviderVariantMap, QualifiedDictionaryGroup, REACT_NODE, ReactNode, RequiredLocales, ResolveQualifiedDictionaryContent, ResolvedDefaultLocale, ResolvedEditor, ResolvedRoutingMode, RewriteObject, RewriteRule, RewriteRules, RoutingConfig, RoutingStorageInput, SELECT, SOLID_NODE, Schema, SchemaKeys, SelectNode, StorageAttributes, StrictMode, StrictModeLocaleMap, SystemConfig, TEXT, TRANSLATION, TranslationNode, TypedNode, TypedNodeModel, UNKNOWN, URLType, UnmergedDictionaryOutput, UnmergedDictionaryResult, formatNodeType };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Locale } from "./allLocales.js";
|
|
2
|
-
import { Dictionary, DictionarySelector, DictionarySelectorForGroup, DictionaryVariantIdsOf, ResolveQualifiedDictionaryContent } from "./dictionary.js";
|
|
2
|
+
import { Dictionary, DictionarySelector, DictionarySelectorForGroup, DictionaryVariantIdsOf, ProviderVariant as ProviderVariant$1, ResolveQualifiedDictionaryContent } from "./dictionary.js";
|
|
3
3
|
import { StrictMode } from "./config.js";
|
|
4
4
|
import { __DeclaredLocalesRegistry, __DictionaryRegistry, __EditorRegistry, __RequiredLocalesRegistry, __RoutingRegistry, __SchemaRegistry, __StrictModeRegistry } from "intlayer";
|
|
5
5
|
//#region src/module_augmentation.d.ts
|
|
@@ -51,6 +51,18 @@ type DeclaredVariants = DictionaryVariantIdsOf<__DictionaryRegistry[keyof __Dict
|
|
|
51
51
|
* value is a compile-time error. Plain keys fall back to {@link DictionarySelector}.
|
|
52
52
|
*/
|
|
53
53
|
type DictionarySelectorForKey<T extends PropertyKey> = [T] extends [keyof __DictionaryRegistry] ? DictionarySelectorForGroup<__DictionaryRegistry[T]> : DictionarySelector;
|
|
54
|
+
/**
|
|
55
|
+
* The `variant` prop of a framework provider (`<IntlayerProvider variant>`),
|
|
56
|
+
* narrowed to this project's declared dictionary keys — so the per-key map form
|
|
57
|
+
* rejects a key no dictionary declares.
|
|
58
|
+
*
|
|
59
|
+
* That narrowing is also what keeps the per-key map safely distinguishable from
|
|
60
|
+
* a structured variant value: on a provider a plain object is always read as
|
|
61
|
+
* the map, and `variant={{ id: 'prod_abc' }}` is a compile error unless `id`
|
|
62
|
+
* happens to be a dictionary key. Pin a structured variant globally by nesting
|
|
63
|
+
* it under an entry instead: `variant={{ default: { id: 'prod_abc' } }}`.
|
|
64
|
+
*/
|
|
65
|
+
type ProviderVariant = ProviderVariant$1<DictionaryKeys & string>;
|
|
54
66
|
type NarrowStringKeys<T> = string extends keyof T ? never : Extract<keyof T, string>;
|
|
55
67
|
type DeclaredLocales = [NarrowStringKeys<__DeclaredLocalesRegistry>] extends [never] ? Locale : NarrowStringKeys<__DeclaredLocalesRegistry>;
|
|
56
68
|
type RequiredLocales = [NarrowStringKeys<__RequiredLocalesRegistry>] extends [never] ? never : NarrowStringKeys<__RequiredLocalesRegistry>;
|
|
@@ -115,5 +127,5 @@ type GetLocaleLang<L extends string> = L extends `${infer Lang}-${string}` ? Lan
|
|
|
115
127
|
*/
|
|
116
128
|
type PathWithoutLocale<Path extends string, Locales extends string> = Path extends `${infer Protocol}://${infer Domain}/${infer Seg}/${infer Rest}` ? Seg extends Locales ? `${Protocol}://${Domain}/${Rest}` : Path : Path extends `${infer Protocol}://${infer Domain}/${infer Seg}` ? Seg extends Locales ? `${Protocol}://${Domain}/` : Path : Path extends `/${infer Seg}/${infer Rest}` ? Seg extends Locales ? `/${Rest}` : Path : Path extends `/${infer Seg}` ? Seg extends Locales ? "/" : Path : Path;
|
|
117
129
|
//#endregion
|
|
118
|
-
export { DeclaredLocales, DeclaredVariants, DictionaryKeys, DictionaryRegistry, DictionaryRegistryContent, DictionaryRegistryElement, DictionaryRegistryResult, type DictionarySelector, type DictionarySelectorForGroup, DictionarySelectorForKey, ExtractSelectorLocale, GetLocaleLang, LocalesValues, LocalizedUrl, PathWithoutLocale, RequiredLocales, ResolvedDefaultLocale, ResolvedEditor, ResolvedRoutingMode, Schema, SchemaKeys, StrictModeLocaleMap };
|
|
130
|
+
export { DeclaredLocales, DeclaredVariants, DictionaryKeys, DictionaryRegistry, DictionaryRegistryContent, DictionaryRegistryElement, DictionaryRegistryResult, type DictionarySelector, type DictionarySelectorForGroup, DictionarySelectorForKey, ExtractSelectorLocale, GetLocaleLang, LocalesValues, LocalizedUrl, PathWithoutLocale, ProviderVariant, RequiredLocales, ResolvedDefaultLocale, ResolvedEditor, ResolvedRoutingMode, Schema, SchemaKeys, StrictModeLocaleMap };
|
|
119
131
|
//# sourceMappingURL=module_augmentation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module_augmentation.d.ts","names":[],"sources":["../../src/module_augmentation.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"module_augmentation.d.ts","names":[],"sources":["../../src/module_augmentation.ts"],"mappings":";;;;;KAoBY,mBAAmB,gDAErB;KAEE,OAAO,UAAU,gCAAgC,WAEzD,gBAAgB,mBACd,iBAAiB;KAGX,uBAAuB,oDAEzB;KAGE,qBACV,2BAA2B,sCACvB,eAAe,cACf;KAEM,0BAA0B,UAAU,oCAErC,KACP,aACA,gBAAgB,uBACd,qBAAqB,WAAW,aAC9B,qBAAqB,KACrB,aACF;KAEM,0BAA0B,UAAU,gBAAgB,kBACxD,wBAEJ,qBAAqB;EAAa,eAAe;IAC/C,IACA,wBACF;;;;;;;;;;KAWQ,yBAAyB,UAAU,aAAa,oBAC1D,kBACe,wBACb,kCAAkC,qBAAqB,IAAI,OAC3D;;;;;KAMQ,sBAAsB,OAAO;EACvC,cAAc,UAAU;IAEtB,IACA,YAAY,gBACV,MACA;;;;;;;;;;;;;;;;;KAkBM,mBAAmB,uBAC7B,2BAA2B;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