package P2;

import S4.j;
import S4.k;
import S4.m;
import S4.n;
import S4.p;
import S4.w;
import java.util.regex.Pattern;
import kotlin.jvm.internal.o;
import n2.AbstractC2612c;
import x4.AbstractC3251q;

/* JADX INFO: loaded from: classes.dex */
public abstract class e {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public static final m f5658a = new m("[sS](\\d{1,2})[. _-]*[eE][. _-]*(\\d{1,3})(?:[abc]|v\\d+)?(?:\\D|$)");

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static final m f5659b = new m("(\\d{1,2})[xX](\\d{1,3})(?:\\D|$)");

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public static final m f5660c = new m("(\\d{1,2})\\.(\\d{2,3})(?:\\s*-\\s*|\\.\\w{2,4}$)?");

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public static final m f5661d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public static final m f5662e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public static final m f5663f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public static final m f5664g;

    static {
        n[] nVarArr = n.f6290a;
        f5661d = new m("(?:episode?|ep)[. _-]*(\\d{1,3})(?:\\D|$)", 0);
        f5662e = new m("(?:season|s)[. _-]*(\\d{1,2})(?:\\D|$)", 0);
        f5663f = new m("\\[(\\d{1,2})[.x](\\d{1,3})\\]");
        f5664g = new m("_+");
    }

    public static d a(String str, Integer num, Integer num2) {
        String strY0 = w.y0(str, "_", " ");
        Pattern patternCompile = Pattern.compile("^[^\\w#\\u3040-\\u9fff\\u0400-\\u04ff]+");
        o.g(patternCompile, "compile(...)");
        String strReplaceAll = patternCompile.matcher(strY0).replaceAll("");
        o.g(strReplaceAll, "replaceAll(...)");
        Pattern patternCompile2 = Pattern.compile("[ \\-:/\\\\\\[\\|{(#$&^]+$");
        o.g(patternCompile2, "compile(...)");
        String strReplaceAll2 = patternCompile2.matcher(strReplaceAll).replaceAll("");
        o.g(strReplaceAll2, "replaceAll(...)");
        return new d(p.o1(strReplaceAll2).toString(), num, num2, num != null ? AbstractC2612c.q(Integer.valueOf(num.intValue())) : null, num2 != null ? AbstractC2612c.q(Integer.valueOf(num2.intValue())) : null);
    }

    public static d b(String str) {
        String str2;
        String str3;
        if (str == null || p.Q0(str)) {
            return new d("", null, null, null, null);
        }
        Pattern patternCompile = Pattern.compile("_+");
        o.g(patternCompile, "compile(...)");
        String strReplaceAll = patternCompile.matcher(str).replaceAll(" ");
        o.g(strReplaceAll, "replaceAll(...)");
        String string = p.o1(strReplaceAll).toString();
        k kVarB = f5658a.b(string);
        if (kVarB != null) {
            return a(string, w.B0((String) ((j) kVarB.a()).get(1)), w.B0((String) ((j) kVarB.a()).get(2)));
        }
        k kVarB2 = f5659b.b(string);
        if (kVarB2 != null) {
            return a(string, w.B0((String) ((j) kVarB2.a()).get(1)), w.B0((String) ((j) kVarB2.a()).get(2)));
        }
        k kVarB3 = f5663f.b(string);
        if (kVarB3 != null) {
            return a(string, w.B0((String) ((j) kVarB3.a()).get(1)), w.B0((String) ((j) kVarB3.a()).get(2)));
        }
        k kVarB4 = f5660c.b(string);
        if (kVarB4 != null) {
            return a(string, w.B0((String) ((j) kVarB4.a()).get(1)), w.B0((String) ((j) kVarB4.a()).get(2)));
        }
        k kVarB5 = f5661d.b(string);
        Integer numB0 = null;
        Integer numB02 = (kVarB5 == null || (str3 = (String) AbstractC3251q.h0(1, kVarB5.a())) == null) ? null : w.B0(str3);
        k kVarB6 = f5662e.b(string);
        if (kVarB6 != null && (str2 = (String) AbstractC3251q.h0(1, kVarB6.a())) != null) {
            numB0 = w.B0(str2);
        }
        return a(string, numB0, numB02);
    }

    public static w4.k c(String str) {
        if (str == null || p.Q0(str)) {
            return null;
        }
        String string = p.o1(f5664g.f(str, " ")).toString();
        k kVarB = f5658a.b(string);
        if (kVarB != null) {
            Integer numB0 = w.B0((String) ((j) kVarB.a()).get(1));
            Integer numB02 = w.B0((String) ((j) kVarB.a()).get(2));
            if (numB0 != null && numB02 != null) {
                return new w4.k(numB0, numB02);
            }
        }
        k kVarB2 = f5659b.b(string);
        if (kVarB2 != null) {
            Integer numB03 = w.B0((String) ((j) kVarB2.a()).get(1));
            Integer numB04 = w.B0((String) ((j) kVarB2.a()).get(2));
            if (numB03 != null && numB04 != null) {
                return new w4.k(numB03, numB04);
            }
        }
        k kVarB3 = f5663f.b(string);
        if (kVarB3 != null) {
            Integer numB05 = w.B0((String) ((j) kVarB3.a()).get(1));
            Integer numB06 = w.B0((String) ((j) kVarB3.a()).get(2));
            if (numB05 != null && numB06 != null) {
                return new w4.k(numB05, numB06);
            }
        }
        k kVarB4 = f5660c.b(string);
        if (kVarB4 == null) {
            return null;
        }
        Integer numB07 = w.B0((String) ((j) kVarB4.a()).get(1));
        Integer numB08 = w.B0((String) ((j) kVarB4.a()).get(2));
        if (numB07 == null || numB08 == null) {
            return null;
        }
        return new w4.k(numB07, numB08);
    }
}
