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

import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.View;
import java.util.HashMap;
import java.util.concurrent.Callable;
import org.json.JSONObject;

/* JADX INFO: loaded from: classes2.dex */
public final /* synthetic */ class bo0 implements Callable {

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

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

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

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

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final /* synthetic */ Object f9614e;

    public /* synthetic */ bo0(wn1 wn1Var, Context context, View view, Activity activity, int i10) {
        this.f9610a = i10;
        this.f9611b = wn1Var;
        this.f9612c = context;
        this.f9613d = view;
        this.f9614e = activity;
    }

    @Override // java.util.concurrent.Callable
    public final Object call() throws zzenv {
        Bundle bundle;
        switch (this.f9610a) {
            case 0:
                do0 do0Var = (do0) this.f9611b;
                eb1 eb1Var = (eb1) this.f9612c;
                wa1 wa1Var = (wa1) this.f9613d;
                JSONObject jSONObject = (JSONObject) this.f9614e;
                do0Var.getClass();
                if (((Boolean) n7.y.f31093e.f31096c.b(ao.I2)).booleanValue()) {
                    com.bytedance.sdk.component.adexpress.dynamic.dynamicview.b.n(m7.n.C.f30472k, do0Var.f10458d.f19368e, zzdxh.NATIVE_ASSETS_LOADING_BASIC_START.a());
                }
                pm0 pm0Var = new pm0();
                int iOptInt = jSONObject.optInt("template_id", -1);
                synchronized (pm0Var) {
                    pm0Var.f15459a = iOptInt;
                }
                pm0Var.k(jSONObject.optString("custom_template_id"));
                JSONObject jSONObjectOptJSONObject = jSONObject.optJSONObject("omid_settings");
                pm0Var.zzv(jSONObjectOptJSONObject != null ? jSONObjectOptJSONObject.optString("omid_partner_name") : null);
                ib1 ib1Var = (ib1) eb1Var.f10745a.f10402b;
                if (!ib1Var.f12456e.contains(Integer.toString(pm0Var.r()))) {
                    int iR = pm0Var.r();
                    throw new zzenv(1, defpackage.e.n(new StringBuilder(String.valueOf(iR).length() + 21), "Invalid template ID: ", iR));
                }
                if (pm0Var.r() == 3) {
                    if (pm0Var.zzS() == null) {
                        throw new zzenv(1, "No custom template id for custom template ad response.");
                    }
                    if (!ib1Var.f12457f.contains(pm0Var.zzS())) {
                        throw new zzenv(1, "Unexpected custom template id in the response.");
                    }
                }
                double dOptDouble = jSONObject.optDouble("rating", -1.0d);
                synchronized (pm0Var) {
                    pm0Var.f15461c = dOptDouble;
                }
                String strOptString = jSONObject.optString("headline", null);
                if (wa1Var.J) {
                    m7.n nVar = m7.n.C;
                    p7.r0 r0Var = nVar.f30464c;
                    Resources resourcesZzf = nVar.f30469h.zzf();
                    String string = resourcesZzf != null ? resourcesZzf.getString(k7.d.f29079s7) : "Test Ad";
                    strOptString = defpackage.e.p(new StringBuilder(String.valueOf(string).length() + 3 + String.valueOf(strOptString).length()), string, " : ", strOptString);
                }
                pm0Var.zzs("headline", strOptString);
                pm0Var.zzs("body", jSONObject.optString("body", null));
                pm0Var.zzs("call_to_action", jSONObject.optString("call_to_action", null));
                pm0Var.zzs("store", jSONObject.optString("store", null));
                pm0Var.zzs("price", jSONObject.optString("price", null));
                pm0Var.zzs("advertiser", jSONObject.optString("advertiser", null));
                return pm0Var;
            case 1:
                if (((Boolean) n7.y.f31093e.f31096c.b(ao.B2)).booleanValue() && (bundle = ((tz) this.f9611b).f17040j) != null) {
                    com.bytedance.sdk.component.adexpress.dynamic.dynamicview.b.n(m7.n.C.f30472k, bundle, zzdxh.HTTP_RESPONSE_READY.a());
                }
                return new cv0((gv0) ((com.google.common.util.concurrent.w) this.f9612c).get(), (JSONObject) ((com.google.common.util.concurrent.w) this.f9613d).get(), (uz) ((com.google.common.util.concurrent.w) this.f9614e).get());
            case 2:
                View view = (View) this.f9613d;
                Activity activity = (Activity) this.f9614e;
                ao1 ao1Var = (ao1) this.f9611b;
                Context context = (Context) this.f9612c;
                eh1 eh1VarZzb = ao1Var.f9204a.zzb();
                jp1 jp1Var = ao1Var.f9207d;
                if (eh1VarZzb == null) {
                    jp1Var.b(15004);
                    return "";
                }
                String strZzb = ((ai1) eh1VarZzb).zzb(context, null, view, activity);
                if (strZzb != null) {
                    return strZzb;
                }
                jp1Var.b(15007);
                return "";
            case 3:
                ao1 ao1Var2 = (ao1) this.f9611b;
                Context context2 = (Context) this.f9612c;
                String str = (String) this.f9613d;
                View view2 = (View) this.f9614e;
                eh1 eh1VarZzb2 = ao1Var2.f9204a.zzb();
                jp1 jp1Var2 = ao1Var2.f9207d;
                if (eh1VarZzb2 == null) {
                    jp1Var2.b(15004);
                    return "";
                }
                String strZzc = ((ai1) eh1VarZzb2).zzc(context2, null, str, view2, null);
                if (strZzc != null) {
                    return strZzc;
                }
                jp1Var2.b(15008);
                return "";
            case 4:
                View view3 = (View) this.f9613d;
                Activity activity2 = (Activity) this.f9614e;
                do1 do1Var = (do1) this.f9611b;
                Context context3 = (Context) this.f9612c;
                do1Var.getClass();
                HashMap map = new HashMap();
                do1Var.f10463e.f(20106, new v40(do1Var, map, context3, view3, activity2, null, 3));
                String strE = do1Var.e(map);
                map.clear();
                return strE;
            case 5:
                do1 do1Var2 = (do1) this.f9611b;
                Context context4 = (Context) this.f9612c;
                String str2 = (String) this.f9613d;
                View view4 = (View) this.f9614e;
                do1Var2.getClass();
                HashMap map2 = new HashMap();
                do1Var2.f10463e.f(20106, new v40(do1Var2, map2, context4, view4, null, str2, 4));
                String strE2 = do1Var2.e(map2);
                map2.clear();
                return strE2;
            default:
                ((so1) this.f9611b).f16515a.a((ql1) this.f9612c, (byte[]) this.f9613d, (byte[]) this.f9614e);
                return null;
        }
    }

    public /* synthetic */ bo0(wn1 wn1Var, Context context, String str, View view, int i10) {
        this.f9610a = i10;
        this.f9611b = wn1Var;
        this.f9612c = context;
        this.f9613d = str;
        this.f9614e = view;
    }

    public /* synthetic */ bo0(Object obj, Object obj2, Object obj3, Object obj4, int i10) {
        this.f9610a = i10;
        this.f9611b = obj;
        this.f9612c = obj2;
        this.f9613d = obj3;
        this.f9614e = obj4;
    }
}
