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

import android.database.Cursor;
import android.os.CancellationSignal;
import androidx.media3.extractor.text.ttml.TtmlNode;
import androidx.room.RoomDatabase;
import com.google.android.gms.measurement.api.AppMeasurementSdk;
import com.strmr.ps.data.local.entity.PendingTraktAction;
import com.strmr.ps.data.local.entity.PlaybackProgress;
import defpackage.cr4;
import defpackage.e6a;
import defpackage.j43;
import defpackage.mk1;
import defpackage.oq8;
import defpackage.p58;
import defpackage.pe9;
import defpackage.qh1;
import defpackage.sp1;
import defpackage.vo6;
import defpackage.vw2;
import defpackage.wm2;
import defpackage.xm2;
import defpackage.yn1;
import java.util.ArrayList;
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 PendingTraktActionDao_Impl implements PendingTraktActionDao {
    private final qh1 __converters = new qh1();
    private final RoomDatabase __db;
    private final xm2<PendingTraktAction> __insertionAdapterOfPendingTraktAction;
    private final oq8 __preparedStmtOfDelete;
    private final oq8 __preparedStmtOfDeleteAll;
    private final oq8 __preparedStmtOfDeleteFailedActions;
    private final oq8 __preparedStmtOfIncrementRetry;
    private final wm2<PendingTraktAction> __updateAdapterOfPendingTraktAction;

    public PendingTraktActionDao_Impl(@vo6 RoomDatabase roomDatabase) {
        this.__db = roomDatabase;
        this.__insertionAdapterOfPendingTraktAction = new xm2<PendingTraktAction>(roomDatabase) { // from class: com.strmr.ps.data.local.dao.PendingTraktActionDao_Impl.1
            @Override // defpackage.oq8
            @vo6
            public String createQuery() {
                return "INSERT OR REPLACE INTO `pending_trakt_actions` (`id`,`actionType`,`tmdbId`,`contentType`,`season`,`episode`,`rating`,`retryCount`,`lastError`,`createdAt`,`lastAttemptAt`) VALUES (nullif(?, 0),?,?,?,?,?,?,?,?,?,?)";
            }

            @Override // defpackage.xm2
            public void bind(@vo6 pe9 pe9Var, @vo6 PendingTraktAction pendingTraktAction) {
                pe9Var.bindLong(1, pendingTraktAction.getId());
                qh1 qh1Var = PendingTraktActionDao_Impl.this.__converters;
                PendingTraktAction.ActionType actionType = pendingTraktAction.getActionType();
                qh1Var.getClass();
                cr4.g(actionType, AppMeasurementSdk.ConditionalUserProperty.VALUE);
                pe9Var.bindString(2, actionType.name());
                pe9Var.bindLong(3, pendingTraktAction.getTmdbId());
                pe9Var.bindString(4, pendingTraktAction.getContentType());
                if (pendingTraktAction.getSeason() == null) {
                    pe9Var.bindNull(5);
                } else {
                    pe9Var.bindLong(5, pendingTraktAction.getSeason().intValue());
                }
                if (pendingTraktAction.getEpisode() == null) {
                    pe9Var.bindNull(6);
                } else {
                    pe9Var.bindLong(6, pendingTraktAction.getEpisode().intValue());
                }
                if (pendingTraktAction.getRating() == null) {
                    pe9Var.bindNull(7);
                } else {
                    pe9Var.bindLong(7, pendingTraktAction.getRating().intValue());
                }
                pe9Var.bindLong(8, pendingTraktAction.getRetryCount());
                if (pendingTraktAction.getLastError() == null) {
                    pe9Var.bindNull(9);
                } else {
                    pe9Var.bindString(9, pendingTraktAction.getLastError());
                }
                pe9Var.bindLong(10, pendingTraktAction.getCreatedAt());
                if (pendingTraktAction.getLastAttemptAt() == null) {
                    pe9Var.bindNull(11);
                } else {
                    pe9Var.bindLong(11, pendingTraktAction.getLastAttemptAt().longValue());
                }
            }
        };
        this.__updateAdapterOfPendingTraktAction = new wm2<PendingTraktAction>(roomDatabase) { // from class: com.strmr.ps.data.local.dao.PendingTraktActionDao_Impl.2
            @Override // defpackage.oq8
            @vo6
            public String createQuery() {
                return "UPDATE OR ABORT `pending_trakt_actions` SET `id` = ?,`actionType` = ?,`tmdbId` = ?,`contentType` = ?,`season` = ?,`episode` = ?,`rating` = ?,`retryCount` = ?,`lastError` = ?,`createdAt` = ?,`lastAttemptAt` = ? WHERE `id` = ?";
            }

            @Override // defpackage.wm2
            public void bind(@vo6 pe9 pe9Var, @vo6 PendingTraktAction pendingTraktAction) {
                pe9Var.bindLong(1, pendingTraktAction.getId());
                qh1 qh1Var = PendingTraktActionDao_Impl.this.__converters;
                PendingTraktAction.ActionType actionType = pendingTraktAction.getActionType();
                qh1Var.getClass();
                cr4.g(actionType, AppMeasurementSdk.ConditionalUserProperty.VALUE);
                pe9Var.bindString(2, actionType.name());
                pe9Var.bindLong(3, pendingTraktAction.getTmdbId());
                pe9Var.bindString(4, pendingTraktAction.getContentType());
                if (pendingTraktAction.getSeason() == null) {
                    pe9Var.bindNull(5);
                } else {
                    pe9Var.bindLong(5, pendingTraktAction.getSeason().intValue());
                }
                if (pendingTraktAction.getEpisode() == null) {
                    pe9Var.bindNull(6);
                } else {
                    pe9Var.bindLong(6, pendingTraktAction.getEpisode().intValue());
                }
                if (pendingTraktAction.getRating() == null) {
                    pe9Var.bindNull(7);
                } else {
                    pe9Var.bindLong(7, pendingTraktAction.getRating().intValue());
                }
                pe9Var.bindLong(8, pendingTraktAction.getRetryCount());
                if (pendingTraktAction.getLastError() == null) {
                    pe9Var.bindNull(9);
                } else {
                    pe9Var.bindString(9, pendingTraktAction.getLastError());
                }
                pe9Var.bindLong(10, pendingTraktAction.getCreatedAt());
                if (pendingTraktAction.getLastAttemptAt() == null) {
                    pe9Var.bindNull(11);
                } else {
                    pe9Var.bindLong(11, pendingTraktAction.getLastAttemptAt().longValue());
                }
                pe9Var.bindLong(12, pendingTraktAction.getId());
            }
        };
        this.__preparedStmtOfDelete = new oq8(roomDatabase) { // from class: com.strmr.ps.data.local.dao.PendingTraktActionDao_Impl.3
            @Override // defpackage.oq8
            @vo6
            public String createQuery() {
                return "DELETE FROM pending_trakt_actions WHERE id = ?";
            }
        };
        this.__preparedStmtOfDeleteAll = new oq8(roomDatabase) { // from class: com.strmr.ps.data.local.dao.PendingTraktActionDao_Impl.4
            @Override // defpackage.oq8
            @vo6
            public String createQuery() {
                return "DELETE FROM pending_trakt_actions";
            }
        };
        this.__preparedStmtOfDeleteFailedActions = new oq8(roomDatabase) { // from class: com.strmr.ps.data.local.dao.PendingTraktActionDao_Impl.5
            @Override // defpackage.oq8
            @vo6
            public String createQuery() {
                return "DELETE FROM pending_trakt_actions WHERE retryCount >= ?";
            }
        };
        this.__preparedStmtOfIncrementRetry = new oq8(roomDatabase) { // from class: com.strmr.ps.data.local.dao.PendingTraktActionDao_Impl.6
            @Override // defpackage.oq8
            @vo6
            public String createQuery() {
                return "\n        UPDATE pending_trakt_actions\n        SET retryCount = retryCount + 1,\n            lastAttemptAt = ?,\n            lastError = ?\n        WHERE id = ?\n    ";
            }
        };
    }

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

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

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

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

    @Override // com.strmr.ps.data.local.dao.PendingTraktActionDao
    public Object getAllPending(Continuation<? super List<PendingTraktAction>> continuation) {
        final p58 p58VarD = p58.d(0, "SELECT * FROM pending_trakt_actions ORDER BY createdAt ASC");
        return mk1.c(this.__db, false, new CancellationSignal(), new Callable<List<PendingTraktAction>>() { // from class: com.strmr.ps.data.local.dao.PendingTraktActionDao_Impl.13
            @Override // java.util.concurrent.Callable
            @vo6
            public List<PendingTraktAction> call() throws Exception {
                Cursor cursorB = sp1.b(PendingTraktActionDao_Impl.this.__db, p58VarD, false);
                try {
                    int iB = yn1.b(cursorB, TtmlNode.ATTR_ID);
                    int iB2 = yn1.b(cursorB, "actionType");
                    int iB3 = yn1.b(cursorB, "tmdbId");
                    int iB4 = yn1.b(cursorB, "contentType");
                    int iB5 = yn1.b(cursorB, "season");
                    int iB6 = yn1.b(cursorB, PlaybackProgress.TYPE_EPISODE);
                    int iB7 = yn1.b(cursorB, "rating");
                    int iB8 = yn1.b(cursorB, "retryCount");
                    int iB9 = yn1.b(cursorB, "lastError");
                    int iB10 = yn1.b(cursorB, "createdAt");
                    int iB11 = yn1.b(cursorB, "lastAttemptAt");
                    ArrayList arrayList = new ArrayList(cursorB.getCount());
                    while (cursorB.moveToNext()) {
                        long j = cursorB.getLong(iB);
                        String string = cursorB.getString(iB2);
                        PendingTraktActionDao_Impl.this.__converters.getClass();
                        cr4.g(string, AppMeasurementSdk.ConditionalUserProperty.VALUE);
                        arrayList.add(new PendingTraktAction(j, PendingTraktAction.ActionType.valueOf(string), cursorB.getInt(iB3), cursorB.getString(iB4), cursorB.isNull(iB5) ? null : Integer.valueOf(cursorB.getInt(iB5)), cursorB.isNull(iB6) ? null : Integer.valueOf(cursorB.getInt(iB6)), cursorB.isNull(iB7) ? null : Integer.valueOf(cursorB.getInt(iB7)), cursorB.getInt(iB8), cursorB.isNull(iB9) ? null : cursorB.getString(iB9), cursorB.getLong(iB10), cursorB.isNull(iB11) ? null : Long.valueOf(cursorB.getLong(iB11))));
                    }
                    return arrayList;
                } finally {
                    cursorB.close();
                    p58VarD.release();
                }
            }
        }, continuation);
    }

    @Override // com.strmr.ps.data.local.dao.PendingTraktActionDao
    public Object getPendingCount(Continuation<? super Integer> continuation) {
        final p58 p58VarD = p58.d(0, "SELECT COUNT(*) FROM pending_trakt_actions");
        return mk1.c(this.__db, false, new CancellationSignal(), new Callable<Integer>() { // from class: com.strmr.ps.data.local.dao.PendingTraktActionDao_Impl.16
            /* JADX WARN: Can't rename method to resolve collision */
            @Override // java.util.concurrent.Callable
            @vo6
            public Integer call() throws Exception {
                Cursor cursorB = sp1.b(PendingTraktActionDao_Impl.this.__db, p58VarD, false);
                try {
                    int iValueOf = cursorB.moveToFirst() ? Integer.valueOf(cursorB.getInt(0)) : 0;
                    cursorB.close();
                    p58VarD.release();
                    return iValueOf;
                } catch (Throwable th) {
                    cursorB.close();
                    p58VarD.release();
                    throw th;
                }
            }
        }, continuation);
    }

    @Override // com.strmr.ps.data.local.dao.PendingTraktActionDao
    public Object getPendingWithRetriesLeft(int i, Continuation<? super List<PendingTraktAction>> continuation) {
        final p58 p58VarD = p58.d(1, "\n        SELECT * FROM pending_trakt_actions\n        WHERE retryCount < ?\n        ORDER BY createdAt ASC\n    ");
        return mk1.c(this.__db, false, vw2.e(p58VarD, 1, i), new Callable<List<PendingTraktAction>>() { // from class: com.strmr.ps.data.local.dao.PendingTraktActionDao_Impl.14
            @Override // java.util.concurrent.Callable
            @vo6
            public List<PendingTraktAction> call() throws Exception {
                Cursor cursorB = sp1.b(PendingTraktActionDao_Impl.this.__db, p58VarD, false);
                try {
                    int iB = yn1.b(cursorB, TtmlNode.ATTR_ID);
                    int iB2 = yn1.b(cursorB, "actionType");
                    int iB3 = yn1.b(cursorB, "tmdbId");
                    int iB4 = yn1.b(cursorB, "contentType");
                    int iB5 = yn1.b(cursorB, "season");
                    int iB6 = yn1.b(cursorB, PlaybackProgress.TYPE_EPISODE);
                    int iB7 = yn1.b(cursorB, "rating");
                    int iB8 = yn1.b(cursorB, "retryCount");
                    int iB9 = yn1.b(cursorB, "lastError");
                    int iB10 = yn1.b(cursorB, "createdAt");
                    int iB11 = yn1.b(cursorB, "lastAttemptAt");
                    ArrayList arrayList = new ArrayList(cursorB.getCount());
                    while (cursorB.moveToNext()) {
                        long j = cursorB.getLong(iB);
                        String string = cursorB.getString(iB2);
                        PendingTraktActionDao_Impl.this.__converters.getClass();
                        cr4.g(string, AppMeasurementSdk.ConditionalUserProperty.VALUE);
                        arrayList.add(new PendingTraktAction(j, PendingTraktAction.ActionType.valueOf(string), cursorB.getInt(iB3), cursorB.getString(iB4), cursorB.isNull(iB5) ? null : Integer.valueOf(cursorB.getInt(iB5)), cursorB.isNull(iB6) ? null : Integer.valueOf(cursorB.getInt(iB6)), cursorB.isNull(iB7) ? null : Integer.valueOf(cursorB.getInt(iB7)), cursorB.getInt(iB8), cursorB.isNull(iB9) ? null : cursorB.getString(iB9), cursorB.getLong(iB10), cursorB.isNull(iB11) ? null : Long.valueOf(cursorB.getLong(iB11))));
                    }
                    return arrayList;
                } finally {
                    cursorB.close();
                    p58VarD.release();
                }
            }
        }, continuation);
    }

    @Override // com.strmr.ps.data.local.dao.PendingTraktActionDao
    public Object hasPendingActions(Continuation<? super Boolean> continuation) {
        final p58 p58VarD = p58.d(0, "SELECT EXISTS(SELECT 1 FROM pending_trakt_actions LIMIT 1)");
        return mk1.c(this.__db, false, new CancellationSignal(), new Callable<Boolean>() { // from class: com.strmr.ps.data.local.dao.PendingTraktActionDao_Impl.17
            /* JADX WARN: Can't rename method to resolve collision */
            @Override // java.util.concurrent.Callable
            @vo6
            public Boolean call() throws Exception {
                Boolean boolValueOf;
                Cursor cursorB = sp1.b(PendingTraktActionDao_Impl.this.__db, p58VarD, false);
                try {
                    if (cursorB.moveToFirst()) {
                        boolValueOf = Boolean.valueOf(cursorB.getInt(0) != 0);
                    } else {
                        boolValueOf = Boolean.FALSE;
                    }
                    cursorB.close();
                    p58VarD.release();
                    return boolValueOf;
                } catch (Throwable th) {
                    cursorB.close();
                    p58VarD.release();
                    throw th;
                }
            }
        }, continuation);
    }

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

    @Override // com.strmr.ps.data.local.dao.PendingTraktActionDao
    public Object insert(final PendingTraktAction pendingTraktAction, Continuation<? super Long> continuation) {
        return mk1.b(this.__db, new Callable<Long>() { // from class: com.strmr.ps.data.local.dao.PendingTraktActionDao_Impl.7
            /* JADX WARN: Can't rename method to resolve collision */
            @Override // java.util.concurrent.Callable
            @vo6
            public Long call() throws Exception {
                PendingTraktActionDao_Impl.this.__db.beginTransaction();
                try {
                    Long lValueOf = Long.valueOf(PendingTraktActionDao_Impl.this.__insertionAdapterOfPendingTraktAction.insertAndReturnId(pendingTraktAction));
                    PendingTraktActionDao_Impl.this.__db.setTransactionSuccessful();
                    return lValueOf;
                } finally {
                    PendingTraktActionDao_Impl.this.__db.endTransaction();
                }
            }
        }, continuation);
    }

    @Override // com.strmr.ps.data.local.dao.PendingTraktActionDao
    public j43<Integer> observePendingCount() {
        final p58 p58VarD = p58.d(0, "SELECT COUNT(*) FROM pending_trakt_actions");
        return mk1.a(this.__db, false, new String[]{"pending_trakt_actions"}, new Callable<Integer>() { // from class: com.strmr.ps.data.local.dao.PendingTraktActionDao_Impl.15
            public void finalize() {
                p58VarD.release();
            }

            /* JADX WARN: Can't rename method to resolve collision */
            @Override // java.util.concurrent.Callable
            @vo6
            public Integer call() throws Exception {
                Cursor cursorB = sp1.b(PendingTraktActionDao_Impl.this.__db, p58VarD, false);
                try {
                    int iValueOf = cursorB.moveToFirst() ? Integer.valueOf(cursorB.getInt(0)) : 0;
                    cursorB.close();
                    return iValueOf;
                } catch (Throwable th) {
                    cursorB.close();
                    throw th;
                }
            }
        });
    }

    @Override // com.strmr.ps.data.local.dao.PendingTraktActionDao
    public Object update(final PendingTraktAction pendingTraktAction, Continuation<? super e6a> continuation) {
        return mk1.b(this.__db, new Callable<e6a>() { // from class: com.strmr.ps.data.local.dao.PendingTraktActionDao_Impl.8
            /* JADX WARN: Can't rename method to resolve collision */
            @Override // java.util.concurrent.Callable
            @vo6
            public e6a call() throws Exception {
                PendingTraktActionDao_Impl.this.__db.beginTransaction();
                try {
                    PendingTraktActionDao_Impl.this.__updateAdapterOfPendingTraktAction.handle(pendingTraktAction);
                    PendingTraktActionDao_Impl.this.__db.setTransactionSuccessful();
                    return e6a.a;
                } finally {
                    PendingTraktActionDao_Impl.this.__db.endTransaction();
                }
            }
        }, continuation);
    }
}
