import a from '../chunks/index5.mjs';

class Logger {
  level;
  mode;
  levels = {
    debug: 0,
    info: 1,
    success: 1,
    warn: 2,
    error: 3
  };
  constructor(options = {}) {
    this.level = options.level || "info";
    this.mode = options.mode || "text";
    if (options.silent)
      this.mode = "silent";
  }
  shouldLog(level) {
    return this.mode !== "silent" && this.levels[level] >= this.levels[this.level];
  }
  createEntry(level, message, data) {
    return {
      level,
      message,
      timestamp: (/* @__PURE__ */ new Date()).toISOString(),
      data
    };
  }
  output(entry) {
    if (!this.shouldLog(entry.level))
      return;
    if (this.mode === "json") {
      console.log(JSON.stringify(entry));
      return;
    }
    const prefix = this.colorizePrefix(entry.level);
    const dataStr = entry.data ? ` ${JSON.stringify(entry.data)}` : "";
    console.log(`${prefix} ${entry.message}${dataStr}`);
  }
  colorizePrefix(level) {
    const timestamp = (/* @__PURE__ */ new Date()).toISOString();
    const prefix = `[${timestamp}] [${level.toUpperCase()}]`;
    switch (level) {
      case "debug":
        return a.gray(prefix);
      case "info":
        return a.green(prefix);
      case "success":
        return a.cyan(prefix);
      case "warn":
        return a.yellow(prefix);
      case "error":
        return a.red(prefix);
    }
  }
  debug(message, data) {
    this.output(this.createEntry("debug", message, data));
  }
  info(message, data) {
    this.output(this.createEntry("info", message, data));
  }
  success(message, data) {
    this.output(this.createEntry("success", message, data));
  }
  warn(message, data) {
    this.output(this.createEntry("warn", message, data));
  }
  error(message, data) {
    this.output(this.createEntry("error", message, data));
  }
  setLevel(level) {
    this.level = level;
  }
  setMode(mode) {
    this.mode = mode;
  }
  setSilent(silent) {
    this.mode = silent ? "silent" : "text";
  }
}
const logger = new Logger();

const logger$1 = {
  __proto__: null,
  Logger: Logger,
  logger: logger
};

export { logger$1 as a, logger as l };
