package coil.disk;

import L4.a;
import V4.AbstractC0786y;
import V4.N;
import android.os.StatFs;
import androidx.navigation.C1134i;
import c5.d;
import c5.e;
import coil.annotation.ExperimentalCoilApi;
import java.io.Closeable;
import java.io.File;
import p5.AbstractC2749t;
import p5.G;
import w4.InterfaceC3141c;

/* JADX INFO: loaded from: classes.dex */
public interface DiskCache {

    public static final class Builder {
        private AbstractC0786y cleanupDispatcher;
        private G directory;
        private long maxSizeBytes;
        private AbstractC2749t fileSystem = AbstractC2749t.SYSTEM;
        private double maxSizePercent = 0.02d;
        private long minimumMaxSizeBytes = 10485760;
        private long maximumMaxSizeBytes = 262144000;

        public Builder() {
            e eVar = N.f8259a;
            this.cleanupDispatcher = d.f13466b;
        }

        public final DiskCache build() {
            long jX;
            G g6 = this.directory;
            if (g6 == null) {
                throw new IllegalStateException("directory == null");
            }
            if (this.maxSizePercent > 0.0d) {
                try {
                    File fileG = g6.g();
                    fileG.mkdir();
                    StatFs statFs = new StatFs(fileG.getAbsolutePath());
                    jX = a.x((long) (this.maxSizePercent * statFs.getBlockCountLong() * statFs.getBlockSizeLong()), this.minimumMaxSizeBytes, this.maximumMaxSizeBytes);
                } catch (Exception unused) {
                    jX = this.minimumMaxSizeBytes;
                }
            } else {
                jX = this.maxSizeBytes;
            }
            return new RealDiskCache(jX, g6, this.fileSystem, this.cleanupDispatcher);
        }

        public final Builder cleanupDispatcher(AbstractC0786y abstractC0786y) {
            this.cleanupDispatcher = abstractC0786y;
            return this;
        }

        public final Builder directory(File file) {
            String str = G.f23047b;
            return directory(C1134i.p(file));
        }

        public final Builder fileSystem(AbstractC2749t abstractC2749t) {
            this.fileSystem = abstractC2749t;
            return this;
        }

        public final Builder maxSizeBytes(long j4) {
            if (j4 <= 0) {
                throw new IllegalArgumentException("size must be > 0.");
            }
            this.maxSizePercent = 0.0d;
            this.maxSizeBytes = j4;
            return this;
        }

        public final Builder maxSizePercent(double d6) {
            if (0.0d > d6 || d6 > 1.0d) {
                throw new IllegalArgumentException("size must be in the range [0.0, 1.0].");
            }
            this.maxSizeBytes = 0L;
            this.maxSizePercent = d6;
            return this;
        }

        public final Builder maximumMaxSizeBytes(long j4) {
            if (j4 <= 0) {
                throw new IllegalArgumentException("size must be > 0.");
            }
            this.maximumMaxSizeBytes = j4;
            return this;
        }

        public final Builder minimumMaxSizeBytes(long j4) {
            if (j4 <= 0) {
                throw new IllegalArgumentException("size must be > 0.");
            }
            this.minimumMaxSizeBytes = j4;
            return this;
        }

        public final Builder directory(G g6) {
            this.directory = g6;
            return this;
        }
    }

    @ExperimentalCoilApi
    public interface Editor {
        void abort();

        void commit();

        @InterfaceC3141c
        Snapshot commitAndGet();

        Snapshot commitAndOpenSnapshot();

        G getData();

        G getMetadata();
    }

    @ExperimentalCoilApi
    public interface Snapshot extends Closeable {
        @Override // java.io.Closeable, java.lang.AutoCloseable
        void close();

        @InterfaceC3141c
        Editor closeAndEdit();

        Editor closeAndOpenEditor();

        G getData();

        G getMetadata();
    }

    @ExperimentalCoilApi
    static /* synthetic */ void getDirectory$annotations() {
    }

    @ExperimentalCoilApi
    static /* synthetic */ void getFileSystem$annotations() {
    }

    @ExperimentalCoilApi
    static /* synthetic */ void getMaxSize$annotations() {
    }

    @ExperimentalCoilApi
    static /* synthetic */ void getSize$annotations() {
    }

    @ExperimentalCoilApi
    void clear();

    @ExperimentalCoilApi
    @InterfaceC3141c
    Editor edit(String str);

    @ExperimentalCoilApi
    @InterfaceC3141c
    Snapshot get(String str);

    G getDirectory();

    AbstractC2749t getFileSystem();

    long getMaxSize();

    long getSize();

    @ExperimentalCoilApi
    Editor openEditor(String str);

    @ExperimentalCoilApi
    Snapshot openSnapshot(String str);

    @ExperimentalCoilApi
    boolean remove(String str);
}
