package com.google.android.gms.internal.firebase_ml; import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Set; /* loaded from: classes2.dex */ public final class zzez extends zzhm { private static final zzif zzto = new zzig("=&-_.!~*'()@:$,;/?:", false); private String fragment; private int port; private String zztp; private String zztq; private String zztr; private List zzts; public zzez() { this.port = -1; } public zzez(String str) { this(zzx(str)); } public zzez(URL url) { this(url.getProtocol(), url.getHost(), url.getPort(), url.getPath(), url.getRef(), url.getQuery(), url.getUserInfo()); } private zzez(String str, String str2, int i, String str3, String str4, String str5, String str6) { this.port = -1; this.zztp = str.toLowerCase(Locale.US); this.zztq = str2; this.port = i; this.zzts = zzw(str3); this.fragment = str4 != null ? zzie.zzar(str4) : null; if (str5 != null) { zzfu.zze(str5, this); } this.zztr = str6 != null ? zzie.zzar(str6) : null; } @Override // java.util.AbstractMap, java.util.Map public final int hashCode() { return zzew().hashCode(); } @Override // java.util.AbstractMap, java.util.Map public final boolean equals(Object obj) { if (this == obj) { return true; } if (super.equals(obj) && (obj instanceof zzez)) { return zzew().equals(((zzez) obj).zzew()); } return false; } @Override // java.util.AbstractMap public final String toString() { return zzew(); } public final String zzew() { StringBuilder sb = new StringBuilder(); sb.append((String) zzks.checkNotNull(this.zztp)); sb.append("://"); String str = this.zztr; if (str != null) { sb.append(zzie.zzau(str)); sb.append('@'); } sb.append((String) zzks.checkNotNull(this.zztq)); int i = this.port; if (i != -1) { sb.append(':'); sb.append(i); } String valueOf = String.valueOf(sb.toString()); StringBuilder sb2 = new StringBuilder(); List list = this.zzts; if (list != null) { int size = list.size(); for (int i2 = 0; i2 < size; i2++) { String str2 = this.zzts.get(i2); if (i2 != 0) { sb2.append('/'); } if (str2.length() != 0) { sb2.append(zzie.zzas(str2)); } } } zza(entrySet(), sb2); String str3 = this.fragment; if (str3 != null) { sb2.append('#'); sb2.append(zzto.zzaw(str3)); } String valueOf2 = String.valueOf(sb2.toString()); return valueOf2.length() != 0 ? valueOf.concat(valueOf2) : new String(valueOf); } public final URL zzu(String str) { try { return new URL(zzx(zzew()), str); } catch (MalformedURLException e) { throw new IllegalArgumentException(e); } } public final void zzv(String str) { this.zzts = zzw(null); } private static List zzw(String str) { String substring; if (str == null || str.length() == 0) { return null; } ArrayList arrayList = new ArrayList(); int i = 0; boolean z = true; while (z) { int indexOf = str.indexOf(47, i); boolean z2 = indexOf != -1; if (z2) { substring = str.substring(i, indexOf); } else { substring = str.substring(i); } arrayList.add(zzie.zzar(substring)); i = indexOf + 1; z = z2; } return arrayList; } /* JADX INFO: Access modifiers changed from: package-private */ public static void zza(Set> set, StringBuilder sb) { boolean z = true; for (Map.Entry entry : set) { Object value = entry.getValue(); if (value != null) { String zzav = zzie.zzav(entry.getKey()); if (value instanceof Collection) { Iterator it = ((Collection) value).iterator(); while (it.hasNext()) { z = zza(z, sb, zzav, it.next()); } } else { z = zza(z, sb, zzav, value); } } } } private static boolean zza(boolean z, StringBuilder sb, String str, Object obj) { if (z) { sb.append('?'); z = false; } else { sb.append('&'); } sb.append(str); String zzav = zzie.zzav(obj.toString()); if (zzav.length() != 0) { sb.append('='); sb.append(zzav); } return z; } private static URL zzx(String str) { try { return new URL(str); } catch (MalformedURLException e) { throw new IllegalArgumentException(e); } } @Override // com.google.android.gms.internal.firebase_ml.zzhm /* renamed from: zzeh */ public final /* synthetic */ zzhm clone() { return (zzez) clone(); } @Override // com.google.android.gms.internal.firebase_ml.zzhm public final /* synthetic */ zzhm zzb(String str, Object obj) { return (zzez) super.zzb(str, obj); } @Override // com.google.android.gms.internal.firebase_ml.zzhm, java.util.AbstractMap public final /* synthetic */ Object clone() throws CloneNotSupportedException { zzez zzezVar = (zzez) super.clone(); if (this.zzts != null) { zzezVar.zzts = new ArrayList(this.zzts); } return zzezVar; } }