@charset "UTF-8";

// @description
// * is-in-list function.
// * This function checks if a given value exists in a provided list.

// @access private

// @version 1.3.0

// @author Khaled Mohamed

// @license MIT

// @repository: https://github.com/Black-Axis/sass-pire

// @namespace global

// @module global/is-in-list

// @dependencies:
// * - meta.type-of (SASS function).
// * - list.index (SASS function).
// * - Error.throw (function).

// @param {List} $list-name
// * The list to check if the second argument is in it or not.

// @param {Any} $value
// * The second argument to check for its existence in the provided list
// * at the first parameter.

// @throw {Exception}
// * Throws an exception if the first parameter is not a list or if the
// * second parameter is not found in the list.

// @example 1
// * .example1 {
// *   content: is-in-list((block, inline, flex), inline);
// * }

// @output 1
// * .example1 {
// *   content: true;
// * }

// @example 2
// * .example2 {
// *   content: is-in-list((12px, 14px, 16px), 18px);
// * }

// @output 2
// * .example2 {
// *   content: false;
// * }

// @return {Boolean} - Returns true if the second argument exists in the
// * list, and false otherwise.

@use "sass:meta";
@use "sass:list";
@use "../../functions/list/flatten-list" as LibFunc;
@use "../../development-utils/toggle-error-message" as Error;

@function is-in-list($list-name, $value) {
    @if meta.type-of($list-name) != list {
        @return Error.throw("The first parameter of is-in-list function must be in a list type.");
    }

    $flatten-list: LibFunc.flatten($list-name);

    @if not list.index($flatten-list, $value) {
        @return false;
    }

    @return true;
}
