import {
  protoOf180f3jzyo7rfj as protoOf,
  initMetadataForClassbxx6q50dy2s7 as initMetadataForClass,
  plus1ogy4liedzq5j as plus,
  toMutableSetjdpdbr9jsqq8 as toMutableSet,
  ArrayList_init_$Create$37gc04va6yfo2 as ArrayList_init_$Create$,
  Unit_instancev9v8hjid95df as Unit_instance,
  VOID3gxj6tk5isa35 as VOID,
  Exceptiondt2hlxn7j7vw as Exception,
  Exception_init_$Init$2jzug8qe36bgh as Exception_init_$Init$,
  captureStack1fzi4aczwc4hg as captureStack,
  toString1pkumu07cwy4m as toString,
  CoroutineImpl2sn3kjnwmfr10 as CoroutineImpl,
  THROW_CCE2g6jy02ryeudk as THROW_CCE,
  get_COROUTINE_SUSPENDED3ujt3p13qm4iy as get_COROUTINE_SUSPENDED,
  initMetadataForLambda3af3he42mmnh as initMetadataForLambda,
  isInterface3d6p8outrmvmk as isInterface,
  Collection1k04j3hzsbod0 as Collection,
  emptyList1g2z5xcrvp2zy as emptyList,
  getKClassFromExpression348iqjl4fnx2f as getKClassFromExpression,
  Unitkvevlwgzwiuc as Unit,
  ensureNotNull1e947j3ixpazm as ensureNotNull,
  equals2au1ep9vhcato as equals,
  joinToString1cxrrlmo0chqs as joinToString,
  initMetadataForCoroutine1i7lbatuf5bnt as initMetadataForCoroutine,
  collectionSizeOrDefault36dulx8yinfqm as collectionSizeOrDefault,
  ArrayList_init_$Create$2byt5m5yn22yy as ArrayList_init_$Create$_0,
  PrimitiveClasses_getInstanceds06xwqrwfdm as PrimitiveClasses_getInstance,
  getKClass3t8tygqu4lcxf as getKClass,
  setOf45ia9pnfhe90 as setOf,
  KtList3hktaavzmj137 as KtList,
  arrayOf1akklvh2at202 as arrayOf,
  createKType31ecntyyaay3k as createKType,
  createInvariantKTypeProjection3h5364czc0a8w as createInvariantKTypeProjection,
  endsWith3cq61xxngobwh as endsWith,
  initMetadataForObject1cxne3s9w65el as initMetadataForObject,
  LinkedHashSet_init_$Create$t7gzf3ihb6pk as LinkedHashSet_init_$Create$,
} from './kotlin-kotlin-stdlib.mjs';
import {
  Application_getInstance2wn6cl3kv21f0 as Application_getInstance,
  contentType317fn4f991q9a as contentType,
  Companion_getInstance1co6rysm0hsdc as Companion_getInstance,
  OutgoingContent3t2ohmyam9o76 as OutgoingContent,
  contentType2zzm38yxo3syt as contentType_0,
  charset1dribv3ku48b1 as charset,
  NullBody_instance3jaj4elqoxne0 as NullBody_instance,
  HttpStatusCode3o1wkms10pg4k as HttpStatusCode,
  ContentType1svlpabm9v7iz as ContentType,
} from './ktor-ktor-http.mjs';
import {
  register$default3nfw6tn7zx41g as register$default,
  Configuration20xgygxdzhlk5 as Configuration,
  suitableCharset1jgdcpdzbzgzn as suitableCharset,
  deserialize3m9mw3rgwyyjs as deserialize,
} from './ktor-ktor-serialization.mjs';
import {
  Charsets_getInstanceqkyjyusuh1b0 as Charsets_getInstance,
  ByteReadChannel2wzou76jce72d as ByteReadChannel,
} from './ktor-ktor-io.mjs';
import {
  TransformRequestBodyContext3ll40opqaho0d as TransformRequestBodyContext,
  HttpRequestBuilder15f2nnx9sjuv1 as HttpRequestBuilder,
  TransformResponseBodyContext1axf7xx6ifwbj as TransformResponseBodyContext,
  HttpResponse1532ob1hsse1y as HttpResponse,
  get_request3dwcif5y0fvf1 as get_request,
  accept2gi3b7wj4jds9 as accept,
  EmptyContent_getInstance3cnuw24sjv05w as EmptyContent_getInstance,
  ClientSSESession332rusa1q4gim as ClientSSESession,
  ClientSSESessionWithDeserialization37nab8162l18r as ClientSSESessionWithDeserialization,
  createClientPluginjwpvufjows5r as createClientPlugin,
} from './ktor-ktor-client-core.mjs';
import {
  TypeInfo2nbxsuf4v8os2 as TypeInfo,
  KtorSimpleLogger1xdphsp5l4e48 as KtorSimpleLogger,
  AttributeKey3aq8ytwgx54f7 as AttributeKey,
} from './ktor-ktor-utils.mjs';
//region block: imports
//endregion
//region block: pre-declaration
initMetadataForClass(ConverterRegistration, 'ConverterRegistration');
initMetadataForClass(ContentNegotiationConfig$defaultMatcher$1);
initMetadataForClass(ContentNegotiationConfig, 'ContentNegotiationConfig', ContentNegotiationConfig, VOID, [Configuration]);
initMetadataForClass(ContentConverterException, 'ContentConverterException', VOID, Exception);
initMetadataForLambda(ContentNegotiation$lambda$slambda, CoroutineImpl, VOID, [4]);
initMetadataForLambda(ContentNegotiation$lambda$slambda_1, CoroutineImpl, VOID, [4]);
initMetadataForCoroutine($invoke$convertRequestCOROUTINE$, CoroutineImpl);
initMetadataForCoroutine($invoke$convertResponseCOROUTINE$, CoroutineImpl);
initMetadataForObject(JsonContentTypeMatcher, 'JsonContentTypeMatcher');
//endregion
function get_LOGGER() {
  _init_properties_ContentNegotiation_kt__o183go();
  return LOGGER;
}
var LOGGER;
function get_DefaultCommonIgnoredTypes() {
  _init_properties_ContentNegotiation_kt__o183go();
  return DefaultCommonIgnoredTypes;
}
var DefaultCommonIgnoredTypes;
function get_ExcludedContentTypes() {
  _init_properties_ContentNegotiation_kt__o183go();
  return ExcludedContentTypes;
}
var ExcludedContentTypes;
function get_ContentNegotiation() {
  _init_properties_ContentNegotiation_kt__o183go();
  return ContentNegotiation;
}
var ContentNegotiation;
function ConverterRegistration(converter, contentTypeToSend, contentTypeMatcher) {
  this.c4m_1 = converter;
  this.d4m_1 = contentTypeToSend;
  this.e4m_1 = contentTypeMatcher;
}
function defaultMatcher($this, pattern) {
  return new ContentNegotiationConfig$defaultMatcher$1(pattern);
}
function ContentNegotiationConfig$defaultMatcher$1($pattern) {
  this.f4m_1 = $pattern;
}
protoOf(ContentNegotiationConfig$defaultMatcher$1).g4m = function (contentType) {
  return contentType.t2l(this.f4m_1);
};
function ContentNegotiationConfig() {
  this.h4m_1 = toMutableSet(plus(get_DefaultIgnoredTypes(), get_DefaultCommonIgnoredTypes()));
  var tmp = this;
  // Inline function 'kotlin.collections.mutableListOf' call
  tmp.i4m_1 = ArrayList_init_$Create$();
  this.j4m_1 = null;
}
protoOf(ContentNegotiationConfig).j3b = function (contentType, converter, configuration) {
  var matcher = contentType.t2l(Application_getInstance().z2j_1) ? JsonContentTypeMatcher_instance : defaultMatcher(this, contentType);
  this.k4m(contentType, converter, matcher, configuration);
};
protoOf(ContentNegotiationConfig).k4m = function (contentTypeToSend, converter, contentTypeMatcher, configuration) {
  // Inline function 'kotlin.apply' call
  configuration(converter);
  var registration = new ConverterRegistration(converter, contentTypeToSend, contentTypeMatcher);
  this.i4m_1.e1(registration);
};
function ContentConverterException(message) {
  Exception_init_$Init$(message, this);
  captureStack(this, ContentConverterException);
}
function ContentNegotiationConfig$_init_$ref_1ne3ob() {
  var l = function () {
    return new ContentNegotiationConfig();
  };
  l.callableName = '<init>';
  return l;
}
function ContentNegotiation$lambda($this$createClientPlugin) {
  _init_properties_ContentNegotiation_kt__o183go();
  var registrations = $this$createClientPlugin.z3n_1.i4m_1;
  var ignoredTypes = $this$createClientPlugin.z3n_1.h4m_1;
  $this$createClientPlugin.y45(ContentNegotiation$lambda$slambda_0(registrations, $this$createClientPlugin, ignoredTypes, null));
  $this$createClientPlugin.l3w(ContentNegotiation$lambda$slambda_2(ignoredTypes, registrations, $this$createClientPlugin, null));
  return Unit_instance;
}
function ContentNegotiation$lambda$convertRequest$lambda(it) {
  _init_properties_ContentNegotiation_kt__o183go();
  return toString(it.c4m_1);
}
function invoke$convertRequest(registrations, $this_createClientPlugin, ignoredTypes, request, body, $completion) {
  var tmp = new $invoke$convertRequestCOROUTINE$(registrations, $this_createClientPlugin, ignoredTypes, request, body, $completion);
  tmp.l8_1 = Unit_instance;
  tmp.m8_1 = null;
  return tmp.r8();
}
function invoke$convertResponse(ignoredTypes, registrations, $this_createClientPlugin, requestUrl, info, body, responseContentType, charset, $completion) {
  charset = charset === VOID ? Charsets_getInstance().o1q_1 : charset;
  var tmp = new $invoke$convertResponseCOROUTINE$(ignoredTypes, registrations, $this_createClientPlugin, requestUrl, info, body, responseContentType, charset, $completion);
  tmp.l8_1 = Unit_instance;
  tmp.m8_1 = null;
  return tmp.r8();
}
function ContentNegotiation$lambda$slambda($registrations, $this_createClientPlugin, $ignoredTypes, resultContinuation) {
  this.c4o_1 = $registrations;
  this.d4o_1 = $this_createClientPlugin;
  this.e4o_1 = $ignoredTypes;
  CoroutineImpl.call(this, resultContinuation);
}
protoOf(ContentNegotiation$lambda$slambda).j4o = function ($this$transformRequestBody, request, body, _unused_var__etf5q3, $completion) {
  var tmp = this.k4o($this$transformRequestBody, request, body, _unused_var__etf5q3, $completion);
  tmp.l8_1 = Unit_instance;
  tmp.m8_1 = null;
  return tmp.r8();
};
protoOf(ContentNegotiation$lambda$slambda).q3x = function (p1, p2, p3, p4, $completion) {
  var tmp = p1 instanceof TransformRequestBodyContext ? p1 : THROW_CCE();
  var tmp_0 = p2 instanceof HttpRequestBuilder ? p2 : THROW_CCE();
  var tmp_1 = !(p3 == null) ? p3 : THROW_CCE();
  return this.j4o(tmp, tmp_0, tmp_1, (p4 == null ? true : p4 instanceof TypeInfo) ? p4 : THROW_CCE(), $completion);
};
protoOf(ContentNegotiation$lambda$slambda).r8 = function () {
  var suspendResult = this.l8_1;
  $sm: do
    try {
      var tmp = this.j8_1;
      switch (tmp) {
        case 0:
          this.k8_1 = 2;
          this.j8_1 = 1;
          suspendResult = invoke$convertRequest(this.c4o_1, this.d4o_1, this.e4o_1, this.g4o_1, this.h4o_1, this);
          if (suspendResult === get_COROUTINE_SUSPENDED()) {
            return suspendResult;
          }

          continue $sm;
        case 1:
          return suspendResult;
        case 2:
          throw this.m8_1;
      }
    } catch ($p) {
      var e = $p;
      if (this.k8_1 === 2) {
        throw e;
      } else {
        this.j8_1 = this.k8_1;
        this.m8_1 = e;
      }
    }
   while (true);
};
protoOf(ContentNegotiation$lambda$slambda).k4o = function ($this$transformRequestBody, request, body, _unused_var__etf5q3, completion) {
  var i = new ContentNegotiation$lambda$slambda(this.c4o_1, this.d4o_1, this.e4o_1, completion);
  i.f4o_1 = $this$transformRequestBody;
  i.g4o_1 = request;
  i.h4o_1 = body;
  i.i4o_1 = _unused_var__etf5q3;
  return i;
};
function ContentNegotiation$lambda$slambda_0($registrations, $this_createClientPlugin, $ignoredTypes, resultContinuation) {
  var i = new ContentNegotiation$lambda$slambda($registrations, $this_createClientPlugin, $ignoredTypes, resultContinuation);
  var l = function ($this$transformRequestBody, request, body, _unused_var__etf5q3, $completion) {
    return i.j4o($this$transformRequestBody, request, body, _unused_var__etf5q3, $completion);
  };
  l.$arity = 4;
  return l;
}
function ContentNegotiation$lambda$slambda_1($ignoredTypes, $registrations, $this_createClientPlugin, resultContinuation) {
  this.t4o_1 = $ignoredTypes;
  this.u4o_1 = $registrations;
  this.v4o_1 = $this_createClientPlugin;
  CoroutineImpl.call(this, resultContinuation);
}
protoOf(ContentNegotiation$lambda$slambda_1).o3x = function ($this$transformResponseBody, response, body, info, $completion) {
  var tmp = this.p3x($this$transformResponseBody, response, body, info, $completion);
  tmp.l8_1 = Unit_instance;
  tmp.m8_1 = null;
  return tmp.r8();
};
protoOf(ContentNegotiation$lambda$slambda_1).q3x = function (p1, p2, p3, p4, $completion) {
  var tmp = p1 instanceof TransformResponseBodyContext ? p1 : THROW_CCE();
  var tmp_0 = p2 instanceof HttpResponse ? p2 : THROW_CCE();
  var tmp_1 = (!(p3 == null) ? isInterface(p3, ByteReadChannel) : false) ? p3 : THROW_CCE();
  return this.o3x(tmp, tmp_0, tmp_1, p4 instanceof TypeInfo ? p4 : THROW_CCE(), $completion);
};
protoOf(ContentNegotiation$lambda$slambda_1).r8 = function () {
  var suspendResult = this.l8_1;
  $sm: do
    try {
      var tmp = this.j8_1;
      switch (tmp) {
        case 0:
          this.k8_1 = 2;
          var tmp0_elvis_lhs = contentType(this.x4o_1);
          var tmp_0;
          if (tmp0_elvis_lhs == null) {
            return null;
          } else {
            tmp_0 = tmp0_elvis_lhs;
          }

          var contentType_0 = tmp_0;
          var charset = suitableCharset(get_request(this.x4o_1).d2q());
          this.j8_1 = 1;
          suspendResult = invoke$convertResponse(this.t4o_1, this.u4o_1, this.v4o_1, get_request(this.x4o_1).f3h(), this.z4o_1, this.y4o_1, contentType_0, charset, this);
          if (suspendResult === get_COROUTINE_SUSPENDED()) {
            return suspendResult;
          }

          continue $sm;
        case 1:
          return suspendResult;
        case 2:
          throw this.m8_1;
      }
    } catch ($p) {
      var e = $p;
      if (this.k8_1 === 2) {
        throw e;
      } else {
        this.j8_1 = this.k8_1;
        this.m8_1 = e;
      }
    }
   while (true);
};
protoOf(ContentNegotiation$lambda$slambda_1).p3x = function ($this$transformResponseBody, response, body, info, completion) {
  var i = new ContentNegotiation$lambda$slambda_1(this.t4o_1, this.u4o_1, this.v4o_1, completion);
  i.w4o_1 = $this$transformResponseBody;
  i.x4o_1 = response;
  i.y4o_1 = body;
  i.z4o_1 = info;
  return i;
};
function ContentNegotiation$lambda$slambda_2($ignoredTypes, $registrations, $this_createClientPlugin, resultContinuation) {
  var i = new ContentNegotiation$lambda$slambda_1($ignoredTypes, $registrations, $this_createClientPlugin, resultContinuation);
  var l = function ($this$transformResponseBody, response, body, info, $completion) {
    return i.o3x($this$transformResponseBody, response, body, info, $completion);
  };
  l.$arity = 4;
  return l;
}
function $invoke$convertRequestCOROUTINE$(registrations, $this_createClientPlugin, ignoredTypes, request, body, resultContinuation) {
  CoroutineImpl.call(this, resultContinuation);
  this.t4m_1 = registrations;
  this.u4m_1 = $this_createClientPlugin;
  this.v4m_1 = ignoredTypes;
  this.w4m_1 = request;
  this.x4m_1 = body;
}
protoOf($invoke$convertRequestCOROUTINE$).r8 = function () {
  var suspendResult = this.l8_1;
  $sm: do
    try {
      var tmp = this.j8_1;
      switch (tmp) {
        case 0:
          this.k8_1 = 7;
          var tmp_0;
          if (this.w4m_1.s3f_1.q2c(get_ExcludedContentTypes())) {
            var excluded = this.w4m_1.s3f_1.o2c(get_ExcludedContentTypes());
            var tmp0 = this.t4m_1;
            var destination = ArrayList_init_$Create$();
            var _iterator__ex2g4s = tmp0.t();
            while (_iterator__ex2g4s.u()) {
              var element = _iterator__ex2g4s.v();
              var tmp$ret$0;
              l$ret$1: do {
                var tmp_1;
                if (isInterface(excluded, Collection)) {
                  tmp_1 = excluded.r();
                } else {
                  tmp_1 = false;
                }
                if (tmp_1) {
                  tmp$ret$0 = true;
                  break l$ret$1;
                }
                var _iterator__ex2g4s_0 = excluded.t();
                while (_iterator__ex2g4s_0.u()) {
                  var element_0 = _iterator__ex2g4s_0.v();
                  if (element.d4m_1.t2l(element_0)) {
                    tmp$ret$0 = false;
                    break l$ret$1;
                  }
                }
                tmp$ret$0 = true;
              }
               while (false);
              if (tmp$ret$0) {
                destination.e1(element);
              }
            }
            tmp_0 = destination;
          } else {
            tmp_0 = this.t4m_1;
          }

          var requestRegistrations = tmp_0;
          var tmp0_elvis_lhs = this.w4m_1.p3f_1.v2e('Accept');
          var acceptHeaders = tmp0_elvis_lhs == null ? emptyList() : tmp0_elvis_lhs;
          var _iterator__ex2g4s_1 = requestRegistrations.t();
          while (_iterator__ex2g4s_1.u()) {
            var element_1 = _iterator__ex2g4s_1.v();
            var tmp$ret$2;
            l$ret$3: do {
              var tmp_2;
              if (isInterface(acceptHeaders, Collection)) {
                tmp_2 = acceptHeaders.r();
              } else {
                tmp_2 = false;
              }
              if (tmp_2) {
                tmp$ret$2 = true;
                break l$ret$3;
              }
              var _iterator__ex2g4s_2 = acceptHeaders.t();
              while (_iterator__ex2g4s_2.u()) {
                var element_2 = _iterator__ex2g4s_2.v();
                if (Companion_getInstance().cm(element_2).t2l(element_1.d4m_1)) {
                  tmp$ret$2 = false;
                  break l$ret$3;
                }
              }
              tmp$ret$2 = true;
            }
             while (false);
            if (tmp$ret$2) {
              var qValue = this.u4m_1.z3n_1.j4m_1;
              var contentTypeToSend = qValue == null ? element_1.d4m_1 : element_1.d4m_1.r2l('q', qValue.toString());
              get_LOGGER().h2j('Adding Accept=' + contentTypeToSend.toString() + ' header for ' + this.w4m_1.n3f_1.toString());
              accept(this.w4m_1, contentTypeToSend);
            }
          }

          var tmp_3;
          var tmp_4 = this.x4m_1;
          if (tmp_4 instanceof OutgoingContent) {
            tmp_3 = true;
          } else {
            var tmp0_0 = this.v4m_1;
            var tmp$ret$4;
            l$ret$5: do {
              var tmp_5;
              if (isInterface(tmp0_0, Collection)) {
                tmp_5 = tmp0_0.r();
              } else {
                tmp_5 = false;
              }
              if (tmp_5) {
                tmp$ret$4 = false;
                break l$ret$5;
              }
              var _iterator__ex2g4s_3 = tmp0_0.t();
              while (_iterator__ex2g4s_3.u()) {
                var element_3 = _iterator__ex2g4s_3.v();
                if (element_3.na(this.x4m_1)) {
                  tmp$ret$4 = true;
                  break l$ret$5;
                }
              }
              tmp$ret$4 = false;
            }
             while (false);
            tmp_3 = tmp$ret$4;
          }

          if (tmp_3) {
            get_LOGGER().h2j('Body type ' + toString(getKClassFromExpression(this.x4m_1)) + ' is in ignored types. ' + ('Skipping ContentNegotiation for ' + this.w4m_1.n3f_1.toString() + '.'));
            return null;
          }

          var tmp_6 = this;
          var tmp0_elvis_lhs_0 = contentType_0(this.w4m_1);
          var tmp_7;
          if (tmp0_elvis_lhs_0 == null) {
            this.u4m_1;
            get_LOGGER().h2j("Request doesn't have Content-Type header. Skipping ContentNegotiation for " + this.w4m_1.n3f_1.toString() + '.');
            return null;
          } else {
            tmp_7 = tmp0_elvis_lhs_0;
          }

          tmp_6.z4m_1 = tmp_7;
          var tmp_8 = this.x4m_1;
          if (tmp_8 instanceof Unit) {
            get_LOGGER().h2j('Sending empty body for ' + this.w4m_1.n3f_1.toString());
            this.w4m_1.p3f_1.f2f('Content-Type');
            return EmptyContent_getInstance();
          }

          var tmp_9 = this;
          var tmp0_1 = this.t4m_1;
          var destination_0 = ArrayList_init_$Create$();
          var _iterator__ex2g4s_4 = tmp0_1.t();
          while (_iterator__ex2g4s_4.u()) {
            var element_4 = _iterator__ex2g4s_4.v();
            if (element_4.e4m_1.g4m(this.z4m_1)) {
              destination_0.e1(element_4);
            }
          }

          var tmp_10;
          if (!destination_0.r()) {
            tmp_10 = destination_0;
          } else {
            tmp_10 = null;
          }

          var tmp1_elvis_lhs = tmp_10;
          var tmp_11;
          if (tmp1_elvis_lhs == null) {
            this.u4m_1;
            get_LOGGER().h2j('None of the registered converters match request Content-Type=' + this.z4m_1.toString() + '. ' + ('Skipping ContentNegotiation for ' + this.w4m_1.n3f_1.toString() + '.'));
            return null;
          } else {
            tmp_11 = tmp1_elvis_lhs;
          }

          tmp_9.y4m_1 = tmp_11;
          if (this.w4m_1.g48() == null) {
            get_LOGGER().h2j('Request has unknown body type. Skipping ContentNegotiation for ' + this.w4m_1.n3f_1.toString() + '.');
            return null;
          }

          this.w4m_1.p3f_1.f2f('Content-Type');
          this.d4n_1 = this.y4m_1;
          this.j8_1 = 1;
          continue $sm;
        case 1:
          this.c4n_1 = this.d4n_1.t();
          this.j8_1 = 2;
          continue $sm;
        case 2:
          if (!this.c4n_1.u()) {
            this.j8_1 = 5;
            continue $sm;
          }

          var element_5 = this.c4n_1.v();
          this.b4n_1 = element_5;
          this.j8_1 = 3;
          var tmp0_elvis_lhs_1 = charset(this.z4m_1);
          var tmp_12 = tmp0_elvis_lhs_1 == null ? Charsets_getInstance().o1q_1 : tmp0_elvis_lhs_1;
          var tmp_13 = ensureNotNull(this.w4m_1.g48());
          var this_0 = this.x4m_1;
          var tmp_14;
          if (!equals(this_0, NullBody_instance)) {
            tmp_14 = this_0;
          } else {
            tmp_14 = null;
          }

          suspendResult = this.b4n_1.c4m_1.a4p(this.z4m_1, tmp_12, tmp_13, tmp_14, this);
          if (suspendResult === get_COROUTINE_SUSPENDED()) {
            return suspendResult;
          }

          continue $sm;
        case 3:
          var result = suspendResult;
          if (!(result == null)) {
            get_LOGGER().h2j('Converted request body using ' + toString(this.b4n_1.c4m_1) + ' for ' + this.w4m_1.n3f_1.toString());
          }

          var result_0 = result;
          if (!(result_0 == null)) {
            this.a4n_1 = result_0;
            this.j8_1 = 6;
            continue $sm;
          } else {
            this.j8_1 = 4;
            continue $sm;
          }

        case 4:
          this.j8_1 = 2;
          continue $sm;
        case 5:
          this.a4n_1 = null;
          if (false) {
            this.j8_1 = 1;
            continue $sm;
          }

          this.j8_1 = 6;
          continue $sm;
        case 6:
          var tmp2_elvis_lhs = this.a4n_1;
          var tmp_15;
          if (tmp2_elvis_lhs == null) {
            var tmp_16 = "Can't convert " + toString(this.x4m_1) + ' with contentType ' + this.z4m_1.toString() + ' using converters ';
            throw new ContentConverterException(tmp_16 + joinToString(this.y4m_1, VOID, VOID, VOID, VOID, VOID, ContentNegotiation$lambda$convertRequest$lambda));
          } else {
            tmp_15 = tmp2_elvis_lhs;
          }

          var serializedContent = tmp_15;
          return serializedContent;
        case 7:
          throw this.m8_1;
      }
    } catch ($p) {
      var e = $p;
      if (this.k8_1 === 7) {
        throw e;
      } else {
        this.j8_1 = this.k8_1;
        this.m8_1 = e;
      }
    }
   while (true);
};
function $invoke$convertResponseCOROUTINE$(ignoredTypes, registrations, $this_createClientPlugin, requestUrl, info, body, responseContentType, charset, resultContinuation) {
  CoroutineImpl.call(this, resultContinuation);
  this.m4n_1 = ignoredTypes;
  this.n4n_1 = registrations;
  this.o4n_1 = $this_createClientPlugin;
  this.p4n_1 = requestUrl;
  this.q4n_1 = info;
  this.r4n_1 = body;
  this.s4n_1 = responseContentType;
  this.t4n_1 = charset;
}
protoOf($invoke$convertResponseCOROUTINE$).r8 = function () {
  var suspendResult = this.l8_1;
  $sm: do
    try {
      var tmp = this.j8_1;
      switch (tmp) {
        case 0:
          this.k8_1 = 2;
          var tmp_0 = this.r4n_1;
          if (!isInterface(tmp_0, ByteReadChannel)) {
            get_LOGGER().h2j('Response body is already transformed. Skipping ContentNegotiation for ' + this.p4n_1.toString() + '.');
            return null;
          }

          if (this.m4n_1.h2(this.q4n_1.a2j_1)) {
            get_LOGGER().h2j('Response body type ' + toString(this.q4n_1.a2j_1) + ' is in ignored types. ' + ('Skipping ContentNegotiation for ' + this.p4n_1.toString() + '.'));
            return null;
          }

          var tmp0 = this.n4n_1;
          var destination = ArrayList_init_$Create$();
          var _iterator__ex2g4s = tmp0.t();
          while (_iterator__ex2g4s.u()) {
            var element = _iterator__ex2g4s.v();
            if (element.e4m_1.g4m(this.s4n_1)) {
              destination.e1(element);
            }
          }

          var destination_0 = ArrayList_init_$Create$_0(collectionSizeOrDefault(destination, 10));
          var _iterator__ex2g4s_0 = destination.t();
          while (_iterator__ex2g4s_0.u()) {
            var item = _iterator__ex2g4s_0.v();
            destination_0.e1(item.c4m_1);
          }

          var tmp_1;
          if (!destination_0.r()) {
            tmp_1 = destination_0;
          } else {
            tmp_1 = null;
          }

          var tmp0_elvis_lhs = tmp_1;
          var tmp_2;
          if (tmp0_elvis_lhs == null) {
            this.o4n_1;
            get_LOGGER().h2j('None of the registered converters match response with Content-Type=' + this.s4n_1.toString() + '. ' + ('Skipping ContentNegotiation for ' + this.p4n_1.toString() + '.'));
            return null;
          } else {
            tmp_2 = tmp0_elvis_lhs;
          }

          var suitableConverters = tmp_2;
          this.j8_1 = 1;
          suspendResult = deserialize(suitableConverters, this.r4n_1, this.q4n_1, this.t4n_1, this);
          if (suspendResult === get_COROUTINE_SUSPENDED()) {
            return suspendResult;
          }

          continue $sm;
        case 1:
          var result = suspendResult;
          if (!isInterface(result, ByteReadChannel)) {
            get_LOGGER().h2j('Response body was converted to ' + toString(getKClassFromExpression(result)) + ' for ' + this.p4n_1.toString() + '.');
          }

          return result;
        case 2:
          throw this.m8_1;
      }
    } catch ($p) {
      var e = $p;
      if (this.k8_1 === 2) {
        throw e;
      } else {
        this.j8_1 = this.k8_1;
        this.m8_1 = e;
      }
    }
   while (true);
};
var properties_initialized_ContentNegotiation_kt_1ayduy;
function _init_properties_ContentNegotiation_kt__o183go() {
  if (!properties_initialized_ContentNegotiation_kt_1ayduy) {
    properties_initialized_ContentNegotiation_kt_1ayduy = true;
    LOGGER = KtorSimpleLogger('io.ktor.client.plugins.contentnegotiation.ContentNegotiation');
    DefaultCommonIgnoredTypes = setOf([PrimitiveClasses_getInstance().rb(), PrimitiveClasses_getInstance().nb(), getKClass(HttpStatusCode), getKClass(ByteReadChannel), getKClass(OutgoingContent), getKClass(ClientSSESession), getKClass(ClientSSESessionWithDeserialization)]);
    // Inline function 'io.ktor.util.AttributeKey' call
    var name = 'ExcludedContentTypesAttr';
    // Inline function 'io.ktor.util.reflect.typeInfo' call
    var tmp = getKClass(KtList);
    // Inline function 'io.ktor.util.reflect.typeOfOrNull' call
    var tmp_0;
    try {
      tmp_0 = createKType(getKClass(KtList), arrayOf([createInvariantKTypeProjection(createKType(getKClass(ContentType), arrayOf([]), false))]), false);
    } catch ($p) {
      var tmp_1;
      if ($p instanceof Error) {
        var _unused_var__etf5q3 = $p;
        tmp_1 = null;
      } else {
        throw $p;
      }
      tmp_0 = tmp_1;
    }
    var tmp$ret$2 = tmp_0;
    var tmp$ret$1 = new TypeInfo(tmp, tmp$ret$2);
    ExcludedContentTypes = new AttributeKey(name, tmp$ret$1);
    var tmp_2 = ContentNegotiationConfig$_init_$ref_1ne3ob();
    ContentNegotiation = createClientPlugin('ContentNegotiation', tmp_2, ContentNegotiation$lambda);
  }
}
function JsonContentTypeMatcher() {
}
protoOf(JsonContentTypeMatcher).g4m = function (contentType) {
  if (contentType.t2l(Application_getInstance().z2j_1)) {
    return true;
  }
  var value = contentType.s2l().toString();
  return Application_getInstance().t2k(value) && endsWith(value, '+json', true);
};
var JsonContentTypeMatcher_instance;
function JsonContentTypeMatcher_getInstance() {
  return JsonContentTypeMatcher_instance;
}
function get_DefaultIgnoredTypes() {
  _init_properties_DefaultIgnoredTypes_web_kt__6eddjw();
  return DefaultIgnoredTypes;
}
var DefaultIgnoredTypes;
var properties_initialized_DefaultIgnoredTypes_web_kt_23uj7m;
function _init_properties_DefaultIgnoredTypes_web_kt__6eddjw() {
  if (!properties_initialized_DefaultIgnoredTypes_web_kt_23uj7m) {
    properties_initialized_DefaultIgnoredTypes_web_kt_23uj7m = true;
    // Inline function 'kotlin.collections.mutableSetOf' call
    DefaultIgnoredTypes = LinkedHashSet_init_$Create$();
  }
}
//region block: post-declaration
protoOf(ContentNegotiationConfig).k3b = register$default;
//endregion
//region block: init
JsonContentTypeMatcher_instance = new JsonContentTypeMatcher();
//endregion
//region block: exports
export {
  get_ContentNegotiation as get_ContentNegotiationcp59ye9rorjc,
};
//endregion


