package wp;

import java.util.List;
import rm.n0;
import tp.w0;

/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes3.dex */
public final class g0 implements d0 {

    /* renamed from: b, reason: collision with root package name */
    private final long f49591b;

    /* renamed from: c, reason: collision with root package name */
    private final long f49592c;

    /* loaded from: classes3.dex */
    static final class a extends kotlin.coroutines.jvm.internal.l implements dn.q {

        /* renamed from: p, reason: collision with root package name */
        int f49593p;

        /* renamed from: q, reason: collision with root package name */
        private /* synthetic */ Object f49594q;

        /* renamed from: r, reason: collision with root package name */
        /* synthetic */ int f49595r;

        a(vm.d dVar) {
            super(3, dVar);
        }

        public final Object b(f fVar, int i10, vm.d dVar) {
            a aVar = new a(dVar);
            aVar.f49594q = fVar;
            aVar.f49595r = i10;
            return aVar.invokeSuspend(n0.f34904a);
        }

        @Override // dn.q
        public /* bridge */ /* synthetic */ Object invoke(Object obj, Object obj2, Object obj3) {
            return b((f) obj, ((Number) obj2).intValue(), (vm.d) obj3);
        }

        /* JADX WARN: Removed duplicated region for block: B:14:0x009b A[RETURN] */
        /* JADX WARN: Removed duplicated region for block: B:20:0x008d A[RETURN] */
        /* JADX WARN: Removed duplicated region for block: B:24:0x0070  */
        @Override // kotlin.coroutines.jvm.internal.a
        /*
            Code decompiled incorrectly, please refer to instructions dump.
        */
        public final Object invokeSuspend(Object obj) {
            Object f10;
            f fVar;
            long j10;
            b0 b0Var;
            f10 = wm.d.f();
            int i10 = this.f49593p;
            if (i10 == 0) {
                rm.y.b(obj);
                fVar = (f) this.f49594q;
                if (this.f49595r > 0) {
                    b0 b0Var2 = b0.START;
                    this.f49593p = 1;
                    if (fVar.emit(b0Var2, this) == f10) {
                        return f10;
                    }
                    return n0.f34904a;
                }
                long j11 = g0.this.f49591b;
                this.f49594q = fVar;
                this.f49593p = 2;
                if (w0.a(j11, this) == f10) {
                    return f10;
                }
                if (g0.this.f49592c > 0) {
                }
                b0Var = b0.STOP_AND_RESET_REPLAY_CACHE;
                this.f49594q = null;
                this.f49593p = 5;
                if (fVar.emit(b0Var, this) == f10) {
                }
                return n0.f34904a;
            }
            if (i10 != 1) {
                if (i10 == 2) {
                    fVar = (f) this.f49594q;
                    rm.y.b(obj);
                    if (g0.this.f49592c > 0) {
                        b0 b0Var3 = b0.STOP;
                        this.f49594q = fVar;
                        this.f49593p = 3;
                        if (fVar.emit(b0Var3, this) == f10) {
                            return f10;
                        }
                        j10 = g0.this.f49592c;
                        this.f49594q = fVar;
                        this.f49593p = 4;
                        if (w0.a(j10, this) == f10) {
                        }
                    }
                    b0Var = b0.STOP_AND_RESET_REPLAY_CACHE;
                    this.f49594q = null;
                    this.f49593p = 5;
                    if (fVar.emit(b0Var, this) == f10) {
                    }
                    return n0.f34904a;
                }
                if (i10 == 3) {
                    fVar = (f) this.f49594q;
                    rm.y.b(obj);
                    j10 = g0.this.f49592c;
                    this.f49594q = fVar;
                    this.f49593p = 4;
                    if (w0.a(j10, this) == f10) {
                        return f10;
                    }
                    b0Var = b0.STOP_AND_RESET_REPLAY_CACHE;
                    this.f49594q = null;
                    this.f49593p = 5;
                    if (fVar.emit(b0Var, this) == f10) {
                    }
                    return n0.f34904a;
                }
                if (i10 == 4) {
                    fVar = (f) this.f49594q;
                    rm.y.b(obj);
                    b0Var = b0.STOP_AND_RESET_REPLAY_CACHE;
                    this.f49594q = null;
                    this.f49593p = 5;
                    if (fVar.emit(b0Var, this) == f10) {
                        return f10;
                    }
                    return n0.f34904a;
                }
                if (i10 != 5) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
            }
            rm.y.b(obj);
            return n0.f34904a;
        }
    }

    /* loaded from: classes3.dex */
    static final class b extends kotlin.coroutines.jvm.internal.l implements dn.p {

        /* renamed from: p, reason: collision with root package name */
        int f49597p;

        /* renamed from: q, reason: collision with root package name */
        /* synthetic */ Object f49598q;

        b(vm.d dVar) {
            super(2, dVar);
        }

        @Override // dn.p
        /* renamed from: b, reason: merged with bridge method [inline-methods] */
        public final Object invoke(b0 b0Var, vm.d dVar) {
            return ((b) create(b0Var, dVar)).invokeSuspend(n0.f34904a);
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final vm.d create(Object obj, vm.d dVar) {
            b bVar = new b(dVar);
            bVar.f49598q = obj;
            return bVar;
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            wm.d.f();
            if (this.f49597p != 0) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            rm.y.b(obj);
            return kotlin.coroutines.jvm.internal.b.a(((b0) this.f49598q) != b0.START);
        }
    }

    public g0(long j10, long j11) {
        this.f49591b = j10;
        this.f49592c = j11;
        if (!(j10 >= 0)) {
            throw new IllegalArgumentException(("stopTimeout(" + j10 + " ms) cannot be negative").toString());
        }
        if (j11 >= 0) {
            return;
        }
        throw new IllegalArgumentException(("replayExpiration(" + j11 + " ms) cannot be negative").toString());
    }

    @Override // wp.d0
    public e a(h0 h0Var) {
        return g.j(g.k(g.u(h0Var, new a(null)), new b(null)));
    }

    public boolean equals(Object obj) {
        if (obj instanceof g0) {
            g0 g0Var = (g0) obj;
            if (this.f49591b == g0Var.f49591b && this.f49592c == g0Var.f49592c) {
                return true;
            }
        }
        return false;
    }

    public int hashCode() {
        return (Long.hashCode(this.f49591b) * 31) + Long.hashCode(this.f49592c);
    }

    public String toString() {
        List d10;
        List a10;
        String m02;
        d10 = sm.t.d(2);
        if (this.f49591b > 0) {
            d10.add("stopTimeout=" + this.f49591b + "ms");
        }
        if (this.f49592c < Long.MAX_VALUE) {
            d10.add("replayExpiration=" + this.f49592c + "ms");
        }
        a10 = sm.t.a(d10);
        StringBuilder sb2 = new StringBuilder();
        sb2.append("SharingStarted.WhileSubscribed(");
        m02 = sm.c0.m0(a10, null, null, null, 0, null, null, 63, null);
        sb2.append(m02);
        sb2.append(')');
        return sb2.toString();
    }
}
