discord-jadx/app/src/main/java/c/i/e/s/a.java

338 lines
13 KiB
Java

package c.i.e.s;
import c.i.e.c;
import c.i.e.d;
import c.i.e.i;
import c.i.e.k;
import c.i.e.l;
import c.i.e.n.b;
import c.i.e.s.b.e;
import c.i.e.s.b.j;
import c.i.e.s.c.e;
import c.i.e.s.c.f;
import com.google.zxing.ChecksumException;
import com.google.zxing.FormatException;
import com.google.zxing.NotFoundException;
import com.google.zxing.Result;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/* compiled from: QRCodeReader */
public class a implements i {
public static final k[] a = new k[0];
public final e b = new e();
@Override // c.i.e.i
public final Result a(c cVar, Map<d, ?> map) throws NotFoundException, ChecksumException, FormatException {
k[] kVarArr;
c.i.e.n.e eVar;
int i;
c.i.e.s.c.a aVar;
float f;
float f2;
float f3;
int i2;
int i3;
if (map == null || !map.containsKey(d.PURE_BARCODE)) {
b a2 = cVar.a();
c.i.e.s.c.c cVar2 = new c.i.e.s.c.c(a2);
l lVar = map == null ? null : (l) map.get(d.NEED_RESULT_POINT_CALLBACK);
cVar2.b = lVar;
c.i.e.s.c.e eVar2 = new c.i.e.s.c.e(a2, lVar);
boolean z2 = map != null && map.containsKey(d.TRY_HARDER);
int i4 = a2.j;
int i5 = a2.i;
int i6 = (i4 * 3) / 388;
if (i6 < 3 || z2) {
i6 = 3;
}
int[] iArr = new int[5];
int i7 = i6 - 1;
boolean z3 = false;
while (true) {
int i8 = 4;
if (i7 >= i4 || z3) {
break;
}
eVar2.b(iArr);
int i9 = 0;
int i10 = 0;
while (i9 < i5) {
if (eVar2.a.f(i9, i7)) {
if ((i10 & 1) == 1) {
i10++;
}
iArr[i10] = iArr[i10] + 1;
} else if ((i10 & 1) != 0) {
iArr[i10] = iArr[i10] + 1;
} else if (i10 == i8) {
if (!c.i.e.s.c.e.c(iArr)) {
eVar2.g(iArr);
} else if (eVar2.e(iArr, i7, i9)) {
if (eVar2.f1451c) {
z3 = eVar2.f();
} else {
if (eVar2.b.size() > 1) {
Iterator<c.i.e.s.c.d> it = eVar2.b.iterator();
c.i.e.s.c.d dVar = null;
while (true) {
if (!it.hasNext()) {
break;
}
c.i.e.s.c.d next = it.next();
if (next.d >= 2) {
if (dVar != null) {
eVar2.f1451c = true;
i2 = 2;
i3 = ((int) (Math.abs(dVar.a - next.a) - Math.abs(dVar.b - next.b))) / 2;
break;
}
dVar = next;
}
}
}
i2 = 2;
i3 = 0;
if (i3 > iArr[i2]) {
i7 += (i3 - iArr[i2]) - i2;
i9 = i5 - 1;
}
}
eVar2.b(iArr);
i6 = 2;
i10 = 0;
} else {
eVar2.g(iArr);
}
i10 = 3;
} else {
i10++;
iArr[i10] = iArr[i10] + 1;
}
i9++;
i8 = 4;
}
if (c.i.e.s.c.e.c(iArr) && eVar2.e(iArr, i7, i5)) {
i6 = iArr[0];
if (eVar2.f1451c) {
z3 = eVar2.f();
}
}
i7 += i6;
}
int size = eVar2.b.size();
if (size >= 3) {
float f4 = 0.0f;
if (size > 3) {
float f5 = 0.0f;
float f6 = 0.0f;
for (c.i.e.s.c.d dVar2 : eVar2.b) {
float f7 = dVar2.f1450c;
f5 += f7;
f6 += f7 * f7;
}
float f8 = (float) size;
float f9 = f5 / f8;
Collections.sort(eVar2.b, new e.c(f9, null));
float max = Math.max(0.2f * f9, (float) Math.sqrt((double) ((f6 / f8) - (f9 * f9))));
int i11 = 0;
while (i11 < eVar2.b.size() && eVar2.b.size() > 3) {
if (Math.abs(eVar2.b.get(i11).f1450c - f9) > max) {
eVar2.b.remove(i11);
i11--;
}
i11++;
}
}
if (eVar2.b.size() > 3) {
for (c.i.e.s.c.d dVar3 : eVar2.b) {
f4 += dVar3.f1450c;
}
Collections.sort(eVar2.b, new e.b(f4 / ((float) eVar2.b.size()), null));
List<c.i.e.s.c.d> list = eVar2.b;
i = 3;
list.subList(3, list.size()).clear();
} else {
i = 3;
}
c.i.e.s.c.d[] dVarArr = new c.i.e.s.c.d[i];
dVarArr[0] = eVar2.b.get(0);
dVarArr[1] = eVar2.b.get(1);
dVarArr[2] = eVar2.b.get(2);
k.b(dVarArr);
f fVar = new f(dVarArr);
c.i.e.s.c.d dVar4 = fVar.b;
c.i.e.s.c.d dVar5 = fVar.f1452c;
c.i.e.s.c.d dVar6 = fVar.a;
float a3 = (cVar2.a(dVar4, dVar6) + cVar2.a(dVar4, dVar5)) / 2.0f;
if (a3 >= 1.0f) {
int g02 = ((c.i.a.f.e.o.c.g0(c.i.a.f.e.o.c.x(dVar4.a, dVar4.b, dVar6.a, dVar6.b) / a3) + c.i.a.f.e.o.c.g0(c.i.a.f.e.o.c.x(dVar4.a, dVar4.b, dVar5.a, dVar5.b) / a3)) / 2) + 7;
int i12 = g02 & 3;
if (i12 == 0) {
g02++;
} else if (i12 == 2) {
g02--;
} else if (i12 == 3) {
throw NotFoundException.k;
}
int[] iArr2 = j.a;
if (g02 % 4 == 1) {
try {
j d = j.d((g02 - 17) / 4);
int c2 = d.c() - 7;
if (d.d.length > 0) {
float f10 = dVar5.a;
float f11 = dVar4.a;
float f12 = (f10 - f11) + dVar6.a;
float f13 = dVar5.b;
float f14 = dVar4.b;
float f15 = 1.0f - (3.0f / ((float) c2));
int a4 = (int) c.d.b.a.a.a(f12, f11, f15, f11);
int a5 = (int) c.d.b.a.a.a((f13 - f14) + dVar6.b, f14, f15, f14);
int i13 = 4;
while (true) {
if (i13 > 16) {
break;
}
try {
aVar = cVar2.b(a3, a4, a5, (float) i13);
break;
} catch (NotFoundException unused) {
i13 <<= 1;
}
}
}
aVar = null;
float f16 = ((float) g02) - 3.5f;
if (aVar != null) {
f2 = aVar.a;
f = aVar.b;
f3 = f16 - 3.0f;
} else {
f2 = (dVar5.a - dVar4.a) + dVar6.a;
f = (dVar5.b - dVar4.b) + dVar6.b;
f3 = f16;
}
b a6 = c.i.e.n.f.a.a(cVar2.a, g02, g02, c.i.e.n.i.a(3.5f, 3.5f, f16, 3.5f, f3, f3, 3.5f, f16, dVar4.a, dVar4.b, dVar5.a, dVar5.b, f2, f, dVar6.a, dVar6.b));
k[] kVarArr2 = aVar == null ? new k[]{dVar6, dVar4, dVar5} : new k[]{dVar6, dVar4, dVar5, aVar};
eVar = this.b.a(a6, map);
kVarArr = kVarArr2;
} catch (IllegalArgumentException unused2) {
throw FormatException.a();
}
} else {
throw FormatException.a();
}
} else {
throw NotFoundException.k;
}
} else {
throw NotFoundException.k;
}
} else {
b a7 = cVar.a();
int[] i14 = a7.i();
int[] g = a7.g();
if (i14 == null || g == null) {
throw NotFoundException.k;
}
int i15 = a7.j;
int i16 = a7.i;
int i17 = i14[0];
int i18 = i14[1];
boolean z4 = true;
int i19 = 0;
while (i17 < i16 && i18 < i15) {
if (z4 != a7.f(i17, i18)) {
i19++;
if (i19 == 5) {
break;
}
z4 = !z4;
}
i17++;
i18++;
}
if (i17 == i16 || i18 == i15) {
throw NotFoundException.k;
}
float f17 = ((float) (i17 - i14[0])) / 7.0f;
int i20 = i14[1];
int i21 = g[1];
int i22 = i14[0];
int i23 = g[0];
if (i22 >= i23 || i20 >= i21) {
throw NotFoundException.k;
}
int i24 = i21 - i20;
if (i24 == i23 - i22 || (i23 = i22 + i24) < a7.i) {
int round = Math.round(((float) ((i23 - i22) + 1)) / f17);
int round2 = Math.round(((float) (i24 + 1)) / f17);
if (round <= 0 || round2 <= 0) {
throw NotFoundException.k;
} else if (round2 == round) {
int i25 = (int) (f17 / 2.0f);
int i26 = i20 + i25;
int i27 = i22 + i25;
int i28 = (((int) (((float) (round - 1)) * f17)) + i27) - i23;
if (i28 > 0) {
if (i28 <= i25) {
i27 -= i28;
} else {
throw NotFoundException.k;
}
}
int i29 = (((int) (((float) (round2 - 1)) * f17)) + i26) - i21;
if (i29 > 0) {
if (i29 <= i25) {
i26 -= i29;
} else {
throw NotFoundException.k;
}
}
b bVar = new b(round, round2);
for (int i30 = 0; i30 < round2; i30++) {
int i31 = ((int) (((float) i30) * f17)) + i26;
for (int i32 = 0; i32 < round; i32++) {
if (a7.f(((int) (((float) i32) * f17)) + i27, i31)) {
bVar.j(i32, i30);
}
}
}
eVar = this.b.a(bVar, map);
kVarArr = a;
} else {
throw NotFoundException.k;
}
} else {
throw NotFoundException.k;
}
}
Object obj = eVar.f;
if ((obj instanceof c.i.e.s.b.i) && ((c.i.e.s.b.i) obj).a && kVarArr.length >= 3) {
k kVar = kVarArr[0];
kVarArr[0] = kVarArr[2];
kVarArr[2] = kVar;
}
Result result = new Result(eVar.f1409c, eVar.a, kVarArr, c.i.e.a.QR_CODE);
List<byte[]> list2 = eVar.d;
if (list2 != null) {
result.b(c.i.e.j.BYTE_SEGMENTS, list2);
}
String str = eVar.e;
if (str != null) {
result.b(c.i.e.j.ERROR_CORRECTION_LEVEL, str);
}
if (eVar.g >= 0 && eVar.h >= 0) {
result.b(c.i.e.j.STRUCTURED_APPEND_SEQUENCE, Integer.valueOf(eVar.h));
result.b(c.i.e.j.STRUCTURED_APPEND_PARITY, Integer.valueOf(eVar.g));
}
return result;
}
@Override // c.i.e.i
public void reset() {
}
}