package com.ss.android.ugc.aweme.compliance.business.serviceimpl;

import X.0Gp;
import X.7AW;
import X.7he;
import X.AnonymousClass2HN;
import X.AnonymousClass44O;
import X.AnonymousClass44P;
import X.AnonymousClass44T;
import X.AnonymousClass44V;
import X.AnonymousClass44W;
import X.AnonymousClass44Y;
import X.AnonymousClass465;
import X.C42363uW;
import X.C42373uX;
import X.C42663v0;
import X.C42673v1;
import X.C42683v2;
import X.C469344n;
import X.C474046i;
import X.Crj;
import X.ESC;
import X.Lnj;
import X.M12;
import X.Rko;
import X.S71;
import X.SfZ;
import android.app.Activity;
import android.content.Context;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.bytedance.router.SmartRoute;
import com.bytedance.router.SmartRouter;
import com.ss.android.ugc.aweme.account.experiment.MultiAccountService;
import com.ss.android.ugc.aweme.compliance.api.services.agegate.IAgeGateService;
import com.ss.android.ugc.aweme.framework.services.IUserService;
import com.ss.android.ugc.aweme.profile.model.AgeGateInfo;
import com.ss.android.ugc.aweme.profile.model.User;
import java.util.HashMap;
import java.util.List;
import kotlin.h.b.n;

public final class AgeGateServiceImpl implements IAgeGateService {
    public static S71 LIZIZ;
    public static final AnonymousClass44Y LIZJ = new AnonymousClass44Y((byte) 0);
    public static String LJ;
    public String LIZ;
    public final Crj LIZLLL = 7he.LIZ(AnonymousClass44W.LIZ);

    static {
        Covode.recordClassIndex(61131);
    }

    private final IUserService LJIIJ() {
        return (IUserService) this.LIZLLL.getValue();
    }

    public final String LJI() {
        return LJ;
    }

    public final String LJIIIIZZ() {
        return this.LIZ;
    }

    public final void LJII() {
        this.LIZ = null;
        0Gp.LIZ(new Rko(this));
    }

    public final void LIZIZ() {
        Activity LJIIIZ;
        if (ESC.LJFF() && (LJIIIZ = SfZ.LJIJ.LJIIIZ()) != null && !AnonymousClass465.LIZ().LIZ()) {
            C474046i.LIZJ().LIZ(LJIIIZ);
        }
    }

    public final boolean LJ() {
        int i = C42683v2.LIZIZ[LIZ().ordinal()];
        if (i == 1) {
            return false;
        }
        if (i == 2 || i == 3) {
            return true;
        }
        throw new 7AW();
    }

    public final C42673v1 LIZ() {
        if (MultiAccountService.LIZJ().LIZIZ()) {
            return C42673v1.PASS;
        }
        if (C42363uW.LJI.LIZJ() != C42673v1.PASS) {
            return C42363uW.LJI.LIZJ();
        }
        return C42673v1.EU_EEA;
    }

    public final boolean LIZJ() {
        Long valueOf;
        if (C42363uW.LJI.LIZJ() != C42673v1.US_FTC) {
            return false;
        }
        C42373uX r1 = C42363uW.LIZ;
        if (r1.LJFF != null) {
            valueOf = r1.LJFF;
        } else {
            valueOf = Long.valueOf(r1.LIZ.getLong("age_gate_block_device_register_expire_time", 0));
        }
        if (valueOf == null) {
            return false;
        }
        long longValue = valueOf.longValue();
        if (longValue <= 0 || System.currentTimeMillis() / 1000 > longValue) {
            return false;
        }
        return true;
    }

    public final boolean LIZLLL() {
        C42663v0 r2 = C42673v1.Companion;
        IUserService LJIIJ = LJIIJ();
        n.LIZIZ(LJIIJ, "");
        User currentUser = LJIIJ.getCurrentUser();
        n.LIZIZ(currentUser, "");
        int i = C42683v2.LIZ[r2.LIZ(currentUser.getAgeGateAction()).ordinal()];
        if (i == 1) {
            return false;
        }
        if (i == 2 || i == 3) {
            return true;
        }
        throw new 7AW();
    }

    public final AnonymousClass44V LJFF() {
        String str;
        IUserService LJIIJ = LJIIJ();
        n.LIZIZ(LJIIJ, "");
        User currentUser = LJIIJ.getCurrentUser();
        n.LIZIZ(currentUser, "");
        AgeGateInfo ageGateInfo = currentUser.getAgeGateInfo();
        String str2 = null;
        if (ageGateInfo != null) {
            str = ageGateInfo.getDefaultDate();
            str2 = ageGateInfo.getUpperBoundDate();
        } else {
            str = null;
        }
        return new AnonymousClass44V(str, str2);
    }

    public static IAgeGateService LJIIIZ() {
        MethodCollector.i(1636);
        IAgeGateService iAgeGateService = (IAgeGateService) Lnj.LIZ(IAgeGateService.class, false);
        if (iAgeGateService != null) {
            MethodCollector.o(1636);
            return iAgeGateService;
        }
        Object LIZIZ2 = Lnj.LIZIZ(IAgeGateService.class, false);
        if (LIZIZ2 != null) {
            IAgeGateService iAgeGateService2 = (IAgeGateService) LIZIZ2;
            MethodCollector.o(1636);
            return iAgeGateService2;
        }
        if (Lnj.LLF == null) {
            synchronized (IAgeGateService.class) {
                try {
                    if (Lnj.LLF == null) {
                        Lnj.LLF = new AgeGateServiceImpl();
                    }
                } catch (Throwable th) {
                    MethodCollector.o(1636);
                    throw th;
                }
            }
        }
        AgeGateServiceImpl ageGateServiceImpl = (AgeGateServiceImpl) Lnj.LLF;
        MethodCollector.o(1636);
        return ageGateServiceImpl;
    }

    public final void LIZ(String str) {
        LJ = str;
    }

    /* JADX WARNING: Code restructure failed: missing block: B:53:0x00f8, code lost:
        if (r0 == null) goto L_0x00fa;
     */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public final void LIZ(android.content.Context r19, java.util.HashMap<java.lang.String, java.lang.String> r20, X.S71 r21) {
        /*
            r18 = this;
            r2 = r21
            r0 = r19
            X.M12.LIZ(r0, r2)
            X.S71 r1 = LIZIZ
            if (r1 == 0) goto L_0x000e
            r1.LIZ()
        L_0x000e:
            LIZIZ = r2
            X.44n r3 = new X.44n
            r4 = 0
            r5 = 0
            r6 = 0
            com.ss.android.ugc.aweme.compliance.api.services.agegate.IAgeGateService r1 = com.ss.android.ugc.aweme.compliance.api.a.LJII()
            X.44V r7 = r1.LJFF()
            r8 = 0
            r9 = 23
            r10 = 0
            r3.<init>(r4, r5, r6, r7, r8, r9, r10)
            java.lang.String r1 = "//compliance/age/verify"
            com.bytedance.router.SmartRoute r2 = com.bytedance.router.SmartRouter.buildRoute(r0, r1)
            java.lang.String r1 = "AGE_GATE_KEY_CONFIG"
            r2.withParam(r1, r3)
            r3 = 0
            java.lang.String r1 = "AGE_GATE_KEY_REGISTRATION"
            r2.withParam(r1, r3)
            java.lang.String r1 = "AGE_GATE_KEY_APP_LOG_PARAMS"
            r3 = r20
            r2.withParam(r1, r3)
            com.ss.android.ugc.aweme.framework.services.IUserService r1 = r18.LJIIJ()
            java.lang.String r3 = ""
            kotlin.h.b.n.LIZIZ(r1, r3)
            com.ss.android.ugc.aweme.profile.model.User r1 = r1.getCurrentUser()
            if (r1 == 0) goto L_0x015d
            com.ss.android.ugc.aweme.profile.model.AgeGateInfo r5 = r1.getAgeGateInfo()
        L_0x004f:
            X.44O r6 = new X.44O
            r7 = 0
            r8 = 0
            r9 = 0
            r10 = 0
            r11 = 0
            r12 = 0
            r13 = 0
            r14 = 0
            r15 = 0
            r1 = 511(0x1ff, float:7.16E-43)
            r17 = 0
            r4 = r6
            r16 = 511(0x1ff, float:7.16E-43)
            r6.<init>(r7, r8, r9, r10, r11, r12, r13, r14, r15, r16, r17)
            if (r5 == 0) goto L_0x006c
            java.lang.String r1 = r5.getHeader()
            if (r1 != 0) goto L_0x006d
        L_0x006c:
            r1 = r3
        L_0x006d:
            r4.setHeader(r1)
            if (r5 == 0) goto L_0x015a
            java.lang.String r1 = r5.getTitle()
        L_0x0076:
            boolean r1 = X.C218436a.LIZ(r1)
            if (r1 == 0) goto L_0x0151
            if (r5 == 0) goto L_0x014e
            java.lang.String r1 = r5.getTitle()
        L_0x0082:
            r4.setTitle(r1)
            if (r5 == 0) goto L_0x014b
            java.lang.String r1 = r5.getNextButtonText()
        L_0x008b:
            boolean r1 = X.C218436a.LIZ(r1)
            if (r1 == 0) goto L_0x0142
            if (r5 == 0) goto L_0x013f
            java.lang.String r1 = r5.getNextButtonText()
        L_0x0097:
            r4.setNextBtnText(r1)
            if (r5 == 0) goto L_0x013c
            java.lang.String r1 = r5.getContent()
        L_0x00a0:
            boolean r1 = X.C218436a.LIZ(r1)
            if (r1 == 0) goto L_0x0110
            if (r5 == 0) goto L_0x010e
            java.lang.String r1 = r5.getContent()
        L_0x00ac:
            r4.setContentDesc(r1)
            if (r5 == 0) goto L_0x010c
            java.lang.String r1 = r5.getAgeGateImageUrl()
        L_0x00b5:
            r4.setImageUrl(r1)
            if (r5 == 0) goto L_0x00c0
            java.lang.String r1 = r5.getAgeGateInputPlaceHolder()
            if (r1 != 0) goto L_0x00c7
        L_0x00c0:
            r1 = 2131827137(0x7f1119c1, float:1.9287178E38)
            java.lang.String r1 = r0.getString(r1)
        L_0x00c7:
            r4.setInputPlaceHolder(r1)
            if (r5 == 0) goto L_0x010a
            java.util.List r0 = r5.getNavButtons()
        L_0x00d0:
            r4.setNavButtons(r0)
            if (r5 == 0) goto L_0x0108
            java.util.List r0 = r5.getHyperlinks()
        L_0x00d9:
            r4.setHyperLinks(r0)
            if (r5 == 0) goto L_0x00fa
            java.lang.Integer r0 = r5.getAgeIndicatorType()
            if (r0 == 0) goto L_0x00fa
            int r0 = r0.intValue()
            java.util.Map<java.lang.Integer, X.44P> r1 = X.AnonymousClass44P.MAP
            java.lang.Integer r0 = java.lang.Integer.valueOf(r0)
            java.lang.Object r0 = r1.get(r0)
            X.44P r0 = (X.AnonymousClass44P) r0
            if (r0 != 0) goto L_0x00fc
            X.44P r0 = X.AnonymousClass44P.HIDE
            if (r0 != 0) goto L_0x00fc
        L_0x00fa:
            X.44P r0 = X.AnonymousClass44P.HIDE
        L_0x00fc:
            r4.setAgeIndicatorType(r0)
            java.lang.String r0 = "AGE_GATE_KEY_UI"
            r2.withParam(r0, r4)
            r2.open()
            return
        L_0x0108:
            r0 = 0
            goto L_0x00d9
        L_0x010a:
            r0 = 0
            goto L_0x00d0
        L_0x010c:
            r1 = 0
            goto L_0x00b5
        L_0x010e:
            r1 = 0
            goto L_0x00ac
        L_0x0110:
            com.ss.android.ugc.aweme.framework.services.IUserService r1 = r18.LJIIJ()
            kotlin.h.b.n.LIZIZ(r1, r3)
            com.ss.android.ugc.aweme.profile.model.User r1 = r1.getCurrentUser()
            kotlin.h.b.n.LIZIZ(r1, r3)
            int r3 = r1.getAgeGateAction()
            X.3v1 r1 = X.C42673v1.US_FTC
            int r1 = r1.getValue()
            if (r3 != r1) goto L_0x0133
            r1 = 2131827199(0x7f1119ff, float:1.9287304E38)
            java.lang.String r1 = r0.getString(r1)
            goto L_0x00ac
        L_0x0133:
            r1 = 2131822146(0x7f110642, float:1.9277055E38)
            java.lang.String r1 = r0.getString(r1)
            goto L_0x00ac
        L_0x013c:
            r1 = 0
            goto L_0x00a0
        L_0x013f:
            r1 = 0
            goto L_0x0097
        L_0x0142:
            r1 = 2131827580(0x7f111b7c, float:1.9288077E38)
            java.lang.String r1 = r0.getString(r1)
            goto L_0x0097
        L_0x014b:
            r1 = 0
            goto L_0x008b
        L_0x014e:
            r1 = 0
            goto L_0x0082
        L_0x0151:
            r1 = 2131822147(0x7f110643, float:1.9277057E38)
            java.lang.String r1 = r0.getString(r1)
            goto L_0x0082
        L_0x015a:
            r1 = 0
            goto L_0x0076
        L_0x015d:
            r5 = 0
            goto L_0x004f
        */
        throw new UnsupportedOperationException("Method not decompiled: com.ss.android.ugc.aweme.compliance.business.serviceimpl.AgeGateServiceImpl.LIZ(android.content.Context, java.util.HashMap, X.S71):void");
    }

    public final void LIZ(Context context, HashMap<String, String> hashMap, S71 s71, boolean z) {
        S71 s712 = s71;
        M12.LIZ(context, s712);
        S71 s713 = LIZIZ;
        if (s713 != null) {
            s713.LIZ();
        }
        LIZIZ = s712;
        C469344n r3 = new C469344n(true, false, (AnonymousClass44T) null, (AnonymousClass44V) null, z, 12, (AnonymousClass2HN) null);
        SmartRoute buildRoute = SmartRouter.buildRoute(context, "//compliance/age/verify");
        buildRoute.withParam("AGE_GATE_KEY_CONFIG", r3);
        buildRoute.withParam("AGE_GATE_KEY_REGISTRATION", true);
        buildRoute.withParam("AGE_GATE_KEY_APP_LOG_PARAMS", hashMap);
        AnonymousClass44O r2 = new AnonymousClass44O((String) null, (String) null, (String) null, (String) null, (String) null, (String) null, (AnonymousClass44P) null, (List) null, (List) null, 511, (AnonymousClass2HN) null);
        r2.setHeader(context.getString(2131823013));
        r2.setTitle(context.getString(2131822147));
        r2.setNextBtnText(context.getString(2131827580));
        r2.setContentDesc(context.getString(2131827138));
        r2.setInputPlaceHolder(context.getString(2131827137));
        buildRoute.withParam("AGE_GATE_KEY_UI", r2);
        buildRoute.open();
    }

    public final void LIZ(Context context, AnonymousClass44T r20, AnonymousClass44V r21, HashMap<String, String> hashMap, S71 s71) {
        String string;
        String string2;
        AnonymousClass44T r1 = r20;
        Context context2 = context;
        AnonymousClass44V r4 = r21;
        S71 s712 = s71;
        M12.LIZ(context2, r1, r4, s712);
        S71 s713 = LIZIZ;
        if (s713 != null) {
            s713.LIZ();
        }
        LIZIZ = s712;
        C469344n r6 = new C469344n(true, false, r1, r4, false, 18, (AnonymousClass2HN) null);
        HashMap<String, String> hashMap2 = hashMap;
        hashMap2.put("enter_from", "age_edit_page");
        hashMap2.put("user_age_status", String.valueOf(r1.getType()));
        SmartRoute buildRoute = SmartRouter.buildRoute(context2, "//compliance/age/edit");
        buildRoute.withParam("AGE_GATE_KEY_CONFIG", r6);
        buildRoute.withParam("AGE_GATE_KEY_EDIT", true);
        buildRoute.withParam("AGE_GATE_KEY_APP_LOG_PARAMS", hashMap2);
        AnonymousClass44O r62 = new AnonymousClass44O((String) null, (String) null, (String) null, (String) null, (String) null, (String) null, (AnonymousClass44P) null, (List) null, (List) null, 511, (AnonymousClass2HN) null);
        Integer type = r1.getType();
        if (type != null && type.intValue() == 2) {
            string = context2.getString(2131821451);
        } else {
            string = context2.getString(2131821463);
        }
        r62.setTitle(string);
        r62.setNextBtnText(context2.getString(2131823145));
        Integer descType = r1.getDescType();
        if (descType != null && descType.intValue() == 1) {
            string2 = context2.getString(2131834579);
        } else {
            string2 = context2.getString(2131821462);
        }
        r62.setContentDesc(string2);
        r62.setInputPlaceHolder(context2.getString(2131821453));
        buildRoute.withParam("AGE_GATE_KEY_UI", r62);
        buildRoute.open();
    }
}
