package hb;

import android.content.Context;
import android.text.format.DateFormat;
import androidx.compose.foundation.layout.o;
import androidx.compose.ui.platform.AndroidCompositionLocals_androidKt;
import ca.canadapost.core.data.consumerhome.model.HomeTrackPin;
import ca.canadapost.core.data.consumerhome.model.HomeTrackPinStatus;
import ca.canadapost.core.data.consumerhome.model.LatestEvent;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import dn.p;
import e0.c0;
import e0.f0;
import gb.b0;
import h2.e0;
import j2.g;
import java.util.Date;
import java.util.List;
import kotlin.jvm.internal.t;
import kotlin.jvm.internal.v;
import l1.i;
import org.joda.time.DateTime;
import q2.d;
import rm.n0;
import sm.u;
import v0.z1;
import v2.r;
import w8.h;
import y0.d4;
import y0.l2;
import y0.m;
import y0.x2;
import y0.y;

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

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes4.dex */
    public static final class a extends v implements p {

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

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

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

        public final void a(m mVar, int i10) {
            c.a(this.f21451p, mVar, l2.a(this.f21452q | 1));
        }

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

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes4.dex */
    public static final class b extends v implements p {

        /* renamed from: p, reason: collision with root package name */
        final /* synthetic */ q2.d f21453p;

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

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

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        b(q2.d dVar, int i10, int i11) {
            super(2);
            this.f21453p = dVar;
            this.f21454q = i10;
            this.f21455r = i11;
        }

        public final void a(m mVar, int i10) {
            c.b(this.f21453p, this.f21454q, mVar, l2.a(this.f21455r | 1));
        }

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

    /* JADX WARN: Code restructure failed: missing block: B:130:0x0349, code lost:
    
        r2 = kotlin.text.z.I0(r16, new java.lang.String[]{"&"}, false, 0, 6, null);
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static final void a(b0 itemData, m mVar, int i10) {
        int i11;
        List k10;
        d.a aVar;
        int l10;
        String b10;
        t.g(itemData, "itemData");
        m r10 = mVar.r(-1246260410);
        if ((i10 & 14) == 0) {
            i11 = (r10.R(itemData) ? 4 : 2) | i10;
        } else {
            i11 = i10;
        }
        if ((i11 & 11) == 2 && r10.v()) {
            r10.A();
        } else {
            if (y0.p.H()) {
                y0.p.Q(-1246260410, i11, -1, "ca.canadapost.module.consumerhome.landing.items.trackpackageitem.DeliveryDate (DeliveryDate.kt:32)");
            }
            HomeTrackPin f10 = itemData.f();
            h.a aVar2 = w8.h.f40968a;
            org.joda.time.format.b e10 = aVar2.e();
            q2.d dVar = null;
            if (f10.getStatus() == HomeTrackPinStatus.DELIVERED) {
                r10.e(999269615);
                LatestEvent latestEvent = f10.getLatestEvent();
                String dateTime = latestEvent != null ? latestEvent.getDateTime() : null;
                if (dateTime != null) {
                    t.d(e10);
                    DateTime n10 = aVar2.n(dateTime, e10);
                    if (n10 != null) {
                        String c10 = aVar2.c(dateTime, itemData.h(), e10);
                        String format = DateFormat.getTimeFormat((Context) r10.t(AndroidCompositionLocals_androidKt.g())).format(n10.u());
                        aVar = new d.a(0, 1, null);
                        r10.e(999270056);
                        l10 = aVar.l(n7.a.f29827a.c(r10, n7.a.f29828b).d().M());
                        try {
                            aVar.f(m2.j.b(bb.h.f6857k0, r10, 0));
                            aVar.f(" ");
                            n0 n0Var = n0.f34904a;
                            aVar.j(l10);
                            r10.N();
                            l10 = aVar.l(new q2.b0(0L, 0L, r.f38997q.a(), null, null, null, null, 0L, null, null, null, 0L, null, null, null, null, 65531, null));
                            try {
                                int i12 = bb.h.f6855j0;
                                t.d(format);
                                aVar.f(m2.j.c(i12, new Object[]{c10, format}, r10, 64));
                                aVar.j(l10);
                                dVar = aVar.m();
                            } finally {
                            }
                        } finally {
                        }
                    }
                }
                r10.N();
            } else if (f10.getStatus() == HomeTrackPinStatus.READY_TO_PICKUP) {
                r10.e(999270659);
                LatestEvent latestEvent2 = f10.getLatestEvent();
                String dateTime2 = latestEvent2 != null ? latestEvent2.getDateTime() : null;
                if (dateTime2 != null) {
                    t.d(e10);
                    DateTime n11 = aVar2.n(dateTime2, e10);
                    if (n11 != null && (b10 = aVar2.b(n11.G(15), e10)) != null) {
                        String c11 = aVar2.c(b10, itemData.h(), e10);
                        aVar = new d.a(0, 1, null);
                        l10 = aVar.l(n7.a.f29827a.c(r10, n7.a.f29828b).d().M());
                        try {
                            aVar.f(m2.j.b(bb.h.f6873s0, r10, 0));
                            aVar.f(" ");
                            n0 n0Var2 = n0.f34904a;
                            aVar.j(l10);
                            l10 = aVar.l(new q2.b0(0L, 0L, r.f38997q.a(), null, null, null, null, 0L, null, null, null, 0L, null, null, null, null, 65531, null));
                            try {
                                aVar.f(c11);
                                aVar.j(l10);
                                dVar = aVar.m();
                            } finally {
                            }
                        } finally {
                        }
                    }
                }
                r10.N();
            } else {
                String expectedDeliveryDate = f10.getExpectedDeliveryDate();
                if (expectedDeliveryDate == null || expectedDeliveryDate.length() == 0) {
                    String deliveryStandardDays = f10.getDeliveryStandardDays();
                    if (deliveryStandardDays == null || deliveryStandardDays.length() == 0) {
                        r10.e(912723239);
                        r10.N();
                    } else {
                        r10.e(999273311);
                        String deliveryStandardDays2 = f10.getDeliveryStandardDays();
                        if (deliveryStandardDays2 == null || k10 == null) {
                            k10 = u.k();
                        }
                        if (k10.size() == 2) {
                            aVar = new d.a(0, 1, null);
                            r10.e(999273486);
                            l10 = aVar.l(n7.a.f29827a.c(r10, n7.a.f29828b).d().M());
                            try {
                                aVar.f(m2.j.b(bb.h.f6861m0, r10, 0));
                                aVar.f(" ");
                                n0 n0Var3 = n0.f34904a;
                                aVar.j(l10);
                                r10.N();
                                l10 = aVar.l(new q2.b0(0L, 0L, r.f38997q.a(), null, null, null, null, 0L, null, null, null, 0L, null, null, null, null, 65531, null));
                                try {
                                    aVar.f(m2.j.c(bb.h.f6859l0, new Object[]{k10.get(0), k10.get(1)}, r10, 64));
                                    aVar.j(l10);
                                    dVar = aVar.m();
                                } finally {
                                }
                            } finally {
                            }
                        }
                        r10.N();
                    }
                } else {
                    r10.e(999271708);
                    Date k11 = aVar2.k(f10.getExpectedDeliveryDate());
                    if (k11 != null) {
                        if (aVar2.h(k11.getTime())) {
                            r10.e(-1236639501);
                            aVar = new d.a(0, 1, null);
                            r10.e(-1236639432);
                            l10 = aVar.l(n7.a.f29827a.c(r10, n7.a.f29828b).d().M());
                            try {
                                aVar.f(m2.j.b(bb.h.f6867p0, r10, 0));
                                aVar.f(" ");
                                n0 n0Var4 = n0.f34904a;
                                aVar.j(l10);
                                r10.N();
                                l10 = aVar.l(new q2.b0(0L, 0L, r.f38997q.a(), null, null, null, null, 0L, null, null, null, 0L, null, null, null, null, 65531, null));
                                try {
                                    aVar.f(m2.j.b(bb.h.f6865o0, r10, 0));
                                    aVar.j(l10);
                                    q2.d m10 = aVar.m();
                                    r10.N();
                                    dVar = m10;
                                } finally {
                                }
                            } finally {
                            }
                        } else {
                            r10.e(-1236638911);
                            String expectedDeliveryDate2 = f10.getExpectedDeliveryDate();
                            if (expectedDeliveryDate2 != null) {
                                String d10 = h.a.d(aVar2, expectedDeliveryDate2, itemData.h(), null, 4, null);
                                aVar = new d.a(0, 1, null);
                                l10 = aVar.l(n7.a.f29827a.c(r10, n7.a.f29828b).d().M());
                                try {
                                    aVar.f(m2.j.b(bb.h.f6863n0, r10, 0));
                                    aVar.f(" ");
                                    n0 n0Var5 = n0.f34904a;
                                    aVar.j(l10);
                                    l10 = aVar.l(new q2.b0(0L, 0L, r.f38997q.a(), null, null, null, null, 0L, null, null, null, 0L, null, null, null, null, 65531, null));
                                    try {
                                        aVar.f(d10);
                                        aVar.j(l10);
                                        dVar = aVar.m();
                                    } finally {
                                    }
                                } finally {
                                }
                            }
                            r10.N();
                        }
                    }
                    r10.N();
                }
            }
            if (dVar != null) {
                b(dVar, bb.e.C, r10, 0);
            }
            if (y0.p.H()) {
                y0.p.P();
            }
        }
        x2 y10 = r10.y();
        if (y10 != null) {
            y10.a(new a(itemData, i10));
        }
    }

    public static final void b(q2.d message, int i10, m mVar, int i11) {
        int i12;
        m mVar2;
        t.g(message, "message");
        m r10 = mVar.r(-1067618465);
        if ((i11 & 14) == 0) {
            i12 = (r10.R(message) ? 4 : 2) | i11;
        } else {
            i12 = i11;
        }
        if ((i11 & 112) == 0) {
            i12 |= r10.i(i10) ? 32 : 16;
        }
        int i13 = i12;
        if ((i13 & 91) == 18 && r10.v()) {
            r10.A();
            mVar2 = r10;
        } else {
            if (y0.p.H()) {
                y0.p.Q(-1067618465, i13, -1, "ca.canadapost.module.consumerhome.landing.items.trackpackageitem.HighlightedInfo (DeliveryDate.kt:123)");
            }
            i.a aVar = l1.i.f27362a;
            float f10 = 16;
            l1.i m10 = androidx.compose.foundation.layout.l.m(aVar, BitmapDescriptorFactory.HUE_RED, c3.h.t(f10), BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED, 13, null);
            e0 b10 = c0.b(e0.b.f16607a.g(), l1.c.f27332a.i(), r10, 48);
            int a10 = y0.j.a(r10, 0);
            y D = r10.D();
            l1.i e10 = l1.h.e(r10, m10);
            g.a aVar2 = j2.g.f23616d;
            dn.a a11 = aVar2.a();
            if (!(r10.w() instanceof y0.f)) {
                y0.j.c();
            }
            r10.u();
            if (r10.n()) {
                r10.o(a11);
            } else {
                r10.F();
            }
            m a12 = d4.a(r10);
            d4.b(a12, b10, aVar2.c());
            d4.b(a12, D, aVar2.e());
            p b11 = aVar2.b();
            if (a12.n() || !t.b(a12.f(), Integer.valueOf(a10))) {
                a12.I(Integer.valueOf(a10));
                a12.l(Integer.valueOf(a10), b11);
            }
            d4.b(a12, e10, aVar2.d());
            f0 f0Var = f0.f16652a;
            v0.f0.a(m2.e.c(i10, r10, (i13 >> 3) & 14), null, o.o(androidx.compose.foundation.layout.l.m(aVar, BitmapDescriptorFactory.HUE_RED, BitmapDescriptorFactory.HUE_RED, c3.h.t(8), BitmapDescriptorFactory.HUE_RED, 11, null), c3.h.t(f10)), 0L, r10, 440, 8);
            n7.a aVar3 = n7.a.f29827a;
            int i14 = n7.a.f29828b;
            mVar2 = r10;
            z1.c(message, null, aVar3.a(r10, i14).f().c(), 0L, null, null, null, 0L, null, null, 0L, 0, false, 0, 0, null, null, aVar3.c(r10, i14).d(), mVar2, i13 & 14, 0, 131066);
            mVar2.O();
            if (y0.p.H()) {
                y0.p.P();
            }
        }
        x2 y10 = mVar2.y();
        if (y10 != null) {
            y10.a(new b(message, i10, i11));
        }
    }
}
