package com.bytedance.sdk.openadsdk.core.dsz;

import android.content.Context;
import android.graphics.Typeface;
import android.os.Build;
import android.text.TextUtils;
import com.bytedance.adsdk.ugeno.wsy.wu;

/* JADX INFO: loaded from: classes2.dex */
public class ro {
    private int dsz;
    private float duv;

    /* JADX INFO: renamed from: ef, reason: collision with root package name */
    private int f7051ef;
    private float fhx;
    protected String fm;
    private float gof;
    private Context gqi;
    private float irt;
    private int jnr;
    private float ku;
    private boolean onz;
    private float qhl;
    private TextUtils.TruncateAt vt;
    private boolean wey;
    private int wsy;
    protected int ro = -16777216;

    /* JADX INFO: renamed from: lb, reason: collision with root package name */
    private float f7052lb = 12.0f;
    private float yz = -1.0f;
    private int ajl = Integer.MAX_VALUE;
    private int wu = 8388611;

    public ro(Context context, boolean z10) {
        this.gqi = context;
        this.wey = z10;
    }

    private TextUtils.TruncateAt lb(String str) {
        if (TextUtils.equals(str, "none")) {
            return null;
        }
        return TextUtils.TruncateAt.END;
    }

    /* JADX WARN: Removed duplicated region for block: B:18:0x0035  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    private int ro(String str) {
        byte b10;
        int iHashCode = str.hashCode();
        if (iHashCode != -1178781136) {
            if (iHashCode != -1039745817) {
                b10 = (iHashCode == 3029637 && str.equals("bold")) ? (byte) 0 : (byte) -1;
            } else if (str.equals("normal")) {
                b10 = 2;
            }
        } else if (str.equals("italic")) {
            b10 = 1;
        }
        if (b10 != 0) {
            return b10 != 1 ? 0 : 2;
        }
        return 1;
    }

    private int yz(String str) {
        str.getClass();
        switch (str) {
            case "underline":
                return 8;
            case "strikethrough":
                return 16;
            case "none":
            default:
                return Integer.MAX_VALUE;
        }
    }

    public void fm(com.bytedance.adsdk.ugeno.ef.ajl.fm fmVar) {
        if (fmVar == null) {
            return;
        }
        if (!TextUtils.isEmpty(this.fm)) {
            fmVar.setText(TextUtils.equals("null", this.fm) ? "" : this.fm);
        }
        fmVar.setTextSize(1, this.f7052lb);
        fmVar.setMinTextSize(wu.fm(this.gqi, this.yz));
        fmVar.setTextColor(this.ro);
        fmVar.setGravity(this.wu);
        fmVar.setLines(this.wsy);
        fmVar.setMaxLines(this.ajl);
        int i10 = this.f7051ef;
        if (i10 != Integer.MAX_VALUE) {
            fmVar.setPaintFlags(i10);
        }
        fmVar.setEllipsize(this.vt);
        if (this.ku > 0.0f) {
            if (this.wey) {
                lb(fmVar);
            } else {
                ro(fmVar);
            }
        }
        fmVar.setTypeface(fm((int) this.duv));
        yz(fmVar);
        float fFm = wu.fm(this.gqi, this.f7052lb);
        if (fFm > 0.0f) {
            fmVar.setLetterSpacing(this.gof / fFm);
        }
        fmVar.setIncludeFontPadding(false);
    }

    private void lb(com.bytedance.adsdk.ugeno.ef.ajl.fm fmVar) {
        float f10 = this.ku;
        if (f10 <= 3.0f) {
            fmVar.setLineSpacing(0.0f, f10);
        } else if (Build.VERSION.SDK_INT >= 28) {
            int iRound = Math.round(wu.fm(this.gqi, (f10 - (this.f7052lb * 1.2f)) / 2.0f));
            fmVar.setPadding(fmVar.getPaddingLeft(), fmVar.getPaddingTop() + iRound, fmVar.getPaddingRight(), fmVar.getPaddingBottom() + iRound);
            fmVar.setLineHeight(Math.round(wu.fm(this.gqi, this.ku)));
        }
    }

    private void ro(com.bytedance.adsdk.ugeno.ef.ajl.fm fmVar) {
        fmVar.setLineSpacing(0.0f, this.ku);
    }

    private void yz(com.bytedance.adsdk.ugeno.ef.ajl.fm fmVar) {
        if (!this.wey) {
            fmVar.setShadowLayer(this.qhl, this.fhx, this.irt, this.dsz);
        } else if (this.onz) {
            float f10 = this.qhl;
            if (f10 <= 0.0f) {
                f10 = 1.0E-5f;
            }
            fmVar.setShadowLayer(f10, this.fhx, this.irt, this.dsz);
        }
    }

    public void fm(String str, String str2) {
        if (TextUtils.isEmpty(str) || TextUtils.isEmpty(str) || TextUtils.isEmpty(str2)) {
            return;
        }
        str.getClass();
        switch (str) {
            case "shadowColor":
                this.dsz = com.bytedance.adsdk.ugeno.wsy.fm.fm(str2);
                this.onz = true;
                break;
            case "shadowOffsetX":
                this.fhx = wu.fm(this.gqi, com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, 0.0f));
                break;
            case "shadowOffsetY":
                this.irt = wu.fm(this.gqi, com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, 0.0f));
                break;
            case "textAlign":
                this.wu = fm(str2);
                break;
            case "textColor":
                this.ro = com.bytedance.adsdk.ugeno.wsy.fm.fm(str2);
                break;
            case "textStyle":
                this.jnr = ro(str2);
                break;
            case "shadowBlur":
                this.qhl = com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, 0.0f);
                break;
            case "textSize":
                this.f7052lb = com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, 0.0f);
                break;
            case "textDecoration":
                this.f7051ef = yz(str2);
                break;
            case "fontWeight":
                float fFm = com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, -1.0f);
                this.duv = fFm;
                if (fFm < 1.0f || fFm > 1000.0f) {
                    this.duv = 400.0f;
                    break;
                }
                break;
            case "lineHeight":
                this.ku = com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, 1.0f);
                break;
            case "text":
                this.fm = str2;
                break;
            case "lines":
                this.wsy = com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, 0);
                break;
            case "ellipsis":
                this.vt = lb(str2);
                break;
            case "minTextSize":
                this.yz = com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, -1.0f);
                break;
            case "maxLines":
                int iFm = com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, Integer.MAX_VALUE);
                this.ajl = iFm > 0 ? iFm : Integer.MAX_VALUE;
                break;
            case "letterSpacing":
                this.gof = wu.fm(this.gqi, com.bytedance.adsdk.ugeno.wsy.lb.fm(str2, 0.0f));
                break;
        }
    }

    /* JADX WARN: Failed to restore switch over string. Please report as a decompilation issue */
    private int fm(String str) {
        str.getClass();
        byte b10 = -1;
        switch (str.hashCode()) {
            case -1364013995:
                if (str.equals("center")) {
                    b10 = 0;
                }
                break;
            case -348726240:
                if (str.equals("center_vertical")) {
                    b10 = 1;
                }
                break;
            case 3317767:
                if (str.equals("left")) {
                    b10 = 2;
                }
                break;
            case 108511772:
                if (str.equals("right")) {
                    b10 = 3;
                }
                break;
            case 1063616078:
                if (str.equals("center_horizontal")) {
                    b10 = 4;
                }
                break;
        }
        switch (b10) {
            case 0:
                return 17;
            case 1:
                return 16;
            case 2:
            default:
                return 3;
            case 3:
                return 5;
            case 4:
                return 1;
        }
    }

    private Typeface fm(int i10) {
        if (Build.VERSION.SDK_INT >= 28) {
            return Typeface.create(Typeface.DEFAULT, i10, false);
        }
        return i10 >= 700 ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT;
    }
}
