@open-pioneer/toc 0.9.0 → 0.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,38 @@
1
1
  # @open-pioneer/toc
2
2
 
3
+ ## 0.10.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 193068a: Deprecate the `mapId` property on React components.
8
+ Use the `MapModel` directly instead to pass a reference to the map.
9
+
10
+ Example:
11
+
12
+ ```tsx
13
+ // Default map for entire component tree
14
+ <DefaultMapProvider map={mapModel}>
15
+ <Toc />
16
+ </DefaultMapProvider>
17
+
18
+ // Map for specific component
19
+ <Toc map={mapModel} />
20
+ ```
21
+
22
+ ### Patch Changes
23
+
24
+ - cd1435b: Update ol to 10.5.0
25
+ - 032eed7: Bump dependencies.
26
+ - cd1435b: Update to react 19.1.0
27
+ - Updated dependencies [2bafdad]
28
+ - Updated dependencies [cd1435b]
29
+ - Updated dependencies [193068a]
30
+ - Updated dependencies [032eed7]
31
+ - Updated dependencies [cd1435b]
32
+ - Updated dependencies [7558df4]
33
+ - @open-pioneer/map@0.10.0
34
+ - @open-pioneer/basemap-switcher@0.10.0
35
+
3
36
  ## 0.9.0
4
37
 
5
38
  ### Minor Changes
package/README.md CHANGED
@@ -6,10 +6,12 @@ Unavailable operational layers are marked with an icon and will be deactivated f
6
6
 
7
7
  ## Usage
8
8
 
9
- To integrate the TOC (table of contents) in your app, insert the following snippet and reference a map ID:
9
+ To integrate the TOC (table of contents) in your app, insert the following snippet (and reference a map):
10
10
 
11
11
  ```tsx
12
- <Toc mapId="map_id" />
12
+ <Toc
13
+ map={map}
14
+ /> /* instead of passing the map, the `DefaultMapProvider` can alternatively be used */
13
15
  ```
14
16
 
15
17
  ### Tools
@@ -18,7 +20,7 @@ Additional tools are available for operational layers.
18
20
  To show the toolset menu, set the `showTools` property to `true`.
19
21
 
20
22
  ```tsx
21
- <Toc mapId="map_id" showTools={true} />
23
+ <Toc map={map} showTools={true} />
22
24
  ```
23
25
 
24
26
  The default tools provided by the TOC are:
@@ -35,14 +37,14 @@ By default, the TOC shows the basemap switcher as an embedded element.
35
37
  To hide the basemap switcher, set the `showBasemapSwitcher` property to `false`:
36
38
 
37
39
  ```tsx
38
- <Toc mapId="map_id" showBasemapSwitcher={false} />
40
+ <Toc map={map} showBasemapSwitcher={false} />
39
41
  ```
40
42
 
41
43
  To configure the embedded basemap switcher, use the `basemapSwitcherProps` property:
42
44
 
43
45
  ```tsx
44
46
  <Toc
45
- mapId="map_id"
47
+ map={map}
46
48
  basemapSwitcherProps={{
47
49
  allowSelectingEmptyBasemap: true
48
50
  }}
@@ -84,7 +86,7 @@ If enabled, a toggle button appears next to parent nodes by which the user can e
84
86
 
85
87
  ```tsx
86
88
  <Toc
87
- mapId={MAP_ID}
89
+ map={map}
88
90
  collapsibleGroups={true}
89
91
  initiallyCollapsed={true} // Whether groups are collapsed by default. Defaults to false.
90
92
  />
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@open-pioneer/toc",
4
- "version": "0.9.0",
4
+ "version": "0.10.0",
5
5
  "description": "This package provides a UI component that displays the map content to the user and allows them to control it.",
6
6
  "keywords": [
7
7
  "open-pioneer-trails"
@@ -14,18 +14,18 @@
14
14
  "directory": "src/packages/toc"
15
15
  },
16
16
  "dependencies": {
17
- "@open-pioneer/chakra-integration": "^3.0.0",
18
- "@open-pioneer/react-utils": "^3.0.0",
19
- "@open-pioneer/runtime": "^3.0.0",
17
+ "@open-pioneer/chakra-integration": "^3.1.0",
18
+ "@open-pioneer/react-utils": "^3.1.0",
19
+ "@open-pioneer/runtime": "^3.1.0",
20
20
  "classnames": "^2.3.2",
21
- "ol": "^10.4.0",
22
- "react": "^19.0.0",
21
+ "ol": "^10.5.0",
22
+ "react": "^19.1.0",
23
23
  "react-icons": "^5.3.0",
24
24
  "@chakra-ui/icons": "^2.2.4",
25
- "@open-pioneer/reactivity": "^3.0.0",
26
- "@conterra/reactivity-core": "^0.4.3",
27
- "@open-pioneer/basemap-switcher": "^0.9.0",
28
- "@open-pioneer/map": "^0.9.0"
25
+ "@open-pioneer/reactivity": "^3.1.0",
26
+ "@conterra/reactivity-core": "^0.5.0",
27
+ "@open-pioneer/basemap-switcher": "^0.10.0",
28
+ "@open-pioneer/map": "^0.10.0"
29
29
  },
30
30
  "exports": {
31
31
  "./package.json": "./package.json",
package/ui/Toc.d.ts CHANGED
@@ -25,7 +25,7 @@ export interface TocProps extends CommonComponentProps, MapModelProps {
25
25
  /**
26
26
  * Properties for the embedded basemap switcher.
27
27
  *
28
- * Property `mapId` is not applied (the basemap switcher uses the same map as the).
28
+ * Property `mapId` is not applied (the basemap switcher uses the same map as the toc).
29
29
  */
30
30
  basemapSwitcherProps?: Omit<BasemapSwitcherProps, "mapId">;
31
31
  /**
@@ -38,7 +38,7 @@ export interface TocProps extends CommonComponentProps, MapModelProps {
38
38
  /**
39
39
  * If `true` groups in the toc are collapsed initially.
40
40
  *
41
- * Defaults to `false`. If {@link collapsibleGroups} is `false` this property should also be `false`. Otherwise only the top level layers will appear in the toc.
41
+ * Defaults to `false`. If {@link collapsibleGroups} is `false` this property should also be `false`. Otherwise, only the top level layers will appear in the toc.
42
42
  */
43
43
  initiallyCollapsed?: boolean;
44
44
  /**
package/ui/Toc.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Toc.js","sources":["Toc.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { reactive, reactiveMap } from \"@conterra/reactivity-core\";\nimport { BasemapSwitcher, BasemapSwitcherProps } from \"@open-pioneer/basemap-switcher\";\nimport { Box, Flex, Spacer, Text } from \"@open-pioneer/chakra-integration\";\nimport { MapModel, MapModelProps, useMapModel } from \"@open-pioneer/map\";\nimport {\n CommonComponentProps,\n SectionHeading,\n TitledSection,\n useCommonComponentProps\n} from \"@open-pioneer/react-utils\";\nimport { useIntl } from \"open-pioneer:react-hooks\";\nimport { FC, ReactNode, useEffect, useId, useMemo, useRef } from \"react\";\nimport { TocItem, TocModel, TocModelProvider, TocWidgetOptions } from \"../model/TocModel\";\nimport { TopLevelLayerList } from \"./LayerList/LayerList\";\nimport { Tools } from \"./Tools\";\n\n/**\n * Props supported by the {@link Toc} component.\n */\nexport interface TocProps extends CommonComponentProps, MapModelProps {\n /**\n * Defines whether the tool component is shown in the toc.\n *\n * Defaults to `false`.\n */\n showTools?: boolean;\n\n /**\n * Properties for the embedded tool component.\n */\n toolsConfig?: ToolsConfig;\n\n /**\n * Defines whether the basemap switcher is shown in the toc.\n *\n * Defaults to `true`.\n */\n showBasemapSwitcher?: boolean;\n\n /**\n * Properties for the embedded basemap switcher.\n *\n * Property `mapId` is not applied (the basemap switcher uses the same map as the).\n */\n basemapSwitcherProps?: Omit<BasemapSwitcherProps, \"mapId\">;\n\n /**\n * If `true`, groups in the toc can be collapsed and expanded.\n * This property should only be `true` if the map actually contains layer groups.\n *\n * Defaults to `false`.\n */\n collapsibleGroups?: boolean;\n\n /**\n * If `true` groups in the toc are collapsed initially.\n *\n * Defaults to `false`. If {@link collapsibleGroups} is `false` this property should also be `false`. Otherwise only the top level layers will appear in the toc.\n */\n initiallyCollapsed?: boolean;\n\n /**\n * Show the parent layers when a child layer is made visible.\n *\n * Defaults to `true`.\n */\n autoShowParents?: boolean;\n}\n\n/**\n * Props supported by the {@link Tools} component.\n */\nexport interface ToolsConfig {\n /**\n * Optional property to show the `hide all layers` entry.\n *\n * Defaults to `true`.\n */\n showHideAllLayers?: boolean;\n\n /**\n * Optional property to show the `collapse all groups` entry.\n *\n * Defaults to `true`. Only applicable if {@link TocProps.collapsibleGroups} is `true`.\n */\n showCollapseAllGroups?: boolean;\n}\n\nconst PADDING = 2;\n\n/**\n * Displays the layers of the configured map.\n */\nexport const Toc: FC<TocProps> = (props: TocProps) => {\n const intl = useIntl();\n const { containerProps } = useCommonComponentProps(\"toc\", props);\n const state = useMapModel(props);\n\n let content: ReactNode | null;\n switch (state.kind) {\n case \"loading\":\n content = null;\n break;\n case \"rejected\":\n content = <Text className=\"toc-error\">{intl.formatMessage({ id: \"error\" })}</Text>;\n break;\n case \"resolved\": {\n const map = state.map;\n content = <TocContent {...props} map={map} />;\n break;\n }\n }\n\n return (\n <Flex {...containerProps} direction=\"column\" gap={PADDING}>\n {content}\n </Flex>\n );\n};\n\n/** This component is rendered once we have a reference to the loaded map model. */\nfunction TocContent(props: TocProps & { map: MapModel }) {\n const {\n map,\n showTools = false,\n toolsConfig,\n showBasemapSwitcher = true,\n basemapSwitcherProps\n } = props;\n const intl = useIntl();\n const model = useTocModel(props);\n const basemapsHeadingId = useId();\n const basemapSwitcher = showBasemapSwitcher && (\n <Box className=\"toc-basemap-switcher\">\n <TitledSection\n title={\n <SectionHeading id={basemapsHeadingId} size={\"sm\"} mb={PADDING}>\n {intl.formatMessage({ id: \"basemapsLabel\" })}\n </SectionHeading>\n }\n >\n <BasemapSwitcher\n map={map}\n aria-labelledby={basemapsHeadingId}\n {...basemapSwitcherProps}\n />\n </TitledSection>\n </Box>\n );\n\n const layerList = (\n <Box className=\"toc-operational-layers\">\n <TitledSection\n title={\n <SectionHeading size={\"sm\"} mb={2}>\n <Flex>\n <Text my={3}>\n {intl.formatMessage({\n id: \"operationalLayerLabel\"\n })}\n </Text>\n <Spacer />\n {showTools && <Tools map={map} {...toolsConfig} />}\n </Flex>\n </SectionHeading>\n }\n >\n <TopLevelLayerList\n map={map}\n aria-label={intl.formatMessage({ id: \"operationalLayerLabel\" })}\n />\n </TitledSection>\n </Box>\n );\n\n return (\n <TocModelProvider value={model}>\n {basemapSwitcher}\n {layerList}\n </TocModelProvider>\n );\n}\n\nfunction useTocModel(props: TocProps): TocModel {\n const initialProps = useRef(props);\n const { model, options } = useMemo(() => {\n const options = reactive<TocWidgetOptions>(\n createOptions(\n initialProps.current.autoShowParents,\n initialProps.current.collapsibleGroups,\n initialProps.current.initiallyCollapsed\n )\n );\n\n // Indexed by layerId\n const items = reactiveMap<string, TocItem>();\n const model: TocModel = {\n get options() {\n return options.value;\n },\n getItem(layerId: string): TocItem | undefined {\n return items.get(layerId);\n },\n getItems(): TocItem[] {\n return Array.from(items.values());\n },\n registerItem(item: TocItem): void {\n if (items.has(item.layerId)) {\n throw new Error(`Item with layerId '${item.layerId}' already registered.`);\n }\n items.set(item.layerId, item);\n },\n unregisterItem(item: TocItem): void {\n if (items.get(item.layerId) !== item) {\n throw new Error(`Item with layerId '${item.layerId}' not registered.`);\n }\n items.delete(item.layerId);\n }\n };\n return { model, options };\n }, []);\n\n // Sync props to model\n useEffect(() => {\n options.value = createOptions(\n props.autoShowParents,\n props.collapsibleGroups,\n props.initiallyCollapsed\n );\n }, [options, props.autoShowParents, props.collapsibleGroups, props.initiallyCollapsed]);\n\n return model;\n}\n\nfunction createOptions(\n autoShowParents?: boolean | undefined,\n collapsibleGroups?: boolean | undefined,\n isCollapsed?: boolean | undefined\n): TocWidgetOptions {\n return {\n autoShowParents: autoShowParents ?? true,\n collapsibleGroups: collapsibleGroups ?? false,\n initiallyCollapsed: isCollapsed ?? false\n };\n}\n"],"names":["options","model"],"mappings":";;;;;;;;;;;;AA0FA,MAAM,OAAU,GAAA,CAAA;AAKH,MAAA,GAAA,GAAoB,CAAC,KAAoB,KAAA;AAClD,EAAA,MAAM,OAAO,OAAQ,EAAA;AACrB,EAAA,MAAM,EAAE,cAAA,EAAmB,GAAA,uBAAA,CAAwB,OAAO,KAAK,CAAA;AAC/D,EAAM,MAAA,KAAA,GAAQ,YAAY,KAAK,CAAA;AAE/B,EAAI,IAAA,OAAA;AACJ,EAAA,QAAQ,MAAM,IAAM;AAAA,IAChB,KAAK,SAAA;AACD,MAAU,OAAA,GAAA,IAAA;AACV,MAAA;AAAA,IACJ,KAAK,UAAA;AACD,MAAU,OAAA,mBAAA,GAAA,CAAC,IAAK,EAAA,EAAA,SAAA,EAAU,WAAa,EA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A,KAAA,CAAM,iBAAiB,KAAM,CAAA,iBAAA,EAAmB,KAAM,CAAA,kBAAkB,CAAC,CAAA;AAEtF,EAAO,OAAA,KAAA;AACX;AAEA,SAAS,aAAA,CACL,eACA,EAAA,iBAAA,EACA,WACgB,EAAA;AAChB,EAAO,OAAA;AAAA,IACH,iBAAiB,eAAmB,IAAA,IAAA;AAAA,IACpC,mBAAmB,iBAAqB,IAAA,KAAA;AAAA,IACxC,oBAAoB,WAAe,IAAA;AAAA,GACvC;AACJ;;;;"}
1
+ {"version":3,"file":"Toc.js","sources":["Toc.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { reactive, reactiveMap } from \"@conterra/reactivity-core\";\nimport { BasemapSwitcher, BasemapSwitcherProps } from \"@open-pioneer/basemap-switcher\";\nimport { Box, Flex, Spacer, Text } from \"@open-pioneer/chakra-integration\";\nimport { MapModel, MapModelProps, useMapModel } from \"@open-pioneer/map\";\nimport {\n CommonComponentProps,\n SectionHeading,\n TitledSection,\n useCommonComponentProps\n} from \"@open-pioneer/react-utils\";\nimport { useIntl } from \"open-pioneer:react-hooks\";\nimport { FC, ReactNode, useEffect, useId, useMemo, useRef } from \"react\";\nimport { TocItem, TocModel, TocModelProvider, TocWidgetOptions } from \"../model/TocModel\";\nimport { TopLevelLayerList } from \"./LayerList/LayerList\";\nimport { Tools } from \"./Tools\";\n\n/**\n * Props supported by the {@link Toc} component.\n */\nexport interface TocProps extends CommonComponentProps, MapModelProps {\n /**\n * Defines whether the tool component is shown in the toc.\n *\n * Defaults to `false`.\n */\n showTools?: boolean;\n\n /**\n * Properties for the embedded tool component.\n */\n toolsConfig?: ToolsConfig;\n\n /**\n * Defines whether the basemap switcher is shown in the toc.\n *\n * Defaults to `true`.\n */\n showBasemapSwitcher?: boolean;\n\n /**\n * Properties for the embedded basemap switcher.\n *\n * Property `mapId` is not applied (the basemap switcher uses the same map as the toc).\n */\n basemapSwitcherProps?: Omit<BasemapSwitcherProps, \"mapId\">;\n\n /**\n * If `true`, groups in the toc can be collapsed and expanded.\n * This property should only be `true` if the map actually contains layer groups.\n *\n * Defaults to `false`.\n */\n collapsibleGroups?: boolean;\n\n /**\n * If `true` groups in the toc are collapsed initially.\n *\n * Defaults to `false`. If {@link collapsibleGroups} is `false` this property should also be `false`. Otherwise, only the top level layers will appear in the toc.\n */\n initiallyCollapsed?: boolean;\n\n /**\n * Show the parent layers when a child layer is made visible.\n *\n * Defaults to `true`.\n */\n autoShowParents?: boolean;\n}\n\n/**\n * Props supported by the {@link Tools} component.\n */\nexport interface ToolsConfig {\n /**\n * Optional property to show the `hide all layers` entry.\n *\n * Defaults to `true`.\n */\n showHideAllLayers?: boolean;\n\n /**\n * Optional property to show the `collapse all groups` entry.\n *\n * Defaults to `true`. Only applicable if {@link TocProps.collapsibleGroups} is `true`.\n */\n showCollapseAllGroups?: boolean;\n}\n\nconst PADDING = 2;\n\n/**\n * Displays the layers of the configured map.\n */\nexport const Toc: FC<TocProps> = (props: TocProps) => {\n const intl = useIntl();\n const { containerProps } = useCommonComponentProps(\"toc\", props);\n const state = useMapModel(props);\n\n let content: ReactNode | null;\n switch (state.kind) {\n case \"loading\":\n content = null;\n break;\n case \"rejected\":\n content = <Text className=\"toc-error\">{intl.formatMessage({ id: \"error\" })}</Text>;\n break;\n case \"resolved\": {\n const map = state.map;\n content = <TocContent {...props} map={map} />;\n break;\n }\n }\n\n return (\n <Flex {...containerProps} direction=\"column\" gap={PADDING}>\n {content}\n </Flex>\n );\n};\n\n/** This component is rendered once we have a reference to the loaded map model. */\nfunction TocContent(props: TocProps & { map: MapModel }) {\n const {\n map,\n showTools = false,\n toolsConfig,\n showBasemapSwitcher = true,\n basemapSwitcherProps\n } = props;\n const intl = useIntl();\n const model = useTocModel(props);\n const basemapsHeadingId = useId();\n const basemapSwitcher = showBasemapSwitcher && (\n <Box className=\"toc-basemap-switcher\">\n <TitledSection\n title={\n <SectionHeading id={basemapsHeadingId} size={\"sm\"} mb={PADDING}>\n {intl.formatMessage({ id: \"basemapsLabel\" })}\n </SectionHeading>\n }\n >\n <BasemapSwitcher\n map={map}\n aria-labelledby={basemapsHeadingId}\n {...basemapSwitcherProps}\n />\n </TitledSection>\n </Box>\n );\n\n const layerList = (\n <Box className=\"toc-operational-layers\">\n <TitledSection\n title={\n <SectionHeading size={\"sm\"} mb={2}>\n <Flex>\n <Text my={3}>\n {intl.formatMessage({\n id: \"operationalLayerLabel\"\n })}\n </Text>\n <Spacer />\n {showTools && <Tools map={map} {...toolsConfig} />}\n </Flex>\n </SectionHeading>\n }\n >\n <TopLevelLayerList\n map={map}\n aria-label={intl.formatMessage({ id: \"operationalLayerLabel\" })}\n />\n </TitledSection>\n </Box>\n );\n\n return (\n <TocModelProvider value={model}>\n {basemapSwitcher}\n {layerList}\n </TocModelProvider>\n );\n}\n\nfunction useTocModel(props: TocProps): TocModel {\n const initialProps = useRef(props);\n const { model, options } = useMemo(() => {\n const options = reactive<TocWidgetOptions>(\n createOptions(\n initialProps.current.autoShowParents,\n initialProps.current.collapsibleGroups,\n initialProps.current.initiallyCollapsed\n )\n );\n\n // Indexed by layerId\n const items = reactiveMap<string, TocItem>();\n const model: TocModel = {\n get options() {\n return options.value;\n },\n getItem(layerId: string): TocItem | undefined {\n return items.get(layerId);\n },\n getItems(): TocItem[] {\n return Array.from(items.values());\n },\n registerItem(item: TocItem): void {\n if (items.has(item.layerId)) {\n throw new Error(`Item with layerId '${item.layerId}' already registered.`);\n }\n items.set(item.layerId, item);\n },\n unregisterItem(item: TocItem): void {\n if (items.get(item.layerId) !== item) {\n throw new Error(`Item with layerId '${item.layerId}' not registered.`);\n }\n items.delete(item.layerId);\n }\n };\n return { model, options };\n }, []);\n\n // Sync props to model\n useEffect(() => {\n options.value = createOptions(\n props.autoShowParents,\n props.collapsibleGroups,\n props.initiallyCollapsed\n );\n }, [options, props.autoShowParents, props.collapsibleGroups, props.initiallyCollapsed]);\n\n return model;\n}\n\nfunction createOptions(\n autoShowParents?: boolean | undefined,\n collapsibleGroups?: boolean | undefined,\n isCollapsed?: boolean | undefined\n): TocWidgetOptions {\n return {\n autoShowParents: autoShowParents ?? true,\n collapsibleGroups: collapsibleGroups ?? false,\n initiallyCollapsed: isCollapsed ?? false\n };\n}\n"],"names":["options","model"],"mappings":";;;;;;;;;;;;AA0FA,MAAM,OAAU,GAAA,CAAA;AAKH,MAAA,GAAA,GAAoB,CAAC,KAAoB,KAAA;AAClD,EAAA,MAAM,OAAO,OAAQ,EAAA;AACrB,EAAA,MAAM,EAAE,cAAA,EAAmB,GAAA,uBAAA,CAAwB,OAAO,KAAK,CAAA;AAC/D,EAAM,MAAA,KAAA,GAAQ,YAAY,KAAK,CAAA;AAE/B,EAAI,IAAA,OAAA;AACJ,EAAA,QAAQ,MAAM,IAAM;AAAA,IAChB,KAAK,SAAA;AACD,MAAU,OAAA,GAAA,IAAA;AACV,MAAA;AAAA,IACJ,KAAK,UAAA;AACD,MAAU,OAAA,mBAAA,GAAA,CAAC,IAAK,EAAA,EAAA,SAAA,EAAU,WAAa,EAAA,QAAA,EAAA,IAAA,CAAK,cAAc,EAAE,EAAA,EAAI,OAAQ,EAAC,CAAE,EAAA,CAAA;AAC3E,MAAA;AAAA,IACJ,KAAK,UAAY,EAAA;AACb,MAAA,MAAM,MAAM,KAAM,CAAA,GAAA;AAClB,MAAA,OAAA,mBAAW,GAAA,CAAA,UAAA,EAAA,EAAY,GAAG,KAAA,EAAO,GAAU,EAAA,CAAA;AAC3C,MAAA;AAAA;AACJ;AAGJ,EACI,uBAAA,GAAA,CAAC,QAAM,GAAG,cAAA,EAAgB,WAAU,QAAS,EAAA,GAAA,EAAK,SAC7C,QACL,EAAA,OAAA,EAAA,CAAA;AAER;AAGA,SAAS,WAAW,KAAqC,EAAA;AACrD,EAAM,MAAA;AAAA,IACF,GAAA;AAAA,IACA,SAAY,GAAA,KAAA;AAAA,IACZ,WAAA;AAAA,I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