package com.flurry.android;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: /storage/emulated/0/Documents/jadec/sources/com.UBI.A90.WW/dex-files/0.dex */
public final class w {
    private Map<String, List<AdUnit>> a = new HashMap();
    private Map<String, AdUnit> b = new HashMap();

    /* JADX INFO: Access modifiers changed from: package-private */
    public final synchronized void a(AdResponse adResponse) {
        this.a.clear();
        for (AdUnit adUnit : adResponse.a()) {
            String obj = adUnit.a().toString();
            List<AdUnit> list = this.a.get(obj);
            if (list == null) {
                list = new ArrayList<>();
            }
            list.add(adUnit);
            this.a.put(obj, list);
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public final synchronized AdUnit a(String str) {
        AdUnit adUnit;
        List<AdUnit> list = this.a.get(str);
        if (list != null) {
            Iterator<AdUnit> it = list.iterator();
            while (it.hasNext()) {
                adUnit = it.next();
                if (y.a(adUnit.b().longValue()) && adUnit.c().size() > 0) {
                    it.remove();
                    this.b.put(adUnit.c().get(0).f().toString(), adUnit);
                    break;
                }
            }
        }
        adUnit = null;
        return adUnit;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public final synchronized List<AdUnit> a(String str, int i) {
        ArrayList arrayList;
        arrayList = new ArrayList();
        List<AdUnit> list = this.a.get(str);
        if (list != null) {
            Iterator<AdUnit> it = list.iterator();
            while (it.hasNext() && arrayList.size() <= i) {
                AdUnit next = it.next();
                if (y.a(next.b().longValue()) && next.d().intValue() == 1 && next.c().size() > 0) {
                    arrayList.add(next);
                    this.b.put(next.c().get(0).f().toString(), next);
                    it.remove();
                }
            }
        }
        return arrayList;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public final synchronized boolean b(String str) {
        boolean z;
        List<AdUnit> list = this.a.get(str);
        if (list != null && !list.isEmpty()) {
            for (AdUnit adUnit : list) {
                if (y.a(adUnit.b().longValue())) {
                    z = true;
                    break;
                }
            }
        }
        z = false;
        return z;
    }
}
