/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.common.http.GenericHttpClient
 *  com.l7tech.common.http.HttpProxyConfig
 *  com.l7tech.common.http.prov.apache.components.ClientConnectionManagerFactory
 *  com.l7tech.common.http.prov.apache.components.ClientConnectionManagerFactory$ConnectionManagerType
 *  com.l7tech.common.http.prov.apache.components.HttpComponentsClient
 *  com.l7tech.util.ConfigFactory
 *  org.apache.hc.client5.http.io.HttpClientConnectionManager
 *  org.jetbrains.annotations.Nullable
 */
package com.l7tech.server.globalresources;

import com.l7tech.common.http.GenericHttpClient;
import com.l7tech.common.http.HttpProxyConfig;
import com.l7tech.common.http.prov.apache.components.ClientConnectionManagerFactory;
import com.l7tech.common.http.prov.apache.components.HttpComponentsClient;
import com.l7tech.server.globalresources.HttpConfigurationCache;
import com.l7tech.server.globalresources.c;
import com.l7tech.server.transport.http.HttpConnectionManagerListener;
import com.l7tech.util.ConfigFactory;
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.hc.client5.http.io.HttpClientConnectionManager;
import org.jetbrains.annotations.Nullable;

public class ConfiguredCommonsHttpClientFactory
extends c {
    private static final String c;
    private static final String d;
    private static final int e;
    private static final int f;
    private static final AtomicBoolean g;
    private static final HttpClientConnectionManager h;

    public ConfiguredCommonsHttpClientFactory(HttpConfigurationCache httpConfigurationCache, HttpConnectionManagerListener httpConnectionManagerListener, boolean bl2) {
        super(httpConfigurationCache, bl2);
        if (g.compareAndSet(false, true)) {
            httpConnectionManagerListener.notifyHttpConnectionManagerCreated(h);
        }
    }

    @Override
    GenericHttpClient a(int n2, int n3, @Nullable HttpProxyConfig httpProxyConfig) {
        return new HttpComponentsClient(h, n2, n3, (Object)httpProxyConfig);
    }

    /*
     * Enabled aggressive block sorting
     */
    static {
        String[] stringArray = new String[2];
        int n2 = 0;
        String string = "wA\u0014vv\nr7I\u0016z\\\nr*|\u0010|}\no-\u0014wA\u0014va\nh8@6a[\u000by:X\u001ca[\u0016";
        int n3 = "wA\u0014vv\nr7I\u0016z\\\nr*|\u0010|}\no-\u0014wA\u0014va\nh8@6a[\u000by:X\u001ca[\u0016".length();
        int n4 = 22;
        int n5 = -1;
        while (true) {
            int n6 = ++n5;
            stringArray[n2++] = ConfiguredCommonsHttpClientFactory.a(37, ConfiguredCommonsHttpClientFactory.a(string.substring(n6, n6 + n4)));
            if ((n5 += n4) >= n3) {
                c = ConfiguredCommonsHttpClientFactory.class.getName() + stringArray[0];
                d = ConfiguredCommonsHttpClientFactory.class.getName() + stringArray[1];
                e = ConfigFactory.getIntProperty((String)c, (int)100);
                f = ConfigFactory.getIntProperty((String)d, (int)1000);
                g = new AtomicBoolean(false);
                h = ClientConnectionManagerFactory.getInstance().createConnectionManager(ClientConnectionManagerFactory.ConnectionManagerType.POOLING, e, f, false);
                return;
            }
            n4 = string.charAt(n5);
        }
    }

    private static char[] a(String string) {
        char[] cArray = string.toCharArray();
        if (cArray.length < 2) {
            cArray = cArray;
            cArray[0] = (char)(cArray[0] ^ 0x39);
        }
        return cArray;
    }

    /*
     * Handled impossible loop by duplicating code
     * Enabled aggressive block sorting
     */
    private static String a(int n2, char[] cArray) {
        char[] cArray2;
        block11: {
            int n3;
            int n4;
            int n5;
            block10: {
                n5 = n2;
                cArray2 = cArray;
                n4 = cArray.length;
                n3 = 0;
                if (!true) break block10;
                n4 = n4;
                if (n4 <= n3) break block11;
            }
            do {
                n5 = n5;
                cArray2 = cArray2;
                int n6 = n3;
                cArray2[n6] = (char)(cArray2[n6] ^ (n5 ^ (switch (n3 % 7) {
                    case 0 -> 124;
                    case 1 -> 9;
                    case 2 -> 80;
                    case 3 -> 43;
                    case 4 -> 16;
                    case 5 -> 64;
                    default -> 57;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

