package o; import java.util.Objects; import java.util.concurrent.atomic.AtomicReference; /* loaded from: classes6.dex */ public final class fUL extends fRY { private fSS a; private EnumC13357fYN b; private int c; private AbstractC13163fSk e; public fUL(AbstractC13163fSk abstractC13163fSk, fSS fss, EnumC13357fYN enumC13357fYN, int i) { this.e = abstractC13163fSk; this.a = fss; this.b = enumC13357fYN; this.c = i; } @Override // o.fRY public final void c(InterfaceC13154fSb interfaceC13154fSb) { if (fUP.d(this.e, this.a, interfaceC13154fSb)) { return; } this.e.subscribe(new Sts(interfaceC13154fSb, this.a, this.b, this.c)); } /* loaded from: classes6.dex */ static final class Sts extends fUJ { private InterfaceC13154fSb g; volatile boolean h; private IeS i; private fSS j; Sts(InterfaceC13154fSb interfaceC13154fSb, fSS fss, EnumC13357fYN enumC13357fYN, int i) { super(i, enumC13357fYN); this.g = interfaceC13154fSb; this.j = fss; this.i = new IeS(this); } @Override // o.fUJ final void c() { this.g.onSubscribe(this); } @Override // o.fUJ final void e() { fRZ frz; boolean z; if (getAndIncrement() != 0) { return; } C13355fYI c13355fYI = this.b; EnumC13357fYN enumC13357fYN = this.e; InterfaceC13414fZq interfaceC13414fZq = this.d; while (!this.c) { if (c13355fYI.get() != null && (enumC13357fYN == EnumC13357fYN.IMMEDIATE || (enumC13357fYN == EnumC13357fYN.BOUNDARY && !this.h))) { this.c = true; interfaceC13414fZq.e(); InterfaceC13154fSb interfaceC13154fSb = this.g; Throwable b = fYR.b(c13355fYI); if (b == null) { interfaceC13154fSb.onComplete(); return; } else { if (b != fYR.b) { interfaceC13154fSb.onError(b); return; } return; } } if (!this.h) { boolean z2 = this.a; try { T b2 = interfaceC13414fZq.b(); if (b2 != null) { frz = (fRZ) Objects.requireNonNull(this.j.a(b2), "The mapper returned a null CompletableSource"); z = false; } else { frz = null; z = true; } if (z2 && z) { this.c = true; InterfaceC13154fSb interfaceC13154fSb2 = this.g; Throwable b3 = fYR.b(c13355fYI); if (b3 == null) { interfaceC13154fSb2.onComplete(); return; } else { if (b3 != fYR.b) { interfaceC13154fSb2.onError(b3); return; } return; } } if (!z) { this.h = true; frz.e(this.i); } } catch (Throwable th) { C13147fSI.c(th); this.c = true; interfaceC13414fZq.e(); this.f.dispose(); if (!fYR.c(c13355fYI, th)) { C13418fZu.c(th); } InterfaceC13154fSb interfaceC13154fSb3 = this.g; Throwable b4 = fYR.b(c13355fYI); if (b4 == null) { interfaceC13154fSb3.onComplete(); return; } else { if (b4 != fYR.b) { interfaceC13154fSb3.onError(b4); return; } return; } } } if (decrementAndGet() == 0) { return; } } interfaceC13414fZq.e(); } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes6.dex */ public static final class IeS extends AtomicReference implements InterfaceC13154fSb { private Sts b; IeS(Sts sts) { this.b = sts; } @Override // o.InterfaceC13154fSb public final void onSubscribe(fSJ fsj) { EnumC13192fTf.c(this, fsj); } @Override // o.InterfaceC13154fSb public final void onComplete() { Sts sts = this.b; sts.h = false; sts.e(); } @Override // o.InterfaceC13154fSb public final void onError(Throwable th) { Sts sts = this.b; if (fYR.c(sts.b, th)) { if (sts.e != EnumC13357fYN.END) { sts.f.dispose(); } sts.h = false; sts.e(); return; } C13418fZu.c(th); } } @Override // o.fUJ final void a() { EnumC13192fTf.e(this.i); } } }