package o;

import java.io.File;
import java.util.ArrayList;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class SV implements Comparable {
    public static final String m = File.separator;
    public final C0135Ff l;

    public SV(C0135Ff c0135Ff) {
        this.l = c0135Ff;
    }

    public final ArrayList a() {
        ArrayList arrayList = new ArrayList();
        int iA = AbstractC1153f.a(this);
        C0135Ff c0135Ff = this.l;
        if (iA == -1) {
            iA = 0;
        } else if (iA < c0135Ff.b() && c0135Ff.g(iA) == 92) {
            iA++;
        }
        int iB = c0135Ff.b();
        int i = iA;
        while (iA < iB) {
            if (c0135Ff.g(iA) == 47 || c0135Ff.g(iA) == 92) {
                arrayList.add(c0135Ff.k(i, iA));
                i = iA + 1;
            }
            iA++;
        }
        if (i < c0135Ff.b()) {
            arrayList.add(c0135Ff.k(i, c0135Ff.b()));
        }
        return arrayList;
    }

    public final SV b() {
        C0135Ff c0135Ff = AbstractC1153f.d;
        C0135Ff c0135Ff2 = this.l;
        if (F3.c(c0135Ff2, c0135Ff)) {
            return null;
        }
        C0135Ff c0135Ff3 = AbstractC1153f.a;
        if (F3.c(c0135Ff2, c0135Ff3)) {
            return null;
        }
        C0135Ff c0135Ff4 = AbstractC1153f.b;
        if (F3.c(c0135Ff2, c0135Ff4)) {
            return null;
        }
        C0135Ff c0135Ff5 = AbstractC1153f.e;
        int iB = c0135Ff2.b();
        byte[] bArr = c0135Ff5.l;
        if (c0135Ff2.i(iB - bArr.length, c0135Ff5, bArr.length) && (c0135Ff2.b() == 2 || c0135Ff2.i(c0135Ff2.b() - 3, c0135Ff3, 1) || c0135Ff2.i(c0135Ff2.b() - 3, c0135Ff4, 1))) {
            return null;
        }
        c0135Ff2.getClass();
        int iH = c0135Ff2.h(c0135Ff3.f());
        if (iH == -1) {
            c0135Ff2.getClass();
            iH = c0135Ff2.h(c0135Ff4.f());
        }
        if (iH == 2 && e() != null) {
            if (c0135Ff2.b() == 3) {
                return null;
            }
            return new SV(C0135Ff.l(c0135Ff2, 0, 3, 1));
        }
        if (iH == 1 && c0135Ff2.i(0, c0135Ff4, c0135Ff4.b())) {
            return null;
        }
        if (iH != -1 || e() == null) {
            return iH == -1 ? new SV(c0135Ff) : iH == 0 ? new SV(C0135Ff.l(c0135Ff2, 0, 1, 1)) : new SV(C0135Ff.l(c0135Ff2, 0, iH, 1));
        }
        if (c0135Ff2.b() == 2) {
            return null;
        }
        return new SV(C0135Ff.l(c0135Ff2, 0, 2, 1));
    }

    public final SV c(SV sv) {
        int iA = AbstractC1153f.a(this);
        C0135Ff c0135Ff = this.l;
        SV sv2 = iA == -1 ? null : new SV(c0135Ff.k(0, iA));
        sv.getClass();
        C0135Ff c0135Ff2 = sv.l;
        int iA2 = AbstractC1153f.a(sv);
        if (!F3.c(sv2, iA2 != -1 ? new SV(c0135Ff2.k(0, iA2)) : null)) {
            throw new IllegalArgumentException(("Paths of different roots cannot be relative to each other: " + this + " and " + sv).toString());
        }
        ArrayList arrayListA = a();
        ArrayList arrayListA2 = sv.a();
        int iMin = Math.min(arrayListA.size(), arrayListA2.size());
        int i = 0;
        while (i < iMin && F3.c(arrayListA.get(i), arrayListA2.get(i))) {
            i++;
        }
        if (i == iMin && c0135Ff.b() == c0135Ff2.b()) {
            return BP.n(".");
        }
        if (arrayListA2.subList(i, arrayListA2.size()).indexOf(AbstractC1153f.e) != -1) {
            throw new IllegalArgumentException(("Impossible relative path to resolve: " + this + " and " + sv).toString());
        }
        C0732af c0732af = new C0732af();
        C0135Ff c0135FfC = AbstractC1153f.c(sv);
        if (c0135FfC == null && (c0135FfC = AbstractC1153f.c(this)) == null) {
            c0135FfC = AbstractC1153f.f(m);
        }
        int size = arrayListA2.size();
        for (int i2 = i; i2 < size; i2++) {
            c0732af.D(AbstractC1153f.e);
            c0732af.D(c0135FfC);
        }
        int size2 = arrayListA.size();
        while (i < size2) {
            c0732af.D((C0135Ff) arrayListA.get(i));
            c0732af.D(c0135FfC);
            i++;
        }
        return AbstractC1153f.d(c0732af, false);
    }

    @Override // java.lang.Comparable
    public final int compareTo(Object obj) {
        return this.l.compareTo(((SV) obj).l);
    }

    public final SV d(String str) {
        C0732af c0732af = new C0732af();
        c0732af.V(str);
        return AbstractC1153f.b(this, AbstractC1153f.d(c0732af, false), false);
    }

    public final Character e() {
        C0135Ff c0135Ff = AbstractC1153f.a;
        C0135Ff c0135Ff2 = this.l;
        if (C0135Ff.e(c0135Ff2, c0135Ff) != -1 || c0135Ff2.b() < 2 || c0135Ff2.g(1) != 58) {
            return null;
        }
        char cG = (char) c0135Ff2.g(0);
        if (('a' > cG || cG >= '{') && ('A' > cG || cG >= '[')) {
            return null;
        }
        return Character.valueOf(cG);
    }

    public final boolean equals(Object obj) {
        return (obj instanceof SV) && F3.c(((SV) obj).l, this.l);
    }

    public final int hashCode() {
        return this.l.hashCode();
    }

    public final File toFile() {
        return new File(this.l.n());
    }

    public final String toString() {
        return this.l.n();
    }
}
