package j$.time.format;

import j$.time.LocalDate;
import java.util.function.Consumer;

/* JADX INFO: loaded from: classes2.dex */
final class p extends C2300j {

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    static final LocalDate f19257h = LocalDate.h0(2000, 1, 1);

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    private final LocalDate f19258g;

    /* synthetic */ p(j$.time.temporal.s sVar, LocalDate localDate, int i6) {
        this(sVar, 2, 2, localDate, i6);
    }

    p(j$.time.temporal.s sVar, LocalDate localDate) {
        this(sVar, 2, 2, localDate, 0);
        if (localDate == null) {
            long j4 = 0;
            if (!sVar.B().i(j4)) {
                throw new IllegalArgumentException("The base value must be within the range of the field");
            }
            if (j4 + C2300j.f19232f[2] > 2147483647L) {
                throw new j$.time.c("Unable to add printer-parser as the range exceeds the capacity of an int");
            }
        }
    }

    private p(j$.time.temporal.s sVar, int i6, int i7, LocalDate localDate, int i8) {
        super(sVar, i6, i7, H.NOT_NEGATIVE, i8);
        this.f19258g = localDate;
    }

    @Override // j$.time.format.C2300j
    final long b(z zVar, long j4) {
        long jAbs = Math.abs(j4);
        LocalDate localDate = this.f19258g;
        long j6 = localDate != null ? j$.time.chrono.k.F(zVar.d()).t(localDate).j(this.f19233a) : 0;
        long[] jArr = C2300j.f19232f;
        if (j4 >= j6) {
            long j7 = jArr[this.f19234b];
            if (j4 < j6 + j7) {
                return jAbs % j7;
            }
        }
        return jAbs % jArr[this.f19235c];
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r1v2, types: [j$.time.format.o] */
    @Override // j$.time.format.C2300j
    final int d(w wVar, long j4, int i6, int i7) {
        p pVar;
        w wVar2;
        final long j6;
        final int i8;
        final int i9;
        int iJ;
        long j7;
        j$.time.temporal.n nVar = this.f19258g;
        if (nVar != null) {
            iJ = wVar.h().t(nVar).j(this.f19233a);
            pVar = this;
            final w wVar3 = wVar;
            j6 = j4;
            i8 = i6;
            i9 = i7;
            wVar3.a(new Consumer() { // from class: j$.time.format.o
                @Override // java.util.function.Consumer
                public final void accept(Object obj) {
                    this.f19252a.d(wVar3, j6, i8, i9);
                }
            });
            wVar2 = wVar3;
        } else {
            pVar = this;
            wVar2 = wVar;
            j6 = j4;
            i8 = i6;
            i9 = i7;
            iJ = 0;
        }
        int i10 = i9 - i8;
        int i11 = pVar.f19234b;
        if (i10 != i11 || j6 < 0) {
            j7 = j6;
        } else {
            long j8 = C2300j.f19232f[i11];
            long j9 = iJ;
            long j10 = j9 - (j9 % j8);
            long j11 = iJ > 0 ? j10 + j6 : j10 - j6;
            j7 = j11 < j9 ? j11 + j8 : j11;
        }
        return wVar2.o(pVar.f19233a, j7, i8, i9);
    }

    @Override // j$.time.format.C2300j
    final C2300j e() {
        if (this.f19237e == -1) {
            return this;
        }
        return new p(this.f19233a, this.f19234b, this.f19235c, this.f19258g, -1);
    }

    @Override // j$.time.format.C2300j
    final C2300j f(int i6) {
        int i7 = this.f19237e + i6;
        return new p(this.f19233a, this.f19234b, this.f19235c, this.f19258g, i7);
    }

    @Override // j$.time.format.C2300j
    final boolean c(w wVar) {
        if (wVar.l()) {
            return super.c(wVar);
        }
        return false;
    }

    @Override // j$.time.format.C2300j
    public final String toString() {
        LocalDate localDate = this.f19258g;
        return "ReducedValue(" + this.f19233a + "," + this.f19234b + "," + this.f19235c + "," + (localDate != null ? localDate : 0) + ")";
    }
}
