package com.l7tech.common.http.prov.apache.components;

import com.l7tech.common.http.GenericHttpException;
import com.l7tech.common.http.GenericHttpHeader;
import com.l7tech.common.http.GenericHttpHeaders;
import com.l7tech.common.http.GenericHttpResponse;
import com.l7tech.common.http.HttpHeader;
import com.l7tech.common.http.HttpHeaders;
import com.l7tech.common.mime.ContentTypeHeader;
import java.io.InputStream;
import java.util.ArrayList;
import org.apache.hc.client5.http.classic.methods.HttpUriRequestBase;
import org.apache.hc.core5.http.ClassicHttpResponse;
import org.apache.hc.core5.http.Header;

class c extends GenericHttpResponse {
   private final ClassicHttpResponse b;
   private HttpUriRequestBase c;
   final ClassicHttpResponse val$httpResponse;
   final ContentTypeHeader val$contentType;
   final Long val$contentLength;
   final e this$1;
   private static final String[] e;

   c(e var1, ClassicHttpResponse var2, ContentTypeHeader var3, Long var4) {
      this.this$1 = var1;
      this.val$httpResponse = var2;
      this.val$contentType = var3;
      this.val$contentLength = var4;
      this.b = this.val$httpResponse;
      this.c = this.this$1.a;
   }

   @Override
   public InputStream getInputStream() throws GenericHttpException {
      // $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/common/http/prov/apache/components/c.b Lorg/apache/hc/core5/http/ClassicHttpResponse;
      // 04: ifnonnull 18
      // 07: new java/lang/IllegalStateException
      // 0a: dup
      // 0b: getstatic com/l7tech/common/http/prov/apache/components/c.e [Ljava/lang/String;
      // 0e: bipush 5
      // 0f: aaload
      // 10: invokespecial java/lang/IllegalStateException.<init> (Ljava/lang/String;)V
      // 13: athrow
      // 14: invokestatic com/l7tech/common/http/prov/apache/components/c.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 17: athrow
      // 18: aload 0
      // 19: getfield com/l7tech/common/http/prov/apache/components/c.b Lorg/apache/hc/core5/http/ClassicHttpResponse;
      // 1c: invokeinterface org/apache/hc/core5/http/ClassicHttpResponse.getEntity ()Lorg/apache/hc/core5/http/HttpEntity; 1
      // 21: ifnonnull 2a
      // 24: aconst_null
      // 25: areturn
      // 26: invokestatic com/l7tech/common/http/prov/apache/components/c.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 29: athrow
      // 2a: aload 0
      // 2b: getfield com/l7tech/common/http/prov/apache/components/c.b Lorg/apache/hc/core5/http/ClassicHttpResponse;
      // 2e: invokeinterface org/apache/hc/core5/http/ClassicHttpResponse.getEntity ()Lorg/apache/hc/core5/http/HttpEntity; 1
      // 33: invokeinterface org/apache/hc/core5/http/HttpEntity.getContent ()Ljava/io/InputStream; 1
      // 38: astore 1
      // 39: aload 0
      // 3a: getfield com/l7tech/common/http/prov/apache/components/c.this$1 Lcom/l7tech/common/http/prov/apache/components/e;
      // 3d: getfield com/l7tech/common/http/prov/apache/components/e.this$0 Lcom/l7tech/common/http/prov/apache/components/HttpComponentsClient;
      // 40: invokevirtual com/l7tech/common/http/prov/apache/components/HttpComponentsClient.c ()Z
      // 43: ifeq 4f
      // 46: new com/l7tech/common/http/prov/apache/components/a
      // 49: dup
      // 4a: aload 1
      // 4b: invokespecial com/l7tech/common/http/prov/apache/components/a.<init> (Ljava/io/InputStream;)V
      // 4e: astore 1
      // 4f: aload 1
      // 50: areturn
      // 51: astore 1
      // 52: new com/l7tech/common/http/GenericHttpException
      // 55: dup
      // 56: aload 1
      // 57: invokespecial com/l7tech/common/http/GenericHttpException.<init> (Ljava/lang/Throwable;)V
      // 5a: athrow
      // try (0 -> 10): 10 java/io/IOException
      // try (12 -> 17): 37 java/io/IOException
      // try (12 -> 18): 18 java/lang/IllegalStateException
      // try (20 -> 36): 37 java/io/IOException
   }

   @Override
   public int getStatus() {
      return this.b.getCode();
   }

   @Override
   public HttpHeaders getHeaders() {
      try {
         if (this.b == null) {
            throw new IllegalStateException(e[3]);
         }
      } catch (IllegalStateException var7) {
         throw a(var7);
      }

      Header[] var1 = this.b.getHeaders();
      ArrayList var2 = new ArrayList();

      for (Header var6 : var1) {
         var2.add(new GenericHttpHeader(var6.getName(), var6.getValue()));
      }

      return new GenericHttpHeaders(var2.toArray(new HttpHeader[var2.size()]));
   }

   @Override
   public ContentTypeHeader getContentType() {
      return this.val$contentType;
   }

   @Override
   public Long getContentLength() {
      return this.val$contentLength;
   }

   @Override
   public void close() {
      // $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/common/http/prov/apache/components/c.this$1 Lcom/l7tech/common/http/prov/apache/components/e;
      // 04: getfield com/l7tech/common/http/prov/apache/components/e.this$0 Lcom/l7tech/common/http/prov/apache/components/HttpComponentsClient;
      // 07: invokevirtual com/l7tech/common/http/prov/apache/components/HttpComponentsClient.a ()V
      // 0a: aload 0
      // 0b: getfield com/l7tech/common/http/prov/apache/components/c.c Lorg/apache/hc/client5/http/classic/methods/HttpUriRequestBase;
      // 0e: invokevirtual org/apache/hc/client5/http/classic/methods/HttpUriRequestBase.isAborted ()Z
      // 11: ifne dc
      // 14: aload 0
      // 15: getfield com/l7tech/common/http/prov/apache/components/c.b Lorg/apache/hc/core5/http/ClassicHttpResponse;
      // 18: ifnull dc
      // 1b: goto 22
      // 1e: invokestatic com/l7tech/common/http/prov/apache/components/c.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 21: athrow
      // 22: aload 0
      // 23: getfield com/l7tech/common/http/prov/apache/components/c.b Lorg/apache/hc/core5/http/ClassicHttpResponse;
      // 26: invokeinterface org/apache/hc/core5/http/ClassicHttpResponse.getEntity ()Lorg/apache/hc/core5/http/HttpEntity; 1
      // 2b: ifnull dc
      // 2e: goto 35
      // 31: invokestatic com/l7tech/common/http/prov/apache/components/c.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 34: athrow
      // 35: aload 0
      // 36: getfield com/l7tech/common/http/prov/apache/components/c.b Lorg/apache/hc/core5/http/ClassicHttpResponse;
      // 39: invokeinterface org/apache/hc/core5/http/ClassicHttpResponse.getEntity ()Lorg/apache/hc/core5/http/HttpEntity; 1
      // 3e: invokeinterface org/apache/hc/core5/http/HttpEntity.getContent ()Ljava/io/InputStream; 1
      // 43: astore 1
      // 44: aload 1
      // 45: ifnull ca
      // 48: aload 1
      // 49: invokevirtual java/io/InputStream.read ()I
      // 4c: iflt b2
      // 4f: aload 0
      // 50: getfield com/l7tech/common/http/prov/apache/components/c.c Lorg/apache/hc/client5/http/classic/methods/HttpUriRequestBase;
      // 53: getstatic com/l7tech/common/http/prov/apache/components/c.e [Ljava/lang/String;
      // 56: astore 5
      // 58: aload 5
      // 5a: bipush 1
      // 5b: aaload
      // 5c: invokevirtual org/apache/hc/client5/http/classic/methods/HttpUriRequestBase.getFirstHeader (Ljava/lang/String;)Lorg/apache/hc/core5/http/Header;
      // 5f: astore 2
      // 60: aload 2
      // 61: ifnull ab
      // 64: aload 2
      // 65: invokeinterface org/apache/hc/core5/http/Header.getValue ()Ljava/lang/String; 1
      // 6a: astore 3
      // 6b: aload 3
      // 6c: ifnull 9a
      // 6f: aload 3
      // 70: invokevirtual java/lang/String.trim ()Ljava/lang/String;
      // 73: aload 5
      // 75: bipush 0
      // 76: aaload
      // 77: invokevirtual java/lang/String.startsWith (Ljava/lang/String;)Z
      // 7a: ifne a8
      // 7d: goto 84
      // 80: invokestatic com/l7tech/common/http/prov/apache/components/c.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 83: athrow
      // 84: aload 3
      // 85: invokevirtual java/lang/String.trim ()Ljava/lang/String;
      // 88: getstatic com/l7tech/common/http/prov/apache/components/c.e [Ljava/lang/String;
      // 8b: bipush 4
      // 8c: aaload
      // 8d: invokevirtual java/lang/String.startsWith (Ljava/lang/String;)Z
      // 90: ifne a8
      // 93: goto 9a
      // 96: invokestatic com/l7tech/common/http/prov/apache/components/c.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // 99: athrow
      // 9a: aload 0
      // 9b: getfield com/l7tech/common/http/prov/apache/components/c.c Lorg/apache/hc/client5/http/classic/methods/HttpUriRequestBase;
      // 9e: invokevirtual org/apache/hc/client5/http/classic/methods/HttpUriRequestBase.abort ()V
      // a1: goto a8
      // a4: invokestatic com/l7tech/common/http/prov/apache/components/c.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // a7: athrow
      // a8: goto b2
      // ab: aload 0
      // ac: getfield com/l7tech/common/http/prov/apache/components/c.c Lorg/apache/hc/client5/http/classic/methods/HttpUriRequestBase;
      // af: invokevirtual org/apache/hc/client5/http/classic/methods/HttpUriRequestBase.abort ()V
      // b2: aload 1
      // b3: invokevirtual java/io/InputStream.close ()V
      // b6: goto ca
      // b9: astore 2
      // ba: aload 1
      // bb: invokevirtual java/io/InputStream.close ()V
      // be: goto ca
      // c1: astore 4
      // c3: aload 1
      // c4: invokevirtual java/io/InputStream.close ()V
      // c7: aload 4
      // c9: athrow
      // ca: goto dc
      // cd: astore 1
      // ce: getstatic com/l7tech/common/http/prov/apache/components/HttpComponentsClient.b Ljava/util/logging/Logger;
      // d1: getstatic java/util/logging/Level.WARNING Ljava/util/logging/Level;
      // d4: getstatic com/l7tech/common/http/prov/apache/components/c.e [Ljava/lang/String;
      // d7: bipush 2
      // d8: aaload
      // d9: invokevirtual java/util/logging/Logger.log (Ljava/util/logging/Level;Ljava/lang/String;)V
      // dc: aload 0
      // dd: getfield com/l7tech/common/http/prov/apache/components/c.c Lorg/apache/hc/client5/http/classic/methods/HttpUriRequestBase;
      // e0: ifnull f6
      // e3: aload 0
      // e4: getfield com/l7tech/common/http/prov/apache/components/c.c Lorg/apache/hc/client5/http/classic/methods/HttpUriRequestBase;
      // e7: invokevirtual org/apache/hc/client5/http/classic/methods/HttpUriRequestBase.reset ()V
      // ea: aload 0
      // eb: aconst_null
      // ec: putfield com/l7tech/common/http/prov/apache/components/c.c Lorg/apache/hc/client5/http/classic/methods/HttpUriRequestBase;
      // ef: goto f6
      // f2: invokestatic com/l7tech/common/http/prov/apache/components/c.a (Ljava/lang/Exception;)Ljava/lang/Exception;
      // f5: athrow
      // f6: return
      // try (57 -> 70): 71 java/io/IOException
      // try (47 -> 64): 65 java/io/IOException
      // try (45 -> 54): 55 java/io/IOException
      // try (8 -> 18): 19 java/io/IOException
      // try (0 -> 11): 12 java/io/IOException
      // try (28 -> 77): 80 java/io/IOException
      // try (28 -> 77): 84 null
      // try (84 -> 85): 84 null
      // try (21 -> 89): 90 java/io/IOException
      // try (97 -> 106): 107 java/io/IOException
   }

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

   static {
      String[] var5 = new String[6];
      int var3 = 0;
      String var2 = "D\u0000$O\rK!\u001cjq\u0011'p5\u001ckq\r\u001f_:\t`r\u0006n~;Har\f=ot\u001agm\u0013!d'\r\"m\u0017<o5\u0005%^<\u0001q>\u0011+y$\u0007lm\u0006nb5\u001b\"\u007f\u000f<o5\f{>\u0001+o:Har\f=o0";
      int var4 = "D\u0000$O\rK!\u001cjq\u0011'p5\u001ckq\r\u001f_:\t`r\u0006n~;Har\f=ot\u001agm\u0013!d'\r\"m\u0017<o5\u0005%^<\u0001q>\u0011+y$\u0007lm\u0006nb5\u001b\"\u007f\u000f<o5\f{>\u0001+o:Har\f=o0"
         .length();
      char var1 = 4;
      int var7 = -1;

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

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

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

                  var2 = "6C}\u001f\u0018x]\fC%,Ns\u0003LcY\u000bVu\u001e\u001ft\u001c\u0010GiP\r}N\u001dG~\tLsY\u001dH:\u0013\u0000~O\u001dB";
                  var4 = "6C}\u001f\u0018x]\fC%,Ns\u0003LcY\u000bVu\u001e\u001ft\u001c\u0010GiP\r}N\u001dG~\tLsY\u001dH:\u0013\u0000~O\u001dB".length();
                  var1 = '\t';
                  var7 = -1;
            }

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

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

      return var10000;
   }

   private static String b(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 -> 7;
            case 1 -> 89;
            case 2 -> 101;
            case 3 -> 15;
            case 4 -> 19;
            case 5 -> 110;
            default -> 67;
         });
      }

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