package kotlin.text;

import java.util.Iterator;
import java.util.NoSuchElementException;
import kotlin.Pair;

/* JADX INFO: loaded from: classes.dex */
public final class b implements Iterator, td.a {

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

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

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

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public xd.c f29265d;

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

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final /* synthetic */ c f29267f;

    public b(c cVar) {
        this.f29267f = cVar;
        int i10 = cVar.f29269b;
        int length = cVar.f29268a.length();
        if (length < 0) {
            throw new IllegalArgumentException(defpackage.e.e("Cannot coerce value to an empty range: maximum ", length, " is less than minimum 0."));
        }
        if (i10 < 0) {
            i10 = 0;
        } else if (i10 > length) {
            i10 = length;
        }
        this.f29263b = i10;
        this.f29264c = i10;
    }

    /* JADX WARN: Removed duplicated region for block: B:9:0x001b  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void a() {
        Pair pair;
        int i10 = this.f29264c;
        if (i10 < 0) {
            this.f29262a = 0;
            this.f29265d = null;
            return;
        }
        c cVar = this.f29267f;
        int i11 = cVar.f29270c;
        if (i11 > 0) {
            int i12 = this.f29266e + 1;
            this.f29266e = i12;
            if (i12 >= i11) {
                this.f29265d = new xd.c(this.f29263b, i.m0(cVar.f29268a), 1);
                this.f29264c = -1;
            } else if (i10 <= cVar.f29268a.length() && (pair = (Pair) cVar.f29271d.invoke(cVar.f29268a, Integer.valueOf(this.f29264c))) != null) {
                int iIntValue = ((Number) pair.getFirst()).intValue();
                int iIntValue2 = ((Number) pair.getSecond()).intValue();
                this.f29265d = ua.b.M(this.f29263b, iIntValue);
                int i13 = iIntValue + iIntValue2;
                this.f29263b = i13;
                this.f29264c = i13 + (iIntValue2 == 0 ? 1 : 0);
            } else {
                this.f29265d = new xd.c(this.f29263b, i.m0(cVar.f29268a), 1);
                this.f29264c = -1;
            }
        }
        this.f29262a = 1;
    }

    @Override // java.util.Iterator
    public final boolean hasNext() {
        if (this.f29262a == -1) {
            a();
        }
        return this.f29262a == 1;
    }

    @Override // java.util.Iterator
    public final Object next() {
        if (this.f29262a == -1) {
            a();
        }
        if (this.f29262a == 0) {
            throw new NoSuchElementException();
        }
        xd.c cVar = this.f29265d;
        nb.g.g(cVar, "null cannot be cast to non-null type kotlin.ranges.IntRange");
        this.f29265d = null;
        this.f29262a = -1;
        return cVar;
    }

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