package ma;

import androidx.lifecycle.a0;
import androidx.lifecycle.f0;
import ca.canadapost.core.data.model.ResultWrapper;
import ca.canadapost.core.data.selfscan.api.ISelfScanApi;
import ca.canadapost.core.data.selfscan.api.ISelfScanTnCApi;
import ca.canadapost.core.data.selfscan.model.SelfScanRequest;
import ca.canadapost.core.data.selfscan.model.SelfScanTnCResponse;
import kotlin.jvm.internal.t;
import p9.h;
import rm.y;

/* loaded from: classes.dex */
public final class b implements ma.a {

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

    /* renamed from: b, reason: collision with root package name */
    private final ISelfScanTnCApi f28791b;

    /* renamed from: c, reason: collision with root package name */
    private final f0 f28792c;

    /* renamed from: d, reason: collision with root package name */
    private final a0 f28793d;

    /* renamed from: e, reason: collision with root package name */
    public h f28794e;

    /* 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 f28795p;

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

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

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

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            this.f28796q = obj;
            this.f28798s |= Integer.MIN_VALUE;
            return b.this.a(this);
        }
    }

    public b(ISelfScanApi qdApi, ISelfScanTnCApi qdTnCApi) {
        t.g(qdApi, "qdApi");
        t.g(qdTnCApi, "qdTnCApi");
        this.f28790a = qdApi;
        this.f28791b = qdTnCApi;
        f0 f0Var = new f0();
        this.f28792c = f0Var;
        this.f28793d = f0Var;
    }

    /* JADX WARN: Removed duplicated region for block: B:19:0x0035  */
    /* JADX WARN: Removed duplicated region for block: B:8:0x0023  */
    @Override // ma.a
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public Object a(vm.d dVar) {
        a aVar;
        Object f10;
        int i10;
        ResultWrapper resultWrapper;
        if (dVar instanceof a) {
            aVar = (a) dVar;
            int i11 = aVar.f28798s;
            if ((i11 & Integer.MIN_VALUE) != 0) {
                aVar.f28798s = i11 - Integer.MIN_VALUE;
                Object obj = aVar.f28796q;
                f10 = wm.d.f();
                i10 = aVar.f28798s;
                if (i10 != 0) {
                    y.b(obj);
                    SelfScanTnCResponse selfScanTnCResponse = (SelfScanTnCResponse) this.f28792c.f();
                    if (selfScanTnCResponse != null) {
                        return new ResultWrapper.Success(selfScanTnCResponse);
                    }
                    ISelfScanTnCApi iSelfScanTnCApi = this.f28791b;
                    aVar.f28795p = this;
                    aVar.f28798s = 1;
                    obj = iSelfScanTnCApi.getSelfScanTnC(aVar);
                    if (obj == f10) {
                        return f10;
                    }
                } else {
                    if (i10 != 1) {
                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                    }
                    this = (b) aVar.f28795p;
                    y.b(obj);
                }
                resultWrapper = (ResultWrapper) obj;
                if (!(resultWrapper instanceof ResultWrapper.Error) && (resultWrapper instanceof ResultWrapper.Success)) {
                    this.f28792c.n((SelfScanTnCResponse) ((ResultWrapper.Success) resultWrapper).getData());
                }
                return resultWrapper;
            }
        }
        aVar = new a(dVar);
        Object obj2 = aVar.f28796q;
        f10 = wm.d.f();
        i10 = aVar.f28798s;
        if (i10 != 0) {
        }
        resultWrapper = (ResultWrapper) obj2;
        if (!(resultWrapper instanceof ResultWrapper.Error)) {
            this.f28792c.n((SelfScanTnCResponse) ((ResultWrapper.Success) resultWrapper).getData());
        }
        return resultWrapper;
    }

    @Override // ma.a
    public a0 b() {
        return this.f28793d;
    }

    @Override // ma.a
    public Object trackReturn(SelfScanRequest selfScanRequest, vm.d dVar) {
        return this.f28790a.trackReturn(selfScanRequest, dVar);
    }
}
