package com.ss.android.ugc.aweme.friends.service;

import X.1hK;
import X.2Eq;
import X.2YN;
import X.2f8;
import X.2zb;
import X.46i;
import X.7q0;
import X.8Zb;
import X.9Y3;
import X.B9C;
import X.C1858DgU;
import X.C1916DhQ;
import X.C3172E4a;
import X.C3177E4f;
import X.C3185E4n;
import X.C4113Ebl;
import X.C4258Ee6;
import X.C4260Ee8;
import X.C4383Eg7;
import X.C4543Eih;
import X.C5054Eqw;
import X.C5287Euh;
import X.C5463ExX;
import X.C5481Exp;
import X.C5502EyA;
import X.C5503EyB;
import X.C5504EyC;
import X.C5512EyK;
import X.C5513EyL;
import X.C5514EyM;
import X.C5515EyN;
import X.C5517EyP;
import X.C5518EyQ;
import X.C5539Eyl;
import X.C5542Eyo;
import X.C5640F0y;
import X.C5656F1o;
import X.C5662F1u;
import X.Cb7;
import X.E09;
import X.E0A;
import X.E0C;
import X.ESC;
import X.F1O;
import X.JXH;
import X.Lnj;
import X.Ls2;
import X.M12;
import X.Mk2;
import X.Mk3;
import X.PgU;
import X.PgX;
import X.PhE;
import X.PlI;
import X.Ppz;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import androidx.fragment.app.Fragment;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.bytedance.ies.abmock.SettingsManager;
import com.bytedance.keva.Keva;
import com.ss.android.ugc.aweme.IAccountUserService;
import com.ss.android.ugc.aweme.find.ui.FindFriendsActivity;
import com.ss.android.ugc.aweme.friends.model.Friend;
import com.ss.android.ugc.aweme.friends.model.FriendList;
import com.ss.android.ugc.aweme.friends.model.ShortenUrlModel;
import com.ss.android.ugc.aweme.friends.ui.ContactsActivity;
import com.ss.android.ugc.aweme.friends.ui.InviteFriendsActivity;
import com.ss.android.ugc.aweme.friends.ui.InviteUserListActivity;
import com.ss.android.ugc.aweme.profile.model.SocialPlatformSetting;
import com.ss.android.ugc.aweme.profile.model.User;
import com.ss.android.ugc.aweme.recommend.users.RecommendUserServiceImpl;
import com.ss.android.ugc.aweme.relation.dialog.SocialRecFriendsConditionViewModel;
import com.ss.android.ugc.aweme.ufr.contact.ContactUFR;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import kotlin.h.b.n;

public final class FriendsServiceImpl implements IFriendsService {
    public ISocialFriendsService LIZ;

    static {
        Covode.recordClassIndex(81280);
    }

    public final Class<? extends F1O> LJ() {
        return ContactUFR.class;
    }

    public final C1858DgU LJFF() {
        return C5504EyC.LIZ;
    }

    public final Class<? extends F1O> LJII() {
        return C5640F0y.class;
    }

    public final C4113Ebl LJIIIIZZ() {
        return C5503EyB.LIZ;
    }

    public final Class<? extends Activity> LJIIJJI() {
        return InviteUserListActivity.class;
    }

    public final void LIZ(String str, boolean z) {
        String str2 = str;
        M12.LIZ(str2);
        C5481Exp.LIZJ.LIZ(str2, z, "", "", "", "");
    }

    public final boolean LIZ(Activity activity) {
        M12.LIZ(activity);
        return Ppz.LIZ(activity);
    }

    public final Intent LIZ(Context context, int i, int i2, String str, String str2) {
        M12.LIZ(str, str2);
        if (context == null) {
            return null;
        }
        Intent intent = new Intent(context, FindFriendsActivity.class);
        intent.putExtra("previous_page", str2);
        return intent;
    }

    public final boolean LIZ(User user) {
        if (user == null || user.getFollowerCount() < 1000) {
            return true;
        }
        return (user == null || user.getMutualStruct() == null) ? false : true;
    }

    /* JADX WARNING: Code restructure failed: missing block: B:10:0x0024, code lost:
        if (r1 == null) goto L_0x0026;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:11:0x0026, code lost:
        kotlin.h.b.n.LIZIZ();
     */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public final void LIZ(int r10, java.lang.String r11, java.lang.String r12, android.content.Context r13, int r14, X.C4485Ehl r15) {
        /*
            r9 = this;
            r6 = r12
            r5 = r11
            r7 = r13
            X.M12.LIZ(r5, r6, r7)
            X.EyQ r0 = X.C5518EyQ.LJ
            X.EyK r4 = r0.LIZIZ(r10)
            X.Eya r0 = X.C5528Eya.POP_UP_TIME_TYPE
            r4.LIZ(r0)
            boolean r0 = r4.LIZ
            if (r0 != 0) goto L_0x0019
            boolean r0 = r4.LIZIZ
            if (r0 == 0) goto L_0x0038
        L_0x0019:
            r2 = r7
        L_0x001a:
            r1 = 0
            if (r2 == 0) goto L_0x0026
            boolean r0 = r2 instanceof X.1hK
            if (r0 == 0) goto L_0x0039
            r1 = r2
            X.1hK r1 = (X.1hK) r1
            if (r1 != 0) goto L_0x0029
        L_0x0026:
            kotlin.h.b.n.LIZIZ()
        L_0x0029:
            X.EyH r2 = new X.EyH
            r8 = r15
            r3 = r14
            r2.<init>(r3, r4, r5, r6, r7, r8)
            X.3vI r0 = new X.3vI
            r0.<init>(r1, r2)
            X.T25.LIZIZ(r0)
        L_0x0038:
            return
        L_0x0039:
            boolean r0 = r2 instanceof android.content.ContextWrapper
            if (r0 == 0) goto L_0x0026
            android.content.ContextWrapper r2 = (android.content.ContextWrapper) r2
            android.content.Context r2 = r2.getBaseContext()
            goto L_0x001a
        */
        throw new UnsupportedOperationException("Method not decompiled: com.ss.android.ugc.aweme.friends.service.FriendsServiceImpl.LIZ(int, java.lang.String, java.lang.String, android.content.Context, int, X.Ehl):void");
    }

    /* JADX WARNING: Code restructure failed: missing block: B:14:0x003e, code lost:
        if (r1 == null) goto L_0x0040;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:15:0x0040, code lost:
        kotlin.h.b.n.LIZIZ();
     */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public final void LIZ(int r9, java.lang.String r10, java.lang.String r11, android.content.Context r12, int r13) {
        /*
            r8 = this;
            r6 = r11
            r5 = r10
            r7 = r12
            X.M12.LIZ(r5, r6, r7)
            X.EyQ r0 = X.C5518EyQ.LJ
            X.EyK r4 = r0.LIZIZ(r9)
            X.Eya r0 = X.C5528Eya.POP_UP_TIME_TYPE
            r4.LIZ(r0)
            com.ss.android.ugc.aweme.IAccountUserService r1 = X.46i.LJFF()
            java.lang.String r0 = ""
            kotlin.h.b.n.LIZIZ(r1, r0)
            com.ss.android.ugc.aweme.profile.model.User r1 = r1.getCurUser()
            r2 = 1
            r0 = 0
            if (r1 == 0) goto L_0x005d
            int r1 = r1.getCompleteProfileGuideStrategy()
            r0 = 5
            if (r1 != r0) goto L_0x005d
            boolean r0 = r4.LIZIZ
            if (r0 == 0) goto L_0x005d
        L_0x002d:
            r4.LIZIZ = r2
            boolean r0 = r4.LIZ
            if (r0 == 0) goto L_0x0051
            r2 = r7
        L_0x0034:
            r1 = 0
            if (r2 == 0) goto L_0x0040
            boolean r0 = r2 instanceof X.1hK
            if (r0 == 0) goto L_0x0052
            r1 = r2
            X.1hK r1 = (X.1hK) r1
            if (r1 != 0) goto L_0x0043
        L_0x0040:
            kotlin.h.b.n.LIZIZ()
        L_0x0043:
            X.EyG r2 = new X.EyG
            r3 = r13
            r2.<init>(r3, r4, r5, r6, r7)
            X.3vI r0 = new X.3vI
            r0.<init>(r1, r2)
            X.T25.LIZIZ(r0)
        L_0x0051:
            return
        L_0x0052:
            boolean r0 = r2 instanceof android.content.ContextWrapper
            if (r0 == 0) goto L_0x0040
            android.content.ContextWrapper r2 = (android.content.ContextWrapper) r2
            android.content.Context r2 = r2.getBaseContext()
            goto L_0x0034
        L_0x005d:
            r2 = 0
            goto L_0x002d
        */
        throw new UnsupportedOperationException("Method not decompiled: com.ss.android.ugc.aweme.friends.service.FriendsServiceImpl.LIZ(int, java.lang.String, java.lang.String, android.content.Context, int):void");
    }

    public final void LIZ(String str, String str2, boolean z, String str3, Map<String, String> map) {
        String str4 = str;
        String str5 = str2;
        M12.LIZ(str4);
        C4258Ee6 ee6 = C4258Ee6.LIZ;
        if (str5 == null) {
            str5 = "";
        }
        ee6.LIZ(str4, str5, z, str3, map);
    }

    /* JADX WARNING: Code restructure failed: missing block: B:6:0x0012, code lost:
        if (r1 == null) goto L_0x0014;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:7:0x0014, code lost:
        kotlin.h.b.n.LIZIZ();
     */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public final void LIZ(X.C5512EyK r10, java.lang.String r11, java.lang.String r12, android.content.Context r13, int r14, X.C4485Ehl r15) {
        /*
            r9 = this;
            r4 = r11
            r3 = r10
            r5 = r12
            r7 = r13
            X.M12.LIZ(r3, r4, r5, r7)
            r2 = r7
        L_0x0008:
            r1 = 0
            if (r2 == 0) goto L_0x0014
            boolean r0 = r2 instanceof X.1hK
            if (r0 == 0) goto L_0x0027
            r1 = r2
            X.1hK r1 = (X.1hK) r1
            if (r1 != 0) goto L_0x0017
        L_0x0014:
            kotlin.h.b.n.LIZIZ()
        L_0x0017:
            X.EyJ r2 = new X.EyJ
            r8 = r15
            r6 = r14
            r2.<init>(r3, r4, r5, r6, r7, r8)
            X.3vI r0 = new X.3vI
            r0.<init>(r1, r2)
            X.T25.LIZIZ(r0)
            return
        L_0x0027:
            boolean r0 = r2 instanceof android.content.ContextWrapper
            if (r0 == 0) goto L_0x0014
            android.content.ContextWrapper r2 = (android.content.ContextWrapper) r2
            android.content.Context r2 = r2.getBaseContext()
            goto L_0x0008
        */
        throw new UnsupportedOperationException("Method not decompiled: com.ss.android.ugc.aweme.friends.service.FriendsServiceImpl.LIZ(X.EyK, java.lang.String, java.lang.String, android.content.Context, int, X.Ehl):void");
    }

    public final void LIZ(Activity activity, C5517EyP eyP) {
        M12.LIZ(activity, eyP);
        JXH.LIZ(activity, new String[]{"android.permission.READ_CONTACTS"}, new C5515EyN(eyP, activity));
    }

    public final boolean LIZ(boolean z) {
        if (((Boolean) 7q0.LIZ.getValue()).booleanValue()) {
            if (!C5502EyA.LJ()) {
                Keva keva = C5502EyA.LIZ;
                if (keva.getBoolean("key_cache_ready_" + C5502EyA.LIZIZ.LJII(), false) && !C5502EyA.LJFF() && z && C5502EyA.LIZIZ() == 3 && !ESC.LJFF()) {
                    IAccountUserService LJFF = 46i.LJFF();
                    n.LIZIZ(LJFF, "");
                    if (LJFF.isLogin()) {
                        return true;
                    }
                }
            }
            return false;
        }
        IAccountUserService LJFF2 = 46i.LJFF();
        n.LIZIZ(LJFF2, "");
        if (LJFF2.isLogin() && !ESC.LJFF() && !C5502EyA.LJ()) {
            Keva keva2 = C5502EyA.LIZ;
            StringBuilder sb = new StringBuilder("key_cache_ready_");
            sb.append(C5502EyA.LIZIZ.LJII());
            return keva2.getBoolean(sb.toString(), false) && !C5502EyA.LJFF() && z && C5502EyA.LIZIZ() == 3;
        }
    }

    public final 8Zb LIZJ() {
        return new C5662F1u();
    }

    public final IContactService LIZLLL() {
        return new ContactServiceImpl();
    }

    public final boolean LJI() {
        return C5504EyC.LIZ.LIZ();
    }

    public final 2Eq LJIIJ() {
        return new C3185E4n();
    }

    public final C4543Eih LJIIL() {
        return C4260Ee8.LIZLLL.LIZ();
    }

    public final boolean LJIILIIL() {
        return C5504EyC.LIZ.LIZIZ();
    }

    public final E0A LIZIZ() {
        return (E09) E0C.LIZIZ.getValue();
    }

    public final long LJIIIZ() {
        return 9Y3.LIZ().LIZ("facebook_upload_interval", 0) * 1000;
    }

    public final boolean LJIILJJIL() {
        if (B9C.LIZ.LIZ() == 2) {
            return true;
        }
        return false;
    }

    public final boolean LJIILLIIL() {
        if (SettingsManager.LIZ().LIZ("hide_find_friends_entrance", 0) == 1) {
            return true;
        }
        return false;
    }

    public final ISocialFriendsService LJIIZILJ() {
        if (this.LIZ == null) {
            this.LIZ = new SocialFriendsService();
        }
        return this.LIZ;
    }

    public final C3177E4f LIZ() {
        return (C3172E4a) E0C.LIZ.getValue();
    }

    public final void LJIILL() {
        Keva keva = C5502EyA.LIZ;
        keva.storeBoolean("key_rec_friends_has_shown_" + C5502EyA.LIZIZ.LJII(), true);
        Keva keva2 = C5502EyA.LIZ;
        keva2.storeBoolean("key_cache_ready_" + C5502EyA.LIZIZ.LJII(), false);
    }

    public static IFriendsService LJIJI() {
        MethodCollector.i(8264);
        IFriendsService iFriendsService = (IFriendsService) Lnj.LIZ(IFriendsService.class, false);
        if (iFriendsService != null) {
            MethodCollector.o(8264);
            return iFriendsService;
        }
        Object LIZIZ = Lnj.LIZIZ(IFriendsService.class, false);
        if (LIZIZ != null) {
            IFriendsService iFriendsService2 = (IFriendsService) LIZIZ;
            MethodCollector.o(8264);
            return iFriendsService2;
        }
        if (Lnj.LLLFZ == null) {
            synchronized (IFriendsService.class) {
                try {
                    if (Lnj.LLLFZ == null) {
                        Lnj.LLLFZ = new FriendsServiceImpl();
                    }
                } catch (Throwable th) {
                    MethodCollector.o(8264);
                    throw th;
                }
            }
        }
        FriendsServiceImpl friendsServiceImpl = (FriendsServiceImpl) Lnj.LLLFZ;
        MethodCollector.o(8264);
        return friendsServiceImpl;
    }

    public final void LJIJ() {
        IAccountUserService LJFF = 46i.LJFF();
        n.LIZIZ(LJFF, "");
        if (LJFF.isLogin() && !C5502EyA.LJ()) {
            int LIZ2 = SettingsManager.LIZ().LIZ("obtain_friends_strategy_when_upgrading", 0);
            if (C5502EyA.LIZ.getBoolean("key_new_version", false) && LIZ2 == 3) {
                C5502EyA.LIZ.storeInt("key_display_strategy", LIZ2);
                C5502EyA.LIZ.storeLong("key_rec_friends_frequency", SettingsManager.LIZ().LIZ("obtain_friends_strategy_when_upgrading_frequency", 30));
                boolean LIZJ = C5502EyA.LIZJ();
                boolean LIZLLL = C5502EyA.LIZLLL();
                C5502EyA.LIZ.storeString("key_check_status", "value_check_start");
                if (!LIZJ && !LIZLLL) {
                    C5502EyA.LIZIZ.LIZ();
                }
                C5502EyA.LIZ.storeString("key_check_status", "value_check_hasdata");
                if (LIZJ || LIZLLL) {
                    C5502EyA.LIZIZ.LIZ();
                }
            }
        }
    }

    public final C5512EyK LIZ(int i) {
        return C5518EyQ.LJ.LIZ(i);
    }

    public final Cb7 LIZ(Context context) {
        M12.LIZ(context);
        return new C5656F1o(context, (byte) 0);
    }

    public final void LIZIZ(String str) {
        M12.LIZ(str);
        C5503EyB.LIZ.LIZ(true);
        C5463ExX.LIZ().syncSocialRelationStatusInRx(2, true, false).LIZ(new C5513EyL(str)).LIZIZ(PhE.LIZIZ(PlI.LIZJ)).LIZ(Mk2.LIZ(Mk3.LIZ)).LIZLLL(new C5514EyM(str));
    }

    public final C5287Euh LIZ(1hK r2) {
        M12.LIZ(r2);
        return SocialRecFriendsConditionViewModel.LIZJ.LIZ(r2);
    }

    public final PgU<ShortenUrlModel> LIZ(String str) {
        M12.LIZ(str);
        PgU<ShortenUrlModel> shortenUrlRx = C5463ExX.LIZ().shortenUrlRx(str);
        n.LIZIZ(shortenUrlRx, "");
        return shortenUrlRx;
    }

    public final void LIZIZ(boolean z) {
        IAccountUserService LJFF = 46i.LJFF();
        n.LIZIZ(LJFF, "");
        User curUser = LJFF.getCurUser();
        n.LIZIZ(curUser, "");
        List<SocialPlatformSetting> socialPlatformSettings = curUser.getSocialData().getSocialPlatformSettings();
        if (socialPlatformSettings != null) {
            for (SocialPlatformSetting next : socialPlatformSettings) {
                if (next.getSocialPlatform() == 1) {
                    next.setSyncStatus(z);
                }
            }
        }
    }

    public final boolean LIZIZ(Activity activity) {
        if ((activity instanceof ContactsActivity) || (activity instanceof InviteFriendsActivity)) {
            return true;
        }
        return false;
    }

    public final C5054Eqw LIZ(Fragment fragment, Ls2<String> ls2) {
        M12.LIZ(fragment, ls2);
        1hK activity = fragment.getActivity();
        if (activity == null) {
            return null;
        }
        2f8 r1 = SocialRecFriendsConditionViewModel.LIZJ;
        n.LIZIZ(activity, "");
        return new C5542Eyo(fragment, r1.LIZ(activity), ls2);
    }

    public final void LIZIZ(String str, boolean z) {
        M12.LIZ(str);
        C5504EyC.LIZ.LIZ(true);
        PgU LIZ2 = C5463ExX.LIZ().syncSocialRelationStatusInRx(1, true, false).LIZ(new C4383Eg7(str, z)).LIZ(new C5539Eyl(str, z), false).LIZ(2zb.LIZ, false).LIZIZ(PhE.LIZIZ(PlI.LIZJ)).LIZ(Mk2.LIZ(Mk3.LIZ));
        2YN r0 = PgX.LIZLLL;
        LIZ2.LIZ(r0, r0);
    }

    public final PgU<FriendList<Friend>> LIZ(String str, int i) {
        M12.LIZ(str);
        PgU<FriendList<Friend>> socialFriendsWithScene = C5463ExX.LIZ().getSocialFriendsWithScene("facebook", C5503EyB.LIZ.LIZ(str), (String) null, Long.valueOf(C5503EyB.LIZ.LIZLLL(str)), Integer.valueOf(i));
        n.LIZIZ(socialFriendsWithScene, "");
        return socialFriendsWithScene;
    }

    public final Intent LIZ(Activity activity, int i, String str) {
        M12.LIZ(activity, str);
        Intent intent = new Intent(activity, InviteUserListActivity.class);
        intent.putExtra("type", i);
        intent.putExtra("enter_from", str);
        return intent;
    }

    public final C1916DhQ LIZ(Context context, HashMap<String, Boolean> hashMap, boolean z, boolean z2) {
        M12.LIZ(context, hashMap);
        return (C1916DhQ) RecommendUserServiceImpl.LIZ().LIZ(context, hashMap);
    }

    public final void LIZIZ(String str, String str2, boolean z, String str3, Map<String, String> map) {
        String str4 = str;
        String str5 = str2;
        M12.LIZ(str4);
        C4258Ee6 ee6 = C4258Ee6.LIZ;
        if (str5 == null) {
            str5 = "";
        }
        ee6.LIZIZ(str4, str5, z, str3, map);
    }

    /* JADX WARNING: Code restructure failed: missing block: B:10:0x001f, code lost:
        if (r1 == null) goto L_0x0021;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:11:0x0021, code lost:
        kotlin.h.b.n.LIZIZ();
     */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public final void LIZIZ(int r9, java.lang.String r10, java.lang.String r11, android.content.Context r12, int r13) {
        /*
            r8 = this;
            r5 = r11
            r4 = r10
            r7 = r12
            X.M12.LIZ(r4, r5, r7)
            X.EyQ r0 = X.C5518EyQ.LJ
            X.EyK r3 = r0.LIZ(r9)
            boolean r0 = r3.LIZ
            if (r0 != 0) goto L_0x0014
            boolean r0 = r3.LIZIZ
            if (r0 == 0) goto L_0x0032
        L_0x0014:
            r2 = r7
        L_0x0015:
            r1 = 0
            if (r2 == 0) goto L_0x0021
            boolean r0 = r2 instanceof X.1hK
            if (r0 == 0) goto L_0x0033
            r1 = r2
            X.1hK r1 = (X.1hK) r1
            if (r1 != 0) goto L_0x0024
        L_0x0021:
            kotlin.h.b.n.LIZIZ()
        L_0x0024:
            X.EyI r2 = new X.EyI
            r6 = r13
            r2.<init>(r3, r4, r5, r6, r7)
            X.3vI r0 = new X.3vI
            r0.<init>(r1, r2)
            X.T25.LIZIZ(r0)
        L_0x0032:
            return
        L_0x0033:
            boolean r0 = r2 instanceof android.content.ContextWrapper
            if (r0 == 0) goto L_0x0021
            android.content.ContextWrapper r2 = (android.content.ContextWrapper) r2
            android.content.Context r2 = r2.getBaseContext()
            goto L_0x0015
        */
        throw new UnsupportedOperationException("Method not decompiled: com.ss.android.ugc.aweme.friends.service.FriendsServiceImpl.LIZIZ(int, java.lang.String, java.lang.String, android.content.Context, int):void");
    }
}
