package C4;

import com.revenuecat.purchases.common.diagnostics.DiagnosticsEntry;
import java.io.Serializable;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import kotlin.jvm.internal.o;
import m3.AbstractC2467b;

/* JADX INFO: loaded from: classes3.dex */
public abstract class a implements A4.d, d, Serializable {
    private final A4.d completion;

    public a(A4.d dVar) {
        this.completion = dVar;
    }

    public A4.d create(A4.d completion) {
        o.h(completion, "completion");
        throw new UnsupportedOperationException("create(Continuation) has not been overridden");
    }

    @Override // C4.d
    public d getCallerFrame() {
        A4.d dVar = this.completion;
        if (dVar instanceof d) {
            return (d) dVar;
        }
        return null;
    }

    public final A4.d getCompletion() {
        return this.completion;
    }

    public StackTraceElement getStackTraceElement() {
        int iIntValue;
        String strC;
        Method method;
        Object objInvoke;
        Method method2;
        Object objInvoke2;
        e eVar = (e) getClass().getAnnotation(e.class);
        String str = null;
        if (eVar == null) {
            return null;
        }
        int iV = eVar.v();
        if (iV > 1) {
            throw new IllegalStateException(("Debug metadata version mismatch. Expected: 1, got " + iV + ". Please update the Kotlin standard library.").toString());
        }
        try {
            Field declaredField = getClass().getDeclaredField("label");
            declaredField.setAccessible(true);
            Object obj = declaredField.get(this);
            Integer num = obj instanceof Integer ? (Integer) obj : null;
            iIntValue = (num != null ? num.intValue() : 0) - 1;
        } catch (Exception unused) {
            iIntValue = -1;
        }
        int i6 = iIntValue >= 0 ? eVar.l()[iIntValue] : -1;
        f fVar = g.f745b;
        f fVar2 = g.f744a;
        if (fVar == null) {
            try {
                f fVar3 = new f(Class.class.getDeclaredMethod("getModule", new Class[0]), getClass().getClassLoader().loadClass("java.lang.Module").getDeclaredMethod("getDescriptor", new Class[0]), getClass().getClassLoader().loadClass("java.lang.module.ModuleDescriptor").getDeclaredMethod(DiagnosticsEntry.NAME_KEY, new Class[0]), 0);
                g.f745b = fVar3;
                fVar = fVar3;
            } catch (Exception unused2) {
                g.f745b = fVar2;
                fVar = fVar2;
            }
        }
        if (fVar != fVar2 && (method = (Method) fVar.f741b) != null && (objInvoke = method.invoke(getClass(), new Object[0])) != null && (method2 = (Method) fVar.f742c) != null && (objInvoke2 = method2.invoke(objInvoke, new Object[0])) != null) {
            Method method3 = (Method) fVar.f743d;
            Object objInvoke3 = method3 != null ? method3.invoke(objInvoke2, new Object[0]) : null;
            if (objInvoke3 instanceof String) {
                str = (String) objInvoke3;
            }
        }
        if (str == null) {
            strC = eVar.c();
        } else {
            strC = str + '/' + eVar.c();
        }
        return new StackTraceElement(strC, eVar.m(), eVar.f(), i6);
    }

    public abstract Object invokeSuspend(Object obj);

    @Override // A4.d
    public final void resumeWith(Object obj) {
        A4.d dVar = this;
        while (true) {
            a aVar = (a) dVar;
            A4.d dVar2 = aVar.completion;
            o.e(dVar2);
            try {
                obj = aVar.invokeSuspend(obj);
                if (obj == B4.a.f492a) {
                    return;
                }
            } catch (Throwable th) {
                obj = AbstractC2467b.d(th);
            }
            aVar.releaseIntercepted();
            if (!(dVar2 instanceof a)) {
                dVar2.resumeWith(obj);
                return;
            }
            dVar = dVar2;
        }
    }

    public String toString() {
        StringBuilder sb = new StringBuilder("Continuation at ");
        Object stackTraceElement = getStackTraceElement();
        if (stackTraceElement == null) {
            stackTraceElement = getClass().getName();
        }
        sb.append(stackTraceElement);
        return sb.toString();
    }

    public A4.d create(Object obj, A4.d completion) {
        o.h(completion, "completion");
        throw new UnsupportedOperationException("create(Any?;Continuation) has not been overridden");
    }

    public void releaseIntercepted() {
    }
}
