import O from "./Colors.js";
class j extends O {
  constructor(s, o, u, C, g, n, c, v, _, l = {}, f, y, b, i) {
    if (super(u, C, g, v, _), this._manualColor = {}, this._manualColor[y] = l ? l.Overall : null, s != "csv") {
      const d = (e) => {
        h = [...n][e] ? [...n][e].items : [], l != null && l != null && Object.keys(l).forEach((a) => {
          const t = h.filter((r) => r.code === a);
          if (t.length > 0 && t[0].labels) {
            let r;
            f && (r = t[0].labels[f.toUpperCase()]), r ? this._manualColor[r] = l[a] : this._manualColor[t[0].value] = l[a];
          }
        });
      }, x = (e) => e == null ? void 0 : e.map((t) => {
        const r = t.group.label;
        return t.label.includes(r) ? t : {
          ...t,
          label: `${r} - ${t.label}`
        };
      }), I = () => {
        var e;
        return c && c.size > 0 ? c : ((e = i == null ? void 0 : i.metadata) == null ? void 0 : e.measures.length) > 0 ? (i.metadata.measures = x(
          i.metadata.measures
        ), i.metadata.measures) : [];
      }, m = () => {
        h = I(), Object.keys(l).forEach((e) => {
          const a = [...h].filter((t) => t.value === e);
          if (a.length > 0 && a[0].labels) {
            const t = b[e];
            b && t && (this._manualColor[t] = l[e]);
            let r;
            f && (r = a[0].labels[f.toUpperCase()]), r ? this._manualColor[r] = l[e] : this._manualColor[a[0].label] = l[e];
          }
        });
      };
      let h = [];
      const p = o === "line" ? 1 : u === "index" ? 0 : 1;
      n ? n.size == 1 && p == 1 ? _ == "measure" ? d(0) : m() : d(p) : m();
    } else
      this._manualColor = l && l[u] ? l[u] : {};
  }
  getColor(s, o) {
    if (this.colorBy === "index") {
      const u = this._manualColor[s] || this._manualColor[o[this.indexBy]];
      return u || "#555555";
    }
    return this.colorBy === "id" && this._manualColor[s] ? this._manualColor[s] : "#555555";
  }
  getColorByIndex(s) {
  }
  getColorByKey(s) {
    return this._manualColor[s] ? this._manualColor[s] : "#555555";
  }
}
export {
  j as default
};
