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

/* JADX INFO: loaded from: classes2.dex */
public final class c implements Runnable {

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

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

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

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

    public /* synthetic */ c(s sVar, String str, long j10, int i10) {
        this.f21492a = i10;
        this.f21493b = str;
        this.f21494c = j10;
        this.f21495d = sVar;
    }

    @Override // java.lang.Runnable
    public final void run() {
        int i10 = this.f21492a;
        long j10 = this.f21494c;
        String str = this.f21493b;
        s sVar = this.f21495d;
        switch (i10) {
            case 0:
                sVar.w();
                com.google.android.gms.common.internal.w.checkNotEmpty(str);
                androidx.collection.f fVar = sVar.f21895c;
                if (fVar.isEmpty()) {
                    sVar.f21896d = j10;
                }
                Integer num = (Integer) fVar.get(str);
                if (num != null) {
                    fVar.put(str, Integer.valueOf(num.intValue() + 1));
                } else if (fVar.f968c < 100) {
                    fVar.put(str, 1);
                    sVar.f21894b.put(str, Long.valueOf(j10));
                } else {
                    sVar.zzj().f21837i.c("Too many ads visible");
                }
                break;
            default:
                sVar.w();
                com.google.android.gms.common.internal.w.checkNotEmpty(str);
                androidx.collection.f fVar2 = sVar.f21895c;
                Integer num2 = (Integer) fVar2.get(str);
                if (num2 == null) {
                    sVar.zzj().f21834f.b(str, "Call to endAdUnitExposure for unknown ad unit id");
                } else {
                    x2 x2VarG = sVar.A().G(false);
                    int iIntValue = num2.intValue() - 1;
                    if (iIntValue != 0) {
                        fVar2.put(str, Integer.valueOf(iIntValue));
                    } else {
                        fVar2.remove(str);
                        androidx.collection.f fVar3 = sVar.f21894b;
                        Long l10 = (Long) fVar3.get(str);
                        if (l10 == null) {
                            sVar.zzj().f21834f.c("First ad unit exposure time was never set");
                        } else {
                            long jLongValue = j10 - l10.longValue();
                            fVar3.remove(str);
                            sVar.G(str, jLongValue, x2VarG);
                        }
                        if (fVar2.isEmpty()) {
                            long j11 = sVar.f21896d;
                            if (j11 != 0) {
                                sVar.E(j10 - j11, x2VarG);
                                sVar.f21896d = 0L;
                            } else {
                                sVar.zzj().f21834f.c("First ad exposure time was never set");
                            }
                        }
                    }
                }
                break;
        }
    }
}
