package com.l7tech.server.policy.variable;

import com.l7tech.message.Message;
import com.l7tech.policy.variable.Syntax.SyntaxErrorHandler;
import org.jetbrains.annotations.NotNull;

class em implements MessageSelector.MessageAttributeSelector {
   private static final String[] a;

   @Override
   public ExpandVariables.Selector.Selection select(Message var1, String var2, SyntaxErrorHandler var3, boolean var4) {
      return new ExpandVariables.Selector.Selection(this.a(var1).getLabel());
   }

   @NotNull
   private MessageSelector.BufferStatus a(Message 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: invokevirtual com/l7tech/message/Message.isInitialized ()Z
      // 04: ifne 21
      // 07: getstatic com/l7tech/server/policy/variable/MessageSelector$BufferStatus.UNINITIALIZED Lcom/l7tech/server/policy/variable/MessageSelector$BufferStatus;
      // 0a: dup
      // 0b: ifnonnull 20
      // 0e: goto 15
      // 11: invokestatic com/l7tech/server/policy/variable/em.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 14: athrow
      // 15: bipush 0
      // 16: invokestatic com/l7tech/server/policy/variable/em.a (I)V
      // 19: goto 20
      // 1c: invokestatic com/l7tech/server/policy/variable/em.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 1f: athrow
      // 20: areturn
      // 21: aload 1
      // 22: ldc com/l7tech/message/MimeKnob
      // 24: invokevirtual com/l7tech/message/Message.getKnob (Ljava/lang/Class;)Ljava/lang/Object;
      // 27: checkcast com/l7tech/message/MimeKnob
      // 2a: astore 2
      // 2b: aload 2
      // 2c: ifnonnull 49
      // 2f: getstatic com/l7tech/server/policy/variable/MessageSelector$BufferStatus.UNINITIALIZED Lcom/l7tech/server/policy/variable/MessageSelector$BufferStatus;
      // 32: dup
      // 33: ifnonnull 48
      // 36: goto 3d
      // 39: invokestatic com/l7tech/server/policy/variable/em.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 3c: athrow
      // 3d: bipush 1
      // 3e: invokestatic com/l7tech/server/policy/variable/em.a (I)V
      // 41: goto 48
      // 44: invokestatic com/l7tech/server/policy/variable/em.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 47: athrow
      // 48: areturn
      // 49: aload 2
      // 4a: invokeinterface com/l7tech/message/MimeKnob.getFirstPart ()Lcom/l7tech/common/mime/PartInfo; 1
      // 4f: astore 3
      // 50: aload 3
      // 51: invokeinterface com/l7tech/common/mime/PartInfo.isBodyStashed ()Z 1
      // 56: ifeq 65
      // 59: getstatic com/l7tech/server/policy/variable/MessageSelector$BufferStatus.BUFFERED Lcom/l7tech/server/policy/variable/MessageSelector$BufferStatus;
      // 5c: dup
      // 5d: ifnonnull 64
      // 60: bipush 2
      // 61: invokestatic com/l7tech/server/policy/variable/em.a (I)V
      // 64: areturn
      // 65: aload 3
      // 66: invokeinterface com/l7tech/common/mime/PartInfo.isBodyAvailable ()Z 1
      // 6b: ifeq 81
      // 6e: getstatic com/l7tech/server/policy/variable/MessageSelector$BufferStatus.UNREAD Lcom/l7tech/server/policy/variable/MessageSelector$BufferStatus;
      // 71: dup
      // 72: ifnonnull 80
      // 75: goto 7c
      // 78: invokestatic com/l7tech/server/policy/variable/em.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 7b: athrow
      // 7c: bipush 3
      // 7d: invokestatic com/l7tech/server/policy/variable/em.a (I)V
      // 80: areturn
      // 81: getstatic com/l7tech/server/policy/variable/MessageSelector$BufferStatus.GONE Lcom/l7tech/server/policy/variable/MessageSelector$BufferStatus;
      // 84: dup
      // 85: ifnonnull 93
      // 88: bipush 4
      // 89: invokestatic com/l7tech/server/policy/variable/em.a (I)V
      // 8c: goto 93
      // 8f: invokestatic com/l7tech/server/policy/variable/em.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 92: athrow
      // 93: areturn
      // 94: astore 3
      // 95: getstatic com/l7tech/server/policy/variable/MessageSelector$BufferStatus.GONE Lcom/l7tech/server/policy/variable/MessageSelector$BufferStatus;
      // 98: dup
      // 99: ifnonnull a7
      // 9c: bipush 5
      // 9d: invokestatic com/l7tech/server/policy/variable/em.a (I)V
      // a0: goto a7
      // a3: invokestatic com/l7tech/server/policy/variable/em.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // a6: athrow
      // a7: areturn
      // try (22 -> 30): 31 java/io/IOException
      // try (20 -> 25): 26 java/io/IOException
      // try (3 -> 11): 12 java/io/IOException
      // try (0 -> 6): 7 java/io/IOException
      // try (34 -> 41): 67 java/io/IOException
      // try (46 -> 50): 67 java/io/IOException
      // try (46 -> 52): 53 java/lang/IllegalStateException
      // try (58 -> 59): 67 java/io/IOException
      // try (58 -> 63): 64 java/lang/IllegalStateException
      // try (68 -> 73): 74 java/io/IOException
   }

   private static void a(int var0) {
      String[] var1 = a;
      throw new IllegalStateException(String.format(var1[1], var1[0], var1[2]));
   }

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

   static {
      String[] var5 = new String[3];
      int var3 = 0;
      String var2 = ",zI#3\u0015-*vL#,G+9pV#/M5&v]#)C+&tF`:\r<\"*\u000f[Kx\u0011W5#5Ii+J6+5\u0001\u007fq\u0007*oxQ\u007f+\u00027 a\u0004~:V,={\u0004b*N5\u000f(pPN*D?*gwx>V,<";
      int var4 = ",zI#3\u0015-*vL#,G+9pV#/M5&v]#)C+&tF`:\r<\"*\u000f[Kx\u0011W5#5Ii+J6+5\u0001\u007fq\u0007*oxQ\u007f+\u00027 a\u0004~:V,={\u0004b*N5\u000f(pPN*D?*gwx>V,<"
         .length();
      char var1 = '$';
      int var0 = -1;

      while (true) {
         String var10002 = a(24, a(var2.substring(++var0, var0 + var1)));
         byte var10001 = -1;
         var5[var3++] = var10002;
         if ((var0 += var1) >= var4) {
            a = var5;
            return;
         }

         var1 = var2.charAt(var0);
      }
   }

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

      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 -> 87;
            case 1 -> 13;
            case 2 -> 60;
            case 3 -> 20;
            case 4 -> 71;
            case 5 -> 58;
            default -> 65;
         });
      }

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