(function (_, kotlin_kotlin) {
  'use strict';
  //region block: imports
  var imul = Math.imul;
  var protoOf = kotlin_kotlin.$_$.od;
  var Unit_instance = kotlin_kotlin.$_$.b1;
  var initMetadataForClass = kotlin_kotlin.$_$.pc;
  var initMetadataForObject = kotlin_kotlin.$_$.vc;
  var equals = kotlin_kotlin.$_$.ic;
  var VOID = kotlin_kotlin.$_$.c;
  var StringBuilder_init_$Create$ = kotlin_kotlin.$_$.g2;
  var initMetadataForInterface = kotlin_kotlin.$_$.tc;
  var objectCreate = kotlin_kotlin.$_$.nd;
  var toString = kotlin_kotlin.$_$.ak;
  var hashCode = kotlin_kotlin.$_$.oc;
  var getStringHashCode = kotlin_kotlin.$_$.nc;
  var getBigIntHashCode = kotlin_kotlin.$_$.kc;
  var THROW_CCE = kotlin_kotlin.$_$.vi;
  var getKClassFromExpression = kotlin_kotlin.$_$.he;
  var println = kotlin_kotlin.$_$.bb;
  var Enum = kotlin_kotlin.$_$.mi;
  var Exception = kotlin_kotlin.$_$.oi;
  var noWhenBranchMatchedException = kotlin_kotlin.$_$.uj;
  var Exception_init_$Create$ = kotlin_kotlin.$_$.m2;
  var stackTraceToString = kotlin_kotlin.$_$.xj;
  var split = kotlin_kotlin.$_$.kg;
  var substringBefore = kotlin_kotlin.$_$.ug;
  var substringAfterLast = kotlin_kotlin.$_$.qg;
  var contains = kotlin_kotlin.$_$.bf;
  var numberToLong = kotlin_kotlin.$_$.pb;
  //endregion
  //region block: pre-declaration
  initMetadataForClass(FormattingAppender, 'FormattingAppender');
  initMetadataForObject(DirectLoggerFactory, 'DirectLoggerFactory');
  initMetadataForClass(DefaultMessageFormatter, 'DefaultMessageFormatter', DefaultMessageFormatter);
  function info(message) {
    return this.au(null, null, message);
  }
  function info_0(marker, throwable, message) {
    var tmp = Level_INFO_getInstance();
    return this.bu(tmp, marker, KLogger$info$lambda(message, throwable));
  }
  function warn(message) {
    return this.du(null, null, message);
  }
  function warn_0(marker, throwable, message) {
    var tmp = Level_WARN_getInstance();
    return this.bu(tmp, marker, KLogger$warn$lambda(message, throwable));
  }
  function error(message) {
    return this.fu(null, null, message);
  }
  function error_0(marker, throwable, message) {
    var tmp = Level_ERROR_getInstance();
    return this.bu(tmp, marker, KLogger$error$lambda(message, throwable));
  }
  initMetadataForInterface(KLogger, 'KLogger');
  initMetadataForClass(KLoggingEvent, 'KLoggingEvent');
  initMetadataForClass(KLoggingEventBuilder, 'KLoggingEventBuilder', KLoggingEventBuilder);
  initMetadataForObject(KotlinLogging, 'KotlinLogging');
  initMetadataForClass(Level, 'Level', VOID, Enum);
  initMetadataForClass(KLoggerDirect, 'KLoggerDirect', VOID, VOID, [KLogger]);
  initMetadataForObject(DefaultErrorMessageProducer, 'DefaultErrorMessageProducer');
  initMetadataForClass(ConsoleOutputAppender, 'ConsoleOutputAppender', ConsoleOutputAppender, FormattingAppender);
  initMetadataForClass(KotlinLoggingConfiguration$direct$1);
  initMetadataForObject(KotlinLoggingConfiguration, 'KotlinLoggingConfiguration');
  initMetadataForObject(KLoggerNameResolver, 'KLoggerNameResolver');
  //endregion
  function FormattingAppender() {
  }
  protoOf(FormattingAppender).et = function (loggingEvent) {
    // Inline function 'kotlin.let' call
    var it = KotlinLoggingConfiguration_getInstance().gt_1.it().jt(loggingEvent);
    this.dt(loggingEvent, it);
  };
  function DirectLoggerFactory() {
  }
  protoOf(DirectLoggerFactory).kt = function (name) {
    return new KLoggerDirect(name);
  };
  var DirectLoggerFactory_instance;
  function DirectLoggerFactory_getInstance() {
    return DirectLoggerFactory_instance;
  }
  function prefix($this, level, loggerName) {
    var tmp;
    if ($this.lt_1) {
      tmp = level.z_1 + ': [' + loggerName + '] ';
    } else {
      tmp = '';
    }
    return tmp;
  }
  function throwableToString($this, $receiver) {
    return createThrowableMsg($this, '', $receiver);
  }
  function createThrowableMsg($this, msg, throwable) {
    var $this_0 = $this;
    var msg_0 = msg;
    var throwable_0 = throwable;
    $l$1: do {
      $l$0: do {
        var tmp;
        if (throwable_0 == null || equals(throwable_0.cause, throwable_0)) {
          tmp = msg_0;
        } else {
          var tmp0 = $this_0;
          var tmp1 = msg_0 + ", Caused by: '" + throwable_0.message + "'";
          var tmp2 = throwable_0.cause;
          $this_0 = tmp0;
          msg_0 = tmp1;
          throwable_0 = tmp2;
          continue $l$0;
        }
        return tmp;
      }
       while (false);
    }
     while (true);
  }
  function DefaultMessageFormatter(includePrefix) {
    includePrefix = includePrefix === VOID ? true : includePrefix;
    this.lt_1 = includePrefix;
  }
  protoOf(DefaultMessageFormatter).jt = function (loggingEvent) {
    // Inline function 'kotlin.with' call
    // Inline function 'kotlin.text.buildString' call
    // Inline function 'kotlin.apply' call
    var this_0 = StringBuilder_init_$Create$();
    this_0.q(prefix(this, loggingEvent.mt_1, loggingEvent.ot_1));
    var tmp0_safe_receiver = loggingEvent.nt_1;
    var tmp1_safe_receiver = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.tt();
    if (tmp1_safe_receiver == null)
      null;
    else {
      // Inline function 'kotlin.let' call
      this_0.q(tmp1_safe_receiver);
      this_0.q(' ');
    }
    this_0.q(loggingEvent.pt_1);
    this_0.q(throwableToString(this, loggingEvent.qt_1));
    return this_0.toString();
  };
  function KLogger$info$lambda($message, $throwable) {
    return function ($this$at) {
      $this$at.ut_1 = toStringSafe($message);
      $this$at.vt_1 = $throwable;
      return Unit_instance;
    };
  }
  function KLogger$warn$lambda($message, $throwable) {
    return function ($this$at) {
      $this$at.ut_1 = toStringSafe($message);
      $this$at.vt_1 = $throwable;
      return Unit_instance;
    };
  }
  function KLogger$error$lambda($message, $throwable) {
    return function ($this$at) {
      $this$at.ut_1 = toStringSafe($message);
      $this$at.vt_1 = $throwable;
      return Unit_instance;
    };
  }
  function KLogger() {
  }
  function KLoggingEvent_init_$Init$(level, marker, loggerName, eventBuilder, $this) {
    KLoggingEvent.call($this, level, marker, loggerName, eventBuilder.ut_1, eventBuilder.vt_1, eventBuilder.wt_1);
    return $this;
  }
  function KLoggingEvent_init_$Create$(level, marker, loggerName, eventBuilder) {
    return KLoggingEvent_init_$Init$(level, marker, loggerName, eventBuilder, objectCreate(protoOf(KLoggingEvent)));
  }
  function KLoggingEvent(level, marker, loggerName, message, cause, payload, timestamp) {
    message = message === VOID ? null : message;
    cause = cause === VOID ? null : cause;
    payload = payload === VOID ? null : payload;
    timestamp = timestamp === VOID ? getCurrentTime() : timestamp;
    this.mt_1 = level;
    this.nt_1 = marker;
    this.ot_1 = loggerName;
    this.pt_1 = message;
    this.qt_1 = cause;
    this.rt_1 = payload;
    this.st_1 = timestamp;
  }
  protoOf(KLoggingEvent).toString = function () {
    return 'KLoggingEvent(level=' + this.mt_1.toString() + ', marker=' + toString(this.nt_1) + ', loggerName=' + this.ot_1 + ', message=' + this.pt_1 + ', cause=' + toString(this.qt_1) + ', payload=' + toString(this.rt_1) + ', timestamp=' + this.st_1.toString() + ')';
  };
  protoOf(KLoggingEvent).hashCode = function () {
    var result = this.mt_1.hashCode();
    result = imul(result, 31) + (this.nt_1 == null ? 0 : hashCode(this.nt_1)) | 0;
    result = imul(result, 31) + getStringHashCode(this.ot_1) | 0;
    result = imul(result, 31) + (this.pt_1 == null ? 0 : getStringHashCode(this.pt_1)) | 0;
    result = imul(result, 31) + (this.qt_1 == null ? 0 : hashCode(this.qt_1)) | 0;
    result = imul(result, 31) + (this.rt_1 == null ? 0 : hashCode(this.rt_1)) | 0;
    result = imul(result, 31) + getBigIntHashCode(this.st_1) | 0;
    return result;
  };
  protoOf(KLoggingEvent).equals = function (other) {
    if (this === other)
      return true;
    if (!(other instanceof KLoggingEvent))
      return false;
    var tmp0_other_with_cast = other instanceof KLoggingEvent ? other : THROW_CCE();
    if (!this.mt_1.equals(tmp0_other_with_cast.mt_1))
      return false;
    if (!equals(this.nt_1, tmp0_other_with_cast.nt_1))
      return false;
    if (!(this.ot_1 === tmp0_other_with_cast.ot_1))
      return false;
    if (!(this.pt_1 == tmp0_other_with_cast.pt_1))
      return false;
    if (!equals(this.qt_1, tmp0_other_with_cast.qt_1))
      return false;
    if (!equals(this.rt_1, tmp0_other_with_cast.rt_1))
      return false;
    if (!(this.st_1 === tmp0_other_with_cast.st_1))
      return false;
    return true;
  };
  function KLoggingEventBuilder() {
    this.ut_1 = null;
    this.vt_1 = null;
    this.wt_1 = null;
    this.xt_1 = null;
    this.yt_1 = null;
  }
  function KotlinLogging() {
    KotlinLogging_instance = this;
    var factory = KotlinLoggingConfiguration_getInstance().ht_1;
    if (KotlinLoggingConfiguration_getInstance().ft_1) {
      println('kotlin-logging: initializing... active logger factory: ' + getKClassFromExpression(factory).o());
    }
  }
  protoOf(KotlinLogging).gu = function (func) {
    return this.kt(KLoggerNameResolver_instance.hu(func));
  };
  protoOf(KotlinLogging).kt = function (name) {
    return KotlinLoggingConfiguration_getInstance().ht_1.kt(name);
  };
  var KotlinLogging_instance;
  function KotlinLogging_getInstance() {
    if (KotlinLogging_instance == null)
      new KotlinLogging();
    return KotlinLogging_instance;
  }
  var Level_TRACE_instance;
  var Level_DEBUG_instance;
  var Level_INFO_instance;
  var Level_WARN_instance;
  var Level_ERROR_instance;
  var Level_OFF_instance;
  var Level_entriesInitialized;
  function Level_initEntries() {
    if (Level_entriesInitialized)
      return Unit_instance;
    Level_entriesInitialized = true;
    Level_TRACE_instance = new Level('TRACE', 0, 0, 'TRACE');
    Level_DEBUG_instance = new Level('DEBUG', 1, 10, 'DEBUG');
    Level_INFO_instance = new Level('INFO', 2, 20, 'INFO');
    Level_WARN_instance = new Level('WARN', 3, 30, 'WARN');
    Level_ERROR_instance = new Level('ERROR', 4, 40, 'ERROR');
    Level_OFF_instance = new Level('OFF', 5, 50, 'OFF');
  }
  function Level(name, ordinal, levelInt, levelStr) {
    Enum.call(this, name, ordinal);
    this.ku_1 = levelInt;
    this.lu_1 = levelStr;
  }
  protoOf(Level).mu = function () {
    return this.j3(KotlinLoggingConfiguration_getInstance().gt_1.nu()) >= 0;
  };
  protoOf(Level).toString = function () {
    return this.lu_1;
  };
  function Level_INFO_getInstance() {
    Level_initEntries();
    return Level_INFO_instance;
  }
  function Level_WARN_getInstance() {
    Level_initEntries();
    return Level_WARN_instance;
  }
  function Level_ERROR_getInstance() {
    Level_initEntries();
    return Level_ERROR_instance;
  }
  function KLoggerDirect(name) {
    this.ou_1 = name;
  }
  protoOf(KLoggerDirect).bu = function (level, marker, block) {
    if (this.qu(level, marker)) {
      // Inline function 'kotlin.apply' call
      var this_0 = new KLoggingEventBuilder();
      block(this_0);
      // Inline function 'kotlin.run' call
      if (level.a1_1 !== 5) {
        KotlinLoggingConfiguration_getInstance().gt_1.pu().et(KLoggingEvent_init_$Create$(level, marker, this.ou_1, this_0));
      }
    }
  };
  protoOf(KLoggerDirect).qu = function (level, marker) {
    return level.mu();
  };
  function toStringSafe(_this__u8e3s4) {
    var tmp;
    try {
      tmp = toString(_this__u8e3s4());
    } catch ($p) {
      var tmp_0;
      if ($p instanceof Exception) {
        var e = $p;
        tmp_0 = DefaultErrorMessageProducer_instance.ru(e);
      } else {
        throw $p;
      }
      tmp = tmp_0;
    }
    return tmp;
  }
  function DefaultErrorMessageProducer() {
  }
  protoOf(DefaultErrorMessageProducer).ru = function (e) {
    return 'Log message invocation failed: ' + e.toString();
  };
  var DefaultErrorMessageProducer_instance;
  function DefaultErrorMessageProducer_getInstance() {
    return DefaultErrorMessageProducer_instance;
  }
  function ConsoleOutputAppender() {
    FormattingAppender.call(this);
  }
  protoOf(ConsoleOutputAppender).dt = function (loggingEvent, formattedMessage) {
    switch (loggingEvent.mt_1.a1_1) {
      case 0:
        console.log(formattedMessage);
        break;
      case 1:
        console.log(formattedMessage);
        break;
      case 2:
        console.info(formattedMessage);
        break;
      case 3:
        console.warn(formattedMessage);
        break;
      case 4:
        console.error(formattedMessage);
        break;
      case 5:
        break;
      default:
        noWhenBranchMatchedException();
        break;
    }
  };
  function KotlinLoggingConfiguration$direct$1() {
    this.su_1 = Level_INFO_getInstance();
    this.tu_1 = new DefaultMessageFormatter(true);
    this.uu_1 = new ConsoleOutputAppender();
  }
  protoOf(KotlinLoggingConfiguration$direct$1).nu = function () {
    return this.su_1;
  };
  protoOf(KotlinLoggingConfiguration$direct$1).it = function () {
    return this.tu_1;
  };
  protoOf(KotlinLoggingConfiguration$direct$1).pu = function () {
    return this.uu_1;
  };
  function KotlinLoggingConfiguration() {
    KotlinLoggingConfiguration_instance = this;
    this.ft_1 = resolveStartupMessageDefault();
    var tmp = this;
    tmp.gt_1 = new KotlinLoggingConfiguration$direct$1();
    this.ht_1 = DirectLoggerFactory_instance;
  }
  var KotlinLoggingConfiguration_instance;
  function KotlinLoggingConfiguration_getInstance() {
    if (KotlinLoggingConfiguration_instance == null)
      new KotlinLoggingConfiguration();
    return KotlinLoggingConfiguration_instance;
  }
  function resolveStartupMessageDefault() {
    try {
      var tmp = typeof window !== 'undefined' && (window.KOTLIN_LOGGING_STARTUP_MESSAGE === 'false' || window.KOTLIN_LOGGING_STARTUP_MESSAGE === false);
      var disabledInWindow = (!(tmp == null) ? typeof tmp === 'boolean' : false) ? tmp : THROW_CCE();
      if (disabledInWindow) {
        return false;
      }
      var tmp_0 = typeof process !== 'undefined' && process.env && (process.env.KOTLIN_LOGGING_STARTUP_MESSAGE === 'false' || process.env.KOTLIN_LOGGING_STARTUP_MESSAGE === false);
      var disabledInEnv = (!(tmp_0 == null) ? typeof tmp_0 === 'boolean' : false) ? tmp_0 : THROW_CCE();
      if (disabledInEnv) {
        return false;
      }
      return true;
    } catch ($p) {
      if ($p instanceof Error) {
        var e = $p;
        return true;
      } else {
        throw $p;
      }
    }
  }
  function KLoggerNameResolver() {
  }
  protoOf(KLoggerNameResolver).hu = function (func) {
    var found = false;
    var exception = Exception_init_$Create$();
    var _iterator__ex2g4s = split(stackTraceToString(exception), ['\n']).t();
    while (_iterator__ex2g4s.u()) {
      var line = _iterator__ex2g4s.v();
      if (found) {
        return substringAfterLast(substringAfterLast(substringBefore(line, '.kt'), '.'), '/');
      }
      if (contains(line, 'at KotlinLogging')) {
        found = true;
      }
    }
    return '';
  };
  var KLoggerNameResolver_instance;
  function KLoggerNameResolver_getInstance() {
    return KLoggerNameResolver_instance;
  }
  function getCurrentTime() {
    return numberToLong(Date.now());
  }
  //region block: post-declaration
  protoOf(KLoggerDirect).zt = info;
  protoOf(KLoggerDirect).au = info_0;
  protoOf(KLoggerDirect).cu = warn;
  protoOf(KLoggerDirect).du = warn_0;
  protoOf(KLoggerDirect).eu = error;
  protoOf(KLoggerDirect).fu = error_0;
  //endregion
  //region block: init
  DirectLoggerFactory_instance = new DirectLoggerFactory();
  DefaultErrorMessageProducer_instance = new DefaultErrorMessageProducer();
  KLoggerNameResolver_instance = new KLoggerNameResolver();
  //endregion
  //region block: exports
  _.$_$ = _.$_$ || {};
  _.$_$.a = KotlinLogging_getInstance;
  //endregion
  return _;
}(module.exports, require('./kotlin-kotlin-stdlib.js')));

//# sourceMappingURL=kotlin-logging.js.map
