package defpackage;

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

/* JADX INFO: renamed from: ᵤᵛᵰˉ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C3439 implements InterfaceC3906 {

    /* JADX INFO: renamed from: ˌᴵ, reason: contains not printable characters */
    public final long f13267;

    /* JADX INFO: renamed from: ᵜᵪʾ, reason: contains not printable characters */
    public boolean f13269;

    /* JADX INFO: renamed from: ᵯᵷʽ, reason: contains not printable characters */
    public boolean f13271;

    /* JADX INFO: renamed from: ᵶˇᵱ, reason: contains not printable characters */
    public final /* synthetic */ C0217 f13272;

    /* JADX INFO: renamed from: ᵔᵖᵹᵫ, reason: contains not printable characters */
    public final C4903 f13268 = new C4903();

    /* JADX INFO: renamed from: ᵨᵼⁱ, reason: contains not printable characters */
    public final C4903 f13270 = new C4903();

    public C3439(C0217 c0217, long j, boolean z) {
        this.f13272 = c0217;
        this.f13267 = j;
        this.f13269 = z;
    }

    @Override // java.io.Closeable, java.lang.AutoCloseable
    public final void close() {
        long j;
        C0217 c0217 = this.f13272;
        synchronized (c0217) {
            this.f13271 = true;
            C4903 c4903 = this.f13270;
            j = c4903.f18672;
            c4903.m10199();
            c0217.notifyAll();
        }
        if (j > 0) {
            C0217 c02172 = this.f13272;
            TimeZone timeZone = AbstractC1190.f5068;
            c02172.f1706.m10186(j);
        }
        this.f13272.m1382();
    }

    /* JADX WARN: Removed duplicated region for block: B:47:0x00b6 A[Catch: all -> 0x0022, DONT_GENERATE, TRY_ENTER, TRY_LEAVE, TryCatch #1 {, blocks: (B:5:0x0005, B:7:0x0012, B:13:0x001c, B:47:0x00b6, B:61:0x00dc, B:62:0x00e1, B:17:0x0025, B:19:0x002b, B:21:0x002f, B:23:0x0033, B:27:0x0041, B:29:0x0045, B:31:0x004f, B:33:0x006c, B:35:0x007d, B:38:0x0094, B:41:0x009e, B:43:0x00a4, B:44:0x00b0, B:58:0x00d2, B:59:0x00d9), top: B:67:0x0005, inners: #2 }] */
    @Override // defpackage.InterfaceC3906
    /* JADX INFO: renamed from: ᵪᵹᵥᵻ */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final long mo1490(C4903 c4903, long j) throws Throwable {
        boolean z;
        Throwable streamResetException;
        long j2;
        long jMo1490;
        do {
            C0217 c0217 = this.f13272;
            synchronized (c0217) {
                c0217.f1706.getClass();
                C5198 c5198 = c0217.f1711;
                z = true;
                boolean z2 = c5198.f19583 || c5198.f19582;
                if (z2) {
                    c0217.f1704.m10664();
                }
                try {
                    if (c0217.m1389() == 0 || this.f13269) {
                        streamResetException = null;
                    } else {
                        streamResetException = c0217.f1701;
                        if (streamResetException == null) {
                            streamResetException = new StreamResetException(c0217.m1389());
                        }
                    }
                    if (this.f13271) {
                        throw new IOException("stream closed");
                    }
                    C4903 c49032 = this.f13270;
                    long j3 = c49032.f18672;
                    if (j3 > 0) {
                        jMo1490 = c49032.mo1490(c4903, Math.min(8192L, j3));
                        C2744.m6638(c0217.f1705, jMo1490, 0L, 2);
                        long jM6639 = c0217.f1705.m6639();
                        if (streamResetException == null) {
                            j2 = -1;
                            if (jM6639 >= c0217.f1706.f18653.m6660() / 2) {
                                c0217.f1706.m10185(jM6639, c0217.f1702);
                                C2744.m6638(c0217.f1705, 0L, jM6639, 1);
                            }
                        } else {
                            j2 = -1;
                        }
                    } else {
                        j2 = -1;
                        if (this.f13269 || streamResetException != null) {
                            jMo1490 = -1;
                        } else {
                            try {
                                c0217.wait();
                                jMo1490 = -1;
                            } catch (InterruptedException unused) {
                                Thread.currentThread().interrupt();
                                throw new InterruptedIOException();
                            }
                        }
                    }
                    z = false;
                } finally {
                    if (z2) {
                        c0217.f1704.m5675();
                    }
                }
            }
            this.f13272.f1706.f18654.getClass();
        } while (z);
        if (jMo1490 != j2) {
            return jMo1490;
        }
        if (streamResetException == null) {
            return j2;
        }
        throw streamResetException;
    }

    @Override // defpackage.InterfaceC3906
    /* JADX INFO: renamed from: ᵻʽᵯ */
    public final C2466 mo1491() {
        return this.f13272.f1704;
    }
}
