package ca.canadapost.module.sendingexperience;

import android.os.Bundle;
import androidx.activity.h;
import androidx.databinding.n;
import androidx.fragment.app.f;
import androidx.lifecycle.b1;
import androidx.lifecycle.c1;
import androidx.lifecycle.d1;
import androidx.navigation.fragment.NavHostFragment;
import ca.canadapost.core.data.model.CoreConstants;
import ca.canadapost.module.sendingexperience.SendingExperienceActivity;
import g.d;
import kotlin.Metadata;
import kotlin.jvm.internal.p0;
import kotlin.jvm.internal.t;
import kotlin.jvm.internal.v;
import m8.i;
import mf.e;
import mf.j;
import n8.m;
import rm.o;
import v4.p;

@Metadata(d1 = {"\u0000H\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0006\b\u0007\u0018\u00002\u00020\u0001B\u0007¢\u0006\u0004\b\u001e\u0010\u001fJ\b\u0010\u0003\u001a\u00020\u0002H\u0002J\u0012\u0010\u0006\u001a\u00020\u00022\b\u0010\u0005\u001a\u0004\u0018\u00010\u0004H\u0002J$\u0010\u000b\u001a\u00020\n2\b\u0010\u0005\u001a\u0004\u0018\u00010\u00042\u0006\u0010\b\u001a\u00020\u00072\b\u0010\t\u001a\u0004\u0018\u00010\u0004H\u0002J\u0012\u0010\f\u001a\u00020\u00022\b\u0010\u0005\u001a\u0004\u0018\u00010\u0004H\u0014J\b\u0010\u000e\u001a\u00020\rH\u0016R\u0016\u0010\u0012\u001a\u00020\u000f8\u0002@\u0002X\u0082.¢\u0006\u0006\n\u0004\b\u0010\u0010\u0011R\u001b\u0010\u0018\u001a\u00020\u00138FX\u0086\u0084\u0002¢\u0006\f\n\u0004\b\u0014\u0010\u0015\u001a\u0004\b\u0016\u0010\u0017R\u001c\u0010\u001d\u001a\b\u0012\u0004\u0012\u00020\u001a0\u00198\u0002@\u0002X\u0082.¢\u0006\u0006\n\u0004\b\u001b\u0010\u001c¨\u0006 "}, d2 = {"Lca/canadapost/module/sendingexperience/SendingExperienceActivity;", "Lca/canadapost/core/common/navigation/ui/b;", "Lrm/n0;", "A0", "Landroid/os/Bundle;", "savedInstanceState", "D0", "", "isLoggedIn", CoreConstants.FRAG_ARGS, "Lv4/j;", "E0", "onCreate", "Lm8/i;", "d", "Lnf/a;", "I", "Lnf/a;", "binding", "Lmf/j;", "J", "Lrm/o;", "C0", "()Lmf/j;", "viewModel", "Lf/c;", "Landroid/content/Intent;", "K", "Lf/c;", "onActivityResultLauncher", "<init>", "()V", "sendingexperience_productionRelease"}, k = 1, mv = {1, 9, 0})
/* loaded from: classes4.dex */
public final class SendingExperienceActivity extends ca.canadapost.core.common.navigation.ui.b {

    /* renamed from: I, reason: from kotlin metadata */
    private nf.a binding;

    /* renamed from: J, reason: from kotlin metadata */
    private final o viewModel = new b1(p0.b(j.class), new a(this), new c(), new b(null, this));

    /* renamed from: K, reason: from kotlin metadata */
    private f.c onActivityResultLauncher;

    /* loaded from: classes4.dex */
    public static final class a extends v implements dn.a {

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

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public a(h hVar) {
            super(0);
            this.f10827p = hVar;
        }

        @Override // dn.a
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public final d1 invoke() {
            return this.f10827p.getViewModelStore();
        }
    }

    /* loaded from: classes4.dex */
    public static final class b extends v implements dn.a {

        /* renamed from: p, reason: collision with root package name */
        final /* synthetic */ dn.a f10828p;

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

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public b(dn.a aVar, h hVar) {
            super(0);
            this.f10828p = aVar;
            this.f10829q = hVar;
        }

        @Override // dn.a
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public final s4.a invoke() {
            s4.a aVar;
            dn.a aVar2 = this.f10828p;
            return (aVar2 == null || (aVar = (s4.a) aVar2.invoke()) == null) ? this.f10829q.getDefaultViewModelCreationExtras() : aVar;
        }
    }

    /* loaded from: classes4.dex */
    static final class c extends v implements dn.a {
        c() {
            super(0);
        }

        @Override // dn.a
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public final c1.c invoke() {
            return SendingExperienceActivity.this.n0();
        }
    }

    private final void A0() {
        f.c registerForActivityResult = registerForActivityResult(new d(), new f.b() { // from class: mf.g
            @Override // f.b
            public final void a(Object obj) {
                SendingExperienceActivity.B0(SendingExperienceActivity.this, (f.a) obj);
            }
        });
        t.f(registerForActivityResult, "registerForActivityResult(...)");
        this.onActivityResultLauncher = registerForActivityResult;
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void B0(SendingExperienceActivity this$0, f.a aVar) {
        t.g(this$0, "this$0");
        if (this$0.C0().P() || aVar.b() != 0) {
            return;
        }
        this$0.finish();
    }

    private final void D0(Bundle bundle) {
        f.c cVar;
        if (C0().P()) {
            Bundle extras = getIntent().getExtras();
            E0(bundle, C0().P(), extras != null ? extras.getBundle(CoreConstants.FRAG_ARGS) : null);
            return;
        }
        m.a aVar = m.f29859a;
        f.c cVar2 = this.onActivityResultLauncher;
        if (cVar2 == null) {
            t.y("onActivityResultLauncher");
            cVar = null;
        } else {
            cVar = cVar2;
        }
        m.a.d(aVar, cVar, this, null, 4, null);
    }

    private final v4.j E0(Bundle savedInstanceState, boolean isLoggedIn, Bundle fragmentArgs) {
        f k02 = getSupportFragmentManager().k0(mf.c.f29097b);
        t.e(k02, "null cannot be cast to non-null type androidx.navigation.fragment.NavHostFragment");
        v4.j A = ((NavHostFragment) k02).A();
        if (savedInstanceState == null && A.D().Z() == 0) {
            p b10 = A.F().b(e.f29100a);
            if (isLoggedIn) {
                b10.b0(mf.c.f29096a);
                A.l0(b10, fragmentArgs);
            }
        }
        return A;
    }

    public final j C0() {
        return (j) this.viewModel.getValue();
    }

    @Override // m8.m
    public i d() {
        return i.NAV_SENDING_EXPERIENCE;
    }

    /* JADX INFO: Access modifiers changed from: protected */
    @Override // ca.canadapost.core.common.navigation.ui.b, androidx.fragment.app.k, androidx.activity.h, androidx.core.app.f, android.app.Activity
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        n j10 = androidx.databinding.f.j(this, mf.d.f29098a);
        t.f(j10, "setContentView(...)");
        nf.a aVar = (nf.a) j10;
        this.binding = aVar;
        nf.a aVar2 = null;
        if (aVar == null) {
            t.y("binding");
            aVar = null;
        }
        aVar.U(k0());
        nf.a aVar3 = this.binding;
        if (aVar3 == null) {
            t.y("binding");
            aVar3 = null;
        }
        v0(aVar3.A.B);
        nf.a aVar4 = this.binding;
        if (aVar4 == null) {
            t.y("binding");
        } else {
            aVar2 = aVar4;
        }
        aVar2.A.B.setNavigationContentDescription(getString(mf.f.f29101a));
        N(m0());
        setTitle(mf.f.f29104d);
        A0();
        D0(bundle);
    }
}
