package com.google.android.gms.ads.nonagon.signalgeneration;

import android.content.Context;
import android.os.Bundle;
import android.util.Pair;
import com.google.android.gms.ads.AdFormat;
import com.google.android.gms.internal.ads.a30;
import com.google.android.gms.internal.ads.ao;
import com.google.android.gms.internal.ads.b30;
import com.google.android.gms.internal.ads.gr0;
import com.google.android.gms.internal.ads.tp;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;

/* JADX INFO: loaded from: classes2.dex */
public final class n0 {

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

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final HashMap f8067b = new HashMap();

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final Context f8068c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final gr0 f8069d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final ExecutorService f8070e;

    public n0(Context context, gr0 gr0Var, a30 a30Var) {
        this.f8068c = context;
        this.f8069d = gr0Var;
        this.f8070e = a30Var;
    }

    public final synchronized void a(Object obj, f0 f0Var) {
        m7.n.C.f30472k.getClass();
        b30.f9364f.execute(new n0.a(this, obj, new Pair(f0Var, Long.valueOf(System.currentTimeMillis())), 7, 0));
    }

    /* JADX WARN: Removed duplicated region for block: B:15:0x0030 A[Catch: all -> 0x002e, TryCatch #0 {all -> 0x002e, blocks: (B:3:0x0001, B:5:0x000f, B:8:0x0021, B:10:0x0027, B:16:0x0033, B:18:0x0039, B:20:0x004a, B:24:0x0058, B:27:0x0077, B:28:0x007b, B:30:0x0081, B:19:0x0042, B:15:0x0030), top: B:36:0x0001 }] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final synchronized void b(boolean z10, p0 p0Var) {
        try {
            HashMap map = this.f8066a;
            Boolean boolValueOf = Boolean.valueOf(z10);
            p0 p0Var2 = (p0) map.get(boolValueOf);
            if (p0Var2 != null) {
                m7.n.C.f30472k.getClass();
                if (p0Var2.f8105b <= System.currentTimeMillis() || p0Var2.zza() == null || p0Var.zza() != null) {
                    map.put(boolValueOf, p0Var);
                }
            }
            b30.f9362d.schedule(new m0(this, z10, p0Var.zza() == null, 0), (p0Var.zza() != null ? (Long) tp.f16979f.j() : (Long) tp.f16980g.j()).longValue(), TimeUnit.SECONDS);
            HashMap map2 = this.f8067b;
            List list = (List) map2.get(boolValueOf);
            map2.put(boolValueOf, new ArrayList());
            if (list != null) {
                Iterator it = list.iterator();
                while (it.hasNext()) {
                    e(p0Var, (Pair) it.next(), false);
                }
            }
        } catch (Throwable th) {
            throw th;
        }
    }

    public final void c(boolean z10) {
        HashMap map = this.f8067b;
        Boolean boolValueOf = Boolean.valueOf(z10);
        if (map.containsKey(boolValueOf)) {
            return;
        }
        map.put(boolValueOf, new ArrayList());
        this.f8070e.submit(new n5.q(2, this, z10));
    }

    public final synchronized void d(boolean z10, boolean z11) {
        Bundle bundle = new Bundle();
        bundle.putString("query_info_type", "requester_type_6");
        bundle.putBoolean("accept_3p_cookie", z10);
        HashMap map = this.f8066a;
        Boolean boolValueOf = Boolean.valueOf(z10);
        p0 p0Var = (p0) map.get(boolValueOf);
        int i10 = 0;
        if (z11 && p0Var != null) {
            i10 = p0Var.f8106c + 1;
        }
        p0 p0Var2 = (p0) map.get(boolValueOf);
        o0 o0Var = new o0(this, z10, i10, p0Var2 == null ? null : Boolean.valueOf(p0Var2.f8107d.get()), this.f8069d);
        g7.e eVar = (g7.e) new g7.e().d(bundle);
        eVar.getClass();
        g7.f fVar = new g7.f(eVar);
        if (((Boolean) n7.y.f31093e.f31096c.b(ao.f9006oc)).booleanValue()) {
            this.f8070e.submit(new h(this, fVar, o0Var, 2));
        } else {
            w7.a.generate(this.f8068c, AdFormat.BANNER, fVar, o0Var);
        }
    }

    public final void e(p0 p0Var, Pair pair, boolean z10) {
        p0Var.f8107d.set(true);
        w7.a aVarZza = p0Var.zza();
        if (aVarZza != null) {
            ((w7.b) pair.first).b(aVarZza);
        } else {
            ((w7.b) pair.first).a(p0Var.f8104a);
        }
        Pair[] pairArr = new Pair[7];
        pairArr[0] = new Pair("se", "query_g");
        pairArr[1] = new Pair("ad_format", "BANNER");
        pairArr[2] = new Pair("rtype", Integer.toString(6));
        pairArr[3] = new Pair("scar", "true");
        m7.n.C.f30472k.getClass();
        pairArr[4] = new Pair("lat_ms", Long.toString(System.currentTimeMillis() - ((Long) pair.second).longValue()));
        pairArr[5] = new Pair("sgpc_h", Boolean.toString(z10));
        pairArr[6] = new Pair("sgpc_rs", Boolean.toString(p0Var.zza() != null));
        b.zze(this.f8069d, null, "sgpcr", pairArr);
    }
}
