package com.l7tech.gateway.api.impl;

import com.l7tech.gateway.api.ManagedObject;
import com.l7tech.util.ConfigFactory;
import com.sun.ws.management.client.EnumerationCtx;
import com.sun.ws.management.client.Resource;
import com.sun.ws.management.client.ResourceFactory;
import com.sun.ws.management.client.exceptions.FaultException;
import jakarta.xml.bind.JAXBException;
import jakarta.xml.soap.SOAPException;
import java.io.Closeable;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.xml.datatype.DatatypeConfigurationException;
import org.dmtf.schemas.wbem.wsman._1.wsman.SelectorSetType;

final class j<IMO extends ManagedObject> implements Iterator<IMO>, Closeable {
   private final String a;
   private final String b;
   private final Class<IMO> c;
   private final int d;
   private final ResourceTracker e;
   private final ResourceFactory f;
   private final int g;
   private final List<IMO> h;
   private EnumerationCtx i;
   private boolean j;
   private static final String k;

   @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/gateway/api/impl/j.h Ljava/util/List;
      // 04: invokeinterface java/util/List.isEmpty ()Z 1
      // 09: ifeq 1f
      // 0c: aload 0
      // 0d: getfield com/l7tech/gateway/api/impl/j.j Z
      // 10: ifne 1f
      // 13: goto 17
      // 16: athrow
      // 17: aload 0
      // 18: invokevirtual com/l7tech/gateway/api/impl/j.a ()V
      // 1b: goto 1f
      // 1e: athrow
      // 1f: aload 0
      // 20: getfield com/l7tech/gateway/api/impl/j.h Ljava/util/List;
      // 23: invokeinterface java/util/List.isEmpty ()Z 1
      // 28: ifne 30
      // 2b: bipush 1
      // 2c: goto 31
      // 2f: athrow
      // 30: bipush 0
      // 31: ireturn
      // try (0 -> 7): 8 java/util/NoSuchElementException
      // try (4 -> 11): 12 java/util/NoSuchElementException
      // try (13 -> 19): 19 java/util/NoSuchElementException
   }

   public IMO next() {
      // $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/gateway/api/impl/j.h Ljava/util/List;
      // 04: invokeinterface java/util/List.isEmpty ()Z 1
      // 09: ifeq 1f
      // 0c: aload 0
      // 0d: getfield com/l7tech/gateway/api/impl/j.j Z
      // 10: ifne 1f
      // 13: goto 17
      // 16: athrow
      // 17: aload 0
      // 18: invokevirtual com/l7tech/gateway/api/impl/j.a ()V
      // 1b: goto 1f
      // 1e: athrow
      // 1f: aload 0
      // 20: getfield com/l7tech/gateway/api/impl/j.h Ljava/util/List;
      // 23: invokeinterface java/util/List.isEmpty ()Z 1
      // 28: ifeq 34
      // 2b: new java/util/NoSuchElementException
      // 2e: dup
      // 2f: invokespecial java/util/NoSuchElementException.<init> ()V
      // 32: athrow
      // 33: athrow
      // 34: aload 0
      // 35: getfield com/l7tech/gateway/api/impl/j.h Ljava/util/List;
      // 38: bipush 0
      // 39: invokeinterface java/util/List.remove (I)Ljava/lang/Object; 2
      // 3e: checkcast com/l7tech/gateway/api/ManagedObject
      // 41: astore 1
      // 42: aload 1
      // 43: areturn
      // try (0 -> 7): 8 java/util/NoSuchElementException
      // try (4 -> 11): 12 java/util/NoSuchElementException
      // try (13 -> 21): 21 java/util/NoSuchElementException
   }

   @Override
   public void remove() {
      throw new UnsupportedOperationException();
   }

   @Override
   public void close() throws IOException {
      if (!this.j) {
         try {
            Resource var1 = this.f.find(this.a, this.b, this.d, (SelectorSetType)null)[0];

            try {
               if (this.i != null) {
                  var1.release(this.i);
               }
            } catch (DatatypeConfigurationException var2) {
               throw var2;
            }

            this.j = true;
            this.i = null;
         } catch (DatatypeConfigurationException var3) {
            throw new IOException(var3);
         } catch (FaultException var4) {
            throw new IOException(var4);
         } catch (JAXBException var5) {
            throw new IOException(var5);
         } catch (SOAPException var6) {
            throw new IOException(var6);
         }
      }
   }

   private j(String var1, String var2, int var3, Class<IMO> var4, ResourceTracker var5, ResourceFactory var6) {
      this.g = ConfigFactory.getIntProperty(k, 10);
      this.h = new ArrayList<>(this.g);
      this.j = false;
      this.a = var1;
      this.b = var2;
      this.c = var4;
      this.d = var3;
      this.e = var5;
      this.f = var6;
      var5.registerCloseable(this);
   }

   private void a() {
      // $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:
      // 000: aload 0
      // 001: getfield com/l7tech/gateway/api/impl/j.j Z
      // 004: ifne 102
      // 007: aload 0
      // 008: getfield com/l7tech/gateway/api/impl/j.f Lcom/sun/ws/management/client/ResourceFactory;
      // 00b: aload 0
      // 00c: getfield com/l7tech/gateway/api/impl/j.a Ljava/lang/String;
      // 00f: aload 0
      // 010: getfield com/l7tech/gateway/api/impl/j.b Ljava/lang/String;
      // 013: aload 0
      // 014: getfield com/l7tech/gateway/api/impl/j.d I
      // 017: i2l
      // 018: aconst_null
      // 019: checkcast org/dmtf/schemas/wbem/wsman/_1/wsman/SelectorSetType
      // 01c: invokevirtual com/sun/ws/management/client/ResourceFactory.find (Ljava/lang/String;Ljava/lang/String;JLorg/dmtf/schemas/wbem/wsman/_1/wsman/SelectorSetType;)[Lcom/sun/ws/management/client/Resource;
      // 01f: bipush 0
      // 020: aaload
      // 021: astore 1
      // 022: aload 0
      // 023: getfield com/l7tech/gateway/api/impl/j.i Lcom/sun/ws/management/client/EnumerationCtx;
      // 026: ifnonnull 03c
      // 029: aload 0
      // 02a: aload 1
      // 02b: aconst_null
      // 02c: aconst_null
      // 02d: aconst_null
      // 02e: bipush 0
      // 02f: bipush 1
      // 030: invokeinterface com/sun/ws/management/client/Resource.enumerate (Ljava/lang/Object;Ljava/util/Map;Ljava/lang/String;ZZ)Lcom/sun/ws/management/client/EnumerationCtx; 6
      // 035: putfield com/l7tech/gateway/api/impl/j.i Lcom/sun/ws/management/client/EnumerationCtx;
      // 038: goto 03c
      // 03b: athrow
      // 03c: aload 1
      // 03d: aload 0
      // 03e: getfield com/l7tech/gateway/api/impl/j.i Lcom/sun/ws/management/client/EnumerationCtx;
      // 041: aload 0
      // 042: getfield com/l7tech/gateway/api/impl/j.d I
      // 045: aload 0
      // 046: getfield com/l7tech/gateway/api/impl/j.g I
      // 049: bipush 0
      // 04a: bipush 0
      // 04b: invokeinterface com/sun/ws/management/client/Resource.pullItems (Lcom/sun/ws/management/client/EnumerationCtx;IIIZ)Ljava/util/List; 6
      // 050: astore 2
      // 051: aload 2
      // 052: invokeinterface java/util/List.iterator ()Ljava/util/Iterator; 1
      // 057: astore 3
      // 058: aload 3
      // 059: invokeinterface java/util/Iterator.hasNext ()Z 1
      // 05e: ifeq 08d
      // 061: aload 3
      // 062: invokeinterface java/util/Iterator.next ()Ljava/lang/Object; 1
      // 067: checkcast com/sun/ws/management/server/EnumerationItem
      // 06a: astore 4
      // 06c: aload 0
      // 06d: getfield com/l7tech/gateway/api/impl/j.h Ljava/util/List;
      // 070: aload 4
      // 072: invokevirtual com/sun/ws/management/server/EnumerationItem.getItem ()Ljava/lang/Object;
      // 075: checkcast org/w3c/dom/Element
      // 078: invokeinterface org/w3c/dom/Element.getOwnerDocument ()Lorg/w3c/dom/Document; 1
      // 07d: aload 0
      // 07e: getfield com/l7tech/gateway/api/impl/j.c Ljava/lang/Class;
      // 081: invokestatic com/l7tech/gateway/api/ManagedObjectFactory.read (Lorg/w3c/dom/Document;Ljava/lang/Class;)Lcom/l7tech/gateway/api/ManagedObject;
      // 084: invokeinterface java/util/List.add (Ljava/lang/Object;)Z 2
      // 089: pop
      // 08a: goto 058
      // 08d: aload 1
      // 08e: invokeinterface com/sun/ws/management/client/Resource.isEndOfSequence ()Z 1
      // 093: ifne 0a6
      // 096: aload 0
      // 097: getfield com/l7tech/gateway/api/impl/j.h Ljava/util/List;
      // 09a: invokeinterface java/util/List.isEmpty ()Z 1
      // 09f: ifeq 0bc
      // 0a2: goto 0a6
      // 0a5: athrow
      // 0a6: aload 0
      // 0a7: bipush 1
      // 0a8: putfield com/l7tech/gateway/api/impl/j.j Z
      // 0ab: aload 0
      // 0ac: aconst_null
      // 0ad: putfield com/l7tech/gateway/api/impl/j.i Lcom/sun/ws/management/client/EnumerationCtx;
      // 0b0: aload 0
      // 0b1: getfield com/l7tech/gateway/api/impl/j.e Lcom/l7tech/gateway/api/impl/ResourceTracker;
      // 0b4: aload 0
      // 0b5: invokevirtual com/l7tech/gateway/api/impl/ResourceTracker.unregisterCloseable (Ljava/io/Closeable;)V
      // 0b8: goto 0bc
      // 0bb: athrow
      // 0bc: goto 102
      // 0bf: astore 1
      // 0c0: new com/l7tech/gateway/api/Accessor$AccessorRuntimeException
      // 0c3: dup
      // 0c4: aload 1
      // 0c5: invokespecial com/l7tech/gateway/api/Accessor$AccessorRuntimeException.<init> (Ljava/lang/Throwable;)V
      // 0c8: athrow
      // 0c9: astore 1
      // 0ca: new com/l7tech/gateway/api/Accessor$AccessorSOAPFaultException
      // 0cd: dup
      // 0ce: aload 1
      // 0cf: invokespecial com/l7tech/gateway/api/Accessor$AccessorSOAPFaultException.<init> (Lcom/sun/ws/management/client/exceptions/FaultException;)V
      // 0d2: athrow
      // 0d3: astore 1
      // 0d4: new com/l7tech/gateway/api/Accessor$AccessorRuntimeException
      // 0d7: dup
      // 0d8: aload 1
      // 0d9: invokespecial com/l7tech/gateway/api/Accessor$AccessorRuntimeException.<init> (Ljava/lang/Throwable;)V
      // 0dc: athrow
      // 0dd: astore 1
      // 0de: new com/l7tech/gateway/api/Accessor$AccessorRuntimeException
      // 0e1: dup
      // 0e2: aload 1
      // 0e3: invokespecial com/l7tech/gateway/api/Accessor$AccessorRuntimeException.<init> (Ljava/lang/Throwable;)V
      // 0e6: athrow
      // 0e7: astore 1
      // 0e8: aload 1
      // 0e9: invokestatic com/l7tech/gateway/api/impl/c.a (Ljava/io/IOException;)Z
      // 0ec: ifeq 0f9
      // 0ef: new com/l7tech/gateway/api/Accessor$AccessorNetworkException
      // 0f2: dup
      // 0f3: aload 1
      // 0f4: invokespecial com/l7tech/gateway/api/Accessor$AccessorNetworkException.<init> (Ljava/lang/Throwable;)V
      // 0f7: athrow
      // 0f8: athrow
      // 0f9: new com/l7tech/gateway/api/Accessor$AccessorRuntimeException
      // 0fc: dup
      // 0fd: aload 1
      // 0fe: invokespecial com/l7tech/gateway/api/Accessor$AccessorRuntimeException.<init> (Ljava/lang/Throwable;)V
      // 101: athrow
      // 102: return
      // try (68 -> 84): 85 javax/xml/datatype/DatatypeConfigurationException
      // try (65 -> 72): 73 javax/xml/datatype/DatatypeConfigurationException
      // try (18 -> 30): 31 javax/xml/datatype/DatatypeConfigurationException
      // try (3 -> 86): 87 javax/xml/datatype/DatatypeConfigurationException
      // try (3 -> 86): 93 com/sun/ws/management/client/exceptions/FaultException
      // try (3 -> 86): 99 jakarta/xml/bind/JAXBException
      // try (3 -> 86): 105 jakarta/xml/soap/SOAPException
      // try (3 -> 86): 111 java/io/IOException
      // try (112 -> 120): 120 javax/xml/datatype/DatatypeConfigurationException
   }

   static {
      String var10002 = a(a("<t_\u001c\n<c:xZ\u001c\u0001jc:lSKHjg65W\\\u0013fr-zF[\teU>oQZ5bm:"));
      byte var10001 = -1;
      k = var10002;
   }

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

      return var10000;
   }

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

      for (int var1 = 0; var10000 > var1; var1++) {
         var10001[var1] = (char)(var10001[var1] ^ switch (var1 % 7) {
            case 0 -> 95;
            case 1 -> 27;
            case 2 -> 50;
            case 3 -> 50;
            case 4 -> 102;
            case 5 -> 11;
            default -> 23;
         });
      }

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