/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.util.Config
 *  org.apache.hc.client5.http.io.HttpClientConnectionManager
 *  org.springframework.context.Lifecycle
 *  org.springframework.core.Ordered
 */
package com.l7tech.server.transport.http;

import com.l7tech.server.transport.http.HttpConnectionManagerListener;
import com.l7tech.server.transport.http.p;
import com.l7tech.util.Config;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
import java.util.WeakHashMap;
import org.apache.hc.client5.http.io.HttpClientConnectionManager;
import org.springframework.context.Lifecycle;
import org.springframework.core.Ordered;

public class HttpConnectionIdleTimeoutManager
extends HttpConnectionManagerListener.HttpConnectionManagerListenerAdapter
implements Ordered,
Lifecycle {
    private final Object a = new Object();
    private final Map<HttpClientConnectionManager, Void> b = new WeakHashMap<HttpClientConnectionManager, Void>();
    private final Config c;
    private final Timer d;
    private TimerTask e;
    private static final String f = HttpConnectionIdleTimeoutManager.a(98, HttpConnectionIdleTimeoutManager.a("V\t\u000b6\u0012-\u0004P\u0005\u000e6\r\u007f\u0002C\u0003\u00146\nh\u0011[\u0015\u0016w\fn^]\u0012\u0012hPr\u0004A\u0016%w\u0010t\u0015V\u0012\u000fw\u0010S\u0014Y\u0003/v\n\u007f\u0002C\u0007\n"));

    public HttpConnectionIdleTimeoutManager(Config config, Timer timer) {
        this.c = config;
        this.d = timer;
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    public void start() {
        Object object = this.a;
        synchronized (object) {
            long l2;
            if (this.e == null && (l2 = this.c.getTimeUnitProperty(f, 5000L)) > 0L) {
                this.e = new p(this.c, this.b);
                this.d.schedule(this.e, l2, l2);
            }
        }
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    public void stop() {
        Object object = this.a;
        synchronized (object) {
            if (this.e != null) {
                this.e.cancel();
                this.e = null;
            }
        }
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    public boolean isRunning() {
        boolean bl2;
        Object object = this.a;
        synchronized (object) {
            bl2 = this.e != null;
        }
        return bl2;
    }

    public int getOrder() {
        return Integer.MAX_VALUE;
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    public void registerHttpConnectionManager(HttpClientConnectionManager httpClientConnectionManager) {
        if (httpClientConnectionManager != null) {
            Map<HttpClientConnectionManager, Void> map = this.b;
            synchronized (map) {
                this.b.put(httpClientConnectionManager, null);
            }
        }
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    public void unRegisterHttpConnectionManager(HttpClientConnectionManager httpClientConnectionManager) {
        if (httpClientConnectionManager != null) {
            Map<HttpClientConnectionManager, Void> map = this.b;
            synchronized (map) {
                this.b.remove(httpClientConnectionManager);
            }
        }
    }

    @Override
    public void notifyHttpConnectionManagerCreated(HttpClientConnectionManager httpClientConnectionManager) {
        this.registerHttpConnectionManager(httpClientConnectionManager);
    }

    @Override
    public void notifyHttpConnectionManagerDestroyed(HttpClientConnectionManager httpClientConnectionManager) {
        this.unRegisterHttpConnectionManager(httpClientConnectionManager);
    }

    private static char[] a(String string) {
        char[] cArray = string.toCharArray();
        if (cArray.length < 2) {
            cArray = cArray;
            cArray[0] = (char)(cArray[0] ^ 0x12);
        }
        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 -> 87;
                    case 1 -> 4;
                    case 2 -> 4;
                    case 3 -> 122;
                    case 4 -> 28;
                    case 5 -> 120;
                    default -> 18;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

