package r2;

import java.text.CharacterIterator;

/* loaded from: classes.dex */
public final class u implements CharacterIterator {

    /* renamed from: p, reason: collision with root package name */
    private final CharSequence f34385p;

    /* renamed from: q, reason: collision with root package name */
    private final int f34386q;

    /* renamed from: r, reason: collision with root package name */
    private final int f34387r;

    /* renamed from: s, reason: collision with root package name */
    private int f34388s;

    public u(CharSequence charSequence, int i10, int i11) {
        this.f34385p = charSequence;
        this.f34386q = i10;
        this.f34387r = i11;
        this.f34388s = i10;
    }

    @Override // java.text.CharacterIterator
    public Object clone() {
        try {
            return super.clone();
        } catch (CloneNotSupportedException unused) {
            throw new InternalError();
        }
    }

    @Override // java.text.CharacterIterator
    public char current() {
        int i10 = this.f34388s;
        if (i10 == this.f34387r) {
            return (char) 65535;
        }
        return this.f34385p.charAt(i10);
    }

    @Override // java.text.CharacterIterator
    public char first() {
        this.f34388s = this.f34386q;
        return current();
    }

    @Override // java.text.CharacterIterator
    public int getBeginIndex() {
        return this.f34386q;
    }

    @Override // java.text.CharacterIterator
    public int getEndIndex() {
        return this.f34387r;
    }

    @Override // java.text.CharacterIterator
    public int getIndex() {
        return this.f34388s;
    }

    @Override // java.text.CharacterIterator
    public char last() {
        int i10 = this.f34386q;
        int i11 = this.f34387r;
        if (i10 == i11) {
            this.f34388s = i11;
            return (char) 65535;
        }
        int i12 = i11 - 1;
        this.f34388s = i12;
        return this.f34385p.charAt(i12);
    }

    @Override // java.text.CharacterIterator
    public char next() {
        int i10 = this.f34388s + 1;
        this.f34388s = i10;
        int i11 = this.f34387r;
        if (i10 < i11) {
            return this.f34385p.charAt(i10);
        }
        this.f34388s = i11;
        return (char) 65535;
    }

    @Override // java.text.CharacterIterator
    public char previous() {
        int i10 = this.f34388s;
        if (i10 <= this.f34386q) {
            return (char) 65535;
        }
        int i11 = i10 - 1;
        this.f34388s = i11;
        return this.f34385p.charAt(i11);
    }

    @Override // java.text.CharacterIterator
    public char setIndex(int i10) {
        int i11 = this.f34386q;
        boolean z10 = false;
        if (i10 <= this.f34387r && i11 <= i10) {
            z10 = true;
        }
        if (!z10) {
            throw new IllegalArgumentException("invalid position");
        }
        this.f34388s = i10;
        return current();
    }
}
