package com.ss.android.ugc.aweme.services.effect;

import X.2Pr;
import X.9Y3;
import X.AnonymousClass78H;
import X.C15505ie;
import X.C38646es;
import X.C42016kJ;
import X.C45066pE;
import X.FWb;
import X.MjP;
import X.Mot;
import X.MpR;
import X.NtX;
import android.content.Context;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.ss.android.ugc.aweme.effect.EffectPointModel;
import com.ss.android.ugc.aweme.effectplatform.EffectPlatform;
import com.ss.android.ugc.aweme.filter.FilterBean;
import com.ss.android.ugc.aweme.services.effect.IEffectService;
import com.ss.android.ugc.aweme.services.effectplatform.EffectPlatformBuilder;
import com.ss.android.ugc.aweme.shortvideo.edit.model.EditPreviewInfo;
import com.ss.android.ugc.effectmanager.effect.listener.IFetchEffectListener;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class EffectService implements IEffectService {
    public static EffectService sInstance;
    public File MV_RES_CACHE_FILE = new File(NtX.LJJIII.LIZLLL().LIZ().LIZ());

    static {
        Covode.recordClassIndex(105224);
    }

    public String getLiveStickerPannel() {
        return "livestreaming";
    }

    public String getCacheDir() {
        return EffectPlatform.LIZ.getAbsolutePath();
    }

    public ArrayList<String> getDraftEffectList() {
        return EffectPlatform.LJ();
    }

    public String getModelCacheDir() {
        return EffectPlatform.LIZIZ.getAbsolutePath();
    }

    public static EffectService getInstance() {
        MethodCollector.i(15661);
        if (sInstance == null) {
            synchronized (EffectService.class) {
                try {
                    if (sInstance == null) {
                        sInstance = new EffectService();
                    }
                } catch (Throwable th) {
                    MethodCollector.o(15661);
                    throw th;
                }
            }
        }
        EffectService effectService = sInstance;
        MethodCollector.o(15661);
        return effectService;
    }

    private AnonymousClass78H getStickerFetch(Mot mot) {
        return MjP.LIZ(mot);
    }

    public Mot createMvEffectPlatform(Context context) {
        return createMvEffectPlatform(context, (String) null);
    }

    public Mot createFontEffectPlatform(Context context) {
        return MpR.LIZ(context, new EffectService$$Lambda$2(this));
    }

    private void setFontEffectPlatformCacheSize(EffectPlatformBuilder effectPlatformBuilder) {
        if (9Y3.LIZ(9Y3.LIZ(), true, "creative_tools_open_font_cache", false)) {
            effectPlatformBuilder.setEffectMaxCacheSize(9Y3.LIZ().LIZ("creative_tool_font_cache_threshold", 838860800) * 1048576);
        }
    }

    private void setMvEffectPlatformCacheSize(EffectPlatformBuilder effectPlatformBuilder) {
        if (9Y3.LIZ(9Y3.LIZ(), true, "creative_tools_open_mv_cache", false)) {
            effectPlatformBuilder.setEffectMaxCacheSize(9Y3.LIZ().LIZ("creative_tool_mv_cache_threshold", 838860800) * 1048576);
        }
    }

    public final /* synthetic */ 2Pr lambda$createFontEffectPlatform$2$EffectService(EffectPlatformBuilder effectPlatformBuilder) {
        effectPlatformBuilder.setCacheDir(new File(FWb.LIZIZ.LIZ().LJIIIIZZ().LIZLLL().LJII("")));
        setFontEffectPlatformCacheSize(effectPlatformBuilder);
        return 2Pr.LIZ;
    }

    public Mot createEffectPlatform(Context context, String str) {
        return MpR.LIZ(context, new EffectService$$Lambda$0(str));
    }

    public Mot createMvEffectPlatform(Context context, String str) {
        return MpR.LIZ(context, new EffectService$$Lambda$1(this, str));
    }

    public final /* synthetic */ 2Pr lambda$createMvEffectPlatform$1$EffectService(String str, EffectPlatformBuilder effectPlatformBuilder) {
        if (str != null) {
            effectPlatformBuilder.setRegion(str);
        }
        effectPlatformBuilder.setCacheDir(this.MV_RES_CACHE_FILE);
        setMvEffectPlatformCacheSize(effectPlatformBuilder);
        return null;
    }

    public void fetchEffectWithMusicBind(Mot mot, String str, String str2, IFetchEffectListener iFetchEffectListener) {
        getStickerFetch(mot).LIZ(str, str2, iFetchEffectListener);
    }

    public void fetchEffectWithMusicBind(Mot mot, String str, Map<String, String> map, IFetchEffectListener iFetchEffectListener) {
        getStickerFetch(mot).LIZ(str, map, iFetchEffectListener);
    }

    public void getVideoCoverByCallback(List<EffectPointModel> list, String str, float f, int i, boolean z, EditPreviewInfo editPreviewInfo, IEffectService.OnVideoCoverCallback onVideoCoverCallback) {
        List<EffectPointModel> list2 = list;
        C45066pE.LIZ(list2, str, f, i, z, editPreviewInfo, onVideoCoverCallback);
    }

    public void getVideoCoverByCallback(List<EffectPointModel> list, FilterBean filterBean, float f, int i, boolean z, C42016kJ r13, IEffectService.OnVideoCoverCallback onVideoCoverCallback) {
        List<EffectPointModel> list2 = list;
        C45066pE.LIZ(list2, C15505ie.LIZIZ(filterBean), f, i, z, C38646es.LJ(r13), onVideoCoverCallback);
    }
}
