/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.gateway.common.Component
 *  com.l7tech.gateway.common.LicenseManager
 *  com.l7tech.gateway.common.audit.Audit
 *  com.l7tech.gateway.common.audit.AuditDetailMessage
 *  com.l7tech.gateway.common.audit.SystemMessages
 *  com.l7tech.gateway.common.transport.SsgActiveConnector
 *  com.l7tech.objectmodel.FindException
 *  com.l7tech.objectmodel.Goid
 *  com.l7tech.util.ExceptionUtils
 *  jakarta.inject.Inject
 *  org.jetbrains.annotations.NotNull
 *  org.jetbrains.annotations.Nullable
 *  org.springframework.context.ApplicationEvent
 */
package com.l7tech.server.transport;

import com.l7tech.gateway.common.Component;
import com.l7tech.gateway.common.LicenseManager;
import com.l7tech.gateway.common.audit.Audit;
import com.l7tech.gateway.common.audit.AuditDetailMessage;
import com.l7tech.gateway.common.audit.SystemMessages;
import com.l7tech.gateway.common.transport.SsgActiveConnector;
import com.l7tech.objectmodel.FindException;
import com.l7tech.objectmodel.Goid;
import com.l7tech.server.LifecycleBean;
import com.l7tech.server.audit.Auditor;
import com.l7tech.server.event.EntityInvalidationEvent;
import com.l7tech.server.transport.ListenerException;
import com.l7tech.server.transport.SsgActiveConnectorManager;
import com.l7tech.util.ExceptionUtils;
import jakarta.inject.Inject;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.springframework.context.ApplicationEvent;

/*
 * Exception performing whole class analysis ignored.
 */
public abstract class ActiveTransportModule
extends LifecycleBean {
    protected final Logger logger;
    protected final Component component;
    private Audit h;
    @Inject
    protected SsgActiveConnectorManager ssgActiveConnectorManager;
    private static final String[] i;

    protected ActiveTransportModule(@NotNull String string, @NotNull Component component, @NotNull Logger logger, @NotNull String string2) {
        if (string == null) {
            ActiveTransportModule.b(0);
        }
        if (component == null) {
            ActiveTransportModule.b(1);
        }
        if (logger == null) {
            ActiveTransportModule.b(2);
        }
        if (string2 == null) {
            ActiveTransportModule.b(3);
        }
        super(string, logger, string2, null);
        this.component = component;
        this.logger = logger;
    }

    @Override
    @Inject
    protected void setLicenseManager(LicenseManager licenseManager) {
        super.setLicenseManager(licenseManager);
    }

    protected boolean isInitialized() {
        return this.isStarted();
    }

    protected boolean isCurrent(Goid goid, int n2) {
        return false;
    }

    protected abstract void addConnector(@NotNull SsgActiveConnector var1) throws ListenerException;

    protected abstract void removeConnector(Goid var1);

    protected abstract Set<String> getSupportedTypes();

    protected boolean typeIsOwnedByThisModule(@NotNull String string) {
        try {
            if (string == null) {
                ActiveTransportModule.b(4);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw ActiveTransportModule.a(illegalArgumentException);
        }
        return this.getSupportedTypes().contains(string);
    }

    protected boolean connectorIsOwnedByThisModule(@NotNull SsgActiveConnector ssgActiveConnector) {
        try {
            if (ssgActiveConnector == null) {
                ActiveTransportModule.b(5);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw ActiveTransportModule.a(illegalArgumentException);
        }
        return this.typeIsOwnedByThisModule(ssgActiveConnector.getType());
    }

    protected boolean isValidConnectorConfig(@NotNull SsgActiveConnector ssgActiveConnector) {
        try {
            if (ssgActiveConnector == null) {
                ActiveTransportModule.b(6);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw ActiveTransportModule.a(illegalArgumentException);
        }
        return true;
    }

    /*
     * Exception decompiling
     */
    @Override
    public void onApplicationEvent(ApplicationEvent var1_1) {
        /*
         * 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: Back jump on a try block [egrp 5[TRYBLOCK] [1, 0, 6 : 89->99)] com.l7tech.server.LifecycleException
         *     at org.benf.cfr.reader.bytecode.analysis.opgraph.Op02WithProcessedDataAndRefs.insertExceptionBlocks(Op02WithProcessedDataAndRefs.java:2283)
         *     at org.benf.cfr.reader.bytecode.CodeAnalyser.getAnalysisInner(CodeAnalyser.java:415)
         *     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:1055)
         *     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 void a(EntityInvalidationEvent entityInvalidationEvent) {
        Goid[] goidArray = entityInvalidationEvent.getEntityIds();
        char[] cArray = entityInvalidationEvent.getEntityOperations();
        try {
            for (int i2 = 0; i2 < goidArray.length; ++i2) {
                this.a(cArray[i2], goidArray[i2]);
            }
        }
        catch (IllegalArgumentException illegalArgumentException) {
            throw ActiveTransportModule.a(illegalArgumentException);
        }
    }

    /*
     * Exception decompiling
     */
    private void a(char var1_1, Goid var2_2) {
        /*
         * 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 [1[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:1055)
         *     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");
    }

    /*
     * Loose catch block
     */
    private void a(Goid goid) throws FindException, ListenerException {
        block12: {
            SsgActiveConnector ssgActiveConnector = (SsgActiveConnector)this.ssgActiveConnectorManager.findByPrimaryKey(goid);
            try {
                if (ssgActiveConnector == null) {
                    return;
                }
            }
            catch (Exception exception) {
                throw ActiveTransportModule.a(exception);
            }
            try {
                if (this.isCurrent(ssgActiveConnector.getGoid(), ssgActiveConnector.getVersion())) {
                    return;
                }
            }
            catch (Exception exception) {
                throw ActiveTransportModule.a(exception);
            }
            this.removeConnector(goid);
            if (!ssgActiveConnector.isEnabled()) break block12;
            try {
                block13: {
                    if (!this.connectorIsOwnedByThisModule(ssgActiveConnector)) break block12;
                    break block13;
                    catch (Exception exception) {
                        throw ActiveTransportModule.a(exception);
                    }
                }
                if (!this.isValidConnectorConfig(ssgActiveConnector)) break block12;
            }
            catch (Exception exception) {
                throw ActiveTransportModule.a(exception);
            }
            SsgActiveConnector ssgActiveConnector2 = ssgActiveConnector.getReadOnlyCopy();
            try {
                this.addConnector(ssgActiveConnector2);
            }
            catch (Exception exception) {
                String string = ExceptionUtils.getMessage((Throwable)exception);
                String string2 = ssgActiveConnector2.getName();
                String string3 = ssgActiveConnector2.getType();
                String[] stringArray = i;
                this.logger.log(Level.WARNING, stringArray[13] + string3 + stringArray[6] + string2 + stringArray[8] + string, ExceptionUtils.getDebugException((Throwable)exception));
            }
        }
    }

    protected final void auditError(String string, String string2, @Nullable Throwable throwable) {
        this.getAudit().logAndAudit((AuditDetailMessage)SystemMessages.CONNECTOR_ERROR, new String[]{string, string2}, throwable);
    }

    protected Audit getAudit() {
        Object object = this.h;
        if (object == null) {
            this.h = object = new Auditor(this, this.getApplicationContext(), this.logger);
        }
        return object;
    }

    /*
     * Exception decompiling
     */
    private static /* synthetic */ void b(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 Throwable a(Throwable throwable) {
        return throwable;
    }

    /*
     * Unable to fully structure code
     */
    static {
        block10: {
            block9: {
                var5 = new String[19];
                var3_1 = 0;
                var2_2 = ")*Fl-X+/&Cl2\n-< Yl5\u001d>$6[,3\u001bp\u000b&_*7\n\u000b8$E01\u0000->\bD'4\u0003:1\u000f7Y,3O/8*H&2\u001c6$\"\u000b )\u000e1- \u000b%.\u001d\u007f+&_*7\n\u007f)*E-$\f+%7\u000b,(\u000b\u007f\u001f\u001f+Y&\"\u00008$,Q&%O:$1B78O0: Y\"5\u00060$\u007f\u000b\u0004><[&\t)*F3.\u0001:$1\u0006&*L$$\u001d\u0012j$H7(\u0019:j&D-/\n<>*Yc\u001c)*E-$\f+%7b0\u000e\u00181/!i:\u0015\u000769\bD'4\u0003:\u0002pe\u000e&,H&/\u001c:\f J74\u001d:\u0002pe!\u000f7Y,3O,>$Y7(\u00018j1Y\"/\u001c/%7_c,\u0000;?)Nya\u0006v,E*5Q\u0010\u001f+J!-\n\u007f>*\u000b05\u000e->e>\u000b7L6,\n1>eM,3O\u001f\u0004*_\r4\u00033j5J1 \u0002:> YcfJ,meD%aJ,d`Xc,\u001a,>eE,5O=/eE6-\u0003\u0004$$F&\u001296L\u0002\"\u001b6< h,/\u0001:)1D1";
                var4_3 = ")*Fl-X+/&Cl2\n-< Yl5\u001d>$6[,3\u001bp\u000b&_*7\n\u000b8$E01\u0000->\bD'4\u0003:1\u000f7Y,3O/8*H&2\u001c6$\"\u000b )\u000e1- \u000b%.\u001d\u007f+&_*7\n\u007f)*E-$\f+%7\u000b,(\u000b\u007f\u001f\u001f+Y&\"\u00008$,Q&%O:$1B78O0: Y\"5\u00060$\u007f\u000b\u0004><[&\t)*F3.\u0001:$1\u0006&*L$$\u001d\u0012j$H7(\u0019:j&D-/\n<>*Yc\u001c)*E-$\f+%7b0\u000e\u00181/!i:\u0015\u000769\bD'4\u0003:\u0002pe\u000e&,H&/\u001c:\f J74\u001d:\u0002pe!\u000f7Y,3O,>$Y7(\u00018j1Y\"/\u001c/%7_c,\u0000;?)Nya\u0006v,E*5Q\u0010\u001f+J!-\n\u007f>*\u000b05\u000e->e>\u000b7L6,\n1>eM,3O\u001f\u0004*_\r4\u00033j5J1 \u0002:> YcfJ,meD%aJ,d`Xc,\u001a,>eE,5O=/eE6-\u0003\u0004$$F&\u001296L\u0002\"\u001b6< h,/\u0001:)1D1".length();
                var1_4 = 49;
                var0_5 = -1;
lbl7:
                // 2 sources

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

                while (true) {
                    var5[var3_1++] = ActiveTransportModule.b(v0, ActiveTransportModule.a(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    var2_2 = "df\u0001|RFJgq\u0014}YLQxv\u0002TtQp|z\u0016yl'xw\\aSp\u001fw~Vq\u007fm2vuSlw";
                    var4_3 = "df\u0001|RFJgq\u0014}YLQxv\u0002TtQp|z\u0016yl'xw\\aSp\u001fw~Vq\u007fm2vuSlw".length();
                    var1_4 = 23;
                    var0_5 = -1;
lbl22:
                    // 2 sources

                    while (true) {
                        v0 = 115;
                        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++] = ActiveTransportModule.b(v0, ActiveTransportModule.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;
            }
        }
        ActiveTransportModule.i = var5;
    }

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

    /*
     * Handled impossible loop by duplicating code
     * Enabled aggressive block sorting
     */
    private static String b(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 -> 99;
                    case 1 -> 108;
                    case 2 -> 2;
                    case 3 -> 106;
                    case 4 -> 104;
                    case 5 -> 70;
                    default -> 118;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

