package h5; import java.nio.charset.Charset; import java.util.Locale; import java.util.regex.Matcher; import java.util.regex.Pattern; /* loaded from: classes2.dex */ public final class e0 { /* renamed from: e, reason: collision with root package name */ private static final Pattern f10015e = Pattern.compile("([a-zA-Z0-9-!#$%&'*+.^_`{|}~]+)/([a-zA-Z0-9-!#$%&'*+.^_`{|}~]+)"); /* renamed from: f, reason: collision with root package name */ private static final Pattern f10016f = Pattern.compile(";\\s*(?:([a-zA-Z0-9-!#$%&'*+.^_`{|}~]+)=(?:([a-zA-Z0-9-!#$%&'*+.^_`{|}~]+)|\"([^\"]*)\"))?"); /* renamed from: a, reason: collision with root package name */ private final String f10017a; /* renamed from: b, reason: collision with root package name */ private final String f10018b; /* renamed from: c, reason: collision with root package name */ private final String f10019c; /* renamed from: d, reason: collision with root package name */ private final String f10020d; private e0(String str, String str2, String str3, String str4) { this.f10017a = str; this.f10018b = str2; this.f10019c = str3; this.f10020d = str4; } public static e0 b(String str) { Matcher matcher = f10015e.matcher(str); if (!matcher.lookingAt()) { return null; } String group = matcher.group(1); Locale locale = Locale.US; String lowerCase = group.toLowerCase(locale); String lowerCase2 = matcher.group(2).toLowerCase(locale); Matcher matcher2 = f10016f.matcher(str); String str2 = null; for (int end = matcher.end(); end < str.length(); end = matcher2.end()) { matcher2.region(end, str.length()); if (!matcher2.lookingAt()) { return null; } String group2 = matcher2.group(1); if (group2 != null && group2.equalsIgnoreCase("charset")) { String group3 = matcher2.group(2); if (group3 == null) { group3 = matcher2.group(3); } else if (group3.startsWith("'") && group3.endsWith("'") && group3.length() > 2) { group3 = group3.substring(1, group3.length() - 1); } if (str2 != null && !group3.equalsIgnoreCase(str2)) { return null; } str2 = group3; } } return new e0(str, lowerCase, lowerCase2, str2); } public Charset a(Charset charset) { try { String str = this.f10020d; return str != null ? Charset.forName(str) : charset; } catch (IllegalArgumentException unused) { return charset; } } public boolean equals(Object obj) { return (obj instanceof e0) && ((e0) obj).f10017a.equals(this.f10017a); } public int hashCode() { return this.f10017a.hashCode(); } public String toString() { return this.f10017a; } }