package p402.p403;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
import kotlin.TypeCastException;
import p138.p176.p177.p242.p246.p251.C4303;
import p402.C6541;
import p402.p411.p412.InterfaceC6614;
import p402.p411.p413.C6635;

/* JADX INFO: renamed from: ގ.ފ.ނ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public class C6560 extends C6559 {
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static final <T, A extends Appendable> A m9771(Iterable<? extends T> iterable, A a, CharSequence charSequence, CharSequence charSequence2, CharSequence charSequence3, int i, CharSequence charSequence4, InterfaceC6614<? super T, ? extends CharSequence> interfaceC6614) {
        if (iterable == null) {
            C6635.m9824("$this$joinTo");
            throw null;
        }
        if (a == null) {
            C6635.m9824("buffer");
            throw null;
        }
        if (charSequence == null) {
            C6635.m9824("separator");
            throw null;
        }
        if (charSequence2 == null) {
            C6635.m9824("prefix");
            throw null;
        }
        if (charSequence3 == null) {
            C6635.m9824("postfix");
            throw null;
        }
        if (charSequence4 == null) {
            C6635.m9824("truncated");
            throw null;
        }
        a.append(charSequence2);
        int i2 = 0;
        for (T t : iterable) {
            i2++;
            if (i2 > 1) {
                a.append(charSequence);
            }
            if (i >= 0 && i2 > i) {
                break;
            }
            C4303.m7089(a, t, interfaceC6614);
        }
        if (i >= 0 && i2 > i) {
            a.append(charSequence4);
        }
        a.append(charSequence3);
        return a;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static final <T> T m9772(List<? extends T> list) {
        if (list == null) {
            C6635.m9824("$this$first");
            throw null;
        }
        if (list.isEmpty()) {
            throw new NoSuchElementException("List is empty.");
        }
        return list.get(0);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static final <T> T m9773(List<? extends T> list, int i) {
        if (list == null) {
            C6635.m9824("$this$getOrNull");
            throw null;
        }
        if (i < 0 || i > C4303.m6987((List) list)) {
            return null;
        }
        return list.get(i);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static final <K, V> V m9774(Map<K, ? extends V> map, K k) {
        if (map == null) {
            C6635.m9824("$this$getValue");
            throw null;
        }
        if (map instanceof InterfaceC6568) {
            return (V) ((InterfaceC6568) map).m9798(k);
        }
        V v = map.get(k);
        if (v != null || map.containsKey(k)) {
            return v;
        }
        throw new NoSuchElementException("Key " + k + " is missing in the map.");
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static /* synthetic */ String m9775(Iterable iterable, CharSequence charSequence, CharSequence charSequence2, CharSequence charSequence3, int i, CharSequence charSequence4, InterfaceC6614 interfaceC6614, int i2) {
        if ((i2 & 1) != 0) {
            charSequence = ", ";
        }
        CharSequence charSequence5 = charSequence;
        CharSequence charSequence6 = (i2 & 2) != 0 ? "" : charSequence2;
        CharSequence charSequence7 = (i2 & 4) != 0 ? "" : charSequence3;
        int i3 = (i2 & 8) != 0 ? -1 : i;
        if ((i2 & 16) != 0) {
            charSequence4 = "...";
        }
        CharSequence charSequence8 = charSequence4;
        InterfaceC6614 interfaceC66142 = (i2 & 32) != 0 ? null : interfaceC6614;
        if (iterable == null) {
            C6635.m9824("$this$joinToString");
            throw null;
        }
        if (charSequence5 == null) {
            C6635.m9824("separator");
            throw null;
        }
        if (charSequence6 == null) {
            C6635.m9824("prefix");
            throw null;
        }
        if (charSequence7 == null) {
            C6635.m9824("postfix");
            throw null;
        }
        if (charSequence8 == null) {
            C6635.m9824("truncated");
            throw null;
        }
        StringBuilder sb = new StringBuilder();
        m9771(iterable, sb, charSequence5, charSequence6, charSequence7, i3, charSequence8, interfaceC66142);
        String string = sb.toString();
        C6635.m9823((Object) string, "joinTo(StringBuilder(), …ed, transform).toString()");
        return string;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static final <T, C extends Collection<? super T>> C m9776(Iterable<? extends T> iterable, C c) {
        if (iterable == null) {
            C6635.m9824("$this$toCollection");
            throw null;
        }
        if (c == null) {
            C6635.m9824("destination");
            throw null;
        }
        Iterator<? extends T> it = iterable.iterator();
        while (it.hasNext()) {
            c.add(it.next());
        }
        return c;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static final <T> List<T> m9777(Iterable<? extends T> iterable) {
        if (iterable == null) {
            C6635.m9824("$this$toList");
            throw null;
        }
        if (!(iterable instanceof Collection)) {
            return C4303.m7184(m9793(iterable));
        }
        Collection collection = (Collection) iterable;
        int size = collection.size();
        if (size == 0) {
            return C6563.f19343;
        }
        if (size != 1) {
            return m9779(collection);
        }
        return C4303.m7191(iterable instanceof List ? ((List) iterable).get(0) : iterable.iterator().next());
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static final <T> List<T> m9778(Iterable<? extends T> iterable, Comparator<? super T> comparator) {
        if (iterable == null) {
            C6635.m9824("$this$sortedWith");
            throw null;
        }
        if (comparator == null) {
            C6635.m9824("comparator");
            throw null;
        }
        if (!(iterable instanceof Collection)) {
            List<T> listM9793 = m9793(iterable);
            C4303.m7096((List) listM9793, (Comparator) comparator);
            return listM9793;
        }
        Collection collection = (Collection) iterable;
        if (collection.size() <= 1) {
            return m9777(iterable);
        }
        Object[] array = collection.toArray(new Object[0]);
        if (array == null) {
            throw new TypeCastException("null cannot be cast to non-null type kotlin.Array<T>");
        }
        m9787(array, comparator);
        return m9781(array);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static final <T> List<T> m9779(Collection<? extends T> collection) {
        if (collection != null) {
            return new ArrayList(collection);
        }
        C6635.m9824("$this$toMutableList");
        throw null;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static final <T> List<T> m9780(Collection<? extends T> collection, T t) {
        if (collection == null) {
            C6635.m9824("$this$plus");
            throw null;
        }
        ArrayList arrayList = new ArrayList(collection.size() + 1);
        arrayList.addAll(collection);
        arrayList.add(t);
        return arrayList;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static final <T> List<T> m9781(T[] tArr) {
        if (tArr == null) {
            C6635.m9824("$this$asList");
            throw null;
        }
        List<T> listAsList = Arrays.asList(tArr);
        C6635.m9823((Object) listAsList, "ArraysUtilJVM.asList(this)");
        return listAsList;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static final <K, V, M extends Map<? super K, ? super V>> M m9782(Iterable<? extends C6541<? extends K, ? extends V>> iterable, M m) {
        if (iterable == null) {
            C6635.m9824("$this$toMap");
            throw null;
        }
        if (m == null) {
            C6635.m9824("destination");
            throw null;
        }
        for (C6541<? extends K, ? extends V> c6541 : iterable) {
            m.put(c6541.f19316, c6541.f19317);
        }
        return m;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static final <K, V> Map<K, V> m9783(Map<? extends K, ? extends V> map) {
        if (map != null) {
            return new LinkedHashMap(map);
        }
        C6635.m9824("$this$toMutableMap");
        throw null;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static final <K, V> Map<K, V> m9784(C6541<? extends K, ? extends V>... c6541Arr) {
        if (c6541Arr == null) {
            C6635.m9824("pairs");
            throw null;
        }
        if (c6541Arr.length <= 0) {
            return C6564.f19344;
        }
        LinkedHashMap linkedHashMap = new LinkedHashMap(C4303.m7176(c6541Arr.length));
        for (C6541<? extends K, ? extends V> c6541 : c6541Arr) {
            linkedHashMap.put(c6541.f19316, c6541.f19317);
        }
        return linkedHashMap;
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static final <T> Set<T> m9785(Set<? extends T> set) {
        if (set == 0) {
            C6635.m9824("$this$optimizeReadOnlySet");
            throw null;
        }
        int size = set.size();
        if (size == 0) {
            return C6565.f19345;
        }
        if (size != 1) {
            return set;
        }
        Set<T> setSingleton = Collections.singleton(set.iterator().next());
        C6635.m9823((Object) setSingleton, "java.util.Collections.singleton(element)");
        return setSingleton;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static /* synthetic */ void m9786(Object[] objArr, Object obj, int i, int i2, int i3) {
        if ((i3 & 2) != 0) {
            i = 0;
        }
        if ((i3 & 4) != 0) {
            i2 = objArr.length;
        }
        if (objArr != null) {
            Arrays.fill(objArr, i, i2, obj);
        } else {
            C6635.m9824("$this$fill");
            throw null;
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static final <T> void m9787(T[] tArr, Comparator<? super T> comparator) {
        if (tArr == null) {
            C6635.m9824("$this$sortWith");
            throw null;
        }
        if (comparator == null) {
            C6635.m9824("comparator");
            throw null;
        }
        if (tArr.length > 1) {
            Arrays.sort(tArr, comparator);
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static final byte[] m9788(byte[] bArr, int i, int i2) {
        if (bArr == null) {
            C6635.m9824("$this$copyOfRangeImpl");
            throw null;
        }
        int length = bArr.length;
        if (i2 <= length) {
            byte[] bArrCopyOfRange = Arrays.copyOfRange(bArr, i, i2);
            C6635.m9823((Object) bArrCopyOfRange, "java.util.Arrays.copyOfR…this, fromIndex, toIndex)");
            return bArrCopyOfRange;
        }
        throw new IndexOutOfBoundsException("toIndex (" + i2 + ") is greater than size (" + length + ").");
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static final byte[] m9789(byte[] bArr, byte[] bArr2, int i, int i2, int i3) {
        if (bArr == null) {
            C6635.m9824("$this$copyInto");
            throw null;
        }
        if (bArr2 != null) {
            System.arraycopy(bArr, i2, bArr2, i, i3 - i2);
            return bArr2;
        }
        C6635.m9824("destination");
        throw null;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static /* synthetic */ byte[] m9790(byte[] bArr, byte[] bArr2, int i, int i2, int i3, int i4) {
        if ((i4 & 2) != 0) {
            i = 0;
        }
        if ((i4 & 4) != 0) {
            i2 = 0;
        }
        if ((i4 & 8) != 0) {
            i3 = bArr.length;
        }
        m9789(bArr, bArr2, i, i2, i3);
        return bArr2;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static /* synthetic */ Object[] m9791(Object[] objArr, Object[] objArr2, int i, int i2, int i3, int i4) {
        if ((i4 & 2) != 0) {
            i = 0;
        }
        if ((i4 & 4) != 0) {
            i2 = 0;
        }
        if ((i4 & 8) != 0) {
            i3 = objArr.length;
        }
        if (objArr == null) {
            C6635.m9824("$this$copyInto");
            throw null;
        }
        if (objArr2 != null) {
            System.arraycopy(objArr, i2, objArr2, i, i3 - i2);
            return objArr2;
        }
        C6635.m9824("destination");
        throw null;
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public static final <T> T m9792(List<? extends T> list) {
        if (list == null) {
            C6635.m9824("$this$firstOrNull");
            throw null;
        }
        if (list.isEmpty()) {
            return null;
        }
        return list.get(0);
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public static final <T> List<T> m9793(Iterable<? extends T> iterable) {
        if (iterable == null) {
            C6635.m9824("$this$toMutableList");
            throw null;
        }
        if (iterable instanceof Collection) {
            return m9779((Collection) iterable);
        }
        ArrayList arrayList = new ArrayList();
        m9776(iterable, arrayList);
        return arrayList;
    }

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public static final <T> T m9794(List<? extends T> list) {
        if (list == null) {
            C6635.m9824("$this$last");
            throw null;
        }
        if (list.isEmpty()) {
            throw new NoSuchElementException("List is empty.");
        }
        return list.get(C4303.m6987((List) list));
    }

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public static final <T> Set<T> m9795(Iterable<? extends T> iterable) {
        if (iterable == null) {
            C6635.m9824("$this$toSet");
            throw null;
        }
        if (!(iterable instanceof Collection)) {
            LinkedHashSet linkedHashSet = new LinkedHashSet();
            m9776(iterable, linkedHashSet);
            return m9785((Set) linkedHashSet);
        }
        Collection collection = (Collection) iterable;
        int size = collection.size();
        if (size == 0) {
            return C6565.f19345;
        }
        if (size != 1) {
            LinkedHashSet linkedHashSet2 = new LinkedHashSet(C4303.m7176(collection.size()));
            m9776(iterable, linkedHashSet2);
            return linkedHashSet2;
        }
        Set<T> setSingleton = Collections.singleton(iterable instanceof List ? ((List) iterable).get(0) : iterable.iterator().next());
        C6635.m9823((Object) setSingleton, "java.util.Collections.singleton(element)");
        return setSingleton;
    }

    /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
    public static final <T> T m9796(List<? extends T> list) {
        if (list == null) {
            C6635.m9824("$this$lastOrNull");
            throw null;
        }
        if (list.isEmpty()) {
            return null;
        }
        return list.get(list.size() - 1);
    }
}
