import { isUndefined } from "lodash-es";
import { _accessValue as accessValue } from "@dynatrace/strato-components-preview/core";
import { useColorScale } from "./use-color-scale.js";
import { isLegendColoring } from "../types/coloring.js";
const useResolveColor = (defaultColor, props, colorParser) => {
  const isLegendColor = isLegendColoring(props);
  const legendColoring = useColorScale();
  if (!isLegendColor) {
    return props.color ?? defaultColor;
  }
  let colorLegend = defaultColor;
  if (!isUndefined(legendColoring) && colorParser) {
    colorLegend = (item) => {
      const value = accessValue(item, props.valueAccessor);
      if (isUndefined(value)) {
        return defaultColor;
      }
      return colorParser(value) ?? defaultColor;
    };
  }
  return colorLegend;
};
export {
  useResolveColor
};
//# sourceMappingURL=use-resolve-color.js.map
