2021-08-03 07:33:18 +00:00
|
|
|
package okhttp3;
|
|
|
|
|
2021-08-09 22:51:56 +00:00
|
|
|
import com.discord.models.domain.ModelAuditLogEntry;
|
2021-11-02 06:38:17 +00:00
|
|
|
import d0.d0.f;
|
|
|
|
import d0.g0.t;
|
|
|
|
import d0.t.k;
|
|
|
|
import d0.z.d.m;
|
2021-08-03 07:33:18 +00:00
|
|
|
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 */
|
2022-03-07 09:34:54 +00:00
|
|
|
/* loaded from: classes3.dex */
|
2021-08-03 07:33:18 +00:00
|
|
|
public final class MediaType {
|
|
|
|
public static final Pattern a = Pattern.compile("([a-zA-Z0-9-!#$%&'*+.^_`{|}~]+)/([a-zA-Z0-9-!#$%&'*+.^_`{|}~]+)");
|
|
|
|
|
2021-12-17 21:59:34 +00:00
|
|
|
/* renamed from: b reason: collision with root package name */
|
2022-03-28 08:10:50 +00:00
|
|
|
public static final Pattern f3801b = Pattern.compile(";\\s*(?:([a-zA-Z0-9-!#$%&'*+.^_`{|}~]+)=(?:([a-zA-Z0-9-!#$%&'*+.^_`{|}~]+)|\"([^\"]*)\"))?");
|
2021-12-17 21:59:34 +00:00
|
|
|
public static final a c = null;
|
2021-08-03 07:33:18 +00:00
|
|
|
public final String d;
|
|
|
|
public final String e;
|
|
|
|
public final String f;
|
|
|
|
public final String[] g;
|
|
|
|
|
|
|
|
/* compiled from: MediaType.kt */
|
2022-03-07 09:34:54 +00:00
|
|
|
/* loaded from: classes3.dex */
|
2021-08-03 07:33:18 +00:00
|
|
|
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();
|
2022-03-28 08:10:50 +00:00
|
|
|
Matcher matcher2 = MediaType.f3801b.matcher(str);
|
2021-08-03 07:33:18 +00:00
|
|
|
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 {
|
2022-03-21 18:52:30 +00:00
|
|
|
StringBuilder R = b.d.b.a.a.R("Parameter is not formatted correctly: \"");
|
2021-08-03 07:33:18 +00:00
|
|
|
String substring = str.substring(end);
|
|
|
|
m.checkExpressionValueIsNotNull(substring, "(this as java.lang.String).substring(startIndex)");
|
2022-03-21 18:52:30 +00:00
|
|
|
R.append(substring);
|
|
|
|
R.append("\" for: \"");
|
|
|
|
R.append(str);
|
|
|
|
R.append('\"');
|
|
|
|
throw new IllegalArgumentException(R.toString().toString());
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2022-03-07 09:34:54 +00:00
|
|
|
/* 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.
|
|
|
|
*/
|
2021-08-03 07:33:18 +00:00
|
|
|
public final Charset a(Charset charset) {
|
|
|
|
String str;
|
2021-08-09 22:51:56 +00:00
|
|
|
m.checkParameterIsNotNull("charset", ModelAuditLogEntry.CHANGE_KEY_NAME);
|
2021-08-03 07:33:18 +00:00
|
|
|
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) {
|
2022-03-07 09:34:54 +00:00
|
|
|
while (!t.equals(this.g[first], "charset", true)) {
|
|
|
|
if (first != last) {
|
2021-08-03 07:33:18 +00:00
|
|
|
first += step2;
|
|
|
|
}
|
|
|
|
}
|
2022-03-07 09:34:54 +00:00
|
|
|
str = this.g[first + 1];
|
2021-08-03 07:33:18 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|