package com.ss.android.ugc.aweme.live.livehostimpl;

import X.2J2;
import X.2fU;
import X.3QV;
import X.3g1;
import X.46i;
import X.4EW;
import X.4FQ;
import X.874;
import X.8q8;
import X.C3026Glf;
import X.C3569GuQ;
import X.C3871GzI;
import X.C3873GzK;
import X.C3876GzN;
import X.C3879GzQ;
import X.C3881GzS;
import X.C3937H0w;
import X.C4100H7d;
import X.GAX;
import X.HK3;
import X.M12;
import X.Mk2;
import X.Mk3;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import com.bytedance.android.livesdkapi.depend.model.live.Room;
import com.bytedance.android.livesdkapi.host.IHostStartLiveManager;
import com.bytedance.android.livesdkapi.session.EnterRoomConfig;
import com.bytedance.android.livesdkapi.session.EnterRoomLinkSession;
import com.bytedance.covode.number.Covode;
import com.bytedance.livesdk.api.base.ILiveSharedPreferencesService;
import com.ss.android.ugc.aweme.AccountService;
import com.ss.android.ugc.aweme.IAccountUserService;
import com.ss.android.ugc.aweme.live.ILiveInnerService;
import com.ss.android.ugc.aweme.live.ILiveOuterService;
import com.ss.android.ugc.aweme.live.LiveOuterService;
import kotlin.h.b.n;

public final class LiveHostStartLiveManager implements IHostStartLiveManager {
    public static final C3879GzQ LIZIZ = new C3879GzQ((byte) 0);
    public 2J2 LIZ;

    static {
        Covode.recordClassIndex(91239);
    }

    public final void onInit() {
    }

    public static void LIZ(HK3 hk3) {
        hk3.show();
        2fU.LIZ.LIZ(hk3);
    }

    public final EnterRoomConfig LIZ(Room room, EnterRoomConfig enterRoomConfig) {
        enterRoomConfig.LIZLLL.LJJLIIIIJ = room.getId();
        return enterRoomConfig;
    }

    public final void LIZIZ(Context context, EnterRoomConfig enterRoomConfig) {
        M12.LIZ(context, enterRoomConfig);
        EnterRoomLinkSession enterRoomLinkSession = new EnterRoomLinkSession(enterRoomConfig);
        C3026Glf glf = GAX.LIZ;
        n.LIZIZ(glf, "");
        glf.LIZ(enterRoomLinkSession);
        if (TextUtils.equals(enterRoomConfig.LIZLLL.LJJLIIIJILLIZJL, "inner_draw")) {
            enterRoomConfig.LIZLLL.LJJLIIIJILLIZJL = "inner_jump";
        }
        if (8q8.LIZ(context) || 874.LIZIZ(ILiveSharedPreferencesService.class).LIZIZ(context) || !(context instanceof Activity) || !LIZIZ.LIZ()) {
            ILiveInnerService LIZIZ2 = 874.LIZIZ(ILiveInnerService.class);
            n.LIZIZ(LIZIZ2, "");
            LIZIZ2.LIZIZ().LIZ(context, enterRoomConfig);
            return;
        }
        4EW r1 = new 4EW(context);
        r1.LIZLLL(2131834710);
        3QV.LIZ(r1, new C3876GzN(context, enterRoomConfig));
        4FQ.LIZ(r1.LIZ().LIZJ());
    }

    /* JADX WARNING: Code restructure failed: missing block: B:59:0x021b, code lost:
        if (kotlin.h.b.n.LIZ(r1, X.HL0.LIZ) == false) goto L_0x0232;
     */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public final boolean LIZ(android.content.Context r13, com.bytedance.android.livesdkapi.session.EnterRoomConfig r14) {
        /*
            r12 = this;
            X.M12.LIZ(r13, r14)
            r5 = 1
            r14.LIZ = r5
            com.ss.android.ugc.aweme.IAccountUserService r0 = X.46i.LJFF()
            java.lang.String r2 = ""
            kotlin.h.b.n.LIZIZ(r0, r2)
            boolean r0 = r0.isLogin()
            r3 = 0
            if (r0 != 0) goto L_0x0059
            boolean r0 = r13 instanceof android.app.Activity
            if (r0 == 0) goto L_0x0058
            android.os.Bundle r1 = new android.os.Bundle
            r1.<init>()
            java.lang.String r0 = "is_fullscreen_dialog"
            r1.putBoolean(r0, r5)
            java.lang.String r0 = "is_skippable_dialog"
            r1.putBoolean(r0, r3)
            X.3g1 r2 = new X.3g1
            r2.<init>()
            com.bytedance.android.livesdkapi.session.EnterRoomConfig$RoomsData r0 = r14.LIZLLL
            java.lang.String r0 = r0.LJJJJI
            r2.LIZIZ = r0
            com.bytedance.android.livesdkapi.session.EnterRoomConfig$RoomsData r0 = r14.LIZLLL
            java.lang.String r0 = r0.LJJJJJ
            r2.LIZJ = r0
            r0 = r13
            android.app.Activity r0 = (android.app.Activity) r0
            r2.LIZ = r0
            r2.LIZLLL = r1
            X.Gzf r0 = new X.Gzf
            r0.<init>(r12, r13, r14)
            r2.LJ = r0
            com.ss.android.ugc.aweme.IAccountService r0 = com.ss.android.ugc.aweme.AccountService.LIZ()
            X.KEn r1 = r0.LJII()
            X.3g2 r0 = r2.LIZ()
            r1.showLoginAndRegisterView(r0)
            return r5
        L_0x0058:
            return r3
        L_0x0059:
            com.bytedance.android.livesdkapi.session.EnterRoomLinkSession r4 = com.bytedance.android.livesdkapi.session.EnterRoomLinkSession.LIZ((com.bytedance.android.livesdkapi.session.EnterRoomConfig) r14)
            com.bytedance.android.livesdkapi.session.Event r7 = new com.bytedance.android.livesdkapi.session.Event
            r6 = 768(0x300, float:1.076E-42)
            X.Gqb r1 = X.C3332Gqb.BussinessApiCall
            java.lang.String r0 = "room_action_handler"
            r7.<init>(r0, r6, r1)
            r4.LIZ((com.bytedance.android.livesdkapi.session.Event) r7)
            com.bytedance.android.livesdkapi.session.EnterRoomConfig$RoomsData r0 = r14.LIZLLL
            long r0 = r0.LJJJJZI
            r8 = 0
            int r6 = (r0 > r8 ? 1 : (r0 == r8 ? 0 : -1))
            if (r6 > 0) goto L_0x009b
            com.bytedance.android.livesdkapi.session.Event r7 = new com.bytedance.android.livesdkapi.session.Event
            r6 = 769(0x301, float:1.078E-42)
            X.Gqb r1 = X.C3332Gqb.BussinessApiCall
            java.lang.String r0 = "room_action_handler_is_null"
            r7.<init>(r0, r6, r1)
            r4.LIZ((com.bytedance.android.livesdkapi.session.Event) r7)
            com.bytedance.android.livesdkapi.session.EnterRoomConfig$RoomsData r0 = r14.LIZLLL
            java.lang.String r0 = r0.LJJIJIIJI
            if (r0 == 0) goto L_0x0097
            java.lang.Long r0 = X.2tE.LJI(r0)
            if (r0 == 0) goto L_0x0097
            long r6 = r0.longValue()
            int r0 = (r6 > r8 ? 1 : (r6 == r8 ? 0 : -1))
            if (r0 > 0) goto L_0x0098
        L_0x0097:
            return r3
        L_0x0098:
            r12.LIZIZ(r13, r14)
        L_0x009b:
            com.bytedance.ies.sdk.datachannel.DataChannelGlobal r1 = com.bytedance.ies.sdk.datachannel.DataChannelGlobal.LIZLLL
            java.lang.Class<X.HEP> r0 = X.HEP.class
            java.lang.Object r6 = r1.LIZIZ(r0)
            com.bytedance.android.livesdkapi.depend.model.live.Room r6 = (com.bytedance.android.livesdkapi.depend.model.live.Room) r6
            if (r6 != 0) goto L_0x00d5
            java.util.HashMap r2 = new java.util.HashMap
            r2.<init>()
            com.bytedance.android.livesdkapi.session.EnterRoomConfig$RoomsData r0 = r14.LIZLLL
            java.lang.String r1 = r0.LJJJJI
            java.lang.String r0 = "enterFromMerge"
            r2.put(r0, r1)
            com.bytedance.android.livesdkapi.session.EnterRoomConfig$RoomsData r0 = r14.LIZLLL
            java.lang.String r1 = r0.LJJJJJ
            java.lang.String r0 = "enterMethod"
            r2.put(r0, r1)
            java.lang.String r0 = "ttlive_schema_push_live"
            X.0c0.LIZ(r0, r3, r2)
            com.bytedance.android.livesdkapi.session.Event r3 = new com.bytedance.android.livesdkapi.session.Event
            r2 = 770(0x302, float:1.079E-42)
            X.Gqb r1 = X.C3332Gqb.BussinessApiCall
            java.lang.String r0 = "live_scheme_start_live"
            r3.<init>(r0, r2, r1)
            r4.LIZ((com.bytedance.android.livesdkapi.session.Event) r3)
            r12.LIZIZ(r13, r14)
            return r5
        L_0x00d5:
            com.bytedance.android.live.base.model.user.User r0 = r6.getOwner()
            r7 = 2131834059(0x7f1134cb, float:1.9301218E38)
            if (r0 == 0) goto L_0x012c
            com.bytedance.android.live.base.model.user.User r0 = r6.getOwner()
            kotlin.h.b.n.LIZIZ(r0, r2)
            long r10 = r0.getId()
            X.H7d r0 = X.C4100H7d.LIZ()
            X.Glh r0 = r0.LIZIZ()
            kotlin.h.b.n.LIZIZ(r0, r2)
            long r8 = r0.LIZJ()
            int r0 = (r10 > r8 ? 1 : (r10 == r8 ? 0 : -1))
            if (r0 != 0) goto L_0x012c
            X.HK2 r1 = new X.HK2
            r1.<init>(r13)
            r1.LJIIIZ = r3
            r6 = 2131834057(0x7f1134c9, float:1.9301214E38)
            r1.LIZIZ(r6)
            X.Gzc r0 = X.C3891Gzc.LIZ
            r1.LIZ((int) r7, (android.content.DialogInterface.OnClickListener) r0, (boolean) r3)
            X.HK3 r0 = r1.LIZ()
            LIZ(r0)
            com.bytedance.android.livesdkapi.session.Event r3 = new com.bytedance.android.livesdkapi.session.Event
            r2 = 33539(0x8303, float:4.6998E-41)
            X.Gqb r1 = X.C3332Gqb.BussinessApiCall
            java.lang.String r0 = "live_current_user_streaming"
            r3.<init>(r0, r2, r1)
            java.lang.String r0 = X.0b0.LIZ(r6)
            r3.LIZ(r0)
            r4.LIZ((com.bytedance.android.livesdkapi.session.Event) r3)
            return r5
        L_0x012c:
            r1 = 2
            X.1Om r0 = X.1Om.LIZ()
            kotlin.h.b.n.LIZIZ(r0, r2)
            java.lang.Object r0 = r0.LJIILIIL
            java.lang.Integer r0 = (java.lang.Integer) r0
            if (r0 != 0) goto L_0x01ab
        L_0x013a:
            com.bytedance.android.livesdkapi.session.EnterRoomConfig$RoomsData r0 = r14.LIZLLL
            java.lang.String r0 = r0.LJIIL
            boolean r0 = android.text.TextUtils.isEmpty(r0)
            if (r0 == 0) goto L_0x01e1
            com.bytedance.android.livesdkapi.session.EnterRoomConfig$RoomsData r0 = r14.LIZLLL
            java.lang.String r0 = r0.LJIIJJI
            boolean r0 = android.text.TextUtils.isEmpty(r0)
            if (r0 == 0) goto L_0x01e1
            kotlin.h.b.n.LIZIZ(r4, r2)
            r12.LIZ((com.bytedance.android.livesdkapi.depend.model.live.Room) r6, (com.bytedance.android.livesdkapi.session.EnterRoomConfig) r14)
            com.bytedance.android.livesdkapi.session.Event r3 = new com.bytedance.android.livesdkapi.session.Event
            r2 = 771(0x303, float:1.08E-42)
            X.Gqb r1 = X.C3332Gqb.BussinessApiCall
            java.lang.String r0 = "live_scheme_jump_to_other_room"
            r3.<init>(r0, r2, r1)
            r4.LIZ((com.bytedance.android.livesdkapi.session.Event) r3)
            X.Grf r2 = new X.Grf
            com.bytedance.android.livesdkapi.session.EnterRoomConfig$RoomsData r0 = r14.LIZLLL
            long r0 = r0.LJJJJZI
            r2.<init>(r0)
            r2.LIZLLL = r14
            com.bytedance.android.livesdkapi.session.EnterRoomConfig$RoomsData r0 = r14.LIZLLL
            java.lang.String r1 = r0.LJIIJ
            java.lang.String r0 = "true"
            boolean r0 = kotlin.h.b.n.LIZ(r0, r1)
            if (r0 == 0) goto L_0x0186
            X.Gg0 r1 = X.C2675Gg0.LIZ()
            X.GwX r0 = new X.GwX
            r0.<init>(r2)
            r1.LIZ((java.lang.Object) r0)
        L_0x0185:
            return r5
        L_0x0186:
            java.lang.Class<com.bytedance.android.live.microom.IMicRoomService> r0 = com.bytedance.android.live.microom.IMicRoomService.class
            X.0UT r0 = X.0cm.LIZ(r0)
            com.bytedance.android.live.microom.IMicRoomService r0 = (com.bytedance.android.live.microom.IMicRoomService) r0
            boolean r0 = r0.isMicRoom()
            if (r0 == 0) goto L_0x01a8
            com.bytedance.android.livesdkapi.session.EnterRoomConfig$RoomsData r0 = r14.LIZLLL
            boolean r0 = r0.LJJLIIJ
            if (r0 == 0) goto L_0x01a8
            java.lang.String r1 = "jump_source_mic_room"
        L_0x019c:
            com.bytedance.android.livesdkapi.session.EnterRoomConfig$RoomsData r0 = r14.LIZLLL
            r0.LJLJI = r1
            X.Gg0 r0 = X.C2675Gg0.LIZ()
            r0.LIZ((java.lang.Object) r2)
            goto L_0x0185
        L_0x01a8:
            java.lang.String r1 = "jump_source_live_banner"
            goto L_0x019c
        L_0x01ab:
            int r0 = r0.intValue()
            if (r1 != r0) goto L_0x013a
            X.HK2 r1 = new X.HK2
            r1.<init>(r13)
            r1.LJIIIZ = r3
            r6 = 2131834060(0x7f1134cc, float:1.930122E38)
            r1.LIZIZ(r6)
            X.Gzd r0 = X.C3892Gzd.LIZ
            r1.LIZ((int) r7, (android.content.DialogInterface.OnClickListener) r0, (boolean) r3)
            X.HK3 r0 = r1.LIZ()
            LIZ(r0)
            com.bytedance.android.livesdkapi.session.Event r3 = new com.bytedance.android.livesdkapi.session.Event
            r2 = 33541(0x8305, float:4.7001E-41)
            X.Gqb r1 = X.C3332Gqb.BussinessApiCall
            java.lang.String r0 = "live_scheme_interact_cannot_jump"
            r3.<init>(r0, r2, r1)
            java.lang.String r0 = X.0b0.LIZ(r6)
            r3.LIZ(r0)
            r4.LIZ((com.bytedance.android.livesdkapi.session.Event) r3)
            return r5
        L_0x01e1:
            com.bytedance.android.livesdkapi.session.EnterRoomConfig$RoomsData r0 = r14.LIZLLL
            java.lang.String r0 = r0.LJIIJJI
            boolean r0 = android.text.TextUtils.isEmpty(r0)
            r8 = 0
            if (r0 != 0) goto L_0x0229
            com.google.gson.Gson r2 = X.0UO.LIZIZ     // Catch:{ Exception -> 0x021e }
            com.bytedance.android.livesdkapi.session.EnterRoomConfig$RoomsData r0 = r14.LIZLLL     // Catch:{ Exception -> 0x021e }
            java.lang.String r1 = r0.LJIIJJI     // Catch:{ Exception -> 0x021e }
            java.lang.Class<com.bytedance.android.livesdk.model.message.common.Text> r0 = com.bytedance.android.livesdk.model.message.common.Text.class
            java.lang.Object r7 = r2.LIZ(r1, r0)     // Catch:{ Exception -> 0x021e }
            com.bytedance.android.livesdk.model.message.common.Text r7 = (com.bytedance.android.livesdk.model.message.common.Text) r7     // Catch:{ Exception -> 0x021e }
            if (r7 == 0) goto L_0x0229
            X.RjP r1 = X.RjP.LIZ()     // Catch:{ Exception -> 0x021e }
            java.lang.String r0 = r7.LIZ     // Catch:{ Exception -> 0x021e }
            java.lang.String r2 = r1.LIZ(r0)     // Catch:{ Exception -> 0x021e }
            java.lang.String r1 = r7.LIZIZ     // Catch:{ Exception -> 0x021e }
            boolean r0 = android.text.TextUtils.isEmpty(r2)     // Catch:{ Exception -> 0x021e }
            if (r0 == 0) goto L_0x020f
            r2 = r1
        L_0x020f:
            android.text.Spannable r1 = X.HL0.LIZ(r2, r7, r8)     // Catch:{ Exception -> 0x021e }
            if (r1 == 0) goto L_0x0229
            android.text.Spannable r0 = X.HL0.LIZ
            boolean r0 = kotlin.h.b.n.LIZ(r1, r0)
            if (r0 == 0) goto L_0x0232
            goto L_0x0229
        L_0x021e:
            r0 = move-exception
            java.lang.String r2 = r0.getMessage()
            r1 = 6
            java.lang.String r0 = "RoomSchemaHandler"
            X.0aP.LIZ(r1, r0, r2)
        L_0x0229:
            android.text.SpannableString r1 = new android.text.SpannableString
            com.bytedance.android.livesdkapi.session.EnterRoomConfig$RoomsData r0 = r14.LIZLLL
            java.lang.String r0 = r0.LJIIL
            r1.<init>(r0)
        L_0x0232:
            boolean r0 = android.text.TextUtils.isEmpty(r1)
            if (r0 != 0) goto L_0x025b
            X.HK2 r2 = new X.HK2
            r2.<init>(r13)
            r2.LJIIIZ = r3
            r2.LIZJ = r1
            X.GuP r1 = new X.GuP
            r1.<init>(r12, r4, r6, r14)
            r0 = 2131834061(0x7f1134cd, float:1.9301222E38)
            r2.LIZ((int) r0, (android.content.DialogInterface.OnClickListener) r1, (boolean) r3)
            X.Gze r1 = X.C3893Gze.LIZ
            r0 = 2131834058(0x7f1134ca, float:1.9301216E38)
            r2.LIZIZ((int) r0, (android.content.DialogInterface.OnClickListener) r1, (boolean) r3)
            X.HK3 r0 = r2.LIZ()
            LIZ(r0)
        L_0x025b:
            com.bytedance.android.livesdkapi.session.Event r3 = new com.bytedance.android.livesdkapi.session.Event
            r2 = 33542(0x8306, float:4.7002E-41)
            X.Gqb r1 = X.C3332Gqb.BussinessApiCall
            java.lang.String r0 = "live_scheme_do_nothing"
            r3.<init>(r0, r2, r1)
            r4.LIZ((com.bytedance.android.livesdkapi.session.Event) r3)
            return r5
        */
        throw new UnsupportedOperationException("Method not decompiled: com.ss.android.ugc.aweme.live.livehostimpl.LiveHostStartLiveManager.LIZ(android.content.Context, com.bytedance.android.livesdkapi.session.EnterRoomConfig):boolean");
    }

    public final void LIZ(Context context, EnterRoomConfig enterRoomConfig, long j) {
        M12.LIZ(context, enterRoomConfig);
        C4100H7d.LIZ().LIZIZ().LIZIZ(j).LIZ(Mk2.LIZ(Mk3.LIZ)).LIZ(new C3569GuQ(this, enterRoomConfig, context), C3881GzS.LIZ);
    }

    public final void LIZ(Context context, EnterRoomConfig enterRoomConfig, String str) {
        M12.LIZ(context, enterRoomConfig, str);
        ILiveOuterService LJJI = LiveOuterService.LJJI();
        n.LIZIZ(LJJI, "");
        C3937H0w LJI = LJJI.LJI();
        n.LIZIZ(LJI, "");
        LJI.LIZJ().LIZ(str, new C3871GzI(this, enterRoomConfig, str, context));
    }

    public final boolean LIZIZ(Context context, EnterRoomConfig enterRoomConfig, String str) {
        M12.LIZ(context, enterRoomConfig, str);
        IAccountUserService LJFF = 46i.LJFF();
        n.LIZIZ(LJFF, "");
        if (LJFF.isLogin()) {
            return LIZ(context, enterRoomConfig);
        }
        if (!(context instanceof Activity)) {
            return false;
        }
        Bundle bundle = new Bundle();
        bundle.putBoolean("is_fullscreen_dialog", true);
        bundle.putBoolean("is_skippable_dialog", false);
        3g1 r3 = new 3g1();
        r3.LIZIZ = enterRoomConfig.LIZLLL.LJJJJI;
        r3.LIZJ = enterRoomConfig.LIZLLL.LJJJJJ;
        r3.LIZ = (Activity) context;
        r3.LIZLLL = bundle;
        C3873GzK gzK = new C3873GzK(this, str, context, enterRoomConfig);
        this.LIZ = gzK;
        AccountService.LIZ().LJII().showLoginAndRegisterView(r3.LIZ());
        46i.LIZ();
        46i.LIZ.LIZ(gzK);
        return true;
    }
}
