package cc;

import android.content.res.Resources;
import ca.canadapost.core.data.auth.model.UserProfile;
import d9.f;
import java.util.List;
import java.util.Locale;

/* loaded from: classes4.dex */
public final class s extends r8.a {
    private final androidx.lifecycle.a0 A;
    private androidx.lifecycle.g0 B;
    private androidx.lifecycle.g0 C;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        a(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 ((a) create(dVar)).invokeSuspend(rm.n0.f34904a);
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final vm.d create(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.f11787p;
            if (i10 == 0) {
                rm.y.b(obj);
                ka.b bVar = s.this.f11774n;
                String str = (String) s.this.v0().f();
                String str2 = (String) s.this.t0().f();
                String str3 = (String) s.this.w0().f();
                String str4 = (String) s.this.u0().f();
                this.f11787p = 1;
                obj = bVar.s(str, str2, str3, str4, this);
                if (obj == f10) {
                    return f10;
                }
            } else {
                if (i10 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                rm.y.b(obj);
            }
            return obj;
        }
    }

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

        @Override // dn.a
        public final String invoke() {
            String securityQuestionAnswer;
            UserProfile userProfile = (UserProfile) s.this.f11774n.a().f();
            return (userProfile == null || (securityQuestionAnswer = userProfile.getSecurityQuestionAnswer()) == null) ? "" : securityQuestionAnswer;
        }
    }

    /* 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 securityQuestionAnswer2;
            UserProfile userProfile = (UserProfile) s.this.f11774n.a().f();
            return (userProfile == null || (securityQuestionAnswer2 = userProfile.getSecurityQuestionAnswer2()) == null) ? "" : securityQuestionAnswer2;
        }
    }

    /* 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 str;
            s sVar = s.this;
            UserProfile userProfile = (UserProfile) sVar.f11774n.a().f();
            if (userProfile == null || (str = userProfile.getSecurityQuestion()) == null) {
                str = "";
            }
            return sVar.q0(str);
        }
    }

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

        @Override // dn.a
        public final String invoke() {
            String str;
            s sVar = s.this;
            UserProfile userProfile = (UserProfile) sVar.f11774n.a().f();
            if (userProfile == null || (str = userProfile.getSecurityQuestion2()) == null) {
                str = "";
            }
            return sVar.q0(str);
        }
    }

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public s(d9.f analyticsService, ka.b repository, t7.c contextService) {
        super(contextService);
        rm.o a10;
        rm.o a11;
        rm.o a12;
        rm.o a13;
        kotlin.jvm.internal.t.g(analyticsService, "analyticsService");
        kotlin.jvm.internal.t.g(repository, "repository");
        kotlin.jvm.internal.t.g(contextService, "contextService");
        this.f11774n = repository;
        this.f11775o = contextService;
        a10 = rm.q.a(new d());
        this.f11776p = a10;
        a11 = rm.q.a(new e());
        this.f11777q = a11;
        a12 = rm.q.a(new b());
        this.f11778r = a12;
        a13 = rm.q.a(new c());
        this.f11779s = a13;
        androidx.lifecycle.f0 f0Var = new androidx.lifecycle.f0();
        this.f11780t = f0Var;
        androidx.lifecycle.f0 f0Var2 = new androidx.lifecycle.f0();
        this.f11781u = f0Var2;
        androidx.lifecycle.f0 f0Var3 = new androidx.lifecycle.f0();
        this.f11782v = f0Var3;
        androidx.lifecycle.f0 f0Var4 = new androidx.lifecycle.f0();
        this.f11783w = f0Var4;
        androidx.lifecycle.f0 f0Var5 = new androidx.lifecycle.f0();
        this.f11784x = f0Var5;
        this.f11785y = f0Var5;
        androidx.lifecycle.f0 f0Var6 = new androidx.lifecycle.f0();
        this.f11786z = f0Var6;
        this.A = f0Var6;
        androidx.lifecycle.g0 g0Var = new androidx.lifecycle.g0() { // from class: cc.q
            @Override // androidx.lifecycle.g0
            public final void d(Object obj) {
                s.A0(s.this, (String) obj);
            }
        };
        f0Var3.k(g0Var);
        this.B = g0Var;
        androidx.lifecycle.g0 g0Var2 = new androidx.lifecycle.g0() { // from class: cc.r
            @Override // androidx.lifecycle.g0
            public final void d(Object obj) {
                s.B0(s.this, (String) obj);
            }
        };
        f0Var4.k(g0Var2);
        this.C = g0Var2;
        f.a.c(analyticsService, "security_questions_accountspage", null, 2, null);
        Boolean bool = Boolean.FALSE;
        f0Var5.q(bool);
        f0Var6.q(bool);
        f0Var.q(o0());
        f0Var2.q(p0());
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void A0(s this$0, String it) {
        kotlin.jvm.internal.t.g(this$0, "this$0");
        kotlin.jvm.internal.t.g(it, "it");
        this$0.e0();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void B0(s this$0, String it) {
        kotlin.jvm.internal.t.g(this$0, "this$0");
        kotlin.jvm.internal.t.g(it, "it");
        this$0.e0();
    }

    private final String m0() {
        return (String) this.f11778r.getValue();
    }

    private final String n0() {
        return (String) this.f11779s.getValue();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final String q0(String str) {
        List S0;
        List S02;
        S0 = sm.p.S0(s0("en"));
        S02 = sm.p.S0(s0("fr"));
        return r0()[x0(S0, S02, str)];
    }

    public final void C0(String position) {
        kotlin.jvm.internal.t.g(position, "position");
        this.f11780t.q(position);
        e0();
    }

    public final void D0(String position) {
        kotlin.jvm.internal.t.g(position, "position");
        this.f11781u.q(position);
        e0();
    }

    /* JADX INFO: Access modifiers changed from: protected */
    @Override // androidx.lifecycle.z0
    public void O() {
        this.f11782v.o(this.B);
        this.f11783w.o(this.C);
        super.O();
    }

    @Override // r8.a
    public boolean c0() {
        if (e()) {
            return g();
        }
        b0();
        return false;
    }

    @Override // r8.b
    public boolean e() {
        CharSequence charSequence = (CharSequence) this.f11782v.f();
        if (charSequence == null || charSequence.length() == 0) {
            CharSequence charSequence2 = (CharSequence) this.f11783w.f();
            if (charSequence2 == null || charSequence2.length() == 0) {
                return false;
            }
        }
        return (kotlin.jvm.internal.t.b(this.f11780t.f(), o0()) && kotlin.jvm.internal.t.b(this.f11781u.f(), p0()) && kotlin.jvm.internal.t.b(this.f11782v.f(), m0()) && kotlin.jvm.internal.t.b(this.f11783w.f(), n0())) ? false : true;
    }

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

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

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

    public final String o0() {
        return (String) this.f11776p.getValue();
    }

    public final String p0() {
        return (String) this.f11777q.getValue();
    }

    public final String[] r0() {
        String[] stringArray = this.f11775o.a().getResources().getStringArray(ob.f.f31108a);
        kotlin.jvm.internal.t.f(stringArray, "getStringArray(...)");
        return stringArray;
    }

    public final String[] s0(String lang) {
        kotlin.jvm.internal.t.g(lang, "lang");
        Resources h10 = w8.l0.h(this.f11775o.a().getApplicationContext(), new Locale(lang));
        kotlin.jvm.internal.t.f(h10, "getLocalizedResources(...)");
        String[] stringArray = h10.getStringArray(ob.f.f31108a);
        kotlin.jvm.internal.t.f(stringArray, "getStringArray(...)");
        return stringArray;
    }

    public final androidx.lifecycle.f0 t0() {
        return this.f11782v;
    }

    public final androidx.lifecycle.f0 u0() {
        return this.f11783w;
    }

    public final androidx.lifecycle.f0 v0() {
        return this.f11780t;
    }

    public final androidx.lifecycle.f0 w0() {
        return this.f11781u;
    }

    public final int x0(List listEn, List listFr, String str) {
        kotlin.jvm.internal.t.g(listEn, "listEn");
        kotlin.jvm.internal.t.g(listFr, "listFr");
        int size = listEn.size();
        for (int i10 = 0; i10 < size; i10++) {
            if (kotlin.jvm.internal.t.b(listEn.get(i10), str)) {
                return i10;
            }
        }
        int size2 = listFr.size();
        for (int i11 = 0; i11 < size2; i11++) {
            if (kotlin.jvm.internal.t.b(listFr.get(i11), str)) {
                return i11;
            }
        }
        return 0;
    }

    public final boolean y0() {
        boolean z10;
        androidx.lifecycle.f0 f0Var = this.f11784x;
        Boolean bool = Boolean.FALSE;
        f0Var.q(bool);
        this.f11786z.q(bool);
        CharSequence charSequence = (CharSequence) this.f11782v.f();
        boolean z11 = true;
        if (charSequence == null || charSequence.length() == 0) {
            this.f11784x.q(Boolean.TRUE);
            z10 = false;
        } else {
            z10 = true;
        }
        CharSequence charSequence2 = (CharSequence) this.f11783w.f();
        if (charSequence2 != null && charSequence2.length() != 0) {
            z11 = false;
        }
        if (!z11) {
            return z10;
        }
        this.f11786z.q(Boolean.TRUE);
        return false;
    }

    public final void z0() {
        d0(new a(null));
    }
}
