package j$.time.chrono;

import defpackage.C5224;
import j$.time.DateTimeException;
import j$.time.LocalDate;
import j$.time.temporal.ChronoUnit;
import j$.time.temporal.Temporal;
import j$.time.temporal.TemporalUnit;
import java.io.InvalidObjectException;
import java.io.ObjectInputStream;
import java.util.Arrays;

/* JADX INFO: compiled from: r8-map-id-da1bda724d8b26dc30f90d2ccf434f42461d6c82e7dbdeb074f412e5504de99c */
/* JADX INFO: loaded from: classes2.dex */
public final class o extends c {
    private static final long serialVersionUID = -5207853542612002020L;
    public final transient m a;
    public final transient int b;
    public final transient int c;
    public final transient int d;

    public o(m mVar, int i, int i2, int i3) {
        mVar.V(i, i2, i3);
        this.a = mVar;
        this.b = i;
        this.c = i2;
        this.d = i3;
    }

    public o(m mVar, long j) {
        int i = (int) j;
        mVar.S();
        if (i < mVar.e || i >= mVar.f) {
            j$.time.g.k("Hijrah date out of range");
            throw null;
        }
        int iBinarySearch = Arrays.binarySearch(mVar.d, i);
        iBinarySearch = iBinarySearch < 0 ? (-iBinarySearch) - 2 : iBinarySearch;
        int[] iArr = {mVar.U(iBinarySearch), ((mVar.g + iBinarySearch) % 12) + 1, (i - mVar.d[iBinarySearch]) + 1};
        this.a = mVar;
        this.b = iArr[0];
        this.c = iArr[1];
        this.d = iArr[2];
    }

    private void readObject(ObjectInputStream objectInputStream) throws InvalidObjectException {
        throw new InvalidObjectException("Deserialization via serialization delegate");
    }

    private Object writeReplace() {
        return new c0((byte) 6, this);
    }

    @Override // j$.time.chrono.c, j$.time.temporal.Temporal
    /* JADX INFO: renamed from: A */
    public final Temporal u(long j, ChronoUnit chronoUnit) {
        return (o) super.u(j, chronoUnit);
    }

    @Override // j$.time.temporal.TemporalAccessor
    public final long E(j$.time.temporal.o oVar) {
        int iX;
        int iW;
        if (!(oVar instanceof j$.time.temporal.a)) {
            return oVar.A(this);
        }
        switch (n.a[((j$.time.temporal.a) oVar).ordinal()]) {
            case 1:
                iX = this.d;
                return iX;
            case 2:
                iX = X();
                return iX;
            case 3:
                iW = (this.d - 1) / 7;
                iX = iW + 1;
                return iX;
            case 4:
                iW = (int) j$.com.android.tools.r8.a.W(F() + 3, 7L);
                iX = iW + 1;
                return iX;
            case 5:
                iW = (this.d - 1) % 7;
                iX = iW + 1;
                return iX;
            case C5224.STRING_SET_FIELD_NUMBER /* 6 */:
                iW = (X() - 1) % 7;
                iX = iW + 1;
                return iX;
            case C5224.DOUBLE_FIELD_NUMBER /* 7 */:
                return F();
            case C5224.BYTES_FIELD_NUMBER /* 8 */:
                iW = (X() - 1) / 7;
                iX = iW + 1;
                return iX;
            case 9:
                iX = this.c;
                return iX;
            case 10:
                return ((((long) this.b) * 12) + ((long) this.c)) - 1;
            case 11:
                iX = this.b;
                return iX;
            case 12:
                iX = this.b;
                return iX;
            case 13:
                return this.b <= 1 ? 0 : 1;
            default:
                throw new j$.time.temporal.q(j$.time.b.a("Unsupported field: ", oVar));
        }
    }

    @Override // j$.time.chrono.c, j$.time.chrono.ChronoLocalDate
    public final long F() {
        return this.a.V(this.b, this.c, this.d);
    }

    @Override // j$.time.chrono.c, j$.time.chrono.ChronoLocalDate
    public final ChronoLocalDateTime H(j$.time.j jVar) {
        return new e(this, jVar);
    }

    @Override // j$.time.chrono.c, j$.time.chrono.ChronoLocalDate
    public final k J() {
        return p.AH;
    }

    @Override // j$.time.chrono.c, j$.time.chrono.ChronoLocalDate
    public final ChronoLocalDate M(j$.time.temporal.n nVar) {
        return (o) super.M(nVar);
    }

    @Override // j$.time.chrono.c, j$.time.chrono.ChronoLocalDate
    public final int P() {
        return this.a.Y(this.b, 12);
    }

    @Override // j$.time.chrono.c
    public final ChronoLocalDate W(long j) {
        if (j == 0) {
            return this;
        }
        long j2 = ((long) this.b) + ((long) ((int) j));
        int i = (int) j2;
        if (j2 == i) {
            return a0(i, this.c, this.d);
        }
        throw new ArithmeticException();
    }

    public final int X() {
        return this.a.Y(this.b, this.c - 1) + this.d;
    }

    @Override // j$.time.chrono.c
    /* JADX INFO: renamed from: Y, reason: merged with bridge method [inline-methods] */
    public final o U(long j) {
        return new o(this.a, F() + j);
    }

    @Override // j$.time.chrono.c
    /* JADX INFO: renamed from: Z, reason: merged with bridge method [inline-methods] */
    public final o V(long j) {
        if (j == 0) {
            return this;
        }
        long j2 = (((long) this.b) * 12) + ((long) (this.c - 1)) + j;
        m mVar = this.a;
        long jX = j$.com.android.tools.r8.a.X(j2, 12L);
        if (jX >= mVar.U(0) && jX <= mVar.U(mVar.d.length - 1) - 1) {
            return a0((int) jX, ((int) j$.com.android.tools.r8.a.W(j2, 12L)) + 1, this.d);
        }
        throw new DateTimeException("Invalid Hijrah year: " + jX);
    }

    @Override // j$.time.chrono.ChronoLocalDate
    public final j a() {
        return this.a;
    }

    public final o a0(int i, int i2, int i3) {
        int iW = this.a.W(i, i2);
        if (i3 > iW) {
            i3 = iW;
        }
        return new o(this.a, i, i2, i3);
    }

    @Override // j$.time.chrono.c, j$.time.temporal.Temporal
    /* JADX INFO: renamed from: b0, reason: merged with bridge method [inline-methods] */
    public final o c(long j, j$.time.temporal.o oVar) {
        if (!(oVar instanceof j$.time.temporal.a)) {
            return (o) super.c(j, oVar);
        }
        j$.time.temporal.a aVar = (j$.time.temporal.a) oVar;
        this.a.t(aVar).b(j, aVar);
        int i = (int) j;
        switch (n.a[aVar.ordinal()]) {
            case 1:
                return a0(this.b, this.c, i);
            case 2:
                return U(Math.min(i, P()) - X());
            case 3:
                return U((j - E(j$.time.temporal.a.ALIGNED_WEEK_OF_MONTH)) * 7);
            case 4:
                return U(j - ((long) (((int) j$.com.android.tools.r8.a.W(F() + 3, 7L)) + 1)));
            case 5:
                return U(j - E(j$.time.temporal.a.ALIGNED_DAY_OF_WEEK_IN_MONTH));
            case C5224.STRING_SET_FIELD_NUMBER /* 6 */:
                return U(j - E(j$.time.temporal.a.ALIGNED_DAY_OF_WEEK_IN_YEAR));
            case C5224.DOUBLE_FIELD_NUMBER /* 7 */:
                return new o(this.a, j);
            case C5224.BYTES_FIELD_NUMBER /* 8 */:
                return U((j - E(j$.time.temporal.a.ALIGNED_WEEK_OF_YEAR)) * 7);
            case 9:
                return a0(this.b, i, this.d);
            case 10:
                return V(j - (((((long) this.b) * 12) + ((long) this.c)) - 1));
            case 11:
                if (this.b < 1) {
                    i = 1 - i;
                }
                return a0(i, this.c, this.d);
            case 12:
                return a0(i, this.c, this.d);
            case 13:
                return a0(1 - this.b, this.c, this.d);
            default:
                throw new j$.time.temporal.q(j$.time.b.a("Unsupported field: ", oVar));
        }
    }

    @Override // j$.time.chrono.c, j$.time.chrono.ChronoLocalDate, j$.time.temporal.Temporal
    public final ChronoLocalDate d(long j, TemporalUnit temporalUnit) {
        return (o) super.d(j, temporalUnit);
    }

    @Override // j$.time.chrono.c, j$.time.temporal.Temporal
    public final Temporal d(long j, TemporalUnit temporalUnit) {
        return (o) super.d(j, temporalUnit);
    }

    @Override // j$.time.chrono.c, j$.time.chrono.ChronoLocalDate
    public final boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj instanceof o) {
            o oVar = (o) obj;
            if (this.b == oVar.b && this.c == oVar.c && this.d == oVar.d && this.a.equals(oVar.a)) {
                return true;
            }
        }
        return false;
    }

    @Override // j$.time.chrono.c, j$.time.chrono.ChronoLocalDate
    public final int hashCode() {
        int i = this.b;
        int i2 = this.c;
        int i3 = this.d;
        this.a.getClass();
        return ((i & (-2048)) ^ 2100100019) ^ (((i << 11) + (i2 << 6)) + i3);
    }

    @Override // j$.time.chrono.c, j$.time.temporal.Temporal
    /* JADX INFO: renamed from: l */
    public final Temporal z(LocalDate localDate) {
        return (o) super.z(localDate);
    }

    @Override // j$.time.chrono.c, j$.time.temporal.TemporalAccessor
    public final j$.time.temporal.r m(j$.time.temporal.o oVar) {
        if (!(oVar instanceof j$.time.temporal.a)) {
            return oVar.l(this);
        }
        if (!j$.com.android.tools.r8.a.s(this, oVar)) {
            throw new j$.time.temporal.q(j$.time.b.a("Unsupported field: ", oVar));
        }
        j$.time.temporal.a aVar = (j$.time.temporal.a) oVar;
        int i = n.a[aVar.ordinal()];
        return i != 1 ? i != 2 ? i != 3 ? this.a.t(aVar) : j$.time.temporal.r.f(1L, 5L) : j$.time.temporal.r.f(1L, P()) : j$.time.temporal.r.f(1L, this.a.W(this.b, this.c));
    }

    @Override // j$.time.chrono.c, j$.time.chrono.ChronoLocalDate
    public final boolean s() {
        return this.a.R(this.b);
    }

    @Override // j$.time.chrono.c, j$.time.chrono.ChronoLocalDate
    public final ChronoLocalDate u(long j, TemporalUnit temporalUnit) {
        return (o) super.u(j, temporalUnit);
    }

    @Override // j$.time.chrono.c, j$.time.chrono.ChronoLocalDate
    public final ChronoLocalDate z(j$.time.temporal.l lVar) {
        return (o) super.z(lVar);
    }
}
