@vielzeug/assay 3.0.0 → 26.10.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.
@@ -1 +0,0 @@
1
- {"version":3,"file":"live-region.cjs","names":[],"sources":["../src/live-region.ts"],"sourcesContent":["import { AssayQueryError } from './errors';\nimport { eventually, type WaitOptions } from './wait';\n\n/** Politeness levels for ARIA live regions. */\nexport type LiveRegionPoliteness = 'assertive' | 'off' | 'polite';\n\n/**\n * ARIA roles that carry an implicit `aria-live` value per the WAI-ARIA spec.\n * `alert` is assertive; `log` and `status` are polite; `marquee` and `timer` are\n * off. Elements with these roles are live regions without explicit `aria-live`.\n */\nconst IMPLICIT_ROLE_POLITENESS: Record<string, LiveRegionPoliteness> = {\n alert: 'assertive',\n log: 'polite',\n marquee: 'off',\n status: 'polite',\n timer: 'off',\n};\nconst LIVE_REGION_SELECTOR =\n '[aria-live], [role=\"alert\"], [role=\"log\"], [role=\"marquee\"], [role=\"status\"], [role=\"timer\"]';\n\nexport interface LiveRegionQueryOptions {\n /** The document to search. Defaults to the global `document`. */\n document?: Document;\n /** Politeness to match via `aria-live` (or implicit role). Defaults to `'polite'`. */\n politeness?: LiveRegionPoliteness;\n /** ARIA role to match (e.g. `'status'`, `'alert'`). Omit to match any role. */\n role?: string;\n /** Root to scope the query. Defaults to `document.body`. */\n root?: ParentNode;\n}\n\n/**\n * Resolves the effective politeness of an element: explicit `aria-live` wins,\n * otherwise falls back to the implicit value from `role=\"status\"`/`role=\"alert\"`.\n * Returns `null` when the element is not a live region.\n */\nfunction resolvePoliteness(el: HTMLElement): LiveRegionPoliteness | null {\n const explicit = el.getAttribute('aria-live');\n\n if (explicit) return explicit as LiveRegionPoliteness;\n\n const role = el.getAttribute('role');\n\n if (role && role in IMPLICIT_ROLE_POLITENESS) return IMPLICIT_ROLE_POLITENESS[role];\n\n return null;\n}\n\nfunction candidates(root: ParentNode): HTMLElement[] {\n const descendants = Array.from(root.querySelectorAll<HTMLElement>(LIVE_REGION_SELECTOR));\n const rootElement = root as ParentNode & { matches?: (selector: string) => boolean };\n\n return rootElement.matches?.(LIVE_REGION_SELECTOR) ? [root as HTMLElement, ...descendants] : descendants;\n}\n\nfunction matchesOptions(element: HTMLElement, politeness: LiveRegionPoliteness, role?: string): boolean {\n return resolvePoliteness(element) === politeness && (role === undefined || element.getAttribute('role') === role);\n}\n\n/**\n * Queries the first live region matching the given politeness (and optional role)\n * within `root`. Returns `null` when none exists — safe to call before the region\n * has been lazily created.\n *\n * Matches explicit `aria-live` attributes and implicit live-region roles.\n *\n * @example\n * const region = queryLiveRegion({ politeness: 'polite' });\n * expect(region).not.toBeNull();\n */\nexport function queryLiveRegion(options: LiveRegionQueryOptions = {}): HTMLElement | null {\n const doc = options.document ?? (typeof document !== 'undefined' ? document : null);\n const politeness = options.politeness ?? 'polite';\n const root = options.root ?? doc?.body ?? null;\n\n if (!root) return null;\n\n return candidates(root).find((element) => matchesOptions(element, politeness, options.role)) ?? null;\n}\n\n/**\n * Queries all live regions matching the given politeness (and optional role)\n * within `root`. Useful for asserting no duplicate regions were created.\n *\n * @example\n * expect(queryAllLiveRegions({ politeness: 'polite' })).toHaveLength(1);\n */\nexport function queryAllLiveRegions(options: LiveRegionQueryOptions = {}): HTMLElement[] {\n const doc = options.document ?? (typeof document !== 'undefined' ? document : null);\n const politeness = options.politeness ?? 'polite';\n const root = options.root ?? doc?.body ?? null;\n\n if (!root) return [];\n\n return candidates(root).filter((element) => matchesOptions(element, politeness, options.role));\n}\n\nexport interface WaitForLiveRegionOptions extends WaitOptions {\n /** The document to search. Defaults to the global `document`. */\n document?: Document;\n /** Politeness to match via `aria-live`. Defaults to `'polite'`. */\n politeness?: LiveRegionPoliteness;\n /** ARIA role to match. Omit to match any role. */\n role?: string;\n /** Root to scope the query. Defaults to `document.body`. */\n root?: ParentNode;\n}\n\n/**\n * Retries until a live region matching the politeness/role exists and contains\n * `text` (substring match). Throws `AssayTimeoutError` on timeout.\n *\n * Handles the clear-then-set announce pattern: the region may briefly be empty\n * before the message is written, so polling until the text appears is the\n * correct approach rather than a single snapshot assertion.\n *\n * @example\n * await waitForLiveRegion('3 results found');\n * await waitForLiveRegion('Session expired', { politeness: 'assertive' });\n */\nexport async function waitForLiveRegion(text: string, options: WaitForLiveRegionOptions = {}): Promise<HTMLElement> {\n const politeness = options.politeness ?? 'polite';\n let matched: HTMLElement | null = null;\n\n await eventually(\n () => {\n const regions = queryAllLiveRegions({\n document: options.document,\n politeness,\n role: options.role,\n root: options.root,\n });\n const region = regions.find((candidate) => candidate.textContent?.includes(text));\n\n if (region) {\n matched = region;\n return;\n }\n\n if (regions.length === 0) throw new AssayQueryError(`No ${politeness} live region found.`);\n throw new AssayQueryError(`No ${politeness} live region includes \"${text}\".`);\n },\n {\n interval: options.interval,\n message: `waitForLiveRegion(\"${text}\")`,\n signal: options.signal,\n timeout: options.timeout,\n },\n );\n\n // `eventually` only resolves once the assertion stops throwing, so `matched` is set.\n return matched!;\n}\n\n/**\n * Retries until a live region matching the politeness/role exists and is empty\n * (cleared). Throws `AssayTimeoutError` on timeout.\n *\n * @example\n * await waitForLiveRegionCleared();\n */\nexport async function waitForLiveRegionCleared(options: WaitForLiveRegionOptions = {}): Promise<void> {\n const politeness = options.politeness ?? 'polite';\n\n await eventually(\n () => {\n const regions = queryAllLiveRegions({\n document: options.document,\n politeness,\n role: options.role,\n root: options.root,\n });\n\n if (regions.some((region) => region.textContent === '')) return;\n if (regions.length === 0) throw new AssayQueryError(`No ${politeness} live region found.`);\n throw new AssayQueryError(`No ${politeness} live region is cleared.`);\n },\n {\n interval: options.interval,\n message: 'waitForLiveRegionCleared',\n signal: options.signal,\n timeout: options.timeout,\n },\n );\n}\n"],"mappings":"wDAWA,IAAM,EAAiE,CACrE,MAAO,YACP,IAAK,SACL,QAAS,MACT,OAAQ,SACR,MAAO,KACT,EACM,EACJ,+FAkBF,SAAS,EAAkB,EAA8C,CACvE,IAAM,EAAW,EAAG,aAAa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AI,CAAC,EAEhF,GAAI,EAAQ,CACV,EAAU,EACV,MACF,CAGA,MADI,EAAQ,SAAW,EAAS,IAAI,EAAA,gBAAgB,MAAM,EAAW,oBAAoB,EACnF,IAAI,EAAA,gBAAgB,MAAM,EAAW,yBAAyB,EAAK,GAAG,CAC9E,EACA,CACE,SAAU,EAAQ,SAClB,QAAS,sBAAsB,EAAK,IACpC,OAAQ,EAAQ,OAChB,QAAS,EAAQ,OACnB,CACF,EAGO,CACT,CASA,eAAsB,EAAyB,EAAoC,CAAC,EAAkB,CACpG,IAAM,EAAa,EAAQ,YAAc,SAEzC,MAAM,EAAA,eACE,CACJ,IAAM,EAAU,EAAoB,CAClC,SAAU,EAAQ,SAClB,aACA,KAAM,EAAQ,KACd,KAAM,EAAQ,IAChB,CAAC,EAEG,MAAQ,KAAM,GAAW,EAAO,cAAgB,EAAE,EAEtD,MADI,EAAQ,SAAW,EAAS,IAAI,EAAA,gBAAgB,MAAM,EAAW,oBAAoB,EACnF,IAAI,EAAA,gBAAgB,MAAM,EAAW,yBAAyB,CACtE,EACA,CACE,SAAU,EAAQ,SAClB,QAAS,2BACT,OAAQ,EAAQ,OAChB,QAAS,EAAQ,OACnB,CACF,CACF"}
@@ -1,65 +0,0 @@
1
- import { type WaitOptions } from './wait';
2
- /** Politeness levels for ARIA live regions. */
3
- export type LiveRegionPoliteness = 'assertive' | 'off' | 'polite';
4
- export interface LiveRegionQueryOptions {
5
- /** The document to search. Defaults to the global `document`. */
6
- document?: Document;
7
- /** Politeness to match via `aria-live` (or implicit role). Defaults to `'polite'`. */
8
- politeness?: LiveRegionPoliteness;
9
- /** ARIA role to match (e.g. `'status'`, `'alert'`). Omit to match any role. */
10
- role?: string;
11
- /** Root to scope the query. Defaults to `document.body`. */
12
- root?: ParentNode;
13
- }
14
- /**
15
- * Queries the first live region matching the given politeness (and optional role)
16
- * within `root`. Returns `null` when none exists — safe to call before the region
17
- * has been lazily created.
18
- *
19
- * Matches explicit `aria-live` attributes and implicit live-region roles.
20
- *
21
- * @example
22
- * const region = queryLiveRegion({ politeness: 'polite' });
23
- * expect(region).not.toBeNull();
24
- */
25
- export declare function queryLiveRegion(options?: LiveRegionQueryOptions): HTMLElement | null;
26
- /**
27
- * Queries all live regions matching the given politeness (and optional role)
28
- * within `root`. Useful for asserting no duplicate regions were created.
29
- *
30
- * @example
31
- * expect(queryAllLiveRegions({ politeness: 'polite' })).toHaveLength(1);
32
- */
33
- export declare function queryAllLiveRegions(options?: LiveRegionQueryOptions): HTMLElement[];
34
- export interface WaitForLiveRegionOptions extends WaitOptions {
35
- /** The document to search. Defaults to the global `document`. */
36
- document?: Document;
37
- /** Politeness to match via `aria-live`. Defaults to `'polite'`. */
38
- politeness?: LiveRegionPoliteness;
39
- /** ARIA role to match. Omit to match any role. */
40
- role?: string;
41
- /** Root to scope the query. Defaults to `document.body`. */
42
- root?: ParentNode;
43
- }
44
- /**
45
- * Retries until a live region matching the politeness/role exists and contains
46
- * `text` (substring match). Throws `AssayTimeoutError` on timeout.
47
- *
48
- * Handles the clear-then-set announce pattern: the region may briefly be empty
49
- * before the message is written, so polling until the text appears is the
50
- * correct approach rather than a single snapshot assertion.
51
- *
52
- * @example
53
- * await waitForLiveRegion('3 results found');
54
- * await waitForLiveRegion('Session expired', { politeness: 'assertive' });
55
- */
56
- export declare function waitForLiveRegion(text: string, options?: WaitForLiveRegionOptions): Promise<HTMLElement>;
57
- /**
58
- * Retries until a live region matching the politeness/role exists and is empty
59
- * (cleared). Throws `AssayTimeoutError` on timeout.
60
- *
61
- * @example
62
- * await waitForLiveRegionCleared();
63
- */
64
- export declare function waitForLiveRegionCleared(options?: WaitForLiveRegionOptions): Promise<void>;
65
- //# sourceMappingURL=live-region.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"live-region.d.ts","sourceRoot":"","sources":["../src/live-region.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,KAAK,WAAW,EAAE,MAAM,QAAQ,CAAC;AAEtD,+CAA+C;AAC/C,MAAM,MAAM,oBAAoB,GAAG,WAAW,GAAG,KAAK,GAAG,QAAQ,CAAC;AAiBlE,MAAM,WAAW,sBAAsB;IACrC,iEAAiE;IACjE,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,sFAAsF;IACtF,UAAU,CAAC,EAAE,oBAAoB,CAAC;IAClC,+EAA+E;IAC/E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,4DAA4D;IAC5D,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB;AA8BD;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,OAAO,GAAE,sBAA2B,GAAG,WAAW,GAAG,IAAI,CAQxF;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,sBAA2B,GAAG,WAAW,EAAE,CAQvF;AAED,MAAM,WAAW,wBAAyB,SAAQ,WAAW;IAC3D,iEAAiE;IACjE,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,mEAAmE;IACnE,UAAU,CAAC,EAAE,oBAAoB,CAAC;IAClC,kDAAkD;IAClD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,4DAA4D;IAC5D,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,wBAA6B,GAAG,OAAO,CAAC,WAAW,CAAC,CAgClH;AAED;;;;;;GAMG;AACH,wBAAsB,wBAAwB,CAAC,OAAO,GAAE,wBAA6B,GAAG,OAAO,CAAC,IAAI,CAAC,CAuBpG"}
@@ -1,73 +0,0 @@
1
- import { AssayQueryError as e } from "./errors.js";
2
- import { eventually as t } from "./wait.js";
3
- //#region src/live-region.ts
4
- var n = {
5
- alert: "assertive",
6
- log: "polite",
7
- marquee: "off",
8
- status: "polite",
9
- timer: "off"
10
- }, r = "[aria-live], [role=\"alert\"], [role=\"log\"], [role=\"marquee\"], [role=\"status\"], [role=\"timer\"]";
11
- function i(e) {
12
- let t = e.getAttribute("aria-live");
13
- if (t) return t;
14
- let r = e.getAttribute("role");
15
- return r && r in n ? n[r] : null;
16
- }
17
- function a(e) {
18
- let t = Array.from(e.querySelectorAll(r));
19
- return e.matches?.(r) ? [e, ...t] : t;
20
- }
21
- function o(e, t, n) {
22
- return i(e) === t && (n === void 0 || e.getAttribute("role") === n);
23
- }
24
- function s(e = {}) {
25
- let t = e.document ?? (typeof document < "u" ? document : null), n = e.politeness ?? "polite", r = e.root ?? t?.body ?? null;
26
- return r ? a(r).find((t) => o(t, n, e.role)) ?? null : null;
27
- }
28
- function c(e = {}) {
29
- let t = e.document ?? (typeof document < "u" ? document : null), n = e.politeness ?? "polite", r = e.root ?? t?.body ?? null;
30
- return r ? a(r).filter((t) => o(t, n, e.role)) : [];
31
- }
32
- async function l(n, r = {}) {
33
- let i = r.politeness ?? "polite", a = null;
34
- return await t(() => {
35
- let t = c({
36
- document: r.document,
37
- politeness: i,
38
- role: r.role,
39
- root: r.root
40
- }), o = t.find((e) => e.textContent?.includes(n));
41
- if (o) {
42
- a = o;
43
- return;
44
- }
45
- throw t.length === 0 ? new e(`No ${i} live region found.`) : new e(`No ${i} live region includes "${n}".`);
46
- }, {
47
- interval: r.interval,
48
- message: `waitForLiveRegion("${n}")`,
49
- signal: r.signal,
50
- timeout: r.timeout
51
- }), a;
52
- }
53
- async function u(n = {}) {
54
- let r = n.politeness ?? "polite";
55
- await t(() => {
56
- let t = c({
57
- document: n.document,
58
- politeness: r,
59
- role: n.role,
60
- root: n.root
61
- });
62
- if (!t.some((e) => e.textContent === "")) throw t.length === 0 ? new e(`No ${r} live region found.`) : new e(`No ${r} live region is cleared.`);
63
- }, {
64
- interval: n.interval,
65
- message: "waitForLiveRegionCleared",
66
- signal: n.signal,
67
- timeout: n.timeout
68
- });
69
- }
70
- //#endregion
71
- export { c as queryAllLiveRegions, s as queryLiveRegion, l as waitForLiveRegion, u as waitForLiveRegionCleared };
72
-
73
- //# sourceMappingURL=live-region.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"live-region.js","names":[],"sources":["../src/live-region.ts"],"sourcesContent":["import { AssayQueryError } from './errors';\nimport { eventually, type WaitOptions } from './wait';\n\n/** Politeness levels for ARIA live regions. */\nexport type LiveRegionPoliteness = 'assertive' | 'off' | 'polite';\n\n/**\n * ARIA roles that carry an implicit `aria-live` value per the WAI-ARIA spec.\n * `alert` is assertive; `log` and `status` are polite; `marquee` and `timer` are\n * off. Elements with these roles are live regions without explicit `aria-live`.\n */\nconst IMPLICIT_ROLE_POLITENESS: Record<string, LiveRegionPoliteness> = {\n alert: 'assertive',\n log: 'polite',\n marquee: 'off',\n status: 'polite',\n timer: 'off',\n};\nconst LIVE_REGION_SELECTOR =\n '[aria-live], [role=\"alert\"], [role=\"log\"], [role=\"marquee\"], [role=\"status\"], [role=\"timer\"]';\n\nexport interface LiveRegionQueryOptions {\n /** The document to search. Defaults to the global `document`. */\n document?: Document;\n /** Politeness to match via `aria-live` (or implicit role). Defaults to `'polite'`. */\n politeness?: LiveRegionPoliteness;\n /** ARIA role to match (e.g. `'status'`, `'alert'`). Omit to match any role. */\n role?: string;\n /** Root to scope the query. Defaults to `document.body`. */\n root?: ParentNode;\n}\n\n/**\n * Resolves the effective politeness of an element: explicit `aria-live` wins,\n * otherwise falls back to the implicit value from `role=\"status\"`/`role=\"alert\"`.\n * Returns `null` when the element is not a live region.\n */\nfunction resolvePoliteness(el: HTMLElement): LiveRegionPoliteness | null {\n const explicit = el.getAttribute('aria-live');\n\n if (explicit) return explicit as LiveRegionPoliteness;\n\n const role = el.getAttribute('role');\n\n if (role && role in IMPLICIT_ROLE_POLITENESS) return IMPLICIT_ROLE_POLITENESS[role];\n\n return null;\n}\n\nfunction candidates(root: ParentNode): HTMLElement[] {\n const descendants = Array.from(root.querySelectorAll<HTMLElement>(LIVE_REGION_SELECTOR));\n const rootElement = root as ParentNode & { matches?: (selector: string) => boolean };\n\n return rootElement.matches?.(LIVE_REGION_SELECTOR) ? [root as HTMLElement, ...descendants] : descendants;\n}\n\nfunction matchesOptions(element: HTMLElement, politeness: LiveRegionPoliteness, role?: string): boolean {\n return resolvePoliteness(element) === politeness && (role === undefined || element.getAttribute('role') === role);\n}\n\n/**\n * Queries the first live region matching the given politeness (and optional role)\n * within `root`. Returns `null` when none exists — safe to call before the region\n * has been lazily created.\n *\n * Matches explicit `aria-live` attributes and implicit live-region roles.\n *\n * @example\n * const region = queryLiveRegion({ politeness: 'polite' });\n * expect(region).not.toBeNull();\n */\nexport function queryLiveRegion(options: LiveRegionQueryOptions = {}): HTMLElement | null {\n const doc = options.document ?? (typeof document !== 'undefined' ? document : null);\n const politeness = options.politeness ?? 'polite';\n const root = options.root ?? doc?.body ?? null;\n\n if (!root) return null;\n\n return candidates(root).find((element) => matchesOptions(element, politeness, options.role)) ?? null;\n}\n\n/**\n * Queries all live regions matching the given politeness (and optional role)\n * within `root`. Useful for asserting no duplicate regions were created.\n *\n * @example\n * expect(queryAllLiveRegions({ politeness: 'polite' })).toHaveLength(1);\n */\nexport function queryAllLiveRegions(options: LiveRegionQueryOptions = {}): HTMLElement[] {\n const doc = options.document ?? (typeof document !== 'undefined' ? document : null);\n const politeness = options.politeness ?? 'polite';\n const root = options.root ?? doc?.body ?? null;\n\n if (!root) return [];\n\n return candidates(root).filter((element) => matchesOptions(element, politeness, options.role));\n}\n\nexport interface WaitForLiveRegionOptions extends WaitOptions {\n /** The document to search. Defaults to the global `document`. */\n document?: Document;\n /** Politeness to match via `aria-live`. Defaults to `'polite'`. */\n politeness?: LiveRegionPoliteness;\n /** ARIA role to match. Omit to match any role. */\n role?: string;\n /** Root to scope the query. Defaults to `document.body`. */\n root?: ParentNode;\n}\n\n/**\n * Retries until a live region matching the politeness/role exists and contains\n * `text` (substring match). Throws `AssayTimeoutError` on timeout.\n *\n * Handles the clear-then-set announce pattern: the region may briefly be empty\n * before the message is written, so polling until the text appears is the\n * correct approach rather than a single snapshot assertion.\n *\n * @example\n * await waitForLiveRegion('3 results found');\n * await waitForLiveRegion('Session expired', { politeness: 'assertive' });\n */\nexport async function waitForLiveRegion(text: string, options: WaitForLiveRegionOptions = {}): Promise<HTMLElement> {\n const politeness = options.politeness ?? 'polite';\n let matched: HTMLElement | null = null;\n\n await eventually(\n () => {\n const regions = queryAllLiveRegions({\n document: options.document,\n politeness,\n role: options.role,\n root: options.root,\n });\n const region = regions.find((candidate) => candidate.textContent?.includes(text));\n\n if (region) {\n matched = region;\n return;\n }\n\n if (regions.length === 0) throw new AssayQueryError(`No ${politeness} live region found.`);\n throw new AssayQueryError(`No ${politeness} live region includes \"${text}\".`);\n },\n {\n interval: options.interval,\n message: `waitForLiveRegion(\"${text}\")`,\n signal: options.signal,\n timeout: options.timeout,\n },\n );\n\n // `eventually` only resolves once the assertion stops throwing, so `matched` is set.\n return matched!;\n}\n\n/**\n * Retries until a live region matching the politeness/role exists and is empty\n * (cleared). Throws `AssayTimeoutError` on timeout.\n *\n * @example\n * await waitForLiveRegionCleared();\n */\nexport async function waitForLiveRegionCleared(options: WaitForLiveRegionOptions = {}): Promise<void> {\n const politeness = options.politeness ?? 'polite';\n\n await eventually(\n () => {\n const regions = queryAllLiveRegions({\n document: options.document,\n politeness,\n role: options.role,\n root: options.root,\n });\n\n if (regions.some((region) => region.textContent === '')) return;\n if (regions.length === 0) throw new AssayQueryError(`No ${politeness} live region found.`);\n throw new AssayQueryError(`No ${politeness} live region is cleared.`);\n },\n {\n interval: options.interval,\n message: 'waitForLiveRegionCleared',\n signal: options.signal,\n timeout: options.timeout,\n },\n );\n}\n"],"mappings":";;;AAWA,IAAM,IAAiE;CACrE,OAAO;CACP,KAAK;CACL,SAAS;CACT,QAAQ;CACR,OAAO;AACT,GACM,IACJ;AAkBF,SAAS,EAAkB,GAA8C;CACvE,IAAM,IAAW,EAAG,aAAa,WAAW;CAE5C,IAAI,GAAU,OAAO;CAErB,IAAM,IAAO,EAAG,aAAa,MAAM;CAInC,OAFI,KAAQ,KAAQ,IAAi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