package vd;

import androidx.lifecycle.a0;
import androidx.lifecycle.a1;
import androidx.lifecycle.f0;
import ca.canadapost.core.data.auth.model.UserProfile;
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 d9.f;
import kotlin.jvm.internal.g0;
import kotlin.jvm.internal.p0;
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 m extends l8.a implements l8.h, l8.c {
    static final /* synthetic */ kn.l[] D = {p0.h(new g0(m.class, "doubleClickGuard", "getDoubleClickGuard()Z", 0))};
    private final a0 A;
    private final l8.g B;
    private final a0 C;

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

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

    /* renamed from: g, reason: collision with root package name */
    private final g9.l f39591g;

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

    /* renamed from: i, reason: collision with root package name */
    private final d9.f f39593i;

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

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

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

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

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

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

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

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

    /* renamed from: r, reason: collision with root package name */
    private final l8.e f39602r;

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

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

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

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

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

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

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

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

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

        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.f39611p;
            if (i10 == 0) {
                y.b(obj);
                g9.l lVar = m.this.f39591g;
                this.f39611p = 1;
                if (lVar.e(this) == f10) {
                    return f10;
                }
            } else {
                if (i10 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                y.b(obj);
            }
            m.this.B.s();
            return n0.f34904a;
        }

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

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

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

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

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

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            Object f10;
            f10 = wm.d.f();
            int i10 = this.f39613p;
            if (i10 == 0) {
                y.b(obj);
                m mVar = m.this;
                this.f39613p = 1;
                if (mVar.m0(this) == f10) {
                    return f10;
                }
            } else {
                if (i10 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                y.b(obj);
            }
            return n0.f34904a;
        }

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

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

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

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

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

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

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            this.f39616q = obj;
            this.f39618s |= Integer.MIN_VALUE;
            return m.this.m0(this);
        }
    }

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public m(t7.c contextService, ka.c profileRepository, g9.l userAuthenticationRepository, ca.b languageService, d9.f analyticsService, String str, boolean z10) {
        super(contextService);
        kotlin.jvm.internal.t.g(contextService, "contextService");
        kotlin.jvm.internal.t.g(profileRepository, "profileRepository");
        kotlin.jvm.internal.t.g(userAuthenticationRepository, "userAuthenticationRepository");
        kotlin.jvm.internal.t.g(languageService, "languageService");
        kotlin.jvm.internal.t.g(analyticsService, "analyticsService");
        this.f39589e = contextService;
        this.f39590f = profileRepository;
        this.f39591g = userAuthenticationRepository;
        this.f39592h = languageService;
        this.f39593i = analyticsService;
        this.f39594j = str;
        this.f39595k = z10;
        this.f39596l = new l8.i(contextService);
        this.f39597m = new l8.d();
        Boolean bool = Boolean.FALSE;
        this.f39598n = new f0(bool);
        this.f39599o = T();
        this.f39600p = new f0(bool);
        this.f39601q = U();
        this.f39602r = new l8.e(false, 0L, 3, null);
        this.f39603s = new f0(z10 ? str : "");
        l8.g gVar = new l8.g();
        this.f39604t = gVar;
        this.f39605u = gVar;
        l8.g gVar2 = new l8.g();
        this.f39606v = gVar2;
        this.f39607w = gVar2;
        f0 f0Var = new f0();
        this.f39608x = f0Var;
        this.f39609y = f0Var;
        l8.g gVar3 = new l8.g();
        this.f39610z = gVar3;
        this.A = gVar3;
        l8.g gVar4 = new l8.g();
        this.B = gVar4;
        this.C = gVar4;
    }

    private final boolean a0() {
        return this.f39602r.a(this, D[0]).booleanValue();
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX WARN: Removed duplicated region for block: B:12:0x0086  */
    /* JADX WARN: Removed duplicated region for block: B:16:0x008c  */
    /* JADX WARN: Removed duplicated region for block: B:25:0x0039  */
    /* JADX WARN: Removed duplicated region for block: B:8:0x0027  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object m0(vm.d dVar) {
        c cVar;
        Object f10;
        int i10;
        ResultWrapper.Error error;
        m mVar = this;
        if (dVar instanceof c) {
            cVar = (c) dVar;
            int i11 = cVar.f39618s;
            if ((i11 & Integer.MIN_VALUE) != 0) {
                cVar.f39618s = i11 - Integer.MIN_VALUE;
                Object obj = cVar.f39616q;
                f10 = wm.d.f();
                i10 = cVar.f39618s;
                if (i10 != 0) {
                    y.b(obj);
                    AndroidDeviceType androidDeviceType = AndroidDeviceType.MOBILE;
                    String str = (String) mVar.f39603s.f();
                    if (str == null) {
                        str = "";
                    }
                    String c10 = mVar.f39592h.c();
                    kotlin.jvm.internal.t.f(c10, "getLanguage(...)");
                    OneToOneEmailRequest oneToOneEmailRequest = new OneToOneEmailRequest(str, c10, new OneToOneEmailRequest.OneToOneEmailAnalytics(androidDeviceType, null, null, null, null, null, null, 126, null));
                    ka.c cVar2 = mVar.f39590f;
                    cVar.f39615p = mVar;
                    cVar.f39618s = 1;
                    obj = cVar2.U(oneToOneEmailRequest, cVar);
                    if (obj == f10) {
                        return f10;
                    }
                } else {
                    if (i10 != 1) {
                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                    }
                    mVar = (m) cVar.f39615p;
                    y.b(obj);
                }
                error = (ResultWrapper.Error) obj;
                if (error != null) {
                    mVar.f39606v.s();
                } else if (error.getError() == RepositoryError.DuplicateEmail) {
                    mVar.f39608x.q(mVar.f39589e.getString(ld.m.W));
                } else if (error.getError() == RepositoryError.NoNetworkError) {
                    mVar.i0(new ResultWrapper.Error(error.getException(), error.getMessage(), error.getError(), null, 8, null), true);
                } else {
                    mVar.f39610z.s();
                }
                return n0.f34904a;
            }
        }
        cVar = new c(dVar);
        Object obj2 = cVar.f39616q;
        f10 = wm.d.f();
        i10 = cVar.f39618s;
        if (i10 != 0) {
        }
        error = (ResultWrapper.Error) obj2;
        if (error != null) {
        }
        return n0.f34904a;
    }

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

    @Override // l8.a
    public void Q(boolean z10) {
        super.Q(z10);
        U().q(Boolean.FALSE);
    }

    @Override // l8.a
    public f0 R() {
        return this.f39599o;
    }

    @Override // l8.a
    public f0 S() {
        return this.f39601q;
    }

    @Override // l8.a
    protected f0 T() {
        return this.f39598n;
    }

    @Override // l8.a
    protected f0 U() {
        return this.f39600p;
    }

    @Override // l8.a
    public void V() {
        this.f39604t.q(Boolean.TRUE);
    }

    public final d9.f Z() {
        return this.f39593i;
    }

    public final String b0() {
        String str = this.f39594j;
        return str == null ? "" : str;
    }

    public final a0 c0() {
        return this.C;
    }

    public final a0 d0() {
        return this.f39607w;
    }

    public final a0 e0() {
        return this.f39605u;
    }

    public final f0 f0() {
        return this.f39603s;
    }

    public final f0 g0() {
        return this.f39609y;
    }

    public final String h0() {
        String userName;
        UserProfile userProfile = (UserProfile) this.f39590f.a().f();
        return (userProfile == null || (userName = userProfile.getUserName()) == null) ? "" : userName;
    }

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

    public final a0 j0() {
        return this.A;
    }

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

    public final void l0() {
        if (a0()) {
            return;
        }
        f0 U = U();
        Object f10 = T().f();
        Boolean bool = Boolean.TRUE;
        boolean z10 = true;
        U.q(Boolean.valueOf(!kotlin.jvm.internal.t.b(f10, bool)));
        this.f39608x.q(!qa.d.i((String) this.f39603s.f()) ? this.f39589e.getString(ld.m.V) : null);
        if (kotlin.jvm.internal.t.b(T().f(), bool)) {
            CharSequence charSequence = (CharSequence) this.f39608x.f();
            if (charSequence != null && charSequence.length() != 0) {
                z10 = false;
            }
            if (z10) {
                h.a.a(this, a1.a(this), null, null, null, new b(null), 7, null);
            }
        }
    }

    public final void n0() {
        f.a.a(this.f39593i, "Update_email_address_contactinfo_Adobe", null, 2, null);
    }

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

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