package p421.p433.p434.p445;

import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import net.lingala.zip4j.exception.ZipException;
import p138.p176.p177.p242.p246.p251.C4303;
import p421.p433.p434.p438.C6786;
import p421.p433.p434.p439.p441.C6810;
import p421.p433.p434.p439.p441.C6813;
import p421.p433.p434.p442.C6822;
import p421.p433.p434.p442.C6828;
import p421.p433.p434.p442.C6829;
import p421.p433.p434.p442.p443.EnumC6834;
import p421.p433.p434.p442.p443.EnumC6835;
import p421.p433.p434.p444.C6837;
import p421.p433.p434.p445.AbstractC6848;
import p421.p433.p434.p445.C6854;
import p421.p433.p434.p446.C6857;

/* JADX INFO: renamed from: ޏ.ؠ.֏.ބ.ރ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public class C6846 extends AbstractC6842<C6847> {

    /* JADX INFO: renamed from: ޏ.ؠ.֏.ބ.ރ$֏, reason: contains not printable characters */
    public static class C6847 extends AbstractC6845 {

        /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
        public List<File> f19875;

        /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
        public C6829 f19876;

        public C6847(List<File> list, C6829 c6829, Charset charset) {
            super(charset);
            this.f19875 = list;
            this.f19876 = c6829;
        }
    }

    public C6846(C6828 c6828, char[] cArr, C6786 c6786, AbstractC6848.C6849 c6849) {
        super(c6828, cArr, c6786, c6849);
    }

    @Override // p421.p433.p434.p445.AbstractC6848
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public long mo9990(Object obj) throws ZipException {
        C6847 c6847 = (C6847) obj;
        List<File> list = c6847.f19875;
        C6829 c6829 = c6847.f19876;
        long length = 0;
        for (File file : list) {
            if (file.exists()) {
                length += (c6829.f19790 && c6829.f19791 == EnumC6835.ZIP_STANDARD) ? file.length() * 2 : file.length();
                C6822 c6822M7073 = C4303.m7073(this.f19867, C6857.m10001(file, c6829));
                if (c6822M7073 != null) {
                    length += this.f19867.f19786.length() - c6822M7073.f19733;
                }
            }
        }
        return length;
    }

    @Override // p421.p433.p434.p445.AbstractC6848
    /* JADX INFO: renamed from: ֏ */
    public C6837.EnumC6840 mo9986() {
        return C6837.EnumC6840.ADD_ENTRY;
    }

    @Override // p421.p433.p434.p445.AbstractC6848
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public void mo9991(Object obj, C6837 c6837) throws IOException {
        C6813 c6813M9981;
        C6847 c6847 = (C6847) obj;
        C6829 c6829 = c6847.f19876;
        if (c6829 == null) {
            throw new ZipException("cannot validate zip parameters");
        }
        EnumC6834 enumC6834 = c6829.f19788;
        if (enumC6834 != EnumC6834.STORE && enumC6834 != EnumC6834.DEFLATE) {
            throw new ZipException("unsupported compression type");
        }
        if (!c6829.f19790) {
            c6829.f19791 = EnumC6835.NONE;
        } else {
            if (c6829.f19791 == EnumC6835.NONE) {
                throw new ZipException("Encryption method has to be set, when encrypt files flag is set");
            }
            char[] cArr = this.f19868;
            if (cArr == null || cArr.length <= 0) {
                throw new ZipException("input password is empty or null");
            }
        }
        List<File> list = c6847.f19875;
        C6829 c68292 = c6847.f19876;
        Charset charset = c6847.f19874;
        ArrayList<File> arrayList = new ArrayList(list);
        if (this.f19867.f19786.exists()) {
            for (File file : list) {
                C6822 c6822M7073 = C4303.m7073(this.f19867, C6857.m10001(file, c68292));
                if (c6822M7073 != null) {
                    if (c68292.f19803) {
                        C6837.EnumC6840 enumC6840 = C6837.EnumC6840.REMOVE_ENTRY;
                        if (c6837 == null) {
                            throw null;
                        }
                        new C6854(this.f19867, this.f19869, new AbstractC6848.C6849(null, false, c6837)).m9993(new C6854.C6855(Collections.singletonList(c6822M7073.f19737), charset));
                        m9992();
                        C6837.EnumC6840 enumC68402 = C6837.EnumC6840.ADD_ENTRY;
                    } else {
                        arrayList.remove(file);
                    }
                }
            }
        }
        C6828 c6828 = this.f19867;
        C6810 c6810 = new C6810(c6828.f19786, c6828.f19785);
        try {
            c6813M9981 = m9981(c6810, charset);
        } catch (Throwable th) {
            try {
                throw th;
            } catch (Throwable th2) {
                try {
                    c6810.f19700.close();
                } catch (Throwable th3) {
                    th.addSuppressed(th3);
                }
                throw th2;
            }
        }
        try {
            for (File file2 : arrayList) {
                m9992();
                C6829 c6829M9982 = m9982(c68292, file2, c6837);
                file2.getAbsolutePath();
                if (c6837 == null) {
                    throw null;
                }
                if (C6857.m10005(file2)) {
                    if (C6829.EnumC6830.INCLUDE_LINK_ONLY.equals(c6829M9982.f19806) || C6829.EnumC6830.INCLUDE_LINK_AND_LINKED_FILE.equals(c6829M9982.f19806)) {
                        m9983(file2, c6813M9981, c6829M9982, c6810);
                        if (C6829.EnumC6830.INCLUDE_LINK_ONLY.equals(c6829M9982.f19806)) {
                        }
                    }
                }
                m9984(file2, c6813M9981, c6829M9982, c6810, c6837);
                throw th;
            }
            c6813M9981.close();
            c6810.f19700.close();
        } finally {
        }
    }
}
