(function (_, kotlin_kotlin, kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core) {
  'use strict';
  //region block: imports
  var VOID = kotlin_kotlin.$_$.g;
  var Unit_getInstance = kotlin_kotlin.$_$.i6;
  var intercepted = kotlin_kotlin.$_$.gd;
  var get_MODE_CANCELLABLE = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.t2;
  var CancellableContinuationImpl = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.g2;
  var resume = kotlin_kotlin.$_$.zd;
  var resumeWithException = kotlin_kotlin.$_$.yd;
  //endregion
  //region block: pre-declaration
  //endregion
  function EventHandler(handler) {
    // Inline function 'kotlin.js.unsafeCast' call
    // Inline function 'kotlin.js.asDynamic' call
    return handler;
  }
  function EventHandler_0(handler) {
    // Inline function 'kotlin.js.unsafeCast' call
    // Inline function 'kotlin.js.asDynamic' call
    return handler;
  }
  function addEventListener(_this__u8e3s4, type, handler, options) {
    options = options === VOID ? undefined : options;
    _this__u8e3s4.addEventListener(type, handler, options);
  }
  function addEventListener_0(_this__u8e3s4, type, handler, options) {
    options = options === VOID ? undefined : options;
    _this__u8e3s4.addEventListener(type, handler, options);
  }
  function removeEventListener(_this__u8e3s4, type, handler, options) {
    options = options === VOID ? undefined : options;
    _this__u8e3s4.removeEventListener(type, handler, options);
  }
  function removeEventListener_0(_this__u8e3s4, type, handler, options) {
    options = options === VOID ? undefined : options;
    _this__u8e3s4.removeEventListener(type, handler, options);
  }
  function EventType(value) {
    // Inline function 'kotlin.js.unsafeCast' call
    // Inline function 'kotlin.js.asDynamic' call
    return value;
  }
  function BodyInit(value) {
    // Inline function 'kotlin.js.unsafeCast' call
    // Inline function 'kotlin.js.asDynamic' call
    return value;
  }
  function BodyInit_0(value) {
    // Inline function 'kotlin.js.unsafeCast' call
    // Inline function 'kotlin.js.asDynamic' call
    return value;
  }
  function toAbortSignal(_this__u8e3s4) {
    var controller = new AbortController();
    _this__u8e3s4.invokeOnCancellation_kffkqp_k$(toAbortSignal$lambda(controller));
    return controller.signal;
  }
  function toAbortSignal$lambda($controller) {
    return function (it) {
      $controller.abort();
      return Unit_getInstance();
    };
  }
  function fetch_0(input, $completion) {
    return fetch_1(new Request(input), $completion);
  }
  function fetch_1(input, $completion) {
    // Inline function 'kotlinx.coroutines.suspendCancellableCoroutine.<anonymous>' call
    var cancellable = new CancellableContinuationImpl(intercepted($completion), get_MODE_CANCELLABLE());
    cancellable.initCancellability_shqc60_k$();
    // Inline function 'web.http.fetch.<anonymous>' call
    // Inline function 'js.objects.jso' call
    // Inline function 'kotlin.apply' call
    // Inline function 'js.objects.jso' call
    var this_0 = {};
    // Inline function 'kotlin.contracts.contract' call
    // Inline function 'web.http.fetch.<anonymous>.<anonymous>' call
    this_0.signal = toAbortSignal(cancellable);
    var request = new Request(input, this_0);
    // Inline function 'js.promise.catch' call
    var tmp = fetch(request);
    var this_1 = tmp.then(resume$ref(cancellable));
    var onRejected = resumeWithException$ref(cancellable);
    this_1.catch(onRejected);
    return cancellable.getResult_clfhg3_k$();
  }
  function resume$ref($boundThis) {
    var l = function (p0) {
      resume($boundThis, p0);
      return Unit_getInstance();
    };
    l.callableName = 'resume';
    return l;
  }
  function resumeWithException$ref($boundThis) {
    var l = function (p0) {
      resumeWithException($boundThis, p0);
      return Unit_getInstance();
    };
    l.callableName = 'resumeWithException';
    return l;
  }
  //region block: exports
  _.$_$ = _.$_$ || {};
  _.$_$.a = fetch_0;
  _.$_$.b = addEventListener;
  _.$_$.c = addEventListener_0;
  _.$_$.d = removeEventListener_0;
  _.$_$.e = removeEventListener;
  //endregion
  return _;
}(module.exports, require('./kotlin-kotlin-stdlib.js'), require('./kotlinx-coroutines-core.js')));

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