package o;

import android.os.Handler;
import android.os.Looper;
import android.view.ActionMode;
import android.view.View;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.z5, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C3065z5 extends Sb0 implements OC {
    public final /* synthetic */ int p;
    public int q;
    public Object r;
    public final /* synthetic */ Object s;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public C3065z5(C0041Bp c0041Bp, InterfaceC0220Im interfaceC0220Im) {
        super(1, interfaceC0220Im);
        this.p = 2;
        this.s = c0041Bp;
    }

    @Override // o.OC
    public final Object g(Object obj) {
        InterfaceC0220Im interfaceC0220Im = (InterfaceC0220Im) obj;
        switch (this.p) {
            case 0:
                return new C3065z5((A5) this.r, (InterfaceC1589jd0) this.s, interfaceC0220Im, 0).n(Oh0.a);
            case 1:
                return new C3065z5((C2063od) this.r, (C1968nd) this.s, interfaceC0220Im, 1).n(Oh0.a);
            default:
                return new C3065z5((C0041Bp) this.s, interfaceC0220Im).n(Oh0.a);
        }
    }

    @Override // o.AbstractC0728ad
    public final Object n(Object obj) {
        ActionMode actionMode;
        C2780w5 c2780w5;
        Throwable th;
        AbstractC2912xa0 c1251g00;
        switch (this.p) {
            case 0:
                A5 a5 = (A5) this.r;
                J90 j90 = a5.e;
                View view = a5.a;
                int i = this.q;
                Oh0 oh0 = Oh0.a;
                try {
                    if (i == 0) {
                        IJ.H(obj);
                        C2875x5 c2875x5 = new C2875x5();
                        InterfaceC1589jd0 interfaceC1589jd0 = (InterfaceC1589jd0) this.s;
                        C2780w5 c2780w52 = new C2780w5(c2875x5, new C2495t5(a5, interfaceC1589jd0, 0), new C2495t5(a5, interfaceC1589jd0, 1), view);
                        OC oc = a5.b;
                        if (oc != null && (c2780w5 = (C2780w5) oc.g(c2780w52)) != null) {
                            c2780w52 = c2780w5;
                        }
                        Looper looperMyLooper = Looper.myLooper();
                        Handler handler = view.getHandler();
                        if (looperMyLooper != (handler != null ? handler.getLooper() : null)) {
                            RunnableC2970y5 runnableC2970y5 = a5.i;
                            if (runnableC2970y5 == null) {
                                runnableC2970y5 = new RunnableC2970y5(a5, c2780w52, c2875x5, 0);
                                a5.i = runnableC2970y5;
                            }
                            view.post(runnableC2970y5);
                        } else {
                            ActionMode actionModeStartActionMode = view.startActionMode(new ActionModeCallbackC1914mz(c2780w52), 1);
                            if (actionModeStartActionMode == null) {
                                return oh0;
                            }
                            a5.h = actionModeStartActionMode;
                        }
                        this.q = 1;
                        Object objA = c2875x5.a.a(this);
                        EnumC0091Dn enumC0091Dn = EnumC0091Dn.l;
                        if (objA != enumC0091Dn) {
                            objA = oh0;
                        }
                        if (objA == enumC0091Dn) {
                            return enumC0091Dn;
                        }
                    } else {
                        if (i != 1) {
                            throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                        }
                        IJ.H(obj);
                    }
                    if (actionMode != null) {
                        actionMode.finish();
                    }
                    RunnableC2970y5 runnableC2970y52 = a5.i;
                    if (runnableC2970y52 != null) {
                        view.removeCallbacks(runnableC2970y52);
                    }
                    a5.h = null;
                    return oh0;
                } finally {
                    j90.a();
                    actionMode = a5.h;
                    if (actionMode != null) {
                        actionMode.finish();
                    }
                    RunnableC2970y5 runnableC2970y53 = a5.i;
                    if (runnableC2970y53 != null) {
                        view.removeCallbacks(runnableC2970y53);
                    }
                    a5.h = null;
                }
            case 1:
                C1968nd c1968nd = (C1968nd) this.s;
                MV mv = ((C2063od) this.r).c;
                int i2 = this.q;
                Oh0 oh02 = Oh0.a;
                try {
                    if (i2 == 0) {
                        IJ.H(obj);
                        mv.setValue(c1968nd);
                        this.q = 1;
                        Object objA2 = c1968nd.b.a(this);
                        EnumC0091Dn enumC0091Dn2 = EnumC0091Dn.l;
                        if (objA2 != enumC0091Dn2) {
                            objA2 = oh02;
                        }
                        if (objA2 == enumC0091Dn2) {
                            return enumC0091Dn2;
                        }
                    } else {
                        if (i2 != 1) {
                            throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                        }
                        IJ.H(obj);
                    }
                    return oh02;
                } finally {
                    mv.setValue(null);
                }
            default:
                C0041Bp c0041Bp = (C0041Bp) this.s;
                int i3 = this.q;
                EnumC0091Dn enumC0091Dn3 = EnumC0091Dn.l;
                try {
                } catch (Throwable th2) {
                    InterfaceC1754lI interfaceC1754lIH = c0041Bp.h();
                    this.r = th2;
                    this.q = 2;
                    Object objD = interfaceC1754lIH.d(this);
                    if (objD == enumC0091Dn3) {
                        return enumC0091Dn3;
                    }
                    th = th2;
                    obj = objD;
                }
                if (i3 == 0) {
                    IJ.H(obj);
                    this.q = 1;
                    obj = C0041Bp.g(c0041Bp, true, this);
                    if (obj == enumC0091Dn3) {
                        return enumC0091Dn3;
                    }
                } else {
                    if (i3 != 1) {
                        if (i3 != 2) {
                            throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                        }
                        th = (Throwable) this.r;
                        IJ.H(obj);
                        c1251g00 = new C1251g00(((Number) obj).intValue(), th);
                        return new C3001yV(c1251g00, Boolean.TRUE);
                    }
                    IJ.H(obj);
                }
                c1251g00 = (AbstractC2912xa0) obj;
                return new C3001yV(c1251g00, Boolean.TRUE);
        }
    }

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public /* synthetic */ C3065z5(InterfaceC2254qd0 interfaceC2254qd0, Object obj, InterfaceC0220Im interfaceC0220Im, int i) {
        super(1, interfaceC0220Im);
        this.p = i;
        this.r = interfaceC2254qd0;
        this.s = obj;
    }
}
