package gc;

import android.app.Application;
import android.content.Context;
import ca.canadapost.core.data.flex.model.FlexLocation;
import ca.canadapost.core.data.flex.model.FlexService;

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

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

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

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

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

    /* renamed from: g, reason: collision with root package name */
    private final String f19801g;

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

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

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

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

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

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

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

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

    /* renamed from: p, reason: collision with root package name */
    private androidx.lifecycle.f0 f19810p;

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

    /* loaded from: classes4.dex */
    static final class a extends kotlin.jvm.internal.v implements dn.l {
        a() {
            super(1);
        }

        @Override // dn.l
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public final FlexLocation.FlexLocationItem.Address invoke(FlexLocation.FlexLocationItem flexLocationItem) {
            FlexLocation.FlexLocationItem.Apl apl;
            FlexLocation.FlexLocationItem.Flex flex;
            if (v0.this.a0().v().f() == FlexService.FLEX) {
                if (flexLocationItem == null || (flex = flexLocationItem.getFlex()) == null) {
                    return null;
                }
                return flex.getMailingAddress();
            }
            if (flexLocationItem == null || (apl = flexLocationItem.getApl()) == null) {
                return null;
            }
            return apl.getMailingAddress();
        }
    }

    /* loaded from: classes4.dex */
    static final class b extends kotlin.jvm.internal.v implements dn.l {

        /* renamed from: p, reason: collision with root package name */
        public static final b f19813p = new b();

        b() {
            super(1);
        }

        @Override // dn.l
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public final Boolean invoke(FlexLocation.FlexLocationItem.Address address) {
            String city;
            boolean z10 = false;
            if (address != null && (city = address.getCity()) != null && city.length() > 0) {
                z10 = true;
            }
            return Boolean.valueOf(z10);
        }
    }

    /* loaded from: classes4.dex */
    static final class c extends kotlin.jvm.internal.v implements dn.l {

        /* renamed from: p, reason: collision with root package name */
        public static final c f19814p = new c();

        c() {
            super(1);
        }

        /* JADX WARN: Code restructure failed: missing block: B:10:0x001b, code lost:
        
            if (r0 == false) goto L20;
         */
        @Override // dn.l
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        /*
            Code decompiled incorrectly, please refer to instructions dump.
        */
        public final Boolean invoke(FlexLocation.FlexLocationItem.Address address) {
            boolean C;
            if ((address != null ? address.getCity() : null) != null) {
                String city = address.getCity();
                if (city != null) {
                    C = kotlin.text.y.C(city);
                    boolean z10 = C;
                }
            }
            if ((address != null ? address.getAddressLine3() : null) != null) {
                return Boolean.TRUE;
            }
            return Boolean.FALSE;
        }
    }

    /* loaded from: classes4.dex */
    static final class d extends kotlin.jvm.internal.v implements dn.l {

        /* renamed from: p, reason: collision with root package name */
        public static final d f19815p = new d();

        d() {
            super(1);
        }

        @Override // dn.l
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public final Boolean invoke(FlexLocation.FlexLocationItem.Address address) {
            String addressLine1;
            boolean z10 = false;
            if (address != null && (addressLine1 = address.getAddressLine1()) != null && addressLine1.length() > 0) {
                z10 = true;
            }
            return Boolean.valueOf(z10);
        }
    }

    /* loaded from: classes4.dex */
    static final class e extends kotlin.jvm.internal.v implements dn.l {

        /* renamed from: p, reason: collision with root package name */
        public static final e f19816p = new e();

        e() {
            super(1);
        }

        @Override // dn.l
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public final Boolean invoke(FlexLocation.FlexLocationItem.Address address) {
            String addressLine2;
            boolean z10 = false;
            if (address != null && (addressLine2 = address.getAddressLine2()) != null && addressLine2.length() > 0) {
                z10 = true;
            }
            return Boolean.valueOf(z10);
        }
    }

    /* loaded from: classes4.dex */
    static final class f extends kotlin.jvm.internal.v implements dn.l {

        /* renamed from: p, reason: collision with root package name */
        public static final f f19817p = new f();

        f() {
            super(1);
        }

        @Override // dn.l
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public final Boolean invoke(FlexLocation.FlexLocationItem.Address address) {
            String postalCode;
            boolean z10 = false;
            if (address != null && (postalCode = address.getPostalCode()) != null && postalCode.length() > 0) {
                z10 = true;
            }
            return Boolean.valueOf(z10);
        }
    }

    /* JADX WARN: Illegal instructions before constructor call */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public v0(v9.d repository, t7.c contextService, j7.c clipboardService, d9.f analyticsService) {
        super((Application) r0);
        kotlin.jvm.internal.t.g(repository, "repository");
        kotlin.jvm.internal.t.g(contextService, "contextService");
        kotlin.jvm.internal.t.g(clipboardService, "clipboardService");
        kotlin.jvm.internal.t.g(analyticsService, "analyticsService");
        Context a10 = contextService.a();
        kotlin.jvm.internal.t.e(a10, "null cannot be cast to non-null type android.app.Application");
        this.f19797c = repository;
        this.f19798d = contextService;
        this.f19799e = clipboardService;
        this.f19800f = analyticsService;
        this.f19801g = "FlexAddress";
        androidx.lifecycle.a0 a11 = androidx.lifecycle.y0.a(repository.n(), new a());
        this.f19802h = a11;
        androidx.lifecycle.f0 f0Var = new androidx.lifecycle.f0();
        this.f19803i = f0Var;
        this.f19804j = f0Var;
        this.f19805k = androidx.lifecycle.y0.a(a11, d.f19815p);
        this.f19806l = androidx.lifecycle.y0.a(a11, e.f19816p);
        this.f19807m = androidx.lifecycle.y0.a(a11, c.f19814p);
        this.f19808n = androidx.lifecycle.y0.a(a11, b.f19813p);
        this.f19809o = androidx.lifecycle.y0.a(a11, f.f19817p);
        androidx.lifecycle.f0 f0Var2 = new androidx.lifecycle.f0();
        this.f19810p = f0Var2;
        this.f19811q = f0Var2;
        f0Var2.q("");
    }

    private final void Q(int i10) {
        FlexLocation.FlexLocationItem.Address address = (FlexLocation.FlexLocationItem.Address) this.f19802h.f();
        if (address != null) {
            if (i10 == 0) {
                this.f19799e.a(this.f19801g, address.getAddressLine1());
                this.f19810p.q(this.f19798d.getString(e2.f19658v));
                return;
            }
            if (i10 == 1) {
                this.f19799e.a(this.f19801g, address.getAddressLine2());
                this.f19810p.q(this.f19798d.getString(e2.f19659w));
                return;
            }
            if (i10 == 2) {
                this.f19799e.a(this.f19801g, address.getAddressLine3());
                this.f19810p.q(this.f19798d.getString(e2.f19656t));
                return;
            }
            if (i10 == 3) {
                this.f19799e.a(this.f19801g, address.getCity());
                this.f19810p.q(this.f19798d.getString(e2.f19654s));
            } else if (i10 == 4) {
                this.f19799e.a(this.f19801g, address.getPostalCode());
                this.f19810p.q(this.f19798d.getString(e2.f19660x));
            } else {
                if (i10 != 5) {
                    return;
                }
                this.f19799e.a(this.f19801g, address.getFormattedAddress().toString());
                this.f19810p.q(this.f19798d.getString(e2.f19657u));
            }
        }
    }

    public final void R() {
        Q(3);
        X();
    }

    public final void S() {
        Q(2);
        X();
    }

    public final void T() {
        Q(5);
        X();
    }

    public final void U() {
        Q(0);
        X();
    }

    public final void V() {
        Q(1);
        X();
    }

    public final void W() {
        Q(4);
        X();
    }

    public final void X() {
        this.f19803i.q(Boolean.TRUE);
    }

    public final androidx.lifecycle.a0 Y() {
        return this.f19811q;
    }

    public final androidx.lifecycle.a0 Z() {
        return this.f19804j;
    }

    public final v9.d a0() {
        return this.f19797c;
    }

    public final androidx.lifecycle.a0 b0() {
        return this.f19808n;
    }

    public final androidx.lifecycle.a0 c0() {
        return this.f19807m;
    }

    public final androidx.lifecycle.a0 d0() {
        return this.f19805k;
    }

    public final androidx.lifecycle.a0 e0() {
        return this.f19806l;
    }

    public final androidx.lifecycle.a0 f0() {
        return this.f19809o;
    }
}
