package ne;

import android.text.Spannable;
import androidx.lifecycle.a0;
import androidx.lifecycle.a1;
import androidx.lifecycle.y0;
import ca.canadapost.core.data.model.ResultWrapper;
import ca.canadapost.core.data.mymail.model.MyMailTncResponse;
import d9.f;
import dn.p;
import kotlin.coroutines.jvm.internal.l;
import kotlin.jvm.internal.t;
import kotlin.jvm.internal.v;
import l8.h;
import rm.n0;
import rm.y;
import tp.m0;
import u8.o;

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

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

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

    /* renamed from: s, reason: collision with root package name */
    private final l8.g f29906s;

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

    /* renamed from: u, reason: collision with root package name */
    private final l8.g f29908u;

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

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

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

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

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

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

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

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            Object f10;
            f10 = wm.d.f();
            int i10 = this.f29912p;
            if (i10 == 0) {
                y.b(obj);
                fa.a aVar = a.this.f29905r;
                this.f29912p = 1;
                obj = aVar.f(this);
                if (obj == f10) {
                    return f10;
                }
            } else {
                if (i10 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                y.b(obj);
            }
            ResultWrapper resultWrapper = (ResultWrapper) obj;
            if (!(resultWrapper instanceof ResultWrapper.Success) && (resultWrapper instanceof ResultWrapper.Error)) {
                a.this.b0((ResultWrapper.Error) resultWrapper, true);
                a.this.f29908u.s();
            }
            return n0.f34904a;
        }

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

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

        @Override // dn.l
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public final Spannable invoke(MyMailTncResponse it) {
            t.g(it, "it");
            return a.this.f29904q.b() ? new o(it.getEn().getTerms()).c().i() : new o(it.getFr().getTerms()).c().i();
        }
    }

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

        @Override // dn.l
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public final String invoke(MyMailTncResponse it) {
            t.g(it, "it");
            return a.this.f29904q.b() ? it.getEn().getTitle() : it.getFr().getTitle();
        }
    }

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public a(t7.c contextService, g9.d sessionRepository, ka.b userRepository, d9.f analyticsService, ca.a languageService, 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(languageService, "languageService");
        t.g(myMailRepository, "myMailRepository");
        this.f29904q = languageService;
        this.f29905r = myMailRepository;
        l8.g gVar = new l8.g();
        this.f29906s = gVar;
        this.f29907t = gVar;
        l8.g gVar2 = new l8.g();
        this.f29908u = gVar2;
        this.f29909v = gVar2;
        this.f29910w = y0.a(myMailRepository.A(), new c());
        this.f29911x = y0.a(myMailRepository.A(), new b());
        n0();
        f.a.c(analyticsService, "Mailbox_Automated_DropOff_Terms_and_Conditions_Read", null, 2, null);
    }

    private final void n0() {
        h.a.a(this, a1.a(this), null, null, null, new C0685a(null), 7, null);
    }

    public final void l0() {
        this.f29906s.q(Boolean.TRUE);
        g0("mailboxTermsConditions_ClickAgree_Adobe", "Mailbox_Automated_DropOff_Terms_and_Conditions_Read");
    }

    public final void m0() {
        this.f29906s.q(Boolean.FALSE);
        g0("mailboxTermsConditions_ClickDontAgree_Adobe", "Mailbox_Automated_DropOff_Terms_and_Conditions_Read");
    }

    public final a0 o0() {
        return this.f29909v;
    }

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

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

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