package com.ss.android.ugc.effectmanager;

import X.4Ms;
import X.7Z0;
import X.7lW;
import X.C2857Q6s;
import X.M12;
import X.OHt;
import X.Q39;
import X.Q5L;
import X.Q62;
import X.Q6D;
import X.Q6E;
import X.Q72;
import android.content.Context;
import android.text.TextUtils;
import com.bytedance.covode.number.Covode;
import com.ss.android.ugc.effectmanager.common.TaskManager;
import com.ss.android.ugc.effectmanager.common.cachemanager.ICache;
import com.ss.android.ugc.effectmanager.common.listener.IEffectNetWorker;
import com.ss.android.ugc.effectmanager.common.listener.IJsonConverter;
import com.ss.android.ugc.effectmanager.common.listener.IMonitorService;
import com.ss.android.ugc.effectmanager.common.logger.EPLog;
import com.ss.android.ugc.effectmanager.common.network.EffectNetWorkerWrapper;
import com.ss.android.ugc.effectmanager.common.utils.EPUtils;
import com.ss.android.ugc.effectmanager.effect.bridge.EffectFetcher;
import com.ss.android.ugc.effectmanager.effect.repository.newrepo.EffectDownloadManager;
import com.ss.android.ugc.effectmanager.effect.task.task.DefaultEffectFetcher;
import com.ss.android.ugc.effectmanager.knadapt.KNExecutorService;
import com.ss.android.ugc.effectmanager.knadapt.KNJsonConverter;
import com.ss.android.ugc.effectmanager.knadapt.KNLogger;
import com.ss.android.ugc.effectmanager.knadapt.KNMonitorService;
import com.ss.android.ugc.effectmanager.knadapt.KNNetworkClient;
import com.ss.android.ugc.effectmanager.knadapt.UseKNPlatform;
import com.ss.android.ugc.effectmanager.link.model.host.Host;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.ExecutorService;
import kotlin.h.b.n;

public class EffectConfiguration {
    public ExecutorService executor;
    public int filterType;
    public HashMap<String, String> iopInfo;
    public IJsonConverter jsonConverter;
    public ListenerManger listenerManger;
    public String mAccessKey;
    public String mApiAddress;
    public String mAppID;
    public String mAppLanguage;
    public String mAppVersion;
    public ICache mCache;
    public String mChannel;
    public Context mContext;
    public String mDeviceId;
    public String mDeviceType;
    public ArrayList<String> mDraftList;
    public Q6D mEffectConfig;
    public File mEffectDir;
    public EffectDownloadManager mEffectDownloadManager;
    public EffectFetcher mEffectFetcher;
    public EffectNetWorkerWrapper mEffectNetWorker;
    public String mGpuVersion;
    public List<Host> mHosts;
    public String mPlatform;
    public String mRegion;
    public int mRetryCount;
    public String mSdkVersion;
    public TaskManager mTaskManager;
    public IMonitorService monitorService;
    public int requestStrategy;
    public String testStatus;

    /* renamed from: com.ss.android.ugc.effectmanager.EffectConfiguration$1  reason: invalid class name */
    public static /* synthetic */ class AnonymousClass1 {
        static {
            Covode.recordClassIndex(125170);
        }
    }

    static {
        Covode.recordClassIndex(125169);
    }

    public String getAccessKey() {
        return this.mAccessKey;
    }

    public String getApiAdress() {
        return this.mApiAddress;
    }

    public String getAppID() {
        return this.mAppID;
    }

    public String getAppLanguage() {
        return this.mAppLanguage;
    }

    public String getAppVersion() {
        return this.mAppVersion;
    }

    public ICache getCache() {
        return this.mCache;
    }

    public String getChannel() {
        return this.mChannel;
    }

    public Context getContext() {
        return this.mContext;
    }

    public String getDeviceId() {
        return this.mDeviceId;
    }

    public String getDeviceType() {
        return this.mDeviceType;
    }

    public ArrayList<String> getDraftList() {
        return this.mDraftList;
    }

    public Q6D getEffectConfig() {
        return this.mEffectConfig;
    }

    public File getEffectDir() {
        return this.mEffectDir;
    }

    public EffectDownloadManager getEffectDownloadManager() {
        return this.mEffectDownloadManager;
    }

    public EffectFetcher getEffectFetcher() {
        return this.mEffectFetcher;
    }

    public EffectNetWorkerWrapper getEffectNetWorker() {
        return this.mEffectNetWorker;
    }

    public ExecutorService getExecutor() {
        return this.executor;
    }

    public int getFilterType() {
        return this.filterType;
    }

    public String getGpuVersion() {
        return this.mGpuVersion;
    }

    public List<Host> getHosts() {
        return this.mHosts;
    }

    public HashMap<String, String> getIopInfo() {
        return this.iopInfo;
    }

    public IJsonConverter getJsonConverter() {
        return this.jsonConverter;
    }

    public ListenerManger getListenerManger() {
        return this.listenerManger;
    }

    public IMonitorService getMonitorService() {
        return this.monitorService;
    }

    public String getPlatform() {
        return this.mPlatform;
    }

    public String getRegion() {
        return this.mRegion;
    }

    public int getRequestStrategy() {
        return this.requestStrategy;
    }

    public int getRetryCount() {
        return this.mRetryCount;
    }

    public String getSdkVersion() {
        return this.mSdkVersion;
    }

    public TaskManager getTaskManager() {
        return this.mTaskManager;
    }

    public String getTestStatus() {
        return this.testStatus;
    }

    public static final class Builder {
        public static boolean hasAddedVersionTagInLog;
        public String accessKey;
        public String appID;
        public String appLanguage;
        public String appVersion;
        public ICache cache;
        public String channel;
        public Context context;
        public String deviceId;
        public String deviceType;
        public ArrayList<String> draftList;
        public File effectDir;
        public EffectFetcher effectFetcher;
        public IEffectNetWorker effectNetWorker;
        public int filterType;
        public String gpuVersion;
        public List<Host> hosts;
        public HashMap<String, String> iopInfo = new HashMap<>();
        public IJsonConverter jsonConverter;
        public ExecutorService mExecutor;
        public Q6E mKNEffectConfigBuilder;
        public IMonitorService monitorService;
        public String platform;
        public String region;
        public int requestStrategy;
        public int retryCount = 3;
        public String sdkVersion;
        public String testStatus;

        static {
            Covode.recordClassIndex(125171);
        }

        public final Builder sysLanguage(String str) {
            return this;
        }

        public final EffectConfiguration build() {
            return new EffectConfiguration(this, (AnonymousClass1) null);
        }

        public final Q6D buildKNEffectConfig() {
            return this.mKNEffectConfigBuilder.LIZ();
        }

        public Builder() {
            if (!hasAddedVersionTagInLog) {
                if (UseKNPlatform.enableKNPlatform) {
                    EPLog.addSDKTagString("760.0.0.171-mt.3-bugfix");
                } else {
                    EPLog.addSDKTagString(EPUtils.getPlatformSDKVersion());
                }
                hasAddedVersionTagInLog = true;
            }
            this.mKNEffectConfigBuilder = new Q6E();
        }

        public final Builder cache(ICache iCache) {
            this.cache = iCache;
            return this;
        }

        public final Builder accessKey(String str) {
            this.accessKey = str;
            this.mKNEffectConfigBuilder.LIZ(str);
            return this;
        }

        public final Builder appID(String str) {
            this.appID = str;
            this.mKNEffectConfigBuilder.LJFF = str;
            return this;
        }

        public final Builder appLanguage(String str) {
            this.appLanguage = str;
            this.mKNEffectConfigBuilder.LJIIIIZZ(str);
            return this;
        }

        public final Builder appVersion(String str) {
            this.appVersion = str;
            this.mKNEffectConfigBuilder.LIZJ(str);
            return this;
        }

        public final Builder channel(String str) {
            this.channel = str;
            this.mKNEffectConfigBuilder.LJ(str);
            return this;
        }

        public final Builder deviceId(String str) {
            this.deviceId = str;
            this.mKNEffectConfigBuilder.LIZLLL(str);
            return this;
        }

        public final Builder deviceType(String str) {
            this.deviceType = str;
            this.mKNEffectConfigBuilder.LJI(str);
            return this;
        }

        public final Builder filterType(int i) {
            this.filterType = i;
            this.mKNEffectConfigBuilder.LIZ(i);
            return this;
        }

        public final Builder gpuInfo(String str) {
            this.gpuVersion = str;
            this.mKNEffectConfigBuilder.LJIJJLI = str;
            return this;
        }

        public final Builder knEffectFetcher(OHt oHt) {
            this.mKNEffectConfigBuilder.LJIJ = oHt;
            return this;
        }

        public final Builder platform(String str) {
            this.platform = str;
            this.mKNEffectConfigBuilder.LJFF(str);
            return this;
        }

        public final Builder region(String str) {
            this.region = str;
            this.mKNEffectConfigBuilder.LJII(str);
            return this;
        }

        public final Builder requestStrategy(int i) {
            this.requestStrategy = i;
            this.mKNEffectConfigBuilder.LJJ = i;
            return this;
        }

        public final Builder retryCount(int i) {
            this.retryCount = i;
            this.mKNEffectConfigBuilder.LJIILJJIL = i;
            return this;
        }

        public final Builder sdkVersion(String str) {
            this.sdkVersion = str;
            this.mKNEffectConfigBuilder.LIZIZ(str);
            return this;
        }

        public final Builder testStatus(String str) {
            this.testStatus = str;
            this.mKNEffectConfigBuilder.LJIJJ = str;
            return this;
        }

        public static Context INVOKEVIRTUAL_com_ss_android_ugc_effectmanager_EffectConfiguration$Builder_com_ss_android_ugc_aweme_lancet_launch_ApplicationContextLancet_getApplicationContext(Context context2) {
            Context applicationContext = context2.getApplicationContext();
            if (7lW.LIZJ && applicationContext == null) {
                return 7lW.LIZ;
            }
            return applicationContext;
        }

        public final Builder context(Context context2) {
            Context INVOKEVIRTUAL_com_ss_android_ugc_effectmanager_EffectConfiguration$Builder_com_ss_android_ugc_aweme_lancet_launch_ApplicationContextLancet_getApplicationContext = INVOKEVIRTUAL_com_ss_android_ugc_effectmanager_EffectConfiguration$Builder_com_ss_android_ugc_aweme_lancet_launch_ApplicationContextLancet_getApplicationContext(context2);
            this.context = INVOKEVIRTUAL_com_ss_android_ugc_effectmanager_EffectConfiguration$Builder_com_ss_android_ugc_aweme_lancet_launch_ApplicationContextLancet_getApplicationContext;
            this.mKNEffectConfigBuilder.LIZ((Object) INVOKEVIRTUAL_com_ss_android_ugc_effectmanager_EffectConfiguration$Builder_com_ss_android_ugc_aweme_lancet_launch_ApplicationContextLancet_getApplicationContext);
            return this;
        }

        public final Builder draftList(ArrayList<String> arrayList) {
            this.draftList = arrayList;
            Q6E q6e = this.mKNEffectConfigBuilder;
            M12.LIZ(arrayList);
            q6e.LJJIFFI = arrayList;
            return this;
        }

        public final Builder effectMaxCacheSize(long j) {
            Q6E q6e = this.mKNEffectConfigBuilder;
            if (j > 0) {
                q6e.LJJIJ = j;
            }
            return this;
        }

        public final Builder effectNetWorker(IEffectNetWorker iEffectNetWorker) {
            this.effectNetWorker = iEffectNetWorker;
            this.mKNEffectConfigBuilder.LIZ((Q5L) new KNNetworkClient(iEffectNetWorker));
            return this;
        }

        public final Builder executor(ExecutorService executorService) {
            this.mExecutor = executorService;
            this.mKNEffectConfigBuilder.LIZ((Q72) new KNExecutorService(executorService));
            return this;
        }

        public final Builder monitorService(IMonitorService iMonitorService) {
            this.monitorService = iMonitorService;
            this.mKNEffectConfigBuilder.LIZ((7Z0) new KNMonitorService(iMonitorService));
            return this;
        }

        public final Builder JsonConverter(IJsonConverter iJsonConverter) {
            this.jsonConverter = iJsonConverter;
            this.mKNEffectConfigBuilder.LIZ(new C2857Q6s(new KNJsonConverter(iJsonConverter)));
            return this;
        }

        public final Builder effectDir(File file) {
            this.effectDir = file;
            if (file == null) {
                return this;
            }
            if (!file.exists()) {
                file.mkdirs();
            }
            this.mKNEffectConfigBuilder.LJIIL = file.getAbsolutePath();
            return this;
        }

        public final Builder hosts(List<Host> list) {
            this.hosts = list;
            if (!list.isEmpty()) {
                this.mKNEffectConfigBuilder.LJIIIZ(list.get(0).getItemName());
            }
            return this;
        }

        public final Builder effectFetcher(EffectFetcher effectFetcher2) {
            this.effectFetcher = effectFetcher2;
            if (effectFetcher2 != null && "DownloadableModelSupportEffectFetcher".equals(effectFetcher2.getClass().getSimpleName()) && Q62.LJFF.LIZIZ()) {
                this.mKNEffectConfigBuilder.LJIJ = Q62.LJFF.LIZ().LIZIZ();
            }
            return this;
        }

        public final Builder iop(String str, String str2, String str3) {
            if (!TextUtils.isEmpty(str)) {
                this.iopInfo.put("lx", str);
            }
            if (!TextUtils.isEmpty(str2)) {
                this.iopInfo.put("ly", str2);
            }
            if (!TextUtils.isEmpty(str3)) {
                this.iopInfo.put("cy_code", str3);
            }
            Q6E q6e = this.mKNEffectConfigBuilder;
            if (str != null && (!n.LIZ(str, Q39.LIZJ))) {
                q6e.LJIL.put("lx", str);
            }
            if (str2 != null && (!n.LIZ(str2, Q39.LIZJ))) {
                q6e.LJIL.put("ly", str2);
            }
            if (str3 != null && (!n.LIZ(str3, Q39.LIZJ))) {
                q6e.LJIL.put("cy_code", str3);
            }
            return this;
        }
    }

    public void setCache(ICache iCache) {
        this.mCache = iCache;
    }

    public void setDeviceId(String str) {
        this.mDeviceId = str;
    }

    public void setDraftList(ArrayList<String> arrayList) {
        this.mDraftList = arrayList;
    }

    public void setEffectDir(File file) {
        this.mEffectDir = file;
    }

    public void setEffectFetcher(EffectFetcher effectFetcher) {
        this.mEffectFetcher = effectFetcher;
    }

    public void setTaskManager(TaskManager taskManager) {
        this.mTaskManager = taskManager;
    }

    public void setEffectNetWorker(IEffectNetWorker iEffectNetWorker) {
        this.mEffectNetWorker.setIEffectNetWorker(iEffectNetWorker);
    }

    public static File INVOKEVIRTUAL_com_ss_android_ugc_effectmanager_EffectConfiguration_com_ss_android_ugc_aweme_lancet_ContextLancet_getFilesDir(Context context) {
        if (4Ms.LIZJ != null && 4Ms.LJ) {
            return 4Ms.LIZJ;
        }
        File filesDir = context.getFilesDir();
        4Ms.LIZJ = filesDir;
        return filesDir;
    }

    public EffectConfiguration(Builder builder) {
        String str;
        String str2;
        DefaultEffectFetcher defaultEffectFetcher;
        String str3 = "online";
        this.mChannel = str3;
        this.iopInfo = new HashMap<>();
        this.mRetryCount = 1;
        this.mApiAddress = "/effect/api";
        this.mAccessKey = builder.accessKey;
        this.mSdkVersion = builder.sdkVersion;
        this.mAppVersion = builder.appVersion;
        this.mDeviceId = builder.deviceId;
        this.mChannel = builder.channel != null ? builder.channel : str3;
        if (builder.platform == null) {
            str = "android";
        } else {
            str = builder.platform;
        }
        this.mPlatform = str;
        this.mDeviceType = builder.deviceType;
        this.mContext = builder.context;
        if (builder.effectDir != null || this.mContext == null) {
            this.mEffectDir = builder.effectDir;
        } else {
            this.mEffectDir = new File(INVOKEVIRTUAL_com_ss_android_ugc_effectmanager_EffectConfiguration_com_ss_android_ugc_aweme_lancet_ContextLancet_getFilesDir(this.mContext), "effect");
        }
        this.mEffectDir = builder.effectDir;
        this.mEffectNetWorker = new EffectNetWorkerWrapper(builder.effectNetWorker, builder.context);
        this.mRegion = builder.region;
        this.mCache = builder.cache;
        this.mRetryCount = builder.retryCount;
        this.jsonConverter = builder.jsonConverter;
        if (builder.appID == null) {
            str2 = "0";
        } else {
            str2 = builder.appID;
        }
        this.mAppID = str2;
        this.mAppLanguage = builder.appLanguage;
        this.iopInfo = builder.iopInfo;
        this.monitorService = builder.monitorService;
        this.executor = builder.mExecutor;
        if (builder.effectFetcher == null) {
            defaultEffectFetcher = new DefaultEffectFetcher(this.mEffectNetWorker, this.monitorService, this.mAppID, this.mAccessKey);
        } else {
            defaultEffectFetcher = builder.effectFetcher;
        }
        this.mEffectFetcher = defaultEffectFetcher;
        this.testStatus = builder.testStatus;
        this.listenerManger = new ListenerManger();
        this.mEffectDownloadManager = EffectDownloadManager.INSTANCE;
        this.mDraftList = builder.draftList;
        this.mGpuVersion = builder.gpuVersion;
        this.requestStrategy = builder.requestStrategy;
        this.mHosts = builder.hosts;
        this.filterType = builder.filterType;
        Q6D buildKNEffectConfig = builder.buildKNEffectConfig();
        this.mEffectConfig = buildKNEffectConfig;
        buildKNEffectConfig.LIZ(KNLogger.INSTANCE);
    }

    public /* synthetic */ EffectConfiguration(Builder builder, AnonymousClass1 r2) {
        this(builder);
    }
}
