package com.chartboost.sdk.impl;

import android.webkit.WebView;
import com.google.firebase.remoteconfig.RemoteConfigConstants;
import com.mbridge.msdk.MBridgeConstans;
import com.unity3d.ads.core.domain.HandleInvocationsFromAdViewer;
import java.util.Date;
import org.json.JSONArray;
import org.json.JSONObject;
/* loaded from: classes2.dex */
public abstract class t {

    /* renamed from: a  reason: collision with root package name */
    public String f1817a;
    public sc b;
    public k c;
    public d7 d;
    public a e;
    public long f;

    /* loaded from: classes2.dex */
    public enum a {
        AD_STATE_IDLE,
        AD_STATE_VISIBLE,
        AD_STATE_NOTVISIBLE
    }

    public t(String str) {
        a();
        this.f1817a = str;
        this.b = new sc(null);
    }

    public void a() {
        this.f = kd.b();
        this.e = a.AD_STATE_IDLE;
    }

    public void a(d7 d7Var) {
        this.d = d7Var;
    }

    public void a(k kVar) {
        this.c = kVar;
    }

    public void b() {
        this.b.clear();
    }

    public k c() {
        return this.c;
    }

    public d7 d() {
        return this.d;
    }

    public boolean e() {
        return this.b.get() != 0;
    }

    public void f() {
        pd.a().a(h(), this.f1817a);
    }

    public void g() {
        pd.a().b(h(), this.f1817a);
    }

    public WebView h() {
        return (WebView) this.b.get();
    }

    public void i() {
        a((JSONObject) null);
    }

    public void j() {
    }

    public void a(float f) {
        pd.a().a(h(), this.f1817a, f);
    }

    public void b(String str, long j) {
        if (j >= this.f) {
            this.e = a.AD_STATE_VISIBLE;
            pd.a().b(h(), this.f1817a, str);
        }
    }

    public void a(WebView webView) {
        this.b = new sc(webView);
    }

    public void b(boolean z) {
        if (e()) {
            pd.a().a(h(), this.f1817a, z ? "locked" : "unlocked");
        }
    }

    public void a(q qVar) {
        pd.a().a(h(), this.f1817a, qVar.c());
    }

    public void a(bc bcVar, r rVar) {
        a(bcVar, rVar, null);
    }

    public void a(bc bcVar, r rVar, JSONObject jSONObject) {
        String j = bcVar.j();
        JSONObject jSONObject2 = new JSONObject();
        xc.a(jSONObject2, "environment", MBridgeConstans.DYNAMIC_VIEW_WX_APP);
        xc.a(jSONObject2, "adSessionType", rVar.a());
        xc.a(jSONObject2, "deviceInfo", pc.d());
        xc.a(jSONObject2, "deviceCategory", gc.a().toString());
        JSONArray jSONArray = new JSONArray();
        jSONArray.put("clid");
        jSONArray.put("vlid");
        xc.a(jSONObject2, "supports", jSONArray);
        JSONObject jSONObject3 = new JSONObject();
        xc.a(jSONObject3, HandleInvocationsFromAdViewer.KEY_OM_PARTNER, rVar.f().a());
        xc.a(jSONObject3, HandleInvocationsFromAdViewer.KEY_OM_PARTNER_VERSION, rVar.f().b());
        xc.a(jSONObject2, "omidNativeInfo", jSONObject3);
        JSONObject jSONObject4 = new JSONObject();
        xc.a(jSONObject4, "libraryVersion", "1.5.0-Chartboost");
        xc.a(jSONObject4, RemoteConfigConstants.RequestFieldKey.APP_ID, od.b().a().getApplicationContext().getPackageName());
        xc.a(jSONObject2, MBridgeConstans.DYNAMIC_VIEW_WX_APP, jSONObject4);
        if (rVar.b() != null) {
            xc.a(jSONObject2, "contentUrl", rVar.b());
        }
        if (rVar.c() != null) {
            xc.a(jSONObject2, "customReferenceData", rVar.c());
        }
        JSONObject jSONObject5 = new JSONObject();
        for (hb hbVar : rVar.g()) {
            xc.a(jSONObject5, hbVar.b(), hbVar.c());
        }
        pd.a().a(h(), j, jSONObject2, jSONObject5, jSONObject);
    }

    public void a(String str) {
        a(str, (JSONObject) null);
    }

    public void a(String str, long j) {
        if (j >= this.f) {
            a aVar = this.e;
            a aVar2 = a.AD_STATE_NOTVISIBLE;
            if (aVar != aVar2) {
                this.e = aVar2;
                pd.a().b(h(), this.f1817a, str);
            }
        }
    }

    public void a(String str, JSONObject jSONObject) {
        pd.a().a(h(), this.f1817a, str, jSONObject);
    }

    public void a(Date date) {
        if (date == null) {
            return;
        }
        JSONObject jSONObject = new JSONObject();
        xc.a(jSONObject, "timestamp", Long.valueOf(date.getTime()));
        pd.a().a(h(), jSONObject);
    }

    public void a(JSONObject jSONObject) {
        pd.a().b(h(), this.f1817a, jSONObject);
    }

    public void a(boolean z) {
        if (e()) {
            pd.a().c(h(), this.f1817a, z ? "foregrounded" : "backgrounded");
        }
    }
}
