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_categorical_scale_exports = {};
__export(build_categorical_scale_exports, {
  buildCategoricalScale: () => buildCategoricalScale
});
module.exports = __toCommonJS(build_categorical_scale_exports);
var import_d3_scale = require("d3-scale");
var import_lodash_es = require("lodash");
var import_charts = require("@dynatrace/strato-components-preview/charts");
var import_constants = require("../constants.js");
const buildCategoricalScale = (categories, colorPalette) => {
  const colors = [];
  if ((0, import_charts._isCustomColorPalette)(colorPalette)) {
    categories.forEach((categoryName, index) => {
      const color = index < colorPalette.length ? colorPalette[index] : import_constants.DEFAULT_BASIC_SHAPE_COLOR_TOKEN.Default;
      colors.push(color);
    });
    if (categories.length < colorPalette.length) {
      colors.push(import_constants.DEFAULT_BASIC_SHAPE_COLOR_TOKEN.Default);
    }
  } else {
    categories.forEach((dataName) => {
      const colorToken = import_charts._colorPaletteMap[colorPalette][dataName];
      if (!(0, import_lodash_es.isUndefined)(colorToken)) {
        colors.push(colorToken.Default);
      }
    });
  }
  return (0, import_d3_scale.scaleOrdinal)(categories, colors);
};
