package X6;

import B6.r;
import B6.t;
import com.google.android.gms.internal.measurement.C1;
import com.google.android.gms.internal.measurement.X1;
import java.util.ArrayList;
import java.util.List;
import n4.u0;

/* JADX INFO: loaded from: classes.dex */
public abstract class g extends u0 {
    public static String C(String str) {
        P6.g.e(str, "<this>");
        return W6.j.I(new W6.f(new r(2, str), new f(0, "    "), 3), "\n");
    }

    public static String D(String str) {
        List listC;
        P6.g.e(str, "<this>");
        if (e.V("|")) {
            throw new IllegalArgumentException("marginPrefix must be non-blank string.");
        }
        c cVar = new c(str);
        if (cVar.hasNext()) {
            Object next = cVar.next();
            if (cVar.hasNext()) {
                ArrayList arrayList = new ArrayList();
                arrayList.add(next);
                while (cVar.hasNext()) {
                    arrayList.add(cVar.next());
                }
                listC = arrayList;
            } else {
                listC = C1.C(next);
            }
        } else {
            listC = t.f1032q;
        }
        int length = str.length();
        listC.size();
        int iV = B6.l.V(listC);
        ArrayList arrayList2 = new ArrayList();
        int i = 0;
        for (Object obj : listC) {
            int i5 = i + 1;
            String strSubstring = null;
            if (i < 0) {
                B6.l.Z();
                throw null;
            }
            String str2 = (String) obj;
            if ((i != 0 && i != iV) || !e.V(str2)) {
                int length2 = str2.length();
                int i8 = 0;
                while (true) {
                    if (i8 >= length2) {
                        i8 = -1;
                        break;
                    }
                    if (!X1.s(str2.charAt(i8))) {
                        break;
                    }
                    i8++;
                }
                if (i8 != -1 && n.L(str2, "|", i8, false)) {
                    strSubstring = str2.substring("|".length() + i8);
                    P6.g.d(strSubstring, "substring(...)");
                }
                if (strSubstring == null) {
                    strSubstring = str2;
                }
            }
            if (strSubstring != null) {
                arrayList2.add(strSubstring);
            }
            i = i5;
        }
        StringBuilder sb = new StringBuilder(length);
        B6.k.k0(arrayList2, sb, "\n", "", "", "...", null);
        return sb.toString();
    }
}
