package com.bytedance.sdk.openadsdk.core.dsz.ajl;

import android.app.Activity;
import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import com.bytedance.adsdk.ugeno.core.duv;
import com.bytedance.adsdk.ugeno.core.fhx;
import com.bytedance.adsdk.ugeno.core.irt;
import com.bytedance.adsdk.ugeno.core.ku;
import com.bytedance.adsdk.ugeno.yz.ajl;
import com.bytedance.sdk.component.utils.wey;
import com.bytedance.sdk.openadsdk.core.model.ha;
import com.bytedance.sdk.openadsdk.core.model.irt;
import com.bytedance.sdk.openadsdk.core.model.lse;
import java.util.HashMap;
import org.json.JSONObject;
import tv.danmaku.ijk.media.player.IjkEventListener;

/* JADX INFO: loaded from: classes2.dex */
public class wsy extends yz {
    private float ai;
    private com.bytedance.sdk.openadsdk.core.widget.jnr gzf;

    /* JADX INFO: renamed from: ha, reason: collision with root package name */
    private boolean f7030ha;
    private com.bytedance.adsdk.ugeno.ro.lb hi;
    private com.bytedance.adsdk.ugeno.ro.lb mq;
    private com.bytedance.adsdk.ugeno.ro.lb nt;
    private boolean ol;
    private float pkk;
    private float wbw;

    public wsy(Context context, lse lseVar, boolean z10, fm fmVar, ViewGroup viewGroup) {
        super(context, lseVar, z10, fmVar, viewGroup);
        this.ol = false;
        this.f7030ha = true;
        if (TextUtils.equals(this.maa, "fullscreen_interstitial_ad")) {
            this.ai = this.jnr.mxq();
        } else if (TextUtils.equals(this.maa, "rewarded_video")) {
            this.ai = this.jnr.we();
        }
    }

    private void dsz() {
        ku kuVar = new ku();
        HashMap map = new HashMap();
        map.put("image_info", this.ajl.ku());
        map.put("cache_dir", this.ajl.onz());
        kuVar.fm(map);
        kuVar.fm(this.ro);
        kuVar.fm(this.yz);
        kuVar.ro(this.hlt);
        this.fm.fm("ad", kuVar);
    }

    private void duv() {
        com.bytedance.adsdk.ugeno.ro.lb lbVar = this.hi;
        if (lbVar != null) {
            lbVar.lb(8);
        }
        com.bytedance.adsdk.ugeno.ro.lb lbVar2 = this.nt;
        if (lbVar2 != null) {
            lbVar2.lb(8);
        }
    }

    private void fhx() {
        com.bytedance.adsdk.ugeno.ro.lb<View> lbVar = this.f7034lb;
        if (lbVar == null) {
            return;
        }
        com.bytedance.adsdk.ugeno.ro.lb<T> lbVarAjl = lbVar.ajl("RVCountdown");
        this.hi = lbVarAjl;
        if (lbVarAjl == 0) {
            this.hi = this.f7034lb.ajl("FVCountdown");
        }
        if (this.hi == null) {
            this.hi = this.f7034lb.ajl("AOCountdown");
        }
        com.bytedance.adsdk.ugeno.ro.lb<T> lbVarAjl2 = this.f7034lb.ajl("RVSkipView");
        this.nt = lbVarAjl2;
        if (lbVarAjl2 == 0) {
            this.nt = this.f7034lb.ajl("FVSkipView");
        }
        if (this.nt == null) {
            this.nt = this.f7034lb.ajl("AOSkipView");
        }
    }

    private boolean irt() {
        lse lseVar = this.jnr;
        return lseVar != null && lseVar.cyr() == 1;
    }

    private void lb(CharSequence charSequence, boolean z10, int i10, boolean z11) {
        com.bytedance.adsdk.ugeno.ro.lb lbVar = this.nt;
        if (lbVar != null && (lbVar instanceof com.bytedance.sdk.openadsdk.core.dsz.ro.ajl)) {
            int i11 = 0;
            if (!z10 && !z11) {
                i11 = 8;
            }
            lbVar.lb(i11);
        }
    }

    private int onz() {
        dsz();
        try {
            this.fm.fm(this.hlt, this.f7034lb);
            if (this.f7034lb != null) {
                fhx();
                duv();
            }
            if (this instanceof com.bytedance.sdk.openadsdk.core.dsz.ajl.fm.ajl) {
                return 0;
            }
            this.ajl.pkk().ro();
            this.ajl.pkk().lb();
            return 0;
        } catch (NoClassDefFoundError unused) {
            return 140;
        } catch (UnsatisfiedLinkError unused2) {
            return 139;
        } catch (Throwable unused3) {
            return 141;
        }
    }

    public int ef() {
        dsz();
        this.fm.fm((fhx) this);
        this.fm.fm((irt) this);
        if (irt()) {
            this.fm.fm(new lb());
        }
        ha haVarPo = this.jnr.po();
        if (haVarPo == null) {
            try {
                if (com.bytedance.sdk.openadsdk.core.dsz.ajl.fm.ajl.fm(this.maa)) {
                    this.f7034lb = this.fm.fm(this.yz, this.hlt, fm(haVarPo));
                } else {
                    this.f7034lb = this.fm.fm(this.yz, this.hlt, (JSONObject) null);
                }
            } catch (NoClassDefFoundError unused) {
                return 140;
            } catch (UnsatisfiedLinkError unused2) {
                return 139;
            } catch (Throwable unused3) {
                return 141;
            }
        } else {
            this.f7034lb = this.fm.fm(this.yz, this.hlt, fm(haVarPo));
        }
        if (this.f7034lb != null) {
            fhx();
            this.mq = this.f7034lb.ajl("ProgressBar");
            duv();
        }
        if (this instanceof com.bytedance.sdk.openadsdk.core.dsz.ajl.fm.ajl) {
            return 0;
        }
        this.ajl.pkk().ro();
        this.ajl.pkk().lb();
        return 0;
    }

    @Override // com.bytedance.sdk.openadsdk.core.dsz.ajl.yz
    public void fm(com.bytedance.sdk.openadsdk.core.widget.jnr jnrVar) {
        this.gzf = jnrVar;
    }

    public void ku() {
        duv duvVar = this.fm;
        if (duvVar != null) {
            duvVar.fm(this.f7034lb, "show", new Object[0]);
        }
    }

    @Override // com.bytedance.sdk.openadsdk.core.dsz.ajl.yz
    public JSONObject ro() {
        return this.ajl.lb();
    }

    @Override // com.bytedance.sdk.openadsdk.core.dsz.ajl.yz, com.bytedance.sdk.component.adexpress.dynamic.yz
    public void setSoundMute(boolean z10) {
    }

    @Override // com.bytedance.sdk.openadsdk.core.dsz.ajl.yz, com.bytedance.sdk.component.adexpress.dynamic.yz
    public void setTime(CharSequence charSequence, int i10, int i11, boolean z10) {
        duv duvVar;
        if (this.f7034lb == null) {
            return;
        }
        boolean z11 = i10 == 1;
        if (TextUtils.equals(this.maa, "open_ad") && (duvVar = this.fm) != null) {
            duvVar.fm(this.f7034lb, "countdown", charSequence);
        }
        ro(charSequence, z11, i11, z10);
        fm(charSequence, z11, i11, z10);
        lb(charSequence, z11, i11, z10);
    }

    public void vt() {
        duv duvVar = this.fm;
        if (duvVar != null) {
            duvVar.fm(this.f7034lb, "videoFail", new Object[0]);
        }
    }

    @Override // com.bytedance.sdk.openadsdk.core.dsz.ajl.yz
    public com.bytedance.adsdk.ugeno.ro.lb wsy() {
        com.bytedance.adsdk.ugeno.ro.lb<View> lbVar = this.f7034lb;
        if (lbVar == null) {
            return null;
        }
        return lbVar.ajl("Playable");
    }

    @Override // com.bytedance.sdk.openadsdk.core.dsz.ajl.yz
    public com.bytedance.adsdk.ugeno.ro.lb wu() {
        com.bytedance.adsdk.ugeno.ro.lb<View> lbVar = this.f7034lb;
        if (lbVar == null) {
            return null;
        }
        return lbVar.ajl("VideoV3");
    }

    @Override // com.bytedance.sdk.openadsdk.core.dsz.ajl.yz
    public int yz() {
        if (!this.ajl.hxv()) {
            return ef();
        }
        wey.fm("UGenRender", "renderWidget: only update data");
        return onz();
    }

    private void ro(CharSequence charSequence, boolean z10, int i10, boolean z11) {
        com.bytedance.adsdk.ugeno.ro.lb lbVar = this.mq;
        if (lbVar != null && (lbVar instanceof com.bytedance.sdk.openadsdk.core.dsz.ro.yz.lb)) {
            try {
                int i11 = Integer.parseInt((String) charSequence);
                if (this.f7030ha) {
                    this.wbw = i10;
                    this.f7030ha = false;
                }
                float f10 = (float) (((0.5d / ((double) this.wbw)) * 100.0d) + ((double) this.pkk));
                this.pkk = f10;
                this.fm.fm(this.f7034lb, "ProgressBar://progress", Float.valueOf(f10), Float.valueOf(this.ai));
                if (!z11 && i11 > 0 && !z10) {
                    ((com.bytedance.sdk.openadsdk.core.dsz.ro.yz.lb) this.mq).wsy(IjkEventListener.BUFFERING_START);
                    ((com.bytedance.sdk.openadsdk.core.dsz.ro.yz.lb) this.mq).fm((int) this.pkk);
                    return;
                }
                ((com.bytedance.sdk.openadsdk.core.dsz.ro.yz.lb) this.mq).lb(8);
            } catch (Throwable th) {
                wey.lb("UGenRender", th.getMessage());
            }
        }
    }

    @Override // com.bytedance.sdk.openadsdk.core.dsz.ajl.yz
    public JSONObject fm() {
        JSONObject jSONObjectLb = this.ajl.lb();
        if (jSONObjectLb != null) {
            return jSONObjectLb.optJSONObject("xTemplate");
        }
        return null;
    }

    @Override // com.bytedance.sdk.openadsdk.core.dsz.ajl.yz, com.bytedance.adsdk.ugeno.core.fhx
    public void fm(com.bytedance.adsdk.ugeno.ro.lb lbVar, String str, ajl.fm fmVar) {
        int i10;
        int i11;
        if (this.wu == null || fmVar == null) {
            return;
        }
        String strRo = fmVar.ro();
        strRo.getClass();
        i10 = 7;
        i11 = -1;
        switch (strRo) {
            case "sendLogExtra":
                new wu().fm("sendLogExtra", this.jnr, this.maa, fmVar.lb());
                return;
            case "sendAdExtra":
                new wu().fm("sendAdExtra", this.jnr, this.maa, fmVar.lb());
                return;
            case "openPrivacy":
                break;
            case "pauseVideo":
            case "videoControl":
                i10 = 4;
                break;
            case "skip":
                i10 = 6;
                break;
            case "openPlayable":
                com.bytedance.sdk.openadsdk.core.vt.irt irtVar = this.f7031ef;
                if (irtVar != null) {
                    irtVar.ro((JSONObject) null);
                    return;
                }
                return;
            case "convert":
                i10 = 2;
                break;
            case "muteVideo":
                i10 = 5;
                break;
            case "openLinks":
                new ajl().fm(fm(lbVar.ku()), this.ro instanceof Activity, this.jnr, this.maa, fmVar.lb(), this.gzf);
                return;
            case "speedVideoOrTimer":
                wey.ro("UGenRender", "onUGenEvent: " + fmVar.lb());
                i10 = 13;
                if (fmVar.lb() != null && !fmVar.lb().isEmpty()) {
                    try {
                        i11 = Integer.parseInt(String.valueOf(fmVar.lb().get("switch")));
                    } catch (Throwable th) {
                        wey.lb("UGenRender", th);
                    }
                    break;
                }
                break;
            case "dislike":
                i10 = 3;
                break;
            default:
                i10 = 0;
                break;
        }
        this.wu.fm(lbVar.ku(), i10, new irt.fm().yz(this.onz).lb(this.fhx).ro(this.irt).fm(this.qhl).ro(this.gof).fm(this.gqi).lb(i11).fm(this.lse).fm(true).fm(lbVar.hxv()).ro(false).fm());
    }

    private void fm(CharSequence charSequence, boolean z10, int i10, boolean z11) {
        int i11;
        com.bytedance.adsdk.ugeno.ro.lb lbVar = this.hi;
        if (lbVar != null && (lbVar instanceof com.bytedance.sdk.openadsdk.core.dsz.ro.ro)) {
            try {
                i11 = Integer.parseInt((String) charSequence);
            } catch (Exception unused) {
                wey.lb("UGenRender", "parse duration exception", charSequence);
                i11 = 0;
            }
            com.bytedance.sdk.openadsdk.core.dsz.ro.ro roVar = (com.bytedance.sdk.openadsdk.core.dsz.ro.ro) this.hi;
            if (!z11 && i11 > 0 && !this.ol && !fm(roVar)) {
                this.hi.lb(0);
                if (!z10 && this.ajl.fm() && com.bytedance.sdk.component.adexpress.yz.ajl.ro(this.ajl.yz())) {
                    ((com.bytedance.sdk.openadsdk.core.dsz.ro.ro) this.hi).onz(String.valueOf(i10));
                    return;
                } else if (!"open_ad".equals(this.ajl.yz()) && this.ajl.fm()) {
                    this.ol = true;
                    this.hi.lb(8);
                    return;
                } else {
                    ((com.bytedance.sdk.openadsdk.core.dsz.ro.ro) this.hi).onz(String.valueOf(charSequence));
                    return;
                }
            }
            this.hi.lb(8);
        }
    }

    private Context fm(View view) {
        Activity activityFm = view != null ? com.bytedance.sdk.component.utils.ro.fm(view) : null;
        return activityFm == null ? this.ro : activityFm;
    }

    @Override // com.bytedance.sdk.openadsdk.core.dsz.ajl.yz
    public void fm(long j10, long j11) {
        super.fm(j10, j11);
        duv duvVar = this.fm;
        if (duvVar != null) {
            duvVar.fm(this.f7034lb, "videoProgress", Long.valueOf(j10), Long.valueOf(j11));
        }
    }

    private boolean fm(com.bytedance.sdk.openadsdk.core.dsz.ro.ro roVar) {
        if (roVar == null) {
            return true;
        }
        if (TextUtils.equals(this.maa, "open_ad")) {
            return roVar.yz() == 8 || roVar.yz() == 4;
        }
        return false;
    }

    public JSONObject fm(ha haVar) {
        if (haVar != null) {
            return haVar.jnr();
        }
        return null;
    }
}
