package defpackage;

import defpackage.ab4;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Set;
import kotlin.Metadata;
import kotlin.coroutines.Continuation;
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 = {"\u0000\u0016\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\u0010\u0005\u001a\u00020\u0004*\u000e\u0012\u0004\u0012\u00020\u0001\u0012\u0004\u0012\u00020\u00020\u00002\u0006\u0010\u0003\u001a\u00020\u0001H\n¢\u0006\u0004\b\u0005\u0010\u0006"}, d2 = {"Lj77;", "", "Lfd4;", "content", "Le6a;", "<anonymous>", "(Lj77;Ljava/lang/Object;)V"}, k = 3, mv = {2, 0, 0})
@DebugMetadata(c = "io.ktor.client.engine.HttpClientEngine$install$1", f = "HttpClientEngine.kt", i = {0, 0}, l = {140, 152}, m = "invokeSuspend", n = {"$this$intercept", "requestData"}, s = {"L$0", "L$1"})
@vx8
final class db4 extends SuspendLambda implements ir3<j77<Object, fd4>, Object, Continuation<? super e6a>, Object> {
    public int a;
    public /* synthetic */ j77 b;
    public /* synthetic */ Object c;
    public final /* synthetic */ ta4 d;
    public final /* synthetic */ fb4 e;

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

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

    /* JADX WARN: Code restructure failed: missing block: B:46:0x012c, code lost:
    
        if (r5.h(r7, r13) == r2) goto L47;
     */
    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object invokeSuspend(Object obj) {
        KType kTypeA;
        gd4 gd4VarA;
        fb4 fb4Var;
        j77 j77Var;
        ib4 ib4Var;
        KType kTypeA2;
        ta4 ta4Var = this.d;
        mq2 mq2Var = ta4Var.l;
        ck1 ck1Var = ck1.a;
        int i = this.a;
        if (i == 0) {
            s38.b(obj);
            j77 j77Var2 = this.b;
            Object obj2 = this.c;
            fd4 fd4Var = new fd4();
            fd4Var.f((fd4) j77Var2.a);
            if (obj2 == null) {
                fd4Var.d = gq6.a;
                KClass orCreateKotlinClass = iw7.a.getOrCreateKotlinClass(Object.class);
                try {
                    kTypeA2 = iw7.a(Object.class);
                } catch (Throwable unused) {
                    kTypeA2 = null;
                }
                fd4Var.b(new fz9(orCreateKotlinClass, kTypeA2));
            } else if (obj2 instanceof vy6) {
                fd4Var.d = obj2;
                fd4Var.b(null);
            } else {
                fd4Var.d = obj2;
                KClass orCreateKotlinClass2 = iw7.a.getOrCreateKotlinClass(Object.class);
                try {
                    kTypeA = iw7.a(Object.class);
                } catch (Throwable unused2) {
                    kTypeA = null;
                }
                fd4Var.b(new fz9(orCreateKotlinClass2, kTypeA));
            }
            mq2Var.a(d11.b, fd4Var);
            gd4VarA = fd4Var.a();
            gd4VarA.f.d(ob4.b, ta4Var.m);
            Set setC = gd4VarA.c.c();
            ArrayList arrayList = new ArrayList();
            for (Object obj3 : setC) {
                if (qc4.a.contains((String) obj3)) {
                    arrayList.add(obj3);
                }
            }
            if (!arrayList.isEmpty()) {
                String string = arrayList.toString();
                cr4.g(string, "header");
                throw new c8a("Header(s) " + string + " are controlled by the engine and cannot be set explicitly");
            }
            Iterator it = gd4VarA.g.iterator();
            do {
                boolean zHasNext = it.hasNext();
                fb4Var = this.e;
                if (!zHasNext) {
                    this.b = j77Var2;
                    this.c = gd4VarA;
                    this.a = 1;
                    Object objA = ab4.a.a(fb4Var, gd4VarA, this);
                    if (objA != ck1Var) {
                        j77Var = j77Var2;
                        obj = objA;
                    }
                    return ck1Var;
                }
                ib4Var = (ib4) it.next();
            } while (fb4Var.getF().contains(ib4Var));
            throw new IllegalArgumentException(("Engine doesn't support " + ib4Var).toString());
        }
        if (i != 1) {
            if (i != 2) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            s38.b(obj);
            return e6a.a;
        }
        gd4VarA = (gd4) this.c;
        j77Var = this.b;
        s38.b(obj);
        ua4 ua4Var = new ua4(ta4Var, gd4VarA, (ud4) obj);
        rd4 rd4VarG = ua4Var.g();
        mq2Var.a(d11.c, rd4VarG);
        kx4.d(rd4VarG.getA()).at(new q2(ta4Var, rd4VarG, 9));
        this.b = null;
        this.c = null;
        this.a = 2;
    }
}
