/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.policy.variable.Syntax$SyntaxErrorHandler
 *  com.l7tech.util.ByteGen
 *  com.l7tech.util.ConfigFactory
 *  com.l7tech.util.HexUtils
 */
package com.l7tech.server.policy.variable;

import com.l7tech.policy.variable.Syntax;
import com.l7tech.server.policy.variable.ExpandVariables;
import com.l7tech.util.ByteGen;
import com.l7tech.util.ConfigFactory;
import com.l7tech.util.HexUtils;
import java.math.BigInteger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ByteGenSelector
implements ExpandVariables.Selector<ByteGen> {
    static final String a;
    static final int b = 0xA00000;
    private static final String c;
    private static final String d;
    private static final String e;
    private static final String f;
    private static final String g;
    private static final Pattern h;
    private static final String[] i;

    @Override
    public ExpandVariables.Selector.Selection select(String string, ByteGen byteGen, String string2, Syntax.SyntaxErrorHandler syntaxErrorHandler, boolean bl2) {
        String string3;
        Matcher matcher = h.matcher(string2);
        if (matcher.matches()) {
            byte[] byArray;
            String string4;
            block35: {
                int n2;
                block34: {
                    string3 = matcher.group(1);
                    string4 = matcher.group(2);
                    n2 = 32;
                    try {
                        if (string3 == null || string3.length() <= 0) break block34;
                    }
                    catch (NumberFormatException numberFormatException) {
                        throw ByteGenSelector.a(numberFormatException);
                    }
                    try {
                        n2 = Integer.parseInt(string3);
                        String[] stringArray = i;
                        int n3 = ConfigFactory.getIntProperty((String)stringArray[11], (int)0xA00000);
                        if (n2 < 1) {
                            String string5 = syntaxErrorHandler.handleBadVariable(string2 + stringArray[12]);
                            try {
                                if (bl2) {
                                    throw new IllegalArgumentException(string5);
                                }
                            }
                            catch (NumberFormatException numberFormatException) {
                                throw ByteGenSelector.a(numberFormatException);
                            }
                            n2 = 1;
                            break block34;
                        }
                        if (n2 <= n3) break block34;
                        stringArray = i;
                        String string6 = syntaxErrorHandler.handleBadVariable(string2 + stringArray[0] + n3 + ".");
                        try {
                            if (bl2) {
                                throw new IllegalArgumentException(string6);
                            }
                        }
                        catch (NumberFormatException numberFormatException) {
                            throw ByteGenSelector.a(numberFormatException);
                        }
                        n2 = n3;
                    }
                    catch (NumberFormatException numberFormatException) {
                        String[] stringArray = i;
                        String string7 = syntaxErrorHandler.handleBadVariable(string2 + stringArray[14]);
                        try {
                            if (bl2) {
                                throw new IllegalArgumentException(string7);
                            }
                        }
                        catch (NumberFormatException numberFormatException2) {
                            throw ByteGenSelector.a(numberFormatException2);
                        }
                    }
                }
                byArray = new byte[n2];
                try {
                    try {
                        byteGen.generateBytes(byArray, 0, n2);
                        if (!string4.isEmpty() && !i[8].equalsIgnoreCase(string4)) break block35;
                    }
                    catch (NumberFormatException numberFormatException) {
                        throw ByteGenSelector.a(numberFormatException);
                    }
                    return new ExpandVariables.Selector.Selection(HexUtils.hexDump((byte[])byArray));
                }
                catch (NumberFormatException numberFormatException) {
                    throw ByteGenSelector.a(numberFormatException);
                }
            }
            try {
                if (i[5].equalsIgnoreCase(string4)) {
                    return new ExpandVariables.Selector.Selection(HexUtils.encodeBase64((byte[])byArray, (boolean)true));
                }
            }
            catch (NumberFormatException numberFormatException) {
                throw ByteGenSelector.a(numberFormatException);
            }
            try {
                if (i[3].equalsIgnoreCase(string4)) {
                    return new ExpandVariables.Selector.Selection(byArray);
                }
            }
            catch (NumberFormatException numberFormatException) {
                throw ByteGenSelector.a(numberFormatException);
            }
            try {
                if (i[15].equalsIgnoreCase(string4)) {
                    return new ExpandVariables.Selector.Selection(new BigInteger(byArray));
                }
            }
            catch (NumberFormatException numberFormatException) {
                throw ByteGenSelector.a(numberFormatException);
            }
            try {
                if (i[2].equalsIgnoreCase(string4)) {
                    return new ExpandVariables.Selector.Selection(new BigInteger(1, byArray));
                }
            }
            catch (NumberFormatException numberFormatException) {
                throw ByteGenSelector.a(numberFormatException);
            }
        }
        string3 = syntaxErrorHandler.handleBadVariable(string2 + i[6]);
        try {
            if (bl2) {
                throw new IllegalArgumentException(string3);
            }
        }
        catch (NumberFormatException numberFormatException) {
            throw ByteGenSelector.a(numberFormatException);
        }
        return NOT_PRESENT;
    }

    @Override
    public Class<ByteGen> getContextObjectClass() {
        return ByteGen.class;
    }

    /*
     * Unable to fully structure code
     */
    static {
        block10: {
            block9: {
                var5 = new String[17];
                var3_1 = 0;
                var2_2 = "WF\u00044+h\\\u0003EK!nd@\u0005A\u001f)y$\u0005Wi\u00050jfL\u0013\u0000\t?\u007fo\u0005\u0014O\u001e(\u007f1\u0005\u001aU\u00182+h@WL\u000e5x*Q\u001fA\u0005f\b\u0002N\u0018/ld@\u0013\b\u0002N\u0018/ld@\u0013\u0006\u0015I\u0005'ys2\u0014O\u0006hg=Q\u0012C\u0003hxoW\u0001E\u0019h{eI\u001eC\u0012h}kW\u001eA\t*n$g\u000eT\u000e\u0001nd\u000b\u001aA\u0013\u0004r~@\u0004\u0006\u0015A\u0018#=>UWF\u00044+h\\\u0003EK!nd@\u0005A\u001f)y$\u0005\"N\u0019#heB\u0019I\u0011#o*V\u0002F\r/s1\u0005\u001aU\u00182+h@W\u000e\u0003#s&\u0005YB]r+eWW\u000e\t/ekW\u000e\u0000\u00044+$\u0019\u0019U\u0006x%b@\u000f\u0007\u001eN\u001f#loW\u0003\u001fE\u0013\u0006\u0015I\u0005'ys\u0006\u0015A\u0018#=>2\u0014O\u0006hg=Q\u0012C\u0003hxoW\u0001E\u0019h{eI\u001eC\u0012h}kW\u001eA\t*n$g\u000eT\u000e\u0001nd\u000b\u001aA\u0013\u0004r~@\u0004;WF\u00044+h\\\u0003EK!nd@\u0005A\u001f)y$\u0005Wi\u00050jfL\u0013\u0000\t?\u007fo\u0005\u0014O\u001e(\u007f1\u0005\u001aU\u00182+h@WP\u00045b~L\u0001EE\u0003\u001fE\u0013AWF\u00044+h\\\u0003EK!nd@\u0005A\u001f)y$\u0005Wi\u00050jfL\u0013\u0000\t?\u007fo\u0005\u0014O\u001e(\u007f1\u0005\u001aU\u00182+h@WAK0jfL\u0013\u0000\u00053fh@\u0005\u000e";
                var4_3 = "WF\u00044+h\\\u0003EK!nd@\u0005A\u001f)y$\u0005Wi\u00050jfL\u0013\u0000\t?\u007fo\u0005\u0014O\u001e(\u007f1\u0005\u001aU\u00182+h@WL\u000e5x*Q\u001fA\u0005f\b\u0002N\u0018/ld@\u0013\b\u0002N\u0018/ld@\u0013\u0006\u0015I\u0005'ys2\u0014O\u0006hg=Q\u0012C\u0003hxoW\u0001E\u0019h{eI\u001eC\u0012h}kW\u001eA\t*n$g\u000eT\u000e\u0001nd\u000b\u001aA\u0013\u0004r~@\u0004\u0006\u0015A\u0018#=>UWF\u00044+h\\\u0003EK!nd@\u0005A\u001f)y$\u0005\"N\u0019#heB\u0019I\u0011#o*V\u0002F\r/s1\u0005\u001aU\u00182+h@W\u000e\u0003#s&\u0005YB]r+eWW\u000e\t/ekW\u000e\u0000\u00044+$\u0019\u0019U\u0006x%b@\u000f\u0007\u001eN\u001f#loW\u0003\u001fE\u0013\u0006\u0015I\u0005'ys\u0006\u0015A\u0018#=>2\u0014O\u0006hg=Q\u0012C\u0003hxoW\u0001E\u0019h{eI\u001eC\u0012h}kW\u001eA\t*n$g\u000eT\u000e\u0001nd\u000b\u001aA\u0013\u0004r~@\u0004;WF\u00044+h\\\u0003EK!nd@\u0005A\u001f)y$\u0005Wi\u00050jfL\u0013\u0000\t?\u007fo\u0005\u0014O\u001e(\u007f1\u0005\u001aU\u00182+h@WP\u00045b~L\u0001EE\u0003\u001fE\u0013AWF\u00044+h\\\u0003EK!nd@\u0005A\u001f)y$\u0005Wi\u00050jfL\u0013\u0000\t?\u007fo\u0005\u0014O\u001e(\u007f1\u0005\u001aU\u00182+h@WAK0jfL\u0013\u0000\u00053fh@\u0005\u000e".length();
                var1_4 = 60;
                var0_5 = -1;
lbl7:
                // 2 sources

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

                while (true) {
                    var5[var3_1++] = ByteGenSelector.a(v0, ByteGenSelector.a(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    var2_2 = "\u0005U\u00048wtL&2\u0013Og8MZG\u0012Xb*M\u0010\u0010\u001fYt/9e\r\u0016\n\u001c=K\u000eA\u0002,\u0002L<cF\u0012T";
                    var4_3 = "\u0005U\u00048wtL&2\u0013Og8MZG\u0012Xb*M\u0010\u0010\u001fYt/9e\r\u0016\n\u001c=K\u000eA\u0002,\u0002L<cF\u0012T".length();
                    var1_4 = 7;
                    var0_5 = -1;
lbl22:
                    // 2 sources

                    while (true) {
                        v0 = 41;
                        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++] = ByteGenSelector.a(v0, ByteGenSelector.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;
            }
        }
        ByteGenSelector.i = var5;
        ByteGenSelector.f = ByteGenSelector.i[7];
        ByteGenSelector.g = ByteGenSelector.i[1];
        ByteGenSelector.e = ByteGenSelector.i[9];
        ByteGenSelector.d = ByteGenSelector.i[10];
        ByteGenSelector.a = ByteGenSelector.i[4];
        ByteGenSelector.c = ByteGenSelector.i[13];
        ByteGenSelector.h = Pattern.compile(ByteGenSelector.i[16]);
    }

    private static NumberFormatException a(NumberFormatException numberFormatException) {
        return numberFormatException;
    }

    private static char[] a(String string) {
        char[] cArray = string.toCharArray();
        if (cArray.length < 2) {
            cArray = cArray;
            cArray[0] = (char)(cArray[0] ^ 0x17);
        }
        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 -> 69;
                    case 1 -> 18;
                    case 2 -> 89;
                    case 3 -> 116;
                    case 4 -> 57;
                    case 5 -> 56;
                    default -> 23;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

