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

import android.os.Bundle;
import android.text.TextUtils;
import java.util.ArrayList;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;

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

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

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

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public String f14089e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public db1 f14090f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public n7.l2 f14091g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public ScheduledFuture f14092h;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final ArrayList f14085a = new ArrayList();

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public int f14093i = 2;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public zzfot f14088d = zzfot.SCAR_REQUEST_TYPE_UNSPECIFIED;

    public md1(nd1 nd1Var) {
        this.f14086b = nd1Var;
    }

    public final synchronized void a(id1 id1Var) {
        try {
            if (((Boolean) ip.f12589c.j()).booleanValue()) {
                ArrayList arrayList = this.f14085a;
                id1Var.zzc();
                arrayList.add(id1Var);
                ScheduledFuture scheduledFuture = this.f14092h;
                if (scheduledFuture != null) {
                    scheduledFuture.cancel(false);
                }
                this.f14092h = b30.f9362d.schedule(this, ((Integer) n7.y.f31093e.f31096c.b(ao.S9)).intValue(), TimeUnit.MILLISECONDS);
            }
        } catch (Throwable th) {
            throw th;
        }
    }

    public final synchronized void b(ArrayList arrayList) {
        try {
            if (((Boolean) ip.f12589c.j()).booleanValue()) {
                if (arrayList.contains("banner") || arrayList.contains("BANNER")) {
                    this.f14093i = 3;
                } else if (arrayList.contains("interstitial") || arrayList.contains("INTERSTITIAL")) {
                    this.f14093i = 4;
                } else if (arrayList.contains("native") || arrayList.contains("NATIVE")) {
                    this.f14093i = 8;
                } else if (arrayList.contains("rewarded") || arrayList.contains("REWARDED")) {
                    this.f14093i = 5;
                } else if (arrayList.contains("app_open_ad")) {
                    this.f14093i = 7;
                } else if (arrayList.contains("rewarded_interstitial") || arrayList.contains("REWARDED_INTERSTITIAL")) {
                    this.f14093i = 6;
                }
            }
        } catch (Throwable th) {
            throw th;
        }
    }

    public final synchronized void c(String str) {
        if (((Boolean) ip.f12589c.j()).booleanValue() && !TextUtils.isEmpty(str)) {
            if (Pattern.matches((String) n7.y.f31093e.f31096c.b(ao.T9), str)) {
                this.f14087c = str;
            }
        }
    }

    public final synchronized void d(Bundle bundle) {
        if (((Boolean) ip.f12589c.j()).booleanValue()) {
            this.f14088d = com.google.android.gms.ads.nonagon.signalgeneration.b.a(bundle);
        }
    }

    public final synchronized void e(db1 db1Var) {
        if (((Boolean) ip.f12589c.j()).booleanValue()) {
            this.f14090f = db1Var;
        }
    }

    public final synchronized void f(n7.l2 l2Var) {
        if (((Boolean) ip.f12589c.j()).booleanValue()) {
            this.f14091g = l2Var;
        }
    }

    public final synchronized void g(String str) {
        if (((Boolean) ip.f12589c.j()).booleanValue()) {
            this.f14089e = str;
        }
    }

    public final synchronized void h() {
        try {
            if (((Boolean) ip.f12589c.j()).booleanValue()) {
                ScheduledFuture scheduledFuture = this.f14092h;
                if (scheduledFuture != null) {
                    scheduledFuture.cancel(false);
                }
                ArrayList<id1> arrayList = this.f14085a;
                for (id1 id1Var : arrayList) {
                    int i10 = this.f14093i;
                    if (i10 != 2) {
                        id1Var.h(i10);
                    }
                    if (!TextUtils.isEmpty(this.f14087c)) {
                        id1Var.zze(this.f14087c);
                    }
                    if (!TextUtils.isEmpty(this.f14089e) && !id1Var.zzl()) {
                        id1Var.zzi(this.f14089e);
                    }
                    db1 db1Var = this.f14090f;
                    if (db1Var != null) {
                        id1Var.e(db1Var);
                    } else {
                        n7.l2 l2Var = this.f14091g;
                        if (l2Var != null) {
                            id1Var.g(l2Var);
                        }
                    }
                    id1Var.c(this.f14088d);
                    this.f14086b.zzb(id1Var.zzm());
                }
                arrayList.clear();
            }
        } catch (Throwable th) {
            throw th;
        }
    }

    public final synchronized void i(int i10) {
        if (((Boolean) ip.f12589c.j()).booleanValue()) {
            this.f14093i = i10;
        }
    }

    @Override // java.lang.Runnable
    public final synchronized void run() {
        h();
    }
}
