package fb;

import ca.canadapost.core.data.auth.model.UserProfile;
import ca.canadapost.core.data.consumerhome.model.HomeTrackPin;
import ca.canadapost.core.data.consumerhome.model.LatestEvent;
import ca.canadapost.core.data.consumerhome.model.LocationAddress;
import ca.canadapost.core.data.mymail.model.NotificationResult;
import ca.canadapost.core.data.profile.model.AMSPrerequisitesResponse;
import gb.b0;
import gb.s;
import gb.w;
import gb.y;
import java.time.LocalTime;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import kotlin.jvm.internal.t;
import sm.u;
import sm.z;

/* loaded from: classes4.dex */
public final class f {
    private Boolean A;
    private boolean B;
    private List C;
    private List D;
    private boolean E;
    private String F;
    private String G;
    private String H;
    private String I;
    private boolean J;
    private boolean K;
    private boolean L;
    private String M;

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

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

    /* renamed from: c, reason: collision with root package name */
    private final dn.a f18056c;

    /* renamed from: d, reason: collision with root package name */
    private final dn.a f18057d;

    /* renamed from: e, reason: collision with root package name */
    private final dn.a f18058e;

    /* renamed from: f, reason: collision with root package name */
    private final dn.a f18059f;

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

    /* renamed from: h, reason: collision with root package name */
    private final dn.l f18061h;

    /* renamed from: i, reason: collision with root package name */
    private final dn.l f18062i;

    /* renamed from: j, reason: collision with root package name */
    private final dn.p f18063j;

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

    /* renamed from: l, reason: collision with root package name */
    private final dn.a f18065l;

    /* renamed from: m, reason: collision with root package name */
    private final dn.a f18066m;

    /* renamed from: n, reason: collision with root package name */
    private final dn.a f18067n;

    /* renamed from: o, reason: collision with root package name */
    private final dn.l f18068o;

    /* renamed from: p, reason: collision with root package name */
    private final dn.l f18069p;

    /* renamed from: q, reason: collision with root package name */
    private boolean f18070q;

    /* renamed from: r, reason: collision with root package name */
    private UserProfile f18071r;

    /* renamed from: s, reason: collision with root package name */
    private AMSPrerequisitesResponse f18072s;

    /* renamed from: t, reason: collision with root package name */
    private Boolean f18073t;

    /* renamed from: u, reason: collision with root package name */
    private List f18074u;

    /* renamed from: v, reason: collision with root package name */
    private List f18075v;

    /* renamed from: w, reason: collision with root package name */
    private Boolean f18076w;

    /* renamed from: x, reason: collision with root package name */
    private Boolean f18077x;

    /* renamed from: y, reason: collision with root package name */
    private Boolean f18078y;

    /* renamed from: z, reason: collision with root package name */
    private Boolean f18079z;

    public f(boolean z10, boolean z11, dn.a trackingPromoItemOnSubscribe, dn.a getSmsNotificationsOnClick, dn.a mailPromoItemOnSubscribe, dn.a myMailsItemOnMyMail, dn.l packagePrimaryBtnOnClick, dn.l trackPackageOnShowPinId, dn.l viewPackageDetailsOnClick, dn.p trackActionMenuOnClick, dn.a manageMailForwardCta, dn.a signUpMailForwardCta, dn.a signUpHoldMailCta, dn.a manageHoldMailOnCta, dn.l customsFormsCardOnCta, dn.l homePickupCardOnCta) {
        List k10;
        List k11;
        t.g(trackingPromoItemOnSubscribe, "trackingPromoItemOnSubscribe");
        t.g(getSmsNotificationsOnClick, "getSmsNotificationsOnClick");
        t.g(mailPromoItemOnSubscribe, "mailPromoItemOnSubscribe");
        t.g(myMailsItemOnMyMail, "myMailsItemOnMyMail");
        t.g(packagePrimaryBtnOnClick, "packagePrimaryBtnOnClick");
        t.g(trackPackageOnShowPinId, "trackPackageOnShowPinId");
        t.g(viewPackageDetailsOnClick, "viewPackageDetailsOnClick");
        t.g(trackActionMenuOnClick, "trackActionMenuOnClick");
        t.g(manageMailForwardCta, "manageMailForwardCta");
        t.g(signUpMailForwardCta, "signUpMailForwardCta");
        t.g(signUpHoldMailCta, "signUpHoldMailCta");
        t.g(manageHoldMailOnCta, "manageHoldMailOnCta");
        t.g(customsFormsCardOnCta, "customsFormsCardOnCta");
        t.g(homePickupCardOnCta, "homePickupCardOnCta");
        this.f18054a = z10;
        this.f18055b = z11;
        this.f18056c = trackingPromoItemOnSubscribe;
        this.f18057d = getSmsNotificationsOnClick;
        this.f18058e = mailPromoItemOnSubscribe;
        this.f18059f = myMailsItemOnMyMail;
        this.f18060g = packagePrimaryBtnOnClick;
        this.f18061h = trackPackageOnShowPinId;
        this.f18062i = viewPackageDetailsOnClick;
        this.f18063j = trackActionMenuOnClick;
        this.f18064k = manageMailForwardCta;
        this.f18065l = signUpMailForwardCta;
        this.f18066m = signUpHoldMailCta;
        this.f18067n = manageHoldMailOnCta;
        this.f18068o = customsFormsCardOnCta;
        this.f18069p = homePickupCardOnCta;
        Boolean bool = Boolean.FALSE;
        this.f18077x = bool;
        this.f18078y = bool;
        this.f18079z = bool;
        this.A = bool;
        this.B = true;
        k10 = u.k();
        this.C = k10;
        k11 = u.k();
        this.D = k11;
        this.F = "";
        this.G = "";
        this.H = "";
        this.I = "";
        this.J = true;
        this.K = true;
        this.L = true;
        this.M = "";
    }

    private final void a(List list) {
        if (this.E) {
            list.add(new gb.c(this.F, this.G, this.H, this.I));
        }
    }

    private final void b(List list) {
        if (this.J) {
            list.add(new gb.k(e.CUSTOMS_FORM_INFO_CARD, this.J, this.K, this.L, this.M, bb.e.f6811x, bb.h.f6856k, bb.h.f6854j, this.f18068o));
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:79:0x0161  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final List c() {
        String str;
        int i10;
        boolean z10;
        String city;
        LocationAddress locationAddr;
        LocationAddress locationAddr2;
        String lastName;
        ArrayList arrayList = new ArrayList();
        if (!this.f18070q || this.f18071r == null) {
            a(arrayList);
            return arrayList;
        }
        UserProfile userProfile = this.f18071r;
        String str2 = "";
        if (userProfile == null || (str = userProfile.getFirstName()) == null) {
            str = "";
        }
        UserProfile userProfile2 = this.f18071r;
        if (userProfile2 != null && (lastName = userProfile2.getLastName()) != null) {
            str2 = lastName;
        }
        arrayList.add(new gb.q(str, str2));
        a(arrayList);
        boolean isAfter = LocalTime.now().isAfter(LocalTime.of(8, 55));
        List list = this.f18074u;
        if (list != null) {
            ArrayList arrayList2 = new ArrayList();
            Iterator it = list.iterator();
            while (it.hasNext()) {
                z.A(arrayList2, ((NotificationResult) it.next()).getMailPieces());
            }
            i10 = arrayList2.size();
        } else {
            i10 = 0;
        }
        if (this.B && i10 > 0 && isAfter) {
            arrayList.add(new s(i10, this.f18059f));
        }
        Boolean bool = this.f18078y;
        Boolean bool2 = Boolean.TRUE;
        if (t.b(bool, bool2)) {
            arrayList.add(new y(e.MAIL_FORWARDING_STATUS, this.D, this.f18064k));
        }
        if (t.b(this.f18077x, bool2)) {
            arrayList.add(new y(e.HOLD_MAIL_STATUS, this.C, this.f18067n));
        }
        List<HomeTrackPin> list2 = this.f18075v;
        if (list2 != null) {
            if (list2.isEmpty()) {
                arrayList.add(new gb.u());
            } else {
                for (HomeTrackPin homeTrackPin : list2) {
                    dn.l lVar = this.f18060g;
                    dn.l lVar2 = this.f18061h;
                    dn.l lVar3 = this.f18062i;
                    dn.p pVar = this.f18063j;
                    boolean z11 = this.f18055b;
                    LatestEvent latestEvent = homeTrackPin.getLatestEvent();
                    String str3 = null;
                    String retailNmEn = latestEvent != null ? latestEvent.getRetailNmEn() : null;
                    boolean z12 = true;
                    if (!(retailNmEn == null || retailNmEn.length() == 0)) {
                        LatestEvent latestEvent2 = homeTrackPin.getLatestEvent();
                        if (!t.b(latestEvent2 != null ? latestEvent2.getRetailNmEn() : null, "null")) {
                            LatestEvent latestEvent3 = homeTrackPin.getLatestEvent();
                            String retailNmFr = latestEvent3 != null ? latestEvent3.getRetailNmFr() : null;
                            if (!(retailNmFr == null || retailNmFr.length() == 0)) {
                                LatestEvent latestEvent4 = homeTrackPin.getLatestEvent();
                                if (!t.b(latestEvent4 != null ? latestEvent4.getRetailNmFr() : null, "null")) {
                                    z10 = true;
                                    LatestEvent latestEvent5 = homeTrackPin.getLatestEvent();
                                    city = (latestEvent5 != null || (locationAddr2 = latestEvent5.getLocationAddr()) == null) ? null : locationAddr2.getCity();
                                    if (!(city != null || city.length() == 0)) {
                                        LatestEvent latestEvent6 = homeTrackPin.getLatestEvent();
                                        if (latestEvent6 != null && (locationAddr = latestEvent6.getLocationAddr()) != null) {
                                            str3 = locationAddr.getRegionCd();
                                        }
                                        if (!(str3 == null || str3.length() == 0)) {
                                            arrayList.add(new b0(homeTrackPin, lVar, lVar2, lVar3, pVar, z11, z10, z12));
                                        }
                                    }
                                    z12 = false;
                                    arrayList.add(new b0(homeTrackPin, lVar, lVar2, lVar3, pVar, z11, z10, z12));
                                }
                            }
                        }
                    }
                    z10 = false;
                    LatestEvent latestEvent52 = homeTrackPin.getLatestEvent();
                    if (latestEvent52 != null) {
                    }
                    if (!(city != null || city.length() == 0)) {
                    }
                    z12 = false;
                    arrayList.add(new b0(homeTrackPin, lVar, lVar2, lVar3, pVar, z11, z10, z12));
                }
            }
        }
        AMSPrerequisitesResponse aMSPrerequisitesResponse = this.f18072s;
        if (!(aMSPrerequisitesResponse != null ? t.b(aMSPrerequisitesResponse.getStatus(), Boolean.TRUE) : false)) {
            arrayList.add(new w(e.TRACKING_PROMO, bb.e.G, bb.h.f6832b1, bb.h.f6829a1, bb.h.Z0, false, this.f18056c, 32, null));
        }
        AMSPrerequisitesResponse aMSPrerequisitesResponse2 = this.f18072s;
        if ((aMSPrerequisitesResponse2 != null ? t.b(aMSPrerequisitesResponse2.getStatus(), Boolean.TRUE) : false) && !t.b(this.f18076w, Boolean.TRUE)) {
            arrayList.add(new w(e.SMS_PROMO, bb.e.B, bb.h.f6843f0, bb.h.f6840e0, bb.h.f6837d0, false, this.f18057d));
        }
        Boolean bool3 = this.A;
        Boolean bool4 = Boolean.TRUE;
        if (t.b(bool3, bool4)) {
            arrayList.add(new w(e.MAIL_FORWARDING_PROMO, bb.e.f6812y, bb.h.f6886z, bb.h.f6884y, bb.h.f6882x, false, this.f18065l));
        }
        if (t.b(this.f18079z, bool4)) {
            arrayList.add(new w(e.HOLD_MAIL_PROMO, bb.e.f6791d, bb.h.f6874t, bb.h.f6872s, bb.h.f6870r, false, this.f18066m));
        }
        if (t.b(this.f18073t, Boolean.FALSE)) {
            arrayList.add(new w(e.MAIL_PROMO, bb.e.f6813z, bb.h.D, bb.h.C, bb.h.B, false, this.f18058e, 32, null));
        }
        if (this.f18070q) {
            b(arrayList);
        }
        return arrayList;
    }

    public final AMSPrerequisitesResponse d() {
        return this.f18072s;
    }

    public final boolean e() {
        return this.f18070q;
    }

    public final Boolean f() {
        return this.f18073t;
    }

    public final void g(uc.a aVar) {
    }

    public final void h(AMSPrerequisitesResponse aMSPrerequisitesResponse) {
        this.f18072s = aMSPrerequisitesResponse;
    }

    public final void i(String title, String description, String linkText, String link, boolean z10) {
        t.g(title, "title");
        t.g(description, "description");
        t.g(linkText, "linkText");
        t.g(link, "link");
        this.F = title;
        this.G = description;
        this.H = linkText;
        this.I = link;
        this.E = z10;
    }

    public final void j(boolean z10, boolean z11, boolean z12, String analyticsEvent) {
        t.g(analyticsEvent, "analyticsEvent");
        this.J = z10;
        this.K = z11;
        this.L = z12;
        this.M = analyticsEvent;
    }

    public final void k(List date) {
        t.g(date, "date");
        this.C = date;
    }

    public final void l(Boolean bool) {
        this.f18077x = bool;
    }

    public final void m(boolean z10) {
        this.f18070q = z10;
    }

    public final void n(List date) {
        t.g(date, "date");
        this.D = date;
    }

    public final void o(Boolean bool) {
        this.f18078y = bool;
    }

    public final void p(List list) {
        this.f18074u = list;
    }

    public final void q(Boolean bool) {
        this.f18073t = bool;
    }

    public final void r(Boolean bool) {
        this.f18079z = bool;
    }

    public final void s(Boolean bool) {
        this.A = bool;
    }

    public final void t(boolean z10) {
        this.B = z10;
    }

    public final void u(List list) {
        this.f18075v = list;
    }

    public final void v(Boolean bool) {
        this.f18076w = bool;
    }

    public final void w(UserProfile userProfile) {
        this.f18071r = userProfile;
    }
}
