/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.gateway.common.stepdebug.DebugAdmin
 *  com.l7tech.gateway.common.stepdebug.DebugResult
 *  com.l7tech.objectmodel.Goid
 *  com.l7tech.util.Option
 *  jakarta.inject.Inject
 *  org.jetbrains.annotations.NotNull
 *  org.jetbrains.annotations.Nullable
 */
package com.l7tech.server.stepdebug;

import com.l7tech.gateway.common.stepdebug.DebugAdmin;
import com.l7tech.gateway.common.stepdebug.DebugResult;
import com.l7tech.objectmodel.Goid;
import com.l7tech.server.stepdebug.DebugContext;
import com.l7tech.server.stepdebug.DebugManager;
import com.l7tech.server.stepdebug.DebugPecData;
import com.l7tech.util.Option;
import jakarta.inject.Inject;
import java.util.Collection;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/*
 * Exception performing whole class analysis ignored.
 */
public class DebugAdminImpl
implements DebugAdmin {
    @Inject
    private DebugManager debugManager;
    private static final String[] a;

    @NotNull
    public DebugResult initializeDebug(@NotNull Goid goid) {
        try {
            if (goid == null) {
                DebugAdminImpl.a(0);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw DebugAdminImpl.a(illegalArgumentException);
        }
        DebugContext debugContext = this.debugManager.createDebugContext(goid);
        return this.a(debugContext);
    }

    @NotNull
    public Option<String> startDebug(@NotNull String string) {
        Option<String> option;
        try {
            if (string == null) {
                DebugAdminImpl.a(1);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw DebugAdminImpl.a(illegalArgumentException);
        }
        try {
            option = this.debugManager.startDebug(string);
            if (option == null) {
                DebugAdminImpl.a(2);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw DebugAdminImpl.a(illegalArgumentException);
        }
        return option;
    }

    public void stopDebug(@NotNull String string) {
        try {
            if (string == null) {
                DebugAdminImpl.a(3);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw DebugAdminImpl.a(illegalArgumentException);
        }
        this.debugManager.stopDebug(string);
    }

    public void stepOver(@NotNull String string, @NotNull Collection<Integer> collection) {
        try {
            if (string == null) {
                DebugAdminImpl.a(4);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw DebugAdminImpl.a(illegalArgumentException);
        }
        try {
            if (collection == null) {
                DebugAdminImpl.a(5);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw DebugAdminImpl.a(illegalArgumentException);
        }
        this.debugManager.stepOver(string, collection);
    }

    public void stepInto(@NotNull String string) {
        try {
            if (string == null) {
                DebugAdminImpl.a(6);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw DebugAdminImpl.a(illegalArgumentException);
        }
        this.debugManager.stepInto(string);
    }

    public void stepOut(@NotNull String string, @NotNull Collection<Integer> collection) {
        try {
            if (string == null) {
                DebugAdminImpl.a(7);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw DebugAdminImpl.a(illegalArgumentException);
        }
        try {
            if (collection == null) {
                DebugAdminImpl.a(8);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw DebugAdminImpl.a(illegalArgumentException);
        }
        this.debugManager.stepOut(string, collection);
    }

    public void resume(@NotNull String string) {
        try {
            if (string == null) {
                DebugAdminImpl.a(9);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw DebugAdminImpl.a(illegalArgumentException);
        }
        this.debugManager.resume(string);
    }

    public void terminateDebug(@NotNull String string) {
        try {
            if (string == null) {
                DebugAdminImpl.a(10);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw DebugAdminImpl.a(illegalArgumentException);
        }
        this.debugManager.terminateDebug(string);
    }

    public void toggleBreakpoint(@NotNull String string, @NotNull Collection<Integer> collection) {
        try {
            if (string == null) {
                DebugAdminImpl.a(11);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw DebugAdminImpl.a(illegalArgumentException);
        }
        try {
            if (collection == null) {
                DebugAdminImpl.a(12);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw DebugAdminImpl.a(illegalArgumentException);
        }
        this.debugManager.toggleBreakpoint(string, collection);
    }

    public void removeAllBreakpoints(@NotNull String string) {
        try {
            if (string == null) {
                DebugAdminImpl.a(13);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw DebugAdminImpl.a(illegalArgumentException);
        }
        this.debugManager.removeAllBreakpoints(string);
    }

    @Nullable
    public DebugResult waitForUpdates(@NotNull String string, long l2) {
        DebugResult debugResult;
        block7: {
            block5: {
                block6: {
                    try {
                        if (string == null) {
                            DebugAdminImpl.a(14);
                        }
                    }
                    catch (IllegalArgumentException illegalArgumentException) {
                        throw DebugAdminImpl.a(illegalArgumentException);
                    }
                    DebugContext debugContext = this.debugManager.getDebugContext(string);
                    try {
                        if (debugContext == null) break block5;
                        if (!debugContext.waitForUpdates(l2)) break block6;
                    }
                    catch (IllegalArgumentException illegalArgumentException) {
                        throw DebugAdminImpl.a(illegalArgumentException);
                    }
                    debugResult = this.a(debugContext);
                    break block7;
                }
                debugResult = null;
                break block7;
            }
            debugResult = new DebugResult(string);
            debugResult.setIsTerminated(true);
        }
        return debugResult;
    }

    public void addUserContextVariable(@NotNull String string, @NotNull String string2) {
        try {
            if (string == null) {
                DebugAdminImpl.a(15);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw DebugAdminImpl.a(illegalArgumentException);
        }
        try {
            if (string2 == null) {
                DebugAdminImpl.a(16);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw DebugAdminImpl.a(illegalArgumentException);
        }
        this.debugManager.addUserContextVariable(string, string2);
    }

    public void removeUserContextVariable(@NotNull String string, @NotNull String string2) {
        try {
            if (string == null) {
                DebugAdminImpl.a(17);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw DebugAdminImpl.a(illegalArgumentException);
        }
        try {
            if (string2 == null) {
                DebugAdminImpl.a(18);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw DebugAdminImpl.a(illegalArgumentException);
        }
        this.debugManager.removeUserContextVariable(string, string2);
    }

    void a(@NotNull DebugManager debugManager) {
        try {
            if (debugManager == null) {
                DebugAdminImpl.a(19);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw DebugAdminImpl.a(illegalArgumentException);
        }
        this.debugManager = debugManager;
    }

    @NotNull
    private DebugResult a(@NotNull DebugContext debugContext) {
        DebugResult debugResult;
        try {
            if (debugContext == null) {
                DebugAdminImpl.a(20);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw DebugAdminImpl.a(illegalArgumentException);
        }
        DebugResult debugResult2 = new DebugResult(debugContext.getTaskId());
        debugResult2.setDebugState(debugContext.getDebugState());
        debugResult2.setIsTerminated(debugContext.isTerminated());
        debugResult2.setBreakpoints(debugContext.getBreakpoints());
        debugResult2.setCurrentLine(debugContext.getCurrentLine());
        DebugPecData debugPecData = debugContext.getDebugPecData();
        try {
            debugResult2.setContextVariables(debugPecData.getContextVariables());
            debugResult2.setPolicyResult(debugPecData.getPolicyResult());
            debugResult = debugResult2;
            if (debugResult == null) {
                DebugAdminImpl.a(21);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw DebugAdminImpl.a(illegalArgumentException);
        }
        return debugResult;
    }

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

    /*
     * Unable to fully structure code
     */
    static {
        block10: {
            block9: {
                var5 = new String[27];
                var3_1 = 0;
                var2_2 = "tq|7\nidp \u001c\u001cAxev\u0006hub'\u0005=\nj\u007f};\u000b!cuyu\tid~\",=Fow\f~us'\u000f\u001bKtdt*\u001c*y\u007f|}\u0004oP\u007fsy}\u001b=Vluc}\u001b,Ajtt0\u001d?\u000b^us'\u000f\u0019@wy\u007f\u001b\u0005(H\u000fiue\u0016\r:Q}]p<\t?Ah>[bv'\u0005=Jn0w=\u001axdT\u007fe\u001c\u001d4H:`p \t5AnucrO}W=0~4H}W45br\u0005-Wn0\u007f=\u001cxF\u007f0\u007f'\u00044\u0006nqb9!<\u000f{cb7\u001a,Mu~_'\u0005:Ah\u0016{tu\u0007\u001b=VY\u007f\u007f&\r PLqc;\t:H\u007f\u0007idt\"'-P\u0010n\u007fv5\u0004=fhup9\u00187Mtd\f~us'\u000f\u0015Etqv7\u001a\u000emqx&.7VO`u3\u001c=W*Z^~&&-Hv0|7\u001c0K~04!F}W:}d!\u001cxJud1 \r,Qh~1<\u001d4H*y\u007f|}\u0004oP\u007fsy}\u001b=Vluc}\u001b,Ajtt0\u001d?\u000b^us'\u000f\u0019@wy\u007f\u001b\u0005(H\bidt\"!6Pu\u0011ybt3\u001c=`\u007frd5:=Wo|e\nidp \u001c\u001cAxev\u0011ybt3\u001c=`\u007frd5:=Wo|e\u0019hu|=\u001e=qiuc\u0011\u00076P\u007fhe\u0004\t*M{r}7\bidt\"'.Ah\u000fs~x&\u00019Hsjt\u0016\r:Q}";
                var4_3 = "tq|7\nidp \u001c\u001cAxev\u0006hub'\u0005=\nj\u007f};\u000b!cuyu\tid~\",=Fow\f~us'\u000f\u001bKtdt*\u001c*y\u007f|}\u0004oP\u007fsy}\u001b=Vluc}\u001b,Ajtt0\u001d?\u000b^us'\u000f\u0019@wy\u007f\u001b\u0005(H\u000fiue\u0016\r:Q}]p<\t?Ah>[bv'\u0005=Jn0w=\u001axdT\u007fe\u001c\u001d4H:`p \t5AnucrO}W=0~4H}W45br\u0005-Wn0\u007f=\u001cxF\u007f0\u007f'\u00044\u0006nqb9!<\u000f{cb7\u001a,Mu~_'\u0005:Ah\u0016{tu\u0007\u001b=VY\u007f\u007f&\r PLqc;\t:H\u007f\u0007idt\"'-P\u0010n\u007fv5\u0004=fhup9\u00187Mtd\f~us'\u000f\u0015Etqv7\u001a\u000emqx&.7VO`u3\u001c=W*Z^~&&-Hv0|7\u001c0K~04!F}W:}d!\u001cxJud1 \r,Qh~1<\u001d4H*y\u007f|}\u0004oP\u007fsy}\u001b=Vluc}\u001b,Ajtt0\u001d?\u000b^us'\u000f\u0019@wy\u007f\u001b\u0005(H\bidt\"!6Pu\u0011ybt3\u001c=`\u007frd5:=Wo|e\nidp \u001c\u001cAxev\u0011ybt3\u001c=`\u007frd5:=Wo|e\u0019hu|=\u001e=qiuc\u0011\u00076P\u007fhe\u0004\t*M{r}7\bidt\"'.Ah\u000fs~x&\u00019Hsjt\u0016\r:Q}".length();
                var1_4 = 4;
                var0_5 = -1;
lbl7:
                // 2 sources

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

                while (true) {
                    var5[var3_1++] = DebugAdminImpl.a(v0, DebugAdminImpl.a(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    var2_2 = "+0&zDs\u0000+0\u0010rOh\u0006\u0014-09x[x 39\u0016eH|\n/:=yYn";
                    var4_3 = "+0&zDs\u0000+0\u0010rOh\u0006\u0014-09x[x 39\u0016eH|\n/:=yYn".length();
                    var1_4 = 14;
                    var0_5 = -1;
lbl22:
                    // 2 sources

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

    private static char[] a(String string) {
        char[] cArray = string.toCharArray();
        if (cArray.length < 2) {
            cArray = cArray;
            cArray[0] = (char)(cArray[0] ^ 0x5A);
        }
        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 -> 100;
                    case 1 -> 110;
                    case 2 -> 111;
                    case 3 -> 44;
                    case 4 -> 22;
                    case 5 -> 38;
                    default -> 90;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

