package com.strmr.ps.data.local.dao;

import android.database.Cursor;
import androidx.room.RoomDatabase;
import com.strmr.ps.data.local.entity.SyncCheckpoint;
import defpackage.e6a;
import defpackage.mk1;
import defpackage.oq8;
import defpackage.p58;
import defpackage.pe9;
import defpackage.rq6;
import defpackage.sp1;
import defpackage.vo6;
import defpackage.vw2;
import defpackage.xm2;
import defpackage.yn1;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.Callable;
import kotlin.coroutines.Continuation;

/* JADX INFO: loaded from: classes3.dex */
public final class SyncCheckpointDao_Impl implements SyncCheckpointDao {
    private final RoomDatabase __db;
    private final xm2<SyncCheckpoint> __insertionAdapterOfSyncCheckpoint;
    private final oq8 __preparedStmtOfDelete;
    private final oq8 __preparedStmtOfDeleteAll;
    private final oq8 __preparedStmtOfDeleteByPrefix;
    private final oq8 __preparedStmtOfMarkComplete;
    private final oq8 __preparedStmtOfUpdateProgress;

    public SyncCheckpointDao_Impl(@vo6 RoomDatabase roomDatabase) {
        this.__db = roomDatabase;
        this.__insertionAdapterOfSyncCheckpoint = new xm2<SyncCheckpoint>(roomDatabase) { // from class: com.strmr.ps.data.local.dao.SyncCheckpointDao_Impl.1
            @Override // defpackage.oq8
            @vo6
            public String createQuery() {
                return "INSERT OR REPLACE INTO `sync_checkpoints` (`syncType`,`currentPage`,`isInProgress`,`itemsSynced`,`totalItems`,`startedAt`,`lastUpdatedAt`) VALUES (?,?,?,?,?,?,?)";
            }

            @Override // defpackage.xm2
            public void bind(@vo6 pe9 pe9Var, @vo6 SyncCheckpoint syncCheckpoint) {
                pe9Var.bindString(1, syncCheckpoint.getSyncType());
                pe9Var.bindLong(2, syncCheckpoint.getCurrentPage());
                pe9Var.bindLong(3, syncCheckpoint.isInProgress() ? 1L : 0L);
                pe9Var.bindLong(4, syncCheckpoint.getItemsSynced());
                if (syncCheckpoint.getTotalItems() == null) {
                    pe9Var.bindNull(5);
                } else {
                    pe9Var.bindLong(5, syncCheckpoint.getTotalItems().intValue());
                }
                pe9Var.bindLong(6, syncCheckpoint.getStartedAt());
                pe9Var.bindLong(7, syncCheckpoint.getLastUpdatedAt());
            }
        };
        this.__preparedStmtOfUpdateProgress = new oq8(roomDatabase) { // from class: com.strmr.ps.data.local.dao.SyncCheckpointDao_Impl.2
            @Override // defpackage.oq8
            @vo6
            public String createQuery() {
                return "\n        UPDATE sync_checkpoints\n        SET currentPage = ?,\n            isInProgress = 1,\n            itemsSynced = ?,\n            lastUpdatedAt = ?\n        WHERE syncType = ?\n    ";
            }
        };
        this.__preparedStmtOfMarkComplete = new oq8(roomDatabase) { // from class: com.strmr.ps.data.local.dao.SyncCheckpointDao_Impl.3
            @Override // defpackage.oq8
            @vo6
            public String createQuery() {
                return "\n        UPDATE sync_checkpoints\n        SET isInProgress = 0,\n            lastUpdatedAt = ?\n        WHERE syncType = ?\n    ";
            }
        };
        this.__preparedStmtOfDelete = new oq8(roomDatabase) { // from class: com.strmr.ps.data.local.dao.SyncCheckpointDao_Impl.4
            @Override // defpackage.oq8
            @vo6
            public String createQuery() {
                return "DELETE FROM sync_checkpoints WHERE syncType = ?";
            }
        };
        this.__preparedStmtOfDeleteAll = new oq8(roomDatabase) { // from class: com.strmr.ps.data.local.dao.SyncCheckpointDao_Impl.5
            @Override // defpackage.oq8
            @vo6
            public String createQuery() {
                return "DELETE FROM sync_checkpoints";
            }
        };
        this.__preparedStmtOfDeleteByPrefix = new oq8(roomDatabase) { // from class: com.strmr.ps.data.local.dao.SyncCheckpointDao_Impl.6
            @Override // defpackage.oq8
            @vo6
            public String createQuery() {
                return "DELETE FROM sync_checkpoints WHERE syncType LIKE ? || '%'";
            }
        };
    }

    @vo6
    public static List<Class<?>> getRequiredConverters() {
        return Collections.EMPTY_LIST;
    }

    @Override // com.strmr.ps.data.local.dao.SyncCheckpointDao
    public Object delete(final String str, Continuation<? super e6a> continuation) {
        return mk1.b(this.__db, new Callable<e6a>() { // from class: com.strmr.ps.data.local.dao.SyncCheckpointDao_Impl.10
            /* JADX WARN: Can't rename method to resolve collision */
            @Override // java.util.concurrent.Callable
            @vo6
            public e6a call() throws Exception {
                pe9 pe9VarAcquire = SyncCheckpointDao_Impl.this.__preparedStmtOfDelete.acquire();
                pe9VarAcquire.bindString(1, str);
                try {
                    SyncCheckpointDao_Impl.this.__db.beginTransaction();
                    try {
                        pe9VarAcquire.executeUpdateDelete();
                        SyncCheckpointDao_Impl.this.__db.setTransactionSuccessful();
                        return e6a.a;
                    } finally {
                        SyncCheckpointDao_Impl.this.__db.endTransaction();
                    }
                } finally {
                    SyncCheckpointDao_Impl.this.__preparedStmtOfDelete.release(pe9VarAcquire);
                }
            }
        }, continuation);
    }

    @Override // com.strmr.ps.data.local.dao.SyncCheckpointDao
    public Object deleteAll(Continuation<? super e6a> continuation) {
        return mk1.b(this.__db, new Callable<e6a>() { // from class: com.strmr.ps.data.local.dao.SyncCheckpointDao_Impl.11
            /* JADX WARN: Can't rename method to resolve collision */
            @Override // java.util.concurrent.Callable
            @vo6
            public e6a call() throws Exception {
                pe9 pe9VarAcquire = SyncCheckpointDao_Impl.this.__preparedStmtOfDeleteAll.acquire();
                try {
                    SyncCheckpointDao_Impl.this.__db.beginTransaction();
                    try {
                        pe9VarAcquire.executeUpdateDelete();
                        SyncCheckpointDao_Impl.this.__db.setTransactionSuccessful();
                        return e6a.a;
                    } finally {
                        SyncCheckpointDao_Impl.this.__db.endTransaction();
                    }
                } finally {
                    SyncCheckpointDao_Impl.this.__preparedStmtOfDeleteAll.release(pe9VarAcquire);
                }
            }
        }, continuation);
    }

    @Override // com.strmr.ps.data.local.dao.SyncCheckpointDao
    public Object deleteByPrefix(final String str, Continuation<? super e6a> continuation) {
        return mk1.b(this.__db, new Callable<e6a>() { // from class: com.strmr.ps.data.local.dao.SyncCheckpointDao_Impl.12
            /* JADX WARN: Can't rename method to resolve collision */
            @Override // java.util.concurrent.Callable
            @vo6
            public e6a call() throws Exception {
                pe9 pe9VarAcquire = SyncCheckpointDao_Impl.this.__preparedStmtOfDeleteByPrefix.acquire();
                pe9VarAcquire.bindString(1, str);
                try {
                    SyncCheckpointDao_Impl.this.__db.beginTransaction();
                    try {
                        pe9VarAcquire.executeUpdateDelete();
                        SyncCheckpointDao_Impl.this.__db.setTransactionSuccessful();
                        return e6a.a;
                    } finally {
                        SyncCheckpointDao_Impl.this.__db.endTransaction();
                    }
                } finally {
                    SyncCheckpointDao_Impl.this.__preparedStmtOfDeleteByPrefix.release(pe9VarAcquire);
                }
            }
        }, continuation);
    }

    @Override // com.strmr.ps.data.local.dao.SyncCheckpointDao
    public Object getCheckpoint(String str, Continuation<? super SyncCheckpoint> continuation) {
        final p58 p58VarD = p58.d(1, "SELECT * FROM sync_checkpoints WHERE syncType = ?");
        return mk1.c(this.__db, false, vw2.f(p58VarD, 1, str), new Callable<SyncCheckpoint>() { // from class: com.strmr.ps.data.local.dao.SyncCheckpointDao_Impl.13
            /* JADX WARN: Can't rename method to resolve collision */
            @Override // java.util.concurrent.Callable
            @rq6
            public SyncCheckpoint call() throws Exception {
                Cursor cursorB = sp1.b(SyncCheckpointDao_Impl.this.__db, p58VarD, false);
                try {
                    int iB = yn1.b(cursorB, "syncType");
                    int iB2 = yn1.b(cursorB, "currentPage");
                    int iB3 = yn1.b(cursorB, "isInProgress");
                    int iB4 = yn1.b(cursorB, "itemsSynced");
                    int iB5 = yn1.b(cursorB, "totalItems");
                    int iB6 = yn1.b(cursorB, "startedAt");
                    int iB7 = yn1.b(cursorB, "lastUpdatedAt");
                    SyncCheckpoint syncCheckpoint = null;
                    if (cursorB.moveToFirst()) {
                        syncCheckpoint = new SyncCheckpoint(cursorB.getString(iB), cursorB.getInt(iB2), cursorB.getInt(iB3) != 0, cursorB.getInt(iB4), cursorB.isNull(iB5) ? null : Integer.valueOf(cursorB.getInt(iB5)), cursorB.getLong(iB6), cursorB.getLong(iB7));
                    }
                    return syncCheckpoint;
                } finally {
                    cursorB.close();
                    p58VarD.release();
                }
            }
        }, continuation);
    }

    @Override // com.strmr.ps.data.local.dao.SyncCheckpointDao
    public Object getLastPage(String str, Continuation<? super Integer> continuation) {
        final p58 p58VarD = p58.d(1, "SELECT currentPage FROM sync_checkpoints WHERE syncType = ?");
        return mk1.c(this.__db, false, vw2.f(p58VarD, 1, str), new Callable<Integer>() { // from class: com.strmr.ps.data.local.dao.SyncCheckpointDao_Impl.14
            /* JADX WARN: Can't rename method to resolve collision */
            @Override // java.util.concurrent.Callable
            @rq6
            public Integer call() throws Exception {
                Cursor cursorB = sp1.b(SyncCheckpointDao_Impl.this.__db, p58VarD, false);
                try {
                    Integer numValueOf = null;
                    if (cursorB.moveToFirst() && !cursorB.isNull(0)) {
                        numValueOf = Integer.valueOf(cursorB.getInt(0));
                    }
                    return numValueOf;
                } finally {
                    cursorB.close();
                    p58VarD.release();
                }
            }
        }, continuation);
    }

    @Override // com.strmr.ps.data.local.dao.SyncCheckpointDao
    public Object isInProgress(String str, Continuation<? super Boolean> continuation) {
        final p58 p58VarD = p58.d(1, "SELECT isInProgress FROM sync_checkpoints WHERE syncType = ?");
        return mk1.c(this.__db, false, vw2.f(p58VarD, 1, str), new Callable<Boolean>() { // from class: com.strmr.ps.data.local.dao.SyncCheckpointDao_Impl.15
            /* JADX WARN: Can't rename method to resolve collision */
            @Override // java.util.concurrent.Callable
            @rq6
            public Boolean call() throws Exception {
                Cursor cursorB = sp1.b(SyncCheckpointDao_Impl.this.__db, p58VarD, false);
                try {
                    Boolean boolValueOf = null;
                    if (cursorB.moveToFirst()) {
                        Integer numValueOf = cursorB.isNull(0) ? null : Integer.valueOf(cursorB.getInt(0));
                        if (numValueOf != null) {
                            boolValueOf = Boolean.valueOf(numValueOf.intValue() != 0);
                        }
                    }
                    return boolValueOf;
                } finally {
                    cursorB.close();
                    p58VarD.release();
                }
            }
        }, continuation);
    }

    @Override // com.strmr.ps.data.local.dao.SyncCheckpointDao
    public Object markComplete(final String str, final long j, Continuation<? super e6a> continuation) {
        return mk1.b(this.__db, new Callable<e6a>() { // from class: com.strmr.ps.data.local.dao.SyncCheckpointDao_Impl.9
            /* JADX WARN: Can't rename method to resolve collision */
            @Override // java.util.concurrent.Callable
            @vo6
            public e6a call() throws Exception {
                pe9 pe9VarAcquire = SyncCheckpointDao_Impl.this.__preparedStmtOfMarkComplete.acquire();
                pe9VarAcquire.bindLong(1, j);
                pe9VarAcquire.bindString(2, str);
                try {
                    SyncCheckpointDao_Impl.this.__db.beginTransaction();
                    try {
                        pe9VarAcquire.executeUpdateDelete();
                        SyncCheckpointDao_Impl.this.__db.setTransactionSuccessful();
                        return e6a.a;
                    } finally {
                        SyncCheckpointDao_Impl.this.__db.endTransaction();
                    }
                } finally {
                    SyncCheckpointDao_Impl.this.__preparedStmtOfMarkComplete.release(pe9VarAcquire);
                }
            }
        }, continuation);
    }

    @Override // com.strmr.ps.data.local.dao.SyncCheckpointDao
    public Object updateProgress(final String str, final int i, final int i2, final long j, Continuation<? super e6a> continuation) {
        return mk1.b(this.__db, new Callable<e6a>() { // from class: com.strmr.ps.data.local.dao.SyncCheckpointDao_Impl.8
            /* JADX WARN: Can't rename method to resolve collision */
            @Override // java.util.concurrent.Callable
            @vo6
            public e6a call() throws Exception {
                pe9 pe9VarAcquire = SyncCheckpointDao_Impl.this.__preparedStmtOfUpdateProgress.acquire();
                pe9VarAcquire.bindLong(1, i);
                pe9VarAcquire.bindLong(2, i2);
                pe9VarAcquire.bindLong(3, j);
                pe9VarAcquire.bindString(4, str);
                try {
                    SyncCheckpointDao_Impl.this.__db.beginTransaction();
                    try {
                        pe9VarAcquire.executeUpdateDelete();
                        SyncCheckpointDao_Impl.this.__db.setTransactionSuccessful();
                        return e6a.a;
                    } finally {
                        SyncCheckpointDao_Impl.this.__db.endTransaction();
                    }
                } finally {
                    SyncCheckpointDao_Impl.this.__preparedStmtOfUpdateProgress.release(pe9VarAcquire);
                }
            }
        }, continuation);
    }

    @Override // com.strmr.ps.data.local.dao.SyncCheckpointDao
    public Object upsert(final SyncCheckpoint syncCheckpoint, Continuation<? super e6a> continuation) {
        return mk1.b(this.__db, new Callable<e6a>() { // from class: com.strmr.ps.data.local.dao.SyncCheckpointDao_Impl.7
            /* JADX WARN: Can't rename method to resolve collision */
            @Override // java.util.concurrent.Callable
            @vo6
            public e6a call() throws Exception {
                SyncCheckpointDao_Impl.this.__db.beginTransaction();
                try {
                    SyncCheckpointDao_Impl.this.__insertionAdapterOfSyncCheckpoint.insert(syncCheckpoint);
                    SyncCheckpointDao_Impl.this.__db.setTransactionSuccessful();
                    return e6a.a;
                } finally {
                    SyncCheckpointDao_Impl.this.__db.endTransaction();
                }
            }
        }, continuation);
    }
}
