package f0; import d0.t.r; import d0.t.u; import d0.z.d.m; import f0.e; import f0.f0.c; import f0.f0.g.l; import f0.f0.k.h; import f0.f0.m.d; import f0.t; import f0.z; import java.net.ProtocolException; import java.net.Proxy; import java.net.ProxySelector; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Random; import java.util.concurrent.TimeUnit; import javax.net.SocketFactory; import javax.net.ssl.HostnameVerifier; import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.X509TrustManager; import kotlin.TypeCastException; import kotlin.jvm.internal.DefaultConstructorMarker; import okhttp3.Interceptor; import okhttp3.WebSocket; import okhttp3.WebSocketListener; /* compiled from: OkHttpClient.kt */ public class x implements Cloneable, e.a { public static final List i = c.m(y.HTTP_2, y.HTTP_1_1); public static final List j = c.m(m.f2767c, m.d); public static final b k = new b(null); public final SSLSocketFactory A; public final X509TrustManager B; public final List C; public final List D; public final HostnameVerifier E; public final g F; public final f0.f0.m.c G; public final int H; public final int I; public final int J; public final int K; public final int L; public final long M; public final l N; public final q l; public final l m; public final List n; public final List o; public final t.b p; public final boolean q; public final c r; /* renamed from: s reason: collision with root package name */ public final boolean f2776s; public final boolean t; public final p u; public final s v; public final Proxy w; /* renamed from: x reason: collision with root package name */ public final ProxySelector f2777x; /* renamed from: y reason: collision with root package name */ public final c f2778y; /* renamed from: z reason: collision with root package name */ public final SocketFactory f2779z; /* compiled from: OkHttpClient.kt */ public static final class a { public int A; public long B; public l C; public q a = new q(); public l b = new l(); /* renamed from: c reason: collision with root package name */ public final List f2780c = new ArrayList(); public final List d = new ArrayList(); public t.b e; public boolean f; public c g; public boolean h; public boolean i; public p j; public s k; public Proxy l; public ProxySelector m; public c n; public SocketFactory o; public SSLSocketFactory p; public X509TrustManager q; public List r; /* renamed from: s reason: collision with root package name */ public List f2781s; public HostnameVerifier t; public g u; public f0.f0.m.c v; public int w; /* renamed from: x reason: collision with root package name */ public int f2782x; /* renamed from: y reason: collision with root package name */ public int f2783y; /* renamed from: z reason: collision with root package name */ public int f2784z; public a() { t tVar = t.a; m.checkParameterIsNotNull(tVar, "$this$asFactory"); this.e = new f0.f0.a(tVar); this.f = true; c cVar = c.a; this.g = cVar; this.h = true; this.i = true; this.j = p.a; this.k = s.a; this.n = cVar; SocketFactory socketFactory = SocketFactory.getDefault(); m.checkExpressionValueIsNotNull(socketFactory, "SocketFactory.getDefault()"); this.o = socketFactory; b bVar = x.k; this.r = x.j; this.f2781s = x.i; this.t = d.a; this.u = g.a; this.f2782x = 10000; this.f2783y = 10000; this.f2784z = 10000; this.B = 1024; } public final a a(long j, TimeUnit timeUnit) { m.checkParameterIsNotNull(timeUnit, "unit"); this.f2783y = c.b("timeout", j, timeUnit); return this; } public final a b(SSLSocketFactory sSLSocketFactory, X509TrustManager x509TrustManager) { m.checkParameterIsNotNull(sSLSocketFactory, "sslSocketFactory"); m.checkParameterIsNotNull(x509TrustManager, "trustManager"); if ((!m.areEqual(sSLSocketFactory, this.p)) || (!m.areEqual(x509TrustManager, this.q))) { this.C = null; } this.p = sSLSocketFactory; m.checkParameterIsNotNull(x509TrustManager, "trustManager"); h.a aVar = h.f2749c; this.v = h.a.b(x509TrustManager); this.q = x509TrustManager; return this; } } /* compiled from: OkHttpClient.kt */ public static final class b { public b(DefaultConstructorMarker defaultConstructorMarker) { } } public x() { this(new a()); } /* JADX DEBUG: Type inference failed for r1v0. Raw type applied. Possible types: java.util.List, java.util.List */ /* JADX WARNING: Removed duplicated region for block: B:110:0x0211 */ /* JADX WARNING: Removed duplicated region for block: B:24:0x00b3 */ /* JADX WARNING: Removed duplicated region for block: B:25:0x00be */ /* JADX WARNING: Removed duplicated region for block: B:49:0x0120 */ public x(a aVar) { ProxySelector proxySelector; boolean z2; List list; boolean z3; m.checkParameterIsNotNull(aVar, "builder"); this.l = aVar.a; this.m = aVar.b; this.n = c.z(aVar.f2780c); this.o = c.z(aVar.d); this.p = aVar.e; this.q = aVar.f; this.r = aVar.g; this.f2776s = aVar.h; this.t = aVar.i; this.u = aVar.j; this.v = aVar.k; Proxy proxy = aVar.l; this.w = proxy; if (proxy != null) { proxySelector = f0.f0.l.a.a; } else { proxySelector = aVar.m; proxySelector = proxySelector == null ? ProxySelector.getDefault() : proxySelector; if (proxySelector == null) { proxySelector = f0.f0.l.a.a; } } this.f2777x = proxySelector; this.f2778y = aVar.n; this.f2779z = aVar.o; List list2 = aVar.r; this.C = list2; this.D = aVar.f2781s; this.E = aVar.t; this.H = aVar.w; this.I = aVar.f2782x; this.J = aVar.f2783y; this.K = aVar.f2784z; this.L = aVar.A; this.M = aVar.B; l lVar = aVar.C; this.N = lVar == null ? new l() : lVar; boolean z4 = false; if (!(list2 instanceof Collection) || !list2.isEmpty()) { Iterator it = list2.iterator(); while (true) { if (it.hasNext()) { if (((m) it.next()).e) { z2 = false; break; } } else { break; } } if (!z2) { this.A = null; this.G = null; this.B = null; this.F = g.a; } else { SSLSocketFactory sSLSocketFactory = aVar.p; if (sSLSocketFactory != null) { this.A = sSLSocketFactory; f0.f0.m.c cVar = aVar.v; if (cVar == null) { m.throwNpe(); } this.G = cVar; X509TrustManager x509TrustManager = aVar.q; if (x509TrustManager == null) { m.throwNpe(); } this.B = x509TrustManager; g gVar = aVar.u; if (cVar == null) { m.throwNpe(); } this.F = gVar.b(cVar); } else { h.a aVar2 = h.f2749c; X509TrustManager n = h.a.n(); this.B = n; h hVar = h.a; if (n == null) { m.throwNpe(); } this.A = hVar.m(n); if (n == null) { m.throwNpe(); } m.checkParameterIsNotNull(n, "trustManager"); f0.f0.m.c b2 = h.a.b(n); this.G = b2; g gVar2 = aVar.u; if (b2 == null) { m.throwNpe(); } this.F = gVar2.b(b2); } } list = this.n; if (list != null) { throw new TypeCastException("null cannot be cast to non-null type kotlin.collections.List"); } else if (!list.contains(null)) { List list3 = this.o; if (list3 == null) { throw new TypeCastException("null cannot be cast to non-null type kotlin.collections.List"); } else if (!list3.contains(null)) { List list4 = this.C; if (!(list4 instanceof Collection) || !list4.isEmpty()) { Iterator it2 = list4.iterator(); while (true) { if (it2.hasNext()) { if (((m) it2.next()).e) { z3 = false; break; } } else { break; } } } z3 = true; if (z3) { if (this.A == null) { if (this.G == null) { if (!(this.B == null ? true : z4)) { throw new IllegalStateException("Check failed.".toString()); } else if (!m.areEqual(this.F, g.a)) { throw new IllegalStateException("Check failed.".toString()); } else { return; } } else { throw new IllegalStateException("Check failed.".toString()); } } else { throw new IllegalStateException("Check failed.".toString()); } } else if (this.A == null) { throw new IllegalStateException("sslSocketFactory == null".toString()); } else if (this.G == null) { throw new IllegalStateException("certificateChainCleaner == null".toString()); } else if (this.B == null) { throw new IllegalStateException("x509TrustManager == null".toString()); } else { return; } } else { StringBuilder L = c.d.b.a.a.L("Null network interceptor: "); L.append(this.o); throw new IllegalStateException(L.toString().toString()); } } else { StringBuilder L2 = c.d.b.a.a.L("Null interceptor: "); L2.append(this.n); throw new IllegalStateException(L2.toString().toString()); } } z2 = true; if (!z2) { } list = this.n; if (list != null) { } } @Override // f0.e.a public e b(z zVar) { m.checkParameterIsNotNull(zVar, "request"); return new f0.f0.g.e(this, zVar, false); } @Override // java.lang.Object public Object clone() { return super.clone(); } public a f() { m.checkParameterIsNotNull(this, "okHttpClient"); a aVar = new a(); aVar.a = this.l; aVar.b = this.m; r.addAll(aVar.f2780c, this.n); r.addAll(aVar.d, this.o); aVar.e = this.p; aVar.f = this.q; aVar.g = this.r; aVar.h = this.f2776s; aVar.i = this.t; aVar.j = this.u; aVar.k = this.v; aVar.l = this.w; aVar.m = this.f2777x; aVar.n = this.f2778y; aVar.o = this.f2779z; aVar.p = this.A; aVar.q = this.B; aVar.r = this.C; aVar.f2781s = this.D; aVar.t = this.E; aVar.u = this.F; aVar.v = this.G; aVar.w = this.H; aVar.f2782x = this.I; aVar.f2783y = this.J; aVar.f2784z = this.K; aVar.A = this.L; aVar.B = this.M; aVar.C = this.N; return aVar; } public WebSocket g(z zVar, WebSocketListener webSocketListener) { m.checkParameterIsNotNull(zVar, "request"); m.checkParameterIsNotNull(webSocketListener, "listener"); f0.f0.n.d dVar = new f0.f0.n.d(f0.f0.f.d.a, zVar, webSocketListener, new Random(), (long) this.L, null, this.M); m.checkParameterIsNotNull(this, "client"); if (dVar.u.b("Sec-WebSocket-Extensions") != null) { dVar.i(new ProtocolException("Request header not permitted: 'Sec-WebSocket-Extensions'"), null); } else { a f = f(); t tVar = t.a; m.checkParameterIsNotNull(tVar, "eventListener"); byte[] bArr = c.a; m.checkParameterIsNotNull(tVar, "$this$asFactory"); f.e = new f0.f0.a(tVar); List list = f0.f0.n.d.a; m.checkParameterIsNotNull(list, "protocols"); List mutableList = u.toMutableList((Collection) list); y yVar = y.H2_PRIOR_KNOWLEDGE; boolean z2 = false; if (mutableList.contains(yVar) || mutableList.contains(y.HTTP_1_1)) { if (!mutableList.contains(yVar) || mutableList.size() <= 1) { z2 = true; } if (!z2) { throw new IllegalArgumentException(("protocols containing h2_prior_knowledge cannot use other protocols: " + mutableList).toString()); } else if (!(!mutableList.contains(y.HTTP_1_0))) { throw new IllegalArgumentException(("protocols must not contain http/1.0: " + mutableList).toString()); } else if (!mutableList.contains(null)) { mutableList.remove(y.SPDY_3); if (!m.areEqual(mutableList, f.f2781s)) { f.C = null; } List unmodifiableList = Collections.unmodifiableList(mutableList); m.checkExpressionValueIsNotNull(unmodifiableList, "Collections.unmodifiableList(protocolsCopy)"); f.f2781s = unmodifiableList; x xVar = new x(f); z.a aVar = new z.a(dVar.u); aVar.b("Upgrade", "websocket"); aVar.b("Connection", "Upgrade"); aVar.b("Sec-WebSocket-Key", dVar.b); aVar.b("Sec-WebSocket-Version", "13"); aVar.b("Sec-WebSocket-Extensions", "permessage-deflate"); z a2 = aVar.a(); f0.f0.g.e eVar = new f0.f0.g.e(xVar, a2, true); dVar.f2753c = eVar; eVar.e(new f0.f0.n.e(dVar, a2)); } else { throw new IllegalArgumentException("protocols must not contain null".toString()); } } else { throw new IllegalArgumentException(("protocols must contain h2_prior_knowledge or http/1.1: " + mutableList).toString()); } } return dVar; } }