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

import X.2cN;
import X.3PY;
import X.3PZ;
import X.3fI;
import X.7V9;
import X.86a;
import X.C4672Lnj;
import X.C5324LyF;
import X.C5345Lya;
import X.C5349Lye;
import X.C5350Lyf;
import X.C5353Lyi;
import X.C5355Lyk;
import X.C5363Lys;
import X.C5384LzD;
import X.C5389LzI;
import X.K2F;
import X.KCE;
import X.LUR;
import X.LXS;
import X.LXT;
import X.M12;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import java.util.Objects;
import kotlin.h.b.n;

public final class DeepLinkServiceImpl implements IDeepLinkService {
    static {
        Covode.recordClassIndex(63391);
    }

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

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

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

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

    public final String LJIIIZ() {
        return LXS.LIZIZ;
    }

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

    public final String LIZIZ() {
        String name = DeepLinkHandlerActivity.class.getName();
        n.LIZIZ(name, "");
        return name;
    }

    public final String LIZJ() {
        String name = DeepLinkActivityV2.class.getName();
        n.LIZIZ(name, "");
        return name;
    }

    public final String LIZLLL() {
        String name = AppLinkHandlerV2.class.getName();
        n.LIZIZ(name, "");
        return name;
    }

    public final void LIZ() {
        C5353Lyi.LIZ = null;
        C5353Lyi.LIZJ = false;
        C5353Lyi.LIZIZ = "";
        C5353Lyi.LJFF = null;
        2cN r0 = C5353Lyi.LIZLLL;
        if (r0 != null) {
            r0.dispose();
        }
    }

    public static IDeepLinkService LJIIJ() {
        MethodCollector.i(4059);
        IDeepLinkService iDeepLinkService = (IDeepLinkService) C4672Lnj.LIZ(IDeepLinkService.class, false);
        if (iDeepLinkService != null) {
            MethodCollector.o(4059);
            return iDeepLinkService;
        }
        Object LIZIZ = C4672Lnj.LIZIZ(IDeepLinkService.class, false);
        if (LIZIZ != null) {
            IDeepLinkService iDeepLinkService2 = (IDeepLinkService) LIZIZ;
            MethodCollector.o(4059);
            return iDeepLinkService2;
        }
        if (C4672Lnj.LLILLL == null) {
            synchronized (IDeepLinkService.class) {
                try {
                    if (C4672Lnj.LLILLL == null) {
                        C4672Lnj.LLILLL = new DeepLinkServiceImpl();
                    }
                } catch (Throwable th) {
                    MethodCollector.o(4059);
                    throw th;
                }
            }
        }
        DeepLinkServiceImpl deepLinkServiceImpl = (DeepLinkServiceImpl) C4672Lnj.LLILLL;
        MethodCollector.o(4059);
        return deepLinkServiceImpl;
    }

    public final boolean LIZ(Context context) {
        M12.LIZ((Object) context);
        return context instanceof DeepLinkHandlerActivity;
    }

    public final boolean LIZIZ(Context context) {
        M12.LIZ((Object) context);
        return context instanceof DeepLinkActivityV2;
    }

    public final boolean LIZJ(String str) {
        return LXS.LJII.LIZIZ(str);
    }

    public final String LIZIZ(Uri uri) {
        M12.LIZ((Object) uri);
        return 3PY.LIZ.LIZIZ(uri);
    }

    public final String LIZIZ(String str) {
        M12.LIZ((Object) str);
        return LXS.LJII.LIZ(str);
    }

    public final String LIZJ(Context context) {
        M12.LIZ((Object) context);
        if (context instanceof DeepLinkHandlerActivity) {
            String str = ((DeepLinkHandlerActivity) context).LJ;
            n.LIZIZ(str, "");
            return str;
        }
        if (context instanceof DeepLinkActivityV2) {
            DeepLinkActivityV2 deepLinkActivityV2 = (DeepLinkActivityV2) context;
            if (deepLinkActivityV2.LIZ().LIZIZ.get("notification_id") instanceof String) {
                Object obj = deepLinkActivityV2.LIZ().LIZIZ.get("notification_id");
                Objects.requireNonNull(obj, "null cannot be cast to non-null type kotlin.String");
                return (String) obj;
            }
        }
        return "";
    }

    public final String LIZLLL(String str) {
        M12.LIZ((Object) str);
        KCE kce = KCE.LIZ;
        M12.LIZ((Object) str);
        Uri parse = Uri.parse(str);
        n.LIZIZ(parse, "");
        if (kce.LIZ(parse)) {
            return kce.LIZIZ(str);
        }
        return kce.LIZ(str);
    }

    public final boolean LIZ(Uri uri) {
        M12.LIZ((Object) uri);
        return LUR.LIZ.LIZ(uri);
    }

    public final boolean LIZ(String str) {
        M12.LIZ((Object) str);
        LXT lxt = LXS.LJII;
        M12.LIZ((Object) str);
        if (86a.LIZ(str)) {
            return false;
        }
        if (n.LIZ(LXS.LIZ, str)) {
            return true;
        }
        String LIZ = lxt.LIZ();
        if (86a.LIZ(LIZ) || !n.LIZ(LIZ, str)) {
            return false;
        }
        return true;
    }

    public final void LIZ(String str, String str2) {
        M12.LIZ((Object) str, (Object) str2);
        K2F k2f = new K2F(str, str2);
        M12.LIZ((Object) k2f);
        C5384LzD.LIZ.onNext(k2f);
    }

    public final void LIZ(C5345Lya lya, C5389LzI lzI) {
        M12.LIZ((Object) lya, (Object) lzI);
        C5353Lyi lyi = C5353Lyi.LJI;
        M12.LIZ((Object) lya, (Object) lzI);
        C5353Lyi.LJ = lzI;
        C5353Lyi.LJFF = lya;
        if (!C5353Lyi.LIZJ) {
            if (C5353Lyi.LIZ == null) {
                C5353Lyi.LIZ = new C5349Lye(C5353Lyi.LJ);
                C5353Lyi.LIZJ = true;
            }
            C5350Lyf lyf = C5350Lyf.LIZ;
            M12.LIZ((Object) lyf);
            2cN LIZLLL = C5384LzD.LIZ.LIZLLL(new C5363Lys(lyf));
            n.LIZIZ(LIZLLL, "");
            C5353Lyi.LIZLLL = LIZLLL;
        }
        C5355Lyk LIZ = lyi.LIZ();
        if (LIZ != null) {
            LIZ.LIZ(lya, LIZ);
        }
    }

    public final boolean LIZIZ(String str, String str2) {
        return C5324LyF.LIZ.LIZ(str, str2);
    }

    public final void LIZ(String str, boolean z, String str2) {
        7V9.LIZ(str, z, str2);
    }

    public final boolean LIZ(Activity activity, String str, String str2) {
        M12.LIZ(activity, str, str2);
        return 3PZ.LIZ().LIZ(activity, str, str2);
    }

    public final void LIZIZ(Activity activity, String str, boolean z) {
        M12.LIZ((Object) activity, (Object) str);
        RequireLoginActivity.LIZLLL.LIZ(activity, str, z);
    }

    public final boolean LIZ(Activity activity, String str, boolean z) {
        Uri uri;
        M12.LIZ((Object) activity, (Object) str);
        3fI r1 = RequireLoginActivity.LIZLLL;
        M12.LIZ((Object) activity, (Object) str);
        Intent intent = activity.getIntent();
        if (intent != null) {
            uri = intent.getData();
        } else {
            uri = null;
        }
        if (!r1.LIZ(uri)) {
            return false;
        }
        r1.LIZ(activity, str, z);
        return true;
    }
}
