"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }

var _chunk2BONUUVScjs = require('./chunk-2BONUUVS.cjs');


var _chunkJT5CJFOScjs = require('./chunk-JT5CJFOS.cjs');


var _chunkR6ZWDCX4cjs = require('./chunk-R6ZWDCX4.cjs');


var _chunkOMKDNOX6cjs = require('./chunk-OMKDNOX6.cjs');


var _chunk55BEED5Vcjs = require('./chunk-55BEED5V.cjs');



var _chunkDEWCXJEQcjs = require('./chunk-DEWCXJEQ.cjs');



var _chunkSCFUDB74cjs = require('./chunk-SCFUDB74.cjs');

// src/logger/console.ts
_chunkSCFUDB74cjs.init_cjs_shims.call(void 0, );
var getLogFn = /* @__PURE__ */ _chunkSCFUDB74cjs.__name.call(void 0, (logLevel = _chunkDEWCXJEQcjs.LogLevel.INFO, config = {}, _chalk = _chunkJT5CJFOScjs.getChalk.call(void 0, )) => {
  const colors = !_optionalChain([config, 'access', _2 => _2.colors, 'optionalAccess', _3 => _3.dark]) && !_optionalChain([config, 'access', _4 => _4.colors, 'optionalAccess', _5 => _5["base"]]) && !_optionalChain([config, 'access', _6 => _6.colors, 'optionalAccess', _7 => _7["base"], 'optionalAccess', _8 => _8.dark]) ? _chunk2BONUUVScjs.DEFAULT_COLOR_CONFIG : _optionalChain([config, 'access', _9 => _9.colors, 'optionalAccess', _10 => _10.dark]) && typeof config.colors.dark === "string" ? config.colors : _optionalChain([config, 'access', _11 => _11.colors, 'optionalAccess', _12 => _12["base"], 'optionalAccess', _13 => _13.dark]) && typeof config.colors["base"].dark === "string" ? config.colors["base"].dark : _optionalChain([config, 'access', _14 => _14.colors, 'optionalAccess', _15 => _15["base"]]) ? _optionalChain([config, 'access', _16 => _16.colors, 'optionalAccess', _17 => _17["base"]]) : _chunk2BONUUVScjs.DEFAULT_COLOR_CONFIG;
  const configLogLevel = config.logLevel || process.env.STORM_LOG_LEVEL || _chunkDEWCXJEQcjs.LogLevelLabel.INFO;
  if (logLevel > _chunk55BEED5Vcjs.getLogLevel.call(void 0, configLogLevel) || logLevel <= _chunkDEWCXJEQcjs.LogLevel.SILENT || _chunk55BEED5Vcjs.getLogLevel.call(void 0, configLogLevel) <= _chunkDEWCXJEQcjs.LogLevel.SILENT) {
    return (_) => {
    };
  }
  if (typeof logLevel === "number" && _chunkDEWCXJEQcjs.LogLevel.FATAL >= logLevel) {
    return (message) => {
      console.error(`
${_chalk.gray(_chunkOMKDNOX6cjs.formatTimestamp.call(void 0, ))} ${_chalk.hex(_nullishCoalesce(colors.fatal, () => ( "#7d1a1a")))(`[${_chunkR6ZWDCX4cjs.CONSOLE_ICONS[_chunkDEWCXJEQcjs.LogLevelLabel.FATAL]} Fatal]`)} ${_chalk.bold.whiteBright(formatLogMessage(message))}
`);
    };
  }
  if (typeof logLevel === "number" && _chunkDEWCXJEQcjs.LogLevel.ERROR >= logLevel) {
    return (message) => {
      console.error(`
${_chalk.gray(_chunkOMKDNOX6cjs.formatTimestamp.call(void 0, ))} ${_chalk.hex(_nullishCoalesce(colors.danger, () => ( "#f85149")))(`[${_chunkR6ZWDCX4cjs.CONSOLE_ICONS[_chunkDEWCXJEQcjs.LogLevelLabel.ERROR]} Error]`)} ${_chalk.bold.whiteBright(formatLogMessage(message))}
`);
    };
  }
  if (typeof logLevel === "number" && _chunkDEWCXJEQcjs.LogLevel.WARN >= logLevel) {
    return (message) => {
      console.warn(`
${_chalk.gray(_chunkOMKDNOX6cjs.formatTimestamp.call(void 0, ))} ${_chalk.hex(_nullishCoalesce(colors.warning, () => ( "#e3b341")))(`[${_chunkR6ZWDCX4cjs.CONSOLE_ICONS[_chunkDEWCXJEQcjs.LogLevelLabel.WARN]} Warn]`)} ${_chalk.bold.whiteBright(formatLogMessage(message))}
`);
    };
  }
  if (typeof logLevel === "number" && _chunkDEWCXJEQcjs.LogLevel.SUCCESS >= logLevel) {
    return (message) => {
      console.info(`
${_chalk.gray(_chunkOMKDNOX6cjs.formatTimestamp.call(void 0, ))} ${_chalk.hex(_nullishCoalesce(colors.success, () => ( "#56d364")))(`[${_chunkR6ZWDCX4cjs.CONSOLE_ICONS[_chunkDEWCXJEQcjs.LogLevelLabel.SUCCESS]} Success]`)} ${_chalk.bold.whiteBright(formatLogMessage(message))}
`);
    };
  }
  if (typeof logLevel === "number" && _chunkDEWCXJEQcjs.LogLevel.INFO >= logLevel) {
    return (message) => {
      console.info(`
${_chalk.gray(_chunkOMKDNOX6cjs.formatTimestamp.call(void 0, ))} ${_chalk.hex(_nullishCoalesce(colors.info, () => ( "#58a6ff")))(`[${_chunkR6ZWDCX4cjs.CONSOLE_ICONS[_chunkDEWCXJEQcjs.LogLevelLabel.INFO]} Info]`)} ${_chalk.bold.whiteBright(formatLogMessage(message))}
`);
    };
  }
  if (typeof logLevel === "number" && _chunkDEWCXJEQcjs.LogLevel.DEBUG >= logLevel) {
    return (message) => {
      console.debug(`
${_chalk.gray(_chunkOMKDNOX6cjs.formatTimestamp.call(void 0, ))} ${_chalk.hex(_nullishCoalesce(colors.brand, () => ( "#1fb2a6")))(`[${_chunkR6ZWDCX4cjs.CONSOLE_ICONS[_chunkDEWCXJEQcjs.LogLevelLabel.DEBUG]}  Debug]`)} ${_chalk.bold.whiteBright(formatLogMessage(message))}
`);
    };
  }
  if (typeof logLevel === "number" && _chunkDEWCXJEQcjs.LogLevel.TRACE >= logLevel) {
    return (message) => {
      console.debug(`
${_chalk.gray(_chunkOMKDNOX6cjs.formatTimestamp.call(void 0, ))} ${_chalk.hex(_nullishCoalesce(colors.brand, () => ( "#1fb2a6")))(`[${_chunkR6ZWDCX4cjs.CONSOLE_ICONS[_chunkDEWCXJEQcjs.LogLevelLabel.TRACE]}  Trace]`)} ${_chalk.bold.whiteBright(formatLogMessage(message))}
`);
    };
  }
  return (message) => {
    console.log(`
${_chalk.gray(_chunkOMKDNOX6cjs.formatTimestamp.call(void 0, ))} ${_chalk.hex(_nullishCoalesce(colors.brand, () => ( "#1fb2a6")))(`[${_chunkR6ZWDCX4cjs.CONSOLE_ICONS[_chunkDEWCXJEQcjs.LogLevelLabel.ALL]}  System]`)} ${_chalk.bold.whiteBright(formatLogMessage(message))}
`);
  };
}, "getLogFn");
var writeFatal = /* @__PURE__ */ _chunkSCFUDB74cjs.__name.call(void 0, (message, config) => getLogFn(_chunkDEWCXJEQcjs.LogLevel.FATAL, config)(message), "writeFatal");
var writeError = /* @__PURE__ */ _chunkSCFUDB74cjs.__name.call(void 0, (message, config) => getLogFn(_chunkDEWCXJEQcjs.LogLevel.ERROR, config)(message), "writeError");
var writeWarning = /* @__PURE__ */ _chunkSCFUDB74cjs.__name.call(void 0, (message, config) => getLogFn(_chunkDEWCXJEQcjs.LogLevel.WARN, config)(message), "writeWarning");
var writeInfo = /* @__PURE__ */ _chunkSCFUDB74cjs.__name.call(void 0, (message, config) => getLogFn(_chunkDEWCXJEQcjs.LogLevel.INFO, config)(message), "writeInfo");
var writeSuccess = /* @__PURE__ */ _chunkSCFUDB74cjs.__name.call(void 0, (message, config) => getLogFn(_chunkDEWCXJEQcjs.LogLevel.SUCCESS, config)(message), "writeSuccess");
var writeDebug = /* @__PURE__ */ _chunkSCFUDB74cjs.__name.call(void 0, (message, config) => getLogFn(_chunkDEWCXJEQcjs.LogLevel.DEBUG, config)(message), "writeDebug");
var writeTrace = /* @__PURE__ */ _chunkSCFUDB74cjs.__name.call(void 0, (message, config) => getLogFn(_chunkDEWCXJEQcjs.LogLevel.TRACE, config)(message), "writeTrace");
var writeSystem = /* @__PURE__ */ _chunkSCFUDB74cjs.__name.call(void 0, (message, config) => getLogFn(_chunkDEWCXJEQcjs.LogLevel.ALL, config)(message), "writeSystem");
var getStopwatch = /* @__PURE__ */ _chunkSCFUDB74cjs.__name.call(void 0, (name) => {
  const start = process.hrtime();
  return () => {
    const end = process.hrtime(start);
    console.info(`
>  \u23F1\uFE0F  The${name ? ` ${name}` : ""} process took ${Math.round(end[0] * 1e3 + end[1] / 1e6)}ms to complete

`);
  };
}, "getStopwatch");
var MAX_DEPTH = 4;
var formatLogMessage = /* @__PURE__ */ _chunkSCFUDB74cjs.__name.call(void 0, (message, options = {}, depth = 0) => {
  if (depth > MAX_DEPTH) {
    return "<max depth>";
  }
  const prefix = _nullishCoalesce(options.prefix, () => ( "-"));
  const skip = _nullishCoalesce(options.skip, () => ( []));
  return typeof message === "undefined" || message === null || !message && typeof message !== "boolean" ? "<none>" : typeof message === "string" ? message : Array.isArray(message) ? `
${message.map((item, index) => ` ${prefix}> #${index} = ${formatLogMessage(item, {
    prefix: `${prefix}-`,
    skip
  }, depth + 1)}`).join("\n")}` : typeof message === "object" ? `
${Object.keys(message).filter((key) => !skip.includes(key)).map((key) => ` ${prefix}> ${key} = ${_isFunction(message[key]) ? "<function>" : typeof message[key] === "object" ? formatLogMessage(message[key], {
    prefix: `${prefix}-`,
    skip
  }, depth + 1) : message[key]}`).join("\n")}` : message;
}, "formatLogMessage");
var _isFunction = /* @__PURE__ */ _chunkSCFUDB74cjs.__name.call(void 0, (value) => {
  try {
    return value instanceof Function || typeof value === "function" || !!(_optionalChain([value, 'optionalAccess', _18 => _18.constructor]) && _optionalChain([value, 'optionalAccess', _19 => _19.call]) && _optionalChain([value, 'optionalAccess', _20 => _20.apply]));
  } catch (e) {
    return false;
  }
}, "_isFunction");













exports.getLogFn = getLogFn; exports.writeFatal = writeFatal; exports.writeError = writeError; exports.writeWarning = writeWarning; exports.writeInfo = writeInfo; exports.writeSuccess = writeSuccess; exports.writeDebug = writeDebug; exports.writeTrace = writeTrace; exports.writeSystem = writeSystem; exports.getStopwatch = getStopwatch; exports.formatLogMessage = formatLogMessage;
