@use "sass:string";
@use "../../functions/index" as fi;

// concat
@function concat($val) {
	$i: string.index($val, '-');
	$start: string.slice($val, 1, 1);

	@if  $i {
		$end: string.slice($val, ($i + 1), ($i + 1));

		@return #{$start}#{$end};
	} @else {
		@return #{$start};
	}
}

$base-options: null;

@mixin flex-arrts($attrs-map, $options: ()) {
	$prefix: fi.prefix($base-options, $options);

	@each $key, $attrs in $attrs-map {
		$short: concat($key);

		@each $value in $attrs {
			#{$prefix}#{$short}-#{concat($value)} {
				#{$key}: $value;
			}
		}
	}
}

@mixin flex-size($total, $options: ()) {
	$prefix: fi.prefix($base-options, $options);

	#{$prefix}f-1\/1 {
		flex: 0 0 100%;
	}

	@for $i from 2 through $total {
		@for $j from 1 through $i - 1 {
			#{$prefix}f-#{$j}\/#{$i} {
				flex: 0 0 fi.percentw($j, $i);
			}
		}
	}
}
