package cc;

import android.app.Application;
import android.content.Context;
import ca.canadapost.core.data.model.ResultWrapper;
import ca.canadapost.core.data.profile.model.AMSPrerequisitesResponse;
import ca.canadapost.core.data.profile.model.SetForgetEmailPreferenceRequest;
import ca.canadapost.core.data.profile.model.SetForgetPreferenceResponse;
import l8.h;

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

    /* renamed from: c, reason: collision with root package name */
    private final p8.a f11415c;

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

    /* renamed from: e, reason: collision with root package name */
    private final g9.d f11417e;

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

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

    /* renamed from: h, reason: collision with root package name */
    private final androidx.lifecycle.f0 f11420h;

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

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

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

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

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

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

        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;
            f10 = wm.d.f();
            int i10 = this.f11426p;
            if (i10 == 0) {
                rm.y.b(obj);
                Boolean bool = (Boolean) d4.this.X().f();
                if (bool == null) {
                    bool = kotlin.coroutines.jvm.internal.b.a(false);
                }
                SetForgetEmailPreferenceRequest setForgetEmailPreferenceRequest = new SetForgetEmailPreferenceRequest(!bool.booleanValue());
                ka.b bVar = d4.this.f11416d;
                this.f11426p = 1;
                obj = bVar.r(setForgetEmailPreferenceRequest, this);
                if (obj == f10) {
                    return f10;
                }
            } else {
                if (i10 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                rm.y.b(obj);
            }
            ResultWrapper.Error error = (ResultWrapper.Error) obj;
            if (error != null) {
                d4.this.W(error, true);
            }
            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);
        }
    }

    /* loaded from: classes4.dex */
    static final class b extends kotlin.jvm.internal.v implements dn.l {

        /* renamed from: p, reason: collision with root package name */
        public static final b f11428p = new b();

        b() {
            super(1);
        }

        @Override // dn.l
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public final Boolean invoke(SetForgetPreferenceResponse setForgetPreferenceResponse) {
            Boolean emailPref;
            return Boolean.valueOf((setForgetPreferenceResponse == null || (emailPref = setForgetPreferenceResponse.getEmailPref()) == null) ? false : emailPref.booleanValue());
        }
    }

    /* loaded from: classes4.dex */
    static final class c extends kotlin.jvm.internal.v implements dn.l {
        c() {
            super(1);
        }

        @Override // dn.l
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public final Boolean invoke(AMSPrerequisitesResponse aMSPrerequisitesResponse) {
            Boolean status;
            boolean z10 = false;
            boolean booleanValue = (aMSPrerequisitesResponse == null || (status = aMSPrerequisitesResponse.getStatus()) == null) ? false : status.booleanValue();
            if (d4.this.f11417e.h() && booleanValue) {
                z10 = true;
            }
            return Boolean.valueOf(z10);
        }
    }

    /* JADX WARN: Illegal instructions before constructor call */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public d4(t7.c contextService, p8.a trackNotificationService, ka.b repository, g9.d sessionRepository) {
        super((Application) r0);
        kotlin.jvm.internal.t.g(contextService, "contextService");
        kotlin.jvm.internal.t.g(trackNotificationService, "trackNotificationService");
        kotlin.jvm.internal.t.g(repository, "repository");
        kotlin.jvm.internal.t.g(sessionRepository, "sessionRepository");
        Context a10 = contextService.a();
        kotlin.jvm.internal.t.e(a10, "null cannot be cast to non-null type android.app.Application");
        this.f11415c = trackNotificationService;
        this.f11416d = repository;
        this.f11417e = sessionRepository;
        this.f11418f = new l8.i(contextService);
        this.f11419g = new l8.d();
        androidx.lifecycle.f0 f0Var = new androidx.lifecycle.f0();
        this.f11420h = f0Var;
        this.f11421i = f0Var;
        l8.g gVar = new l8.g();
        this.f11422j = gVar;
        this.f11423k = gVar;
        this.f11424l = androidx.lifecycle.y0.a(repository.J(), new c());
        this.f11425m = androidx.lifecycle.y0.a(repository.H(), b.f11428p);
    }

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

    public final void S() {
        this.f11420h.q(Boolean.valueOf(this.f11415c.a()));
    }

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

    public final androidx.lifecycle.a0 U() {
        return this.f11423k;
    }

    public final androidx.lifecycle.a0 V() {
        return this.f11424l;
    }

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

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

    public final androidx.lifecycle.a0 Y() {
        return this.f11421i;
    }

    public final void Z() {
        this.f11422j.s();
    }

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

    @Override // l8.c
    public androidx.lifecycle.a0 t() {
        return this.f11419g.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.f11418f.u(m0Var, context, start, str, block);
    }
}
