package com.ss.android.ugc.aweme.im.sdk.share.viewmodel;

import X.0Bt;
import X.0CB;
import X.0CH;
import X.1Bn;
import X.3WX;
import X.6Is;
import X.C0908IYx;
import X.C1103Icg;
import X.C1871Ip4;
import X.C2201IuO;
import X.Cv9;
import X.Cwu;
import X.DAj;
import X.IYQ;
import X.Lel;
import X.M12;
import X.MKj;
import com.bytedance.covode.number.Covode;
import com.ss.android.ugc.aweme.im.sdk.share.panel.viewmodel.SharePanelViewModel;
import com.ss.android.ugc.aweme.im.service.model.IMContact;
import com.ss.android.ugc.aweme.sharer.ui.SharePackage;
import java.util.List;
import java.util.Set;
import java.util.concurrent.CancellationException;
import kotlinx.coroutines.CoroutineExceptionHandler;

public final class SharePanelImHeadViewModel extends 0Bt implements 6Is, 3WX {
    public final 1Bn<Boolean> LIZ;
    public final 1Bn<Boolean> LIZIZ;
    public final 1Bn<Set<IMContact>> LIZJ;
    public final 1Bn<Boolean> LIZLLL;
    public final 1Bn<Boolean> LJ;
    public final 1Bn<Cwu<IMContact, Boolean>> LJFF;
    public final 1Bn<Boolean> LJI;
    public final 1Bn<Cwu<IMContact, Boolean>> LJII;
    public final 1Bn<List<IMContact>> LJIIIIZZ;
    public final SharePanelViewModel LJIIIZ;
    public final SharePackage LJIIJ;
    public final C2201IuO LJIIJJI;
    public final Cv9 LJIIL;

    static {
        Covode.recordClassIndex(87220);
    }

    public final void LIZ(List<? extends IMContact> list, Throwable th) {
        M12.LIZ(list, th);
    }

    public final void onStateChanged(0CH r1, 0CB r2) {
    }

    public final void LIZIZ() {
        this.LJ.setValue(true);
    }

    public final int LIZ() {
        MKj iMSetting = C1103Icg.LJ.LIZ().getIMSetting();
        if (iMSetting != null) {
            return iMSetting.LIZJ;
        }
        return 10;
    }

    public final void onCleared() {
        SharePanelImHeadViewModel.super.onCleared();
        DAj.LIZ(this.LJIIL, (CancellationException) null);
        this.LIZ.setValue(false);
        this.LIZIZ.setValue(false);
    }

    public final void LIZ(List<? extends IMContact> list) {
        M12.LIZ(list);
        this.LJIIIIZZ.setValue(list);
    }

    public final void LIZ(IMContact iMContact) {
        M12.LIZ(iMContact);
        this.LJII.setValue(new Cwu(iMContact, true));
    }

    public final void LIZ(boolean z) {
        this.LJI.setValue(Boolean.valueOf(z));
    }

    public SharePanelImHeadViewModel(SharePackage sharePackage, C2201IuO iuO) {
        SharePackage sharePackage2 = sharePackage;
        M12.LIZ(sharePackage2, iuO);
        this.LJIIJ = sharePackage2;
        this.LJIIJJI = iuO;
        this.LIZ = new 1Bn<>(false);
        this.LIZIZ = new 1Bn<>(false);
        this.LIZJ = new 1Bn<>();
        this.LIZLLL = new 1Bn<>(false);
        this.LJ = new 1Bn<>(false);
        this.LJFF = new 1Bn<>();
        this.LJI = new 1Bn<>(false);
        this.LJII = new 1Bn<>();
        this.LJIIIIZZ = new 1Bn<>();
        this.LJIIL = DAj.LIZ(new C1871Ip4(CoroutineExceptionHandler.LIZLLL));
        this.LJIIIZ = C0908IYx.LIZ(SharePanelViewModel.LJIIL, sharePackage2, this, Lel.INSTANCE, IYQ.NORMAL, 0, 16);
    }

    /* JADX DEBUG: Multi-variable search result rejected for TypeSearchVarInfo{r2v0, resolved type: com.ss.android.ugc.aweme.feed.model.upvote.UpvoteStruct} */
    /* JADX DEBUG: Multi-variable search result rejected for TypeSearchVarInfo{r2v16, resolved type: com.ss.android.ugc.aweme.feed.model.upvote.UpvoteStruct} */
    /* JADX DEBUG: Multi-variable search result rejected for TypeSearchVarInfo{r3v10, resolved type: java.lang.Object} */
    /* JADX DEBUG: Multi-variable search result rejected for TypeSearchVarInfo{r1v34, resolved type: com.ss.android.ugc.aweme.feed.model.upvote.UpvoteStruct} */
    /* JADX DEBUG: Multi-variable search result rejected for TypeSearchVarInfo{r2v18, resolved type: com.ss.android.ugc.aweme.feed.model.upvote.UpvoteStruct} */
    /* JADX WARNING: Code restructure failed: missing block: B:50:0x011f, code lost:
        if (r21 != false) goto L_0x0121;
     */
    /* JADX WARNING: Multi-variable type inference failed */
    /* JADX WARNING: Removed duplicated region for block: B:59:0x019c  */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public final boolean LIZ(com.ss.android.ugc.aweme.im.service.model.IMContact r20, boolean r21) {
        /*
            r19 = this;
            r0 = r19
            r3 = r20
            X.M12.LIZ(r3)
            boolean r1 = r3 instanceof X.C2270IvV
            r2 = 0
            if (r1 == 0) goto L_0x001b
            r1 = r0
        L_0x000d:
            r6 = 0
            r7 = 1
            if (r1 == 0) goto L_0x001d
            X.1Bn<java.lang.Boolean> r1 = r0.LIZ
            java.lang.Boolean r0 = java.lang.Boolean.valueOf(r7)
            r1.setValue(r0)
            return r6
        L_0x001b:
            r1 = r2
            goto L_0x000d
        L_0x001d:
            boolean r1 = r3 instanceof X.C2269IvU
            if (r1 == 0) goto L_0x00ed
            r4 = r0
        L_0x0022:
            java.lang.String r1 = ""
            if (r4 == 0) goto L_0x00f0
            com.ss.android.ugc.aweme.sharer.ui.SharePackage r3 = r0.LJIIJ
            android.os.Bundle r4 = r3.LJIILJJIL
            java.lang.String r3 = "aid"
            java.lang.String r10 = r4.getString(r3)
            if (r10 != 0) goto L_0x0033
        L_0x0032:
            return r6
        L_0x0033:
            kotlin.h.b.n.LIZIZ(r10, r1)
            com.ss.android.ugc.aweme.upvote.event.UpvotePublishMobParam r7 = new com.ss.android.ugc.aweme.upvote.event.UpvotePublishMobParam
            java.lang.String r3 = "enter_from"
            java.lang.String r8 = r4.getString(r3, r1)
            kotlin.h.b.n.LIZIZ(r8, r1)
            r9 = 0
            java.lang.String r3 = "author_id"
            java.lang.String r11 = r4.getString(r3, r1)
            kotlin.h.b.n.LIZIZ(r11, r1)
            r5 = -1
            java.lang.String r3 = "follow_status"
            int r3 = r4.getInt(r3, r5)
            java.lang.String r12 = java.lang.String.valueOf(r3)
            r13 = 0
            r14 = 0
            r15 = 0
            r16 = 0
            java.lang.String r3 = "panel_source"
            java.lang.String r3 = r4.getString(r3, r1)
            kotlin.h.b.n.LIZIZ(r3, r1)
            r18 = 482(0x1e2, float:6.75E-43)
            r17 = r3
            r7.<init>(r8, r9, r10, r11, r12, r13, r14, r15, r16, r17, r18)
            com.ss.android.ugc.aweme.IAccountUserService r3 = X.46i.LJFF()
            kotlin.h.b.n.LIZIZ(r3, r1)
            java.lang.String r5 = r3.getCurUserId()
            X.A05 r1 = X.A05.LIZ
            com.ss.android.ugc.aweme.feed.model.upvote.UpvoteList r1 = r1.LIZ(r10)
            if (r1 == 0) goto L_0x00d4
            java.util.List r1 = r1.getUpvotes()
            if (r1 == 0) goto L_0x00d4
            java.util.Iterator r4 = r1.iterator()
        L_0x0088:
            boolean r1 = r4.hasNext()
            if (r1 == 0) goto L_0x00a6
            java.lang.Object r3 = r4.next()
            r1 = r3
            com.ss.android.ugc.aweme.feed.model.upvote.UpvoteStruct r1 = (com.ss.android.ugc.aweme.feed.model.upvote.UpvoteStruct) r1
            com.ss.android.ugc.aweme.profile.model.User r1 = r1.getUser()
            if (r1 == 0) goto L_0x00d2
            java.lang.String r1 = r1.getUid()
        L_0x009f:
            boolean r1 = kotlin.h.b.n.LIZ(r1, r5)
            if (r1 == 0) goto L_0x0088
            r2 = r3
        L_0x00a6:
            com.ss.android.ugc.aweme.feed.model.upvote.UpvoteStruct r2 = (com.ss.android.ugc.aweme.feed.model.upvote.UpvoteStruct) r2
            if (r2 == 0) goto L_0x00d4
            java.lang.String r1 = "button"
            r7.LIZ(r1)
            java.lang.String r1 = r2.getText()
            if (r1 == 0) goto L_0x00bb
            int r1 = r1.length()
            if (r1 != 0) goto L_0x00d0
        L_0x00bb:
            r1 = 1
        L_0x00bc:
            r11 = r1 ^ 1
            X.A05 r9 = X.A05.LIZ
            r13 = 0
            X.Iwa r1 = new X.Iwa
            r1.<init>(r0)
            r15 = 8
            r10 = r10
            r12 = r7
            r14 = r1
            X.9pq.LIZ(r9, r10, r11, r12, r13, r14, r15)
            goto L_0x0032
        L_0x00d0:
            r1 = 0
            goto L_0x00bc
        L_0x00d2:
            r1 = r2
            goto L_0x009f
        L_0x00d4:
            java.lang.String r1 = "share_panel"
            r7.LIZ(r1)
            X.A05 r8 = X.A05.LIZ
            r11 = 0
            r12 = 0
            r13 = 0
            X.Iwb r1 = new X.Iwb
            r1.<init>(r0)
            r15 = 28
            r9 = r10
            r10 = r7
            r14 = r1
            X.9pq.LIZ(r8, r9, r10, r11, r12, r13, r14, r15)
            goto L_0x0032
        L_0x00ed:
            r4 = r2
            goto L_0x0022
        L_0x00f0:
            com.ss.android.ugc.aweme.im.sdk.share.panel.viewmodel.SharePanelViewModel r2 = r0.LJIIIZ
            boolean r2 = r2.LIZLLL
            if (r2 != 0) goto L_0x011f
            if (r21 == 0) goto L_0x01a8
            com.ss.android.ugc.aweme.im.sdk.share.panel.viewmodel.SharePanelViewModel r2 = r0.LJIIIZ
            java.util.Set r2 = r2.LIZIZ()
            int r4 = r2.size()
            int r2 = r19.LIZ()
            if (r4 < r2) goto L_0x0121
            com.ss.android.ugc.aweme.im.sdk.share.panel.viewmodel.SharePanelViewModel r2 = r0.LJIIIZ
            java.util.Set r2 = r2.LIZIZ()
            boolean r2 = r2.contains(r3)
            if (r2 != 0) goto L_0x0121
            X.1Bn<java.lang.Boolean> r1 = r0.LIZLLL
            java.lang.Boolean r0 = java.lang.Boolean.valueOf(r7)
            r1.setValue(r0)
            r0 = 0
            return r6
        L_0x011f:
            if (r21 == 0) goto L_0x01a8
        L_0x0121:
            com.ss.android.ugc.aweme.im.sdk.share.panel.viewmodel.SharePanelViewModel r2 = r0.LJIIIZ
            java.util.List r2 = r2.LIZ()
            int r5 = r2.indexOf(r3)
            com.ss.android.ugc.aweme.sharer.ui.SharePackage r2 = r0.LJIIJ
            android.os.Bundle r4 = r2.LJIILJJIL
            java.lang.String r2 = "rank_num"
            r4.putInt(r2, r5)
            X.SfZ r4 = X.SfZ.LJIJ
            android.app.Activity r6 = r4.LJIIIZ()
            if (r6 == 0) goto L_0x0151
            com.ss.android.ugc.aweme.sharer.ui.SharePackage r4 = r0.LJIIJ
            android.os.Bundle r5 = r4.LJIILJJIL
            X.2M8 r4 = com.ss.android.ugc.aweme.feed.param.FeedParamProvider.LIZIZ
            X.TnV r4 = r4.LIZ(r6)
            java.lang.String r4 = r4.getLastGroupId()
            if (r4 != 0) goto L_0x01a6
        L_0x014c:
            java.lang.String r4 = "last_group_id"
            r5.putString(r4, r1)
        L_0x0151:
            X.BYD r8 = X.BYD.LIZ
            com.ss.android.ugc.aweme.sharer.ui.SharePackage r9 = r0.LJIIJ
            r11 = 0
            r12 = 0
            r13 = 0
            r15 = 0
            r16 = 0
            r17 = 120(0x78, float:1.68E-43)
            r10 = r3
            X.BYD.LIZ(r8, r9, r10, r11, r12, r13, r15, r16, r17)
            com.ss.android.ugc.aweme.sharer.ui.SharePackage r1 = r0.LJIIJ
            android.os.Bundle r1 = r1.LJIILJJIL
            r1.remove(r2)
            com.ss.android.ugc.aweme.im.sdk.share.panel.viewmodel.SharePanelViewModel r1 = r0.LJIIIZ
            java.util.Set r1 = r1.LIZIZ()
            r1.add(r3)
            X.IuO r4 = r0.LJIIJJI
            com.ss.android.ugc.aweme.sharer.ui.SharePackage r2 = r0.LJIIJ
            java.lang.String r1 = "chat_mergeIM"
            r4.LIZ(r1, r2)
        L_0x017b:
            X.1Bn<java.util.Set<com.ss.android.ugc.aweme.im.service.model.IMContact>> r2 = r0.LIZJ
            com.ss.android.ugc.aweme.im.sdk.share.panel.viewmodel.SharePanelViewModel r1 = r0.LJIIIZ
            java.util.Set r1 = r1.LIZIZ()
            r2.setValue(r1)
            X.1Bn<X.Cwu<com.ss.android.ugc.aweme.im.service.model.IMContact, java.lang.Boolean>> r4 = r0.LJFF
            X.Cwu r2 = new X.Cwu
            java.lang.Boolean r1 = java.lang.Boolean.valueOf(r21)
            r2.<init>(r3, r1)
            r4.setValue(r2)
            com.ss.android.ugc.aweme.im.sdk.share.panel.viewmodel.SharePanelViewModel r1 = r0.LJIIIZ
            boolean r1 = r1.LJIIIIZZ()
            if (r1 == 0) goto L_0x01a5
            X.1Bn<java.lang.Boolean> r1 = r0.LIZIZ
            java.lang.Boolean r0 = java.lang.Boolean.valueOf(r7)
            r1.setValue(r0)
        L_0x01a5:
            return r7
        L_0x01a6:
            r1 = r4
            goto L_0x014c
        L_0x01a8:
            com.ss.android.ugc.aweme.im.sdk.share.panel.viewmodel.SharePanelViewModel r1 = r0.LJIIIZ
            java.util.Set r1 = r1.LIZIZ()
            r1.remove(r3)
            goto L_0x017b
        */
        throw new UnsupportedOperationException("Method not decompiled: com.ss.android.ugc.aweme.im.sdk.share.viewmodel.SharePanelImHeadViewModel.LIZ(com.ss.android.ugc.aweme.im.service.model.IMContact, boolean):boolean");
    }

    public /* synthetic */ SharePanelImHeadViewModel(SharePackage sharePackage, C2201IuO iuO, byte b) {
        this(sharePackage, iuO);
    }
}
