package hd;

import android.app.Application;
import android.content.Context;
import android.text.Spanned;
import androidx.lifecycle.a0;
import androidx.lifecycle.a1;
import ca.canadapost.core.data.auth.model.Name;
import ca.canadapost.core.data.model.RepositoryError;
import ca.canadapost.core.data.model.ResultWrapper;
import java.util.LinkedHashMap;
import kotlin.jvm.internal.t;
import l8.h;
import rm.n0;
import rm.y;
import tp.m0;
import tp.o0;
import tp.u1;

/* loaded from: classes4.dex */
public final class l extends androidx.lifecycle.b implements l8.h, l8.c {

    /* renamed from: c, reason: collision with root package name */
    private final g9.i f21566c;

    /* renamed from: d, reason: collision with root package name */
    private final /* synthetic */ l8.i f21567d;

    /* renamed from: e, reason: collision with root package name */
    private final /* synthetic */ l8.d f21568e;

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

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

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

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

    /* loaded from: classes4.dex */
    static final class a extends kotlin.coroutines.jvm.internal.l implements dn.p {

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

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

        /* renamed from: s, reason: collision with root package name */
        final /* synthetic */ ka.a f21576s;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        a(Name name, ka.a aVar, vm.d dVar) {
            super(2, dVar);
            this.f21575r = name;
            this.f21576s = aVar;
        }

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

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            Object f10;
            f10 = wm.d.f();
            int i10 = this.f21573p;
            if (i10 == 0) {
                y.b(obj);
                g9.i iVar = l.this.f21566c;
                Name name = this.f21575r;
                ka.a aVar = this.f21576s;
                this.f21573p = 1;
                obj = iVar.j(name, aVar, 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) {
                l.this.f21571h.s();
            } else if (resultWrapper instanceof ResultWrapper.Error) {
                l.this.V((ResultWrapper.Error) resultWrapper, true);
            }
            return n0.f34904a;
        }

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

    /* JADX WARN: Illegal instructions before constructor call */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public l(t7.c contextService, g9.i l2Repository, d9.f analyticsService) {
        super((Application) r0);
        t.g(contextService, "contextService");
        t.g(l2Repository, "l2Repository");
        t.g(analyticsService, "analyticsService");
        Context a10 = contextService.a();
        t.e(a10, "null cannot be cast to non-null type android.app.Application");
        this.f21566c = l2Repository;
        this.f21567d = new l8.i(contextService);
        this.f21568e = new l8.d();
        l8.g gVar = new l8.g();
        this.f21569f = gVar;
        this.f21570g = gVar;
        l8.g gVar2 = new l8.g();
        this.f21571h = gVar2;
        this.f21572i = gVar2;
        LinkedHashMap linkedHashMap = new LinkedHashMap();
        linkedHashMap.put("e.Var13", l2Repository.o());
        analyticsService.c("User-IdentityVerification_L2_Failure", linkedHashMap);
    }

    @Override // l8.h
    public a0 J() {
        return this.f21567d.J();
    }

    public final CharSequence S() {
        Spanned a10 = androidx.core.text.b.a(P().getString(ed.m.f16948e, Integer.valueOf(3 - this.f21566c.e())), 0);
        t.f(a10, "fromHtml(...)");
        return a10;
    }

    public final a0 T() {
        return this.f21572i;
    }

    public final a0 U() {
        return this.f21570g;
    }

    public void V(ResultWrapper.Error error, boolean z10) {
        t.g(error, "error");
        this.f21568e.a(error, z10);
    }

    public final void W() {
        this.f21569f.s();
    }

    public final void X() {
        ka.a aVar = (ka.a) this.f21566c.i().f();
        Name name = (Name) this.f21566c.d().f();
        if (aVar == null || name == null) {
            V(new ResultWrapper.Error(null, null, RepositoryError.Unknown, null, 8, null), true);
        } else {
            h.a.a(this, a1.a(this), null, null, null, new a(name, aVar, null), 7, null);
        }
    }

    @Override // l8.c
    public a0 o() {
        return this.f21568e.o();
    }

    @Override // l8.c
    public a0 t() {
        return this.f21568e.t();
    }

    @Override // l8.h
    public u1 u(m0 m0Var, vm.g context, o0 start, String str, dn.p block) {
        t.g(m0Var, "<this>");
        t.g(context, "context");
        t.g(start, "start");
        t.g(block, "block");
        return this.f21567d.u(m0Var, context, start, str, block);
    }
}
