package okhttp3;

import K1.b;
import java.net.ProxySelector;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.TimeUnit;
import javax.net.SocketFactory;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.X509TrustManager;
import kotlin.jvm.internal.o;
import okhttp3.Call;
import okhttp3.WebSocket;
import okhttp3.internal.Util;
import okhttp3.internal.connection.RealCall;
import okhttp3.internal.connection.RouteDatabase;
import okhttp3.internal.platform.Platform;
import okhttp3.internal.proxy.NullProxySelector;
import okhttp3.internal.tls.CertificateChainCleaner;
import okhttp3.internal.tls.OkHostnameVerifier;

/* JADX INFO: loaded from: classes3.dex */
public class OkHttpClient implements Cloneable, Call.Factory, WebSocket.Factory {

    /* JADX INFO: renamed from: E, reason: collision with root package name */
    public static final Companion f22065E = new Companion(0);

    /* JADX INFO: renamed from: F, reason: collision with root package name */
    public static final List f22066F = Util.k(Protocol.HTTP_2, Protocol.HTTP_1_1);

    /* JADX INFO: renamed from: G, reason: collision with root package name */
    public static final List f22067G = Util.k(ConnectionSpec.f21976e, ConnectionSpec.f21977f);

    /* JADX INFO: renamed from: A, reason: collision with root package name */
    public final int f22068A;

    /* JADX INFO: renamed from: B, reason: collision with root package name */
    public final int f22069B;

    /* JADX INFO: renamed from: C, reason: collision with root package name */
    public final int f22070C;

    /* JADX INFO: renamed from: D, reason: collision with root package name */
    public final RouteDatabase f22071D;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final Dispatcher f22072a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final ConnectionPool f22073b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final List f22074c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final List f22075d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final b f22076e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final boolean f22077f;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public final Authenticator f22078j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public final boolean f22079k;
    public final boolean l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public final CookieJar f22080m;

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public final Cache f22081n;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public final Dns f22082o;

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    public final ProxySelector f22083p;

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public final Authenticator f22084q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public final SocketFactory f22085r;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public final SSLSocketFactory f22086s;

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public final X509TrustManager f22087t;

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public final List f22088u;

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    public final List f22089v;

    /* JADX INFO: renamed from: w, reason: collision with root package name */
    public final OkHostnameVerifier f22090w;

    /* JADX INFO: renamed from: x, reason: collision with root package name */
    public final CertificatePinner f22091x;

    /* JADX INFO: renamed from: y, reason: collision with root package name */
    public final CertificateChainCleaner f22092y;

    /* JADX INFO: renamed from: z, reason: collision with root package name */
    public final int f22093z;

    public static final class Builder {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        public Dispatcher f22094a = new Dispatcher();

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        public ConnectionPool f22095b = new ConnectionPool();

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        public final ArrayList f22096c = new ArrayList();

        /* JADX INFO: renamed from: d, reason: collision with root package name */
        public final ArrayList f22097d = new ArrayList();

        /* JADX INFO: renamed from: e, reason: collision with root package name */
        public final b f22098e;

        /* JADX INFO: renamed from: f, reason: collision with root package name */
        public boolean f22099f;

        /* JADX INFO: renamed from: g, reason: collision with root package name */
        public final Authenticator f22100g;

        /* JADX INFO: renamed from: h, reason: collision with root package name */
        public boolean f22101h;

        /* JADX INFO: renamed from: i, reason: collision with root package name */
        public boolean f22102i;

        /* JADX INFO: renamed from: j, reason: collision with root package name */
        public final CookieJar f22103j;

        /* JADX INFO: renamed from: k, reason: collision with root package name */
        public Cache f22104k;
        public final Dns l;

        /* JADX INFO: renamed from: m, reason: collision with root package name */
        public final Authenticator f22105m;

        /* JADX INFO: renamed from: n, reason: collision with root package name */
        public final SocketFactory f22106n;

        /* JADX INFO: renamed from: o, reason: collision with root package name */
        public final List f22107o;

        /* JADX INFO: renamed from: p, reason: collision with root package name */
        public List f22108p;

        /* JADX INFO: renamed from: q, reason: collision with root package name */
        public final OkHostnameVerifier f22109q;

        /* JADX INFO: renamed from: r, reason: collision with root package name */
        public final CertificatePinner f22110r;

        /* JADX INFO: renamed from: s, reason: collision with root package name */
        public int f22111s;

        /* JADX INFO: renamed from: t, reason: collision with root package name */
        public int f22112t;

        /* JADX INFO: renamed from: u, reason: collision with root package name */
        public int f22113u;

        /* JADX INFO: renamed from: v, reason: collision with root package name */
        public int f22114v;

        /* JADX INFO: renamed from: w, reason: collision with root package name */
        public final long f22115w;

        /* JADX INFO: renamed from: x, reason: collision with root package name */
        public RouteDatabase f22116x;

        public Builder() {
            EventListener$Companion$NONE$1 eventListener$Companion$NONE$1 = EventListener.f22010a;
            byte[] bArr = Util.f22179a;
            o.h(eventListener$Companion$NONE$1, "<this>");
            this.f22098e = new b(eventListener$Companion$NONE$1, 27);
            this.f22099f = true;
            Authenticator authenticator = Authenticator.f21899a;
            this.f22100g = authenticator;
            this.f22101h = true;
            this.f22102i = true;
            this.f22103j = CookieJar.f21999a;
            this.l = Dns.f22008a;
            this.f22105m = authenticator;
            SocketFactory socketFactory = SocketFactory.getDefault();
            o.g(socketFactory, "getDefault()");
            this.f22106n = socketFactory;
            OkHttpClient.f22065E.getClass();
            this.f22107o = OkHttpClient.f22067G;
            this.f22108p = OkHttpClient.f22066F;
            this.f22109q = OkHostnameVerifier.f22608a;
            this.f22110r = CertificatePinner.f21947d;
            this.f22112t = 10000;
            this.f22113u = 10000;
            this.f22114v = 10000;
            this.f22115w = 1024L;
        }

        public final OkHttpClient a() {
            return new OkHttpClient(this);
        }

        public final void b(long j4) {
            TimeUnit unit = TimeUnit.SECONDS;
            o.h(unit, "unit");
            this.f22111s = Util.b(j4);
        }

        public final void c(long j4) {
            TimeUnit unit = TimeUnit.SECONDS;
            o.h(unit, "unit");
            this.f22112t = Util.b(j4);
        }

        public final void d(long j4) {
            TimeUnit unit = TimeUnit.SECONDS;
            o.h(unit, "unit");
            this.f22113u = Util.b(j4);
        }

        public final void e(long j4) {
            TimeUnit unit = TimeUnit.SECONDS;
            o.h(unit, "unit");
            this.f22114v = Util.b(j4);
        }
    }

    public static final class Companion {
        public /* synthetic */ Companion(int i6) {
            this();
        }

        private Companion() {
        }
    }

    public OkHttpClient(Builder builder) {
        o.h(builder, "builder");
        this.f22072a = builder.f22094a;
        this.f22073b = builder.f22095b;
        this.f22074c = Util.y(builder.f22096c);
        this.f22075d = Util.y(builder.f22097d);
        this.f22076e = builder.f22098e;
        this.f22077f = builder.f22099f;
        this.f22078j = builder.f22100g;
        this.f22079k = builder.f22101h;
        this.l = builder.f22102i;
        this.f22080m = builder.f22103j;
        this.f22081n = builder.f22104k;
        this.f22082o = builder.l;
        ProxySelector proxySelector = ProxySelector.getDefault();
        this.f22083p = proxySelector == null ? NullProxySelector.f22597a : proxySelector;
        this.f22084q = builder.f22105m;
        this.f22085r = builder.f22106n;
        List list = builder.f22107o;
        this.f22088u = list;
        this.f22089v = builder.f22108p;
        this.f22090w = builder.f22109q;
        this.f22093z = builder.f22111s;
        this.f22068A = builder.f22112t;
        this.f22069B = builder.f22113u;
        this.f22070C = builder.f22114v;
        RouteDatabase routeDatabase = builder.f22116x;
        this.f22071D = routeDatabase == null ? new RouteDatabase() : routeDatabase;
        if (list == null || !list.isEmpty()) {
            Iterator it = list.iterator();
            while (it.hasNext()) {
                if (((ConnectionSpec) it.next()).f21978a) {
                    CertificatePinner certificatePinner = builder.f22110r;
                    Platform.Companion companion = Platform.Companion;
                    X509TrustManager x509TrustManagerPlatformTrustManager = companion.get().platformTrustManager();
                    this.f22087t = x509TrustManagerPlatformTrustManager;
                    Platform platform = companion.get();
                    o.e(x509TrustManagerPlatformTrustManager);
                    this.f22086s = platform.newSslSocketFactory(x509TrustManagerPlatformTrustManager);
                    CertificateChainCleaner.Companion.getClass();
                    CertificateChainCleaner certificateChainCleanerBuildCertificateChainCleaner = companion.get().buildCertificateChainCleaner(x509TrustManagerPlatformTrustManager);
                    this.f22092y = certificateChainCleanerBuildCertificateChainCleaner;
                    o.e(certificateChainCleanerBuildCertificateChainCleaner);
                    certificatePinner.getClass();
                    this.f22091x = o.c(certificatePinner.f21949b, certificateChainCleanerBuildCertificateChainCleaner) ? certificatePinner : new CertificatePinner(certificatePinner.f21948a, certificateChainCleanerBuildCertificateChainCleaner);
                }
            }
            this.f22086s = null;
            this.f22092y = null;
            this.f22087t = null;
            this.f22091x = CertificatePinner.f21947d;
        } else {
            this.f22086s = null;
            this.f22092y = null;
            this.f22087t = null;
            this.f22091x = CertificatePinner.f21947d;
        }
        List list2 = this.f22074c;
        o.f(list2, "null cannot be cast to non-null type kotlin.collections.List<okhttp3.Interceptor?>");
        if (list2.contains(null)) {
            throw new IllegalStateException(("Null interceptor: " + list2).toString());
        }
        List list3 = this.f22075d;
        o.f(list3, "null cannot be cast to non-null type kotlin.collections.List<okhttp3.Interceptor?>");
        if (list3.contains(null)) {
            throw new IllegalStateException(("Null network interceptor: " + list3).toString());
        }
        X509TrustManager x509TrustManager = this.f22087t;
        CertificateChainCleaner certificateChainCleaner = this.f22092y;
        SSLSocketFactory sSLSocketFactory = this.f22086s;
        List list4 = this.f22088u;
        if (list4 == null || !list4.isEmpty()) {
            Iterator it2 = list4.iterator();
            while (it2.hasNext()) {
                if (((ConnectionSpec) it2.next()).f21978a) {
                    if (sSLSocketFactory == null) {
                        throw new IllegalStateException("sslSocketFactory == null");
                    }
                    if (certificateChainCleaner == null) {
                        throw new IllegalStateException("certificateChainCleaner == null");
                    }
                    if (x509TrustManager == null) {
                        throw new IllegalStateException("x509TrustManager == null");
                    }
                    return;
                }
            }
        }
        if (sSLSocketFactory != null) {
            throw new IllegalStateException("Check failed.");
        }
        if (certificateChainCleaner != null) {
            throw new IllegalStateException("Check failed.");
        }
        if (x509TrustManager != null) {
            throw new IllegalStateException("Check failed.");
        }
        if (!o.c(this.f22091x, CertificatePinner.f21947d)) {
            throw new IllegalStateException("Check failed.");
        }
    }

    @Override // okhttp3.Call.Factory
    public final RealCall a(Request request) {
        o.h(request, "request");
        return new RealCall(this, request);
    }

    public final Object clone() {
        return super.clone();
    }

    public OkHttpClient() {
        this(new Builder());
    }
}
