content: package kotlin.coroutines.jvm.internal;
  
  import java.lang.reflect.Field;
  import java.util.ArrayList;
  import kotlin.Metadata;
  import kotlin.jvm.internal.Intrinsics;
  
  @Metadata(d1 = {"\u00000\n\u0000\n\u0002\u0010\b\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0011\n\u0002\u0010\u000e\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\u001a\u0018\u0010\u0002\u001a\u00020\u00032\u0006\u0010\u0004\u001a\u00020\u00012\u0006\u0010\u0005\u001a\u00020\u0001H\u0002\u001a\u000e\u0010\u0006\u001a\u0004\u0018\u00010\u0007*\u00020\bH\u0002\u001a\f\u0010\t\u001a\u00020\u0001*\u00020\bH\u0002\u001a\u0019\u0010\n\u001a\n\u0012\u0004\u0012\u00020\f\u0018\u00010\u000b*\u00020\bH\u0001¢\u0006\u0002\u0010\r\u001a\u0013\u0010\u000e\u001a\u0004\u0018\u00010\u000f*\u00020\bH\u0001¢\u0006\u0002\b\u0010\"\u000e\u0010\u0000\u001a\u00020\u0001XT¢\u0006\u0002\n\u0000¨\u0006\u0011"}, d2 = {"COROUTINES_DEBUG_METADATA_VERSION", "", "checkDebugMetadataVersion", "", "expected", "actual", "getDebugMetadataAnnotation", "Lkotlin/coroutines/jvm/internal/DebugMetadata;", "Lkotlin/coroutines/jvm/internal/BaseContinuationImpl;", "getLabel", "getSpilledVariableFieldMapping", "", "", "(Lkotlin/coroutines/jvm/internal/BaseContinuationImpl;)[Ljava/lang/String;", "getStackTraceElementImpl", "Ljava/lang/StackTraceElement;", "getStackTraceElement", "kotlin-stdlib"}, k = 2, mv = {1, 7, 1}, xi = 48)
  /* compiled from: DebugMetadata.kt */
  public final class DebugMetadataKt {
      private static final int COROUTINES_DEBUG_METADATA_VERSION = 1;
  
      private static final void checkDebugMetadataVersion(int expected, int actual) {
          if (actual > expected) {
              throw new IllegalStateException(("Debug metadata version mismatch. Expected: " + expected + ", got " + actual + ". Please update the Kotlin standard library.").toString());
          }
      }
  
      private static final DebugMetadata getDebugMetadataAnnotation(BaseContinuationImpl $this$getDebugMetadataAnnotation) {
          return (DebugMetadata) $this$getDebugMetadataAnnotation.getClass().getAnnotation(DebugMetadata.class);
      }
  
      private static final int getLabel(BaseContinuationImpl $this$getLabel) {
          try {
              Field declaredField = $this$getLabel.getClass().getDeclaredField("label");
              declaredField.setAccessible(true);
              Object obj = declaredField.get($this$getLabel);
              Integer num = obj instanceof Integer ? (Integer) obj : null;
              return (num != null ? num.intValue() : 0) - 1;
          } catch (Exception e) {
              return -1;
          }
      }
  
      public static final String[] getSpilledVariableFieldMapping(BaseContinuationImpl $this$getSpilledVariableFieldMapping) {
          Intrinsics.checkNotNullParameter($this$getSpilledVariableFieldMapping, "<this>");
          DebugMetadata debugMetadataAnnotation = getDebugMetadataAnnotation($this$getSpilledVariableFieldMapping);
          if (debugMetadataAnnotation == null) {
              return null;
          }
          checkDebugMetadataVersion(1, debugMetadataAnnotation.v());
          ArrayList arrayList = new ArrayList();
          int label = getLabel($this$getSpilledVariableFieldMapping);
          int[] i = debugMetadataAnnotation.i();
          int length = i.length;
          for (int i2 = 0; i2 < length; i2++) {
              int i3 = i2;
              if (i[i2] == label) {
                  arrayList.add(debugMetadataAnnotation.s()[i3]);
                  arrayList.add(debugMetadataAnnotation.n()[i3]);
              }
          }
          Object[] array = arrayList.toArray(new String[0]);
          Intrinsics.checkNotNull(array, "null cannot be cast to non-null type kotlin.Array<T of kotlin.collections.ArraysKt__ArraysJVMKt.toTypedArray>");
          return (String[]) array;
      }
  
      public static final StackTraceElement getStackTraceElement(BaseContinuationImpl $this$getStackTraceElementImpl) {
          Intrinsics.checkNotNullParameter($this$getStackTraceElementImpl, "<this>");
          DebugMetadata debugMetadataAnnotation = getDebugMetadataAnnotation($this$getStackTraceElementImpl);
          if (debugMetadataAnnotation == null) {
              return null;
          }
          checkDebugMetadataVersion(1, debugMetadataAnnotation.v());
          int label = getLabel($this$getStackTraceElementImpl);
          int i = label < 0 ? -1 : debugMetadataAnnotation.l()[label];
          String moduleName = ModuleNameRetriever.INSTANCE.getModuleName($this$getStackTraceElementImpl);
          return new StackTraceElement(moduleName == null ? debugMetadataAnnotation.c() : moduleName + '/' + debugMetadataAnnotation.c(), debugMetadataAnnotation.m(), debugMetadataAnnotation.f(), i);
      }
  }
  