package j$.time.chrono;

import j$.time.Instant;
import j$.time.LocalDate;
import j$.time.LocalDateTime;
import j$.time.ZoneId;
import j$.time.ZonedDateTime;
import java.io.InvalidObjectException;
import java.io.ObjectInputStream;
import java.io.Serializable;
import java.util.List;
import java.util.Map;

/* JADX INFO: loaded from: classes2.dex */
public final class r extends AbstractC2282a implements Serializable {

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public static final r f19171d = new r();
    private static final long serialVersionUID = -1440403870442975015L;

    @Override // j$.time.chrono.k
    public final l P(int i6) {
        if (i6 == 0) {
            return s.BCE;
        }
        if (i6 == 1) {
            return s.CE;
        }
        throw new j$.time.c("Invalid era: " + i6);
    }

    @Override // j$.time.chrono.k
    public final String s() {
        return "ISO";
    }

    @Override // j$.time.chrono.k
    public final String T() {
        return "iso8601";
    }

    @Override // j$.time.chrono.k
    public final ChronoLocalDate G(int i6, int i7, int i8) {
        return LocalDate.h0(i6, i7, i8);
    }

    @Override // j$.time.chrono.k
    public final ChronoLocalDate z(int i6, int i7) {
        return LocalDate.k0(i6, i7);
    }

    @Override // j$.time.chrono.k
    public final ChronoLocalDate q(long j4) {
        return LocalDate.j0(j4);
    }

    @Override // j$.time.chrono.k
    public final ChronoLocalDate t(j$.time.temporal.n nVar) {
        return LocalDate.J(nVar);
    }

    private r() {
    }

    @Override // j$.time.chrono.k
    public final InterfaceC2285d w(LocalDateTime localDateTime) {
        return LocalDateTime.B(localDateTime);
    }

    @Override // j$.time.chrono.k
    public final ChronoZonedDateTime x(Instant instant, ZoneId zoneId) {
        return ZonedDateTime.B(instant, zoneId);
    }

    @Override // j$.time.chrono.k
    public final ChronoLocalDate M() {
        return LocalDate.J(LocalDate.g0(j$.time.b.c()));
    }

    @Override // j$.time.chrono.k
    public final boolean D(long j4) {
        if ((3 & j4) == 0) {
            return j4 % 100 != 0 || j4 % 400 == 0;
        }
        return false;
    }

    @Override // j$.time.chrono.k
    public final int v(l lVar, int i6) {
        if (lVar instanceof s) {
            return lVar == s.CE ? i6 : 1 - i6;
        }
        throw new ClassCastException("Era must be IsoEra");
    }

    @Override // j$.time.chrono.k
    public final List C() {
        return j$.time.b.b(s.values());
    }

    @Override // j$.time.chrono.AbstractC2282a, j$.time.chrono.k
    public final ChronoLocalDate R(Map map, j$.time.format.G g6) {
        return (LocalDate) super.R(map, g6);
    }

    @Override // j$.time.chrono.AbstractC2282a
    final void U(Map map, j$.time.format.G g6) {
        j$.time.temporal.a aVar = j$.time.temporal.a.PROLEPTIC_MONTH;
        Long l = (Long) map.remove(aVar);
        if (l != null) {
            if (g6 != j$.time.format.G.LENIENT) {
                aVar.c0(l.longValue());
            }
            AbstractC2282a.p(map, j$.time.temporal.a.MONTH_OF_YEAR, ((int) Math.floorMod(l.longValue(), r4)) + 1);
            AbstractC2282a.p(map, j$.time.temporal.a.YEAR, Math.floorDiv(l.longValue(), 12));
        }
    }

    @Override // j$.time.chrono.AbstractC2282a
    final ChronoLocalDate Y(Map map, j$.time.format.G g6) {
        j$.time.temporal.a aVar = j$.time.temporal.a.YEAR_OF_ERA;
        Long l = (Long) map.remove(aVar);
        if (l != null) {
            if (g6 != j$.time.format.G.LENIENT) {
                aVar.c0(l.longValue());
            }
            Long l6 = (Long) map.remove(j$.time.temporal.a.ERA);
            if (l6 != null) {
                if (l6.longValue() == 1) {
                    AbstractC2282a.p(map, j$.time.temporal.a.YEAR, l.longValue());
                    return null;
                }
                if (l6.longValue() == 0) {
                    AbstractC2282a.p(map, j$.time.temporal.a.YEAR, Math.subtractExact(1L, l.longValue()));
                    return null;
                }
                throw new j$.time.c("Invalid value for era: " + l6);
            }
            j$.time.temporal.a aVar2 = j$.time.temporal.a.YEAR;
            Long l7 = (Long) map.get(aVar2);
            if (g6 != j$.time.format.G.STRICT) {
                AbstractC2282a.p(map, aVar2, (l7 == null || l7.longValue() > 0) ? l.longValue() : Math.subtractExact(1L, l.longValue()));
                return null;
            }
            if (l7 != null) {
                long jLongValue = l7.longValue();
                long jLongValue2 = l.longValue();
                if (jLongValue <= 0) {
                    jLongValue2 = Math.subtractExact(1L, jLongValue2);
                }
                AbstractC2282a.p(map, aVar2, jLongValue2);
                return null;
            }
            map.put(aVar, l);
            return null;
        }
        j$.time.temporal.a aVar3 = j$.time.temporal.a.ERA;
        if (!map.containsKey(aVar3)) {
            return null;
        }
        aVar3.c0(((Long) map.get(aVar3)).longValue());
        return null;
    }

    @Override // j$.time.chrono.AbstractC2282a
    final ChronoLocalDate V(Map map, j$.time.format.G g6) {
        j$.time.temporal.a aVar = j$.time.temporal.a.YEAR;
        int iB0 = aVar.b0(((Long) map.remove(aVar)).longValue());
        boolean z6 = true;
        if (g6 == j$.time.format.G.LENIENT) {
            return LocalDate.h0(iB0, 1, 1).n0(Math.subtractExact(((Long) map.remove(j$.time.temporal.a.MONTH_OF_YEAR)).longValue(), 1L)).m0(Math.subtractExact(((Long) map.remove(j$.time.temporal.a.DAY_OF_MONTH)).longValue(), 1L));
        }
        j$.time.temporal.a aVar2 = j$.time.temporal.a.MONTH_OF_YEAR;
        int iB02 = aVar2.b0(((Long) map.remove(aVar2)).longValue());
        j$.time.temporal.a aVar3 = j$.time.temporal.a.DAY_OF_MONTH;
        int iB03 = aVar3.b0(((Long) map.remove(aVar3)).longValue());
        if (g6 == j$.time.format.G.SMART) {
            if (iB02 == 4 || iB02 == 6 || iB02 == 9 || iB02 == 11) {
                iB03 = Math.min(iB03, 30);
            } else if (iB02 == 2) {
                j$.time.n nVar = j$.time.n.FEBRUARY;
                long j4 = iB0;
                int i6 = j$.time.v.f19379b;
                if ((3 & j4) != 0 || (j4 % 100 == 0 && j4 % 400 != 0)) {
                    z6 = false;
                }
                iB03 = Math.min(iB03, nVar.B(z6));
            }
        }
        return LocalDate.h0(iB0, iB02, iB03);
    }

    @Override // j$.time.chrono.k
    public final j$.time.temporal.x W(j$.time.temporal.a aVar) {
        return aVar.B();
    }

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

    Object writeReplace() {
        return new D((byte) 1, this);
    }
}
