package j4;

import T4.i;
import a.AbstractC0212a;
import i4.EnumC0643a;
import java.io.Serializable;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import r4.AbstractC0983h;

/* JADX INFO: renamed from: j4.a, reason: case insensitive filesystem */
/* JADX INFO: loaded from: classes.dex */
public abstract class AbstractC0799a implements h4.c, InterfaceC0802d, Serializable {
    private final h4.c completion;

    public AbstractC0799a(h4.c cVar) {
        this.completion = cVar;
    }

    public h4.c create(h4.c cVar) {
        AbstractC0983h.e("completion", cVar);
        throw new UnsupportedOperationException("create(Continuation) has not been overridden");
    }

    public InterfaceC0802d getCallerFrame() {
        h4.c cVar = this.completion;
        if (cVar instanceof InterfaceC0802d) {
            return (InterfaceC0802d) cVar;
        }
        return null;
    }

    public final h4.c getCompletion() {
        return this.completion;
    }

    public StackTraceElement getStackTraceElement() {
        int iIntValue;
        String strC;
        Method method;
        Object objInvoke;
        Method method2;
        Object objInvoke2;
        InterfaceC0803e interfaceC0803e = (InterfaceC0803e) getClass().getAnnotation(InterfaceC0803e.class);
        String str = null;
        if (interfaceC0803e == null) {
            return null;
        }
        int iV = interfaceC0803e.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 i = iIntValue >= 0 ? interfaceC0803e.l()[iIntValue] : -1;
        i iVar = AbstractC0804f.f8561b;
        i iVar2 = AbstractC0804f.f8560a;
        if (iVar == null) {
            try {
                i iVar3 = new i(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("name", new Class[0]));
                AbstractC0804f.f8561b = iVar3;
                iVar = iVar3;
            } catch (Exception unused2) {
                AbstractC0804f.f8561b = iVar2;
                iVar = iVar2;
            }
        }
        if (iVar != iVar2 && (method = iVar.f2879a) != null && (objInvoke = method.invoke(getClass(), new Object[0])) != null && (method2 = iVar.f2880b) != null && (objInvoke2 = method2.invoke(objInvoke, new Object[0])) != null) {
            Method method3 = iVar.f2881c;
            Object objInvoke3 = method3 != null ? method3.invoke(objInvoke2, new Object[0]) : null;
            if (objInvoke3 instanceof String) {
                str = (String) objInvoke3;
            }
        }
        if (str == null) {
            strC = interfaceC0803e.c();
        } else {
            strC = str + '/' + interfaceC0803e.c();
        }
        return new StackTraceElement(strC, interfaceC0803e.m(), interfaceC0803e.f(), i);
    }

    public abstract Object invokeSuspend(Object obj);

    @Override // h4.c
    public final void resumeWith(Object obj) {
        h4.c cVar = this;
        while (true) {
            AbstractC0799a abstractC0799a = (AbstractC0799a) cVar;
            h4.c cVar2 = abstractC0799a.completion;
            AbstractC0983h.b(cVar2);
            try {
                obj = abstractC0799a.invokeSuspend(obj);
                if (obj == EnumC0643a.f6670k) {
                    return;
                }
            } catch (Throwable th) {
                obj = AbstractC0212a.e(th);
            }
            abstractC0799a.releaseIntercepted();
            if (!(cVar2 instanceof AbstractC0799a)) {
                cVar2.resumeWith(obj);
                return;
            }
            cVar = cVar2;
        }
    }

    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 h4.c create(Object obj, h4.c cVar) {
        AbstractC0983h.e("completion", cVar);
        throw new UnsupportedOperationException("create(Any?;Continuation) has not been overridden");
    }

    public void releaseIntercepted() {
    }
}
