package o; import java.util.Objects; import java.util.concurrent.atomic.AtomicReference; /* renamed from: o.fUR, reason: case insensitive filesystem */ /* loaded from: classes6.dex */ public final class C13218fUR extends fRY { private fSS b; private AbstractC13163fSk c; private boolean d; public C13218fUR(AbstractC13163fSk abstractC13163fSk, fSS fss, boolean z) { this.c = abstractC13163fSk; this.b = fss; this.d = z; } @Override // o.fRY public final void c(InterfaceC13154fSb interfaceC13154fSb) { if (fUP.d(this.c, this.b, interfaceC13154fSb)) { return; } this.c.subscribe(new HBt(interfaceC13154fSb, this.b, this.d)); } /* renamed from: o.fUR$HBt */ /* loaded from: classes6.dex */ static final class HBt implements InterfaceC13174fSv, fSJ { private static C0112HBt j = new C0112HBt(null); final InterfaceC13154fSb a; volatile boolean c; final boolean e; fSJ g; private fSS i; final C13355fYI b = new C13355fYI(); final AtomicReference d = new AtomicReference<>(); HBt(InterfaceC13154fSb interfaceC13154fSb, fSS fss, boolean z) { this.a = interfaceC13154fSb; this.i = fss; this.e = z; } @Override // o.InterfaceC13174fSv public final void onSubscribe(fSJ fsj) { if (EnumC13192fTf.d(this.g, fsj)) { this.g = fsj; this.a.onSubscribe(this); } } @Override // o.InterfaceC13174fSv public final void onNext(T t) { try { fRZ frz = (fRZ) Objects.requireNonNull(this.i.a(t), "The mapper returned a null CompletableSource"); C0112HBt c0112HBt = new C0112HBt(this); while (true) { C0112HBt c0112HBt2 = this.d.get(); if (c0112HBt2 != j) { AtomicReference atomicReference = this.d; while (!atomicReference.compareAndSet(c0112HBt2, c0112HBt)) { if (atomicReference.get() != c0112HBt2) { break; } } if (c0112HBt2 != null) { EnumC13192fTf.e(c0112HBt2); } frz.e(c0112HBt); return; } return; } } catch (Throwable th) { C13147fSI.c(th); this.g.dispose(); onError(th); } } @Override // o.InterfaceC13174fSv public final void onComplete() { this.c = true; if (this.d.get() == null) { C13355fYI c13355fYI = this.b; InterfaceC13154fSb interfaceC13154fSb = this.a; Throwable b = fYR.b(c13355fYI); if (b == null) { interfaceC13154fSb.onComplete(); } else if (b != fYR.b) { interfaceC13154fSb.onError(b); } } } final void c() { AtomicReference atomicReference = this.d; C0112HBt c0112HBt = j; C0112HBt andSet = atomicReference.getAndSet(c0112HBt); if (andSet == null || andSet == c0112HBt) { return; } EnumC13192fTf.e(andSet); } @Override // o.fSJ public final void dispose() { this.g.dispose(); AtomicReference atomicReference = this.d; C0112HBt c0112HBt = j; C0112HBt andSet = atomicReference.getAndSet(c0112HBt); if (andSet != null && andSet != c0112HBt) { EnumC13192fTf.e(andSet); } Throwable b = fYR.b(this.b); if (b == null || b == fYR.b) { return; } C13418fZu.c(b); } @Override // o.fSJ public final boolean isDisposed() { return this.d.get() == j; } /* JADX INFO: Access modifiers changed from: package-private */ /* renamed from: o.fUR$HBt$HBt, reason: collision with other inner class name */ /* loaded from: classes6.dex */ public static final class C0112HBt extends AtomicReference implements InterfaceC13154fSb { private HBt a; C0112HBt(HBt hBt) { this.a = hBt; } @Override // o.InterfaceC13154fSb public final void onSubscribe(fSJ fsj) { EnumC13192fTf.a(this, fsj); } @Override // o.InterfaceC13154fSb public final void onError(Throwable th) { HBt hBt = this.a; AtomicReference atomicReference = hBt.d; while (!atomicReference.compareAndSet(this, null)) { if (atomicReference.get() != this) { C13418fZu.c(th); return; } } if (fYR.c(hBt.b, th)) { if (hBt.e) { if (hBt.c) { C13355fYI c13355fYI = hBt.b; InterfaceC13154fSb interfaceC13154fSb = hBt.a; Throwable b = fYR.b(c13355fYI); if (b == null) { interfaceC13154fSb.onComplete(); return; } else { if (b != fYR.b) { interfaceC13154fSb.onError(b); return; } return; } } return; } hBt.g.dispose(); hBt.c(); C13355fYI c13355fYI2 = hBt.b; InterfaceC13154fSb interfaceC13154fSb2 = hBt.a; Throwable b2 = fYR.b(c13355fYI2); if (b2 == null) { interfaceC13154fSb2.onComplete(); return; } else { if (b2 != fYR.b) { interfaceC13154fSb2.onError(b2); return; } return; } } C13418fZu.c(th); } @Override // o.InterfaceC13154fSb public final void onComplete() { HBt hBt = this.a; AtomicReference atomicReference = hBt.d; while (!atomicReference.compareAndSet(this, null)) { if (atomicReference.get() != this) { return; } } if (hBt.c) { C13355fYI c13355fYI = hBt.b; InterfaceC13154fSb interfaceC13154fSb = hBt.a; Throwable b = fYR.b(c13355fYI); if (b == null) { interfaceC13154fSb.onComplete(); } else if (b != fYR.b) { interfaceC13154fSb.onError(b); } } } } @Override // o.InterfaceC13174fSv public final void onError(Throwable th) { if (fYR.c(this.b, th)) { if (this.e) { onComplete(); return; } c(); C13355fYI c13355fYI = this.b; InterfaceC13154fSb interfaceC13154fSb = this.a; Throwable b = fYR.b(c13355fYI); if (b == null) { interfaceC13154fSb.onComplete(); return; } else { if (b != fYR.b) { interfaceC13154fSb.onError(b); return; } return; } } C13418fZu.c(th); } } }