package m8;

import androidx.lifecycle.a0;
import androidx.lifecycle.f0;
import ca.canadapost.core.common.more.a;
import ca.canadapost.core.data.auth.model.UserProfile;
import java.util.ArrayList;
import java.util.List;
import kotlin.jvm.internal.t;
import o8.b0;

/* loaded from: classes.dex */
public final class k implements h {

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

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

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

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

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

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

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

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

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

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

    public k(t7.c contextService, g9.d sessionRepository, ka.b profileRepository, p9.h featureFlagRepository) {
        t.g(contextService, "contextService");
        t.g(sessionRepository, "sessionRepository");
        t.g(profileRepository, "profileRepository");
        t.g(featureFlagRepository, "featureFlagRepository");
        this.f28768a = contextService;
        this.f28769b = sessionRepository;
        this.f28770c = profileRepository;
        this.f28771d = featureFlagRepository;
        f0 f0Var = new f0(new ArrayList());
        this.f28772e = f0Var;
        this.f28773f = f0Var;
        f0 f0Var2 = new f0(new ArrayList());
        this.f28774g = f0Var2;
        this.f28775h = f0Var2;
        f0 f0Var3 = new f0();
        this.f28776i = f0Var3;
        this.f28777j = f0Var3;
        f0Var.q(e());
        if (featureFlagRepository.d(p9.a.SENDING_EXPERIENCE)) {
            f0Var2.q(f());
        }
    }

    private final List e() {
        Boolean bool = (Boolean) this.f28769b.i().f();
        if (bool == null) {
            bool = Boolean.FALSE;
        }
        boolean booleanValue = bool.booleanValue();
        ArrayList arrayList = new ArrayList();
        j jVar = j.f28767a;
        arrayList.add(jVar.d());
        arrayList.add(jVar.r());
        arrayList.add(jVar.l());
        arrayList.add(jVar.k());
        arrayList.add(jVar.h());
        arrayList.add(jVar.e());
        arrayList.add(jVar.i(this.f28771d));
        arrayList.add(jVar.n());
        if (booleanValue) {
            arrayList.add(jVar.m((UserProfile) this.f28770c.a().f()));
        } else {
            arrayList.add(jVar.p());
        }
        arrayList.add(jVar.q());
        if (this.f28771d.d(p9.a.AT_HOME_PICKUP)) {
            arrayList.add(jVar.j());
        }
        return arrayList;
    }

    private final List f() {
        ArrayList arrayList = new ArrayList();
        arrayList.add(new a.C0205a(h7.l.f21151h2));
        j8.b bVar = j8.b.f23978a;
        arrayList.add(new a.b(bVar.i()));
        arrayList.add(new a.b(bVar.g()));
        if (this.f28771d.d(p9.a.AT_HOME_PICKUP)) {
            arrayList.add(new a.b(bVar.f()));
        }
        arrayList.add(new a.b(bVar.c()));
        arrayList.add(new a.b(bVar.e()));
        arrayList.add(new a.C0205a(h7.l.f21199r0));
        arrayList.add(new a.b(bVar.a()));
        arrayList.add(new a.b(bVar.b()));
        arrayList.add(new a.b(bVar.d()));
        arrayList.add(new a.C0205a(h7.l.P1));
        arrayList.add(new a.b(bVar.h()));
        arrayList.add(new a.b(bVar.j()));
        return arrayList;
    }

    @Override // m8.h
    public a0 a() {
        return this.f28775h;
    }

    @Override // m8.h
    public void b(i moduleType) {
        t.g(moduleType, "moduleType");
        d(moduleType.getId());
    }

    @Override // m8.h
    public a0 c() {
        return this.f28777j;
    }

    @Override // m8.h
    public void d(int i10) {
        List<b0> list;
        b0 b0Var = (b0) this.f28776i.f();
        if ((b0Var == null || b0Var.h().getId() != i10) && (list = (List) this.f28772e.f()) != null) {
            for (b0 b0Var2 : list) {
                if (b0Var2.h().getId() == i10) {
                    b0Var2.o(true);
                    this.f28776i.q(b0Var2);
                } else {
                    b0Var2.o(false);
                }
            }
        }
    }

    @Override // m8.h
    public a0 getItems() {
        return this.f28773f;
    }
}
