package defpackage;

import java.io.IOException;
import java.util.ArrayDeque;
import java.util.TimeZone;
import okhttp3.internal.http2.StreamResetException;

/* renamed from: ᵲᵙʾ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C4498 implements InterfaceC5047 {

    /* renamed from: ˀᵗᵝᵭ, reason: contains not printable characters */
    public boolean f16757;

    /* renamed from: ˎˑː, reason: contains not printable characters */
    public final C0778 f16758;

    /* renamed from: ˑᵥˁ, reason: contains not printable characters */
    public final C3784 f16759;

    /* renamed from: ᵡˎ, reason: contains not printable characters */
    public final C3448 f16760;

    /* renamed from: ᵡⁱᵥ, reason: contains not printable characters */
    public final ArrayDeque f16761;

    /* renamed from: ᵢˇᵭ, reason: contains not printable characters */
    public final C4560 f16762;

    /* renamed from: ᵤᵙᵷ, reason: contains not printable characters */
    public long f16763;

    /* renamed from: ᵧـˌᵎ, reason: contains not printable characters */
    public int f16764;

    /* renamed from: ᵧᵾˀˈ, reason: contains not printable characters */
    public final int f16765;

    /* renamed from: ᵮᵠـˌ, reason: contains not printable characters */
    public final C0778 f16766;

    /* renamed from: ᵺʙ, reason: contains not printable characters */
    public IOException f16767;

    /* renamed from: ᵾᵬ, reason: contains not printable characters */
    public long f16768;

    /* renamed from: ᵿʗᵝʽ, reason: contains not printable characters */
    public final C5257 f16769;

    public C4498(int i, C4560 c4560, boolean z, boolean z2, C2609 c2609) {
        this.f16765 = i;
        this.f16762 = c4560;
        this.f16769 = new C5257(i);
        this.f16763 = c4560.f16966.m7295();
        ArrayDeque arrayDeque = new ArrayDeque();
        this.f16761 = arrayDeque;
        this.f16760 = new C3448(this, c4560.f16980.m7295(), z2);
        this.f16759 = new C3784(this, z);
        this.f16758 = new C0778(this);
        this.f16766 = new C0778(this);
        if (c2609 == null) {
            if (m9587()) {
                return;
            }
            ᵹˉᵞ.ᵳٴᵶ("remotely-initiated streams should have headers");
            throw null;
        }
        if (m9587()) {
            ᵹˉᵞ.ᵳٴᵶ("locally-initiated streams shouldn't have headers yet");
            throw null;
        }
        arrayDeque.add(c2609);
    }

    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public final boolean m9577(int i, IOException iOException) {
        TimeZone timeZone = AbstractC4061.f15224;
        synchronized (this) {
            if (m9579() != 0) {
                return false;
            }
            this.f16764 = i;
            this.f16767 = iOException;
            notifyAll();
            if (this.f16760.f12943) {
                if (this.f16759.f14128) {
                    return false;
                }
            }
            this.f16762.m9715(this.f16765);
            return true;
        }
    }

    /* renamed from: ˌᵜᵹᵩ, reason: contains not printable characters */
    public final void m9578(int i) {
        synchronized (this) {
            if (m9579() == 0) {
                this.f16764 = i;
                notifyAll();
            }
        }
    }

    /* renamed from: ˎˏʜʾ, reason: contains not printable characters */
    public final int m9579() {
        int i;
        synchronized (this) {
            i = this.f16764;
        }
        return i;
    }

    /* renamed from: ˏˋٴ, reason: contains not printable characters */
    public final void m9580(int i) {
        if (m9577(i, null)) {
            this.f16762.m9714(this.f16765, i);
        }
    }

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public final void m9581() throws IOException {
        C3784 c3784 = this.f16759;
        if (c3784.f14130) {
            C0910.m3045("stream closed");
            return;
        }
        if (c3784.f14128) {
            C0910.m3045("stream finished");
        } else if (m9579() != 0) {
            IOException iOException = this.f16767;
            if (iOException == null) {
                throw new StreamResetException(m9579());
            }
        }
    }

    /* renamed from: ᵝᵵᵺ, reason: contains not printable characters */
    public final boolean m9582() {
        synchronized (this) {
            try {
                if (m9579() != 0) {
                    return false;
                }
                C3448 c3448 = this.f16760;
                if (c3448.f12943 || c3448.f12944) {
                    C3784 c3784 = this.f16759;
                    if (c3784.f14128 || c3784.f14130) {
                        if (this.f16757) {
                            return false;
                        }
                    }
                }
                return true;
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    @Override // defpackage.InterfaceC5047
    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public final InterfaceC3226 mo9583() {
        return this.f16760;
    }

    /* JADX WARN: Removed duplicated region for block: B:16:0x001c  */
    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final void m9584() {
        /*
            r2 = this;
            java.util.TimeZone r0 = defpackage.AbstractC4061.f15224
            monitor-enter(r2)
            ᵤᵡˊᵯ r0 = r2.f16760     // Catch: java.lang.Throwable -> L18
            boolean r1 = r0.f12943     // Catch: java.lang.Throwable -> L18
            if (r1 != 0) goto L1c
            boolean r0 = r0.f12944     // Catch: java.lang.Throwable -> L18
            if (r0 == 0) goto L1c
            ᵩʨᵣˊ r0 = r2.f16759     // Catch: java.lang.Throwable -> L18
            boolean r1 = r0.f14128     // Catch: java.lang.Throwable -> L18
            if (r1 != 0) goto L1a
            boolean r0 = r0.f14130     // Catch: java.lang.Throwable -> L18
            if (r0 == 0) goto L1c
            goto L1a
        L18:
            r0 = move-exception
            goto L35
        L1a:
            r0 = 1
            goto L1d
        L1c:
            r0 = 0
        L1d:
            boolean r1 = r2.m9582()     // Catch: java.lang.Throwable -> L18
            monitor-exit(r2)
            if (r0 == 0) goto L2b
            r0 = 9
            r1 = 0
            r2.m9588(r0, r1)
            return
        L2b:
            if (r1 != 0) goto L34
            ᵳˋᵢ r0 = r2.f16762
            int r2 = r2.f16765
            r0.m9715(r2)
        L34:
            return
        L35:
            monitor-exit(r2)
            throw r0
        */
        throw new UnsupportedOperationException("Method not decompiled: defpackage.C4498.m9584():void");
    }

    @Override // defpackage.InterfaceC5047
    /* renamed from: ᵶᵷᵕ, reason: contains not printable characters */
    public final InterfaceC3280 mo9585() {
        return this.f16759;
    }

    /* renamed from: ᵸˑ, reason: contains not printable characters */
    public final void m9586(C2609 c2609, boolean z) {
        boolean zM9582;
        TimeZone timeZone = AbstractC4061.f15224;
        synchronized (this) {
            try {
                if (this.f16757 && c2609.m6560(":status") == null && c2609.m6560(":method") == null) {
                    this.f16760.getClass();
                } else {
                    this.f16757 = true;
                    this.f16761.add(c2609);
                }
                if (z) {
                    this.f16760.f12943 = true;
                }
                zM9582 = m9582();
                notifyAll();
            } catch (Throwable th) {
                throw th;
            }
        }
        if (zM9582) {
            return;
        }
        this.f16762.m9715(this.f16765);
    }

    /* renamed from: ᵹᵝᵶ, reason: contains not printable characters */
    public final boolean m9587() {
        boolean z = (this.f16765 & 1) == 1;
        this.f16762.getClass();
        return true == z;
    }

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public final void m9588(int i, IOException iOException) {
        if (m9577(i, iOException)) {
            this.f16762.f16959.m9644(this.f16765, i);
        }
    }
}
