package com.strmr.ps.data.service;

import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.util.Log;
import androidx.media3.container.NalUnitUtil;
import androidx.media3.exoplayer.RendererCapabilities;
import androidx.media3.exoplayer.upstream.CmcdData;
import dagger.hilt.android.qualifiers.ApplicationContext;
import defpackage.cr4;
import defpackage.kp6;
import defpackage.q07;
import defpackage.vx8;
import defpackage.wo5;
import javax.inject.Inject;
import javax.inject.Singleton;
import kotlin.Metadata;

/* JADX INFO: loaded from: classes3.dex */
@Singleton
@Metadata(d1 = {"\u0000\u0010\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0018\u0002\n\u0002\b\u0005\b\u0007\u0018\u00002\u00020\u0001:\u0001\u0006B\u0013\b\u0007\u0012\b\b\u0001\u0010\u0003\u001a\u00020\u0002¢\u0006\u0004\b\u0004\u0010\u0005¨\u0006\u0007"}, d2 = {"Lcom/strmr/ps/data/service/StreamingDeepLinkService;", "", "Landroid/content/Context;", "context", "<init>", "(Landroid/content/Context;)V", CmcdData.OBJECT_TYPE_AUDIO_ONLY, "app_sideloadRelease"}, k = 1, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
@vx8
public final class StreamingDeepLinkService {
    public static final Object b = wo5.j(new q07("netflix", "com.netflix.mediaclient"), new q07("disney", "com.disney.disneyplus"), new q07("hbomax", "com.hbo.hbonow"), new q07("max", "com.hbo.hbonow"), new q07("prime", "com.amazon.avod.thirdpartyclient"), new q07("appletv", "com.apple.atve.androidtv.appletv"), new q07("paramount", "com.cbs.ott"), new q07("peacock", "com.peacocktv.peacockandroid"), new q07("hulu", "com.hulu.plus"), new q07("crunchyroll", "com.crunchyroll.crunchyroid"), new q07("starz", "com.starz.starzplay.android"), new q07("showtime", "com.showtime.showtimeanytime"));
    public static final Object c = wo5.j(new q07("netflix", "com.netflix.ninja"), new q07("disney", "com.disney.disneyplus"), new q07("hbomax", "com.hbo.hbonow"), new q07("max", "com.hbo.hbonow"), new q07("prime", "com.amazon.amazonvideo.livingroom"), new q07("appletv", "com.apple.atve.androidtv.appletv"), new q07("paramount", "com.cbs.ott"), new q07("peacock", "com.peacocktv.peacockandroid"), new q07("hulu", "com.hulu.livingroomplus"), new q07("crunchyroll", "com.crunchyroll.crunchyroid"), new q07("starz", "com.starz.starzplay.android"), new q07("showtime", "com.showtime.standalone"));
    public static final Object d = wo5.j(new q07("netflix", "Netflix"), new q07("disney", "Disney+"), new q07("hbomax", "Max"), new q07("max", "Max"), new q07("prime", "Prime Video"), new q07("appletv", "Apple TV+"), new q07("paramount", "Paramount+"), new q07("peacock", "Peacock"), new q07("hulu", "Hulu"), new q07("crunchyroll", "Crunchyroll"), new q07("starz", "Starz"), new q07("showtime", "Showtime"));
    public static final Object e = wo5.j(new q07(8, "netflix"), new q07(9, "prime"), new q07(337, "disney"), new q07(Integer.valueOf(RendererCapabilities.DECODER_SUPPORT_MASK), "max"), new q07(1899, "max"), new q07(15, "hulu"), new q07(386, "peacock"), new q07(531, "paramount"), new q07(2, "appletv"), new q07(350, "appletv"), new q07(283, "crunchyroll"), new q07(43, "starz"), new q07(37, "showtime"));
    public final Context a;

    @Metadata(d1 = {"\u0000\u0018\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0010\u000e\n\u0002\b\u0002\n\u0002\u0010$\n\u0002\b\u0004\b\u0086\u0003\u0018\u00002\u00020\u0001R\u0014\u0010\u0003\u001a\u00020\u00028\u0002X\u0082T¢\u0006\u0006\n\u0004\b\u0003\u0010\u0004R \u0010\u0006\u001a\u000e\u0012\u0004\u0012\u00020\u0002\u0012\u0004\u0012\u00020\u00020\u00058\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u0006\u0010\u0007R \u0010\b\u001a\u000e\u0012\u0004\u0012\u00020\u0002\u0012\u0004\u0012\u00020\u00020\u00058\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\b\u0010\u0007¨\u0006\t"}, d2 = {"Lcom/strmr/ps/data/service/StreamingDeepLinkService$a;", "", "", "TAG", "Ljava/lang/String;", "", "MOBILE_PACKAGES", "Ljava/util/Map;", "TV_PACKAGES", "app_sideloadRelease"}, k = 1, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
    public static final class a {
    }

    @Inject
    public StreamingDeepLinkService(@ApplicationContext @kp6 Context context) {
        cr4.g(context, "context");
        this.a = context;
    }

    /* JADX WARN: Type inference failed for: r0v0, types: [java.lang.Object, java.util.Map] */
    /* JADX WARN: Type inference failed for: r1v0, types: [java.lang.Object, java.util.Map] */
    public final String a(String str) {
        String str2 = (String) c.get(str);
        if (str2 != null && b(str2)) {
            return str2;
        }
        String str3 = (String) b.get(str);
        return ((str3 == null || !b(str3)) && str2 != null) ? str2 : str3;
    }

    public final boolean b(String str) {
        try {
            this.a.getPackageManager().getPackageInfo(str, 0);
            return true;
        } catch (PackageManager.NameNotFoundException unused) {
            return false;
        }
    }

    /* JADX WARN: Failed to restore switch over string. Please report as a decompilation issue */
    public final boolean c(String str, String str2, String str3) {
        String strConcat;
        Intent intent = null;
        if (str2 != null || str3 != null) {
            switch (str.hashCode()) {
                case -1331547564:
                    strConcat = (!str.equals("disney") || str3 == null) ? null : "https://www.disneyplus.com/search/".concat(str3);
                    break;
                case -793238692:
                    strConcat = (!str.equals("appletv") || str3 == null) ? null : "https://tv.apple.com/search?term=".concat(str3);
                    break;
                case -694617888:
                    strConcat = (!str.equals("peacock") || str3 == null) ? null : "https://www.peacocktv.com/watch/search?q=".concat(str3);
                    break;
                case 107876:
                    strConcat = (!str.equals("max") || str3 == null) ? null : "https://play.max.com/search?q=".concat(str3);
                    break;
                case 3214166:
                    strConcat = (!str.equals("hulu") || str3 == null) ? null : "https://www.hulu.com/search?q=".concat(str3);
                    break;
                case 106934911:
                    strConcat = (!str.equals("prime") || str2 == null) ? null : "https://www.amazon.com/gp/video/detail/".concat(str2);
                    break;
                case 1842975634:
                    strConcat = (str.equals("netflix") && str2 != null) ? "https://www.netflix.com/title/".concat(str2) : null;
                    break;
                case 1954759737:
                    strConcat = (!str.equals("paramount") || str3 == null) ? null : "https://www.paramountplus.com/search/?q=".concat(str3);
                    break;
                default:
                    strConcat = null;
                    break;
            }
        } else {
            strConcat = null;
        }
        String strA = a(str);
        if (strA == null) {
            Log.w("StreamingDeepLinkService", "Unknown service: ".concat(str));
            return false;
        }
        boolean zB = b(strA);
        Context context = this.a;
        if (!zB) {
            try {
                try {
                    Intent intent2 = new Intent("android.intent.action.VIEW");
                    intent2.setData(Uri.parse("market://details?id=".concat(strA)));
                    intent2.addFlags(268435456);
                    context.startActivity(intent2);
                    return false;
                } catch (Exception e2) {
                    Log.e("StreamingDeepLinkService", "Failed to open Play Store", e2);
                    return false;
                }
            } catch (Exception unused) {
                Intent intent3 = new Intent("android.intent.action.VIEW");
                intent3.setData(Uri.parse("https://play.google.com/store/apps/details?id=".concat(strA)));
                intent3.addFlags(268435456);
                context.startActivity(intent3);
                return false;
            }
        }
        try {
            if (strConcat != null) {
                intent = new Intent("android.intent.action.VIEW", Uri.parse(strConcat));
                intent.setPackage(strA);
                intent.addFlags(268435456);
            } else {
                Intent launchIntentForPackage = context.getPackageManager().getLaunchIntentForPackage(strA);
                if (launchIntentForPackage != null) {
                    launchIntentForPackage.addFlags(268435456);
                    intent = launchIntentForPackage;
                }
            }
            if (intent != null) {
                context.startActivity(intent);
                return true;
            }
            Log.w("StreamingDeepLinkService", "No launch intent for ".concat(str));
            return false;
        } catch (Exception e3) {
            Log.e("StreamingDeepLinkService", "Failed to open " + str + " app", e3);
            return false;
        }
    }
}
