discord-jadx/app/src/main/java/okhttp3/MediaType.java

160 lines
6.9 KiB
Java

package okhttp3;
import com.discord.models.domain.ModelAuditLogEntry;
import d0.d0.f;
import d0.g0.t;
import d0.t.k;
import d0.z.d.m;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import kotlin.TypeCastException;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.ranges.IntProgression;
/* compiled from: MediaType.kt */
/* loaded from: classes3.dex */
public final class MediaType {
public static final Pattern a = Pattern.compile("([a-zA-Z0-9-!#$%&'*+.^_`{|}~]+)/([a-zA-Z0-9-!#$%&'*+.^_`{|}~]+)");
/* renamed from: b reason: collision with root package name */
public static final Pattern f3781b = Pattern.compile(";\\s*(?:([a-zA-Z0-9-!#$%&'*+.^_`{|}~]+)=(?:([a-zA-Z0-9-!#$%&'*+.^_`{|}~]+)|\"([^\"]*)\"))?");
public static final a c = null;
public final String d;
public final String e;
public final String f;
public final String[] g;
/* compiled from: MediaType.kt */
/* loaded from: classes3.dex */
public static final class a {
public static final MediaType a(String str) {
m.checkParameterIsNotNull(str, "$this$toMediaType");
Matcher matcher = MediaType.a.matcher(str);
if (matcher.lookingAt()) {
String group = matcher.group(1);
m.checkExpressionValueIsNotNull(group, "typeSubtype.group(1)");
Locale locale = Locale.US;
m.checkExpressionValueIsNotNull(locale, "Locale.US");
if (group != null) {
String lowerCase = group.toLowerCase(locale);
m.checkExpressionValueIsNotNull(lowerCase, "(this as java.lang.String).toLowerCase(locale)");
String group2 = matcher.group(2);
m.checkExpressionValueIsNotNull(group2, "typeSubtype.group(2)");
m.checkExpressionValueIsNotNull(locale, "Locale.US");
if (group2 != null) {
String lowerCase2 = group2.toLowerCase(locale);
m.checkExpressionValueIsNotNull(lowerCase2, "(this as java.lang.String).toLowerCase(locale)");
ArrayList arrayList = new ArrayList();
Matcher matcher2 = MediaType.f3781b.matcher(str);
int end = matcher.end();
while (end < str.length()) {
matcher2.region(end, str.length());
if (matcher2.lookingAt()) {
String group3 = matcher2.group(1);
if (group3 == null) {
end = matcher2.end();
} else {
String group4 = matcher2.group(2);
if (group4 == null) {
group4 = matcher2.group(3);
} else if (t.startsWith$default(group4, "'", false, 2, null) && t.endsWith$default(group4, "'", false, 2, null) && group4.length() > 2) {
group4 = group4.substring(1, group4.length() - 1);
m.checkExpressionValueIsNotNull(group4, "(this as java.lang.Strin…ing(startIndex, endIndex)");
}
arrayList.add(group3);
arrayList.add(group4);
end = matcher2.end();
}
} else {
StringBuilder R = b.d.b.a.a.R("Parameter is not formatted correctly: \"");
String substring = str.substring(end);
m.checkExpressionValueIsNotNull(substring, "(this as java.lang.String).substring(startIndex)");
R.append(substring);
R.append("\" for: \"");
R.append(str);
R.append('\"');
throw new IllegalArgumentException(R.toString().toString());
}
}
Object[] array = arrayList.toArray(new String[0]);
if (array != null) {
return new MediaType(str, lowerCase, lowerCase2, (String[]) array, null);
}
throw new TypeCastException("null cannot be cast to non-null type kotlin.Array<T>");
}
throw new TypeCastException("null cannot be cast to non-null type java.lang.String");
}
throw new TypeCastException("null cannot be cast to non-null type java.lang.String");
}
throw new IllegalArgumentException(("No subtype found for: \"" + str + '\"').toString());
}
public static final MediaType b(String str) {
m.checkParameterIsNotNull(str, "$this$toMediaTypeOrNull");
try {
return a(str);
} catch (IllegalArgumentException unused) {
return null;
}
}
}
public MediaType(String str, String str2, String str3, String[] strArr, DefaultConstructorMarker defaultConstructorMarker) {
this.d = str;
this.e = str2;
this.f = str3;
this.g = strArr;
}
public static final MediaType b(String str) {
return a.a(str);
}
/* JADX WARN: Removed duplicated region for block: B:16:0x003d A[EXC_TOP_SPLITTER, SYNTHETIC] */
/* JADX WARN: Removed duplicated region for block: B:21:? A[RETURN, SYNTHETIC] */
/*
Code decompiled incorrectly, please refer to instructions dump.
*/
public final Charset a(Charset charset) {
String str;
m.checkParameterIsNotNull("charset", ModelAuditLogEntry.CHANGE_KEY_NAME);
IntProgression step = f.step(k.getIndices(this.g), 2);
int first = step.getFirst();
int last = step.getLast();
int step2 = step.getStep();
if (step2 < 0 ? first >= last : first <= last) {
while (!t.equals(this.g[first], "charset", true)) {
if (first != last) {
first += step2;
}
}
str = this.g[first + 1];
if (str != null) {
return charset;
}
try {
return Charset.forName(str);
} catch (IllegalArgumentException unused) {
return charset;
}
}
str = null;
if (str != null) {
}
}
public boolean equals(Object obj) {
return (obj instanceof MediaType) && m.areEqual(((MediaType) obj).d, this.d);
}
public int hashCode() {
return this.d.hashCode();
}
public String toString() {
return this.d;
}
}