var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var set_layers_id_exports = {};
__export(set_layers_id_exports, {
  setLayersId: () => setLayersId
});
module.exports = __toCommonJS(set_layers_id_exports);
var import_react = __toESM(require("react"));
var import_react_is = require("react-is");
var import_BubbleLayer = require("../components/BubbleLayer/BubbleLayer.js");
var import_ChoroplethLayer = require("../components/ChoroplethLayer/ChoroplethLayer.js");
var import_ConnectionLayer = require("../components/ConnectionLayer/ConnectionLayer.js");
var import_DotLayer = require("../components/DotLayer/DotLayer.js");
var import_BubbleLayer2 = require("../slots/BubbleLayer.js");
var import_ChoroplethLayer2 = require("../slots/ChoroplethLayer.js");
var import_ConnectionLayer2 = require("../slots/ConnectionLayer.js");
var import_DotLayer2 = require("../slots/DotLayer.js");
const layers = new WeakMap([
  [import_BubbleLayer2.BubbleLayer, { component: import_BubbleLayer.BubbleLayer, prefix: "bubble" }],
  [import_DotLayer2.DotLayer, { component: import_DotLayer.DotLayer, prefix: "dot" }],
  [import_ChoroplethLayer2.ChoroplethLayer, { component: import_ChoroplethLayer.ChoroplethLayer, prefix: "choropleth" }],
  [import_ConnectionLayer2.ConnectionLayer, { component: import_ConnectionLayer.ConnectionLayer, prefix: "connection" }]
]);
const setLayersId = (children) => {
  const layerIds = [];
  let index = 0;
  const parsedChildren = import_react.default.Children.map(children, (child) => {
    if ((0, import_react_is.isElement)(child)) {
      switch (child.type) {
        case import_BubbleLayer2.BubbleLayer:
        case import_ConnectionLayer2.ConnectionLayer:
        case import_ChoroplethLayer2.ChoroplethLayer:
        case import_DotLayer2.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 };
};
