package cc;

import android.app.Application;
import android.content.Context;
import ca.canadapost.core.data.aws.model.AndroidDeviceType;
import ca.canadapost.core.data.model.RepositoryError;
import ca.canadapost.core.data.model.ResultWrapper;
import ca.canadapost.core.data.profile.model.OneToOneEmailRequest;
import l8.h;

/* loaded from: classes4.dex */
public final class u extends androidx.lifecycle.b implements l8.h, l8.c {

    /* renamed from: c, reason: collision with root package name */
    private final t7.c f11818c;

    /* renamed from: d, reason: collision with root package name */
    private final ka.c f11819d;

    /* renamed from: e, reason: collision with root package name */
    private final ca.b f11820e;

    /* renamed from: f, reason: collision with root package name */
    private final String f11821f;

    /* renamed from: g, reason: collision with root package name */
    private final /* synthetic */ l8.i f11822g;

    /* renamed from: h, reason: collision with root package name */
    private final /* synthetic */ l8.d f11823h;

    /* renamed from: i, reason: collision with root package name */
    private final l8.g f11824i;

    /* renamed from: j, reason: collision with root package name */
    private final androidx.lifecycle.a0 f11825j;

    /* renamed from: k, reason: collision with root package name */
    private final l8.g f11826k;

    /* renamed from: l, reason: collision with root package name */
    private final androidx.lifecycle.a0 f11827l;

    /* loaded from: classes4.dex */
    static final class a extends kotlin.coroutines.jvm.internal.l implements dn.p {

        /* renamed from: p, reason: collision with root package name */
        int f11828p;

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

        @Override // kotlin.coroutines.jvm.internal.a
        public final vm.d create(Object obj, vm.d dVar) {
            return new a(dVar);
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            Object f10;
            Object U;
            f10 = wm.d.f();
            int i10 = this.f11828p;
            if (i10 == 0) {
                rm.y.b(obj);
                AndroidDeviceType androidDeviceType = AndroidDeviceType.MOBILE;
                String T = u.this.T();
                String c10 = u.this.U().c();
                kotlin.jvm.internal.t.f(c10, "getLanguage(...)");
                OneToOneEmailRequest oneToOneEmailRequest = new OneToOneEmailRequest(T, c10, new OneToOneEmailRequest.OneToOneEmailAnalytics(androidDeviceType, null, null, null, null, null, null, 126, null));
                ka.c cVar = u.this.f11819d;
                this.f11828p = 1;
                U = cVar.U(oneToOneEmailRequest, this);
                if (U == f10) {
                    return f10;
                }
            } else {
                if (i10 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                rm.y.b(obj);
                U = obj;
            }
            ResultWrapper.Error error = (ResultWrapper.Error) U;
            if (error == null) {
                u.this.f11824i.s();
            } else if (error.getError() == RepositoryError.ServiceError) {
                u.this.f11826k.s();
            } else if (error.getError() == RepositoryError.NoNetworkError) {
                u.this.V(new ResultWrapper.Error(error.getException(), error.getMessage(), error.getError(), null, 8, null), true);
            } else {
                u.this.f11826k.s();
            }
            return rm.n0.f34904a;
        }

        @Override // dn.p
        public final Object invoke(tp.m0 m0Var, vm.d dVar) {
            return ((a) create(m0Var, dVar)).invokeSuspend(rm.n0.f34904a);
        }
    }

    /* JADX WARN: Illegal instructions before constructor call */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public u(t7.c contextService, ka.c profileRepository, ca.b languageService, String email) {
        super((Application) r0);
        kotlin.jvm.internal.t.g(contextService, "contextService");
        kotlin.jvm.internal.t.g(profileRepository, "profileRepository");
        kotlin.jvm.internal.t.g(languageService, "languageService");
        kotlin.jvm.internal.t.g(email, "email");
        Context a10 = contextService.a();
        kotlin.jvm.internal.t.e(a10, "null cannot be cast to non-null type android.app.Application");
        this.f11818c = contextService;
        this.f11819d = profileRepository;
        this.f11820e = languageService;
        this.f11821f = email;
        this.f11822g = new l8.i(contextService);
        this.f11823h = new l8.d();
        l8.g gVar = new l8.g();
        this.f11824i = gVar;
        this.f11825j = gVar;
        l8.g gVar2 = new l8.g();
        this.f11826k = gVar2;
        this.f11827l = gVar2;
    }

    @Override // l8.h
    public androidx.lifecycle.a0 J() {
        return this.f11822g.J();
    }

    public final String T() {
        return this.f11821f;
    }

    public final ca.b U() {
        return this.f11820e;
    }

    public void V(ResultWrapper.Error error, boolean z10) {
        kotlin.jvm.internal.t.g(error, "error");
        this.f11823h.a(error, z10);
    }

    public final androidx.lifecycle.a0 W() {
        return this.f11825j;
    }

    public final androidx.lifecycle.a0 X() {
        return this.f11827l;
    }

    public final void Y() {
        h.a.a(this, androidx.lifecycle.a1.a(this), null, null, null, new a(null), 7, null);
    }

    @Override // l8.c
    public androidx.lifecycle.a0 o() {
        return this.f11823h.o();
    }

    @Override // l8.c
    public androidx.lifecycle.a0 t() {
        return this.f11823h.t();
    }

    @Override // l8.h
    public tp.u1 u(tp.m0 m0Var, vm.g context, tp.o0 start, String str, dn.p block) {
        kotlin.jvm.internal.t.g(m0Var, "<this>");
        kotlin.jvm.internal.t.g(context, "context");
        kotlin.jvm.internal.t.g(start, "start");
        kotlin.jvm.internal.t.g(block, "block");
        return this.f11822g.u(m0Var, context, start, str, block);
    }
}
