package com.google.android.gms.internal.ads;

import java.util.Collection;
import java.util.ConcurrentModificationException;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.Objects;

/* JADX INFO: loaded from: classes2.dex */
public class cr1 implements Iterator {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final /* synthetic */ int f10059a = 0;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final Iterator f10060b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public Object f10061c;

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

    public cr1(dr1 dr1Var) {
        Objects.requireNonNull(dr1Var);
        this.f10062d = dr1Var;
        this.f10060b = dr1Var.f10490c.entrySet().iterator();
    }

    public final void a() {
        kr1 kr1Var = (kr1) this.f10062d;
        kr1Var.zza();
        if (kr1Var.f13383b != ((Collection) this.f10061c)) {
            throw new ConcurrentModificationException();
        }
    }

    @Override // java.util.Iterator
    public final boolean hasNext() {
        int i10 = this.f10059a;
        Iterator it = this.f10060b;
        switch (i10) {
            case 0:
                break;
            case 1:
                break;
            default:
                a();
                break;
        }
        return it.hasNext();
    }

    @Override // java.util.Iterator
    public final Object next() {
        int i10 = this.f10059a;
        Iterator it = this.f10060b;
        switch (i10) {
            case 0:
                Map.Entry entry = (Map.Entry) it.next();
                this.f10061c = (Collection) entry.getValue();
                return ((dr1) this.f10062d).d(entry);
            case 1:
                Map.Entry entry2 = (Map.Entry) it.next();
                this.f10061c = entry2;
                return entry2.getKey();
            default:
                a();
                return it.next();
        }
    }

    @Override // java.util.Iterator
    public final void remove() {
        int i10 = this.f10059a;
        Object obj = this.f10062d;
        Iterator it = this.f10060b;
        switch (i10) {
            case 0:
                ih1.f1("no calls to next() since the last call to remove()", ((Collection) this.f10061c) != null);
                it.remove();
                ((dr1) obj).f10491d.f19756e -= ((Collection) this.f10061c).size();
                ((Collection) this.f10061c).clear();
                this.f10061c = null;
                break;
            case 1:
                ih1.f1("no calls to next() since the last call to remove()", ((Map.Entry) this.f10061c) != null);
                Collection collection = (Collection) ((Map.Entry) this.f10061c).getValue();
                it.remove();
                ((er1) obj).f10905c.f19756e -= collection.size();
                collection.clear();
                this.f10061c = null;
                break;
            default:
                it.remove();
                kr1 kr1Var = (kr1) obj;
                zzgsv zzgsvVar = kr1Var.f13386e;
                zzgsvVar.f19756e--;
                kr1Var.zzb();
                break;
        }
    }

    public cr1(er1 er1Var, Iterator it) {
        this.f10060b = it;
        Objects.requireNonNull(er1Var);
        this.f10062d = er1Var;
    }

    public cr1(kr1 kr1Var) {
        Iterator it;
        Objects.requireNonNull(kr1Var);
        this.f10062d = kr1Var;
        Collection collection = kr1Var.f13383b;
        this.f10061c = collection;
        if (collection instanceof List) {
            it = ((List) collection).listIterator();
        } else {
            it = collection.iterator();
        }
        this.f10060b = it;
    }

    public cr1(kr1 kr1Var, ListIterator listIterator) {
        Objects.requireNonNull(kr1Var);
        this.f10062d = kr1Var;
        this.f10061c = kr1Var.f13383b;
        this.f10060b = listIterator;
    }
}
