package ca.canadapost.core.common.ui;

import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
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 ca.canadapost.core.common.ui.ServerErrorDialogFragment;
import h7.j;
import h7.l;
import kotlin.Metadata;
import kotlin.jvm.internal.v;
import rm.o;
import u7.q1;
import u7.x;
import u8.t;
import w8.y;

@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\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0007\n\u0002\u0018\u0002\n\u0002\b\f\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\b\u0010\u0011\u001a\u00020\u0010H\u0016J\n\u0010\u0013\u001a\u0004\u0018\u00010\u0012H\u0016J\n\u0010\u0015\u001a\u0004\u0018\u00010\u0014H\u0016J&\u0010\u0016\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\u0018\u001a\u00020\u00102\u0006\u0010\u0017\u001a\u00020\u000e2\b\u0010\t\u001a\u0004\u0018\u00010\bH\u0016J\u0010\u0010\u001b\u001a\u00020\u00102\u0006\u0010\u001a\u001a\u00020\u0019H\u0016R\"\u0010#\u001a\u00020\u001c8\u0006@\u0006X\u0087.¢\u0006\u0012\n\u0004\b\u001d\u0010\u001e\u001a\u0004\b\u001f\u0010 \"\u0004\b!\u0010\"R\u001b\u0010\r\u001a\u00020$8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b%\u0010&\u001a\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/ServerErrorDialogFragment;", "Lca/canadapost/core/common/ui/b;", "", "Lu7/q1;", "Landroid/view/LayoutInflater;", "inflater", "Landroid/view/ViewGroup;", "container", "Landroid/os/Bundle;", "savedInstanceState", "Landroidx/lifecycle/u;", "viewLifecycleOwner", "Landroidx/lifecycle/z0;", "viewModel", "Landroid/view/View;", "J", "Lrm/n0;", "D", "Landroidx/appcompat/widget/Toolbar;", "C", "", "B", "onCreateView", "view", "onViewCreated", "Landroid/content/DialogInterface;", "dialog", "onCancel", "Landroidx/lifecycle/c1$c;", "q", "Landroidx/lifecycle/c1$c;", "I", "()Landroidx/lifecycle/c1$c;", "setViewModelFactory", "(Landroidx/lifecycle/c1$c;)V", "viewModelFactory", "Lu8/t;", "r", "Lrm/o;", "H", "()Lu8/t;", "G", "()Lu7/q1;", "binding", "<init>", "()V", "s", "a", "core_common_productionRelease"}, k = 1, mv = {1, 9, 0})
/* loaded from: classes.dex */
public final class ServerErrorDialogFragment extends ca.canadapost.core.common.ui.b {

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

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

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

    /* 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(t.class), new c(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 f7976p;

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

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

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

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

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

        @Override // dn.a
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public final d1 invoke() {
            d1 viewModelStore = ((e1) this.f7977p.invoke()).getViewModelStore();
            kotlin.jvm.internal.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 ServerErrorDialogFragment.this.I();
        }
    }

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

    /* JADX INFO: Access modifiers changed from: private */
    public static final void K(ServerErrorDialogFragment this$0, View view) {
        kotlin.jvm.internal.t.g(this$0, "this$0");
        y.c(this$0, "ServerErrorDialogFragment:ON_TRY_AGAIN", Boolean.TRUE);
        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("error_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;
    }

    @Override // ca.canadapost.core.common.ui.b
    public void D() {
        super.D();
        y.c(this, "ServerErrorDialogFragment:ON_CLOSE", Boolean.TRUE);
        Dialog dialog = getDialog();
        if (dialog != null) {
            dialog.dismiss();
        }
    }

    public q1 G() {
        return (q1) this.f7973p.b();
    }

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

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

    @Override // androidx.fragment.app.e, android.content.DialogInterface.OnCancelListener
    public void onCancel(DialogInterface dialog) {
        kotlin.jvm.internal.t.g(dialog, "dialog");
        super.onCancel(dialog);
        y.c(this, "ServerErrorDialogFragment:ON_CLOSE", Boolean.TRUE);
    }

    @Override // androidx.fragment.app.f
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        kotlin.jvm.internal.t.g(inflater, "inflater");
        u viewLifecycleOwner = getViewLifecycleOwner();
        kotlin.jvm.internal.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) {
        String string;
        String string2;
        kotlin.jvm.internal.t.g(view, "view");
        super.onViewCreated(view, bundle);
        q1 G = G();
        TextView textView = G.C;
        Bundle arguments = getArguments();
        if (arguments == null || (string = arguments.getString("error_message")) == null) {
            string = getString(l.f21161j2);
        }
        textView.setText(string);
        TextView textView2 = G.A;
        Bundle arguments2 = getArguments();
        if (arguments2 == null || (string2 = arguments2.getString("button_text")) == null) {
            string2 = getString(l.f21144g0);
        }
        textView2.setText(string2);
        G.A.setOnClickListener(new View.OnClickListener() { // from class: u8.r
            @Override // android.view.View.OnClickListener
            public final void onClick(View view2) {
                ServerErrorDialogFragment.K(ServerErrorDialogFragment.this, view2);
            }
        });
    }
}
