/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  org.jetbrains.annotations.NotNull
 *  org.jetbrains.annotations.Nullable
 */
package com.l7tech.server.policy.module;

import com.l7tech.server.policy.module.CustomAssertionModule;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Enumeration;
import java.util.LinkedHashSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/*
 * Exception performing whole class analysis ignored.
 */
public class AllCustomAssertionClassLoader
extends ClassLoader {
    private final Collection<CustomAssertionModule> a;
    private final ClassLoader b;
    private static final String[] c;

    public AllCustomAssertionClassLoader(@NotNull ClassLoader classLoader, @NotNull Collection<CustomAssertionModule> collection, @Nullable ClassLoader classLoader2) {
        if (classLoader == null) {
            AllCustomAssertionClassLoader.a(0);
        }
        if (collection == null) {
            AllCustomAssertionClassLoader.a(1);
        }
        super(classLoader);
        this.a = collection;
        this.b = classLoader2;
    }

    @Override
    protected Class<?> findClass(String string) throws ClassNotFoundException {
        Class<?> clazz;
        block8: {
            clazz = null;
            for (CustomAssertionModule customAssertionModule : this.a) {
                clazz = this.a((ClassLoader)customAssertionModule.getModuleClassLoader(), string);
                try {
                    if (clazz == null) continue;
                    break;
                }
                catch (ClassNotFoundException classNotFoundException) {
                    throw AllCustomAssertionClassLoader.a(classNotFoundException);
                }
            }
            try {
                if (clazz != null || this.b == null) break block8;
            }
            catch (ClassNotFoundException classNotFoundException) {
                throw AllCustomAssertionClassLoader.a(classNotFoundException);
            }
            clazz = this.a(this.b, string);
        }
        try {
            if (clazz == null) {
                throw new ClassNotFoundException(string);
            }
        }
        catch (ClassNotFoundException classNotFoundException) {
            throw AllCustomAssertionClassLoader.a(classNotFoundException);
        }
        return clazz;
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     * Loose catch block
     */
    private Class<?> a(@NotNull ClassLoader classLoader, String string) {
        try {
            if (classLoader == null) {
                AllCustomAssertionClassLoader.a(2);
            }
        }
        catch (ClassNotFoundException classNotFoundException) {
            throw AllCustomAssertionClassLoader.a(classNotFoundException);
        }
        ClassLoader classLoader2 = Thread.currentThread().getContextClassLoader();
        try {
            if (classLoader2 != null) {
                Thread.currentThread().setContextClassLoader(null);
            }
        }
        catch (ClassNotFoundException classNotFoundException) {
            throw AllCustomAssertionClassLoader.a(classNotFoundException);
        }
        Class<?> clazz = classLoader.loadClass(string);
        try {
            if (classLoader2 != null) {
                Thread.currentThread().setContextClassLoader(classLoader2);
            }
        }
        catch (ClassNotFoundException classNotFoundException) {
            throw AllCustomAssertionClassLoader.a(classNotFoundException);
        }
        return clazz;
        catch (ClassNotFoundException classNotFoundException) {
            try {
                if (classLoader2 != null) {
                    Thread.currentThread().setContextClassLoader(classLoader2);
                }
            }
            catch (ClassNotFoundException classNotFoundException2) {
                throw AllCustomAssertionClassLoader.a(classNotFoundException2);
            }
            catch (Throwable throwable) {
                try {
                    if (classLoader2 != null) {
                        Thread.currentThread().setContextClassLoader(classLoader2);
                    }
                }
                catch (ClassNotFoundException classNotFoundException3) {
                    throw AllCustomAssertionClassLoader.a(classNotFoundException3);
                }
                throw throwable;
            }
        }
        return null;
    }

    @Override
    protected URL findResource(String string) {
        URL uRL;
        block5: {
            uRL = null;
            for (CustomAssertionModule customAssertionModule : this.a) {
                Object t2 = customAssertionModule.getModuleClassLoader();
                uRL = ((ClassLoader)t2).getResource(string);
                try {
                    if (uRL == null) continue;
                    break;
                }
                catch (IllegalArgumentException illegalArgumentException) {
                    throw AllCustomAssertionClassLoader.a(illegalArgumentException);
                }
            }
            try {
                if (uRL != null || this.b == null) break block5;
            }
            catch (IllegalArgumentException illegalArgumentException) {
                throw AllCustomAssertionClassLoader.a(illegalArgumentException);
            }
            uRL = this.b.getResource(string);
        }
        return uRL;
    }

    @Override
    protected Enumeration<URL> findResources(String string) throws IOException {
        LinkedHashSet<URL> linkedHashSet = new LinkedHashSet<URL>();
        ArrayList<Object> arrayList = new ArrayList<Object>();
        for (CustomAssertionModule object : this.a) {
            arrayList.add(object.getModuleClassLoader());
        }
        try {
            if (this.b != null) {
                arrayList.add(this.b);
            }
        }
        catch (IOException iOException) {
            throw AllCustomAssertionClassLoader.a(iOException);
        }
        for (ClassLoader classLoader : arrayList) {
            linkedHashSet.addAll(Collections.list(classLoader.getResources(string)));
        }
        if (!arrayList.isEmpty()) {
            ClassLoader classLoader = ((ClassLoader)arrayList.get(0)).getParent();
            try {
                if (classLoader != null) {
                    linkedHashSet.removeAll(Collections.list(classLoader.getResources(string)));
                }
            }
            catch (IOException iOException) {
                throw AllCustomAssertionClassLoader.a(iOException);
            }
        }
        return Collections.enumeration(linkedHashSet);
    }

    /*
     * Exception decompiling
     */
    private static /* synthetic */ void a(int var0) {
        /*
         * 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 [0[TRYBLOCK]], but top level block is 2[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:1050)
         *     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 static Exception a(Exception exception) {
        return exception;
    }

    /*
     * Unable to fully structure code
     */
    static {
        block10: {
            block9: {
                var5 = new String[7];
                var3_1 = 0;
                var2_2 = "3\nB\u0019aD\u00165\u0006G\u0019~\u0016\u0010&\u0000]\u0019}\u001c\u000e9\u0006V\u0019`\u001c\u0006%\tJ\u0019L\u001f\u000e\u0013\u0010\\Bb\u001e##\u0016JDy\u001a\r>&CW~\u0000.?\u0004KS\u007f\u0006 \u0004]Sc\u0007\u000b4\ni_c\u0017!<\u0004\\E>\u0011\u0017HC`\u0016\f$EIY\u007fS\"\u001e\n[xx\u001f\u000ep\u0015NDl\u001e\u0007$\u0000]\u0016*V\u0011wE@P-V\u0011~@\\\u0016`\u0006\u0011$EAYyS\u00005EACa\u001f\u0007=\nKCa\u0016\u0011";
                var4_3 = "3\nB\u0019aD\u00165\u0006G\u0019~\u0016\u0010&\u0000]\u0019}\u001c\u000e9\u0006V\u0019`\u001c\u0006%\tJ\u0019L\u001f\u000e\u0013\u0010\\Bb\u001e##\u0016JDy\u001a\r>&CW~\u0000.?\u0004KS\u007f\u0006 \u0004]Sc\u0007\u000b4\ni_c\u0017!<\u0004\\E>\u0011\u0017HC`\u0016\f$EIY\u007fS\"\u001e\n[xx\u001f\u000ep\u0015NDl\u001e\u0007$\u0000]\u0016*V\u0011wE@P-V\u0011~@\\\u0016`\u0006\u0011$EAYyS\u00005EACa\u001f\u0007=\nKCa\u0016\u0011".length();
                var1_4 = 61;
                var0_5 = -1;
lbl7:
                // 2 sources

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

                while (true) {
                    var5[var3_1++] = AllCustomAssertionClassLoader.a(v0, AllCustomAssertionClassLoader.a(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    var2_2 = "\bh%;\u001d)\u0013Pd'7\u000evrQB'3\u001adJ[`/7\u001b";
                    var4_3 = "\bh%;\u001d)\u0013Pd'7\u000evrQB'3\u001adJ[`/7\u001b".length();
                    var1_4 = 6;
                    var0_5 = -1;
lbl22:
                    // 2 sources

                    while (true) {
                        v0 = 37;
                        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++] = AllCustomAssertionClassLoader.a(v0, AllCustomAssertionClassLoader.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;
            }
        }
        AllCustomAssertionClassLoader.c = var5;
    }

    private static char[] a(String string) {
        char[] cArray = string.toCharArray();
        if (cArray.length < 2) {
            cArray = cArray;
            cArray[0] = (char)(cArray[0] ^ 0x23);
        }
        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 -> 17;
                    case 1 -> 36;
                    case 2 -> 110;
                    case 3 -> 119;
                    case 4 -> 76;
                    case 5 -> 50;
                    default -> 35;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

