package o;

import android.os.Build;
import androidx.work.impl.WorkDatabase;
import java.io.ByteArrayOutputStream;
import java.io.ObjectOutputStream;
import java.util.Set;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.xr, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C2945xr extends AbstractC2218q80 {
    public final /* synthetic */ int d;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public /* synthetic */ C2945xr(WorkDatabase workDatabase, int i) {
        super(workDatabase);
        this.d = i;
    }

    @Override // o.AbstractC2218q80
    public final String b() {
        switch (this.d) {
            case 0:
                return "INSERT OR IGNORE INTO `Dependency` (`work_spec_id`,`prerequisite_id`) VALUES (?,?)";
            case 1:
                return "INSERT OR REPLACE INTO `Preference` (`key`,`long_value`) VALUES (?,?)";
            case 2:
                return "INSERT OR REPLACE INTO `SystemIdInfo` (`work_spec_id`,`generation`,`system_id`) VALUES (?,?,?)";
            case 3:
                return "INSERT OR IGNORE INTO `WorkName` (`name`,`work_spec_id`) VALUES (?,?)";
            case 4:
                return "INSERT OR REPLACE INTO `WorkProgress` (`work_spec_id`,`progress`) VALUES (?,?)";
            case 5:
                return "INSERT OR IGNORE INTO `WorkSpec` (`id`,`state`,`worker_class_name`,`input_merger_class_name`,`input`,`output`,`initial_delay`,`interval_duration`,`flex_duration`,`run_attempt_count`,`backoff_policy`,`backoff_delay_duration`,`last_enqueue_time`,`minimum_retention_duration`,`schedule_requested_at`,`run_in_foreground`,`out_of_quota_policy`,`period_count`,`generation`,`next_schedule_time_override`,`next_schedule_time_override_generation`,`stop_reason`,`required_network_type`,`requires_charging`,`requires_device_idle`,`requires_battery_not_low`,`requires_storage_not_low`,`trigger_content_update_delay`,`trigger_max_content_delay`,`content_uri_triggers`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
            default:
                return "INSERT OR IGNORE INTO `WorkTag` (`tag`,`work_spec_id`) VALUES (?,?)";
        }
    }

    public final void d(LC lc, Object obj) throws Throwable {
        int i;
        int i2;
        byte[] byteArray;
        switch (this.d) {
            case 0:
                C2565tr c2565tr = (C2565tr) obj;
                String str = c2565tr.a;
                if (str == null) {
                    lc.r(1);
                } else {
                    lc.k(1, str);
                }
                String str2 = c2565tr.b;
                if (str2 == null) {
                    lc.r(2);
                    return;
                } else {
                    lc.k(2, str2);
                    return;
                }
            case 1:
                C1294gY c1294gY = (C1294gY) obj;
                lc.k(1, c1294gY.a);
                lc.B(2, c1294gY.b.longValue());
                return;
            case 2:
                String str3 = ((C1872mc0) obj).a;
                if (str3 == null) {
                    lc.r(1);
                } else {
                    lc.k(1, str3);
                }
                lc.B(2, r2.b);
                lc.B(3, r2.c);
                return;
            case 3:
                lc.r(1);
                String str4 = ((C2936xm0) obj).a;
                if (str4 == null) {
                    lc.r(2);
                    return;
                } else {
                    lc.k(2, str4);
                    return;
                }
            case 4:
                throw new ClassCastException();
            case 5:
                Dm0 dm0 = (Dm0) obj;
                String str5 = dm0.a;
                int i3 = 1;
                if (str5 == null) {
                    lc.r(1);
                } else {
                    lc.k(1, str5);
                }
                lc.B(2, YT.T(dm0.b));
                String str6 = dm0.c;
                if (str6 == null) {
                    lc.r(3);
                } else {
                    lc.k(3, str6);
                }
                String str7 = dm0.d;
                if (str7 == null) {
                    lc.r(4);
                } else {
                    lc.k(4, str7);
                }
                byte[] bArrB = C0585Wo.b(dm0.e);
                if (bArrB == null) {
                    lc.r(5);
                } else {
                    lc.E(5, bArrB);
                }
                byte[] bArrB2 = C0585Wo.b(dm0.f);
                if (bArrB2 == null) {
                    lc.r(6);
                } else {
                    lc.E(6, bArrB2);
                }
                lc.B(7, dm0.g);
                lc.B(8, dm0.h);
                lc.B(9, dm0.i);
                lc.B(10, dm0.k);
                int iW = AbstractC2462sn.w(dm0.l);
                if (iW == 0) {
                    i = 0;
                } else {
                    if (iW != 1) {
                        throw new C2170pj();
                    }
                    i = 1;
                }
                lc.B(11, i);
                lc.B(12, dm0.m);
                lc.B(13, dm0.n);
                lc.B(14, dm0.f85o);
                lc.B(15, dm0.p);
                lc.B(16, dm0.q ? 1L : 0L);
                int iW2 = AbstractC2462sn.w(dm0.r);
                if (iW2 == 0) {
                    i2 = 0;
                } else {
                    if (iW2 != 1) {
                        throw new C2170pj();
                    }
                    i2 = 1;
                }
                lc.B(17, i2);
                lc.B(18, dm0.s);
                lc.B(19, dm0.t);
                lc.B(20, dm0.u);
                lc.B(21, dm0.v);
                lc.B(22, dm0.w);
                C0608Xl c0608Xl = dm0.j;
                if (c0608Xl == null) {
                    lc.r(23);
                    lc.r(24);
                    lc.r(25);
                    lc.r(26);
                    lc.r(27);
                    lc.r(28);
                    lc.r(29);
                    lc.r(30);
                    return;
                }
                int i4 = c0608Xl.a;
                int iW3 = AbstractC2462sn.w(i4);
                if (iW3 == 0) {
                    i3 = 0;
                } else if (iW3 != 1) {
                    if (iW3 == 2) {
                        i3 = 2;
                    } else if (iW3 == 3) {
                        i3 = 3;
                    } else if (iW3 == 4) {
                        i3 = 4;
                    } else {
                        if (Build.VERSION.SDK_INT < 30 || i4 != 6) {
                            throw new IllegalArgumentException("Could not convert " + AbstractC0126Ew.s(i4) + " to int");
                        }
                        i3 = 5;
                    }
                }
                lc.B(23, i3);
                lc.B(24, c0608Xl.b ? 1L : 0L);
                lc.B(25, c0608Xl.c ? 1L : 0L);
                lc.B(26, c0608Xl.d ? 1L : 0L);
                lc.B(27, c0608Xl.e ? 1L : 0L);
                lc.B(28, c0608Xl.f);
                lc.B(29, c0608Xl.g);
                Set<C0582Wl> set = c0608Xl.h;
                if (set.isEmpty()) {
                    byteArray = new byte[0];
                } else {
                    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
                    try {
                        ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
                        try {
                            objectOutputStream.writeInt(set.size());
                            for (C0582Wl c0582Wl : set) {
                                objectOutputStream.writeUTF(c0582Wl.a.toString());
                                objectOutputStream.writeBoolean(c0582Wl.b);
                            }
                            objectOutputStream.close();
                            byteArrayOutputStream.close();
                            byteArray = byteArrayOutputStream.toByteArray();
                        } finally {
                        }
                    } catch (Throwable th) {
                        try {
                            throw th;
                        } catch (Throwable th2) {
                            C1884mi0.o(byteArrayOutputStream, th);
                            throw th2;
                        }
                    }
                }
                lc.E(30, byteArray);
                return;
            default:
                Fm0 fm0 = (Fm0) obj;
                String str8 = fm0.a;
                if (str8 == null) {
                    lc.r(1);
                } else {
                    lc.k(1, str8);
                }
                String str9 = fm0.b;
                if (str9 == null) {
                    lc.r(2);
                    return;
                } else {
                    lc.k(2, str9);
                    return;
                }
        }
    }

    public final void e(Object obj) {
        LC lcA = a();
        try {
            d(lcA, obj);
            lcA.m.executeInsert();
        } finally {
            c(lcA);
        }
    }
}
