package kotlin.text;

import java.util.Iterator;
import java.util.NoSuchElementException;

/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes3.dex */
public final class e implements rp.h {

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

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

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

    /* renamed from: d, reason: collision with root package name */
    private final dn.p f26495d;

    /* loaded from: classes3.dex */
    public static final class a implements Iterator, en.a {

        /* renamed from: p, reason: collision with root package name */
        private int f26496p = -1;

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

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

        /* renamed from: s, reason: collision with root package name */
        private jn.i f26499s;

        /* renamed from: t, reason: collision with root package name */
        private int f26500t;

        a() {
            int k10;
            k10 = jn.o.k(e.this.f26493b, 0, e.this.f26492a.length());
            this.f26497q = k10;
            this.f26498r = k10;
        }

        /* JADX WARN: Code restructure failed: missing block: B:9:0x0021, code lost:
        
            if (r0 < r6.f26501u.f26494c) goto L9;
         */
        /*
            Code decompiled incorrectly, please refer to instructions dump.
        */
        private final void a() {
            jn.i q10;
            int b02;
            int b03;
            if (this.f26498r < 0) {
                this.f26496p = 0;
                this.f26499s = null;
                return;
            }
            if (e.this.f26494c > 0) {
                int i10 = this.f26500t + 1;
                this.f26500t = i10;
            }
            if (this.f26498r <= e.this.f26492a.length()) {
                rm.v vVar = (rm.v) e.this.f26495d.invoke(e.this.f26492a, Integer.valueOf(this.f26498r));
                if (vVar == null) {
                    int i11 = this.f26497q;
                    b02 = z.b0(e.this.f26492a);
                    this.f26499s = new jn.i(i11, b02);
                    this.f26498r = -1;
                } else {
                    int intValue = ((Number) vVar.a()).intValue();
                    int intValue2 = ((Number) vVar.b()).intValue();
                    q10 = jn.o.q(this.f26497q, intValue);
                    this.f26499s = q10;
                    int i12 = intValue + intValue2;
                    this.f26497q = i12;
                    this.f26498r = i12 + (intValue2 == 0 ? 1 : 0);
                }
                this.f26496p = 1;
            }
            int i13 = this.f26497q;
            b03 = z.b0(e.this.f26492a);
            this.f26499s = new jn.i(i13, b03);
            this.f26498r = -1;
            this.f26496p = 1;
        }

        @Override // java.util.Iterator
        /* renamed from: b, reason: merged with bridge method [inline-methods] */
        public jn.i next() {
            if (this.f26496p == -1) {
                a();
            }
            if (this.f26496p == 0) {
                throw new NoSuchElementException();
            }
            jn.i iVar = this.f26499s;
            kotlin.jvm.internal.t.e(iVar, "null cannot be cast to non-null type kotlin.ranges.IntRange");
            this.f26499s = null;
            this.f26496p = -1;
            return iVar;
        }

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

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

    public e(CharSequence input, int i10, int i11, dn.p getNextMatch) {
        kotlin.jvm.internal.t.g(input, "input");
        kotlin.jvm.internal.t.g(getNextMatch, "getNextMatch");
        this.f26492a = input;
        this.f26493b = i10;
        this.f26494c = i11;
        this.f26495d = getNextMatch;
    }

    @Override // rp.h
    public Iterator iterator() {
        return new a();
    }
}
