package kotlinx.coroutines.internal;

import p012d1.InterfaceC0633f;
import p036l1.InterfaceC1436p;
import p039m1.AbstractC1471h;
import p039m1.C1470g;
import p060t1.InterfaceC1684i1;

/* renamed from: kotlinx.coroutines.internal.a0 */
/* loaded from: classes.dex */
public final class C1352a0 {

    /* renamed from: a */
    public static final C1384w f3012a = new C1384w("NO_THREAD_ELEMENTS");

    /* renamed from: b */
    public static final InterfaceC1436p<Object, InterfaceC0633f.InterfaceC0636b, Object> f3013b = C1353a.f3016e;

    /* renamed from: c */
    public static final InterfaceC1436p<InterfaceC1684i1<?>, InterfaceC0633f.InterfaceC0636b, InterfaceC1684i1<?>> f3014c = C1354b.f3017e;

    /* renamed from: d */
    public static final InterfaceC1436p<C1361d0, InterfaceC0633f.InterfaceC0636b, C1361d0> f3015d = C1355c.f3018e;

    /* renamed from: kotlinx.coroutines.internal.a0$a */
    /* loaded from: classes.dex */
    public static final class C1353a extends AbstractC1471h implements InterfaceC1436p<Object, InterfaceC0633f.InterfaceC0636b, Object> {

        /* renamed from: e */
        public static final C1353a f3016e = new C1353a();

        public C1353a() {
            super(2);
        }

        @Override // p036l1.InterfaceC1436p
        /* renamed from: c */
        public final Object mo1385b(Object obj, InterfaceC0633f.InterfaceC0636b interfaceC0636b) {
            if (interfaceC0636b instanceof InterfaceC1684i1) {
                Integer num = obj instanceof Integer ? (Integer) obj : null;
                int intValue = num == null ? 1 : num.intValue();
                return intValue == 0 ? interfaceC0636b : Integer.valueOf(intValue + 1);
            }
            return obj;
        }
    }

    /* renamed from: kotlinx.coroutines.internal.a0$b */
    /* loaded from: classes.dex */
    public static final class C1354b extends AbstractC1471h implements InterfaceC1436p<InterfaceC1684i1<?>, InterfaceC0633f.InterfaceC0636b, InterfaceC1684i1<?>> {

        /* renamed from: e */
        public static final C1354b f3017e = new C1354b();

        public C1354b() {
            super(2);
        }

        @Override // p036l1.InterfaceC1436p
        /* renamed from: c */
        public final InterfaceC1684i1<?> mo1385b(InterfaceC1684i1<?> interfaceC1684i1, InterfaceC0633f.InterfaceC0636b interfaceC0636b) {
            if (interfaceC1684i1 != null) {
                return interfaceC1684i1;
            }
            if (interfaceC0636b instanceof InterfaceC1684i1) {
                return (InterfaceC1684i1) interfaceC0636b;
            }
            return null;
        }
    }

    /* renamed from: kotlinx.coroutines.internal.a0$c */
    /* loaded from: classes.dex */
    public static final class C1355c extends AbstractC1471h implements InterfaceC1436p<C1361d0, InterfaceC0633f.InterfaceC0636b, C1361d0> {

        /* renamed from: e */
        public static final C1355c f3018e = new C1355c();

        public C1355c() {
            super(2);
        }

        @Override // p036l1.InterfaceC1436p
        /* renamed from: c */
        public final C1361d0 mo1385b(C1361d0 c1361d0, InterfaceC0633f.InterfaceC0636b interfaceC0636b) {
            if (interfaceC0636b instanceof InterfaceC1684i1) {
                InterfaceC1684i1<?> interfaceC1684i1 = (InterfaceC1684i1) interfaceC0636b;
                c1361d0.m1546a(interfaceC1684i1, interfaceC1684i1.m575l(c1361d0.f3028a));
            }
            return c1361d0;
        }
    }

    /* renamed from: a */
    public static final void m1571a(InterfaceC0633f interfaceC0633f, Object obj) {
        if (obj == f3012a) {
            return;
        }
        if (obj instanceof C1361d0) {
            ((C1361d0) obj).m1545b(interfaceC0633f);
            return;
        }
        Object fold = interfaceC0633f.fold(null, f3014c);
        if (fold == null) {
            throw new NullPointerException("null cannot be cast to non-null type kotlinx.coroutines.ThreadContextElement<kotlin.Any?>");
        }
        ((InterfaceC1684i1) fold).m576b(interfaceC0633f, obj);
    }

    /* renamed from: b */
    public static final Object m1570b(InterfaceC0633f interfaceC0633f) {
        Object fold = interfaceC0633f.fold(0, f3013b);
        C1470g.m1295b(fold);
        return fold;
    }

    /* renamed from: c */
    public static final Object m1569c(InterfaceC0633f interfaceC0633f, Object obj) {
        if (obj == null) {
            obj = m1570b(interfaceC0633f);
        }
        return obj == 0 ? f3012a : obj instanceof Integer ? interfaceC0633f.fold(new C1361d0(interfaceC0633f, ((Number) obj).intValue()), f3015d) : ((InterfaceC1684i1) obj).m575l(interfaceC0633f);
    }
}