package com.bytedance.creativex.recorder.filter.panel;

import X.1Bn;
import X.2HN;
import X.5Am;
import X.5Fu;
import X.5LC;
import X.5if;
import X.7he;
import X.C0547MYu;
import X.C1079Mjy;
import X.C1134Mkr;
import X.C1147Ml4;
import X.C1149Ml6;
import X.C1196Mlr;
import X.C1230MmP;
import X.C1231MmQ;
import X.C1232MmR;
import X.C1233MmS;
import X.C1235MmU;
import X.C1236MmV;
import X.C1238MmX;
import X.C1251Mmk;
import X.C1266Mmz;
import X.C1267Mn0;
import X.C2140N2p;
import X.C2282N8b;
import X.C2755NQg;
import X.C3936Nox;
import X.C4087NrO;
import X.C5137OJw;
import X.CrX;
import X.Crj;
import X.Cv9;
import X.Cwu;
import X.DAj;
import X.DBT;
import X.LWw;
import X.LsC;
import X.M12;
import X.PgU;
import X.S88;
import android.app.Activity;
import android.os.Handler;
import android.os.Looper;
import androidx.lifecycle.LiveData;
import com.bytedance.covode.number.Covode;
import com.bytedance.ui_component.LifecycleAwareViewModel;
import com.ss.android.ugc.aweme.filter.FilterBean;
import kotlin.h.b.n;

public final class FilterPanelViewModel extends LifecycleAwareViewModel<FilterPanelState> implements C1149Ml6 {
    public final C1134Mkr LIZ;
    public final Handler LIZIZ = new Handler(Looper.getMainLooper());
    public DBT LIZJ;
    public final 1Bn<C1147Ml4> LIZLLL = new 1Bn<>();
    public final C5137OJw<C1251Mmk> LJ;
    public final C4087NrO LJFF;
    public final C0547MYu LJI;
    public final LsC<Activity, Boolean> LJII;
    public final Crj LJIIL = 7he.LIZ(new C1238MmX(this));
    public final C1079Mjy LJIILIIL = new C1079Mjy();
    public final Crj LJIILJJIL = 7he.LIZ(C2282N8b.LIZ);
    public final PgU<C1251Mmk> LJIILL;
    public final boolean LJIILLIIL;

    static {
        Covode.recordClassIndex(25489);
    }

    public final Cv9 LIZLLL() {
        return (Cv9) this.LJIILJJIL.getValue();
    }

    public final PgU<C1251Mmk> LIZJ() {
        return this.LJIILL;
    }

    public final LiveData<C1147Ml4> LIZIZ() {
        return S88.LIZ(this.LIZLLL);
    }

    public final /* synthetic */ 5Am dU_() {
        return new FilterPanelState(new 5Fu(), (FilterBean) null, this.LJIILLIIL, LWw.LIZ(), (5LC) null, (Cwu) null, 48, (2HN) null);
    }

    public final void onCleared() {
        FilterPanelViewModel.super.onCleared();
        if (!this.LJIILIIL.isDisposed()) {
            this.LJIILIIL.dispose();
        }
        DAj.LIZIZ(LIZLLL());
    }

    public final void cl_() {
        FilterPanelViewModel.super.cl_();
        this.LIZ.getCurSelectedFilter().LIZ(this, new C1236MmV(this));
        this.LJI.LJFF().LIZJ().observe(this, new C1235MmU(this));
        this.LJI.LJFF().LIZIZ().observe(this, new C1196Mlr(this));
        LIZ((Cwu<Integer, String>) CrX.LIZ);
        if (C3936Nox.LIZIZ.LIZ()) {
            this.LJIILIIL.LIZ(this.LJI.LIZ(false).LIZ(C1266Mmz.LIZ, C1267Mn0.LIZ));
        } else {
            this.LJI.LIZ();
        }
    }

    public final void LIZ(Cwu<Integer, String> cwu) {
        LIZJ(new C1230MmP(cwu));
    }

    public final void LIZ(boolean z) {
        LIZLLL(new C1233MmS(this, z));
        ((C2140N2p) this.LJIIL.getValue()).LIZ(new C2755NQg(!z));
    }

    public final void LIZ(FilterBean filterBean, boolean z) {
        String str;
        if (5if.LIZ(this.LJI, filterBean)) {
            if (filterBean != null) {
                C1134Mkr mkr = this.LIZ;
                if (z) {
                    str = "filter_box";
                } else {
                    str = null;
                }
                mkr.setFilterChosen(filterBean, str, true, true, false);
                this.LIZ.setFilterDisable(false, "build_in");
                LIZJ(C1231MmQ.LIZ);
            }
            LIZLLL(new C1232MmR(filterBean));
        }
    }

    public FilterPanelViewModel(C4087NrO nrO, C0547MYu mYu, boolean z, LsC<? super Activity, Boolean> lsC) {
        M12.LIZ(nrO, mYu);
        this.LJFF = nrO;
        this.LJI = mYu;
        this.LJIILLIIL = z;
        this.LJII = lsC;
        Object LIZ2 = nrO.LIZ(C1134Mkr.class);
        n.LIZIZ(LIZ2, "");
        this.LIZ = (C1134Mkr) LIZ2;
        C5137OJw<C1251Mmk> oJw = new C5137OJw<>();
        n.LIZIZ(oJw, "");
        this.LJ = oJw;
        PgU<C1251Mmk> LIZJ2 = oJw.LIZJ();
        n.LIZIZ(LIZJ2, "");
        this.LJIILL = LIZJ2;
    }
}
