package com.l7tech.policy.assertion;

import com.l7tech.policy.assertion.composite.CompositeAssertion;
import java.util.ArrayList;
import java.util.Collections;
import java.util.EmptyStackException;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.Stack;

final class c implements Iterator<Assertion> {
   private Stack a = new Stack();
   private Assertion b = null;
   private static final String[] c;

   public c(final Assertion param1, Assertion nullx) {
      ArrayList var3 = new ArrayList(1);
      var3.add(nullx);
      this.a.push(var3.iterator());
   }

   @Override
   public boolean hasNext() {
      // $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/c.a Ljava/util/Stack;
      // 04: invokevirtual java/util/Stack.empty ()Z
      // 07: ifne 2b
      // 0a: aload 0
      // 0b: getfield com/l7tech/policy/assertion/c.a Ljava/util/Stack;
      // 0e: invokevirtual java/util/Stack.peek ()Ljava/lang/Object;
      // 11: checkcast java/util/Iterator
      // 14: invokeinterface java/util/Iterator.hasNext ()Z 1
      // 19: ifeq 2b
      // 1c: goto 23
      // 1f: invokestatic com/l7tech/policy/assertion/c.a (Ljava/lang/RuntimeException;)Ljava/lang/RuntimeException;
      // 22: athrow
      // 23: bipush 1
      // 24: goto 2c
      // 27: invokestatic com/l7tech/policy/assertion/c.a (Ljava/lang/RuntimeException;)Ljava/lang/RuntimeException;
      // 2a: athrow
      // 2b: bipush 0
      // 2c: ireturn
      // try (0 -> 10): 11 java/util/EmptyStackException
      // try (4 -> 15): 15 java/util/EmptyStackException
   }

   public Assertion next() {
      Iterator var1;
      try {
         var1 = (Iterator)this.a.peek();
      } catch (EmptyStackException var5) {
         throw new NoSuchElementException();
      }

      Assertion var2 = (Assertion)var1.next();
      Iterator var3 = Collections.EMPTY_LIST.iterator();
      if (this.a(var2)) {
         var3 = ((CompositeAssertion)var2).getChildren().iterator();
      }

      try {
         if (!var1.hasNext()) {
            this.a.pop();
         }
      } catch (EmptyStackException var4) {
         throw a(var4);
      }

      try {
         if (var3.hasNext()) {
            this.a.push(var3);
         }
      } catch (EmptyStackException var6) {
         throw a(var6);
      }

      this.b = var2;
      return var2;
   }

   @Override
   public void remove() throws UnsupportedOperationException, IllegalStateException {
      try {
         if (this.b == null) {
            throw new IllegalStateException();
         }
      } catch (UnsupportedOperationException var9) {
         throw a(var9);
      }

      CompositeAssertion var1 = this.b.getParent();

      try {
         if (var1 == null) {
            throw new UnsupportedOperationException(c[0]);
         }
      } catch (UnsupportedOperationException var6) {
         throw a(var6);
      }

      try {
         if (this.a(this.b)) {
            this.a.pop();
         }
      } catch (UnsupportedOperationException var8) {
         throw a(var8);
      }

      ArrayList var2 = new ArrayList<>(var1.getChildren());
      boolean var3 = false;
      Iterator var4 = var2.iterator();

      while (var4.hasNext()) {
         if (this.b.equals(var4.next())) {
            var4.remove();
            var3 = true;
            break;
         }
      }

      try {
         if (!var3) {
            throw new IllegalStateException(c[1] + this.b);
         }
      } catch (UnsupportedOperationException var5) {
         throw a(var5);
      }

      try {
         var1.setChildren(var2);
         if (var4.hasNext()) {
            this.a.pop();
            this.a.push(var4);
         }
      } catch (UnsupportedOperationException var7) {
         throw a(var7);
      }

      this.b = null;
   }

   private boolean a(Assertion 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: instanceof com/l7tech/policy/assertion/composite/CompositeAssertion
      // 04: ifeq 25
      // 07: aload 1
      // 08: checkcast com/l7tech/policy/assertion/composite/CompositeAssertion
      // 0b: invokevirtual com/l7tech/policy/assertion/composite/CompositeAssertion.getChildren ()Ljava/util/List;
      // 0e: invokeinterface java/util/List.size ()I 1
      // 13: ifle 25
      // 16: goto 1d
      // 19: invokestatic com/l7tech/policy/assertion/c.a (Ljava/lang/RuntimeException;)Ljava/lang/RuntimeException;
      // 1c: athrow
      // 1d: bipush 1
      // 1e: goto 26
      // 21: invokestatic com/l7tech/policy/assertion/c.a (Ljava/lang/RuntimeException;)Ljava/lang/RuntimeException;
      // 24: athrow
      // 25: bipush 0
      // 26: ireturn
      // try (0 -> 8): 9 java/util/EmptyStackException
      // try (3 -> 13): 13 java/util/EmptyStackException
   }

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

   static {
      String[] var5 = new String[2];
      int var3 = 0;
      String var2 = "awf}\u0000|Lpse|\u0019mLpygg\u001aMtbv\f|Lo\u007f{`\u0006f\u000b\"\u007ff3\u001fi\u001egx|)O";
      int var4 = "awf}\u0000|Lpse|\u0019mLpygg\u001aMtbv\f|Lo\u007f{`\u0006f\u000b\"\u007ff3\u001fi\u001egx|)O".length();
      char var1 = 18;
      int var0 = -1;

      while (true) {
         String var10002 = a(103, a(var2.substring(++var0, var0 + var1)));
         byte var10001 = -1;
         var5[var3++] = var10002;
         if ((var0 += var1) >= var4) {
            c = 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] ^ 11);
      }

      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 -> 101;
            case 1 -> 113;
            case 2 -> 111;
            case 3 -> 116;
            case 4 -> 8;
            case 5 -> 111;
            default -> 11;
         });
      }

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