package ib;

import ca.canadapost.core.data.db.cupboard.model.CustomsFormObject;
import d9.f;
import java.util.ArrayList;
import java.util.List;

/* loaded from: classes4.dex */
public final class q0 extends h {
    private final androidx.lifecycle.a0 A;
    private final l8.g B;
    private final androidx.lifecycle.a0 C;
    private final androidx.lifecycle.f0 D;
    private final androidx.lifecycle.a0 E;

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

    /* renamed from: s, reason: collision with root package name */
    private final p9.h f22944s;

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

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

    /* renamed from: v, reason: collision with root package name */
    private final w8.r f22947v;

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

    /* renamed from: x, reason: collision with root package name */
    private final androidx.lifecycle.f0 f22949x;

    /* renamed from: y, reason: collision with root package name */
    private final androidx.lifecycle.a0 f22950y;

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

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes4.dex */
    public static final class a extends kotlin.coroutines.jvm.internal.l implements dn.p {

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

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

        /* JADX INFO: Access modifiers changed from: package-private */
        /* renamed from: ib.q0$a$a, reason: collision with other inner class name */
        /* loaded from: classes4.dex */
        public static final class C0484a extends kotlin.coroutines.jvm.internal.l implements dn.p {

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

            /* renamed from: q, reason: collision with root package name */
            final /* synthetic */ q0 f22956q;

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

            /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
            C0484a(q0 q0Var, CustomsFormObject customsFormObject, vm.d dVar) {
                super(2, dVar);
                this.f22956q = q0Var;
                this.f22957r = customsFormObject;
            }

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

            @Override // kotlin.coroutines.jvm.internal.a
            public final Object invokeSuspend(Object obj) {
                wm.d.f();
                if (this.f22955p != 0) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                rm.y.b(obj);
                return kotlin.coroutines.jvm.internal.b.a(this.f22956q.f22946u.a(this.f22957r));
            }

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

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

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

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            Object f10;
            f10 = wm.d.f();
            int i10 = this.f22952p;
            if (i10 == 0) {
                rm.y.b(obj);
                tp.i0 b10 = tp.a1.b();
                C0484a c0484a = new C0484a(q0.this, this.f22954r, null);
                this.f22952p = 1;
                if (tp.i.g(b10, c0484a, this) == f10) {
                    return f10;
                }
            } else {
                if (i10 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                rm.y.b(obj);
            }
            q0.this.n0();
            return rm.n0.f34904a;
        }

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

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes4.dex */
    public static final class b extends kotlin.coroutines.jvm.internal.l implements dn.p {

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

        /* JADX INFO: Access modifiers changed from: package-private */
        /* loaded from: classes4.dex */
        public static final class a extends kotlin.jvm.internal.v implements dn.a {

            /* renamed from: p, reason: collision with root package name */
            final /* synthetic */ q0 f22960p;

            /* renamed from: q, reason: collision with root package name */
            final /* synthetic */ CustomsFormObject f22961q;

            /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
            a(q0 q0Var, CustomsFormObject customsFormObject) {
                super(0);
                this.f22960p = q0Var;
                this.f22961q = customsFormObject;
            }

            @Override // dn.a
            public /* bridge */ /* synthetic */ Object invoke() {
                m265invoke();
                return rm.n0.f34904a;
            }

            /* renamed from: invoke, reason: collision with other method in class */
            public final void m265invoke() {
                this.f22960p.t0(this.f22961q);
            }
        }

        /* JADX INFO: Access modifiers changed from: package-private */
        /* renamed from: ib.q0$b$b, reason: collision with other inner class name */
        /* loaded from: classes4.dex */
        public static final class C0485b extends kotlin.jvm.internal.v implements dn.a {

            /* renamed from: p, reason: collision with root package name */
            final /* synthetic */ q0 f22962p;

            /* renamed from: q, reason: collision with root package name */
            final /* synthetic */ CustomsFormObject f22963q;

            /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
            C0485b(q0 q0Var, CustomsFormObject customsFormObject) {
                super(0);
                this.f22962p = q0Var;
                this.f22963q = customsFormObject;
            }

            @Override // dn.a
            public /* bridge */ /* synthetic */ Object invoke() {
                m266invoke();
                return rm.n0.f34904a;
            }

            /* renamed from: invoke, reason: collision with other method in class */
            public final void m266invoke() {
                this.f22962p.D.n(this.f22963q);
            }
        }

        /* JADX INFO: Access modifiers changed from: package-private */
        /* loaded from: classes4.dex */
        public static final class c extends kotlin.jvm.internal.v implements dn.a {

            /* renamed from: p, reason: collision with root package name */
            final /* synthetic */ q0 f22964p;

            /* renamed from: q, reason: collision with root package name */
            final /* synthetic */ CustomsFormObject f22965q;

            /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
            c(q0 q0Var, CustomsFormObject customsFormObject) {
                super(0);
                this.f22964p = q0Var;
                this.f22965q = customsFormObject;
            }

            @Override // dn.a
            public /* bridge */ /* synthetic */ Object invoke() {
                m267invoke();
                return rm.n0.f34904a;
            }

            /* renamed from: invoke, reason: collision with other method in class */
            public final void m267invoke() {
                this.f22964p.m0(this.f22965q);
            }
        }

        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.f22958p;
            if (i10 == 0) {
                rm.y.b(obj);
                q0 q0Var = q0.this;
                this.f22958p = 1;
                obj = q0Var.s0(this);
                if (obj == f10) {
                    return f10;
                }
            } else {
                if (i10 != 1) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                rm.y.b(obj);
            }
            ArrayList arrayList = new ArrayList();
            for (CustomsFormObject customsFormObject : (List) obj) {
                String nickName = customsFormObject.nickName;
                kotlin.jvm.internal.t.f(nickName, "nickName");
                String str = customsFormObject.creationDateString;
                if (str == null) {
                    str = q0.this.f22943r.getString(b1.f22580c0);
                }
                String str2 = str;
                kotlin.jvm.internal.t.d(str2);
                arrayList.add(new j(nickName, str2, new a(q0.this, customsFormObject), new C0485b(q0.this, customsFormObject), new c(q0.this, customsFormObject)));
            }
            q0.this.f22949x.q(arrayList);
            return rm.n0.f34904a;
        }

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

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes4.dex */
    public static final class c extends kotlin.coroutines.jvm.internal.d {

        /* renamed from: p, reason: collision with root package name */
        /* synthetic */ Object f22966p;

        /* renamed from: r, reason: collision with root package name */
        int f22968r;

        c(vm.d dVar) {
            super(dVar);
        }

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            this.f22966p = obj;
            this.f22968r |= Integer.MIN_VALUE;
            return q0.this.s0(this);
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes4.dex */
    public static final class d extends kotlin.coroutines.jvm.internal.l implements dn.p {

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

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

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

        @Override // kotlin.coroutines.jvm.internal.a
        public final Object invokeSuspend(Object obj) {
            wm.d.f();
            if (this.f22969p != 0) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            rm.y.b(obj);
            return q0.this.f22946u.getAll();
        }

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

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public q0(t7.c contextService, p9.h featureFlagRepository, ja.d sharedPreferencesService, s0 customsFormObjectDataManager, w8.r shareDataService, ca.a languageService, d9.f analyticsService) {
        super(contextService, featureFlagRepository, sharedPreferencesService, languageService);
        kotlin.jvm.internal.t.g(contextService, "contextService");
        kotlin.jvm.internal.t.g(featureFlagRepository, "featureFlagRepository");
        kotlin.jvm.internal.t.g(sharedPreferencesService, "sharedPreferencesService");
        kotlin.jvm.internal.t.g(customsFormObjectDataManager, "customsFormObjectDataManager");
        kotlin.jvm.internal.t.g(shareDataService, "shareDataService");
        kotlin.jvm.internal.t.g(languageService, "languageService");
        kotlin.jvm.internal.t.g(analyticsService, "analyticsService");
        this.f22943r = contextService;
        this.f22944s = featureFlagRepository;
        this.f22945t = sharedPreferencesService;
        this.f22946u = customsFormObjectDataManager;
        this.f22947v = shareDataService;
        this.f22948w = languageService;
        androidx.lifecycle.f0 f0Var = new androidx.lifecycle.f0();
        this.f22949x = f0Var;
        this.f22950y = f0Var;
        l8.g gVar = new l8.g();
        this.f22951z = gVar;
        this.A = gVar;
        l8.g gVar2 = new l8.g();
        this.B = gVar2;
        this.C = gVar2;
        androidx.lifecycle.f0 f0Var2 = new androidx.lifecycle.f0();
        this.D = f0Var2;
        this.E = f0Var2;
        f.a.c(analyticsService, "CustomsQRcodesummary", null, 2, null);
        n0();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final void m0(CustomsFormObject customsFormObject) {
        tp.k.d(androidx.lifecycle.a1.a(this), null, null, new a(customsFormObject, null), 3, null);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final void n0() {
        tp.k.d(androidx.lifecycle.a1.a(this), null, null, new b(null), 3, null);
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX WARN: Removed duplicated region for block: B:15:0x0031  */
    /* JADX WARN: Removed duplicated region for block: B:8:0x0023  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object s0(vm.d dVar) {
        c cVar;
        Object f10;
        int i10;
        if (dVar instanceof c) {
            cVar = (c) dVar;
            int i11 = cVar.f22968r;
            if ((i11 & Integer.MIN_VALUE) != 0) {
                cVar.f22968r = i11 - Integer.MIN_VALUE;
                Object obj = cVar.f22966p;
                f10 = wm.d.f();
                i10 = cVar.f22968r;
                if (i10 != 0) {
                    rm.y.b(obj);
                    tp.i0 b10 = tp.a1.b();
                    d dVar2 = new d(null);
                    cVar.f22968r = 1;
                    obj = tp.i.g(b10, dVar2, cVar);
                    if (obj == f10) {
                        return f10;
                    }
                } else {
                    if (i10 != 1) {
                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                    }
                    rm.y.b(obj);
                }
                kotlin.jvm.internal.t.f(obj, "withContext(...)");
                return obj;
            }
        }
        cVar = new c(dVar);
        Object obj2 = cVar.f22966p;
        f10 = wm.d.f();
        i10 = cVar.f22968r;
        if (i10 != 0) {
        }
        kotlin.jvm.internal.t.f(obj2, "withContext(...)");
        return obj2;
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final void t0(CustomsFormObject customsFormObject) {
        this.f22947v.d("CUSTOMS_FORM_SHARE_DATA_CUSTOMS_FORM_OBJECT_VIEWMODEL", new s(customsFormObject, this.f22948w));
        this.B.s();
    }

    public final s l0(CustomsFormObject customsFormObject) {
        kotlin.jvm.internal.t.g(customsFormObject, "customsFormObject");
        return new s(customsFormObject, this.f22948w);
    }

    public final androidx.lifecycle.a0 o0() {
        return this.f22950y;
    }

    public final androidx.lifecycle.a0 p0() {
        return this.C;
    }

    public final androidx.lifecycle.a0 q0() {
        return this.A;
    }

    public final androidx.lifecycle.a0 r0() {
        return this.E;
    }

    public final void u0() {
        this.f22951z.s();
        this.f22949x.q(null);
    }

    public final void v0() {
        this.f22947v.c();
        this.f22951z.s();
    }
}
