@inlang/paraglide-js 2.14.0 → 2.15.0
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/dist/cli/steps/initialize-inlang-project.d.ts.map +1 -1
- package/dist/cli/steps/initialize-inlang-project.js +0 -3
- package/dist/cli/steps/initialize-inlang-project.js.map +1 -1
- package/dist/compiler/compile.d.ts.map +1 -1
- package/dist/compiler/compile.js +0 -2
- package/dist/compiler/compile.js.map +1 -1
- package/dist/compiler/runtime/check-locale.d.ts +32 -0
- package/dist/compiler/runtime/check-locale.d.ts.map +1 -0
- package/dist/compiler/runtime/check-locale.js +51 -0
- package/dist/compiler/runtime/check-locale.js.map +1 -0
- package/dist/compiler/runtime/check-locale.test.d.ts +2 -0
- package/dist/compiler/runtime/check-locale.test.d.ts.map +1 -0
- package/dist/compiler/runtime/check-locale.test.js +117 -0
- package/dist/compiler/runtime/check-locale.test.js.map +1 -0
- package/dist/compiler/runtime/create-runtime.d.ts.map +1 -1
- package/dist/compiler/runtime/create-runtime.js +12 -6
- package/dist/compiler/runtime/create-runtime.js.map +1 -1
- package/dist/compiler/runtime/extract-locale-from-cookie.d.ts.map +1 -1
- package/dist/compiler/runtime/extract-locale-from-cookie.js +2 -5
- package/dist/compiler/runtime/extract-locale-from-cookie.js.map +1 -1
- package/dist/compiler/runtime/extract-locale-from-cookie.test.js +16 -0
- package/dist/compiler/runtime/extract-locale-from-cookie.test.js.map +1 -1
- package/dist/compiler/runtime/extract-locale-from-header.d.ts.map +1 -1
- package/dist/compiler/runtime/extract-locale-from-header.js +9 -7
- package/dist/compiler/runtime/extract-locale-from-header.js.map +1 -1
- package/dist/compiler/runtime/extract-locale-from-header.test.js +16 -0
- package/dist/compiler/runtime/extract-locale-from-header.test.js.map +1 -1
- package/dist/compiler/runtime/extract-locale-from-navigator.d.ts.map +1 -1
- package/dist/compiler/runtime/extract-locale-from-navigator.js +9 -7
- package/dist/compiler/runtime/extract-locale-from-navigator.js.map +1 -1
- package/dist/compiler/runtime/extract-locale-from-navigator.test.js +24 -0
- package/dist/compiler/runtime/extract-locale-from-navigator.test.js.map +1 -1
- package/dist/compiler/runtime/extract-locale-from-request-async.d.ts.map +1 -1
- package/dist/compiler/runtime/extract-locale-from-request-async.js +5 -6
- package/dist/compiler/runtime/extract-locale-from-request-async.js.map +1 -1
- package/dist/compiler/runtime/extract-locale-from-request.d.ts.map +1 -1
- package/dist/compiler/runtime/extract-locale-from-request.js +4 -9
- package/dist/compiler/runtime/extract-locale-from-request.js.map +1 -1
- package/dist/compiler/runtime/extract-locale-from-url.d.ts +4 -0
- package/dist/compiler/runtime/extract-locale-from-url.d.ts.map +1 -1
- package/dist/compiler/runtime/extract-locale-from-url.js +8 -15
- package/dist/compiler/runtime/extract-locale-from-url.js.map +1 -1
- package/dist/compiler/runtime/extract-locale-from-url.test.js +32 -0
- package/dist/compiler/runtime/extract-locale-from-url.test.js.map +1 -1
- package/dist/compiler/runtime/get-locale.d.ts.map +1 -1
- package/dist/compiler/runtime/get-locale.js +10 -7
- package/dist/compiler/runtime/get-locale.js.map +1 -1
- package/dist/compiler/runtime/get-locale.test.js +12 -0
- package/dist/compiler/runtime/get-locale.test.js.map +1 -1
- package/dist/compiler/runtime/localize-href.d.ts +2 -2
- package/dist/compiler/runtime/localize-href.js +2 -2
- package/dist/compiler/runtime/localize-href.test.js +13 -0
- package/dist/compiler/runtime/localize-href.test.js.map +1 -1
- package/dist/compiler/runtime/localize-url.d.ts +2 -2
- package/dist/compiler/runtime/localize-url.d.ts.map +1 -1
- package/dist/compiler/runtime/localize-url.js +11 -11
- package/dist/compiler/runtime/localize-url.js.map +1 -1
- package/dist/compiler/runtime/localize-url.test.js +32 -0
- package/dist/compiler/runtime/localize-url.test.js.map +1 -1
- package/dist/compiler/runtime/set-locale.js +2 -2
- package/dist/compiler/runtime/set-locale.js.map +1 -1
- package/dist/compiler/runtime/set-locale.test.js +28 -0
- package/dist/compiler/runtime/set-locale.test.js.map +1 -1
- package/dist/compiler/runtime/should-redirect.d.ts +4 -5
- package/dist/compiler/runtime/should-redirect.d.ts.map +1 -1
- package/dist/compiler/runtime/should-redirect.js +9 -8
- package/dist/compiler/runtime/should-redirect.js.map +1 -1
- package/dist/compiler/runtime/type-definitions.js +1 -1
- package/dist/compiler/runtime/type.d.ts +3 -2
- package/dist/compiler/runtime/type.d.ts.map +1 -1
- package/dist/compiler/runtime/type.test.js +18 -0
- package/dist/compiler/runtime/type.test.js.map +1 -1
- package/dist/compiler/runtime/variables.d.ts.map +1 -1
- package/dist/compiler/runtime/variables.js +2 -4
- package/dist/compiler/runtime/variables.js.map +1 -1
- package/dist/services/env-variables/create-index-file.js +0 -1
- package/dist/services/env-variables/create-index-file.js.map +1 -1
- package/dist/services/env-variables/index.d.ts +0 -1
- package/dist/services/env-variables/index.d.ts.map +1 -1
- package/dist/services/env-variables/index.js +1 -2
- package/dist/services/env-variables/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/compiler/runtime/assert-is-locale.d.ts +0 -9
- package/dist/compiler/runtime/assert-is-locale.d.ts.map +0 -1
- package/dist/compiler/runtime/assert-is-locale.js +0 -20
- package/dist/compiler/runtime/assert-is-locale.js.map +0 -1
- package/dist/compiler/runtime/assert-is-locale.test.d.ts +0 -2
- package/dist/compiler/runtime/assert-is-locale.test.d.ts.map +0 -1
- package/dist/compiler/runtime/assert-is-locale.test.js +0 -70
- package/dist/compiler/runtime/assert-is-locale.test.js.map +0 -1
- package/dist/compiler/runtime/is-locale.d.ts +0 -16
- package/dist/compiler/runtime/is-locale.d.ts.map +0 -1
- package/dist/compiler/runtime/is-locale.js +0 -23
- package/dist/compiler/runtime/is-locale.js.map +0 -1
- package/dist/compiler/runtime/is-locale.test.d.ts +0 -2
- package/dist/compiler/runtime/is-locale.test.d.ts.map +0 -1
- package/dist/compiler/runtime/is-locale.test.js +0 -32
- package/dist/compiler/runtime/is-locale.test.js.map +0 -1
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Asserts that the input is a locale.
|
|
3
|
-
*
|
|
4
|
-
* @param {unknown} input - The input to check.
|
|
5
|
-
* @returns {Locale} The input if it is a locale.
|
|
6
|
-
* @throws {Error} If the input is not a locale.
|
|
7
|
-
*/
|
|
8
|
-
export function assertIsLocale(input: unknown): Locale;
|
|
9
|
-
//# sourceMappingURL=assert-is-locale.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"assert-is-locale.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/assert-is-locale.js"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,sCAJW,OAAO,GACL,MAAM,CAiBlB"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { locales } from "./variables.js";
|
|
2
|
-
/**
|
|
3
|
-
* Asserts that the input is a locale.
|
|
4
|
-
*
|
|
5
|
-
* @param {unknown} input - The input to check.
|
|
6
|
-
* @returns {Locale} The input if it is a locale.
|
|
7
|
-
* @throws {Error} If the input is not a locale.
|
|
8
|
-
*/
|
|
9
|
-
export function assertIsLocale(input) {
|
|
10
|
-
if (typeof input !== "string") {
|
|
11
|
-
throw new Error(`Invalid locale: ${input}. Expected a string.`);
|
|
12
|
-
}
|
|
13
|
-
const lowerInput = input.toLowerCase();
|
|
14
|
-
const matchedLocale = locales.find((item) => item.toLowerCase() === lowerInput);
|
|
15
|
-
if (!matchedLocale) {
|
|
16
|
-
throw new Error(`Invalid locale: ${input}. Expected one of: ${locales.join(", ")}`);
|
|
17
|
-
}
|
|
18
|
-
return matchedLocale;
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=assert-is-locale.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"assert-is-locale.js","sourceRoot":"","sources":["../../../src/compiler/runtime/assert-is-locale.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,KAAK;IACnC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,mBAAmB,KAAK,sBAAsB,CAAC,CAAC;IACjE,CAAC;IACD,MAAM,UAAU,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;IACvC,MAAM,aAAa,GAAG,OAAO,CAAC,IAAI,CACjC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,UAAU,CAC3C,CAAC;IACF,IAAI,CAAC,aAAa,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CACd,mBAAmB,KAAK,sBAAsB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAClE,CAAC;IACH,CAAC;IACD,OAAO,aAAa,CAAC;AACtB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"assert-is-locale.test.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/assert-is-locale.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { newProject } from "@inlang/sdk";
|
|
2
|
-
import { expect, test } from "vitest";
|
|
3
|
-
import { createParaglide } from "../create-paraglide.js";
|
|
4
|
-
test("throws if the locale is not available", async () => {
|
|
5
|
-
const runtime = await createParaglide({
|
|
6
|
-
blob: await newProject({
|
|
7
|
-
settings: {
|
|
8
|
-
baseLocale: "en",
|
|
9
|
-
locales: ["en", "de"],
|
|
10
|
-
},
|
|
11
|
-
}),
|
|
12
|
-
});
|
|
13
|
-
expect(() => runtime.assertIsLocale("es")).toThrow();
|
|
14
|
-
});
|
|
15
|
-
test("throws for non-string inputs", async () => {
|
|
16
|
-
const runtime = await createParaglide({
|
|
17
|
-
blob: await newProject({
|
|
18
|
-
settings: {
|
|
19
|
-
baseLocale: "en",
|
|
20
|
-
locales: ["en", "de"],
|
|
21
|
-
},
|
|
22
|
-
}),
|
|
23
|
-
});
|
|
24
|
-
expect(() => runtime.assertIsLocale(null)).toThrow();
|
|
25
|
-
expect(() => runtime.assertIsLocale(undefined)).toThrow();
|
|
26
|
-
expect(() => runtime.assertIsLocale(123)).toThrow();
|
|
27
|
-
expect(() => runtime.assertIsLocale({})).toThrow();
|
|
28
|
-
expect(() => runtime.assertIsLocale([])).toThrow();
|
|
29
|
-
});
|
|
30
|
-
test("passes if the locale is available", async () => {
|
|
31
|
-
const runtime = await createParaglide({
|
|
32
|
-
blob: await newProject({
|
|
33
|
-
settings: {
|
|
34
|
-
baseLocale: "en",
|
|
35
|
-
locales: ["en", "de"],
|
|
36
|
-
},
|
|
37
|
-
}),
|
|
38
|
-
});
|
|
39
|
-
expect(() => runtime.assertIsLocale("en")).not.toThrow();
|
|
40
|
-
});
|
|
41
|
-
test("the return value is a Locale", async () => {
|
|
42
|
-
const runtime = await createParaglide({
|
|
43
|
-
blob: await newProject({
|
|
44
|
-
settings: {
|
|
45
|
-
baseLocale: "en",
|
|
46
|
-
locales: ["en", "de"],
|
|
47
|
-
},
|
|
48
|
-
}),
|
|
49
|
-
});
|
|
50
|
-
const locale = runtime.assertIsLocale("en");
|
|
51
|
-
// a bit of a wacky test given that locale is `string`
|
|
52
|
-
locale;
|
|
53
|
-
});
|
|
54
|
-
test("is case-insensitive", async () => {
|
|
55
|
-
const runtime = await createParaglide({
|
|
56
|
-
blob: await newProject({
|
|
57
|
-
settings: {
|
|
58
|
-
baseLocale: "en",
|
|
59
|
-
locales: ["en", "pt-BR", "de-ch"],
|
|
60
|
-
},
|
|
61
|
-
}),
|
|
62
|
-
});
|
|
63
|
-
expect(() => runtime.assertIsLocale("EN")).not.toThrow();
|
|
64
|
-
expect(() => runtime.assertIsLocale("pt-br")).not.toThrow();
|
|
65
|
-
expect(() => runtime.assertIsLocale("de-CH")).not.toThrow();
|
|
66
|
-
expect(runtime.assertIsLocale("EN")).toBe("en");
|
|
67
|
-
expect(runtime.assertIsLocale("pT-bR")).toBe("pt-BR");
|
|
68
|
-
expect(runtime.assertIsLocale("de-CH")).toBe("de-ch");
|
|
69
|
-
});
|
|
70
|
-
//# sourceMappingURL=assert-is-locale.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"assert-is-locale.test.js","sourceRoot":"","sources":["../../../src/compiler/runtime/assert-is-locale.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAGzD,IAAI,CAAC,uCAAuC,EAAE,KAAK,IAAI,EAAE;IACxD,MAAM,OAAO,GAAG,MAAM,eAAe,CAAC;QACrC,IAAI,EAAE,MAAM,UAAU,CAAC;YACtB,QAAQ,EAAE;gBACT,UAAU,EAAE,IAAI;gBAChB,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC;aACrB;SACD,CAAC;KACF,CAAC,CAAC;IAEH,MAAM,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;AACtD,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,8BAA8B,EAAE,KAAK,IAAI,EAAE;IAC/C,MAAM,OAAO,GAAG,MAAM,eAAe,CAAC;QACrC,IAAI,EAAE,MAAM,UAAU,CAAC;YACtB,QAAQ,EAAE;gBACT,UAAU,EAAE,IAAI;gBAChB,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC;aACrB;SACD,CAAC;KACF,CAAC,CAAC;IAEH,MAAM,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;IACrD,MAAM,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;IAC1D,MAA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AAQ,EAAE;gBACT,UAAU,EAAE,IAAI;gBAChB,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC;aACjC;SACD,CAAC;KACF,CAAC,CAAC;IAEH,MAAM,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;IACzD,MAAM,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;IAC5D,MAAM,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;IAE5D,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChD,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACtD,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACvD,CAAC,CAAC,CAAC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Check if something is an available locale.
|
|
3
|
-
*
|
|
4
|
-
* @example
|
|
5
|
-
* if (isLocale(params.locale)) {
|
|
6
|
-
* setLocale(params.locale);
|
|
7
|
-
* } else {
|
|
8
|
-
* setLocale('en');
|
|
9
|
-
* }
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* @param {unknown} locale
|
|
13
|
-
* @returns {locale is Locale}
|
|
14
|
-
*/
|
|
15
|
-
export function isLocale(locale: unknown): locale is Locale;
|
|
16
|
-
//# sourceMappingURL=is-locale.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-locale.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/is-locale.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,iCAHW,OAAO,GACL,MAAM,IAAI,MAAM,CAO5B"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { locales } from "./variables.js";
|
|
2
|
-
/**
|
|
3
|
-
* Check if something is an available locale.
|
|
4
|
-
*
|
|
5
|
-
* @example
|
|
6
|
-
* if (isLocale(params.locale)) {
|
|
7
|
-
* setLocale(params.locale);
|
|
8
|
-
* } else {
|
|
9
|
-
* setLocale('en');
|
|
10
|
-
* }
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* @param {unknown} locale
|
|
14
|
-
* @returns {locale is Locale}
|
|
15
|
-
*/
|
|
16
|
-
export function isLocale(locale) {
|
|
17
|
-
if (typeof locale !== "string")
|
|
18
|
-
return false;
|
|
19
|
-
return !locale
|
|
20
|
-
? false
|
|
21
|
-
: locales.some((item) => item.toLowerCase() === locale.toLowerCase());
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=is-locale.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-locale.js","sourceRoot":"","sources":["../../../src/compiler/runtime/is-locale.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,QAAQ,CAAC,MAAM;IAC9B,IAAI,OAAO,MAAM,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC7C,OAAO,CAAC,MAAM;QACb,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC;AACxE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-locale.test.d.ts","sourceRoot":"","sources":["../../../src/compiler/runtime/is-locale.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { newProject } from "@inlang/sdk";
|
|
2
|
-
import { expect, test } from "vitest";
|
|
3
|
-
import { createParaglide } from "../create-paraglide.js";
|
|
4
|
-
const runtime = await createParaglide({
|
|
5
|
-
blob: await newProject({
|
|
6
|
-
settings: {
|
|
7
|
-
baseLocale: "en",
|
|
8
|
-
locales: ["en", "pt-BR", "de-ch"],
|
|
9
|
-
},
|
|
10
|
-
}),
|
|
11
|
-
});
|
|
12
|
-
test("returns true for exact matches", () => {
|
|
13
|
-
expect(runtime.isLocale("pt-BR")).toBe(true);
|
|
14
|
-
});
|
|
15
|
-
test("is case-insensitive", () => {
|
|
16
|
-
expect(runtime.isLocale("EN")).toBe(true);
|
|
17
|
-
expect(runtime.isLocale("pt-br")).toBe(true);
|
|
18
|
-
expect(runtime.isLocale("de-CH")).toBe(true);
|
|
19
|
-
});
|
|
20
|
-
test("returns false for non-existent locales", () => {
|
|
21
|
-
expect(runtime.isLocale("es")).toBe(false);
|
|
22
|
-
expect(runtime.isLocale("xx")).toBe(false);
|
|
23
|
-
expect(runtime.isLocale("")).toBe(false);
|
|
24
|
-
});
|
|
25
|
-
test("returns false for non-string inputs", () => {
|
|
26
|
-
expect(runtime.isLocale(null)).toBe(false);
|
|
27
|
-
expect(runtime.isLocale(undefined)).toBe(false);
|
|
28
|
-
expect(runtime.isLocale(123)).toBe(false);
|
|
29
|
-
expect(runtime.isLocale({})).toBe(false);
|
|
30
|
-
expect(runtime.isLocale([])).toBe(false);
|
|
31
|
-
});
|
|
32
|
-
//# sourceMappingURL=is-locale.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-locale.test.js","sourceRoot":"","sources":["../../../src/compiler/runtime/is-locale.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,O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