package com.applovin.impl; import android.os.Handler; import android.util.Pair; import com.applovin.impl.be; import com.applovin.impl.eb; import com.applovin.impl.fo; import com.mbridge.msdk.playercommon.exoplayer2.C; /* loaded from: classes.dex */ final class ae { private final fo.b a = new fo.b(); private final fo.d b = new fo.d(); private final r0 c; private final Handler d; private long e; private int f; private boolean g; private xd h; private xd i; private xd j; private int k; private Object l; private long m; private boolean a(long j, long j2) { return j == C.TIME_UNSET || j == j2; } public xd d() { return this.j; } public xd e() { return this.h; } public xd f() { return this.i; } public ae(r0 r0Var, Handler handler) { this.c = r0Var; this.d = handler; } public boolean h() { xd xdVar = this.j; return xdVar == null || (!xdVar.f.i && xdVar.j() && this.j.f.e != C.TIME_UNSET && this.k < 100); } public xd b() { xd xdVar = this.i; b1.b((xdVar == null || xdVar.d() == null) ? false : true); this.i = this.i.d(); g(); return this.i; } public xd a() { xd xdVar = this.h; if (xdVar == null) { return null; } if (xdVar == this.i) { this.i = xdVar.d(); } this.h.l(); int i = this.k - 1; this.k = i; if (i == 0) { this.j = null; xd xdVar2 = this.h; this.l = xdVar2.b; this.m = xdVar2.f.a.d; } this.h = this.h.d(); g(); return this.h; } public void c() { if (this.k == 0) { return; } xd xdVar = (xd) b1.b(this.h); this.l = xdVar.b; this.m = xdVar.f.a.d; while (xdVar != null) { xdVar.l(); xdVar = xdVar.d(); } this.h = null; this.j = null; this.i = null; this.k = 0; g(); } private void g() { if (this.c != null) { final eb.a f = eb.f(); for (xd xdVar = this.h; xdVar != null; xdVar = xdVar.d()) { f.b(xdVar.f.a); } xd xdVar2 = this.i; final be.a aVar = xdVar2 == null ? null : xdVar2.f.a; this.d.post(new Runnable() { // from class: com.applovin.impl.ae$$ExternalSyntheticLambda0 @Override // java.lang.Runnable public final void run() { ae.this.a(f, aVar); } }); } } private boolean a(zd zdVar, zd zdVar2) { return zdVar.b == zdVar2.b && zdVar.a.equals(zdVar2.a); } /* JADX WARN: Code restructure failed: missing block: B:6:0x0018, code lost: if (r1 != com.mbridge.msdk.playercommon.exoplayer2.C.TIME_UNSET) goto L8; */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public com.applovin.impl.xd a(com.applovin.impl.ri[] r12, com.applovin.impl.vo r13, com.applovin.impl.n0 r14, com.applovin.impl.fe r15, com.applovin.impl.zd r16, com.applovin.impl.wo r17) { /* r11 = this; r0 = r11 r8 = r16 com.applovin.impl.xd r1 = r0.j if (r1 != 0) goto L1f com.applovin.impl.be$a r1 = r8.a boolean r1 = r1.a() if (r1 == 0) goto L1c long r1 = r8.c r3 = -9223372036854775807(0x8000000000000001, double:-4.9E-324) int r3 = (r1 > r3 ? 1 : (r1 == r3 ? 0 : -1)) if (r3 == 0) goto L1c L1a: r3 = r1 goto L2e L1c: r1 = 0 goto L1a L1f: long r1 = r1.f() com.applovin.impl.xd r3 = r0.j com.applovin.impl.zd r3 = r3.f long r3 = r3.e long r1 = r1 + r3 long r3 = r8.b long r1 = r1 - r3 goto L1a L2e: com.applovin.impl.xd r10 = new com.applovin.impl.xd r1 = r10 r2 = r12 r5 = r13 r6 = r14 r7 = r15 r8 = r16 r9 = r17 r1.(r2, r3, r5, r6, r7, r8, r9) com.applovin.impl.xd r1 = r0.j if (r1 == 0) goto L44 r1.a(r10) goto L48 L44: r0.h = r10 r0.i = r10 L48: r1 = 0 r0.l = r1 r0.j = r10 int r1 = r0.k int r1 = r1 + 1 r0.k = r1 r11.g() return r10 */ throw new UnsupportedOperationException("Method not decompiled: com.applovin.impl.ae.a(com.applovin.impl.ri[], com.applovin.impl.vo, com.applovin.impl.n0, com.applovin.impl.fe, com.applovin.impl.zd, com.applovin.impl.wo):com.applovin.impl.xd"); } private zd a(oh ohVar) { return a(ohVar.a, ohVar.b, ohVar.c, ohVar.s); } private zd a(fo foVar, xd xdVar, long j) { long j2; zd zdVar = xdVar.f; long f = (xdVar.f() + zdVar.e) - j; if (zdVar.g) { long j3 = 0; int a = foVar.a(foVar.a(zdVar.a.a), this.a, this.b, this.f, this.g); if (a == -1) { return null; } int i = foVar.a(a, this.a, true).c; Object obj = this.a.b; long j4 = zdVar.a.d; if (foVar.a(i, this.b).p == a) { Pair a2 = foVar.a(this.b, this.a, i, C.TIME_UNSET, Math.max(0L, f)); if (a2 == null) { return null; } obj = a2.first; long longValue = ((Long) a2.second).longValue(); xd d = xdVar.d(); if (d == null || !d.b.equals(obj)) { j4 = this.e; this.e = 1 + j4; } else { j4 = d.f.a.d; } j2 = longValue; j3 = C.TIME_UNSET; } else { j2 = 0; } return a(foVar, a(foVar, obj, j2, j4, this.a), j3, j2); } be.a aVar = zdVar.a; foVar.a(aVar.a, this.a); if (aVar.a()) { int i2 = aVar.b; int a3 = this.a.a(i2); if (a3 == -1) { return null; } int b = this.a.b(i2, aVar.c); if (b < a3) { return a(foVar, aVar.a, i2, b, zdVar.c, aVar.d); } long j5 = zdVar.c; if (j5 == C.TIME_UNSET) { fo.d dVar = this.b; fo.b bVar = this.a; Pair a4 = foVar.a(dVar, bVar, bVar.c, C.TIME_UNSET, Math.max(0L, f)); if (a4 == null) { return null; } j5 = ((Long) a4.second).longValue(); } return a(foVar, aVar.a, Math.max(a(foVar, aVar.a, aVar.b), j5), zdVar.c, aVar.d); } int d2 = this.a.d(aVar.e); if (d2 == this.a.a(aVar.e)) { return a(foVar, aVar.a, a(foVar, aVar.a, aVar.e), zdVar.e, aVar.d); } return a(foVar, aVar.a, aVar.e, d2, zdVar.e, aVar.d); } private zd a(fo foVar, be.a aVar, long j, long j2) { foVar.a(aVar.a, this.a); if (aVar.a()) { return a(foVar, aVar.a, aVar.b, aVar.c, j, aVar.d); } return a(foVar, aVar.a, j2, j, aVar.d); } private zd a(fo foVar, Object obj, int i, int i2, long j, long j2) { be.a aVar = new be.a(obj, i, i2, j2); long a = foVar.a(aVar.a, this.a).a(aVar.b, aVar.c); long b = i2 == this.a.d(i) ? this.a.b() : 0L; return new zd(aVar, (a == C.TIME_UNSET || b < a) ? b : Math.max(0L, a - 1), j, C.TIME_UNSET, a, this.a.f(aVar.b), false, false, false); } private zd a(fo foVar, Object obj, long j, long j2, long j3) { long j4 = j; foVar.a(obj, this.a); int a = this.a.a(j4); be.a aVar = new be.a(obj, j3, a); boolean a2 = a(aVar); boolean a3 = a(foVar, aVar); boolean a4 = a(foVar, aVar, a2); boolean z = a != -1 && this.a.f(a); long b = a != -1 ? this.a.b(a) : -9223372036854775807L; long j5 = (b == C.TIME_UNSET || b == Long.MIN_VALUE) ? this.a.d : b; if (j5 != C.TIME_UNSET && j4 >= j5) { j4 = Math.max(0L, j5 - 1); } return new zd(aVar, j4, j2, b, j5, z, a2, a3, a4); } private long a(fo foVar, Object obj, int i) { foVar.a(obj, this.a); long b = this.a.b(i); if (b == Long.MIN_VALUE) { return this.a.d; } return b + this.a.c(i); } public zd a(long j, oh ohVar) { xd xdVar = this.j; if (xdVar == null) { return a(ohVar); } return a(ohVar.a, xdVar, j); } /* JADX WARN: Removed duplicated region for block: B:12:0x0062 */ /* JADX WARN: Removed duplicated region for block: B:17:0x006c */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public com.applovin.impl.zd a(com.applovin.impl.fo r19, com.applovin.impl.zd r20) { /* r18 = this; r0 = r18 r1 = r19 r2 = r20 com.applovin.impl.be$a r3 = r2.a boolean r12 = r0.a(r3) boolean r13 = r0.a(r1, r3) boolean r14 = r0.a(r1, r3, r12) com.applovin.impl.be$a r4 = r2.a java.lang.Object r4 = r4.a com.applovin.impl.fo$b r5 = r0.a r1.a(r4, r5) boolean r1 = r3.a() r4 = -9223372036854775807(0x8000000000000001, double:-4.9E-324) r6 = -1 if (r1 != 0) goto L35 int r1 = r3.e if (r1 != r6) goto L2e goto L35 L2e: com.applovin.impl.fo$b r7 = r0.a long r7 = r7.b(r1) goto L36 L35: r7 = r4 L36: boolean r1 = r3.a() if (r1 == 0) goto L48 com.applovin.impl.fo$b r1 = r0.a int r4 = r3.b int r5 = r3.c long r4 = r1.a(r4, r5) L46: r9 = r4 goto L5c L48: int r1 = (r7 > r4 ? 1 : (r7 == r4 ? 0 : -1)) if (r1 == 0) goto L55 r4 = -9223372036854775808 int r1 = (r7 > r4 ? 1 : (r7 == r4 ? 0 : -1)) if (r1 != 0) goto L53 goto L55 L53: r9 = r7 goto L5c L55: com.applovin.impl.fo$b r1 = r0.a long r4 = r1.c() goto L46 L5c: boolean r1 = r3.a() if (r1 == 0) goto L6c com.applovin.impl.fo$b r1 = r0.a int r4 = r3.b boolean r1 = r1.f(r4) L6a: r11 = r1 goto L7c L6c: int r1 = r3.e if (r1 == r6) goto L7a com.applovin.impl.fo$b r4 = r0.a boolean r1 = r4.f(r1) if (r1 == 0) goto L7a r1 = 1 goto L6a L7a: r1 = 0 goto L6a L7c: com.applovin.impl.zd r15 = new com.applovin.impl.zd long r4 = r2.b long r1 = r2.c r16 = r1 r1 = r15 r2 = r3 r3 = r4 r5 = r16 r1.(r2, r3, r5, r7, r9, r11, r12, r13, r14) return r15 */ throw new UnsupportedOperationException("Method not decompiled: com.applovin.impl.ae.a(com.applovin.impl.fo, com.applovin.impl.zd):com.applovin.impl.zd"); } private boolean a(be.a aVar) { return !aVar.a() && aVar.e == -1; } private boolean a(fo foVar, be.a aVar, boolean z) { int a = foVar.a(aVar.a); return !foVar.a(foVar.a(a, this.a).c, this.b).j && foVar.b(a, this.a, this.b, this.f, this.g) && z; } private boolean a(fo foVar, be.a aVar) { if (a(aVar)) { return foVar.a(foVar.a(aVar.a, this.a).c, this.b).q == foVar.a(aVar.a); } return false; } public boolean a(wd wdVar) { xd xdVar = this.j; return xdVar != null && xdVar.a == wdVar; } /* JADX INFO: Access modifiers changed from: private */ public /* synthetic */ void a(eb.a aVar, be.a aVar2) { this.c.a(aVar.a(), aVar2); } public void a(long j) { xd xdVar = this.j; if (xdVar != null) { xdVar.b(j); } } public boolean a(xd xdVar) { boolean z = false; b1.b(xdVar != null); if (xdVar.equals(this.j)) { return false; } this.j = xdVar; while (xdVar.d() != null) { xdVar = xdVar.d(); if (xdVar == this.i) { this.i = this.h; z = true; } xdVar.l(); this.k--; } this.j.a((xd) null); g(); return z; } public be.a a(fo foVar, Object obj, long j) { return a(foVar, obj, j, a(foVar, obj), this.a); } private static be.a a(fo foVar, Object obj, long j, long j2, fo.b bVar) { foVar.a(obj, bVar); int b = bVar.b(j); if (b == -1) { return new be.a(obj, j2, bVar.a(j)); } return new be.a(obj, b, bVar.d(b), j2); } private long a(fo foVar, Object obj) { int a; int i = foVar.a(obj, this.a).c; Object obj2 = this.l; if (obj2 != null && (a = foVar.a(obj2)) != -1 && foVar.a(a, this.a).c == i) { return this.m; } for (xd xdVar = this.h; xdVar != null; xdVar = xdVar.d()) { if (xdVar.b.equals(obj)) { return xdVar.f.a.d; } } for (xd xdVar2 = this.h; xdVar2 != null; xdVar2 = xdVar2.d()) { int a2 = foVar.a(xdVar2.b); if (a2 != -1 && foVar.a(a2, this.a).c == i) { return xdVar2.f.a.d; } } long j = this.e; this.e = 1 + j; if (this.h == null) { this.l = obj; this.m = j; } return j; } private boolean a(fo foVar) { xd xdVar = this.h; if (xdVar == null) { return true; } int a = foVar.a(xdVar.b); while (true) { a = foVar.a(a, this.a, this.b, this.f, this.g); while (xdVar.d() != null && !xdVar.f.g) { xdVar = xdVar.d(); } xd d = xdVar.d(); if (a == -1 || d == null || foVar.a(d.b) != a) { break; } xdVar = d; } boolean a2 = a(xdVar); xdVar.f = a(foVar, xdVar.f); return !a2; } public boolean a(fo foVar, long j, long j2) { boolean a; zd zdVar; xd xdVar = this.h; xd xdVar2 = null; while (xdVar != null) { zd zdVar2 = xdVar.f; if (xdVar2 == null) { zdVar = a(foVar, zdVar2); } else { zd a2 = a(foVar, xdVar2, j); if (a2 == null) { a = a(xdVar2); } else if (a(zdVar2, a2)) { zdVar = a2; } else { a = a(xdVar2); } return !a; } xdVar.f = zdVar.a(zdVar2.c); if (!a(zdVar2.e, zdVar.e)) { xdVar.m(); long j3 = zdVar.e; return (a(xdVar) || (xdVar == this.i && !xdVar.f.f && ((j2 > Long.MIN_VALUE ? 1 : (j2 == Long.MIN_VALUE ? 0 : -1)) == 0 || (j2 > ((j3 > C.TIME_UNSET ? 1 : (j3 == C.TIME_UNSET ? 0 : -1)) == 0 ? Long.MAX_VALUE : xdVar.e(j3)) ? 1 : (j2 == ((j3 > C.TIME_UNSET ? 1 : (j3 == C.TIME_UNSET ? 0 : -1)) == 0 ? Long.MAX_VALUE : xdVar.e(j3)) ? 0 : -1)) >= 0))) ? false : true; } xdVar2 = xdVar; xdVar = xdVar.d(); } return true; } public boolean a(fo foVar, int i) { this.f = i; return a(foVar); } public boolean a(fo foVar, boolean z) { this.g = z; return a(foVar); } }