package com.l7tech.gateway.common.security.rbac;

import com.l7tech.objectmodel.Entity;
import com.l7tech.objectmodel.EntityHeaderRef;
import com.l7tech.objectmodel.EntityType;
import com.l7tech.util.DeserializeSafe;
import java.io.Serializable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

@DeserializeSafe
public final class EntityProtectionInfo implements Serializable {
   private static final long serialVersionUID = 2140250756247723622L;
   private final EntityType entityType;
   private final boolean readOnly;
   private static final String[] a;

   public EntityProtectionInfo(@NotNull EntityType var1, boolean var2) {
      this.entityType = var1;
      this.readOnly = var2;
   }

   public boolean isReadOnly() {
      return this.readOnly;
   }

   public boolean matchesTypeOf(@Nullable Entity param1) {
      // $VF: Couldn't be decompiled
      // Please report this to the Vineflower issue tracker, at https://github.com/Vineflower/vineflower/issues with a copy of the class file (if you have the rights to distribute it!)
      // java.lang.RuntimeException: parsing failure!
      //   at org.jetbrains.java.decompiler.modules.decompiler.decompose.DomHelper.parseGraph(DomHelper.java:211)
      //   at org.jetbrains.java.decompiler.main.rels.MethodProcessor.codeToJava(MethodProcessor.java:174)
      //
      // Bytecode:
      // 00: aload 1
      // 01: ifnull 26
      // 04: aload 0
      // 05: getfield com/l7tech/gateway/common/security/rbac/EntityProtectionInfo.entityType Lcom/l7tech/objectmodel/EntityType;
      // 08: invokevirtual com/l7tech/objectmodel/EntityType.getEntityClass ()Ljava/lang/Class;
      // 0b: aload 1
      // 0c: invokeinterface com/l7tech/objectmodel/Entity.getClass ()Ljava/lang/Class; 1
      // 11: invokevirtual java/lang/Class.isAssignableFrom (Ljava/lang/Class;)Z
      // 14: ifeq 26
      // 17: goto 1e
      // 1a: invokestatic com/l7tech/gateway/common/security/rbac/EntityProtectionInfo.a (Ljava/lang/IllegalArgumentException;)Ljava/lang/IllegalArgumentException;
      // 1d: athrow
      // 1e: bipush 1
      // 1f: goto 27
      // 22: invokestatic com/l7tech/gateway/common/security/rbac/EntityProtectionInfo.a (Ljava/lang/IllegalArgumentException;)Ljava/lang/IllegalArgumentException;
      // 25: athrow
      // 26: bipush 0
      // 27: ireturn
      // try (0 -> 9): 10 java/lang/IllegalArgumentException
      // try (2 -> 14): 14 java/lang/IllegalArgumentException
   }

   public boolean matchesTypeOf(@Nullable EntityHeaderRef param1) {
      // $VF: Couldn't be decompiled
      // Please report this to the Vineflower issue tracker, at https://github.com/Vineflower/vineflower/issues with a copy of the class file (if you have the rights to distribute it!)
      // java.lang.RuntimeException: parsing failure!
      //   at org.jetbrains.java.decompiler.modules.decompiler.decompose.DomHelper.parseGraph(DomHelper.java:211)
      //   at org.jetbrains.java.decompiler.main.rels.MethodProcessor.codeToJava(MethodProcessor.java:174)
      //
      // Bytecode:
      // 00: aload 1
      // 01: ifnull 1e
      // 04: aload 0
      // 05: getfield com/l7tech/gateway/common/security/rbac/EntityProtectionInfo.entityType Lcom/l7tech/objectmodel/EntityType;
      // 08: aload 1
      // 09: invokevirtual com/l7tech/objectmodel/EntityHeaderRef.getType ()Lcom/l7tech/objectmodel/EntityType;
      // 0c: if_acmpne 1e
      // 0f: goto 16
      // 12: invokestatic com/l7tech/gateway/common/security/rbac/EntityProtectionInfo.a (Ljava/lang/IllegalArgumentException;)Ljava/lang/IllegalArgumentException;
      // 15: athrow
      // 16: bipush 1
      // 17: goto 1f
      // 1a: invokestatic com/l7tech/gateway/common/security/rbac/EntityProtectionInfo.a (Ljava/lang/IllegalArgumentException;)Ljava/lang/IllegalArgumentException;
      // 1d: athrow
      // 1e: bipush 0
      // 1f: ireturn
      // try (0 -> 7): 8 java/lang/IllegalArgumentException
      // try (2 -> 12): 12 java/lang/IllegalArgumentException
   }

   private static IllegalArgumentException a(IllegalArgumentException var0) {
      return var0;
   }

   static {
      String[] var5 = new String[4];
      int var3 = 0;
      String var2 = "\\0VBVo>!+_^O4R\u0014y^DPq|.6LeW=P@)YYC<Y\u0014<J\u000b\u0005tOGyWM\u0002tON|K\u000bO$O\u0014yVDVq^\u0005yV^N=";
      int var4 = "\\0VBVo>!+_^O4R\u0014y^DPq|.6LeW=P@)YYC<Y\u0014<J\u000b\u0005tOGyWM\u0002tON|K\u000bO$O\u0014yVDVq^\u0005yV^N=".length();
      char var1 = 6;
      int var7 = -1;

      label24:
      while (true) {
         byte var10000 = 79;
         String var10001 = var2.substring(++var7, var7 + var1);
         byte var10002 = -1;

         while (true) {
            String var8 = a(var10000, a(var10001));
            switch (var10002) {
               case 0:
                  var5[var3++] = var8;
                  if ((var7 += var1) >= var4) {
                     a = var5;
                     return;
                  }

                  var1 = var2.charAt(var7);
                  break;
               default:
                  var5[var3++] = var8;
                  if ((var7 += var1) < var4) {
                     var1 = var2.charAt(var7);
                     continue label24;
                  }

                  var2 = "_m\u0016\u0018\fr2Cs\u0007<Yl\u000f^\u0014<\u0012_`\n^\u001fj\u0012_t\u0003\bWh\tWn\r\u001fWx\u0003Yv\u0010\u0018\frIHa\u0003\u0012WN\bNj\u0016\b(y\tNf\u0001\u0005\u0011d\bsm\u0004\u001e";
                  var4 = "_m\u0016\u0018\fr2Cs\u0007<Yl\u000f^\u0014<\u0012_`\n^\u001fj\u0012_t\u0003\bWh\tWn\r\u001fWx\u0003Yv\u0010\u0018\frIHa\u0003\u0012WN\bNj\u0016\b(y\tNf\u0001\u0005\u0011d\bsm\u0004\u001e"
                     .length();
                  var1 = '\n';
                  var7 = -1;
            }

            var10000 = 21;
            var10001 = var2.substring(++var7, var7 + var1);
            var10002 = 0;
         }
      }
   }

   private static char[] a(String var0) {
      char[] var10000 = var0.toCharArray();
      if (var10000.length < 2) {
         var10000[0] = (char)(var10000[0] ^ 115);
      }

      return var10000;
   }

   private static String a(int var0, char[] var1) {
      int var10003 = var1.length;
      int var10002 = var0;
      char[] var10001 = var1;
      int var10000 = var10003;

      for (int var2 = 0; var10000 > var2; var2++) {
         var10001[var2] = (char)(var10001[var2] ^ var10002 ^ switch (var2 % 7) {
            case 0 -> 47;
            case 1 -> 22;
            case 2 -> 119;
            case 3 -> 100;
            case 4 -> 109;
            case 5 -> 30;
            default -> 115;
         });
      }

      return new String(var10001).intern();
   }
}
