import x from "./Colors.js";
const c = "#9F9F9F";
class M extends x {
  constructor(e, h, u, i, y, b, C, a, o, s, t) {
    super(u, i, y, b, C), this.colorMap = {}, this._colorBy = h == "line" ? "id" : u;
    const n = (r) => r == null ? void 0 : r.map((p) => {
      const f = p.group.label;
      return p.label.includes(f) ? p : {
        ...p,
        label: `${f} - ${p.label}`
      };
    }), g = () => {
      var r;
      return o && o.size > 0 ? o : ((r = t == null ? void 0 : t.metadata) == null ? void 0 : r.measures.length) > 0 ? (t.metadata.measures = n(t.metadata.measures), t.metadata.measures) : [];
    };
    this._indexBy && (a == null ? void 0 : a.size) > 0 && [...a].forEach((r) => {
      r && r.items && r.items.forEach((l) => {
        s && l.labels && l.labels[s.toUpperCase()] ? this.colorMap[l.labels[s.toUpperCase()]] = l.categoryStyle : this.colorMap[l.value] = l.categoryStyle;
      });
    }), o && (o = g(), [...o].forEach((r) => {
      r && r.styles && (s && r.labels && r.labels[s.toUpperCase()] ? this.colorMap[r.labels[s.toUpperCase()]] = r.styles : this.colorMap[r.label] = r.styles);
    }));
  }
  getColor(e, h) {
    return this._colorBy === "index" ? this.colorMap[h[this._indexBy]] ? this.colorMap[h[this._indexBy]].color : c : this.colorMap[e] ? this.colorMap[e].color : c;
  }
  getColorByIndex(e) {
    return this.colorMap[e] ? this.colorMap[e].color : c;
  }
  getColorByKey(e) {
    return this.colorMap[e] ? this.colorMap[e].color : c;
  }
}
export {
  M as default
};
