package com.ss.android.ugc.aweme.homepage.ui.slide;

import X.0Bt;
import X.0Bu;
import X.1Bn;
import X.7he;
import X.9HM;
import X.AnonymousClass3PM;
import X.C03012Pr;
import X.C06262ce;
import X.C34023h4;
import X.C34033h5;
import X.C34053h7;
import X.C34113hD;
import X.C34203hM;
import X.C474046i;
import X.C65674r1;
import X.Crj;
import X.DAe;
import X.DB2;
import X.DBT;
import X.EiP;
import X.EjU;
import X.Lea;
import X.LsC;
import X.M12;
import android.os.Bundle;
import android.os.Looper;
import androidx.lifecycle.LiveData;
import com.bytedance.covode.number.Covode;
import com.bytedance.hox.Hox;
import com.ss.android.ugc.aweme.IAccountUserService;
import com.ss.android.ugc.aweme.dsp.service.IMusicDspService;
import com.ss.android.ugc.aweme.feed.model.Aweme;
import com.ss.android.ugc.aweme.homepage.api.data.HomePageDataViewModel;
import com.ss.android.ugc.aweme.homepage.ui.view.tab.HomeTabViewModel;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CancellationException;
import kotlin.h.b.n;

public final class SlideGuideViewModel extends 0Bt implements EjU {
    public static Boolean LJIIL;
    public static final C34113hD LJIILIIL = new C34113hD((byte) 0);
    public final 1Bn<Integer> LIZ;
    public final LiveData<Integer> LIZIZ;
    public final 1Bn<Boolean> LIZJ;
    public final LiveData<Boolean> LIZLLL;
    public boolean LJ;
    public String LJFF;
    public DBT LJI;
    public DBT LJII;
    public boolean LJIIIIZZ;
    public Boolean LJIIIZ;
    public final List<String> LJIIJ;
    public final DB2 LJIIJJI;
    public final Crj LJIILJJIL;
    public Boolean LJIILL;
    public final C34053h7 LJIILLIIL;
    public final HomePageDataViewModel LJIIZILJ;

    static {
        Covode.recordClassIndex(83164);
    }

    private final IMusicDspService LIZIZ() {
        return (IMusicDspService) this.LJIILJJIL.getValue();
    }

    public final void LIZ() {
        if (!n.LIZ(this.LIZLLL.getValue(), false)) {
            LIZ(this.LIZJ, false);
            DBT dbt = this.LJII;
            if (dbt != null) {
                dbt.LIZ((CancellationException) null);
            }
        }
    }

    public final void LIZ(boolean z) {
        this.LJIILL = Boolean.valueOf(!z);
        Boolean bool = (Boolean) this.LIZLLL.getValue();
        if (bool == null) {
            bool = false;
        }
        n.LIZIZ(bool, "");
        boolean booleanValue = bool.booleanValue();
        if (n.LIZ(this.LJIIIZ, true) && !booleanValue && n.LIZ(this.LJFF, "Following")) {
            LIZ("Following", 0);
        }
    }

    public final boolean LIZ(String str) {
        boolean z;
        boolean z2;
        Aweme aweme = this.LJIIZILJ.LJIIJ;
        if (aweme == null || !aweme.isAd()) {
            z = false;
        } else {
            z = true;
        }
        int hashCode = str.hashCode();
        if (hashCode != -1525083535) {
            if (hashCode != 2576150) {
                if (hashCode == 1442906357 && str.equals("MUSIC_DSP_XTAB")) {
                    return LIZIZ().LJIILL();
                }
            } else if (str.equals("Shop")) {
                return false;
            }
        } else if (str.equals("Following")) {
            Boolean bool = this.LJIILL;
            if (bool != null) {
                z2 = bool.booleanValue();
            } else {
                z2 = true;
            }
            IAccountUserService LJFF2 = C474046i.LJFF();
            n.LIZIZ(LJFF2, "");
            if (!LJFF2.isLogin()) {
                return false;
            }
            if (this.LJIILLIIL.LIZ() && !z2) {
                return false;
            }
            if (z || z2) {
                return true;
            }
            return false;
        }
        return z;
    }

    private final DBT LIZIZ(String str, long j) {
        return DAe.LIZ(0Bu.LIZ(this), this.LJIIJJI, new C34023h4(this, false, j, str, (C65674r1) null), 2);
    }

    public final <T> void LIZ(1Bn<T> r3, T t) {
        if (n.LIZ(Looper.getMainLooper(), Looper.myLooper())) {
            r3.setValue(t);
        } else {
            r3.postValue(t);
        }
    }

    public final void LIZ(String str, long j) {
        if (LIZ(str)) {
            AnonymousClass3PM.LIZIZ("SlideGuide", str + " is avoid show");
            return;
        }
        this.LJI = LIZIZ(str, j);
    }

    /* JADX WARNING: Illegal instructions before constructor call */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public /* synthetic */ SlideGuideViewModel(com.bytedance.hox.Hox r7, com.ss.android.ugc.aweme.homepage.ui.view.tab.HomeTabViewModel r8, X.C34053h7 r9, com.ss.android.ugc.aweme.homepage.api.data.HomePageDataViewModel r10) {
        /*
            r6 = this;
            X.DB2 r5 = X.DCr.LIZIZ
            r0 = r6
            r2 = r8
            r1 = r7
            r4 = r10
            r3 = r9
            r0.<init>(r1, r2, r3, r4, r5)
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: com.ss.android.ugc.aweme.homepage.ui.slide.SlideGuideViewModel.<init>(com.bytedance.hox.Hox, com.ss.android.ugc.aweme.homepage.ui.view.tab.HomeTabViewModel, X.3h7, com.ss.android.ugc.aweme.homepage.api.data.HomePageDataViewModel):void");
    }

    public SlideGuideViewModel(Hox hox, HomeTabViewModel homeTabViewModel, C34053h7 r6, HomePageDataViewModel homePageDataViewModel, DB2 db2) {
        M12.LIZ(hox, homeTabViewModel, r6, homePageDataViewModel, db2);
        this.LJIILLIIL = r6;
        this.LJIIZILJ = homePageDataViewModel;
        this.LJIIJJI = db2;
        this.LJIILJJIL = 7he.LIZ(C34033h5.LIZ);
        C06262ce r0 = new C06262ce();
        this.LIZ = r0;
        this.LIZIZ = r0;
        C06262ce r02 = new C06262ce();
        this.LIZJ = r02;
        this.LIZLLL = r02;
        this.LJFF = "For You";
        List<EiP> LJIIJJI2 = Lea.LJIIJJI(homeTabViewModel.LIZLLL());
        ArrayList arrayList = new ArrayList(9HM.LIZ(LJIIJJI2, 10));
        for (EiP LJ2 : LJIIJJI2) {
            arrayList.add(LJ2.LJ());
        }
        this.LJIIJ = Lea.LJII(arrayList);
        C34203hM.LIZ(hox, "HOME", new LsC<Bundle, C03012Pr>(this) {
            public final /* synthetic */ SlideGuideViewModel this$0;

            static {
                Covode.recordClassIndex(83165);
            }

            {
                this.this$0 = r2;
            }

            public final /* synthetic */ Object invoke(Object obj) {
                M12.LIZ(obj);
                this.this$0.LIZ();
                return C03012Pr.LIZ;
            }
        });
    }
}
