package o; import java.util.Objects; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; /* loaded from: classes6.dex */ public final class fVY extends fRY implements InterfaceC13204fTr { private InterfaceC13169fSq a; private boolean c; private fSS d; public fVY(InterfaceC13169fSq interfaceC13169fSq, fSS fss, boolean z) { this.a = interfaceC13169fSq; this.d = fss; this.c = z; } @Override // o.fRY public final void c(InterfaceC13154fSb interfaceC13154fSb) { this.a.subscribe(new HBt(interfaceC13154fSb, this.d, this.c)); } @Override // o.InterfaceC13204fTr public final AbstractC13163fSk b() { return new fVU(this.a, this.d, this.c); } /* loaded from: classes6.dex */ static final class HBt extends AtomicInteger implements fSJ, InterfaceC13174fSv { private volatile boolean a; private InterfaceC13154fSb b; private C13355fYI c = new C13355fYI(); final fSC d = new fSC(); private boolean e; private fSJ f; private fSS j; HBt(InterfaceC13154fSb interfaceC13154fSb, fSS fss, boolean z) { this.b = interfaceC13154fSb; this.j = fss; this.e = z; lazySet(1); } @Override // o.InterfaceC13174fSv public final void onSubscribe(fSJ fsj) { if (EnumC13192fTf.d(this.f, fsj)) { this.f = fsj; this.b.onSubscribe(this); } } @Override // o.InterfaceC13174fSv public final void onNext(T t) { try { fRZ frz = (fRZ) Objects.requireNonNull(this.j.a(t), "The mapper returned a null CompletableSource"); getAndIncrement(); IeS ieS = new IeS(this); if (this.a || !this.d.e(ieS)) { return; } frz.e(ieS); } catch (Throwable th) { C13147fSI.c(th); this.f.dispose(); onError(th); } } @Override // o.InterfaceC13174fSv public final void onComplete() { if (decrementAndGet() == 0) { C13355fYI c13355fYI = this.c; InterfaceC13154fSb interfaceC13154fSb = this.b; Throwable b = fYR.b(c13355fYI); if (b == null) { interfaceC13154fSb.onComplete(); } else if (b != fYR.b) { interfaceC13154fSb.onError(b); } } } @Override // o.fSJ public final void dispose() { this.a = true; this.f.dispose(); this.d.dispose(); Throwable b = fYR.b(this.c); if (b == null || b == fYR.b) { return; } C13418fZu.c(b); } @Override // o.fSJ public final boolean isDisposed() { return this.f.isDisposed(); } /* loaded from: classes6.dex */ final class IeS extends AtomicReference implements InterfaceC13154fSb, fSJ { private HBt e; IeS(HBt hBt) { this.e = hBt; } @Override // o.InterfaceC13154fSb public final void onSubscribe(fSJ fsj) { EnumC13192fTf.a(this, fsj); } @Override // o.InterfaceC13154fSb public final void onComplete() { HBt hBt = this.e; hBt.d.b(this); hBt.onComplete(); } @Override // o.InterfaceC13154fSb public final void onError(Throwable th) { HBt hBt = this.e; hBt.d.b(this); hBt.onError(th); } @Override // o.fSJ public final void dispose() { EnumC13192fTf.e(this); } @Override // o.fSJ public final boolean isDisposed() { return EnumC13192fTf.c(get()); } } @Override // o.InterfaceC13174fSv public final void onError(Throwable th) { if (fYR.c(this.c, th)) { if (this.e) { if (decrementAndGet() == 0) { C13355fYI c13355fYI = this.c; InterfaceC13154fSb interfaceC13154fSb = this.b; Throwable b = fYR.b(c13355fYI); if (b == null) { interfaceC13154fSb.onComplete(); return; } else { if (b != fYR.b) { interfaceC13154fSb.onError(b); return; } return; } } return; } this.a = true; this.f.dispose(); this.d.dispose(); C13355fYI c13355fYI2 = this.c; InterfaceC13154fSb interfaceC13154fSb2 = this.b; Throwable b2 = fYR.b(c13355fYI2); if (b2 == null) { interfaceC13154fSb2.onComplete(); return; } else { if (b2 != fYR.b) { interfaceC13154fSb2.onError(b2); return; } return; } } C13418fZu.c(th); } } }