package R4;

import java.io.IOException;
import r4.AbstractC0983h;
import r4.C0992q;

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

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

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

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

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

    @Override // N4.a
    public final long a() {
        long jA;
        y[] yVarArr;
        int i = 0;
        switch (this.f2684e) {
            case 0:
                q qVar = (q) this.f2685f;
                qVar.f2713k.a(qVar, (D) ((C0992q) this.f2686g).f9768k);
                return -1L;
            case 1:
                try {
                    ((q) this.f2685f).f2713k.b((y) this.f2686g);
                    break;
                } catch (IOException e2) {
                    S4.o oVar = S4.o.f2834a;
                    S4.o oVar2 = S4.o.f2834a;
                    String strH = AbstractC0983h.h("Http2Connection.Listener failure for ", ((q) this.f2685f).f2715m);
                    oVar2.getClass();
                    S4.o.i(strH, 4, e2);
                    try {
                        ((y) this.f2686g).c(EnumC0183b.PROTOCOL_ERROR, e2);
                        break;
                    } catch (IOException unused) {
                    }
                }
                return -1L;
            default:
                l lVar = (l) this.f2685f;
                D d3 = (D) this.f2686g;
                C0992q c0992q = new C0992q();
                q qVar2 = lVar.f2691l;
                synchronized (qVar2.f2711G) {
                    synchronized (qVar2) {
                        try {
                            D d6 = qVar2.f2705A;
                            D d7 = new D();
                            d7.b(d6);
                            d7.b(d3);
                            c0992q.f9768k = d7;
                            jA = ((long) d7.a()) - ((long) d6.a());
                            if (jA == 0 || qVar2.f2714l.isEmpty()) {
                                yVarArr = null;
                            } else {
                                Object[] array = qVar2.f2714l.values().toArray(new y[0]);
                                if (array == null) {
                                    throw new NullPointerException("null cannot be cast to non-null type kotlin.Array<T of kotlin.collections.ArraysKt__ArraysJVMKt.toTypedArray>");
                                }
                                yVarArr = (y[]) array;
                            }
                            D d8 = (D) c0992q.f9768k;
                            AbstractC0983h.e("<set-?>", d8);
                            qVar2.f2705A = d8;
                            qVar2.f2720t.c(new j(AbstractC0983h.h(qVar2.f2715m, " onSettings"), qVar2, c0992q, i), 0L);
                        } catch (Throwable th) {
                            throw th;
                        }
                    }
                    try {
                        qVar2.f2711G.a((D) c0992q.f9768k);
                    } catch (IOException e6) {
                        qVar2.e(e6);
                    }
                    break;
                }
                if (yVarArr != null) {
                    int length = yVarArr.length;
                    while (i < length) {
                        y yVar = yVarArr[i];
                        i++;
                        synchronized (yVar) {
                            yVar.f2759f += jA;
                            if (jA > 0) {
                                yVar.notifyAll();
                            }
                        }
                    }
                }
                return -1L;
        }
    }
}
