package hb;

import ca.canadapost.core.data.consumerhome.model.HomeTrackPinStatus;
import ca.canadapost.core.data.consumerhome.model.LatestEvent;
import ca.canadapost.core.data.consumerhome.model.LocationAddress;
import dn.p;
import gb.b0;
import h2.e0;
import j2.g;
import kotlin.jvm.internal.t;
import kotlin.jvm.internal.v;
import l1.i;
import l7.n;
import l7.o;
import rm.n0;
import v0.z1;
import y0.d4;
import y0.l2;
import y0.m;
import y0.x2;
import y0.y;

/* loaded from: classes4.dex */
public abstract class a {

    /* JADX INFO: Access modifiers changed from: package-private */
    /* renamed from: hb.a$a, reason: collision with other inner class name */
    /* loaded from: classes4.dex */
    public static final class C0458a extends v implements p {

        /* renamed from: p, reason: collision with root package name */
        final /* synthetic */ b0 f21445p;

        /* renamed from: q, reason: collision with root package name */
        final /* synthetic */ int f21446q;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        C0458a(b0 b0Var, int i10) {
            super(2);
            this.f21445p = b0Var;
            this.f21446q = i10;
        }

        public final void a(m mVar, int i10) {
            a.a(this.f21445p, mVar, l2.a(this.f21446q | 1));
        }

        @Override // dn.p
        public /* bridge */ /* synthetic */ Object invoke(Object obj, Object obj2) {
            a((m) obj, ((Number) obj2).intValue());
            return n0.f34904a;
        }
    }

    public static final void a(b0 itemData, m mVar, int i10) {
        int i11;
        m mVar2;
        m mVar3;
        t.g(itemData, "itemData");
        m r10 = mVar.r(-261571588);
        if ((i10 & 14) == 0) {
            i11 = (r10.R(itemData) ? 4 : 2) | i10;
        } else {
            i11 = i10;
        }
        if ((i11 & 11) == 2 && r10.v()) {
            r10.A();
            mVar2 = r10;
        } else {
            if (y0.p.H()) {
                y0.p.Q(-261571588, i11, -1, "ca.canadapost.module.consumerhome.landing.items.trackpackageitem.Address (Address.kt:18)");
            }
            if (itemData.f().getStatus() != HomeTrackPinStatus.READY_TO_PICKUP || itemData.f().isReturn()) {
                mVar2 = r10;
            } else {
                n.a(c3.h.t(10), o.Vertical, r10, 54);
                i.a aVar = l1.i.f27362a;
                e0 a10 = e0.d.a(e0.b.f16607a.h(), l1.c.f27332a.k(), r10, 0);
                int a11 = y0.j.a(r10, 0);
                y D = r10.D();
                l1.i e10 = l1.h.e(r10, aVar);
                g.a aVar2 = j2.g.f23616d;
                dn.a a12 = aVar2.a();
                if (!(r10.w() instanceof y0.f)) {
                    y0.j.c();
                }
                r10.u();
                if (r10.n()) {
                    r10.o(a12);
                } else {
                    r10.F();
                }
                m a13 = d4.a(r10);
                d4.b(a13, a10, aVar2.c());
                d4.b(a13, D, aVar2.e());
                p b10 = aVar2.b();
                if (a13.n() || !t.b(a13.f(), Integer.valueOf(a11))) {
                    a13.I(Integer.valueOf(a11));
                    a13.l(Integer.valueOf(a11), b10);
                }
                d4.b(a13, e10, aVar2.d());
                e0.g gVar = e0.g.f16653a;
                r10.e(-948885011);
                if (itemData.d()) {
                    String c10 = c(itemData.f().getLatestEvent());
                    n7.a aVar3 = n7.a.f29827a;
                    int i12 = n7.a.f29828b;
                    mVar3 = r10;
                    z1.b(c10, null, aVar3.a(r10, i12).f().g(), 0L, null, null, null, 0L, null, null, 0L, 0, false, 0, 0, null, aVar3.c(r10, i12).b(), mVar3, 0, 0, 65530);
                } else {
                    mVar3 = r10;
                }
                mVar3.N();
                m mVar4 = mVar3;
                mVar4.e(859691236);
                if (itemData.c()) {
                    String b11 = b(itemData.f().getLatestEvent());
                    n7.a aVar4 = n7.a.f29827a;
                    int i13 = n7.a.f29828b;
                    mVar2 = mVar4;
                    z1.b(b11, null, aVar4.a(mVar4, i13).f().g(), 0L, null, null, null, 0L, null, null, 0L, 0, false, 0, 0, null, aVar4.c(mVar4, i13).b(), mVar2, 0, 0, 65530);
                } else {
                    mVar2 = mVar4;
                }
                mVar2.N();
                mVar2.O();
            }
            if (y0.p.H()) {
                y0.p.P();
            }
        }
        x2 y10 = mVar2.y();
        if (y10 != null) {
            y10.a(new C0458a(itemData, i10));
        }
    }

    private static final String b(LatestEvent latestEvent) {
        LocationAddress locationAddr;
        LocationAddress locationAddr2;
        String str = null;
        String city = (latestEvent == null || (locationAddr2 = latestEvent.getLocationAddr()) == null) ? null : locationAddr2.getCity();
        if (latestEvent != null && (locationAddr = latestEvent.getLocationAddr()) != null) {
            str = locationAddr.getRegionCd();
        }
        return city + " " + str;
    }

    private static final String c(LatestEvent latestEvent) {
        String str = null;
        if (w8.m.a()) {
            if (latestEvent != null) {
                str = latestEvent.getRetailNmEn();
            }
        } else if (latestEvent != null) {
            str = latestEvent.getRetailNmFr();
        }
        return str == null ? "" : str;
    }
}
