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

import android.R;
import android.app.Activity;
import android.content.Context;
import android.text.TextUtils;
import android.util.SparseArray;
import android.view.View;
import androidx.annotation.NonNull;
import b6.f;
import com.bytedance.sdk.component.utils.maa;
import com.bytedance.sdk.openadsdk.api.nativeAd.PAGNativeAd;
import com.bytedance.sdk.openadsdk.core.gof;
import com.bytedance.sdk.openadsdk.core.lb.lb;
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.vt;
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 ro extends lb {
    private static int pkk = Integer.MIN_VALUE;
    protected final lse ajl;
    protected f dsz;
    protected PAGNativeAd duv;

    /* JADX INFO: renamed from: ef, reason: collision with root package name */
    protected WeakReference<View> f7152ef;
    protected com.bytedance.sdk.openadsdk.sds.fm.fm.lb fhx;
    private String fm;
    protected com.bytedance.sdk.openadsdk.core.vt.ro gof;
    protected int gqi;
    protected Map<String, Object> irt;
    public irt jnr;
    protected fm ku;

    /* JADX INFO: renamed from: lb, reason: collision with root package name */
    private boolean f7153lb;
    protected boolean onz;
    protected com.bytedance.sdk.openadsdk.core.yz.fm qhl;
    private WeakReference<Activity> ro;
    protected duv vt;
    protected final String wsy;
    protected final int wu;
    protected Context yz;

    public interface fm {
        void fm(View view, int i10);
    }

    public ro(@NonNull Context context, @NonNull lse lseVar, @NonNull String str, int i10) {
        this.onz = false;
        this.gqi = 0;
        this.f7153lb = false;
        this.yz = context;
        this.ajl = lseVar;
        this.wsy = str;
        this.wu = i10;
    }

    public void fm(int i10) {
        this.gzf = i10;
    }

    public String jnr() {
        return this.fm;
    }

    public void lb(int i10) {
        this.nt = i10;
    }

    public void ro(int i10) {
        this.mq = i10;
    }

    public void yz(int i10) {
        this.gqi = i10;
    }

    public ro(@NonNull Context context, @NonNull lse lseVar, @NonNull String str, int i10, boolean z10) {
        this(context, lseVar, str, i10);
        this.f7153lb = z10;
    }

    public static boolean lb(View view) {
        return 520093705 == view.getId() || 520093707 == view.getId() || 520093703 == view.getId() || fm(view.getContext()) == view.getId() || qhl.wjb == view.getId() || qhl.jk == view.getId();
    }

    public void fm(f fVar) {
        this.dsz = fVar;
    }

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

    public void ro(View view) {
        if (view == null) {
            return;
        }
        this.f7152ef = new WeakReference<>(view);
    }

    public View yz() {
        WeakReference<Activity> weakReference = this.ro;
        if (weakReference == null || weakReference.get() == null) {
            return null;
        }
        return this.ro.get().findViewById(R.id.content);
    }

    public void fm(PAGNativeAd pAGNativeAd) {
        this.duv = pAGNativeAd;
    }

    public void fm(fm fmVar) {
        this.ku = fmVar;
    }

    public void fm(com.bytedance.sdk.openadsdk.core.vt.ro roVar) {
        this.gof = roVar;
    }

    public void fm(com.bytedance.sdk.openadsdk.core.yz.fm fmVar) {
        this.qhl = fmVar;
    }

    public void fm(com.bytedance.sdk.openadsdk.sds.fm.fm.lb lbVar) {
        this.fhx = lbVar;
    }

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

    public boolean fm(duv duvVar, Map<String, Object> map) {
        return false;
    }

    public void fm(Activity activity) {
        if (activity == null) {
            return;
        }
        this.ro = new WeakReference<>(activity);
    }

    public void fm(Map<String, Object> map) {
        Map<String, Object> map2 = this.irt;
        if (map2 != null) {
            map2.putAll(map);
            map.putAll(this.irt);
        }
        this.irt = map;
    }

    @Override // com.bytedance.sdk.openadsdk.core.lb.lb
    public void fm(View view, float f10, float f11, float f12, float f13, SparseArray<lb.fm> sparseArray, boolean z10) {
        int i10;
        boolean z11;
        JSONObject jSONObject;
        JSONObject jSONObject2;
        com.bytedance.sdk.openadsdk.core.onz.yz yzVarFm;
        if (this.yz == null) {
            this.yz = gof.fm();
        }
        if ((this.f7153lb || !fm(view, 1, f10, f11, f12, f13, sparseArray, z10)) && this.yz != null) {
            irt irtVar = this.jnr;
            if (irtVar != null) {
                int i11 = irtVar.wu;
                JSONObject jSONObject3 = irtVar.f7177ef;
                JSONObject jSONObject4 = irtVar.dsz;
                z11 = irtVar.onz;
                i10 = i11;
                jSONObject = jSONObject3;
                jSONObject2 = jSONObject4;
            } else {
                i10 = -1;
                z11 = false;
                jSONObject = null;
                jSONObject2 = null;
            }
            long j10 = this.hlt;
            long j11 = this.hi;
            WeakReference<View> weakReference = this.f7152ef;
            duv duvVarFm = fm(f10, f11, f12, f13, sparseArray, j10, j11, weakReference == null ? null : weakReference.get(), jnr(), zan.wu(this.yz), zan.vt(this.yz), zan.ef(this.yz), i10, jSONObject, jSONObject2);
            this.vt = duvVarFm;
            if (fm(duvVarFm, this.irt)) {
                return;
            }
            if (this.dsz != null) {
                if (this.irt == null) {
                    this.irt = new HashMap();
                }
                this.irt.put("duration", Long.valueOf(this.dsz.ajl()));
            }
            lse lseVar = this.ajl;
            if (!this.f7153lb && !z11) {
                fm fmVar = this.ku;
                if (fmVar != null) {
                    fmVar.fm(view, -1);
                }
                if (fm(view, z10)) {
                    boolean zRo = ai.ro(lseVar);
                    String strFm = zRo ? this.wsy : bx.fm(this.wu);
                    if (view != null) {
                        try {
                            if (Boolean.TRUE.equals(view.getTag(520093762))) {
                                xgn.fm(true);
                            }
                        } catch (Exception unused) {
                        }
                    }
                    Activity activityFm = view != null ? com.bytedance.sdk.component.utils.ro.fm(view) : null;
                    boolean zFm = xgn.fm(activityFm == null ? this.yz : activityFm, lseVar, this.wu, this.duv, this.qhl, strFm, this.fhx, zRo, 0);
                    xgn.fm(false);
                    if (zFm || lseVar == null || lseVar.ya() == null || lseVar.ya().lb() != 2) {
                        if (lseVar != null && !zFm && TextUtils.isEmpty(lseVar.rbn()) && com.bytedance.sdk.openadsdk.yz.ro.fm(this.wsy)) {
                            com.bytedance.sdk.openadsdk.sds.fm.fm.yz.fm(this.yz, this.wsy).fm(lseVar);
                        }
                        com.bytedance.sdk.openadsdk.yz.lb.fm("click", lseVar, this.vt, this.wsy, zFm, this.irt, z10 ? 1 : 2);
                        return;
                    }
                    return;
                }
                return;
            }
            com.bytedance.sdk.openadsdk.yz.lb.fm("click", lseVar, this.vt, this.wsy, true, this.irt, z10 ? 1 : 2);
            com.bytedance.sdk.openadsdk.core.model.yz yzVarKl = lseVar.kl();
            if (yzVarKl == null || lseVar.zn() || (yzVarFm = yzVarKl.fm()) == null) {
                return;
            }
            f fVar = this.dsz;
            yzVarFm.wsy(fVar != null ? fVar.ajl() : 0L);
        }
    }

    public boolean fm(View view, boolean z10) {
        return fm(view, this.ajl, z10);
    }

    public static boolean fm(View view, lse lseVar, boolean z10) {
        if (view != null && lseVar != null) {
            try {
                int i10 = com.bytedance.sdk.component.adexpress.dynamic.fm.wey;
                String strValueOf = String.valueOf(view.getTag(i10));
                if (view.getTag(i10) != null && !TextUtils.isEmpty(strValueOf)) {
                    if ("click".equals(strValueOf)) {
                        return z10;
                    }
                    return true;
                }
            } catch (Exception unused) {
            }
            if (lb(view)) {
                return lseVar.rka() != 1 || z10;
            }
            if (lseVar.aws() == 1 && !z10) {
                return false;
            }
        }
        return true;
    }

    public duv fm(float f10, float f11, float f12, float f13, SparseArray<lb.fm> sparseArray, long j10, long j11, View view, String str, float f14, int i10, float f15, int i11, JSONObject jSONObject, JSONObject jSONObject2) {
        return new duv.fm().ajl(f10).jnr(f11).yz(f12).lb(f13).ro(j10).fm(j11).fm(zan.fm(view)).ro(zan.lb(view)).yz(this.nt).jnr(this.mq).ajl(this.gzf).fm(sparseArray).ro(vt.ro().fm() ? 1 : 2).fm(str).fm(f14).lb(i10).ro(f15).fm(i11).fm(jSONObject).ro(jSONObject2).fm();
    }

    public boolean fm(View view, int i10, float f10, float f11, float f12, float f13, SparseArray<lb.fm> sparseArray, boolean z10) {
        if (this.gof == null) {
            return false;
        }
        this.gof.fm(view, i10, new irt.fm().yz(f10).lb(f11).ro(f12).fm(f13).ro(this.hlt).fm(this.hi).fm(sparseArray).fm(z10).fm());
        return true;
    }

    private static int fm(Context context) {
        if (pkk == Integer.MIN_VALUE) {
            pkk = maa.jnr(context, "btn_native_creative");
        }
        return pkk;
    }
}
