package com.ss.android.ugc.aweme.ad.feed.utils;

import X.AnonymousClass2NH;
import X.AnonymousClass2ZT;
import X.AnonymousClass2ZU;
import X.AnonymousClass3QV;
import X.AnonymousClass4EW;
import X.AnonymousClass4FQ;
import X.C12422nK;
import X.Lnj;
import android.content.Context;
import android.net.Uri;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.bytedance.ies.abmock.SettingsManager;
import com.ss.android.ugc.aweme.ad.feed.IFeedBackDialogManager;
import com.ss.android.ugc.aweme.feed.model.Aweme;
import com.ss.android.ugc.aweme.feed.model.AwemeRawAd;
import kotlin.h.b.n;

public final class FeedBackDialogManagerService implements IFeedBackDialogManager {
    public static final AnonymousClass2ZU LIZ = new AnonymousClass2ZU((byte) 0);
    public static volatile long LIZIZ;

    static {
        Covode.recordClassIndex(52787);
    }

    public static IFeedBackDialogManager LIZ() {
        MethodCollector.i(16724);
        IFeedBackDialogManager iFeedBackDialogManager = (IFeedBackDialogManager) Lnj.LIZ(IFeedBackDialogManager.class, false);
        if (iFeedBackDialogManager != null) {
            MethodCollector.o(16724);
            return iFeedBackDialogManager;
        }
        Object LIZIZ2 = Lnj.LIZIZ(IFeedBackDialogManager.class, false);
        if (LIZIZ2 != null) {
            IFeedBackDialogManager iFeedBackDialogManager2 = (IFeedBackDialogManager) LIZIZ2;
            MethodCollector.o(16724);
            return iFeedBackDialogManager2;
        }
        if (Lnj.LJJIL == null) {
            synchronized (IFeedBackDialogManager.class) {
                try {
                    if (Lnj.LJJIL == null) {
                        Lnj.LJJIL = new FeedBackDialogManagerService();
                    }
                } catch (Throwable th) {
                    MethodCollector.o(16724);
                    throw th;
                }
            }
        }
        FeedBackDialogManagerService feedBackDialogManagerService = (FeedBackDialogManagerService) Lnj.LJJIL;
        MethodCollector.o(16724);
        return feedBackDialogManagerService;
    }

    public final void LIZIZ(String str) {
        if (LIZ(str) && LIZIZ == 0) {
            LIZIZ = System.currentTimeMillis();
        }
    }

    public final boolean LIZ(String str) {
        Uri parse;
        String host;
        if (str == null || (parse = Uri.parse(str)) == null || (host = parse.getHost()) == null) {
            return false;
        }
        n.LIZIZ(host, "");
        String path = parse.getPath();
        if (path == null) {
            return false;
        }
        n.LIZIZ(path, "");
        for (String parse2 : AnonymousClass2NH.LIZ().LIZ) {
            Uri parse3 = Uri.parse(parse2);
            if (parse3 != null && n.LIZ(parse3.getHost(), host) && n.LIZ(parse3.getPath(), path) && n.LIZ(parse.getQueryParameter("source_type"), "feed")) {
                return true;
            }
        }
        return false;
    }

    public final void LIZ(Context context, Aweme aweme) {
        String str;
        AwemeRawAd awemeRawAd;
        if (context != null) {
            long j = LIZIZ;
            LIZIZ = 0;
            if (aweme == null || (awemeRawAd = aweme.getAwemeRawAd()) == null) {
                str = null;
            } else {
                str = awemeRawAd.getWebUrl();
            }
            if (LIZ(str) && j != 0 && (System.currentTimeMillis() - j) / 1000 >= ((long) SettingsManager.LIZ().LIZ("ad_feedback_dialog_time", 10))) {
                AnonymousClass4EW r1 = new AnonymousClass4EW(context);
                r1.LIZJ(2131820544);
                r1.LIZLLL(2131820545);
                AnonymousClass3QV.LIZ(r1, AnonymousClass2ZT.LIZ);
                r1.LIZ(false);
                AnonymousClass4FQ.LIZ(r1.LIZ().LIZJ());
                C12422nK.onEventV3("your_ad_activity_page_back_toast_show");
            }
        }
    }
}
