package d3;

/* JADX INFO: renamed from: d3.a, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public final class RunnableC0766a implements Runnable {

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

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public final /* synthetic */ String f11881r;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public final /* synthetic */ long f11882s;

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public final /* synthetic */ C0764A f11883t;

    public /* synthetic */ RunnableC0766a(C0764A c0764a, String str, long j8, int i) {
        this.f11880q = i;
        this.f11881r = str;
        this.f11882s = j8;
        this.f11883t = c0764a;
    }

    @Override // java.lang.Runnable
    public final void run() {
        switch (this.f11880q) {
            case n4.u0.f15495q /* 0 */:
                C0764A c0764a = this.f11883t;
                c0764a.E();
                String str = this.f11881r;
                P2.w.c(str);
                q.e eVar = c0764a.f11421s;
                boolean zIsEmpty = eVar.isEmpty();
                long j8 = this.f11882s;
                if (zIsEmpty) {
                    c0764a.f11422t = j8;
                }
                Integer num = (Integer) eVar.get(str);
                if (num != null) {
                    eVar.put(str, Integer.valueOf(num.intValue() + 1));
                } else if (eVar.f16190s < 100) {
                    eVar.put(str, 1);
                    c0764a.f11420r.put(str, Long.valueOf(j8));
                } else {
                    Z z8 = ((C0817r0) c0764a.f5146q).f12150y;
                    C0817r0.k(z8);
                    z8.f11878y.b("Too many ads visible");
                }
                break;
            default:
                C0764A c0764a2 = this.f11883t;
                c0764a2.E();
                String str2 = this.f11881r;
                P2.w.c(str2);
                q.e eVar2 = c0764a2.f11421s;
                Integer num2 = (Integer) eVar2.get(str2);
                C0817r0 c0817r0 = (C0817r0) c0764a2.f5146q;
                if (num2 == null) {
                    Z z9 = c0817r0.f12150y;
                    C0817r0.k(z9);
                    z9.f11875v.c(str2, "Call to endAdUnitExposure for unknown ad unit id");
                } else {
                    C0795j1 c0795j1 = c0817r0.f12124E;
                    C0817r0.j(c0795j1);
                    C0786g1 c0786g1L = c0795j1.L(false);
                    int iIntValue = num2.intValue() - 1;
                    if (iIntValue != 0) {
                        eVar2.put(str2, Integer.valueOf(iIntValue));
                    } else {
                        eVar2.remove(str2);
                        q.e eVar3 = c0764a2.f11420r;
                        Long l8 = (Long) eVar3.get(str2);
                        long j9 = this.f11882s;
                        Z z10 = c0817r0.f12150y;
                        if (l8 == null) {
                            C0817r0.k(z10);
                            z10.f11875v.b("First ad unit exposure time was never set");
                        } else {
                            long jLongValue = j9 - l8.longValue();
                            eVar3.remove(str2);
                            c0764a2.J(str2, jLongValue, c0786g1L);
                        }
                        if (eVar2.isEmpty()) {
                            long j10 = c0764a2.f11422t;
                            if (j10 != 0) {
                                c0764a2.I(j9 - j10, c0786g1L);
                                c0764a2.f11422t = 0L;
                            } else {
                                C0817r0.k(z10);
                                z10.f11875v.b("First ad exposure time was never set");
                            }
                        }
                    }
                }
                break;
        }
    }
}
