package o; import com.google.android.gms.maps.model.BitmapDescriptorFactory; import java.util.Arrays; import java.util.HashMap; import o.EsB; /* loaded from: classes.dex */ public final class Npn { public static boolean e = false; private static int g = 1000; private static long i; paA[] a; public final ogI d; private LWm k; private LWm r; public boolean c = false; private int p = 0; private HashMap q = null; private int j = 32; private int n = 32; public boolean b = false; public boolean f = false; private boolean[] h = new boolean[32]; /* renamed from: o, reason: collision with root package name */ private int f8291o = 1; private int l = 0; private int m = 32; private EsB[] s = new EsB[g]; private int t = 0; /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes.dex */ public interface LWm { EsB b(); void c(EsB esB); void c(LWm lWm); void d(); EsB e(boolean[] zArr); boolean f(); } public Npn() { this.a = null; this.a = new paA[32]; i(); ogI ogi = new ogI(); this.d = ogi; this.k = new C16577pTo(ogi); this.r = new paA(ogi); } private void j() { int i2 = this.j << 1; this.j = i2; this.a = (paA[]) Arrays.copyOf(this.a, i2); ogI ogi = this.d; ogi.b = (EsB[]) Arrays.copyOf(ogi.b, this.j); int i3 = this.j; this.h = new boolean[i3]; this.n = i3; this.m = i3; } private void i() { for (int i2 = 0; i2 < this.l; i2++) { paA paa = this.a[i2]; if (paa != null) { this.d.c.a(paa); } this.a[i2] = null; } } public final void a() { for (int i2 = 0; i2 < this.d.b.length; i2++) { EsB esB = this.d.b[i2]; if (esB != null) { esB.c(); } } this.d.e.c(this.s, this.t); this.t = 0; Arrays.fill(this.d.b, (Object) null); this.p = 0; this.k.d(); this.f8291o = 1; for (int i3 = 0; i3 < this.l; i3++) { paA paa = this.a[i3]; if (paa != null) { paa.a = false; } } i(); this.l = 0; this.r = new paA(this.d); } public final EsB b(Object obj) { EsB esB = null; if (obj == null) { return null; } if (this.f8291o + 1 >= this.n) { j(); } if (obj instanceof C1230Yni) { C1230Yni c1230Yni = (C1230Yni) obj; esB = c1230Yni.h; if (esB == null) { EsB esB2 = c1230Yni.h; if (esB2 == null) { c1230Yni.h = new EsB(EsB.RVV.UNRESTRICTED); } else { esB2.c(); } esB = c1230Yni.h; } if (esB.d == -1 || esB.d > this.p || this.d.b[esB.d] == null) { if (esB.d != -1) { esB.c(); } int i2 = this.p + 1; this.p = i2; this.f8291o++; esB.d = i2; esB.i = EsB.RVV.UNRESTRICTED; this.d.b[this.p] = esB; } } return esB; } public final paA c() { paA a = this.d.c.a(); if (a == null) { a = new paA(this.d); i++; } else { a.g(); } EsB.b++; return a; } public final EsB d() { if (this.f8291o + 1 >= this.n) { j(); } EsB b = b(EsB.RVV.SLACK); int i2 = this.p + 1; this.p = i2; this.f8291o++; b.d = i2; this.d.b[this.p] = b; return b; } private EsB h() { if (this.f8291o + 1 >= this.n) { j(); } EsB b = b(EsB.RVV.SLACK); int i2 = this.p + 1; this.p = i2; this.f8291o++; b.d = i2; this.d.b[this.p] = b; return b; } public final EsB b(int i2) { if (this.f8291o + 1 >= this.n) { j(); } EsB b = b(EsB.RVV.ERROR); int i3 = this.p + 1; this.p = i3; this.f8291o++; b.d = i3; b.h = i2; this.d.b[this.p] = b; this.k.c(b); return b; } private EsB b(EsB.RVV rvv) { EsB a = this.d.e.a(); if (a == null) { a = new EsB(rvv); a.i = rvv; } else { a.c(); a.i = rvv; } int i2 = this.t; int i3 = g; if (i2 >= i3) { int i4 = i3 << 1; g = i4; this.s = (EsB[]) Arrays.copyOf(this.s, i4); } EsB[] esBArr = this.s; int i5 = this.t; this.t = i5 + 1; esBArr[i5] = a; return a; } public final void e() throws Exception { if (this.k.f()) { b(); return; } if (this.f) { for (int i2 = 0; i2 < this.l; i2++) { if (!this.a[i2].c) { LWm lWm = this.k; g(); a(lWm); b(); return; } } b(); return; } LWm lWm2 = this.k; g(); a(lWm2); b(); } public final void e(paA paa) { EsB esB; if (paa == null) { return; } boolean z = true; if (this.l + 1 >= this.m || this.f8291o + 1 >= this.n) { j(); } if (!paa.c) { paa.b(this); if (paa.f()) { return; } paa.e(); if (paa.a()) { EsB h = h(); paa.b = h; int i2 = this.l; a(paa); if (this.l == i2 + 1) { this.r.c(paa); a(this.r); if (h.a == -1) { if (paa.b == h && (esB = (EsB) paA.c(new Object[]{paa, h}, -1087570060, 1087570061, System.identityHashCode(paa))) != null) { paa.d(esB); } if (!paa.c) { paa.b.c(this, paa); } this.d.c.a(paa); this.l--; } if (((Boolean) paA.c(new Object[]{paa}, 1475961657, -1475961655, System.identityHashCode(paa))).booleanValue() || z) { return; } } } z = false; if (((Boolean) paA.c(new Object[]{paa}, 1475961657, -1475961655, System.identityHashCode(paa))).booleanValue()) { return; } else { return; } } a(paa); } private final void a(paA paa) { int i2; if (paa.c) { paa.b.e(this, paa.d); } else { this.a[this.l] = paa; paa.b.a = this.l; this.l++; paa.b.c(this, paa); } if (this.c) { int i3 = 0; while (i3 < this.l) { if (this.a[i3] == null) { System.out.println("WTF"); } paA paa2 = this.a[i3]; if (paa2 != null && paa2.c) { paA paa3 = this.a[i3]; paa3.b.e(this, paa3.d); this.d.c.a(paa3); this.a[i3] = null; int i4 = i3 + 1; int i5 = i4; while (true) { i2 = this.l; if (i4 >= i2) { break; } paA[] paaArr = this.a; int i6 = i4 - 1; paA paa4 = paaArr[i4]; paaArr[i6] = paa4; if (paa4.b.a == i4) { this.a[i6].b.a = i6; } i5 = i4; i4++; } if (i5 < i2) { this.a[i5] = null; } this.l = i2 - 1; i3--; } i3++; } this.c = false; } } private final int a(LWm lWm) { for (int i2 = 0; i2 < this.f8291o; i2++) { this.h[i2] = false; } boolean z = false; int i3 = 0; while (!z) { i3++; if (i3 >= (this.f8291o << 1)) { return i3; } if (lWm.b() != null) { this.h[lWm.b().d] = true; } EsB e2 = lWm.e(this.h); if (e2 != null) { if (this.h[e2.d]) { return i3; } this.h[e2.d] = true; } if (e2 != null) { float f = Float.MAX_VALUE; int i4 = -1; for (int i5 = 0; i5 < this.l; i5++) { paA paa = this.a[i5]; if (paa.b.i != EsB.RVV.UNRESTRICTED && !paa.c && paa.b(e2)) { float e3 = paa.e.e(e2); if (e3 < BitmapDescriptorFactory.HUE_RED) { float f2 = (-paa.d) / e3; if (f2 < f) { i4 = i5; f = f2; } } } } if (i4 >= 0) { paA paa2 = this.a[i4]; paa2.b.a = -1; paa2.d(e2); paa2.b.a = i4; paa2.b.c(this, paa2); } } else { z = true; } } return i3; } private int g() throws Exception { for (int i2 = 0; i2 < this.l; i2++) { if (this.a[i2].b.i != EsB.RVV.UNRESTRICTED) { float f = this.a[i2].d; float f2 = BitmapDescriptorFactory.HUE_RED; if (f < BitmapDescriptorFactory.HUE_RED) { boolean z = false; int i3 = 0; while (!z) { i3++; float f3 = Float.MAX_VALUE; int i4 = -1; int i5 = -1; int i6 = 0; int i7 = 0; while (i6 < this.l) { paA paa = this.a[i6]; if (paa.b.i != EsB.RVV.UNRESTRICTED && !paa.c && paa.d < f2) { int c = paa.e.c(); int i8 = 0; while (i8 < c) { EsB d = paa.e.d(i8); float e2 = paa.e.e(d); if (e2 > f2) { for (int i9 = 0; i9 < 9; i9++) { float f4 = d.m[i9] / e2; if ((f4 < f3 && i9 == i7) || i9 > i7) { i5 = d.d; i7 = i9; f3 = f4; i4 = i6; } } } i8++; f2 = BitmapDescriptorFactory.HUE_RED; } } i6++; f2 = BitmapDescriptorFactory.HUE_RED; } if (i4 != -1) { paA paa2 = this.a[i4]; paa2.b.a = -1; paa2.d(this.d.b[i5]); paa2.b.a = i4; paa2.b.c(this, paa2); } else { z = true; } if (i3 > this.f8291o / 2) { z = true; } f2 = BitmapDescriptorFactory.HUE_RED; } return i3; } } } return 0; } private void b() { for (int i2 = 0; i2 < this.l; i2++) { paA paa = this.a[i2]; paa.b.c = paa.d; } } public final void e(EsB esB, EsB esB2, int i2, int i3) { paA c = c(); EsB d = d(); d.h = 0; c.a(esB, esB2, d, i2); if (i3 != 8) { c.e(b(i3), (int) (-c.e.e(d))); } e(c); } public final void d(EsB esB, EsB esB2, int i2, int i3) { paA c = c(); EsB d = d(); d.h = 0; c.e(esB, esB2, d, i2); if (i3 != 8) { c.e(b(i3), (int) (-c.e.e(d))); } e(c); } public final void b(EsB esB, EsB esB2, int i2, float f, EsB esB3, EsB esB4, int i3, int i4) { paA c = c(); c.b(esB, esB2, i2, f, esB3, esB4, i3); if (i4 != 8) { c.d(this, i4); } e(c); } public final paA b(EsB esB, EsB esB2, int i2, int i3) { if (i3 == 8 && esB2.g && esB.a == -1) { esB.e(this, esB2.c + i2); return null; } paA c = c(); c.d(esB, esB2, i2); if (i3 != 8) { c.d(this, i3); } e(c); return c; } public final void c(EsB esB, int i2) { if (esB.a == -1) { esB.e(this, i2); for (int i3 = 0; i3 < this.p + 1; i3++) { EsB esB2 = this.d.b[i3]; if (esB2 != null) { boolean z = esB2.f; } } return; } int i4 = esB.a; if (esB.a != -1) { paA paa = this.a[i4]; if (paa.c) { paa.d = i2; return; } if (paa.e.c() == 0) { paa.c = true; paa.d = i2; return; } else { paA c = c(); c.b(esB, i2); e(c); return; } } paA c2 = c(); c2.c(esB, i2); e(c2); } }