import { isPlainObject as g } from "../../core/utilities.mjs";
import { LOG_LEVEL as r } from "../levels.mjs";
class u {
  config;
  color;
  defaultStyle = [
    "border-radius: 3px",
    "font-size: 14px",
    "font-weight: bold",
    "color: white",
    "-webkit-text-stroke: .6px black",
    "padding: 2px 5px",
    "margin-right: 2px"
  ].join(";");
  levelColorMap = {
    1: "#00BCD4",
    //cyan
    2: "#f39c12",
    //yellow
    3: "#c0392b",
    //red
    4: "#2ecc71",
    //green
    5: "#7f8c8d"
    //gray
  };
  constructor(e) {
    this.config = e, this.color = this.colorize(e.namespace);
  }
  report(e, o) {
    const { enabled: t, namespace: l } = this.config, { args: i = [], group: a, level: c } = o;
    if (t) {
      const p = this.getConsole(c), h = "color: white; padding-left: 10px;", n = [];
      for (const s of i)
        g(s) ? n.push(JSON.parse(JSON.stringify(s))) : n.push(s);
      p(
        `%c${l}%c${a}%c${e}`,
        `background: ${this.color}; ${this.defaultStyle}`,
        this.getStyle(c),
        h,
        ...n
      );
    }
  }
  reportInfo(e, o, ...t) {
    this.report(e, { level: r.LOG, group: o, args: t });
  }
  reportWarning(e, o, ...t) {
    this.report(e, { level: r.WARN, group: o, args: t });
  }
  reportError(e, o, ...t) {
    this.report(e, { level: r.ERROR, group: o, args: t });
  }
  getOptions() {
    return this.config;
  }
  getStyle(e = r.DEFAULT) {
    return `background: ${this.levelColorMap[e] ?? this.levelColorMap[5]}; ${this.defaultStyle}`;
  }
  getConsole(e) {
    let o = console.log.bind(console);
    switch (e) {
      case r.ERROR:
        o = console.error.bind(console);
        break;
      case r.INFO:
        o = console.info.bind(console);
        break;
      case r.WARN:
        o = console.warn.bind(console);
        break;
    }
    return o;
  }
  colorize(e) {
    let o = 0;
    for (let l = 0; l < e.length; o = e.charCodeAt(l++) + ((o << 5) - o)) ;
    const t = Math.floor(Math.abs(Math.sin(o) * 1e4 % 1 * 16777216)).toString(16);
    return "#" + Array(6 - t.length + 1).join("0") + t;
  }
}
export {
  u as SimpleReporter
};
//# sourceMappingURL=simple.mjs.map
