package okio.internal;

/* JADX INFO: compiled from: r8-map-id-ae6aab8d9a1033945587ffdd1bc6222159522c1d66e66a2c4cecb065134dd0a6 */
/* JADX INFO: loaded from: E:\ios\vf_dex\classes3.dex */
@kotlin.Metadata(d1 = {"\u0000b\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u000e\n\u0002\b\u0002\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\b\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u0002\n\u0002\b\u0012\b\u0000\u0018\u0000 >2\u00020\u0001:\u0001?B#\b\u0000\u0012\u0006\u0010\u0003\u001a\u00020\u0002\u0012\u0006\u0010\u0005\u001a\u00020\u0004\u0012\b\b\u0002\u0010\u0006\u001a\u00020\u0001¢\u0006\u0004\b\u0007\u0010\bJ\u0017\u0010\u000b\u001a\u00020\t2\u0006\u0010\n\u001a\u00020\tH\u0002¢\u0006\u0004\b\u000b\u0010\fJ\u0013\u0010\u000e\u001a\u00020\r*\u00020\tH\u0002¢\u0006\u0004\b\u000e\u0010\u000fJ%\u0010\u0012\u001a\u0014\u0012\u0010\u0012\u000e\u0012\u0004\u0012\u00020\u0001\u0012\u0004\u0012\u00020\t0\u00110\u0010*\u00020\u0002H\u0002¢\u0006\u0004\b\u0012\u0010\u0013J!\u0010\u0015\u001a\u0010\u0012\u0004\u0012\u00020\u0001\u0012\u0004\u0012\u00020\t\u0018\u00010\u0011*\u00020\u0014H\u0002¢\u0006\u0004\b\u0015\u0010\u0016J!\u0010\u0017\u001a\u0010\u0012\u0004\u0012\u00020\u0001\u0012\u0004\u0012\u00020\t\u0018\u00010\u0011*\u00020\u0014H\u0002¢\u0006\u0004\b\u0017\u0010\u0016J\u001d\u0010\u0019\u001a\b\u0012\u0004\u0012\u00020\t0\u00102\u0006\u0010\u0018\u001a\u00020\tH\u0016¢\u0006\u0004\b\u0019\u0010\u001aJ\u001f\u0010\u001b\u001a\n\u0012\u0004\u0012\u00020\t\u0018\u00010\u00102\u0006\u0010\u0018\u001a\u00020\tH\u0016¢\u0006\u0004\b\u001b\u0010\u001aJ\u0017\u0010\u001e\u001a\u00020\u001d2\u0006\u0010\u001c\u001a\u00020\tH\u0016¢\u0006\u0004\b\u001e\u0010\u001fJ'\u0010\"\u001a\u00020\u001d2\u0006\u0010\u001c\u001a\u00020\t2\u0006\u0010 \u001a\u00020\u00042\u0006\u0010!\u001a\u00020\u0004H\u0016¢\u0006\u0004\b\"\u0010#J\u0019\u0010%\u001a\u0004\u0018\u00010$2\u0006\u0010\n\u001a\u00020\tH\u0016¢\u0006\u0004\b%\u0010&J\u0017\u0010(\u001a\u00020'2\u0006\u0010\u001c\u001a\u00020\tH\u0016¢\u0006\u0004\b(\u0010)J\u001f\u0010+\u001a\u00020*2\u0006\u0010\u001c\u001a\u00020\t2\u0006\u0010 \u001a\u00020\u0004H\u0016¢\u0006\u0004\b+\u0010,J\u001f\u0010-\u001a\u00020*2\u0006\u0010\u001c\u001a\u00020\t2\u0006\u0010!\u001a\u00020\u0004H\u0016¢\u0006\u0004\b-\u0010,J\u001f\u0010/\u001a\u00020.2\u0006\u0010\u0018\u001a\u00020\t2\u0006\u0010 \u001a\u00020\u0004H\u0016¢\u0006\u0004\b/\u00100J\u001f\u00103\u001a\u00020.2\u0006\u00101\u001a\u00020\t2\u0006\u00102\u001a\u00020\tH\u0016¢\u0006\u0004\b3\u00104J\u001f\u00105\u001a\u00020.2\u0006\u0010\n\u001a\u00020\t2\u0006\u0010!\u001a\u00020\u0004H\u0016¢\u0006\u0004\b5\u00100R\u0014\u0010\u0003\u001a\u00020\u00028\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b6\u00107R\u0014\u0010\u0006\u001a\u00020\u00018\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b8\u00109R-\u0010=\u001a\u0014\u0012\u0010\u0012\u000e\u0012\u0004\u0012\u00020\u0001\u0012\u0004\u0012\u00020\t0\u00110\u00108BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b/\u0010:\u001a\u0004\b;\u0010<¨\u0006@"}, d2 = {"Lokio/internal/ResourceFileSystem;", "Lokio/FileSystem;", "Ljava/lang/ClassLoader;", "classLoader", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "indexEagerly", "systemFileSystem", "<init>", "(Ljava/lang/ClassLoader;ZLokio/FileSystem;)V", "Lokio/Path;", "path", "y", "(Lokio/Path;)Lokio/Path;", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "D", "(Lokio/Path;)Ljava/lang/String;", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "Lkotlin/Pair;", "A", "(Ljava/lang/ClassLoader;)Ljava/util/List;", "Ljava/net/URL;", "B", "(Ljava/net/URL;)Lkotlin/Pair;", "C", "dir", "k", "(Lokio/Path;)Ljava/util/List;", "l", "file", "Lokio/FileHandle;", "o", "(Lokio/Path;)Lokio/FileHandle;", "mustCreate", "mustExist", "q", "(Lokio/Path;ZZ)Lokio/FileHandle;", "Lokio/FileMetadata;", "n", "(Lokio/Path;)Lokio/FileMetadata;", "Lokio/Source;", "t", "(Lokio/Path;)Lokio/Source;", "Lokio/Sink;", "s", "(Lokio/Path;Z)Lokio/Sink;", "b", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "g", "(Lokio/Path;Z)V", "source", "target", "c", "(Lokio/Path;Lokio/Path;)V", "i", "e", "Ljava/lang/ClassLoader;", "f", "Lokio/FileSystem;", "Lkotlin/Lazy;", "z", "()Ljava/util/List;", "roots", "h", "Companion", "okio"}, k = 1, mv = {1, 9, 0}, xi = 48)
@kotlin.jvm.internal.SourceDebugExtension
public final class ResourceFileSystem extends okio.FileSystem {
    private static final okio.internal.ResourceFileSystem.Companion h = new okio.internal.ResourceFileSystem.Companion(null);
    private static final okio.Path i = okio.Path.Companion.e(okio.Path.INSTANCE, "/", false, 1, null);

    /* JADX INFO: renamed from: e, reason: from kotlin metadata */
    private final java.lang.ClassLoader classLoader;

    /* JADX INFO: renamed from: f, reason: from kotlin metadata */
    private final okio.FileSystem systemFileSystem;

    /* JADX INFO: renamed from: g, reason: from kotlin metadata */
    private final kotlin.Lazy roots;

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX INFO: compiled from: r8-map-id-ae6aab8d9a1033945587ffdd1bc6222159522c1d66e66a2c4cecb065134dd0a6 */
    @kotlin.Metadata(d1 = {"\u0000\u001a\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0002\b\n\b\u0082\u0003\u0018\u00002\u00020\u0001B\t\b\u0002¢\u0006\u0004\b\u0002\u0010\u0003J\u0017\u0010\u0007\u001a\u00020\u00062\u0006\u0010\u0005\u001a\u00020\u0004H\u0002¢\u0006\u0004\b\u0007\u0010\bJ\u0019\u0010\n\u001a\u00020\u0004*\u00020\u00042\u0006\u0010\t\u001a\u00020\u0004¢\u0006\u0004\b\n\u0010\u000bR\u0017\u0010\f\u001a\u00020\u00048\u0006¢\u0006\f\n\u0004\b\f\u0010\r\u001a\u0004\b\u000e\u0010\u000f¨\u0006\u0010"}, d2 = {"Lokio/internal/ResourceFileSystem$Companion;", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "<init>", "()V", "Lokio/Path;", "path", okhttp3.HttpUrl.FRAGMENT_ENCODE_SET, "c", "(Lokio/Path;)Z", "base", "d", "(Lokio/Path;Lokio/Path;)Lokio/Path;", "ROOT", "Lokio/Path;", "b", "()Lokio/Path;", "okio"}, k = 1, mv = {1, 9, 0}, xi = 48)
    static final class Companion {
        public /* synthetic */ Companion(kotlin.jvm.internal.DefaultConstructorMarker defaultConstructorMarker) {
            this();
        }

        /* JADX INFO: Access modifiers changed from: private */
        public final boolean c(okio.Path path) {
            return !kotlin.text.StringsKt.I(path.e(), ".class", true);
        }

        public final okio.Path b() {
            return okio.internal.ResourceFileSystem.i;
        }

        public final okio.Path d(okio.Path path, okio.Path path2) {
            kotlin.jvm.internal.Intrinsics.l(path, "<this>");
            kotlin.jvm.internal.Intrinsics.l(path2, "base");
            return b().j(kotlin.text.StringsKt.S(kotlin.text.StringsKt.P0(path.toString(), path2.toString()), '\\', '/', false, 4, (java.lang.Object) null));
        }

        private Companion() {
        }
    }

    public /* synthetic */ ResourceFileSystem(java.lang.ClassLoader classLoader, boolean z, okio.FileSystem fileSystem, int i2, kotlin.jvm.internal.DefaultConstructorMarker defaultConstructorMarker) {
        this(classLoader, z, (i2 & 4) != 0 ? okio.FileSystem.b : fileSystem);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final java.util.List A(java.lang.ClassLoader classLoader) throws java.io.IOException {
        java.util.Enumeration<java.net.URL> resources = classLoader.getResources(okhttp3.HttpUrl.FRAGMENT_ENCODE_SET);
        kotlin.jvm.internal.Intrinsics.k(resources, "getResources(...)");
        java.util.ArrayList<java.net.URL> list = java.util.Collections.list(resources);
        kotlin.jvm.internal.Intrinsics.k(list, "list(...)");
        java.util.ArrayList arrayList = new java.util.ArrayList();
        for (java.net.URL url : list) {
            kotlin.jvm.internal.Intrinsics.i(url);
            kotlin.Pair pairB = B(url);
            if (pairB != null) {
                arrayList.add(pairB);
            }
        }
        java.util.Enumeration<java.net.URL> resources2 = classLoader.getResources("META-INF/MANIFEST.MF");
        kotlin.jvm.internal.Intrinsics.k(resources2, "getResources(...)");
        java.util.ArrayList<java.net.URL> list2 = java.util.Collections.list(resources2);
        kotlin.jvm.internal.Intrinsics.k(list2, "list(...)");
        java.util.ArrayList arrayList2 = new java.util.ArrayList();
        for (java.net.URL url2 : list2) {
            kotlin.jvm.internal.Intrinsics.i(url2);
            kotlin.Pair pairC = C(url2);
            if (pairC != null) {
                arrayList2.add(pairC);
            }
        }
        return kotlin.collections.CollectionsKt.Q0(arrayList, arrayList2);
    }

    private final kotlin.Pair B(java.net.URL url) {
        if (kotlin.jvm.internal.Intrinsics.g(url.getProtocol(), "file")) {
            return kotlin.TuplesKt.a(this.systemFileSystem, okio.Path.Companion.d(okio.Path.INSTANCE, new java.io.File(url.toURI()), false, 1, null));
        }
        return null;
    }

    private final kotlin.Pair C(java.net.URL url) {
        int iA0;
        java.lang.String string = url.toString();
        kotlin.jvm.internal.Intrinsics.k(string, "toString(...)");
        if (!kotlin.text.StringsKt.Z(string, "jar:file:", false, 2, (java.lang.Object) null) || (iA0 = kotlin.text.StringsKt.A0(string, "!", 0, false, 6, (java.lang.Object) null)) == -1) {
            return null;
        }
        okio.Path.Companion companion = okio.Path.INSTANCE;
        java.lang.String strSubstring = string.substring(4, iA0);
        kotlin.jvm.internal.Intrinsics.k(strSubstring, "substring(...)");
        return kotlin.TuplesKt.a(okio.internal.ZipFilesKt.d(okio.Path.Companion.d(companion, new java.io.File(java.net.URI.create(strSubstring)), false, 1, null), this.systemFileSystem, new kotlin.jvm.functions.Function1<okio.internal.ZipEntry, java.lang.Boolean>() { // from class: okio.internal.ResourceFileSystem$toJarRoot$zip$1
            /* JADX INFO: renamed from: a, reason: merged with bridge method [inline-methods] */
            public final java.lang.Boolean invoke(okio.internal.ZipEntry zipEntry) {
                kotlin.jvm.internal.Intrinsics.l(zipEntry, "entry");
                return java.lang.Boolean.valueOf(okio.internal.ResourceFileSystem.h.c(zipEntry.getCanonicalPath()));
            }
        }), i);
    }

    private final java.lang.String D(okio.Path path) {
        return y(path).i(i).toString();
    }

    private final okio.Path y(okio.Path path) {
        return i.l(path, true);
    }

    private final java.util.List z() {
        return (java.util.List) this.roots.getValue();
    }

    @Override // okio.FileSystem
    public okio.Sink b(okio.Path file, boolean mustExist) throws java.io.IOException {
        kotlin.jvm.internal.Intrinsics.l(file, "file");
        throw new java.io.IOException(this + " is read-only");
    }

    @Override // okio.FileSystem
    public void c(okio.Path source, okio.Path target) throws java.io.IOException {
        kotlin.jvm.internal.Intrinsics.l(source, "source");
        kotlin.jvm.internal.Intrinsics.l(target, "target");
        throw new java.io.IOException(this + " is read-only");
    }

    @Override // okio.FileSystem
    public void g(okio.Path dir, boolean mustCreate) throws java.io.IOException {
        kotlin.jvm.internal.Intrinsics.l(dir, "dir");
        throw new java.io.IOException(this + " is read-only");
    }

    @Override // okio.FileSystem
    public void i(okio.Path path, boolean mustExist) throws java.io.IOException {
        kotlin.jvm.internal.Intrinsics.l(path, "path");
        throw new java.io.IOException(this + " is read-only");
    }

    @Override // okio.FileSystem
    public java.util.List k(okio.Path dir) throws java.io.FileNotFoundException {
        kotlin.jvm.internal.Intrinsics.l(dir, "dir");
        java.lang.String strD = D(dir);
        java.util.LinkedHashSet linkedHashSet = new java.util.LinkedHashSet();
        boolean z = false;
        for (kotlin.Pair pair : z()) {
            okio.FileSystem fileSystem = (okio.FileSystem) pair.a();
            okio.Path path = (okio.Path) pair.b();
            try {
                java.util.List listK = fileSystem.k(path.j(strD));
                java.util.ArrayList arrayList = new java.util.ArrayList();
                for (java.lang.Object obj : listK) {
                    if (h.c((okio.Path) obj)) {
                        arrayList.add(obj);
                    }
                }
                java.util.ArrayList arrayList2 = new java.util.ArrayList(kotlin.collections.CollectionsKt.z(arrayList, 10));
                java.util.Iterator it = arrayList.iterator();
                while (it.hasNext()) {
                    arrayList2.add(h.d((okio.Path) it.next(), path));
                }
                kotlin.collections.CollectionsKt.E(linkedHashSet, arrayList2);
                z = true;
            } catch (java.io.IOException unused) {
            }
        }
        if (z) {
            return kotlin.collections.CollectionsKt.k1(linkedHashSet);
        }
        throw new java.io.FileNotFoundException("file not found: " + dir);
    }

    @Override // okio.FileSystem
    public java.util.List l(okio.Path dir) {
        kotlin.jvm.internal.Intrinsics.l(dir, "dir");
        java.lang.String strD = D(dir);
        java.util.LinkedHashSet linkedHashSet = new java.util.LinkedHashSet();
        java.util.Iterator it = z().iterator();
        boolean z = false;
        while (true) {
            java.util.ArrayList arrayList = null;
            if (!it.hasNext()) {
                break;
            }
            kotlin.Pair pair = (kotlin.Pair) it.next();
            okio.FileSystem fileSystem = (okio.FileSystem) pair.a();
            okio.Path path = (okio.Path) pair.b();
            java.util.List listL = fileSystem.l(path.j(strD));
            if (listL != null) {
                java.util.ArrayList arrayList2 = new java.util.ArrayList();
                for (java.lang.Object obj : listL) {
                    if (h.c((okio.Path) obj)) {
                        arrayList2.add(obj);
                    }
                }
                java.util.ArrayList arrayList3 = new java.util.ArrayList(kotlin.collections.CollectionsKt.z(arrayList2, 10));
                java.util.Iterator it2 = arrayList2.iterator();
                while (it2.hasNext()) {
                    arrayList3.add(h.d((okio.Path) it2.next(), path));
                }
                arrayList = arrayList3;
            }
            if (arrayList != null) {
                kotlin.collections.CollectionsKt.E(linkedHashSet, arrayList);
                z = true;
            }
        }
        if (z) {
            return kotlin.collections.CollectionsKt.k1(linkedHashSet);
        }
        return null;
    }

    @Override // okio.FileSystem
    public okio.FileMetadata n(okio.Path path) {
        kotlin.jvm.internal.Intrinsics.l(path, "path");
        if (!h.c(path)) {
            return null;
        }
        java.lang.String strD = D(path);
        for (kotlin.Pair pair : z()) {
            okio.FileMetadata fileMetadataN = ((okio.FileSystem) pair.a()).n(((okio.Path) pair.b()).j(strD));
            if (fileMetadataN != null) {
                return fileMetadataN;
            }
        }
        return null;
    }

    @Override // okio.FileSystem
    public okio.FileHandle o(okio.Path file) throws java.io.FileNotFoundException {
        kotlin.jvm.internal.Intrinsics.l(file, "file");
        if (!h.c(file)) {
            throw new java.io.FileNotFoundException("file not found: " + file);
        }
        java.lang.String strD = D(file);
        java.util.Iterator it = z().iterator();
        while (it.hasNext()) {
            kotlin.Pair pair = (kotlin.Pair) it.next();
            try {
                return ((okio.FileSystem) pair.a()).o(((okio.Path) pair.b()).j(strD));
            } catch (java.io.FileNotFoundException unused) {
            }
        }
        throw new java.io.FileNotFoundException("file not found: " + file);
    }

    @Override // okio.FileSystem
    public okio.FileHandle q(okio.Path file, boolean mustCreate, boolean mustExist) throws java.io.IOException {
        kotlin.jvm.internal.Intrinsics.l(file, "file");
        throw new java.io.IOException("resources are not writable");
    }

    @Override // okio.FileSystem
    public okio.Sink s(okio.Path file, boolean mustCreate) throws java.io.IOException {
        kotlin.jvm.internal.Intrinsics.l(file, "file");
        throw new java.io.IOException(this + " is read-only");
    }

    @Override // okio.FileSystem
    public okio.Source t(okio.Path file) throws java.io.FileNotFoundException {
        okio.Source sourceK;
        kotlin.jvm.internal.Intrinsics.l(file, "file");
        if (!h.c(file)) {
            throw new java.io.FileNotFoundException("file not found: " + file);
        }
        okio.Path path = i;
        java.io.InputStream resourceAsStream = this.classLoader.getResourceAsStream(okio.Path.m(path, file, false, 2, null).i(path).toString());
        if (resourceAsStream != null && (sourceK = okio.Okio.k(resourceAsStream)) != null) {
            return sourceK;
        }
        throw new java.io.FileNotFoundException("file not found: " + file);
    }

    public ResourceFileSystem(java.lang.ClassLoader classLoader, boolean z, okio.FileSystem fileSystem) {
        kotlin.jvm.internal.Intrinsics.l(classLoader, "classLoader");
        kotlin.jvm.internal.Intrinsics.l(fileSystem, "systemFileSystem");
        this.classLoader = classLoader;
        this.systemFileSystem = fileSystem;
        this.roots = kotlin.LazyKt.b(new kotlin.jvm.functions.Function0<java.util.List<? extends kotlin.Pair<? extends okio.FileSystem, ? extends okio.Path>>>() { // from class: okio.internal.ResourceFileSystem$roots$2
            {
                super(0);
            }

            public final java.util.List invoke() {
                okio.internal.ResourceFileSystem resourceFileSystem = this.a;
                return resourceFileSystem.A(resourceFileSystem.classLoader);
            }
        });
        if (z) {
            z().size();
        }
    }
}
