@charset "UTF-8";

// @description
// * trim function.
// * This function removes all right and left whitespace from
// * a given string.

// @access public

// @version 1.0.0

// @license MIT

// @repository: https://github.com/Black-Axis/sass-pire

// @namespace global

// @module global/trim

// @dependencies:
// * - meta.type-of (SASS function).
// * - trim-start (function).
// * - trim-end (function).
// * - Error.throw (function).

// @update We updated the usage of the math library of Sass and added
// * more validations.

// @param {String} $str-value
// * The value which will be used to trim whitespace from two directions.

// @throw {Exception}
// * Throws an exception if the parameter is not a string.

// @example
// * .example {
// *   content: trim("    Just an example   ");
// * }

// @output
// * .example {
// *   content: "Just an example";
// * }

// @return {String} - A value after trim from start and end.

@use "sass:meta";
@use "sass:string";
@use "./trim-start" as LibFunc1;
@use "./trim-end" as LibFunc2;
@use "../../development-utils/toggle-error-message" as Error;

// stylelint-disable scss/at-rule-conditional-no-parentheses

@function trim($str-value) {
    @if meta.type-of($str-value) != string {
        @return Error.throw("The parameter of trim function must be in a string type.");
    }

    $second-trim: LibFunc2.trim-end($str-value);

    @return LibFunc1.trim-start($second-trim);
}
