package com.bytedance.sdk.openadsdk.activity.single;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.media3.exoplayer.upstream.CmcdData;
import com.bytedance.sdk.openadsdk.component.reward.duv;
import com.bytedance.sdk.openadsdk.component.reward.fm.duv;
import com.bytedance.sdk.openadsdk.component.reward.gof;
import com.bytedance.sdk.openadsdk.component.reward.qhl;
import com.bytedance.sdk.openadsdk.core.model.ai;
import com.bytedance.sdk.openadsdk.core.model.hlt;
import com.bytedance.sdk.openadsdk.core.model.lse;
import com.bytedance.sdk.openadsdk.core.model.wey;
import com.bytedance.sdk.openadsdk.dsz.vt;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import org.json.JSONObject;

/* JADX INFO: loaded from: classes2.dex */
public class ro {

    /* JADX INFO: renamed from: lb, reason: collision with root package name */
    private static com.bytedance.sdk.openadsdk.fm.lb.ro f6788lb;
    private static com.bytedance.sdk.openadsdk.fm.jnr.fm ro;
    private final vt ajl;
    private Activity dsz;
    private final boolean duv;

    /* JADX INFO: renamed from: ef, reason: collision with root package name */
    private final boolean f6789ef;
    private Bundle fhx;
    public duv fm;
    private boolean gof;
    private boolean gqi;
    private Runnable irt;
    private com.bytedance.sdk.openadsdk.activity.single.lb ku;
    private int onz;
    private final boolean vt;
    private final boolean wey;
    private com.bytedance.sdk.openadsdk.fm.jnr.fm wsy;
    private com.bytedance.sdk.openadsdk.fm.lb.ro wu;
    private final lse yz;
    private final Bundle jnr = new Bundle();
    private final duv.ro qhl = new duv.ro();
    private final boolean sds = com.bytedance.sdk.openadsdk.hlt.jnr.ku();

    public static class fm extends AbstractC0048ro {
        public fm(ro roVar, lse lseVar, com.bytedance.sdk.openadsdk.component.reward.top.lb lbVar) {
            super(roVar, lseVar, lbVar);
        }

        @Override // com.bytedance.sdk.openadsdk.activity.single.ro.AbstractC0048ro
        public int fm(lse lseVar) {
            if (lseVar != null) {
                return lseVar.vg();
            }
            return 5;
        }
    }

    public static class jnr {
        public final Bundle fm = new Bundle();
        public boolean jnr;

        /* JADX INFO: renamed from: lb, reason: collision with root package name */
        public final com.bytedance.sdk.openadsdk.component.reward.fm.ro f6792lb;
        public final int ro;
        public boolean yz;

        public jnr(int i10, com.bytedance.sdk.openadsdk.component.reward.fm.ro roVar) {
            this.ro = i10;
            this.f6792lb = roVar;
        }

        public String toString() {
            return super.toString();
        }
    }

    public static class lb implements Runnable {
        private final lse fm;

        public lb(lse lseVar) {
            this.fm = lseVar;
        }

        @Override // java.lang.Runnable
        public void run() {
            if (this.fm.emt() || lse.ajl(this.fm)) {
                return;
            }
            if (this.fm.ii()) {
                if (com.bytedance.sdk.openadsdk.utils.ro.lb()) {
                    gof.fm(com.bytedance.sdk.openadsdk.core.gof.fm()).fm(this.fm.cpu());
                    return;
                } else {
                    qhl.fm(com.bytedance.sdk.openadsdk.core.gof.fm()).fm(this.fm.cpu());
                    return;
                }
            }
            if (com.bytedance.sdk.openadsdk.utils.ro.lb()) {
                com.bytedance.sdk.openadsdk.component.reward.wsy.fm(com.bytedance.sdk.openadsdk.core.gof.fm()).fm(this.fm.cpu());
            } else {
                com.bytedance.sdk.openadsdk.component.reward.ajl.fm(com.bytedance.sdk.openadsdk.core.gof.fm()).fm(this.fm.cpu());
            }
        }
    }

    /* JADX INFO: renamed from: com.bytedance.sdk.openadsdk.activity.single.ro$ro, reason: collision with other inner class name */
    public static abstract class AbstractC0048ro implements Handler.Callback {
        private boolean ai;
        protected int ajl;
        private int bx;
        private final Context duv;
        private boolean fhx;
        protected final ro fm;

        /* JADX INFO: renamed from: gc, reason: collision with root package name */
        private boolean f6794gc;
        private float gof;
        private int gzf;

        /* JADX INFO: renamed from: ha, reason: collision with root package name */
        private int f6795ha;
        private int hi;
        private int hlt;
        private int hxv;
        private boolean irt;
        protected int jnr;
        private final com.bytedance.sdk.openadsdk.component.reward.top.lb ku;

        /* JADX INFO: renamed from: lb, reason: collision with root package name */
        protected float f6796lb;
        private int lse;
        private boolean lz;
        private int maa;
        private boolean mon;
        private boolean mq;
        private boolean nt;
        private int ol;
        private boolean onz;
        private int pkk;

        /* JADX INFO: renamed from: qf, reason: collision with root package name */
        private boolean f6797qf;
        private boolean qhl;
        protected lse ro;
        private int sds;
        private boolean si;
        private int tzk;
        private int wey;
        private boolean xgn;
        protected int yz;
        private int zan;
        private final Handler vt = new Handler(Looper.getMainLooper(), this);
        private final int dsz = 1000;
        protected int wsy = -1;
        private int gqi = 1000;
        private boolean wbw = false;
        boolean wu = false;

        /* JADX INFO: renamed from: ef, reason: collision with root package name */
        public int f6793ef = -1;

        public AbstractC0048ro(ro roVar, lse lseVar, com.bytedance.sdk.openadsdk.component.reward.top.lb lbVar) {
            this.fm = roVar;
            this.ro = lseVar;
            this.ku = lbVar;
            this.duv = lbVar.getContext();
            this.yz = fm(lseVar);
        }

        private void dsz() {
            int i10 = this.pkk;
            int i11 = this.bx;
            boolean z10 = this.f6797qf;
            int i12 = this.tzk;
            int i13 = this.zan;
            if (i10 < i11 || z10) {
                return;
            }
            if (i12 >= i13) {
                this.lz = false;
            } else {
                this.tzk = i12 + 1;
                onz();
            }
        }

        private void duv() {
            com.bytedance.sdk.openadsdk.component.reward.top.lb lbVar;
            if (this.ai || this.fhx || this.irt || (lbVar = this.ku) == null) {
                return;
            }
            lbVar.setShowEndCardNextAd(true, this.ro);
        }

        private void jnr(int i10) {
            if (this.si && i10 == 4) {
                this.ajl = i10;
                fm(i10, 1000);
            }
        }

        private void ku() {
            if (this.fm.wey()) {
                this.ku.showSkipButton();
                this.fhx = true;
            } else {
                this.irt = true;
                this.ku.showCloseButton();
            }
            this.ku.setShowPlayableNextAd(false, this.ro);
        }

        private void onz() {
            wu wuVarKu;
            this.f6797qf = true;
            this.pkk = 0;
            ro roVar = this.fm;
            if (roVar == null || (wuVarKu = roVar.ku()) == null || wuVarKu.bwv()) {
                return;
            }
            duv();
        }

        private void vt() {
            int i10 = this.wsy;
            if (i10 > 0) {
                this.wsy = i10 - 1;
            }
            if (this.wsy == 0 && this.qhl) {
                this.qhl = false;
                ro roVar = this.fm;
                if (roVar == null || roVar.ku() == null) {
                    return;
                }
                wu wuVarKu = this.fm.ku();
                if (wuVarKu instanceof com.bytedance.sdk.openadsdk.activity.single.jnr) {
                    ((com.bytedance.sdk.openadsdk.activity.single.jnr) wuVarKu).sds();
                }
            }
        }

        private void yz(int i10) {
            if (this.wsy > 0 && this.qhl && i10 == 3) {
                this.ajl = i10;
                fm(i10, 1000);
            }
        }

        public void ajl() {
            this.mq = true;
        }

        public void ef() {
            if (this.lz) {
                this.f6797qf = true;
            }
        }

        public int fm() {
            return this.yz;
        }

        public abstract int fm(lse lseVar);

        @Override // android.os.Handler.Callback
        public boolean handleMessage(@NonNull Message message) {
            int i10 = message.what;
            if (i10 == 1 || i10 == 2) {
                fm(message);
            } else if (i10 == 3) {
                if (this.wsy > 0) {
                    vt();
                    if (this.wsy >= 0) {
                        fm(message.what, 1000);
                    }
                }
            } else if (i10 == 4) {
                if (this.si) {
                    jnr();
                    if (this.si && !this.ai) {
                        fm(message.what, 1000);
                    }
                }
            } else if (i10 == 5 && this.lz) {
                wsy();
                if (this.lz && !this.ai) {
                    fm(message.what, 1000);
                }
            }
            return true;
        }

        public void lb() {
            this.vt.removeMessages(this.ajl);
        }

        public void ro(boolean z10) {
            if (z10) {
                this.gqi = (int) (1000.0f / this.gof);
            } else {
                this.gqi = 1000;
            }
        }

        public void wsy() {
            if (this.mq && this.lz && !this.ai) {
                int i10 = this.f6795ha;
                int i11 = this.pkk;
                boolean z10 = this.nt;
                int i12 = i10 + 1;
                this.f6795ha = i12;
                this.pkk = i11 + 1;
                if (z10 && i12 >= this.hxv) {
                    duv();
                }
                if (this.xgn || this.f6794gc) {
                    dsz();
                }
            }
        }

        public void wu() {
            if (this.lz) {
                duv();
                this.f6797qf = false;
            }
        }

        public void fm(boolean z10) {
            this.nt = z10;
            this.pkk = 0;
            if (z10) {
                int i10 = this.lse;
                int i11 = this.sds;
                this.wey = i10 - i11;
                this.hi = i11;
                this.hlt = i10;
            }
        }

        public void jnr() {
            if (this.mq && this.si) {
                if (this.irt) {
                    this.si = false;
                }
                if (this.ai) {
                    return;
                }
                int i10 = this.gzf;
                boolean z10 = this.nt;
                int i11 = i10 + 1;
                this.gzf = i11;
                if (z10) {
                    this.hlt = this.lse;
                } else {
                    this.hlt = this.wey + this.sds;
                }
                if (i11 >= this.wey) {
                    if (!this.wu) {
                        this.ol++;
                        this.wu = true;
                        try {
                            JSONObject jSONObject = new JSONObject();
                            jSONObject.put("click_countdown_remaining", this.yz);
                            jSONObject.put("hint_sequence", this.ol);
                            com.bytedance.sdk.openadsdk.yz.lb.yz(this.ro, this.fm.ku().d_(), jSONObject);
                        } catch (Throwable unused) {
                        }
                    }
                    com.bytedance.sdk.openadsdk.activity.single.lb lbVar = this.fm.ku;
                    int i12 = this.hi;
                    this.hi = i12 - 1;
                    lbVar.fm(i12, this.yz);
                } else {
                    this.wu = false;
                    this.fm.ku.fm(-1, this.yz);
                }
                if (this.nt && this.gzf >= this.maa) {
                    boolean z11 = this.fhx;
                    boolean z12 = this.irt;
                    if (!z11 && !z12) {
                        this.ku.setShowPlayableNextAd(true, this.ro);
                    }
                }
                if (this.gzf < this.hlt || this.fm.ku() == null) {
                    return;
                }
                wu wuVarKu = this.fm.ku();
                if (wuVarKu instanceof com.bytedance.sdk.openadsdk.activity.single.jnr) {
                    this.vt.removeMessages(4);
                    ((com.bytedance.sdk.openadsdk.activity.single.jnr) wuVarKu).sds();
                }
            }
        }

        public void lb(int i10) {
            this.wsy = i10;
            if (i10 > 0) {
                this.qhl = true;
                if (this.yz <= 0 || this.fhx) {
                    yz(3);
                }
            }
        }

        public void ro() {
            this.si = false;
            this.lz = false;
            this.wu = false;
            this.ol = 0;
            this.f6793ef = -1;
            this.f6797qf = false;
            this.zan = 0;
            this.pkk = 0;
            this.f6795ha = 0;
            this.nt = false;
            this.tzk = 0;
            this.wbw = false;
            com.bytedance.sdk.openadsdk.component.reward.top.lb lbVar = this.ku;
            if (lbVar != null) {
                lbVar.setShowPlayableNextAd(false, this.ro);
            }
        }

        public void yz() {
            if (this.fhx || this.irt) {
                return;
            }
            fm(-1);
            this.wbw = true;
            com.bytedance.sdk.openadsdk.component.reward.top.lb lbVar = this.ku;
            if (lbVar != null) {
                lbVar.setCountDownFor1InN("", -1);
                this.ku.setShowEndCardNextAd(true, this.ro);
            }
        }

        public void fm(int i10) {
            int i11 = this.ajl;
            if (i10 != -1) {
                this.f6793ef = i10;
            }
            this.vt.removeMessages(i11);
        }

        public void ro(int i10) {
            if (this.f6793ef != 2 || i10 == 1) {
                if (i10 != -1) {
                    this.f6793ef = i10;
                }
                if (this.vt.hasMessages(this.ajl) || this.wbw) {
                    return;
                }
                ro roVar = this.fm;
                if (roVar == null || roVar.ku() == null || this.fm.ku().hlt() == null || !this.fm.ku().hlt().vt.get()) {
                    int i11 = this.yz;
                    boolean z10 = this.fhx;
                    int i12 = this.ajl;
                    if (i12 == 1 || i12 == 2) {
                        if (i11 < 0 || z10 || this.irt) {
                            return;
                        }
                        this.vt.sendEmptyMessageDelayed(i12, this.gqi);
                        return;
                    }
                    if (i12 == 3) {
                        yz(3);
                    } else if (i12 == 4) {
                        jnr(4);
                    } else if (i12 == 5) {
                        fm(5, true);
                    }
                }
            }
        }

        private void fm(@NonNull Message message) {
            int i10 = this.yz;
            if (i10 > 0) {
                int i11 = this.jnr;
                int i12 = (int) ((((double) (i11 - i10)) * 100.0d) / ((double) i11));
                com.bytedance.sdk.openadsdk.component.reward.top.lb lbVar = this.ku;
                StringBuilder sb = new StringBuilder();
                int i13 = this.yz;
                this.yz = i13 - 1;
                sb.append(i13);
                sb.append(CmcdData.STREAMING_FORMAT_SS);
                lbVar.setCountDownFor1InN(sb.toString(), i12);
                vt();
                jnr();
                if (this.yz >= 0) {
                    fm(message.what, this.gqi);
                }
                wsy();
                return;
            }
            yz(3);
            jnr(4);
            fm(5, true);
            ku();
        }

        private void fm(int i10, int i11) {
            if (this.wbw) {
                return;
            }
            this.vt.removeMessages(i10);
            this.vt.sendEmptyMessageDelayed(i10, i11);
        }

        private void fm(int i10, boolean z10) {
            if (this.lz && i10 == 5) {
                this.ajl = i10;
                if (z10) {
                    fm(i10, 1000);
                } else {
                    this.vt.sendEmptyMessage(i10);
                }
            }
        }

        public void fm(lse lseVar, boolean z10) {
            this.wey = ai.sds(lseVar);
            this.sds = ai.hi(lseVar);
            this.maa = ai.nt(lseVar);
            this.lse = ai.mq(lseVar);
            this.hi = this.sds;
            this.mq = false;
            this.nt = false;
            this.gzf = 0;
            this.si = true;
            com.bytedance.sdk.openadsdk.component.reward.top.lb lbVar = this.ku;
            if (lbVar != null) {
                lbVar.setShowPlayableNextAd(false, lseVar);
            }
            this.ai = z10;
            if (this.yz <= 0 || this.fhx) {
                jnr(4);
            }
        }

        public void fm(int i10, lse lseVar) {
            if (lseVar != null && lseVar.cap() != null) {
                this.gof = lseVar.cap().fm();
                this.ro = lseVar;
            }
            int i11 = this.yz;
            boolean z10 = this.fhx;
            boolean z11 = this.irt;
            int i12 = this.ajl;
            if (z10 || z11) {
                return;
            }
            float f10 = i10;
            this.f6796lb = f10;
            if (f10 <= i11) {
                this.ajl = 2;
                this.yz = (int) f10;
            } else if (i12 == 0) {
                this.ajl = 1;
            }
            if (!this.onz) {
                this.jnr = this.yz;
                this.onz = true;
            }
            int i13 = this.ajl;
            if (i12 == i13 && this.vt.hasMessages(i13)) {
                return;
            }
            this.vt.removeCallbacksAndMessages(null);
            this.vt.sendEmptyMessage(this.ajl);
        }

        public void fm(wu wuVar) {
            lse lseVar;
            hlt hltVarFm;
            if (wuVar == null || (lseVar = wuVar.ajl) == null || (hltVarFm = lseVar.fm()) == null) {
                return;
            }
            this.hxv = hltVarFm.lb();
            this.ai = wuVar.qhl;
            this.zan = hltVarFm.fm();
            this.mon = wuVar.irt;
            this.bx = hltVarFm.ro();
            this.f6794gc = wey.wsy(wuVar.ajl);
            this.xgn = wey.ajl(wuVar.ajl);
            this.lz = true;
            if ((this.yz <= 0 || this.fhx) && !this.vt.hasMessages(5)) {
                fm(5, false);
            }
        }
    }

    public static class yz extends AbstractC0048ro {
        private boolean duv;
        private int ku;
        private final int vt;

        public yz(ro roVar, lse lseVar, com.bytedance.sdk.openadsdk.component.reward.top.lb lbVar) {
            super(roVar, lseVar, lbVar);
            if (lseVar == null) {
                this.vt = 100;
            } else if (lseVar.lcp() >= 0) {
                this.vt = Math.min(100, lseVar.lcp());
            } else {
                this.vt = com.bytedance.sdk.openadsdk.core.gof.yz().mq(String.valueOf(lseVar.pg())).ajl;
            }
        }

        @Override // com.bytedance.sdk.openadsdk.activity.single.ro.AbstractC0048ro
        public int fm(lse lseVar) {
            if (lseVar != null) {
                return lseVar.uuv();
            }
            return 30;
        }

        @Override // com.bytedance.sdk.openadsdk.activity.single.ro.AbstractC0048ro, android.os.Handler.Callback
        public boolean handleMessage(@NonNull Message message) {
            if (!this.duv && this.yz <= this.ku) {
                this.duv = true;
                wu wuVarKu = this.fm.ku();
                if (wuVarKu != null) {
                    wuVarKu.kwx();
                }
            }
            super.handleMessage(message);
            return true;
        }

        @Override // com.bytedance.sdk.openadsdk.activity.single.ro.AbstractC0048ro
        public void fm(int i10, lse lseVar) {
            boolean z10 = this.ajl == 0;
            int i11 = this.yz;
            super.fm(i10, lseVar);
            if (!z10) {
                if (this.f6796lb < i11) {
                    this.ku = (int) ((1.0f - (this.vt / 100.0f)) * this.yz);
                    return;
                }
                return;
            }
            if (this.ajl == 1) {
                this.ku = 3;
            } else {
                this.ku = (int) ((1.0f - (this.vt / 100.0f)) * this.f6796lb);
            }
            com.bytedance.sdk.openadsdk.component.reward.duv duvVar = this.fm.fm;
            if (duvVar != null) {
                duvVar.fm(this.yz);
            }
        }
    }

    public ro(Activity activity, lse lseVar, boolean z10) {
        this.yz = lseVar;
        this.gqi = z10;
        this.dsz = activity;
        this.ajl = new vt(activity.getApplicationContext());
        boolean zQf = lseVar.qf();
        this.f6789ef = zQf;
        this.vt = zQf && 39 == lseVar.ywr();
        this.duv = zQf && 40 == lseVar.ywr();
        int iYwr = lseVar.ywr();
        if (iYwr == 43 || iYwr == 44) {
            this.ku = new com.bytedance.sdk.openadsdk.activity.single.yz(this.dsz, lseVar, this);
        } else {
            this.ku = new ef(this.dsz, lseVar, this);
        }
        this.wey = com.bytedance.sdk.openadsdk.hlt.jnr.fm("adapt_decor_size", 0) == 1;
        this.ku.fm();
        pkk();
    }

    private void pkk() {
        if (this.yz.ii()) {
            this.fm = new com.bytedance.sdk.openadsdk.component.reward.duv(new duv.fm() { // from class: com.bytedance.sdk.openadsdk.activity.single.ro.1
                @Override // com.bytedance.sdk.openadsdk.component.reward.duv.fm
                public void fm(int i10, boolean z10) {
                    wu wuVarKu;
                    if (ro.this.duv().getBoolean("reward_verify", false) || ro.this.qhl()) {
                        return;
                    }
                    if ((z10 || !ro.this.dsz()) && (wuVarKu = ro.this.ku()) != null) {
                        wuVarKu.lb(i10);
                    }
                }
            });
        }
    }

    public void ai() {
        this.ku.qhl();
    }

    public boolean ajl() {
        return this.f6789ef;
    }

    public boolean dsz() {
        return this.yz.irt();
    }

    public Bundle duv() {
        return this.jnr;
    }

    public void ef() {
        this.ku.ef();
    }

    public void fhx() {
        com.bytedance.sdk.openadsdk.fm.jnr.fm fmVar = this.wsy;
        if (fmVar != null) {
            fmVar.ro();
            return;
        }
        com.bytedance.sdk.openadsdk.fm.lb.ro roVar = this.wu;
        if (roVar != null) {
            roVar.ro();
        } else {
            wu wuVarKu = ku();
            com.bytedance.sdk.openadsdk.yz.vt.fm(this.yz, "close", wuVarKu != null ? wuVarKu.bx() : 0);
        }
    }

    public lse fm() {
        return this.yz;
    }

    public void gof() {
        lse lseVar = this.yz;
        if (lseVar != null) {
            lseVar.ef(true);
        }
        com.bytedance.sdk.openadsdk.component.reward.duv duvVar = this.fm;
        if (duvVar != null) {
            duvVar.lb();
        }
    }

    public boolean gqi() {
        return this.yz.bx();
    }

    public List<lse> gzf() {
        return this.ku.fhx();
    }

    public int ha() {
        return this.ku.wu();
    }

    public wu hi() {
        return this.ku.dsz();
    }

    public com.bytedance.sdk.openadsdk.component.reward.top.lb hlt() {
        return this.ku.duv();
    }

    public void irt() {
        if (gqi()) {
            return;
        }
        sds();
        Objects.toString(this.wsy);
        Objects.toString(this.wu);
        com.bytedance.sdk.openadsdk.fm.jnr.fm fmVar = this.wsy;
        if (fmVar != null) {
            fmVar.fm();
        } else {
            com.bytedance.sdk.openadsdk.fm.lb.ro roVar = this.wu;
            if (roVar != null) {
                roVar.fm();
            } else {
                wu wuVarKu = ku();
                com.bytedance.sdk.openadsdk.yz.vt.fm(this.yz, "show", wuVarKu != null ? wuVarKu.bx() : 0);
            }
        }
        Runnable runnable = this.irt;
        if (runnable != null) {
            runnable.run();
            this.irt = null;
        }
    }

    public boolean jnr() {
        if (this.yz != null && this.f6789ef) {
            return this.vt || this.duv;
        }
        return false;
    }

    public wu ku() {
        return this.ku.ku();
    }

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

    public boolean lse() {
        return this.ku.jnr();
    }

    public vt maa() {
        return this.ajl;
    }

    public boolean mq() {
        return this.gof;
    }

    public boolean nt() {
        return this.ku instanceof com.bytedance.sdk.openadsdk.activity.single.yz;
    }

    public void ol() {
        this.ku.gof();
    }

    public void onz() {
        com.bytedance.sdk.openadsdk.fm.jnr.fm fmVar = this.wsy;
        if (fmVar != null) {
            fmVar.onAdClicked();
            return;
        }
        com.bytedance.sdk.openadsdk.fm.lb.ro roVar = this.wu;
        if (roVar != null) {
            roVar.onAdClicked();
        }
    }

    public boolean qhl() {
        lse lseVar = this.yz;
        return lseVar != null && lseVar.zan();
    }

    public boolean ro() {
        return this.wey;
    }

    public void sds() {
        this.yz.wu(true);
        this.ku.irt();
    }

    public int vt() {
        return this.ku.vt();
    }

    public void wbw() {
        this.ku.gqi();
    }

    public boolean wey() {
        return this.ku.yz();
    }

    public void wsy() {
        Activity activity = this.dsz;
        if (activity != null) {
            activity.finish();
        }
    }

    public Activity wu() {
        com.bytedance.sdk.openadsdk.activity.single.lb lbVar = this.ku;
        return lbVar == null ? this.dsz : lbVar.fm;
    }

    public boolean yz() {
        return this.duv;
    }

    public void jnr(TTAdActivity tTAdActivity) {
        this.onz = 6;
        this.ku.fm(tTAdActivity);
        this.qhl.fm(tTAdActivity);
        this.dsz = null;
    }

    public boolean lb() {
        return this.sds;
    }

    public void yz(TTAdActivity tTAdActivity) {
        this.onz = 5;
        this.ku.wsy();
    }

    public boolean fm(lse lseVar) {
        return (lseVar == null || wey.onz(lseVar) || lseVar.wzb() || lseVar.jd() == null || lseVar.jd().yz() <= 0) ? false : true;
    }

    public void lb(TTAdActivity tTAdActivity) {
        this.onz = 4;
        this.ku.lb();
        com.bytedance.sdk.openadsdk.component.reward.duv duvVar = this.fm;
        if (duvVar != null) {
            duvVar.fm();
        }
    }

    public void ro(TTAdActivity tTAdActivity) {
        this.onz = 3;
        this.ku.ro();
        com.bytedance.sdk.openadsdk.component.reward.duv duvVar = this.fm;
        if (duvVar != null) {
            duvVar.ro();
        }
        this.qhl.fm(tTAdActivity, this.yz.nnq(), this.yz.lvj(), this.wey);
    }

    public void fm(TTAdActivity tTAdActivity, Bundle bundle, com.bytedance.sdk.openadsdk.fm.jnr.fm fmVar, com.bytedance.sdk.openadsdk.fm.lb.ro roVar) {
        this.fhx = bundle;
        this.onz = 1;
        this.wsy = fmVar;
        this.wu = roVar;
        if (!this.gqi && bundle != null) {
            if (fmVar == null) {
                this.wsy = ro;
                ro = null;
            }
            if (roVar == null) {
                this.wu = f6788lb;
                f6788lb = null;
            }
        }
        this.ku.fm(bundle);
    }

    public void ro(boolean z10) {
        try {
            lse lseVar = this.yz;
            if (lseVar != null) {
                lseVar.lb(z10);
            }
            com.bytedance.sdk.openadsdk.component.reward.duv.fm(this.yz, false, 3);
        } catch (Throwable unused) {
        }
    }

    public void fm(TTAdActivity tTAdActivity) {
        this.onz = 2;
        this.ku.ajl();
    }

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

    public void ro(wu wuVar) {
        wuVar.fm(this.dsz, this.fhx);
        int i10 = this.onz;
        if (i10 == 2) {
            wuVar.dsz();
            return;
        }
        if (i10 == 3) {
            wuVar.dsz();
            wuVar.lb();
            wuVar.lb(true);
        } else if (i10 == 4) {
            wuVar.lb(false);
            wuVar.onz();
        } else {
            if (i10 != 5) {
                return;
            }
            wuVar.yz();
        }
    }

    public void fm(TTAdActivity tTAdActivity, Bundle bundle, int i10) {
        com.bytedance.sdk.openadsdk.component.reward.fm.lb.fm(this.yz, tTAdActivity != null ? tTAdActivity.getIntent() : null, bundle, i10);
        if (this.gqi) {
            return;
        }
        com.bytedance.sdk.openadsdk.fm.jnr.fm fmVar = this.wsy;
        if (fmVar != null) {
            ro = fmVar;
            return;
        }
        com.bytedance.sdk.openadsdk.fm.lb.ro roVar = this.wu;
        if (roVar != null) {
            f6788lb = roVar;
        }
    }

    public void fm(wu wuVar, jnr jnrVar) {
        this.ku.fm(wuVar, null, jnrVar);
    }

    public void fm(Activity activity) {
        this.ku.ro(activity);
    }

    public void fm(final wu wuVar, final boolean z10, final int i10, final String str, final int i11, final String str2, final int i12) {
        Activity activity;
        if (!gqi()) {
            this.irt = new Runnable() { // from class: com.bytedance.sdk.openadsdk.activity.single.ro.2
                @Override // java.lang.Runnable
                public void run() {
                    ro.this.fm(wuVar, z10, i10, str, i11, str2, i12);
                }
            };
            return;
        }
        if (qhl()) {
            return;
        }
        gof();
        if (this.wsy != null && (activity = this.dsz) != null) {
            activity.runOnUiThread(new Runnable() { // from class: com.bytedance.sdk.openadsdk.activity.single.ro.3
                @Override // java.lang.Runnable
                public void run() {
                    ro.this.wsy.fm(z10, i10, str, i11, str2);
                }
            });
            com.bytedance.sdk.openadsdk.component.reward.duv.fm(this.yz, z10, i12);
        } else {
            com.bytedance.sdk.openadsdk.component.reward.duv.fm(this.yz, false, i12);
        }
    }

    public void ro(wu wuVar, jnr jnrVar) {
        this.ku.fm(wuVar, jnrVar);
    }

    public void ro(wu wuVar, int i10) {
        this.ku.ro(wuVar, i10);
    }

    public void fm(com.bytedance.sdk.openadsdk.activity.single.fm fmVar, boolean z10) {
        this.ku.fm(fmVar, z10);
    }

    public void fm(wu wuVar) {
        com.bytedance.sdk.openadsdk.activity.single.lb lbVar = this.ku;
        if (lbVar == null) {
            return;
        }
        lbVar.fm(wuVar);
    }

    public void fm(wu wuVar, boolean z10) {
        com.bytedance.sdk.openadsdk.activity.single.lb lbVar = this.ku;
        if (lbVar == null) {
            return;
        }
        lbVar.fm(wuVar, z10);
    }

    public void fm(View view) {
        this.ku.fm(view);
    }

    public void fm(View view, boolean z10) {
        this.ku.fm(view, z10);
    }

    public boolean fm(wu wuVar, int i10) {
        return this.ku.fm(wuVar, i10);
    }

    public void fm(float f10) {
        this.ku.fm(f10);
    }

    public void fm(Map<String, Object> map, wu wuVar, float f10, float f11) {
        this.ku.fm(map, wuVar, f10, f11);
    }

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

    public void fm(wu wuVar, boolean z10, boolean z11, boolean z12, int i10) {
        this.ku.fm(wuVar, z10, z11, z12, i10);
    }
}
