package qe;

import androidx.lifecycle.a0;
import androidx.lifecycle.a1;
import ca.canadapost.core.data.mymail.model.AddressEligibilityBody;
import ca.canadapost.core.data.mymail.model.MyMailFlowArguments;
import ca.canadapost.core.data.mymail.model.MyMailStatus;
import d9.f;
import dn.p;
import kotlin.coroutines.jvm.internal.l;
import kotlin.jvm.internal.t;
import l8.g;
import l8.h;
import rm.n0;
import rm.y;
import tp.m0;

/* loaded from: classes4.dex */
public final class c extends yd.c {

    /* renamed from: q, reason: collision with root package name */
    private final fa.a f33669q;

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

    /* renamed from: s, reason: collision with root package name */
    private final a0 f33671s;

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

    /* renamed from: u, reason: collision with root package name */
    private final a0 f33673u;

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

    /* renamed from: w, reason: collision with root package name */
    private final a0 f33675w;

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

    /* renamed from: y, reason: collision with root package name */
    private final a0 f33677y;

    /* loaded from: classes4.dex */
    static final class a extends l implements p {

        /* renamed from: p, reason: collision with root package name */
        int f33678p;

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

        /* renamed from: qe.c$a$a, reason: collision with other inner class name */
        /* loaded from: classes4.dex */
        public /* synthetic */ class C0780a {

            /* renamed from: a, reason: collision with root package name */
            public static final /* synthetic */ int[] f33681a;

            static {
                int[] iArr = new int[MyMailStatus.values().length];
                try {
                    iArr[MyMailStatus.SUBSCRIBED.ordinal()] = 1;
                } catch (NoSuchFieldError unused) {
                }
                try {
                    iArr[MyMailStatus.WAITLISTED.ordinal()] = 2;
                } catch (NoSuchFieldError unused2) {
                }
                try {
                    iArr[MyMailStatus.NOTSUBSCRIBED.ordinal()] = 3;
                } catch (NoSuchFieldError unused3) {
                }
                try {
                    iArr[MyMailStatus.ELIGIBLE.ordinal()] = 4;
                } catch (NoSuchFieldError unused4) {
                }
                try {
                    iArr[MyMailStatus.UNAUTHORIZED.ordinal()] = 5;
                } catch (NoSuchFieldError unused5) {
                }
                try {
                    iArr[MyMailStatus.LOGGED_OUT.ordinal()] = 6;
                } catch (NoSuchFieldError unused6) {
                }
                f33681a = iArr;
            }
        }

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        a(MyMailStatus myMailStatus, vm.d dVar) {
            super(2, dVar);
            this.f33680r = myMailStatus;
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final vm.d create(Object obj, vm.d dVar) {
            return new a(this.f33680r, dVar);
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            Object f10;
            f10 = wm.d.f();
            int i10 = this.f33678p;
            if (i10 == 0) {
                y.b(obj);
                c cVar = c.this;
                AddressEligibilityBody S = cVar.S();
                this.f33678p = 1;
                obj = cVar.c0(S, this);
                if (obj == f10) {
                    return f10;
                }
            } else {
                if (i10 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                y.b(obj);
            }
            Boolean bool = (Boolean) obj;
            MyMailFlowArguments myMailFlowArguments = (MyMailFlowArguments) c.this.f33669q.p().f();
            Boolean a10 = myMailFlowArguments != null ? kotlin.coroutines.jvm.internal.b.a(myMailFlowArguments.getIsTncAccepted()) : null;
            MyMailStatus myMailStatus = this.f33680r;
            switch (myMailStatus == null ? -1 : C0780a.f33681a[myMailStatus.ordinal()]) {
                case 1:
                    if (!t.b(a10, kotlin.coroutines.jvm.internal.b.a(true))) {
                        c.this.f33669q.o(true);
                        if (!t.b(c.this.f33669q.k().f(), kotlin.coroutines.jvm.internal.b.a(true))) {
                            c.this.f33670r.s();
                            break;
                        } else {
                            c.this.f33674v.s();
                            break;
                        }
                    } else {
                        c.this.f33672t.s();
                        break;
                    }
                case 2:
                case 3:
                case 4:
                case 5:
                    if (t.b(bool, kotlin.coroutines.jvm.internal.b.a(true))) {
                        c.this.f33669q.o(this.f33680r != MyMailStatus.WAITLISTED);
                        if (!t.b(c.this.f33669q.k().f(), kotlin.coroutines.jvm.internal.b.a(true))) {
                            c.this.f33670r.s();
                            break;
                        } else {
                            c.this.f33674v.s();
                            break;
                        }
                    }
                    break;
                case 6:
                    c.this.f33676x.s();
                    break;
            }
            return n0.f34904a;
        }

        @Override // dn.p
        public final Object invoke(m0 m0Var, vm.d dVar) {
            return ((a) create(m0Var, dVar)).invokeSuspend(n0.f34904a);
        }
    }

    /* loaded from: classes4.dex */
    static final class b extends l implements p {

        /* renamed from: p, reason: collision with root package name */
        int f33682p;

        b(vm.d dVar) {
            super(2, dVar);
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final vm.d create(Object obj, vm.d dVar) {
            return new b(dVar);
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            Object f10;
            f10 = wm.d.f();
            int i10 = this.f33682p;
            if (i10 == 0) {
                y.b(obj);
                c cVar = c.this;
                this.f33682p = 1;
                if (yd.c.Y(cVar, null, this, 1, null) == f10) {
                    return f10;
                }
            } else {
                if (i10 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                y.b(obj);
            }
            return n0.f34904a;
        }

        @Override // dn.p
        public final Object invoke(m0 m0Var, vm.d dVar) {
            return ((b) create(m0Var, dVar)).invokeSuspend(n0.f34904a);
        }
    }

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public c(t7.c contextService, g9.d sessionRepository, ka.b userRepository, f analyticsService, fa.a myMailRepository) {
        super(contextService, myMailRepository, sessionRepository, userRepository, analyticsService);
        t.g(contextService, "contextService");
        t.g(sessionRepository, "sessionRepository");
        t.g(userRepository, "userRepository");
        t.g(analyticsService, "analyticsService");
        t.g(myMailRepository, "myMailRepository");
        this.f33669q = myMailRepository;
        g gVar = new g();
        this.f33670r = gVar;
        this.f33671s = gVar;
        g gVar2 = new g();
        this.f33672t = gVar2;
        this.f33673u = gVar2;
        g gVar3 = new g();
        this.f33674v = gVar3;
        this.f33675w = gVar3;
        g gVar4 = new g();
        this.f33676x = gVar4;
        this.f33677y = gVar4;
        f.a.c(analyticsService, "Mailbox_Automated_DropOff_Waitlist", null, 2, null);
    }

    public final void o0(MyMailStatus myMailStatus) {
        h.a.a(this, a1.a(this), null, null, null, new a(myMailStatus, null), 7, null);
    }

    public final a0 p0() {
        return this.f33677y;
    }

    public final a0 q0() {
        return this.f33675w;
    }

    public final a0 r0() {
        return this.f33671s;
    }

    public final a0 s0() {
        return this.f33673u;
    }

    public final boolean t0() {
        return t.b(this.f33669q.k().f(), Boolean.TRUE);
    }

    public final void u0() {
        h.a.a(this, a1.a(this), null, null, null, new b(null), 7, null);
    }
}
