(function (_, kotlin_io_ktor_ktor_utils, kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core, kotlin_kotlin) {
  'use strict';
  //region block: imports
  var LockFreeLinkedListNode = kotlin_io_ktor_ktor_utils.$_$.f;
  var DisposableHandle = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.u1;
  var initMetadataForClass = kotlin_kotlin.$_$.pc;
  var VOID = kotlin_kotlin.$_$.c;
  var CopyOnWriteHashMap = kotlin_io_ktor_ktor_utils.$_$.c;
  var THROW_CCE = kotlin_kotlin.$_$.vi;
  var equals = kotlin_kotlin.$_$.ic;
  var addSuppressed = kotlin_kotlin.$_$.ij;
  var Unit_instance = kotlin_kotlin.$_$.b1;
  var protoOf = kotlin_kotlin.$_$.od;
  //endregion
  //region block: pre-declaration
  initMetadataForClass(HandlerRegistration, 'HandlerRegistration', VOID, LockFreeLinkedListNode, [DisposableHandle]);
  initMetadataForClass(Events, 'Events', Events);
  initMetadataForClass(EventDefinition, 'EventDefinition', EventDefinition);
  //endregion
  function HandlerRegistration() {
  }
  function Events() {
    this.c4j_1 = new CopyOnWriteHashMap();
  }
  protoOf(Events).d4j = function (definition, value) {
    var exception = null;
    var tmp0_safe_receiver = this.c4j_1.g42(definition);
    if (tmp0_safe_receiver == null)
      null;
    else {
      // Inline function 'io.ktor.util.internal.LockFreeLinkedListHead.forEach' call
      var tmp = tmp0_safe_receiver.m36();
      var cur = tmp instanceof LockFreeLinkedListNode ? tmp : THROW_CCE();
      while (!equals(cur, tmp0_safe_receiver)) {
        if (cur instanceof HandlerRegistration) {
          var registration = cur;
          try {
            var tmp_0 = registration.f4j_1;
            (typeof tmp_0 === 'function' ? tmp_0 : THROW_CCE())(value);
          } catch ($p) {
            if ($p instanceof Error) {
              var e = $p;
              var tmp0_safe_receiver_0 = exception;
              var tmp_1;
              if (tmp0_safe_receiver_0 == null) {
                tmp_1 = null;
              } else {
                addSuppressed(tmp0_safe_receiver_0, e);
                tmp_1 = Unit_instance;
              }
              if (tmp_1 == null) {
                // Inline function 'kotlin.run' call
                exception = e;
              }
            } else {
              throw $p;
            }
          }
        }
        cur = cur.e43();
      }
    }
    var tmp1_safe_receiver = exception;
    if (tmp1_safe_receiver == null)
      null;
    else {
      // Inline function 'kotlin.let' call
      throw tmp1_safe_receiver;
    }
  };
  function EventDefinition() {
  }
  //region block: exports
  _.$_$ = _.$_$ || {};
  _.$_$.a = EventDefinition;
  _.$_$.b = Events;
  //endregion
  return _;
}(module.exports, require('./ktor-ktor-utils.js'), require('./kotlinx-coroutines-core.js'), require('./kotlin-kotlin-stdlib.js')));

//# sourceMappingURL=ktor-ktor-events.js.map
