import React from "react";
import { isElement } from "react-is";
import { BubbleLayer as _BubbleLayer } from "../components/BubbleLayer/BubbleLayer.js";
import { ChoroplethLayer as _ChoroplethLayer } from "../components/ChoroplethLayer/ChoroplethLayer.js";
import { ConnectionLayer as _ConnectionLayer } from "../components/ConnectionLayer/ConnectionLayer.js";
import { DotLayer as _DotLayer } from "../components/DotLayer/DotLayer.js";
import { BubbleLayer } from "../slots/BubbleLayer.js";
import { ChoroplethLayer } from "../slots/ChoroplethLayer.js";
import { ConnectionLayer } from "../slots/ConnectionLayer.js";
import { DotLayer } from "../slots/DotLayer.js";
const layers = new WeakMap([
  [BubbleLayer, { component: _BubbleLayer, prefix: "bubble" }],
  [DotLayer, { component: _DotLayer, prefix: "dot" }],
  [ChoroplethLayer, { component: _ChoroplethLayer, prefix: "choropleth" }],
  [ConnectionLayer, { component: _ConnectionLayer, prefix: "connection" }]
]);
const setLayersId = (children) => {
  const layerIds = [];
  let index = 0;
  const parsedChildren = React.Children.map(children, (child) => {
    if (isElement(child)) {
      switch (child.type) {
        case BubbleLayer:
        case ConnectionLayer:
        case ChoroplethLayer:
        case DotLayer: {
          const layer = layers.get(child.type);
          const layerId = `${layer?.prefix}-${index}`;
          index += 1;
          layerIds.push(layerId);
          const newProps = {
            ...child.props,
            layerId
          };
          return {
            ...child,
            key: layerId,
            props: newProps,
            type: layer?.component
          };
        }
        default: {
          return child;
        }
      }
    }
    return child;
  });
  return { layerIds, parsedChildren };
};
export {
  setLayersId
};
//# sourceMappingURL=set-layers-id.js.map
