package g9;

import ca.canadapost.core.data.model.ResultWrapper;
import ca.canadapost.core.data.profile.api.IOAuthApi;
import ca.canadapost.core.services.models.EpostOAuthLoginResponse;

/* loaded from: classes.dex */
public final class m implements g {

    /* renamed from: a, reason: collision with root package name */
    private final IOAuthApi f19189a;

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes.dex */
    public static final class a extends kotlin.coroutines.jvm.internal.d {

        /* renamed from: p, reason: collision with root package name */
        Object f19190p;

        /* renamed from: q, reason: collision with root package name */
        /* synthetic */ Object f19191q;

        /* renamed from: s, reason: collision with root package name */
        int f19193s;

        a(vm.d dVar) {
            super(dVar);
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            this.f19191q = obj;
            this.f19193s |= Integer.MIN_VALUE;
            return m.this.a(null, null, this);
        }
    }

    public m(IOAuthApi oAuthApi) {
        kotlin.jvm.internal.t.g(oAuthApi, "oAuthApi");
        this.f19189a = oAuthApi;
    }

    private final EpostOAuthLoginResponse b(ResultWrapper resultWrapper) {
        if (resultWrapper instanceof ResultWrapper.Success) {
            return (EpostOAuthLoginResponse) ((ResultWrapper.Success) resultWrapper).getData();
        }
        if (resultWrapper instanceof ResultWrapper.Error) {
            return null;
        }
        throw new rm.t();
    }

    /* JADX WARN: Removed duplicated region for block: B:15:0x0036  */
    /* JADX WARN: Removed duplicated region for block: B:8:0x0024  */
    @Override // g9.g
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public Object a(String str, String str2, vm.d dVar) {
        a aVar;
        Object f10;
        int i10;
        if (dVar instanceof a) {
            aVar = (a) dVar;
            int i11 = aVar.f19193s;
            if ((i11 & Integer.MIN_VALUE) != 0) {
                aVar.f19193s = i11 - Integer.MIN_VALUE;
                a aVar2 = aVar;
                Object obj = aVar2.f19191q;
                f10 = wm.d.f();
                i10 = aVar2.f19193s;
                if (i10 != 0) {
                    rm.y.b(obj);
                    IOAuthApi iOAuthApi = this.f19189a;
                    aVar2.f19190p = this;
                    aVar2.f19193s = 1;
                    obj = IOAuthApi.a.a(iOAuthApi, str, str2, null, null, null, aVar2, 28, null);
                    if (obj == f10) {
                        return f10;
                    }
                } else {
                    if (i10 != 1) {
                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                    }
                    this = (m) aVar2.f19190p;
                    rm.y.b(obj);
                }
                return this.b((ResultWrapper) obj);
            }
        }
        aVar = new a(dVar);
        a aVar22 = aVar;
        Object obj2 = aVar22.f19191q;
        f10 = wm.d.f();
        i10 = aVar22.f19193s;
        if (i10 != 0) {
        }
        return this.b((ResultWrapper) obj2);
    }
}
