@open-pioneer/react-utils 4.9.0-dev.20261002130116 → 4.9.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/CHANGELOG.md CHANGED
@@ -1,13 +1,15 @@
1
1
  # @open-pioneer/react-utils
2
2
 
3
- ## 4.9.0-dev.20261002130116
3
+ ## 4.9.0
4
4
 
5
5
  ### Patch Changes
6
6
 
7
7
  - 6b160f3: Fix three roving menu issues:
8
- - Pressing `End` in a menu whose current item is unknown now moves to the last item instead of the first.
9
- - Keyboard navigation uses `getAttribute("aria-disabled")` to skip disabled nodes instead of reading the `ariaDisabled` property.
10
- - `useRovingMenuItem({ disabled: true })` now returns `itemProps` with `aria-disabled="true"`. Previously the item element had to carry the attribute itself to be skipped during keyboard navigation.
8
+ - Pressing `End` in a menu whose current item is unknown now moves to the last item instead of the first.
9
+ - Keyboard navigation uses `getAttribute("aria-disabled")` to skip disabled nodes instead of reading the `ariaDisabled` property.
10
+ - `useRovingMenuItem({ disabled: true })` now returns `itemProps` with `aria-disabled="true"`. Previously the item element had to carry the attribute itself to be skipped during keyboard navigation.
11
+
12
+ - 42ca366: Update dependencies
11
13
 
12
14
  ## 4.8.0
13
15
 
@@ -38,23 +40,23 @@
38
40
  These components render translated messages using `intl.formatMessage` / `intl.formatRichMessage`
39
41
  and support reactive changes of the `intl` property.
40
42
 
41
- Example:
43
+ Example:
42
44
 
43
- ```tsx
44
- // currentIntl can be a signal
45
- <FormattedMessage intl={currentIntl} id="message.id" />
46
- ```
45
+ ```tsx
46
+ // currentIntl can be a signal
47
+ <FormattedMessage intl={currentIntl} id="message.id" />
48
+ ```
47
49
 
48
50
  - 27f5f1e: Add a new `classnames` function to replace the `classnames` package.
49
51
  - 4b207f4: Added a `required` option to `useHeadingLevel` hook to make it return `undefined` instead of throwing an error when used outside of a `TitledSection`.
50
52
 
51
- This allows to use the hook in components which do not necessarily need to be used inside a `TitledSection`.
53
+ This allows to use the hook in components which do not necessarily need to be used inside a `TitledSection`.
52
54
 
53
- ```tsx
54
- const currentHeading: number | undefined = useHeadingLevel({
55
- required: false,
56
- });
57
- ```
55
+ ```tsx
56
+ const currentHeading: number | undefined = useHeadingLevel({
57
+ required: false
58
+ });
59
+ ```
58
60
 
59
61
  ## 4.5.0
60
62
 
@@ -64,20 +66,20 @@
64
66
  - d523ade: Add more properties to the `CommonComponentProps` interface.
65
67
  Previously, trails components only allowed customizing the `className`.
66
68
 
67
- Now, these additional properties are supported:
68
- - `role`: the ARIA role
69
- - `aria-*`: arbitrary ARIA attributes
70
- - `data-*`: arbitrary JavaScript values
71
- - `css`: additional Chakra style rules
69
+ Now, these additional properties are supported:
70
+ - `role`: the ARIA role
71
+ - `aria-*`: arbitrary ARIA attributes
72
+ - `data-*`: arbitrary JavaScript values
73
+ - `css`: additional Chakra style rules
72
74
 
73
- NOTE: Defining these values may overwrite existing behavior of a component if values cannot be merged.
74
- For example, overriding an existing `data-` property may break a component.
75
+ NOTE: Defining these values may overwrite existing behavior of a component if values cannot be merged.
76
+ For example, overriding an existing `data-` property may break a component.
75
77
 
76
78
  - d523ade: Implement `mergeChakraProps` helper to merge multiple props objects.
77
79
  - 604a589: Provide an implementation of the roving tab index pattern for menus ("Roving Menu").
78
80
  This roving menu can be used to implement accessible menus with support for keyboard navigation.
79
- - Supports plain menus (e.g. toolbars, sidebars, ...)
80
- - Supports simple cases of nesting (horizontal menu in vertical menu, or the other way around)
81
+ - Supports plain menus (e.g. toolbars, sidebars, ...)
82
+ - Supports simple cases of nesting (horizontal menu in vertical menu, or the other way around)
81
83
 
82
84
  ## 4.4.0
83
85
 
@@ -121,22 +123,22 @@
121
123
  - a5177fc: Allow using `SectionHeading` in the children of a `TitledSection` instead of the `title` prop.
122
124
  This is more flexible and more readable compared to complex components in the `title` prop.
123
125
 
124
- For example:
126
+ For example:
125
127
 
126
- ```jsx
127
- <TitledSection>
128
- <SectionHeading>Top level heading (H1)</SectionHeading>
129
- .. Some Content ..
128
+ ```jsx
130
129
  <TitledSection>
131
- <Box backgroundColor="green.500">
132
- <SectionHeading>Other Heading (H2)</SectionHeading>
133
- </Box>
134
- .. More Content ..
130
+ <SectionHeading>Top level heading (H1)</SectionHeading>
131
+ .. Some Content ..
132
+ <TitledSection>
133
+ <Box backgroundColor="green.500">
134
+ <SectionHeading>Other Heading (H2)</SectionHeading>
135
+ </Box>
136
+ .. More Content ..
137
+ </TitledSection>
135
138
  </TitledSection>
136
- </TitledSection>
137
- ```
139
+ ```
138
140
 
139
- Note that you should be using exactly one `<SectionHeading />` for each `<TitledSection />`.
141
+ Note that you should be using exactly one `<SectionHeading />` for each `<TitledSection />`.
140
142
 
141
143
  ### Patch Changes
142
144
 
@@ -156,13 +158,13 @@
156
158
  ### Major Changes
157
159
 
158
160
  - 9477e54: Update dependencies
159
- - React 19
160
- - Vite 6
161
- - FormatJS 3
162
- - Open Pioneer Build Tools
163
- - ...
161
+ - React 19
162
+ - Vite 6
163
+ - FormatJS 3
164
+ - Open Pioneer Build Tools
165
+ - ...
164
166
 
165
- For more details, see https://github.com/open-pioneer/trails-core-packages/pull/81
167
+ For more details, see https://github.com/open-pioneer/trails-core-packages/pull/81
166
168
 
167
169
  ## 2.4.0
168
170
 
@@ -196,14 +198,14 @@
196
198
 
197
199
  - a208b32: **Breaking:** Removed the `ToolButton` component; it has moved to `@open-pioneer/map-ui-components`.
198
200
 
199
- If you were previously using the `ToolButton` in your app, you need to update your import statements when updating to this version:
201
+ If you were previously using the `ToolButton` in your app, you need to update your import statements when updating to this version:
200
202
 
201
- ```diff
202
- - import { ToolButton } from "@open-pioneer/react-utils";
203
- + import { ToolButton } from "@open-pioneer/map-ui-components";
204
- ```
203
+ ```diff
204
+ - import { ToolButton } from "@open-pioneer/react-utils";
205
+ + import { ToolButton } from "@open-pioneer/map-ui-components";
206
+ ```
205
207
 
206
- You need to update your `package.json` as well to refer to the `map-ui-components` package.
208
+ You need to update your `package.json` as well to refer to the `map-ui-components` package.
207
209
 
208
210
  ### Minor Changes
209
211
 
@@ -219,13 +221,13 @@
219
221
  - 2c092dc: Update dependencies
220
222
  - 4140646: Add `sectionHeadingProps` to configure the generated `<SectionHeading>` if `title` is a string.
221
223
 
222
- For example:
224
+ For example:
223
225
 
224
- ```tsx
225
- <TitledSection title="some title" sectionHeadingProps={{ size: "lg" }}>
226
- ... Titled content ...
227
- </TitledSection>
228
- ```
226
+ ```tsx
227
+ <TitledSection title="some title" sectionHeadingProps={{ size: "lg" }}>
228
+ ... Titled content ...
229
+ </TitledSection>
230
+ ```
229
231
 
230
232
  ## 0.2.2
231
233
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@open-pioneer/react-utils",
4
- "version": "4.9.0-dev.20261002130116",
4
+ "version": "4.9.0",
5
5
  "description": "Contains common react utilities used by the open pioneer trails project",
6
6
  "keywords": [
7
7
  "open-pioneer-trails"
@@ -15,10 +15,10 @@
15
15
  },
16
16
  "dependencies": {
17
17
  "@chakra-ui/react": "^3.37.0",
18
- "@conterra/reactivity-core": "^0.8.8",
19
- "@open-pioneer/core": "4.9.0-dev.20261002130116",
20
- "@open-pioneer/reactivity": "4.9.0-dev.20261002130116",
21
- "react": "^19.3.0"
18
+ "@conterra/reactivity-core": "^0.8.9",
19
+ "@open-pioneer/core": "4.9.0",
20
+ "@open-pioneer/reactivity": "4.9.0",
21
+ "react": "^19.3.1"
22
22
  },
23
23
  "publishConfig": {
24
24
  "directory": "dist",
@@ -34,18 +34,15 @@ function useRovingMenuImpl(props, isActiveInParent) {
34
34
  const menuRef = useRef(null);
35
35
  const initialActive = useRef(active);
36
36
  const state = useMemo(
37
- () => (
37
+ () => new InternalMenuState({
38
+ menuId,
39
+ orientation,
40
+ menuRef,
41
+ wrap,
38
42
  // oxlint-disable-next-line react/refs
39
- new InternalMenuState({
40
- menuId,
41
- orientation,
42
- menuRef,
43
- wrap,
44
- // oxlint-disable-next-line react/refs
45
- active: initialActive.current,
46
- isActiveInParent
47
- })
48
- ),
43
+ active: initialActive.current,
44
+ isActiveInParent
45
+ }),
49
46
  [menuRef, orientation, menuId, wrap, isActiveInParent]
50
47
  );
51
48
  useEffect(() => {
@@ -1 +1 @@
1
- {"version":3,"file":"useRovingMenu.js","sources":["useRovingMenu.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n KeyboardEvent,\n FocusEvent,\n RefObject,\n useCallback,\n useId,\n useMemo,\n useRef,\n useEffect\n} from \"react\";\nimport { useEvent } from \"../useEvent\";\n// oxlint-disable-next-line @typescript-eslint/no-unused-vars\nimport { type RovingMenuRoot } from \"./RovingMenuRoot\";\nimport { InternalMenuState, MENU_ID_ATTR, RovingMenuState } from \"./RovingMenuState\";\nimport { useMenuState } from \"./useMenuState\";\nimport { RovingMenuItemDomProps, useRovingMenuItemImpl } from \"./useRovingMenuItem\";\n\n/**\n * Properties supported when creating a new menu via {@link useRovingMenu}.\n *\n * @group Roving menu\n */\nexport interface RovingMenuProps {\n /**\n * Configures the orientation of the menu (default: `horizontal`).\n *\n * Horizontal menus can be navigated using left/right, vertical menus use up/down.\n */\n orientation?: \"vertical\" | \"horizontal\";\n\n /**\n * Wrap around when pressing an arrow key at the start or the end of the menu.\n *\n * Default: `true`.\n */\n wrap?: boolean;\n\n /**\n * Whether the menu is active.\n * Only active menus are focusable by the user through keyboard navigation.\n *\n * Default: `true`\n */\n active?: boolean;\n}\n\n/** @internal */\nexport interface RovingMenuDomProps {\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n ref: RefObject<any>;\n role: string;\n tabIndex: number;\n [MENU_ID_ATTR]: string;\n \"aria-orientation\": \"horizontal\" | \"vertical\";\n onKeyDown: (event: KeyboardEvent) => void;\n onFocus: (event: FocusEvent) => void;\n}\n\n/**\n * The return value of {@link useRovingMenu}.\n *\n * @group Roving menu\n */\nexport interface RovingMenuResult {\n /**\n * DOM-Properties that must be applied to the menu's dom element.\n *\n * Note that other properties may be added in a future release.\n */\n menuProps: RovingMenuDomProps;\n\n /**\n * Properties that should be passed to the {@link RovingMenuRoot}.\n *\n * The specific internals of this object are an implementation detail.\n */\n menuState: RovingMenuState;\n}\n\n/**\n * The roving menu is a render-less component for lists that support keyboard navigation.\n * It implements the basics for an accessible, keyboard navigable menu using the \"roving tab index\" pattern.\n *\n * Items can be navigated using arrow keys and home/end keys.\n *\n * @group Roving menu\n * @expandType RovingMenuProps\n */\nexport function useRovingMenu(props: RovingMenuProps = {}): RovingMenuResult {\n return useRovingMenuImpl(props);\n}\n\n/**\n * Properties supported when creating a new nested menu via {@link useNestedRovingMenu}.\n *\n * @group Roving menu\n */\nexport interface NestedRovingMenuProps extends RovingMenuProps {\n /**\n * The value of the menu within its parent menu.\n */\n value: string;\n}\n\n/**\n * The return value of {@link useNestedRovingMenu}.\n *\n * @group Roving menu\n */\nexport interface NestedRovingMenuResult extends RovingMenuResult {\n menuProps: RovingMenuDomProps & RovingMenuItemDomProps;\n}\n\n/**\n * Like {@link useRovingMenu}, but suitable for nested menus.\n *\n * Only a single level of nesting is supported at this time (i.e. horizontal in vertical, or the other way around).\n *\n * @group Roving menu\n * @expandType NestedRovingMenuProps\n */\nexport function useNestedRovingMenu(props: NestedRovingMenuProps): NestedRovingMenuResult {\n const parentMenuState = useMenuState();\n const { menuProps, menuState } = useRovingMenuImpl(\n props,\n useCallback(() => parentMenuState.isActive(props.value), [parentMenuState, props.value])\n );\n const { itemProps } = useRovingMenuItemImpl(props, \"nested\");\n\n return useMemo(() => {\n return {\n menuProps: {\n ...menuProps,\n ...itemProps,\n onFocus(e: FocusEvent) {\n // Tracks active state in parent\n itemProps.onFocus(e);\n\n // Focuses the correct child\n menuProps.onFocus(e);\n }\n },\n menuState\n };\n }, [menuProps, menuState, itemProps]);\n}\n\nfunction useRovingMenuImpl(\n props: RovingMenuProps,\n isActiveInParent?: () => boolean\n): RovingMenuResult {\n const { orientation = \"horizontal\", active = true, wrap = true } = props;\n const menuId = useId();\n const menuRef = useRef<HTMLElement>(null);\n\n const initialActive = useRef(active);\n\n // Shared state between items and root\n const state = useMemo(\n () =>\n // oxlint-disable-next-line react/refs\n new InternalMenuState({\n menuId,\n orientation,\n menuRef,\n wrap,\n // oxlint-disable-next-line react/refs\n active: initialActive.current,\n isActiveInParent\n }),\n [menuRef, orientation, menuId, wrap, isActiveInParent]\n );\n\n // Fine grained updates without losing state\n useEffect(() => {\n state.active = active;\n }, [state, active]);\n\n const onKeyDown = useEvent((event: KeyboardEvent) => {\n state.onKeyDown(event);\n });\n const onFocus = useEvent((event: FocusEvent) => {\n state.onFocus(event);\n });\n const result = useMemo(\n (): RovingMenuResult => ({\n menuProps: {\n ref: menuRef,\n role: \"toolbar\",\n \"aria-orientation\": orientation,\n tabIndex: -1,\n [MENU_ID_ATTR]: menuId,\n onKeyDown,\n onFocus\n },\n menuState: state as unknown as RovingMenuState\n }),\n [menuId, orientation, onKeyDown, onFocus, state]\n );\n return result;\n}\n"],"names":[],"mappings":";;;;;;AA2FO,SAAS,aAAA,CAAc,KAAA,GAAyB,EAAC,EAAqB;AACzE,EAAA,OAAO,kBAAkB,KAAK,CAAA;AAClC;AA+BO,SAAS,oBAAoB,KAAA,EAAsD;AACtF,EAAA,MAAM,kBAAkB,YAAA,EAAa;AACrC,EAAA,MAAM,EAAE,SAAA,EAAW,SAAA,EAAU,GAAI,iBAAA;AAAA,IAC7B,KAAA;AAAA,IACA,WAAA,CAAY,MAAM,eAAA,CAAgB,QAAA,CAAS,KAAA,CAAM,KAAK,CAAA,EAAG,CAAC,eAAA,EAAiB,KAAA,CAAM,KAAK,CAAC;AAAA,GAC3F;AACA,EAAA,MAAM,EAAE,SAAA,EAAU,GAAI,qBAAA,CAAsB,OAAO,QAAQ,CAAA;AAE3D,EAAA,OAAO,QAAQ,MAAM;AACjB,IAAA,OAAO;AAAA,MACH,SAAA,EAAW;AAAA,QACP,GAAG,SAAA;AAAA,QACH,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;AACD,EAAA,MAAM,MAAA,GAAS,OAAA;AAAA,IACX,OAAyB;AAAA,MACrB,SAAA,EAAW;AAAA,QACP,GAAA,EAAK,OAAA;AAAA,QACL,IAAA,EAAM,SAAA;AAAA,QACN,kBAAA,EAAoB,WAAA;AAAA,QACpB,QAAA,EAAU,EAAA;AAAA,QACV,CAAC,YAAY,GAAG,MAAA;AAAA,QAChB,SAAA;AAAA,QACA;AAAA,OACJ;AAAA,MACA,SAAA,EAAW;AAAA,KACf,CAAA;AAAA,IACA,CAAC,MAAA,EAAQ,WAAA,EAAa,SAAA,EAAW,SAAS,KAAK;AAAA,GACnD;AACA,EAAA,OAAO,MAAA;AACX;;"}
1
+ {"version":3,"file":"useRovingMenu.js","sources":["useRovingMenu.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n KeyboardEvent,\n FocusEvent,\n RefObject,\n useCallback,\n useId,\n useMemo,\n useRef,\n useEffect\n} from \"react\";\nimport { useEvent } from \"../useEvent\";\n// oxlint-disable-next-line @typescript-eslint/no-unused-vars\nimport { type RovingMenuRoot } from \"./RovingMenuRoot\";\nimport { InternalMenuState, MENU_ID_ATTR, RovingMenuState } from \"./RovingMenuState\";\nimport { useMenuState } from \"./useMenuState\";\nimport { RovingMenuItemDomProps, useRovingMenuItemImpl } from \"./useRovingMenuItem\";\n\n/**\n * Properties supported when creating a new menu via {@link useRovingMenu}.\n *\n * @group Roving menu\n */\nexport interface RovingMenuProps {\n /**\n * Configures the orientation of the menu (default: `horizontal`).\n *\n * Horizontal menus can be navigated using left/right, vertical menus use up/down.\n */\n orientation?: \"vertical\" | \"horizontal\";\n\n /**\n * Wrap around when pressing an arrow key at the start or the end of the menu.\n *\n * Default: `true`.\n */\n wrap?: boolean;\n\n /**\n * Whether the menu is active.\n * Only active menus are focusable by the user through keyboard navigation.\n *\n * Default: `true`\n */\n active?: boolean;\n}\n\n/** @internal */\nexport interface RovingMenuDomProps {\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n ref: RefObject<any>;\n role: string;\n tabIndex: number;\n [MENU_ID_ATTR]: string;\n \"aria-orientation\": \"horizontal\" | \"vertical\";\n onKeyDown: (event: KeyboardEvent) => void;\n onFocus: (event: FocusEvent) => void;\n}\n\n/**\n * The return value of {@link useRovingMenu}.\n *\n * @group Roving menu\n */\nexport interface RovingMenuResult {\n /**\n * DOM-Properties that must be applied to the menu's dom element.\n *\n * Note that other properties may be added in a future release.\n */\n menuProps: RovingMenuDomProps;\n\n /**\n * Properties that should be passed to the {@link RovingMenuRoot}.\n *\n * The specific internals of this object are an implementation detail.\n */\n menuState: RovingMenuState;\n}\n\n/**\n * The roving menu is a render-less component for lists that support keyboard navigation.\n * It implements the basics for an accessible, keyboard navigable menu using the \"roving tab index\" pattern.\n *\n * Items can be navigated using arrow keys and home/end keys.\n *\n * @group Roving menu\n * @expandType RovingMenuProps\n */\nexport function useRovingMenu(props: RovingMenuProps = {}): RovingMenuResult {\n return useRovingMenuImpl(props);\n}\n\n/**\n * Properties supported when creating a new nested menu via {@link useNestedRovingMenu}.\n *\n * @group Roving menu\n */\nexport interface NestedRovingMenuProps extends RovingMenuProps {\n /**\n * The value of the menu within its parent menu.\n */\n value: string;\n}\n\n/**\n * The return value of {@link useNestedRovingMenu}.\n *\n * @group Roving menu\n */\nexport interface NestedRovingMenuResult extends RovingMenuResult {\n menuProps: RovingMenuDomProps & RovingMenuItemDomProps;\n}\n\n/**\n * Like {@link useRovingMenu}, but suitable for nested menus.\n *\n * Only a single level of nesting is supported at this time (i.e. horizontal in vertical, or the other way around).\n *\n * @group Roving menu\n * @expandType NestedRovingMenuProps\n */\nexport function useNestedRovingMenu(props: NestedRovingMenuProps): NestedRovingMenuResult {\n const parentMenuState = useMenuState();\n const { menuProps, menuState } = useRovingMenuImpl(\n props,\n useCallback(() => parentMenuState.isActive(props.value), [parentMenuState, props.value])\n );\n const { itemProps } = useRovingMenuItemImpl(props, \"nested\");\n\n return useMemo(() => {\n return {\n menuProps: {\n ...menuProps,\n ...itemProps,\n onFocus(e: FocusEvent) {\n // Tracks active state in parent\n itemProps.onFocus(e);\n\n // Focuses the correct child\n menuProps.onFocus(e);\n }\n },\n menuState\n };\n }, [menuProps, menuState, itemProps]);\n}\n\nfunction useRovingMenuImpl(\n props: RovingMenuProps,\n isActiveInParent?: () => boolean\n): RovingMenuResult {\n const { orientation = \"horizontal\", active = true, wrap = true } = props;\n const menuId = useId();\n const menuRef = useRef<HTMLElement>(null);\n\n const initialActive = useRef(active);\n\n // Shared state between items and root\n const state = useMemo(\n () =>\n new InternalMenuState({\n menuId,\n orientation,\n menuRef,\n wrap,\n // oxlint-disable-next-line react/refs\n active: initialActive.current,\n isActiveInParent\n }),\n [menuRef, orientation, menuId, wrap, isActiveInParent]\n );\n\n // Fine grained updates without losing state\n useEffect(() => {\n state.active = active;\n }, [state, active]);\n\n const onKeyDown = useEvent((event: KeyboardEvent) => {\n state.onKeyDown(event);\n });\n const onFocus = useEvent((event: FocusEvent) => {\n state.onFocus(event);\n });\n const result = useMemo(\n (): RovingMenuResult => ({\n menuProps: {\n ref: menuRef,\n role: \"toolbar\",\n \"aria-orientation\": orientation,\n tabIndex: -1,\n [MENU_ID_ATTR]: menuId,\n onKeyDown,\n onFocus\n },\n menuState: state as unknown as RovingMenuState\n }),\n [menuId, orientation, onKeyDown, onFocus, state]\n );\n return result;\n}\n"],"names":[],"mappings":";;;;;;AA2FO,SAAS,aAAA,CAAc,KAAA,GAAyB,EAAC,EAAqB;AACzE,EAAA,OAAO,kBAAkB,KAAK,CAAA;AAClC;AA+BO,SAAS,oBAAoB,KAAA,EAAsD;AACtF,EAAA,MAAM,kBAAkB,YAAA,EAAa;AACrC,EAAA,MAAM,EAAE,SAAA,EAAW,SAAA,EAAU,GAAI,iBAAA;AAAA,IAC7B,KAAA;AAAA,IACA,WAAA,CAAY,MAAM,eAAA,CAAgB,QAAA,CAAS,KA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