package g.m0;

import g.h0.b.p;
import g.h0.c.l;
import g.k;
import java.util.Iterator;
import java.util.NoSuchElementException;

/* JADX INFO: compiled from: Strings.kt */
/* JADX INFO: loaded from: classes.dex */
@g.i
public final class b implements g.l0.d<g.j0.h> {
    public final CharSequence a;

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

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

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final p<CharSequence, Integer, k<Integer, Integer>> f4161d;

    /* JADX INFO: compiled from: Strings.kt */
    @g.i
    public static final class a implements Iterator<g.j0.h>, g.h0.c.g0.a {

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

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

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

        /* JADX INFO: renamed from: g, reason: collision with root package name */
        public g.j0.h f4165g;

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

        public a() {
            int i2 = b.this.f4159b;
            int length = b.this.a.length();
            if (length >= 0) {
                if (i2 < 0) {
                    i2 = 0;
                } else if (i2 > length) {
                    i2 = length;
                }
                this.f4163e = i2;
                this.f4164f = i2;
                return;
            }
            throw new IllegalArgumentException("Cannot coerce value to an empty range: maximum " + length + " is less than minimum 0.");
        }

        /* JADX WARN: Removed duplicated region for block: B:11:0x0023  */
        /* JADX WARN: Removed duplicated region for block: B:9:0x001b  */
        /*
            Code decompiled incorrectly, please refer to instructions dump.
            To view partially-correct add '--show-bad-code' argument
        */
        public final void b() {
            /*
                r7 = this;
                int r0 = r7.f4164f
                r1 = 0
                if (r0 >= 0) goto Lc
                r7.f4162b = r1
                r0 = 0
                r7.f4165g = r0
                goto L82
            Lc:
                g.m0.b r2 = g.m0.b.this
                int r3 = r2.f4160c
                r4 = -1
                r5 = 1
                if (r3 <= 0) goto L1b
                int r6 = r7.f4166h
                int r6 = r6 + r5
                r7.f4166h = r6
                if (r6 >= r3) goto L23
            L1b:
                java.lang.CharSequence r2 = r2.a
                int r2 = r2.length()
                if (r0 <= r2) goto L37
            L23:
                g.j0.h r0 = new g.j0.h
                int r1 = r7.f4163e
                g.m0.b r2 = g.m0.b.this
                java.lang.CharSequence r2 = r2.a
                int r2 = g.m0.f.h(r2)
                r0.<init>(r1, r2)
                r7.f4165g = r0
                r7.f4164f = r4
                goto L80
            L37:
                g.m0.b r0 = g.m0.b.this
                g.h0.b.p<java.lang.CharSequence, java.lang.Integer, g.k<java.lang.Integer, java.lang.Integer>> r2 = r0.f4161d
                java.lang.CharSequence r0 = r0.a
                int r3 = r7.f4164f
                java.lang.Integer r3 = java.lang.Integer.valueOf(r3)
                java.lang.Object r0 = r2.d(r0, r3)
                g.k r0 = (g.k) r0
                if (r0 != 0) goto L5f
                g.j0.h r0 = new g.j0.h
                int r1 = r7.f4163e
                g.m0.b r2 = g.m0.b.this
                java.lang.CharSequence r2 = r2.a
                int r2 = g.m0.f.h(r2)
                r0.<init>(r1, r2)
                r7.f4165g = r0
                r7.f4164f = r4
                goto L80
            L5f:
                A r2 = r0.f4139b
                java.lang.Number r2 = (java.lang.Number) r2
                int r2 = r2.intValue()
                B r0 = r0.f4140e
                java.lang.Number r0 = (java.lang.Number) r0
                int r0 = r0.intValue()
                int r3 = r7.f4163e
                g.j0.h r3 = g.j0.l.d(r3, r2)
                r7.f4165g = r3
                int r2 = r2 + r0
                r7.f4163e = r2
                if (r0 != 0) goto L7d
                r1 = r5
            L7d:
                int r2 = r2 + r1
                r7.f4164f = r2
            L80:
                r7.f4162b = r5
            L82:
                return
            */
            throw new UnsupportedOperationException("Method not decompiled: g.m0.b.a.b():void");
        }

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

        @Override // java.util.Iterator
        public g.j0.h next() {
            if (this.f4162b == -1) {
                b();
            }
            if (this.f4162b == 0) {
                throw new NoSuchElementException();
            }
            g.j0.h hVar = this.f4165g;
            l.d(hVar, "null cannot be cast to non-null type kotlin.ranges.IntRange");
            this.f4165g = null;
            this.f4162b = -1;
            return hVar;
        }

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

    /* JADX WARN: Multi-variable type inference failed */
    public b(CharSequence charSequence, int i2, int i3, p<? super CharSequence, ? super Integer, k<Integer, Integer>> pVar) {
        l.f(charSequence, "input");
        l.f(pVar, "getNextMatch");
        this.a = charSequence;
        this.f4159b = i2;
        this.f4160c = i3;
        this.f4161d = pVar;
    }

    @Override // g.l0.d
    public Iterator<g.j0.h> iterator() {
        return new a();
    }
}
