package r8;

import android.app.Application;
import android.content.Context;
import androidx.lifecycle.a0;
import androidx.lifecycle.a1;
import androidx.lifecycle.f0;
import ca.canadapost.core.data.model.ResultWrapper;
import dn.p;
import kotlin.coroutines.jvm.internal.l;
import kotlin.jvm.internal.t;
import l8.d;
import l8.g;
import l8.h;
import l8.i;
import rm.n0;
import rm.y;
import tp.m0;
import tp.o0;
import tp.u1;

/* loaded from: classes.dex */
public abstract class a extends androidx.lifecycle.b implements b, h, l8.c {

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

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

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

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

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

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

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

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

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

    /* renamed from: l, reason: collision with root package name */
    private final f0 f34491l;

    /* renamed from: m, reason: collision with root package name */
    private final f0 f34492m;

    /* renamed from: r8.a$a, reason: collision with other inner class name */
    /* loaded from: classes.dex */
    static final class C0807a extends l implements p {

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

        /* renamed from: r, reason: collision with root package name */
        final /* synthetic */ dn.l f34495r;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        C0807a(dn.l lVar, vm.d dVar) {
            super(2, dVar);
            this.f34495r = lVar;
        }

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

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            Object f10;
            f10 = wm.d.f();
            int i10 = this.f34493p;
            if (i10 == 0) {
                y.b(obj);
                a.this.V().n(kotlin.coroutines.jvm.internal.b.a(false));
                dn.l lVar = this.f34495r;
                this.f34493p = 1;
                obj = lVar.invoke(this);
                if (obj == f10) {
                    return f10;
                }
            } else {
                if (i10 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                y.b(obj);
            }
            ResultWrapper.Error error = (ResultWrapper.Error) obj;
            if (error == null) {
                a.this.b0();
            } else {
                a.this.X(error, true);
            }
            return n0.f34904a;
        }

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

    /* JADX WARN: Illegal instructions before constructor call */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public a(t7.c contextService) {
        super((Application) r0);
        t.g(contextService, "contextService");
        Context a10 = contextService.a();
        t.e(a10, "null cannot be cast to non-null type android.app.Application");
        this.f34482c = contextService;
        this.f34483d = new i(contextService);
        this.f34484e = new d();
        g gVar = new g();
        this.f34485f = gVar;
        this.f34486g = gVar;
        g gVar2 = new g();
        this.f34487h = gVar2;
        this.f34488i = gVar2;
        g gVar3 = new g();
        this.f34489j = gVar3;
        this.f34490k = gVar3;
        f0 f0Var = new f0();
        Boolean bool = Boolean.FALSE;
        f0Var.q(bool);
        this.f34491l = f0Var;
        f0 f0Var2 = new f0();
        f0Var2.q(bool);
        this.f34492m = f0Var2;
    }

    private final void f0() {
        this.f34485f.s();
    }

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

    public final a0 Q() {
        return this.f34490k;
    }

    public final a0 R() {
        return this.f34488i;
    }

    public final a0 S() {
        return this.f34486g;
    }

    public f0 T() {
        return this.f34491l;
    }

    /* JADX INFO: Access modifiers changed from: protected */
    public final g U() {
        return this.f34489j;
    }

    public f0 V() {
        return this.f34492m;
    }

    /* JADX INFO: Access modifiers changed from: protected */
    public final g W() {
        return this.f34487h;
    }

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

    public boolean Y() {
        Boolean bool = (Boolean) V().f();
        if (bool == null || !bool.booleanValue()) {
            return false;
        }
        f0();
        return true;
    }

    public void Z() {
        V().q(Boolean.TRUE);
    }

    public void a0() {
        V().q(Boolean.FALSE);
        this.f34489j.s();
        this.f34487h.s();
    }

    public void b0() {
        this.f34489j.s();
        this.f34487h.s();
    }

    public boolean c0() {
        return e() && g();
    }

    public void d0(dn.l serviceCall) {
        t.g(serviceCall, "serviceCall");
        if (c0()) {
            h.a.a(this, a1.a(this), null, null, this.f34482c.getString(h7.l.f21136e2), new C0807a(serviceCall, null), 3, null);
        }
    }

    public void e0() {
        boolean e10 = e();
        V().q(Boolean.valueOf(e10));
        T().q(Boolean.valueOf(e10));
    }

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

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

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