package n7;

import P6.g;
import R0.m;
import java.io.IOException;
import java.net.Socket;
import java.util.concurrent.ConcurrentLinkedQueue;
import n4.u0;
import o7.l;
import r7.k;
import r7.o;

/* JADX INFO: loaded from: classes.dex */
public final class b extends a {

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final /* synthetic */ int f15534e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final /* synthetic */ Object f15535f;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public /* synthetic */ b(String str, Object obj, int i) {
        super(str, true);
        this.f15534e = i;
        this.f15535f = obj;
    }

    @Override // n7.a
    public final long a() {
        switch (this.f15534e) {
            case u0.f15495q /* 0 */:
                ((k) this.f15535f).a();
                return -1L;
            case 1:
                m mVar = (m) this.f15535f;
                long jNanoTime = System.nanoTime();
                int i = 0;
                long j8 = Long.MIN_VALUE;
                l lVar = null;
                int i5 = 0;
                for (l lVar2 : (ConcurrentLinkedQueue) mVar.f5955e) {
                    g.d(lVar2, "connection");
                    synchronized (lVar2) {
                        if (mVar.d(lVar2, jNanoTime) > 0) {
                            i5++;
                        } else {
                            i++;
                            long j9 = jNanoTime - lVar2.f15997q;
                            if (j9 > j8) {
                                lVar = lVar2;
                                j8 = j9;
                            }
                        }
                    }
                }
                long j10 = mVar.f5952b;
                if (j8 < j10 && i <= 5) {
                    if (i > 0) {
                        return j10 - j8;
                    }
                    if (i5 > 0) {
                        return j10;
                    }
                    return -1L;
                }
                g.b(lVar);
                synchronized (lVar) {
                    if (!lVar.f15996p.isEmpty()) {
                        return 0L;
                    }
                    if (lVar.f15997q + j8 != jNanoTime) {
                        return 0L;
                    }
                    lVar.f15990j = true;
                    ((ConcurrentLinkedQueue) mVar.f5955e).remove(lVar);
                    Socket socket = lVar.f15985d;
                    g.b(socket);
                    l7.b.e(socket);
                    if (!((ConcurrentLinkedQueue) mVar.f5955e).isEmpty()) {
                        return 0L;
                    }
                    ((c) mVar.f5953c).a();
                    return 0L;
                }
            default:
                o oVar = (o) this.f15535f;
                oVar.getClass();
                try {
                    oVar.f16643M.n(2, 0, false);
                    return -1L;
                } catch (IOException e8) {
                    oVar.a(2, 2, e8);
                    return -1L;
                }
        }
    }

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public b(m mVar, String str) {
        super(str, true);
        this.f15534e = 1;
        this.f15535f = mVar;
    }
}
