package defpackage;

import androidx.media3.container.NalUnitUtil;
import com.google.android.gms.measurement.api.AppMeasurementSdk;
import defpackage.fg8;
import java.util.Iterator;
import java.util.List;
import kotlin.Metadata;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.jvm.internal.ContinuationImpl;
import kotlin.coroutines.jvm.internal.DebugMetadata;
import kotlin.coroutines.jvm.internal.SuspendLambda;
import kotlin.reflect.KClass;
import kotlin.reflect.KType;

/* JADX INFO: loaded from: classes3.dex */
@Metadata(d1 = {"\u00002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0010\u0003\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003*`\u0010\b\"-\b\u0001\u0012\u0013\u0012\u00110\u0001¢\u0006\f\b\u0002\u0012\b\b\u0003\u0012\u0004\b\b(\u0004\u0012\n\u0012\b\u0012\u0004\u0012\u00020\u00060\u0005\u0012\u0006\u0012\u0004\u0018\u00010\u00070\u00002-\b\u0001\u0012\u0013\u0012\u00110\u0001¢\u0006\f\b\u0002\u0012\b\b\u0003\u0012\u0004\b\b(\u0004\u0012\n\u0012\b\u0012\u0004\u0012\u00020\u00060\u0005\u0012\u0006\u0012\u0004\u0018\u00010\u00070\u0000*`\u0010\u000b\"-\b\u0001\u0012\u0013\u0012\u00110\t¢\u0006\f\b\u0002\u0012\b\b\u0003\u0012\u0004\b\b(\n\u0012\n\u0012\b\u0012\u0004\u0012\u00020\u00060\u0005\u0012\u0006\u0012\u0004\u0018\u00010\u00070\u00002-\b\u0001\u0012\u0013\u0012\u00110\t¢\u0006\f\b\u0002\u0012\b\b\u0003\u0012\u0004\b\b(\n\u0012\n\u0012\b\u0012\u0004\u0012\u00020\u00060\u0005\u0012\u0006\u0012\u0004\u0018\u00010\u00070\u0000*\u008a\u0001\u0010\u000f\"B\b\u0001\u0012\u0013\u0012\u00110\t¢\u0006\f\b\u0002\u0012\b\b\u0003\u0012\u0004\b\b(\n\u0012\u0013\u0012\u00110\r¢\u0006\f\b\u0002\u0012\b\b\u0003\u0012\u0004\b\b(\u000e\u0012\n\u0012\b\u0012\u0004\u0012\u00020\u00060\u0005\u0012\u0006\u0012\u0004\u0018\u00010\u00070\f2B\b\u0001\u0012\u0013\u0012\u00110\t¢\u0006\f\b\u0002\u0012\b\b\u0003\u0012\u0004\b\b(\n\u0012\u0013\u0012\u00110\r¢\u0006\f\b\u0002\u0012\b\b\u0003\u0012\u0004\b\b(\u000e\u0012\n\u0012\b\u0012\u0004\u0012\u00020\u00060\u0005\u0012\u0006\u0012\u0004\u0018\u00010\u00070\f¨\u0006\u0010"}, d2 = {"Lkotlin/Function2;", "Lrd4;", "Lj17;", AppMeasurementSdk.ConditionalUserProperty.NAME, "response", "Lkotlin/coroutines/Continuation;", "Le6a;", "", "ResponseValidator", "", "cause", "CallExceptionHandler", "Lkotlin/Function3;", "Led4;", "request", "CallRequestExceptionHandler", "ktor-client-core"}, k = 2, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
@vx8
public final class la4 {
    public static final jh5 a = oh5.b().a().a("io.ktor.client.plugins.HttpCallValidator");
    public static final i11 b = tm1.a(a.a, new od0(6), "HttpResponseValidator");
    public static final dx c;

    @Metadata(k = 3, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    public /* synthetic */ class a extends xr3 implements qq3<ka4> {
        public static final a a = new a(0, ka4.class, "<init>", "<init>()V", 0);

        @Override // defpackage.qq3
        public final Object invoke() {
            return new ka4();
        }
    }

    @Metadata(d1 = {"\u0000\u000e\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\u0010\u0003\u001a\u00020\u00022\u0006\u0010\u0001\u001a\u00020\u0000H\n¢\u0006\u0004\b\u0003\u0010\u0004"}, d2 = {"Lfd4;", "request", "Le6a;", "<anonymous>", "(Lfd4;)V"}, k = 3, mv = {2, 0, 0})
    @DebugMetadata(c = "io.ktor.client.plugins.HttpCallValidatorKt$HttpCallValidator$2$1", f = "HttpCallValidator.kt", i = {}, l = {}, m = "invokeSuspend", n = {}, s = {})
    public static final class b extends SuspendLambda implements gr3<fd4, Continuation<? super e6a>, Object> {
        public /* synthetic */ Object a;
        public final /* synthetic */ boolean b;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public b(boolean z, Continuation continuation) {
            super(2, continuation);
            this.b = z;
        }

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        public final Continuation create(Object obj, Continuation continuation) {
            b bVar = new b(this.b, continuation);
            bVar.a = obj;
            return bVar;
        }

        @Override // defpackage.gr3
        public final Object invoke(Object obj, Object obj2) {
            b bVar = (b) create((fd4) obj, (Continuation) obj2);
            e6a e6aVar = e6a.a;
            bVar.invokeSuspend(e6aVar);
            return e6aVar;
        }

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        public final Object invokeSuspend(Object obj) {
            ck1 ck1Var = ck1.a;
            s38.b(obj);
            fx fxVar = ((fd4) this.a).f;
            dx dxVar = la4.c;
            final boolean z = this.b;
            fxVar.c(dxVar, new qq3() { // from class: ma4
                @Override // defpackage.qq3
                public final Object invoke() {
                    return Boolean.valueOf(z);
                }
            });
            return e6a.a;
        }
    }

    @Metadata(d1 = {"\u0000\u0012\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\u0010\u0004\u001a\u00020\u0003*\u00020\u00002\u0006\u0010\u0002\u001a\u00020\u0001H\n¢\u0006\u0004\b\u0004\u0010\u0005"}, d2 = {"Lfg8$a;", "Lfd4;", "request", "Lua4;", "<anonymous>", "(Lfg8$a;Lfd4;)Lua4;"}, k = 3, mv = {2, 0, 0})
    @DebugMetadata(c = "io.ktor.client.plugins.HttpCallValidatorKt$HttpCallValidator$2$2", f = "HttpCallValidator.kt", i = {1}, l = {112, 113}, m = "invokeSuspend", n = {"call"}, s = {"L$0"})
    public static final class c extends SuspendLambda implements ir3<fg8.a, fd4, Continuation<? super ua4>, Object> {
        public int a;
        public /* synthetic */ ak1 b;
        public /* synthetic */ fd4 c;
        public final /* synthetic */ List d;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public c(List list, Continuation continuation) {
            super(3, continuation);
            this.d = list;
        }

        @Override // defpackage.ir3
        public final Object invoke(Object obj, Object obj2, Object obj3) {
            c cVar = new c(this.d, (Continuation) obj3);
            cVar.b = (fg8.a) obj;
            cVar.c = (fd4) obj2;
            return cVar.invokeSuspend(e6a.a);
        }

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        public final Object invokeSuspend(Object obj) {
            ck1 ck1Var = ck1.a;
            int i = this.a;
            if (i == 0) {
                s38.b(obj);
                fg8.a aVar = (fg8.a) this.b;
                fd4 fd4Var = this.c;
                this.b = null;
                this.a = 1;
                obj = aVar.a.a(fd4Var, this);
                if (obj != ck1Var) {
                }
            }
            if (i != 1) {
                if (i != 2) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                ua4 ua4Var = (ua4) this.b;
                s38.b(obj);
                return ua4Var;
            }
            s38.b(obj);
            ua4 ua4Var2 = (ua4) obj;
            rd4 rd4VarG = ua4Var2.g();
            this.b = ua4Var2;
            this.a = 2;
            return la4.b(this.d, rd4VarG, this) == ck1Var ? ck1Var : ua4Var2;
        }
    }

    @Metadata(d1 = {"\u0000\u000e\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0003\n\u0002\b\u0003\u0010\u0004\u001a\u0004\u0018\u00010\u00022\u0006\u0010\u0001\u001a\u00020\u00002\u0006\u0010\u0003\u001a\u00020\u0002H\n¢\u0006\u0004\b\u0004\u0010\u0005"}, d2 = {"Led4;", "request", "", "cause", "<anonymous>", "(Led4;Ljava/lang/Throwable;)Ljava/lang/Throwable;"}, k = 3, mv = {2, 0, 0})
    @DebugMetadata(c = "io.ktor.client.plugins.HttpCallValidatorKt$HttpCallValidator$2$3", f = "HttpCallValidator.kt", i = {0}, l = {119}, m = "invokeSuspend", n = {"unwrappedCause"}, s = {"L$0"})
    public static final class d extends SuspendLambda implements ir3<ed4, Throwable, Continuation<? super Throwable>, Object> {
        public int a;
        public /* synthetic */ Object b;
        public /* synthetic */ Throwable c;
        public final /* synthetic */ List d;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public d(List list, Continuation continuation) {
            super(3, continuation);
            this.d = list;
        }

        @Override // defpackage.ir3
        public final Object invoke(Object obj, Object obj2, Object obj3) {
            d dVar = new d(this.d, (Continuation) obj3);
            dVar.b = (ed4) obj;
            dVar.c = (Throwable) obj2;
            return dVar.invokeSuspend(e6a.a);
        }

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        public final Object invokeSuspend(Object obj) {
            ck1 ck1Var = ck1.a;
            int i = this.a;
            if (i != 0) {
                if (i != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                Throwable th = (Throwable) this.b;
                s38.b(obj);
                return th;
            }
            s38.b(obj);
            ed4 ed4Var = (ed4) this.b;
            Throwable thA = vq2.a(this.c);
            this.b = thA;
            this.a = 1;
            la4.a(this.d, thA, ed4Var, this);
            return e6a.a == ck1Var ? ck1Var : thA;
        }
    }

    @Metadata(d1 = {"\u0000\u000e\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0003\n\u0002\b\u0003\u0010\u0004\u001a\u0004\u0018\u00010\u00022\u0006\u0010\u0001\u001a\u00020\u00002\u0006\u0010\u0003\u001a\u00020\u0002H\n¢\u0006\u0004\b\u0004\u0010\u0005"}, d2 = {"Led4;", "request", "", "cause", "<anonymous>", "(Led4;Ljava/lang/Throwable;)Ljava/lang/Throwable;"}, k = 3, mv = {2, 0, 0})
    @DebugMetadata(c = "io.ktor.client.plugins.HttpCallValidatorKt$HttpCallValidator$2$4", f = "HttpCallValidator.kt", i = {0}, l = {125}, m = "invokeSuspend", n = {"unwrappedCause"}, s = {"L$0"})
    public static final class e extends SuspendLambda implements ir3<ed4, Throwable, Continuation<? super Throwable>, Object> {
        public int a;
        public /* synthetic */ Object b;
        public /* synthetic */ Throwable c;
        public final /* synthetic */ List d;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public e(List list, Continuation continuation) {
            super(3, continuation);
            this.d = list;
        }

        @Override // defpackage.ir3
        public final Object invoke(Object obj, Object obj2, Object obj3) {
            e eVar = new e(this.d, (Continuation) obj3);
            eVar.b = (ed4) obj;
            eVar.c = (Throwable) obj2;
            return eVar.invokeSuspend(e6a.a);
        }

        @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
        public final Object invokeSuspend(Object obj) {
            ck1 ck1Var = ck1.a;
            int i = this.a;
            if (i != 0) {
                if (i != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                Throwable th = (Throwable) this.b;
                s38.b(obj);
                return th;
            }
            s38.b(obj);
            ed4 ed4Var = (ed4) this.b;
            Throwable thA = vq2.a(this.c);
            this.b = thA;
            this.a = 1;
            la4.a(this.d, thA, ed4Var, this);
            return e6a.a == ck1Var ? ck1Var : thA;
        }
    }

    static {
        KType kTypeA;
        KClass orCreateKotlinClass = iw7.a.getOrCreateKotlinClass(Boolean.class);
        try {
            kTypeA = iw7.a(Boolean.TYPE);
        } catch (Throwable unused) {
            kTypeA = null;
        }
        c = new dx("ExpectSuccessAttributeKey", new fz9(orCreateKotlinClass, kTypeA));
    }

    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static final void a(List list, Throwable th, ed4 ed4Var, ContinuationImpl continuationImpl) {
        na4 na4Var;
        Iterator it;
        if (continuationImpl instanceof na4) {
            na4Var = (na4) continuationImpl;
            int i = na4Var.e;
            if ((i & Integer.MIN_VALUE) != 0) {
                na4Var.e = i - Integer.MIN_VALUE;
            } else {
                na4Var = new na4(continuationImpl);
            }
        }
        Object obj = na4Var.d;
        ck1 ck1Var = ck1.a;
        int i2 = na4Var.e;
        if (i2 == 0) {
            s38.b(obj);
            a.h("Processing exception " + th + " for request " + ed4Var.getC());
            it = list.iterator();
        } else {
            if (i2 != 1 && i2 != 2) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            it = na4Var.c;
            ed4 ed4Var2 = na4Var.b;
            Throwable th2 = na4Var.a;
            s38.b(obj);
            ed4Var = ed4Var2;
            th = th2;
        }
        if (it.hasNext()) {
            vz3 vz3Var = (vz3) it.next();
            if (vz3Var instanceof rq2) {
                na4Var.a = th;
                na4Var.b = ed4Var;
                na4Var.c = it;
                na4Var.e = 1;
                throw null;
            }
            if (!(vz3Var instanceof q08)) {
                throw new io6();
            }
            na4Var.a = th;
            na4Var.b = ed4Var;
            na4Var.c = it;
            na4Var.e = 2;
            throw null;
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static final Object b(List list, rd4 rd4Var, ContinuationImpl continuationImpl) {
        oa4 oa4Var;
        Iterator it;
        if (continuationImpl instanceof oa4) {
            oa4Var = (oa4) continuationImpl;
            int i = oa4Var.d;
            if ((i & Integer.MIN_VALUE) != 0) {
                oa4Var.d = i - Integer.MIN_VALUE;
            } else {
                oa4Var = new oa4(continuationImpl);
            }
        }
        Object obj = oa4Var.c;
        ck1 ck1Var = ck1.a;
        int i2 = oa4Var.d;
        if (i2 == 0) {
            s38.b(obj);
            a.h("Validating response for request " + rd4Var.getA().e().getC());
            it = list.iterator();
        } else {
            if (i2 != 1) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            it = oa4Var.b;
            rd4Var = oa4Var.a;
            s38.b(obj);
        }
        while (it.hasNext()) {
            gr3 gr3Var = (gr3) it.next();
            oa4Var.a = rd4Var;
            oa4Var.b = it;
            oa4Var.d = 1;
            if (gr3Var.invoke(rd4Var, oa4Var) == ck1Var) {
                return ck1Var;
            }
        }
        return e6a.a;
    }
}
