@charset "UTF-8";

@mixin only($params...) {
  @if length($params) == 0 {
    @error "Please pass an argument. The argument must be either a negative or positive number or list of numbers. Or pass one of the following predefined string values: 'first', 'last', 'odd', 'even'.";
  } @else if length($params) == 1 {
    $value: nth($params, 1);
    @if type-of($value) == "number" {
      @if $value < 0 {
        &:nth-last-of-type(#{$value * -1}) {
          @content;
        }
      } @else {
        &:nth-of-type(#{$value}) {
          @content;
        }
      }
    } @else if type-of($value) == "string" {
      @if $value == "odd" {
        &:nth-of-type(odd) {
          @content;
        }
      } @else if $value == "even" {
        &:nth-of-type(even) {
          @content;
        }
      } @else if $value == "first" {
        &:first-of-type {
          @content;
        }
      } @else if $value == "last" {
        &:last-of-type {
          @content;
        }
      } @else {
        // For class, id or attribute selectors.
        &#{$value} {
          @content;
        }
      }
    }
  } @else if length($params) > 1 {
    $list: ();
    @for $i from 1 through length($params) {
      $list: append($list, if(nth($params, $i) < 0, unquote("&:nth-last-of-type(#{nth($params, $i) * -1})"), unquote("&:nth-of-type(#{nth($params, $i)})")), comma);
    }
    #{$list} {
      @content;
    }
  }
}
