what-the-bank/sources/o/C15538gtR.java

430 lines
17 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package o;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import o.AbstractC15574gua;
/* renamed from: o.gtR, reason: case insensitive filesystem */
/* loaded from: classes6.dex */
final class C15538gtR extends AbstractC15574gua implements Serializable {
private static final int LAST_CACHED_YEAR = 2100;
private static final long serialVersionUID = 3044319355680032515L;
private final gtX[] lastRules;
private final ConcurrentMap<Integer, gtW[]> lastRulesCache = new ConcurrentHashMap();
private final long[] savingsInstantTransitions;
private final C15522gsr[] savingsLocalTransitions;
private final gsI[] standardOffsets;
private final long[] standardTransitions;
private final gsI[] wallOffsets;
/* JADX INFO: Access modifiers changed from: package-private */
public C15538gtR(gsI gsi, gsI gsi2, List<gtW> list, List<gtW> list2, List<gtX> list3) {
this.standardTransitions = new long[list.size()];
gsI[] gsiArr = new gsI[list.size() + 1];
this.standardOffsets = gsiArr;
gsiArr[0] = gsi;
int i = 0;
while (i < list.size()) {
this.standardTransitions[i] = list.get(i).toEpochSecond();
int i2 = i + 1;
this.standardOffsets[i2] = list.get(i).getOffsetAfter();
i = i2;
}
ArrayList arrayList = new ArrayList();
ArrayList arrayList2 = new ArrayList();
arrayList2.add(gsi2);
for (gtW gtw : list2) {
if (gtw.isGap()) {
arrayList.add(gtw.getDateTimeBefore());
arrayList.add(gtw.getDateTimeAfter());
} else {
arrayList.add(gtw.getDateTimeAfter());
arrayList.add(gtw.getDateTimeBefore());
}
arrayList2.add(gtw.getOffsetAfter());
}
this.savingsLocalTransitions = (C15522gsr[]) arrayList.toArray(new C15522gsr[arrayList.size()]);
this.wallOffsets = (gsI[]) arrayList2.toArray(new gsI[arrayList2.size()]);
this.savingsInstantTransitions = new long[list2.size()];
for (int i3 = 0; i3 < list2.size(); i3++) {
this.savingsInstantTransitions[i3] = list2.get(i3).getInstant().getEpochSecond();
}
if (list3.size() > 15) {
throw new IllegalArgumentException("Too many transition rules");
}
this.lastRules = (gtX[]) list3.toArray(new gtX[list3.size()]);
}
private C15538gtR(long[] jArr, gsI[] gsiArr, long[] jArr2, gsI[] gsiArr2, gtX[] gtxArr) {
this.standardTransitions = jArr;
this.standardOffsets = gsiArr;
this.savingsInstantTransitions = jArr2;
this.wallOffsets = gsiArr2;
this.lastRules = gtxArr;
ArrayList arrayList = new ArrayList();
int i = 0;
while (i < jArr2.length) {
int i2 = i + 1;
gtW gtw = new gtW(jArr2[i], gsiArr2[i], gsiArr2[i2]);
if (gtw.isGap()) {
arrayList.add(gtw.getDateTimeBefore());
arrayList.add(gtw.getDateTimeAfter());
} else {
arrayList.add(gtw.getDateTimeAfter());
arrayList.add(gtw.getDateTimeBefore());
}
i = i2;
}
this.savingsLocalTransitions = (C15522gsr[]) arrayList.toArray(new C15522gsr[arrayList.size()]);
}
private Object writeReplace() {
return new gtU((byte) 1, this);
}
/* JADX INFO: Access modifiers changed from: package-private */
public final void writeExternal(DataOutput dataOutput) throws IOException {
dataOutput.writeInt(this.standardTransitions.length);
for (long j : this.standardTransitions) {
gtU.writeEpochSec(j, dataOutput);
}
for (gsI gsi : this.standardOffsets) {
gtU.writeOffset(gsi, dataOutput);
}
dataOutput.writeInt(this.savingsInstantTransitions.length);
for (long j2 : this.savingsInstantTransitions) {
gtU.writeEpochSec(j2, dataOutput);
}
for (gsI gsi2 : this.wallOffsets) {
gtU.writeOffset(gsi2, dataOutput);
}
dataOutput.writeByte(this.lastRules.length);
for (gtX gtx : this.lastRules) {
gtx.writeExternal(dataOutput);
}
}
/* JADX INFO: Access modifiers changed from: package-private */
public static C15538gtR readExternal(DataInput dataInput) throws IOException, ClassNotFoundException {
int readInt = dataInput.readInt();
long[] jArr = new long[readInt];
for (int i = 0; i < readInt; i++) {
jArr[i] = gtU.readEpochSec(dataInput);
}
int i2 = readInt + 1;
gsI[] gsiArr = new gsI[i2];
for (int i3 = 0; i3 < i2; i3++) {
gsiArr[i3] = gtU.readOffset(dataInput);
}
int readInt2 = dataInput.readInt();
long[] jArr2 = new long[readInt2];
for (int i4 = 0; i4 < readInt2; i4++) {
jArr2[i4] = gtU.readEpochSec(dataInput);
}
int i5 = readInt2 + 1;
gsI[] gsiArr2 = new gsI[i5];
for (int i6 = 0; i6 < i5; i6++) {
gsiArr2[i6] = gtU.readOffset(dataInput);
}
int readByte = dataInput.readByte();
gtX[] gtxArr = new gtX[readByte];
for (int i7 = 0; i7 < readByte; i7++) {
gtxArr[i7] = gtX.readExternal(dataInput);
}
return new C15538gtR(jArr, gsiArr, jArr2, gsiArr2, gtxArr);
}
@Override // o.AbstractC15574gua
public final boolean isFixedOffset() {
return this.savingsInstantTransitions.length == 0 && this.lastRules.length == 0 && this.wallOffsets[0].equals(this.standardOffsets[0]);
}
@Override // o.AbstractC15574gua
public final gsI getOffset(C15523gss c15523gss) {
long epochSecond = c15523gss.getEpochSecond();
if (this.lastRules.length > 0) {
long[] jArr = this.savingsInstantTransitions;
if (jArr.length == 0 || epochSecond > jArr[jArr.length - 1]) {
gtW[] findTransitionArray = findTransitionArray(findYear(epochSecond, this.wallOffsets[r7.length - 1]));
gtW gtw = null;
for (int i = 0; i < findTransitionArray.length; i++) {
gtw = findTransitionArray[i];
if (epochSecond < gtw.toEpochSecond()) {
return gtw.getOffsetBefore();
}
}
return gtw.getOffsetAfter();
}
}
int binarySearch = Arrays.binarySearch(this.savingsInstantTransitions, epochSecond);
if (binarySearch < 0) {
binarySearch = (-binarySearch) - 2;
}
return this.wallOffsets[binarySearch + 1];
}
@Override // o.AbstractC15574gua
public final gsI getOffset(C15522gsr c15522gsr) {
Object offsetInfo = getOffsetInfo(c15522gsr);
if (offsetInfo instanceof gtW) {
return ((gtW) offsetInfo).getOffsetBefore();
}
return (gsI) offsetInfo;
}
@Override // o.AbstractC15574gua
public final List<gsI> getValidOffsets(C15522gsr c15522gsr) {
Object offsetInfo = getOffsetInfo(c15522gsr);
if (offsetInfo instanceof gtW) {
return ((gtW) offsetInfo).getValidOffsets();
}
return Collections.singletonList((gsI) offsetInfo);
}
@Override // o.AbstractC15574gua
public final gtW getTransition(C15522gsr c15522gsr) {
Object offsetInfo = getOffsetInfo(c15522gsr);
if (offsetInfo instanceof gtW) {
return (gtW) offsetInfo;
}
return null;
}
private Object getOffsetInfo(C15522gsr c15522gsr) {
int i = 0;
if (this.lastRules.length > 0) {
C15522gsr[] c15522gsrArr = this.savingsLocalTransitions;
if (c15522gsrArr.length == 0 || c15522gsr.isAfter(c15522gsrArr[c15522gsrArr.length - 1])) {
gtW[] findTransitionArray = findTransitionArray(c15522gsr.getYear());
int length = findTransitionArray.length;
Object obj = null;
while (i < length) {
gtW gtw = findTransitionArray[i];
Object findOffsetInfo = findOffsetInfo(c15522gsr, gtw);
if ((findOffsetInfo instanceof gtW) || findOffsetInfo.equals(gtw.getOffsetBefore())) {
return findOffsetInfo;
}
i++;
obj = findOffsetInfo;
}
return obj;
}
}
int binarySearch = Arrays.binarySearch(this.savingsLocalTransitions, c15522gsr);
if (binarySearch == -1) {
return this.wallOffsets[0];
}
if (binarySearch < 0) {
binarySearch = (-binarySearch) - 2;
} else {
Object[] objArr = this.savingsLocalTransitions;
if (binarySearch < objArr.length - 1) {
int i2 = binarySearch + 1;
if (objArr[binarySearch].equals(objArr[i2])) {
binarySearch = i2;
}
}
}
if ((binarySearch & 1) == 0) {
C15522gsr[] c15522gsrArr2 = this.savingsLocalTransitions;
C15522gsr c15522gsr2 = c15522gsrArr2[binarySearch];
C15522gsr c15522gsr3 = c15522gsrArr2[binarySearch + 1];
gsI[] gsiArr = this.wallOffsets;
int i3 = binarySearch / 2;
gsI gsi = gsiArr[i3];
gsI gsi2 = gsiArr[i3 + 1];
if (gsi2.getTotalSeconds() > gsi.getTotalSeconds()) {
return new gtW(c15522gsr2, gsi, gsi2);
}
return new gtW(c15522gsr3, gsi, gsi2);
}
return this.wallOffsets[(binarySearch / 2) + 1];
}
private Object findOffsetInfo(C15522gsr c15522gsr, gtW gtw) {
C15522gsr dateTimeBefore = gtw.getDateTimeBefore();
if (gtw.isGap()) {
if (c15522gsr.isBefore(dateTimeBefore)) {
return gtw.getOffsetBefore();
}
return c15522gsr.isBefore(gtw.getDateTimeAfter()) ? gtw : gtw.getOffsetAfter();
}
if (c15522gsr.isBefore(dateTimeBefore)) {
return c15522gsr.isBefore(gtw.getDateTimeAfter()) ? gtw.getOffsetBefore() : gtw;
}
return gtw.getOffsetAfter();
}
@Override // o.AbstractC15574gua
public final boolean isValidOffset(C15522gsr c15522gsr, gsI gsi) {
return getValidOffsets(c15522gsr).contains(gsi);
}
private gtW[] findTransitionArray(int i) {
Integer valueOf = Integer.valueOf(i);
gtW[] gtwArr = this.lastRulesCache.get(valueOf);
if (gtwArr != null) {
return gtwArr;
}
gtX[] gtxArr = this.lastRules;
gtW[] gtwArr2 = new gtW[gtxArr.length];
for (int i2 = 0; i2 < gtxArr.length; i2++) {
gtwArr2[i2] = gtxArr[i2].createTransition(i);
}
if (i < LAST_CACHED_YEAR) {
this.lastRulesCache.putIfAbsent(valueOf, gtwArr2);
}
return gtwArr2;
}
@Override // o.AbstractC15574gua
public final gsI getStandardOffset(C15523gss c15523gss) {
int binarySearch = Arrays.binarySearch(this.standardTransitions, c15523gss.getEpochSecond());
if (binarySearch < 0) {
binarySearch = (-binarySearch) - 2;
}
return this.standardOffsets[binarySearch + 1];
}
@Override // o.AbstractC15574gua
public final C15519gso getDaylightSavings(C15523gss c15523gss) {
return C15519gso.ofSeconds(getOffset(c15523gss).getTotalSeconds() - getStandardOffset(c15523gss).getTotalSeconds());
}
@Override // o.AbstractC15574gua
public final boolean isDaylightSavings(C15523gss c15523gss) {
return !getStandardOffset(c15523gss).equals(getOffset(c15523gss));
}
@Override // o.AbstractC15574gua
public final gtW nextTransition(C15523gss c15523gss) {
if (this.savingsInstantTransitions.length == 0) {
return null;
}
long epochSecond = c15523gss.getEpochSecond();
long[] jArr = this.savingsInstantTransitions;
if (epochSecond >= jArr[jArr.length - 1]) {
if (this.lastRules.length == 0) {
return null;
}
int findYear = findYear(epochSecond, this.wallOffsets[r11.length - 1]);
for (gtW gtw : findTransitionArray(findYear)) {
if (epochSecond < gtw.toEpochSecond()) {
return gtw;
}
}
if (findYear < 999999999) {
return findTransitionArray(findYear + 1)[0];
}
return null;
}
int binarySearch = Arrays.binarySearch(jArr, epochSecond);
int i = binarySearch < 0 ? (-binarySearch) - 1 : binarySearch + 1;
long j = this.savingsInstantTransitions[i];
gsI[] gsiArr = this.wallOffsets;
return new gtW(j, gsiArr[i], gsiArr[i + 1]);
}
@Override // o.AbstractC15574gua
public final gtW previousTransition(C15523gss c15523gss) {
if (this.savingsInstantTransitions.length == 0) {
return null;
}
long epochSecond = c15523gss.getEpochSecond();
if (c15523gss.getNano() > 0 && epochSecond < Long.MAX_VALUE) {
epochSecond++;
}
long j = this.savingsInstantTransitions[r11.length - 1];
if (this.lastRules.length > 0 && epochSecond > j) {
gsI gsi = this.wallOffsets[r11.length - 1];
int findYear = findYear(epochSecond, gsi);
gtW[] findTransitionArray = findTransitionArray(findYear);
for (int length = findTransitionArray.length - 1; length >= 0; length--) {
if (epochSecond > findTransitionArray[length].toEpochSecond()) {
return findTransitionArray[length];
}
}
int i = findYear - 1;
if (i > findYear(j, gsi)) {
return findTransitionArray(i)[r11.length - 1];
}
}
int binarySearch = Arrays.binarySearch(this.savingsInstantTransitions, epochSecond);
if (binarySearch < 0) {
binarySearch = (-binarySearch) - 1;
}
if (binarySearch <= 0) {
return null;
}
int i2 = binarySearch - 1;
long j2 = this.savingsInstantTransitions[i2];
gsI[] gsiArr = this.wallOffsets;
return new gtW(j2, gsiArr[i2], gsiArr[binarySearch]);
}
private int findYear(long j, gsI gsi) {
return C15520gsp.ofEpochDay(gtG.floorDiv(j + gsi.getTotalSeconds(), 86400L)).getYear();
}
@Override // o.AbstractC15574gua
public final List<gtW> getTransitions() {
ArrayList arrayList = new ArrayList();
int i = 0;
while (true) {
long[] jArr = this.savingsInstantTransitions;
if (i < jArr.length) {
long j = jArr[i];
gsI[] gsiArr = this.wallOffsets;
gsI gsi = gsiArr[i];
i++;
arrayList.add(new gtW(j, gsi, gsiArr[i]));
} else {
return Collections.unmodifiableList(arrayList);
}
}
}
@Override // o.AbstractC15574gua
public final List<gtX> getTransitionRules() {
return Collections.unmodifiableList(Arrays.asList(this.lastRules));
}
@Override // o.AbstractC15574gua
public final boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof C15538gtR) {
C15538gtR c15538gtR = (C15538gtR) obj;
return Arrays.equals(this.standardTransitions, c15538gtR.standardTransitions) && Arrays.equals(this.standardOffsets, c15538gtR.standardOffsets) && Arrays.equals(this.savingsInstantTransitions, c15538gtR.savingsInstantTransitions) && Arrays.equals(this.wallOffsets, c15538gtR.wallOffsets) && Arrays.equals(this.lastRules, c15538gtR.lastRules);
}
if (obj instanceof AbstractC15574gua.IeS) {
return isFixedOffset() && getOffset(C15523gss.EPOCH).equals(((AbstractC15574gua.IeS) obj).getOffset(C15523gss.EPOCH));
}
return false;
}
@Override // o.AbstractC15574gua
public final int hashCode() {
int hashCode = Arrays.hashCode(this.standardTransitions);
int hashCode2 = Arrays.hashCode(this.standardOffsets);
int hashCode3 = Arrays.hashCode(this.savingsInstantTransitions);
return (((hashCode ^ hashCode2) ^ hashCode3) ^ Arrays.hashCode(this.wallOffsets)) ^ Arrays.hashCode(this.lastRules);
}
public final String toString() {
StringBuilder sb = new StringBuilder("StandardZoneRules[currentStandardOffset=");
sb.append(this.standardOffsets[r1.length - 1]);
sb.append("]");
return sb.toString();
}
}