package com.ss.android.ugc.aweme.setting.page.authmanager;

import X.0AP;
import X.0Bv;
import X.0CH;
import X.2Pr;
import X.2cN;
import X.5Am;
import X.5An;
import X.5vY;
import X.5wO;
import X.Aid;
import X.B1N;
import X.B8T;
import X.C0435Cwt;
import X.C0643D4t;
import X.C5745F4z;
import X.CZv;
import X.D1G;
import X.DRZ;
import X.DUT;
import X.DV9;
import X.DVU;
import X.F4N;
import X.F4P;
import X.F4Q;
import X.F51;
import X.KEM;
import X.LsC;
import X.LsD;
import X.LsE;
import X.LsF;
import X.Lsh;
import X.M12;
import X.PHD;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.SparseArray;
import android.view.View;
import com.bytedance.covode.number.Covode;
import com.bytedance.jedi.arch.JediViewModel;
import com.bytedance.jedi.arch.lifecycleAwareLazy;
import com.bytedance.router.SmartRouter;
import com.ss.android.ugc.aweme.base.arch.JediBaseFragment;
import com.ss.android.ugc.aweme.setting.page.BasePage;
import com.ss.android.ugc.aweme.setting.viewmodel.AuthListViewModel;
import java.net.URLEncoder;
import java.util.Objects;

@CZv
public final class AuthManagementPage extends BasePage implements B1N<Aid>, 5vY, F51 {
    public Aid LJ = new Aid();
    public JediBaseFragment LJFF;
    public final lifecycleAwareLazy LJI;
    public SparseArray LJII;

    static {
        Covode.recordClassIndex(105935);
    }

    public final int LIZ() {
        return 2131561237;
    }

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

    public final void LJI() {
        SparseArray sparseArray = this.LJII;
        if (sparseArray != null) {
            sparseArray.clear();
        }
    }

    public final boolean getUniqueOnlyGlobal() {
        return true;
    }

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

    public final /* bridge */ /* synthetic */ 0Bv be_() {
        return this.LJ;
    }

    public final /* bridge */ /* synthetic */ 5An getReceiver() {
        return this;
    }

    public final 0CH getLifecycleOwner() {
        5wO.LIZJ(this);
        return this;
    }

    /* JADX WARNING: type inference failed for: r0v0, types: [X.DUz] */
    /* JADX WARNING: Multi-variable type inference failed */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public final X.C1325DUz getLifecycleOwnerHolder() {
        /*
            r1 = this;
            X.5wO.LIZ(r1)
            r0 = r1
            return r0
        */
        throw new UnsupportedOperationException("Method not decompiled: com.ss.android.ugc.aweme.setting.page.authmanager.AuthManagementPage.getLifecycleOwnerHolder():X.DUz");
    }

    /* JADX WARNING: type inference failed for: r0v0, types: [X.DUy<X.DVU>] */
    /* JADX WARNING: Multi-variable type inference failed */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public final X.C1324DUy<X.DVU> getReceiverHolder() {
        /*
            r1 = this;
            X.5wO.LIZIZ(r1)
            r0 = r1
            return r0
        */
        throw new UnsupportedOperationException("Method not decompiled: com.ss.android.ugc.aweme.setting.page.authmanager.AuthManagementPage.getReceiverHolder():X.DUy");
    }

    public final void LIZIZ() {
        LIZ((JediBaseFragment) AuthAppInfoListFragment.LIZLLL.LIZ(this));
    }

    public final boolean LIZLLL() {
        JediBaseFragment jediBaseFragment = this.LJFF;
        if (jediBaseFragment == null || (jediBaseFragment instanceof AuthAppInfoListFragment)) {
            LIZJ();
            return true;
        }
        LIZIZ();
        return true;
    }

    public AuthManagementPage() {
        D1G LIZ = KEM.LIZ.LIZ(AuthListViewModel.class);
        F4Q f4q = new F4Q(LIZ);
        this.LJI = new lifecycleAwareLazy(this, f4q, new F4N(this, f4q, LIZ, F4P.INSTANCE));
    }

    private final void LIZ(JediBaseFragment jediBaseFragment) {
        this.LJFF = jediBaseFragment;
        0AP LIZ = getChildFragmentManager().LIZ();
        LIZ.LIZIZ(2131362474, jediBaseFragment);
        LIZ.LIZJ();
    }

    public final void LIZ(C5745F4z f4z) {
        M12.LIZ(f4z);
        AuthAppInfoListFragment authAppInfoListFragment = this.LJFF;
        if (authAppInfoListFragment != null && (authAppInfoListFragment instanceof AuthAppInfoListFragment)) {
            Objects.requireNonNull(authAppInfoListFragment, "null cannot be cast to non-null type com.ss.android.ugc.aweme.setting.page.authmanager.AuthAppInfoListFragment");
            M12.LIZ(f4z);
            AuthListViewModel LIZJ = authAppInfoListFragment.LIZJ();
            M12.LIZ(f4z);
            LIZJ.LIZIZ.setValue(f4z);
        }
        if (!TextUtils.isEmpty(f4z.getPermissionUrl())) {
            SmartRouter.buildRoute(this, "aweme://webview?url=".concat(String.valueOf(URLEncoder.encode(f4z.getPermissionUrl(), "UTF-8")))).open();
        } else {
            LIZ((JediBaseFragment) new AuthAppInfoFragment());
        }
    }

    public final <VM1 extends JediViewModel<S1>, S1 extends 5Am, R> R withState(VM1 vm1, LsC<? super S1, ? extends R> lsC) {
        M12.LIZ(vm1, lsC);
        return 5wO.LIZ(vm1, lsC);
    }

    public final void onViewCreated(View view, Bundle bundle) {
        M12.LIZ(view);
        AuthManagementPage.super.onViewCreated(view, bundle);
        LIZ((JediBaseFragment) AuthAppInfoListFragment.LIZLLL.LIZ(this));
    }

    public final <S extends 5Am> 2cN subscribe(JediViewModel<S> jediViewModel, DUT<S> dut, LsD<? super DVU, ? super S, 2Pr> lsD) {
        M12.LIZ(jediViewModel, dut, lsD);
        return 5wO.LIZ(this, jediViewModel, dut, lsD);
    }

    public final <S extends 5Am, A> 2cN selectSubscribe(JediViewModel<S> jediViewModel, PHD<S, ? extends A> phd, DUT<DRZ<A>> dut, LsD<? super DVU, ? super A, 2Pr> lsD) {
        M12.LIZ(jediViewModel, phd, dut, lsD);
        return 5wO.LIZ(this, jediViewModel, phd, dut, lsD);
    }

    public final <S extends 5Am, A, B> 2cN selectSubscribe(JediViewModel<S> jediViewModel, PHD<S, ? extends A> phd, PHD<S, ? extends B> phd2, DUT<C0435Cwt<A, B>> dut, LsE<? super DVU, ? super A, ? super B, 2Pr> lsE) {
        M12.LIZ(jediViewModel, phd, phd2, dut, lsE);
        return 5wO.LIZ(this, jediViewModel, phd, phd2, dut, lsE);
    }

    public final <S extends 5Am, T> 2cN asyncSubscribe(JediViewModel<S> jediViewModel, PHD<S, ? extends B8T<? extends T>> phd, DUT<DRZ<B8T<T>>> dut, LsD<? super DVU, ? super Throwable, 2Pr> lsD, LsC<? super DVU, 2Pr> lsC, LsD<? super DVU, ? super T, 2Pr> lsD2) {
        M12.LIZ(jediViewModel, phd, dut);
        return 5wO.LIZ(this, jediViewModel, phd, dut, lsD, lsC, lsD2);
    }

    public final <S extends 5Am, A, B, C> 2cN selectSubscribe(JediViewModel<S> jediViewModel, PHD<S, ? extends A> phd, PHD<S, ? extends B> phd2, PHD<S, ? extends C> phd3, DUT<DV9<A, B, C>> dut, LsF<? super DVU, ? super A, ? super B, ? super C, 2Pr> lsF) {
        M12.LIZ(jediViewModel, phd, phd2, phd3, dut, lsF);
        return 5wO.LIZ(this, jediViewModel, phd, phd2, phd3, dut, lsF);
    }

    public final <S extends 5Am, A, B, C, D> 2cN selectSubscribe(JediViewModel<S> jediViewModel, PHD<S, ? extends A> phd, PHD<S, ? extends B> phd2, PHD<S, ? extends C> phd3, PHD<S, ? extends D> phd4, DUT<C0643D4t<A, B, C, D>> dut, Lsh<? super DVU, ? super A, ? super B, ? super C, ? super D, 2Pr> lsh) {
        M12.LIZ(jediViewModel, phd, phd2, phd3, phd4, dut, lsh);
        return 5wO.LIZ(this, jediViewModel, phd, phd2, phd3, phd4, dut, lsh);
    }
}
