package d.i;

import d.e.a.p;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.Objects;

/* JADX INFO: loaded from: classes.dex */
public final class b implements d.h.a<d.f.c> {

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

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

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

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

    public static final class a implements Iterator<d.f.c> {

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

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

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

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

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

        public a() {
            int i = b.this.f1663b;
            int length = b.this.f1662a.length();
            if (length >= 0) {
                if (i < 0) {
                    i = 0;
                } else if (i > length) {
                    i = length;
                }
                this.f1667b = i;
                this.f1668c = i;
                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:0x0022  */
        /* JADX WARN: Removed duplicated region for block: B:9:0x001a  */
        /*
            Code decompiled incorrectly, please refer to instructions dump.
            To view partially-correct add '--show-bad-code' argument
        */
        public final void a() {
            /*
                r7 = this;
                int r0 = r7.f1668c
                r1 = 0
                if (r0 >= 0) goto Lc
                r7.f1666a = r1
                r0 = 0
                r7.f1669d = r0
                goto L8b
            Lc:
                d.i.b r2 = d.i.b.this
                int r3 = r2.f1664c
                r4 = 1
                if (r3 <= 0) goto L1a
                int r5 = r7.f1670e
                int r5 = r5 + r4
                r7.f1670e = r5
                if (r5 >= r3) goto L22
            L1a:
                java.lang.CharSequence r2 = r2.f1662a
                int r2 = r2.length()
                if (r0 <= r2) goto L32
            L22:
                d.f.c r0 = new d.f.c
                int r1 = r7.f1667b
                d.i.b r2 = d.i.b.this
                java.lang.CharSequence r2 = r2.f1662a
                int r2 = d.i.j.b(r2)
                r0.<init>(r1, r2)
                goto L55
            L32:
                d.i.b r0 = d.i.b.this
                d.e.a.p<java.lang.CharSequence, java.lang.Integer, d.a<java.lang.Integer, java.lang.Integer>> r2 = r0.f1665d
                java.lang.CharSequence r0 = r0.f1662a
                int r3 = r7.f1668c
                java.lang.Integer r3 = java.lang.Integer.valueOf(r3)
                java.lang.Object r0 = r2.b(r0, r3)
                d.a r0 = (d.a) r0
                if (r0 != 0) goto L5b
                d.f.c r0 = new d.f.c
                int r1 = r7.f1667b
                d.i.b r2 = d.i.b.this
                java.lang.CharSequence r2 = r2.f1662a
                int r2 = d.i.j.b(r2)
                r0.<init>(r1, r2)
            L55:
                r7.f1669d = r0
                r0 = -1
                r7.f1668c = r0
                goto L89
            L5b:
                A r2 = r0.f1634a
                java.lang.Number r2 = (java.lang.Number) r2
                int r2 = r2.intValue()
                B r0 = r0.f1635b
                java.lang.Number r0 = (java.lang.Number) r0
                int r0 = r0.intValue()
                int r3 = r7.f1667b
                r5 = -2147483648(0xffffffff80000000, float:-0.0)
                if (r2 > r5) goto L76
                d.f.c r3 = d.f.c.f1658d
                d.f.c r3 = d.f.c.f1659e
                goto L7e
            L76:
                d.f.c r5 = new d.f.c
                int r6 = r2 + (-1)
                r5.<init>(r3, r6)
                r3 = r5
            L7e:
                r7.f1669d = r3
                int r2 = r2 + r0
                r7.f1667b = r2
                if (r0 != 0) goto L86
                r1 = r4
            L86:
                int r2 = r2 + r1
                r7.f1668c = r2
            L89:
                r7.f1666a = r4
            L8b:
                return
            */
            throw new UnsupportedOperationException("Method not decompiled: d.i.b.a.a():void");
        }

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

        @Override // java.util.Iterator
        public d.f.c next() {
            if (this.f1666a == -1) {
                a();
            }
            if (this.f1666a == 0) {
                throw new NoSuchElementException();
            }
            d.f.c cVar = this.f1669d;
            Objects.requireNonNull(cVar, "null cannot be cast to non-null type kotlin.ranges.IntRange");
            this.f1669d = null;
            this.f1666a = -1;
            return cVar;
        }

        @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 i, int i2, p<? super CharSequence, ? super Integer, d.a<Integer, Integer>> pVar) {
        d.e.b.e.d(charSequence, "input");
        d.e.b.e.d(pVar, "getNextMatch");
        this.f1662a = charSequence;
        this.f1663b = i;
        this.f1664c = i2;
        this.f1665d = pVar;
    }

    @Override // d.h.a
    public Iterator<d.f.c> iterator() {
        return new a();
    }
}
