package defpackage;

import java.io.IOException;
import java.io.InterruptedIOException;
import java.util.TimeZone;

/* JADX INFO: renamed from: ᵻːᵮˈ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C5198 implements InterfaceC1636 {

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

    /* JADX INFO: renamed from: ᵔᵖᵹᵫ, reason: contains not printable characters */
    public boolean f19583;

    /* JADX INFO: renamed from: ᵜᵪʾ, reason: contains not printable characters */
    public final C4903 f19584 = new C4903();

    /* JADX INFO: renamed from: ᵨᵼⁱ, reason: contains not printable characters */
    public final /* synthetic */ C0217 f19585;

    public C5198(C0217 c0217, boolean z) {
        this.f19585 = c0217;
        this.f19582 = z;
    }

    @Override // defpackage.InterfaceC1636, java.io.Closeable, java.lang.AutoCloseable
    public final void close() throws IOException {
        C0217 c0217 = this.f19585;
        TimeZone timeZone = AbstractC1190.f5068;
        synchronized (c0217) {
            if (this.f19583) {
                return;
            }
            boolean z = c0217.m1389() == 0;
            C0217 c02172 = this.f19585;
            if (!c02172.f1711.f19582) {
                if (this.f19584.f18672 > 0) {
                    while (this.f19584.f18672 > 0) {
                        m10741(true);
                    }
                } else if (z) {
                    c02172.f1706.m10182(c02172.f1702, true, null, 0L);
                }
            }
            C0217 c02173 = this.f19585;
            synchronized (c02173) {
                this.f19583 = true;
                c02173.notifyAll();
            }
            this.f19585.f1706.flush();
            this.f19585.m1382();
        }
    }

    @Override // defpackage.InterfaceC1636, java.io.Flushable
    public final void flush() throws IOException {
        C0217 c0217 = this.f19585;
        TimeZone timeZone = AbstractC1190.f5068;
        synchronized (c0217) {
            c0217.m1384();
        }
        while (this.f19584.f18672 > 0) {
            m10741(false);
            this.f19585.f1706.flush();
        }
    }

    @Override // defpackage.InterfaceC1636
    /* JADX INFO: renamed from: ˀᵭ */
    public final void mo1843(C4903 c4903, long j) throws IOException {
        TimeZone timeZone = AbstractC1190.f5068;
        C4903 c49032 = this.f19584;
        c49032.mo1843(c4903, j);
        while (c49032.f18672 >= 16384) {
            m10741(false);
        }
    }

    /* JADX WARN: Finally extract failed */
    /* JADX INFO: renamed from: ᵲᵶᵳˈ, reason: contains not printable characters */
    public final void m10741(boolean z) throws IOException {
        long jMin;
        boolean z2;
        C0217 c0217 = this.f19585;
        synchronized (c0217) {
            c0217.f1699.m10664();
            while (c0217.f1708 >= c0217.f1709 && !this.f19582 && !this.f19583 && c0217.m1389() == 0) {
                try {
                    try {
                        c0217.wait();
                    } catch (InterruptedException unused) {
                        Thread.currentThread().interrupt();
                        throw new InterruptedIOException();
                    }
                } catch (Throwable th) {
                    c0217.f1699.m5675();
                    throw th;
                }
            }
            c0217.f1699.m5675();
            c0217.m1384();
            jMin = Math.min(c0217.f1709 - c0217.f1708, this.f19584.f18672);
            c0217.f1708 += jMin;
            z2 = z && jMin == this.f19584.f18672;
        }
        this.f19585.f1699.m10664();
        try {
            C0217 c02172 = this.f19585;
            c02172.f1706.m10182(c02172.f1702, z2, this.f19584, jMin);
        } finally {
            this.f19585.f1699.m5675();
        }
    }

    @Override // defpackage.InterfaceC1636
    /* JADX INFO: renamed from: ᵻʽᵯ */
    public final C2466 mo1844() {
        return this.f19585.f1699;
    }
}
