package com.bytedance.sdk.openadsdk.qhl;

import java.util.ArrayList;
import java.util.List;

/* JADX INFO: loaded from: classes2.dex */
public class ro {
    public static int fm = -1;
    public static int jnr = 3;

    /* JADX INFO: renamed from: lb, reason: collision with root package name */
    public static int f7525lb = 1;
    public static int ro = 0;
    public static int yz = 2;
    private int ajl = fm;
    private long wsy = 0;
    private long wu = 0;

    /* JADX INFO: renamed from: ef, reason: collision with root package name */
    private final List<lb> f7526ef = new ArrayList();
    private long vt = 0;

    public int fm() {
        return this.ajl;
    }

    public void lb(long j10) {
        int i10;
        int i11 = this.ajl;
        if (i11 == fm || i11 == (i10 = yz) || i11 == jnr) {
            return;
        }
        this.ajl = i10;
        this.vt = j10;
    }

    public void ro(long j10) {
        int i10;
        int i11 = this.ajl;
        if (i11 == fm || i11 == (i10 = jnr)) {
            return;
        }
        this.ajl = i10;
        this.wu = j10;
    }

    public void yz(long j10) {
        int i10 = this.ajl;
        if (i10 == fm || i10 != yz) {
            return;
        }
        this.ajl = f7525lb;
        this.f7526ef.add(new lb(this.vt, j10));
        this.vt = 0L;
    }

    public void fm(long j10) {
        this.ajl = ro;
        this.wsy = j10;
    }

    public long fm(long j10, long j11) {
        long j12;
        long j13;
        long jRo;
        long j14 = this.wu;
        if (j14 != 0 && j10 > j14) {
            return 0L;
        }
        int i10 = 0;
        for (lb lbVar : this.f7526ef) {
            if (lbVar.ro() > j10) {
                if (j10 < lbVar.fm()) {
                    j13 = i10;
                    jRo = lbVar.ro() - lbVar.fm();
                } else {
                    j13 = i10;
                    jRo = lbVar.ro() - j10;
                }
                i10 = (int) (jRo + j13);
            }
        }
        long j15 = this.wsy;
        if (j15 < j10) {
            long j16 = this.vt;
            if (j16 == 0) {
                j16 = this.wu;
                if (j16 == 0) {
                    j12 = j11 - j10;
                }
            } else if (j16 <= j10) {
                return 0L;
            }
            return (j16 - j10) - ((long) i10);
        }
        long j17 = this.vt;
        if (j17 == 0) {
            j17 = this.wu;
            if (j17 == 0) {
                j12 = j11 - j15;
            }
        } else if (j17 <= j15) {
            return 0L;
        }
        return (j17 - j15) - ((long) i10);
        return j12 - ((long) i10);
    }
}
