/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.common.mime.NoSuchPartException
 *  com.l7tech.common.mime.PartInfo
 *  com.l7tech.gateway.common.audit.Audit
 *  com.l7tech.message.Message
 *  com.l7tech.util.Charsets
 *  com.l7tech.util.CollectionUtils
 *  com.l7tech.util.Functions
 *  com.l7tech.util.Functions$UnaryThrows
 *  com.l7tech.util.Functions$UnaryVoid
 *  com.l7tech.util.IOUtils
 *  com.l7tech.util.SyspropUtil
 *  org.jetbrains.annotations.NotNull
 *  org.jetbrains.annotations.Nullable
 */
package com.l7tech.server.util;

import com.l7tech.common.mime.NoSuchPartException;
import com.l7tech.common.mime.PartInfo;
import com.l7tech.gateway.common.audit.Audit;
import com.l7tech.message.Message;
import com.l7tech.server.util.d;
import com.l7tech.server.util.e;
import com.l7tech.util.Charsets;
import com.l7tech.util.CollectionUtils;
import com.l7tech.util.Functions;
import com.l7tech.util.IOUtils;
import com.l7tech.util.SyspropUtil;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.security.cert.Certificate;
import java.security.cert.CertificateEncodingException;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/*
 * Exception performing whole class analysis ignored.
 */
public class ContextVariableUtils {
    private static final int a;
    private static final String[] b;

    public static List<String> getAllResolvedStrings(@NotNull String string, @NotNull Map<String, Object> map, @NotNull Audit audit, @NotNull Pattern pattern, @Nullable Functions.UnaryVoid<Object> unaryVoid) {
        try {
            if (string == null) {
                ContextVariableUtils.a(0);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw ContextVariableUtils.a(illegalArgumentException);
        }
        try {
            if (map == null) {
                ContextVariableUtils.a(1);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw ContextVariableUtils.a(illegalArgumentException);
        }
        try {
            if (audit == null) {
                ContextVariableUtils.a(2);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw ContextVariableUtils.a(illegalArgumentException);
        }
        try {
            if (pattern == null) {
                ContextVariableUtils.a(3);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw ContextVariableUtils.a(illegalArgumentException);
        }
        return Functions.flatmap((Iterable)CollectionUtils.list((Object[])pattern.split(string)), (Functions.UnaryThrows)new d(map, audit, pattern, unaryVoid));
    }

    public static List<String> getStringsFromList(@NotNull List<Object> list, @Nullable Pattern pattern, @Nullable Functions.UnaryVoid<Object> unaryVoid) {
        try {
            if (list == null) {
                ContextVariableUtils.a(4);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw ContextVariableUtils.a(illegalArgumentException);
        }
        return Functions.flatmap(list, (Functions.UnaryThrows)new e(pattern, unaryVoid));
    }

    /*
     * Loose catch block
     * Enabled force condition propagation
     * Lifted jumps to return sites
     */
    @NotNull
    public static byte[] convertContextVariableValueToByteArray(@Nullable Object object, int n2, @Nullable Charset charset) throws IOException, NoSuchPartException, NoBinaryRepresentationException {
        block36: {
            if (n2 < 0) {
                n2 = a;
            }
            try {
                if (null == object) {
                    throw new NoBinaryRepresentationException(b[2]);
                }
            }
            catch (Throwable throwable) {
                throw ContextVariableUtils.a(throwable);
            }
            if (!(object instanceof byte[])) break block36;
            try {
                byte[] byArray;
                block37: {
                    byArray = (byte[])object;
                    if (byArray != null) return byArray;
                    break block37;
                    catch (Throwable throwable) {
                        throw ContextVariableUtils.a(throwable);
                    }
                }
                ContextVariableUtils.a(5);
                return byArray;
            }
            catch (Throwable throwable) {
                throw ContextVariableUtils.a(throwable);
            }
        }
        if (object instanceof Message) {
            byte[] byArray;
            Message message = (Message)object;
            InputStream inputStream = message.getMimeKnob().getEntireMessageBodyAsInputStream(false);
            try {
                byArray = IOUtils.slurpStream((InputStream)inputStream, (int)n2);
            }
            catch (Throwable throwable) {
                if (inputStream == null) throw throwable;
                try {
                    inputStream.close();
                    throw throwable;
                }
                catch (Throwable throwable2) {
                    throwable.addSuppressed(throwable2);
                }
                throw throwable;
            }
            try {
                if (inputStream != null) {
                    inputStream.close();
                }
            }
            catch (Throwable throwable) {
                throw ContextVariableUtils.a(throwable);
            }
            try {
                byte[] byArray2 = byArray;
                if (byArray != null) return byArray2;
                ContextVariableUtils.a(6);
                return byArray2;
            }
            catch (Throwable throwable) {
                throw ContextVariableUtils.a(throwable);
            }
        }
        if (object instanceof PartInfo) {
            byte[] byArray;
            PartInfo partInfo = (PartInfo)object;
            InputStream inputStream = partInfo.getInputStream(false);
            try {
                byArray = IOUtils.slurpStream((InputStream)inputStream, (int)n2);
            }
            catch (Throwable throwable) {
                if (inputStream == null) throw throwable;
                try {
                    inputStream.close();
                    throw throwable;
                }
                catch (Throwable throwable3) {
                    throwable.addSuppressed(throwable3);
                }
                throw throwable;
            }
            try {
                if (inputStream != null) {
                    inputStream.close();
                }
            }
            catch (Throwable throwable) {
                throw ContextVariableUtils.a(throwable);
            }
            try {
                byte[] byArray3 = byArray;
                if (byArray != null) return byArray3;
                ContextVariableUtils.a(7);
                return byArray3;
            }
            catch (Throwable throwable) {
                throw ContextVariableUtils.a(throwable);
            }
        }
        if (object instanceof CharSequence) {
            CharSequence charSequence = (CharSequence)object;
            if (null == charset) {
                charset = Charsets.ISO8859;
            }
            try {
                byte[] byArray = charSequence.toString().getBytes(charset);
                if (byArray != null) return byArray;
                ContextVariableUtils.a(8);
                return byArray;
            }
            catch (Throwable throwable) {
                throw ContextVariableUtils.a(throwable);
            }
        }
        if (!(object instanceof Certificate)) throw new NoBinaryRepresentationException(b[11] + String.valueOf(object.getClass()));
        Certificate certificate = (Certificate)object;
        try {
            byte[] byArray = certificate.getEncoded();
            if (byArray != null) return byArray;
            ContextVariableUtils.a(9);
            return byArray;
        }
        catch (IOException iOException) {
            throw ContextVariableUtils.a(iOException);
        }
        {
            catch (CertificateEncodingException certificateEncodingException) {
                throw new IOException(certificateEncodingException);
            }
        }
    }

    /*
     * Unable to fully structure code
     */
    static {
        block10: {
            block9: {
                var5 = new String[15];
                var3_1 = 0;
                var2_2 = "A t2KG\rmNv#qZ\u000eeN>5+\u0017\u0012!\u0003n5q\u0012\u000fn\u001a;4`F\u0014s\u0000;(p^\r\nd\u0016k4`A\u0012h\u0001u6T\u0000z$iWAu\u0001; l\\\u0005!\fr(d@\u0018!\u001c~6wW\u0012d\u0000o'q[\u000eoN})w\u0012\u000ft\u0002wfsS\u0013h\u000fy*`\u000fr\u000bi0`@7`\u001cr'g^\u0004r\fr\u001ew/qb\u0000u\u001a~4k+b\u0001vii\u0005\u0015d\rsivW\u0013w\u000biipF\bmAX)kF\u0004y\u001aM'w[\u0000c\u0002~\u0013q[\rrKb\u0001vhi\u0005\u0015d\rshvW\u0013w\u000bihpF\bm@X)kF\u0004y\u001aM'w[\u0000c\u0002~\u0013q[\rr@x)kD\u0004s\u001aO)G[\u000f`\u001cbhvF\u0013d\u000fvhhS\u0019C\u0017o#v\nn\fq#fF-h\u001do\u0007`\u001b\u007f/q]\u0013\u0015f\u000bo\u0007i^3d\u001dt*sW\u0005R\u001ai/kU\u0012>@\u001c|3hW\u000fuN})w\u0012!O\u0001o\bp^\r!\u001ez4d_\u0004u\u000bif\"\u0017\u0012&Nt %\u0017\u0012/KhfhG\u0012uNu)q\u0012\u0003dNu3i^:T\u0000z$iWAu\u0001; l\\\u0005!\fr(d@\u0018!\u001c~6wW\u0012d\u0000o'q[\u000eoN})w\u0012\u0017`\u001cr'g^\u0004!\u0001}fqK\u0011dN+b\u0001vii\u0005\u0015d\rsivW\u0013w\u000biipF\bmAX)kF\u0004y\u001aM'w[\u0000c\u0002~\u0013q[\rr";
                var4_3 = "A t2KG\rmNv#qZ\u000eeN>5+\u0017\u0012!\u0003n5q\u0012\u000fn\u001a;4`F\u0014s\u0000;(p^\r\nd\u0016k4`A\u0012h\u0001u6T\u0000z$iWAu\u0001; l\\\u0005!\fr(d@\u0018!\u001c~6wW\u0012d\u0000o'q[\u000eoN})w\u0012\u000ft\u0002wfsS\u0013h\u000fy*`\u000fr\u000bi0`@7`\u001cr'g^\u0004r\fr\u001ew/qb\u0000u\u001a~4k+b\u0001vii\u0005\u0015d\rsivW\u0013w\u000biipF\bmAX)kF\u0004y\u001aM'w[\u0000c\u0002~\u0013q[\rrKb\u0001vhi\u0005\u0015d\rshvW\u0013w\u000bihpF\bm@X)kF\u0004y\u001aM'w[\u0000c\u0002~\u0013q[\rr@x)kD\u0004s\u001aO)G[\u000f`\u001cbhvF\u0013d\u000fvhhS\u0019C\u0017o#v\nn\fq#fF-h\u001do\u0007`\u001b\u007f/q]\u0013\u0015f\u000bo\u0007i^3d\u001dt*sW\u0005R\u001ai/kU\u0012>@\u001c|3hW\u000fuN})w\u0012!O\u0001o\bp^\r!\u001ez4d_\u0004u\u000bif\"\u0017\u0012&Nt %\u0017\u0012/KhfhG\u0012uNu)q\u0012\u0003dNu3i^:T\u0000z$iWAu\u0001; l\\\u0005!\fr(d@\u0018!\u001c~6wW\u0012d\u0000o'q[\u000eoN})w\u0012\u0017`\u001cr'g^\u0004!\u0001}fqK\u0011dN+b\u0001vii\u0005\u0015d\rsivW\u0013w\u000biipF\bmAX)kF\u0004y\u001aM'w[\u0000c\u0002~\u0013q[\rr".length();
                var1_4 = 42;
                var0_5 = -1;
lbl7:
                // 2 sources

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

                while (true) {
                    var5[var3_1++] = ContextVariableUtils.a(v0, ContextVariableUtils.a(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    var2_2 = "\u001cq\u0015o\u000b:r\u0015s\u0012z\r'v7}\u0012H&\u0018{\u000fJ\u001a:o8{\u000fH\u001a0o-u\u0013U\u001e*w\u001eB\u0000P\n-O\u0014V\u0018H\u001a\ti\tu\u0018";
                    var4_3 = "\u001cq\u0015o\u000b:r\u0015s\u0012z\r'v7}\u0012H&\u0018{\u000fJ\u001a:o8{\u000fH\u001a0o-u\u0013U\u001e*w\u001eB\u0000P\n-O\u0014V\u0018H\u001a\ti\tu\u0018".length();
                    var1_4 = 18;
                    var0_5 = -1;
lbl22:
                    // 2 sources

                    while (true) {
                        v0 = 47;
                        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++] = ContextVariableUtils.a(v0, ContextVariableUtils.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;
            }
        }
        ContextVariableUtils.b = var5;
        ContextVariableUtils.a = SyspropUtil.getInteger((String)ContextVariableUtils.b[6], (int)0x200000);
    }

    /*
     * 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 6[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 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] ^ 0x34);
        }
        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 -> 84;
                    case 1 -> 59;
                    case 2 -> 78;
                    case 3 -> 19;
                    case 4 -> 80;
                    case 5 -> 103;
                    default -> 52;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }

    public static class NoBinaryRepresentationException
    extends Exception {
        static final long serialVersionUID = 2518387636796541683L;

        public NoBinaryRepresentationException() {
        }

        public NoBinaryRepresentationException(String string) {
            super(string);
        }

        public NoBinaryRepresentationException(String string, Throwable throwable) {
            super(string, throwable);
        }

        public NoBinaryRepresentationException(Throwable throwable) {
            super(throwable);
        }
    }
}

