package com.ss.android.ugc.aweme.userservice;

import X.2HW;
import X.2ce;
import X.7ku;
import X.C0436Cwu;
import X.C3182E4k;
import X.C3563EJb;
import X.CwZ;
import X.D1M;
import X.EI0;
import X.EI3;
import X.EJT;
import X.EJV;
import X.EJX;
import X.Lnj;
import X.M12;
import X.MY0;
import X.Mfh;
import X.MgS;
import X.MgW;
import X.Pfk;
import X.PgU;
import X.PgV;
import X.PhE;
import X.Pl5;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.ss.android.ugc.aweme.base.api.BaseResponse;
import com.ss.android.ugc.aweme.profile.model.BlockStatus;
import com.ss.android.ugc.aweme.profile.model.FollowStatus;
import com.ss.android.ugc.aweme.profile.model.User;
import com.ss.android.ugc.aweme.userservice.api.IUserService;
import java.util.HashMap;
import java.util.Map;
import kotlin.h.b.n;

public class UserService implements IUserService {
    public EJX LIZ;
    public Map<String, Pl5<C0436Cwu<C3563EJb, FollowStatus>>> LIZIZ = new HashMap();

    static {
        Covode.recordClassIndex(121966);
    }

    public final MgS<String, User> LIZ() {
        LJ();
        return EJV.LIZ;
    }

    public final 2ce<FollowStatus> LIZIZ() {
        return 2HW.LIZ.LIZ("#FollowStatus");
    }

    public final 2ce<BlockStatus> LIZJ() {
        return 2HW.LIZ.LIZ("#BlockStatus");
    }

    public UserService() {
        if (!((Boolean) 7ku.LJIJ.getValue()).booleanValue()) {
            LJ();
        }
    }

    private synchronized void LJ() {
        MethodCollector.i(15863);
        if (this.LIZ == null) {
            this.LIZ = EJV.LIZIZ;
        }
        MethodCollector.o(15863);
    }

    public static IUserService LIZLLL() {
        MethodCollector.i(16041);
        IUserService iUserService = (IUserService) Lnj.LIZ(IUserService.class, false);
        if (iUserService != null) {
            MethodCollector.o(16041);
            return iUserService;
        }
        Object LIZIZ2 = Lnj.LIZIZ(IUserService.class, false);
        if (LIZIZ2 != null) {
            IUserService iUserService2 = (IUserService) LIZIZ2;
            MethodCollector.o(16041);
            return iUserService2;
        }
        if (Lnj.bN == null) {
            synchronized (IUserService.class) {
                try {
                    if (Lnj.bN == null) {
                        Lnj.bN = new UserService();
                    }
                } catch (Throwable th) {
                    MethodCollector.o(16041);
                    throw th;
                }
            }
        }
        UserService userService = (UserService) Lnj.bN;
        MethodCollector.o(16041);
        return userService;
    }

    public final PgU<MY0<User>> LIZ(String str) {
        LJ();
        EJX ejx = this.LIZ;
        M12.LIZ(str);
        return Mfh.LIZ(ejx.LJ).LIZ(str, new MgW[0]);
    }

    public final PgU<BaseResponse> LIZ(String str, String str2) {
        LJ();
        EJX ejx = this.LIZ;
        M12.LIZ(str, str2);
        return ejx.LIZJ.LIZJ(new EI3(str, str2));
    }

    public final FollowStatus LIZ(String str, int i, String str2) {
        LJ();
        int i2 = i;
        String str3 = str2;
        String str4 = str;
        FollowStatus LIZ2 = CommonFollowApi.LIZ(str4, str3, i2, -1, -1, "", -1, "", (Map<String, String>) null, (String) null);
        Pl5<C0436Cwu<C3563EJb, FollowStatus>> pl5 = this.LIZ.LIZLLL;
        C3563EJb eJb = r4;
        C3563EJb eJb2 = new C3563EJb(str4, str3, i2, -1, -1, "", -1, (String) null, (String) null, (String) null, (Integer) null);
        pl5.onNext(new C0436Cwu(eJb, LIZ2));
        return LIZ2;
    }

    public final PgV<FollowStatus> LIZ(String str, String str2, int i, int i2, int i3, String str3, int i4, String str4) {
        C3563EJb eJb;
        Integer num;
        LJ();
        EJX ejx = this.LIZ;
        String str5 = str;
        String str6 = str2;
        M12.LIZ(str5, str6);
        C3182E4k LIZ2 = EI0.LIZ.LIZ(str5);
        C0436Cwu cwu = null;
        String str7 = str3;
        int i5 = i3;
        int i6 = i4;
        String str8 = str4;
        int i7 = i;
        int i8 = i2;
        if (LIZ2 != null) {
            cwu = CwZ.LIZ(LIZ2, 1);
        } else {
            C3182E4k LIZIZ2 = EI0.LIZ.LIZIZ(str5);
            if (LIZIZ2 != null) {
                cwu = CwZ.LIZ(LIZIZ2, 0);
            }
            eJb = new C3563EJb(str5, str6, i7, i8, i5, str7, i6, str8);
            PgU LIZJ = ejx.LIZIZ.LIZJ(eJb);
            EJT ejt = new EJT(ejx, cwu, str5, eJb);
            D1M.LIZ(ejt, "onAfterNext is null");
            PgV<FollowStatus> LIZ3 = PgV.LIZ(PhE.LIZ(new Pfk(LIZJ, ejt)));
            n.LIZIZ(LIZ3, "");
            return LIZ3;
        }
        if (!(cwu == null || (num = (Integer) cwu.getSecond()) == null || (num.intValue() != 1 && num.intValue() != 0))) {
            C3182E4k e4k = (C3182E4k) cwu.getFirst();
            eJb = new C3563EJb(str5, str6, i7, i8, i5, str7, i6, str8, e4k.LIZIZ, e4k.LIZJ, (Integer) cwu.getSecond());
            PgU LIZJ2 = ejx.LIZIZ.LIZJ(eJb);
            EJT ejt2 = new EJT(ejx, cwu, str5, eJb);
            D1M.LIZ(ejt2, "onAfterNext is null");
            PgV<FollowStatus> LIZ32 = PgV.LIZ(PhE.LIZ(new Pfk(LIZJ2, ejt2)));
            n.LIZIZ(LIZ32, "");
            return LIZ32;
        }
        eJb = new C3563EJb(str5, str6, i7, i8, i5, str7, i6, str8);
        PgU LIZJ22 = ejx.LIZIZ.LIZJ(eJb);
        EJT ejt22 = new EJT(ejx, cwu, str5, eJb);
        D1M.LIZ(ejt22, "onAfterNext is null");
        PgV<FollowStatus> LIZ322 = PgV.LIZ(PhE.LIZ(new Pfk(LIZJ22, ejt22)));
        n.LIZIZ(LIZ322, "");
        return LIZ322;
    }

    public final FollowStatus LIZ(String str, String str2, int i, int i2, int i3, String str3, int i4, String str4, Map<String, String> map, String str5) {
        LJ();
        String str6 = str3;
        int i5 = i3;
        int i6 = i2;
        int i7 = i;
        String str7 = str2;
        String str8 = str;
        int i8 = i4;
        String str9 = str8;
        String str10 = str7;
        int i9 = i7;
        int i10 = i6;
        int i11 = i5;
        String str11 = str6;
        int i12 = i8;
        FollowStatus LIZ2 = CommonFollowApi.LIZ(str9, str10, i9, i10, i11, str11, i12, str4, map, str5);
        Pl5<C0436Cwu<C3563EJb, FollowStatus>> pl5 = this.LIZ.LIZLLL;
        C3563EJb eJb = r4;
        C3563EJb eJb2 = new C3563EJb(str8, str7, i7, i5, i6, str6, i8, (String) null, (String) null, (String) null, (Integer) null);
        pl5.onNext(new C0436Cwu(eJb, LIZ2));
        return LIZ2;
    }
}
