content: package kotlinx.coroutines.internal;
  
  import kotlin.Metadata;
  import kotlin.coroutines.CoroutineContext;
  import kotlin.coroutines.EmptyCoroutineContext;
  import kotlin.jvm.functions.Function2;
  import kotlin.jvm.internal.Intrinsics;
  import kotlinx.coroutines.ThreadContextElement;
  
  @Metadata(d1 = {"\u0000<\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0004\n\u0002\u0010\u000e\n\u0002\b\u0003\b\u0000\u0018\u0000*\u0004\b\u0000\u0010\u00012\b\u0012\u0004\u0012\u0002H\u00010\u0002B\u001b\u0012\u0006\u0010\u0003\u001a\u00028\u0000\u0012\f\u0010\u0004\u001a\b\u0012\u0004\u0012\u00028\u00000\u0005¢\u0006\u0002\u0010\u0006J(\u0010\f\u001a\u0004\u0018\u0001H\r\"\b\b\u0001\u0010\r*\u00020\u000e2\f\u0010\u0007\u001a\b\u0012\u0004\u0012\u0002H\r0\bH\u0002¢\u0006\u0002\u0010\u000fJ\u0014\u0010\u0010\u001a\u00020\u00112\n\u0010\u0007\u001a\u0006\u0012\u0002\b\u00030\bH\u0016J\u001d\u0010\u0012\u001a\u00020\u00132\u0006\u0010\u0014\u001a\u00020\u00112\u0006\u0010\u0015\u001a\u00028\u0000H\u0016¢\u0006\u0002\u0010\u0016J\b\u0010\u0017\u001a\u00020\u0018H\u0016J\u0015\u0010\u0019\u001a\u00028\u00002\u0006\u0010\u0014\u001a\u00020\u0011H\u0016¢\u0006\u0002\u0010\u001aR\u0018\u0010\u0007\u001a\u0006\u0012\u0002\b\u00030\bX\u0004¢\u0006\b\n\u0000\u001a\u0004\b\t\u0010\nR\u0014\u0010\u0004\u001a\b\u0012\u0004\u0012\u00028\u00000\u0005X\u0004¢\u0006\u0002\n\u0000R\u0010\u0010\u0003\u001a\u00028\u0000X\u0004¢\u0006\u0004\n\u0002\u0010\u000b¨\u0006\u001b"}, d2 = {"Lkotlinx/coroutines/internal/ThreadLocalElement;", "T", "Lkotlinx/coroutines/ThreadContextElement;", "value", "threadLocal", "Ljava/lang/ThreadLocal;", "(Ljava/lang/Object;Ljava/lang/ThreadLocal;)V", "key", "Lkotlin/coroutines/CoroutineContext$Key;", "getKey", "()Lkotlin/coroutines/CoroutineContext$Key;", "Ljava/lang/Object;", "get", "E", "Lkotlin/coroutines/CoroutineContext$Element;", "(Lkotlin/coroutines/CoroutineContext$Key;)Lkotlin/coroutines/CoroutineContext$Element;", "minusKey", "Lkotlin/coroutines/CoroutineContext;", "restoreThreadContext", "", "context", "oldState", "(Lkotlin/coroutines/CoroutineContext;Ljava/lang/Object;)V", "toString", "", "updateThreadContext", "(Lkotlin/coroutines/CoroutineContext;)Ljava/lang/Object;", "kotlinx-coroutines-core"}, k = 1, mv = {1, 6, 0}, xi = 48)
  /* compiled from: ThreadContext.kt */
  public final class ThreadLocalElement<T> implements ThreadContextElement<T> {
      private final CoroutineContext.Key<?> key;
      private final ThreadLocal<T> threadLocal;
      private final T value;
  
      public ThreadLocalElement(T value2, ThreadLocal<T> threadLocal2) {
          this.value = value2;
          this.threadLocal = threadLocal2;
          this.key = new ThreadLocalKey(threadLocal2);
      }
  
      public <R> R fold(R initial, Function2<? super R, ? super CoroutineContext.Element, ? extends R> operation) {
          return ThreadContextElement.DefaultImpls.fold(this, initial, operation);
      }
  
      public <E extends CoroutineContext.Element> E get(CoroutineContext.Key<E> key2) {
          if (Intrinsics.areEqual((Object) getKey(), (Object) key2)) {
              return this;
          }
          return null;
      }
  
      public CoroutineContext.Key<?> getKey() {
          return this.key;
      }
  
      public CoroutineContext minusKey(CoroutineContext.Key<?> key2) {
          return Intrinsics.areEqual((Object) getKey(), (Object) key2) ? EmptyCoroutineContext.INSTANCE : this;
      }
  
      public CoroutineContext plus(CoroutineContext context) {
          return ThreadContextElement.DefaultImpls.plus(this, context);
      }
  
      public void restoreThreadContext(CoroutineContext context, T oldState) {
          this.threadLocal.set(oldState);
      }
  
      public String toString() {
          return "ThreadLocal(value=" + this.value + ", threadLocal = " + this.threadLocal + ')';
      }
  
      public T updateThreadContext(CoroutineContext context) {
          T t = this.threadLocal.get();
          this.threadLocal.set(this.value);
          return t;
      }
  }
  