package kg;

import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.os.Bundle;
import androidx.lifecycle.a0;
import androidx.lifecycle.f0;
import ca.canadapost.core.data.addresscomplete.webservice.AddressCompleteFindItem;
import ca.canadapost.core.data.auth.model.UserProfile;
import d9.f;
import g9.k;
import java.util.Map;
import kn.l;
import kotlin.jvm.internal.g0;
import kotlin.jvm.internal.p0;
import kotlin.jvm.internal.t;
import kotlin.text.y;
import n8.a;
import p9.h;

/* loaded from: classes4.dex */
public final class d extends androidx.lifecycle.b {
    static final /* synthetic */ l[] I = {p0.h(new g0(d.class, "doubleClickGuard", "getDoubleClickGuard()Z", 0))};
    private final l8.g A;
    private final a0 B;
    private Integer C;
    private final f0 D;
    private final f0 E;
    private f0 F;
    private final androidx.lifecycle.g0 G;
    private final androidx.lifecycle.g0 H;

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

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

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

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

    /* renamed from: g, reason: collision with root package name */
    private final o9.c f25811g;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    /* JADX WARN: Illegal instructions before constructor call */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public d(t7.c contextService, g9.g jwtTokenRepository, g9.d sessionRepository, ka.b userProfileRepository, o9.c cpcEventBus, d9.f analyticsService, k registrationRepository, h featureFlagRepository, a photoData) {
        super((Application) r10);
        t.g(contextService, "contextService");
        t.g(jwtTokenRepository, "jwtTokenRepository");
        t.g(sessionRepository, "sessionRepository");
        t.g(userProfileRepository, "userProfileRepository");
        t.g(cpcEventBus, "cpcEventBus");
        t.g(analyticsService, "analyticsService");
        t.g(registrationRepository, "registrationRepository");
        t.g(featureFlagRepository, "featureFlagRepository");
        t.g(photoData, "photoData");
        Context a10 = contextService.a();
        t.e(a10, "null cannot be cast to non-null type android.app.Application");
        this.f25807c = contextService;
        this.f25808d = jwtTokenRepository;
        this.f25809e = sessionRepository;
        this.f25810f = userProfileRepository;
        this.f25811g = cpcEventBus;
        this.f25812h = analyticsService;
        this.f25813i = registrationRepository;
        this.f25814j = featureFlagRepository;
        this.f25815k = photoData;
        this.f25816l = new l8.e(false, 0L, 3, null);
        l8.g gVar = new l8.g();
        this.f25817m = gVar;
        this.f25818n = gVar;
        l8.g gVar2 = new l8.g();
        this.f25819o = gVar2;
        this.f25820p = gVar2;
        f0 f0Var = new f0();
        this.f25821q = f0Var;
        this.f25822r = f0Var;
        l8.g gVar3 = new l8.g();
        this.f25823s = gVar3;
        this.f25824t = gVar3;
        l8.g gVar4 = new l8.g();
        this.f25825u = gVar4;
        this.f25826v = gVar4;
        f0 f0Var2 = new f0();
        this.f25827w = f0Var2;
        this.f25828x = f0Var2;
        f0 f0Var3 = new f0();
        this.f25829y = f0Var3;
        this.f25830z = f0Var3;
        l8.g gVar5 = new l8.g();
        this.A = gVar5;
        this.B = gVar5;
        this.D = new f0();
        this.E = new f0();
        this.F = new f0();
        androidx.lifecycle.g0 g0Var = new androidx.lifecycle.g0() { // from class: kg.b
            @Override // androidx.lifecycle.g0
            public final void d(Object obj) {
                d.h0(d.this, ((Boolean) obj).booleanValue());
            }
        };
        sessionRepository.i().k(g0Var);
        this.G = g0Var;
        androidx.lifecycle.g0 g0Var2 = new androidx.lifecycle.g0() { // from class: kg.c
            @Override // androidx.lifecycle.g0
            public final void d(Object obj) {
                d.n0(d.this, (UserProfile) obj);
            }
        };
        userProfileRepository.a().k(g0Var2);
        this.H = g0Var2;
        cpcEventBus.a(this);
    }

    private final boolean U() {
        return this.f25816l.a(this, I[0]).booleanValue();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void h0(d this$0, boolean z10) {
        t.g(this$0, "this$0");
        this$0.f25821q.q(Boolean.valueOf(z10));
        if (z10) {
            return;
        }
        this$0.f25829y.q(Integer.valueOf(yf.h.f52606l1));
        this$0.p0("SignInToViewPhoto");
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX WARN: Removed duplicated region for block: B:19:0x0052  */
    /* JADX WARN: Removed duplicated region for block: B:22:0x0063  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static final void n0(d this$0, UserProfile userProfile) {
        boolean z10;
        t.g(this$0, "this$0");
        if (t.b(this$0.f25822r.f(), Boolean.FALSE)) {
            return;
        }
        if (t.b(this$0.f25821q.f(), Boolean.TRUE)) {
            if (!t.b(this$0.f25815k.a(), userProfile != null ? userProfile.getPostalZip() : null)) {
                if (!t.b(this$0.s0(this$0.f25815k.c()), userProfile != null ? userProfile.getPostalZip() : null)) {
                    z10 = true;
                    if (z10) {
                        f0 f0Var = this$0.f25829y;
                        Integer num = this$0.C;
                        if (num == null) {
                            num = Integer.valueOf(yf.h.f52609m);
                        }
                        f0Var.q(num);
                    } else {
                        this$0.f25829y.q(Integer.valueOf(yf.h.f52653u3));
                        this$0.p0("VerifyPostalCode");
                    }
                    this$0.f25827w.q(Boolean.valueOf(z10));
                }
            }
        }
        z10 = false;
        if (z10) {
        }
        this$0.f25827w.q(Boolean.valueOf(z10));
    }

    private final void r0() {
        this.f25813i.m("MOBILE_ANDROID_CPC", "SignInToViewPhoto", "SignInToViewPhoto");
    }

    private final String s0(String str) {
        String J;
        J = y.J(str, " ", "", false, 4, null);
        return J;
    }

    /* JADX INFO: Access modifiers changed from: protected */
    @Override // androidx.lifecycle.z0
    public void O() {
        this.f25809e.i().o(this.G);
        this.f25810f.a().o(this.H);
        this.f25811g.b(this);
        super.O();
    }

    public final f0 S() {
        return this.F;
    }

    public final String T() {
        return this.f25815k.b();
    }

    public final h V() {
        return this.f25814j;
    }

    public final g9.g W() {
        return this.f25808d;
    }

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

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

    public final a0 Z() {
        return this.f25826v;
    }

    public final a0 a0() {
        return this.f25820p;
    }

    @mm.h
    public final void addressAvailable(AddressCompleteFindItem.a event) {
        t.g(event, "event");
        this.D.q(event.f8021b.PostalCode);
    }

    public final a0 b0() {
        return this.f25818n;
    }

    public final f0 c0() {
        return this.D;
    }

    public final f0 d0() {
        return this.E;
    }

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

    public final a0 f0() {
        return this.f25822r;
    }

    public final a0 g0() {
        return this.f25828x;
    }

    public final void i0() {
        this.f25823s.s();
    }

    /* JADX WARN: Code restructure failed: missing block: B:17:0x0050, code lost:
    
        if (r0 != false) goto L21;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void j0() {
        boolean z10;
        boolean z11;
        if (U()) {
            return;
        }
        CharSequence charSequence = (CharSequence) this.D.f();
        if (!(charSequence == null || charSequence.length() == 0)) {
            z10 = y.z((String) this.D.f(), this.f25815k.c(), true);
            if (!z10) {
                String str = (String) this.D.f();
                z11 = y.z(str != null ? s0(str) : null, s0(this.f25815k.a()), true);
            }
            this.f25827w.q(Boolean.FALSE);
            o0("continue_to_photo_verify_image_Adobe", d9.e.f15943f.a("VerifyPostalCode"));
            String str2 = (String) this.F.f();
            if (str2 != null) {
                p0(str2);
            }
            this.A.s();
            return;
        }
        this.E.q(this.f25807c.getString(yf.h.F0));
    }

    public final void k0() {
        if (U()) {
            return;
        }
        Bundle bundle = new Bundle();
        bundle.putString("responseTag", "getFindPostalCodeOrigin");
        bundle.putBoolean("disableDrawer", true);
        a.C0681a c0681a = n8.a.f29843a;
        Activity b10 = this.f25807c.b();
        t.f(b10, "getCurrentActivity(...)");
        c0681a.a(b10, bundle);
    }

    public final void l0() {
        if (U()) {
            return;
        }
        r0();
        this.f25819o.s();
    }

    public final void m0() {
        if (U()) {
            return;
        }
        r0();
        this.f25817m.s();
    }

    public final void o0(String tag, Map extras) {
        t.g(tag, "tag");
        t.g(extras, "extras");
        this.f25812h.b(tag, extras);
    }

    public final void p0(String tag) {
        t.g(tag, "tag");
        f.a.c(this.f25812h, tag, null, 2, null);
    }

    public final void q0(int i10) {
        this.C = Integer.valueOf(i10);
        if (t.b(this.f25828x.f(), Boolean.FALSE) && t.b(this.f25822r.f(), Boolean.TRUE)) {
            this.f25829y.q(Integer.valueOf(i10));
        }
    }
}
