package vq;

import com.fasterxml.jackson.core.JsonFactory;
import java.util.ArrayList;
import java.util.Locale;
import kotlin.jvm.internal.t;
import kotlin.text.y;
import uq.x;

/* loaded from: classes3.dex */
public abstract class h {

    /* renamed from: a, reason: collision with root package name */
    private static final kotlin.text.l f40459a = new kotlin.text.l("([a-zA-Z0-9-!#$%&'*+.^_`{|}~]+)/([a-zA-Z0-9-!#$%&'*+.^_`{|}~]+)");

    /* renamed from: b, reason: collision with root package name */
    private static final kotlin.text.l f40460b = new kotlin.text.l(";\\s*(?:([a-zA-Z0-9-!#$%&'*+.^_`{|}~]+)=(?:([a-zA-Z0-9-!#$%&'*+.^_`{|}~]+)|\"([^\"]*)\"))?");

    public static final boolean a(x xVar, Object obj) {
        t.g(xVar, "<this>");
        return (obj instanceof x) && t.b(((x) obj).d(), xVar.d());
    }

    public static final int b(x xVar) {
        t.g(xVar, "<this>");
        return xVar.d().hashCode();
    }

    /* JADX WARN: Incorrect condition in loop: B:4:0x0024 */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static final String c(x xVar, String name) {
        boolean z10;
        t.g(xVar, "<this>");
        t.g(name, "name");
        int i10 = 0;
        int c10 = ym.c.c(0, xVar.e().length - 1, 2);
        if (c10 < 0) {
            return null;
        }
        while (!z10) {
            if (i10 == c10) {
                return null;
            }
            i10 += 2;
        }
        return xVar.e()[i10 + 1];
    }

    public static final x d(String str) {
        boolean P;
        boolean y10;
        t.g(str, "<this>");
        kotlin.text.j z10 = m.z(f40459a, str, 0);
        if (z10 == null) {
            throw new IllegalArgumentException("No subtype found for: \"" + str + JsonFactory.DEFAULT_QUOTE_CHAR);
        }
        String str2 = (String) z10.b().get(1);
        Locale locale = Locale.ROOT;
        String lowerCase = str2.toLowerCase(locale);
        t.f(lowerCase, "this as java.lang.String).toLowerCase(Locale.ROOT)");
        String lowerCase2 = ((String) z10.b().get(2)).toLowerCase(locale);
        t.f(lowerCase2, "this as java.lang.String).toLowerCase(Locale.ROOT)");
        ArrayList arrayList = new ArrayList();
        int m10 = z10.d().m();
        while (true) {
            int i10 = m10 + 1;
            if (i10 >= str.length()) {
                Object[] array = arrayList.toArray(new String[0]);
                t.e(array, "null cannot be cast to non-null type kotlin.Array<T of kotlin.collections.ArraysKt__ArraysJVMKt.toTypedArray>");
                return new x(str, lowerCase, lowerCase2, (String[]) array);
            }
            kotlin.text.j z11 = m.z(f40460b, str, i10);
            if (!(z11 != null)) {
                StringBuilder sb2 = new StringBuilder();
                sb2.append("Parameter is not formatted correctly: \"");
                String substring = str.substring(i10);
                t.f(substring, "this as java.lang.String).substring(startIndex)");
                sb2.append(substring);
                sb2.append("\" for: \"");
                sb2.append(str);
                sb2.append(JsonFactory.DEFAULT_QUOTE_CHAR);
                throw new IllegalArgumentException(sb2.toString().toString());
            }
            kotlin.text.h hVar = z11.c().get(1);
            String a10 = hVar != null ? hVar.a() : null;
            if (a10 == null) {
                m10 = z11.d().m();
            } else {
                kotlin.text.h hVar2 = z11.c().get(2);
                String a11 = hVar2 != null ? hVar2.a() : null;
                if (a11 == null) {
                    kotlin.text.h hVar3 = z11.c().get(3);
                    t.d(hVar3);
                    a11 = hVar3.a();
                } else {
                    P = y.P(a11, "'", false, 2, null);
                    if (P) {
                        y10 = y.y(a11, "'", false, 2, null);
                        if (y10 && a11.length() > 2) {
                            a11 = a11.substring(1, a11.length() - 1);
                            t.f(a11, "this as java.lang.String…ing(startIndex, endIndex)");
                        }
                    }
                }
                arrayList.add(a10);
                arrayList.add(a11);
                m10 = z11.d().m();
            }
        }
    }

    public static final x e(String str) {
        t.g(str, "<this>");
        try {
            return d(str);
        } catch (IllegalArgumentException unused) {
            return null;
        }
    }

    public static final String f(x xVar) {
        t.g(xVar, "<this>");
        return xVar.d();
    }
}
