package com.bytedance.android.livesdk.interaction;

import X.0Zm;
import X.0Zp;
import X.0Zr;
import X.0cm;
import X.12L;
import X.1Lu;
import X.1jk;
import X.2DB;
import X.2DC;
import X.2Pr;
import X.2fU;
import X.C1044Fun;
import X.C1064Fv7;
import X.C1157Fwc;
import X.C1265FyM;
import X.C1430G2l;
import X.C1450G3f;
import X.C1471G4a;
import X.C1480G4j;
import X.C1485G4o;
import X.C2182GVj;
import X.C2194GVv;
import X.C3491GtA;
import X.G3D;
import X.G4F;
import X.G4G;
import X.G4H;
import X.G4I;
import X.G4T;
import X.G4X;
import X.G5Q;
import X.GT2;
import X.GT5;
import X.Ls2;
import X.LsC;
import X.M12;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.View;
import com.bytedance.android.live.design.app.LiveDialog;
import com.bytedance.android.live.effect.api.IEffectService;
import com.bytedance.android.livesdk.LiveDialogFragment;
import com.bytedance.android.livesdk.livesetting.broadcast.QAQuickEntranceSetting;
import com.bytedance.android.livesdk.livesetting.roomfunction.LivePollSetting;
import com.bytedance.android.livesdk.model.RoomAuthStatus;
import com.bytedance.android.livesdkapi.depend.model.live.Room;
import com.bytedance.covode.number.Covode;
import com.bytedance.ies.sdk.datachannel.DataChannel;
import java.util.HashMap;
import kotlin.h.b.n;

public final class InteractionFeaturesDialog extends LiveDialogFragment implements C1471G4a {
    public static final G4H LIZ = new G4H((byte) 0);
    public final C2194GVv LIZIZ = new C2194GVv(this);
    public HashMap LIZJ;

    static {
        Covode.recordClassIndex(16983);
    }

    public final View LIZ(int i) {
        if (this.LIZJ == null) {
            this.LIZJ = new HashMap();
        }
        View view = (View) this.LIZJ.get(Integer.valueOf(i));
        if (view != null) {
            return view;
        }
        View view2 = getView();
        if (view2 == null) {
            return null;
        }
        View findViewById = view2.findViewById(i);
        this.LIZJ.put(Integer.valueOf(i), findViewById);
        return findViewById;
    }

    public final /* synthetic */ void onDestroyView() {
        super.onDestroyView();
        z_();
    }

    public final void z_() {
        HashMap hashMap = this.LIZJ;
        if (hashMap != null) {
            hashMap.clear();
        }
    }

    public final void LIZLLL() {
        C1485G4o.LJ.LIZ(1, new C1480G4j(this));
    }

    private final void LJIIJJI() {
        C3491GtA LIZ2 = C3491GtA.LJFF.LIZ("livesdk_anchor_qa_quick_mode_entrance_show");
        LIZ2.LIZ(this.LJIILIIL);
        LIZ2.LIZ("enter_from", "interaction_panel");
        LIZ2.LIZLLL();
    }

    public final void LJ() {
        View LIZ2 = LIZ(2131368643);
        n.LIZIZ(LIZ2, "");
        C1430G2l.LIZ(LIZ2.findViewById(2131363865));
        G4X.LJI.LIZIZ(this);
    }

    public final void onDestroy() {
        Room room;
        DataChannel dataChannel = this.LJIILIIL;
        if (!(dataChannel == null || (room = (Room) dataChannel.LIZIZ(C1064Fv7.class)) == null)) {
            C2182GVj.LJIIJJI.LIZIZ(room.getId(), (0Zm) this.LIZIZ);
        }
        InteractionFeaturesDialog.super.onDestroy();
    }

    public final C1044Fun LIZ() {
        C1044Fun fun = new C1044Fun(2131561616);
        fun.LIZIZ = 2131887240;
        fun.LIZ(new ColorDrawable(0));
        fun.LJI = 80;
        fun.LJFF = 0.0f;
        fun.LJIIIIZZ = -2;
        return fun;
    }

    private final void LJFF() {
        if (G5Q.LIZJ(this.LJIILIIL) || !QAQuickEntranceSetting.INSTANCE.enable() || !G5Q.LJIIIIZZ(this.LJIILIIL)) {
            if (!G5Q.LIZJ(this.LJIILIIL)) {
                return;
            }
            if (!G5Q.LIZLLL(this.LJIILIIL) && !G5Q.LJ(this.LJIILIIL) && !G5Q.LJI(this.LJIILIIL)) {
                return;
            }
        }
        View LIZ2 = LIZ(2131369220);
        LIZ2.findViewById(2131365678).setImageResource(2131234982);
        LIZ2.findViewById(2131371242).setText(2131829618);
        LIZ2.findViewById(2131364007).setText(2131829614);
        C1430G2l.LIZIZ(LIZ2);
        LJIIJJI();
        LIZ2.setOnClickListener(new G4T(LIZ2, this));
    }

    private final void LJI() {
        View LIZ2 = LIZ(2131371465);
        LIZ2.findViewById(2131365678).setImageResource(2131234976);
        LIZ2.findViewById(2131371242).setText(2131829616);
        LIZ2.findViewById(2131364007).setText(2131829615);
        C1430G2l.LIZIZ(LIZ2);
        LIZJ(0);
        LIZ2.setOnClickListener(new G4G(this));
    }

    private final void LJII() {
        Object obj;
        if (!G5Q.LIZJ(this.LJIILIIL) && !12L.LIZ(this.LJIILIIL)) {
            return;
        }
        if (!G5Q.LIZJ(this.LJIILIIL) || G5Q.LIZLLL(this.LJIILIIL)) {
            View LIZ2 = LIZ(2131369102);
            LIZ2.findViewById(2131365678).setImageResource(2131234976);
            LIZ2.findViewById(2131371242).setText(2131829957);
            LIZ2.findViewById(2131364007).setText(2131829598);
            int i = G5Q.LIZ;
            if (i != 0) {
                C1430G2l.LIZIZ(LIZ2.findViewById(2131369405));
                1jk findViewById = LIZ2.findViewById(2131369405);
                n.LIZIZ(findViewById, "");
                findViewById.setText(String.valueOf(i));
            } else {
                DataChannel dataChannel = this.LJIILIIL;
                if (dataChannel != null) {
                    obj = dataChannel.LIZIZ(2DC.class);
                } else {
                    obj = null;
                }
                if (n.LIZ(obj, true)) {
                    C1430G2l.LIZIZ(LIZ2.findViewById(2131369404));
                }
            }
            C1430G2l.LIZIZ(LIZ2);
            LIZJ(i);
            LIZ2.setOnClickListener(new C1450G3f(LIZ2, i, this));
        }
    }

    public final void onDismiss(DialogInterface dialogInterface) {
        super.onDismiss(dialogInterface);
        G4X.LJI.LIZIZ(this);
    }

    public final void LIZ(long j) {
        View LIZ2 = LIZ(2131368643);
        n.LIZIZ(LIZ2, "");
        C1430G2l.LIZIZ(LIZ2.findViewById(2131363865));
    }

    private final void LIZJ(int i) {
        C3491GtA LIZ2 = C3491GtA.LJFF.LIZ("livesdk_anchor_qa_entrance_show");
        LIZ2.LIZ(this.LJIILIIL);
        LIZ2.LIZ("has_red_dot", Math.min(i, 1));
        LIZ2.LIZ("show_question_number", i);
        LIZ2.LIZ("request_page", "interaction_entrance");
        LIZ2.LIZLLL();
        if (i > 0) {
            C3491GtA LIZ3 = C3491GtA.LJFF.LIZ("livesdk_anchor_qa_red_dot_show");
            LIZ3.LIZ(this.LJIILIIL);
            LIZ3.LIZ("show_question_number", i);
            LIZ3.LIZLLL();
        }
    }

    public final void LIZIZ(int i) {
        C3491GtA LIZ2 = C3491GtA.LJFF.LIZ("livesdk_anchor_qa_entrance_click");
        LIZ2.LIZ(this.LJIILIIL);
        LIZ2.LIZ("has_red_dot", Math.min(i, 1));
        LIZ2.LIZ("show_question_number", i);
        LIZ2.LIZ("request_page", "interaction_entrance");
        LIZ2.LIZLLL();
    }

    public final void LIZ(Context context, Ls2<2Pr> ls2) {
        if (G4X.LIZIZ) {
            1Lu r2 = new 1Lu(context);
            r2.LJIJI = true;
            r2.LIZIZ(2131829604);
            r2.LIZJ(2131829603);
            r2.LIZIZ(2131829601, new G4I(ls2));
            r2.LIZLLL(2131829602);
            LiveDialog LIZIZ2 = r2.LIZIZ();
            LIZIZ2.show();
            2fU.LIZ.LIZ(LIZIZ2);
            return;
        }
        ls2.invoke();
    }

    public final void onViewCreated(View view, Bundle bundle) {
        long j;
        Object obj;
        DataChannel dataChannel;
        Room room;
        RoomAuthStatus roomAuthStatus;
        Room room2;
        Room room3;
        InteractionFeaturesDialog interactionFeaturesDialog = this;
        View view2 = view;
        M12.LIZ(view2);
        super.onViewCreated(view2, bundle);
        C2182GVj gVj = C2182GVj.LJIIJJI;
        DataChannel dataChannel2 = interactionFeaturesDialog.LJIILIIL;
        if (dataChannel2 == null || (room3 = (Room) dataChannel2.LIZIZ(C1064Fv7.class)) == null) {
            j = 0;
        } else {
            j = room3.getId();
        }
        if (gVj.LIZ(j)) {
            View LIZ2 = interactionFeaturesDialog.LIZ(2131363886);
            LIZ2.findViewById(2131365678).setImageResource(2131234975);
            LIZ2.findViewById(2131371242).setText(2131828501);
            LIZ2.findViewById(2131364007).setText(2131828500);
            C1430G2l.LIZIZ(LIZ2);
            0Zp.LIZ(0Zp.LIZ, interactionFeaturesDialog.LJIILIIL, "interaction_panel", false, false, false, (String) null, 60);
            LIZ2.setOnClickListener(new G4F(interactionFeaturesDialog));
            DataChannel dataChannel3 = interactionFeaturesDialog.LJIILIIL;
            if (!(dataChannel3 == null || (room2 = (Room) dataChannel3.LIZIZ(C1064Fv7.class)) == null)) {
                if (C2182GVj.LJIIJJI.LIZLLL(room2.getId())) {
                    n.LIZIZ(LIZ2, "");
                    C1430G2l.LIZIZ(LIZ2.findViewById(2131363865));
                } else {
                    n.LIZIZ(LIZ2, "");
                    C1430G2l.LIZ(LIZ2.findViewById(2131363865));
                }
                C2182GVj.LJIIJJI.LIZ(room2.getId(), (0Zm) interactionFeaturesDialog.LIZIZ);
            }
        }
        if (LivePollSetting.INSTANCE.enable(interactionFeaturesDialog.LJIILIIL) || !((dataChannel = interactionFeaturesDialog.LJIILIIL) == null || (room = (Room) dataChannel.LIZIZ(C1064Fv7.class)) == null || (roomAuthStatus = room.getRoomAuthStatus()) == null || roomAuthStatus.enableGiftPoll != 1)) {
            View LIZ3 = interactionFeaturesDialog.LIZ(2131368643);
            LIZ3.findViewById(2131365678).setImageResource(2131234981);
            LIZ3.findViewById(2131371242).setText(2131830180);
            LIZ3.findViewById(2131364007).setText(2131830179);
            DataChannel dataChannel4 = interactionFeaturesDialog.LJIILIIL;
            if (dataChannel4 != null) {
                obj = dataChannel4.LIZIZ(2DB.class);
            } else {
                obj = null;
            }
            if (n.LIZ(obj, true)) {
                C1430G2l.LIZIZ(LIZ3.findViewById(2131369404));
            }
            C1430G2l.LIZIZ(LIZ3);
            if (GT5.LJ.LIZIZ() || GT5.LJ.LIZ()) {
                C1430G2l.LIZIZ(LIZ3.findViewById(2131363865));
            }
            G4X.LJI.LIZ((C1471G4a) interactionFeaturesDialog);
            GT2.LIZ.LIZ();
            LIZ3.setOnClickListener(new G3D(LIZ3, interactionFeaturesDialog));
        }
        if (0Zr.LIZ(C1430G2l.LIZ(interactionFeaturesDialog.LJIILIIL))) {
            IEffectService LIZ4 = 0cm.LIZ(IEffectService.class);
            n.LIZIZ(LIZ4, "");
            if (LIZ4.getLiveGameEffectHelper().LIZ(interactionFeaturesDialog.LJIILIIL, "draw_guess")) {
                C1265FyM fyM = C1265FyM.LJ;
                DataChannel dataChannel5 = interactionFeaturesDialog.LJIILIIL;
                if (!C1265FyM.LIZJ && dataChannel5 != null) {
                    C1265FyM.LIZ = dataChannel5;
                    C1265FyM.LIZJ = true;
                    fyM.LIZJ();
                }
                View LIZ5 = interactionFeaturesDialog.LIZ(2131364250);
                C1430G2l.LIZIZ(LIZ5);
                LIZ5.findViewById(2131365678).setImageResource(2131234947);
                LIZ5.findViewById(2131371242).setText(2131828544);
                LIZ5.findViewById(2131364007).setText(2131828537);
                C1430G2l.LIZ(LIZ5, 500, (LsC<? super View, 2Pr>) new C1157Fwc(interactionFeaturesDialog));
                C3491GtA LIZ6 = C3491GtA.LJFF.LIZ("livesdk_anchor_pictionary_entrance_show");
                LIZ6.LIZ(interactionFeaturesDialog.LJIILIIL);
                LIZ6.LIZLLL();
            }
        }
        if (!G5Q.LIZJ(interactionFeaturesDialog.LJIILIIL)) {
            interactionFeaturesDialog.LJII();
            interactionFeaturesDialog.LJFF();
        } else if (!G5Q.LJII(interactionFeaturesDialog.LJIILIIL)) {
            if (G5Q.LIZLLL(interactionFeaturesDialog.LJIILIIL)) {
                interactionFeaturesDialog.LJFF();
                interactionFeaturesDialog.LJII();
            } else if (G5Q.LJ(interactionFeaturesDialog.LJIILIIL)) {
                interactionFeaturesDialog.LJFF();
                interactionFeaturesDialog.LJI();
            } else if (G5Q.LJFF(interactionFeaturesDialog.LJIILIIL)) {
                interactionFeaturesDialog.LJI();
            } else if (G5Q.LJI(interactionFeaturesDialog.LJIILIIL)) {
                interactionFeaturesDialog.LJFF();
            }
        }
    }
}
