/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.gateway.common.audit.Audit
 *  com.l7tech.policy.SingleUrlResourceInfo
 *  com.l7tech.policy.assertion.Assertion
 *  com.l7tech.policy.variable.Syntax
 *  com.l7tech.util.ExceptionUtils
 */
package com.l7tech.server.util.res;

import com.l7tech.gateway.common.audit.Audit;
import com.l7tech.policy.SingleUrlResourceInfo;
import com.l7tech.policy.assertion.Assertion;
import com.l7tech.policy.variable.Syntax;
import com.l7tech.server.policy.ServerPolicyException;
import com.l7tech.server.policy.variable.ExpandVariables;
import com.l7tech.server.url.UrlResolver;
import com.l7tech.server.util.res.ResourceGetter;
import com.l7tech.server.util.res.c;
import com.l7tech.util.ExceptionUtils;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.security.GeneralSecurityException;
import java.text.ParseException;
import java.util.Map;

class e<R, M>
extends c<R, M> {
    private final String b;
    private final boolean c;
    private static final String[] d;

    /*
     * Enabled aggressive block sorting
     * Enabled unnecessary exception pruning
     * Enabled aggressive exception aggregation
     */
    e(Assertion assertion, SingleUrlResourceInfo singleUrlResourceInfo, UrlResolver<R> urlResolver, Audit audit) throws ServerPolicyException {
        super(urlResolver, audit);
        boolean bl2;
        String string = singleUrlResourceInfo.getUrl();
        try {
            if (string == null) {
                throw new ServerPolicyException(assertion, d[0]);
            }
        }
        catch (MalformedURLException malformedURLException) {
            throw e.a(malformedURLException);
        }
        try {
            this.b = string;
            e e10 = this;
            bl2 = Syntax.getReferencedNames((String)string).length > 0;
        }
        catch (MalformedURLException malformedURLException) {
            throw e.a(malformedURLException);
        }
        try {
            e10.c = bl2;
            if (this.c) return;
            try {
                new URL(string);
                return;
            }
            catch (MalformedURLException malformedURLException) {
                throw new ServerPolicyException(assertion, d[1] + string);
            }
        }
        catch (ServerPolicyException serverPolicyException) {
            throw e.a((Exception)((Object)serverPolicyException));
        }
    }

    @Override
    public void close() {
    }

    /*
     * Unable to fully structure code
     */
    @Override
    public R getResource(M var1_1, Map<String, Object> var2_2) throws IOException, ResourceGetter.ResourceParseException, GeneralSecurityException, ResourceGetter.ResourceIOException, ResourceGetter.MalformedResourceUrlException {
        block8: {
            block7: {
                if (var2_2 == null) ** GOTO lbl8
                try {
                    block9: {
                        if (this.c) break block7;
                        break block9;
                        catch (ParseException v0) {
                            throw e.a(v0);
                        }
                    }
                    v1 = this.b;
                    break block8;
                }
                catch (ParseException v2) {
                    throw e.a(v2);
                }
            }
            v1 = ExpandVariables.process(this.b, var2_2, this.audit);
        }
        var3_3 = v1;
        try {
            return this.fetchObject(var3_3);
        }
        catch (ParseException var4_4) {
            throw new ResourceGetter.ResourceParseException(ExceptionUtils.getMessage((Throwable)var4_4), var4_4, var3_3);
        }
        catch (IOException var4_5) {
            throw new ResourceGetter.ResourceIOException(ExceptionUtils.getMessage((Throwable)var4_5), var4_5, var3_3);
        }
    }

    private static Exception a(Exception exception) {
        return exception;
    }

    /*
     * Enabled aggressive block sorting
     */
    static {
        String[] stringArray = new String[2];
        int n2 = 0;
        String string = "\u001b|\u007f,dy0vgi,bb%5p,*\u007f{\u0016\u001f{z>a~3vgi,bb%5p,\n_[mv";
        int n3 = "\u001b|\u007f,dy0vgi,bb%5p,*\u007f{\u0016\u001f{z>a~3vgi,bb%5p,\n_[mv".length();
        int n4 = 20;
        int n5 = -1;
        while (true) {
            int n6 = ++n5;
            stringArray[n2++] = e.c(94, e.a(string.substring(n6, n6 + n4)));
            if ((n5 += n4) >= n3) {
                d = stringArray;
                return;
            }
            n4 = string.charAt(n5);
        }
    }

    private static char[] a(String string) {
        char[] cArray = string.toCharArray();
        if (cArray.length < 2) {
            cArray = cArray;
            cArray[0] = (char)(cArray[0] ^ 9);
        }
        return cArray;
    }

    /*
     * Handled impossible loop by duplicating code
     * Enabled aggressive block sorting
     */
    private static String c(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 -> 8;
                    case 1 -> 75;
                    case 2 -> 82;
                    case 3 -> 1;
                    case 4 -> 83;
                    case 5 -> 73;
                    default -> 9;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

