package q7;

import P6.g;
import x7.A;
import x7.C1731g;
import x7.F;
import x7.J;
import x7.p;

/* JADX INFO: loaded from: classes.dex */
public final class b implements F, AutoCloseable {

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public final p f16332q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public boolean f16333r;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public final /* synthetic */ F4.a f16334s;

    public b(F4.a aVar) {
        this.f16334s = aVar;
        this.f16332q = new p(((A) aVar.f2498e).f18721q.f());
    }

    @Override // x7.F
    public final void X(C1731g c1731g, long j8) {
        g.e(c1731g, "source");
        if (this.f16333r) {
            throw new IllegalStateException("closed");
        }
        if (j8 == 0) {
            return;
        }
        F4.a aVar = this.f16334s;
        A a3 = (A) aVar.f2498e;
        if (a3.f18723s) {
            throw new IllegalStateException("closed");
        }
        a3.f18722r.w0(j8);
        a3.a();
        A a8 = (A) aVar.f2498e;
        a8.Y("\r\n");
        a8.X(c1731g, j8);
        a8.Y("\r\n");
    }

    @Override // x7.F, java.io.Closeable, java.lang.AutoCloseable
    public final synchronized void close() {
        if (this.f16333r) {
            return;
        }
        this.f16333r = true;
        ((A) this.f16334s.f2498e).Y("0\r\n\r\n");
        F4.a aVar = this.f16334s;
        p pVar = this.f16332q;
        aVar.getClass();
        J j8 = pVar.f18779e;
        pVar.f18779e = J.f18740d;
        j8.a();
        j8.b();
        this.f16334s.f2494a = 3;
    }

    @Override // x7.F
    public final J f() {
        return this.f16332q;
    }

    @Override // x7.F, java.io.Flushable
    public final synchronized void flush() {
        if (this.f16333r) {
            return;
        }
        ((A) this.f16334s.f2498e).flush();
    }
}
