package com.bytedance.sdk.openadsdk.core.YoT;

import android.text.TextUtils;
import com.amazon.a.a.o.b;
import com.bytedance.sdk.openadsdk.core.model.Wwa;
import java.util.HashSet;
import java.util.Set;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
/* loaded from: classes2.dex */
public class YFl {
    private String AlY;
    private String DSW;
    private String EH;
    private int NjR;
    Sg Sg;
    private String eT;
    private int nc;
    private double qsH;
    tN tN;
    private String vc;
    private String wN;
    AlY YFl = new AlY(this);
    private final Set<nc> YoT = new HashSet();
    private String GA = "VAST_ACTION_BUTTON";
    private boolean pDU = false;

    public String AlY() {
        return this.AlY;
    }

    public void AlY(String str) {
        this.DSW = str;
    }

    public String DSW() {
        return this.DSW;
    }

    public void DSW(String str) {
        this.EH = str;
    }

    public void EH() {
        this.pDU = true;
    }

    public int GA() {
        return this.nc;
    }

    public Sg Sg() {
        return this.Sg;
    }

    public void Sg(int i) {
        this.nc = i;
    }

    public void Sg(String str) {
        this.wN = str;
    }

    public AlY YFl() {
        return this.YFl;
    }

    public void YFl(double d) {
        this.qsH = d;
    }

    public void YFl(int i) {
        this.NjR = i;
    }

    public void YFl(String str) {
        this.AlY = str;
    }

    public int YoT() {
        return this.NjR;
    }

    public String eT() {
        return this.eT;
    }

    public Set<nc> pDU() {
        return this.YoT;
    }

    public double qsH() {
        return this.qsH;
    }

    public tN tN() {
        return this.tN;
    }

    public void tN(String str) {
        this.vc = str;
    }

    public String vc() {
        return this.vc;
    }

    public String wN() {
        return this.wN;
    }

    public void wN(String str) {
        this.GA = str;
    }

    public void YFl(Sg sg) {
        if (sg != null) {
            sg.YFl(this.DSW);
        }
        this.Sg = sg;
    }

    public void YFl(tN tNVar) {
        if (tNVar != null) {
            tNVar.YFl(this.DSW);
        }
        this.tN = tNVar;
    }

    public String NjR() {
        tN tNVar;
        String str = this.vc;
        if (!TextUtils.isEmpty(this.EH)) {
            String str2 = this.EH;
            this.EH = null;
            return str2;
        }
        String str3 = this.GA;
        str3.hashCode();
        if (str3.equals("VAST_ICON")) {
            Sg sg = this.Sg;
            if (sg != null && !TextUtils.isEmpty(sg.qsH)) {
                str = this.Sg.qsH;
            }
        } else if (str3.equals("VAST_END_CARD") && (tNVar = this.tN) != null && !TextUtils.isEmpty(tNVar.qsH)) {
            str = this.tN.qsH;
        }
        this.GA = "VAST_ACTION_BUTTON";
        return str;
    }

    public JSONObject nc() throws JSONException {
        JSONObject jSONObject = new JSONObject();
        jSONObject.put("videoTrackers", this.YFl.YFl());
        Sg sg = this.Sg;
        if (sg != null) {
            jSONObject.put("vastIcon", sg.YFl());
        }
        tN tNVar = this.tN;
        if (tNVar != null) {
            jSONObject.put("endCard", tNVar.YFl());
        }
        jSONObject.put("title", this.AlY);
        jSONObject.put(b.c, this.wN);
        jSONObject.put("clickThroughUrl", this.vc);
        jSONObject.put("videoUrl", this.DSW);
        jSONObject.put("videDuration", this.qsH);
        jSONObject.put("tag", this.eT);
        jSONObject.put("videoWidth", this.NjR);
        jSONObject.put("videoHeight", this.nc);
        jSONObject.put("viewabilityVendor", rkt());
        return jSONObject;
    }

    private JSONArray rkt() {
        JSONArray jSONArray = new JSONArray();
        for (nc ncVar : this.YoT) {
            if (ncVar != null) {
                jSONArray.put(ncVar.AlY());
            }
        }
        return jSONArray;
    }

    public static YFl YFl(JSONObject jSONObject) {
        if (jSONObject == null) {
            return null;
        }
        YFl yFl = new YFl();
        yFl.YFl.YFl(jSONObject.optJSONObject("videoTrackers"));
        yFl.Sg = Sg.YFl(jSONObject.optJSONObject("vastIcon"));
        yFl.tN = tN.Sg(jSONObject.optJSONObject("endCard"));
        yFl.AlY = jSONObject.optString("title");
        yFl.wN = jSONObject.optString(b.c);
        yFl.vc = jSONObject.optString("clickThroughUrl");
        yFl.DSW = jSONObject.optString("videoUrl");
        yFl.qsH = jSONObject.optDouble("videDuration");
        yFl.eT = jSONObject.optString("tag");
        yFl.NjR = jSONObject.optInt("videoWidth");
        yFl.NjR = jSONObject.optInt("videoHeight");
        yFl.YoT.addAll(nc.YFl(jSONObject.optJSONArray("viewabilityVendor")));
        return yFl;
    }

    public void YFl(Wwa wwa) {
        this.YFl.YFl(wwa);
        Sg sg = this.Sg;
        if (sg != null) {
            sg.YFl(wwa);
        }
        tN tNVar = this.tN;
        if (tNVar != null) {
            tNVar.YFl(wwa);
        }
    }

    public void vc(String str) {
        this.eT = str;
        this.YFl.YFl(str);
    }

    public void YFl(Set<nc> set) {
        if (set == null || set.size() <= 0) {
            return;
        }
        this.YoT.addAll(set);
    }
}
