package com.bytedance.adsdk.ugeno.core;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import java.util.ArrayList;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

/* JADX INFO: loaded from: classes.dex */
public class fm {
    private String ajl;
    private String fm;
    private long jnr;

    /* JADX INFO: renamed from: lb, reason: collision with root package name */
    private List<C0013fm> f6310lb;
    private float ro;
    private long yz;

    /* JADX INFO: renamed from: com.bytedance.adsdk.ugeno.core.fm$fm, reason: collision with other inner class name */
    public static class C0013fm {
        private float ajl;

        /* JADX INFO: renamed from: ef, reason: collision with root package name */
        private String f6311ef;
        private long fm;
        private String jnr;

        /* JADX INFO: renamed from: lb, reason: collision with root package name */
        private String f6312lb;
        private float ro;
        private String vt;
        private float wsy;
        private float[] wu;
        private long yz;

        public float ajl() {
            return this.ajl;
        }

        public String ef() {
            return this.f6311ef;
        }

        public long fm() {
            return this.fm;
        }

        public String jnr() {
            return this.jnr;
        }

        public String lb() {
            return this.f6312lb;
        }

        public float ro() {
            return this.ro;
        }

        public String vt() {
            return this.vt;
        }

        public float wsy() {
            return this.wsy;
        }

        public float[] wu() {
            return this.wu;
        }

        public long yz() {
            return this.yz;
        }

        public void fm(float f10) {
            this.ro = f10;
        }

        public void lb(float f10) {
            this.wsy = f10;
        }

        public void ro(float f10) {
            this.ajl = f10;
        }

        public void yz(String str) {
            this.f6311ef = str;
        }

        public void fm(long j10) {
            this.fm = j10;
        }

        public void lb(String str) {
            this.vt = str;
        }

        public void ro(long j10) {
            this.yz = j10;
        }

        public void fm(String str) {
            this.f6312lb = str;
        }

        public void ro(String str) {
            this.jnr = str;
        }

        public void fm(float[] fArr) {
            this.wu = fArr;
        }

        public static C0013fm fm(JSONObject jSONObject, com.bytedance.adsdk.ugeno.ro.lb lbVar) {
            if (jSONObject == null) {
                return null;
            }
            C0013fm c0013fm = new C0013fm();
            c0013fm.fm(jSONObject.optLong("duration"));
            String strOptString = jSONObject.optString("loop");
            if (TextUtils.equals("infinite", strOptString)) {
                c0013fm.fm(-1.0f);
            } else {
                try {
                    c0013fm.fm(Float.parseFloat(strOptString));
                } catch (NumberFormatException unused) {
                    c0013fm.fm(0.0f);
                }
            }
            c0013fm.fm(jSONObject.optString("loopMode"));
            c0013fm.ro(jSONObject.optString("type"));
            if (TextUtils.equals(c0013fm.jnr(), "ripple")) {
                c0013fm.lb(jSONObject.optString("rippleColor"));
            }
            View viewKu = lbVar.ku();
            Context context = viewKu != null ? viewKu.getContext() : null;
            if (TextUtils.equals(c0013fm.jnr(), "backgroundColor")) {
                String strFm = com.bytedance.adsdk.ugeno.lb.ro.fm(jSONObject.optString("valueTo"), lbVar.duv());
                int iFm = com.bytedance.adsdk.ugeno.wsy.fm.fm(jSONObject.optString("valueFrom"));
                int iFm2 = com.bytedance.adsdk.ugeno.wsy.fm.fm(strFm);
                c0013fm.ro(iFm);
                c0013fm.lb(iFm2);
            } else if ((TextUtils.equals(c0013fm.jnr(), "translateX") || TextUtils.equals(c0013fm.jnr(), "translateY")) && context != null) {
                try {
                    float fFm = com.bytedance.adsdk.ugeno.wsy.wu.fm(context, (float) jSONObject.optDouble("valueFrom"));
                    float fFm2 = com.bytedance.adsdk.ugeno.wsy.wu.fm(context, (float) jSONObject.optDouble("valueTo"));
                    c0013fm.ro(fFm);
                    c0013fm.lb(fFm2);
                } catch (Exception unused2) {
                }
            } else {
                c0013fm.ro((float) jSONObject.optDouble("valueFrom"));
                c0013fm.lb((float) jSONObject.optDouble("valueTo"));
            }
            c0013fm.yz(jSONObject.optString("interpolator"));
            c0013fm.ro(com.bytedance.adsdk.ugeno.wsy.lb.fm(com.bytedance.adsdk.ugeno.lb.ro.fm(jSONObject.optString("startDelay"), lbVar.duv()), 0L));
            JSONArray jSONArrayOptJSONArray = jSONObject.optJSONArray("values");
            if (jSONArrayOptJSONArray != null && jSONArrayOptJSONArray.length() > 0) {
                float[] fArr = new float[jSONArrayOptJSONArray.length()];
                int i10 = 0;
                if ((TextUtils.equals(c0013fm.jnr(), "translateX") || TextUtils.equals(c0013fm.jnr(), "translateY")) && context != null) {
                    while (i10 < jSONArrayOptJSONArray.length()) {
                        fArr[i10] = com.bytedance.adsdk.ugeno.wsy.wu.fm(context, (float) fm.fm(jSONArrayOptJSONArray.optString(i10), lbVar.duv()));
                        i10++;
                    }
                } else {
                    while (i10 < jSONArrayOptJSONArray.length()) {
                        fArr[i10] = (float) fm.fm(jSONArrayOptJSONArray.optString(i10), lbVar.duv());
                        i10++;
                    }
                }
                c0013fm.fm(fArr);
            }
            return c0013fm;
        }
    }

    public String ajl() {
        return this.ajl;
    }

    public String fm() {
        return this.fm;
    }

    public long jnr() {
        return this.jnr;
    }

    public List<C0013fm> lb() {
        return this.f6310lb;
    }

    public float ro() {
        return this.ro;
    }

    public long yz() {
        return this.yz;
    }

    public void fm(float f10) {
        this.ro = f10;
    }

    public void ro(long j10) {
        this.jnr = j10;
    }

    public void fm(long j10) {
        this.yz = j10;
    }

    public void ro(String str) {
        this.ajl = str;
    }

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

    public void fm(List<C0013fm> list) {
        this.f6310lb = list;
    }

    public static fm fm(String str, com.bytedance.adsdk.ugeno.ro.lb lbVar) {
        if (TextUtils.isEmpty(str)) {
            return null;
        }
        try {
            return fm(new JSONObject(str), lbVar);
        } catch (JSONException unused) {
            return null;
        }
    }

    public static fm fm(JSONObject jSONObject, com.bytedance.adsdk.ugeno.ro.lb lbVar) {
        return fm(jSONObject, null, lbVar);
    }

    public static fm fm(JSONObject jSONObject, JSONObject jSONObject2, com.bytedance.adsdk.ugeno.ro.lb lbVar) {
        if (jSONObject == null) {
            return null;
        }
        fm fmVar = new fm();
        fmVar.fm(jSONObject.optString("ordering"));
        String strOptString = jSONObject.optString("loop");
        if (TextUtils.equals("infinite", strOptString)) {
            fmVar.fm(-1.0f);
        } else {
            try {
                fmVar.fm(Float.parseFloat(strOptString));
            } catch (NumberFormatException unused) {
                fmVar.fm(0.0f);
            }
        }
        fmVar.fm(jSONObject.optLong("duration", 0L));
        fmVar.ro(com.bytedance.adsdk.ugeno.wsy.lb.fm(com.bytedance.adsdk.ugeno.lb.ro.fm(jSONObject.optString("startDelay"), lbVar.duv()), 0L));
        fmVar.ro(jSONObject.optString("loopMode"));
        JSONArray jSONArrayOptJSONArray = jSONObject.optJSONArray("animators");
        if (jSONArrayOptJSONArray != null) {
            ArrayList arrayList = new ArrayList();
            for (int i10 = 0; i10 < jSONArrayOptJSONArray.length(); i10++) {
                JSONObject jSONObjectOptJSONObject = jSONArrayOptJSONArray.optJSONObject(i10);
                if (jSONObject2 != null) {
                    com.bytedance.adsdk.ugeno.wsy.ro.fm(jSONObject2, jSONObjectOptJSONObject);
                }
                arrayList.add(C0013fm.fm(jSONObjectOptJSONObject, lbVar));
            }
            fmVar.fm(arrayList);
        }
        return fmVar;
    }

    public static double fm(Object obj, JSONObject jSONObject) {
        if (obj instanceof String) {
            return com.bytedance.adsdk.ugeno.wsy.lb.fm(com.bytedance.adsdk.ugeno.lb.ro.fm((String) obj, jSONObject), 0.0d);
        }
        if (obj instanceof Double) {
            return ((Double) obj).doubleValue();
        }
        if (obj instanceof Long) {
            return ((Double) obj).doubleValue();
        }
        if (obj instanceof Integer) {
            return ((Double) obj).doubleValue();
        }
        return 0.0d;
    }
}
