package com.google.android.gms.internal.atv_ads_framework;

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

/* JADX INFO: loaded from: classes2.dex */
public abstract class i implements Iterator {

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

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

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

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

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

    public i(d1 d1Var, String str) {
        this.f19932c = str;
    }

    @Override // java.util.Iterator
    /* JADX INFO: renamed from: a, reason: merged with bridge method [inline-methods] */
    public final boolean hasNext() {
        int i10;
        int i11 = this.f19931b;
        if (i11 == 4) {
            throw new IllegalStateException();
        }
        int i12 = i11 - 1;
        String string = null;
        if (i11 == 0) {
            throw null;
        }
        if (i12 == 0) {
            return true;
        }
        if (i12 != 2) {
            this.f19931b = 4;
            int i13 = this.f19933d;
            while (true) {
                int length = this.f19933d;
                if (length == -1) {
                    this.f19931b = 3;
                    break;
                }
                CharSequence charSequence = ((h) this).f19932c;
                int length2 = charSequence.length();
                hb.a.R0(length, length2);
                while (true) {
                    if (length >= length2) {
                        length = -1;
                        break;
                    }
                    if (charSequence.charAt(length) == ':') {
                        break;
                    }
                    length++;
                }
                CharSequence charSequence2 = this.f19932c;
                if (length == -1) {
                    length = charSequence2.length();
                    this.f19933d = -1;
                    i10 = -1;
                } else {
                    i10 = length + 1;
                    this.f19933d = i10;
                }
                if (i10 == i13) {
                    int i14 = i10 + 1;
                    this.f19933d = i14;
                    if (i14 > charSequence2.length()) {
                        this.f19933d = -1;
                    }
                } else {
                    if (i13 < length) {
                        charSequence2.charAt(i13);
                    }
                    if (i13 < length) {
                        charSequence2.charAt(length - 1);
                    }
                    int i15 = this.f19934e;
                    if (i15 == 1) {
                        length = charSequence2.length();
                        this.f19933d = -1;
                        if (length > i13) {
                            charSequence2.charAt(length - 1);
                        }
                    } else {
                        this.f19934e = i15 - 1;
                    }
                    string = charSequence2.subSequence(i13, length).toString();
                }
            }
            this.f19930a = string;
            if (this.f19931b != 3) {
                this.f19931b = 1;
                return true;
            }
        }
        return false;
    }

    @Override // java.util.Iterator
    /* JADX INFO: renamed from: b, reason: merged with bridge method [inline-methods] */
    public final Object next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        this.f19931b = 2;
        String str = this.f19930a;
        this.f19930a = null;
        return str;
    }

    public final void c() {
        throw new UnsupportedOperationException();
    }

    @Override // java.util.Iterator
    public final /* bridge */ /* synthetic */ void remove() {
        c();
        throw null;
    }
}
