3 // scss-lint:disable ElsePlacement
 
   5 /// Transforms shorthand to its shortest possible form.
 
   7 /// @argument {list} $values
 
   8 ///   List of directional values.
 
  11 ///   $values: _compact-shorthand(10px 20px 10px 20px);
 
  14 ///   $values: 10px 20px;
 
  20 @function _compact-shorthand($values) {
 
  24   $b: if(length($values) < 2, $a, nth($values, 2));
 
  25   $c: if(length($values) < 3, $a, nth($values, 3));
 
  26   $d: if(length($values) < 2, $a, nth($values, if(length($values) < 4, 2, 4)));
 
  28   @if $a == 0 { $a: 0; }
 
  29   @if $b == 0 { $b: 0; }
 
  30   @if $c == 0 { $c: 0; }
 
  31   @if $d == 0 { $d: 0; }
 
  33   @if $a == $b and $a == $c and $a == $d { $output: $a;          }
 
  34   @else if $a == $c and $b == $d         { $output: $a $b;       }
 
  35   @else if $b == $d                      { $output: $a $b $c;    }
 
  36   @else                                  { $output: $a $b $c $d; }