package com.revenuecat.purchases.common;

import S4.p;
import S4.w;
import T4.b;
import android.os.Build;
import com.google.android.recaptcha.internal.a;
import com.revenuecat.purchases.ForceServerErrorStrategy;
import com.revenuecat.purchases.LogHandler;
import com.revenuecat.purchases.LogLevel;
import com.revenuecat.purchases.Store;
import com.revenuecat.purchases.VerificationResult;
import com.revenuecat.purchases.api.BuildConfig;
import com.revenuecat.purchases.common.LogWrapperKt;
import com.revenuecat.purchases.common.diagnostics.DiagnosticsTracker;
import com.revenuecat.purchases.common.networking.ConnectionErrorReason;
import com.revenuecat.purchases.common.networking.ETagManager;
import com.revenuecat.purchases.common.networking.Endpoint;
import com.revenuecat.purchases.common.networking.HTTPRequest;
import com.revenuecat.purchases.common.networking.HTTPResult;
import com.revenuecat.purchases.common.networking.HTTPTimeoutManager;
import com.revenuecat.purchases.common.networking.MapConverter;
import com.revenuecat.purchases.common.networking.NullPointerReadingErrorStreamException;
import com.revenuecat.purchases.common.networking.RCHTTPStatusCodes;
import com.revenuecat.purchases.common.verification.SignatureVerificationException;
import com.revenuecat.purchases.common.verification.SignatureVerificationMode;
import com.revenuecat.purchases.common.verification.SigningManager;
import com.revenuecat.purchases.interfaces.StorefrontProvider;
import com.revenuecat.purchases.strings.NetworkStrings;
import com.revenuecat.purchases.utils.MapExtensionsKt;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.SocketTimeoutException;
import java.net.URL;
import java.net.URLConnection;
import java.util.Arrays;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import kotlin.jvm.internal.h;
import kotlin.jvm.internal.o;
import org.json.JSONObject;
import w4.g;
import w4.k;
import x4.AbstractC3229F;
import x4.AbstractC3251q;
import x4.y;

/* JADX INFO: loaded from: classes3.dex */
public final class HTTPClient {
    public static final Companion Companion = new Companion(null);
    public static final int NO_STATUS_CODE = -1;
    private final AppConfig appConfig;
    private final DateProvider dateProvider;
    private final DiagnosticsTracker diagnosticsTrackerIfEnabled;
    private final ETagManager eTagManager;
    private final boolean enableExtraRequestLogging;
    private final ForceServerErrorStrategy forceServerErrorStrategy;
    private final LocaleProvider localeProvider;
    private final MapConverter mapConverter;
    private final RequestResponseListener requestResponseListener;
    private final SigningManager signingManager;
    private final StorefrontProvider storefrontProvider;
    private final HTTPTimeoutManager timeoutManager;

    public static final class Companion {
        public /* synthetic */ Companion(h hVar) {
            this();
        }

        private Companion() {
        }
    }

    public /* synthetic */ class WhenMappings {
        public static final /* synthetic */ int[] $EnumSwitchMapping$0;

        static {
            int[] iArr = new int[Store.values().length];
            try {
                iArr[Store.AMAZON.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            $EnumSwitchMapping$0 = iArr;
        }
    }

    public HTTPClient(AppConfig appConfig, ETagManager eTagManager, DiagnosticsTracker diagnosticsTracker, SigningManager signingManager, StorefrontProvider storefrontProvider, DateProvider dateProvider, MapConverter mapConverter, LocaleProvider localeProvider, ForceServerErrorStrategy forceServerErrorStrategy, RequestResponseListener requestResponseListener, HTTPTimeoutManager timeoutManager) {
        o.h(appConfig, "appConfig");
        o.h(eTagManager, "eTagManager");
        o.h(signingManager, "signingManager");
        o.h(storefrontProvider, "storefrontProvider");
        o.h(dateProvider, "dateProvider");
        o.h(mapConverter, "mapConverter");
        o.h(localeProvider, "localeProvider");
        o.h(timeoutManager, "timeoutManager");
        this.appConfig = appConfig;
        this.eTagManager = eTagManager;
        this.diagnosticsTrackerIfEnabled = diagnosticsTracker;
        this.signingManager = signingManager;
        this.storefrontProvider = storefrontProvider;
        this.dateProvider = dateProvider;
        this.mapConverter = mapConverter;
        this.localeProvider = localeProvider;
        this.forceServerErrorStrategy = forceServerErrorStrategy;
        this.requestResponseListener = requestResponseListener;
        this.timeoutManager = timeoutManager;
        this.enableExtraRequestLogging = false;
    }

    private final BufferedReader buffer(InputStream inputStream) {
        return new BufferedReader(new InputStreamReader(inputStream));
    }

    private final HttpURLConnection getConnection(HTTPRequest hTTPRequest, long j4) throws IOException {
        URLConnection uRLConnectionOpenConnection = hTTPRequest.getFullURL().openConnection();
        o.f(uRLConnectionOpenConnection, "null cannot be cast to non-null type java.net.HttpURLConnection");
        HttpURLConnection httpURLConnection = (HttpURLConnection) uRLConnectionOpenConnection;
        httpURLConnection.setConnectTimeout((int) j4);
        for (Map.Entry<String, String> entry : hTTPRequest.getHeaders().entrySet()) {
            httpURLConnection.addRequestProperty(entry.getKey(), entry.getValue());
        }
        JSONObject body = hTTPRequest.getBody();
        if (body != null) {
            httpURLConnection.setDoOutput(true);
            httpURLConnection.setRequestMethod("POST");
            OutputStream os = httpURLConnection.getOutputStream();
            o.g(os, "os");
            BufferedWriter bufferedWriterBuffer = buffer(os);
            String string = body.toString();
            o.g(string, "body.toString()");
            writeFully(bufferedWriterBuffer, string);
        }
        return httpURLConnection;
    }

    private final String getETagHeader(URLConnection uRLConnection) {
        return uRLConnection.getHeaderField("X-RevenueCat-ETag");
    }

    private final Map<String, String> getHeaders(Map<String, String> map, URL url, boolean z6, String str, boolean z7, String str2) {
        k kVar = new k("Content-Type", "application/json");
        k kVar2 = new k("X-Platform", getXPlatformHeader());
        k kVar3 = new k("X-Platform-Flavor", this.appConfig.getPlatformInfo().getFlavor());
        k kVar4 = new k("X-Platform-Flavor-Version", this.appConfig.getPlatformInfo().getVersion());
        k kVar5 = new k("X-Platform-Version", String.valueOf(Build.VERSION.SDK_INT));
        k kVar6 = new k("X-Platform-Device", Build.MODEL);
        k kVar7 = new k("X-Platform-Brand", Build.BRAND);
        k kVar8 = new k("X-Version", "9.26.1");
        k kVar9 = new k("X-Preferred-Locales", w.x0(this.localeProvider.getCurrentLocalesLanguageTags(), '-', '_'));
        k kVar10 = new k("X-Client-Locale", this.appConfig.getLanguageTag());
        k kVar11 = new k("X-Client-Version", this.appConfig.getVersionName());
        k kVar12 = new k("X-Client-Bundle-ID", this.appConfig.getPackageName());
        k kVar13 = new k("X-Observer-Mode-Enabled", this.appConfig.getFinishTransactions() ? "false" : "true");
        k kVar14 = new k("X-Nonce", str);
        k kVar15 = new k(HTTPRequest.POST_PARAMS_HASH, str2);
        k kVar16 = new k("X-Custom-Entitlements-Computation", this.appConfig.getCustomEntitlementComputation() ? "true" : null);
        k kVar17 = new k("X-UI-Preview-Mode", this.appConfig.getUiPreviewMode() ? "true" : null);
        k kVar18 = new k("X-Storefront", this.storefrontProvider.getStorefront());
        k kVar19 = new k("X-Is-Debug-Build", String.valueOf(this.appConfig.isDebugBuild()));
        g.f25463b.getClass();
        LinkedHashMap linkedHashMapZ = AbstractC3229F.z(AbstractC3229F.w(kVar, kVar2, kVar3, kVar4, kVar5, kVar6, kVar7, kVar8, kVar9, kVar10, kVar11, kVar12, kVar13, kVar14, kVar15, kVar16, kVar17, kVar18, kVar19, new k("X-Kotlin-Version", "2.1.0"), new k("X-Is-Backgrounded", String.valueOf(this.appConfig.isAppBackgrounded())), new k("X-Billing-Client-Sdk-Version", BuildConfig.BILLING_CLIENT_VERSION)), map);
        ETagManager eTagManager = this.eTagManager;
        String string = url.toString();
        o.g(string, "fullURL.toString()");
        return MapExtensionsKt.filterNotNullValues(AbstractC3229F.z(linkedHashMapZ, eTagManager.getETagHeaders$purchases_defaultsBc8Release(string, z7, z6)));
    }

    private final InputStream getInputStream(HttpURLConnection httpURLConnection) throws Exception {
        LogHandler currentLogHandler;
        String strJ;
        String str;
        try {
            return httpURLConnection.getInputStream();
        } catch (Exception e6) {
            if (!(e6 instanceof IllegalArgumentException ? true : e6 instanceof IOException)) {
                throw e6;
            }
            LogIntent logIntent = LogIntent.WARNING;
            HTTPClient$getInputStream$$inlined$log$1 hTTPClient$getInputStream$$inlined$log$1 = new HTTPClient$getInputStream$$inlined$log$1(logIntent, e6);
            switch (LogWrapperKt.WhenMappings.$EnumSwitchMapping$0[logIntent.ordinal()]) {
                case 1:
                    LogLevel logLevel = LogLevel.DEBUG;
                    currentLogHandler = LogWrapperKt.getCurrentLogHandler();
                    if (Config.INSTANCE.getLogLevel().compareTo(logLevel) <= 0) {
                        strJ = a.j(logLevel, new StringBuilder("[Purchases] - "));
                        str = (String) hTTPClient$getInputStream$$inlined$log$1.invoke();
                        currentLogHandler.d(strJ, str);
                    }
                    break;
                case 2:
                    LogWrapperKt.getCurrentLogHandler().e("[Purchases] - ERROR", (String) hTTPClient$getInputStream$$inlined$log$1.invoke(), null);
                    break;
                case 3:
                    LogLevel logLevel2 = LogLevel.WARN;
                    LogHandler currentLogHandler2 = LogWrapperKt.getCurrentLogHandler();
                    if (Config.INSTANCE.getLogLevel().compareTo(logLevel2) <= 0) {
                        currentLogHandler2.w(a.j(logLevel2, new StringBuilder("[Purchases] - ")), (String) hTTPClient$getInputStream$$inlined$log$1.invoke());
                    }
                    break;
                case 4:
                    LogLevel logLevel3 = LogLevel.INFO;
                    LogHandler currentLogHandler3 = LogWrapperKt.getCurrentLogHandler();
                    if (Config.INSTANCE.getLogLevel().compareTo(logLevel3) <= 0) {
                        currentLogHandler3.i(a.j(logLevel3, new StringBuilder("[Purchases] - ")), (String) hTTPClient$getInputStream$$inlined$log$1.invoke());
                    }
                    break;
                case 5:
                    LogLevel logLevel4 = LogLevel.DEBUG;
                    currentLogHandler = LogWrapperKt.getCurrentLogHandler();
                    if (Config.INSTANCE.getLogLevel().compareTo(logLevel4) <= 0) {
                        strJ = a.j(logLevel4, new StringBuilder("[Purchases] - "));
                        str = (String) hTTPClient$getInputStream$$inlined$log$1.invoke();
                        currentLogHandler.d(strJ, str);
                    }
                    break;
                case 6:
                    LogWrapperKt.getCurrentLogHandler().e("[Purchases] - ERROR", (String) hTTPClient$getInputStream$$inlined$log$1.invoke(), null);
                    break;
                case 7:
                    LogLevel logLevel5 = LogLevel.INFO;
                    LogHandler currentLogHandler4 = LogWrapperKt.getCurrentLogHandler();
                    if (Config.INSTANCE.getLogLevel().compareTo(logLevel5) <= 0) {
                        currentLogHandler4.i(a.j(logLevel5, new StringBuilder("[Purchases] - ")), (String) hTTPClient$getInputStream$$inlined$log$1.invoke());
                    }
                    break;
                case 8:
                    LogLevel logLevel6 = LogLevel.DEBUG;
                    currentLogHandler = LogWrapperKt.getCurrentLogHandler();
                    if (Config.INSTANCE.getLogLevel().compareTo(logLevel6) <= 0) {
                        strJ = a.j(logLevel6, new StringBuilder("[Purchases] - "));
                        str = (String) hTTPClient$getInputStream$$inlined$log$1.invoke();
                        currentLogHandler.d(strJ, str);
                    }
                    break;
                case 9:
                    LogLevel logLevel7 = LogLevel.DEBUG;
                    currentLogHandler = LogWrapperKt.getCurrentLogHandler();
                    if (Config.INSTANCE.getLogLevel().compareTo(logLevel7) <= 0) {
                        strJ = a.j(logLevel7, new StringBuilder("[Purchases] - "));
                        str = (String) hTTPClient$getInputStream$$inlined$log$1.invoke();
                        currentLogHandler.d(strJ, str);
                    }
                    break;
                case 10:
                    LogLevel logLevel8 = LogLevel.WARN;
                    LogHandler currentLogHandler5 = LogWrapperKt.getCurrentLogHandler();
                    if (Config.INSTANCE.getLogLevel().compareTo(logLevel8) <= 0) {
                        currentLogHandler5.w(a.j(logLevel8, new StringBuilder("[Purchases] - ")), (String) hTTPClient$getInputStream$$inlined$log$1.invoke());
                    }
                    break;
                case 11:
                    LogLevel logLevel9 = LogLevel.WARN;
                    LogHandler currentLogHandler6 = LogWrapperKt.getCurrentLogHandler();
                    if (Config.INSTANCE.getLogLevel().compareTo(logLevel9) <= 0) {
                        currentLogHandler6.w(a.j(logLevel9, new StringBuilder("[Purchases] - ")), (String) hTTPClient$getInputStream$$inlined$log$1.invoke());
                    }
                    break;
                case 12:
                    LogWrapperKt.getCurrentLogHandler().e("[Purchases] - ERROR", (String) hTTPClient$getInputStream$$inlined$log$1.invoke(), null);
                    break;
                case 13:
                    LogLevel logLevel10 = LogLevel.WARN;
                    LogHandler currentLogHandler7 = LogWrapperKt.getCurrentLogHandler();
                    if (Config.INSTANCE.getLogLevel().compareTo(logLevel10) <= 0) {
                        currentLogHandler7.w(a.j(logLevel10, new StringBuilder("[Purchases] - ")), (String) hTTPClient$getInputStream$$inlined$log$1.invoke());
                    }
                    break;
                case 14:
                    LogWrapperKt.getCurrentLogHandler().e("[Purchases] - ERROR", (String) hTTPClient$getInputStream$$inlined$log$1.invoke(), null);
                    break;
            }
            try {
                return httpURLConnection.getErrorStream();
            } catch (NullPointerException e7) {
                throw new NullPointerReadingErrorStreamException(e7.getMessage(), e7);
            }
        }
    }

    private final boolean getLoadShedderHeader(URLConnection uRLConnection) {
        String lowerCase;
        String headerField = uRLConnection.getHeaderField(HTTPResult.LOAD_SHEDDER_HEADER_NAME);
        if (headerField != null) {
            lowerCase = headerField.toLowerCase(Locale.ROOT);
            o.g(lowerCase, "toLowerCase(...)");
        } else {
            lowerCase = null;
        }
        return o.c(lowerCase, "true");
    }

    private final Date getRequestDateHeader(URLConnection uRLConnection) {
        String requestTimeHeader = getRequestTimeHeader(uRLConnection);
        if (requestTimeHeader != null) {
            return new Date(Long.parseLong(requestTimeHeader));
        }
        return null;
    }

    private final String getRequestTimeHeader(URLConnection uRLConnection) {
        String headerField = uRLConnection.getHeaderField(HTTPResult.REQUEST_TIME_HEADER_NAME);
        if (headerField == null || p.Q0(headerField)) {
            return null;
        }
        return headerField;
    }

    private final String getXPlatformHeader() {
        return WhenMappings.$EnumSwitchMapping$0[this.appConfig.getStore().ordinal()] == 1 ? "amazon" : "android";
    }

    /* JADX WARN: Removed duplicated region for block: B:45:0x00fa  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    private final HTTPResult performCall(URL url, boolean z6, Endpoint endpoint, Map<String, ? extends Object> map, List<k> list, Map<String, String> map2, boolean z7) throws Exception {
        URL url2;
        String postParamsForSigningHeaderIfNeeded;
        URL url3;
        String str;
        boolean z8;
        String str2;
        String str3;
        URL url4;
        String str4;
        int i6;
        boolean z9;
        String str5;
        HTTPClient hTTPClient;
        HttpURLConnection httpURLConnection;
        String str6;
        VerificationResult verificationResultVerifyResponse;
        RequestResponseListener requestResponseListener;
        ForceServerErrorStrategy forceServerErrorStrategy;
        ForceServerErrorStrategy forceServerErrorStrategy2;
        HTTPResult hTTPResultFakeResponseWithoutPerformingRequest;
        JSONObject jSONObjectConvertToJSON$purchases_defaultsBc8Release = map != null ? this.mapConverter.convertToJSON$purchases_defaultsBc8Release(map) : null;
        String path = endpoint.getPath(z6);
        boolean zShouldVerifyEndpoint = this.signingManager.shouldVerifyEndpoint(endpoint);
        boolean z10 = zShouldVerifyEndpoint && endpoint.getNeedsNonceToPerformSigning();
        if (this.appConfig.getRunningTests() && (forceServerErrorStrategy2 = this.forceServerErrorStrategy) != null && (hTTPResultFakeResponseWithoutPerformingRequest = forceServerErrorStrategy2.fakeResponseWithoutPerformingRequest(url, endpoint)) != null) {
            LogLevel logLevel = LogLevel.WARN;
            LogHandler currentLogHandler = LogWrapperKt.getCurrentLogHandler();
            if (Config.INSTANCE.getLogLevel().compareTo(logLevel) <= 0) {
                currentLogHandler.w(a.j(logLevel, new StringBuilder("[Purchases] - ")), "Faking response for request to " + Endpoint.getPath$default(endpoint, false, 1, null));
            }
            return hTTPResultFakeResponseWithoutPerformingRequest;
        }
        try {
            if (this.appConfig.getRunningTests() && (forceServerErrorStrategy = this.forceServerErrorStrategy) != null && forceServerErrorStrategy.shouldForceServerError(url, endpoint)) {
                LogLevel logLevel2 = LogLevel.WARN;
                LogHandler currentLogHandler2 = LogWrapperKt.getCurrentLogHandler();
                if (Config.INSTANCE.getLogLevel().compareTo(logLevel2) <= 0) {
                    currentLogHandler2.w("[Purchases] - " + logLevel2.name(), "Forcing server error for request to " + new URL(url, path));
                }
                url2 = new URL(this.forceServerErrorStrategy.getServerErrorURL());
            } else {
                url2 = new URL(url, path);
            }
            String strCreateRandomNonce = z10 ? this.signingManager.createRandomNonce() : null;
            if (list == null) {
                postParamsForSigningHeaderIfNeeded = null;
            } else if ((zShouldVerifyEndpoint ? list : null) != null) {
                postParamsForSigningHeaderIfNeeded = this.signingManager.getPostParamsForSigningHeaderIfNeeded(endpoint, list);
            }
            URL url5 = url2;
            HTTPRequest hTTPRequest = new HTTPRequest(url5, getHeaders(map2, url5, z7, strCreateRandomNonce, zShouldVerifyEndpoint, postParamsForSigningHeaderIfNeeded), jSONObjectConvertToJSON$purchases_defaultsBc8Release);
            if (this.enableExtraRequestLogging) {
                LogLevel logLevel3 = LogLevel.DEBUG;
                LogHandler currentLogHandler3 = LogWrapperKt.getCurrentLogHandler();
                url3 = url5;
                if (Config.INSTANCE.getLogLevel().compareTo(logLevel3) <= 0) {
                    currentLogHandler3.d("[Purchases] - " + logLevel3.name(), "HTTP request:\\n " + toCurlRequest(hTTPRequest));
                }
            } else {
                url3 = url5;
            }
            HttpURLConnection connection = getConnection(hTTPRequest, this.timeoutManager.getTimeoutForRequest(z6, endpoint.getSupportsFallbackBaseURLs() && !this.appConfig.getFallbackBaseURLs().isEmpty()));
            InputStream inputStream = getInputStream(connection);
            try {
                LogLevel logLevel4 = LogLevel.DEBUG;
                LogHandler currentLogHandler4 = LogWrapperKt.getCurrentLogHandler();
                Config config = Config.INSTANCE;
                if (config.getLogLevel().compareTo(logLevel4) <= 0) {
                    StringBuilder sb = new StringBuilder("[Purchases] - ");
                    str = strCreateRandomNonce;
                    sb.append(logLevel4.name());
                    z8 = zShouldVerifyEndpoint;
                    str2 = postParamsForSigningHeaderIfNeeded;
                    currentLogHandler4.d(sb.toString(), String.format(NetworkStrings.API_REQUEST_STARTED, Arrays.copyOf(new Object[]{connection.getRequestMethod(), path}, 2)));
                } else {
                    str = strCreateRandomNonce;
                    z8 = zShouldVerifyEndpoint;
                    str2 = postParamsForSigningHeaderIfNeeded;
                }
                int responseCode = connection.getResponseCode();
                String fully = inputStream != null ? readFully(inputStream) : null;
                if (this.enableExtraRequestLogging) {
                    LogHandler currentLogHandler5 = LogWrapperKt.getCurrentLogHandler();
                    if (config.getLogLevel().compareTo(logLevel4) <= 0) {
                        currentLogHandler5.d("[Purchases] - " + logLevel4.name(), "HTTP response:\\n  status code: " + responseCode + " \\n  body: " + fully);
                    }
                }
                if (inputStream != null) {
                    inputStream.close();
                }
                connection.disconnect();
                LogHandler currentLogHandler6 = LogWrapperKt.getCurrentLogHandler();
                if (config.getLogLevel().compareTo(logLevel4) <= 0) {
                    currentLogHandler6.d(a.j(logLevel4, new StringBuilder("[Purchases] - ")), String.format(NetworkStrings.API_REQUEST_COMPLETED, Arrays.copyOf(new Object[]{connection.getRequestMethod(), path, Integer.valueOf(responseCode)}, 3)));
                }
                if (fully == null) {
                    throw new IOException(NetworkStrings.HTTP_RESPONSE_PAYLOAD_NULL);
                }
                if (!this.appConfig.getRunningTests() || (requestResponseListener = this.requestResponseListener) == null) {
                    str3 = str;
                    url4 = url3;
                    str4 = fully;
                    i6 = responseCode;
                    z9 = z8;
                    str5 = str2;
                } else {
                    LinkedHashMap linkedHashMap = new LinkedHashMap();
                    Map<String, List<String>> headerFields = connection.getHeaderFields();
                    o.g(headerFields, "connection.headerFields");
                    for (Map.Entry<String, List<String>> entry : headerFields.entrySet()) {
                        String key = entry.getKey();
                        List<String> values = entry.getValue();
                        if (key != null) {
                            o.g(values, "values");
                            if (!values.isEmpty()) {
                                linkedHashMap.put(key, AbstractC3251q.m0(values, ", ", null, null, null, 62));
                            }
                        }
                    }
                    try {
                        URL url6 = new URL(url, path);
                        String string = url6.toString();
                        o.g(string, "fullURL.toString()");
                        String requestMethod = connection.getRequestMethod();
                        o.g(requestMethod, "connection.requestMethod");
                        url4 = url3;
                        str4 = fully;
                        z9 = z8;
                        str5 = str2;
                        str3 = str;
                        try {
                            try {
                                requestResponseListener.onRequestResponse(string, requestMethod, getHeaders(map2, url6, z7, str3, z9, str5), jSONObjectConvertToJSON$purchases_defaultsBc8Release != null ? jSONObjectConvertToJSON$purchases_defaultsBc8Release.toString() : null, responseCode, linkedHashMap, str4);
                                i6 = responseCode;
                            } catch (Throwable th) {
                                th = th;
                                i6 = responseCode;
                                LogLevel logLevel5 = LogLevel.WARN;
                                LogHandler currentLogHandler7 = LogWrapperKt.getCurrentLogHandler();
                                if (Config.INSTANCE.getLogLevel().compareTo(logLevel5) <= 0) {
                                    currentLogHandler7.w(a.j(logLevel5, new StringBuilder("[Purchases] - ")), "RequestResponseListener error: " + th.getMessage());
                                }
                            }
                        } catch (Throwable th2) {
                            th = th2;
                            i6 = responseCode;
                        }
                    } catch (Throwable th3) {
                        th = th3;
                        str3 = str;
                        url4 = url3;
                        str4 = fully;
                        i6 = responseCode;
                        z9 = z8;
                        str5 = str2;
                    }
                }
                if (z9 && RCHTTPStatusCodes.INSTANCE.isSuccessful(i6)) {
                    httpURLConnection = connection;
                    str6 = path;
                    verificationResultVerifyResponse = verifyResponse(str6, httpURLConnection, str4, str3, str5);
                    hTTPClient = this;
                } else {
                    hTTPClient = this;
                    httpURLConnection = connection;
                    str6 = path;
                    verificationResultVerifyResponse = VerificationResult.NOT_REQUESTED;
                }
                VerificationResult verificationResult = verificationResultVerifyResponse;
                if (verificationResult == VerificationResult.FAILED && (hTTPClient.signingManager.getSignatureVerificationMode() instanceof SignatureVerificationMode.Enforced)) {
                    throw new SignatureVerificationException(str6);
                }
                boolean loadShedderHeader = hTTPClient.getLoadShedderHeader(httpURLConnection);
                ETagManager eTagManager = hTTPClient.eTagManager;
                String eTagHeader = hTTPClient.getETagHeader(httpURLConnection);
                String string2 = url4.toString();
                o.g(string2, "fullURL.toString()");
                return eTagManager.getHTTPResultFromCacheOrBackend$purchases_defaultsBc8Release(i6, str4, eTagHeader, string2, z7, hTTPClient.getRequestDateHeader(httpURLConnection), verificationResult, loadShedderHeader, z6);
            } finally {
            }
        } catch (MalformedURLException e6) {
            throw new RuntimeException(e6);
        }
    }

    private static final boolean performRequest$canUseFallback(Endpoint endpoint, int i6, List<URL> list) {
        return endpoint.getSupportsFallbackBaseURLs() && i6 >= 0 && i6 < list.size();
    }

    /* JADX WARN: Multi-variable type inference failed */
    public static /* synthetic */ HTTPResult performRequest$default(HTTPClient hTTPClient, URL url, Endpoint endpoint, Map map, List list, Map map2, boolean z6, List list2, int i6, int i7, Object obj) {
        if ((i7 & 32) != 0) {
            z6 = false;
        }
        if ((i7 & 64) != 0) {
            list2 = y.f26065a;
        }
        if ((i7 & 128) != 0) {
            i6 = 0;
        }
        return hTTPClient.performRequest(url, endpoint, map, list, map2, z6, list2, i6);
    }

    private static final HTTPResult performRequest$performRequestToFallbackURL(List<URL> list, int i6, HTTPClient hTTPClient, Endpoint endpoint, Map<String, ? extends Object> map, List<k> list2, Map<String, String> map2, boolean z6) {
        LogHandler currentLogHandler;
        String strJ;
        String str;
        URL url = list.get(i6);
        LogIntent logIntent = LogIntent.DEBUG;
        HTTPClient$performRequest$performRequestToFallbackURL$$inlined$log$1 hTTPClient$performRequest$performRequestToFallbackURL$$inlined$log$1 = new HTTPClient$performRequest$performRequestToFallbackURL$$inlined$log$1(logIntent, endpoint, url);
        switch (LogWrapperKt.WhenMappings.$EnumSwitchMapping$0[logIntent.ordinal()]) {
            case 1:
                LogLevel logLevel = LogLevel.DEBUG;
                currentLogHandler = LogWrapperKt.getCurrentLogHandler();
                if (Config.INSTANCE.getLogLevel().compareTo(logLevel) <= 0) {
                    strJ = a.j(logLevel, new StringBuilder("[Purchases] - "));
                    str = (String) hTTPClient$performRequest$performRequestToFallbackURL$$inlined$log$1.invoke();
                    currentLogHandler.d(strJ, str);
                }
                break;
            case 2:
                LogWrapperKt.getCurrentLogHandler().e("[Purchases] - ERROR", (String) hTTPClient$performRequest$performRequestToFallbackURL$$inlined$log$1.invoke(), null);
                break;
            case 3:
                LogLevel logLevel2 = LogLevel.WARN;
                LogHandler currentLogHandler2 = LogWrapperKt.getCurrentLogHandler();
                if (Config.INSTANCE.getLogLevel().compareTo(logLevel2) <= 0) {
                    currentLogHandler2.w(a.j(logLevel2, new StringBuilder("[Purchases] - ")), (String) hTTPClient$performRequest$performRequestToFallbackURL$$inlined$log$1.invoke());
                }
                break;
            case 4:
                LogLevel logLevel3 = LogLevel.INFO;
                LogHandler currentLogHandler3 = LogWrapperKt.getCurrentLogHandler();
                if (Config.INSTANCE.getLogLevel().compareTo(logLevel3) <= 0) {
                    currentLogHandler3.i(a.j(logLevel3, new StringBuilder("[Purchases] - ")), (String) hTTPClient$performRequest$performRequestToFallbackURL$$inlined$log$1.invoke());
                }
                break;
            case 5:
                LogLevel logLevel4 = LogLevel.DEBUG;
                currentLogHandler = LogWrapperKt.getCurrentLogHandler();
                if (Config.INSTANCE.getLogLevel().compareTo(logLevel4) <= 0) {
                    strJ = a.j(logLevel4, new StringBuilder("[Purchases] - "));
                    str = (String) hTTPClient$performRequest$performRequestToFallbackURL$$inlined$log$1.invoke();
                    currentLogHandler.d(strJ, str);
                }
                break;
            case 6:
                LogWrapperKt.getCurrentLogHandler().e("[Purchases] - ERROR", (String) hTTPClient$performRequest$performRequestToFallbackURL$$inlined$log$1.invoke(), null);
                break;
            case 7:
                LogLevel logLevel5 = LogLevel.INFO;
                LogHandler currentLogHandler4 = LogWrapperKt.getCurrentLogHandler();
                if (Config.INSTANCE.getLogLevel().compareTo(logLevel5) <= 0) {
                    currentLogHandler4.i(a.j(logLevel5, new StringBuilder("[Purchases] - ")), (String) hTTPClient$performRequest$performRequestToFallbackURL$$inlined$log$1.invoke());
                }
                break;
            case 8:
                LogLevel logLevel6 = LogLevel.DEBUG;
                currentLogHandler = LogWrapperKt.getCurrentLogHandler();
                if (Config.INSTANCE.getLogLevel().compareTo(logLevel6) <= 0) {
                    strJ = a.j(logLevel6, new StringBuilder("[Purchases] - "));
                    str = (String) hTTPClient$performRequest$performRequestToFallbackURL$$inlined$log$1.invoke();
                    currentLogHandler.d(strJ, str);
                }
                break;
            case 9:
                LogLevel logLevel7 = LogLevel.DEBUG;
                currentLogHandler = LogWrapperKt.getCurrentLogHandler();
                if (Config.INSTANCE.getLogLevel().compareTo(logLevel7) <= 0) {
                    strJ = a.j(logLevel7, new StringBuilder("[Purchases] - "));
                    str = (String) hTTPClient$performRequest$performRequestToFallbackURL$$inlined$log$1.invoke();
                    currentLogHandler.d(strJ, str);
                }
                break;
            case 10:
                LogLevel logLevel8 = LogLevel.WARN;
                LogHandler currentLogHandler5 = LogWrapperKt.getCurrentLogHandler();
                if (Config.INSTANCE.getLogLevel().compareTo(logLevel8) <= 0) {
                    currentLogHandler5.w(a.j(logLevel8, new StringBuilder("[Purchases] - ")), (String) hTTPClient$performRequest$performRequestToFallbackURL$$inlined$log$1.invoke());
                }
                break;
            case 11:
                LogLevel logLevel9 = LogLevel.WARN;
                LogHandler currentLogHandler6 = LogWrapperKt.getCurrentLogHandler();
                if (Config.INSTANCE.getLogLevel().compareTo(logLevel9) <= 0) {
                    currentLogHandler6.w(a.j(logLevel9, new StringBuilder("[Purchases] - ")), (String) hTTPClient$performRequest$performRequestToFallbackURL$$inlined$log$1.invoke());
                }
                break;
            case 12:
                LogWrapperKt.getCurrentLogHandler().e("[Purchases] - ERROR", (String) hTTPClient$performRequest$performRequestToFallbackURL$$inlined$log$1.invoke(), null);
                break;
            case 13:
                LogLevel logLevel10 = LogLevel.WARN;
                LogHandler currentLogHandler7 = LogWrapperKt.getCurrentLogHandler();
                if (Config.INSTANCE.getLogLevel().compareTo(logLevel10) <= 0) {
                    currentLogHandler7.w(a.j(logLevel10, new StringBuilder("[Purchases] - ")), (String) hTTPClient$performRequest$performRequestToFallbackURL$$inlined$log$1.invoke());
                }
                break;
            case 14:
                LogWrapperKt.getCurrentLogHandler().e("[Purchases] - ERROR", (String) hTTPClient$performRequest$performRequestToFallbackURL$$inlined$log$1.invoke(), null);
                break;
        }
        return hTTPClient.performRequest(url, endpoint, map, list2, map2, z6, list, i6 + 1);
    }

    private final String readFully(InputStream inputStream) {
        return A4.g.P(buffer(inputStream));
    }

    private final String toCurlRequest(HTTPRequest hTTPRequest) {
        StringBuilder sb = new StringBuilder("curl -v -X ");
        sb.append(hTTPRequest.getBody() == null ? "GET" : "POST");
        sb.append(" \\\n  ");
        for (Map.Entry<String, String> entry : hTTPRequest.getHeaders().entrySet()) {
            sb.append("-H \"");
            sb.append(entry.getKey());
            sb.append(Constants.SUBS_ID_BASE_PLAN_ID_SEPARATOR);
            sb.append(entry.getValue());
            sb.append("\" \\\n  ");
        }
        if (hTTPRequest.getBody() != null) {
            sb.append("-d '");
            sb.append(hTTPRequest.getBody().toString());
            sb.append("' \\\n  ");
        }
        sb.append("\"");
        sb.append(hTTPRequest.getFullURL());
        sb.append("\"");
        String string = sb.toString();
        o.g(string, "builder.toString()");
        return string;
    }

    private final void trackHttpRequestPerformedIfNeeded(URL url, Endpoint endpoint, Date date, boolean z6, HTTPResult hTTPResult, boolean z7, IOException iOException) {
        VerificationResult verificationResult;
        DiagnosticsTracker diagnosticsTracker = this.diagnosticsTrackerIfEnabled;
        if (diagnosticsTracker != null) {
            long jBetween = DurationExtensionsKt.between(b.f6709b, date, this.dateProvider.getNow());
            int responseCode = z6 ? hTTPResult != null ? hTTPResult.getResponseCode() : RCHTTPStatusCodes.NOT_MODIFIED : -1;
            HTTPResult.Origin origin = hTTPResult != null ? hTTPResult.getOrigin() : null;
            if (hTTPResult == null || (verificationResult = hTTPResult.getVerificationResult()) == null) {
                verificationResult = VerificationResult.NOT_REQUESTED;
            }
            VerificationResult verificationResult2 = verificationResult;
            boolean z8 = z6 && RCHTTPStatusCodes.INSTANCE.isSuccessful(responseCode);
            ConnectionErrorReason connectionErrorReasonFromIOException = iOException != null ? ConnectionErrorReason.Companion.fromIOException(iOException) : null;
            String host = url.getHost();
            o.g(host, "baseURL.host");
            diagnosticsTracker.m503trackHttpRequestPerformedXzGXFE(host, endpoint, jBetween, z8, responseCode, hTTPResult != null ? hTTPResult.getBackendErrorCode() : null, origin, verificationResult2, z7, connectionErrorReasonFromIOException);
        }
    }

    private final VerificationResult verifyResponse(String str, URLConnection uRLConnection, String str2, String str3, String str4) {
        return this.signingManager.verifyResponse(str, uRLConnection.getHeaderField(HTTPResult.SIGNATURE_HEADER_NAME), str3, str2, getRequestTimeHeader(uRLConnection), getETagHeader(uRLConnection), str4);
    }

    private final void writeFully(BufferedWriter bufferedWriter, String str) throws IOException {
        bufferedWriter.write(str);
        bufferedWriter.flush();
    }

    public final void clearCaches() {
        this.eTagManager.clearCaches$purchases_defaultsBc8Release();
    }

    public final SigningManager getSigningManager() {
        return this.signingManager;
    }

    public final HTTPResult performRequest(URL baseURL, Endpoint endpoint, Map<String, ? extends Object> map, List<k> list, Map<String, String> requestHeaders, boolean z6, List<URL> fallbackBaseURLs, int i6) throws Throwable {
        IOException iOException;
        boolean z7;
        Date date;
        HTTPResult hTTPResult;
        Endpoint endpoint2;
        IOException iOException2;
        boolean z8;
        HTTPResult hTTPResult2;
        IOException iOException3;
        boolean z9;
        HTTPResult hTTPResult3;
        Date date2;
        Endpoint endpoint3;
        URL url;
        LogHandler currentLogHandler;
        String strJ;
        String str;
        IOException iOException4;
        HTTPResult hTTPResultPerformRequest$performRequestToFallbackURL;
        HTTPClient hTTPClient = this;
        o.h(baseURL, "baseURL");
        o.h(endpoint, "endpoint");
        o.h(requestHeaders, "requestHeaders");
        o.h(fallbackBaseURLs, "fallbackBaseURLs");
        boolean z10 = i6 == 0;
        Date now = hTTPClient.dateProvider.getNow();
        HTTPTimeoutManager.RequestResult requestResult = HTTPTimeoutManager.RequestResult.OTHER_RESULT;
        try {
            HTTPResult hTTPResultPerformCall = hTTPClient.performCall(baseURL, i6 > 0, endpoint, map, list, requestHeaders, z6);
            z7 = true;
            if (z10 && hTTPResultPerformCall != null) {
                try {
                    if (RCHTTPStatusCodes.INSTANCE.isSuccessful(hTTPResultPerformCall.getResponseCode())) {
                        requestResult = HTTPTimeoutManager.RequestResult.SUCCESS_ON_MAIN_BACKEND;
                    }
                } catch (IOException e6) {
                    iOException2 = e6;
                    hTTPResult2 = hTTPResultPerformCall;
                    z8 = true;
                    endpoint2 = endpoint;
                    try {
                        try {
                            if ((iOException2 instanceof SocketTimeoutException) && z10) {
                                try {
                                    if (performRequest$canUseFallback(endpoint2, i6, fallbackBaseURLs)) {
                                        requestResult = HTTPTimeoutManager.RequestResult.TIMEOUT_ON_MAIN_BACKEND_FOR_FALLBACK_SUPPORTED_ENDPOINT;
                                        iOException4 = iOException2;
                                        try {
                                            hTTPResultPerformRequest$performRequestToFallbackURL = performRequest$performRequestToFallbackURL(fallbackBaseURLs, i6, this, endpoint2, map, list, requestHeaders, z6);
                                            hTTPClient = this;
                                        } catch (Throwable th) {
                                            th = th;
                                            hTTPClient = this;
                                            iOException = iOException4;
                                            hTTPResult = hTTPResult2;
                                            date = now;
                                            z7 = z8;
                                            hTTPClient.timeoutManager.recordRequestResult(requestResult);
                                            hTTPClient.trackHttpRequestPerformedIfNeeded(baseURL, endpoint, date, z7, hTTPResult, z6, iOException);
                                            throw th;
                                        }
                                    }
                                    hTTPResult3 = hTTPResultPerformRequest$performRequestToFallbackURL;
                                    hTTPClient.timeoutManager.recordRequestResult(requestResult);
                                    url = baseURL;
                                    endpoint3 = endpoint;
                                    z9 = z6;
                                    iOException3 = iOException4;
                                    date2 = now;
                                    z7 = z8;
                                } catch (Throwable th2) {
                                    th = th2;
                                    iOException4 = iOException2;
                                }
                            }
                            if (!performRequest$canUseFallback(endpoint2, i6, fallbackBaseURLs)) {
                                hTTPClient = this;
                                iOException = iOException4;
                                date = now;
                                z7 = z8;
                                try {
                                    throw iOException;
                                } catch (Throwable th3) {
                                    th = th3;
                                    hTTPResult = hTTPResult2;
                                    hTTPClient.timeoutManager.recordRequestResult(requestResult);
                                    hTTPClient.trackHttpRequestPerformedIfNeeded(baseURL, endpoint, date, z7, hTTPResult, z6, iOException);
                                    throw th;
                                }
                            }
                            try {
                                hTTPResultPerformRequest$performRequestToFallbackURL = performRequest$performRequestToFallbackURL(fallbackBaseURLs, i6, this, endpoint2, map, list, requestHeaders, z6);
                                hTTPClient = this;
                                hTTPResult3 = hTTPResultPerformRequest$performRequestToFallbackURL;
                                hTTPClient.timeoutManager.recordRequestResult(requestResult);
                                url = baseURL;
                                endpoint3 = endpoint;
                                z9 = z6;
                                iOException3 = iOException4;
                                date2 = now;
                                z7 = z8;
                            } catch (Throwable th4) {
                                th = th4;
                                hTTPClient = this;
                                iOException = iOException4;
                                date = now;
                                z7 = z8;
                                hTTPResult = hTTPResult2;
                                hTTPClient.timeoutManager.recordRequestResult(requestResult);
                                hTTPClient.trackHttpRequestPerformedIfNeeded(baseURL, endpoint, date, z7, hTTPResult, z6, iOException);
                                throw th;
                            }
                        } catch (Throwable th5) {
                            th = th5;
                            hTTPClient = this;
                        }
                        iOException4 = iOException2;
                    } catch (Throwable th6) {
                        th = th6;
                        iOException = iOException2;
                        date = now;
                        z7 = z8;
                        hTTPClient = this;
                    }
                } catch (Throwable th7) {
                    th = th7;
                    hTTPResult = hTTPResultPerformCall;
                    date = now;
                    iOException = null;
                    hTTPClient.timeoutManager.recordRequestResult(requestResult);
                    hTTPClient.trackHttpRequestPerformedIfNeeded(baseURL, endpoint, date, z7, hTTPResult, z6, iOException);
                    throw th;
                }
            }
            hTTPClient.timeoutManager.recordRequestResult(requestResult);
            url = baseURL;
            z9 = z6;
            hTTPResult3 = hTTPResultPerformCall;
            date2 = now;
            iOException3 = null;
            endpoint3 = endpoint;
        } catch (IOException e7) {
            endpoint2 = endpoint;
            iOException2 = e7;
            z8 = false;
            hTTPResult2 = null;
        } catch (Throwable th8) {
            th = th8;
            iOException = null;
            hTTPClient = this;
            z7 = false;
            date = now;
            hTTPResult = null;
        }
        hTTPClient.trackHttpRequestPerformedIfNeeded(url, endpoint3, date2, z7, hTTPResult3, z9, iOException3);
        HTTPResult hTTPResult4 = hTTPResult3;
        if (hTTPResult4 != null) {
            return (RCHTTPStatusCodes.INSTANCE.isServerError(hTTPResult4.getResponseCode()) && performRequest$canUseFallback(endpoint, i6, fallbackBaseURLs)) ? performRequest$performRequestToFallbackURL(fallbackBaseURLs, i6, this, endpoint, map, list, requestHeaders, z6) : hTTPResult4;
        }
        LogIntent logIntent = LogIntent.WARNING;
        HTTPClient$performRequest$$inlined$log$1 hTTPClient$performRequest$$inlined$log$1 = new HTTPClient$performRequest$$inlined$log$1(logIntent);
        switch (LogWrapperKt.WhenMappings.$EnumSwitchMapping$0[logIntent.ordinal()]) {
            case 1:
                LogLevel logLevel = LogLevel.DEBUG;
                currentLogHandler = LogWrapperKt.getCurrentLogHandler();
                if (Config.INSTANCE.getLogLevel().compareTo(logLevel) <= 0) {
                    strJ = a.j(logLevel, new StringBuilder("[Purchases] - "));
                    str = (String) hTTPClient$performRequest$$inlined$log$1.invoke();
                    currentLogHandler.d(strJ, str);
                }
                break;
            case 2:
                LogWrapperKt.getCurrentLogHandler().e("[Purchases] - ERROR", (String) hTTPClient$performRequest$$inlined$log$1.invoke(), null);
                break;
            case 3:
                LogLevel logLevel2 = LogLevel.WARN;
                LogHandler currentLogHandler2 = LogWrapperKt.getCurrentLogHandler();
                if (Config.INSTANCE.getLogLevel().compareTo(logLevel2) <= 0) {
                    currentLogHandler2.w(a.j(logLevel2, new StringBuilder("[Purchases] - ")), (String) hTTPClient$performRequest$$inlined$log$1.invoke());
                }
                break;
            case 4:
                LogLevel logLevel3 = LogLevel.INFO;
                LogHandler currentLogHandler3 = LogWrapperKt.getCurrentLogHandler();
                if (Config.INSTANCE.getLogLevel().compareTo(logLevel3) <= 0) {
                    currentLogHandler3.i(a.j(logLevel3, new StringBuilder("[Purchases] - ")), (String) hTTPClient$performRequest$$inlined$log$1.invoke());
                }
                break;
            case 5:
                LogLevel logLevel4 = LogLevel.DEBUG;
                currentLogHandler = LogWrapperKt.getCurrentLogHandler();
                if (Config.INSTANCE.getLogLevel().compareTo(logLevel4) <= 0) {
                    strJ = a.j(logLevel4, new StringBuilder("[Purchases] - "));
                    str = (String) hTTPClient$performRequest$$inlined$log$1.invoke();
                    currentLogHandler.d(strJ, str);
                }
                break;
            case 6:
                LogWrapperKt.getCurrentLogHandler().e("[Purchases] - ERROR", (String) hTTPClient$performRequest$$inlined$log$1.invoke(), null);
                break;
            case 7:
                LogLevel logLevel5 = LogLevel.INFO;
                LogHandler currentLogHandler4 = LogWrapperKt.getCurrentLogHandler();
                if (Config.INSTANCE.getLogLevel().compareTo(logLevel5) <= 0) {
                    currentLogHandler4.i(a.j(logLevel5, new StringBuilder("[Purchases] - ")), (String) hTTPClient$performRequest$$inlined$log$1.invoke());
                }
                break;
            case 8:
                LogLevel logLevel6 = LogLevel.DEBUG;
                currentLogHandler = LogWrapperKt.getCurrentLogHandler();
                if (Config.INSTANCE.getLogLevel().compareTo(logLevel6) <= 0) {
                    strJ = a.j(logLevel6, new StringBuilder("[Purchases] - "));
                    str = (String) hTTPClient$performRequest$$inlined$log$1.invoke();
                    currentLogHandler.d(strJ, str);
                }
                break;
            case 9:
                LogLevel logLevel7 = LogLevel.DEBUG;
                currentLogHandler = LogWrapperKt.getCurrentLogHandler();
                if (Config.INSTANCE.getLogLevel().compareTo(logLevel7) <= 0) {
                    strJ = a.j(logLevel7, new StringBuilder("[Purchases] - "));
                    str = (String) hTTPClient$performRequest$$inlined$log$1.invoke();
                    currentLogHandler.d(strJ, str);
                }
                break;
            case 10:
                LogLevel logLevel8 = LogLevel.WARN;
                LogHandler currentLogHandler5 = LogWrapperKt.getCurrentLogHandler();
                if (Config.INSTANCE.getLogLevel().compareTo(logLevel8) <= 0) {
                    currentLogHandler5.w(a.j(logLevel8, new StringBuilder("[Purchases] - ")), (String) hTTPClient$performRequest$$inlined$log$1.invoke());
                }
                break;
            case 11:
                LogLevel logLevel9 = LogLevel.WARN;
                LogHandler currentLogHandler6 = LogWrapperKt.getCurrentLogHandler();
                if (Config.INSTANCE.getLogLevel().compareTo(logLevel9) <= 0) {
                    currentLogHandler6.w(a.j(logLevel9, new StringBuilder("[Purchases] - ")), (String) hTTPClient$performRequest$$inlined$log$1.invoke());
                }
                break;
            case 12:
                LogWrapperKt.getCurrentLogHandler().e("[Purchases] - ERROR", (String) hTTPClient$performRequest$$inlined$log$1.invoke(), null);
                break;
            case 13:
                LogLevel logLevel10 = LogLevel.WARN;
                LogHandler currentLogHandler7 = LogWrapperKt.getCurrentLogHandler();
                if (Config.INSTANCE.getLogLevel().compareTo(logLevel10) <= 0) {
                    currentLogHandler7.w(a.j(logLevel10, new StringBuilder("[Purchases] - ")), (String) hTTPClient$performRequest$$inlined$log$1.invoke());
                }
                break;
            case 14:
                LogWrapperKt.getCurrentLogHandler().e("[Purchases] - ERROR", (String) hTTPClient$performRequest$$inlined$log$1.invoke(), null);
                break;
        }
        return performRequest(baseURL, endpoint, map, list, requestHeaders, true, fallbackBaseURLs, i6);
    }

    private final BufferedWriter buffer(OutputStream outputStream) {
        return new BufferedWriter(new OutputStreamWriter(outputStream));
    }

    /* JADX WARN: Illegal instructions before constructor call */
    public /* synthetic */ HTTPClient(AppConfig appConfig, ETagManager eTagManager, DiagnosticsTracker diagnosticsTracker, SigningManager signingManager, StorefrontProvider storefrontProvider, DateProvider dateProvider, MapConverter mapConverter, LocaleProvider localeProvider, ForceServerErrorStrategy forceServerErrorStrategy, RequestResponseListener requestResponseListener, HTTPTimeoutManager hTTPTimeoutManager, int i6, h hVar) {
        DateProvider defaultDateProvider = (i6 & 32) != 0 ? new DefaultDateProvider() : dateProvider;
        this(appConfig, eTagManager, diagnosticsTracker, signingManager, storefrontProvider, defaultDateProvider, (i6 & 64) != 0 ? new MapConverter() : mapConverter, localeProvider, (i6 & 256) != 0 ? null : forceServerErrorStrategy, (i6 & 512) != 0 ? null : requestResponseListener, (i6 & 1024) != 0 ? new HTTPTimeoutManager(appConfig, defaultDateProvider) : hTTPTimeoutManager);
    }
}
