package androidx.room.util;

import android.os.Build;
import java.util.ArrayList;
import kotlin.collections.n;

/* JADX INFO: loaded from: classes.dex */
public abstract class f {
    public static final int a(k3.c cVar, String str) {
        nb.g.i(cVar, "<this>");
        int iB = b(cVar, str);
        if (iB >= 0) {
            return iB;
        }
        int iB2 = b(cVar, "`" + str + '`');
        if (iB2 >= 0) {
            return iB2;
        }
        int i10 = -1;
        if (Build.VERSION.SDK_INT <= 25 && str.length() != 0) {
            int columnCount = cVar.getColumnCount();
            String strConcat = ".".concat(str);
            String str2 = "." + str + '`';
            for (int i11 = 0; i11 < columnCount; i11++) {
                String columnName = cVar.getColumnName(i11);
                if (columnName.length() >= str.length() + 2 && (kotlin.text.h.b0(columnName, strConcat, false) || (columnName.charAt(0) == '`' && kotlin.text.h.b0(columnName, str2, false)))) {
                    i10 = i11;
                    break;
                }
            }
        }
        return i10;
    }

    public static final int b(k3.c cVar, String str) {
        nb.g.i(cVar, "<this>");
        nb.g.i(str, "name");
        int columnCount = cVar.getColumnCount();
        for (int i10 = 0; i10 < columnCount; i10++) {
            if (nb.g.c(str, cVar.getColumnName(i10))) {
                return i10;
            }
        }
        return -1;
    }

    public static final int c(k3.c cVar, String str) {
        nb.g.i(cVar, "stmt");
        int iA = a(cVar, str);
        if (iA >= 0) {
            return iA;
        }
        int columnCount = cVar.getColumnCount();
        ArrayList arrayList = new ArrayList(columnCount);
        for (int i10 = 0; i10 < columnCount; i10++) {
            arrayList.add(cVar.getColumnName(i10));
        }
        throw new IllegalArgumentException("Column '" + str + "' does not exist. Available columns: [" + n.j1(arrayList, null, null, null, null, 63) + ']');
    }
}
