// Utility generator
// Inspired by Bootstrap 4

@use "sass:list";
@use "sass:map";
@use "sass:meta";

@mixin generate($utility, $infix) {
    $values: map.get($utility, values);

    // If the values are a list or string, convert it into a map
    @if meta.type-of($values) == "string" or meta.type-of(list.nth($values, 1)) != "list" {
        $values: list.zip($values, $values);
    }

    @each $key, $value in $values {
        $properties: map.get($utility, property);
        $property-class: map.get($utility, class);
        $property-class-modifier: "";

        @if $key {
            $property-class-modifier: "-" + $key;
        }

        .#{$property-class + $infix + $property-class-modifier} {
            @each $property in $properties {
                // stylelint-disable-next-line declaration-no-important
                #{$property}: $value !important;
            }
        }
    }
}
