package ᨨ;

import java.io.EOFException;
import java.io.IOException;
import java.util.zip.DataFormatException;
import java.util.zip.Inflater;
import ඓ.K.K.K.C1293;

/* renamed from: ᨨ.䁗  reason: contains not printable characters */
/* compiled from: InflaterSource */
public final class C1498 implements AbstractC1494 {

    /* renamed from: ʬ  reason: contains not printable characters */
    public final Inflater f5536;

    /* renamed from: ඓ  reason: contains not printable characters */
    public boolean f5537;

    /* renamed from: ῲ  reason: contains not printable characters */
    public final AbstractC1496 f5538;

    /* renamed from: 㸾  reason: contains not printable characters */
    public int f5539;

    public C1498(AbstractC1496 r1, Inflater inflater) {
        if (r1 == null) {
            throw new IllegalArgumentException("source == null");
        } else if (inflater != null) {
            this.f5538 = r1;
            this.f5536 = inflater;
        } else {
            throw new IllegalArgumentException("inflater == null");
        }
    }

    @Override // ᨨ.AbstractC1494, java.io.Closeable, java.lang.AutoCloseable
    public void close() throws IOException {
        if (!this.f5537) {
            this.f5536.end();
            this.f5537 = true;
            this.f5538.close();
        }
    }

    @Override // ᨨ.AbstractC1494
    public long read(C1492 r7, long j) throws IOException {
        C1475 r0;
        int i = (j > 0 ? 1 : (j == 0 ? 0 : -1));
        if (i < 0) {
            throw new IllegalArgumentException(C1293.m3409("byteCount < 0: ", j));
        } else if (this.f5537) {
            throw new IllegalStateException("closed");
        } else if (i == 0) {
            return 0;
        } else {
            while (true) {
                boolean z = false;
                if (this.f5536.needsInput()) {
                    m3828();
                    if (this.f5536.getRemaining() != 0) {
                        throw new IllegalStateException("?");
                    } else if (this.f5538.m3821()) {
                        z = true;
                    } else {
                        C1475 r02 = this.f5538.m3819().f5530;
                        int i2 = r02.f5494;
                        int i3 = r02.f5496;
                        this.f5539 = i2 - i3;
                        this.f5536.setInput(r02.f5498, i3, this.f5539);
                    }
                }
                try {
                    r0 = r7.m3786(1);
                    int inflate = this.f5536.inflate(r0.f5498, r0.f5494, (int) Math.min(j, (long) (8192 - r0.f5494)));
                    if (inflate > 0) {
                        r0.f5494 += inflate;
                        long j2 = (long) inflate;
                        r7.f5529 += j2;
                        return j2;
                    } else if (this.f5536.finished()) {
                        break;
                    } else if (this.f5536.needsDictionary()) {
                        break;
                    } else if (z) {
                        throw new EOFException("source exhausted prematurely");
                    }
                } catch (DataFormatException e) {
                    throw new IOException(e);
                }
            }
            m3828();
            if (r0.f5496 != r0.f5494) {
                return -1;
            }
            r7.f5530 = r0.m3696();
            C1497.m3827(r0);
            return -1;
        }
    }

    @Override // ᨨ.AbstractC1494
    public C1477 timeout() {
        return this.f5538.timeout();
    }

    /* renamed from: ᨨ  reason: contains not printable characters */
    public final void m3828() throws IOException {
        int i = this.f5539;
        if (i != 0) {
            int remaining = i - this.f5536.getRemaining();
            this.f5539 -= remaining;
            this.f5538.skip((long) remaining);
        }
    }
}
