package w2;

import android.text.Layout;
import androidx.annotation.Nullable;
import androidx.media3.common.text.Cue;

/* JADX INFO: loaded from: classes.dex */
public final class h {

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public CharSequence f34152c;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public long f34150a = 0;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public long f34151b = 0;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public int f34153d = 2;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public float f34154e = -3.4028235E38f;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public int f34155f = 1;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public int f34156g = 0;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public float f34157h = -3.4028235E38f;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public int f34158i = Integer.MIN_VALUE;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public float f34159j = 1.0f;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public int f34160k = Integer.MIN_VALUE;

    @Nullable
    private static Layout.Alignment convertTextAlignment(int i10) {
        if (i10 != 1) {
            if (i10 == 2) {
                return Layout.Alignment.ALIGN_CENTER;
            }
            if (i10 != 3) {
                if (i10 != 4) {
                    if (i10 != 5) {
                        defpackage.e.z("Unknown textAlignment: ", i10, "WebvttCueParser");
                        return null;
                    }
                }
            }
            return Layout.Alignment.ALIGN_OPPOSITE;
        }
        return Layout.Alignment.ALIGN_NORMAL;
    }

    /* JADX WARN: Removed duplicated region for block: B:21:0x0032  */
    /* JADX WARN: Removed duplicated region for block: B:22:0x0034  */
    /* JADX WARN: Removed duplicated region for block: B:30:0x0056  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Cue.Builder a() {
        float f10 = this.f34157h;
        float f11 = -3.4028235E38f;
        if (f10 == -3.4028235E38f) {
            int i10 = this.f34153d;
            f10 = i10 != 4 ? i10 != 5 ? 0.5f : 1.0f : 0.0f;
        }
        int i11 = this.f34158i;
        if (i11 == Integer.MIN_VALUE) {
            int i12 = this.f34153d;
            if (i12 == 1) {
                i11 = 0;
            } else if (i12 == 3) {
                i11 = 2;
            } else if (i12 != 4) {
                if (i12 != 5) {
                    i11 = 1;
                }
            }
        }
        Cue.Builder textAlignment = new Cue.Builder().setTextAlignment(convertTextAlignment(this.f34153d));
        float f12 = this.f34154e;
        int i13 = this.f34155f;
        if (f12 == -3.4028235E38f || i13 != 0 || (f12 >= 0.0f && f12 <= 1.0f)) {
            if (f12 != -3.4028235E38f) {
                f11 = f12;
            } else if (i13 == 0) {
                f11 = 1.0f;
            }
        }
        Cue.Builder positionAnchor = textAlignment.setLine(f11, i13).setLineAnchor(this.f34156g).setPosition(f10).setPositionAnchor(i11);
        float f13 = this.f34159j;
        if (i11 == 0) {
            f10 = 1.0f - f10;
        } else if (i11 == 1) {
            f10 = f10 <= 0.5f ? f10 * 2.0f : (1.0f - f10) * 2.0f;
        } else if (i11 != 2) {
            throw new IllegalStateException(String.valueOf(i11));
        }
        Cue.Builder verticalType = positionAnchor.setSize(Math.min(f13, f10)).setVerticalType(this.f34160k);
        CharSequence charSequence = this.f34152c;
        if (charSequence != null) {
            verticalType.setText(charSequence);
        }
        return verticalType;
    }
}
