package N2;

import java.util.ArrayDeque;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executor;

/* JADX INFO: loaded from: classes.dex */
public final class m implements W2.d, W2.c {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final HashMap f2215a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public ArrayDeque f2216b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final O2.l f2217c;

    public m() {
        O2.l lVar = O2.l.f2311k;
        this.f2215a = new HashMap();
        this.f2216b = new ArrayDeque();
        this.f2217c = lVar;
    }

    @Override // W2.c
    public final void a(W2.a aVar) {
        Set<Map.Entry> setEntrySet;
        aVar.getClass();
        synchronized (this) {
            try {
                ArrayDeque arrayDeque = this.f2216b;
                if (arrayDeque != null) {
                    arrayDeque.add(aVar);
                    return;
                }
                synchronized (this) {
                    try {
                        Map map = (Map) this.f2215a.get(I2.b.class);
                        setEntrySet = map == null ? Collections.EMPTY_SET : map.entrySet();
                    } finally {
                    }
                }
                for (Map.Entry entry : setEntrySet) {
                    ((Executor) entry.getValue()).execute(new F.j(3, entry, aVar));
                }
            } finally {
            }
        }
    }

    public final synchronized void b(Executor executor, W2.b bVar) {
        try {
            executor.getClass();
            if (!this.f2215a.containsKey(I2.b.class)) {
                this.f2215a.put(I2.b.class, new ConcurrentHashMap());
            }
            ((ConcurrentHashMap) this.f2215a.get(I2.b.class)).put(bVar, executor);
        } catch (Throwable th) {
            throw th;
        }
    }

    public final synchronized void c(com.google.firebase.messaging.q qVar) {
        qVar.getClass();
        if (this.f2215a.containsKey(I2.b.class)) {
            ConcurrentHashMap concurrentHashMap = (ConcurrentHashMap) this.f2215a.get(I2.b.class);
            concurrentHashMap.remove(qVar);
            if (concurrentHashMap.isEmpty()) {
                this.f2215a.remove(I2.b.class);
            }
        }
    }
}
