package u8;

import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.accessibility.AccessibilityManager;
import android.view.inputmethod.InputMethodManager;
import androidx.lifecycle.c1;
import androidx.lifecycle.g0;
import ca.canadapost.core.common.customView.h0;
import ca.canadapost.core.data.model.Event;
import ca.canadapost.core.data.model.RepositoryError;
import ca.canadapost.core.data.model.RepositoryErrorEvent;
import kotlin.Metadata;
import o8.d0;
import rm.n0;
import u8.g;

@Metadata(d1 = {"\u0000N\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0010\u000b\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0007\n\u0002\u0018\u0002\n\u0002\b\u0007\n\u0002\u0018\u0002\n\u0002\b\u0006\b'\u0018\u00002\u00020\u00012\u00020\u00022\u00020\u0003B\u0007¢\u0006\u0004\b*\u0010+J\u0010\u0010\u0007\u001a\u00020\u00062\u0006\u0010\u0005\u001a\u00020\u0004H\u0002J\u0010\u0010\b\u001a\u00020\u00062\u0006\u0010\u0005\u001a\u00020\u0004H\u0002J\b\u0010\t\u001a\u00020\u0006H\u0002J\u0012\u0010\f\u001a\u00020\u00062\b\u0010\u000b\u001a\u0004\u0018\u00010\nH\u0016J\u001a\u0010\u000f\u001a\u00020\u00062\u0006\u0010\u000e\u001a\u00020\r2\b\u0010\u000b\u001a\u0004\u0018\u00010\nH\u0016J\u0010\u0010\u0010\u001a\u00020\u00062\u0006\u0010\u0005\u001a\u00020\u0004H\u0004J\u0006\u0010\u0011\u001a\u00020\u0006J\u0006\u0010\u0013\u001a\u00020\u0012J\b\u0010\u0014\u001a\u00020\u0012H\u0016J\b\u0010\u0015\u001a\u00020\u0006H\u0016R\"\u0010\u001d\u001a\u00020\u00168\u0004@\u0004X\u0085.¢\u0006\u0012\n\u0004\b\u0017\u0010\u0018\u001a\u0004\b\u0019\u0010\u001a\"\u0004\b\u001b\u0010\u001cR\"\u0010%\u001a\u00020\u001e8\u0004@\u0004X\u0085.¢\u0006\u0012\n\u0004\b\u001f\u0010 \u001a\u0004\b!\u0010\"\"\u0004\b#\u0010$R\u0016\u0010)\u001a\u00020&8\u0002@\u0002X\u0082.¢\u0006\u0006\n\u0004\b'\u0010(¨\u0006,"}, d2 = {"Lu8/b;", "Landroidx/fragment/app/f;", "", "Ly7/i;", "Lca/canadapost/core/data/model/RepositoryErrorEvent;", "errorEvent", "Lrm/n0;", "A", "B", "F", "Landroid/os/Bundle;", "savedInstanceState", "onCreate", "Landroid/view/View;", "view", "onViewCreated", "z", "C", "", "D", "E", "onResume", "Landroidx/lifecycle/c1$c;", "p", "Landroidx/lifecycle/c1$c;", "y", "()Landroidx/lifecycle/c1$c;", "setViewModelFactory", "(Landroidx/lifecycle/c1$c;)V", "viewModelFactory", "Laa/a;", "q", "Laa/a;", "x", "()Laa/a;", "setIInAppReviewRepository", "(Laa/a;)V", "iInAppReviewRepository", "Lo8/d0;", "r", "Lo8/d0;", "navViewModel", "<init>", "()V", "core_common_productionRelease"}, k = 1, mv = {1, 9, 0})
/* loaded from: classes.dex */
public abstract class b extends androidx.fragment.app.f implements y7.i {

    /* renamed from: p, reason: collision with root package name and from kotlin metadata */
    protected c1.c viewModelFactory;

    /* renamed from: q, reason: collision with root package name and from kotlin metadata */
    protected aa.a iInAppReviewRepository;

    /* renamed from: r, reason: collision with root package name and from kotlin metadata */
    private d0 navViewModel;

    /* loaded from: classes.dex */
    public /* synthetic */ class a {

        /* renamed from: a, reason: collision with root package name */
        public static final /* synthetic */ int[] f36986a;

        static {
            int[] iArr = new int[RepositoryError.values().length];
            try {
                iArr[RepositoryError.NoNetworkError.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            f36986a = iArr;
        }
    }

    /* renamed from: u8.b$b, reason: collision with other inner class name */
    /* loaded from: classes.dex */
    static final class C0879b extends kotlin.jvm.internal.v implements dn.l {
        C0879b() {
            super(1);
        }

        public final void a(Boolean bool) {
            kotlin.jvm.internal.t.d(bool);
            if (bool.booleanValue()) {
                w8.b.f40952a.d(b.this.getActivity());
            }
        }

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

    /* loaded from: classes.dex */
    static final class c extends kotlin.jvm.internal.v implements dn.l {
        c() {
            super(1);
        }

        public final void a(Event event) {
            Boolean bool = (Boolean) event.getContentIfNotHandled();
            if (bool != null) {
                b bVar = b.this;
                if (bool.booleanValue()) {
                    aa.a x10 = bVar.x();
                    androidx.fragment.app.k requireActivity = bVar.requireActivity();
                    kotlin.jvm.internal.t.f(requireActivity, "requireActivity(...)");
                    x10.b(requireActivity);
                }
            }
        }

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

    /* loaded from: classes.dex */
    static final class d implements g0, kotlin.jvm.internal.n {

        /* renamed from: a, reason: collision with root package name */
        private final /* synthetic */ dn.l f36989a;

        d(dn.l function) {
            kotlin.jvm.internal.t.g(function, "function");
            this.f36989a = function;
        }

        @Override // kotlin.jvm.internal.n
        public final rm.i b() {
            return this.f36989a;
        }

        @Override // androidx.lifecycle.g0
        public final /* synthetic */ void d(Object obj) {
            this.f36989a.invoke(obj);
        }

        public final boolean equals(Object obj) {
            if ((obj instanceof g0) && (obj instanceof kotlin.jvm.internal.n)) {
                return kotlin.jvm.internal.t.b(b(), ((kotlin.jvm.internal.n) obj).b());
            }
            return false;
        }

        public final int hashCode() {
            return b().hashCode();
        }
    }

    private final void A(RepositoryErrorEvent repositoryErrorEvent) {
        if (repositoryErrorEvent.getIntrusive()) {
            g.f36993k.i(getContext()).x(getContext());
            return;
        }
        Context context = getContext();
        h0.b(getContext(), getView(), context != null ? context.getString(h7.l.I3) : null, 0, false, false);
    }

    private final void B(RepositoryErrorEvent repositoryErrorEvent) {
        String message = repositoryErrorEvent.getMessage();
        String message2 = !(message == null || message.length() == 0) ? repositoryErrorEvent.getMessage() : getString(h7.l.f21161j2);
        String title = repositoryErrorEvent.getTitle();
        String title2 = !(title == null || title.length() == 0) ? repositoryErrorEvent.getTitle() : getString(h7.l.f21154i0);
        if (!repositoryErrorEvent.getIntrusive()) {
            h0.b(getContext(), getView(), message2, 0, false, false);
            return;
        }
        g.a aVar = g.f36993k;
        Context context = getContext();
        if (message2 == null) {
            message2 = "";
        }
        aVar.j(context, message2, title2).x(getContext());
    }

    private final void F() {
        d9.a.f15931a.g((getResources().getConfiguration().uiMode & 48) == 32 ? "Dark mode" : "Light mode");
    }

    public final void C() {
        androidx.fragment.app.k activity = getActivity();
        if (activity != null) {
            Object systemService = activity.getSystemService("input_method");
            kotlin.jvm.internal.t.e(systemService, "null cannot be cast to non-null type android.view.inputmethod.InputMethodManager");
            InputMethodManager inputMethodManager = (InputMethodManager) systemService;
            View currentFocus = activity.getCurrentFocus();
            if (currentFocus == null) {
                currentFocus = new View(activity);
            }
            kotlin.jvm.internal.t.d(currentFocus);
            inputMethodManager.hideSoftInputFromWindow(currentFocus.getApplicationWindowToken(), 0);
        }
    }

    public final boolean D() {
        Object systemService = requireActivity().getSystemService("accessibility");
        kotlin.jvm.internal.t.e(systemService, "null cannot be cast to non-null type android.view.accessibility.AccessibilityManager");
        return ((AccessibilityManager) systemService).isEnabled();
    }

    public boolean E() {
        return false;
    }

    @Override // androidx.fragment.app.f
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        om.a.b(this);
        this.navViewModel = (d0) new c1(this, y()).a(d0.class);
        F();
    }

    @Override // androidx.fragment.app.f
    public void onResume() {
        super.onResume();
        if (D()) {
            d0 d0Var = this.navViewModel;
            if (d0Var == null) {
                kotlin.jvm.internal.t.y("navViewModel");
                d0Var = null;
            }
            d0Var.y0().j(getViewLifecycleOwner(), new d(new C0879b()));
        }
    }

    @Override // androidx.fragment.app.f
    public void onViewCreated(View view, Bundle bundle) {
        kotlin.jvm.internal.t.g(view, "view");
        super.onViewCreated(view, bundle);
        x().c().j(getViewLifecycleOwner(), new d(new c()));
    }

    /* JADX INFO: Access modifiers changed from: protected */
    public final aa.a x() {
        aa.a aVar = this.iInAppReviewRepository;
        if (aVar != null) {
            return aVar;
        }
        kotlin.jvm.internal.t.y("iInAppReviewRepository");
        return null;
    }

    /* JADX INFO: Access modifiers changed from: protected */
    public final c1.c y() {
        c1.c cVar = this.viewModelFactory;
        if (cVar != null) {
            return cVar;
        }
        kotlin.jvm.internal.t.y("viewModelFactory");
        return null;
    }

    /* JADX INFO: Access modifiers changed from: protected */
    public final void z(RepositoryErrorEvent errorEvent) {
        kotlin.jvm.internal.t.g(errorEvent, "errorEvent");
        if (a.f36986a[errorEvent.getError().ordinal()] == 1) {
            A(errorEvent);
        } else {
            B(errorEvent);
        }
    }
}
