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

import android.app.Activity;
import android.content.Context;
import android.os.SystemClock;
import android.text.TextUtils;
import android.util.SparseArray;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import com.bytedance.sdk.openadsdk.component.reward.lb.wu;
import com.bytedance.sdk.openadsdk.core.gof;
import com.bytedance.sdk.openadsdk.core.lb.lb;
import com.bytedance.sdk.openadsdk.core.lb.ro;
import com.bytedance.sdk.openadsdk.core.model.ai;
import com.bytedance.sdk.openadsdk.core.model.duv;
import com.bytedance.sdk.openadsdk.core.model.irt;
import com.bytedance.sdk.openadsdk.core.model.lse;
import com.bytedance.sdk.openadsdk.core.model.wey;
import com.bytedance.sdk.openadsdk.core.vt.ef;
import com.bytedance.sdk.openadsdk.core.vt.sds;
import com.bytedance.sdk.openadsdk.core.xgn;
import com.bytedance.sdk.openadsdk.utils.bx;
import com.bytedance.sdk.openadsdk.utils.qhl;
import com.bytedance.sdk.openadsdk.utils.zan;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.Map;
import org.json.JSONObject;

/* JADX INFO: loaded from: classes2.dex */
public class fm extends ro {
    private boolean fm;

    /* JADX INFO: renamed from: gc, reason: collision with root package name */
    private int f7147gc;
    private boolean hxv;

    /* JADX INFO: renamed from: lb, reason: collision with root package name */
    private boolean f7148lb;
    private WeakReference<InterfaceC0078fm> pkk;
    private boolean ro;

    /* JADX INFO: renamed from: com.bytedance.sdk.openadsdk.core.lb.fm$fm, reason: collision with other inner class name */
    public interface InterfaceC0078fm {
        long getVideoProgress();
    }

    public fm(@NonNull Context context, @NonNull lse lseVar, @NonNull String str, int i10) {
        super(context, lseVar, str, i10);
        this.fm = true;
        this.ro = false;
        this.f7148lb = false;
        this.hxv = false;
    }

    private boolean ef() {
        lse lseVar = ((ro) this).ajl;
        if (lseVar == null || wu()) {
            return false;
        }
        if (lseVar.siu() != 5 && lseVar.siu() != 15) {
            return false;
        }
        if (this.f7147gc == 0) {
            this.f7147gc = lseVar.ie();
        }
        ro();
        fm();
        lb();
        if (this.f7147gc == 5 && wsy() && fm() && !ro() && !lb()) {
            return false;
        }
        int i10 = this.f7147gc;
        return i10 == 1 || i10 == 2 || i10 == 5;
    }

    private boolean wsy() {
        lse lseVar = ((ro) this).ajl;
        return lse.jnr(lseVar) && lseVar.qb() == 1;
    }

    private boolean wu() {
        return this instanceof ef;
    }

    public void fm(boolean z10) {
        this.fm = z10;
    }

    public void lb(boolean z10) {
        this.f7148lb = z10;
    }

    public void ro(boolean z10) {
        this.ro = z10;
    }

    public void yz(boolean z10) {
        this.hxv = z10;
    }

    private boolean yz(View view) {
        if (view == null) {
            return false;
        }
        if ((view instanceof com.bytedance.sdk.openadsdk.core.fhx.ro.ajl) || view.getId() == qhl.hou || view.getId() == qhl.tzk || view.getId() == qhl.lz || view.getId() == qhl.f7564qf || view.getId() == qhl.si || view.getId() == 520093726 || view.getId() == qhl.eys) {
            return true;
        }
        if (!(view instanceof ViewGroup)) {
            return false;
        }
        int i10 = 0;
        while (true) {
            ViewGroup viewGroup = (ViewGroup) view;
            if (i10 >= viewGroup.getChildCount()) {
                return false;
            }
            if (yz(viewGroup.getChildAt(i10))) {
                return true;
            }
            i10++;
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:124:0x0231  */
    /* JADX WARN: Removed duplicated region for block: B:185:0x0341  */
    /* JADX WARN: Removed duplicated region for block: B:63:0x0112  */
    @Override // com.bytedance.sdk.openadsdk.core.lb.ro, com.bytedance.sdk.openadsdk.core.lb.lb
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public void fm(View view, float f10, float f11, float f12, float f13, SparseArray<lb.fm> sparseArray, boolean z10) {
        com.bytedance.sdk.openadsdk.core.onz.yz yzVarFm;
        JSONObject jSONObject;
        boolean z11;
        int i10;
        JSONObject jSONObject2;
        View view2;
        Object tag;
        Activity activityFm;
        boolean z12;
        irt irtVar;
        if (fm(view, 2, f10, f11, f12, f13, sparseArray, z10)) {
            return;
        }
        lse lseVar = ((ro) this).ajl;
        lseVar.fhx(true);
        lseVar.qi();
        if (!lseVar.wey()) {
            lseVar.yz(true);
        }
        if (lse.jnr(lseVar)) {
            if (!wu.fm(lseVar) || (irtVar = ((ro) this).jnr) == null) {
                com.bytedance.sdk.openadsdk.yz.lb.ro(lseVar, ((ro) this).wsy, lseVar.cll());
            } else {
                com.bytedance.sdk.openadsdk.yz.lb.ro(lseVar, ((ro) this).wsy, irtVar.qhl);
            }
        }
        if (this.dsz != null) {
            if (this.irt == null) {
                this.irt = new HashMap();
            }
            this.irt.put("duration", Long.valueOf(this.dsz.ajl()));
        }
        int iIj = lseVar.ij();
        lseVar.kwx(0);
        com.bytedance.sdk.openadsdk.sds.fm.fm.lb lbVar = this.fhx;
        if (lbVar != null) {
            lbVar.fm(iIj > 0 ? iIj : 0);
        }
        Map<String, Object> map = this.irt;
        if (map != null) {
            map.remove("dsp_click_type");
            this.irt.remove("click_probability_jump");
            this.irt.remove("auto_click");
        }
        boolean zZn = lseVar.zn();
        if (iIj > 0) {
            if (this.irt == null) {
                this.irt = new HashMap();
            }
            if (zZn && iIj < 11) {
                this.irt.put("dsp_click_type", Integer.valueOf(iIj));
            }
            if (iIj >= 11 && lseVar.fb() == 0) {
                this.irt.put("click_probability_jump", Integer.valueOf(com.bytedance.sdk.openadsdk.core.model.ef.fm(iIj)));
            }
        }
        com.bytedance.sdk.openadsdk.core.model.yz yzVarKl = lseVar.kl();
        if (zZn || yzVarKl != null) {
            WeakReference<InterfaceC0078fm> weakReference = this.pkk;
            long videoProgress = (weakReference == null || weakReference.get() == null) ? 0L : this.pkk.get().getVideoProgress();
            if (!zZn && yzVarKl != null && (yzVarFm = yzVarKl.fm()) != null) {
                yzVarFm.wsy(videoProgress);
            }
            if (zZn) {
                if (view != null) {
                    Object tag2 = view.getTag(570425345);
                    String str = tag2 instanceof String ? (String) tag2 : "VAST_ACTION_BUTTON";
                    com.bytedance.sdk.openadsdk.core.onz.fm fmVarMt = lseVar.mt();
                    if (fmVarMt != null) {
                        fmVarMt.jnr(str);
                        if (!TextUtils.isEmpty(str)) {
                            fm(str);
                        }
                        if ("VAST_ICON".equals(str)) {
                            com.bytedance.sdk.openadsdk.core.onz.ro roVarRo = fmVarMt.ro();
                            if (roVarRo != null) {
                                roVarRo.fm(videoProgress);
                            }
                        } else if ("VAST_END_CARD".equals(str)) {
                            com.bytedance.sdk.openadsdk.core.onz.lb lbVarLb = fmVarMt.lb();
                            if (lbVarLb != null) {
                                lbVarLb.fm(videoProgress);
                            }
                        } else {
                            com.bytedance.sdk.openadsdk.core.onz.yz yzVarFm2 = fmVarMt.fm();
                            if (yzVarFm2 != null) {
                                yzVarFm2.wsy(videoProgress);
                            }
                        }
                    }
                }
            }
        }
        if (ef() && yz(view) && !this.f7148lb) {
            super.fm(view, f10, f11, f12, f13, sparseArray, z10);
            return;
        }
        if (((ro) this).yz == null) {
            ((ro) this).yz = gof.fm();
        }
        if (((ro) this).yz != null && fm(view, z10)) {
            JSONObject jSONObjectFm = sds.fm(view);
            irt irtVar2 = ((ro) this).jnr;
            if (irtVar2 != null) {
                int i11 = irtVar2.wu;
                JSONObject jSONObject3 = irtVar2.f7177ef;
                JSONObject jSONObject4 = irtVar2.dsz;
                i10 = i11;
                z11 = irtVar2.onz;
                jSONObject = jSONObject3;
                jSONObject2 = jSONObject4;
            } else {
                jSONObject = jSONObjectFm;
                z11 = false;
                i10 = -1;
                jSONObject2 = null;
            }
            long j10 = this.hlt;
            long j11 = this.hi;
            WeakReference<View> weakReference2 = this.f7152ef;
            duv duvVarFm = fm(f10, f11, f12, f13, sparseArray, j10, j11, weakReference2 == null ? yz() : weakReference2.get(), jnr(), zan.wu(((ro) this).yz), zan.vt(((ro) this).yz), zan.ef(((ro) this).yz), i10, jSONObject, jSONObject2);
            this.vt = duvVarFm;
            if (z11) {
                com.bytedance.sdk.openadsdk.yz.lb.fm("click", lseVar, duvVarFm, ((ro) this).wsy, true, this.irt, z10 ? 1 : 2);
                return;
            }
            int iOy = lseVar.oy();
            if (iOy == 2 || iOy == 3) {
                view2 = view;
                if (iOy == 3) {
                    String strRbn = lseVar.rbn();
                    if (TextUtils.isEmpty(strRbn) || !strRbn.contains("play.google.com/store")) {
                        if (this.duv != null || this.ro) {
                            com.bytedance.sdk.openadsdk.yz.lb.fm("click_button", lseVar, this.vt, ((ro) this).wsy, true, this.irt, z10 ? 1 : 2);
                        }
                        if (view2 != null) {
                            try {
                                tag = view2.getTag(520093762);
                            } catch (Exception unused) {
                            }
                        } else {
                            tag = null;
                        }
                        if ((view2 != null && (view.getId() == 520093726 || (view2 instanceof com.bytedance.sdk.openadsdk.core.fhx.ro.ajl))) || Boolean.TRUE.equals(tag)) {
                            xgn.fm(true);
                        }
                        activityFm = view2 != null ? com.bytedance.sdk.component.utils.ro.fm(view) : null;
                        Context context = activityFm == null ? ((ro) this).yz : activityFm;
                        if (wey.lb(lseVar) && this.hxv) {
                            z12 = false;
                        } else {
                            boolean zFm = xgn.fm(context, lseVar, this.wu, this.duv, this.qhl, ((ro) this).wsy, this.fhx, true, iIj);
                            lseVar.ajl(SystemClock.elapsedRealtime());
                            xgn.fm(false);
                            z12 = zFm;
                        }
                        if (this.fm) {
                            com.bytedance.sdk.openadsdk.yz.lb.fm("click", lseVar, this.vt, ((ro) this).wsy, z12, this.irt, z10 ? 1 : 2);
                        }
                    } else if (com.bytedance.sdk.openadsdk.sds.fm.fm.ro.fm(((ro) this).yz, strRbn, strRbn.substring(strRbn.indexOf("?id=") + 4), ((ro) this).wsy, lseVar)) {
                        if (this.fm) {
                            com.bytedance.sdk.openadsdk.yz.lb.fm("click", lseVar, this.vt, ((ro) this).wsy, true, this.irt, z10 ? 1 : 2);
                        }
                    }
                }
            } else if (iOy != 4) {
                if (iOy == 5) {
                    String strRo = ro(((ro) this).wsy);
                    if (!TextUtils.isEmpty(strRo)) {
                        com.bytedance.sdk.openadsdk.yz.lb.fm("click_call", lseVar, this.vt, strRo, true, this.irt, z10 ? 1 : 2);
                    }
                    com.bytedance.sdk.openadsdk.yz.lb.fm("click", lseVar, this.vt, ((ro) this).wsy, bx.ro(view.getContext(), lseVar.xp()), this.irt, z10 ? 1 : 2);
                    view2 = view;
                } else if (iOy != 8) {
                    view2 = view;
                    iOy = -1;
                }
            } else if (!ai.ro(lseVar) || (this.duv == null && this.qhl == null)) {
                view2 = view;
                com.bytedance.sdk.openadsdk.sds.fm.fm.lb lbVar2 = this.fhx;
                if (lbVar2 != null) {
                    lbVar2.fm(lseVar);
                    Map<String, Object> map2 = this.irt;
                    if (lseVar.wey() && !lseVar.gqi()) {
                        map2.put("auto_click", Boolean.TRUE);
                        lseVar.jnr(false);
                    }
                    if (this.fm) {
                        com.bytedance.sdk.openadsdk.yz.lb.fm("click", lseVar, this.vt, ((ro) this).wsy, true, map2, z10 ? 1 : 2);
                    }
                }
            } else {
                view2 = view;
                activityFm = view2 != null ? com.bytedance.sdk.component.utils.ro.fm(view) : null;
                boolean zFm2 = xgn.fm(activityFm == null ? ((ro) this).yz : activityFm, lseVar, this.wu, this.duv, this.qhl, ((ro) this).wsy, this.fhx, true, iIj);
                if (this.fm) {
                    com.bytedance.sdk.openadsdk.yz.lb.fm("click", lseVar, this.vt, ((ro) this).wsy, zFm2, this.irt, z10 ? 1 : 2);
                }
            }
            ro.fm fmVar = this.ku;
            if (fmVar != null) {
                fmVar.fm(view2, iOy);
            }
        }
    }

    public boolean lb() {
        return false;
    }

    public boolean ro() {
        return false;
    }

    private String ro(String str) {
        str.getClass();
        switch (str) {
            case "banner_ad":
                return "banner_call";
            case "open_ad":
                return "open_ad";
            case "embeded_ad":
                return "feed_call";
            case "interaction":
                return "interaction_call";
            case "slide_banner_ad":
                return "banner_call";
            default:
                return "";
        }
    }

    public boolean fm() {
        lse lseVar = ((ro) this).ajl;
        if (lseVar == null) {
            return true;
        }
        int iRo = gof.yz().ro(lseVar.pg());
        int iLb = com.bytedance.sdk.component.utils.gof.lb(gof.fm());
        if (iRo == 1) {
            return bx.yz(iLb);
        }
        if (iRo == 2) {
            return bx.jnr(iLb) || bx.yz(iLb) || bx.ajl(iLb);
        }
        if (iRo != 3) {
            return iRo != 5 || bx.yz(iLb) || bx.ajl(iLb);
        }
        return false;
    }

    public void fm(InterfaceC0078fm interfaceC0078fm) {
        this.pkk = new WeakReference<>(interfaceC0078fm);
    }

    public void fm(View view) {
        fm(view, this.wey, this.sds, this.maa, this.lse, this.f7149ha, this.ol);
    }
}
