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

import X.3aH;
import X.3i8;
import X.46i;
import X.C4146EcI;
import X.C5769F5x;
import X.C6135FJz;
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.router.RouteIntent;
import com.bytedance.router.interceptor.IInterceptor;
import com.ss.android.ugc.aweme.IAccountUserService;
import com.ss.android.ugc.aweme.im.sdk.common.controller.providedservices.IMService;
import kotlin.h.b.n;
import kotlin.o.y;

public final class InstantMessageInterceptor implements IInterceptor {
    public static final C6135FJz LIZ = new C6135FJz((byte) 0);

    static {
        Covode.recordClassIndex(103821);
    }

    public final boolean matchInterceptRules(RouteIntent routeIntent) {
        String str;
        Uri uri;
        if (routeIntent == null || (uri = routeIntent.getUri()) == null) {
            str = null;
        } else {
            str = uri.getHost();
        }
        return n.LIZ("chat", str);
    }

    public static void LIZ(Context context, Intent intent) {
        3i8.LIZ(intent, context);
        context.startActivity(intent);
    }

    public final boolean onInterceptRoute(Context context, RouteIntent routeIntent) {
        if (!(context == null || routeIntent == null)) {
            if (IMService.createIIMServicebyMonsterPlugin(false).isConversationListPagination()) {
                String url = routeIntent.getUrl();
                n.LIZIZ(url, "");
                routeIntent.setUrl(y.LIZ(url, "chat/center", "chat/center2", false));
            }
            46i.LIZ();
            IAccountUserService LJFF = 46i.LIZ.LJFF();
            n.LIZIZ(LJFF, "");
            if (!LJFF.isLogin() && (context instanceof Activity)) {
                LIZ(context, C5769F5x.LIZ.LIZ((Activity) context, routeIntent.getExtra(), routeIntent.getUri().getQueryParameter("multi_account_push_uid")));
                return true;
            } else if (C4146EcI.LIZ.LIZIZ()) {
                Intent LIZ2 = 3aH.LIZ(context);
                LIZ2.setFlags(67108864);
                LIZ2.putExtra("com.ss.android.ugc.aweme.intent.extra.EXTRA_AWEME_PUSH_TAB", "NOTIFICATION");
                LIZ2.putExtras(routeIntent.getExtra());
                LIZ(context, LIZ2);
                return true;
            }
        }
        return false;
    }
}
