package u8;

import android.app.Activity;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.text.Html;
import android.text.SpannableStringBuilder;
import android.text.TextPaint;
import android.text.style.BulletSpan;
import android.text.style.DrawableMarginSpan;
import android.text.style.URLSpan;
import android.text.style.UnderlineSpan;
import android.util.TypedValue;
import ca.canadapost.core.common.customView.z;

/* loaded from: classes.dex */
public final class o extends SpannableStringBuilder {

    /* loaded from: classes.dex */
    public static final class a extends UnderlineSpan {
        a() {
        }

        @Override // android.text.style.UnderlineSpan, android.text.style.CharacterStyle
        public void updateDrawState(TextPaint tp2) {
            kotlin.jvm.internal.t.g(tp2, "tp");
            tp2.setUnderlineText(false);
        }
    }

    public o(String str) {
        super(Html.fromHtml(str, 0));
    }

    private final float a(Context context, float f10) {
        return TypedValue.applyDimension(1, f10, context.getResources().getDisplayMetrics());
    }

    public static /* synthetic */ o g(o oVar, Context context, int i10, float f10, int i11, Object obj) {
        if ((i11 & 4) != 0) {
            f10 = 5.0f;
        }
        return oVar.f(context, i10, f10);
    }

    public /* bridge */ char b(int i10) {
        return super.charAt(i10);
    }

    public final o c() {
        BulletSpan[] bulletSpanArr = (BulletSpan[]) getSpans(0, length(), BulletSpan.class);
        kotlin.jvm.internal.t.d(bulletSpanArr);
        int i10 = 0;
        for (BulletSpan bulletSpan : bulletSpanArr) {
            i10++;
            int spanStart = getSpanStart(bulletSpan);
            int spanEnd = getSpanEnd(bulletSpan);
            removeSpan(bulletSpan);
            setSpan(new z(50, 50, i10), spanStart, spanEnd, 17);
        }
        return this;
    }

    @Override // android.text.SpannableStringBuilder, java.lang.CharSequence
    public final /* bridge */ char charAt(int i10) {
        return b(i10);
    }

    public final o d(Activity activity) {
        kotlin.jvm.internal.t.g(activity, "activity");
        BulletSpan[] bulletSpanArr = (BulletSpan[]) getSpans(0, length(), BulletSpan.class);
        kotlin.jvm.internal.t.d(bulletSpanArr);
        for (BulletSpan bulletSpan : bulletSpanArr) {
            int spanStart = getSpanStart(bulletSpan);
            int spanEnd = getSpanEnd(bulletSpan);
            removeSpan(bulletSpan);
            setSpan(new BulletSpan((int) a(activity, 15.0f)), spanStart, spanEnd, 17);
        }
        return this;
    }

    public final o e() {
        return this;
    }

    public final o f(Context context, int i10, float f10) {
        kotlin.jvm.internal.t.g(context, "context");
        Drawable drawable = androidx.core.content.a.getDrawable(context, i10);
        if (drawable != null) {
            setSpan(new DrawableMarginSpan(drawable, (int) a(context, f10)), 0, 1, 33);
        }
        return this;
    }

    public /* bridge */ int h() {
        return super.length();
    }

    public final o i() {
        URLSpan[] uRLSpanArr = (URLSpan[]) getSpans(0, length(), URLSpan.class);
        kotlin.jvm.internal.t.d(uRLSpanArr);
        for (URLSpan uRLSpan : uRLSpanArr) {
            setSpan(new a(), getSpanStart(uRLSpan), getSpanEnd(uRLSpan), 0);
        }
        return this;
    }

    @Override // android.text.SpannableStringBuilder, java.lang.CharSequence
    public final /* bridge */ int length() {
        return h();
    }
}
