package o; import com.airbnb.deeplinkdispatch.base.MatchIndex; import java.io.IOException; import java.io.ObjectInputStream; import java.io.Serializable; import java.text.DateFormatSymbols; import java.text.ParseException; import java.text.ParsePosition; import java.util.ArrayList; import java.util.Calendar; import java.util.Comparator; import java.util.Date; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.ListIterator; import java.util.Locale; import java.util.Map; import java.util.TimeZone; import java.util.TreeSet; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.regex.Matcher; import java.util.regex.Pattern; /* loaded from: classes6.dex */ public final class gjW implements Serializable { private final int p; private transient List u; private final TimeZone v; private final int w; private final Locale x; private final String y; private static Locale g = new Locale("ja", "JP", "JP"); private static final Comparator k = Comparator.reverseOrder(); private static final ConcurrentMap[] s = new ConcurrentMap[17]; private static final saX d = new HBt() { // from class: o.gjW.1 @Override // o.gjW.HBt final int d(gjW gjw, int i2) { return i2 < 100 ? gjW.a(gjw, i2) : i2; } }; private static final saX m = new HBt() { // from class: o.gjW.5 @Override // o.gjW.HBt final int d(gjW gjw, int i2) { return i2 - 1; } }; private static final saX l = new HBt(1); private static final saX r = new HBt(3); private static final saX t = new HBt(4); private static final saX b = new HBt(6); private static final saX e = new HBt(5); private static final saX a = new HBt() { // from class: o.gjW.2 @Override // o.gjW.HBt final int d(gjW gjw, int i2) { if (i2 == 7) { return 1; } return 1 + i2; } }; private static final saX c = new HBt(8); private static final saX h = new HBt(11); private static final saX f = new HBt() { // from class: o.gjW.4 @Override // o.gjW.HBt final int d(gjW gjw, int i2) { if (i2 == 24) { return 0; } return i2; } }; private static final saX j = new HBt() { // from class: o.gjW.3 @Override // o.gjW.HBt final int d(gjW gjw, int i2) { if (i2 == 12) { return 0; } return i2; } }; private static final saX i = new HBt(10); /* renamed from: o, reason: collision with root package name */ private static final saX f9139o = new HBt(12); private static final saX q = new HBt(13); private static final saX n = new HBt(14); static /* synthetic */ boolean c(char c2) { return (c2 >= 'A' && c2 <= 'Z') || (c2 >= 'a' && c2 <= 'z'); } /* JADX INFO: Access modifiers changed from: protected */ public gjW(String str, TimeZone timeZone, Locale locale) { int i2; this.y = str; this.v = timeZone; Locale b2 = gjH.b(locale); this.x = b2; Calendar calendar = Calendar.getInstance(timeZone, b2); if (b2.equals(g)) { i2 = 0; } else { calendar.setTime(new Date()); i2 = calendar.get(1) - 80; } int i3 = (i2 / 100) * 100; this.p = i3; this.w = i2 - i3; c(calendar); } private void c(Calendar calendar) { this.u = new ArrayList(); ojQ ojq = new ojQ(this, calendar); while (true) { ZqN e2 = ojq.e(); if (e2 == null) { return; } else { this.u.add(e2); } } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes6.dex */ public static class ZqN { final saX a; private int e; ZqN(saX sax, int i) { this.a = sax; this.e = i; } final int a(ListIterator listIterator) { if (!this.a.b() || !listIterator.hasNext()) { return 0; } saX sax = listIterator.next().a; listIterator.previous(); if (sax.b()) { return this.e; } return 0; } public final String toString() { StringBuilder sb = new StringBuilder("StrategyAndWidth [strategy="); sb.append(this.a); sb.append(", width="); sb.append(this.e); sb.append("]"); return sb.toString(); } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes6.dex */ public class ojQ { private gjW a; private int b; private final Calendar e; ojQ(gjW gjw, Calendar calendar) { this.a = gjw; this.e = calendar; } final ZqN e() { if (this.b >= this.a.y.length()) { return null; } char charAt = this.a.y.charAt(this.b); if (gjW.c(charAt)) { return c(charAt); } return a(); } private ZqN c(char c) { int i = this.b; do { int i2 = this.b + 1; this.b = i2; if (i2 >= this.a.y.length()) { break; } } while (this.a.y.charAt(this.b) == c); int i3 = this.b - i; return new ZqN(gjW.c(this.a, c, i3, this.e), i3); } private ZqN a() { StringBuilder sb = new StringBuilder(); boolean z = false; while (this.b < this.a.y.length()) { char charAt = this.a.y.charAt(this.b); if (!z && gjW.c(charAt)) { break; } if (charAt == '\'') { int i = this.b + 1; this.b = i; if (i == this.a.y.length() || this.a.y.charAt(this.b) != '\'') { z = !z; } } this.b++; sb.append(charAt); } if (z) { throw new IllegalArgumentException("Unterminated quote"); } String obj = sb.toString(); return new ZqN(new LWm(obj), obj.length()); } } public final boolean equals(Object obj) { if (!(obj instanceof gjW)) { return false; } gjW gjw = (gjW) obj; return this.y.equals(gjw.y) && this.v.equals(gjw.v) && this.x.equals(gjw.x); } public final int hashCode() { return this.y.hashCode() + ((this.v.hashCode() + (this.x.hashCode() * 13)) * 13); } public final String toString() { StringBuilder sb = new StringBuilder("FastDateParser["); sb.append(this.y); sb.append(", "); sb.append(this.x); sb.append(", "); sb.append(this.v.getID()); sb.append("]"); return sb.toString(); } private void readObject(ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException { objectInputStream.defaultReadObject(); c(Calendar.getInstance(this.v, this.x)); } public final Date a(String str) throws ParseException { ParsePosition parsePosition = new ParsePosition(0); Date a2 = a(str, parsePosition); if (a2 != null) { return a2; } if (this.x.equals(g)) { StringBuilder sb = new StringBuilder("(The "); sb.append(this.x); sb.append(" locale does not support dates before 1868 AD)\nUnparseable date: \""); sb.append(str); throw new ParseException(sb.toString(), parsePosition.getErrorIndex()); } throw new ParseException("Unparseable date: ".concat(String.valueOf(str)), parsePosition.getErrorIndex()); } public final Date a(String str, ParsePosition parsePosition) { Calendar calendar = Calendar.getInstance(this.v, this.x); calendar.clear(); if (b(str, parsePosition, calendar)) { return calendar.getTime(); } return null; } private boolean b(String str, ParsePosition parsePosition, Calendar calendar) { ListIterator listIterator = this.u.listIterator(); while (listIterator.hasNext()) { ZqN next = listIterator.next(); if (!next.a.e(this, calendar, str, parsePosition, next.a(listIterator))) { return false; } } return true; } /* JADX INFO: Access modifiers changed from: private */ public static StringBuilder d(StringBuilder sb, String str) { for (int i2 = 0; i2 < str.length(); i2++) { char charAt = str.charAt(i2); if (charAt != '$' && charAt != '.' && charAt != '?' && charAt != '^' && charAt != '[' && charAt != '\\' && charAt != '{' && charAt != '|') { switch (charAt) { } sb.append(charAt); } sb.append('\\'); sb.append(charAt); } if (sb.charAt(sb.length() - 1) == '.') { sb.append('?'); } return sb; } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes6.dex */ public static abstract class saX { boolean b() { return false; } abstract boolean e(gjW gjw, Calendar calendar, String str, ParsePosition parsePosition, int i); private saX() { } /* synthetic */ saX(byte b) { this(); } } /* loaded from: classes6.dex */ static abstract class Sts extends saX { Pattern e; abstract void b(Calendar calendar, String str); @Override // o.gjW.saX final boolean b() { return false; } private Sts() { super((byte) 0); } /* synthetic */ Sts(byte b) { this(); } @Override // o.gjW.saX final boolean e(gjW gjw, Calendar calendar, String str, ParsePosition parsePosition, int i) { Matcher matcher = this.e.matcher(str.substring(parsePosition.getIndex())); if (!matcher.lookingAt()) { parsePosition.setErrorIndex(parsePosition.getIndex()); return false; } parsePosition.setIndex(parsePosition.getIndex() + matcher.end(1)); b(calendar, matcher.group(1)); return true; } public String toString() { StringBuilder sb = new StringBuilder(); sb.append(getClass().getSimpleName()); sb.append(" [pattern="); sb.append(this.e); sb.append("]"); return sb.toString(); } } private static ConcurrentMap b(int i2) { ConcurrentMap concurrentMap; ConcurrentMap[] concurrentMapArr = s; synchronized (concurrentMapArr) { if (concurrentMapArr[i2] == null) { concurrentMapArr[i2] = new ConcurrentHashMap(3); } concurrentMap = concurrentMapArr[i2]; } return concurrentMap; } private saX c(int i2, Calendar calendar) { ConcurrentMap b2 = b(i2); saX sax = b2.get(this.x); if (sax == null) { sax = i2 == 15 ? new tOB(this.x) : new IeS(i2, calendar, this.x); saX putIfAbsent = b2.putIfAbsent(this.x, sax); if (putIfAbsent != null) { return putIfAbsent; } } return sax; } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes6.dex */ public static class LWm extends saX { private final String a; @Override // o.gjW.saX final boolean b() { return false; } LWm(String str) { super((byte) 0); this.a = str; } @Override // o.gjW.saX final boolean e(gjW gjw, Calendar calendar, String str, ParsePosition parsePosition, int i) { for (int i2 = 0; i2 < this.a.length(); i2++) { int index = parsePosition.getIndex() + i2; if (index == str.length()) { parsePosition.setErrorIndex(index); return false; } if (this.a.charAt(i2) != str.charAt(index)) { parsePosition.setErrorIndex(index); return false; } } parsePosition.setIndex(this.a.length() + parsePosition.getIndex()); return true; } public final String toString() { StringBuilder sb = new StringBuilder("CopyQuotedStrategy [formatField="); sb.append(this.a); sb.append("]"); return sb.toString(); } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes6.dex */ public static class IeS extends Sts { private Locale a; private final Map b; private final int c; IeS(int i, Calendar calendar, Locale locale) { super((byte) 0); this.c = i; this.a = gjH.b(locale); StringBuilder sb = new StringBuilder(); sb.append("((?iu)"); this.b = gjW.d(calendar, locale, i, sb); sb.setLength(sb.length() - 1); sb.append(")"); this.e = Pattern.compile(sb.toString()); } @Override // o.gjW.Sts final void b(Calendar calendar, String str) { String lowerCase = str.toLowerCase(this.a); Integer num = this.b.get(lowerCase); if (num == null) { Map map = this.b; StringBuilder sb = new StringBuilder(); sb.append(lowerCase); sb.append('.'); num = map.get(sb.toString()); } calendar.set(this.c, num.intValue()); } @Override // o.gjW.Sts public final String toString() { StringBuilder sb = new StringBuilder("CaseInsensitiveTextStrategy [field="); sb.append(this.c); sb.append(", locale="); sb.append(this.a); sb.append(", lKeyValues="); sb.append(this.b); sb.append(", pattern="); sb.append(this.e); sb.append("]"); return sb.toString(); } } /* loaded from: classes6.dex */ static class HBt extends saX { private final int a; @Override // o.gjW.saX final boolean b() { return true; } int d(gjW gjw, int i) { return i; } HBt(int i) { super((byte) 0); this.a = i; } @Override // o.gjW.saX final boolean e(gjW gjw, Calendar calendar, String str, ParsePosition parsePosition, int i) { int index = parsePosition.getIndex(); int length = str.length(); if (i == 0) { while (index < length && Character.isWhitespace(str.charAt(index))) { index++; } parsePosition.setIndex(index); } else { int i2 = i + index; if (length > i2) { length = i2; } } while (index < length && Character.isDigit(str.charAt(index))) { index++; } if (parsePosition.getIndex() == index) { parsePosition.setErrorIndex(index); return false; } int parseInt = Integer.parseInt(str.substring(parsePosition.getIndex(), index)); parsePosition.setIndex(index); calendar.set(this.a, d(gjw, parseInt)); return true; } public String toString() { StringBuilder sb = new StringBuilder("NumberStrategy [field="); sb.append(this.a); sb.append("]"); return sb.toString(); } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes6.dex */ public static class tOB extends Sts { private final Map a; private final Locale c; /* loaded from: classes6.dex */ static class Sts { final int a; final TimeZone b; Sts(TimeZone timeZone, boolean z) { this.b = timeZone; this.a = z ? timeZone.getDSTSavings() : 0; } } tOB(Locale locale) { super((byte) 0); this.a = new HashMap(); this.c = gjH.b(locale); StringBuilder sb = new StringBuilder(); sb.append("((?iu)[+-]\\d{4}|GMT[+-]\\d{1,2}:\\d{2}"); TreeSet treeSet = new TreeSet(gjW.k); for (String[] strArr : DateFormatSymbols.getInstance(locale).getZoneStrings()) { String str = strArr[0]; if (!str.equalsIgnoreCase("GMT")) { TimeZone timeZone = TimeZone.getTimeZone(str); Sts sts = new Sts(timeZone, false); Sts sts2 = sts; for (int i = 1; i < strArr.length; i++) { if (i == 3) { sts2 = new Sts(timeZone, true); } else if (i == 5) { sts2 = sts; } String str2 = strArr[i]; if (str2 != null) { String lowerCase = str2.toLowerCase(locale); if (treeSet.add(lowerCase)) { this.a.put(lowerCase, sts2); } } } } } for (String str3 : treeSet) { sb.append(MatchIndex.ALLOWED_VALUES_SEPARATOR); gjW.d(sb, str3); } sb.append(")"); this.e = Pattern.compile(sb.toString()); } @Override // o.gjW.Sts final void b(Calendar calendar, String str) { TimeZone d = gjX.d(str); if (d != null) { calendar.setTimeZone(d); return; } String lowerCase = str.toLowerCase(this.c); Sts sts = this.a.get(lowerCase); if (sts == null) { Map map = this.a; StringBuilder sb = new StringBuilder(); sb.append(lowerCase); sb.append('.'); sts = map.get(sb.toString()); } calendar.set(16, sts.a); calendar.set(15, sts.b.getRawOffset()); } @Override // o.gjW.Sts public final String toString() { StringBuilder sb = new StringBuilder("TimeZoneStrategy [locale="); sb.append(this.c); sb.append(", tzNames="); sb.append(this.a); sb.append(", pattern="); sb.append(this.e); sb.append("]"); return sb.toString(); } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes6.dex */ public static class RVV extends Sts { private static final saX c = new RVV("(Z|(?:[+-]\\d{2}))"); private static final saX d = new RVV("(Z|(?:[+-]\\d{2}\\d{2}))"); private static final saX b = new RVV("(Z|(?:[+-]\\d{2}(?::)\\d{2}))"); private RVV(String str) { super((byte) 0); this.e = Pattern.compile(str); } @Override // o.gjW.Sts final void b(Calendar calendar, String str) { calendar.setTimeZone(gjX.d(str)); } static saX c(int i) { if (i == 1) { return c; } if (i == 2) { return d; } if (i == 3) { return b; } throw new IllegalArgumentException("invalid number of X"); } } /* JADX WARN: Failed to find 'out' block for switch in B:5:0x0009. Please report as an issue. */ /* JADX WARN: Failed to find 'out' block for switch in B:6:0x000c. Please report as an issue. */ static /* synthetic */ saX c(gjW gjw, char c2, int i2, Calendar calendar) { if (c2 != 'y') { if (c2 != 'z') { switch (c2) { case 'D': return b; case 'E': return gjw.c(7, calendar); case 'F': return c; case 'G': return gjw.c(0, calendar); case 'H': return h; default: switch (c2) { case 'K': return i; case 'M': return i2 >= 3 ? gjw.c(2, calendar) : m; case 'S': return n; case 'a': return gjw.c(9, calendar); case 'd': return e; case 'h': return j; case 'k': return f; case 'm': return f9139o; case 's': return q; case 'u': return a; case 'w': return r; default: switch (c2) { case 'W': return t; case 'X': return RVV.c(i2); case 'Y': break; case 'Z': if (i2 == 2) { return RVV.b; } break; default: StringBuilder sb = new StringBuilder("Format '"); sb.append(c2); sb.append("' not supported"); throw new IllegalArgumentException(sb.toString()); } } } } return gjw.c(15, calendar); } return i2 > 2 ? l : d; } static /* synthetic */ Map d(Calendar calendar, Locale locale, int i2, StringBuilder sb) { HashMap hashMap = new HashMap(); Locale b2 = gjH.b(locale); Map displayNames = calendar.getDisplayNames(i2, 0, b2); TreeSet treeSet = new TreeSet(k); for (Map.Entry entry : displayNames.entrySet()) { String lowerCase = entry.getKey().toLowerCase(b2); if (treeSet.add(lowerCase)) { hashMap.put(lowerCase, entry.getValue()); } } Iterator it = treeSet.iterator(); while (it.hasNext()) { d(sb, (String) it.next()).append(MatchIndex.ALLOWED_VALUES_SEPARATOR); } return hashMap; } static /* synthetic */ int a(gjW gjw, int i2) { int i3 = gjw.p + i2; return i2 >= gjw.w ? i3 : i3 + 100; } }