package com.vinfast.companion.main.ui.booking.history;

/* JADX INFO: compiled from: r8-map-id-ae6aab8d9a1033945587ffdd1bc6222159522c1d66e66a2c4cecb065134dd0a6 */
/* JADX INFO: loaded from: E:\ios\vf_dex\classes3.dex */
@kotlin.Metadata(d1 = {"\u0000f\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0002\b\u0003\n\u0002\u0010\b\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\u0010 \n\u0002\b\u0007\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\b\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0007\n\u0002\u0018\u0002\n\u0002\b\u0006\b&\u0018\u0000*\b\b\u0000\u0010\u0002*\u00020\u00012\u00020\u0003B\u0007¢\u0006\u0004\b\u0004\u0010\u0005J\u001f\u0010\n\u001a\u00020\t2\u0006\u0010\u0007\u001a\u00020\u00062\b\b\u0002\u0010\b\u001a\u00020\u0006¢\u0006\u0004\b\n\u0010\u000bJ\r\u0010\f\u001a\u00020\t¢\u0006\u0004\b\f\u0010\u0005J\u0015\u0010\u000f\u001a\u00020\t2\u0006\u0010\u000e\u001a\u00020\r¢\u0006\u0004\b\u000f\u0010\u0010J+\u0010\u0015\u001a\u000e\u0012\n\u0012\b\u0012\u0004\u0012\u00028\u00000\u00140\u00132\u0006\u0010\u0011\u001a\u00020\r2\u0006\u0010\u0012\u001a\u00020\rH\u0014¢\u0006\u0004\b\u0015\u0010\u0016J1\u0010\u0019\u001a\b\u0012\u0004\u0012\u00020\u00010\u00142\f\u0010\u0017\u001a\b\u0012\u0004\u0012\u00020\u00010\u00142\f\u0010\u0018\u001a\b\u0012\u0004\u0012\u00028\u00000\u0014H\u0014¢\u0006\u0004\b\u0019\u0010\u001aJ\u000f\u0010\u001b\u001a\u00020\tH\u0014¢\u0006\u0004\b\u001b\u0010\u0005R \u0010\"\u001a\b\u0012\u0004\u0012\u00020\u001d0\u001c8\u0004X\u0084\u0004¢\u0006\f\n\u0004\b\u001e\u0010\u001f\u001a\u0004\b \u0010!R \u0010%\u001a\b\u0012\u0004\u0012\u00028\u00000\u001c8\u0004X\u0084\u0004¢\u0006\f\n\u0004\b#\u0010\u001f\u001a\u0004\b$\u0010!R\u001a\u0010+\u001a\u00020&8\u0004X\u0084\u0004¢\u0006\f\n\u0004\b'\u0010(\u001a\u0004\b)\u0010*R*\u00102\u001a\u0012\u0012\u0004\u0012\u00020\u00010,j\b\u0012\u0004\u0012\u00020\u0001`-8\u0004X\u0084\u0004¢\u0006\f\n\u0004\b.\u0010/\u001a\u0004\b0\u00101R$\u0010:\u001a\u0004\u0018\u0001038\u0004@\u0004X\u0084\u000e¢\u0006\u0012\n\u0004\b4\u00105\u001a\u0004\b6\u00107\"\u0004\b8\u00109R\u0017\u0010>\u001a\b\u0012\u0004\u0012\u00020\u001d0;8F¢\u0006\u0006\u001a\u0004\b<\u0010=R\u0017\u0010@\u001a\b\u0012\u0004\u0012\u00028\u00000;8F¢\u0006\u0006\u001a\u0004\b?\u0010=¨\u0006A"}, d2 = {"Lcom/vinfast/companion/main/ui/booking/history/BaseHistoryAppointmentViewModel;", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "Model", "Lcom/vinfast/companion/core/base/BaseViewModel;", "<init>", "()V", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "isRefresh", "isFirstTime", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "P", "(ZZ)V", "U", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "position", "T", "(I)V", "pageIndex", "pageSize", "Lkotlinx/coroutines/flow/Flow;", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "J", "(II)Lkotlinx/coroutines/flow/Flow;", "currentAppointmentList", "newAppointmentList", "S", "(Ljava/util/List;Ljava/util/List;)Ljava/util/List;", "onCleared", "Landroidx/lifecycle/MutableLiveData;", "Lcom/vinfast/companion/core/base/ui/model/UiState;", "m", "Landroidx/lifecycle/MutableLiveData;", "R", "()Landroidx/lifecycle/MutableLiveData;", "_appointmentListStateLiveData", "n", "get_navigateToAppointmentDetailScreenLiveData", "_navigateToAppointmentDetailScreenLiveData", "Lcom/vinfast/companion/core/base/ui/model/ListState;", "o", "Lcom/vinfast/companion/core/base/ui/model/ListState;", "M", "()Lcom/vinfast/companion/core/base/ui/model/ListState;", "mAppointmentListState", "Ljava/util/ArrayList;", "Lkotlin/collections/ArrayList;", "p", "Ljava/util/ArrayList;", "L", "()Ljava/util/ArrayList;", "mAppointmentList", "Lkotlinx/coroutines/Job;", "q", "Lkotlinx/coroutines/Job;", "N", "()Lkotlinx/coroutines/Job;", "setMGetServiceHistoryJob", "(Lkotlinx/coroutines/Job;)V", "mGetServiceHistoryJob", "Landroidx/lifecycle/LiveData;", "K", "()Landroidx/lifecycle/LiveData;", "appointmentListStateLiveData", "O", "navigateToAppointmentDetailScreenLiveData", "services_release"}, k = 1, mv = {2, 2, 0}, xi = 48)
public abstract class BaseHistoryAppointmentViewModel<Model> extends com.vinfast.companion.core.base.BaseViewModel {

    /* JADX INFO: renamed from: m, reason: from kotlin metadata */
    private final androidx.lifecycle.MutableLiveData _appointmentListStateLiveData = new androidx.lifecycle.MutableLiveData();

    /* JADX INFO: renamed from: n, reason: from kotlin metadata */
    private final androidx.lifecycle.MutableLiveData _navigateToAppointmentDetailScreenLiveData = new androidx.lifecycle.MutableLiveData();

    /* JADX INFO: renamed from: o, reason: from kotlin metadata */
    private final com.vinfast.companion.core.base.ui.model.ListState mAppointmentListState = new com.vinfast.companion.core.base.ui.model.ListState(0, 0, false, (java.lang.String) null, 15, (kotlin.jvm.internal.DefaultConstructorMarker) null);

    /* JADX INFO: renamed from: p, reason: from kotlin metadata */
    private final java.util.ArrayList mAppointmentList = new java.util.ArrayList();

    /* JADX INFO: renamed from: q, reason: from kotlin metadata */
    private kotlinx.coroutines.Job mGetServiceHistoryJob;

    public static /* synthetic */ void Q(com.vinfast.companion.main.ui.booking.history.BaseHistoryAppointmentViewModel baseHistoryAppointmentViewModel, boolean z, boolean z4, int i, java.lang.Object obj) {
        if (obj != null) {
            throw new java.lang.UnsupportedOperationException("Super calls with default arguments not supported in this target, function: getServiceHistory");
        }
        if ((i & 2) != 0) {
            z4 = false;
        }
        baseHistoryAppointmentViewModel.P(z, z4);
    }

    protected kotlinx.coroutines.flow.Flow J(int pageIndex, int pageSize) {
        return kotlinx.coroutines.flow.FlowKt.C();
    }

    public final androidx.lifecycle.LiveData K() {
        return this._appointmentListStateLiveData;
    }

    /* JADX INFO: renamed from: L, reason: from getter */
    protected final java.util.ArrayList getMAppointmentList() {
        return this.mAppointmentList;
    }

    /* JADX INFO: renamed from: M, reason: from getter */
    protected final com.vinfast.companion.core.base.ui.model.ListState getMAppointmentListState() {
        return this.mAppointmentListState;
    }

    /* JADX INFO: renamed from: N, reason: from getter */
    protected final kotlinx.coroutines.Job getMGetServiceHistoryJob() {
        return this.mGetServiceHistoryJob;
    }

    public final androidx.lifecycle.LiveData O() {
        return this._navigateToAppointmentDetailScreenLiveData;
    }

    public final void P(boolean isRefresh, boolean isFirstTime) {
        kotlinx.coroutines.Job job = this.mGetServiceHistoryJob;
        boolean z = job != null && job.isActive();
        if (isRefresh || !z) {
            if (isRefresh || this.mAppointmentListState.a()) {
                if (isRefresh) {
                    this.mAppointmentListState.e(0);
                    this.mAppointmentListState.d(true);
                } else {
                    com.vinfast.companion.core.base.ui.model.ListState listState = this.mAppointmentListState;
                    listState.e(listState.b() + 1);
                }
                kotlinx.coroutines.Job job2 = this.mGetServiceHistoryJob;
                if (job2 != null) {
                    kotlinx.coroutines.Job.DefaultImpls.a(job2, (java.util.concurrent.CancellationException) null, 1, (java.lang.Object) null);
                }
                this.mGetServiceHistoryJob = kotlinx.coroutines.BuildersKt.d(androidx.lifecycle.ViewModelKt.a(this), (kotlin.coroutines.CoroutineContext) null, (kotlinx.coroutines.CoroutineStart) null, new com.vinfast.companion.main.ui.booking.history.BaseHistoryAppointmentViewModel$getServiceHistory$1(this, isRefresh, isFirstTime, null), 3, (java.lang.Object) null);
            }
        }
    }

    /* JADX INFO: renamed from: R, reason: from getter */
    protected final androidx.lifecycle.MutableLiveData get_appointmentListStateLiveData() {
        return this._appointmentListStateLiveData;
    }

    protected java.util.List S(java.util.List currentAppointmentList, java.util.List newAppointmentList) {
        kotlin.jvm.internal.Intrinsics.l(currentAppointmentList, "currentAppointmentList");
        kotlin.jvm.internal.Intrinsics.l(newAppointmentList, "newAppointmentList");
        return kotlin.collections.CollectionsKt.o();
    }

    public final void T(int position) {
        if (position < 0 || position >= this.mAppointmentList.size()) {
            return;
        }
        java.lang.Object obj = this.mAppointmentList.get(position);
        if (obj == null) {
            obj = null;
        }
        if (obj == null) {
            return;
        }
        this._navigateToAppointmentDetailScreenLiveData.q(obj);
    }

    public final void U() {
        this._appointmentListStateLiveData.q((com.vinfast.companion.core.base.ui.model.UiState) this._appointmentListStateLiveData.f());
    }

    protected void onCleared() {
        kotlinx.coroutines.Job job = this.mGetServiceHistoryJob;
        if (job != null) {
            kotlinx.coroutines.Job.DefaultImpls.a(job, (java.util.concurrent.CancellationException) null, 1, (java.lang.Object) null);
        }
        this.mGetServiceHistoryJob = null;
        super.onCleared();
    }
}
