package o;

import java.text.BreakIterator;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.r0, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C2295r0 extends AbstractC2201q0 {
    public static C2295r0 e;
    public static C2295r0 f;
    public static C2295r0 g;
    public final /* synthetic */ int c;
    public Object d;

    @Override // o.AbstractC2201q0
    public final int[] e(int i) {
        int iD;
        switch (this.c) {
            case 0:
                String str = (String) this.a;
                if (str == null) {
                    str = null;
                }
                int length = str.length();
                if (length <= 0 || i >= length) {
                    return null;
                }
                if (i < 0) {
                    i = 0;
                }
                do {
                    BreakIterator breakIterator = (BreakIterator) this.d;
                    if (breakIterator == null) {
                        breakIterator = null;
                    }
                    if (breakIterator.isBoundary(i)) {
                        BreakIterator breakIterator2 = (BreakIterator) this.d;
                        if (breakIterator2 == null) {
                            breakIterator2 = null;
                        }
                        int iFollowing = breakIterator2.following(i);
                        if (iFollowing == -1) {
                            return null;
                        }
                        return h(i, iFollowing);
                    }
                    BreakIterator breakIterator3 = (BreakIterator) this.d;
                    if (breakIterator3 == null) {
                        breakIterator3 = null;
                    }
                    i = breakIterator3.following(i);
                } while (i != -1);
                return null;
            case 1:
                String str2 = (String) this.a;
                if (str2 == null) {
                    str2 = null;
                }
                if (str2.length() <= 0) {
                    return null;
                }
                String str3 = (String) this.a;
                if (str3 == null) {
                    str3 = null;
                }
                if (i >= str3.length()) {
                    return null;
                }
                if (i < 0) {
                    i = 0;
                }
                while (!o(i) && (!o(i) || (i != 0 && o(i - 1)))) {
                    BreakIterator breakIterator4 = (BreakIterator) this.d;
                    if (breakIterator4 == null) {
                        breakIterator4 = null;
                    }
                    i = breakIterator4.following(i);
                    if (i == -1) {
                        return null;
                    }
                }
                BreakIterator breakIterator5 = (BreakIterator) this.d;
                if (breakIterator5 == null) {
                    breakIterator5 = null;
                }
                int iFollowing2 = breakIterator5.following(i);
                if (iFollowing2 == -1 || !n(iFollowing2)) {
                    return null;
                }
                return h(i, iFollowing2);
            default:
                String str4 = (String) this.a;
                if (str4 == null) {
                    str4 = null;
                }
                if (str4.length() <= 0) {
                    return null;
                }
                String str5 = (String) this.a;
                if (str5 == null) {
                    str5 = null;
                }
                if (i >= str5.length()) {
                    return null;
                }
                if (i < 0) {
                    Ne0 ne0 = (Ne0) this.d;
                    if (ne0 == null) {
                        ne0 = null;
                    }
                    iD = ne0.b.d(0);
                } else {
                    Ne0 ne02 = (Ne0) this.d;
                    if (ne02 == null) {
                        ne02 = null;
                    }
                    int iD2 = ne02.b.d(i);
                    iD = l(iD2, 2) == i ? iD2 : iD2 + 1;
                }
                Ne0 ne03 = (Ne0) this.d;
                if (ne03 == null) {
                    ne03 = null;
                }
                if (iD >= ne03.b.f) {
                    return null;
                }
                return h(l(iD, 2), l(iD, 1) + 1);
        }
    }

    @Override // o.AbstractC2201q0
    public final int[] j(int i) {
        int iD;
        switch (this.c) {
            case 0:
                String str = (String) this.a;
                if (str == null) {
                    str = null;
                }
                int length = str.length();
                if (length <= 0 || i <= 0) {
                    return null;
                }
                if (i > length) {
                    i = length;
                }
                do {
                    BreakIterator breakIterator = (BreakIterator) this.d;
                    if (breakIterator == null) {
                        breakIterator = null;
                    }
                    if (breakIterator.isBoundary(i)) {
                        BreakIterator breakIterator2 = (BreakIterator) this.d;
                        if (breakIterator2 == null) {
                            breakIterator2 = null;
                        }
                        int iPreceding = breakIterator2.preceding(i);
                        if (iPreceding == -1) {
                            return null;
                        }
                        return h(iPreceding, i);
                    }
                    BreakIterator breakIterator3 = (BreakIterator) this.d;
                    if (breakIterator3 == null) {
                        breakIterator3 = null;
                    }
                    i = breakIterator3.preceding(i);
                } while (i != -1);
                return null;
            case 1:
                String str2 = (String) this.a;
                if (str2 == null) {
                    str2 = null;
                }
                int length2 = str2.length();
                if (length2 <= 0 || i <= 0) {
                    return null;
                }
                if (i > length2) {
                    i = length2;
                }
                while (i > 0 && !o(i - 1) && !n(i)) {
                    BreakIterator breakIterator4 = (BreakIterator) this.d;
                    if (breakIterator4 == null) {
                        breakIterator4 = null;
                    }
                    i = breakIterator4.preceding(i);
                    if (i == -1) {
                        return null;
                    }
                }
                BreakIterator breakIterator5 = (BreakIterator) this.d;
                if (breakIterator5 == null) {
                    breakIterator5 = null;
                }
                int iPreceding2 = breakIterator5.preceding(i);
                if (iPreceding2 == -1 || !o(iPreceding2)) {
                    return null;
                }
                if (iPreceding2 == 0 || !o(iPreceding2 - 1)) {
                    return h(iPreceding2, i);
                }
                return null;
            default:
                String str3 = (String) this.a;
                if (str3 == null) {
                    str3 = null;
                }
                if (str3.length() <= 0 || i <= 0) {
                    return null;
                }
                String str4 = (String) this.a;
                if (str4 == null) {
                    str4 = null;
                }
                if (i > str4.length()) {
                    Ne0 ne0 = (Ne0) this.d;
                    if (ne0 == null) {
                        ne0 = null;
                    }
                    String str5 = (String) this.a;
                    if (str5 == null) {
                        str5 = null;
                    }
                    iD = ne0.b.d(str5.length());
                } else {
                    Ne0 ne02 = (Ne0) this.d;
                    if (ne02 == null) {
                        ne02 = null;
                    }
                    int iD2 = ne02.b.d(i);
                    iD = l(iD2, 1) + 1 == i ? iD2 : iD2 - 1;
                }
                if (iD < 0) {
                    return null;
                }
                return h(l(iD, 2), l(iD, 1) + 1);
        }
    }

    public int l(int i, int i2) {
        Ne0 ne0 = (Ne0) this.d;
        if (ne0 == null) {
            ne0 = null;
        }
        int iG = ne0.g(i);
        Ne0 ne02 = (Ne0) this.d;
        if (ne02 == null) {
            ne02 = null;
        }
        if (i2 != ne02.h(iG)) {
            Ne0 ne03 = (Ne0) this.d;
            return (ne03 != null ? ne03 : null).g(i);
        }
        return Ne0.d(((Ne0) this.d) != null ? r5 : null, i) - 1;
    }

    public void m(String str) {
        switch (this.c) {
            case 0:
                this.a = str;
                BreakIterator breakIterator = (BreakIterator) this.d;
                if (breakIterator == null) {
                    breakIterator = null;
                }
                breakIterator.setText(str);
                break;
            default:
                this.a = str;
                BreakIterator breakIterator2 = (BreakIterator) this.d;
                if (breakIterator2 == null) {
                    breakIterator2 = null;
                }
                breakIterator2.setText(str);
                break;
        }
    }

    public boolean n(int i) {
        if (i <= 0 || !o(i - 1)) {
            return false;
        }
        String str = (String) this.a;
        if (str == null) {
            str = null;
        }
        return i == str.length() || !o(i);
    }

    public boolean o(int i) {
        if (i < 0) {
            return false;
        }
        String str = (String) this.a;
        if (str == null) {
            str = null;
        }
        if (i >= str.length()) {
            return false;
        }
        String str2 = (String) this.a;
        return Character.isLetterOrDigit((str2 != null ? str2 : null).codePointAt(i));
    }
}
