package com.l7tech.policy.assertion;

import com.l7tech.util.CollectionUtils;
import com.l7tech.util.ConfigFactory;
import com.l7tech.util.ExceptionUtils;
import com.l7tech.util.Functions;
import com.l7tech.util.TextUtils;
import com.l7tech.util.XmlSafe;
import java.io.Serializable;
import java.util.Collections;
import java.util.List;

@XmlSafe
public class HttpPassthroughRuleSet implements Cloneable, Serializable {
   public static final int ORIGINAL_PASSTHROUGH = 0;
   public static final int CUSTOM_PASSTHROUGH = 1;
   public static final int CUSTOM_AND_ORIGINAL_PASSTHROUGH = 2;
   public static final int BLOCK = 3;
   private static final String PROP_HEADERS_TO_SKIP;
   private static final String HEADERS_TO_SKIP_DEFAULT;
   public static final List<String> HEADERS_NOT_TO_IMPLICITLY_FORWARD;
   private boolean forwardAll;
   private HttpPassthroughRule[] rules;
   static final long serialVersionUID = -2034959890774044923L;
   private static final String[] a;

   @XmlSafe
   public HttpPassthroughRuleSet() {
      this.forwardAll = false;
      this.rules = new HttpPassthroughRule[0];
   }

   @XmlSafe
   public HttpPassthroughRuleSet(boolean var1, HttpPassthroughRule[] var2) {
      this.forwardAll = var1;
      this.rules = var2;
      if (var2 == null) {
         throw new IllegalArgumentException(a[2]);
      }
   }

   @XmlSafe
   public boolean isForwardAll() {
      return this.forwardAll;
   }

   @XmlSafe
   public void setForwardAll(boolean var1) {
      this.forwardAll = var1;
   }

   @XmlSafe
   public HttpPassthroughRule[] getRules() {
      return this.rules;
   }

   @XmlSafe
   public void setRules(HttpPassthroughRule[] var1) {
      this.rules = var1;
   }

   @XmlSafe
   public void remove(String 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 0
      // 01: getfield com/l7tech/policy/assertion/HttpPassthroughRuleSet.rules [Lcom/l7tech/policy/assertion/HttpPassthroughRule;
      // 04: ifnull 92
      // 07: bipush 0
      // 08: istore 2
      // 09: bipush 0
      // 0a: istore 3
      // 0b: iload 3
      // 0c: aload 0
      // 0d: getfield com/l7tech/policy/assertion/HttpPassthroughRuleSet.rules [Lcom/l7tech/policy/assertion/HttpPassthroughRule;
      // 10: arraylength
      // 11: if_icmpge 42
      // 14: aload 0
      // 15: getfield com/l7tech/policy/assertion/HttpPassthroughRuleSet.rules [Lcom/l7tech/policy/assertion/HttpPassthroughRule;
      // 18: iload 3
      // 19: aaload
      // 1a: invokevirtual com/l7tech/policy/assertion/HttpPassthroughRule.getName ()Ljava/lang/String;
      // 1d: aload 1
      // 1e: invokevirtual java/lang/String.compareToIgnoreCase (Ljava/lang/String;)I
      // 21: ifne 3c
      // 24: goto 2b
      // 27: invokestatic com/l7tech/policy/assertion/HttpPassthroughRuleSet.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 2a: athrow
      // 2b: aload 0
      // 2c: getfield com/l7tech/policy/assertion/HttpPassthroughRuleSet.rules [Lcom/l7tech/policy/assertion/HttpPassthroughRule;
      // 2f: iload 3
      // 30: aconst_null
      // 31: aastore
      // 32: iinc 2 1
      // 35: goto 3c
      // 38: invokestatic com/l7tech/policy/assertion/HttpPassthroughRuleSet.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 3b: athrow
      // 3c: iinc 3 1
      // 3f: goto 0b
      // 42: iload 2
      // 43: ifle 92
      // 46: aload 0
      // 47: getfield com/l7tech/policy/assertion/HttpPassthroughRuleSet.rules [Lcom/l7tech/policy/assertion/HttpPassthroughRule;
      // 4a: arraylength
      // 4b: iload 2
      // 4c: isub
      // 4d: anewarray 89
      // 50: astore 3
      // 51: bipush 0
      // 52: istore 4
      // 54: bipush 0
      // 55: istore 5
      // 57: iload 5
      // 59: aload 3
      // 5a: arraylength
      // 5b: if_icmpge 8d
      // 5e: aload 0
      // 5f: getfield com/l7tech/policy/assertion/HttpPassthroughRuleSet.rules [Lcom/l7tech/policy/assertion/HttpPassthroughRule;
      // 62: iload 4
      // 64: aaload
      // 65: ifnonnull 79
      // 68: goto 6f
      // 6b: invokestatic com/l7tech/policy/assertion/HttpPassthroughRuleSet.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 6e: athrow
      // 6f: iinc 4 1
      // 72: goto 5e
      // 75: invokestatic com/l7tech/policy/assertion/HttpPassthroughRuleSet.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 78: athrow
      // 79: aload 3
      // 7a: iload 5
      // 7c: aload 0
      // 7d: getfield com/l7tech/policy/assertion/HttpPassthroughRuleSet.rules [Lcom/l7tech/policy/assertion/HttpPassthroughRule;
      // 80: iload 4
      // 82: aaload
      // 83: aastore
      // 84: iinc 4 1
      // 87: iinc 5 1
      // 8a: goto 57
      // 8d: aload 0
      // 8e: aload 3
      // 8f: putfield com/l7tech/policy/assertion/HttpPassthroughRuleSet.rules [Lcom/l7tech/policy/assertion/HttpPassthroughRule;
      // 92: return
      // try (7 -> 20): 21 java/lang/IllegalArgumentException
      // try (12 -> 29): 30 java/lang/IllegalArgumentException
      // try (47 -> 56): 57 java/lang/IllegalArgumentException
      // try (51 -> 61): 61 java/lang/IllegalArgumentException
   }

   @XmlSafe
   public int ruleForName(String 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 0
      // 01: getfield com/l7tech/policy/assertion/HttpPassthroughRuleSet.forwardAll Z
      // 04: ifeq 0d
      // 07: bipush 0
      // 08: ireturn
      // 09: invokestatic com/l7tech/policy/assertion/HttpPassthroughRuleSet.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 0c: athrow
      // 0d: aload 0
      // 0e: getfield com/l7tech/policy/assertion/HttpPassthroughRuleSet.rules [Lcom/l7tech/policy/assertion/HttpPassthroughRule;
      // 11: ifnull 89
      // 14: bipush 0
      // 15: istore 2
      // 16: bipush 0
      // 17: istore 3
      // 18: bipush 0
      // 19: istore 4
      // 1b: iload 4
      // 1d: aload 0
      // 1e: getfield com/l7tech/policy/assertion/HttpPassthroughRuleSet.rules [Lcom/l7tech/policy/assertion/HttpPassthroughRule;
      // 21: arraylength
      // 22: if_icmpge 5e
      // 25: aload 0
      // 26: getfield com/l7tech/policy/assertion/HttpPassthroughRuleSet.rules [Lcom/l7tech/policy/assertion/HttpPassthroughRule;
      // 29: iload 4
      // 2b: aaload
      // 2c: invokevirtual com/l7tech/policy/assertion/HttpPassthroughRule.getName ()Ljava/lang/String;
      // 2f: aload 1
      // 30: invokevirtual java/lang/String.compareToIgnoreCase (Ljava/lang/String;)I
      // 33: ifne 58
      // 36: goto 3d
      // 39: invokestatic com/l7tech/policy/assertion/HttpPassthroughRuleSet.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 3c: athrow
      // 3d: aload 0
      // 3e: getfield com/l7tech/policy/assertion/HttpPassthroughRuleSet.rules [Lcom/l7tech/policy/assertion/HttpPassthroughRule;
      // 41: iload 4
      // 43: aaload
      // 44: invokevirtual com/l7tech/policy/assertion/HttpPassthroughRule.isUsesCustomizedValue ()Z
      // 47: ifeq 56
      // 4a: goto 51
      // 4d: invokestatic com/l7tech/policy/assertion/HttpPassthroughRuleSet.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 50: athrow
      // 51: bipush 1
      // 52: istore 2
      // 53: goto 58
      // 56: bipush 1
      // 57: istore 3
      // 58: iinc 4 1
      // 5b: goto 1b
      // 5e: iload 2
      // 5f: ifeq 73
      // 62: iload 3
      // 63: ifeq 73
      // 66: goto 6d
      // 69: invokestatic com/l7tech/policy/assertion/HttpPassthroughRuleSet.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 6c: athrow
      // 6d: bipush 2
      // 6e: ireturn
      // 6f: invokestatic com/l7tech/policy/assertion/HttpPassthroughRuleSet.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 72: athrow
      // 73: iload 2
      // 74: ifeq 7d
      // 77: bipush 1
      // 78: ireturn
      // 79: invokestatic com/l7tech/policy/assertion/HttpPassthroughRuleSet.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 7c: athrow
      // 7d: iload 3
      // 7e: ifeq 87
      // 81: bipush 0
      // 82: ireturn
      // 83: invokestatic com/l7tech/policy/assertion/HttpPassthroughRuleSet.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 86: athrow
      // 87: bipush 3
      // 88: ireturn
      // 89: bipush 3
      // 8a: ireturn
      // try (0 -> 5): 5 java/lang/IllegalArgumentException
      // try (16 -> 29): 30 java/lang/IllegalArgumentException
      // try (21 -> 38): 39 java/lang/IllegalArgumentException
      // try (48 -> 52): 53 java/lang/IllegalArgumentException
      // try (50 -> 57): 57 java/lang/IllegalArgumentException
      // try (59 -> 63): 63 java/lang/IllegalArgumentException
      // try (65 -> 69): 69 java/lang/IllegalArgumentException
   }

   public HttpPassthroughRuleSet clone() {
      try {
         HttpPassthroughRuleSet var1 = (HttpPassthroughRuleSet)super.clone();
         var1.rules = new HttpPassthroughRule[this.rules.length];
         int var2 = 0;

         try {
            while (var2 < this.rules.length) {
               var1.rules[var2] = this.rules[var2].clone();
               var2++;
            }
         } catch (CloneNotSupportedException var3) {
            throw a(var3);
         }

         return var1;
      } catch (CloneNotSupportedException var4) {
         throw ExceptionUtils.wrap(var4);
      }
   }

   static {
      String[] var5 = new String[6];
      int var3 = 0;
      String var2 = "\u00027i:*\u001f7\u0004;l:6G/\b;}:'[0\u0004*p})Fm),pd\u0016I0\u0012,lf)]$\t\nqx#{&\u0015vlq'L&\u0013+P{\u0015C*\u0011m\n=adkI/\b.a8fK,\u000f6aw2A,\u000ft$g#Z5\u0004*(4%G-\u0015=j`k\\:\u0011=(4\"I7\u0004t$w)F7\u00046p9*M-\u0006,l8f\\1\u00006wr#Zn\u00046g{\"A-\u0006t$w)F7\u00046p9#F \u000e<mz!\u0004c\t7w`\u0016\u00057j32\b3\u0000+w4(]/\rxef4I:\u0012m\n=adkI/\b.a8fK,\u000f6aw2A,\u000ft$g#Z5\u0004*(4%G-\u0015=j`k\\:\u0011=(4\"I7\u0004t$w)F7\u00046p9*M-\u0006,l8f\\1\u00006wr#Zn\u00046g{\"A-\u0006t$w)F7\u00046p9#F \u000e<mz!\u0004c\t7w`";
      int var4 = "\u00027i:*\u001f7\u0004;l:6G/\b;}:'[0\u0004*p})Fm),pd\u0016I0\u0012,lf)]$\t\nqx#{&\u0015vlq'L&\u0013+P{\u0015C*\u0011m\n=adkI/\b.a8fK,\u000f6aw2A,\u000ft$g#Z5\u0004*(4%G-\u0015=j`k\\:\u0011=(4\"I7\u0004t$w)F7\u00046p9*M-\u0006,l8f\\1\u00006wr#Zn\u00046g{\"A-\u0006t$w)F7\u00046p9#F \u000e<mz!\u0004c\t7w`\u0016\u00057j32\b3\u0000+w4(]/\rxef4I:\u0012m\n=adkI/\b.a8fK,\u000f6aw2A,\u000ft$g#Z5\u0004*(4%G-\u0015=j`k\\:\u0011=(4\"I7\u0004t$w)F7\u00046p9*M-\u0006,l8f\\1\u00006wr#Zn\u00046g{\"A-\u0006t$w)F7\u00046p9#F \u000e<mz!\u0004c\t7w`"
         .length();
      char var1 = '@';
      int var7 = -1;

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

         while (true) {
            String var9 = a(var10000, a(var10001));
            switch (var10002) {
               case 0:
                  var5[var3++] = var9;
                  if ((var7 += var1) >= var4) {
                     a = var5;
                     String[] var10 = a;
                     PROP_HEADERS_TO_SKIP = a[5];
                     HEADERS_TO_SKIP_DEFAULT = var10[3];
                     String[] var8 = a;
                     HEADERS_NOT_TO_IMPLICITLY_FORWARD = Collections.unmodifiableList(
                        Functions.grep(
                           Functions.map(
                              CollectionUtils.list(ConfigFactory.getProperty(var8[0], var8[1]).split(var8[4])),
                              Functions.then(TextUtils.trim(), TextUtils.lower())
                           ),
                           TextUtils.isNotEmpty()
                        )
                     );
                     return;
                  }

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

                  var2 = "M[^Hj+\u0019@rG\u0019JZoGtK\u001cJF7_xK\rJW+@tZ\u0000\rY6\u001dY\\\u0000\u0014f9@b\\\u001c\u0016Y-Tyz\u0001\bS\u000bVe\u0006\u001c\u0001W<Vc[ \u000be3Za";
                  var4 = "M[^Hj+\u0019@rG\u0019JZoGtK\u001cJF7_xK\rJW+@tZ\u0000\rY6\u001dY\\\u0000\u0014f9@b\\\u001c\u0016Y-Tyz\u0001\bS\u000bVe\u0006\u001c\u0001W<Vc[ \u000be3Za"
                     .length();
                  var1 = 7;
                  var7 = -1;
            }

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

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

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

      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 -> 118;
            case 1 -> 79;
            case 2 -> 19;
            case 3 -> 3;
            case 4 -> 81;
            case 5 -> 63;
            default -> 84;
         });
      }

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