@open-pioneer/map 0.11.0 → 0.12.0-dev.20250905090001

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.
Files changed (47) hide show
  1. package/CHANGELOG.md +101 -5
  2. package/MapRegistryImpl.js.map +1 -1
  3. package/README.md +32 -20
  4. package/api/MapModel.d.ts +5 -0
  5. package/api/index.d.ts +1 -1
  6. package/api/layers/GroupLayer.js.map +1 -1
  7. package/api/layers/SimpleLayer.js.map +1 -1
  8. package/api/layers/WMSLayer.js.map +1 -1
  9. package/api/layers/WMTSLayer.js.map +1 -1
  10. package/api/layers/base.d.ts +17 -0
  11. package/api/layers/base.js.map +1 -1
  12. package/api/shared.d.ts +6 -4
  13. package/index.js +1 -1
  14. package/model/AbstractLayer.js.map +1 -1
  15. package/model/AbstractLayerBase.d.ts +3 -0
  16. package/model/AbstractLayerBase.js +8 -0
  17. package/model/AbstractLayerBase.js.map +1 -1
  18. package/model/Highlights.js +9 -1
  19. package/model/Highlights.js.map +1 -1
  20. package/model/LayerCollectionImpl.js +52 -24
  21. package/model/LayerCollectionImpl.js.map +1 -1
  22. package/model/MapModelImpl.js.map +1 -1
  23. package/model/SublayersCollectionImpl.js.map +1 -1
  24. package/model/createMapModel.js.map +1 -1
  25. package/model/getRecursiveLayers.js.map +1 -1
  26. package/model/layers/GroupLayerImpl.js.map +1 -1
  27. package/model/layers/SimpleLayerImpl.js.map +1 -1
  28. package/model/layers/WMSLayerImpl.js.map +1 -1
  29. package/model/layers/WMTSLayerImpl.js.map +1 -1
  30. package/package.json +6 -7
  31. package/projections.d.ts +3 -1
  32. package/projections.js.map +1 -1
  33. package/ui/DefaultMapProvider.d.ts +3 -2
  34. package/ui/DefaultMapProvider.js +7 -13
  35. package/ui/DefaultMapProvider.js.map +1 -1
  36. package/ui/MapAnchor.js.map +1 -1
  37. package/ui/MapContainer.d.ts +2 -0
  38. package/ui/MapContainer.js +4 -16
  39. package/ui/MapContainer.js.map +1 -1
  40. package/ui/MapContainerContext.js.map +1 -1
  41. package/ui/computeMapAnchorStyles.js.map +1 -1
  42. package/ui/useMapModel.d.ts +28 -22
  43. package/ui/useMapModel.js +31 -29
  44. package/ui/useMapModel.js.map +1 -1
  45. package/util/capabilities-utils.js.map +1 -1
  46. package/util/geometry-utils.js.map +1 -1
  47. package/util/ol-test-support.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"MapContainerContext.js","sources":["MapContainerContext.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { Provider, createContext, useContext } from \"react\";\n\n/** Values provided to children of {@link MapContainer}. */\nexport interface MapContainerContextType {\n mapAnchorsHost: HTMLElement;\n}\n\nconst MapContainerContext = createContext<MapContainerContextType | undefined>(undefined);\nMapContainerContext.displayName = \"MapContainerContext\";\n\nexport const MapContainerContextProvider: Provider<MapContainerContextType> =\n MapContainerContext.Provider as Provider<MapContainerContextType>;\n\nexport function useMapContainerContext(): MapContainerContextType {\n const contextValue = useContext(MapContainerContext);\n if (!contextValue) {\n throw new Error(\n `Map container context is not available. The component must be a child of the <MapContainer /> component.`\n );\n }\n return contextValue;\n}\n"],"names":[],"mappings":";;AASA,MAAM,mBAAA,GAAsB,cAAmD,MAAS,CAAA;AACxF,mBAAA,CAAoB,WAAc,GAAA,qBAAA;AAE3B,MAAM,8BACT,mBAAoB,CAAA;AAEjB,SAAS,sBAAkD,GAAA;AAC9D,EAAM,MAAA,YAAA,GAAe,WAAW,mBAAmB,CAAA;AACnD,EAAA,IAAI,CAAC,YAAc,EAAA;AACf,IAAA,MAAM,IAAI,KAAA;AAAA,MACN,CAAA,wGAAA;AAAA,KACJ;AAAA;AAEJ,EAAO,OAAA,YAAA;AACX;;;;"}
1
+ {"version":3,"file":"MapContainerContext.js","sources":["MapContainerContext.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { Provider, createContext, useContext } from \"react\";\n\n/** Values provided to children of {@link MapContainer}. */\nexport interface MapContainerContextType {\n mapAnchorsHost: HTMLElement;\n}\n\nconst MapContainerContext = createContext<MapContainerContextType | undefined>(undefined);\nMapContainerContext.displayName = \"MapContainerContext\";\n\nexport const MapContainerContextProvider: Provider<MapContainerContextType> =\n MapContainerContext.Provider as Provider<MapContainerContextType>;\n\nexport function useMapContainerContext(): MapContainerContextType {\n const contextValue = useContext(MapContainerContext);\n if (!contextValue) {\n throw new Error(\n `Map container context is not available. The component must be a child of the <MapContainer /> component.`\n );\n }\n return contextValue;\n}\n"],"names":[],"mappings":";;AASA,MAAM,mBAAA,GAAsB,cAAmD,MAAS,CAAA;AACxF,mBAAA,CAAoB,WAAA,GAAc,qBAAA;AAE3B,MAAM,8BACT,mBAAA,CAAoB;AAEjB,SAAS,sBAAA,GAAkD;AAC9D,EAAA,MAAM,YAAA,GAAe,WAAW,mBAAmB,CAAA;AACnD,EAAA,IAAI,CAAC,YAAA,EAAc;AACf,IAAA,MAAM,IAAI,KAAA;AAAA,MACN,CAAA,wGAAA;AAAA,KACJ;AAAA,EACJ;AACA,EAAA,OAAO,YAAA;AACX;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"computeMapAnchorStyles.js","sources":["computeMapAnchorStyles.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { SystemStyleObject } from \"@chakra-ui/react\";\nimport { MapAnchorPosition } from \"./MapAnchor\";\n\nexport function computeMapAnchorStyles(\n position: MapAnchorPosition,\n horizontalGap?: number | undefined,\n verticalGap?: number | undefined\n): SystemStyleObject {\n const horizontal = horizontalGap ?? 0;\n const vertical = verticalGap ?? 0;\n const attributionGap = verticalGap == null ? ATTR_GAP : 0;\n\n const styleProps: SystemStyleObject = {};\n switch (position) {\n case \"top-left\":\n styleProps.left = `${horizontal}px`;\n styleProps.top = `${vertical}px`;\n break;\n case \"top-right\":\n styleProps.right = `${horizontal}px`;\n styleProps.top = `${vertical}px`;\n break;\n case \"bottom-left\":\n styleProps.left = `${horizontal}px`;\n styleProps.bottom = `${vertical + attributionGap}px`;\n break;\n case \"bottom-right\":\n styleProps.right = `${horizontal}px`;\n styleProps.bottom = `${vertical + attributionGap}px`;\n break;\n case \"top-center\":\n styleProps.top = `${vertical}px`;\n styleProps.left = `calc((100% - ${horizontal}px) / 2)`;\n styleProps.transform = \"translateX(-50%)\";\n break;\n case \"bottom-center\":\n styleProps.bottom = `${vertical + attributionGap}px`;\n styleProps.left = `calc((100% - ${horizontal}px) / 2)`;\n styleProps.transform = \"translateX(-50%)\";\n break;\n case \"left-center\":\n styleProps.left = `${horizontal}px`;\n styleProps.top = `calc((100% - ${vertical}px) / 2)`;\n styleProps.transform = \"translateY(-50%)\";\n break;\n case \"right-center\":\n styleProps.right = `${horizontal}px`;\n styleProps.top = `calc((100% - ${vertical}px) / 2)`;\n styleProps.transform = \"translateY(-50%)\";\n break;\n case \"center\":\n styleProps.top = `calc((100% - ${vertical}px) / 2)`;\n styleProps.left = `calc((100% - ${horizontal}px) / 2)`;\n styleProps.transform = \"translate(-50%, -50%)\";\n break;\n }\n\n styleProps.maxW = `calc((100%) - ${2 * horizontal}px)`;\n styleProps.maxH = `calc((100%) - ${attributionGap}px - ${2 * vertical}px)`;\n return styleProps;\n}\n\n/**\n * height of the ol attribution component\n * improvement: Get height directly from `Attribution` HTMLDivElement\n */\nconst ATTR_HEIGHT = 20;\n\n/**\n * additional space between attribution and map anchor container\n */\nconst ATTR_SPACE = 10;\nconst ATTR_GAP = ATTR_HEIGHT + ATTR_SPACE;\n"],"names":[],"mappings":"AAKgB,SAAA,sBAAA,CACZ,QACA,EAAA,aAAA,EACA,WACiB,EAAA;AACjB,EAAA,MAAM,aAAa,aAAiB,IAAA,CAAA;AACpC,EAAA,MAAM,WAAW,WAAe,IAAA,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AA,CAAA;AAC5C,MAAA,UAAA,CAAW,SAAY,GAAA,kBAAA;AACvB,MAAA;AAAA,IACJ,KAAK,aAAA;AACD,MAAW,UAAA,CAAA,IAAA,GAAO,GAAG,UAAU,CAAA,EAAA,CAAA;AAC/B,MAAW,UAAA,CAAA,GAAA,GAAM,gBAAgB,QAAQ,CAAA,QAAA,CAAA;AACzC,MAAA,UAAA,CAAW,SAAY,GAAA,kBAAA;AACvB,MAAA;AAAA,IACJ,KAAK,cAAA;AACD,MAAW,UAAA,CAAA,KAAA,GAAQ,GAAG,UAAU,CAAA,EAAA,CAAA;AAChC,MAAW,UAAA,CAAA,GAAA,GAAM,gBAAgB,QAAQ,CAAA,QAAA,CAAA;AACzC,MAAA,UAAA,CAAW,SAAY,GAAA,kBAAA;AACvB,MAAA;AAAA,IACJ,KAAK,QAAA;AACD,MAAW,UAAA,CAAA,GAAA,GAAM,gBAAgB,QAAQ,CAAA,QAAA,CAAA;AACzC,MAAW,UAAA,CAAA,IAAA,GAAO,gBAAgB,UAAU,CAAA,QAAA,CAAA;AAC5C,MAAA,UAAA,CAAW,SAAY,GAAA,uBAAA;AACvB,MAAA;AAAA;AAGR,EAAW,UAAA,CAAA,IAAA,GAAO,CAAiB,cAAA,EAAA,CAAA,GAAI,UAAU,CAAA,GAAA,CAAA;AACjD,EAAA,UAAA,CAAW,IAAO,GAAA,CAAA,cAAA,EAAiB,cAAc,CAAA,KAAA,EAAQ,IAAI,QAAQ,CAAA,GAAA,CAAA;AACrE,EAAO,OAAA,UAAA;AACX;AAMA,MAAM,WAAc,GAAA,EAAA;AAKpB,MAAM,UAAa,GAAA,EAAA;AACnB,MAAM,WAAW,WAAc,GAAA,UAAA;;;;"}
1
+ {"version":3,"file":"computeMapAnchorStyles.js","sources":["computeMapAnchorStyles.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { SystemStyleObject } from \"@chakra-ui/react\";\nimport { MapAnchorPosition } from \"./MapAnchor\";\n\nexport function computeMapAnchorStyles(\n position: MapAnchorPosition,\n horizontalGap?: number | undefined,\n verticalGap?: number | undefined\n): SystemStyleObject {\n const horizontal = horizontalGap ?? 0;\n const vertical = verticalGap ?? 0;\n const attributionGap = verticalGap == null ? ATTR_GAP : 0;\n\n const styleProps: SystemStyleObject = {};\n switch (position) {\n case \"top-left\":\n styleProps.left = `${horizontal}px`;\n styleProps.top = `${vertical}px`;\n break;\n case \"top-right\":\n styleProps.right = `${horizontal}px`;\n styleProps.top = `${vertical}px`;\n break;\n case \"bottom-left\":\n styleProps.left = `${horizontal}px`;\n styleProps.bottom = `${vertical + attributionGap}px`;\n break;\n case \"bottom-right\":\n styleProps.right = `${horizontal}px`;\n styleProps.bottom = `${vertical + attributionGap}px`;\n break;\n case \"top-center\":\n styleProps.top = `${vertical}px`;\n styleProps.left = `calc((100% - ${horizontal}px) / 2)`;\n styleProps.transform = \"translateX(-50%)\";\n break;\n case \"bottom-center\":\n styleProps.bottom = `${vertical + attributionGap}px`;\n styleProps.left = `calc((100% - ${horizontal}px) / 2)`;\n styleProps.transform = \"translateX(-50%)\";\n break;\n case \"left-center\":\n styleProps.left = `${horizontal}px`;\n styleProps.top = `calc((100% - ${vertical}px) / 2)`;\n styleProps.transform = \"translateY(-50%)\";\n break;\n case \"right-center\":\n styleProps.right = `${horizontal}px`;\n styleProps.top = `calc((100% - ${vertical}px) / 2)`;\n styleProps.transform = \"translateY(-50%)\";\n break;\n case \"center\":\n styleProps.top = `calc((100% - ${vertical}px) / 2)`;\n styleProps.left = `calc((100% - ${horizontal}px) / 2)`;\n styleProps.transform = \"translate(-50%, -50%)\";\n break;\n }\n\n styleProps.maxW = `calc((100%) - ${2 * horizontal}px)`;\n styleProps.maxH = `calc((100%) - ${attributionGap}px - ${2 * vertical}px)`;\n return styleProps;\n}\n\n/**\n * height of the ol attribution component\n * improvement: Get height directly from `Attribution` HTMLDivElement\n */\nconst ATTR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,GAAc,EAAA;AAKpB,MAAM,UAAA,GAAa,EAAA;AACnB,MAAM,WAAW,WAAA,GAAc,UAAA;;;;"}
@@ -17,26 +17,11 @@ export interface UseMapModelRejected {
17
17
  error: Error;
18
18
  }
19
19
  /**
20
- * Options that specify which map to use. See {@link useMapModel}.
20
+ * React hook that returns the default map model (if available, see {@link DefaultMapProvider}).
21
21
  *
22
- * When not setting any of these properties on a component, the default map (from the `DefaultMapProvider`) will be used.
23
- * If that is not available either, an error will be thrown.
22
+ * @deprecated Use {@link useMapModelValue} instead.
24
23
  */
25
- export interface MapModelProps {
26
- /**
27
- * The id of the map.
28
- * The map will be looked up in the MapRegistry service.
29
- *
30
- * @deprecated Use the `map` property instead.
31
- *
32
- * @see {@link DefaultMapProvider}
33
- */
34
- mapId?: string | undefined;
35
- /**
36
- * The map model to use.
37
- */
38
- map?: MapModel | undefined;
39
- }
24
+ export declare function useMapModel(): UseMapModelResult;
40
25
  /**
41
26
  * React hook that looks up the map with the given id in the `map.MapRegistry` service.
42
27
  *
@@ -47,15 +32,36 @@ export interface MapModelProps {
47
32
  */
48
33
  export declare function useMapModel(mapId: string): UseMapModelResult;
49
34
  /**
50
- * React hook that resolves a map model specified by the given `props` (see {@link MapModelProps}).
35
+ * React hook that resolves a map model specified by the given `props`.
51
36
  *
52
37
  * Returns an object representing the progress, which will eventually represent either
53
38
  * the map model value or an initialization error.
54
39
  *
55
40
  * The map model cannot be returned directly because it may not have completed its initialization yet.
56
41
  */
57
- export declare function useMapModel(props: MapModelProps): UseMapModelResult;
42
+ export declare function useMapModel(props: {
43
+ mapId: string;
44
+ }): UseMapModelResult;
58
45
  /**
59
- * React hook that returns the default map model (if available, see {@link DefaultMapProvider}).
46
+ * Options that specify which map to use. See {@link useMapModelValue}.
47
+ *
48
+ * When not setting any of these properties on a component, the default map (from the `DefaultMapProvider`) will be used.
49
+ * If that is not available either, an error will be thrown.
50
+ *
51
+ * @see {@link DefaultMapProvider}
60
52
  */
61
- export declare function useMapModel(): UseMapModelResult;
53
+ export interface MapModelProps {
54
+ /**
55
+ * The map model to use.
56
+ */
57
+ map?: MapModel | undefined;
58
+ }
59
+ /**
60
+ * Returns the configured map model.
61
+ *
62
+ * The map model is either directly configured or specified via a {@link DefaultMapProvider}.
63
+ * If neither has been specified, an error will be thrown.
64
+ *
65
+ * This hook is preferable to {@link useMapModel} because it can return the map model directly, without waiting.
66
+ */
67
+ export declare function useMapModelValue(props?: MapModelProps): MapModel;
package/ui/useMapModel.js CHANGED
@@ -2,17 +2,33 @@ import { useService } from '../_virtual/_virtual-pioneer-module_react-hooks.js';
2
2
  import { useMemo } from 'react';
3
3
  import { useAsync } from 'react-use';
4
4
  import { MapModelImpl } from '../model/MapModelImpl.js';
5
- import { useDefaultMapProps } from './DefaultMapProvider.js';
5
+ import { useDefaultMap } from './DefaultMapProvider.js';
6
6
 
7
7
  function useMapModel(props) {
8
- const resolvedMapArg = useResolvedMapArg(props);
8
+ if (props instanceof MapModelImpl) {
9
+ throw new Error(
10
+ `Map model instances cannot be passed directly to 'useMapModel' (see TypeScript signature).`
11
+ );
12
+ }
13
+ const defaultMap = useDefaultMap();
9
14
  const mapRegistry = useService("map.MapRegistry");
15
+ let mapId;
16
+ if (typeof props === "string") {
17
+ mapId = props;
18
+ } else if (typeof props === "object") {
19
+ mapId = props.mapId;
20
+ }
21
+ if (mapId == null && !defaultMap) {
22
+ throw new Error(
23
+ "No map specified. Either configure a mapId or use the DefaultMapProvider."
24
+ );
25
+ }
10
26
  const state = useAsync(async () => {
11
- if (typeof resolvedMapArg === "string") {
12
- return await mapRegistry.expectMapModel(resolvedMapArg);
27
+ if (mapId == null) {
28
+ return defaultMap;
13
29
  }
14
- return Promise.resolve(resolvedMapArg);
15
- }, [mapRegistry, resolvedMapArg]);
30
+ return await mapRegistry.expectMapModel(mapId);
31
+ }, [mapRegistry, mapId]);
16
32
  const result = useMemo(() => {
17
33
  if (state.loading) {
18
34
  return { kind: "loading" };
@@ -24,36 +40,22 @@ function useMapModel(props) {
24
40
  }, [state]);
25
41
  return result;
26
42
  }
27
- function useResolvedMapArg(props) {
28
- if (typeof props === "object" && props.mapId != null && props.map != null) {
29
- throw new Error(`Cannot specify both 'mapId' and 'map' in useMapModel at the same time.`);
30
- }
43
+ function useMapModelValue(props) {
31
44
  if (props instanceof MapModelImpl) {
32
45
  throw new Error(
33
- `Map model instances cannot be passed directly to 'useMapModel' (see TypeScript signature).`
46
+ `Map model instances cannot be passed directly to 'useMapModelValue' (see TypeScript signature).`
34
47
  );
35
48
  }
36
- const localProps = useMemo(() => {
37
- if (props == null) {
38
- return {};
39
- }
40
- if (typeof props === "string") {
41
- return { mapId: props };
42
- }
43
- return { mapId: props.mapId, map: props.map };
44
- }, [...typeof props === "string" || props == null ? [props] : [props.mapId, props.map]]);
45
- const defaultProps = useDefaultMapProps();
46
- const resolvedMapArg = resolveMap(localProps) ?? resolveMap(defaultProps);
47
- if (resolvedMapArg == null) {
49
+ const localMap = props?.map;
50
+ const defaultMap = useDefaultMap();
51
+ const map = localMap ?? defaultMap;
52
+ if (!map) {
48
53
  throw new Error(
49
- `No map specified. You must either specify the map (or its id) via a DefaultMapProvider parent or configure it explicitly.`
54
+ `No map specified. You must either specify the map via a DefaultMapProvider parent or configure it explicitly.`
50
55
  );
51
56
  }
52
- return resolvedMapArg;
53
- }
54
- function resolveMap(props) {
55
- return props?.map ?? props?.mapId;
57
+ return map;
56
58
  }
57
59
 
58
- export { useMapModel };
60
+ export { useMapModel, useMapModelValue };
59
61
  //# sourceMappingURL=useMapModel.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useMapModel.js","sources":["useMapModel.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { useService } from \"open-pioneer:react-hooks\";\nimport { useMemo } from \"react\";\nimport { useAsync } from \"react-use\";\nimport { MapModel, MapRegistry } from \"../api\";\nimport { MapModelImpl } from \"../model/MapModelImpl\";\n// eslint-disable-next-line unused-imports/no-unused-imports\nimport { DefaultMapProvider, useDefaultMapProps } from \"./DefaultMapProvider\";\n\n/** Return value of {@link useMapModel}. */\nexport type UseMapModelResult = UseMapModelLoading | UseMapModelResolved | UseMapModelRejected;\n\nexport interface UseMapModelLoading {\n kind: \"loading\";\n map?: undefined;\n error?: undefined;\n}\n\nexport interface UseMapModelResolved {\n kind: \"resolved\";\n map: MapModel;\n error?: undefined;\n}\n\nexport interface UseMapModelRejected {\n kind: \"rejected\";\n map?: undefined;\n error: Error;\n}\n\n/**\n * Options that specify which map to use. See {@link useMapModel}.\n *\n * When not setting any of these properties on a component, the default map (from the `DefaultMapProvider`) will be used.\n * If that is not available either, an error will be thrown.\n */\nexport interface MapModelProps {\n /**\n * The id of the map.\n * The map will be looked up in the MapRegistry service.\n *\n * @deprecated Use the `map` property instead.\n *\n * @see {@link DefaultMapProvider}\n */\n mapId?: string | undefined;\n\n /**\n * The map model to use.\n */\n map?: MapModel | undefined;\n}\n\n/**\n * React hook that looks up the map with the given id in the `map.MapRegistry` service.\n *\n * Returns an object representing the progress, which will eventually represent either\n * the map model value or an initialization error.\n *\n * The map model cannot be returned directly because it may not have completed its initialization yet.\n */\nexport function useMapModel(mapId: string): UseMapModelResult;\n\n/**\n * React hook that resolves a map model specified by the given `props` (see {@link MapModelProps}).\n *\n * Returns an object representing the progress, which will eventually represent either\n * the map model value or an initialization error.\n *\n * The map model cannot be returned directly because it may not have completed its initialization yet.\n */\nexport function useMapModel(props: MapModelProps): UseMapModelResult;\n\n/**\n * React hook that returns the default map model (if available, see {@link DefaultMapProvider}).\n */\nexport function useMapModel(): UseMapModelResult;\nexport function useMapModel(props?: undefined | string | MapModelProps): UseMapModelResult {\n const resolvedMapArg = useResolvedMapArg(props);\n const mapRegistry = useService<MapRegistry>(\"map.MapRegistry\");\n const state = useAsync(async () => {\n if (typeof resolvedMapArg === \"string\") {\n return await mapRegistry.expectMapModel(resolvedMapArg);\n }\n return Promise.resolve(resolvedMapArg);\n }, [mapRegistry, resolvedMapArg]);\n const result = useMemo((): UseMapModelResult => {\n if (state.loading) {\n return { kind: \"loading\" };\n }\n if (state.error) {\n return { kind: \"rejected\", error: state.error };\n }\n return { kind: \"resolved\", map: state.value! };\n }, [state]);\n return result;\n}\n\n/**\n * Resolves the map model (or its id) from the given props and the default map props.\n */\nfunction useResolvedMapArg(props?: undefined | string | MapModelProps): MapModel | string {\n if (typeof props === \"object\" && props.mapId != null && props.map != null) {\n throw new Error(`Cannot specify both 'mapId' and 'map' in useMapModel at the same time.`);\n }\n if (props instanceof MapModelImpl) {\n // This cannot happen in valid typescript code, but it might be a common mistake.\n throw new Error(\n `Map model instances cannot be passed directly to 'useMapModel' (see TypeScript signature).`\n );\n }\n const localProps = useMemo((): MapModelProps => {\n // Normalize local props for compatibility with old string overload.\n if (props == null) {\n return {};\n }\n if (typeof props === \"string\") {\n return { mapId: props };\n }\n return { mapId: props.mapId, map: props.map };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [...(typeof props === \"string\" || props == null ? [props] : [props.mapId, props.map])]);\n const defaultProps = useDefaultMapProps();\n\n const resolvedMapArg = resolveMap(localProps) ?? resolveMap(defaultProps);\n if (resolvedMapArg == null) {\n throw new Error(\n `No map specified. ` +\n `You must either specify the map (or its id) via a DefaultMapProvider parent or configure it explicitly.`\n );\n }\n return resolvedMapArg;\n}\n\nfunction resolveMap(props?: MapModelProps): MapModel | string | undefined {\n return props?.map ?? props?.mapId;\n}\n"],"names":[],"mappings":";;;;;;AA8EO,SAAS,YAAY,KAA+D,EAAA;AACvF,EAAM,MAAA,cAAA,GAAiB,kBAAkB,KAAK,CAAA;AAC9C,EAAM,MAAA,WAAA,GAAc,WAAwB,iBAAiB,CAAA;AAC7D,EAAM,MAAA,KAAA,GAAQ,SAAS,YAAY;AAC/B,IAAI,IAAA,OAAO,mBAAmB,QAAU,EAAA;AACpC,MAAO,OAAA,MAAM,WAAY,CAAA,cAAA,CAAe,cAAc,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,OAAO,KAAM,CAAA,GAAG,CAAE,CAAC,CAAA;AACzF,EAAA,MAAM,eAAe,kBAAmB,EAAA;AAExC,EAAA,MAAM,cAAiB,GAAA,UAAA,CAAW,UAAU,CAAA,IAAK,WAAW,YAAY,CAAA;AACxE,EAAA,IAAI,kBAAkB,IAAM,EAAA;AACxB,IAAA,MAAM,IAAI,KAAA;AAAA,MACN,CAAA,yHAAA;AAAA,KAEJ;AAAA;AAEJ,EAAO,OAAA,cAAA;AACX;AAEA,SAAS,WAAW,KAAsD,EAAA;AACtE,EAAO,OAAA,KAAA,EAAO,OAAO,KAAO,EAAA,KAAA;AAChC;;;;"}
1
+ {"version":3,"file":"useMapModel.js","sources":["useMapModel.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { useService } from \"open-pioneer:react-hooks\";\nimport { useMemo } from \"react\";\nimport { useAsync } from \"react-use\";\nimport { MapModel, MapRegistry } from \"../api\";\nimport { MapModelImpl } from \"../model/MapModelImpl\";\n// eslint-disable-next-line unused-imports/no-unused-imports\nimport { DefaultMapProvider, useDefaultMap } from \"./DefaultMapProvider\";\n\n/** Return value of {@link useMapModel}. */\nexport type UseMapModelResult = UseMapModelLoading | UseMapModelResolved | UseMapModelRejected;\n\nexport interface UseMapModelLoading {\n kind: \"loading\";\n map?: undefined;\n error?: undefined;\n}\n\nexport interface UseMapModelResolved {\n kind: \"resolved\";\n map: MapModel;\n error?: undefined;\n}\n\nexport interface UseMapModelRejected {\n kind: \"rejected\";\n map?: undefined;\n error: Error;\n}\n\n/**\n * React hook that returns the default map model (if available, see {@link DefaultMapProvider}).\n *\n * @deprecated Use {@link useMapModelValue} instead.\n */\nexport function useMapModel(): UseMapModelResult;\n\n/**\n * React hook that looks up the map with the given id in the `map.MapRegistry` service.\n *\n * Returns an object representing the progress, which will eventually represent either\n * the map model value or an initialization error.\n *\n * The map model cannot be returned directly because it may not have completed its initialization yet.\n */\nexport function useMapModel(mapId: string): UseMapModelResult;\n\n/**\n * React hook that resolves a map model specified by the given `props`.\n *\n * Returns an object representing the progress, which will eventually represent either\n * the map model value or an initialization error.\n *\n * The map model cannot be returned directly because it may not have completed its initialization yet.\n */\nexport function useMapModel(props: { mapId: string }): UseMapModelResult;\n\nexport function useMapModel(props?: undefined | string | { mapId: string }): UseMapModelResult {\n if (props instanceof MapModelImpl) {\n // This cannot happen in valid typescript code, but it might be a common mistake.\n throw new Error(\n `Map model instances cannot be passed directly to 'useMapModel' (see TypeScript signature).`\n );\n }\n\n const defaultMap = useDefaultMap();\n const mapRegistry = useService<MapRegistry>(\"map.MapRegistry\");\n\n let mapId: string | undefined;\n if (typeof props === \"string\") {\n mapId = props;\n } else if (typeof props === \"object\") {\n mapId = props.mapId;\n }\n\n if (mapId == null && !defaultMap) {\n throw new Error(\n \"No map specified. Either configure a mapId or use the DefaultMapProvider.\"\n );\n }\n\n const state = useAsync(async () => {\n if (mapId == null) {\n // For backwards compatibility\n return defaultMap!;\n }\n\n return await mapRegistry.expectMapModel(mapId);\n }, [mapRegistry, mapId]);\n\n const result = useMemo((): UseMapModelResult => {\n if (state.loading) {\n return { kind: \"loading\" };\n }\n if (state.error) {\n return { kind: \"rejected\", error: state.error };\n }\n return { kind: \"resolved\", map: state.value! };\n }, [state]);\n return result;\n}\n\n/**\n * Options that specify which map to use. See {@link useMapModelValue}.\n *\n * When not setting any of these properties on a component, the default map (from the `DefaultMapProvider`) will be used.\n * If that is not available either, an error will be thrown.\n *\n * @see {@link DefaultMapProvider}\n */\nexport interface MapModelProps {\n /**\n * The map model to use.\n */\n map?: MapModel | undefined;\n}\n\n/**\n * Returns the configured map model.\n *\n * The map model is either directly configured or specified via a {@link DefaultMapProvider}.\n * If neither has been specified, an error will be thrown.\n *\n * This hook is preferable to {@link useMapModel} because it can return the map model directly, without waiting.\n */\nexport function useMapModelValue(props?: MapModelProps): MapModel {\n if (props instanceof MapModelImpl) {\n // This cannot happen in valid typescript code, but it might be a common mistake.\n throw new Error(\n `Map model instances cannot be passed directly to 'useMapModelValue' (see TypeScript signature).`\n );\n }\n\n const localMap = props?.map;\n const defaultMap = useDefaultMap();\n const map = localMap ?? defaultMap;\n if (!map) {\n throw new Error(\n `No map specified. ` +\n `You must either specify the map via a DefaultMapProvider parent or configure it explicitly.`\n );\n }\n return map;\n}\n"],"names":[],"mappings":";;;;;;AA0DO,SAAS,YAAY,KAAA,EAAmE;AAC3F,EAAA,IAAI,iBAAiB,YAAA,EAAc;AAE/B,IAAA,MAAM,IAAI,KAAA;AAAA,MACN,CAAA,0FAAA;AAAA,KACJ;AAAA,EACJ;AAEA,EAAA,MAAM,aAAa,aAAA,EAAc;AACjC,EAAA,MAAM,WAAA,GAAc,WAAwB,iBAAiB,CAAA;AAE7D,EAAA,IAAI,KAAA;AACJ,EAAA,IAAI,OAAO,UAAU,QAAA,EAAU;AAC3B,IAAA,KAAA,GAAQ,KAAA;AAAA,EACZ,CAAA,MAAA,IAAW,OAAO,KAAA,KAAU,QAAA,EAAU;AAClC,IAAA,KAAA,GAAQ,KAAA,CAAM,KAAA;AAAA,EAClB;AAEA,EAAA,IAAI,KAAA,IAAS,IAAA,IAAQ,CAAC,UAAA,EAAY;AAC9B,IAAA,MAAM,IAAI,KAAA;AAAA,MACN;AAAA,KACJ;AAAA,EACJ;AAEA,EAAA,MAAM,KAAA,GAAQ,SAAS,YAAY;AAC/B,IAAA,IAAI,SAAS,IAAA,EAAM;AAEf,MAAA,OAAO,UAAA;AAAA,IACX;AAEA,IAAA,OAAO,MAAM,WAAA,CAAY,cAAA,CAAe,KAAK,CAAA;AAAA,EACjD,CAAA,EAAG,CAAC,WAAA,EAAa,KAAK,CAAC,CAAA;AAEvB,EAAA,MAAM,MAAA,GAAS,QAAQ,MAAyB;AAC5C,IAAA,IAAI,MAAM,OAAA,EAAS;AACf,MAAA,OAAO,EAAE,MAAM,SAAA,EAAU;AAAA,IAC7B;AACA,IAAA,IAAI,MAAM,KAAA,EAAO;AACb,MAAA,OAAO,EAAE,IAAA,EAAM,UAAA,EAAY,KAAA,EAAO,MAAM,KAAA,EAAM;AAAA,IAClD;AACA,IAAA,OAAO,EAAE,IAAA,EAAM,UAAA,EAAY,GAAA,EAAK,MAAM,KAAA,EAAO;AAAA,EACjD,CAAA,EAAG,CAAC,KAAK,CAAC,CAAA;AACV,EAAA,OAAO,MAAA;AACX;AAyBO,SAAS,iBAAiB,KAAA,EAAiC;AAC9D,EAAA,IAAI,iBAAiB,YAAA,EAAc;AAE/B,IAAA,MAAM,IAAI,KAAA;AAAA,MACN,CAAA,+FAAA;AAAA,KACJ;AAAA,EACJ;AAEA,EAAA,MAAM,WAAW,KAAA,EAAO,GAAA;AACxB,EAAA,MAAM,aAAa,aAAA,EAAc;AACjC,EAAA,MAAM,MAAM,QAAA,IAAY,UAAA;AACxB,EAAA,IAAI,CAAC,GAAA,EAAK;AACN,IAAA,MAAM,IAAI,KAAA;AAAA,MACN,CAAA,6GAAA;AAAA,KAEJ;AAAA,EACJ;AACA,EAAA,OAAO,GAAA;AACX;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"capabilities-utils.js","sources":["capabilities-utils.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { HttpService } from \"@open-pioneer/http\";\n\nexport async function fetchCapabilities(\n url: string,\n httpService: HttpService,\n signal: AbortSignal\n): Promise<string> {\n const response = await httpService.fetch(url, { signal });\n if (!response.ok) {\n throw new Error(\"Request failed: \" + response.status);\n }\n const result = await response.text();\n return result;\n}\n"],"names":[],"mappings":"AAIsB,eAAA,iBAAA,CAClB,GACA,EAAA,WAAA,EACA,MACe,EAAA;AACf,EAAA,MAAM,WAAW,MAAM,WAAA,CAAY,MAAM,GAAK,EAAA,EAAE,QAAQ,CAAA;AACxD,EAAI,IAAA,CAAC,SAAS,EAAI,EAAA;AACd,IAAA,MAAM,IAAI,KAAA,CAAM,kBAAqB,GAAA,QAAA,CAAS,MAAM,CAAA;AAAA;AAExD,EAAM,MAAA,MAAA,GAAS,MAAM,QAAA,CAAS,IAAK,EAAA;AACnC,EAAO,OAAA,MAAA;AACX;;;;"}
1
+ {"version":3,"file":"capabilities-utils.js","sources":["capabilities-utils.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { HttpService } from \"@open-pioneer/http\";\n\nexport async function fetchCapabilities(\n url: string,\n httpService: HttpService,\n signal: AbortSignal\n): Promise<string> {\n const response = await httpService.fetch(url, { signal });\n if (!response.ok) {\n throw new Error(\"Request failed: \" + response.status);\n }\n const result = await response.text();\n return result;\n}\n"],"names":[],"mappings":"AAIA,eAAsB,iBAAA,CAClB,GAAA,EACA,WAAA,EACA,MAAA,EACe;AACf,EAAA,MAAM,WAAW,MAAM,WAAA,CAAY,MAAM,GAAA,EAAK,EAAE,QAAQ,CAAA;AACxD,EAAA,IAAI,CAAC,SAAS,EAAA,EAAI;AACd,IAAA,MAAM,IAAI,KAAA,CAAM,kBAAA,GAAqB,QAAA,CAAS,MAAM,CAAA;AAAA,EACxD;AACA,EAAA,MAAM,MAAA,GAAS,MAAM,QAAA,CAAS,IAAA,EAAK;AACnC,EAAA,OAAO,MAAA;AACX;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"geometry-utils.js","sources":["geometry-utils.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { Extent, getHeight, getWidth } from \"ol/extent\";\n\nconst DEFAULT_BUFFER_FACTOR = 1.2;\n\n/**\n * Computes a buffered extent using the given original extent.\n *\n * Use the `factor` (`1.2` by default) to specify the size increase.\n */\nexport function calculateBufferedExtent(extent: Extent, factor = DEFAULT_BUFFER_FACTOR): Extent {\n checkExtent(extent);\n const width = getHeight(extent);\n const height = getWidth(extent);\n const bufferWidth = width * factor;\n const bufferHeight = height * factor;\n const bufferedExtent = [\n extent[0] - (bufferWidth - width) / 2,\n extent[1] - (bufferHeight - height) / 2,\n extent[2] + (bufferWidth - width) / 2,\n extent[3] + (bufferHeight - height) / 2\n ];\n return bufferedExtent;\n}\n\nfunction checkExtent(extent: Extent): asserts extent is [number, number, number, number] {\n if (extent.length !== 4) {\n throw new Error(`Invalid extent (expected length 4, but got length ${extent.length}).`);\n }\n}\n"],"names":[],"mappings":";;AAIA,MAAM,qBAAwB,GAAA,GAAA;AAOd,SAAA,uBAAA,CAAwB,MAAgB,EAAA,MAAA,GAAS,qBAA+B,EAAA;AAC5F,EAAA,WAAA,CAAY,MAAM,CAAA;AAClB,EAAM,MAAA,KAAA,GAAQ,UAAU,MAAM,CAAA;AAC9B,EAAM,MAAA,MAAA,GAAS,SAAS,MAAM,CAAA;AAC9B,EAAA,MAAM,cAAc,KAAQ,GAAA,MAAA;AAC5B,EAAA,MAAM,eAAe,MAAS,GAAA,MAAA;AAC9B,EAAA,MAAM,cAAiB,GAAA;AAAA,IACnB,MAAO,CAAA,CAAC,CAAK,GAAA,CAAA,WAAA,GAAc,KAAS,IAAA,CAAA;AAAA,IACpC,MAAO,CAAA,CAAC,CAAK,GAAA,CAAA,YAAA,GAAe,MAAU,IAAA,CAAA;AAAA,IACtC,MAAO,CAAA,CAAC,CAAK,GAAA,CAAA,WAAA,GAAc,KAAS,IAAA,CAAA;AAAA,IACpC,MAAO,CAAA,CAAC,CAAK,GAAA,CAAA,YAAA,GAAe,MAAU,IAAA;AAAA,GAC1C;AACA,EAAO,OAAA,cAAA;AACX;AAEA,SAAS,YAAY,MAAoE,EAAA;AACrF,EAAI,IAAA,MAAA,CAAO,WAAW,CAAG,EAAA;AACrB,IAAA,MAAM,IAAI,KAAA,CAAM,CAAqD,kDAAA,EAAA,MAAA,CAAO,MAAM,CAAI,EAAA,CAAA,CAAA;AAAA;AAE9F;;;;"}
1
+ {"version":3,"file":"geometry-utils.js","sources":["geometry-utils.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { Extent, getHeight, getWidth } from \"ol/extent\";\n\nconst DEFAULT_BUFFER_FACTOR = 1.2;\n\n/**\n * Computes a buffered extent using the given original extent.\n *\n * Use the `factor` (`1.2` by default) to specify the size increase.\n */\nexport function calculateBufferedExtent(extent: Extent, factor = DEFAULT_BUFFER_FACTOR): Extent {\n checkExtent(extent);\n const width = getHeight(extent);\n const height = getWidth(extent);\n const bufferWidth = width * factor;\n const bufferHeight = height * factor;\n const bufferedExtent = [\n extent[0] - (bufferWidth - width) / 2,\n extent[1] - (bufferHeight - height) / 2,\n extent[2] + (bufferWidth - width) / 2,\n extent[3] + (bufferHeight - height) / 2\n ];\n return bufferedExtent;\n}\n\nfunction checkExtent(extent: Extent): asserts extent is [number, number, number, number] {\n if (extent.length !== 4) {\n throw new Error(`Invalid extent (expected length 4, but got length ${extent.length}).`);\n }\n}\n"],"names":[],"mappings":";;AAIA,MAAM,qBAAA,GAAwB,GAAA;AAOvB,SAAS,uBAAA,CAAwB,MAAA,EAAgB,MAAA,GAAS,qBAAA,EAA+B;AAC5F,EAAA,WAAA,CAAY,MAAM,CAAA;AAClB,EAAA,MAAM,KAAA,GAAQ,UAAU,MAAM,CAAA;AAC9B,EAAA,MAAM,MAAA,GAAS,SAAS,MAAM,CAAA;AAC9B,EAAA,MAAM,cAAc,KAAA,GAAQ,MAAA;AAC5B,EAAA,MAAM,eAAe,MAAA,GAAS,MAAA;AAC9B,EAAA,MAAM,cAAA,GAAiB;AAAA,IACnB,MAAA,CAAO,CAAC,CAAA,GAAA,CAAK,WAAA,GAAc,KAAA,IAAS,CAAA;AAAA,IACpC,MAAA,CAAO,CAAC,CAAA,GAAA,CAAK,YAAA,GAAe,MAAA,IAAU,CAAA;AAAA,IACtC,MAAA,CAAO,CAAC,CAAA,GAAA,CAAK,WAAA,GAAc,KAAA,IAAS,CAAA;AAAA,IACpC,MAAA,CAAO,CAAC,CAAA,GAAA,CAAK,YAAA,GAAe,MAAA,IAAU;AAAA,GAC1C;AACA,EAAA,OAAO,cAAA;AACX;AAEA,SAAS,YAAY,MAAA,EAAoE;AACrF,EAAA,IAAI,MAAA,CAAO,WAAW,CAAA,EAAG;AACrB,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,kDAAA,EAAqD,MAAA,CAAO,MAAM,CAAA,EAAA,CAAI,CAAA;AAAA,EAC1F;AACJ;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"ol-test-support.js","sources":["ol-test-support.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { equals as extentEquals } from \"ol/extent\";\nimport OlMap from \"ol/Map\";\n\nlet setupDone = false;\n\n/** @internal */\nexport function patchOpenLayersClassesForTesting() {\n if (setupDone) {\n return;\n }\n\n // Test support: OpenLayers relies on div.offsetHeight (and Width)\n // plus getComputedStyle(div), which do not work as expected in happy dom.\n // The following snippet fakes a size so tests can work with the map.\n OlMap.prototype.updateSize = function () {\n const target = this.getTargetElement();\n const height = 500;\n const width = 500;\n const size = target ? [width, height] : undefined;\n const oldSize = this.getSize();\n if (size && (!oldSize || !extentEquals(size, oldSize))) {\n this.setSize(size);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (this as any).updateViewportSize_();\n }\n };\n setupDone = true;\n}\n"],"names":["extentEquals"],"mappings":";;;AAKA,IAAI,SAAY,GAAA,KAAA;AAGT,SAAS,gCAAmC,GAAA;AAC/C,EAAA,IAAI,SAAW,EAAA;AACX,IAAA;AAAA;AAMJ,EAAM,KAAA,CAAA,SAAA,CAAU,aAAa,WAAY;AACrC,IAAM,MAAA,MAAA,GAAS,KAAK,gBAAiB,EAAA;AACrC,IAAA,MAAM,MAAS,GAAA,GAAA;AACf,IAAA,MAAM,KAAQ,GAAA,GAAA;AACd,IAAA,MAAM,IAAO,GAAA,MAAA,GAAS,CAAC,KAAA,EAAO,MAAM,CAAI,GAAA,MAAA;AACxC,IAAM,MAAA,OAAA,GAAU,KAAK,OAAQ,EAAA;AAC7B,IAAA,IAAI,SAAS,CAAC,OAAA,IAAW,CAACA,MAAa,CAAA,IAAA,EAAM,OAAO,CAAI,CAAA,EAAA;AACpD,MAAA,IAAA,CAAK,QAAQ,IAAI,CAAA;AAEjB,MAAC,KAAa,mBAAoB,EAAA;AAAA;AACtC,GACJ;AACA,EAAY,SAAA,GAAA,IAAA;AAChB;;;;"}
1
+ {"version":3,"file":"ol-test-support.js","sources":["ol-test-support.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { equals as extentEquals } from \"ol/extent\";\nimport OlMap from \"ol/Map\";\n\nlet setupDone = false;\n\n/** @internal */\nexport function patchOpenLayersClassesForTesting() {\n if (setupDone) {\n return;\n }\n\n // Test support: OpenLayers relies on div.offsetHeight (and Width)\n // plus getComputedStyle(div), which do not work as expected in happy dom.\n // The following snippet fakes a size so tests can work with the map.\n OlMap.prototype.updateSize = function () {\n const target = this.getTargetElement();\n const height = 500;\n const width = 500;\n const size = target ? [width, height] : undefined;\n const oldSize = this.getSize();\n if (size && (!oldSize || !extentEquals(size, oldSize))) {\n this.setSize(size);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (this as any).updateViewportSize_();\n }\n };\n setupDone = true;\n}\n"],"names":["extentEquals"],"mappings":";;;AAKA,IAAI,SAAA,GAAY,KAAA;AAGT,SAAS,gCAAA,GAAmC;AAC/C,EAAA,IAAI,SAAA,EAAW;AACX,IAAA;AAAA,EACJ;AAKA,EAAA,KAAA,CAAM,SAAA,CAAU,aAAa,WAAY;AACrC,IAAA,MAAM,MAAA,GAAS,KAAK,gBAAA,EAAiB;AACrC,IAAA,MAAM,MAAA,GAAS,GAAA;AACf,IAAA,MAAM,KAAA,GAAQ,GAAA;AACd,IAAA,MAAM,IAAA,GAAO,MAAA,GAAS,CAAC,KAAA,EAAO,MAAM,CAAA,GAAI,MAAA;AACxC,IAAA,MAAM,OAAA,GAAU,KAAK,OAAA,EAAQ;AAC7B,IAAA,IAAI,SAAS,CAAC,OAAA,IAAW,CAACA,MAAA,CAAa,IAAA,EAAM,OAAO,CAAA,CAAA,EAAI;AACpD,MAAA,IAAA,CAAK,QAAQ,IAAI,CAAA;AAEjB,MAAC,KAAa,mBAAA,EAAoB;AAAA,IACtC;AAAA,EACJ,CAAA;AACA,EAAA,SAAA,GAAY,IAAA;AAChB;;;;"}