package cl;

import java.util.Iterator;
import java.util.LinkedList;

/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes3.dex */
public final class f {

    /* renamed from: e, reason: collision with root package name */
    static final f f12020e = new f(g.f12025b, 0, 0, 0);

    /* renamed from: a, reason: collision with root package name */
    private final int f12021a;

    /* renamed from: b, reason: collision with root package name */
    private final g f12022b;

    /* renamed from: c, reason: collision with root package name */
    private final int f12023c;

    /* renamed from: d, reason: collision with root package name */
    private final int f12024d;

    private f(g gVar, int i10, int i11, int i12) {
        this.f12022b = gVar;
        this.f12021a = i10;
        this.f12023c = i11;
        this.f12024d = i12;
    }

    private static int b(f fVar) {
        int i10 = fVar.f12023c;
        if (i10 > 62) {
            return 21;
        }
        if (i10 > 31) {
            return 20;
        }
        return i10 > 0 ? 10 : 0;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public f a(int i10) {
        g gVar = this.f12022b;
        int i11 = this.f12021a;
        int i12 = this.f12024d;
        if (i11 == 4 || i11 == 2) {
            int i13 = d.f12013c[i11][0];
            int i14 = 65535 & i13;
            int i15 = i13 >> 16;
            gVar = gVar.a(i14, i15);
            i12 += i15;
            i11 = 0;
        }
        int i16 = this.f12023c;
        f fVar = new f(gVar, i11, i16 + 1, i12 + ((i16 == 0 || i16 == 31) ? 18 : i16 == 62 ? 9 : 8));
        return fVar.f12023c == 2078 ? fVar.c(i10 + 1) : fVar;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public f c(int i10) {
        int i11 = this.f12023c;
        return i11 == 0 ? this : new f(this.f12022b.b(i10 - i11, i11), this.f12021a, 0, this.f12024d);
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public int d() {
        return this.f12023c;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public int e() {
        return this.f12024d;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public int f() {
        return this.f12021a;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public boolean g(f fVar) {
        int i10 = this.f12024d + (d.f12013c[this.f12021a][fVar.f12021a] >> 16);
        int i11 = this.f12023c;
        int i12 = fVar.f12023c;
        if (i11 < i12) {
            i10 += b(fVar) - b(this);
        } else if (i11 > i12 && i12 > 0) {
            i10 += 10;
        }
        return i10 <= fVar.f12024d;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public f h(int i10, int i11) {
        int i12 = this.f12024d;
        g gVar = this.f12022b;
        int i13 = this.f12021a;
        if (i10 != i13) {
            int i14 = d.f12013c[i13][i10];
            int i15 = 65535 & i14;
            int i16 = i14 >> 16;
            gVar = gVar.a(i15, i16);
            i12 += i16;
        }
        int i17 = i10 == 2 ? 4 : 5;
        return new f(gVar.a(i11, i17), i10, 0, i12 + i17);
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public f i(int i10, int i11) {
        g gVar = this.f12022b;
        int i12 = this.f12021a;
        int i13 = i12 == 2 ? 4 : 5;
        return new f(gVar.a(d.f12015e[i12][i10], i13).a(i11, 5), this.f12021a, 0, this.f12024d + i13 + 5);
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public fl.a j(byte[] bArr) {
        LinkedList linkedList = new LinkedList();
        for (g gVar = c(bArr.length).f12022b; gVar != null; gVar = gVar.d()) {
            linkedList.addFirst(gVar);
        }
        fl.a aVar = new fl.a();
        Iterator it = linkedList.iterator();
        while (it.hasNext()) {
            ((g) it.next()).c(aVar, bArr);
        }
        return aVar;
    }

    public String toString() {
        return String.format("%s bits=%d bytes=%d", d.f12012b[this.f12021a], Integer.valueOf(this.f12024d), Integer.valueOf(this.f12023c));
    }
}
