package o;

import com.google.android.gms.common.api.Api;
import java.util.Arrays;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.j0, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public abstract class AbstractC1536j0 {
    public AbstractC1631k0[] l;
    public int m;
    public int n;

    /* renamed from: o, reason: collision with root package name */
    public C2344rb0 f591o;

    public final AbstractC1631k0 d() {
        AbstractC1631k0 abstractC1631k0E;
        C2344rb0 c2344rb0;
        synchronized (this) {
            try {
                AbstractC1631k0[] abstractC1631k0ArrF = this.l;
                if (abstractC1631k0ArrF == null) {
                    abstractC1631k0ArrF = f();
                    this.l = abstractC1631k0ArrF;
                } else if (this.m >= abstractC1631k0ArrF.length) {
                    Object[] objArrCopyOf = Arrays.copyOf(abstractC1631k0ArrF, abstractC1631k0ArrF.length * 2);
                    this.l = (AbstractC1631k0[]) objArrCopyOf;
                    abstractC1631k0ArrF = (AbstractC1631k0[]) objArrCopyOf;
                }
                int i = this.n;
                do {
                    abstractC1631k0E = abstractC1631k0ArrF[i];
                    if (abstractC1631k0E == null) {
                        abstractC1631k0E = e();
                        abstractC1631k0ArrF[i] = abstractC1631k0E;
                    }
                    i++;
                    if (i >= abstractC1631k0ArrF.length) {
                        i = 0;
                    }
                } while (!abstractC1631k0E.a(this));
                this.n = i;
                this.m++;
                c2344rb0 = this.f591o;
            } catch (Throwable th) {
                throw th;
            }
        }
        if (c2344rb0 != null) {
            c2344rb0.w(1);
        }
        return abstractC1631k0E;
    }

    public abstract AbstractC1631k0 e();

    public abstract AbstractC1631k0[] f();

    public final void g(AbstractC1631k0 abstractC1631k0) {
        C2344rb0 c2344rb0;
        int i;
        InterfaceC0220Im[] interfaceC0220ImArrB;
        synchronized (this) {
            try {
                int i2 = this.m - 1;
                this.m = i2;
                c2344rb0 = this.f591o;
                if (i2 == 0) {
                    this.n = 0;
                }
                interfaceC0220ImArrB = abstractC1631k0.b(this);
            } catch (Throwable th) {
                throw th;
            }
        }
        for (InterfaceC0220Im interfaceC0220Im : interfaceC0220ImArrB) {
            if (interfaceC0220Im != null) {
                interfaceC0220Im.resumeWith(Oh0.a);
            }
        }
        if (c2344rb0 != null) {
            c2344rb0.w(-1);
        }
    }

    public final C2344rb0 h() {
        C2344rb0 c2344rb0;
        synchronized (this) {
            c2344rb0 = this.f591o;
            if (c2344rb0 == null) {
                int i = this.m;
                c2344rb0 = new C2344rb0(1, Api.BaseClientBuilder.API_PRIORITY_OTHER, 2);
                c2344rb0.q(Integer.valueOf(i));
                this.f591o = c2344rb0;
            }
        }
        return c2344rb0;
    }
}
