package cc;

import ca.canadapost.core.data.auth.model.UserProfile;
import ca.canadapost.core.data.model.ResultWrapper;

/* loaded from: classes4.dex */
public final class n0 extends r8.a {

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

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

    /* renamed from: p, reason: collision with root package name */
    private final rm.o f11684p;

    /* renamed from: q, reason: collision with root package name */
    private final rm.o f11685q;

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

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

    /* renamed from: t, reason: collision with root package name */
    private String f11688t;

    /* renamed from: u, reason: collision with root package name */
    private String f11689u;

    /* JADX WARN: Failed to restore enum class, 'enum' modifier and super class removed */
    /* JADX WARN: Unknown enum class pattern. Please report as an issue! */
    /* loaded from: classes4.dex */
    public static final class a {
        private static final /* synthetic */ xm.a $ENTRIES;
        private static final /* synthetic */ a[] $VALUES;
        public static final a INVALID_EMAIL = new a("INVALID_EMAIL", 0);
        public static final a SAME_AS_TRANSACTIONAL_EMAIL = new a("SAME_AS_TRANSACTIONAL_EMAIL", 1);

        private static final /* synthetic */ a[] $values() {
            return new a[]{INVALID_EMAIL, SAME_AS_TRANSACTIONAL_EMAIL};
        }

        static {
            a[] $values = $values();
            $VALUES = $values;
            $ENTRIES = xm.b.a($values);
        }

        private a(String str, int i10) {
        }

        public static xm.a getEntries() {
            return $ENTRIES;
        }

        public static a valueOf(String str) {
            return (a) Enum.valueOf(a.class, str);
        }

        public static a[] values() {
            return (a[]) $VALUES.clone();
        }
    }

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

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

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

        @Override // dn.l
        /* renamed from: b, reason: merged with bridge method [inline-methods] */
        public final Object invoke(vm.d dVar) {
            return ((b) create(dVar)).invokeSuspend(rm.n0.f34904a);
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final vm.d create(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.f11690p;
            if (i10 == 0) {
                rm.y.b(obj);
                if (!n0.this.o0()) {
                    return null;
                }
                ka.b bVar = n0.this.f11682n;
                String str = n0.this.f11689u;
                this.f11690p = 1;
                obj = bVar.n(str, 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) {
                return error;
            }
            return null;
        }
    }

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

        @Override // dn.a
        public final String invoke() {
            String additionalEmail;
            UserProfile userProfile = (UserProfile) n0.this.f11682n.a().f();
            return (userProfile == null || (additionalEmail = userProfile.getAdditionalEmail()) == null) ? "" : additionalEmail;
        }
    }

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

        @Override // dn.a
        public final String invoke() {
            String transactionalEmail;
            UserProfile userProfile = (UserProfile) n0.this.f11682n.a().f();
            return (userProfile == null || (transactionalEmail = userProfile.getTransactionalEmail()) == null) ? "" : transactionalEmail;
        }
    }

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public n0(ka.b repository, t7.c contextService) {
        super(contextService);
        rm.o a10;
        rm.o a11;
        kotlin.jvm.internal.t.g(repository, "repository");
        kotlin.jvm.internal.t.g(contextService, "contextService");
        this.f11682n = repository;
        this.f11683o = T();
        a10 = rm.q.a(new d());
        this.f11684p = a10;
        a11 = rm.q.a(new c());
        this.f11685q = a11;
        androidx.lifecycle.f0 f0Var = new androidx.lifecycle.f0();
        f0Var.q(Boolean.FALSE);
        this.f11686r = f0Var;
        androidx.lifecycle.f0 f0Var2 = new androidx.lifecycle.f0();
        f0Var2.q(null);
        this.f11687s = f0Var2;
        this.f11688t = n0();
        this.f11689u = m0();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final boolean o0() {
        return !kotlin.jvm.internal.t.b(this.f11689u, m0());
    }

    private final boolean p0() {
        return !kotlin.jvm.internal.t.b(this.f11688t, n0());
    }

    private final boolean t0() {
        boolean z10 = true;
        if (!(this.f11689u.length() == 0)) {
            if (!(this.f11689u.length() > 0) || !qa.d.i(this.f11689u)) {
                z10 = false;
            }
        }
        if (z10) {
            this.f11687s.q(null);
        } else {
            this.f11687s.q(a.INVALID_EMAIL);
        }
        return z10;
    }

    @Override // r8.b
    public boolean e() {
        return p0() || o0();
    }

    @Override // r8.b
    public boolean g() {
        return t0();
    }

    public final androidx.lifecycle.a0 j0() {
        return this.f11687s;
    }

    public final androidx.lifecycle.a0 k0() {
        return this.f11683o;
    }

    public final androidx.lifecycle.a0 l0() {
        return this.f11686r;
    }

    public final String m0() {
        return (String) this.f11685q.getValue();
    }

    public final String n0() {
        return (String) this.f11684p.getValue();
    }

    public final void q0(String value) {
        CharSequence e12;
        kotlin.jvm.internal.t.g(value, "value");
        e12 = kotlin.text.z.e1(value);
        this.f11689u = e12.toString();
        e0();
    }

    public final void r0() {
        d0(new b(null));
    }

    public final void s0(String value) {
        CharSequence e12;
        kotlin.jvm.internal.t.g(value, "value");
        e12 = kotlin.text.z.e1(value);
        this.f11688t = e12.toString();
        e0();
    }
}
