package ca.canadapost.core.common.ui;

import android.app.Dialog;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.f;
import androidx.fragment.app.p0;
import androidx.lifecycle.c1;
import androidx.lifecycle.d1;
import androidx.lifecycle.e1;
import androidx.lifecycle.u;
import androidx.lifecycle.z0;
import h7.j;
import h7.l;
import kotlin.Metadata;
import kotlin.jvm.internal.t;
import kotlin.jvm.internal.v;
import rm.o;
import u7.s1;
import u7.x;

@Metadata(d1 = {"\u0000`\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\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0007\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u000b\b\u0007\u0018\u0000 .2\u00020\u00012\b\u0012\u0004\u0012\u00020\u00030\u0002:\u0001/B\u0007¢\u0006\u0004\b,\u0010-J5\u0010\u000f\u001a\u00020\u000e2\u0006\u0010\u0005\u001a\u00020\u00042\b\u0010\u0007\u001a\u0004\u0018\u00010\u00062\b\u0010\t\u001a\u0004\u0018\u00010\b2\u0006\u0010\u000b\u001a\u00020\n2\u0006\u0010\r\u001a\u00020\fH\u0096\u0001J\n\u0010\u0011\u001a\u0004\u0018\u00010\u0010H\u0016J\n\u0010\u0013\u001a\u0004\u0018\u00010\u0012H\u0016J&\u0010\u0014\u001a\u0004\u0018\u00010\u000e2\u0006\u0010\u0005\u001a\u00020\u00042\b\u0010\u0007\u001a\u0004\u0018\u00010\u00062\b\u0010\t\u001a\u0004\u0018\u00010\bH\u0016J\u001a\u0010\u0017\u001a\u00020\u00162\u0006\u0010\u0015\u001a\u00020\u000e2\b\u0010\t\u001a\u0004\u0018\u00010\bH\u0016R\"\u0010\u001f\u001a\u00020\u00188\u0006@\u0006X\u0087.¢\u0006\u0012\n\u0004\b\u0019\u0010\u001a\u001a\u0004\b\u001b\u0010\u001c\"\u0004\b\u001d\u0010\u001eR\u001b\u0010\r\u001a\u00020 8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b!\u0010\"\u001a\u0004\b#\u0010$R\u001e\u0010(\u001a\n\u0012\u0004\u0012\u00020\u0016\u0018\u00010%8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b&\u0010'R\u0014\u0010+\u001a\u00020\u00038\u0016X\u0096\u0005¢\u0006\u0006\u001a\u0004\b)\u0010*¨\u00060"}, d2 = {"Lca/canadapost/core/common/ui/c;", "Lca/canadapost/core/common/ui/b;", "", "Lu7/s1;", "Landroid/view/LayoutInflater;", "inflater", "Landroid/view/ViewGroup;", "container", "Landroid/os/Bundle;", "savedInstanceState", "Landroidx/lifecycle/u;", "viewLifecycleOwner", "Landroidx/lifecycle/z0;", "viewModel", "Landroid/view/View;", "J", "Landroidx/appcompat/widget/Toolbar;", "C", "", "B", "onCreateView", "view", "Lrm/n0;", "onViewCreated", "Landroidx/lifecycle/c1$c;", "q", "Landroidx/lifecycle/c1$c;", "I", "()Landroidx/lifecycle/c1$c;", "setViewModelFactory", "(Landroidx/lifecycle/c1$c;)V", "viewModelFactory", "Lu8/x;", "r", "Lrm/o;", "H", "()Lu8/x;", "Lkotlin/Function0;", "s", "Ldn/a;", "onClickListener", "G", "()Lu7/s1;", "binding", "<init>", "()V", "t", "a", "core_common_productionRelease"}, k = 1, mv = {1, 9, 0})
/* loaded from: classes.dex */
public final class c extends ca.canadapost.core.common.ui.b {

    /* renamed from: u, reason: collision with root package name */
    public static final int f7980u = 8;

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

    /* renamed from: s, reason: collision with root package name and from kotlin metadata */
    private dn.a onClickListener;

    /* renamed from: p, reason: collision with root package name */
    private final /* synthetic */ x f7981p = new x(j.Z);

    /* renamed from: r, reason: collision with root package name and from kotlin metadata */
    private final o viewModel = p0.a(this, kotlin.jvm.internal.p0.b(u8.x.class), new C0209c(new b(this)), new d());

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

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

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public b(f fVar) {
            super(0);
            this.f7985p = fVar;
        }

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

    /* renamed from: ca.canadapost.core.common.ui.c$c, reason: collision with other inner class name */
    /* loaded from: classes.dex */
    public static final class C0209c extends v implements dn.a {

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

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

        @Override // dn.a
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public final d1 invoke() {
            d1 viewModelStore = ((e1) this.f7986p.invoke()).getViewModelStore();
            t.f(viewModelStore, "ownerProducer().viewModelStore");
            return viewModelStore;
        }
    }

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

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

    private final u8.x H() {
        return (u8.x) this.viewModel.getValue();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void K(c this$0, View view) {
        t.g(this$0, "this$0");
        dn.a aVar = this$0.onClickListener;
        if (aVar != null) {
            aVar.invoke();
        }
        Dialog dialog = this$0.getDialog();
        if (dialog != null) {
            dialog.dismiss();
        }
    }

    @Override // ca.canadapost.core.common.ui.b
    public String B() {
        String string;
        Bundle arguments = getArguments();
        return (arguments == null || (string = arguments.getString("toolbar_title")) == null) ? getString(l.X) : string;
    }

    @Override // ca.canadapost.core.common.ui.b
    public Toolbar C() {
        u7.c appBarBinding = G().B.getAppBarBinding();
        if (appBarBinding != null) {
            return appBarBinding.B;
        }
        return null;
    }

    public s1 G() {
        return (s1) this.f7981p.b();
    }

    public final c1.c I() {
        c1.c cVar = this.viewModelFactory;
        if (cVar != null) {
            return cVar;
        }
        t.y("viewModelFactory");
        return null;
    }

    public View J(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState, u viewLifecycleOwner, z0 viewModel) {
        t.g(inflater, "inflater");
        t.g(viewLifecycleOwner, "viewLifecycleOwner");
        t.g(viewModel, "viewModel");
        return this.f7981p.c(inflater, container, savedInstanceState, viewLifecycleOwner, viewModel);
    }

    @Override // androidx.fragment.app.f
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        t.g(inflater, "inflater");
        u viewLifecycleOwner = getViewLifecycleOwner();
        t.f(viewLifecycleOwner, "getViewLifecycleOwner(...)");
        return J(inflater, null, savedInstanceState, viewLifecycleOwner, H());
    }

    @Override // ca.canadapost.core.common.ui.b, androidx.fragment.app.f
    public void onViewCreated(View view, Bundle bundle) {
        int i10;
        t.g(view, "view");
        super.onViewCreated(view, bundle);
        s1 G = G();
        TextView textView = G.D;
        Bundle arguments = getArguments();
        textView.setText(arguments != null ? arguments.getString("message") : null);
        Bundle arguments2 = getArguments();
        if (arguments2 != null && (i10 = arguments2.getInt("icon")) != 0) {
            G.C.setImageResource(i10);
        }
        Button button = G.A;
        Bundle arguments3 = getArguments();
        button.setText(arguments3 != null ? arguments3.getString("button_text") : null);
        G.A.setOnClickListener(new View.OnClickListener() { // from class: u8.v
            @Override // android.view.View.OnClickListener
            public final void onClick(View view2) {
                ca.canadapost.core.common.ui.c.K(ca.canadapost.core.common.ui.c.this, view2);
            }
        });
    }
}
