package com.ss.android.ugc.aweme.feed.model;

import X.M12;
import com.bytedance.covode.number.Covode;
import com.ss.android.ugc.aweme.profile.model.User;
import kotlin.h.b.n;

public final class DuetHelperKt {
    static {
        Covode.recordClassIndex(78904);
    }

    public static final boolean checkDuetSetting(Aweme aweme) {
        if (aweme.author == null) {
            return false;
        }
        User user = aweme.author;
        n.LIZIZ(user, "");
        int duetSetting = user.getDuetSetting();
        if (duetSetting == 0) {
            return true;
        }
        if (duetSetting != 1) {
            return false;
        }
        User user2 = aweme.author;
        n.LIZIZ(user2, "");
        if (user2.getFollowStatus() == 2) {
            return true;
        }
        return false;
    }

    public static final boolean canAddDuet(Aweme aweme, boolean z) {
        int i;
        M12.LIZ(aweme);
        InteractPermission interactPermission = aweme.interactPermission;
        if (interactPermission != null) {
            i = interactPermission.getDuet();
            if (i == 4) {
                return false;
            }
        } else {
            i = 0;
        }
        if ((z || (i != 2 && !aweme.isPrivate())) && aweme.canDuetVideoType() && !aweme.isWithPromotionalMusic() && aweme.duetSetting != 2) {
            return true;
        }
        return false;
    }

    public static final boolean setGrayForDuet(Aweme aweme, boolean z, boolean z2, boolean z3, boolean z4) {
        int i;
        M12.LIZ(aweme);
        boolean checkDuetSetting = checkDuetSetting(aweme);
        InteractPermission interactPermission = aweme.interactPermission;
        if (interactPermission != null) {
            i = interactPermission.getDuet();
        } else {
            i = 0;
        }
        if (z2 && i != 3 && (z || (checkDuetSetting && i != 1))) {
            User user = aweme.author;
            n.LIZIZ(user, "");
            if ((!user.isSecret() || z) && !z3 && !z4) {
                return false;
            }
        }
        return true;
    }
}
