@charset "UTF-8";

// @description
// * scale mixin.
// * This mixin provides a convenient way to apply scaling using the
// * `transform` property with proper vendor prefixes.
// * It supports both numerical values for scaling factors and predefined
// * keywords such as `inherit`, `initial`, `revert`, `unset`, and `none`.

// @access public

// @version 1.3.1

// @author Khaled Mohamed

// @license MIT

// @repository: https://github.com/Black-Axis/sass-pire

// @reference: https://developer.mozilla.org/en-US/docs/Web/CSS/transform

// @namespace transform

// @module transform/scale

// @dependencies:
// * - meta.type-of (SASS function).
// * - var.$main-units (variable).
// * - LibMixin.prefixing-all (mixin).
// * - Error.throw (function).

// @param {Number|String} $x
// * The scaling factor for the x-axis.
// * Default: 1.
// * If a number, it must be unitless.
// * If a string, it can be: (inherit, initial, revert, unset, none).

// @param {Number|String} $y
// * The scaling factor for the y-axis.
// * Default: $x.
// * If a number, it must be unitless.
// * If a string, it can be: (inherit, initial, revert, unset, none).

// @example
// * .example {
// *   @include scale(2);
// * }

// @output
// * .example {
// *   -webkit-transform: scale(2, 2);
// *   -moz-transform: scale(2, 2);
// *   -ms-transform: scale(2, 2);
// *   -o-transform: scale(2, 2);
// *   transform: scale(2, 2);
// * }

@use "sass:meta";
@use "sass:list";
@use "sass:math";
@use "../../abstract/global-variables" as var;
@use "../../mixins/vendor-prefixes/prefix" as LibMixin;
@use "../../development-utils/toggle-error-message" as Error;

@mixin scale($x: 1px, $y: $x) {
    $transform-props-values: (inherit, initial, revert, unset, none) !default;

    @if meta.type-of($x) == number and meta.type-of($y) == number {
        @if not list.index(var.$main-units, math.unit($x)) or not list.index(var.$main-units, math.unit($y)) {
            content: Error.throw("The parameter of scale mixin must has one of these units: (#{var.$main-units}).");
        } @else {
            @include LibMixin.prefixing-all(transform, scale($x, $y));
        }
    } @else if meta.type-of($x) == string and meta.type-of($y) == string {
        @if list.index($transform-props-values, $x) and list.index($transform-props-values, $y) {
            @include LibMixin.prefixing-all(transform, scale($x, $y));
        } @else {
            content: Error.throw(
                "The parameter of scale mixin must has one of these values: (#{$transform-props-values})."
            );
        }
    } @else if meta.type-of($x) == number and meta.type-of($y) == string {
        @if list.index(var.$main-units, math.unit($x)) and list.index($transform-props-values, $y) {
            @include LibMixin.prefixing-all(transform, scale($x, $y));
        } @else {
            content: Error.throw("The parameter x of scale mixin must has one of these units: (#{var.$main-units}).");
        }
    } @else if meta.type-of($x) == string and meta.type-of($y) == number {
        @if list.index(var.$main-units, math.unit($y)) and list.index($transform-props-values, $x) {
            @include LibMixin.prefixing-all(transform, scale($x, $y));
        } @else {
            content: Error.throw("The parameter y of scale mixin must has one of these units: (#{var.$main-units}).");
        }
    } @else {
        content: Error.throw("The value of scale mixin must be in a number or a string type.");
    }
}
