package o; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; /* loaded from: classes6.dex */ public final class fWD extends fUX { private fRZ a; public fWD(AbstractC13163fSk abstractC13163fSk, fRZ frz) { super(abstractC13163fSk); this.a = frz; } @Override // o.AbstractC13163fSk public final void subscribeActual(InterfaceC13174fSv interfaceC13174fSv) { IeS ieS = new IeS(interfaceC13174fSv); interfaceC13174fSv.onSubscribe(ieS); this.c.subscribe(ieS); this.a.e(ieS.h); } /* loaded from: classes6.dex */ static final class IeS extends AtomicInteger implements InterfaceC13174fSv, fSJ { final InterfaceC13174fSv a; volatile boolean c; volatile boolean e; final AtomicReference d = new AtomicReference<>(); final Sts h = new Sts(this); final C13355fYI b = new C13355fYI(); IeS(InterfaceC13174fSv interfaceC13174fSv) { this.a = interfaceC13174fSv; } @Override // o.InterfaceC13174fSv public final void onSubscribe(fSJ fsj) { EnumC13192fTf.a(this.d, fsj); } @Override // o.InterfaceC13174fSv public final void onNext(T t) { fYQ.b(this.a, t, this, this.b); } @Override // o.InterfaceC13174fSv public final void onError(Throwable th) { EnumC13192fTf.e(this.h); InterfaceC13174fSv interfaceC13174fSv = this.a; C13355fYI c13355fYI = this.b; if (fYR.c(c13355fYI, th)) { if (getAndIncrement() == 0) { Throwable b = fYR.b(c13355fYI); if (b == null) { interfaceC13174fSv.onComplete(); return; } else { if (b != fYR.b) { interfaceC13174fSv.onError(b); return; } return; } } return; } C13418fZu.c(th); } @Override // o.fSJ public final boolean isDisposed() { return EnumC13192fTf.c(this.d.get()); } @Override // o.fSJ public final void dispose() { EnumC13192fTf.e(this.d); EnumC13192fTf.e(this.h); Throwable b = fYR.b(this.b); if (b == null || b == fYR.b) { return; } C13418fZu.c(b); } /* loaded from: classes6.dex */ static final class Sts extends AtomicReference implements InterfaceC13154fSb { private IeS a; Sts(IeS ieS) { this.a = ieS; } @Override // o.InterfaceC13154fSb public final void onSubscribe(fSJ fsj) { EnumC13192fTf.a(this, fsj); } @Override // o.InterfaceC13154fSb public final void onError(Throwable th) { IeS ieS = this.a; EnumC13192fTf.e(ieS.d); InterfaceC13174fSv interfaceC13174fSv = ieS.a; C13355fYI c13355fYI = ieS.b; if (fYR.c(c13355fYI, th)) { if (ieS.getAndIncrement() == 0) { Throwable b = fYR.b(c13355fYI); if (b == null) { interfaceC13174fSv.onComplete(); return; } else { if (b != fYR.b) { interfaceC13174fSv.onError(b); return; } return; } } return; } C13418fZu.c(th); } @Override // o.InterfaceC13154fSb public final void onComplete() { IeS ieS = this.a; ieS.e = true; if (ieS.c) { InterfaceC13174fSv interfaceC13174fSv = ieS.a; C13355fYI c13355fYI = ieS.b; if (ieS.getAndIncrement() == 0) { Throwable b = fYR.b(c13355fYI); if (b == null) { interfaceC13174fSv.onComplete(); } else if (b != fYR.b) { interfaceC13174fSv.onError(b); } } } } } @Override // o.InterfaceC13174fSv public final void onComplete() { this.c = true; if (this.e) { InterfaceC13174fSv interfaceC13174fSv = this.a; C13355fYI c13355fYI = this.b; if (getAndIncrement() == 0) { Throwable b = fYR.b(c13355fYI); if (b == null) { interfaceC13174fSv.onComplete(); } else if (b != fYR.b) { interfaceC13174fSv.onError(b); } } } } } }