content: package okhttp3;
  
  import java.nio.charset.Charset;
  import java.util.ArrayList;
  import java.util.List;
  import java.util.Locale;
  import java.util.regex.Matcher;
  import java.util.regex.Pattern;
  import kotlin.Deprecated;
  import kotlin.DeprecationLevel;
  import kotlin.Metadata;
  import kotlin.ReplaceWith;
  import kotlin.collections.ArraysKt;
  import kotlin.jvm.JvmStatic;
  import kotlin.jvm.internal.DefaultConstructorMarker;
  import kotlin.jvm.internal.Intrinsics;
  import kotlin.ranges.IntProgression;
  import kotlin.ranges.RangesKt;
  import kotlin.text.StringsKt;
  import kotlin.text.Typography;
  
  @Metadata(bv = {1, 0, 3}, d1 = {"\u00002\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0003\n\u0002\u0010\u0011\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0010\b\n\u0002\b\u0007\u0018\u0000 \u00182\u00020\u0001:\u0001\u0018B-\b\u0002\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u0012\u0006\u0010\u0004\u001a\u00020\u0003\u0012\u0006\u0010\u0005\u001a\u00020\u0003\u0012\f\u0010\u0006\u001a\b\u0012\u0004\u0012\u00020\u00030\u0007¢\u0006\u0002\u0010\bJ\u0016\u0010\u000b\u001a\u0004\u0018\u00010\f2\n\b\u0002\u0010\r\u001a\u0004\u0018\u00010\fH\u0007J\u0013\u0010\u000e\u001a\u00020\u000f2\b\u0010\u0010\u001a\u0004\u0018\u00010\u0001H\u0002J\b\u0010\u0011\u001a\u00020\u0012H\u0016J\u0010\u0010\u0013\u001a\u0004\u0018\u00010\u00032\u0006\u0010\u0014\u001a\u00020\u0003J\r\u0010\u0005\u001a\u00020\u0003H\u0007¢\u0006\u0002\b\u0015J\b\u0010\u0016\u001a\u00020\u0003H\u0016J\r\u0010\u0004\u001a\u00020\u0003H\u0007¢\u0006\u0002\b\u0017R\u000e\u0010\u0002\u001a\u00020\u0003X\u0004¢\u0006\u0002\n\u0000R\u0016\u0010\u0006\u001a\b\u0012\u0004\u0012\u00020\u00030\u0007X\u0004¢\u0006\u0004\n\u0002\u0010\tR\u0013\u0010\u0005\u001a\u00020\u00038\u0007¢\u0006\b\n\u0000\u001a\u0004\b\u0005\u0010\nR\u0013\u0010\u0004\u001a\u00020\u00038\u0007¢\u0006\b\n\u0000\u001a\u0004\b\u0004\u0010\n¨\u0006\u0019"}, d2 = {"Lokhttp3/MediaType;", "", "mediaType", "", "type", "subtype", "parameterNamesAndValues", "", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)V", "[Ljava/lang/String;", "()Ljava/lang/String;", "charset", "Ljava/nio/charset/Charset;", "defaultValue", "equals", "", "other", "hashCode", "", "parameter", "name", "-deprecated_subtype", "toString", "-deprecated_type", "Companion", "okhttp"}, k = 1, mv = {1, 4, 0})
  /* compiled from: MediaType.kt */
  public final class MediaType {
      public static final Companion Companion = new Companion((DefaultConstructorMarker) null);
      /* access modifiers changed from: private */
      public static final Pattern PARAMETER = Pattern.compile(";\\s*(?:([a-zA-Z0-9-!#$%&'*+.^_`{|}~]+)=(?:([a-zA-Z0-9-!#$%&'*+.^_`{|}~]+)|\"([^\"]*)\"))?");
      private static final String QUOTED = "\"([^\"]*)\"";
      private static final String TOKEN = "([a-zA-Z0-9-!#$%&'*+.^_`{|}~]+)";
      /* access modifiers changed from: private */
      public static final Pattern TYPE_SUBTYPE = Pattern.compile("([a-zA-Z0-9-!#$%&'*+.^_`{|}~]+)/([a-zA-Z0-9-!#$%&'*+.^_`{|}~]+)");
      private final String mediaType;
      private final String[] parameterNamesAndValues;
      private final String subtype;
      private final String type;
  
      @Metadata(bv = {1, 0, 3}, d1 = {"\u0000$\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0007\b\u0003\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002J\u0015\u0010\n\u001a\u00020\u000b2\u0006\u0010\f\u001a\u00020\u0007H\u0007¢\u0006\u0002\b\rJ\u0017\u0010\u000e\u001a\u0004\u0018\u00010\u000b2\u0006\u0010\f\u001a\u00020\u0007H\u0007¢\u0006\u0002\b\u000fJ\u0011\u0010\u0010\u001a\u00020\u000b*\u00020\u0007H\u0007¢\u0006\u0002\b\nJ\u0013\u0010\u0011\u001a\u0004\u0018\u00010\u000b*\u00020\u0007H\u0007¢\u0006\u0002\b\u000eR\u0016\u0010\u0003\u001a\n \u0005*\u0004\u0018\u00010\u00040\u0004X\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0006\u001a\u00020\u0007XT¢\u0006\u0002\n\u0000R\u000e\u0010\b\u001a\u00020\u0007XT¢\u0006\u0002\n\u0000R\u0016\u0010\t\u001a\n \u0005*\u0004\u0018\u00010\u00040\u0004X\u0004¢\u0006\u0002\n\u0000¨\u0006\u0012"}, d2 = {"Lokhttp3/MediaType$Companion;", "", "()V", "PARAMETER", "Ljava/util/regex/Pattern;", "kotlin.jvm.PlatformType", "QUOTED", "", "TOKEN", "TYPE_SUBTYPE", "get", "Lokhttp3/MediaType;", "mediaType", "-deprecated_get", "parse", "-deprecated_parse", "toMediaType", "toMediaTypeOrNull", "okhttp"}, k = 1, mv = {1, 4, 0})
      /* compiled from: MediaType.kt */
      public static final class Companion {
          private Companion() {
          }
  
          public /* synthetic */ Companion(DefaultConstructorMarker $constructor_marker) {
              this();
          }
  
          @Deprecated(level = DeprecationLevel.ERROR, message = "moved to extension function", replaceWith = @ReplaceWith(expression = "mediaType.toMediaType()", imports = {"okhttp3.MediaType.Companion.toMediaType"}))
          /* renamed from: -deprecated_get  reason: not valid java name */
          public final MediaType m1666deprecated_get(String mediaType) {
              Intrinsics.checkNotNullParameter(mediaType, "mediaType");
              return get(mediaType);
          }
  
          @Deprecated(level = DeprecationLevel.ERROR, message = "moved to extension function", replaceWith = @ReplaceWith(expression = "mediaType.toMediaTypeOrNull()", imports = {"okhttp3.MediaType.Companion.toMediaTypeOrNull"}))
          /* renamed from: -deprecated_parse  reason: not valid java name */
          public final MediaType m1667deprecated_parse(String mediaType) {
              Intrinsics.checkNotNullParameter(mediaType, "mediaType");
              return parse(mediaType);
          }
  
          @JvmStatic
          public final MediaType get(String $this$toMediaType) {
              String str;
              String str2 = $this$toMediaType;
              Intrinsics.checkNotNullParameter(str2, "$this$toMediaType");
              Matcher matcher = MediaType.TYPE_SUBTYPE.matcher(str2);
              if (matcher.lookingAt()) {
                  String group = matcher.group(1);
                  Intrinsics.checkNotNullExpressionValue(group, "typeSubtype.group(1)");
                  Locale locale = Locale.US;
                  Intrinsics.checkNotNullExpressionValue(locale, "Locale.US");
                  if (group != null) {
                      String lowerCase = group.toLowerCase(locale);
                      Intrinsics.checkNotNullExpressionValue(lowerCase, "(this as java.lang.String).toLowerCase(locale)");
                      String group2 = matcher.group(2);
                      Intrinsics.checkNotNullExpressionValue(group2, "typeSubtype.group(2)");
                      Locale locale2 = Locale.US;
                      Intrinsics.checkNotNullExpressionValue(locale2, "Locale.US");
                      if (group2 != null) {
                          String lowerCase2 = group2.toLowerCase(locale2);
                          Intrinsics.checkNotNullExpressionValue(lowerCase2, "(this as java.lang.String).toLowerCase(locale)");
                          String str3 = lowerCase2;
                          List arrayList = new ArrayList();
                          Matcher matcher2 = MediaType.PARAMETER.matcher(str2);
                          int end = matcher.end();
                          while (end < $this$toMediaType.length()) {
                              matcher2.region(end, $this$toMediaType.length());
                              if (matcher2.lookingAt()) {
                                  String group3 = matcher2.group(1);
                                  if (group3 == null) {
                                      end = matcher2.end();
                                  } else {
                                      String group4 = matcher2.group(2);
                                      if (group4 == null) {
                                          str = matcher2.group(3);
                                      } else if (!StringsKt.startsWith$default(group4, "'", false, 2, (Object) null) || !StringsKt.endsWith$default(group4, "'", false, 2, (Object) null) || group4.length() <= 2) {
                                          str = group4;
                                      } else {
                                          str = group4.substring(1, group4.length() - 1);
                                          Intrinsics.checkNotNullExpressionValue(str, "(this as java.lang.Strin…ing(startIndex, endIndex)");
                                      }
                                      arrayList.add(group3);
                                      arrayList.add(str);
                                      end = matcher2.end();
                                  }
                              } else {
                                  StringBuilder append = new StringBuilder().append("Parameter is not formatted correctly: \"");
                                  String substring = str2.substring(end);
                                  Intrinsics.checkNotNullExpressionValue(substring, "(this as java.lang.String).substring(startIndex)");
                                  throw new IllegalArgumentException(append.append(substring).append("\" for: \"").append(str2).append(Typography.quote).toString().toString());
                              }
                          }
                          Object[] array = arrayList.toArray(new String[0]);
                          if (array != null) {
                              return new MediaType($this$toMediaType, lowerCase, str3, (String[]) array, (DefaultConstructorMarker) null);
                          }
                          throw new NullPointerException("null cannot be cast to non-null type kotlin.Array<T>");
                      }
                      throw new NullPointerException("null cannot be cast to non-null type java.lang.String");
                  }
                  throw new NullPointerException("null cannot be cast to non-null type java.lang.String");
              }
              throw new IllegalArgumentException(("No subtype found for: \"" + str2 + Typography.quote).toString());
          }
  
          @JvmStatic
          public final MediaType parse(String $this$toMediaTypeOrNull) {
              Intrinsics.checkNotNullParameter($this$toMediaTypeOrNull, "$this$toMediaTypeOrNull");
              try {
                  return get($this$toMediaTypeOrNull);
              } catch (IllegalArgumentException e) {
                  return null;
              }
          }
      }
  
      private MediaType(String mediaType2, String type2, String subtype2, String[] parameterNamesAndValues2) {
          this.mediaType = mediaType2;
          this.type = type2;
          this.subtype = subtype2;
          this.parameterNamesAndValues = parameterNamesAndValues2;
      }
  
      public /* synthetic */ MediaType(String mediaType2, String type2, String subtype2, String[] parameterNamesAndValues2, DefaultConstructorMarker $constructor_marker) {
          this(mediaType2, type2, subtype2, parameterNamesAndValues2);
      }
  
      public static /* synthetic */ Charset charset$default(MediaType mediaType2, Charset charset, int i, Object obj) {
          if ((i & 1) != 0) {
              charset = null;
              Charset charset2 = null;
          }
          return mediaType2.charset(charset);
      }
  
      @JvmStatic
      public static final MediaType get(String str) {
          return Companion.get(str);
      }
  
      @JvmStatic
      public static final MediaType parse(String str) {
          return Companion.parse(str);
      }
  
      @Deprecated(level = DeprecationLevel.ERROR, message = "moved to val", replaceWith = @ReplaceWith(expression = "subtype", imports = {}))
      /* renamed from: -deprecated_subtype  reason: not valid java name */
      public final String m1664deprecated_subtype() {
          return this.subtype;
      }
  
      @Deprecated(level = DeprecationLevel.ERROR, message = "moved to val", replaceWith = @ReplaceWith(expression = "type", imports = {}))
      /* renamed from: -deprecated_type  reason: not valid java name */
      public final String m1665deprecated_type() {
          return this.type;
      }
  
      public final Charset charset() {
          return charset$default(this, (Charset) null, 1, (Object) null);
      }
  
      public final Charset charset(Charset defaultValue) {
          String parameter = parameter("charset");
          if (parameter == null) {
              return defaultValue;
          }
          try {
              return Charset.forName(parameter);
          } catch (IllegalArgumentException e) {
              return defaultValue;
          }
      }
  
      public boolean equals(Object other) {
          return (other instanceof MediaType) && Intrinsics.areEqual((Object) ((MediaType) other).mediaType, (Object) this.mediaType);
      }
  
      public int hashCode() {
          return this.mediaType.hashCode();
      }
  
      public final String parameter(String name) {
          Intrinsics.checkNotNullParameter(name, "name");
          IntProgression step = RangesKt.step((IntProgression) ArraysKt.getIndices((T[]) this.parameterNamesAndValues), 2);
          int first = step.getFirst();
          int last = step.getLast();
          int step2 = step.getStep();
          if (step2 >= 0) {
              if (first > last) {
                  return null;
              }
          } else if (first < last) {
              return null;
          }
          while (!StringsKt.equals(this.parameterNamesAndValues[first], name, true)) {
              if (first == last) {
                  return null;
              }
              first += step2;
          }
          return this.parameterNamesAndValues[first + 1];
      }
  
      public final String subtype() {
          return this.subtype;
      }
  
      public String toString() {
          return this.mediaType;
      }
  
      public final String type() {
          return this.type;
      }
  }
  