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

import com.l7tech.policy.assertion.Assertion;
import com.l7tech.server.event.metrics.AssertionFinished;
import com.l7tech.server.event.metrics.ServiceFinished;
import com.l7tech.server.message.PolicyEnforcementContext;
import com.l7tech.server.message.metrics.GatewayMetricsPublisher;
import com.l7tech.server.message.metrics.GatewayMetricsSupport;
import com.l7tech.server.message.metrics.LatencyMetrics;
import com.l7tech.server.message.metrics.b;
import com.l7tech.server.message.metrics.c;
import com.l7tech.server.message.metrics.d;
import com.l7tech.server.policy.assertion.ServerAssertion;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

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

    public static void setPublisher(@NotNull PolicyEnforcementContext policyEnforcementContext, @Nullable GatewayMetricsPublisher gatewayMetricsPublisher) {
        block9: {
            GatewayMetricsPublisher gatewayMetricsPublisher2;
            GatewayMetricsSupport gatewayMetricsSupport;
            block11: {
                block10: {
                    try {
                        if (policyEnforcementContext == null) {
                            GatewayMetricsUtils.a(0);
                        }
                    }
                    catch (IllegalArgumentException illegalArgumentException) {
                        throw GatewayMetricsUtils.a(illegalArgumentException);
                    }
                    try {
                        try {
                            try {
                                if (!(policyEnforcementContext instanceof GatewayMetricsSupport)) break block9;
                                gatewayMetricsSupport = (GatewayMetricsSupport)((Object)policyEnforcementContext);
                                if (gatewayMetricsPublisher == null) break block10;
                            }
                            catch (IllegalArgumentException illegalArgumentException) {
                                throw GatewayMetricsUtils.a(illegalArgumentException);
                            }
                            if (!gatewayMetricsPublisher.hasSubscribers()) break block10;
                        }
                        catch (IllegalArgumentException illegalArgumentException) {
                            throw GatewayMetricsUtils.a(illegalArgumentException);
                        }
                        gatewayMetricsPublisher2 = gatewayMetricsPublisher;
                        break block11;
                    }
                    catch (IllegalArgumentException illegalArgumentException) {
                        throw GatewayMetricsUtils.a(illegalArgumentException);
                    }
                }
                gatewayMetricsPublisher2 = null;
            }
            gatewayMetricsSupport.setGatewayMetricsEventsPublisher(gatewayMetricsPublisher2);
        }
    }

    public static void setPublisher(@NotNull PolicyEnforcementContext policyEnforcementContext, @NotNull PolicyEnforcementContext policyEnforcementContext2) {
        block10: {
            try {
                if (policyEnforcementContext == null) {
                    GatewayMetricsUtils.a(1);
                }
            }
            catch (IllegalArgumentException illegalArgumentException) {
                throw GatewayMetricsUtils.a(illegalArgumentException);
            }
            try {
                if (policyEnforcementContext2 == null) {
                    GatewayMetricsUtils.a(2);
                }
            }
            catch (IllegalArgumentException illegalArgumentException) {
                throw GatewayMetricsUtils.a(illegalArgumentException);
            }
            try {
                try {
                    if (!(policyEnforcementContext instanceof GatewayMetricsSupport) || !(policyEnforcementContext2 instanceof GatewayMetricsSupport)) break block10;
                }
                catch (IllegalArgumentException illegalArgumentException) {
                    throw GatewayMetricsUtils.a(illegalArgumentException);
                }
                ((GatewayMetricsSupport)((Object)policyEnforcementContext2)).setGatewayMetricsEventsPublisher(((GatewayMetricsSupport)((Object)policyEnforcementContext)).getGatewayMetricsEventsPublisher());
            }
            catch (IllegalArgumentException illegalArgumentException) {
                throw GatewayMetricsUtils.a(illegalArgumentException);
            }
        }
    }

    public static void publishAssertionFinish(@NotNull PolicyEnforcementContext policyEnforcementContext, @NotNull ServerAssertion serverAssertion, @NotNull LatencyMetrics latencyMetrics) {
        try {
            if (policyEnforcementContext == null) {
                GatewayMetricsUtils.a(3);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw GatewayMetricsUtils.a(illegalArgumentException);
        }
        try {
            if (serverAssertion == null) {
                GatewayMetricsUtils.a(4);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw GatewayMetricsUtils.a(illegalArgumentException);
        }
        try {
            if (latencyMetrics == null) {
                GatewayMetricsUtils.a(5);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw GatewayMetricsUtils.a(illegalArgumentException);
        }
        if (policyEnforcementContext instanceof GatewayMetricsSupport) {
            GatewayMetricsPublisher gatewayMetricsPublisher = ((GatewayMetricsSupport)((Object)policyEnforcementContext)).getGatewayMetricsEventsPublisher();
            try {
                if (gatewayMetricsPublisher != null) {
                    gatewayMetricsPublisher.a(GatewayMetricsUtils.a(policyEnforcementContext, serverAssertion.getAssertion(), latencyMetrics));
                }
            }
            catch (IllegalArgumentException illegalArgumentException) {
                throw GatewayMetricsUtils.a(illegalArgumentException);
            }
        }
    }

    public static void publishServiceFinish(@NotNull PolicyEnforcementContext policyEnforcementContext, @NotNull LatencyMetrics latencyMetrics) {
        try {
            if (policyEnforcementContext == null) {
                GatewayMetricsUtils.a(6);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw GatewayMetricsUtils.a(illegalArgumentException);
        }
        try {
            if (latencyMetrics == null) {
                GatewayMetricsUtils.a(7);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw GatewayMetricsUtils.a(illegalArgumentException);
        }
        if (policyEnforcementContext instanceof GatewayMetricsSupport) {
            GatewayMetricsPublisher gatewayMetricsPublisher = ((GatewayMetricsSupport)((Object)policyEnforcementContext)).getGatewayMetricsEventsPublisher();
            try {
                if (gatewayMetricsPublisher != null) {
                    gatewayMetricsPublisher.a(GatewayMetricsUtils.a(policyEnforcementContext, latencyMetrics));
                }
            }
            catch (IllegalArgumentException illegalArgumentException) {
                throw GatewayMetricsUtils.a(illegalArgumentException);
            }
        }
    }

    @NotNull
    static AssertionFinished a(@NotNull PolicyEnforcementContext policyEnforcementContext, @NotNull Assertion assertion, @NotNull LatencyMetrics latencyMetrics) {
        try {
            if (policyEnforcementContext == null) {
                GatewayMetricsUtils.a(8);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw GatewayMetricsUtils.a(illegalArgumentException);
        }
        try {
            if (assertion == null) {
                GatewayMetricsUtils.a(9);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw GatewayMetricsUtils.a(illegalArgumentException);
        }
        try {
            if (latencyMetrics == null) {
                GatewayMetricsUtils.a(10);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw GatewayMetricsUtils.a(illegalArgumentException);
        }
        return new b(policyEnforcementContext, assertion, latencyMetrics);
    }

    @NotNull
    static ServiceFinished a(@NotNull PolicyEnforcementContext policyEnforcementContext, @NotNull LatencyMetrics latencyMetrics) {
        try {
            if (policyEnforcementContext == null) {
                GatewayMetricsUtils.a(11);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw GatewayMetricsUtils.a(illegalArgumentException);
        }
        try {
            if (latencyMetrics == null) {
                GatewayMetricsUtils.a(12);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw GatewayMetricsUtils.a(illegalArgumentException);
        }
        return new c(policyEnforcementContext, latencyMetrics);
    }

    @NotNull
    static Class<? extends PolicyEnforcementContext> a() {
        return d.class;
    }

    /*
     * 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 IllegalArgumentException a(IllegalArgumentException illegalArgumentException) {
        return illegalArgumentException;
    }

    /*
     * Unable to fully structure code
     */
    static {
        block10: {
            block9: {
                var5 = new String[13];
                var3_1 = 0;
                var2_2 = "?\u0014-cxz>\u000e\u00078s{k6;U9id.\u0018\u0001\u001a+Hcb4o\u0005>twc=;\u0010-&1++hU0`6++aP,&{{+;U1ib.:*U1szb\u000e<\u0010-p\u007fm=\u0002\u0010+t\u007fm+\u0014?\u0000=j\u007f}0\u001c\u0010-p\u007fm=\t\u001c1oef\u0010.\u0006,cdz1 \u001b\u0012cb|1,\u00065,\u001a2)z9,*\u00167)ek*9\u0010-){k+<\u00148c9c=;\u00076ee!\u001f.\u0001:qww\u0015*\u0001-ou}\r;\u001c3u\u001a,\u0007:gbk\u000b*\u0007)ouk\u001e&\u001b6u~k<\n\u0003:hb\t.\u0006,cdz1 \u001b\u0016?\u0000=j\u007f}0\u000e\u0006,cdz1 \u001b\u0019oxg+'\u0007,\u001a1rsv,\u001c,\u0007:gbk\u0019<\u0006:tbg7!36h\u007f}0*\u0011\u001aps`,";
                var4_3 = "?\u0014-cxz>\u000e\u00078s{k6;U9id.\u0018\u0001\u001a+Hcb4o\u0005>twc=;\u0010-&1++hU0`6++aP,&{{+;U1ib.:*U1szb\u000e<\u0010-p\u007fm=\u0002\u0010+t\u007fm+\u0014?\u0000=j\u007f}0\u001c\u0010-p\u007fm=\t\u001c1oef\u0010.\u0006,cdz1 \u001b\u0012cb|1,\u00065,\u001a2)z9,*\u00167)ek*9\u0010-){k+<\u00148c9c=;\u00076ee!\u001f.\u0001:qww\u0015*\u0001-ou}\r;\u001c3u\u001a,\u0007:gbk\u000b*\u0007)ouk\u001e&\u001b6u~k<\n\u0003:hb\t.\u0006,cdz1 \u001b\u0016?\u0000=j\u007f}0\u000e\u0006,cdz1 \u001b\u0019oxg+'\u0007,\u001a1rsv,\u001c,\u0007:gbk\u0019<\u0006:tbg7!36h\u007f}0*\u0011\u001aps`,".length();
                var1_4 = 6;
                var0_5 = -1;
lbl7:
                // 2 sources

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

                while (true) {
                    var5[var3_1++] = GatewayMetricsUtils.a(v0, GatewayMetricsUtils.a(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    var2_2 = "9\u0015.Sfi1#\u00032fa\u0005)\u00183ow";
                    var4_3 = "9\u0015.Sfi1#\u00032fa\u0005)\u00183ow".length();
                    var1_4 = 12;
                    var0_5 = -1;
lbl22:
                    // 2 sources

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

    private static char[] a(String string) {
        char[] cArray = string.toCharArray();
        if (cArray.length < 2) {
            cArray = cArray;
            cArray[0] = (char)(cArray[0] ^ 0x4D);
        }
        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 -> 90;
                    case 1 -> 96;
                    case 2 -> 74;
                    case 3 -> 19;
                    case 4 -> 3;
                    case 5 -> 27;
                    default -> 77;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

