package A4;

import java.util.Iterator;
import java.util.NoSuchElementException;
import r4.AbstractC0983h;
import s4.InterfaceC1015a;

/* JADX INFO: loaded from: classes.dex */
public final class d implements Iterator, InterfaceC1015a {

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

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public int f83l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public int f84m;

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public int f85n;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public int f86o;

    public d(String str) {
        AbstractC0983h.e("string", str);
        this.f82k = str;
    }

    @Override // java.util.Iterator
    public final boolean hasNext() {
        int i;
        int i5;
        int i6 = this.f83l;
        if (i6 != 0) {
            return i6 == 1;
        }
        if (this.f86o < 0) {
            this.f83l = 2;
            return false;
        }
        String str = this.f82k;
        int length = str.length();
        int length2 = str.length();
        for (int i7 = this.f84m; i7 < length2; i7++) {
            char cCharAt = str.charAt(i7);
            if (cCharAt == '\n' || cCharAt == '\r') {
                i = (cCharAt == '\r' && (i5 = i7 + 1) < str.length() && str.charAt(i5) == '\n') ? 2 : 1;
                length = i7;
                this.f83l = 1;
                this.f86o = i;
                this.f85n = length;
                return true;
            }
        }
        i = -1;
        this.f83l = 1;
        this.f86o = i;
        this.f85n = length;
        return true;
    }

    @Override // java.util.Iterator
    public final Object next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        this.f83l = 0;
        int i = this.f85n;
        int i5 = this.f84m;
        this.f84m = this.f86o + i;
        return this.f82k.subSequence(i5, i).toString();
    }

    @Override // java.util.Iterator
    public final void remove() {
        throw new UnsupportedOperationException("Operation is not supported for read-only collection");
    }
}
