package E3;

import C0.B;
import java.util.Iterator;
import java.util.NoSuchElementException;
import m1.AbstractC2464a;

/* JADX INFO: loaded from: classes3.dex */
public final class m implements Iterator {

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public String f1157b;

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

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final c f1159d;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public final /* synthetic */ B f1162j;

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

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

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public int f1161f = Integer.MAX_VALUE;

    public m(B b5, n nVar, CharSequence charSequence) {
        this.f1162j = b5;
        this.f1159d = nVar.f1163a;
        this.f1158c = charSequence;
    }

    @Override // java.util.Iterator
    public final boolean hasNext() {
        String string;
        c cVar;
        A4.g.s(this.f1156a != 4);
        int iC = AbstractC2464a.c(this.f1156a);
        if (iC == 0) {
            return true;
        }
        if (iC != 2) {
            this.f1156a = 4;
            int i6 = this.f1160e;
            while (true) {
                int length = this.f1160e;
                if (length == -1) {
                    this.f1156a = 3;
                    string = null;
                    break;
                }
                b bVar = (b) this.f1162j.f506b;
                CharSequence charSequence = this.f1158c;
                int length2 = charSequence.length();
                A4.g.p(length, length2);
                while (true) {
                    if (length >= length2) {
                        length = -1;
                        break;
                    }
                    if (bVar.a(charSequence.charAt(length))) {
                        break;
                    }
                    length++;
                }
                if (length == -1) {
                    length = charSequence.length();
                    this.f1160e = -1;
                } else {
                    this.f1160e = length + 1;
                }
                int i7 = this.f1160e;
                if (i7 == i6) {
                    int i8 = i7 + 1;
                    this.f1160e = i8;
                    if (i8 > charSequence.length()) {
                        this.f1160e = -1;
                    }
                } else {
                    while (true) {
                        cVar = this.f1159d;
                        if (i6 >= length || !cVar.a(charSequence.charAt(i6))) {
                            break;
                        }
                        i6++;
                    }
                    while (length > i6 && cVar.a(charSequence.charAt(length - 1))) {
                        length--;
                    }
                    int i9 = this.f1161f;
                    if (i9 == 1) {
                        length = charSequence.length();
                        this.f1160e = -1;
                        while (length > i6 && cVar.a(charSequence.charAt(length - 1))) {
                            length--;
                        }
                    } else {
                        this.f1161f = i9 - 1;
                    }
                    string = charSequence.subSequence(i6, length).toString();
                }
            }
            this.f1157b = string;
            if (this.f1156a != 3) {
                this.f1156a = 1;
                return true;
            }
        }
        return false;
    }

    @Override // java.util.Iterator
    public final Object next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        this.f1156a = 2;
        String str = this.f1157b;
        this.f1157b = null;
        return str;
    }

    @Override // java.util.Iterator
    public final void remove() {
        throw new UnsupportedOperationException();
    }
}
