package qd;

import android.app.Application;
import android.content.Context;
import androidx.lifecycle.a0;
import androidx.lifecycle.a1;
import androidx.lifecycle.f0;
import ca.canadapost.core.data.model.Event;
import ca.canadapost.core.data.model.ResultWrapper;
import d9.f;
import l8.h;
import rm.n0;
import rm.y;
import tp.m0;
import tp.o0;
import tp.u1;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes4.dex */
    public static final class a extends kotlin.coroutines.jvm.internal.l implements dn.p {

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

        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.f33662p;
            if (i10 == 0) {
                y.b(obj);
                rd.c cVar = w.this.f33647d;
                String str = (String) w.this.V().f();
                if (str == null) {
                    str = "";
                }
                this.f33662p = 1;
                obj = cVar.b(str, this);
                if (obj == f10) {
                    return f10;
                }
            } else {
                if (i10 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                y.b(obj);
            }
            ResultWrapper resultWrapper = (ResultWrapper) obj;
            if (resultWrapper instanceof ResultWrapper.Success) {
                w.this.f33647d.a();
                w.this.f33655l.n(w.this.f33647d.getUsername().f());
                w.this.f33654k.n(new Event(kotlin.coroutines.jvm.internal.b.a(true)));
            } else if (resultWrapper instanceof ResultWrapper.Error) {
                ResultWrapper.Error error = (ResultWrapper.Error) resultWrapper;
                w.this.Z(new ResultWrapper.Error(error.getException(), error.getMessage(), error.getError(), null, 8, null), true);
            }
            return n0.f34904a;
        }

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

    /* JADX WARN: Illegal instructions before constructor call */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public w(t7.c contextService, rd.c repository, d9.f analyticsService) {
        super((Application) r0);
        kotlin.jvm.internal.t.g(contextService, "contextService");
        kotlin.jvm.internal.t.g(repository, "repository");
        kotlin.jvm.internal.t.g(analyticsService, "analyticsService");
        Context a10 = contextService.a();
        kotlin.jvm.internal.t.e(a10, "null cannot be cast to non-null type android.app.Application");
        this.f33646c = contextService;
        this.f33647d = repository;
        this.f33648e = new l8.i(contextService);
        this.f33649f = new l8.d();
        f0 f0Var = new f0();
        this.f33650g = f0Var;
        f0 f0Var2 = new f0();
        this.f33651h = f0Var2;
        f0 f0Var3 = new f0();
        this.f33652i = f0Var3;
        f0 f0Var4 = new f0();
        this.f33653j = f0Var4;
        f0 f0Var5 = new f0();
        this.f33654k = f0Var5;
        f0 f0Var6 = new f0();
        this.f33655l = f0Var6;
        this.f33656m = f0Var;
        this.f33657n = new f0();
        this.f33658o = f0Var3;
        this.f33659p = f0Var4;
        this.f33660q = f0Var5;
        this.f33661r = f0Var6;
        f.a.c(analyticsService, "UserForgotPWStep3", null, 2, null);
        f0Var.q(contextService.getString(ld.m.f27983g0));
        Boolean bool = Boolean.FALSE;
        f0Var3.q(bool);
        f0Var4.q(Boolean.TRUE);
        f0Var2.q(bool);
    }

    private final void b0() {
        h.a.a(this, a1.a(this), null, null, null, new a(null), 7, null);
    }

    private final boolean d0() {
        f0 f0Var = this.f33652i;
        CharSequence charSequence = (CharSequence) this.f33657n.f();
        f0Var.q(Boolean.valueOf(charSequence == null || charSequence.length() == 0));
        kotlin.jvm.internal.t.d(this.f33652i.f());
        return !((Boolean) r3).booleanValue();
    }

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

    public final a0 T() {
        return this.f33659p;
    }

    public final a0 U() {
        return this.f33658o;
    }

    public final f0 V() {
        return this.f33657n;
    }

    public final a0 W() {
        return this.f33656m;
    }

    public final a0 X() {
        return this.f33660q;
    }

    public final a0 Y() {
        return this.f33661r;
    }

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

    public final void a0() {
        if (d0()) {
            b0();
        }
    }

    public final void c0() {
        f0 f0Var = this.f33653j;
        kotlin.jvm.internal.t.d(f0Var.f());
        f0Var.q(Boolean.valueOf(!((Boolean) r0).booleanValue()));
    }

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

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

    @Override // l8.h
    public u1 u(m0 m0Var, vm.g context, 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.f33648e.u(m0Var, context, start, str, block);
    }
}
