package cc;

import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.os.Bundle;
import ca.canadapost.core.data.addresscomplete.webservice.AddressCompleteFindItem;
import d9.f;
import n8.a;

/* loaded from: classes4.dex */
public final class q0 extends androidx.lifecycle.b {

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

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

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

    /* renamed from: f, reason: collision with root package name */
    private final ja.d f11731f;

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

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

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

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

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

    /* renamed from: l, reason: collision with root package name */
    private boolean f11737l;

    /* JADX WARN: Illegal instructions before constructor call */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public q0(d9.f analyticsService, t7.c contextService, o9.c cpcEventBus, ja.d sharedPreferencesService, s9.c findRateRepository) {
        super((Application) r0);
        kotlin.jvm.internal.t.g(analyticsService, "analyticsService");
        kotlin.jvm.internal.t.g(contextService, "contextService");
        kotlin.jvm.internal.t.g(cpcEventBus, "cpcEventBus");
        kotlin.jvm.internal.t.g(sharedPreferencesService, "sharedPreferencesService");
        kotlin.jvm.internal.t.g(findRateRepository, "findRateRepository");
        Context a10 = contextService.a();
        kotlin.jvm.internal.t.e(a10, "null cannot be cast to non-null type android.app.Application");
        this.f11728c = analyticsService;
        this.f11729d = contextService;
        this.f11730e = cpcEventBus;
        this.f11731f = sharedPreferencesService;
        this.f11732g = findRateRepository;
        androidx.lifecycle.f0 f0Var = new androidx.lifecycle.f0();
        this.f11733h = f0Var;
        this.f11734i = f0Var;
        androidx.lifecycle.f0 f0Var2 = new androidx.lifecycle.f0();
        this.f11735j = f0Var2;
        this.f11736k = f0Var2;
        f.a.c(analyticsService, "Home_postalcode", null, 2, null);
        Q();
        cpcEventBus.a(this);
    }

    private final void V() {
        this.f11731f.putBoolean("settingdefaultPostCodeUserTrigged", true);
    }

    /* JADX INFO: Access modifiers changed from: protected */
    @Override // androidx.lifecycle.z0
    public void O() {
        this.f11730e.b(this);
        super.O();
    }

    public final void Q() {
        this.f11733h.q(Boolean.valueOf(this.f11731f.getBoolean("settingdefaultPostCodeEnabled", false)));
        this.f11735j.q(this.f11731f.getString("settingdefaultPostCodeValue", ""));
    }

    public final androidx.lifecycle.a0 R() {
        return this.f11734i;
    }

    public final androidx.lifecycle.a0 S() {
        return this.f11736k;
    }

    public final void T(String postalCode) {
        kotlin.jvm.internal.t.g(postalCode, "postalCode");
        this.f11731f.putString("settingdefaultPostCodeValue", postalCode);
    }

    public final void U(boolean z10) {
        f.a.a(this.f11728c, "use_homepostalcodeclick_Adobe", null, 2, null);
        this.f11733h.q(Boolean.valueOf(z10));
        V();
    }

    public final void W() {
        Bundle bundle = new Bundle();
        bundle.putString("responseTag", "getFindPostalCodeOrigin");
        this.f11737l = true;
        f.a.a(this.f11728c, "AMS_addresssearch_homepostalcodeclick_Adobe", null, 2, null);
        a.C0681a c0681a = n8.a.f29843a;
        Activity b10 = this.f11729d.b();
        kotlin.jvm.internal.t.f(b10, "getCurrentActivity(...)");
        c0681a.a(b10, bundle);
    }

    public final void X(boolean z10) {
        if (z10 && z10 != this.f11731f.getBoolean("settingdefaultPostCodeEnabled", false)) {
            W();
        } else {
            if (z10) {
                return;
            }
            this.f11731f.putBoolean("settingdefaultPostCodeEnabled", false);
            this.f11735j.q("");
            this.f11732g.d("");
            this.f11731f.remove("settingdefaultPostCodeValue");
        }
    }

    @mm.h
    public final void addressAvailable(AddressCompleteFindItem.a event) {
        kotlin.jvm.internal.t.g(event, "event");
        if (this.f11737l) {
            this.f11737l = false;
            if (kotlin.jvm.internal.t.b("getFindPostalCodeOrigin", event.f8020a)) {
                this.f11735j.q(event.f8021b.PostalCode);
                s9.c cVar = this.f11732g;
                String PostalCode = event.f8021b.PostalCode;
                kotlin.jvm.internal.t.f(PostalCode, "PostalCode");
                cVar.d(PostalCode);
                this.f11731f.putBoolean("settingdefaultPostCodeEnabled", true);
            }
        }
    }
}
