package p463.p484.p485.p489;

import java.io.InvalidObjectException;
import java.io.Serializable;
import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import org.threeten.bp.DateTimeException;
import p138.p139.p143.p144.C2803;
import p463.p473.p474.p479.C7158;
import p463.p484.p485.C7189;
import p463.p484.p485.EnumC7175;
import p463.p484.p485.p486.AbstractC7196;
import p463.p484.p485.p486.AbstractC7202;
import p463.p484.p485.p487.EnumC7250;

/* JADX INFO: renamed from: ޒ.ށ.֏.ޓ.ތ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public final class C7287 implements Serializable {

    /* JADX INFO: renamed from: މ, reason: contains not printable characters */
    public static final ConcurrentMap<String, C7287> f21150 = new ConcurrentHashMap(4, 0.75f, 2);

    /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
    public final EnumC7175 f21151;

    /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
    public final int f21152;

    /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
    public final transient InterfaceC7275 f21153 = new C7288("DayOfWeek", this, EnumC7260.DAYS, EnumC7260.WEEKS, C7288.f21157);

    /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
    public final transient InterfaceC7275 f21154 = new C7288("WeekOfMonth", this, EnumC7260.WEEKS, EnumC7260.MONTHS, C7288.f21158);

    /* JADX INFO: renamed from: އ, reason: contains not printable characters */
    public final transient InterfaceC7275 f21155;

    /* JADX INFO: renamed from: ވ, reason: contains not printable characters */
    public final transient InterfaceC7275 f21156;

    /* JADX INFO: renamed from: ޒ.ށ.֏.ޓ.ތ$֏, reason: contains not printable characters */
    public static class C7288 implements InterfaceC7275 {

        /* JADX INFO: renamed from: ވ, reason: contains not printable characters */
        public static final C7286 f21157 = C7286.m10914(1, 7);

        /* JADX INFO: renamed from: މ, reason: contains not printable characters */
        public static final C7286 f21158 = C7286.m10916(0, 1, 4, 6);

        /* JADX INFO: renamed from: ފ, reason: contains not printable characters */
        public static final C7286 f21159 = C7286.m10916(0, 1, 52, 54);

        /* JADX INFO: renamed from: ދ, reason: contains not printable characters */
        public static final C7286 f21160 = C7286.m10915(1, 52, 53);

        /* JADX INFO: renamed from: ތ, reason: contains not printable characters */
        public static final C7286 f21161 = EnumC7259.YEAR.f21101;

        /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
        public final String f21162;

        /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
        public final C7287 f21163;

        /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
        public final InterfaceC7285 f21164;

        /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
        public final InterfaceC7285 f21165;

        /* JADX INFO: renamed from: އ, reason: contains not printable characters */
        public final C7286 f21166;

        public C7288(String str, C7287 c7287, InterfaceC7285 interfaceC7285, InterfaceC7285 interfaceC72852, C7286 c7286) {
            this.f21162 = str;
            this.f21163 = c7287;
            this.f21164 = interfaceC7285;
            this.f21165 = interfaceC72852;
            this.f21166 = c7286;
        }

        public String toString() {
            return this.f21162 + "[" + this.f21163.toString() + "]";
        }

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final int m10922(int i, int i2) {
            return ((i2 - 1) + (i + 7)) / 7;
        }

        /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
        public final int m10923(InterfaceC7270 interfaceC7270, int i) {
            return C7158.m10544(interfaceC7270.mo10596(EnumC7259.DAY_OF_WEEK) - i, 7) + 1;
        }

        @Override // p463.p484.p485.p489.InterfaceC7275
        /* JADX INFO: renamed from: ֏ */
        public <R extends InterfaceC7269> R mo10898(R r, long j) {
            int iM10917 = this.f21166.m10917(j, this);
            if (iM10917 == r.mo10596(this)) {
                return r;
            }
            if (this.f21165 != EnumC7260.FOREVER) {
                return (R) r.mo10618(iM10917 - r1, this.f21164);
            }
            int iMo10596 = r.mo10596(this.f21163.f21155);
            InterfaceC7269 interfaceC7269Mo10618 = r.mo10618((long) ((j - ((long) r1)) * 52.1775d), EnumC7260.WEEKS);
            if (interfaceC7269Mo10618.mo10596(this) > iM10917) {
                return (R) interfaceC7269Mo10618.mo10614(interfaceC7269Mo10618.mo10596(this.f21163.f21155), EnumC7260.WEEKS);
            }
            if (interfaceC7269Mo10618.mo10596(this) < iM10917) {
                interfaceC7269Mo10618 = interfaceC7269Mo10618.mo10618(2L, EnumC7260.WEEKS);
            }
            R r2 = (R) interfaceC7269Mo10618.mo10618(iMo10596 - interfaceC7269Mo10618.mo10596(this.f21163.f21155), EnumC7260.WEEKS);
            return r2.mo10596(this) > iM10917 ? (R) r2.mo10614(1L, EnumC7260.WEEKS) : r2;
        }

        @Override // p463.p484.p485.p489.InterfaceC7275
        /* JADX INFO: renamed from: ֏ */
        public InterfaceC7270 mo10899(Map<InterfaceC7275, Long> map, InterfaceC7270 interfaceC7270, EnumC7250 enumC7250) {
            long jM10917;
            AbstractC7196 abstractC7196Mo10779;
            long jM10922;
            AbstractC7196 abstractC7196Mo107792;
            long jM109172;
            int iM10923;
            long jM10925;
            int value = this.f21163.f21151.getValue();
            if (this.f21165 == EnumC7260.WEEKS) {
                map.put(EnumC7259.DAY_OF_WEEK, Long.valueOf(C7158.m10544((this.f21166.m10917(map.remove(this).longValue(), this) - 1) + (value - 1), 7) + 1));
                return null;
            }
            if (!map.containsKey(EnumC7259.DAY_OF_WEEK)) {
                return null;
            }
            if (this.f21165 == EnumC7260.FOREVER) {
                if (!map.containsKey(this.f21163.f21155)) {
                    return null;
                }
                AbstractC7202 abstractC7202M10777 = AbstractC7202.m10777(interfaceC7270);
                EnumC7259 enumC7259 = EnumC7259.DAY_OF_WEEK;
                int iM10544 = C7158.m10544(enumC7259.m10897(map.get(enumC7259).longValue()) - value, 7) + 1;
                int iM10917 = this.f21166.m10917(map.get(this).longValue(), this);
                if (enumC7250 == EnumC7250.LENIENT) {
                    abstractC7196Mo107792 = abstractC7202M10777.mo10779(iM10917, 1, this.f21163.f21152);
                    jM109172 = map.get(this.f21163.f21155).longValue();
                    iM10923 = m10923((InterfaceC7270) abstractC7196Mo107792, value);
                    jM10925 = m10925(abstractC7196Mo107792, iM10923);
                } else {
                    abstractC7196Mo107792 = abstractC7202M10777.mo10779(iM10917, 1, this.f21163.f21152);
                    jM109172 = this.f21163.f21155.mo10905().m10917(map.get(this.f21163.f21155).longValue(), this.f21163.f21155);
                    iM10923 = m10923((InterfaceC7270) abstractC7196Mo107792, value);
                    jM10925 = m10925(abstractC7196Mo107792, iM10923);
                }
                AbstractC7196 abstractC7196Mo10618 = abstractC7196Mo107792.mo10618(((jM109172 - jM10925) * 7) + ((long) (iM10544 - iM10923)), (InterfaceC7285) EnumC7260.DAYS);
                if (enumC7250 == EnumC7250.STRICT && abstractC7196Mo10618.mo10597(this) != map.get(this).longValue()) {
                    throw new DateTimeException("Strict mode rejected date parsed to a different year");
                }
                map.remove(this);
                map.remove(this.f21163.f21155);
                map.remove(EnumC7259.DAY_OF_WEEK);
                return abstractC7196Mo10618;
            }
            if (!map.containsKey(EnumC7259.YEAR)) {
                return null;
            }
            EnumC7259 enumC72592 = EnumC7259.DAY_OF_WEEK;
            int iM105442 = C7158.m10544(enumC72592.m10897(map.get(enumC72592).longValue()) - value, 7) + 1;
            EnumC7259 enumC72593 = EnumC7259.YEAR;
            int iM10897 = enumC72593.m10897(map.get(enumC72593).longValue());
            AbstractC7202 abstractC7202M107772 = AbstractC7202.m10777(interfaceC7270);
            InterfaceC7285 interfaceC7285 = this.f21165;
            if (interfaceC7285 != EnumC7260.MONTHS) {
                if (interfaceC7285 != EnumC7260.YEARS) {
                    throw new IllegalStateException("unreachable");
                }
                long jLongValue = map.remove(this).longValue();
                AbstractC7196 abstractC7196Mo107793 = abstractC7202M107772.mo10779(iM10897, 1, 1);
                if (enumC7250 == EnumC7250.LENIENT) {
                    int iM109232 = m10923((InterfaceC7270) abstractC7196Mo107793, value);
                    jM10917 = ((jLongValue - m10925(abstractC7196Mo107793, iM109232)) * 7) + ((long) (iM105442 - iM109232));
                } else {
                    int iM109233 = m10923((InterfaceC7270) abstractC7196Mo107793, value);
                    jM10917 = ((((long) this.f21166.m10917(jLongValue, this)) - m10925(abstractC7196Mo107793, iM109233)) * 7) + ((long) (iM105442 - iM109233));
                }
                AbstractC7196 abstractC7196Mo106182 = abstractC7196Mo107793.mo10618(jM10917, (InterfaceC7285) EnumC7260.DAYS);
                if (enumC7250 == EnumC7250.STRICT && abstractC7196Mo106182.mo10597(EnumC7259.YEAR) != map.get(EnumC7259.YEAR).longValue()) {
                    throw new DateTimeException("Strict mode rejected date parsed to a different year");
                }
                map.remove(this);
                map.remove(EnumC7259.YEAR);
                map.remove(EnumC7259.DAY_OF_WEEK);
                return abstractC7196Mo106182;
            }
            if (!map.containsKey(EnumC7259.MONTH_OF_YEAR)) {
                return null;
            }
            long jLongValue2 = map.remove(this).longValue();
            if (enumC7250 == EnumC7250.LENIENT) {
                abstractC7196Mo10779 = abstractC7202M107772.mo10779(iM10897, 1, 1).mo10618(map.get(EnumC7259.MONTH_OF_YEAR).longValue() - 1, (InterfaceC7285) EnumC7260.MONTHS);
                int iM109234 = m10923((InterfaceC7270) abstractC7196Mo10779, value);
                int iMo10596 = abstractC7196Mo10779.mo10596(EnumC7259.DAY_OF_MONTH);
                jM10922 = ((jLongValue2 - ((long) m10922(m10924(iMo10596, iM109234), iMo10596))) * 7) + ((long) (iM105442 - iM109234));
            } else {
                EnumC7259 enumC72594 = EnumC7259.MONTH_OF_YEAR;
                abstractC7196Mo10779 = abstractC7202M107772.mo10779(iM10897, enumC72594.m10897(map.get(enumC72594).longValue()), 8);
                int iM109235 = m10923((InterfaceC7270) abstractC7196Mo10779, value);
                long jM109173 = this.f21166.m10917(jLongValue2, this);
                int iMo105962 = abstractC7196Mo10779.mo10596(EnumC7259.DAY_OF_MONTH);
                jM10922 = ((jM109173 - ((long) m10922(m10924(iMo105962, iM109235), iMo105962))) * 7) + ((long) (iM105442 - iM109235));
            }
            AbstractC7196 abstractC7196Mo106183 = abstractC7196Mo10779.mo10618(jM10922, (InterfaceC7285) EnumC7260.DAYS);
            if (enumC7250 == EnumC7250.STRICT && abstractC7196Mo106183.mo10597(EnumC7259.MONTH_OF_YEAR) != map.get(EnumC7259.MONTH_OF_YEAR).longValue()) {
                throw new DateTimeException("Strict mode rejected date parsed to a different month");
            }
            map.remove(this);
            map.remove(EnumC7259.YEAR);
            map.remove(EnumC7259.MONTH_OF_YEAR);
            map.remove(EnumC7259.DAY_OF_WEEK);
            return abstractC7196Mo106183;
        }

        @Override // p463.p484.p485.p489.InterfaceC7275
        /* JADX INFO: renamed from: ֏ */
        public boolean mo10900(InterfaceC7270 interfaceC7270) {
            if (!interfaceC7270.mo10595(EnumC7259.DAY_OF_WEEK)) {
                return false;
            }
            InterfaceC7285 interfaceC7285 = this.f21165;
            if (interfaceC7285 == EnumC7260.WEEKS) {
                return true;
            }
            if (interfaceC7285 == EnumC7260.MONTHS) {
                return interfaceC7270.mo10595(EnumC7259.DAY_OF_MONTH);
            }
            if (interfaceC7285 == EnumC7260.YEARS) {
                return interfaceC7270.mo10595(EnumC7259.DAY_OF_YEAR);
            }
            if (interfaceC7285 == C7261.f21124 || interfaceC7285 == EnumC7260.FOREVER) {
                return interfaceC7270.mo10595(EnumC7259.EPOCH_DAY);
            }
            return false;
        }

        /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
        public final int m10924(int i, int i2) {
            int iM10544 = C7158.m10544(i - i2, 7);
            return iM10544 + 1 > this.f21163.f21152 ? 7 - iM10544 : -iM10544;
        }

        @Override // p463.p484.p485.p489.InterfaceC7275
        /* JADX INFO: renamed from: ؠ */
        public long mo10901(InterfaceC7270 interfaceC7270) {
            int iM10925;
            int iM10922;
            int iM10544 = C7158.m10544(interfaceC7270.mo10596(EnumC7259.DAY_OF_WEEK) - this.f21163.f21151.getValue(), 7) + 1;
            InterfaceC7285 interfaceC7285 = this.f21165;
            if (interfaceC7285 == EnumC7260.WEEKS) {
                return iM10544;
            }
            if (interfaceC7285 == EnumC7260.MONTHS) {
                int iMo10596 = interfaceC7270.mo10596(EnumC7259.DAY_OF_MONTH);
                iM10922 = m10922(m10924(iMo10596, iM10544), iMo10596);
            } else {
                if (interfaceC7285 != EnumC7260.YEARS) {
                    if (interfaceC7285 == C7261.f21124) {
                        int iM105442 = C7158.m10544(interfaceC7270.mo10596(EnumC7259.DAY_OF_WEEK) - this.f21163.f21151.getValue(), 7) + 1;
                        long jM10925 = m10925(interfaceC7270, iM105442);
                        if (jM10925 == 0) {
                            iM10925 = ((int) m10925(AbstractC7202.m10777(interfaceC7270).mo10781(interfaceC7270).mo10614(1L, (InterfaceC7285) EnumC7260.WEEKS), iM105442)) + 1;
                        } else {
                            if (jM10925 >= 53) {
                                int iM109222 = m10922(m10924(interfaceC7270.mo10596(EnumC7259.DAY_OF_YEAR), iM105442), (C7189.m10721((long) interfaceC7270.mo10596(EnumC7259.YEAR)) ? 366 : 365) + this.f21163.f21152);
                                if (jM10925 >= iM109222) {
                                    jM10925 -= (long) (iM109222 - 1);
                                }
                            }
                            iM10925 = (int) jM10925;
                        }
                        return iM10925;
                    }
                    if (interfaceC7285 != EnumC7260.FOREVER) {
                        throw new IllegalStateException("unreachable");
                    }
                    int iM105443 = C7158.m10544(interfaceC7270.mo10596(EnumC7259.DAY_OF_WEEK) - this.f21163.f21151.getValue(), 7) + 1;
                    int iMo105962 = interfaceC7270.mo10596(EnumC7259.YEAR);
                    long jM109252 = m10925(interfaceC7270, iM105443);
                    if (jM109252 == 0) {
                        iMo105962--;
                    } else if (jM109252 >= 53) {
                        if (jM109252 >= m10922(m10924(interfaceC7270.mo10596(EnumC7259.DAY_OF_YEAR), iM105443), (C7189.m10721((long) iMo105962) ? 366 : 365) + this.f21163.f21152)) {
                            iMo105962++;
                        }
                    }
                    return iMo105962;
                }
                int iMo105963 = interfaceC7270.mo10596(EnumC7259.DAY_OF_YEAR);
                iM10922 = m10922(m10924(iMo105963, iM10544), iMo105963);
            }
            return iM10922;
        }

        /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
        public final long m10925(InterfaceC7270 interfaceC7270, int i) {
            int iMo10596 = interfaceC7270.mo10596(EnumC7259.DAY_OF_YEAR);
            return m10922(m10924(iMo10596, i), iMo10596);
        }

        @Override // p463.p484.p485.p489.InterfaceC7275
        /* JADX INFO: renamed from: ހ */
        public C7286 mo10902(InterfaceC7270 interfaceC7270) {
            EnumC7259 enumC7259;
            InterfaceC7285 interfaceC7285 = this.f21165;
            if (interfaceC7285 == EnumC7260.WEEKS) {
                return this.f21166;
            }
            if (interfaceC7285 == EnumC7260.MONTHS) {
                enumC7259 = EnumC7259.DAY_OF_MONTH;
            } else {
                if (interfaceC7285 != EnumC7260.YEARS) {
                    if (interfaceC7285 == C7261.f21124) {
                        return m10926(interfaceC7270);
                    }
                    if (interfaceC7285 == EnumC7260.FOREVER) {
                        return interfaceC7270.mo10594(EnumC7259.YEAR);
                    }
                    throw new IllegalStateException("unreachable");
                }
                enumC7259 = EnumC7259.DAY_OF_YEAR;
            }
            int iM10924 = m10924(interfaceC7270.mo10596(enumC7259), C7158.m10544(interfaceC7270.mo10596(EnumC7259.DAY_OF_WEEK) - this.f21163.f21151.getValue(), 7) + 1);
            C7286 c7286Mo10594 = interfaceC7270.mo10594(enumC7259);
            return C7286.m10914(m10922(iM10924, (int) c7286Mo10594.f21146), m10922(iM10924, (int) c7286Mo10594.f21149));
        }

        /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
        public final C7286 m10926(InterfaceC7270 interfaceC7270) {
            int iM10544 = C7158.m10544(interfaceC7270.mo10596(EnumC7259.DAY_OF_WEEK) - this.f21163.f21151.getValue(), 7) + 1;
            long jM10925 = m10925(interfaceC7270, iM10544);
            if (jM10925 == 0) {
                return m10926(AbstractC7202.m10777(interfaceC7270).mo10781(interfaceC7270).mo10614(2L, (InterfaceC7285) EnumC7260.WEEKS));
            }
            return jM10925 >= ((long) m10922(m10924(interfaceC7270.mo10596(EnumC7259.DAY_OF_YEAR), iM10544), (C7189.m10721((long) interfaceC7270.mo10596(EnumC7259.YEAR)) ? 366 : 365) + this.f21163.f21152)) ? m10926(AbstractC7202.m10777(interfaceC7270).mo10781(interfaceC7270).mo10618(2L, (InterfaceC7285) EnumC7260.WEEKS)) : C7286.m10914(1L, r0 - 1);
        }

        @Override // p463.p484.p485.p489.InterfaceC7275
        /* JADX INFO: renamed from: ބ */
        public boolean mo10903() {
            return true;
        }

        @Override // p463.p484.p485.p489.InterfaceC7275
        /* JADX INFO: renamed from: ޅ */
        public boolean mo10904() {
            return false;
        }

        @Override // p463.p484.p485.p489.InterfaceC7275
        /* JADX INFO: renamed from: ކ */
        public C7286 mo10905() {
            return this.f21166;
        }
    }

    static {
        new C7287(EnumC7175.MONDAY, 4);
        m10921(EnumC7175.SUNDAY, 1);
    }

    public C7287(EnumC7175 enumC7175, int i) {
        new C7288("WeekOfYear", this, EnumC7260.WEEKS, EnumC7260.YEARS, C7288.f21159);
        this.f21155 = new C7288("WeekOfWeekBasedYear", this, EnumC7260.WEEKS, C7261.f21124, C7288.f21160);
        this.f21156 = new C7288("WeekBasedYear", this, C7261.f21124, EnumC7260.FOREVER, C7288.f21161);
        C7158.m10540(enumC7175, "firstDayOfWeek");
        if (i < 1 || i > 7) {
            throw new IllegalArgumentException("Minimal number of days is invalid");
        }
        this.f21151 = enumC7175;
        this.f21152 = i;
    }

    private Object readResolve() throws InvalidObjectException {
        try {
            return m10921(this.f21151, this.f21152);
        } catch (IllegalArgumentException e) {
            StringBuilder sbM4889 = C2803.m4889("Invalid WeekFields");
            sbM4889.append(e.getMessage());
            throw new InvalidObjectException(sbM4889.toString());
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static C7287 m10920(Locale locale) {
        C7158.m10540(locale, "locale");
        GregorianCalendar gregorianCalendar = new GregorianCalendar(new Locale(locale.getLanguage(), locale.getCountry()));
        long firstDayOfWeek = gregorianCalendar.getFirstDayOfWeek() - 1;
        if (EnumC7175.SUNDAY != null) {
            return m10921(EnumC7175.f20793[((((int) (firstDayOfWeek % 7)) + 7) + 6) % 7], gregorianCalendar.getMinimalDaysInFirstWeek());
        }
        throw null;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static C7287 m10921(EnumC7175 enumC7175, int i) {
        String str = enumC7175.toString() + i;
        C7287 c7287 = f21150.get(str);
        if (c7287 != null) {
            return c7287;
        }
        f21150.putIfAbsent(str, new C7287(enumC7175, i));
        return f21150.get(str);
    }

    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        return (obj instanceof C7287) && hashCode() == obj.hashCode();
    }

    public int hashCode() {
        return (this.f21151.ordinal() * 7) + this.f21152;
    }

    public String toString() {
        StringBuilder sbM4889 = C2803.m4889("WeekFields[");
        sbM4889.append(this.f21151);
        sbM4889.append(',');
        sbM4889.append(this.f21152);
        sbM4889.append(']');
        return sbM4889.toString();
    }
}
