package vd;

import android.app.Application;
import android.content.Context;
import androidx.lifecycle.a0;
import androidx.lifecycle.a1;
import ca.canadapost.core.data.aws.model.AndroidDeviceType;
import ca.canadapost.core.data.model.RepositoryError;
import ca.canadapost.core.data.model.ResultWrapper;
import ca.canadapost.core.data.profile.model.OneToOneEmailRequest;
import kotlin.jvm.internal.g0;
import kotlin.jvm.internal.p0;
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 q extends androidx.lifecycle.b implements l8.h, l8.c {

    /* renamed from: p, reason: collision with root package name */
    static final /* synthetic */ kn.l[] f39625p = {p0.h(new g0(q.class, "doubleClickGuard", "getDoubleClickGuard()Z", 0))};

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

    /* renamed from: d, reason: collision with root package name */
    private final ca.b f39627d;

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

    /* renamed from: f, reason: collision with root package name */
    private final g9.l f39629f;

    /* renamed from: g, reason: collision with root package name */
    private final ja.d f39630g;

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

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

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

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

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

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

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

    /* renamed from: o, reason: collision with root package name */
    private final l8.e f39638o;

    /* 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 f39639p;

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

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

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            Object f10;
            f10 = wm.d.f();
            int i10 = this.f39639p;
            if (i10 == 0) {
                y.b(obj);
                g9.l lVar = q.this.f39629f;
                this.f39639p = 1;
                if (lVar.e(this) == f10) {
                    return f10;
                }
            } else {
                if (i10 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                y.b(obj);
            }
            q.this.f39634k.s();
            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 kotlin.coroutines.jvm.internal.l implements dn.p {

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

        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;
            Object U;
            f10 = wm.d.f();
            int i10 = this.f39641p;
            if (i10 == 0) {
                y.b(obj);
                AndroidDeviceType androidDeviceType = AndroidDeviceType.MOBILE;
                String W = q.this.W();
                String c10 = q.this.X().c();
                kotlin.jvm.internal.t.f(c10, "getLanguage(...)");
                OneToOneEmailRequest oneToOneEmailRequest = new OneToOneEmailRequest(W, c10, new OneToOneEmailRequest.OneToOneEmailAnalytics(androidDeviceType, null, null, null, null, null, null, 126, null));
                ka.c cVar = q.this.f39628e;
                this.f39641p = 1;
                U = cVar.U(oneToOneEmailRequest, this);
                if (U == f10) {
                    return f10;
                }
            } else {
                if (i10 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                y.b(obj);
                U = obj;
            }
            ResultWrapper.Error error = (ResultWrapper.Error) U;
            if (error == null) {
                q.this.f0();
            } else if (error.getError() == RepositoryError.ServiceError) {
                q.this.e0();
            } else if (error.getError() == RepositoryError.NoNetworkError) {
                q.this.b0(new ResultWrapper.Error(error.getException(), error.getMessage(), error.getError(), null, 8, null), true);
            } else {
                q.this.e0();
            }
            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: Illegal instructions before constructor call */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public q(t7.c contextService, ca.b languageService, ka.c userProfileRepository, g9.l userAuthenticationRepository, ja.d sharedPreferencesService, String email) {
        super((Application) r0);
        kotlin.jvm.internal.t.g(contextService, "contextService");
        kotlin.jvm.internal.t.g(languageService, "languageService");
        kotlin.jvm.internal.t.g(userProfileRepository, "userProfileRepository");
        kotlin.jvm.internal.t.g(userAuthenticationRepository, "userAuthenticationRepository");
        kotlin.jvm.internal.t.g(sharedPreferencesService, "sharedPreferencesService");
        kotlin.jvm.internal.t.g(email, "email");
        Context a10 = contextService.a();
        kotlin.jvm.internal.t.e(a10, "null cannot be cast to non-null type android.app.Application");
        this.f39626c = contextService;
        this.f39627d = languageService;
        this.f39628e = userProfileRepository;
        this.f39629f = userAuthenticationRepository;
        this.f39630g = sharedPreferencesService;
        this.f39631h = email;
        this.f39632i = new l8.i(contextService);
        this.f39633j = new l8.d();
        l8.g gVar = new l8.g();
        this.f39634k = gVar;
        this.f39635l = gVar;
        l8.g gVar2 = new l8.g();
        this.f39636m = gVar2;
        this.f39637n = gVar2;
        this.f39638o = new l8.e(false, 0L, 3, null);
    }

    private final boolean V() {
        return this.f39638o.a(this, f39625p[0]).booleanValue();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final void e0() {
        this.f39636m.q(this.f39626c.getString(ld.m.f28019y0));
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final void f0() {
        this.f39636m.q(this.f39626c.d(ld.m.f28021z0, this.f39631h));
    }

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

    public final String W() {
        return this.f39631h;
    }

    public final ca.b X() {
        return this.f39627d;
    }

    public final a0 Y() {
        return this.f39635l;
    }

    public final ja.d Z() {
        return this.f39630g;
    }

    public final a0 a0() {
        return this.f39637n;
    }

    public void b0(ResultWrapper.Error error, boolean z10) {
        kotlin.jvm.internal.t.g(error, "error");
        this.f39633j.a(error, z10);
    }

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

    public final void d0() {
        if (V()) {
            return;
        }
        h.a.a(this, a1.a(this), null, null, null, new b(null), 7, null);
    }

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

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

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