var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var build_scale_from_legend_config_exports = {};
__export(build_scale_from_legend_config_exports, {
  buildScaleFromLegendConfig: () => buildScaleFromLegendConfig,
  isCategoricalLegend: () => isCategoricalLegend,
  isSequentialLegend: () => isSequentialLegend,
  isThresholdLegend: () => isThresholdLegend
});
module.exports = __toCommonJS(build_scale_from_legend_config_exports);
var import_charts = require("@dynatrace/strato-components-preview/charts");
var import_build_categorical_scale = require("./build-categorical-scale.js");
var import_constants = require("../constants.js");
const isThresholdLegend = (legendConfig) => legendConfig.type === "threshold";
const isSequentialLegend = (legendConfig) => legendConfig.type === "sequential";
const isCategoricalLegend = (legendConfig) => legendConfig.type === "categorical";
const buildScaleFromLegendConfig = (mapLegendConfig) => {
  if (isSequentialLegend(mapLegendConfig)) {
    const { min, max, colorPalette } = mapLegendConfig;
    return (0, import_charts._buildQuantizeScaleFromColorPalette)(min, max, colorPalette);
  } else if (isThresholdLegend(mapLegendConfig)) {
    const { ranges } = mapLegendConfig;
    return (0, import_charts._buildThresholdScaleFromRanges)(ranges, import_constants.DEFAULT_RANGE_COLOR);
  } else if (isCategoricalLegend(mapLegendConfig)) {
    const { categories, colorPalette } = mapLegendConfig;
    return (0, import_build_categorical_scale.buildCategoricalScale)(categories, colorPalette);
  }
};
