import { _getCanvasColor as getCanvasColor } from "@dynatrace/strato-components-preview/charts";
import { _accessValue as accessValue } from "@dynatrace/strato-components-preview/core";
import { calculateHoveredColor } from "../../../functions/calculate-hovered-color.js";
import { defineColor } from "../../../functions/define-color.js";
const parseRegionDataToGeoJSON = (mapSource, data, regionAccessor, color) => {
  const features = data.reduce((features2, item) => {
    let id = "";
    if (typeof regionAccessor === "function") {
      id = regionAccessor(item);
    } else {
      id = accessValue(item, regionAccessor);
    }
    const feature = mapSource.features.find((region) => region.id === id);
    if (feature !== void 0) {
      const regionColor = defineColor(color, item);
      const canvasColor = getCanvasColor(regionColor);
      const hoveredColor = calculateHoveredColor(canvasColor);
      const { n: name } = feature.properties;
      const feat = {
        ...feature,
        properties: {
          name,
          data: item,
          ...item,
          __color: canvasColor,
          __hoveredColor: hoveredColor
        }
      };
      features2.push(feat);
    }
    return features2;
  }, []);
  return {
    type: "FeatureCollection",
    features
  };
};
export {
  parseRegionDataToGeoJSON
};
//# sourceMappingURL=parse-region-data-to-geo-json.js.map
