package androidx.window.core;

import com.bytedance.sdk.component.pglcrypt.PglCryptUtils;
import java.util.ArrayList;
import java.util.Collection;
import kotlin.NoWhenBranchMatchedException;
import kotlin.collections.EmptyList;
import kotlin.collections.q;
import sd.l;

/* JADX INFO: loaded from: classes.dex */
public final class f extends i {

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final Object f4423b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final String f4424c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final String f4425d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final g f4426e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final VerificationMode f4427f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public final WindowStrictModeException f4428g;

    public f(Object obj, String str, String str2, g gVar, VerificationMode verificationMode) {
        Collection collectionL0;
        nb.g.i(obj, "value");
        nb.g.i(str, "tag");
        nb.g.i(gVar, "logger");
        nb.g.i(verificationMode, "verificationMode");
        this.f4423b = obj;
        this.f4424c = str;
        this.f4425d = str2;
        this.f4426e = gVar;
        this.f4427f = verificationMode;
        String strB = i.b(obj, str2);
        nb.g.i(strB, PglCryptUtils.KEY_MESSAGE);
        WindowStrictModeException windowStrictModeException = new WindowStrictModeException(strB);
        StackTraceElement[] stackTrace = windowStrictModeException.getStackTrace();
        nb.g.h(stackTrace, "stackTrace");
        int length = stackTrace.length - 2;
        length = length < 0 ? 0 : length;
        if (length < 0) {
            throw new IllegalArgumentException(defpackage.e.e("Requested element count ", length, " is less than zero.").toString());
        }
        if (length == 0) {
            collectionL0 = EmptyList.f29203a;
        } else {
            int length2 = stackTrace.length;
            if (length >= length2) {
                collectionL0 = q.c0(stackTrace);
            } else if (length == 1) {
                collectionL0 = hb.a.l0(stackTrace[length2 - 1]);
            } else {
                ArrayList arrayList = new ArrayList(length);
                for (int i10 = length2 - length; i10 < length2; i10++) {
                    arrayList.add(stackTrace[i10]);
                }
                collectionL0 = arrayList;
            }
        }
        windowStrictModeException.setStackTrace((StackTraceElement[]) collectionL0.toArray(new StackTraceElement[0]));
        this.f4428g = windowStrictModeException;
    }

    @Override // androidx.window.core.i
    public final Object a() throws WindowStrictModeException {
        int iOrdinal = this.f4427f.ordinal();
        if (iOrdinal == 0) {
            throw this.f4428g;
        }
        if (iOrdinal != 1) {
            if (iOrdinal == 2) {
                return null;
            }
            throw new NoWhenBranchMatchedException();
        }
        String strB = i.b(this.f4423b, this.f4425d);
        ((a) this.f4426e).getClass();
        nb.g.i(this.f4424c, "tag");
        nb.g.i(strB, PglCryptUtils.KEY_MESSAGE);
        return null;
    }

    @Override // androidx.window.core.i
    public final i c(String str, l lVar) {
        nb.g.i(lVar, "condition");
        return this;
    }
}
