package ca.canadapost.module.homepickup.fragments;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.k;
import androidx.lifecycle.c1;
import androidx.lifecycle.d1;
import androidx.lifecycle.e1;
import androidx.lifecycle.g0;
import ca.canadapost.core.common.customView.l;
import ca.canadapost.core.common.ui.CpcBarCodeScannerActivity;
import ca.canadapost.core.data.model.Event;
import ca.canadapost.module.homepickup.fragments.EnterTrackingNumberFragment;
import com.google.firebase.messaging.Constants;
import dn.p;
import h7.i;
import java.util.ArrayList;
import kotlin.Metadata;
import kotlin.jvm.internal.n;
import kotlin.jvm.internal.t;
import kotlin.jvm.internal.v;
import l8.h;
import q8.a;
import rm.n0;
import rm.o;
import rm.y;
import tp.m0;
import w8.l;
import w8.p0;
import y0.m;
import yf.h;

@Metadata(d1 = {"\u0000`\n\u0002\u0018\u0002\n\u0002\u0018\u0002\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\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u000e\b\u0007\u0018\u00002\u00020\u00012\u00020\u0002B\u0007¢\u0006\u0004\b+\u0010,J\u0012\u0010\u0006\u001a\u00020\u00052\b\u0010\u0004\u001a\u0004\u0018\u00010\u0003H\u0002J\u0019\u0010\u000b\u001a\u00020\u00052\u0006\u0010\b\u001a\u00020\u00072\u0006\u0010\n\u001a\u00020\tH\u0096\u0001J\u0019\u0010\u000e\u001a\u00020\u00052\u0006\u0010\r\u001a\u00020\f2\u0006\u0010\n\u001a\u00020\tH\u0096\u0001J$\u0010\u0016\u001a\u00020\u00152\u0006\u0010\u0010\u001a\u00020\u000f2\b\u0010\u0012\u001a\u0004\u0018\u00010\u00112\b\u0010\u0014\u001a\u0004\u0018\u00010\u0013H\u0016J\u001a\u0010\u0018\u001a\u00020\u00052\u0006\u0010\u0017\u001a\u00020\u00152\b\u0010\u0014\u001a\u0004\u0018\u00010\u0013H\u0016J\"\u0010\u001e\u001a\u00020\u00052\u0006\u0010\u001a\u001a\u00020\u00192\u0006\u0010\u001b\u001a\u00020\u00192\b\u0010\u001d\u001a\u0004\u0018\u00010\u001cH\u0017R\u001b\u0010$\u001a\u00020\u001f8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b \u0010!\u001a\u0004\b\"\u0010#R\"\u0010\u0004\u001a\u00020\u00038\u0004@\u0004X\u0085.¢\u0006\u0012\n\u0004\b%\u0010&\u001a\u0004\b'\u0010(\"\u0004\b)\u0010*¨\u0006-"}, d2 = {"Lca/canadapost/module/homepickup/fragments/EnterTrackingNumberFragment;", "Lu8/b;", "Lw8/p0;", "Lq8/a;", "permissionServices", "Lrm/n0;", "M", "Landroid/app/Activity;", "activity", "Ll8/h$b;", "event", "c", "Landroidx/fragment/app/f;", "fragment", "p", "Landroid/view/LayoutInflater;", "inflater", "Landroid/view/ViewGroup;", "container", "Landroid/os/Bundle;", "savedInstanceState", "Landroid/view/View;", "onCreateView", "view", "onViewCreated", "", "requestCode", "resultCode", "Landroid/content/Intent;", Constants.ScionAnalytics.MessageType.DATA_MESSAGE, "onActivityResult", "Ltc/l;", "t", "Lrm/o;", "L", "()Ltc/l;", "viewModel", "u", "Lq8/a;", "K", "()Lq8/a;", "setPermissionServices", "(Lq8/a;)V", "<init>", "()V", "homepickup_productionRelease"}, k = 1, mv = {1, 9, 0})
/* loaded from: classes4.dex */
public final class EnterTrackingNumberFragment extends u8.b implements p0 {

    /* renamed from: s, reason: collision with root package name */
    private final /* synthetic */ l f9574s = new l();

    /* renamed from: t, reason: collision with root package name and from kotlin metadata */
    private final o viewModel = androidx.fragment.app.p0.a(this, kotlin.jvm.internal.p0.b(tc.l.class), new f(new e(this)), new g());

    /* renamed from: u, reason: collision with root package name and from kotlin metadata */
    protected q8.a permissionServices;

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

        /* JADX INFO: Access modifiers changed from: package-private */
        /* renamed from: ca.canadapost.module.homepickup.fragments.EnterTrackingNumberFragment$a$a, reason: collision with other inner class name */
        /* loaded from: classes4.dex */
        public static final class C0259a extends kotlin.coroutines.jvm.internal.l implements p {

            /* renamed from: p, reason: collision with root package name */
            int f9578p;

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

            /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
            C0259a(EnterTrackingNumberFragment enterTrackingNumberFragment, vm.d dVar) {
                super(2, dVar);
                this.f9579q = enterTrackingNumberFragment;
            }

            @Override // kotlin.coroutines.jvm.internal.a
            public final vm.d create(Object obj, vm.d dVar) {
                return new C0259a(this.f9579q, dVar);
            }

            @Override // kotlin.coroutines.jvm.internal.a
            public final Object invokeSuspend(Object obj) {
                wm.d.f();
                if (this.f9578p != 0) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                y.b(obj);
                k activity = this.f9579q.getActivity();
                Toolbar toolbar = activity != null ? (Toolbar) activity.findViewById(i.M0) : null;
                if (toolbar != null) {
                    toolbar.setVisibility(8);
                }
                return n0.f34904a;
            }

            @Override // dn.p
            public final Object invoke(m0 m0Var, vm.d dVar) {
                return ((C0259a) create(m0Var, dVar)).invokeSuspend(n0.f34904a);
            }
        }

        a() {
            super(2);
        }

        public final void a(m mVar, int i10) {
            if ((i10 & 11) == 2 && mVar.v()) {
                mVar.A();
                return;
            }
            if (y0.p.H()) {
                y0.p.Q(1740170463, i10, -1, "ca.canadapost.module.homepickup.fragments.EnterTrackingNumberFragment.onCreateView.<anonymous> (EnterTrackingNumberFragment.kt:38)");
            }
            y0.p0.d(kotlin.jvm.internal.d.f26181a, new C0259a(EnterTrackingNumberFragment.this, null), mVar, 72);
            vc.f.c(EnterTrackingNumberFragment.this.L(), mVar, 0);
            if (y0.p.H()) {
                y0.p.P();
            }
        }

        @Override // dn.p
        public /* bridge */ /* synthetic */ Object invoke(Object obj, Object obj2) {
            a((m) obj, ((Number) obj2).intValue());
            return n0.f34904a;
        }
    }

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

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

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

            static {
                int[] iArr = new int[xc.a.values().length];
                try {
                    iArr[xc.a.NAV_BACK.ordinal()] = 1;
                } catch (NoSuchFieldError unused) {
                }
                try {
                    iArr[xc.a.NAV_SCAN_BARCODE.ordinal()] = 2;
                } catch (NoSuchFieldError unused2) {
                }
                f9581a = iArr;
            }
        }

        b() {
            super(1);
        }

        public final void a(xc.a aVar) {
            int i10 = aVar == null ? -1 : a.f9581a[aVar.ordinal()];
            if (i10 == 1) {
                EnterTrackingNumberFragment.this.requireActivity().finish();
            } else {
                if (i10 != 2) {
                    return;
                }
                EnterTrackingNumberFragment enterTrackingNumberFragment = EnterTrackingNumberFragment.this;
                enterTrackingNumberFragment.M(enterTrackingNumberFragment.K());
            }
        }

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

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

        public final void a(Event event) {
            String str = (String) event.getContentIfNotHandled();
            if (str != null) {
                EnterTrackingNumberFragment enterTrackingNumberFragment = EnterTrackingNumberFragment.this;
                l.a aVar = ca.canadapost.core.common.customView.l.f7730d;
                k requireActivity = enterTrackingNumberFragment.requireActivity();
                t.f(requireActivity, "requireActivity(...)");
                aVar.a(requireActivity, str);
            }
        }

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

    /* loaded from: classes4.dex */
    static final class d implements g0, n {

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

        d(dn.l function) {
            t.g(function, "function");
            this.f9583a = function;
        }

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

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

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

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

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

        /* renamed from: p, reason: collision with root package name */
        final /* synthetic */ androidx.fragment.app.f f9584p;

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

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

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

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

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

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

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

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

    /* JADX INFO: Access modifiers changed from: private */
    public final tc.l L() {
        return (tc.l) this.viewModel.getValue();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final void M(q8.a aVar) {
        if (aVar != null) {
            aVar.c(new String[]{"android.permission.CAMERA"}, new w8.f() { // from class: tc.j
                @Override // w8.f
                public final void accept(Object obj) {
                    EnterTrackingNumberFragment.N(EnterTrackingNumberFragment.this, (a.EnumC0774a) obj);
                }
            });
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final void N(EnterTrackingNumberFragment this$0, a.EnumC0774a enumC0774a) {
        t.g(this$0, "this$0");
        if (enumC0774a != a.EnumC0774a.GRANTED) {
            return;
        }
        k activity = this$0.getActivity();
        if (activity == null || !activity.isFinishing()) {
            ml.a d10 = ml.a.d(this$0);
            d10.k(CpcBarCodeScannerActivity.class);
            ArrayList arrayList = new ArrayList(ml.a.f29194h);
            arrayList.addAll(ml.a.f29195i);
            arrayList.add("QR_CODE");
            arrayList.add("DATA_MATRIX");
            arrayList.add("PDF_417");
            arrayList.remove("UPC_A");
            arrayList.remove("UPC_E");
            d10.l(arrayList);
            Context context = this$0.getContext();
            d10.n(context != null ? context.getString(h.F1) : null);
            d10.m(false);
            d10.g();
        }
    }

    protected final q8.a K() {
        q8.a aVar = this.permissionServices;
        if (aVar != null) {
            return aVar;
        }
        t.y("permissionServices");
        return null;
    }

    @Override // w8.p0
    public void c(Activity activity, h.b event) {
        t.g(activity, "activity");
        t.g(event, "event");
        this.f9574s.c(activity, event);
    }

    @Override // androidx.fragment.app.f
    public void onActivityResult(int i10, int i11, Intent intent) {
        ml.b i12;
        super.onActivityResult(i10, i11, intent);
        int i13 = i10 & 65535;
        if (i13 != 49374 || i11 == 0 || (i12 = ml.a.i(i13, i11, intent)) == null) {
            return;
        }
        tc.l L = L();
        String a10 = i12.a();
        t.f(a10, "getContents(...)");
        L.T(a10);
    }

    @Override // androidx.fragment.app.f
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        t.g(inflater, "inflater");
        return k7.a.a(this, g1.c.c(1740170463, true, new a()));
    }

    @Override // u8.b, androidx.fragment.app.f
    public void onViewCreated(View view, Bundle bundle) {
        t.g(view, "view");
        super.onViewCreated(view, bundle);
        L().Q().j(getViewLifecycleOwner(), new d(new b()));
        L().R().j(getViewLifecycleOwner(), new d(new c()));
    }

    @Override // w8.p0
    public void p(androidx.fragment.app.f fragment, h.b event) {
        t.g(fragment, "fragment");
        t.g(event, "event");
        this.f9574s.p(fragment, event);
    }
}
