/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.util.SyspropUtil
 */
package com.l7tech.server;

import com.l7tech.server.ServerConfig;
import com.l7tech.server.TelemetryPropertiesLoader;
import com.l7tech.util.SyspropUtil;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.function.Function;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;

public class TelemetryPropertiesLoaderImpl
implements TelemetryPropertiesLoader {
    private static final Logger a;
    private static final String b;
    private static final String c;
    private static final String d;
    private static final String e;
    private static final String f;
    private static TelemetryPropertiesLoaderImpl g;
    private final Properties h = new Properties();
    private final boolean i = SyspropUtil.getBoolean((String)j[2], (boolean)false);
    private static final String[] j;

    TelemetryPropertiesLoaderImpl() {
        this.a();
    }

    public static synchronized TelemetryPropertiesLoader getInstance() {
        if (null == g) {
            g = new TelemetryPropertiesLoaderImpl();
        }
        return g;
    }

    /*
     * Exception decompiling
     */
    private void a() {
        /*
         * This method has failed to decompile.  When submitting a bug report, please provide this stack trace, and (if you hold appropriate legal rights) the relevant class file.
         * 
         * org.benf.cfr.reader.util.ConfusedCFRException: Tried to end blocks [3[TRYBLOCK]], but top level block is 7[SWITCH]
         *     at org.benf.cfr.reader.bytecode.analysis.opgraph.Op04StructuredStatement.processEndingBlocks(Op04StructuredStatement.java:435)
         *     at org.benf.cfr.reader.bytecode.analysis.opgraph.Op04StructuredStatement.buildNestedBlocks(Op04StructuredStatement.java:484)
         *     at org.benf.cfr.reader.bytecode.analysis.opgraph.Op03SimpleStatement.createInitialStructuredBlock(Op03SimpleStatement.java:736)
         *     at org.benf.cfr.reader.bytecode.CodeAnalyser.getAnalysisInner(CodeAnalyser.java:850)
         *     at org.benf.cfr.reader.bytecode.CodeAnalyser.getAnalysisOrWrapFail(CodeAnalyser.java:278)
         *     at org.benf.cfr.reader.bytecode.CodeAnalyser.getAnalysis(CodeAnalyser.java:201)
         *     at org.benf.cfr.reader.entities.attributes.AttributeCode.analyse(AttributeCode.java:94)
         *     at org.benf.cfr.reader.entities.Method.analyse(Method.java:531)
         *     at org.benf.cfr.reader.entities.ClassFile.analyseMid(ClassFile.java:1055)
         *     at org.benf.cfr.reader.entities.ClassFile.analyseTop(ClassFile.java:942)
         *     at org.benf.cfr.reader.Driver.doJarVersionTypes(Driver.java:257)
         *     at org.benf.cfr.reader.Driver.doJar(Driver.java:139)
         *     at org.benf.cfr.reader.CfrDriverImpl.analyse(CfrDriverImpl.java:76)
         *     at org.benf.cfr.reader.Main.main(Main.java:54)
         */
        throw new IllegalStateException("Decompilation failed");
    }

    private Map<String, String> a(Map<String, String> map) {
        HashMap<String, String> hashMap = new HashMap<String, String>();
        for (Map.Entry<String, String> entry : map.entrySet()) {
            hashMap.put(entry.getKey(), System.getenv(entry.getValue()));
        }
        return hashMap;
    }

    private Map<String, String> b() {
        Map<String, String> map;
        InputStream inputStream;
        Properties properties;
        block17: {
            String[] stringArray;
            block16: {
                stringArray = j;
                String string = ServerConfig.getInstance().getProperty(stringArray[7]);
                File file = new File(string);
                properties = new Properties();
                try {
                    if (!file.exists()) break block16;
                    inputStream = new FileInputStream(file);
                    break block17;
                }
                catch (Throwable throwable) {
                    throw TelemetryPropertiesLoaderImpl.a(throwable);
                }
            }
            stringArray = j;
            inputStream = TelemetryPropertiesLoaderImpl.class.getResourceAsStream(stringArray[1]);
        }
        FileInputStream fileInputStream = inputStream;
        try {
            try {
                if (fileInputStream != null) {
                    properties.load(fileInputStream);
                }
            }
            catch (Throwable throwable) {
                throw TelemetryPropertiesLoaderImpl.a(throwable);
            }
            map = TelemetryPropertiesLoaderImpl.a(properties);
        }
        catch (Throwable throwable) {
            try {
                if (fileInputStream != null) {
                    try {
                        ((InputStream)fileInputStream).close();
                    }
                    catch (Throwable throwable2) {
                        throwable.addSuppressed(throwable2);
                    }
                }
                throw throwable;
            }
            catch (IOException iOException) {
                a.log(Level.WARNING, j[4], iOException);
                return Collections.emptyMap();
            }
        }
        try {
            if (fileInputStream != null) {
                ((InputStream)fileInputStream).close();
            }
        }
        catch (Throwable throwable) {
            throw TelemetryPropertiesLoaderImpl.a(throwable);
        }
        return map;
    }

    private static Map<String, String> a(Properties properties) {
        Map map = properties.stringPropertyNames().stream().collect(Collectors.toMap(Function.identity(), properties::getProperty));
        return Collections.unmodifiableMap(map);
    }

    private void a(String string, String string2, boolean bl2) {
        if (bl2) {
            String[] stringArray = j;
            if (stringArray[13].equals(string) || stringArray[8].equals(string)) {
                stringArray = j;
                a.log(Level.CONFIG, stringArray[5], string);
            } else {
                a.log(Level.CONFIG, j[3], new Object[]{string, string2});
            }
        }
        this.h.setProperty(string, string2);
    }

    @Override
    public Properties getProperties() {
        return this.h;
    }

    @Override
    public String getProperty(String string, String string2) {
        return this.h.getProperty(string, string2);
    }

    /*
     * Unable to fully structure code
     */
    static {
        block10: {
            block9: {
                var5 = new String[18];
                var3_1 = 0;
                var2_2 = "2\u001f rL<V\u0014\"\u001f*vT5V$\u0003hcK?R3\b2z\\#\u00195\u0015+=UgV3\u0019.=]9Q=\u0016#`J\u0013M8\u001c/t\"\u0005\u001f2gP>Ev\u000e#\u007f\\=G\"\b?3I\"M&\u001f4g@pYf\u0007{h\b-$\u0013\b4|KpC5\u0019#`J9L1Z2vU5O3\u000e4j\u0019 P9\n#aM9G%0\u0003\t/}^pQ&\u001f%z_9G2Z0rU%Gv\u001c)a\u0019$G:\u001f+vM\"[v\n4|I5P\"\u0003fh\t-\u00072\u001f rL<V\u0017\"\u001f*vT5V$\u0003\u0016aV G$\u000e/vJ\u0000C\"\u0012\u0018\"\u001f*vT5V$\u0003hcK?Z/T6rJ#U9\b\"\u0014\"\u001f*vT5V$\u0003hcK?R3\b2z\\#\b \u001b4zX2N3/\u0003\u00144vZ?E8\u0013<v]pV3\u0016#~\\$P/Z6aV G$\u000e?3]5D?\u0014/gP?LlZ=#D#\"\u001f*vT5V$\u0003\u0016aV Q\u0013\u00140EX\"f3\u001c5=I\"M&\u001f4gP5Q\u001a\"\u001f*vT5V$\u0003h`\\7O3\u00142=N\"K\"\u001f\rv@D\u0006\b)qU5Ov\b#r]9L1Z/}M5P8\u001b*3M5N3\u0017#gK)\u00023\u00140zK?L;\u001f(g\u0019&C$\u0013'qU5Qv\u001e#uP>K\"\u0013)}J\u00195\u0015+=UgV3\u0019.=]9Q=\u0016#`J\u0013M8\u001c/t";
                var4_3 = "2\u001f rL<V\u0014\"\u001f*vT5V$\u0003hcK?R3\b2z\\#\u00195\u0015+=UgV3\u0019.=]9Q=\u0016#`J\u0013M8\u001c/t\"\u0005\u001f2gP>Ev\u000e#\u007f\\=G\"\b?3I\"M&\u001f4g@pYf\u0007{h\b-$\u0013\b4|KpC5\u0019#`J9L1Z2vU5O3\u000e4j\u0019 P9\n#aM9G%0\u0003\t/}^pQ&\u001f%z_9G2Z0rU%Gv\u001c)a\u0019$G:\u001f+vM\"[v\n4|I5P\"\u0003fh\t-\u00072\u001f rL<V\u0017\"\u001f*vT5V$\u0003\u0016aV G$\u000e/vJ\u0000C\"\u0012\u0018\"\u001f*vT5V$\u0003hcK?Z/T6rJ#U9\b\"\u0014\"\u001f*vT5V$\u0003hcK?R3\b2z\\#\b \u001b4zX2N3/\u0003\u00144vZ?E8\u0013<v]pV3\u0016#~\\$P/Z6aV G$\u000e?3]5D?\u0014/gP?LlZ=#D#\"\u001f*vT5V$\u0003\u0016aV Q\u0013\u00140EX\"f3\u001c5=I\"M&\u001f4gP5Q\u001a\"\u001f*vT5V$\u0003h`\\7O3\u00142=N\"K\"\u001f\rv@D\u0006\b)qU5Ov\b#r]9L1Z/}M5P8\u001b*3M5N3\u0017#gK)\u00023\u00140zK?L;\u001f(g\u0019&C$\u0013'qU5Qv\u001e#uP>K\"\u0013)}J\u00195\u0015+=UgV3\u0019.=]9Q=\u0016#`J\u0013M8\u001c/t".length();
                var1_4 = 7;
                var0_5 = -1;
lbl7:
                // 2 sources

                while (true) {
                    v0 = 4;
                    v1 = ++var0_5;
                    v2 = var2_2.substring(v1, v1 + var1_4);
                    v3 = -1;
                    break block9;
                    break;
                }
lbl13:
                // 1 sources

                while (true) {
                    var5[var3_1++] = TelemetryPropertiesLoaderImpl.a(v0, TelemetryPropertiesLoaderImpl.a(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    var2_2 = "iTa=\u001f~\u001doH]*\u001dk\u001aX_{\u000e\u0013i-xW~v\u0002i\u0006mT\u007f,\u001b~\u001a\bkP\u007f1\u0013y\u0005x";
                    var4_3 = "iTa=\u001f~\u001doH]*\u001dk\u001aX_{\u000e\u0013i-xW~v\u0002i\u0006mT\u007f,\u001b~\u001a\bkP\u007f1\u0013y\u0005x".length();
                    var1_4 = 35;
                    var0_5 = -1;
lbl22:
                    // 2 sources

                    while (true) {
                        v0 = 79;
                        v4 = ++var0_5;
                        v2 = var2_2.substring(v4, v4 + var1_4);
                        v3 = 0;
                        break block9;
                        break;
                    }
                    break;
                }
lbl28:
                // 1 sources

                while (true) {
                    var5[var3_1++] = TelemetryPropertiesLoaderImpl.a(v0, TelemetryPropertiesLoaderImpl.a(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    break block10;
                    break;
                }
            }
            switch (v3) {
                default: {
                    ** continue;
                }
                ** case 0:
lbl39:
                // 1 sources

                ** continue;
            }
        }
        TelemetryPropertiesLoaderImpl.j = var5;
        TelemetryPropertiesLoaderImpl.b = TelemetryPropertiesLoaderImpl.j[9];
        TelemetryPropertiesLoaderImpl.f = TelemetryPropertiesLoaderImpl.j[0];
        TelemetryPropertiesLoaderImpl.d = TelemetryPropertiesLoaderImpl.j[15];
        TelemetryPropertiesLoaderImpl.c = TelemetryPropertiesLoaderImpl.j[16];
        TelemetryPropertiesLoaderImpl.e = TelemetryPropertiesLoaderImpl.j[10];
        TelemetryPropertiesLoaderImpl.a = Logger.getLogger(TelemetryPropertiesLoaderImpl.class.getName());
        TelemetryPropertiesLoaderImpl.g = null;
    }

    private static Throwable a(Throwable throwable) {
        return throwable;
    }

    private static char[] a(String string) {
        char[] cArray = string.toCharArray();
        if (cArray.length < 2) {
            cArray = cArray;
            cArray[0] = (char)(cArray[0] ^ 0x26);
        }
        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 -> 82;
                    case 1 -> 126;
                    case 2 -> 66;
                    case 3 -> 23;
                    case 4 -> 61;
                    case 5 -> 84;
                    default -> 38;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

