package e9;

import java.util.ArrayList;

/* JADX INFO: loaded from: classes2.dex */
public final class i {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final float f25594a;

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

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public j f25597d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public j f25598e;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final ArrayList f25596c = new ArrayList();

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

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public int f25600g = -1;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public float f25601h = 0.0f;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public int f25602i = -1;

    public i(float f10, int i10) {
        this.f25594a = f10;
        this.f25595b = i10;
    }

    public final void a(float f10, float f11, float f12, boolean z10, boolean z11) {
        float fAbs;
        float f13 = f12 / 2.0f;
        float f14 = f10 - f13;
        float f15 = f13 + f10;
        float f16 = this.f25595b;
        if (f15 > f16) {
            fAbs = Math.abs(f15 - Math.max(f15 - f12, f16));
        } else {
            fAbs = 0.0f;
            if (f14 < 0.0f) {
                fAbs = Math.abs(f14 - Math.min(f14 + f12, 0.0f));
            }
        }
        b(f10, f11, f12, z10, z11, fAbs, 0.0f, 0.0f);
    }

    public final void b(float f10, float f11, float f12, boolean z10, boolean z11, float f13, float f14, float f15) {
        if (f12 <= 0.0f) {
            return;
        }
        ArrayList arrayList = this.f25596c;
        if (z11) {
            if (z10) {
                throw new IllegalArgumentException("Anchor keylines cannot be focal.");
            }
            int i10 = this.f25602i;
            if (i10 != -1 && i10 != 0) {
                throw new IllegalArgumentException("Anchor keylines must be either the first or last keyline.");
            }
            this.f25602i = arrayList.size();
        }
        j jVar = new j(Float.MIN_VALUE, f10, f11, f12, z11, f13, f14, f15);
        if (z10) {
            if (this.f25597d == null) {
                this.f25597d = jVar;
                this.f25599f = arrayList.size();
            }
            if (this.f25600g != -1 && arrayList.size() - this.f25600g > 1) {
                throw new IllegalArgumentException("Keylines marked as focal must be placed next to each other. There cannot be non-focal keylines between focal keylines.");
            }
            if (f12 != this.f25597d.f25606d) {
                throw new IllegalArgumentException("Keylines that are marked as focal must all have the same masked item size.");
            }
            this.f25598e = jVar;
            this.f25600g = arrayList.size();
        } else {
            if (this.f25597d == null && f12 < this.f25601h) {
                throw new IllegalArgumentException("Keylines before the first focal keyline must be ordered by incrementing masked item size.");
            }
            if (this.f25598e != null && f12 > this.f25601h) {
                throw new IllegalArgumentException("Keylines after the last focal keyline must be ordered by decreasing masked item size.");
            }
        }
        this.f25601h = f12;
        arrayList.add(jVar);
    }

    public final void c(float f10, float f11, float f12, int i10, boolean z10) {
        if (i10 <= 0 || f12 <= 0.0f) {
            return;
        }
        for (int i11 = 0; i11 < i10; i11++) {
            a((i11 * f12) + f10, f11, f12, z10, false);
        }
    }

    public final k d() {
        if (this.f25597d == null) {
            throw new IllegalStateException("There must be a keyline marked as focal.");
        }
        ArrayList arrayList = new ArrayList();
        int i10 = 0;
        while (true) {
            ArrayList arrayList2 = this.f25596c;
            if (i10 >= arrayList2.size()) {
                return new k(this.f25594a, arrayList, this.f25599f, this.f25600g, this.f25595b);
            }
            j jVar = (j) arrayList2.get(i10);
            float f10 = this.f25597d.f25604b;
            float f11 = this.f25599f;
            float f12 = this.f25594a;
            arrayList.add(new j((i10 * f12) + (f10 - (f11 * f12)), jVar.f25604b, jVar.f25605c, jVar.f25606d, jVar.f25607e, jVar.f25608f, jVar.f25609g, jVar.f25610h));
            i10++;
        }
    }
}
