(function (_, kotlin_kotlin, kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core, kotlin_org_jetbrains_kotlin_wrappers_kotlin_js_core) {
  'use strict';
  //region block: imports
  var intercepted = kotlin_kotlin.$_$.ia;
  var CancellableContinuationImpl = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.l1;
  var Unit_instance = kotlin_kotlin.$_$.b1;
  var Companion_instance = kotlin_kotlin.$_$.w;
  var _Result___init__impl__xyqfz8 = kotlin_kotlin.$_$.y3;
  var toJsError = kotlin_org_jetbrains_kotlin_wrappers_kotlin_js_core.$_$.a;
  var createFailure = kotlin_kotlin.$_$.mj;
  //endregion
  //region block: pre-declaration
  //endregion
  function awaitPromiseLike(promise, $completion) {
    var cancellable = new CancellableContinuationImpl(intercepted($completion), 1);
    cancellable.b2w();
    // Inline function 'js.promise.PromiseLike.thenTo' call
    thenToContinuation(promise, cancellable);
    return cancellable.c2w();
  }
  function thenToContinuation(promise, continuation) {
    var tmp = thenToContinuation$lambda(continuation);
    promise.then(tmp, thenToContinuation$lambda_0(continuation));
  }
  function thenToContinuation$lambda($continuation) {
    return function (it) {
      // Inline function 'kotlin.coroutines.resume' call
      var this_0 = $continuation;
      // Inline function 'kotlin.Companion.success' call
      var tmp$ret$1 = _Result___init__impl__xyqfz8(it);
      this_0.p9(tmp$ret$1);
      return null;
    };
  }
  function thenToContinuation$lambda_0($continuation) {
    return function (it) {
      var tmp0 = $continuation;
      // Inline function 'js.errors.toThrowable' call
      // Inline function 'kotlin.coroutines.resumeWithException' call
      // Inline function 'kotlin.Companion.failure' call
      var exception = toJsError(it);
      var tmp$ret$2 = _Result___init__impl__xyqfz8(createFailure(exception));
      tmp0.p9(tmp$ret$2);
      return null;
    };
  }
  //region block: exports
  _.$_$ = _.$_$ || {};
  _.$_$.a = awaitPromiseLike;
  _.$_$.b = thenToContinuation;
  //endregion
  return _;
}(module.exports, require('./kotlin-kotlin-stdlib.js'), require('./kotlinx-coroutines-core.js'), require('./kotlin-js-core.js')));

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