@charset "UTF-8";

// @description
// * merge function.
// * This function merges lists together and return all in a one list.

// @access private

// @version 1.5.0

// @author Khaled Mohamed

// @license MIT

// @repository: https://github.com/Black-Axis/sass-pire

// @namespace list

// @module list/merge

// @dependencies:
// * - meta.type-of (SASS function).
// * - list.join (SASS function).
// * - LibFunc.flatten-list (function).
// * - Error.throw (function).

// @param {List} $list...
// * A group of lists that may contain nested lists.

// @throw {Exception}
// * Throws an exception if the provided parameter is not a lists.

// @example
// * .example {
// *   content: merge((2, 4, 5, (12, 5, 6)), (22, 38), (44, ((323))));
// * }

// @output
// * .example {
// *   content: 2 4 5 12 5 6 22 38 44 323;
// * }

// @return {List} - Returns a merged list.

@use "sass:meta";
@use "sass:list";
@use "../../functions/list/flatten-list" as LibFunc;
@use "../../development-utils/toggle-error-message" as Error;

@function merge($lists...) {
    $merged-list: ();

    @each $value in $lists {
        @if meta.type-of($value) != list {
            @return Error.throw("The parameter of merge function must be in a list type.");
        }

        $flatten-one-list: LibFunc.flatten($value);
        $merged-list: list.join($merged-list, $flatten-one-list, space);
    }

    @return $merged-list;
}
